[PATCH 7/8] wined3d: Introduce wined3d_texture_use_pbo().

Henri Verbeet hverbeet at codeweavers.com
Mon Mar 14 11:02:17 CDT 2016


From: Stefan Dösinger <stefan at codeweavers.com>

Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
---
 dlls/wined3d/surface.c         | 18 +++---------------
 dlls/wined3d/texture.c         | 11 +++++++++++
 dlls/wined3d/volume.c          |  4 +---
 dlls/wined3d/wined3d_private.h |  2 ++
 4 files changed, 17 insertions(+), 18 deletions(-)

diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index d06f1eb..64ed04a 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -518,19 +518,6 @@ static void surface_evict_sysmem(struct wined3d_surface *surface)
     surface_invalidate_location(surface, WINED3D_LOCATION_SYSMEM);
 }
 
-static BOOL surface_use_pbo(const struct wined3d_surface *surface)
-{
-    const struct wined3d_gl_info *gl_info = &surface->resource.device->adapter->gl_info;
-    struct wined3d_texture *texture = surface->container;
-
-    return texture->resource.pool == WINED3D_POOL_DEFAULT
-                && surface->resource.access_flags & WINED3D_RESOURCE_ACCESS_CPU
-                && gl_info->supported[ARB_PIXEL_BUFFER_OBJECT]
-                && !texture->resource.format->convert
-                && !(texture->flags & WINED3D_TEXTURE_PIN_SYSMEM)
-                && !(texture->flags & WINED3D_TEXTURE_COND_NP2_EMULATED);
-}
-
 static HRESULT surface_private_setup(struct wined3d_surface *surface)
 {
     /* TODO: Check against the maximum texture sizes supported by the video card. */
@@ -597,7 +584,7 @@ static HRESULT surface_private_setup(struct wined3d_surface *surface)
     if (texture->resource.usage & WINED3DUSAGE_DEPTHSTENCIL)
         surface->locations = WINED3D_LOCATION_DISCARDED;
 
-    if (surface_use_pbo(surface))
+    if (wined3d_texture_use_pbo(texture, gl_info))
         surface->resource.map_binding = WINED3D_LOCATION_BUFFER;
 
     return WINED3D_OK;
@@ -1743,7 +1730,8 @@ HRESULT wined3d_surface_update_desc(struct wined3d_surface *surface, const struc
      * If the surface didn't use PBOs previously but could now, don't
      * change it - whatever made us not use PBOs might come back, e.g.
      * color keys. */
-    if (surface->resource.map_binding == WINED3D_LOCATION_BUFFER && !surface_use_pbo(surface))
+    if (surface->resource.map_binding == WINED3D_LOCATION_BUFFER
+            && !wined3d_texture_use_pbo(surface->container, gl_info))
         surface->resource.map_binding = create_dib ? WINED3D_LOCATION_DIB : WINED3D_LOCATION_SYSMEM;
 
     if (create_dib)
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c
index e0b5510..c86d640 100644
--- a/dlls/wined3d/texture.c
+++ b/dlls/wined3d/texture.c
@@ -28,6 +28,15 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3d_texture);
 WINE_DECLARE_DEBUG_CHANNEL(d3d_perf);
 WINE_DECLARE_DEBUG_CHANNEL(winediag);
 
+BOOL wined3d_texture_use_pbo(const struct wined3d_texture *texture, const struct wined3d_gl_info *gl_info)
+{
+    return texture->resource.pool == WINED3D_POOL_DEFAULT
+            && texture->resource.access_flags & WINED3D_RESOURCE_ACCESS_CPU
+            && gl_info->supported[ARB_PIXEL_BUFFER_OBJECT]
+            && !texture->resource.format->convert
+            && !(texture->flags & (WINED3D_TEXTURE_PIN_SYSMEM | WINED3D_TEXTURE_COND_NP2_EMULATED));
+}
+
 static HRESULT wined3d_texture_init(struct wined3d_texture *texture, const struct wined3d_texture_ops *texture_ops,
         UINT layer_count, UINT level_count, const struct wined3d_resource_desc *desc, DWORD flags,
         struct wined3d_device *device, void *parent, const struct wined3d_parent_ops *parent_ops,
@@ -61,6 +70,8 @@ static HRESULT wined3d_texture_init(struct wined3d_texture *texture, const struc
         return hr;
     }
     wined3d_resource_update_draw_binding(&texture->resource);
+    if ((flags & WINED3D_TEXTURE_CREATE_MAPPABLE) || desc->format == WINED3DFMT_D16_LOCKABLE)
+        texture->resource.access_flags |= WINED3D_RESOURCE_ACCESS_CPU;
 
     texture->texture_ops = texture_ops;
 
diff --git a/dlls/wined3d/volume.c b/dlls/wined3d/volume.c
index e1749ac..c846ec4 100644
--- a/dlls/wined3d/volume.c
+++ b/dlls/wined3d/volume.c
@@ -489,9 +489,7 @@ HRESULT wined3d_volume_init(struct wined3d_volume *volume, struct wined3d_textur
     volume->texture_level = level;
     volume->locations = WINED3D_LOCATION_DISCARDED;
 
-    if (desc->pool == WINED3D_POOL_DEFAULT && desc->usage & WINED3DUSAGE_DYNAMIC
-            && gl_info->supported[ARB_PIXEL_BUFFER_OBJECT]
-            && !format->convert)
+    if (wined3d_texture_use_pbo(container, gl_info))
     {
         wined3d_resource_free_sysmem(&volume->resource);
         volume->resource.map_binding = WINED3D_LOCATION_BUFFER;
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 83a9d04..15fe6c9 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -2458,6 +2458,8 @@ void wined3d_texture_remove_buffer_object(struct wined3d_texture *texture,
 void wined3d_texture_set_dirty(struct wined3d_texture *texture) DECLSPEC_HIDDEN;
 void wined3d_texture_set_swapchain(struct wined3d_texture *texture,
         struct wined3d_swapchain *swapchain) DECLSPEC_HIDDEN;
+BOOL wined3d_texture_use_pbo(const struct wined3d_texture *texture,
+        const struct wined3d_gl_info *gl_info) DECLSPEC_HIDDEN;
 
 #define WINED3D_LOCATION_DISCARDED      0x00000001
 #define WINED3D_LOCATION_SYSMEM         0x00000002
-- 
2.1.4




More information about the wine-patches mailing list