summaryrefslogtreecommitdiff
path: root/tests/compute/half-texture.slang
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2019-03-27 12:25:43 -0400
committerGitHub <noreply@github.com>2019-03-27 12:25:43 -0400
commitc9930ea56ce0d3d9783d4d2482edb91cb765109e (patch)
tree42bc3b4d44771d1c1bca389f20b9321793d268e1 /tests/compute/half-texture.slang
parent047adbd4dd3dd6e3098adcb63a8ac475ae06d20d (diff)
GLSL half texture access (#931)
* * Added $c macro - that will do casting to target type. Used here to cast texture reads back to half. Works in tandem with $z which will close parens. * half-texture.slang test * Make binding failing if TextureView fails * Simplify logic around parens. * Improve comment around $c macro. * Test against hlsl output to avoid error on CI.
Diffstat (limited to 'tests/compute/half-texture.slang')
-rw-r--r--tests/compute/half-texture.slang41
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/compute/half-texture.slang b/tests/compute/half-texture.slang
new file mode 100644
index 000000000..635336c66
--- /dev/null
+++ b/tests/compute/half-texture.slang
@@ -0,0 +1,41 @@
+//TEST:SIMPLE: -target spirv -entry computeMain -profile cs_6_2
+//TEST:SIMPLE: -target hlsl -entry computeMain -profile cs_6_2
+
+//TEST_INPUT:ubuffer(data=[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0], stride=16):dxbinding(0),glbinding(0),out
+RWStructuredBuffer<int> outputBuffer;
+
+//TEST_INPUT: Texture2D(size=4):dxbinding(1),glbinding(1)
+RWTexture2D<half> halfTexture;
+//TEST_INPUT: Texture2D(size=4):dxbinding(2),glbinding(2)
+RWTexture2D<half2> halfTexture2;
+//TEST_INPUT: Texture2D(size=4):dxbinding(3),glbinding(3)
+RWTexture2D<half4> halfTexture4;
+
+//TEST_INPUT: Sampler : dxbinding(0),glbinding(0)
+SamplerState s;
+
+[numthreads(4, 4, 1)]
+void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
+{
+ int2 pos = int2(dispatchThreadID.xy);
+ float2 uv = pos * (1.0f / 3.0f);
+ int2 pos2 = int2(3 - pos.y, 3 - pos.x);
+
+#if 0
+ half h = halfTexture.Sample(s, uv);
+ half2 h2 = halfTexture2.Sample(s, uv);
+ half4 h4 = halfTexture4.Sample(s, uv);
+#else
+ half h = halfTexture[pos2];
+ half2 h2 = halfTexture2[pos2];
+ half4 h4 = halfTexture4[pos2];
+#endif
+
+ // Store a results
+ halfTexture[pos] = h2.x + h2.y;
+ halfTexture2[pos] = h4.xy;
+ halfTexture4[pos] = half4(h2, h, h);
+
+ int index = pos.x + pos.y * 4;
+ outputBuffer[index] = index;
+} \ No newline at end of file