1 /* RetroArch - A frontend for libretro.
2 * Copyright (C) 2014-2018 - Ali Bouhlel
3 * Copyright (C) 2016-2019 - Brad Parker
4 *
5 * RetroArch is free software: you can redistribute it and/or modify it under the terms
6 * of the GNU General Public License as published by the Free Software Found-
7 * ation, either version 3 of the License, or (at your option) any later version.
8 *
9 * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11 * PURPOSE. See the GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along with RetroArch.
14 * If not, see <http://www.gnu.org/licenses/>.
15 */
16
17 #pragma once
18
19 #include <retro_inline.h>
20
21 #include "dxgi_common.h"
22 #include <d3d12.h>
23
24 typedef const ID3D12PipelineState* D3D12PipelineStateRef;
25
26 /* auto-generated */
27
28 typedef ID3D12Object* D3D12Object;
29 typedef ID3D12DeviceChild* D3D12DeviceChild;
30 typedef ID3D12RootSignature* D3D12RootSignature;
31 typedef ID3D12RootSignatureDeserializer* D3D12RootSignatureDeserializer;
32 typedef ID3D12VersionedRootSignatureDeserializer* D3D12VersionedRootSignatureDeserializer;
33 typedef ID3D12Pageable* D3D12Pageable;
34 typedef ID3D12Heap* D3D12Heap;
35 typedef ID3D12Resource* D3D12Resource;
36 typedef ID3D12CommandAllocator* D3D12CommandAllocator;
37 typedef ID3D12Fence* D3D12Fence;
38 typedef ID3D12PipelineState* D3D12PipelineState;
39 typedef ID3D12DescriptorHeap* D3D12DescriptorHeap;
40 typedef ID3D12QueryHeap* D3D12QueryHeap;
41 typedef ID3D12CommandSignature* D3D12CommandSignature;
42 typedef ID3D12CommandList* D3D12CommandList;
43 typedef ID3D12GraphicsCommandList* D3D12GraphicsCommandList;
44 typedef ID3D12CommandQueue* D3D12CommandQueue;
45 typedef ID3D12Device* D3D12Device;
46 typedef ID3D12PipelineLibrary* D3D12PipelineLibrary;
47 #ifdef DEBUG
48 typedef ID3D12Debug* D3D12Debug;
49 typedef ID3D12DebugDevice* D3D12DebugDevice;
50 typedef ID3D12DebugCommandQueue* D3D12DebugCommandQueue;
51 typedef ID3D12DebugCommandList* D3D12DebugCommandList;
52 #endif
53 typedef ID3D12InfoQueue* D3D12InfoQueue;
54
D3D12Release(void * object)55 static INLINE ULONG D3D12Release(void* object)
56 {
57 return ((ID3D12Object*)object)->lpVtbl->Release((ID3D12Object*)object);
58 }
D3D12ReleaseDeviceChild(D3D12DeviceChild device_child)59 static INLINE ULONG D3D12ReleaseDeviceChild(D3D12DeviceChild device_child)
60 {
61 return device_child->lpVtbl->Release(device_child);
62 }
D3D12ReleaseRootSignature(D3D12RootSignature root_signature)63 static INLINE ULONG D3D12ReleaseRootSignature(D3D12RootSignature root_signature)
64 {
65 return root_signature->lpVtbl->Release(root_signature);
66 }
67 static INLINE ULONG
D3D12ReleaseRootSignatureDeserializer(D3D12RootSignatureDeserializer root_signature_deserializer)68 D3D12ReleaseRootSignatureDeserializer(D3D12RootSignatureDeserializer root_signature_deserializer)
69 {
70 return root_signature_deserializer->lpVtbl->Release(root_signature_deserializer);
71 }
72 static INLINE const D3D12_ROOT_SIGNATURE_DESC*
D3D12GetRootSignatureDesc(D3D12RootSignatureDeserializer root_signature_deserializer)73 D3D12GetRootSignatureDesc(D3D12RootSignatureDeserializer root_signature_deserializer)
74 {
75 return root_signature_deserializer->lpVtbl->GetRootSignatureDesc(root_signature_deserializer);
76 }
D3D12ReleaseVersionedRootSignatureDeserializer(D3D12VersionedRootSignatureDeserializer versioned_root_signature_deserializer)77 static INLINE ULONG D3D12ReleaseVersionedRootSignatureDeserializer(
78 D3D12VersionedRootSignatureDeserializer versioned_root_signature_deserializer)
79 {
80 return versioned_root_signature_deserializer->lpVtbl->Release(
81 versioned_root_signature_deserializer);
82 }
D3D12GetRootSignatureDescAtVersion(D3D12VersionedRootSignatureDeserializer versioned_root_signature_deserializer,D3D_ROOT_SIGNATURE_VERSION convert_to_version,const D3D12_VERSIONED_ROOT_SIGNATURE_DESC ** desc)83 static INLINE HRESULT D3D12GetRootSignatureDescAtVersion(
84 D3D12VersionedRootSignatureDeserializer versioned_root_signature_deserializer,
85 D3D_ROOT_SIGNATURE_VERSION convert_to_version,
86 const D3D12_VERSIONED_ROOT_SIGNATURE_DESC** desc)
87 {
88 return versioned_root_signature_deserializer->lpVtbl->GetRootSignatureDescAtVersion(
89 versioned_root_signature_deserializer, convert_to_version, desc);
90 }
D3D12GetUnconvertedRootSignatureDesc(D3D12VersionedRootSignatureDeserializer versioned_root_signature_deserializer)91 static INLINE const D3D12_VERSIONED_ROOT_SIGNATURE_DESC* D3D12GetUnconvertedRootSignatureDesc(
92 D3D12VersionedRootSignatureDeserializer versioned_root_signature_deserializer)
93 {
94 return versioned_root_signature_deserializer->lpVtbl->GetUnconvertedRootSignatureDesc(
95 versioned_root_signature_deserializer);
96 }
D3D12ReleasePageable(D3D12Pageable pageable)97 static INLINE ULONG D3D12ReleasePageable(D3D12Pageable pageable)
98 {
99 return pageable->lpVtbl->Release(pageable);
100 }
D3D12ReleaseHeap(D3D12Heap heap)101 static INLINE ULONG D3D12ReleaseHeap(D3D12Heap heap) { return heap->lpVtbl->Release(heap); }
D3D12ReleaseResource(void * resource)102 static INLINE ULONG D3D12ReleaseResource(void* resource)
103 {
104 return ((ID3D12Resource*)resource)->lpVtbl->Release((ID3D12Resource*)resource);
105 }
106 static INLINE HRESULT
D3D12Map(void * resource,UINT subresource,D3D12_RANGE * read_range,void ** data)107 D3D12Map(void* resource, UINT subresource, D3D12_RANGE* read_range, void** data)
108 {
109 return ((ID3D12Resource*)resource)
110 ->lpVtbl->Map((ID3D12Resource*)resource, subresource, read_range, data);
111 }
D3D12Unmap(void * resource,UINT subresource,D3D12_RANGE * written_range)112 static INLINE void D3D12Unmap(void* resource, UINT subresource, D3D12_RANGE* written_range)
113 {
114 ((ID3D12Resource*)resource)
115 ->lpVtbl->Unmap((ID3D12Resource*)resource, subresource, written_range);
116 }
D3D12GetGPUVirtualAddress(void * resource)117 static INLINE D3D12_GPU_VIRTUAL_ADDRESS D3D12GetGPUVirtualAddress(void* resource)
118 {
119 return ((ID3D12Resource*)resource)->lpVtbl->GetGPUVirtualAddress((ID3D12Resource*)resource);
120 }
D3D12WriteToSubresource(void * resource,UINT dst_subresource,D3D12_BOX * dst_box,void * src_data,UINT src_row_pitch,UINT src_depth_pitch)121 static INLINE HRESULT D3D12WriteToSubresource(
122 void* resource,
123 UINT dst_subresource,
124 D3D12_BOX* dst_box,
125 void* src_data,
126 UINT src_row_pitch,
127 UINT src_depth_pitch)
128 {
129 return ((ID3D12Resource*)resource)
130 ->lpVtbl->WriteToSubresource(
131 (ID3D12Resource*)resource, dst_subresource, dst_box, src_data, src_row_pitch,
132 src_depth_pitch);
133 }
D3D12ReadFromSubresource(void * resource,void * dst_data,UINT dst_row_pitch,UINT dst_depth_pitch,UINT src_subresource,D3D12_BOX * src_box)134 static INLINE HRESULT D3D12ReadFromSubresource(
135 void* resource,
136 void* dst_data,
137 UINT dst_row_pitch,
138 UINT dst_depth_pitch,
139 UINT src_subresource,
140 D3D12_BOX* src_box)
141 {
142 return ((ID3D12Resource*)resource)
143 ->lpVtbl->ReadFromSubresource(
144 (ID3D12Resource*)resource, dst_data, dst_row_pitch, dst_depth_pitch, src_subresource,
145 src_box);
146 }
D3D12GetHeapProperties(void * resource,D3D12_HEAP_PROPERTIES * heap_properties,D3D12_HEAP_FLAGS * heap_flags)147 static INLINE HRESULT D3D12GetHeapProperties(
148 void* resource, D3D12_HEAP_PROPERTIES* heap_properties, D3D12_HEAP_FLAGS* heap_flags)
149 {
150 return ((ID3D12Resource*)resource)
151 ->lpVtbl->GetHeapProperties((ID3D12Resource*)resource, heap_properties, heap_flags);
152 }
D3D12ReleaseCommandAllocator(D3D12CommandAllocator command_allocator)153 static INLINE ULONG D3D12ReleaseCommandAllocator(D3D12CommandAllocator command_allocator)
154 {
155 return command_allocator->lpVtbl->Release(command_allocator);
156 }
D3D12ResetCommandAllocator(D3D12CommandAllocator command_allocator)157 static INLINE HRESULT D3D12ResetCommandAllocator(D3D12CommandAllocator command_allocator)
158 {
159 return command_allocator->lpVtbl->Reset(command_allocator);
160 }
D3D12ReleaseFence(D3D12Fence fence)161 static INLINE ULONG D3D12ReleaseFence(D3D12Fence fence) { return fence->lpVtbl->Release(fence); }
D3D12GetCompletedValue(D3D12Fence fence)162 static INLINE UINT64 D3D12GetCompletedValue(D3D12Fence fence)
163 {
164 return fence->lpVtbl->GetCompletedValue(fence);
165 }
D3D12SetEventOnCompletion(D3D12Fence fence,UINT64 value,HANDLE h_event)166 static INLINE HRESULT D3D12SetEventOnCompletion(D3D12Fence fence, UINT64 value, HANDLE h_event)
167 {
168 return fence->lpVtbl->SetEventOnCompletion(fence, value, h_event);
169 }
D3D12SignalFence(D3D12Fence fence,UINT64 value)170 static INLINE HRESULT D3D12SignalFence(D3D12Fence fence, UINT64 value)
171 {
172 return fence->lpVtbl->Signal(fence, value);
173 }
D3D12ReleasePipelineState(D3D12PipelineState pipeline_state)174 static INLINE ULONG D3D12ReleasePipelineState(D3D12PipelineState pipeline_state)
175 {
176 return pipeline_state->lpVtbl->Release(pipeline_state);
177 }
D3D12GetCachedBlob(D3D12PipelineState pipeline_state,ID3DBlob ** blob)178 static INLINE HRESULT D3D12GetCachedBlob(D3D12PipelineState pipeline_state, ID3DBlob** blob)
179 {
180 return pipeline_state->lpVtbl->GetCachedBlob(pipeline_state, blob);
181 }
D3D12ReleaseDescriptorHeap(D3D12DescriptorHeap descriptor_heap)182 static INLINE ULONG D3D12ReleaseDescriptorHeap(D3D12DescriptorHeap descriptor_heap)
183 {
184 return descriptor_heap->lpVtbl->Release(descriptor_heap);
185 }
D3D12ReleaseQueryHeap(D3D12QueryHeap query_heap)186 static INLINE ULONG D3D12ReleaseQueryHeap(D3D12QueryHeap query_heap)
187 {
188 return query_heap->lpVtbl->Release(query_heap);
189 }
D3D12ReleaseCommandSignature(D3D12CommandSignature command_signature)190 static INLINE ULONG D3D12ReleaseCommandSignature(D3D12CommandSignature command_signature)
191 {
192 return command_signature->lpVtbl->Release(command_signature);
193 }
D3D12ReleaseCommandList(D3D12CommandList command_list)194 static INLINE ULONG D3D12ReleaseCommandList(D3D12CommandList command_list)
195 {
196 return command_list->lpVtbl->Release(command_list);
197 }
D3D12ReleaseGraphicsCommandList(D3D12GraphicsCommandList graphics_command_list)198 static INLINE ULONG D3D12ReleaseGraphicsCommandList(D3D12GraphicsCommandList graphics_command_list)
199 {
200 return graphics_command_list->lpVtbl->Release(graphics_command_list);
201 }
D3D12CloseGraphicsCommandList(D3D12GraphicsCommandList graphics_command_list)202 static INLINE HRESULT D3D12CloseGraphicsCommandList(D3D12GraphicsCommandList graphics_command_list)
203 {
204 return graphics_command_list->lpVtbl->Close(graphics_command_list);
205 }
D3D12ResetGraphicsCommandList(D3D12GraphicsCommandList graphics_command_list,D3D12CommandAllocator allocator,D3D12PipelineState initial_state)206 static INLINE HRESULT D3D12ResetGraphicsCommandList(
207 D3D12GraphicsCommandList graphics_command_list,
208 D3D12CommandAllocator allocator,
209 D3D12PipelineState initial_state)
210 {
211 return graphics_command_list->lpVtbl->Reset(graphics_command_list, allocator, initial_state);
212 }
213 static INLINE void
D3D12ClearState(D3D12GraphicsCommandList graphics_command_list,D3D12PipelineState pipeline_state)214 D3D12ClearState(D3D12GraphicsCommandList graphics_command_list, D3D12PipelineState pipeline_state)
215 {
216 graphics_command_list->lpVtbl->ClearState(graphics_command_list, pipeline_state);
217 }
D3D12DrawInstanced(D3D12GraphicsCommandList graphics_command_list,UINT vertex_count_per_instance,UINT instance_count,UINT start_vertex_location,UINT start_instance_location)218 static INLINE void D3D12DrawInstanced(
219 D3D12GraphicsCommandList graphics_command_list,
220 UINT vertex_count_per_instance,
221 UINT instance_count,
222 UINT start_vertex_location,
223 UINT start_instance_location)
224 {
225 graphics_command_list->lpVtbl->DrawInstanced(
226 graphics_command_list, vertex_count_per_instance, instance_count, start_vertex_location,
227 start_instance_location);
228 }
D3D12DrawIndexedInstanced(D3D12GraphicsCommandList graphics_command_list,UINT index_count_per_instance,UINT instance_count,UINT start_index_location,INT base_vertex_location,UINT start_instance_location)229 static INLINE void D3D12DrawIndexedInstanced(
230 D3D12GraphicsCommandList graphics_command_list,
231 UINT index_count_per_instance,
232 UINT instance_count,
233 UINT start_index_location,
234 INT base_vertex_location,
235 UINT start_instance_location)
236 {
237 graphics_command_list->lpVtbl->DrawIndexedInstanced(
238 graphics_command_list, index_count_per_instance, instance_count, start_index_location,
239 base_vertex_location, start_instance_location);
240 }
D3D12Dispatch(D3D12GraphicsCommandList graphics_command_list,UINT thread_group_count_x,UINT thread_group_count_y,UINT thread_group_count_z)241 static INLINE void D3D12Dispatch(
242 D3D12GraphicsCommandList graphics_command_list,
243 UINT thread_group_count_x,
244 UINT thread_group_count_y,
245 UINT thread_group_count_z)
246 {
247 graphics_command_list->lpVtbl->Dispatch(
248 graphics_command_list, thread_group_count_x, thread_group_count_y, thread_group_count_z);
249 }
D3D12CopyBufferRegion(D3D12GraphicsCommandList graphics_command_list,D3D12Resource dst_buffer,UINT64 dst_offset,D3D12Resource src_buffer,UINT64 src_offset,UINT64 num_bytes)250 static INLINE void D3D12CopyBufferRegion(
251 D3D12GraphicsCommandList graphics_command_list,
252 D3D12Resource dst_buffer,
253 UINT64 dst_offset,
254 D3D12Resource src_buffer,
255 UINT64 src_offset,
256 UINT64 num_bytes)
257 {
258 graphics_command_list->lpVtbl->CopyBufferRegion(
259 graphics_command_list, dst_buffer, dst_offset, (ID3D12Resource*)src_buffer, src_offset,
260 num_bytes);
261 }
D3D12CopyTextureRegion(D3D12GraphicsCommandList graphics_command_list,D3D12_TEXTURE_COPY_LOCATION * dst,UINT dst_x,UINT dst_y,UINT dst_z,D3D12_TEXTURE_COPY_LOCATION * src,D3D12_BOX * src_box)262 static INLINE void D3D12CopyTextureRegion(
263 D3D12GraphicsCommandList graphics_command_list,
264 D3D12_TEXTURE_COPY_LOCATION* dst,
265 UINT dst_x,
266 UINT dst_y,
267 UINT dst_z,
268 D3D12_TEXTURE_COPY_LOCATION* src,
269 D3D12_BOX* src_box)
270 {
271 graphics_command_list->lpVtbl->CopyTextureRegion(
272 graphics_command_list, dst, dst_x, dst_y, dst_z, src, src_box);
273 }
D3D12CopyResource(D3D12GraphicsCommandList graphics_command_list,void * dst_resource,void * src_resource)274 static INLINE void D3D12CopyResource(
275 D3D12GraphicsCommandList graphics_command_list, void* dst_resource, void* src_resource)
276 {
277 graphics_command_list->lpVtbl->CopyResource(
278 graphics_command_list, (ID3D12Resource*)dst_resource, (ID3D12Resource*)src_resource);
279 }
D3D12CopyTiles(D3D12GraphicsCommandList graphics_command_list,void * tiled_resource,D3D12_TILED_RESOURCE_COORDINATE * tile_region_start_coordinate,D3D12_TILE_REGION_SIZE * tile_region_size,void * buffer,UINT64 buffer_start_offset_in_bytes,D3D12_TILE_COPY_FLAGS flags)280 static INLINE void D3D12CopyTiles(
281 D3D12GraphicsCommandList graphics_command_list,
282 void* tiled_resource,
283 D3D12_TILED_RESOURCE_COORDINATE* tile_region_start_coordinate,
284 D3D12_TILE_REGION_SIZE* tile_region_size,
285 void* buffer,
286 UINT64 buffer_start_offset_in_bytes,
287 D3D12_TILE_COPY_FLAGS flags)
288 {
289 graphics_command_list->lpVtbl->CopyTiles(
290 graphics_command_list, (ID3D12Resource*)tiled_resource, tile_region_start_coordinate,
291 tile_region_size, (ID3D12Resource*)buffer, buffer_start_offset_in_bytes, flags);
292 }
D3D12ResolveSubresource(D3D12GraphicsCommandList graphics_command_list,void * dst_resource,UINT dst_subresource,void * src_resource,UINT src_subresource,DXGI_FORMAT format)293 static INLINE void D3D12ResolveSubresource(
294 D3D12GraphicsCommandList graphics_command_list,
295 void* dst_resource,
296 UINT dst_subresource,
297 void* src_resource,
298 UINT src_subresource,
299 DXGI_FORMAT format)
300 {
301 graphics_command_list->lpVtbl->ResolveSubresource(
302 graphics_command_list, (ID3D12Resource*)dst_resource, dst_subresource,
303 (ID3D12Resource*)src_resource, src_subresource, format);
304 }
D3D12IASetPrimitiveTopology(D3D12GraphicsCommandList graphics_command_list,D3D12_PRIMITIVE_TOPOLOGY primitive_topology)305 static INLINE void D3D12IASetPrimitiveTopology(
306 D3D12GraphicsCommandList graphics_command_list, D3D12_PRIMITIVE_TOPOLOGY primitive_topology)
307 {
308 graphics_command_list->lpVtbl->IASetPrimitiveTopology(graphics_command_list, primitive_topology);
309 }
D3D12RSSetViewports(D3D12GraphicsCommandList graphics_command_list,UINT num_viewports,D3D12_VIEWPORT * viewports)310 static INLINE void D3D12RSSetViewports(
311 D3D12GraphicsCommandList graphics_command_list, UINT num_viewports, D3D12_VIEWPORT* viewports)
312 {
313 graphics_command_list->lpVtbl->RSSetViewports(graphics_command_list, num_viewports, viewports);
314 }
D3D12RSSetScissorRects(D3D12GraphicsCommandList graphics_command_list,UINT num_rects,D3D12_RECT * rects)315 static INLINE void D3D12RSSetScissorRects(
316 D3D12GraphicsCommandList graphics_command_list, UINT num_rects, D3D12_RECT* rects)
317 {
318 graphics_command_list->lpVtbl->RSSetScissorRects(graphics_command_list, num_rects, rects);
319 }
320 static INLINE void
D3D12OMSetStencilRef(D3D12GraphicsCommandList graphics_command_list,UINT stencil_ref)321 D3D12OMSetStencilRef(D3D12GraphicsCommandList graphics_command_list, UINT stencil_ref)
322 {
323 graphics_command_list->lpVtbl->OMSetStencilRef(graphics_command_list, stencil_ref);
324 }
D3D12SetPipelineState(D3D12GraphicsCommandList graphics_command_list,D3D12PipelineStateRef pipeline_state)325 static INLINE void D3D12SetPipelineState(
326 D3D12GraphicsCommandList graphics_command_list, D3D12PipelineStateRef pipeline_state)
327 {
328 graphics_command_list->lpVtbl->SetPipelineState(graphics_command_list, (D3D12PipelineState)pipeline_state);
329 }
D3D12ResourceBarrier(D3D12GraphicsCommandList graphics_command_list,UINT num_barriers,D3D12_RESOURCE_BARRIER * barriers)330 static INLINE void D3D12ResourceBarrier(
331 D3D12GraphicsCommandList graphics_command_list,
332 UINT num_barriers,
333 D3D12_RESOURCE_BARRIER* barriers)
334 {
335 graphics_command_list->lpVtbl->ResourceBarrier(graphics_command_list, num_barriers, barriers);
336 }
D3D12ExecuteBundle(D3D12GraphicsCommandList graphics_command_list,D3D12GraphicsCommandList command_list)337 static INLINE void D3D12ExecuteBundle(
338 D3D12GraphicsCommandList graphics_command_list, D3D12GraphicsCommandList command_list)
339 {
340 graphics_command_list->lpVtbl->ExecuteBundle(graphics_command_list, command_list);
341 }
D3D12SetComputeRootSignature(D3D12GraphicsCommandList graphics_command_list,D3D12RootSignature root_signature)342 static INLINE void D3D12SetComputeRootSignature(
343 D3D12GraphicsCommandList graphics_command_list, D3D12RootSignature root_signature)
344 {
345 graphics_command_list->lpVtbl->SetComputeRootSignature(graphics_command_list, root_signature);
346 }
D3D12SetGraphicsRootSignature(D3D12GraphicsCommandList graphics_command_list,D3D12RootSignature root_signature)347 static INLINE void D3D12SetGraphicsRootSignature(
348 D3D12GraphicsCommandList graphics_command_list, D3D12RootSignature root_signature)
349 {
350 graphics_command_list->lpVtbl->SetGraphicsRootSignature(graphics_command_list, root_signature);
351 }
D3D12SetComputeRootDescriptorTable(D3D12GraphicsCommandList graphics_command_list,UINT root_parameter_index,D3D12_GPU_DESCRIPTOR_HANDLE base_descriptor)352 static INLINE void D3D12SetComputeRootDescriptorTable(
353 D3D12GraphicsCommandList graphics_command_list,
354 UINT root_parameter_index,
355 D3D12_GPU_DESCRIPTOR_HANDLE base_descriptor)
356 {
357 graphics_command_list->lpVtbl->SetComputeRootDescriptorTable(
358 graphics_command_list, root_parameter_index, base_descriptor);
359 }
D3D12SetGraphicsRootDescriptorTable(D3D12GraphicsCommandList graphics_command_list,UINT root_parameter_index,D3D12_GPU_DESCRIPTOR_HANDLE base_descriptor)360 static INLINE void D3D12SetGraphicsRootDescriptorTable(
361 D3D12GraphicsCommandList graphics_command_list,
362 UINT root_parameter_index,
363 D3D12_GPU_DESCRIPTOR_HANDLE base_descriptor)
364 {
365 graphics_command_list->lpVtbl->SetGraphicsRootDescriptorTable(
366 graphics_command_list, root_parameter_index, base_descriptor);
367 }
D3D12SetComputeRoot32BitConstant(D3D12GraphicsCommandList graphics_command_list,UINT root_parameter_index,UINT src_data,UINT dest_offset_in32_bit_values)368 static INLINE void D3D12SetComputeRoot32BitConstant(
369 D3D12GraphicsCommandList graphics_command_list,
370 UINT root_parameter_index,
371 UINT src_data,
372 UINT dest_offset_in32_bit_values)
373 {
374 graphics_command_list->lpVtbl->SetComputeRoot32BitConstant(
375 graphics_command_list, root_parameter_index, src_data, dest_offset_in32_bit_values);
376 }
D3D12SetGraphicsRoot32BitConstant(D3D12GraphicsCommandList graphics_command_list,UINT root_parameter_index,UINT src_data,UINT dest_offset_in32_bit_values)377 static INLINE void D3D12SetGraphicsRoot32BitConstant(
378 D3D12GraphicsCommandList graphics_command_list,
379 UINT root_parameter_index,
380 UINT src_data,
381 UINT dest_offset_in32_bit_values)
382 {
383 graphics_command_list->lpVtbl->SetGraphicsRoot32BitConstant(
384 graphics_command_list, root_parameter_index, src_data, dest_offset_in32_bit_values);
385 }
D3D12SetComputeRoot32BitConstants(D3D12GraphicsCommandList graphics_command_list,UINT root_parameter_index,UINT num32_bit_values_to_set,void * src_data,UINT dest_offset_in32_bit_values)386 static INLINE void D3D12SetComputeRoot32BitConstants(
387 D3D12GraphicsCommandList graphics_command_list,
388 UINT root_parameter_index,
389 UINT num32_bit_values_to_set,
390 void* src_data,
391 UINT dest_offset_in32_bit_values)
392 {
393 graphics_command_list->lpVtbl->SetComputeRoot32BitConstants(
394 graphics_command_list, root_parameter_index, num32_bit_values_to_set, src_data,
395 dest_offset_in32_bit_values);
396 }
D3D12SetGraphicsRoot32BitConstants(D3D12GraphicsCommandList graphics_command_list,UINT root_parameter_index,UINT num32_bit_values_to_set,void * src_data,UINT dest_offset_in32_bit_values)397 static INLINE void D3D12SetGraphicsRoot32BitConstants(
398 D3D12GraphicsCommandList graphics_command_list,
399 UINT root_parameter_index,
400 UINT num32_bit_values_to_set,
401 void* src_data,
402 UINT dest_offset_in32_bit_values)
403 {
404 graphics_command_list->lpVtbl->SetGraphicsRoot32BitConstants(
405 graphics_command_list, root_parameter_index, num32_bit_values_to_set, src_data,
406 dest_offset_in32_bit_values);
407 }
D3D12SetComputeRootConstantBufferView(D3D12GraphicsCommandList graphics_command_list,UINT root_parameter_index,D3D12_GPU_VIRTUAL_ADDRESS buffer_location)408 static INLINE void D3D12SetComputeRootConstantBufferView(
409 D3D12GraphicsCommandList graphics_command_list,
410 UINT root_parameter_index,
411 D3D12_GPU_VIRTUAL_ADDRESS buffer_location)
412 {
413 graphics_command_list->lpVtbl->SetComputeRootConstantBufferView(
414 graphics_command_list, root_parameter_index, buffer_location);
415 }
D3D12SetGraphicsRootConstantBufferView(D3D12GraphicsCommandList graphics_command_list,UINT root_parameter_index,D3D12_GPU_VIRTUAL_ADDRESS buffer_location)416 static INLINE void D3D12SetGraphicsRootConstantBufferView(
417 D3D12GraphicsCommandList graphics_command_list,
418 UINT root_parameter_index,
419 D3D12_GPU_VIRTUAL_ADDRESS buffer_location)
420 {
421 graphics_command_list->lpVtbl->SetGraphicsRootConstantBufferView(
422 graphics_command_list, root_parameter_index, buffer_location);
423 }
D3D12SetComputeRootShaderResourceView(D3D12GraphicsCommandList graphics_command_list,UINT root_parameter_index,D3D12_GPU_VIRTUAL_ADDRESS buffer_location)424 static INLINE void D3D12SetComputeRootShaderResourceView(
425 D3D12GraphicsCommandList graphics_command_list,
426 UINT root_parameter_index,
427 D3D12_GPU_VIRTUAL_ADDRESS buffer_location)
428 {
429 graphics_command_list->lpVtbl->SetComputeRootShaderResourceView(
430 graphics_command_list, root_parameter_index, buffer_location);
431 }
D3D12SetGraphicsRootShaderResourceView(D3D12GraphicsCommandList graphics_command_list,UINT root_parameter_index,D3D12_GPU_VIRTUAL_ADDRESS buffer_location)432 static INLINE void D3D12SetGraphicsRootShaderResourceView(
433 D3D12GraphicsCommandList graphics_command_list,
434 UINT root_parameter_index,
435 D3D12_GPU_VIRTUAL_ADDRESS buffer_location)
436 {
437 graphics_command_list->lpVtbl->SetGraphicsRootShaderResourceView(
438 graphics_command_list, root_parameter_index, buffer_location);
439 }
D3D12SetComputeRootUnorderedAccessView(D3D12GraphicsCommandList graphics_command_list,UINT root_parameter_index,D3D12_GPU_VIRTUAL_ADDRESS buffer_location)440 static INLINE void D3D12SetComputeRootUnorderedAccessView(
441 D3D12GraphicsCommandList graphics_command_list,
442 UINT root_parameter_index,
443 D3D12_GPU_VIRTUAL_ADDRESS buffer_location)
444 {
445 graphics_command_list->lpVtbl->SetComputeRootUnorderedAccessView(
446 graphics_command_list, root_parameter_index, buffer_location);
447 }
D3D12SetGraphicsRootUnorderedAccessView(D3D12GraphicsCommandList graphics_command_list,UINT root_parameter_index,D3D12_GPU_VIRTUAL_ADDRESS buffer_location)448 static INLINE void D3D12SetGraphicsRootUnorderedAccessView(
449 D3D12GraphicsCommandList graphics_command_list,
450 UINT root_parameter_index,
451 D3D12_GPU_VIRTUAL_ADDRESS buffer_location)
452 {
453 graphics_command_list->lpVtbl->SetGraphicsRootUnorderedAccessView(
454 graphics_command_list, root_parameter_index, buffer_location);
455 }
456 static INLINE void
D3D12IASetIndexBuffer(D3D12GraphicsCommandList graphics_command_list,D3D12_INDEX_BUFFER_VIEW * view)457 D3D12IASetIndexBuffer(D3D12GraphicsCommandList graphics_command_list, D3D12_INDEX_BUFFER_VIEW* view)
458 {
459 graphics_command_list->lpVtbl->IASetIndexBuffer(graphics_command_list, view);
460 }
D3D12IASetVertexBuffers(D3D12GraphicsCommandList graphics_command_list,UINT start_slot,UINT num_views,D3D12_VERTEX_BUFFER_VIEW * views)461 static INLINE void D3D12IASetVertexBuffers(
462 D3D12GraphicsCommandList graphics_command_list,
463 UINT start_slot,
464 UINT num_views,
465 D3D12_VERTEX_BUFFER_VIEW* views)
466 {
467 graphics_command_list->lpVtbl->IASetVertexBuffers(
468 graphics_command_list, start_slot, num_views, views);
469 }
D3D12SOSetTargets(D3D12GraphicsCommandList graphics_command_list,UINT start_slot,UINT num_views,D3D12_STREAM_OUTPUT_BUFFER_VIEW * views)470 static INLINE void D3D12SOSetTargets(
471 D3D12GraphicsCommandList graphics_command_list,
472 UINT start_slot,
473 UINT num_views,
474 D3D12_STREAM_OUTPUT_BUFFER_VIEW* views)
475 {
476 graphics_command_list->lpVtbl->SOSetTargets(graphics_command_list, start_slot, num_views, views);
477 }
D3D12OMSetRenderTargets(D3D12GraphicsCommandList graphics_command_list,UINT num_render_target_descriptors,D3D12_CPU_DESCRIPTOR_HANDLE * render_target_descriptors,BOOL r_ts_single_handle_to_descriptor_range,D3D12_CPU_DESCRIPTOR_HANDLE * depth_stencil_descriptor)478 static INLINE void D3D12OMSetRenderTargets(
479 D3D12GraphicsCommandList graphics_command_list,
480 UINT num_render_target_descriptors,
481 D3D12_CPU_DESCRIPTOR_HANDLE* render_target_descriptors,
482 BOOL r_ts_single_handle_to_descriptor_range,
483 D3D12_CPU_DESCRIPTOR_HANDLE* depth_stencil_descriptor)
484 {
485 graphics_command_list->lpVtbl->OMSetRenderTargets(
486 graphics_command_list, num_render_target_descriptors, render_target_descriptors,
487 r_ts_single_handle_to_descriptor_range, depth_stencil_descriptor);
488 }
D3D12ClearDepthStencilView(D3D12GraphicsCommandList graphics_command_list,D3D12_CPU_DESCRIPTOR_HANDLE depth_stencil_view,D3D12_CLEAR_FLAGS clear_flags,FLOAT depth,UINT8 stencil,UINT num_rects,D3D12_RECT * rects)489 static INLINE void D3D12ClearDepthStencilView(
490 D3D12GraphicsCommandList graphics_command_list,
491 D3D12_CPU_DESCRIPTOR_HANDLE depth_stencil_view,
492 D3D12_CLEAR_FLAGS clear_flags,
493 FLOAT depth,
494 UINT8 stencil,
495 UINT num_rects,
496 D3D12_RECT* rects)
497 {
498 graphics_command_list->lpVtbl->ClearDepthStencilView(
499 graphics_command_list, depth_stencil_view, clear_flags, depth, stencil, num_rects, rects);
500 }
D3D12DiscardResource(D3D12GraphicsCommandList graphics_command_list,void * resource,D3D12_DISCARD_REGION * region)501 static INLINE void D3D12DiscardResource(
502 D3D12GraphicsCommandList graphics_command_list, void* resource, D3D12_DISCARD_REGION* region)
503 {
504 graphics_command_list->lpVtbl->DiscardResource(
505 graphics_command_list, (ID3D12Resource*)resource, region);
506 }
D3D12BeginQuery(D3D12GraphicsCommandList graphics_command_list,D3D12QueryHeap query_heap,D3D12_QUERY_TYPE type,UINT index)507 static INLINE void D3D12BeginQuery(
508 D3D12GraphicsCommandList graphics_command_list,
509 D3D12QueryHeap query_heap,
510 D3D12_QUERY_TYPE type,
511 UINT index)
512 {
513 graphics_command_list->lpVtbl->BeginQuery(graphics_command_list, query_heap, type, index);
514 }
D3D12EndQuery(D3D12GraphicsCommandList graphics_command_list,D3D12QueryHeap query_heap,D3D12_QUERY_TYPE type,UINT index)515 static INLINE void D3D12EndQuery(
516 D3D12GraphicsCommandList graphics_command_list,
517 D3D12QueryHeap query_heap,
518 D3D12_QUERY_TYPE type,
519 UINT index)
520 {
521 graphics_command_list->lpVtbl->EndQuery(graphics_command_list, query_heap, type, index);
522 }
D3D12ResolveQueryData(D3D12GraphicsCommandList graphics_command_list,D3D12QueryHeap query_heap,D3D12_QUERY_TYPE type,UINT start_index,UINT num_queries,void * destination_buffer,UINT64 aligned_destination_buffer_offset)523 static INLINE void D3D12ResolveQueryData(
524 D3D12GraphicsCommandList graphics_command_list,
525 D3D12QueryHeap query_heap,
526 D3D12_QUERY_TYPE type,
527 UINT start_index,
528 UINT num_queries,
529 void* destination_buffer,
530 UINT64 aligned_destination_buffer_offset)
531 {
532 graphics_command_list->lpVtbl->ResolveQueryData(
533 graphics_command_list, query_heap, type, start_index, num_queries,
534 (ID3D12Resource*)destination_buffer, aligned_destination_buffer_offset);
535 }
D3D12SetPredication(D3D12GraphicsCommandList graphics_command_list,void * buffer,UINT64 aligned_buffer_offset,D3D12_PREDICATION_OP operation)536 static INLINE void D3D12SetPredication(
537 D3D12GraphicsCommandList graphics_command_list,
538 void* buffer,
539 UINT64 aligned_buffer_offset,
540 D3D12_PREDICATION_OP operation)
541 {
542 graphics_command_list->lpVtbl->SetPredication(
543 graphics_command_list, (ID3D12Resource*)buffer, aligned_buffer_offset, operation);
544 }
D3D12SetGraphicsCommandListMarker(D3D12GraphicsCommandList graphics_command_list,UINT metadata,void * data,UINT size)545 static INLINE void D3D12SetGraphicsCommandListMarker(
546 D3D12GraphicsCommandList graphics_command_list, UINT metadata, void* data, UINT size)
547 {
548 graphics_command_list->lpVtbl->SetMarker(graphics_command_list, metadata, data, size);
549 }
D3D12BeginGraphicsCommandListEvent(D3D12GraphicsCommandList graphics_command_list,UINT metadata,void * data,UINT size)550 static INLINE void D3D12BeginGraphicsCommandListEvent(
551 D3D12GraphicsCommandList graphics_command_list, UINT metadata, void* data, UINT size)
552 {
553 graphics_command_list->lpVtbl->BeginEvent(graphics_command_list, metadata, data, size);
554 }
D3D12EndGraphicsCommandListEvent(D3D12GraphicsCommandList graphics_command_list)555 static INLINE void D3D12EndGraphicsCommandListEvent(D3D12GraphicsCommandList graphics_command_list)
556 {
557 graphics_command_list->lpVtbl->EndEvent(graphics_command_list);
558 }
D3D12ExecuteIndirect(D3D12GraphicsCommandList graphics_command_list,D3D12CommandSignature command_signature,UINT max_command_count,void * argument_buffer,UINT64 argument_buffer_offset,void * count_buffer,UINT64 count_buffer_offset)559 static INLINE void D3D12ExecuteIndirect(
560 D3D12GraphicsCommandList graphics_command_list,
561 D3D12CommandSignature command_signature,
562 UINT max_command_count,
563 void* argument_buffer,
564 UINT64 argument_buffer_offset,
565 void* count_buffer,
566 UINT64 count_buffer_offset)
567 {
568 graphics_command_list->lpVtbl->ExecuteIndirect(
569 graphics_command_list, command_signature, max_command_count,
570 (ID3D12Resource*)argument_buffer, argument_buffer_offset, (ID3D12Resource*)count_buffer,
571 count_buffer_offset);
572 }
D3D12ReleaseCommandQueue(D3D12CommandQueue command_queue)573 static INLINE ULONG D3D12ReleaseCommandQueue(D3D12CommandQueue command_queue)
574 {
575 return command_queue->lpVtbl->Release(command_queue);
576 }
D3D12UpdateTileMappings(D3D12CommandQueue command_queue,void * resource,UINT num_resource_regions,D3D12_TILED_RESOURCE_COORDINATE * resource_region_start_coordinates,D3D12_TILE_REGION_SIZE * resource_region_sizes,D3D12Heap heap,UINT num_ranges,D3D12_TILE_RANGE_FLAGS * range_flags,UINT * heap_range_start_offsets,UINT * range_tile_counts,D3D12_TILE_MAPPING_FLAGS flags)577 static INLINE void D3D12UpdateTileMappings(
578 D3D12CommandQueue command_queue,
579 void* resource,
580 UINT num_resource_regions,
581 D3D12_TILED_RESOURCE_COORDINATE* resource_region_start_coordinates,
582 D3D12_TILE_REGION_SIZE* resource_region_sizes,
583 D3D12Heap heap,
584 UINT num_ranges,
585 D3D12_TILE_RANGE_FLAGS* range_flags,
586 UINT* heap_range_start_offsets,
587 UINT* range_tile_counts,
588 D3D12_TILE_MAPPING_FLAGS flags)
589 {
590 command_queue->lpVtbl->UpdateTileMappings(
591 command_queue, (ID3D12Resource*)resource, num_resource_regions,
592 resource_region_start_coordinates, resource_region_sizes, heap, num_ranges, range_flags,
593 heap_range_start_offsets, range_tile_counts, flags);
594 }
D3D12CopyTileMappings(D3D12CommandQueue command_queue,void * dst_resource,D3D12_TILED_RESOURCE_COORDINATE * dst_region_start_coordinate,void * src_resource,D3D12_TILED_RESOURCE_COORDINATE * src_region_start_coordinate,D3D12_TILE_REGION_SIZE * region_size,D3D12_TILE_MAPPING_FLAGS flags)595 static INLINE void D3D12CopyTileMappings(
596 D3D12CommandQueue command_queue,
597 void* dst_resource,
598 D3D12_TILED_RESOURCE_COORDINATE* dst_region_start_coordinate,
599 void* src_resource,
600 D3D12_TILED_RESOURCE_COORDINATE* src_region_start_coordinate,
601 D3D12_TILE_REGION_SIZE* region_size,
602 D3D12_TILE_MAPPING_FLAGS flags)
603 {
604 command_queue->lpVtbl->CopyTileMappings(
605 command_queue, (ID3D12Resource*)dst_resource, dst_region_start_coordinate,
606 (ID3D12Resource*)src_resource, src_region_start_coordinate, region_size, flags);
607 }
608 static INLINE void
D3D12SetCommandQueueMarker(D3D12CommandQueue command_queue,UINT metadata,void * data,UINT size)609 D3D12SetCommandQueueMarker(D3D12CommandQueue command_queue, UINT metadata, void* data, UINT size)
610 {
611 command_queue->lpVtbl->SetMarker(command_queue, metadata, data, size);
612 }
613 static INLINE void
D3D12BeginCommandQueueEvent(D3D12CommandQueue command_queue,UINT metadata,void * data,UINT size)614 D3D12BeginCommandQueueEvent(D3D12CommandQueue command_queue, UINT metadata, void* data, UINT size)
615 {
616 command_queue->lpVtbl->BeginEvent(command_queue, metadata, data, size);
617 }
D3D12EndCommandQueueEvent(D3D12CommandQueue command_queue)618 static INLINE void D3D12EndCommandQueueEvent(D3D12CommandQueue command_queue)
619 {
620 command_queue->lpVtbl->EndEvent(command_queue);
621 }
622 static INLINE HRESULT
D3D12SignalCommandQueue(D3D12CommandQueue command_queue,D3D12Fence fence,UINT64 value)623 D3D12SignalCommandQueue(D3D12CommandQueue command_queue, D3D12Fence fence, UINT64 value)
624 {
625 return command_queue->lpVtbl->Signal(command_queue, fence, value);
626 }
D3D12Wait(D3D12CommandQueue command_queue,D3D12Fence fence,UINT64 value)627 static INLINE HRESULT D3D12Wait(D3D12CommandQueue command_queue, D3D12Fence fence, UINT64 value)
628 {
629 return command_queue->lpVtbl->Wait(command_queue, fence, value);
630 }
D3D12GetTimestampFrequency(D3D12CommandQueue command_queue,UINT64 * frequency)631 static INLINE HRESULT D3D12GetTimestampFrequency(D3D12CommandQueue command_queue, UINT64* frequency)
632 {
633 return command_queue->lpVtbl->GetTimestampFrequency(command_queue, frequency);
634 }
D3D12GetClockCalibration(D3D12CommandQueue command_queue,UINT64 * gpu_timestamp,UINT64 * cpu_timestamp)635 static INLINE HRESULT D3D12GetClockCalibration(
636 D3D12CommandQueue command_queue, UINT64* gpu_timestamp, UINT64* cpu_timestamp)
637 {
638 return command_queue->lpVtbl->GetClockCalibration(command_queue, gpu_timestamp, cpu_timestamp);
639 }
D3D12ReleaseDevice(D3D12Device device)640 static INLINE ULONG D3D12ReleaseDevice(D3D12Device device)
641 {
642 return device->lpVtbl->Release(device);
643 }
D3D12GetNodeCount(D3D12Device device)644 static INLINE UINT D3D12GetNodeCount(D3D12Device device)
645 {
646 return device->lpVtbl->GetNodeCount(device);
647 }
D3D12CreateCommandQueue(D3D12Device device,D3D12_COMMAND_QUEUE_DESC * desc,ID3D12CommandQueue ** out)648 static INLINE HRESULT D3D12CreateCommandQueue(
649 D3D12Device device, D3D12_COMMAND_QUEUE_DESC* desc, ID3D12CommandQueue** out)
650 {
651 return device->lpVtbl->CreateCommandQueue(device, desc, uuidof(ID3D12CommandQueue), (void**)out);
652 }
D3D12CreateCommandAllocator(D3D12Device device,D3D12_COMMAND_LIST_TYPE type,ID3D12CommandAllocator ** out)653 static INLINE HRESULT D3D12CreateCommandAllocator(
654 D3D12Device device, D3D12_COMMAND_LIST_TYPE type, ID3D12CommandAllocator** out)
655 {
656 return device->lpVtbl->CreateCommandAllocator(
657 device, type, uuidof(ID3D12CommandAllocator), (void**)out);
658 }
D3D12CreateGraphicsPipelineState(D3D12Device device,D3D12_GRAPHICS_PIPELINE_STATE_DESC * desc,ID3D12PipelineState ** out)659 static INLINE HRESULT D3D12CreateGraphicsPipelineState(
660 D3D12Device device, D3D12_GRAPHICS_PIPELINE_STATE_DESC* desc, ID3D12PipelineState** out)
661 {
662 return device->lpVtbl->CreateGraphicsPipelineState(
663 device, desc, uuidof(ID3D12PipelineState), (void**)out);
664 }
D3D12CreateComputePipelineState(D3D12Device device,D3D12_COMPUTE_PIPELINE_STATE_DESC * desc,ID3D12PipelineState ** out)665 static INLINE HRESULT D3D12CreateComputePipelineState(
666 D3D12Device device, D3D12_COMPUTE_PIPELINE_STATE_DESC* desc, ID3D12PipelineState** out)
667 {
668 return device->lpVtbl->CreateComputePipelineState(
669 device, desc, uuidof(ID3D12PipelineState), (void**)out);
670 }
D3D12CreateCommandList(D3D12Device device,UINT node_mask,D3D12_COMMAND_LIST_TYPE type,D3D12CommandAllocator command_allocator,D3D12PipelineState initial_state,ID3D12CommandList ** out)671 static INLINE HRESULT D3D12CreateCommandList(
672 D3D12Device device,
673 UINT node_mask,
674 D3D12_COMMAND_LIST_TYPE type,
675 D3D12CommandAllocator command_allocator,
676 D3D12PipelineState initial_state,
677 ID3D12CommandList** out)
678 {
679 return device->lpVtbl->CreateCommandList(
680 device, node_mask, type, command_allocator, initial_state, uuidof(ID3D12CommandList),
681 (void**)out);
682 }
D3D12CheckFeatureSupport(D3D12Device device,D3D12_FEATURE feature,void * feature_support_data,UINT feature_support_data_size)683 static INLINE HRESULT D3D12CheckFeatureSupport(
684 D3D12Device device,
685 D3D12_FEATURE feature,
686 void* feature_support_data,
687 UINT feature_support_data_size)
688 {
689 return device->lpVtbl->CheckFeatureSupport(
690 device, feature, feature_support_data, feature_support_data_size);
691 }
D3D12CreateDescriptorHeap(D3D12Device device,D3D12_DESCRIPTOR_HEAP_DESC * descriptor_heap_desc,D3D12DescriptorHeap * out)692 static INLINE HRESULT D3D12CreateDescriptorHeap(
693 D3D12Device device,
694 D3D12_DESCRIPTOR_HEAP_DESC* descriptor_heap_desc,
695 D3D12DescriptorHeap* out)
696 {
697 return device->lpVtbl->CreateDescriptorHeap(
698 device, descriptor_heap_desc, uuidof(ID3D12DescriptorHeap), (void**)out);
699 }
D3D12GetDescriptorHandleIncrementSize(D3D12Device device,D3D12_DESCRIPTOR_HEAP_TYPE descriptor_heap_type)700 static INLINE UINT D3D12GetDescriptorHandleIncrementSize(
701 D3D12Device device, D3D12_DESCRIPTOR_HEAP_TYPE descriptor_heap_type)
702 {
703 return device->lpVtbl->GetDescriptorHandleIncrementSize(device, descriptor_heap_type);
704 }
D3D12CreateRootSignature(D3D12Device device,UINT node_mask,void * blob_with_root_signature,SIZE_T blob_length_in_bytes,ID3D12RootSignature ** out)705 static INLINE HRESULT D3D12CreateRootSignature(
706 D3D12Device device,
707 UINT node_mask,
708 void* blob_with_root_signature,
709 SIZE_T blob_length_in_bytes,
710 ID3D12RootSignature** out)
711 {
712 return device->lpVtbl->CreateRootSignature(
713 device, node_mask, blob_with_root_signature, blob_length_in_bytes,
714 uuidof(ID3D12RootSignature), (void**)out);
715 }
D3D12CreateConstantBufferView(D3D12Device device,D3D12_CONSTANT_BUFFER_VIEW_DESC * desc,D3D12_CPU_DESCRIPTOR_HANDLE dest_descriptor)716 static INLINE void D3D12CreateConstantBufferView(
717 D3D12Device device,
718 D3D12_CONSTANT_BUFFER_VIEW_DESC* desc,
719 D3D12_CPU_DESCRIPTOR_HANDLE dest_descriptor)
720 {
721 device->lpVtbl->CreateConstantBufferView(device, desc, dest_descriptor);
722 }
D3D12CreateShaderResourceView(D3D12Device device,D3D12Resource resource,D3D12_SHADER_RESOURCE_VIEW_DESC * desc,D3D12_CPU_DESCRIPTOR_HANDLE dest_descriptor)723 static INLINE void D3D12CreateShaderResourceView(
724 D3D12Device device,
725 D3D12Resource resource,
726 D3D12_SHADER_RESOURCE_VIEW_DESC* desc,
727 D3D12_CPU_DESCRIPTOR_HANDLE dest_descriptor)
728 {
729 device->lpVtbl->CreateShaderResourceView(device, resource, desc, dest_descriptor);
730 }
D3D12CreateUnorderedAccessView(D3D12Device device,void * resource,void * counter_resource,D3D12_UNORDERED_ACCESS_VIEW_DESC * desc,D3D12_CPU_DESCRIPTOR_HANDLE dest_descriptor)731 static INLINE void D3D12CreateUnorderedAccessView(
732 D3D12Device device,
733 void* resource,
734 void* counter_resource,
735 D3D12_UNORDERED_ACCESS_VIEW_DESC* desc,
736 D3D12_CPU_DESCRIPTOR_HANDLE dest_descriptor)
737 {
738 device->lpVtbl->CreateUnorderedAccessView(
739 device, (ID3D12Resource*)resource, (ID3D12Resource*)counter_resource, desc,
740 dest_descriptor);
741 }
D3D12CreateRenderTargetView(D3D12Device device,void * resource,D3D12_RENDER_TARGET_VIEW_DESC * desc,D3D12_CPU_DESCRIPTOR_HANDLE dest_descriptor)742 static INLINE void D3D12CreateRenderTargetView(
743 D3D12Device device,
744 void* resource,
745 D3D12_RENDER_TARGET_VIEW_DESC* desc,
746 D3D12_CPU_DESCRIPTOR_HANDLE dest_descriptor)
747 {
748 device->lpVtbl->CreateRenderTargetView(device, (ID3D12Resource*)resource, desc, dest_descriptor);
749 }
D3D12CreateDepthStencilView(D3D12Device device,void * resource,D3D12_DEPTH_STENCIL_VIEW_DESC * desc,D3D12_CPU_DESCRIPTOR_HANDLE dest_descriptor)750 static INLINE void D3D12CreateDepthStencilView(
751 D3D12Device device,
752 void* resource,
753 D3D12_DEPTH_STENCIL_VIEW_DESC* desc,
754 D3D12_CPU_DESCRIPTOR_HANDLE dest_descriptor)
755 {
756 device->lpVtbl->CreateDepthStencilView(device, (ID3D12Resource*)resource, desc, dest_descriptor);
757 }
D3D12CreateSampler(D3D12Device device,D3D12_SAMPLER_DESC * desc,D3D12_CPU_DESCRIPTOR_HANDLE dest_descriptor)758 static INLINE void D3D12CreateSampler(
759 D3D12Device device, D3D12_SAMPLER_DESC* desc, D3D12_CPU_DESCRIPTOR_HANDLE dest_descriptor)
760 {
761 device->lpVtbl->CreateSampler(device, desc, dest_descriptor);
762 }
D3D12CopyDescriptors(D3D12Device device,UINT num_dest_descriptor_ranges,D3D12_CPU_DESCRIPTOR_HANDLE * dest_descriptor_range_starts,UINT * dest_descriptor_range_sizes,UINT num_src_descriptor_ranges,D3D12_CPU_DESCRIPTOR_HANDLE * src_descriptor_range_starts,UINT * src_descriptor_range_sizes,D3D12_DESCRIPTOR_HEAP_TYPE descriptor_heaps_type)763 static INLINE void D3D12CopyDescriptors(
764 D3D12Device device,
765 UINT num_dest_descriptor_ranges,
766 D3D12_CPU_DESCRIPTOR_HANDLE* dest_descriptor_range_starts,
767 UINT* dest_descriptor_range_sizes,
768 UINT num_src_descriptor_ranges,
769 D3D12_CPU_DESCRIPTOR_HANDLE* src_descriptor_range_starts,
770 UINT* src_descriptor_range_sizes,
771 D3D12_DESCRIPTOR_HEAP_TYPE descriptor_heaps_type)
772 {
773 device->lpVtbl->CopyDescriptors(
774 device, num_dest_descriptor_ranges, dest_descriptor_range_starts,
775 dest_descriptor_range_sizes, num_src_descriptor_ranges, src_descriptor_range_starts,
776 src_descriptor_range_sizes, descriptor_heaps_type);
777 }
D3D12CopyDescriptorsSimple(D3D12Device device,UINT num_descriptors,D3D12_CPU_DESCRIPTOR_HANDLE dest_descriptor_range_start,D3D12_CPU_DESCRIPTOR_HANDLE src_descriptor_range_start,D3D12_DESCRIPTOR_HEAP_TYPE descriptor_heaps_type)778 static INLINE void D3D12CopyDescriptorsSimple(
779 D3D12Device device,
780 UINT num_descriptors,
781 D3D12_CPU_DESCRIPTOR_HANDLE dest_descriptor_range_start,
782 D3D12_CPU_DESCRIPTOR_HANDLE src_descriptor_range_start,
783 D3D12_DESCRIPTOR_HEAP_TYPE descriptor_heaps_type)
784 {
785 device->lpVtbl->CopyDescriptorsSimple(
786 device, num_descriptors, dest_descriptor_range_start, src_descriptor_range_start,
787 descriptor_heaps_type);
788 }
D3D12GetResourceAllocationInfo(D3D12Device device,UINT visible_mask,UINT num_resource_descs,D3D12_RESOURCE_DESC * resource_descs)789 static INLINE D3D12_RESOURCE_ALLOCATION_INFO D3D12GetResourceAllocationInfo(
790 D3D12Device device,
791 UINT visible_mask,
792 UINT num_resource_descs,
793 D3D12_RESOURCE_DESC* resource_descs)
794 {
795 return device->lpVtbl->GetResourceAllocationInfo(
796 device, visible_mask, num_resource_descs, resource_descs);
797 }
798 static INLINE D3D12_HEAP_PROPERTIES
D3D12GetCustomHeapProperties(D3D12Device device,UINT node_mask,D3D12_HEAP_TYPE heap_type)799 D3D12GetCustomHeapProperties(D3D12Device device, UINT node_mask, D3D12_HEAP_TYPE heap_type)
800 {
801 return device->lpVtbl->GetCustomHeapProperties(device, node_mask, heap_type);
802 }
D3D12CreateCommittedResource(D3D12Device device,D3D12_HEAP_PROPERTIES * heap_properties,D3D12_HEAP_FLAGS heap_flags,D3D12_RESOURCE_DESC * desc,D3D12_RESOURCE_STATES initial_resource_state,D3D12_CLEAR_VALUE * optimized_clear_value,ID3D12Resource ** out)803 static INLINE HRESULT D3D12CreateCommittedResource(
804 D3D12Device device,
805 D3D12_HEAP_PROPERTIES* heap_properties,
806 D3D12_HEAP_FLAGS heap_flags,
807 D3D12_RESOURCE_DESC* desc,
808 D3D12_RESOURCE_STATES initial_resource_state,
809 D3D12_CLEAR_VALUE* optimized_clear_value,
810 ID3D12Resource** out)
811 {
812 return device->lpVtbl->CreateCommittedResource(
813 device, heap_properties, heap_flags, desc, initial_resource_state, optimized_clear_value,
814 uuidof(ID3D12Resource), (void**)out);
815 }
D3D12CreateHeap(D3D12Device device,D3D12_HEAP_DESC * desc,ID3D12Heap ** out)816 static INLINE HRESULT D3D12CreateHeap(D3D12Device device, D3D12_HEAP_DESC* desc, ID3D12Heap** out)
817 {
818 return device->lpVtbl->CreateHeap(device, desc, uuidof(ID3D12Heap), (void**)out);
819 }
D3D12CreatePlacedResource(D3D12Device device,D3D12Heap heap,UINT64 heap_offset,D3D12_RESOURCE_DESC * desc,D3D12_RESOURCE_STATES initial_state,D3D12_CLEAR_VALUE * optimized_clear_value,ID3D12Resource ** out)820 static INLINE HRESULT D3D12CreatePlacedResource(
821 D3D12Device device,
822 D3D12Heap heap,
823 UINT64 heap_offset,
824 D3D12_RESOURCE_DESC* desc,
825 D3D12_RESOURCE_STATES initial_state,
826 D3D12_CLEAR_VALUE* optimized_clear_value,
827 ID3D12Resource** out)
828 {
829 return device->lpVtbl->CreatePlacedResource(
830 device, heap, heap_offset, desc, initial_state, optimized_clear_value,
831 uuidof(ID3D12Resource), (void**)out);
832 }
D3D12CreateReservedResource(D3D12Device device,D3D12_RESOURCE_DESC * desc,D3D12_RESOURCE_STATES initial_state,D3D12_CLEAR_VALUE * optimized_clear_value,ID3D12Resource ** out)833 static INLINE HRESULT D3D12CreateReservedResource(
834 D3D12Device device,
835 D3D12_RESOURCE_DESC* desc,
836 D3D12_RESOURCE_STATES initial_state,
837 D3D12_CLEAR_VALUE* optimized_clear_value,
838 ID3D12Resource** out)
839 {
840 return device->lpVtbl->CreateReservedResource(
841 device, desc, initial_state, optimized_clear_value, uuidof(ID3D12Resource), (void**)out);
842 }
D3D12CreateFence(D3D12Device device,UINT64 initial_value,D3D12_FENCE_FLAGS flags,ID3D12Fence ** out)843 static INLINE HRESULT D3D12CreateFence(
844 D3D12Device device, UINT64 initial_value, D3D12_FENCE_FLAGS flags, ID3D12Fence** out)
845 {
846 return device->lpVtbl->CreateFence(
847 device, initial_value, flags, uuidof(ID3D12Fence), (void**)out);
848 }
D3D12GetDeviceRemovedReason(D3D12Device device)849 static INLINE HRESULT D3D12GetDeviceRemovedReason(D3D12Device device)
850 {
851 return device->lpVtbl->GetDeviceRemovedReason(device);
852 }
D3D12GetCopyableFootprints(D3D12Device device,D3D12_RESOURCE_DESC * resource_desc,UINT first_subresource,UINT num_subresources,UINT64 base_offset,D3D12_PLACED_SUBRESOURCE_FOOTPRINT * layouts,UINT * num_rows,UINT64 * row_size_in_bytes,UINT64 * total_bytes)853 static INLINE void D3D12GetCopyableFootprints(
854 D3D12Device device,
855 D3D12_RESOURCE_DESC* resource_desc,
856 UINT first_subresource,
857 UINT num_subresources,
858 UINT64 base_offset,
859 D3D12_PLACED_SUBRESOURCE_FOOTPRINT* layouts,
860 UINT* num_rows,
861 UINT64* row_size_in_bytes,
862 UINT64* total_bytes)
863 {
864 device->lpVtbl->GetCopyableFootprints(
865 device, resource_desc, first_subresource, num_subresources, base_offset, layouts, num_rows,
866 row_size_in_bytes, total_bytes);
867 }
868 static INLINE HRESULT
D3D12CreateQueryHeap(D3D12Device device,D3D12_QUERY_HEAP_DESC * desc,ID3D12Heap ** out)869 D3D12CreateQueryHeap(D3D12Device device, D3D12_QUERY_HEAP_DESC* desc, ID3D12Heap** out)
870 {
871 return device->lpVtbl->CreateQueryHeap(device, desc, uuidof(ID3D12Heap), (void**)out);
872 }
D3D12SetStablePowerState(D3D12Device device,BOOL enable)873 static INLINE HRESULT D3D12SetStablePowerState(D3D12Device device, BOOL enable)
874 {
875 return device->lpVtbl->SetStablePowerState(device, enable);
876 }
D3D12CreateCommandSignature(D3D12Device device,D3D12_COMMAND_SIGNATURE_DESC * desc,D3D12RootSignature root_signature,ID3D12CommandSignature ** out)877 static INLINE HRESULT D3D12CreateCommandSignature(
878 D3D12Device device,
879 D3D12_COMMAND_SIGNATURE_DESC* desc,
880 D3D12RootSignature root_signature,
881 ID3D12CommandSignature** out)
882 {
883 return device->lpVtbl->CreateCommandSignature(
884 device, desc, root_signature, uuidof(ID3D12CommandSignature), (void**)out);
885 }
D3D12GetResourceTiling(D3D12Device device,void * tiled_resource,UINT * num_tiles_for_entire_resource,D3D12_PACKED_MIP_INFO * packed_mip_desc,D3D12_TILE_SHAPE * standard_tile_shape_for_non_packed_mips,UINT * num_subresource_tilings,UINT first_subresource_tiling_to_get,D3D12_SUBRESOURCE_TILING * subresource_tilings_for_non_packed_mips)886 static INLINE void D3D12GetResourceTiling(
887 D3D12Device device,
888 void* tiled_resource,
889 UINT* num_tiles_for_entire_resource,
890 D3D12_PACKED_MIP_INFO* packed_mip_desc,
891 D3D12_TILE_SHAPE* standard_tile_shape_for_non_packed_mips,
892 UINT* num_subresource_tilings,
893 UINT first_subresource_tiling_to_get,
894 D3D12_SUBRESOURCE_TILING* subresource_tilings_for_non_packed_mips)
895 {
896 device->lpVtbl->GetResourceTiling(
897 device, (ID3D12Resource*)tiled_resource, num_tiles_for_entire_resource, packed_mip_desc,
898 standard_tile_shape_for_non_packed_mips, num_subresource_tilings,
899 first_subresource_tiling_to_get, subresource_tilings_for_non_packed_mips);
900 }
D3D12GetAdapterLuid(D3D12Device device)901 static INLINE LUID D3D12GetAdapterLuid(D3D12Device device)
902 {
903 return device->lpVtbl->GetAdapterLuid(device);
904 }
D3D12ReleasePipelineLibrary(D3D12PipelineLibrary pipeline_library)905 static INLINE ULONG D3D12ReleasePipelineLibrary(D3D12PipelineLibrary pipeline_library)
906 {
907 return pipeline_library->lpVtbl->Release(pipeline_library);
908 }
909 static INLINE HRESULT
D3D12StorePipeline(D3D12PipelineLibrary pipeline_library,LPCWSTR name,D3D12PipelineState pipeline)910 D3D12StorePipeline(D3D12PipelineLibrary pipeline_library, LPCWSTR name, D3D12PipelineState pipeline)
911 {
912 return pipeline_library->lpVtbl->StorePipeline(pipeline_library, name, pipeline);
913 }
D3D12LoadGraphicsPipeline(D3D12PipelineLibrary pipeline_library,LPCWSTR name,D3D12_GRAPHICS_PIPELINE_STATE_DESC * desc,ID3D12PipelineState ** out)914 static INLINE HRESULT D3D12LoadGraphicsPipeline(
915 D3D12PipelineLibrary pipeline_library,
916 LPCWSTR name,
917 D3D12_GRAPHICS_PIPELINE_STATE_DESC* desc,
918 ID3D12PipelineState** out)
919 {
920 return pipeline_library->lpVtbl->LoadGraphicsPipeline(
921 pipeline_library, name, desc, uuidof(ID3D12PipelineState), (void**)out);
922 }
D3D12LoadComputePipeline(D3D12PipelineLibrary pipeline_library,LPCWSTR name,D3D12_COMPUTE_PIPELINE_STATE_DESC * desc,ID3D12PipelineState ** out)923 static INLINE HRESULT D3D12LoadComputePipeline(
924 D3D12PipelineLibrary pipeline_library,
925 LPCWSTR name,
926 D3D12_COMPUTE_PIPELINE_STATE_DESC* desc,
927 ID3D12PipelineState** out)
928 {
929 return pipeline_library->lpVtbl->LoadComputePipeline(
930 pipeline_library, name, desc, uuidof(ID3D12PipelineState), (void**)out);
931 }
D3D12GetSerializedSize(D3D12PipelineLibrary pipeline_library)932 static INLINE SIZE_T D3D12GetSerializedSize(D3D12PipelineLibrary pipeline_library)
933 {
934 return pipeline_library->lpVtbl->GetSerializedSize(pipeline_library);
935 }
936 static INLINE HRESULT
D3D12Serialize(D3D12PipelineLibrary pipeline_library,void * data,SIZE_T data_size_in_bytes)937 D3D12Serialize(D3D12PipelineLibrary pipeline_library, void* data, SIZE_T data_size_in_bytes)
938 {
939 return pipeline_library->lpVtbl->Serialize(pipeline_library, data, data_size_in_bytes);
940 }
941
942 #ifdef DEBUG
D3D12ReleaseDebug(D3D12Debug debug)943 static INLINE ULONG D3D12ReleaseDebug(D3D12Debug debug) { return debug->lpVtbl->Release(debug); }
D3D12EnableDebugLayer(D3D12Debug debug)944 static INLINE void D3D12EnableDebugLayer(D3D12Debug debug)
945 {
946 debug->lpVtbl->EnableDebugLayer(debug);
947 }
D3D12ReleaseDebugDevice(D3D12DebugDevice debug_device)948 static INLINE ULONG D3D12ReleaseDebugDevice(D3D12DebugDevice debug_device)
949 {
950 return debug_device->lpVtbl->Release(debug_device);
951 }
952 static INLINE HRESULT
D3D12SetDebugDeviceFeatureMask(D3D12DebugDevice debug_device,D3D12_DEBUG_FEATURE mask)953 D3D12SetDebugDeviceFeatureMask(D3D12DebugDevice debug_device, D3D12_DEBUG_FEATURE mask)
954 {
955 return debug_device->lpVtbl->SetFeatureMask(debug_device, mask);
956 }
D3D12GetDebugDeviceFeatureMask(D3D12DebugDevice debug_device)957 static INLINE D3D12_DEBUG_FEATURE D3D12GetDebugDeviceFeatureMask(D3D12DebugDevice debug_device)
958 {
959 return debug_device->lpVtbl->GetFeatureMask(debug_device);
960 }
961 static INLINE HRESULT
D3D12ReportLiveDeviceObjects(D3D12DebugDevice debug_device,D3D12_RLDO_FLAGS flags)962 D3D12ReportLiveDeviceObjects(D3D12DebugDevice debug_device, D3D12_RLDO_FLAGS flags)
963 {
964 return debug_device->lpVtbl->ReportLiveDeviceObjects(debug_device, flags);
965 }
D3D12ReleaseDebugCommandQueue(D3D12DebugCommandQueue debug_command_queue)966 static INLINE ULONG D3D12ReleaseDebugCommandQueue(D3D12DebugCommandQueue debug_command_queue)
967 {
968 return debug_command_queue->lpVtbl->Release(debug_command_queue);
969 }
D3D12AssertDebugCommandQueueResourceState(D3D12DebugCommandQueue debug_command_queue,void * resource,UINT subresource,UINT state)970 static INLINE BOOL D3D12AssertDebugCommandQueueResourceState(
971 D3D12DebugCommandQueue debug_command_queue, void* resource, UINT subresource, UINT state)
972 {
973 return debug_command_queue->lpVtbl->AssertResourceState(
974 debug_command_queue, (ID3D12Resource*)resource, subresource, state);
975 }
D3D12ReleaseDebugCommandList(D3D12DebugCommandList debug_command_list)976 static INLINE ULONG D3D12ReleaseDebugCommandList(D3D12DebugCommandList debug_command_list)
977 {
978 return debug_command_list->lpVtbl->Release(debug_command_list);
979 }
D3D12AssertDebugCommandListResourceState(D3D12DebugCommandList debug_command_list,void * resource,UINT subresource,UINT state)980 static INLINE BOOL D3D12AssertDebugCommandListResourceState(
981 D3D12DebugCommandList debug_command_list, void* resource, UINT subresource, UINT state)
982 {
983 return debug_command_list->lpVtbl->AssertResourceState(
984 debug_command_list, (ID3D12Resource*)resource, subresource, state);
985 }
D3D12SetDebugCommandListFeatureMask(D3D12DebugCommandList debug_command_list,D3D12_DEBUG_FEATURE mask)986 static INLINE HRESULT D3D12SetDebugCommandListFeatureMask(
987 D3D12DebugCommandList debug_command_list, D3D12_DEBUG_FEATURE mask)
988 {
989 return debug_command_list->lpVtbl->SetFeatureMask(debug_command_list, mask);
990 }
991 static INLINE D3D12_DEBUG_FEATURE
D3D12GetDebugCommandListFeatureMask(D3D12DebugCommandList debug_command_list)992 D3D12GetDebugCommandListFeatureMask(D3D12DebugCommandList debug_command_list)
993 {
994 return debug_command_list->lpVtbl->GetFeatureMask(debug_command_list);
995 }
996 #endif
997
D3D12ReleaseInfoQueue(D3D12InfoQueue info_queue)998 static INLINE ULONG D3D12ReleaseInfoQueue(D3D12InfoQueue info_queue)
999 {
1000 return info_queue->lpVtbl->Release(info_queue);
1001 }
1002 static INLINE HRESULT
D3D12SetMessageCountLimit(D3D12InfoQueue info_queue,UINT64 message_count_limit)1003 D3D12SetMessageCountLimit(D3D12InfoQueue info_queue, UINT64 message_count_limit)
1004 {
1005 return info_queue->lpVtbl->SetMessageCountLimit(info_queue, message_count_limit);
1006 }
D3D12ClearStoredMessages(D3D12InfoQueue info_queue)1007 static INLINE void D3D12ClearStoredMessages(D3D12InfoQueue info_queue)
1008 {
1009 info_queue->lpVtbl->ClearStoredMessages(info_queue);
1010 }
1011 #ifndef __WINRT__
D3D12GetMessageA(D3D12InfoQueue info_queue,UINT64 message_index,D3D12_MESSAGE * message,SIZE_T * message_byte_length)1012 static INLINE HRESULT D3D12GetMessageA(
1013 D3D12InfoQueue info_queue,
1014 UINT64 message_index,
1015 D3D12_MESSAGE* message,
1016 SIZE_T* message_byte_length)
1017 {
1018 return info_queue->lpVtbl->GetMessageA(info_queue, message_index, message, message_byte_length);
1019 }
1020 #endif
D3D12GetNumMessagesAllowedByStorageFilter(D3D12InfoQueue info_queue)1021 static INLINE UINT64 D3D12GetNumMessagesAllowedByStorageFilter(D3D12InfoQueue info_queue)
1022 {
1023 return info_queue->lpVtbl->GetNumMessagesAllowedByStorageFilter(info_queue);
1024 }
D3D12GetNumMessagesDeniedByStorageFilter(D3D12InfoQueue info_queue)1025 static INLINE UINT64 D3D12GetNumMessagesDeniedByStorageFilter(D3D12InfoQueue info_queue)
1026 {
1027 return info_queue->lpVtbl->GetNumMessagesDeniedByStorageFilter(info_queue);
1028 }
D3D12GetNumStoredMessages(D3D12InfoQueue info_queue)1029 static INLINE UINT64 D3D12GetNumStoredMessages(D3D12InfoQueue info_queue)
1030 {
1031 return info_queue->lpVtbl->GetNumStoredMessages(info_queue);
1032 }
D3D12GetNumStoredMessagesAllowedByRetrievalFilter(D3D12InfoQueue info_queue)1033 static INLINE UINT64 D3D12GetNumStoredMessagesAllowedByRetrievalFilter(D3D12InfoQueue info_queue)
1034 {
1035 return info_queue->lpVtbl->GetNumStoredMessagesAllowedByRetrievalFilter(info_queue);
1036 }
D3D12GetNumMessagesDiscardedByMessageCountLimit(D3D12InfoQueue info_queue)1037 static INLINE UINT64 D3D12GetNumMessagesDiscardedByMessageCountLimit(D3D12InfoQueue info_queue)
1038 {
1039 return info_queue->lpVtbl->GetNumMessagesDiscardedByMessageCountLimit(info_queue);
1040 }
D3D12GetMessageCountLimit(D3D12InfoQueue info_queue)1041 static INLINE UINT64 D3D12GetMessageCountLimit(D3D12InfoQueue info_queue)
1042 {
1043 return info_queue->lpVtbl->GetMessageCountLimit(info_queue);
1044 }
1045 static INLINE HRESULT
D3D12AddStorageFilterEntries(D3D12InfoQueue info_queue,D3D12_INFO_QUEUE_FILTER * filter)1046 D3D12AddStorageFilterEntries(D3D12InfoQueue info_queue, D3D12_INFO_QUEUE_FILTER* filter)
1047 {
1048 return info_queue->lpVtbl->AddStorageFilterEntries(info_queue, filter);
1049 }
D3D12GetStorageFilter(D3D12InfoQueue info_queue,D3D12_INFO_QUEUE_FILTER * filter,SIZE_T * filter_byte_length)1050 static INLINE HRESULT D3D12GetStorageFilter(
1051 D3D12InfoQueue info_queue, D3D12_INFO_QUEUE_FILTER* filter, SIZE_T* filter_byte_length)
1052 {
1053 return info_queue->lpVtbl->GetStorageFilter(info_queue, filter, filter_byte_length);
1054 }
D3D12ClearStorageFilter(D3D12InfoQueue info_queue)1055 static INLINE void D3D12ClearStorageFilter(D3D12InfoQueue info_queue)
1056 {
1057 info_queue->lpVtbl->ClearStorageFilter(info_queue);
1058 }
D3D12PushEmptyStorageFilter(D3D12InfoQueue info_queue)1059 static INLINE HRESULT D3D12PushEmptyStorageFilter(D3D12InfoQueue info_queue)
1060 {
1061 return info_queue->lpVtbl->PushEmptyStorageFilter(info_queue);
1062 }
D3D12PushCopyOfStorageFilter(D3D12InfoQueue info_queue)1063 static INLINE HRESULT D3D12PushCopyOfStorageFilter(D3D12InfoQueue info_queue)
1064 {
1065 return info_queue->lpVtbl->PushCopyOfStorageFilter(info_queue);
1066 }
1067 static INLINE HRESULT
D3D12PushStorageFilter(D3D12InfoQueue info_queue,D3D12_INFO_QUEUE_FILTER * filter)1068 D3D12PushStorageFilter(D3D12InfoQueue info_queue, D3D12_INFO_QUEUE_FILTER* filter)
1069 {
1070 return info_queue->lpVtbl->PushStorageFilter(info_queue, filter);
1071 }
D3D12PopStorageFilter(D3D12InfoQueue info_queue)1072 static INLINE void D3D12PopStorageFilter(D3D12InfoQueue info_queue)
1073 {
1074 info_queue->lpVtbl->PopStorageFilter(info_queue);
1075 }
D3D12GetStorageFilterStackSize(D3D12InfoQueue info_queue)1076 static INLINE UINT D3D12GetStorageFilterStackSize(D3D12InfoQueue info_queue)
1077 {
1078 return info_queue->lpVtbl->GetStorageFilterStackSize(info_queue);
1079 }
1080 static INLINE HRESULT
D3D12AddRetrievalFilterEntries(D3D12InfoQueue info_queue,D3D12_INFO_QUEUE_FILTER * filter)1081 D3D12AddRetrievalFilterEntries(D3D12InfoQueue info_queue, D3D12_INFO_QUEUE_FILTER* filter)
1082 {
1083 return info_queue->lpVtbl->AddRetrievalFilterEntries(info_queue, filter);
1084 }
D3D12GetRetrievalFilter(D3D12InfoQueue info_queue,D3D12_INFO_QUEUE_FILTER * filter,SIZE_T * filter_byte_length)1085 static INLINE HRESULT D3D12GetRetrievalFilter(
1086 D3D12InfoQueue info_queue, D3D12_INFO_QUEUE_FILTER* filter, SIZE_T* filter_byte_length)
1087 {
1088 return info_queue->lpVtbl->GetRetrievalFilter(info_queue, filter, filter_byte_length);
1089 }
D3D12ClearRetrievalFilter(D3D12InfoQueue info_queue)1090 static INLINE void D3D12ClearRetrievalFilter(D3D12InfoQueue info_queue)
1091 {
1092 info_queue->lpVtbl->ClearRetrievalFilter(info_queue);
1093 }
D3D12PushEmptyRetrievalFilter(D3D12InfoQueue info_queue)1094 static INLINE HRESULT D3D12PushEmptyRetrievalFilter(D3D12InfoQueue info_queue)
1095 {
1096 return info_queue->lpVtbl->PushEmptyRetrievalFilter(info_queue);
1097 }
D3D12PushCopyOfRetrievalFilter(D3D12InfoQueue info_queue)1098 static INLINE HRESULT D3D12PushCopyOfRetrievalFilter(D3D12InfoQueue info_queue)
1099 {
1100 return info_queue->lpVtbl->PushCopyOfRetrievalFilter(info_queue);
1101 }
1102 static INLINE HRESULT
D3D12PushRetrievalFilter(D3D12InfoQueue info_queue,D3D12_INFO_QUEUE_FILTER * filter)1103 D3D12PushRetrievalFilter(D3D12InfoQueue info_queue, D3D12_INFO_QUEUE_FILTER* filter)
1104 {
1105 return info_queue->lpVtbl->PushRetrievalFilter(info_queue, filter);
1106 }
D3D12PopRetrievalFilter(D3D12InfoQueue info_queue)1107 static INLINE void D3D12PopRetrievalFilter(D3D12InfoQueue info_queue)
1108 {
1109 info_queue->lpVtbl->PopRetrievalFilter(info_queue);
1110 }
D3D12GetRetrievalFilterStackSize(D3D12InfoQueue info_queue)1111 static INLINE UINT D3D12GetRetrievalFilterStackSize(D3D12InfoQueue info_queue)
1112 {
1113 return info_queue->lpVtbl->GetRetrievalFilterStackSize(info_queue);
1114 }
D3D12AddMessage(D3D12InfoQueue info_queue,D3D12_MESSAGE_CATEGORY category,D3D12_MESSAGE_SEVERITY severity,D3D12_MESSAGE_ID i_d,LPCSTR description)1115 static INLINE HRESULT D3D12AddMessage(
1116 D3D12InfoQueue info_queue,
1117 D3D12_MESSAGE_CATEGORY category,
1118 D3D12_MESSAGE_SEVERITY severity,
1119 D3D12_MESSAGE_ID i_d,
1120 LPCSTR description)
1121 {
1122 return info_queue->lpVtbl->AddMessage(info_queue, category, severity, i_d, description);
1123 }
D3D12AddApplicationMessage(D3D12InfoQueue info_queue,D3D12_MESSAGE_SEVERITY severity,LPCSTR description)1124 static INLINE HRESULT D3D12AddApplicationMessage(
1125 D3D12InfoQueue info_queue, D3D12_MESSAGE_SEVERITY severity, LPCSTR description)
1126 {
1127 return info_queue->lpVtbl->AddApplicationMessage(info_queue, severity, description);
1128 }
1129 static INLINE HRESULT
D3D12SetBreakOnCategory(D3D12InfoQueue info_queue,D3D12_MESSAGE_CATEGORY category,BOOL b_enable)1130 D3D12SetBreakOnCategory(D3D12InfoQueue info_queue, D3D12_MESSAGE_CATEGORY category, BOOL b_enable)
1131 {
1132 return info_queue->lpVtbl->SetBreakOnCategory(info_queue, category, b_enable);
1133 }
1134 static INLINE HRESULT
D3D12SetBreakOnSeverity(D3D12InfoQueue info_queue,D3D12_MESSAGE_SEVERITY severity,BOOL b_enable)1135 D3D12SetBreakOnSeverity(D3D12InfoQueue info_queue, D3D12_MESSAGE_SEVERITY severity, BOOL b_enable)
1136 {
1137 return info_queue->lpVtbl->SetBreakOnSeverity(info_queue, severity, b_enable);
1138 }
1139 static INLINE HRESULT
D3D12SetBreakOnID(D3D12InfoQueue info_queue,D3D12_MESSAGE_ID i_d,BOOL b_enable)1140 D3D12SetBreakOnID(D3D12InfoQueue info_queue, D3D12_MESSAGE_ID i_d, BOOL b_enable)
1141 {
1142 return info_queue->lpVtbl->SetBreakOnID(info_queue, i_d, b_enable);
1143 }
1144 static INLINE BOOL
D3D12GetBreakOnCategory(D3D12InfoQueue info_queue,D3D12_MESSAGE_CATEGORY category)1145 D3D12GetBreakOnCategory(D3D12InfoQueue info_queue, D3D12_MESSAGE_CATEGORY category)
1146 {
1147 return info_queue->lpVtbl->GetBreakOnCategory(info_queue, category);
1148 }
1149 static INLINE BOOL
D3D12GetBreakOnSeverity(D3D12InfoQueue info_queue,D3D12_MESSAGE_SEVERITY severity)1150 D3D12GetBreakOnSeverity(D3D12InfoQueue info_queue, D3D12_MESSAGE_SEVERITY severity)
1151 {
1152 return info_queue->lpVtbl->GetBreakOnSeverity(info_queue, severity);
1153 }
D3D12GetBreakOnID(D3D12InfoQueue info_queue,D3D12_MESSAGE_ID i_d)1154 static INLINE BOOL D3D12GetBreakOnID(D3D12InfoQueue info_queue, D3D12_MESSAGE_ID i_d)
1155 {
1156 return info_queue->lpVtbl->GetBreakOnID(info_queue, i_d);
1157 }
D3D12SetMuteDebugOutput(D3D12InfoQueue info_queue,BOOL b_mute)1158 static INLINE void D3D12SetMuteDebugOutput(D3D12InfoQueue info_queue, BOOL b_mute)
1159 {
1160 info_queue->lpVtbl->SetMuteDebugOutput(info_queue, b_mute);
1161 }
D3D12GetMuteDebugOutput(D3D12InfoQueue info_queue)1162 static INLINE BOOL D3D12GetMuteDebugOutput(D3D12InfoQueue info_queue)
1163 {
1164 return info_queue->lpVtbl->GetMuteDebugOutput(info_queue);
1165 }
1166
1167 /* end of auto-generated */
1168 #ifdef DEBUG
D3D12GetDebugInterface_(D3D12Debug * out)1169 static INLINE HRESULT D3D12GetDebugInterface_(D3D12Debug* out)
1170 {
1171 return D3D12GetDebugInterface(uuidof(ID3D12Debug), (void**)out);
1172 }
1173 #endif
1174
1175 static INLINE HRESULT
D3D12CreateDevice_(DXGIAdapter adapter,D3D_FEATURE_LEVEL MinimumFeatureLevel,D3D12Device * out)1176 D3D12CreateDevice_(DXGIAdapter adapter, D3D_FEATURE_LEVEL MinimumFeatureLevel, D3D12Device* out)
1177 {
1178 return D3D12CreateDevice(
1179 (IUnknown*)adapter, MinimumFeatureLevel, uuidof(ID3D12Device), (void**)out);
1180 }
1181
D3D12CreateGraphicsCommandList(D3D12Device device,UINT node_mask,D3D12_COMMAND_LIST_TYPE type,D3D12CommandAllocator command_allocator,D3D12PipelineState initial_state,D3D12GraphicsCommandList * out)1182 static INLINE HRESULT D3D12CreateGraphicsCommandList(
1183 D3D12Device device,
1184 UINT node_mask,
1185 D3D12_COMMAND_LIST_TYPE type,
1186 D3D12CommandAllocator command_allocator,
1187 D3D12PipelineState initial_state,
1188 D3D12GraphicsCommandList* out)
1189 {
1190 return device->lpVtbl->CreateCommandList(
1191 device, node_mask, type, command_allocator, initial_state,
1192 uuidof(ID3D12GraphicsCommandList), (void**)out);
1193 }
1194
D3D12ClearRenderTargetView(D3D12GraphicsCommandList command_list,D3D12_CPU_DESCRIPTOR_HANDLE render_target_view,const FLOAT colorRGBA[4],UINT num_rects,const D3D12_RECT * rects)1195 static INLINE void D3D12ClearRenderTargetView(
1196 D3D12GraphicsCommandList command_list,
1197 D3D12_CPU_DESCRIPTOR_HANDLE render_target_view,
1198 const FLOAT colorRGBA[4],
1199 UINT num_rects,
1200 const D3D12_RECT* rects)
1201 {
1202 command_list->lpVtbl->ClearRenderTargetView(
1203 command_list, render_target_view, colorRGBA, num_rects, rects);
1204 }
1205
D3D12ExecuteCommandLists(D3D12CommandQueue command_queue,UINT num_command_lists,const D3D12CommandList * command_lists)1206 static INLINE void D3D12ExecuteCommandLists(
1207 D3D12CommandQueue command_queue,
1208 UINT num_command_lists,
1209 const D3D12CommandList* command_lists)
1210 {
1211 command_queue->lpVtbl->ExecuteCommandLists(command_queue, num_command_lists, command_lists);
1212 }
D3D12ExecuteGraphicsCommandLists(D3D12CommandQueue command_queue,UINT num_command_lists,const D3D12GraphicsCommandList * command_lists)1213 static INLINE void D3D12ExecuteGraphicsCommandLists(
1214 D3D12CommandQueue command_queue,
1215 UINT num_command_lists,
1216 const D3D12GraphicsCommandList* command_lists)
1217 {
1218 command_queue->lpVtbl->ExecuteCommandLists(
1219 command_queue, num_command_lists, (ID3D12CommandList* const*)command_lists);
1220 }
1221
1222 static INLINE HRESULT
DXGIGetSwapChainBuffer(DXGISwapChain swapchain,UINT buffer,D3D12Resource * surface)1223 DXGIGetSwapChainBuffer(DXGISwapChain swapchain, UINT buffer, D3D12Resource* surface)
1224 {
1225 return swapchain->lpVtbl->GetBuffer(swapchain, buffer, uuidof(ID3D12Resource), (void**)surface);
1226 }
D3D12SetDescriptorHeaps(D3D12GraphicsCommandList command_list,UINT num_descriptor_heaps,const D3D12DescriptorHeap * descriptor_heaps)1227 static INLINE void D3D12SetDescriptorHeaps(
1228 D3D12GraphicsCommandList command_list,
1229 UINT num_descriptor_heaps,
1230 const D3D12DescriptorHeap* descriptor_heaps)
1231 {
1232 command_list->lpVtbl->SetDescriptorHeaps(command_list, num_descriptor_heaps, descriptor_heaps);
1233 }
1234 #if 0 /* function prototype is wrong ... */
1235 static INLINE D3D12_CPU_DESCRIPTOR_HANDLE D3D12GetCPUDescriptorHandleForHeapStart(
1236 D3D12DescriptorHeap descriptor_heap)
1237 {
1238 return descriptor_heap->lpVtbl->GetCPUDescriptorHandleForHeapStart(descriptor_heap);
1239 }
1240 static INLINE D3D12_GPU_DESCRIPTOR_HANDLE D3D12GetGPUDescriptorHandleForHeapStart(
1241 D3D12DescriptorHeap descriptor_heap)
1242 {
1243 return descriptor_heap->lpVtbl->GetGPUDescriptorHandleForHeapStart(descriptor_heap);
1244 }
1245 #else
1246 static INLINE D3D12_CPU_DESCRIPTOR_HANDLE
D3D12GetCPUDescriptorHandleForHeapStart(D3D12DescriptorHeap descriptor_heap)1247 D3D12GetCPUDescriptorHandleForHeapStart(D3D12DescriptorHeap descriptor_heap)
1248 {
1249 D3D12_CPU_DESCRIPTOR_HANDLE out;
1250 ((void(STDMETHODCALLTYPE*)(ID3D12DescriptorHeap*, D3D12_CPU_DESCRIPTOR_HANDLE*))
1251 descriptor_heap->lpVtbl->GetCPUDescriptorHandleForHeapStart)(descriptor_heap, &out);
1252 return out;
1253 }
1254 static INLINE D3D12_GPU_DESCRIPTOR_HANDLE
D3D12GetGPUDescriptorHandleForHeapStart(D3D12DescriptorHeap descriptor_heap)1255 D3D12GetGPUDescriptorHandleForHeapStart(D3D12DescriptorHeap descriptor_heap)
1256 {
1257 D3D12_GPU_DESCRIPTOR_HANDLE out;
1258 ((void(STDMETHODCALLTYPE*)(ID3D12DescriptorHeap*, D3D12_GPU_DESCRIPTOR_HANDLE*))
1259 descriptor_heap->lpVtbl->GetGPUDescriptorHandleForHeapStart)(descriptor_heap, &out);
1260 return out;
1261 }
1262 #endif
1263
1264 /* internal */
1265
1266 #include <retro_math.h>
1267 #include <retro_common_api.h>
1268 #include <gfx/math/matrix_4x4.h>
1269
1270 #include "../common/d3dcompiler_common.h"
1271 #include "../../retroarch.h"
1272 #include "../drivers_shader/slang_process.h"
1273
1274 #define D3D12_MAX_GPU_COUNT 16
1275
1276 typedef struct d3d12_vertex_t
1277 {
1278 float position[2];
1279 float texcoord[2];
1280 float color[4];
1281 } d3d12_vertex_t;
1282
1283 typedef struct
1284 {
1285 struct
1286 {
1287 float x, y, w, h;
1288 } pos;
1289 struct
1290 {
1291 float u, v, w, h;
1292 } coords;
1293 UINT32 colors[4];
1294 struct
1295 {
1296 float scaling;
1297 float rotation;
1298 } params;
1299 } d3d12_sprite_t;
1300
1301 typedef struct
1302 {
1303 D3D12DescriptorHeap handle; /* descriptor pool */
1304 D3D12_DESCRIPTOR_HEAP_DESC desc;
1305 D3D12_CPU_DESCRIPTOR_HANDLE cpu; /* descriptor */
1306 D3D12_GPU_DESCRIPTOR_HANDLE gpu; /* descriptor */
1307 UINT stride;
1308 bool* map;
1309 int start;
1310 } d3d12_descriptor_heap_t;
1311
1312 typedef struct
1313 {
1314 D3D12Resource handle;
1315 D3D12Resource upload_buffer;
1316 D3D12_RESOURCE_DESC desc;
1317 /* the first view is srv, the rest are mip levels uavs */
1318 D3D12_CPU_DESCRIPTOR_HANDLE cpu_descriptor[D3D12_MAX_TEXTURE_DIMENSION_2_TO_EXP - 5];
1319 D3D12_GPU_DESCRIPTOR_HANDLE gpu_descriptor[D3D12_MAX_TEXTURE_DIMENSION_2_TO_EXP - 5];
1320 D3D12_GPU_DESCRIPTOR_HANDLE sampler;
1321 D3D12_CPU_DESCRIPTOR_HANDLE rt_view;
1322 D3D12_PLACED_SUBRESOURCE_FOOTPRINT layout;
1323 UINT num_rows;
1324 UINT64 row_size_in_bytes;
1325 UINT64 total_bytes;
1326 d3d12_descriptor_heap_t* srv_heap;
1327 bool dirty;
1328 float4_t size_data;
1329 } d3d12_texture_t;
1330
1331 #ifndef ALIGN
1332 #ifdef _MSC_VER
1333 #define ALIGN(x) __declspec(align(x))
1334 #else
1335 #define ALIGN(x) __attribute__((aligned(x)))
1336 #endif
1337 #endif
1338
1339 typedef struct ALIGN(16)
1340 {
1341 math_matrix_4x4 mvp;
1342 struct
1343 {
1344 float width;
1345 float height;
1346 } OutputSize;
1347 float time;
1348 } d3d12_uniform_t;
1349
1350 typedef struct
1351 {
1352 unsigned cur_mon_id;
1353 #ifdef __WINRT__
1354 DXGIFactory2 factory;
1355 #else
1356 DXGIFactory factory;
1357 #endif
1358 DXGIAdapter adapter;
1359 D3D12Device device;
1360
1361 IDXGIAdapter1 *adapters[D3D12_MAX_GPU_COUNT];
1362 struct string_list *gpu_list;
1363
1364 struct
1365 {
1366 D3D12CommandQueue handle;
1367 D3D12CommandAllocator allocator;
1368 D3D12GraphicsCommandList cmd;
1369 D3D12Fence fence;
1370 HANDLE fenceEvent;
1371 UINT64 fenceValue;
1372 } queue;
1373
1374 struct
1375 {
1376 D3D12RootSignature cs_rootSignature; /* descriptor layout */
1377 D3D12RootSignature sl_rootSignature; /* descriptor layout */
1378 D3D12RootSignature rootSignature; /* descriptor layout */
1379 d3d12_descriptor_heap_t srv_heap; /* ShaderResouceView descritor heap */
1380 d3d12_descriptor_heap_t rtv_heap; /* RenderTargetView descritor heap */
1381 d3d12_descriptor_heap_t sampler_heap;
1382 } desc;
1383
1384 struct
1385 {
1386 DXGISwapChain handle;
1387 D3D12Resource renderTargets[2];
1388 D3D12_CPU_DESCRIPTOR_HANDLE desc_handles[2];
1389 D3D12_VIEWPORT viewport;
1390 D3D12_RECT scissorRect;
1391 float clearcolor[4];
1392 int frame_index;
1393 bool vsync;
1394 unsigned swap_interval;
1395 } chain;
1396
1397 struct
1398 {
1399 d3d12_texture_t texture[GFX_MAX_FRAME_HISTORY + 1];
1400 D3D12Resource ubo;
1401 D3D12_CONSTANT_BUFFER_VIEW_DESC ubo_view;
1402 D3D12Resource vbo;
1403 D3D12_VERTEX_BUFFER_VIEW vbo_view;
1404 D3D12_VIEWPORT viewport;
1405 D3D12_RECT scissorRect;
1406 float4_t output_size;
1407 int rotation;
1408 } frame;
1409
1410 struct
1411 {
1412 D3D12Resource vbo;
1413 D3D12_VERTEX_BUFFER_VIEW vbo_view;
1414 d3d12_texture_t texture;
1415
1416 float alpha;
1417 bool enabled;
1418 bool fullscreen;
1419 } menu;
1420
1421 struct
1422 {
1423 D3D12PipelineStateRef pipe;
1424 D3D12PipelineState pipe_blend;
1425 D3D12PipelineState pipe_noblend;
1426 D3D12PipelineState pipe_font;
1427 D3D12Resource vbo;
1428 D3D12_VERTEX_BUFFER_VIEW vbo_view;
1429 int offset;
1430 int capacity;
1431 bool enabled;
1432 } sprites;
1433
1434 #ifdef HAVE_OVERLAY
1435 struct
1436 {
1437 D3D12Resource vbo;
1438 D3D12_VERTEX_BUFFER_VIEW vbo_view;
1439 d3d12_texture_t* textures;
1440 bool enabled;
1441 bool fullscreen;
1442 int count;
1443 } overlays;
1444 #endif
1445
1446 struct
1447 {
1448 D3D12PipelineState pipe;
1449 D3D12_GPU_DESCRIPTOR_HANDLE sampler;
1450 D3D12Resource buffers[SLANG_CBUFFER_MAX];
1451 D3D12_CONSTANT_BUFFER_VIEW_DESC buffer_view[SLANG_CBUFFER_MAX];
1452 d3d12_texture_t rt;
1453 d3d12_texture_t feedback;
1454 D3D12_VIEWPORT viewport;
1455 D3D12_RECT scissorRect;
1456 pass_semantics_t semantics;
1457 uint32_t frame_count;
1458 int32_t frame_direction;
1459 D3D12_GPU_DESCRIPTOR_HANDLE textures;
1460 D3D12_GPU_DESCRIPTOR_HANDLE samplers;
1461 } pass[GFX_MAX_SHADERS];
1462
1463 struct video_shader* shader_preset;
1464 d3d12_texture_t luts[GFX_MAX_TEXTURES];
1465
1466 D3D12PipelineState pipes[GFX_MAX_SHADERS];
1467 D3D12PipelineState mipmapgen_pipe;
1468 d3d12_uniform_t ubo_values;
1469 D3D12Resource ubo;
1470 D3D12_CONSTANT_BUFFER_VIEW_DESC ubo_view;
1471 DXGI_FORMAT format;
1472 D3D12_GPU_DESCRIPTOR_HANDLE samplers[RARCH_FILTER_MAX][RARCH_WRAP_MAX];
1473 math_matrix_4x4 mvp, mvp_no_rot;
1474 struct video_viewport vp;
1475 bool resize_chain;
1476 bool keep_aspect;
1477 bool resize_viewport;
1478 bool resize_render_targets;
1479 bool init_history;
1480 D3D12Resource menu_pipeline_vbo;
1481 D3D12_VERTEX_BUFFER_VIEW menu_pipeline_vbo_view;
1482
1483 #ifdef DEBUG
1484 D3D12Debug debugController;
1485 #endif
1486 } d3d12_video_t;
1487
1488 typedef enum {
1489 ROOT_ID_TEXTURE_T = 0,
1490 ROOT_ID_SAMPLER_T,
1491 ROOT_ID_UBO,
1492 ROOT_ID_PC,
1493 ROOT_ID_MAX,
1494 } root_signature_parameter_index_t;
1495
1496 typedef enum {
1497 CS_ROOT_ID_TEXTURE_T = 0,
1498 CS_ROOT_ID_UAV_T,
1499 CS_ROOT_ID_CONSTANTS,
1500 CS_ROOT_ID_MAX,
1501 } compute_root_index_t;
1502
1503 RETRO_BEGIN_DECLS
1504
1505 extern D3D12_RENDER_TARGET_BLEND_DESC d3d12_blend_enable_desc;
1506
1507 bool d3d12_init_base(d3d12_video_t* d3d12);
1508
1509 bool d3d12_init_descriptors(d3d12_video_t* d3d12);
1510 void d3d12_init_samplers(d3d12_video_t* d3d12);
1511
1512 bool d3d12_init_pipeline(
1513 D3D12Device device,
1514 D3DBlob vs_code,
1515 D3DBlob ps_code,
1516 D3DBlob gs_code,
1517 D3D12_GRAPHICS_PIPELINE_STATE_DESC* desc,
1518 D3D12PipelineState* out);
1519
1520 bool d3d12_init_swapchain(d3d12_video_t* d3d12, int width, int height, void *corewindow);
1521
1522 bool d3d12_init_queue(d3d12_video_t* d3d12);
1523
1524 D3D12_GPU_VIRTUAL_ADDRESS
1525 d3d12_create_buffer(D3D12Device device, UINT size_in_bytes, D3D12Resource* buffer);
1526
1527 void d3d12_init_texture(D3D12Device device, d3d12_texture_t* tex);
1528 void d3d12_release_texture(d3d12_texture_t* texture);
1529
1530 void d3d12_update_texture(
1531 int width,
1532 int height,
1533 int pitch,
1534 DXGI_FORMAT format,
1535 const void* data,
1536 d3d12_texture_t* texture);
1537
1538 void d3d12_upload_texture(D3D12GraphicsCommandList cmd,
1539 d3d12_texture_t* texture, void *userdata);
1540
1541 void d3d12_create_fullscreen_quad_vbo(
1542 D3D12Device device, D3D12_VERTEX_BUFFER_VIEW* view, D3D12Resource* vbo);
1543
1544 DXGI_FORMAT d3d12_get_closest_match(D3D12Device device, D3D12_FEATURE_DATA_FORMAT_SUPPORT* desired);
1545
1546 #if !defined(__cplusplus) || defined(CINTERFACE)
d3d12_resource_transition(D3D12GraphicsCommandList cmd,D3D12Resource resource,D3D12_RESOURCE_STATES state_before,D3D12_RESOURCE_STATES state_after)1547 static INLINE void d3d12_resource_transition(
1548 D3D12GraphicsCommandList cmd,
1549 D3D12Resource resource,
1550 D3D12_RESOURCE_STATES state_before,
1551 D3D12_RESOURCE_STATES state_after)
1552 {
1553 D3D12_RESOURCE_BARRIER barrier;
1554 barrier.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION;
1555 barrier.Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE;
1556 barrier.Transition.pResource = resource;
1557 barrier.Transition.StateBefore = state_before;
1558 barrier.Transition.StateAfter = state_after;
1559 barrier.Transition.Subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES;
1560 D3D12ResourceBarrier(cmd, 1, &barrier);
1561 }
1562
d3d12_set_texture(D3D12GraphicsCommandList cmd,const d3d12_texture_t * texture)1563 static INLINE void d3d12_set_texture(D3D12GraphicsCommandList cmd, const d3d12_texture_t* texture)
1564 {
1565 D3D12SetGraphicsRootDescriptorTable(cmd, ROOT_ID_TEXTURE_T, texture->gpu_descriptor[0]);
1566 }
1567
1568 static INLINE void
d3d12_set_sampler(D3D12GraphicsCommandList cmd,D3D12_GPU_DESCRIPTOR_HANDLE sampler)1569 d3d12_set_sampler(D3D12GraphicsCommandList cmd, D3D12_GPU_DESCRIPTOR_HANDLE sampler)
1570 {
1571 D3D12SetGraphicsRootDescriptorTable(cmd, ROOT_ID_SAMPLER_T, sampler);
1572 }
1573
1574 static INLINE void
d3d12_set_texture_and_sampler(D3D12GraphicsCommandList cmd,const d3d12_texture_t * texture)1575 d3d12_set_texture_and_sampler(D3D12GraphicsCommandList cmd, const d3d12_texture_t* texture)
1576 {
1577 D3D12SetGraphicsRootDescriptorTable(cmd, ROOT_ID_TEXTURE_T, texture->gpu_descriptor[0]);
1578 D3D12SetGraphicsRootDescriptorTable(cmd, ROOT_ID_SAMPLER_T, texture->sampler);
1579 }
1580
1581 #endif
1582
1583 RETRO_END_DECLS
1584