From 0336aefcf49e147c014d7bd22484f7a8954e9081 Mon Sep 17 00:00:00 2001 From: Juha Heiskanen Date: Wed, 17 Mar 2021 10:15:32 +0200 Subject: [PATCH] Add early fragment tests When early fragment tests are enabled, any depth value computed by the fragment shader has no effect. This CL adds 6 new tests, which are enabling the Early Fragment Test Mode for depth calculations. Components: Vulkan VK-GL-CTS Issue: 2738 New Tests: dEQP-VK.spirv_assembly.instruction.graphics.early_fragment* Change-Id: Ieed7012fa413bdd43a4d71acb052d9ded0ae9bf3 --- android/cts/master/vk-master-2021-03-01.txt | 6 + android/cts/master/vk-master.txt | 6 + .../graphics/early_fragment/depth_equal.amber | 150 ++++++++++++++++++++ .../graphics/early_fragment/depth_greater.amber | 151 +++++++++++++++++++++ .../early_fragment/depth_greater_or_equal.amber | 150 ++++++++++++++++++++ .../graphics/early_fragment/depth_less.amber | 151 +++++++++++++++++++++ .../early_fragment/depth_less_or_equal.amber | 150 ++++++++++++++++++++ .../graphics/early_fragment/depth_not_equal.amber | 150 ++++++++++++++++++++ .../spirv_assembly/vktSpvAsmInstructionTests.cpp | 37 +++++ external/vulkancts/mustpass/master/vk-default.txt | 6 + 10 files changed, 957 insertions(+) create mode 100644 external/vulkancts/data/vulkan/amber/spirv_assembly/instruction/graphics/early_fragment/depth_equal.amber create mode 100644 external/vulkancts/data/vulkan/amber/spirv_assembly/instruction/graphics/early_fragment/depth_greater.amber create mode 100644 external/vulkancts/data/vulkan/amber/spirv_assembly/instruction/graphics/early_fragment/depth_greater_or_equal.amber create mode 100644 external/vulkancts/data/vulkan/amber/spirv_assembly/instruction/graphics/early_fragment/depth_less.amber create mode 100644 external/vulkancts/data/vulkan/amber/spirv_assembly/instruction/graphics/early_fragment/depth_less_or_equal.amber create mode 100644 external/vulkancts/data/vulkan/amber/spirv_assembly/instruction/graphics/early_fragment/depth_not_equal.amber diff --git a/android/cts/master/vk-master-2021-03-01.txt b/android/cts/master/vk-master-2021-03-01.txt index d6989e0..906c68f 100644 --- a/android/cts/master/vk-master-2021-03-01.txt +++ b/android/cts/master/vk-master-2021-03-01.txt @@ -104499,6 +104499,12 @@ dEQP-VK.spirv_assembly.instruction.graphics.float32.comparison_4.frexpstruct_tes dEQP-VK.spirv_assembly.instruction.graphics.float32.comparison_4.frexpstruct_tese dEQP-VK.spirv_assembly.instruction.graphics.float32.comparison_4.frexpstruct_geom dEQP-VK.spirv_assembly.instruction.graphics.float32.comparison_4.frexpstruct_frag +dEQP-VK.spirv_assembly.instruction.graphics.early_fragment.depth_less +dEQP-VK.spirv_assembly.instruction.graphics.early_fragment.depth_greater +dEQP-VK.spirv_assembly.instruction.graphics.early_fragment.depth_less_or_equal +dEQP-VK.spirv_assembly.instruction.graphics.early_fragment.depth_greater_or_equal +dEQP-VK.spirv_assembly.instruction.graphics.early_fragment.depth_equal +dEQP-VK.spirv_assembly.instruction.graphics.early_fragment.depth_not_equal dEQP-VK.spirv_assembly.instruction.spirv1p4.hlsl_functionality1.member_decorate_string dEQP-VK.spirv_assembly.instruction.function_params.sampler_param dEQP-VK.spirv_assembly.instruction.amd_trinary_minmax.min3.i8.scalar diff --git a/android/cts/master/vk-master.txt b/android/cts/master/vk-master.txt index d4f469e..73fa803 100644 --- a/android/cts/master/vk-master.txt +++ b/android/cts/master/vk-master.txt @@ -431658,6 +431658,12 @@ dEQP-VK.spirv_assembly.instruction.graphics.64bit_compare.uint64.frag_opulesstha dEQP-VK.spirv_assembly.instruction.graphics.64bit_compare.uint64.frag_opulessthanequal_vector dEQP-VK.spirv_assembly.instruction.graphics.64bit_compare.uint64.frag_opugreaterthan_vector dEQP-VK.spirv_assembly.instruction.graphics.64bit_compare.uint64.frag_opugreaterthanequal_vector +dEQP-VK.spirv_assembly.instruction.graphics.early_fragment.depth_less +dEQP-VK.spirv_assembly.instruction.graphics.early_fragment.depth_greater +dEQP-VK.spirv_assembly.instruction.graphics.early_fragment.depth_less_or_equal +dEQP-VK.spirv_assembly.instruction.graphics.early_fragment.depth_greater_or_equal +dEQP-VK.spirv_assembly.instruction.graphics.early_fragment.depth_equal +dEQP-VK.spirv_assembly.instruction.graphics.early_fragment.depth_not_equal dEQP-VK.spirv_assembly.instruction.spirv1p4.opcopylogical.different_matrix_layout dEQP-VK.spirv_assembly.instruction.spirv1p4.opcopylogical.different_matrix_strides dEQP-VK.spirv_assembly.instruction.spirv1p4.opcopylogical.nested_arrays_different_inner_stride diff --git a/external/vulkancts/data/vulkan/amber/spirv_assembly/instruction/graphics/early_fragment/depth_equal.amber b/external/vulkancts/data/vulkan/amber/spirv_assembly/instruction/graphics/early_fragment/depth_equal.amber new file mode 100644 index 0000000..9af8b04 --- /dev/null +++ b/external/vulkancts/data/vulkan/amber/spirv_assembly/instruction/graphics/early_fragment/depth_equal.amber @@ -0,0 +1,150 @@ +#!amber +# Copyright 2021 Google LLC. +# Copyright 2021 The Khronos Group Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Early Fragment Test 'DepthEqual'. +# Polygon depth: 0.5 +# FragDepth: 0.3 +# Depth compare op: equal +# Execution mode: Any +# Depth buffer clear value: 0.5 +# Description: FragDepth < CLEAR_DEPTH. Depth test should pass. Overwriting the gl_FragDepth is ignored, when Early Fragment Test Mode is enabled. + +SHADER vertex vert_shader GLSL +#version 430 + +layout(location = 0) in vec4 position; + +void main() +{ + gl_Position = vec4(position.xy, 0.5, 1.0); +} +END + +# The fragment shader is generated from following GLSL code: +# version 430 +# +# layout(early_fragment_tests) in; +# +# layout(location = 0) out vec4 color_out; +# layout(depth_any) out float gl_FragDepth; +# +# void main() +# { +# color_out = vec4(1.0, 0.0, 0.0, 1.0); +# gl_FragDepth = 0.3; +# } + +SHADER fragment frag_shader SPIRV-ASM TARGET_ENV spv1.0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %color_out %gl_FragDepth + OpExecutionMode %main OriginUpperLeft + OpExecutionMode %main EarlyFragmentTests + OpExecutionMode %main DepthReplacing + OpSource GLSL 430 + OpName %main "main" + OpName %color_out "color_out" + OpName %gl_FragDepth "gl_FragDepth" + OpDecorate %color_out Location 0 + OpDecorate %gl_FragDepth BuiltIn FragDepth + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %color_out = OpVariable %_ptr_Output_v4float Output + %float_1 = OpConstant %float 1 + %float_0 = OpConstant %float 0 + %12 = OpConstantComposite %v4float %float_1 %float_0 %float_0 %float_1 +%_ptr_Output_float = OpTypePointer Output %float +%gl_FragDepth = OpVariable %_ptr_Output_float Output + %float_0_3 = OpConstant %float 0.3 + %main = OpFunction %void None %3 + %5 = OpLabel + OpStore %color_out %12 + OpStore %gl_FragDepth %float_0_3 + OpReturn + OpFunctionEnd +END + +BUFFER framebuffer FORMAT B8G8R8A8_UNORM +BUFFER depth_buf FORMAT D16_UNORM + +PIPELINE graphics my_pipeline + ATTACH vert_shader + ATTACH frag_shader + DEPTH + TEST on + WRITE on + COMPARE_OP equal + CLAMP off + BOUNDS min 0.0 max 1.0 + BIAS constant 0.0 clamp 0.0 slope 0.0 + END + BIND BUFFER framebuffer AS color LOCATION 0 + BIND BUFFER depth_buf AS depth_stencil +END + +CLEAR_COLOR my_pipeline 0 0 0 255 +CLEAR_DEPTH my_pipeline 0.5 +CLEAR my_pipeline + +RUN my_pipeline DRAW_RECT POS 0 0 SIZE 250 250 + +# ---------------- VERIFY PIPELINE ------------------ +# This pipeline verifies the dept buffer contents. +# The fragment shader writes color green if the value is expected, +# otherwise red. + +SHADER vertex vtex_shader_verify PASSTHROUGH + +SHADER fragment frag_shader_verify GLSL +#version 430 + +layout(location = 0) out vec4 outColor; +uniform layout(set=0, binding=0) sampler2D imageSampler; + +const float expectedValue = 0.5; +const float tolerance = 0.01; + +void main() +{ + float value = texelFetch(imageSampler, ivec2(gl_FragCoord.xy), 0).r; + + if (abs(value - expectedValue) < tolerance) + outColor = vec4(0.0f, 1.0f, 0.0f, 1.0f); + else + outColor = vec4(1.0f, 0.0f, 0.0f, 1.0f); +} +END + +BUFFER framebuffer_verify FORMAT B8G8R8A8_UNORM +SAMPLER sampler +PIPELINE graphics verify_pipeline + ATTACH vtex_shader_verify + ATTACH frag_shader_verify + FRAMEBUFFER_SIZE 250 250 + BIND BUFFER depth_buf AS combined_image_sampler SAMPLER sampler DESCRIPTOR_SET 0 BINDING 0 + BIND BUFFER framebuffer_verify AS color LOCATION 0 +END + +CLEAR_COLOR verify_pipeline 0 0 0 255 +CLEAR verify_pipeline + +RUN verify_pipeline DRAW_RECT POS 0 0 SIZE 250 250 + +EXPECT framebuffer_verify IDX 0 0 SIZE 250 250 EQ_RGBA 0 255 0 255 \ No newline at end of file diff --git a/external/vulkancts/data/vulkan/amber/spirv_assembly/instruction/graphics/early_fragment/depth_greater.amber b/external/vulkancts/data/vulkan/amber/spirv_assembly/instruction/graphics/early_fragment/depth_greater.amber new file mode 100644 index 0000000..e24a2c4 --- /dev/null +++ b/external/vulkancts/data/vulkan/amber/spirv_assembly/instruction/graphics/early_fragment/depth_greater.amber @@ -0,0 +1,151 @@ +#!amber +# Copyright 2021 Google LLC. +# Copyright 2021 The Khronos Group Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Early Fragment Test 'DepthGreater'. +# Polygon depth: 0.6 +# FragDepth: 0.4 +# Depth compare op: greater +# Execution mode: DepthGreater +# Depth buffer clear value: 0.5 +# Description: FragDepth < CLEAR_DEPTH. Depth test should pass. Overwriting the gl_FragDepth is ignored, when Early Fragment Test Mode is enabled. + +SHADER vertex vert_shader GLSL +#version 430 + +layout(location = 0) in vec4 position; + +void main() +{ + gl_Position = vec4(position.xy, 0.6, 1.0); +} +END + +# The fragment shader is generated from following GLSL code: +# version 430 +# +# layout(early_fragment_tests) in; +# +# layout(location = 0) out vec4 color_out; +# layout(depth_greater) out float gl_FragDepth; +# +# void main() +# { +# color_out = vec4(1.0, 0.0, 0.0, 1.0); +# gl_FragDepth = 0.4; +# } + +SHADER fragment frag_shader SPIRV-ASM TARGET_ENV spv1.0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %color_out %gl_FragDepth + OpExecutionMode %main OriginUpperLeft + OpExecutionMode %main EarlyFragmentTests + OpExecutionMode %main DepthReplacing + OpExecutionMode %main DepthGreater + OpSource GLSL 430 + OpName %main "main" + OpName %color_out "color_out" + OpName %gl_FragDepth "gl_FragDepth" + OpDecorate %color_out Location 0 + OpDecorate %gl_FragDepth BuiltIn FragDepth + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %color_out = OpVariable %_ptr_Output_v4float Output + %float_1 = OpConstant %float 1 + %float_0 = OpConstant %float 0 + %12 = OpConstantComposite %v4float %float_1 %float_0 %float_0 %float_1 +%_ptr_Output_float = OpTypePointer Output %float +%gl_FragDepth = OpVariable %_ptr_Output_float Output +%float_0_4 = OpConstant %float 0.4 + %main = OpFunction %void None %3 + %5 = OpLabel + OpStore %color_out %12 + OpStore %gl_FragDepth %float_0_4 + OpReturn + OpFunctionEnd +END + +BUFFER framebuffer FORMAT B8G8R8A8_UNORM +BUFFER depth_buf FORMAT D16_UNORM + +PIPELINE graphics my_pipeline + ATTACH vert_shader + ATTACH frag_shader + DEPTH + TEST on + WRITE on + COMPARE_OP greater + CLAMP off + BOUNDS min 0.0 max 1.0 + BIAS constant 0.0 clamp 0.0 slope 0.0 + END + BIND BUFFER framebuffer AS color LOCATION 0 + BIND BUFFER depth_buf AS depth_stencil +END + +CLEAR_COLOR my_pipeline 0 0 0 255 +CLEAR_DEPTH my_pipeline 0.5 +CLEAR my_pipeline + +RUN my_pipeline DRAW_RECT POS 0 0 SIZE 250 250 + +# ---------------- VERIFY PIPELINE ------------------ +# This pipeline verifies the dept buffer contents. +# The fragment shader writes color green if the value is expected, +# otherwise red. + +SHADER vertex vtex_shader_verify PASSTHROUGH + +SHADER fragment frag_shader_verify GLSL +#version 430 + +layout(location = 0) out vec4 outColor; +uniform layout(set=0, binding=0) sampler2D imageSampler; + +const float expectedValue = 0.6; +const float tolerance = 0.01; + +void main() +{ + float value = texelFetch(imageSampler, ivec2(gl_FragCoord.xy), 0).r; + + if (abs(value - expectedValue) < tolerance) + outColor = vec4(0.0f, 1.0f, 0.0f, 1.0f); + else + outColor = vec4(1.0f, 0.0f, 0.0f, 1.0f); +} +END + +BUFFER framebuffer_verify FORMAT B8G8R8A8_UNORM +SAMPLER sampler +PIPELINE graphics verify_pipeline + ATTACH vtex_shader_verify + ATTACH frag_shader_verify + FRAMEBUFFER_SIZE 250 250 + BIND BUFFER depth_buf AS combined_image_sampler SAMPLER sampler DESCRIPTOR_SET 0 BINDING 0 + BIND BUFFER framebuffer_verify AS color LOCATION 0 +END + +CLEAR_COLOR verify_pipeline 0 0 0 255 +CLEAR verify_pipeline + +RUN verify_pipeline DRAW_RECT POS 0 0 SIZE 250 250 + +EXPECT framebuffer_verify IDX 0 0 SIZE 250 250 EQ_RGBA 0 255 0 255 \ No newline at end of file diff --git a/external/vulkancts/data/vulkan/amber/spirv_assembly/instruction/graphics/early_fragment/depth_greater_or_equal.amber b/external/vulkancts/data/vulkan/amber/spirv_assembly/instruction/graphics/early_fragment/depth_greater_or_equal.amber new file mode 100644 index 0000000..ee9fe0a --- /dev/null +++ b/external/vulkancts/data/vulkan/amber/spirv_assembly/instruction/graphics/early_fragment/depth_greater_or_equal.amber @@ -0,0 +1,150 @@ +#!amber +# Copyright 2021 Google LLC. +# Copyright 2021 The Khronos Group Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Early Fragment Test 'DepthGreaterOrEqual'. +# Polygon depth: 0.5 +# FragDepth: 0.3 +# Depth compare op: greater_or_equal +# Execution mode: Any +# Depth buffer clear value: 0.5 +# Description: FragDepth < CLEAR_DEPTH. Depth test should pass. Overwriting the gl_FragDepth is ignored, when Early Fragment Test Mode is enabled. + +SHADER vertex vert_shader GLSL +#version 430 + +layout(location = 0) in vec4 position; + +void main() +{ + gl_Position = vec4(position.xy, 0.5, 1.0); +} +END + +# The fragment shader is generated from following GLSL code: +# version 430 +# +# layout(early_fragment_tests) in; +# +# layout(location = 0) out vec4 color_out; +# layout(depth_any) out float gl_FragDepth; +# +# void main() +# { +# color_out = vec4(1.0, 0.0, 0.0, 1.0); +# gl_FragDepth = 0.3; +# } + +SHADER fragment frag_shader SPIRV-ASM TARGET_ENV spv1.0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %color_out %gl_FragDepth + OpExecutionMode %main OriginUpperLeft + OpExecutionMode %main EarlyFragmentTests + OpExecutionMode %main DepthReplacing + OpSource GLSL 430 + OpName %main "main" + OpName %color_out "color_out" + OpName %gl_FragDepth "gl_FragDepth" + OpDecorate %color_out Location 0 + OpDecorate %gl_FragDepth BuiltIn FragDepth + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %color_out = OpVariable %_ptr_Output_v4float Output + %float_1 = OpConstant %float 1 + %float_0 = OpConstant %float 0 + %12 = OpConstantComposite %v4float %float_1 %float_0 %float_0 %float_1 +%_ptr_Output_float = OpTypePointer Output %float +%gl_FragDepth = OpVariable %_ptr_Output_float Output + %float_0_3 = OpConstant %float 0.3 + %main = OpFunction %void None %3 + %5 = OpLabel + OpStore %color_out %12 + OpStore %gl_FragDepth %float_0_3 + OpReturn + OpFunctionEnd +END + +BUFFER framebuffer FORMAT B8G8R8A8_UNORM +BUFFER depth_buf FORMAT D16_UNORM + +PIPELINE graphics my_pipeline + ATTACH vert_shader + ATTACH frag_shader + DEPTH + TEST on + WRITE on + COMPARE_OP greater_or_equal + CLAMP off + BOUNDS min 0.0 max 1.0 + BIAS constant 0.0 clamp 0.0 slope 0.0 + END + BIND BUFFER framebuffer AS color LOCATION 0 + BIND BUFFER depth_buf AS depth_stencil +END + +CLEAR_COLOR my_pipeline 0 0 0 255 +CLEAR_DEPTH my_pipeline 0.5 +CLEAR my_pipeline + +RUN my_pipeline DRAW_RECT POS 0 0 SIZE 250 250 + +# ---------------- VERIFY PIPELINE ------------------ +# This pipeline verifies the dept buffer contents. +# The fragment shader writes color green if the value is expected, +# otherwise red. + +SHADER vertex vtex_shader_verify PASSTHROUGH + +SHADER fragment frag_shader_verify GLSL + +#version 430 + +layout(location = 0) out vec4 outColor; +uniform layout(set=0, binding=0) sampler2D imageSampler; + +const float expectedValue = 0.5; +const float tolerance = 0.01; + +void main() +{ + float value = texelFetch(imageSampler, ivec2(gl_FragCoord.xy), 0).r; + if (abs(value - expectedValue) < tolerance) + outColor = vec4(0.0f, 1.0f, 0.0f, 1.0f); + else + outColor = vec4(1.0f, 0.0f, 0.0f, 1.0f); +} +END + +BUFFER framebuffer_verify FORMAT B8G8R8A8_UNORM +SAMPLER sampler +PIPELINE graphics verify_pipeline + ATTACH vtex_shader_verify + ATTACH frag_shader_verify + FRAMEBUFFER_SIZE 250 250 + BIND BUFFER depth_buf AS combined_image_sampler SAMPLER sampler DESCRIPTOR_SET 0 BINDING 0 + BIND BUFFER framebuffer_verify AS color LOCATION 0 +END + +CLEAR_COLOR verify_pipeline 0 0 0 255 +CLEAR verify_pipeline + +RUN verify_pipeline DRAW_RECT POS 0 0 SIZE 250 250 + +EXPECT framebuffer_verify IDX 0 0 SIZE 250 250 EQ_RGBA 0 255 0 255 \ No newline at end of file diff --git a/external/vulkancts/data/vulkan/amber/spirv_assembly/instruction/graphics/early_fragment/depth_less.amber b/external/vulkancts/data/vulkan/amber/spirv_assembly/instruction/graphics/early_fragment/depth_less.amber new file mode 100644 index 0000000..f7805ab --- /dev/null +++ b/external/vulkancts/data/vulkan/amber/spirv_assembly/instruction/graphics/early_fragment/depth_less.amber @@ -0,0 +1,151 @@ +#!amber +# Copyright 2021 Google LLC. +# Copyright 2021 The Khronos Group Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Early Fragment Test 'DepthLess' execution mode. +# Polygon depth: 0.4 +# FragDepth: 0.7 +# Depth compare op: less +# Execution mode: DepthLess +# Depth buffer clear value: 0.5 +# Description: FragDepth > CLEAR_DEPTH. Depth test should pass. Overwriting the gl_FragDepth is ignored, when Early Fragment Test Mode is enabled. + +SHADER vertex vert_shader GLSL +#version 430 + +layout(location = 0) in vec4 position; + +void main() +{ + gl_Position = vec4(position.xy, 0.4, 1.0); +} +END + +# The fragment shader is generated from following GLSL code: +# #version 430 +# +# layout(early_fragment_tests) in; +# +# layout(location = 0) out vec4 color_out; +# layout(depth_less) out float gl_FragDepth; +# +# void main() +# { +# color_out = vec4(1.0, 0.0, 0.0, 1.0); +# gl_FragDepth = 0.7; +# } + +SHADER fragment frag_shader SPIRV-ASM TARGET_ENV spv1.0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %color_out %gl_FragDepth + OpExecutionMode %main OriginUpperLeft + OpExecutionMode %main EarlyFragmentTests + OpExecutionMode %main DepthReplacing + OpExecutionMode %main DepthLess + OpSource GLSL 430 + OpName %main "main" + OpName %color_out "color_out" + OpName %gl_FragDepth "gl_FragDepth" + OpDecorate %color_out Location 0 + OpDecorate %gl_FragDepth BuiltIn FragDepth + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %color_out = OpVariable %_ptr_Output_v4float Output + %float_1 = OpConstant %float 1 + %float_0 = OpConstant %float 0 + %12 = OpConstantComposite %v4float %float_1 %float_0 %float_0 %float_1 +%_ptr_Output_float = OpTypePointer Output %float +%gl_FragDepth = OpVariable %_ptr_Output_float Output +%float_0_7 = OpConstant %float 0.7 + %main = OpFunction %void None %3 + %5 = OpLabel + OpStore %color_out %12 + OpStore %gl_FragDepth %float_0_7 + OpReturn + OpFunctionEnd +END + +BUFFER framebuffer FORMAT B8G8R8A8_UNORM +BUFFER depth_buf FORMAT D16_UNORM + +PIPELINE graphics my_pipeline + ATTACH vert_shader + ATTACH frag_shader + DEPTH + TEST on + WRITE on + COMPARE_OP less + CLAMP off + BOUNDS min 0.0 max 1.0 + BIAS constant 0.0 clamp 0.0 slope 0.0 + END + BIND BUFFER framebuffer AS color LOCATION 0 + BIND BUFFER depth_buf AS depth_stencil +END + +CLEAR_COLOR my_pipeline 0 0 0 255 +CLEAR_DEPTH my_pipeline 0.5 +CLEAR my_pipeline + +RUN my_pipeline DRAW_RECT POS 0 0 SIZE 250 250 + +# ---------------- VERIFY PIPELINE ------------------ +# This pipeline verifies the dept buffer contents. +# The fragment shader writes color green if the value is expected, +# otherwise red. + +SHADER vertex vtex_shader_verify PASSTHROUGH + +SHADER fragment frag_shader_verify GLSL + +#version 430 + +layout(location = 0) out vec4 outColor; +uniform layout(set=0, binding=0) sampler2D imageSampler; + +const float expectedValue = 0.4; +const float tolerance = 0.01; + +void main() +{ + float value = texelFetch(imageSampler, ivec2(gl_FragCoord.xy), 0).r; + if (abs(value - expectedValue) < tolerance) + outColor = vec4(0.0f, 1.0f, 0.0f, 1.0f); + else + outColor = vec4(1.0f, 0.0f, 0.0f, 1.0f); +} +END + +BUFFER framebuffer_verify FORMAT B8G8R8A8_UNORM +SAMPLER sampler +PIPELINE graphics verify_pipeline + ATTACH vtex_shader_verify + ATTACH frag_shader_verify + FRAMEBUFFER_SIZE 250 250 + BIND BUFFER depth_buf AS combined_image_sampler SAMPLER sampler DESCRIPTOR_SET 0 BINDING 0 + BIND BUFFER framebuffer_verify AS color LOCATION 0 +END + +CLEAR_COLOR verify_pipeline 0 0 0 255 +CLEAR verify_pipeline + +RUN verify_pipeline DRAW_RECT POS 0 0 SIZE 250 250 + +EXPECT framebuffer_verify IDX 0 0 SIZE 250 250 EQ_RGBA 0 255 0 255 \ No newline at end of file diff --git a/external/vulkancts/data/vulkan/amber/spirv_assembly/instruction/graphics/early_fragment/depth_less_or_equal.amber b/external/vulkancts/data/vulkan/amber/spirv_assembly/instruction/graphics/early_fragment/depth_less_or_equal.amber new file mode 100644 index 0000000..b983d96 --- /dev/null +++ b/external/vulkancts/data/vulkan/amber/spirv_assembly/instruction/graphics/early_fragment/depth_less_or_equal.amber @@ -0,0 +1,150 @@ +#!amber +# Copyright 2021 Google LLC. +# Copyright 2021 The Khronos Group Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Early Fragment Test 'DepthLessOrEqual'. +# Polygon depth: 0.5 +# FragDepth: 0.7 +# Depth compare op: less_or_equal +# Execution mode: Any +# Depth buffer clear value: 0.5 +# Description: FragDepth > CLEAR_DEPTH. Depth test should pass. Overwriting the gl_FragDepth is ignored, when Early Fragment Test Mode is enabled. + +SHADER vertex vert_shader GLSL +#version 430 + +layout(location = 0) in vec4 position; + +void main() +{ + gl_Position = vec4(position.xy, 0.5, 1.0); +} +END + +# The fragment shader is generated from following GLSL code: +# version 430 +# +# layout(early_fragment_tests) in; +# +# layout(location = 0) out vec4 color_out; +# layout(depth_any) out float gl_FragDepth; +# +# void main() +# { +# color_out = vec4(1.0, 0.0, 0.0, 1.0); +# gl_FragDepth = 0.7; +# } + +SHADER fragment frag_shader SPIRV-ASM TARGET_ENV spv1.0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %color_out %gl_FragDepth + OpExecutionMode %main OriginUpperLeft + OpExecutionMode %main EarlyFragmentTests + OpExecutionMode %main DepthReplacing + OpSource GLSL 430 + OpName %main "main" + OpName %color_out "color_out" + OpName %gl_FragDepth "gl_FragDepth" + OpDecorate %color_out Location 0 + OpDecorate %gl_FragDepth BuiltIn FragDepth + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %color_out = OpVariable %_ptr_Output_v4float Output + %float_1 = OpConstant %float 1 + %float_0 = OpConstant %float 0 + %12 = OpConstantComposite %v4float %float_1 %float_0 %float_0 %float_1 +%_ptr_Output_float = OpTypePointer Output %float +%gl_FragDepth = OpVariable %_ptr_Output_float Output + %float_0_7 = OpConstant %float 0.7 + %main = OpFunction %void None %3 + %5 = OpLabel + OpStore %color_out %12 + OpStore %gl_FragDepth %float_0_7 + OpReturn + OpFunctionEnd +END + +BUFFER framebuffer FORMAT B8G8R8A8_UNORM +BUFFER depth_buf FORMAT D16_UNORM + +PIPELINE graphics my_pipeline + ATTACH vert_shader + ATTACH frag_shader + DEPTH + TEST on + WRITE on + COMPARE_OP less_or_equal + CLAMP off + BOUNDS min 0.0 max 1.0 + BIAS constant 0.0 clamp 0.0 slope 0.0 + END + BIND BUFFER framebuffer AS color LOCATION 0 + BIND BUFFER depth_buf AS depth_stencil +END + +CLEAR_COLOR my_pipeline 0 0 0 255 +CLEAR_DEPTH my_pipeline 0.5 +CLEAR my_pipeline + +RUN my_pipeline DRAW_RECT POS 0 0 SIZE 250 250 + +# ---------------- VERIFY PIPELINE ------------------ +# This pipeline verifies the dept buffer contents. +# The fragment shader writes color green if the value is expected, +# otherwise red. + +SHADER vertex vtex_shader_verify PASSTHROUGH + +SHADER fragment frag_shader_verify GLSL + +#version 430 + +layout(location = 0) out vec4 outColor; +uniform layout(set=0, binding=0) sampler2D imageSampler; + +const float expectedValue = 0.5; +const float tolerance = 0.01; + +void main() +{ + float value = texelFetch(imageSampler, ivec2(gl_FragCoord.xy), 0).r; + if (abs(value - expectedValue) < tolerance) + outColor = vec4(0.0f, 1.0f, 0.0f, 1.0f); + else + outColor = vec4(1.0f, 0.0f, 0.0f, 1.0f); +} +END + +BUFFER framebuffer_verify FORMAT B8G8R8A8_UNORM +SAMPLER sampler +PIPELINE graphics verify_pipeline + ATTACH vtex_shader_verify + ATTACH frag_shader_verify + FRAMEBUFFER_SIZE 250 250 + BIND BUFFER depth_buf AS combined_image_sampler SAMPLER sampler DESCRIPTOR_SET 0 BINDING 0 + BIND BUFFER framebuffer_verify AS color LOCATION 0 +END + +CLEAR_COLOR verify_pipeline 0 0 0 255 +CLEAR verify_pipeline + +RUN verify_pipeline DRAW_RECT POS 0 0 SIZE 250 250 + +EXPECT framebuffer_verify IDX 0 0 SIZE 250 250 EQ_RGBA 0 255 0 255 \ No newline at end of file diff --git a/external/vulkancts/data/vulkan/amber/spirv_assembly/instruction/graphics/early_fragment/depth_not_equal.amber b/external/vulkancts/data/vulkan/amber/spirv_assembly/instruction/graphics/early_fragment/depth_not_equal.amber new file mode 100644 index 0000000..f68e00e --- /dev/null +++ b/external/vulkancts/data/vulkan/amber/spirv_assembly/instruction/graphics/early_fragment/depth_not_equal.amber @@ -0,0 +1,150 @@ +#!amber +# Copyright 2021 Google LLC. +# Copyright 2021 The Khronos Group Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Early Fragment Test 'DepthNotEqual'. +# Polygon depth: 0.3 +# FragDepth: 0.5 +# Depth compare op: not_equal +# Execution mode: Any +# Depth buffer clear value: 0.5 +# Description: FragDepth == CLEAR_DEPTH. Depth test should pass. Overwriting the gl_FragDepth is ignored, when Early Fragment Test Mode is enabled. + +SHADER vertex vert_shader GLSL +#version 430 + +layout(location = 0) in vec4 position; + +void main() +{ + gl_Position = vec4(position.xy, 0.3, 1.0); +} +END + +# The fragment shader is generated from following GLSL code: +# version 430 +# +# layout(early_fragment_tests) in; +# +# layout(location = 0) out vec4 color_out; +# layout(depth_any) out float gl_FragDepth; +# +# void main() +# { +# color_out = vec4(1.0, 0.0, 0.0, 1.0); +# gl_FragDepth = 0.5; +# } + +SHADER fragment frag_shader SPIRV-ASM TARGET_ENV spv1.0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %color_out %gl_FragDepth + OpExecutionMode %main OriginUpperLeft + OpExecutionMode %main EarlyFragmentTests + OpExecutionMode %main DepthReplacing + OpSource GLSL 430 + OpName %main "main" + OpName %color_out "color_out" + OpName %gl_FragDepth "gl_FragDepth" + OpDecorate %color_out Location 0 + OpDecorate %gl_FragDepth BuiltIn FragDepth + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %color_out = OpVariable %_ptr_Output_v4float Output + %float_1 = OpConstant %float 1 + %float_0 = OpConstant %float 0 + %12 = OpConstantComposite %v4float %float_1 %float_0 %float_0 %float_1 +%_ptr_Output_float = OpTypePointer Output %float +%gl_FragDepth = OpVariable %_ptr_Output_float Output + %float_0_5 = OpConstant %float 0.5 + %main = OpFunction %void None %3 + %5 = OpLabel + OpStore %color_out %12 + OpStore %gl_FragDepth %float_0_5 + OpReturn + OpFunctionEnd +END + +BUFFER framebuffer FORMAT B8G8R8A8_UNORM +BUFFER depth_buf FORMAT D16_UNORM + +PIPELINE graphics my_pipeline + ATTACH vert_shader + ATTACH frag_shader + DEPTH + TEST on + WRITE on + COMPARE_OP not_equal + CLAMP off + BOUNDS min 0.0 max 1.0 + BIAS constant 0.0 clamp 0.0 slope 0.0 + END + BIND BUFFER framebuffer AS color LOCATION 0 + BIND BUFFER depth_buf AS depth_stencil +END + +CLEAR_COLOR my_pipeline 0 0 0 255 +CLEAR_DEPTH my_pipeline 0.5 +CLEAR my_pipeline + +RUN my_pipeline DRAW_RECT POS 0 0 SIZE 250 250 + +# ---------------- VERIFY PIPELINE ------------------ +# This pipeline verifies the dept buffer contents. +# The fragment shader writes color green if the value is expected, +# otherwise red. + +SHADER vertex vtex_shader_verify PASSTHROUGH + +SHADER fragment frag_shader_verify GLSL +#version 430 + +layout(location = 0) out vec4 outColor; +uniform layout(set=0, binding=0) sampler2D imageSampler; + +const float expectedValue = 0.3; +const float tolerance = 0.01; + +void main() +{ + float value = texelFetch(imageSampler, ivec2(gl_FragCoord.xy), 0).r; + + if (abs(value - expectedValue) < tolerance) + outColor = vec4(0.0f, 1.0f, 0.0f, 1.0f); + else + outColor = vec4(1.0f, 0.0f, 0.0f, 1.0f); +} +END + +BUFFER framebuffer_verify FORMAT B8G8R8A8_UNORM +SAMPLER sampler +PIPELINE graphics verify_pipeline + ATTACH vtex_shader_verify + ATTACH frag_shader_verify + FRAMEBUFFER_SIZE 250 250 + BIND BUFFER depth_buf AS combined_image_sampler SAMPLER sampler DESCRIPTOR_SET 0 BINDING 0 + BIND BUFFER framebuffer_verify AS color LOCATION 0 +END + +CLEAR_COLOR verify_pipeline 0 0 0 255 +CLEAR verify_pipeline + +RUN verify_pipeline DRAW_RECT POS 0 0 SIZE 250 250 + +EXPECT framebuffer_verify IDX 0 0 SIZE 250 250 EQ_RGBA 0 255 0 255 \ No newline at end of file diff --git a/external/vulkancts/modules/vulkan/spirv_assembly/vktSpvAsmInstructionTests.cpp b/external/vulkancts/modules/vulkan/spirv_assembly/vktSpvAsmInstructionTests.cpp index efa784d..ce10ec9 100644 --- a/external/vulkancts/modules/vulkan/spirv_assembly/vktSpvAsmInstructionTests.cpp +++ b/external/vulkancts/modules/vulkan/spirv_assembly/vktSpvAsmInstructionTests.cpp @@ -20405,6 +20405,42 @@ tcu::TestCaseGroup* createFunctionParamsGroup (tcu::TestContext& testCtx) return testGroup.release(); } +tcu::TestCaseGroup* createEarlyFragmentTests(tcu::TestContext& testCtx) +{ + de::MovePtr earlyFragTests (new tcu::TestCaseGroup(testCtx, "early_fragment", "Early Fragment Tests")); + + static const char dataDir[] = "spirv_assembly/instruction/graphics/early_fragment"; + + static const struct Case + { + const string name; + const string desc; + } + cases[] = + { + // Overwriting the gl_FragDepth should be ignored, when Early Fragment Test Mode is enabled. + { "depth_less", "gl_FragDepth > CLEAR_DEPTH. Polygon depth < CLEAR_DEPTH." }, + { "depth_greater", "gl_FragDepth < CLEAR_DEPTH. Polygon depth > CLEAR_DEPTH." }, + { "depth_less_or_equal", "gl_FragDepth > CLEAR_DEPTH. Polygon depth == CLEAR_DEPTH." }, + { "depth_greater_or_equal", "gl_FragDepth < CLEAR_DEPTH. Polygon depth == CLEAR_DEPTH." }, + { "depth_equal", "gl_FragDepth < CLEAR_DEPTH. Polygon depth == CLEAR_DEPTH." }, + { "depth_not_equal", "gl_FragDepth == CLEAR_DEPTH. Polygon depth < CLEAR_DEPTH." } + }; + + for (const auto& tCase : cases) + { + cts_amber::AmberTestCase* testCase = cts_amber::createAmberTestCase(testCtx, + tCase.name.c_str(), + tCase.desc.c_str(), + dataDir, + tCase.name + ".amber"); + + earlyFragTests->addChild(testCase); + } + + return earlyFragTests.release(); +} + tcu::TestCaseGroup* createInstructionTests (tcu::TestContext& testCtx) { const bool testComputePipeline = true; @@ -20566,6 +20602,7 @@ tcu::TestCaseGroup* createInstructionTests (tcu::TestContext& testCtx) graphicsTests->addChild(createFloat32Tests(testCtx)); graphicsTests->addChild(createSpirvIdsAbuseTests(testCtx)); graphicsTests->addChild(create64bitCompareGraphicsGroup(testCtx)); + graphicsTests->addChild(createEarlyFragmentTests(testCtx)); instructionTests->addChild(computeTests.release()); instructionTests->addChild(graphicsTests.release()); diff --git a/external/vulkancts/mustpass/master/vk-default.txt b/external/vulkancts/mustpass/master/vk-default.txt index eb5b5a2..b2756bc 100644 --- a/external/vulkancts/mustpass/master/vk-default.txt +++ b/external/vulkancts/mustpass/master/vk-default.txt @@ -431644,6 +431644,12 @@ dEQP-VK.spirv_assembly.instruction.graphics.64bit_compare.uint64.frag_opulesstha dEQP-VK.spirv_assembly.instruction.graphics.64bit_compare.uint64.frag_opulessthanequal_vector dEQP-VK.spirv_assembly.instruction.graphics.64bit_compare.uint64.frag_opugreaterthan_vector dEQP-VK.spirv_assembly.instruction.graphics.64bit_compare.uint64.frag_opugreaterthanequal_vector +dEQP-VK.spirv_assembly.instruction.graphics.early_fragment.depth_less +dEQP-VK.spirv_assembly.instruction.graphics.early_fragment.depth_greater +dEQP-VK.spirv_assembly.instruction.graphics.early_fragment.depth_less_or_equal +dEQP-VK.spirv_assembly.instruction.graphics.early_fragment.depth_greater_or_equal +dEQP-VK.spirv_assembly.instruction.graphics.early_fragment.depth_equal +dEQP-VK.spirv_assembly.instruction.graphics.early_fragment.depth_not_equal dEQP-VK.spirv_assembly.instruction.spirv1p4.opcopylogical.different_matrix_layout dEQP-VK.spirv_assembly.instruction.spirv1p4.opcopylogical.different_matrix_strides dEQP-VK.spirv_assembly.instruction.spirv1p4.opcopylogical.nested_arrays_different_inner_stride -- 2.7.4