Skip to content

Commit 7fc9977

Browse files
committed
[mlir][dxsa] Add dcl_tessellator_domain instruction
Example: dxsa.dcl_tessellator_domain domain_quad Signed-off-by: Vladimir Shiryaev <tagolog@users.noreply.github.com>
1 parent cd6fa32 commit 7fc9977

4 files changed

Lines changed: 62 additions & 0 deletions

File tree

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

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

54+
def DXSA_TessellatorDomain_Isoline : I32EnumAttrCase<"domain_isoline", 1>;
55+
def DXSA_TessellatorDomain_Tri : I32EnumAttrCase<"domain_tri", 2>;
56+
def DXSA_TessellatorDomain_Quad : I32EnumAttrCase<"domain_quad", 3>;
57+
58+
def DXSA_TessellatorDomain : I32EnumAttr<
59+
"TessellatorDomain", "tessellator domain", [
60+
DXSA_TessellatorDomain_Isoline,
61+
DXSA_TessellatorDomain_Tri,
62+
DXSA_TessellatorDomain_Quad
63+
]> {
64+
let cppNamespace = "::mlir::dxsa";
65+
let genSpecializedAttr = 0;
66+
}
67+
68+
def DXSA_TessellatorDomainAttr :
69+
EnumAttr<DXSADialect, DXSA_TessellatorDomain, "tessellator_domain"> {
70+
let assemblyFormat = "$value";
71+
}
72+
5473
def DXSA_TessellatorOutputPrimitiveType_OutputPoint : I32EnumAttrCase<"output_point", 1>;
5574
def DXSA_TessellatorOutputPrimitiveType_OutputLine : I32EnumAttrCase<"output_line", 2>;
5675
def DXSA_TessellatorOutputPrimitiveType_OutputTriangleCw : I32EnumAttrCase<"output_triangle_cw", 3>;
@@ -238,6 +257,23 @@ def DXSA_DclOutputControlPointCount :
238257
let assemblyFormat = [{ $count attr-dict }];
239258
}
240259

260+
def DXSA_DclTessellatorDomain : DXSA_Op<"dcl_tessellator_domain"> {
261+
let summary = "declares the tessellator domain";
262+
let description = [{
263+
The `dxsa.dcl_tessellator_domain` operation declares the tessellator
264+
domain.
265+
266+
Example:
267+
268+
```mlir
269+
dxsa.dcl_tessellator_domain domain_quad
270+
```
271+
}];
272+
273+
let arguments = (ins DXSA_TessellatorDomainAttr:$domain);
274+
let assemblyFormat = "$domain attr-dict";
275+
}
276+
241277
def DXSA_DclTessellatorOutputPrimitive
242278
: DXSA_Op<"dcl_tessellator_output_primitive"> {
243279
let summary = "declares the tessellator output primitive type";

mlir/lib/Target/DXSA/BinaryParser.cpp

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

532+
Instruction buildDclTessellatorDomain(dxsa::TessellatorDomain domain,
533+
Location loc) {
534+
auto domainAttr =
535+
dxsa::TessellatorDomainAttr::get(builder.getContext(), domain);
536+
return dxsa::DclTessellatorDomain::create(builder, loc, domainAttr);
537+
}
538+
532539
Instruction buildDclTessellatorOutputPrimitive(
533540
dxsa::TessellatorOutputPrimitiveType outputPrimitiveType, Location loc) {
534541
auto outputPrimitiveTypeAttr =
@@ -908,6 +915,15 @@ class Parser {
908915
return builder.buildDclOutputControlPointCount(count, loc);
909916
}
910917

918+
FailureOr<Instruction> parseDclTessellatorDomain(uint32_t opcodeToken,
919+
Location loc) {
920+
auto rawDomain = DECODE_D3D11_SB_TESS_DOMAIN(opcodeToken);
921+
auto domain = dxsa::symbolizeTessellatorDomain(rawDomain);
922+
if (!domain)
923+
return emitError(loc, "unknown tessellator domain: ") << rawDomain;
924+
return builder.buildDclTessellatorDomain(*domain, loc);
925+
}
926+
911927
FailureOr<Instruction>
912928
parseDclTessellatorOutputPrimitive(uint32_t opcodeToken, Location loc) {
913929
auto rawOutputPrimitiveType =
@@ -949,6 +965,9 @@ class Parser {
949965
case D3D11_SB_OPCODE_DCL_OUTPUT_CONTROL_POINT_COUNT:
950966
result = parseDclOutputControlPointCount(opcodeToken, loc);
951967
break;
968+
case D3D11_SB_OPCODE_DCL_TESS_DOMAIN:
969+
result = parseDclTessellatorDomain(opcodeToken, loc);
970+
break;
952971
case D3D11_SB_OPCODE_DCL_TESS_OUTPUT_PRIMITIVE:
953972
result = parseDclTessellatorOutputPrimitive(opcodeToken, loc);
954973
break;
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// RUN: mlir-translate --import-dxsa-bin %S/inputs/dcl_tessellator_domain.bin | FileCheck %s
2+
3+
// CHECK: module {
4+
// CHECK-NEXT: dxsa.dcl_tessellator_domain domain_isoline
5+
// CHECK-NEXT: dxsa.dcl_tessellator_domain domain_tri
6+
// CHECK-NEXT: dxsa.dcl_tessellator_domain domain_quad
7+
// CHECK-NEXT: }
12 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)