Add more d3d_wrapper functions

This commit is contained in:
twinaphex 2015-11-09 15:34:16 +01:00
parent 4f0405980e
commit 3a9ee7feae
4 changed files with 32 additions and 6 deletions

View File

@ -299,22 +299,38 @@ void d3d_clear(LPDIRECT3DDEVICE dev,
#endif #endif
} }
void d3d_lockrectangle_clear(LPDIRECT3DTEXTURE tex, void d3d_lockrectangle(LPDIRECT3DTEXTURE tex,
unsigned level, D3DLOCKED_RECT *lock_rect, RECT *rect, unsigned level, D3DLOCKED_RECT *lock_rect, RECT *rect,
unsigned rectangle_height, unsigned flags) unsigned rectangle_height, unsigned flags)
{ {
#if defined(_XBOX) #if defined(_XBOX)
D3DTexture_LockRect(tex, level, lock_rect, rect, flags); D3DTexture_LockRect(tex, level, lock_rect, rect, flags);
memset(lock_rect->pBits, 0, rectangle_height * lock_rect->Pitch); return true;
#else #else
if (SUCCEEDED(tex->LockRect(level, lock_rect, rect, flags))) if (SUCCEEDED(tex->LockRect(level, lock_rect, rect, flags)))
{ return true;
memset(lock_rect->pBits, level, rectangle_height * lock_rect->Pitch); return false;
tex->UnlockRect(0);
}
#endif #endif
} }
void d3d_unlockrectangle_clear(LPDIRECT3DTEXTURE tex)
{
#ifndef _XBOX
tex->UnlockRect(0);
#endif
}
void d3d_lockrectangle_clear(LPDIRECT3DTEXTURE tex,
unsigned level, D3DLOCKED_RECT *lock_rect, RECT *rect,
unsigned rectangle_height, unsigned flags)
{
#if defined(_XBOX)
level = 0;
#endif
memset(lock_rect->pBits, level, rectangle_height * lock_rect->Pitch);
d3d_unlockrectangle_clear(tex);
}
void d3d_set_viewport(LPDIRECT3DDEVICE dev, D3DVIEWPORT *vp) void d3d_set_viewport(LPDIRECT3DDEVICE dev, D3DVIEWPORT *vp)
{ {
if (!d3d_restore_device(dev)) if (!d3d_restore_device(dev))

View File

@ -72,10 +72,16 @@ void d3d_clear(LPDIRECT3DDEVICE dev,
unsigned count, const D3DRECT *rects, unsigned flags, unsigned count, const D3DRECT *rects, unsigned flags,
D3DCOLOR color, float z, unsigned stencil); D3DCOLOR color, float z, unsigned stencil);
void d3d_lockrectangle(LPDIRECT3DTEXTURE tex,
unsigned level, D3DLOCKED_RECT *lock_rect, RECT *rect,
unsigned rectangle_height, unsigned flags);
void d3d_lockrectangle_clear(LPDIRECT3DTEXTURE tex, void d3d_lockrectangle_clear(LPDIRECT3DTEXTURE tex,
unsigned level, D3DLOCKED_RECT *lock_rect, RECT *rect, unsigned level, D3DLOCKED_RECT *lock_rect, RECT *rect,
unsigned rectangle_height, unsigned flags); unsigned rectangle_height, unsigned flags);
void d3d_unlockrectangle_clear(LPDIRECT3DTEXTURE tex);
void d3d_set_texture(LPDIRECT3DDEVICE dev, unsigned sampler, void d3d_set_texture(LPDIRECT3DDEVICE dev, unsigned sampler,
LPDIRECT3DTEXTURE tex); LPDIRECT3DTEXTURE tex);

View File

@ -1338,6 +1338,8 @@ static void renderchain_blit_to_texture(void *data,
if (first->last_width != width || first->last_height != height) if (first->last_width != width || first->last_height != height)
{ {
d3d_lockrectangle(first->tex, 0, &d3dlr,
NULL, first->info.tex_h, D3DLOCK_NOSYSLOCK);
d3d_lockrectangle_clear(first->tex, 0, &d3dlr, d3d_lockrectangle_clear(first->tex, 0, &d3dlr,
NULL, first->info.tex_h, D3DLOCK_NOSYSLOCK); NULL, first->info.tex_h, D3DLOCK_NOSYSLOCK);
} }

View File

@ -234,6 +234,8 @@ static void renderchain_blit_to_texture(void *data, const void *frame,
if (chain->last_width != width || chain->last_height != height) if (chain->last_width != width || chain->last_height != height)
{ {
d3d_lockrectangle(chain->tex,
0, &d3dlr, NULL, chain->tex_h, D3DLOCK_NOSYSLOCK);
d3d_lockrectangle_clear(chain->tex, d3d_lockrectangle_clear(chain->tex,
0, &d3dlr, NULL, chain->tex_h, D3DLOCK_NOSYSLOCK); 0, &d3dlr, NULL, chain->tex_h, D3DLOCK_NOSYSLOCK);
} }