OpenGL Pixel History Multisampling support

- Read pixel value from the selected sample
- Support the average value for multisampled textures
- Mark events that fail sample mask
This commit is contained in:
Orson Baines
2023-01-12 15:41:54 -05:00
committed by Baldur Karlsson
parent 076beab650
commit d87f505a26
8 changed files with 715 additions and 176 deletions
+1
View File
@@ -432,6 +432,7 @@ set(data
data/glsl/quadwrite.frag
data/glsl/pixelhistory_mscopy.comp
data/glsl/pixelhistory_mscopy_depth.comp
data/glsl/pixelhistory_mscopy_gl.comp
data/glsl/pixelhistory_primid.frag
data/glsl/shaderdebug_sample.vert
data/glsl/texdisplay.frag
+1
View File
@@ -65,6 +65,7 @@ DECLARE_EMBED(glsl_depthms2arr_frag);
DECLARE_EMBED(glsl_gles_texsample_h);
DECLARE_EMBED(glsl_pixelhistory_mscopy_comp);
DECLARE_EMBED(glsl_pixelhistory_mscopy_depth_comp);
DECLARE_EMBED(glsl_pixelhistory_mscopy_gl_comp);
DECLARE_EMBED(glsl_pixelhistory_primid_frag);
DECLARE_EMBED(glsl_shaderdebug_sample_vert);
DECLARE_EMBED(glsl_texremap_frag);
@@ -0,0 +1,57 @@
/******************************************************************************
* The MIT License (MIT)
*
* Copyright (c) 2020-2022 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"
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
layout(binding = 0) uniform PRECISION sampler2DMS srcMS;
layout(std140, binding = 1) uniform multisamplePush
{
int sampleIdx;
int x;
int y;
int dstOffset;
}
mscopy;
layout(binding = 2, std140) writeonly buffer pixelhistorydest
{
vec4 result[];
}
dest;
layout(binding = 3) uniform PRECISION sampler2DMS srcDepthMS;
layout(binding = 4) uniform PRECISION usampler2DMS srcStencilMS;
void main()
{
uint pixelOffset = gl_GlobalInvocationID.x;
vec4 data = texelFetch(srcMS, ivec2(mscopy.x + pixelOffset, mscopy.y), mscopy.sampleIdx);
dest.result[mscopy.dstOffset + pixelOffset * 2] = data;
float depthValue =
texelFetch(srcDepthMS, ivec2(mscopy.x + pixelOffset, mscopy.y), mscopy.sampleIdx).x;
uint stencilValue =
texelFetch(srcStencilMS, ivec2(mscopy.x + pixelOffset, mscopy.y), mscopy.sampleIdx).x;
dest.result[mscopy.dstOffset + (pixelOffset * 2) + 1] = vec4(depthValue, float(stencilValue), 0, 0);
}
+1
View File
@@ -155,6 +155,7 @@ RESOURCE_glsl_minmaxresult_comp TYPE_EMBED "glsl/minmaxresult.comp"
RESOURCE_glsl_histogram_comp TYPE_EMBED "glsl/histogram.comp"
RESOURCE_glsl_pixelhistory_mscopy_comp TYPE_EMBED "glsl/pixelhistory_mscopy.comp"
RESOURCE_glsl_pixelhistory_mscopy_depth_comp TYPE_EMBED "glsl/pixelhistory_mscopy_depth.comp"
RESOURCE_glsl_pixelhistory_mscopy_gl_comp TYPE_EMBED "glsl/pixelhistory_mscopy_gl.comp"
RESOURCE_glsl_pixelhistory_primid_frag TYPE_EMBED "glsl/pixelhistory_primid.frag"
RESOURCE_glsl_glsl_ubos_h TYPE_EMBED "glsl/glsl_ubos.h"
RESOURCE_glsl_gl_texsample_h TYPE_EMBED "glsl/gl_texsample.h"
+1
View File
@@ -65,6 +65,7 @@
#define RESOURCE_glsl_vk_depthms2buffer_comp 448
#define RESOURCE_glsl_vk_buffer2ms_comp 449
#define RESOURCE_glsl_vk_depthbuf2ms_frag 450
#define RESOURCE_glsl_pixelhistory_mscopy_gl_comp 451
// Next default values for new objects
//
File diff suppressed because it is too large Load Diff
+1
View File
@@ -699,6 +699,7 @@
<None Include="data\glsl\ms2array.comp" />
<None Include="data\glsl\pixelhistory_mscopy.comp" />
<None Include="data\glsl\pixelhistory_mscopy_depth.comp" />
<None Include="data\glsl\pixelhistory_mscopy_gl.comp" />
<None Include="data\glsl\pixelhistory_primid.frag" />
<None Include="data\glsl\quadresolve.frag" />
<None Include="data\glsl\quadwrite.frag" />
+3
View File
@@ -1109,6 +1109,9 @@
<None Include="data\glsl\pixelhistory_mscopy_depth.comp">
<Filter>Resources\glsl</Filter>
</None>
<None Include="data\glsl\pixelhistory_mscopy_gl.comp">
<Filter>Resources\glsl</Filter>
</None>
<None Include="data\glsl\discard.frag">
<Filter>Resources\glsl</Filter>
</None>