summaryrefslogtreecommitdiffstats
path: root/tests/compute
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2021-02-17 15:09:09 -0800
committerGitHub <noreply@github.com>2021-02-17 15:09:09 -0800
commite59aee131b6d51236613bc374cfa2d5f3b54efe1 (patch)
tree1225fb886e6b280ca50d737c1769bb8465480692 /tests/compute
parent39975b207e5db7de8feaaebfda2ae122c1850b26 (diff)
Add `SampleGrad` overload for lod clamp. (#1711)
* Add `SampleGrad` overload for lod clamp. * Fix gfx to run the test on vulkan. * Whitespace change to trigger CI build * remove presentFrame call in render-test Co-authored-by: Yong He <yhe@nvidia.com> Co-authored-by: Tim Foley <tfoleyNV@users.noreply.github.com>
Diffstat (limited to 'tests/compute')
-rw-r--r--tests/compute/texture-sample-grad-offset-clamp.slang85
-rw-r--r--tests/compute/texture-sample-grad-offset-clamp.slang.expected.txt1
2 files changed, 86 insertions, 0 deletions
diff --git a/tests/compute/texture-sample-grad-offset-clamp.slang b/tests/compute/texture-sample-grad-offset-clamp.slang
new file mode 100644
index 000000000..2a7d4d79a
--- /dev/null
+++ b/tests/compute/texture-sample-grad-offset-clamp.slang
@@ -0,0 +1,85 @@
+//TEST(compute, vulkan):COMPARE_RENDER_COMPUTE:-vk -shaderobj
+//TEST(compute):COMPARE_RENDER_COMPUTE:-shaderobj
+
+//TEST_INPUT: Texture2D(size=4, content = one):name=t2D
+//TEST_INPUT: Sampler:name=samplerState
+//TEST_INPUT: ubuffer(data=[0], stride=4):out,name=outputBuffer
+
+Texture2D t2D;
+SamplerState samplerState;
+RWStructuredBuffer<float> outputBuffer;
+
+cbuffer Uniforms
+{
+ float4x4 modelViewProjection;
+}
+
+struct AssembledVertex
+{
+ float3 position;
+ float3 color;
+ float2 uv;
+};
+
+struct CoarseVertex
+{
+ float3 color;
+ float2 uv;
+};
+
+struct Fragment
+{
+ float4 color;
+};
+
+
+// Vertex Shader
+
+struct VertexStageInput
+{
+ AssembledVertex assembledVertex : A;
+};
+
+struct VertexStageOutput
+{
+ CoarseVertex coarseVertex : CoarseVertex;
+ float4 sv_position : SV_Position;
+};
+
+VertexStageOutput vertexMain(VertexStageInput input)
+{
+ VertexStageOutput output;
+
+ float3 position = input.assembledVertex.position;
+ float3 color = input.assembledVertex.color;
+
+ output.coarseVertex.color = color;
+ output.sv_position = mul(modelViewProjection, float4(position, 1.0));
+ output.coarseVertex.uv = input.assembledVertex.uv;
+ return output;
+}
+
+// Fragment Shader
+
+struct FragmentStageInput
+{
+ CoarseVertex coarseVertex : CoarseVertex;
+};
+
+struct FragmentStageOutput
+{
+ Fragment fragment : SV_Target;
+};
+
+FragmentStageOutput fragmentMain(FragmentStageInput input)
+{
+ FragmentStageOutput output;
+
+ float3 color = input.coarseVertex.color;
+ float2 uv = input.coarseVertex.uv;
+ output.fragment.color = float4(color, 1.0);
+
+ float4 val = t2D.SampleGrad(samplerState, uv, float2(0,0), float2(0,0), 0, 0.5f);
+ outputBuffer[0] = val.x;
+ return output;
+}
diff --git a/tests/compute/texture-sample-grad-offset-clamp.slang.expected.txt b/tests/compute/texture-sample-grad-offset-clamp.slang.expected.txt
new file mode 100644
index 000000000..47b9ba0c8
--- /dev/null
+++ b/tests/compute/texture-sample-grad-offset-clamp.slang.expected.txt
@@ -0,0 +1 @@
+3F800000 \ No newline at end of file