mirror of
https://github.com/libretro/RetroArch
synced 2025-04-03 10:21:31 +00:00
(d3d9_common.c) Cleanups
This commit is contained in:
parent
0c4a3a83ce
commit
282b4ba21b
@ -249,15 +249,12 @@ static void *d3d9_texture_new_from_file(
|
|||||||
PALETTEENTRY *palette)
|
PALETTEENTRY *palette)
|
||||||
{
|
{
|
||||||
void *buf = NULL;
|
void *buf = NULL;
|
||||||
HRESULT hr = D3D9CreateTextureFromFile((LPDIRECT3DDEVICE9)dev,
|
if (FAILED(D3D9CreateTextureFromFile((LPDIRECT3DDEVICE9)dev,
|
||||||
path, width, height, miplevels, usage, format,
|
path, width, height, miplevels, usage, format,
|
||||||
(D3DPOOL)pool, filter, mipfilter, color_key,
|
(D3DPOOL)pool, filter, mipfilter, color_key,
|
||||||
(D3DXIMAGE_INFO*)src_info_data,
|
(D3DXIMAGE_INFO*)src_info_data,
|
||||||
palette, (struct IDirect3DTexture9**)&buf);
|
palette, (struct IDirect3DTexture9**)&buf)))
|
||||||
|
|
||||||
if (FAILED(hr))
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -289,13 +286,13 @@ void *d3d9_texture_new(void *_dev,
|
|||||||
if (want_mipmap)
|
if (want_mipmap)
|
||||||
usage |= D3DUSAGE_AUTOGENMIPMAP;
|
usage |= D3DUSAGE_AUTOGENMIPMAP;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (FAILED(IDirect3DDevice9_CreateTexture(dev,
|
if (FAILED(IDirect3DDevice9_CreateTexture(dev,
|
||||||
width, height, miplevels, usage,
|
width, height, miplevels, usage,
|
||||||
(D3DFORMAT)format,
|
(D3DFORMAT)format,
|
||||||
(D3DPOOL)pool,
|
(D3DPOOL)pool,
|
||||||
(struct IDirect3DTexture9**)&buf, NULL)))
|
(struct IDirect3DTexture9**)&buf, NULL)))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -312,9 +309,10 @@ void *d3d9_vertex_buffer_new(void *_dev,
|
|||||||
usage = D3DUSAGE_SOFTWAREPROCESSING;
|
usage = D3DUSAGE_SOFTWAREPROCESSING;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (FAILED(IDirect3DDevice9_CreateVertexBuffer(dev, length, usage, fvf,
|
if (FAILED(IDirect3DDevice9_CreateVertexBuffer(
|
||||||
(D3DPOOL)pool,
|
dev, length, usage, fvf,
|
||||||
(LPDIRECT3DVERTEXBUFFER9*)&buf, NULL)))
|
(D3DPOOL)pool,
|
||||||
|
(LPDIRECT3DVERTEXBUFFER9*)&buf, NULL)))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return buf;
|
return buf;
|
||||||
@ -339,45 +337,6 @@ void d3d9_vertex_buffer_free(void *vertex_data, void *vertex_declaration)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool d3d9_device_create_offscreen_plain_surface(
|
|
||||||
void *_dev,
|
|
||||||
unsigned width,
|
|
||||||
unsigned height,
|
|
||||||
unsigned format,
|
|
||||||
unsigned pool,
|
|
||||||
void **surf_data,
|
|
||||||
void *data)
|
|
||||||
{
|
|
||||||
#ifndef _XBOX
|
|
||||||
LPDIRECT3DDEVICE9 dev = (LPDIRECT3DDEVICE9)_dev;
|
|
||||||
if (SUCCEEDED(IDirect3DDevice9_CreateOffscreenPlainSurface(dev,
|
|
||||||
width, height,
|
|
||||||
(D3DFORMAT)format, (D3DPOOL)pool,
|
|
||||||
(LPDIRECT3DSURFACE9*)surf_data,
|
|
||||||
(HANDLE*)data)))
|
|
||||||
return true;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool d3d9_device_get_render_target_data(void *_dev,
|
|
||||||
void *_src, void *_dst)
|
|
||||||
{
|
|
||||||
#ifndef _XBOX
|
|
||||||
LPDIRECT3DSURFACE9 src = (LPDIRECT3DSURFACE9)_src;
|
|
||||||
LPDIRECT3DSURFACE9 dst = (LPDIRECT3DSURFACE9)_dst;
|
|
||||||
LPDIRECT3DDEVICE9 dev = (LPDIRECT3DDEVICE9)_dev;
|
|
||||||
if (dev &&
|
|
||||||
SUCCEEDED(IDirect3DDevice9_GetRenderTargetData(
|
|
||||||
dev, src, dst)))
|
|
||||||
return true;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool d3d9_reset_internal(void *data,
|
static bool d3d9_reset_internal(void *data,
|
||||||
D3DPRESENT_PARAMETERS *d3dpp
|
D3DPRESENT_PARAMETERS *d3dpp
|
||||||
)
|
)
|
||||||
@ -478,16 +437,6 @@ bool d3d9_reset(void *dev, void *d3dpp)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void d3d9_device_free(void *_dev, void *_pd3d)
|
|
||||||
{
|
|
||||||
LPDIRECT3D9 pd3d = (LPDIRECT3D9)_pd3d;
|
|
||||||
LPDIRECT3DDEVICE9 dev = (LPDIRECT3DDEVICE9)_dev;
|
|
||||||
if (dev)
|
|
||||||
IDirect3DDevice9_Release(dev);
|
|
||||||
if (pd3d)
|
|
||||||
IDirect3D9_Release(pd3d);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool d3d9x_create_font_indirect(void *_dev,
|
bool d3d9x_create_font_indirect(void *_dev,
|
||||||
void *desc, void **font_data)
|
void *desc, void **font_data)
|
||||||
{
|
{
|
||||||
|
@ -448,8 +448,22 @@ static INLINE void d3d9_surface_free(LPDIRECT3DSURFACE9 surf)
|
|||||||
IDirect3DSurface9_Release(surf);
|
IDirect3DSurface9_Release(surf);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool d3d9_device_get_render_target_data(void *dev,
|
static INLINE bool d3d9_device_get_render_target_data(
|
||||||
void *_src, void *_dst);
|
void *_dev,
|
||||||
|
void *_src, void *_dst)
|
||||||
|
{
|
||||||
|
#ifndef _XBOX
|
||||||
|
LPDIRECT3DSURFACE9 src = (LPDIRECT3DSURFACE9)_src;
|
||||||
|
LPDIRECT3DSURFACE9 dst = (LPDIRECT3DSURFACE9)_dst;
|
||||||
|
LPDIRECT3DDEVICE9 dev = (LPDIRECT3DDEVICE9)_dev;
|
||||||
|
if (dev &&
|
||||||
|
SUCCEEDED(IDirect3DDevice9_GetRenderTargetData(
|
||||||
|
dev, src, dst)))
|
||||||
|
return true;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
static INLINE bool d3d9_device_get_render_target(
|
static INLINE bool d3d9_device_get_render_target(
|
||||||
LPDIRECT3DDEVICE9 dev,
|
LPDIRECT3DDEVICE9 dev,
|
||||||
@ -490,17 +504,26 @@ static INLINE bool d3d9_get_render_state(
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void d3d9_device_set_render_target(void *dev, unsigned idx,
|
static INLINE bool d3d9_device_create_offscreen_plain_surface(
|
||||||
void *data);
|
void *_dev,
|
||||||
|
|
||||||
bool d3d9_device_create_offscreen_plain_surface(
|
|
||||||
void *dev,
|
|
||||||
unsigned width,
|
unsigned width,
|
||||||
unsigned height,
|
unsigned height,
|
||||||
unsigned format,
|
unsigned format,
|
||||||
unsigned pool,
|
unsigned pool,
|
||||||
void **surf_data,
|
void **surf_data,
|
||||||
void *data);
|
void *data)
|
||||||
|
{
|
||||||
|
#ifndef _XBOX
|
||||||
|
LPDIRECT3DDEVICE9 dev = (LPDIRECT3DDEVICE9)_dev;
|
||||||
|
if (SUCCEEDED(IDirect3DDevice9_CreateOffscreenPlainSurface(dev,
|
||||||
|
width, height,
|
||||||
|
(D3DFORMAT)format, (D3DPOOL)pool,
|
||||||
|
(LPDIRECT3DSURFACE9*)surf_data,
|
||||||
|
(HANDLE*)data)))
|
||||||
|
return true;
|
||||||
|
#endif
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
static INLINE bool d3d9_surface_lock_rect(LPDIRECT3DSURFACE9 surf,
|
static INLINE bool d3d9_surface_lock_rect(LPDIRECT3DSURFACE9 surf,
|
||||||
D3DLOCKED_RECT *data2)
|
D3DLOCKED_RECT *data2)
|
||||||
@ -564,7 +587,15 @@ static INLINE bool d3d9_device_get_backbuffer(
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void d3d9_device_free(void *dev, void *pd3d);
|
static INLINE void d3d9_device_free(void *_dev, void *_pd3d)
|
||||||
|
{
|
||||||
|
LPDIRECT3D9 pd3d = (LPDIRECT3D9)_pd3d;
|
||||||
|
LPDIRECT3DDEVICE9 dev = (LPDIRECT3DDEVICE9)_dev;
|
||||||
|
if (dev)
|
||||||
|
IDirect3DDevice9_Release(dev);
|
||||||
|
if (pd3d)
|
||||||
|
IDirect3D9_Release(pd3d);
|
||||||
|
}
|
||||||
|
|
||||||
void *d3d9_create(void);
|
void *d3d9_create(void);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user