Skip to content

Commit 90a23a8

Browse files
committed
[mlir][dxsa] Add dcl_input_sgv instruction
Example: dxsa.dcl_input_sgv <type = input, components = 4, mask = <x>, index = [0]>, <vertexID> Signed-off-by: Vladimir Shiryaev <tagolog@users.noreply.github.com>
1 parent cdfb680 commit 90a23a8

4 files changed

Lines changed: 43 additions & 0 deletions

File tree

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -759,6 +759,24 @@ def DXSA_DclIndexRange : DXSA_Op<"dcl_index_range"> {
759759
let hasVerifier = 1;
760760
}
761761

762+
def DXSA_DclInputSgv : DXSA_Op<"dcl_input_sgv"> {
763+
let summary = "declares an input register as a System Generated Value";
764+
let description = [{
765+
The `dxsa.dcl_input_sgv` operation declares an input register
766+
that expects a System Generated Value to be provided
767+
from the upstream stage.
768+
769+
Example:
770+
771+
```mlir
772+
dxsa.dcl_input_sgv <type = input, components = 4, mask = <x>, index = [0]>, <vertexID>
773+
```
774+
}];
775+
let arguments = (ins DXSA_InlineOperandAttr:$operand,
776+
DXSA_SystemValueNameAttr:$name);
777+
let assemblyFormat = "$operand `,` $name attr-dict";
778+
}
779+
762780
def DXSA_DclOutputSgv : DXSA_Op<"dcl_output_sgv"> {
763781
let summary = "declares an output as a System Generated Value";
764782
let description = [{

mlir/lib/Target/DXSA/BinaryParser.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -651,6 +651,12 @@ class DXBuilder {
651651
builder.getI32IntegerAttr(count));
652652
}
653653

654+
Instruction buildDclInputSgv(dxsa::InlineOperandAttr operand,
655+
dxsa::SystemValueName name, Location loc) {
656+
auto nameAttr = dxsa::SystemValueNameAttr::get(builder.getContext(), name);
657+
return dxsa::DclInputSgv::create(builder, loc, operand, nameAttr);
658+
}
659+
654660
Instruction buildDclOutputSgv(dxsa::InlineOperandAttr operand,
655661
dxsa::SystemValueName name, Location loc) {
656662
auto nameAttr = dxsa::SystemValueNameAttr::get(builder.getContext(), name);
@@ -1291,6 +1297,14 @@ class Parser {
12911297
return builder.buildDclOutputSiv(*operand, *name, loc);
12921298
}
12931299

1300+
FailureOr<Instruction> parseDclInputSgv(Location loc) {
1301+
auto operand = parseInlineOperand();
1302+
FAILURE_IF_FAILED(operand);
1303+
auto name = parseSystemValueName(getLocation());
1304+
FAILURE_IF_FAILED(name);
1305+
return builder.buildDclInputSgv(*operand, *name, loc);
1306+
}
1307+
12941308
FailureOr<Instruction> parseDclHsMaxTessFactor(Location loc) {
12951309
auto token = parseToken();
12961310
FAILURE_IF_FAILED(token);
@@ -1441,6 +1455,9 @@ class Parser {
14411455
case D3D10_SB_OPCODE_DCL_INDEX_RANGE:
14421456
result = parseDclIndexRange(loc);
14431457
break;
1458+
case D3D10_SB_OPCODE_DCL_INPUT_SGV:
1459+
result = parseDclInputSgv(loc);
1460+
break;
14441461
case D3D10_SB_OPCODE_DCL_OUTPUT_SGV:
14451462
result = parseDclOutputSgv(loc);
14461463
break;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// RUN: mlir-translate --import-dxsa-bin %S/inputs/dcl_input_sgv.bin | FileCheck %s
2+
3+
// CHECK: module {
4+
// CHECK-NEXT: dxsa.dcl_input_sgv <type = input, components = 4, mask = <x>, index = [0]>, <vertexID>
5+
// CHECK-NEXT: dxsa.dcl_input_sgv <type = input, components = 4, mask = <y>, index = [0]>, <instanceID>
6+
// CHECK-NEXT: dxsa.dcl_input_sgv <type = input, components = 4, mask = <z>, index = [1]>, <vertexID>
7+
// CHECK-NEXT: dxsa.dcl_input_sgv <type = input, components = 4, mask = <w>, index = [1]>, <instanceID>
8+
// CHECK-NEXT: }
64 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)