diff --git a/gfx/common/ctr_defines.h b/gfx/common/ctr_defines.h index f64d346a38..cabaa44983 100644 --- a/gfx/common/ctr_defines.h +++ b/gfx/common/ctr_defines.h @@ -16,17 +16,6 @@ #ifndef CTR_DEFINES_H__ #define CTR_DEFINES_H__ -#include <3ds.h> -#include - -#define COLOR_ABGR(r, g, b, a) (((unsigned)(a) << 24) | ((b) << 16) | ((g) << 8) | ((r) << 0)) - -#define CTR_TOP_FRAMEBUFFER_WIDTH 400 -#define CTR_TOP_FRAMEBUFFER_HEIGHT 240 -#define CTR_BOTTOM_FRAMEBUFFER_WIDTH 320 -#define CTR_BOTTOM_FRAMEBUFFER_HEIGHT 240 -#define CTR_STATE_DATE_SIZE 11 - typedef enum { CTR_VIDEO_MODE_3D = 0, @@ -36,17 +25,4 @@ typedef enum CTR_VIDEO_MODE_LAST } ctr_video_mode_enum; -#ifdef USE_CTRULIB_2 -extern u8* gfxTopLeftFramebuffers[2]; -extern u8* gfxTopRightFramebuffers[2]; -extern u8* gfxBottomFramebuffers[2]; -#endif - -#ifdef CONSOLE_LOG -extern PrintConsole* ctrConsole; -#endif - -extern const u8 ctr_sprite_shbin[]; -extern const u32 ctr_sprite_shbin_size; - #endif /* CTR_DEFINES_H__ */ diff --git a/gfx/common/d3d10_defines.h b/gfx/common/d3d10_defines.h deleted file mode 100644 index c812a63769..0000000000 --- a/gfx/common/d3d10_defines.h +++ /dev/null @@ -1,88 +0,0 @@ -/* 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 . - */ - -#ifndef _D3D10_DEFINES_H_ -#define _D3D10_DEFINES_H_ - -#include - -#include "dxgi_common.h" -#include - -#include - -#include "../drivers_shader/slang_process.h" - -#define D3D10_MAX_GPU_COUNT 16 - -enum d3d10_video_flags -{ - D3D10_ST_FLAG_VSYNC = (1 << 0), - D3D10_ST_FLAG_RESIZE_CHAIN = (1 << 1), - D3D10_ST_FLAG_KEEP_ASPECT = (1 << 2), - D3D10_ST_FLAG_RESIZE_VIEWPORT = (1 << 3), - D3D10_ST_FLAG_RESIZE_RTS = (1 << 4), /* RT = Render Target */ - D3D10_ST_FLAG_INIT_HISTORY = (1 << 5), - D3D10_ST_FLAG_SPRITES_ENABLE = (1 << 6), - D3D10_ST_FLAG_OVERLAYS_ENABLE = (1 << 7), - D3D10_ST_FLAG_OVERLAYS_FULLSCREEN = (1 << 8), - D3D10_ST_FLAG_MENU_ENABLE = (1 << 9), - D3D10_ST_FLAG_MENU_FULLSCREEN = (1 << 10), - D3D10_ST_FLAG_FRAME_DUPE_LOCK = (1 << 11) -}; - -typedef const ID3D10SamplerState* D3D10SamplerStateRef; - -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; -#ifdef DEBUG -typedef ID3D10Debug* D3D10Debug; -#endif -typedef ID3D10SwitchToRef* D3D10SwitchToRef; -typedef ID3D10InfoQueue* D3D10InfoQueue; - -#ifndef ALIGN -#ifdef _MSC_VER -#define ALIGN(x) __declspec(align(x)) -#else -#define ALIGN(x) __attribute__((aligned(x))) -#endif -#endif - -#endif diff --git a/gfx/common/d3d11_defines.h b/gfx/common/d3d11_defines.h deleted file mode 100644 index 4c0ac2d3fd..0000000000 --- a/gfx/common/d3d11_defines.h +++ /dev/null @@ -1,134 +0,0 @@ -/* 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 . - */ - -#ifndef _D3D11_DEFINES_H_ -#define _D3D11_DEFINES_H_ - -#include - -#include "dxgi_common.h" -#ifdef CINTERFACE -#define D3D11_NO_HELPERS -#endif -#include - -#include -#include - -#include "../drivers_shader/slang_process.h" - -#define D3D11_MAX_GPU_COUNT 16 - -enum d3d11_state_flags -{ - D3D11_ST_FLAG_VSYNC = (1 << 0), - D3D11_ST_FLAG_WAITABLE_SWAPCHAINS = (1 << 1), - D3D11_ST_FLAG_RESIZE_CHAIN = (1 << 2), - D3D11_ST_FLAG_KEEP_ASPECT = (1 << 3), - D3D11_ST_FLAG_RESIZE_VIEWPORT = (1 << 4), - D3D11_ST_FLAG_RESIZE_RTS = (1 << 5), /* RT = Render Target */ - D3D11_ST_FLAG_INIT_HISTORY = (1 << 6), - D3D11_ST_FLAG_HAS_FLIP_MODEL = (1 << 7), - D3D11_ST_FLAG_HAS_ALLOW_TEARING = (1 << 8), - D3D11_ST_FLAG_HW_IFACE_ENABLE = (1 << 9), - D3D11_ST_FLAG_HDR_SUPPORT = (1 << 10), - D3D11_ST_FLAG_HDR_ENABLE = (1 << 11), - D3D11_ST_FLAG_SPRITES_ENABLE = (1 << 12), - D3D11_ST_FLAG_OVERLAYS_ENABLE = (1 << 13), - D3D11_ST_FLAG_OVERLAYS_FULLSCREEN = (1 << 14), - D3D11_ST_FLAG_MENU_ENABLE = (1 << 15), - D3D11_ST_FLAG_MENU_FULLSCREEN = (1 << 16), - D3D11_ST_FLAG_FRAME_DUPE_LOCK = (1 << 17) -}; - -enum d3d11_feature_level_hint -{ - D3D11_FEATURE_LEVEL_HINT_DONTCARE, - D3D11_FEATURE_LEVEL_HINT_1_0_CORE, - D3D11_FEATURE_LEVEL_HINT_9_1, - D3D11_FEATURE_LEVEL_HINT_9_2, - D3D11_FEATURE_LEVEL_HINT_9_3, - D3D11_FEATURE_LEVEL_HINT_10_0, - D3D11_FEATURE_LEVEL_HINT_10_1, - D3D11_FEATURE_LEVEL_HINT_11_0, - D3D11_FEATURE_LEVEL_HINT_11_1, - D3D11_FEATURE_LEVEL_HINT_12_0, - D3D11_FEATURE_LEVEL_HINT_12_1, - D3D11_FEATURE_LEVEL_HINT_12_2 -}; - -typedef const ID3D11ShaderResourceView* D3D11ShaderResourceViewRef; -typedef const ID3D11SamplerState* D3D11SamplerStateRef; -typedef const ID3D11BlendState* D3D11BlendStateRef; - -typedef ID3D11InputLayout* D3D11InputLayout; -typedef ID3D11RasterizerState* D3D11RasterizerState; -typedef ID3D11DepthStencilState* D3D11DepthStencilState; -typedef ID3D11BlendState* D3D11BlendState; -typedef ID3D11PixelShader* D3D11PixelShader; -typedef ID3D11SamplerState* D3D11SamplerState; -typedef ID3D11VertexShader* D3D11VertexShader; -typedef ID3D11DomainShader* D3D11DomainShader; -typedef ID3D11HullShader* D3D11HullShader; -typedef ID3D11ComputeShader* D3D11ComputeShader; -typedef ID3D11GeometryShader* D3D11GeometryShader; - -/* auto-generated */ - -typedef ID3D11Resource* D3D11Resource; -typedef ID3D11Buffer* D3D11Buffer; -typedef ID3D11Texture1D* D3D11Texture1D; -typedef ID3D11Texture2D* D3D11Texture2D; -typedef ID3D11Texture3D* D3D11Texture3D; -typedef ID3D11View* D3D11View; -typedef ID3D11ShaderResourceView* D3D11ShaderResourceView; -typedef ID3D11RenderTargetView* D3D11RenderTargetView; -typedef ID3D11DepthStencilView* D3D11DepthStencilView; -typedef ID3D11UnorderedAccessView* D3D11UnorderedAccessView; -typedef ID3D11Asynchronous* D3D11Asynchronous; -typedef ID3D11Query* D3D11Query; -typedef ID3D11Predicate* D3D11Predicate; -typedef ID3D11Counter* D3D11Counter; -typedef ID3D11ClassInstance* D3D11ClassInstance; -typedef ID3D11ClassLinkage* D3D11ClassLinkage; -typedef ID3D11CommandList* D3D11CommandList; -typedef ID3D11DeviceContext* D3D11DeviceContext; -typedef ID3D11VideoDecoder* D3D11VideoDecoder; -typedef ID3D11VideoProcessorEnumerator* D3D11VideoProcessorEnumerator; -typedef ID3D11VideoProcessor* D3D11VideoProcessor; -typedef ID3D11AuthenticatedChannel* D3D11AuthenticatedChannel; -typedef ID3D11CryptoSession* D3D11CryptoSession; -typedef ID3D11VideoDecoderOutputView* D3D11VideoDecoderOutputView; -typedef ID3D11VideoProcessorInputView* D3D11VideoProcessorInputView; -typedef ID3D11VideoProcessorOutputView* D3D11VideoProcessorOutputView; -typedef ID3D11VideoContext* D3D11VideoContext; -typedef ID3D11VideoDevice* D3D11VideoDevice; -typedef ID3D11Device* D3D11Device; -#ifdef DEBUG -typedef ID3D11Debug* D3D11Debug; -#endif -typedef ID3D11SwitchToRef* D3D11SwitchToRef; -typedef ID3D11TracingDevice* D3D11TracingDevice; -typedef ID3D11InfoQueue* D3D11InfoQueue; - -#ifndef ALIGN -#ifdef _MSC_VER -#define ALIGN(x) __declspec(align(x)) -#else -#define ALIGN(x) __attribute__((aligned(x))) -#endif -#endif - -#endif diff --git a/gfx/common/d3d12_defines.h b/gfx/common/d3d12_defines.h deleted file mode 100644 index 1eac7f4da1..0000000000 --- a/gfx/common/d3d12_defines.h +++ /dev/null @@ -1,137 +0,0 @@ -/* RetroArch - A frontend for libretro. - * Copyright (C) 2014-2018 - Ali Bouhlel - * Copyright (C) 2016-2019 - Brad Parker - * - * 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 . - */ - -#ifndef _D3D12_DEFINES_H_ -#define _D3D12_DEFINES_H_ - -#include -#include - -#include "dxgi_common.h" -#include - -#include - -#include "../common/d3dcompiler_common.h" -#include "../drivers_shader/slang_process.h" - -#define D3D12_MAX_GPU_COUNT 16 - -#define D3D12_RESOURCE_TRANSITION(cmd, resource, state_before, state_after) \ -{ \ - D3D12_RESOURCE_BARRIER _barrier; \ - _barrier.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION; \ - _barrier.Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE; \ - _barrier.Transition.pResource = resource; \ - _barrier.Transition.StateBefore = state_before; \ - _barrier.Transition.StateAfter = state_after; \ - _barrier.Transition.Subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES; \ - cmd->lpVtbl->ResourceBarrier(cmd, 1, &_barrier); \ -} - -enum d3d12_video_flags -{ - D3D12_ST_FLAG_RESIZE_CHAIN = (1 << 0), - D3D12_ST_FLAG_KEEP_ASPECT = (1 << 1), - D3D12_ST_FLAG_RESIZE_VIEWPORT = (1 << 2), - D3D12_ST_FLAG_RESIZE_RTS = (1 << 3), - D3D12_ST_FLAG_INIT_HISTORY = (1 << 4), - D3D12_ST_FLAG_OVERLAYS_ENABLE = (1 << 5), - D3D12_ST_FLAG_OVERLAYS_FULLSCREEN = (1 << 6), - D3D12_ST_FLAG_SPRITES_ENABLE = (1 << 7), - D3D12_ST_FLAG_MENU_ENABLE = (1 << 8), - D3D12_ST_FLAG_MENU_FULLSCREEN = (1 << 9), - D3D12_ST_FLAG_HDR_SUPPORT = (1 << 10), - D3D12_ST_FLAG_HDR_ENABLE = (1 << 11), - D3D12_ST_FLAG_VSYNC = (1 << 12), - D3D12_ST_FLAG_WAITABLE_SWAPCHAINS = (1 << 13), - D3D12_ST_FLAG_HW_IFACE_ENABLE = (1 << 14), - D3D12_ST_FLAG_FRAME_DUPE_LOCK = (1 << 15) -}; - -typedef enum -{ - ROOT_ID_TEXTURE_T = 0, - ROOT_ID_SAMPLER_T, - ROOT_ID_UBO, - ROOT_ID_PC, - ROOT_ID_MAX -} root_signature_parameter_index_t; - -typedef enum -{ - CS_ROOT_ID_TEXTURE_T = 0, - CS_ROOT_ID_UAV_T, - CS_ROOT_ID_CONSTANTS, - CS_ROOT_ID_MAX -} compute_root_index_t; - -typedef const ID3D12PipelineState* D3D12PipelineStateRef; - -/* auto-generated */ - -typedef ID3D12Object* D3D12Object; -typedef ID3D12DeviceChild* D3D12DeviceChild; -typedef ID3D12RootSignature* D3D12RootSignature; -typedef ID3D12RootSignatureDeserializer* D3D12RootSignatureDeserializer; -typedef ID3D12VersionedRootSignatureDeserializer* D3D12VersionedRootSignatureDeserializer; -typedef ID3D12Pageable* D3D12Pageable; -typedef ID3D12Heap* D3D12Heap; -typedef ID3D12Resource* D3D12Resource; -typedef ID3D12CommandAllocator* D3D12CommandAllocator; -typedef ID3D12Fence* D3D12Fence; -typedef ID3D12PipelineState* D3D12PipelineState; -typedef ID3D12DescriptorHeap* D3D12DescriptorHeap; -typedef ID3D12QueryHeap* D3D12QueryHeap; -typedef ID3D12CommandSignature* D3D12CommandSignature; -typedef ID3D12CommandList* D3D12CommandList; -typedef ID3D12GraphicsCommandList* D3D12GraphicsCommandList; -typedef ID3D12CommandQueue* D3D12CommandQueue; -typedef ID3D12Device* D3D12Device; -typedef ID3D12PipelineLibrary* D3D12PipelineLibrary; -#ifdef DEBUG -typedef ID3D12Debug* D3D12Debug; -typedef ID3D12DebugDevice* D3D12DebugDevice; -typedef ID3D12DebugCommandQueue* D3D12DebugCommandQueue; -typedef ID3D12DebugCommandList* D3D12DebugCommandList; -#ifdef DEVICE_DEBUG -typedef ID3D12DeviceRemovedExtendedDataSettings* D3D12DeviceRemovedExtendedDataSettings; -#endif /* DEVICE_DEBUG */ -#endif -typedef ID3D12InfoQueue* D3D12InfoQueue; - -typedef struct -{ - D3D12DescriptorHeap handle; /* descriptor pool */ - D3D12_DESCRIPTOR_HEAP_DESC desc; - D3D12_CPU_DESCRIPTOR_HANDLE cpu; /* descriptor */ - D3D12_GPU_DESCRIPTOR_HANDLE gpu; /* descriptor */ - UINT stride; - bool* map; - int start; -} d3d12_descriptor_heap_t; - -#ifndef ALIGN -#ifdef _MSC_VER -#define ALIGN(x) __declspec(align(x)) -#else -#define ALIGN(x) __attribute__((aligned(x))) -#endif -#endif - -/* end of auto-generated */ - -#endif diff --git a/gfx/drivers/ctr_gfx.c b/gfx/drivers/ctr_gfx.c index efae5c22ba..49c0a6c606 100644 --- a/gfx/drivers/ctr_gfx.c +++ b/gfx/drivers/ctr_gfx.c @@ -53,11 +53,18 @@ #include "../../verbosity.h" #include "../../paths.h" -#include "../common/ctr_defines.h" #ifndef HAVE_THREADS #include "../../tasks/tasks_internal.h" #endif +#define COLOR_ABGR(r, g, b, a) (((unsigned)(a) << 24) | ((b) << 16) | ((g) << 8) | ((r) << 0)) + +#define CTR_TOP_FRAMEBUFFER_WIDTH 400 +#define CTR_TOP_FRAMEBUFFER_HEIGHT 240 +#define CTR_BOTTOM_FRAMEBUFFER_WIDTH 320 +#define CTR_BOTTOM_FRAMEBUFFER_HEIGHT 240 +#define CTR_STATE_DATE_SIZE 11 + #define CTR_SET_SCALE_VECTOR(vec, vp_width, vp_height, tex_width, tex_height) \ (vec)->x = -2.0f / (vp_width); \ (vec)->y = -2.0f / (vp_height); \ @@ -92,6 +99,20 @@ typedef struct s16 u0, v0, u1, v1; } ctr_vertex_t; +#ifdef USE_CTRULIB_2 +extern u8* gfxTopLeftFramebuffers[2]; +extern u8* gfxTopRightFramebuffers[2]; +extern u8* gfxBottomFramebuffers[2]; +#endif + +#ifdef CONSOLE_LOG +extern PrintConsole* ctrConsole; +#endif + +extern const u8 ctr_sprite_shbin[]; +extern const u32 ctr_sprite_shbin_size; + + typedef struct ctr_video { struct diff --git a/gfx/drivers/d3d10.c b/gfx/drivers/d3d10.c index 0fbce3230f..b999e9aa7d 100644 --- a/gfx/drivers/d3d10.c +++ b/gfx/drivers/d3d10.c @@ -29,6 +29,8 @@ #include #include +#include +#include #include #include #include @@ -47,8 +49,10 @@ #include "../font_driver.h" #include "../common/d3d_common.h" #include "../common/win32_common.h" -#include "../common/d3d10_defines.h" +#include "../video_shader_parse.h" +#include "../drivers_shader/slang_process.h" #include "../common/dxgi_common.h" +#include #include "../common/d3dcompiler_common.h" #ifdef HAVE_MENU #include "../../menu/menu_driver.h" @@ -63,6 +67,66 @@ #define D3D10_ROLLING_SCANLINE_SIMULATION +#define D3D10_MAX_GPU_COUNT 16 + +enum d3d10_video_flags +{ + D3D10_ST_FLAG_VSYNC = (1 << 0), + D3D10_ST_FLAG_RESIZE_CHAIN = (1 << 1), + D3D10_ST_FLAG_KEEP_ASPECT = (1 << 2), + D3D10_ST_FLAG_RESIZE_VIEWPORT = (1 << 3), + D3D10_ST_FLAG_RESIZE_RTS = (1 << 4), /* RT = Render Target */ + D3D10_ST_FLAG_INIT_HISTORY = (1 << 5), + D3D10_ST_FLAG_SPRITES_ENABLE = (1 << 6), + D3D10_ST_FLAG_OVERLAYS_ENABLE = (1 << 7), + D3D10_ST_FLAG_OVERLAYS_FULLSCREEN = (1 << 8), + D3D10_ST_FLAG_MENU_ENABLE = (1 << 9), + D3D10_ST_FLAG_MENU_FULLSCREEN = (1 << 10), + D3D10_ST_FLAG_FRAME_DUPE_LOCK = (1 << 11) +}; + +typedef const ID3D10SamplerState* D3D10SamplerStateRef; + +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; +#ifdef DEBUG +typedef ID3D10Debug* D3D10Debug; +#endif +typedef ID3D10SwitchToRef* D3D10SwitchToRef; +typedef ID3D10InfoQueue* D3D10InfoQueue; + +#ifndef ALIGN +#ifdef _MSC_VER +#define ALIGN(x) __declspec(align(x)) +#else +#define ALIGN(x) __attribute__((aligned(x))) +#endif +#endif + typedef struct { D3D10Texture2D handle; diff --git a/gfx/drivers/d3d11.c b/gfx/drivers/d3d11.c index 83fc62c6ec..7db8f8b493 100644 --- a/gfx/drivers/d3d11.c +++ b/gfx/drivers/d3d11.c @@ -23,11 +23,17 @@ #define CINTERFACE #define COBJMACROS +#ifdef CINTERFACE +#define D3D11_NO_HELPERS +#endif #include #include #include +#include +#include + #include #include #include @@ -59,8 +65,9 @@ #endif #include "../common/d3d_common.h" -#include "../common/d3d11_defines.h" #include "../common/dxgi_common.h" +#include +#include #include "../common/d3dcompiler_common.h" #ifdef HAVE_SLANG #include "../drivers_shader/slang_process.h" @@ -76,6 +83,108 @@ const GUID DECLSPEC_SELECTANY libretro_IID_IDXGIFactory5 = { 0x7632e1f5,0xee65,0 #endif #endif +#define D3D11_MAX_GPU_COUNT 16 + +enum d3d11_state_flags +{ + D3D11_ST_FLAG_VSYNC = (1 << 0), + D3D11_ST_FLAG_WAITABLE_SWAPCHAINS = (1 << 1), + D3D11_ST_FLAG_RESIZE_CHAIN = (1 << 2), + D3D11_ST_FLAG_KEEP_ASPECT = (1 << 3), + D3D11_ST_FLAG_RESIZE_VIEWPORT = (1 << 4), + D3D11_ST_FLAG_RESIZE_RTS = (1 << 5), /* RT = Render Target */ + D3D11_ST_FLAG_INIT_HISTORY = (1 << 6), + D3D11_ST_FLAG_HAS_FLIP_MODEL = (1 << 7), + D3D11_ST_FLAG_HAS_ALLOW_TEARING = (1 << 8), + D3D11_ST_FLAG_HW_IFACE_ENABLE = (1 << 9), + D3D11_ST_FLAG_HDR_SUPPORT = (1 << 10), + D3D11_ST_FLAG_HDR_ENABLE = (1 << 11), + D3D11_ST_FLAG_SPRITES_ENABLE = (1 << 12), + D3D11_ST_FLAG_OVERLAYS_ENABLE = (1 << 13), + D3D11_ST_FLAG_OVERLAYS_FULLSCREEN = (1 << 14), + D3D11_ST_FLAG_MENU_ENABLE = (1 << 15), + D3D11_ST_FLAG_MENU_FULLSCREEN = (1 << 16), + D3D11_ST_FLAG_FRAME_DUPE_LOCK = (1 << 17) +}; + +enum d3d11_feature_level_hint +{ + D3D11_FEATURE_LEVEL_HINT_DONTCARE, + D3D11_FEATURE_LEVEL_HINT_1_0_CORE, + D3D11_FEATURE_LEVEL_HINT_9_1, + D3D11_FEATURE_LEVEL_HINT_9_2, + D3D11_FEATURE_LEVEL_HINT_9_3, + D3D11_FEATURE_LEVEL_HINT_10_0, + D3D11_FEATURE_LEVEL_HINT_10_1, + D3D11_FEATURE_LEVEL_HINT_11_0, + D3D11_FEATURE_LEVEL_HINT_11_1, + D3D11_FEATURE_LEVEL_HINT_12_0, + D3D11_FEATURE_LEVEL_HINT_12_1, + D3D11_FEATURE_LEVEL_HINT_12_2 +}; + +typedef const ID3D11ShaderResourceView* D3D11ShaderResourceViewRef; +typedef const ID3D11SamplerState* D3D11SamplerStateRef; +typedef const ID3D11BlendState* D3D11BlendStateRef; + +typedef ID3D11InputLayout* D3D11InputLayout; +typedef ID3D11RasterizerState* D3D11RasterizerState; +typedef ID3D11DepthStencilState* D3D11DepthStencilState; +typedef ID3D11BlendState* D3D11BlendState; +typedef ID3D11PixelShader* D3D11PixelShader; +typedef ID3D11SamplerState* D3D11SamplerState; +typedef ID3D11VertexShader* D3D11VertexShader; +typedef ID3D11DomainShader* D3D11DomainShader; +typedef ID3D11HullShader* D3D11HullShader; +typedef ID3D11ComputeShader* D3D11ComputeShader; +typedef ID3D11GeometryShader* D3D11GeometryShader; + +/* auto-generated */ + +typedef ID3D11Resource* D3D11Resource; +typedef ID3D11Buffer* D3D11Buffer; +typedef ID3D11Texture1D* D3D11Texture1D; +typedef ID3D11Texture2D* D3D11Texture2D; +typedef ID3D11Texture3D* D3D11Texture3D; +typedef ID3D11View* D3D11View; +typedef ID3D11ShaderResourceView* D3D11ShaderResourceView; +typedef ID3D11RenderTargetView* D3D11RenderTargetView; +typedef ID3D11DepthStencilView* D3D11DepthStencilView; +typedef ID3D11UnorderedAccessView* D3D11UnorderedAccessView; +typedef ID3D11Asynchronous* D3D11Asynchronous; +typedef ID3D11Query* D3D11Query; +typedef ID3D11Predicate* D3D11Predicate; +typedef ID3D11Counter* D3D11Counter; +typedef ID3D11ClassInstance* D3D11ClassInstance; +typedef ID3D11ClassLinkage* D3D11ClassLinkage; +typedef ID3D11CommandList* D3D11CommandList; +typedef ID3D11DeviceContext* D3D11DeviceContext; +typedef ID3D11VideoDecoder* D3D11VideoDecoder; +typedef ID3D11VideoProcessorEnumerator* D3D11VideoProcessorEnumerator; +typedef ID3D11VideoProcessor* D3D11VideoProcessor; +typedef ID3D11AuthenticatedChannel* D3D11AuthenticatedChannel; +typedef ID3D11CryptoSession* D3D11CryptoSession; +typedef ID3D11VideoDecoderOutputView* D3D11VideoDecoderOutputView; +typedef ID3D11VideoProcessorInputView* D3D11VideoProcessorInputView; +typedef ID3D11VideoProcessorOutputView* D3D11VideoProcessorOutputView; +typedef ID3D11VideoContext* D3D11VideoContext; +typedef ID3D11VideoDevice* D3D11VideoDevice; +typedef ID3D11Device* D3D11Device; +#ifdef DEBUG +typedef ID3D11Debug* D3D11Debug; +#endif +typedef ID3D11SwitchToRef* D3D11SwitchToRef; +typedef ID3D11TracingDevice* D3D11TracingDevice; +typedef ID3D11InfoQueue* D3D11InfoQueue; + +#ifndef ALIGN +#ifdef _MSC_VER +#define ALIGN(x) __declspec(align(x)) +#else +#define ALIGN(x) __attribute__((aligned(x))) +#endif +#endif + #if defined(HAVE_DYLIB) && !defined(__WINRT__) #include diff --git a/gfx/drivers/d3d12.c b/gfx/drivers/d3d12.c index 65f7f00bd9..970e2f8d33 100644 --- a/gfx/drivers/d3d12.c +++ b/gfx/drivers/d3d12.c @@ -28,6 +28,9 @@ #include #include +#include +#include + #include #include @@ -64,7 +67,8 @@ #include "../common/d3d_common.h" #include "../common/dxgi_common.h" -#include "../common/d3d12_defines.h" +#include +#include #include "../common/d3dcompiler_common.h" #ifdef HAVE_SLANG #include "../drivers_shader/slang_process.h" @@ -74,6 +78,110 @@ #include "../../uwp/uwp_func.h" #endif +#define D3D12_MAX_GPU_COUNT 16 + +#define D3D12_RESOURCE_TRANSITION(cmd, resource, state_before, state_after) \ +{ \ + D3D12_RESOURCE_BARRIER _barrier; \ + _barrier.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION; \ + _barrier.Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE; \ + _barrier.Transition.pResource = resource; \ + _barrier.Transition.StateBefore = state_before; \ + _barrier.Transition.StateAfter = state_after; \ + _barrier.Transition.Subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES; \ + cmd->lpVtbl->ResourceBarrier(cmd, 1, &_barrier); \ +} + +enum d3d12_video_flags +{ + D3D12_ST_FLAG_RESIZE_CHAIN = (1 << 0), + D3D12_ST_FLAG_KEEP_ASPECT = (1 << 1), + D3D12_ST_FLAG_RESIZE_VIEWPORT = (1 << 2), + D3D12_ST_FLAG_RESIZE_RTS = (1 << 3), + D3D12_ST_FLAG_INIT_HISTORY = (1 << 4), + D3D12_ST_FLAG_OVERLAYS_ENABLE = (1 << 5), + D3D12_ST_FLAG_OVERLAYS_FULLSCREEN = (1 << 6), + D3D12_ST_FLAG_SPRITES_ENABLE = (1 << 7), + D3D12_ST_FLAG_MENU_ENABLE = (1 << 8), + D3D12_ST_FLAG_MENU_FULLSCREEN = (1 << 9), + D3D12_ST_FLAG_HDR_SUPPORT = (1 << 10), + D3D12_ST_FLAG_HDR_ENABLE = (1 << 11), + D3D12_ST_FLAG_VSYNC = (1 << 12), + D3D12_ST_FLAG_WAITABLE_SWAPCHAINS = (1 << 13), + D3D12_ST_FLAG_HW_IFACE_ENABLE = (1 << 14), + D3D12_ST_FLAG_FRAME_DUPE_LOCK = (1 << 15) +}; + +typedef enum +{ + ROOT_ID_TEXTURE_T = 0, + ROOT_ID_SAMPLER_T, + ROOT_ID_UBO, + ROOT_ID_PC, + ROOT_ID_MAX +} root_signature_parameter_index_t; + +typedef enum +{ + CS_ROOT_ID_TEXTURE_T = 0, + CS_ROOT_ID_UAV_T, + CS_ROOT_ID_CONSTANTS, + CS_ROOT_ID_MAX +} compute_root_index_t; + +typedef const ID3D12PipelineState* D3D12PipelineStateRef; + +/* auto-generated */ + +typedef ID3D12Object* D3D12Object; +typedef ID3D12DeviceChild* D3D12DeviceChild; +typedef ID3D12RootSignature* D3D12RootSignature; +typedef ID3D12RootSignatureDeserializer* D3D12RootSignatureDeserializer; +typedef ID3D12VersionedRootSignatureDeserializer* D3D12VersionedRootSignatureDeserializer; +typedef ID3D12Pageable* D3D12Pageable; +typedef ID3D12Heap* D3D12Heap; +typedef ID3D12Resource* D3D12Resource; +typedef ID3D12CommandAllocator* D3D12CommandAllocator; +typedef ID3D12Fence* D3D12Fence; +typedef ID3D12PipelineState* D3D12PipelineState; +typedef ID3D12DescriptorHeap* D3D12DescriptorHeap; +typedef ID3D12QueryHeap* D3D12QueryHeap; +typedef ID3D12CommandSignature* D3D12CommandSignature; +typedef ID3D12CommandList* D3D12CommandList; +typedef ID3D12GraphicsCommandList* D3D12GraphicsCommandList; +typedef ID3D12CommandQueue* D3D12CommandQueue; +typedef ID3D12Device* D3D12Device; +typedef ID3D12PipelineLibrary* D3D12PipelineLibrary; +#ifdef DEBUG +typedef ID3D12Debug* D3D12Debug; +typedef ID3D12DebugDevice* D3D12DebugDevice; +typedef ID3D12DebugCommandQueue* D3D12DebugCommandQueue; +typedef ID3D12DebugCommandList* D3D12DebugCommandList; +#ifdef DEVICE_DEBUG +typedef ID3D12DeviceRemovedExtendedDataSettings* D3D12DeviceRemovedExtendedDataSettings; +#endif /* DEVICE_DEBUG */ +#endif +typedef ID3D12InfoQueue* D3D12InfoQueue; + +typedef struct +{ + D3D12DescriptorHeap handle; /* descriptor pool */ + D3D12_DESCRIPTOR_HEAP_DESC desc; + D3D12_CPU_DESCRIPTOR_HANDLE cpu; /* descriptor */ + D3D12_GPU_DESCRIPTOR_HANDLE gpu; /* descriptor */ + UINT stride; + bool* map; + int start; +} d3d12_descriptor_heap_t; + +#ifndef ALIGN +#ifdef _MSC_VER +#define ALIGN(x) __declspec(align(x)) +#else +#define ALIGN(x) __attribute__((aligned(x))) +#endif +#endif + #define D3D12_GFX_SYNC() \ { \ D3D12Fence fence = d3d12->queue.fence; \ diff --git a/menu/menu_setting.c b/menu/menu_setting.c index c0ef9a6cb1..767febdd99 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -132,6 +132,7 @@ /* Required for 3DS display mode setting */ #if defined(_3DS) +#include <3ds.h> #include <3ds/services/cfgu.h> #include "gfx/common/ctr_defines.h" #endif