various fixes for CXX_BUILD.

This commit is contained in:
aliaspider 2018-02-04 20:03:27 +01:00
parent ac22a9ce20
commit 700fce3bd2
18 changed files with 421 additions and 1599 deletions

View File

@ -13,6 +13,8 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#define CINTERFACE
#include <gfx/scaler/pixconv.h>
#include "d3d10_common.h"

File diff suppressed because it is too large Load Diff

View File

@ -13,6 +13,8 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#define CINTERFACE
#include <string.h>
#include "d3d11_common.h"
@ -122,9 +124,9 @@ void d3d11_init_texture(D3D11Device device, d3d11_texture_t* texture)
void d3d11_update_texture(
D3D11DeviceContext ctx,
int width,
int height,
int pitch,
unsigned width,
unsigned height,
unsigned pitch,
DXGI_FORMAT format,
const void* data,
d3d11_texture_t* texture)

View File

@ -18,6 +18,9 @@
#include <retro_inline.h>
#include "dxgi_common.h"
#ifdef CINTERFACE
#define D3D11_NO_HELPERS
#endif
#include <d3d11.h>
typedef const ID3D11ShaderResourceView* D3D11ShaderResourceViewRef;
@ -2578,9 +2581,9 @@ static INLINE void d3d11_release_texture(d3d11_texture_t* texture)
void d3d11_update_texture(
D3D11DeviceContext ctx,
int width,
int height,
int pitch,
unsigned width,
unsigned height,
unsigned pitch,
DXGI_FORMAT format,
const void* data,
d3d11_texture_t* texture);

View File

@ -13,6 +13,8 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#define CINTERFACE
#include "d3d12_common.h"
#include "dxgi_common.h"
#include "d3dcompiler_common.h"
@ -25,7 +27,11 @@
#ifdef __MINGW32__
/* clang-format off */
#ifdef __cplusplus
#define DEFINE_GUIDW(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) EXTERN_C const GUID DECLSPEC_SELECTANY name = { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } }
#else
#define DEFINE_GUIDW(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) const GUID DECLSPEC_SELECTANY name = { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } }
#endif
DEFINE_GUIDW(IID_ID3D12PipelineState, 0x765a30f3, 0xf624, 0x4c6f, 0xa8, 0x28, 0xac, 0xe9, 0x48, 0x62, 0x24, 0x45);
DEFINE_GUIDW(IID_ID3D12RootSignature, 0xc54a6b66, 0x72df, 0x4ee8, 0x8b, 0xe5, 0xa9, 0x46, 0xa1, 0x42, 0x92, 0x14);
@ -64,7 +70,7 @@ static const char* d3d12_dll_name = "d3d12.dll";
HRESULT WINAPI D3D12CreateDevice(
IUnknown* pAdapter, D3D_FEATURE_LEVEL MinimumFeatureLevel, REFIID riid, void** ppDevice)
{
static PFN_D3D12_CREATE_DEVICE fp;
static PFN_D3D12_CREATE_DEVICE fp;
if (!d3d12_dll)
d3d12_dll = dylib_load(d3d12_dll_name);
@ -75,7 +81,7 @@ HRESULT WINAPI D3D12CreateDevice(
fp = (PFN_D3D12_CREATE_DEVICE)dylib_proc(d3d12_dll, "D3D12CreateDevice");
if (fp)
return fp(pAdapter, MinimumFeatureLevel, riid, ppDevice);
return fp(pAdapter, MinimumFeatureLevel, riid, ppDevice);
error:
return TYPE_E_CANTLOADLIBRARY;
@ -88,13 +94,13 @@ HRESULT WINAPI D3D12GetDebugInterface(REFIID riid, void** ppvDebug)
d3d12_dll = dylib_load(d3d12_dll_name);
if (!d3d12_dll)
goto error;
goto error;
if (!fp)
fp = (PFN_D3D12_GET_DEBUG_INTERFACE)dylib_proc(d3d12_dll, "D3D12GetDebugInterface");
if (fp)
return fp(riid, ppvDebug);
if (fp)
return fp(riid, ppvDebug);
error:
return TYPE_E_CANTLOADLIBRARY;
@ -114,8 +120,7 @@ HRESULT WINAPI D3D12SerializeRootSignature(
goto error;
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);
@ -138,10 +143,10 @@ HRESULT WINAPI D3D12SerializeVersionedRootSignature(
if (!fp)
fp = (PFN_D3D12_SERIALIZE_VERSIONED_ROOT_SIGNATURE)dylib_proc(
d3d12_dll, "D3D12SerializeRootSignature");
d3d12_dll, "D3D12SerializeRootSignature");
if (fp)
return fp(pRootSignature, ppBlob, ppErrorBlob);
return fp(pRootSignature, ppBlob, ppErrorBlob);
error:
return TYPE_E_CANTLOADLIBRARY;
@ -179,10 +184,8 @@ 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,
.Flags = D3D12_COMMAND_QUEUE_FLAG_NONE,
};
static const D3D12_COMMAND_QUEUE_DESC desc = { D3D12_COMMAND_LIST_TYPE_DIRECT, 0,
D3D12_COMMAND_QUEUE_FLAG_NONE, 0 };
D3D12CreateCommandQueue(
d3d12->device, (D3D12_COMMAND_QUEUE_DESC*)&desc, &d3d12->queue.handle);
}
@ -206,26 +209,25 @@ 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,
.BufferDesc.Height = height,
.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM,
.SampleDesc.Count = 1,
DXGI_SWAP_CHAIN_DESC desc = { 0 };
desc.BufferCount = countof(d3d12->chain.renderTargets);
desc.BufferDesc.Width = width;
desc.BufferDesc.Height = height;
desc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
desc.SampleDesc.Count = 1;
#if 0
.BufferDesc.RefreshRate.Numerator = 60,
.BufferDesc.RefreshRate.Denominator = 1,
.SampleDesc.Quality = 0,
desc.BufferDesc.RefreshRate.Numerator = 60;
desc.BufferDesc.RefreshRate.Denominator = 1;
desc.SampleDesc.Quality = 0;
#endif
.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT,
.OutputWindow = hwnd,
.Windowed = TRUE,
desc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
desc.OutputWindow = hwnd;
desc.Windowed = TRUE;
#if 0
.SwapEffect = DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL,
desc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL;
#else
.SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD,
desc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD;
#endif
};
DXGICreateSwapChain(d3d12->factory, d3d12->queue.handle, &desc, &d3d12->chain.handle);
}
@ -285,7 +287,7 @@ static void d3d12_init_sampler(
bool d3d12_init_descriptors(d3d12_video_t* d3d12)
{
D3D12_ROOT_SIGNATURE_DESC desc;
D3D12_ROOT_SIGNATURE_DESC desc;
static const D3D12_DESCRIPTOR_RANGE srv_table[] = {
{
.RangeType = D3D12_DESCRIPTOR_RANGE_TYPE_SRV,
@ -308,30 +310,22 @@ bool d3d12_init_descriptors(d3d12_video_t* d3d12)
},
};
D3D12_ROOT_PARAMETER rootParameters[ROOT_INDEX_MAX] = {
{
D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE,
{{0}},
D3D12_SHADER_VISIBILITY_PIXEL,
},
{
D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE,
{{0}},
D3D12_SHADER_VISIBILITY_PIXEL,
},
{
D3D12_ROOT_PARAMETER_TYPE_CBV,
{{0}},
D3D12_SHADER_VISIBILITY_VERTEX,
}
};
D3D12_ROOT_PARAMETER rootParameters[ROOT_ID_MAX] = {};
rootParameters[0].DescriptorTable.NumDescriptorRanges = countof(srv_table);
rootParameters[0].DescriptorTable.pDescriptorRanges = srv_table;
rootParameters[1].DescriptorTable.NumDescriptorRanges = countof(sampler_table);
rootParameters[1].DescriptorTable.pDescriptorRanges = sampler_table;
rootParameters[2].Descriptor.RegisterSpace = 0;
rootParameters[2].Descriptor.ShaderRegister = 0;
rootParameters[ROOT_ID_TEXTURE_T].ParameterType = D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE;
rootParameters[ROOT_ID_TEXTURE_T].DescriptorTable.NumDescriptorRanges = countof(srv_table);
rootParameters[ROOT_ID_TEXTURE_T].DescriptorTable.pDescriptorRanges = srv_table;
rootParameters[ROOT_ID_TEXTURE_T].ShaderVisibility = D3D12_SHADER_VISIBILITY_PIXEL;
rootParameters[ROOT_ID_SAMPLER_T].ParameterType = D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE;
rootParameters[ROOT_ID_SAMPLER_T].DescriptorTable.NumDescriptorRanges = countof(sampler_table);
rootParameters[ROOT_ID_SAMPLER_T].DescriptorTable.pDescriptorRanges = sampler_table;
rootParameters[ROOT_ID_SAMPLER_T].ShaderVisibility = D3D12_SHADER_VISIBILITY_PIXEL;
rootParameters[ROOT_ID_UBO].ParameterType = D3D12_ROOT_PARAMETER_TYPE_CBV;
rootParameters[ROOT_ID_UBO].Descriptor.RegisterSpace = 0;
rootParameters[ROOT_ID_UBO].Descriptor.ShaderRegister = 0;
rootParameters[ROOT_ID_UBO].ShaderVisibility = D3D12_SHADER_VISIBILITY_VERTEX;
desc.NumParameters = countof(rootParameters);
desc.pParameters = rootParameters;
@ -417,24 +411,6 @@ bool d3d12_init_pipeline(d3d12_video_t* d3d12)
.ConservativeRaster = D3D12_CONSERVATIVE_RASTERIZATION_MODE_OFF,
};
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,
},
};
if (!d3d_compile(stock, sizeof(stock), NULL, "VSMain", "vs_5_0", &vs_code))
return false;
@ -442,48 +418,44 @@ 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),
.VS.BytecodeLength = D3DGetBufferSize(vs_code),
.PS.pShaderBytecode = D3DGetBufferPointer(ps_code),
.PS.BytecodeLength = D3DGetBufferSize(ps_code),
.BlendState.AlphaToCoverageEnable = FALSE,
.BlendState.IndependentBlendEnable = FALSE,
.BlendState.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,
},
.SampleMask = UINT_MAX,
.RasterizerState.FillMode = D3D12_FILL_MODE_SOLID,
.RasterizerState.CullMode = D3D12_CULL_MODE_BACK,
.RasterizerState.FrontCounterClockwise = FALSE,
.RasterizerState.DepthBias = D3D12_DEFAULT_DEPTH_BIAS,
.RasterizerState.DepthBiasClamp = D3D12_DEFAULT_DEPTH_BIAS_CLAMP,
.RasterizerState.SlopeScaledDepthBias = D3D12_DEFAULT_SLOPE_SCALED_DEPTH_BIAS,
.RasterizerState.DepthClipEnable = TRUE,
.RasterizerState.MultisampleEnable = FALSE,
.RasterizerState.AntialiasedLineEnable = FALSE,
.RasterizerState.ForcedSampleCount = 0,
.RasterizerState.ConservativeRaster = D3D12_CONSERVATIVE_RASTERIZATION_MODE_OFF,
.DepthStencilState.DepthEnable = FALSE,
.DepthStencilState.StencilEnable = FALSE,
.InputLayout.pInputElementDescs = inputElementDesc,
.InputLayout.NumElements = countof(inputElementDesc),
.PrimitiveTopologyType = D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE,
.NumRenderTargets = 1,
.RTVFormats[0] = DXGI_FORMAT_R8G8B8A8_UNORM,
.SampleDesc.Count = 1,
};
D3D12_GRAPHICS_PIPELINE_STATE_DESC psodesc = { 0 };
psodesc.pRootSignature = d3d12->pipe.rootSignature;
psodesc.VS.pShaderBytecode = D3DGetBufferPointer(vs_code);
psodesc.VS.BytecodeLength = D3DGetBufferSize(vs_code);
psodesc.PS.pShaderBytecode = D3DGetBufferPointer(ps_code);
psodesc.PS.BytecodeLength = D3DGetBufferSize(ps_code);
psodesc.BlendState.AlphaToCoverageEnable = FALSE;
psodesc.BlendState.IndependentBlendEnable = FALSE;
psodesc.BlendState.RenderTarget[0].BlendEnable = TRUE;
psodesc.BlendState.RenderTarget[0].LogicOpEnable = FALSE;
psodesc.BlendState.RenderTarget[0].SrcBlend = D3D12_BLEND_SRC_ALPHA;
psodesc.BlendState.RenderTarget[0].DestBlend = D3D12_BLEND_INV_SRC_ALPHA;
psodesc.BlendState.RenderTarget[0].BlendOp = D3D12_BLEND_OP_ADD;
psodesc.BlendState.RenderTarget[0].SrcBlendAlpha = D3D12_BLEND_SRC_ALPHA;
psodesc.BlendState.RenderTarget[0].DestBlendAlpha = D3D12_BLEND_INV_SRC_ALPHA;
psodesc.BlendState.RenderTarget[0].BlendOpAlpha = D3D12_BLEND_OP_ADD;
psodesc.BlendState.RenderTarget[0].LogicOp = D3D12_LOGIC_OP_NOOP;
psodesc.BlendState.RenderTarget[0].RenderTargetWriteMask = D3D12_COLOR_WRITE_ENABLE_ALL;
psodesc.SampleMask = UINT_MAX;
psodesc.RasterizerState.FillMode = D3D12_FILL_MODE_SOLID;
psodesc.RasterizerState.CullMode = D3D12_CULL_MODE_BACK;
psodesc.RasterizerState.FrontCounterClockwise = FALSE;
psodesc.RasterizerState.DepthBias = D3D12_DEFAULT_DEPTH_BIAS;
psodesc.RasterizerState.DepthBiasClamp = D3D12_DEFAULT_DEPTH_BIAS_CLAMP;
psodesc.RasterizerState.SlopeScaledDepthBias = D3D12_DEFAULT_SLOPE_SCALED_DEPTH_BIAS;
psodesc.RasterizerState.DepthClipEnable = TRUE;
psodesc.RasterizerState.MultisampleEnable = FALSE;
psodesc.RasterizerState.AntialiasedLineEnable = FALSE;
psodesc.RasterizerState.ForcedSampleCount = 0;
psodesc.RasterizerState.ConservativeRaster = D3D12_CONSERVATIVE_RASTERIZATION_MODE_OFF;
psodesc.DepthStencilState.DepthEnable = FALSE;
psodesc.DepthStencilState.StencilEnable = FALSE;
psodesc.InputLayout.pInputElementDescs = inputElementDesc;
psodesc.InputLayout.NumElements = countof(inputElementDesc);
psodesc.PrimitiveTopologyType = D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE;
psodesc.NumRenderTargets = 1;
psodesc.RTVFormats[0] = DXGI_FORMAT_R8G8B8A8_UNORM;
psodesc.SampleDesc.Count = 1;
D3D12CreateGraphicsPipelineState(d3d12->device, &psodesc, &d3d12->pipe.handle);
}
@ -497,21 +469,16 @@ bool d3d12_init_pipeline(d3d12_video_t* d3d12)
D3D12_GPU_VIRTUAL_ADDRESS
d3d12_create_buffer(D3D12Device device, UINT size_in_bytes, D3D12Resource* buffer)
{
static const D3D12_HEAP_PROPERTIES heap_props = {
.Type = D3D12_HEAP_TYPE_UPLOAD,
.CreationNodeMask = 1,
.VisibleNodeMask = 1,
};
D3D12_HEAP_PROPERTIES heap_props = { D3D12_HEAP_TYPE_UPLOAD, D3D12_CPU_PAGE_PROPERTY_UNKNOWN,
D3D12_MEMORY_POOL_UNKNOWN, 1, 1 };
D3D12_RESOURCE_DESC resource_desc = { D3D12_RESOURCE_DIMENSION_BUFFER };
D3D12_RESOURCE_DESC resource_desc = {
.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER,
.Width = size_in_bytes,
.Height = 1,
.DepthOrArraySize = 1,
.MipLevels = 1,
.SampleDesc.Count = 1,
.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR,
};
resource_desc.Width = size_in_bytes;
resource_desc.Height = 1;
resource_desc.DepthOrArraySize = 1;
resource_desc.MipLevels = 1;
resource_desc.SampleDesc.Count = 1;
resource_desc.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR;
D3D12CreateCommittedResource(
device, (D3D12_HEAP_PROPERTIES*)&heap_props, D3D12_HEAP_FLAG_NONE, &resource_desc,
@ -530,12 +497,14 @@ void d3d12_init_texture(
Release(texture->upload_buffer);
{
D3D12_HEAP_PROPERTIES heap_props = { D3D12_HEAP_TYPE_DEFAULT, D3D12_CPU_PAGE_PROPERTY_UNKNOWN,
D3D12_MEMORY_POOL_UNKNOWN, 1, 1 };
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);
@ -546,16 +515,16 @@ void d3d12_init_texture(
&texture->row_size_in_bytes, &texture->total_bytes);
{
D3D12_RESOURCE_DESC buffer_desc = {
.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER,
.Width = texture->total_bytes,
.Height = 1,
.DepthOrArraySize = 1,
.MipLevels = 1,
.SampleDesc.Count = 1,
.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR,
};
D3D12_HEAP_PROPERTIES heap_props = { D3D12_HEAP_TYPE_UPLOAD, 0, 0, 1, 1 };
D3D12_HEAP_PROPERTIES heap_props = { D3D12_HEAP_TYPE_UPLOAD, D3D12_CPU_PAGE_PROPERTY_UNKNOWN,
D3D12_MEMORY_POOL_UNKNOWN, 1, 1 };
D3D12_RESOURCE_DESC buffer_desc = { D3D12_RESOURCE_DIMENSION_BUFFER };
buffer_desc.Width = texture->total_bytes;
buffer_desc.Height = 1;
buffer_desc.DepthOrArraySize = 1;
buffer_desc.MipLevels = 1;
buffer_desc.SampleDesc.Count = 1;
buffer_desc.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR;
D3D12CreateCommittedResource(
device, &heap_props, D3D12_HEAP_FLAG_NONE, &buffer_desc,
@ -563,15 +532,15 @@ void d3d12_init_texture(
}
{
D3D12_CPU_DESCRIPTOR_HANDLE handle;
D3D12_SHADER_RESOURCE_VIEW_DESC view_desc = { 0 };
D3D12_CPU_DESCRIPTOR_HANDLE handle;
D3D12_SHADER_RESOURCE_VIEW_DESC view_desc = { DXGI_FORMAT_UNKNOWN };
view_desc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING;
view_desc.Format = texture->desc.Format;
view_desc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2D;
view_desc.Texture2D.MipLevels = texture->desc.MipLevels;
view_desc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING;
view_desc.Format = texture->desc.Format;
view_desc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2D;
view_desc.Texture2D.MipLevels = texture->desc.MipLevels;
handle.ptr = heap->cpu.ptr + heap_index * heap->stride;
handle.ptr = 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;
@ -583,9 +552,9 @@ void d3d12_upload_texture(D3D12GraphicsCommandList cmd, d3d12_texture_t* texture
D3D12_TEXTURE_COPY_LOCATION src = { 0 };
D3D12_TEXTURE_COPY_LOCATION dst = { 0 };
src.pResource = texture->upload_buffer;
src.Type = D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT;
src.PlacedFootprint = texture->layout;
src.pResource = texture->upload_buffer;
src.Type = D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT;
src.PlacedFootprint = texture->layout;
dst.pResource = texture->handle;
dst.Type = D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX;
@ -631,10 +600,10 @@ void d3d12_create_fullscreen_quad_vbo(
DXGI_FORMAT d3d12_get_closest_match(
D3D12Device device, DXGI_FORMAT desired_format, D3D12_FORMAT_SUPPORT1 desired_format_support)
{
DXGI_FORMAT default_list[] = {desired_format, DXGI_FORMAT_UNKNOWN};
DXGI_FORMAT* format = dxgi_get_format_fallback_list(desired_format);
DXGI_FORMAT default_list[] = { desired_format, DXGI_FORMAT_UNKNOWN };
DXGI_FORMAT* format = dxgi_get_format_fallback_list(desired_format);
if(!format)
if (!format)
format = default_list;
while (*format != DXGI_FORMAT_UNKNOWN)

View File

@ -1365,10 +1365,10 @@ typedef struct
enum
{
ROOT_INDEX_TEXTURE_TABLE = 0,
ROOT_INDEX_SAMPLER_TABLE,
ROOT_INDEX_UBO,
ROOT_INDEX_MAX,
ROOT_ID_TEXTURE_T = 0,
ROOT_ID_SAMPLER_T,
ROOT_ID_UBO,
ROOT_ID_MAX,
} root_signature_parameter_index_t;
typedef enum {
@ -1420,13 +1420,13 @@ static INLINE void d3d12_resource_transition(
static INLINE void d3d12_set_texture(D3D12GraphicsCommandList cmd, const d3d12_texture_t* texture)
{
D3D12SetGraphicsRootDescriptorTable(cmd, ROOT_INDEX_TEXTURE_TABLE, texture->gpu_descriptor);
D3D12SetGraphicsRootDescriptorTable(cmd, ROOT_ID_TEXTURE_T, texture->gpu_descriptor);
}
static INLINE void
d3d12_set_sampler(D3D12GraphicsCommandList cmd, D3D12_GPU_DESCRIPTOR_HANDLE sampler)
{
D3D12SetGraphicsRootDescriptorTable(cmd, ROOT_INDEX_SAMPLER_TABLE, sampler);
D3D12SetGraphicsRootDescriptorTable(cmd, ROOT_ID_SAMPLER_T, sampler);
}
static INLINE void d3d12_update_texture(

View File

@ -13,6 +13,8 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#define CINTERFACE
#include <stdio.h>
#ifdef HAVE_CONFIG_H

View File

@ -143,8 +143,8 @@ DXGI_FORMAT* dxgi_get_format_fallback_list(DXGI_FORMAT format)
((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; \
const UINT8* in = (const UINT8*)src_data; \
UINT8* out = (UINT8*)dst_data; \
for (i = 0; i < height; i++) \
{ \
memcpy(out, in, width * sizeof(src_type)); \

View File

@ -247,17 +247,9 @@
#endif
#endif
#if !defined(__cplusplus) || defined(CINTERFACE)
#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)

View File

@ -85,7 +85,7 @@ static void* win32_display_server_init(void)
if (!SUCCEEDED(hr))
{
g_taskbarList = false;
g_taskbarList = NULL;
RARCH_ERR("[dispserv]: CoCreateInstance of ITaskbarList3 failed.\n");
}
#endif

View File

@ -13,6 +13,8 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#define CINTERFACE
#include <assert.h>
#include <string/stdstring.h>

View File

@ -13,6 +13,8 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#define CINTERFACE
#include <assert.h>
#include <string/stdstring.h>
@ -39,7 +41,7 @@
static void d3d11_set_filtering(void* data, unsigned index, bool smooth)
{
unsigned i;
unsigned i;
d3d11_video_t* d3d11 = (d3d11_video_t*)data;
for (i = 0; i < RARCH_WRAP_MAX; i++)
@ -141,8 +143,9 @@ static void d3d11_free_shader_preset(d3d11_video_t* d3d11)
static bool d3d11_gfx_set_shader(void* data, enum rarch_shader_type type, const char* path)
{
#if defined(HAVE_SLANG) && defined(HAVE_SPIRV_CROSS)
unsigned i;
d3d11_video_t* d3d11 = (d3d11_video_t*)data;
unsigned i;
d3d11_texture_t* source;
d3d11_video_t* d3d11 = (d3d11_video_t*)data;
if (!d3d11)
return false;
@ -171,8 +174,7 @@ static bool d3d11_gfx_set_shader(void* data, enum rarch_shader_type type, const
video_shader_resolve_relative(d3d11->shader_preset, path);
d3d11_texture_t* source = &d3d11->frame.texture[0];
source = &d3d11->frame.texture[0];
for (i = 0; i < d3d11->shader_preset->passes; source = &d3d11->pass[i++].rt)
{
unsigned j;
@ -219,16 +221,16 @@ static bool d3d11_gfx_set_shader(void* data, enum rarch_shader_type type, const
/* clang-format on */
if (!slang_process(
d3d11->shader_preset, i, RARCH_SHADER_HLSL, 50, &semantics_map,
&d3d11->pass[i].semantics))
d3d11->shader_preset, i, RARCH_SHADER_HLSL, 50, &semantics_map,
&d3d11->pass[i].semantics))
goto error;
{
static const D3D11_INPUT_ELEMENT_DESC desc[] = {
{ "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, offsetof(d3d11_vertex_t, position),
D3D11_INPUT_PER_VERTEX_DATA, 0 },
D3D11_INPUT_PER_VERTEX_DATA, 0 },
{ "TEXCOORD", 1, DXGI_FORMAT_R32G32_FLOAT, 0, offsetof(d3d11_vertex_t, texcoord),
D3D11_INPUT_PER_VERTEX_DATA, 0 },
D3D11_INPUT_PER_VERTEX_DATA, 0 },
};
#ifdef DEBUG
bool save_hlsl = true;
@ -253,13 +255,13 @@ static bool d3d11_gfx_set_shader(void* data, enum rarch_shader_type type, const
strncpy(ps_path + base_len, ps_ext, sizeof(ps_ext));
if (!d3d11_init_shader(
d3d11->device, vs_src, 0, vs_path, "main", NULL, NULL, desc, countof(desc),
&d3d11->pass[i].shader))
d3d11->device, vs_src, 0, vs_path, "main", NULL, NULL, desc, countof(desc),
&d3d11->pass[i].shader))
save_hlsl = true;
if (!d3d11_init_shader(
d3d11->device, ps_src, 0, ps_path, NULL, "main", NULL, NULL, 0,
&d3d11->pass[i].shader))
d3d11->device, ps_src, 0, ps_path, NULL, "main", NULL, NULL, 0,
&d3d11->pass[i].shader))
save_hlsl = true;
if (save_hlsl)
@ -342,7 +344,7 @@ error:
static void d3d11_gfx_free(void* data)
{
unsigned i;
unsigned i;
d3d11_video_t* d3d11 = (d3d11_video_t*)data;
if (!d3d11)
@ -400,7 +402,7 @@ static void d3d11_gfx_free(void* data)
static void*
d3d11_gfx_init(const video_info_t* video, const input_driver_t** input, void** input_data)
{
unsigned i;
unsigned i;
WNDCLASSEX wndclass = { 0 };
MONITORINFOEX current_mon;
HMONITOR hm_to_use;
@ -436,25 +438,25 @@ d3d11_gfx_init(const video_info_t* video, const input_driver_t** input, void** i
{
UINT flags = 0;
D3D_FEATURE_LEVEL requested_feature_level = D3D_FEATURE_LEVEL_11_0;
DXGI_SWAP_CHAIN_DESC desc = {
.BufferCount = 1,
.BufferDesc.Width = d3d11->vp.full_width,
.BufferDesc.Height = d3d11->vp.full_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_SEQUENTIAL,
DXGI_SWAP_CHAIN_DESC desc = { 0 };
desc.BufferCount = 1;
desc.BufferDesc.Width = d3d11->vp.full_width;
desc.BufferDesc.Height = d3d11->vp.full_height;
desc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
desc.BufferDesc.RefreshRate.Numerator = 60;
desc.BufferDesc.RefreshRate.Denominator = 1;
desc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
desc.OutputWindow = main_window.hwnd;
desc.SampleDesc.Count = 1;
desc.SampleDesc.Quality = 0;
desc.Windowed = TRUE;
desc.SwapEffect = DXGI_SWAP_EFFECT_SEQUENTIAL;
#if 0
.SwapEffect = DXGI_SWAP_EFFECT_DISCARD,
.SwapEffect = DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL,
.SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD,
desc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
desc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL;
desc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD;
#endif
};
#ifdef DEBUG
flags |= D3D11_CREATE_DEVICE_DEBUG;
@ -508,12 +510,12 @@ d3d11_gfx_init(const video_info_t* video, const input_driver_t** input, void** i
d3d11_gfx_set_rotation(d3d11, 0);
{
D3D11_SAMPLER_DESC desc = {
.MaxAnisotropy = 1,
.ComparisonFunc = D3D11_COMPARISON_NEVER,
.MinLOD = -D3D11_FLOAT32_MAX,
.MaxLOD = D3D11_FLOAT32_MAX,
};
D3D11_SAMPLER_DESC desc = { D3D11_FILTER_MIN_MAG_MIP_POINT };
desc.MaxAnisotropy = 1;
desc.ComparisonFunc = D3D11_COMPARISON_NEVER;
desc.MinLOD = -D3D11_FLOAT32_MAX;
desc.MaxLOD = D3D11_FLOAT32_MAX;
/* Initialize samplers */
for (i = 0; i < RARCH_WRAP_MAX; i++)
{
@ -557,11 +559,11 @@ d3d11_gfx_init(const video_info_t* video, const input_driver_t** input, void** i
};
{
D3D11_BUFFER_DESC desc = {
.Usage = D3D11_USAGE_IMMUTABLE,
.ByteWidth = sizeof(vertices),
.BindFlags = D3D11_BIND_VERTEX_BUFFER,
};
D3D11_BUFFER_DESC desc = { 0 };
desc.Usage = D3D11_USAGE_IMMUTABLE;
desc.ByteWidth = sizeof(vertices);
desc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
D3D11_SUBRESOURCE_DATA vertexData = { vertices };
D3D11CreateBuffer(d3d11->device, &desc, &vertexData, &d3d11->frame.vbo);
desc.Usage = D3D11_USAGE_DYNAMIC;
@ -691,21 +693,18 @@ d3d11_gfx_init(const video_info_t* video, const input_driver_t** input, void** i
}
{
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,
},
};
D3D11_BLEND_DESC blend_desc = { 0 };
blend_desc.AlphaToCoverageEnable = FALSE;
blend_desc.IndependentBlendEnable = FALSE;
blend_desc.RenderTarget[0].BlendEnable = TRUE;
blend_desc.RenderTarget[0].SrcBlend = D3D11_BLEND_SRC_ALPHA;
blend_desc.RenderTarget[0].DestBlend = D3D11_BLEND_INV_SRC_ALPHA;
blend_desc.RenderTarget[0].BlendOp = D3D11_BLEND_OP_ADD;
blend_desc.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_SRC_ALPHA;
blend_desc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_INV_SRC_ALPHA;
blend_desc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD;
blend_desc.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL;
D3D11CreateBlendState(d3d11->device, &blend_desc, &d3d11->blend_enable);
blend_desc.RenderTarget[0].SrcBlend = D3D11_BLEND_ONE;
@ -716,10 +715,11 @@ d3d11_gfx_init(const video_info_t* video, const input_driver_t** input, void** i
D3D11CreateBlendState(d3d11->device, &blend_desc, &d3d11->blend_disable);
}
{
D3D11_RASTERIZER_DESC desc = {
.FillMode = D3D11_FILL_SOLID,
.CullMode = D3D11_CULL_NONE,
};
D3D11_RASTERIZER_DESC desc = { 0 };
desc.FillMode = D3D11_FILL_SOLID;
desc.CullMode = D3D11_CULL_NONE;
D3D11CreateRasterizerState(d3d11->device, &desc, &d3d11->state);
}
D3D11SetState(d3d11->context, d3d11->state);
@ -873,8 +873,8 @@ static bool d3d11_gfx_frame(
const char* msg,
video_frame_info_t* video_info)
{
unsigned i;
d3d11_texture_t* texture = NULL;
unsigned i;
d3d11_texture_t* texture = NULL;
d3d11_video_t* d3d11 = (d3d11_video_t*)data;
D3D11DeviceContext context = d3d11->context;
@ -883,7 +883,7 @@ static bool d3d11_gfx_frame(
D3D11Texture2D backBuffer;
Release(d3d11->renderTargetView);
DXGIResizeBuffers(d3d11->swapChain, 0, 0, 0, 0, 0);
DXGIResizeBuffers(d3d11->swapChain, 0, 0, 0, DXGI_FORMAT_UNKNOWN, 0);
DXGIGetSwapChainBufferD3D11(d3d11->swapChain, 0, &backBuffer);
D3D11CreateTexture2DRenderTargetView(
@ -1176,8 +1176,9 @@ static bool d3d11_gfx_read_viewport(void* data, uint8_t* buffer, bool is_idle)
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;
DXGI_FORMAT format = rgb32 ? DXGI_FORMAT_B8G8R8A8_UNORM : DXGI_FORMAT_EX_A4R4G4B4_UNORM;
d3d11_video_t* d3d11 = (d3d11_video_t*)data;
DXGI_FORMAT format =
rgb32 ? DXGI_FORMAT_B8G8R8A8_UNORM : (DXGI_FORMAT)DXGI_FORMAT_EX_A4R4G4B4_UNORM;
if (d3d11->menu.texture.desc.Width != width || d3d11->menu.texture.desc.Height != height)
{
@ -1247,7 +1248,7 @@ static uintptr_t d3d11_gfx_load_texture(
if (!d3d11)
return 0;
texture = (d3d11_texture_t*)calloc(1, sizeof(*texture));
texture = (d3d11_texture_t*)calloc(1, sizeof(*texture));
if (!texture)
return 0;

View File

@ -13,6 +13,8 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#define CINTERFACE
#include <assert.h>
#include <string/stdstring.h>
@ -236,7 +238,7 @@ static bool d3d12_gfx_frame(
D3D12RSSetScissorRects(d3d12->queue.cmd, 1, &d3d12->frame.scissorRect);
D3D12SetGraphicsRootConstantBufferView(
d3d12->queue.cmd, ROOT_INDEX_UBO, d3d12->frame.ubo_view.BufferLocation);
d3d12->queue.cmd, ROOT_ID_UBO, d3d12->frame.ubo_view.BufferLocation);
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);
@ -248,7 +250,7 @@ static bool d3d12_gfx_frame(
d3d12_upload_texture(d3d12->queue.cmd, &d3d12->menu.texture);
D3D12SetGraphicsRootConstantBufferView(
d3d12->queue.cmd, ROOT_INDEX_UBO, d3d12->ubo_view.BufferLocation);
d3d12->queue.cmd, ROOT_ID_UBO, d3d12->ubo_view.BufferLocation);
if (d3d12->menu.fullscreen)
{

View File

@ -13,6 +13,8 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#define CINTERFACE
#include <stdio.h>
#include <string.h>
#include <malloc.h>

View File

@ -31,6 +31,7 @@
#endif
#include <streams/file_stream.h>
#define VFS_FRONTEND
#include <vfs/vfs_implementation.h>
static const int64_t vfs_error_return_value = -1;

View File

@ -13,6 +13,8 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#define CINTERFACE
#include <retro_miscellaneous.h>
#ifdef HAVE_CONFIG_H
@ -80,12 +82,12 @@ static void menu_display_d3d11_draw(void* data)
{
D3D11_MAPPED_SUBRESOURCE mapped_vbo;
d3d11_sprite_t *v = NULL;
d3d11_sprite_t* v = NULL;
D3D11MapBuffer(
d3d11->context, d3d11->sprites.vbo, 0, D3D11_MAP_WRITE_NO_OVERWRITE, 0, &mapped_vbo);
v = (d3d11_sprite_t*)mapped_vbo.pData + d3d11->sprites.offset;
v = (d3d11_sprite_t*)mapped_vbo.pData + d3d11->sprites.offset;
v->pos.x = draw->x / (float)d3d11->viewport.Width;
v->pos.y = (d3d11->viewport.Height - draw->y - draw->height) / (float)d3d11->viewport.Height;
@ -139,15 +141,15 @@ static void menu_display_d3d11_draw_pipeline(void* data)
case VIDEO_SHADER_MENU:
case VIDEO_SHADER_MENU_2:
{
video_coord_array_t *ca = menu_display_get_coords_array();
video_coord_array_t* ca = menu_display_get_coords_array();
if (!d3d11->menu_pipeline_vbo)
{
D3D11_BUFFER_DESC desc = {
.Usage = D3D11_USAGE_IMMUTABLE,
.ByteWidth = ca->coords.vertices * 2 * sizeof(float),
.BindFlags = D3D11_BIND_VERTEX_BUFFER,
};
D3D11_BUFFER_DESC desc = { 0 };
desc.Usage = D3D11_USAGE_IMMUTABLE;
desc.ByteWidth = ca->coords.vertices * 2 * sizeof(float);
desc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
D3D11_SUBRESOURCE_DATA vertexData = { ca->coords.vertex };
D3D11CreateBuffer(d3d11->device, &desc, &vertexData, &d3d11->menu_pipeline_vbo);
}
@ -199,12 +201,12 @@ static bool menu_display_d3d11_font_init_first(
float font_size,
bool is_threaded)
{
font_data_t** handle = (font_data_t**)font_handle;
font_data_t *new_handle = font_driver_init_first(
video_data, font_path, font_size, true, is_threaded, FONT_DRIVER_RENDER_D3D11_API);
font_data_t** handle = (font_data_t**)font_handle;
font_data_t* new_handle = font_driver_init_first(
video_data, font_path, font_size, true, is_threaded, FONT_DRIVER_RENDER_D3D11_API);
if (!new_handle)
return false;
*handle = new_handle;
return false;
*handle = new_handle;
return true;
}

View File

@ -426,8 +426,8 @@ bool netplay_resolve_input(netplay_t *netplay, size_t sim_ptr, bool resim)
{
/* Merge them */
/* Most devices have all the digital parts in the first word. */
static const uint32_t digital_common[3] = {-1, 0, 0};
static const uint32_t digital_keyboard[5] = {-1, -1, -1, -1, -1};
static const uint32_t digital_common[3] = {~0u, 0u, 0u};
static const uint32_t digital_keyboard[5] = {~0u, ~0u, ~0u, ~0u, ~0u};
const uint32_t *digital;
if (dtype == RETRO_DEVICE_KEYBOARD)
digital = digital_keyboard;

View File

@ -50,8 +50,11 @@
#include <setupapi.h>
#include <hidsdi.h>
#ifndef __cplusplus
/* Why doesn't including cguid.h work to get a GUID_NULL instead? */
#ifdef __cplusplus
EXTERN_C __attribute__((weak))
const GUID GUID_NULL = {0, 0, 0, {0, 0, 0, 0, 0, 0, 0, 0}};
#else
__attribute__((weak))
const GUID GUID_NULL = {0, 0, 0, {0, 0, 0, 0, 0, 0, 0, 0}};
#endif