wined3d: Merge texture2d_preload() and texture3d_preload() into wined3d_texture_load().

This commit is contained in:
Henri Verbeet 2013-11-22 10:45:02 +01:00 committed by Alexandre Julliard
parent c025b5d06b
commit e0beab8b81
5 changed files with 65 additions and 87 deletions

View File

@ -2797,7 +2797,7 @@ static void context_preload_texture(struct wined3d_context *context,
return;
srgb = state->sampler_states[idx][WINED3D_SAMP_SRGB_TEXTURE] ? SRGB_SRGB : SRGB_RGB;
texture->texture_ops->texture_preload(texture, context, srgb);
wined3d_texture_load(texture, context, srgb);
}
/* Context activation is done by the caller. */

View File

@ -3402,7 +3402,7 @@ HRESULT CDECL wined3d_device_update_texture(struct wined3d_device *device,
/* Make sure that the destination texture is loaded. */
context = context_acquire(device, NULL);
dst_texture->texture_ops->texture_preload(dst_texture, context, SRGB_RGB);
wined3d_texture_load(dst_texture, context, SRGB_RGB);
context_release(context);
/* Update every surface level of the texture. */

View File

@ -3455,7 +3455,7 @@ void surface_internal_preload(struct wined3d_surface *surface,
TRACE("iface %p, srgb %#x.\n", surface, srgb);
texture->texture_ops->texture_preload(texture, context, srgb);
wined3d_texture_load(texture, context, srgb);
}
/* Read the framebuffer back into the surface */

View File

@ -508,11 +508,60 @@ DWORD CDECL wined3d_texture_get_priority(const struct wined3d_texture *texture)
return resource_get_priority(&texture->resource);
}
/* Context activation is done by the caller */
void wined3d_texture_load(struct wined3d_texture *texture,
struct wined3d_context *context, enum WINED3DSRGB srgb)
{
UINT sub_count = texture->level_count * texture->layer_count;
const struct wined3d_gl_info *gl_info = context->gl_info;
BOOL srgb_mode;
DWORD flag;
UINT i;
TRACE("texture %p, srgb %#x.\n", texture, srgb);
if (gl_info->supported[EXT_TEXTURE_SRGB_DECODE])
srgb = SRGB_RGB;
switch (srgb)
{
case SRGB_RGB:
srgb_mode = FALSE;
break;
case SRGB_SRGB:
srgb_mode = TRUE;
break;
default:
srgb_mode = texture->flags & WINED3D_TEXTURE_IS_SRGB;
break;
}
if (srgb_mode)
flag = WINED3D_TEXTURE_SRGB_VALID;
else
flag = WINED3D_TEXTURE_RGB_VALID;
if (texture->flags & flag)
{
TRACE("Texture %p not dirty, nothing to do.\n", texture);
return;
}
/* Reload the surfaces if the texture is marked dirty. */
for (i = 0; i < sub_count; ++i)
{
texture->texture_ops->texture_sub_resource_load(texture->sub_resources[i], context, srgb_mode);
}
texture->flags |= flag;
}
void CDECL wined3d_texture_preload(struct wined3d_texture *texture)
{
struct wined3d_context *context;
context = context_acquire(texture->resource.device, NULL);
texture->texture_ops->texture_preload(texture, context, SRGB_ANY);
wined3d_texture_load(texture, context, SRGB_ANY);
context_release(context);
}
@ -631,54 +680,10 @@ HRESULT CDECL wined3d_texture_add_dirty_region(struct wined3d_texture *texture,
return WINED3D_OK;
}
static BOOL texture_srgb_mode(const struct wined3d_texture *texture, enum WINED3DSRGB srgb)
static void texture2d_sub_resource_load(struct wined3d_resource *sub_resource,
struct wined3d_context *context, BOOL srgb)
{
switch (srgb)
{
case SRGB_RGB:
return FALSE;
case SRGB_SRGB:
return TRUE;
default:
return texture->flags & WINED3D_TEXTURE_IS_SRGB;
}
}
/* Context activation is done by the caller */
static void texture2d_preload(struct wined3d_texture *texture,
struct wined3d_context *context, enum WINED3DSRGB srgb)
{
UINT sub_count = texture->level_count * texture->layer_count;
const struct wined3d_gl_info *gl_info = context->gl_info;
BOOL srgb_mode;
DWORD flag;
UINT i;
TRACE("texture %p, srgb %#x.\n", texture, srgb);
if (gl_info->supported[EXT_TEXTURE_SRGB_DECODE])
srgb = SRGB_RGB;
srgb_mode = texture_srgb_mode(texture, srgb);
if (srgb_mode)
flag = WINED3D_TEXTURE_SRGB_VALID;
else
flag = WINED3D_TEXTURE_RGB_VALID;
if (texture->flags & flag)
{
TRACE("Texture %p not dirty, nothing to do.\n", texture);
return;
}
/* Reload the surfaces if the texture is marked dirty. */
for (i = 0; i < sub_count; ++i)
{
surface_load(surface_from_resource(texture->sub_resources[i]), srgb_mode);
}
texture->flags |= flag;
surface_load(surface_from_resource(sub_resource), srgb);
}
static void texture2d_sub_resource_add_dirty_region(struct wined3d_resource *sub_resource,
@ -698,7 +703,7 @@ static void texture2d_sub_resource_cleanup(struct wined3d_resource *sub_resource
static const struct wined3d_texture_ops texture2d_ops =
{
texture2d_preload,
texture2d_sub_resource_load,
texture2d_sub_resource_add_dirty_region,
texture2d_sub_resource_cleanup,
};
@ -998,39 +1003,10 @@ static HRESULT texture_init(struct wined3d_texture *texture, const struct wined3
return WINED3D_OK;
}
/* Context activation is done by the caller. */
static void texture3d_preload(struct wined3d_texture *texture,
struct wined3d_context *context, enum WINED3DSRGB srgb)
static void texture3d_sub_resource_load(struct wined3d_resource *sub_resource,
struct wined3d_context *context, BOOL srgb)
{
UINT sub_count = texture->level_count * texture->layer_count;
const struct wined3d_gl_info *gl_info = context->gl_info;
BOOL srgb_mode;
DWORD flag;
UINT i;
TRACE("texture %p, srgb %#x.\n", texture, srgb);
if (gl_info->supported[EXT_TEXTURE_SRGB_DECODE])
srgb = SRGB_RGB;
srgb_mode = texture_srgb_mode(texture, srgb);
if (srgb_mode)
flag = WINED3D_TEXTURE_SRGB_VALID;
else
flag = WINED3D_TEXTURE_RGB_VALID;
if (texture->flags & flag)
{
TRACE("Texture %p not dirty, nothing to do.\n", texture);
return;
}
/* Reload the surfaces if the texture is marked dirty. */
for (i = 0; i < sub_count; ++i)
{
wined3d_volume_load(volume_from_resource(texture->sub_resources[i]), context, srgb_mode);
}
texture->flags |= flag;
wined3d_volume_load(volume_from_resource(sub_resource), context, srgb);
}
static void texture3d_sub_resource_add_dirty_region(struct wined3d_resource *sub_resource,
@ -1049,7 +1025,7 @@ static void texture3d_sub_resource_cleanup(struct wined3d_resource *sub_resource
static const struct wined3d_texture_ops texture3d_ops =
{
texture3d_preload,
texture3d_sub_resource_load,
texture3d_sub_resource_add_dirty_region,
texture3d_sub_resource_cleanup,
};

View File

@ -2058,8 +2058,8 @@ struct gl_texture
struct wined3d_texture_ops
{
void (*texture_preload)(struct wined3d_texture *texture, struct wined3d_context *context,
enum WINED3DSRGB srgb);
void (*texture_sub_resource_load)(struct wined3d_resource *sub_resource,
struct wined3d_context *context, BOOL srgb);
void (*texture_sub_resource_add_dirty_region)(struct wined3d_resource *sub_resource,
const struct wined3d_box *dirty_region);
void (*texture_sub_resource_cleanup)(struct wined3d_resource *sub_resource);
@ -2107,6 +2107,8 @@ void wined3d_texture_bind(struct wined3d_texture *texture,
struct wined3d_context *context, BOOL srgb) DECLSPEC_HIDDEN;
void wined3d_texture_bind_and_dirtify(struct wined3d_texture *texture,
struct wined3d_context *context, BOOL srgb) DECLSPEC_HIDDEN;
void wined3d_texture_load(struct wined3d_texture *texture,
struct wined3d_context *context, enum WINED3DSRGB srgb) DECLSPEC_HIDDEN;
void wined3d_texture_set_dirty(struct wined3d_texture *texture) DECLSPEC_HIDDEN;
#define WINED3D_VFLAG_ALLOCATED 0x00000001