mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-09-25 07:05:48 +00:00
Add bullet-proofing to GetTextureData/GetBufferData
* So that it won't crash on invalid input but will just return empty data.
This commit is contained in:
@@ -2819,6 +2819,12 @@ byte *D3D11DebugManager::GetTextureData(ResourceId id, uint32_t arrayIdx, uint32
|
||||
m_pImmediateContext->CopyResource(UNWRAP(WrappedID3D11Texture3D, d), wrapTex->GetReal());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
RDCERR("Trying to get texture data for unknown ID %llu!", id);
|
||||
dataSize = 0;
|
||||
return new byte[0];
|
||||
}
|
||||
|
||||
MapIntercept intercept;
|
||||
|
||||
|
||||
@@ -2078,7 +2078,10 @@ void D3D11DebugManager::GetBufferData(ResourceId buff, uint64_t offset, uint64_t
|
||||
auto it = WrappedID3D11Buffer::m_BufferList.find(buff);
|
||||
|
||||
if(it == WrappedID3D11Buffer::m_BufferList.end())
|
||||
{
|
||||
RDCERR("Getting buffer data for unknown buffer %llu!", buff);
|
||||
return;
|
||||
}
|
||||
|
||||
ID3D11Buffer *buffer = it->second.m_Buffer;
|
||||
|
||||
|
||||
@@ -2211,6 +2211,13 @@ byte *GLReplay::GetTextureData(ResourceId tex, uint32_t arrayIdx, uint32_t mip,
|
||||
GLsizei arraysize = 1;
|
||||
GLint samples = texDetails.samples;
|
||||
|
||||
if(texType == eGL_NONE)
|
||||
{
|
||||
RDCERR("Trying to get texture data for unknown ID %llu!", tex);
|
||||
dataSize = 0;
|
||||
return new byte[0];
|
||||
}
|
||||
|
||||
if(texType == eGL_TEXTURE_BUFFER)
|
||||
{
|
||||
GLuint bufName = 0;
|
||||
|
||||
@@ -2170,6 +2170,12 @@ void VulkanDebugManager::GetBufferData(ResourceId buff, uint64_t offset, uint64_
|
||||
|
||||
VkBuffer srcBuf = m_pDriver->GetResourceManager()->GetCurrentHandle<VkBuffer>(buff);
|
||||
|
||||
if(srcBuf == VK_NULL_HANDLE)
|
||||
{
|
||||
RDCERR("Getting buffer data for unknown buffer %llu!", buff);
|
||||
return;
|
||||
}
|
||||
|
||||
if(len == 0)
|
||||
{
|
||||
len = m_pDriver->m_CreationInfo.m_Buffer[buff].size - offset;
|
||||
|
||||
@@ -4346,6 +4346,13 @@ byte *VulkanReplay::GetTextureData(ResourceId tex, uint32_t arrayIdx, uint32_t m
|
||||
{
|
||||
bool wasms = false;
|
||||
|
||||
if(m_pDriver->m_CreationInfo.m_Image.find(tex) == m_pDriver->m_CreationInfo.m_Image.end())
|
||||
{
|
||||
RDCERR("Trying to get texture data for unknown ID %llu!", tex);
|
||||
dataSize = 0;
|
||||
return new byte[0];
|
||||
}
|
||||
|
||||
VulkanCreationInfo::Image &imInfo = m_pDriver->m_CreationInfo.m_Image[tex];
|
||||
|
||||
ImageLayouts &layouts = m_pDriver->m_ImageLayouts[tex];
|
||||
|
||||
@@ -453,8 +453,16 @@ bool ReplayRenderer::GetBufferData(ResourceId buff, uint64_t offset, uint64_t le
|
||||
if(data == NULL)
|
||||
return false;
|
||||
|
||||
ResourceId liveId = m_pDevice->GetLiveID(buff);
|
||||
|
||||
if(liveId == ResourceId())
|
||||
{
|
||||
RDCERR("Couldn't get Live ID for %llu getting buffer data", buff);
|
||||
return false;
|
||||
}
|
||||
|
||||
vector<byte> retData;
|
||||
m_pDevice->GetBufferData(m_pDevice->GetLiveID(buff), offset, len, retData);
|
||||
m_pDevice->GetBufferData(liveId, offset, len, retData);
|
||||
|
||||
create_array_init(*data, retData.size(), !retData.empty() ? &retData[0] : NULL);
|
||||
|
||||
@@ -467,9 +475,16 @@ bool ReplayRenderer::GetTextureData(ResourceId tex, uint32_t arrayIdx, uint32_t
|
||||
if(data == NULL)
|
||||
return false;
|
||||
|
||||
ResourceId liveId = m_pDevice->GetLiveID(tex);
|
||||
|
||||
if(liveId == ResourceId())
|
||||
{
|
||||
RDCERR("Couldn't get Live ID for %llu getting texture data", tex);
|
||||
return false;
|
||||
}
|
||||
|
||||
size_t sz;
|
||||
byte *bytes = m_pDevice->GetTextureData(m_pDevice->GetLiveID(tex), arrayIdx, mip, false, false,
|
||||
0.0f, 0.0f, sz);
|
||||
byte *bytes = m_pDevice->GetTextureData(liveId, arrayIdx, mip, false, false, 0.0f, 0.0f, sz);
|
||||
|
||||
create_array_init(*data, sz, bytes);
|
||||
|
||||
|
||||
@@ -811,7 +811,7 @@ namespace renderdoc
|
||||
|
||||
bool success = ReplayRenderer_GetBufferData(m_Real, buff, offset, len, mem);
|
||||
|
||||
byte[] ret = null;
|
||||
byte[] ret = new byte[] { };
|
||||
|
||||
if (success)
|
||||
ret = (byte[])CustomMarshal.GetTemplatedArray(mem, typeof(byte), true);
|
||||
@@ -827,7 +827,7 @@ namespace renderdoc
|
||||
|
||||
bool success = ReplayRenderer_GetTextureData(m_Real, tex, arrayIdx, mip, mem);
|
||||
|
||||
byte[] ret = null;
|
||||
byte[] ret = new byte[] { };
|
||||
|
||||
if (success)
|
||||
ret = (byte[])CustomMarshal.GetTemplatedArray(mem, typeof(byte), true);
|
||||
|
||||
Reference in New Issue
Block a user