Skip to content

Commit

Permalink
(D3D10/11/12) cleanups / fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
aliaspider committed Jan 30, 2018
1 parent f896ba2 commit 13f18af
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 260 deletions.
2 changes: 1 addition & 1 deletion Makefile.msvc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
64 changes: 3 additions & 61 deletions gfx/common/d3d10_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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,
Expand Down
15 changes: 7 additions & 8 deletions gfx/common/d3d11_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#ifdef HAVE_DYNAMIC
#include <dynamic/dylib.h>


HRESULT WINAPI D3D11CreateDeviceAndSwapChain(
IDXGIAdapter* pAdapter,
D3D_DRIVER_TYPE DriverType,
Expand All @@ -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)
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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,
Expand Down
67 changes: 4 additions & 63 deletions gfx/common/d3d11_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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,
Expand Down
Loading

0 comments on commit 13f18af

Please sign in to comment.