wined3d: Keep GL_UNPACK_CLIENT_STORAGE_APPLE off by default.

This is cleaner than the other way around and avoids side effects in
code that wasn't written with client storage in mind. Contrary to the
original intention, it also means fewer client storage toggle calls.
This commit is contained in:
Stefan Dösinger 2013-08-19 10:52:31 +02:00 committed by Alexandre Julliard
parent 3172d35188
commit a4f009d847
5 changed files with 8 additions and 60 deletions

View File

@ -7102,12 +7102,6 @@ static void upload_palette(const struct wined3d_surface *surface, struct wined3d
d3dfmt_p8_init_palette(surface, table, colorkey);
if (gl_info->supported[APPLE_CLIENT_STORAGE])
{
gl_info->gl_ops.gl.p_glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_FALSE);
checkGLcall("glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_FALSE)");
}
if (!priv->palette_texture)
gl_info->gl_ops.gl.p_glGenTextures(1, &priv->palette_texture);
@ -7124,12 +7118,6 @@ static void upload_palette(const struct wined3d_surface *surface, struct wined3d
/* TODO: avoid unneeded uploads in the future by adding some SFLAG_PALETTE_DIRTY mechanism */
gl_info->gl_ops.gl.p_glTexImage1D(GL_TEXTURE_1D, 0, GL_RGBA, 256, 0, GL_RGBA, GL_UNSIGNED_BYTE, table);
if (gl_info->supported[APPLE_CLIENT_STORAGE])
{
gl_info->gl_ops.gl.p_glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE);
checkGLcall("glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE)");
}
/* Switch back to unit 0 in which the 2D texture will be stored. */
context_active_texture(context, gl_info, 0);
}

View File

@ -1564,13 +1564,6 @@ struct wined3d_context *context_create(struct wined3d_swapchain *swapchain,
gl_info->gl_ops.gl.p_glPixelStorei(GL_UNPACK_ALIGNMENT, device->surface_alignment);
checkGLcall("glPixelStorei(GL_UNPACK_ALIGNMENT, device->surface_alignment);");
if (gl_info->supported[APPLE_CLIENT_STORAGE])
{
/* Most textures will use client storage if supported. Exceptions are
* non-native power of 2 textures and textures in DIB sections. */
gl_info->gl_ops.gl.p_glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE);
checkGLcall("glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE)");
}
if (gl_info->supported[ARB_VERTEX_BLEND])
{
/* Direct3D always uses n-1 weights for n world matrices and uses

View File

@ -871,13 +871,6 @@ static void create_dummy_textures(struct wined3d_device *device, struct wined3d_
* We emulate this by creating dummy textures and binding them
* to each texture stage when the currently set D3D texture is NULL. */
if (gl_info->supported[APPLE_CLIENT_STORAGE])
{
/* The dummy texture does not have client storage backing */
gl_info->gl_ops.gl.p_glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_FALSE);
checkGLcall("glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_FALSE)");
}
count = min(MAX_COMBINED_SAMPLERS, gl_info->limits.combined_samplers);
for (i = 0; i < count; ++i)
{
@ -941,13 +934,6 @@ static void create_dummy_textures(struct wined3d_device *device, struct wined3d_
}
}
}
if (gl_info->supported[APPLE_CLIENT_STORAGE])
{
/* Re-enable because if supported it is enabled by default */
gl_info->gl_ops.gl.p_glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE);
checkGLcall("glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE)");
}
}
/* Context activation is done by the caller. */
@ -4648,12 +4634,6 @@ HRESULT CDECL wined3d_device_set_cursor_properties(struct wined3d_device *device
context = context_acquire(device, NULL);
if (gl_info->supported[APPLE_CLIENT_STORAGE])
{
gl_info->gl_ops.gl.p_glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_FALSE);
checkGLcall("glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_FALSE)");
}
invalidate_active_texture(device, context);
/* Create a new cursor texture */
gl_info->gl_ops.gl.p_glGenTextures(1, &device->cursorTexture);
@ -4664,12 +4644,6 @@ HRESULT CDECL wined3d_device_set_cursor_properties(struct wined3d_device *device
checkGLcall("glTexImage2D");
HeapFree(GetProcessHeap(), 0, mem);
if (gl_info->supported[APPLE_CLIENT_STORAGE])
{
gl_info->gl_ops.gl.p_glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE);
checkGLcall("glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE)");
}
context_release(context);
}
else

View File

@ -694,7 +694,6 @@ static void surface_release_client_storage(struct wined3d_surface *surface)
struct wined3d_context *context = context_acquire(surface->resource.device, NULL);
const struct wined3d_gl_info *gl_info = context->gl_info;
gl_info->gl_ops.gl.p_glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_FALSE);
if (surface->texture_name)
{
surface_bind_and_dirtify(surface, context, FALSE);
@ -707,7 +706,6 @@ static void surface_release_client_storage(struct wined3d_surface *surface)
gl_info->gl_ops.gl.p_glTexImage2D(surface->texture_target, surface->texture_level,
GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL);
}
gl_info->gl_ops.gl.p_glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE);
context_release(context);
@ -2642,7 +2640,7 @@ HRESULT surface_upload_from_surface(struct wined3d_surface *dst_surface, const P
static void surface_allocate_surface(struct wined3d_surface *surface, const struct wined3d_gl_info *gl_info,
const struct wined3d_format *format, BOOL srgb)
{
BOOL enable_client_storage = FALSE;
BOOL disable_client_storage = FALSE;
GLsizei width = surface->pow2Width;
GLsizei height = surface->pow2Height;
const BYTE *mem = NULL;
@ -2685,10 +2683,7 @@ static void surface_allocate_surface(struct wined3d_surface *surface, const stru
* SFLAG_CONVERTED: The conversion destination memory is freed after loading the surface
* allocatedMemory == NULL: Not defined in the extension. Seems to disable client storage effectively
*/
gl_info->gl_ops.gl.p_glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_FALSE);
checkGLcall("glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_FALSE)");
surface->flags &= ~SFLAG_CLIENT;
enable_client_storage = TRUE;
}
else
{
@ -2699,6 +2694,10 @@ static void surface_allocate_surface(struct wined3d_surface *surface, const stru
* PBO. Instead use heapMemory, but get the alignment right. */
mem = (BYTE *)(((ULONG_PTR)surface->resource.heapMemory
+ (RESOURCE_ALIGNMENT - 1)) & ~(RESOURCE_ALIGNMENT - 1));
gl_info->gl_ops.gl.p_glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE);
checkGLcall("glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE)");
disable_client_storage = TRUE;
}
}
@ -2715,10 +2714,10 @@ static void surface_allocate_surface(struct wined3d_surface *surface, const stru
checkGLcall("glTexImage2D");
}
if (enable_client_storage)
if (disable_client_storage)
{
gl_info->gl_ops.gl.p_glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE);
checkGLcall("glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE)");
gl_info->gl_ops.gl.p_glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_FALSE);
checkGLcall("glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_FALSE)");
}
}

View File

@ -92,12 +92,6 @@ void volume_load(const struct wined3d_volume *volume, struct wined3d_context *co
volume->resource.width, volume->resource.height, volume->resource.depth,
0, format->glFormat, format->glType, volume->resource.allocatedMemory));
checkGLcall("glTexImage3D");
/* When adding code releasing volume->resource.allocatedMemory to save
* data keep in mind that GL_UNPACK_CLIENT_STORAGE_APPLE is enabled by
* default if supported(GL_APPLE_client_storage). Thus do not release
* volume->resource.allocatedMemory if GL_APPLE_client_storage is
* supported. */
}
/* Do not call while under the GL lock. */