Skip to content

Commit 6d7d883

Browse files
committed
[mlir][dxsa] Add dcl_tessellator_partitioning instruction
Example: dxsa.dcl_tessellator_partitioning partitioning_integer Signed-off-by: Vladimir Shiryaev <tagolog@users.noreply.github.com>
1 parent 7845f17 commit 6d7d883

4 files changed

Lines changed: 69 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
@@ -112,6 +112,28 @@ def DXSA_OutputPrimitiveTopologyAttr :
112112
let assemblyFormat = "$value";
113113
}
114114

115+
def DXSA_TessellatorPartitioningMode_Integer : I32EnumAttrCase<"partitioning_integer", 1>;
116+
def DXSA_TessellatorPartitioningMode_Pow2 : I32EnumAttrCase<"partitioning_pow2", 2>;
117+
def DXSA_TessellatorPartitioningMode_FractionalOdd : I32EnumAttrCase<"partitioning_fractional_odd", 3>;
118+
def DXSA_TessellatorPartitioningMode_FractionalEven : I32EnumAttrCase<"partitioning_fractional_even", 4>;
119+
120+
def DXSA_TessellatorPartitioningMode : I32EnumAttr<
121+
"TessellatorPartitioningMode", "tessellator partitioning mode", [
122+
DXSA_TessellatorPartitioningMode_Integer,
123+
DXSA_TessellatorPartitioningMode_Pow2,
124+
DXSA_TessellatorPartitioningMode_FractionalOdd,
125+
DXSA_TessellatorPartitioningMode_FractionalEven
126+
]> {
127+
let cppNamespace = "::mlir::dxsa";
128+
let genSpecializedAttr = 0;
129+
}
130+
131+
def DXSA_TessellatorPartitioningModeAttr :
132+
EnumAttr<DXSADialect, DXSA_TessellatorPartitioningMode,
133+
"tessellator_partitioning_mode"> {
134+
let assemblyFormat = "$value";
135+
}
136+
115137
//===----------------------------------------------------------------------===//
116138
// DXSA op definitions
117139
//===----------------------------------------------------------------------===//
@@ -307,4 +329,21 @@ def DXSA_DclOutputTopology : DXSA_Op<"dcl_output_topology"> {
307329
let assemblyFormat = "$topology attr-dict";
308330
}
309331

332+
def DXSA_DclTessellatorPartitioning
333+
: DXSA_Op<"dcl_tessellator_partitioning"> {
334+
let summary = "declares the tessellator partitioning mode";
335+
let description = [{
336+
The `dxsa.dcl_tessellator_partitioning` operation declares the
337+
tessellator partitioning mode in a Hull Shader declaration section.
338+
339+
Example:
340+
341+
```mlir
342+
dxsa.dcl_tessellator_partitioning partitioning_integer
343+
```
344+
}];
345+
let arguments = (ins DXSA_TessellatorPartitioningModeAttr:$partitioningMode);
346+
let assemblyFormat = "$partitioningMode attr-dict";
347+
}
348+
310349
#endif // DXSA_OPS

mlir/lib/Target/DXSA/BinaryParser.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,14 @@ class DXBuilder {
553553
return dxsa::DclOutputTopology::create(builder, loc, outputTopologyAttr);
554554
}
555555

556+
Instruction buildDclTessellatorPartitioning(
557+
dxsa::TessellatorPartitioningMode partitioningMode, Location loc) {
558+
auto partitioningModeAttr = dxsa::TessellatorPartitioningModeAttr::get(
559+
builder.getContext(), partitioningMode);
560+
return dxsa::DclTessellatorPartitioning::create(builder, loc,
561+
partitioningModeAttr);
562+
}
563+
556564
private:
557565
MLIRContext *context;
558566
ModuleOp module;
@@ -949,6 +957,17 @@ class Parser {
949957
return builder.buildDclOutputTopology(*outputTopology, loc);
950958
}
951959

960+
FailureOr<Instruction> parseDclTessellatorPartitioning(uint32_t opcodeToken,
961+
Location loc) {
962+
auto rawPartitioningMode = DECODE_D3D11_SB_TESS_PARTITIONING(opcodeToken);
963+
auto partitioningMode =
964+
dxsa::symbolizeTessellatorPartitioningMode(rawPartitioningMode);
965+
if (!partitioningMode)
966+
return emitError(loc, "unknown tessellator partitioning mode: ")
967+
<< rawPartitioningMode;
968+
return builder.buildDclTessellatorPartitioning(*partitioningMode, loc);
969+
}
970+
952971
OptionalParseResult parseDclInstruction(uint32_t opcodeToken, Location loc,
953972
Instruction &out) {
954973
FailureOr<Instruction> result;
@@ -971,6 +990,9 @@ class Parser {
971990
case D3D11_SB_OPCODE_DCL_TESS_OUTPUT_PRIMITIVE:
972991
result = parseDclTessellatorOutputPrimitive(opcodeToken, loc);
973992
break;
993+
case D3D11_SB_OPCODE_DCL_TESS_PARTITIONING:
994+
result = parseDclTessellatorPartitioning(opcodeToken, loc);
995+
break;
974996
case D3D10_SB_OPCODE_DCL_GS_OUTPUT_PRIMITIVE_TOPOLOGY:
975997
result = parseDclOutputTopology(opcodeToken, loc);
976998
break;
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_partitioning.bin | FileCheck %s
2+
3+
// CHECK: module {
4+
// CHECK-NEXT: dxsa.dcl_tessellator_partitioning partitioning_integer
5+
// CHECK-NEXT: dxsa.dcl_tessellator_partitioning partitioning_pow2
6+
// CHECK-NEXT: dxsa.dcl_tessellator_partitioning partitioning_fractional_odd
7+
// CHECK-NEXT: dxsa.dcl_tessellator_partitioning partitioning_fractional_even
8+
// CHECK-NEXT: }
16 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)