dzn: remove all usage of ComPtr<T>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15816>
This commit is contained in:
parent
74228c32ee
commit
5f17d070a9
|
@ -828,7 +828,7 @@ dzn_cmd_buffer_alloc_internal_buf(dzn_cmd_buffer *cmdbuf,
|
|||
ID3D12Resource **out)
|
||||
{
|
||||
dzn_device *device = container_of(cmdbuf->vk.base.device, dzn_device, vk);
|
||||
ComPtr<ID3D12Resource> res;
|
||||
ID3D12Resource *res;
|
||||
*out = NULL;
|
||||
|
||||
/* Align size on 64k (the default alignment) */
|
||||
|
@ -863,10 +863,11 @@ dzn_cmd_buffer_alloc_internal_buf(dzn_cmd_buffer *cmdbuf,
|
|||
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
|
||||
if (!entry) {
|
||||
cmdbuf->error = vk_error(device, VK_ERROR_OUT_OF_DEVICE_MEMORY);
|
||||
res->Release();
|
||||
return cmdbuf->error;
|
||||
}
|
||||
|
||||
entry->res = res.Detach();
|
||||
entry->res = res;
|
||||
list_addtail(&entry->link, &cmdbuf->internal_bufs);
|
||||
*out = entry->res;
|
||||
return VK_SUCCESS;
|
||||
|
|
|
@ -336,14 +336,14 @@ dzn_physical_device_cache_caps(dzn_physical_device *pdev)
|
|||
.NodeMask = 0,
|
||||
};
|
||||
|
||||
ComPtr<ID3D12CommandQueue> cmdqueue;
|
||||
|
||||
ID3D12CommandQueue *cmdqueue;
|
||||
pdev->dev->CreateCommandQueue(&queue_desc,
|
||||
IID_PPV_ARGS(&cmdqueue));
|
||||
|
||||
uint64_t ts_freq;
|
||||
cmdqueue->GetTimestampFrequency(&ts_freq);
|
||||
pdev->timestamp_period = 1000000000.0f / ts_freq;
|
||||
cmdqueue->Release();
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -901,21 +901,28 @@ dzn_EnumeratePhysicalDevices(VkInstance inst,
|
|||
VK_FROM_HANDLE(dzn_instance, instance, inst);
|
||||
|
||||
if (!instance->physical_devices_enumerated) {
|
||||
ComPtr<IDXGIFactory4> factory = dxgi_get_factory(false);
|
||||
ComPtr<IDXGIAdapter1> adapter(NULL);
|
||||
IDXGIFactory4 *factory = dxgi_get_factory(false);
|
||||
IDXGIAdapter1 *adapter = NULL;
|
||||
for (UINT i = 0; SUCCEEDED(factory->EnumAdapters1(i, &adapter)); ++i) {
|
||||
DXGI_ADAPTER_DESC1 desc;
|
||||
adapter->GetDesc1(&desc);
|
||||
if (instance->debug_flags & DZN_DEBUG_WARP) {
|
||||
if ((desc.Flags & DXGI_ADAPTER_FLAG_SOFTWARE) == 0)
|
||||
if ((desc.Flags & DXGI_ADAPTER_FLAG_SOFTWARE) == 0) {
|
||||
adapter->Release();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
VkResult result =
|
||||
dzn_physical_device_create(instance, adapter.Get(), &desc);
|
||||
if (result != VK_SUCCESS)
|
||||
dzn_physical_device_create(instance, adapter, &desc);
|
||||
|
||||
adapter->Release();
|
||||
if (result != VK_SUCCESS) {
|
||||
factory->Release();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
factory->Release();
|
||||
}
|
||||
|
||||
VK_OUTARRAY_MAKE_TYPED(VkPhysicalDevice, out, pPhysicalDevices,
|
||||
|
@ -1788,7 +1795,7 @@ dzn_device_create_root_sig(dzn_device *device,
|
|||
{
|
||||
dzn_instance *instance =
|
||||
container_of(device->vk.physical->instance, dzn_instance, vk);
|
||||
ComPtr<ID3DBlob> sig, error;
|
||||
ID3DBlob *sig, *error;
|
||||
|
||||
if (FAILED(instance->d3d12.serialize_root_sig(desc,
|
||||
&sig, &error))) {
|
||||
|
@ -1801,6 +1808,7 @@ dzn_device_create_root_sig(dzn_device *device,
|
|||
error_msg);
|
||||
}
|
||||
|
||||
error->Release();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -1808,9 +1816,12 @@ dzn_device_create_root_sig(dzn_device *device,
|
|||
if (FAILED(device->dev->CreateRootSignature(0,
|
||||
sig->GetBufferPointer(),
|
||||
sig->GetBufferSize(),
|
||||
IID_PPV_ARGS(&root_sig))))
|
||||
IID_PPV_ARGS(&root_sig)))) {
|
||||
sig->Release();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
sig->Release();
|
||||
return root_sig;
|
||||
}
|
||||
|
||||
|
|
|
@ -55,12 +55,9 @@
|
|||
|
||||
#define D3D12_IGNORE_SDK_LAYERS
|
||||
#include <directx/d3d12.h>
|
||||
#include <wrl/client.h>
|
||||
|
||||
#include "spirv_to_dxil.h"
|
||||
|
||||
using Microsoft::WRL::ComPtr;
|
||||
|
||||
#define DZN_SWAP(a, b) \
|
||||
do { \
|
||||
auto __tmp = a; \
|
||||
|
|
|
@ -264,16 +264,19 @@ dzn_GetQueryPoolResults(VkDevice device,
|
|||
uint64_t available = 0;
|
||||
|
||||
if (flags & VK_QUERY_RESULT_WAIT_BIT) {
|
||||
ComPtr<ID3D12Fence> query_fence(NULL);
|
||||
ID3D12Fence *query_fence = NULL;
|
||||
uint64_t query_fence_val = 0;
|
||||
|
||||
while (true) {
|
||||
mtx_lock(&qpool->queries_lock);
|
||||
query_fence = ComPtr<ID3D12Fence>(query->fence);
|
||||
if (query->fence) {
|
||||
query_fence = query->fence;
|
||||
query_fence->AddRef();
|
||||
}
|
||||
query_fence_val = query->fence_value;
|
||||
mtx_unlock(&qpool->queries_lock);
|
||||
|
||||
if (query_fence.Get())
|
||||
if (query_fence)
|
||||
break;
|
||||
|
||||
/* Check again in 10ms.
|
||||
|
@ -283,16 +286,23 @@ dzn_GetQueryPoolResults(VkDevice device,
|
|||
}
|
||||
|
||||
query_fence->SetEventOnCompletion(query_fence_val, NULL);
|
||||
query_fence->Release();
|
||||
available = UINT64_MAX;
|
||||
} else {
|
||||
ID3D12Fence *query_fence = NULL;
|
||||
mtx_lock(&qpool->queries_lock);
|
||||
ComPtr<ID3D12Fence> query_fence(query->fence);
|
||||
if (query->fence) {
|
||||
query_fence = query->fence;
|
||||
query_fence->AddRef();
|
||||
}
|
||||
uint64_t query_fence_val = query->fence_value;
|
||||
mtx_unlock(&qpool->queries_lock);
|
||||
|
||||
if (query_fence.Get() &&
|
||||
query_fence->GetCompletedValue() >= query_fence_val)
|
||||
available = UINT64_MAX;
|
||||
if (query_fence) {
|
||||
if (query_fence->GetCompletedValue() >= query_fence_val)
|
||||
available = UINT64_MAX;
|
||||
query_fence->Release();
|
||||
}
|
||||
}
|
||||
|
||||
if (qpool->heap_type != D3D12_QUERY_HEAP_TYPE_PIPELINE_STATISTICS) {
|
||||
|
|
|
@ -67,7 +67,7 @@ dxgi_get_factory(bool debug)
|
|||
return factory;
|
||||
}
|
||||
|
||||
static ComPtr<ID3D12Debug>
|
||||
static ID3D12Debug *
|
||||
get_debug_interface()
|
||||
{
|
||||
typedef HRESULT(WINAPI *PFN_D3D12_GET_DEBUG_INTERFACE)(REFIID riid, void **ppFactory);
|
||||
|
@ -85,7 +85,7 @@ get_debug_interface()
|
|||
return NULL;
|
||||
}
|
||||
|
||||
ComPtr<ID3D12Debug> debug;
|
||||
ID3D12Debug *debug;
|
||||
if (FAILED(D3D12GetDebugInterface(IID_PPV_ARGS(&debug)))) {
|
||||
mesa_loge("D3D12GetDebugInterface failed\n");
|
||||
return NULL;
|
||||
|
@ -97,19 +97,25 @@ get_debug_interface()
|
|||
void
|
||||
d3d12_enable_debug_layer()
|
||||
{
|
||||
ComPtr<ID3D12Debug> debug = get_debug_interface();
|
||||
if (debug)
|
||||
ID3D12Debug *debug = get_debug_interface();
|
||||
if (debug) {
|
||||
debug->EnableDebugLayer();
|
||||
debug->Release();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
d3d12_enable_gpu_validation()
|
||||
{
|
||||
ComPtr<ID3D12Debug> debug = get_debug_interface();
|
||||
ComPtr<ID3D12Debug3> debug3;
|
||||
if (debug &&
|
||||
SUCCEEDED(debug->QueryInterface(IID_PPV_ARGS(&debug3))))
|
||||
debug3->SetEnableGPUBasedValidation(true);
|
||||
ID3D12Debug *debug = get_debug_interface();
|
||||
if (debug) {
|
||||
ID3D12Debug3 *debug3;
|
||||
if (SUCCEEDED(debug->QueryInterface(IID_PPV_ARGS(&debug3)))) {
|
||||
debug3->SetEnableGPUBasedValidation(true);
|
||||
debug3->Release();
|
||||
}
|
||||
debug->Release();
|
||||
}
|
||||
}
|
||||
|
||||
ID3D12Device1 *
|
||||
|
|
Loading…
Reference in New Issue