From 094196220d95c0098bd55365f8cc667324108dfa Mon Sep 17 00:00:00 2001 From: aliaspider Date: Sun, 21 Jan 2018 04:10:45 +0100 Subject: [PATCH 1/3] (D3D11/D3D12) initial video driver implementation. - some headers from the windows 10 sdk need to be added to the include path when targeting mingw : d3d11.h d3d11sdklayers.h d3d12.h d3d12sdklayers.h d3d12shader.h d3dcommon.h d3dcompiler.h --- Makefile.common | 26 + configuration.c | 6 + gfx/common/d3d11_common.c | 43 + gfx/common/d3d11_common.h | 1391 +++++++++++++++++++++ gfx/common/d3d12_common.c | 482 +++++++ gfx/common/d3d12_common.h | 957 ++++++++++++++ gfx/common/d3dcompiler_common.c | 88 ++ gfx/common/d3dcompiler_common.h | 88 ++ gfx/common/dxgi_common.c | 39 + gfx/common/dxgi_common.h | 450 +++++++ gfx/drivers/d3d11.c | 614 +++++++++ gfx/drivers/d3d12.c | 449 +++++++ gfx/drivers/d3d_shaders/opaque_sm5.hlsl.h | 25 + gfx/video_driver.c | 6 + gfx/video_driver.h | 2 + griffin/griffin.c | 8 + 16 files changed, 4674 insertions(+) create mode 100644 gfx/common/d3d11_common.c create mode 100644 gfx/common/d3d11_common.h create mode 100644 gfx/common/d3d12_common.c create mode 100644 gfx/common/d3d12_common.h create mode 100644 gfx/common/d3dcompiler_common.c create mode 100644 gfx/common/d3dcompiler_common.h create mode 100644 gfx/common/dxgi_common.c create mode 100644 gfx/common/dxgi_common.h create mode 100644 gfx/drivers/d3d11.c create mode 100644 gfx/drivers/d3d12.c create mode 100644 gfx/drivers/d3d_shaders/opaque_sm5.hlsl.h diff --git a/Makefile.common b/Makefile.common index 71a91c16dd..554fd92033 100644 --- a/Makefile.common +++ b/Makefile.common @@ -1289,6 +1289,32 @@ endif endif endif +ifeq ($(HAVE_D3D11), 1) + OBJ += gfx/drivers/d3d11.o gfx/common/d3d11_common.o + DEFINES += -DHAVE_D3D11 +# LIBS += -ld3d11 + WANT_DXGI = 1 + WANT_D3DCOMPILER = 1 +endif + +ifeq ($(HAVE_D3D12), 1) + OBJ += gfx/drivers/d3d12.o gfx/common/d3d12_common.o + DEFINES += -DHAVE_D3D12 +# LIBS += -ld3d12 + WANT_DXGI = 1 + WANT_D3DCOMPILER = 1 +endif + +ifeq ($(WANT_D3DCOMPILER), 1) + OBJ += gfx/common/d3dcompiler_common.o +# LIBS += -ld3dcompiler +endif + +ifeq ($(WANT_DXGI), 1) + OBJ += gfx/common/dxgi_common.o +# LIBS += -ldxgi +endif + ifeq ($(HAVE_D3D8), 1) HAVE_D3D_COMMON = 1 HAVE_DX_COMMON = 1 diff --git a/configuration.c b/configuration.c index 98b41b402d..446be959af 100644 --- a/configuration.c +++ b/configuration.c @@ -132,6 +132,8 @@ enum video_driver_enum VIDEO_CTR, VIDEO_SWITCH, VIDEO_D3D9, + VIDEO_D3D11, + VIDEO_D3D12, VIDEO_VG, VIDEO_OMAP, VIDEO_EXYNOS, @@ -695,6 +697,10 @@ const char *config_get_default_video(void) case VIDEO_XDK_D3D: case VIDEO_D3D9: return "d3d"; + case VIDEO_D3D11: + return "d3d11"; + case VIDEO_D3D12: + return "d3d12"; case VIDEO_PSP1: return "psp1"; case VIDEO_VITA2D: diff --git a/gfx/common/d3d11_common.c b/gfx/common/d3d11_common.c new file mode 100644 index 0000000000..5eaf2bd0e2 --- /dev/null +++ b/gfx/common/d3d11_common.c @@ -0,0 +1,43 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2014-2018 - Ali Bouhlel + * + * RetroArch is free software: you can redistribute it and/or modify it under the terms + * of the GNU General Public License as published by the Free Software Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with RetroArch. + * If not, see . + */ + +#include "d3d11_common.h" + +#include + +static dylib_t d3d11_dll; + +HRESULT WINAPI D3D11CreateDeviceAndSwapChain( IDXGIAdapter* pAdapter,D3D_DRIVER_TYPE DriverType, HMODULE Software, UINT Flags, + CONST D3D_FEATURE_LEVEL* pFeatureLevels, UINT FeatureLevels, UINT SDKVersion, CONST DXGI_SWAP_CHAIN_DESC* pSwapChainDesc, + IDXGISwapChain** ppSwapChain, ID3D11Device** ppDevice, D3D_FEATURE_LEVEL* pFeatureLevel, ID3D11DeviceContext** ppImmediateContext) +{ + static PFN_D3D11_CREATE_DEVICE_AND_SWAP_CHAIN fp; + + if(!d3d11_dll) + d3d11_dll = dylib_load("d3d11.dll"); + + if(!d3d11_dll) + return TYPE_E_CANTLOADLIBRARY; + + if(!fp) + fp = (PFN_D3D11_CREATE_DEVICE_AND_SWAP_CHAIN)dylib_proc(d3d11_dll, "D3D11CreateDeviceAndSwapChain"); + + if(!fp) + return TYPE_E_CANTLOADLIBRARY; + + return fp(pAdapter,DriverType,Software, Flags,pFeatureLevels, FeatureLevels, SDKVersion, pSwapChainDesc, + ppSwapChain, ppDevice, pFeatureLevel, ppImmediateContext); + +} diff --git a/gfx/common/d3d11_common.h b/gfx/common/d3d11_common.h new file mode 100644 index 0000000000..d91092ce3a --- /dev/null +++ b/gfx/common/d3d11_common.h @@ -0,0 +1,1391 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2014-2018 - Ali Bouhlel + * + * RetroArch is free software: you can redistribute it and/or modify it under the terms + * of the GNU General Public License as published by the Free Software Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with RetroArch. + * If not, see . + */ + + +#pragma once + +#ifdef __MINGW32__ +#define __REQUIRED_RPCNDR_H_VERSION__ 475 +#define _In_ +#define _In_opt_ +#define _Null_ + +#define _Out_writes_bytes_opt_(s) +#define _Inout_opt_bytecount_(s) +#endif + +#define CINTERFACE +#define COBJMACROS +//#ifdef __GNUC__ +//#define WIDL_C_INLINE_WRAPPERS +//#include <_mingw.h> +//#undef __forceinline +//#define __forceinline inline __attribute__((__always_inline__)) +//#endif + +#include +#include "dxgi_common.h" + +#ifndef countof +#define countof(a) (sizeof(a)/ sizeof(*a)) +#endif + +#ifndef __uuidof +#define __uuidof(type) &IID_##type +#endif + +#ifndef COM_RELEASE_DECLARED +#define COM_RELEASE_DECLARED +#if defined(__cplusplus) && !defined(CINTERFACE) +static inline ULONG Release(IUnknown* object) +{ + return object->Release(); +} +#else +static inline ULONG Release(void* object) +{ + return ((IUnknown*)object)->lpVtbl->Release(object); +} +#endif +#endif + +typedef ID3D11InputLayout* D3D11InputLayout; +typedef ID3D11RasterizerState* D3D11RasterizerState; +typedef ID3D11DepthStencilState* D3D11DepthStencilState; +typedef ID3D11BlendState* D3D11BlendState; +typedef ID3D11PixelShader* D3D11PixelShader; +typedef ID3D11SamplerState* D3D11SamplerState; +typedef ID3D11VertexShader* D3D11VertexShader; +typedef ID3D11DomainShader* D3D11DomainShader; +typedef ID3D11HullShader* D3D11HullShader; +typedef ID3D11ComputeShader* D3D11ComputeShader; +typedef ID3D11GeometryShader* D3D11GeometryShader; + +/* auto-generated */ + +typedef ID3D11Resource* D3D11Resource; +typedef ID3D11Buffer* D3D11Buffer; +typedef ID3D11Texture1D* D3D11Texture1D; +typedef ID3D11Texture2D* D3D11Texture2D; +typedef ID3D11Texture3D* D3D11Texture3D; +typedef ID3D11View* D3D11View; +typedef ID3D11ShaderResourceView* D3D11ShaderResourceView; +typedef ID3D11RenderTargetView* D3D11RenderTargetView; +typedef ID3D11DepthStencilView* D3D11DepthStencilView; +typedef ID3D11UnorderedAccessView* D3D11UnorderedAccessView; +typedef ID3D11Asynchronous* D3D11Asynchronous; +typedef ID3D11Query* D3D11Query; +typedef ID3D11Predicate* D3D11Predicate; +typedef ID3D11Counter* D3D11Counter; +typedef ID3D11ClassInstance* D3D11ClassInstance; +typedef ID3D11ClassLinkage* D3D11ClassLinkage; +typedef ID3D11CommandList* D3D11CommandList; +typedef ID3D11DeviceContext* D3D11DeviceContext; +typedef ID3D11VideoDecoder* D3D11VideoDecoder; +typedef ID3D11VideoProcessorEnumerator* D3D11VideoProcessorEnumerator; +typedef ID3D11VideoProcessor* D3D11VideoProcessor; +typedef ID3D11AuthenticatedChannel* D3D11AuthenticatedChannel; +typedef ID3D11CryptoSession* D3D11CryptoSession; +typedef ID3D11VideoDecoderOutputView* D3D11VideoDecoderOutputView; +typedef ID3D11VideoProcessorInputView* D3D11VideoProcessorInputView; +typedef ID3D11VideoProcessorOutputView* D3D11VideoProcessorOutputView; +typedef ID3D11VideoContext* D3D11VideoContext; +typedef ID3D11VideoDevice* D3D11VideoDevice; +typedef ID3D11Device* D3D11Device; +typedef ID3D11Debug* D3D11Debug; +typedef ID3D11SwitchToRef* D3D11SwitchToRef; +typedef ID3D11TracingDevice* D3D11TracingDevice; +typedef ID3D11InfoQueue* D3D11InfoQueue; + +static inline void D3D11SetResourceEvictionPriority(D3D11Resource resource, UINT eviction_priority) +{ + resource->lpVtbl->SetEvictionPriority(resource, eviction_priority); +} +static inline UINT D3D11GetResourceEvictionPriority(D3D11Resource resource) +{ + return resource->lpVtbl->GetEvictionPriority(resource); +} +static inline void D3D11SetBufferEvictionPriority(D3D11Buffer buffer, UINT eviction_priority) +{ + buffer->lpVtbl->SetEvictionPriority(buffer, eviction_priority); +} +static inline UINT D3D11GetBufferEvictionPriority(D3D11Buffer buffer) +{ + return buffer->lpVtbl->GetEvictionPriority(buffer); +} +static inline void D3D11SetTexture1DEvictionPriority(D3D11Texture1D texture1d, UINT eviction_priority) +{ + texture1d->lpVtbl->SetEvictionPriority(texture1d, eviction_priority); +} +static inline UINT D3D11GetTexture1DEvictionPriority(D3D11Texture1D texture1d) +{ + return texture1d->lpVtbl->GetEvictionPriority(texture1d); +} +static inline void D3D11SetTexture2DEvictionPriority(D3D11Texture2D texture2d, UINT eviction_priority) +{ + texture2d->lpVtbl->SetEvictionPriority(texture2d, eviction_priority); +} +static inline UINT D3D11GetTexture2DEvictionPriority(D3D11Texture2D texture2d) +{ + return texture2d->lpVtbl->GetEvictionPriority(texture2d); +} +static inline void D3D11SetTexture3DEvictionPriority(D3D11Texture3D texture3d, UINT eviction_priority) +{ + texture3d->lpVtbl->SetEvictionPriority(texture3d, eviction_priority); +} +static inline UINT D3D11GetTexture3DEvictionPriority(D3D11Texture3D texture3d) +{ + return texture3d->lpVtbl->GetEvictionPriority(texture3d); +} +static inline void D3D11GetViewResource(D3D11View view, D3D11Resource* resource) +{ + view->lpVtbl->GetResource(view, resource); +} +static inline void D3D11GetShaderResourceViewResource(D3D11ShaderResourceView shader_resource_view, D3D11Resource* resource) +{ + shader_resource_view->lpVtbl->GetResource(shader_resource_view, resource); +} +static inline void D3D11GetRenderTargetViewResource(D3D11RenderTargetView render_target_view, D3D11Resource* resource) +{ + render_target_view->lpVtbl->GetResource(render_target_view, resource); +} +static inline void D3D11GetDepthStencilViewResource(D3D11DepthStencilView depth_stencil_view, D3D11Resource* resource) +{ + depth_stencil_view->lpVtbl->GetResource(depth_stencil_view, resource); +} +static inline void D3D11GetUnorderedAccessViewResource(D3D11UnorderedAccessView unordered_access_view, D3D11Resource* resource) +{ + unordered_access_view->lpVtbl->GetResource(unordered_access_view, resource); +} +static inline UINT D3D11GetAsynchronousDataSize(D3D11Asynchronous asynchronous) +{ + return asynchronous->lpVtbl->GetDataSize(asynchronous); +} +static inline UINT D3D11GetQueryDataSize(D3D11Query query) +{ + return query->lpVtbl->GetDataSize(query); +} +static inline UINT D3D11GetPredicateDataSize(D3D11Predicate predicate) +{ + return predicate->lpVtbl->GetDataSize(predicate); +} +static inline UINT D3D11GetCounterDataSize(D3D11Counter counter) +{ + return counter->lpVtbl->GetDataSize(counter); +} +static inline void D3D11GetClassLinkage(D3D11ClassInstance class_instance, D3D11ClassLinkage* linkage) +{ + class_instance->lpVtbl->GetClassLinkage(class_instance, linkage); +} +static inline void D3D11GetInstanceName(D3D11ClassInstance class_instance, LPSTR instance_name, SIZE_T* buffer_length) +{ + class_instance->lpVtbl->GetInstanceName(class_instance, instance_name, buffer_length); +} +static inline void D3D11GetTypeName(D3D11ClassInstance class_instance, LPSTR type_name, SIZE_T* buffer_length) +{ + class_instance->lpVtbl->GetTypeName(class_instance, type_name, buffer_length); +} +static inline HRESULT D3D11GetClassInstance(D3D11ClassLinkage class_linkage, LPCSTR class_instance_name, UINT instance_index, D3D11ClassInstance* instance) +{ + return class_linkage->lpVtbl->GetClassInstance(class_linkage, class_instance_name, instance_index, instance); +} +static inline HRESULT D3D11CreateClassInstance(D3D11ClassLinkage class_linkage, LPCSTR class_type_name, UINT constant_buffer_offset, UINT constant_vector_offset, UINT texture_offset, UINT sampler_offset, D3D11ClassInstance* instance) +{ + return class_linkage->lpVtbl->CreateClassInstance(class_linkage, class_type_name, constant_buffer_offset, constant_vector_offset, texture_offset, sampler_offset, instance); +} +static inline UINT D3D11GetCommandListContextFlags(D3D11CommandList command_list) +{ + return command_list->lpVtbl->GetContextFlags(command_list); +} +static inline void D3D11SetVShaderConstantBuffers(D3D11DeviceContext device_context, UINT start_slot, UINT num_buffers, D3D11Buffer*const constant_buffers) +{ + device_context->lpVtbl->VSSetConstantBuffers(device_context, start_slot, num_buffers, constant_buffers); +} +static inline void D3D11SetPShaderResources(D3D11DeviceContext device_context, UINT start_slot, UINT num_views, D3D11ShaderResourceView*const shader_resource_views) +{ + device_context->lpVtbl->PSSetShaderResources(device_context, start_slot, num_views, shader_resource_views); +} +static inline void D3D11SetPShader(D3D11DeviceContext device_context, D3D11PixelShader pixel_shader, D3D11ClassInstance*const class_instances, UINT num_class_instances) +{ + device_context->lpVtbl->PSSetShader(device_context, pixel_shader, class_instances, num_class_instances); +} +static inline void D3D11SetPShaderSamplers(D3D11DeviceContext device_context, UINT start_slot, UINT num_samplers, D3D11SamplerState*const samplers) +{ + device_context->lpVtbl->PSSetSamplers(device_context, start_slot, num_samplers, samplers); +} +static inline void D3D11SetVShader(D3D11DeviceContext device_context, D3D11VertexShader vertex_shader, D3D11ClassInstance*const class_instances, UINT num_class_instances) +{ + device_context->lpVtbl->VSSetShader(device_context, vertex_shader, class_instances, num_class_instances); +} +static inline void D3D11DrawIndexed(D3D11DeviceContext device_context, UINT index_count, UINT start_index_location, INT base_vertex_location) +{ + device_context->lpVtbl->DrawIndexed(device_context, index_count, start_index_location, base_vertex_location); +} +static inline void D3D11Draw(D3D11DeviceContext device_context, UINT vertex_count, UINT start_vertex_location) +{ + device_context->lpVtbl->Draw(device_context, vertex_count, start_vertex_location); +} +static inline HRESULT D3D11Map(D3D11DeviceContext device_context, D3D11Resource resource, UINT subresource, D3D11_MAP map_type, UINT map_flags, D3D11_MAPPED_SUBRESOURCE* mapped_resource) +{ + return device_context->lpVtbl->Map(device_context, resource, subresource, map_type, map_flags, mapped_resource); +} +static inline void D3D11Unmap(D3D11DeviceContext device_context, D3D11Resource resource, UINT subresource) +{ + device_context->lpVtbl->Unmap(device_context, resource, subresource); +} +static inline void D3D11SetPShaderConstantBuffers(D3D11DeviceContext device_context, UINT start_slot, UINT num_buffers, D3D11Buffer*const constant_buffers) +{ + device_context->lpVtbl->PSSetConstantBuffers(device_context, start_slot, num_buffers, constant_buffers); +} +static inline void D3D11SetInputLayout(D3D11DeviceContext device_context, D3D11InputLayout input_layout) +{ + device_context->lpVtbl->IASetInputLayout(device_context, input_layout); +} +static inline void D3D11SetVertexBuffers(D3D11DeviceContext device_context, UINT start_slot, UINT num_buffers, D3D11Buffer*const vertex_buffers, UINT* strides, UINT* offsets) +{ + device_context->lpVtbl->IASetVertexBuffers(device_context, start_slot, num_buffers, vertex_buffers, strides, offsets); +} +static inline void D3D11SetIndexBuffer(D3D11DeviceContext device_context, D3D11Buffer index_buffer, DXGI_FORMAT format, UINT offset) +{ + device_context->lpVtbl->IASetIndexBuffer(device_context, index_buffer, format, offset); +} +static inline void D3D11DrawIndexedInstanced(D3D11DeviceContext device_context, UINT index_count_per_instance, UINT instance_count, UINT start_index_location, INT base_vertex_location, UINT start_instance_location) +{ + device_context->lpVtbl->DrawIndexedInstanced(device_context, index_count_per_instance, instance_count, start_index_location, base_vertex_location, start_instance_location); +} +static inline void D3D11DrawInstanced(D3D11DeviceContext device_context, UINT vertex_count_per_instance, UINT instance_count, UINT start_vertex_location, UINT start_instance_location) +{ + device_context->lpVtbl->DrawInstanced(device_context, vertex_count_per_instance, instance_count, start_vertex_location, start_instance_location); +} +static inline void D3D11SetGShaderConstantBuffers(D3D11DeviceContext device_context, UINT start_slot, UINT num_buffers, D3D11Buffer*const constant_buffers) +{ + device_context->lpVtbl->GSSetConstantBuffers(device_context, start_slot, num_buffers, constant_buffers); +} +static inline void D3D11SetGShader(D3D11DeviceContext device_context, D3D11GeometryShader shader, D3D11ClassInstance*const class_instances, UINT num_class_instances) +{ + device_context->lpVtbl->GSSetShader(device_context, shader, class_instances, num_class_instances); +} +static inline void D3D11SetPrimitiveTopology(D3D11DeviceContext device_context, D3D11_PRIMITIVE_TOPOLOGY topology) +{ + device_context->lpVtbl->IASetPrimitiveTopology(device_context, topology); +} +static inline void D3D11SetVShaderResources(D3D11DeviceContext device_context, UINT start_slot, UINT num_views, D3D11ShaderResourceView*const shader_resource_views) +{ + device_context->lpVtbl->VSSetShaderResources(device_context, start_slot, num_views, shader_resource_views); +} +static inline void D3D11SetVShaderSamplers(D3D11DeviceContext device_context, UINT start_slot, UINT num_samplers, D3D11SamplerState*const samplers) +{ + device_context->lpVtbl->VSSetSamplers(device_context, start_slot, num_samplers, samplers); +} +static inline void D3D11Begin(D3D11DeviceContext device_context, D3D11Asynchronous async) +{ + device_context->lpVtbl->Begin(device_context, async); +} +static inline void D3D11End(D3D11DeviceContext device_context, D3D11Asynchronous async) +{ + device_context->lpVtbl->End(device_context, async); +} +static inline HRESULT D3D11GetData(D3D11DeviceContext device_context, D3D11Asynchronous async, void* data, UINT data_size, UINT get_data_flags) +{ + return device_context->lpVtbl->GetData(device_context, async, data, data_size, get_data_flags); +} +static inline void D3D11SetPredication(D3D11DeviceContext device_context, D3D11Predicate predicate, BOOL predicate_value) +{ + device_context->lpVtbl->SetPredication(device_context, predicate, predicate_value); +} +static inline void D3D11SetGShaderResources(D3D11DeviceContext device_context, UINT start_slot, UINT num_views, D3D11ShaderResourceView*const shader_resource_views) +{ + device_context->lpVtbl->GSSetShaderResources(device_context, start_slot, num_views, shader_resource_views); +} +static inline void D3D11SetGShaderSamplers(D3D11DeviceContext device_context, UINT start_slot, UINT num_samplers, D3D11SamplerState*const samplers) +{ + device_context->lpVtbl->GSSetSamplers(device_context, start_slot, num_samplers, samplers); +} +static inline void D3D11SetRenderTargets(D3D11DeviceContext device_context, UINT num_views, D3D11RenderTargetView*const render_target_views, D3D11DepthStencilView depth_stencil_view) +{ + device_context->lpVtbl->OMSetRenderTargets(device_context, num_views, render_target_views, depth_stencil_view); +} +static inline void D3D11SetRenderTargetsAndUnorderedAccessViews(D3D11DeviceContext device_context, UINT num_rtvs, D3D11RenderTargetView*const render_target_views, D3D11DepthStencilView depth_stencil_view, UINT uavstart_slot, UINT num_uavs, D3D11UnorderedAccessView*const unordered_access_views, UINT* uavinitial_counts) +{ + device_context->lpVtbl->OMSetRenderTargetsAndUnorderedAccessViews(device_context, num_rtvs, render_target_views, depth_stencil_view, uavstart_slot, num_uavs, unordered_access_views, uavinitial_counts); +} +static inline void D3D11SetBlendState(D3D11DeviceContext device_context, D3D11BlendState blend_state, FLOAT blend_factor[4], UINT sample_mask) +{ + device_context->lpVtbl->OMSetBlendState(device_context, blend_state, blend_factor, sample_mask); +} +static inline void D3D11SetDepthStencilState(D3D11DeviceContext device_context, D3D11DepthStencilState depth_stencil_state, UINT stencil_ref) +{ + device_context->lpVtbl->OMSetDepthStencilState(device_context, depth_stencil_state, stencil_ref); +} +static inline void D3D11SOSetTargets(D3D11DeviceContext device_context, UINT num_buffers, D3D11Buffer*const sotargets, UINT* offsets) +{ + device_context->lpVtbl->SOSetTargets(device_context, num_buffers, sotargets, offsets); +} +static inline void D3D11DrawAuto(D3D11DeviceContext device_context) +{ + device_context->lpVtbl->DrawAuto(device_context); +} +static inline void D3D11DrawIndexedInstancedIndirect(D3D11DeviceContext device_context, D3D11Buffer buffer_for_args, UINT aligned_byte_offset_for_args) +{ + device_context->lpVtbl->DrawIndexedInstancedIndirect(device_context, buffer_for_args, aligned_byte_offset_for_args); +} +static inline void D3D11DrawInstancedIndirect(D3D11DeviceContext device_context, D3D11Buffer buffer_for_args, UINT aligned_byte_offset_for_args) +{ + device_context->lpVtbl->DrawInstancedIndirect(device_context, buffer_for_args, aligned_byte_offset_for_args); +} +static inline void D3D11Dispatch(D3D11DeviceContext device_context, UINT thread_group_count_x, UINT thread_group_count_y, UINT thread_group_count_z) +{ + device_context->lpVtbl->Dispatch(device_context, thread_group_count_x, thread_group_count_y, thread_group_count_z); +} +static inline void D3D11DispatchIndirect(D3D11DeviceContext device_context, D3D11Buffer buffer_for_args, UINT aligned_byte_offset_for_args) +{ + device_context->lpVtbl->DispatchIndirect(device_context, buffer_for_args, aligned_byte_offset_for_args); +} +static inline void D3D11SetState(D3D11DeviceContext device_context, D3D11RasterizerState rasterizer_state) +{ + device_context->lpVtbl->RSSetState(device_context, rasterizer_state); +} +static inline void D3D11SetViewports(D3D11DeviceContext device_context, UINT num_viewports, D3D11_VIEWPORT* viewports) +{ + device_context->lpVtbl->RSSetViewports(device_context, num_viewports, viewports); +} +static inline void D3D11SetScissorRects(D3D11DeviceContext device_context, UINT num_rects, D3D11_RECT* rects) +{ + device_context->lpVtbl->RSSetScissorRects(device_context, num_rects, rects); +} +static inline void D3D11CopySubresourceRegion(D3D11DeviceContext device_context, D3D11Resource dst_resource, UINT dst_subresource, UINT dst_x, UINT dst_y, UINT dst_z, D3D11Resource src_resource, UINT src_subresource, D3D11_BOX* src_box) +{ + device_context->lpVtbl->CopySubresourceRegion(device_context, dst_resource, dst_subresource, dst_x, dst_y, dst_z, src_resource, src_subresource, src_box); +} +static inline void D3D11CopyResource(D3D11DeviceContext device_context, D3D11Resource dst_resource, D3D11Resource src_resource) +{ + device_context->lpVtbl->CopyResource(device_context, dst_resource, src_resource); +} +static inline void D3D11UpdateSubresource(D3D11DeviceContext device_context, D3D11Resource dst_resource, UINT dst_subresource, D3D11_BOX* dst_box, void* src_data, UINT src_row_pitch, UINT src_depth_pitch) +{ + device_context->lpVtbl->UpdateSubresource(device_context, dst_resource, dst_subresource, dst_box, src_data, src_row_pitch, src_depth_pitch); +} +static inline void D3D11CopyStructureCount(D3D11DeviceContext device_context, D3D11Buffer dst_buffer, UINT dst_aligned_byte_offset, D3D11UnorderedAccessView src_view) +{ + device_context->lpVtbl->CopyStructureCount(device_context, dst_buffer, dst_aligned_byte_offset, src_view); +} +static inline void D3D11ClearRenderTargetView(D3D11DeviceContext device_context, D3D11RenderTargetView render_target_view, FLOAT color_rgba[4]) +{ + device_context->lpVtbl->ClearRenderTargetView(device_context, render_target_view, color_rgba); +} +static inline void D3D11ClearUnorderedAccessViewUint(D3D11DeviceContext device_context, D3D11UnorderedAccessView unordered_access_view, UINT values[4]) +{ + device_context->lpVtbl->ClearUnorderedAccessViewUint(device_context, unordered_access_view, values); +} +static inline void D3D11ClearUnorderedAccessViewFloat(D3D11DeviceContext device_context, D3D11UnorderedAccessView unordered_access_view, FLOAT values[4]) +{ + device_context->lpVtbl->ClearUnorderedAccessViewFloat(device_context, unordered_access_view, values); +} +static inline void D3D11ClearDepthStencilView(D3D11DeviceContext device_context, D3D11DepthStencilView depth_stencil_view, UINT clear_flags, FLOAT depth, UINT8 stencil) +{ + device_context->lpVtbl->ClearDepthStencilView(device_context, depth_stencil_view, clear_flags, depth, stencil); +} +static inline void D3D11GenerateMips(D3D11DeviceContext device_context, D3D11ShaderResourceView shader_resource_view) +{ + device_context->lpVtbl->GenerateMips(device_context, shader_resource_view); +} +static inline void D3D11SetResourceMinLOD(D3D11DeviceContext device_context, D3D11Resource resource, FLOAT min_lod) +{ + device_context->lpVtbl->SetResourceMinLOD(device_context, resource, min_lod); +} +static inline FLOAT D3D11GetResourceMinLOD(D3D11DeviceContext device_context, D3D11Resource resource) +{ + return device_context->lpVtbl->GetResourceMinLOD(device_context, resource); +} +static inline void D3D11ResolveSubresource(D3D11DeviceContext device_context, D3D11Resource dst_resource, UINT dst_subresource, D3D11Resource src_resource, UINT src_subresource, DXGI_FORMAT format) +{ + device_context->lpVtbl->ResolveSubresource(device_context, dst_resource, dst_subresource, src_resource, src_subresource, format); +} +static inline void D3D11ExecuteCommandList(D3D11DeviceContext device_context, D3D11CommandList command_list, BOOL restore_context_state) +{ + device_context->lpVtbl->ExecuteCommandList(device_context, command_list, restore_context_state); +} +static inline void D3D11HSSetShaderResources(D3D11DeviceContext device_context, UINT start_slot, UINT num_views, D3D11ShaderResourceView*const shader_resource_views) +{ + device_context->lpVtbl->HSSetShaderResources(device_context, start_slot, num_views, shader_resource_views); +} +static inline void D3D11HSSetShader(D3D11DeviceContext device_context, D3D11HullShader hull_shader, D3D11ClassInstance*const class_instances, UINT num_class_instances) +{ + device_context->lpVtbl->HSSetShader(device_context, hull_shader, class_instances, num_class_instances); +} +static inline void D3D11HSSetSamplers(D3D11DeviceContext device_context, UINT start_slot, UINT num_samplers, D3D11SamplerState*const samplers) +{ + device_context->lpVtbl->HSSetSamplers(device_context, start_slot, num_samplers, samplers); +} +static inline void D3D11HSSetConstantBuffers(D3D11DeviceContext device_context, UINT start_slot, UINT num_buffers, D3D11Buffer*const constant_buffers) +{ + device_context->lpVtbl->HSSetConstantBuffers(device_context, start_slot, num_buffers, constant_buffers); +} +static inline void D3D11SetDShaderResources(D3D11DeviceContext device_context, UINT start_slot, UINT num_views, D3D11ShaderResourceView*const shader_resource_views) +{ + device_context->lpVtbl->DSSetShaderResources(device_context, start_slot, num_views, shader_resource_views); +} +static inline void D3D11SetDShader(D3D11DeviceContext device_context, D3D11DomainShader domain_shader, D3D11ClassInstance*const class_instances, UINT num_class_instances) +{ + device_context->lpVtbl->DSSetShader(device_context, domain_shader, class_instances, num_class_instances); +} +static inline void D3D11SetDShaderSamplers(D3D11DeviceContext device_context, UINT start_slot, UINT num_samplers, D3D11SamplerState*const samplers) +{ + device_context->lpVtbl->DSSetSamplers(device_context, start_slot, num_samplers, samplers); +} +static inline void D3D11SetDShaderConstantBuffers(D3D11DeviceContext device_context, UINT start_slot, UINT num_buffers, D3D11Buffer*const constant_buffers) +{ + device_context->lpVtbl->DSSetConstantBuffers(device_context, start_slot, num_buffers, constant_buffers); +} +static inline void D3D11SetCShaderResources(D3D11DeviceContext device_context, UINT start_slot, UINT num_views, D3D11ShaderResourceView*const shader_resource_views) +{ + device_context->lpVtbl->CSSetShaderResources(device_context, start_slot, num_views, shader_resource_views); +} +static inline void D3D11SetCShaderUnorderedAccessViews(D3D11DeviceContext device_context, UINT start_slot, UINT num_uavs, D3D11UnorderedAccessView*const unordered_access_views, UINT* uavinitial_counts) +{ + device_context->lpVtbl->CSSetUnorderedAccessViews(device_context, start_slot, num_uavs, unordered_access_views, uavinitial_counts); +} +static inline void D3D11SetCShader(D3D11DeviceContext device_context, D3D11ComputeShader compute_shader, D3D11ClassInstance*const class_instances, UINT num_class_instances) +{ + device_context->lpVtbl->CSSetShader(device_context, compute_shader, class_instances, num_class_instances); +} +static inline void D3D11SetCShaderSamplers(D3D11DeviceContext device_context, UINT start_slot, UINT num_samplers, D3D11SamplerState*const samplers) +{ + device_context->lpVtbl->CSSetSamplers(device_context, start_slot, num_samplers, samplers); +} +static inline void D3D11SetCShaderConstantBuffers(D3D11DeviceContext device_context, UINT start_slot, UINT num_buffers, D3D11Buffer*const constant_buffers) +{ + device_context->lpVtbl->CSSetConstantBuffers(device_context, start_slot, num_buffers, constant_buffers); +} +static inline void D3D11GetVShaderConstantBuffers(D3D11DeviceContext device_context, UINT start_slot, UINT num_buffers, D3D11Buffer* constant_buffers) +{ + device_context->lpVtbl->VSGetConstantBuffers(device_context, start_slot, num_buffers, constant_buffers); +} +static inline void D3D11GetPShaderResources(D3D11DeviceContext device_context, UINT start_slot, UINT num_views, D3D11ShaderResourceView* shader_resource_views) +{ + device_context->lpVtbl->PSGetShaderResources(device_context, start_slot, num_views, shader_resource_views); +} +static inline void D3D11GetPShader(D3D11DeviceContext device_context, D3D11PixelShader* pixel_shader, D3D11ClassInstance* class_instances, UINT* num_class_instances) +{ + device_context->lpVtbl->PSGetShader(device_context, pixel_shader, class_instances, num_class_instances); +} +static inline void D3D11GetPShaderSamplers(D3D11DeviceContext device_context, UINT start_slot, UINT num_samplers, D3D11SamplerState* samplers) +{ + device_context->lpVtbl->PSGetSamplers(device_context, start_slot, num_samplers, samplers); +} +static inline void D3D11GetVShader(D3D11DeviceContext device_context, D3D11VertexShader* vertex_shader, D3D11ClassInstance* class_instances, UINT* num_class_instances) +{ + device_context->lpVtbl->VSGetShader(device_context, vertex_shader, class_instances, num_class_instances); +} +static inline void D3D11GetPShaderConstantBuffers(D3D11DeviceContext device_context, UINT start_slot, UINT num_buffers, D3D11Buffer* constant_buffers) +{ + device_context->lpVtbl->PSGetConstantBuffers(device_context, start_slot, num_buffers, constant_buffers); +} +static inline void D3D11GetInputLayout(D3D11DeviceContext device_context, D3D11InputLayout* input_layout) +{ + device_context->lpVtbl->IAGetInputLayout(device_context, input_layout); +} +static inline void D3D11GetVertexBuffers(D3D11DeviceContext device_context, UINT start_slot, UINT num_buffers, D3D11Buffer* vertex_buffers, UINT* strides, UINT* offsets) +{ + device_context->lpVtbl->IAGetVertexBuffers(device_context, start_slot, num_buffers, vertex_buffers, strides, offsets); +} +static inline void D3D11GetIndexBuffer(D3D11DeviceContext device_context, D3D11Buffer* index_buffer, DXGI_FORMAT* format, UINT* offset) +{ + device_context->lpVtbl->IAGetIndexBuffer(device_context, index_buffer, format, offset); +} +static inline void D3D11GetGShaderConstantBuffers(D3D11DeviceContext device_context, UINT start_slot, UINT num_buffers, D3D11Buffer* constant_buffers) +{ + device_context->lpVtbl->GSGetConstantBuffers(device_context, start_slot, num_buffers, constant_buffers); +} +static inline void D3D11GetGShader(D3D11DeviceContext device_context, D3D11GeometryShader* geometry_shader, D3D11ClassInstance* class_instances, UINT* num_class_instances) +{ + device_context->lpVtbl->GSGetShader(device_context, geometry_shader, class_instances, num_class_instances); +} +static inline void D3D11GetPrimitiveTopology(D3D11DeviceContext device_context, D3D11_PRIMITIVE_TOPOLOGY* topology) +{ + device_context->lpVtbl->IAGetPrimitiveTopology(device_context, topology); +} +static inline void D3D11GetVShaderResources(D3D11DeviceContext device_context, UINT start_slot, UINT num_views, D3D11ShaderResourceView* shader_resource_views) +{ + device_context->lpVtbl->VSGetShaderResources(device_context, start_slot, num_views, shader_resource_views); +} +static inline void D3D11GetVShaderSamplers(D3D11DeviceContext device_context, UINT start_slot, UINT num_samplers, D3D11SamplerState* samplers) +{ + device_context->lpVtbl->VSGetSamplers(device_context, start_slot, num_samplers, samplers); +} +static inline void D3D11GetPredication(D3D11DeviceContext device_context, D3D11Predicate* predicate, BOOL* predicate_value) +{ + device_context->lpVtbl->GetPredication(device_context, predicate, predicate_value); +} +static inline void D3D11GetGShaderResources(D3D11DeviceContext device_context, UINT start_slot, UINT num_views, D3D11ShaderResourceView* shader_resource_views) +{ + device_context->lpVtbl->GSGetShaderResources(device_context, start_slot, num_views, shader_resource_views); +} +static inline void D3D11GetGShaderSamplers(D3D11DeviceContext device_context, UINT start_slot, UINT num_samplers, D3D11SamplerState* samplers) +{ + device_context->lpVtbl->GSGetSamplers(device_context, start_slot, num_samplers, samplers); +} +static inline void D3D11GetRenderTargets(D3D11DeviceContext device_context, UINT num_views, D3D11RenderTargetView* render_target_views, D3D11DepthStencilView* depth_stencil_view) +{ + device_context->lpVtbl->OMGetRenderTargets(device_context, num_views, render_target_views, depth_stencil_view); +} +static inline void D3D11GetRenderTargetsAndUnorderedAccessViews(D3D11DeviceContext device_context, UINT num_rtvs, D3D11RenderTargetView* render_target_views, D3D11DepthStencilView* depth_stencil_view, UINT uavstart_slot, UINT num_uavs, D3D11UnorderedAccessView* unordered_access_views) +{ + device_context->lpVtbl->OMGetRenderTargetsAndUnorderedAccessViews(device_context, num_rtvs, render_target_views, depth_stencil_view, uavstart_slot, num_uavs, unordered_access_views); +} +static inline void D3D11GetBlendState(D3D11DeviceContext device_context, D3D11BlendState* blend_state, FLOAT blend_factor[4], UINT* sample_mask) +{ + device_context->lpVtbl->OMGetBlendState(device_context, blend_state, blend_factor, sample_mask); +} +static inline void D3D11GetDepthStencilState(D3D11DeviceContext device_context, D3D11DepthStencilState* depth_stencil_state, UINT* stencil_ref) +{ + device_context->lpVtbl->OMGetDepthStencilState(device_context, depth_stencil_state, stencil_ref); +} +static inline void D3D11SOGetTargets(D3D11DeviceContext device_context, UINT num_buffers, D3D11Buffer* sotargets) +{ + device_context->lpVtbl->SOGetTargets(device_context, num_buffers, sotargets); +} +static inline void D3D11GetState(D3D11DeviceContext device_context, D3D11RasterizerState* rasterizer_state) +{ + device_context->lpVtbl->RSGetState(device_context, rasterizer_state); +} +static inline void D3D11GetViewports(D3D11DeviceContext device_context, UINT* num_viewports, D3D11_VIEWPORT* viewports) +{ + device_context->lpVtbl->RSGetViewports(device_context, num_viewports, viewports); +} +static inline void D3D11GetScissorRects(D3D11DeviceContext device_context, UINT* num_rects, D3D11_RECT* rects) +{ + device_context->lpVtbl->RSGetScissorRects(device_context, num_rects, rects); +} +static inline void D3D11HSGetShaderResources(D3D11DeviceContext device_context, UINT start_slot, UINT num_views, D3D11ShaderResourceView* shader_resource_views) +{ + device_context->lpVtbl->HSGetShaderResources(device_context, start_slot, num_views, shader_resource_views); +} +static inline void D3D11HSGetShader(D3D11DeviceContext device_context, D3D11HullShader* hull_shader, D3D11ClassInstance* class_instances, UINT* num_class_instances) +{ + device_context->lpVtbl->HSGetShader(device_context, hull_shader, class_instances, num_class_instances); +} +static inline void D3D11HSGetSamplers(D3D11DeviceContext device_context, UINT start_slot, UINT num_samplers, D3D11SamplerState* samplers) +{ + device_context->lpVtbl->HSGetSamplers(device_context, start_slot, num_samplers, samplers); +} +static inline void D3D11HSGetConstantBuffers(D3D11DeviceContext device_context, UINT start_slot, UINT num_buffers, D3D11Buffer* constant_buffers) +{ + device_context->lpVtbl->HSGetConstantBuffers(device_context, start_slot, num_buffers, constant_buffers); +} +static inline void D3D11GetDShaderResources(D3D11DeviceContext device_context, UINT start_slot, UINT num_views, D3D11ShaderResourceView* shader_resource_views) +{ + device_context->lpVtbl->DSGetShaderResources(device_context, start_slot, num_views, shader_resource_views); +} +static inline void D3D11GetDShader(D3D11DeviceContext device_context, D3D11DomainShader* domain_shader, D3D11ClassInstance* class_instances, UINT* num_class_instances) +{ + device_context->lpVtbl->DSGetShader(device_context, domain_shader, class_instances, num_class_instances); +} +static inline void D3D11GetDShaderSamplers(D3D11DeviceContext device_context, UINT start_slot, UINT num_samplers, D3D11SamplerState* samplers) +{ + device_context->lpVtbl->DSGetSamplers(device_context, start_slot, num_samplers, samplers); +} +static inline void D3D11GetDShaderConstantBuffers(D3D11DeviceContext device_context, UINT start_slot, UINT num_buffers, D3D11Buffer* constant_buffers) +{ + device_context->lpVtbl->DSGetConstantBuffers(device_context, start_slot, num_buffers, constant_buffers); +} +static inline void D3D11GetCShaderResources(D3D11DeviceContext device_context, UINT start_slot, UINT num_views, D3D11ShaderResourceView* shader_resource_views) +{ + device_context->lpVtbl->CSGetShaderResources(device_context, start_slot, num_views, shader_resource_views); +} +static inline void D3D11GetCShaderUnorderedAccessViews(D3D11DeviceContext device_context, UINT start_slot, UINT num_uavs, D3D11UnorderedAccessView* unordered_access_views) +{ + device_context->lpVtbl->CSGetUnorderedAccessViews(device_context, start_slot, num_uavs, unordered_access_views); +} +static inline void D3D11GetCShader(D3D11DeviceContext device_context, D3D11ComputeShader* compute_shader, D3D11ClassInstance* class_instances, UINT* num_class_instances) +{ + device_context->lpVtbl->CSGetShader(device_context, compute_shader, class_instances, num_class_instances); +} +static inline void D3D11GetCShaderSamplers(D3D11DeviceContext device_context, UINT start_slot, UINT num_samplers, D3D11SamplerState* samplers) +{ + device_context->lpVtbl->CSGetSamplers(device_context, start_slot, num_samplers, samplers); +} +static inline void D3D11GetCShaderConstantBuffers(D3D11DeviceContext device_context, UINT start_slot, UINT num_buffers, D3D11Buffer* constant_buffers) +{ + device_context->lpVtbl->CSGetConstantBuffers(device_context, start_slot, num_buffers, constant_buffers); +} +static inline void D3D11ClearState(D3D11DeviceContext device_context) +{ + device_context->lpVtbl->ClearState(device_context); +} +static inline void D3D11Flush(D3D11DeviceContext device_context) +{ + device_context->lpVtbl->Flush(device_context); +} +static inline UINT D3D11GetDeviceContextContextFlags(D3D11DeviceContext device_context) +{ + return device_context->lpVtbl->GetContextFlags(device_context); +} +static inline HRESULT D3D11FinishCommandList(D3D11DeviceContext device_context, BOOL restore_deferred_context_state, D3D11CommandList* command_list) +{ + return device_context->lpVtbl->FinishCommandList(device_context, restore_deferred_context_state, command_list); +} +static inline HRESULT D3D11GetCreationParameters(D3D11VideoDecoder video_decoder, D3D11_VIDEO_DECODER_DESC* video_desc, D3D11_VIDEO_DECODER_CONFIG* config) +{ + return video_decoder->lpVtbl->GetCreationParameters(video_decoder, video_desc, config); +} +static inline HRESULT D3D11GetDriverHandle(D3D11VideoDecoder video_decoder, HANDLE* driver_handle) +{ + return video_decoder->lpVtbl->GetDriverHandle(video_decoder, driver_handle); +} +static inline HRESULT D3D11GetVideoProcessorContentDesc(D3D11VideoProcessorEnumerator video_processor_enumerator, D3D11_VIDEO_PROCESSOR_CONTENT_DESC* content_desc) +{ + return video_processor_enumerator->lpVtbl->GetVideoProcessorContentDesc(video_processor_enumerator, content_desc); +} +static inline HRESULT D3D11CheckVideoProcessorFormat(D3D11VideoProcessorEnumerator video_processor_enumerator, DXGI_FORMAT format, UINT* flags) +{ + return video_processor_enumerator->lpVtbl->CheckVideoProcessorFormat(video_processor_enumerator, format, flags); +} +static inline HRESULT D3D11GetVideoProcessorCaps(D3D11VideoProcessorEnumerator video_processor_enumerator, D3D11_VIDEO_PROCESSOR_CAPS* caps) +{ + return video_processor_enumerator->lpVtbl->GetVideoProcessorCaps(video_processor_enumerator, caps); +} +static inline HRESULT D3D11GetVideoProcessorRateConversionCaps(D3D11VideoProcessorEnumerator video_processor_enumerator, UINT type_index, D3D11_VIDEO_PROCESSOR_RATE_CONVERSION_CAPS* caps) +{ + return video_processor_enumerator->lpVtbl->GetVideoProcessorRateConversionCaps(video_processor_enumerator, type_index, caps); +} +static inline HRESULT D3D11GetVideoProcessorCustomRate(D3D11VideoProcessorEnumerator video_processor_enumerator, UINT type_index, UINT custom_rate_index, D3D11_VIDEO_PROCESSOR_CUSTOM_RATE* rate) +{ + return video_processor_enumerator->lpVtbl->GetVideoProcessorCustomRate(video_processor_enumerator, type_index, custom_rate_index, rate); +} +static inline HRESULT D3D11GetVideoProcessorFilterRange(D3D11VideoProcessorEnumerator video_processor_enumerator, D3D11_VIDEO_PROCESSOR_FILTER filter, D3D11_VIDEO_PROCESSOR_FILTER_RANGE* range) +{ + return video_processor_enumerator->lpVtbl->GetVideoProcessorFilterRange(video_processor_enumerator, filter, range); +} +static inline void D3D11GetContentDesc(D3D11VideoProcessor video_processor, D3D11_VIDEO_PROCESSOR_CONTENT_DESC* desc) +{ + video_processor->lpVtbl->GetContentDesc(video_processor, desc); +} +static inline void D3D11GetRateConversionCaps(D3D11VideoProcessor video_processor, D3D11_VIDEO_PROCESSOR_RATE_CONVERSION_CAPS* caps) +{ + video_processor->lpVtbl->GetRateConversionCaps(video_processor, caps); +} +static inline HRESULT D3D11GetAuthenticatedChannelCertificateSize(D3D11AuthenticatedChannel authenticated_channel, UINT* certificate_size) +{ + return authenticated_channel->lpVtbl->GetCertificateSize(authenticated_channel, certificate_size); +} +static inline HRESULT D3D11GetAuthenticatedChannelCertificate(D3D11AuthenticatedChannel authenticated_channel, UINT certificate_size, BYTE* certificate) +{ + return authenticated_channel->lpVtbl->GetCertificate(authenticated_channel, certificate_size, certificate); +} +static inline void D3D11GetChannelHandle(D3D11AuthenticatedChannel authenticated_channel, HANDLE* channel_handle) +{ + authenticated_channel->lpVtbl->GetChannelHandle(authenticated_channel, channel_handle); +} +static inline void D3D11GetCryptoType(D3D11CryptoSession crypto_session, GUID* crypto_type) +{ + crypto_session->lpVtbl->GetCryptoType(crypto_session, crypto_type); +} +static inline void D3D11GetDecoderProfile(D3D11CryptoSession crypto_session, GUID* decoder_profile) +{ + crypto_session->lpVtbl->GetDecoderProfile(crypto_session, decoder_profile); +} +static inline HRESULT D3D11GetCryptoSessionCertificateSize(D3D11CryptoSession crypto_session, UINT* certificate_size) +{ + return crypto_session->lpVtbl->GetCertificateSize(crypto_session, certificate_size); +} +static inline HRESULT D3D11GetCryptoSessionCertificate(D3D11CryptoSession crypto_session, UINT certificate_size, BYTE* certificate) +{ + return crypto_session->lpVtbl->GetCertificate(crypto_session, certificate_size, certificate); +} +static inline void D3D11GetCryptoSessionHandle(D3D11CryptoSession crypto_session, HANDLE* crypto_session_handle) +{ + crypto_session->lpVtbl->GetCryptoSessionHandle(crypto_session, crypto_session_handle); +} +static inline void D3D11GetVideoDecoderOutputViewResource(D3D11VideoDecoderOutputView video_decoder_output_view, D3D11Resource* resource) +{ + video_decoder_output_view->lpVtbl->GetResource(video_decoder_output_view, resource); +} +static inline void D3D11GetVideoProcessorInputViewResource(D3D11VideoProcessorInputView video_processor_input_view, D3D11Resource* resource) +{ + video_processor_input_view->lpVtbl->GetResource(video_processor_input_view, resource); +} +static inline void D3D11GetVideoProcessorOutputViewResource(D3D11VideoProcessorOutputView video_processor_output_view, D3D11Resource* resource) +{ + video_processor_output_view->lpVtbl->GetResource(video_processor_output_view, resource); +} +static inline HRESULT D3D11GetDecoderBuffer(D3D11VideoContext video_context, D3D11VideoDecoder decoder, D3D11_VIDEO_DECODER_BUFFER_TYPE type, UINT* buffer_size, void** buffer) +{ + return video_context->lpVtbl->GetDecoderBuffer(video_context, decoder, type, buffer_size, buffer); +} +static inline HRESULT D3D11ReleaseDecoderBuffer(D3D11VideoContext video_context, D3D11VideoDecoder decoder, D3D11_VIDEO_DECODER_BUFFER_TYPE type) +{ + return video_context->lpVtbl->ReleaseDecoderBuffer(video_context, decoder, type); +} +static inline HRESULT D3D11DecoderBeginFrame(D3D11VideoContext video_context, D3D11VideoDecoder decoder, D3D11VideoDecoderOutputView view, UINT content_key_size, void* content_key) +{ + return video_context->lpVtbl->DecoderBeginFrame(video_context, decoder, view, content_key_size, content_key); +} +static inline HRESULT D3D11DecoderEndFrame(D3D11VideoContext video_context, D3D11VideoDecoder decoder) +{ + return video_context->lpVtbl->DecoderEndFrame(video_context, decoder); +} +static inline HRESULT D3D11SubmitDecoderBuffers(D3D11VideoContext video_context, D3D11VideoDecoder decoder, UINT num_buffers, D3D11_VIDEO_DECODER_BUFFER_DESC* buffer_desc) +{ + return video_context->lpVtbl->SubmitDecoderBuffers(video_context, decoder, num_buffers, buffer_desc); +} +static inline APP_DEPRECATED_HRESULT D3D11DecoderExtension(D3D11VideoContext video_context, D3D11VideoDecoder decoder, D3D11_VIDEO_DECODER_EXTENSION* extension_data) +{ + return video_context->lpVtbl->DecoderExtension(video_context, decoder, extension_data); +} +static inline void D3D11VideoProcessorSetOutputTargetRect(D3D11VideoContext video_context, D3D11VideoProcessor video_processor, BOOL enable, RECT* rect) +{ + video_context->lpVtbl->VideoProcessorSetOutputTargetRect(video_context, video_processor, enable, rect); +} +static inline void D3D11VideoProcessorSetOutputBackgroundColor(D3D11VideoContext video_context, D3D11VideoProcessor video_processor, BOOL ycb_cr, D3D11_VIDEO_COLOR* color) +{ + video_context->lpVtbl->VideoProcessorSetOutputBackgroundColor(video_context, video_processor, ycb_cr, color); +} +static inline void D3D11VideoProcessorSetOutputColorSpace(D3D11VideoContext video_context, D3D11VideoProcessor video_processor, D3D11_VIDEO_PROCESSOR_COLOR_SPACE* color_space) +{ + video_context->lpVtbl->VideoProcessorSetOutputColorSpace(video_context, video_processor, color_space); +} +static inline void D3D11VideoProcessorSetOutputAlphaFillMode(D3D11VideoContext video_context, D3D11VideoProcessor video_processor, D3D11_VIDEO_PROCESSOR_ALPHA_FILL_MODE alpha_fill_mode, UINT stream_index) +{ + video_context->lpVtbl->VideoProcessorSetOutputAlphaFillMode(video_context, video_processor, alpha_fill_mode, stream_index); +} +static inline void D3D11VideoProcessorSetOutputConstriction(D3D11VideoContext video_context, D3D11VideoProcessor video_processor, BOOL enable, SIZE size) +{ + video_context->lpVtbl->VideoProcessorSetOutputConstriction(video_context, video_processor, enable, size); +} +static inline void D3D11VideoProcessorSetOutputStereoMode(D3D11VideoContext video_context, D3D11VideoProcessor video_processor, BOOL enable) +{ + video_context->lpVtbl->VideoProcessorSetOutputStereoMode(video_context, video_processor, enable); +} +static inline APP_DEPRECATED_HRESULT D3D11VideoProcessorSetOutputExtension(D3D11VideoContext video_context, D3D11VideoProcessor video_processor, GUID* extension_guid, UINT data_size, void* data) +{ + return video_context->lpVtbl->VideoProcessorSetOutputExtension(video_context, video_processor, extension_guid, data_size, data); +} +static inline void D3D11VideoProcessorGetOutputTargetRect(D3D11VideoContext video_context, D3D11VideoProcessor video_processor, BOOL* enabled, RECT* rect) +{ + video_context->lpVtbl->VideoProcessorGetOutputTargetRect(video_context, video_processor, enabled, rect); +} +static inline void D3D11VideoProcessorGetOutputBackgroundColor(D3D11VideoContext video_context, D3D11VideoProcessor video_processor, BOOL* ycb_cr, D3D11_VIDEO_COLOR* color) +{ + video_context->lpVtbl->VideoProcessorGetOutputBackgroundColor(video_context, video_processor, ycb_cr, color); +} +static inline void D3D11VideoProcessorGetOutputColorSpace(D3D11VideoContext video_context, D3D11VideoProcessor video_processor, D3D11_VIDEO_PROCESSOR_COLOR_SPACE* color_space) +{ + video_context->lpVtbl->VideoProcessorGetOutputColorSpace(video_context, video_processor, color_space); +} +static inline void D3D11VideoProcessorGetOutputAlphaFillMode(D3D11VideoContext video_context, D3D11VideoProcessor video_processor, D3D11_VIDEO_PROCESSOR_ALPHA_FILL_MODE* alpha_fill_mode, UINT* stream_index) +{ + video_context->lpVtbl->VideoProcessorGetOutputAlphaFillMode(video_context, video_processor, alpha_fill_mode, stream_index); +} +static inline void D3D11VideoProcessorGetOutputConstriction(D3D11VideoContext video_context, D3D11VideoProcessor video_processor, BOOL* enabled, SIZE* size) +{ + video_context->lpVtbl->VideoProcessorGetOutputConstriction(video_context, video_processor, enabled, size); +} +static inline void D3D11VideoProcessorGetOutputStereoMode(D3D11VideoContext video_context, D3D11VideoProcessor video_processor, BOOL* enabled) +{ + video_context->lpVtbl->VideoProcessorGetOutputStereoMode(video_context, video_processor, enabled); +} +static inline APP_DEPRECATED_HRESULT D3D11VideoProcessorGetOutputExtension(D3D11VideoContext video_context, D3D11VideoProcessor video_processor, GUID* extension_guid, UINT data_size, void* data) +{ + return video_context->lpVtbl->VideoProcessorGetOutputExtension(video_context, video_processor, extension_guid, data_size, data); +} +static inline void D3D11VideoProcessorSetStreamFrameFormat(D3D11VideoContext video_context, D3D11VideoProcessor video_processor, UINT stream_index, D3D11_VIDEO_FRAME_FORMAT frame_format) +{ + video_context->lpVtbl->VideoProcessorSetStreamFrameFormat(video_context, video_processor, stream_index, frame_format); +} +static inline void D3D11VideoProcessorSetStreamColorSpace(D3D11VideoContext video_context, D3D11VideoProcessor video_processor, UINT stream_index, D3D11_VIDEO_PROCESSOR_COLOR_SPACE* color_space) +{ + video_context->lpVtbl->VideoProcessorSetStreamColorSpace(video_context, video_processor, stream_index, color_space); +} +static inline void D3D11VideoProcessorSetStreamOutputRate(D3D11VideoContext video_context, D3D11VideoProcessor video_processor, UINT stream_index, D3D11_VIDEO_PROCESSOR_OUTPUT_RATE output_rate, BOOL repeat_frame, DXGI_RATIONAL* custom_rate) +{ + video_context->lpVtbl->VideoProcessorSetStreamOutputRate(video_context, video_processor, stream_index, output_rate, repeat_frame, custom_rate); +} +static inline void D3D11VideoProcessorSetStreamSourceRect(D3D11VideoContext video_context, D3D11VideoProcessor video_processor, UINT stream_index, BOOL enable, RECT* rect) +{ + video_context->lpVtbl->VideoProcessorSetStreamSourceRect(video_context, video_processor, stream_index, enable, rect); +} +static inline void D3D11VideoProcessorSetStreamDestRect(D3D11VideoContext video_context, D3D11VideoProcessor video_processor, UINT stream_index, BOOL enable, RECT* rect) +{ + video_context->lpVtbl->VideoProcessorSetStreamDestRect(video_context, video_processor, stream_index, enable, rect); +} +static inline void D3D11VideoProcessorSetStreamAlpha(D3D11VideoContext video_context, D3D11VideoProcessor video_processor, UINT stream_index, BOOL enable, FLOAT alpha) +{ + video_context->lpVtbl->VideoProcessorSetStreamAlpha(video_context, video_processor, stream_index, enable, alpha); +} +static inline void D3D11VideoProcessorSetStreamPalette(D3D11VideoContext video_context, D3D11VideoProcessor video_processor, UINT stream_index, UINT count, UINT* entries) +{ + video_context->lpVtbl->VideoProcessorSetStreamPalette(video_context, video_processor, stream_index, count, entries); +} +static inline void D3D11VideoProcessorSetStreamPixelAspectRatio(D3D11VideoContext video_context, D3D11VideoProcessor video_processor, UINT stream_index, BOOL enable, DXGI_RATIONAL* source_aspect_ratio, DXGI_RATIONAL* destination_aspect_ratio) +{ + video_context->lpVtbl->VideoProcessorSetStreamPixelAspectRatio(video_context, video_processor, stream_index, enable, source_aspect_ratio, destination_aspect_ratio); +} +static inline void D3D11VideoProcessorSetStreamLumaKey(D3D11VideoContext video_context, D3D11VideoProcessor video_processor, UINT stream_index, BOOL enable, FLOAT lower, FLOAT upper) +{ + video_context->lpVtbl->VideoProcessorSetStreamLumaKey(video_context, video_processor, stream_index, enable, lower, upper); +} +static inline void D3D11VideoProcessorSetStreamStereoFormat(D3D11VideoContext video_context, D3D11VideoProcessor video_processor, UINT stream_index, BOOL enable, D3D11_VIDEO_PROCESSOR_STEREO_FORMAT format, BOOL left_view_frame0, BOOL base_view_frame0, D3D11_VIDEO_PROCESSOR_STEREO_FLIP_MODE flip_mode, int mono_offset) +{ + video_context->lpVtbl->VideoProcessorSetStreamStereoFormat(video_context, video_processor, stream_index, enable, format, left_view_frame0, base_view_frame0, flip_mode, mono_offset); +} +static inline void D3D11VideoProcessorSetStreamAutoProcessingMode(D3D11VideoContext video_context, D3D11VideoProcessor video_processor, UINT stream_index, BOOL enable) +{ + video_context->lpVtbl->VideoProcessorSetStreamAutoProcessingMode(video_context, video_processor, stream_index, enable); +} +static inline void D3D11VideoProcessorSetStreamFilter(D3D11VideoContext video_context, D3D11VideoProcessor video_processor, UINT stream_index, D3D11_VIDEO_PROCESSOR_FILTER filter, BOOL enable, int level) +{ + video_context->lpVtbl->VideoProcessorSetStreamFilter(video_context, video_processor, stream_index, filter, enable, level); +} +static inline APP_DEPRECATED_HRESULT D3D11VideoProcessorSetStreamExtension(D3D11VideoContext video_context, D3D11VideoProcessor video_processor, UINT stream_index, GUID* extension_guid, UINT data_size, void* data) +{ + return video_context->lpVtbl->VideoProcessorSetStreamExtension(video_context, video_processor, stream_index, extension_guid, data_size, data); +} +static inline void D3D11VideoProcessorGetStreamFrameFormat(D3D11VideoContext video_context, D3D11VideoProcessor video_processor, UINT stream_index, D3D11_VIDEO_FRAME_FORMAT* frame_format) +{ + video_context->lpVtbl->VideoProcessorGetStreamFrameFormat(video_context, video_processor, stream_index, frame_format); +} +static inline void D3D11VideoProcessorGetStreamColorSpace(D3D11VideoContext video_context, D3D11VideoProcessor video_processor, UINT stream_index, D3D11_VIDEO_PROCESSOR_COLOR_SPACE* color_space) +{ + video_context->lpVtbl->VideoProcessorGetStreamColorSpace(video_context, video_processor, stream_index, color_space); +} +static inline void D3D11VideoProcessorGetStreamOutputRate(D3D11VideoContext video_context, D3D11VideoProcessor video_processor, UINT stream_index, D3D11_VIDEO_PROCESSOR_OUTPUT_RATE* output_rate, BOOL* repeat_frame, DXGI_RATIONAL* custom_rate) +{ + video_context->lpVtbl->VideoProcessorGetStreamOutputRate(video_context, video_processor, stream_index, output_rate, repeat_frame, custom_rate); +} +static inline void D3D11VideoProcessorGetStreamSourceRect(D3D11VideoContext video_context, D3D11VideoProcessor video_processor, UINT stream_index, BOOL* enabled, RECT* rect) +{ + video_context->lpVtbl->VideoProcessorGetStreamSourceRect(video_context, video_processor, stream_index, enabled, rect); +} +static inline void D3D11VideoProcessorGetStreamDestRect(D3D11VideoContext video_context, D3D11VideoProcessor video_processor, UINT stream_index, BOOL* enabled, RECT* rect) +{ + video_context->lpVtbl->VideoProcessorGetStreamDestRect(video_context, video_processor, stream_index, enabled, rect); +} +static inline void D3D11VideoProcessorGetStreamAlpha(D3D11VideoContext video_context, D3D11VideoProcessor video_processor, UINT stream_index, BOOL* enabled, FLOAT* alpha) +{ + video_context->lpVtbl->VideoProcessorGetStreamAlpha(video_context, video_processor, stream_index, enabled, alpha); +} +static inline void D3D11VideoProcessorGetStreamPalette(D3D11VideoContext video_context, D3D11VideoProcessor video_processor, UINT stream_index, UINT count, UINT* entries) +{ + video_context->lpVtbl->VideoProcessorGetStreamPalette(video_context, video_processor, stream_index, count, entries); +} +static inline void D3D11VideoProcessorGetStreamPixelAspectRatio(D3D11VideoContext video_context, D3D11VideoProcessor video_processor, UINT stream_index, BOOL* enabled, DXGI_RATIONAL* source_aspect_ratio, DXGI_RATIONAL* destination_aspect_ratio) +{ + video_context->lpVtbl->VideoProcessorGetStreamPixelAspectRatio(video_context, video_processor, stream_index, enabled, source_aspect_ratio, destination_aspect_ratio); +} +static inline void D3D11VideoProcessorGetStreamLumaKey(D3D11VideoContext video_context, D3D11VideoProcessor video_processor, UINT stream_index, BOOL* enabled, FLOAT* lower, FLOAT* upper) +{ + video_context->lpVtbl->VideoProcessorGetStreamLumaKey(video_context, video_processor, stream_index, enabled, lower, upper); +} +static inline void D3D11VideoProcessorGetStreamStereoFormat(D3D11VideoContext video_context, D3D11VideoProcessor video_processor, UINT stream_index, BOOL* enable, D3D11_VIDEO_PROCESSOR_STEREO_FORMAT* format, BOOL* left_view_frame0, BOOL* base_view_frame0, D3D11_VIDEO_PROCESSOR_STEREO_FLIP_MODE* flip_mode, int* mono_offset) +{ + video_context->lpVtbl->VideoProcessorGetStreamStereoFormat(video_context, video_processor, stream_index, enable, format, left_view_frame0, base_view_frame0, flip_mode, mono_offset); +} +static inline void D3D11VideoProcessorGetStreamAutoProcessingMode(D3D11VideoContext video_context, D3D11VideoProcessor video_processor, UINT stream_index, BOOL* enabled) +{ + video_context->lpVtbl->VideoProcessorGetStreamAutoProcessingMode(video_context, video_processor, stream_index, enabled); +} +static inline void D3D11VideoProcessorGetStreamFilter(D3D11VideoContext video_context, D3D11VideoProcessor video_processor, UINT stream_index, D3D11_VIDEO_PROCESSOR_FILTER filter, BOOL* enabled, int* level) +{ + video_context->lpVtbl->VideoProcessorGetStreamFilter(video_context, video_processor, stream_index, filter, enabled, level); +} +static inline APP_DEPRECATED_HRESULT D3D11VideoProcessorGetStreamExtension(D3D11VideoContext video_context, D3D11VideoProcessor video_processor, UINT stream_index, GUID* extension_guid, UINT data_size, void* data) +{ + return video_context->lpVtbl->VideoProcessorGetStreamExtension(video_context, video_processor, stream_index, extension_guid, data_size, data); +} +static inline HRESULT D3D11VideoProcessorBlt(D3D11VideoContext video_context, D3D11VideoProcessor video_processor, D3D11VideoProcessorOutputView view, UINT output_frame, UINT stream_count, D3D11_VIDEO_PROCESSOR_STREAM* streams) +{ + return video_context->lpVtbl->VideoProcessorBlt(video_context, video_processor, view, output_frame, stream_count, streams); +} +static inline HRESULT D3D11NegotiateCryptoSessionKeyExchange(D3D11VideoContext video_context, D3D11CryptoSession crypto_session, UINT data_size, void* data) +{ + return video_context->lpVtbl->NegotiateCryptoSessionKeyExchange(video_context, crypto_session, data_size, data); +} +static inline void D3D11EncryptionBlt(D3D11VideoContext video_context, D3D11CryptoSession crypto_session, D3D11Texture2D src_surface, D3D11Texture2D dst_surface, UINT ivsize, void* iv) +{ + video_context->lpVtbl->EncryptionBlt(video_context, crypto_session, src_surface, dst_surface, ivsize, iv); +} +static inline void D3D11DecryptionBlt(D3D11VideoContext video_context, D3D11CryptoSession crypto_session, D3D11Texture2D src_surface, D3D11Texture2D dst_surface, D3D11_ENCRYPTED_BLOCK_INFO* encrypted_block_info, UINT content_key_size, void* content_key, UINT ivsize, void* iv) +{ + video_context->lpVtbl->DecryptionBlt(video_context, crypto_session, src_surface, dst_surface, encrypted_block_info, content_key_size, content_key, ivsize, iv); +} +static inline void D3D11StartSessionKeyRefresh(D3D11VideoContext video_context, D3D11CryptoSession crypto_session, UINT random_number_size, void* random_number) +{ + video_context->lpVtbl->StartSessionKeyRefresh(video_context, crypto_session, random_number_size, random_number); +} +static inline void D3D11FinishSessionKeyRefresh(D3D11VideoContext video_context, D3D11CryptoSession crypto_session) +{ + video_context->lpVtbl->FinishSessionKeyRefresh(video_context, crypto_session); +} +static inline HRESULT D3D11GetEncryptionBltKey(D3D11VideoContext video_context, D3D11CryptoSession crypto_session, UINT key_size, void* readback_key) +{ + return video_context->lpVtbl->GetEncryptionBltKey(video_context, crypto_session, key_size, readback_key); +} +static inline HRESULT D3D11NegotiateAuthenticatedChannelKeyExchange(D3D11VideoContext video_context, D3D11AuthenticatedChannel channel, UINT data_size, void* data) +{ + return video_context->lpVtbl->NegotiateAuthenticatedChannelKeyExchange(video_context, channel, data_size, data); +} +static inline HRESULT D3D11QueryAuthenticatedChannel(D3D11VideoContext video_context, D3D11AuthenticatedChannel channel, UINT input_size, void* input, UINT output_size, void* output) +{ + return video_context->lpVtbl->QueryAuthenticatedChannel(video_context, channel, input_size, input, output_size, output); +} +static inline HRESULT D3D11ConfigureAuthenticatedChannel(D3D11VideoContext video_context, D3D11AuthenticatedChannel channel, UINT input_size, void* input, D3D11_AUTHENTICATED_CONFIGURE_OUTPUT* output) +{ + return video_context->lpVtbl->ConfigureAuthenticatedChannel(video_context, channel, input_size, input, output); +} +static inline void D3D11VideoProcessorSetStreamRotation(D3D11VideoContext video_context, D3D11VideoProcessor video_processor, UINT stream_index, BOOL enable, D3D11_VIDEO_PROCESSOR_ROTATION rotation) +{ + video_context->lpVtbl->VideoProcessorSetStreamRotation(video_context, video_processor, stream_index, enable, rotation); +} +static inline void D3D11VideoProcessorGetStreamRotation(D3D11VideoContext video_context, D3D11VideoProcessor video_processor, UINT stream_index, BOOL* enable, D3D11_VIDEO_PROCESSOR_ROTATION* rotation) +{ + video_context->lpVtbl->VideoProcessorGetStreamRotation(video_context, video_processor, stream_index, enable, rotation); +} +static inline HRESULT D3D11CreateVideoDecoder(D3D11VideoDevice video_device, D3D11_VIDEO_DECODER_DESC* video_desc, D3D11_VIDEO_DECODER_CONFIG* config, D3D11VideoDecoder* decoder) +{ + return video_device->lpVtbl->CreateVideoDecoder(video_device, video_desc, config, decoder); +} +static inline HRESULT D3D11CreateVideoProcessor(D3D11VideoDevice video_device, D3D11VideoProcessorEnumerator enumerator, UINT rate_conversion_index, D3D11VideoProcessor* video_processor) +{ + return video_device->lpVtbl->CreateVideoProcessor(video_device, enumerator, rate_conversion_index, video_processor); +} +static inline HRESULT D3D11CreateAuthenticatedChannel(D3D11VideoDevice video_device, D3D11_AUTHENTICATED_CHANNEL_TYPE channel_type, D3D11AuthenticatedChannel* authenticated_channel) +{ + return video_device->lpVtbl->CreateAuthenticatedChannel(video_device, channel_type, authenticated_channel); +} +static inline HRESULT D3D11CreateCryptoSession(D3D11VideoDevice video_device, GUID* crypto_type, GUID* decoder_profile, GUID* key_exchange_type, D3D11CryptoSession* crypto_session) +{ + return video_device->lpVtbl->CreateCryptoSession(video_device, crypto_type, decoder_profile, key_exchange_type, crypto_session); +} +static inline HRESULT D3D11CreateVideoDecoderOutputView(D3D11VideoDevice video_device, D3D11Resource resource, D3D11_VIDEO_DECODER_OUTPUT_VIEW_DESC* desc, D3D11VideoDecoderOutputView* vdovview) +{ + return video_device->lpVtbl->CreateVideoDecoderOutputView(video_device, resource, desc, vdovview); +} +static inline HRESULT D3D11CreateVideoProcessorInputView(D3D11VideoDevice video_device, D3D11Resource resource, D3D11VideoProcessorEnumerator enumerator, D3D11_VIDEO_PROCESSOR_INPUT_VIEW_DESC* desc, D3D11VideoProcessorInputView* vpiview) +{ + return video_device->lpVtbl->CreateVideoProcessorInputView(video_device, resource, enumerator, desc, vpiview); +} +static inline HRESULT D3D11CreateVideoProcessorOutputView(D3D11VideoDevice video_device, D3D11Resource resource, D3D11VideoProcessorEnumerator enumerator, D3D11_VIDEO_PROCESSOR_OUTPUT_VIEW_DESC* desc, D3D11VideoProcessorOutputView* vpoview) +{ + return video_device->lpVtbl->CreateVideoProcessorOutputView(video_device, resource, enumerator, desc, vpoview); +} +static inline HRESULT D3D11CreateVideoProcessorEnumerator(D3D11VideoDevice video_device, D3D11_VIDEO_PROCESSOR_CONTENT_DESC* desc, D3D11VideoProcessorEnumerator* enumerator) +{ + return video_device->lpVtbl->CreateVideoProcessorEnumerator(video_device, desc, enumerator); +} +static inline UINT D3D11GetVideoDecoderProfileCount(D3D11VideoDevice video_device) +{ + return video_device->lpVtbl->GetVideoDecoderProfileCount(video_device); +} +static inline HRESULT D3D11GetVideoDecoderProfile(D3D11VideoDevice video_device, UINT index, GUID* decoder_profile) +{ + return video_device->lpVtbl->GetVideoDecoderProfile(video_device, index, decoder_profile); +} +static inline HRESULT D3D11CheckVideoDecoderFormat(D3D11VideoDevice video_device, GUID* decoder_profile, DXGI_FORMAT format, BOOL* supported) +{ + return video_device->lpVtbl->CheckVideoDecoderFormat(video_device, decoder_profile, format, supported); +} +static inline HRESULT D3D11GetVideoDecoderConfigCount(D3D11VideoDevice video_device, D3D11_VIDEO_DECODER_DESC* desc, UINT* count) +{ + return video_device->lpVtbl->GetVideoDecoderConfigCount(video_device, desc, count); +} +static inline HRESULT D3D11GetVideoDecoderConfig(D3D11VideoDevice video_device, D3D11_VIDEO_DECODER_DESC* desc, UINT index, D3D11_VIDEO_DECODER_CONFIG* config) +{ + return video_device->lpVtbl->GetVideoDecoderConfig(video_device, desc, index, config); +} +static inline HRESULT D3D11GetContentProtectionCaps(D3D11VideoDevice video_device, GUID* crypto_type, GUID* decoder_profile, D3D11_VIDEO_CONTENT_PROTECTION_CAPS* caps) +{ + return video_device->lpVtbl->GetContentProtectionCaps(video_device, crypto_type, decoder_profile, caps); +} +static inline HRESULT D3D11CheckCryptoKeyExchange(D3D11VideoDevice video_device, GUID* crypto_type, GUID* decoder_profile, UINT index, GUID* key_exchange_type) +{ + return video_device->lpVtbl->CheckCryptoKeyExchange(video_device, crypto_type, decoder_profile, index, key_exchange_type); +} +static inline HRESULT D3D11CreateBuffer(D3D11Device device, D3D11_BUFFER_DESC* desc, D3D11_SUBRESOURCE_DATA* initial_data, D3D11Buffer* buffer) +{ + return device->lpVtbl->CreateBuffer(device, desc, initial_data, buffer); +} +static inline HRESULT D3D11CreateTexture1D(D3D11Device device, D3D11_TEXTURE1D_DESC* desc, D3D11_SUBRESOURCE_DATA* initial_data, D3D11Texture1D* texture1d) +{ + return device->lpVtbl->CreateTexture1D(device, desc, initial_data, texture1d); +} +static inline HRESULT D3D11CreateTexture2D(D3D11Device device, D3D11_TEXTURE2D_DESC* desc, D3D11_SUBRESOURCE_DATA* initial_data, D3D11Texture2D* texture2d) +{ + return device->lpVtbl->CreateTexture2D(device, desc, initial_data, texture2d); +} +static inline HRESULT D3D11CreateTexture3D(D3D11Device device, D3D11_TEXTURE3D_DESC* desc, D3D11_SUBRESOURCE_DATA* initial_data, D3D11Texture3D* texture3d) +{ + return device->lpVtbl->CreateTexture3D(device, desc, initial_data, texture3d); +} +static inline HRESULT D3D11CreateShaderResourceView(D3D11Device device, D3D11Resource resource, D3D11_SHADER_RESOURCE_VIEW_DESC* desc, D3D11ShaderResourceView* srview) +{ + return device->lpVtbl->CreateShaderResourceView(device, resource, desc, srview); +} +static inline HRESULT D3D11CreateUnorderedAccessView(D3D11Device device, D3D11Resource resource, D3D11_UNORDERED_ACCESS_VIEW_DESC* desc, D3D11UnorderedAccessView* uaview) +{ + return device->lpVtbl->CreateUnorderedAccessView(device, resource, desc, uaview); +} +static inline HRESULT D3D11CreateRenderTargetView(D3D11Device device, D3D11Resource resource, D3D11_RENDER_TARGET_VIEW_DESC* desc, D3D11RenderTargetView* rtview) +{ + return device->lpVtbl->CreateRenderTargetView(device, resource, desc, rtview); +} +static inline HRESULT D3D11CreateDepthStencilView(D3D11Device device, D3D11Resource resource, D3D11_DEPTH_STENCIL_VIEW_DESC* desc, D3D11DepthStencilView* depth_stencil_view) +{ + return device->lpVtbl->CreateDepthStencilView(device, resource, desc, depth_stencil_view); +} +static inline HRESULT D3D11CreateInputLayout(D3D11Device device, D3D11_INPUT_ELEMENT_DESC* input_element_descs, UINT num_elements, void* shader_bytecode_with_input_signature, SIZE_T bytecode_length, D3D11InputLayout* input_layout) +{ + return device->lpVtbl->CreateInputLayout(device, input_element_descs, num_elements, shader_bytecode_with_input_signature, bytecode_length, input_layout); +} +static inline HRESULT D3D11CreateVertexShader(D3D11Device device, void* shader_bytecode, SIZE_T bytecode_length, D3D11ClassLinkage class_linkage, D3D11VertexShader* vertex_shader) +{ + return device->lpVtbl->CreateVertexShader(device, shader_bytecode, bytecode_length, class_linkage, vertex_shader); +} +static inline HRESULT D3D11CreateGeometryShader(D3D11Device device, void* shader_bytecode, SIZE_T bytecode_length, D3D11ClassLinkage class_linkage, D3D11GeometryShader* geometry_shader) +{ + return device->lpVtbl->CreateGeometryShader(device, shader_bytecode, bytecode_length, class_linkage, geometry_shader); +} +static inline HRESULT D3D11CreateGeometryShaderWithStreamOutput(D3D11Device device, void* shader_bytecode, SIZE_T bytecode_length, D3D11_SO_DECLARATION_ENTRY* sodeclaration, UINT num_entries, UINT* buffer_strides, UINT num_strides, UINT rasterized_stream, D3D11ClassLinkage class_linkage, D3D11GeometryShader* geometry_shader) +{ + return device->lpVtbl->CreateGeometryShaderWithStreamOutput(device, shader_bytecode, bytecode_length, sodeclaration, num_entries, buffer_strides, num_strides, rasterized_stream, class_linkage, geometry_shader); +} +static inline HRESULT D3D11CreatePixelShader(D3D11Device device, void* shader_bytecode, SIZE_T bytecode_length, D3D11ClassLinkage class_linkage, D3D11PixelShader* pixel_shader) +{ + return device->lpVtbl->CreatePixelShader(device, shader_bytecode, bytecode_length, class_linkage, pixel_shader); +} +static inline HRESULT D3D11CreateHullShader(D3D11Device device, void* shader_bytecode, SIZE_T bytecode_length, D3D11ClassLinkage class_linkage, D3D11HullShader* hull_shader) +{ + return device->lpVtbl->CreateHullShader(device, shader_bytecode, bytecode_length, class_linkage, hull_shader); +} +static inline HRESULT D3D11CreateDomainShader(D3D11Device device, void* shader_bytecode, SIZE_T bytecode_length, D3D11ClassLinkage class_linkage, D3D11DomainShader* domain_shader) +{ + return device->lpVtbl->CreateDomainShader(device, shader_bytecode, bytecode_length, class_linkage, domain_shader); +} +static inline HRESULT D3D11CreateComputeShader(D3D11Device device, void* shader_bytecode, SIZE_T bytecode_length, D3D11ClassLinkage class_linkage, D3D11ComputeShader* compute_shader) +{ + return device->lpVtbl->CreateComputeShader(device, shader_bytecode, bytecode_length, class_linkage, compute_shader); +} +static inline HRESULT D3D11CreateClassLinkage(D3D11Device device, D3D11ClassLinkage* linkage) +{ + return device->lpVtbl->CreateClassLinkage(device, linkage); +} +static inline HRESULT D3D11CreateBlendState(D3D11Device device, D3D11_BLEND_DESC* blend_state_desc, D3D11BlendState* blend_state) +{ + return device->lpVtbl->CreateBlendState(device, blend_state_desc, blend_state); +} +static inline HRESULT D3D11CreateDepthStencilState(D3D11Device device, D3D11_DEPTH_STENCIL_DESC* depth_stencil_desc, D3D11DepthStencilState* depth_stencil_state) +{ + return device->lpVtbl->CreateDepthStencilState(device, depth_stencil_desc, depth_stencil_state); +} +static inline HRESULT D3D11CreateRasterizerState(D3D11Device device, D3D11_RASTERIZER_DESC* rasterizer_desc, D3D11RasterizerState* rasterizer_state) +{ + return device->lpVtbl->CreateRasterizerState(device, rasterizer_desc, rasterizer_state); +} +static inline HRESULT D3D11CreateSamplerState(D3D11Device device, D3D11_SAMPLER_DESC* sampler_desc, D3D11SamplerState* sampler_state) +{ + return device->lpVtbl->CreateSamplerState(device, sampler_desc, sampler_state); +} +static inline HRESULT D3D11CreateQuery(D3D11Device device, D3D11_QUERY_DESC* query_desc, D3D11Query* query) +{ + return device->lpVtbl->CreateQuery(device, query_desc, query); +} +static inline HRESULT D3D11CreatePredicate(D3D11Device device, D3D11_QUERY_DESC* predicate_desc, D3D11Predicate* predicate) +{ + return device->lpVtbl->CreatePredicate(device, predicate_desc, predicate); +} +static inline HRESULT D3D11CreateCounter(D3D11Device device, D3D11_COUNTER_DESC* counter_desc, D3D11Counter* counter) +{ + return device->lpVtbl->CreateCounter(device, counter_desc, counter); +} +static inline HRESULT D3D11CreateDeferredContext(D3D11Device device, UINT context_flags, D3D11DeviceContext* deferred_context) +{ + return device->lpVtbl->CreateDeferredContext(device, context_flags, deferred_context); +} +static inline HRESULT D3D11OpenSharedResource(D3D11Device device, HANDLE h_resource, ID3D11Resource** out) +{ + return device->lpVtbl->OpenSharedResource(device, h_resource, __uuidof(ID3D11Resource), (void**)out); +} +static inline HRESULT D3D11CheckFormatSupport(D3D11Device device, DXGI_FORMAT format, UINT* format_support) +{ + return device->lpVtbl->CheckFormatSupport(device, format, format_support); +} +static inline HRESULT D3D11CheckMultisampleQualityLevels(D3D11Device device, DXGI_FORMAT format, UINT sample_count, UINT* num_quality_levels) +{ + return device->lpVtbl->CheckMultisampleQualityLevels(device, format, sample_count, num_quality_levels); +} +static inline void D3D11CheckCounterInfo(D3D11Device device, D3D11_COUNTER_INFO* counter_info) +{ + device->lpVtbl->CheckCounterInfo(device, counter_info); +} +static inline HRESULT D3D11CheckCounter(D3D11Device device, D3D11_COUNTER_DESC* desc, D3D11_COUNTER_TYPE* type, UINT* active_counters, LPSTR sz_name, UINT* name_length, LPSTR sz_units, UINT* units_length, LPSTR sz_description, UINT* description_length) +{ + return device->lpVtbl->CheckCounter(device, desc, type, active_counters, sz_name, name_length, sz_units, units_length, sz_description, description_length); +} +static inline HRESULT D3D11CheckFeatureSupport(D3D11Device device, D3D11_FEATURE feature, void* feature_support_data, UINT feature_support_data_size) +{ + return device->lpVtbl->CheckFeatureSupport(device, feature, feature_support_data, feature_support_data_size); +} +static inline D3D_FEATURE_LEVEL D3D11GetFeatureLevel(D3D11Device device) +{ + return device->lpVtbl->GetFeatureLevel(device); +} +static inline UINT D3D11GetCreationFlags(D3D11Device device) +{ + return device->lpVtbl->GetCreationFlags(device); +} +static inline HRESULT D3D11GetDeviceRemovedReason(D3D11Device device) +{ + return device->lpVtbl->GetDeviceRemovedReason(device); +} +static inline void D3D11GetImmediateContext(D3D11Device device, D3D11DeviceContext* immediate_context) +{ + device->lpVtbl->GetImmediateContext(device, immediate_context); +} +static inline HRESULT D3D11SetExceptionMode(D3D11Device device, UINT raise_flags) +{ + return device->lpVtbl->SetExceptionMode(device, raise_flags); +} +static inline UINT D3D11GetExceptionMode(D3D11Device device) +{ + return device->lpVtbl->GetExceptionMode(device); +} +static inline HRESULT D3D11SetDebugFeatureMask(D3D11Debug debug, UINT mask) +{ + return debug->lpVtbl->SetFeatureMask(debug, mask); +} +static inline UINT D3D11GetDebugFeatureMask(D3D11Debug debug) +{ + return debug->lpVtbl->GetFeatureMask(debug); +} +static inline HRESULT D3D11SetPresentPerRenderOpDelay(D3D11Debug debug, UINT milliseconds) +{ + return debug->lpVtbl->SetPresentPerRenderOpDelay(debug, milliseconds); +} +static inline UINT D3D11GetPresentPerRenderOpDelay(D3D11Debug debug) +{ + return debug->lpVtbl->GetPresentPerRenderOpDelay(debug); +} +static inline HRESULT D3D11SetSwapChain(D3D11Debug debug, IDXGISwapChain* swap_chain) +{ + return debug->lpVtbl->SetSwapChain(debug, (IDXGISwapChain*)swap_chain); +} +static inline HRESULT D3D11GetSwapChain(D3D11Debug debug, IDXGISwapChain** swap_chain) +{ + return debug->lpVtbl->GetSwapChain(debug, (IDXGISwapChain**)swap_chain); +} +static inline HRESULT D3D11ValidateContext(D3D11Debug debug, D3D11DeviceContext context) +{ + return debug->lpVtbl->ValidateContext(debug, context); +} +static inline HRESULT D3D11ReportLiveDeviceObjects(D3D11Debug debug, D3D11_RLDO_FLAGS flags) +{ + return debug->lpVtbl->ReportLiveDeviceObjects(debug, flags); +} +static inline HRESULT D3D11ValidateContextForDispatch(D3D11Debug debug, D3D11DeviceContext context) +{ + return debug->lpVtbl->ValidateContextForDispatch(debug, context); +} +static inline BOOL D3D11SetUseRef(D3D11SwitchToRef switch_to_ref, BOOL use_ref) +{ + return switch_to_ref->lpVtbl->SetUseRef(switch_to_ref, use_ref); +} +static inline BOOL D3D11GetUseRef(D3D11SwitchToRef switch_to_ref) +{ + return switch_to_ref->lpVtbl->GetUseRef(switch_to_ref); +} +static inline HRESULT D3D11SetShaderTrackingOptionsByType(D3D11TracingDevice tracing_device, UINT resource_type_flags, UINT options) +{ + return tracing_device->lpVtbl->SetShaderTrackingOptionsByType(tracing_device, resource_type_flags, options); +} +static inline HRESULT D3D11SetShaderTrackingOptions(D3D11TracingDevice tracing_device, void* shader, UINT options) +{ + return tracing_device->lpVtbl->SetShaderTrackingOptions(tracing_device, (IUnknown*)shader, options); +} +static inline HRESULT D3D11SetMessageCountLimit(D3D11InfoQueue info_queue, UINT64 message_count_limit) +{ + return info_queue->lpVtbl->SetMessageCountLimit(info_queue, message_count_limit); +} +static inline void D3D11ClearStoredMessages(D3D11InfoQueue info_queue) +{ + info_queue->lpVtbl->ClearStoredMessages(info_queue); +} +static inline HRESULT D3D11GetMessageA(D3D11InfoQueue info_queue, UINT64 message_index, D3D11_MESSAGE* message, SIZE_T* message_byte_length) +{ + return info_queue->lpVtbl->GetMessageA(info_queue, message_index, message, message_byte_length); +} +static inline UINT64 D3D11GetNumMessagesAllowedByStorageFilter(D3D11InfoQueue info_queue) +{ + return info_queue->lpVtbl->GetNumMessagesAllowedByStorageFilter(info_queue); +} +static inline UINT64 D3D11GetNumMessagesDeniedByStorageFilter(D3D11InfoQueue info_queue) +{ + return info_queue->lpVtbl->GetNumMessagesDeniedByStorageFilter(info_queue); +} +static inline UINT64 D3D11GetNumStoredMessages(D3D11InfoQueue info_queue) +{ + return info_queue->lpVtbl->GetNumStoredMessages(info_queue); +} +static inline UINT64 D3D11GetNumStoredMessagesAllowedByRetrievalFilter(D3D11InfoQueue info_queue) +{ + return info_queue->lpVtbl->GetNumStoredMessagesAllowedByRetrievalFilter(info_queue); +} +static inline UINT64 D3D11GetNumMessagesDiscardedByMessageCountLimit(D3D11InfoQueue info_queue) +{ + return info_queue->lpVtbl->GetNumMessagesDiscardedByMessageCountLimit(info_queue); +} +static inline UINT64 D3D11GetMessageCountLimit(D3D11InfoQueue info_queue) +{ + return info_queue->lpVtbl->GetMessageCountLimit(info_queue); +} +static inline HRESULT D3D11AddStorageFilterEntries(D3D11InfoQueue info_queue, D3D11_INFO_QUEUE_FILTER* filter) +{ + return info_queue->lpVtbl->AddStorageFilterEntries(info_queue, filter); +} +static inline HRESULT D3D11GetStorageFilter(D3D11InfoQueue info_queue, D3D11_INFO_QUEUE_FILTER* filter, SIZE_T* filter_byte_length) +{ + return info_queue->lpVtbl->GetStorageFilter(info_queue, filter, filter_byte_length); +} +static inline void D3D11ClearStorageFilter(D3D11InfoQueue info_queue) +{ + info_queue->lpVtbl->ClearStorageFilter(info_queue); +} +static inline HRESULT D3D11PushEmptyStorageFilter(D3D11InfoQueue info_queue) +{ + return info_queue->lpVtbl->PushEmptyStorageFilter(info_queue); +} +static inline HRESULT D3D11PushCopyOfStorageFilter(D3D11InfoQueue info_queue) +{ + return info_queue->lpVtbl->PushCopyOfStorageFilter(info_queue); +} +static inline HRESULT D3D11PushStorageFilter(D3D11InfoQueue info_queue, D3D11_INFO_QUEUE_FILTER* filter) +{ + return info_queue->lpVtbl->PushStorageFilter(info_queue, filter); +} +static inline void D3D11PopStorageFilter(D3D11InfoQueue info_queue) +{ + info_queue->lpVtbl->PopStorageFilter(info_queue); +} +static inline UINT D3D11GetStorageFilterStackSize(D3D11InfoQueue info_queue) +{ + return info_queue->lpVtbl->GetStorageFilterStackSize(info_queue); +} +static inline HRESULT D3D11AddRetrievalFilterEntries(D3D11InfoQueue info_queue, D3D11_INFO_QUEUE_FILTER* filter) +{ + return info_queue->lpVtbl->AddRetrievalFilterEntries(info_queue, filter); +} +static inline HRESULT D3D11GetRetrievalFilter(D3D11InfoQueue info_queue, D3D11_INFO_QUEUE_FILTER* filter, SIZE_T* filter_byte_length) +{ + return info_queue->lpVtbl->GetRetrievalFilter(info_queue, filter, filter_byte_length); +} +static inline void D3D11ClearRetrievalFilter(D3D11InfoQueue info_queue) +{ + info_queue->lpVtbl->ClearRetrievalFilter(info_queue); +} +static inline HRESULT D3D11PushEmptyRetrievalFilter(D3D11InfoQueue info_queue) +{ + return info_queue->lpVtbl->PushEmptyRetrievalFilter(info_queue); +} +static inline HRESULT D3D11PushCopyOfRetrievalFilter(D3D11InfoQueue info_queue) +{ + return info_queue->lpVtbl->PushCopyOfRetrievalFilter(info_queue); +} +static inline HRESULT D3D11PushRetrievalFilter(D3D11InfoQueue info_queue, D3D11_INFO_QUEUE_FILTER* filter) +{ + return info_queue->lpVtbl->PushRetrievalFilter(info_queue, filter); +} +static inline void D3D11PopRetrievalFilter(D3D11InfoQueue info_queue) +{ + info_queue->lpVtbl->PopRetrievalFilter(info_queue); +} +static inline UINT D3D11GetRetrievalFilterStackSize(D3D11InfoQueue info_queue) +{ + return info_queue->lpVtbl->GetRetrievalFilterStackSize(info_queue); +} +static inline HRESULT D3D11AddMessage(D3D11InfoQueue info_queue, D3D11_MESSAGE_CATEGORY category, D3D11_MESSAGE_SEVERITY severity, D3D11_MESSAGE_ID id, LPCSTR description) +{ + return info_queue->lpVtbl->AddMessage(info_queue, category, severity, id, description); +} +static inline HRESULT D3D11AddApplicationMessage(D3D11InfoQueue info_queue, D3D11_MESSAGE_SEVERITY severity, LPCSTR description) +{ + return info_queue->lpVtbl->AddApplicationMessage(info_queue, severity, description); +} +static inline HRESULT D3D11SetBreakOnCategory(D3D11InfoQueue info_queue, D3D11_MESSAGE_CATEGORY category, BOOL enable) +{ + return info_queue->lpVtbl->SetBreakOnCategory(info_queue, category, enable); +} +static inline HRESULT D3D11SetBreakOnSeverity(D3D11InfoQueue info_queue, D3D11_MESSAGE_SEVERITY severity, BOOL enable) +{ + return info_queue->lpVtbl->SetBreakOnSeverity(info_queue, severity, enable); +} +static inline HRESULT D3D11SetBreakOnID(D3D11InfoQueue info_queue, D3D11_MESSAGE_ID id, BOOL enable) +{ + return info_queue->lpVtbl->SetBreakOnID(info_queue, id, enable); +} +static inline BOOL D3D11GetBreakOnCategory(D3D11InfoQueue info_queue, D3D11_MESSAGE_CATEGORY category) +{ + return info_queue->lpVtbl->GetBreakOnCategory(info_queue, category); +} +static inline BOOL D3D11GetBreakOnSeverity(D3D11InfoQueue info_queue, D3D11_MESSAGE_SEVERITY severity) +{ + return info_queue->lpVtbl->GetBreakOnSeverity(info_queue, severity); +} +static inline BOOL D3D11GetBreakOnID(D3D11InfoQueue info_queue, D3D11_MESSAGE_ID id) +{ + return info_queue->lpVtbl->GetBreakOnID(info_queue, id); +} +static inline void D3D11SetMuteDebugOutput(D3D11InfoQueue info_queue, BOOL mute) +{ + info_queue->lpVtbl->SetMuteDebugOutput(info_queue, mute); +} +static inline BOOL D3D11GetMuteDebugOutput(D3D11InfoQueue info_queue) +{ + return info_queue->lpVtbl->GetMuteDebugOutput(info_queue); +} +/* end of auto-generated */ + +static inline HRESULT DXGIGetSwapChainBufferD3D11(DXGISwapChain swap_chain, UINT buffer, D3D11Texture2D* out) +{ + return swap_chain->lpVtbl->GetBuffer(swap_chain, buffer, __uuidof(ID3D11Texture2D), (void**)out); +} + +static inline HRESULT D3D11MapTexture2D(D3D11DeviceContext device_context, D3D11Texture2D texture, UINT subresource, D3D11_MAP map_type, UINT map_flags, D3D11_MAPPED_SUBRESOURCE* mapped_resource) +{ + return device_context->lpVtbl->Map(device_context, (D3D11Resource) texture, subresource, map_type, map_flags, mapped_resource); +} +static inline void D3D11UnmapTexture2D(D3D11DeviceContext device_context, D3D11Texture2D texture, UINT subresource) +{ + device_context->lpVtbl->Unmap(device_context, (D3D11Resource)texture, subresource); +} +static inline void D3D11CopyTexture2DSubresourceRegion(D3D11DeviceContext device_context, D3D11Texture2D dst_texture, UINT dst_subresource, UINT dst_x, UINT dst_y, UINT dst_z, D3D11Texture2D src_texture, UINT src_subresource, D3D11_BOX* src_box) +{ + device_context->lpVtbl->CopySubresourceRegion(device_context, (D3D11Resource)dst_texture, dst_subresource, dst_x, dst_y, dst_z, (D3D11Resource)src_texture, src_subresource, src_box); +} +static inline HRESULT D3D11CreateTexture2DRenderTargetView(D3D11Device device, D3D11Texture2D texture, D3D11_RENDER_TARGET_VIEW_DESC* desc, D3D11RenderTargetView* rtview) +{ + return device->lpVtbl->CreateRenderTargetView(device, (D3D11Resource)texture, desc, rtview); +} +static inline HRESULT D3D11CreateTexture2DShaderResourceView(D3D11Device device, D3D11Texture2D texture, D3D11_SHADER_RESOURCE_VIEW_DESC* desc, D3D11ShaderResourceView* srview) +{ + return device->lpVtbl->CreateShaderResourceView(device, (D3D11Resource)texture, desc, srview); +} + +static inline HRESULT D3D11MapBuffer(D3D11DeviceContext device_context, D3D11Buffer buffer, UINT subresource, D3D11_MAP map_type, UINT map_flags, D3D11_MAPPED_SUBRESOURCE* mapped_resource) +{ + return device_context->lpVtbl->Map(device_context, (D3D11Resource)buffer, subresource, map_type, map_flags, mapped_resource); +} +static inline void D3D11UnmapBuffer(D3D11DeviceContext device_context, D3D11Buffer buffer, UINT subresource) +{ + device_context->lpVtbl->Unmap(device_context, (D3D11Resource)buffer, subresource); +} diff --git a/gfx/common/d3d12_common.c b/gfx/common/d3d12_common.c new file mode 100644 index 0000000000..60e93bac99 --- /dev/null +++ b/gfx/common/d3d12_common.c @@ -0,0 +1,482 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2014-2018 - Ali Bouhlel + * + * RetroArch is free software: you can redistribute it and/or modify it under the terms + * of the GNU General Public License as published by the Free Software Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with RetroArch. + * If not, see . + */ + +#include + +#include "d3d12_common.h" +#include "dxgi_common.h" +#include "d3dcompiler_common.h" + +#include "verbosity.h" + +static dylib_t d3d12_dll; +static const char *d3d12_dll_name = "d3d12.dll"; + +HRESULT WINAPI +D3D12CreateDevice(IUnknown *pAdapter, + D3D_FEATURE_LEVEL MinimumFeatureLevel, + REFIID riid, void **ppDevice) +{ + if (!d3d12_dll) + d3d12_dll = dylib_load(d3d12_dll_name); + + if (d3d12_dll) + { + static PFN_D3D12_CREATE_DEVICE fp; + + if (!fp) + fp = (PFN_D3D12_CREATE_DEVICE)dylib_proc(d3d12_dll, "D3D12CreateDevice"); + + if (fp) + return fp(pAdapter, MinimumFeatureLevel, riid, ppDevice); + } + + return TYPE_E_CANTLOADLIBRARY; +} + +HRESULT WINAPI +D3D12GetDebugInterface(REFIID riid, void **ppvDebug) +{ + if (!d3d12_dll) + d3d12_dll = dylib_load(d3d12_dll_name); + + if (d3d12_dll) + { + static PFN_D3D12_GET_DEBUG_INTERFACE fp; + + if (!fp) + fp = (PFN_D3D12_GET_DEBUG_INTERFACE)dylib_proc(d3d12_dll, "D3D12GetDebugInterface"); + + if (fp) + return fp(riid, ppvDebug); + } + + return TYPE_E_CANTLOADLIBRARY; +} + +HRESULT WINAPI +D3D12SerializeRootSignature(const D3D12_ROOT_SIGNATURE_DESC *pRootSignature, + D3D_ROOT_SIGNATURE_VERSION Version, + ID3DBlob **ppBlob, ID3DBlob **ppErrorBlob) +{ + if (!d3d12_dll) + d3d12_dll = dylib_load(d3d12_dll_name); + + if (d3d12_dll) + { + static PFN_D3D12_SERIALIZE_ROOT_SIGNATURE fp; + + if (!fp) + fp = (PFN_D3D12_SERIALIZE_ROOT_SIGNATURE)dylib_proc(d3d12_dll, "D3D12SerializeRootSignature"); + + if (fp) + return fp(pRootSignature, Version, ppBlob, ppErrorBlob); + } + + return TYPE_E_CANTLOADLIBRARY; +} + +HRESULT WINAPI +D3D12SerializeVersionedRootSignature(const D3D12_VERSIONED_ROOT_SIGNATURE_DESC *pRootSignature, + ID3DBlob **ppBlob, ID3DBlob **ppErrorBlob) +{ + if (!d3d12_dll) + d3d12_dll = dylib_load(d3d12_dll_name); + + if (d3d12_dll) + { + static PFN_D3D12_SERIALIZE_VERSIONED_ROOT_SIGNATURE fp; + + if (!fp) + fp = (PFN_D3D12_SERIALIZE_VERSIONED_ROOT_SIGNATURE)dylib_proc(d3d12_dll, + "D3D12SerializeRootSignature"); + + if (fp) + return fp(pRootSignature, ppBlob, ppErrorBlob); + } + + return TYPE_E_CANTLOADLIBRARY; +} + + +#include + +bool d3d12_init_context(d3d12_video_t *d3d12) +{ + +#ifdef DEBUG + D3D12GetDebugInterface_(&d3d12->debugController); + D3D12EnableDebugLayer(d3d12->debugController); +#endif + + DXGICreateFactory(&d3d12->factory); + + { + int i = 0; + + while (true) + { + if (FAILED(DXGIEnumAdapters(d3d12->factory, i++, &d3d12->adapter))) + return false; + + if (SUCCEEDED(D3D12CreateDevice_(d3d12->adapter, D3D_FEATURE_LEVEL_11_0, &d3d12->device))) + break; + + Release(d3d12->adapter); + } + } + + return true; +} + +bool d3d12_init_queue(d3d12_video_t *d3d12) +{ + { + D3D12_COMMAND_QUEUE_DESC desc = + { + .Type = D3D12_COMMAND_LIST_TYPE_DIRECT, + .Flags = D3D12_COMMAND_QUEUE_FLAG_NONE, + }; + D3D12CreateCommandQueue(d3d12->device, &desc, &d3d12->queue.handle); + } + + D3D12CreateCommandAllocator(d3d12->device, D3D12_COMMAND_LIST_TYPE_DIRECT, + &d3d12->queue.allocator); + + D3D12CreateGraphicsCommandList(d3d12->device, 0, D3D12_COMMAND_LIST_TYPE_DIRECT, + d3d12->queue.allocator, d3d12->pipe.handle, &d3d12->queue.cmd); + + D3D12CloseGraphicsCommandList(d3d12->queue.cmd); + + D3D12CreateFence(d3d12->device, 0, D3D12_FENCE_FLAG_NONE, &d3d12->queue.fence); + d3d12->queue.fenceValue = 1; + d3d12->queue.fenceEvent = CreateEvent(NULL, FALSE, FALSE, NULL); + + return true; +} + +bool d3d12_init_swapchain(d3d12_video_t *d3d12, int width, int height, HWND hwnd) +{ + { + DXGI_SWAP_CHAIN_DESC desc = + { + .BufferCount = countof(d3d12->chain.renderTargets), + .BufferDesc.Width = width, + .BufferDesc.Height = height, + .BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM, + .SampleDesc.Count = 1, +// .BufferDesc.RefreshRate.Numerator = 60, +// .BufferDesc.RefreshRate.Denominator = 1, +// .SampleDesc.Quality = 0, + .BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT, + .OutputWindow = hwnd, + .Windowed = TRUE, + .SwapEffect = DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL, +// .SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD, + }; + DXGICreateSwapChain(d3d12->factory, d3d12->queue.handle, &desc, &d3d12->chain.handle); + } + + DXGIMakeWindowAssociation(d3d12->factory, hwnd, DXGI_MWA_NO_ALT_ENTER); + + d3d12->chain.frame_index = DXGIGetCurrentBackBufferIndex(d3d12->chain.handle); + + for (int i = 0; i < countof(d3d12->chain.renderTargets); i++) + { + d3d12->chain.desc_handles[i].ptr = d3d12->pipe.rtv_heap.cpu.ptr + i * d3d12->pipe.rtv_heap.stride; + DXGIGetSwapChainBuffer(d3d12->chain.handle, i, &d3d12->chain.renderTargets[i]); + D3D12CreateRenderTargetView(d3d12->device, d3d12->chain.renderTargets[i], + NULL, d3d12->chain.desc_handles[i]); + } + + d3d12->chain.viewport.Width = width; + d3d12->chain.viewport.Height = height; + d3d12->chain.scissorRect.right = width; + d3d12->chain.scissorRect.bottom = height; + + return true; +} + +static void d3d12_init_descriptor_heap(D3D12Device device, d3d12_descriptor_heap_t *out) +{ + D3D12CreateDescriptorHeap(device, &out->desc, &out->handle); + out->cpu = D3D12GetCPUDescriptorHandleForHeapStart(out->handle); + out->gpu = D3D12GetGPUDescriptorHandleForHeapStart(out->handle); + out->stride = D3D12GetDescriptorHandleIncrementSize(device, out->desc.Type); +} + + +bool d3d12_init_descriptors(d3d12_video_t *d3d12) +{ + static const D3D12_DESCRIPTOR_RANGE desc_table[] = + { + { + .RangeType = D3D12_DESCRIPTOR_RANGE_TYPE_SRV, + .NumDescriptors = 1, + .BaseShaderRegister = 0, + .RegisterSpace = 0, +// .Flags = D3D12_DESCRIPTOR_RANGE_FLAG_DATA_STATIC, /* version 1_1 only */ + .OffsetInDescriptorsFromTableStart = D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND, + }, + }; + + + static const D3D12_ROOT_PARAMETER rootParameters[] = + { + { + .ParameterType = D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE, + .DescriptorTable = {countof(desc_table), desc_table}, + .ShaderVisibility = D3D12_SHADER_VISIBILITY_PIXEL, + }, + }; + + static const D3D12_STATIC_SAMPLER_DESC samplers[] = + { + { + .Filter = D3D12_FILTER_MIN_MAG_MIP_LINEAR, + .AddressU = D3D12_TEXTURE_ADDRESS_MODE_BORDER, + .AddressV = D3D12_TEXTURE_ADDRESS_MODE_BORDER, + .AddressW = D3D12_TEXTURE_ADDRESS_MODE_BORDER, + .MipLODBias = 0, + .MaxAnisotropy = 0, + .ComparisonFunc = D3D12_COMPARISON_FUNC_NEVER, + .BorderColor = D3D12_STATIC_BORDER_COLOR_TRANSPARENT_BLACK, + .MinLOD = 0.0f, + .MaxLOD = D3D12_FLOAT32_MAX, + .ShaderRegister = 0, + .RegisterSpace = 0, + .ShaderVisibility = D3D12_SHADER_VISIBILITY_PIXEL, + }, + }; + + static const D3D12_ROOT_SIGNATURE_DESC desc = + { + .NumParameters = countof(rootParameters), rootParameters, + .NumStaticSamplers = countof(samplers), samplers, + .Flags = D3D12_ROOT_SIGNATURE_FLAG_ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT, + }; + + { + D3DBlob signature; + D3DBlob error; + D3D12SerializeRootSignature(&desc, D3D_ROOT_SIGNATURE_VERSION_1, &signature, &error); + + if (error) + { + RARCH_ERR("[D3D12]: CreateRootSignature failed :\n%s\n", (const char *)D3DGetBufferPointer(error)); + Release(error); + return false; + } + + D3D12CreateRootSignature(d3d12->device, 0, D3DGetBufferPointer(signature), + D3DGetBufferSize(signature), &d3d12->pipe.rootSignature); + Release(signature); + } + + d3d12->pipe.rtv_heap.desc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_RTV; + d3d12->pipe.rtv_heap.desc.NumDescriptors = countof(d3d12->chain.renderTargets); + d3d12->pipe.rtv_heap.desc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_NONE; + d3d12_init_descriptor_heap(d3d12->device, &d3d12->pipe.rtv_heap); + + d3d12->pipe.srv_heap.desc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV; + d3d12->pipe.srv_heap.desc.NumDescriptors = 16; + d3d12->pipe.srv_heap.desc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE; + d3d12_init_descriptor_heap(d3d12->device, &d3d12->pipe.srv_heap); + + return true; +} + +bool d3d12_init_pipeline(d3d12_video_t *d3d12) +{ + D3DBlob vs_code; + D3DBlob ps_code; + + static const char stock [] = +#include "gfx/drivers/d3d_shaders/opaque_sm5.hlsl.h" + ; + + D3D12_INPUT_ELEMENT_DESC inputElementDesc[] = + { + {"POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, offsetof(d3d12_vertex_t, position), D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0}, + {"TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, offsetof(d3d12_vertex_t, texcoord), D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0}, + {"COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, offsetof(d3d12_vertex_t, color), D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0}, + }; + + + D3D12_RASTERIZER_DESC rasterizerDesc = + { + .FillMode = D3D12_FILL_MODE_SOLID, + .CullMode = D3D12_CULL_MODE_BACK, + .FrontCounterClockwise = FALSE, + .DepthBias = D3D12_DEFAULT_DEPTH_BIAS, + .DepthBiasClamp = D3D12_DEFAULT_DEPTH_BIAS_CLAMP, + .SlopeScaledDepthBias = D3D12_DEFAULT_SLOPE_SCALED_DEPTH_BIAS, + .DepthClipEnable = TRUE, + .MultisampleEnable = FALSE, + .AntialiasedLineEnable = FALSE, + .ForcedSampleCount = 0, + .ConservativeRaster = D3D12_CONSERVATIVE_RASTERIZATION_MODE_OFF, + }; + + const D3D12_RENDER_TARGET_BLEND_DESC defaultRenderTargetBlendDesc = + { + .BlendEnable = FALSE, .LogicOpEnable = FALSE, + D3D12_BLEND_ONE, D3D12_BLEND_ZERO, D3D12_BLEND_OP_ADD, + D3D12_BLEND_ONE, D3D12_BLEND_ZERO, D3D12_BLEND_OP_ADD, + D3D12_LOGIC_OP_NOOP, + D3D12_COLOR_WRITE_ENABLE_ALL, + }; + + D3D12_BLEND_DESC blendDesc = + { + .AlphaToCoverageEnable = FALSE, + .IndependentBlendEnable = FALSE, + .RenderTarget[0] = defaultRenderTargetBlendDesc, + }; + + if (!d3d_compile(stock, sizeof(stock), "VSMain", "vs_5_0", &vs_code)) + return false; + + if (!d3d_compile(stock, sizeof(stock), "PSMain", "ps_5_0", &ps_code)) + return false; + + { + D3D12_GRAPHICS_PIPELINE_STATE_DESC psodesc = + { + .pRootSignature = d3d12->pipe.rootSignature, + .VS.pShaderBytecode = D3DGetBufferPointer(vs_code), D3DGetBufferSize(vs_code), + .PS.pShaderBytecode = D3DGetBufferPointer(ps_code), D3DGetBufferSize(ps_code), + .BlendState = blendDesc, + .SampleMask = UINT_MAX, + .RasterizerState = rasterizerDesc, + .DepthStencilState.DepthEnable = FALSE, + .DepthStencilState.StencilEnable = FALSE, + .InputLayout.pInputElementDescs = inputElementDesc, countof(inputElementDesc), + .PrimitiveTopologyType = D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE, + .NumRenderTargets = 1, + .RTVFormats[0] = DXGI_FORMAT_R8G8B8A8_UNORM, + .SampleDesc.Count = 1, + }; + + D3D12CreateGraphicsPipelineState(d3d12->device, &psodesc, &d3d12->pipe.handle); + } + + Release(vs_code); + Release(ps_code); + + return true; +} + +void d3d12_create_vertex_buffer(D3D12Device device, D3D12_VERTEX_BUFFER_VIEW *view, + D3D12Resource *vbo) +{ + D3D12_HEAP_PROPERTIES heap_props = + { + .Type = D3D12_HEAP_TYPE_UPLOAD, + .CreationNodeMask = 1, + .VisibleNodeMask = 1, + }; + + D3D12_RESOURCE_DESC resource_desc = + { + .Dimension = D3D12_RESOURCE_DIMENSION_BUFFER, + .Width = view->SizeInBytes, + .Height = 1, + .DepthOrArraySize = 1, + .MipLevels = 1, + .SampleDesc.Count = 1, + .Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR, + }; + + D3D12CreateCommittedResource(device, &heap_props, D3D12_HEAP_FLAG_NONE, &resource_desc, + D3D12_RESOURCE_STATE_GENERIC_READ, NULL, vbo); + view->BufferLocation = D3D12GetGPUVirtualAddress(*vbo); +} + +void d3d12_create_texture(D3D12Device device, d3d12_descriptor_heap_t *heap, int heap_index, + d3d12_texture_t *tex) +{ + { + tex->desc.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D; + tex->desc.DepthOrArraySize = 1; + tex->desc.MipLevels = 1; + tex->desc.SampleDesc.Count = 1; + + D3D12_HEAP_PROPERTIES heap_props = {D3D12_HEAP_TYPE_DEFAULT, 0, 0, 1, 1}; + D3D12CreateCommittedResource(device, &heap_props, D3D12_HEAP_FLAG_NONE, &tex->desc, + D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE, NULL, &tex->handle); + } + + D3D12GetCopyableFootprints(device, &tex->desc, 0, 1, 0, &tex->layout, &tex->num_rows, + &tex->row_size_in_bytes, &tex->total_bytes); + + { + D3D12_RESOURCE_DESC buffer_desc = + { + .Dimension = D3D12_RESOURCE_DIMENSION_BUFFER, + .Width = tex->total_bytes, + .Height = 1, + .DepthOrArraySize = 1, + .MipLevels = 1, + .SampleDesc.Count = 1, + .Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR, + }; + D3D12_HEAP_PROPERTIES heap_props = {D3D12_HEAP_TYPE_UPLOAD, 0, 0, 1, 1}; + + D3D12CreateCommittedResource(device, &heap_props, D3D12_HEAP_FLAG_NONE, &buffer_desc, + D3D12_RESOURCE_STATE_GENERIC_READ, NULL, &tex->upload_buffer); + } + + { + D3D12_SHADER_RESOURCE_VIEW_DESC view_desc = + { + .Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING, + .Format = tex->desc.Format, + .ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2D, + .Texture2D.MipLevels = tex->desc.MipLevels, + }; + D3D12_CPU_DESCRIPTOR_HANDLE handle = {heap->cpu.ptr + heap_index *heap->stride}; + D3D12CreateShaderResourceView(device, tex->handle, &view_desc, handle); + tex->gpu_descriptor.ptr = heap->gpu.ptr + heap_index * heap->stride; + } + +} + +void d3d12_upload_texture(D3D12GraphicsCommandList cmd, d3d12_texture_t *texture) +{ + D3D12_TEXTURE_COPY_LOCATION src = + { + .pResource = texture->upload_buffer, + .Type = D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT, + .PlacedFootprint = texture->layout, + }; + + D3D12_TEXTURE_COPY_LOCATION dst = + { + .pResource = texture->handle, + .Type = D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX, + .SubresourceIndex = 0, + }; + + d3d12_transition(cmd, texture->handle, + D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE, D3D12_RESOURCE_STATE_COPY_DEST); + + D3D12CopyTextureRegion(cmd, &dst, 0, 0, 0, &src, NULL); + + d3d12_transition(cmd, texture->handle, + D3D12_RESOURCE_STATE_COPY_DEST, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE); + + texture->dirty = false; +} diff --git a/gfx/common/d3d12_common.h b/gfx/common/d3d12_common.h new file mode 100644 index 0000000000..8accd87996 --- /dev/null +++ b/gfx/common/d3d12_common.h @@ -0,0 +1,957 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2014-2018 - Ali Bouhlel + * + * RetroArch is free software: you can redistribute it and/or modify it under the terms + * of the GNU General Public License as published by the Free Software Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with RetroArch. + * If not, see . + */ + +#pragma once + +#ifdef __MINGW32__ +#define __REQUIRED_RPCNDR_H_VERSION__ 475 +#define _In_ +#define _In_opt_ +#define _Null_ + +#define _Out_writes_bytes_opt_(s) +#endif + +#define CINTERFACE +#include +#include "dxgi_common.h" + +#ifndef countof +#define countof(a) (sizeof(a)/ sizeof(*a)) +#endif + +#ifndef __uuidof +#define __uuidof(type) &IID_##type +#endif + +#ifndef COM_RELEASE_DECLARED +#define COM_RELEASE_DECLARED +#if defined(__cplusplus) && !defined(CINTERFACE) +static inline ULONG Release(IUnknown* object) +{ + return object->Release(); +} +#else +static inline ULONG Release(void* object) +{ + return ((IUnknown*)object)->lpVtbl->Release(object); +} +#endif +#endif + +/* auto-generated */ + +typedef ID3D12Object* D3D12Object; +typedef ID3D12DeviceChild* D3D12DeviceChild; +typedef ID3D12RootSignature* D3D12RootSignature; +typedef ID3D12RootSignatureDeserializer* D3D12RootSignatureDeserializer; +typedef ID3D12VersionedRootSignatureDeserializer* D3D12VersionedRootSignatureDeserializer; +typedef ID3D12Pageable* D3D12Pageable; +typedef ID3D12Heap* D3D12Heap; +typedef ID3D12Resource* D3D12Resource; +typedef ID3D12CommandAllocator* D3D12CommandAllocator; +typedef ID3D12Fence* D3D12Fence; +typedef ID3D12PipelineState* D3D12PipelineState; +typedef ID3D12DescriptorHeap* D3D12DescriptorHeap; +typedef ID3D12QueryHeap* D3D12QueryHeap; +typedef ID3D12CommandSignature* D3D12CommandSignature; +typedef ID3D12CommandList* D3D12CommandList; +typedef ID3D12GraphicsCommandList* D3D12GraphicsCommandList; +typedef ID3D12CommandQueue* D3D12CommandQueue; +typedef ID3D12Device* D3D12Device; +typedef ID3D12PipelineLibrary* D3D12PipelineLibrary; +typedef ID3D12Debug* D3D12Debug; +typedef ID3D12DebugDevice* D3D12DebugDevice; +typedef ID3D12DebugCommandQueue* D3D12DebugCommandQueue; +typedef ID3D12DebugCommandList* D3D12DebugCommandList; +typedef ID3D12InfoQueue* D3D12InfoQueue; + +static inline ULONG D3D12Release(void* object) +{ + return ((ID3D12Object*)object)->lpVtbl->Release(object); +} +static inline ULONG D3D12ReleaseDeviceChild(D3D12DeviceChild device_child) +{ + return device_child->lpVtbl->Release(device_child); +} +static inline ULONG D3D12ReleaseRootSignature(D3D12RootSignature root_signature) +{ + return root_signature->lpVtbl->Release(root_signature); +} +static inline ULONG D3D12ReleaseRootSignatureDeserializer(D3D12RootSignatureDeserializer root_signature_deserializer) +{ + return root_signature_deserializer->lpVtbl->Release(root_signature_deserializer); +} +static inline const D3D12_ROOT_SIGNATURE_DESC * D3D12GetRootSignatureDesc(D3D12RootSignatureDeserializer root_signature_deserializer) +{ + return root_signature_deserializer->lpVtbl->GetRootSignatureDesc(root_signature_deserializer); +} +static inline ULONG D3D12ReleaseVersionedRootSignatureDeserializer(D3D12VersionedRootSignatureDeserializer versioned_root_signature_deserializer) +{ + return versioned_root_signature_deserializer->lpVtbl->Release(versioned_root_signature_deserializer); +} +static inline HRESULT D3D12GetRootSignatureDescAtVersion(D3D12VersionedRootSignatureDeserializer versioned_root_signature_deserializer, D3D_ROOT_SIGNATURE_VERSION convert_to_version, const D3D12_VERSIONED_ROOT_SIGNATURE_DESC** desc) +{ + return versioned_root_signature_deserializer->lpVtbl->GetRootSignatureDescAtVersion(versioned_root_signature_deserializer, convert_to_version, desc); +} +static inline const D3D12_VERSIONED_ROOT_SIGNATURE_DESC * D3D12GetUnconvertedRootSignatureDesc(D3D12VersionedRootSignatureDeserializer versioned_root_signature_deserializer) +{ + return versioned_root_signature_deserializer->lpVtbl->GetUnconvertedRootSignatureDesc(versioned_root_signature_deserializer); +} +static inline ULONG D3D12ReleasePageable(D3D12Pageable pageable) +{ + return pageable->lpVtbl->Release(pageable); +} +static inline ULONG D3D12ReleaseHeap(D3D12Heap heap) +{ + return heap->lpVtbl->Release(heap); +} +static inline ULONG D3D12ReleaseResource(void* resource) +{ + return ((ID3D12Resource*)resource)->lpVtbl->Release(resource); +} +static inline HRESULT D3D12Map(void* resource, UINT subresource, D3D12_RANGE* read_range, void** data) +{ + return ((ID3D12Resource*)resource)->lpVtbl->Map(resource, subresource, read_range, data); +} +static inline void D3D12Unmap(void* resource, UINT subresource, D3D12_RANGE* written_range) +{ + ((ID3D12Resource*)resource)->lpVtbl->Unmap(resource, subresource, written_range); +} +static inline D3D12_GPU_VIRTUAL_ADDRESS D3D12GetGPUVirtualAddress(void* resource) +{ + return ((ID3D12Resource*)resource)->lpVtbl->GetGPUVirtualAddress(resource); +} +static inline HRESULT D3D12WriteToSubresource(void* resource, UINT dst_subresource, D3D12_BOX* dst_box, void* src_data, UINT src_row_pitch, UINT src_depth_pitch) +{ + return ((ID3D12Resource*)resource)->lpVtbl->WriteToSubresource(resource, dst_subresource, dst_box, src_data, src_row_pitch, src_depth_pitch); +} +static inline HRESULT D3D12ReadFromSubresource(void* resource, void* dst_data, UINT dst_row_pitch, UINT dst_depth_pitch, UINT src_subresource, D3D12_BOX* src_box) +{ + return ((ID3D12Resource*)resource)->lpVtbl->ReadFromSubresource(resource, dst_data, dst_row_pitch, dst_depth_pitch, src_subresource, src_box); +} +static inline HRESULT D3D12GetHeapProperties(void* resource, D3D12_HEAP_PROPERTIES* heap_properties, D3D12_HEAP_FLAGS* heap_flags) +{ + return ((ID3D12Resource*)resource)->lpVtbl->GetHeapProperties(resource, heap_properties, heap_flags); +} +static inline ULONG D3D12ReleaseCommandAllocator(D3D12CommandAllocator command_allocator) +{ + return command_allocator->lpVtbl->Release(command_allocator); +} +static inline HRESULT D3D12ResetCommandAllocator(D3D12CommandAllocator command_allocator) +{ + return command_allocator->lpVtbl->Reset(command_allocator); +} +static inline ULONG D3D12ReleaseFence(D3D12Fence fence) +{ + return fence->lpVtbl->Release(fence); +} +static inline UINT64 D3D12GetCompletedValue(D3D12Fence fence) +{ + return fence->lpVtbl->GetCompletedValue(fence); +} +static inline HRESULT D3D12SetEventOnCompletion(D3D12Fence fence, UINT64 value, HANDLE h_event) +{ + return fence->lpVtbl->SetEventOnCompletion(fence, value, h_event); +} +static inline HRESULT D3D12SignalFence(D3D12Fence fence, UINT64 value) +{ + return fence->lpVtbl->Signal(fence, value); +} +static inline ULONG D3D12ReleasePipelineState(D3D12PipelineState pipeline_state) +{ + return pipeline_state->lpVtbl->Release(pipeline_state); +} +static inline HRESULT D3D12GetCachedBlob(D3D12PipelineState pipeline_state, ID3DBlob** blob) +{ + return pipeline_state->lpVtbl->GetCachedBlob(pipeline_state, blob); +} +static inline ULONG D3D12ReleaseDescriptorHeap(D3D12DescriptorHeap descriptor_heap) +{ + return descriptor_heap->lpVtbl->Release(descriptor_heap); +} +static inline ULONG D3D12ReleaseQueryHeap(D3D12QueryHeap query_heap) +{ + return query_heap->lpVtbl->Release(query_heap); +} +static inline ULONG D3D12ReleaseCommandSignature(D3D12CommandSignature command_signature) +{ + return command_signature->lpVtbl->Release(command_signature); +} +static inline ULONG D3D12ReleaseCommandList(D3D12CommandList command_list) +{ + return command_list->lpVtbl->Release(command_list); +} +static inline ULONG D3D12ReleaseGraphicsCommandList(D3D12GraphicsCommandList graphics_command_list) +{ + return graphics_command_list->lpVtbl->Release(graphics_command_list); +} +static inline HRESULT D3D12CloseGraphicsCommandList(D3D12GraphicsCommandList graphics_command_list) +{ + return graphics_command_list->lpVtbl->Close(graphics_command_list); +} +static inline HRESULT D3D12ResetGraphicsCommandList(D3D12GraphicsCommandList graphics_command_list, D3D12CommandAllocator allocator, D3D12PipelineState initial_state) +{ + return graphics_command_list->lpVtbl->Reset(graphics_command_list, allocator, initial_state); +} +static inline void D3D12ClearState(D3D12GraphicsCommandList graphics_command_list, D3D12PipelineState pipeline_state) +{ + graphics_command_list->lpVtbl->ClearState(graphics_command_list, pipeline_state); +} +static inline void D3D12DrawInstanced(D3D12GraphicsCommandList graphics_command_list, UINT vertex_count_per_instance, UINT instance_count, UINT start_vertex_location, UINT start_instance_location) +{ + graphics_command_list->lpVtbl->DrawInstanced(graphics_command_list, vertex_count_per_instance, instance_count, start_vertex_location, start_instance_location); +} +static inline void 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) +{ + graphics_command_list->lpVtbl->DrawIndexedInstanced(graphics_command_list, index_count_per_instance, instance_count, start_index_location, base_vertex_location, start_instance_location); +} +static inline void D3D12Dispatch(D3D12GraphicsCommandList graphics_command_list, UINT thread_group_count_x, UINT thread_group_count_y, UINT thread_group_count_z) +{ + graphics_command_list->lpVtbl->Dispatch(graphics_command_list, thread_group_count_x, thread_group_count_y, thread_group_count_z); +} +static inline void D3D12CopyBufferRegion(D3D12GraphicsCommandList graphics_command_list, D3D12Resource dst_buffer, UINT64 dst_offset, D3D12Resource src_buffer, UINT64 src_offset, UINT64 num_bytes) +{ + graphics_command_list->lpVtbl->CopyBufferRegion(graphics_command_list, dst_buffer, dst_offset, (ID3D12Resource*)src_buffer, src_offset, num_bytes); +} +static inline void 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) +{ + graphics_command_list->lpVtbl->CopyTextureRegion(graphics_command_list, dst, dst_x, dst_y, dst_z, src, src_box); +} +static inline void D3D12CopyResource(D3D12GraphicsCommandList graphics_command_list, void* dst_resource, void* src_resource) +{ + graphics_command_list->lpVtbl->CopyResource(graphics_command_list, (ID3D12Resource*)dst_resource, (ID3D12Resource*)src_resource); +} +static inline void 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) +{ + graphics_command_list->lpVtbl->CopyTiles(graphics_command_list, (ID3D12Resource*)tiled_resource, tile_region_start_coordinate, tile_region_size, (ID3D12Resource*)buffer, buffer_start_offset_in_bytes, flags); +} +static inline void D3D12ResolveSubresource(D3D12GraphicsCommandList graphics_command_list, void* dst_resource, UINT dst_subresource, void* src_resource, UINT src_subresource, DXGI_FORMAT format) +{ + graphics_command_list->lpVtbl->ResolveSubresource(graphics_command_list, (ID3D12Resource*)dst_resource, dst_subresource, (ID3D12Resource*)src_resource, src_subresource, format); +} +static inline void D3D12IASetPrimitiveTopology(D3D12GraphicsCommandList graphics_command_list, D3D12_PRIMITIVE_TOPOLOGY primitive_topology) +{ + graphics_command_list->lpVtbl->IASetPrimitiveTopology(graphics_command_list, primitive_topology); +} +static inline void D3D12RSSetViewports(D3D12GraphicsCommandList graphics_command_list, UINT num_viewports, D3D12_VIEWPORT* viewports) +{ + graphics_command_list->lpVtbl->RSSetViewports(graphics_command_list, num_viewports, viewports); +} +static inline void D3D12RSSetScissorRects(D3D12GraphicsCommandList graphics_command_list, UINT num_rects, D3D12_RECT* rects) +{ + graphics_command_list->lpVtbl->RSSetScissorRects(graphics_command_list, num_rects, rects); +} +static inline void D3D12OMSetStencilRef(D3D12GraphicsCommandList graphics_command_list, UINT stencil_ref) +{ + graphics_command_list->lpVtbl->OMSetStencilRef(graphics_command_list, stencil_ref); +} +static inline void D3D12SetPipelineState(D3D12GraphicsCommandList graphics_command_list, D3D12PipelineState pipeline_state) +{ + graphics_command_list->lpVtbl->SetPipelineState(graphics_command_list, pipeline_state); +} +static inline void D3D12ResourceBarrier(D3D12GraphicsCommandList graphics_command_list, UINT num_barriers, D3D12_RESOURCE_BARRIER* barriers) +{ + graphics_command_list->lpVtbl->ResourceBarrier(graphics_command_list, num_barriers, barriers); +} +static inline void D3D12ExecuteBundle(D3D12GraphicsCommandList graphics_command_list, D3D12GraphicsCommandList command_list) +{ + graphics_command_list->lpVtbl->ExecuteBundle(graphics_command_list, command_list); +} +static inline void D3D12SetComputeRootSignature(D3D12GraphicsCommandList graphics_command_list, D3D12RootSignature root_signature) +{ + graphics_command_list->lpVtbl->SetComputeRootSignature(graphics_command_list, root_signature); +} +static inline void D3D12SetGraphicsRootSignature(D3D12GraphicsCommandList graphics_command_list, D3D12RootSignature root_signature) +{ + graphics_command_list->lpVtbl->SetGraphicsRootSignature(graphics_command_list, root_signature); +} +static inline void D3D12SetComputeRootDescriptorTable(D3D12GraphicsCommandList graphics_command_list, UINT root_parameter_index, D3D12_GPU_DESCRIPTOR_HANDLE base_descriptor) +{ + graphics_command_list->lpVtbl->SetComputeRootDescriptorTable(graphics_command_list, root_parameter_index, base_descriptor); +} +static inline void D3D12SetGraphicsRootDescriptorTable(D3D12GraphicsCommandList graphics_command_list, UINT root_parameter_index, D3D12_GPU_DESCRIPTOR_HANDLE base_descriptor) +{ + graphics_command_list->lpVtbl->SetGraphicsRootDescriptorTable(graphics_command_list, root_parameter_index, base_descriptor); +} +static inline void D3D12SetComputeRoot32BitConstant(D3D12GraphicsCommandList graphics_command_list, UINT root_parameter_index, UINT src_data, UINT dest_offset_in32_bit_values) +{ + graphics_command_list->lpVtbl->SetComputeRoot32BitConstant(graphics_command_list, root_parameter_index, src_data, dest_offset_in32_bit_values); +} +static inline void D3D12SetGraphicsRoot32BitConstant(D3D12GraphicsCommandList graphics_command_list, UINT root_parameter_index, UINT src_data, UINT dest_offset_in32_bit_values) +{ + graphics_command_list->lpVtbl->SetGraphicsRoot32BitConstant(graphics_command_list, root_parameter_index, src_data, dest_offset_in32_bit_values); +} +static inline void D3D12SetComputeRoot32BitConstants(D3D12GraphicsCommandList graphics_command_list, UINT root_parameter_index, UINT num32_bit_values_to_set, void* src_data, UINT dest_offset_in32_bit_values) +{ + graphics_command_list->lpVtbl->SetComputeRoot32BitConstants(graphics_command_list, root_parameter_index, num32_bit_values_to_set, src_data, dest_offset_in32_bit_values); +} +static inline void D3D12SetGraphicsRoot32BitConstants(D3D12GraphicsCommandList graphics_command_list, UINT root_parameter_index, UINT num32_bit_values_to_set, void* src_data, UINT dest_offset_in32_bit_values) +{ + graphics_command_list->lpVtbl->SetGraphicsRoot32BitConstants(graphics_command_list, root_parameter_index, num32_bit_values_to_set, src_data, dest_offset_in32_bit_values); +} +static inline void D3D12SetComputeRootConstantBufferView(D3D12GraphicsCommandList graphics_command_list, UINT root_parameter_index, D3D12_GPU_VIRTUAL_ADDRESS buffer_location) +{ + graphics_command_list->lpVtbl->SetComputeRootConstantBufferView(graphics_command_list, root_parameter_index, buffer_location); +} +static inline void D3D12SetGraphicsRootConstantBufferView(D3D12GraphicsCommandList graphics_command_list, UINT root_parameter_index, D3D12_GPU_VIRTUAL_ADDRESS buffer_location) +{ + graphics_command_list->lpVtbl->SetGraphicsRootConstantBufferView(graphics_command_list, root_parameter_index, buffer_location); +} +static inline void D3D12SetComputeRootShaderResourceView(D3D12GraphicsCommandList graphics_command_list, UINT root_parameter_index, D3D12_GPU_VIRTUAL_ADDRESS buffer_location) +{ + graphics_command_list->lpVtbl->SetComputeRootShaderResourceView(graphics_command_list, root_parameter_index, buffer_location); +} +static inline void D3D12SetGraphicsRootShaderResourceView(D3D12GraphicsCommandList graphics_command_list, UINT root_parameter_index, D3D12_GPU_VIRTUAL_ADDRESS buffer_location) +{ + graphics_command_list->lpVtbl->SetGraphicsRootShaderResourceView(graphics_command_list, root_parameter_index, buffer_location); +} +static inline void D3D12SetComputeRootUnorderedAccessView(D3D12GraphicsCommandList graphics_command_list, UINT root_parameter_index, D3D12_GPU_VIRTUAL_ADDRESS buffer_location) +{ + graphics_command_list->lpVtbl->SetComputeRootUnorderedAccessView(graphics_command_list, root_parameter_index, buffer_location); +} +static inline void D3D12SetGraphicsRootUnorderedAccessView(D3D12GraphicsCommandList graphics_command_list, UINT root_parameter_index, D3D12_GPU_VIRTUAL_ADDRESS buffer_location) +{ + graphics_command_list->lpVtbl->SetGraphicsRootUnorderedAccessView(graphics_command_list, root_parameter_index, buffer_location); +} +static inline void D3D12IASetIndexBuffer(D3D12GraphicsCommandList graphics_command_list, D3D12_INDEX_BUFFER_VIEW* view) +{ + graphics_command_list->lpVtbl->IASetIndexBuffer(graphics_command_list, view); +} +static inline void D3D12IASetVertexBuffers(D3D12GraphicsCommandList graphics_command_list, UINT start_slot, UINT num_views, D3D12_VERTEX_BUFFER_VIEW* views) +{ + graphics_command_list->lpVtbl->IASetVertexBuffers(graphics_command_list, start_slot, num_views, views); +} +static inline void D3D12SOSetTargets(D3D12GraphicsCommandList graphics_command_list, UINT start_slot, UINT num_views, D3D12_STREAM_OUTPUT_BUFFER_VIEW* views) +{ + graphics_command_list->lpVtbl->SOSetTargets(graphics_command_list, start_slot, num_views, views); +} +static inline void 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) +{ + graphics_command_list->lpVtbl->OMSetRenderTargets(graphics_command_list, num_render_target_descriptors, render_target_descriptors, r_ts_single_handle_to_descriptor_range, depth_stencil_descriptor); +} +static inline void 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) +{ + graphics_command_list->lpVtbl->ClearDepthStencilView(graphics_command_list, depth_stencil_view, clear_flags, depth, stencil, num_rects, rects); +} +static inline void D3D12DiscardResource(D3D12GraphicsCommandList graphics_command_list, void* resource, D3D12_DISCARD_REGION* region) +{ + graphics_command_list->lpVtbl->DiscardResource(graphics_command_list, (ID3D12Resource*)resource, region); +} +static inline void D3D12BeginQuery(D3D12GraphicsCommandList graphics_command_list, D3D12QueryHeap query_heap, D3D12_QUERY_TYPE type, UINT index) +{ + graphics_command_list->lpVtbl->BeginQuery(graphics_command_list, query_heap, type, index); +} +static inline void D3D12EndQuery(D3D12GraphicsCommandList graphics_command_list, D3D12QueryHeap query_heap, D3D12_QUERY_TYPE type, UINT index) +{ + graphics_command_list->lpVtbl->EndQuery(graphics_command_list, query_heap, type, index); +} +static inline void 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) +{ + graphics_command_list->lpVtbl->ResolveQueryData(graphics_command_list, query_heap, type, start_index, num_queries, (ID3D12Resource*)destination_buffer, aligned_destination_buffer_offset); +} +static inline void D3D12SetPredication(D3D12GraphicsCommandList graphics_command_list, void* buffer, UINT64 aligned_buffer_offset, D3D12_PREDICATION_OP operation) +{ + graphics_command_list->lpVtbl->SetPredication(graphics_command_list, (ID3D12Resource*)buffer, aligned_buffer_offset, operation); +} +static inline void D3D12SetGraphicsCommandListMarker(D3D12GraphicsCommandList graphics_command_list, UINT metadata, void* data, UINT size) +{ + graphics_command_list->lpVtbl->SetMarker(graphics_command_list, metadata, data, size); +} +static inline void D3D12BeginGraphicsCommandListEvent(D3D12GraphicsCommandList graphics_command_list, UINT metadata, void* data, UINT size) +{ + graphics_command_list->lpVtbl->BeginEvent(graphics_command_list, metadata, data, size); +} +static inline void D3D12EndGraphicsCommandListEvent(D3D12GraphicsCommandList graphics_command_list) +{ + graphics_command_list->lpVtbl->EndEvent(graphics_command_list); +} +static inline void 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) +{ + graphics_command_list->lpVtbl->ExecuteIndirect(graphics_command_list, command_signature, max_command_count, (ID3D12Resource*)argument_buffer, argument_buffer_offset, (ID3D12Resource*)count_buffer, count_buffer_offset); +} +static inline ULONG D3D12ReleaseCommandQueue(D3D12CommandQueue command_queue) +{ + return command_queue->lpVtbl->Release(command_queue); +} +static inline void 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) +{ + command_queue->lpVtbl->UpdateTileMappings(command_queue, (ID3D12Resource*)resource, num_resource_regions, resource_region_start_coordinates, resource_region_sizes, heap, num_ranges, range_flags, heap_range_start_offsets, range_tile_counts, flags); +} +static inline void 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) +{ + command_queue->lpVtbl->CopyTileMappings(command_queue, (ID3D12Resource*)dst_resource, dst_region_start_coordinate, (ID3D12Resource*)src_resource, src_region_start_coordinate, region_size, flags); +} +static inline void D3D12SetCommandQueueMarker(D3D12CommandQueue command_queue, UINT metadata, void* data, UINT size) +{ + command_queue->lpVtbl->SetMarker(command_queue, metadata, data, size); +} +static inline void D3D12BeginCommandQueueEvent(D3D12CommandQueue command_queue, UINT metadata, void* data, UINT size) +{ + command_queue->lpVtbl->BeginEvent(command_queue, metadata, data, size); +} +static inline void D3D12EndCommandQueueEvent(D3D12CommandQueue command_queue) +{ + command_queue->lpVtbl->EndEvent(command_queue); +} +static inline HRESULT D3D12SignalCommandQueue(D3D12CommandQueue command_queue, D3D12Fence fence, UINT64 value) +{ + return command_queue->lpVtbl->Signal(command_queue, fence, value); +} +static inline HRESULT D3D12Wait(D3D12CommandQueue command_queue, D3D12Fence fence, UINT64 value) +{ + return command_queue->lpVtbl->Wait(command_queue, fence, value); +} +static inline HRESULT D3D12GetTimestampFrequency(D3D12CommandQueue command_queue, UINT64* frequency) +{ + return command_queue->lpVtbl->GetTimestampFrequency(command_queue, frequency); +} +static inline HRESULT D3D12GetClockCalibration(D3D12CommandQueue command_queue, UINT64* gpu_timestamp, UINT64* cpu_timestamp) +{ + return command_queue->lpVtbl->GetClockCalibration(command_queue, gpu_timestamp, cpu_timestamp); +} +static inline ULONG D3D12ReleaseDevice(D3D12Device device) +{ + return device->lpVtbl->Release(device); +} +static inline UINT D3D12GetNodeCount(D3D12Device device) +{ + return device->lpVtbl->GetNodeCount(device); +} +static inline HRESULT D3D12CreateCommandQueue(D3D12Device device, D3D12_COMMAND_QUEUE_DESC* desc, ID3D12CommandQueue** out) +{ + return device->lpVtbl->CreateCommandQueue(device, desc, __uuidof(ID3D12CommandQueue), (void**)out); +} +static inline HRESULT D3D12CreateCommandAllocator(D3D12Device device, D3D12_COMMAND_LIST_TYPE type, ID3D12CommandAllocator** out) +{ + return device->lpVtbl->CreateCommandAllocator(device, type, __uuidof(ID3D12CommandAllocator), (void**)out); +} +static inline HRESULT D3D12CreateGraphicsPipelineState(D3D12Device device, D3D12_GRAPHICS_PIPELINE_STATE_DESC* desc, ID3D12PipelineState** out) +{ + return device->lpVtbl->CreateGraphicsPipelineState(device, desc, __uuidof(ID3D12PipelineState), (void**)out); +} +static inline HRESULT D3D12CreateComputePipelineState(D3D12Device device, D3D12_COMPUTE_PIPELINE_STATE_DESC* desc, ID3D12PipelineState** out) +{ + return device->lpVtbl->CreateComputePipelineState(device, desc, __uuidof(ID3D12PipelineState), (void**)out); +} +static inline HRESULT D3D12CreateCommandList(D3D12Device device, UINT node_mask, D3D12_COMMAND_LIST_TYPE type, D3D12CommandAllocator command_allocator, D3D12PipelineState initial_state, ID3D12CommandList** out) +{ + return device->lpVtbl->CreateCommandList(device, node_mask, type, command_allocator, initial_state, __uuidof(ID3D12CommandList), (void**)out); +} +static inline HRESULT D3D12CheckFeatureSupport(D3D12Device device, D3D12_FEATURE feature, void* feature_support_data, UINT feature_support_data_size) +{ + return device->lpVtbl->CheckFeatureSupport(device, feature, feature_support_data, feature_support_data_size); +} +static inline HRESULT D3D12CreateDescriptorHeap(D3D12Device device, D3D12_DESCRIPTOR_HEAP_DESC* descriptor_heap_desc, D3D12DescriptorHeap* out) +{ + return device->lpVtbl->CreateDescriptorHeap(device, descriptor_heap_desc, __uuidof(ID3D12DescriptorHeap), (void**)out); +} +static inline UINT D3D12GetDescriptorHandleIncrementSize(D3D12Device device, D3D12_DESCRIPTOR_HEAP_TYPE descriptor_heap_type) +{ + return device->lpVtbl->GetDescriptorHandleIncrementSize(device, descriptor_heap_type); +} +static inline HRESULT D3D12CreateRootSignature(D3D12Device device, UINT node_mask, void* blob_with_root_signature, SIZE_T blob_length_in_bytes, ID3D12RootSignature** out) +{ + return device->lpVtbl->CreateRootSignature(device, node_mask, blob_with_root_signature, blob_length_in_bytes, __uuidof(ID3D12RootSignature), (void**)out); +} +static inline void D3D12CreateConstantBufferView(D3D12Device device, D3D12_CONSTANT_BUFFER_VIEW_DESC* desc, D3D12_CPU_DESCRIPTOR_HANDLE dest_descriptor) +{ + device->lpVtbl->CreateConstantBufferView(device, desc, dest_descriptor); +} +static inline void D3D12CreateShaderResourceView(D3D12Device device, D3D12Resource resource, D3D12_SHADER_RESOURCE_VIEW_DESC* desc, D3D12_CPU_DESCRIPTOR_HANDLE dest_descriptor) +{ + device->lpVtbl->CreateShaderResourceView(device, resource, desc, dest_descriptor); +} +static inline void D3D12CreateUnorderedAccessView(D3D12Device device, void* resource, void* counter_resource, D3D12_UNORDERED_ACCESS_VIEW_DESC* desc, D3D12_CPU_DESCRIPTOR_HANDLE dest_descriptor) +{ + device->lpVtbl->CreateUnorderedAccessView(device, (ID3D12Resource*)resource, (ID3D12Resource*)counter_resource, desc, dest_descriptor); +} +static inline void D3D12CreateRenderTargetView(D3D12Device device, void* resource, D3D12_RENDER_TARGET_VIEW_DESC* desc, D3D12_CPU_DESCRIPTOR_HANDLE dest_descriptor) +{ + device->lpVtbl->CreateRenderTargetView(device, (ID3D12Resource*)resource, desc, dest_descriptor); +} +static inline void D3D12CreateDepthStencilView(D3D12Device device, void* resource, D3D12_DEPTH_STENCIL_VIEW_DESC* desc, D3D12_CPU_DESCRIPTOR_HANDLE dest_descriptor) +{ + device->lpVtbl->CreateDepthStencilView(device, (ID3D12Resource*)resource, desc, dest_descriptor); +} +static inline void D3D12CreateSampler(D3D12Device device, D3D12_SAMPLER_DESC* desc, D3D12_CPU_DESCRIPTOR_HANDLE dest_descriptor) +{ + device->lpVtbl->CreateSampler(device, desc, dest_descriptor); +} +static inline void 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) +{ + device->lpVtbl->CopyDescriptors(device, num_dest_descriptor_ranges, dest_descriptor_range_starts, dest_descriptor_range_sizes, num_src_descriptor_ranges, src_descriptor_range_starts, src_descriptor_range_sizes, descriptor_heaps_type); +} +static inline void 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) +{ + device->lpVtbl->CopyDescriptorsSimple(device, num_descriptors, dest_descriptor_range_start, src_descriptor_range_start, descriptor_heaps_type); +} +static inline D3D12_RESOURCE_ALLOCATION_INFO D3D12GetResourceAllocationInfo(D3D12Device device, UINT visible_mask, UINT num_resource_descs, D3D12_RESOURCE_DESC* resource_descs) +{ + return device->lpVtbl->GetResourceAllocationInfo(device, visible_mask, num_resource_descs, resource_descs); +} +static inline D3D12_HEAP_PROPERTIES D3D12GetCustomHeapProperties(D3D12Device device, UINT node_mask, D3D12_HEAP_TYPE heap_type) +{ + return device->lpVtbl->GetCustomHeapProperties(device, node_mask, heap_type); +} +static inline HRESULT 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) +{ + return device->lpVtbl->CreateCommittedResource(device, heap_properties, heap_flags, desc, initial_resource_state, optimized_clear_value, __uuidof(ID3D12Resource), (void**)out); +} +static inline HRESULT D3D12CreateHeap(D3D12Device device, D3D12_HEAP_DESC* desc, ID3D12Heap** out) +{ + return device->lpVtbl->CreateHeap(device, desc, __uuidof(ID3D12Heap), (void**)out); +} +static inline HRESULT 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) +{ + return device->lpVtbl->CreatePlacedResource(device, heap, heap_offset, desc, initial_state, optimized_clear_value, __uuidof(ID3D12Resource), (void**)out); +} +static inline HRESULT D3D12CreateReservedResource(D3D12Device device, D3D12_RESOURCE_DESC* desc, D3D12_RESOURCE_STATES initial_state, D3D12_CLEAR_VALUE* optimized_clear_value, ID3D12Resource** out) +{ + return device->lpVtbl->CreateReservedResource(device, desc, initial_state, optimized_clear_value, __uuidof(ID3D12Resource), (void**)out); +} +static inline HRESULT D3D12CreateFence(D3D12Device device, UINT64 initial_value, D3D12_FENCE_FLAGS flags, ID3D12Fence** out) +{ + return device->lpVtbl->CreateFence(device, initial_value, flags, __uuidof(ID3D12Fence), (void**)out); +} +static inline HRESULT D3D12GetDeviceRemovedReason(D3D12Device device) +{ + return device->lpVtbl->GetDeviceRemovedReason(device); +} +static inline void 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) +{ + device->lpVtbl->GetCopyableFootprints(device, resource_desc, first_subresource, num_subresources, base_offset, layouts, num_rows, row_size_in_bytes, total_bytes); +} +static inline HRESULT D3D12CreateQueryHeap(D3D12Device device, D3D12_QUERY_HEAP_DESC* desc, ID3D12Heap** out) +{ + return device->lpVtbl->CreateQueryHeap(device, desc, __uuidof(ID3D12Heap), (void**)out); +} +static inline HRESULT D3D12SetStablePowerState(D3D12Device device, BOOL enable) +{ + return device->lpVtbl->SetStablePowerState(device, enable); +} +static inline HRESULT D3D12CreateCommandSignature(D3D12Device device, D3D12_COMMAND_SIGNATURE_DESC* desc, D3D12RootSignature root_signature, ID3D12CommandSignature** out) +{ + return device->lpVtbl->CreateCommandSignature(device, desc, root_signature, __uuidof(ID3D12CommandSignature), (void**)out); +} +static inline void 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) +{ + device->lpVtbl->GetResourceTiling(device, (ID3D12Resource*)tiled_resource, num_tiles_for_entire_resource, packed_mip_desc, standard_tile_shape_for_non_packed_mips, num_subresource_tilings, first_subresource_tiling_to_get, subresource_tilings_for_non_packed_mips); +} +static inline LUID D3D12GetAdapterLuid(D3D12Device device) +{ + return device->lpVtbl->GetAdapterLuid(device); +} +static inline ULONG D3D12ReleasePipelineLibrary(D3D12PipelineLibrary pipeline_library) +{ + return pipeline_library->lpVtbl->Release(pipeline_library); +} +static inline HRESULT D3D12StorePipeline(D3D12PipelineLibrary pipeline_library, LPCWSTR name, D3D12PipelineState pipeline) +{ + return pipeline_library->lpVtbl->StorePipeline(pipeline_library, name, pipeline); +} +static inline HRESULT D3D12LoadGraphicsPipeline(D3D12PipelineLibrary pipeline_library, LPCWSTR name, D3D12_GRAPHICS_PIPELINE_STATE_DESC* desc, ID3D12PipelineState** out) +{ + return pipeline_library->lpVtbl->LoadGraphicsPipeline(pipeline_library, name, desc, __uuidof(ID3D12PipelineState), (void**)out); +} +static inline HRESULT D3D12LoadComputePipeline(D3D12PipelineLibrary pipeline_library, LPCWSTR name, D3D12_COMPUTE_PIPELINE_STATE_DESC* desc, ID3D12PipelineState** out) +{ + return pipeline_library->lpVtbl->LoadComputePipeline(pipeline_library, name, desc, __uuidof(ID3D12PipelineState), (void**)out); +} +static inline SIZE_T D3D12GetSerializedSize(D3D12PipelineLibrary pipeline_library) +{ + return pipeline_library->lpVtbl->GetSerializedSize(pipeline_library); +} +static inline HRESULT D3D12Serialize(D3D12PipelineLibrary pipeline_library, void* data, SIZE_T data_size_in_bytes) +{ + return pipeline_library->lpVtbl->Serialize(pipeline_library, data, data_size_in_bytes); +} +static inline ULONG D3D12ReleaseDebug(D3D12Debug debug) +{ + return debug->lpVtbl->Release(debug); +} +static inline void D3D12EnableDebugLayer(D3D12Debug debug) +{ + debug->lpVtbl->EnableDebugLayer(debug); +} +static inline ULONG D3D12ReleaseDebugDevice(D3D12DebugDevice debug_device) +{ + return debug_device->lpVtbl->Release(debug_device); +} +static inline HRESULT D3D12SetDebugDeviceFeatureMask(D3D12DebugDevice debug_device, D3D12_DEBUG_FEATURE mask) +{ + return debug_device->lpVtbl->SetFeatureMask(debug_device, mask); +} +static inline D3D12_DEBUG_FEATURE D3D12GetDebugDeviceFeatureMask(D3D12DebugDevice debug_device) +{ + return debug_device->lpVtbl->GetFeatureMask(debug_device); +} +static inline HRESULT D3D12ReportLiveDeviceObjects(D3D12DebugDevice debug_device, D3D12_RLDO_FLAGS flags) +{ + return debug_device->lpVtbl->ReportLiveDeviceObjects(debug_device, flags); +} +static inline ULONG D3D12ReleaseDebugCommandQueue(D3D12DebugCommandQueue debug_command_queue) +{ + return debug_command_queue->lpVtbl->Release(debug_command_queue); +} +static inline BOOL D3D12AssertDebugCommandQueueResourceState(D3D12DebugCommandQueue debug_command_queue, void* resource, UINT subresource, UINT state) +{ + return debug_command_queue->lpVtbl->AssertResourceState(debug_command_queue, (ID3D12Resource*)resource, subresource, state); +} +static inline ULONG D3D12ReleaseDebugCommandList(D3D12DebugCommandList debug_command_list) +{ + return debug_command_list->lpVtbl->Release(debug_command_list); +} +static inline BOOL D3D12AssertDebugCommandListResourceState(D3D12DebugCommandList debug_command_list, void* resource, UINT subresource, UINT state) +{ + return debug_command_list->lpVtbl->AssertResourceState(debug_command_list, (ID3D12Resource*)resource, subresource, state); +} +static inline HRESULT D3D12SetDebugCommandListFeatureMask(D3D12DebugCommandList debug_command_list, D3D12_DEBUG_FEATURE mask) +{ + return debug_command_list->lpVtbl->SetFeatureMask(debug_command_list, mask); +} +static inline D3D12_DEBUG_FEATURE D3D12GetDebugCommandListFeatureMask(D3D12DebugCommandList debug_command_list) +{ + return debug_command_list->lpVtbl->GetFeatureMask(debug_command_list); +} +static inline ULONG D3D12ReleaseInfoQueue(D3D12InfoQueue info_queue) +{ + return info_queue->lpVtbl->Release(info_queue); +} +static inline HRESULT D3D12SetMessageCountLimit(D3D12InfoQueue info_queue, UINT64 message_count_limit) +{ + return info_queue->lpVtbl->SetMessageCountLimit(info_queue, message_count_limit); +} +static inline void D3D12ClearStoredMessages(D3D12InfoQueue info_queue) +{ + info_queue->lpVtbl->ClearStoredMessages(info_queue); +} +static inline HRESULT D3D12GetMessageA(D3D12InfoQueue info_queue, UINT64 message_index, D3D12_MESSAGE* message, SIZE_T* message_byte_length) +{ + return info_queue->lpVtbl->GetMessageA(info_queue, message_index, message, message_byte_length); +} +static inline UINT64 D3D12GetNumMessagesAllowedByStorageFilter(D3D12InfoQueue info_queue) +{ + return info_queue->lpVtbl->GetNumMessagesAllowedByStorageFilter(info_queue); +} +static inline UINT64 D3D12GetNumMessagesDeniedByStorageFilter(D3D12InfoQueue info_queue) +{ + return info_queue->lpVtbl->GetNumMessagesDeniedByStorageFilter(info_queue); +} +static inline UINT64 D3D12GetNumStoredMessages(D3D12InfoQueue info_queue) +{ + return info_queue->lpVtbl->GetNumStoredMessages(info_queue); +} +static inline UINT64 D3D12GetNumStoredMessagesAllowedByRetrievalFilter(D3D12InfoQueue info_queue) +{ + return info_queue->lpVtbl->GetNumStoredMessagesAllowedByRetrievalFilter(info_queue); +} +static inline UINT64 D3D12GetNumMessagesDiscardedByMessageCountLimit(D3D12InfoQueue info_queue) +{ + return info_queue->lpVtbl->GetNumMessagesDiscardedByMessageCountLimit(info_queue); +} +static inline UINT64 D3D12GetMessageCountLimit(D3D12InfoQueue info_queue) +{ + return info_queue->lpVtbl->GetMessageCountLimit(info_queue); +} +static inline HRESULT D3D12AddStorageFilterEntries(D3D12InfoQueue info_queue, D3D12_INFO_QUEUE_FILTER* filter) +{ + return info_queue->lpVtbl->AddStorageFilterEntries(info_queue, filter); +} +static inline HRESULT D3D12GetStorageFilter(D3D12InfoQueue info_queue, D3D12_INFO_QUEUE_FILTER* filter, SIZE_T* filter_byte_length) +{ + return info_queue->lpVtbl->GetStorageFilter(info_queue, filter, filter_byte_length); +} +static inline void D3D12ClearStorageFilter(D3D12InfoQueue info_queue) +{ + info_queue->lpVtbl->ClearStorageFilter(info_queue); +} +static inline HRESULT D3D12PushEmptyStorageFilter(D3D12InfoQueue info_queue) +{ + return info_queue->lpVtbl->PushEmptyStorageFilter(info_queue); +} +static inline HRESULT D3D12PushCopyOfStorageFilter(D3D12InfoQueue info_queue) +{ + return info_queue->lpVtbl->PushCopyOfStorageFilter(info_queue); +} +static inline HRESULT D3D12PushStorageFilter(D3D12InfoQueue info_queue, D3D12_INFO_QUEUE_FILTER* filter) +{ + return info_queue->lpVtbl->PushStorageFilter(info_queue, filter); +} +static inline void D3D12PopStorageFilter(D3D12InfoQueue info_queue) +{ + info_queue->lpVtbl->PopStorageFilter(info_queue); +} +static inline UINT D3D12GetStorageFilterStackSize(D3D12InfoQueue info_queue) +{ + return info_queue->lpVtbl->GetStorageFilterStackSize(info_queue); +} +static inline HRESULT D3D12AddRetrievalFilterEntries(D3D12InfoQueue info_queue, D3D12_INFO_QUEUE_FILTER* filter) +{ + return info_queue->lpVtbl->AddRetrievalFilterEntries(info_queue, filter); +} +static inline HRESULT D3D12GetRetrievalFilter(D3D12InfoQueue info_queue, D3D12_INFO_QUEUE_FILTER* filter, SIZE_T* filter_byte_length) +{ + return info_queue->lpVtbl->GetRetrievalFilter(info_queue, filter, filter_byte_length); +} +static inline void D3D12ClearRetrievalFilter(D3D12InfoQueue info_queue) +{ + info_queue->lpVtbl->ClearRetrievalFilter(info_queue); +} +static inline HRESULT D3D12PushEmptyRetrievalFilter(D3D12InfoQueue info_queue) +{ + return info_queue->lpVtbl->PushEmptyRetrievalFilter(info_queue); +} +static inline HRESULT D3D12PushCopyOfRetrievalFilter(D3D12InfoQueue info_queue) +{ + return info_queue->lpVtbl->PushCopyOfRetrievalFilter(info_queue); +} +static inline HRESULT D3D12PushRetrievalFilter(D3D12InfoQueue info_queue, D3D12_INFO_QUEUE_FILTER* filter) +{ + return info_queue->lpVtbl->PushRetrievalFilter(info_queue, filter); +} +static inline void D3D12PopRetrievalFilter(D3D12InfoQueue info_queue) +{ + info_queue->lpVtbl->PopRetrievalFilter(info_queue); +} +static inline UINT D3D12GetRetrievalFilterStackSize(D3D12InfoQueue info_queue) +{ + return info_queue->lpVtbl->GetRetrievalFilterStackSize(info_queue); +} +static inline HRESULT D3D12AddMessage(D3D12InfoQueue info_queue, D3D12_MESSAGE_CATEGORY category, D3D12_MESSAGE_SEVERITY severity, D3D12_MESSAGE_ID i_d, LPCSTR description) +{ + return info_queue->lpVtbl->AddMessage(info_queue, category, severity, i_d, description); +} +static inline HRESULT D3D12AddApplicationMessage(D3D12InfoQueue info_queue, D3D12_MESSAGE_SEVERITY severity, LPCSTR description) +{ + return info_queue->lpVtbl->AddApplicationMessage(info_queue, severity, description); +} +static inline HRESULT D3D12SetBreakOnCategory(D3D12InfoQueue info_queue, D3D12_MESSAGE_CATEGORY category, BOOL b_enable) +{ + return info_queue->lpVtbl->SetBreakOnCategory(info_queue, category, b_enable); +} +static inline HRESULT D3D12SetBreakOnSeverity(D3D12InfoQueue info_queue, D3D12_MESSAGE_SEVERITY severity, BOOL b_enable) +{ + return info_queue->lpVtbl->SetBreakOnSeverity(info_queue, severity, b_enable); +} +static inline HRESULT D3D12SetBreakOnID(D3D12InfoQueue info_queue, D3D12_MESSAGE_ID i_d, BOOL b_enable) +{ + return info_queue->lpVtbl->SetBreakOnID(info_queue, i_d, b_enable); +} +static inline BOOL D3D12GetBreakOnCategory(D3D12InfoQueue info_queue, D3D12_MESSAGE_CATEGORY category) +{ + return info_queue->lpVtbl->GetBreakOnCategory(info_queue, category); +} +static inline BOOL D3D12GetBreakOnSeverity(D3D12InfoQueue info_queue, D3D12_MESSAGE_SEVERITY severity) +{ + return info_queue->lpVtbl->GetBreakOnSeverity(info_queue, severity); +} +static inline BOOL D3D12GetBreakOnID(D3D12InfoQueue info_queue, D3D12_MESSAGE_ID i_d) +{ + return info_queue->lpVtbl->GetBreakOnID(info_queue, i_d); +} +static inline void D3D12SetMuteDebugOutput(D3D12InfoQueue info_queue, BOOL b_mute) +{ + info_queue->lpVtbl->SetMuteDebugOutput(info_queue, b_mute); +} +static inline BOOL D3D12GetMuteDebugOutput(D3D12InfoQueue info_queue) +{ + return info_queue->lpVtbl->GetMuteDebugOutput(info_queue); +} + +/* end of auto-generated */ + +static inline HRESULT D3D12GetDebugInterface_(D3D12Debug* out ) +{ + return D3D12GetDebugInterface(__uuidof(ID3D12Debug), (void**)out); +} + +static inline HRESULT D3D12CreateDevice_(DXGIAdapter adapter, D3D_FEATURE_LEVEL MinimumFeatureLevel, D3D12Device* out) +{ + return D3D12CreateDevice((IUnknown*)adapter, MinimumFeatureLevel, __uuidof(ID3D12Device), (void**)out); +} + +static inline HRESULT D3D12CreateGraphicsCommandList(D3D12Device device, UINT node_mask, D3D12_COMMAND_LIST_TYPE type, D3D12CommandAllocator command_allocator, D3D12PipelineState initial_state, D3D12GraphicsCommandList* out) +{ + return device->lpVtbl->CreateCommandList(device, node_mask, type, command_allocator, initial_state, __uuidof(ID3D12GraphicsCommandList), (void**)out); +} + +static inline void D3D12ClearRenderTargetView(D3D12GraphicsCommandList command_list, D3D12_CPU_DESCRIPTOR_HANDLE render_target_view, const FLOAT colorRGBA[4], UINT num_rects, const D3D12_RECT *rects) +{ + command_list->lpVtbl->ClearRenderTargetView(command_list, render_target_view, colorRGBA, num_rects, rects); +} + +static inline void D3D12ExecuteCommandLists(D3D12CommandQueue command_queue, UINT num_command_lists, const D3D12CommandList* command_lists) +{ + command_queue->lpVtbl->ExecuteCommandLists(command_queue, num_command_lists, command_lists); +} +static inline void D3D12ExecuteGraphicsCommandLists(D3D12CommandQueue command_queue, UINT num_command_lists, const D3D12GraphicsCommandList* command_lists) +{ + command_queue->lpVtbl->ExecuteCommandLists(command_queue, num_command_lists, (ID3D12CommandList*const *)command_lists); +} + +static inline HRESULT DXGIGetSwapChainBuffer(DXGISwapChain swapchain, UINT buffer, D3D12Resource* surface) +{ + return swapchain->lpVtbl->GetBuffer(swapchain, buffer, __uuidof(ID3D12Resource), (void **)surface); +} +static inline void D3D12SetDescriptorHeaps(D3D12GraphicsCommandList command_list, UINT num_descriptor_heaps, const D3D12DescriptorHeap* descriptor_heaps) +{ + command_list->lpVtbl->SetDescriptorHeaps(command_list, num_descriptor_heaps, descriptor_heaps); +} +#if 0 /* function prototype is wrong ... */ +static inline D3D12_CPU_DESCRIPTOR_HANDLE D3D12GetCPUDescriptorHandleForHeapStart(D3D12DescriptorHeap descriptor_heap) +{ + return descriptor_heap->lpVtbl->GetCPUDescriptorHandleForHeapStart(descriptor_heap); +} +static inline D3D12_GPU_DESCRIPTOR_HANDLE D3D12GetGPUDescriptorHandleForHeapStart(D3D12DescriptorHeap descriptor_heap) +{ + return descriptor_heap->lpVtbl->GetGPUDescriptorHandleForHeapStart(descriptor_heap); +} +#else +static inline D3D12_CPU_DESCRIPTOR_HANDLE D3D12GetCPUDescriptorHandleForHeapStart(D3D12DescriptorHeap descriptor_heap) +{ + D3D12_CPU_DESCRIPTOR_HANDLE out; + ((void (STDMETHODCALLTYPE *)(ID3D12DescriptorHeap*, D3D12_CPU_DESCRIPTOR_HANDLE*)) + descriptor_heap->lpVtbl->GetCPUDescriptorHandleForHeapStart)(descriptor_heap, &out); + return out; +} +static inline D3D12_GPU_DESCRIPTOR_HANDLE D3D12GetGPUDescriptorHandleForHeapStart(D3D12DescriptorHeap descriptor_heap) +{ + D3D12_GPU_DESCRIPTOR_HANDLE out; + ((void (STDMETHODCALLTYPE *)(ID3D12DescriptorHeap*, D3D12_GPU_DESCRIPTOR_HANDLE*)) + descriptor_heap->lpVtbl->GetGPUDescriptorHandleForHeapStart)(descriptor_heap, &out); + return out; +} +#endif + +/* internal */ + + + +typedef struct d3d12_vertex_t +{ + float position[2]; + float texcoord[2]; + float color[4]; +} d3d12_vertex_t; + +typedef struct +{ + D3D12DescriptorHeap handle; /* descriptor pool */ + D3D12_DESCRIPTOR_HEAP_DESC desc; + D3D12_CPU_DESCRIPTOR_HANDLE cpu; /* descriptor */ + D3D12_GPU_DESCRIPTOR_HANDLE gpu; /* descriptor */ + UINT stride; + UINT count; +}d3d12_descriptor_heap_t; + +typedef struct +{ + D3D12Resource handle; + D3D12Resource upload_buffer; + D3D12_RESOURCE_DESC desc; + D3D12_GPU_DESCRIPTOR_HANDLE gpu_descriptor; + D3D12_PLACED_SUBRESOURCE_FOOTPRINT layout; + UINT num_rows; + UINT64 row_size_in_bytes; + UINT64 total_bytes; + bool dirty; +}d3d12_texture_t; +typedef struct +{ + unsigned cur_mon_id; + DXGIFactory factory; + DXGIAdapter adapter; + D3D12Device device; + + struct + { + D3D12CommandQueue handle; + D3D12CommandAllocator allocator; + D3D12GraphicsCommandList cmd; + D3D12Fence fence; + HANDLE fenceEvent; + UINT64 fenceValue; + }queue; + + struct + { + D3D12PipelineState handle; + D3D12RootSignature rootSignature; /* descriptor layout */ + d3d12_descriptor_heap_t srv_heap; /* ShaderResouceView descritor heap */ + d3d12_descriptor_heap_t rtv_heap; /* RenderTargetView descritor heap */ + }pipe; + + struct + { + DXGISwapChain handle; + D3D12Resource renderTargets[2]; + D3D12_CPU_DESCRIPTOR_HANDLE desc_handles[2]; + D3D12_VIEWPORT viewport; + D3D12_RECT scissorRect; + float clearcolor[4]; + int frame_index; + bool vsync; + }chain; + + struct + { + D3D12Resource vbo; + D3D12_VERTEX_BUFFER_VIEW vbo_view; + d3d12_texture_t tex; + bool rgb32; + }frame; + + struct + { + D3D12Resource vbo; + D3D12_VERTEX_BUFFER_VIEW vbo_view; + d3d12_texture_t tex; + + float alpha; + bool enabled; + bool fullscreen; + }menu; + +#ifdef DEBUG + D3D12Debug debugController; +#endif +} d3d12_video_t; + + +bool d3d12_init_context(d3d12_video_t* d3d12); +bool d3d12_init_descriptors(d3d12_video_t* d3d12); +bool d3d12_init_pipeline(d3d12_video_t* d3d12); +bool d3d12_init_swapchain(d3d12_video_t* d3d12, int width, int height, HWND hwnd); +bool d3d12_init_queue(d3d12_video_t *d3d12); + +void d3d12_create_vertex_buffer(D3D12Device device, D3D12_VERTEX_BUFFER_VIEW* view, D3D12Resource* vbo); +void d3d12_create_texture(D3D12Device device, d3d12_descriptor_heap_t* heap, int heap_index, d3d12_texture_t *tex); +void d3d12_upload_texture(D3D12GraphicsCommandList cmd, d3d12_texture_t* texture); + +static inline d3d12_transition(D3D12GraphicsCommandList cmd, D3D12Resource resource, + D3D12_RESOURCE_STATES state_before, D3D12_RESOURCE_STATES state_after) +{ + D3D12_RESOURCE_BARRIER barrier = + { + .Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION, + .Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE, + .Transition.pResource = resource, + .Transition.StateBefore = state_before, + .Transition.StateAfter = state_after, + .Transition.Subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES, + }; + D3D12ResourceBarrier(cmd, 1, &barrier); +} diff --git a/gfx/common/d3dcompiler_common.c b/gfx/common/d3dcompiler_common.c new file mode 100644 index 0000000000..cf7411130a --- /dev/null +++ b/gfx/common/d3dcompiler_common.c @@ -0,0 +1,88 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2014-2018 - Ali Bouhlel + * + * RetroArch is free software: you can redistribute it and/or modify it under the terms + * of the GNU General Public License as published by the Free Software Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with RetroArch. + * If not, see . + */ + +#include +#include + +#include "gfx/common/d3dcompiler_common.h" +#include "verbosity.h" + +HRESULT WINAPI +D3DCompile(LPCVOID pSrcData, SIZE_T SrcDataSize, LPCSTR pSourceName, + CONST D3D_SHADER_MACRO *pDefines, ID3DInclude *pInclude, LPCSTR pEntrypoint, + LPCSTR pTarget, UINT Flags1, UINT Flags2, ID3DBlob **ppCode, ID3DBlob **ppErrorMsgs) +{ + static dylib_t d3dcompiler_dll; + static const char *dll_list[] = + { + "D3DCompiler_47.dll", + "D3DCompiler_46.dll", + "D3DCompiler_45.dll", + "D3DCompiler_44.dll", + "D3DCompiler_43.dll", + "D3DCompiler_42.dll", + "D3DCompiler_41.dll", + "D3DCompiler_40.dll", + "D3DCompiler_39.dll", + "D3DCompiler_38.dll", + "D3DCompiler_37.dll", + "D3DCompiler_36.dll", + "D3DCompiler_35.dll", + "D3DCompiler_34.dll", + "D3DCompiler_33.dll", + NULL, + }; + const char **dll_name = dll_list; + + while (!d3dcompiler_dll && *dll_name) + d3dcompiler_dll = dylib_load(*dll_name++); + + if (d3dcompiler_dll) + { + static pD3DCompile fp; + + if (!fp) + fp = (pD3DCompile)dylib_proc(d3dcompiler_dll, "D3DCompile"); + + if (fp) + return fp(pSrcData, SrcDataSize, pSourceName, pDefines, pInclude, pEntrypoint, pTarget, Flags1, + Flags2, ppCode, ppErrorMsgs); + } + + return TYPE_E_CANTLOADLIBRARY; +} + + +bool d3d_compile(const char *src, size_t size, LPCSTR entrypoint, LPCSTR target, D3DBlob *out) +{ + D3DBlob error_msg; + UINT compileflags = 0; + +#ifdef DEBUG + compileflags |= D3DCOMPILE_DEBUG | D3DCOMPILE_SKIP_OPTIMIZATION; +#endif + + if(FAILED(D3DCompile(src, size, NULL, NULL, NULL, entrypoint, target, compileflags, 0, out, &error_msg))) + return false; + + if (error_msg) + { + RARCH_ERR("D3DCompile failed :\n%s\n", (const char *)D3DGetBufferPointer(error_msg)); + Release(error_msg); + return false; + } + + return true; +} diff --git a/gfx/common/d3dcompiler_common.h b/gfx/common/d3dcompiler_common.h new file mode 100644 index 0000000000..ba9560d280 --- /dev/null +++ b/gfx/common/d3dcompiler_common.h @@ -0,0 +1,88 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2014-2018 - Ali Bouhlel + * + * RetroArch is free software: you can redistribute it and/or modify it under the terms + * of the GNU General Public License as published by the Free Software Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with RetroArch. + * If not, see . + */ + +#pragma once + +#ifdef __MINGW32__ +#define __REQUIRED_RPCNDR_H_VERSION__ 475 +#define _In_ +#define _In_opt_ +#define _Null_ + +#define _Out_writes_bytes_opt_(s) +#endif + +#define CINTERFACE +#include +#include + +#ifndef countof +#define countof(a) (sizeof(a)/ sizeof(*a)) +#endif + +#ifndef __uuidof +#define __uuidof(type) &IID_##type +#endif + +#ifndef COM_RELEASE_DECLARED +#define COM_RELEASE_DECLARED +#if defined(__cplusplus) && !defined(CINTERFACE) +static inline ULONG Release(IUnknown* object) +{ + return object->Release(); +} +#else +static inline ULONG Release(void* object) +{ + return ((IUnknown*)object)->lpVtbl->Release(object); +} +#endif +#endif + +/* auto-generated */ + +typedef ID3DBlob* D3DBlob; +typedef ID3DDestructionNotifier* D3DDestructionNotifier; + + +static inline ULONG D3DReleaseBlob(D3DBlob blob) +{ + return blob->lpVtbl->Release(blob); +} +static inline LPVOID D3DGetBufferPointer(D3DBlob blob) +{ + return blob->lpVtbl->GetBufferPointer(blob); +} +static inline SIZE_T D3DGetBufferSize(D3DBlob blob) +{ + return blob->lpVtbl->GetBufferSize(blob); +} +static inline ULONG D3DReleaseDestructionNotifier(D3DDestructionNotifier destruction_notifier) +{ + return destruction_notifier->lpVtbl->Release(destruction_notifier); +} +static inline HRESULT D3DRegisterDestructionCallback(D3DDestructionNotifier destruction_notifier, PFN_DESTRUCTION_CALLBACK callback_fn, void* data, UINT* callback_id) +{ + return destruction_notifier->lpVtbl->RegisterDestructionCallback(destruction_notifier, callback_fn, data, callback_id); +} +static inline HRESULT D3DUnregisterDestructionCallback(D3DDestructionNotifier destruction_notifier, UINT callback_id) +{ + return destruction_notifier->lpVtbl->UnregisterDestructionCallback(destruction_notifier, callback_id); +} + +/* end of auto-generated */ + + +bool d3d_compile(const char* src, size_t size, LPCSTR entrypoint, LPCSTR target, D3DBlob* out); diff --git a/gfx/common/dxgi_common.c b/gfx/common/dxgi_common.c new file mode 100644 index 0000000000..0092dd5f52 --- /dev/null +++ b/gfx/common/dxgi_common.c @@ -0,0 +1,39 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2014-2018 - Ali Bouhlel + * + * RetroArch is free software: you can redistribute it and/or modify it under the terms + * of the GNU General Public License as published by the Free Software Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with RetroArch. + * If not, see . + */ + +#include + +#include "dxgi_common.h" + +HRESULT WINAPI CreateDXGIFactory1(REFIID riid, void **ppFactory) +{ + static dylib_t dxgi_dll; + static HRESULT (WINAPI *fp)(REFIID, void **); + + if(!dxgi_dll) + dxgi_dll = dylib_load("dxgi.dll"); + + if(!dxgi_dll) + return TYPE_E_CANTLOADLIBRARY; + + if(!fp) + fp = (HRESULT (WINAPI *)(REFIID, void **))dylib_proc(dxgi_dll, "CreateDXGIFactory1"); + + if(!fp) + return TYPE_E_CANTLOADLIBRARY; + + return fp(riid, ppFactory); +} + diff --git a/gfx/common/dxgi_common.h b/gfx/common/dxgi_common.h new file mode 100644 index 0000000000..e37e65240a --- /dev/null +++ b/gfx/common/dxgi_common.h @@ -0,0 +1,450 @@ +#pragma once + +#ifdef __MINGW32__ +#define __REQUIRED_RPCNDR_H_VERSION__ 475 +#define _In_ +#define _In_opt_ +#define _Null_ + +#define _Out_writes_bytes_opt_(s) +#endif + +#define CINTERFACE +#include + +#ifndef countof +#define countof(a) (sizeof(a)/ sizeof(*a)) +#endif + +#ifndef __uuidof +#define __uuidof(type) &IID_##type +#endif + +#ifndef COM_RELEASE_DECLARED +#define COM_RELEASE_DECLARED +#if defined(__cplusplus) && !defined(CINTERFACE) +static inline ULONG Release(IUnknown* object) +{ + return object->Release(); +} +#else +static inline ULONG Release(void* object) +{ + return ((IUnknown*)object)->lpVtbl->Release(object); +} +#endif +#endif + +/* auto-generated */ + +typedef IDXGIObject* DXGIObject; +typedef IDXGIDeviceSubObject* DXGIDeviceSubObject; +typedef IDXGIResource* DXGIResource; +typedef IDXGIKeyedMutex* DXGIKeyedMutex; +typedef IDXGISurface1* DXGISurface; +typedef IDXGIOutput* DXGIOutput; +typedef IDXGIDevice* DXGIDevice; +typedef IDXGIFactory1* DXGIFactory; +typedef IDXGIAdapter1* DXGIAdapter; +typedef IDXGIDisplayControl* DXGIDisplayControl; +typedef IDXGIOutputDuplication* DXGIOutputDuplication; +typedef IDXGIDecodeSwapChain* DXGIDecodeSwapChain; +typedef IDXGIFactoryMedia* DXGIFactoryMedia; +typedef IDXGISwapChainMedia* DXGISwapChainMedia; +typedef IDXGISwapChain3* DXGISwapChain; + +static inline ULONG DXGIReleaseDeviceSubObject(DXGIDeviceSubObject device_sub_object) +{ + return device_sub_object->lpVtbl->Release(device_sub_object); +} +static inline HRESULT DXGIGetSharedHandle(void* resource, HANDLE* shared_handle) +{ + return ((IDXGIResource*)resource)->lpVtbl->GetSharedHandle(resource, shared_handle); +} +static inline HRESULT DXGIGetUsage(void* resource, DXGI_USAGE* usage) +{ + return ((IDXGIResource*)resource)->lpVtbl->GetUsage(resource, usage); +} +static inline HRESULT DXGISetEvictionPriority(void* resource, UINT eviction_priority) +{ + return ((IDXGIResource*)resource)->lpVtbl->SetEvictionPriority(resource, eviction_priority); +} +static inline HRESULT DXGIGetEvictionPriority(void* resource, UINT* eviction_priority) +{ + return ((IDXGIResource*)resource)->lpVtbl->GetEvictionPriority(resource, eviction_priority); +} +static inline ULONG DXGIReleaseKeyedMutex(DXGIKeyedMutex keyed_mutex) +{ + return keyed_mutex->lpVtbl->Release(keyed_mutex); +} +static inline HRESULT DXGIAcquireSync(DXGIKeyedMutex keyed_mutex, UINT64 key, DWORD dw_milliseconds) +{ + return keyed_mutex->lpVtbl->AcquireSync(keyed_mutex, key, dw_milliseconds); +} +static inline HRESULT DXGIReleaseSync(DXGIKeyedMutex keyed_mutex, UINT64 key) +{ + return keyed_mutex->lpVtbl->ReleaseSync(keyed_mutex, key); +} +static inline ULONG DXGIReleaseSurface(DXGISurface surface) +{ + return surface->lpVtbl->Release(surface); +} +static inline HRESULT DXGIMap(DXGISurface surface, DXGI_MAPPED_RECT* locked_rect, UINT map_flags) +{ + return surface->lpVtbl->Map(surface, locked_rect, map_flags); +} +static inline HRESULT DXGIUnmap(DXGISurface surface) +{ + return surface->lpVtbl->Unmap(surface); +} +static inline HRESULT DXGIGetDC(DXGISurface surface, BOOL discard, HDC* hdc) +{ + return surface->lpVtbl->GetDC(surface, discard, hdc); +} +static inline HRESULT DXGIReleaseDC(DXGISurface surface, RECT* dirty_rect) +{ + return surface->lpVtbl->ReleaseDC(surface, dirty_rect); +} +static inline ULONG DXGIReleaseOutput(DXGIOutput output) +{ + return output->lpVtbl->Release(output); +} +static inline HRESULT DXGIGetDisplayModeList(DXGIOutput output, DXGI_FORMAT enum_format, UINT flags, UINT* num_modes, DXGI_MODE_DESC* desc) +{ + return output->lpVtbl->GetDisplayModeList(output, enum_format, flags, num_modes, desc); +} +static inline HRESULT DXGIFindClosestMatchingMode(DXGIOutput output, DXGI_MODE_DESC* mode_to_match, DXGI_MODE_DESC* closest_match, void* concerned_device) +{ + return output->lpVtbl->FindClosestMatchingMode(output, mode_to_match, closest_match, (IUnknown*)concerned_device); +} +static inline HRESULT DXGIWaitForVBlank(DXGIOutput output) +{ + return output->lpVtbl->WaitForVBlank(output); +} +static inline HRESULT DXGITakeOwnership(DXGIOutput output, void* device, BOOL exclusive) +{ + return output->lpVtbl->TakeOwnership(output, (IUnknown*)device, exclusive); +} +static inline void DXGIReleaseOwnership(DXGIOutput output) +{ + output->lpVtbl->ReleaseOwnership(output); +} +static inline HRESULT DXGIGetGammaControlCapabilities(DXGIOutput output, DXGI_GAMMA_CONTROL_CAPABILITIES* gamma_caps) +{ + return output->lpVtbl->GetGammaControlCapabilities(output, gamma_caps); +} +static inline HRESULT DXGISetGammaControl(DXGIOutput output, DXGI_GAMMA_CONTROL* array) +{ + return output->lpVtbl->SetGammaControl(output, array); +} +static inline HRESULT DXGIGetGammaControl(DXGIOutput output, DXGI_GAMMA_CONTROL* array) +{ + return output->lpVtbl->GetGammaControl(output, array); +} +static inline HRESULT DXGISetDisplaySurface(DXGIOutput output, DXGISurface scanout_surface) +{ + return output->lpVtbl->SetDisplaySurface(output, (IDXGISurface*)scanout_surface); +} +static inline HRESULT DXGIGetDisplaySurfaceData(DXGIOutput output, DXGISurface destination) +{ + return output->lpVtbl->GetDisplaySurfaceData(output, (IDXGISurface*)destination); +} +static inline ULONG DXGIReleaseDevice(DXGIDevice device) +{ + return device->lpVtbl->Release(device); +} +static inline HRESULT DXGICreateSurface(DXGIDevice device, DXGI_SURFACE_DESC* desc, UINT num_surfaces, DXGI_USAGE usage, DXGI_SHARED_RESOURCE* shared_resource, DXGISurface* surface) +{ + return device->lpVtbl->CreateSurface(device, desc, num_surfaces, usage, shared_resource, (IDXGISurface**)surface); +} +static inline HRESULT DXGISetGPUThreadPriority(DXGIDevice device, INT priority) +{ + return device->lpVtbl->SetGPUThreadPriority(device, priority); +} +static inline HRESULT DXGIGetGPUThreadPriority(DXGIDevice device, INT* priority) +{ + return device->lpVtbl->GetGPUThreadPriority(device, priority); +} +static inline ULONG DXGIReleaseFactory(DXGIFactory factory) +{ + return factory->lpVtbl->Release(factory); +} +static inline HRESULT DXGIMakeWindowAssociation(DXGIFactory factory, HWND window_handle, UINT flags) +{ + return factory->lpVtbl->MakeWindowAssociation(factory, window_handle, flags); +} +static inline HRESULT DXGIGetWindowAssociation(DXGIFactory factory, HWND* window_handle) +{ + return factory->lpVtbl->GetWindowAssociation(factory, window_handle); +} +static inline HRESULT DXGICreateSwapChain(DXGIFactory factory, void* device, DXGI_SWAP_CHAIN_DESC* desc, DXGISwapChain* swap_chain) +{ + return factory->lpVtbl->CreateSwapChain(factory, (IUnknown*)device, desc, (IDXGISwapChain**)swap_chain); +} +static inline HRESULT DXGICreateSoftwareAdapter(DXGIFactory factory, HMODULE module, DXGIAdapter* adapter) +{ + return factory->lpVtbl->CreateSoftwareAdapter(factory, module, (IDXGIAdapter**)adapter); +} +static inline HRESULT DXGIEnumAdapters(DXGIFactory factory, UINT id, DXGIAdapter* adapter) +{ + return factory->lpVtbl->EnumAdapters1(factory, id, adapter); +} +static inline BOOL DXGIIsCurrent(DXGIFactory factory) +{ + return factory->lpVtbl->IsCurrent(factory); +} +static inline ULONG DXGIReleaseAdapter(DXGIAdapter adapter) +{ + return adapter->lpVtbl->Release(adapter); +} +static inline HRESULT DXGIEnumOutputs(DXGIAdapter adapter, UINT id, DXGIOutput* output) +{ + return adapter->lpVtbl->EnumOutputs(adapter, id, output); +} +static inline HRESULT DXGICheckInterfaceSupport(DXGIAdapter adapter, REFGUID interface_name, LARGE_INTEGER* u_m_d_version) +{ + return adapter->lpVtbl->CheckInterfaceSupport(adapter, interface_name, u_m_d_version); +} +static inline HRESULT DXGIGetAdapterDesc1(DXGIAdapter adapter, DXGI_ADAPTER_DESC1* desc) +{ + return adapter->lpVtbl->GetDesc1(adapter, desc); +} +static inline ULONG DXGIReleaseDisplayControl(DXGIDisplayControl display_control) +{ + return display_control->lpVtbl->Release(display_control); +} +static inline BOOL DXGIIsStereoEnabled(DXGIDisplayControl display_control) +{ + return display_control->lpVtbl->IsStereoEnabled(display_control); +} +static inline void DXGISetStereoEnabled(DXGIDisplayControl display_control, BOOL enabled) +{ + display_control->lpVtbl->SetStereoEnabled(display_control, enabled); +} +static inline ULONG DXGIReleaseOutputDuplication(DXGIOutputDuplication output_duplication) +{ + return output_duplication->lpVtbl->Release(output_duplication); +} +static inline HRESULT DXGIAcquireNextFrame(DXGIOutputDuplication output_duplication, UINT timeout_in_milliseconds, DXGI_OUTDUPL_FRAME_INFO* frame_info, void* desktop_resource) +{ + return output_duplication->lpVtbl->AcquireNextFrame(output_duplication, timeout_in_milliseconds, frame_info, (IDXGIResource**)desktop_resource); +} +static inline HRESULT DXGIGetFrameDirtyRects(DXGIOutputDuplication output_duplication, UINT dirty_rects_buffer_size, RECT* dirty_rects_buffer, UINT* dirty_rects_buffer_size_required) +{ + return output_duplication->lpVtbl->GetFrameDirtyRects(output_duplication, dirty_rects_buffer_size, dirty_rects_buffer, dirty_rects_buffer_size_required); +} +static inline HRESULT DXGIGetFrameMoveRects(DXGIOutputDuplication output_duplication, UINT move_rects_buffer_size, DXGI_OUTDUPL_MOVE_RECT* move_rect_buffer, UINT* move_rects_buffer_size_required) +{ + return output_duplication->lpVtbl->GetFrameMoveRects(output_duplication, move_rects_buffer_size, move_rect_buffer, move_rects_buffer_size_required); +} +static inline HRESULT DXGIGetFramePointerShape(DXGIOutputDuplication output_duplication, UINT pointer_shape_buffer_size, void* pointer_shape_buffer, UINT* pointer_shape_buffer_size_required, DXGI_OUTDUPL_POINTER_SHAPE_INFO* pointer_shape_info) +{ + return output_duplication->lpVtbl->GetFramePointerShape(output_duplication, pointer_shape_buffer_size, pointer_shape_buffer, pointer_shape_buffer_size_required, pointer_shape_info); +} +static inline HRESULT DXGIMapDesktopSurface(DXGIOutputDuplication output_duplication, DXGI_MAPPED_RECT* locked_rect) +{ + return output_duplication->lpVtbl->MapDesktopSurface(output_duplication, locked_rect); +} +static inline HRESULT DXGIUnMapDesktopSurface(DXGIOutputDuplication output_duplication) +{ + return output_duplication->lpVtbl->UnMapDesktopSurface(output_duplication); +} +static inline HRESULT DXGIReleaseFrame(DXGIOutputDuplication output_duplication) +{ + return output_duplication->lpVtbl->ReleaseFrame(output_duplication); +} +static inline ULONG DXGIReleaseDecodeSwapChain(DXGIDecodeSwapChain decode_swap_chain) +{ + return decode_swap_chain->lpVtbl->Release(decode_swap_chain); +} +static inline HRESULT DXGIPresentBuffer(DXGIDecodeSwapChain decode_swap_chain, UINT buffer_to_present, UINT sync_interval, UINT flags) +{ + return decode_swap_chain->lpVtbl->PresentBuffer(decode_swap_chain, buffer_to_present, sync_interval, flags); +} +static inline HRESULT DXGISetSourceRect(DXGIDecodeSwapChain decode_swap_chain, RECT* rect) +{ + return decode_swap_chain->lpVtbl->SetSourceRect(decode_swap_chain, rect); +} +static inline HRESULT DXGISetTargetRect(DXGIDecodeSwapChain decode_swap_chain, RECT* rect) +{ + return decode_swap_chain->lpVtbl->SetTargetRect(decode_swap_chain, rect); +} +static inline HRESULT DXGISetDestSize(DXGIDecodeSwapChain decode_swap_chain, UINT width, UINT height) +{ + return decode_swap_chain->lpVtbl->SetDestSize(decode_swap_chain, width, height); +} +static inline HRESULT DXGIGetSourceRect(DXGIDecodeSwapChain decode_swap_chain, RECT* rect) +{ + return decode_swap_chain->lpVtbl->GetSourceRect(decode_swap_chain, rect); +} +static inline HRESULT DXGIGetTargetRect(DXGIDecodeSwapChain decode_swap_chain, RECT* rect) +{ + return decode_swap_chain->lpVtbl->GetTargetRect(decode_swap_chain, rect); +} +static inline HRESULT DXGIGetDestSize(DXGIDecodeSwapChain decode_swap_chain, UINT* width, UINT* height) +{ + return decode_swap_chain->lpVtbl->GetDestSize(decode_swap_chain, width, height); +} +static inline HRESULT DXGISetColorSpace(DXGIDecodeSwapChain decode_swap_chain, DXGI_MULTIPLANE_OVERLAY_YCbCr_FLAGS color_space) +{ + return decode_swap_chain->lpVtbl->SetColorSpace(decode_swap_chain, color_space); +} +static inline DXGI_MULTIPLANE_OVERLAY_YCbCr_FLAGS DXGIGetColorSpace(DXGIDecodeSwapChain decode_swap_chain) +{ + return decode_swap_chain->lpVtbl->GetColorSpace(decode_swap_chain); +} +static inline ULONG DXGIReleaseFactoryMedia(DXGIFactoryMedia factory_media) +{ + return factory_media->lpVtbl->Release(factory_media); +} +static inline HRESULT DXGICreateSwapChainForCompositionSurfaceHandle(DXGIFactoryMedia factory_media, void* device, HANDLE h_surface, DXGI_SWAP_CHAIN_DESC1* desc, DXGIOutput restrict_to_output, DXGISwapChain* swap_chain) +{ + return factory_media->lpVtbl->CreateSwapChainForCompositionSurfaceHandle(factory_media, (IUnknown*)device, h_surface, desc, restrict_to_output, (IDXGISwapChain1**)swap_chain); +} +static inline HRESULT DXGICreateDecodeSwapChainForCompositionSurfaceHandle(DXGIFactoryMedia factory_media, void* device, HANDLE h_surface, DXGI_DECODE_SWAP_CHAIN_DESC* desc, void* yuv_decode_buffers, DXGIOutput restrict_to_output, DXGIDecodeSwapChain* swap_chain) +{ + return factory_media->lpVtbl->CreateDecodeSwapChainForCompositionSurfaceHandle(factory_media, (IUnknown*)device, h_surface, desc, (IDXGIResource*)yuv_decode_buffers, restrict_to_output, swap_chain); +} +static inline ULONG DXGIReleaseSwapChainMedia(DXGISwapChainMedia swap_chain_media) +{ + return swap_chain_media->lpVtbl->Release(swap_chain_media); +} +static inline HRESULT DXGIGetFrameStatisticsMedia(DXGISwapChainMedia swap_chain_media, DXGI_FRAME_STATISTICS_MEDIA* stats) +{ + return swap_chain_media->lpVtbl->GetFrameStatisticsMedia(swap_chain_media, stats); +} +static inline HRESULT DXGISetPresentDuration(DXGISwapChainMedia swap_chain_media, UINT duration) +{ + return swap_chain_media->lpVtbl->SetPresentDuration(swap_chain_media, duration); +} +static inline HRESULT DXGICheckPresentDurationSupport(DXGISwapChainMedia swap_chain_media, UINT desired_present_duration, UINT* closest_smaller_present_duration, UINT* closest_larger_present_duration) +{ + return swap_chain_media->lpVtbl->CheckPresentDurationSupport(swap_chain_media, desired_present_duration, closest_smaller_present_duration, closest_larger_present_duration); +} +static inline ULONG DXGIReleaseSwapChain(DXGISwapChain swap_chain) +{ + return swap_chain->lpVtbl->Release(swap_chain); +} +static inline HRESULT DXGIPresent(DXGISwapChain swap_chain, UINT sync_interval, UINT flags) +{ + return swap_chain->lpVtbl->Present(swap_chain, sync_interval, flags); +} +static inline HRESULT DXGIGetBuffer(DXGISwapChain swap_chain, UINT buffer, IDXGISurface** out) +{ + return swap_chain->lpVtbl->GetBuffer(swap_chain, buffer, __uuidof(IDXGISurface), (void**)out); +} +static inline HRESULT DXGISetFullscreenState(DXGISwapChain swap_chain, BOOL fullscreen, DXGIOutput target) +{ + return swap_chain->lpVtbl->SetFullscreenState(swap_chain, fullscreen, target); +} +static inline HRESULT DXGIGetFullscreenState(DXGISwapChain swap_chain, BOOL* fullscreen, DXGIOutput* target) +{ + return swap_chain->lpVtbl->GetFullscreenState(swap_chain, fullscreen, target); +} +static inline HRESULT DXGIResizeBuffers(DXGISwapChain swap_chain, UINT buffer_count, UINT width, UINT height, DXGI_FORMAT new_format, UINT swap_chain_flags) +{ + return swap_chain->lpVtbl->ResizeBuffers(swap_chain, buffer_count, width, height, new_format, swap_chain_flags); +} +static inline HRESULT DXGIResizeTarget(DXGISwapChain swap_chain, DXGI_MODE_DESC* new_target_parameters) +{ + return swap_chain->lpVtbl->ResizeTarget(swap_chain, new_target_parameters); +} +static inline HRESULT DXGIGetContainingOutput(DXGISwapChain swap_chain, DXGIOutput* output) +{ + return swap_chain->lpVtbl->GetContainingOutput(swap_chain, output); +} +static inline HRESULT DXGIGetFrameStatistics(DXGISwapChain swap_chain, DXGI_FRAME_STATISTICS* stats) +{ + return swap_chain->lpVtbl->GetFrameStatistics(swap_chain, stats); +} +static inline HRESULT DXGIGetLastPresentCount(DXGISwapChain swap_chain, UINT* last_present_count) +{ + return swap_chain->lpVtbl->GetLastPresentCount(swap_chain, last_present_count); +} +static inline HRESULT DXGIGetSwapChainDesc1(DXGISwapChain swap_chain, DXGI_SWAP_CHAIN_DESC1* desc) +{ + return swap_chain->lpVtbl->GetDesc1(swap_chain, desc); +} +static inline HRESULT DXGIGetFullscreenDesc(DXGISwapChain swap_chain, DXGI_SWAP_CHAIN_FULLSCREEN_DESC* desc) +{ + return swap_chain->lpVtbl->GetFullscreenDesc(swap_chain, desc); +} +static inline HRESULT DXGIGetHwnd(DXGISwapChain swap_chain, HWND* hwnd) +{ + return swap_chain->lpVtbl->GetHwnd(swap_chain, hwnd); +} +static inline HRESULT DXGIPresent1(DXGISwapChain swap_chain, UINT sync_interval, UINT present_flags, DXGI_PRESENT_PARAMETERS* present_parameters) +{ + return swap_chain->lpVtbl->Present1(swap_chain, sync_interval, present_flags, present_parameters); +} +static inline BOOL DXGIIsTemporaryMonoSupported(DXGISwapChain swap_chain) +{ + return swap_chain->lpVtbl->IsTemporaryMonoSupported(swap_chain); +} +static inline HRESULT DXGIGetRestrictToOutput(DXGISwapChain swap_chain, DXGIOutput* restrict_to_output) +{ + return swap_chain->lpVtbl->GetRestrictToOutput(swap_chain, restrict_to_output); +} +static inline HRESULT DXGISetBackgroundColor(DXGISwapChain swap_chain, DXGI_RGBA* color) +{ + return swap_chain->lpVtbl->SetBackgroundColor(swap_chain, color); +} +static inline HRESULT DXGIGetBackgroundColor(DXGISwapChain swap_chain, DXGI_RGBA* color) +{ + return swap_chain->lpVtbl->GetBackgroundColor(swap_chain, color); +} +static inline HRESULT DXGISetRotation(DXGISwapChain swap_chain, DXGI_MODE_ROTATION rotation) +{ + return swap_chain->lpVtbl->SetRotation(swap_chain, rotation); +} +static inline HRESULT DXGIGetRotation(DXGISwapChain swap_chain, DXGI_MODE_ROTATION* rotation) +{ + return swap_chain->lpVtbl->GetRotation(swap_chain, rotation); +} +static inline HRESULT DXGISetSourceSize(DXGISwapChain swap_chain, UINT width, UINT height) +{ + return swap_chain->lpVtbl->SetSourceSize(swap_chain, width, height); +} +static inline HRESULT DXGIGetSourceSize(DXGISwapChain swap_chain, UINT* width, UINT* height) +{ + return swap_chain->lpVtbl->GetSourceSize(swap_chain, width, height); +} +static inline HRESULT DXGISetMaximumFrameLatency(DXGISwapChain swap_chain, UINT max_latency) +{ + return swap_chain->lpVtbl->SetMaximumFrameLatency(swap_chain, max_latency); +} +static inline HRESULT DXGIGetMaximumFrameLatency(DXGISwapChain swap_chain, UINT* max_latency) +{ + return swap_chain->lpVtbl->GetMaximumFrameLatency(swap_chain, max_latency); +} +static inline HANDLE DXGIGetFrameLatencyWaitableObject(DXGISwapChain swap_chain) +{ + return swap_chain->lpVtbl->GetFrameLatencyWaitableObject(swap_chain); +} +static inline HRESULT DXGISetMatrixTransform(DXGISwapChain swap_chain, DXGI_MATRIX_3X2_F* matrix) +{ + return swap_chain->lpVtbl->SetMatrixTransform(swap_chain, matrix); +} +static inline HRESULT DXGIGetMatrixTransform(DXGISwapChain swap_chain, DXGI_MATRIX_3X2_F* matrix) +{ + return swap_chain->lpVtbl->GetMatrixTransform(swap_chain, matrix); +} +static inline UINT DXGIGetCurrentBackBufferIndex(DXGISwapChain swap_chain) +{ + return swap_chain->lpVtbl->GetCurrentBackBufferIndex(swap_chain); +} +static inline HRESULT DXGICheckColorSpaceSupport(DXGISwapChain swap_chain, DXGI_COLOR_SPACE_TYPE color_space, UINT* color_space_support) +{ + return swap_chain->lpVtbl->CheckColorSpaceSupport(swap_chain, color_space, color_space_support); +} +static inline HRESULT DXGISetColorSpace1(DXGISwapChain swap_chain, DXGI_COLOR_SPACE_TYPE color_space) +{ + return swap_chain->lpVtbl->SetColorSpace1(swap_chain, color_space); +} + +/* end of auto-generated */ + +static inline HRESULT DXGICreateFactory(DXGIFactory* factory) +{ + return CreateDXGIFactory1(__uuidof(IDXGIFactory1), (void**)factory); +} diff --git a/gfx/drivers/d3d11.c b/gfx/drivers/d3d11.c new file mode 100644 index 0000000000..539e082805 --- /dev/null +++ b/gfx/drivers/d3d11.c @@ -0,0 +1,614 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2014-2018 - Ali Bouhlel + * + * RetroArch is free software: you can redistribute it and/or modify it under the terms + * of the GNU General Public License as published by the Free Software Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with RetroArch. + * If not, see . + */ + +#include +#include + +#include "driver.h" +#include "verbosity.h" +#include "configuration.h" +#include "gfx/video_driver.h" +#include "gfx/common/win32_common.h" +#include "gfx/common/d3d11_common.h" +#include "gfx/common/dxgi_common.h" +#include "gfx/common/d3dcompiler_common.h" + +typedef struct d3d11_vertex_t +{ + float position[2]; + float texcoord[2]; + float color[4]; +} d3d11_vertex_t; + +typedef struct +{ + unsigned cur_mon_id; + DXGISwapChain swapChain; + D3D11Device device; + D3D_FEATURE_LEVEL supportedFeatureLevel; + D3D11DeviceContext context; + D3D11RenderTargetView renderTargetView; + D3D11Buffer vertexBuffer; + D3D11InputLayout layout; + D3D11VertexShader vs; + D3D11PixelShader ps; + D3D11SamplerState sampler_nearest; + D3D11SamplerState sampler_linear; + D3D11Texture2D frame_default; + D3D11Texture2D frame_staging; + struct + { + D3D11Texture2D tex; + D3D11ShaderResourceView view; + D3D11Buffer vbo; + int width; + int height; + bool enabled; + bool fullscreen; + } menu; + int frame_width; + int frame_height; + D3D11ShaderResourceView frame_view; + float clearcolor[4]; + bool vsync; + bool rgb32; +} d3d11_video_t; + +static void* d3d11_gfx_init(const video_info_t* video, + const input_driver_t** input, void** input_data) +{ + WNDCLASSEX wndclass = {0}; + settings_t* settings = config_get_ptr(); + gfx_ctx_input_t inp = {input, input_data}; + d3d11_video_t* d3d11 = (d3d11_video_t*)calloc(1, sizeof(*d3d11)); + + if (!d3d11) + return NULL; + + win32_window_reset(); + win32_monitor_init(); + wndclass.lpfnWndProc = WndProcD3D; + win32_window_init(&wndclass, true, NULL); + + if (!win32_set_video_mode(d3d11, video->width, video->height, video->fullscreen)) + { + RARCH_ERR("[D3D11]: win32_set_video_mode failed.\n"); + goto error; + } + + gfx_ctx_d3d.input_driver(NULL, settings->arrays.input_joypad_driver, input, input_data); + + d3d11->rgb32 = video->rgb32; + d3d11->vsync = video->vsync; + + { + UINT flags = 0; + D3D_FEATURE_LEVEL requested_feature_level = D3D_FEATURE_LEVEL_11_0; + DXGI_SWAP_CHAIN_DESC desc = + { + .BufferCount = 1, + .BufferDesc.Width = video->width, + .BufferDesc.Height = video->height, + .BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM, + .BufferDesc.RefreshRate.Numerator = 60, + .BufferDesc.RefreshRate.Denominator = 1, + .BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT, + .OutputWindow = main_window.hwnd, + .SampleDesc.Count = 1, + .SampleDesc.Quality = 0, + .Windowed = TRUE, +// .SwapEffect = DXGI_SWAP_EFFECT_DISCARD, + .SwapEffect = DXGI_SWAP_EFFECT_SEQUENTIAL, +// .SwapEffect = DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL, +// .SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD, + }; + +//#ifdef DEBUG + flags |= D3D11_CREATE_DEVICE_DEBUG; +//#endif + + D3D11CreateDeviceAndSwapChain(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, flags, + &requested_feature_level, 1, D3D11_SDK_VERSION, &desc, + (IDXGISwapChain**)&d3d11->swapChain, &d3d11->device, &d3d11->supportedFeatureLevel, &d3d11->context); + } + +// d3d = *device->lpVtbl; +// ctx = *context->lpVtbl; +// dxgi = *swapChain->lpVtbl; + + D3D11Texture2D backBuffer; + DXGIGetSwapChainBufferD3D11(d3d11->swapChain, 0, &backBuffer); + D3D11CreateTexture2DRenderTargetView(d3d11->device, backBuffer, NULL, &d3d11->renderTargetView); + Release(backBuffer); + D3D11SetRenderTargets(d3d11->context, 1, &d3d11->renderTargetView, NULL); + + D3D11_VIEWPORT vp = {0, 0, video->width, video->height, 0.0f, 1.0f}; + D3D11SetViewports(d3d11->context, 1, &vp); + + + d3d11->frame_width = video->input_scale * RARCH_SCALE_BASE; + d3d11->frame_height = video->input_scale * RARCH_SCALE_BASE; + { + D3D11_TEXTURE2D_DESC desc = + { + .Width = d3d11->frame_width, + .Height = d3d11->frame_height, + .MipLevels = 1, + .ArraySize = 1, + .Format = DXGI_FORMAT_B8G8R8A8_UNORM, +// .Format = d3d11->rgb32? DXGI_FORMAT_B8G8R8X8_UNORM : DXGI_FORMAT_B5G6R5_UNORM, + .SampleDesc.Count = 1, + .SampleDesc.Quality = 0, + .Usage = D3D11_USAGE_DEFAULT, + .BindFlags = D3D11_BIND_SHADER_RESOURCE, + .CPUAccessFlags = 0, + .MiscFlags = 0, + }; + D3D11_SHADER_RESOURCE_VIEW_DESC view_desc = + { + .Format = desc.Format, + .ViewDimension = D3D_SRV_DIMENSION_TEXTURE2D, + .Texture2D.MostDetailedMip = 0, + .Texture2D.MipLevels = -1, + }; + + D3D11CreateTexture2D(d3d11->device, &desc, NULL, &d3d11->frame_default); + D3D11CreateTexture2DShaderResourceView(d3d11->device, d3d11->frame_default, &view_desc, &d3d11->frame_view); + desc.Format = desc.Format; + desc.BindFlags = 0; + desc.Usage = D3D11_USAGE_STAGING; + desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; + D3D11CreateTexture2D(d3d11->device, &desc, NULL, &d3d11->frame_staging); + } + + { + D3D11_SAMPLER_DESC desc = + { + .Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR, + .AddressU = D3D11_TEXTURE_ADDRESS_BORDER, + .AddressV = D3D11_TEXTURE_ADDRESS_BORDER, + .AddressW = D3D11_TEXTURE_ADDRESS_BORDER, + .MipLODBias = 0.0f, + .MaxAnisotropy = 1, + .ComparisonFunc = D3D11_COMPARISON_NEVER, + .BorderColor[0] = 0.0f, + .BorderColor[1] = 0.0f, + .BorderColor[2] = 0.0f, + .BorderColor[3] = 0.0f, + .MinLOD = -D3D11_FLOAT32_MAX, + .MaxLOD = D3D11_FLOAT32_MAX, + }; + D3D11CreateSamplerState(d3d11->device, &desc, &d3d11->sampler_nearest); + desc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR; + D3D11CreateSamplerState(d3d11->device, &desc, &d3d11->sampler_linear); + } + + { + d3d11_vertex_t vertices[] = + { + {{ -1.0f, -1.0f}, {0.0f, 1.0f}, {1.0f, 1.0f, 1.0f, 1.0f}}, + {{ -1.0f, 1.0f}, {0.0f, 0.0f}, {1.0f, 1.0f, 1.0f, 1.0f}}, + {{ 1.0f, -1.0f}, {1.0f, 1.0f}, {1.0f, 1.0f, 1.0f, 1.0f}}, + {{ 1.0f, 1.0f}, {1.0f, 0.0f}, {1.0f, 1.0f, 1.0f, 1.0f}}, + }; + + { + D3D11_BUFFER_DESC desc = + { + .Usage = D3D11_USAGE_DYNAMIC, + .ByteWidth = sizeof(vertices), + .BindFlags = D3D11_BIND_VERTEX_BUFFER, + .StructureByteStride = 0, /* sizeof(Vertex) ? */ + .CPUAccessFlags = D3D11_CPU_ACCESS_WRITE, + }; + D3D11_SUBRESOURCE_DATA vertexData = {vertices}; + D3D11CreateBuffer(d3d11->device, &desc, &vertexData, &d3d11->vertexBuffer); + desc.Usage = D3D11_USAGE_IMMUTABLE; + desc.CPUAccessFlags = 0; + D3D11CreateBuffer(d3d11->device, &desc, &vertexData, &d3d11->menu.vbo); + } + D3D11SetPrimitiveTopology(d3d11->context, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP); + } + + { + D3DBlob vs_code; + D3DBlob ps_code; + + static const char stock [] = +#include "d3d_shaders/opaque_sm5.hlsl.h" + ; + + D3D11_INPUT_ELEMENT_DESC desc[] = + { + {"POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, offsetof(d3d11_vertex_t, position), D3D11_INPUT_PER_VERTEX_DATA, 0}, + {"TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, offsetof(d3d11_vertex_t, texcoord), D3D11_INPUT_PER_VERTEX_DATA, 0}, + {"COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, offsetof(d3d11_vertex_t, color), D3D11_INPUT_PER_VERTEX_DATA, 0}, + }; + + d3d_compile(stock, sizeof(stock), "VSMain", "vs_5_0", &vs_code); + d3d_compile(stock, sizeof(stock), "PSMain", "ps_5_0", &ps_code); + + D3D11CreateVertexShader(d3d11->device, D3DGetBufferPointer(vs_code), D3DGetBufferSize(vs_code), + NULL, &d3d11->vs); + D3D11CreatePixelShader(d3d11->device, D3DGetBufferPointer(ps_code), D3DGetBufferSize(ps_code), + NULL, &d3d11->ps); + D3D11CreateInputLayout(d3d11->device, desc, countof(desc), + D3DGetBufferPointer(vs_code), D3DGetBufferSize(vs_code), &d3d11->layout); + + Release(vs_code); + Release(ps_code); + } + + D3D11SetInputLayout(d3d11->context, d3d11->layout); + D3D11SetVShader(d3d11->context, d3d11->vs, NULL, 0); + D3D11SetPShader(d3d11->context, d3d11->ps, NULL, 0); + + return d3d11; + +error: + free(d3d11); + return NULL; +} + +static bool d3d11_gfx_frame(void* data, const void* frame, + unsigned width, unsigned height, uint64_t frame_count, + unsigned pitch, const char* msg, video_frame_info_t* video_info) +{ + (void)msg; + + d3d11_video_t* d3d11 = (d3d11_video_t*)data; +#if 1 + if(frame && width && height) + { + D3D11_MAPPED_SUBRESOURCE mapped_frame; + D3D11MapTexture2D(d3d11->context, d3d11->frame_staging, 0, D3D11_MAP_WRITE, 0, &mapped_frame); + { + int i, j; + + if (d3d11->rgb32) + { + const uint8_t* in = frame; + uint8_t* out = mapped_frame.pData; + for (i = 0; i < height; i++) + { + memcpy(out, in, width * (d3d11->rgb32? 4 : 2)); + in += pitch; + out += mapped_frame.RowPitch; + } + } + else + { + const uint16_t* in = frame; + uint32_t* out = mapped_frame.pData; + for (i = 0; i < height; i++) + { + for (j = 0; j < width; j++) + { + unsigned b = ((in[j] >> 11) & 0x1F); + unsigned g = ((in[j] >> 5) & 0x3F); + unsigned r = ((in[j] >> 0) & 0x1F); + + out[j] = ((r >> 2) << 0) | (r << 3) |((g >> 4) << 8) | (g << 10) |((b >> 2) << 16) | (b << 19); + + } + in += width; + out += mapped_frame.RowPitch / 4; + } + } + + } + D3D11UnmapTexture2D(d3d11->context, d3d11->frame_staging, 0); + D3D11_BOX frame_box = {0, 0, 0, width, height, 1}; + D3D11CopyTexture2DSubresourceRegion(d3d11->context, d3d11->frame_default, 0, 0 , 0 , 0, + d3d11->frame_staging, 0, &frame_box); + + { + D3D11_MAPPED_SUBRESOURCE mapped_vbo; + D3D11MapBuffer(d3d11->context, d3d11->vertexBuffer, 0, D3D11_MAP_WRITE_NO_OVERWRITE, 0, + &mapped_vbo); + { + d3d11_vertex_t* vbo = mapped_vbo.pData; + vbo[0].texcoord[0] = 0.0f * (width / (float)d3d11->frame_width); + vbo[0].texcoord[1] = 1.0f * (height / (float)d3d11->frame_height); + vbo[1].texcoord[0] = 0.0f * (width / (float)d3d11->frame_width); + vbo[1].texcoord[1] = 0.0f * (height / (float)d3d11->frame_height); + vbo[2].texcoord[0] = 1.0f * (width / (float)d3d11->frame_width); + vbo[2].texcoord[1] = 1.0f * (height / (float)d3d11->frame_height); + vbo[3].texcoord[0] = 1.0f * (width / (float)d3d11->frame_width); + vbo[3].texcoord[1] = 0.0f * (height / (float)d3d11->frame_height); + } + D3D11UnmapBuffer(d3d11->context, d3d11->vertexBuffer, 0); + } + } + + D3D11ClearRenderTargetView(d3d11->context, d3d11->renderTargetView, d3d11->clearcolor); + + { + UINT stride = sizeof(d3d11_vertex_t); + UINT offset = 0; + D3D11SetVertexBuffers(d3d11->context, 0, 1, &d3d11->vertexBuffer, &stride, &offset); + D3D11SetPShaderResources(d3d11->context, 0, 1, &d3d11->frame_view); + D3D11SetPShaderSamplers(d3d11->context, 0, 1, &d3d11->sampler_linear); + + D3D11Draw(d3d11->context, 4, 0); + + if (d3d11->menu.enabled) + { + D3D11SetVertexBuffers(d3d11->context, 0, 1, &d3d11->menu.vbo, &stride, &offset); + D3D11SetPShaderResources(d3d11->context, 0, 1, &d3d11->menu.view); + D3D11SetPShaderSamplers(d3d11->context, 0, 1, &d3d11->sampler_linear); + + D3D11Draw(d3d11->context, 4, 0); + } + } + + DXGIPresent(d3d11->swapChain, !!d3d11->vsync, 0); +#endif + if(msg && *msg) + gfx_ctx_d3d.update_window_title(NULL, video_info); + + + + + return true; +} + +static void d3d11_gfx_set_nonblock_state(void* data, bool toggle) +{ + d3d11_video_t* d3d11 = (d3d11_video_t*)data; + d3d11->vsync = !toggle; +} + +static bool d3d11_gfx_alive(void* data) +{ + (void)data; + bool quit; + bool resize; + unsigned width; + unsigned height; + win32_check_window(&quit, &resize, &width, &height); + return true; +} + +static bool d3d11_gfx_focus(void* data) +{ + return win32_has_focus(); +} + +static bool d3d11_gfx_suppress_screensaver(void* data, bool enable) +{ + (void)data; + (void)enable; + return false; +} + +static bool d3d11_gfx_has_windowed(void* data) +{ + (void)data; + return true; +} + +static void d3d11_gfx_free(void* data) +{ + d3d11_video_t* d3d11 = (d3d11_video_t*)data; + + if(d3d11->menu.tex) + Release(d3d11->menu.tex); + if(d3d11->menu.view) + Release(d3d11->menu.view); + + Release(d3d11->menu.vbo); + + + Release(d3d11->sampler_nearest); + Release(d3d11->sampler_linear); + Release(d3d11->frame_view); + Release(d3d11->frame_default); + Release(d3d11->frame_staging); + Release(d3d11->ps); + Release(d3d11->vs); + Release(d3d11->vertexBuffer); + Release(d3d11->layout); + Release(d3d11->renderTargetView); + Release(d3d11->swapChain); + Release(d3d11->context); + Release(d3d11->device); + + win32_monitor_from_window(); + win32_destroy_window(); + free(d3d11); +} + +static bool d3d11_gfx_set_shader(void* data, + enum rarch_shader_type type, const char* path) +{ + (void)data; + (void)type; + (void)path; + + return false; +} + +static void d3d11_gfx_set_rotation(void* data, + unsigned rotation) +{ + (void)data; + (void)rotation; +} + +static void d3d11_gfx_viewport_info(void* data, + struct video_viewport* vp) +{ + (void)data; + (void)vp; +} + +static bool d3d11_gfx_read_viewport(void* data, uint8_t* buffer, bool is_idle) +{ + (void)data; + (void)buffer; + + return true; +} + +static void d3d11_set_menu_texture_frame(void* data, + const void* frame, bool rgb32, unsigned width, unsigned height, + float alpha) +{ + d3d11_video_t* d3d11 = (d3d11_video_t*)data; + + if (d3d11->menu.tex && (d3d11->menu.width != width || d3d11->menu.height != height)) + { + Release(d3d11->menu.tex); + d3d11->menu.tex = NULL; + } + + if (!d3d11->menu.tex) + { + d3d11->menu.width = width; + d3d11->menu.height = height; + + D3D11_TEXTURE2D_DESC desc = + { + .Width = d3d11->menu.width, + .Height = d3d11->menu.height, + .MipLevels = 1, + .ArraySize = 1, + .Format = DXGI_FORMAT_R8G8B8A8_UNORM, + .SampleDesc.Count = 1, + .SampleDesc.Quality = 0, + .Usage = D3D11_USAGE_DYNAMIC, + .BindFlags = D3D11_BIND_SHADER_RESOURCE, + .CPUAccessFlags = D3D11_CPU_ACCESS_WRITE, + .MiscFlags = 0, + }; + D3D11_SHADER_RESOURCE_VIEW_DESC view_desc = + { + .Format = desc.Format, + .ViewDimension = D3D_SRV_DIMENSION_TEXTURE2D, + .Texture2D.MostDetailedMip = 0, + .Texture2D.MipLevels = -1, + }; + + D3D11CreateTexture2D(d3d11->device, &desc, NULL, &d3d11->menu.tex); + D3D11CreateTexture2DShaderResourceView(d3d11->device, d3d11->menu.tex, &view_desc, &d3d11->menu.view); + } + + { + D3D11_MAPPED_SUBRESOURCE mapped_frame; + D3D11MapTexture2D(d3d11->context, d3d11->menu.tex, 0, D3D11_MAP_WRITE_DISCARD, 0, &mapped_frame); + { + int i,j; + + if (rgb32) + { + const uint32_t* in = frame; + uint32_t* out = mapped_frame.pData; + for (i = 0; i < height; i++) + { + memcpy(out, in, width * 4); + in += width; + out += mapped_frame.RowPitch / 4; + } + } + else + { + const uint16_t* in = frame; + uint32_t* out = mapped_frame.pData; + for (i = 0; i < height; i++) + { + for (j = 0; j < width; j++) + { + unsigned r = ((in[j] >> 12) & 0xF); + unsigned g = ((in[j] >> 8) & 0xF); + unsigned b = ((in[j] >> 4) & 0xF); + unsigned a = ((in[j] >> 0) & 0xF); + + out[j] = (r << 0) | (r << 4) |(g << 8) | (g << 12) |(b << 16) | (b << 20) |(a << 24) | (a << 28); + + } + in += width; + out += mapped_frame.RowPitch / 4; + } + } + + } + D3D11UnmapTexture2D(d3d11->context, d3d11->menu.tex, 0); + } +} +static void d3d11_set_menu_texture_enable(void* data, + bool state, bool full_screen) +{ + d3d11_video_t* d3d11 = (d3d11_video_t*)data; + + d3d11->menu.enabled = state; + d3d11->menu.fullscreen = full_screen; +} + + +static const video_poke_interface_t d3d11_poke_interface = +{ + NULL, /* set_coords */ + NULL, /* set_mvp */ + NULL, /* load_texture */ + NULL, /* unload_texture */ + NULL, /* set_video_mode */ + NULL, /* set_filtering */ + NULL, /* get_video_output_size */ + NULL, /* get_video_output_prev */ + NULL, /* get_video_output_next */ + NULL, /* get_current_framebuffer */ + NULL, /* get_proc_address */ + NULL, /* set_aspect_ratio */ + NULL, /* apply_state_changes */ + d3d11_set_menu_texture_frame, /* set_texture_frame */ + d3d11_set_menu_texture_enable, /* set_texture_enable */ + NULL, /* set_osd_msg */ + NULL, /* show_mouse */ + NULL, /* grab_mouse_toggle */ + NULL, /* get_current_shader */ + NULL, /* get_current_software_framebuffer */ + NULL, /* get_hw_render_interface */ +}; + +static void d3d11_gfx_get_poke_interface(void* data, + const video_poke_interface_t** iface) +{ + *iface = &d3d11_poke_interface; +} + +video_driver_t video_d3d11 = +{ + d3d11_gfx_init, + d3d11_gfx_frame, + d3d11_gfx_set_nonblock_state, + d3d11_gfx_alive, + d3d11_gfx_focus, + d3d11_gfx_suppress_screensaver, + d3d11_gfx_has_windowed, + d3d11_gfx_set_shader, + d3d11_gfx_free, + "d3d11", + NULL, /* set_viewport */ + d3d11_gfx_set_rotation, + d3d11_gfx_viewport_info, + d3d11_gfx_read_viewport, + NULL, /* read_frame_raw */ + +#ifdef HAVE_OVERLAY + NULL, /* overlay_interface */ +#endif + d3d11_gfx_get_poke_interface, +}; diff --git a/gfx/drivers/d3d12.c b/gfx/drivers/d3d12.c new file mode 100644 index 0000000000..32fca294c9 --- /dev/null +++ b/gfx/drivers/d3d12.c @@ -0,0 +1,449 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2014-2018 - Ali Bouhlel + * + * RetroArch is free software: you can redistribute it and/or modify it under the terms + * of the GNU General Public License as published by the Free Software Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with RetroArch. + * If not, see . + */ + +#include +#include + +#include "driver.h" +#include "verbosity.h" +#include "configuration.h" +#include "gfx/video_driver.h" +#include "gfx/common/win32_common.h" +#include "gfx/common/dxgi_common.h" +#include "gfx/common/d3d12_common.h" +#include "gfx/common/d3dcompiler_common.h" + +static void *d3d12_gfx_init(const video_info_t *video, + const input_driver_t **input, void **input_data) +{ + WNDCLASSEX wndclass = {0}; + settings_t *settings = config_get_ptr(); + gfx_ctx_input_t inp = {input, input_data}; + d3d12_video_t *d3d12 = (d3d12_video_t *)calloc(1, sizeof(*d3d12)); + + if (!d3d12) + return NULL; + + win32_window_reset(); + win32_monitor_init(); + wndclass.lpfnWndProc = WndProcD3D; + win32_window_init(&wndclass, true, NULL); + + if (!win32_set_video_mode(d3d12, video->width, video->height, video->fullscreen)) + { + RARCH_ERR("[D3D12]: win32_set_video_mode failed.\n"); + goto error; + } + + gfx_ctx_d3d.input_driver(NULL, settings->arrays.input_joypad_driver, input, input_data); + + d3d12->chain.vsync = video->vsync; + d3d12->frame.rgb32 = video->rgb32; + + if (!d3d12_init_context(d3d12)) + goto error; + + if (!d3d12_init_descriptors(d3d12)) + goto error; + + if (!d3d12_init_pipeline(d3d12)) + goto error; + + if(!d3d12_init_queue(d3d12)) + return false; + + if (!d3d12_init_swapchain(d3d12, video->width, video->height, main_window.hwnd)) + goto error; + + + { + d3d12_vertex_t vertices[] = + { + {{ -1.0f, -1.0f}, {0.0f, 1.0f}, {1.0f, 1.0f, 1.0f, 1.0f}}, + {{ -1.0f, 1.0f}, {0.0f, 0.0f}, {1.0f, 1.0f, 1.0f, 1.0f}}, + {{ 1.0f, -1.0f}, {1.0f, 1.0f}, {1.0f, 1.0f, 1.0f, 1.0f}}, + {{ 1.0f, 1.0f}, {1.0f, 0.0f}, {1.0f, 1.0f, 1.0f, 1.0f}}, + }; + + d3d12->frame.vbo_view.SizeInBytes = sizeof(vertices); + d3d12->frame.vbo_view.StrideInBytes = sizeof(*vertices); + d3d12_create_vertex_buffer(d3d12->device, &d3d12->frame.vbo_view, &d3d12->frame.vbo); + + { + void *vertex_data_begin; + D3D12_RANGE read_range = {0, 0}; + + D3D12Map(d3d12->frame.vbo, 0, &read_range, &vertex_data_begin); + memcpy(vertex_data_begin, vertices, sizeof(vertices)); + D3D12Unmap(d3d12->frame.vbo, 0, NULL); + } + + } + return d3d12; + +error: + RARCH_ERR("[D3D12]: failed to init video driver.\n"); + free(d3d12); + return NULL; +} + + +static bool d3d12_gfx_frame(void *data, const void *frame, + unsigned width, unsigned height, uint64_t frame_count, + unsigned pitch, const char *msg, video_frame_info_t *video_info) +{ + (void)msg; + + d3d12_video_t *d3d12 = (d3d12_video_t *)data; + D3D12_CPU_DESCRIPTOR_HANDLE rtvHandle; + + D3D12ResetCommandAllocator(d3d12->queue.allocator); + + D3D12ResetGraphicsCommandList(d3d12->queue.cmd, d3d12->queue.allocator, d3d12->pipe.handle); + D3D12SetGraphicsRootSignature(d3d12->queue.cmd, d3d12->pipe.rootSignature); + D3D12SetDescriptorHeaps(d3d12->queue.cmd, 1, &d3d12->pipe.srv_heap.handle); + + d3d12_transition(d3d12->queue.cmd, d3d12->chain.renderTargets[d3d12->chain.frame_index], + D3D12_RESOURCE_STATE_PRESENT, D3D12_RESOURCE_STATE_RENDER_TARGET); + + D3D12RSSetViewports(d3d12->queue.cmd, 1, &d3d12->chain.viewport); + D3D12RSSetScissorRects(d3d12->queue.cmd, 1, &d3d12->chain.scissorRect); + D3D12OMSetRenderTargets(d3d12->queue.cmd, 1, &d3d12->chain.desc_handles[d3d12->chain.frame_index], + FALSE, NULL); + D3D12ClearRenderTargetView(d3d12->queue.cmd, d3d12->chain.desc_handles[d3d12->chain.frame_index], + d3d12->chain.clearcolor, 0, NULL); + + D3D12IASetPrimitiveTopology(d3d12->queue.cmd, D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP); + + if (data && width && height) + { + if (!d3d12->frame.tex.handle || (d3d12->frame.tex.desc.Width != width) + || (d3d12->frame.tex.desc.Height = height)) + { + if (d3d12->frame.tex.handle) + Release(d3d12->frame.tex.handle); + + if (d3d12->frame.tex.upload_buffer) + Release(d3d12->frame.tex.upload_buffer); + + d3d12->frame.tex.desc.Width = width; + d3d12->frame.tex.desc.Height = height; + d3d12->frame.tex.desc.Format = d3d12->frame.rgb32 ? DXGI_FORMAT_B8G8R8A8_UNORM : + DXGI_FORMAT_B5G6R5_UNORM; + d3d12_create_texture(d3d12->device, &d3d12->pipe.srv_heap, 0, &d3d12->frame.tex); + } + + { + int i, j; + const uint8_t *in = frame; + uint8_t *out; + + D3D12Map(d3d12->frame.tex.upload_buffer, 0, NULL, &out); + out += d3d12->frame.tex.layout.Offset; + + for (i = 0; i < height; i++) + { + memcpy(out, in, width * (d3d12->frame.rgb32 ? 4 : 2)); + in += pitch; + out += d3d12->frame.tex.layout.Footprint.RowPitch; + } + + D3D12Unmap(d3d12->frame.tex.upload_buffer, 0, NULL); + } + + d3d12_upload_texture(d3d12->queue.cmd, &d3d12->frame.tex); + D3D12IASetVertexBuffers(d3d12->queue.cmd, 0, 1, &d3d12->frame.vbo_view); + D3D12SetGraphicsRootDescriptorTable(d3d12->queue.cmd, 0, + d3d12->frame.tex.gpu_descriptor); /* set texture */ + D3D12DrawInstanced(d3d12->queue.cmd, 4, 1, 0, 0); + } + + + if (d3d12->menu.enabled && d3d12->menu.tex.handle) + { + if(d3d12->menu.tex.dirty) + d3d12_upload_texture(d3d12->queue.cmd, &d3d12->menu.tex); +// D3D12IASetVertexBuffers(d3d12->queue.cmd, 0, 1, &d3d12->frame.vbo_view); + D3D12SetGraphicsRootDescriptorTable(d3d12->queue.cmd, 0, + d3d12->menu.tex.gpu_descriptor); /* set texture */ + D3D12DrawInstanced(d3d12->queue.cmd, 4, 1, 0, 0); + } + + + d3d12_transition(d3d12->queue.cmd, d3d12->chain.renderTargets[d3d12->chain.frame_index], + D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_PRESENT); + D3D12CloseGraphicsCommandList(d3d12->queue.cmd); + + D3D12ExecuteGraphicsCommandLists(d3d12->queue.handle, 1, &d3d12->queue.cmd); + +#if 1 + DXGIPresent(d3d12->chain.handle, !!d3d12->chain.vsync, 0); +#else + DXGI_PRESENT_PARAMETERS pp = {0}; + DXGIPresent1(d3d12->swapchain, 0, 0, &pp); +#endif + + /* wait_for_previous_frame */ + D3D12SignalCommandQueue(d3d12->queue.handle, d3d12->queue.fence, d3d12->queue.fenceValue); + + if (D3D12GetCompletedValue(d3d12->queue.fence) < d3d12->queue.fenceValue) + { + D3D12SetEventOnCompletion(d3d12->queue.fence, d3d12->queue.fenceValue, d3d12->queue.fenceEvent); + WaitForSingleObject(d3d12->queue.fenceEvent, INFINITE); + } + + d3d12->queue.fenceValue++; + d3d12->chain.frame_index = DXGIGetCurrentBackBufferIndex(d3d12->chain.handle); + + if (msg && *msg) + gfx_ctx_d3d.update_window_title(NULL, video_info); + + return true; +} + +static void d3d12_gfx_set_nonblock_state(void *data, bool toggle) +{ + d3d12_video_t *d3d12 = (d3d12_video_t *)data; + d3d12->chain.vsync = !toggle; +} + +static bool d3d12_gfx_alive(void *data) +{ + (void)data; + bool quit; + bool resize; + unsigned width; + unsigned height; + win32_check_window(&quit, &resize, &width, &height); + return true; +} + +static bool d3d12_gfx_focus(void *data) +{ + return win32_has_focus(); +} + +static bool d3d12_gfx_suppress_screensaver(void *data, bool enable) +{ + (void)data; + (void)enable; + return false; +} + +static bool d3d12_gfx_has_windowed(void *data) +{ + (void)data; + return true; +} + +static void d3d12_gfx_free(void *data) +{ + d3d12_video_t *d3d12 = (d3d12_video_t *)data; + + Release(d3d12->frame.vbo); + if (d3d12->frame.tex.handle) + Release(d3d12->frame.tex.handle); + if (d3d12->frame.tex.upload_buffer) + Release(d3d12->frame.tex.upload_buffer); + + if (d3d12->menu.tex.handle) + Release(d3d12->menu.tex.handle); + + if (d3d12->menu.tex.handle) + Release(d3d12->menu.tex.upload_buffer); + + Release(d3d12->pipe.srv_heap.handle); + Release(d3d12->pipe.rtv_heap.handle); + Release(d3d12->pipe.rootSignature); + Release(d3d12->pipe.handle); + + Release(d3d12->queue.fence); + Release(d3d12->chain.renderTargets[0]); + Release(d3d12->chain.renderTargets[1]); + Release(d3d12->chain.handle); + + Release(d3d12->queue.cmd); + Release(d3d12->queue.allocator); + Release(d3d12->queue.handle); + + Release(d3d12->factory); + Release(d3d12->device); + Release(d3d12->adapter); + + win32_monitor_from_window(); + win32_destroy_window(); + + free(d3d12); +} + +static bool d3d12_gfx_set_shader(void *data, + enum rarch_shader_type type, const char *path) +{ + (void)data; + (void)type; + (void)path; + + return false; +} + +static void d3d12_gfx_set_rotation(void *data, + unsigned rotation) +{ + (void)data; + (void)rotation; +} + +static void d3d12_gfx_viewport_info(void *data, + struct video_viewport *vp) +{ + (void)data; + (void)vp; +} + +static bool d3d12_gfx_read_viewport(void *data, uint8_t *buffer, bool is_idle) +{ + (void)data; + (void)buffer; + + return true; +} + +static void d3d12_set_menu_texture_frame(void *data, + const void *frame, bool rgb32, unsigned width, unsigned height, + float alpha) +{ + d3d12_video_t *d3d12 = (d3d12_video_t *)data; + + if (!d3d12->menu.tex.handle || (d3d12->menu.tex.desc.Width != width) + || (d3d12->menu.tex.desc.Height = height)) + { + if (d3d12->menu.tex.handle) + Release(d3d12->menu.tex.handle); + + if (d3d12->menu.tex.upload_buffer) + Release(d3d12->menu.tex.upload_buffer); + + d3d12->menu.tex.desc.Width = width; + d3d12->menu.tex.desc.Height = height; + d3d12->menu.tex.desc.Format = rgb32 ? DXGI_FORMAT_B8G8R8A8_UNORM : DXGI_FORMAT_B4G4R4A4_UNORM; + d3d12_create_texture(d3d12->device, &d3d12->pipe.srv_heap, 1, &d3d12->menu.tex); + } + + { + int i, j; + uint8_t *out; + + D3D12Map(d3d12->menu.tex.upload_buffer, 0, NULL, &out); + out += d3d12->menu.tex.layout.Offset; + + if(rgb32) + { + const uint32_t *in = frame; + for (i = 0; i < height; i++) + { + memcpy(out, in, width * sizeof(*in)); + in += width; + out += d3d12->menu.tex.layout.Footprint.RowPitch; + } + } + else + { + const uint16_t *in = frame; + for (i = 0; i < height; i++) + { + for (j = 0; j < width; j++) + { + unsigned r = ((in[j] >> 12) & 0xF); + unsigned g = ((in[j] >> 8) & 0xF); + unsigned b = ((in[j] >> 4) & 0xF); + unsigned a = ((in[j] >> 0) & 0xF); + + ((uint16_t*)out)[j] = (b << 0) | (g << 4) | (r << 8) |(a << 12); + } + in += width; + out += d3d12->menu.tex.layout.Footprint.RowPitch; + } + + } + + D3D12Unmap(d3d12->menu.tex.upload_buffer, 0, NULL); + } + d3d12->menu.tex.dirty = true; + d3d12->menu.alpha = alpha; +} +static void d3d12_set_menu_texture_enable(void *data, + bool state, bool full_screen) +{ + d3d12_video_t *d3d12 = (d3d12_video_t *)data; + + d3d12->menu.enabled = state; + d3d12->menu.fullscreen = full_screen; +} + + +static const video_poke_interface_t d3d12_poke_interface = +{ + NULL, /* set_coords */ + NULL, /* set_mvp */ + NULL, /* load_texture */ + NULL, /* unload_texture */ + NULL, /* set_video_mode */ + NULL, /* set_filtering */ + NULL, /* get_video_output_size */ + NULL, /* get_video_output_prev */ + NULL, /* get_video_output_next */ + NULL, /* get_current_framebuffer */ + NULL, /* get_proc_address */ + NULL, /* set_aspect_ratio */ + NULL, /* apply_state_changes */ + d3d12_set_menu_texture_frame, /* set_texture_frame */ + d3d12_set_menu_texture_enable, /* set_texture_enable */ + NULL, /* set_osd_msg */ + NULL, /* show_mouse */ + NULL, /* grab_mouse_toggle */ + NULL, /* get_current_shader */ + NULL, /* get_current_software_framebuffer */ + NULL, /* get_hw_render_interface */ +}; + +static void d3d12_gfx_get_poke_interface(void *data, + const video_poke_interface_t **iface) +{ + *iface = &d3d12_poke_interface; +} + +video_driver_t video_d3d12 = +{ + d3d12_gfx_init, + d3d12_gfx_frame, + d3d12_gfx_set_nonblock_state, + d3d12_gfx_alive, + d3d12_gfx_focus, + d3d12_gfx_suppress_screensaver, + d3d12_gfx_has_windowed, + d3d12_gfx_set_shader, + d3d12_gfx_free, + "d3d12", + NULL, /* set_viewport */ + d3d12_gfx_set_rotation, + d3d12_gfx_viewport_info, + d3d12_gfx_read_viewport, + NULL, /* read_frame_raw */ + +#ifdef HAVE_OVERLAY + NULL, /* overlay_interface */ +#endif + d3d12_gfx_get_poke_interface, +}; diff --git a/gfx/drivers/d3d_shaders/opaque_sm5.hlsl.h b/gfx/drivers/d3d_shaders/opaque_sm5.hlsl.h new file mode 100644 index 0000000000..f0e7b13bc9 --- /dev/null +++ b/gfx/drivers/d3d_shaders/opaque_sm5.hlsl.h @@ -0,0 +1,25 @@ + +#define SRC(src) #src +SRC( + struct PSInput + { + float4 position : SV_POSITION; + float2 texcoord : TEXCOORD0; + float4 color : COLOR; + }; + PSInput VSMain(float4 position : POSITION, float2 texcoord : TEXCOORD0, float4 color : COLOR) + { + PSInput result; + result.position = position; + result.texcoord = texcoord; + result.color = color; + return result; + } + uniform sampler s0; + uniform Texture2D t0; + float4 PSMain(PSInput input) : SV_TARGET + { + return input.color * t0.Sample(s0, input.texcoord); +// return input.color; + }; +) diff --git a/gfx/video_driver.c b/gfx/video_driver.c index 053b32d3c4..cf19329940 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -262,6 +262,12 @@ static const video_driver_t *video_drivers[] = { #ifdef XENON &video_xenon360, #endif +#if defined(HAVE_D3D11) + &video_d3d11, +#endif +#if defined(HAVE_D3D12) + &video_d3d12, +#endif #if defined(HAVE_D3D) &video_d3d, #endif diff --git a/gfx/video_driver.h b/gfx/video_driver.h index c2102c5051..af527041b8 100644 --- a/gfx/video_driver.h +++ b/gfx/video_driver.h @@ -1336,6 +1336,8 @@ extern video_driver_t video_vita2d; extern video_driver_t video_ctr; extern video_driver_t video_switch; extern video_driver_t video_d3d; +extern video_driver_t video_d3d11; +extern video_driver_t video_d3d12; extern video_driver_t video_gx; extern video_driver_t video_wiiu; extern video_driver_t video_xenon360; diff --git a/griffin/griffin.c b/griffin/griffin.c index 53d450061b..5fb22f0b24 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -345,6 +345,14 @@ VIDEO DRIVER #endif +#if defined(HAVE_D3D11) +#include "../gfx/drivers/d3d11.c" +#endif + +#if defined(HAVE_D3D12) +#include "../gfx/drivers/d3d12.c" +#endif + #if defined(GEKKO) #ifdef HW_RVL #include "../gfx/drivers/gx_gfx_vi_encoder.c" From 6b9dc2205b3cc2710d0ad2fb65556ac47b757f5d Mon Sep 17 00:00:00 2001 From: aliaspider Date: Sun, 21 Jan 2018 04:12:01 +0100 Subject: [PATCH 2/3] (MSVC) add Makefile.msvc --- Makefile.msvc | 271 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 271 insertions(+) create mode 100644 Makefile.msvc diff --git a/Makefile.msvc b/Makefile.msvc new file mode 100644 index 0000000000..0bacd323d0 --- /dev/null +++ b/Makefile.msvc @@ -0,0 +1,271 @@ +TARGET := retroarch.exe +DEBUG = 0 +GRIFFIN_BUILD = 0 +OS = Win32 +ARCH = amd64 +#TARGET_ARCH = x86 +BUILD_DIR = objs/msvc + + +HAVE_D3DX := 1 +HAVE_D3D8 := 0 +HAVE_D3D9 := 1 +HAVE_D3D11 := 1 +HAVE_D3D12 := 1 +HAVE_CG := 1 +HAVE_OPENGL := 1 + +HAVE_RPNG := 1 +HAVE_ZLIB := 1 +WANT_ZLIB := 1 +HAVE_RGUI := 1 +HAVE_XMB := 1 +HAVE_MATERIALUI := 1 +HAVE_STB_FONT := 1 +HAVE_THREADS := 1 +HAVE_LIBRETRODB := 1 +HAVE_COMMAND := 1 +HAVE_STDIN_CMD := 1 +HAVE_CMD := 1 +HAVE_DYLIB := 1 +HAVE_DYNAMIC := 1 +HAVE_DINPUT := 1 +HAVE_MENU_COMMON := 1 +HAVE_BUILTINZLIB := 1 + +HAVE_RJPEG := 1 +HAVE_RBMP := 1 +HAVE_RTGA := 1 +HAVE_7ZIP := 1 +HAVE_NETWORKING := 1 +HAVE_NETWORK_CMD := 1 +HAVE_OVERLAY := 1 +HAVE_LANGEXTRA := 1 +HAVE_CHEEVOS := 1 +HAVE_KEYMAPPER := 1 + +ifeq ($(ARCH),x64) + ARCH := amd64 +endif + +ARCH2 := $(ARCH) +ifeq ($(ARCH),amd64) + ARCH2 := x64 +endif + +ifeq ($(TARGET_ARCH),) + TARGET_ARCH = $(ARCH) +endif + +ifeq ($(TARGET_ARCH),x64) + TARGET_ARCH = amd64 +endif + +TARGET_ARCH2 = $(TARGET_ARCH) +ifeq ($(TARGET_ARCH2),amd64) + TARGET_ARCH2 = x64 +endif + +CROSS = $(ARCH) +ifeq ($(ARCH),x86) +CROSS = +endif + + +WindowsSdkDir = C:\Program Files (x86)\Windows Kits\10\$(NOTHING) +WindowsSDKVersion := 10.0.14393.0\$(NOTHING) +VCINSTALLDIR := C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\$(NOTHING) + +INCLUDE := $(VCINSTALLDIR)include;$(VCINSTALLDIR)atlmfc\include;$(WindowsSdkDir)include\$(WindowsSDKVersion)ucrt;$(WindowsSdkDir)include\$(WindowsSDKVersion)shared;$(WindowsSdkDir)include\$(WindowsSDKVersion)um; +LIB := $(VCINSTALLDIR)LIB\$(CROSS);$(VCINSTALLDIR)atlmfc\lib\$(CROSS);$(WindowsSdkDir)lib\$(WindowsSDKVersion)ucrt\$(TARGET_ARCH2);$(WindowsSdkDir)lib\$(WindowsSDKVersion)um\$(TARGET_ARCH2);C:\Program Files (x86)\NVIDIA Corporation\Cg\lib.$(TARGET_ARCH2);C:\Program Files (x86)\Microsoft DirectX SDK (February 2010)\Lib\$(TARGET_ARCH2); +LIBPATH := $(VCINSTALLDIR)LIB\$(CROSS);$(VCINSTALLDIR)atlmfc\lib\$(CROSS); + +PATH := $(shell IFS=$$'\n'; cygpath "$(VCINSTALLDIR)bin\\$(CROSS)"):$(shell IFS=$$'\n'; cygpath "$(WindowsSdkDir)\bin\\$(ARCH2)"):$(PATH) + + +export INCLUDE := $(INCLUDE) +export LIB := $(LIB) +export LIBPATH := $(LIBPATH) +export PATH := $(PATH) + +#$(info WindowsSdkDir : $(WindowsSdkDir)) +#$(info WindowsSDKVersion : $(WindowsSDKVersion)) +#$(info VCINSTALLDIR : $(VCINSTALLDIR)) +#$(info INCLUDE : $(INCLUDE)) +#$(info LIB : $(LIB)) +#$(info LIBPATH : $(LIBPATH)) +#$(info PATH : $(PATH)) +#$(error end) + +DEFINES := +ifeq ($(TARGET_ARCH),x64) +DEFINES += -D__x86_64__ +else +#DEFINES += -D__i686__ +endif + +FLAGS += -nologo -MP +FLAGS += -Gm- -Zc:inline -fp:precise -Zc:forScope -GR- -Gd -Oi -volatile:iso +#FLAGS += -Zc:wchar_t -Zp16 -Z7 +#FLAGS += -utf-8 +#FLAGS += -source-charset:utf-8 + + +CFLAGS += -TC +CXXFLAGS += -TP +WARNINGS += -WX -W3 +WARNINGS += -wd4101 -wd4996 -wd4244 -wd4267 -wd4090 -wd4305 -wd4146 -wd4334 -wd4018 + +CC = cl.exe +CXX = cl.exe +LD = link.exe +RC = rc.exe + +LIBS += shell32.lib user32.lib gdi32.lib comdlg32.lib winmm.lib ole32.lib +LDFLAGS += -nologo -wx -nxcompat -machine:$(TARGET_ARCH2) + + +ifeq ($(DEBUG),1) +FLAGS += -GS -Gy -Od -RTC1 -D_SECURE_SCL=1 -Zi +FLAGS += -MDd +LDFLAGS += -DEBUG +DEFINES += -DDEBUG -D_DEBUG +#LIBS += -ld3d9 -ld3dx9d + +else +FLAGS += -GS- -Gy- -O2 -Ob2 -GF -GT -Oy -Ot -D_SECURE_SCL=0 +FLAGS += -MD +#LIBS += -ld3d9 -ld3dx9 + +endif + + +ifeq ($(DEBUG),1) + BUILD_DIR := $(BUILD_DIR)-debug +endif + +ifeq ($(GRIFFIN_BUILD),1) + BUILD_DIR := $(BUILD_DIR)-griffin +endif + +BUILD_DIR := $(BUILD_DIR)-$(TARGET_ARCH2) + +ifneq ($(V), 1) + Q := @ +endif + + +OBJ := +include Makefile.common + +ifeq ($(GRIFFIN_BUILD), 1) + OBJ := griffin/griffin.o + DEFINES_BLACKLIST := -DHAVE_COMPRESSION + DEFINES := $(filter-out $(DEFINES_BLACKLIST),$(DEFINES)) + DEFINES += -DHAVE_GRIFFIN -DUSE_MATH_DEFINES +else + DEFINES += -DJSON_STATIC + BLACKLIST := + OBJ := $(filter-out $(BLACKLIST),$(OBJ)) +endif + +DEFINES += -DRARCH_INTERNAL -DHAVE_DYNAMIC +INCLUDE_DIRS += -I. -Igfx/include + +#OBJ := version_git.o + +OBJ := $(patsubst %rarch.o,%rarch.res,$(OBJ)) +OBJ := $(addprefix $(BUILD_DIR)/,$(OBJ)) +OBJ := $(OBJ:.o=.obj) + +#INCDIRS := -I. -Ideps -Ideps/stb -Ideps/libz -Ideps/7zip -Ilibretro-common/include + + +#CFLAGS = $(FLAGS) +#CXXFLAGS = $(FLAGS) +LDFLAGS += -WX -SUBSYSTEM:WINDOWS -ENTRY:mainCRTStartup + +DEFINES := $(patsubst -f%,,$(DEFINES)) +LDFLAGS := $(patsubst -l%,%.lib,$(LDFLAGS)) +LIBS := $(filter-out -lm,$(LIBS)) +LIBS := $(patsubst -l%,%.lib,$(LIBS)) + + +#$(info INCLUDE_DIRS : $(INCLUDE_DIRS)) +#$(info DEFINES : $(DEFINES)) +#$(info CFLAGS : $(CFLAGS)) +#$(info CXXFLAGS : $(CXXFLAGS)) +#$(info LDFLAGS : $(LDFLAGS)) +#$(info LIBS : $(LIBS)) +#$(info OBJ : $(OBJ)) +#$(info target : $(TARGET)) +#$(info flags : $(FLAGS)) +#$(info INCLUDE : $(INCLUDE)) +#$(info LIB : $(LIB)) +#$(info LIBPATH : $(LIBPATH)) +#$(error end) + +$(info os : $(OS)) +$(info host : $(ARCH)) +$(info target : $(TARGET_ARCH)) + +all: $(TARGET) + +%: $(BUILD_DIR)/% + cp $< $@ + +ifeq ($(DEBUG),1) +%.exe: $(BUILD_DIR)/%.exe + cp $< $@ + cp $(BUILD_DIR)/$*.pdb $*.pbd +endif + +SHELL:=$(SHELL) -o pipefail + +DEPFLAGS = -showIncludes | tee $(BUILD_DIR)/$*.dtemp | sed /'Note: including file:'/d +MAKEDEPS = echo $@: $< \\ > $(BUILD_DIR)/$*.depend && \ + grep 'Note: including file:' $(BUILD_DIR)/$*.dtemp \ + | sed '/$(subst \,\\,$(WindowsSdkDir))/Id; /$(subst \,\\,$(VCINSTALLDIR))/Id; s/Note: including file:[ ]*//g; s/\\/\//g; s/ /\\ /g; s/.*/ & \\/g' \ + >> $(BUILD_DIR)/$*.depend && \ + rm -f $(BUILD_DIR)/$*.dtemp + +#DEPFLAGS := +#MAKEDEPS := + +$(BUILD_DIR)/%.obj: %.cpp + @$(if $(Q), echo CXX $<,) + @mkdir -p $(dir $@) + $(Q)$(CXX) -c -Fo:$@ $< $(FLAGS) $(CXXFLAGS) $(DEFINES) $(INCLUDE_DIRS) $(WARNINGS) $(DEPFLAGS) + @$(MAKEDEPS) + +$(BUILD_DIR)/%.obj: %.c + @$(if $(Q), echo CC $<,) + @mkdir -p $(dir $@) + $(Q)$(CC) -c -Fo:$@ $< $(FLAGS) $(CFLAGS) $(DEFINES) $(INCLUDE_DIRS) $(WARNINGS) $(DEPFLAGS) + @$(MAKEDEPS) + +$(BUILD_DIR)/%.res: %.rc + @$(if $(Q), echo RC $<,) + @mkdir -p $(dir $@) + $(Q)$(RC) $< + $(Q)mv $*.res $@ + +$(BUILD_DIR)/$(TARGET): $(OBJ) .$(TARGET).last + @$(if $(Q), echo LD $@,) + @touch .$(TARGET).last + $(Q)$(LD) $(OBJ) $(LDFLAGS) $(LIBS) -out:$(BUILD_DIR)/$(TARGET) + + +%.depend: ; +%.last: ; + +clean: + rm -f $(OBJ) $(TARGET) + rm -f $(BUILD_DIR)/$(TARGET) + rm -f .$(TARGET).last + rm -f $(OBJ:.obj=.depend) + +.PHONY: clean all +.PRECIOUS: %.depend %.last + +-include $(patsubst %.obj,%.depend,$(filter %.obj,$(OBJ))) From c8027ebe1d83bd600841e3e4aa183f4aacf46bcb Mon Sep 17 00:00:00 2001 From: aliaspider Date: Sun, 21 Jan 2018 04:28:06 +0100 Subject: [PATCH 3/3] (tools) add the tool used to generate the d3d headers. --- {wiiu/slang => deps/peglib}/peglib.h | 24 +- tools/com-parser/Makefile | 160 ++++++ tools/com-parser/com-parse.cpp | 775 +++++++++++++++++++++++++++ tools/com-parser/grammar.txt | 30 ++ wiiu/wiiu_dbg.h | 14 +- 5 files changed, 995 insertions(+), 8 deletions(-) rename {wiiu/slang => deps/peglib}/peglib.h (99%) create mode 100644 tools/com-parser/Makefile create mode 100644 tools/com-parser/com-parse.cpp create mode 100644 tools/com-parser/grammar.txt diff --git a/wiiu/slang/peglib.h b/deps/peglib/peglib.h similarity index 99% rename from wiiu/slang/peglib.h rename to deps/peglib/peglib.h index 20b5080e1b..d5a5f05321 100644 --- a/wiiu/slang/peglib.h +++ b/deps/peglib/peglib.h @@ -1,4 +1,4 @@ -// +// // peglib.h // // Copyright (c) 2015-17 Yuji Hirose. All rights reserved. @@ -2238,6 +2238,20 @@ struct AstBase : public Annotation std::vector>> nodes; std::shared_ptr> parent; + static peg::AstBase empty; + AstBase& operator [] (const char* name) + { + for(std::shared_ptr>& node : nodes) + { + if(node->name == name) + return *node; + } + return empty; + } + operator const char *() + { + return token.c_str(); + } }; template @@ -2770,6 +2784,14 @@ private: } // namespace peg + +template +std::basic_ios<_Elem, _Traits> &operator << (std::basic_ios<_Elem, _Traits> &ios, + peg::AstBase &node) +{ + return ios << node.token.c_str(); +} + #endif // vim: et ts=4 sw=4 cin cino={1s ff=unix diff --git a/tools/com-parser/Makefile b/tools/com-parser/Makefile new file mode 100644 index 0000000000..71ed3df303 --- /dev/null +++ b/tools/com-parser/Makefile @@ -0,0 +1,160 @@ + +TARGET = com-parse +DEBUG = 0 +GENDEPS = 1 +TARGET_ARCH = amd64 +OS ?= win32 + + +OBJ := +OBJ += com-parse.o + + + +EXE_EXT := $(suffix $(wildcard $(MAKE).*)) + +ifeq ($(compiler),) + ifeq ($(patsubst %.exe,%,$(basename $(CC))),cl) + compiler = msvc + else + compiler = gcc + endif +endif + +CC_OUT = -o $(NOTHING) +CXX_OUT = $(CC_OUT) +LD_OUT = $(CC_OUT) +OBJ_EXT := o + +ifeq ($(DEBUG),1) + DEFINES += -DDEBUG -D_DEBUG +endif + +ifeq ($(compiler),msvc) + ARCH = amd64 + ARCH2 = x64 + TARGET_ARCH2 = x64 + CROSS = amd64 + WindowsSdkDir = C:\Program Files (x86)\Windows Kits\10\$(NOTHING) + WindowsSDKVersion := 10.0.14393.0\$(NOTHING) + VCINSTALLDIR := C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\$(NOTHING) + + INCLUDE := $(VCINSTALLDIR)include;$(VCINSTALLDIR)atlmfc\include;$(WindowsSdkDir)include\$(WindowsSDKVersion)ucrt;$(WindowsSdkDir)include\$(WindowsSDKVersion)shared;$(WindowsSdkDir)include\$(WindowsSDKVersion)um; + LIB := $(VCINSTALLDIR)LIB\$(CROSS);$(VCINSTALLDIR)atlmfc\lib\$(CROSS);$(WindowsSdkDir)lib\$(WindowsSDKVersion)ucrt\$(TARGET_ARCH2);$(WindowsSdkDir)lib\$(WindowsSDKVersion)um\$(TARGET_ARCH2);C:\Program Files (x86)\NVIDIA Corporation\Cg\lib.$(TARGET_ARCH2);C:\Program Files (x86)\Microsoft DirectX SDK (February 2010)\Lib\$(TARGET_ARCH2); + LIBPATH := $(VCINSTALLDIR)LIB\$(CROSS);$(VCINSTALLDIR)atlmfc\lib\$(CROSS); + + PATH := $(shell IFS=$$'\n'; cygpath "$(VCINSTALLDIR)bin\\$(CROSS)"):$(shell IFS=$$'\n'; cygpath "$(WindowsSdkDir)\bin\\$(ARCH2)"):$(PATH) + + export INCLUDE := $(INCLUDE) + export LIB := $(LIB) + export LIBPATH := $(LIBPATH) + export PATH := $(PATH) + + DEFINES := + FLAGS += -nologo + FLAGS += -Gm- -Zc:inline -fp:precise -Zc:forScope -Gd -Oi -volatile:iso + #FLAGS += -GR- + CFLAGS += -TC + CXXFLAGS += -TP -EHsc + WARNINGS += -WX -W3 + WARNINGS += -wd4101 -wd4996 -wd4244 -wd4267 -wd4090 -wd4305 -wd4146 -wd4334 -wd4018 + + CC = cl.exe + CXX = cl.exe + LD = link.exe + RC = rc.exe + LIBS += shell32.lib user32.lib gdi32.lib comdlg32.lib winmm.lib ole32.lib + LDFLAGS += -nologo -wx -nxcompat -machine:$(TARGET_ARCH2) + ifeq ($(DEBUG),1) + FLAGS += -GS -Gy -Od -RTC1 -D_SECURE_SCL=1 -Zi + FLAGS += -MDd + LDFLAGS += -DEBUG + DEFINES += -DDEBUG -D_DEBUG + else + FLAGS += -GS- -Gy- -O2 -Ob2 -GF -GT -Oy -Ot -D_SECURE_SCL=0 + FLAGS += -MD + endif + OBJ := $(OBJ:.o=.obj) + LDFLAGS += -WX -SUBSYSTEM:WINDOWS -ENTRY:mainCRTStartup + DEFINES := $(patsubst -f%,,$(DEFINES)) + LDFLAGS := $(patsubst -l%,%.lib,$(LDFLAGS)) + LIBS := $(filter-out -lm,$(LIBS)) + LIBS := $(patsubst -l%,%.lib,$(LIBS)) + DEPFLAGS = -showIncludes | tee $*.dtemp | sed /'Note: including file:'/d + MAKEDEPS = echo $@: $< \\ > $*.depend && \ + grep 'Note: including file:' $*.dtemp \ + | sed '/$(subst \,\\,$(WindowsSdkDir))/Id; /$(subst \,\\,$(VCINSTALLDIR))/Id; s/Note: including file:[ ]*//g; s/\\/\//g; s/ /\\ /g; s/.*/ & \\/g' \ + >> $*.depend && \ + rm -f $*.dtemp + + OBJ_EXT := obj + CC_OUT := -Fo: + CXX_OUT := $(CC_OUT) + LD_OUT := -out: +else + RC := windres + DEPFLAGS = -MT $@ -MMD -MP -MF $(BUILD_DIR)$*.depend + LD = $(CXX) + ifeq ($(DEBUG),1) + FLAGS += -g -O0 + else + FLAGS += -O3 + endif +endif + + +INCLUDE_DIRS += -I. -I../../deps/peglib + + +$(info os : $(OS)) +$(info host : $(ARCH)) +$(info target : $(TARGET_ARCH)) +$(info compiler : $(compiler)) + +all: $(TARGET)$(EXE_EXT) + +%.h: + touch $*.tmp + $(CXX) $*.tmp -DCINTERFACE -D_REFIID_DEFINED= -D_REFGUID_DEFINED= -D_HRESULT_DEFINED= \ + -EP -FI $@ $(FLAGS) $(CXXFLAGS) $(DEFINES) $(INCLUDE_DIRS) $(WARNINGS) > $@ + rm $*.tmp + +SHELL:=$(SHELL) -o pipefail + + +ifeq ($(GENDEPS),0) + DEPFLAGS := + MAKEDEPS := +endif + +%.$(OBJ_EXT): %.cpp + $(CXX) -c $(CXX_OUT)$@ $< $(FLAGS) $(CXXFLAGS) $(DEFINES) $(INCLUDE_DIRS) $(WARNINGS) $(DEPFLAGS) + @$(MAKEDEPS) + +%.$(OBJ_EXT): %.c + $(CC) -c $(CC_OUT)$@ $< $(FLAGS) $(CFLAGS) $(DEFINES) $(INCLUDE_DIRS) $(WARNINGS) $(DEPFLAGS) + @$(MAKEDEPS) + +%.res: %.rc + $(RC) $< + mv $*.res $@ + +$(TARGET)$(EXE_EXT): $(OBJ) .$(TARGET).last + @touch .$(TARGET).last + $(LD) $(OBJ) $(LDFLAGS) $(LIBS) $(LD_OUT)$@ + + +%.depend: ; +%.last: ; +.FORCE: + +clean: + rm -f $(OBJ) $(TARGET)$(EXE_EXT) + rm -f $(TARGET) + rm -f .$(TARGET).last + rm -f $(OBJ:.obj=.depend) + +.PHONY: clean all +.PRECIOUS: %.depend %.last + +-include $(patsubst %.obj,%.depend,$(filter %.obj,$(OBJ))) diff --git a/tools/com-parser/com-parse.cpp b/tools/com-parser/com-parse.cpp new file mode 100644 index 0000000000..229be04e89 --- /dev/null +++ b/tools/com-parser/com-parse.cpp @@ -0,0 +1,775 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2014-2018 - Ali Bouhlel + * + * RetroArch is free software: you can redistribute it and/or modify it under the terms + * of the GNU General Public License as published by the Free Software Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with RetroArch. + * If not, see . + */ + + +#include +#include +#include +#include +#include + +using namespace peg; +using namespace std; + +template +AstBase AstBase::empty = AstBase("", 0, 0, "", string("")); + + +//bool use_typedefs = false; +bool use_typedefs = true; + +//const char* prefix_seperator = "_"; +const char* prefix_seperator = ""; + +vector ignored_fn_prefixes_list = +{ + "OM", + "IA", + "RS", +}; + +vector fn_prefixes_list = +{ + "OM", + "IA", + "RS", + "VS", + "PS", + "GS", + "DS", + "CS", +}; + +bool move_fn_prefix_after_action = true; + +vector ignored_types_list = +{ + "AsyncIUnknown", + "IMarshal", + "IMalloc", + "IEnumString", + "ISequentialStream", + "IStream", + "IRpcChannelBuffer", + "IAsyncRpcChannelBuffer", + "IRpcProxyBuffer", + "IServerSecurity", + "IRpcOptions", + "IGlobalOptions", + "ISurrogate", + "ISynchronize", + "ISynchronizeEvent", + "IDataObject", + "IDataAdviseHolder", + "IDirectWriterLock", + "IDummyHICONIncluder", + "IDispatch", + "IDropSource", + "IDropTarget", + "IDataFilter", + "IDropSourceNotify", +}; + +const char* required_prefix = "ID"; + +vector ignored_functions_list = +{ + "Release", + "QueryInterface", + "AddRef", + "GetParent", + "GetAdapter", + "GetDevice", + "GetDesc", + "GetType", + "SetName", + "SetPrivateDataInterface", + "SetPrivateData", + "GetPrivateData", + + "OpenSharedHandle", + "CreateSharedHandle", + "OpenSharedHandleByName", + + "SetTrackingOptions", +}; + +vector overloaded_list = +{ + "Release", + "QueryInterface", + "AddRef", + "GetParent", + "GetAdapter", + "GetDesc", + "GetType", + "SetName", + "SetPrivateDataInterface", + "SetPrivateData", + "GetPrivateData", + "Reset", + "Signal", + "BeginEvent", + "EndEvent", + "SetMarker", + "AssertResourceState", + "GetFeatureMask", + "SetFeatureMask", + "GetFrameStatistics", + "Close", + "SetEvictionPriority", + "GetEvictionPriority", + "GetResource", + "GetDataSize", + "GetContextFlags", + "GetCertificate", + "GetCertificateSize", +}; + +vector action_list = +{ + "Release", + "Get", + "Set", + "Enum", + "Get", + "Query", + "Add", + "Signal", + "Begin", + "End", + "Assert", + "Close", + "Map", + "Unmap" +}; + +vector derived_types_list = +{ + "ID3D12Device", + "ID3D12Debug", + "ID3D12DebugDevice", + "ID3D12DebugCommandList", + "IDXGIFactory1", + "IDXGIAdapter1", + "IDXGISurface1", + "IDXGISwapChain3", + "IDXGIOutput", + "IDXGIDevice", +}; + +vector base_objects_list = +{ + "IUnknown", + "ID3D12Object", + "ID3D12Resource", + "IDXGIObject", + "IDXGIResource", + "D3D11Resource", +}; + +//string insert_name(const char* fname, const char* name) +string insert_name(const string& fname, const string& name) +{ + string str; + for(string action: action_list) + { + if(!strncmp(fname.c_str(), action.c_str(), action.length())) + { + if(name.length() == 2 && name[1] == 'S') + { + if(!strncmp(fname.c_str() + action.length(), "Shader", strlen("Shader"))) + return action + name[0] + (fname.c_str() + action.length()); + else + return action + name[0] + "Shader" + (fname.c_str() + action.length()); + } + else + return action + name + (fname.c_str() + action.length()); + } + } + return string(fname) + name; + +} +//string insert_name(string fname, string name) +//{ +// return insert_name(fname.c_str(), name.c_str()); +//} + +string get_derived_basename(const char *name) +{ + string str = name; + if(::isdigit(str.back())) + str.pop_back(); + + return str; +} + +string get_derived_basename(string name) +{ + return get_derived_basename(name.c_str()); +} + +string get_prefix(const char *type) +{ + string prefix; + + if(*type != 'I') + return type; + + type++; + + while (::isalnum(*type) && !::islower(*type)) + prefix.push_back(*type++); + + prefix.pop_back(); + + return prefix; +} + +string get_prefix(const string &type) +{ + return get_prefix(type.c_str()); +} + + +string clean_name(const char *name) +{ + string str; + + if (name[0] == 'p' && name[1] == 'p' && name[2] == 'v' && ::isupper(name[3])) + name += 3; + if (name[0] == 'p' && name[1] == 'p' && ::isupper(name[2])) + name += 2; + else if ((*name == 'p' || *name == 'b') && ::isupper(name[1])) + name ++; + + bool was_upper = false; + if (*name) + { + if (::isupper(*name)) + { + was_upper = true; + str = (char)::tolower(*name); + } + else + str = *name; + } + + while (*++name) + { + if (::isupper(*name)) + { + if(!was_upper && !::isdigit(str.back())) + str = str + '_'; + + was_upper = true; + str += (char)::tolower(*name); + } + else + { + was_upper = false; + str += *name; + } + } + + if(str == "enum") + str = "enumerator"; + + return str; +} + +struct name_pair{ + string name; + string original; +}; + +class ComFunction +{ +public: + struct param_t + { + name_pair type; + name_pair ptr; + name_pair name; + int array_size = 0; + bool const_ = false; + bool base = false; + bool derived = false; + }; + param_t this_; + vector params; + string riid; + + string name; + string original_name; + string return_type; + string prefix; + + bool overloaded = false; + bool ignored = false; + bool preferred = false; + + ComFunction(Ast node) + { + original_name = node["FunctionName"]; + return_type = node["ReturnType"]; + + for (auto param_ : node["Parameters"].nodes) + { + Ast ¶m = *param_; + param_t p; + p.type.original = param["Type"]["Name"]; + p.const_ = param["Type"]["TypeQualifier"] == "const"; + + if(p.type.original == "REFIID") + { + riid = string("I") + prefix; + continue; + } + if(!riid.empty()) + { + if(param["Name"][2] == 'v') + riid += param["Name"] + 3; + else + riid += param["Name"] + 2; + break; + } + + p.ptr.original = param["Type"]["Pointer"]; + p.ptr.name = p.ptr.original; + + if(use_typedefs && + (prefix.empty() || (p.type.original[0] == 'I' && !strncmp(p.type.original.c_str() + 1, prefix.c_str(), prefix.length()))) + ) + { + p.type.name = p.type.original.c_str() + 1; + if(::isdigit(p.type.name.back())) + p.type.name.pop_back(); + + if(!p.ptr.name.empty()) + p.ptr.name.pop_back(); + } + else + { + p.type.name = p.type.original; + p.ptr.name = p.ptr.name; + } + + if (param.name == "This") + { + prefix = get_prefix(p.type.original); + p.name.original = param["Type"]["Name"] + 1 + prefix.length(); + p.name.name = clean_name(p.name.original.c_str()); + if(::isdigit(p.name.name.back())) + p.name.name.pop_back(); + + this_ = p; + } + else + { + p.name.original = param["Name"]; + p.name.name = clean_name(p.name.original.c_str()); + p.array_size = ::strtoul(param["ArraySize"], NULL, 10); + params.push_back(p); + } + + } + + if(original_name == "GetCPUDescriptorHandleForHeapStart") + { + param_t p; + p.type.name = p.type.original = return_type; + p.ptr.name = p.ptr.original = "*"; + return_type = "void"; + p.name.name = p.name.original = "out"; + params.push_back(p); + } + + for(string str : ignored_functions_list) + if(original_name == str) + ignored = true; + + for(string str : ignored_types_list) + if(get_derived_basename(this_.type.original) == get_derived_basename(str)) + ignored = true; + + if(required_prefix) + if(strncmp(this_.type.original.c_str(), required_prefix, strlen(required_prefix))) + ignored = true; + + for(string str : derived_types_list) + { + if(get_derived_basename(this_.type.original) == get_derived_basename(str)) + { + this_.derived = true; + if(this_.type.original != str) + ignored = true; + } + for (param_t ¶m : params) + if(get_derived_basename(param.type.original) == get_derived_basename(str)) + { + if(param.type.original != str) + param.derived = true; + else + { +// cout << param.type.original << endl; + preferred = true; + } + } + } + + for(string str : overloaded_list) + if(original_name == str) + overloaded = true; + + for(string str : base_objects_list) + { + if(this_.type.original == str) + this_.base = true; + for (param_t ¶m : params) + if(param.type.original == str) + param.base = true; + + } + + name = prefix + prefix_seperator; + + if(overloaded && !this_.base) + { + name += insert_name(original_name, this_.name.original); + if(::isdigit(name.back())) + name.pop_back(); + } + else + { + string fn_prefix; + for (string& str : ignored_fn_prefixes_list) + if(!strncmp(original_name.c_str(), str.c_str(), str.length())) + { + if(::isupper(original_name[str.length()])) + fn_prefix = str; + break; + } + if(!fn_prefix.empty()) + { + name += original_name.c_str() + fn_prefix.length(); + } + else + { + for (string str : fn_prefixes_list) + if(!strncmp(original_name.c_str(), str.c_str(), str.length())) + { + if(::isupper(original_name[str.length()])) + fn_prefix = str; + break; + } + if(!fn_prefix.empty()) + name += insert_name(original_name.c_str() + fn_prefix.length(), fn_prefix.c_str()); + else + name += original_name; + } + } + +// if(original_name == "CreateCommandQueue" && ignored) +// cout << "ignored CreateCommandQueue !!" << __LINE__ << endl; + + } + string str() + { + stringstream out; + out << "static inline " << return_type << " " << name << "("; + + if(this_.base) + out << "void*"; + else + out << this_.type.name << this_.ptr.name; + + out << " " << this_.name.name; + + for (param_t ¶m : params) + { + out << ", "; + + if(param.const_) + out << "const "; + + if(param.base) + out << "void*"; + else + out << param.type.name << param.ptr.name; + + out << " " << param.name.name; + if(param.array_size) + out << '[' << param.array_size << ']'; + + } + if(!riid.empty()) + out << ", " << riid << "** out"; + + out << ")\n{\n"; + out << " "; + + if (return_type != "void") + out << "return "; + + if(original_name == "GetCPUDescriptorHandleForHeapStart") + out << "((void (STDMETHODCALLTYPE *)(ID3D12DescriptorHeap*, D3D12_CPU_DESCRIPTOR_HANDLE*))\n "; + + if(this_.base) + out << "((" << this_.type.original << this_.ptr.original << ')' << this_.name.name << ')'; + else + out << this_.name.name; + + out << "->lpVtbl->" << original_name; + + if(original_name == "GetCPUDescriptorHandleForHeapStart") + out << ')'; + + out << '(' << this_.name.name; + + for (param_t param : params) + { + out << ", "; + + if(param.base || param.derived) + out << '(' << param.type.original << param.ptr.original << ')'; + + out << param.name.name; + } + + if(!riid.empty()) + out << ", __uuidof(" << riid << "), (void**)out"; + + out << ");\n"; + out << "}\n"; + return out.str(); + } + + +}; +class ComHeader +{ +public: + shared_ptr ast; + vector functions; + vector types; + ComHeader(const char *filename) + { + string header; + { + ifstream fs(filename); +#if 0 + stringstream ss; + ss << fs.rdbuf(); + header = ss.str(); +#else + while (!fs.eof()) + { + char line[4096]; + fs.getline(line, sizeof(line)); + char* str = line; + while (*str && ::isspace(*str)) + str++; + if (*str && !strncmp(str, "typedef struct ", strlen("typedef struct "))) + { + if(*str && strstr(str, "Vtbl")) + { + header += str; + header.push_back('\n'); + while(*line) + { + fs.getline(line, sizeof(line)); + str = line; + while (*str && ::isspace(*str)) + str++; + if(*str) + { + header += str; + header.push_back('\n'); + } + if(*str == '}') + break; + } + } + } + } +#endif + } + { + ofstream out("test.cpp.h"); + out << header; + out.close(); + } + + string header_grammar; + { + ifstream fs("grammar.txt"); + stringstream ss; + ss << fs.rdbuf(); + header_grammar = ss.str(); + } + + parser parser; + parser.log = [&](size_t ln, size_t col, const string & msg) + { + cout << "Error parsing grammar:" << ln << ":" << col << ": " << msg << endl; + }; + + if (!parser.load_grammar(header_grammar.c_str())) + { + cout << "Failed to load grammar" << endl; + return; + } + + parser.log = [&](size_t ln, size_t col, const string & msg) + { + cout << filename << ":" << ln << ":" << col << ": " << msg << endl; + }; + + parser.enable_ast(); + + if (!parser.parse_n(header.c_str(), header.size(), ast)) + { + cout << "Error parsing header file: " << filename << endl; + return; + } + + ast = AstOptimizer(false).optimize(ast); + + if (ast->name != "Program") + { + cout << "Expected root node to be Program, not" << ast->name << endl; + return; + } + + for (shared_ptr node_ : ast->nodes) + { + Ast node = *node_; + + if (node.name == "Function") + functions.push_back(node); + else if (node.name == "Line") + { + + } + else if (node.name == "EndOfFile") + break; + else + { +// cout << "Unexcpected node " << node->name << endl; + } + } + + for(ComFunction& fn : functions) + { + if(!fn.ignored && fn.preferred && ::isdigit(fn.name.back())) + { + fn.name.pop_back(); + for(ComFunction& fn2 : functions) + if(&fn != &fn2 && !fn2.ignored && get_derived_basename(fn.original_name) == get_derived_basename(fn2.original_name)) + { +// cout << &fn << &fn2 << fn.original_name << " " << fn2.original_name << endl; +// assert(fn2.preferred == false); + fn2.ignored = true; +// if(fn2.original_name == "CreateCommandQueue" && fn2.ignored) +// cout << "ignored CreateCommandQueue !!" << __LINE__ << endl; + } + } + } + + for(ComFunction& fn : functions) + { + if(!fn.ignored) + { + bool known = false; + for(name_pair& known_type:types) + if (fn.this_.type.original == known_type.original) + { + known = true; + break; + } + + if(!known) + types.push_back(fn.this_.type); + } + } + } + ComHeader(shared_ptr ast_) + { + + } + string str() + { + stringstream out; + int indent = 0; + for(name_pair known_type:types) + if (indent < known_type.original.length()) + indent = known_type.original.length(); + + for(name_pair known_type:types) + { + out << "typedef " << known_type.original << '*' << string(indent + 1 - known_type.original.length(), ' ') << known_type.name << ";\n"; + } + out << "\n\n"; + for (ComFunction &fn : functions) + if(!fn.ignored) + out << fn.str(); + return out.str(); + } + +}; + +template +basic_ostream<_Elem, _Traits> &operator << (basic_ostream<_Elem, _Traits> &ios, ComHeader &header) +{ + return ios << header.str(); +} + + +int main(int argc, const char **argv) +{ + const char *header_fn = argv[1]; + ComHeader header(header_fn); + + if (header.functions.empty()) + return 1; + + if (argc > 2) + cout << ast_to_s(header.ast) << flush; + + ofstream out("test.h"); + const char* basename = strrchr(argv[1], '/'); + if(!basename) + basename = strrchr(argv[1], '\\'); + if(basename) + basename++; + if(!basename) + basename = argv[1]; + +#if 1 + out << "\n#include <" << basename << ">\n\n"; +#else + out << "\n"; + out << "#include \n"; + out << "#include \n"; + out << "#include \n\n"; +#endif + + out << header; + out.close(); + + + return 0; +} diff --git a/tools/com-parser/grammar.txt b/tools/com-parser/grammar.txt new file mode 100644 index 0000000000..21cf85f57d --- /dev/null +++ b/tools/com-parser/grammar.txt @@ -0,0 +1,30 @@ + +Program <- (Function / Comment / Line)* EndOfFile + + +Function <- _ ReturnType _ '(' _ FunctionName _ ')'_ Parameters +Parameters <- '('_ This _ ','? _ ( _ Param _ ','?)*_ ');' +FunctionName <- CallType _ '*' _ +This <- Type _ 'This' +Param <- InOut? _ Type _ Name _ ArraySize? +ReturnType <- +Type <- (TypeQualifier _)? Name Pointer? +TypeQualifier <- 'const' +~CallType <- '__export'? ('STDMETHODCALLTYPE' / 'STDMETHODVCALLTYPE' / 'STDAPICALLTYPE' / 'STDAPIVCALLTYPE' / '__cdecl' / '__stdcall') +~InOut <- '_'Name + +ArraySize <- '[' _ _ ']' +Pointer <- _<('*'/'const '/'const')+> +Name <- <([a-z]/[A-Z]/'_'/[0-9])+> +Number <- <[0-9]+> +~Line <- <(!EndOfLine !EndOfFile .)*> (EndOfLine / EndOfFile) + +~EndOfStatement <- ';' +~EndOfLine <- '\r\n' / '\n' / '\r' +EndOfFile <- !. +End <- EndOfLine / EndOfFile +~_ <- (Comment / [ \t\r\n])* +Indent <- [ \t] +~Space <- [ \t] +Comment <- [ \t]*<('/*' (!'*/' .)* '*/' / '//') Line> + diff --git a/wiiu/wiiu_dbg.h b/wiiu/wiiu_dbg.h index b75edfaf27..5e22701484 100644 --- a/wiiu/wiiu_dbg.h +++ b/wiiu/wiiu_dbg.h @@ -26,13 +26,13 @@ void DisassemblePPCRange(void *start, void *end, void* printf_func, void* GetSym /* #define DEBUG_HOLD() do{printf("%s@%s:%d.\n",__FUNCTION__, __FILE__, __LINE__);fflush(stdout);wait_for_input();}while(0) */ #define DEBUG_LINE() do{printf("%s:%4d %s().\n", __FILE__, __LINE__, __FUNCTION__);fflush(stdout);}while(0) -#define DEBUG_STR(X) printf( "%s: %s\n", #X, (char*)(X)) -#define DEBUG_VAR(X) printf( "%-20s: 0x%08" PRIX32 "\n", #X, (uint32_t)(X)) -#define DEBUG_VAR2(X) printf( "%-20s: 0x%08" PRIX32 " (%i)\n", #X, (uint32_t)(X), (int)(X)) -#define DEBUG_INT(X) printf( "%-20s: %10" PRIi32 "\n", #X, (int32_t)(X)) -#define DEBUG_FLOAT(X) printf( "%-20s: %10.3f\n", #X, (float)(X)) -#define DEBUG_VAR64(X) printf( #X"\r\t\t\t\t : 0x%016" PRIX64 "\n", (uint64_t)(X)) -#define DEBUG_MAGIC(X) printf( "%-20s: '%c''%c''%c''%c' (0x%08X)\n", #X, (u32)(X)>>24, (u32)(X)>>16, (u32)(X)>>8, (u32)(X),(u32)(X)) +#define DEBUG_STR(X) do{printf( "%s: %s\n", #X, (char*)(X));fflush(stdout);}while(0) +#define DEBUG_VAR(X) do{printf( "%-20s: 0x%08" PRIX32 "\n", #X, (uint32_t)(X));fflush(stdout);}while(0) +#define DEBUG_VAR2(X) do{printf( "%-20s: 0x%08" PRIX32 " (%i)\n", #X, (uint32_t)(X), (int)(X));fflush(stdout);}while(0) +#define DEBUG_INT(X) do{printf( "%-20s: %10" PRIi32 "\n", #X, (int32_t)(X));fflush(stdout);}while(0) +#define DEBUG_FLOAT(X) do{printf( "%-20s: %10.3f\n", #X, (float)(X));fflush(stdout);}while(0) +#define DEBUG_VAR64(X) do{printf( "%-20s: 0x%016" PRIX64 "\n", #X, (uint64_t)(X));fflush(stdout);}while(0) +#define DEBUG_MAGIC(X) do{printf( "%-20s: '%c''%c''%c''%c' (0x%08X)\n", #X, (u32)(X)>>24, (u32)(X)>>16, (u32)(X)>>8, (u32)(X),(u32)(X));fflush(stdout);}while(0) /* #define DEBUG_ERROR(X) do{if(X)dump_result_value(X);}while(0) */ #define PRINTFPOS(X,Y) "\x1b["#X";"#Y"H"