upleb.uk

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

summaryrefslogtreecommitdiff
path: root/runtime/test/d3d12_compute_test.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/test/d3d12_compute_test.cpp')
-rw-r--r--runtime/test/d3d12_compute_test.cpp24
1 files changed, 11 insertions, 13 deletions
diff --git a/runtime/test/d3d12_compute_test.cpp b/runtime/test/d3d12_compute_test.cpp
index e1dcef0fd..05591a780 100644
--- a/runtime/test/d3d12_compute_test.cpp
+++ b/runtime/test/d3d12_compute_test.cpp
@@ -10,6 +10,7 @@
10// No game data. Set LEONIDA_VK_VALIDATION=1 to run under VK_LAYER_KHRONOS_validation. 10// No game data. Set LEONIDA_VK_VALIDATION=1 to run under VK_LAYER_KHRONOS_validation.
11#include "shader_fixture_path.h" 11#include "shader_fixture_path.h"
12#include "test_temp_dir.h" 12#include "test_temp_dir.h"
13#include "d3d12_test_shaders.h"
13#include "vk_test_device.h" 14#include "vk_test_device.h"
14#include "host_wine.h" 15#include "host_wine.h"
15#include "../shims/d3d12_com.h" 16#include "../shims/d3d12_com.h"
@@ -42,7 +43,6 @@ using XboxComputePipelineFn = HRESULT(WINAPI*)(void* device, const D3D12_COMPUTE
42 std::uint64_t, const IID*, void**); 43 std::uint64_t, const IID*, void**);
43// Device slot 67 as amd_fidelityfx_upscaler_xbox.dll calls it: (desc, riid, out). 44// Device slot 67 as amd_fidelityfx_upscaler_xbox.dll calls it: (desc, riid, out).
44using XboxNativeComputePipelineFn = HRESULT(WINAPI*)(void* device, const void*, const IID*, void**); 45using XboxNativeComputePipelineFn = HRESULT(WINAPI*)(void* device, const void*, const IID*, void**);
45using SerializeFn = HRESULT(WINAPI*)(const D3D12_VERSIONED_ROOT_SIGNATURE_DESC*, ID3DBlob**, ID3DBlob**);
46 46
47template<class T> 47template<class T>
48struct Ref { 48struct Ref {
@@ -103,19 +103,9 @@ std::vector<std::uint8_t> shader_container(const std::vector<std::uint8_t>& fssm
103 return out; 103 return out;
104} 104}
105 105
106// The shared helper: Windows 10's in-box d3d12.dll refuses the heap-directly-indexed flags at every version.
106std::vector<std::uint8_t> serialize(const D3D12_VERSIONED_ROOT_SIGNATURE_DESC& desc) { 107std::vector<std::uint8_t> serialize(const D3D12_VERSIONED_ROOT_SIGNATURE_DESC& desc) {
107 const HMODULE d3d12 = LoadLibraryExA("d3d12.dll", nullptr, LOAD_LIBRARY_SEARCH_SYSTEM32); 108 return d3d12test::serialize_root_signature(desc);
108 const auto fn = d3d12 ? reinterpret_cast<SerializeFn>(
109 reinterpret_cast<void*>(GetProcAddress(d3d12, "D3D12SerializeVersionedRootSignature")))
110 : nullptr;
111 std::vector<std::uint8_t> out;
112 ID3DBlob* blob = nullptr;
113 if (fn && SUCCEEDED(fn(&desc, &blob, nullptr)) && blob) {
114 const auto* p = static_cast<const std::uint8_t*>(blob->GetBufferPointer());
115 out.assign(p, p + blob->GetBufferSize());
116 blob->Release();
117 }
118 return out;
119} 109}
120 110
121D3D12_RESOURCE_DESC buffer_desc(UINT64 bytes, D3D12_RESOURCE_FLAGS flags) { 111D3D12_RESOURCE_DESC buffer_desc(UINT64 bytes, D3D12_RESOURCE_FLAGS flags) {
@@ -495,6 +485,14 @@ int main() {
495 D3D12_RESOURCE_STATE_COMMON, nullptr, 485 D3D12_RESOURCE_STATE_COMMON, nullptr,
496 IID_PPV_ARGS(&inside.p)))); 486 IID_PPV_ARGS(&inside.p))));
497 EXPECT(inside->GetGPUVirtualAddress() + (1u << 20) <= capped_arena); 487 EXPECT(inside->GetGPUVirtualAddress() + (1u << 20) <= capped_arena);
488 // The existing buffer and the reserved range prevent a contiguous arena-sized allocation.
489 // A valid default buffer can still use a dedicated allocation and report a usable relative VA.
490 const auto no_slice = buffer_desc(capped_arena, D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS);
491 Ref<ID3D12Resource> dedicated;
492 EXPECT(SUCCEEDED(capped->CreateCommittedResource(&heap, D3D12_HEAP_FLAG_NONE, &no_slice,
493 D3D12_RESOURCE_STATE_COMMON, nullptr,
494 IID_PPV_ARGS(&dedicated.p))));
495 EXPECT(dedicated->GetGPUVirtualAddress() >= capped_arena);
498 EXPECT(capped->CreateCommittedResource(&heap, D3D12_HEAP_FLAG_NONE, &too_large, D3D12_RESOURCE_STATE_COMMON, 496 EXPECT(capped->CreateCommittedResource(&heap, D3D12_HEAP_FLAG_NONE, &too_large, D3D12_RESOURCE_STATE_COMMON,
499 nullptr, IID_PPV_ARGS(&past.p)) == E_OUTOFMEMORY && !past.p); 497 nullptr, IID_PPV_ARGS(&past.p)) == E_OUTOFMEMORY && !past.p);
500 std::printf("arena: %llu MiB (device limits: maxBufferSize %llu MiB, maxMemoryAllocationSize %llu MiB); " 498 std::printf("arena: %llu MiB (device limits: maxBufferSize %llu MiB, maxMemoryAllocationSize %llu MiB); "