From a2fa1f714ab7acc02da34950500d5501e4eca65e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20D=C3=B6singer?= <stefan@codeweavers.com>
Date: Tue, 21 Jan 2014 13:25:48 +0100
Subject: wined3d: Remove surface->pbo.

---
 dlls/wined3d/surface.c         | 34 +++++++++++++++++-----------------
 dlls/wined3d/texture.c         |  2 +-
 dlls/wined3d/wined3d_private.h |  2 --
 3 files changed, 18 insertions(+), 20 deletions(-)

diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index fd5cc8c..e9ae033 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -46,7 +46,7 @@ static void surface_cleanup(struct wined3d_surface *surface)
 
     TRACE("surface %p.\n", surface);
 
-    if (surface->pbo || surface->rb_multisample
+    if (surface->resource.buffer_object || surface->rb_multisample
             || surface->rb_resolved || !list_empty(&surface->renderbuffers))
     {
         struct wined3d_renderbuffer_entry *entry, *entry2;
@@ -57,10 +57,10 @@ static void surface_cleanup(struct wined3d_surface *surface)
         context = context_acquire(device, NULL);
         gl_info = context->gl_info;
 
-        if (surface->pbo)
+        if (surface->resource.buffer_object)
         {
-            TRACE("Deleting PBO %u.\n", surface->pbo);
-            GL_EXTCALL(glDeleteBuffers(1, &surface->pbo));
+            TRACE("Deleting PBO %u.\n", surface->resource.buffer_object);
+            GL_EXTCALL(glDeleteBuffers(1, &surface->resource.buffer_object));
         }
 
         if (surface->rb_multisample)
@@ -473,7 +473,7 @@ static void surface_get_memory(const struct wined3d_surface *surface, struct win
     if (location & WINED3D_LOCATION_BUFFER)
     {
         data->addr = NULL;
-        data->buffer_object = surface->pbo;
+        data->buffer_object = surface->resource.buffer_object;
         return;
     }
     if (location & WINED3D_LOCATION_USER_MEMORY)
@@ -506,20 +506,20 @@ static void surface_prepare_buffer(struct wined3d_surface *surface)
     GLenum error;
     const struct wined3d_gl_info *gl_info;
 
-    if (surface->pbo)
+    if (surface->resource.buffer_object)
         return;
 
     context = context_acquire(surface->resource.device, NULL);
     gl_info = context->gl_info;
 
-    GL_EXTCALL(glGenBuffers(1, &surface->pbo));
+    GL_EXTCALL(glGenBuffers(1, &surface->resource.buffer_object));
     error = gl_info->gl_ops.gl.p_glGetError();
-    if (!surface->pbo || error != GL_NO_ERROR)
+    if (!surface->resource.buffer_object || error != GL_NO_ERROR)
         ERR("Failed to create a PBO with error %s (%#x).\n", debug_glerror(error), error);
 
-    TRACE("Binding PBO %u.\n", surface->pbo);
+    TRACE("Binding PBO %u.\n", surface->resource.buffer_object);
 
-    GL_EXTCALL(glBindBuffer(GL_PIXEL_UNPACK_BUFFER, surface->pbo));
+    GL_EXTCALL(glBindBuffer(GL_PIXEL_UNPACK_BUFFER, surface->resource.buffer_object));
     checkGLcall("glBindBuffer");
 
     GL_EXTCALL(glBufferData(GL_PIXEL_UNPACK_BUFFER, surface->resource.size + 4,
@@ -693,7 +693,7 @@ static void surface_unmap(struct wined3d_surface *surface)
             context = context_acquire(device, NULL);
             gl_info = context->gl_info;
 
-            GL_EXTCALL(glBindBuffer(GL_PIXEL_UNPACK_BUFFER, surface->pbo));
+            GL_EXTCALL(glBindBuffer(GL_PIXEL_UNPACK_BUFFER, surface->resource.buffer_object));
             GL_EXTCALL(glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER));
             GL_EXTCALL(glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0));
             checkGLcall("glUnmapBuffer");
@@ -1089,10 +1089,10 @@ static HRESULT wined3d_surface_depth_blt(struct wined3d_surface *src_surface, DW
 /* Context activation is done by the caller. */
 static void surface_remove_pbo(struct wined3d_surface *surface, const struct wined3d_gl_info *gl_info)
 {
-    GL_EXTCALL(glDeleteBuffers(1, &surface->pbo));
-    checkGLcall("glDeleteBuffers(1, &surface->pbo)");
+    GL_EXTCALL(glDeleteBuffers(1, &surface->resource.buffer_object));
+    checkGLcall("glDeleteBuffers(1, &surface->resource.buffer_object)");
 
-    surface->pbo = 0;
+    surface->resource.buffer_object = 0;
     wined3d_resource_invalidate_location(&surface->resource, WINED3D_LOCATION_BUFFER);
 }
 
@@ -1159,7 +1159,7 @@ static void surface_unload(struct wined3d_resource *resource)
     }
 
     /* Destroy PBOs, but load them into real sysmem before */
-    if (surface->pbo)
+    if (surface->resource.buffer_object)
         surface_remove_pbo(surface, gl_info);
 
     /* Destroy fbo render buffers. This is needed for implicit render targets, for
@@ -2539,7 +2539,7 @@ HRESULT wined3d_surface_map(struct wined3d_surface *surface, struct wined3d_map_
             context = context_acquire(device, NULL);
             gl_info = context->gl_info;
 
-            GL_EXTCALL(glBindBuffer(GL_PIXEL_UNPACK_BUFFER, surface->pbo));
+            GL_EXTCALL(glBindBuffer(GL_PIXEL_UNPACK_BUFFER, surface->resource.buffer_object));
             base_memory = GL_EXTCALL(glMapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_READ_WRITE));
             GL_EXTCALL(glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0));
             checkGLcall("map PBO");
@@ -3878,7 +3878,7 @@ static HRESULT surface_load_texture(struct wined3d_surface *surface,
     /* Don't use PBOs for converted surfaces. During PBO conversion we look at
      * WINED3D_TEXTURE_CONVERTED but it isn't set (yet) in all cases it is
      * getting called. */
-    if ((format.convert || conversion) && surface->pbo)
+    if ((format.convert || conversion) && surface->resource.buffer_object)
     {
         TRACE("Removing the pbo attached to surface %p.\n", surface);
 
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c
index 23f4a1b..e3fb0df 100644
--- a/dlls/wined3d/texture.c
+++ b/dlls/wined3d/texture.c
@@ -1652,7 +1652,7 @@ HRESULT CDECL wined3d_texture_get_dc(struct wined3d_texture *texture, unsigned i
         }
         if (!(surface->resource.map_binding == WINED3D_LOCATION_USER_MEMORY
                 || surface->container->flags & WINED3D_TEXTURE_PIN_SYSMEM
-                || surface->pbo))
+                || surface->resource.buffer_object))
             surface->resource.map_binding = WINED3D_LOCATION_DIB;
     }
 
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 579d760..51aef5a 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -2523,8 +2523,6 @@ struct wined3d_surface
     UINT pow2Width;
     UINT pow2Height;
 
-    /* PBO */
-    GLuint                    pbo;
     GLuint rb_multisample;
     GLuint rb_resolved;
     GLenum texture_target;
-- 
2.7.1

