diff options
| author | Tim Foley <tfoleyNV@users.noreply.github.com> | 2019-01-25 12:02:50 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-01-25 12:02:50 -0800 |
| commit | 41fde4b836dbab627f8643a5002b2b6dd0417211 (patch) | |
| tree | 1b1030137fc25403f4b414328dee72e08ea88344 /tests/cross-compile/texture-load.slang | |
| parent | 027e4518ad52b39e4600fa1f94dcae6ce370519f (diff) | |
Fix GLSL translation of several Texture* operations (#800)
A user found that the `Texture2D<float2>.Load(...)` operation was not being compiled to GLSL properly, such that it returned a `vec4` instead of the expected `vec2`.
The GLSL texture-related functions always return (and take) 4-component vectors, and we already have infrastructure in `emit.cpp` for recognizing a `$z` operator in the GLSL intrinsic definition to stand in for an appropriate swizzle based on teh number of components in the texture result type.
This change just adds that `$z` operator to the GLSL code for several more texture operations (including `Load()`) that are defined on a `Texture*<T>` and that return `T`.
This change doesn't try to add additional GLSL translations for texture-related operations (e.g., additional variations like `SampleCmp` that we have defined in the stdlib but not given GLSL translations for). That work still needs to be done.
Diffstat (limited to 'tests/cross-compile/texture-load.slang')
| -rw-r--r-- | tests/cross-compile/texture-load.slang | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/cross-compile/texture-load.slang b/tests/cross-compile/texture-load.slang new file mode 100644 index 000000000..71f22b13a --- /dev/null +++ b/tests/cross-compile/texture-load.slang @@ -0,0 +1,21 @@ +// texture-load.slang + +// Confirm that texture `Load` operations yield the +// expected type when compiled to SPIR-V. + +//TEST:CROSS_COMPILE:-target spirv-assembly -entry main -stage compute + +Texture2D<float2> inputTexture; +RWTexture2D<float2> outputTexture; + +cbuffer C +{ + int2 pos; +} + +[numthreads(16, 16, 1)] +void main(uint2 pixelIndex : SV_DispatchThreadID) +{ + float2 tmp = inputTexture.Load(int3(pos,0)); + outputTexture[pos] = tmp; +} |
