Skip to content

Commit d7483e9

Browse files
committed
[mlir][dxsa] Add dcl_tessellator_output_primitive instruction
Example: dxsa.dcl_tessellator_output_primitive output_triangle_cw Signed-off-by: Vladimir Shiryaev <tagolog@users.noreply.github.com>
1 parent 47303ee commit d7483e9

4 files changed

Lines changed: 72 additions & 0 deletions

File tree

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

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,28 @@ def DXSA_GlobalFlagsAttr :
5151
let assemblyFormat = "`<` $value `>`";
5252
}
5353

54+
def DXSA_TessellatorOutputPrimitiveType_OutputPoint : I32EnumAttrCase<"output_point", 1>;
55+
def DXSA_TessellatorOutputPrimitiveType_OutputLine : I32EnumAttrCase<"output_line", 2>;
56+
def DXSA_TessellatorOutputPrimitiveType_OutputTriangleCw : I32EnumAttrCase<"output_triangle_cw", 3>;
57+
def DXSA_TessellatorOutputPrimitiveType_OutputTriangleCcw : I32EnumAttrCase<"output_triangle_ccw", 4>;
58+
59+
def DXSA_TessellatorOutputPrimitiveType : I32EnumAttr<
60+
"TessellatorOutputPrimitiveType", "tessellator output primitive type", [
61+
DXSA_TessellatorOutputPrimitiveType_OutputPoint,
62+
DXSA_TessellatorOutputPrimitiveType_OutputLine,
63+
DXSA_TessellatorOutputPrimitiveType_OutputTriangleCw,
64+
DXSA_TessellatorOutputPrimitiveType_OutputTriangleCcw
65+
]> {
66+
let cppNamespace = "::mlir::dxsa";
67+
let genSpecializedAttr = 0;
68+
}
69+
70+
def DXSA_TessellatorOutputPrimitiveTypeAttr :
71+
EnumAttr<DXSADialect, DXSA_TessellatorOutputPrimitiveType,
72+
"tessellator_output_primitive_type"> {
73+
let assemblyFormat = "$value";
74+
}
75+
5476
//===----------------------------------------------------------------------===//
5577
// DXSA op definitions
5678
//===----------------------------------------------------------------------===//
@@ -196,4 +218,21 @@ def DXSA_DclOutputControlPointCount :
196218
let assemblyFormat = [{ $count attr-dict }];
197219
}
198220

221+
def DXSA_DclTessellatorOutputPrimitive
222+
: DXSA_Op<"dcl_tessellator_output_primitive"> {
223+
let summary = "declares the tessellator output primitive type";
224+
let description = [{
225+
The `dxsa.dcl_tessellator_output_primitive` operation declares the
226+
tessellator output primitive type.
227+
228+
Example:
229+
230+
```mlir
231+
dxsa.dcl_tessellator_output_primitive output_triangle_cw
232+
```
233+
}];
234+
let arguments = (ins DXSA_TessellatorOutputPrimitiveTypeAttr:$type);
235+
let assemblyFormat = "$type attr-dict";
236+
}
237+
199238
#endif // DXSA_OPS

mlir/lib/Target/DXSA/BinaryParser.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,15 @@ class DXBuilder {
529529
builder, loc, builder.getI32IntegerAttr(count));
530530
}
531531

532+
Instruction buildDclTessellatorOutputPrimitive(
533+
dxsa::TessellatorOutputPrimitiveType outputPrimitiveType, Location loc) {
534+
auto outputPrimitiveTypeAttr =
535+
dxsa::TessellatorOutputPrimitiveTypeAttr::get(builder.getContext(),
536+
outputPrimitiveType);
537+
return dxsa::DclTessellatorOutputPrimitive::create(builder, loc,
538+
outputPrimitiveTypeAttr);
539+
}
540+
532541
private:
533542
MLIRContext *context;
534543
ModuleOp module;
@@ -891,6 +900,19 @@ class Parser {
891900
return builder.buildDclOutputControlPointCount(count, loc);
892901
}
893902

903+
FailureOr<Instruction>
904+
parseDclTessellatorOutputPrimitive(uint32_t opcodeToken, Location loc) {
905+
auto rawOutputPrimitiveType =
906+
DECODE_D3D11_SB_TESS_OUTPUT_PRIMITIVE(opcodeToken);
907+
auto outputPrimitiveType =
908+
dxsa::symbolizeTessellatorOutputPrimitiveType(rawOutputPrimitiveType);
909+
if (!outputPrimitiveType)
910+
return emitError(loc, "unknown tessellator output primitive type: ")
911+
<< rawOutputPrimitiveType;
912+
return builder.buildDclTessellatorOutputPrimitive(*outputPrimitiveType,
913+
loc);
914+
}
915+
894916
OptionalParseResult parseDclInstruction(uint32_t opcodeToken, Location loc,
895917
Instruction &out) {
896918
FailureOr<Instruction> result;
@@ -907,6 +929,9 @@ class Parser {
907929
case D3D11_SB_OPCODE_DCL_OUTPUT_CONTROL_POINT_COUNT:
908930
result = parseDclOutputControlPointCount(opcodeToken, loc);
909931
break;
932+
case D3D11_SB_OPCODE_DCL_TESS_OUTPUT_PRIMITIVE:
933+
result = parseDclTessellatorOutputPrimitive(opcodeToken, loc);
934+
break;
910935
default:
911936
return std::nullopt;
912937
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// RUN: mlir-translate --import-dxsa-bin %S/inputs/dcl_tessellator_output_primitive.bin | FileCheck %s
2+
3+
// CHECK: module {
4+
// CHECK-NEXT: dxsa.dcl_tessellator_output_primitive output_point
5+
// CHECK-NEXT: dxsa.dcl_tessellator_output_primitive output_line
6+
// CHECK-NEXT: dxsa.dcl_tessellator_output_primitive output_triangle_cw
7+
// CHECK-NEXT: dxsa.dcl_tessellator_output_primitive output_triangle_ccw
8+
// CHECK-NEXT: }
16 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)