From 51ea984f4fcaba9f84950ee9a383faff098134a2 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 3 Oct 2017 04:18:27 +0200 Subject: [PATCH] Create d3d_texture_get_level_desc --- gfx/common/d3d_common.c | 20 +++++++++++++++++++- gfx/common/d3d_common.h | 3 +++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/gfx/common/d3d_common.c b/gfx/common/d3d_common.c index f68f066fe7..d524336a1f 100644 --- a/gfx/common/d3d_common.c +++ b/gfx/common/d3d_common.c @@ -62,6 +62,24 @@ void d3d_set_transform(LPDIRECT3DDEVICE dev, #endif } +bool d3d_texture_get_level_desc(LPDIRECT3DTEXTURE tex, + unsigned idx, void *_ppsurface_level) +{ + if (!tex) + return false; +#if defined(HAVE_D3D9) && !defined(__cplusplus) + if (SUCCEEDED(IDirect3DTexture9_GetLevelDesc(tex, idx, (D3DSURFACE_DESC*)_ppsurface_level))) + return true; +#elif defined(HAVE_D3D8) && !defined(__cplusplus) + if (SUCCEEDED(IDirect3DTexture8_GetLevelDesc(tex, idx, (D3DSURFACE_DESC*)_ppsurface_level))) + return true; +#else + if (SUCCEEDED(tex->GetLevelDesc(idx, (D3DSURFACE_DESC*)_ppsurface_level))) + return true; +#endif + return false; +} + bool d3d_texture_get_surface_level(LPDIRECT3DTEXTURE tex, unsigned idx, void **_ppsurface_level) { @@ -669,7 +687,7 @@ void d3d_texture_blit(unsigned pixel_size, { #if defined(_XBOX360) D3DSURFACE_DESC desc; - tex->GetLevelDesc(0, &desc); + d3d_texture_get_level_desc(tex, 0, &desc); XGCopySurface(lr->pBits, lr->Pitch, width, height, desc.Format, NULL, frame, pitch, desc.Format, NULL, 0, 0); #else diff --git a/gfx/common/d3d_common.h b/gfx/common/d3d_common.h index 1c808dbf8e..8fd61d2aad 100644 --- a/gfx/common/d3d_common.h +++ b/gfx/common/d3d_common.h @@ -35,6 +35,9 @@ void d3d_vertex_buffer_unlock(void *data); void d3d_vertex_buffer_free(void *vertex_data, void *vertex_declaration); +bool d3d_texture_get_level_desc(LPDIRECT3DTEXTURE tex, + unsigned idx, void *_ppsurface_level); + bool d3d_texture_get_surface_level(LPDIRECT3DTEXTURE tex, unsigned idx, void **_ppsurface_level);