mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-04-01 05:11:54 +00:00
Make Xbox GDK code public (and fix some GDK code rot) (#8844)
This commit is contained in:
@@ -224,3 +224,12 @@ Sint32 JNI_OnLoad(void *vm, void *reserved)
|
||||
return -1; /* JNI_ERR */
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(__XBOXONE__) || defined(__XBOXSERIES__)
|
||||
char *SDL_GetUserFolder(SDL_Folder folder)
|
||||
{
|
||||
(void)folder;
|
||||
SDL_Unsupported();
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "../../SDL_internal.h"
|
||||
#include "SDL_internal.h"
|
||||
|
||||
#ifdef SDL_FILESYSTEM_XBOX
|
||||
|
||||
@@ -26,9 +26,9 @@
|
||||
/* System dependent filesystem routines */
|
||||
|
||||
#include "../../core/windows/SDL_windows.h"
|
||||
#include "SDL_hints.h"
|
||||
#include "SDL_system.h"
|
||||
#include "SDL_filesystem.h"
|
||||
#include <SDL3/SDL_hints.h>
|
||||
#include <SDL3/SDL_system.h>
|
||||
#include <SDL3/SDL_filesystem.h>
|
||||
#include <XGameSaveFiles.h>
|
||||
|
||||
char *
|
||||
|
||||
@@ -1435,7 +1435,7 @@ static void D3D12_FreeSRVIndex(SDL_Renderer *renderer, SIZE_T index)
|
||||
|
||||
static int GetTextureProperty(SDL_PropertiesID props, const char *name, ID3D12Resource **texture)
|
||||
{
|
||||
IUnknown *unknown = SDL_GetProperty(props, name, NULL);
|
||||
IUnknown *unknown = (IUnknown*)SDL_GetProperty(props, name, NULL);
|
||||
if (unknown) {
|
||||
HRESULT result = D3D_CALL(unknown, QueryInterface, D3D_GUID(SDL_IID_ID3D12Resource), (void **)texture);
|
||||
if (FAILED(result)) {
|
||||
|
||||
@@ -19,9 +19,156 @@
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#include "SDL_internal.h"
|
||||
#if defined(SDL_VIDEO_RENDER_D3D12) && !defined(SDL_RENDER_DISABLED) && (defined(__XBOXONE__) || defined(__XBOXSERIES__))
|
||||
#include "../../SDL_internal.h"
|
||||
#if SDL_VIDEO_RENDER_D3D12 && !SDL_RENDER_DISABLED && (defined(__XBOXONE__) || defined(__XBOXSERIES__))
|
||||
#include "SDL_render_d3d12_xbox.h"
|
||||
#include "../../core/windows/SDL_windows.h"
|
||||
#include <XGameRuntime.h>
|
||||
|
||||
#if defined(_MSC_VER) && !defined(__clang__)
|
||||
#define SDL_COMPOSE_ERROR(str) __FUNCTION__ ", " str
|
||||
#else
|
||||
#define SDL_COMPOSE_ERROR(str) SDL_STRINGIFY_ARG(__FUNCTION__) ", " str
|
||||
#endif
|
||||
|
||||
static const GUID SDL_IID_ID3D12Device1 = { 0x77acce80, 0x638e, 0x4e65, { 0x88, 0x95, 0xc1, 0xf2, 0x33, 0x86, 0x86, 0x3e } };
|
||||
static const GUID SDL_IID_ID3D12Resource = { 0x696442be, 0xa72e, 0x4059, { 0xbc, 0x79, 0x5b, 0x5c, 0x98, 0x04, 0x0f, 0xad } };
|
||||
static const GUID SDL_IID_IDXGIDevice1 = { 0x77db970f, 0x6276, 0x48ba, { 0xba, 0x28, 0x07, 0x01, 0x43, 0xb4, 0x39, 0x2c } };
|
||||
|
||||
extern "C" HRESULT
|
||||
D3D12_XBOX_CreateDevice(ID3D12Device **device, SDL_bool createDebug)
|
||||
{
|
||||
HRESULT result;
|
||||
D3D12XBOX_CREATE_DEVICE_PARAMETERS params;
|
||||
IDXGIDevice1 *dxgiDevice;
|
||||
IDXGIAdapter *dxgiAdapter;
|
||||
IDXGIOutput *dxgiOutput;
|
||||
SDL_zero(params);
|
||||
|
||||
params.Version = D3D12_SDK_VERSION;
|
||||
params.ProcessDebugFlags = createDebug ? D3D12_PROCESS_DEBUG_FLAG_DEBUG_LAYER_ENABLED : D3D12XBOX_PROCESS_DEBUG_FLAG_NONE;
|
||||
params.GraphicsCommandQueueRingSizeBytes = D3D12XBOX_DEFAULT_SIZE_BYTES;
|
||||
params.GraphicsScratchMemorySizeBytes = D3D12XBOX_DEFAULT_SIZE_BYTES;
|
||||
params.ComputeScratchMemorySizeBytes = D3D12XBOX_DEFAULT_SIZE_BYTES;
|
||||
|
||||
result = D3D12XboxCreateDevice(NULL, ¶ms, SDL_IID_ID3D12Device1, (void **) device);
|
||||
if (FAILED(result)) {
|
||||
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("[xbox] D3D12XboxCreateDevice"), result);
|
||||
goto done;
|
||||
}
|
||||
|
||||
result = (*device)->QueryInterface(SDL_IID_IDXGIDevice1, (void **) &dxgiDevice);
|
||||
if (FAILED(result)) {
|
||||
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("[xbox] ID3D12Device to IDXGIDevice1"), result);
|
||||
goto done;
|
||||
}
|
||||
|
||||
result = dxgiDevice->GetAdapter(&dxgiAdapter);
|
||||
if (FAILED(result)) {
|
||||
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("[xbox] dxgiDevice->GetAdapter"), result);
|
||||
goto done;
|
||||
}
|
||||
|
||||
result = dxgiAdapter->EnumOutputs(0, &dxgiOutput);
|
||||
if (FAILED(result)) {
|
||||
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("[xbox] dxgiAdapter->EnumOutputs"), result);
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* Set frame interval */
|
||||
result = (*device)->SetFrameIntervalX(dxgiOutput, D3D12XBOX_FRAME_INTERVAL_60_HZ, 1, D3D12XBOX_FRAME_INTERVAL_FLAG_NONE);
|
||||
if (FAILED(result)) {
|
||||
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("[xbox] SetFrameIntervalX"), result);
|
||||
goto done;
|
||||
}
|
||||
|
||||
result = (*device)->ScheduleFrameEventX(D3D12XBOX_FRAME_EVENT_ORIGIN, 0, NULL, D3D12XBOX_SCHEDULE_FRAME_EVENT_FLAG_NONE);
|
||||
if (FAILED(result)) {
|
||||
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("[xbox] ScheduleFrameEventX"), result);
|
||||
goto done;
|
||||
}
|
||||
|
||||
done:
|
||||
return result;
|
||||
}
|
||||
|
||||
extern "C" HRESULT
|
||||
D3D12_XBOX_CreateBackBufferTarget(ID3D12Device1 *device, int width, int height, void **resource)
|
||||
{
|
||||
|
||||
D3D12_HEAP_PROPERTIES heapProps;
|
||||
D3D12_RESOURCE_DESC resourceDesc;
|
||||
|
||||
SDL_zero(heapProps);
|
||||
heapProps.Type = D3D12_HEAP_TYPE_DEFAULT;
|
||||
heapProps.CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_UNKNOWN;
|
||||
heapProps.MemoryPoolPreference = D3D12_MEMORY_POOL_UNKNOWN;
|
||||
heapProps.CreationNodeMask = 1;
|
||||
heapProps.VisibleNodeMask = 1;
|
||||
|
||||
SDL_zero(resourceDesc);
|
||||
resourceDesc.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D;
|
||||
resourceDesc.Alignment = 0;
|
||||
resourceDesc.Width = width;
|
||||
resourceDesc.Height = height;
|
||||
resourceDesc.DepthOrArraySize = 1;
|
||||
resourceDesc.MipLevels = 1;
|
||||
resourceDesc.Format = DXGI_FORMAT_B8G8R8A8_UNORM;
|
||||
resourceDesc.SampleDesc.Count = 1;
|
||||
resourceDesc.SampleDesc.Quality = 0;
|
||||
resourceDesc.Layout = D3D12_TEXTURE_LAYOUT_UNKNOWN;
|
||||
resourceDesc.Flags = D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET;
|
||||
|
||||
return device->CreateCommittedResource(&heapProps,
|
||||
D3D12_HEAP_FLAG_ALLOW_DISPLAY,
|
||||
&resourceDesc,
|
||||
D3D12_RESOURCE_STATE_PRESENT,
|
||||
NULL,
|
||||
SDL_IID_ID3D12Resource,
|
||||
resource
|
||||
);
|
||||
}
|
||||
|
||||
extern "C" HRESULT
|
||||
D3D12_XBOX_StartFrame(ID3D12Device1 *device, UINT64 *outToken)
|
||||
{
|
||||
*outToken = D3D12XBOX_FRAME_PIPELINE_TOKEN_NULL;
|
||||
return device->WaitFrameEventX(D3D12XBOX_FRAME_EVENT_ORIGIN, INFINITE, NULL, D3D12XBOX_WAIT_FRAME_EVENT_FLAG_NONE, outToken);
|
||||
}
|
||||
|
||||
extern "C" HRESULT
|
||||
D3D12_XBOX_PresentFrame(ID3D12CommandQueue *commandQueue, UINT64 token, ID3D12Resource *renderTarget)
|
||||
{
|
||||
D3D12XBOX_PRESENT_PLANE_PARAMETERS planeParameters;
|
||||
SDL_zero(planeParameters);
|
||||
planeParameters.Token = token;
|
||||
planeParameters.ResourceCount = 1;
|
||||
planeParameters.ppResources = &renderTarget;
|
||||
return commandQueue->PresentX(1, &planeParameters, NULL);
|
||||
}
|
||||
|
||||
extern "C" void
|
||||
D3D12_XBOX_GetResolution(Uint32 *width, Uint32 *height)
|
||||
{
|
||||
switch (XSystemGetDeviceType()) {
|
||||
case XSystemDeviceType::XboxScarlettLockhart:
|
||||
*width = 2560;
|
||||
*height = 1440;
|
||||
break;
|
||||
|
||||
case XSystemDeviceType::XboxOneX:
|
||||
case XSystemDeviceType::XboxScarlettAnaconda:
|
||||
case XSystemDeviceType::XboxOneXDevkit:
|
||||
case XSystemDeviceType::XboxScarlettDevkit:
|
||||
*width = 3840;
|
||||
*height = 2160;
|
||||
break;
|
||||
|
||||
default:
|
||||
*width = 1920;
|
||||
*height = 1080;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#error "This is a placeholder Xbox file, as the real one is under NDA. See README-gdk.md for more info."
|
||||
#endif
|
||||
|
||||
@@ -19,4 +19,31 @@
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#error "This is a placeholder Xbox file, as the real one is under NDA. See README-gdk.md for more info."
|
||||
#ifndef SDL_render_d3d12_xbox_h_
|
||||
#define SDL_render_d3d12_xbox_h_
|
||||
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
#if defined(__XBOXONE__)
|
||||
#include <d3d12_x.h>
|
||||
#else /* __XBOXSERIES__ */
|
||||
#include <d3d12_xs.h>
|
||||
#endif
|
||||
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern HRESULT D3D12_XBOX_CreateDevice(ID3D12Device **device, SDL_bool createDebug);
|
||||
extern HRESULT D3D12_XBOX_CreateBackBufferTarget(ID3D12Device1 *device, int width, int height, void **resource);
|
||||
extern HRESULT D3D12_XBOX_StartFrame(ID3D12Device1 *device, UINT64 *outToken);
|
||||
extern HRESULT D3D12_XBOX_PresentFrame(ID3D12CommandQueue *commandQueue, UINT64 token, ID3D12Resource *renderTarget);
|
||||
extern void D3D12_XBOX_GetResolution(Uint32 *width, Uint32 *height);
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -18,10 +18,127 @@
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "SDL_internal.h"
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
#if defined(SDL_VIDEO_RENDER_D3D12) && !defined(SDL_RENDER_DISABLED) && defined(__XBOXONE__)
|
||||
#if SDL_VIDEO_RENDER_D3D12 && !SDL_RENDER_DISABLED && defined(__XBOXONE__)
|
||||
|
||||
#error "This is a placeholder Xbox file, as the real one is under NDA. See README-gdk.md for more info."
|
||||
#include <SDL3/SDL_stdinc.h>
|
||||
|
||||
#include "../../core/windows/SDL_windows.h"
|
||||
#include <d3d12_x.h>
|
||||
|
||||
#include "SDL_shaders_d3d12.h"
|
||||
|
||||
#define SDL_COMPOSE_ERROR(str) SDL_STRINGIFY_ARG(__FUNCTION__) ", " str
|
||||
|
||||
/* Shader blob headers are generated with a pre-build step using buildshaders.bat */
|
||||
#include "../VisualC-GDK/shaders/D3D12_PixelShader_Colors_One.h"
|
||||
#include "../VisualC-GDK/shaders/D3D12_PixelShader_NV12_BT601_One.h"
|
||||
#include "../VisualC-GDK/shaders/D3D12_PixelShader_NV12_BT709_One.h"
|
||||
#include "../VisualC-GDK/shaders/D3D12_PixelShader_NV12_JPEG_One.h"
|
||||
#include "../VisualC-GDK/shaders/D3D12_PixelShader_NV21_BT601_One.h"
|
||||
#include "../VisualC-GDK/shaders/D3D12_PixelShader_NV21_BT709_One.h"
|
||||
#include "../VisualC-GDK/shaders/D3D12_PixelShader_NV21_JPEG_One.h"
|
||||
#include "../VisualC-GDK/shaders/D3D12_PixelShader_Textures_One.h"
|
||||
#include "../VisualC-GDK/shaders/D3D12_PixelShader_YUV_BT601_One.h"
|
||||
#include "../VisualC-GDK/shaders/D3D12_PixelShader_YUV_BT709_One.h"
|
||||
#include "../VisualC-GDK/shaders/D3D12_PixelShader_YUV_JPEG_One.h"
|
||||
|
||||
#include "../VisualC-GDK/shaders/D3D12_VertexShader_Color_One.h"
|
||||
#include "../VisualC-GDK/shaders/D3D12_VertexShader_NV_One.h"
|
||||
#include "../VisualC-GDK/shaders/D3D12_VertexShader_Texture_One.h"
|
||||
#include "../VisualC-GDK/shaders/D3D12_VertexShader_YUV_One.h"
|
||||
|
||||
#include "../VisualC-GDK/shaders/D3D12_RootSig_Color_One.h"
|
||||
#include "../VisualC-GDK/shaders/D3D12_RootSig_NV_One.h"
|
||||
#include "../VisualC-GDK/shaders/D3D12_RootSig_Texture_One.h"
|
||||
#include "../VisualC-GDK/shaders/D3D12_RootSig_YUV_One.h"
|
||||
|
||||
static struct
|
||||
{
|
||||
const void *ps_shader_data;
|
||||
SIZE_T ps_shader_size;
|
||||
const void *vs_shader_data;
|
||||
SIZE_T vs_shader_size;
|
||||
D3D12_RootSignature root_sig;
|
||||
} D3D12_shaders[NUM_SHADERS] = {
|
||||
{ D3D12_PixelShader_Colors, sizeof(D3D12_PixelShader_Colors),
|
||||
D3D12_VertexShader_Color, sizeof(D3D12_VertexShader_Color),
|
||||
ROOTSIG_COLOR },
|
||||
{ D3D12_PixelShader_Textures, sizeof(D3D12_PixelShader_Textures),
|
||||
D3D12_VertexShader_Texture, sizeof(D3D12_VertexShader_Texture),
|
||||
ROOTSIG_TEXTURE },
|
||||
#if SDL_HAVE_YUV
|
||||
{ D3D12_PixelShader_YUV_JPEG, sizeof(D3D12_PixelShader_YUV_JPEG),
|
||||
D3D12_VertexShader_YUV, sizeof(D3D12_VertexShader_YUV),
|
||||
ROOTSIG_YUV },
|
||||
{ D3D12_PixelShader_YUV_BT601, sizeof(D3D12_PixelShader_YUV_BT601),
|
||||
D3D12_VertexShader_YUV, sizeof(D3D12_VertexShader_YUV),
|
||||
ROOTSIG_YUV },
|
||||
{ D3D12_PixelShader_YUV_BT709, sizeof(D3D12_PixelShader_YUV_BT709),
|
||||
D3D12_VertexShader_YUV, sizeof(D3D12_VertexShader_YUV),
|
||||
ROOTSIG_YUV },
|
||||
{ D3D12_PixelShader_NV12_JPEG, sizeof(D3D12_PixelShader_NV12_JPEG),
|
||||
D3D12_VertexShader_NV, sizeof(D3D12_VertexShader_NV),
|
||||
ROOTSIG_NV },
|
||||
{ D3D12_PixelShader_NV12_BT601, sizeof(D3D12_PixelShader_NV12_BT601),
|
||||
D3D12_VertexShader_NV, sizeof(D3D12_VertexShader_NV),
|
||||
ROOTSIG_NV },
|
||||
{ D3D12_PixelShader_NV12_BT709, sizeof(D3D12_PixelShader_NV12_BT709),
|
||||
D3D12_VertexShader_NV, sizeof(D3D12_VertexShader_NV),
|
||||
ROOTSIG_NV },
|
||||
{ D3D12_PixelShader_NV21_JPEG, sizeof(D3D12_PixelShader_NV21_JPEG),
|
||||
D3D12_VertexShader_NV, sizeof(D3D12_VertexShader_NV),
|
||||
ROOTSIG_NV },
|
||||
{ D3D12_PixelShader_NV21_BT601, sizeof(D3D12_PixelShader_NV21_BT601),
|
||||
D3D12_VertexShader_NV, sizeof(D3D12_VertexShader_NV),
|
||||
ROOTSIG_NV },
|
||||
{ D3D12_PixelShader_NV21_BT709, sizeof(D3D12_PixelShader_NV21_BT709),
|
||||
D3D12_VertexShader_NV, sizeof(D3D12_VertexShader_NV),
|
||||
ROOTSIG_NV },
|
||||
#endif
|
||||
};
|
||||
|
||||
static struct
|
||||
{
|
||||
const void *rs_shader_data;
|
||||
SIZE_T rs_shader_size;
|
||||
} D3D12_rootsigs[NUM_ROOTSIGS] = {
|
||||
{ D3D12_RootSig_Color, sizeof(D3D12_RootSig_Color) },
|
||||
{ D3D12_RootSig_Texture, sizeof(D3D12_RootSig_Texture) },
|
||||
#if SDL_HAVE_YUV
|
||||
{ D3D12_RootSig_YUV, sizeof(D3D12_RootSig_YUV) },
|
||||
{ D3D12_RootSig_NV, sizeof(D3D12_RootSig_NV) },
|
||||
#endif
|
||||
};
|
||||
|
||||
extern "C" void
|
||||
D3D12_GetVertexShader(D3D12_Shader shader, D3D12_SHADER_BYTECODE *outBytecode)
|
||||
{
|
||||
outBytecode->pShaderBytecode = D3D12_shaders[shader].vs_shader_data;
|
||||
outBytecode->BytecodeLength = D3D12_shaders[shader].vs_shader_size;
|
||||
}
|
||||
|
||||
extern "C" void
|
||||
D3D12_GetPixelShader(D3D12_Shader shader, D3D12_SHADER_BYTECODE *outBytecode)
|
||||
{
|
||||
outBytecode->pShaderBytecode = D3D12_shaders[shader].ps_shader_data;
|
||||
outBytecode->BytecodeLength = D3D12_shaders[shader].ps_shader_size;
|
||||
}
|
||||
|
||||
extern "C" D3D12_RootSignature
|
||||
D3D12_GetRootSignatureType(D3D12_Shader shader)
|
||||
{
|
||||
return D3D12_shaders[shader].root_sig;
|
||||
}
|
||||
|
||||
extern "C" void
|
||||
D3D12_GetRootSignatureData(D3D12_RootSignature rootSig, D3D12_SHADER_BYTECODE *outBytecode)
|
||||
{
|
||||
outBytecode->pShaderBytecode = D3D12_rootsigs[rootSig].rs_shader_data;
|
||||
outBytecode->BytecodeLength = D3D12_rootsigs[rootSig].rs_shader_size;
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_RENDER_D3D12 && !SDL_RENDER_DISABLED && defined(__XBOXONE__) */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
||||
@@ -18,10 +18,127 @@
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "SDL_internal.h"
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
#if defined(SDL_VIDEO_RENDER_D3D12) && !defined(SDL_RENDER_DISABLED) && defined(__XBOXSERIES__)
|
||||
#if SDL_VIDEO_RENDER_D3D12 && !SDL_RENDER_DISABLED && defined(__XBOXSERIES__)
|
||||
|
||||
#error "This is a placeholder Xbox file, as the real one is under NDA. See README-gdk.md for more info."
|
||||
#include <SDL3/SDL_stdinc.h>
|
||||
|
||||
#include "../../core/windows/SDL_windows.h"
|
||||
#include <d3d12_xs.h>
|
||||
|
||||
#include "SDL_shaders_d3d12.h"
|
||||
|
||||
#define SDL_COMPOSE_ERROR(str) SDL_STRINGIFY_ARG(__FUNCTION__) ", " str
|
||||
|
||||
/* Shader blob headers are generated with a pre-build step using buildshaders.bat */
|
||||
#include "../VisualC-GDK/shaders/D3D12_PixelShader_Colors_Series.h"
|
||||
#include "../VisualC-GDK/shaders/D3D12_PixelShader_Textures_Series.h"
|
||||
#include "../VisualC-GDK/shaders/D3D12_PixelShader_NV12_BT601_Series.h"
|
||||
#include "../VisualC-GDK/shaders/D3D12_PixelShader_NV12_BT709_Series.h"
|
||||
#include "../VisualC-GDK/shaders/D3D12_PixelShader_NV12_JPEG_Series.h"
|
||||
#include "../VisualC-GDK/shaders/D3D12_PixelShader_NV21_BT601_Series.h"
|
||||
#include "../VisualC-GDK/shaders/D3D12_PixelShader_NV21_BT709_Series.h"
|
||||
#include "../VisualC-GDK/shaders/D3D12_PixelShader_NV21_JPEG_Series.h"
|
||||
#include "../VisualC-GDK/shaders/D3D12_PixelShader_YUV_BT601_Series.h"
|
||||
#include "../VisualC-GDK/shaders/D3D12_PixelShader_YUV_BT709_Series.h"
|
||||
#include "../VisualC-GDK/shaders/D3D12_PixelShader_YUV_JPEG_Series.h"
|
||||
|
||||
#include "../VisualC-GDK/shaders/D3D12_VertexShader_Color_Series.h"
|
||||
#include "../VisualC-GDK/shaders/D3D12_VertexShader_Texture_Series.h"
|
||||
#include "../VisualC-GDK/shaders/D3D12_VertexShader_NV_Series.h"
|
||||
#include "../VisualC-GDK/shaders/D3D12_VertexShader_YUV_Series.h"
|
||||
|
||||
#include "../VisualC-GDK/shaders/D3D12_RootSig_Color_Series.h"
|
||||
#include "../VisualC-GDK/shaders/D3D12_RootSig_Texture_Series.h"
|
||||
#include "../VisualC-GDK/shaders/D3D12_RootSig_YUV_Series.h"
|
||||
#include "../VisualC-GDK/shaders/D3D12_RootSig_NV_Series.h"
|
||||
|
||||
static struct
|
||||
{
|
||||
const void *ps_shader_data;
|
||||
SIZE_T ps_shader_size;
|
||||
const void *vs_shader_data;
|
||||
SIZE_T vs_shader_size;
|
||||
D3D12_RootSignature root_sig;
|
||||
} D3D12_shaders[NUM_SHADERS] = {
|
||||
{ D3D12_PixelShader_Colors, sizeof(D3D12_PixelShader_Colors),
|
||||
D3D12_VertexShader_Color, sizeof(D3D12_VertexShader_Color),
|
||||
ROOTSIG_COLOR },
|
||||
{ D3D12_PixelShader_Textures, sizeof(D3D12_PixelShader_Textures),
|
||||
D3D12_VertexShader_Texture, sizeof(D3D12_VertexShader_Texture),
|
||||
ROOTSIG_TEXTURE },
|
||||
#if SDL_HAVE_YUV
|
||||
{ D3D12_PixelShader_YUV_JPEG, sizeof(D3D12_PixelShader_YUV_JPEG),
|
||||
D3D12_VertexShader_YUV, sizeof(D3D12_VertexShader_YUV),
|
||||
ROOTSIG_YUV },
|
||||
{ D3D12_PixelShader_YUV_BT601, sizeof(D3D12_PixelShader_YUV_BT601),
|
||||
D3D12_VertexShader_YUV, sizeof(D3D12_VertexShader_YUV),
|
||||
ROOTSIG_YUV },
|
||||
{ D3D12_PixelShader_YUV_BT709, sizeof(D3D12_PixelShader_YUV_BT709),
|
||||
D3D12_VertexShader_YUV, sizeof(D3D12_VertexShader_YUV),
|
||||
ROOTSIG_YUV },
|
||||
{ D3D12_PixelShader_NV12_JPEG, sizeof(D3D12_PixelShader_NV12_JPEG),
|
||||
D3D12_VertexShader_NV, sizeof(D3D12_VertexShader_NV),
|
||||
ROOTSIG_NV },
|
||||
{ D3D12_PixelShader_NV12_BT601, sizeof(D3D12_PixelShader_NV12_BT601),
|
||||
D3D12_VertexShader_NV, sizeof(D3D12_VertexShader_NV),
|
||||
ROOTSIG_NV },
|
||||
{ D3D12_PixelShader_NV12_BT709, sizeof(D3D12_PixelShader_NV12_BT709),
|
||||
D3D12_VertexShader_NV, sizeof(D3D12_VertexShader_NV),
|
||||
ROOTSIG_NV },
|
||||
{ D3D12_PixelShader_NV21_JPEG, sizeof(D3D12_PixelShader_NV21_JPEG),
|
||||
D3D12_VertexShader_NV, sizeof(D3D12_VertexShader_NV),
|
||||
ROOTSIG_NV },
|
||||
{ D3D12_PixelShader_NV21_BT601, sizeof(D3D12_PixelShader_NV21_BT601),
|
||||
D3D12_VertexShader_NV, sizeof(D3D12_VertexShader_NV),
|
||||
ROOTSIG_NV },
|
||||
{ D3D12_PixelShader_NV21_BT709, sizeof(D3D12_PixelShader_NV21_BT709),
|
||||
D3D12_VertexShader_NV, sizeof(D3D12_VertexShader_NV),
|
||||
ROOTSIG_NV },
|
||||
#endif
|
||||
};
|
||||
|
||||
static struct
|
||||
{
|
||||
const void *rs_shader_data;
|
||||
SIZE_T rs_shader_size;
|
||||
} D3D12_rootsigs[NUM_ROOTSIGS] = {
|
||||
{ D3D12_RootSig_Color, sizeof(D3D12_RootSig_Color) },
|
||||
{ D3D12_RootSig_Texture, sizeof(D3D12_RootSig_Texture) },
|
||||
#if SDL_HAVE_YUV
|
||||
{ D3D12_RootSig_YUV, sizeof(D3D12_RootSig_YUV) },
|
||||
{ D3D12_RootSig_NV, sizeof(D3D12_RootSig_NV) },
|
||||
#endif
|
||||
};
|
||||
|
||||
extern "C" void
|
||||
D3D12_GetVertexShader(D3D12_Shader shader, D3D12_SHADER_BYTECODE *outBytecode)
|
||||
{
|
||||
outBytecode->pShaderBytecode = D3D12_shaders[shader].vs_shader_data;
|
||||
outBytecode->BytecodeLength = D3D12_shaders[shader].vs_shader_size;
|
||||
}
|
||||
|
||||
extern "C" void
|
||||
D3D12_GetPixelShader(D3D12_Shader shader, D3D12_SHADER_BYTECODE *outBytecode)
|
||||
{
|
||||
outBytecode->pShaderBytecode = D3D12_shaders[shader].ps_shader_data;
|
||||
outBytecode->BytecodeLength = D3D12_shaders[shader].ps_shader_size;
|
||||
}
|
||||
|
||||
extern "C" D3D12_RootSignature
|
||||
D3D12_GetRootSignatureType(D3D12_Shader shader)
|
||||
{
|
||||
return D3D12_shaders[shader].root_sig;
|
||||
}
|
||||
|
||||
extern "C" void
|
||||
D3D12_GetRootSignatureData(D3D12_RootSignature rootSig, D3D12_SHADER_BYTECODE *outBytecode)
|
||||
{
|
||||
outBytecode->pShaderBytecode = D3D12_rootsigs[rootSig].rs_shader_data;
|
||||
outBytecode->BytecodeLength = D3D12_rootsigs[rootSig].rs_shader_size;
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_RENDER_D3D12 && !SDL_RENDER_DISABLED && defined(__XBOXSERIES__) */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
||||
@@ -41,7 +41,7 @@ int SDL_Direct3D9GetAdapterIndex(SDL_DisplayID displayID)
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef SDL_GDK_TEXTINPUT
|
||||
#ifndef __GDK__
|
||||
|
||||
DECLSPEC int SDLCALL SDL_GDKGetTaskQueue(void *outTaskQueue);
|
||||
int SDL_GDKGetTaskQueue(void *outTaskQueue)
|
||||
@@ -81,3 +81,11 @@ void SDL_iPhoneSetEventPump(SDL_bool enabled)
|
||||
SDL_Unsupported();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(__XBOXONE__) || defined(__XBOXSERIES__)
|
||||
int SDL_Direct3D9GetAdapterIndex(SDL_DisplayID displayID)
|
||||
{
|
||||
(void)displayID;
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -169,9 +169,11 @@ static SDL_Scancode WindowsScanCodeToSDLScanCode(LPARAM lParam, WPARAM wParam)
|
||||
} else {
|
||||
Uint16 vkCode = LOWORD(wParam);
|
||||
|
||||
#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__)
|
||||
/* Windows may not report scan codes for some buttons (multimedia buttons etc).
|
||||
* Get scan code from the VK code.*/
|
||||
scanCode = LOWORD(MapVirtualKey(vkCode, MAPVK_VK_TO_VSC_EX));
|
||||
#endif /*!defined(__XBOXONE__) && !defined(__XBOXSERIES__)*/
|
||||
|
||||
/* Pause/Break key have a special scan code with 0xe1 prefix.
|
||||
* Use Pause scan code that is used in Win32. */
|
||||
@@ -515,8 +517,6 @@ WIN_KeyboardHookProc(int nCode, WPARAM wParam, LPARAM lParam)
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif /*!defined(__XBOXONE__) && !defined(__XBOXSERIES__)*/
|
||||
|
||||
static void WIN_HandleRawMouseInput(Uint64 timestamp, SDL_WindowData *data, RAWMOUSE *rawmouse)
|
||||
{
|
||||
SDL_MouseID mouseID;
|
||||
@@ -692,6 +692,7 @@ void WIN_PollRawMouseInput(void)
|
||||
data->last_rawinput_poll = now;
|
||||
}
|
||||
|
||||
#endif /*!defined(__XBOXONE__) && !defined(__XBOXSERIES__)*/
|
||||
|
||||
LRESULT CALLBACK
|
||||
WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
|
||||
@@ -264,7 +264,7 @@ int WIN_AdjustWindowRectForHWND(HWND hwnd, LPRECT lpRect, UINT frame_dpi)
|
||||
#endif
|
||||
|
||||
#if defined(__XBOXONE__) || defined(__XBOXSERIES__)
|
||||
AdjustWindowRectEx(&rect, style, menu, styleEx);
|
||||
AdjustWindowRectEx(lpRect, style, menu, styleEx);
|
||||
#else
|
||||
if (WIN_IsPerMonitorV2DPIAware(videodevice)) {
|
||||
/* With per-monitor v2, the window border/titlebar size depend on the DPI, so we need to call AdjustWindowRectExForDpi instead of AdjustWindowRectEx. */
|
||||
@@ -490,6 +490,7 @@ static int SetupWindowData(SDL_VideoDevice *_this, SDL_Window *window, HWND hwnd
|
||||
|
||||
data->initializing = SDL_FALSE;
|
||||
|
||||
#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__)
|
||||
if (window->flags & SDL_WINDOW_EXTERNAL) {
|
||||
/* Query the title from the existing window */
|
||||
LPTSTR title;
|
||||
@@ -510,6 +511,7 @@ static int SetupWindowData(SDL_VideoDevice *_this, SDL_Window *window, HWND hwnd
|
||||
SDL_small_free(title, isstack);
|
||||
}
|
||||
}
|
||||
#endif /*!defined(__XBOXONE__) && !defined(__XBOXSERIES__)*/
|
||||
|
||||
SDL_PropertiesID props = SDL_GetWindowProperties(window);
|
||||
SDL_SetProperty(props, SDL_PROPERTY_WINDOW_WIN32_HWND_POINTER, data->hwnd);
|
||||
@@ -554,7 +556,9 @@ static void CleanupWindowData(SDL_VideoDevice *_this, SDL_Window *window)
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__)
|
||||
SDL_free(data->rawinput);
|
||||
#endif /*!defined(__XBOXONE__) && !defined(__XBOXSERIES__)*/
|
||||
SDL_free(data);
|
||||
}
|
||||
window->driverdata = NULL;
|
||||
@@ -672,6 +676,7 @@ int WIN_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesI
|
||||
}
|
||||
}
|
||||
|
||||
#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__)
|
||||
/* FIXME: does not work on all hardware configurations with different renders (i.e. hybrid GPUs) */
|
||||
if (window->flags & SDL_WINDOW_TRANSPARENT) {
|
||||
void *handle = SDL_LoadObject("dwmapi.dll");
|
||||
@@ -739,6 +744,7 @@ int WIN_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesI
|
||||
return SDL_SetError("Could not create GL window (WGL support not configured)");
|
||||
#endif
|
||||
}
|
||||
#endif /*!defined(__XBOXONE__) && !defined(__XBOXSERIES__)*/
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -67,11 +67,13 @@ struct SDL_WindowData
|
||||
SDL_bool windowed_mode_was_maximized;
|
||||
SDL_bool in_window_deactivation;
|
||||
RECT cursor_clipped_rect;
|
||||
#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__)
|
||||
RAWINPUT *rawinput;
|
||||
UINT rawinput_offset;
|
||||
UINT rawinput_size;
|
||||
UINT rawinput_count;
|
||||
Uint64 last_rawinput_poll;
|
||||
#endif /*!defined(__XBOXONE__) && !defined(__XBOXSERIES__)*/
|
||||
SDL_Point last_raw_mouse_position;
|
||||
SDL_bool mouse_tracked;
|
||||
SDL_bool destroy_parent_with_window;
|
||||
|
||||
Reference in New Issue
Block a user