From 5c5ab3def3f2ad392d2cd4a76e4cc2cc66da09d7 Mon Sep 17 00:00:00 2001 From: akharlamov Date: Mon, 12 Nov 2018 14:26:43 -0800 Subject: [PATCH] Apply thumbnail resampling fix to dx12. See CL fb4ec5c7e32905b4bc1c7a66a1074e1e8f8e59c8 for full description. --- renderdoc/driver/d3d12/d3d12_device.cpp | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/renderdoc/driver/d3d12/d3d12_device.cpp b/renderdoc/driver/d3d12/d3d12_device.cpp index 6d67f66c3..a2034ddb5 100644 --- a/renderdoc/driver/d3d12/d3d12_device.cpp +++ b/renderdoc/driver/d3d12/d3d12_device.cpp @@ -1521,17 +1521,12 @@ bool WrappedID3D12Device::EndFrameCapture(void *dev, void *wnd) { ResourceFormat fmt = MakeResourceFormat(desc.Format); - float aspect = float(desc.Width) / float(desc.Height); - thwidth = (uint16_t)RDCMIN(maxSize, (uint32_t)desc.Width); thwidth &= ~0x7; // align down to multiple of 8 - thheight = uint16_t(float(thwidth) / aspect); + thheight = uint16_t(thwidth * desc.Height / desc.Width); thpixels = new byte[3U * thwidth * thheight]; - float widthf = float(desc.Width); - float heightf = float(desc.Height); - uint32_t stride = fmt.compByteWidth * fmt.compCount; bool buf1010102 = false; @@ -1549,11 +1544,10 @@ bool WrappedID3D12Device::EndFrameCapture(void *dev, void *wnd) { for(uint32_t x = 0; x < thwidth; x++) { - float xf = float(x) / float(thwidth); - float yf = float(y) / float(thheight); + uint32_t xSource = uint32_t(x * desc.Width / thwidth); + uint32_t ySource = uint32_t(y * desc.Height / thheight); - byte *srcPixels = &data[stride * uint32_t(xf * widthf) + - layout.Footprint.RowPitch * uint32_t(yf * heightf)]; + byte *srcPixels = &data[stride * xSource + layout.Footprint.RowPitch * ySource]; if(buf1010102) {