Skip to content

Commit 2f93f2b

Browse files
committed
[mlir][dxsa] Add dcl_max_output_vertex_count instruction
Example: dxsa.dcl_max_output_vertex_count 42 Signed-off-by: Vladimir Shiryaev <tagolog@users.noreply.github.com>
1 parent d77ed2d commit 2f93f2b

5 files changed

Lines changed: 63 additions & 2 deletions

File tree

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -857,4 +857,25 @@ def DXSA_DclGsInstanceCount : DXSA_Op<"dcl_gs_instance_count"> {
857857
let assemblyFormat = [{ $count attr-dict }];
858858
}
859859

860+
def DXSA_DclMaxOutputVertexCount :
861+
DXSA_Op<"dcl_max_output_vertex_count"> {
862+
let summary = "declares the geometry shader maximum output vertex count";
863+
let description = [{
864+
The `dxsa.dcl_max_output_vertex_count` operation declares the maximum
865+
number of vertices that a single invocation of the geometry shader will
866+
emit.
867+
868+
The count must be in [1, 1024].
869+
870+
Example:
871+
872+
```mlir
873+
dxsa.dcl_max_output_vertex_count 42
874+
```
875+
}];
876+
let arguments = (ins ConfinedAttr<I32Attr,
877+
[IntPositive, IntMaxValue<1024>]>:$count);
878+
let assemblyFormat = [{ $count attr-dict }];
879+
}
880+
860881
#endif // DXSA_OPS

mlir/lib/Target/DXSA/BinaryParser.cpp

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,8 @@ static void initInstructionInfo(MutableArrayRef<InstructionInfo> instructions) {
159159
D3D10_SB_DCL_OP);
160160
SET(D3D10_SB_OPCODE_DCL_GS_OUTPUT_PRIMITIVE_TOPOLOGY, "dcl_outputtopology", 0,
161161
0x00, D3D10_SB_DCL_OP);
162-
SET(D3D10_SB_OPCODE_DCL_MAX_OUTPUT_VERTEX_COUNT, "dcl_maxout", 0, 0x00,
163-
D3D10_SB_DCL_OP);
162+
SET(D3D10_SB_OPCODE_DCL_MAX_OUTPUT_VERTEX_COUNT,
163+
"dcl_max_output_vertex_count", 0, 0x00, D3D10_SB_DCL_OP);
164164
SET(D3D10_SB_OPCODE_DCL_INPUT_PS, "dcl_input_ps", 1, 0x00, D3D10_SB_DCL_OP);
165165
SET(D3D10_SB_OPCODE_DCL_CONSTANT_BUFFER, "dcl_constantbuffer", 1, 0x00,
166166
D3D10_SB_DCL_OP);
@@ -591,6 +591,10 @@ class DXBuilder {
591591
builder.getI32IntegerAttr(count));
592592
}
593593

594+
Instruction buildDclMaxOutputVertexCount(uint32_t count, Location loc) {
595+
return dxsa::DclMaxOutputVertexCount::create(builder, loc, count);
596+
}
597+
594598
Instruction buildDclInputPs(dxsa::InterpolationMode interpolationMode,
595599
Operand operand, Location loc) {
596600
auto interpolationModeAttr = dxsa::InterpolationModeAttr::get(
@@ -1101,6 +1105,19 @@ class Parser {
11011105
return builder.buildDclGsInstanceCount(count, loc);
11021106
}
11031107

1108+
FailureOr<Instruction> parseDclMaxOutputVertexCount(Location loc) {
1109+
auto countToken = parseToken();
1110+
FAILURE_IF_FAILED(countToken);
1111+
auto count = *countToken;
1112+
if (count == 0)
1113+
return emitError(getLocation(), "max output vertex count cannot be zero");
1114+
if (count > 1024)
1115+
return emitError(getLocation(),
1116+
"max output vertex count must be <= 1024, got ")
1117+
<< count;
1118+
return builder.buildDclMaxOutputVertexCount(count, loc);
1119+
}
1120+
11041121
FailureOr<dxsa::InterpolationMode>
11051122
parseInterpolationMode(uint32_t opcodeToken, Location loc) {
11061123
auto rawInterpolationMode =
@@ -1301,6 +1318,9 @@ class Parser {
13011318
case D3D11_SB_OPCODE_DCL_GS_INSTANCE_COUNT:
13021319
result = parseDclGsInstanceCount(loc);
13031320
break;
1321+
case D3D10_SB_OPCODE_DCL_MAX_OUTPUT_VERTEX_COUNT:
1322+
result = parseDclMaxOutputVertexCount(loc);
1323+
break;
13041324
case D3D10_SB_OPCODE_DCL_INPUT_PS:
13051325
result = parseDclInputPs(opcodeToken, loc);
13061326
break;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// RUN: mlir-translate --import-dxsa-bin %S/inputs/dcl_max_output_vertex_count.bin | FileCheck %s
2+
3+
// CHECK: module {
4+
// CHECK-NEXT: dxsa.dcl_max_output_vertex_count 1
5+
// CHECK-NEXT: dxsa.dcl_max_output_vertex_count 1024
6+
// CHECK-NEXT: }
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// RUN: mlir-opt %s -split-input-file -verify-diagnostics
2+
3+
// expected-error@+1 {{attribute 'count' failed to satisfy constraint: 32-bit signless integer attribute whose value is positive whose maximum value is 1024}}
4+
dxsa.dcl_max_output_vertex_count -1
5+
6+
// -----
7+
8+
// expected-error@+1 {{attribute 'count' failed to satisfy constraint: 32-bit signless integer attribute whose value is positive whose maximum value is 1024}}
9+
dxsa.dcl_max_output_vertex_count 0
10+
11+
// -----
12+
13+
// expected-error@+1 {{attribute 'count' failed to satisfy constraint: 32-bit signless integer attribute whose value is positive whose maximum value is 1024}}
14+
dxsa.dcl_max_output_vertex_count 1025
16 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)