dzn: port to d3d12 c-api

Using the vulkan-helpers from C++ code has turned out to have a lot of
friction, because no other driver uses C++ for this.

So let's bite the bullet and call the D3D12 C-API instead. The C-API
wasn't really around when we started out, but it's there now.

This is still far from ideal; we should really create some wrapping
macros to generate the extremely verbose COM calls.

Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15816>
This commit is contained in:
Erik Faye-Lund 2022-03-25 17:08:50 +01:00 committed by Marge Bot
parent 4753222e62
commit 4903a7c051
11 changed files with 477 additions and 390 deletions

File diff suppressed because it is too large Load Diff

View File

@ -467,7 +467,7 @@ dzn_pipeline_layout_destroy(dzn_pipeline_layout *layout)
dzn_device *device = container_of(layout->base.device, dzn_device, vk);
if (layout->root.sig)
layout->root.sig->Release();
ID3D12RootSignature_Release(layout->root.sig);
vk_free(&device->vk.alloc, layout);
}
@ -760,10 +760,10 @@ static void
dzn_descriptor_heap_finish(dzn_descriptor_heap *heap)
{
if (heap->heap)
heap->heap->Release();
ID3D12DescriptorHeap_Release(heap->heap);
if (heap->dev)
heap->dev->Release();
ID3D12Device_Release(heap->dev);
}
static VkResult
@ -776,8 +776,8 @@ dzn_descriptor_heap_init(dzn_descriptor_heap *heap,
heap->desc_count = desc_count;
heap->type = type;
heap->dev = device->dev;
heap->dev->AddRef();
heap->desc_sz = device->dev->GetDescriptorHandleIncrementSize(type);
ID3D12Device1_AddRef(heap->dev);
heap->desc_sz = ID3D12Device1_GetDescriptorHandleIncrementSize(device->dev, type);
D3D12_DESCRIPTOR_HEAP_DESC desc = {
.Type = type,
@ -787,16 +787,22 @@ dzn_descriptor_heap_init(dzn_descriptor_heap *heap,
D3D12_DESCRIPTOR_HEAP_FLAG_NONE,
};
if (FAILED(device->dev->CreateDescriptorHeap(&desc,
IID_PPV_ARGS(&heap->heap)))) {
if (FAILED(ID3D12Device1_CreateDescriptorHeap(device->dev, &desc,
IID_ID3D12DescriptorHeap,
(void **)&heap->heap))) {
return vk_error(device,
shader_visible ?
VK_ERROR_OUT_OF_DEVICE_MEMORY : VK_ERROR_OUT_OF_HOST_MEMORY);
}
heap->cpu_base = heap->heap->GetCPUDescriptorHandleForHeapStart().ptr;
if (shader_visible)
heap->gpu_base = heap->heap->GetGPUDescriptorHandleForHeapStart().ptr;
D3D12_CPU_DESCRIPTOR_HANDLE cpu_handle;
ID3D12DescriptorHeap_GetCPUDescriptorHandleForHeapStart(heap->heap, &cpu_handle);
heap->cpu_base = cpu_handle.ptr;
if (shader_visible) {
D3D12_GPU_DESCRIPTOR_HANDLE gpu_handle;
ID3D12DescriptorHeap_GetGPUDescriptorHandleForHeapStart(heap->heap, &gpu_handle);
heap->gpu_base = gpu_handle.ptr;
}
return VK_SUCCESS;
}
@ -822,8 +828,8 @@ dzn_descriptor_heap_write_sampler_desc(dzn_descriptor_heap *heap,
uint32_t desc_offset,
const dzn_sampler *sampler)
{
heap->dev->CreateSampler(&sampler->desc,
dzn_descriptor_heap_get_cpu_handle(heap, desc_offset));
ID3D12Device1_CreateSampler(heap->dev, &sampler->desc,
dzn_descriptor_heap_get_cpu_handle(heap, desc_offset));
}
void
@ -837,7 +843,7 @@ dzn_descriptor_heap_write_image_view_desc(dzn_descriptor_heap *heap,
dzn_image *image = container_of(iview->vk.image, dzn_image, vk);
if (writeable) {
heap->dev->CreateUnorderedAccessView(image->res, NULL, &iview->uav_desc, view_handle);
ID3D12Device1_CreateUnorderedAccessView(heap->dev, image->res, NULL, &iview->uav_desc, view_handle);
} else if (cube_as_2darray &&
(iview->srv_desc.ViewDimension == D3D12_SRV_DIMENSION_TEXTURECUBEARRAY ||
iview->srv_desc.ViewDimension == D3D12_SRV_DIMENSION_TEXTURECUBE)) {
@ -862,9 +868,9 @@ dzn_descriptor_heap_write_image_view_desc(dzn_descriptor_heap *heap,
srv_desc.Texture2DArray.ArraySize = 6;
}
heap->dev->CreateShaderResourceView(image->res, &srv_desc, view_handle);
ID3D12Device1_CreateShaderResourceView(heap->dev, image->res, &srv_desc, view_handle);
} else {
heap->dev->CreateShaderResourceView(image->res, &iview->srv_desc, view_handle);
ID3D12Device1_CreateShaderResourceView(heap->dev, image->res, &iview->srv_desc, view_handle);
}
}
@ -878,9 +884,9 @@ dzn_descriptor_heap_write_buffer_view_desc(dzn_descriptor_heap *heap,
dzn_descriptor_heap_get_cpu_handle(heap, desc_offset);
if (writeable)
heap->dev->CreateUnorderedAccessView(bview->buffer->res, NULL, &bview->uav_desc, view_handle);
ID3D12Device1_CreateUnorderedAccessView(heap->dev, bview->buffer->res, NULL, &bview->uav_desc, view_handle);
else
heap->dev->CreateShaderResourceView(bview->buffer->res, &bview->srv_desc, view_handle);
ID3D12Device1_CreateShaderResourceView(heap->dev, bview->buffer->res, &bview->srv_desc, view_handle);
}
void
@ -901,10 +907,10 @@ dzn_descriptor_heap_write_buffer_desc(dzn_descriptor_heap *heap,
info->type == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) {
assert(!writeable);
D3D12_CONSTANT_BUFFER_VIEW_DESC cbv_desc = {
.BufferLocation = info->buffer->res->GetGPUVirtualAddress() + info->offset,
.BufferLocation = ID3D12Resource_GetGPUVirtualAddress(info->buffer->res) + info->offset,
.SizeInBytes = ALIGN_POT(size, 256),
};
heap->dev->CreateConstantBufferView(&cbv_desc, view_handle);
ID3D12Device1_CreateConstantBufferView(heap->dev, &cbv_desc, view_handle);
} else if (writeable) {
D3D12_UNORDERED_ACCESS_VIEW_DESC uav_desc = {
.Format = DXGI_FORMAT_R32_TYPELESS,
@ -915,7 +921,7 @@ dzn_descriptor_heap_write_buffer_desc(dzn_descriptor_heap *heap,
.Flags = D3D12_BUFFER_UAV_FLAG_RAW,
},
};
heap->dev->CreateUnorderedAccessView(info->buffer->res, NULL, &uav_desc, view_handle);
ID3D12Device1_CreateUnorderedAccessView(heap->dev, info->buffer->res, NULL, &uav_desc, view_handle);
} else {
D3D12_SHADER_RESOURCE_VIEW_DESC srv_desc = {
.Format = DXGI_FORMAT_R32_TYPELESS,
@ -927,7 +933,7 @@ dzn_descriptor_heap_write_buffer_desc(dzn_descriptor_heap *heap,
.Flags = D3D12_BUFFER_SRV_FLAG_RAW,
},
};
heap->dev->CreateShaderResourceView(info->buffer->res, &srv_desc, view_handle);
ID3D12Device1_CreateShaderResourceView(heap->dev, info->buffer->res, &srv_desc, view_handle);
}
}
@ -943,10 +949,10 @@ dzn_descriptor_heap_copy(dzn_descriptor_heap *dst_heap,
D3D12_CPU_DESCRIPTOR_HANDLE src_handle =
dzn_descriptor_heap_get_cpu_handle(src_heap, src_offset);
dst_heap->dev->CopyDescriptorsSimple(desc_count,
dst_handle,
src_handle,
dst_heap->type);
ID3D12Device1_CopyDescriptorsSimple(dst_heap->dev, desc_count,
dst_handle,
src_handle,
dst_heap->type);
}
struct dzn_descriptor_set_ptr {
@ -1423,7 +1429,7 @@ dzn_descriptor_heap_pool_init(dzn_descriptor_heap_pool *pool,
list_inithead(&pool->active_heaps);
list_inithead(&pool->free_heaps);
pool->offset = 0;
pool->desc_sz = device->dev->GetDescriptorHandleIncrementSize(type);
pool->desc_sz = ID3D12Device1_GetDescriptorHandleIncrementSize(device->dev, type);
}
VkResult

View File

@ -43,7 +43,10 @@
#include <stdlib.h>
#include <windows.h>
#define CINTERFACE
#include <directx/d3d12sdklayers.h>
#undef CINTERFACE
#if defined(VK_USE_PLATFORM_WIN32_KHR) || \
defined(VK_USE_PLATFORM_DISPLAY_KHR)
@ -113,10 +116,10 @@ dzn_physical_device_destroy(dzn_physical_device *pdev)
list_del(&pdev->link);
if (pdev->dev)
pdev->dev->Release();
ID3D12Device1_Release(pdev->dev);
if (pdev->adapter)
pdev->adapter->Release();
IDXGIAdapter1_Release(pdev->adapter);
dzn_wsi_finish(pdev);
vk_physical_device_finish(&pdev->vk);
@ -236,7 +239,7 @@ dzn_physical_device_create(dzn_instance *instance,
mtx_init(&pdev->dev_lock, mtx_plain);
pdev->adapter_desc = *adapter_desc;
pdev->adapter = adapter;
adapter->AddRef();
IDXGIAdapter1_AddRef(adapter);
list_addtail(&pdev->link, &instance->physical_devices);
vk_warn_non_conformant_implementation("dzn");
@ -282,11 +285,11 @@ dzn_physical_device_cache_caps(dzn_physical_device *pdev)
.pFeatureLevelsRequested = checklist,
};
pdev->dev->CheckFeatureSupport(D3D12_FEATURE_FEATURE_LEVELS, &levels, sizeof(levels));
ID3D12Device1_CheckFeatureSupport(pdev->dev, D3D12_FEATURE_FEATURE_LEVELS, &levels, sizeof(levels));
pdev->feature_level = levels.MaxSupportedFeatureLevel;
pdev->dev->CheckFeatureSupport(D3D12_FEATURE_ARCHITECTURE1, &pdev->architecture, sizeof(pdev->architecture));
pdev->dev->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS, &pdev->options, sizeof(pdev->options));
ID3D12Device1_CheckFeatureSupport(pdev->dev, D3D12_FEATURE_ARCHITECTURE1, &pdev->architecture, sizeof(pdev->architecture));
ID3D12Device1_CheckFeatureSupport(pdev->dev, D3D12_FEATURE_D3D12_OPTIONS, &pdev->options, sizeof(pdev->options));
pdev->queue_families[pdev->queue_family_count++] = {
.props = {
@ -337,13 +340,14 @@ dzn_physical_device_cache_caps(dzn_physical_device *pdev)
};
ID3D12CommandQueue *cmdqueue;
pdev->dev->CreateCommandQueue(&queue_desc,
IID_PPV_ARGS(&cmdqueue));
ID3D12Device1_CreateCommandQueue(pdev->dev, &queue_desc,
IID_ID3D12CommandQueue,
(void **)&cmdqueue);
uint64_t ts_freq;
cmdqueue->GetTimestampFrequency(&ts_freq);
ID3D12CommandQueue_GetTimestampFrequency(cmdqueue, &ts_freq);
pdev->timestamp_period = 1000000000.0f / ts_freq;
cmdqueue->Release();
ID3D12CommandQueue_Release(cmdqueue);
}
static void
@ -502,8 +506,8 @@ dzn_physical_device_get_format_support(dzn_physical_device *pdev,
ID3D12Device1 *dev = dzn_physical_device_get_d3d12_dev(pdev);
HRESULT hres =
dev->CheckFeatureSupport(D3D12_FEATURE_FORMAT_SUPPORT,
&dfmt_info, sizeof(dfmt_info));
ID3D12Device1_CheckFeatureSupport(dev, D3D12_FEATURE_FORMAT_SUPPORT,
&dfmt_info, sizeof(dfmt_info));
assert(!FAILED(hres));
if (usage != VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT)
@ -517,7 +521,7 @@ dzn_physical_device_get_format_support(dzn_physical_device *pdev,
.Format = dzn_image_get_dxgi_format(format, 0, aspect),
};
hres = dev->CheckFeatureSupport(D3D12_FEATURE_FORMAT_SUPPORT,
hres = ID3D12Device1_CheckFeatureSupport(dev, D3D12_FEATURE_FORMAT_SUPPORT,
&dfmt_info2, sizeof(dfmt_info2));
assert(!FAILED(hres));
@ -800,7 +804,7 @@ dzn_physical_device_get_image_format_properties(dzn_physical_device *pdev,
};
HRESULT hres =
dev->CheckFeatureSupport(D3D12_FEATURE_MULTISAMPLE_QUALITY_LEVELS,
ID3D12Device1_CheckFeatureSupport(dev, D3D12_FEATURE_MULTISAMPLE_QUALITY_LEVELS,
&ms_info, sizeof(ms_info));
if (!FAILED(hres) && ms_info.NumQualityLevels > 0)
properties->imageFormatProperties.sampleCounts |= s;
@ -903,12 +907,12 @@ dzn_EnumeratePhysicalDevices(VkInstance inst,
if (!instance->physical_devices_enumerated) {
IDXGIFactory4 *factory = dxgi_get_factory(false);
IDXGIAdapter1 *adapter = NULL;
for (UINT i = 0; SUCCEEDED(factory->EnumAdapters1(i, &adapter)); ++i) {
for (UINT i = 0; SUCCEEDED(IDXGIFactory4_EnumAdapters1(factory, i, &adapter)); ++i) {
DXGI_ADAPTER_DESC1 desc;
adapter->GetDesc1(&desc);
IDXGIAdapter1_GetDesc1(adapter, &desc);
if (instance->debug_flags & DZN_DEBUG_WARP) {
if ((desc.Flags & DXGI_ADAPTER_FLAG_SOFTWARE) == 0) {
adapter->Release();
IDXGIAdapter1_Release(adapter);
continue;
}
}
@ -916,13 +920,13 @@ dzn_EnumeratePhysicalDevices(VkInstance inst,
VkResult result =
dzn_physical_device_create(instance, adapter, &desc);
adapter->Release();
IDXGIAdapter1_Release(adapter);
if (result != VK_SUCCESS) {
factory->Release();
IDXGIFactory4_Release(factory);
return result;
}
}
factory->Release();
IDXGIFactory4_Release(factory);
}
VK_OUTARRAY_MAKE_TYPED(VkPhysicalDevice, out, pPhysicalDevices,
@ -1398,7 +1402,7 @@ dzn_queue_sync_wait(dzn_queue *queue, const struct vk_sync_wait *wait)
assert(sync->fence != NULL);
if (value > 0 && FAILED(queue->cmdqueue->Wait(sync->fence, value)))
if (value > 0 && FAILED(ID3D12CommandQueue_Wait(queue->cmdqueue, sync->fence, value)))
return vk_error(device, VK_ERROR_UNKNOWN);
return VK_SUCCESS;
@ -1419,7 +1423,7 @@ dzn_queue_sync_signal(dzn_queue *queue, const struct vk_sync_signal *signal)
assert(sync->fence != NULL);
if (FAILED(queue->cmdqueue->Signal(sync->fence, value)))
if (FAILED(ID3D12CommandQueue_Signal(queue->cmdqueue, sync->fence, value)))
return vk_error(device, VK_ERROR_UNKNOWN);
return VK_SUCCESS;
@ -1443,10 +1447,10 @@ dzn_queue_submit(struct vk_queue *q,
dzn_cmd_buffer *cmd_buffer =
container_of(info->command_buffers[i], dzn_cmd_buffer, vk);
ID3D12CommandList *cmdlists[] = { cmd_buffer->cmdlist };
ID3D12CommandList *cmdlists[] = { (ID3D12CommandList *)cmd_buffer->cmdlist };
util_dynarray_foreach(&cmd_buffer->events.wait, dzn_event *, evt) {
if (FAILED(queue->cmdqueue->Wait((*evt)->fence, 1)))
if (FAILED(ID3D12CommandQueue_Wait(queue->cmdqueue, (*evt)->fence, 1)))
return vk_error(device, VK_ERROR_UNKNOWN);
}
@ -1456,7 +1460,7 @@ dzn_queue_submit(struct vk_queue *q,
struct dzn_query *query = &range->qpool->queries[q];
if (query->fence &&
FAILED(queue->cmdqueue->Wait(query->fence, query->fence_value)))
FAILED(ID3D12CommandQueue_Wait(queue->cmdqueue, query->fence, query->fence_value)))
return vk_error(device, VK_ERROR_UNKNOWN);
}
mtx_unlock(&range->qpool->queries_lock);
@ -1467,7 +1471,7 @@ dzn_queue_submit(struct vk_queue *q,
for (uint32_t q = range->start; q < range->start + range->count; q++) {
struct dzn_query *query = &range->qpool->queries[q];
if (query->fence) {
query->fence->Release();
ID3D12Fence_Release(query->fence);
query->fence = NULL;
}
query->fence_value = 0;
@ -1475,10 +1479,10 @@ dzn_queue_submit(struct vk_queue *q,
mtx_unlock(&range->qpool->queries_lock);
}
queue->cmdqueue->ExecuteCommandLists(1, cmdlists);
ID3D12CommandQueue_ExecuteCommandLists(queue->cmdqueue, 1, cmdlists);
util_dynarray_foreach(&cmd_buffer->events.signal, dzn_cmd_event_signal, evt) {
if (FAILED(queue->cmdqueue->Signal(evt->event->fence, evt->value ? 1 : 0)))
if (FAILED(ID3D12CommandQueue_Signal(queue->cmdqueue, evt->event->fence, evt->value ? 1 : 0)))
return vk_error(device, VK_ERROR_UNKNOWN);
}
@ -1488,7 +1492,7 @@ dzn_queue_submit(struct vk_queue *q,
struct dzn_query *query = &range->qpool->queries[q];
query->fence_value = queue->fence_point + 1;
query->fence = queue->fence;
query->fence->AddRef();
ID3D12Fence_AddRef(query->fence);
}
mtx_unlock(&range->qpool->queries_lock);
}
@ -1500,7 +1504,7 @@ dzn_queue_submit(struct vk_queue *q,
return vk_error(device, VK_ERROR_UNKNOWN);
}
if (FAILED(queue->cmdqueue->Signal(queue->fence, ++queue->fence_point)))
if (FAILED(ID3D12CommandQueue_Signal(queue->cmdqueue, queue->fence, ++queue->fence_point)))
return vk_error(device, VK_ERROR_UNKNOWN);
return VK_SUCCESS;
@ -1510,10 +1514,10 @@ static void
dzn_queue_finish(dzn_queue *queue)
{
if (queue->cmdqueue)
queue->cmdqueue->Release();
ID3D12CommandQueue_Release(queue->cmdqueue);
if (queue->fence)
queue->fence->Release();
ID3D12Fence_Release(queue->fence);
vk_queue_finish(&queue->vk);
}
@ -1541,14 +1545,16 @@ dzn_queue_init(dzn_queue *queue,
(INT)(pCreateInfo->pQueuePriorities[index_in_family] * (float)D3D12_COMMAND_QUEUE_PRIORITY_HIGH);
queue_desc.NodeMask = 0;
if (FAILED(device->dev->CreateCommandQueue(&queue_desc,
IID_PPV_ARGS(&queue->cmdqueue)))) {
if (FAILED(ID3D12Device1_CreateCommandQueue(device->dev, &queue_desc,
IID_ID3D12CommandQueue,
(void **)&queue->cmdqueue))) {
dzn_queue_finish(queue);
return vk_error(device->vk.physical->instance, VK_ERROR_INITIALIZATION_FAILED);
}
if (FAILED(device->dev->CreateFence(0, D3D12_FENCE_FLAG_NONE,
IID_PPV_ARGS(&queue->fence)))) {
if (FAILED(ID3D12Device1_CreateFence(device->dev, 0, D3D12_FENCE_FLAG_NONE,
IID_ID3D12Fence,
(void **)&queue->fence))) {
dzn_queue_finish(queue);
return vk_error(device->vk.physical->instance, VK_ERROR_INITIALIZATION_FAILED);
}
@ -1607,8 +1613,8 @@ static VkResult
dzn_device_query_init(dzn_device *device)
{
/* FIXME: create the resource in the default heap */
D3D12_HEAP_PROPERTIES hprops =
device->dev->GetCustomHeapProperties(0, D3D12_HEAP_TYPE_UPLOAD);
D3D12_HEAP_PROPERTIES hprops;
ID3D12Device1_GetCustomHeapProperties(device->dev, &hprops, 0, D3D12_HEAP_TYPE_UPLOAD);
D3D12_RESOURCE_DESC rdesc = {
.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER,
.Alignment = D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT,
@ -1622,21 +1628,22 @@ dzn_device_query_init(dzn_device *device)
.Flags = D3D12_RESOURCE_FLAG_NONE,
};
if (FAILED(device->dev->CreateCommittedResource(&hprops,
if (FAILED(ID3D12Device1_CreateCommittedResource(device->dev, &hprops,
D3D12_HEAP_FLAG_NONE,
&rdesc,
D3D12_RESOURCE_STATE_GENERIC_READ,
NULL,
IID_PPV_ARGS(&device->queries.refs))))
IID_ID3D12Resource,
(void **)&device->queries.refs)))
return vk_error(device->vk.physical, VK_ERROR_OUT_OF_DEVICE_MEMORY);
uint8_t *queries_ref;
if (FAILED(device->queries.refs->Map(0, NULL, (void **)&queries_ref)))
if (FAILED(ID3D12Resource_Map(device->queries.refs, 0, NULL, (void **)&queries_ref)))
return vk_error(device->vk.physical, VK_ERROR_OUT_OF_HOST_MEMORY);
memset(queries_ref + DZN_QUERY_REFS_ALL_ONES_OFFSET, 0xff, DZN_QUERY_REFS_SECTION_SIZE);
memset(queries_ref + DZN_QUERY_REFS_ALL_ZEROS_OFFSET, 0x0, DZN_QUERY_REFS_SECTION_SIZE);
device->queries.refs->Unmap(0, NULL);
ID3D12Resource_Unmap(device->queries.refs, 0, NULL);
return VK_SUCCESS;
}
@ -1645,7 +1652,7 @@ static void
dzn_device_query_finish(dzn_device *device)
{
if (device->queries.refs)
device->queries.refs->Release();
ID3D12Resource_Release(device->queries.refs);
}
static void
@ -1667,7 +1674,7 @@ dzn_device_destroy(dzn_device *device, const VkAllocationCallbacks *pAllocator)
dzn_meta_finish(device);
if (device->dev)
device->dev->Release();
ID3D12Device1_Release(device->dev);
vk_device_finish(&device->vk);
vk_free2(&instance->vk.alloc, pAllocator, device);
@ -1736,10 +1743,11 @@ dzn_device_create(dzn_physical_device *pdev,
return vk_error(pdev, VK_ERROR_INITIALIZATION_FAILED);
}
device->dev->AddRef();
ID3D12Device1_AddRef(device->dev);
ID3D12InfoQueue *info_queue;
if (SUCCEEDED(device->dev->QueryInterface(IID_PPV_ARGS(&info_queue)))) {
if (SUCCEEDED(ID3D12Device1_QueryInterface(device->dev, IID_ID3D12InfoQueue,
(void **)&info_queue))) {
D3D12_MESSAGE_SEVERITY severities[] = {
D3D12_MESSAGE_SEVERITY_INFO,
D3D12_MESSAGE_SEVERITY_WARNING,
@ -1755,7 +1763,7 @@ dzn_device_create(dzn_physical_device *pdev,
NewFilter.DenyList.NumIDs = ARRAY_SIZE(msg_ids);
NewFilter.DenyList.pIDList = msg_ids;
info_queue->PushStorageFilter(&NewFilter);
ID3D12InfoQueue_PushStorageFilter(info_queue, &NewFilter);
}
result = dzn_meta_init(device);
@ -1800,7 +1808,7 @@ dzn_device_create_root_sig(dzn_device *device,
if (FAILED(instance->d3d12.serialize_root_sig(desc,
&sig, &error))) {
if (instance->debug_flags & DZN_DEBUG_SIG) {
const char* error_msg = (const char*)error->GetBufferPointer();
const char* error_msg = (const char*)ID3D10Blob_GetBufferPointer(error);
fprintf(stderr,
"== SERIALIZE ROOT SIG ERROR =============================================\n"
"%s\n"
@ -1808,20 +1816,21 @@ dzn_device_create_root_sig(dzn_device *device,
error_msg);
}
error->Release();
ID3D10Blob_Release(error);
return NULL;
}
ID3D12RootSignature *root_sig;
if (FAILED(device->dev->CreateRootSignature(0,
sig->GetBufferPointer(),
sig->GetBufferSize(),
IID_PPV_ARGS(&root_sig)))) {
sig->Release();
if (FAILED(ID3D12Device1_CreateRootSignature(device->dev, 0,
ID3D10Blob_GetBufferPointer(sig),
ID3D10Blob_GetBufferSize(sig),
IID_ID3D12RootSignature,
(void **)&root_sig))) {
ID3D10Blob_Release(sig);
return NULL;
}
sig->Release();
ID3D10Blob_Release(sig);
return root_sig;
}
@ -1879,13 +1888,13 @@ dzn_device_memory_destroy(dzn_device_memory *mem,
dzn_device *device = container_of(mem->base.device, dzn_device, vk);
if (mem->map)
mem->map_res->Unmap(0, NULL);
ID3D12Resource_Unmap(mem->map_res, 0, NULL);
if (mem->map_res)
mem->map_res->Release();
ID3D12Resource_Release(mem->map_res);
if (mem->heap)
mem->heap->Release();
ID3D12Heap_Release(mem->heap);
vk_object_base_finish(&mem->base);
vk_free2(&device->vk.alloc, pAllocator, mem);
@ -1951,7 +1960,9 @@ dzn_device_memory_create(dzn_device *device,
heap_desc.Properties.CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_NOT_AVAILABLE;
}
if (FAILED(device->dev->CreateHeap(&heap_desc, IID_PPV_ARGS(&mem->heap)))) {
if (FAILED(ID3D12Device1_CreateHeap(device->dev, &heap_desc,
IID_ID3D12Heap,
(void **)&mem->heap))) {
dzn_device_memory_destroy(mem, pAllocator);
return vk_error(device, VK_ERROR_OUT_OF_DEVICE_MEMORY);
}
@ -1970,9 +1981,11 @@ dzn_device_memory_create(dzn_device *device,
res_desc.SampleDesc.Quality = 0;
res_desc.Flags = D3D12_RESOURCE_FLAG_DENY_SHADER_RESOURCE;
res_desc.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR;
HRESULT hr = device->dev->CreatePlacedResource(mem->heap, 0, &res_desc,
mem->initial_state,
NULL, IID_PPV_ARGS(&mem->map_res));
HRESULT hr = ID3D12Device1_CreatePlacedResource(device->dev, mem->heap, 0, &res_desc,
mem->initial_state,
NULL,
IID_ID3D12Resource,
(void **)&mem->map_res);
if (FAILED(hr)) {
dzn_device_memory_destroy(mem, pAllocator);
return vk_error(device, VK_ERROR_OUT_OF_DEVICE_MEMORY);
@ -2035,7 +2048,7 @@ dzn_MapMemory(VkDevice _device,
range.Begin = offset;
range.End = offset + size;
void *map = NULL;
if (FAILED(mem->map_res->Map(0, &range, &map)))
if (FAILED(ID3D12Resource_Map(mem->map_res, 0, &range, &map)))
return vk_error(device, VK_ERROR_MEMORY_MAP_FAILED);
mem->map = map;
@ -2057,7 +2070,7 @@ dzn_UnmapMemory(VkDevice _device,
return;
assert(mem->map_res);
mem->map_res->Unmap(0, NULL);
ID3D12Resource_Unmap(mem->map_res, 0, NULL);
mem->map = NULL;
mem->map_size = 0;
@ -2088,7 +2101,7 @@ dzn_buffer_destroy(dzn_buffer *buf, const VkAllocationCallbacks *pAllocator)
dzn_device *device = container_of(buf->base.device, dzn_device, vk);
if (buf->res)
buf->res->Release();
ID3D12Resource_Release(buf->res);
vk_object_base_finish(&buf->base);
vk_free2(&device->vk.alloc, pAllocator, buf);
@ -2319,11 +2332,13 @@ dzn_BindBufferMemory2(VkDevice _device,
VK_FROM_HANDLE(dzn_device_memory, mem, pBindInfos[i].memory);
VK_FROM_HANDLE(dzn_buffer, buffer, pBindInfos[i].buffer);
if (FAILED(device->dev->CreatePlacedResource(mem->heap,
if (FAILED(ID3D12Device1_CreatePlacedResource(device->dev, mem->heap,
pBindInfos[i].memoryOffset,
&buffer->desc,
mem->initial_state,
NULL, IID_PPV_ARGS(&buffer->res))))
NULL,
IID_ID3D12Resource,
(void **)&buffer->res)))
return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
}
@ -2403,7 +2418,7 @@ dzn_event_destroy(dzn_event *event,
container_of(event->base.device, dzn_device, vk);
if (event->fence)
event->fence->Release();
ID3D12Fence_Release(event->fence);
vk_object_base_finish(&event->base);
vk_free2(&device->vk.alloc, pAllocator, event);
@ -2423,8 +2438,9 @@ dzn_event_create(dzn_device *device,
vk_object_base_init(&device->vk, &event->base, VK_OBJECT_TYPE_EVENT);
if (FAILED(device->dev->CreateFence(0, D3D12_FENCE_FLAG_NONE,
IID_PPV_ARGS(&event->fence)))) {
if (FAILED(ID3D12Device1_CreateFence(device->dev, 0, D3D12_FENCE_FLAG_NONE,
IID_ID3D12Fence,
(void **)&event->fence))) {
dzn_event_destroy(event, pAllocator);
return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
}
@ -2458,7 +2474,7 @@ dzn_ResetEvent(VkDevice dev,
VK_FROM_HANDLE(dzn_device, device, dev);
VK_FROM_HANDLE(dzn_event, event, evt);
if (FAILED(event->fence->Signal(0)))
if (FAILED(ID3D12Fence_Signal(event->fence, 0)))
return vk_error(device, VK_ERROR_OUT_OF_DEVICE_MEMORY);
return VK_SUCCESS;
@ -2471,7 +2487,7 @@ dzn_SetEvent(VkDevice dev,
VK_FROM_HANDLE(dzn_device, device, dev);
VK_FROM_HANDLE(dzn_event, event, evt);
if (FAILED(event->fence->Signal(1)))
if (FAILED(ID3D12Fence_Signal(event->fence, 1)))
return vk_error(device, VK_ERROR_OUT_OF_DEVICE_MEMORY);
return VK_SUCCESS;
@ -2483,7 +2499,7 @@ dzn_GetEventStatus(VkDevice device,
{
VK_FROM_HANDLE(dzn_event, event, evt);
return event->fence->GetCompletedValue() == 0 ?
return ID3D12Fence_GetCompletedValue(event->fence) == 0 ?
VK_EVENT_RESET : VK_EVENT_SET;
}

View File

@ -38,7 +38,7 @@ dzn_image_destroy(dzn_image *image,
dzn_device *device = container_of(image->vk.base.device, dzn_device, vk);
if (image->res)
image->res->Release();
ID3D12Resource_Release(image->res);
vk_image_finish(&image->vk);
vk_free2(&device->vk.alloc, pAllocator, image);
@ -126,7 +126,7 @@ dzn_image_create(dzn_device *device,
};
D3D12_PLACED_SUBRESOURCE_FOOTPRINT footprint;
uint64_t size = 0;
device->dev->GetCopyableFootprints(&tmp_desc, 0, 1, 0, &footprint, NULL, NULL, &size);
ID3D12Device1_GetCopyableFootprints(device->dev, &tmp_desc, 0, 1, 0, &footprint, NULL, NULL, &size);
image->linear.row_stride = footprint.Footprint.RowPitch;
image->linear.size = size;
@ -630,11 +630,13 @@ dzn_BindImageMemory2(VkDevice dev,
if (!did_bind) {
image->mem = mem;
image->mem_offset = bind_info->memoryOffset;
if (FAILED(device->dev->CreatePlacedResource(mem->heap,
if (FAILED(ID3D12Device1_CreatePlacedResource(device->dev, mem->heap,
bind_info->memoryOffset,
&image->desc,
mem->initial_state,
NULL, IID_PPV_ARGS(&image->res))))
NULL,
IID_ID3D12Resource,
(void **)&image->res)))
return vk_error(device, VK_ERROR_OUT_OF_DEVICE_MEMORY);
did_bind = true;
}
@ -674,7 +676,8 @@ dzn_GetImageMemoryRequirements2(VkDevice _device,
}
}
D3D12_RESOURCE_ALLOCATION_INFO info = device->dev->GetResourceAllocationInfo(0, 1, &image->desc);
D3D12_RESOURCE_ALLOCATION_INFO info;
ID3D12Device1_GetResourceAllocationInfo(device->dev, &info, 0, 1, &image->desc);
pMemoryRequirements->memoryRequirements = VkMemoryRequirements {
.size = info.SizeInBytes,
@ -720,7 +723,7 @@ dzn_GetImageSubresourceLayout(VkDevice _device,
D3D12_PLACED_SUBRESOURCE_FOOTPRINT footprint;
UINT num_rows;
UINT64 row_size, total_size;
device->dev->GetCopyableFootprints(&image->desc,
ID3D12Device1_GetCopyableFootprints(device->dev, &image->desc,
subres_index, 1,
0, // base-offset?
&footprint,

View File

@ -95,10 +95,10 @@ dzn_meta_indirect_draw_finish(dzn_device *device, enum dzn_indirect_draw_type ty
dzn_meta_indirect_draw *meta = &device->indirect_draws[type];
if (meta->root_sig)
meta->root_sig->Release();
ID3D12RootSignature_Release(meta->root_sig);
if (meta->pipeline_state)
meta->pipeline_state->Release();
ID3D12PipelineState_Release(meta->pipeline_state);
}
static VkResult
@ -192,8 +192,9 @@ dzn_meta_indirect_draw_init(dzn_device *device,
dzn_meta_compile_shader(device, nir, &desc.CS);
assert(desc.CS.pShaderBytecode);
if (FAILED(device->dev->CreateComputePipelineState(&desc,
IID_PPV_ARGS(&meta->pipeline_state))))
if (FAILED(ID3D12Device1_CreateComputePipelineState(device->dev, &desc,
IID_ID3D12PipelineState,
(void **)&meta->pipeline_state)))
ret = vk_error(instance, VK_ERROR_INITIALIZATION_FAILED);
out:
@ -217,11 +218,11 @@ dzn_meta_triangle_fan_rewrite_index_finish(dzn_device *device,
&device->triangle_fan[old_index_type];
if (meta->root_sig)
meta->root_sig->Release();
ID3D12RootSignature_Release(meta->root_sig);
if (meta->pipeline_state)
meta->pipeline_state->Release();
ID3D12PipelineState_Release(meta->pipeline_state);
if (meta->cmd_sig)
meta->cmd_sig->Release();
ID3D12CommandSignature_Release(meta->cmd_sig);
}
static VkResult
@ -328,15 +329,17 @@ dzn_meta_triangle_fan_rewrite_index_init(dzn_device *device,
desc.pRootSignature = meta->root_sig;
dzn_meta_compile_shader(device, nir, &desc.CS);
if (FAILED(device->dev->CreateComputePipelineState(&desc,
IID_PPV_ARGS(&meta->pipeline_state)))) {
if (FAILED(ID3D12Device1_CreateComputePipelineState(device->dev, &desc,
IID_ID3D12PipelineState,
(void **)&meta->pipeline_state))) {
ret = vk_error(instance, VK_ERROR_INITIALIZATION_FAILED);
goto out;
}
if (FAILED(device->dev->CreateCommandSignature(&cmd_sig_desc,
meta->root_sig,
IID_PPV_ARGS(&meta->cmd_sig))))
if (FAILED(ID3D12Device1_CreateCommandSignature(device->dev, &cmd_sig_desc,
meta->root_sig,
IID_ID3D12CommandSignature,
(void **)&meta->cmd_sig)))
ret = vk_error(instance, VK_ERROR_INITIALIZATION_FAILED);
out:
@ -451,9 +454,9 @@ dzn_meta_blit_destroy(dzn_device *device, dzn_meta_blit *blit)
return;
if (blit->root_sig)
blit->root_sig->Release();
ID3D12RootSignature_Release(blit->root_sig);
if (blit->pipeline_state)
blit->pipeline_state->Release();
ID3D12PipelineState_Release(blit->pipeline_state);
vk_free(&device->vk.alloc, blit);
}
@ -608,8 +611,9 @@ dzn_meta_blit_create(dzn_device *device, const dzn_meta_blit_key *key)
}
}
if (FAILED(device->dev->CreateGraphicsPipelineState(&desc,
IID_PPV_ARGS(&blit->pipeline_state)))) {
if (FAILED(ID3D12Device1_CreateGraphicsPipelineState(device->dev, &desc,
IID_ID3D12PipelineState,
(void **)&blit->pipeline_state))) {
dzn_meta_blit_destroy(device, blit);
return NULL;
}

View File

@ -25,7 +25,10 @@
#define DZN_NIR_H
#define D3D12_IGNORE_SDK_LAYERS
#define CINTERFACE
#define COBJMACROS
#include <directx/d3d12.h>
#undef CINTERFACE
#include "nir.h"

View File

@ -716,7 +716,7 @@ dzn_pipeline_init(dzn_pipeline *pipeline,
STATIC_ASSERT(sizeof(pipeline->root.type) == sizeof(layout->root.type));
memcpy(pipeline->root.type, layout->root.type, sizeof(pipeline->root.type));
pipeline->root.sig = layout->root.sig;
pipeline->root.sig->AddRef();
ID3D12RootSignature_AddRef(pipeline->root.sig);
STATIC_ASSERT(sizeof(layout->desc_count) == sizeof(pipeline->desc_count));
memcpy(pipeline->desc_count, layout->desc_count, sizeof(pipeline->desc_count));
@ -730,9 +730,9 @@ static void
dzn_pipeline_finish(dzn_pipeline *pipeline)
{
if (pipeline->state)
pipeline->state->Release();
ID3D12PipelineState_Release(pipeline->state);
if (pipeline->root.sig)
pipeline->root.sig->Release();
ID3D12RootSignature_Release(pipeline->root.sig);
vk_object_base_finish(&pipeline->base);
}
@ -746,7 +746,7 @@ dzn_graphics_pipeline_destroy(dzn_graphics_pipeline *pipeline,
for (uint32_t i = 0; i < ARRAY_SIZE(pipeline->indirect_cmd_sigs); i++) {
if (pipeline->indirect_cmd_sigs[i])
pipeline->indirect_cmd_sigs[i]->Release();
ID3D12CommandSignature_Release(pipeline->indirect_cmd_sigs[i]);
}
dzn_pipeline_finish(&pipeline->base);
@ -904,8 +904,9 @@ dzn_graphics_pipeline_create(dzn_device *device,
}
hres = device->dev->CreateGraphicsPipelineState(&desc,
IID_PPV_ARGS(&pipeline->base.state));
hres = ID3D12Device1_CreateGraphicsPipelineState(device->dev, &desc,
IID_ID3D12PipelineState,
(void **)&pipeline->base.state);
if (FAILED(hres)) {
ret = vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
goto out;
@ -983,9 +984,10 @@ dzn_graphics_pipeline_get_indirect_cmd_sig(dzn_graphics_pipeline *pipeline,
.pArgumentDescs = cmd_args,
};
HRESULT hres =
device->dev->CreateCommandSignature(&cmd_sig_desc,
pipeline->base.root.sig,
IID_PPV_ARGS(&cmdsig));
ID3D12Device1_CreateCommandSignature(device->dev, &cmd_sig_desc,
pipeline->base.root.sig,
IID_ID3D12CommandSignature,
(void **)&cmdsig);
if (FAILED(hres))
return NULL;
@ -1039,7 +1041,7 @@ dzn_compute_pipeline_destroy(dzn_compute_pipeline *pipeline,
return;
if (pipeline->indirect_cmd_sig)
pipeline->indirect_cmd_sig->Release();
ID3D12CommandSignature_Release(pipeline->indirect_cmd_sig);
dzn_pipeline_finish(&pipeline->base);
vk_free2(&pipeline->base.base.device->alloc, alloc, pipeline);
@ -1077,8 +1079,9 @@ dzn_compute_pipeline_create(dzn_device *device,
if (ret != VK_SUCCESS)
goto out;
if (FAILED(device->dev->CreateComputePipelineState(&desc,
IID_PPV_ARGS(&pipeline->base.state)))) {
if (FAILED(ID3D12Device1_CreateComputePipelineState(device->dev, &desc,
IID_ID3D12PipelineState,
(void **)&pipeline->base.state))) {
ret = vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
goto out;
}
@ -1123,9 +1126,10 @@ dzn_compute_pipeline_get_indirect_cmd_sig(dzn_compute_pipeline *pipeline)
};
HRESULT hres =
device->dev->CreateCommandSignature(&indirect_dispatch_desc,
pipeline->base.root.sig,
IID_PPV_ARGS(&pipeline->indirect_cmd_sig));
ID3D12Device1_CreateCommandSignature(device->dev, &indirect_dispatch_desc,
pipeline->base.root.sig,
IID_ID3D12CommandSignature,
(void **)&pipeline->indirect_cmd_sig);
if (FAILED(hres))
return NULL;

View File

@ -51,10 +51,12 @@
#include <vulkan/vulkan.h>
#include <vulkan/vk_icd.h>
#include <dxgi1_4.h>
#define D3D12_IGNORE_SDK_LAYERS
#define CINTERFACE
#define COBJMACROS
#include <dxgi1_4.h>
#include <directx/d3d12.h>
#undef CINTERFACE
#include "spirv_to_dxil.h"

View File

@ -62,20 +62,20 @@ dzn_query_pool_destroy(dzn_query_pool *qpool,
dzn_device *device = container_of(qpool->base.device, dzn_device, vk);
if (qpool->collect_map)
qpool->collect_buffer->Unmap(0, NULL);
ID3D12Resource_Unmap(qpool->collect_buffer, 0, NULL);
if (qpool->collect_buffer)
qpool->collect_buffer->Release();
ID3D12Resource_Release(qpool->collect_buffer);
if (qpool->resolve_buffer)
qpool->resolve_buffer->Release();
ID3D12Resource_Release(qpool->resolve_buffer);
if (qpool->heap)
qpool->heap->Release();
ID3D12QueryHeap_Release(qpool->heap);
for (uint32_t q = 0; q < qpool->query_count; q++) {
if (qpool->queries[q].fence)
qpool->queries[q].fence->Release();
ID3D12Fence_Release(qpool->queries[q].fence);
}
mtx_destroy(&qpool->queries_lock);
@ -109,7 +109,9 @@ dzn_query_pool_create(dzn_device *device,
desc.NodeMask = 0;
HRESULT hres =
device->dev->CreateQueryHeap(&desc, IID_PPV_ARGS(&qpool->heap));
ID3D12Device1_CreateQueryHeap(device->dev, &desc,
IID_ID3D12QueryHeap,
(void **)&qpool->heap);
if (FAILED(hres)) {
dzn_query_pool_destroy(qpool, alloc);
return vk_error(device, VK_ERROR_OUT_OF_DEVICE_MEMORY);
@ -127,8 +129,9 @@ dzn_query_pool_create(dzn_device *device,
default: unreachable("Unsupported query type");
}
D3D12_HEAP_PROPERTIES hprops =
device->dev->GetCustomHeapProperties(0, D3D12_HEAP_TYPE_DEFAULT);
D3D12_HEAP_PROPERTIES hprops;
ID3D12Device1_GetCustomHeapProperties(device->dev, &hprops, 0,
D3D12_HEAP_TYPE_DEFAULT);
D3D12_RESOURCE_DESC rdesc = {
.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER,
.Alignment = D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT,
@ -142,29 +145,34 @@ dzn_query_pool_create(dzn_device *device,
.Flags = D3D12_RESOURCE_FLAG_NONE,
};
hres = device->dev->CreateCommittedResource(&hprops,
D3D12_HEAP_FLAG_NONE,
&rdesc,
D3D12_RESOURCE_STATE_COPY_DEST,
NULL, IID_PPV_ARGS(&qpool->resolve_buffer));
hres = ID3D12Device1_CreateCommittedResource(device->dev, &hprops,
D3D12_HEAP_FLAG_NONE,
&rdesc,
D3D12_RESOURCE_STATE_COPY_DEST,
NULL,
IID_ID3D12Resource,
(void **)&qpool->resolve_buffer);
if (FAILED(hres)) {
dzn_query_pool_destroy(qpool, alloc);
return vk_error(device, VK_ERROR_OUT_OF_DEVICE_MEMORY);
}
hprops = device->dev->GetCustomHeapProperties(0, D3D12_HEAP_TYPE_READBACK);
ID3D12Device1_GetCustomHeapProperties(device->dev, &hprops, 0,
D3D12_HEAP_TYPE_READBACK);
rdesc.Width = info->queryCount * (qpool->query_size + sizeof(uint64_t));
hres = device->dev->CreateCommittedResource(&hprops,
D3D12_HEAP_FLAG_NONE,
&rdesc,
D3D12_RESOURCE_STATE_COPY_DEST,
NULL, IID_PPV_ARGS(&qpool->collect_buffer));
hres = ID3D12Device1_CreateCommittedResource(device->dev, &hprops,
D3D12_HEAP_FLAG_NONE,
&rdesc,
D3D12_RESOURCE_STATE_COPY_DEST,
NULL,
IID_ID3D12Resource,
(void **)&qpool->collect_buffer);
if (FAILED(hres)) {
dzn_query_pool_destroy(qpool, alloc);
return vk_error(device, VK_ERROR_OUT_OF_DEVICE_MEMORY);
}
hres = qpool->collect_buffer->Map(0, NULL, (void **)&qpool->collect_map);
hres = ID3D12Resource_Map(qpool->collect_buffer, 0, NULL, (void **)&qpool->collect_map);
if (FAILED(hres)) {
dzn_query_pool_destroy(qpool, alloc);
return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
@ -226,7 +234,7 @@ dzn_ResetQueryPool(VkDevice device,
query->fence_value = 0;
if (query->fence) {
query->fence->Release();
ID3D12Fence_Release(query->fence);
query->fence = NULL;
}
}
@ -271,7 +279,7 @@ dzn_GetQueryPoolResults(VkDevice device,
mtx_lock(&qpool->queries_lock);
if (query->fence) {
query_fence = query->fence;
query_fence->AddRef();
ID3D12Fence_AddRef(query_fence);
}
query_fence_val = query->fence_value;
mtx_unlock(&qpool->queries_lock);
@ -285,23 +293,23 @@ dzn_GetQueryPoolResults(VkDevice device,
Sleep(10);
}
query_fence->SetEventOnCompletion(query_fence_val, NULL);
query_fence->Release();
ID3D12Fence_SetEventOnCompletion(query_fence, query_fence_val, NULL);
ID3D12Fence_Release(query_fence);
available = UINT64_MAX;
} else {
ID3D12Fence *query_fence = NULL;
mtx_lock(&qpool->queries_lock);
if (query->fence) {
query_fence = query->fence;
query_fence->AddRef();
ID3D12Fence_AddRef(query_fence);
}
uint64_t query_fence_val = query->fence_value;
mtx_unlock(&qpool->queries_lock);
if (query_fence) {
if (query_fence->GetCompletedValue() >= query_fence_val)
if (ID3D12Fence_GetCompletedValue(query_fence) >= query_fence_val)
available = UINT64_MAX;
query_fence->Release();
ID3D12Fence_Release(query_fence);
}
}

View File

@ -40,8 +40,10 @@ dzn_sync_init(struct vk_device *device,
assert(!(sync->flags & VK_SYNC_IS_SHAREABLE));
if (FAILED(ddev->dev->CreateFence(initial_value, D3D12_FENCE_FLAG_NONE,
IID_PPV_ARGS(&dsync->fence))))
if (FAILED(ID3D12Device1_CreateFence(ddev->dev, initial_value,
D3D12_FENCE_FLAG_NONE,
IID_ID3D12Fence,
(void **)&dsync->fence)))
return vk_error(device, VK_ERROR_OUT_OF_DEVICE_MEMORY);
return VK_SUCCESS;
@ -53,7 +55,7 @@ dzn_sync_finish(struct vk_device *device,
{
dzn_sync *dsync = container_of(sync, dzn_sync, vk);
dsync->fence->Release();
ID3D12Fence_Release(dsync->fence);
}
static VkResult
@ -66,7 +68,7 @@ dzn_sync_signal(struct vk_device *device,
if (!(sync->flags & VK_SYNC_IS_TIMELINE))
value = 1;
if (FAILED(dsync->fence->Signal(value)))
if (FAILED(ID3D12Fence_Signal(dsync->fence, value)))
return vk_error(device, VK_ERROR_OUT_OF_DEVICE_MEMORY);
return VK_SUCCESS;
@ -79,7 +81,7 @@ dzn_sync_get_value(struct vk_device *device,
{
dzn_sync *dsync = container_of(sync, dzn_sync, vk);
*value = dsync->fence->GetCompletedValue();
*value = ID3D12Fence_GetCompletedValue(dsync->fence);
return VK_SUCCESS;
}
@ -89,7 +91,7 @@ dzn_sync_reset(struct vk_device *device,
{
dzn_sync *dsync = container_of(sync, dzn_sync, vk);
if (FAILED(dsync->fence->Signal(0)))
if (FAILED(ID3D12Fence_Signal(dsync->fence, 0)))
return vk_error(device, VK_ERROR_OUT_OF_DEVICE_MEMORY);
return VK_SUCCESS;
@ -105,11 +107,13 @@ dzn_sync_move(struct vk_device *device,
dzn_sync *dsrc = container_of(src, dzn_sync, vk);
ID3D12Fence *new_fence;
if (FAILED(ddev->dev->CreateFence(0, D3D12_FENCE_FLAG_NONE,
IID_PPV_ARGS(&new_fence))))
if (FAILED(ID3D12Device1_CreateFence(ddev->dev, 0,
D3D12_FENCE_FLAG_NONE,
IID_ID3D12Fence,
(void **)&new_fence)))
return vk_error(device, VK_ERROR_OUT_OF_DEVICE_MEMORY);
ddst->fence->Release();
ID3D12Fence_Release(ddst->fence);
ddst->fence = dsrc->fence;
dsrc->fence = new_fence;
return VK_SUCCESS;
@ -143,9 +147,12 @@ dzn_sync_wait(struct vk_device *device,
D3D12_MULTIPLE_FENCE_WAIT_FLAG_ANY :
D3D12_MULTIPLE_FENCE_WAIT_FLAG_ALL;
if (FAILED(ddev->dev->SetEventOnMultipleFenceCompletion(fences, values,
wait_count, flags,
event))) {
if (FAILED(ID3D12Device1_SetEventOnMultipleFenceCompletion(ddev->dev,
fences,
values,
wait_count,
flags,
event))) {
STACK_ARRAY_FINISH(fences);
STACK_ARRAY_FINISH(values);
CloseHandle(event);

View File

@ -28,7 +28,9 @@
#include <stdarg.h>
#include <stdio.h>
#define CINTERFACE
#include <directx/d3d12sdklayers.h>
#undef CINTERFACE
IDXGIFactory4 *
dxgi_get_factory(bool debug)
@ -86,7 +88,7 @@ get_debug_interface()
}
ID3D12Debug *debug;
if (FAILED(D3D12GetDebugInterface(IID_PPV_ARGS(&debug)))) {
if (FAILED(D3D12GetDebugInterface(IID_ID3D12Debug, (void **)&debug))) {
mesa_loge("D3D12GetDebugInterface failed\n");
return NULL;
}
@ -99,8 +101,8 @@ d3d12_enable_debug_layer()
{
ID3D12Debug *debug = get_debug_interface();
if (debug) {
debug->EnableDebugLayer();
debug->Release();
ID3D12Debug_EnableDebugLayer(debug);
ID3D12Debug_Release(debug);
}
}
@ -110,18 +112,20 @@ d3d12_enable_gpu_validation()
ID3D12Debug *debug = get_debug_interface();
if (debug) {
ID3D12Debug3 *debug3;
if (SUCCEEDED(debug->QueryInterface(IID_PPV_ARGS(&debug3)))) {
debug3->SetEnableGPUBasedValidation(true);
debug3->Release();
if (SUCCEEDED(ID3D12Debug_QueryInterface(debug,
IID_ID3D12Debug3,
(void **)&debug3))) {
ID3D12Debug3_SetEnableGPUBasedValidation(debug3, true);
ID3D12Debug3_Release(debug3);
}
debug->Release();
ID3D12Debug_Release(debug);
}
}
ID3D12Device1 *
d3d12_create_device(IDXGIAdapter1 *adapter, bool experimental_features)
{
typedef HRESULT(WINAPI *PFN_D3D12CREATEDEVICE)(IUnknown*, D3D_FEATURE_LEVEL, REFIID, void**);
typedef HRESULT(WINAPI *PFN_D3D12CREATEDEVICE)(IDXGIAdapter1*, D3D_FEATURE_LEVEL, REFIID, void**);
PFN_D3D12CREATEDEVICE D3D12CreateDevice;
HMODULE d3d12_mod = LoadLibraryA("D3D12.DLL");
@ -151,7 +155,8 @@ d3d12_create_device(IDXGIAdapter1 *adapter, bool experimental_features)
ID3D12Device1 *dev;
if (SUCCEEDED(D3D12CreateDevice(adapter, D3D_FEATURE_LEVEL_11_0,
IID_PPV_ARGS(&dev))))
IID_ID3D12Device1,
(void **)&dev)))
return dev;
mesa_loge("D3D12CreateDevice failed\n");