summaryrefslogtreecommitdiffstats
path: root/tests/hlsl
diff options
context:
space:
mode:
authorTim Foley <tfoleyNV@users.noreply.github.com>2018-11-19 09:08:26 -0800
committerGitHub <noreply@github.com>2018-11-19 09:08:26 -0800
commit1f4b49596f710e8009d1cc996574049c4afc3627 (patch)
tree873cded8658a74227349082eef9cc24656125e10 /tests/hlsl
parent7e0c5ad677e04be4ecd2ce087d856ba26f1667a4 (diff)
Fix declaration of RWTexture*.Load() operations (#722)
The `Texture2D.Load()` operation takes a `uint3` of coordinates, with the `.xy` part holding the texel coordinates and the `.z` part holding a mip level. In contrast, the `RWTexture2D.Load()` operation only takes a `uint2`. This isn't clearly specified on MSDN, so Slang failed to get the declaration right. This change fixes it so that we only add the extra coordinate for the mip level on non-multisample, read-only texture types (the previous code only checked for multisample-ness). I also changed the logic that outputs swizzles to extract the coordinates and mip level so that it only applies when there is a mip level being passed through (this code should never actually be applied, though, because we shouldn't be generating `texelFetch` for RW texures anyway...). One final change that sneask in here is making the `offset` parameter for one of the load-with-offset cases correctly use the base coordinate count for the texture type (e.g., 2D even for `Texture2DArray`). That is an unrelated fix, but I thought I'd sneak it in here rather than do a separate PR.
Diffstat (limited to 'tests/hlsl')
-rw-r--r--tests/hlsl/simple/rw-texture.hlsl34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/hlsl/simple/rw-texture.hlsl b/tests/hlsl/simple/rw-texture.hlsl
new file mode 100644
index 000000000..26916b474
--- /dev/null
+++ b/tests/hlsl/simple/rw-texture.hlsl
@@ -0,0 +1,34 @@
+// rw-texture.hlsl
+
+//TEST:COMPARE_HLSL:-no-mangle -profile ps_5_0 -entry main
+
+// Ensure that we implement the `Load` operations on
+// `RWTexture*` types with the correct signature.
+
+#ifndef __SLANG__
+#define C C_0
+#define SV_Target SV_TARGET
+#define u2 u2_0
+#define u3 u3_0
+#define t2 t2_0
+#define t2a t2a_0
+#define t3 t3_0
+#endif
+
+
+cbuffer C : register(b0)
+{
+ uint2 u2;
+ uint3 u3;
+};
+
+RWTexture2D<float4> t2 : register(u1);
+RWTexture2DArray<float4> t2a : register(u2);
+RWTexture3D<float4> t3 : register(u3);
+
+float4 main() : SV_Target
+{
+ return t2.Load(u2)
+ + t2a.Load(u3)
+ + t3.Load(u3);
+}