mirror of
https://github.com/ProjectLeonida/mandy.git
synced 2026-12-06 15:38:38 +00:00
Merges main at1154976d4into the integration branch at273b3bdf9(merge baseece4ba5b3). 42 files conflicted; this commit is the resolution only. Build and test repairs follow in their own commits. Rule of resolution: where both sides added different things, both stay; where both made the same change in two forms, main's reviewed form stays and whatever #984's form did in addition is carried into it; where the two changed the same code for different purposes, both purposes are kept. Xbox proxy code (runtime/shims/d3d12_xs_device.cpp, d3d12_xs_device.h, d3d12_xs.cpp, d3d12_xs_alloc_size.h, d3d12_xs_desc_clean.h, registry.cpp): - d3d12_xs_device.cpp is #984's file with main's differing pieces ported in: env_slot and the configurable device routes, XboxQueueSlotRoutes, PresentationHandler / set_presentation_handler, the console caller rule for device slots 61 and 74 (#383, #385), route_xbox_device_slot, slot 81 as GetFrameStatisticsX, create_host_device, the console-form rule for slots 25 and 56, the console list IID of #359, and the forms of queue slot 18 (#403) and list slot 139 (#396). - Kept from #984: the list proxy with handle translation, queue slots 16/17 as Signal/Wait, the fence's completed-value mirror, the shared FrameTokenSource, PresentX through queue_present_x when no handler is attached (slot 30, or 32 on a queue detected as the newer layout), slots 27/53/55/57/70/71/133, the wider pc_resource_desc, S_OK for queue slots past the PC table. - Dropped: #984's GetFrameEventsX and LEONIDA_XS_FRAME_EVENTS_SLOT, its second-word rule for slot 61, its undetected-layout rule for queue slot 18, its list IID mapping to GraphicsCommandList6; main's copy of the base list proxy, its null-view slot 70 and its refusing slot 133. Proxy tests (runtime/test/xs_proxy_mock_test.cpp, device_proxy_test.cpp, queue_proxy_test.cpp): - Checks of both sides, each run once; main's forms of the render-target size and layout checks with #984's extra cases added; main's --env-slots-74 and #984's --env-slots-70. - Adapted to the merged code: the queue tail answers S_OK, slot 73 answers an unknown IID with the list proxy, the queue slot 18 case installs a console caller. Dropped: #984's slot 81 GetFrameEventsX cases. D3D12/Vulkan layer (runtime/shims/d3d12_com.cpp, d3d12_vulkan_device.cpp, runtime/src/command_list.h, frame_pacer.h, shader_library.h, vulkan_backend.h, vulkan_replay.h, runtime/test/command_list_test.cpp, d3d12_close_parity_test.cpp, d3d12_execute_indirect_validation_test.cpp, replay_texture_barrier_test.cpp, vk_pipeline_check.cpp, vk_test_device.h): - Resource::create_texture: #984's title images (deferred placed, pending streamed, title pool) and main's ordinary textures (#1413 shared blocks, #1364 staging fallback) are exclusive branches chosen by the texture's origin, so both pools run on disjoint sets of textures. - frame_pacer.h is main's pacer (#402) with #984's FrameTokenSource as the token counter. - main's forms kept for ExecuteIndirect (#1066, #377), the barrier into LAYOUT_UNDEFINED (#1055), the B4G4R4A4 stand-in, per-face stencil masks, the unaligned tile staging (#528) and the device-lost flag (#980). - shader_library.h: main's block inflate; #984's `bulk` parameter now defaults to true so main's callers keep it. - Dropped: #984's B8G8R8A8 stand-in for B4G4R4A4 targets, its refusal of separate stencil masks, its zero-count refusal in ExecuteIndirect, its wider UNDEFINED -> UNDEFINED release and the test case for it. Other shims (runtime/shims/dstorage.cpp, file_system.cpp, gameinput.cpp, xgameruntime_offline.cpp, runtime/test/xgameruntime_offline_test.cpp, xmem_test.cpp): - ReadFile and DirectStorage reads: #984's pinned kernel_writes read, then main's touch_pages retry on ERROR_NOACCESS. main's rt::fs::read_file is folded into #984's read_file. - gameinput: main's strict LEONIDA_INPUT_SCRIPT parser with #984's rsup/rsdown entries. - Speech synthesis: main's one silent voice and handle checks; #984's accept-anything form dropped. Build, tools, docs (runtime/CMakeLists.txt, runtime/cmake/translator_deps.cmake, scripts/build_runtime.ps1, make_game.py, tools/rdna2spirv.py, shader_disasm.py, shader_ir.py, shader_library.py, runtime/test/shaders/cs_imgload_tfe.asm, cs_imgload_d16_tfe.asm, docs/README.md, boot.md, d3d12_vulkan.md, runtime/README.md): - Unions of the test, target and source lists; spirv_loop_guard.py added to translator_deps.cmake. - rdna2spirv.py: main's DPP compare rule (#957), SMEM vcc base (#647) and widen_wave64_masks (#1021); #984's restore_skipped_instructions and restore_dot4_inline_sel. #984's duplicate widen_wave64_valu_masks dropped. - shader_disasm.py and shader_ir.py: main's structure with #984's one-line-per-dword llvm-mc input and wave flags. - shader_library.py: main's structure with #984's --compute-hashes and per-state compute variants. One file that did not conflict is changed here: tools/rdna2_decode.py. Git kept both sides' decoders for a VOPC compare with a DPP operand, and #984's narrower one shadowed main's; it is main's file again. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
613 lines
37 KiB
C++
613 lines
37 KiB
C++
// What ID3D12GraphicsCommandList::Close returns after one recorded call, on the layer and on Windows' own D3D12 over
|
|
// WARP (no debug layer). Each case records its calls on a fresh allocator and direct list, then closes it; nothing is
|
|
// executed. The layer is held to WARP's verdict (Close succeeds or fails; the code is printed but not compared, since
|
|
// the layer answers every refused list with E_INVALIDARG where the PC runtime also uses E_FAIL).
|
|
//
|
|
// Where the two disagree today the case is marked as a known difference, and the test checks that the difference is
|
|
// still there: a change that makes such a case match fails here until its mark is removed, so the table stays an
|
|
// accurate list of the gap. Two kinds:
|
|
// layer_stricter WARP closes the list, the layer fails it. Since one failed list fails the whole
|
|
// ExecuteCommandLists, each of these drops a submission D3D12 would run.
|
|
// layer_looser WARP fails the list, the layer closes it.
|
|
// The `warp_ok` column is WARP's verdict as measured on Windows 11 26200 (d3d10warp.dll 10.0.26100.9818); it is
|
|
// the reference when no WARP device can be made (Wine, whose vkd3d answers differently, or a machine without WARP),
|
|
// and a live WARP answer that differs from it is printed. Calls that crash the PC runtime (ExecuteIndirect with a
|
|
// null command signature) are left out. No game data.
|
|
#include "vk_test_device.h"
|
|
#include "d3d12_test_shaders.h"
|
|
#include "host_wine.h"
|
|
#include "../shims/d3d12_com.h"
|
|
|
|
#include <dxgi1_4.h>
|
|
|
|
#include <cstdio>
|
|
#include <functional>
|
|
#include <limits>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#define CHECK(condition) do { \
|
|
if (!(condition)) { std::fprintf(stderr, "line %d: %s\n", __LINE__, #condition); return false; } \
|
|
} while (0)
|
|
|
|
#define REQUIRE(condition) do { \
|
|
if (!(condition)) { std::fprintf(stderr, "line %d: %s\n", __LINE__, #condition); return 1; } \
|
|
} while (0)
|
|
|
|
using namespace d3d12test;
|
|
|
|
namespace {
|
|
|
|
constexpr HRESULT not_run = HRESULT(0x7fff0000); // the case needs an interface the device does not give
|
|
|
|
struct Env {
|
|
ID3D12Device* device = nullptr;
|
|
Ref<ID3D12Resource> buffer, upload, readback, target, target2, depth, msaa, tex, mips;
|
|
Ref<ID3D12DescriptorHeap> rtv_heap, dsv_heap;
|
|
D3D12_CPU_DESCRIPTOR_HANDLE rtv{}, dsv{};
|
|
Ref<ID3D12QueryHeap> occlusion;
|
|
Ref<ID3D12CommandAllocator> closed_bundle_allocator;
|
|
Ref<ID3D12GraphicsCommandList> closed_bundle;
|
|
// The list being recorded, and the same list as ID3D12GraphicsCommandList2 and 7 (null when not given; list7
|
|
// also when the device has no enhanced barriers).
|
|
ID3D12GraphicsCommandList* list = nullptr;
|
|
ID3D12GraphicsCommandList2* list2 = nullptr;
|
|
ID3D12GraphicsCommandList7* list7 = nullptr;
|
|
|
|
bool init(ID3D12Device* d) {
|
|
device = d;
|
|
const D3D12_HEAP_PROPERTIES default_heap{D3D12_HEAP_TYPE_DEFAULT}, upload_heap{D3D12_HEAP_TYPE_UPLOAD},
|
|
readback_heap{D3D12_HEAP_TYPE_READBACK};
|
|
const auto create = [&](const D3D12_HEAP_PROPERTIES& heap, const D3D12_RESOURCE_DESC& desc,
|
|
D3D12_RESOURCE_STATES state, Ref<ID3D12Resource>& out) {
|
|
return SUCCEEDED(device->CreateCommittedResource(&heap, D3D12_HEAP_FLAG_NONE, &desc, state, nullptr,
|
|
IID_PPV_ARGS(&out.p)));
|
|
};
|
|
const auto texture = [](DXGI_FORMAT format, D3D12_RESOURCE_FLAGS flags, UINT samples = 1, UINT16 mip_levels = 1,
|
|
UINT16 layers = 1) {
|
|
D3D12_RESOURCE_DESC desc{};
|
|
desc.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D;
|
|
desc.Width = desc.Height = 64;
|
|
desc.DepthOrArraySize = layers;
|
|
desc.MipLevels = mip_levels;
|
|
desc.Format = format;
|
|
desc.SampleDesc.Count = samples;
|
|
desc.Flags = flags;
|
|
return desc;
|
|
};
|
|
const DXGI_FORMAT rgba = DXGI_FORMAT_R8G8B8A8_UNORM;
|
|
CHECK(create(default_heap, buffer_desc(65536), D3D12_RESOURCE_STATE_COMMON, buffer));
|
|
CHECK(create(upload_heap, buffer_desc(1 << 20), D3D12_RESOURCE_STATE_GENERIC_READ, upload));
|
|
CHECK(create(readback_heap, buffer_desc(1 << 20), D3D12_RESOURCE_STATE_COPY_DEST, readback));
|
|
CHECK(create(default_heap, texture(rgba, D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET), D3D12_RESOURCE_STATE_COMMON,
|
|
target));
|
|
CHECK(create(default_heap, texture(rgba, D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET), D3D12_RESOURCE_STATE_COMMON,
|
|
target2));
|
|
CHECK(create(default_heap, texture(rgba, D3D12_RESOURCE_FLAG_NONE), D3D12_RESOURCE_STATE_COMMON, tex));
|
|
CHECK(create(default_heap, texture(rgba, D3D12_RESOURCE_FLAG_NONE, 1, 4, 3), D3D12_RESOURCE_STATE_COMMON,
|
|
mips));
|
|
CHECK(create(default_heap, texture(DXGI_FORMAT_D32_FLOAT_S8X24_UINT, D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL),
|
|
D3D12_RESOURCE_STATE_DEPTH_WRITE, depth));
|
|
CHECK(create(default_heap, texture(rgba, D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET, 4),
|
|
D3D12_RESOURCE_STATE_COMMON, msaa));
|
|
const D3D12_DESCRIPTOR_HEAP_DESC rtv_desc{D3D12_DESCRIPTOR_HEAP_TYPE_RTV, 1, D3D12_DESCRIPTOR_HEAP_FLAG_NONE,
|
|
0};
|
|
const D3D12_DESCRIPTOR_HEAP_DESC dsv_desc{D3D12_DESCRIPTOR_HEAP_TYPE_DSV, 1, D3D12_DESCRIPTOR_HEAP_FLAG_NONE,
|
|
0};
|
|
CHECK(SUCCEEDED(device->CreateDescriptorHeap(&rtv_desc, IID_PPV_ARGS(&rtv_heap.p))));
|
|
CHECK(SUCCEEDED(device->CreateDescriptorHeap(&dsv_desc, IID_PPV_ARGS(&dsv_heap.p))));
|
|
rtv = rtv_heap->GetCPUDescriptorHandleForHeapStart();
|
|
dsv = dsv_heap->GetCPUDescriptorHandleForHeapStart();
|
|
device->CreateRenderTargetView(target.p, nullptr, rtv);
|
|
device->CreateDepthStencilView(depth.p, nullptr, dsv);
|
|
const D3D12_QUERY_HEAP_DESC query_desc{D3D12_QUERY_HEAP_TYPE_OCCLUSION, 8, 0};
|
|
CHECK(SUCCEEDED(device->CreateQueryHeap(&query_desc, IID_PPV_ARGS(&occlusion.p))));
|
|
CHECK(SUCCEEDED(device->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_BUNDLE,
|
|
IID_PPV_ARGS(&closed_bundle_allocator.p))));
|
|
CHECK(SUCCEEDED(device->CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_BUNDLE, closed_bundle_allocator.p,
|
|
nullptr, IID_PPV_ARGS(&closed_bundle.p))));
|
|
CHECK(SUCCEEDED(closed_bundle->Close()));
|
|
return true;
|
|
}
|
|
};
|
|
|
|
D3D12_RESOURCE_BARRIER barrier(ID3D12Resource* resource, D3D12_RESOURCE_STATES before, D3D12_RESOURCE_STATES after,
|
|
UINT subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES,
|
|
D3D12_RESOURCE_BARRIER_FLAGS flags = D3D12_RESOURCE_BARRIER_FLAG_NONE) {
|
|
D3D12_RESOURCE_BARRIER b = transition(resource, before, after);
|
|
b.Transition.Subresource = subresource;
|
|
b.Flags = flags;
|
|
return b;
|
|
}
|
|
|
|
D3D12_TEXTURE_COPY_LOCATION subresource(ID3D12Resource* resource, UINT index) {
|
|
D3D12_TEXTURE_COPY_LOCATION location{};
|
|
location.pResource = resource;
|
|
location.Type = D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX;
|
|
location.SubresourceIndex = index;
|
|
return location;
|
|
}
|
|
|
|
D3D12_TEXTURE_COPY_LOCATION footprint(ID3D12Resource* resource, UINT64 offset, UINT row_pitch,
|
|
DXGI_FORMAT format = DXGI_FORMAT_R8G8B8A8_UNORM) {
|
|
D3D12_TEXTURE_COPY_LOCATION location{};
|
|
location.pResource = resource;
|
|
location.Type = D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT;
|
|
location.PlacedFootprint.Offset = offset;
|
|
location.PlacedFootprint.Footprint = {format, 64, 64, 1, row_pitch};
|
|
return location;
|
|
}
|
|
|
|
enum class Known { match, layer_stricter, layer_looser };
|
|
|
|
// Records the case's calls on e.list; false when it needs an interface the device does not give.
|
|
using Recorder = std::function<bool(Env&)>;
|
|
|
|
struct Case {
|
|
const char* name;
|
|
bool warp_ok; // WARP's Close verdict, measured
|
|
Known known;
|
|
Recorder record;
|
|
};
|
|
|
|
#define CALLS(...) [](Env& e) { __VA_ARGS__; return true; }
|
|
#define RECORD_COPY(dst_location, x, src_location, box) do { \
|
|
const auto d = dst_location; const auto s = src_location; e.list->CopyTextureRegion(&d, x, 0, 0, &s, box); \
|
|
} while (0)
|
|
|
|
constexpr auto common = D3D12_RESOURCE_STATE_COMMON;
|
|
constexpr auto copy_dest = D3D12_RESOURCE_STATE_COPY_DEST;
|
|
constexpr auto all = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES;
|
|
constexpr auto begin_only = D3D12_RESOURCE_BARRIER_FLAG_BEGIN_ONLY;
|
|
constexpr auto end_only = D3D12_RESOURCE_BARRIER_FLAG_END_ONLY;
|
|
constexpr DXGI_FORMAT rgba = DXGI_FORMAT_R8G8B8A8_UNORM;
|
|
constexpr auto stricter = Known::layer_stricter;
|
|
constexpr auto looser = Known::layer_looser;
|
|
constexpr auto match = Known::match;
|
|
|
|
// One enhanced texture barrier over every subresource of `resource`; false when the list has no enhanced barriers.
|
|
bool texture_barrier(Env& e, ID3D12Resource* resource, D3D12_BARRIER_SYNC sync_before, D3D12_BARRIER_SYNC sync_after,
|
|
D3D12_BARRIER_ACCESS access_before, D3D12_BARRIER_ACCESS access_after,
|
|
D3D12_BARRIER_LAYOUT layout_before, D3D12_BARRIER_LAYOUT layout_after) {
|
|
if (!e.list7) return false;
|
|
D3D12_TEXTURE_BARRIER b{};
|
|
b.SyncBefore = sync_before;
|
|
b.SyncAfter = sync_after;
|
|
b.AccessBefore = access_before;
|
|
b.AccessAfter = access_after;
|
|
b.LayoutBefore = layout_before;
|
|
b.LayoutAfter = layout_after;
|
|
b.pResource = resource;
|
|
b.Subresources = {0xffffffff, 0, 0, 0, 0, 0}; // every subresource
|
|
D3D12_BARRIER_GROUP group{};
|
|
group.Type = D3D12_BARRIER_TYPE_TEXTURE;
|
|
group.NumBarriers = 1;
|
|
group.pTextureBarriers = &b;
|
|
e.list7->Barrier(1, &group);
|
|
return true;
|
|
}
|
|
|
|
std::vector<Case> cases() {
|
|
return {
|
|
{"empty list", true, match, [](Env&) { return true; }},
|
|
{"ResourceBarrier(0, nullptr)", true, match, CALLS(e.list->ResourceBarrier(0, nullptr))},
|
|
// Resource barriers
|
|
{"transition COMMON -> COMMON", false, looser,
|
|
CALLS(const auto b = barrier(e.tex.p, common, common); e.list->ResourceBarrier(1, &b))},
|
|
{"transition COPY_DEST -> COPY_DEST", false, looser,
|
|
CALLS(const auto a = barrier(e.tex.p, common, copy_dest);
|
|
const auto b = barrier(e.tex.p, copy_dest, copy_dest);
|
|
e.list->ResourceBarrier(1, &a); e.list->ResourceBarrier(1, &b))},
|
|
{"transition with BEGIN_ONLY | END_ONLY", false, match,
|
|
CALLS(const auto b = barrier(e.tex.p, common, copy_dest, all, begin_only | end_only);
|
|
e.list->ResourceBarrier(1, &b))},
|
|
{"split transition: BEGIN_ONLY then END_ONLY", true, match,
|
|
CALLS(auto b = barrier(e.tex.p, common, copy_dest, all, begin_only); e.list->ResourceBarrier(1, &b);
|
|
b.Flags = end_only; e.list->ResourceBarrier(1, &b);
|
|
const auto c = barrier(e.tex.p, copy_dest, common); e.list->ResourceBarrier(1, &c))},
|
|
{"split transition: END_ONLY without BEGIN_ONLY", true, match,
|
|
CALLS(const auto b = barrier(e.tex.p, common, copy_dest, all, end_only); e.list->ResourceBarrier(1, &b))},
|
|
{"transition of a null resource", false, match,
|
|
CALLS(const auto b = barrier(nullptr, common, copy_dest); e.list->ResourceBarrier(1, &b))},
|
|
{"transition of subresource 99 of a 1-subresource texture", false, looser,
|
|
CALLS(const auto b = barrier(e.tex.p, common, copy_dest, 99); e.list->ResourceBarrier(1, &b))},
|
|
{"transition to COPY_DEST | COPY_SOURCE (write and read)", false, looser,
|
|
CALLS(const auto b = barrier(e.tex.p, common, copy_dest | D3D12_RESOURCE_STATE_COPY_SOURCE);
|
|
e.list->ResourceBarrier(1, &b))},
|
|
{"UAV barrier of a null resource", true, match,
|
|
CALLS(D3D12_RESOURCE_BARRIER b{}; b.Type = D3D12_RESOURCE_BARRIER_TYPE_UAV; e.list->ResourceBarrier(1, &b))},
|
|
{"UAV barrier with BEGIN_ONLY", false, match,
|
|
CALLS(D3D12_RESOURCE_BARRIER b{}; b.Type = D3D12_RESOURCE_BARRIER_TYPE_UAV; b.Flags = begin_only;
|
|
e.list->ResourceBarrier(1, &b))},
|
|
{"aliasing barrier null -> null", true, match,
|
|
CALLS(D3D12_RESOURCE_BARRIER b{}; b.Type = D3D12_RESOURCE_BARRIER_TYPE_ALIASING;
|
|
e.list->ResourceBarrier(1, &b))},
|
|
{"barrier type 7", false, match,
|
|
CALLS(D3D12_RESOURCE_BARRIER b{}; b.Type = D3D12_RESOURCE_BARRIER_TYPE(7); e.list->ResourceBarrier(1, &b))},
|
|
// Enhanced barriers (ID3D12GraphicsCommandList7::Barrier). LayoutAfter UNDEFINED says the contents are no
|
|
// longer needed; the retail title ends a depth buffer's use that way (sync DEPTH_STENCIL -> NONE, access
|
|
// DEPTH_STENCIL_WRITE -> NO_ACCESS), and the layer failed the list's Close for it. The WARP column of these
|
|
// four rows was measured on Windows 11 26340 (#984), not on the build the header names.
|
|
{"Barrier: depth DEPTH_STENCIL_WRITE -> COPY_SOURCE", true, match,
|
|
[](Env& e) {
|
|
return texture_barrier(e, e.depth.p, D3D12_BARRIER_SYNC_DEPTH_STENCIL, D3D12_BARRIER_SYNC_COPY,
|
|
D3D12_BARRIER_ACCESS_DEPTH_STENCIL_WRITE, D3D12_BARRIER_ACCESS_COPY_SOURCE,
|
|
D3D12_BARRIER_LAYOUT_DEPTH_STENCIL_WRITE, D3D12_BARRIER_LAYOUT_COPY_SOURCE);
|
|
}},
|
|
{"Barrier: depth DEPTH_STENCIL_WRITE -> UNDEFINED, sync NONE after", true, match,
|
|
[](Env& e) {
|
|
return texture_barrier(e, e.depth.p, D3D12_BARRIER_SYNC_DEPTH_STENCIL, D3D12_BARRIER_SYNC_NONE,
|
|
D3D12_BARRIER_ACCESS_DEPTH_STENCIL_WRITE, D3D12_BARRIER_ACCESS_NO_ACCESS,
|
|
D3D12_BARRIER_LAYOUT_DEPTH_STENCIL_WRITE, D3D12_BARRIER_LAYOUT_UNDEFINED);
|
|
}},
|
|
{"Barrier: texture COMMON -> UNDEFINED", true, match,
|
|
[](Env& e) {
|
|
return texture_barrier(e, e.tex.p, D3D12_BARRIER_SYNC_ALL, D3D12_BARRIER_SYNC_NONE,
|
|
D3D12_BARRIER_ACCESS_COMMON, D3D12_BARRIER_ACCESS_NO_ACCESS,
|
|
D3D12_BARRIER_LAYOUT_COMMON, D3D12_BARRIER_LAYOUT_UNDEFINED);
|
|
}},
|
|
{"Barrier: texture UNDEFINED -> UNDEFINED", true, match,
|
|
[](Env& e) {
|
|
return texture_barrier(e, e.tex.p, D3D12_BARRIER_SYNC_NONE, D3D12_BARRIER_SYNC_NONE,
|
|
D3D12_BARRIER_ACCESS_NO_ACCESS, D3D12_BARRIER_ACCESS_NO_ACCESS,
|
|
D3D12_BARRIER_LAYOUT_UNDEFINED, D3D12_BARRIER_LAYOUT_UNDEFINED);
|
|
}},
|
|
// CopyBufferRegion
|
|
{"CopyBufferRegion of 0 bytes", true, match, CALLS(e.list->CopyBufferRegion(e.buffer.p, 0, e.upload.p, 0, 0))},
|
|
{"CopyBufferRegion past the end of the destination", false, looser,
|
|
CALLS(e.list->CopyBufferRegion(e.buffer.p, 65000, e.upload.p, 0, 4096))},
|
|
{"CopyBufferRegion within one buffer, disjoint", true, match,
|
|
CALLS(e.list->CopyBufferRegion(e.buffer.p, 0, e.buffer.p, 4096, 1024))},
|
|
{"CopyBufferRegion within one buffer, overlapping", true, match,
|
|
CALLS(e.list->CopyBufferRegion(e.buffer.p, 0, e.buffer.p, 512, 1024))},
|
|
{"CopyBufferRegion from a null source", false, match,
|
|
CALLS(e.list->CopyBufferRegion(e.buffer.p, 0, nullptr, 0, 16))},
|
|
{"CopyBufferRegion into a texture", false, looser,
|
|
CALLS(e.list->CopyBufferRegion(e.tex.p, 0, e.upload.p, 0, 16))},
|
|
// CopyTextureRegion
|
|
{"CopyTextureRegion upload, offset 0, row pitch 256", true, match,
|
|
CALLS(RECORD_COPY(subresource(e.tex.p, 0), 0, footprint(e.upload.p, 0, 256), nullptr))},
|
|
{"CopyTextureRegion upload, offset 16 (not 512-aligned)", true, stricter,
|
|
CALLS(RECORD_COPY(subresource(e.tex.p, 0), 0, footprint(e.upload.p, 16, 256), nullptr))},
|
|
{"CopyTextureRegion upload, offset 4 (not 512-aligned)", true, stricter,
|
|
CALLS(RECORD_COPY(subresource(e.tex.p, 0), 0, footprint(e.upload.p, 4, 256), nullptr))},
|
|
{"CopyTextureRegion upload, row pitch 260 (not 256-aligned)", true, stricter,
|
|
CALLS(RECORD_COPY(subresource(e.tex.p, 0), 0, footprint(e.upload.p, 0, 260), nullptr))},
|
|
{"CopyTextureRegion upload, row pitch 128 (shorter than a row)", false, match,
|
|
CALLS(RECORD_COPY(subresource(e.tex.p, 0), 0, footprint(e.upload.p, 0, 128), nullptr))},
|
|
{"CopyTextureRegion upload, footprint format UNKNOWN", false, looser,
|
|
CALLS(RECORD_COPY(subresource(e.tex.p, 0), 0, footprint(e.upload.p, 0, 256, DXGI_FORMAT_UNKNOWN), nullptr))},
|
|
{"CopyTextureRegion upload, footprint R32_FLOAT into RGBA8", false, looser,
|
|
CALLS(RECORD_COPY(subresource(e.tex.p, 0), 0, footprint(e.upload.p, 0, 256, DXGI_FORMAT_R32_FLOAT), nullptr))},
|
|
{"CopyTextureRegion upload, footprint RGBA8_SRGB into RGBA8", true, match,
|
|
CALLS(RECORD_COPY(subresource(e.tex.p, 0), 0,
|
|
footprint(e.upload.p, 0, 256, DXGI_FORMAT_R8G8B8A8_UNORM_SRGB), nullptr))},
|
|
{"CopyTextureRegion upload with an empty box", true, match,
|
|
CALLS(const D3D12_BOX box{4, 4, 0, 4, 8, 1};
|
|
RECORD_COPY(subresource(e.tex.p, 0), 0, footprint(e.upload.p, 0, 256), &box))},
|
|
{"CopyTextureRegion upload with an inverted box", true, match,
|
|
CALLS(const D3D12_BOX box{8, 4, 0, 4, 8, 1};
|
|
RECORD_COPY(subresource(e.tex.p, 0), 0, footprint(e.upload.p, 0, 256), &box))},
|
|
{"CopyTextureRegion upload past the texture's edge (x 32 of 64)", false, looser,
|
|
CALLS(RECORD_COPY(subresource(e.tex.p, 0), 32, footprint(e.upload.p, 0, 256), nullptr))},
|
|
{"CopyTextureRegion into a readback footprint", true, match,
|
|
CALLS(RECORD_COPY(footprint(e.readback.p, 0, 256), 0, subresource(e.tex.p, 0), nullptr))},
|
|
{"CopyTextureRegion footprint to footprint", true, stricter,
|
|
CALLS(RECORD_COPY(footprint(e.readback.p, 0, 256), 0, footprint(e.upload.p, 0, 256), nullptr))},
|
|
{"CopyTextureRegion into subresource 5 of a 1-subresource texture", false, looser,
|
|
CALLS(RECORD_COPY(subresource(e.tex.p, 5), 0, footprint(e.upload.p, 0, 256), nullptr))},
|
|
{"CopyTextureRegion between two subresources of one texture", true, match,
|
|
CALLS(RECORD_COPY(subresource(e.mips.p, 1), 0, subresource(e.mips.p, 5), nullptr))},
|
|
{"CopyTextureRegion within one subresource, disjoint", true, match,
|
|
CALLS(const D3D12_BOX box{0, 0, 0, 8, 8, 1};
|
|
RECORD_COPY(subresource(e.tex.p, 0), 32, subresource(e.tex.p, 0), &box))},
|
|
{"CopyTextureRegion into a null location", false, match,
|
|
CALLS(const auto s = subresource(e.tex.p, 0); e.list->CopyTextureRegion(nullptr, 0, 0, 0, &s, nullptr))},
|
|
// CopyResource
|
|
{"CopyResource with the destination as the source", true, match,
|
|
CALLS(e.list->CopyResource(e.tex.p, e.tex.p))},
|
|
{"CopyResource buffer to texture", true, match, CALLS(e.list->CopyResource(e.tex.p, e.buffer.p))},
|
|
{"CopyResource between buffers of different sizes", false, looser,
|
|
CALLS(e.list->CopyResource(e.upload.p, e.buffer.p))},
|
|
{"CopyResource texture to texture", true, match, CALLS(e.list->CopyResource(e.target2.p, e.target.p))},
|
|
// Clears and discards
|
|
{"ClearRenderTargetView with an inverted rectangle", true, match,
|
|
CALLS(const FLOAT red[4] = {1, 0, 0, 1}; const D3D12_RECT r{10, 10, 5, 5};
|
|
e.list->ClearRenderTargetView(e.rtv, red, 1, &r))},
|
|
{"ClearRenderTargetView with a rectangle past the target", true, match,
|
|
CALLS(const FLOAT red[4] = {1, 0, 0, 1}; const D3D12_RECT r{-8, -8, 4096, 4096};
|
|
e.list->ClearRenderTargetView(e.rtv, red, 1, &r))},
|
|
{"ClearRenderTargetView with NaN, infinite and negative channels", true, match,
|
|
CALLS(const FLOAT c[4] = {std::numeric_limits<float>::quiet_NaN(), std::numeric_limits<float>::infinity(),
|
|
-1, 2};
|
|
e.list->ClearRenderTargetView(e.rtv, c, 0, nullptr))},
|
|
// A depth outside [0, 1] (NaN included) is stored as given and a clear that names no plane clears nothing:
|
|
// WARP closes both lists (d3d12_clear_test reads the texels back).
|
|
{"ClearDepthStencilView with flags 0", true, match,
|
|
CALLS(e.list->ClearDepthStencilView(e.dsv, D3D12_CLEAR_FLAGS(0), 1, 0, 0, nullptr))},
|
|
{"ClearDepthStencilView depth 1.5", true, match,
|
|
CALLS(e.list->ClearDepthStencilView(e.dsv, D3D12_CLEAR_FLAG_DEPTH, 1.5f, 0, 0, nullptr))},
|
|
{"ClearDepthStencilView depth -0.5", true, match,
|
|
CALLS(e.list->ClearDepthStencilView(e.dsv, D3D12_CLEAR_FLAG_DEPTH, -0.5f, 0, 0, nullptr))},
|
|
{"ClearDepthStencilView depth NaN", true, match,
|
|
CALLS(e.list->ClearDepthStencilView(e.dsv, D3D12_CLEAR_FLAG_DEPTH,
|
|
std::numeric_limits<float>::quiet_NaN(), 0, 0,
|
|
nullptr))},
|
|
{"ClearDepthStencilView stencil only, depth 7 (not used)", true, match,
|
|
CALLS(e.list->ClearDepthStencilView(e.dsv, D3D12_CLEAR_FLAG_STENCIL, 7.0f, 3, 0, nullptr))},
|
|
{"ClearDepthStencilView with flags 7 (an unknown bit)", true, stricter,
|
|
CALLS(e.list->ClearDepthStencilView(e.dsv, D3D12_CLEAR_FLAGS(7), 1, 0, 0, nullptr))},
|
|
{"DiscardResource with no region", true, match, CALLS(e.list->DiscardResource(e.target.p, nullptr))},
|
|
{"DiscardResource of 0 subresources", true, match,
|
|
CALLS(const D3D12_DISCARD_REGION r{0, nullptr, 0, 0}; e.list->DiscardResource(e.target.p, &r))},
|
|
{"DiscardResource of a texture that is no target", true, match,
|
|
CALLS(e.list->DiscardResource(e.tex.p, nullptr))},
|
|
// ResolveSubresource
|
|
{"ResolveSubresource 4x -> 1x", true, match,
|
|
CALLS(e.list->ResolveSubresource(e.target.p, 0, e.msaa.p, 0, rgba))},
|
|
{"ResolveSubresource with format UNKNOWN", false, looser,
|
|
CALLS(e.list->ResolveSubresource(e.target.p, 0, e.msaa.p, 0, DXGI_FORMAT_UNKNOWN))},
|
|
{"ResolveSubresource as RGBA8_SRGB of RGBA8 textures", true, match,
|
|
CALLS(e.list->ResolveSubresource(e.target.p, 0, e.msaa.p, 0, DXGI_FORMAT_R8G8B8A8_UNORM_SRGB))},
|
|
{"ResolveSubresource as R32_FLOAT of RGBA8 textures", false, looser,
|
|
CALLS(e.list->ResolveSubresource(e.target.p, 0, e.msaa.p, 0, DXGI_FORMAT_R32_FLOAT))},
|
|
{"ResolveSubresource from a single-sampled texture", false, looser,
|
|
CALLS(e.list->ResolveSubresource(e.target.p, 0, e.target2.p, 0, rgba))},
|
|
{"ResolveSubresource with the destination as the source", false, match,
|
|
CALLS(e.list->ResolveSubresource(e.msaa.p, 0, e.msaa.p, 0, rgba))},
|
|
// Input assembler, rasterizer, output merger
|
|
{"IASetVertexBuffers(30, 4): slots past 31", true, stricter,
|
|
CALLS(const D3D12_VERTEX_BUFFER_VIEW v[4] = {}; e.list->IASetVertexBuffers(30, 4, v))},
|
|
{"IASetVertexBuffers(0, 0, nullptr)", true, match, CALLS(e.list->IASetVertexBuffers(0, 0, nullptr))},
|
|
{"IASetIndexBuffer(nullptr)", true, match, CALLS(e.list->IASetIndexBuffer(nullptr))},
|
|
{"IASetIndexBuffer as R16_UINT", true, match,
|
|
CALLS(const D3D12_INDEX_BUFFER_VIEW v{e.buffer->GetGPUVirtualAddress(), 64, DXGI_FORMAT_R16_UINT};
|
|
e.list->IASetIndexBuffer(&v))},
|
|
{"IASetIndexBuffer as R32_UINT", true, match,
|
|
CALLS(const D3D12_INDEX_BUFFER_VIEW v{e.buffer->GetGPUVirtualAddress(), 64, DXGI_FORMAT_R32_UINT};
|
|
e.list->IASetIndexBuffer(&v))},
|
|
{"IASetIndexBuffer as UNKNOWN, size 0", true, match,
|
|
CALLS(const D3D12_INDEX_BUFFER_VIEW v{0, 0, DXGI_FORMAT_UNKNOWN}; e.list->IASetIndexBuffer(&v))},
|
|
{"IASetIndexBuffer as UNKNOWN, size 64", true, match,
|
|
CALLS(const D3D12_INDEX_BUFFER_VIEW v{e.buffer->GetGPUVirtualAddress(), 64, DXGI_FORMAT_UNKNOWN};
|
|
e.list->IASetIndexBuffer(&v))},
|
|
{"IASetIndexBuffer as R8_UINT", true, match,
|
|
CALLS(const D3D12_INDEX_BUFFER_VIEW v{e.buffer->GetGPUVirtualAddress(), 64, DXGI_FORMAT_R8_UINT};
|
|
e.list->IASetIndexBuffer(&v))},
|
|
{"IASetIndexBuffer as R32_FLOAT", true, match,
|
|
CALLS(const D3D12_INDEX_BUFFER_VIEW v{e.buffer->GetGPUVirtualAddress(), 64, DXGI_FORMAT_R32_FLOAT};
|
|
e.list->IASetIndexBuffer(&v))},
|
|
{"IASetPrimitiveTopology(UNDEFINED)", true, match,
|
|
CALLS(e.list->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_UNDEFINED))},
|
|
{"IASetPrimitiveTopology(TRIANGLELIST)", true, match,
|
|
CALLS(e.list->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST))},
|
|
{"IASetPrimitiveTopology(7) (gap value)", true, match,
|
|
CALLS(e.list->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY(7)))},
|
|
{"IASetPrimitiveTopology(32_CONTROL_POINT_PATCHLIST)", true, match,
|
|
CALLS(e.list->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_32_CONTROL_POINT_PATCHLIST))},
|
|
{"IASetPrimitiveTopology(65) (past 32-cp patch)", true, match,
|
|
CALLS(e.list->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY(65)))},
|
|
{"IASetPrimitiveTopology(99)", true, match, CALLS(e.list->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY(99)))},
|
|
{"OMSetBlendFactor", true, match,
|
|
CALLS(const FLOAT factor[4] = {0.25f, 0.5f, 0.75f, 1.0f}; e.list->OMSetBlendFactor(factor))},
|
|
{"OMSetStencilRef(7)", true, match, CALLS(e.list->OMSetStencilRef(7))},
|
|
{"ExecuteBundle after post-close state calls on bundle", true, match,
|
|
CALLS(const FLOAT factor[4] = {0.25f, 0.5f, 0.75f, 1.0f};
|
|
e.closed_bundle->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
|
|
e.closed_bundle->IASetIndexBuffer(nullptr);
|
|
e.closed_bundle->OMSetBlendFactor(factor);
|
|
e.closed_bundle->OMSetStencilRef(9);
|
|
e.closed_bundle->ClearState(nullptr);
|
|
e.list->ExecuteBundle(e.closed_bundle.p))},
|
|
{"RSSetViewports(0, nullptr)", true, match, CALLS(e.list->RSSetViewports(0, nullptr))},
|
|
{"RSSetViewports(17)", true, stricter,
|
|
CALLS(D3D12_VIEWPORT v[17]; for (auto& x : v) x = {0, 0, 8, 8, 0, 1}; e.list->RSSetViewports(17, v))},
|
|
{"RSSetViewports with MinDepth -1", true, match,
|
|
CALLS(const D3D12_VIEWPORT v{0, 0, 8, 8, -1, 1}; e.list->RSSetViewports(1, &v))},
|
|
{"RSSetViewports with a negative width", true, match,
|
|
CALLS(const D3D12_VIEWPORT v{0, 0, -8, 8, 0, 1}; e.list->RSSetViewports(1, &v))},
|
|
{"RSSetViewports with a negative height", true, match,
|
|
CALLS(const D3D12_VIEWPORT v{0, 8, 8, -8, 0, 1}; e.list->RSSetViewports(1, &v))},
|
|
{"RSSetViewports at x -40000", true, match,
|
|
CALLS(const D3D12_VIEWPORT v{-40000, 0, 8, 8, 0, 1}; e.list->RSSetViewports(1, &v))},
|
|
{"RSSetScissorRects(0, nullptr)", true, match, CALLS(e.list->RSSetScissorRects(0, nullptr))},
|
|
{"RSSetScissorRects(17)", true, match, CALLS(const D3D12_RECT r[17] = {}; e.list->RSSetScissorRects(17, r))},
|
|
{"RSSetScissorRects inverted", true, match,
|
|
CALLS(const D3D12_RECT r{10, 10, 5, 5}; e.list->RSSetScissorRects(1, &r))},
|
|
{"OMSetRenderTargets(9)", false, match,
|
|
CALLS(D3D12_CPU_DESCRIPTOR_HANDLE h[9]; for (auto& x : h) x = e.rtv;
|
|
e.list->OMSetRenderTargets(9, h, FALSE, nullptr))},
|
|
{"OMSetRenderTargets(0, nullptr, depth)", true, match,
|
|
CALLS(e.list->OMSetRenderTargets(0, nullptr, FALSE, &e.dsv))},
|
|
// Draws, dispatches and root arguments with nothing set
|
|
{"DrawInstanced(3) with nothing set", true, stricter, CALLS(e.list->DrawInstanced(3, 1, 0, 0))},
|
|
{"DrawInstanced(0) with nothing set", true, stricter, CALLS(e.list->DrawInstanced(0, 1, 0, 0))},
|
|
{"Dispatch(1, 1, 1) with nothing set", true, stricter, CALLS(e.list->Dispatch(1, 1, 1))},
|
|
{"Dispatch(0, 0, 0) with nothing set", true, stricter, CALLS(e.list->Dispatch(0, 0, 0))},
|
|
{"SetGraphicsRoot32BitConstant before a root signature", true, stricter,
|
|
CALLS(e.list->SetGraphicsRoot32BitConstant(0, 1, 0))},
|
|
{"SetGraphicsRootConstantBufferView before a root signature", true, stricter,
|
|
CALLS(e.list->SetGraphicsRootConstantBufferView(0, e.buffer->GetGPUVirtualAddress()))},
|
|
{"SetGraphicsRootDescriptorTable before a root signature", true, stricter,
|
|
CALLS(e.list->SetGraphicsRootDescriptorTable(0, {}))},
|
|
{"SetGraphicsRootSignature(nullptr)", true, match, CALLS(e.list->SetGraphicsRootSignature(nullptr))},
|
|
{"SetDescriptorHeaps(0, nullptr)", true, match, CALLS(e.list->SetDescriptorHeaps(0, nullptr))},
|
|
{"ClearState(nullptr)", true, match, CALLS(e.list->ClearState(nullptr))},
|
|
// Predication and queries
|
|
{"SetPredication(nullptr)", true, match,
|
|
CALLS(e.list->SetPredication(nullptr, 0, D3D12_PREDICATION_OP_EQUAL_ZERO))},
|
|
{"SetPredication at offset 4", false, match,
|
|
CALLS(e.list->SetPredication(e.buffer.p, 4, D3D12_PREDICATION_OP_EQUAL_ZERO);
|
|
e.list->SetPredication(nullptr, 0, D3D12_PREDICATION_OP_EQUAL_ZERO))},
|
|
{"SetPredication with operation 7", false, match,
|
|
CALLS(e.list->SetPredication(e.buffer.p, 0, D3D12_PREDICATION_OP(7));
|
|
e.list->SetPredication(nullptr, 0, D3D12_PREDICATION_OP_EQUAL_ZERO))},
|
|
{"BeginQuery without EndQuery", false, match,
|
|
CALLS(e.list->BeginQuery(e.occlusion.p, D3D12_QUERY_TYPE_OCCLUSION, 0))},
|
|
{"EndQuery without BeginQuery", false, match,
|
|
CALLS(e.list->EndQuery(e.occlusion.p, D3D12_QUERY_TYPE_OCCLUSION, 0))},
|
|
{"BeginQuery twice on one index", false, match,
|
|
CALLS(e.list->BeginQuery(e.occlusion.p, D3D12_QUERY_TYPE_OCCLUSION, 0);
|
|
e.list->BeginQuery(e.occlusion.p, D3D12_QUERY_TYPE_OCCLUSION, 0);
|
|
e.list->EndQuery(e.occlusion.p, D3D12_QUERY_TYPE_OCCLUSION, 0))},
|
|
{"BeginQuery and EndQuery at index 100 of 8", false, looser,
|
|
CALLS(e.list->BeginQuery(e.occlusion.p, D3D12_QUERY_TYPE_OCCLUSION, 100);
|
|
e.list->EndQuery(e.occlusion.p, D3D12_QUERY_TYPE_OCCLUSION, 100))},
|
|
{"BeginQuery OCCLUSION, EndQuery BINARY_OCCLUSION", true, stricter,
|
|
CALLS(e.list->BeginQuery(e.occlusion.p, D3D12_QUERY_TYPE_OCCLUSION, 0);
|
|
e.list->EndQuery(e.occlusion.p, D3D12_QUERY_TYPE_BINARY_OCCLUSION, 0))},
|
|
{"ResolveQueryData of 0 queries", true, match,
|
|
CALLS(e.list->ResolveQueryData(e.occlusion.p, D3D12_QUERY_TYPE_OCCLUSION, 0, 0, e.readback.p, 0))},
|
|
{"ResolveQueryData at offset 4", false, match,
|
|
CALLS(e.list->ResolveQueryData(e.occlusion.p, D3D12_QUERY_TYPE_OCCLUSION, 0, 1, e.readback.p, 4))},
|
|
{"ResolveQueryData of a query never begun", true, match,
|
|
CALLS(e.list->ResolveQueryData(e.occlusion.p, D3D12_QUERY_TYPE_OCCLUSION, 3, 1, e.readback.p, 0))},
|
|
// Markers and immediate writes
|
|
{"EndEvent without BeginEvent", true, match, CALLS(e.list->EndEvent())},
|
|
{"SetMarker(0, nullptr, 0)", true, match, CALLS(e.list->SetMarker(0, nullptr, 0))},
|
|
{"WriteBufferImmediate of 0 values", true, match,
|
|
[](Env& e) {
|
|
if (!e.list2) return false;
|
|
e.list2->WriteBufferImmediate(0, nullptr, nullptr);
|
|
return true;
|
|
}},
|
|
{"WriteBufferImmediate at an address that is not 4-aligned", true, stricter,
|
|
[](Env& e) {
|
|
if (!e.list2) return false;
|
|
const D3D12_WRITEBUFFERIMMEDIATE_PARAMETER p{e.buffer->GetGPUVirtualAddress() + 2, 7};
|
|
e.list2->WriteBufferImmediate(1, &p, nullptr);
|
|
return true;
|
|
}},
|
|
};
|
|
}
|
|
|
|
// Records one case on a fresh allocator and list of `env`'s device and returns what Close says.
|
|
bool run_case(Env& env, const Case& c, HRESULT& close) {
|
|
Ref<ID3D12CommandAllocator> allocator;
|
|
Ref<ID3D12GraphicsCommandList> list;
|
|
Ref<ID3D12GraphicsCommandList2> list2;
|
|
Ref<ID3D12GraphicsCommandList7> list7;
|
|
CHECK(SUCCEEDED(env.device->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT, IID_PPV_ARGS(&allocator.p))));
|
|
CHECK(SUCCEEDED(env.device->CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, allocator.p, nullptr,
|
|
IID_PPV_ARGS(&list.p))));
|
|
if (FAILED(list->QueryInterface(IID_PPV_ARGS(&list2.p)))) list2.p = nullptr;
|
|
D3D12_FEATURE_DATA_D3D12_OPTIONS12 options12{};
|
|
if (FAILED(env.device->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS12, &options12, sizeof(options12))) ||
|
|
!options12.EnhancedBarriersSupported || FAILED(list->QueryInterface(IID_PPV_ARGS(&list7.p))))
|
|
list7.p = nullptr;
|
|
env.list = list.p;
|
|
env.list2 = list2.p;
|
|
env.list7 = list7.p;
|
|
const bool recorded = c.record(env);
|
|
close = recorded ? list->Close() : not_run;
|
|
if (!recorded) list->Close();
|
|
env.list = nullptr;
|
|
env.list2 = nullptr;
|
|
env.list7 = nullptr;
|
|
return true;
|
|
}
|
|
|
|
std::string text(HRESULT hr) {
|
|
if (hr == not_run) return "n/a";
|
|
char out[16];
|
|
std::snprintf(out, sizeof(out), "0x%08lx", static_cast<unsigned long>(hr));
|
|
return out;
|
|
}
|
|
|
|
} // namespace
|
|
|
|
int main() {
|
|
std::setvbuf(stdout, nullptr, _IONBF, 0);
|
|
vktest::Device vk;
|
|
const auto device_status = vk.initialize();
|
|
if (device_status == vktest::DeviceStatus::unavailable) {
|
|
std::fprintf(stderr, "SKIP: no usable Vulkan 1.3 device\n");
|
|
return 77;
|
|
}
|
|
REQUIRE(device_status == vktest::DeviceStatus::ready);
|
|
const auto table = cases();
|
|
const unsigned errors_before = vk.validation_errors();
|
|
|
|
std::vector<HRESULT> layer(table.size(), not_run), warp(table.size(), not_run);
|
|
{
|
|
rt::d3d12::VulkanDeviceInfo info{};
|
|
info.get_instance_proc = vk.instance_proc;
|
|
info.instance = vk.instance;
|
|
info.physical = vk.physical;
|
|
info.device = vk.device;
|
|
info.queue = vk.queue;
|
|
info.queue_family = vk.family;
|
|
info.buffer_device_address = true;
|
|
Ref<ID3D12Device> ours;
|
|
REQUIRE(SUCCEEDED(rt::d3d12::create_vulkan_device(info, IID_PPV_ARGS(&ours.p))));
|
|
Env env;
|
|
REQUIRE(env.init(ours.p));
|
|
for (std::size_t i = 0; i < table.size(); ++i) REQUIRE(run_case(env, table[i], layer[i]));
|
|
}
|
|
|
|
bool warp_ran = false;
|
|
if (!hostwine::host_is_wine()) {
|
|
Ref<IDXGIFactory4> factory;
|
|
Ref<IDXGIAdapter> adapter;
|
|
Ref<ID3D12Device> host;
|
|
if (SUCCEEDED(CreateDXGIFactory1(IID_PPV_ARGS(&factory.p))) &&
|
|
SUCCEEDED(factory->EnumWarpAdapter(IID_PPV_ARGS(&adapter.p))) &&
|
|
SUCCEEDED(D3D12CreateDevice(adapter.p, D3D_FEATURE_LEVEL_11_0, IID_PPV_ARGS(&host.p)))) {
|
|
Env env;
|
|
REQUIRE(env.init(host.p));
|
|
for (std::size_t i = 0; i < table.size(); ++i) REQUIRE(run_case(env, table[i], warp[i]));
|
|
// Nothing is executed, so nothing should remove the device; if something did, its answers are suspect.
|
|
REQUIRE(host->GetDeviceRemovedReason() == S_OK);
|
|
warp_ran = true;
|
|
} else {
|
|
std::printf("no WARP device: the layer is compared with the measured WARP column\n");
|
|
}
|
|
}
|
|
|
|
unsigned failures = 0, matched = 0, known_stricter = 0, known_looser = 0, warp_changed = 0, skipped = 0;
|
|
std::printf("%-62s | %-10s | %-10s | %s\n", "case", "layer", "WARP", "expected");
|
|
for (std::size_t i = 0; i < table.size(); ++i) {
|
|
const Case& c = table[i];
|
|
const bool live = warp_ran && warp[i] != not_run;
|
|
const char* expected = c.known == Known::match ? "match"
|
|
: c.known == Known::layer_stricter ? "layer stricter (known)"
|
|
: "layer looser (known)";
|
|
std::printf("%-62s | %-10s | %-10s | %s\n", c.name, text(layer[i]).c_str(),
|
|
live ? text(warp[i]).c_str() : (c.warp_ok ? "(S_OK)" : "(failure)"), expected);
|
|
if (layer[i] == not_run) {
|
|
++skipped;
|
|
continue;
|
|
}
|
|
if (live && SUCCEEDED(warp[i]) != c.warp_ok) {
|
|
std::printf(" WARP's verdict here differs from the measured column (%s): compared with the live answer\n",
|
|
c.warp_ok ? "S_OK" : "a failure");
|
|
++warp_changed;
|
|
}
|
|
const bool reference_ok = live ? SUCCEEDED(warp[i]) : c.warp_ok;
|
|
const bool layer_ok = SUCCEEDED(layer[i]);
|
|
const bool want_layer_ok = c.known == Known::match ? reference_ok : !reference_ok;
|
|
if (layer_ok != want_layer_ok) {
|
|
if (c.known == Known::match)
|
|
std::fprintf(stderr, "FAIL %s: layer Close %s, WARP %s\n", c.name, text(layer[i]).c_str(),
|
|
reference_ok ? "succeeds" : "fails");
|
|
else
|
|
std::fprintf(stderr, "FAIL %s: now matches WARP; mark it Known::match in the table\n", c.name);
|
|
++failures;
|
|
continue;
|
|
}
|
|
if (c.known == Known::match) ++matched;
|
|
else if (c.known == Known::layer_stricter) ++known_stricter;
|
|
else ++known_looser;
|
|
}
|
|
const unsigned validation_errors = vk.validation_errors() - errors_before;
|
|
if (validation_errors) {
|
|
std::fprintf(stderr, "%u Vulkan validation errors\n", validation_errors);
|
|
++failures;
|
|
}
|
|
std::printf("close parity: %zu cases, %u match %s, %u known layer-stricter, %u known layer-looser, %u not run, "
|
|
"%u where WARP differs from the measured column, %u failures\n",
|
|
table.size(), matched, warp_ran ? "WARP" : "the measured WARP column", known_stricter, known_looser,
|
|
skipped, warp_changed, failures);
|
|
return failures ? 1 : 0;
|
|
}
|