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
23 changes: 20 additions & 3 deletions mlir/include/mlir/Dialect/DXSA/IR/DXSAOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ def DXSA_SystemValueName : I32EnumAttr<

def DXSA_SystemValueNameAttr :
EnumAttr<DXSADialect, DXSA_SystemValueName, "system_value_name"> {
let assemblyFormat = "$value";
let assemblyFormat = "`<` $value `>`";
}

//===----------------------------------------------------------------------===//
Expand Down Expand Up @@ -657,7 +657,7 @@ def DXSA_DclInputPsSiv : DXSA_Op<"dcl_input_ps_siv"> {
Example:

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

```mlir
dxsa.dcl_input_ps_sgv %v0, sampleIndex
dxsa.dcl_input_ps_sgv %v0, <sampleIndex>
```
}];
let arguments = (ins DXSA_OperandType:$operand,
Expand Down Expand Up @@ -737,4 +737,21 @@ def DXSA_DclIndexRange : DXSA_Op<"dcl_index_range"> {
let hasVerifier = 1;
}

def DXSA_DclOutputSgv : DXSA_Op<"dcl_output_sgv"> {
let summary = "declares an output as a System Generated Value";
let description = [{
The `dxsa.dcl_output_sgv` operation declares an output to be written
that represents a System Generated Value.

Example:

```mlir
dxsa.dcl_output_sgv <type = output, components = 1, mask = <x>, index = [4]>, <primitiveID>
```
}];
let arguments = (ins DXSA_InlineOperandAttr:$operand,
DXSA_SystemValueNameAttr:$name);
let assemblyFormat = "$operand `,` $name attr-dict";
}

#endif // DXSA_OPS
17 changes: 17 additions & 0 deletions mlir/lib/Target/DXSA/BinaryParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,12 @@ class DXBuilder {
builder.getI32IntegerAttr(count));
}

Instruction buildDclOutputSgv(dxsa::InlineOperandAttr operand,
dxsa::SystemValueName name, Location loc) {
auto nameAttr = dxsa::SystemValueNameAttr::get(builder.getContext(), name);
return dxsa::DclOutputSgv::create(builder, loc, operand, nameAttr);
}

private:
MLIRContext *context;
ModuleOp module;
Expand Down Expand Up @@ -1188,6 +1194,14 @@ class Parser {
return builder.buildDclIndexRange(*operand, *count, loc);
}

FailureOr<Instruction> parseDclOutputSgv(Location loc) {
auto operand = parseInlineOperand();
FAILURE_IF_FAILED(operand);
auto name = parseSystemValueName(getLocation());
FAILURE_IF_FAILED(name);
return builder.buildDclOutputSgv(*operand, *name, loc);
}

OptionalParseResult parseDclInstruction(uint32_t opcodeToken, Location loc,
Instruction &out) {
FailureOr<Instruction> result;
Expand Down Expand Up @@ -1237,6 +1251,9 @@ class Parser {
case D3D10_SB_OPCODE_DCL_INDEX_RANGE:
result = parseDclIndexRange(loc);
break;
case D3D10_SB_OPCODE_DCL_OUTPUT_SGV:
result = parseDclOutputSgv(loc);
break;
default:
return std::nullopt;
}
Expand Down
6 changes: 3 additions & 3 deletions mlir/test/Target/DXSA/dcl_input_ps_sgv.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ module {
// dcl_input_ps_sgv v0.x, primitiveID
// CHECK: %0 = dxsa.index.imm {imm = 0 : i32}
// CHECK-NEXT: %1 = dxsa.operand %0 {mask = 16 : i32, num_components = 4 : i32, type = 1 : i32}
// CHECK-NEXT: dxsa.dcl_input_ps_sgv %1, primitiveID
// CHECK-NEXT: dxsa.dcl_input_ps_sgv %1, <primitiveID>

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

// dcl_input_ps_sgv v2.x, sampleIndex
// CHECK-NEXT: %4 = dxsa.index.imm {imm = 2 : i32}
// CHECK-NEXT: %5 = dxsa.operand %4 {mask = 16 : i32, num_components = 4 : i32, type = 1 : i32}
// CHECK-NEXT: dxsa.dcl_input_ps_sgv %5, sampleIndex
// CHECK-NEXT: dxsa.dcl_input_ps_sgv %5, <sampleIndex>
}
10 changes: 5 additions & 5 deletions mlir/test/Target/DXSA/dcl_input_ps_siv.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,25 @@ module {
// dcl_input_ps_siv linear v0.x, position
// CHECK: %0 = dxsa.index.imm {imm = 0 : i32}
// CHECK-NEXT: %1 = dxsa.operand %0 {mask = 16 : i32, num_components = 4 : i32, type = 1 : i32}
// CHECK-NEXT: dxsa.dcl_input_ps_siv linear %1, position
// CHECK-NEXT: dxsa.dcl_input_ps_siv linear %1, <position>

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

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

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

// dcl_input_ps_siv linear v4.x, viewportArrayIndex
// CHECK-NEXT: %8 = dxsa.index.imm {imm = 4 : i32}
// CHECK-NEXT: %9 = dxsa.operand %8 {mask = 16 : i32, num_components = 4 : i32, type = 1 : i32}
// CHECK-NEXT: dxsa.dcl_input_ps_siv linear %9, viewportArrayIndex
// CHECK-NEXT: dxsa.dcl_input_ps_siv linear %9, <viewportArrayIndex>
}
5 changes: 5 additions & 0 deletions mlir/test/Target/DXSA/dcl_output_sgv.mlir
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// RUN: mlir-translate --import-dxsa-bin %S/inputs/dcl_output_sgv.bin | FileCheck %s

// CHECK: module {
// CHECK-NEXT: dxsa.dcl_output_sgv <type = output, components = 4, mask = <x>, index = [0]>, <primitiveID>
// CHECK-NEXT: }
Binary file added mlir/test/Target/DXSA/inputs/dcl_output_sgv.bin
Binary file not shown.