-
Notifications
You must be signed in to change notification settings - Fork 246
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
1 parent
8047160
commit 314ef89
Showing
3 changed files
with
40 additions
and
12 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
//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-SAME: Offset % | ||
outputBuffer.result = textureGatherOffset(u_sampler, v_texCoord, u_offset); | ||
} |
This file contains 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