upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
authorJan Trencansky <jan.trencansky@protonmail.com>2026-11-24 19:02:22 -0500
committerJan Trencansky <jan.trencansky@protonmail.com>2026-11-24 19:54:46 -0500
commitea43b63b7a3ec5e89100b7bc15a8fbd06a435fdd (patch)
tree5f0a973c6e1f8479f7cb165ee46690e5ccbc71dc /runtime
parent869c88979621cacac26542a0b35b4448fde4f994 (diff)
A8 render targets: guard test for device extensions, and the fallback case
From rung-428-on-main (554f0e4ec). The bug that commit fixed, VK_KHR_maintenance5 enabled inside maintenance8's #ifdef, is not in #984's copy of the A8 support: the enable already sits under its own guard here, so only the comment on it comes over. What the commit adds besides still applies: tests/test_vulkan_extension_guards.py reads the runtime sources and fails on any device extension enabled inside another extension's #ifdef. d3d12_a8_copy_test also forces the fallback (a8_render_target false) on any device: A8_UNORM render targets are refused at creation, in GetResourceAllocationInfo and in the format support, no A8 image is created, and plain A8_UNORM textures still copy. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Diffstat (limited to 'runtime')
-rw-r--r--runtime/shims/d3d12_vulkan_device.cpp2
-rw-r--r--runtime/test/d3d12_a8_copy_test.cpp47
2 files changed, 47 insertions, 2 deletions
diff --git a/runtime/shims/d3d12_vulkan_device.cpp b/runtime/shims/d3d12_vulkan_device.cpp
index 308b7dd78..b4a7a9587 100644
--- a/runtime/shims/d3d12_vulkan_device.cpp
+++ b/runtime/shims/d3d12_vulkan_device.cpp
@@ -15080,6 +15080,8 @@ HRESULT create_vulkan_device_standalone(REFIID riid, void** out, QueueTestSettin
15080#ifdef VK_KHR_MAINTENANCE_8_EXTENSION_NAME 15080#ifdef VK_KHR_MAINTENANCE_8_EXTENSION_NAME
15081 if (info.maintenance8) device_extensions.push_back(VK_KHR_MAINTENANCE_8_EXTENSION_NAME); 15081 if (info.maintenance8) device_extensions.push_back(VK_KHR_MAINTENANCE_8_EXTENSION_NAME);
15082#endif 15082#endif
15083 // Under its own guard only: headers or a driver without VK_KHR_maintenance8 still have the A8 path, and
15084 // a8_render_target is never set without this extension being enabled.
15083#ifdef VK_KHR_MAINTENANCE_5_EXTENSION_NAME 15085#ifdef VK_KHR_MAINTENANCE_5_EXTENSION_NAME
15084 if (info.a8_render_target) device_extensions.push_back(VK_KHR_MAINTENANCE_5_EXTENSION_NAME); 15086 if (info.a8_render_target) device_extensions.push_back(VK_KHR_MAINTENANCE_5_EXTENSION_NAME);
15085#endif 15087#endif
diff --git a/runtime/test/d3d12_a8_copy_test.cpp b/runtime/test/d3d12_a8_copy_test.cpp
index a83a41810..ff77688f0 100644
--- a/runtime/test/d3d12_a8_copy_test.cpp
+++ b/runtime/test/d3d12_a8_copy_test.cpp
@@ -10,7 +10,11 @@
10// wraps vkCreateImage and vkCmdCopyImage behind the instance-proc pointer it hands the layer, so it sees this 10// wraps vkCreateImage and vkCmdCopyImage behind the instance-proc pointer it hands the layer, so it sees this
11// without the validation layer; with LEONIDA_VK_VALIDATION=1 and the layer installed, the layer's errors also 11// without the validation layer; with LEONIDA_VK_VALIDATION=1 and the layer installed, the layer's errors also
12// fail it; 12// fail it;
13// - the same-backing copies (A8 -> A8, R8 -> R8) are the controls and still copy image to image. 13// - the same-backing copies (A8 -> A8, R8 -> R8) are the controls and still copy image to image;
14// - a device without the A8 path (a8_render_target false, which VK_KHR_maintenance5 not being enabled means)
15// takes the documented fallback: A8_UNORM render targets refused, other A8_UNORM textures R8_UNORM images that
16// copy as before. tests/test_vulkan_extension_guards.py checks that the extension is enabled wherever the path
17// is taken.
14// Synthetic data only. 18// Synthetic data only.
15#include "vk_test_device.h" 19#include "vk_test_device.h"
16#include "../shims/d3d12_com.h" 20#include "../shims/d3d12_com.h"
@@ -290,7 +294,46 @@ int main() {
290 ++failures; 294 ++failures;
291 } 295 }
292 } else { 296 } else {
293 std::printf("A8 render targets: not on this device, only the R8-backed copies below run\n"); 297 std::printf("A8 render targets: not on this device, only the fallback below runs\n");
298 }
299
300 // The documented fallback of a device without VK_FORMAT_A8_UNORM_KHR (or without VK_KHR_maintenance5 enabled,
301 // a8_render_target false; forced here on any device): A8_UNORM render targets are refused at creation and in
302 // the format support, and every other A8_UNORM texture is an R8_UNORM image that copies as before.
303 {
304 Ref<ID3D12Device> device;
305 if (!make_device(vk, false, device)) return 1;
306 const unsigned a8_before = a8_images;
307 D3D12_FEATURE_DATA_FORMAT_SUPPORT support{DXGI_FORMAT_A8_UNORM};
308 if (FAILED(device->CheckFeatureSupport(D3D12_FEATURE_FORMAT_SUPPORT, &support, sizeof(support))) ||
309 !(support.Support1 & D3D12_FORMAT_SUPPORT1_TEXTURE2D) ||
310 (support.Support1 & (D3D12_FORMAT_SUPPORT1_RENDER_TARGET | D3D12_FORMAT_SUPPORT1_BLENDABLE))) {
311 std::fprintf(stderr, "fallback: A8_UNORM format support 0x%08x (want TEXTURE2D, no RENDER_TARGET or "
312 "BLENDABLE)\n", unsigned(support.Support1));
313 ++failures;
314 }
315 const D3D12_RESOURCE_ALLOCATION_INFO size = device->GetResourceAllocationInfo(0, 1, &target);
316 const D3D12_HEAP_PROPERTIES default_heap{D3D12_HEAP_TYPE_DEFAULT};
317 Ref<ID3D12Resource> refused;
318 const HRESULT hr = device->CreateCommittedResource(&default_heap, D3D12_HEAP_FLAG_NONE, &target,
319 D3D12_RESOURCE_STATE_COMMON, nullptr,
320 IID_PPV_ARGS(&refused.p));
321 if (SUCCEEDED(hr) || refused.p || size.SizeInBytes != UINT64_MAX) {
322 std::fprintf(stderr, "fallback: an A8_UNORM render target was not refused (hr 0x%08lx, size %llu)\n",
323 static_cast<unsigned long>(hr), static_cast<unsigned long long>(size.SizeInBytes));
324 ++failures;
325 } else {
326 std::printf("fallback: A8_UNORM render target refused (hr 0x%08lx), format support 0x%08x\n",
327 static_cast<unsigned long>(hr), unsigned(support.Support1));
328 }
329 if (!copy_case(device.p, "fallback: CopyResource A8 texture -> A8 texture", plain, plain, true) ||
330 !copy_case(device.p, "fallback: CopyTextureRegion A8 texture -> A8 texture (3x3 box)", plain, plain,
331 false))
332 ++failures;
333 if (a8_images != a8_before) {
334 std::fprintf(stderr, "fallback: %u VK_FORMAT_A8_UNORM_KHR images created\n", a8_images - a8_before);
335 ++failures;
336 }
294 } 337 }
295 338
296 if (unknown_copies) { 339 if (unknown_copies) {