mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-09-23 06:05:45 +00:00
Add basic support for displaying/picking S8 textures. Refs #165
This commit is contained in:
@@ -177,6 +177,7 @@ enum SpecialFormat
|
||||
eSpecial_B4G4R4A4,
|
||||
eSpecial_D24S8,
|
||||
eSpecial_D32S8,
|
||||
eSpecial_S8,
|
||||
eSpecial_YUV,
|
||||
};
|
||||
|
||||
|
||||
@@ -508,6 +508,8 @@ DXGI_FORMAT ResourceFormat2DXGIFormat(ResourceFormat format)
|
||||
return DXGI_FORMAT_D24_UNORM_S8_UINT;
|
||||
case eSpecial_D32S8:
|
||||
return DXGI_FORMAT_D32_FLOAT_S8X24_UINT;
|
||||
case eSpecial_S8:
|
||||
return DXGI_FORMAT_R8_UINT;
|
||||
default:
|
||||
case eSpecial_ETC2:
|
||||
case eSpecial_EAC:
|
||||
@@ -736,6 +738,9 @@ bool write_dds_to_file(FILE *f, const dds_data &data)
|
||||
{
|
||||
switch(data.format.specialFormat)
|
||||
{
|
||||
case eSpecial_S8:
|
||||
bytesPerPixel = 1;
|
||||
break;
|
||||
case eSpecial_R10G10B10A2:
|
||||
case eSpecial_R9G9B9E5:
|
||||
case eSpecial_R11G11B10:
|
||||
@@ -1005,6 +1010,9 @@ dds_data load_dds_from_file(FILE *f)
|
||||
uint32_t bytesPerPixel = 1;
|
||||
switch(ret.format.specialFormat)
|
||||
{
|
||||
case eSpecial_S8:
|
||||
bytesPerPixel = 1;
|
||||
break;
|
||||
case eSpecial_R10G10B10A2:
|
||||
case eSpecial_R9G9B9E5:
|
||||
case eSpecial_R11G11B10:
|
||||
|
||||
@@ -292,6 +292,9 @@ DXGI_FORMAT MakeDXGIFormat(ResourceFormat fmt)
|
||||
ret = DXGI_FORMAT_AYUV;
|
||||
break;
|
||||
#endif
|
||||
case eSpecial_S8:
|
||||
RDCERR("D3D11 has no stencil-only format");
|
||||
break;
|
||||
default:
|
||||
RDCERR("Unrecognised special format");
|
||||
break;
|
||||
|
||||
@@ -859,6 +859,10 @@ ResourceFormat MakeResourceFormat(WrappedOpenGL &gl, GLenum target, GLenum fmt)
|
||||
ret.specialFormat = eSpecial_D32S8;
|
||||
ret.special = true;
|
||||
break;
|
||||
case eGL_STENCIL_INDEX8:
|
||||
ret.specialFormat = eSpecial_S8;
|
||||
ret.special = true;
|
||||
break;
|
||||
default:
|
||||
RDCERR("Unexpected depth or stencil format %x", fmt);
|
||||
}
|
||||
@@ -954,6 +958,9 @@ GLenum MakeGLFormat(WrappedOpenGL &gl, ResourceFormat fmt)
|
||||
case eSpecial_D32S8:
|
||||
ret = eGL_DEPTH32F_STENCIL8;
|
||||
break;
|
||||
case eSpecial_S8:
|
||||
ret = eGL_STENCIL_INDEX8;
|
||||
break;
|
||||
default:
|
||||
RDCERR("Unsupported special format %u", fmt.specialFormat);
|
||||
break;
|
||||
|
||||
@@ -1231,7 +1231,8 @@ void GLReplay::PickPixel(ResourceId texture, uint32_t x, uint32_t y, uint32_t sl
|
||||
// need to read stencil separately as GL can't read both depth and stencil
|
||||
// at the same time.
|
||||
if(texDetails.internalFormat == eGL_DEPTH24_STENCIL8 ||
|
||||
texDetails.internalFormat == eGL_DEPTH32F_STENCIL8)
|
||||
texDetails.internalFormat == eGL_DEPTH32F_STENCIL8 ||
|
||||
texDetails.internalFormat == eGL_STENCIL_INDEX8)
|
||||
{
|
||||
texDisplay.Red = texDisplay.Blue = texDisplay.Alpha = false;
|
||||
|
||||
@@ -1241,6 +1242,14 @@ void GLReplay::PickPixel(ResourceId texture, uint32_t x, uint32_t y, uint32_t sl
|
||||
gl.glReadPixels(0, 0, 1, 1, eGL_RGBA, eGL_FLOAT, (void *)stencilpixel);
|
||||
|
||||
pixel[1] = float(stencilpixel[1])/255.0f;
|
||||
|
||||
// the first depth read will have read stencil instead.
|
||||
// NULL it out so the UI sees only stencil
|
||||
if(texDetails.internalFormat == eGL_STENCIL_INDEX8)
|
||||
{
|
||||
pixel[1] = float(stencilpixel[0])/255.0f;
|
||||
pixel[0] = 0.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1387,6 +1396,15 @@ bool GLReplay::RenderTextureInternal(TextureDisplay cfg, bool blendAlpha)
|
||||
RDCGLenum dsTexMode = eGL_NONE;
|
||||
if(IsDepthStencilFormat(texDetails.internalFormat))
|
||||
{
|
||||
// stencil-only, make sure we display it as such
|
||||
if(texDetails.internalFormat == eGL_STENCIL_INDEX8)
|
||||
{
|
||||
cfg.Red = false;
|
||||
cfg.Green = true;
|
||||
cfg.Blue = false;
|
||||
cfg.Alpha = false;
|
||||
}
|
||||
|
||||
if (!cfg.Red && cfg.Green)
|
||||
{
|
||||
dsTexMode = eGL_STENCIL_INDEX;
|
||||
|
||||
@@ -158,6 +158,7 @@ size_t GetByteSize(GLsizei w, GLsizei h, GLsizei d, GLenum format, GLenum type)
|
||||
case eGL_ALPHA:
|
||||
case eGL_DEPTH_COMPONENT:
|
||||
case eGL_STENCIL_INDEX:
|
||||
case eGL_STENCIL:
|
||||
return w*h*d*elemSize;
|
||||
case eGL_RG:
|
||||
case eGL_RG_INTEGER:
|
||||
|
||||
@@ -669,6 +669,9 @@ bool ReplayRenderer::SaveTexture(const TextureSave &saveData, const char *path)
|
||||
{
|
||||
switch(td.format.specialFormat)
|
||||
{
|
||||
case eSpecial_S8:
|
||||
bytesPerPixel = 1;
|
||||
break;
|
||||
case eSpecial_R10G10B10A2:
|
||||
case eSpecial_R9G9B9E5:
|
||||
case eSpecial_R11G11B10:
|
||||
|
||||
@@ -179,6 +179,7 @@ namespace renderdoc
|
||||
B4G4R4A4,
|
||||
D24S8,
|
||||
D32S8,
|
||||
S8,
|
||||
YUV,
|
||||
};
|
||||
|
||||
|
||||
@@ -258,7 +258,8 @@ namespace renderdocui.Windows
|
||||
|
||||
if (texture.format.compType == FormatComponentType.Depth ||
|
||||
(texture.format.special && texture.format.specialFormat == SpecialFormat.D24S8) ||
|
||||
(texture.format.special && texture.format.specialFormat == SpecialFormat.D32S8))
|
||||
(texture.format.special && texture.format.specialFormat == SpecialFormat.D32S8) ||
|
||||
(texture.format.special && texture.format.specialFormat == SpecialFormat.S8))
|
||||
depth = true;
|
||||
|
||||
TreelistView.Node node = null;
|
||||
@@ -322,7 +323,8 @@ namespace renderdocui.Windows
|
||||
|
||||
if (texture.format.compType == FormatComponentType.Depth ||
|
||||
(texture.format.special && texture.format.specialFormat == SpecialFormat.D24S8) ||
|
||||
(texture.format.special && texture.format.specialFormat == SpecialFormat.D32S8))
|
||||
(texture.format.special && texture.format.specialFormat == SpecialFormat.D32S8) ||
|
||||
(texture.format.special && texture.format.specialFormat == SpecialFormat.S8))
|
||||
depth = true;
|
||||
|
||||
var drawcall = m_Core.GetDrawcall(m_Core.CurFrame, mods[0].eventID);
|
||||
|
||||
Reference in New Issue
Block a user