[mlir][dxsa] Add gather4 variants#203
Open
asavonic wants to merge 2 commits into
Open
Conversation
Sample instruction takes an address, a resource (texture), a sampler, and writes texture data to the destination register. There are several optional that can be present: - Offset is encoded as an extended opcode. - LOD clamp and feeback for sample_cl_s. The spec mentions clamp and feedback as optional, but DXC decodes them both. It is possible that they are always present as operands, but can be null. Other extended instruction are added for other resource instructions, and not enabled for sample instruction.
tagolog
requested changes
Jun 26, 2026
There was a problem hiding this comment.
With the latest PRs, I've introduced a new approach to test files that was approved by Anton.
Can we combine all gather-related tests to a single test file gather_ops.test and run mlir-translate with --split-input-file option?
atomic_ops.test
// 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.atomic_and u<0>, r<0>, r<1, <x>>
// CHECK-NEXT: }
0x070000a9, 0x0011e000, 0x00000000, 0x00100e46, 0x00000000, 0x0010000a, 0x00000001
// -----
// CHECK-LABEL: dxsa.module {
// CHECK-NEXT: dxsa.atomic_and g<0>, r<2>, r<3, <x>>
// CHECK-NEXT: }
0x070000a9, 0x0011f000, 0x00000000, 0x00100e46, 0x00000002, 0x0010000a, 0x00000003| case D3DWDDM1_3_SB_OPCODE_SAMPLE_C_LZ_FEEDBACK: { | ||
| // 1 extra operand | ||
| auto extraOp = parseSrcOperand(); | ||
| FAILURE_IF_FAILED(srcAddress); |
There was a problem hiding this comment.
Suggested change
| FAILURE_IF_FAILED(srcAddress); | |
| FAILURE_IF_FAILED(extraOp); |
There was a problem hiding this comment.
the same issue is in parseSampleOp (not involved this PR, but worth fixing)
// 2 extra operands
auto extraOp = parseSrcOperand();
FAILURE_IF_FAILED(srcAddress);
extraOperands.push_back(*extraOp);
[[fallthrough]];| let results = (outs); | ||
|
|
||
| let assemblyFormat = [{ | ||
| $dst `,` $src_address `,` $src_resource `,` $src_sampler `,` $src_reference_value |
There was a problem hiding this comment.
Suggested change
| $dst `,` $src_address `,` $src_resource `,` $src_sampler `,` $src_reference_value | |
| $dst `,` $src_address `,` $src_resource `,` $src_sampler `,` $src_reference_value |
| let results = (outs); | ||
|
|
||
| let assemblyFormat = [{ | ||
| $dst `,` $src_address `,` $src_offset `,` $src_resource `,` $src_sampler `,` $src_reference_value |
There was a problem hiding this comment.
Suggested change
| $dst `,` $src_address `,` $src_offset `,` $src_resource `,` $src_sampler `,` $src_reference_value | |
| $dst `,` $src_address `,` $src_offset `,` $src_resource `,` $src_sampler `,` $src_reference_value |
| //===----------------------------------------------------------------------===// | ||
|
|
||
| def DXSA_Gather4POC : DXSA_Op<"gather4_po_c"> { | ||
| let summary = "Same as `dxsa.gather4_po`, except performs comparison on texels, similar to `dxsa.sample_c`"; |
There was a problem hiding this comment.
Suggested change
| let summary = "Same as `dxsa.gather4_po`, except performs comparison on texels, similar to `dxsa.sample_c`"; | |
| let summary = "same as `dxsa.gather4_po`, except performs comparison on texels, similar to `dxsa.sample_c`"; |
| case D3D11_SB_OPCODE_GATHER4_PO_C: | ||
| case D3DWDDM1_3_SB_OPCODE_GATHER4_PO_C_FEEDBACK: | ||
| return builder.buildGather4POC(*dst, *srcAddress, srcOffset, *srcResource, | ||
| *srcSampler, extraOperand, feedback, |
There was a problem hiding this comment.
clang-format changes this line a little bit
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Please ignore the first commit in the stack. It is reviewed separately in #182.