Skip to content

Commit 8e2bba9

Browse files
Andrew Savonichevasavonic
authored andcommitted
[mlir][dxsa] Add sample instruction
Sample instruction takes an address, a resource (texture), a sampler, and writes texture data to the destination register. There are several optional that can be present: - Offset is encoded as an extended opcode. - LOD clamp and feeback for sample_cl_s. The spec mentions clamp and feedback as optional, but DXC decodes them both. It is possible that they are always present as operands, but can be null. Other extended instruction are added for other resource instructions, and not enabled for sample instruction. Feedback (ClampFeedback) and Offset are both supposed to be optional attributes. MLIR parser is not able to handle cases where feedback is present, but offset is absent, so and fails roundtrip verifier tests. Therefore such instructions are separate, and feedback operand is not optional.
1 parent 224d480 commit 8e2bba9

10 files changed

Lines changed: 988 additions & 0 deletions

File tree

mlir/include/mlir/Dialect/DXSA/IR/DXSAResourceOps.td

Lines changed: 428 additions & 0 deletions
Large diffs are not rendered by default.

mlir/lib/Dialect/DXSA/IR/DXSAOperand.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -991,3 +991,18 @@ void SrcOperandAttr::print(AsmPrinter &printer) const {
991991
printNegAndAbsModifier(printer, getModifier(),
992992
[&] { printSrcOperandBody(printer, *this); });
993993
}
994+
995+
LogicalResult
996+
SampleOffsetAttr::verify(function_ref<InFlightDiagnostic()> emitError,
997+
int32_t u, int32_t v, int32_t w) {
998+
int32_t values[] = {u, v, w};
999+
for (int32_t value : values) {
1000+
if (value < -8 || value > 7) {
1001+
return emitError()
1002+
<< "sample offsets must be 4 bit 2's complement numbers, "
1003+
"having integer range [-8,7], got "
1004+
<< value;
1005+
}
1006+
}
1007+
return success();
1008+
}

0 commit comments

Comments
 (0)