mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-24 16:39:43 +00:00
Rewrite d3d_texture_blit
This commit is contained in:
parent
86385dcaf7
commit
e32ceb8f30
@ -1206,27 +1206,24 @@ bool d3d_set_vertex_shader_constantf(LPDIRECT3DDEVICE dev,
|
||||
}
|
||||
|
||||
void d3d_texture_blit(unsigned pixel_size,
|
||||
LPDIRECT3DTEXTURE tex, D3DLOCKED_RECT *lr, const void *frame,
|
||||
LPDIRECT3DTEXTURE tex,
|
||||
D3DLOCKED_RECT *lr, const void *frame,
|
||||
unsigned width, unsigned height, unsigned pitch)
|
||||
{
|
||||
if (d3d_lock_rectangle(tex, 0, lr, NULL, 0, 0))
|
||||
{
|
||||
#if defined(_XBOX360)
|
||||
D3DSURFACE_DESC 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);
|
||||
D3DSURFACE_DESC 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
|
||||
unsigned y;
|
||||
for (y = 0; y < height; y++)
|
||||
{
|
||||
const uint8_t *in = (const uint8_t*)frame + y * pitch;
|
||||
uint8_t *out = (uint8_t*)lr->pBits + y * lr->Pitch;
|
||||
memcpy(out, in, width * pixel_size);
|
||||
}
|
||||
#endif
|
||||
d3d_unlock_rectangle(tex);
|
||||
unsigned y;
|
||||
for (y = 0; y < height; y++)
|
||||
{
|
||||
const uint8_t *in = (const uint8_t*)frame + y * pitch;
|
||||
uint8_t *out = (uint8_t*)lr->pBits + y * lr->Pitch;
|
||||
memcpy(out, in, width * pixel_size);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
bool d3d_get_render_state(void *data, D3DRENDERSTATETYPE state, DWORD *value)
|
||||
|
@ -189,8 +189,13 @@ static void d3d8_renderchain_blit_to_texture(void *data, const void *frame,
|
||||
|
||||
/* Set the texture to NULL so D3D doesn't complain about it being in use... */
|
||||
d3d_set_texture(d3dr, 0, NULL);
|
||||
d3d_texture_blit(chain->pixel_size, chain->tex,
|
||||
&d3dlr, frame, width, height, pitch);
|
||||
|
||||
if (d3d_lock_rectangle(chain->tex, 0, &d3dlr, NULL, 0, 0))
|
||||
{
|
||||
d3d_texture_blit(chain->pixel_size, chain->tex,
|
||||
&d3dlr, frame, width, height, pitch);
|
||||
d3d_unlock_rectangle(chain->tex);
|
||||
}
|
||||
}
|
||||
|
||||
static void d3d8_renderchain_deinit(void *data)
|
||||
|
@ -74,6 +74,7 @@ struct CGVertex
|
||||
struct Pass
|
||||
{
|
||||
struct LinkInfo info;
|
||||
D3DPOOL pool;
|
||||
LPDIRECT3DTEXTURE tex;
|
||||
LPDIRECT3DVERTEXBUFFER vertex_buf;
|
||||
CGprogram vPrg, fPrg;
|
||||
@ -939,6 +940,7 @@ static bool d3d9_cg_renderchain_set_pass_size(
|
||||
|
||||
pass->info.tex_w = width;
|
||||
pass->info.tex_h = height;
|
||||
pass->pool = D3DPOOL_DEFAULT;
|
||||
pass->tex = d3d_texture_new(chain->dev, NULL,
|
||||
width, height, 1,
|
||||
D3DUSAGE_RENDERTARGET,
|
||||
@ -1078,6 +1080,7 @@ static bool d3d9_cg_renderchain_add_pass(
|
||||
pass.last_width = 0;
|
||||
pass.last_height = 0;
|
||||
pass.attrib_map = unsigned_vector_list_new();
|
||||
pass.pool = D3DPOOL_DEFAULT;
|
||||
|
||||
d3d9_cg_load_program(chain, &pass.fPrg,
|
||||
&pass.vPrg, info->pass->source.path, true);
|
||||
@ -1339,7 +1342,9 @@ static void cg_d3d9_renderchain_blit_to_texture(
|
||||
D3DLOCKED_RECT d3dlr;
|
||||
struct Pass *first = (struct Pass*)&chain->passes->data[0];
|
||||
|
||||
if (first->last_width != width || first->last_height != height)
|
||||
if (
|
||||
(first->last_width != width || first->last_height != height)
|
||||
)
|
||||
{
|
||||
d3d_lock_rectangle(first->tex, 0, &d3dlr,
|
||||
NULL, first->info.tex_h, D3DLOCK_NOSYSLOCK);
|
||||
@ -1347,8 +1352,12 @@ static void cg_d3d9_renderchain_blit_to_texture(
|
||||
NULL, first->info.tex_h, D3DLOCK_NOSYSLOCK);
|
||||
}
|
||||
|
||||
d3d_texture_blit(chain->pixel_size, first->tex,
|
||||
&d3dlr, frame, width, height, pitch);
|
||||
if (d3d_lock_rectangle(first->tex, 0, &d3dlr, NULL, 0, 0))
|
||||
{
|
||||
d3d_texture_blit(chain->pixel_size, first->tex,
|
||||
&d3dlr, frame, width, height, pitch);
|
||||
d3d_unlock_rectangle(first->tex);
|
||||
}
|
||||
}
|
||||
|
||||
static void cg_d3d9_renderchain_unbind_all(cg_renderchain_t *chain)
|
||||
|
@ -233,8 +233,13 @@ static void hlsl_d3d9_renderchain_blit_to_texture(
|
||||
|
||||
/* Set the texture to NULL so D3D doesn't complain about it being in use... */
|
||||
d3d_set_texture(d3dr, 0, NULL);
|
||||
d3d_texture_blit(chain->pixel_size, chain->tex,
|
||||
&d3dlr, frame, width, height, pitch);
|
||||
|
||||
if (d3d_lock_rectangle(chain->tex, 0, &d3dlr, NULL, 0, 0))
|
||||
{
|
||||
d3d_texture_blit(chain->pixel_size, chain->tex,
|
||||
&d3dlr, frame, width, height, pitch);
|
||||
d3d_unlock_rectangle(chain->tex);
|
||||
}
|
||||
}
|
||||
|
||||
static void hlsl_d3d9_renderchain_deinit(void *data)
|
||||
|
Loading…
Reference in New Issue
Block a user