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
36 changes: 36 additions & 0 deletions mlir/include/mlir/Dialect/DXSA/IR/DXSAOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,26 @@ def DXSA_TessellatorOutputPrimitiveTypeAttr :
let assemblyFormat = "$value";
}

def DXSA_OutputPrimitiveTopology_PointList : I32EnumAttrCase<"pointlist", 1>;
def DXSA_OutputPrimitiveTopology_LineStrip : I32EnumAttrCase<"linestrip", 3>;
def DXSA_OutputPrimitiveTopology_TriangleStrip : I32EnumAttrCase<"trianglestrip", 5>;

def DXSA_OutputPrimitiveTopology : I32EnumAttr<
"OutputPrimitiveTopology", "shader output primitive topology", [
DXSA_OutputPrimitiveTopology_PointList,
DXSA_OutputPrimitiveTopology_LineStrip,
DXSA_OutputPrimitiveTopology_TriangleStrip
]> {
let cppNamespace = "::mlir::dxsa";
let genSpecializedAttr = 0;
}

def DXSA_OutputPrimitiveTopologyAttr :
EnumAttr<DXSADialect, DXSA_OutputPrimitiveTopology,
"output_primitive_topology"> {
let assemblyFormat = "$value";
}

//===----------------------------------------------------------------------===//
// DXSA op definitions
//===----------------------------------------------------------------------===//
Expand Down Expand Up @@ -235,4 +255,20 @@ def DXSA_DclTessellatorOutputPrimitive
let assemblyFormat = "$type attr-dict";
}

def DXSA_DclOutputTopology : DXSA_Op<"dcl_output_topology"> {
let summary = "declare what primitive topology the shader generates as output";
let description = [{
The `dxsa.dcl_output_topology` operation declares the primitive topology
that the shader generates as output.

Example:

```mlir
dxsa.dcl_output_topology trianglestrip
```
}];
let arguments = (ins DXSA_OutputPrimitiveTopologyAttr:$topology);
let assemblyFormat = "$topology attr-dict";
}

#endif // DXSA_OPS
23 changes: 23 additions & 0 deletions mlir/lib/Target/DXSA/BinaryParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,14 @@ class DXBuilder {
outputPrimitiveTypeAttr);
}

Instruction
buildDclOutputTopology(dxsa::OutputPrimitiveTopology outputTopology,
Location loc) {
auto outputTopologyAttr = dxsa::OutputPrimitiveTopologyAttr::get(
builder.getContext(), outputTopology);
return dxsa::DclOutputTopology::create(builder, loc, outputTopologyAttr);
}

private:
MLIRContext *context;
ModuleOp module;
Expand Down Expand Up @@ -913,6 +921,18 @@ class Parser {
loc);
}

FailureOr<Instruction> parseDclOutputTopology(uint32_t opcodeToken,
Location loc) {
auto rawOutputTopology =
DECODE_D3D10_SB_GS_OUTPUT_PRIMITIVE_TOPOLOGY(opcodeToken);
auto outputTopology =
dxsa::symbolizeOutputPrimitiveTopology(rawOutputTopology);
if (!outputTopology)
return emitError(loc, "unknown output primitive topology: ")
<< rawOutputTopology;
return builder.buildDclOutputTopology(*outputTopology, loc);
}

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

// CHECK: module {
// CHECK-NEXT: dxsa.dcl_output_topology pointlist
// CHECK-NEXT: dxsa.dcl_output_topology linestrip
// CHECK-NEXT: dxsa.dcl_output_topology trianglestrip
// CHECK-NEXT: }
Binary file not shown.