From a5bf9d8dc6f4a35ba877c45da02de667f43153f7 Mon Sep 17 00:00:00 2001 From: aliaspider Date: Tue, 23 Jan 2018 18:04:55 +0100 Subject: [PATCH] (D3D10/11/12) .add a d3d10 driver. .add more utility functions to d3d*_common files. .add an image transfer/convert function to dxgi_common. .various refactors / style nits. --- Makefile.common | 26 +- Makefile.msvc | 2 + configuration.c | 3 + gfx/common/d3d10_common.c | 128 +++ gfx/common/d3d10_common.h | 1147 +++++++++++++++++++ gfx/common/d3d11_common.c | 68 ++ gfx/common/d3d11_common.h | 1975 +++++++++++++++++++++++++------- gfx/common/d3d12_common.c | 421 +++---- gfx/common/d3d12_common.h | 806 ++++++++----- gfx/common/dxgi_common.c | 215 +++- gfx/common/dxgi_common.h | 246 +++- gfx/common/win32_common.c | 4 +- gfx/common/win32_common.h | 2 +- gfx/drivers/d3d.h | 2 + gfx/drivers/d3d10.c | 446 ++++++++ gfx/drivers/d3d11.c | 548 +++------ gfx/drivers/d3d12.c | 321 ++---- gfx/video_driver.c | 3 + gfx/video_driver.h | 1 + griffin/griffin.c | 7 +- tools/com-parser/com-parse.cpp | 14 +- 21 files changed, 4838 insertions(+), 1547 deletions(-) create mode 100644 gfx/common/d3d10_common.c create mode 100644 gfx/common/d3d10_common.h create mode 100644 gfx/drivers/d3d10.c diff --git a/Makefile.common b/Makefile.common index 003028c90e..ad58095034 100644 --- a/Makefile.common +++ b/Makefile.common @@ -1186,8 +1186,7 @@ ifeq ($(HAVE_VULKAN), 1) -I$(DEPS_DIR)/glslang \ -I$(DEPS_DIR)/SPIRV-Cross - CXXFLAGS += -Wno-switch -Wno-sign-compare -fno-strict-aliasing -Wno-maybe-uninitialized -Wno-reorder -Wno-parentheses -Igfx/include - CFLAGS += -Igfx/include + CXXFLAGS += -Wno-switch -Wno-sign-compare -fno-strict-aliasing -Wno-maybe-uninitialized -Wno-reorder -Wno-parentheses GLSLANG_OBJ := $(GLSLANG_SOURCES:.cpp=.o) SPIRV_CROSS_OBJ := $(SPIRV_CROSS_SOURCES:.cpp=.o) @@ -1213,6 +1212,10 @@ ifeq ($(HAVE_VULKAN), 1) DEFINES += -DHAVE_SLANG endif +ifeq ($(findstring 1, $(HAVE_VULKAN) $(HAVE_D3D10) $(HAVE_D3D11) $(HAVE_D3D12)),1) + INCLUDE_DIRS += -Igfx/include +endif + ifeq ($(WANT_WGL), 1) OBJ += gfx/drivers_context/wgl_ctx.o LIBS += -lcomctl32 @@ -1289,30 +1292,25 @@ endif endif endif +ifeq ($(HAVE_D3D10), 1) + OBJ += gfx/drivers/d3d10.o gfx/common/d3d10_common.o + DEFINES += -DHAVE_D3D10 +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) +ifneq ($(findstring 1, $(HAVE_D3D10) $(HAVE_D3D11) $(HAVE_D3D12)),) OBJ += gfx/common/d3dcompiler_common.o -# LIBS += -ld3dcompiler -endif - -ifeq ($(WANT_DXGI), 1) OBJ += gfx/common/dxgi_common.o -# LIBS += -ldxgi + CFLAGS += -Wno-unknown-pragmas endif ifeq ($(HAVE_D3D8), 1) diff --git a/Makefile.msvc b/Makefile.msvc index ae5642c1d6..4bb703617c 100644 --- a/Makefile.msvc +++ b/Makefile.msvc @@ -14,6 +14,7 @@ VCINSTALLDIR := C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\$(NOTHING HAVE_D3DX := 1 HAVE_D3D8 := 0 HAVE_D3D9 := 1 +HAVE_D3D10 := 1 HAVE_D3D11 := 1 HAVE_D3D12 := 1 HAVE_CG := 1 @@ -50,6 +51,7 @@ HAVE_CHEEVOS := 1 HAVE_KEYMAPPER := 1 include Makefile.common +CFLAGS := $(filter-out -Wno-unknown-pragmas,$(CFLAGS)) CXXFLAGS := $(filter-out -fpermissive -Wno-switch -Wno-sign-compare -fno-strict-aliasing -Wno-maybe-uninitialized -Wno-reorder -Wno-parentheses,$(CXXFLAGS)) CXXFLAGS += $(CFLAGS) LIBS := $(filter-out -lstdc++,$(LIBS)) diff --git a/configuration.c b/configuration.c index 6caed8ebf0..08f10c07af 100644 --- a/configuration.c +++ b/configuration.c @@ -132,6 +132,7 @@ enum video_driver_enum VIDEO_SWITCH, VIDEO_D3D8, VIDEO_D3D9, + VIDEO_D3D10, VIDEO_D3D11, VIDEO_D3D12, VIDEO_VG, @@ -698,6 +699,8 @@ const char *config_get_default_video(void) return "d3d8"; case VIDEO_D3D9: return "d3d9"; + case VIDEO_D3D10: + return "d3d10"; case VIDEO_D3D11: return "d3d11"; case VIDEO_D3D12: diff --git a/gfx/common/d3d10_common.c b/gfx/common/d3d10_common.c new file mode 100644 index 0000000000..525115481a --- /dev/null +++ b/gfx/common/d3d10_common.c @@ -0,0 +1,128 @@ +/* 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 "d3d10_common.h" + +#include + +static dylib_t d3d10_dll; + +typedef HRESULT (WINAPI *PFN_D3D10_CREATE_DEVICE_AND_SWAP_CHAIN)( + IDXGIAdapter *pAdapter, + D3D10_DRIVER_TYPE DriverType, + HMODULE Software, + UINT Flags, + UINT SDKVersion, + DXGI_SWAP_CHAIN_DESC *pSwapChainDesc, + IDXGISwapChain **ppSwapChain, + ID3D10Device **ppDevice); + +HRESULT WINAPI D3D10CreateDeviceAndSwapChain( + IDXGIAdapter *pAdapter, + D3D10_DRIVER_TYPE DriverType, + HMODULE Software, + UINT Flags, + UINT SDKVersion, + DXGI_SWAP_CHAIN_DESC *pSwapChainDesc, + IDXGISwapChain **ppSwapChain, + ID3D10Device **ppDevice) + +{ + static PFN_D3D10_CREATE_DEVICE_AND_SWAP_CHAIN fp; + + if(!d3d10_dll) + d3d10_dll = dylib_load("d3d10.dll"); + + if(!d3d10_dll) + return TYPE_E_CANTLOADLIBRARY; + + if(!fp) + fp = (PFN_D3D10_CREATE_DEVICE_AND_SWAP_CHAIN)dylib_proc(d3d10_dll, "D3D10CreateDeviceAndSwapChain"); + + if(!fp) + return TYPE_E_CANTLOADLIBRARY; + + return fp(pAdapter,DriverType,Software, Flags, SDKVersion, pSwapChainDesc, ppSwapChain, ppDevice); + +} + + +void d3d10_init_texture(D3D10Device device, d3d10_texture_t* texture) +{ + Release(texture->handle); + Release(texture->staging); + Release(texture->view); + +// .Usage = D3D10_USAGE_DYNAMIC, +// .CPUAccessFlags = D3D10_CPU_ACCESS_WRITE, + + texture->desc.MipLevels = 1; + texture->desc.ArraySize = 1; + texture->desc.SampleDesc.Count = 1; + texture->desc.SampleDesc.Quality = 0; + texture->desc.BindFlags = D3D10_BIND_SHADER_RESOURCE; + texture->desc.CPUAccessFlags = 0; + texture->desc.MiscFlags = 0; + D3D10CreateTexture2D(device, &texture->desc, NULL, &texture->handle); + + { + D3D10_SHADER_RESOURCE_VIEW_DESC view_desc = + { + .Format = texture->desc.Format, + .ViewDimension = D3D_SRV_DIMENSION_TEXTURE2D, + .Texture2D.MostDetailedMip = 0, + .Texture2D.MipLevels = -1, + }; + D3D10CreateTexture2DShaderResourceView(device, texture->handle, &view_desc, &texture->view); + } + + { + D3D10_TEXTURE2D_DESC desc = texture->desc; + desc.BindFlags = 0; + desc.Usage = D3D10_USAGE_STAGING; + desc.CPUAccessFlags = D3D10_CPU_ACCESS_WRITE; + D3D10CreateTexture2D(device, &desc, NULL, &texture->staging); + } +} + +void d3d10_update_texture(int width, int height, int pitch, DXGI_FORMAT format, const void* data, d3d10_texture_t* texture) +{ + D3D10_MAPPED_TEXTURE2D mapped_texture; + + D3D10MapTexture2D(texture->staging, 0, D3D10_MAP_WRITE, 0, &mapped_texture); + + dxgi_copy(width, height, format, pitch, data, texture->desc.Format, mapped_texture.RowPitch, mapped_texture.pData); + + D3D10UnmapTexture2D(texture->staging, 0); + + if(texture->desc.Usage == D3D10_USAGE_DEFAULT) + texture->dirty = true; +} + +DXGI_FORMAT d3d10_get_closest_match(D3D10Device device, DXGI_FORMAT desired_format, UINT desired_format_support) +{ + DXGI_FORMAT* format = dxgi_get_format_fallback_list(desired_format); + UINT format_support; + + while(*format != DXGI_FORMAT_UNKNOWN) + { + if(SUCCEEDED(D3D10CheckFormatSupport(device, *format, &format_support)) + && ((format_support & desired_format_support) == desired_format_support)) + break; + format++; + } + assert(*format); + return *format; +} diff --git a/gfx/common/d3d10_common.h b/gfx/common/d3d10_common.h new file mode 100644 index 0000000000..7c1225dae1 --- /dev/null +++ b/gfx/common/d3d10_common.h @@ -0,0 +1,1147 @@ +/* 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 +#if 0 +#ifdef __GNUC__ +#define WIDL_C_INLINE_WRAPPERS +#include <_mingw.h> +#undef __forceinline +#define __forceinline inline __attribute__((__always_inline__)) +#endif +#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) +{ + if (object) + return object->Release(); + return 0; +} +#else +static inline ULONG Release(void* object) +{ + if (object) + return ((IUnknown*)object)->lpVtbl->Release(object); + return 0; +} +#endif +#endif + +typedef ID3D10InputLayout* D3D10InputLayout; +typedef ID3D10RasterizerState* D3D10RasterizerState; +typedef ID3D10DepthStencilState* D3D10DepthStencilState; +typedef ID3D10BlendState* D3D10BlendState; +typedef ID3D10PixelShader* D3D10PixelShader; +typedef ID3D10SamplerState* D3D10SamplerState; +typedef ID3D10VertexShader* D3D10VertexShader; +typedef ID3D10GeometryShader* D3D10GeometryShader; + +/* auto-generated */ +typedef ID3DDestructionNotifier* D3DDestructionNotifier; +typedef ID3D10Resource* D3D10Resource; +typedef ID3D10Buffer* D3D10Buffer; +typedef ID3D10Texture1D* D3D10Texture1D; +typedef ID3D10Texture2D* D3D10Texture2D; +typedef ID3D10Texture3D* D3D10Texture3D; +typedef ID3D10View* D3D10View; +typedef ID3D10ShaderResourceView* D3D10ShaderResourceView; +typedef ID3D10RenderTargetView* D3D10RenderTargetView; +typedef ID3D10DepthStencilView* D3D10DepthStencilView; +typedef ID3D10Asynchronous* D3D10Asynchronous; +typedef ID3D10Query* D3D10Query; +typedef ID3D10Predicate* D3D10Predicate; +typedef ID3D10Counter* D3D10Counter; +typedef ID3D10Device* D3D10Device; +typedef ID3D10Multithread* D3D10Multithread; +typedef ID3D10Debug* D3D10Debug; +typedef ID3D10SwitchToRef* D3D10SwitchToRef; +typedef ID3D10InfoQueue* D3D10InfoQueue; + +static inline void D3D10SetResourceEvictionPriority(D3D10Resource resource, UINT eviction_priority) +{ + resource->lpVtbl->SetEvictionPriority(resource, eviction_priority); +} +static inline UINT D3D10GetResourceEvictionPriority(D3D10Resource resource) +{ + return resource->lpVtbl->GetEvictionPriority(resource); +} +static inline void D3D10SetBufferEvictionPriority(D3D10Buffer buffer, UINT eviction_priority) +{ + buffer->lpVtbl->SetEvictionPriority(buffer, eviction_priority); +} +static inline UINT D3D10GetBufferEvictionPriority(D3D10Buffer buffer) +{ + return buffer->lpVtbl->GetEvictionPriority(buffer); +} +static inline HRESULT +D3D10MapBuffer(D3D10Buffer buffer, D3D10_MAP map_type, UINT map_flags, void** data) +{ + return buffer->lpVtbl->Map(buffer, map_type, map_flags, data); +} +static inline void D3D10UnmapBuffer(D3D10Buffer buffer) { buffer->lpVtbl->Unmap(buffer); } +static inline void +D3D10SetTexture1DEvictionPriority(D3D10Texture1D texture1d, UINT eviction_priority) +{ + texture1d->lpVtbl->SetEvictionPriority(texture1d, eviction_priority); +} +static inline UINT D3D10GetTexture1DEvictionPriority(D3D10Texture1D texture1d) +{ + return texture1d->lpVtbl->GetEvictionPriority(texture1d); +} +static inline HRESULT D3D10MapTexture1D( + D3D10Texture1D texture1d, UINT subresource, D3D10_MAP map_type, UINT map_flags, void** data) +{ + return texture1d->lpVtbl->Map(texture1d, subresource, map_type, map_flags, data); +} +static inline void D3D10UnmapTexture1D(D3D10Texture1D texture1d, UINT subresource) +{ + texture1d->lpVtbl->Unmap(texture1d, subresource); +} +static inline void +D3D10SetTexture2DEvictionPriority(D3D10Texture2D texture2d, UINT eviction_priority) +{ + texture2d->lpVtbl->SetEvictionPriority(texture2d, eviction_priority); +} +static inline UINT D3D10GetTexture2DEvictionPriority(D3D10Texture2D texture2d) +{ + return texture2d->lpVtbl->GetEvictionPriority(texture2d); +} +static inline HRESULT D3D10MapTexture2D( + D3D10Texture2D texture2d, + UINT subresource, + D3D10_MAP map_type, + UINT map_flags, + D3D10_MAPPED_TEXTURE2D* mapped_tex2d) +{ + return texture2d->lpVtbl->Map(texture2d, subresource, map_type, map_flags, mapped_tex2d); +} +static inline void D3D10UnmapTexture2D(D3D10Texture2D texture2d, UINT subresource) +{ + texture2d->lpVtbl->Unmap(texture2d, subresource); +} +static inline void +D3D10SetTexture3DEvictionPriority(D3D10Texture3D texture3d, UINT eviction_priority) +{ + texture3d->lpVtbl->SetEvictionPriority(texture3d, eviction_priority); +} +static inline UINT D3D10GetTexture3DEvictionPriority(D3D10Texture3D texture3d) +{ + return texture3d->lpVtbl->GetEvictionPriority(texture3d); +} +static inline HRESULT D3D10MapTexture3D( + D3D10Texture3D texture3d, + UINT subresource, + D3D10_MAP map_type, + UINT map_flags, + D3D10_MAPPED_TEXTURE3D* mapped_tex3d) +{ + return texture3d->lpVtbl->Map(texture3d, subresource, map_type, map_flags, mapped_tex3d); +} +static inline void D3D10UnmapTexture3D(D3D10Texture3D texture3d, UINT subresource) +{ + texture3d->lpVtbl->Unmap(texture3d, subresource); +} +static inline void D3D10GetViewResource(D3D10View view, D3D10Resource* resource) +{ + view->lpVtbl->GetResource(view, resource); +} +static inline void D3D10GetShaderResourceViewResource( + D3D10ShaderResourceView shader_resource_view, D3D10Resource* resource) +{ + shader_resource_view->lpVtbl->GetResource(shader_resource_view, resource); +} +static inline void +D3D10GetRenderTargetViewResource(D3D10RenderTargetView render_target_view, D3D10Resource* resource) +{ + render_target_view->lpVtbl->GetResource(render_target_view, resource); +} +static inline void +D3D10GetDepthStencilViewResource(D3D10DepthStencilView depth_stencil_view, D3D10Resource* resource) +{ + depth_stencil_view->lpVtbl->GetResource(depth_stencil_view, resource); +} +static inline void D3D10BeginAsynchronous(D3D10Asynchronous asynchronous) +{ + asynchronous->lpVtbl->Begin(asynchronous); +} +static inline void D3D10EndAsynchronous(D3D10Asynchronous asynchronous) +{ + asynchronous->lpVtbl->End(asynchronous); +} +static inline HRESULT D3D10GetAsynchronousData( + D3D10Asynchronous asynchronous, void* data, UINT data_size, UINT get_data_flags) +{ + return asynchronous->lpVtbl->GetData(asynchronous, data, data_size, get_data_flags); +} +static inline UINT D3D10GetAsynchronousDataSize(D3D10Asynchronous asynchronous) +{ + return asynchronous->lpVtbl->GetDataSize(asynchronous); +} +static inline void D3D10BeginQuery(D3D10Query query) { query->lpVtbl->Begin(query); } +static inline void D3D10EndQuery(D3D10Query query) { query->lpVtbl->End(query); } +static inline HRESULT +D3D10GetQueryData(D3D10Query query, void* data, UINT data_size, UINT get_data_flags) +{ + return query->lpVtbl->GetData(query, data, data_size, get_data_flags); +} +static inline UINT D3D10GetQueryDataSize(D3D10Query query) +{ + return query->lpVtbl->GetDataSize(query); +} +static inline void D3D10BeginPredicate(D3D10Predicate predicate) +{ + predicate->lpVtbl->Begin(predicate); +} +static inline void D3D10EndPredicate(D3D10Predicate predicate) +{ + predicate->lpVtbl->End(predicate); +} +static inline HRESULT +D3D10GetPredicateData(D3D10Predicate predicate, void* data, UINT data_size, UINT get_data_flags) +{ + return predicate->lpVtbl->GetData(predicate, data, data_size, get_data_flags); +} +static inline UINT D3D10GetPredicateDataSize(D3D10Predicate predicate) +{ + return predicate->lpVtbl->GetDataSize(predicate); +} +static inline void D3D10BeginCounter(D3D10Counter counter) { counter->lpVtbl->Begin(counter); } +static inline void D3D10EndCounter(D3D10Counter counter) { counter->lpVtbl->End(counter); } +static inline HRESULT +D3D10GetCounterData(D3D10Counter counter, void* data, UINT data_size, UINT get_data_flags) +{ + return counter->lpVtbl->GetData(counter, data, data_size, get_data_flags); +} +static inline UINT D3D10GetCounterDataSize(D3D10Counter counter) +{ + return counter->lpVtbl->GetDataSize(counter); +} +static inline void D3D10SetVShaderConstantBuffers( + D3D10Device device, UINT start_slot, UINT num_buffers, D3D10Buffer* const constant_buffers) +{ + device->lpVtbl->VSSetConstantBuffers(device, start_slot, num_buffers, constant_buffers); +} +static inline void D3D10SetPShaderResources( + D3D10Device device, + UINT start_slot, + UINT num_views, + D3D10ShaderResourceView* const shader_resource_views) +{ + device->lpVtbl->PSSetShaderResources(device, start_slot, num_views, shader_resource_views); +} +static inline void D3D10SetPShader(D3D10Device device, D3D10PixelShader pixel_shader) +{ + device->lpVtbl->PSSetShader(device, pixel_shader); +} +static inline void D3D10SetPShaderSamplers( + D3D10Device device, UINT start_slot, UINT num_samplers, D3D10SamplerState* const samplers) +{ + device->lpVtbl->PSSetSamplers(device, start_slot, num_samplers, samplers); +} +static inline void D3D10SetVShader(D3D10Device device, D3D10VertexShader vertex_shader) +{ + device->lpVtbl->VSSetShader(device, vertex_shader); +} +static inline void D3D10DrawIndexed( + D3D10Device device, UINT index_count, UINT start_index_location, INT base_vertex_location) +{ + device->lpVtbl->DrawIndexed(device, index_count, start_index_location, base_vertex_location); +} +static inline void D3D10Draw(D3D10Device device, UINT vertex_count, UINT start_vertex_location) +{ + device->lpVtbl->Draw(device, vertex_count, start_vertex_location); +} +static inline void D3D10SetPShaderConstantBuffers( + D3D10Device device, UINT start_slot, UINT num_buffers, D3D10Buffer* const constant_buffers) +{ + device->lpVtbl->PSSetConstantBuffers(device, start_slot, num_buffers, constant_buffers); +} +static inline void D3D10SetInputLayout(D3D10Device device, D3D10InputLayout input_layout) +{ + device->lpVtbl->IASetInputLayout(device, input_layout); +} +static inline void D3D10SetVertexBuffers( + D3D10Device device, + UINT start_slot, + UINT num_buffers, + D3D10Buffer* const vertex_buffers, + UINT* strides, + UINT* offsets) +{ + device->lpVtbl->IASetVertexBuffers( + device, start_slot, num_buffers, vertex_buffers, strides, offsets); +} +static inline void +D3D10SetIndexBuffer(D3D10Device device, D3D10Buffer index_buffer, DXGI_FORMAT format, UINT offset) +{ + device->lpVtbl->IASetIndexBuffer(device, index_buffer, format, offset); +} +static inline void D3D10DrawIndexedInstanced( + D3D10Device device, + UINT index_count_per_instance, + UINT instance_count, + UINT start_index_location, + INT base_vertex_location, + UINT start_instance_location) +{ + device->lpVtbl->DrawIndexedInstanced( + device, index_count_per_instance, instance_count, start_index_location, + base_vertex_location, start_instance_location); +} +static inline void D3D10DrawInstanced( + D3D10Device device, + UINT vertex_count_per_instance, + UINT instance_count, + UINT start_vertex_location, + UINT start_instance_location) +{ + device->lpVtbl->DrawInstanced( + device, vertex_count_per_instance, instance_count, start_vertex_location, + start_instance_location); +} +static inline void D3D10SetGShaderConstantBuffers( + D3D10Device device, UINT start_slot, UINT num_buffers, D3D10Buffer* const constant_buffers) +{ + device->lpVtbl->GSSetConstantBuffers(device, start_slot, num_buffers, constant_buffers); +} +static inline void D3D10SetGShader(D3D10Device device, D3D10GeometryShader shader) +{ + device->lpVtbl->GSSetShader(device, shader); +} +static inline void D3D10SetPrimitiveTopology(D3D10Device device, D3D10_PRIMITIVE_TOPOLOGY topology) +{ + device->lpVtbl->IASetPrimitiveTopology(device, topology); +} +static inline void D3D10SetVShaderResources( + D3D10Device device, + UINT start_slot, + UINT num_views, + D3D10ShaderResourceView* const shader_resource_views) +{ + device->lpVtbl->VSSetShaderResources(device, start_slot, num_views, shader_resource_views); +} +static inline void D3D10SetVShaderSamplers( + D3D10Device device, UINT start_slot, UINT num_samplers, D3D10SamplerState* const samplers) +{ + device->lpVtbl->VSSetSamplers(device, start_slot, num_samplers, samplers); +} +static inline void +D3D10SetPredication(D3D10Device device, D3D10Predicate predicate, BOOL predicate_value) +{ + device->lpVtbl->SetPredication(device, predicate, predicate_value); +} +static inline void D3D10SetGShaderResources( + D3D10Device device, + UINT start_slot, + UINT num_views, + D3D10ShaderResourceView* const shader_resource_views) +{ + device->lpVtbl->GSSetShaderResources(device, start_slot, num_views, shader_resource_views); +} +static inline void D3D10SetGShaderSamplers( + D3D10Device device, UINT start_slot, UINT num_samplers, D3D10SamplerState* const samplers) +{ + device->lpVtbl->GSSetSamplers(device, start_slot, num_samplers, samplers); +} +static inline void D3D10SetRenderTargets( + D3D10Device device, + UINT num_views, + D3D10RenderTargetView* const render_target_views, + D3D10DepthStencilView depth_stencil_view) +{ + device->lpVtbl->OMSetRenderTargets(device, num_views, render_target_views, depth_stencil_view); +} +static inline void D3D10SetBlendState( + D3D10Device device, D3D10BlendState blend_state, FLOAT blend_factor[4], UINT sample_mask) +{ + device->lpVtbl->OMSetBlendState(device, blend_state, blend_factor, sample_mask); +} +static inline void D3D10SetDepthStencilState( + D3D10Device device, D3D10DepthStencilState depth_stencil_state, UINT stencil_ref) +{ + device->lpVtbl->OMSetDepthStencilState(device, depth_stencil_state, stencil_ref); +} +static inline void +D3D10SOSetTargets(D3D10Device device, UINT num_buffers, D3D10Buffer* const sotargets, UINT* offsets) +{ + device->lpVtbl->SOSetTargets(device, num_buffers, sotargets, offsets); +} +static inline void D3D10DrawAuto(D3D10Device device) { device->lpVtbl->DrawAuto(device); } +static inline void D3D10SetState(D3D10Device device, D3D10RasterizerState rasterizer_state) +{ + device->lpVtbl->RSSetState(device, rasterizer_state); +} +static inline void +D3D10SetViewports(D3D10Device device, UINT num_viewports, D3D10_VIEWPORT* viewports) +{ + device->lpVtbl->RSSetViewports(device, num_viewports, viewports); +} +static inline void D3D10SetScissorRects(D3D10Device device, UINT num_rects, D3D10_RECT* rects) +{ + device->lpVtbl->RSSetScissorRects(device, num_rects, rects); +} +static inline void D3D10CopySubresourceRegionDevice( + D3D10Device device, + D3D10Resource dst_resource, + UINT dst_subresource, + UINT dst_x, + UINT dst_y, + UINT dst_z, + D3D10Resource src_resource, + UINT src_subresource, + D3D10_BOX* src_box) +{ + device->lpVtbl->CopySubresourceRegion( + device, dst_resource, dst_subresource, dst_x, dst_y, dst_z, src_resource, src_subresource, + src_box); +} +static inline void +D3D10CopyResource(D3D10Device device, D3D10Resource dst_resource, D3D10Resource src_resource) +{ + device->lpVtbl->CopyResource(device, dst_resource, src_resource); +} +static inline void D3D10UpdateSubresource( + D3D10Device device, + D3D10Resource dst_resource, + UINT dst_subresource, + D3D10_BOX* dst_box, + void* src_data, + UINT src_row_pitch, + UINT src_depth_pitch) +{ + device->lpVtbl->UpdateSubresource( + device, dst_resource, dst_subresource, dst_box, src_data, src_row_pitch, src_depth_pitch); +} +static inline void D3D10ClearRenderTargetView( + D3D10Device device, D3D10RenderTargetView render_target_view, FLOAT color_rgba[4]) +{ + device->lpVtbl->ClearRenderTargetView(device, render_target_view, color_rgba); +} +static inline void D3D10ClearDepthStencilView( + D3D10Device device, + D3D10DepthStencilView depth_stencil_view, + UINT clear_flags, + FLOAT depth, + UINT8 stencil) +{ + device->lpVtbl->ClearDepthStencilView(device, depth_stencil_view, clear_flags, depth, stencil); +} +static inline void +D3D10GenerateMips(D3D10Device device, D3D10ShaderResourceView shader_resource_view) +{ + device->lpVtbl->GenerateMips(device, shader_resource_view); +} +static inline void D3D10ResolveSubresource( + D3D10Device device, + D3D10Resource dst_resource, + UINT dst_subresource, + D3D10Resource src_resource, + UINT src_subresource, + DXGI_FORMAT format) +{ + device->lpVtbl->ResolveSubresource( + device, dst_resource, dst_subresource, src_resource, src_subresource, format); +} +static inline void D3D10GetVShaderConstantBuffers( + D3D10Device device, UINT start_slot, UINT num_buffers, D3D10Buffer* constant_buffers) +{ + device->lpVtbl->VSGetConstantBuffers(device, start_slot, num_buffers, constant_buffers); +} +static inline void D3D10GetPShaderResources( + D3D10Device device, + UINT start_slot, + UINT num_views, + D3D10ShaderResourceView* shader_resource_views) +{ + device->lpVtbl->PSGetShaderResources(device, start_slot, num_views, shader_resource_views); +} +static inline void D3D10GetPShader(D3D10Device device, D3D10PixelShader* pixel_shader) +{ + device->lpVtbl->PSGetShader(device, pixel_shader); +} +static inline void D3D10GetPShaderSamplers( + D3D10Device device, UINT start_slot, UINT num_samplers, D3D10SamplerState* samplers) +{ + device->lpVtbl->PSGetSamplers(device, start_slot, num_samplers, samplers); +} +static inline void D3D10GetVShader(D3D10Device device, D3D10VertexShader* vertex_shader) +{ + device->lpVtbl->VSGetShader(device, vertex_shader); +} +static inline void D3D10GetPShaderConstantBuffers( + D3D10Device device, UINT start_slot, UINT num_buffers, D3D10Buffer* constant_buffers) +{ + device->lpVtbl->PSGetConstantBuffers(device, start_slot, num_buffers, constant_buffers); +} +static inline void D3D10GetInputLayout(D3D10Device device, D3D10InputLayout* input_layout) +{ + device->lpVtbl->IAGetInputLayout(device, input_layout); +} +static inline void D3D10GetVertexBuffers( + D3D10Device device, + UINT start_slot, + UINT num_buffers, + D3D10Buffer* vertex_buffers, + UINT* strides, + UINT* offsets) +{ + device->lpVtbl->IAGetVertexBuffers( + device, start_slot, num_buffers, vertex_buffers, strides, offsets); +} +static inline void D3D10GetIndexBuffer( + D3D10Device device, D3D10Buffer* index_buffer, DXGI_FORMAT* format, UINT* offset) +{ + device->lpVtbl->IAGetIndexBuffer(device, index_buffer, format, offset); +} +static inline void D3D10GetGShaderConstantBuffers( + D3D10Device device, UINT start_slot, UINT num_buffers, D3D10Buffer* constant_buffers) +{ + device->lpVtbl->GSGetConstantBuffers(device, start_slot, num_buffers, constant_buffers); +} +static inline void D3D10GetGShader(D3D10Device device, D3D10GeometryShader* geometry_shader) +{ + device->lpVtbl->GSGetShader(device, geometry_shader); +} +static inline void D3D10GetPrimitiveTopology(D3D10Device device, D3D10_PRIMITIVE_TOPOLOGY* topology) +{ + device->lpVtbl->IAGetPrimitiveTopology(device, topology); +} +static inline void D3D10GetVShaderResources( + D3D10Device device, + UINT start_slot, + UINT num_views, + D3D10ShaderResourceView* shader_resource_views) +{ + device->lpVtbl->VSGetShaderResources(device, start_slot, num_views, shader_resource_views); +} +static inline void D3D10GetVShaderSamplers( + D3D10Device device, UINT start_slot, UINT num_samplers, D3D10SamplerState* samplers) +{ + device->lpVtbl->VSGetSamplers(device, start_slot, num_samplers, samplers); +} +static inline void +D3D10GetPredication(D3D10Device device, D3D10Predicate* predicate, BOOL* predicate_value) +{ + device->lpVtbl->GetPredication(device, predicate, predicate_value); +} +static inline void D3D10GetGShaderResources( + D3D10Device device, + UINT start_slot, + UINT num_views, + D3D10ShaderResourceView* shader_resource_views) +{ + device->lpVtbl->GSGetShaderResources(device, start_slot, num_views, shader_resource_views); +} +static inline void D3D10GetGShaderSamplers( + D3D10Device device, UINT start_slot, UINT num_samplers, D3D10SamplerState* samplers) +{ + device->lpVtbl->GSGetSamplers(device, start_slot, num_samplers, samplers); +} +static inline void D3D10GetRenderTargets( + D3D10Device device, + UINT num_views, + D3D10RenderTargetView* render_target_views, + D3D10DepthStencilView* depth_stencil_view) +{ + device->lpVtbl->OMGetRenderTargets(device, num_views, render_target_views, depth_stencil_view); +} +static inline void D3D10GetBlendState( + D3D10Device device, D3D10BlendState* blend_state, FLOAT blend_factor[4], UINT* sample_mask) +{ + device->lpVtbl->OMGetBlendState(device, blend_state, blend_factor, sample_mask); +} +static inline void D3D10GetDepthStencilState( + D3D10Device device, D3D10DepthStencilState* depth_stencil_state, UINT* stencil_ref) +{ + device->lpVtbl->OMGetDepthStencilState(device, depth_stencil_state, stencil_ref); +} +static inline void +D3D10SOGetTargets(D3D10Device device, UINT num_buffers, D3D10Buffer* sotargets, UINT* offsets) +{ + device->lpVtbl->SOGetTargets(device, num_buffers, sotargets, offsets); +} +static inline void D3D10GetState(D3D10Device device, D3D10RasterizerState* rasterizer_state) +{ + device->lpVtbl->RSGetState(device, rasterizer_state); +} +static inline void +D3D10GetViewports(D3D10Device device, UINT* num_viewports, D3D10_VIEWPORT* viewports) +{ + device->lpVtbl->RSGetViewports(device, num_viewports, viewports); +} +static inline void D3D10GetScissorRects(D3D10Device device, UINT* num_rects, D3D10_RECT* rects) +{ + device->lpVtbl->RSGetScissorRects(device, num_rects, rects); +} +static inline HRESULT D3D10GetDeviceRemovedReason(D3D10Device device) +{ + return device->lpVtbl->GetDeviceRemovedReason(device); +} +static inline HRESULT D3D10SetExceptionMode(D3D10Device device, UINT raise_flags) +{ + return device->lpVtbl->SetExceptionMode(device, raise_flags); +} +static inline UINT D3D10GetExceptionMode(D3D10Device device) +{ + return device->lpVtbl->GetExceptionMode(device); +} +static inline void D3D10ClearState(D3D10Device device) { device->lpVtbl->ClearState(device); } +static inline void D3D10Flush(D3D10Device device) { device->lpVtbl->Flush(device); } +static inline HRESULT D3D10CreateBuffer( + D3D10Device device, + D3D10_BUFFER_DESC* desc, + D3D10_SUBRESOURCE_DATA* initial_data, + D3D10Buffer* buffer) +{ + return device->lpVtbl->CreateBuffer(device, desc, initial_data, buffer); +} +static inline HRESULT D3D10CreateTexture1D( + D3D10Device device, + D3D10_TEXTURE1D_DESC* desc, + D3D10_SUBRESOURCE_DATA* initial_data, + D3D10Texture1D* texture1d) +{ + return device->lpVtbl->CreateTexture1D(device, desc, initial_data, texture1d); +} +static inline HRESULT D3D10CreateTexture2D( + D3D10Device device, + D3D10_TEXTURE2D_DESC* desc, + D3D10_SUBRESOURCE_DATA* initial_data, + D3D10Texture2D* texture2d) +{ + return device->lpVtbl->CreateTexture2D(device, desc, initial_data, texture2d); +} +static inline HRESULT D3D10CreateTexture3D( + D3D10Device device, + D3D10_TEXTURE3D_DESC* desc, + D3D10_SUBRESOURCE_DATA* initial_data, + D3D10Texture3D* texture3d) +{ + return device->lpVtbl->CreateTexture3D(device, desc, initial_data, texture3d); +} +static inline HRESULT D3D10CreateShaderResourceViewDevice( + D3D10Device device, + D3D10Resource resource, + D3D10_SHADER_RESOURCE_VIEW_DESC* desc, + D3D10ShaderResourceView* srview) +{ + return device->lpVtbl->CreateShaderResourceView(device, resource, desc, srview); +} +static inline HRESULT D3D10CreateRenderTargetViewDevice( + D3D10Device device, + D3D10Resource resource, + D3D10_RENDER_TARGET_VIEW_DESC* desc, + D3D10RenderTargetView* rtview) +{ + return device->lpVtbl->CreateRenderTargetView(device, resource, desc, rtview); +} +static inline HRESULT D3D10CreateDepthStencilView( + D3D10Device device, + D3D10Resource resource, + D3D10_DEPTH_STENCIL_VIEW_DESC* desc, + D3D10DepthStencilView* depth_stencil_view) +{ + return device->lpVtbl->CreateDepthStencilView(device, resource, desc, depth_stencil_view); +} +static inline HRESULT D3D10CreateInputLayout( + D3D10Device device, + D3D10_INPUT_ELEMENT_DESC* input_element_descs, + UINT num_elements, + void* shader_bytecode_with_input_signature, + SIZE_T bytecode_length, + D3D10InputLayout* input_layout) +{ + return device->lpVtbl->CreateInputLayout( + device, input_element_descs, num_elements, shader_bytecode_with_input_signature, + bytecode_length, input_layout); +} +static inline HRESULT D3D10CreateVertexShader( + D3D10Device device, + void* shader_bytecode, + SIZE_T bytecode_length, + D3D10VertexShader* vertex_shader) +{ + return device->lpVtbl->CreateVertexShader( + device, shader_bytecode, bytecode_length, vertex_shader); +} +static inline HRESULT D3D10CreateGeometryShader( + D3D10Device device, + void* shader_bytecode, + SIZE_T bytecode_length, + D3D10GeometryShader* geometry_shader) +{ + return device->lpVtbl->CreateGeometryShader( + device, shader_bytecode, bytecode_length, geometry_shader); +} +static inline HRESULT D3D10CreateGeometryShaderWithStreamOutput( + D3D10Device device, + void* shader_bytecode, + SIZE_T bytecode_length, + D3D10_SO_DECLARATION_ENTRY* sodeclaration, + UINT num_entries, + UINT output_stream_stride, + D3D10GeometryShader* geometry_shader) +{ + return device->lpVtbl->CreateGeometryShaderWithStreamOutput( + device, shader_bytecode, bytecode_length, sodeclaration, num_entries, output_stream_stride, + geometry_shader); +} +static inline HRESULT D3D10CreatePixelShader( + D3D10Device device, + void* shader_bytecode, + SIZE_T bytecode_length, + D3D10PixelShader* pixel_shader) +{ + return device->lpVtbl->CreatePixelShader(device, shader_bytecode, bytecode_length, pixel_shader); +} +static inline HRESULT D3D10CreateBlendState( + D3D10Device device, D3D10_BLEND_DESC* blend_state_desc, D3D10BlendState* blend_state) +{ + return device->lpVtbl->CreateBlendState(device, blend_state_desc, blend_state); +} +static inline HRESULT D3D10CreateDepthStencilState( + D3D10Device device, + D3D10_DEPTH_STENCIL_DESC* depth_stencil_desc, + D3D10DepthStencilState* depth_stencil_state) +{ + return device->lpVtbl->CreateDepthStencilState(device, depth_stencil_desc, depth_stencil_state); +} +static inline HRESULT D3D10CreateRasterizerState( + D3D10Device device, + D3D10_RASTERIZER_DESC* rasterizer_desc, + D3D10RasterizerState* rasterizer_state) +{ + return device->lpVtbl->CreateRasterizerState(device, rasterizer_desc, rasterizer_state); +} +static inline HRESULT D3D10CreateSamplerState( + D3D10Device device, D3D10_SAMPLER_DESC* sampler_desc, D3D10SamplerState* sampler_state) +{ + return device->lpVtbl->CreateSamplerState(device, sampler_desc, sampler_state); +} +static inline HRESULT +D3D10CreateQuery(D3D10Device device, D3D10_QUERY_DESC* query_desc, D3D10Query* query) +{ + return device->lpVtbl->CreateQuery(device, query_desc, query); +} +static inline HRESULT D3D10CreatePredicate( + D3D10Device device, D3D10_QUERY_DESC* predicate_desc, D3D10Predicate* predicate) +{ + return device->lpVtbl->CreatePredicate(device, predicate_desc, predicate); +} +static inline HRESULT +D3D10CreateCounter(D3D10Device device, D3D10_COUNTER_DESC* counter_desc, D3D10Counter* counter) +{ + return device->lpVtbl->CreateCounter(device, counter_desc, counter); +} +static inline HRESULT +D3D10CheckFormatSupport(D3D10Device device, DXGI_FORMAT format, UINT* format_support) +{ + return device->lpVtbl->CheckFormatSupport(device, format, format_support); +} +static inline HRESULT D3D10CheckMultisampleQualityLevels( + D3D10Device 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 D3D10CheckCounterInfo(D3D10Device device, D3D10_COUNTER_INFO* counter_info) +{ + device->lpVtbl->CheckCounterInfo(device, counter_info); +} +static inline HRESULT D3D10CheckCounter( + D3D10Device device, + D3D10_COUNTER_DESC* desc, + D3D10_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 UINT D3D10GetCreationFlags(D3D10Device device) +{ + return device->lpVtbl->GetCreationFlags(device); +} +static inline HRESULT +D3D10OpenSharedResource(D3D10Device device, HANDLE h_resource, ID3D10Resource** out) +{ + return device->lpVtbl->OpenSharedResource( + device, h_resource, __uuidof(ID3D10Resource), (void**)out); +} +static inline void D3D10SetTextFilterSize(D3D10Device device, UINT width, UINT height) +{ + device->lpVtbl->SetTextFilterSize(device, width, height); +} +static inline void D3D10GetTextFilterSize(D3D10Device device, UINT* width, UINT* height) +{ + device->lpVtbl->GetTextFilterSize(device, width, height); +} +static inline void D3D10Enter(D3D10Multithread multithread) +{ + multithread->lpVtbl->Enter(multithread); +} +static inline void D3D10Leave(D3D10Multithread multithread) +{ + multithread->lpVtbl->Leave(multithread); +} +static inline BOOL D3D10SetMultithreadProtected(D3D10Multithread multithread, BOOL mtprotect) +{ + return multithread->lpVtbl->SetMultithreadProtected(multithread, mtprotect); +} +static inline BOOL D3D10GetMultithreadProtected(D3D10Multithread multithread) +{ + return multithread->lpVtbl->GetMultithreadProtected(multithread); +} +static inline HRESULT D3D10SetDebugFeatureMask(D3D10Debug debug, UINT mask) +{ + return debug->lpVtbl->SetFeatureMask(debug, mask); +} +static inline UINT D3D10GetDebugFeatureMask(D3D10Debug debug) +{ + return debug->lpVtbl->GetFeatureMask(debug); +} +static inline HRESULT D3D10SetPresentPerRenderOpDelay(D3D10Debug debug, UINT milliseconds) +{ + return debug->lpVtbl->SetPresentPerRenderOpDelay(debug, milliseconds); +} +static inline UINT D3D10GetPresentPerRenderOpDelay(D3D10Debug debug) +{ + return debug->lpVtbl->GetPresentPerRenderOpDelay(debug); +} +static inline HRESULT D3D10SetSwapChain(D3D10Debug debug, IDXGISwapChain* swap_chain) +{ + return debug->lpVtbl->SetSwapChain(debug, (IDXGISwapChain*)swap_chain); +} +static inline HRESULT D3D10GetSwapChain(D3D10Debug debug, IDXGISwapChain** swap_chain) +{ + return debug->lpVtbl->GetSwapChain(debug, (IDXGISwapChain**)swap_chain); +} +static inline HRESULT D3D10Validate(D3D10Debug debug) { return debug->lpVtbl->Validate(debug); } +static inline BOOL D3D10SetUseRef(D3D10SwitchToRef switch_to_ref, BOOL use_ref) +{ + return switch_to_ref->lpVtbl->SetUseRef(switch_to_ref, use_ref); +} +static inline BOOL D3D10GetUseRef(D3D10SwitchToRef switch_to_ref) +{ + return switch_to_ref->lpVtbl->GetUseRef(switch_to_ref); +} +static inline HRESULT +D3D10SetMessageCountLimit(D3D10InfoQueue info_queue, UINT64 message_count_limit) +{ + return info_queue->lpVtbl->SetMessageCountLimit(info_queue, message_count_limit); +} +static inline void D3D10ClearStoredMessages(D3D10InfoQueue info_queue) +{ + info_queue->lpVtbl->ClearStoredMessages(info_queue); +} +static inline HRESULT D3D10GetMessageA( + D3D10InfoQueue info_queue, + UINT64 message_index, + D3D10_MESSAGE* message, + SIZE_T* message_byte_length) +{ + return info_queue->lpVtbl->GetMessageA(info_queue, message_index, message, message_byte_length); +} +static inline UINT64 D3D10GetNumMessagesAllowedByStorageFilter(D3D10InfoQueue info_queue) +{ + return info_queue->lpVtbl->GetNumMessagesAllowedByStorageFilter(info_queue); +} +static inline UINT64 D3D10GetNumMessagesDeniedByStorageFilter(D3D10InfoQueue info_queue) +{ + return info_queue->lpVtbl->GetNumMessagesDeniedByStorageFilter(info_queue); +} +static inline UINT64 D3D10GetNumStoredMessages(D3D10InfoQueue info_queue) +{ + return info_queue->lpVtbl->GetNumStoredMessages(info_queue); +} +static inline UINT64 D3D10GetNumStoredMessagesAllowedByRetrievalFilter(D3D10InfoQueue info_queue) +{ + return info_queue->lpVtbl->GetNumStoredMessagesAllowedByRetrievalFilter(info_queue); +} +static inline UINT64 D3D10GetNumMessagesDiscardedByMessageCountLimit(D3D10InfoQueue info_queue) +{ + return info_queue->lpVtbl->GetNumMessagesDiscardedByMessageCountLimit(info_queue); +} +static inline UINT64 D3D10GetMessageCountLimit(D3D10InfoQueue info_queue) +{ + return info_queue->lpVtbl->GetMessageCountLimit(info_queue); +} +static inline HRESULT +D3D10AddStorageFilterEntries(D3D10InfoQueue info_queue, D3D10_INFO_QUEUE_FILTER* filter) +{ + return info_queue->lpVtbl->AddStorageFilterEntries(info_queue, filter); +} +static inline HRESULT D3D10GetStorageFilter( + D3D10InfoQueue info_queue, D3D10_INFO_QUEUE_FILTER* filter, SIZE_T* filter_byte_length) +{ + return info_queue->lpVtbl->GetStorageFilter(info_queue, filter, filter_byte_length); +} +static inline void D3D10ClearStorageFilter(D3D10InfoQueue info_queue) +{ + info_queue->lpVtbl->ClearStorageFilter(info_queue); +} +static inline HRESULT D3D10PushEmptyStorageFilter(D3D10InfoQueue info_queue) +{ + return info_queue->lpVtbl->PushEmptyStorageFilter(info_queue); +} +static inline HRESULT D3D10PushCopyOfStorageFilter(D3D10InfoQueue info_queue) +{ + return info_queue->lpVtbl->PushCopyOfStorageFilter(info_queue); +} +static inline HRESULT +D3D10PushStorageFilter(D3D10InfoQueue info_queue, D3D10_INFO_QUEUE_FILTER* filter) +{ + return info_queue->lpVtbl->PushStorageFilter(info_queue, filter); +} +static inline void D3D10PopStorageFilter(D3D10InfoQueue info_queue) +{ + info_queue->lpVtbl->PopStorageFilter(info_queue); +} +static inline UINT D3D10GetStorageFilterStackSize(D3D10InfoQueue info_queue) +{ + return info_queue->lpVtbl->GetStorageFilterStackSize(info_queue); +} +static inline HRESULT +D3D10AddRetrievalFilterEntries(D3D10InfoQueue info_queue, D3D10_INFO_QUEUE_FILTER* filter) +{ + return info_queue->lpVtbl->AddRetrievalFilterEntries(info_queue, filter); +} +static inline HRESULT D3D10GetRetrievalFilter( + D3D10InfoQueue info_queue, D3D10_INFO_QUEUE_FILTER* filter, SIZE_T* filter_byte_length) +{ + return info_queue->lpVtbl->GetRetrievalFilter(info_queue, filter, filter_byte_length); +} +static inline void D3D10ClearRetrievalFilter(D3D10InfoQueue info_queue) +{ + info_queue->lpVtbl->ClearRetrievalFilter(info_queue); +} +static inline HRESULT D3D10PushEmptyRetrievalFilter(D3D10InfoQueue info_queue) +{ + return info_queue->lpVtbl->PushEmptyRetrievalFilter(info_queue); +} +static inline HRESULT D3D10PushCopyOfRetrievalFilter(D3D10InfoQueue info_queue) +{ + return info_queue->lpVtbl->PushCopyOfRetrievalFilter(info_queue); +} +static inline HRESULT +D3D10PushRetrievalFilter(D3D10InfoQueue info_queue, D3D10_INFO_QUEUE_FILTER* filter) +{ + return info_queue->lpVtbl->PushRetrievalFilter(info_queue, filter); +} +static inline void D3D10PopRetrievalFilter(D3D10InfoQueue info_queue) +{ + info_queue->lpVtbl->PopRetrievalFilter(info_queue); +} +static inline UINT D3D10GetRetrievalFilterStackSize(D3D10InfoQueue info_queue) +{ + return info_queue->lpVtbl->GetRetrievalFilterStackSize(info_queue); +} +static inline HRESULT D3D10AddMessage( + D3D10InfoQueue info_queue, + D3D10_MESSAGE_CATEGORY category, + D3D10_MESSAGE_SEVERITY severity, + D3D10_MESSAGE_ID id, + LPCSTR description) +{ + return info_queue->lpVtbl->AddMessage(info_queue, category, severity, id, description); +} +static inline HRESULT D3D10AddApplicationMessage( + D3D10InfoQueue info_queue, D3D10_MESSAGE_SEVERITY severity, LPCSTR description) +{ + return info_queue->lpVtbl->AddApplicationMessage(info_queue, severity, description); +} +static inline HRESULT +D3D10SetBreakOnCategory(D3D10InfoQueue info_queue, D3D10_MESSAGE_CATEGORY category, BOOL enable) +{ + return info_queue->lpVtbl->SetBreakOnCategory(info_queue, category, enable); +} +static inline HRESULT +D3D10SetBreakOnSeverity(D3D10InfoQueue info_queue, D3D10_MESSAGE_SEVERITY severity, BOOL enable) +{ + return info_queue->lpVtbl->SetBreakOnSeverity(info_queue, severity, enable); +} +static inline HRESULT D3D10SetBreakOnID(D3D10InfoQueue info_queue, D3D10_MESSAGE_ID id, BOOL enable) +{ + return info_queue->lpVtbl->SetBreakOnID(info_queue, id, enable); +} +static inline BOOL +D3D10GetBreakOnCategory(D3D10InfoQueue info_queue, D3D10_MESSAGE_CATEGORY category) +{ + return info_queue->lpVtbl->GetBreakOnCategory(info_queue, category); +} +static inline BOOL +D3D10GetBreakOnSeverity(D3D10InfoQueue info_queue, D3D10_MESSAGE_SEVERITY severity) +{ + return info_queue->lpVtbl->GetBreakOnSeverity(info_queue, severity); +} +static inline BOOL D3D10GetBreakOnID(D3D10InfoQueue info_queue, D3D10_MESSAGE_ID id) +{ + return info_queue->lpVtbl->GetBreakOnID(info_queue, id); +} +static inline void D3D10SetMuteDebugOutput(D3D10InfoQueue info_queue, BOOL mute) +{ + info_queue->lpVtbl->SetMuteDebugOutput(info_queue, mute); +} +static inline BOOL D3D10GetMuteDebugOutput(D3D10InfoQueue info_queue) +{ + return info_queue->lpVtbl->GetMuteDebugOutput(info_queue); +} + +/* end of auto-generated */ + +static inline HRESULT +DXGIGetSwapChainBufferD3D10(DXGISwapChain swap_chain, UINT buffer, D3D10Texture2D* out) +{ + return swap_chain->lpVtbl->GetBuffer(swap_chain, buffer, __uuidof(ID3D10Texture2D), (void**)out); +} +static inline void D3D10CopyTexture2DSubresourceRegion( + D3D10Device device, + D3D10Texture2D dst_texture, + UINT dst_subresource, + UINT dst_x, + UINT dst_y, + UINT dst_z, + D3D10Texture2D src_texture, + UINT src_subresource, + D3D10_BOX* src_box) +{ + device->lpVtbl->CopySubresourceRegion( + device, (D3D10Resource)dst_texture, dst_subresource, dst_x, dst_y, dst_z, + (D3D10Resource)src_texture, src_subresource, src_box); +} +static inline HRESULT D3D10CreateTexture2DRenderTargetView( + D3D10Device device, + D3D10Texture2D texture, + D3D10_RENDER_TARGET_VIEW_DESC* desc, + D3D10RenderTargetView* rtview) +{ + return device->lpVtbl->CreateRenderTargetView(device, (D3D10Resource)texture, desc, rtview); +} +static inline HRESULT D3D10CreateTexture2DShaderResourceView( + D3D10Device device, + D3D10Texture2D texture, + D3D10_SHADER_RESOURCE_VIEW_DESC* desc, + D3D10ShaderResourceView* srview) +{ + return device->lpVtbl->CreateShaderResourceView(device, (D3D10Resource)texture, desc, srview); +} + + /* internal */ + +#include + +typedef struct d3d10_vertex_t +{ + float position[2]; + float texcoord[2]; + float color[4]; +} d3d10_vertex_t; + +typedef struct +{ + D3D10Texture2D handle; + D3D10Texture2D staging; + D3D10_TEXTURE2D_DESC desc; + D3D10ShaderResourceView view; + bool dirty; + bool ignore_alpha; +} d3d10_texture_t; + +typedef struct +{ + unsigned cur_mon_id; + DXGISwapChain swapChain; + D3D10Device device; + D3D10RenderTargetView renderTargetView; + D3D10InputLayout layout; + D3D10VertexShader vs; + D3D10PixelShader ps; + D3D10SamplerState sampler_nearest; + D3D10SamplerState sampler_linear; + D3D10BlendState blend_enable; + D3D10BlendState blend_disable; + float clearcolor[4]; + struct + { + d3d10_texture_t texture; + D3D10Buffer vbo; + D3D10SamplerState sampler; + bool enabled; + bool fullscreen; + } menu; + struct + { + d3d10_texture_t texture; + D3D10Buffer vbo; + D3D10SamplerState sampler; + } frame; + DXGI_FORMAT format; + + bool vsync; +} d3d10_video_t; + +void d3d10_init_texture(D3D10Device device, d3d10_texture_t* texture); + +void d3d10_update_texture( + int width, + int height, + int pitch, + DXGI_FORMAT format, + const void* data, + d3d10_texture_t* texture); + +DXGI_FORMAT d3d10_get_closest_match( + D3D10Device device, DXGI_FORMAT desired_format, UINT desired_format_support); + +static inline DXGI_FORMAT +d3d10_get_closest_match_texture2D(D3D10Device device, DXGI_FORMAT desired_format) +{ + return d3d10_get_closest_match( + device, desired_format, + D3D10_FORMAT_SUPPORT_TEXTURE2D | D3D10_FORMAT_SUPPORT_SHADER_SAMPLE); +} diff --git a/gfx/common/d3d11_common.c b/gfx/common/d3d11_common.c index 5eaf2bd0e2..cc808e21e8 100644 --- a/gfx/common/d3d11_common.c +++ b/gfx/common/d3d11_common.c @@ -41,3 +41,71 @@ HRESULT WINAPI D3D11CreateDeviceAndSwapChain( IDXGIAdapter* pAdapter,D3D_DRIVER_ ppSwapChain, ppDevice, pFeatureLevel, ppImmediateContext); } + +void d3d11_init_texture(D3D11Device device, d3d11_texture_t* texture) +{ + Release(texture->handle); + Release(texture->staging); + Release(texture->view); + +// .Usage = D3D11_USAGE_DYNAMIC, +// .CPUAccessFlags = D3D11_CPU_ACCESS_WRITE, + + texture->desc.MipLevels = 1; + texture->desc.ArraySize = 1; + texture->desc.SampleDesc.Count = 1; + texture->desc.SampleDesc.Quality = 0; + texture->desc.BindFlags = D3D11_BIND_SHADER_RESOURCE; + texture->desc.CPUAccessFlags = 0; + texture->desc.MiscFlags = 0; + D3D11CreateTexture2D(device, &texture->desc, NULL, &texture->handle); + + { + D3D11_SHADER_RESOURCE_VIEW_DESC view_desc = + { + .Format = texture->desc.Format, + .ViewDimension = D3D_SRV_DIMENSION_TEXTURE2D, + .Texture2D.MostDetailedMip = 0, + .Texture2D.MipLevels = -1, + }; + D3D11CreateTexture2DShaderResourceView(device, texture->handle, &view_desc, &texture->view); + } + + { + D3D11_TEXTURE2D_DESC desc = texture->desc; + desc.BindFlags = 0; + desc.Usage = D3D11_USAGE_STAGING; + desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; + D3D11CreateTexture2D(device, &desc, NULL, &texture->staging); + } +} + +void d3d11_update_texture(D3D11DeviceContext ctx, int width, int height, int pitch, DXGI_FORMAT format, const void* data, d3d11_texture_t* texture) +{ + D3D11_MAPPED_SUBRESOURCE mapped_texture; + + D3D11MapTexture2D(ctx, texture->staging, 0, D3D11_MAP_WRITE, 0, &mapped_texture); + + dxgi_copy(width, height, format, pitch, data, texture->desc.Format, mapped_texture.RowPitch, mapped_texture.pData); + + D3D11UnmapTexture2D(ctx, texture->staging, 0); + + if(texture->desc.Usage == D3D11_USAGE_DEFAULT) + texture->dirty = true; +} + + +DXGI_FORMAT d3d11_get_closest_match(D3D11Device device, DXGI_FORMAT desired_format, UINT desired_format_support) +{ + DXGI_FORMAT* format = dxgi_get_format_fallback_list(desired_format); + UINT format_support; + while(*format != DXGI_FORMAT_UNKNOWN) + { + if(SUCCEEDED(D3D11CheckFormatSupport(device, *format, &format_support)) + && ((format_support & desired_format_support) == desired_format_support)) + break; + format++; + } + assert(*format); + return *format; +} diff --git a/gfx/common/d3d11_common.h b/gfx/common/d3d11_common.h index a98c534cc1..c040db3a17 100644 --- a/gfx/common/d3d11_common.h +++ b/gfx/common/d3d11_common.h @@ -13,7 +13,6 @@ * If not, see . */ - #pragma once #ifdef __MINGW32__ @@ -41,11 +40,11 @@ #include "dxgi_common.h" #ifndef countof -#define countof(a) (sizeof(a)/ sizeof(*a)) +#define countof(a) (sizeof(a) / sizeof(*a)) #endif #ifndef __uuidof -#define __uuidof(type) &IID_##type +#define __uuidof(type) & IID_##type #endif #ifndef COM_RELEASE_DECLARED @@ -53,27 +52,31 @@ #if defined(__cplusplus) && !defined(CINTERFACE) static inline ULONG Release(IUnknown* object) { - return object->Release(); + if (object) + return object->Release(); + return 0; } #else static inline ULONG Release(void* object) { - return ((IUnknown*)object)->lpVtbl->Release(object); + if (object) + return ((IUnknown*)object)->lpVtbl->Release(object); + return 0; } #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; +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 */ @@ -127,7 +130,8 @@ static inline UINT D3D11GetBufferEvictionPriority(D3D11Buffer buffer) { return buffer->lpVtbl->GetEvictionPriority(buffer); } -static inline void D3D11SetTexture1DEvictionPriority(D3D11Texture1D texture1d, UINT eviction_priority) +static inline void +D3D11SetTexture1DEvictionPriority(D3D11Texture1D texture1d, UINT eviction_priority) { texture1d->lpVtbl->SetEvictionPriority(texture1d, eviction_priority); } @@ -135,7 +139,8 @@ static inline UINT D3D11GetTexture1DEvictionPriority(D3D11Texture1D texture1d) { return texture1d->lpVtbl->GetEvictionPriority(texture1d); } -static inline void D3D11SetTexture2DEvictionPriority(D3D11Texture2D texture2d, UINT eviction_priority) +static inline void +D3D11SetTexture2DEvictionPriority(D3D11Texture2D texture2d, UINT eviction_priority) { texture2d->lpVtbl->SetEvictionPriority(texture2d, eviction_priority); } @@ -143,7 +148,8 @@ static inline UINT D3D11GetTexture2DEvictionPriority(D3D11Texture2D texture2d) { return texture2d->lpVtbl->GetEvictionPriority(texture2d); } -static inline void D3D11SetTexture3DEvictionPriority(D3D11Texture3D texture3d, UINT eviction_priority) +static inline void +D3D11SetTexture3DEvictionPriority(D3D11Texture3D texture3d, UINT eviction_priority) { texture3d->lpVtbl->SetEvictionPriority(texture3d, eviction_priority); } @@ -155,19 +161,23 @@ static inline void D3D11GetViewResource(D3D11View view, D3D11Resource* resource) { view->lpVtbl->GetResource(view, resource); } -static inline void D3D11GetShaderResourceViewResource(D3D11ShaderResourceView shader_resource_view, D3D11Resource* 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) +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) +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) +static inline void D3D11GetUnorderedAccessViewResource( + D3D11UnorderedAccessView unordered_access_view, D3D11Resource* resource) { unordered_access_view->lpVtbl->GetResource(unordered_access_view, resource); } @@ -187,107 +197,211 @@ static inline UINT D3D11GetCounterDataSize(D3D11Counter counter) { return counter->lpVtbl->GetDataSize(counter); } -static inline void D3D11GetClassLinkage(D3D11ClassInstance class_instance, D3D11ClassLinkage* linkage) +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) +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) +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) +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); + 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) +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); + 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) +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); + 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) +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); + 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) +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); + 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) +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) +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); + 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) +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); + 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) +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) +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); + 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) +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) +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); + device_context->lpVtbl->PSSetConstantBuffers( + device_context, start_slot, num_buffers, constant_buffers); } -static inline void D3D11SetInputLayout(D3D11DeviceContext device_context, D3D11InputLayout input_layout) +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) +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); + 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) +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) +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); + 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) +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); + 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) +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); + 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) +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); + device_context->lpVtbl->GSSetShader( + device_context, shader, class_instances, num_class_instances); } -static inline void D3D11SetPrimitiveTopology(D3D11DeviceContext device_context, D3D11_PRIMITIVE_TOPOLOGY topology) +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) +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); + 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) +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); } @@ -299,39 +413,80 @@ static inline void D3D11End(D3D11DeviceContext device_context, D3D11Asynchronous { 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) +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) +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) +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); + 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) +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) +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); + 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) +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); + 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) +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) +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) +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); } @@ -339,289 +494,584 @@ 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) +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); + 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) +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); + 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) +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); + 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) +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); + device_context->lpVtbl->DispatchIndirect( + device_context, buffer_for_args, aligned_byte_offset_for_args); } -static inline void D3D11SetState(D3D11DeviceContext device_context, D3D11RasterizerState rasterizer_state) +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) +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) +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) +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); + 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) +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) +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); + 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) +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); + 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]) +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]) +static inline void D3D11ClearUnorderedAccessViewUint( + D3D11DeviceContext device_context, + D3D11UnorderedAccessView unordered_access_view, + UINT values[4]) { - device_context->lpVtbl->ClearUnorderedAccessViewUint(device_context, unordered_access_view, values); + device_context->lpVtbl->ClearUnorderedAccessViewUint( + device_context, unordered_access_view, values); } -static inline void D3D11ClearUnorderedAccessViewFloat(D3D11DeviceContext device_context, D3D11UnorderedAccessView unordered_access_view, FLOAT values[4]) +static inline void D3D11ClearUnorderedAccessViewFloat( + D3D11DeviceContext device_context, + D3D11UnorderedAccessView unordered_access_view, + FLOAT values[4]) { - device_context->lpVtbl->ClearUnorderedAccessViewFloat(device_context, unordered_access_view, values); + 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) +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); + device_context->lpVtbl->ClearDepthStencilView( + device_context, depth_stencil_view, clear_flags, depth, stencil); } -static inline void D3D11GenerateMips(D3D11DeviceContext device_context, D3D11ShaderResourceView shader_resource_view) +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) +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) +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) +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); + 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) +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) +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); + 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) +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); + 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) +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) +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); + 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) +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); + 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) +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); + 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) +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) +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); + 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) +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); + 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) +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); + 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) +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); + 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) +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) +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); + 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) +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); + 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) +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); + 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) +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); + 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) +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) +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); + 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) +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); + device_context->lpVtbl->PSGetConstantBuffers( + device_context, start_slot, num_buffers, constant_buffers); } -static inline void D3D11GetInputLayout(D3D11DeviceContext device_context, D3D11InputLayout* input_layout) +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) +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); + 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) +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) +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); + 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) +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); + device_context->lpVtbl->GSGetShader( + device_context, geometry_shader, class_instances, num_class_instances); } -static inline void D3D11GetPrimitiveTopology(D3D11DeviceContext device_context, D3D11_PRIMITIVE_TOPOLOGY* topology) +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) +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); + 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) +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) +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) +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); + 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) +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) +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); + 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) +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); + 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) +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) +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) +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) +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) +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) +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) +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); + 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) +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); + 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) +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) +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); + 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) +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); + 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) +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); + 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) +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) +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); + 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) +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); + 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) +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); + 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) +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); + 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) +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) +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); + device_context->lpVtbl->CSGetConstantBuffers( + device_context, start_slot, num_buffers, constant_buffers); } static inline void D3D11ClearState(D3D11DeviceContext device_context) { @@ -635,11 +1085,18 @@ static inline UINT D3D11GetDeviceContextContextFlags(D3D11DeviceContext device_c { return device_context->lpVtbl->GetContextFlags(device_context); } -static inline HRESULT D3D11FinishCommandList(D3D11DeviceContext device_context, BOOL restore_deferred_context_state, D3D11CommandList* command_list) +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); + 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) +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); } @@ -647,47 +1104,74 @@ static inline HRESULT D3D11GetDriverHandle(D3D11VideoDecoder video_decoder, HAND { return video_decoder->lpVtbl->GetDriverHandle(video_decoder, driver_handle); } -static inline HRESULT D3D11GetVideoProcessorContentDesc(D3D11VideoProcessorEnumerator video_processor_enumerator, D3D11_VIDEO_PROCESSOR_CONTENT_DESC* content_desc) +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); + return video_processor_enumerator->lpVtbl->GetVideoProcessorContentDesc( + video_processor_enumerator, content_desc); } -static inline HRESULT D3D11CheckVideoProcessorFormat(D3D11VideoProcessorEnumerator video_processor_enumerator, DXGI_FORMAT format, UINT* flags) +static inline HRESULT D3D11CheckVideoProcessorFormat( + D3D11VideoProcessorEnumerator video_processor_enumerator, DXGI_FORMAT format, UINT* flags) { - return video_processor_enumerator->lpVtbl->CheckVideoProcessorFormat(video_processor_enumerator, format, 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) +static inline HRESULT D3D11GetVideoProcessorCaps( + D3D11VideoProcessorEnumerator video_processor_enumerator, D3D11_VIDEO_PROCESSOR_CAPS* caps) { - return video_processor_enumerator->lpVtbl->GetVideoProcessorCaps(video_processor_enumerator, 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) +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); + 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) +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); + 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) +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); + return video_processor_enumerator->lpVtbl->GetVideoProcessorFilterRange( + video_processor_enumerator, filter, range); } -static inline void D3D11GetContentDesc(D3D11VideoProcessor video_processor, D3D11_VIDEO_PROCESSOR_CONTENT_DESC* desc) +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) +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) +static inline HRESULT D3D11GetAuthenticatedChannelCertificateSize( + D3D11AuthenticatedChannel authenticated_channel, UINT* certificate_size) { - return authenticated_channel->lpVtbl->GetCertificateSize(authenticated_channel, certificate_size); + return authenticated_channel->lpVtbl->GetCertificateSize( + authenticated_channel, certificate_size); } -static inline HRESULT D3D11GetAuthenticatedChannelCertificate(D3D11AuthenticatedChannel authenticated_channel, UINT certificate_size, BYTE* certificate) +static inline HRESULT D3D11GetAuthenticatedChannelCertificate( + D3D11AuthenticatedChannel authenticated_channel, UINT certificate_size, BYTE* certificate) { - return authenticated_channel->lpVtbl->GetCertificate(authenticated_channel, certificate_size, certificate); + return authenticated_channel->lpVtbl->GetCertificate( + authenticated_channel, certificate_size, certificate); } -static inline void D3D11GetChannelHandle(D3D11AuthenticatedChannel authenticated_channel, HANDLE* channel_handle) +static inline void +D3D11GetChannelHandle(D3D11AuthenticatedChannel authenticated_channel, HANDLE* channel_handle) { authenticated_channel->lpVtbl->GetChannelHandle(authenticated_channel, channel_handle); } @@ -699,291 +1183,660 @@ static inline void D3D11GetDecoderProfile(D3D11CryptoSession crypto_session, GUI { crypto_session->lpVtbl->GetDecoderProfile(crypto_session, decoder_profile); } -static inline HRESULT D3D11GetCryptoSessionCertificateSize(D3D11CryptoSession crypto_session, UINT* certificate_size) +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) +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) +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) +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) +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) +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) +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); + 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) +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) +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); + return video_context->lpVtbl->DecoderBeginFrame( + video_context, decoder, view, content_key_size, content_key); } -static inline HRESULT D3D11DecoderEndFrame(D3D11VideoContext video_context, D3D11VideoDecoder decoder) +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) +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); + 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) +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) +static inline void D3D11VideoProcessorSetOutputTargetRect( + D3D11VideoContext video_context, D3D11VideoProcessor video_processor, BOOL enable, RECT* rect) { - video_context->lpVtbl->VideoProcessorSetOutputTargetRect(video_context, video_processor, enable, 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) +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); + 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) +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); + 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) +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); + 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) +static inline void D3D11VideoProcessorSetOutputConstriction( + D3D11VideoContext video_context, D3D11VideoProcessor video_processor, BOOL enable, SIZE size) { - video_context->lpVtbl->VideoProcessorSetOutputConstriction(video_context, video_processor, enable, size); + video_context->lpVtbl->VideoProcessorSetOutputConstriction( + video_context, video_processor, enable, size); } -static inline void D3D11VideoProcessorSetOutputStereoMode(D3D11VideoContext video_context, D3D11VideoProcessor video_processor, BOOL enable) +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) +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); + 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) +static inline void D3D11VideoProcessorGetOutputTargetRect( + D3D11VideoContext video_context, + D3D11VideoProcessor video_processor, + BOOL* enabled, + RECT* rect) { - video_context->lpVtbl->VideoProcessorGetOutputTargetRect(video_context, video_processor, enabled, 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) +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); + 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) +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); + 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) +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); + 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) +static inline void D3D11VideoProcessorGetOutputConstriction( + D3D11VideoContext video_context, + D3D11VideoProcessor video_processor, + BOOL* enabled, + SIZE* size) { - video_context->lpVtbl->VideoProcessorGetOutputConstriction(video_context, video_processor, enabled, size); + video_context->lpVtbl->VideoProcessorGetOutputConstriction( + video_context, video_processor, enabled, size); } -static inline void D3D11VideoProcessorGetOutputStereoMode(D3D11VideoContext video_context, D3D11VideoProcessor video_processor, BOOL* enabled) +static inline void D3D11VideoProcessorGetOutputStereoMode( + D3D11VideoContext video_context, D3D11VideoProcessor video_processor, BOOL* enabled) { - video_context->lpVtbl->VideoProcessorGetOutputStereoMode(video_context, video_processor, 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) +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); + 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) +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); + 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) +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); + 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) +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); + 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) +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); + 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) +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); + 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) +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); + 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) +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); + 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) +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); + 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) +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); + 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) +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); + 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) +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); + 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) +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); + 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) +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); + 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) +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); + 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) +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); + 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) +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); + 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) +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); + 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) +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); + 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) +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); + 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) +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); + 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) +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); + 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) +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); + 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) +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); + 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) +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); + 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) +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); + 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) +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); + 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) +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); + 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) +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); + 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) +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); + 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) +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); + 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) +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); + video_context->lpVtbl->StartSessionKeyRefresh( + video_context, crypto_session, random_number_size, random_number); } -static inline void D3D11FinishSessionKeyRefresh(D3D11VideoContext video_context, D3D11CryptoSession crypto_session) +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) +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); + 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) +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); + 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) +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); + 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) +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); + 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) +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); + 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) +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); + 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) +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) +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); + 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) +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); + 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) +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); + 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) +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); + 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) +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); + 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) +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); + 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) +static inline HRESULT D3D11CreateVideoProcessorEnumerator( + D3D11VideoDevice video_device, + D3D11_VIDEO_PROCESSOR_CONTENT_DESC* desc, + D3D11VideoProcessorEnumerator* enumerator) { return video_device->lpVtbl->CreateVideoProcessorEnumerator(video_device, desc, enumerator); } @@ -991,153 +1844,294 @@ static inline UINT D3D11GetVideoDecoderProfileCount(D3D11VideoDevice video_devic { return video_device->lpVtbl->GetVideoDecoderProfileCount(video_device); } -static inline HRESULT D3D11GetVideoDecoderProfile(D3D11VideoDevice video_device, UINT index, GUID* decoder_profile) +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) +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); + 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) +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) +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) +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); + 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) +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); + 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) +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) +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) +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) +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) +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) +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) +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) +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) +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); + 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) +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); + 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) +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); + 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) +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); + 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) +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); + 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) +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); + 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) +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); + 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) +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); + 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) +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) +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) +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) +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) +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) +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) +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) +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) +static inline HRESULT +D3D11OpenSharedResource(D3D11Device device, HANDLE h_resource, ID3D11Resource** out) { - return device->lpVtbl->OpenSharedResource(device, h_resource, __uuidof(ID3D11Resource), (void**)out); + return device->lpVtbl->OpenSharedResource( + device, h_resource, __uuidof(ID3D11Resource), (void**)out); } -static inline HRESULT D3D11CheckFormatSupport(D3D11Device device, DXGI_FORMAT format, UINT* format_support) +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) +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); + 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) +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); + 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) +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); + return device->lpVtbl->CheckFeatureSupport( + device, feature, feature_support_data, feature_support_data_size); } static inline D3D_FEATURE_LEVEL D3D11GetFeatureLevel(D3D11Device device) { @@ -1151,7 +2145,8 @@ static inline HRESULT D3D11GetDeviceRemovedReason(D3D11Device device) { return device->lpVtbl->GetDeviceRemovedReason(device); } -static inline void D3D11GetImmediateContext(D3D11Device device, D3D11DeviceContext* immediate_context) +static inline void +D3D11GetImmediateContext(D3D11Device device, D3D11DeviceContext* immediate_context) { device->lpVtbl->GetImmediateContext(device, immediate_context); } @@ -1207,15 +2202,20 @@ 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) +static inline HRESULT D3D11SetShaderTrackingOptionsByType( + D3D11TracingDevice tracing_device, UINT resource_type_flags, UINT options) { - return tracing_device->lpVtbl->SetShaderTrackingOptionsByType(tracing_device, resource_type_flags, options); + return tracing_device->lpVtbl->SetShaderTrackingOptionsByType( + tracing_device, resource_type_flags, options); } -static inline HRESULT D3D11SetShaderTrackingOptions(D3D11TracingDevice tracing_device, void* shader, UINT options) +static inline HRESULT +D3D11SetShaderTrackingOptions(D3D11TracingDevice tracing_device, void* shader, UINT options) { - return tracing_device->lpVtbl->SetShaderTrackingOptions(tracing_device, (IUnknown*)shader, options); + return tracing_device->lpVtbl->SetShaderTrackingOptions( + tracing_device, (IUnknown*)shader, options); } -static inline HRESULT D3D11SetMessageCountLimit(D3D11InfoQueue info_queue, UINT64 message_count_limit) +static inline HRESULT +D3D11SetMessageCountLimit(D3D11InfoQueue info_queue, UINT64 message_count_limit) { return info_queue->lpVtbl->SetMessageCountLimit(info_queue, message_count_limit); } @@ -1223,7 +2223,11 @@ 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) +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); } @@ -1251,11 +2255,13 @@ 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) +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) +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); } @@ -1271,7 +2277,8 @@ 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) +static inline HRESULT +D3D11PushStorageFilter(D3D11InfoQueue info_queue, D3D11_INFO_QUEUE_FILTER* filter) { return info_queue->lpVtbl->PushStorageFilter(info_queue, filter); } @@ -1283,11 +2290,13 @@ 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) +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) +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); } @@ -1303,7 +2312,8 @@ 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) +static inline HRESULT +D3D11PushRetrievalFilter(D3D11InfoQueue info_queue, D3D11_INFO_QUEUE_FILTER* filter) { return info_queue->lpVtbl->PushRetrievalFilter(info_queue, filter); } @@ -1315,19 +2325,27 @@ 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) +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) +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) +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) +static inline HRESULT +D3D11SetBreakOnSeverity(D3D11InfoQueue info_queue, D3D11_MESSAGE_SEVERITY severity, BOOL enable) { return info_queue->lpVtbl->SetBreakOnSeverity(info_queue, severity, enable); } @@ -1335,11 +2353,13 @@ static inline HRESULT D3D11SetBreakOnID(D3D11InfoQueue info_queue, D3D11_MESSAGE { return info_queue->lpVtbl->SetBreakOnID(info_queue, id, enable); } -static inline BOOL D3D11GetBreakOnCategory(D3D11InfoQueue info_queue, D3D11_MESSAGE_CATEGORY category) +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) +static inline BOOL +D3D11GetBreakOnSeverity(D3D11InfoQueue info_queue, D3D11_MESSAGE_SEVERITY severity) { return info_queue->lpVtbl->GetBreakOnSeverity(info_queue, severity); } @@ -1355,39 +2375,150 @@ 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) +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) +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); + 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) +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) +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); + 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) +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) +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) +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); + 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) +static inline void +D3D11UnmapBuffer(D3D11DeviceContext device_context, D3D11Buffer buffer, UINT subresource) { device_context->lpVtbl->Unmap(device_context, (D3D11Resource)buffer, subresource); } + +#include +#include + +typedef struct d3d11_vertex_t +{ + float position[2]; + float texcoord[2]; + float color[4]; +} d3d11_vertex_t; + +typedef struct +{ + D3D11Texture2D handle; + D3D11Texture2D staging; + D3D11_TEXTURE2D_DESC desc; + D3D11ShaderResourceView view; + bool dirty; +} d3d11_texture_t; + +typedef struct +{ + unsigned cur_mon_id; + DXGISwapChain swapChain; + D3D11Device device; + D3D_FEATURE_LEVEL supportedFeatureLevel; + D3D11DeviceContext ctx; + D3D11RenderTargetView renderTargetView; + D3D11InputLayout layout; + D3D11VertexShader vs; + D3D11PixelShader ps; + D3D11SamplerState sampler_nearest; + D3D11SamplerState sampler_linear; + D3D11BlendState blend_enable; + D3D11BlendState blend_disable; + float clearcolor[4]; + struct + { + d3d11_texture_t texture; + D3D11Buffer vbo; + D3D11SamplerState sampler; + bool enabled; + bool fullscreen; + } menu; + struct + { + d3d11_texture_t texture; + D3D11Buffer vbo; + D3D11SamplerState sampler; + } frame; + DXGI_FORMAT format; + + bool vsync; +} d3d11_video_t; + +void d3d11_init_texture(D3D11Device device, d3d11_texture_t* texture); +void d3d11_update_texture( + D3D11DeviceContext ctx, + int width, + int height, + int pitch, + DXGI_FORMAT format, + const void* data, + d3d11_texture_t* texture); +DXGI_FORMAT d3d11_get_closest_match( + D3D11Device device, DXGI_FORMAT desired_format, UINT desired_format_support); + +static inline DXGI_FORMAT +d3d11_get_closest_match_texture2D(D3D11Device device, DXGI_FORMAT desired_format) +{ + return d3d11_get_closest_match( + device, desired_format, + D3D11_FORMAT_SUPPORT_TEXTURE2D | D3D11_FORMAT_SUPPORT_SHADER_SAMPLE); +} diff --git a/gfx/common/d3d12_common.c b/gfx/common/d3d12_common.c index 566875f864..630b9697b8 100644 --- a/gfx/common/d3d12_common.c +++ b/gfx/common/d3d12_common.c @@ -21,13 +21,11 @@ #include "verbosity.h" -static dylib_t d3d12_dll; +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) +HRESULT WINAPI D3D12CreateDevice( + IUnknown *pAdapter, D3D_FEATURE_LEVEL MinimumFeatureLevel, REFIID riid, void **ppDevice) { if (!d3d12_dll) d3d12_dll = dylib_load(d3d12_dll_name); @@ -46,8 +44,7 @@ D3D12CreateDevice(IUnknown *pAdapter, return TYPE_E_CANTLOADLIBRARY; } -HRESULT WINAPI -D3D12GetDebugInterface(REFIID riid, void **ppvDebug) +HRESULT WINAPI D3D12GetDebugInterface(REFIID riid, void **ppvDebug) { if (!d3d12_dll) d3d12_dll = dylib_load(d3d12_dll_name); @@ -66,10 +63,10 @@ D3D12GetDebugInterface(REFIID riid, void **ppvDebug) return TYPE_E_CANTLOADLIBRARY; } -HRESULT WINAPI -D3D12SerializeRootSignature(const D3D12_ROOT_SIGNATURE_DESC *pRootSignature, - D3D_ROOT_SIGNATURE_VERSION Version, - ID3DBlob **ppBlob, ID3DBlob **ppErrorBlob) +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); @@ -79,7 +76,8 @@ D3D12SerializeRootSignature(const D3D12_ROOT_SIGNATURE_DESC *pRootSignature, static PFN_D3D12_SERIALIZE_ROOT_SIGNATURE fp; if (!fp) - fp = (PFN_D3D12_SERIALIZE_ROOT_SIGNATURE)dylib_proc(d3d12_dll, "D3D12SerializeRootSignature"); + fp = (PFN_D3D12_SERIALIZE_ROOT_SIGNATURE)dylib_proc( + d3d12_dll, "D3D12SerializeRootSignature"); if (fp) return fp(pRootSignature, Version, ppBlob, ppErrorBlob); @@ -88,9 +86,10 @@ D3D12SerializeRootSignature(const D3D12_ROOT_SIGNATURE_DESC *pRootSignature, return TYPE_E_CANTLOADLIBRARY; } -HRESULT WINAPI -D3D12SerializeVersionedRootSignature(const D3D12_VERSIONED_ROOT_SIGNATURE_DESC *pRootSignature, - ID3DBlob **ppBlob, ID3DBlob **ppErrorBlob) +HRESULT WINAPI D3D12SerializeVersionedRootSignature( + const D3D12_VERSIONED_ROOT_SIGNATURE_DESC *pRootSignature, + ID3DBlob ** ppBlob, + ID3DBlob ** ppErrorBlob) { if (!d3d12_dll) d3d12_dll = dylib_load(d3d12_dll_name); @@ -100,8 +99,8 @@ D3D12SerializeVersionedRootSignature(const D3D12_VERSIONED_ROOT_SIGNATURE_DESC * static PFN_D3D12_SERIALIZE_VERSIONED_ROOT_SIGNATURE fp; if (!fp) - fp = (PFN_D3D12_SERIALIZE_VERSIONED_ROOT_SIGNATURE)dylib_proc(d3d12_dll, - "D3D12SerializeRootSignature"); + fp = (PFN_D3D12_SERIALIZE_VERSIONED_ROOT_SIGNATURE)dylib_proc( + d3d12_dll, "D3D12SerializeRootSignature"); if (fp) return fp(pRootSignature, ppBlob, ppErrorBlob); @@ -110,7 +109,6 @@ D3D12SerializeVersionedRootSignature(const D3D12_VERSIONED_ROOT_SIGNATURE_DESC * return TYPE_E_CANTLOADLIBRARY; } - #include bool d3d12_init_base(d3d12_video_t *d3d12) @@ -144,19 +142,18 @@ bool d3d12_init_base(d3d12_video_t *d3d12) bool d3d12_init_queue(d3d12_video_t *d3d12) { { - static const D3D12_COMMAND_QUEUE_DESC desc = - { - .Type = D3D12_COMMAND_LIST_TYPE_DIRECT, + static const 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); + 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); + d3d12->queue.allocator, d3d12->pipe.handle, &d3d12->queue.cmd); D3D12CloseGraphicsCommandList(d3d12->queue.cmd); @@ -170,22 +167,21 @@ bool d3d12_init_queue(d3d12_video_t *d3d12) 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, + 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, + .SampleDesc.Count = 1, #if 0 .BufferDesc.RefreshRate.Numerator = 60, .BufferDesc.RefreshRate.Denominator = 1, .SampleDesc.Quality = 0, #endif - .BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT, + .BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT, .OutputWindow = hwnd, - .Windowed = TRUE, -#if 1 + .Windowed = TRUE, +#if 0 .SwapEffect = DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL, #else .SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD, @@ -200,15 +196,16 @@ bool d3d12_init_swapchain(d3d12_video_t *d3d12, int width, int height, HWND hwnd 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; + 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]); + 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.viewport.Width = width; + d3d12->chain.viewport.Height = height; + d3d12->chain.scissorRect.right = width; d3d12->chain.scissorRect.bottom = height; return true; @@ -217,74 +214,74 @@ bool d3d12_init_swapchain(d3d12_video_t *d3d12, int width, int height, HWND hwnd 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->cpu = D3D12GetCPUDescriptorHandleForHeapStart(out->handle); + out->gpu = D3D12GetGPUDescriptorHandleForHeapStart(out->handle); out->stride = D3D12GetDescriptorHandleIncrementSize(device, out->desc.Type); } -static void d3d12_init_sampler(D3D12Device device, d3d12_descriptor_heap_t *heap, descriptor_heap_slot_t heap_index, - D3D12_FILTER filter, D3D12_TEXTURE_ADDRESS_MODE address_mode, D3D12_GPU_DESCRIPTOR_HANDLE* dst) +static void d3d12_init_sampler(D3D12Device device, + d3d12_descriptor_heap_t * heap, + descriptor_heap_slot_t heap_index, + D3D12_FILTER filter, + D3D12_TEXTURE_ADDRESS_MODE address_mode, + D3D12_GPU_DESCRIPTOR_HANDLE * dst) { - D3D12_SAMPLER_DESC sampler_desc = - { - .Filter = filter, - .AddressU = address_mode, - .AddressV = address_mode, - .AddressW = address_mode, - .MipLODBias = 0, - .MaxAnisotropy = 0, + D3D12_SAMPLER_DESC sampler_desc = { + .Filter = filter, + .AddressU = address_mode, + .AddressV = address_mode, + .AddressW = address_mode, + .MipLODBias = 0, + .MaxAnisotropy = 0, .ComparisonFunc = D3D12_COMPARISON_FUNC_NEVER, - .BorderColor = {0.0f}, - .MinLOD = 0.0f, - .MaxLOD = D3D12_FLOAT32_MAX, + .BorderColor = { 0.0f }, + .MinLOD = 0.0f, + .MaxLOD = D3D12_FLOAT32_MAX, }; - D3D12_CPU_DESCRIPTOR_HANDLE handle = {heap->cpu.ptr + heap_index * heap->stride}; + D3D12_CPU_DESCRIPTOR_HANDLE handle = { heap->cpu.ptr + heap_index * heap->stride }; D3D12CreateSampler(device, &sampler_desc, handle); dst->ptr = heap->gpu.ptr + heap_index * heap->stride; } bool d3d12_init_descriptors(d3d12_video_t *d3d12) { - static const D3D12_DESCRIPTOR_RANGE srv_table[] = - { + static const D3D12_DESCRIPTOR_RANGE srv_table[] = { { - .RangeType = D3D12_DESCRIPTOR_RANGE_TYPE_SRV, - .NumDescriptors = 1, - .BaseShaderRegister = 0, - .RegisterSpace = 0, + .RangeType = D3D12_DESCRIPTOR_RANGE_TYPE_SRV, + .NumDescriptors = 1, + .BaseShaderRegister = 0, + .RegisterSpace = 0, #if 0 .Flags = D3D12_DESCRIPTOR_RANGE_FLAG_DATA_STATIC, /* version 1_1 only */ #endif - .OffsetInDescriptorsFromTableStart = D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND, + .OffsetInDescriptorsFromTableStart = D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND, }, }; - static const D3D12_DESCRIPTOR_RANGE sampler_table[] = - { + static const D3D12_DESCRIPTOR_RANGE sampler_table[] = { { - .RangeType = D3D12_DESCRIPTOR_RANGE_TYPE_SAMPLER, - .NumDescriptors = 1, - .BaseShaderRegister = 0, - .RegisterSpace = 0, - .OffsetInDescriptorsFromTableStart = D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND, + .RangeType = D3D12_DESCRIPTOR_RANGE_TYPE_SAMPLER, + .NumDescriptors = 1, + .BaseShaderRegister = 0, + .RegisterSpace = 0, + .OffsetInDescriptorsFromTableStart = D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND, }, }; - static const D3D12_ROOT_PARAMETER rootParameters[] = - { + static const D3D12_ROOT_PARAMETER rootParameters[] = { { - .ParameterType = D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE, - .DescriptorTable = {countof(srv_table), srv_table}, - .ShaderVisibility = D3D12_SHADER_VISIBILITY_PIXEL, + .ParameterType = D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE, + .DescriptorTable = { countof(srv_table), srv_table }, + .ShaderVisibility = D3D12_SHADER_VISIBILITY_PIXEL, }, { - .ParameterType = D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE, - .DescriptorTable = {countof(sampler_table), sampler_table}, - .ShaderVisibility = D3D12_SHADER_VISIBILITY_PIXEL, + .ParameterType = D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE, + .DescriptorTable = { countof(sampler_table), sampler_table }, + .ShaderVisibility = D3D12_SHADER_VISIBILITY_PIXEL, }, }; - static const D3D12_ROOT_SIGNATURE_DESC desc = - { - .NumParameters = countof(rootParameters), rootParameters, + static const D3D12_ROOT_SIGNATURE_DESC desc = { + .NumParameters = countof(rootParameters), + rootParameters, .Flags = D3D12_ROOT_SIGNATURE_FLAG_ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT, }; @@ -295,37 +292,38 @@ bool d3d12_init_descriptors(d3d12_video_t *d3d12) if (error) { - RARCH_ERR("[D3D12]: CreateRootSignature failed :\n%s\n", (const char *)D3DGetBufferPointer(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); + D3DGetBufferSize(signature), &d3d12->pipe.rootSignature); Release(signature); } - d3d12->pipe.rtv_heap.desc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_RTV; + 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->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.Type = D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV; d3d12->pipe.srv_heap.desc.NumDescriptors = SRV_HEAP_SLOT_MAX; - d3d12->pipe.srv_heap.desc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE; + d3d12->pipe.srv_heap.desc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE; d3d12_init_descriptor_heap(d3d12->device, &d3d12->pipe.srv_heap); - d3d12->pipe.sampler_heap.desc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER; + d3d12->pipe.sampler_heap.desc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER; d3d12->pipe.sampler_heap.desc.NumDescriptors = SAMPLER_HEAP_SLOT_MAX; - d3d12->pipe.sampler_heap.desc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE; + d3d12->pipe.sampler_heap.desc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE; d3d12_init_descriptor_heap(d3d12->device, &d3d12->pipe.sampler_heap); - d3d12_init_sampler(d3d12->device, &d3d12->pipe.sampler_heap, - SAMPLER_HEAP_SLOT_LINEAR, D3D12_FILTER_MIN_MAG_MIP_LINEAR, - D3D12_TEXTURE_ADDRESS_MODE_BORDER, &d3d12->sampler_linear); - d3d12_init_sampler(d3d12->device, &d3d12->pipe.sampler_heap, - SAMPLER_HEAP_SLOT_NEAREST, D3D12_FILTER_MIN_MAG_MIP_POINT, - D3D12_TEXTURE_ADDRESS_MODE_BORDER, &d3d12->sampler_nearest); + d3d12_init_sampler(d3d12->device, &d3d12->pipe.sampler_heap, SAMPLER_HEAP_SLOT_LINEAR, + D3D12_FILTER_MIN_MAG_MIP_LINEAR, D3D12_TEXTURE_ADDRESS_MODE_BORDER, + &d3d12->sampler_linear); + d3d12_init_sampler(d3d12->device, &d3d12->pipe.sampler_heap, SAMPLER_HEAP_SLOT_NEAREST, + D3D12_FILTER_MIN_MAG_MIP_POINT, D3D12_TEXTURE_ADDRESS_MODE_BORDER, + &d3d12->sampler_nearest); return true; } @@ -334,44 +332,49 @@ bool d3d12_init_pipeline(d3d12_video_t *d3d12) D3DBlob vs_code; D3DBlob ps_code; - static const char stock [] = + static const char stock[] = #include "gfx/drivers/d3d_shaders/opaque_sm5.hlsl.h" - ; + ; - static const 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}, + static const 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 }, }; - - static const D3D12_RASTERIZER_DESC rasterizerDesc = - { - .FillMode = D3D12_FILL_MODE_SOLID, - .CullMode = D3D12_CULL_MODE_BACK, + static const 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, + .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, + .ForcedSampleCount = 0, + .ConservativeRaster = D3D12_CONSERVATIVE_RASTERIZATION_MODE_OFF, }; - static const D3D12_BLEND_DESC blendDesc = - { - .AlphaToCoverageEnable = FALSE, + static const D3D12_BLEND_DESC blendDesc = { + .AlphaToCoverageEnable = FALSE, .IndependentBlendEnable = FALSE, .RenderTarget[0] = - { - .BlendEnable = TRUE, .LogicOpEnable = FALSE, - D3D12_BLEND_SRC_ALPHA, D3D12_BLEND_INV_SRC_ALPHA, D3D12_BLEND_OP_ADD, - D3D12_BLEND_SRC_ALPHA, D3D12_BLEND_INV_SRC_ALPHA, D3D12_BLEND_OP_ADD, - D3D12_LOGIC_OP_NOOP, D3D12_COLOR_WRITE_ENABLE_ALL, - }, + { + .BlendEnable = TRUE, + .LogicOpEnable = FALSE, + D3D12_BLEND_SRC_ALPHA, + D3D12_BLEND_INV_SRC_ALPHA, + D3D12_BLEND_OP_ADD, + D3D12_BLEND_SRC_ALPHA, + D3D12_BLEND_INV_SRC_ALPHA, + D3D12_BLEND_OP_ADD, + D3D12_LOGIC_OP_NOOP, + D3D12_COLOR_WRITE_ENABLE_ALL, + }, }; if (!d3d_compile(stock, sizeof(stock), "VSMain", "vs_5_0", &vs_code)) @@ -381,21 +384,23 @@ bool d3d12_init_pipeline(d3d12_video_t *d3d12) 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, + 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), + .InputLayout.pInputElementDescs = inputElementDesc, + countof(inputElementDesc), .PrimitiveTopologyType = D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE, - .NumRenderTargets = 1, - .RTVFormats[0] = DXGI_FORMAT_R8G8B8A8_UNORM, - .SampleDesc.Count = 1, + .NumRenderTargets = 1, + .RTVFormats[0] = DXGI_FORMAT_R8G8B8A8_UNORM, + .SampleDesc.Count = 1, }; D3D12CreateGraphicsPipelineState(d3d12->device, &psodesc, &d3d12->pipe.handle); @@ -407,128 +412,144 @@ bool d3d12_init_pipeline(d3d12_video_t *d3d12) return true; } -void d3d12_create_vertex_buffer(D3D12Device device, D3D12_VERTEX_BUFFER_VIEW *view, - D3D12Resource *vbo) +void d3d12_create_vertex_buffer( + D3D12Device device, D3D12_VERTEX_BUFFER_VIEW *view, D3D12Resource *vbo) { - static const D3D12_HEAP_PROPERTIES heap_props = - { - .Type = D3D12_HEAP_TYPE_UPLOAD, + static const D3D12_HEAP_PROPERTIES heap_props = { + .Type = D3D12_HEAP_TYPE_UPLOAD, .CreationNodeMask = 1, - .VisibleNodeMask = 1, + .VisibleNodeMask = 1, }; - D3D12_RESOURCE_DESC resource_desc = - { - .Dimension = D3D12_RESOURCE_DIMENSION_BUFFER, - .Width = view->SizeInBytes, - .Height = 1, + D3D12_RESOURCE_DESC resource_desc = { + .Dimension = D3D12_RESOURCE_DIMENSION_BUFFER, + .Width = view->SizeInBytes, + .Height = 1, .DepthOrArraySize = 1, - .MipLevels = 1, + .MipLevels = 1, .SampleDesc.Count = 1, - .Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR, + .Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR, }; D3D12CreateCommittedResource(device, &heap_props, D3D12_HEAP_FLAG_NONE, &resource_desc, - D3D12_RESOURCE_STATE_GENERIC_READ, NULL, vbo); + D3D12_RESOURCE_STATE_GENERIC_READ, NULL, vbo); view->BufferLocation = D3D12GetGPUVirtualAddress(*vbo); } -void d3d12_create_texture(D3D12Device device, d3d12_descriptor_heap_t *heap, descriptor_heap_slot_t heap_index, - d3d12_texture_t *tex) +void d3d12_init_texture(D3D12Device device, + d3d12_descriptor_heap_t * heap, + descriptor_heap_slot_t heap_index, + d3d12_texture_t * texture) { - { - tex->desc.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D; - tex->desc.DepthOrArraySize = 1; - tex->desc.MipLevels = 1; - tex->desc.SampleDesc.Count = 1; + Release(texture->handle); + Release(texture->upload_buffer); - 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); + { + texture->desc.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D; + texture->desc.DepthOrArraySize = 1; + texture->desc.MipLevels = 1; + texture->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, &texture->desc, + D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE, NULL, &texture->handle); } - D3D12GetCopyableFootprints(device, &tex->desc, 0, 1, 0, &tex->layout, &tex->num_rows, - &tex->row_size_in_bytes, &tex->total_bytes); + D3D12GetCopyableFootprints(device, &texture->desc, 0, 1, 0, &texture->layout, &texture->num_rows, + &texture->row_size_in_bytes, &texture->total_bytes); { - D3D12_RESOURCE_DESC buffer_desc = - { - .Dimension = D3D12_RESOURCE_DIMENSION_BUFFER, - .Width = tex->total_bytes, - .Height = 1, + D3D12_RESOURCE_DESC buffer_desc = { + .Dimension = D3D12_RESOURCE_DIMENSION_BUFFER, + .Width = texture->total_bytes, + .Height = 1, .DepthOrArraySize = 1, - .MipLevels = 1, + .MipLevels = 1, .SampleDesc.Count = 1, - .Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR, + .Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR, }; - D3D12_HEAP_PROPERTIES heap_props = {D3D12_HEAP_TYPE_UPLOAD, 0, 0, 1, 1}; + 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_RESOURCE_STATE_GENERIC_READ, NULL, &texture->upload_buffer); } { - D3D12_SHADER_RESOURCE_VIEW_DESC view_desc = - { + 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, + .Format = texture->desc.Format, + .ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2D, + .Texture2D.MipLevels = texture->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; + D3D12_CPU_DESCRIPTOR_HANDLE handle = { heap->cpu.ptr + heap_index * heap->stride }; + D3D12CreateShaderResourceView(device, texture->handle, &view_desc, handle); + texture->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, + 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, + D3D12_TEXTURE_COPY_LOCATION dst = { + .pResource = texture->handle, + .Type = D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX, .SubresourceIndex = 0, }; - d3d12_resource_transition(cmd, texture->handle, - D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE, D3D12_RESOURCE_STATE_COPY_DEST); + d3d12_resource_transition(cmd, texture->handle, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE, + D3D12_RESOURCE_STATE_COPY_DEST); D3D12CopyTextureRegion(cmd, &dst, 0, 0, 0, &src, NULL); - d3d12_resource_transition(cmd, texture->handle, - D3D12_RESOURCE_STATE_COPY_DEST, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE); + d3d12_resource_transition(cmd, texture->handle, D3D12_RESOURCE_STATE_COPY_DEST, + D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE); texture->dirty = false; } -void d3d12_create_fullscreen_quad_vbo(D3D12Device device, D3D12_VERTEX_BUFFER_VIEW *view, D3D12Resource *vbo) +void d3d12_create_fullscreen_quad_vbo( + D3D12Device device, D3D12_VERTEX_BUFFER_VIEW *view, D3D12Resource *vbo) { - static const 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}}, + static const 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 } }, }; - view->SizeInBytes = sizeof(vertices); + view->SizeInBytes = sizeof(vertices); view->StrideInBytes = sizeof(*vertices); d3d12_create_vertex_buffer(device, view, vbo); { - void *vertex_data_begin; - D3D12_RANGE read_range = {0, 0}; + void * vertex_data_begin; + D3D12_RANGE read_range = { 0, 0 }; D3D12Map(*vbo, 0, &read_range, &vertex_data_begin); memcpy(vertex_data_begin, vertices, sizeof(vertices)); D3D12Unmap(*vbo, 0, NULL); } } + +DXGI_FORMAT d3d12_get_closest_match( + D3D12Device device, DXGI_FORMAT desired_format, D3D12_FORMAT_SUPPORT1 desired_format_support) +{ + DXGI_FORMAT *format = dxgi_get_format_fallback_list(desired_format); + UINT format_support; + while (*format != DXGI_FORMAT_UNKNOWN) + { + D3D12_FEATURE_DATA_FORMAT_SUPPORT format_support = { *format }; + if (SUCCEEDED(D3D12CheckFeatureSupport( + device, D3D12_FEATURE_FORMAT_SUPPORT, &format_support, sizeof(format_support))) && + ((format_support.Support1 & desired_format_support) == desired_format_support)) + break; + format++; + } + assert(*format); + return *format; +} diff --git a/gfx/common/d3d12_common.h b/gfx/common/d3d12_common.h index 8b75151a15..246328c771 100644 --- a/gfx/common/d3d12_common.h +++ b/gfx/common/d3d12_common.h @@ -29,11 +29,11 @@ #include "dxgi_common.h" #ifndef countof -#define countof(a) (sizeof(a)/ sizeof(*a)) +#define countof(a) (sizeof(a) / sizeof(*a)) #endif #ifndef __uuidof -#define __uuidof(type) &IID_##type +#define __uuidof(type) & IID_##type #endif #ifndef COM_RELEASE_DECLARED @@ -41,12 +41,18 @@ #if defined(__cplusplus) && !defined(CINTERFACE) static inline ULONG Release(IUnknown* object) { - return object->Release(); + if (object) + return object->Release(); + + return 0; } #else static inline ULONG Release(void* object) { - return ((IUnknown*)object)->lpVtbl->Release(object); + if (object) + return ((IUnknown*)object)->lpVtbl->Release(object); + + return 0; } #endif #endif @@ -90,39 +96,47 @@ static inline ULONG D3D12ReleaseRootSignature(D3D12RootSignature root_signature) { return root_signature->lpVtbl->Release(root_signature); } -static inline ULONG D3D12ReleaseRootSignatureDeserializer(D3D12RootSignatureDeserializer root_signature_deserializer) +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) +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) +static inline ULONG D3D12ReleaseVersionedRootSignatureDeserializer( + D3D12VersionedRootSignatureDeserializer versioned_root_signature_deserializer) { - return versioned_root_signature_deserializer->lpVtbl->Release(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) +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); + 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) +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); + 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 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) +static inline HRESULT D3D12Map( + void* resource, UINT subresource, D3D12_RANGE* read_range, void** data) { return ((ID3D12Resource*)resource)->lpVtbl->Map(resource, subresource, read_range, data); } @@ -134,17 +148,25 @@ 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) +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); + 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) +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); + 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) +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); + return ((ID3D12Resource*)resource) + ->lpVtbl->GetHeapProperties(resource, heap_properties, heap_flags); } static inline ULONG D3D12ReleaseCommandAllocator(D3D12CommandAllocator command_allocator) { @@ -154,10 +176,7 @@ static inline HRESULT D3D12ResetCommandAllocator(D3D12CommandAllocator command_a { return command_allocator->lpVtbl->Reset(command_allocator); } -static inline ULONG D3D12ReleaseFence(D3D12Fence fence) -{ - return fence->lpVtbl->Release(fence); -} +static inline ULONG D3D12ReleaseFence(D3D12Fence fence) { return fence->lpVtbl->Release(fence); } static inline UINT64 D3D12GetCompletedValue(D3D12Fence fence) { return fence->lpVtbl->GetCompletedValue(fence); @@ -202,175 +221,270 @@ static inline HRESULT D3D12CloseGraphicsCommandList(D3D12GraphicsCommandList gra { return graphics_command_list->lpVtbl->Close(graphics_command_list); } -static inline HRESULT D3D12ResetGraphicsCommandList(D3D12GraphicsCommandList graphics_command_list, D3D12CommandAllocator allocator, D3D12PipelineState initial_state) +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) +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) +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); + 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) +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); + 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) +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); + 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) +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); + 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) +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); + 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) +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); + 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) +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); + 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) +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); + 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) +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) +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) +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) +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) +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) +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) +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) +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) +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) +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); + 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) +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); + 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) +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); + 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) +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); + 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) +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); + 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) +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); + 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) +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); + 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) +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); + 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) +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); + 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) +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); + 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) +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); + 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) +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); + 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) +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) +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); + 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) +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) +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); + 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) +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); + 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) +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); + 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) +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) +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) +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); + 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) +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); + 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) +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) +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); } @@ -378,27 +492,44 @@ static inline void D3D12EndGraphicsCommandListEvent(D3D12GraphicsCommandList gra { 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) +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); + 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) +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); + 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) +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); + 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) +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) +static inline void D3D12BeginCommandQueueEvent( + D3D12CommandQueue command_queue, UINT metadata, void* data, UINT size) { command_queue->lpVtbl->BeginEvent(command_queue, metadata, data, size); } @@ -406,7 +537,8 @@ static inline void D3D12EndCommandQueueEvent(D3D12CommandQueue command_queue) { command_queue->lpVtbl->EndEvent(command_queue); } -static inline HRESULT D3D12SignalCommandQueue(D3D12CommandQueue command_queue, D3D12Fence fence, UINT64 value) +static inline HRESULT D3D12SignalCommandQueue( + D3D12CommandQueue command_queue, D3D12Fence fence, UINT64 value) { return command_queue->lpVtbl->Signal(command_queue, fence, value); } @@ -418,7 +550,8 @@ static inline HRESULT D3D12GetTimestampFrequency(D3D12CommandQueue command_queue { return command_queue->lpVtbl->GetTimestampFrequency(command_queue, frequency); } -static inline HRESULT D3D12GetClockCalibration(D3D12CommandQueue command_queue, UINT64* gpu_timestamp, UINT64* cpu_timestamp) +static inline HRESULT D3D12GetClockCalibration( + D3D12CommandQueue command_queue, UINT64* gpu_timestamp, UINT64* cpu_timestamp) { return command_queue->lpVtbl->GetClockCalibration(command_queue, gpu_timestamp, cpu_timestamp); } @@ -430,111 +563,166 @@ static inline UINT D3D12GetNodeCount(D3D12Device device) { return device->lpVtbl->GetNodeCount(device); } -static inline HRESULT D3D12CreateCommandQueue(D3D12Device device, D3D12_COMMAND_QUEUE_DESC* desc, ID3D12CommandQueue** out) +static inline HRESULT D3D12CreateCommandQueue( + D3D12Device device, D3D12_COMMAND_QUEUE_DESC* desc, ID3D12CommandQueue** out) { - return device->lpVtbl->CreateCommandQueue(device, desc, __uuidof(ID3D12CommandQueue), (void**)out); + return device->lpVtbl->CreateCommandQueue( + device, desc, __uuidof(ID3D12CommandQueue), (void**)out); } -static inline HRESULT D3D12CreateCommandAllocator(D3D12Device device, D3D12_COMMAND_LIST_TYPE type, ID3D12CommandAllocator** out) +static inline HRESULT D3D12CreateCommandAllocator( + D3D12Device device, D3D12_COMMAND_LIST_TYPE type, ID3D12CommandAllocator** out) { - return device->lpVtbl->CreateCommandAllocator(device, type, __uuidof(ID3D12CommandAllocator), (void**)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) +static inline HRESULT D3D12CreateGraphicsPipelineState( + D3D12Device device, D3D12_GRAPHICS_PIPELINE_STATE_DESC* desc, ID3D12PipelineState** out) { - return device->lpVtbl->CreateGraphicsPipelineState(device, desc, __uuidof(ID3D12PipelineState), (void**)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) +static inline HRESULT D3D12CreateComputePipelineState( + D3D12Device device, D3D12_COMPUTE_PIPELINE_STATE_DESC* desc, ID3D12PipelineState** out) { - return device->lpVtbl->CreateComputePipelineState(device, desc, __uuidof(ID3D12PipelineState), (void**)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) +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); + 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) +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); + 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) +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); + 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) +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) +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); + 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) +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) +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) +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); + 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) +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) +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) +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) +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); + 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) +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); + 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) +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); + 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) +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) +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); + 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) +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); + 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) +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); + 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) +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); + 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) +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); + 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) +static inline HRESULT D3D12CreateQueryHeap( + D3D12Device device, D3D12_QUERY_HEAP_DESC* desc, ID3D12Heap** out) { return device->lpVtbl->CreateQueryHeap(device, desc, __uuidof(ID3D12Heap), (void**)out); } @@ -542,13 +730,23 @@ 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) +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); + 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) +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); + 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) { @@ -558,31 +756,34 @@ static inline ULONG D3D12ReleasePipelineLibrary(D3D12PipelineLibrary pipeline_li { return pipeline_library->lpVtbl->Release(pipeline_library); } -static inline HRESULT D3D12StorePipeline(D3D12PipelineLibrary pipeline_library, LPCWSTR name, D3D12PipelineState pipeline) +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) +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); + 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) +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); + 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) +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) +static inline ULONG D3D12ReleaseDebug(D3D12Debug debug) { return debug->lpVtbl->Release(debug); } +static inline void D3D12EnableDebugLayer(D3D12Debug debug) { debug->lpVtbl->EnableDebugLayer(debug); } @@ -590,7 +791,8 @@ 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) +static inline HRESULT D3D12SetDebugDeviceFeatureMask( + D3D12DebugDevice debug_device, D3D12_DEBUG_FEATURE mask) { return debug_device->lpVtbl->SetFeatureMask(debug_device, mask); } @@ -598,7 +800,8 @@ static inline D3D12_DEBUG_FEATURE D3D12GetDebugDeviceFeatureMask(D3D12DebugDevic { return debug_device->lpVtbl->GetFeatureMask(debug_device); } -static inline HRESULT D3D12ReportLiveDeviceObjects(D3D12DebugDevice debug_device, D3D12_RLDO_FLAGS flags) +static inline HRESULT D3D12ReportLiveDeviceObjects( + D3D12DebugDevice debug_device, D3D12_RLDO_FLAGS flags) { return debug_device->lpVtbl->ReportLiveDeviceObjects(debug_device, flags); } @@ -606,23 +809,29 @@ static inline ULONG D3D12ReleaseDebugCommandQueue(D3D12DebugCommandQueue debug_c { return debug_command_queue->lpVtbl->Release(debug_command_queue); } -static inline BOOL D3D12AssertDebugCommandQueueResourceState(D3D12DebugCommandQueue debug_command_queue, void* resource, UINT subresource, UINT state) +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); + 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) +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); + 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) +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) +static inline D3D12_DEBUG_FEATURE D3D12GetDebugCommandListFeatureMask( + D3D12DebugCommandList debug_command_list) { return debug_command_list->lpVtbl->GetFeatureMask(debug_command_list); } @@ -630,7 +839,8 @@ 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) +static inline HRESULT D3D12SetMessageCountLimit( + D3D12InfoQueue info_queue, UINT64 message_count_limit) { return info_queue->lpVtbl->SetMessageCountLimit(info_queue, message_count_limit); } @@ -638,7 +848,8 @@ 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) +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); } @@ -666,11 +877,13 @@ 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) +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) +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); } @@ -686,7 +899,8 @@ 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) +static inline HRESULT D3D12PushStorageFilter( + D3D12InfoQueue info_queue, D3D12_INFO_QUEUE_FILTER* filter) { return info_queue->lpVtbl->PushStorageFilter(info_queue, filter); } @@ -698,11 +912,13 @@ 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) +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) +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); } @@ -718,7 +934,8 @@ 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) +static inline HRESULT D3D12PushRetrievalFilter( + D3D12InfoQueue info_queue, D3D12_INFO_QUEUE_FILTER* filter) { return info_queue->lpVtbl->PushRetrievalFilter(info_queue, filter); } @@ -730,31 +947,38 @@ 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) +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) +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) +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) +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) +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) +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) +static inline BOOL D3D12GetBreakOnSeverity( + D3D12InfoQueue info_queue, D3D12_MESSAGE_SEVERITY severity) { return info_queue->lpVtbl->GetBreakOnSeverity(info_queue, severity); } @@ -773,73 +997,91 @@ static inline BOOL D3D12GetMuteDebugOutput(D3D12InfoQueue info_queue) /* end of auto-generated */ -static inline HRESULT D3D12GetDebugInterface_(D3D12Debug* out ) +static inline HRESULT D3D12GetDebugInterface_(D3D12Debug* out) { return D3D12GetDebugInterface(__uuidof(ID3D12Debug), (void**)out); } -static inline HRESULT D3D12CreateDevice_(DXGIAdapter adapter, D3D_FEATURE_LEVEL MinimumFeatureLevel, D3D12Device* out) +static inline HRESULT D3D12CreateDevice_( + DXGIAdapter adapter, D3D_FEATURE_LEVEL MinimumFeatureLevel, D3D12Device* out) { - return D3D12CreateDevice((IUnknown*)adapter, MinimumFeatureLevel, __uuidof(ID3D12Device), (void**)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) +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); + 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) +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); + 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) +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) +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); + command_queue->lpVtbl->ExecuteCommandLists( + command_queue, num_command_lists, (ID3D12CommandList* const*)command_lists); } -static inline HRESULT DXGIGetSwapChainBuffer(DXGISwapChain swapchain, UINT buffer, D3D12Resource* surface) +static inline HRESULT DXGIGetSwapChainBuffer( + DXGISwapChain swapchain, UINT buffer, D3D12Resource* surface) { - return swapchain->lpVtbl->GetBuffer(swapchain, buffer, __uuidof(ID3D12Resource), (void **)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) +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) +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) +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) +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); + ((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) +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); + ((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]; @@ -849,85 +1091,85 @@ typedef struct d3d12_vertex_t typedef struct { - D3D12DescriptorHeap handle; /* descriptor pool */ - D3D12_DESCRIPTOR_HEAP_DESC desc; + 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; + 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; + 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; + UINT num_rows; + UINT64 row_size_in_bytes; + UINT64 total_bytes; + bool dirty; +} d3d12_texture_t; typedef struct { - unsigned cur_mon_id; + unsigned cur_mon_id; DXGIFactory factory; DXGIAdapter adapter; D3D12Device device; struct { - D3D12CommandQueue handle; - D3D12CommandAllocator allocator; + D3D12CommandQueue handle; + D3D12CommandAllocator allocator; D3D12GraphicsCommandList cmd; - D3D12Fence fence; - HANDLE fenceEvent; - UINT64 fenceValue; - }queue; + 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 */ + D3D12PipelineState handle; + D3D12RootSignature rootSignature; /* descriptor layout */ + d3d12_descriptor_heap_t srv_heap; /* ShaderResouceView descritor heap */ + d3d12_descriptor_heap_t rtv_heap; /* RenderTargetView descritor heap */ d3d12_descriptor_heap_t sampler_heap; - }pipe; + } pipe; struct { - DXGISwapChain handle; - D3D12Resource renderTargets[2]; + 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; + 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; + D3D12Resource vbo; + D3D12_VERTEX_BUFFER_VIEW vbo_view; + d3d12_texture_t texture; D3D12_GPU_DESCRIPTOR_HANDLE sampler; - bool rgb32; - }frame; + } frame; struct { - D3D12Resource vbo; - D3D12_VERTEX_BUFFER_VIEW vbo_view; - d3d12_texture_t tex; + D3D12Resource vbo; + D3D12_VERTEX_BUFFER_VIEW vbo_view; + d3d12_texture_t texture; D3D12_GPU_DESCRIPTOR_HANDLE sampler; float alpha; - bool enabled; - bool fullscreen; - }menu; + bool enabled; + bool fullscreen; + } menu; + DXGI_FORMAT format; D3D12_GPU_DESCRIPTOR_HANDLE sampler_linear; D3D12_GPU_DESCRIPTOR_HANDLE sampler_nearest; @@ -941,8 +1183,7 @@ enum DESC_TABLE_INDEX_SRV_TEXTURE = 0, DESC_TABLE_INDEX_SAMPLER, }; -typedef enum -{ +typedef enum { SAMPLER_HEAP_SLOT_LINEAR = 0, SAMPLER_HEAP_SLOT_NEAREST, SAMPLER_HEAP_SLOT_MAX, @@ -951,30 +1192,34 @@ typedef enum SRV_HEAP_SLOT_MENU_TEXTURE, SRV_HEAP_SLOT_CUSTOM, SRV_HEAP_SLOT_MAX = 16 -}descriptor_heap_slot_t; +} descriptor_heap_slot_t; bool d3d12_init_base(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); +bool d3d12_init_queue(d3d12_video_t* d3d12); + +void d3d12_create_vertex_buffer( + D3D12Device device, D3D12_VERTEX_BUFFER_VIEW* view, D3D12Resource* vbo); + +void d3d12_init_texture(D3D12Device device, d3d12_descriptor_heap_t* heap, + descriptor_heap_slot_t heap_index, d3d12_texture_t* tex); -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, descriptor_heap_slot_t heap_index, d3d12_texture_t *tex); void d3d12_upload_texture(D3D12GraphicsCommandList cmd, d3d12_texture_t* texture); -void d3d12_create_fullscreen_quad_vbo(D3D12Device device, D3D12_VERTEX_BUFFER_VIEW *view, D3D12Resource *vbo); +void d3d12_create_fullscreen_quad_vbo( + D3D12Device device, D3D12_VERTEX_BUFFER_VIEW* view, D3D12Resource* vbo); static inline d3d12_resource_transition(D3D12GraphicsCommandList cmd, D3D12Resource resource, - D3D12_RESOURCE_STATES state_before, D3D12_RESOURCE_STATES state_after) + 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, + 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.StateAfter = state_after, .Transition.Subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES, }; D3D12ResourceBarrier(cmd, 1, &barrier); @@ -990,3 +1235,28 @@ static inline d3d12_set_sampler(D3D12GraphicsCommandList cmd, D3D12_GPU_DESCRIPT D3D12SetGraphicsRootDescriptorTable(cmd, DESC_TABLE_INDEX_SAMPLER, sampler); } +static inline void d3d12_update_texture(int width, int height, int pitch, DXGI_FORMAT format, + const void* data, d3d12_texture_t* texture) +{ + uint8_t* dst; + D3D12_RANGE read_range = { 0, 0 }; + + D3D12Map(texture->upload_buffer, 0, &read_range, &dst); + + dxgi_copy(width, height, format, pitch, data, texture->desc.Format, + texture->layout.Footprint.RowPitch, dst + texture->layout.Offset); + + D3D12Unmap(texture->upload_buffer, 0, NULL); + + texture->dirty = true; +} + +DXGI_FORMAT d3d12_get_closest_match( + D3D12Device device, DXGI_FORMAT desired_format, D3D12_FORMAT_SUPPORT1 desired_format_support); + +static inline DXGI_FORMAT d3d12_get_closest_match_texture2D( + D3D12Device device, DXGI_FORMAT desired_format) +{ + return d3d12_get_closest_match(device, desired_format, + D3D12_FORMAT_SUPPORT1_TEXTURE2D | D3D12_FORMAT_SUPPORT1_SHADER_SAMPLE); +} diff --git a/gfx/common/dxgi_common.c b/gfx/common/dxgi_common.c index 0092dd5f52..463c06dd8c 100644 --- a/gfx/common/dxgi_common.c +++ b/gfx/common/dxgi_common.c @@ -13,6 +13,7 @@ * If not, see . */ +#include #include #include "dxgi_common.h" @@ -20,20 +21,222 @@ HRESULT WINAPI CreateDXGIFactory1(REFIID riid, void **ppFactory) { static dylib_t dxgi_dll; - static HRESULT (WINAPI *fp)(REFIID, void **); + static HRESULT(WINAPI * fp)(REFIID, void **); - if(!dxgi_dll) + if (!dxgi_dll) dxgi_dll = dylib_load("dxgi.dll"); - if(!dxgi_dll) + if (!dxgi_dll) return TYPE_E_CANTLOADLIBRARY; - if(!fp) - fp = (HRESULT (WINAPI *)(REFIID, void **))dylib_proc(dxgi_dll, "CreateDXGIFactory1"); + if (!fp) + fp = (HRESULT(WINAPI *)(REFIID, void **))dylib_proc(dxgi_dll, "CreateDXGIFactory1"); - if(!fp) + if (!fp) return TYPE_E_CANTLOADLIBRARY; return fp(riid, ppFactory); } +DXGI_FORMAT *dxgi_get_format_fallback_list(DXGI_FORMAT format) +{ + static DXGI_FORMAT format_unknown = DXGI_FORMAT_UNKNOWN; + + switch ((unsigned)format) + { + case DXGI_FORMAT_R8G8B8A8_UNORM: + { + static DXGI_FORMAT formats[] = { DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_B8G8R8A8_UNORM, + DXGI_FORMAT_B8G8R8X8_UNORM, DXGI_FORMAT_UNKNOWN }; + return formats; + } + case DXGI_FORMAT_B8G8R8A8_UNORM: + { + static DXGI_FORMAT formats[] = { DXGI_FORMAT_B8G8R8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, + DXGI_FORMAT_UNKNOWN }; + return formats; + } + case DXGI_FORMAT_B8G8R8X8_UNORM: + { + static DXGI_FORMAT formats[] = { DXGI_FORMAT_B8G8R8X8_UNORM, DXGI_FORMAT_B8G8R8A8_UNORM, + DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_UNKNOWN }; + return formats; + } + case DXGI_FORMAT_B5G6R5_UNORM: + { + static DXGI_FORMAT formats[] = { DXGI_FORMAT_B5G6R5_UNORM, DXGI_FORMAT_B8G8R8X8_UNORM, + DXGI_FORMAT_B8G8R8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, + DXGI_FORMAT_UNKNOWN }; + return formats; + } + case DXGI_FORMAT_EX_A4R4G4B4_UNORM: + case DXGI_FORMAT_B4G4R4A4_UNORM: + { + static DXGI_FORMAT formats[] = { DXGI_FORMAT_B4G4R4A4_UNORM, DXGI_FORMAT_B8G8R8A8_UNORM, + DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_UNKNOWN }; + return formats; + } + default: + assert(0); + } + return &format_unknown; +} + +#define FORMAT_PROCESS_( \ + src_type, src_rb, src_gb, src_bb, src_ab, src_rs, src_gs, src_bs, src_as, dst_type, dst_rb, \ + dst_gb, dst_bb, dst_ab, dst_rs, dst_gs, dst_bs, dst_as) \ + do \ + { \ + if (((src_rs == dst_rs && src_rb == dst_rb) || !dst_rb) && \ + ((src_gs == dst_gs && src_gb == dst_gb) || !dst_gb) && \ + ((src_bs == dst_bs && src_bb == dst_bb) || !dst_bb) && \ + ((src_as == dst_as && src_ab == dst_ab) || !dst_ab)) \ + { \ + const UINT8 *in = src_data; \ + UINT8 * out = dst_data; \ + for (i = 0; i < height; i++) \ + { \ + memcpy(out, in, width * sizeof(src_type)); \ + in += src_pitch ? src_pitch : width * sizeof(src_type); \ + out += dst_pitch ? dst_pitch : width * sizeof(dst_type); \ + } \ + } \ + else \ + { \ + const src_type *src_ptr = (const src_type *)src_data; \ + dst_type * dst_ptr = (dst_type *)dst_data; \ + if (src_pitch) \ + src_pitch -= width * sizeof(*src_ptr); \ + if (dst_pitch) \ + dst_pitch -= width * sizeof(*dst_ptr); \ + for (i = 0; i < height; i++) \ + { \ + for (j = 0; j < width; j++) \ + { \ + unsigned r, g, b, a; \ + src_type src_val = *src_ptr++; \ + if (src_rb) \ + { \ + r = (src_val >> src_rs) & ((1 << src_rb) - 1); \ + r = (src_rb < dst_rb) \ + ? (r << (dst_rb - src_rb)) | \ + (r >> ((2 * src_rb > dst_rb) ? 2 * src_rb - dst_rb : 0)) \ + : r >> (src_rb - dst_rb); \ + } \ + if (src_gb) \ + { \ + g = (src_val >> src_gs) & ((1 << src_gb) - 1); \ + g = (src_gb < dst_gb) \ + ? (g << (dst_gb - src_gb)) | \ + (g >> ((2 * src_gb > dst_gb) ? 2 * src_gb - dst_gb : 0)) \ + : g >> (src_gb - dst_gb); \ + } \ + if (src_bb) \ + { \ + b = (src_val >> src_bs) & ((1 << src_bb) - 1); \ + b = (src_bb < dst_bb) \ + ? (b << (dst_bb - src_bb)) | \ + (b >> ((2 * src_bb > dst_bb) ? 2 * src_bb - dst_bb : 0)) \ + : b >> (src_bb - dst_bb); \ + } \ + if (src_ab) \ + { \ + a = (src_val >> src_as) & ((1 << src_ab) - 1); \ + a = (src_ab < dst_ab) \ + ? (a << (dst_ab - src_ab)) | \ + (a >> ((2 * src_ab > dst_ab) ? 2 * src_ab - dst_ab : 0)) \ + : a >> (src_ab - dst_ab); \ + } \ + *dst_ptr++ = ((src_rb ? r : 0) << dst_rs) | ((src_gb ? g : 0) << dst_gs) | \ + ((src_bb ? b : 0) << dst_bs) | \ + ((src_ab ? a : ((1 << dst_ab) - 1)) << dst_as); \ + } \ + src_ptr = (src_type *)((UINT8 *)src_ptr + src_pitch); \ + dst_ptr = (dst_type *)((UINT8 *)dst_ptr + dst_pitch); \ + } \ + } \ + } while (0) + +#define FORMAT_PROCESS(args) FORMAT_PROCESS_ args + +#define FORMAT_DST(st, dt) \ + case dt: \ + { \ + FORMAT_PROCESS((st##_DESCS, dt##_DESCS)); \ + break; \ + } + +#define FORMAT_SRC(st) \ + case st: \ + { \ + switch ((unsigned)dst_format) \ + { \ + FORMAT_DST_LIST(st); \ + default: \ + assert(0); \ + break; \ + } \ + break; \ + } + +/* r, g, b, a r, g, b, a */ +#define DXGI_FORMAT_R8G8B8A8_UNORM_DESCS UINT32, 8, 8, 8, 8, 0, 8, 16, 24 +#define DXGI_FORMAT_B8G8R8X8_UNORM_DESCS UINT32, 8, 8, 8, 0, 16, 8, 0, 0 +#define DXGI_FORMAT_B8G8R8A8_UNORM_DESCS UINT32, 8, 8, 8, 8, 16, 8, 0, 24 +#define DXGI_FORMAT_B5G6R5_UNORM_DESCS UINT16, 5, 6, 5, 0, 11, 5, 0, 0 +#define DXGI_FORMAT_B5G5R5A1_UNORM_DESCS UINT16, 5, 5, 5, 1, 10, 5, 0, 11 +#define DXGI_FORMAT_B4G4R4A4_UNORM_DESCS UINT16, 4, 4, 4, 4, 8, 4, 0, 12 +#define DXGI_FORMAT_EX_A4R4G4B4_UNORM_DESCS UINT16, 4, 4, 4, 4, 4, 8, 12, 0 + +#define FORMAT_SRC_LIST() \ + FORMAT_SRC(DXGI_FORMAT_R8G8B8A8_UNORM); \ + FORMAT_SRC(DXGI_FORMAT_B8G8R8X8_UNORM); \ + FORMAT_SRC(DXGI_FORMAT_B5G6R5_UNORM); \ + FORMAT_SRC(DXGI_FORMAT_B5G5R5A1_UNORM); \ + FORMAT_SRC(DXGI_FORMAT_B4G4R4A4_UNORM); \ + FORMAT_SRC(DXGI_FORMAT_B8G8R8A8_UNORM); \ + FORMAT_SRC(DXGI_FORMAT_EX_A4R4G4B4_UNORM) + +#define FORMAT_DST_LIST(srcfmt) \ + FORMAT_DST(srcfmt, DXGI_FORMAT_R8G8B8A8_UNORM); \ + FORMAT_DST(srcfmt, DXGI_FORMAT_B8G8R8X8_UNORM); \ + FORMAT_DST(srcfmt, DXGI_FORMAT_B5G6R5_UNORM); \ + FORMAT_DST(srcfmt, DXGI_FORMAT_B5G5R5A1_UNORM); \ + FORMAT_DST(srcfmt, DXGI_FORMAT_B4G4R4A4_UNORM); \ + FORMAT_DST(srcfmt, DXGI_FORMAT_B8G8R8A8_UNORM); \ + FORMAT_DST(srcfmt, DXGI_FORMAT_EX_A4R4G4B4_UNORM) + +#ifdef _MSC_VER +#pragma warning(disable : 4293) +#endif +void dxgi_copy( + int width, + int height, + DXGI_FORMAT src_format, + int src_pitch, + const void *src_data, + DXGI_FORMAT dst_format, + int dst_pitch, + void * dst_data) +{ + int i, j; +#if defined(PERF_START) && defined(PERF_STOP) + PERF_START(); +#endif + + switch ((unsigned)src_format) + { + FORMAT_SRC_LIST(); + + default: + assert(0); + break; + } + +#if defined(PERF_START) && defined(PERF_STOP) + PERF_STOP(); +#endif +} +#ifdef _MSC_VER +#pragma warning(default : 4293) +#endif diff --git a/gfx/common/dxgi_common.h b/gfx/common/dxgi_common.h index e37e65240a..1bfa91d4ea 100644 --- a/gfx/common/dxgi_common.h +++ b/gfx/common/dxgi_common.h @@ -10,14 +10,15 @@ #endif #define CINTERFACE +#include #include #ifndef countof -#define countof(a) (sizeof(a)/ sizeof(*a)) +#define countof(a) (sizeof(a) / sizeof(*a)) #endif #ifndef __uuidof -#define __uuidof(type) &IID_##type +#define __uuidof(type) & IID_##type #endif #ifndef COM_RELEASE_DECLARED @@ -25,12 +26,18 @@ #if defined(__cplusplus) && !defined(CINTERFACE) static inline ULONG Release(IUnknown* object) { - return object->Release(); + if (object) + return object->Release(); + + return 0; } #else static inline ULONG Release(void* object) { - return ((IUnknown*)object)->lpVtbl->Release(object); + if (object) + return ((IUnknown*)object)->lpVtbl->Release(object); + + return 0; } #endif #endif @@ -93,10 +100,7 @@ static inline HRESULT DXGIMap(DXGISurface surface, DXGI_MAPPED_RECT* locked_rect { return surface->lpVtbl->Map(surface, locked_rect, map_flags); } -static inline HRESULT DXGIUnmap(DXGISurface surface) -{ - return surface->lpVtbl->Unmap(surface); -} +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); @@ -105,17 +109,20 @@ 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) +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) +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); + return output->lpVtbl->FindClosestMatchingMode( + output, mode_to_match, closest_match, (IUnknown*)concerned_device); } static inline HRESULT DXGIWaitForVBlank(DXGIOutput output) { @@ -129,7 +136,8 @@ static inline void DXGIReleaseOwnership(DXGIOutput output) { output->lpVtbl->ReleaseOwnership(output); } -static inline HRESULT DXGIGetGammaControlCapabilities(DXGIOutput output, DXGI_GAMMA_CONTROL_CAPABILITIES* gamma_caps) +static inline HRESULT +DXGIGetGammaControlCapabilities(DXGIOutput output, DXGI_GAMMA_CONTROL_CAPABILITIES* gamma_caps) { return output->lpVtbl->GetGammaControlCapabilities(output, gamma_caps); } @@ -149,13 +157,17 @@ static inline HRESULT DXGIGetDisplaySurfaceData(DXGIOutput output, DXGISurface d { return output->lpVtbl->GetDisplaySurfaceData(output, (IDXGISurface*)destination); } -static inline ULONG DXGIReleaseDevice(DXGIDevice device) +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->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); + return device->lpVtbl->CreateSurface( + device, desc, num_surfaces, usage, shared_resource, (IDXGISurface**)surface); } static inline HRESULT DXGISetGPUThreadPriority(DXGIDevice device, INT priority) { @@ -177,11 +189,14 @@ static inline HRESULT DXGIGetWindowAssociation(DXGIFactory factory, HWND* window { return factory->lpVtbl->GetWindowAssociation(factory, window_handle); } -static inline HRESULT DXGICreateSwapChain(DXGIFactory factory, void* device, DXGI_SWAP_CHAIN_DESC* desc, DXGISwapChain* swap_chain) +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); + return factory->lpVtbl->CreateSwapChain( + factory, (IUnknown*)device, desc, (IDXGISwapChain**)swap_chain); } -static inline HRESULT DXGICreateSoftwareAdapter(DXGIFactory factory, HMODULE module, DXGIAdapter* adapter) +static inline HRESULT +DXGICreateSoftwareAdapter(DXGIFactory factory, HMODULE module, DXGIAdapter* adapter) { return factory->lpVtbl->CreateSoftwareAdapter(factory, module, (IDXGIAdapter**)adapter); } @@ -201,7 +216,8 @@ static inline HRESULT DXGIEnumOutputs(DXGIAdapter adapter, UINT id, DXGIOutput* { return adapter->lpVtbl->EnumOutputs(adapter, id, output); } -static inline HRESULT DXGICheckInterfaceSupport(DXGIAdapter adapter, REFGUID interface_name, LARGE_INTEGER* u_m_d_version) +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); } @@ -225,23 +241,49 @@ static inline ULONG DXGIReleaseOutputDuplication(DXGIOutputDuplication output_du { 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) +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); + 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) +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); + 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) +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); + 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) +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); + 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) +static inline HRESULT +DXGIMapDesktopSurface(DXGIOutputDuplication output_duplication, DXGI_MAPPED_RECT* locked_rect) { return output_duplication->lpVtbl->MapDesktopSurface(output_duplication, locked_rect); } @@ -257,9 +299,11 @@ static inline ULONG DXGIReleaseDecodeSwapChain(DXGIDecodeSwapChain decode_swap_c { 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) +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); + 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) { @@ -269,7 +313,8 @@ static inline HRESULT DXGISetTargetRect(DXGIDecodeSwapChain decode_swap_chain, R { return decode_swap_chain->lpVtbl->SetTargetRect(decode_swap_chain, rect); } -static inline HRESULT DXGISetDestSize(DXGIDecodeSwapChain decode_swap_chain, UINT width, UINT height) +static inline HRESULT +DXGISetDestSize(DXGIDecodeSwapChain decode_swap_chain, UINT width, UINT height) { return decode_swap_chain->lpVtbl->SetDestSize(decode_swap_chain, width, height); } @@ -281,15 +326,18 @@ static inline HRESULT DXGIGetTargetRect(DXGIDecodeSwapChain decode_swap_chain, R { return decode_swap_chain->lpVtbl->GetTargetRect(decode_swap_chain, rect); } -static inline HRESULT DXGIGetDestSize(DXGIDecodeSwapChain decode_swap_chain, UINT* width, UINT* height) +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) +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) +static inline DXGI_MULTIPLANE_OVERLAY_YCbCr_FLAGS +DXGIGetColorSpace(DXGIDecodeSwapChain decode_swap_chain) { return decode_swap_chain->lpVtbl->GetColorSpace(decode_swap_chain); } @@ -297,19 +345,37 @@ 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) +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); + 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) +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); + 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) +static inline HRESULT +DXGIGetFrameStatisticsMedia(DXGISwapChainMedia swap_chain_media, DXGI_FRAME_STATISTICS_MEDIA* stats) { return swap_chain_media->lpVtbl->GetFrameStatisticsMedia(swap_chain_media, stats); } @@ -317,9 +383,15 @@ static inline HRESULT DXGISetPresentDuration(DXGISwapChainMedia swap_chain_media { 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) +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); + 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) { @@ -333,19 +405,29 @@ static inline HRESULT DXGIGetBuffer(DXGISwapChain swap_chain, UINT buffer, IDXGI { return swap_chain->lpVtbl->GetBuffer(swap_chain, buffer, __uuidof(IDXGISurface), (void**)out); } -static inline HRESULT DXGISetFullscreenState(DXGISwapChain swap_chain, BOOL fullscreen, DXGIOutput target) +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) +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) +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); + 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) +static inline HRESULT +DXGIResizeTarget(DXGISwapChain swap_chain, DXGI_MODE_DESC* new_target_parameters) { return swap_chain->lpVtbl->ResizeTarget(swap_chain, new_target_parameters); } @@ -365,7 +447,8 @@ static inline HRESULT DXGIGetSwapChainDesc1(DXGISwapChain swap_chain, DXGI_SWAP_ { return swap_chain->lpVtbl->GetDesc1(swap_chain, desc); } -static inline HRESULT DXGIGetFullscreenDesc(DXGISwapChain swap_chain, DXGI_SWAP_CHAIN_FULLSCREEN_DESC* desc) +static inline HRESULT +DXGIGetFullscreenDesc(DXGISwapChain swap_chain, DXGI_SWAP_CHAIN_FULLSCREEN_DESC* desc) { return swap_chain->lpVtbl->GetFullscreenDesc(swap_chain, desc); } @@ -373,15 +456,21 @@ 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) +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); + 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) +static inline HRESULT +DXGIGetRestrictToOutput(DXGISwapChain swap_chain, DXGIOutput* restrict_to_output) { return swap_chain->lpVtbl->GetRestrictToOutput(swap_chain, restrict_to_output); } @@ -433,11 +522,13 @@ 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) +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) +static inline HRESULT +DXGISetColorSpace1(DXGISwapChain swap_chain, DXGI_COLOR_SPACE_TYPE color_space) { return swap_chain->lpVtbl->SetColorSpace1(swap_chain, color_space); } @@ -448,3 +539,40 @@ static inline HRESULT DXGICreateFactory(DXGIFactory* factory) { return CreateDXGIFactory1(__uuidof(IDXGIFactory1), (void**)factory); } + +/* internal */ + +typedef enum { + DXGI_FORMAT_EX_A4R4G4B4_UNORM = 1000, +} DXGI_FORMAT_EX; + +DXGI_FORMAT* dxgi_get_format_fallback_list(DXGI_FORMAT format); + +void dxgi_copy( + int width, + int height, + DXGI_FORMAT src_format, + int src_pitch, + const void* src_data, + DXGI_FORMAT dst_format, + int dst_pitch, + void* dst_data); + +#if 1 +#include +#ifndef PERF_START +#define PERF_START() \ + static struct retro_perf_counter perfcounter = { __FUNCTION__ }; \ + LARGE_INTEGER start, stop; \ + rarch_perf_register(&perfcounter); \ + perfcounter.call_cnt++; \ + QueryPerformanceCounter(&start) + +#define PERF_STOP() \ + QueryPerformanceCounter(&stop); \ + perfcounter.total += stop.QuadPart - start.QuadPart +#endif +#else +#define PERF_START() +#define PERF_STOP() +#endif diff --git a/gfx/common/win32_common.c b/gfx/common/win32_common.c index 1d49aed4d7..e0e547cf60 100644 --- a/gfx/common/win32_common.c +++ b/gfx/common/win32_common.c @@ -75,7 +75,7 @@ const GUID GUID_DEVINTERFACE_HID = { 0x4d1e55b2, 0xf16f, 0x11Cf, { 0x88, 0xcb, 0 static HDEVNOTIFY notification_handler; #endif -#if defined(HAVE_D3D9) || defined(HAVE_D3D8) +#if defined(HAVE_D3D8) || defined(HAVE_D3D9) || defined (HAVE_D3D10) || defined (HAVE_D3D11) || defined (HAVE_D3D12) extern bool dinput_handle_message(void *dinput, UINT message, WPARAM wParam, LPARAM lParam); extern void *dinput_gdi; @@ -569,7 +569,7 @@ static void win32_set_droppable(ui_window_win32_t *window, bool droppable) DragAcceptFiles_func(window->hwnd, droppable); } -#if defined(HAVE_D3D9) || defined(HAVE_D3D8) +#if defined(HAVE_D3D8) || defined(HAVE_D3D9) || defined (HAVE_D3D10) || defined (HAVE_D3D11) || defined (HAVE_D3D12) LRESULT CALLBACK WndProcD3D(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) { diff --git a/gfx/common/win32_common.h b/gfx/common/win32_common.h index 39ffcded83..963db7f2cf 100644 --- a/gfx/common/win32_common.h +++ b/gfx/common/win32_common.h @@ -127,7 +127,7 @@ bool win32_taskbar_is_created(void); void win32_set_taskbar_created(bool created); -#if defined(HAVE_D3D9) || defined(HAVE_D3D8) +#if defined(HAVE_D3D8) || defined(HAVE_D3D9) || defined (HAVE_D3D10) || defined (HAVE_D3D11) || defined (HAVE_D3D12) LRESULT CALLBACK WndProcD3D(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam); #endif diff --git a/gfx/drivers/d3d.h b/gfx/drivers/d3d.h index 74010360ab..883559e210 100644 --- a/gfx/drivers/d3d.h +++ b/gfx/drivers/d3d.h @@ -37,7 +37,9 @@ #include "../font_driver.h" #include "../video_driver.h" +#if defined(HAVE_D3D8) || defined(HAVE_D3D9) #include "../common/d3d_common.h" +#endif #ifdef _XBOX #include "../../defines/xdk_defines.h" #endif diff --git a/gfx/drivers/d3d10.c b/gfx/drivers/d3d10.c new file mode 100644 index 0000000000..dcb37a878a --- /dev/null +++ b/gfx/drivers/d3d10.c @@ -0,0 +1,446 @@ +/* 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/d3d10_common.h" +#include "gfx/common/dxgi_common.h" +#include "gfx/common/d3dcompiler_common.h" + +static void* +d3d10_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 }; + d3d10_video_t* d3d10 = (d3d10_video_t*)calloc(1, sizeof(*d3d10)); + + if (!d3d10) + return NULL; + + win32_window_reset(); + win32_monitor_init(); + wndclass.lpfnWndProc = WndProcD3D; + win32_window_init(&wndclass, true, NULL); + + if (!win32_set_video_mode(d3d10, video->width, video->height, video->fullscreen)) + { + RARCH_ERR("[D3D10]: win32_set_video_mode failed.\n"); + goto error; + } + + gfx_ctx_d3d.input_driver(NULL, settings->arrays.input_joypad_driver, input, input_data); + + { + UINT flags = 0; + DXGI_SWAP_CHAIN_DESC desc = { + .BufferCount = 2, + .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, +#if 0 + .SwapEffect = DXGI_SWAP_EFFECT_SEQUENTIAL, + .SwapEffect = DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL, + .SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD, +#endif + }; + +#ifdef DEBUG + flags |= D3D10_CREATE_DEVICE_DEBUG; +#endif + + D3D10CreateDeviceAndSwapChain( + NULL, D3D10_DRIVER_TYPE_HARDWARE, NULL, flags, D3D10_SDK_VERSION, &desc, + (IDXGISwapChain**)&d3d10->swapChain, &d3d10->device); + } + + { + D3D10Texture2D backBuffer; + DXGIGetSwapChainBufferD3D10(d3d10->swapChain, 0, &backBuffer); + D3D10CreateTexture2DRenderTargetView( + d3d10->device, backBuffer, NULL, &d3d10->renderTargetView); + Release(backBuffer); + } + + D3D10SetRenderTargets(d3d10->device, 1, &d3d10->renderTargetView, NULL); + + { + D3D10_VIEWPORT vp = { 0, 0, video->width, video->height, 0.0f, 1.0f }; + D3D10SetViewports(d3d10->device, 1, &vp); + } + + d3d10->vsync = video->vsync; + d3d10->format = video->rgb32 ? DXGI_FORMAT_B8G8R8X8_UNORM : DXGI_FORMAT_B5G6R5_UNORM; + + d3d10->frame.texture.desc.Format = + d3d10_get_closest_match_texture2D(d3d10->device, d3d10->format); + d3d10->frame.texture.desc.Usage = D3D10_USAGE_DEFAULT; + d3d10->menu.texture.desc.Usage = D3D10_USAGE_DEFAULT; + + { + D3D10_SAMPLER_DESC desc = { + .Filter = D3D10_FILTER_MIN_MAG_MIP_POINT, + .AddressU = D3D10_TEXTURE_ADDRESS_BORDER, + .AddressV = D3D10_TEXTURE_ADDRESS_BORDER, + .AddressW = D3D10_TEXTURE_ADDRESS_BORDER, + .MaxAnisotropy = 1, + .ComparisonFunc = D3D10_COMPARISON_NEVER, + .MinLOD = -D3D10_FLOAT32_MAX, + .MaxLOD = D3D10_FLOAT32_MAX, + }; + D3D10CreateSamplerState(d3d10->device, &desc, &d3d10->sampler_nearest); + + desc.Filter = D3D10_FILTER_MIN_MAG_MIP_LINEAR; + D3D10CreateSamplerState(d3d10->device, &desc, &d3d10->sampler_linear); + } + + { + d3d10_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 } }, + }; + + { + D3D10_BUFFER_DESC desc = { + .ByteWidth = sizeof(vertices), + .Usage = D3D10_USAGE_DYNAMIC, + .BindFlags = D3D10_BIND_VERTEX_BUFFER, + .CPUAccessFlags = D3D10_CPU_ACCESS_WRITE, + }; + D3D10_SUBRESOURCE_DATA vertexData = { vertices }; + D3D10CreateBuffer(d3d10->device, &desc, &vertexData, &d3d10->frame.vbo); + desc.Usage = D3D10_USAGE_IMMUTABLE; + desc.CPUAccessFlags = 0; + D3D10CreateBuffer(d3d10->device, &desc, &vertexData, &d3d10->menu.vbo); + } + D3D10SetPrimitiveTopology(d3d10->device, D3D10_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP); + } + + { + D3DBlob vs_code; + D3DBlob ps_code; + + static const char stock[] = +#include "d3d_shaders/opaque_sm5.hlsl.h" + ; + + D3D10_INPUT_ELEMENT_DESC desc[] = { + { "POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, offsetof(d3d10_vertex_t, position), + D3D10_INPUT_PER_VERTEX_DATA, 0 }, + { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, offsetof(d3d10_vertex_t, texcoord), + D3D10_INPUT_PER_VERTEX_DATA, 0 }, + { "COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, offsetof(d3d10_vertex_t, color), + D3D10_INPUT_PER_VERTEX_DATA, 0 }, + }; + + d3d_compile(stock, sizeof(stock), "VSMain", "vs_4_0", &vs_code); + d3d_compile(stock, sizeof(stock), "PSMain", "ps_4_0", &ps_code); + + D3D10CreateVertexShader( + d3d10->device, D3DGetBufferPointer(vs_code), D3DGetBufferSize(vs_code), &d3d10->vs); + D3D10CreatePixelShader( + d3d10->device, D3DGetBufferPointer(ps_code), D3DGetBufferSize(ps_code), &d3d10->ps); + D3D10CreateInputLayout( + d3d10->device, desc, countof(desc), D3DGetBufferPointer(vs_code), + D3DGetBufferSize(vs_code), &d3d10->layout); + + Release(vs_code); + Release(ps_code); + } + + D3D10SetInputLayout(d3d10->device, d3d10->layout); + D3D10SetVShader(d3d10->device, d3d10->vs); + D3D10SetPShader(d3d10->device, d3d10->ps); + + { + D3D10_BLEND_DESC blend_desc = { + .AlphaToCoverageEnable = FALSE, + .BlendEnable = { TRUE }, + D3D10_BLEND_SRC_ALPHA, + D3D10_BLEND_INV_SRC_ALPHA, + D3D10_BLEND_OP_ADD, + D3D10_BLEND_SRC_ALPHA, + D3D10_BLEND_INV_SRC_ALPHA, + D3D10_BLEND_OP_ADD, + { D3D10_COLOR_WRITE_ENABLE_ALL }, + }; + D3D10CreateBlendState(d3d10->device, &blend_desc, &d3d10->blend_enable); + blend_desc.BlendEnable[0] = FALSE; + D3D10CreateBlendState(d3d10->device, &blend_desc, &d3d10->blend_disable); + } + + return d3d10; + +error: + free(d3d10); + return NULL; +} + +static bool d3d10_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; + + d3d10_video_t* d3d10 = (d3d10_video_t*)data; + PERF_START(); + D3D10ClearRenderTargetView(d3d10->device, d3d10->renderTargetView, d3d10->clearcolor); + + if (frame && width && height) + { + D3D10_BOX frame_box = { 0, 0, 0, width, height, 1 }; + + if (d3d10->frame.texture.desc.Width != width || d3d10->frame.texture.desc.Height != height) + { + d3d10->frame.texture.desc.Width = width; + d3d10->frame.texture.desc.Height = height; + d3d10_init_texture(d3d10->device, &d3d10->frame.texture); + } + + d3d10_update_texture(width, height, pitch, d3d10->format, frame, &d3d10->frame.texture); + D3D10CopyTexture2DSubresourceRegion( + d3d10->device, d3d10->frame.texture.handle, 0, 0, 0, 0, d3d10->frame.texture.staging, 0, + &frame_box); + } + + { + UINT stride = sizeof(d3d10_vertex_t); + UINT offset = 0; + D3D10SetVertexBuffers(d3d10->device, 0, 1, &d3d10->frame.vbo, &stride, &offset); + D3D10SetPShaderResources(d3d10->device, 0, 1, &d3d10->frame.texture.view); + D3D10SetPShaderSamplers(d3d10->device, 0, 1, &d3d10->sampler_linear); + + D3D10SetBlendState(d3d10->device, d3d10->blend_disable, NULL, D3D10_DEFAULT_SAMPLE_MASK); + D3D10Draw(d3d10->device, 4, 0); + D3D10SetBlendState(d3d10->device, d3d10->blend_enable, NULL, D3D10_DEFAULT_SAMPLE_MASK); + + if (d3d10->menu.enabled) + { + if (d3d10->menu.texture.dirty) + D3D10CopyTexture2DSubresourceRegion( + d3d10->device, d3d10->menu.texture.handle, 0, 0, 0, 0, + d3d10->menu.texture.staging, 0, NULL); + + D3D10SetVertexBuffers(d3d10->device, 0, 1, &d3d10->menu.vbo, &stride, &offset); + D3D10SetPShaderResources(d3d10->device, 0, 1, &d3d10->menu.texture.view); + D3D10SetPShaderSamplers(d3d10->device, 0, 1, &d3d10->sampler_linear); + + D3D10Draw(d3d10->device, 4, 0); + } + } + + DXGIPresent(d3d10->swapChain, !d3d10->vsync, 0); + PERF_STOP(); + + if (msg && *msg) + gfx_ctx_d3d.update_window_title(NULL, video_info); + + return true; +} + +static void d3d10_gfx_set_nonblock_state(void* data, bool toggle) +{ + d3d10_video_t* d3d10 = (d3d10_video_t*)data; + d3d10->vsync = !toggle; +} + +static bool d3d10_gfx_alive(void* data) +{ + (void)data; + bool quit; + bool resize; + unsigned width; + unsigned height; + + win32_check_window(&quit, &resize, &width, &height); + + if (width != 0 && height != 0) + video_driver_set_size(&width, &height); + + return !quit; +} + +static bool d3d10_gfx_focus(void* data) { return win32_has_focus(); } + +static bool d3d10_gfx_suppress_screensaver(void* data, bool enable) +{ + (void)data; + (void)enable; + return false; +} + +static bool d3d10_gfx_has_windowed(void* data) +{ + (void)data; + return true; +} + +static void d3d10_gfx_free(void* data) +{ + d3d10_video_t* d3d10 = (d3d10_video_t*)data; + + Release(d3d10->frame.texture.view); + Release(d3d10->frame.texture.handle); + Release(d3d10->frame.texture.staging); + Release(d3d10->frame.vbo); + + Release(d3d10->menu.texture.handle); + Release(d3d10->menu.texture.staging); + Release(d3d10->menu.texture.view); + Release(d3d10->menu.vbo); + + Release(d3d10->blend_enable); + Release(d3d10->blend_disable); + Release(d3d10->sampler_nearest); + Release(d3d10->sampler_linear); + Release(d3d10->ps); + Release(d3d10->vs); + Release(d3d10->layout); + Release(d3d10->renderTargetView); + Release(d3d10->swapChain); + Release(d3d10->device); + + win32_monitor_from_window(); + win32_destroy_window(); + free(d3d10); +} + +static bool d3d10_gfx_set_shader(void* data, enum rarch_shader_type type, const char* path) +{ + (void)data; + (void)type; + (void)path; + + return false; +} + +static void d3d10_gfx_set_rotation(void* data, unsigned rotation) +{ + (void)data; + (void)rotation; +} + +static void d3d10_gfx_viewport_info(void* data, struct video_viewport* vp) +{ + (void)data; + (void)vp; +} + +static bool d3d10_gfx_read_viewport(void* data, uint8_t* buffer, bool is_idle) +{ + (void)data; + (void)buffer; + + return true; +} + +static void d3d10_set_menu_texture_frame( + void* data, const void* frame, bool rgb32, unsigned width, unsigned height, float alpha) +{ + d3d10_video_t* d3d10 = (d3d10_video_t*)data; + int pitch = width * (rgb32 ? sizeof(uint32_t) : sizeof(uint16_t)); + DXGI_FORMAT format = rgb32 ? DXGI_FORMAT_B8G8R8A8_UNORM : DXGI_FORMAT_EX_A4R4G4B4_UNORM; + + if (d3d10->menu.texture.desc.Width != width || d3d10->menu.texture.desc.Height != height) + { + d3d10->menu.texture.desc.Format = d3d10_get_closest_match_texture2D(d3d10->device, format); + d3d10->menu.texture.desc.Width = width; + d3d10->menu.texture.desc.Height = height; + d3d10_init_texture(d3d10->device, &d3d10->menu.texture); + } + + d3d10_update_texture(width, height, pitch, format, frame, &d3d10->menu.texture); +} +static void d3d10_set_menu_texture_enable(void* data, bool state, bool full_screen) +{ + d3d10_video_t* d3d10 = (d3d10_video_t*)data; + + d3d10->menu.enabled = state; + d3d10->menu.fullscreen = full_screen; +} + +static const video_poke_interface_t d3d10_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 */ + d3d10_set_menu_texture_frame, /* set_texture_frame */ + d3d10_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 d3d10_gfx_get_poke_interface(void* data, const video_poke_interface_t** iface) +{ + *iface = &d3d10_poke_interface; +} + +video_driver_t video_d3d10 = { + d3d10_gfx_init, + d3d10_gfx_frame, + d3d10_gfx_set_nonblock_state, + d3d10_gfx_alive, + d3d10_gfx_focus, + d3d10_gfx_suppress_screensaver, + d3d10_gfx_has_windowed, + d3d10_gfx_set_shader, + d3d10_gfx_free, + "d3d10", + NULL, /* set_viewport */ + d3d10_gfx_set_rotation, + d3d10_gfx_viewport_info, + d3d10_gfx_read_viewport, + NULL, /* read_frame_raw */ + +#ifdef HAVE_OVERLAY + NULL, /* overlay_interface */ +#endif + d3d10_gfx_get_poke_interface, +}; diff --git a/gfx/drivers/d3d11.c b/gfx/drivers/d3d11.c index 21b83980d2..bf29fd41e4 100644 --- a/gfx/drivers/d3d11.c +++ b/gfx/drivers/d3d11.c @@ -24,55 +24,16 @@ #include "gfx/common/d3d11_common.h" #include "gfx/common/dxgi_common.h" #include "gfx/common/d3dcompiler_common.h" +#include "performance_counters.h" +#include -typedef struct d3d11_vertex_t +static void* +d3d11_gfx_init(const video_info_t* video, const input_driver_t** input, void** input_data) { - 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)); + 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; @@ -82,24 +43,18 @@ static void* d3d11_gfx_init(const video_info_t* video, wndclass.lpfnWndProc = WndProcD3D; win32_window_init(&wndclass, true, NULL); - if (!win32_set_video_mode(d3d11, video->width, - video->height, video->fullscreen)) + 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; + gfx_ctx_d3d.input_driver(NULL, settings->arrays.input_joypad_driver, input, input_data); { - UINT flags = 0; - D3D_FEATURE_LEVEL requested_feature_level = D3D_FEATURE_LEVEL_11_0; - DXGI_SWAP_CHAIN_DESC desc = - { + 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, @@ -120,78 +75,42 @@ static void* d3d11_gfx_init(const video_info_t* video, }; #ifdef DEBUG - flags |= D3D11_CREATE_DEVICE_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); + D3D11CreateDeviceAndSwapChain( + NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, flags, &requested_feature_level, 1, + D3D11_SDK_VERSION, &desc, (IDXGISwapChain**)&d3d11->swapChain, &d3d11->device, + &d3d11->supportedFeatureLevel, &d3d11->ctx); } { D3D11Texture2D backBuffer; DXGIGetSwapChainBufferD3D11(d3d11->swapChain, 0, &backBuffer); - D3D11CreateTexture2DRenderTargetView(d3d11->device, backBuffer, - NULL, &d3d11->renderTargetView); + D3D11CreateTexture2DRenderTargetView( + d3d11->device, backBuffer, NULL, &d3d11->renderTargetView); Release(backBuffer); } - D3D11SetRenderTargets(d3d11->context, 1, - &d3d11->renderTargetView, NULL); + D3D11SetRenderTargets(d3d11->ctx, 1, &d3d11->renderTargetView, NULL); + { - D3D11_VIEWPORT vp = {0, 0, video->width, video->height, 0.0f, 1.0f}; - D3D11SetViewports(d3d11->context, 1, &vp); + D3D11_VIEWPORT vp = { 0, 0, video->width, video->height, 0.0f, 1.0f }; + D3D11SetViewports(d3d11->ctx, 1, &vp); } + d3d11->vsync = video->vsync; + d3d11->format = video->rgb32 ? DXGI_FORMAT_B8G8R8X8_UNORM : DXGI_FORMAT_B5G6R5_UNORM; - 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, -#if 0 - .Format = d3d11->rgb32 ? - DXGI_FORMAT_B8G8R8X8_UNORM : DXGI_FORMAT_B5G6R5_UNORM, -#endif - .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, - }; + d3d11->frame.texture.desc.Format = + d3d11_get_closest_match_texture2D(d3d11->device, d3d11->format); + d3d11->frame.texture.desc.Usage = D3D11_USAGE_DEFAULT; - 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->menu.texture.desc.Format = DXGI_FORMAT_B4G4R4A4_UNORM; + d3d11->menu.texture.desc.Usage = D3D11_USAGE_DEFAULT; { - D3D11_SAMPLER_DESC desc = - { + D3D11_SAMPLER_DESC desc = { .Filter = D3D11_FILTER_MIN_MAG_MIP_POINT, .AddressU = D3D11_TEXTURE_ADDRESS_BORDER, .AddressV = D3D11_TEXTURE_ADDRESS_BORDER, @@ -208,70 +127,89 @@ static void* d3d11_gfx_init(const video_info_t* video, } { - 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_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 = - { + 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); + D3D11_SUBRESOURCE_DATA vertexData = { vertices }; + D3D11CreateBuffer(d3d11->device, &desc, &vertexData, &d3d11->frame.vbo); desc.Usage = D3D11_USAGE_IMMUTABLE; desc.CPUAccessFlags = 0; - D3D11CreateBuffer(d3d11->device, &desc, - &vertexData, &d3d11->menu.vbo); + D3D11CreateBuffer(d3d11->device, &desc, &vertexData, &d3d11->menu.vbo); } - D3D11SetPrimitiveTopology(d3d11->context, - D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP); + D3D11SetPrimitiveTopology(d3d11->ctx, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP); } { D3DBlob vs_code; D3DBlob ps_code; - static const char stock [] = + 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}, + 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), + 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); + D3D11SetInputLayout(d3d11->ctx, d3d11->layout); + D3D11SetVShader(d3d11->ctx, d3d11->vs, NULL, 0); + D3D11SetPShader(d3d11->ctx, d3d11->ps, NULL, 0); + + { + D3D11_BLEND_DESC blend_desc = { + .AlphaToCoverageEnable = FALSE, + .IndependentBlendEnable = FALSE, + .RenderTarget[0] = + { + .BlendEnable = TRUE, + D3D11_BLEND_SRC_ALPHA, + D3D11_BLEND_INV_SRC_ALPHA, + D3D11_BLEND_OP_ADD, + D3D11_BLEND_SRC_ALPHA, + D3D11_BLEND_INV_SRC_ALPHA, + D3D11_BLEND_OP_ADD, + D3D11_COLOR_WRITE_ENABLE_ALL, + }, + }; + D3D11CreateBlendState(d3d11->device, &blend_desc, &d3d11->blend_enable); + blend_desc.RenderTarget[0].BlendEnable = FALSE; + D3D11CreateBlendState(d3d11->device, &blend_desc, &d3d11->blend_disable); + } return d3d11; @@ -280,113 +218,69 @@ error: 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) +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) { d3d11_video_t* d3d11 = (d3d11_video_t*)data; - (void)msg; + PERF_START(); + D3D11ClearRenderTargetView(d3d11->ctx, d3d11->renderTargetView, d3d11->clearcolor); - if(frame && width && height) + if (frame && width && height) { - D3D11_MAPPED_SUBRESOURCE mapped_frame; - D3D11MapTexture2D(d3d11->context, - d3d11->frame_staging, 0, D3D11_MAP_WRITE, 0, &mapped_frame); + D3D11_BOX frame_box = { 0, 0, 0, width, height, 1 }; + + if (d3d11->frame.texture.desc.Width != width || d3d11->frame.texture.desc.Height != height) { - unsigned 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; - } - } - + d3d11->frame.texture.desc.Width = width; + d3d11->frame.texture.desc.Height = height; + d3d11_init_texture(d3d11->device, &d3d11->frame.texture); } - 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); - } + d3d11_update_texture( + d3d11->ctx, width, height, pitch, d3d11->format, frame, &d3d11->frame.texture); + D3D11CopyTexture2DSubresourceRegion( + d3d11->ctx, d3d11->frame.texture.handle, 0, 0, 0, 0, d3d11->frame.texture.staging, 0, + &frame_box); } - 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); + D3D11SetVertexBuffers(d3d11->ctx, 0, 1, &d3d11->frame.vbo, &stride, &offset); + D3D11SetPShaderResources(d3d11->ctx, 0, 1, &d3d11->frame.texture.view); + D3D11SetPShaderSamplers(d3d11->ctx, 0, 1, &d3d11->sampler_linear); - D3D11Draw(d3d11->context, 4, 0); + D3D11SetBlendState(d3d11->ctx, d3d11->blend_disable, NULL, D3D11_DEFAULT_SAMPLE_MASK); + D3D11Draw(d3d11->ctx, 4, 0); + D3D11SetBlendState(d3d11->ctx, d3d11->blend_enable, NULL, D3D11_DEFAULT_SAMPLE_MASK); - if (d3d11->menu.enabled) + if (d3d11->menu.enabled && d3d11->menu.texture.handle) { - 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); + if (d3d11->menu.texture.dirty) + D3D11CopyTexture2DSubresourceRegion( + d3d11->ctx, d3d11->menu.texture.handle, 0, 0, 0, 0, d3d11->menu.texture.staging, + 0, NULL); - D3D11Draw(d3d11->context, 4, 0); + D3D11SetVertexBuffers(d3d11->ctx, 0, 1, &d3d11->menu.vbo, &stride, &offset); + D3D11SetPShaderResources(d3d11->ctx, 0, 1, &d3d11->menu.texture.view); + D3D11SetPShaderSamplers(d3d11->ctx, 0, 1, &d3d11->sampler_linear); + + D3D11Draw(d3d11->ctx, 4, 0); } } DXGIPresent(d3d11->swapChain, !!d3d11->vsync, 0); + PERF_STOP(); - if(msg && *msg) + if (msg && *msg) gfx_ctx_d3d.update_window_title(NULL, video_info); return true; @@ -404,8 +298,8 @@ static void d3d11_gfx_set_nonblock_state(void* data, bool toggle) static bool d3d11_gfx_alive(void* data) { - bool quit; - bool resize; + bool quit; + bool resize; unsigned width; unsigned height; @@ -419,10 +313,7 @@ static bool d3d11_gfx_alive(void* data) return !quit; } -static bool d3d11_gfx_focus(void* data) -{ - return win32_has_focus(); -} +static bool d3d11_gfx_focus(void* data) { return win32_has_focus(); } static bool d3d11_gfx_suppress_screensaver(void* data, bool enable) { @@ -444,25 +335,26 @@ static void d3d11_gfx_free(void* data) if (!d3d11) return; - if(d3d11->menu.tex) - Release(d3d11->menu.tex); - if(d3d11->menu.view) - Release(d3d11->menu.view); + Release(d3d11->frame.texture.view); + Release(d3d11->frame.texture.handle); + Release(d3d11->frame.texture.staging); + Release(d3d11->frame.vbo); + Release(d3d11->menu.texture.handle); + Release(d3d11->menu.texture.staging); + Release(d3d11->menu.texture.view); Release(d3d11->menu.vbo); + Release(d3d11->blend_enable); + Release(d3d11->blend_disable); 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->ctx); Release(d3d11->device); win32_monitor_from_window(); @@ -470,8 +362,7 @@ static void d3d11_gfx_free(void* data) free(d3d11); } -static bool d3d11_gfx_set_shader(void* data, - enum rarch_shader_type type, const char* path) +static bool d3d11_gfx_set_shader(void* data, enum rarch_shader_type type, const char* path) { (void)data; (void)type; @@ -480,22 +371,19 @@ static bool d3d11_gfx_set_shader(void* data, return false; } -static void d3d11_gfx_set_rotation(void* data, - unsigned rotation) +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) +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) +static bool d3d11_gfx_read_viewport(void* data, uint8_t* buffer, bool is_idle) { (void)data; (void)buffer; @@ -503,144 +391,64 @@ static bool d3d11_gfx_read_viewport(void* data, return true; } -static void d3d11_set_menu_texture_frame(void* data, - const void* frame, bool rgb32, unsigned width, unsigned height, - float alpha) +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; + d3d11_video_t* d3d11 = (d3d11_video_t*)data; + int pitch = width * (rgb32 ? sizeof(uint32_t) : sizeof(uint16_t)); + DXGI_FORMAT format = rgb32 ? DXGI_FORMAT_B8G8R8A8_UNORM : DXGI_FORMAT_EX_A4R4G4B4_UNORM; - if ( d3d11->menu.tex && - (d3d11->menu.width != width || - d3d11->menu.height != height)) + if (d3d11->menu.texture.desc.Width != width || d3d11->menu.texture.desc.Height != height) { - Release(d3d11->menu.tex); - d3d11->menu.tex = NULL; + d3d11->menu.texture.desc.Format = d3d11_get_closest_match_texture2D(d3d11->device, format); + d3d11->menu.texture.desc.Width = width; + d3d11->menu.texture.desc.Height = height; + d3d11_init_texture(d3d11->device, &d3d11->menu.texture); } - 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); - { - unsigned 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); - } + d3d11_update_texture(d3d11->ctx, width, height, pitch, format, frame, &d3d11->menu.texture); } -static void d3d11_set_menu_texture_enable(void* data, - bool state, bool full_screen) +static void d3d11_set_menu_texture_enable(void* data, bool state, bool full_screen) { d3d11_video_t* d3d11 = (d3d11_video_t*)data; if (!d3d11) return; - d3d11->menu.enabled = state; - d3d11->menu.fullscreen = full_screen; + 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 */ +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 */ + 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) +static void d3d11_gfx_get_poke_interface(void* data, const video_poke_interface_t** iface) { *iface = &d3d11_poke_interface; } -video_driver_t video_d3d11 = -{ +video_driver_t video_d3d11 = { d3d11_gfx_init, d3d11_gfx_frame, d3d11_gfx_set_nonblock_state, diff --git a/gfx/drivers/d3d12.c b/gfx/drivers/d3d12.c index 794b4394de..abf1466999 100644 --- a/gfx/drivers/d3d12.c +++ b/gfx/drivers/d3d12.c @@ -25,9 +25,9 @@ #include "gfx/common/d3d12_common.h" #include "gfx/common/d3dcompiler_common.h" -static void d3d12_set_filtering(void *data, unsigned index, bool smooth) +static void d3d12_set_filtering(void* data, unsigned index, bool smooth) { - d3d12_video_t *d3d12 = (d3d12_video_t *)data; + d3d12_video_t* d3d12 = (d3d12_video_t*)data; if (smooth) d3d12->frame.sampler = d3d12->sampler_linear; @@ -35,13 +35,13 @@ static void d3d12_set_filtering(void *data, unsigned index, bool smooth) d3d12->frame.sampler = d3d12->sampler_nearest; } -static void *d3d12_gfx_init(const video_info_t *video, - const input_driver_t **input, void **input_data) +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)); + 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; @@ -59,9 +59,6 @@ static void *d3d12_gfx_init(const video_info_t *video, 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_base(d3d12)) goto error; @@ -78,10 +75,14 @@ static void *d3d12_gfx_init(const video_info_t *video, goto error; d3d12_create_fullscreen_quad_vbo(d3d12->device, &d3d12->frame.vbo_view, &d3d12->frame.vbo); - d3d12_create_fullscreen_quad_vbo(d3d12->device, &d3d12->menu.vbo_view, &d3d12->menu.vbo); + d3d12_create_fullscreen_quad_vbo(d3d12->device, &d3d12->menu.vbo_view, &d3d12->menu.vbo); d3d12_set_filtering(d3d12, 0, video->smooth); + d3d12->chain.vsync = video->vsync; + d3d12->format = video->rgb32 ? DXGI_FORMAT_B8G8R8X8_UNORM : DXGI_FORMAT_B5G6R5_UNORM; + d3d12->frame.texture.desc.Format = d3d12_get_closest_match_texture2D(d3d12->device, d3d12->format); + return d3d12; error: @@ -90,105 +91,87 @@ error: 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) +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) { - d3d12_video_t *d3d12 = (d3d12_video_t *)data; + d3d12_video_t* d3d12 = (d3d12_video_t*)data; (void)msg; - + PERF_START(); D3D12ResetCommandAllocator(d3d12->queue.allocator); D3D12ResetGraphicsCommandList(d3d12->queue.cmd, d3d12->queue.allocator, d3d12->pipe.handle); D3D12SetGraphicsRootSignature(d3d12->queue.cmd, d3d12->pipe.rootSignature); { - D3D12DescriptorHeap desc_heaps [] = {d3d12->pipe.srv_heap.handle, d3d12->pipe.sampler_heap.handle}; + D3D12DescriptorHeap desc_heaps[] = { d3d12->pipe.srv_heap.handle, + d3d12->pipe.sampler_heap.handle }; D3D12SetDescriptorHeaps(d3d12->queue.cmd, countof(desc_heaps), desc_heaps); } - d3d12_resource_transition(d3d12->queue.cmd, d3d12->chain.renderTargets[d3d12->chain.frame_index], - D3D12_RESOURCE_STATE_PRESENT, D3D12_RESOURCE_STATE_RENDER_TARGET); + d3d12_resource_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); + 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.texture.handle || (d3d12->frame.texture.desc.Width != width) || + (d3d12->frame.texture.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, SRV_HEAP_SLOT_FRAME_TEXTURE, - &d3d12->frame.tex); + d3d12->frame.texture.desc.Width = width; + d3d12->frame.texture.desc.Height = height; + d3d12_init_texture( + d3d12->device, &d3d12->pipe.srv_heap, SRV_HEAP_SLOT_FRAME_TEXTURE, + &d3d12->frame.texture); } + d3d12_update_texture(width, height, pitch, d3d12->format, frame, &d3d12->frame.texture); - { - unsigned i; - D3D12_RANGE read_range = {0, 0}; - const uint8_t *in = frame; - uint8_t *out = NULL; - - - D3D12Map(d3d12->frame.tex.upload_buffer, 0, &read_range, &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); - - d3d12_set_texture(d3d12->queue.cmd, &d3d12->frame.tex); + d3d12_upload_texture(d3d12->queue.cmd, &d3d12->frame.texture); + d3d12_set_texture(d3d12->queue.cmd, &d3d12->frame.texture); d3d12_set_sampler(d3d12->queue.cmd, d3d12->frame.sampler); D3D12IASetVertexBuffers(d3d12->queue.cmd, 0, 1, &d3d12->frame.vbo_view); D3D12DrawInstanced(d3d12->queue.cmd, 4, 1, 0, 0); } - if (d3d12->menu.enabled && d3d12->menu.tex.handle) + if (d3d12->menu.enabled && d3d12->menu.texture.handle) { - if (d3d12->menu.tex.dirty) - d3d12_upload_texture(d3d12->queue.cmd, &d3d12->menu.tex); + if (d3d12->menu.texture.dirty) + d3d12_upload_texture(d3d12->queue.cmd, &d3d12->menu.texture); - d3d12_set_texture(d3d12->queue.cmd, &d3d12->menu.tex); + d3d12_set_texture(d3d12->queue.cmd, &d3d12->menu.texture); d3d12_set_sampler(d3d12->queue.cmd, d3d12->menu.sampler); D3D12IASetVertexBuffers(d3d12->queue.cmd, 0, 1, &d3d12->menu.vbo_view); D3D12DrawInstanced(d3d12->queue.cmd, 4, 1, 0, 0); } - - d3d12_resource_transition(d3d12->queue.cmd, d3d12->chain.renderTargets[d3d12->chain.frame_index], - D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_PRESENT); + d3d12_resource_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); + // DXGIPresent(d3d12->chain.handle, !!d3d12->chain.vsync, 0); + DXGIPresent(d3d12->chain.handle, 0, 0); #else - DXGI_PRESENT_PARAMETERS pp = {0}; + DXGI_PRESENT_PARAMETERS pp = { 0 }; DXGIPresent1(d3d12->swapchain, 0, 0, &pp); #endif @@ -197,12 +180,14 @@ static bool d3d12_gfx_frame(void *data, const void *frame, if (D3D12GetCompletedValue(d3d12->queue.fence) < d3d12->queue.fenceValue) { - D3D12SetEventOnCompletion(d3d12->queue.fence, d3d12->queue.fenceValue, d3d12->queue.fenceEvent); + 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); + PERF_STOP(); if (msg && *msg) gfx_ctx_d3d.update_window_title(NULL, video_info); @@ -210,17 +195,17 @@ static bool d3d12_gfx_frame(void *data, const void *frame, return true; } -static void d3d12_gfx_set_nonblock_state(void *data, bool toggle) +static void d3d12_gfx_set_nonblock_state(void* data, bool toggle) { - d3d12_video_t *d3d12 = (d3d12_video_t *)data; - d3d12->chain.vsync = !toggle; + d3d12_video_t* d3d12 = (d3d12_video_t*)data; + d3d12->chain.vsync = !toggle; } -static bool d3d12_gfx_alive(void *data) +static bool d3d12_gfx_alive(void* data) { (void)data; - bool quit; - bool resize; + bool quit; + bool resize; unsigned width; unsigned height; @@ -232,43 +217,31 @@ static bool d3d12_gfx_alive(void *data) return !quit; } -static bool d3d12_gfx_focus(void *data) -{ - return win32_has_focus(); -} +static bool d3d12_gfx_focus(void* data) { return win32_has_focus(); } -static bool d3d12_gfx_suppress_screensaver(void *data, bool enable) +static bool d3d12_gfx_suppress_screensaver(void* data, bool enable) { (void)data; (void)enable; return false; } -static bool d3d12_gfx_has_windowed(void *data) +static bool d3d12_gfx_has_windowed(void* data) { (void)data; return true; } -static void d3d12_gfx_free(void *data) +static void d3d12_gfx_free(void* data) { - d3d12_video_t *d3d12 = (d3d12_video_t *)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); - + Release(d3d12->frame.texture.handle); + Release(d3d12->frame.texture.upload_buffer); Release(d3d12->menu.vbo); - - if (d3d12->menu.tex.handle) - Release(d3d12->menu.tex.handle); - - if (d3d12->menu.tex.handle) - Release(d3d12->menu.tex.upload_buffer); + Release(d3d12->menu.texture.handle); + Release(d3d12->menu.texture.upload_buffer); Release(d3d12->pipe.sampler_heap.handle); Release(d3d12->pipe.srv_heap.handle); @@ -295,8 +268,7 @@ static void d3d12_gfx_free(void *data) free(d3d12); } -static bool d3d12_gfx_set_shader(void *data, - enum rarch_shader_type type, const char *path) +static bool d3d12_gfx_set_shader(void* data, enum rarch_shader_type type, const char* path) { (void)data; (void)type; @@ -305,21 +277,19 @@ static bool d3d12_gfx_set_shader(void *data, return false; } -static void d3d12_gfx_set_rotation(void *data, - unsigned rotation) +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) +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) +static bool d3d12_gfx_read_viewport(void* data, uint8_t* buffer, bool is_idle) { (void)data; (void)buffer; @@ -327,78 +297,29 @@ static bool d3d12_gfx_read_viewport(void *data, uint8_t *buffer, bool is_idle) return true; } -static void d3d12_set_menu_texture_frame(void *data, - const void *frame, bool rgb32, unsigned width, unsigned height, - float alpha) +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; + d3d12_video_t* d3d12 = (d3d12_video_t*)data; + int pitch = width * (rgb32 ? sizeof(uint32_t) : sizeof(uint16_t)); + DXGI_FORMAT format = rgb32 ? DXGI_FORMAT_B8G8R8A8_UNORM : DXGI_FORMAT_EX_A4R4G4B4_UNORM; - if (!d3d12->menu.tex.handle || (d3d12->menu.tex.desc.Width != width) - || (d3d12->menu.tex.desc.Height = height)) + if (d3d12->menu.texture.desc.Width != width || d3d12->menu.texture.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, SRV_HEAP_SLOT_MENU_TEXTURE, - &d3d12->menu.tex); + d3d12->menu.texture.desc.Width = width; + d3d12->menu.texture.desc.Height = height; + d3d12->menu.texture.desc.Format = d3d12_get_closest_match_texture2D(d3d12->device, format); + d3d12_init_texture( + d3d12->device, &d3d12->pipe.srv_heap, SRV_HEAP_SLOT_MENU_TEXTURE, &d3d12->menu.texture); } - { - unsigned i, j; - D3D12_RANGE read_range = {0, 0}; - uint8_t *out = NULL; + d3d12_update_texture(width, height, pitch, format, frame, &d3d12->menu.texture); - D3D12Map(d3d12->menu.tex.upload_buffer, 0, &read_range, &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; { - D3D12_RANGE read_range = {0, 0}; - d3d12_vertex_t *v; + D3D12_RANGE read_range = { 0, 0 }; + d3d12_vertex_t* v; D3D12Map(d3d12->menu.vbo, 0, &read_range, &v); v[0].color[3] = alpha; @@ -407,51 +328,47 @@ static void d3d12_set_menu_texture_frame(void *data, v[3].color[3] = alpha; D3D12Unmap(d3d12->menu.vbo, 0, NULL); } - d3d12->menu.sampler = config_get_ptr()->bools.menu_linear_filter ? - d3d12->sampler_linear : d3d12->sampler_nearest; + d3d12->menu.sampler = config_get_ptr()->bools.menu_linear_filter ? d3d12->sampler_linear + : d3d12->sampler_nearest; } -static void d3d12_set_menu_texture_enable(void *data, - bool state, bool full_screen) +static void d3d12_set_menu_texture_enable(void* data, bool state, bool full_screen) { - d3d12_video_t *d3d12 = (d3d12_video_t *)data; + d3d12_video_t* d3d12 = (d3d12_video_t*)data; - d3d12->menu.enabled = state; - d3d12->menu.fullscreen = full_screen; + 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 */ +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 */ + 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) +static void d3d12_gfx_get_poke_interface(void* data, const video_poke_interface_t** iface) { *iface = &d3d12_poke_interface; } -video_driver_t video_d3d12 = -{ +video_driver_t video_d3d12 = { d3d12_gfx_init, d3d12_gfx_frame, d3d12_gfx_set_nonblock_state, diff --git a/gfx/video_driver.c b/gfx/video_driver.c index eaf6527205..f651ef43de 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -262,6 +262,9 @@ static const video_driver_t *video_drivers[] = { #ifdef XENON &video_xenon360, #endif +#if defined(HAVE_D3D10) + &video_d3d10, +#endif #if defined(HAVE_D3D11) &video_d3d11, #endif diff --git a/gfx/video_driver.h b/gfx/video_driver.h index e7b2408294..1cf7ac49f1 100644 --- a/gfx/video_driver.h +++ b/gfx/video_driver.h @@ -1337,6 +1337,7 @@ extern video_driver_t video_ctr; extern video_driver_t video_switch; extern video_driver_t video_d3d8; extern video_driver_t video_d3d9; +extern video_driver_t video_d3d10; extern video_driver_t video_d3d11; extern video_driver_t video_d3d12; extern video_driver_t video_gx; diff --git a/griffin/griffin.c b/griffin/griffin.c index 20426ba538..3986079c5b 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -345,6 +345,11 @@ VIDEO DRIVER #endif +#if defined(HAVE_D3D10) +#include "../gfx/drivers/d3d10.c" +#include "../gfx/common/d3d10_common.c" +#endif + #if defined(HAVE_D3D11) #include "../gfx/drivers/d3d11.c" #include "../gfx/common/d3d11_common.c" @@ -355,7 +360,7 @@ VIDEO DRIVER #include "../gfx/common/d3d12_common.c" #endif -#if defined(HAVE_D3D11) || defined(HAVE_D3D12) +#if defined(HAVE_D3D10) || defined(HAVE_D3D11) || defined(HAVE_D3D12) #include "../gfx/common/d3dcompiler_common.c" #include "../gfx/common/dxgi_common.c" #endif diff --git a/tools/com-parser/com-parse.cpp b/tools/com-parser/com-parse.cpp index 229be04e89..900a94040f 100644 --- a/tools/com-parser/com-parse.cpp +++ b/tools/com-parser/com-parse.cpp @@ -119,6 +119,8 @@ vector overloaded_list = "SetPrivateDataInterface", "SetPrivateData", "GetPrivateData", + "Map", + "Unmap", "Reset", "Signal", "BeginEvent", @@ -136,6 +138,13 @@ vector overloaded_list = "GetContextFlags", "GetCertificate", "GetCertificateSize", + "Begin", + "End", + "GetData", + + "CopySubresourceRegion", + "CreateRenderTargetView", + "CreateShaderResourceView", }; vector action_list = @@ -174,10 +183,11 @@ vector base_objects_list = { "IUnknown", "ID3D12Object", - "ID3D12Resource", +// "ID3D12Resource", "IDXGIObject", "IDXGIResource", - "D3D11Resource", +// "ID3D11Resource", +// "ID3D10Resource", }; //string insert_name(const char* fname, const char* name)