diff options
| author | ItsNotRexed <300290919+ItsNotRexed@users.noreply.github.com> | 2026-11-22 23:11:17 -0500 |
|---|---|---|
| committer | ItsNotRexed <300290919+ItsNotRexed@users.noreply.github.com> | 2026-11-22 23:11:17 -0500 |
| commit | 43f41a1d8d37b5e73d7d08d1925c2dc4bf547b90 (patch) | |
| tree | 60f8ffbc11b83f0c6368f24c18f22f29f2f6d220 /runtime | |
| parent | c42b2cbd05d9032d5de967c5f41eb50df7be27f8 (diff) | |
| parent | 099bcf8f3d54a527624fae0ed08ced0d53993562 (diff) | |
Merge pull request #4101 from Exopus
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'runtime')
| -rw-r--r-- | runtime/shims/d3d12_vulkan_device.cpp | 10 | ||||
| -rw-r--r-- | runtime/test/d3d12_vulkan_device_test.cpp | 4 |
2 files changed, 11 insertions, 3 deletions
diff --git a/runtime/shims/d3d12_vulkan_device.cpp b/runtime/shims/d3d12_vulkan_device.cpp index 91c7c8afe..8b410aadd 100644 --- a/runtime/shims/d3d12_vulkan_device.cpp +++ b/runtime/shims/d3d12_vulkan_device.cpp | |||
| @@ -6555,8 +6555,12 @@ public: | |||
| 6555 | planes == 2 ? (plane ? VK_IMAGE_ASPECT_STENCIL_BIT : VK_IMAGE_ASPECT_DEPTH_BIT) : format.aspects; | 6555 | planes == 2 ? (plane ? VK_IMAGE_ASPECT_STENCIL_BIT : VK_IMAGE_ASPECT_DEPTH_BIT) : format.aspects; |
| 6556 | const leonida::BlockFormat block = footprint_block(format, aspect); | 6556 | const leonida::BlockFormat block = footprint_block(format, aspect); |
| 6557 | if (!block.bytes) return fail(); | 6557 | if (!block.bytes) return fail(); |
| 6558 | const UINT width = std::max<UINT>(1, UINT(desc->Width >> mip)); | 6558 | // D3D12 takes any MipLevels, and the PC runtime's own shifts wrap past the type's width: a 16x16 texture |
| 6559 | const UINT height = one_d ? 1 : std::max<UINT>(1, desc->Height >> mip); | 6559 | // with 40 mips reports subresource 32 as 1x16 and 33 as 1x8, a volume's depth likewise (measured on an |
| 6560 | // RTX 5060 Ti, compare_footprints). The masks give the same answers without shifting a 32-bit (or the | ||
| 6561 | // 64-bit Width) value by its width or more, which C++ leaves undefined. | ||
| 6562 | const UINT width = std::max<UINT>(1, UINT(desc->Width >> (mip & 63))); | ||
| 6563 | const UINT height = one_d ? 1 : std::max<UINT>(1, desc->Height >> (mip & 31)); | ||
| 6560 | const UINT blocks_wide = (width + block.block - 1) / block.block; | 6564 | const UINT blocks_wide = (width + block.block - 1) / block.block; |
| 6561 | const UINT blocks_high = (height + block.block - 1) / block.block; | 6565 | const UINT blocks_high = (height + block.block - 1) / block.block; |
| 6562 | const UINT64 row_size = UINT64(blocks_wide) * block.bytes; | 6566 | const UINT64 row_size = UINT64(blocks_wide) * block.bytes; |
| @@ -6567,7 +6571,7 @@ public: | |||
| 6567 | offset = align(offset, D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT); | 6571 | offset = align(offset, D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT); |
| 6568 | DXGI_FORMAT footprint_format = desc->Format; | 6572 | DXGI_FORMAT footprint_format = desc->Format; |
| 6569 | if (planes == 2) footprint_format = plane ? DXGI_FORMAT_R8_TYPELESS : DXGI_FORMAT_R32_TYPELESS; | 6573 | if (planes == 2) footprint_format = plane ? DXGI_FORMAT_R8_TYPELESS : DXGI_FORMAT_R32_TYPELESS; |
| 6570 | const UINT slices = std::max(1u, depth >> mip); | 6574 | const UINT slices = std::max(1u, depth >> (mip & 31)); |
| 6571 | if (layouts) | 6575 | if (layouts) |
| 6572 | layouts[i] = {offset, {footprint_format, blocks_wide * block.block, blocks_high * block.block, slices, pitch}}; | 6576 | layouts[i] = {offset, {footprint_format, blocks_wide * block.block, blocks_high * block.block, slices, pitch}}; |
| 6573 | if (rows) rows[i] = blocks_high; | 6577 | if (rows) rows[i] = blocks_high; |
diff --git a/runtime/test/d3d12_vulkan_device_test.cpp b/runtime/test/d3d12_vulkan_device_test.cpp index c6622e8d1..6ce6d70cb 100644 --- a/runtime/test/d3d12_vulkan_device_test.cpp +++ b/runtime/test/d3d12_vulkan_device_test.cpp | |||
| @@ -533,6 +533,10 @@ int compare_footprints(ID3D12Device* ours) { | |||
| 533 | {texture_desc(16, 16, DXGI_FORMAT_R8G8_TYPELESS, D3D12_RESOURCE_FLAG_NONE, 3), 3}, | 533 | {texture_desc(16, 16, DXGI_FORMAT_R8G8_TYPELESS, D3D12_RESOURCE_FLAG_NONE, 3), 3}, |
| 534 | {texture_desc(16, 16, DXGI_FORMAT_R8G8_UINT, D3D12_RESOURCE_FLAG_NONE, 3), 3}, | 534 | {texture_desc(16, 16, DXGI_FORMAT_R8G8_UINT, D3D12_RESOURCE_FLAG_NONE, 3), 3}, |
| 535 | {texture_desc(16, 16, DXGI_FORMAT_R8G8_SINT, D3D12_RESOURCE_FLAG_NONE, 3), 3}, | 535 | {texture_desc(16, 16, DXGI_FORMAT_R8G8_SINT, D3D12_RESOURCE_FLAG_NONE, 3), 3}, |
| 536 | // Mip counts past 32 (and past 64 for the width): D3D12 accepts any count, every mip past the chain is 1x1. | ||
| 537 | {texture_desc(16, 16, DXGI_FORMAT_R8G8B8A8_UNORM, D3D12_RESOURCE_FLAG_NONE, 40), 40}, | ||
| 538 | {line_desc(16, 70, 1, DXGI_FORMAT_R8G8B8A8_UNORM), 70}, | ||
| 539 | {volume_desc(40), 40}, | ||
| 536 | }; | 540 | }; |
| 537 | for (const auto& c : footprint_validity_cases()) cases.push_back({c.first, 1}); | 541 | for (const auto& c : footprint_validity_cases()) cases.push_back({c.first, 1}); |
| 538 | int mismatches = 0; | 542 | int mismatches = 0; |