diff --git a/libs/vkd3d/command.c b/libs/vkd3d/command.c index bd41985d..f45adb64 100644 --- a/libs/vkd3d/command.c +++ b/libs/vkd3d/command.c @@ -144,6 +144,14 @@ static const struct ID3D12CommandAllocatorVtbl d3d12_command_allocator_vtbl = d3d12_command_allocator_Reset, }; +static struct d3d12_command_allocator *unsafe_impl_from_ID3D12CommandAllocator(ID3D12CommandAllocator *iface) +{ + if (!iface) + return NULL; + assert(iface->lpVtbl == &d3d12_command_allocator_vtbl); + return impl_from_ID3D12CommandAllocator(iface); +} + static void d3d12_command_allocator_init(struct d3d12_command_allocator *allocator, struct d3d12_device *device, D3D12_COMMAND_LIST_TYPE type) { @@ -179,6 +187,592 @@ HRESULT d3d12_command_allocator_create(struct d3d12_device *device, return S_OK; } +/* ID3D12CommandList */ +static inline struct d3d12_command_list *impl_from_ID3D12GraphicsCommandList(ID3D12GraphicsCommandList *iface) +{ + return CONTAINING_RECORD(iface, struct d3d12_command_list, ID3D12GraphicsCommandList_iface); +} + +static HRESULT STDMETHODCALLTYPE d3d12_command_list_QueryInterface(ID3D12GraphicsCommandList *iface, + REFIID riid, void **object) +{ + TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object); + + if (IsEqualGUID(riid, &IID_ID3D12GraphicsCommandList) + || IsEqualGUID(riid, &IID_ID3D12CommandList) + || IsEqualGUID(riid, &IID_ID3D12DeviceChild) + || IsEqualGUID(riid, &IID_ID3D12Object) + || IsEqualGUID(riid, &IID_IUnknown)) + { + ID3D12GraphicsCommandList_AddRef(iface); + *object = iface; + return S_OK; + } + + WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid)); + + *object = NULL; + return E_NOINTERFACE; +} + +static ULONG STDMETHODCALLTYPE d3d12_command_list_AddRef(ID3D12GraphicsCommandList *iface) +{ + struct d3d12_command_list *list = impl_from_ID3D12GraphicsCommandList(iface); + ULONG refcount = InterlockedIncrement(&list->refcount); + + TRACE("%p increasing refcount to %u.\n", list, refcount); + + return refcount; +} + +static ULONG STDMETHODCALLTYPE d3d12_command_list_Release(ID3D12GraphicsCommandList *iface) +{ + struct d3d12_command_list *list = impl_from_ID3D12GraphicsCommandList(iface); + ULONG refcount = InterlockedDecrement(&list->refcount); + + TRACE("%p decreasing refcount to %u.\n", list, refcount); + + if (!refcount) + { + struct d3d12_device *device = list->device; + + vkd3d_free(list); + + ID3D12Device_Release(&device->ID3D12Device_iface); + } + + return refcount; +} + +static HRESULT STDMETHODCALLTYPE d3d12_command_list_GetPrivateData(ID3D12GraphicsCommandList *iface, + REFGUID guid, UINT *data_size, void *data) +{ + FIXME("iface %p, guid %s, data_size %p, data %p stub!", iface, debugstr_guid(guid), data_size, data); + + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE d3d12_command_list_SetPrivateData(ID3D12GraphicsCommandList *iface, + REFGUID guid, UINT data_size, const void *data) +{ + FIXME("iface %p, guid %s, data_size %u, data %p stub!\n", iface, debugstr_guid(guid), data_size, data); + + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE d3d12_command_list_SetPrivateDataInterface(ID3D12GraphicsCommandList *iface, + REFGUID guid, const IUnknown *data) +{ + FIXME("iface %p, guid %s, data %p stub!\n", iface, debugstr_guid(guid), data); + + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE d3d12_command_list_SetName(ID3D12GraphicsCommandList *iface, const WCHAR *name) +{ + FIXME("iface %p, name %s stub!\n", iface, debugstr_w(name)); + + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE d3d12_command_list_GetDevice(ID3D12GraphicsCommandList *iface, + REFIID riid, void **device) +{ + struct d3d12_command_list *list = impl_from_ID3D12GraphicsCommandList(iface); + + TRACE("iface %p, riid %s, device %p.\n", iface, debugstr_guid(riid), device); + + return ID3D12Device_QueryInterface(&list->device->ID3D12Device_iface, riid, device); +} + +static D3D12_COMMAND_LIST_TYPE STDMETHODCALLTYPE d3d12_command_list_GetType(ID3D12GraphicsCommandList *iface) +{ + struct d3d12_command_list *list = impl_from_ID3D12GraphicsCommandList(iface); + + TRACE("iface %p.\n", iface); + + return list->type; +} + +static HRESULT STDMETHODCALLTYPE d3d12_command_list_Close(ID3D12GraphicsCommandList *iface) +{ + FIXME("iface %p stub!\n", iface); + + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE d3d12_command_list_Reset(ID3D12GraphicsCommandList *iface, + ID3D12CommandAllocator *allocator, ID3D12PipelineState *initial_state) +{ + FIXME("iface %p, allocator %p, initial_state %p stub!\n", + iface, allocator, initial_state); + + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE d3d12_command_list_ClearState(ID3D12GraphicsCommandList *iface, + ID3D12PipelineState *pipeline_state) +{ + FIXME("iface %p, pipline_state %p stub!\n", iface, pipeline_state); + + return E_NOTIMPL; +} + +static void STDMETHODCALLTYPE d3d12_command_list_DrawInstanced(ID3D12GraphicsCommandList *iface, + UINT vertex_count_per_instance, UINT instance_count, UINT start_vertex_location, + UINT start_instance_location) +{ + FIXME("iface %p, vertex_count_per_instance %u, instance_count %u, " + "start_vertex_location %u, start_instance_location %u stub!\n", + iface, vertex_count_per_instance, instance_count, + start_vertex_location, start_instance_location); +} + +static void STDMETHODCALLTYPE d3d12_command_list_DrawIndexedInstanced(ID3D12GraphicsCommandList *iface, + UINT index_count_per_instance, UINT instance_count, UINT start_vertex_location, + INT base_vertex_location, UINT start_instance_location) +{ + FIXME("iface %p, index_count_per_instance %u, instance_count %u, start_vertex_location %u, " + "base_vertex_location %d, start_instance_location %u stub!\n", + iface, index_count_per_instance, instance_count, start_vertex_location, + base_vertex_location, start_instance_location); +} + +static void STDMETHODCALLTYPE d3d12_command_list_Dispatch(ID3D12GraphicsCommandList *iface, + UINT x, UINT y, UINT z) +{ + FIXME("iface %p, x %u, y %u, z %u stub!\n", iface, x, y, z); +} + +static void STDMETHODCALLTYPE d3d12_command_list_CopyBufferRegion(ID3D12GraphicsCommandList *iface, + ID3D12Resource *dst_resource, UINT64 dst_offset, ID3D12Resource *src_resource, + UINT64 src_offset, UINT64 byte_count) +{ + FIXME("iface %p, dst_resource %p, dst_offset %s, src_resource %p, src_offset %s, byte_count %s stub!\n", + iface, dst_resource, debugstr_uint64(dst_offset), src_resource, + debugstr_uint64(src_offset), debugstr_uint64(byte_count)); +} + +static void STDMETHODCALLTYPE d3d12_command_list_CopyTextureRegion(ID3D12GraphicsCommandList *iface, + const D3D12_TEXTURE_COPY_LOCATION *dst, UINT dst_x, UINT dst_y, UINT dst_z, + const D3D12_TEXTURE_COPY_LOCATION *src, const D3D12_BOX *src_box) +{ + FIXME("iface %p, dst %p, dst_x %u, dst_y %u, dst_z %u, src %p, src_box %p stub!\n", + iface, dst, dst_x, dst_y, dst_z, src, src_box); +} + +static void STDMETHODCALLTYPE d3d12_command_list_CopyResource(ID3D12GraphicsCommandList *iface, + ID3D12Resource *dst_resource, ID3D12Resource *src_resource) +{ + FIXME("iface %p, dst_resource %p, src_resource %p stub!\n", iface, dst_resource, src_resource); +} + +static void STDMETHODCALLTYPE d3d12_command_list_CopyTiles(ID3D12GraphicsCommandList *iface, + ID3D12Resource *tiled_resource, const D3D12_TILED_RESOURCE_COORDINATE *tile_region_start_coordinate, + const D3D12_TILE_REGION_SIZE *tile_region_size, ID3D12Resource *buffer, UINT64 buffer_offset, + D3D12_TILE_COPY_FLAGS flags) +{ + FIXME("iface %p, tiled_resource %p, tile_region_start_coordinate %p, tile_region_size %p, " + "buffer %p, buffer_offset %s, flags %#x stub!\n", + iface, tiled_resource, tile_region_start_coordinate, tile_region_size, + buffer, debugstr_uint64(buffer_offset), flags); +} + +static void STDMETHODCALLTYPE d3d12_command_list_ResolveSubresource(ID3D12GraphicsCommandList *iface, + ID3D12Resource *dst_resource, UINT dst_sub_resource, + ID3D12Resource *src_resource, UINT src_sub_resource, DXGI_FORMAT format) +{ + FIXME("iface %p, dst_resource %p, dst_sub_resource %u, src_resource %p, src_sub_resource %u, " + "format %#x stub!\n", + iface, dst_resource, dst_sub_resource, src_resource, src_sub_resource, format); +} + +static void STDMETHODCALLTYPE d3d12_command_list_IASetPrimitiveTopology(ID3D12GraphicsCommandList *iface, + D3D12_PRIMITIVE_TOPOLOGY primitive_topology) +{ + FIXME("iface %p, primitive_topology %#x stub!\n", iface, primitive_topology); +} + +static void STDMETHODCALLTYPE d3d12_command_list_RSSetViewports(ID3D12GraphicsCommandList *iface, + UINT viewport_count, const D3D12_VIEWPORT *viewports) +{ + FIXME("iface %p, viewport_count %u, viewports %p stub!\n", + iface, viewport_count, viewports); +} + +static void STDMETHODCALLTYPE d3d12_command_list_RSSetScissorRects(ID3D12GraphicsCommandList *iface, + UINT rect_count, const D3D12_RECT *rects) +{ + FIXME("iface %p, rect_count %u, rects %p stub!\n", + iface, rect_count, rects); +} + +static void STDMETHODCALLTYPE d3d12_command_list_OMSetBlendFactor(ID3D12GraphicsCommandList *iface, + const FLOAT blend_factor[4]) +{ + FIXME("iface %p, blend_factor %p stub!\n", iface, blend_factor); +} + +static void STDMETHODCALLTYPE d3d12_command_list_OMSetStencilRef(ID3D12GraphicsCommandList *iface, + UINT stencil_ref) +{ + FIXME("iface %p, stencil_ref %u stub!\n", iface, stencil_ref); +} + +static void STDMETHODCALLTYPE d3d12_command_list_SetPipelineState(ID3D12GraphicsCommandList *iface, + ID3D12PipelineState *pipeline_state) +{ + FIXME("iface %p, pipeline_state %p stub!\n", iface, pipeline_state); +} + +static void STDMETHODCALLTYPE d3d12_command_list_ResourceBarrier(ID3D12GraphicsCommandList *iface, + UINT barrier_count, const D3D12_RESOURCE_BARRIER *barriers) +{ + FIXME("iface %p, barrier_count %u, barriers %p stub!\n", + iface, barrier_count, barriers); +} + +static void STDMETHODCALLTYPE d3d12_command_list_ExecuteBundle(ID3D12GraphicsCommandList *iface, + ID3D12GraphicsCommandList *command_list) +{ + FIXME("iface %p, command_list %p stub!\n", iface, command_list); +} + +static void STDMETHODCALLTYPE d3d12_command_list_SetDescriptorHeaps(ID3D12GraphicsCommandList *iface, + UINT heap_count, ID3D12DescriptorHeap *const *heaps) +{ + FIXME("iface %p, heap_count %u, heaps %p stub!\n", iface, heap_count, heaps); +} + +static void STDMETHODCALLTYPE d3d12_command_list_SetComputeRootSignature(ID3D12GraphicsCommandList *iface, + ID3D12RootSignature *root_signature) +{ + FIXME("iface %p, root_signature %p stub!\n", iface, root_signature); +} + +static void STDMETHODCALLTYPE d3d12_command_list_SetGraphicsRootSignature(ID3D12GraphicsCommandList *iface, + ID3D12RootSignature *root_signature) +{ + FIXME("iface %p, root_signature %p stub!\n", iface, root_signature); +} + +static void STDMETHODCALLTYPE d3d12_command_list_SetComputeRootDescriptorTable(ID3D12GraphicsCommandList *iface, + UINT root_parameter_index, D3D12_GPU_DESCRIPTOR_HANDLE base_descriptor) +{ + FIXME("iface %p, root_parameter_index %u, base_descriptor %s stub!\n", + iface, root_parameter_index, debugstr_uint64(base_descriptor.ptr)); +} + +static void STDMETHODCALLTYPE d3d12_command_list_SetGraphicsRootDescriptorTable(ID3D12GraphicsCommandList *iface, + UINT root_parameter_index, D3D12_GPU_DESCRIPTOR_HANDLE base_descriptor) +{ + FIXME("iface %p, root_parameter_index %u, base_descriptor %s stub!\n", + iface, root_parameter_index, debugstr_uint64(base_descriptor.ptr)); +} + +static void STDMETHODCALLTYPE d3d12_command_list_SetComputeRoot32BitConstant(ID3D12GraphicsCommandList *iface, + UINT root_parameter_index, UINT data, UINT dst_offset) +{ + FIXME("iface %p, root_parameter_index %u, data 0x%08x, dst_offset %u stub!\n", + iface, root_parameter_index, data, dst_offset); +} + +static void STDMETHODCALLTYPE d3d12_command_list_SetGraphicsRoot32BitConstant(ID3D12GraphicsCommandList *iface, + UINT root_parameter_index, UINT data, UINT dst_offset) +{ + FIXME("iface %p, root_parameter_index %u, data 0x%08x, dst_offset %u stub!\n", + iface, root_parameter_index, data, dst_offset); +} + +static void STDMETHODCALLTYPE d3d12_command_list_SetComputeRoot32BitConstants(ID3D12GraphicsCommandList *iface, + UINT root_parameter_index, UINT constant_count, const void *data, UINT dst_offset) +{ + FIXME("iface %p, root_parameter_index %u, constant_count %u, data %p, dst_offset %u stub!\n", + iface, root_parameter_index, constant_count, data, dst_offset); +} + +static void STDMETHODCALLTYPE d3d12_command_list_SetGraphicsRoot32BitConstants(ID3D12GraphicsCommandList *iface, + UINT root_parameter_index, UINT constant_count, const void *data, UINT dst_offset) +{ + FIXME("iface %p, root_parameter_index %u, constant_count %u, data %p, dst_offset %u stub!\n", + iface, root_parameter_index, constant_count, data, dst_offset); +} + +static void STDMETHODCALLTYPE d3d12_command_list_SetComputeRootConstantBufferView( + ID3D12GraphicsCommandList *iface, UINT root_parameter_index, D3D12_GPU_VIRTUAL_ADDRESS address) +{ + FIXME("iface %p, root_parameter_index %u, address %s stub!\n", + iface, root_parameter_index, debugstr_uint64(address)); +} + +static void STDMETHODCALLTYPE d3d12_command_list_SetGraphicsRootConstantBufferView( + ID3D12GraphicsCommandList *iface, UINT root_parameter_index, D3D12_GPU_VIRTUAL_ADDRESS address) +{ + FIXME("iface %p, root_parameter_index %u, address %s stub!\n", + iface, root_parameter_index, debugstr_uint64(address)); +} + +static void STDMETHODCALLTYPE d3d12_command_list_SetComputeRootShaderResourceView( + ID3D12GraphicsCommandList *iface, UINT root_parameter_index, D3D12_GPU_VIRTUAL_ADDRESS address) +{ + FIXME("iface %p, root_parameter_index %u, address %s stub!\n", + iface, root_parameter_index, debugstr_uint64(address)); +} + +static void STDMETHODCALLTYPE d3d12_command_list_SetGraphicsRootShaderResourceView( + ID3D12GraphicsCommandList *iface, UINT root_parameter_index, D3D12_GPU_VIRTUAL_ADDRESS address) +{ + FIXME("iface %p, root_parameter_index %u, address %s stub!\n", + iface, root_parameter_index, debugstr_uint64(address)); +} + +static void STDMETHODCALLTYPE d3d12_command_list_SetComputeRootUnorderedAccessView( + ID3D12GraphicsCommandList *iface, UINT root_parameter_index, D3D12_GPU_VIRTUAL_ADDRESS address) +{ + FIXME("iface %p, root_parameter_index %u, address %s stub!\n", + iface, root_parameter_index, debugstr_uint64(address)); +} + +static void STDMETHODCALLTYPE d3d12_command_list_SetGraphicsRootUnorderedAccessView( + ID3D12GraphicsCommandList *iface, UINT root_parameter_index, D3D12_GPU_VIRTUAL_ADDRESS address) +{ + FIXME("iface %p, root_parameter_index %u, address %s stub!\n", + iface, root_parameter_index, debugstr_uint64(address)); +} + +static void STDMETHODCALLTYPE d3d12_command_list_IASetIndexBuffer(ID3D12GraphicsCommandList *iface, + const D3D12_INDEX_BUFFER_VIEW *view) +{ + FIXME("iface %p, view %p stub!\n", iface, view); +} + +static void STDMETHODCALLTYPE d3d12_command_list_IASetVertexBuffers(ID3D12GraphicsCommandList *iface, + UINT start_slot, UINT view_count, const D3D12_VERTEX_BUFFER_VIEW *views) +{ + FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n", iface, start_slot, view_count, views); +} + +static void STDMETHODCALLTYPE d3d12_command_list_SOSetTargets(ID3D12GraphicsCommandList *iface, + UINT start_slot, UINT view_count, const D3D12_STREAM_OUTPUT_BUFFER_VIEW *views) +{ + FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n", iface, start_slot, view_count, views); +} + +static void STDMETHODCALLTYPE d3d12_command_list_OMSetRenderTargets(ID3D12GraphicsCommandList *iface, + UINT render_target_descriptor_count, const D3D12_CPU_DESCRIPTOR_HANDLE *render_target_descriptors, + BOOL single_descriptor_handle, const D3D12_CPU_DESCRIPTOR_HANDLE *depth_stencil_descriptor) +{ + FIXME("iface %p, render_target_descriptor_count %u, render_target_descriptors %p, " + "single_descriptor_handle %#x, depth_stencil_descriptor %p stub!\n", + iface, render_target_descriptor_count, render_target_descriptors, + single_descriptor_handle, depth_stencil_descriptor); +} + +static void STDMETHODCALLTYPE d3d12_command_list_ClearDepthStencilView(ID3D12GraphicsCommandList *iface, + D3D12_CPU_DESCRIPTOR_HANDLE dsv, D3D12_CLEAR_FLAGS flags, FLOAT depth, UINT8 stencil, + UINT rect_count, const D3D12_RECT *rects) +{ + FIXME("iface %p, dsv %#lx, flags %#x, depth %.8e, stencil 0x%02x, rect_count %u, rects %p stub!\n", + iface, dsv.ptr, flags, depth, stencil, rect_count, rects); +} + +static void STDMETHODCALLTYPE d3d12_command_list_ClearRenderTargetView(ID3D12GraphicsCommandList *iface, + D3D12_CPU_DESCRIPTOR_HANDLE rtv, const FLOAT color[4], UINT rect_count, const D3D12_RECT *rects) +{ + FIXME("iface %p, rtv %#lx, color %p, rect_count %u, rects %p stub!\n", + iface, rtv.ptr, color, rect_count, rects); +} + +static void STDMETHODCALLTYPE d3d12_command_list_ClearUnorderedAccessViewFloat(ID3D12GraphicsCommandList *iface, + D3D12_GPU_DESCRIPTOR_HANDLE gpu_handle, D3D12_CPU_DESCRIPTOR_HANDLE cpu_handle, + ID3D12Resource *resource, UINT rect_count, const D3D12_RECT *rects) +{ + FIXME("iface %p, gpu_handle %s, cpu_handle %lx, resource %p, rect_count %u, rects %p stub!\n", + iface, debugstr_uint64(gpu_handle.ptr), cpu_handle.ptr, resource, rect_count, rects); +} + +static void STDMETHODCALLTYPE d3d12_command_list_DiscardResource(ID3D12GraphicsCommandList *iface, + ID3D12Resource *resource, const D3D12_DISCARD_REGION *region) +{ + FIXME("iface %p, resource %p, region %p stub!\n", iface, resource, region); +} + +static void STDMETHODCALLTYPE d3d12_command_list_BeginQuery(ID3D12GraphicsCommandList *iface, + ID3D12QueryHeap *heap, D3D12_QUERY_TYPE type, UINT index) +{ + FIXME("iface %p, heap %p, type %#x, index %u stub!\n", iface, heap, type, index); +} + +static void STDMETHODCALLTYPE d3d12_command_list_EndQuery(ID3D12GraphicsCommandList *iface, + ID3D12QueryHeap *heap, D3D12_QUERY_TYPE type, UINT index) +{ + FIXME("iface %p, heap %p, type %#x, index %u stub!\n", iface, heap, type, index); +} + +static void STDMETHODCALLTYPE d3d12_command_list_ResolveQueryData(ID3D12GraphicsCommandList *iface, + ID3D12QueryHeap *heap, D3D12_QUERY_TYPE type, UINT start_index, UINT query_count, + ID3D12Resource *dst_buffer, UINT64 aligned_dst_buffer_offset) +{ + FIXME("iface %p, heap %p, type %#x, start_index %u, query_count %u, " + "dst_buffer %p, aligned_dst_buffer_offset %s stub!\n", + iface, heap, type, start_index, query_count, + dst_buffer, debugstr_uint64(aligned_dst_buffer_offset)); +} + +static void STDMETHODCALLTYPE d3d12_command_list_SetPredication(ID3D12GraphicsCommandList *iface, + ID3D12Resource *buffer, UINT64 aligned_buffer_offset, D3D12_PREDICATION_OP operation) +{ + FIXME("iface %p, buffer %p, aligned_buffer_offset %s, operation %#x stub!\n", + iface, buffer, debugstr_uint64(aligned_buffer_offset), operation); +} + +static void STDMETHODCALLTYPE d3d12_command_list_SetMarker(ID3D12GraphicsCommandList *iface, + UINT metadata, const void *data, UINT size) +{ + FIXME("iface %p, metadata %#x, data %p, size %u stub!\n", iface, metadata, data, size); +} + +static void STDMETHODCALLTYPE d3d12_command_list_BeginEvent(ID3D12GraphicsCommandList *iface, + UINT metadata, const void *data, UINT size) +{ + FIXME("iface %p, metadata %#x, data %p, size %u stub!\n", iface, metadata, data, size); +} + +static void STDMETHODCALLTYPE d3d12_command_list_EndEvent(ID3D12GraphicsCommandList *iface) +{ + FIXME("iface %p stub!\n", iface); +} + +static void STDMETHODCALLTYPE d3d12_command_list_ExecuteIndirect(ID3D12GraphicsCommandList *iface, + ID3D12CommandSignature *command_signature, + UINT max_command_count, ID3D12Resource *arg_buffer, + UINT64 arg_buffer_offset, ID3D12Resource *count_buffer, UINT64 count_buffer_offset) +{ + FIXME("iface %p, command_signature %p, max_command_count %u, arg_buffer %p, " + "arg_buffer_offset %s, count_buffer %p, count_buffer_offset %s stub!\n", + iface, command_signature, max_command_count, arg_buffer, debugstr_uint64(arg_buffer_offset), + count_buffer, debugstr_uint64(count_buffer_offset)); +} + +static const struct ID3D12GraphicsCommandListVtbl d3d12_command_list_vtbl = +{ + /* IUnknown methods */ + d3d12_command_list_QueryInterface, + d3d12_command_list_AddRef, + d3d12_command_list_Release, + /* ID3D12Object methods */ + d3d12_command_list_GetPrivateData, + d3d12_command_list_SetPrivateData, + d3d12_command_list_SetPrivateDataInterface, + d3d12_command_list_SetName, + /* ID3D12DeviceChild methods */ + d3d12_command_list_GetDevice, + /* ID3D12CommandList methods */ + d3d12_command_list_GetType, + /* ID3D12GraphicsCommandList methods */ + d3d12_command_list_Close, + d3d12_command_list_Reset, + d3d12_command_list_ClearState, + d3d12_command_list_DrawInstanced, + d3d12_command_list_DrawIndexedInstanced, + d3d12_command_list_Dispatch, + d3d12_command_list_CopyBufferRegion, + d3d12_command_list_CopyTextureRegion, + d3d12_command_list_CopyResource, + d3d12_command_list_CopyTiles, + d3d12_command_list_ResolveSubresource, + d3d12_command_list_IASetPrimitiveTopology, + d3d12_command_list_RSSetViewports, + d3d12_command_list_RSSetScissorRects, + d3d12_command_list_OMSetBlendFactor, + d3d12_command_list_OMSetStencilRef, + d3d12_command_list_SetPipelineState, + d3d12_command_list_ResourceBarrier, + d3d12_command_list_ExecuteBundle, + d3d12_command_list_SetDescriptorHeaps, + d3d12_command_list_SetComputeRootSignature, + d3d12_command_list_SetGraphicsRootSignature, + d3d12_command_list_SetComputeRootDescriptorTable, + d3d12_command_list_SetGraphicsRootDescriptorTable, + d3d12_command_list_SetComputeRoot32BitConstant, + d3d12_command_list_SetGraphicsRoot32BitConstant, + d3d12_command_list_SetComputeRoot32BitConstants, + d3d12_command_list_SetGraphicsRoot32BitConstants, + d3d12_command_list_SetComputeRootConstantBufferView, + d3d12_command_list_SetGraphicsRootConstantBufferView, + d3d12_command_list_SetComputeRootShaderResourceView, + d3d12_command_list_SetGraphicsRootShaderResourceView, + d3d12_command_list_SetComputeRootUnorderedAccessView, + d3d12_command_list_SetGraphicsRootUnorderedAccessView, + d3d12_command_list_IASetIndexBuffer, + d3d12_command_list_IASetVertexBuffers, + d3d12_command_list_SOSetTargets, + d3d12_command_list_OMSetRenderTargets, + d3d12_command_list_ClearDepthStencilView, + d3d12_command_list_ClearRenderTargetView, + d3d12_command_list_ClearUnorderedAccessViewFloat, + d3d12_command_list_DiscardResource, + d3d12_command_list_BeginQuery, + d3d12_command_list_EndQuery, + d3d12_command_list_ResolveQueryData, + d3d12_command_list_SetPredication, + d3d12_command_list_SetMarker, + d3d12_command_list_BeginEvent, + d3d12_command_list_EndEvent, + d3d12_command_list_ExecuteIndirect, +}; + +static void d3d12_command_list_init(struct d3d12_command_list *list, struct d3d12_device *device, + D3D12_COMMAND_LIST_TYPE type, struct d3d12_command_allocator *allocator, + ID3D12PipelineState *initial_pipeline_state) +{ + list->ID3D12GraphicsCommandList_iface.lpVtbl = &d3d12_command_list_vtbl; + list->refcount = 1; + + list->type = type; + + if (initial_pipeline_state) + FIXME("Ignoring initial pipeline state %p.\n", initial_pipeline_state); + + list->device = device; + ID3D12Device_AddRef(&device->ID3D12Device_iface); +} + +HRESULT d3d12_command_list_create(struct d3d12_device *device, + UINT node_mask, D3D12_COMMAND_LIST_TYPE type, ID3D12CommandAllocator *allocator_iface, + ID3D12PipelineState *initial_pipeline_state, struct d3d12_command_list **list) +{ + struct d3d12_command_allocator *allocator; + struct d3d12_command_list *object; + + if (!(allocator = unsafe_impl_from_ID3D12CommandAllocator(allocator_iface))) + { + WARN("Command allocator is NULL.\n"); + return E_INVALIDARG; + } + + if (allocator->type != type) + { + WARN("Command list types do not match (allocator %#x, list %#x).\n", + allocator->type, type); + return E_INVALIDARG; + } + + if (node_mask && node_mask != 1) + FIXME("Multi-adapter not supported.\n"); + + if (!(object = vkd3d_malloc(sizeof(*object)))) + return E_OUTOFMEMORY; + + d3d12_command_list_init(object, device, type, allocator, initial_pipeline_state); + + TRACE("Created command list %p.\n", object); + + *list = object; + + return S_OK; +} + /* ID3D12CommandQueue */ static inline struct d3d12_command_queue *impl_from_ID3D12CommandQueue(ID3D12CommandQueue *iface) { diff --git a/libs/vkd3d/device.c b/libs/vkd3d/device.c index 0c80089e..e775d1d5 100644 --- a/libs/vkd3d/device.c +++ b/libs/vkd3d/device.c @@ -167,12 +167,21 @@ static HRESULT STDMETHODCALLTYPE d3d12_device_CreateCommandList(ID3D12Device *if UINT node_mask, D3D12_COMMAND_LIST_TYPE type, ID3D12CommandAllocator *command_allocator, ID3D12PipelineState *initial_pipeline_state, REFIID riid, void **command_list) { - FIXME("iface %p, node_mask 0x%08x, type %#x, command_allocator %p, " - "initial_pipeline_state %p, riid %s, command_list %p stub!\n", + struct d3d12_device *device = impl_from_ID3D12Device(iface); + struct d3d12_command_list *object; + HRESULT hr; + + TRACE("iface %p, node_mask 0x%08x, type %#x, command_allocator %p, " + "initial_pipeline_state %p, riid %s, command_list %p.\n", iface, node_mask, type, command_allocator, initial_pipeline_state, debugstr_guid(riid), command_list); - return E_NOTIMPL; + if (FAILED(hr = d3d12_command_list_create(device, node_mask, type, command_allocator, + initial_pipeline_state, &object))) + return hr; + + return return_interface((IUnknown *)&object->ID3D12GraphicsCommandList_iface, + &IID_ID3D12GraphicsCommandList, riid, command_list); } static HRESULT STDMETHODCALLTYPE d3d12_device_CheckFeatureSupport(ID3D12Device *iface, diff --git a/libs/vkd3d/vkd3d_private.h b/libs/vkd3d/vkd3d_private.h index 9e873fe7..3b919658 100644 --- a/libs/vkd3d/vkd3d_private.h +++ b/libs/vkd3d/vkd3d_private.h @@ -47,6 +47,21 @@ struct d3d12_command_allocator HRESULT d3d12_command_allocator_create(struct d3d12_device *device, D3D12_COMMAND_LIST_TYPE type, struct d3d12_command_allocator **allocator) DECLSPEC_HIDDEN; +/* ID3D12CommandList */ +struct d3d12_command_list +{ + ID3D12GraphicsCommandList ID3D12GraphicsCommandList_iface; + ULONG refcount; + + D3D12_COMMAND_LIST_TYPE type; + + struct d3d12_device *device; +}; + +HRESULT d3d12_command_list_create(struct d3d12_device *device, + UINT node_mask, D3D12_COMMAND_LIST_TYPE type, ID3D12CommandAllocator *allocator_iface, + ID3D12PipelineState *initial_pipeline_state, struct d3d12_command_list **list) DECLSPEC_HIDDEN; + /* ID3D12CommandQueue */ struct d3d12_command_queue {