wined3d: Move texture->sysmem specific code into its special function.

This commit is contained in:
Stefan Dösinger 2007-11-02 21:28:11 +01:00 committed by Alexandre Julliard
parent 4678cd75be
commit d97e3fd086
1 changed files with 26 additions and 22 deletions

View File

@ -37,6 +37,28 @@ HRESULT d3dfmt_convert_surface(BYTE *src, BYTE *dst, UINT pitch, UINT width, UIN
static void d3dfmt_p8_init_palette(IWineD3DSurfaceImpl *This, BYTE table[256][4], BOOL colorkey); static void d3dfmt_p8_init_palette(IWineD3DSurfaceImpl *This, BYTE table[256][4], BOOL colorkey);
static void surface_download_data(IWineD3DSurfaceImpl *This) { static void surface_download_data(IWineD3DSurfaceImpl *This) {
IWineD3DDeviceImpl *myDevice = This->resource.wineD3DDevice;
if (0 == This->glDescription.textureName) {
ERR("Surface does not have a texture, but SFLAG_INTEXTURE is set\n");
return;
}
if(myDevice->createParms.BehaviorFlags & WINED3DCREATE_MULTITHREADED) {
ActivateContext(myDevice, myDevice->lastActiveRenderTarget, CTXUSAGE_RESOURCELOAD);
}
ENTER_GL();
/* Make sure that a proper texture unit is selected, bind the texture
* and dirtify the sampler to restore the texture on the next draw
*/
if (GL_SUPPORT(ARB_MULTITEXTURE)) {
GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB));
checkGLcall("glActiveTextureARB");
}
IWineD3DDeviceImpl_MarkStateDirty(This->resource.wineD3DDevice, STATE_SAMPLER(0));
IWineD3DSurface_PreLoad((IWineD3DSurface *) This);
if (This->resource.format == WINED3DFMT_DXT1 || if (This->resource.format == WINED3DFMT_DXT1 ||
This->resource.format == WINED3DFMT_DXT2 || This->resource.format == WINED3DFMT_DXT3 || This->resource.format == WINED3DFMT_DXT2 || This->resource.format == WINED3DFMT_DXT3 ||
This->resource.format == WINED3DFMT_DXT4 || This->resource.format == WINED3DFMT_DXT5) { This->resource.format == WINED3DFMT_DXT4 || This->resource.format == WINED3DFMT_DXT5) {
@ -58,6 +80,7 @@ static void surface_download_data(IWineD3DSurfaceImpl *This) {
checkGLcall("glGetCompressedTexImageARB()"); checkGLcall("glGetCompressedTexImageARB()");
} }
} }
LEAVE_GL();
} else { } else {
void *mem; void *mem;
int src_pitch = 0; int src_pitch = 0;
@ -65,6 +88,7 @@ static void surface_download_data(IWineD3DSurfaceImpl *This) {
if(This->Flags & SFLAG_CONVERTED) { if(This->Flags & SFLAG_CONVERTED) {
FIXME("Read back converted textures unsupported\n"); FIXME("Read back converted textures unsupported\n");
LEAVE_GL();
return; return;
} }
@ -96,6 +120,7 @@ static void surface_download_data(IWineD3DSurfaceImpl *This) {
This->glDescription.glType, mem); This->glDescription.glType, mem);
checkGLcall("glGetTexImage()"); checkGLcall("glGetTexImage()");
} }
LEAVE_GL();
if (This->Flags & SFLAG_NONPOW2) { if (This->Flags & SFLAG_NONPOW2) {
LPBYTE src_data, dst_data; LPBYTE src_data, dst_data;
@ -163,6 +188,7 @@ static void surface_download_data(IWineD3DSurfaceImpl *This) {
HeapFree(GetProcessHeap(), 0, mem); HeapFree(GetProcessHeap(), 0, mem);
} }
} }
/* Surface has now been downloaded */ /* Surface has now been downloaded */
This->Flags |= SFLAG_INSYSMEM; This->Flags |= SFLAG_INSYSMEM;
} }
@ -3556,7 +3582,6 @@ static inline void surface_blt_to_drawable(IWineD3DSurfaceImpl *This, const RECT
static HRESULT WINAPI IWineD3DSurfaceImpl_LoadLocation(IWineD3DSurface *iface, DWORD flag, const RECT *rect) { static HRESULT WINAPI IWineD3DSurfaceImpl_LoadLocation(IWineD3DSurface *iface, DWORD flag, const RECT *rect) {
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface; IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
IWineD3DDeviceImpl *device = This->resource.wineD3DDevice; IWineD3DDeviceImpl *device = This->resource.wineD3DDevice;
IWineD3DDeviceImpl *myDevice;
GLenum format, internal, type; GLenum format, internal, type;
CONVERT_TYPES convert; CONVERT_TYPES convert;
int bpp; int bpp;
@ -3581,34 +3606,13 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_LoadLocation(IWineD3DSurface *iface, D
This->Flags |= SFLAG_LOST; This->Flags |= SFLAG_LOST;
return WINED3DERR_DEVICELOST; return WINED3DERR_DEVICELOST;
} }
myDevice = This->resource.wineD3DDevice;
if(flag == SFLAG_INSYSMEM) { if(flag == SFLAG_INSYSMEM) {
surface_prepare_system_memory(This); surface_prepare_system_memory(This);
/* Download the surface to system memory */ /* Download the surface to system memory */
if(This->Flags & SFLAG_INTEXTURE) { if(This->Flags & SFLAG_INTEXTURE) {
if (0 == This->glDescription.textureName) {
ERR("Surface does not have a texture, but SFLAG_INTEXTURE is set\n");
}
if(myDevice->createParms.BehaviorFlags & WINED3DCREATE_MULTITHREADED) {
ActivateContext(myDevice, myDevice->lastActiveRenderTarget, CTXUSAGE_RESOURCELOAD);
}
ENTER_GL();
/* Make sure that a proper texture unit is selected, bind the texture
* and dirtify the sampler to restore the texture on the next draw
*/
if (GL_SUPPORT(ARB_MULTITEXTURE)) {
GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB));
checkGLcall("glActiveTextureARB");
}
IWineD3DDeviceImpl_MarkStateDirty(This->resource.wineD3DDevice, STATE_SAMPLER(0));
IWineD3DSurface_PreLoad(iface);
surface_download_data(This); surface_download_data(This);
LEAVE_GL();
} else { } else {
read_from_framebuffer(This, rect, read_from_framebuffer(This, rect,
This->resource.allocatedMemory, This->resource.allocatedMemory,