Stefan Dösinger : wined3d: Implement IWineD3DSurface:: UnLoad.
Alexandre Julliard
julliard at winehq.org
Mon Jan 14 09:33:18 CST 2008
Module: wine
Branch: master
Commit: c372654b2644ce18d9e0ed8790139c96e2766191
URL: http://source.winehq.org/git/wine.git/?a=commit;h=c372654b2644ce18d9e0ed8790139c96e2766191
Author: Stefan Dösinger <stefan at codeweavers.com>
Date: Sat Jan 12 22:33:04 2008 +0100
wined3d: Implement IWineD3DSurface::UnLoad.
---
dlls/wined3d/surface.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 52 insertions(+), 2 deletions(-)
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index 27e32aa..c9da469 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -489,8 +489,58 @@ void WINAPI IWineD3DSurfaceImpl_PreLoad(IWineD3DSurface *iface) {
return;
}
-void WINAPI IWineD3DSurfaceImpl_UnLoad(IWineD3DSurface *iface) {
- FIXME("(%p): Stub!\n", iface);
+static void surface_remove_pbo(IWineD3DSurfaceImpl *This) {
+ This->resource.heapMemory = HeapAlloc(GetProcessHeap() ,0 , This->resource.size + RESOURCE_ALIGNMENT);
+ This->resource.allocatedMemory =
+ (BYTE *)(((ULONG_PTR) This->resource.heapMemory + (RESOURCE_ALIGNMENT - 1)) & ~(RESOURCE_ALIGNMENT - 1));
+
+ ENTER_GL();
+ GL_EXTCALL(glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, This->pbo));
+ checkGLcall("glBindBuffer(GL_PIXEL_UNPACK_BUFFER, This->pbo)");
+ GL_EXTCALL(glGetBufferSubDataARB(GL_PIXEL_UNPACK_BUFFER_ARB, 0, This->resource.size, This->resource.allocatedMemory));
+ checkGLcall("glGetBufferSubData");
+ GL_EXTCALL(glDeleteBuffersARB(1, &This->pbo));
+ checkGLcall("glDeleteBuffers");
+ LEAVE_GL();
+
+ This->pbo = 0;
+ This->Flags &= ~SFLAG_PBO;
+}
+
+static void WINAPI IWineD3DSurfaceImpl_UnLoad(IWineD3DSurface *iface) {
+ IWineD3DBaseTexture *texture = NULL;
+ IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
+ TRACE("(%p)\n", iface);
+
+ /* Default pool resources are supposed to be destroyed before Reset is called.
+ * Implicit resources stay however. So this means we have an implicit render target
+ * or depth stencil, and the content isn't supposed to survive the reset anyway
+ */
+ if(This->resource.pool == WINED3DPOOL_DEFAULT) {
+ TRACE("Default pool - nothing to do\n");
+ return;
+ }
+
+ /* Load the surface into system memory */
+ IWineD3DSurface_LoadLocation(iface, SFLAG_INSYSMEM, NULL);
+
+ /* Destroy PBOs, but load them into real sysmem before */
+ if(This->Flags & SFLAG_PBO) {
+ surface_remove_pbo(This);
+ }
+
+ /* If we're in a texture, the texture name belongs to the texture. Otherwise,
+ * destroy it
+ */
+ IWineD3DSurface_GetContainer(iface, &IID_IWineD3DBaseTexture, (void **) &texture);
+ if(!texture) {
+ ENTER_GL();
+ glDeleteTextures(1, &This->glDescription.textureName);
+ This->glDescription.textureName = 0;
+ LEAVE_GL();
+ } else {
+ IWineD3DBaseTexture_Release(texture);
+ }
return;
}
More information about the wine-cvs
mailing list