-
Notifications
You must be signed in to change notification settings - Fork 2
[mlir][dxsa] Add topology instructions #198
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dxsa-mlir
Are you sure you want to change the base?
Changes from all commits
2c32aeb
84d75cb
d838277
f68f5e5
b8c4550
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,154 @@ | ||
| //===- DXSATopologyOps.td - DXSA topology ops --------------*- tablegen -*-===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
| // | ||
| // Topology instructions of the DXSA dialect. | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #ifndef MLIR_DIALECT_DXSA_IR_DXSATOPOLOGYOPS | ||
| #define MLIR_DIALECT_DXSA_IR_DXSATOPOLOGYOPS | ||
|
|
||
| include "mlir/Dialect/DXSA/IR/DXSAOpBase.td" | ||
|
|
||
| //===----------------------------------------------------------------------===// | ||
| // dxsa.emit | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| def DXSA_Emit : DXSA_NullaryOp<"emit"> { | ||
| let summary = "outputs a geometry-shader vertex from declared output registers"; | ||
| let description = [{ | ||
| The `dxsa.emit` operation reads every declared `o#` output register and | ||
| outputs a vertex from the geometry shader. Each `dxsa.emit` produces one | ||
| vertex; successive emits assemble primitives according to the output | ||
| topology declared by `dxsa.dcl_output_topology`. | ||
|
|
||
| A geometry shader may issue `dxsa.emit` any number of times, including | ||
| inside flow control. If output streams have been declared with | ||
| `dxsa.dcl_stream`, `dxsa.emit_stream` must be used instead. | ||
|
|
||
| Example: | ||
|
|
||
| ```mlir | ||
| dxsa.emit | ||
| ``` | ||
| }]; | ||
| } | ||
|
|
||
| //===----------------------------------------------------------------------===// | ||
| // dxsa.cut | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| def DXSA_Cut : DXSA_NullaryOp<"cut"> { | ||
| let summary = "ends the current geometry-shader output strip"; | ||
| let description = [{ | ||
| The `dxsa.cut` operation ends the current output strip at the last emitted | ||
| vertex, so the next `dxsa.emit` begins a new strip. This only affects | ||
| linestrip and trianglestrip output topologies; for pointlist output, | ||
| `dxsa.cut` has no effect. | ||
|
|
||
| A geometry shader may issue `dxsa.cut` any number of times, including | ||
| inside flow control. If output streams have been declared with | ||
| `dxsa.dcl_stream`, `dxsa.cut_stream` must be used instead. | ||
|
|
||
| Example: | ||
|
|
||
| ```mlir | ||
| dxsa.cut | ||
| ``` | ||
| }]; | ||
| } | ||
|
|
||
| //===----------------------------------------------------------------------===// | ||
| // dxsa.emit_then_cut | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| def DXSA_EmitThenCut : DXSA_NullaryOp<"emit_then_cut"> { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Microsoft call this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instruction names in Microsoft's specification are formed according to different naming rules, rather than following a single uniform convention. We decided to use snake_case for operation names to maintain consistency across the dialect. |
||
| let summary = "outputs a geometry-shader vertex and ends the current strip"; | ||
| let description = [{ | ||
| The `dxsa.emit_then_cut` operation has the same effect as `dxsa.emit`, | ||
| immediately followed by `dxsa.cut`. | ||
|
|
||
| A geometry shader may issue `dxsa.emit_then_cut` any number of times, | ||
| including inside flow control. If output streams have been declared with | ||
| `dxsa.dcl_stream`, `dxsa.emit_then_cut_stream` must be used instead. | ||
|
|
||
| Example: | ||
|
|
||
| ```mlir | ||
| dxsa.emit_then_cut | ||
| ``` | ||
| }]; | ||
| } | ||
|
|
||
| //===----------------------------------------------------------------------===// | ||
| // dxsa.emit_stream | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| def DXSA_EmitStream : DXSA_GsStreamIndexOp<"emit_stream"> { | ||
| let summary = "outputs a geometry-shader vertex on an output stream"; | ||
| let description = [{ | ||
| The `dxsa.emit_stream` operation reads every declared `o#` output register | ||
| for stream `$index` and outputs a vertex on that geometry-shader output | ||
| stream. Each `dxsa.emit_stream` produces one vertex; successive emits on | ||
| the same stream assemble primitives according to the output topology | ||
| declared for that stream. | ||
|
|
||
| The `$index` must be in the range [0, 3]. | ||
|
|
||
| Example: | ||
|
|
||
| ```mlir | ||
| dxsa.emit_stream 0 | ||
| ``` | ||
| }]; | ||
| } | ||
|
|
||
| //===----------------------------------------------------------------------===// | ||
| // dxsa.cut_stream | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| def DXSA_CutStream : DXSA_GsStreamIndexOp<"cut_stream"> { | ||
| let summary = "ends the current strip on a geometry-shader output stream"; | ||
| let description = [{ | ||
| The `dxsa.cut_stream` operation ends the current output strip at the last | ||
| emitted vertex on stream `$index`, so the next emit on that stream begins a | ||
| new strip. This has the same semantics as `dxsa.cut`, scoped to the given | ||
| output stream. | ||
|
|
||
| The `$index` must be in the range [0, 3]. | ||
|
|
||
| Example: | ||
|
|
||
| ```mlir | ||
| dxsa.cut_stream 0 | ||
| ``` | ||
| }]; | ||
| } | ||
|
|
||
| //===----------------------------------------------------------------------===// | ||
| // dxsa.emit_then_cut_stream | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| def DXSA_EmitThenCutStream : DXSA_GsStreamIndexOp<"emit_then_cut_stream"> { | ||
| let summary = "outputs a vertex on a stream and ends the current strip"; | ||
| let description = [{ | ||
| The `dxsa.emit_then_cut_stream` operation has the same effect as | ||
| `dxsa.emit_stream`, immediately followed by `dxsa.cut_stream`, on stream | ||
| `$index`. | ||
|
|
||
| The `$index` must be in the range [0, 3]. | ||
|
|
||
| Example: | ||
|
|
||
| ```mlir | ||
| dxsa.emit_then_cut_stream 0 | ||
| ``` | ||
| }]; | ||
| } | ||
|
|
||
| #endif // MLIR_DIALECT_DXSA_IR_DXSATOPOLOGYOPS | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| // RUN: mlir-translate --split-input-file --import-dxsa-hex %s | FileCheck %s | ||
| // RUN: mlir-translate --split-input-file --import-dxsa-hex %s | mlir-opt --split-input-file --verify-roundtrip | ||
|
|
||
| // CHECK-LABEL: dxsa.module { | ||
| // CHECK-NEXT: dxsa.cut | ||
| // CHECK-NEXT: } | ||
| 0x01000009 | ||
|
|
||
| // ----- | ||
|
|
||
| // CHECK-LABEL: dxsa.module { | ||
| // CHECK-NEXT: dxsa.emit | ||
| // CHECK-NEXT: } | ||
| 0x01000013 | ||
|
|
||
| // ----- | ||
|
|
||
| // CHECK-LABEL: dxsa.module { | ||
| // CHECK-NEXT: dxsa.emit_then_cut | ||
| // CHECK-NEXT: } | ||
| 0x01000014 | ||
|
|
||
| // ----- | ||
|
|
||
| // CHECK-LABEL: dxsa.module { | ||
| // CHECK-NEXT: dxsa.emit_stream 0 | ||
| // CHECK-NEXT: } | ||
| 0x03000075, 0x00110000, 0x00000000 | ||
|
|
||
| // ----- | ||
|
|
||
| // CHECK-LABEL: dxsa.module { | ||
| // CHECK-NEXT: dxsa.emit_stream 3 | ||
| // CHECK-NEXT: } | ||
| 0x03000075, 0x00110000, 0x00000003 | ||
|
|
||
| // ----- | ||
|
|
||
| // CHECK-LABEL: dxsa.module { | ||
| // CHECK-NEXT: dxsa.cut_stream 0 | ||
| // CHECK-NEXT: } | ||
| 0x03000076, 0x00110000, 0x00000000 | ||
|
|
||
| // ----- | ||
|
|
||
| // CHECK-LABEL: dxsa.module { | ||
| // CHECK-NEXT: dxsa.cut_stream 3 | ||
| // CHECK-NEXT: } | ||
| 0x03000076, 0x00110000, 0x00000003 | ||
|
|
||
| // ----- | ||
|
|
||
| // CHECK-LABEL: dxsa.module { | ||
| // CHECK-NEXT: dxsa.emit_then_cut_stream 0 | ||
| // CHECK-NEXT: } | ||
| 0x03000077, 0x00110000, 0x00000000 | ||
|
|
||
| // ----- | ||
|
|
||
| // CHECK-LABEL: dxsa.module { | ||
| // CHECK-NEXT: dxsa.emit_then_cut_stream 3 | ||
| // CHECK-NEXT: } | ||
| 0x03000077, 0x00110000, 0x00000003 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is identical to what is in #194; I'm not sure which PR had it first and where the review comment should go. Regardless, the same comment applies here.