wined3d: Remove the redundant "pow2_width" and "pow2_height" fields.

This commit is contained in:
Elizabeth Figura 2024-03-20 16:05:50 -05:00 committed by Alexandre Julliard
parent dcb0136cc0
commit 5160533b42
5 changed files with 27 additions and 47 deletions

View file

@ -700,8 +700,8 @@ static struct fbo_entry *wined3d_context_gl_find_fbo_entry(struct wined3d_contex
{
rt_texture = wined3d_texture_from_resource(resource);
rt_level = render_targets[i].sub_resource_idx % rt_texture->level_count;
width = wined3d_texture_get_level_pow2_width(rt_texture, rt_level);
height = wined3d_texture_get_level_pow2_height(rt_texture, rt_level);
width = wined3d_texture_get_level_width(rt_texture, rt_level);
height = wined3d_texture_get_level_height(rt_texture, rt_level);
resource_type = "texture";
}
@ -723,8 +723,8 @@ static struct fbo_entry *wined3d_context_gl_find_fbo_entry(struct wined3d_contex
{
ds_texture = wined3d_texture_from_resource(resource);
ds_level = depth_stencil->sub_resource_idx % ds_texture->level_count;
width = wined3d_texture_get_level_pow2_width(ds_texture, ds_level);
height = wined3d_texture_get_level_pow2_height(ds_texture, ds_level);
width = wined3d_texture_get_level_width(ds_texture, ds_level);
height = wined3d_texture_get_level_height(ds_texture, ds_level);
resource_type = "texture";
}

View file

@ -13321,8 +13321,8 @@ static DWORD glsl_blitter_blit(struct wined3d_blitter *blitter, enum wined3d_bli
case COMPLEX_FIXUP_YUV:
src_level = src_sub_resource_idx % src_texture->level_count;
location = GL_EXTCALL(glGetUniformLocation(program->id, "size"));
GL_EXTCALL(glUniform2f(location, wined3d_texture_get_level_pow2_width(src_texture, src_level),
wined3d_texture_get_level_pow2_height(src_texture, src_level)));
GL_EXTCALL(glUniform2f(location, wined3d_texture_get_level_width(src_texture, src_level),
wined3d_texture_get_level_height(src_texture, src_level)));
break;
default:

View file

@ -180,8 +180,8 @@ void texture2d_get_blt_info(const struct wined3d_texture_gl *texture_gl,
GLsizei w, h;
level = sub_resource_idx % texture_gl->t.level_count;
w = wined3d_texture_get_level_pow2_width(&texture_gl->t, level);
h = wined3d_texture_get_level_pow2_height(&texture_gl->t, level);
w = wined3d_texture_get_level_width(&texture_gl->t, level);
h = wined3d_texture_get_level_height(&texture_gl->t, level);
target = wined3d_texture_gl_get_sub_resource_target(texture_gl, sub_resource_idx);
switch (target)
@ -996,8 +996,8 @@ static void wined3d_texture_gl_allocate_mutable_storage(struct wined3d_texture_g
for (level = 0; level < level_count; ++level)
{
width = wined3d_texture_get_level_pow2_width(&texture_gl->t, level);
height = wined3d_texture_get_level_pow2_height(&texture_gl->t, level);
width = wined3d_texture_get_level_width(&texture_gl->t, level);
height = wined3d_texture_get_level_height(&texture_gl->t, level);
if (texture_gl->t.resource.format_attrs & WINED3D_FORMAT_ATTR_HEIGHT_SCALE)
{
height *= format->f.height_scale.numerator;
@ -1037,10 +1037,10 @@ static void wined3d_texture_gl_allocate_immutable_storage(struct wined3d_texture
GLenum gl_internal_format, const struct wined3d_gl_info *gl_info)
{
unsigned int samples = wined3d_resource_get_sample_count(&texture_gl->t.resource);
GLsizei height = wined3d_texture_get_level_pow2_height(&texture_gl->t, 0);
GLsizei width = wined3d_texture_get_level_pow2_width(&texture_gl->t, 0);
GLboolean standard_pattern = texture_gl->t.resource.multisample_type != WINED3D_MULTISAMPLE_NON_MASKABLE
&& texture_gl->t.resource.multisample_quality == WINED3D_STANDARD_MULTISAMPLE_PATTERN;
GLsizei height = wined3d_texture_get_level_height(&texture_gl->t, 0);
GLsizei width = wined3d_texture_get_level_width(&texture_gl->t, 0);
switch (texture_gl->target)
{
@ -1846,17 +1846,17 @@ void wined3d_texture_gl_set_compatible_renderbuffer(struct wined3d_texture_gl *t
rt_texture = wined3d_texture_from_resource(rt->resource);
rt_level = rt->sub_resource_idx % rt_texture->level_count;
width = wined3d_texture_get_level_pow2_width(rt_texture, rt_level);
height = wined3d_texture_get_level_pow2_height(rt_texture, rt_level);
width = wined3d_texture_get_level_width(rt_texture, rt_level);
height = wined3d_texture_get_level_height(rt_texture, rt_level);
}
else
{
width = wined3d_texture_get_level_pow2_width(&texture_gl->t, level);
height = wined3d_texture_get_level_pow2_height(&texture_gl->t, level);
width = wined3d_texture_get_level_width(&texture_gl->t, level);
height = wined3d_texture_get_level_height(&texture_gl->t, level);
}
src_width = wined3d_texture_get_level_pow2_width(&texture_gl->t, level);
src_height = wined3d_texture_get_level_pow2_height(&texture_gl->t, level);
src_width = wined3d_texture_get_level_width(&texture_gl->t, level);
src_height = wined3d_texture_get_level_height(&texture_gl->t, level);
/* A depth stencil smaller than the render target is not valid */
if (width > src_width || height > src_height)
@ -3672,7 +3672,6 @@ static HRESULT wined3d_texture_init(struct wined3d_texture *texture, const struc
const struct wined3d_d3d_info *d3d_info = &device->adapter->d3d_info;
struct wined3d_device_parent *device_parent = device->device_parent;
unsigned int sub_count, i, j, size, offset = 0;
unsigned int pow2_width, pow2_height;
const struct wined3d_format *format;
HRESULT hr;
@ -3710,8 +3709,6 @@ static HRESULT wined3d_texture_init(struct wined3d_texture *texture, const struc
return WINED3DERR_INVALIDCALL;
}
pow2_width = desc->width;
pow2_height = desc->height;
if (((desc->width & (desc->width - 1)) || (desc->height & (desc->height - 1)) || (desc->depth & (desc->depth - 1)))
&& !d3d_info->unconditional_npot)
{
@ -3729,16 +3726,13 @@ static HRESULT wined3d_texture_init(struct wined3d_texture *texture, const struc
}
texture->flags |= WINED3D_TEXTURE_COND_NP2;
}
texture->pow2_width = pow2_width;
texture->pow2_height = pow2_height;
if ((pow2_width > d3d_info->limits.texture_size || pow2_height > d3d_info->limits.texture_size)
if ((desc->width > d3d_info->limits.texture_size || desc->height > d3d_info->limits.texture_size)
&& (desc->bind_flags & WINED3D_BIND_SHADER_RESOURCE))
{
/* One of four options:
* 1: Do the same as we do with NPOT and scale the texture. (Any
* texture ops would require the texture to be scaled which is
* potentially slow.)
* 1: Scale the texture. (Any texture ops would require the texture to
* be scaled which is potentially slow.)
* 2: Set the texture to the maximum size (bad idea).
* 3: WARN and return WINED3DERR_NOTAVAILABLE.
* 4: Create the surface, but allow it to be used only for DirectDraw
@ -3747,12 +3741,12 @@ static HRESULT wined3d_texture_init(struct wined3d_texture *texture, const struc
* the render target. */
if (desc->access & WINED3D_RESOURCE_ACCESS_GPU)
{
WARN("Dimensions (%ux%u) exceed the maximum texture size.\n", pow2_width, pow2_height);
WARN("Dimensions (%ux%u) exceed the maximum texture size.\n", desc->width, desc->height);
return WINED3DERR_NOTAVAILABLE;
}
/* We should never use this surface in combination with OpenGL. */
TRACE("Creating an oversized (%ux%u) surface.\n", pow2_width, pow2_height);
TRACE("Creating an oversized (%ux%u) surface.\n", desc->width, desc->height);
}
for (i = 0; i < layer_count; ++i)
@ -5809,8 +5803,8 @@ static void ffp_blitter_clear_rendertargets(struct wined3d_device *device, unsig
unsigned int ds_level = dsv->sub_resource_idx % depth_stencil->level_count;
render_offscreen = true;
drawable_width = wined3d_texture_get_level_pow2_width(depth_stencil, ds_level);
drawable_height = wined3d_texture_get_level_pow2_height(depth_stencil, ds_level);
drawable_width = wined3d_texture_get_level_width(depth_stencil, ds_level);
drawable_height = wined3d_texture_get_level_height(depth_stencil, ds_level);
}
if (depth_stencil)

View file

@ -470,8 +470,8 @@ void wined3d_rendertarget_view_get_drawable_size(const struct wined3d_rendertarg
/* The drawable size of an FBO target is the OpenGL texture size,
* which is the power of two size. */
*width = wined3d_texture_get_level_pow2_width(texture, level_idx);
*height = wined3d_texture_get_level_pow2_height(texture, level_idx);
*width = wined3d_texture_get_level_width(texture, level_idx);
*height = wined3d_texture_get_level_height(texture, level_idx);
}
}

View file

@ -3312,8 +3312,6 @@ struct wined3d_texture
struct wined3d_resource resource;
const struct wined3d_texture_ops *texture_ops;
struct wined3d_swapchain *swapchain;
unsigned int pow2_width;
unsigned int pow2_height;
UINT layer_count;
unsigned int level_count;
unsigned int download_count;
@ -3423,18 +3421,6 @@ 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);
}
static inline void wined3d_texture_get_level_box(const struct wined3d_texture *texture,
unsigned int level, struct wined3d_box *box)
{