From 27caf46616a01b954618a3fc99b9ab1bd3e72bb1 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 15 Jan 2018 06:14:20 +0100 Subject: [PATCH] Add d3d_get_render_state --- gfx/common/d3d_common.c | 20 ++++++++++++++++++++ gfx/common/d3d_common.h | 6 +++++- gfx/drivers_font/xdk360_fonts.cpp | 6 +++--- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/gfx/common/d3d_common.c b/gfx/common/d3d_common.c index 0b026f15ab..bd64b86933 100644 --- a/gfx/common/d3d_common.c +++ b/gfx/common/d3d_common.c @@ -1223,6 +1223,26 @@ void d3d_texture_blit(unsigned pixel_size, } } +bool d3d_get_render_state(void *data, D3DRENDERSTATETYPE state, DWORD *value) +{ + LPDIRECT3DDEVICE dev = (LPDIRECT3DDEVICE)data; + + if (!dev) + return false; + +#if defined(HAVE_D3D9) && !defined(__cplusplus) + if (IDirect3DDevice9_GetRenderState(dev, state, value) == D3D_OK) + return true; +#elif defined(HAVE_D3D8) && !defined(__cplusplus) + if (IDirect3DDevice8_GetRenderState(dev, state, value) == D3D_OK) + return true; +#else + if (dev->GetRenderState(state, value) == D3D_OK) + return true; +#endif + return false; +} + void d3d_set_render_state(void *data, D3DRENDERSTATETYPE state, DWORD value) { LPDIRECT3DDEVICE dev = (LPDIRECT3DDEVICE)data; diff --git a/gfx/common/d3d_common.h b/gfx/common/d3d_common.h index 913fb031af..ab65dbdee1 100644 --- a/gfx/common/d3d_common.h +++ b/gfx/common/d3d_common.h @@ -147,7 +147,11 @@ bool d3d_device_get_render_target(LPDIRECT3DDEVICE dev, void d3d_device_set_render_target(LPDIRECT3DDEVICE dev, unsigned idx, void *data); -void d3d_set_render_state(void *data, D3DRENDERSTATETYPE state, DWORD value); +bool d3d_get_render_state(void *data, + D3DRENDERSTATETYPE state, DWORD *value); + +void d3d_set_render_state(void *data, + D3DRENDERSTATETYPE state, DWORD value); void d3d_device_set_render_target(LPDIRECT3DDEVICE dev, unsigned idx, void *data); diff --git a/gfx/drivers_font/xdk360_fonts.cpp b/gfx/drivers_font/xdk360_fonts.cpp index 55e26178d2..32685b35fd 100644 --- a/gfx/drivers_font/xdk360_fonts.cpp +++ b/gfx/drivers_font/xdk360_fonts.cpp @@ -630,7 +630,8 @@ static void xdk360_render_msg_pre(xdk360_video_font_t * font) LPDIRECT3DDEVICE d3dr = font->d3d->dev; /* Save state. */ - d3dr->GetRenderState( D3DRS_VIEWPORTENABLE, (DWORD*)&font->m_dwSavedState ); + d3d_get_render_state(d3dr, D3DRS_VIEWPORTENABLE, + (DWORD*)&font->m_dwSavedState ); /* Set the texture scaling factor as a vertex shader constant. */ /* Get the description */ @@ -639,8 +640,7 @@ static void xdk360_render_msg_pre(xdk360_video_font_t * font) /* Set render state. */ d3d_set_texture(d3dr, 0, font->m_pFontTexture); - /* Read the TextureDesc here to ensure no load/hit/store from d3d_texture_get_level_desc(). */ - vTexScale[0] = 1.0f / TextureDesc.Width; /* LHS due to int->float conversion. */ + vTexScale[0] = 1.0f / TextureDesc.Width; vTexScale[1] = 1.0f / TextureDesc.Height; vTexScale[2] = 0.0f; vTexScale[3] = 0.0f;