(D3D10/11/12) cleanups / fixes.

This commit is contained in:
aliaspider 2018-01-30 19:34:53 +01:00
parent f896ba29d0
commit 13f18afcd9
8 changed files with 61 additions and 260 deletions

View File

@ -126,7 +126,7 @@ FLAGS += -Gm- -Zc:inline -fp:precise -Zc:forScope -GR- -Gd -Oi -volatile:iso
CFLAGS += -TC
CXXFLAGS += -TP -EHsc
WARNINGS += -WX -W3
WARNINGS += -wd4101 -wd4996 -wd4244 -wd4267 -wd4090 -wd4305 -wd4146 -wd4334 -wd4018
WARNINGS += -wd4101 -wd4996 -wd4244 -wd4267 -wd4090 -wd4305 -wd4146 -wd4334 -wd4018 -wd4800
CC = cl.exe
CXX = cl.exe

View File

@ -17,66 +17,8 @@
#include <retro_inline.h>
#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)
#define __in
#define __out
#define __in_bcount(size)
#define __in_ecount(size)
#define __out_bcount(size)
#define __out_bcount_part(size, length)
#define __out_ecount(size)
#define __inout
#define __deref_out_ecount(size)
#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 <d3d10.h>
#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
#include <d3d10.h>
typedef ID3D10InputLayout* D3D10InputLayout;
typedef ID3D10RasterizerState* D3D10RasterizerState;
@ -823,7 +765,7 @@ static INLINE HRESULT
D3D10OpenSharedResource(D3D10Device device, HANDLE h_resource, ID3D10Resource** out)
{
return device->lpVtbl->OpenSharedResource(
device, h_resource, __uuidof(ID3D10Resource), (void**)out);
device, h_resource, uuidof(ID3D10Resource), (void**)out);
}
static INLINE void D3D10SetTextFilterSize(D3D10Device device, UINT width, UINT height)
{
@ -1049,7 +991,7 @@ static INLINE BOOL D3D10GetMuteDebugOutput(D3D10InfoQueue info_queue)
static INLINE HRESULT
DXGIGetSwapChainBufferD3D10(DXGISwapChain swap_chain, UINT buffer, D3D10Texture2D* out)
{
return swap_chain->lpVtbl->GetBuffer(swap_chain, buffer, __uuidof(ID3D10Texture2D), (void**)out);
return swap_chain->lpVtbl->GetBuffer(swap_chain, buffer, uuidof(ID3D10Texture2D), (void**)out);
}
static INLINE void D3D10CopyTexture2DSubresourceRegion(
D3D10Device device,

View File

@ -19,7 +19,6 @@
#ifdef HAVE_DYNAMIC
#include <dynamic/dylib.h>
HRESULT WINAPI D3D11CreateDeviceAndSwapChain(
IDXGIAdapter* pAdapter,
D3D_DRIVER_TYPE DriverType,
@ -34,7 +33,7 @@ HRESULT WINAPI D3D11CreateDeviceAndSwapChain(
D3D_FEATURE_LEVEL* pFeatureLevel,
ID3D11DeviceContext** ppImmediateContext)
{
static dylib_t d3d11_dll;
static dylib_t d3d11_dll;
static PFN_D3D11_CREATE_DEVICE_AND_SWAP_CHAIN fp;
if (!d3d11_dll)
@ -86,11 +85,11 @@ void d3d11_init_texture(D3D11Device device, d3d11_texture_t* texture)
D3D11CreateTexture2D(device, &texture->desc, NULL, &texture->handle);
{
D3D11_SHADER_RESOURCE_VIEW_DESC view_desc = { 0 };
view_desc.Format = texture->desc.Format;
view_desc.ViewDimension = D3D_SRV_DIMENSION_TEXTURE2D;
view_desc.Texture2D.MostDetailedMip = 0;
view_desc.Texture2D.MipLevels = -1;
D3D11_SHADER_RESOURCE_VIEW_DESC view_desc = { 0 };
view_desc.Format = texture->desc.Format;
view_desc.ViewDimension = D3D_SRV_DIMENSION_TEXTURE2D;
view_desc.Texture2D.MostDetailedMip = 0;
view_desc.Texture2D.MipLevels = -1;
D3D11CreateTexture2DShaderResourceView(device, texture->handle, &view_desc, &texture->view);
}
@ -150,7 +149,7 @@ d3d11_get_closest_match(D3D11Device device, DXGI_FORMAT desired_format, UINT des
bool d3d11_init_shader(
D3D11Device device,
void* src,
const void* src,
size_t size,
LPCSTR vs_entry,
LPCSTR ps_entry,

View File

@ -17,66 +17,8 @@
#include <retro_inline.h>
#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)
#define __in
#define __out
#define __in_bcount(size)
#define __in_ecount(size)
#define __out_bcount(size)
#define __out_bcount_part(size, length)
#define __out_ecount(size)
#define __inout
#define __deref_out_ecount(size)
#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 <d3d11.h>
#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
#include <d3d11.h>
typedef ID3D11InputLayout* D3D11InputLayout;
typedef ID3D11RasterizerState* D3D11RasterizerState;
@ -2103,7 +2045,7 @@ static INLINE HRESULT
D3D11OpenSharedResource(D3D11Device device, HANDLE h_resource, ID3D11Resource** out)
{
return device->lpVtbl->OpenSharedResource(
device, h_resource, __uuidof(ID3D11Resource), (void**)out);
device, h_resource, uuidof(ID3D11Resource), (void**)out);
}
static INLINE HRESULT
D3D11CheckFormatSupport(D3D11Device device, DXGI_FORMAT format, UINT* format_support)
@ -2393,7 +2335,7 @@ static INLINE BOOL D3D11GetMuteDebugOutput(D3D11InfoQueue info_queue)
static INLINE HRESULT
DXGIGetSwapChainBufferD3D11(DXGISwapChain swap_chain, UINT buffer, D3D11Texture2D* out)
{
return swap_chain->lpVtbl->GetBuffer(swap_chain, buffer, __uuidof(ID3D11Texture2D), (void**)out);
return swap_chain->lpVtbl->GetBuffer(swap_chain, buffer, uuidof(ID3D11Texture2D), (void**)out);
}
static INLINE HRESULT D3D11MapTexture2D(
@ -2507,7 +2449,6 @@ typedef struct
#define ALIGN(x) __declspec(align(x))
#else
#define ALIGN(x) __attribute__((aligned(x)))
#define static_assert _Static_assert
#endif
#endif
@ -2614,7 +2555,7 @@ d3d11_set_texture_and_sampler(D3D11DeviceContext ctx, UINT slot, d3d11_texture_t
bool d3d11_init_shader(
D3D11Device device,
void* src,
const void* src,
size_t size,
LPCSTR vs_entry,
LPCSTR ps_entry,

View File

@ -17,58 +17,8 @@
#include <retro_inline.h>
#ifdef __MINGW32__
#define __REQUIRED_RPCNDR_H_VERSION__ 475
#define _In_
#define _In_opt_
#define _Null_
#define __in_ecount_opt(s)
#define static_assert _Static_assert
#define _Out_writes_bytes_opt_(s)
#define __in
#define __out
#define __in_bcount(size)
#define __in_ecount(size)
#define __out_bcount(size)
#define __out_bcount_part(size, length)
#define __out_ecount(size)
#define __inout
#define __deref_out_ecount(size)
#endif
#define CINTERFACE
#include <d3d12.h>
#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
#include <d3d12.h>
/* auto-generated */
@ -690,25 +640,25 @@ static INLINE HRESULT D3D12CreateCommandQueue(
D3D12Device device, D3D12_COMMAND_QUEUE_DESC* desc, ID3D12CommandQueue** out)
{
return device->lpVtbl->CreateCommandQueue(
device, desc, __uuidof(ID3D12CommandQueue), (void**)out);
device, desc, uuidof(ID3D12CommandQueue), (void**)out);
}
static INLINE HRESULT D3D12CreateCommandAllocator(
D3D12Device device, D3D12_COMMAND_LIST_TYPE type, ID3D12CommandAllocator** out)
{
return device->lpVtbl->CreateCommandAllocator(
device, type, __uuidof(ID3D12CommandAllocator), (void**)out);
device, type, uuidof(ID3D12CommandAllocator), (void**)out);
}
static INLINE HRESULT D3D12CreateGraphicsPipelineState(
D3D12Device device, D3D12_GRAPHICS_PIPELINE_STATE_DESC* desc, ID3D12PipelineState** out)
{
return device->lpVtbl->CreateGraphicsPipelineState(
device, desc, __uuidof(ID3D12PipelineState), (void**)out);
device, desc, uuidof(ID3D12PipelineState), (void**)out);
}
static INLINE HRESULT D3D12CreateComputePipelineState(
D3D12Device device, D3D12_COMPUTE_PIPELINE_STATE_DESC* desc, ID3D12PipelineState** out)
{
return device->lpVtbl->CreateComputePipelineState(
device, desc, __uuidof(ID3D12PipelineState), (void**)out);
device, desc, uuidof(ID3D12PipelineState), (void**)out);
}
static INLINE HRESULT D3D12CreateCommandList(
D3D12Device device,
@ -719,7 +669,7 @@ static INLINE HRESULT D3D12CreateCommandList(
ID3D12CommandList** out)
{
return device->lpVtbl->CreateCommandList(
device, node_mask, type, command_allocator, initial_state, __uuidof(ID3D12CommandList),
device, node_mask, type, command_allocator, initial_state, uuidof(ID3D12CommandList),
(void**)out);
}
static INLINE HRESULT D3D12CheckFeatureSupport(
@ -737,7 +687,7 @@ static INLINE HRESULT D3D12CreateDescriptorHeap(
D3D12DescriptorHeap* out)
{
return device->lpVtbl->CreateDescriptorHeap(
device, descriptor_heap_desc, __uuidof(ID3D12DescriptorHeap), (void**)out);
device, descriptor_heap_desc, uuidof(ID3D12DescriptorHeap), (void**)out);
}
static INLINE UINT D3D12GetDescriptorHandleIncrementSize(
D3D12Device device, D3D12_DESCRIPTOR_HEAP_TYPE descriptor_heap_type)
@ -753,7 +703,7 @@ static INLINE HRESULT D3D12CreateRootSignature(
{
return device->lpVtbl->CreateRootSignature(
device, node_mask, blob_with_root_signature, blob_length_in_bytes,
__uuidof(ID3D12RootSignature), (void**)out);
uuidof(ID3D12RootSignature), (void**)out);
}
static INLINE void D3D12CreateConstantBufferView(
D3D12Device device,
@ -853,11 +803,11 @@ static INLINE HRESULT D3D12CreateCommittedResource(
{
return device->lpVtbl->CreateCommittedResource(
device, heap_properties, heap_flags, desc, initial_resource_state, optimized_clear_value,
__uuidof(ID3D12Resource), (void**)out);
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);
return device->lpVtbl->CreateHeap(device, desc, uuidof(ID3D12Heap), (void**)out);
}
static INLINE HRESULT D3D12CreatePlacedResource(
D3D12Device device,
@ -870,7 +820,7 @@ static INLINE HRESULT D3D12CreatePlacedResource(
{
return device->lpVtbl->CreatePlacedResource(
device, heap, heap_offset, desc, initial_state, optimized_clear_value,
__uuidof(ID3D12Resource), (void**)out);
uuidof(ID3D12Resource), (void**)out);
}
static INLINE HRESULT D3D12CreateReservedResource(
D3D12Device device,
@ -880,13 +830,13 @@ static INLINE HRESULT D3D12CreateReservedResource(
ID3D12Resource** out)
{
return device->lpVtbl->CreateReservedResource(
device, desc, initial_state, optimized_clear_value, __uuidof(ID3D12Resource), (void**)out);
device, desc, initial_state, optimized_clear_value, uuidof(ID3D12Resource), (void**)out);
}
static INLINE HRESULT D3D12CreateFence(
D3D12Device device, UINT64 initial_value, D3D12_FENCE_FLAGS flags, ID3D12Fence** out)
{
return device->lpVtbl->CreateFence(
device, initial_value, flags, __uuidof(ID3D12Fence), (void**)out);
device, initial_value, flags, uuidof(ID3D12Fence), (void**)out);
}
static INLINE HRESULT D3D12GetDeviceRemovedReason(D3D12Device device)
{
@ -910,7 +860,7 @@ static INLINE void D3D12GetCopyableFootprints(
static INLINE HRESULT
D3D12CreateQueryHeap(D3D12Device device, D3D12_QUERY_HEAP_DESC* desc, ID3D12Heap** out)
{
return device->lpVtbl->CreateQueryHeap(device, desc, __uuidof(ID3D12Heap), (void**)out);
return device->lpVtbl->CreateQueryHeap(device, desc, uuidof(ID3D12Heap), (void**)out);
}
static INLINE HRESULT D3D12SetStablePowerState(D3D12Device device, BOOL enable)
{
@ -923,7 +873,7 @@ static INLINE HRESULT D3D12CreateCommandSignature(
ID3D12CommandSignature** out)
{
return device->lpVtbl->CreateCommandSignature(
device, desc, root_signature, __uuidof(ID3D12CommandSignature), (void**)out);
device, desc, root_signature, uuidof(ID3D12CommandSignature), (void**)out);
}
static INLINE void D3D12GetResourceTiling(
D3D12Device device,
@ -960,7 +910,7 @@ static INLINE HRESULT D3D12LoadGraphicsPipeline(
ID3D12PipelineState** out)
{
return pipeline_library->lpVtbl->LoadGraphicsPipeline(
pipeline_library, name, desc, __uuidof(ID3D12PipelineState), (void**)out);
pipeline_library, name, desc, uuidof(ID3D12PipelineState), (void**)out);
}
static INLINE HRESULT D3D12LoadComputePipeline(
D3D12PipelineLibrary pipeline_library,
@ -969,7 +919,7 @@ static INLINE HRESULT D3D12LoadComputePipeline(
ID3D12PipelineState** out)
{
return pipeline_library->lpVtbl->LoadComputePipeline(
pipeline_library, name, desc, __uuidof(ID3D12PipelineState), (void**)out);
pipeline_library, name, desc, uuidof(ID3D12PipelineState), (void**)out);
}
static INLINE SIZE_T D3D12GetSerializedSize(D3D12PipelineLibrary pipeline_library)
{
@ -1204,14 +1154,14 @@ static INLINE BOOL D3D12GetMuteDebugOutput(D3D12InfoQueue info_queue)
static INLINE HRESULT D3D12GetDebugInterface_(D3D12Debug* out)
{
return D3D12GetDebugInterface(__uuidof(ID3D12Debug), (void**)out);
return D3D12GetDebugInterface(uuidof(ID3D12Debug), (void**)out);
}
static INLINE HRESULT
D3D12CreateDevice_(DXGIAdapter adapter, D3D_FEATURE_LEVEL MinimumFeatureLevel, D3D12Device* out)
{
return D3D12CreateDevice(
(IUnknown*)adapter, MinimumFeatureLevel, __uuidof(ID3D12Device), (void**)out);
(IUnknown*)adapter, MinimumFeatureLevel, uuidof(ID3D12Device), (void**)out);
}
static INLINE HRESULT D3D12CreateGraphicsCommandList(
@ -1224,7 +1174,7 @@ static INLINE HRESULT D3D12CreateGraphicsCommandList(
{
return device->lpVtbl->CreateCommandList(
device, node_mask, type, command_allocator, initial_state,
__uuidof(ID3D12GraphicsCommandList), (void**)out);
uuidof(ID3D12GraphicsCommandList), (void**)out);
}
static INLINE void D3D12ClearRenderTargetView(
@ -1258,7 +1208,7 @@ static INLINE HRESULT
DXGIGetSwapChainBuffer(DXGISwapChain swapchain, UINT buffer, D3D12Resource* surface)
{
return swapchain->lpVtbl->GetBuffer(
swapchain, buffer, __uuidof(ID3D12Resource), (void**)surface);
swapchain, buffer, uuidof(ID3D12Resource), (void**)surface);
}
static INLINE void D3D12SetDescriptorHeaps(
D3D12GraphicsCommandList command_list,

View File

@ -18,61 +18,15 @@
#include <retro_inline.h>
#include <boolean.h>
#ifdef __MINGW32__
#define __REQUIRED_RPCNDR_H_VERSION__ 475
#define _In_
#define _In_opt_
#define _Null_
#define _Out_writes_bytes_opt_(s)
#define __in
#define __out
#define __in_bcount(size)
#define __in_ecount(size)
#define __out_bcount(size)
#define __out_bcount_part(size, length)
#define __out_ecount(size)
#define __inout
#define __deref_out_ecount(size)
#endif
#define CINTERFACE
#include "dxgi_common.h"
#include <d3dcommon.h>
#include <d3dcompiler.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
/* auto-generated */
typedef ID3DBlob* D3DBlob;
typedef ID3DDestructionNotifier* D3DDestructionNotifier;
#if !defined(__cplusplus) || defined(CINTERFACE)
static INLINE ULONG D3DReleaseBlob(D3DBlob blob) { return blob->lpVtbl->Release(blob); }
static INLINE LPVOID D3DGetBufferPointer(D3DBlob blob)
{
@ -98,7 +52,7 @@ D3DUnregisterDestructionCallback(D3DDestructionNotifier destruction_notifier, UI
return destruction_notifier->lpVtbl->UnregisterDestructionCallback(
destruction_notifier, callback_id);
}
#endif
/* end of auto-generated */
bool d3d_compile(const char* src, size_t size, LPCSTR entrypoint, LPCSTR target, D3DBlob* out);

View File

@ -9,9 +9,15 @@
#define _Null_
#define _Out_writes_bytes_opt_(s)
#define _Out_writes_bytes_(s)
#define _In_reads_bytes_(s)
#define _Inout_opt_bytecount_(s)
#define __in
#define __out
#define _Inout_
#define _COM_Outptr_
#define __in_bcount(size)
#define __in_ecount(size)
#define __out_bcount(size)
@ -19,9 +25,13 @@
#define __out_ecount(size)
#define __inout
#define __deref_out_ecount(size)
#define __in_ecount_opt(s)
#ifndef __cplusplus
#define static_assert _Static_assert
#endif
#endif
#define CINTERFACE
#include <assert.h>
#include <dxgi1_5.h>
@ -29,8 +39,12 @@
#define countof(a) (sizeof(a) / sizeof(*a))
#endif
#ifndef __uuidof
#define __uuidof(type) & IID_##type
#ifndef uuidof
#if defined(__cplusplus)
#define uuidof(type) IID_##type
#else
#define uuidof(type) &IID_##type
#endif
#endif
#ifndef COM_RELEASE_DECLARED
@ -72,6 +86,7 @@ typedef IDXGIFactoryMedia* DXGIFactoryMedia;
typedef IDXGISwapChainMedia* DXGISwapChainMedia;
typedef IDXGISwapChain3* DXGISwapChain;
#if !defined(__cplusplus) || defined(CINTERFACE)
static INLINE ULONG DXGIReleaseDeviceSubObject(DXGIDeviceSubObject device_sub_object)
{
return device_sub_object->lpVtbl->Release(device_sub_object);
@ -415,7 +430,7 @@ static INLINE HRESULT DXGIPresent(DXGISwapChain swap_chain, UINT sync_interval,
}
static INLINE HRESULT DXGIGetBuffer(DXGISwapChain swap_chain, UINT buffer, IDXGISurface** out)
{
return swap_chain->lpVtbl->GetBuffer(swap_chain, buffer, __uuidof(IDXGISurface), (void**)out);
return swap_chain->lpVtbl->GetBuffer(swap_chain, buffer, uuidof(IDXGISurface), (void**)out);
}
static INLINE HRESULT
DXGISetFullscreenState(DXGISwapChain swap_chain, BOOL fullscreen, DXGIOutput target)
@ -544,12 +559,12 @@ DXGISetColorSpace1(DXGISwapChain swap_chain, DXGI_COLOR_SPACE_TYPE color_space)
{
return swap_chain->lpVtbl->SetColorSpace1(swap_chain, color_space);
}
#endif
/* end of auto-generated */
static INLINE HRESULT DXGICreateFactory(DXGIFactory* factory)
{
return CreateDXGIFactory1(__uuidof(IDXGIFactory1), (void**)factory);
return CreateDXGIFactory1(uuidof(IDXGIFactory1), (void**)factory);
}
/* internal */

View File

@ -560,7 +560,7 @@ public:
}
if(!riid.empty())
out << ", __uuidof(" << riid << "), (void**)out";
out << ", uuidof(" << riid << "), (void**)out";
out << ");\n";
out << "}\n";