Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions mlir/include/mlir/Dialect/DXSA/IR/DXSAOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,28 @@ def DXSA_GlobalFlagsAttr :
let assemblyFormat = "`<` $value `>`";
}

def DXSA_TessellatorOutputPrimitiveType_OutputPoint : I32EnumAttrCase<"output_point", 1>;
def DXSA_TessellatorOutputPrimitiveType_OutputLine : I32EnumAttrCase<"output_line", 2>;
def DXSA_TessellatorOutputPrimitiveType_OutputTriangleCw : I32EnumAttrCase<"output_triangle_cw", 3>;
def DXSA_TessellatorOutputPrimitiveType_OutputTriangleCcw : I32EnumAttrCase<"output_triangle_ccw", 4>;

def DXSA_TessellatorOutputPrimitiveType : I32EnumAttr<
"TessellatorOutputPrimitiveType", "tessellator output primitive type", [
DXSA_TessellatorOutputPrimitiveType_OutputPoint,
DXSA_TessellatorOutputPrimitiveType_OutputLine,
DXSA_TessellatorOutputPrimitiveType_OutputTriangleCw,
DXSA_TessellatorOutputPrimitiveType_OutputTriangleCcw
]> {
let cppNamespace = "::mlir::dxsa";
let genSpecializedAttr = 0;
}

def DXSA_TessellatorOutputPrimitiveTypeAttr :
EnumAttr<DXSADialect, DXSA_TessellatorOutputPrimitiveType,
"tessellator_output_primitive_type"> {
let assemblyFormat = "$value";
}

//===----------------------------------------------------------------------===//
// DXSA op definitions
//===----------------------------------------------------------------------===//
Expand Down Expand Up @@ -196,4 +218,21 @@ def DXSA_DclOutputControlPointCount :
let assemblyFormat = [{ $count attr-dict }];
}

def DXSA_DclTessellatorOutputPrimitive
: DXSA_Op<"dcl_tessellator_output_primitive"> {
let summary = "declares the tessellator output primitive type";
let description = [{
The `dxsa.dcl_tessellator_output_primitive` operation declares the
tessellator output primitive type.

Example:

```mlir
dxsa.dcl_tessellator_output_primitive output_triangle_cw
```
}];
let arguments = (ins DXSA_TessellatorOutputPrimitiveTypeAttr:$type);
let assemblyFormat = "$type attr-dict";
}

#endif // DXSA_OPS
25 changes: 25 additions & 0 deletions mlir/lib/Target/DXSA/BinaryParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,15 @@ class DXBuilder {
builder, loc, builder.getI32IntegerAttr(count));
}

Instruction buildDclTessellatorOutputPrimitive(
dxsa::TessellatorOutputPrimitiveType outputPrimitiveType, Location loc) {
auto outputPrimitiveTypeAttr =
dxsa::TessellatorOutputPrimitiveTypeAttr::get(builder.getContext(),
outputPrimitiveType);
return dxsa::DclTessellatorOutputPrimitive::create(builder, loc,
outputPrimitiveTypeAttr);
}

private:
MLIRContext *context;
ModuleOp module;
Expand Down Expand Up @@ -891,6 +900,19 @@ class Parser {
return builder.buildDclOutputControlPointCount(count, loc);
}

FailureOr<Instruction>
parseDclTessellatorOutputPrimitive(uint32_t opcodeToken, Location loc) {
auto rawOutputPrimitiveType =
DECODE_D3D11_SB_TESS_OUTPUT_PRIMITIVE(opcodeToken);
auto outputPrimitiveType =
dxsa::symbolizeTessellatorOutputPrimitiveType(rawOutputPrimitiveType);
if (!outputPrimitiveType)
return emitError(loc, "unknown tessellator output primitive type: ")
<< rawOutputPrimitiveType;
return builder.buildDclTessellatorOutputPrimitive(*outputPrimitiveType,
loc);
}

OptionalParseResult parseDclInstruction(uint32_t opcodeToken, Location loc,
Instruction &out) {
FailureOr<Instruction> result;
Expand All @@ -907,6 +929,9 @@ class Parser {
case D3D11_SB_OPCODE_DCL_OUTPUT_CONTROL_POINT_COUNT:
result = parseDclOutputControlPointCount(opcodeToken, loc);
break;
case D3D11_SB_OPCODE_DCL_TESS_OUTPUT_PRIMITIVE:
result = parseDclTessellatorOutputPrimitive(opcodeToken, loc);
break;
default:
return std::nullopt;
}
Expand Down
8 changes: 8 additions & 0 deletions mlir/test/Target/DXSA/dcl_tessellator_output_primitive.mlir
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// RUN: mlir-translate --import-dxsa-bin %S/inputs/dcl_tessellator_output_primitive.bin | FileCheck %s

// CHECK: module {
// CHECK-NEXT: dxsa.dcl_tessellator_output_primitive output_point
// CHECK-NEXT: dxsa.dcl_tessellator_output_primitive output_line
// CHECK-NEXT: dxsa.dcl_tessellator_output_primitive output_triangle_cw
// CHECK-NEXT: dxsa.dcl_tessellator_output_primitive output_triangle_ccw
// CHECK-NEXT: }
Binary file not shown.