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
18 changes: 18 additions & 0 deletions mlir/include/mlir/Dialect/DXSA/IR/DXSAOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -1054,4 +1054,22 @@ def DXSA_DclSampler : DXSA_Op<"dcl_sampler"> {
let hasVerifier = 1;
}

def DXSA_DclStream : DXSA_Op<"dcl_stream"> {
let summary = "declares a geometry shader (GS) output stream";
let description = [{
The `dxsa.dcl_stream` operation declares a geometry shader (GS) output stream.

The `$index` must be in the range [0, 3].

Example:

```mlir
dxsa.dcl_stream 0
```
}];
let arguments = (ins ConfinedAttr<I32Attr,
[IntNonNegative, IntMaxValue<3>]>:$index);
let assemblyFormat = [{ $index attr-dict }];
}

#endif // DXSA_OPS
24 changes: 24 additions & 0 deletions mlir/lib/Target/DXSA/BinaryParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,11 @@ class DXBuilder {
return dxsa::DclMaxOutputVertexCount::create(builder, loc, count);
}

Instruction buildDclStream(uint32_t index, Location loc) {
return dxsa::DclStream::create(builder, loc,
builder.getI32IntegerAttr(index));
}

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

FailureOr<Instruction> parseDclStream(Location loc) {
auto operand = parseInlineOperand();
FAILURE_IF_FAILED(operand);
if (operand->getType() != dxsa::InlineOperandType::stream)
return emitError(loc, "unexpected operand type: ")
<< dxsa::stringifyInlineOperandType(operand->getType());
if (operand->getComponents() != 0)
return emitError(loc, "unexpected number of components: ")
<< operand->getComponents();
auto indexArray = operand->getIndex();
if (!indexArray || indexArray.size() != 1)
return emitError(loc, "unsupported index dimension: ")
<< (indexArray ? indexArray.size() : 0);
return builder.buildDclStream(static_cast<uint32_t>(indexArray[0]), loc);
}

FailureOr<dxsa::InterpolationMode>
parseInterpolationMode(uint32_t opcodeToken, Location loc) {
auto rawInterpolationMode =
Expand Down Expand Up @@ -1492,6 +1513,9 @@ class Parser {
case D3D10_SB_OPCODE_DCL_MAX_OUTPUT_VERTEX_COUNT:
result = parseDclMaxOutputVertexCount(loc);
break;
case D3D11_SB_OPCODE_DCL_STREAM:
result = parseDclStream(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_stream.mlir
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// RUN: mlir-translate --import-dxsa-bin %S/inputs/dcl_stream.bin | FileCheck %s

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

// expected-error@+1 {{attribute 'index' failed to satisfy constraint: 32-bit signless integer attribute whose value is non-negative whose maximum value is 3}}
dxsa.dcl_stream -1

// -----

// expected-error@+1 {{attribute 'index' failed to satisfy constraint: 32-bit signless integer attribute whose value is non-negative whose maximum value is 3}}
dxsa.dcl_stream 4
Binary file added mlir/test/Target/DXSA/inputs/dcl_stream.bin
Binary file not shown.