|
@@ -1656,31 +1656,32 @@ namespace bgfx { namespace d3d12
|
|
|
|
|
|
|
|
ID3D12Resource* readback = createCommittedResource(m_device, HeapProperty::ReadBack, total);
|
|
ID3D12Resource* readback = createCommittedResource(m_device, HeapProperty::ReadBack, total);
|
|
|
|
|
|
|
|
|
|
+ uint32_t srcWidth = bx::uint32_max(1, texture.m_width >>_mip);
|
|
|
|
|
+ uint32_t srcHeight = bx::uint32_max(1, texture.m_height>>_mip);
|
|
|
|
|
+
|
|
|
D3D12_BOX box;
|
|
D3D12_BOX box;
|
|
|
box.left = 0;
|
|
box.left = 0;
|
|
|
box.top = 0;
|
|
box.top = 0;
|
|
|
- box.right = texture.m_width;
|
|
|
|
|
- box.bottom = texture.m_height;
|
|
|
|
|
|
|
+ box.right = srcWidth;
|
|
|
|
|
+ box.bottom = srcHeight;
|
|
|
box.front = 0;
|
|
box.front = 0;
|
|
|
box.back = 1;
|
|
box.back = 1;
|
|
|
|
|
|
|
|
D3D12_TEXTURE_COPY_LOCATION dstLocation = { readback, D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT, { layout } };
|
|
D3D12_TEXTURE_COPY_LOCATION dstLocation = { readback, D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT, { layout } };
|
|
|
- D3D12_TEXTURE_COPY_LOCATION srcLocation = { texture.m_ptr, D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX, {} };
|
|
|
|
|
|
|
+ D3D12_TEXTURE_COPY_LOCATION srcLocation = { texture.m_ptr, D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX, { } };
|
|
|
|
|
+ srcLocation.SubresourceIndex = _mip;
|
|
|
m_commandList->CopyTextureRegion(&dstLocation, 0, 0, 0, &srcLocation, &box);
|
|
m_commandList->CopyTextureRegion(&dstLocation, 0, 0, 0, &srcLocation, &box);
|
|
|
|
|
|
|
|
finish();
|
|
finish();
|
|
|
m_commandList = m_cmd.alloc();
|
|
m_commandList = m_cmd.alloc();
|
|
|
|
|
|
|
|
- uint32_t srcWidth = bx::uint32_max(1, texture.m_width >>_mip);
|
|
|
|
|
- uint32_t srcHeight = bx::uint32_max(1, texture.m_height>>_mip);
|
|
|
|
|
- uint8_t* src;
|
|
|
|
|
-
|
|
|
|
|
const uint8_t bpp = bimg::getBitsPerPixel(bimg::TextureFormat::Enum(texture.m_textureFormat) );
|
|
const uint8_t bpp = bimg::getBitsPerPixel(bimg::TextureFormat::Enum(texture.m_textureFormat) );
|
|
|
uint8_t* dst = (uint8_t*)_data;
|
|
uint8_t* dst = (uint8_t*)_data;
|
|
|
uint32_t dstPitch = srcWidth*bpp/8;
|
|
uint32_t dstPitch = srcWidth*bpp/8;
|
|
|
|
|
|
|
|
uint32_t pitch = bx::uint32_min(srcPitch, dstPitch);
|
|
uint32_t pitch = bx::uint32_min(srcPitch, dstPitch);
|
|
|
|
|
|
|
|
|
|
+ uint8_t* src;
|
|
|
readback->Map(0, NULL, (void**)&src);
|
|
readback->Map(0, NULL, (void**)&src);
|
|
|
|
|
|
|
|
for (uint32_t yy = 0, height = srcHeight; yy < height; ++yy)
|
|
for (uint32_t yy = 0, height = srcHeight; yy < height; ++yy)
|
|
@@ -5831,28 +5832,20 @@ namespace bgfx { namespace d3d12
|
|
|
state = src.setState(m_commandList, D3D12_RESOURCE_STATE_COPY_SOURCE);
|
|
state = src.setState(m_commandList, D3D12_RESOURCE_STATE_COPY_SOURCE);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- uint32_t srcWidth = bx::uint32_min(src.m_width, blit.m_srcX + blit.m_width) - blit.m_srcX;
|
|
|
|
|
- uint32_t srcHeight = bx::uint32_min(src.m_height, blit.m_srcY + blit.m_height) - blit.m_srcY;
|
|
|
|
|
- uint32_t srcDepth = bx::uint32_min(src.m_depth, blit.m_srcZ + blit.m_depth) - blit.m_srcZ;
|
|
|
|
|
- uint32_t dstWidth = bx::uint32_min(dst.m_width, blit.m_dstX + blit.m_width) - blit.m_dstX;
|
|
|
|
|
- uint32_t dstHeight = bx::uint32_min(dst.m_height, blit.m_dstY + blit.m_height) - blit.m_dstY;
|
|
|
|
|
- uint32_t dstDepth = bx::uint32_min(dst.m_depth, blit.m_dstZ + blit.m_depth) - blit.m_dstZ;
|
|
|
|
|
- uint32_t width = bx::uint32_min(srcWidth, dstWidth);
|
|
|
|
|
- uint32_t height = bx::uint32_min(srcHeight, dstHeight);
|
|
|
|
|
- uint32_t depth = bx::uint32_min(srcDepth, dstDepth);
|
|
|
|
|
-
|
|
|
|
|
if (TextureD3D12::Texture3D == src.m_type)
|
|
if (TextureD3D12::Texture3D == src.m_type)
|
|
|
{
|
|
{
|
|
|
D3D12_BOX box;
|
|
D3D12_BOX box;
|
|
|
box.left = blit.m_srcX;
|
|
box.left = blit.m_srcX;
|
|
|
box.top = blit.m_srcY;
|
|
box.top = blit.m_srcY;
|
|
|
box.front = blit.m_srcZ;
|
|
box.front = blit.m_srcZ;
|
|
|
- box.right = blit.m_srcX + width;
|
|
|
|
|
- box.bottom = blit.m_srcY + height;;
|
|
|
|
|
- box.back = blit.m_srcZ + bx::uint32_imax(1, depth);
|
|
|
|
|
-
|
|
|
|
|
- D3D12_TEXTURE_COPY_LOCATION dstLocation = { dst.m_ptr, D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX, { { 0, { DXGI_FORMAT_UNKNOWN, 0, 0, 0, 0 } } } };
|
|
|
|
|
- D3D12_TEXTURE_COPY_LOCATION srcLocation = { src.m_ptr, D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX, { { 0, { DXGI_FORMAT_UNKNOWN, 0, 0, 0, 0 } } } };
|
|
|
|
|
|
|
+ box.right = blit.m_srcX + blit.m_width;
|
|
|
|
|
+ box.bottom = blit.m_srcY + blit.m_height;
|
|
|
|
|
+ box.back = blit.m_srcZ + bx::uint32_imax(1, blit.m_depth);
|
|
|
|
|
+
|
|
|
|
|
+ D3D12_TEXTURE_COPY_LOCATION dstLocation = { dst.m_ptr, D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX, { } };
|
|
|
|
|
+ dstLocation.SubresourceIndex = blit.m_dstMip;
|
|
|
|
|
+ D3D12_TEXTURE_COPY_LOCATION srcLocation = { src.m_ptr, D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX, { } };
|
|
|
|
|
+ srcLocation.SubresourceIndex = blit.m_srcMip;
|
|
|
m_commandList->CopyTextureRegion(&dstLocation
|
|
m_commandList->CopyTextureRegion(&dstLocation
|
|
|
, blit.m_dstX
|
|
, blit.m_dstX
|
|
|
, blit.m_dstY
|
|
, blit.m_dstY
|
|
@@ -5867,8 +5860,8 @@ namespace bgfx { namespace d3d12
|
|
|
box.left = blit.m_srcX;
|
|
box.left = blit.m_srcX;
|
|
|
box.top = blit.m_srcY;
|
|
box.top = blit.m_srcY;
|
|
|
box.front = 0;
|
|
box.front = 0;
|
|
|
- box.right = blit.m_srcX + width;
|
|
|
|
|
- box.bottom = blit.m_srcY + height;;
|
|
|
|
|
|
|
+ box.right = blit.m_srcX + blit.m_width;
|
|
|
|
|
+ box.bottom = blit.m_srcY + blit.m_height;
|
|
|
box.back = 1;
|
|
box.back = 1;
|
|
|
|
|
|
|
|
const uint32_t srcZ = TextureD3D12::TextureCube == src.m_type
|
|
const uint32_t srcZ = TextureD3D12::TextureCube == src.m_type
|