Skip to content

Commit 7bdb317

Browse files
committed
Check for ARB_texture_storage in CopyTex2DMSToArray and used it
* ARB_texture_view only works on textures allocated with ARB_texture_storage so we have to check for both extensions and then use texture storage to allocate space for the destination array texture.
1 parent 1431fd6 commit 7bdb317

File tree

3 files changed

+41
-15
lines changed

3 files changed

+41
-15
lines changed

renderdoc/driver/gl/gl_debug.cpp

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1627,20 +1627,54 @@ void GLReplay::PickPixel(ResourceId texture, uint32_t x, uint32_t y, uint32_t sl
16271627
}
16281628
}
16291629

1630-
void GLReplay::CopyTex2DMSToArray(GLuint destArray, GLuint srcMS, GLint width, GLint height,
1630+
void GLReplay::CopyTex2DMSToArray(GLuint &destArray, GLuint srcMS, GLint width, GLint height,
16311631
GLint arraySize, GLint samples, GLenum intFormat)
16321632
{
16331633
WrappedOpenGL &gl = *m_pDriver;
16341634

1635-
if(!HasExt[ARB_compute_shader])
1636-
return;
1635+
// create temporary texture array, which we'll initialise to be the width/height in same format,
1636+
// with the same number of array slices as multi samples.
1637+
gl.glGenTextures(1, &destArray);
1638+
gl.glBindTexture(eGL_TEXTURE_2D_ARRAY, destArray);
1639+
1640+
bool failed = false;
1641+
1642+
if(!failed && !HasExt[ARB_compute_shader])
1643+
{
1644+
RDCWARN(
1645+
"Can't copy multisampled texture to array for serialisation without ARB_compute_shader.");
1646+
failed = true;
1647+
}
16371648

1638-
if(!HasExt[ARB_texture_view])
1649+
if(!failed && !HasExt[ARB_texture_view])
16391650
{
16401651
RDCWARN("Can't copy multisampled texture to array for serialisation without ARB_texture_view.");
1652+
failed = true;
1653+
}
1654+
1655+
if(!failed && !HasExt[ARB_texture_storage])
1656+
{
1657+
RDCWARN(
1658+
"Can't copy multisampled texture to array for serialisation without ARB_texture_view, and "
1659+
"ARB_texture_view requires ARB_texture_storage.");
1660+
failed = true;
1661+
}
1662+
1663+
if(failed)
1664+
{
1665+
// create using the non-storage API which is always available, so the texture is at least valid
1666+
// (but with undefined/empty contents).
1667+
gl.glTextureImage3DEXT(destArray, eGL_TEXTURE_2D_ARRAY, 0, intFormat, width, height,
1668+
arraySize * samples, 0, GetBaseFormat(intFormat), GetDataType(intFormat),
1669+
NULL);
1670+
gl.glTexParameteri(eGL_TEXTURE_2D_ARRAY, eGL_TEXTURE_MAX_LEVEL, 0);
16411671
return;
16421672
}
16431673

1674+
// initialise the texture using texture storage, as required for texture views.
1675+
gl.glTextureStorage3DEXT(destArray, eGL_TEXTURE_2D_ARRAY, 1, intFormat, width, height,
1676+
arraySize * samples);
1677+
16441678
GLRenderState rs(&gl.GetHookset(), NULL, READING);
16451679
rs.FetchState(m_pDriver->GetCtx(), m_pDriver);
16461680

renderdoc/driver/gl/gl_replay.cpp

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2485,16 +2485,8 @@ byte *GLReplay::GetTextureData(ResourceId tex, uint32_t arrayIdx, uint32_t mip,
24852485
{
24862486
MakeCurrentReplayContext(m_DebugCtx);
24872487

2488-
// create temporary texture array of width/height in same format to render to,
2489-
// with the same number of array slices as multi samples.
2490-
gl.glGenTextures(1, &tempTex);
2491-
gl.glBindTexture(eGL_TEXTURE_2D_ARRAY, tempTex);
2492-
gl.glTextureImage3DEXT(tempTex, eGL_TEXTURE_2D_ARRAY, 0, intFormat, width, height,
2493-
arraysize * samples, 0, GetBaseFormat(intFormat), GetDataType(intFormat),
2494-
NULL);
2495-
gl.glTexParameteri(eGL_TEXTURE_2D_ARRAY, eGL_TEXTURE_MAX_LEVEL, 0);
2496-
2497-
// copy multisampled texture to an array
2488+
// copy multisampled texture to an array. This creates tempTex and returns it in that variable,
2489+
// for us to own
24982490
CopyTex2DMSToArray(tempTex, texname, width, height, arraysize, samples, intFormat);
24992491

25002492
// rewrite the variables to temporary texture

renderdoc/driver/gl/gl_replay.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ class GLReplay : public IReplayDriver
247247

248248
void CopyArrayToTex2DMS(GLuint destMS, GLuint srcArray, GLint width, GLint height,
249249
GLint arraySize, GLint samples, GLenum intFormat);
250-
void CopyTex2DMSToArray(GLuint destArray, GLuint srcMS, GLint width, GLint height,
250+
void CopyTex2DMSToArray(GLuint &destArray, GLuint srcMS, GLint width, GLint height,
251251
GLint arraySize, GLint samples, GLenum intFormat);
252252

253253
struct OutputWindow : public GLWindowingData

0 commit comments

Comments
 (0)