mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-11-21 16:46:41 -08:00
libs/vkd3d: Allocate CPU memory for descriptors.
This commit is contained in:
parent
cd37442fd0
commit
9262f87249
@ -685,9 +685,26 @@ static HRESULT STDMETHODCALLTYPE d3d12_device_CreateDescriptorHeap(ID3D12Device
|
||||
static UINT STDMETHODCALLTYPE d3d12_device_GetDescriptorHandleIncrementSize(ID3D12Device *iface,
|
||||
D3D12_DESCRIPTOR_HEAP_TYPE descriptor_heap_type)
|
||||
{
|
||||
FIXME("iface %p, descriptor_heap_type %#x stub!\n", iface, descriptor_heap_type);
|
||||
TRACE("iface %p, descriptor_heap_type %#x.\n", iface, descriptor_heap_type);
|
||||
|
||||
switch (descriptor_heap_type)
|
||||
{
|
||||
case D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV:
|
||||
return sizeof(struct d3d12_cbv_srv_uav_desc);
|
||||
|
||||
case D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER:
|
||||
return sizeof(struct d3d12_sampler_desc);
|
||||
|
||||
case D3D12_DESCRIPTOR_HEAP_TYPE_RTV:
|
||||
return sizeof(struct d3d12_rtv_desc);
|
||||
|
||||
case D3D12_DESCRIPTOR_HEAP_TYPE_DSV:
|
||||
return sizeof(struct d3d12_dsv_desc);
|
||||
|
||||
default:
|
||||
FIXME("Unhandled type %#x.\n", descriptor_heap_type);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static HRESULT STDMETHODCALLTYPE d3d12_device_CreateRootSignature(ID3D12Device *iface,
|
||||
|
@ -830,12 +830,28 @@ static void d3d12_descriptor_heap_init(struct d3d12_descriptor_heap *descriptor_
|
||||
HRESULT d3d12_descriptor_heap_create(struct d3d12_device *device,
|
||||
const D3D12_DESCRIPTOR_HEAP_DESC *desc, struct d3d12_descriptor_heap **descriptor_heap)
|
||||
{
|
||||
size_t max_descriptor_count, descriptor_size;
|
||||
struct d3d12_descriptor_heap *object;
|
||||
|
||||
if (!(object = vkd3d_malloc(sizeof(*object))))
|
||||
if (!(descriptor_size = ID3D12Device_GetDescriptorHandleIncrementSize(&device->ID3D12Device_iface, desc->Type)))
|
||||
{
|
||||
WARN("No descriptor size for descriptor type %#x.\n", desc->Type);
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
|
||||
max_descriptor_count = (~(size_t)0 - sizeof(*object)) / descriptor_size;
|
||||
if (desc->NumDescriptors > max_descriptor_count)
|
||||
{
|
||||
WARN("Invalid descriptor count %u (max %zu).\n", desc->NumDescriptors, max_descriptor_count);
|
||||
return E_OUTOFMEMORY;
|
||||
}
|
||||
|
||||
if (!(object = vkd3d_malloc(offsetof(struct d3d12_descriptor_heap,
|
||||
descriptors[descriptor_size * desc->NumDescriptors]))))
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
d3d12_descriptor_heap_init(object, device, desc);
|
||||
memset(object->descriptors, 0, descriptor_size * desc->NumDescriptors);
|
||||
|
||||
TRACE("Created descriptor heap %p.\n", object);
|
||||
|
||||
|
@ -33,6 +33,8 @@
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#define VKD3D_DESCRIPTOR_MAGIC_FREE 0x00000000u
|
||||
|
||||
struct d3d12_command_list;
|
||||
struct d3d12_device;
|
||||
|
||||
@ -83,6 +85,26 @@ HRESULT d3d12_committed_resource_create(struct d3d12_device *device,
|
||||
const D3D12_RESOURCE_DESC *desc, D3D12_RESOURCE_STATES initial_state,
|
||||
const D3D12_CLEAR_VALUE *optimized_clear_value, struct d3d12_resource **resource) DECLSPEC_HIDDEN;
|
||||
|
||||
struct d3d12_cbv_srv_uav_desc
|
||||
{
|
||||
uint32_t magic;
|
||||
};
|
||||
|
||||
struct d3d12_sampler_desc
|
||||
{
|
||||
uint32_t magic;
|
||||
};
|
||||
|
||||
struct d3d12_rtv_desc
|
||||
{
|
||||
uint32_t magic;
|
||||
};
|
||||
|
||||
struct d3d12_dsv_desc
|
||||
{
|
||||
uint32_t magic;
|
||||
};
|
||||
|
||||
/* ID3D12DescriptorHeap */
|
||||
struct d3d12_descriptor_heap
|
||||
{
|
||||
@ -92,6 +114,8 @@ struct d3d12_descriptor_heap
|
||||
D3D12_DESCRIPTOR_HEAP_DESC desc;
|
||||
|
||||
struct d3d12_device *device;
|
||||
|
||||
BYTE descriptors[];
|
||||
};
|
||||
|
||||
HRESULT d3d12_descriptor_heap_create(struct d3d12_device *device,
|
||||
|
Loading…
Reference in New Issue
Block a user