From cedf77d87fd7b883f29a457309a13a2c284fc0b8 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 22 Apr 2022 13:50:36 +0200 Subject: [PATCH] Move d3d9_renderchain_blit_to_texture to d3d9_common.c --- gfx/common/d3d9_common.c | 28 ++++++++++++++++++++++++++++ gfx/common/d3d9_common.h | 8 ++++++++ gfx/drivers/d3d8.c | 4 ++-- gfx/drivers/d3d9_renderchain.h | 28 ---------------------------- gfx/drivers/d3d9cg.c | 2 +- gfx/drivers/d3d9hlsl.c | 2 +- 6 files changed, 40 insertions(+), 32 deletions(-) diff --git a/gfx/common/d3d9_common.c b/gfx/common/d3d9_common.c index e05d8d60e6..23dadc22f0 100644 --- a/gfx/common/d3d9_common.c +++ b/gfx/common/d3d9_common.c @@ -1506,6 +1506,34 @@ void d3d9_set_rotation(void *data, unsigned rot) d3d->dev_rotation = rot; } +void d3d9_blit_to_texture( + LPDIRECT3DTEXTURE9 tex, + const void *frame, + unsigned tex_width, unsigned tex_height, + unsigned width, unsigned height, + unsigned last_width, unsigned last_height, + unsigned pitch, unsigned pixel_size) +{ + D3DLOCKED_RECT d3dlr = {0, NULL}; + + if ( + (last_width != width || last_height != height) + ) + { + d3d9_lock_rectangle(tex, 0, &d3dlr, + NULL, tex_height, D3DLOCK_NOSYSLOCK); + d3d9_lock_rectangle_clear(tex, 0, &d3dlr, + NULL, tex_height, D3DLOCK_NOSYSLOCK); + } + + if (d3d9_lock_rectangle(tex, 0, &d3dlr, NULL, 0, 0)) + { + d3d9_texture_blit(pixel_size, tex, + &d3dlr, frame, width, height, pitch); + d3d9_unlock_rectangle(tex); + } +} + #ifdef HAVE_OVERLAY void d3d9_free_overlays(d3d9_video_t *d3d) { diff --git a/gfx/common/d3d9_common.h b/gfx/common/d3d9_common.h index 53cb6759e1..dc50079752 100644 --- a/gfx/common/d3d9_common.h +++ b/gfx/common/d3d9_common.h @@ -785,6 +785,14 @@ void d3d9_set_viewport(void *data, void d3d9_set_menu_texture_enable(void *data, bool state, bool full_screen); +void d3d9_blit_to_texture( + LPDIRECT3DTEXTURE9 tex, + const void *frame, + unsigned tex_width, unsigned tex_height, + unsigned width, unsigned height, + unsigned last_width, unsigned last_height, + unsigned pitch, unsigned pixel_size); + void d3d9_apply_state_changes(void *data); extern LPDIRECT3D9 g_pD3D9; diff --git a/gfx/drivers/d3d8.c b/gfx/drivers/d3d8.c index 3a22d9594c..fea141f2cf 100644 --- a/gfx/drivers/d3d8.c +++ b/gfx/drivers/d3d8.c @@ -214,7 +214,7 @@ static void d3d8_renderchain_set_vertices( } } -static void d3d8_renderchain_blit_to_texture( +static void d3d8_blit_to_texture( d3d8_renderchain_t *chain, const void *frame, unsigned width, unsigned height, unsigned pitch) @@ -318,7 +318,7 @@ static bool d3d8_renderchain_render( LPDIRECT3DDEVICE8 d3dr = (LPDIRECT3DDEVICE8)d3d->dev; d3d8_renderchain_t *chain = (d3d8_renderchain_t*)d3d->renderchain_data; - d3d8_renderchain_blit_to_texture(chain, frame, frame_width, frame_height, pitch); + d3d8_blit_to_texture(chain, frame, frame_width, frame_height, pitch); d3d8_renderchain_set_vertices(d3d, chain, 1, frame_width, frame_height, chain->frame_count); d3d8_renderchain_render_pass(d3d, d3dr, chain, 0, rotation); diff --git a/gfx/drivers/d3d9_renderchain.h b/gfx/drivers/d3d9_renderchain.h index 37083113b4..5cb04e79ca 100644 --- a/gfx/drivers/d3d9_renderchain.h +++ b/gfx/drivers/d3d9_renderchain.h @@ -367,34 +367,6 @@ static INLINE void d3d9_init_renderchain(d3d9_renderchain_t *chain) chain->bound_vert = unsigned_vector_list_new(); } -static INLINE void d3d9_renderchain_blit_to_texture( - LPDIRECT3DTEXTURE9 tex, - const void *frame, - unsigned tex_width, unsigned tex_height, - unsigned width, unsigned height, - unsigned last_width, unsigned last_height, - unsigned pitch, unsigned pixel_size) -{ - D3DLOCKED_RECT d3dlr = {0, NULL}; - - if ( - (last_width != width || last_height != height) - ) - { - d3d9_lock_rectangle(tex, 0, &d3dlr, - NULL, tex_height, D3DLOCK_NOSYSLOCK); - d3d9_lock_rectangle_clear(tex, 0, &d3dlr, - NULL, tex_height, D3DLOCK_NOSYSLOCK); - } - - if (d3d9_lock_rectangle(tex, 0, &d3dlr, NULL, 0, 0)) - { - d3d9_texture_blit(pixel_size, tex, - &d3dlr, frame, width, height, pitch); - d3d9_unlock_rectangle(tex); - } -} - RETRO_END_DECLS #endif diff --git a/gfx/drivers/d3d9cg.c b/gfx/drivers/d3d9cg.c index 841167a060..b33daac56f 100644 --- a/gfx/drivers/d3d9cg.c +++ b/gfx/drivers/d3d9cg.c @@ -1133,7 +1133,7 @@ static bool d3d9_cg_renderchain_render( &out_width, &out_height, current_width, current_height, chain->final_viewport); - d3d9_renderchain_blit_to_texture(first_pass->tex, + d3d9_blit_to_texture(first_pass->tex, frame_data, first_pass->info.tex_w, first_pass->info.tex_h, diff --git a/gfx/drivers/d3d9hlsl.c b/gfx/drivers/d3d9hlsl.c index 0d8ee62df3..075fba8e50 100644 --- a/gfx/drivers/d3d9hlsl.c +++ b/gfx/drivers/d3d9hlsl.c @@ -689,7 +689,7 @@ static bool hlsl_d3d9_renderchain_render( &out_width, &out_height, current_width, current_height, chain->chain.final_viewport); - d3d9_renderchain_blit_to_texture(first_pass->tex, + d3d9_blit_to_texture(first_pass->tex, frame, first_pass->info.tex_w, first_pass->info.tex_h,