From 9561f88fd582c8176aaa4d73ba7619e5f30a0d7c Mon Sep 17 00:00:00 2001 From: baldurk Date: Fri, 5 Dec 2014 09:28:34 +0000 Subject: [PATCH] As a hack for now, don't save/restore D32F_S8 texture data * On nvidia it seems that doing glCopyImageSubData() on a D32F_S8 texture can cause serious problems, so ignore it for now. We can generally get away with it, as usually the only depth buffer in this format is the 'main' depth buffer, which isn't used frame-to-frame. --- renderdoc/driver/gl/gl_common.cpp | 3 +++ renderdoc/driver/gl/gl_common.h | 1 + renderdoc/driver/gl/gl_manager.cpp | 22 +++++++++++++++++++--- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/renderdoc/driver/gl/gl_common.cpp b/renderdoc/driver/gl/gl_common.cpp index 102422657..e0e2714c5 100644 --- a/renderdoc/driver/gl/gl_common.cpp +++ b/renderdoc/driver/gl/gl_common.cpp @@ -155,6 +155,9 @@ void DoVendorChecks(const GLHookSet &gl) gl.glDeleteTextures(1, &dummy); } + + // don't have a test for this, just have to enable it all the time, for now. + ExtensionSupport::VendorChecks[VendorCheck_NV_avoid_D32S8_copy] = true; } bool ExtensionSupported(ExtensionCheckEnum ext) diff --git a/renderdoc/driver/gl/gl_common.h b/renderdoc/driver/gl/gl_common.h index b1f5b3004..66c906911 100644 --- a/renderdoc/driver/gl/gl_common.h +++ b/renderdoc/driver/gl/gl_common.h @@ -104,6 +104,7 @@ enum VendorCheckEnum { VendorCheck_AMD_vertex_buffer_query, VendorCheck_EXT_compressed_cube_size, + VendorCheck_NV_avoid_D32S8_copy, VendorCheck_Count, }; bool VendorCheck(VendorCheckEnum ext); diff --git a/renderdoc/driver/gl/gl_manager.cpp b/renderdoc/driver/gl/gl_manager.cpp index 34add5112..edef421c4 100644 --- a/renderdoc/driver/gl/gl_manager.cpp +++ b/renderdoc/driver/gl/gl_manager.cpp @@ -265,7 +265,15 @@ bool GLResourceManager::Prepare_InitialState(GLResource res) if(details.curType == eGL_TEXTURE_CUBE_MAP) d *= 6; - gl.glCopyImageSubData(res.name, details.curType, i, 0, 0, 0, tex, details.curType, i, 0, 0, 0, w, h, d); + // it seems like everything explodes if I do glCopyImageSubData on a D32F_S8 texture - in-program the overlay + // gets corrupted as one UBO seems to not provide data anymore until it's "refreshed". It seems like a driver bug, + // nvidia specific. + // In most cases a program isn't going to rely on the contents of a depth-stencil buffer (shadow maps that it might + // require would be depth-only formatted). + if(details.internalFormat == eGL_DEPTH32F_STENCIL8 && VendorCheck(VendorCheck_NV_avoid_D32S8_copy)) + RDCDEBUG("Not fetching initial contents of D32F_S8 texture"); + else + gl.glCopyImageSubData(res.name, details.curType, i, 0, 0, 0, tex, details.curType, i, 0, 0, 0, w, h, d); } gl.glTextureParameterivEXT(res.name, details.curType, eGL_TEXTURE_MAX_LEVEL, (GLint *)&state->maxLevel); @@ -871,8 +879,16 @@ void GLResourceManager::Apply_InitialState(GLResource live, InitialContentData i if(details.curType == eGL_TEXTURE_CUBE_MAP) d *= 6; - - gl.glCopyImageSubData(tex, details.curType, i, 0, 0, 0, live.name, details.curType, i, 0, 0, 0, w, h, d); + + // it seems like everything explodes if I do glCopyImageSubData on a D32F_S8 texture - on replay loads of things + // get heavily corrupted - probably the same as the problems we get in-program, but magnified. It seems like a driver bug, + // nvidia specific. + // In most cases a program isn't going to rely on the contents of a depth-stencil buffer (shadow maps that it might + // require would be depth-only formatted). + if(details.internalFormat == eGL_DEPTH32F_STENCIL8 && VendorCheck(VendorCheck_NV_avoid_D32S8_copy)) + RDCDEBUG("Not fetching initial contents of D32F_S8 texture"); + else + gl.glCopyImageSubData(tex, details.curType, i, 0, 0, 0, live.name, details.curType, i, 0, 0, 0, w, h, d); } TextureStateInitialData *state = (TextureStateInitialData *)initial.blob;