Commit 1e0603eb authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Store the power-of-two dimensions in the texture.

parent fca93ef0
......@@ -4501,25 +4501,6 @@ HRESULT wined3d_surface_init(struct wined3d_surface *surface, struct wined3d_tex
unsigned int resource_size;
HRESULT hr;
if (container->flags & WINED3D_TEXTURE_COND_NP2_EMULATED)
{
unsigned int pow2_width = 1, pow2_height = 1;
/* Find the nearest pow2 match. */
while (pow2_width < desc->width)
pow2_width <<= 1;
while (pow2_height < desc->height)
pow2_height <<= 1;
surface->pow2Width = pow2_width;
surface->pow2Height = pow2_height;
}
else
{
surface->pow2Width = desc->width;
surface->pow2Height = desc->height;
}
/* Quick lockable sanity check.
* TODO: remove this after surfaces, usage and lockability have been debugged properly
* this function is too deep to need to care about things like this.
......@@ -4564,6 +4545,8 @@ HRESULT wined3d_surface_init(struct wined3d_surface *surface, struct wined3d_tex
}
surface->container = container;
surface->pow2Width = wined3d_texture_get_level_pow2_width(container, level);
surface->pow2Height = wined3d_texture_get_level_pow2_height(container, level);
surface->texture_target = target;
surface->texture_level = level;
surface->texture_layer = layer;
......
......@@ -899,18 +899,20 @@ HRESULT CDECL wined3d_texture_update_desc(struct wined3d_texture *texture, UINT
&& !gl_info->supported[ARB_TEXTURE_RECTANGLE] && !gl_info->supported[WINED3D_GL_NORMALIZED_TEXRECT])
{
texture->flags |= WINED3D_TEXTURE_COND_NP2_EMULATED;
surface->pow2Width = surface->pow2Height = 1;
while (surface->pow2Width < width)
surface->pow2Width <<= 1;
while (surface->pow2Height < height)
surface->pow2Height <<= 1;
texture->pow2_width = texture->pow2_height = 1;
while (texture->pow2_width < width)
texture->pow2_width <<= 1;
while (texture->pow2_height < height)
texture->pow2_height <<= 1;
}
else
{
texture->flags &= ~WINED3D_TEXTURE_COND_NP2_EMULATED;
surface->pow2Width = width;
surface->pow2Height = height;
texture->pow2_width = width;
texture->pow2_height = height;
}
surface->pow2Width = texture->pow2_width;
surface->pow2Height = texture->pow2_height;
sub_resource->locations = 0;
......@@ -1556,6 +1558,8 @@ static HRESULT texture_init(struct wined3d_texture *texture, const struct wined3
texture->flags |= WINED3D_TEXTURE_COND_NP2_EMULATED;
}
}
texture->pow2_width = pow2_width;
texture->pow2_height = pow2_height;
if ((pow2_width > gl_info->limits.texture_size || pow2_height > gl_info->limits.texture_size)
&& (desc->usage & WINED3DUSAGE_TEXTURE))
......
......@@ -2449,6 +2449,8 @@ struct wined3d_texture
const struct wined3d_texture_ops *texture_ops;
struct gl_texture texture_rgb, texture_srgb;
struct wined3d_swapchain *swapchain;
unsigned int pow2_width;
unsigned int pow2_height;
UINT layer_count;
UINT level_count;
unsigned int download_count;
......@@ -2521,6 +2523,18 @@ static inline unsigned int wined3d_texture_get_level_depth(const struct wined3d_
return max(1, texture->resource.depth >> level);
}
static inline unsigned int wined3d_texture_get_level_pow2_width(const struct wined3d_texture *texture,
unsigned int level)
{
return max(1, texture->pow2_width >> level);
}
static inline unsigned int wined3d_texture_get_level_pow2_height(const struct wined3d_texture *texture,
unsigned int level)
{
return max(1, texture->pow2_height >> level);
}
void wined3d_texture_apply_sampler_desc(struct wined3d_texture *texture,
const struct wined3d_sampler_desc *sampler_desc, const struct wined3d_context *context) DECLSPEC_HIDDEN;
void wined3d_texture_bind(struct wined3d_texture *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