void d3d_texture_blit(unsigned pixel_size, LPDIRECT3DTEXTURE tex, D3DLOCKED_RECT *lr, const void *frame, unsigned width, unsigned height, unsigned pitch) { #ifdef _XBOX D3DTexture_LockRect(tex, 0, lr, NULL, D3DLOCK_NOSYSLOCK); #if defined(_XBOX360) D3DSURFACE_DESC desc; tex->GetLevelDesc(0, &desc); XGCopySurface(lr->pBits, lr->Pitch, width, height, desc.Format, NULL, frame, pitch, desc.Format, NULL, 0, 0); #elif defined(_XBOX1) 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 D3DTexture_UnlockRect(tex, 0); #else if (SUCCEEDED(tex->LockRect(0, lr, NULL, D3DLOCK_NOSYSLOCK))) { 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); } tex->UnlockRect(0); } #endif }
void d3d_unlock_rectangle(LPDIRECT3DTEXTURE tex) { #ifdef _XBOX D3DTexture_UnlockRect(tex, 0); #else #if defined(HAVE_D3D9) && !defined(__cplusplus) IDirect3DSurface9_UnlockRect(tex); #else tex->UnlockRect(0); #endif #endif }
void d3d_texture_blit(void *data, unsigned pixel_size, LPDIRECT3DTEXTURE tex, D3DLOCKED_RECT *lr, const void *frame, unsigned width, unsigned height, unsigned pitch) { unsigned y; d3d_video_t *d3d = (d3d_video_t*)data; (void)y; if (!d3d) return; #ifdef _XBOX /* Set the texture to NULL so D3D doesn't complain about it being in use... */ d3d_set_texture(d3d->dev, 0, NULL); D3DTexture_LockRect(tex, 0, lr, NULL, D3DLOCK_NOSYSLOCK); #if defined(_XBOX360) D3DSURFACE_DESC desc; tex->GetLevelDesc(0, &desc); XGCopySurface(lr->pBits, lr->Pitch, width, height, desc.Format, NULL, frame, pitch, desc.Format, NULL, 0, 0); #elif defined(_XBOX1) 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 * d3d->pixel_size); } #endif D3DTexture_UnlockRect(tex, 0); #else if (SUCCEEDED(tex->LockRect(0, lr, NULL, D3DLOCK_NOSYSLOCK))) { 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); } tex->UnlockRect(0); } #endif }