Commit 59e2f52f authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Replace the "dirty" field in struct gl_texture with WINED3D_TEXTURE_ flags.

parent c44012f0
...@@ -71,8 +71,6 @@ static HRESULT wined3d_texture_init(struct wined3d_texture *texture, const struc ...@@ -71,8 +71,6 @@ static HRESULT wined3d_texture_init(struct wined3d_texture *texture, const struc
texture->level_count = level_count; texture->level_count = level_count;
texture->filter_type = (desc->usage & WINED3DUSAGE_AUTOGENMIPMAP) ? WINED3D_TEXF_LINEAR : WINED3D_TEXF_NONE; texture->filter_type = (desc->usage & WINED3DUSAGE_AUTOGENMIPMAP) ? WINED3D_TEXF_LINEAR : WINED3D_TEXF_NONE;
texture->lod = 0; texture->lod = 0;
texture->texture_rgb.dirty = TRUE;
texture->texture_srgb.dirty = TRUE;
texture->flags = WINED3D_TEXTURE_POW2_MAT_IDENT; texture->flags = WINED3D_TEXTURE_POW2_MAT_IDENT;
if (texture->resource.format->flags & WINED3DFMT_FLAG_FILTERING) if (texture->resource.format->flags & WINED3DFMT_FLAG_FILTERING)
...@@ -141,8 +139,7 @@ static void wined3d_texture_cleanup(struct wined3d_texture *texture) ...@@ -141,8 +139,7 @@ static void wined3d_texture_cleanup(struct wined3d_texture *texture)
void wined3d_texture_set_dirty(struct wined3d_texture *texture) void wined3d_texture_set_dirty(struct wined3d_texture *texture)
{ {
texture->texture_rgb.dirty = TRUE; texture->flags &= ~(WINED3D_TEXTURE_RGB_VALID | WINED3D_TEXTURE_SRGB_VALID);
texture->texture_srgb.dirty = TRUE;
} }
/* Context activation is done by the caller. */ /* Context activation is done by the caller. */
...@@ -677,14 +674,23 @@ static void texture2d_preload(struct wined3d_texture *texture, enum WINED3DSRGB ...@@ -677,14 +674,23 @@ static void texture2d_preload(struct wined3d_texture *texture, enum WINED3DSRGB
struct wined3d_device *device = texture->resource.device; struct wined3d_device *device = texture->resource.device;
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info; const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
struct wined3d_context *context = NULL; struct wined3d_context *context = NULL;
struct gl_texture *gl_tex;
BOOL srgb_mode; BOOL srgb_mode;
DWORD flag;
UINT i; UINT i;
TRACE("texture %p, srgb %#x.\n", texture, srgb); TRACE("texture %p, srgb %#x.\n", texture, srgb);
srgb_mode = texture_srgb_mode(texture, srgb); srgb_mode = texture_srgb_mode(texture, srgb);
gl_tex = wined3d_texture_get_gl_texture(texture, gl_info, srgb_mode); if (srgb_mode && !gl_info->supported[EXT_TEXTURE_SRGB_DECODE])
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;
}
if (!device->isInDraw) if (!device->isInDraw)
{ {
...@@ -693,21 +699,12 @@ static void texture2d_preload(struct wined3d_texture *texture, enum WINED3DSRGB ...@@ -693,21 +699,12 @@ static void texture2d_preload(struct wined3d_texture *texture, enum WINED3DSRGB
context = context_acquire(device, NULL); context = context_acquire(device, NULL);
} }
if (gl_tex->dirty) /* Reload the surfaces if the texture is marked dirty. */
{ for (i = 0; i < sub_count; ++i)
/* 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);
}
}
else
{ {
TRACE("Texture %p not dirty, nothing to do.\n", texture); surface_load(surface_from_resource(texture->sub_resources[i]), srgb_mode);
} }
texture->flags |= flag;
/* No longer dirty. */
gl_tex->dirty = FALSE;
if (context) context_release(context); if (context) context_release(context);
} }
...@@ -1059,35 +1056,34 @@ static void texture3d_preload(struct wined3d_texture *texture, enum WINED3DSRGB ...@@ -1059,35 +1056,34 @@ static void texture3d_preload(struct wined3d_texture *texture, enum WINED3DSRGB
struct wined3d_device *device = texture->resource.device; struct wined3d_device *device = texture->resource.device;
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info; const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
struct wined3d_context *context = NULL; struct wined3d_context *context = NULL;
struct gl_texture *gl_tex;
BOOL srgb_mode; BOOL srgb_mode;
DWORD flag;
UINT i; UINT i;
TRACE("texture %p, srgb %#x.\n", texture, srgb); TRACE("texture %p, srgb %#x.\n", texture, srgb);
srgb_mode = texture_srgb_mode(texture, srgb); srgb_mode = texture_srgb_mode(texture, srgb);
gl_tex = wined3d_texture_get_gl_texture(texture, gl_info, srgb_mode); if (srgb_mode && !gl_info->supported[EXT_TEXTURE_SRGB_DECODE])
flag = WINED3D_TEXTURE_SRGB_VALID;
else
flag = WINED3D_TEXTURE_RGB_VALID;
if (gl_tex->dirty) if (texture->flags & flag)
{ {
context = context_acquire(device, NULL); TRACE("Texture %p not dirty, nothing to do.\n", texture);
return;
}
/* Reload the surfaces if the texture is marked dirty. */ context = context_acquire(device, NULL);
for (i = 0; i < sub_count; ++i)
{
wined3d_volume_load(volume_from_resource(texture->sub_resources[i]), context,
srgb_mode);
}
context_release(context); /* Reload the surfaces if the texture is marked dirty. */
} for (i = 0; i < sub_count; ++i)
else
{ {
TRACE("Texture %p not dirty, nothing to do.\n", texture); wined3d_volume_load(volume_from_resource(texture->sub_resources[i]), context, srgb_mode);
} }
texture->flags |= flag;
/* No longer dirty. */ context_release(context);
gl_tex->dirty = FALSE;
} }
static void texture3d_sub_resource_add_dirty_region(struct wined3d_resource *sub_resource, static void texture3d_sub_resource_add_dirty_region(struct wined3d_resource *sub_resource,
......
...@@ -2057,7 +2057,6 @@ enum WINED3DSRGB ...@@ -2057,7 +2057,6 @@ enum WINED3DSRGB
struct gl_texture struct gl_texture
{ {
DWORD states[MAX_WINETEXTURESTATES]; DWORD states[MAX_WINETEXTURESTATES];
BOOL dirty;
GLuint name; GLuint name;
}; };
...@@ -2071,9 +2070,11 @@ struct wined3d_texture_ops ...@@ -2071,9 +2070,11 @@ struct wined3d_texture_ops
void (*texture_sub_resource_cleanup)(struct wined3d_resource *sub_resource); void (*texture_sub_resource_cleanup)(struct wined3d_resource *sub_resource);
}; };
#define WINED3D_TEXTURE_COND_NP2 0x1 #define WINED3D_TEXTURE_COND_NP2 0x00000001
#define WINED3D_TEXTURE_POW2_MAT_IDENT 0x2 #define WINED3D_TEXTURE_POW2_MAT_IDENT 0x00000002
#define WINED3D_TEXTURE_IS_SRGB 0x4 #define WINED3D_TEXTURE_IS_SRGB 0x00000004
#define WINED3D_TEXTURE_RGB_VALID 0x00000008
#define WINED3D_TEXTURE_SRGB_VALID 0x00000010
struct wined3d_texture struct wined3d_texture
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment