mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-04-29 08:15:44 +00:00
Updates SDL to version 2.0.4, which makes it compatible with VS2015.
This commit is contained in:
parent
7b52fed504
commit
b63ef177f4
924 changed files with 79241 additions and 39934 deletions
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 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
|
||||
|
|
@ -29,12 +29,17 @@
|
|||
#include "SDL_syswm.h"
|
||||
#include "../SDL_sysrender.h"
|
||||
#include "../SDL_d3dmath.h"
|
||||
/* #include "SDL_log.h" */
|
||||
|
||||
#include <d3d11_1.h>
|
||||
|
||||
|
||||
#ifdef __WINRT__
|
||||
|
||||
#if NTDDI_VERSION > NTDDI_WIN8
|
||||
#include <DXGI1_3.h>
|
||||
#endif
|
||||
|
||||
#include "SDL_render_winrt.h"
|
||||
|
||||
#if WINAPI_FAMILY == WINAPI_FAMILY_APP
|
||||
|
|
@ -134,6 +139,7 @@ typedef struct
|
|||
/* Defined here so we don't have to include uuid.lib */
|
||||
static const GUID IID_IDXGIFactory2 = { 0x50c83a1c, 0xe072, 0x4c48, { 0x87, 0xb0, 0x36, 0x30, 0xfa, 0x36, 0xa6, 0xd0 } };
|
||||
static const GUID IID_IDXGIDevice1 = { 0x77db970f, 0x6276, 0x48ba, { 0xba, 0x28, 0x07, 0x01, 0x43, 0xb4, 0x39, 0x2c } };
|
||||
static const GUID IID_IDXGIDevice3 = { 0x6007896c, 0x3244, 0x4afd, { 0xbf, 0x18, 0xa6, 0xd3, 0xbe, 0xda, 0x50, 0x23 } };
|
||||
static const GUID IID_ID3D11Texture2D = { 0x6f15aaf2, 0xd208, 0x4e89, { 0x9a, 0xb4, 0x48, 0x95, 0x35, 0xd3, 0x4f, 0x9c } };
|
||||
static const GUID IID_ID3D11Device1 = { 0xa04bfb29, 0x08ef, 0x43d6, { 0xa4, 0x9c, 0xa9, 0xbd, 0xbd, 0xcb, 0xe6, 0x86 } };
|
||||
static const GUID IID_ID3D11DeviceContext1 = { 0xbb2c6faa, 0xb5fb, 0x4082, { 0x8e, 0x6b, 0x38, 0x8b, 0x8c, 0xfa, 0x90, 0xe1 } };
|
||||
|
|
@ -357,7 +363,7 @@ static const DWORD D3D11_PixelShader_Textures[] = {
|
|||
|
||||
float4 main(PixelShaderInput input) : SV_TARGET
|
||||
{
|
||||
const float3 offset = {-0.0625, -0.5, -0.5};
|
||||
const float3 offset = {-0.0627451017, -0.501960814, -0.501960814};
|
||||
const float3 Rcoeff = {1.164, 0.000, 1.596};
|
||||
const float3 Gcoeff = {1.164, -0.391, -0.813};
|
||||
const float3 Bcoeff = {1.164, 2.018, 0.000};
|
||||
|
|
@ -381,12 +387,12 @@ static const DWORD D3D11_PixelShader_Textures[] = {
|
|||
*/
|
||||
#if defined(D3D11_USE_SHADER_MODEL_4_0_level_9_1)
|
||||
static const DWORD D3D11_PixelShader_YUV[] = {
|
||||
0x43425844, 0x04e69cba, 0x74ce6dd2, 0x7fcf84cb, 0x3003d677, 0x00000001,
|
||||
0x43425844, 0x2321c6c6, 0xf14df2d1, 0xc79d068d, 0x8e672abf, 0x00000001,
|
||||
0x000005e8, 0x00000006, 0x00000038, 0x000001dc, 0x000003bc, 0x00000438,
|
||||
0x00000540, 0x000005b4, 0x396e6f41, 0x0000019c, 0x0000019c, 0xffff0200,
|
||||
0x0000016c, 0x00000030, 0x00300000, 0x00300000, 0x00300000, 0x00240003,
|
||||
0x00300000, 0x00000000, 0x00010001, 0x00020002, 0xffff0200, 0x05000051,
|
||||
0xa00f0000, 0xbd800000, 0xbf000000, 0xbf000000, 0x3f800000, 0x05000051,
|
||||
0xa00f0000, 0xbd808081, 0xbf008081, 0xbf008081, 0x3f800000, 0x05000051,
|
||||
0xa00f0001, 0x3f94fdf4, 0x3fcc49ba, 0x00000000, 0x00000000, 0x05000051,
|
||||
0xa00f0002, 0x3f94fdf4, 0xbec83127, 0xbf5020c5, 0x00000000, 0x05000051,
|
||||
0xa00f0003, 0x3f94fdf4, 0x400126e9, 0x00000000, 0x00000000, 0x0200001f,
|
||||
|
|
@ -413,7 +419,7 @@ static const DWORD D3D11_PixelShader_YUV[] = {
|
|||
0x00000001, 0x00101046, 0x00000001, 0x00107e46, 0x00000002, 0x00106000,
|
||||
0x00000000, 0x05000036, 0x00100042, 0x00000000, 0x0010000a, 0x00000001,
|
||||
0x0a000000, 0x00100072, 0x00000000, 0x00100246, 0x00000000, 0x00004002,
|
||||
0xbd800000, 0xbf000000, 0xbf000000, 0x00000000, 0x0a00000f, 0x00100012,
|
||||
0xbd808081, 0xbf008081, 0xbf008081, 0x00000000, 0x0a00000f, 0x00100012,
|
||||
0x00000001, 0x00100086, 0x00000000, 0x00004002, 0x3f94fdf4, 0x3fcc49ba,
|
||||
0x00000000, 0x00000000, 0x0a000010, 0x00100022, 0x00000001, 0x00100246,
|
||||
0x00000000, 0x00004002, 0x3f94fdf4, 0xbec83127, 0xbf5020c5, 0x00000000,
|
||||
|
|
@ -447,12 +453,12 @@ static const DWORD D3D11_PixelShader_YUV[] = {
|
|||
};
|
||||
#elif defined(D3D11_USE_SHADER_MODEL_4_0_level_9_3)
|
||||
static const DWORD D3D11_PixelShader_YUV[] = {
|
||||
0x43425844, 0xe6d969fc, 0x63cac33c, 0xa4926502, 0x5d788135, 0x00000001,
|
||||
0x43425844, 0x6ede7360, 0x45ff5f8a, 0x34ac92ba, 0xb865f5e0, 0x00000001,
|
||||
0x000005c0, 0x00000006, 0x00000038, 0x000001b4, 0x00000394, 0x00000410,
|
||||
0x00000518, 0x0000058c, 0x396e6f41, 0x00000174, 0x00000174, 0xffff0200,
|
||||
0x00000144, 0x00000030, 0x00300000, 0x00300000, 0x00300000, 0x00240003,
|
||||
0x00300000, 0x00000000, 0x00010001, 0x00020002, 0xffff0201, 0x05000051,
|
||||
0xa00f0000, 0xbd800000, 0xbf000000, 0x3f800000, 0x00000000, 0x05000051,
|
||||
0xa00f0000, 0xbd808081, 0xbf008081, 0x3f800000, 0x00000000, 0x05000051,
|
||||
0xa00f0001, 0x3f94fdf4, 0x3fcc49ba, 0x00000000, 0x400126e9, 0x05000051,
|
||||
0xa00f0002, 0x3f94fdf4, 0xbec83127, 0xbf5020c5, 0x00000000, 0x0200001f,
|
||||
0x80000000, 0xb0030000, 0x0200001f, 0x80000000, 0xb00f0001, 0x0200001f,
|
||||
|
|
@ -477,7 +483,7 @@ static const DWORD D3D11_PixelShader_YUV[] = {
|
|||
0x09000045, 0x001000f2, 0x00000001, 0x00101046, 0x00000001, 0x00107e46,
|
||||
0x00000002, 0x00106000, 0x00000000, 0x05000036, 0x00100042, 0x00000000,
|
||||
0x0010000a, 0x00000001, 0x0a000000, 0x00100072, 0x00000000, 0x00100246,
|
||||
0x00000000, 0x00004002, 0xbd800000, 0xbf000000, 0xbf000000, 0x00000000,
|
||||
0x00000000, 0x00004002, 0xbd808081, 0xbf008081, 0xbf008081, 0x00000000,
|
||||
0x0a00000f, 0x00100012, 0x00000001, 0x00100086, 0x00000000, 0x00004002,
|
||||
0x3f94fdf4, 0x3fcc49ba, 0x00000000, 0x00000000, 0x0a000010, 0x00100022,
|
||||
0x00000001, 0x00100246, 0x00000000, 0x00004002, 0x3f94fdf4, 0xbec83127,
|
||||
|
|
@ -754,8 +760,8 @@ SDL_RenderDriver D3D11_RenderDriver = {
|
|||
};
|
||||
|
||||
|
||||
static Uint32
|
||||
DXGIFormatToSDLPixelFormat(DXGI_FORMAT dxgiFormat) {
|
||||
Uint32
|
||||
D3D11_DXGIFormatToSDLPixelFormat(DXGI_FORMAT dxgiFormat) {
|
||||
switch (dxgiFormat) {
|
||||
case DXGI_FORMAT_B8G8R8A8_UNORM:
|
||||
return SDL_PIXELFORMAT_ARGB8888;
|
||||
|
|
@ -823,9 +829,24 @@ D3D11_CreateRenderer(SDL_Window * window, Uint32 flags)
|
|||
renderer->info.flags = (SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE);
|
||||
renderer->driverdata = data;
|
||||
|
||||
#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
|
||||
/* VSync is required in Windows Phone, at least for Win Phone 8.0 and 8.1.
|
||||
* Failure to use it seems to either result in:
|
||||
*
|
||||
* - with the D3D11 debug runtime turned OFF, vsync seemingly gets turned
|
||||
* off (framerate doesn't get capped), but nothing appears on-screen
|
||||
*
|
||||
* - with the D3D11 debug runtime turned ON, vsync gets automatically
|
||||
* turned back on, and the following gets output to the debug console:
|
||||
*
|
||||
* DXGI ERROR: IDXGISwapChain::Present: Interval 0 is not supported, changed to Interval 1. [ UNKNOWN ERROR #1024: ]
|
||||
*/
|
||||
renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC;
|
||||
#else
|
||||
if ((flags & SDL_RENDERER_PRESENTVSYNC)) {
|
||||
renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* HACK: make sure the SDL_Renderer references the SDL_Window data now, in
|
||||
* order to give init functions access to the underlying window handle:
|
||||
|
|
@ -846,10 +867,17 @@ D3D11_CreateRenderer(SDL_Window * window, Uint32 flags)
|
|||
}
|
||||
|
||||
static void
|
||||
D3D11_DestroyRenderer(SDL_Renderer * renderer)
|
||||
D3D11_ReleaseAll(SDL_Renderer * renderer)
|
||||
{
|
||||
D3D11_RenderData *data = (D3D11_RenderData *) renderer->driverdata;
|
||||
SDL_Texture *texture = NULL;
|
||||
|
||||
/* Release all textures */
|
||||
for (texture = renderer->textures; texture; texture = texture->next) {
|
||||
D3D11_DestroyTexture(renderer, texture);
|
||||
}
|
||||
|
||||
/* Release/reset everything else */
|
||||
if (data) {
|
||||
SAFE_RELEASE(data->dxgiFactory);
|
||||
SAFE_RELEASE(data->dxgiAdapter);
|
||||
|
|
@ -873,12 +901,35 @@ D3D11_DestroyRenderer(SDL_Renderer * renderer)
|
|||
SAFE_RELEASE(data->clippedRasterizer);
|
||||
SAFE_RELEASE(data->vertexShaderConstants);
|
||||
|
||||
data->swapEffect = (DXGI_SWAP_EFFECT) 0;
|
||||
data->rotation = DXGI_MODE_ROTATION_UNSPECIFIED;
|
||||
data->currentRenderTargetView = NULL;
|
||||
data->currentRasterizerState = NULL;
|
||||
data->currentBlendState = NULL;
|
||||
data->currentShader = NULL;
|
||||
data->currentShaderResource = NULL;
|
||||
data->currentSampler = NULL;
|
||||
|
||||
/* Unload the D3D libraries. This should be done last, in order
|
||||
* to prevent IUnknown::Release() calls from crashing.
|
||||
*/
|
||||
if (data->hD3D11Mod) {
|
||||
SDL_UnloadObject(data->hD3D11Mod);
|
||||
data->hD3D11Mod = NULL;
|
||||
}
|
||||
if (data->hDXGIMod) {
|
||||
SDL_UnloadObject(data->hDXGIMod);
|
||||
data->hDXGIMod = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
D3D11_DestroyRenderer(SDL_Renderer * renderer)
|
||||
{
|
||||
D3D11_RenderData *data = (D3D11_RenderData *) renderer->driverdata;
|
||||
D3D11_ReleaseAll(renderer);
|
||||
if (data) {
|
||||
SDL_free(data);
|
||||
}
|
||||
SDL_free(renderer);
|
||||
|
|
@ -1294,15 +1345,33 @@ D3D11_IsDisplayRotated90Degrees(DXGI_MODE_ROTATION rotation)
|
|||
}
|
||||
|
||||
static int
|
||||
D3D11_GetViewportAlignedD3DRect(SDL_Renderer * renderer, const SDL_Rect * sdlRect, D3D11_RECT * outRect)
|
||||
D3D11_GetRotationForCurrentRenderTarget(SDL_Renderer * renderer)
|
||||
{
|
||||
D3D11_RenderData *data = (D3D11_RenderData *)renderer->driverdata;
|
||||
if (data->currentOffscreenRenderTargetView) {
|
||||
return DXGI_MODE_ROTATION_IDENTITY;
|
||||
} else {
|
||||
return data->rotation;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
D3D11_GetViewportAlignedD3DRect(SDL_Renderer * renderer, const SDL_Rect * sdlRect, D3D11_RECT * outRect, BOOL includeViewportOffset)
|
||||
{
|
||||
D3D11_RenderData *data = (D3D11_RenderData *) renderer->driverdata;
|
||||
switch (data->rotation) {
|
||||
const int rotation = D3D11_GetRotationForCurrentRenderTarget(renderer);
|
||||
switch (rotation) {
|
||||
case DXGI_MODE_ROTATION_IDENTITY:
|
||||
outRect->left = sdlRect->x;
|
||||
outRect->right = sdlRect->x + sdlRect->w;
|
||||
outRect->top = sdlRect->y;
|
||||
outRect->bottom = sdlRect->y + sdlRect->h;
|
||||
if (includeViewportOffset) {
|
||||
outRect->left += renderer->viewport.x;
|
||||
outRect->right += renderer->viewport.x;
|
||||
outRect->top += renderer->viewport.y;
|
||||
outRect->bottom += renderer->viewport.y;
|
||||
}
|
||||
break;
|
||||
case DXGI_MODE_ROTATION_ROTATE270:
|
||||
outRect->left = sdlRect->y;
|
||||
|
|
@ -1355,6 +1424,7 @@ D3D11_CreateSwapChain(SDL_Renderer * renderer, int w, int h)
|
|||
#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
|
||||
swapChainDesc.Scaling = DXGI_SCALING_STRETCH; /* On phone, only stretch and aspect-ratio stretch scaling are allowed. */
|
||||
swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD; /* On phone, no swap effects are supported. */
|
||||
/* TODO, WinRT: see if Win 8.x DXGI_SWAP_CHAIN_DESC1 settings are available on Windows Phone 8.1, and if there's any advantage to having them on */
|
||||
#else
|
||||
if (usingXAML) {
|
||||
swapChainDesc.Scaling = DXGI_SCALING_STRETCH;
|
||||
|
|
@ -1417,6 +1487,8 @@ D3D11_CreateSwapChain(SDL_Renderer * renderer, int w, int h)
|
|||
WIN_SetErrorFromHRESULT(__FUNCTION__ ", IDXGIFactory2::CreateSwapChainForHwnd", result);
|
||||
goto done;
|
||||
}
|
||||
|
||||
IDXGIFactory_MakeWindowAssociation(data->dxgiFactory, windowinfo.info.win.window, DXGI_MWA_NO_WINDOW_CHANGES);
|
||||
#else
|
||||
SDL_SetError(__FUNCTION__", Unable to find something to attach a swap chain to");
|
||||
goto done;
|
||||
|
|
@ -1447,6 +1519,7 @@ D3D11_CreateWindowSizeDependentResources(SDL_Renderer * renderer)
|
|||
*/
|
||||
SDL_GetWindowSize(renderer->window, &w, &h);
|
||||
data->rotation = D3D11_GetCurrentRotation();
|
||||
/* SDL_Log("%s: windowSize={%d,%d}, orientation=%d\n", __FUNCTION__, w, h, (int)data->rotation); */
|
||||
if (D3D11_IsDisplayRotated90Degrees(data->rotation)) {
|
||||
int tmp = w;
|
||||
w = h;
|
||||
|
|
@ -1463,7 +1536,15 @@ D3D11_CreateWindowSizeDependentResources(SDL_Renderer * renderer)
|
|||
DXGI_FORMAT_UNKNOWN,
|
||||
0
|
||||
);
|
||||
if (FAILED(result)) {
|
||||
if (result == DXGI_ERROR_DEVICE_REMOVED) {
|
||||
/* If the device was removed for any reason, a new device and swap chain will need to be created. */
|
||||
D3D11_HandleDeviceLost(renderer);
|
||||
|
||||
/* Everything is set up now. Do not continue execution of this method. HandleDeviceLost will reenter this method
|
||||
* and correctly set up the new device.
|
||||
*/
|
||||
goto done;
|
||||
} else if (FAILED(result)) {
|
||||
WIN_SetErrorFromHRESULT(__FUNCTION__ ", IDXGISwapChain::ResizeBuffers", result);
|
||||
goto done;
|
||||
}
|
||||
|
|
@ -1476,11 +1557,21 @@ D3D11_CreateWindowSizeDependentResources(SDL_Renderer * renderer)
|
|||
}
|
||||
|
||||
#if WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP
|
||||
/* Set the proper rotation for the swap chain, and generate the
|
||||
* 3D matrix transformation for rendering to the rotated swap chain.
|
||||
/* Set the proper rotation for the swap chain.
|
||||
*
|
||||
* To note, the call for this, IDXGISwapChain1::SetRotation, is not necessary
|
||||
* on Windows Phone, nor is it supported there. It's only needed in Windows 8/RT.
|
||||
* on Windows Phone 8.0, nor is it supported there.
|
||||
*
|
||||
* IDXGISwapChain1::SetRotation does seem to be available on Windows Phone 8.1,
|
||||
* however I've yet to find a way to make it work. It might have something to
|
||||
* do with IDXGISwapChain::ResizeBuffers appearing to not being available on
|
||||
* Windows Phone 8.1 (it wasn't on Windows Phone 8.0), but I'm not 100% sure of this.
|
||||
* The call doesn't appear to be entirely necessary though, and is a performance-related
|
||||
* call, at least according to the following page on MSDN:
|
||||
* http://code.msdn.microsoft.com/windowsapps/DXGI-swap-chain-rotation-21d13d71
|
||||
* -- David L.
|
||||
*
|
||||
* TODO, WinRT: reexamine the docs for IDXGISwapChain1::SetRotation, see if might be available, usable, and prudent-to-call on WinPhone 8.1
|
||||
*/
|
||||
if (data->swapEffect == DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL) {
|
||||
result = IDXGISwapChain1_SetRotation(data->swapChain, data->rotation);
|
||||
|
|
@ -1537,7 +1628,7 @@ D3D11_HandleDeviceLost(SDL_Renderer * renderer)
|
|||
D3D11_RenderData *data = (D3D11_RenderData *) renderer->driverdata;
|
||||
HRESULT result = S_OK;
|
||||
|
||||
/* FIXME: Need to release all resources - all textures are invalid! */
|
||||
D3D11_ReleaseAll(renderer);
|
||||
|
||||
result = D3D11_CreateDeviceResources(renderer);
|
||||
if (FAILED(result)) {
|
||||
|
|
@ -1551,9 +1642,37 @@ D3D11_HandleDeviceLost(SDL_Renderer * renderer)
|
|||
return result;
|
||||
}
|
||||
|
||||
/* Let the application know that the device has been reset */
|
||||
{
|
||||
SDL_Event event;
|
||||
event.type = SDL_RENDER_DEVICE_RESET;
|
||||
SDL_PushEvent(&event);
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
void
|
||||
D3D11_Trim(SDL_Renderer * renderer)
|
||||
{
|
||||
#ifdef __WINRT__
|
||||
#if NTDDI_VERSION > NTDDI_WIN8
|
||||
D3D11_RenderData *data = (D3D11_RenderData *)renderer->driverdata;
|
||||
HRESULT result = S_OK;
|
||||
IDXGIDevice3 *dxgiDevice = NULL;
|
||||
|
||||
result = ID3D11Device_QueryInterface(data->d3dDevice, &IID_IDXGIDevice3, &dxgiDevice);
|
||||
if (FAILED(result)) {
|
||||
//WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11Device to IDXGIDevice3", result);
|
||||
return;
|
||||
}
|
||||
|
||||
IDXGIDevice3_Trim(dxgiDevice);
|
||||
SAFE_RELEASE(dxgiDevice);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
D3D11_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event)
|
||||
{
|
||||
|
|
@ -2065,12 +2184,14 @@ D3D11_UpdateViewport(SDL_Renderer * renderer)
|
|||
SDL_FRect orientationAlignedViewport;
|
||||
BOOL swapDimensions;
|
||||
D3D11_VIEWPORT viewport;
|
||||
const int rotation = D3D11_GetRotationForCurrentRenderTarget(renderer);
|
||||
|
||||
if (renderer->viewport.w == 0 || renderer->viewport.h == 0) {
|
||||
/* If the viewport is empty, assume that it is because
|
||||
* SDL_CreateRenderer is calling it, and will call it again later
|
||||
* with a non-empty viewport.
|
||||
*/
|
||||
/* SDL_Log("%s, no viewport was set!\n", __FUNCTION__); */
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -2079,7 +2200,7 @@ D3D11_UpdateViewport(SDL_Renderer * renderer)
|
|||
* default coordinate system) so rotations will be done in the opposite
|
||||
* direction of the DXGI_MODE_ROTATION enumeration.
|
||||
*/
|
||||
switch (data->rotation) {
|
||||
switch (rotation) {
|
||||
case DXGI_MODE_ROTATION_IDENTITY:
|
||||
projection = MatrixIdentity();
|
||||
break;
|
||||
|
|
@ -2130,7 +2251,7 @@ D3D11_UpdateViewport(SDL_Renderer * renderer)
|
|||
* a landscape mode, for all Windows 8/RT devices, or a portrait mode,
|
||||
* for Windows Phone devices.
|
||||
*/
|
||||
swapDimensions = D3D11_IsDisplayRotated90Degrees(data->rotation);
|
||||
swapDimensions = D3D11_IsDisplayRotated90Degrees(rotation);
|
||||
if (swapDimensions) {
|
||||
orientationAlignedViewport.x = (float) renderer->viewport.y;
|
||||
orientationAlignedViewport.y = (float) renderer->viewport.x;
|
||||
|
|
@ -2150,6 +2271,7 @@ D3D11_UpdateViewport(SDL_Renderer * renderer)
|
|||
viewport.Height = orientationAlignedViewport.h;
|
||||
viewport.MinDepth = 0.0f;
|
||||
viewport.MaxDepth = 1.0f;
|
||||
/* SDL_Log("%s: D3D viewport = {%f,%f,%f,%f}\n", __FUNCTION__, viewport.TopLeftX, viewport.TopLeftY, viewport.Width, viewport.Height); */
|
||||
ID3D11DeviceContext_RSSetViewports(data->d3dContext, 1, &viewport);
|
||||
|
||||
return 0;
|
||||
|
|
@ -2159,13 +2281,12 @@ static int
|
|||
D3D11_UpdateClipRect(SDL_Renderer * renderer)
|
||||
{
|
||||
D3D11_RenderData *data = (D3D11_RenderData *) renderer->driverdata;
|
||||
const SDL_Rect *rect = &renderer->clip_rect;
|
||||
|
||||
if (SDL_RectEmpty(rect)) {
|
||||
if (!renderer->clipping_enabled) {
|
||||
ID3D11DeviceContext_RSSetScissorRects(data->d3dContext, 0, NULL);
|
||||
} else {
|
||||
D3D11_RECT scissorRect;
|
||||
if (D3D11_GetViewportAlignedD3DRect(renderer, rect, &scissorRect) != 0) {
|
||||
if (D3D11_GetViewportAlignedD3DRect(renderer, &renderer->clip_rect, &scissorRect, TRUE) != 0) {
|
||||
/* D3D11_GetViewportAlignedD3DRect will have set the SDL error */
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -2246,7 +2367,7 @@ D3D11_UpdateVertexBuffer(SDL_Renderer *renderer,
|
|||
} else {
|
||||
SAFE_RELEASE(rendererData->vertexBuffer);
|
||||
|
||||
vertexBufferDesc.ByteWidth = dataSizeInBytes;
|
||||
vertexBufferDesc.ByteWidth = (UINT) dataSizeInBytes;
|
||||
vertexBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
|
||||
vertexBufferDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
|
||||
vertexBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
|
||||
|
|
@ -2293,7 +2414,7 @@ D3D11_RenderStartDrawOp(SDL_Renderer * renderer)
|
|||
rendererData->currentRenderTargetView = renderTargetView;
|
||||
}
|
||||
|
||||
if (SDL_RectEmpty(&renderer->clip_rect)) {
|
||||
if (!renderer->clipping_enabled) {
|
||||
rasterizerState = rendererData->mainRasterizer;
|
||||
} else {
|
||||
rasterizerState = rendererData->clippedRasterizer;
|
||||
|
|
@ -2383,7 +2504,7 @@ D3D11_RenderDrawPoints(SDL_Renderer * renderer,
|
|||
a = (float)(renderer->a / 255.0f);
|
||||
|
||||
vertices = SDL_stack_alloc(VertexPositionColor, count);
|
||||
for (i = 0; i < min(count, 128); ++i) {
|
||||
for (i = 0; i < count; ++i) {
|
||||
const VertexPositionColor v = { { points[i].x, points[i].y, 0.0f }, { 0.0f, 0.0f }, { r, g, b, a } };
|
||||
vertices[i] = v;
|
||||
}
|
||||
|
|
@ -2754,7 +2875,7 @@ D3D11_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
|
|||
}
|
||||
|
||||
/* Copy the desired portion of the back buffer to the staging texture: */
|
||||
if (D3D11_GetViewportAlignedD3DRect(renderer, rect, &srcRect) != 0) {
|
||||
if (D3D11_GetViewportAlignedD3DRect(renderer, rect, &srcRect, FALSE) != 0) {
|
||||
/* D3D11_GetViewportAlignedD3DRect will have set the SDL error */
|
||||
goto done;
|
||||
}
|
||||
|
|
@ -2790,7 +2911,7 @@ D3D11_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
|
|||
*/
|
||||
if (SDL_ConvertPixels(
|
||||
rect->w, rect->h,
|
||||
DXGIFormatToSDLPixelFormat(stagingTextureDesc.Format),
|
||||
D3D11_DXGIFormatToSDLPixelFormat(stagingTextureDesc.Format),
|
||||
textureMemory.pData,
|
||||
textureMemory.RowPitch,
|
||||
format,
|
||||
|
|
@ -2801,7 +2922,7 @@ D3D11_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
|
|||
*/
|
||||
char errorMessage[1024];
|
||||
SDL_snprintf(errorMessage, sizeof(errorMessage), __FUNCTION__ ", Convert Pixels failed: %s", SDL_GetError());
|
||||
SDL_SetError(errorMessage);
|
||||
SDL_SetError("%s", errorMessage);
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
|
@ -2827,6 +2948,8 @@ D3D11_RenderPresent(SDL_Renderer * renderer)
|
|||
HRESULT result;
|
||||
DXGI_PRESENT_PARAMETERS parameters;
|
||||
|
||||
SDL_zero(parameters);
|
||||
|
||||
#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
|
||||
syncInterval = 1;
|
||||
presentFlags = 0;
|
||||
|
|
@ -2844,7 +2967,6 @@ D3D11_RenderPresent(SDL_Renderer * renderer)
|
|||
* rects to improve efficiency in certain scenarios.
|
||||
* This option is not available on Windows Phone 8, to note.
|
||||
*/
|
||||
SDL_zero(parameters);
|
||||
result = IDXGISwapChain1_Present1(data->swapChain, syncInterval, presentFlags, ¶meters);
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 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
|
||||
|
|
@ -23,6 +23,7 @@
|
|||
#if SDL_VIDEO_RENDER_D3D11 && !SDL_RENDER_DISABLED
|
||||
|
||||
#include "SDL_syswm.h"
|
||||
#include "../../video/winrt/SDL_winrtvideo_cpp.h"
|
||||
extern "C" {
|
||||
#include "../SDL_sysrender.h"
|
||||
}
|
||||
|
|
@ -79,11 +80,7 @@ D3D11_GetCoreWindowFromSDLRenderer(SDL_Renderer * renderer)
|
|||
extern "C" DXGI_MODE_ROTATION
|
||||
D3D11_GetCurrentRotation()
|
||||
{
|
||||
#if NTDDI_VERSION > NTDDI_WIN8
|
||||
const DisplayOrientations currentOrientation = DisplayInformation::GetForCurrentView()->CurrentOrientation;
|
||||
#else
|
||||
const DisplayOrientations currentOrientation = DisplayProperties::CurrentOrientation;
|
||||
#endif
|
||||
const DisplayOrientations currentOrientation = WINRT_DISPLAY_PROPERTY(CurrentOrientation);
|
||||
|
||||
switch (currentOrientation) {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2016 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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue