diff options
Diffstat (limited to 'runtime/test/d3d12_query_rules_test.cpp')
| -rw-r--r-- | runtime/test/d3d12_query_rules_test.cpp | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/runtime/test/d3d12_query_rules_test.cpp b/runtime/test/d3d12_query_rules_test.cpp index 6d51ab704..9d5d4711d 100644 --- a/runtime/test/d3d12_query_rules_test.cpp +++ b/runtime/test/d3d12_query_rules_test.cpp | |||
| @@ -230,6 +230,20 @@ std::string all_cases(ID3D12Device* device) { | |||
| 230 | return heap_cases(device) + list_cases(e) + timestamp_runs(e); | 230 | return heap_cases(device) + list_cases(e) + timestamp_runs(e); |
| 231 | } | 231 | } |
| 232 | 232 | ||
| 233 | bool check_copy_timestamp_capability(ID3D12Device* device, bool expected, const char* queue_pool) { | ||
| 234 | D3D12_FEATURE_DATA_D3D12_OPTIONS3 options{}; | ||
| 235 | const auto desc = D3D12_QUERY_HEAP_DESC{D3D12_QUERY_HEAP_TYPE_COPY_QUEUE_TIMESTAMP, 2, 0}; | ||
| 236 | Ref<ID3D12QueryHeap> heap; | ||
| 237 | const HRESULT hr = device->CreateQueryHeap(&desc, IID_PPV_ARGS(&heap.p)); | ||
| 238 | if (SUCCEEDED(device->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS3, &options, sizeof(options))) && | ||
| 239 | bool(options.CopyQueueTimestampQueriesSupported) == expected && | ||
| 240 | (expected ? SUCCEEDED(hr) && heap.p : hr == E_NOTIMPL && !heap.p)) | ||
| 241 | return true; | ||
| 242 | std::fprintf(stderr, "%s: OPTIONS3 or COPY_QUEUE_TIMESTAMP heap disagrees with Vulkan queue support (%d)\n", | ||
| 243 | queue_pool, int(expected)); | ||
| 244 | return false; | ||
| 245 | } | ||
| 246 | |||
| 233 | std::vector<std::string> lines(const std::string& s) { | 247 | std::vector<std::string> lines(const std::string& s) { |
| 234 | std::vector<std::string> out; | 248 | std::vector<std::string> out; |
| 235 | size_t at = 0; | 249 | size_t at = 0; |
| @@ -244,6 +258,7 @@ std::vector<std::string> lines(const std::string& s) { | |||
| 244 | 258 | ||
| 245 | int main() { | 259 | int main() { |
| 246 | vktest::Device vk; | 260 | vktest::Device vk; |
| 261 | vk.all_queue_types = true; | ||
| 247 | const auto device_status = vk.initialize(); | 262 | const auto device_status = vk.initialize(); |
| 248 | if (device_status == vktest::DeviceStatus::unavailable) return 77; | 263 | if (device_status == vktest::DeviceStatus::unavailable) return 77; |
| 249 | if (device_status != vktest::DeviceStatus::ready) return 1; | 264 | if (device_status != vktest::DeviceStatus::ready) return 1; |
| @@ -259,6 +274,8 @@ int main() { | |||
| 259 | info.queue = vk.queue; | 274 | info.queue = vk.queue; |
| 260 | info.queue_family = vk.family; | 275 | info.queue_family = vk.family; |
| 261 | if (FAILED(rt::d3d12::create_vulkan_device(info, IID_PPV_ARGS(&ours.p)))) return 1; | 276 | if (FAILED(rt::d3d12::create_vulkan_device(info, IID_PPV_ARGS(&ours.p)))) return 1; |
| 277 | if (!check_copy_timestamp_capability(ours.p, vk.families[vk.family].timestampValidBits != 0, | ||
| 278 | "graphics queue fallback")) return 1; | ||
| 262 | mine = all_cases(ours.p); | 279 | mine = all_cases(ours.p); |
| 263 | { // A timestamp heap of the wrong kind for the list: the host refuses it at Close (E_INVALIDARG); the layer | 280 | { // A timestamp heap of the wrong kind for the list: the host refuses it at Close (E_INVALIDARG); the layer |
| 264 | // checks heap types at execution, so it must refuse the list there. | 281 | // checks heap types at execution, so it must refuse the list there. |
| @@ -283,6 +300,42 @@ int main() { | |||
| 283 | } | 300 | } |
| 284 | } | 301 | } |
| 285 | } | 302 | } |
| 303 | if (vk.copy_family != vk.family) { | ||
| 304 | Ref<ID3D12Device> ours; | ||
| 305 | rt::d3d12::VulkanDeviceInfo info{}; | ||
| 306 | info.get_instance_proc = vk.instance_proc; | ||
| 307 | info.instance = vk.instance; | ||
| 308 | info.physical = vk.physical; | ||
| 309 | info.device = vk.device; | ||
| 310 | info.queue = vk.queue; | ||
| 311 | info.queue_family = vk.family; | ||
| 312 | info.command_queues = vk.queues; | ||
| 313 | info.copy_family = vk.copy_family; | ||
| 314 | info.copy_queues = {vk.copy_queue}; | ||
| 315 | const auto& family = vk.families[vk.copy_family]; | ||
| 316 | const bool dedicated_can_resolve = family.timestampValidBits && | ||
| 317 | (family.queueFlags & (VK_QUEUE_GRAPHICS_BIT | VK_QUEUE_COMPUTE_BIT)); | ||
| 318 | const bool expected = vk.families[vk.family].timestampValidBits && dedicated_can_resolve; | ||
| 319 | if (FAILED(rt::d3d12::create_vulkan_device(info, IID_PPV_ARGS(&ours.p))) || | ||
| 320 | !check_copy_timestamp_capability(ours.p, expected, "dedicated copy queue")) return 1; | ||
| 321 | if (expected) { | ||
| 322 | Env e{ours.p}; | ||
| 323 | if (!setup(e) || timestamp_runs(e).find("timestamps on copy: plausible\n") == std::string::npos) { | ||
| 324 | std::fprintf(stderr, "dedicated copy queue: advertised timestamps failed to resolve\n"); | ||
| 325 | return 1; | ||
| 326 | } | ||
| 327 | } else if (!dedicated_can_resolve) { | ||
| 328 | Ref<ID3D12CommandQueue> copy_queue; | ||
| 329 | const D3D12_COMMAND_QUEUE_DESC desc{D3D12_COMMAND_LIST_TYPE_COPY}; | ||
| 330 | UINT64 frequency = 0; | ||
| 331 | if (FAILED(ours->CreateCommandQueue(&desc, IID_PPV_ARGS(©_queue.p))) || | ||
| 332 | copy_queue->GetTimestampFrequency(&frequency) != E_FAIL) { | ||
| 333 | std::fprintf(stderr, "dedicated copy queue: timestamp frequency should be unavailable\n"); | ||
| 334 | return 1; | ||
| 335 | } | ||
| 336 | } | ||
| 337 | std::printf("dedicated copy queue: timestamp queries %s\n", expected ? "resolved" : "refused as expected"); | ||
| 338 | } | ||
| 286 | Ref<IDXGIFactory4> factory; | 339 | Ref<IDXGIFactory4> factory; |
| 287 | if (FAILED(CreateDXGIFactory1(IID_PPV_ARGS(&factory.p)))) return 1; | 340 | if (FAILED(CreateDXGIFactory1(IID_PPV_ARGS(&factory.p)))) return 1; |
| 288 | unsigned differ = 0; | 341 | unsigned differ = 0; |