From 97149601da8241bfb2960e4ca398c317716a2ab0 Mon Sep 17 00:00:00 2001 From: Jake Turner Date: Wed, 6 May 2026 14:48:53 +0100 Subject: [PATCH] VK_Shader_Debug_Zoo changes for compute derivative tests For compute quad derivatives tests use specific derivative i.e. fine or coarse. It isn't specified which derivative mode is used, drivers differ on behaviour. --- util/test/demos/vk/vk_shader_debug_zoo.cpp | 30 ++++++++++++---------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/util/test/demos/vk/vk_shader_debug_zoo.cpp b/util/test/demos/vk/vk_shader_debug_zoo.cpp index 0e7dd82bf..78624e62c 100644 --- a/util/test/demos/vk/vk_shader_debug_zoo.cpp +++ b/util/test/demos/vk/vk_shader_debug_zoo.cpp @@ -1972,6 +1972,7 @@ layout(local_size_x = GROUP_SIZE_X, local_size_y = GROUP_SIZE_Y, local_size_z = layout(QUAD_LAYOUT) in; uvec3 tid; +uvec3 gid; uint flatId; #if WORKGROUP_SUPPORT @@ -1985,25 +1986,31 @@ void SetOutput(vec4 val) void Init(vec4 val) { - tid = gl_LocalInvocationID; - flatId = tid.z * gl_WorkGroupSize.x * gl_WorkGroupSize.y + tid.y * gl_WorkGroupSize.x + tid.x; + flatId = gid.z * gl_WorkGroupSize.x * gl_WorkGroupSize.y + gid.y * gl_WorkGroupSize.x + gid.x; SetOutput(val); } void main() { + // Only want the workgroup (1,0,0) to output results + if ((gl_WorkGroupID.x != 1) || (gl_WorkGroupID.y != 0) || (gl_WorkGroupID.z != 0)) + return; + vec4 testResult = vec4(0); + gid = gl_LocalInvocationID; + tid = gl_GlobalInvocationID; Init(testResult); uint id = flatId; uint ZERO = id / 10000; vec2 inpos; - inpos.xy = gl_LocalInvocationID.xy / 8.0; + inpos.xy = gid.xy / 8.0; #if WORKGROUP_SUPPORT gsmUint4[flatId].xyz = tid; #endif // #if WORKGROUP_SUPPORT #if SUBGROUP_SUPPORT - id += gl_SubgroupInvocationID * ZERO; + id += gl_SubgroupInvocationID; + testResult.w = id * ZERO; #endif // #if SUBGROUP_SUPPORT if(IsTest(0)) @@ -2017,32 +2024,32 @@ void main() } if(IsTest(1)) { - vec3 test1 = dFdx(gl_LocalInvocationID*gl_LocalInvocationID); + vec3 test1 = gid; testResult.xyz = test1; } if(IsTest(2)) { - vec3 test2 = dFdy(gl_LocalInvocationID*gl_LocalInvocationID); + vec3 test2 = tid; testResult.xyz = test2; } if(IsTest(3)) { - vec3 test3 = dFdxFine(gl_LocalInvocationID*gl_LocalInvocationID); + vec3 test3 = dFdxFine(gid*gid*gid); testResult.xyz = test3; } if(IsTest(4)) { - vec3 test4 = dFdyFine(gl_LocalInvocationID*gl_LocalInvocationID); + vec3 test4 = dFdyFine(gid*gid*gid); testResult.xyz = test4; } if(IsTest(5)) { - vec3 test5 = dFdxCoarse(gl_LocalInvocationID*gl_LocalInvocationID); + vec3 test5 = dFdxCoarse(gid*gid); testResult.xyz = test5; } if(IsTest(6)) { - vec3 test6 = dFdyCoarse(gl_LocalInvocationID*gl_LocalInvocationID); + vec3 test6 = dFdyCoarse(gid*gid); testResult.xyz = test6; } if(IsTest(7)) @@ -2088,9 +2095,6 @@ void main() } )EOSHADER"; -#if 0 -#endif // #if 0 - std::string capabilities = "OpCapability Shader\n"; std::string spv_extensions; std::string extinstimport =