Fix texture saving for 3D textures on mips above mip 0. Refs #359

This commit is contained in:
baldurk
2016-09-15 17:10:16 +02:00
parent 2a27c94b1a
commit c35b3509ed
2 changed files with 25 additions and 2 deletions
+18 -2
View File
@@ -2947,7 +2947,7 @@ byte *D3D11DebugManager::GetTextureData(ResourceId id, uint32_t arrayIdx, uint32
int oldW = GetWidth(), oldH = GetHeight();
for(UINT i = 0; i < desc.Depth; i++)
for(UINT i = 0; i < (desc.Depth >> mip); i++)
{
rtvDesc.Texture3D.FirstWSlice = i;
hr = m_WrappedDevice->CreateRenderTargetView(rtTex, &rtvDesc, &wrappedrtv);
@@ -2978,7 +2978,7 @@ byte *D3D11DebugManager::GetTextureData(ResourceId id, uint32_t arrayIdx, uint32
texDisplay.mip = mip;
texDisplay.sampleIdx = 0;
texDisplay.CustomShader = ResourceId();
texDisplay.sliceFace = i;
texDisplay.sliceFace = i << mip;
texDisplay.rangemin = blackPoint;
texDisplay.rangemax = whitePoint;
texDisplay.scale = 1.0f;
@@ -3026,6 +3026,22 @@ byte *D3D11DebugManager::GetTextureData(ResourceId id, uint32_t arrayIdx, uint32
intercept.InitWrappedResource(dummyTex, subresource, ret);
intercept.SetD3D(mapped);
intercept.CopyFromD3D();
// for 3D textures if we wanted a particular slice (arrayIdx > 0)
// copy it into the beginning.
if(intercept.numSlices > 1 && arrayIdx > 0 && (int)arrayIdx < intercept.numSlices)
{
byte *dst = ret;
byte *src = ret + intercept.app.DepthPitch * arrayIdx;
for(int row = 0; row < intercept.numRows; row++)
{
memcpy(dst, src, intercept.app.RowPitch);
src += intercept.app.RowPitch;
dst += intercept.app.RowPitch;
}
}
}
else
{
+7
View File
@@ -5114,6 +5114,13 @@ byte *VulkanReplay::GetTextureData(ResourceId tex, uint32_t arrayIdx, uint32_t m
},
};
for(int i = 0; i < 2; i++)
{
copyregion[i].imageExtent.width = RDCMAX(1U, copyregion[i].imageExtent.width >> mip);
copyregion[i].imageExtent.height = RDCMAX(1U, copyregion[i].imageExtent.height >> mip);
copyregion[i].imageExtent.depth = RDCMAX(1U, copyregion[i].imageExtent.depth >> mip);
}
// for most combined depth-stencil images this will be large enough for both to be copied
// separately, but for D24S8 we need to add extra space since they won't be copied packed
dataSize = GetByteSize(imInfo.extent.width, imInfo.extent.height, imInfo.extent.depth,