Skip to content

Commit a40efc5

Browse files
committed
[mlir][dxsa] Add dcl_stream instruction
Example: dxsa.dcl_stream 0 Signed-off-by: Vladimir Shiryaev <tagolog@users.noreply.github.com>
1 parent 708571b commit a40efc5

5 files changed

Lines changed: 57 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
@@ -1054,4 +1054,22 @@ def DXSA_DclSampler : DXSA_Op<"dcl_sampler"> {
10541054
let hasVerifier = 1;
10551055
}
10561056

1057+
def DXSA_DclStream : DXSA_Op<"dcl_stream"> {
1058+
let summary = "declares a geometry shader (GS) output stream";
1059+
let description = [{
1060+
The `dxsa.dcl_stream` operation declares a geometry shader (GS) output stream.
1061+
1062+
The `$index` must be in the range [0, 3].
1063+
1064+
Example:
1065+
1066+
```mlir
1067+
dxsa.dcl_stream 0
1068+
```
1069+
}];
1070+
let arguments = (ins ConfinedAttr<I32Attr,
1071+
[IntNonNegative, IntMaxValue<3>]>:$index);
1072+
let assemblyFormat = [{ $index attr-dict }];
1073+
}
1074+
10571075
#endif // DXSA_OPS

mlir/lib/Target/DXSA/BinaryParser.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,11 @@ class DXBuilder {
595595
return dxsa::DclMaxOutputVertexCount::create(builder, loc, count);
596596
}
597597

598+
Instruction buildDclStream(uint32_t index, Location loc) {
599+
return dxsa::DclStream::create(builder, loc,
600+
builder.getI32IntegerAttr(index));
601+
}
602+
598603
Instruction buildDclInputPs(dxsa::InterpolationMode interpolationMode,
599604
Operand operand, Location loc) {
600605
auto interpolationModeAttr = dxsa::InterpolationModeAttr::get(
@@ -1168,6 +1173,22 @@ class Parser {
11681173
return builder.buildDclMaxOutputVertexCount(count, loc);
11691174
}
11701175

1176+
FailureOr<Instruction> parseDclStream(Location loc) {
1177+
auto operand = parseInlineOperand();
1178+
FAILURE_IF_FAILED(operand);
1179+
if (operand->getType() != dxsa::InlineOperandType::stream)
1180+
return emitError(loc, "unexpected operand type: ")
1181+
<< dxsa::stringifyInlineOperandType(operand->getType());
1182+
if (operand->getComponents() != 0)
1183+
return emitError(loc, "unexpected number of components: ")
1184+
<< operand->getComponents();
1185+
auto indexArray = operand->getIndex();
1186+
if (!indexArray || indexArray.size() != 1)
1187+
return emitError(loc, "unsupported index dimension: ")
1188+
<< (indexArray ? indexArray.size() : 0);
1189+
return builder.buildDclStream(static_cast<uint32_t>(indexArray[0]), loc);
1190+
}
1191+
11711192
FailureOr<dxsa::InterpolationMode>
11721193
parseInterpolationMode(uint32_t opcodeToken, Location loc) {
11731194
auto rawInterpolationMode =
@@ -1492,6 +1513,9 @@ class Parser {
14921513
case D3D10_SB_OPCODE_DCL_MAX_OUTPUT_VERTEX_COUNT:
14931514
result = parseDclMaxOutputVertexCount(loc);
14941515
break;
1516+
case D3D11_SB_OPCODE_DCL_STREAM:
1517+
result = parseDclStream(loc);
1518+
break;
14951519
case D3D10_SB_OPCODE_DCL_INPUT_PS:
14961520
result = parseDclInputPs(opcodeToken, loc);
14971521
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_stream.bin | FileCheck %s
2+
3+
// CHECK: module {
4+
// CHECK-NEXT: dxsa.dcl_stream 0
5+
// CHECK-NEXT: dxsa.dcl_stream 3
6+
// CHECK-NEXT: }
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// RUN: mlir-opt %s -split-input-file -verify-diagnostics
2+
3+
// expected-error@+1 {{attribute 'index' failed to satisfy constraint: 32-bit signless integer attribute whose value is non-negative whose maximum value is 3}}
4+
dxsa.dcl_stream -1
5+
6+
// -----
7+
8+
// expected-error@+1 {{attribute 'index' failed to satisfy constraint: 32-bit signless integer attribute whose value is non-negative whose maximum value is 3}}
9+
dxsa.dcl_stream 4
24 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)