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 /source | |
| 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 'source')
| -rw-r--r-- | source/slang/hlsl.meta.slang | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/source/slang/hlsl.meta.slang b/source/slang/hlsl.meta.slang index 2df6c5492..dad634934 100644 --- a/source/slang/hlsl.meta.slang +++ b/source/slang/hlsl.meta.slang @@ -2536,7 +2536,7 @@ __generic<TElement, T, Shape: __ITextureShape, let isArray:int, let sampleCount: vector<TElement,4> __texture_gather_offset( _Texture<T, Shape, isArray, 0, sampleCount, access, isShadow, 0, format> texture, SamplerState s, - constexpr vector<float, Shape.dimensions+isArray> location, + vector<float, Shape.dimensions+isArray> location, constexpr vector<int, Shape.planeDimensions> offset, int component) { @@ -2557,8 +2557,9 @@ vector<TElement,4> __texture_gather_offset( __intrinsic_asm "$0.gather($1, $2, $3, metal::component($4))"; case spirv: return spirv_asm { + OpCapability ImageGatherExtended; %sampledImage : __sampledImageType(texture) = OpSampledImage $texture $s; - result:$$vector<TElement,4> = OpImageGather %sampledImage $location $component ConstOffset $offset; + result:$$vector<TElement,4> = OpImageGather %sampledImage $location $component Offset $offset; }; case wgsl: if (isShadow == 1) @@ -2606,7 +2607,8 @@ vector<TElement,4> __texture_gather_offset( __intrinsic_asm "textureGatherOffset($0, $1, $2, $3)"; case spirv: return spirv_asm { - result:$$vector<TElement,4> = OpImageGather $sampler $location $component ConstOffset $offset; + OpCapability ImageGatherExtended; + result:$$vector<TElement,4> = OpImageGather $sampler $location $component Offset $offset; }; } } |
