Skip to content

Commit 4e0138c

Browse files
committed
[mlir][dxsa] Add dcl_output_sgv instruction
Example: dxsa.dcl_output_sgv <type = output, components = 4, mask = <x>, index = [0]>, <primitiveID> Signed-off-by: Vladimir Shiryaev <tagolog@users.noreply.github.com>
1 parent 014c7b3 commit 4e0138c

6 files changed

Lines changed: 50 additions & 11 deletions

File tree

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

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ def DXSA_SystemValueName : I32EnumAttr<
252252

253253
def DXSA_SystemValueNameAttr :
254254
EnumAttr<DXSADialect, DXSA_SystemValueName, "system_value_name"> {
255-
let assemblyFormat = "$value";
255+
let assemblyFormat = "`<` $value `>`";
256256
}
257257

258258
//===----------------------------------------------------------------------===//
@@ -657,7 +657,7 @@ def DXSA_DclInputPsSiv : DXSA_Op<"dcl_input_ps_siv"> {
657657
Example:
658658

659659
```mlir
660-
dxsa.dcl_input_ps_siv linear %v0, position
660+
dxsa.dcl_input_ps_siv linear %v0, <position>
661661
```
662662
}];
663663
let arguments = (ins DXSA_InterpolationModeAttr:$mode,
@@ -675,7 +675,7 @@ def DXSA_DclInputPsSgv : DXSA_Op<"dcl_input_ps_sgv"> {
675675
Example:
676676

677677
```mlir
678-
dxsa.dcl_input_ps_sgv %v0, sampleIndex
678+
dxsa.dcl_input_ps_sgv %v0, <sampleIndex>
679679
```
680680
}];
681681
let arguments = (ins DXSA_OperandType:$operand,
@@ -719,4 +719,21 @@ def DXSA_DclOutput : DXSA_Op<"dcl_output"> {
719719
let assemblyFormat = "$operand attr-dict";
720720
}
721721

722+
def DXSA_DclOutputSgv : DXSA_Op<"dcl_output_sgv"> {
723+
let summary = "declares an output as a System Generated Value";
724+
let description = [{
725+
The `dxsa.dcl_output_sgv` operation declares an output to be written
726+
that represents a System Generated Value.
727+
728+
Example:
729+
730+
```mlir
731+
dxsa.dcl_output_sgv <type = output, components = 1, mask = <x>, index = [4]>, <primitiveID>
732+
```
733+
}];
734+
let arguments = (ins DXSA_InlineOperandAttr:$operand,
735+
DXSA_SystemValueNameAttr:$name);
736+
let assemblyFormat = "$operand `,` $name attr-dict";
737+
}
738+
722739
#endif // DXSA_OPS

mlir/lib/Target/DXSA/BinaryParser.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,12 @@ class DXBuilder {
635635
return dxsa::DclOutput::create(builder, loc, operand);
636636
}
637637

638+
Instruction buildDclOutputSgv(dxsa::InlineOperandAttr operand,
639+
dxsa::SystemValueName name, Location loc) {
640+
auto nameAttr = dxsa::SystemValueNameAttr::get(builder.getContext(), name);
641+
return dxsa::DclOutputSgv::create(builder, loc, operand, nameAttr);
642+
}
643+
638644
private:
639645
MLIRContext *context;
640646
ModuleOp module;
@@ -1174,6 +1180,14 @@ class Parser {
11741180
return builder.buildDclOutput(*operand, loc);
11751181
}
11761182

1183+
FailureOr<Instruction> parseDclOutputSgv(Location loc) {
1184+
auto operand = parseInlineOperand();
1185+
FAILURE_IF_FAILED(operand);
1186+
auto name = parseSystemValueName(getLocation());
1187+
FAILURE_IF_FAILED(name);
1188+
return builder.buildDclOutputSgv(*operand, *name, loc);
1189+
}
1190+
11771191
OptionalParseResult parseDclInstruction(uint32_t opcodeToken, Location loc,
11781192
Instruction &out) {
11791193
FailureOr<Instruction> result;
@@ -1220,6 +1234,9 @@ class Parser {
12201234
case D3D10_SB_OPCODE_DCL_OUTPUT:
12211235
result = parseDclOutput(loc);
12221236
break;
1237+
case D3D10_SB_OPCODE_DCL_OUTPUT_SGV:
1238+
result = parseDclOutputSgv(loc);
1239+
break;
12231240
default:
12241241
return std::nullopt;
12251242
}

mlir/test/Target/DXSA/dcl_input_ps_sgv.mlir

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ module {
55
// dcl_input_ps_sgv v0.x, primitiveID
66
// CHECK: %0 = dxsa.index.imm {imm = 0 : i32}
77
// CHECK-NEXT: %1 = dxsa.operand %0 {mask = 16 : i32, num_components = 4 : i32, type = 1 : i32}
8-
// CHECK-NEXT: dxsa.dcl_input_ps_sgv %1, primitiveID
8+
// CHECK-NEXT: dxsa.dcl_input_ps_sgv %1, <primitiveID>
99

1010
// dcl_input_ps_sgv v1.x, isFrontFace
1111
// CHECK-NEXT: %2 = dxsa.index.imm {imm = 1 : i32}
1212
// CHECK-NEXT: %3 = dxsa.operand %2 {mask = 16 : i32, num_components = 4 : i32, type = 1 : i32}
13-
// CHECK-NEXT: dxsa.dcl_input_ps_sgv %3, isFrontFace
13+
// CHECK-NEXT: dxsa.dcl_input_ps_sgv %3, <isFrontFace>
1414

1515
// dcl_input_ps_sgv v2.x, sampleIndex
1616
// CHECK-NEXT: %4 = dxsa.index.imm {imm = 2 : i32}
1717
// CHECK-NEXT: %5 = dxsa.operand %4 {mask = 16 : i32, num_components = 4 : i32, type = 1 : i32}
18-
// CHECK-NEXT: dxsa.dcl_input_ps_sgv %5, sampleIndex
18+
// CHECK-NEXT: dxsa.dcl_input_ps_sgv %5, <sampleIndex>
1919
}

mlir/test/Target/DXSA/dcl_input_ps_siv.mlir

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,25 @@ module {
55
// dcl_input_ps_siv linear v0.x, position
66
// CHECK: %0 = dxsa.index.imm {imm = 0 : i32}
77
// CHECK-NEXT: %1 = dxsa.operand %0 {mask = 16 : i32, num_components = 4 : i32, type = 1 : i32}
8-
// CHECK-NEXT: dxsa.dcl_input_ps_siv linear %1, position
8+
// CHECK-NEXT: dxsa.dcl_input_ps_siv linear %1, <position>
99

1010
// dcl_input_ps_siv linear v1.x, clipDistance
1111
// CHECK-NEXT: %2 = dxsa.index.imm {imm = 1 : i32}
1212
// CHECK-NEXT: %3 = dxsa.operand %2 {mask = 16 : i32, num_components = 4 : i32, type = 1 : i32}
13-
// CHECK-NEXT: dxsa.dcl_input_ps_siv linear %3, clipDistance
13+
// CHECK-NEXT: dxsa.dcl_input_ps_siv linear %3, <clipDistance>
1414

1515
// dcl_input_ps_siv linear v2.x, cullDistance
1616
// CHECK-NEXT: %4 = dxsa.index.imm {imm = 2 : i32}
1717
// CHECK-NEXT: %5 = dxsa.operand %4 {mask = 16 : i32, num_components = 4 : i32, type = 1 : i32}
18-
// CHECK-NEXT: dxsa.dcl_input_ps_siv linear %5, cullDistance
18+
// CHECK-NEXT: dxsa.dcl_input_ps_siv linear %5, <cullDistance>
1919

2020
// dcl_input_ps_siv linear v3.x, renderTargetArrayIndex
2121
// CHECK-NEXT: %6 = dxsa.index.imm {imm = 3 : i32}
2222
// CHECK-NEXT: %7 = dxsa.operand %6 {mask = 16 : i32, num_components = 4 : i32, type = 1 : i32}
23-
// CHECK-NEXT: dxsa.dcl_input_ps_siv linear %7, renderTargetArrayIndex
23+
// CHECK-NEXT: dxsa.dcl_input_ps_siv linear %7, <renderTargetArrayIndex>
2424

2525
// dcl_input_ps_siv linear v4.x, viewportArrayIndex
2626
// CHECK-NEXT: %8 = dxsa.index.imm {imm = 4 : i32}
2727
// CHECK-NEXT: %9 = dxsa.operand %8 {mask = 16 : i32, num_components = 4 : i32, type = 1 : i32}
28-
// CHECK-NEXT: dxsa.dcl_input_ps_siv linear %9, viewportArrayIndex
28+
// CHECK-NEXT: dxsa.dcl_input_ps_siv linear %9, <viewportArrayIndex>
2929
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// RUN: mlir-translate --import-dxsa-bin %S/inputs/dcl_output_sgv.bin | FileCheck %s
2+
3+
// CHECK: module {
4+
// CHECK-NEXT: dxsa.dcl_output_sgv <type = output, components = 4, mask = <x>, index = [0]>, <primitiveID>
5+
// CHECK-NEXT: }
16 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)