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
21 changes: 21 additions & 0 deletions mlir/include/mlir/Dialect/DXSA/IR/DXSAOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -857,4 +857,25 @@ def DXSA_DclGsInstanceCount : DXSA_Op<"dcl_gs_instance_count"> {
let assemblyFormat = [{ $count attr-dict }];
}

def DXSA_DclMaxOutputVertexCount :
DXSA_Op<"dcl_max_output_vertex_count"> {
let summary = "declares the geometry shader maximum output vertex count";
let description = [{
The `dxsa.dcl_max_output_vertex_count` operation declares the maximum
number of vertices that a single invocation of the geometry shader will
emit.

The count must be in [1, 1024].

Example:

```mlir
dxsa.dcl_max_output_vertex_count 42
```
}];
let arguments = (ins ConfinedAttr<I32Attr,
[IntPositive, IntMaxValue<1024>]>:$count);
let assemblyFormat = [{ $count attr-dict }];
}

#endif // DXSA_OPS
24 changes: 22 additions & 2 deletions mlir/lib/Target/DXSA/BinaryParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ static void initInstructionInfo(MutableArrayRef<InstructionInfo> instructions) {
D3D10_SB_DCL_OP);
SET(D3D10_SB_OPCODE_DCL_GS_OUTPUT_PRIMITIVE_TOPOLOGY, "dcl_outputtopology", 0,
0x00, D3D10_SB_DCL_OP);
SET(D3D10_SB_OPCODE_DCL_MAX_OUTPUT_VERTEX_COUNT, "dcl_maxout", 0, 0x00,
D3D10_SB_DCL_OP);
SET(D3D10_SB_OPCODE_DCL_MAX_OUTPUT_VERTEX_COUNT,
"dcl_max_output_vertex_count", 0, 0x00, D3D10_SB_DCL_OP);
SET(D3D10_SB_OPCODE_DCL_INPUT_PS, "dcl_input_ps", 1, 0x00, D3D10_SB_DCL_OP);
SET(D3D10_SB_OPCODE_DCL_CONSTANT_BUFFER, "dcl_constantbuffer", 1, 0x00,
D3D10_SB_DCL_OP);
Expand Down Expand Up @@ -591,6 +591,10 @@ class DXBuilder {
builder.getI32IntegerAttr(count));
}

Instruction buildDclMaxOutputVertexCount(uint32_t count, Location loc) {
return dxsa::DclMaxOutputVertexCount::create(builder, loc, count);
}

Instruction buildDclInputPs(dxsa::InterpolationMode interpolationMode,
Operand operand, Location loc) {
auto interpolationModeAttr = dxsa::InterpolationModeAttr::get(
Expand Down Expand Up @@ -1101,6 +1105,19 @@ class Parser {
return builder.buildDclGsInstanceCount(count, loc);
}

FailureOr<Instruction> parseDclMaxOutputVertexCount(Location loc) {
auto countToken = parseToken();
FAILURE_IF_FAILED(countToken);
auto count = *countToken;
if (count == 0)
return emitError(getLocation(), "max output vertex count cannot be zero");
if (count > 1024)
return emitError(getLocation(),
"max output vertex count must be <= 1024, got ")
<< count;
return builder.buildDclMaxOutputVertexCount(count, loc);
}

FailureOr<dxsa::InterpolationMode>
parseInterpolationMode(uint32_t opcodeToken, Location loc) {
auto rawInterpolationMode =
Expand Down Expand Up @@ -1301,6 +1318,9 @@ class Parser {
case D3D11_SB_OPCODE_DCL_GS_INSTANCE_COUNT:
result = parseDclGsInstanceCount(loc);
break;
case D3D10_SB_OPCODE_DCL_MAX_OUTPUT_VERTEX_COUNT:
result = parseDclMaxOutputVertexCount(loc);
break;
case D3D10_SB_OPCODE_DCL_INPUT_PS:
result = parseDclInputPs(opcodeToken, loc);
break;
Expand Down
6 changes: 6 additions & 0 deletions mlir/test/Target/DXSA/dcl_max_output_vertex_count.mlir
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// RUN: mlir-translate --import-dxsa-bin %S/inputs/dcl_max_output_vertex_count.bin | FileCheck %s

// CHECK: module {
// CHECK-NEXT: dxsa.dcl_max_output_vertex_count 1
// CHECK-NEXT: dxsa.dcl_max_output_vertex_count 1024
// CHECK-NEXT: }
14 changes: 14 additions & 0 deletions mlir/test/Target/DXSA/dcl_max_output_vertex_count_invalid.mlir
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// RUN: mlir-opt %s -split-input-file -verify-diagnostics

// expected-error@+1 {{attribute 'count' failed to satisfy constraint: 32-bit signless integer attribute whose value is positive whose maximum value is 1024}}
dxsa.dcl_max_output_vertex_count -1

// -----

// expected-error@+1 {{attribute 'count' failed to satisfy constraint: 32-bit signless integer attribute whose value is positive whose maximum value is 1024}}
dxsa.dcl_max_output_vertex_count 0

// -----

// expected-error@+1 {{attribute 'count' failed to satisfy constraint: 32-bit signless integer attribute whose value is positive whose maximum value is 1024}}
dxsa.dcl_max_output_vertex_count 1025
Binary file not shown.