=?UTF-8?Q?Stefan=20D=C3=B6singer=20?=: wined3d: Use GL_APPLE_client_storage for volumes if available.
Alexandre Julliard
julliard at winehq.org
Tue Sep 24 03:22:02 CDT 2013
Module: wine
Branch: master
Commit: 556e3e0c764ee5eff1eb02b97a01d4141d6ec58f
URL: http://source.winehq.org/git/wine.git/?a=commit;h=556e3e0c764ee5eff1eb02b97a01d4141d6ec58f
Author: Stefan Dösinger <stefan at codeweavers.com>
Date: Mon Sep 23 13:29:16 2013 +0200
wined3d: Use GL_APPLE_client_storage for volumes if available.
---
dlls/wined3d/volume.c | 53 +++++++++++++++++++++++++++-------------
dlls/wined3d/wined3d_private.h | 1 +
2 files changed, 37 insertions(+), 17 deletions(-)
diff --git a/dlls/wined3d/volume.c b/dlls/wined3d/volume.c
index 7be0811..d61f32f 100644
--- a/dlls/wined3d/volume.c
+++ b/dlls/wined3d/volume.c
@@ -57,18 +57,48 @@ void volume_set_container(struct wined3d_volume *volume, struct wined3d_texture
volume->container = container;
}
+static BOOL volume_prepare_system_memory(struct wined3d_volume *volume)
+{
+ if (volume->resource.heap_memory)
+ return TRUE;
+
+ if (!wined3d_resource_allocate_sysmem(&volume->resource))
+ {
+ ERR("Failed to allocate system memory.\n");
+ return FALSE;
+ }
+ return TRUE;
+}
+
/* Context activation is done by the caller. */
-static void wined3d_volume_allocate_texture(const struct wined3d_volume *volume,
+static void wined3d_volume_allocate_texture(struct wined3d_volume *volume,
const struct wined3d_context *context, BOOL srgb)
{
const struct wined3d_gl_info *gl_info = context->gl_info;
const struct wined3d_format *format = volume->resource.format;
+ void *mem = NULL;
+
+ if (gl_info->supported[APPLE_CLIENT_STORAGE] && !format->convert
+ && volume_prepare_system_memory(volume))
+ {
+ TRACE("Enabling GL_UNPACK_CLIENT_STORAGE_APPLE for volume %p\n", volume);
+ gl_info->gl_ops.gl.p_glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE);
+ checkGLcall("glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE)");
+ mem = volume->resource.heap_memory;
+ volume->flags |= WINED3D_VFLAG_CLIENT_STORAGE;
+ }
GL_EXTCALL(glTexImage3DEXT(GL_TEXTURE_3D, volume->texture_level,
srgb ? format->glGammaInternal : format->glInternal,
volume->resource.width, volume->resource.height, volume->resource.depth,
- 0, format->glFormat, format->glType, NULL));
+ 0, format->glFormat, format->glType, mem));
checkGLcall("glTexImage3D");
+
+ if (mem)
+ {
+ gl_info->gl_ops.gl.p_glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_FALSE);
+ checkGLcall("glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_FALSE)");
+ }
}
static void wined3d_volume_get_pitch(const struct wined3d_volume *volume, UINT *row_pitch,
@@ -261,6 +291,8 @@ static BOOL wined3d_volume_can_evict(const struct wined3d_volume *volume)
return FALSE;
if (volume->resource.format->convert)
return FALSE;
+ if (volume->flags & WINED3D_VFLAG_CLIENT_STORAGE)
+ return FALSE;
return TRUE;
}
@@ -452,20 +484,6 @@ static void wined3d_volume_free_pbo(struct wined3d_volume *volume)
context_release(context);
}
-static BOOL volume_prepare_system_memory(struct wined3d_volume *volume)
-{
- if (volume->resource.heap_memory)
- return TRUE;
-
- if (!wined3d_resource_allocate_sysmem(&volume->resource))
- {
- ERR("Failed to allocate system memory.\n");
- return FALSE;
- }
- return TRUE;
-}
-
-
static void volume_unload(struct wined3d_resource *resource)
{
struct wined3d_volume *volume = volume_from_resource(resource);
@@ -501,7 +519,8 @@ static void volume_unload(struct wined3d_resource *resource)
}
/* The texture name is managed by the container. */
- volume->flags &= ~(WINED3D_VFLAG_ALLOCATED | WINED3D_VFLAG_SRGB_ALLOCATED);
+ volume->flags &= ~(WINED3D_VFLAG_ALLOCATED | WINED3D_VFLAG_SRGB_ALLOCATED
+ | WINED3D_VFLAG_CLIENT_STORAGE);
resource_unload(resource);
}
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 02c7aff..5525dd9 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -2114,6 +2114,7 @@ void wined3d_texture_set_dirty(struct wined3d_texture *texture) DECLSPEC_HIDDEN;
#define WINED3D_VFLAG_ALLOCATED 0x00000001
#define WINED3D_VFLAG_SRGB_ALLOCATED 0x00000002
#define WINED3D_VFLAG_PBO 0x00000004
+#define WINED3D_VFLAG_CLIENT_STORAGE 0x00000008
#define WINED3D_LOCATION_DISCARDED 0x00000001
#define WINED3D_LOCATION_SYSMEM 0x00000002
More information about the wine-cvs
mailing list