(D3D9) Cleanups

This commit is contained in:
twinaphex 2022-04-22 16:21:27 +02:00
parent 845a469d4c
commit 90f53bf6f4
3 changed files with 25 additions and 46 deletions

View File

@ -222,24 +222,6 @@ static INLINE void d3d9_free_pixel_shader(LPDIRECT3DDEVICE9 dev,
IDirect3DPixelShader9_Release(ps);
}
static INLINE bool d3d9_set_vertex_shader_constantf(
LPDIRECT3DDEVICE9 dev,
UINT start_register,
const float* constant_data,
unsigned vector4f_count)
{
#ifdef _XBOX
IDirect3DDevice9_SetVertexShaderConstantF(dev,
start_register, constant_data, vector4f_count);
#else
if (IDirect3DDevice9_SetVertexShaderConstantF(dev,
start_register, constant_data, vector4f_count) != D3D_OK)
return false;
#endif
return true;
}
static INLINE void d3d9_texture_blit(
unsigned pixel_size,
void *tex,

View File

@ -1811,7 +1811,8 @@ static bool d3d9_cg_frame(void *data, const void *frame,
IDirect3DDevice9_Clear(d3d->dev, 0, 0, D3DCLEAR_TARGET,
0, 1, 0);
d3d9_set_vertex_shader_constantf(d3d->dev, 0, (const float*)&d3d->mvp, 4);
IDirect3DDevice9_SetVertexShaderConstantF(d3d->dev,
0, (const float*)&d3d->mvp, 4);
if (!d3d9_cg_renderchain_render(
d3d, frame, frame_width, frame_height,
pitch, d3d->dev_rotation))
@ -1837,7 +1838,8 @@ static bool d3d9_cg_frame(void *data, const void *frame,
#ifdef HAVE_OVERLAY
if (d3d->overlays_enabled && overlay_behind_menu)
{
d3d9_set_vertex_shader_constantf(d3d->dev, 0, (const float*)&d3d->mvp, 4);
IDirect3DDevice9_SetVertexShaderConstantF(d3d->dev,
0, (const float*)&d3d->mvp, 4);
for (i = 0; i < d3d->overlays_size; i++)
d3d9_overlay_render(d3d, width, height, &d3d->overlays[i], true);
}
@ -1846,8 +1848,8 @@ static bool d3d9_cg_frame(void *data, const void *frame,
#ifdef HAVE_MENU
if (d3d->menu && d3d->menu->enabled)
{
d3d9_set_vertex_shader_constantf(d3d->dev, 0, (const
float*)&d3d->mvp, 4);
IDirect3DDevice9_SetVertexShaderConstantF(d3d->dev,
0, (const float*)&d3d->mvp, 4);
d3d9_overlay_render(d3d, width, height, d3d->menu, false);
d3d->menu_display.offset = 0;
@ -1873,8 +1875,8 @@ static bool d3d9_cg_frame(void *data, const void *frame,
#ifdef HAVE_OVERLAY
if (d3d->overlays_enabled && !overlay_behind_menu)
{
d3d9_set_vertex_shader_constantf(d3d->dev, 0, (const
float*)&d3d->mvp, 4);
IDirect3DDevice9_SetVertexShaderConstantF(d3d->dev,
0, (const float*)&d3d->mvp, 4);
for (i = 0; i < d3d->overlays_size; i++)
d3d9_overlay_render(d3d, width, height, &d3d->overlays[i], true);
}

View File

@ -102,25 +102,6 @@ static void gfx_display_d3d9_cg_blend_end(void *data)
IDirect3DDevice9_SetRenderState(d3d->dev, D3DRS_ALPHABLENDENABLE, false);
}
static void gfx_display_d3d9_cg_bind_texture(gfx_display_ctx_draw_t *draw,
d3d9_video_t *d3d)
{
LPDIRECT3DDEVICE9 dev = d3d->dev;
IDirect3DDevice9_SetTexture(dev, 0,
(IDirect3DBaseTexture9*)draw->texture);
IDirect3DDevice9_SetSamplerState(dev,
0, D3DSAMP_ADDRESSU, D3DTADDRESS_COMM_CLAMP);
IDirect3DDevice9_SetSamplerState(dev,
0, D3DSAMP_ADDRESSV, D3DTADDRESS_COMM_CLAMP);
IDirect3DDevice9_SetSamplerState(dev,
0, D3DSAMP_MINFILTER, D3DTEXF_COMM_LINEAR);
IDirect3DDevice9_SetSamplerState(dev,
0, D3DSAMP_MAGFILTER, D3DTEXF_COMM_LINEAR);
IDirect3DDevice9_SetSamplerState(dev, 0,
D3DSAMP_MIPFILTER, D3DTEXF_COMM_LINEAR);
}
static void gfx_display_d3d9_cg_draw(gfx_display_ctx_draw_t *draw,
void *data, unsigned video_width, unsigned video_height)
{
@ -209,10 +190,24 @@ static void gfx_display_d3d9_cg_draw(gfx_display_ctx_draw_t *draw,
matrix_4x4_multiply(m2, d3d->mvp_transposed, m1);
d3d_matrix_transpose(&m1, &m2);
d3d9_set_vertex_shader_constantf(d3d->dev, 0, (const float*)&m1, 4);
IDirect3DDevice9_SetVertexShaderConstantF(dev,
0, (const float*)&m1, 4);
if (draw && draw->texture)
gfx_display_d3d9_cg_bind_texture(draw, d3d);
if (draw->texture)
{
IDirect3DDevice9_SetTexture(dev, 0,
(IDirect3DBaseTexture9*)draw->texture);
IDirect3DDevice9_SetSamplerState(dev,
0, D3DSAMP_ADDRESSU, D3DTADDRESS_COMM_CLAMP);
IDirect3DDevice9_SetSamplerState(dev,
0, D3DSAMP_ADDRESSV, D3DTADDRESS_COMM_CLAMP);
IDirect3DDevice9_SetSamplerState(dev,
0, D3DSAMP_MINFILTER, D3DTEXF_COMM_LINEAR);
IDirect3DDevice9_SetSamplerState(dev,
0, D3DSAMP_MAGFILTER, D3DTEXF_COMM_LINEAR);
IDirect3DDevice9_SetSamplerState(dev, 0,
D3DSAMP_MIPFILTER, D3DTEXF_COMM_LINEAR);
}
type = (D3DPRIMITIVETYPE)gfx_display_prim_to_d3d9_cg_enum(draw->prim_type);
start = d3d->menu_display.offset;