diff --git a/src/gallium/auxiliary/driver_noop/noop_state.c b/src/gallium/auxiliary/driver_noop/noop_state.c index 5115e94185d..c16aeff29fa 100644 --- a/src/gallium/auxiliary/driver_noop/noop_state.c +++ b/src/gallium/auxiliary/driver_noop/noop_state.c @@ -111,8 +111,6 @@ static struct pipe_surface *noop_create_surface(struct pipe_context *ctx, pipe_resource_reference(&surface->texture, texture); surface->context = ctx; surface->format = surf_tmpl->format; - surface->width = texture->width0; - surface->height = texture->height0; surface->texture = texture; surface->u.tex.first_layer = surf_tmpl->u.tex.first_layer; surface->u.tex.last_layer = surf_tmpl->u.tex.last_layer; diff --git a/src/gallium/auxiliary/driver_trace/tr_dump_state.c b/src/gallium/auxiliary/driver_trace/tr_dump_state.c index 51cbde2c721..d83e20d5f09 100644 --- a/src/gallium/auxiliary/driver_trace/tr_dump_state.c +++ b/src/gallium/auxiliary/driver_trace/tr_dump_state.c @@ -697,8 +697,6 @@ void trace_dump_surface_template(const struct pipe_surface *state, trace_dump_member(format, state, format); trace_dump_member(ptr, state, texture); - trace_dump_member(uint, state, width); - trace_dump_member(uint, state, height); trace_dump_member_begin("target"); trace_dump_enum(tr_util_pipe_texture_target_name(target)); diff --git a/src/gallium/auxiliary/util/u_blitter.c b/src/gallium/auxiliary/util/u_blitter.c index ff16752556a..7d11c0d29b7 100644 --- a/src/gallium/auxiliary/util/u_blitter.c +++ b/src/gallium/auxiliary/util/u_blitter.c @@ -1821,8 +1821,7 @@ static void do_blits(struct blitter_context_priv *ctx, struct pipe_framebuffer_state fb_state = {0}; /* Initialize framebuffer state. */ - fb_state.width = dst->width; - fb_state.height = dst->height; + pipe_surface_size(dst, &fb_state.width, &fb_state.height); fb_state.nr_cbufs = is_zsbuf ? 0 : 1; blitter_set_dst_dimensions(ctx, fb_state.width, fb_state.height); @@ -2378,8 +2377,7 @@ void util_blitter_clear_render_target(struct blitter_context *blitter, bind_fs_clear_color(ctx, false); /* set a framebuffer state */ - fb_state.width = dstsurf->width; - fb_state.height = dstsurf->height; + pipe_surface_size(dstsurf, &fb_state.width, &fb_state.height); fb_state.nr_cbufs = 1; fb_state.cbufs[0] = dstsurf; fb_state.zsbuf = NULL; @@ -2390,7 +2388,7 @@ void util_blitter_clear_render_target(struct blitter_context *blitter, pipe->set_min_samples(pipe, 1); msaa = util_framebuffer_get_num_samples(&fb_state) > 1; - blitter_set_dst_dimensions(ctx, dstsurf->width, dstsurf->height); + blitter_set_dst_dimensions(ctx, fb_state.width, fb_state.height); blitter_set_common_draw_rect_state(ctx, false, msaa); struct pipe_constant_buffer cb = { @@ -2469,8 +2467,7 @@ void util_blitter_clear_depth_stencil(struct blitter_context *blitter, bind_fs_empty(ctx); /* set a framebuffer state */ - fb_state.width = dstsurf->width; - fb_state.height = dstsurf->height; + pipe_surface_size(dstsurf, &fb_state.width, &fb_state.height); fb_state.nr_cbufs = 0; fb_state.cbufs[0] = NULL; fb_state.zsbuf = dstsurf; @@ -2480,7 +2477,7 @@ void util_blitter_clear_depth_stencil(struct blitter_context *blitter, if (pipe->set_min_samples) pipe->set_min_samples(pipe, 1); - blitter_set_dst_dimensions(ctx, dstsurf->width, dstsurf->height); + blitter_set_dst_dimensions(ctx, fb_state.width, fb_state.height); num_layers = dstsurf->u.tex.last_layer - dstsurf->u.tex.first_layer + 1; if (num_layers > 1 && ctx->has_layered) { @@ -2535,8 +2532,7 @@ void util_blitter_custom_depth_stencil(struct blitter_context *blitter, bind_fs_empty(ctx); /* set a framebuffer state */ - fb_state.width = zsurf->width; - fb_state.height = zsurf->height; + pipe_surface_size(zsurf, &fb_state.width, &fb_state.height); fb_state.nr_cbufs = 1; if (cbsurf) { fb_state.cbufs[0] = cbsurf; @@ -2554,9 +2550,9 @@ void util_blitter_custom_depth_stencil(struct blitter_context *blitter, blitter_set_common_draw_rect_state(ctx, false, util_framebuffer_get_num_samples(&fb_state) > 1); - blitter_set_dst_dimensions(ctx, zsurf->width, zsurf->height); + blitter_set_dst_dimensions(ctx, fb_state.width, fb_state.height); blitter->draw_rectangle(blitter, ctx->velem_state, get_vs_passthrough_pos, - 0, 0, zsurf->width, zsurf->height, depth, + 0, 0, fb_state.width, fb_state.height, depth, 1, UTIL_BLITTER_ATTRIB_NONE, NULL); util_blitter_restore_vertex_states(blitter); @@ -2728,8 +2724,7 @@ void util_blitter_custom_color(struct blitter_context *blitter, bind_fs_clear_color(ctx, false); /* set a framebuffer state */ - fb_state.width = dstsurf->width; - fb_state.height = dstsurf->height; + pipe_surface_size(dstsurf, &fb_state.width, &fb_state.height); fb_state.nr_cbufs = 1; fb_state.cbufs[0] = dstsurf; fb_state.zsbuf = NULL; @@ -2741,9 +2736,9 @@ void util_blitter_custom_color(struct blitter_context *blitter, blitter_set_common_draw_rect_state(ctx, false, util_framebuffer_get_num_samples(&fb_state) > 1); - blitter_set_dst_dimensions(ctx, dstsurf->width, dstsurf->height); + blitter_set_dst_dimensions(ctx, fb_state.width, fb_state.height); blitter->draw_rectangle(blitter, ctx->velem_state, get_vs_passthrough_pos, - 0, 0, dstsurf->width, dstsurf->height, + 0, 0, fb_state.width, fb_state.height, 0, 1, UTIL_BLITTER_ATTRIB_NONE, NULL); util_blitter_restore_vertex_states(blitter); @@ -2768,6 +2763,7 @@ static void *get_custom_vs(struct blitter_context *blitter) */ void util_blitter_custom_shader(struct blitter_context *blitter, struct pipe_surface *dstsurf, + uint16_t width, uint16_t height, void *custom_vs, void *custom_fs) { struct blitter_context_priv *ctx = (struct blitter_context_priv*)blitter; @@ -2793,8 +2789,8 @@ void util_blitter_custom_shader(struct blitter_context *blitter, pipe->bind_fs_state(pipe, custom_fs); /* set a framebuffer state */ - fb_state.width = dstsurf->width; - fb_state.height = dstsurf->height; + fb_state.width = width; + fb_state.height = height; fb_state.nr_cbufs = 1; fb_state.cbufs[0] = dstsurf; fb_state.resolve = NULL; @@ -2805,9 +2801,9 @@ void util_blitter_custom_shader(struct blitter_context *blitter, blitter_set_common_draw_rect_state(ctx, false, util_framebuffer_get_num_samples(&fb_state) > 1); - blitter_set_dst_dimensions(ctx, dstsurf->width, dstsurf->height); + blitter_set_dst_dimensions(ctx, fb_state.width, fb_state.height); blitter->draw_rectangle(blitter, ctx->velem_state, get_custom_vs, - 0, 0, dstsurf->width, dstsurf->height, + 0, 0, fb_state.width, fb_state.height, 0, 1, UTIL_BLITTER_ATTRIB_NONE, NULL); util_blitter_restore_vertex_states(blitter); @@ -2902,7 +2898,8 @@ util_blitter_stencil_fallback(struct blitter_context *blitter, blitter_set_common_draw_rect_state(ctx, scissor != NULL, util_framebuffer_get_num_samples(&fb_state) > 1); - blitter_set_dst_dimensions(ctx, dst_view->width, dst_view->height); + blitter_set_dst_dimensions(ctx, pipe_surface_width(dst_view), + pipe_surface_height(dst_view)); if (scissor) { pipe->set_scissor_states(pipe, 0, 1, scissor); diff --git a/src/gallium/auxiliary/util/u_blitter.h b/src/gallium/auxiliary/util/u_blitter.h index f59a5109da5..b9d445b1363 100644 --- a/src/gallium/auxiliary/util/u_blitter.h +++ b/src/gallium/auxiliary/util/u_blitter.h @@ -389,6 +389,7 @@ void util_blitter_custom_resolve_color(struct blitter_context *blitter, /* Used by vc4 for 8/16-bit linear-to-tiled blits */ void util_blitter_custom_shader(struct blitter_context *blitter, struct pipe_surface *dstsurf, + uint16_t width, uint16_t height, void *custom_vs, void *custom_fs); /* Used by D3D12 for non-MSAA -> MSAA stencil blits */ diff --git a/src/gallium/auxiliary/util/u_debug_image.c b/src/gallium/auxiliary/util/u_debug_image.c index d615ba16906..0ee9be02051 100644 --- a/src/gallium/auxiliary/util/u_debug_image.c +++ b/src/gallium/auxiliary/util/u_debug_image.c @@ -112,19 +112,19 @@ debug_dump_surface(struct pipe_context *pipe, * to be done here: */ texture = surface->texture; - data = pipe_texture_map(pipe, texture, surface->u.tex.level, surface->u.tex.first_layer, PIPE_MAP_READ, - 0, 0, surface->width, surface->height, &transfer); + 0, 0, pipe_surface_width(surface), + pipe_surface_height(surface), &transfer); if (!data) return; debug_dump_image(prefix, texture->format, util_format_get_blocksize(texture->format), - util_format_get_nblocksx(texture->format, surface->width), - util_format_get_nblocksy(texture->format, surface->height), + util_format_get_nblocksx(texture->format, pipe_surface_width(surface)), + util_format_get_nblocksy(texture->format, pipe_surface_height(surface)), transfer->stride, data); @@ -194,7 +194,8 @@ debug_dump_surface_bmp(struct pipe_context *pipe, ptr = pipe_texture_map(pipe, texture, surface->u.tex.level, surface->u.tex.first_layer, PIPE_MAP_READ, - 0, 0, surface->width, surface->height, &transfer); + 0, 0, pipe_surface_width(surface), + pipe_surface_height(surface), &transfer); debug_dump_transfer_bmp(pipe, filename, transfer, ptr); diff --git a/src/gallium/auxiliary/util/u_dump_state.c b/src/gallium/auxiliary/util/u_dump_state.c index 4c6262a75a9..0efcca8372e 100644 --- a/src/gallium/auxiliary/util/u_dump_state.c +++ b/src/gallium/auxiliary/util/u_dump_state.c @@ -712,8 +712,6 @@ util_dump_surface(FILE *stream, const struct pipe_surface *state) util_dump_struct_begin(stream, "pipe_surface"); util_dump_member(stream, format, state, format); - util_dump_member(stream, uint, state, width); - util_dump_member(stream, uint, state, height); util_dump_member(stream, ptr, state, texture); util_dump_member(stream, uint, state, u.tex.level); diff --git a/src/gallium/auxiliary/util/u_framebuffer.c b/src/gallium/auxiliary/util/u_framebuffer.c index 0ed41648189..054803ff024 100644 --- a/src/gallium/auxiliary/util/u_framebuffer.c +++ b/src/gallium/auxiliary/util/u_framebuffer.c @@ -168,13 +168,18 @@ util_framebuffer_min_size(const struct pipe_framebuffer_state *fb, if (!fb->cbufs[i]) continue; - w = MIN2(w, fb->cbufs[i]->width); - h = MIN2(h, fb->cbufs[i]->height); + uint16_t width, height; + pipe_surface_size(fb->cbufs[i], &width, &height); + + w = MIN2(w, width); + h = MIN2(h, height); } if (fb->zsbuf) { - w = MIN2(w, fb->zsbuf->width); - h = MIN2(h, fb->zsbuf->height); + uint16_t width, height; + pipe_surface_size(fb->zsbuf, &width, &height); + w = MIN2(w, width); + h = MIN2(h, height); } if (w == ~0u) { diff --git a/src/gallium/auxiliary/util/u_inlines.h b/src/gallium/auxiliary/util/u_inlines.h index 3319541724b..0b7097ab42b 100644 --- a/src/gallium/auxiliary/util/u_inlines.h +++ b/src/gallium/auxiliary/util/u_inlines.h @@ -345,8 +345,6 @@ pipe_surface_reset(struct pipe_context *ctx, struct pipe_surface* ps, { pipe_resource_reference(&ps->texture, pt); ps->format = pt->format; - ps->width = (uint16_t)u_minify(pt->width0, level); - ps->height = (uint16_t)u_minify(pt->height0, level); ps->u.tex.level = level; ps->u.tex.first_layer = ps->u.tex.last_layer = layer; ps->context = ctx; @@ -361,6 +359,67 @@ pipe_surface_init(struct pipe_context *ctx, struct pipe_surface* ps, pipe_surface_reset(ctx, ps, pt, level, layer); } +static inline unsigned +pipe_surface_width(const struct pipe_surface *ps) +{ + if (ps->texture->target == PIPE_BUFFER) { + /* TODO: delete clover */ + return ps->u.buf.last_element - ps->u.buf.first_element + 1; + } + + unsigned width = (uint16_t)u_minify(ps->texture->width0, ps->u.tex.level); + + /* adjust texture view size to get full blocksize on compressed formats */ + if (!util_format_is_depth_or_stencil(ps->texture->format) && ps->format != ps->texture->format) { + const struct util_format_description *res_desc = util_format_description(ps->texture->format); + const struct util_format_description *surf_desc = util_format_description(ps->format); + + if (res_desc->block.width != surf_desc->block.width || + res_desc->block.height != surf_desc->block.height) { + unsigned nblks_x = util_format_get_nblocksx(ps->texture->format, width); + width = nblks_x * surf_desc->block.width; + } + } + + return width; +} + +static inline unsigned +pipe_surface_height(const struct pipe_surface *ps) +{ + if (ps->texture->target == PIPE_BUFFER) { + /* TODO: delete clover */ + return ps->texture->height0; + } + + unsigned height = u_minify(ps->texture->height0, ps->u.tex.level); + + /* adjust texture view size to get full blocksize on compressed formats */ + if (!util_format_is_depth_or_stencil(ps->texture->format) && ps->format != ps->texture->format) { + const struct util_format_description *res_desc = util_format_description(ps->texture->format); + const struct util_format_description *surf_desc = util_format_description(ps->format); + + if (res_desc->block.width != surf_desc->block.width || + res_desc->block.height != surf_desc->block.height) { + + unsigned nblks_y = util_format_get_nblocksy(ps->texture->format, height); + height = nblks_y * surf_desc->block.height; + } + } + + return height; +} + +static inline void +pipe_surface_size(const struct pipe_surface *ps, uint16_t *width, uint16_t *height) +{ + if (width) + *width = (uint16_t)pipe_surface_width(ps); + + if (height) + *height = (uint16_t)pipe_surface_height(ps); +} + /* Return true if the surfaces are equal. */ static inline bool pipe_surface_equal(struct pipe_surface *s1, struct pipe_surface *s2) diff --git a/src/gallium/auxiliary/util/u_tracepoints.py b/src/gallium/auxiliary/util/u_tracepoints.py index 30aaab9df1d..f1608aa05b8 100644 --- a/src/gallium/auxiliary/util/u_tracepoints.py +++ b/src/gallium/auxiliary/util/u_tracepoints.py @@ -50,13 +50,9 @@ Header('util/format/u_format.h') Tracepoint('surface', args=[ArgStruct(type='const struct pipe_surface *', var='psurf')], - tp_struct=[Arg(type='uint16_t', name='width', var='psurf->width', c_format='%u'), - Arg(type='uint16_t', name='height', var='psurf->height', c_format='%u'), - Arg(type='uint8_t', name='nr_samples', var='psurf->nr_samples', c_format='%u'), + tp_struct=[Arg(type='uint8_t', name='nr_samples', var='psurf->nr_samples', c_format='%u'), Arg(type='const char *', name='format', var='util_format_short_name(psurf->format)', c_format='%s')], - tp_print=['%ux%u@%u, fmt=%s', - '__entry->width', - '__entry->height', + tp_print=['%u samples, fmt=%s', '__entry->nr_samples', '__entry->format'], ) diff --git a/src/gallium/auxiliary/vl/vl_bicubic_filter.c b/src/gallium/auxiliary/vl/vl_bicubic_filter.c index 88232db5f9b..17fda6251ea 100644 --- a/src/gallium/auxiliary/vl/vl_bicubic_filter.c +++ b/src/gallium/auxiliary/vl/vl_bicubic_filter.c @@ -403,8 +403,8 @@ vl_bicubic_filter_render(struct vl_bicubic_filter *filter, } else { scissor.minx = 0; scissor.miny = 0; - scissor.maxx = dst->width; - scissor.maxy = dst->height; + scissor.maxx = pipe_surface_width(dst); + scissor.maxy = pipe_surface_height(dst); } clear_color.f[0] = clear_color.f[1] = 0.0f; @@ -417,8 +417,8 @@ vl_bicubic_filter_render(struct vl_bicubic_filter *filter, viewport.translate[0] = dst_area->x0; viewport.translate[1] = dst_area->y0; } else { - viewport.scale[0] = dst->width; - viewport.scale[1] = dst->height; + viewport.scale[0] = pipe_surface_width(dst); + viewport.scale[1] = pipe_surface_height(dst); } viewport.scale[2] = 1; viewport.swizzle_x = PIPE_VIEWPORT_SWIZZLE_POSITIVE_X; @@ -440,14 +440,15 @@ vl_bicubic_filter_render(struct vl_bicubic_filter *filter, u_upload_unmap(filter->pipe->const_uploader); memset(&fb_state, 0, sizeof(fb_state)); - fb_state.width = dst->width; - fb_state.height = dst->height; + fb_state.width = pipe_surface_width(dst); + fb_state.height = pipe_surface_height(dst); fb_state.nr_cbufs = 1; fb_state.cbufs[0] = dst; filter->pipe->set_scissor_states(filter->pipe, 0, 1, &scissor); filter->pipe->clear_render_target(filter->pipe, dst, &clear_color, - 0, 0, dst->width, dst->height, false); + 0, 0, pipe_surface_width(dst), + pipe_surface_height(dst), false); filter->pipe->set_constant_buffer(filter->pipe, PIPE_SHADER_FRAGMENT, 0, false, &cb); filter->pipe->bind_rasterizer_state(filter->pipe, filter->rs_state); diff --git a/src/gallium/auxiliary/vl/vl_compositor_cs.c b/src/gallium/auxiliary/vl/vl_compositor_cs.c index dca1270a9dc..fda3c47e8b4 100644 --- a/src/gallium/auxiliary/vl/vl_compositor_cs.c +++ b/src/gallium/auxiliary/vl/vl_compositor_cs.c @@ -895,22 +895,21 @@ vl_compositor_cs_render(struct vl_compositor_state *s, assert(c && s); assert(dst_surface); - c->fb_state.width = dst_surface->width; - c->fb_state.height = dst_surface->height; + pipe_surface_size(dst_surface, &c->fb_state.width, &c->fb_state.height); c->fb_state.cbufs[0] = dst_surface; if (!s->scissor_valid) { s->scissor.minx = 0; s->scissor.miny = 0; - s->scissor.maxx = dst_surface->width; - s->scissor.maxy = dst_surface->height; + s->scissor.maxx = c->fb_state.width; + s->scissor.maxy = c->fb_state.height; } if (clear_dirty && dirty_area && (dirty_area->x0 < dirty_area->x1 || dirty_area->y0 < dirty_area->y1)) { c->pipe->clear_render_target(c->pipe, dst_surface, &s->clear_color, - 0, 0, dst_surface->width, dst_surface->height, false); + 0, 0, c->fb_state.width, c->fb_state.height, false); dirty_area->x0 = dirty_area->y0 = VL_COMPOSITOR_MAX_DIRTY; dirty_area->x1 = dirty_area->y1 = VL_COMPOSITOR_MIN_DIRTY; } diff --git a/src/gallium/auxiliary/vl/vl_compositor_gfx.c b/src/gallium/auxiliary/vl/vl_compositor_gfx.c index d208f8aa37d..75d5c7f6c0c 100644 --- a/src/gallium/auxiliary/vl/vl_compositor_gfx.c +++ b/src/gallium/auxiliary/vl/vl_compositor_gfx.c @@ -713,15 +713,14 @@ vl_compositor_gfx_render(struct vl_compositor_state *s, assert(c); assert(dst_surface); - c->fb_state.width = dst_surface->width; - c->fb_state.height = dst_surface->height; + pipe_surface_size(dst_surface, &c->fb_state.width, &c->fb_state.height); c->fb_state.cbufs[0] = dst_surface; if (!s->scissor_valid) { s->scissor.minx = 0; s->scissor.miny = 0; - s->scissor.maxx = dst_surface->width; - s->scissor.maxy = dst_surface->height; + s->scissor.maxx = c->fb_state.width; + s->scissor.maxy = c->fb_state.height; } c->pipe->set_scissor_states(c->pipe, 0, 1, &s->scissor); @@ -732,7 +731,7 @@ vl_compositor_gfx_render(struct vl_compositor_state *s, (dirty_area->x0 < dirty_area->x1 || dirty_area->y0 < dirty_area->y1)) { c->pipe->clear_render_target(c->pipe, dst_surface, &s->clear_color, - 0, 0, dst_surface->width, dst_surface->height, false); + 0, 0, c->fb_state.width, c->fb_state.height, false); dirty_area->x0 = dirty_area->y0 = VL_COMPOSITOR_MAX_DIRTY; dirty_area->x1 = dirty_area->y1 = VL_COMPOSITOR_MIN_DIRTY; } diff --git a/src/gallium/auxiliary/vl/vl_matrix_filter.c b/src/gallium/auxiliary/vl/vl_matrix_filter.c index 616a9eb5894..09a72ba50ed 100644 --- a/src/gallium/auxiliary/vl/vl_matrix_filter.c +++ b/src/gallium/auxiliary/vl/vl_matrix_filter.c @@ -283,8 +283,8 @@ vl_matrix_filter_render(struct vl_matrix_filter *filter, assert(filter && src && dst); memset(&viewport, 0, sizeof(viewport)); - viewport.scale[0] = dst->width; - viewport.scale[1] = dst->height; + viewport.scale[0] = pipe_surface_width(dst); + viewport.scale[1] = pipe_surface_height(dst); viewport.scale[2] = 1; viewport.swizzle_x = PIPE_VIEWPORT_SWIZZLE_POSITIVE_X; viewport.swizzle_y = PIPE_VIEWPORT_SWIZZLE_POSITIVE_Y; @@ -292,8 +292,8 @@ vl_matrix_filter_render(struct vl_matrix_filter *filter, viewport.swizzle_w = PIPE_VIEWPORT_SWIZZLE_POSITIVE_W; memset(&fb_state, 0, sizeof(fb_state)); - fb_state.width = dst->width; - fb_state.height = dst->height; + fb_state.width = pipe_surface_width(dst); + fb_state.height = pipe_surface_height(dst); fb_state.nr_cbufs = 1; fb_state.cbufs[0] = dst; diff --git a/src/gallium/auxiliary/vl/vl_mc.c b/src/gallium/auxiliary/vl/vl_mc.c index 1d71be70070..c69f1ee910e 100644 --- a/src/gallium/auxiliary/vl/vl_mc.c +++ b/src/gallium/auxiliary/vl/vl_mc.c @@ -586,11 +586,11 @@ vl_mc_set_surface(struct vl_mc_buffer *buffer, struct pipe_surface *surface) buffer->surface_cleared = false; - buffer->viewport.scale[0] = surface->width; - buffer->viewport.scale[1] = surface->height; + buffer->viewport.scale[0] = pipe_surface_width(surface); + buffer->viewport.scale[1] = pipe_surface_height(surface); - buffer->fb_state.width = surface->width; - buffer->fb_state.height = surface->height; + buffer->fb_state.width = pipe_surface_width(surface); + buffer->fb_state.height = pipe_surface_height(surface); buffer->fb_state.cbufs[0] = surface; } diff --git a/src/gallium/auxiliary/vl/vl_median_filter.c b/src/gallium/auxiliary/vl/vl_median_filter.c index 4fe3456c5b8..d9c89419022 100644 --- a/src/gallium/auxiliary/vl/vl_median_filter.c +++ b/src/gallium/auxiliary/vl/vl_median_filter.c @@ -401,8 +401,8 @@ vl_median_filter_render(struct vl_median_filter *filter, assert(filter && src && dst); memset(&viewport, 0, sizeof(viewport)); - viewport.scale[0] = dst->width; - viewport.scale[1] = dst->height; + viewport.scale[0] = pipe_surface_width(dst); + viewport.scale[1] = pipe_surface_height(dst); viewport.scale[2] = 1; viewport.swizzle_x = PIPE_VIEWPORT_SWIZZLE_POSITIVE_X; viewport.swizzle_y = PIPE_VIEWPORT_SWIZZLE_POSITIVE_Y; @@ -410,8 +410,8 @@ vl_median_filter_render(struct vl_median_filter *filter, viewport.swizzle_w = PIPE_VIEWPORT_SWIZZLE_POSITIVE_W; memset(&fb_state, 0, sizeof(fb_state)); - fb_state.width = dst->width; - fb_state.height = dst->height; + fb_state.width = pipe_surface_width(dst); + fb_state.height = pipe_surface_height(dst); fb_state.nr_cbufs = 1; fb_state.cbufs[0] = dst; diff --git a/src/gallium/auxiliary/vl/vl_zscan.c b/src/gallium/auxiliary/vl/vl_zscan.c index 1b24d9aa272..2493f64993c 100644 --- a/src/gallium/auxiliary/vl/vl_zscan.c +++ b/src/gallium/auxiliary/vl/vl_zscan.c @@ -424,8 +424,8 @@ vl_zscan_init_buffer(struct vl_zscan *zscan, struct vl_zscan_buffer *buffer, pipe_sampler_view_reference(&buffer->src, src); - buffer->viewport.scale[0] = dst->width; - buffer->viewport.scale[1] = dst->height; + buffer->viewport.scale[0] = pipe_surface_width(dst); + buffer->viewport.scale[1] = pipe_surface_height(dst); buffer->viewport.scale[2] = 1; buffer->viewport.translate[0] = 0; buffer->viewport.translate[1] = 0; @@ -435,8 +435,8 @@ vl_zscan_init_buffer(struct vl_zscan *zscan, struct vl_zscan_buffer *buffer, buffer->viewport.swizzle_z = PIPE_VIEWPORT_SWIZZLE_POSITIVE_Z; buffer->viewport.swizzle_w = PIPE_VIEWPORT_SWIZZLE_POSITIVE_W; - buffer->fb_state.width = dst->width; - buffer->fb_state.height = dst->height; + buffer->fb_state.width = pipe_surface_width(dst); + buffer->fb_state.height = pipe_surface_height(dst); buffer->fb_state.nr_cbufs = 1; pipe_surface_reference(&buffer->fb_state.cbufs[0], dst); diff --git a/src/gallium/drivers/asahi/agx_state.c b/src/gallium/drivers/asahi/agx_state.c index c5d18f512d0..0fe609f669a 100644 --- a/src/gallium/drivers/asahi/agx_state.c +++ b/src/gallium/drivers/asahi/agx_state.c @@ -878,8 +878,6 @@ agx_create_surface(struct pipe_context *ctx, struct pipe_resource *texture, surface->context = ctx; surface->format = surf_tmpl->format; surface->nr_samples = surf_tmpl->nr_samples; - surface->width = u_minify(texture->width0, level); - surface->height = u_minify(texture->height0, level); surface->texture = texture; surface->u.tex.first_layer = surf_tmpl->u.tex.first_layer; surface->u.tex.last_layer = surf_tmpl->u.tex.last_layer; diff --git a/src/gallium/drivers/crocus/crocus_state.c b/src/gallium/drivers/crocus/crocus_state.c index 997e9bbc11e..4b66ecb11b6 100644 --- a/src/gallium/drivers/crocus/crocus_state.c +++ b/src/gallium/drivers/crocus/crocus_state.c @@ -2859,8 +2859,6 @@ crocus_create_surface(struct pipe_context *ctx, pipe_resource_reference(&psurf->texture, tex); psurf->context = ctx; psurf->format = tmpl->format; - psurf->width = tex->width0; - psurf->height = tex->height0; psurf->u.tex.first_layer = tmpl->u.tex.first_layer; psurf->u.tex.last_layer = tmpl->u.tex.last_layer; psurf->u.tex.level = tmpl->u.tex.level; @@ -3000,9 +2998,6 @@ crocus_create_surface(struct pipe_context *ctx, tile_x_sa /= fmtl->bw; tile_y_sa /= fmtl->bh; - psurf->width = surf->surf.logical_level0_px.width; - psurf->height = surf->surf.logical_level0_px.height; - return psurf; } @@ -4948,8 +4943,8 @@ emit_null_fb_surface(struct crocus_batch *batch, layer = 0; if (cso->nr_cbufs == 0 && cso->zsbuf) { - width = cso->zsbuf->width; - height = cso->zsbuf->height; + width = ((struct crocus_surface*)cso->zsbuf)->surf.logical_level0_px.width; + height = ((struct crocus_surface*)cso->zsbuf)->surf.logical_level0_px.height; level = cso->zsbuf->u.tex.level; layer = cso->zsbuf->u.tex.first_layer; } diff --git a/src/gallium/drivers/d3d12/d3d12_blit.cpp b/src/gallium/drivers/d3d12/d3d12_blit.cpp index 1b0cc9934b3..a3103755f00 100644 --- a/src/gallium/drivers/d3d12/d3d12_blit.cpp +++ b/src/gallium/drivers/d3d12/d3d12_blit.cpp @@ -509,6 +509,8 @@ resolve_stencil_to_temp(struct d3d12_context *ctx, pctx->set_sampler_views(pctx, PIPE_SHADER_FRAGMENT, 0, 1, 0, &src_view); pctx->bind_sampler_states(pctx, PIPE_SHADER_FRAGMENT, 0, 1, &sampler_state); util_blitter_custom_shader(ctx->blitter, dst_surf, + (uint16_t)pipe_surface_width(dst_surf), + (uint16_t)pipe_surface_height(dst_surf), get_stencil_resolve_vs(ctx), get_stencil_resolve_fs(ctx, info->src.box.height == info->dst.box.height)); util_blitter_restore_textures(ctx->blitter); diff --git a/src/gallium/drivers/d3d12/d3d12_context_graphics.cpp b/src/gallium/drivers/d3d12/d3d12_context_graphics.cpp index 1a963d8c301..64b4205acf1 100644 --- a/src/gallium/drivers/d3d12/d3d12_context_graphics.cpp +++ b/src/gallium/drivers/d3d12/d3d12_context_graphics.cpp @@ -2059,8 +2059,10 @@ d3d12_clear(struct pipe_context *pctx, for (int i = 0; i < ctx->fb.nr_cbufs; ++i) { if (buffers & (PIPE_CLEAR_COLOR0 << i)) { struct pipe_surface *psurf = ctx->fb.cbufs[i]; + uint16_t width, height; + pipe_surface_size(psurf, &width, &height); d3d12_clear_render_target(pctx, psurf, color, - 0, 0, psurf->width, psurf->height, + 0, 0, width, height, true); } } @@ -2068,10 +2070,12 @@ d3d12_clear(struct pipe_context *pctx, if (buffers & PIPE_CLEAR_DEPTHSTENCIL && ctx->fb.zsbuf) { struct pipe_surface *psurf = ctx->fb.zsbuf; + uint16_t width, height; + pipe_surface_size(psurf, &width, &height); d3d12_clear_depth_stencil(pctx, psurf, buffers & PIPE_CLEAR_DEPTHSTENCIL, depth, stencil, - 0, 0, psurf->width, psurf->height, + 0, 0, width, height, true); } } diff --git a/src/gallium/drivers/d3d12/d3d12_surface.cpp b/src/gallium/drivers/d3d12/d3d12_surface.cpp index 5b40eab136b..9a10f73622a 100644 --- a/src/gallium/drivers/d3d12/d3d12_surface.cpp +++ b/src/gallium/drivers/d3d12/d3d12_surface.cpp @@ -248,8 +248,6 @@ d3d12_create_surface(struct pipe_context *pctx, pipe_reference_init(&surface->base.reference, 1); surface->base.context = pctx; surface->base.format = tpl->format; - surface->base.width = static_cast(u_minify(pres->width0, tpl->u.tex.level)); - surface->base.height = static_cast(u_minify(pres->height0, tpl->u.tex.level)); surface->base.u.tex.level = tpl->u.tex.level; surface->base.u.tex.first_layer = tpl->u.tex.first_layer; surface->base.u.tex.last_layer = tpl->u.tex.last_layer; @@ -294,8 +292,8 @@ blit_surface(struct pipe_context *pctx, struct d3d12_surface *surface, bool pre) info.src.box.x = info.dst.box.x = 0; info.src.box.y = info.dst.box.y = 0; info.src.box.z = info.dst.box.z = 0; - info.src.box.width = info.dst.box.width = surface->base.width; - info.src.box.height = info.dst.box.height = surface->base.height; + info.src.box.width = info.dst.box.width = pipe_surface_width(&surface->base); + info.src.box.height = info.dst.box.height = pipe_surface_height(&surface->base); info.src.box.depth = info.dst.box.depth = 0; info.mask = PIPE_MASK_RGBA; diff --git a/src/gallium/drivers/etnaviv/etnaviv_surface.c b/src/gallium/drivers/etnaviv/etnaviv_surface.c index a0c78a7030a..096a135ece1 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_surface.c +++ b/src/gallium/drivers/etnaviv/etnaviv_surface.c @@ -122,8 +122,6 @@ etna_create_surface(struct pipe_context *pctx, struct pipe_resource *prsc, } surf->base.format = templat->format; - surf->base.width = rsc->levels[level].width; - surf->base.height = rsc->levels[level].height; surf->base.writable = templat->writable; /* what is this for anyway */ surf->base.u = templat->u; surf->level = lev; diff --git a/src/gallium/drivers/freedreno/a2xx/fd2_gmem.c b/src/gallium/drivers/freedreno/a2xx/fd2_gmem.c index 7a04c60ff9c..b0c63558ce9 100644 --- a/src/gallium/drivers/freedreno/a2xx/fd2_gmem.c +++ b/src/gallium/drivers/freedreno/a2xx/fd2_gmem.c @@ -219,7 +219,6 @@ emit_mem2gmem_surf(struct fd_batch *batch, uint32_t base, uint32_t offset = fd_resource_offset(rsc, psurf->u.tex.level, psurf->u.tex.first_layer); enum pipe_format format = fd_gmem_restore_format(psurf->format); - OUT_PKT3(ring, CP_SET_CONSTANT, 2); OUT_RING(ring, CP_REG(REG_A2XX_RB_COLOR_INFO)); OUT_RING(ring, A2XX_RB_COLOR_INFO_BASE(base) | @@ -237,8 +236,8 @@ emit_mem2gmem_surf(struct fd_batch *batch, uint32_t base, A2XX_SQ_TEX_1_FORMAT(fd2_pipe2surface(format).format) | A2XX_SQ_TEX_1_CLAMP_POLICY(SQ_TEX_CLAMP_POLICY_OGL), 0); - OUT_RING(ring, A2XX_SQ_TEX_2_WIDTH(psurf->width - 1) | - A2XX_SQ_TEX_2_HEIGHT(psurf->height - 1)); + OUT_RING(ring, A2XX_SQ_TEX_2_WIDTH(pipe_surface_width(psurf) - 1) | + A2XX_SQ_TEX_2_HEIGHT(pipe_surface_height(psurf) - 1)); OUT_RING(ring, A2XX_SQ_TEX_3_MIP_FILTER(SQ_TEX_FILTER_BASEMAP) | A2XX_SQ_TEX_3_SWIZ_X(0) | A2XX_SQ_TEX_3_SWIZ_Y(1) | A2XX_SQ_TEX_3_SWIZ_Z(2) | A2XX_SQ_TEX_3_SWIZ_W(3) | diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_emit.c b/src/gallium/drivers/freedreno/a3xx/fd3_emit.c index b56c07e29a5..cd733e8965b 100644 --- a/src/gallium/drivers/freedreno/a3xx/fd3_emit.c +++ b/src/gallium/drivers/freedreno/a3xx/fd3_emit.c @@ -301,6 +301,8 @@ fd3_emit_gmem_restore_tex(struct fd_ringbuffer *ring, struct fd_resource *rsc = fd_resource(psurf[i]->texture); enum pipe_format format = fd_gmem_restore_format(psurf[i]->format); + uint16_t width, height; + pipe_surface_size(psurf[i], &width, &height); /* The restore blit_zs shader expects stencil in sampler 0, and depth * in sampler 1 */ @@ -319,8 +321,8 @@ fd3_emit_gmem_restore_tex(struct fd_ringbuffer *ring, A3XX_TEX_CONST_0_TYPE(A3XX_TEX_2D) | fd3_tex_swiz(format, PIPE_SWIZZLE_X, PIPE_SWIZZLE_Y, PIPE_SWIZZLE_Z, PIPE_SWIZZLE_W)); - OUT_RING(ring, A3XX_TEX_CONST_1_WIDTH(psurf[i]->width) | - A3XX_TEX_CONST_1_HEIGHT(psurf[i]->height)); + OUT_RING(ring, A3XX_TEX_CONST_1_WIDTH(width) | + A3XX_TEX_CONST_1_HEIGHT(height)); OUT_RING(ring, A3XX_TEX_CONST_2_PITCH(fd_resource_pitch(rsc, lvl)) | A3XX_TEX_CONST_2_INDX(BASETABLE_SZ * i)); OUT_RING(ring, 0x00000000); diff --git a/src/gallium/drivers/freedreno/a4xx/fd4_emit.c b/src/gallium/drivers/freedreno/a4xx/fd4_emit.c index 468cdf51654..30ce9f98655 100644 --- a/src/gallium/drivers/freedreno/a4xx/fd4_emit.c +++ b/src/gallium/drivers/freedreno/a4xx/fd4_emit.c @@ -385,7 +385,8 @@ fd4_emit_gmem_restore_tex(struct fd_ringbuffer *ring, unsigned nr_bufs, if (bufs[i]) { struct fd_resource *rsc = fd_resource(bufs[i]->texture); enum pipe_format format = fd_gmem_restore_format(bufs[i]->format); - + uint16_t width, height; + pipe_surface_size(bufs[i], &width, &height); /* The restore blit_zs shader expects stencil in sampler 0, * and depth in sampler 1 */ @@ -416,8 +417,8 @@ fd4_emit_gmem_restore_tex(struct fd_ringbuffer *ring, unsigned nr_bufs, A4XX_TEX_CONST_0_TYPE(A4XX_TEX_2D) | fd4_tex_swiz(format, PIPE_SWIZZLE_X, PIPE_SWIZZLE_Y, PIPE_SWIZZLE_Z, PIPE_SWIZZLE_W)); - OUT_RING(ring, A4XX_TEX_CONST_1_WIDTH(bufs[i]->width) | - A4XX_TEX_CONST_1_HEIGHT(bufs[i]->height)); + OUT_RING(ring, A4XX_TEX_CONST_1_WIDTH(width) | + A4XX_TEX_CONST_1_HEIGHT(height)); OUT_RING(ring, A4XX_TEX_CONST_2_PITCH(fd_resource_pitch(rsc, lvl))); OUT_RING(ring, 0x00000000); OUT_RELOC(ring, rsc->bo, offset, 0, 0); diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_blitter.cc b/src/gallium/drivers/freedreno/a6xx/fd6_blitter.cc index cb6cd0dc4ff..7e16a9793df 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_blitter.cc +++ b/src/gallium/drivers/freedreno/a6xx/fd6_blitter.cc @@ -1117,17 +1117,19 @@ fd6_resolve_tile(struct fd_batch *batch, struct fd_ringbuffer *ring, uint64_t gmem_base = batch->ctx->screen->gmem_base + base; uint32_t gmem_pitch = gmem->bin_w * batch->framebuffer.samples * util_format_get_blocksize(psurf->format); + unsigned width = pipe_surface_width(psurf); + unsigned height = pipe_surface_height(psurf); OUT_PKT4(ring, REG_A6XX_GRAS_2D_DST_TL, 2); OUT_RING(ring, A6XX_GRAS_2D_DST_TL_X(0) | A6XX_GRAS_2D_DST_TL_Y(0)); - OUT_RING(ring, A6XX_GRAS_2D_DST_BR_X(psurf->width - 1) | - A6XX_GRAS_2D_DST_BR_Y(psurf->height - 1)); + OUT_RING(ring, A6XX_GRAS_2D_DST_BR_X(width - 1) | + A6XX_GRAS_2D_DST_BR_Y(height - 1)); OUT_REG(ring, A6XX_GRAS_2D_SRC_TL_X(0), - A6XX_GRAS_2D_SRC_BR_X(psurf->width - 1), + A6XX_GRAS_2D_SRC_BR_X(width - 1), A6XX_GRAS_2D_SRC_TL_Y(0), - A6XX_GRAS_2D_SRC_BR_Y(psurf->height - 1), + A6XX_GRAS_2D_SRC_BR_Y(height - 1), ); /* Enable scissor bit, which will take into account the window scissor @@ -1158,8 +1160,8 @@ fd6_resolve_tile(struct fd_batch *batch, struct fd_ringbuffer *ring, ), SP_PS_2D_SRC_SIZE( CHIP, - .width = psurf->width, - .height = psurf->height, + .width = width, + .height = height, ), SP_PS_2D_SRC( CHIP, diff --git a/src/gallium/drivers/freedreno/freedreno_surface.c b/src/gallium/drivers/freedreno/freedreno_surface.c index b94fb813acb..efa24ac48da 100644 --- a/src/gallium/drivers/freedreno/freedreno_surface.c +++ b/src/gallium/drivers/freedreno/freedreno_surface.c @@ -30,8 +30,6 @@ fd_create_surface(struct pipe_context *pctx, struct pipe_resource *ptex, psurf->context = pctx; psurf->format = surf_tmpl->format; - psurf->width = u_minify(ptex->width0, level); - psurf->height = u_minify(ptex->height0, level); psurf->nr_samples = surf_tmpl->nr_samples; if (ptex->target == PIPE_BUFFER) { diff --git a/src/gallium/drivers/i915/i915_clear.c b/src/gallium/drivers/i915/i915_clear.c index 9981505b0d0..4fb0a0a1be7 100644 --- a/src/gallium/drivers/i915/i915_clear.c +++ b/src/gallium/drivers/i915/i915_clear.c @@ -231,16 +231,20 @@ i915_clear_blitter(struct pipe_context *pipe, unsigned buffers, struct pipe_surface *ps = framebuffer->cbufs[i]; if (ps) { - pipe->clear_render_target(pipe, ps, color, 0, 0, ps->width, - ps->height, true); + uint16_t width, height; + pipe_surface_size(ps, &width, &height); + pipe->clear_render_target(pipe, ps, color, 0, 0, width, + height, true); } } } if (buffers & PIPE_CLEAR_DEPTHSTENCIL) { struct pipe_surface *ps = framebuffer->zsbuf; + uint16_t width, height; + pipe_surface_size(ps, &width, &height); pipe->clear_depth_stencil(pipe, ps, buffers & PIPE_CLEAR_DEPTHSTENCIL, - depth, stencil, 0, 0, ps->width, ps->height, + depth, stencil, 0, 0, width, height, true); } } diff --git a/src/gallium/drivers/i915/i915_surface.c b/src/gallium/drivers/i915/i915_surface.c index f0275af7bbf..0a44b6541f1 100644 --- a/src/gallium/drivers/i915/i915_surface.c +++ b/src/gallium/drivers/i915/i915_surface.c @@ -140,8 +140,8 @@ i915_clear_render_target_render(struct pipe_context *pipe, util_blitter_save_framebuffer(i915->blitter, &i915->framebuffer); - fb_state.width = dst->width; - fb_state.height = dst->height; + fb_state.width = width; + fb_state.height = height; fb_state.nr_cbufs = 1; fb_state.cbufs[0] = dst; fb_state.zsbuf = NULL; @@ -170,8 +170,8 @@ i915_clear_depth_stencil_render(struct pipe_context *pipe, util_blitter_save_framebuffer(i915->blitter, &i915->framebuffer); - fb_state.width = dst->width; - fb_state.height = dst->height; + fb_state.width = width; + fb_state.height = height; fb_state.nr_cbufs = 0; fb_state.zsbuf = dst; pipe->set_framebuffer_state(pipe, &fb_state); @@ -404,8 +404,6 @@ i915_create_surface_custom(struct pipe_context *ctx, struct pipe_resource *pt, pipe_reference_init(&ps->reference, 1); pipe_resource_reference(&ps->texture, pt); ps->format = surf_tmpl->format; - ps->width = u_minify(width0, surf_tmpl->u.tex.level); - ps->height = u_minify(height0, surf_tmpl->u.tex.level); ps->u.tex.level = surf_tmpl->u.tex.level; ps->u.tex.first_layer = surf_tmpl->u.tex.first_layer; ps->u.tex.last_layer = surf_tmpl->u.tex.last_layer; diff --git a/src/gallium/drivers/iris/iris_state.c b/src/gallium/drivers/iris/iris_state.c index b519c470e07..4c55eb4b23d 100644 --- a/src/gallium/drivers/iris/iris_state.c +++ b/src/gallium/drivers/iris/iris_state.c @@ -3273,8 +3273,6 @@ iris_create_surface(struct pipe_context *ctx, pipe_resource_reference(&psurf->texture, tex); psurf->context = ctx; psurf->format = tmpl->format; - psurf->width = isl_surf.logical_level0_px.width; - psurf->height = isl_surf.logical_level0_px.height; psurf->texture = tex; psurf->u.tex.first_layer = tmpl->u.tex.first_layer; psurf->u.tex.last_layer = tmpl->u.tex.last_layer; diff --git a/src/gallium/drivers/lima/lima_blit.c b/src/gallium/drivers/lima/lima_blit.c index a90a570ea5a..f5214f99225 100644 --- a/src/gallium/drivers/lima/lima_blit.c +++ b/src/gallium/drivers/lima/lima_blit.c @@ -75,13 +75,14 @@ lima_pack_blit_cmd(struct lima_job *job, reload_render_state.multi_sample |= (sample_mask << 12); + uint16_t width, height; if (job->key.cbuf) { - fb_width = job->key.cbuf->width; - fb_height = job->key.cbuf->height; + pipe_surface_size(job->key.cbuf, &width, &height); } else { - fb_width = job->key.zsbuf->width; - fb_height = job->key.zsbuf->height; + pipe_surface_size(job->key.zsbuf, &width, &height); } + fb_width = width; + fb_height = height; if (util_format_is_depth_or_stencil(psurf->format)) { reload_render_state.alpha_blend &= 0x0fffffff; @@ -295,10 +296,9 @@ lima_do_blit(struct pipe_context *pctx, } bool tile_aligned = false; - if (info->dst.box.x == 0 && info->dst.box.y == 0 && - info->dst.box.width == lima_dst_surf->base.width && - info->dst.box.height == lima_dst_surf->base.height) + info->dst.box.width == pipe_surface_width(&lima_dst_surf->base) && + info->dst.box.height == pipe_surface_height(&lima_dst_surf->base)) tile_aligned = true; if (info->dst.box.x % 16 == 0 && info->dst.box.y % 16 == 0 && diff --git a/src/gallium/drivers/lima/lima_job.c b/src/gallium/drivers/lima/lima_job.c index 1c8d42c87e1..12af5e4cbb2 100644 --- a/src/gallium/drivers/lima/lima_job.c +++ b/src/gallium/drivers/lima/lima_job.c @@ -65,8 +65,10 @@ lima_get_fb_info(struct lima_job *job) fb->width = ctx->framebuffer.base.width; fb->height = ctx->framebuffer.base.height; } else { - fb->width = surf->base.width; - fb->height = surf->base.height; + uint16_t width, height; + pipe_surface_size(&surf->base, &width, &height); + fb->width = width; + fb->height = height; } int width = align(fb->width, 16) >> 4; diff --git a/src/gallium/drivers/lima/lima_resource.c b/src/gallium/drivers/lima/lima_resource.c index f3418ce4cb0..247a6895bd9 100644 --- a/src/gallium/drivers/lima/lima_resource.c +++ b/src/gallium/drivers/lima/lima_resource.c @@ -580,15 +580,13 @@ lima_surface_create(struct pipe_context *pctx, psurf->context = pctx; psurf->format = surf_tmpl->format; - psurf->width = u_minify(pres->width0, level); - psurf->height = u_minify(pres->height0, level); psurf->nr_samples = surf_tmpl->nr_samples; psurf->u.tex.level = level; psurf->u.tex.first_layer = surf_tmpl->u.tex.first_layer; psurf->u.tex.last_layer = surf_tmpl->u.tex.last_layer; - surf->tiled_w = align(psurf->width, 16) >> 4; - surf->tiled_h = align(psurf->height, 16) >> 4; + surf->tiled_w = align(u_minify(pres->width0, level), 16) >> 4; + surf->tiled_h = align(u_minify(pres->height0, level), 16) >> 4; surf->reload = 0; if (util_format_has_stencil(util_format_description(psurf->format))) diff --git a/src/gallium/drivers/llvmpipe/lp_surface.c b/src/gallium/drivers/llvmpipe/lp_surface.c index b42606c2924..0fb74534c4c 100644 --- a/src/gallium/drivers/llvmpipe/lp_surface.c +++ b/src/gallium/drivers/llvmpipe/lp_surface.c @@ -226,18 +226,10 @@ llvmpipe_create_surface(struct pipe_context *pipe, if (llvmpipe_resource_is_texture(pt)) { assert(surf_tmpl->u.tex.level <= pt->last_level); assert(surf_tmpl->u.tex.first_layer <= surf_tmpl->u.tex.last_layer); - ps->width = u_minify(pt->width0, surf_tmpl->u.tex.level); - ps->height = u_minify(pt->height0, surf_tmpl->u.tex.level); ps->u.tex.level = surf_tmpl->u.tex.level; ps->u.tex.first_layer = surf_tmpl->u.tex.first_layer; ps->u.tex.last_layer = surf_tmpl->u.tex.last_layer; } else { - /* setting width as number of elements should get us correct - * renderbuffer width - */ - ps->width = surf_tmpl->u.buf.last_element - - surf_tmpl->u.buf.first_element + 1; - ps->height = pt->height0; ps->u.buf.first_element = surf_tmpl->u.buf.first_element; ps->u.buf.last_element = surf_tmpl->u.buf.last_element; assert(ps->u.buf.first_element <= ps->u.buf.last_element); diff --git a/src/gallium/drivers/nouveau/nv30/nv30_miptree.c b/src/gallium/drivers/nouveau/nv30/nv30_miptree.c index bd5898d38f3..08819b4fe53 100644 --- a/src/gallium/drivers/nouveau/nv30/nv30_miptree.c +++ b/src/gallium/drivers/nouveau/nv30/nv30_miptree.c @@ -573,9 +573,6 @@ nv30_miptree_surface_new(struct pipe_context *pipe, else ns->pitch = lvl->pitch; - /* comment says there are going to be removed, but they're used by the st */ - ps->width = ns->width; - ps->height = ns->height; return ps; } diff --git a/src/gallium/drivers/nouveau/nv50/nv50_miptree.c b/src/gallium/drivers/nouveau/nv50/nv50_miptree.c index 4554dbf02d4..905b8fb053b 100644 --- a/src/gallium/drivers/nouveau/nv50/nv50_miptree.c +++ b/src/gallium/drivers/nouveau/nv50/nv50_miptree.c @@ -486,10 +486,6 @@ nv50_surface_from_miptree(struct nv50_miptree *mt, ns->depth = ps->u.tex.last_layer - ps->u.tex.first_layer + 1; ns->offset = mt->level[templ->u.tex.level].offset; - /* comment says there are going to be removed, but they're used by the st */ - ps->width = ns->width; - ps->height = ns->height; - ns->width <<= mt->ms_x; ns->height <<= mt->ms_y; diff --git a/src/gallium/drivers/nouveau/nv50/nv50_resource.c b/src/gallium/drivers/nouveau/nv50/nv50_resource.c index 2e2961c88a8..3c55b3d4787 100644 --- a/src/gallium/drivers/nouveau/nv50/nv50_resource.c +++ b/src/gallium/drivers/nouveau/nv50/nv50_resource.c @@ -66,9 +66,6 @@ nv50_surface_from_buffer(struct pipe_context *pipe, sf->height = 1; sf->depth = 1; - sf->base.width = sf->width; - sf->base.height = sf->height; - sf->base.context = pipe; return &sf->base; } diff --git a/src/gallium/drivers/nouveau/nv50/nv50_surface.c b/src/gallium/drivers/nouveau/nv50/nv50_surface.c index 7499d67d738..7f661065fe5 100644 --- a/src/gallium/drivers/nouveau/nv50/nv50_surface.c +++ b/src/gallium/drivers/nouveau/nv50/nv50_surface.c @@ -1111,8 +1111,7 @@ nv50_blit_set_dst(struct nv50_blitctx *ctx, nv50->framebuffer.cbufs[0] = nv50_miptree_surface_new(pipe, res, &templ); nv50->framebuffer.nr_cbufs = 1; nv50->framebuffer.zsbuf = NULL; - nv50->framebuffer.width = nv50->framebuffer.cbufs[0]->width; - nv50->framebuffer.height = nv50->framebuffer.cbufs[0]->height; + pipe_surface_size(nv50->framebuffer.cbufs[0], &nv50->framebuffer.width, &nv50->framebuffer.height); } static void diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_surface.c b/src/gallium/drivers/nouveau/nvc0/nvc0_surface.c index c168b418345..2339cdc5e51 100644 --- a/src/gallium/drivers/nouveau/nvc0/nvc0_surface.c +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_surface.c @@ -980,8 +980,7 @@ nvc0_blit_set_dst(struct nvc0_blitctx *ctx, nvc0->framebuffer.cbufs[0] = nvc0_miptree_surface_new(pipe, res, &templ); nvc0->framebuffer.nr_cbufs = 1; nvc0->framebuffer.zsbuf = NULL; - nvc0->framebuffer.width = nvc0->framebuffer.cbufs[0]->width; - nvc0->framebuffer.height = nvc0->framebuffer.cbufs[0]->height; + pipe_surface_size(nvc0->framebuffer.cbufs[0], &nvc0->framebuffer.width, &nvc0->framebuffer.height); } static void diff --git a/src/gallium/drivers/panfrost/pan_resource.c b/src/gallium/drivers/panfrost/pan_resource.c index e13a05fb664..e4af8248acb 100644 --- a/src/gallium/drivers/panfrost/pan_resource.c +++ b/src/gallium/drivers/panfrost/pan_resource.c @@ -259,22 +259,14 @@ panfrost_create_surface(struct pipe_context *pipe, struct pipe_resource *pt, if (pt->target != PIPE_BUFFER) { assert(surf_tmpl->u.tex.level <= pt->last_level); - ps->width = u_minify(pt->width0, surf_tmpl->u.tex.level); - ps->height = u_minify(pt->height0, surf_tmpl->u.tex.level); ps->nr_samples = surf_tmpl->nr_samples; ps->u.tex.level = surf_tmpl->u.tex.level; ps->u.tex.first_layer = surf_tmpl->u.tex.first_layer; ps->u.tex.last_layer = surf_tmpl->u.tex.last_layer; } else { - /* setting width as number of elements should get us correct - * renderbuffer width */ - ps->width = - surf_tmpl->u.buf.last_element - surf_tmpl->u.buf.first_element + 1; - ps->height = pt->height0; ps->u.buf.first_element = surf_tmpl->u.buf.first_element; ps->u.buf.last_element = surf_tmpl->u.buf.last_element; assert(ps->u.buf.first_element <= ps->u.buf.last_element); - assert(ps->u.buf.last_element < ps->width); } } diff --git a/src/gallium/drivers/r300/r300_blit.c b/src/gallium/drivers/r300/r300_blit.c index dfcf3c16d9a..dd83858a4c8 100644 --- a/src/gallium/drivers/r300/r300_blit.c +++ b/src/gallium/drivers/r300/r300_blit.c @@ -491,8 +491,7 @@ void r300_decompress_zmask_locked_unsafe(struct r300_context *r300) struct pipe_framebuffer_state fb; memset(&fb, 0, sizeof(fb)); - fb.width = r300->locked_zbuffer->width; - fb.height = r300->locked_zbuffer->height; + pipe_surface_size(r300->locked_zbuffer, &fb.width, &fb.height); fb.zsbuf = r300->locked_zbuffer; r300->context.set_framebuffer_state(&r300->context, &fb); diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index 6023fe1c3b2..76d98bedaac 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -829,7 +829,8 @@ static void r300_print_fb_surf_info(struct pipe_surface *surf, unsigned index, "r300: TEX: Macro: %s, Micro: %s, " "Dim: %ix%ix%i, LastLevel: %i, Format: %s\n", - binding, index, surf->width, surf->height, + binding, index, pipe_surface_width(surf), + pipe_surface_height(surf), surf->u.tex.first_layer, surf->u.tex.last_layer, surf->u.tex.level, util_format_short_name(surf->format), diff --git a/src/gallium/drivers/r300/r300_texture.c b/src/gallium/drivers/r300/r300_texture.c index c307283bd2f..148494b061e 100644 --- a/src/gallium/drivers/r300/r300_texture.c +++ b/src/gallium/drivers/r300/r300_texture.c @@ -1180,8 +1180,6 @@ struct pipe_surface* r300_create_surface_custom(struct pipe_context * ctx, pipe_resource_reference(&surface->base.texture, texture); surface->base.context = ctx; surface->base.format = surf_tmpl->format; - surface->base.width = u_minify(width0_override, level); - surface->base.height = u_minify(height0_override, level); surface->base.u.tex.level = level; surface->base.u.tex.first_layer = surf_tmpl->u.tex.first_layer; surface->base.u.tex.last_layer = surf_tmpl->u.tex.last_layer; @@ -1199,7 +1197,7 @@ struct pipe_surface* r300_create_surface_custom(struct pipe_context * ctx, /* Parameters for the CBZB clear. */ surface->cbzb_allowed = tex->tex.cbzb_allowed[level]; - surface->cbzb_width = align(surface->base.width, 64); + surface->cbzb_width = align(pipe_surface_width(surf_tmpl), 64); /* Height must be aligned to the size of a tile. */ tile_height = r300_get_pixel_alignment(surface->base.format, @@ -1209,7 +1207,7 @@ struct pipe_surface* r300_create_surface_custom(struct pipe_context * ctx, DIM_HEIGHT, 0, tex->b.bind & PIPE_BIND_SCANOUT); - surface->cbzb_height = align((surface->base.height + 1) / 2, + surface->cbzb_height = align((pipe_surface_height(surf_tmpl) + 1) / 2, tile_height); /* Offset must be aligned to 2K and must point at the beginning diff --git a/src/gallium/drivers/r600/r600_blit.c b/src/gallium/drivers/r600/r600_blit.c index e213f3eeaca..ba91fcbcb43 100644 --- a/src/gallium/drivers/r600/r600_blit.c +++ b/src/gallium/drivers/r600/r600_blit.c @@ -662,7 +662,7 @@ void r600_resource_copy_region(struct pipe_context *ctx, struct r600_context *rctx = (struct r600_context *)ctx; struct pipe_surface *dst_view, dst_templ; struct pipe_sampler_view src_templ, *src_view; - unsigned dst_width, dst_height, src_width0, src_height0, src_widthFL, src_heightFL; + unsigned src_width0, src_height0, src_widthFL, src_heightFL; unsigned src_force_level = 0; struct pipe_box sbox, dstbox; @@ -686,8 +686,6 @@ void r600_resource_copy_region(struct pipe_context *ctx, return; /* error */ } - dst_width = u_minify(dst->width0, dst_level); - dst_height = u_minify(dst->height0, dst_level); src_width0 = src->width0; src_height0 = src->height0; src_widthFL = u_minify(src->width0, src_level); @@ -706,8 +704,6 @@ void r600_resource_copy_region(struct pipe_context *ctx, src_templ.format = PIPE_FORMAT_R32G32B32A32_UINT; /* 128-bit block */ dst_templ.format = src_templ.format; - dst_width = util_format_get_nblocksx(dst->format, dst_width); - dst_height = util_format_get_nblocksy(dst->format, dst_height); src_width0 = util_format_get_nblocksx(src->format, src_width0); src_height0 = util_format_get_nblocksy(src->format, src_height0); src_widthFL = util_format_get_nblocksx(src->format, src_widthFL); @@ -731,7 +727,6 @@ void r600_resource_copy_region(struct pipe_context *ctx, src_templ.format = PIPE_FORMAT_R8G8B8A8_UINT; dst_templ.format = PIPE_FORMAT_R8G8B8A8_UINT; - dst_width = util_format_get_nblocksx(dst->format, dst_width); src_width0 = util_format_get_nblocksx(src->format, src_width0); src_widthFL = util_format_get_nblocksx(src->format, src_widthFL); @@ -775,8 +770,7 @@ void r600_resource_copy_region(struct pipe_context *ctx, dst_view = r600_create_surface_custom(ctx, dst, &dst_templ, /* we don't care about these two for r600g */ - dst->width0, dst->height0, - dst_width, dst_height); + dst->width0, dst->height0); if (rctx->b.gfx_level >= EVERGREEN) { src_view = evergreen_create_sampler_view_custom(ctx, src, &src_templ, diff --git a/src/gallium/drivers/r600/r600_pipe_common.h b/src/gallium/drivers/r600/r600_pipe_common.h index 786b1cd56c0..0adf361a34e 100644 --- a/src/gallium/drivers/r600/r600_pipe_common.h +++ b/src/gallium/drivers/r600/r600_pipe_common.h @@ -740,8 +740,7 @@ struct pipe_resource *r600_texture_create(struct pipe_screen *screen, struct pipe_surface *r600_create_surface_custom(struct pipe_context *pipe, struct pipe_resource *texture, const struct pipe_surface *templ, - unsigned width0, unsigned height0, - unsigned width, unsigned height); + unsigned width0, unsigned height0); unsigned r600_translate_colorswap(enum pipe_format format, bool do_endian_swap); void evergreen_do_fast_color_clear(struct r600_common_context *rctx, struct pipe_framebuffer_state *fb, diff --git a/src/gallium/drivers/r600/r600_texture.c b/src/gallium/drivers/r600/r600_texture.c index bc9e208337f..91ec9f30797 100644 --- a/src/gallium/drivers/r600/r600_texture.c +++ b/src/gallium/drivers/r600/r600_texture.c @@ -1497,8 +1497,7 @@ void r600_texture_transfer_unmap(struct pipe_context *ctx, struct pipe_surface *r600_create_surface_custom(struct pipe_context *pipe, struct pipe_resource *texture, const struct pipe_surface *templ, - unsigned width0, unsigned height0, - unsigned width, unsigned height) + unsigned width0, unsigned height0) { struct r600_surface *surface = CALLOC_STRUCT(r600_surface); @@ -1512,8 +1511,6 @@ struct pipe_surface *r600_create_surface_custom(struct pipe_context *pipe, pipe_resource_reference(&surface->base.texture, texture); surface->base.context = pipe; surface->base.format = templ->format; - surface->base.width = width; - surface->base.height = height; surface->base.u = templ->u; surface->width0 = width0; @@ -1526,9 +1523,6 @@ static struct pipe_surface *r600_create_surface(struct pipe_context *pipe, struct pipe_resource *tex, const struct pipe_surface *templ) { - unsigned level = templ->u.tex.level; - unsigned width = u_minify(tex->width0, level); - unsigned height = u_minify(tex->height0, level); unsigned width0 = tex->width0; unsigned height0 = tex->height0; @@ -1544,20 +1538,13 @@ static struct pipe_surface *r600_create_surface(struct pipe_context *pipe, * height is changed. */ if (tex_desc->block.width != templ_desc->block.width || tex_desc->block.height != templ_desc->block.height) { - unsigned nblks_x = util_format_get_nblocksx(tex->format, width); - unsigned nblks_y = util_format_get_nblocksy(tex->format, height); - - width = nblks_x * templ_desc->block.width; - height = nblks_y * templ_desc->block.height; - width0 = util_format_get_nblocksx(tex->format, width0); height0 = util_format_get_nblocksy(tex->format, height0); } } return r600_create_surface_custom(pipe, tex, templ, - width0, height0, - width, height); + width0, height0); } static void r600_surface_destroy(struct pipe_context *pipe, diff --git a/src/gallium/drivers/radeonsi/si_clear.c b/src/gallium/drivers/radeonsi/si_clear.c index 8d11cafc122..43fe2f23241 100644 --- a/src/gallium/drivers/radeonsi/si_clear.c +++ b/src/gallium/drivers/radeonsi/si_clear.c @@ -1076,12 +1076,14 @@ static void si_fb_clear_via_compute(struct si_context *sctx, unsigned *buffers, if (vi_dcc_enabled(tex, surf->u.tex.level)) continue; + uint16_t width, height; + pipe_surface_size(surf, &width, &height); /* Clears of thick and linear layouts are fastest with compute. */ if (tex->surface.thick_tiling || - (tex->surface.is_linear && (surf->height > 1 || depth > 1 || surf->width >= 8192))) { + (tex->surface.is_linear && (height > 1 || depth > 1 || width >= 8192))) { struct pipe_box box; - u_box_3d(0, 0, surf->u.tex.first_layer, surf->width, surf->height, depth, &box); + u_box_3d(0, 0, surf->u.tex.first_layer, width, height, depth, &box); if (si_compute_clear_image(sctx, &tex->buffer.b.b, surf->format, surf->u.tex.level, &box, color, sctx->render_cond_enabled, true)) @@ -1257,10 +1259,12 @@ static bool si_try_normal_clear(struct si_context *sctx, struct pipe_surface *ds const union pipe_color_union *color, float depth, unsigned stencil) { + uint16_t surf_width, surf_height; + pipe_surface_size(dst, &surf_width, &surf_height); /* This is worth it only if it's a whole image clear. */ if (dstx == 0 && dsty == 0 && - width == dst->width && - height == dst->height && + width == surf_width && + height == surf_height && dst->u.tex.first_layer == 0 && dst->u.tex.last_layer == util_max_layer(dst->texture, dst->u.tex.level) && /* pipe->clear honors render_condition, so only use it if it's unset or if it's set and enabled. */ @@ -1278,8 +1282,8 @@ static bool si_try_normal_clear(struct si_context *sctx, struct pipe_surface *ds fb.zsbuf = dst; } - fb.width = dst->width; - fb.height = dst->height; + fb.width = surf_width; + fb.height = surf_height; ctx->set_framebuffer_state(ctx, &fb); ctx->clear(ctx, buffers, NULL, color, depth, stencil); diff --git a/src/gallium/drivers/radeonsi/si_texture.c b/src/gallium/drivers/radeonsi/si_texture.c index 25514f21679..50ca1078412 100644 --- a/src/gallium/drivers/radeonsi/si_texture.c +++ b/src/gallium/drivers/radeonsi/si_texture.c @@ -2300,8 +2300,6 @@ static struct pipe_surface *si_create_surface(struct pipe_context *pipe, struct pipe_resource_reference(&surface->base.texture, tex); surface->base.context = pipe; surface->base.format = templ->format; - surface->base.width = width; - surface->base.height = height; surface->base.u = templ->u; surface->width0 = width0; diff --git a/src/gallium/drivers/radeonsi/si_vpe.c b/src/gallium/drivers/radeonsi/si_vpe.c index 457a231191f..a13fef997f2 100644 --- a/src/gallium/drivers/radeonsi/si_vpe.c +++ b/src/gallium/drivers/radeonsi/si_vpe.c @@ -546,21 +546,24 @@ si_vpe_set_plane_info(struct vpe_video_processor *vpeproc, return VPE_STATUS_NOT_SUPPORTED; /* 1st plane ret setting */ + uint16_t width, height; + pipe_surface_size(surfaces[0], &width, &height); plane_size->surface_size.x = 0; plane_size->surface_size.y = 0; - plane_size->surface_size.width = surfaces[0]->width; - plane_size->surface_size.height = surfaces[0]->height; + plane_size->surface_size.width = width; + plane_size->surface_size.height = height; plane_size->surface_pitch = si_tex_0->surface.u.gfx9.surf_pitch; - plane_size->surface_aligned_height = surfaces[0]->height; + plane_size->surface_aligned_height = height; /* YUV 2nd plane ret setting */ if (util_format_get_num_planes(format) == 2) { + pipe_surface_size(surfaces[1], &width, &height); plane_size->chroma_size.x = 0; plane_size->chroma_size.y = 0; - plane_size->chroma_size.width = surfaces[1]->width; - plane_size->chroma_size.height = surfaces[1]->height; + plane_size->chroma_size.width = width; + plane_size->chroma_size.height = height; plane_size->chroma_pitch = si_tex_1->surface.u.gfx9.surf_pitch; - plane_size->chrome_aligned_height = surfaces[1]->height; + plane_size->chrome_aligned_height = height; } /* Color space setting */ @@ -687,8 +690,8 @@ si_vpe_set_stream_out_param(struct vpe_video_processor *vpeproc, if (process_properties->background_color) { build_param->target_rect.x = 0; build_param->target_rect.y = 0; - build_param->target_rect.width = vpeproc->dst_surfaces[0]->width; - build_param->target_rect.height = vpeproc->dst_surfaces[0]->height; + build_param->target_rect.width = pipe_surface_width(vpeproc->dst_surfaces[0]); + build_param->target_rect.height = pipe_surface_height(vpeproc->dst_surfaces[0]); } else { build_param->target_rect.x = process_properties->dst_region.x0; build_param->target_rect.y = process_properties->dst_region.y0; diff --git a/src/gallium/drivers/softpipe/sp_clear.c b/src/gallium/drivers/softpipe/sp_clear.c index bc896db073b..d7ff2499c25 100644 --- a/src/gallium/drivers/softpipe/sp_clear.c +++ b/src/gallium/drivers/softpipe/sp_clear.c @@ -80,7 +80,8 @@ softpipe_clear(struct pipe_context *pipe, unsigned buffers, zs_buffers != PIPE_CLEAR_DEPTHSTENCIL) { /* Clearing only depth or stencil in a combined depth-stencil buffer. */ util_clear_depth_stencil(pipe, zsbuf, zs_buffers, depth, stencil, - 0, 0, zsbuf->width, zsbuf->height); + 0, 0, pipe_surface_width(zsbuf), + pipe_surface_height(zsbuf)); } else if (zs_buffers) { static const union pipe_color_union zero; diff --git a/src/gallium/drivers/softpipe/sp_texture.c b/src/gallium/drivers/softpipe/sp_texture.c index c4f9ab6eacd..77384b196da 100644 --- a/src/gallium/drivers/softpipe/sp_texture.c +++ b/src/gallium/drivers/softpipe/sp_texture.c @@ -302,8 +302,6 @@ softpipe_create_surface(struct pipe_context *pipe, ps->format = surf_tmpl->format; if (pt->target != PIPE_BUFFER) { assert(surf_tmpl->u.tex.level <= pt->last_level); - ps->width = u_minify(pt->width0, surf_tmpl->u.tex.level); - ps->height = u_minify(pt->height0, surf_tmpl->u.tex.level); ps->u.tex.level = surf_tmpl->u.tex.level; ps->u.tex.first_layer = surf_tmpl->u.tex.first_layer; ps->u.tex.last_layer = surf_tmpl->u.tex.last_layer; @@ -312,13 +310,9 @@ softpipe_create_surface(struct pipe_context *pipe, } } else { - /* setting width as number of elements should get us correct renderbuffer width */ - ps->width = surf_tmpl->u.buf.last_element - surf_tmpl->u.buf.first_element + 1; - ps->height = pt->height0; ps->u.buf.first_element = surf_tmpl->u.buf.first_element; ps->u.buf.last_element = surf_tmpl->u.buf.last_element; assert(ps->u.buf.first_element <= ps->u.buf.last_element); - assert(ps->u.buf.last_element < ps->width); } } return ps; diff --git a/src/gallium/drivers/softpipe/sp_tile_cache.c b/src/gallium/drivers/softpipe/sp_tile_cache.c index 4a32a923cf4..9c3b6e7c3a7 100644 --- a/src/gallium/drivers/softpipe/sp_tile_cache.c +++ b/src/gallium/drivers/softpipe/sp_tile_cache.c @@ -203,7 +203,9 @@ sp_tile_cache_set_surface(struct softpipe_tile_cache *tc, ps->u.tex.level, ps->u.tex.first_layer + i, PIPE_MAP_READ_WRITE | PIPE_MAP_UNSYNCHRONIZED, - 0, 0, ps->width, ps->height, + 0, 0, + pipe_surface_width(ps), + pipe_surface_height(ps), &tc->transfer[i]); } } diff --git a/src/gallium/drivers/svga/svga_pipe_clear.c b/src/gallium/drivers/svga/svga_pipe_clear.c index 63f38fbd300..042833bf428 100644 --- a/src/gallium/drivers/svga/svga_pipe_clear.c +++ b/src/gallium/drivers/svga/svga_pipe_clear.c @@ -143,9 +143,8 @@ try_clear(struct svga_context *svga, if (buffers & PIPE_CLEAR_STENCIL) flags |= SVGA3D_CLEAR_STENCIL; - - rect.w = MAX2(rect.w, fb->zsbuf->width); - rect.h = MAX2(rect.h, fb->zsbuf->height); + rect.w = MAX2(rect.w, pipe_surface_width(fb->zsbuf)); + rect.h = MAX2(rect.h, pipe_surface_height(fb->zsbuf)); } if (!svga_have_vgpu10(svga) && @@ -321,8 +320,9 @@ svga_clear_texture(struct pipe_context *pipe, return; } - if (box->x == 0 && box->y == 0 && box->width == surface->width && - box->height == surface->height) { + + if (box->x == 0 && box->y == 0 && box->width == pipe_surface_width(surface) && + box->height == pipe_surface_height(surface)) { /* clearing whole surface, use direct VGPU10 command */ assert(svga_surface(dsv)->view_id != SVGA3D_INVALID_ID); @@ -363,8 +363,8 @@ svga_clear_texture(struct pipe_context *pipe, return; } - if (box->x == 0 && box->y == 0 && box->width == surface->width && - box->height == surface->height) { + if (box->x == 0 && box->y == 0 && box->width == pipe_surface_width(surface) && + box->height == pipe_surface_height(surface)) { struct pipe_framebuffer_state *curr = &svga->curr.framebuffer; bool int_target = is_integer_target(curr, PIPE_CLEAR_COLOR); @@ -509,16 +509,16 @@ svga_clear_render_target(struct pipe_context *pipe, struct pipe_surface *dst, const union pipe_color_union *color, unsigned dstx, unsigned dsty, - unsigned width, unsigned height, + unsigned dst_width, unsigned dst_height, bool render_condition_enabled) { struct svga_context *svga = svga_context( pipe ); svga_toggle_render_condition(svga, render_condition_enabled, false); if (!svga_have_vgpu10(svga) || dstx != 0 || dsty != 0 || - width != dst->width || height != dst->height) { - svga_blitter_clear_render_target(svga, dst, color, dstx, dsty, width, - height); + dst_width != pipe_surface_width(dst) || dst_height != pipe_surface_height(dst)) { + svga_blitter_clear_render_target(svga, dst, color, dstx, dsty, dst_width, + dst_height); } else { enum pipe_error ret; diff --git a/src/gallium/drivers/svga/svga_pipe_misc.c b/src/gallium/drivers/svga/svga_pipe_misc.c index 4624341b9c6..195c555b83c 100644 --- a/src/gallium/drivers/svga/svga_pipe_misc.c +++ b/src/gallium/drivers/svga/svga_pipe_misc.c @@ -108,23 +108,23 @@ svga_set_framebuffer_state(struct pipe_context *pipe, * different size, depending on the host API and driver, */ { - int width = 0, height = 0; + uint16_t width = 0, height = 0; if (fb->zsbuf) { - width = fb->zsbuf->width; - height = fb->zsbuf->height; + pipe_surface_size(fb->zsbuf, &width, &height); } for (i = 0; i < fb->nr_cbufs; ++i) { if (fb->cbufs[i]) { if (width && height) { - if (fb->cbufs[i]->width != width || - fb->cbufs[i]->height != height) { + uint16_t cwidth, cheight; + pipe_surface_size(fb->cbufs[i], &cwidth, &cheight); + if (cwidth != width || + cheight != height) { debug_warning("Mixed-size color and depth/stencil surfaces " "may not work properly"); } } else { - width = fb->cbufs[i]->width; - height = fb->cbufs[i]->height; + pipe_surface_size(fb->cbufs[i], &width, &height); } } } diff --git a/src/gallium/drivers/svga/svga_surface.c b/src/gallium/drivers/svga/svga_surface.c index cf600c61e46..e989276179f 100644 --- a/src/gallium/drivers/svga/svga_surface.c +++ b/src/gallium/drivers/svga/svga_surface.c @@ -305,8 +305,6 @@ svga_create_surface_view(struct pipe_context *pipe, pipe_resource_reference(&s->base.texture, pt); s->base.context = pipe; s->base.format = surf_tmpl->format; - s->base.width = u_minify(pt->width0, surf_tmpl->u.tex.level); - s->base.height = u_minify(pt->height0, surf_tmpl->u.tex.level); s->base.u.tex.level = surf_tmpl->u.tex.level; s->base.u.tex.first_layer = surf_tmpl->u.tex.first_layer; s->base.u.tex.last_layer = surf_tmpl->u.tex.last_layer; diff --git a/src/gallium/drivers/v3d/v3d_blit.c b/src/gallium/drivers/v3d/v3d_blit.c index 3df4a85693d..33b464de302 100644 --- a/src/gallium/drivers/v3d/v3d_blit.c +++ b/src/gallium/drivers/v3d/v3d_blit.c @@ -545,8 +545,12 @@ v3d_tlb_blit(struct pipe_context *pctx, struct pipe_blit_info *info) * This should be fine because we only get here if the src and dst boxes * match, so we know the blit involves the same tiles on both surfaces. */ - job->draw_width = MIN2(dst_surf->width, src_surf->width); - job->draw_height = MIN2(dst_surf->height, src_surf->height); + uint16_t dst_width, dst_height; + pipe_surface_size(dst_surf, &dst_width, &dst_height); + uint16_t src_width, src_height; + pipe_surface_size(src_surf, &src_width, &src_height); + job->draw_width = MIN2(dst_width, src_width); + job->draw_height = MIN2(dst_height, src_height); job->tile_desc.width = tile_width; job->tile_desc.height = tile_height; @@ -818,9 +822,11 @@ v3d_sand8_blit(struct pipe_context *pctx, struct pipe_blit_info *info) * size now we are using a cpp=4 format. Next dimension take into * account the UIF microtile layouts. */ - dst_surf->width = align(dst_surf->width, 8) / 2; + uint16_t width, height; + pipe_surface_size(dst_surf, &width, &height); + width = align(width, 8) / 2; if (src->cpp == 1) - dst_surf->height /= 2; + height /= 2; /* Set the constant buffer. */ struct pipe_constant_buffer cb_uniforms = { @@ -849,7 +855,7 @@ v3d_sand8_blit(struct pipe_context *pctx, struct pipe_blit_info *info) pctx->set_sampler_views(pctx, PIPE_SHADER_FRAGMENT, 0, 0, 0, NULL); pctx->bind_sampler_states(pctx, PIPE_SHADER_FRAGMENT, 0, 0, NULL); - util_blitter_custom_shader(v3d->blitter, dst_surf, + util_blitter_custom_shader(v3d->blitter, dst_surf, width, height, v3d_get_sand8_vs(pctx), v3d_get_sand8_fs(pctx, src->cpp)); @@ -1137,10 +1143,12 @@ v3d_sand30_blit(struct pipe_context *pctx, struct pipe_blit_info *info) * size now we are using a cpp=8 format. Next dimension take into * account the UIF microtile layouts. */ - dst_surf->height /= 2; - dst_surf->width = align(dst_surf->width, 8); + uint16_t width, height; + pipe_surface_size(dst_surf, &width, &height); + height /= 2; + width = align(width, 8); if (src->cpp == 2) - dst_surf->width /= 2; + width /= 2; /* Set the constant buffer. */ struct pipe_constant_buffer cb_uniforms = { .user_buffer = &sand30_stride, @@ -1170,7 +1178,7 @@ v3d_sand30_blit(struct pipe_context *pctx, struct pipe_blit_info *info) NULL); pctx->bind_sampler_states(pctx, PIPE_SHADER_FRAGMENT, 0, 0, NULL); - util_blitter_custom_shader(v3d->blitter, dst_surf, + util_blitter_custom_shader(v3d->blitter, dst_surf, width, height, v3d_get_sand30_vs(pctx), v3d_get_sand30_fs(pctx)); diff --git a/src/gallium/drivers/v3d/v3d_resource.c b/src/gallium/drivers/v3d/v3d_resource.c index d8de2002154..3b3823839f7 100644 --- a/src/gallium/drivers/v3d/v3d_resource.c +++ b/src/gallium/drivers/v3d/v3d_resource.c @@ -1095,8 +1095,6 @@ v3d_create_surface(struct pipe_context *pctx, psurf->context = pctx; psurf->format = surf_tmpl->format; - psurf->width = u_minify(ptex->width0, level); - psurf->height = u_minify(ptex->height0, level); psurf->u.tex.level = level; psurf->u.tex.first_layer = surf_tmpl->u.tex.first_layer; psurf->u.tex.last_layer = surf_tmpl->u.tex.last_layer; diff --git a/src/gallium/drivers/vc4/vc4_blit.c b/src/gallium/drivers/vc4/vc4_blit.c index 1264217a199..a3e0f0dc530 100644 --- a/src/gallium/drivers/vc4/vc4_blit.c +++ b/src/gallium/drivers/vc4/vc4_blit.c @@ -162,8 +162,8 @@ vc4_tile_blit(struct pipe_context *pctx, struct pipe_blit_info *info) job->draw_min_y = info->dst.box.y; job->draw_max_x = info->dst.box.x + info->dst.box.width; job->draw_max_y = info->dst.box.y + info->dst.box.height; - job->draw_width = dst_surf->width; - job->draw_height = dst_surf->height; + job->draw_width = pipe_surface_width(dst_surf); + job->draw_height = pipe_surface_height(dst_surf); job->tile_width = tile_width; job->tile_height = tile_height; @@ -385,9 +385,11 @@ vc4_yuv_blit(struct pipe_context *pctx, struct pipe_blit_info *info) util_blitter_unset_running_flag(vc4->blitter); return; } - dst_surf->width = align(dst_surf->width, 8) / 2; + uint16_t width, height; + pipe_surface_size(dst_surf, &width, &height); + width = align(width, 8) / 2; if (dst->cpp == 1) - dst_surf->height /= 2; + height /= 2; /* Set the constant buffer. */ uint32_t stride = src->slices[info->src.level].stride; @@ -410,7 +412,7 @@ vc4_yuv_blit(struct pipe_context *pctx, struct pipe_blit_info *info) pctx->set_sampler_views(pctx, PIPE_SHADER_FRAGMENT, 0, 0, 0, NULL); pctx->bind_sampler_states(pctx, PIPE_SHADER_FRAGMENT, 0, 0, NULL); - util_blitter_custom_shader(vc4->blitter, dst_surf, + util_blitter_custom_shader(vc4->blitter, dst_surf, width, height, vc4_get_yuv_vs(pctx), vc4_get_yuv_fs(pctx, src->cpp)); diff --git a/src/gallium/drivers/vc4/vc4_resource.c b/src/gallium/drivers/vc4/vc4_resource.c index fbd86cc7a72..41ba936ace3 100644 --- a/src/gallium/drivers/vc4/vc4_resource.c +++ b/src/gallium/drivers/vc4/vc4_resource.c @@ -778,8 +778,6 @@ vc4_create_surface(struct pipe_context *pctx, psurf->context = pctx; psurf->format = surf_tmpl->format; - psurf->width = u_minify(ptex->width0, level); - psurf->height = u_minify(ptex->height0, level); psurf->u.tex.level = level; psurf->u.tex.first_layer = surf_tmpl->u.tex.first_layer; psurf->u.tex.last_layer = surf_tmpl->u.tex.last_layer; @@ -804,8 +802,8 @@ vc4_dump_surface_non_msaa(struct pipe_surface *psurf) struct vc4_resource *rsc = vc4_resource(prsc); uint32_t *map = vc4_bo_map(rsc->bo); uint32_t stride = rsc->slices[0].stride / 4; - uint32_t width = psurf->width; - uint32_t height = psurf->height; + uint16_t width, height; + pipe_surface_size(psurf, &width, &height); uint32_t chunk_w = width / 79; uint32_t chunk_h = height / 40; uint32_t found_colors[10] = { 0 }; @@ -899,8 +897,10 @@ vc4_surface_msaa_get_sample(struct pipe_surface *psurf, { struct pipe_resource *prsc = psurf->texture; struct vc4_resource *rsc = vc4_resource(prsc); + uint16_t width, height; + pipe_surface_size(psurf, &width, &height); uint32_t tile_w = 32, tile_h = 32; - uint32_t tiles_w = DIV_ROUND_UP(psurf->width, 32); + uint32_t tiles_w = DIV_ROUND_UP(width, 32); uint32_t tile_x = x / tile_w; uint32_t tile_y = y / tile_h; @@ -971,23 +971,25 @@ static void vc4_dump_surface_msaa(struct pipe_surface *psurf) { uint32_t tile_w = 32, tile_h = 32; - uint32_t tiles_w = DIV_ROUND_UP(psurf->width, tile_w); - uint32_t tiles_h = DIV_ROUND_UP(psurf->height, tile_h); + uint16_t width, height; + pipe_surface_size(psurf, &width, &height); + uint32_t tiles_w = DIV_ROUND_UP(width, tile_w); + uint32_t tiles_h = DIV_ROUND_UP(height, tile_h); uint32_t char_w = 140, char_h = 60; uint32_t char_w_per_tile = char_w / tiles_w - 1; uint32_t char_h_per_tile = char_h / tiles_h - 1; fprintf(stderr, "Surface: %dx%d (%dx MSAA)\n", - psurf->width, psurf->height, psurf->texture->nr_samples); + width, height, psurf->texture->nr_samples); for (int x = 0; x < (char_w_per_tile + 1) * tiles_w; x++) fprintf(stderr, "-"); fprintf(stderr, "\n"); - for (int ty = 0; ty < psurf->height; ty += tile_h) { + for (int ty = 0; ty < height; ty += tile_h) { for (int y = 0; y < char_h_per_tile; y++) { - for (int tx = 0; tx < psurf->width; tx += tile_w) { + for (int tx = 0; tx < width; tx += tile_w) { for (int x = 0; x < char_w_per_tile; x++) { uint32_t bx1 = (x * tile_w / char_w_per_tile); diff --git a/src/gallium/drivers/virgl/virgl_context.c b/src/gallium/drivers/virgl/virgl_context.c index ff41be4ea2a..7dcec305a53 100644 --- a/src/gallium/drivers/virgl/virgl_context.c +++ b/src/gallium/drivers/virgl/virgl_context.c @@ -373,8 +373,6 @@ static struct pipe_surface *virgl_create_surface(struct pipe_context *ctx, surf->base.context = ctx; surf->base.format = templ->format; - surf->base.width = u_minify(resource->width0, templ->u.tex.level); - surf->base.height = u_minify(resource->height0, templ->u.tex.level); surf->base.u.tex.level = templ->u.tex.level; surf->base.u.tex.first_layer = templ->u.tex.first_layer; surf->base.u.tex.last_layer = templ->u.tex.last_layer; diff --git a/src/gallium/drivers/zink/zink_clear.c b/src/gallium/drivers/zink/zink_clear.c index 2c6af70b8af..393662b8dd1 100644 --- a/src/gallium/drivers/zink/zink_clear.c +++ b/src/gallium/drivers/zink/zink_clear.c @@ -188,7 +188,7 @@ zink_clear(struct pipe_context *pctx, color.f[3] = 1.0; pctx->clear_render_target(pctx, ctx->fb_state.cbufs[i], &color, 0, 0, - ctx->fb_state.cbufs[i]->width, ctx->fb_state.cbufs[i]->height, + ctx->fb_state.width, ctx->fb_state.height, ctx->render_condition_active); } pctx->clear_render_target(pctx, ctx->fb_state.cbufs[i], pcolor, @@ -417,8 +417,13 @@ static void set_clear_fb(struct pipe_context *pctx, struct pipe_surface *psurf, struct pipe_surface *zsurf) { struct pipe_framebuffer_state fb_state = {0}; - fb_state.width = psurf ? psurf->width : zsurf->width; - fb_state.height = psurf ? psurf->height : zsurf->height; + uint16_t width, height; + if (psurf) + pipe_surface_size(psurf, &width, &height); + else + pipe_surface_size(zsurf, &width, &height); + fb_state.width = width; + fb_state.height = height; fb_state.nr_cbufs = !!psurf; fb_state.cbufs[0] = psurf; fb_state.zsbuf = zsurf; diff --git a/src/gallium/drivers/zink/zink_kopper.c b/src/gallium/drivers/zink/zink_kopper.c index ef04ea1628c..69c4771325e 100644 --- a/src/gallium/drivers/zink/zink_kopper.c +++ b/src/gallium/drivers/zink/zink_kopper.c @@ -1135,8 +1135,6 @@ zink_kopper_fixup_depth_buffer(struct zink_context *ctx) res->base.b.height0 = ctx->fb_state.height; pipe_resource_reference(&pz, NULL); - ctx->fb_state.zsbuf->width = ctx->fb_state.width; - ctx->fb_state.zsbuf->height = ctx->fb_state.height; struct pipe_surface *psurf = ctx->base.create_surface(&ctx->base, &res->base.b, ctx->fb_state.zsbuf); struct zink_ctx_surface *cz = (struct zink_ctx_surface*)psurf; diff --git a/src/gallium/drivers/zink/zink_surface.c b/src/gallium/drivers/zink/zink_surface.c index b326ce49187..5f5bfb341a5 100644 --- a/src/gallium/drivers/zink/zink_surface.c +++ b/src/gallium/drivers/zink/zink_surface.c @@ -115,8 +115,9 @@ init_surface_info(struct zink_screen *screen, struct zink_surface *surface, stru VkImageViewUsageCreateInfo *usage_info = (VkImageViewUsageCreateInfo *)ivci->pNext; surface->info.flags = res->obj->vkflags; surface->info.usage = usage_info ? usage_info->usage : res->obj->vkusage; - surface->info.width = surface->base.width; - surface->info.height = surface->base.height; + + surface->info.width = pipe_surface_width(&surface->base); + surface->info.height = pipe_surface_height(&surface->base); surface->info.layerCount = ivci->subresourceRange.layerCount; surface->info.format[0] = ivci->format; if (res->obj->dt) { @@ -141,22 +142,6 @@ init_pipe_surface_info(struct pipe_context *pctx, struct pipe_surface *psurf, co unsigned int level = templ->u.tex.level; psurf->context = pctx; psurf->format = templ->format; - psurf->width = u_minify(pres->width0, level); - assert(psurf->width); - psurf->height = u_minify(pres->height0, level); - assert(psurf->height); - - if (util_format_is_compressed(pres->format) && - !util_format_is_compressed(psurf->format)) { - assert(util_format_get_blockwidth(psurf->format) == 1); - assert(util_format_get_blockheight(psurf->format) == 1); - - psurf->width = DIV_ROUND_UP(psurf->width, - util_format_get_blockwidth(pres->format)); - psurf->height = DIV_ROUND_UP(psurf->height, - util_format_get_blockheight(pres->format)); - } - psurf->nr_samples = templ->nr_samples; psurf->u.tex.level = level; psurf->u.tex.first_layer = templ->u.tex.first_layer; @@ -557,8 +542,6 @@ zink_surface_swapchain_update(struct zink_context *ctx, struct zink_surface *sur mesa_loge("ZINK: failed to allocate surface->swapchain!"); return; } - surface->base.width = res->base.b.width0; - surface->base.height = res->base.b.height0; init_surface_info(screen, surface, res, &surface->ivci); surface->dt_swapchain = cdt->swapchain; } diff --git a/src/gallium/frontends/lavapipe/lvp_execute.c b/src/gallium/frontends/lavapipe/lvp_execute.c index ad80f4f3763..e507f3a6346 100644 --- a/src/gallium/frontends/lavapipe/lvp_execute.c +++ b/src/gallium/frontends/lavapipe/lvp_execute.c @@ -1220,8 +1220,6 @@ static struct pipe_surface *create_img_surface_bo(struct rendering_state *state, VkImageSubresourceRange *range, struct pipe_resource *bo, enum pipe_format pformat, - int width, - int height, int base_layer, int layer_count, int level) { @@ -1230,8 +1228,6 @@ static struct pipe_surface *create_img_surface_bo(struct rendering_state *state, const struct pipe_surface template = { .format = pformat, - .width = width, - .height = height, .u.tex.first_layer = range->baseArrayLayer + base_layer, .u.tex.last_layer = range->baseArrayLayer + base_layer + layer_count - 1, .u.tex.level = range->baseMipLevel + level, @@ -1243,8 +1239,7 @@ static struct pipe_surface *create_img_surface_bo(struct rendering_state *state, } static struct pipe_surface *create_img_surface(struct rendering_state *state, struct lvp_image_view *imgv, - VkFormat format, int width, - int height, + VkFormat format, int base_layer, int layer_count) { VkImageSubresourceRange imgv_subres = @@ -1252,11 +1247,11 @@ static struct pipe_surface *create_img_surface(struct rendering_state *state, return create_img_surface_bo(state, &imgv_subres, imgv->image->planes[0].bo, lvp_vk_format_to_pipe_format(format), - width, height, base_layer, layer_count, 0); + base_layer, layer_count, 0); } static void add_img_view_surface(struct rendering_state *state, - struct lvp_image_view *imgv, int width, int height, + struct lvp_image_view *imgv, int layer_count) { if (imgv->surface) { @@ -1266,7 +1261,6 @@ static void add_img_view_surface(struct rendering_state *state, if (!imgv->surface) { imgv->surface = create_img_surface(state, imgv, imgv->vk.format, - width, height, 0, layer_count); } } @@ -1296,8 +1290,6 @@ static void clear_attachment_layers(struct rendering_state *state, struct pipe_surface *clear_surf = create_img_surface(state, imgv, imgv->vk.format, - state->framebuffer.width, - state->framebuffer.height, base_layer, layer_count); @@ -1731,7 +1723,6 @@ handle_begin_rendering(struct vk_cmd_queue_entry *cmd, if (state->color_att[i].imgv) { struct lvp_image_view *imgv = state->color_att[i].imgv; add_img_view_surface(state, imgv, - state->framebuffer.width, state->framebuffer.height, state->framebuffer.layers); if (state->forced_sample_count && imgv->image->vk.samples == 1) state->color_att[i].imgv = create_multisample_surface(state, imgv, state->forced_sample_count, @@ -1756,7 +1747,6 @@ handle_begin_rendering(struct vk_cmd_queue_entry *cmd, state->stencil_att.imgv; struct lvp_image_view *imgv = state->ds_imgv; add_img_view_surface(state, imgv, - state->framebuffer.width, state->framebuffer.height, state->framebuffer.layers); if (state->forced_sample_count && imgv->image->vk.samples == 1) { VkAttachmentLoadOp load_op; @@ -3103,7 +3093,6 @@ static void handle_clear_ds_image(struct vk_cmd_queue_entry *cmd, surf = create_img_surface_bo(state, range, image->planes[0].bo, image->planes[0].bo->format, - width, height, 0, depth, j); state->pctx->clear_depth_stencil(state->pctx, diff --git a/src/gallium/frontends/va/surface.c b/src/gallium/frontends/va/surface.c index cfbc5845e36..967216b2bb9 100644 --- a/src/gallium/frontends/va/surface.c +++ b/src/gallium/frontends/va/surface.c @@ -990,8 +990,10 @@ vlVaHandleSurfaceAllocate(vlVaDriver *drv, vlVaSurface *surface, if (i > !!surface->buffer->interlaced) c.f[0] = c.f[1] = c.f[2] = c.f[3] = 0.5f; + uint16_t width, height; + pipe_surface_size(surfaces[i], &width, &height); drv->pipe->clear_render_target(drv->pipe, surfaces[i], &c, 0, 0, - surfaces[i]->width, surfaces[i]->height, + width, height, false); } vlVaSurfaceFlush(drv, surface); diff --git a/src/gallium/frontends/vdpau/mixer.c b/src/gallium/frontends/vdpau/mixer.c index ecac2fc31c3..64d21d84a3b 100644 --- a/src/gallium/frontends/vdpau/mixer.c +++ b/src/gallium/frontends/vdpau/mixer.c @@ -356,8 +356,8 @@ VdpStatus vlVdpVideoMixerRender(VdpVideoMixer mixer, res_tmpl.usage = PIPE_USAGE_DEFAULT; if (!vmixer->bicubic.filter) { - res_tmpl.width0 = dst->surface->width; - res_tmpl.height0 = dst->surface->height; + res_tmpl.width0 = pipe_surface_width(dst->surface); + res_tmpl.height0 = pipe_surface_height(dst->surface); } else { res_tmpl.width0 = surf->templat.width; res_tmpl.height0 = surf->templat.height; diff --git a/src/gallium/frontends/vdpau/output.c b/src/gallium/frontends/vdpau/output.c index 20b1b39e0dc..a99d8a6eb49 100644 --- a/src/gallium/frontends/vdpau/output.c +++ b/src/gallium/frontends/vdpau/output.c @@ -823,8 +823,8 @@ VdpStatus vlVdpOutputSurfaceDMABuf(VdpOutputSurface surface, mtx_unlock(&vlsurface->device->mutex); result->handle = whandle.handle; - result->width = vlsurface->surface->width; - result->height = vlsurface->surface->height; + result->width = pipe_surface_width(vlsurface->surface); + result->height = pipe_surface_height(vlsurface->surface); result->offset = whandle.offset; result->stride = whandle.stride; result->format = PipeToFormatRGBA(vlsurface->surface->format); diff --git a/src/gallium/frontends/vdpau/presentation.c b/src/gallium/frontends/vdpau/presentation.c index ad2baf2ff82..ff3c1e4820f 100644 --- a/src/gallium/frontends/vdpau/presentation.c +++ b/src/gallium/frontends/vdpau/presentation.c @@ -248,13 +248,13 @@ vlVdpPresentationQueueDisplay(VdpPresentationQueue presentation_queue, dst_clip.x0 = 0; dst_clip.y0 = 0; - dst_clip.x1 = clip_width ? clip_width : surf_draw->width; - dst_clip.y1 = clip_height ? clip_height : surf_draw->height; + dst_clip.x1 = clip_width ? clip_width : pipe_surface_width(surf_draw); + dst_clip.y1 = clip_height ? clip_height : pipe_surface_height(surf_draw); src_rect.x0 = 0; src_rect.y0 = 0; - src_rect.x1 = surf_draw->width; - src_rect.y1 = surf_draw->height; + src_rect.x1 = pipe_surface_width(surf_draw); + src_rect.y1 = pipe_surface_height(surf_draw); vl_compositor_clear_layers(cstate); vl_compositor_set_rgba_layer(cstate, compositor, 0, surf->sampler_view, &src_rect, NULL, NULL); diff --git a/src/gallium/frontends/vdpau/surface.c b/src/gallium/frontends/vdpau/surface.c index 13604603d44..5de3fa43454 100644 --- a/src/gallium/frontends/vdpau/surface.c +++ b/src/gallium/frontends/vdpau/surface.c @@ -450,8 +450,10 @@ vlVdpVideoSurfaceClear(vlVdpSurface *vlsurf) if (i > !!vlsurf->templat.interlaced) c.f[0] = c.f[1] = c.f[2] = c.f[3] = 0.5f; + uint16_t width, height; + pipe_surface_size(surfaces[i], &width, &height); pipe->clear_render_target(pipe, surfaces[i], &c, 0, 0, - surfaces[i]->width, surfaces[i]->height, false); + width, height, false); } pipe->flush(pipe, NULL, 0); } @@ -534,10 +536,9 @@ VdpStatus vlVdpVideoSurfaceDMABuf(VdpVideoSurface surface, } mtx_unlock(&p_surf->device->mutex); - result->handle = whandle.handle; - result->width = surf->width; - result->height = surf->height; + result->width = pipe_surface_width(surf); + result->height = pipe_surface_height(surf); result->offset = whandle.offset; result->stride = whandle.stride; diff --git a/src/gallium/frontends/xa/xa_renderer.c b/src/gallium/frontends/xa/xa_renderer.c index 75a55b70a69..d3e146beb41 100644 --- a/src/gallium/frontends/xa/xa_renderer.c +++ b/src/gallium/frontends/xa/xa_renderer.c @@ -322,8 +322,8 @@ void renderer_bind_destination(struct xa_context *r, struct pipe_surface *surface) { - int width = surface->width; - int height = surface->height; + uint16_t width, height; + pipe_surface_size(surface, &width, &height); struct pipe_framebuffer_state fb; struct pipe_viewport_state viewport; @@ -333,8 +333,7 @@ renderer_bind_destination(struct xa_context *r, /* Framebuffer uses actual surface width/height */ memset(&fb, 0, sizeof fb); - fb.width = surface->width; - fb.height = surface->height; + pipe_surface_size(surface, &fb.width, &fb.height); fb.nr_cbufs = 1; fb.cbufs[0] = surface; fb.zsbuf = NULL; diff --git a/src/gallium/include/pipe/p_state.h b/src/gallium/include/pipe/p_state.h index 4937df62e40..23a99a81a36 100644 --- a/src/gallium/include/pipe/p_state.h +++ b/src/gallium/include/pipe/p_state.h @@ -472,10 +472,6 @@ struct pipe_surface struct pipe_resource *texture; /**< resource into which this is a view */ struct pipe_context *context; /**< context this surface belongs to */ - /* XXX width/height should be removed */ - uint16_t width; /**< logical width in pixels */ - uint16_t height; /**< logical height in pixels */ - /** * Number of samples for the surface. This will be 0 if rendering * should use the resource's nr_samples, or another value if the resource diff --git a/src/mesa/main/renderbuffer.c b/src/mesa/main/renderbuffer.c index 49bcd1be8cc..6374d0aba1e 100644 --- a/src/mesa/main/renderbuffer.c +++ b/src/mesa/main/renderbuffer.c @@ -663,8 +663,6 @@ _mesa_update_renderbuffer_surface(struct gl_context *ctx, surf->texture->nr_storage_samples != rb->NumStorageSamples || surf->format != format || surf->texture != resource || - surf->width != rtt_width || - surf->height != rtt_height || surf->nr_samples != nr_samples || surf->u.tex.level != level || surf->u.tex.first_layer != first_layer || diff --git a/src/mesa/state_tracker/st_atom_framebuffer.c b/src/mesa/state_tracker/st_atom_framebuffer.c index 87394935aff..f6483addf62 100644 --- a/src/mesa/state_tracker/st_atom_framebuffer.c +++ b/src/mesa/state_tracker/st_atom_framebuffer.c @@ -61,11 +61,13 @@ static void update_framebuffer_size(struct pipe_framebuffer_state *framebuffer, struct pipe_surface *surface) { + uint16_t width, height; assert(surface); - assert(surface->width < USHRT_MAX); - assert(surface->height < USHRT_MAX); - framebuffer->width = MIN2(framebuffer->width, surface->width); - framebuffer->height = MIN2(framebuffer->height, surface->height); + pipe_surface_size(surface, &width, &height); + assert(width < USHRT_MAX); + assert(height < USHRT_MAX); + framebuffer->width = MIN2(framebuffer->width, width); + framebuffer->height = MIN2(framebuffer->height, height); } /** diff --git a/src/mesa/state_tracker/st_cb_readpixels.c b/src/mesa/state_tracker/st_cb_readpixels.c index 295d12ba973..38c4bc23748 100644 --- a/src/mesa/state_tracker/st_cb_readpixels.c +++ b/src/mesa/state_tracker/st_cb_readpixels.c @@ -216,8 +216,7 @@ try_pbo_readpixels(struct st_context *st, struct gl_renderbuffer *rb, /* Set up no-attachment framebuffer */ memset(&fb, 0, sizeof(fb)); - fb.width = surface->width; - fb.height = surface->height; + pipe_surface_size(surface, &fb.width, &fb.height); fb.samples = 1; fb.layers = addr.depth; cso_set_framebuffer(cso, &fb); diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c index 0122bcb4c66..1e7c6a7320e 100644 --- a/src/mesa/state_tracker/st_cb_texture.c +++ b/src/mesa/state_tracker/st_cb_texture.c @@ -1777,19 +1777,22 @@ try_pbo_upload_common(struct gl_context *ctx, pipe_sampler_view_release(sampler_view); } + uint16_t width, height; + pipe_surface_size(surface, &width, &height); + /* Framebuffer_state */ { struct pipe_framebuffer_state fb; memset(&fb, 0, sizeof(fb)); - fb.width = surface->width; - fb.height = surface->height; + fb.width = width; + fb.height = height; fb.nr_cbufs = 1; fb.cbufs[0] = surface; cso_set_framebuffer(cso, &fb); } - cso_set_viewport_dims(cso, surface->width, surface->height, false); + cso_set_viewport_dims(cso, width, height, false); /* Blend state */ cso_set_blend(cso, &st->pbo.upload_blend); @@ -1804,7 +1807,7 @@ try_pbo_upload_common(struct gl_context *ctx, /* Set up the fragment shader */ cso_set_fragment_shader_handle(cso, fs); - success = st_pbo_draw(st, addr, surface->width, surface->height); + success = st_pbo_draw(st, addr, width, height); fail: /* Unbind all because st/mesa won't do it if the current shader doesn't diff --git a/src/mesa/state_tracker/st_manager.c b/src/mesa/state_tracker/st_manager.c index f961e965518..4b0608810ec 100644 --- a/src/mesa/state_tracker/st_manager.c +++ b/src/mesa/state_tracker/st_manager.c @@ -203,9 +203,8 @@ st_set_ws_renderbuffer_surface(struct gl_renderbuffer *rb, rb->surface = surf; /* just assign, don't ref */ pipe_resource_reference(&rb->texture, surf->texture); - - rb->Width = surf->width; - rb->Height = surf->height; + rb->Width = pipe_surface_width(surf); + rb->Height = pipe_surface_height(surf); }