Replaced SDL_RenderGetD3D11Device(), SDL_RenderGetD3D12Device(), and SDL_RenderGetD3D9Device() with renderer properties.
parent
0cd4b7d3e3
commit
a1941fad6c
|
@ -1152,9 +1152,10 @@ The following functions have been renamed:
|
|||
|
||||
SDL_AndroidGetExternalStorageState() takes the state as an output parameter and returns 0 if the function succeeds or a negative error code if there was an error.
|
||||
|
||||
The following functions have been renamed:
|
||||
* SDL_RenderGetD3D11Device() => SDL_GetRenderD3D11Device()
|
||||
* SDL_RenderGetD3D9Device() => SDL_GetRenderD3D9Device()
|
||||
The following functions have been removed:
|
||||
* SDL_RenderGetD3D11Device() - replaced with the "SDL.renderer.d3d11.device" property
|
||||
* SDL_RenderGetD3D12Device() - replaced with the "SDL.renderer.d3d12.device" property
|
||||
* SDL_RenderGetD3D9Device() - replaced with the "SDL.renderer.d3d9.device" property
|
||||
|
||||
## SDL_syswm.h
|
||||
|
||||
|
|
|
@ -462,10 +462,6 @@
|
|||
#define SDL_UpperBlit SDL_BlitSurface
|
||||
#define SDL_UpperBlitScaled SDL_BlitSurfaceScaled
|
||||
|
||||
/* ##SDL_system.h */
|
||||
#define SDL_RenderGetD3D11Device SDL_GetRenderD3D11Device
|
||||
#define SDL_RenderGetD3D9Device SDL_GetRenderD3D9Device
|
||||
|
||||
/* ##SDL_thread.h */
|
||||
#define SDL_TLSCleanup SDL_CleanupTLS
|
||||
#define SDL_TLSCreate SDL_CreateTLS
|
||||
|
@ -911,10 +907,6 @@
|
|||
#define SDL_UpperBlit SDL_UpperBlit_renamed_SDL_BlitSurface
|
||||
#define SDL_UpperBlitScaled SDL_UpperBlitScaled_renamed_SDL_BlitSurfaceScaled
|
||||
|
||||
/* ##SDL_system.h */
|
||||
#define SDL_RenderGetD3D11Device SDL_RenderGetD3D11Device_renamed_SDL_GetRenderD3D11Device
|
||||
#define SDL_RenderGetD3D9Device SDL_RenderGetD3D9Device_renamed_SDL_GetRenderD3D9Device
|
||||
|
||||
/* ##SDL_thread.h */
|
||||
#define SDL_TLSCleanup SDL_TLSCleanup_renamed_SDL_CleanupTLS
|
||||
#define SDL_TLSCreate SDL_TLSCreate_renamed_SDL_CreateTLS
|
||||
|
|
|
@ -309,6 +309,11 @@ extern DECLSPEC int SDLCALL SDL_GetRendererInfo(SDL_Renderer *renderer, SDL_Rend
|
|||
/**
|
||||
* Get the properties associated with a renderer.
|
||||
*
|
||||
* The following properties are provided by SDL:
|
||||
* "SDL.renderer.d3d9.device" - the IDirect3DDevice9 associated with the renderer
|
||||
* "SDL.renderer.d3d11.device" - the ID3D11Device associated with the renderer
|
||||
* "SDL.renderer.d3d12.device" - the ID3D12Device associated with the renderer
|
||||
*
|
||||
* \param renderer the rendering context
|
||||
* \returns a valid property ID on success or 0 on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
|
|
|
@ -73,60 +73,8 @@ extern DECLSPEC void SDLCALL SDL_SetWindowsMessageHook(SDL_WindowsMessageHook ca
|
|||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_Direct3D9GetAdapterIndex(SDL_DisplayID displayID);
|
||||
|
||||
typedef struct IDirect3DDevice9 IDirect3DDevice9;
|
||||
|
||||
/**
|
||||
* Get the D3D9 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 D3D device
|
||||
* \returns the D3D9 device associated with given renderer or NULL if it is
|
||||
* not a D3D9 renderer; call SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern DECLSPEC IDirect3DDevice9* SDLCALL SDL_GetRenderD3D9Device(SDL_Renderer * renderer);
|
||||
|
||||
typedef struct ID3D11Device ID3D11Device;
|
||||
|
||||
/**
|
||||
* Get the D3D11 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 D3D11 device
|
||||
* \returns the D3D11 device associated with given renderer or NULL if it is
|
||||
* not a D3D11 renderer; call SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern DECLSPEC ID3D11Device* SDLCALL SDL_GetRenderD3D11Device(SDL_Renderer * renderer);
|
||||
|
||||
#endif /* defined(__WIN32__) || defined(__WINGDK__) */
|
||||
|
||||
#if defined(__WIN32__) || defined(__GDK__)
|
||||
|
||||
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 3.0.0.
|
||||
*/
|
||||
extern DECLSPEC ID3D12Device* SDLCALL SDL_RenderGetD3D12Device(SDL_Renderer* renderer);
|
||||
|
||||
#endif /* defined(__WIN32__) || defined(__GDK__) */
|
||||
|
||||
#if defined(__WIN32__) || defined(__WINGDK__)
|
||||
|
||||
/**
|
||||
|
|
|
@ -286,8 +286,6 @@ SDL3_0.0.0 {
|
|||
SDL_GetRelativeMouseMode;
|
||||
SDL_GetRelativeMouseState;
|
||||
SDL_GetRenderClipRect;
|
||||
SDL_GetRenderD3D11Device;
|
||||
SDL_GetRenderD3D9Device;
|
||||
SDL_GetRenderDrawBlendMode;
|
||||
SDL_GetRenderDrawColor;
|
||||
SDL_GetRenderDriver;
|
||||
|
@ -522,7 +520,6 @@ SDL3_0.0.0 {
|
|||
SDL_RenderFlush;
|
||||
SDL_RenderGeometry;
|
||||
SDL_RenderGeometryRaw;
|
||||
SDL_RenderGetD3D12Device;
|
||||
SDL_RenderLine;
|
||||
SDL_RenderLines;
|
||||
SDL_RenderPoint;
|
||||
|
|
|
@ -310,8 +310,6 @@
|
|||
#define SDL_GetRelativeMouseMode SDL_GetRelativeMouseMode_REAL
|
||||
#define SDL_GetRelativeMouseState SDL_GetRelativeMouseState_REAL
|
||||
#define SDL_GetRenderClipRect SDL_GetRenderClipRect_REAL
|
||||
#define SDL_GetRenderD3D11Device SDL_GetRenderD3D11Device_REAL
|
||||
#define SDL_GetRenderD3D9Device SDL_GetRenderD3D9Device_REAL
|
||||
#define SDL_GetRenderDrawBlendMode SDL_GetRenderDrawBlendMode_REAL
|
||||
#define SDL_GetRenderDrawColor SDL_GetRenderDrawColor_REAL
|
||||
#define SDL_GetRenderDriver SDL_GetRenderDriver_REAL
|
||||
|
@ -546,7 +544,6 @@
|
|||
#define SDL_RenderFlush SDL_RenderFlush_REAL
|
||||
#define SDL_RenderGeometry SDL_RenderGeometry_REAL
|
||||
#define SDL_RenderGeometryRaw SDL_RenderGeometryRaw_REAL
|
||||
#define SDL_RenderGetD3D12Device SDL_RenderGetD3D12Device_REAL
|
||||
#define SDL_RenderLine SDL_RenderLine_REAL
|
||||
#define SDL_RenderLines SDL_RenderLines_REAL
|
||||
#define SDL_RenderPoint SDL_RenderPoint_REAL
|
||||
|
|
|
@ -67,14 +67,11 @@ SDL_DYNAPI_PROC(SDL_Thread*,SDL_CreateThreadWithStackSize,(SDL_ThreadFunction a,
|
|||
#endif
|
||||
|
||||
SDL_DYNAPI_PROC(int,SDL_RegisterApp,(const char *a, Uint32 b, void *c),(a,b,c),return)
|
||||
SDL_DYNAPI_PROC(ID3D12Device*,SDL_RenderGetD3D12Device,(SDL_Renderer *a),(a),return)
|
||||
SDL_DYNAPI_PROC(void,SDL_SetWindowsMessageHook,(SDL_WindowsMessageHook a, void *b),(a,b),)
|
||||
SDL_DYNAPI_PROC(void,SDL_UnregisterApp,(void),(),)
|
||||
|
||||
SDL_DYNAPI_PROC(SDL_bool,SDL_DXGIGetOutputInfo,(SDL_DisplayID a, int *b, int *c),(a,b,c),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_Direct3D9GetAdapterIndex,(SDL_DisplayID a),(a),return)
|
||||
SDL_DYNAPI_PROC(ID3D11Device*,SDL_GetRenderD3D11Device,(SDL_Renderer *a),(a),return)
|
||||
SDL_DYNAPI_PROC(IDirect3DDevice9*,SDL_GetRenderD3D9Device,(SDL_Renderer *a),(a),return)
|
||||
|
||||
SDL_DYNAPI_PROC(int,SDL_GDKGetTaskQueue,(XTaskQueueHandle *a),(a),return)
|
||||
SDL_DYNAPI_PROC(void,SDL_GDKSuspendComplete,(void),(),)
|
||||
|
|
|
@ -46,13 +46,13 @@ this should probably be removed at some point in the future. --ryan. */
|
|||
#define SDL_WINDOWRENDERDATA "SDL.internal.window.renderer"
|
||||
|
||||
#define CHECK_RENDERER_MAGIC(renderer, retval) \
|
||||
if (!(renderer) || (renderer)->magic != &renderer_magic) { \
|
||||
if (!(renderer) || (renderer)->magic != &SDL_renderer_magic) { \
|
||||
SDL_InvalidParamError("renderer"); \
|
||||
return retval; \
|
||||
}
|
||||
|
||||
#define CHECK_TEXTURE_MAGIC(texture, retval) \
|
||||
if (!(texture) || (texture)->magic != &texture_magic) { \
|
||||
if (!(texture) || (texture)->magic != &SDL_texture_magic) { \
|
||||
SDL_InvalidParamError("texture"); \
|
||||
return retval; \
|
||||
}
|
||||
|
@ -122,8 +122,8 @@ static const SDL_RenderDriver *render_drivers[] = {
|
|||
};
|
||||
#endif /* !SDL_RENDER_DISABLED */
|
||||
|
||||
static char renderer_magic;
|
||||
static char texture_magic;
|
||||
char SDL_renderer_magic;
|
||||
char SDL_texture_magic;
|
||||
|
||||
static SDL_INLINE void DebugLogRenderCommands(const SDL_RenderCommand *cmd)
|
||||
{
|
||||
|
@ -896,7 +896,7 @@ SDL_Renderer *SDL_CreateRenderer(SDL_Window *window, const char *name, Uint32 fl
|
|||
}
|
||||
|
||||
renderer->batching = batching;
|
||||
renderer->magic = &renderer_magic;
|
||||
renderer->magic = &SDL_renderer_magic;
|
||||
renderer->window = window;
|
||||
renderer->target_mutex = SDL_CreateMutex();
|
||||
renderer->main_view.viewport.w = -1;
|
||||
|
@ -965,7 +965,7 @@ SDL_Renderer *SDL_CreateSoftwareRenderer(SDL_Surface *surface)
|
|||
|
||||
if (renderer) {
|
||||
VerifyDrawQueueFunctions(renderer);
|
||||
renderer->magic = &renderer_magic;
|
||||
renderer->magic = &SDL_renderer_magic;
|
||||
renderer->target_mutex = SDL_CreateMutex();
|
||||
renderer->main_view.pixel_w = surface->w;
|
||||
renderer->main_view.pixel_h = surface->h;
|
||||
|
@ -1150,7 +1150,7 @@ SDL_Texture *SDL_CreateTexture(SDL_Renderer *renderer, Uint32 format, int access
|
|||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
texture->magic = &texture_magic;
|
||||
texture->magic = &SDL_texture_magic;
|
||||
texture->format = format;
|
||||
texture->access = access;
|
||||
texture->w = w;
|
||||
|
|
|
@ -20,30 +20,3 @@
|
|||
*/
|
||||
#include "SDL_internal.h"
|
||||
|
||||
#if !(defined(__WIN32__) || defined(__WINGDK__))
|
||||
|
||||
DECLSPEC void *SDLCALL SDL_GetRenderD3D9Device(SDL_Renderer *renderer); /* returns IDirect3DDevice9 * */
|
||||
void *SDL_GetRenderD3D9Device(SDL_Renderer *renderer)
|
||||
{
|
||||
(void)renderer;
|
||||
SDL_Unsupported();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
DECLSPEC void *SDLCALL SDL_GetRenderD3D11Device(SDL_Renderer *renderer); /* returns ID3D11Device * */
|
||||
void *SDL_GetRenderD3D11Device(SDL_Renderer *renderer)
|
||||
{
|
||||
(void)renderer;
|
||||
SDL_Unsupported();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
DECLSPEC void *SDLCALL SDL_RenderGetD3D12Device(SDL_Renderer *renderer); /* return ID3D12Device * */
|
||||
void *SDL_RenderGetD3D12Device(SDL_Renderer *renderer)
|
||||
{
|
||||
(void)renderer;
|
||||
SDL_Unsupported();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -44,6 +44,8 @@ typedef struct SDL_DRect
|
|||
/* The SDL 2D rendering system */
|
||||
|
||||
typedef struct SDL_RenderDriver SDL_RenderDriver;
|
||||
extern char SDL_renderer_magic;
|
||||
extern char SDL_texture_magic;
|
||||
|
||||
/* Rendering view state */
|
||||
typedef struct SDL_RenderViewState
|
||||
|
|
|
@ -1563,6 +1563,7 @@ SDL_Renderer *D3D_CreateRenderer(SDL_Window *window, Uint32 flags)
|
|||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
renderer->magic = &SDL_renderer_magic;
|
||||
|
||||
data = (D3D_RenderData *)SDL_calloc(1, sizeof(*data));
|
||||
if (data == NULL) {
|
||||
|
@ -1713,6 +1714,8 @@ SDL_Renderer *D3D_CreateRenderer(SDL_Window *window, Uint32 flags)
|
|||
data->drawstate.cliprect_enabled_dirty = SDL_TRUE;
|
||||
data->drawstate.blend = SDL_BLENDMODE_INVALID;
|
||||
|
||||
SDL_SetProperty(SDL_GetRendererProperties(renderer), "SDL.renderer.d3d9.device", data->device, NULL, NULL);
|
||||
|
||||
return renderer;
|
||||
}
|
||||
|
||||
|
@ -1726,28 +1729,3 @@ SDL_RenderDriver D3D_RenderDriver = {
|
|||
0 }
|
||||
};
|
||||
#endif /* SDL_VIDEO_RENDER_D3D && !SDL_RENDER_DISABLED */
|
||||
|
||||
#if defined(__WIN32__) || defined(__WINGDK__)
|
||||
/* This function needs to always exist on Windows, for the Dynamic API. */
|
||||
IDirect3DDevice9 *SDL_GetRenderD3D9Device(SDL_Renderer *renderer)
|
||||
{
|
||||
IDirect3DDevice9 *device = NULL;
|
||||
|
||||
#if defined(SDL_VIDEO_RENDER_D3D) && !defined(SDL_RENDER_DISABLED)
|
||||
D3D_RenderData *data = (D3D_RenderData *)renderer->driverdata;
|
||||
|
||||
/* Make sure that this is a D3D renderer */
|
||||
if (renderer->DestroyRenderer != D3D_DestroyRenderer) {
|
||||
SDL_SetError("Renderer is not a D3D renderer");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
device = data->device;
|
||||
if (device) {
|
||||
IDirect3DDevice9_AddRef(device);
|
||||
}
|
||||
#endif /* SDL_VIDEO_RENDER_D3D && !SDL_RENDER_DISABLED */
|
||||
|
||||
return device;
|
||||
}
|
||||
#endif /* defined(__WIN32__) || defined(__WINGDK__) */
|
||||
|
|
|
@ -668,6 +668,8 @@ static HRESULT D3D11_CreateDeviceResources(SDL_Renderer *renderer)
|
|||
ID3D11DeviceContext_VSSetShader(data->d3dContext, data->vertexShader, NULL, 0);
|
||||
ID3D11DeviceContext_VSSetConstantBuffers(data->d3dContext, 0, 1, &data->vertexShaderConstants);
|
||||
|
||||
SDL_SetProperty(SDL_GetRendererProperties(renderer), "SDL.renderer.d3d11.device", data->d3dDevice, NULL, NULL);
|
||||
|
||||
done:
|
||||
SAFE_RELEASE(d3dDevice);
|
||||
SAFE_RELEASE(d3dContext);
|
||||
|
@ -2411,6 +2413,7 @@ SDL_Renderer *D3D11_CreateRenderer(SDL_Window *window, Uint32 flags)
|
|||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
renderer->magic = &SDL_renderer_magic;
|
||||
|
||||
data = (D3D11_RenderData *)SDL_calloc(1, sizeof(*data));
|
||||
if (data == NULL) {
|
||||
|
@ -2506,28 +2509,3 @@ SDL_RenderDriver D3D11_RenderDriver = {
|
|||
};
|
||||
|
||||
#endif /* SDL_VIDEO_RENDER_D3D11 && !SDL_RENDER_DISABLED */
|
||||
|
||||
#if defined(__WIN32__) || defined(__WINGDK__)
|
||||
/* This function needs to always exist on Windows, for the Dynamic API. */
|
||||
ID3D11Device *SDL_GetRenderD3D11Device(SDL_Renderer *renderer)
|
||||
{
|
||||
ID3D11Device *device = NULL;
|
||||
|
||||
#if defined(SDL_VIDEO_RENDER_D3D11) && !defined(SDL_RENDER_DISABLED)
|
||||
D3D11_RenderData *data = (D3D11_RenderData *)renderer->driverdata;
|
||||
|
||||
/* Make sure that this is a D3D renderer */
|
||||
if (renderer->DestroyRenderer != D3D11_DestroyRenderer) {
|
||||
SDL_SetError("Renderer is not a D3D11 renderer");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
device = (ID3D11Device *)data->d3dDevice;
|
||||
if (device) {
|
||||
ID3D11Device_AddRef(device);
|
||||
}
|
||||
#endif /* SDL_VIDEO_RENDER_D3D11 && !SDL_RENDER_DISABLED */
|
||||
|
||||
return device;
|
||||
}
|
||||
#endif /* defined(__WIN32__) || defined(__WINGDK__) */
|
||||
|
|
|
@ -1069,6 +1069,9 @@ static HRESULT D3D12_CreateDeviceResources(SDL_Renderer *renderer)
|
|||
}
|
||||
}
|
||||
data->srvPoolHead = &data->srvPoolNodes[0];
|
||||
|
||||
SDL_SetProperty(SDL_GetRendererProperties(renderer), "SDL.renderer.d3d12.device", data->d3dDevice, NULL, NULL);
|
||||
|
||||
done:
|
||||
SAFE_RELEASE(d3dDevice);
|
||||
return result;
|
||||
|
@ -2961,6 +2964,7 @@ SDL_Renderer *D3D12_CreateRenderer(SDL_Window *window, Uint32 flags)
|
|||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
renderer->magic = &SDL_renderer_magic;
|
||||
|
||||
data = (D3D12_RenderData *)SDL_calloc(1, sizeof(*data));
|
||||
if (data == NULL) {
|
||||
|
@ -3046,32 +3050,3 @@ SDL_RenderDriver D3D12_RenderDriver = {
|
|||
#endif
|
||||
|
||||
#endif /* SDL_VIDEO_RENDER_D3D12 && !SDL_RENDER_DISABLED */
|
||||
|
||||
#if defined(__WIN32__) || defined(__GDK__)
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
#endif
|
||||
/* This function needs to always exist on Windows, for the Dynamic API. */
|
||||
ID3D12Device *
|
||||
SDL_RenderGetD3D12Device(SDL_Renderer *renderer)
|
||||
{
|
||||
ID3D12Device *device = NULL;
|
||||
|
||||
#if defined(SDL_VIDEO_RENDER_D3D12) && !defined(SDL_RENDER_DISABLED)
|
||||
D3D12_RenderData *data = (D3D12_RenderData *)renderer->driverdata;
|
||||
|
||||
/* Make sure that this is a D3D renderer */
|
||||
if (renderer->DestroyRenderer != D3D12_DestroyRenderer) {
|
||||
SDL_SetError("Renderer is not a D3D12 renderer");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
device = (ID3D12Device *)data->d3dDevice;
|
||||
if (device) {
|
||||
D3D_CALL(device, AddRef);
|
||||
}
|
||||
#endif /* SDL_VIDEO_RENDER_D3D12 && !SDL_RENDER_DISABLED */
|
||||
|
||||
return device;
|
||||
}
|
||||
#endif /* defined(__WIN32__) || defined(__GDK__) */
|
||||
|
|
|
@ -145,8 +145,9 @@ static SDL_bool CreateWindowAndRenderer(Uint32 window_flags, const char *driver)
|
|||
#endif
|
||||
|
||||
#ifdef __WIN32__
|
||||
d3d11_device = SDL_GetRenderD3D11Device(renderer);
|
||||
d3d11_device = (ID3D11Device *)SDL_GetProperty(SDL_GetRendererProperties(renderer), "SDL.renderer.d3d11.device");
|
||||
if (d3d11_device) {
|
||||
ID3D11Device_AddRef(d3d11_device);
|
||||
ID3D11Device_GetImmediateContext(d3d11_device, &d3d11_context);
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue