Extend GL Depth Test Overlay

Support shader exported depth by replaying using the capture pixel shader to determine passing pixels via a stencil mask
This commit is contained in:
Jake Turner
2023-11-06 14:38:04 +00:00
parent b804e99ea3
commit de06321536
11 changed files with 245 additions and 13 deletions
+2
View File
@@ -73,5 +73,7 @@ DECLARE_EMBED(glsl_vk_ms2buffer_comp);
DECLARE_EMBED(glsl_vk_depthms2buffer_comp);
DECLARE_EMBED(glsl_vk_buffer2ms_comp);
DECLARE_EMBED(glsl_vk_depthbuf2ms_frag);
DECLARE_EMBED(glsl_depth_copy_frag);
DECLARE_EMBED(glsl_depth_copyms_frag);
#undef DECLARE_EMBED
+41
View File
@@ -0,0 +1,41 @@
/******************************************************************************
* The MIT License (MIT)
*
* Copyright (c) 2020-2023 Baldur Karlsson
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
******************************************************************************/
#include "glsl_globals.h"
#if defined(VULKAN)
layout(binding = 0) uniform sampler2D srcDepth;
#else
uniform PRECISION sampler2D srcDepth;
#endif
void main()
{
ivec2 srcCoord = ivec2(int(gl_FragCoord.x), int(gl_FragCoord.y));
gl_FragDepth = texelFetch(srcDepth, srcCoord, 0).x;
}
+47
View File
@@ -0,0 +1,47 @@
/******************************************************************************
* The MIT License (MIT)
*
* Copyright (c) 2020-2023 Baldur Karlsson
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
******************************************************************************/
#if defined(GLES)
#extension GL_OES_sample_variables : require
#elif defined(OPENGL_CORE)
#extension GL_ARB_sample_shading : require
#endif
#include "glsl_globals.h"
#if defined(VULKAN)
layout(binding = 0) uniform sampler2DMS srcDepth;
#else
uniform PRECISION sampler2DMS srcDepth;
#endif
void main()
{
ivec2 srcCoord = ivec2(int(gl_FragCoord.x), int(gl_FragCoord.y));
gl_FragDepth = texelFetch(srcDepth, srcCoord, gl_SampleID).x;
}
+2
View File
@@ -148,6 +148,8 @@ RESOURCE_glsl_texdisplay_frag TYPE_EMBED "glsl/texdisplay.frag"
RESOURCE_glsl_vktext_vert TYPE_EMBED "glsl/vktext.vert"
RESOURCE_glsl_vktext_frag TYPE_EMBED "glsl/vktext.frag"
RESOURCE_glsl_fixedcol_frag TYPE_EMBED "glsl/fixedcol.frag"
RESOURCE_glsl_depth_copy_frag TYPE_EMBED "glsl/depth_copy.frag"
RESOURCE_glsl_depth_copyms_frag TYPE_EMBED "glsl/depth_copyms.frag"
RESOURCE_glsl_mesh_vert TYPE_EMBED "glsl/mesh.vert"
RESOURCE_glsl_mesh_geom TYPE_EMBED "glsl/mesh.geom"
RESOURCE_glsl_mesh_frag TYPE_EMBED "glsl/mesh.frag"
+2
View File
@@ -66,6 +66,8 @@
#define RESOURCE_glsl_vk_depthms2buffer_comp 448
#define RESOURCE_glsl_vk_buffer2ms_comp 449
#define RESOURCE_glsl_vk_depthbuf2ms_frag 450
#define RESOURCE_glsl_depth_copy_frag 451
#define RESOURCE_glsl_depth_copyms_frag 452
// Next default values for new objects
//