Replaced SDL_GetTextureDXGIResource() with texture properties
Fixes https://github.com/libsdl-org/SDL/issues/8529main
parent
09d1e9defb
commit
b374105975
|
@ -309,12 +309,13 @@ 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
|
||||
* 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
|
||||
* "SDL.renderer.d3d12.command_queue" - the ID3D12CommandQueue associated with
|
||||
* the renderer
|
||||
* "SDL.renderer.d3d12.command_queue" - the ID3D12CommandQueue associated with the renderer
|
||||
* ```
|
||||
*
|
||||
* \param renderer the rendering context
|
||||
* \returns a valid property ID on success or 0 on failure; call
|
||||
|
@ -416,27 +417,42 @@ extern DECLSPEC SDL_Texture *SDLCALL SDL_CreateTexture(SDL_Renderer *renderer, U
|
|||
*/
|
||||
extern DECLSPEC SDL_Texture *SDLCALL SDL_CreateTextureFromSurface(SDL_Renderer *renderer, SDL_Surface *surface);
|
||||
|
||||
typedef struct IDXGIResource IDXGIResource;
|
||||
|
||||
/**
|
||||
* Get the DXGI resource associated with a texture.
|
||||
*
|
||||
* This is available when using the direct3d11 and direct3d12 renderers.
|
||||
*
|
||||
* Once you are done using the resource, you should release it to avoid a
|
||||
* resource leak.
|
||||
*
|
||||
* \param texture the texture from which to get the associated resource
|
||||
* \returns the DXGI resource associated with given texture or NULL if it is
|
||||
* not available; call SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern DECLSPEC IDXGIResource* SDLCALL SDL_GetTextureDXGIResource(SDL_Texture *texture);
|
||||
|
||||
/**
|
||||
* Get the properties associated with a texture.
|
||||
*
|
||||
* The following properties are provided by SDL:
|
||||
*
|
||||
* With the direct3d11 renderer:
|
||||
* ```
|
||||
* "SDL.texture.d3d11.texture" - the ID3D11Texture2D associated with the texture
|
||||
* "SDL.texture.d3d11.texture_u" - the ID3D11Texture2D associated with the U plane of a YUV texture
|
||||
* "SDL.texture.d3d11.texture_v" - the ID3D11Texture2D associated with the V plane of a YUV texture
|
||||
* ```
|
||||
*
|
||||
* With the direct3d12 renderer:
|
||||
* ```
|
||||
* "SDL.texture.d3d12.texture" - the ID3D12Resource associated with the texture
|
||||
* "SDL.texture.d3d12.texture_u" - the ID3D12Resource associated with the U plane of a YUV texture
|
||||
* "SDL.texture.d3d12.texture_v" - the ID3D12Resource associated with the V plane of a YUV texture
|
||||
* ```
|
||||
*
|
||||
* With the opengl renderer:
|
||||
* ```
|
||||
* "SDL.texture.opengl.texture" - the GLuint texture associated with the texture
|
||||
* "SDL.texture.opengl.texture_u" - the GLuint texture associated with the U plane of a YUV texture
|
||||
* "SDL.texture.opengl.texture_v" - the GLuint texture associated with the V plane of a YUV texture
|
||||
* "SDL.texture.opengl.tex_w" - the 16.16 fixed point texture coordinate width of the texture
|
||||
* "SDL.texture.opengl.tex_h" - the 16.16 fixed point texture coordinate height of the texture
|
||||
* ```
|
||||
*
|
||||
* With the opengles2 renderer:
|
||||
* ```
|
||||
* "SDL.texture.opengles2.texture" - the GLuint texture associated with the texture
|
||||
* "SDL.texture.opengles2.texture_uv" - the GLuint texture associated with the UV plane of an NV12 texture
|
||||
* "SDL.texture.opengles2.texture_u" - the GLuint texture associated with the U plane of a YUV texture
|
||||
* "SDL.texture.opengles2.texture_v" - the GLuint texture associated with the V plane of a YUV texture
|
||||
* ```
|
||||
*
|
||||
* \param texture the texture to query
|
||||
* \returns a valid property ID on success or 0 on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
|
|
|
@ -936,53 +936,71 @@ extern DECLSPEC SDL_Window *SDLCALL SDL_GetWindowParent(SDL_Window *window);
|
|||
*
|
||||
* The following properties are provided by SDL:
|
||||
*
|
||||
* On Android: "SDL.window.android.window" - the ANativeWindow associated with
|
||||
* the window "SDL.window.android.surface" - the EGLSurface associated with
|
||||
* the window
|
||||
* On Android:
|
||||
* ```
|
||||
* "SDL.window.android.window" - the ANativeWindow associated with the window
|
||||
* "SDL.window.android.surface" - the EGLSurface associated with the window
|
||||
* ```
|
||||
*
|
||||
* On iOS: "SDL.window.uikit.window" - the (__unsafe_unretained) UIWindow
|
||||
* associated with the window "SDL.window.uikit.metal_view_tag" - the
|
||||
* NSInteger tag assocated with metal views on the window
|
||||
* On iOS:
|
||||
* ```
|
||||
* "SDL.window.uikit.window" - the (__unsafe_unretained) UIWindow associated with the window
|
||||
* "SDL.window.uikit.metal_view_tag" - the NSInteger tag assocated with metal views on the window
|
||||
* ```
|
||||
*
|
||||
* On KMS/DRM: "SDL.window.kmsdrm.dev_index" - the device index associated
|
||||
* with the window (e.g. the X in /dev/dri/cardX) "SDL.window.kmsdrm.drm_fd" -
|
||||
* the DRM FD associated with the window "SDL.window.kmsdrm.gbm_dev" - the GBM
|
||||
* device associated with the window
|
||||
* On KMS/DRM:
|
||||
* ```
|
||||
* "SDL.window.kmsdrm.dev_index" - the device index associated with the window (e.g. the X in /dev/dri/cardX)
|
||||
* "SDL.window.kmsdrm.drm_fd" - the DRM FD associated with the window
|
||||
* "SDL.window.kmsdrm.gbm_dev" - the GBM device associated with the window
|
||||
* ```
|
||||
*
|
||||
* On macOS: "SDL.window.cocoa.window" - the (__unsafe_unretained) NSWindow
|
||||
* associated with the window "SDL.window.cocoa.metal_view_tag" - the
|
||||
* NSInteger tag assocated with metal views on the window
|
||||
* On macOS:
|
||||
* ```
|
||||
* "SDL.window.cocoa.window" - the (__unsafe_unretained) NSWindow associated with the window
|
||||
* "SDL.window.cocoa.metal_view_tag" - the NSInteger tag assocated with metal views on the window
|
||||
* ```
|
||||
*
|
||||
* On Vivante: "SDL.window.vivante.display" - the EGLNativeDisplayType
|
||||
* associated with the window "SDL.window.vivante.window" - the
|
||||
* EGLNativeWindowType associated with the window "SDL.window.vivante.surface"
|
||||
* - the EGLSurface associated with the window
|
||||
* On Vivante:
|
||||
* ```
|
||||
* "SDL.window.vivante.display" - the EGLNativeDisplayType associated with the window
|
||||
* "SDL.window.vivante.window" - the EGLNativeWindowType associated with the window
|
||||
* "SDL.window.vivante.surface" - the EGLSurface associated with the window
|
||||
* ```
|
||||
*
|
||||
* On UWP: "SDL.window.winrt.window" - the IInspectable CoreWindow associated
|
||||
* with the window
|
||||
* On UWP:
|
||||
* ```
|
||||
* "SDL.window.winrt.window" - the IInspectable CoreWindow associated with the window
|
||||
* ```
|
||||
*
|
||||
* On Windows: "SDL.window.win32.hwnd" - the HWND associated with the window
|
||||
* On Windows:
|
||||
* ```
|
||||
* "SDL.window.win32.hwnd" - the HWND associated with the window
|
||||
* "SDL.window.win32.hdc" - the HDC associated with the window
|
||||
* "SDL.window.win32.instance" - the HINSTANCE associated with the window
|
||||
* ```
|
||||
*
|
||||
* On Wayland: "SDL.window.wayland.registry" - the wl_registry associated with
|
||||
* the window "SDL.window.wayland.display" - the wl_display associated with
|
||||
* the window "SDL.window.wayland.surface" - the wl_surface associated with
|
||||
* the window "SDL.window.wayland.egl_window" - the wl_egl_window associated
|
||||
* with the window "SDL.window.wayland.xdg_surface" - the xdg_surface
|
||||
* associated with the window "SDL.window.wayland.xdg_toplevel" - the
|
||||
* xdg_toplevel role associated with the window "SDL.window.wayland.xdg_popup"
|
||||
* - the xdg_popup role associated with the window
|
||||
* "SDL.window.wayland.xdg_positioner" - the xdg_positioner associated with
|
||||
* the window, in popup mode
|
||||
* On Wayland:
|
||||
* ```
|
||||
* "SDL.window.wayland.registry" - the wl_registry associated with the window
|
||||
* "SDL.window.wayland.display" - the wl_display associated with the window
|
||||
* "SDL.window.wayland.surface" - the wl_surface associated with the window
|
||||
* "SDL.window.wayland.egl_window" - the wl_egl_window associated with the window
|
||||
* "SDL.window.wayland.xdg_surface" - the xdg_surface associated with the window
|
||||
* "SDL.window.wayland.xdg_toplevel" - the xdg_toplevel role associated with the window
|
||||
* "SDL.window.wayland.xdg_popup" - the xdg_popup role associated with the window
|
||||
* "SDL.window.wayland.xdg_positioner" - the xdg_positioner associated with the window, in popup mode
|
||||
* ```
|
||||
*
|
||||
* Note: The xdg_* window objects do not internally persist across window
|
||||
* show/hide calls. They will be null if the window is hidden and must be
|
||||
* queried each time it is shown.
|
||||
* Note: The xdg_* window objects do not internally persist across window show/hide calls.
|
||||
* They will be null if the window is hidden and must be queried each time it is shown.
|
||||
*
|
||||
* On X11: "SDL.window.x11.display" - the X11 Display associated with the
|
||||
* window "SDL.window.x11.screen" - the screen number associated with the
|
||||
* window "SDL.window.x11.window" - the X11 Window associated with the window
|
||||
* On X11:
|
||||
* ```
|
||||
* "SDL.window.x11.display" - the X11 Display associated with the window
|
||||
* "SDL.window.x11.screen" - the screen number associated with the window
|
||||
* "SDL.window.x11.window" - the X11 Window associated with the window
|
||||
* ```
|
||||
*
|
||||
* \param window the window to query
|
||||
* \returns a valid property ID on success or 0 on failure; call
|
||||
|
|
|
@ -898,7 +898,6 @@ SDL3_0.0.0 {
|
|||
SDL_SetAudioStreamFrequencyRatio;
|
||||
SDL_SetAudioPostmixCallback;
|
||||
SDL_GetAudioStreamQueued;
|
||||
SDL_GetTextureDXGIResource;
|
||||
SDL_CreateProperties;
|
||||
SDL_LockProperties;
|
||||
SDL_UnlockProperties;
|
||||
|
|
|
@ -923,7 +923,6 @@
|
|||
#define SDL_SetAudioStreamFrequencyRatio SDL_SetAudioStreamFrequencyRatio_REAL
|
||||
#define SDL_SetAudioPostmixCallback SDL_SetAudioPostmixCallback_REAL
|
||||
#define SDL_GetAudioStreamQueued SDL_GetAudioStreamQueued_REAL
|
||||
#define SDL_GetTextureDXGIResource SDL_GetTextureDXGIResource_REAL
|
||||
#define SDL_CreateProperties SDL_CreateProperties_REAL
|
||||
#define SDL_LockProperties SDL_LockProperties_REAL
|
||||
#define SDL_UnlockProperties SDL_UnlockProperties_REAL
|
||||
|
|
|
@ -957,7 +957,6 @@ SDL_DYNAPI_PROC(float,SDL_GetAudioStreamFrequencyRatio,(SDL_AudioStream *a),(a),
|
|||
SDL_DYNAPI_PROC(int,SDL_SetAudioStreamFrequencyRatio,(SDL_AudioStream *a, float b),(a,b),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_SetAudioPostmixCallback,(SDL_AudioDeviceID a, SDL_AudioPostmixCallback b, void *c),(a,b,c),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_GetAudioStreamQueued,(SDL_AudioStream *a),(a),return)
|
||||
SDL_DYNAPI_PROC(IDXGIResource*,SDL_GetTextureDXGIResource,(SDL_Texture *a),(a),return)
|
||||
SDL_DYNAPI_PROC(SDL_PropertiesID,SDL_CreateProperties,(void),(),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_LockProperties,(SDL_PropertiesID a),(a),return)
|
||||
SDL_DYNAPI_PROC(void,SDL_UnlockProperties,(SDL_PropertiesID a),(a),)
|
||||
|
|
|
@ -4185,19 +4185,6 @@ void *SDL_GetRenderMetalCommandEncoder(SDL_Renderer *renderer)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
IDXGIResource *SDL_GetTextureDXGIResource(SDL_Texture *texture)
|
||||
{
|
||||
SDL_Renderer *renderer;
|
||||
|
||||
CHECK_TEXTURE_MAGIC(texture, NULL);
|
||||
renderer = texture->renderer;
|
||||
if (renderer && renderer->GetTextureDXGIResource) {
|
||||
return renderer->GetTextureDXGIResource(texture);
|
||||
}
|
||||
SDL_Unsupported();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static SDL_BlendMode SDL_GetShortBlendMode(SDL_BlendMode blendMode)
|
||||
{
|
||||
if (blendMode == SDL_BLENDMODE_NONE_FULL) {
|
||||
|
|
|
@ -214,8 +214,6 @@ struct SDL_Renderer
|
|||
void *(*GetMetalLayer)(SDL_Renderer *renderer);
|
||||
void *(*GetMetalCommandEncoder)(SDL_Renderer *renderer);
|
||||
|
||||
IDXGIResource *(*GetTextureDXGIResource)(SDL_Texture *texture);
|
||||
|
||||
/* The current renderer info */
|
||||
SDL_RendererInfo info;
|
||||
|
||||
|
|
|
@ -184,7 +184,6 @@ static const GUID SDL_IID_IDXGIDevice1 = { 0x77db970f, 0x6276, 0x48ba, { 0xba, 0
|
|||
#if defined(__WINRT__) && NTDDI_VERSION > NTDDI_WIN8
|
||||
static const GUID SDL_IID_IDXGIDevice3 = { 0x6007896c, 0x3244, 0x4afd, { 0xbf, 0x18, 0xa6, 0xd3, 0xbe, 0xda, 0x50, 0x23 } };
|
||||
#endif
|
||||
static const GUID SDL_IID_IDXGIResource = { 0x035f3ab4, 0x482e, 0x4e50, { 0xb4, 0x1f, 0x8a, 0x7f, 0x8b, 0xd8, 0x96, 0x0b } };
|
||||
static const GUID SDL_IID_ID3D11Texture2D = { 0x6f15aaf2, 0xd208, 0x4e89, { 0x9a, 0xb4, 0x48, 0x95, 0x35, 0xd3, 0x4f, 0x9c } };
|
||||
static const GUID SDL_IID_ID3D11Device1 = { 0xa04bfb29, 0x08ef, 0x43d6, { 0xa4, 0x9c, 0xa9, 0xbd, 0xbd, 0xcb, 0xe6, 0x86 } };
|
||||
static const GUID SDL_IID_ID3D11DeviceContext1 = { 0xbb2c6faa, 0xb5fb, 0x4082, { 0x8e, 0x6b, 0x38, 0x8b, 0x8c, 0xfa, 0x90, 0xe1 } };
|
||||
|
@ -1115,6 +1114,7 @@ static int D3D11_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
|||
D3D11_DestroyTexture(renderer, texture);
|
||||
return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateTexture2D"), result);
|
||||
}
|
||||
SDL_SetProperty(SDL_GetTextureProperties(texture), "SDL.texture.d3d11.texture", textureData->mainTexture);
|
||||
#if SDL_HAVE_YUV
|
||||
if (texture->format == SDL_PIXELFORMAT_YV12 ||
|
||||
texture->format == SDL_PIXELFORMAT_IYUV) {
|
||||
|
@ -1131,6 +1131,7 @@ static int D3D11_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
|||
D3D11_DestroyTexture(renderer, texture);
|
||||
return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateTexture2D"), result);
|
||||
}
|
||||
SDL_SetProperty(SDL_GetTextureProperties(texture), "SDL.texture.d3d11.texture_u", textureData->mainTextureU);
|
||||
|
||||
result = ID3D11Device_CreateTexture2D(rendererData->d3dDevice,
|
||||
&textureDesc,
|
||||
|
@ -1140,6 +1141,7 @@ static int D3D11_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
|||
D3D11_DestroyTexture(renderer, texture);
|
||||
return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateTexture2D"), result);
|
||||
}
|
||||
SDL_SetProperty(SDL_GetTextureProperties(texture), "SDL.texture.d3d11.texture_v", textureData->mainTextureV);
|
||||
}
|
||||
if (texture->format == SDL_PIXELFORMAT_NV12 ||
|
||||
texture->format == SDL_PIXELFORMAT_NV21) {
|
||||
|
@ -1629,26 +1631,6 @@ static void D3D11_SetTextureScaleMode(SDL_Renderer *renderer, SDL_Texture *textu
|
|||
textureData->scaleMode = (scaleMode == SDL_SCALEMODE_NEAREST) ? D3D11_FILTER_MIN_MAG_MIP_POINT : D3D11_FILTER_MIN_MAG_MIP_LINEAR;
|
||||
}
|
||||
|
||||
static IDXGIResource *D3D11_GetTextureDXGIResource(SDL_Texture *texture)
|
||||
{
|
||||
D3D11_TextureData *textureData = (D3D11_TextureData *)texture->driverdata;
|
||||
IDXGIResource *resource = NULL;
|
||||
HRESULT result;
|
||||
|
||||
if (!textureData || !textureData->mainTexture) {
|
||||
SDL_SetError("Texture is not currently available");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
result = ID3D11Texture2D_QueryInterface(textureData->mainTexture, &SDL_IID_IDXGIResource, (void **)&resource);
|
||||
if (FAILED(result)) {
|
||||
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("GetTextureDXGIResource"), result);
|
||||
return NULL;
|
||||
}
|
||||
return resource;
|
||||
}
|
||||
|
||||
static int D3D11_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
{
|
||||
D3D11_RenderData *rendererData = (D3D11_RenderData *)renderer->driverdata;
|
||||
|
@ -2426,7 +2408,6 @@ SDL_Renderer *D3D11_CreateRenderer(SDL_Window *window, Uint32 flags)
|
|||
renderer->LockTexture = D3D11_LockTexture;
|
||||
renderer->UnlockTexture = D3D11_UnlockTexture;
|
||||
renderer->SetTextureScaleMode = D3D11_SetTextureScaleMode;
|
||||
renderer->GetTextureDXGIResource = D3D11_GetTextureDXGIResource;
|
||||
renderer->SetRenderTarget = D3D11_SetRenderTarget;
|
||||
renderer->QueueSetViewport = D3D11_QueueSetViewport;
|
||||
renderer->QueueSetDrawColor = D3D11_QueueSetViewport; /* SetViewport and SetDrawColor are (currently) no-ops. */
|
||||
|
|
|
@ -253,7 +253,6 @@ static const GUID SDL_IID_ID3D12DescriptorHeap = { 0x8efb471d, 0x616c, 0x4f49, {
|
|||
static const GUID SDL_IID_ID3D12CommandAllocator = { 0x6102dee4, 0xaf59, 0x4b09, { 0xb9, 0x99, 0xb4, 0x4d, 0x73, 0xf0, 0x9b, 0x24 } };
|
||||
static const GUID SDL_IID_ID3D12GraphicsCommandList2 = { 0x38C3E585, 0xFF17, 0x412C, { 0x91, 0x50, 0x4F, 0xC6, 0xF9, 0xD7, 0x2A, 0x28 } };
|
||||
static const GUID SDL_IID_ID3D12Fence = { 0x0a753dcf, 0xc4d8, 0x4b91, { 0xad, 0xf6, 0xbe, 0x5a, 0x60, 0xd9, 0x5a, 0x76 } };
|
||||
static const GUID SDL_IID_IDXGIResource = { 0x035f3ab4, 0x482e, 0x4e50, { 0xb4, 0x1f, 0x8a, 0x7f, 0x8b, 0xd8, 0x96, 0x0b } };
|
||||
static const GUID SDL_IID_ID3D12Resource = { 0x696442be, 0xa72e, 0x4059, { 0xbc, 0x79, 0x5b, 0x5c, 0x98, 0x04, 0x0f, 0xad } };
|
||||
static const GUID SDL_IID_ID3D12RootSignature = { 0xc54a6b66, 0x72df, 0x4ee8, { 0x8b, 0xe5, 0xa9, 0x46, 0xa1, 0x42, 0x92, 0x14 } };
|
||||
static const GUID SDL_IID_ID3D12PipelineState = { 0x765a30f3, 0xf624, 0x4c6f, { 0xa8, 0x28, 0xac, 0xe9, 0x48, 0x62, 0x24, 0x45 } };
|
||||
|
@ -1487,6 +1486,7 @@ static int D3D12_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
|||
D3D12_DestroyTexture(renderer, texture);
|
||||
return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D12Device::CreateCommittedResource [texture]"), result);
|
||||
}
|
||||
SDL_SetProperty(SDL_GetTextureProperties(texture), "SDL.texture.d3d12.texture", textureData->mainTexture);
|
||||
#if SDL_HAVE_YUV
|
||||
if (texture->format == SDL_PIXELFORMAT_YV12 ||
|
||||
texture->format == SDL_PIXELFORMAT_IYUV) {
|
||||
|
@ -1508,6 +1508,7 @@ static int D3D12_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
|||
D3D12_DestroyTexture(renderer, texture);
|
||||
return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D12Device::CreateCommittedResource [texture]"), result);
|
||||
}
|
||||
SDL_SetProperty(SDL_GetTextureProperties(texture), "SDL.texture.d3d12.texture_u", textureData->mainTextureU);
|
||||
|
||||
result = D3D_CALL(rendererData->d3dDevice, CreateCommittedResource,
|
||||
&heapProps,
|
||||
|
@ -1522,6 +1523,7 @@ static int D3D12_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
|||
D3D12_DestroyTexture(renderer, texture);
|
||||
return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D12Device::CreateCommittedResource [texture]"), result);
|
||||
}
|
||||
SDL_SetProperty(SDL_GetTextureProperties(texture), "SDL.texture.d3d12.texture_v", textureData->mainTextureV);
|
||||
}
|
||||
|
||||
if (texture->format == SDL_PIXELFORMAT_NV12 ||
|
||||
|
@ -2065,25 +2067,6 @@ static void D3D12_SetTextureScaleMode(SDL_Renderer *renderer, SDL_Texture *textu
|
|||
textureData->scaleMode = (scaleMode == SDL_SCALEMODE_NEAREST) ? D3D12_FILTER_MIN_MAG_MIP_POINT : D3D12_FILTER_MIN_MAG_MIP_LINEAR;
|
||||
}
|
||||
|
||||
static IDXGIResource *D3D12_GetTextureDXGIResource(SDL_Texture *texture)
|
||||
{
|
||||
D3D12_TextureData *textureData = (D3D12_TextureData *)texture->driverdata;
|
||||
IDXGIResource *resource = NULL;
|
||||
HRESULT result;
|
||||
|
||||
if (!textureData || !textureData->mainTexture) {
|
||||
SDL_SetError("Texture is not currently available");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
result = D3D_CALL(textureData->mainTexture, QueryInterface, D3D_GUID(SDL_IID_IDXGIResource), (void **)&resource);
|
||||
if (FAILED(result)) {
|
||||
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("GetTextureDXGIResource"), result);
|
||||
return NULL;
|
||||
}
|
||||
return resource;
|
||||
}
|
||||
|
||||
static int D3D12_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
{
|
||||
D3D12_RenderData *rendererData = (D3D12_RenderData *)renderer->driverdata;
|
||||
|
@ -2984,7 +2967,6 @@ SDL_Renderer *D3D12_CreateRenderer(SDL_Window *window, Uint32 flags)
|
|||
renderer->LockTexture = D3D12_LockTexture;
|
||||
renderer->UnlockTexture = D3D12_UnlockTexture;
|
||||
renderer->SetTextureScaleMode = D3D12_SetTextureScaleMode;
|
||||
renderer->GetTextureDXGIResource = D3D12_GetTextureDXGIResource;
|
||||
renderer->SetRenderTarget = D3D12_SetRenderTarget;
|
||||
renderer->QueueSetViewport = D3D12_QueueSetViewport;
|
||||
renderer->QueueSetDrawColor = D3D12_QueueSetViewport; /* SetViewport and SetDrawColor are (currently) no-ops. */
|
||||
|
|
|
@ -518,6 +518,10 @@ static int GL_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
|||
data->texw = (GLfloat)(texture->w) / texture_w;
|
||||
data->texh = (GLfloat)texture->h / texture_h;
|
||||
}
|
||||
SDL_PropertiesID props = SDL_GetTextureProperties(texture);
|
||||
SDL_SetProperty(props, "SDL.texture.opengl.texture", (void *)(uintptr_t)data->texture);
|
||||
SDL_SetProperty(props, "SDL.texture.opengl.tex_w", (void *)(uintptr_t)(Uint32)(data->texw * 65536));
|
||||
SDL_SetProperty(props, "SDL.texture.opengl.tex_h", (void *)(uintptr_t)(Uint32)(data->texh * 65536));
|
||||
|
||||
data->format = format;
|
||||
data->formattype = type;
|
||||
|
@ -590,6 +594,7 @@ static int GL_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
|||
GL_CLAMP_TO_EDGE);
|
||||
renderdata->glTexImage2D(textype, 0, internalFormat, (texture_w + 1) / 2,
|
||||
(texture_h + 1) / 2, 0, format, type, NULL);
|
||||
SDL_SetProperty(props, "SDL.texture.opengl.texture_u", (void *)(uintptr_t)data->utexture);
|
||||
|
||||
renderdata->glBindTexture(textype, data->vtexture);
|
||||
renderdata->glTexParameteri(textype, GL_TEXTURE_MIN_FILTER,
|
||||
|
@ -602,6 +607,7 @@ static int GL_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
|||
GL_CLAMP_TO_EDGE);
|
||||
renderdata->glTexImage2D(textype, 0, internalFormat, (texture_w + 1) / 2,
|
||||
(texture_h + 1) / 2, 0, format, type, NULL);
|
||||
SDL_SetProperty(props, "SDL.texture.opengl.texture_v", (void *)(uintptr_t)data->vtexture);
|
||||
}
|
||||
|
||||
if (texture->format == SDL_PIXELFORMAT_NV12 ||
|
||||
|
|
|
@ -1499,6 +1499,7 @@ static int GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
|||
renderdata->glTexParameteri(data->texture_type, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
renderdata->glTexParameteri(data->texture_type, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
renderdata->glTexImage2D(data->texture_type, 0, format, (texture->w + 1) / 2, (texture->h + 1) / 2, 0, format, type, NULL);
|
||||
SDL_SetProperty(SDL_GetTextureProperties(texture), "SDL.texture.opengles2.texture_v", (void *)(uintptr_t)data->texture_v);
|
||||
|
||||
renderdata->glGenTextures(1, &data->texture_u);
|
||||
if (GL_CheckError("glGenTexures()", renderer) < 0) {
|
||||
|
@ -1514,6 +1515,8 @@ static int GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
|||
if (GL_CheckError("glTexImage2D()", renderer) < 0) {
|
||||
return -1;
|
||||
}
|
||||
SDL_SetProperty(SDL_GetTextureProperties(texture), "SDL.texture.opengles2.texture_u", (void *)(uintptr_t)data->texture_u);
|
||||
|
||||
} else if (data->nv12) {
|
||||
renderdata->glGenTextures(1, &data->texture_u);
|
||||
if (GL_CheckError("glGenTexures()", renderer) < 0) {
|
||||
|
@ -1529,6 +1532,7 @@ static int GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
|||
if (GL_CheckError("glTexImage2D()", renderer) < 0) {
|
||||
return -1;
|
||||
}
|
||||
SDL_SetProperty(SDL_GetTextureProperties(texture), "SDL.texture.opengles2.texture_uv", (void *)(uintptr_t)data->texture_u);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -1549,6 +1553,7 @@ static int GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
|||
return -1;
|
||||
}
|
||||
}
|
||||
SDL_SetProperty(SDL_GetTextureProperties(texture), "SDL.texture.opengles2.texture", (void *)(uintptr_t)data->texture);
|
||||
|
||||
if (texture->access == SDL_TEXTUREACCESS_TARGET) {
|
||||
data->fbo = GLES2_GetFBO(renderer->driverdata, texture->w, texture->h);
|
||||
|
@ -1995,9 +2000,6 @@ static int GLES2_SetVSync(SDL_Renderer *renderer, const int vsync)
|
|||
/*************************************************************************************************
|
||||
* Bind/unbinding of textures
|
||||
*************************************************************************************************/
|
||||
static int GLES2_BindTexture(SDL_Renderer *renderer, SDL_Texture *texture, float *texw, float *texh);
|
||||
static int GLES2_UnbindTexture(SDL_Renderer *renderer, SDL_Texture *texture);
|
||||
|
||||
static int GLES2_BindTexture(SDL_Renderer *renderer, SDL_Texture *texture, float *texw, float *texh)
|
||||
{
|
||||
GLES2_RenderData *data = (GLES2_RenderData *)renderer->driverdata;
|
||||
|
|
|
@ -625,20 +625,12 @@ static SDL_bool GetTextureForD3D11Frame(AVFrame *frame, SDL_Texture **texture)
|
|||
}
|
||||
}
|
||||
|
||||
IDXGIResource *dxgi_resource = SDL_GetTextureDXGIResource(*texture);
|
||||
if (!dxgi_resource) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
ID3D11Resource *dx11_resource = NULL;
|
||||
HRESULT result = IDXGIResource_QueryInterface(dxgi_resource, &SDL_IID_ID3D11Resource, (void **)&dx11_resource);
|
||||
IDXGIResource_Release(dxgi_resource);
|
||||
if (FAILED(result)) {
|
||||
SDL_SetError("Couldn't get texture ID3D11Resource interface: 0x%x", result);
|
||||
ID3D11Resource *dx11_resource = SDL_GetProperty(SDL_GetTextureProperties(*texture), "SDL.texture.d3d11.texture");
|
||||
if (!dx11_resource) {
|
||||
SDL_SetError("Couldn't get texture ID3D11Resource interface");
|
||||
return SDL_FALSE;
|
||||
}
|
||||
ID3D11DeviceContext_CopySubresourceRegion(d3d11_context, dx11_resource, 0, 0, 0, 0, (ID3D11Resource *)pTexture, iSliceIndex, NULL);
|
||||
ID3D11Resource_Release(dx11_resource);
|
||||
|
||||
return SDL_TRUE;
|
||||
#else
|
||||
|
|
Loading…
Reference in New Issue