mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-10-16 00:59:22 +00:00
Fix reading back compressed texture data during remote replay
This commit is contained in:
1 parent
860eeace4c
commit
faf93fa2ac
3 files changed
+19
-33
No files matched your search
@@ -287,6 +287,8 @@ private:
|
||||
// uploading
|
||||
// level -> data
|
||||
map<int, vector<byte> > compressedData;
|
||||
|
||||
void GetCompressedImageDataGLES(int mip, GLenum target, size_t size, byte *buf);
|
||||
};
|
||||
|
||||
map<ResourceId, TextureData> m_Textures;
|
||||
|
||||
@@ -660,20 +660,19 @@ void GLResourceManager::CreateTextureImage(GLuint tex, GLenum internalFormat, GL
|
||||
}
|
||||
}
|
||||
|
||||
static void GetCompressedImageDataGLES(const vector<byte> &data, GLenum target, size_t size, byte *buf)
|
||||
void WrappedOpenGL::TextureData::GetCompressedImageDataGLES(int mip, GLenum target, size_t size,
|
||||
byte *buf)
|
||||
{
|
||||
const bool isCubeFace = IsCubeFace(target);
|
||||
size_t startOffs = isCubeFace ? CubeTargetIndex(target) * size : 0;
|
||||
if(data.size() >= startOffs + size)
|
||||
const vector<byte> &data = compressedData[mip];
|
||||
|
||||
memset(buf, 0, size);
|
||||
|
||||
size_t startOffs = IsCubeFace(target) ? CubeTargetIndex(target) * size : 0;
|
||||
if(data.size() >= startOffs)
|
||||
{
|
||||
memcpy(buf, data.data() + startOffs, size);
|
||||
}
|
||||
else
|
||||
{
|
||||
// we don't warn for cube maps because some cube faces can be missing
|
||||
if(!isCubeFace)
|
||||
RDCERR("Different expected and stored compressed texture sizes!");
|
||||
memset(buf, 0, size);
|
||||
size_t byteSize = RDCMIN(data.size() - startOffs, size);
|
||||
if(byteSize > 0)
|
||||
memcpy(buf, data.data() + startOffs, byteSize);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -887,7 +886,7 @@ void GLResourceManager::PrepareTextureInitialContents(ResourceId liveid, Resourc
|
||||
|
||||
if(IsGLES)
|
||||
{
|
||||
GetCompressedImageDataGLES(details.compressedData[i], targets[trg], size, buf);
|
||||
details.GetCompressedImageDataGLES(i, targets[trg], size, buf);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1270,7 +1269,7 @@ bool GLResourceManager::Serialise_InitialState(ResourceId resid, GLResource res)
|
||||
|
||||
if(IsGLES)
|
||||
{
|
||||
GetCompressedImageDataGLES(details.compressedData[i], targets[trg], size, buf);
|
||||
details.GetCompressedImageDataGLES(i, targets[trg], size, buf);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1860,7 +1859,7 @@ void GLResourceManager::Apply_InitialState(GLResource live, InitialContentData i
|
||||
|
||||
if(IsGLES)
|
||||
{
|
||||
GetCompressedImageDataGLES(details.compressedData[i], targets[trg], size, buf);
|
||||
details.GetCompressedImageDataGLES(i, targets[trg], size, buf);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -2580,17 +2580,10 @@ byte *GLReplay::GetTextureData(ResourceId tex, uint32_t arrayIdx, uint32_t mip,
|
||||
{
|
||||
m_GetTexturePrevData[mip] = new byte[dataSize * arraysize];
|
||||
if(IsGLES)
|
||||
{
|
||||
const vector<byte> &data = texDetails.compressedData[mip];
|
||||
if(data.size() == dataSize * arraysize)
|
||||
memcpy(m_GetTexturePrevData[mip], data.data(), data.size());
|
||||
else
|
||||
RDCERR("Different expected and stored compressed texture sizes for array texture!");
|
||||
}
|
||||
texDetails.GetCompressedImageDataGLES(mip, target, dataSize * arraysize,
|
||||
m_GetTexturePrevData[mip]);
|
||||
else
|
||||
{
|
||||
gl.glGetCompressedTexImage(target, mip, m_GetTexturePrevData[mip]);
|
||||
}
|
||||
}
|
||||
|
||||
// now copy the slice from the cache into ret
|
||||
@@ -2603,17 +2596,9 @@ byte *GLReplay::GetTextureData(ResourceId tex, uint32_t arrayIdx, uint32_t mip,
|
||||
{
|
||||
// for non-arrays we can just readback without caching
|
||||
if(IsGLES)
|
||||
{
|
||||
const vector<byte> &data = texDetails.compressedData[mip];
|
||||
if(data.size() == dataSize)
|
||||
memcpy(ret, data.data(), data.size());
|
||||
else
|
||||
RDCERR("Different expected and stored compressed texture sizes!");
|
||||
}
|
||||
texDetails.GetCompressedImageDataGLES(mip, target, dataSize, ret);
|
||||
else
|
||||
{
|
||||
gl.glGetCompressedTexImage(target, mip, ret);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
Reference in new issue
Block a user