mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-07-31 11:51:04 +00:00
Fix handling of S8 multisampled textures. Closes #2883
This commit is contained in:
@@ -108,6 +108,7 @@ precision highp int;
|
||||
#define SHADER_D24_UNORM_S8_UINT 3
|
||||
#define SHADER_D32_SFLOAT 4
|
||||
#define SHADER_D32_SFLOAT_S8_UINT 5
|
||||
#define SHADER_S8_UINT 6
|
||||
|
||||
// divide MS<->buffer workgroups by 64
|
||||
#define MS_DISPATCH_LOCAL_SIZE 64
|
||||
|
||||
@@ -102,6 +102,26 @@ void main()
|
||||
uint stencilData = srcData[idx * 2 + 1];
|
||||
stencil = stencilData & 0xFF;
|
||||
}
|
||||
else if(format == SHADER_S8_UINT)
|
||||
{
|
||||
uint stencilData = srcData[idx / 4];
|
||||
if((idx % 4) == 0)
|
||||
{
|
||||
stencil = stencilData & 0x000000FF;
|
||||
}
|
||||
else if((idx % 4) == 1)
|
||||
{
|
||||
stencil = (stencilData & 0x0000FF00) >> 8;
|
||||
}
|
||||
else if((idx % 4) == 2)
|
||||
{
|
||||
stencil = (stencilData & 0x00FF0000) >> 16;
|
||||
}
|
||||
else
|
||||
{
|
||||
stencil = (stencilData & 0xFF000000) >> 24;
|
||||
}
|
||||
}
|
||||
|
||||
if(currentStencil < 256u)
|
||||
{
|
||||
|
||||
@@ -115,4 +115,24 @@ void main()
|
||||
result[dispatchOffset + (idx * 2 + 0)] = floatBitsToUint(depth);
|
||||
result[dispatchOffset + (idx * 2 + 1)] = stencil;
|
||||
}
|
||||
// For S8, we need to sample 4 pixels at a time
|
||||
else if(format == SHADER_S8_UINT)
|
||||
{
|
||||
int pxIdx = int(idx * 4);
|
||||
int x0 = (pxIdx + 0) % textureWidth;
|
||||
int y0 = (pxIdx + 0) / textureWidth;
|
||||
int x1 = (pxIdx + 1) % textureWidth;
|
||||
int y1 = (pxIdx + 1) / textureWidth;
|
||||
int x2 = (pxIdx + 2) % textureWidth;
|
||||
int y2 = (pxIdx + 2) / textureWidth;
|
||||
int x3 = (pxIdx + 3) % textureWidth;
|
||||
int y3 = (pxIdx + 3) / textureWidth;
|
||||
|
||||
uvec4 stencil = uvec4(texelFetch(srcStencilMS, ivec3(x0, y0, slice), sampleIdx).x,
|
||||
texelFetch(srcStencilMS, ivec3(x1, y1, slice), sampleIdx).x,
|
||||
texelFetch(srcStencilMS, ivec3(x2, y2, slice), sampleIdx).x,
|
||||
texelFetch(srcStencilMS, ivec3(x3, y3, slice), sampleIdx).x);
|
||||
result[dispatchOffset + idx] = ((stencil.x & 0xFF) << 0) | ((stencil.y & 0xFF) << 8) |
|
||||
((stencil.z & 0xFF) << 16) | ((stencil.w & 0xFF) << 24);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user