From 52ade93e9dc2686d83554ce9000c27ab692613c2 Mon Sep 17 00:00:00 2001 From: Ricardo Garcia Date: Tue, 3 Nov 2020 09:17:17 +0100 Subject: [PATCH] Avoid invalid hit kinds with OpReportIntersection OpReportIntersectionKHR accepts values in the [0, 127] range for the hit kind, while gl_HitKindFrontFacingTriangleEXT or gl_HitKindBackFacingTriangleEXT are reserved values outside that range and should not be used with reportIntersectionEXT() in GLSL. Affected tests: dEQP-VK.ray_tracing_pipeline.builtin.* dEQP-VK.ray_tracing_pipeline.memguarantee.* dEQP-VK.ray_tracing_pipeline.complexcontrolflow.* Components: Vulkan VK-GL-CTS issue: 2626 Change-Id: Ic69abbb53968036ab56ebad4a832485fbccd8fb5 --- .../vulkan/ray_tracing/vktRayTracingBuiltinTests.cpp | 12 ++++++------ .../vktRayTracingComplexControlFlowTests.cpp | 4 ++-- .../ray_tracing/vktRayTracingMemGuaranteeTests.cpp | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/external/vulkancts/modules/vulkan/ray_tracing/vktRayTracingBuiltinTests.cpp b/external/vulkancts/modules/vulkan/ray_tracing/vktRayTracingBuiltinTests.cpp index be88d78bc..58a969d03 100644 --- a/external/vulkancts/modules/vulkan/ray_tracing/vktRayTracingBuiltinTests.cpp +++ b/external/vulkancts/modules/vulkan/ray_tracing/vktRayTracingBuiltinTests.cpp @@ -337,7 +337,7 @@ const std::string RayTracingTestCase::getIntersectionPassthrough (void) "\n" "void main()\n" "{\n" - " reportIntersectionEXT(0.95f, gl_HitKindFrontFacingTriangleEXT);\n" + " reportIntersectionEXT(0.95f, 0x7Eu);\n" "}\n"; return intersectionPassthrough; @@ -660,7 +660,7 @@ void RayTracingTestCase::initPrograms (SourceCollections& programCollection) con "void main()\n" "{\n" " int r = int(gl_" + std::string(m_data.name) + ");\n" - + condition + " reportIntersectionEXT(0.95f, gl_HitKindFrontFacingTriangleEXT);\n" + + condition + " reportIntersectionEXT(0.95f, 0x7Eu);\n" "}\n"; const std::string intersectionShader = condition.empty() ? getIntersectionPassthrough() : intersectionShaderSingle; @@ -721,7 +721,7 @@ void RayTracingTestCase::initPrograms (SourceCollections& programCollection) con "\n" "void main()\n" "{\n" - " uint hitKind = " + std::string(m_data.frontFace ? "gl_HitKindFrontFacingTriangleEXT" : "gl_HitKindBackFacingTriangleEXT") + ";\n" + " uint hitKind = " + std::string(m_data.frontFace ? "0x7Eu" : "0x7Fu") + ";\n" " reportIntersectionEXT(0.95f, hitKind);\n" "}\n"; const std::string raygenFlagsFragment = @@ -999,7 +999,7 @@ void RayTracingTestCase::initPrograms (SourceCollections& programCollection) con "\n" " float a = float(gl_LaunchIDEXT.x) / gl_LaunchSizeEXT.x;\n" " float b = 1.0f + float(gl_LaunchIDEXT.y) / gl_LaunchSizeEXT.y;\n" - " reportIntersectionEXT(0.4375f + 0.25f * a / b, gl_HitKindFrontFacingTriangleEXT);\n" + " reportIntersectionEXT(0.4375f + 0.25f * a / b, 0x7Eu);\n" "}\n"; programCollection.glslSources.add("sect") << glu::IntersectionSource(updateRayTracingGLSL(css.str())) << buildOptions; @@ -1961,9 +1961,9 @@ std::vector RayTracingBuiltinLaunchTestInstance::expectedIntValuesBuffe { const deUint32 n = x + m_data.width * (y + m_data.height * z); const deUint32 geometryNdx = n / m_data.squaresGroupCount; - const deUint32 hitKind = ((geometryNdx & 1) == 0) ? 0xFE : 0xFF; + const deUint32 hitKind = ((geometryNdx & 1) == 0) ? 0xFEu : 0xFFu; const bool geometryOpaque = ((geometryNdx & 2) == 0) ? true : false; - deUint32 v = (m_data.geomType == GEOM_TYPE_TRIANGLES) ? hitKind : 0xFE; + deUint32 v = (m_data.geomType == GEOM_TYPE_TRIANGLES) ? hitKind : 0x7Eu; if (m_data.stage == VK_SHADER_STAGE_ANY_HIT_BIT_KHR && geometryOpaque) v = DEFAULT_UINT_CLEAR_VALUE; diff --git a/external/vulkancts/modules/vulkan/ray_tracing/vktRayTracingComplexControlFlowTests.cpp b/external/vulkancts/modules/vulkan/ray_tracing/vktRayTracingComplexControlFlowTests.cpp index 39e2bcfbf..e4353262b 100644 --- a/external/vulkancts/modules/vulkan/ray_tracing/vktRayTracingComplexControlFlowTests.cpp +++ b/external/vulkancts/modules/vulkan/ray_tracing/vktRayTracingComplexControlFlowTests.cpp @@ -1077,7 +1077,7 @@ const std::string ComplexControlFlowTestCase::getIntersectionPassthrough (void) "\n" "void main()\n" "{\n" - " reportIntersectionEXT(0.95f, gl_HitKindFrontFacingTriangleEXT);\n" + " reportIntersectionEXT(0.95f, 0u);\n" "}\n"; return intersectionPassthrough; @@ -1126,7 +1126,7 @@ void ComplexControlFlowTestCase::initPrograms (SourceCollections& programCollect const std::string idTemplate = "$"; const std::string shaderCallInstruction = (m_data.testOp == TEST_OP_EXECUTE_CALLABLE) ? "executeCallableEXT(0, " + idTemplate + ")" : (m_data.testOp == TEST_OP_TRACE_RAY) ? "traceRayEXT(as, 0, 0xFF, p.hitOfs, 0, p.miss, vec3((gl_LaunchIDEXT.x) + vec3(0.5f)) / vec3(gl_LaunchSizeEXT), 1.0f, vec3(0.0f, 0.0f, 1.0f), 100.0f, " + idTemplate + ")" - : (m_data.testOp == TEST_OP_REPORT_INTERSECTION) ? "reportIntersectionEXT(1.0f, gl_HitKindFrontFacingTriangleEXT)" + : (m_data.testOp == TEST_OP_REPORT_INTERSECTION) ? "reportIntersectionEXT(1.0f, 0u)" : "TEST_OP_NOT_IMPLEMENTED_FAILURE"; std::string declsPreMain = "#version 460 core\n" diff --git a/external/vulkancts/modules/vulkan/ray_tracing/vktRayTracingMemGuaranteeTests.cpp b/external/vulkancts/modules/vulkan/ray_tracing/vktRayTracingMemGuaranteeTests.cpp index 8e4cb8705..502540451 100644 --- a/external/vulkancts/modules/vulkan/ray_tracing/vktRayTracingMemGuaranteeTests.cpp +++ b/external/vulkancts/modules/vulkan/ray_tracing/vktRayTracingMemGuaranteeTests.cpp @@ -308,7 +308,7 @@ void RayTracingTestCase::initPrograms (SourceCollections& programCollection) con const std::string glslExtensions = (m_data.testType == TEST_TYPE_BETWEEN_STAGES ? "#extension GL_KHR_memory_scope_semantics : require\n" : ""); const bool calleeIsAnyHit = (m_data.stage == VK_SHADER_STAGE_INTERSECTION_BIT_KHR); const std::string repackInstruction = calleeIsAnyHit - ? "reportIntersectionEXT(0.95f, gl_HitKindFrontFacingTriangleEXT)" + ? "reportIntersectionEXT(0.95f, 0u)" : "executeCallableEXT(0, 0)"; const std::string updateBarrierCaller = (m_data.testType == TEST_TYPE_BETWEEN_STAGES ? " memoryBarrier(gl_ScopeShaderCallEXT, gl_StorageSemanticsImage, gl_SemanticsRelease);\n" : ""); const std::string updateBarrierCallee = (m_data.testType == TEST_TYPE_BETWEEN_STAGES ? " memoryBarrier(gl_ScopeShaderCallEXT, gl_StorageSemanticsImage, gl_SemanticsAcquire);\n" : ""); -- 2.34.1