diff options
| author | Jay Kwak <82421531+jkwak-work@users.noreply.github.com> | 2024-10-29 09:56:07 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-10-29 09:56:07 -0700 |
| commit | 8b3f9048cb94164a036be4ae144b2108968b65b5 (patch) | |
| tree | caccdf07086f21dfe709d6afd64e60348e7f8547 /tests/bugs | |
| parent | f65d756bff8d4c5cbc15bd0322a2ae8e6b896a21 (diff) | |
Use Offset instead of ConstOffset for GLSL function textureGatherOffset (#5426)
* Use Offset instead of ConstOffset for GLSL function textureGatherOffset
This commit changes to use `Offset` option on OpImageGather instruction
when translating `textureGatherOffset` to SPIR-V code.
Interestingly GLSL allows the offset value to be a variable not
constant just for the function `textureGatherOffset` while all other
offset variants of texture sampling functions require the offset to be a
constant value.
From a few experiments, I found that the spirv-optimizer changes
`Offset` to `ConstOffset` if the offset is a compile-time value. I also
found that when the offset value is zero, it changes to `None` with no
offset value.
Diffstat (limited to 'tests/bugs')
| -rw-r--r-- | tests/bugs/gh-5339.slang | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/bugs/gh-5339.slang b/tests/bugs/gh-5339.slang new file mode 100644 index 000000000..163b05bc7 --- /dev/null +++ b/tests/bugs/gh-5339.slang @@ -0,0 +1,27 @@ +//TEST:SIMPLE(filecheck=SPV): -allow-glsl -target spirv-asm -entry computeMain -stage compute + +// Test if we are correctly using `Offset` option instead of `ConstOffset` +// when the offset value is not a compile-time constant. + +//SPV:OpCapability ImageGatherExtended + +#extension GL_EXT_gpu_shader5 : require + +layout (location = 0) in highp vec2 v_texCoord; + +layout (binding = 0) uniform highp sampler2D u_sampler; +layout (binding = 1) uniform offset { highp ivec2 u_offset; }; + +//TEST_INPUT:ubuffer(data=[0], stride=4):out,name=outputBuffer +buffer MyBlockName +{ + vec4 result; +} outputBuffer; + +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + //SPV:OpImageGather % + //SPV-NOT:Const + //SPV-SAME: Offset % + outputBuffer.result = textureGatherOffset(u_sampler, v_texCoord, u_offset); +} |
