DirectX 12 Renderer (#5761)
* DirectX 12 Renderer (27 squashed commits) * Add missing SDL_hidapi.h of merge of SDL.vcxproj.filters * Fixed OpenWatcom build failure * Dynapi fix Co-authored-by: Ryan C. Gordon <icculus@icculus.org>main
parent
63e12cf601
commit
4082821822
|
@ -1596,6 +1596,7 @@ elseif(WINDOWS)
|
|||
|
||||
check_include_file(d3d9.h HAVE_D3D_H)
|
||||
check_include_file(d3d11_1.h HAVE_D3D11_H)
|
||||
check_include_file(d3d12.h HAVE_D3D12_H)
|
||||
check_include_file(ddraw.h HAVE_DDRAW_H)
|
||||
check_include_file(dsound.h HAVE_DSOUND_H)
|
||||
check_include_file(dinput.h HAVE_DINPUT_H)
|
||||
|
@ -1603,7 +1604,7 @@ elseif(WINDOWS)
|
|||
set(HAVE_DINPUT_H 0)
|
||||
endif()
|
||||
check_include_file(dxgi.h HAVE_DXGI_H)
|
||||
if(HAVE_D3D_H OR HAVE_D3D11_H OR HAVE_DDRAW_H OR HAVE_DSOUND_H OR HAVE_DINPUT_H)
|
||||
if(HAVE_D3D_H OR HAVE_D3D11_H OR HAVE_D3D12_H OR HAVE_DDRAW_H OR HAVE_DSOUND_H OR HAVE_DINPUT_H)
|
||||
set(HAVE_DIRECTX TRUE)
|
||||
if(NOT MINGW AND NOT USE_WINSDK_DIRECTX)
|
||||
# TODO: change $ENV{DXSDL_DIR} to get the path from the include checks
|
||||
|
@ -1697,6 +1698,10 @@ elseif(WINDOWS)
|
|||
set(SDL_VIDEO_RENDER_D3D11 1)
|
||||
set(HAVE_RENDER_D3D TRUE)
|
||||
endif()
|
||||
if(SDL_RENDER_D3D AND HAVE_D3D12_H AND NOT WINDOWS_STORE)
|
||||
set(SDL_VIDEO_RENDER_D3D12 1)
|
||||
set(HAVE_RENDER_D3D TRUE)
|
||||
endif()
|
||||
set(HAVE_SDL_VIDEO TRUE)
|
||||
endif()
|
||||
|
||||
|
|
|
@ -80,6 +80,7 @@ SRCS+= SDL_syspower.c
|
|||
SRCS+= SDL_d3dmath.c
|
||||
SRCS+= SDL_render_d3d.c SDL_shaders_d3d.c
|
||||
SRCS+= SDL_render_d3d11.c SDL_shaders_d3d11.c
|
||||
SRCS+= SDL_render_d3d12.c SDL_shaders_d3d12.c
|
||||
SRCS+= SDL_render_gl.c SDL_shaders_gl.c
|
||||
SRCS+= SDL_render_gles2.c SDL_shaders_gles2.c
|
||||
SRCS+= SDL_windowssensor.c
|
||||
|
@ -99,7 +100,7 @@ RCOBJS= $(RCSRCS:.rc=.res)
|
|||
.c: ./src;./src/dynapi;./src/audio;./src/cpuinfo;./src/events;./src/file;./src/haptic;./src/joystick;./src/power;./src/render;./src/render/software;./src/sensor;./src/stdlib;./src/thread;./src/timer;./src/video;./src/video/yuv2rgb;./src/atomic;./src/audio/disk;
|
||||
.c: ./src/haptic/dummy;./src/joystick/dummy;./src/joystick/virtual;./src/audio/dummy;./src/video/dummy;./src/sensor/dummy;
|
||||
.c: ./src/core/windows;./src/audio/winmm;./src/audio/directsound;./src/audio/wasapi;./src/loadso/windows;./src/filesystem/windows;./src/haptic/windows;./src/joystick/windows;./src/sensor/windows;./src/thread/windows;./src/timer/windows;./src/video/windows;
|
||||
.c: ./src/locale/;./src/locale/windows;./src/misc;./src/misc/windows;./src/power/windows;./src/joystick/hidapi;./src/hidapi;./src/render/direct3d;./src/render/direct3d11;./src/render/opengl;./src/render/opengles2
|
||||
.c: ./src/locale/;./src/locale/windows;./src/misc;./src/misc/windows;./src/power/windows;./src/joystick/hidapi;./src/hidapi;./src/render/direct3d;./src/render/direct3d11;./src/render/direct3d12;./src/render/opengl;./src/render/opengles2
|
||||
.rc: ./src/main/windows
|
||||
|
||||
all: $(DLLFILE) $(LIBFILE) $(TLIB) .symbolic
|
||||
|
|
|
@ -348,6 +348,7 @@
|
|||
<ClInclude Include="..\..\src\misc\SDL_sysurl.h" />
|
||||
<ClInclude Include="..\..\src\power\SDL_syspower.h" />
|
||||
<ClInclude Include="..\..\src\render\direct3d11\SDL_shaders_d3d11.h" />
|
||||
<ClInclude Include="..\..\src\render\direct3d12\SDL_shaders_d3d12.h" />
|
||||
<ClInclude Include="..\..\src\render\direct3d\SDL_shaders_d3d.h" />
|
||||
<ClInclude Include="..\..\src\render\opengles2\SDL_gles2funcs.h" />
|
||||
<ClInclude Include="..\..\src\render\opengles2\SDL_shaders_gles2.h" />
|
||||
|
@ -527,6 +528,8 @@
|
|||
<ClCompile Include="..\..\src\power\SDL_power.c" />
|
||||
<ClCompile Include="..\..\src\power\windows\SDL_syspower.c" />
|
||||
<ClCompile Include="..\..\src\render\direct3d11\SDL_shaders_d3d11.c" />
|
||||
<ClCompile Include="..\..\src\render\direct3d12\SDL_render_d3d12.c" />
|
||||
<ClCompile Include="..\..\src\render\direct3d12\SDL_shaders_d3d12.c" />
|
||||
<ClCompile Include="..\..\src\render\direct3d\SDL_render_d3d.c" />
|
||||
<ClCompile Include="..\..\src\render\direct3d11\SDL_render_d3d11.c" />
|
||||
<ClCompile Include="..\..\src\render\direct3d\SDL_shaders_d3d.c" />
|
||||
|
@ -617,4 +620,4 @@
|
|||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
</Project>
|
|
@ -169,6 +169,9 @@
|
|||
<Filter Include="video\khronos\vulkan">
|
||||
<UniqueIdentifier>{4755f3a6-49ac-46d6-86be-21f5c21f2197}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="render\direct3d12">
|
||||
<UniqueIdentifier>{f48c2b17-1bee-4fec-a7c8-24cf619abe08}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\include\begin_code.h">
|
||||
|
@ -829,6 +832,9 @@
|
|||
<ClInclude Include="..\..\src\SDL_hints_c.h" />
|
||||
<ClInclude Include="..\..\src\SDL_internal.h" />
|
||||
<ClInclude Include="..\..\src\SDL_log_c.h" />
|
||||
<ClInclude Include="..\..\src\render\direct3d12\SDL_shaders_d3d12.h">
|
||||
<Filter>render\direct3d12</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\src\audio\wasapi\SDL_wasapi.c" />
|
||||
|
@ -1326,8 +1332,14 @@
|
|||
<ClCompile Include="..\..\src\power\windows\SDL_syspower.c">
|
||||
<Filter>power\windows</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\render\direct3d12\SDL_render_d3d12.c">
|
||||
<Filter>render\direct3d12</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\render\direct3d12\SDL_shaders_d3d12.c">
|
||||
<Filter>render\direct3d12</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="..\..\src\main\windows\version.rc" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
</Project>
|
|
@ -3264,6 +3264,7 @@ CheckDIRECTX()
|
|||
if test x$enable_directx = xyes; then
|
||||
AC_CHECK_HEADER(d3d9.h, have_d3d=yes)
|
||||
AC_CHECK_HEADER(d3d11_1.h, have_d3d11=yes)
|
||||
AC_CHECK_HEADER(d3d12.h, have_d3d12=yes)
|
||||
AC_CHECK_HEADER(ddraw.h, have_ddraw=yes)
|
||||
AC_CHECK_HEADER(dsound.h, have_dsound=yes)
|
||||
AC_CHECK_HEADER(dinput.h, have_dinput=yes)
|
||||
|
@ -3991,6 +3992,10 @@ case "$host" in
|
|||
AC_DEFINE(SDL_VIDEO_RENDER_D3D11, 1, [ ])
|
||||
SUMMARY_video="${SUMMARY_video} d3d11"
|
||||
fi
|
||||
if test x$enable_render_d3d = xyes -a x$have_d3d12 = xyes; then
|
||||
AC_DEFINE(SDL_VIDEO_RENDER_D3D12, 1, [ ])
|
||||
SUMMARY_video="${SUMMARY_video} d3d12"
|
||||
fi
|
||||
fi
|
||||
# Set up files for the audio library
|
||||
if test x$enable_audio = xyes; then
|
||||
|
|
|
@ -243,6 +243,7 @@
|
|||
|
||||
#cmakedefine HAVE_D3D_H @HAVE_D3D_H@
|
||||
#cmakedefine HAVE_D3D11_H @HAVE_D3D11_H@
|
||||
#cmakedefine HAVE_D3D12_H @HAVE_D3D12_H@
|
||||
#cmakedefine HAVE_DDRAW_H @HAVE_DDRAW_H@
|
||||
#cmakedefine HAVE_DSOUND_H @HAVE_DSOUND_H@
|
||||
#cmakedefine HAVE_DINPUT_H @HAVE_DINPUT_H@
|
||||
|
|
|
@ -413,6 +413,7 @@
|
|||
|
||||
#undef SDL_VIDEO_RENDER_D3D
|
||||
#undef SDL_VIDEO_RENDER_D3D11
|
||||
#undef SDL_VIDEO_RENDER_D3D12
|
||||
#undef SDL_VIDEO_RENDER_OGL
|
||||
#undef SDL_VIDEO_RENDER_OGL_ES
|
||||
#undef SDL_VIDEO_RENDER_OGL_ES2
|
||||
|
|
|
@ -38,6 +38,18 @@
|
|||
#include <winsdkver.h>
|
||||
#endif
|
||||
|
||||
/* sdkddkver.h defines more specific SDK version numbers. This is needed because older versions of the
|
||||
* Windows 10 SDK have broken declarations for the C API for DirectX 12. */
|
||||
#if !defined(HAVE_SDKDDKVER_H) && defined(__has_include)
|
||||
#if __has_include(<sdkddkver.h>)
|
||||
#define HAVE_SDKDDKVER_H 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SDKDDKVER_H
|
||||
#include <sdkddkver.h>
|
||||
#endif
|
||||
|
||||
/* This is a set of defines to configure the SDL features */
|
||||
|
||||
#if !defined(_STDINT_H_) && (!defined(HAVE_STDINT_H) || !_HAVE_STDINT_H)
|
||||
|
@ -107,6 +119,9 @@ typedef unsigned int uintptr_t;
|
|||
#define HAVE_D3D11_H 1
|
||||
#define HAVE_ROAPI_H 1
|
||||
#endif
|
||||
#if defined(WDK_NTDDI_VERSION) && WDK_NTDDI_VERSION > 0x0A000008 /* 10.0.19041.0 */
|
||||
#define HAVE_D3D12_H 1
|
||||
#endif
|
||||
#define HAVE_MMDEVICEAPI_H 1
|
||||
#define HAVE_AUDIOCLIENT_H 1
|
||||
#define HAVE_TPCSHRD_H 1
|
||||
|
@ -295,6 +310,9 @@ typedef unsigned int uintptr_t;
|
|||
#if !defined(SDL_VIDEO_RENDER_D3D11) && defined(HAVE_D3D11_H)
|
||||
#define SDL_VIDEO_RENDER_D3D11 1
|
||||
#endif
|
||||
#if !defined(SDL_VIDEO_RENDER_D3D12) && defined(HAVE_D3D12_H)
|
||||
#define SDL_VIDEO_RENDER_D3D12 1
|
||||
#endif
|
||||
|
||||
/* Enable OpenGL support */
|
||||
#ifndef SDL_VIDEO_OPENGL
|
||||
|
|
|
@ -250,6 +250,9 @@ typedef unsigned int uintptr_t;
|
|||
/* Enable appropriate renderer(s) */
|
||||
#define SDL_VIDEO_RENDER_D3D11 1
|
||||
|
||||
/* Disable D3D12 as it's not implemented for WinRT */
|
||||
#define SDL_VIDEO_RENDER_D3D12 0
|
||||
|
||||
#if SDL_VIDEO_OPENGL_ES2
|
||||
#define SDL_VIDEO_RENDER_OGL_ES2 1
|
||||
#endif
|
||||
|
|
|
@ -1200,6 +1200,8 @@ extern "C" {
|
|||
*
|
||||
* This variable is case insensitive and can be set to the following values:
|
||||
* "direct3d"
|
||||
* "direct3d11"
|
||||
* "direct3d12"
|
||||
* "opengl"
|
||||
* "opengles2"
|
||||
* "opengles"
|
||||
|
|
|
@ -102,6 +102,22 @@ typedef struct ID3D11Device ID3D11Device;
|
|||
*/
|
||||
extern DECLSPEC ID3D11Device* SDLCALL SDL_RenderGetD3D11Device(SDL_Renderer * renderer);
|
||||
|
||||
typedef struct ID3D12Device ID3D12Device;
|
||||
|
||||
/**
|
||||
* Get the D3D12 device associated with a renderer.
|
||||
*
|
||||
* Once you are done using the device, you should release it to avoid a
|
||||
* resource leak.
|
||||
*
|
||||
* \param renderer the renderer from which to get the associated D3D12 device
|
||||
* \returns the D3D12 device associated with given renderer or NULL if it is
|
||||
* not a D3D12 renderer; call SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.23.
|
||||
*/
|
||||
extern DECLSPEC ID3D12Device* SDLCALL SDL_RenderGetD3D12Device(SDL_Renderer* renderer);
|
||||
|
||||
/**
|
||||
* Get the DXGI Adapter and Output indices for the specified display index.
|
||||
*
|
||||
|
|
|
@ -33,7 +33,11 @@
|
|||
#undef WINVER
|
||||
#define WINVER 0x0501
|
||||
#undef _WIN32_WINNT
|
||||
#if !defined(SDL_VIDEO_RENDER_D3D12)
|
||||
#define _WIN32_WINNT 0x501 /* Need 0x410 for AlphaBlend() and 0x500 for EnumDisplayDevices(), 0x501 for raw input */
|
||||
#else
|
||||
#define _WIN32_WINNT 0xA00 /* For D3D12, 0xA00 is required */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <windows.h>
|
||||
|
|
|
@ -847,3 +847,4 @@
|
|||
++'_SDL_GUIDFromString'.'SDL2.dll'.'SDL_GUIDFromString'
|
||||
++'_SDL_HasLSX'.'SDL2.dll'.'SDL_HasLSX'
|
||||
++'_SDL_HasLASX'.'SDL2.dll'.'SDL_HasLASX'
|
||||
++'_SDL_RenderGetD3D12Device'.'SDL2.dll'.'SDL_RenderGetD3D12Device'
|
||||
|
|
|
@ -873,3 +873,4 @@
|
|||
#define SDL_GUIDFromString SDL_GUIDFromString_REAL
|
||||
#define SDL_HasLSX SDL_HasLSX_REAL
|
||||
#define SDL_HasLASX SDL_HasLASX_REAL
|
||||
#define SDL_RenderGetD3D12Device SDL_RenderGetD3D12Device_REAL
|
||||
|
|
|
@ -948,3 +948,6 @@ SDL_DYNAPI_PROC(void,SDL_GUIDToString,(SDL_GUID a, char *b, int c),(a,b,c),)
|
|||
SDL_DYNAPI_PROC(SDL_GUID,SDL_GUIDFromString,(const char *a),(a),return)
|
||||
SDL_DYNAPI_PROC(SDL_bool,SDL_HasLSX,(void),(),return)
|
||||
SDL_DYNAPI_PROC(SDL_bool,SDL_HasLASX,(void),(),return)
|
||||
#ifdef __WIN32__
|
||||
SDL_DYNAPI_PROC(ID3D12Device*,SDL_RenderGetD3D12Device,(SDL_Renderer *a),(a),return)
|
||||
#endif
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
*/
|
||||
#include "../SDL_internal.h"
|
||||
|
||||
#if (SDL_VIDEO_RENDER_D3D || SDL_VIDEO_RENDER_D3D11) && !SDL_RENDER_DISABLED
|
||||
#if (SDL_VIDEO_RENDER_D3D || SDL_VIDEO_RENDER_D3D11 || SDL_VIDEO_RENDER_D3D12) && !SDL_RENDER_DISABLED
|
||||
#include "SDL_stdinc.h"
|
||||
|
||||
#include "SDL_d3dmath.h"
|
||||
|
@ -131,6 +131,6 @@ Float4X4 MatrixRotationZ(float r)
|
|||
|
||||
}
|
||||
|
||||
#endif /* (SDL_VIDEO_RENDER_D3D || SDL_VIDEO_RENDER_D3D11) && !SDL_RENDER_DISABLED */
|
||||
#endif /* (SDL_VIDEO_RENDER_D3D || SDL_VIDEO_RENDER_D3D11 || SDL_VIDEO_RENDER_D3D12) && !SDL_RENDER_DISABLED */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
*/
|
||||
#include "../SDL_internal.h"
|
||||
|
||||
#if (SDL_VIDEO_RENDER_D3D || SDL_VIDEO_RENDER_D3D11) && !SDL_RENDER_DISABLED
|
||||
#if (SDL_VIDEO_RENDER_D3D || SDL_VIDEO_RENDER_D3D11 || SDL_VIDEO_RENDER_D3D12) && !SDL_RENDER_DISABLED
|
||||
|
||||
/* Direct3D matrix math functions */
|
||||
|
||||
|
@ -67,6 +67,6 @@ Float4X4 MatrixRotationX(float r);
|
|||
Float4X4 MatrixRotationY(float r);
|
||||
Float4X4 MatrixRotationZ(float r);
|
||||
|
||||
#endif /* (SDL_VIDEO_RENDER_D3D || SDL_VIDEO_RENDER_D3D11) && !SDL_RENDER_DISABLED */
|
||||
#endif /* (SDL_VIDEO_RENDER_D3D || SDL_VIDEO_RENDER_D3D11 || SDL_VIDEO_RENDER_D3D12) && !SDL_RENDER_DISABLED */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
@ -96,6 +96,9 @@ static const SDL_RenderDriver *render_drivers[] = {
|
|||
#if SDL_VIDEO_RENDER_D3D11
|
||||
&D3D11_RenderDriver,
|
||||
#endif
|
||||
#if SDL_VIDEO_RENDER_D3D12
|
||||
&D3D12_RenderDriver,
|
||||
#endif
|
||||
#if SDL_VIDEO_RENDER_METAL
|
||||
&METAL_RenderDriver,
|
||||
#endif
|
||||
|
|
|
@ -283,6 +283,7 @@ struct SDL_RenderDriver
|
|||
/* Not all of these are available in a given build. Use #ifdefs, etc. */
|
||||
extern SDL_RenderDriver D3D_RenderDriver;
|
||||
extern SDL_RenderDriver D3D11_RenderDriver;
|
||||
extern SDL_RenderDriver D3D12_RenderDriver;
|
||||
extern SDL_RenderDriver GL_RenderDriver;
|
||||
extern SDL_RenderDriver GLES2_RenderDriver;
|
||||
extern SDL_RenderDriver GLES_RenderDriver;
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
/* D3D12 shader implementation */
|
||||
|
||||
typedef enum {
|
||||
SHADER_SOLID,
|
||||
SHADER_RGB,
|
||||
#if SDL_HAVE_YUV
|
||||
SHADER_YUV_JPEG,
|
||||
SHADER_YUV_BT601,
|
||||
SHADER_YUV_BT709,
|
||||
SHADER_NV12_JPEG,
|
||||
SHADER_NV12_BT601,
|
||||
SHADER_NV12_BT709,
|
||||
SHADER_NV21_JPEG,
|
||||
SHADER_NV21_BT601,
|
||||
SHADER_NV21_BT709,
|
||||
#endif
|
||||
NUM_SHADERS
|
||||
} D3D12_Shader;
|
||||
|
||||
typedef enum {
|
||||
ROOTSIG_COLOR,
|
||||
ROOTSIG_TEXTURE,
|
||||
#if SDL_HAVE_YUV
|
||||
ROOTSIG_YUV,
|
||||
ROOTSIG_NV,
|
||||
#endif
|
||||
NUM_ROOTSIGS
|
||||
} D3D12_RootSignature;
|
||||
|
||||
extern void D3D12_GetVertexShader(D3D12_Shader shader, D3D12_SHADER_BYTECODE *outBytecode);
|
||||
extern void D3D12_GetPixelShader(D3D12_Shader shader, D3D12_SHADER_BYTECODE *outBytecode);
|
||||
extern D3D12_RootSignature D3D12_GetRootSignatureType(D3D12_Shader shader);
|
||||
extern void D3D12_GetRootSignatureData(D3D12_RootSignature rootSig, D3D12_SHADER_BYTECODE* outBytecode);
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
Loading…
Reference in New Issue