gallium: de-pointerize pipe_surface

this allows eliminating surface refcounting and objects
which, relatively speaking, don't serve much purpose

see MR for details

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34054>
This commit is contained in:
Mike Blumenkrantz 2025-03-14 14:33:53 -04:00 committed by Marge Bot
parent 506c8f9b76
commit 2eb45daa9c
254 changed files with 2086 additions and 2338 deletions

View file

@ -423,17 +423,17 @@ dd_dump_draw_vbo(struct dd_draw_state *dstate, struct pipe_draw_info *info,
DUMP(framebuffer_state, &dstate->framebuffer_state);
for (i = 0; i < dstate->framebuffer_state.nr_cbufs; i++)
if (dstate->framebuffer_state.cbufs[i]) {
if (dstate->framebuffer_state.cbufs[i].texture) {
fprintf(f, " " COLOR_STATE "cbufs[%i]:" COLOR_RESET "\n ", i);
DUMP(surface, dstate->framebuffer_state.cbufs[i]);
DUMP(surface, &dstate->framebuffer_state.cbufs[i]);
fprintf(f, " ");
DUMP(resource, dstate->framebuffer_state.cbufs[i]->texture);
DUMP(resource, dstate->framebuffer_state.cbufs[i].texture);
}
if (dstate->framebuffer_state.zsbuf) {
if (dstate->framebuffer_state.zsbuf.texture) {
fprintf(f, " " COLOR_STATE "zsbuf:" COLOR_RESET "\n ");
DUMP(surface, dstate->framebuffer_state.zsbuf);
DUMP(surface, &dstate->framebuffer_state.zsbuf);
fprintf(f, " ");
DUMP(resource, dstate->framebuffer_state.zsbuf->texture);
DUMP(resource, dstate->framebuffer_state.zsbuf.texture);
}
fprintf(f, "\n");
}

View file

@ -987,16 +987,9 @@ trace_context_set_framebuffer_state(struct pipe_context *_pipe,
{
struct trace_context *tr_ctx = trace_context(_pipe);
struct pipe_context *pipe = tr_ctx->pipe;
unsigned i;
/* Unwrap the input state */
memcpy(&tr_ctx->unwrapped_state, state, sizeof(tr_ctx->unwrapped_state));
for (i = 0; i < state->nr_cbufs; ++i)
tr_ctx->unwrapped_state.cbufs[i] = trace_surface_unwrap(tr_ctx, state->cbufs[i]);
for (i = state->nr_cbufs; i < PIPE_MAX_COLOR_BUFS; ++i)
tr_ctx->unwrapped_state.cbufs[i] = NULL;
tr_ctx->unwrapped_state.zsbuf = trace_surface_unwrap(tr_ctx, state->zsbuf);
state = &tr_ctx->unwrapped_state;
util_copy_framebuffer_state(&tr_ctx->unwrapped_state, state);
dump_fb_state(tr_ctx, "set_framebuffer_state", trace_dump_is_triggered());

View file

@ -191,6 +191,13 @@ bool trace_dump_is_triggered(void);
trace_dump_member_end(); \
} while(0)
#define trace_dump_member_val(_type, _obj, _member) \
do { \
trace_dump_member_begin(#_member); \
trace_dump_##_type(&(_obj)->_member); \
trace_dump_member_end(); \
} while(0)
#define trace_dump_member_enum(_type, _obj, _member) \
do { \

View file

@ -560,8 +560,10 @@ void trace_dump_framebuffer_state(const struct pipe_framebuffer_state *state)
trace_dump_member(uint, state, samples);
trace_dump_member(uint, state, layers);
trace_dump_member(uint, state, nr_cbufs);
trace_dump_member_array(ptr, state, cbufs);
trace_dump_member(ptr, state, zsbuf);
trace_dump_member_begin("cbufs");
trace_dump_array_impl(surface, state->cbufs, state->nr_cbufs, &);
trace_dump_member_end();
trace_dump_member_val(surface, state, zsbuf);
trace_dump_struct_end();
}
@ -578,8 +580,10 @@ void trace_dump_framebuffer_state_deep(const struct pipe_framebuffer_state *stat
trace_dump_member(uint, state, samples);
trace_dump_member(uint, state, layers);
trace_dump_member(uint, state, nr_cbufs);
trace_dump_member_array(surface, state, cbufs);
trace_dump_member(surface, state, zsbuf);
trace_dump_member_begin("cbufs");
trace_dump_array_impl(surface, state->cbufs, state->nr_cbufs, &);
trace_dump_member_end();
trace_dump_member_val(surface, state, zsbuf);
trace_dump_struct_end();
}
@ -677,7 +681,7 @@ void trace_dump_sampler_view_template(const struct pipe_sampler_view *state)
void trace_dump_surface(const struct pipe_surface *surface)
{
trace_dump_surface_template(surface, surface ? surface->texture->target : 0);
trace_dump_surface_template(surface, surface && surface->texture ? surface->texture->target : 0);
}

View file

@ -355,9 +355,6 @@ trace_video_buffer_destroy(struct pipe_video_buffer *_buffer)
pipe_sampler_view_reference(&tr_vbuffer->sampler_view_planes[i], NULL);
pipe_sampler_view_reference(&tr_vbuffer->sampler_view_components[i], NULL);
}
for (int i=0; i < VL_MAX_SURFACES; i++) {
pipe_surface_reference(&tr_vbuffer->surfaces[i], NULL);
}
video_buffer->destroy(video_buffer);
ralloc_free(tr_vbuffer);
@ -431,30 +428,21 @@ trace_video_buffer_get_sampler_view_components(struct pipe_video_buffer *_buffer
return view_components ? tr_vbuffer->sampler_view_components : NULL;
}
static struct pipe_surface **
static struct pipe_surface *
trace_video_buffer_get_surfaces(struct pipe_video_buffer *_buffer)
{
struct trace_context *tr_ctx = trace_context(_buffer->context);
struct trace_video_buffer *tr_vbuffer = trace_video_buffer(_buffer);
struct pipe_video_buffer *buffer = tr_vbuffer->video_buffer;
struct trace_video_buffer *tr_vbuffer = trace_video_buffer(_buffer);
struct pipe_video_buffer *buffer = tr_vbuffer->video_buffer;
trace_dump_call_begin("pipe_video_buffer", "get_surfaces");
trace_dump_arg(ptr, buffer);
trace_dump_call_begin("pipe_video_buffer", "get_surfaces");
trace_dump_arg(ptr, buffer);
struct pipe_surface **surfaces = buffer->get_surfaces(buffer);
struct pipe_surface *surfaces = buffer->get_surfaces(buffer);
trace_dump_ret_array(ptr, surfaces, VL_MAX_SURFACES);
trace_dump_call_end();
trace_dump_array_impl(surface, surfaces, VL_MAX_SURFACES, &);
trace_dump_call_end();
for (int i=0; i < VL_MAX_SURFACES; i++) {
if (!surfaces || !surfaces[i]) {
pipe_surface_reference(&tr_vbuffer->surfaces[i], NULL);
} else if (tr_vbuffer->surfaces[i] == NULL || (trace_surface(tr_vbuffer->surfaces[i])->surface != surfaces[i])){
pipe_surface_reference(&tr_vbuffer->surfaces[i], trace_surf_create(tr_ctx, surfaces[i]->texture, surfaces[i]));
}
}
return surfaces ? tr_vbuffer->surfaces : NULL;
return surfaces;
}

View file

@ -34,7 +34,6 @@ struct trace_video_buffer
struct pipe_sampler_view *sampler_view_planes[VL_NUM_COMPONENTS];
struct pipe_sampler_view *sampler_view_components[VL_NUM_COMPONENTS];
struct pipe_surface *surfaces[VL_MAX_SURFACES];
};
static inline struct trace_video_buffer *

View file

@ -485,7 +485,7 @@ hud_draw_results(struct hud_context *hud, struct pipe_resource *tex)
struct cso_context *cso = hud->cso;
struct pipe_context *pipe = hud->pipe;
struct pipe_framebuffer_state fb;
struct pipe_surface surf_templ, *surf;
struct pipe_surface surf_templ;
struct pipe_viewport_state viewport;
const struct pipe_sampler_state *sampler_states[] =
{ &hud->font_sampler_state };
@ -545,12 +545,10 @@ hud_draw_results(struct hud_context *hud, struct pipe_resource *tex)
if (srgb_format != PIPE_FORMAT_NONE)
surf_templ.format = srgb_format;
}
surf = pipe->create_surface(pipe, tex, &surf_templ);
memset(&fb, 0, sizeof(fb));
fb.nr_cbufs = 1;
fb.cbufs[0] = surf;
fb.zsbuf = NULL;
fb.cbufs[0] = surf_templ;
fb.width = hud->fb_width;
fb.height = hud->fb_height;
fb.resolve = NULL;
@ -664,8 +662,6 @@ done:
ST_INVALIDATE_VS_CONSTBUF0 |
ST_INVALIDATE_VERTEX_BUFFERS);
}
pipe_surface_reference(&surf, NULL);
}
static void

View file

@ -159,14 +159,11 @@ pp_free_fbos(struct pp_queue_t *ppq)
return;
for (i = 0; i < ppq->n_tmp; i++) {
pipe_surface_reference(&ppq->tmps[i], NULL);
pipe_resource_reference(&ppq->tmp[i], NULL);
}
for (i = 0; i < ppq->n_inner_tmp; i++) {
pipe_surface_reference(&ppq->inner_tmps[i], NULL);
pipe_resource_reference(&ppq->inner_tmp[i], NULL);
}
pipe_surface_reference(&ppq->stencils, NULL);
pipe_resource_reference(&ppq->stencil, NULL);
ppq->fbos_init = false;
@ -295,19 +292,18 @@ pp_init_fbos(struct pp_queue_t *ppq, unsigned int w,
for (i = 0; i < ppq->n_tmp; i++) {
ppq->tmp[i] = p->screen->resource_create(p->screen, &tmp_res);
ppq->tmps[i] = p->pipe->create_surface(p->pipe, ppq->tmp[i], &p->surf);
ppq->tmps[i] = p->surf;
ppq->tmps[i].texture = ppq->tmp[i];
if (!ppq->tmp[i] || !ppq->tmps[i])
if (!ppq->tmp[i])
goto error;
}
for (i = 0; i < ppq->n_inner_tmp; i++) {
ppq->inner_tmp[i] = p->screen->resource_create(p->screen, &tmp_res);
ppq->inner_tmps[i] = p->pipe->create_surface(p->pipe,
ppq->inner_tmp[i],
&p->surf);
if (!ppq->inner_tmp[i] || !ppq->inner_tmps[i])
ppq->inner_tmps[i] = p->surf;
ppq->inner_tmps[i].texture = ppq->inner_tmp[i];
if (!ppq->inner_tmp[i])
goto error;
}
@ -326,8 +322,8 @@ pp_init_fbos(struct pp_queue_t *ppq, unsigned int w,
}
ppq->stencil = p->screen->resource_create(p->screen, &tmp_res);
ppq->stencils = p->pipe->create_surface(p->pipe, ppq->stencil, &p->surf);
if (!ppq->stencil || !ppq->stencils)
ppq->stencils = p->surf;
if (!ppq->stencil)
goto error;
p->framebuffer.width = w;

View file

@ -184,7 +184,7 @@ pp_jimenezmlaa_run(struct pp_queue_t *ppq, struct pipe_resource *in,
/* Blit the input to the output */
pp_blit(p->pipe, in, 0, 0,
w, h, 0, p->framebuffer.cbufs[0],
w, h, 0, &p->framebuffer.cbufs[0],
0, 0, w, h);
u_sampler_view_default_template(&v_tmp, in, in->format);
@ -211,7 +211,7 @@ pp_jimenezmlaa_run(struct pp_queue_t *ppq, struct pipe_resource *in,
pipe->sampler_view_release(pipe, arr[1]);
p->blend.rt[0].blend_enable = 0;
p->framebuffer.zsbuf = NULL;
memset(&p->framebuffer.zsbuf, 0, sizeof(p->framebuffer.zsbuf));
}
/** The init function of the MLAA filter. */

View file

@ -83,7 +83,7 @@ struct pp_queue_t
struct pipe_resource *stencil; /* stencil shared by inner_tmps */
struct pipe_resource *areamaptex; /* MLAA area map texture */
struct pipe_surface *tmps[2], *inner_tmps[3], *stencils;
struct pipe_surface tmps[2], inner_tmps[3], stencils;
void ***shaders; /* Shaders in TGSI form */
unsigned int *filters; /* Active filter to filters.h mapping. */

View file

@ -110,7 +110,7 @@ pp_run(struct pp_queue_t *ppq, struct pipe_resource *in,
pp_blit(ppq->p->pipe, in, 0, 0,
w, h, 0, ppq->tmps[0],
w, h, 0, &ppq->tmps[0],
0, 0, w, h);
in = ppq->tmp[0];
@ -223,14 +223,14 @@ pp_filter_setup_out(struct pp_program *p, struct pipe_resource *out)
{
p->surf.format = out->format;
p->framebuffer.cbufs[0] = p->pipe->create_surface(p->pipe, out, &p->surf);
p->framebuffer.cbufs[0] = p->surf;
p->framebuffer.cbufs[0].texture = out;
}
/** Clean up the input and output set with the above. */
void
pp_filter_end_pass(struct pp_program *p)
{
pipe_surface_reference(&p->framebuffer.cbufs[0], NULL);
pipe_sampler_view_reference(&p->view, NULL);
}

View file

@ -1585,6 +1585,7 @@ void util_blitter_default_dst_texture(struct pipe_surface *dst_templ,
unsigned dstz)
{
memset(dst_templ, 0, sizeof(*dst_templ));
dst_templ->texture = dst;
dst_templ->format = util_format_linear(dst->format);
dst_templ->u.tex.level = dstlevel;
dst_templ->u.tex.first_layer = dstz;
@ -1728,7 +1729,7 @@ void util_blitter_copy_texture(struct blitter_context *blitter,
{
struct blitter_context_priv *ctx = (struct blitter_context_priv*)blitter;
struct pipe_context *pipe = ctx->base.pipe;
struct pipe_surface *dst_view, dst_templ;
struct pipe_surface dst_templ;
struct pipe_sampler_view src_templ, *src_view;
struct pipe_box dstbox;
@ -1740,19 +1741,17 @@ void util_blitter_copy_texture(struct blitter_context *blitter,
/* Initialize the surface. */
util_blitter_default_dst_texture(&dst_templ, dst, dst_level, dstz);
dst_view = pipe->create_surface(pipe, dst, &dst_templ);
/* Initialize the sampler view. */
util_blitter_default_src_texture(blitter, &src_templ, src, src_level);
src_view = pipe->create_sampler_view(pipe, src, &src_templ);
/* Copy. */
util_blitter_blit_generic(blitter, dst_view, &dstbox,
util_blitter_blit_generic(blitter, &dst_templ, &dstbox,
src_view, srcbox, src->width0, src->height0,
PIPE_MASK_RGBAZS, PIPE_TEX_FILTER_NEAREST, NULL,
false, false, 0, NULL);
pipe_surface_reference(&dst_view, NULL);
pipe_sampler_view_reference(&src_view, NULL);
}
@ -1825,9 +1824,9 @@ static void do_blits(struct blitter_context_priv *ctx,
(src_samples <= 1 || sample_shading)) {
/* Set framebuffer state. */
if (is_zsbuf) {
fb_state.zsbuf = dst;
memcpy(&fb_state.zsbuf, dst, sizeof(*dst));
} else {
fb_state.cbufs[0] = dst;
memcpy(&fb_state.cbufs[0], dst, sizeof(*dst));
}
pipe->set_framebuffer_state(pipe, &fb_state);
@ -1879,9 +1878,9 @@ static void do_blits(struct blitter_context_priv *ctx,
/* Set framebuffer state. */
if (is_zsbuf) {
fb_state.zsbuf = dst;
memcpy(&fb_state.zsbuf, dst, sizeof(*dst));
} else {
fb_state.cbufs[0] = dst;
memcpy(&fb_state.cbufs[0], dst, sizeof(*dst));
}
pipe->set_framebuffer_state(pipe, &fb_state);
@ -2200,7 +2199,7 @@ util_blitter_blit(struct blitter_context *blitter,
struct pipe_resource *src = info->src.resource;
struct blitter_context_priv *ctx = (struct blitter_context_priv*)blitter;
struct pipe_context *pipe = ctx->base.pipe;
struct pipe_surface *dst_view, dst_templ;
struct pipe_surface dst_templ;
struct pipe_sampler_view src_templ, *src_view;
const uint8_t *swizzle = info->swizzle_enable ? info->swizzle : NULL;
@ -2208,7 +2207,6 @@ util_blitter_blit(struct blitter_context *blitter,
util_blitter_default_dst_texture(&dst_templ, dst, info->dst.level,
info->dst.box.z);
dst_templ.format = info->dst.format;
dst_view = pipe->create_surface(pipe, dst, &dst_templ);
/* Initialize the sampler view. */
util_blitter_default_src_texture(blitter, &src_templ, src, info->src.level);
@ -2222,14 +2220,13 @@ util_blitter_blit(struct blitter_context *blitter,
src_view = pipe->create_sampler_view(pipe, src, &src_templ);
/* Copy. */
util_blitter_blit_generic(blitter, dst_view, &info->dst.box,
util_blitter_blit_generic(blitter, &dst_templ, &info->dst.box,
src_view, &info->src.box, src->width0, src->height0,
info->mask, info->filter,
info->scissor_enable ? &info->scissor : NULL,
info->alpha_blend, info->sample0_only,
info->dst_sample, fs_override);
pipe_surface_reference(&dst_view, NULL);
pipe_sampler_view_reference(&src_view, NULL);
}
@ -2241,7 +2238,7 @@ void util_blitter_generate_mipmap(struct blitter_context *blitter,
{
struct blitter_context_priv *ctx = (struct blitter_context_priv*)blitter;
struct pipe_context *pipe = ctx->base.pipe;
struct pipe_surface dst_templ, *dst_view;
struct pipe_surface dst_templ;
struct pipe_sampler_view src_templ, *src_view;
bool is_depth;
void *sampler_state;
@ -2315,7 +2312,6 @@ void util_blitter_generate_mipmap(struct blitter_context *blitter,
util_blitter_default_dst_texture(&dst_templ, tex, dst_level,
first_layer);
dst_templ.format = format;
dst_view = pipe->create_surface(pipe, tex, &dst_templ);
/* Initialize the sampler view. */
util_blitter_default_src_texture(blitter, &src_templ, tex, src_level);
@ -2324,10 +2320,9 @@ void util_blitter_generate_mipmap(struct blitter_context *blitter,
pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, 1, 0, &src_view);
do_blits(ctx, dst_view, &dstbox, src_view, tex->width0, tex->height0,
do_blits(ctx, &dst_templ, &dstbox, src_view, tex->width0, tex->height0,
&srcbox, is_depth, false, false, 0);
pipe_surface_reference(&dst_view, NULL);
pipe_sampler_view_reference(&src_view, NULL);
}
@ -2372,9 +2367,7 @@ void util_blitter_clear_render_target(struct blitter_context *blitter,
/* set a framebuffer state */
pipe_surface_size(dstsurf, &fb_state.width, &fb_state.height);
fb_state.nr_cbufs = 1;
fb_state.cbufs[0] = dstsurf;
fb_state.zsbuf = NULL;
fb_state.resolve = NULL;
fb_state.cbufs[0] = *dstsurf;
pipe->set_framebuffer_state(pipe, &fb_state);
pipe->set_sample_mask(pipe, ~0);
if (pipe->set_min_samples)
@ -2461,10 +2454,7 @@ void util_blitter_clear_depth_stencil(struct blitter_context *blitter,
/* set a framebuffer state */
pipe_surface_size(dstsurf, &fb_state.width, &fb_state.height);
fb_state.nr_cbufs = 0;
fb_state.cbufs[0] = NULL;
fb_state.zsbuf = dstsurf;
fb_state.resolve = NULL;
fb_state.zsbuf = *dstsurf;
pipe->set_framebuffer_state(pipe, &fb_state);
pipe->set_sample_mask(pipe, ~0);
if (pipe->set_min_samples)
@ -2526,16 +2516,11 @@ void util_blitter_custom_depth_stencil(struct blitter_context *blitter,
/* set a framebuffer state */
pipe_surface_size(zsurf, &fb_state.width, &fb_state.height);
fb_state.nr_cbufs = 1;
if (cbsurf) {
fb_state.cbufs[0] = cbsurf;
fb_state.cbufs[0] = *cbsurf;
fb_state.nr_cbufs = 1;
} else {
fb_state.cbufs[0] = NULL;
fb_state.nr_cbufs = 0;
}
fb_state.zsbuf = zsurf;
fb_state.resolve = NULL;
fb_state.zsbuf = *zsurf;
pipe->set_framebuffer_state(pipe, &fb_state);
pipe->set_sample_mask(pipe, sample_mask);
if (pipe->set_min_samples)
@ -2569,7 +2554,7 @@ void util_blitter_custom_resolve_color(struct blitter_context *blitter,
struct blitter_context_priv *ctx = (struct blitter_context_priv*)blitter;
struct pipe_context *pipe = ctx->base.pipe;
struct pipe_framebuffer_state fb_state = { 0 };
struct pipe_surface *srcsurf, *dstsurf, surf_tmpl;
struct pipe_surface srcsurf = {0}, dstsurf = {0};
util_blitter_set_running_flag(blitter);
blitter_check_saved_vertex_states(ctx);
@ -2584,19 +2569,17 @@ void util_blitter_custom_resolve_color(struct blitter_context *blitter,
if (pipe->set_min_samples)
pipe->set_min_samples(pipe, 1);
memset(&surf_tmpl, 0, sizeof(surf_tmpl));
surf_tmpl.format = format;
surf_tmpl.u.tex.level = dst_level;
surf_tmpl.u.tex.first_layer = dst_layer;
surf_tmpl.u.tex.last_layer = dst_layer;
dstsurf.format = format;
dstsurf.texture = dst;
dstsurf.u.tex.level = dst_level;
dstsurf.u.tex.first_layer = dst_layer;
dstsurf.u.tex.last_layer = dst_layer;
dstsurf = pipe->create_surface(pipe, dst, &surf_tmpl);
surf_tmpl.u.tex.level = 0;
surf_tmpl.u.tex.first_layer = src_layer;
surf_tmpl.u.tex.last_layer = src_layer;
srcsurf = pipe->create_surface(pipe, src, &surf_tmpl);
srcsurf.format = format;
srcsurf.texture = src;
srcsurf.u.tex.level = 0;
srcsurf.u.tex.first_layer = src_layer;
srcsurf.u.tex.last_layer = src_layer;
/* set a framebuffer state */
fb_state.width = src->width0;
@ -2604,8 +2587,6 @@ void util_blitter_custom_resolve_color(struct blitter_context *blitter,
fb_state.nr_cbufs = 2;
fb_state.cbufs[0] = srcsurf;
fb_state.cbufs[1] = dstsurf;
fb_state.zsbuf = NULL;
fb_state.resolve = NULL;
pipe->set_framebuffer_state(pipe, &fb_state);
blitter_set_common_draw_rect_state(ctx, false,
@ -2619,9 +2600,6 @@ void util_blitter_custom_resolve_color(struct blitter_context *blitter,
util_blitter_restore_fragment_states(blitter);
util_blitter_restore_render_cond(blitter);
util_blitter_unset_running_flag(blitter);
pipe_surface_reference(&srcsurf, NULL);
pipe_surface_reference(&dstsurf, NULL);
}
void util_blitter_custom_color(struct blitter_context *blitter,
@ -2652,9 +2630,7 @@ void util_blitter_custom_color(struct blitter_context *blitter,
/* set a framebuffer state */
pipe_surface_size(dstsurf, &fb_state.width, &fb_state.height);
fb_state.nr_cbufs = 1;
fb_state.cbufs[0] = dstsurf;
fb_state.zsbuf = NULL;
fb_state.resolve = NULL;
fb_state.cbufs[0] = *dstsurf;
pipe->set_framebuffer_state(pipe, &fb_state);
pipe->set_sample_mask(pipe, ~0);
if (pipe->set_min_samples)
@ -2718,7 +2694,7 @@ void util_blitter_custom_shader(struct blitter_context *blitter,
fb_state.width = width;
fb_state.height = height;
fb_state.nr_cbufs = 1;
fb_state.cbufs[0] = dstsurf;
fb_state.cbufs[0] = *dstsurf;
fb_state.resolve = NULL;
pipe->set_framebuffer_state(pipe, &fb_state);
pipe->set_sample_mask(pipe, ~0);
@ -2796,9 +2772,8 @@ util_blitter_stencil_fallback(struct blitter_context *blitter,
blitter_disable_render_cond(ctx);
/* Initialize the surface. */
struct pipe_surface *dst_view, dst_templ;
struct pipe_surface dst_templ;
util_blitter_default_dst_texture(&dst_templ, dst, dst_level, dstbox->z);
dst_view = pipe->create_surface(pipe, dst, &dst_templ);
/* Initialize the sampler view. */
struct pipe_sampler_view src_templ, *src_view;
@ -2815,7 +2790,7 @@ util_blitter_stencil_fallback(struct blitter_context *blitter,
struct pipe_framebuffer_state fb_state = { 0 };
fb_state.width = dstbox->x + dstbox->width;
fb_state.height = dstbox->y + dstbox->height;
fb_state.zsbuf = dst_view;
fb_state.zsbuf = dst_templ;
fb_state.resolve = NULL;
pipe->set_framebuffer_state(pipe, &fb_state);
pipe->set_sample_mask(pipe, ~0);
@ -2824,8 +2799,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, pipe_surface_width(dst_view),
pipe_surface_height(dst_view));
blitter_set_dst_dimensions(ctx, pipe_surface_width(&dst_templ),
pipe_surface_height(&dst_templ));
if (scissor) {
pipe->set_scissor_states(pipe, 0, 1, scissor);
@ -2884,6 +2859,5 @@ util_blitter_stencil_fallback(struct blitter_context *blitter,
util_blitter_restore_constant_buffer_state(blitter);
util_blitter_unset_running_flag(blitter);
pipe_surface_reference(&dst_view, NULL);
pipe_sampler_view_reference(&src_view, NULL);
}

View file

@ -211,6 +211,13 @@ util_dump_ptr(FILE *stream, const void *value)
util_dump_member_end(_stream); \
} while(0)
#define util_dump_member_val(_stream, _type, _obj, _member) \
do { \
util_dump_member_begin(_stream, #_member); \
util_dump_##_type(_stream, &(_obj)->_member); \
util_dump_member_end(_stream); \
} while(0)
#define util_dump_arg_array(_stream, _type, _arg, _size) \
do { \
util_dump_arg_begin(_stream, #_arg); \
@ -225,6 +232,13 @@ util_dump_ptr(FILE *stream, const void *value)
util_dump_member_end(_stream); \
} while(0)
#define util_dump_member_array_val(_stream, _type, _obj, _member) \
do { \
util_dump_member_begin(_stream, #_member); \
util_dump_struct_array(_stream, _type, (_obj)->_member, sizeof((_obj)->_member)/sizeof((_obj)->_member[0])); \
util_dump_member_end(_stream); \
} while(0)
/*
@ -664,8 +678,8 @@ util_dump_framebuffer_state(FILE *stream, const struct pipe_framebuffer_state *s
util_dump_member(stream, uint, state, samples);
util_dump_member(stream, uint, state, layers);
util_dump_member(stream, uint, state, nr_cbufs);
util_dump_member_array(stream, ptr, state, cbufs);
util_dump_member(stream, ptr, state, zsbuf);
util_dump_member_array_val(stream, surface, state, cbufs);
util_dump_member_val(stream, ptr, state, zsbuf);
util_dump_struct_end(stream);
}

View file

@ -64,12 +64,11 @@ util_framebuffer_state_equal(const struct pipe_framebuffer_state *dst,
}
for (i = 0; i < src->nr_cbufs; i++) {
if (dst->cbufs[i] != src->cbufs[i]) {
if (!pipe_surface_equal(&dst->cbufs[i], &src->cbufs[i]))
return false;
}
}
if (dst->zsbuf != src->zsbuf) {
if (!pipe_surface_equal(&dst->zsbuf, &src->zsbuf)) {
return false;
}
@ -100,34 +99,25 @@ util_copy_framebuffer_state(struct pipe_framebuffer_state *dst,
dst->samples = src->samples;
dst->layers = src->layers;
for (i = 0; i < src->nr_cbufs; i++)
pipe_surface_reference(&dst->cbufs[i], src->cbufs[i]);
for (i = 0; i < src->nr_cbufs; i++) {
pipe_resource_reference(&dst->cbufs[i].texture, src->cbufs[i].texture);
dst->cbufs[i] = src->cbufs[i];
}
/* Set remaining dest cbuf pointers to NULL */
for ( ; i < ARRAY_SIZE(dst->cbufs); i++)
pipe_surface_reference(&dst->cbufs[i], NULL);
for ( ; i < ARRAY_SIZE(dst->cbufs); i++) {
pipe_resource_reference(&dst->cbufs[i].texture, NULL);
memset(&dst->cbufs[i], 0, sizeof(dst->cbufs[i]));
}
dst->nr_cbufs = src->nr_cbufs;
dst->viewmask = src->viewmask;
pipe_surface_reference(&dst->zsbuf, src->zsbuf);
pipe_resource_reference(&dst->zsbuf.texture, src->zsbuf.texture);
dst->zsbuf = src->zsbuf;
pipe_resource_reference(&dst->resolve, src->resolve);
} else {
dst->width = 0;
dst->height = 0;
dst->samples = 0;
dst->layers = 0;
for (i = 0 ; i < ARRAY_SIZE(dst->cbufs); i++)
pipe_surface_reference(&dst->cbufs[i], NULL);
dst->nr_cbufs = 0;
dst->viewmask = 0;
pipe_surface_reference(&dst->zsbuf, NULL);
pipe_resource_reference(&dst->resolve, NULL);
util_unreference_framebuffer_state(dst);
}
}
@ -137,18 +127,11 @@ util_unreference_framebuffer_state(struct pipe_framebuffer_state *fb)
{
unsigned i;
for (i = 0; i < fb->nr_cbufs; i++) {
pipe_surface_reference(&fb->cbufs[i], NULL);
}
pipe_surface_reference(&fb->zsbuf, NULL);
for (i = 0 ; i < ARRAY_SIZE(fb->cbufs); i++)
pipe_resource_reference(&fb->cbufs[i].texture, NULL);
pipe_resource_reference(&fb->zsbuf.texture, NULL);
pipe_resource_reference(&fb->resolve, NULL);
fb->samples = fb->layers = 0;
fb->width = fb->height = 0;
fb->nr_cbufs = 0;
fb->viewmask = 0;
memset(fb, 0, sizeof(*fb));
}
@ -165,19 +148,19 @@ util_framebuffer_min_size(const struct pipe_framebuffer_state *fb,
unsigned i;
for (i = 0; i < fb->nr_cbufs; i++) {
if (!fb->cbufs[i])
if (!fb->cbufs[i].texture)
continue;
uint16_t width, height;
pipe_surface_size(fb->cbufs[i], &width, &height);
pipe_surface_size(&fb->cbufs[i], &width, &height);
w = MIN2(w, width);
h = MIN2(h, height);
}
if (fb->zsbuf) {
if (fb->zsbuf.texture) {
uint16_t width, height;
pipe_surface_size(fb->zsbuf, &width, &height);
pipe_surface_size(&fb->zsbuf, &width, &height);
w = MIN2(w, width);
h = MIN2(h, height);
}
@ -208,19 +191,19 @@ util_framebuffer_get_num_layers(const struct pipe_framebuffer_state *fb)
* we obtain the number of layers directly from
* the framebuffer state.
*/
if (!(fb->nr_cbufs || fb->zsbuf))
if (!(fb->nr_cbufs || fb->zsbuf.texture))
return fb->layers;
for (i = 0; i < fb->nr_cbufs; i++) {
if (fb->cbufs[i]) {
unsigned num = fb->cbufs[i]->u.tex.last_layer -
fb->cbufs[i]->u.tex.first_layer + 1;
if (fb->cbufs[i].texture) {
unsigned num = fb->cbufs[i].u.tex.last_layer -
fb->cbufs[i].u.tex.first_layer + 1;
num_layers = MAX2(num_layers, num);
}
}
if (fb->zsbuf) {
unsigned num = fb->zsbuf->u.tex.last_layer -
fb->zsbuf->u.tex.first_layer + 1;
if (fb->zsbuf.texture) {
unsigned num = fb->zsbuf.u.tex.last_layer -
fb->zsbuf.u.tex.first_layer + 1;
num_layers = MAX2(num_layers, num);
}
return num_layers;
@ -246,7 +229,7 @@ util_framebuffer_get_num_samples(const struct pipe_framebuffer_state *fb)
* if samples is legitimately not getting set somewhere
* multi-sampling will evidently break.
*/
if (!(fb->nr_cbufs || fb->zsbuf))
if (!(fb->nr_cbufs || fb->zsbuf.texture))
return MAX2(fb->samples, 1);
/**
@ -254,14 +237,14 @@ util_framebuffer_get_num_samples(const struct pipe_framebuffer_state *fb)
* pipe_surface::nr_samples will always be 0.
*/
for (i = 0; i < fb->nr_cbufs; i++) {
if (fb->cbufs[i]) {
return MAX3(1, fb->cbufs[i]->texture->nr_samples,
fb->cbufs[i]->nr_samples);
if (fb->cbufs[i].texture) {
return MAX3(1, fb->cbufs[i].texture->nr_samples,
fb->cbufs[i].nr_samples);
}
}
if (fb->zsbuf) {
return MAX3(1, fb->zsbuf->texture->nr_samples,
fb->zsbuf->nr_samples);
if (fb->zsbuf.texture) {
return MAX3(1, fb->zsbuf.texture->nr_samples,
fb->zsbuf.nr_samples);
}
return MAX2(fb->samples, 1);
@ -296,3 +279,41 @@ util_sample_locations_flip_y(struct pipe_screen *screen, unsigned fb_height,
memcpy(locations, new_locations, grid_width * grid_height * samples);
}
void
util_framebuffer_init(struct pipe_context *pctx, const struct pipe_framebuffer_state *fb, struct pipe_surface **cbufs, struct pipe_surface **zsbuf)
{
if (fb) {
for (unsigned i = 0; i < fb->nr_cbufs; i++) {
if (cbufs[i] && pipe_surface_equal(&fb->cbufs[i], cbufs[i]))
continue;
struct pipe_surface *psurf = fb->cbufs[i].texture ? pctx->create_surface(pctx, fb->cbufs[i].texture, &fb->cbufs[i]) : NULL;
if (cbufs[i])
pipe_surface_unref(pctx, &cbufs[i]);
cbufs[i] = psurf;
}
for (unsigned i = fb->nr_cbufs; i < PIPE_MAX_COLOR_BUFS; i++) {
if (cbufs[i])
pipe_surface_unref(pctx, &cbufs[i]);
cbufs[i] = NULL;
}
if (*zsbuf && pipe_surface_equal(&fb->zsbuf, *zsbuf))
return;
struct pipe_surface *zsurf = fb->zsbuf.texture ? pctx->create_surface(pctx, fb->zsbuf.texture, &fb->zsbuf) : NULL;
if (*zsbuf)
pipe_surface_unref(pctx, zsbuf);
*zsbuf = zsurf;
} else {
for (unsigned i = 0; i < PIPE_MAX_COLOR_BUFS; i++) {
if (cbufs[i])
pipe_surface_unref(pctx, &cbufs[i]);
cbufs[i] = NULL;
}
if (*zsbuf)
pipe_surface_unref(pctx, zsbuf);
*zsbuf = NULL;
}
}

View file

@ -69,6 +69,17 @@ util_sample_locations_flip_y(struct pipe_screen *screen, unsigned fb_height,
unsigned samples, uint8_t *locations);
void
#ifndef _WIN32
__attribute__((deprecated))
#endif
util_framebuffer_init(struct pipe_context *pctx, const struct pipe_framebuffer_state *fb, struct pipe_surface **cbufs, struct pipe_surface **zsbuf);
/* if you see this in your driver stop using it */
#define PIPE_FB_SURFACES \
struct pipe_surface *fb_cbufs[PIPE_MAX_COLOR_BUFS]; \
struct pipe_surface *fb_zsbuf
#ifdef __cplusplus
}
#endif

View file

@ -423,13 +423,13 @@ pipe_surface_size(const struct pipe_surface *ps, uint16_t *width, uint16_t *heig
static inline bool
pipe_surface_equal(const struct pipe_surface *s1, const struct pipe_surface *s2)
{
return s1->texture == s2->texture &&
return !!s1 == !!s2 && s1->texture == s2->texture &&
s1->format == s2->format &&
s1->nr_samples == s2->nr_samples &&
(s1->texture->target != PIPE_BUFFER ||
((s1->texture && s1->texture->target != PIPE_BUFFER) ||
(s1->u.buf.first_element == s2->u.buf.first_element &&
s1->u.buf.last_element == s2->u.buf.last_element)) &&
(s1->texture->target == PIPE_BUFFER ||
((s1->texture && s1->texture->target == PIPE_BUFFER) ||
(s1->u.tex.level == s2->u.tex.level &&
s1->u.tex.first_layer == s2->u.tex.first_layer &&
s1->u.tex.last_layer == s2->u.tex.last_layer));

View file

@ -55,6 +55,7 @@ u_surface_default_template(struct pipe_surface *surf,
memset(surf, 0, sizeof(*surf));
surf->format = texture->format;
surf->texture = (void*)texture;
}

View file

@ -70,19 +70,18 @@ static void
util_set_framebuffer_cb0(struct cso_context *cso, struct pipe_context *ctx,
struct pipe_resource *tex)
{
struct pipe_surface templ = {{0}}, *surf;
struct pipe_surface templ = {{0}};
struct pipe_framebuffer_state fb = {0};
templ.format = tex->format;
surf = ctx->create_surface(ctx, tex, &templ);
templ.texture = tex;
fb.width = tex->width0;
fb.height = tex->height0;
fb.cbufs[0] = surf;
fb.cbufs[0] = templ;
fb.nr_cbufs = 1;
cso_set_framebuffer(cso, &fb);
pipe_surface_reference(&surf, NULL);
}
static void

View file

@ -27,6 +27,7 @@
#include "util/u_threaded_context.h"
#include "util/u_cpu_detect.h"
#include "util/format/u_format.h"
#include "util/u_framebuffer.h"
#include "util/u_inlines.h"
#include "util/u_memory.h"
#include "util/u_upload_mgr.h"
@ -1415,12 +1416,8 @@ tc_call_set_framebuffer_state(struct pipe_context *pipe, void *call)
struct pipe_framebuffer_state *p = &to_call(call, tc_framebuffer)->state;
pipe->set_framebuffer_state(pipe, p);
util_unreference_framebuffer_state(p);
unsigned nr_cbufs = p->nr_cbufs;
for (unsigned i = 0; i < nr_cbufs; i++)
tc_drop_surface_reference(p->cbufs[i]);
tc_drop_surface_reference(p->zsbuf);
tc_drop_resource_reference(p->resolve);
return call_size(tc_framebuffer);
}
@ -1433,12 +1430,7 @@ tc_set_framebuffer_state(struct pipe_context *_pipe,
tc_add_call(tc, TC_CALL_set_framebuffer_state, tc_framebuffer);
unsigned nr_cbufs = fb->nr_cbufs;
p->state.width = fb->width;
p->state.height = fb->height;
p->state.samples = fb->samples;
p->state.layers = fb->layers;
p->state.nr_cbufs = nr_cbufs;
p->state.viewmask = fb->viewmask;
p->state = *fb;
/* when unbinding, mark attachments as used for the current batch */
for (unsigned i = 0; i < tc->nr_cbufs; i++) {
@ -1449,11 +1441,11 @@ tc_set_framebuffer_state(struct pipe_context *_pipe,
tc_set_resource_batch_usage_persistent(tc, tc->fb_resolve, false);
for (unsigned i = 0; i < nr_cbufs; i++) {
p->state.cbufs[i] = NULL;
pipe_surface_reference(&p->state.cbufs[i], fb->cbufs[i]);
/* ref for cmd */
struct pipe_resource *ref = NULL;
pipe_resource_reference(&ref, fb->cbufs[i].texture);
/* full tracking requires storing the fb attachment resources */
if (fb->cbufs[i])
pipe_resource_reference(&tc->fb_resources[i], fb->cbufs[i]->texture);
pipe_resource_reference(&tc->fb_resources[i], fb->cbufs[i].texture);
tc_set_resource_batch_usage_persistent(tc, tc->fb_resources[i], true);
}
tc->nr_cbufs = nr_cbufs;
@ -1469,8 +1461,7 @@ tc_set_framebuffer_state(struct pipe_context *_pipe,
uint8_t zsbuf = tc->renderpass_info_recording->has_draw ?
0 :
tc->renderpass_info_recording->data8[3];
bool zsbuf_changed = tc->fb_resources[PIPE_MAX_COLOR_BUFS] !=
(fb->zsbuf ? fb->zsbuf->texture : NULL);
bool zsbuf_changed = tc->fb_resources[PIPE_MAX_COLOR_BUFS] != fb->zsbuf.texture;
if (tc->seen_fb_state) {
/* this is the end of a renderpass, so increment the renderpass info */
@ -1489,16 +1480,19 @@ tc_set_framebuffer_state(struct pipe_context *_pipe,
/* future fb state changes will increment the index */
tc->seen_fb_state = true;
}
pipe_resource_reference(&tc->fb_resources[PIPE_MAX_COLOR_BUFS],
fb->zsbuf ? fb->zsbuf->texture : NULL);
/* ref for cmd */
struct pipe_resource *zsref = NULL;
pipe_resource_reference(&zsref, fb->zsbuf.texture);
pipe_resource_reference(&tc->fb_resources[PIPE_MAX_COLOR_BUFS], fb->zsbuf.texture);
/* ref for cmd */
struct pipe_resource *rref = NULL;
pipe_resource_reference(&rref, fb->resolve);
pipe_resource_reference(&tc->fb_resolve, fb->resolve);
tc_set_resource_batch_usage_persistent(tc, tc->fb_resources[PIPE_MAX_COLOR_BUFS], true);
tc_set_resource_batch_usage_persistent(tc, tc->fb_resolve, true);
tc->in_renderpass = false;
p->state.zsbuf = NULL;
pipe_surface_reference(&p->state.zsbuf, fb->zsbuf);
p->state.resolve = NULL;
pipe_resource_reference(&p->state.resolve, fb->resolve);
}
struct tc_tess_state {

View file

@ -90,12 +90,12 @@ trace_framebuffer_state(struct u_trace *ut, void *cs, const struct pipe_framebuf
trace_framebuffer(ut, cs, pfb);
for (unsigned i = 0; i < pfb->nr_cbufs; i++) {
if (pfb->cbufs[i]) {
trace_surface(ut, cs, pfb->cbufs[i]);
if (pfb->cbufs[i].texture) {
trace_surface(ut, cs, &pfb->cbufs[i]);
}
}
if (pfb->zsbuf) {
trace_surface(ut, cs, pfb->zsbuf);
if (pfb->zsbuf.texture) {
trace_surface(ut, cs, &pfb->zsbuf);
}
}

View file

@ -443,7 +443,7 @@ vl_bicubic_filter_render(struct vl_bicubic_filter *filter,
fb_state.width = pipe_surface_width(dst);
fb_state.height = pipe_surface_height(dst);
fb_state.nr_cbufs = 1;
fb_state.cbufs[0] = dst;
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,

View file

@ -144,7 +144,7 @@ init_pipe_state(struct vl_compositor *c)
assert(c);
c->fb_state.nr_cbufs = 1;
c->fb_state.zsbuf = NULL;
memset(&c->fb_state.zsbuf, 0, sizeof(c->fb_state.zsbuf));
memset(&sampler, 0, sizeof(sampler));
sampler.wrap_s = PIPE_TEX_WRAP_CLAMP_TO_EDGE;
@ -737,43 +737,43 @@ vl_compositor_yuv_deint_full(struct vl_compositor_state *s,
struct u_rect *dst_rect,
enum vl_compositor_deinterlace deinterlace)
{
struct pipe_surface **dst_surfaces;
struct pipe_surface *dst_surfaces;
dst_surfaces = dst->get_surfaces(dst);
set_yuv_layer(s, c, 0, src, src_rect, NULL, VL_COMPOSITOR_PLANE_Y, deinterlace);
vl_compositor_set_layer_dst_area(s, 0, dst_rect);
vl_compositor_render(s, c, dst_surfaces[0], NULL, false);
vl_compositor_render(s, c, &dst_surfaces[0], NULL, false);
if (dst_surfaces[1]) {
if (dst_surfaces[1].texture) {
bool clear = util_format_get_nr_components(src->buffer_format) == 1;
union pipe_color_union clear_color = { .f = {0.5, 0.5} };
dst_rect->x0 = util_format_get_plane_width(dst->buffer_format, 1, dst_rect->x0);
dst_rect->x1 = util_format_get_plane_width(dst->buffer_format, 1, dst_rect->x1);
dst_rect->y0 = util_format_get_plane_height(dst->buffer_format, 1, dst_rect->y0);
dst_rect->y1 = util_format_get_plane_height(dst->buffer_format, 1, dst_rect->y1);
set_yuv_layer(s, c, 0, src, src_rect, NULL, dst_surfaces[2] ? VL_COMPOSITOR_PLANE_U :
set_yuv_layer(s, c, 0, src, src_rect, NULL, dst_surfaces[2].texture ? VL_COMPOSITOR_PLANE_U :
VL_COMPOSITOR_PLANE_UV, deinterlace);
vl_compositor_set_layer_dst_area(s, 0, dst_rect);
if (clear) {
struct u_rect clear_rect = *dst_rect;
s->used_layers = 0;
vl_compositor_set_clear_color(s, &clear_color);
vl_compositor_render(s, c, dst_surfaces[1], &clear_rect, true);
vl_compositor_render(s, c, &dst_surfaces[1], &clear_rect, true);
} else {
vl_compositor_render(s, c, dst_surfaces[1], NULL, false);
vl_compositor_render(s, c, &dst_surfaces[1], NULL, false);
}
if (dst_surfaces[2]) {
if (dst_surfaces[2].texture) {
set_yuv_layer(s, c, 0, src, src_rect, NULL, VL_COMPOSITOR_PLANE_V, deinterlace);
vl_compositor_set_layer_dst_area(s, 0, dst_rect);
if (clear) {
struct u_rect clear_rect = *dst_rect;
s->used_layers = 0;
vl_compositor_set_clear_color(s, &clear_color);
vl_compositor_render(s, c, dst_surfaces[2], &clear_rect, true);
vl_compositor_render(s, c, &dst_surfaces[2], &clear_rect, true);
} else {
vl_compositor_render(s, c, dst_surfaces[2], NULL, false);
vl_compositor_render(s, c, &dst_surfaces[2], NULL, false);
}
}
}
@ -789,7 +789,7 @@ vl_compositor_convert_rgb_to_yuv(struct vl_compositor_state *s,
struct u_rect *dst_rect)
{
struct pipe_sampler_view *sv, sv_templ;
struct pipe_surface **dst_surfaces;
struct pipe_surface *dst_surfaces;
dst_surfaces = dst->get_surfaces(dst);
@ -799,22 +799,22 @@ vl_compositor_convert_rgb_to_yuv(struct vl_compositor_state *s,
set_rgb_to_yuv_layer(s, c, 0, sv, src_rect, NULL, VL_COMPOSITOR_PLANE_Y);
vl_compositor_set_layer_dst_area(s, 0, dst_rect);
vl_compositor_render(s, c, dst_surfaces[0], NULL, false);
vl_compositor_render(s, c, &dst_surfaces[0], NULL, false);
if (dst_surfaces[1]) {
if (dst_surfaces[1].texture) {
dst_rect->x0 = util_format_get_plane_width(dst->buffer_format, 1, dst_rect->x0);
dst_rect->x1 = util_format_get_plane_width(dst->buffer_format, 1, dst_rect->x1);
dst_rect->y0 = util_format_get_plane_height(dst->buffer_format, 1, dst_rect->y0);
dst_rect->y1 = util_format_get_plane_height(dst->buffer_format, 1, dst_rect->y1);
set_rgb_to_yuv_layer(s, c, 0, sv, src_rect, NULL, dst_surfaces[2] ? VL_COMPOSITOR_PLANE_U :
set_rgb_to_yuv_layer(s, c, 0, sv, src_rect, NULL, dst_surfaces[2].texture ? VL_COMPOSITOR_PLANE_U :
VL_COMPOSITOR_PLANE_UV);
vl_compositor_set_layer_dst_area(s, 0, dst_rect);
vl_compositor_render(s, c, dst_surfaces[1], NULL, false);
vl_compositor_render(s, c, &dst_surfaces[1], NULL, false);
if (dst_surfaces[2]) {
if (dst_surfaces[2].texture) {
set_rgb_to_yuv_layer(s, c, 0, sv, src_rect, NULL, VL_COMPOSITOR_PLANE_V);
vl_compositor_set_layer_dst_area(s, 0, dst_rect);
vl_compositor_render(s, c, dst_surfaces[2], NULL, false);
vl_compositor_render(s, c, &dst_surfaces[2], NULL, false);
}
}

View file

@ -611,9 +611,9 @@ cs_launch(struct vl_compositor *c,
/* Bind the image */
struct pipe_image_view image = {0};
image.resource = c->fb_state.cbufs[0]->texture;
image.resource = c->fb_state.cbufs[0].texture;
image.shader_access = image.access = PIPE_IMAGE_ACCESS_READ_WRITE;
image.format = c->fb_state.cbufs[0]->texture->format;
image.format = c->fb_state.cbufs[0].texture->format;
ctx->set_shader_images(c->pipe, PIPE_SHADER_COMPUTE, 0, 1, 0, &image);
@ -892,7 +892,7 @@ vl_compositor_cs_render(struct vl_compositor_state *s,
assert(dst_surface);
pipe_surface_size(dst_surface, &c->fb_state.width, &c->fb_state.height);
c->fb_state.cbufs[0] = dst_surface;
c->fb_state.cbufs[0] = *dst_surface;
if (!s->scissor_valid) {
s->scissor.minx = 0;

View file

@ -714,7 +714,7 @@ vl_compositor_gfx_render(struct vl_compositor_state *s,
assert(dst_surface);
pipe_surface_size(dst_surface, &c->fb_state.width, &c->fb_state.height);
c->fb_state.cbufs[0] = dst_surface;
c->fb_state.cbufs[0] = *dst_surface;
if (!s->scissor_valid) {
s->scissor.minx = 0;

View file

@ -471,7 +471,7 @@ vl_deint_filter_render(struct vl_deint_filter *filter,
struct pipe_sampler_view **prev_sv;
struct pipe_sampler_view **next_sv;
struct pipe_sampler_view *sampler_views[4];
struct pipe_surface **dst_surfaces;
struct pipe_surface *dst_surfaces;
const unsigned *plane_order;
int i;
unsigned j;
@ -513,8 +513,8 @@ vl_deint_filter_render(struct vl_deint_filter *filter,
/* process each plane separately */
for (i = 0, j = 0; i < VL_NUM_COMPONENTS; ++i) {
struct pipe_surface *blit_surf = dst_surfaces[field];
struct pipe_surface *dst_surf = dst_surfaces[1 - field];
struct pipe_surface *blit_surf = &dst_surfaces[field];
struct pipe_surface *dst_surf = &dst_surfaces[1 - field];
int k = plane_order[i];
/* bind blend state for this component in the plane */
@ -535,14 +535,14 @@ vl_deint_filter_render(struct vl_deint_filter *filter,
0, 4, 0, sampler_views);
/* blit current field */
fb_state.cbufs[0] = blit_surf;
fb_state.cbufs[0] = *blit_surf;
filter->pipe->bind_fs_state(filter->pipe, field ? filter->fs_copy_bottom : filter->fs_copy_top);
filter->pipe->set_framebuffer_state(filter->pipe, &fb_state);
filter->pipe->set_viewport_states(filter->pipe, 0, 1, &viewport);
util_draw_arrays(filter->pipe, MESA_PRIM_QUADS, 0, 4);
/* blit or interpolate other field */
fb_state.cbufs[0] = dst_surf;
fb_state.cbufs[0] = *dst_surf;
filter->pipe->set_framebuffer_state(filter->pipe, &fb_state);
if (i > 0 && filter->skip_chroma) {
util_draw_arrays(filter->pipe, MESA_PRIM_QUADS, 0, 4);

View file

@ -204,7 +204,7 @@ vl_deint_filter_cs_render(struct vl_deint_filter *filter,
struct pipe_sampler_view **prev_sv;
struct pipe_sampler_view **next_sv;
struct pipe_sampler_view *sampler_views[4];
struct pipe_surface **dst_surfaces;
struct pipe_surface *dst_surfaces;
/* Set up destination and source */
dst_surfaces = filter->video_buffer->get_surfaces(filter->video_buffer);
@ -217,7 +217,7 @@ vl_deint_filter_cs_render(struct vl_deint_filter *filter,
0, 4, filter->sampler);
for (unsigned i = 0; i < 2; i++) {
struct pipe_surface *dst = dst_surfaces[i];
struct pipe_surface *dst = &dst_surfaces[i];
/* Update sampler view sources */
sampler_views[0] = prevprev_sv[i];

View file

@ -600,10 +600,11 @@ init_source(struct vl_idct *idct, struct vl_idct_buffer *buffer)
buffer->fb_state_mismatch.nr_cbufs = 1;
memset(&surf_templ, 0, sizeof(surf_templ));
surf_templ.texture = tex;
surf_templ.format = tex->format;
surf_templ.u.tex.first_layer = 0;
surf_templ.u.tex.last_layer = 0;
buffer->fb_state_mismatch.cbufs[0] = idct->pipe->create_surface(idct->pipe, tex, &surf_templ);
buffer->fb_state_mismatch.cbufs[0] = surf_templ;
buffer->viewport_mismatch.scale[0] = tex->width0;
buffer->viewport_mismatch.scale[1] = tex->height0;
@ -621,7 +622,7 @@ cleanup_source(struct vl_idct_buffer *buffer)
{
assert(buffer);
pipe_surface_reference(&buffer->fb_state_mismatch.cbufs[0], NULL);
memset(&buffer->fb_state_mismatch.cbufs[0], 0, sizeof(struct pipe_surface));
pipe_sampler_view_reference(&buffer->sampler_views.individual.source, NULL);
}
@ -643,13 +644,10 @@ init_intermediate(struct vl_idct *idct, struct vl_idct_buffer *buffer)
for(i = 0; i < idct->nr_of_render_targets; ++i) {
memset(&surf_templ, 0, sizeof(surf_templ));
surf_templ.format = tex->format;
surf_templ.texture = tex;
surf_templ.u.tex.first_layer = i;
surf_templ.u.tex.last_layer = i;
buffer->fb_state.cbufs[i] = idct->pipe->create_surface(
idct->pipe, tex, &surf_templ);
if (!buffer->fb_state.cbufs[i])
goto error_surfaces;
buffer->fb_state.cbufs[i] = surf_templ;
}
buffer->viewport.scale[0] = tex->width0;
@ -661,23 +659,14 @@ init_intermediate(struct vl_idct *idct, struct vl_idct_buffer *buffer)
buffer->viewport.swizzle_w = PIPE_VIEWPORT_SWIZZLE_POSITIVE_W;
return true;
error_surfaces:
for(i = 0; i < idct->nr_of_render_targets; ++i)
pipe_surface_reference(&buffer->fb_state.cbufs[i], NULL);
return false;
}
static void
cleanup_intermediate(struct vl_idct_buffer *buffer)
{
unsigned i;
assert(buffer);
for(i = 0; i < PIPE_MAX_COLOR_BUFS; ++i)
pipe_surface_reference(&buffer->fb_state.cbufs[i], NULL);
memset(buffer->fb_state.cbufs, 0, sizeof(buffer->fb_state.cbufs));
pipe_sampler_view_reference(&buffer->sampler_views.individual.intermediate, NULL);
}

View file

@ -295,7 +295,7 @@ vl_matrix_filter_render(struct vl_matrix_filter *filter,
fb_state.width = pipe_surface_width(dst);
fb_state.height = pipe_surface_height(dst);
fb_state.nr_cbufs = 1;
fb_state.cbufs[0] = dst;
fb_state.cbufs[0] = *dst;
filter->pipe->bind_rasterizer_state(filter->pipe, filter->rs_state);
filter->pipe->bind_blend_state(filter->pipe, filter->blend);

View file

@ -568,7 +568,7 @@ vl_mc_init_buffer(struct vl_mc *renderer, struct vl_mc_buffer *buffer)
buffer->viewport.swizzle_w = PIPE_VIEWPORT_SWIZZLE_POSITIVE_W;
buffer->fb_state.nr_cbufs = 1;
buffer->fb_state.zsbuf = NULL;
memset(&buffer->fb_state.zsbuf, 0, sizeof(buffer->fb_state.zsbuf));
return true;
}
@ -591,7 +591,7 @@ vl_mc_set_surface(struct vl_mc_buffer *buffer, struct pipe_surface *surface)
buffer->fb_state.width = pipe_surface_width(surface);
buffer->fb_state.height = pipe_surface_height(surface);
buffer->fb_state.cbufs[0] = surface;
buffer->fb_state.cbufs[0] = *surface;
}
static void

View file

@ -413,7 +413,7 @@ vl_median_filter_render(struct vl_median_filter *filter,
fb_state.width = pipe_surface_width(dst);
fb_state.height = pipe_surface_height(dst);
fb_state.nr_cbufs = 1;
fb_state.cbufs[0] = dst;
fb_state.cbufs[0] = *dst;
filter->pipe->bind_rasterizer_state(filter->pipe, filter->rs_state);
filter->pipe->bind_blend_state(filter->pipe, filter->blend);

View file

@ -122,7 +122,7 @@ get_video_buffer_private(struct vl_mpeg12_decoder *dec, struct pipe_video_buffer
struct pipe_context *pipe = dec->context;
struct video_buffer_private *priv;
struct pipe_sampler_view **sv;
struct pipe_surface **surf;
struct pipe_surface *surf;
unsigned i;
priv = vl_video_buffer_get_associated_data(buf, &dec->base);
@ -140,9 +140,7 @@ get_video_buffer_private(struct vl_mpeg12_decoder *dec, struct pipe_video_buffer
priv->sampler_view_planes[i] = pipe->create_sampler_view(pipe, sv[i]->texture, sv[i]);
surf = buf->get_surfaces(buf);
for (i = 0; i < VL_MAX_SURFACES; ++i)
if (surf[i])
priv->surfaces[i] = pipe->create_surface(pipe, surf[i]->texture, surf[i]);
memcpy(priv->surfaces, surf, sizeof(priv->surfaces));
vl_video_buffer_set_associated_data(buf, &dec->base, priv, destroy_video_buffer_private);
@ -166,7 +164,7 @@ init_zscan_buffer(struct vl_mpeg12_decoder *dec, struct vl_mpeg12_buffer *buffer
{
struct pipe_resource *res, res_tmpl;
struct pipe_sampler_view sv_tmpl;
struct pipe_surface **destination;
struct pipe_surface *destination;
unsigned i;
@ -200,12 +198,9 @@ init_zscan_buffer(struct vl_mpeg12_decoder *dec, struct vl_mpeg12_buffer *buffer
else
destination = dec->mc_source->get_surfaces(dec->mc_source);
if (!destination)
goto error_surface;
for (i = 0; i < VL_NUM_COMPONENTS; ++i)
if (!vl_zscan_init_buffer(i == 0 ? &dec->zscan_y : &dec->zscan_c,
&buffer->zscan[i], buffer->zscan_source, destination[i]))
&buffer->zscan[i], buffer->zscan_source, &destination[i]))
goto error_plane;
return true;
@ -214,7 +209,6 @@ error_plane:
for (; i > 0; --i)
vl_zscan_cleanup_buffer(&buffer->zscan[i - 1]);
error_surface:
error_sampler:
pipe_sampler_view_reference(&buffer->zscan_source, NULL);

View file

@ -219,9 +219,6 @@ vl_video_buffer_destroy(struct pipe_video_buffer *buffer)
pipe_resource_reference(&buf->resources[i], NULL);
}
for (i = 0; i < VL_MAX_SURFACES; ++i)
pipe_surface_reference(&buf->surfaces[i], NULL);
vl_video_buffer_set_associated_data(buffer, NULL, NULL, NULL);
FREE(buffer);
@ -339,46 +336,35 @@ error:
return NULL;
}
static struct pipe_surface **
vl_video_buffer_surfaces(struct pipe_video_buffer *buffer)
static struct pipe_surface *
vl_video_buffer_get_surfaces(struct pipe_video_buffer *buffer)
{
struct vl_video_buffer *buf = (struct vl_video_buffer *)buffer;
struct pipe_surface surf_templ;
struct pipe_context *pipe;
return &buf->surfaces[0];
}
static void
vl_video_buffer_surfaces(struct vl_video_buffer *buf)
{
unsigned i, j, array_size, surf;
assert(buf);
pipe = buf->base.context;
array_size = buffer->interlaced ? 2 : 1;
array_size = buf->base.interlaced ? 2 : 1;
for (i = 0, surf = 0; i < VL_NUM_COMPONENTS; ++i) {
for (j = 0; j < array_size; ++j, ++surf) {
assert(surf < VL_MAX_SURFACES);
if (!buf->resources[i]) {
pipe_surface_reference(&buf->surfaces[surf], NULL);
memset(&buf->surfaces[surf], 0, sizeof(buf->surfaces[0]));
continue;
}
if (!buf->surfaces[surf]) {
memset(&surf_templ, 0, sizeof(surf_templ));
surf_templ.format = vl_video_buffer_surface_format(buf->resources[i]->format);
surf_templ.u.tex.first_layer = surf_templ.u.tex.last_layer = j;
buf->surfaces[surf] = pipe->create_surface(pipe, buf->resources[i], &surf_templ);
if (!buf->surfaces[surf])
goto error;
}
buf->surfaces[surf].texture = buf->resources[i];
buf->surfaces[surf].format = vl_video_buffer_surface_format(buf->resources[i]->format);
buf->surfaces[surf].u.tex.first_layer = buf->surfaces[surf].u.tex.last_layer = j;
}
}
return buf->surfaces;
error:
for (i = 0; i < VL_MAX_SURFACES; ++i )
pipe_surface_reference(&buf->surfaces[i], NULL);
return NULL;
}
struct pipe_video_buffer *
@ -495,7 +481,7 @@ vl_video_buffer_create_ex2(struct pipe_context *pipe,
buffer->base.get_resources = vl_video_buffer_resources;
buffer->base.get_sampler_view_planes = vl_video_buffer_sampler_view_planes;
buffer->base.get_sampler_view_components = vl_video_buffer_sampler_view_components;
buffer->base.get_surfaces = vl_video_buffer_surfaces;
buffer->base.get_surfaces = vl_video_buffer_get_surfaces;
for (i = 0; i < num_planes; ++i)
buffer->resources[i] = resources[i];
@ -506,6 +492,8 @@ vl_video_buffer_create_ex2(struct pipe_context *pipe,
pipe_resource_reference(&res, NULL);
}
vl_video_buffer_surfaces(buffer);
return &buffer->base;
}

View file

@ -45,7 +45,7 @@ struct vl_video_buffer
struct pipe_sampler_view *sampler_view_planes[VL_NUM_COMPONENTS];
struct pipe_sampler_view *sampler_view_components[VL_NUM_COMPONENTS];
unsigned num_sampler_view_components;
struct pipe_surface *surfaces[VL_MAX_SURFACES];
struct pipe_surface surfaces[VL_MAX_SURFACES];
};
static inline void

View file

@ -438,7 +438,7 @@ vl_zscan_init_buffer(struct vl_zscan *zscan, struct vl_zscan_buffer *buffer,
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);
buffer->fb_state.cbufs[0] = *dst;
memset(&res_tmpl, 0, sizeof(res_tmpl));
res_tmpl.target = PIPE_TEXTURE_3D;
@ -473,7 +473,7 @@ vl_zscan_cleanup_buffer(struct vl_zscan_buffer *buffer)
pipe_sampler_view_reference(&buffer->src, NULL);
pipe_sampler_view_reference(&buffer->layout, NULL);
pipe_sampler_view_reference(&buffer->quant, NULL);
pipe_surface_reference(&buffer->fb_state.cbufs[0], NULL);
memset(&buffer->fb_state.cbufs[0], 0, sizeof(struct pipe_surface));
}
void

View file

@ -831,12 +831,12 @@ agx_batch_submit(struct agx_context *ctx, struct agx_batch *batch,
struct pipe_framebuffer_state *fb = &batch->key;
for (unsigned i = 0; i < fb->nr_cbufs; ++i) {
if (fb->cbufs[i])
asahi_add_attachment(&att, agx_resource(fb->cbufs[i]->texture));
if (fb->cbufs[i].texture)
asahi_add_attachment(&att, agx_resource(fb->cbufs[i].texture));
}
if (fb->zsbuf) {
struct agx_resource *rsrc = agx_resource(fb->zsbuf->texture);
if (fb->zsbuf.texture) {
struct agx_resource *rsrc = agx_resource(fb->zsbuf.texture);
asahi_add_attachment(&att, rsrc);
if (rsrc->separate_stencil)

View file

@ -1089,7 +1089,7 @@ agx_clear(struct pipe_context *pctx, unsigned buffers,
/* Clear colour must be clamped to properly handle signed ints. */
union pipe_color_union clamped =
util_clamp_color(batch->key.cbufs[rt]->format, color);
util_clamp_color(batch->key.cbufs[rt].format, color);
batch->uploaded_clear_color[rt] = agx_pool_upload_aligned(
&batch->pool, clamped.f, sizeof(clamped.f), 16);
@ -1241,16 +1241,16 @@ agx_cmdbuf(struct agx_device *dev, struct drm_asahi_cmd_render *c,
c->isp_bgobjvals = 0x300;
struct agx_resource *zres = NULL, *sres = NULL;
struct pipe_surface *zsbuf = framebuffer->zsbuf;
struct pipe_surface *zsbuf = &framebuffer->zsbuf;
if (framebuffer->zsbuf) {
if (framebuffer->zsbuf.texture) {
agx_pack(&c->isp_zls_pixels, CR_ISP_ZLS_PIXELS, cfg) {
cfg.x = c->width_px;
cfg.y = c->height_px;
}
}
if (zsbuf) {
if (zsbuf->texture) {
struct agx_resource *zsres = agx_resource(zsbuf->texture);
const struct util_format_description *desc =
util_format_description(zsres->layout.format);
@ -1571,10 +1571,10 @@ agx_flush_render(struct agx_context *ctx, struct agx_batch *batch,
agx_tilebuffer_spills(&batch->tilebuffer_layout);
for (unsigned i = 0; i < batch->key.nr_cbufs; ++i) {
struct pipe_surface *surf = batch->key.cbufs[i];
const struct pipe_surface *surf = &batch->key.cbufs[i];
clear_pipeline_textures |=
surf && surf->texture && !(batch->clear & (PIPE_CLEAR_COLOR0 << i));
surf->texture && !(batch->clear & (PIPE_CLEAR_COLOR0 << i));
}
/* Scissor and depth bias arrays are staged to dynamic arrays on the CPU. At
@ -1694,13 +1694,13 @@ agx_invalidate_resource(struct pipe_context *pctx,
struct agx_batch *batch = agx_get_batch(ctx);
/* Handle the glInvalidateFramebuffer case */
if (batch->key.zsbuf && batch->key.zsbuf->texture == resource)
if (batch->key.zsbuf.texture == resource)
batch->resolve &= ~PIPE_CLEAR_DEPTHSTENCIL;
for (unsigned i = 0; i < batch->key.nr_cbufs; ++i) {
struct pipe_surface *surf = batch->key.cbufs[i];
const struct pipe_surface *surf = &batch->key.cbufs[i];
if (surf && surf->texture == resource)
if (surf->texture == resource)
batch->resolve &= ~(PIPE_CLEAR_COLOR0 << i);
}
}

View file

@ -75,7 +75,7 @@ void
agx_legalize_compression(struct agx_context *ctx, struct agx_resource *rsrc,
enum pipe_format format)
{
if (!ail_is_view_compatible(&rsrc->layout, format)) {
if (rsrc && !ail_is_view_compatible(&rsrc->layout, format)) {
agx_decompress(ctx, rsrc, "Incompatible formats");
}
}
@ -861,9 +861,6 @@ static struct pipe_surface *
agx_create_surface(struct pipe_context *ctx, struct pipe_resource *texture,
const struct pipe_surface *surf_tmpl)
{
agx_legalize_compression(agx_context(ctx), agx_resource(texture),
surf_tmpl->format);
struct pipe_surface *surface = CALLOC_STRUCT(pipe_surface);
if (!surface)
@ -1101,6 +1098,16 @@ agx_set_framebuffer_state(struct pipe_context *pctx,
return;
util_copy_framebuffer_state(&ctx->framebuffer, state);
for (unsigned i = 0; i < state->nr_cbufs; ++i) {
agx_legalize_compression(ctx,
agx_resource(ctx->framebuffer.cbufs[i].texture),
ctx->framebuffer.cbufs[i].format);
}
agx_legalize_compression(ctx, agx_resource(ctx->framebuffer.zsbuf.texture),
ctx->framebuffer.zsbuf.format);
ctx->batch = NULL;
agx_dirty_all(ctx);
}
@ -1111,7 +1118,7 @@ agx_set_framebuffer_state(struct pipe_context *pctx,
* constructs the internal pipe_image_view used.
*/
static struct pipe_image_view
image_view_for_surface(struct pipe_surface *surf)
image_view_for_surface(const struct pipe_surface *surf)
{
return (struct pipe_image_view){
.resource = surf->texture,
@ -1128,7 +1135,7 @@ image_view_for_surface(struct pipe_surface *surf)
/* Similarly, to read render targets, surfaces are bound as textures */
static struct pipe_sampler_view
sampler_view_for_surface(struct pipe_surface *surf)
sampler_view_for_surface(const struct pipe_surface *surf)
{
bool layered = surf->u.tex.last_layer > surf->u.tex.first_layer;
@ -2348,9 +2355,7 @@ agx_update_fs(struct agx_batch *batch)
key.nr_samples = nr_samples;
for (unsigned i = 0; i < batch->key.nr_cbufs; ++i) {
struct pipe_surface *surf = batch->key.cbufs[i];
key.rt_formats[i] = surf ? surf->format : PIPE_FORMAT_NONE;
key.rt_formats[i] = batch->key.cbufs[i].format;
}
}
@ -2387,9 +2392,7 @@ agx_update_fs(struct agx_batch *batch)
};
for (unsigned i = 0; i < PIPE_MAX_COLOR_BUFS; ++i) {
struct pipe_surface *surf = batch->key.cbufs[i];
link_key.epilog.fs.rt_formats[i] = surf ? surf->format : PIPE_FORMAT_NONE;
link_key.epilog.fs.rt_formats[i] = batch->key.cbufs[i].format;
link_key.epilog.fs.remap[i] =
link_key.epilog.fs.link.broadcast_rt0 ? 0 : i;
}
@ -2736,8 +2739,8 @@ agx_upload_spilled_rt_descriptors(struct agx_texture_packed *out,
struct agx_texture_packed *texture = out + (2 * rt);
struct agx_pbe_packed *pbe = (struct agx_pbe_packed *)(texture + 1);
struct pipe_surface *surf = batch->key.cbufs[rt];
if (!surf)
const struct pipe_surface *surf = &batch->key.cbufs[rt];
if (!surf->texture)
continue;
struct agx_resource *rsrc = agx_resource(surf->texture);
@ -3124,9 +3127,9 @@ agx_build_bg_eot(struct agx_batch *batch, bool store, bool partial_render)
!store;
for (unsigned rt = 0; rt < PIPE_MAX_COLOR_BUFS; ++rt) {
struct pipe_surface *surf = batch->key.cbufs[rt];
const struct pipe_surface *surf = &batch->key.cbufs[rt];
if (surf == NULL)
if (surf->texture == NULL)
continue;
if (store) {
@ -3178,8 +3181,8 @@ agx_build_bg_eot(struct agx_batch *batch, bool store, bool partial_render)
struct agx_ptr texture =
agx_pool_alloc_aligned(&batch->pool, AGX_TEXTURE_LENGTH, 64);
struct pipe_surface *surf = batch->key.cbufs[rt];
assert(surf != NULL && "cannot load nonexistent attachment");
const struct pipe_surface *surf = &batch->key.cbufs[rt];
assert(surf->texture != NULL && "cannot load nonexistent attachment");
struct agx_resource *rsrc = agx_resource(surf->texture);
struct pipe_sampler_view sampler_view = sampler_view_for_surface(surf);
@ -3200,7 +3203,7 @@ agx_build_bg_eot(struct agx_batch *batch, bool store, bool partial_render)
uniforms = MAX2(uniforms, 4 + (8 * rt) + 8);
} else if (key.op[rt] == AGX_EOT_STORE) {
struct pipe_image_view view =
image_view_for_surface(batch->key.cbufs[rt]);
image_view_for_surface(&batch->key.cbufs[rt]);
struct agx_ptr pbe =
agx_pool_alloc_aligned(&batch->pool, AGX_PBE_LENGTH, 256);
@ -3403,9 +3406,7 @@ agx_batch_init_state(struct agx_batch *batch)
/* Choose a tilebuffer layout given the framebuffer key */
enum pipe_format formats[PIPE_MAX_COLOR_BUFS] = {0};
for (unsigned i = 0; i < batch->key.nr_cbufs; ++i) {
struct pipe_surface *surf = batch->key.cbufs[i];
if (surf)
formats[i] = surf->format;
formats[i] = batch->key.cbufs[i].format;
}
batch->tilebuffer_layout = agx_build_tilebuffer_layout(
@ -3424,8 +3425,8 @@ agx_batch_init_state(struct agx_batch *batch)
if (!batch->tilebuffer_layout.spilled[i])
continue;
struct pipe_surface *surf = batch->key.cbufs[i];
if (!surf)
struct pipe_surface *surf = &batch->key.cbufs[i];
if (!surf->texture)
continue;
struct agx_resource *rsrc = agx_resource(surf->texture);
@ -3443,9 +3444,9 @@ agx_batch_init_state(struct agx_batch *batch)
}
}
if (batch->key.zsbuf) {
unsigned level = batch->key.zsbuf->u.tex.level;
struct agx_resource *rsrc = agx_resource(batch->key.zsbuf->texture);
if (batch->key.zsbuf.texture) {
unsigned level = batch->key.zsbuf.u.tex.level;
struct agx_resource *rsrc = agx_resource(batch->key.zsbuf.texture);
agx_batch_writes(batch, rsrc, level);
@ -3454,9 +3455,9 @@ agx_batch_init_state(struct agx_batch *batch)
}
for (unsigned i = 0; i < batch->key.nr_cbufs; ++i) {
if (batch->key.cbufs[i]) {
struct agx_resource *rsrc = agx_resource(batch->key.cbufs[i]->texture);
unsigned level = batch->key.cbufs[i]->u.tex.level;
if (batch->key.cbufs[i].texture) {
struct agx_resource *rsrc = agx_resource(batch->key.cbufs[i].texture);
unsigned level = batch->key.cbufs[i].u.tex.level;
if (agx_resource_valid(rsrc, level))
batch->load |= PIPE_CLEAR_COLOR0 << i;
@ -4834,7 +4835,7 @@ agx_legalize_feedback_loop_surf(struct agx_context *ctx,
struct agx_resource *rsrc,
struct pipe_surface *surf, unsigned bit)
{
if (!surf || agx_resource(surf->texture) != rsrc || !rsrc->layout.compressed)
if (agx_resource(surf->texture) != rsrc || !rsrc->layout.compressed)
return;
/* Decompress if we can and shadow if we can't. */
@ -4882,11 +4883,11 @@ agx_legalize_feedback_loops(struct agx_context *ctx)
for (unsigned cb = 0; cb < ctx->framebuffer.nr_cbufs; ++cb) {
agx_legalize_feedback_loop_surf(
ctx, rsrc, ctx->framebuffer.cbufs[cb], PIPE_CLEAR_COLOR0 << i);
ctx, rsrc, &ctx->framebuffer.cbufs[cb], PIPE_CLEAR_COLOR0 << i);
}
/* TODO: Separate stencil? */
agx_legalize_feedback_loop_surf(ctx, rsrc, ctx->framebuffer.zsbuf,
agx_legalize_feedback_loop_surf(ctx, rsrc, &ctx->framebuffer.zsbuf,
PIPE_CLEAR_DEPTH);
}
}

View file

@ -643,7 +643,7 @@ crocus_clear(struct pipe_context *ctx,
util_framebuffer_get_num_layers(cso_fb),
buffers & PIPE_CLEAR_DEPTHSTENCIL, p_color, depth, stencil, false);
} else {
struct pipe_surface *psurf = cso_fb->zsbuf;
const struct pipe_surface *psurf = &cso_fb->zsbuf;
box.depth = psurf->u.tex.last_layer - psurf->u.tex.first_layer + 1;
box.z = psurf->u.tex.first_layer;
@ -661,7 +661,7 @@ crocus_clear(struct pipe_context *ctx,
for (unsigned i = 0; i < cso_fb->nr_cbufs; i++) {
if (buffers & (PIPE_CLEAR_COLOR0 << i)) {
struct pipe_surface *psurf = cso_fb->cbufs[i];
struct pipe_surface *psurf = ice->state.fb_cbufs[i];
struct crocus_surface *isurf = (void *) psurf;
box.depth = psurf->u.tex.last_layer - psurf->u.tex.first_layer + 1,
box.z = psurf->u.tex.first_layer,

View file

@ -201,6 +201,9 @@ crocus_destroy_context(struct pipe_context *ctx)
util_blitter_destroy(ice->blitter);
screen->vtbl.destroy_state(ice);
util_framebuffer_init(ctx, NULL, ice->state.fb_cbufs, &ice->state.fb_zsbuf);
util_unreference_framebuffer_state(&ice->state.framebuffer);
for (unsigned i = 0; i < ARRAY_SIZE(ice->shaders.scratch_bos); i++) {
for (unsigned j = 0; j < ARRAY_SIZE(ice->shaders.scratch_bos[i]); j++)
crocus_bo_unreference(ice->shaders.scratch_bos[i][j]);

View file

@ -35,6 +35,7 @@
#include "crocus_resource.h"
#include "crocus_screen.h"
#include "util/u_blitter.h"
#include "util/u_framebuffer.h"
struct crocus_bo;
struct crocus_context;
@ -571,6 +572,7 @@ struct crocus_context {
struct pipe_viewport_state viewports[CROCUS_MAX_VIEWPORTS];
struct pipe_scissor_state scissors[CROCUS_MAX_VIEWPORTS];
struct pipe_stencil_ref stencil_ref;
PIPE_FB_SURFACES; //STOP USING THIS
struct pipe_framebuffer_state framebuffer;
struct pipe_clip_state clip_planes;

View file

@ -2137,8 +2137,8 @@ crocus_update_compiled_clip(struct crocus_context *ice)
if (offset_back || offset_front) {
double mrd = 0.0;
if (ice->state.framebuffer.zsbuf)
mrd = util_get_depth_format_mrd(util_format_description(ice->state.framebuffer.zsbuf->format));
if (ice->state.framebuffer.zsbuf.texture)
mrd = util_get_depth_format_mrd(util_format_description(ice->state.framebuffer.zsbuf.format));
key.offset_units = rs_state->offset_units * mrd * 2;
key.offset_factor = rs_state->offset_scale * mrd;
key.offset_clamp = rs_state->offset_clamp * mrd;

View file

@ -62,7 +62,7 @@ disable_rb_aux_buffer(struct crocus_context *ice,
return false;
for (unsigned i = 0; i < cso_fb->nr_cbufs; i++) {
struct crocus_surface *surf = (void *) cso_fb->cbufs[i];
struct crocus_surface *surf = (void *) ice->state.fb_cbufs[i];
if (!surf)
continue;
@ -227,7 +227,7 @@ crocus_predraw_resolve_framebuffer(struct crocus_context *ice,
const nir_shader *nir = ish->nir;
if (ice->state.dirty & CROCUS_DIRTY_DEPTH_BUFFER) {
struct pipe_surface *zs_surf = cso_fb->zsbuf;
struct pipe_surface *zs_surf = ice->state.fb_zsbuf;
if (zs_surf) {
struct crocus_resource *z_res, *s_res;
@ -255,9 +255,9 @@ crocus_predraw_resolve_framebuffer(struct crocus_context *ice,
if (nir->info.outputs_read != 0) {
for (unsigned i = 0; i < cso_fb->nr_cbufs; i++) {
if (cso_fb->cbufs[i]) {
struct crocus_surface *surf = (void *) cso_fb->cbufs[i];
struct crocus_resource *res = (void *) cso_fb->cbufs[i]->texture;
if (ice->state.fb_cbufs[i]) {
struct crocus_surface *surf = (void *) ice->state.fb_cbufs[i];
struct crocus_resource *res = (void *) ice->state.fb_cbufs[i]->texture;
crocus_resource_prepare_texture(ice, res, surf->view.format,
surf->view.base_level, 1,
@ -269,7 +269,7 @@ crocus_predraw_resolve_framebuffer(struct crocus_context *ice,
if (ice->state.stage_dirty & CROCUS_STAGE_DIRTY_BINDINGS_FS) {
for (unsigned i = 0; i < cso_fb->nr_cbufs; i++) {
struct crocus_surface *surf = (void *) cso_fb->cbufs[i];
struct crocus_surface *surf = (void *) ice->state.fb_cbufs[i];
if (!surf)
continue;
@ -325,7 +325,7 @@ crocus_postdraw_update_resolve_tracking(struct crocus_context *ice,
ice->state.dirty & (CROCUS_DIRTY_DEPTH_BUFFER |
CROCUS_DIRTY_GEN6_WM_DEPTH_STENCIL);
struct pipe_surface *zs_surf = cso_fb->zsbuf;
struct pipe_surface *zs_surf = ice->state.fb_zsbuf;
if (zs_surf) {
struct crocus_resource *z_res, *s_res;
crocus_get_depth_stencil_resources(devinfo, zs_surf->texture, &z_res, &s_res);
@ -363,7 +363,7 @@ crocus_postdraw_update_resolve_tracking(struct crocus_context *ice,
ice->state.stage_dirty & CROCUS_STAGE_DIRTY_BINDINGS_FS;
for (unsigned i = 0; i < cso_fb->nr_cbufs; i++) {
struct crocus_surface *surf = (void *) cso_fb->cbufs[i];
struct crocus_surface *surf = (void *) ice->state.fb_cbufs[i];
if (!surf)
continue;

View file

@ -1508,8 +1508,8 @@ can_emit_logic_op(struct crocus_context *ice)
/* all pre gen8 have logicop restricted to unorm */
enum pipe_format pformat = PIPE_FORMAT_NONE;
for (unsigned i = 0; i < ice->state.framebuffer.nr_cbufs; i++) {
if (ice->state.framebuffer.cbufs[i]) {
pformat = ice->state.framebuffer.cbufs[i]->format;
if (ice->state.framebuffer.cbufs[i].texture) {
pformat = ice->state.framebuffer.cbufs[i].format;
break;
}
}
@ -1859,17 +1859,17 @@ want_pma_fix(struct crocus_context *ice)
* meaning the PMA signal will already be disabled).
*/
if (!cso_fb->zsbuf)
if (!cso_fb->zsbuf.texture)
return false;
struct crocus_resource *zres, *sres;
crocus_get_depth_stencil_resources(devinfo,
cso_fb->zsbuf->texture, &zres, &sres);
cso_fb->zsbuf.texture, &zres, &sres);
/* 3DSTATE_DEPTH_BUFFER::SURFACE_TYPE != NULL &&
* 3DSTATE_DEPTH_BUFFER::HIZ Enable &&
*/
if (!zres || !crocus_resource_level_has_hiz(zres, cso_fb->zsbuf->u.tex.level))
if (!zres || !crocus_resource_level_has_hiz(zres, cso_fb->zsbuf.u.tex.level))
return false;
/* 3DSTATE_WM::EDSC_Mode != EDSC_PREPS */
@ -3424,27 +3424,28 @@ crocus_set_framebuffer_state(struct pipe_context *ctx,
#endif
}
if (cso->zsbuf || state->zsbuf) {
if (cso->zsbuf.texture || state->zsbuf.texture) {
ice->state.dirty |= CROCUS_DIRTY_DEPTH_BUFFER;
/* update SF's depth buffer format */
if (GFX_VER == 7 && cso->zsbuf)
if (GFX_VER == 7 && cso->zsbuf.texture)
ice->state.dirty |= CROCUS_DIRTY_RASTER;
}
/* wm thread dispatch enable */
ice->state.dirty |= CROCUS_DIRTY_WM;
util_framebuffer_init(ctx, state, ice->state.fb_cbufs, &ice->state.fb_zsbuf);
util_copy_framebuffer_state(cso, state);
cso->samples = samples;
cso->layers = layers;
if (cso->zsbuf) {
if (cso->zsbuf.texture) {
struct crocus_resource *zres;
struct crocus_resource *stencil_res;
enum isl_aux_usage aux_usage = ISL_AUX_USAGE_NONE;
crocus_get_depth_stencil_resources(devinfo, cso->zsbuf->texture, &zres,
crocus_get_depth_stencil_resources(devinfo, cso->zsbuf.texture, &zres,
&stencil_res);
if (zres && crocus_resource_level_has_hiz(zres, cso->zsbuf->u.tex.level)) {
if (zres && crocus_resource_level_has_hiz(zres, cso->zsbuf.u.tex.level)) {
aux_usage = zres->aux.usage;
}
ice->state.hiz_usage = aux_usage;
@ -4773,7 +4774,7 @@ crocus_populate_fs_key(const struct crocus_context *ice,
if (info->outputs_written & BITFIELD64_BIT(FRAG_RESULT_DEPTH))
lookup |= ELK_WM_IZ_PS_COMPUTES_DEPTH_BIT;
if (fb->zsbuf && zsa->cso.depth_enabled) {
if (fb->zsbuf.texture && zsa->cso.depth_enabled) {
lookup |= ELK_WM_IZ_DEPTH_TEST_ENABLE_BIT;
if (zsa->cso.depth_writemask)
@ -4942,11 +4943,11 @@ emit_null_fb_surface(struct crocus_batch *batch,
level = 0;
layer = 0;
if (cso->nr_cbufs == 0 && cso->zsbuf) {
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;
if (cso->nr_cbufs == 0 && ice->state.fb_zsbuf) {
width = ((struct crocus_surface*)ice->state.fb_zsbuf)->surf.logical_level0_px.width;
height = ((struct crocus_surface*)ice->state.fb_zsbuf)->surf.logical_level0_px.height;
level = cso->zsbuf.u.tex.level;
layer = cso->zsbuf.u.tex.first_layer;
}
emit_sized_null_surface(batch, width, height,
layers, level, layer,
@ -5390,9 +5391,9 @@ crocus_populate_binding_table(struct crocus_context *ice,
/* Gen4/5 can't handle blending off when a dual src blend wm is enabled. */
blend_enable = rt->blend_enable || wm_prog_data->dual_src_blend;
#endif
if (cso_fb->cbufs[i]) {
if (cso_fb->cbufs[i].texture) {
surf_offsets[s] = emit_surface(batch,
(struct crocus_surface *)cso_fb->cbufs[i],
(struct crocus_surface *)ice->state.fb_cbufs[i],
ice->state.draw_aux_usage[i],
blend_enable,
write_disables);
@ -5408,9 +5409,9 @@ crocus_populate_binding_table(struct crocus_context *ice,
foreach_surface_used(i, CROCUS_SURFACE_GROUP_RENDER_TARGET_READ) {
struct pipe_framebuffer_state *cso_fb = &ice->state.framebuffer;
if (cso_fb->cbufs[i]) {
if (cso_fb->cbufs[i].texture) {
surf_offsets[s++] = emit_rt_surface(batch,
(struct crocus_surface *)cso_fb->cbufs[i],
(struct crocus_surface *)ice->state.fb_cbufs[i],
ice->state.draw_aux_usage[i]);
}
}
@ -7107,10 +7108,10 @@ crocus_upload_dirty_render_state(struct crocus_context *ice,
sf.MultisampleRasterizationMode = MSRASTMODE_ON_PATTERN;
#endif
#if GFX_VER == 7
if (ice->state.framebuffer.zsbuf) {
if (ice->state.framebuffer.zsbuf.texture) {
struct crocus_resource *zres, *sres;
crocus_get_depth_stencil_resources(&batch->screen->devinfo,
ice->state.framebuffer.zsbuf->texture,
ice->state.framebuffer.zsbuf.texture,
&zres, &sres);
/* ANV thinks that the stencil-ness doesn't matter, this is just
* about handling polygon offset scaling.
@ -7443,15 +7444,15 @@ crocus_upload_dirty_render_state(struct crocus_context *ice,
.mocs = crocus_mocs(NULL, isl_dev),
};
if (cso->zsbuf) {
crocus_get_depth_stencil_resources(&batch->screen->devinfo, cso->zsbuf->texture, &zres, &sres);
struct crocus_surface *zsbuf = (struct crocus_surface *)cso->zsbuf;
if (cso->zsbuf.texture) {
crocus_get_depth_stencil_resources(&batch->screen->devinfo, cso->zsbuf.texture, &zres, &sres);
struct crocus_surface *zsbuf = (struct crocus_surface *)ice->state.fb_zsbuf;
if (zsbuf->align_res) {
zres = (struct crocus_resource *)zsbuf->align_res;
}
view.base_level = cso->zsbuf->u.tex.level;
view.base_array_layer = cso->zsbuf->u.tex.first_layer;
view.array_len = cso->zsbuf->u.tex.last_layer - cso->zsbuf->u.tex.first_layer + 1;
view.base_level = cso->zsbuf.u.tex.level;
view.base_array_layer = cso->zsbuf.u.tex.first_layer;
view.array_len = cso->zsbuf.u.tex.last_layer - cso->zsbuf.u.tex.first_layer + 1;
if (zres) {
view.usage |= ISL_SURF_USAGE_DEPTH_BIT;

View file

@ -491,11 +491,6 @@ resolve_stencil_to_temp(struct d3d12_context *ctx,
struct pipe_surface dst_tmpl;
util_blitter_default_dst_texture(&dst_tmpl, tmp, 0, 0);
dst_tmpl.format = tmp->format;
struct pipe_surface *dst_surf = pctx->create_surface(pctx, tmp, &dst_tmpl);
if (!dst_surf) {
debug_printf("D3D12: failed to create stencil-resolve dst-surface\n");
return NULL;
}
struct pipe_sampler_view src_templ, *src_view;
util_blitter_default_src_texture(ctx->blitter, &src_templ,
@ -508,13 +503,12 @@ resolve_stencil_to_temp(struct d3d12_context *ctx,
util_blit_save_state(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),
util_blitter_custom_shader(ctx->blitter, &dst_tmpl,
(uint16_t)pipe_surface_width(&dst_tmpl),
(uint16_t)pipe_surface_height(&dst_tmpl),
get_stencil_resolve_vs(ctx),
get_stencil_resolve_fs(ctx, info->src.box.height == info->dst.box.height));
util_blitter_restore_textures(ctx->blitter);
pipe_surface_reference(&dst_surf, NULL);
pipe_sampler_view_reference(&src_view, NULL);
return tmp;
}
@ -603,7 +597,6 @@ static void
blit_replicate_stencil(struct d3d12_context *ctx,
const struct pipe_blit_info *info)
{
struct pipe_context *pctx = &ctx->base;
assert(info->mask & PIPE_MASK_S);
if (D3D12_DEBUG_BLIT & d3d12_debug)
@ -616,13 +609,12 @@ blit_replicate_stencil(struct d3d12_context *ctx,
util_blit(ctx, &new_info);
}
struct pipe_surface *dst_view, dst_templ;
struct pipe_surface dst_templ;
util_blitter_default_dst_texture(&dst_templ, info->dst.resource,
info->dst.level, info->dst.box.z);
dst_view = pctx->create_surface(pctx, info->dst.resource, &dst_templ);
util_blit_save_state(ctx);
util_blitter_clear_depth_stencil(ctx->blitter, dst_view, PIPE_CLEAR_STENCIL,
util_blitter_clear_depth_stencil(ctx->blitter, &dst_templ, PIPE_CLEAR_STENCIL,
0, 0, info->dst.box.x, info->dst.box.y,
info->dst.box.width, info->dst.box.height);
util_blit_save_state(ctx);
@ -633,8 +625,6 @@ blit_replicate_stencil(struct d3d12_context *ctx,
info->src.level,
&info->src.box,
info->scissor_enable ? &info->scissor : NULL);
pipe_surface_unref(pctx, &dst_view);
}
void

View file

@ -956,7 +956,7 @@ d3d12_fill_shader_key(struct d3d12_selection_context *sel_ctx,
if (sel_ctx->ctx->gfx_pipeline_state.blend &&
sel_ctx->ctx->gfx_pipeline_state.blend->desc.RenderTarget[0].LogicOpEnable &&
!sel_ctx->ctx->gfx_pipeline_state.has_float_rtv) {
key->fs.cast_to_uint = util_format_is_unorm(sel_ctx->ctx->fb.cbufs[0]->format);
key->fs.cast_to_uint = util_format_is_unorm(sel_ctx->ctx->fb.cbufs[0].format);
key->fs.cast_to_int = !key->fs.cast_to_uint;
}
if (sel_ctx->needs_point_sprite_lowering) {

View file

@ -36,6 +36,7 @@
#include "pipe/p_state.h"
#include "util/list.h"
#include "util/slab.h"
#include "util/u_framebuffer.h"
#include "util/u_suballoc.h"
#include "util/u_threaded_context.h"
@ -205,6 +206,7 @@ struct d3d12_context {
struct hash_table *compute_transform_cache;
struct pipe_constant_buffer cbufs[PIPE_SHADER_TYPES][PIPE_MAX_CONSTANT_BUFFERS];
PIPE_FB_SURFACES; //STOP USING THIS
struct pipe_framebuffer_state fb;
struct pipe_vertex_buffer vbs[PIPE_MAX_ATTRIBS];
D3D12_VERTEX_BUFFER_VIEW vbvs[PIPE_MAX_ATTRIBS];

View file

@ -104,6 +104,7 @@ d3d12_context_destroy(struct pipe_context *pctx)
if (ctx->timestamp_query)
pctx->destroy_query(pctx, ctx->timestamp_query);
util_framebuffer_init(pctx, NULL, ctx->fb_cbufs, &ctx->fb_zsbuf);
util_unreference_framebuffer_state(&ctx->fb);
d3d12_compute_pipeline_state_cache_destroy(ctx);
d3d12_root_signature_cache_destroy(ctx);

View file

@ -1418,26 +1418,27 @@ d3d12_set_framebuffer_state(struct pipe_context *pctx,
struct d3d12_context *ctx = d3d12_context(pctx);
int samples = -1;
bool prev_cbufs_or_zsbuf = ctx->fb.nr_cbufs || ctx->fb.zsbuf;
bool prev_cbufs_or_zsbuf = ctx->fb.nr_cbufs || ctx->fb.zsbuf.texture;
util_framebuffer_init(pctx, state, ctx->fb_cbufs, &ctx->fb_zsbuf);
util_copy_framebuffer_state(&d3d12_context(pctx)->fb, state);
bool new_cbufs_or_zsbuf = ctx->fb.nr_cbufs || ctx->fb.zsbuf;
bool new_cbufs_or_zsbuf = ctx->fb.nr_cbufs || ctx->fb.zsbuf.texture;
ctx->gfx_pipeline_state.num_cbufs = state->nr_cbufs;
ctx->gfx_pipeline_state.has_float_rtv = false;
for (int i = 0; i < state->nr_cbufs; ++i) {
if (state->cbufs[i]) {
if (util_format_is_float(state->cbufs[i]->format))
if (state->cbufs[i].texture) {
if (util_format_is_float(state->cbufs[i].format))
ctx->gfx_pipeline_state.has_float_rtv = true;
ctx->gfx_pipeline_state.rtv_formats[i] = d3d12_get_format(state->cbufs[i]->format);
samples = MAX2(samples, (int)state->cbufs[i]->texture->nr_samples);
ctx->gfx_pipeline_state.rtv_formats[i] = d3d12_get_format(state->cbufs[i].format);
samples = MAX2(samples, (int)state->cbufs[i].texture->nr_samples);
} else {
ctx->gfx_pipeline_state.rtv_formats[i] = DXGI_FORMAT_UNKNOWN;
}
}
if (state->zsbuf) {
ctx->gfx_pipeline_state.dsv_format = d3d12_get_resource_rt_format(state->zsbuf->format);
samples = MAX2(samples, (int)ctx->fb.zsbuf->texture->nr_samples);
if (state->zsbuf.texture) {
ctx->gfx_pipeline_state.dsv_format = d3d12_get_resource_rt_format(state->zsbuf.format);
samples = MAX2(samples, (int)ctx->fb.zsbuf.texture->nr_samples);
} else
ctx->gfx_pipeline_state.dsv_format = DXGI_FORMAT_UNKNOWN;
@ -1922,7 +1923,6 @@ d3d12_clear_render_target(struct pipe_context *pctx,
bool render_condition_enabled)
{
struct d3d12_context *ctx = d3d12_context(pctx);
struct d3d12_surface *surf = d3d12_surface(psurf);
if (!render_condition_enabled && ctx->current_predication)
ctx->cmdlist->SetPredication(NULL, 0, D3D12_PREDICATION_OP_EQUAL_ZERO);
@ -1987,6 +1987,9 @@ d3d12_clear_render_target(struct pipe_context *pctx,
}
util_blitter_clear_render_target(ctx->blitter, psurf, &local_color, dstx, dsty, width, height);
} else {
struct pipe_surface *tmpsurf = pctx->create_surface(pctx, psurf->texture, psurf);
struct d3d12_surface *surf = d3d12_surface(tmpsurf);
if (!(util_format_colormask(util_format_description(psurf->format)) &
PIPE_MASK_A))
clear_color[3] = 1.0f;
@ -1996,9 +1999,10 @@ d3d12_clear_render_target(struct pipe_context *pctx,
(int)dsty + (int)height };
ctx->cmdlist->ClearRenderTargetView(surf->desc_handle.cpu_handle,
clear_color, 1, &rect);
d3d12_batch_reference_surface_texture(d3d12_current_batch(ctx), surf);
pipe_surface_unref(pctx, &tmpsurf);
}
d3d12_batch_reference_surface_texture(d3d12_current_batch(ctx), surf);
if (!render_condition_enabled && ctx->current_predication) {
d3d12_enable_predication(ctx);
@ -2016,7 +2020,8 @@ d3d12_clear_depth_stencil(struct pipe_context *pctx,
bool render_condition_enabled)
{
struct d3d12_context *ctx = d3d12_context(pctx);
struct d3d12_surface *surf = d3d12_surface(psurf);
struct pipe_surface *tmpsurf = pctx->create_surface(pctx, psurf->texture, psurf);
struct d3d12_surface *surf = d3d12_surface(tmpsurf);
if (!render_condition_enabled && ctx->current_predication)
ctx->cmdlist->SetPredication(NULL, 0, D3D12_PREDICATION_OP_EQUAL_ZERO);
@ -2044,6 +2049,7 @@ d3d12_clear_depth_stencil(struct pipe_context *pctx,
if (!render_condition_enabled && ctx->current_predication) {
d3d12_enable_predication(ctx);
}
pipe_surface_unref(pctx, &tmpsurf);
}
static void
@ -2058,7 +2064,7 @@ d3d12_clear(struct pipe_context *pctx,
if (buffers & PIPE_CLEAR_COLOR) {
for (int i = 0; i < ctx->fb.nr_cbufs; ++i) {
if (buffers & (PIPE_CLEAR_COLOR0 << i)) {
struct pipe_surface *psurf = ctx->fb.cbufs[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,
@ -2068,8 +2074,8 @@ d3d12_clear(struct pipe_context *pctx,
}
}
if (buffers & PIPE_CLEAR_DEPTHSTENCIL && ctx->fb.zsbuf) {
struct pipe_surface *psurf = ctx->fb.zsbuf;
if (buffers & PIPE_CLEAR_DEPTHSTENCIL && ctx->fb.zsbuf.texture) {
struct pipe_surface *psurf = &ctx->fb.zsbuf;
uint16_t width, height;
pipe_surface_size(psurf, &width, &height);
d3d12_clear_depth_stencil(pctx, psurf,

View file

@ -939,8 +939,8 @@ d3d12_draw_vbo(struct pipe_context *pctx,
}
for (int i = 0; i < ctx->fb.nr_cbufs; ++i) {
if (ctx->fb.cbufs[i]) {
struct d3d12_surface *surface = d3d12_surface(ctx->fb.cbufs[i]);
if (ctx->fb_cbufs[i]) {
struct d3d12_surface *surface = d3d12_surface(ctx->fb_cbufs[i]);
conversion_modes[i] = d3d12_surface_update_pre_draw(pctx, surface, d3d12_rtv_format(ctx, i));
if (conversion_modes[i] != D3D12_SURFACE_CONVERSION_NONE)
ctx->cmdlist_dirty |= D3D12_DIRTY_FRAMEBUFFER;
@ -1076,7 +1076,7 @@ d3d12_draw_vbo(struct pipe_context *pctx,
viewports[i].MinDepth = 0.0f;
viewports[i].MaxDepth = 1.0f;
}
if (ctx->fb.nr_cbufs == 0 && !ctx->fb.zsbuf) {
if (ctx->fb.nr_cbufs == 0 && !ctx->fb.zsbuf.texture) {
viewports[i].TopLeftX = MAX2(0.0f, viewports[i].TopLeftX);
viewports[i].TopLeftY = MAX2(0.0f, viewports[i].TopLeftY);
viewports[i].Width = MIN2(ctx->fb.width, viewports[i].Width);
@ -1158,15 +1158,15 @@ d3d12_draw_vbo(struct pipe_context *pctx,
D3D12_CPU_DESCRIPTOR_HANDLE render_targets[PIPE_MAX_COLOR_BUFS] = {};
D3D12_CPU_DESCRIPTOR_HANDLE *depth_desc = NULL, tmp_desc;
for (int i = 0; i < ctx->fb.nr_cbufs; ++i) {
if (ctx->fb.cbufs[i]) {
struct d3d12_surface *surface = d3d12_surface(ctx->fb.cbufs[i]);
if (ctx->fb_cbufs[i]) {
struct d3d12_surface *surface = d3d12_surface(ctx->fb_cbufs[i]);
render_targets[i] = d3d12_surface_get_handle(surface, conversion_modes[i]);
d3d12_batch_reference_surface_texture(batch, surface);
} else
render_targets[i] = screen->null_rtv.cpu_handle;
}
if (ctx->fb.zsbuf) {
struct d3d12_surface *surface = d3d12_surface(ctx->fb.zsbuf);
if (ctx->fb_zsbuf) {
struct d3d12_surface *surface = d3d12_surface(ctx->fb_zsbuf);
tmp_desc = surface->desc_handle.cpu_handle;
d3d12_batch_reference_surface_texture(batch, surface);
depth_desc = &tmp_desc;
@ -1199,7 +1199,7 @@ d3d12_draw_vbo(struct pipe_context *pctx,
ctx->cmdlist->SOSetTargets(0, 4, so_buffer_views);
for (int i = 0; i < ctx->fb.nr_cbufs; ++i) {
struct pipe_surface *psurf = ctx->fb.cbufs[i];
struct pipe_surface *psurf = ctx->fb_cbufs[i];
if (!psurf)
continue;
@ -1208,8 +1208,8 @@ d3d12_draw_vbo(struct pipe_context *pctx,
transition_surface_subresources_state(ctx, psurf, pres,
D3D12_RESOURCE_STATE_RENDER_TARGET);
}
if (ctx->fb.zsbuf) {
struct pipe_surface *psurf = ctx->fb.zsbuf;
if (ctx->fb_zsbuf) {
struct pipe_surface *psurf = ctx->fb_zsbuf;
transition_surface_subresources_state(ctx, psurf, psurf->texture,
D3D12_RESOURCE_STATE_DEPTH_WRITE);
}
@ -1272,8 +1272,8 @@ d3d12_draw_vbo(struct pipe_context *pctx,
ctx->shader_dirty[i] = 0;
for (int i = 0; i < ctx->fb.nr_cbufs; ++i) {
if (ctx->fb.cbufs[i]) {
struct d3d12_surface *surface = d3d12_surface(ctx->fb.cbufs[i]);
if (ctx->fb_cbufs[i]) {
struct d3d12_surface *surface = d3d12_surface(ctx->fb_cbufs[i]);
d3d12_surface_update_post_draw(pctx, surface, conversion_modes[i]);
}
}

View file

@ -34,6 +34,7 @@
#include "util/u_video.h"
#include "vl/vl_video_buffer.h"
#include "util/u_sampler.h"
#include "util/u_surface.h"
#include "frontend/winsys_handle.h"
#include "d3d12_format.h"
#include "d3d12_screen.h"
@ -234,12 +235,6 @@ d3d12_video_buffer_destroy(struct pipe_video_buffer *buffer)
pD3D12VideoBuffer->base.associated_data = nullptr;
}
for (uint i = 0; i < pD3D12VideoBuffer->surfaces.size(); ++i) {
if (pD3D12VideoBuffer->surfaces[i] != NULL) {
pipe_surface_reference(&pD3D12VideoBuffer->surfaces[i], NULL);
}
}
for (uint i = 0; i < pD3D12VideoBuffer->sampler_view_planes.size(); ++i) {
if (pD3D12VideoBuffer->sampler_view_planes[i] != NULL) {
pipe_sampler_view_reference(&pD3D12VideoBuffer->sampler_view_planes[i], NULL);
@ -265,13 +260,12 @@ d3d12_video_buffer_destroy_associated_data(void *associated_data)
/**
* get an individual surfaces for each plane
*/
struct pipe_surface **
struct pipe_surface *
d3d12_video_buffer_get_surfaces(struct pipe_video_buffer *buffer)
{
assert(buffer);
struct d3d12_video_buffer *pD3D12VideoBuffer = (struct d3d12_video_buffer *) buffer;
struct pipe_context * pipe = pD3D12VideoBuffer->base.context;
struct pipe_surface surface_template = {};
// DPB buffers don't support views
if ((pD3D12VideoBuffer->base.bind & PIPE_BIND_VIDEO_DECODE_DPB) ||
@ -281,11 +275,6 @@ d3d12_video_buffer_get_surfaces(struct pipe_video_buffer *buffer)
if (!pipe->create_surface)
return nullptr;
// Some video frameworks iterate over [0..VL_MAX_SURFACES) and ignore the nullptr entries
// So we have to null initialize the other surfaces not used from [num_planes..VL_MAX_SURFACES)
// Like in src/gallium/frontends/va/surface.c
pD3D12VideoBuffer->surfaces.resize(VL_MAX_SURFACES, nullptr);
// pCurPlaneResource refers to the planar resource, not the overall resource.
// in d3d12_resource this is handled by having a linked list of planes with
// d3dRes->base.next ptr to next plane resource
@ -293,28 +282,24 @@ d3d12_video_buffer_get_surfaces(struct pipe_video_buffer *buffer)
struct pipe_resource *pCurPlaneResource = &pD3D12VideoBuffer->texture->base.b;
for (uint PlaneSlice = 0; PlaneSlice < pD3D12VideoBuffer->num_planes; ++PlaneSlice) {
if (!pD3D12VideoBuffer->surfaces[PlaneSlice]) {
memset(&surface_template, 0, sizeof(surface_template));
surface_template.format =
util_format_get_plane_format(pD3D12VideoBuffer->texture->overall_format, PlaneSlice);
struct pipe_surface surface_template = {};
surface_template.format = util_format_get_plane_format(pD3D12VideoBuffer->texture->overall_format, PlaneSlice);
surface_template.texture = pCurPlaneResource;
pD3D12VideoBuffer->surfaces[PlaneSlice] =
pipe->create_surface(pipe, pCurPlaneResource, &surface_template);
if (!pipe->screen->is_format_supported(pipe->screen, surface_template.format, PIPE_TEXTURE_2D,
0, 0, PIPE_BIND_RENDER_TARGET))
goto error;
if (!pD3D12VideoBuffer->surfaces[PlaneSlice]) {
goto error;
}
}
pD3D12VideoBuffer->surfaces[PlaneSlice] = surface_template;
pCurPlaneResource = pCurPlaneResource->next;
}
return pD3D12VideoBuffer->surfaces.data();
for (uint i = pD3D12VideoBuffer->num_planes; i < VL_MAX_SURFACES; i++)
memset(&pD3D12VideoBuffer->surfaces[i], 0, sizeof(struct pipe_surface));
return pD3D12VideoBuffer->surfaces;
error:
for (uint PlaneSlice = 0; PlaneSlice < pD3D12VideoBuffer->num_planes; ++PlaneSlice) {
pipe_surface_reference(&pD3D12VideoBuffer->surfaces[PlaneSlice], NULL);
}
return nullptr;
}

View file

@ -27,6 +27,7 @@
#include "pipe/p_context.h"
#include "pipe/p_video_codec.h"
#include "vl/vl_defines.h"
#include <vector>
#include "d3d12_video_types.h"
@ -77,7 +78,7 @@ d3d12_video_buffer_get_sampler_view_components(struct pipe_video_buffer *buffer)
/**
* get an individual surfaces for each plane
*/
struct pipe_surface **
struct pipe_surface *
d3d12_video_buffer_get_surfaces(struct pipe_video_buffer *buffer);
/*
@ -94,7 +95,7 @@ struct d3d12_video_buffer
pipe_video_buffer base;
struct d3d12_resource * texture = nullptr;
uint num_planes = 0;
std::vector<pipe_surface *> surfaces;
struct pipe_surface surfaces[VL_MAX_SURFACES];
std::vector<pipe_sampler_view *> sampler_view_planes;
std::vector<pipe_sampler_view *> sampler_view_components;

View file

@ -122,7 +122,7 @@ etna_update_blend(struct etna_context *ctx)
unsigned current_rt = 0;
for (unsigned i = 0; i < pfb->nr_cbufs; i++) {
if (!pfb->cbufs[i])
if (!pfb->cbufs[i].texture)
continue;
const struct pipe_rt_blend_state *rt;
@ -133,7 +133,7 @@ etna_update_blend(struct etna_context *ctx)
else
rt = &pblend->rt[0];
if (translate_pe_format_rb_swap(pfb->cbufs[i]->format)) {
if (translate_pe_format_rb_swap(pfb->cbufs[i].format)) {
colormask = rt->colormask & (PIPE_MASK_A | PIPE_MASK_G);
if (rt->colormask & PIPE_MASK_R)
colormask |= PIPE_MASK_B;
@ -147,7 +147,7 @@ etna_update_blend(struct etna_context *ctx)
* - The color mask covers all channels of the render target
* - No blending or logicop is used
*/
const struct util_format_description *desc = util_format_description(pfb->cbufs[i]->format);
const struct util_format_description *desc = util_format_description(pfb->cbufs[i].format);
bool full_overwrite = (blend->rt[i].fo_allowed &&
util_format_colormask_full(desc, colormask));
@ -203,10 +203,10 @@ etna_update_blend_color(struct etna_context *ctx)
unsigned rt = 0;
for (unsigned i = 0; i < fb->nr_cbufs; i++) {
if (!fb->cbufs[i])
if (!fb->cbufs[i].texture)
continue;
bool rb_swap = translate_pe_format_rb_swap(fb->cbufs[i]->format);
bool rb_swap = translate_pe_format_rb_swap(fb->cbufs[i].format);
if (rt == 0) {
cs->PE_ALPHA_BLEND_COLOR =

View file

@ -225,7 +225,7 @@ etna_blit_clear_color_blt(struct pipe_context *pctx, unsigned idx,
const union pipe_color_union *color)
{
struct etna_context *ctx = etna_context(pctx);
struct pipe_surface *dst = ctx->framebuffer_s.cbufs[idx];
struct pipe_surface *dst = ctx->fb_cbufs[idx];
struct etna_surface *surf = etna_surface(dst);
uint64_t new_clear_value = etna_clear_blit_pack_rgba(surf->base.format, color);
int msaa_xscale = 1, msaa_yscale = 1;
@ -385,7 +385,7 @@ etna_clear_blt(struct pipe_context *pctx, unsigned buffers, const struct pipe_sc
if (buffers & PIPE_CLEAR_COLOR) {
for (int idx = 0; idx < ctx->framebuffer_s.nr_cbufs; ++idx) {
struct etna_surface *surf = etna_surface(ctx->framebuffer_s.cbufs[idx]);
struct etna_surface *surf = etna_surface(ctx->fb_cbufs[idx]);
if (!surf)
continue;
@ -397,8 +397,8 @@ etna_clear_blt(struct pipe_context *pctx, unsigned buffers, const struct pipe_sc
}
}
if ((buffers & PIPE_CLEAR_DEPTHSTENCIL) && ctx->framebuffer_s.zsbuf != NULL)
etna_blit_clear_zs_blt(pctx, ctx->framebuffer_s.zsbuf, buffers, depth, stencil);
if ((buffers & PIPE_CLEAR_DEPTHSTENCIL) && ctx->framebuffer_s.zsbuf.texture != NULL)
etna_blit_clear_zs_blt(pctx, ctx->fb_zsbuf, buffers, depth, stencil);
etna_stall(ctx->stream, SYNC_RECIPIENT_RA, SYNC_RECIPIENT_BLT);

View file

@ -114,6 +114,7 @@ etna_context_destroy(struct pipe_context *pctx)
if (ctx->flush_resources)
_mesa_set_destroy(ctx->flush_resources, NULL);
util_framebuffer_init(pctx, NULL, ctx->fb_cbufs, &ctx->fb_zsbuf);
util_copy_framebuffer_state(&ctx->framebuffer_s, NULL);
if (ctx->blitter)
@ -306,8 +307,8 @@ etna_draw_vbo(struct pipe_context *pctx, const struct pipe_draw_info *info,
key.flatshade = ctx->rasterizer->flatshade;
for (i = 0; i < pfb->nr_cbufs; i++) {
if (pfb->cbufs[i])
key.frag_rb_swap |= !!translate_pe_format_rb_swap(pfb->cbufs[i]->format) << i;
if (pfb->cbufs[i].texture)
key.frag_rb_swap |= !!translate_pe_format_rb_swap(pfb->cbufs[i].format) << i;
}
if (!etna_get_vs(ctx, &key) || !etna_get_fs(ctx, &key)) {
@ -324,20 +325,20 @@ etna_draw_vbo(struct pipe_context *pctx, const struct pipe_draw_info *info,
*/
if (ctx->dirty & ETNA_DIRTY_ZSA) {
if (etna_depth_enabled(ctx))
resource_written(ctx, pfb->zsbuf->texture);
resource_written(ctx, pfb->zsbuf.texture);
if (etna_stencil_enabled(ctx))
resource_written(ctx, pfb->zsbuf->texture);
resource_written(ctx, pfb->zsbuf.texture);
}
if (ctx->dirty & ETNA_DIRTY_FRAMEBUFFER) {
for (i = 0; i < pfb->nr_cbufs; i++) {
struct pipe_resource *surf;
if (!pfb->cbufs[i])
if (!pfb->cbufs[i].texture)
continue;
surf = pfb->cbufs[i]->texture;
surf = pfb->cbufs[i].texture;
resource_written(ctx, surf);
}
}
@ -443,12 +444,12 @@ etna_draw_vbo(struct pipe_context *pctx, const struct pipe_draw_info *info,
pctx->flush(pctx, NULL, 0);
for (i = 0; i < pfb->nr_cbufs; i++) {
if (pfb->cbufs[i])
etna_resource_level_mark_changed(etna_surface(pfb->cbufs[i])->level);
if (ctx->fb_cbufs[i])
etna_resource_level_mark_changed(etna_surface(ctx->fb_cbufs[i])->level);
}
if (ctx->framebuffer_s.zsbuf)
etna_resource_level_mark_changed(etna_surface(ctx->framebuffer_s.zsbuf)->level);
if (ctx->fb_zsbuf)
etna_resource_level_mark_changed(etna_surface(ctx->fb_zsbuf)->level);
if (info->index_size && indexbuf != info->index.resource)
pipe_resource_reference(&indexbuf, NULL);
}

View file

@ -39,6 +39,7 @@
#include "pipe/p_shader_tokens.h"
#include "pipe/p_state.h"
#include "util/slab.h"
#include "util/u_framebuffer.h"
#include <util/u_suballoc.h>
struct pipe_screen;
@ -181,6 +182,8 @@ struct etna_context {
struct etna_index_buffer index_buffer;
struct etna_shader_state shader;
PIPE_FB_SURFACES; //STOP USING THIS
/* saved parameter-like state. these are mainly kept around for the blitter */
struct pipe_framebuffer_state framebuffer_s;
struct pipe_stencil_ref stencil_ref_s;

View file

@ -342,7 +342,7 @@ etna_blit_clear_color_rs(struct pipe_context *pctx, unsigned idx,
const union pipe_color_union *color, bool use_ts)
{
struct etna_context *ctx = etna_context(pctx);
struct pipe_surface *dst = ctx->framebuffer_s.cbufs[idx];
struct pipe_surface *dst = ctx->fb_cbufs[idx];
struct etna_surface *surf = etna_surface(dst);
uint64_t new_clear_value = etna_clear_blit_pack_rgba(surf->base.format, color);
@ -484,7 +484,7 @@ etna_clear_rs(struct pipe_context *pctx, unsigned buffers, const struct pipe_sci
bool need_ts_flush = false;
if (buffers & PIPE_CLEAR_COLOR) {
for (int idx = 0; idx < ctx->framebuffer_s.nr_cbufs; ++idx) {
struct etna_surface *surf = etna_surface(ctx->framebuffer_s.cbufs[idx]);
struct etna_surface *surf = etna_surface(ctx->fb_cbufs[idx]);
if (!surf)
continue;
@ -493,8 +493,8 @@ etna_clear_rs(struct pipe_context *pctx, unsigned buffers, const struct pipe_sci
need_ts_flush = true;
}
}
if ((buffers & PIPE_CLEAR_DEPTHSTENCIL) && ctx->framebuffer_s.zsbuf != NULL) {
struct etna_surface *surf = etna_surface(ctx->framebuffer_s.zsbuf);
if ((buffers & PIPE_CLEAR_DEPTHSTENCIL) && ctx->fb_zsbuf != NULL) {
struct etna_surface *surf = etna_surface(ctx->fb_zsbuf);
if (surf->level->ts_size)
need_ts_flush = true;
@ -510,7 +510,7 @@ etna_clear_rs(struct pipe_context *pctx, unsigned buffers, const struct pipe_sci
const bool use_ts = etna_use_ts_for_mrt(ctx->screen, &ctx->framebuffer_s);
for (int idx = 0; idx < ctx->framebuffer_s.nr_cbufs; ++idx) {
struct etna_surface *surf = etna_surface(ctx->framebuffer_s.cbufs[idx]);
struct etna_surface *surf = etna_surface(ctx->fb_cbufs[idx]);
if (!surf)
continue;
@ -528,8 +528,8 @@ etna_clear_rs(struct pipe_context *pctx, unsigned buffers, const struct pipe_sci
etna_set_state(ctx->stream, VIVS_GL_FLUSH_CACHE,
VIVS_GL_FLUSH_CACHE_COLOR | VIVS_GL_FLUSH_CACHE_DEPTH);
if ((buffers & PIPE_CLEAR_DEPTHSTENCIL) && ctx->framebuffer_s.zsbuf != NULL)
etna_blit_clear_zs_rs(pctx, ctx->framebuffer_s.zsbuf, buffers, depth, stencil);
if ((buffers & PIPE_CLEAR_DEPTHSTENCIL) && ctx->fb_zsbuf != NULL)
etna_blit_clear_zs_rs(pctx, ctx->fb_zsbuf, buffers, depth, stencil);
etna_stall(ctx->stream, SYNC_RECIPIENT_RA, SYNC_RECIPIENT_PE);
}

View file

@ -150,11 +150,13 @@ etna_set_framebuffer_state(struct pipe_context *pctx,
const bool use_ts = etna_use_ts_for_mrt(screen, fb);
unsigned rt = 0;
util_framebuffer_init(pctx, fb, ctx->fb_cbufs, &ctx->fb_zsbuf);
for (unsigned i = 0; i < fb->nr_cbufs; i++) {
if (!fb->cbufs[i])
if (!fb->cbufs[i].texture)
continue;
struct etna_surface *cbuf = etna_surface(fb->cbufs[i]);
struct etna_surface *cbuf = etna_surface(ctx->fb_cbufs[i]);
struct etna_resource *res = etna_resource(cbuf->base.texture);
bool color_supertiled = (res->layout & ETNA_LAYOUT_BIT_SUPER) != 0;
uint32_t fmt = translate_pe_format(cbuf->base.format);
@ -336,8 +338,8 @@ etna_set_framebuffer_state(struct pipe_context *pctx,
cs->PE_PIPE_COLOR_ADDR[i] = screen->dummy_rt_reloc;
}
if (fb->zsbuf != NULL) {
struct etna_surface *zsbuf = etna_surface(fb->zsbuf);
if (fb->zsbuf.texture != NULL) {
struct etna_surface *zsbuf = etna_surface(ctx->fb_zsbuf);
struct etna_resource *res = etna_resource(zsbuf->base.texture);
etna_update_render_surface(pctx, zsbuf);
@ -761,7 +763,7 @@ etna_update_ts_config(struct etna_context *ctx)
for (unsigned i = 0; i < fb->nr_cbufs; i++) {
uint32_t ts_config;
if (!fb->cbufs[i])
if (!fb->cbufs[i].texture)
continue;
/* Read the current ts config value for the render target. */
@ -771,7 +773,7 @@ etna_update_ts_config(struct etna_context *ctx)
ts_config = ctx->framebuffer.RT_TS_MEM_CONFIG[rt - 1];
/* Update the ts config for color fast clear. */
struct etna_surface *c_surf = etna_surface(fb->cbufs[i]);
struct etna_surface *c_surf = etna_surface(ctx->fb_cbufs[i]);
if (etna_resource_level_ts_valid(c_surf->level)) {
if (rt == 0)
ts_config |= VIVS_TS_MEM_CONFIG_COLOR_FAST_CLEAR;
@ -801,8 +803,8 @@ etna_update_ts_config(struct etna_context *ctx)
}
/* Update the ts config for depth fast clear. */
if (ctx->framebuffer_s.zsbuf) {
struct etna_surface *zs_surf = etna_surface(ctx->framebuffer_s.zsbuf);
if (ctx->framebuffer_s.zsbuf.texture) {
struct etna_surface *zs_surf = etna_surface(ctx->fb_zsbuf);
uint32_t ts_config = ctx->framebuffer.TS_MEM_CONFIG;
if (etna_resource_level_ts_valid(zs_surf->level))
@ -873,10 +875,10 @@ etna_update_zsa(struct etna_context *ctx)
* know if any other draws to the same surface require late Z write.
*/
for (unsigned i = 0; i < fb->nr_cbufs; i++) {
if (!fb->cbufs[i])
if (!fb->cbufs[i].texture)
continue;
struct etna_surface *cbuf = etna_surface(fb->cbufs[i]);
struct etna_surface *cbuf = etna_surface(ctx->fb_cbufs[i]);
struct etna_resource *res = etna_resource(cbuf->base.texture);
if (res->layout == ETNA_LAYOUT_LINEAR)
@ -927,10 +929,10 @@ etna_update_zsa(struct etna_context *ctx)
new_ra_depth |= VIVS_RA_EARLY_DEPTH_WRITE_DISABLE;
for (unsigned i = 0; i < fb->nr_cbufs; i++) {
if (!fb->cbufs[i])
if (!fb->cbufs[i].texture)
continue;
struct pipe_resource *res = fb->cbufs[i]->texture;
struct pipe_resource *res = fb->cbufs[i].texture;
if ((late_z_test || late_zs) && res->nr_samples > 1)
new_ra_depth |= VIVS_RA_EARLY_DEPTH_LATE_DEPTH_MSAA;
@ -956,10 +958,10 @@ etna_record_flush_resources(struct etna_context *ctx)
struct pipe_framebuffer_state *fb = &ctx->framebuffer_s;
for (unsigned i = 0; i < fb->nr_cbufs; i++) {
if (!fb->cbufs[i])
if (!fb->cbufs[i].texture)
continue;
struct etna_surface *surf = etna_surface(fb->cbufs[i]);
struct etna_surface *surf = etna_surface(ctx->fb_cbufs[i]);
struct etna_resource *rsc = etna_resource(surf->prsc);
if (rsc->shared && !rsc->explicit_flush)

View file

@ -53,7 +53,7 @@ etna_use_ts_for_mrt(const struct etna_screen *screen, const struct pipe_framebuf
unsigned count = 0;
for (unsigned i = 0; i < fb->nr_cbufs; i++) {
if (!fb->cbufs[i])
if (!fb->cbufs[i].texture)
continue;
count++;

View file

@ -441,7 +441,7 @@ fd2_clear_fast(struct fd_context *ctx, unsigned buffers,
struct fd_ringbuffer *ring = batch->draw;
struct pipe_framebuffer_state *pfb = &batch->framebuffer;
uint32_t color_clear = 0, depth_clear = 0;
enum pipe_format format = pipe_surface_format(pfb->cbufs[0]);
enum pipe_format format = pipe_surface_format(&pfb->cbufs[0]);
int depth_size = -1; /* -1: no clear, 0: clear 16-bit, 1: clear 32-bit */
int color_size = -1;
@ -457,12 +457,12 @@ fd2_clear_fast(struct fd_context *ctx, unsigned buffers,
if (!(buffers & PIPE_CLEAR_DEPTH))
return false;
if ((pfb->zsbuf->format == PIPE_FORMAT_Z24_UNORM_S8_UINT ||
pfb->zsbuf->format == PIPE_FORMAT_S8_UINT_Z24_UNORM) &&
if ((pfb->zsbuf.format == PIPE_FORMAT_Z24_UNORM_S8_UINT ||
pfb->zsbuf.format == PIPE_FORMAT_S8_UINT_Z24_UNORM) &&
!(buffers & PIPE_CLEAR_STENCIL))
return false;
depth_size = fd_pipe2depth(pfb->zsbuf->format) == DEPTHX_24_8;
depth_size = fd_pipe2depth(pfb->zsbuf.format) == DEPTHX_24_8;
}
assert(color_size >= 0 || depth_size >= 0);
@ -583,7 +583,7 @@ fd2_clear(struct fd_context *ctx, enum fd_buffer_mask buffers,
if (buffers & (FD_BUFFER_DEPTH | FD_BUFFER_STENCIL)) {
uint32_t clear_mask, depth_clear;
switch (fd_pipe2depth(fb->zsbuf->format)) {
switch (fd_pipe2depth(fb->zsbuf.format)) {
case DEPTHX_24_8:
clear_mask = ((buffers & FD_BUFFER_DEPTH) ? 0xe : 0) |
((buffers & FD_BUFFER_STENCIL) ? 0x1 : 0);

View file

@ -186,10 +186,10 @@ prepare_tile_fini_ib(struct fd_batch *batch) assert_dt
OUT_RING(ring, A2XX_RB_MODECONTROL_EDRAM_MODE(EDRAM_COPY));
if (batch->resolve & (FD_BUFFER_DEPTH | FD_BUFFER_STENCIL))
emit_gmem2mem_surf(batch, gmem->zsbuf_base[0], pfb->zsbuf);
emit_gmem2mem_surf(batch, gmem->zsbuf_base[0], &pfb->zsbuf);
if (batch->resolve & FD_BUFFER_COLOR)
emit_gmem2mem_surf(batch, gmem->cbuf_base[0], pfb->cbufs[0]);
emit_gmem2mem_surf(batch, gmem->cbuf_base[0], &pfb->cbufs[0]);
OUT_PKT3(ring, CP_SET_CONSTANT, 2);
OUT_RING(ring, CP_REG(REG_A2XX_RB_MODECONTROL));
@ -359,10 +359,10 @@ fd2_emit_tile_mem2gmem(struct fd_batch *batch,
OUT_RING(ring, 0x00000000);
if (fd_gmem_needs_restore(batch, tile, FD_BUFFER_DEPTH | FD_BUFFER_STENCIL))
emit_mem2gmem_surf(batch, gmem->zsbuf_base[0], pfb->zsbuf);
emit_mem2gmem_surf(batch, gmem->zsbuf_base[0], &pfb->zsbuf);
if (fd_gmem_needs_restore(batch, tile, FD_BUFFER_COLOR))
emit_mem2gmem_surf(batch, gmem->cbuf_base[0], pfb->cbufs[0]);
emit_mem2gmem_surf(batch, gmem->cbuf_base[0], &pfb->cbufs[0]);
OUT_PKT3(ring, CP_SET_CONSTANT, 2);
OUT_RING(ring, CP_REG(REG_A2XX_PA_CL_VTE_CNTL));
@ -419,9 +419,9 @@ fd2_emit_sysmem_prep(struct fd_batch *batch)
struct fd_context *ctx = batch->ctx;
struct fd_ringbuffer *ring = batch->gmem;
struct pipe_framebuffer_state *pfb = &batch->framebuffer;
struct pipe_surface *psurf = pfb->cbufs[0];
struct pipe_surface *psurf = &pfb->cbufs[0];
if (!psurf)
if (!psurf->texture)
return;
struct fd_resource *rsc = fd_resource(psurf->texture);
@ -470,7 +470,7 @@ fd2_emit_tile_init(struct fd_batch *batch) assert_dt
struct fd_ringbuffer *ring = batch->gmem;
struct pipe_framebuffer_state *pfb = &batch->framebuffer;
const struct fd_gmem_stateobj *gmem = batch->gmem_state;
enum pipe_format format = pipe_surface_format(pfb->cbufs[0]);
enum pipe_format format = pipe_surface_format(&pfb->cbufs[0]);
uint32_t reg;
fd2_emit_restore(ctx, ring);
@ -483,19 +483,19 @@ fd2_emit_tile_init(struct fd_batch *batch) assert_dt
OUT_RING(ring, A2XX_RB_COLOR_INFO_SWAP(fmt2swap(format)) |
A2XX_RB_COLOR_INFO_FORMAT(fd2_pipe2color(format)));
reg = A2XX_RB_DEPTH_INFO_DEPTH_BASE(gmem->zsbuf_base[0]);
if (pfb->zsbuf)
reg |= A2XX_RB_DEPTH_INFO_DEPTH_FORMAT(fd_pipe2depth(pfb->zsbuf->format));
if (pfb->zsbuf.texture)
reg |= A2XX_RB_DEPTH_INFO_DEPTH_FORMAT(fd_pipe2depth(pfb->zsbuf.format));
OUT_RING(ring, reg); /* RB_DEPTH_INFO */
/* fast clear patches */
int depth_size = -1;
int color_size = -1;
if (pfb->cbufs[0])
if (pfb->cbufs[0].texture)
color_size = util_format_get_blocksizebits(format) == 32 ? 4 : 2;
if (pfb->zsbuf)
depth_size = fd_pipe2depth(pfb->zsbuf->format) == 1 ? 4 : 2;
if (pfb->zsbuf.texture)
depth_size = fd_pipe2depth(pfb->zsbuf.format) == 1 ? 4 : 2;
for (int i = 0; i < fd_patch_num_elements(&batch->gmem_patches); i++) {
struct fd_cs_patch *patch = fd_patch_element(&batch->gmem_patches, i);
@ -524,9 +524,9 @@ fd2_emit_tile_init(struct fd_batch *batch) assert_dt
patch->cs[1] = A2XX_RB_COLOR_INFO_SWAP(fmt2swap(format)) |
A2XX_RB_COLOR_INFO_FORMAT(fd2_pipe2color(format));
patch->cs[2] = A2XX_RB_DEPTH_INFO_DEPTH_BASE(gmem->zsbuf_base[0]);
if (pfb->zsbuf)
if (pfb->zsbuf.texture)
patch->cs[2] |= A2XX_RB_DEPTH_INFO_DEPTH_FORMAT(
fd_pipe2depth(pfb->zsbuf->format));
fd_pipe2depth(pfb->zsbuf.format));
continue;
default:
continue;
@ -653,7 +653,7 @@ fd2_emit_tile_prep(struct fd_batch *batch, const struct fd_tile *tile)
{
struct fd_ringbuffer *ring = batch->gmem;
struct pipe_framebuffer_state *pfb = &batch->framebuffer;
enum pipe_format format = pipe_surface_format(pfb->cbufs[0]);
enum pipe_format format = pipe_surface_format(&pfb->cbufs[0]);
OUT_PKT3(ring, CP_SET_CONSTANT, 2);
OUT_RING(ring, CP_REG(REG_A2XX_RB_COLOR_INFO));
@ -678,7 +678,7 @@ fd2_emit_tile_renderprep(struct fd_batch *batch,
struct fd2_context *fd2_ctx = fd2_context(ctx);
struct fd_ringbuffer *ring = batch->gmem;
struct pipe_framebuffer_state *pfb = &batch->framebuffer;
enum pipe_format format = pipe_surface_format(pfb->cbufs[0]);
enum pipe_format format = pipe_surface_format(&pfb->cbufs[0]);
OUT_PKT3(ring, CP_SET_CONSTANT, 2);
OUT_RING(ring, CP_REG(REG_A2XX_RB_COLOR_INFO));

View file

@ -257,7 +257,7 @@ emit_textures(struct fd_context *ctx, struct fd_ringbuffer *ring,
*/
void
fd3_emit_gmem_restore_tex(struct fd_ringbuffer *ring,
struct pipe_surface **psurf, int bufs)
struct pipe_surface *psurf, int bufs)
{
int i, j;
@ -287,7 +287,7 @@ fd3_emit_gmem_restore_tex(struct fd_ringbuffer *ring,
OUT_RING(ring, CP_LOAD_STATE_1_STATE_TYPE(ST_CONSTANTS) |
CP_LOAD_STATE_1_EXT_SRC_ADDR(0));
for (i = 0; i < bufs; i++) {
if (!psurf[i]) {
if (!psurf[i].texture) {
OUT_RING(ring, A3XX_TEX_CONST_0_TYPE(A3XX_TEX_2D) |
A3XX_TEX_CONST_0_SWIZ_X(A3XX_TEX_ONE) |
A3XX_TEX_CONST_0_SWIZ_Y(A3XX_TEX_ONE) |
@ -299,10 +299,10 @@ fd3_emit_gmem_restore_tex(struct fd_ringbuffer *ring,
continue;
}
struct fd_resource *rsc = fd_resource(psurf[i]->texture);
enum pipe_format format = fd_gmem_restore_format(psurf[i]->format);
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);
pipe_surface_size(&psurf[i], &width, &height);
/* The restore blit_zs shader expects stencil in sampler 0, and depth
* in sampler 1
*/
@ -312,9 +312,9 @@ fd3_emit_gmem_restore_tex(struct fd_ringbuffer *ring,
}
/* note: PIPE_BUFFER disallowed for surfaces */
unsigned lvl = psurf[i]->u.tex.level;
unsigned lvl = psurf[i].u.tex.level;
assert(psurf[i]->u.tex.first_layer == psurf[i]->u.tex.last_layer);
assert(psurf[i].u.tex.first_layer == psurf[i].u.tex.last_layer);
OUT_RING(ring, A3XX_TEX_CONST_0_TILE_MODE(rsc->layout.tile_mode) |
A3XX_TEX_CONST_0_FMT(fd3_pipe2tex(format)) |
@ -337,14 +337,14 @@ fd3_emit_gmem_restore_tex(struct fd_ringbuffer *ring,
OUT_RING(ring, CP_LOAD_STATE_1_STATE_TYPE(ST_CONSTANTS) |
CP_LOAD_STATE_1_EXT_SRC_ADDR(0));
for (i = 0; i < bufs; i++) {
if (psurf[i]) {
struct fd_resource *rsc = fd_resource(psurf[i]->texture);
if (psurf[i].texture) {
struct fd_resource *rsc = fd_resource(psurf[i].texture);
/* Matches above logic for blit_zs shader */
if (rsc->stencil && i == 0)
rsc = rsc->stencil;
unsigned lvl = psurf[i]->u.tex.level;
unsigned lvl = psurf[i].u.tex.level;
uint32_t offset =
fd_resource_offset(rsc, lvl, psurf[i]->u.tex.first_layer);
fd_resource_offset(rsc, lvl, psurf[i].u.tex.first_layer);
OUT_RELOC(ring, rsc->bo, offset, 0, 0);
} else {
OUT_RING(ring, 0x00000000);
@ -702,9 +702,9 @@ fd3_emit_state(struct fd_context *ctx, struct fd_ringbuffer *ring,
(FD_DIRTY_VIEWPORT | FD_DIRTY_RASTERIZER | FD_DIRTY_FRAMEBUFFER)) {
float zmin, zmax;
int depth = 24;
if (ctx->batch->framebuffer.zsbuf) {
if (ctx->batch->framebuffer.zsbuf.texture) {
depth = util_format_get_component_bits(
pipe_surface_format(ctx->batch->framebuffer.zsbuf),
pipe_surface_format(&ctx->batch->framebuffer.zsbuf),
UTIL_FORMAT_COLORSPACE_ZS, 0);
}
util_viewport_zmin_zmax(&ctx->viewport[0], ctx->rasterizer->clip_halfz,
@ -749,7 +749,7 @@ fd3_emit_state(struct fd_context *ctx, struct fd_ringbuffer *ring,
for (i = 0; i < ARRAY_SIZE(blend->rb_mrt); i++) {
enum pipe_format format =
pipe_surface_format(ctx->batch->framebuffer.cbufs[i]);
pipe_surface_format(&ctx->batch->framebuffer.cbufs[i]);
const struct util_format_description *desc =
util_format_description(format);
bool is_float = util_format_is_float(format);

View file

@ -21,7 +21,7 @@
struct fd_ringbuffer;
void fd3_emit_gmem_restore_tex(struct fd_ringbuffer *ring,
struct pipe_surface **psurf, int bufs);
struct pipe_surface *psurf, int bufs);
/* grouped together emit-state for prog/vertex/state emit: */
struct fd3_emit {

View file

@ -39,7 +39,7 @@ fd3_gmem_emit_set_prog(struct fd_context *ctx, struct fd3_emit *emit,
static void
emit_mrt(struct fd_ringbuffer *ring, unsigned nr_bufs,
struct pipe_surface **bufs, const uint32_t *bases, uint32_t bin_w,
struct pipe_surface *bufs, const uint32_t *bases, uint32_t bin_w,
bool decode_srgb)
{
enum a3xx_tile_mode tile_mode;
@ -61,8 +61,8 @@ emit_mrt(struct fd_ringbuffer *ring, unsigned nr_bufs,
tile_mode = LINEAR;
}
if ((i < nr_bufs) && bufs[i]) {
struct pipe_surface *psurf = bufs[i];
if ((i < nr_bufs) && bufs[i].texture) {
struct pipe_surface *psurf = &bufs[i];
rsc = fd_resource(psurf->texture);
pformat = psurf->format;
@ -107,14 +107,14 @@ emit_mrt(struct fd_ringbuffer *ring, unsigned nr_bufs,
A3XX_RB_MRT_BUF_INFO_COLOR_BUF_PITCH(stride) |
A3XX_RB_MRT_BUF_INFO_COLOR_SWAP(swap) |
COND(srgb, A3XX_RB_MRT_BUF_INFO_COLOR_SRGB));
if (bin_w || (i >= nr_bufs) || !bufs[i]) {
if (bin_w || (i >= nr_bufs) || !bufs[i].texture) {
OUT_RING(ring, A3XX_RB_MRT_BUF_BASE_COLOR_BUF_BASE(base));
} else {
OUT_RELOC(ring, rsc->bo, offset, 0, -1);
}
OUT_PKT0(ring, REG_A3XX_SP_FS_IMAGE_OUTPUT_REG(i), 1);
OUT_RING(ring, COND((i < nr_bufs) && bufs[i],
OUT_RING(ring, COND((i < nr_bufs) && bufs[i].texture,
A3XX_SP_FS_IMAGE_OUTPUT_REG_MRTFORMAT(
fd3_fs_output_format(pformat))));
}
@ -449,23 +449,23 @@ fd3_emit_tile_gmem2mem(struct fd_batch *batch,
fd3_emit_vertex_bufs(ring, &emit);
if (batch->resolve & (FD_BUFFER_DEPTH | FD_BUFFER_STENCIL)) {
struct fd_resource *rsc = fd_resource(pfb->zsbuf->texture);
struct fd_resource *rsc = fd_resource(pfb->zsbuf.texture);
if (!rsc->stencil || batch->resolve & FD_BUFFER_DEPTH)
emit_gmem2mem_surf(batch, RB_COPY_DEPTH_STENCIL, false,
gmem->zsbuf_base[0], pfb->zsbuf);
gmem->zsbuf_base[0], &pfb->zsbuf);
if (rsc->stencil && batch->resolve & FD_BUFFER_STENCIL)
emit_gmem2mem_surf(batch, RB_COPY_DEPTH_STENCIL, true,
gmem->zsbuf_base[1], pfb->zsbuf);
gmem->zsbuf_base[1], &pfb->zsbuf);
}
if (batch->resolve & FD_BUFFER_COLOR) {
for (i = 0; i < pfb->nr_cbufs; i++) {
if (!pfb->cbufs[i])
if (!pfb->cbufs[i].texture)
continue;
if (!(batch->resolve & (PIPE_CLEAR_COLOR0 << i)))
continue;
emit_gmem2mem_surf(batch, RB_COPY_RESOLVE, false, gmem->cbuf_base[i],
pfb->cbufs[i]);
&pfb->cbufs[i]);
}
}
@ -484,10 +484,10 @@ fd3_emit_tile_gmem2mem(struct fd_batch *batch,
static void
emit_mem2gmem_surf(struct fd_batch *batch, const uint32_t bases[],
struct pipe_surface **psurf, uint32_t bufs, uint32_t bin_w)
struct pipe_surface *psurf, uint32_t bufs, uint32_t bin_w)
{
struct fd_ringbuffer *ring = batch->gmem;
struct pipe_surface *zsbufs[2];
struct pipe_surface zsbufs[2];
assert(bufs > 0);
@ -498,8 +498,8 @@ emit_mem2gmem_surf(struct fd_batch *batch, const uint32_t bases[],
emit_mrt(ring, bufs, psurf, bases, bin_w, false);
if (psurf[0] && (psurf[0]->format == PIPE_FORMAT_Z32_FLOAT ||
psurf[0]->format == PIPE_FORMAT_Z32_FLOAT_S8X24_UINT)) {
if (psurf[0].texture && (psurf[0].format == PIPE_FORMAT_Z32_FLOAT ||
psurf[0].format == PIPE_FORMAT_Z32_FLOAT_S8X24_UINT)) {
/* Depth is stored as unorm in gmem, so we have to write it in using a
* special blit shader which writes depth.
*/
@ -515,7 +515,7 @@ emit_mem2gmem_surf(struct fd_batch *batch, const uint32_t bases[],
A3XX_RB_DEPTH_INFO_DEPTH_FORMAT(DEPTHX_32));
OUT_RING(ring, A3XX_RB_DEPTH_PITCH(4 * batch->gmem_state->bin_w));
if (psurf[0]->format == PIPE_FORMAT_Z32_FLOAT) {
if (psurf[0].format == PIPE_FORMAT_Z32_FLOAT) {
OUT_PKT0(ring, REG_A3XX_RB_MRT_CONTROL(0), 1);
OUT_RING(ring, 0);
} else {
@ -677,15 +677,15 @@ fd3_emit_tile_mem2gmem(struct fd_batch *batch,
if (fd_gmem_needs_restore(batch, tile,
FD_BUFFER_DEPTH | FD_BUFFER_STENCIL)) {
if (pfb->zsbuf->format != PIPE_FORMAT_Z32_FLOAT_S8X24_UINT &&
pfb->zsbuf->format != PIPE_FORMAT_Z32_FLOAT) {
if (pfb->zsbuf.format != PIPE_FORMAT_Z32_FLOAT_S8X24_UINT &&
pfb->zsbuf.format != PIPE_FORMAT_Z32_FLOAT) {
/* Non-float can use a regular color write. It's split over 8-bit
* components, so half precision is always sufficient.
*/
fd3_gmem_emit_set_prog(ctx, &emit, &ctx->blit_prog[0]);
} else {
/* Float depth needs special blit shader that writes depth */
if (pfb->zsbuf->format == PIPE_FORMAT_Z32_FLOAT)
if (pfb->zsbuf.format == PIPE_FORMAT_Z32_FLOAT)
fd3_gmem_emit_set_prog(ctx, &emit, &ctx->blit_z);
else
fd3_gmem_emit_set_prog(ctx, &emit, &ctx->blit_zs);
@ -736,8 +736,8 @@ fd3_emit_sysmem_prep(struct fd_batch *batch) assert_dt
uint32_t i, pitch = 0;
for (i = 0; i < pfb->nr_cbufs; i++) {
struct pipe_surface *psurf = pfb->cbufs[i];
if (!psurf)
struct pipe_surface *psurf = &pfb->cbufs[i];
if (!psurf->texture)
continue;
struct fd_resource *rsc = fd_resource(psurf->texture);
pitch = fd_resource_pitch(rsc, psurf->u.tex.level) / rsc->layout.cpp;
@ -1002,12 +1002,12 @@ fd3_emit_tile_renderprep(struct fd_batch *batch,
OUT_PKT0(ring, REG_A3XX_RB_DEPTH_INFO, 2);
reg = A3XX_RB_DEPTH_INFO_DEPTH_BASE(gmem->zsbuf_base[0]);
if (pfb->zsbuf) {
reg |= A3XX_RB_DEPTH_INFO_DEPTH_FORMAT(fd_pipe2depth(pfb->zsbuf->format));
if (pfb->zsbuf.texture) {
reg |= A3XX_RB_DEPTH_INFO_DEPTH_FORMAT(fd_pipe2depth(pfb->zsbuf.format));
}
OUT_RING(ring, reg);
if (pfb->zsbuf) {
struct fd_resource *rsc = fd_resource(pfb->zsbuf->texture);
if (pfb->zsbuf.texture) {
struct fd_resource *rsc = fd_resource(pfb->zsbuf.texture);
OUT_RING(ring,
A3XX_RB_DEPTH_PITCH(gmem->bin_w << fdl_cpp_shift(&rsc->layout)));
if (rsc->stencil) {

View file

@ -74,7 +74,7 @@ emit_shader(struct fd_ringbuffer *ring, const struct ir3_shader_variant *so)
void
fd3_program_emit(struct fd_ringbuffer *ring, struct fd3_emit *emit, int nr,
struct pipe_surface **bufs)
struct pipe_surface *bufs)
{
const struct ir3_shader_variant *vp, *fp;
const struct ir3_info *vsi, *fsi;
@ -167,7 +167,7 @@ fd3_program_emit(struct fd_ringbuffer *ring, struct fd3_emit *emit, int nr,
* format, so it's just treated like red
*/
for (i = 0; i < nr; i++)
if (util_format_is_alpha(pipe_surface_format(bufs[i])))
if (util_format_is_alpha(pipe_surface_format(&bufs[i])))
color_regid[i] += 3;
/* we could probably divide this up into things that need to be
@ -319,7 +319,7 @@ fd3_program_emit(struct fd_ringbuffer *ring, struct fd3_emit *emit, int nr,
COND(color_regid[i] & HALF_REG_ID, A3XX_SP_FS_MRT_REG_HALF_PRECISION);
if (i < nr) {
enum pipe_format fmt = pipe_surface_format(bufs[i]);
enum pipe_format fmt = pipe_surface_format(&bufs[i]);
mrt_reg |=
COND(util_format_is_pure_uint(fmt), A3XX_SP_FS_MRT_REG_UINT) |
COND(util_format_is_pure_sint(fmt), A3XX_SP_FS_MRT_REG_SINT);

View file

@ -31,7 +31,7 @@ fd3_program_state(struct ir3_program_state *state)
}
void fd3_program_emit(struct fd_ringbuffer *ring, struct fd3_emit *emit, int nr,
struct pipe_surface **bufs);
struct pipe_surface *bufs);
void fd3_prog_init(struct pipe_context *pctx);

View file

@ -347,7 +347,7 @@ emit_textures(struct fd_context *ctx, struct fd_ringbuffer *ring,
*/
void
fd4_emit_gmem_restore_tex(struct fd_ringbuffer *ring, unsigned nr_bufs,
struct pipe_surface **bufs)
struct pipe_surface *bufs)
{
unsigned char mrt_comp[A4XX_MAX_RENDER_TARGETS];
int i;
@ -382,11 +382,11 @@ fd4_emit_gmem_restore_tex(struct fd_ringbuffer *ring, unsigned nr_bufs,
OUT_RING(ring, CP_LOAD_STATE4_1_STATE_TYPE(ST4_CONSTANTS) |
CP_LOAD_STATE4_1_EXT_SRC_ADDR(0));
for (i = 0; i < nr_bufs; i++) {
if (bufs[i]) {
struct fd_resource *rsc = fd_resource(bufs[i]->texture);
enum pipe_format format = fd_gmem_restore_format(bufs[i]->format);
if (bufs[i].texture) {
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);
pipe_surface_size(&bufs[i], &width, &height);
/* The restore blit_zs shader expects stencil in sampler 0,
* and depth in sampler 1
*/
@ -396,9 +396,9 @@ fd4_emit_gmem_restore_tex(struct fd_ringbuffer *ring, unsigned nr_bufs,
}
/* note: PIPE_BUFFER disallowed for surfaces */
unsigned lvl = bufs[i]->u.tex.level;
unsigned lvl = bufs[i].u.tex.level;
unsigned offset =
fd_resource_offset(rsc, lvl, bufs[i]->u.tex.first_layer);
fd_resource_offset(rsc, lvl, bufs[i].u.tex.first_layer);
/* z32 restore is accomplished using depth write. If there is
* no stencil component (ie. PIPE_FORMAT_Z32_FLOAT_S8X24_UINT)
@ -411,7 +411,7 @@ fd4_emit_gmem_restore_tex(struct fd_ringbuffer *ring, unsigned nr_bufs,
(format == PIPE_FORMAT_Z32_FLOAT_S8X24_UINT))
mrt_comp[i] = 0;
assert(bufs[i]->u.tex.first_layer == bufs[i]->u.tex.last_layer);
assert(bufs[i].u.tex.first_layer == bufs[i].u.tex.last_layer);
OUT_RING(ring, A4XX_TEX_CONST_0_FMT(fd4_pipe2tex(format)) |
A4XX_TEX_CONST_0_TYPE(A4XX_TEX_2D) |
@ -649,7 +649,7 @@ fd4_emit_state(struct fd_context *ctx, struct fd_ringbuffer *ring,
unsigned char mrt_comp[A4XX_MAX_RENDER_TARGETS] = {0};
for (unsigned i = 0; i < A4XX_MAX_RENDER_TARGETS; i++) {
mrt_comp[i] = ((i < pfb->nr_cbufs) && pfb->cbufs[i]) ? 0xf : 0;
mrt_comp[i] = ((i < pfb->nr_cbufs) && pfb->cbufs[i].texture) ? 0xf : 0;
}
OUT_PKT0(ring, REG_A4XX_RB_RENDER_COMPONENTS, 1);
@ -668,7 +668,7 @@ fd4_emit_state(struct fd_context *ctx, struct fd_ringbuffer *ring,
struct pipe_framebuffer_state *pfb = &ctx->batch->framebuffer;
uint32_t rb_alpha_control = zsa->rb_alpha_control;
if (util_format_is_pure_integer(pipe_surface_format(pfb->cbufs[0])))
if (util_format_is_pure_integer(pipe_surface_format(&pfb->cbufs[0])))
rb_alpha_control &= ~A4XX_RB_ALPHA_CONTROL_ALPHA_TEST;
OUT_PKT0(ring, REG_A4XX_RB_ALPHA_CONTROL, 1);
@ -800,9 +800,9 @@ fd4_emit_state(struct fd_context *ctx, struct fd_ringbuffer *ring,
(FD_DIRTY_VIEWPORT | FD_DIRTY_RASTERIZER | FD_DIRTY_FRAMEBUFFER)) {
float zmin, zmax;
int depth = 24;
if (ctx->batch->framebuffer.zsbuf) {
if (ctx->batch->framebuffer.zsbuf.texture) {
depth = util_format_get_component_bits(
pipe_surface_format(ctx->batch->framebuffer.zsbuf),
pipe_surface_format(&ctx->batch->framebuffer.zsbuf),
UTIL_FORMAT_COLORSPACE_ZS, 0);
}
util_viewport_zmin_zmax(&ctx->viewport[0], ctx->rasterizer->clip_halfz,
@ -825,7 +825,7 @@ fd4_emit_state(struct fd_context *ctx, struct fd_ringbuffer *ring,
struct pipe_framebuffer_state *pfb = &ctx->batch->framebuffer;
unsigned n = pfb->nr_cbufs;
/* if we have depth/stencil, we need at least on MRT: */
if (pfb->zsbuf)
if (pfb->zsbuf.texture)
n = MAX2(1, n);
fd4_program_emit(ring, emit, n, pfb->cbufs);
}
@ -842,7 +842,7 @@ fd4_emit_state(struct fd_context *ctx, struct fd_ringbuffer *ring,
for (i = 0; i < A4XX_MAX_RENDER_TARGETS; i++) {
enum pipe_format format =
pipe_surface_format(ctx->batch->framebuffer.cbufs[i]);
pipe_surface_format(&ctx->batch->framebuffer.cbufs[i]);
bool is_int = util_format_is_pure_integer(format);
bool has_alpha = util_format_has_alpha(format);
uint32_t control = blend->rb_mrt[i].control;

View file

@ -19,7 +19,7 @@
struct fd_ringbuffer;
void fd4_emit_gmem_restore_tex(struct fd_ringbuffer *ring, unsigned nr_bufs,
struct pipe_surface **bufs);
struct pipe_surface *bufs);
/* grouped together emit-state for prog/vertex/state emit: */
struct fd4_emit {
@ -48,7 +48,7 @@ struct fd4_emit {
static inline enum a4xx_color_fmt
fd4_emit_format(struct pipe_surface *surf)
{
if (!surf)
if (!surf->texture)
return 0;
return fd4_pipe2color(surf->format);
}

View file

@ -40,7 +40,7 @@ fd4_gmem_emit_set_prog(struct fd_context *ctx, struct fd4_emit *emit,
static void
emit_mrt(struct fd_ringbuffer *ring, unsigned nr_bufs,
struct pipe_surface **bufs, const uint32_t *bases, uint32_t bin_w,
struct pipe_surface *bufs, const uint32_t *bases, uint32_t bin_w,
bool decode_srgb)
{
enum a4xx_tile_mode tile_mode;
@ -61,8 +61,8 @@ emit_mrt(struct fd_ringbuffer *ring, unsigned nr_bufs,
uint32_t base = 0;
uint32_t offset = 0;
if ((i < nr_bufs) && bufs[i]) {
struct pipe_surface *psurf = bufs[i];
if ((i < nr_bufs) && bufs[i].texture) {
struct pipe_surface *psurf = &bufs[i];
enum pipe_format pformat = psurf->format;
rsc = fd_resource(psurf->texture);
@ -109,7 +109,7 @@ emit_mrt(struct fd_ringbuffer *ring, unsigned nr_bufs,
A4XX_RB_MRT_BUF_INFO_COLOR_BUF_PITCH(stride) |
A4XX_RB_MRT_BUF_INFO_COLOR_SWAP(swap) |
COND(srgb, A4XX_RB_MRT_BUF_INFO_COLOR_SRGB));
if (bin_w || (i >= nr_bufs) || !bufs[i]) {
if (bin_w || (i >= nr_bufs) || !bufs[i].texture) {
OUT_RING(ring, base);
OUT_RING(ring, A4XX_RB_MRT_CONTROL3_STRIDE(stride));
} else {
@ -268,21 +268,21 @@ fd4_emit_tile_gmem2mem(struct fd_batch *batch,
fd4_emit_vertex_bufs(ring, &emit);
if (batch->resolve & (FD_BUFFER_DEPTH | FD_BUFFER_STENCIL)) {
struct fd_resource *rsc = fd_resource(pfb->zsbuf->texture);
struct fd_resource *rsc = fd_resource(pfb->zsbuf.texture);
if (!rsc->stencil || (batch->resolve & FD_BUFFER_DEPTH))
emit_gmem2mem_surf(batch, false, gmem->zsbuf_base[0], pfb->zsbuf);
emit_gmem2mem_surf(batch, false, gmem->zsbuf_base[0], &pfb->zsbuf);
if (rsc->stencil && (batch->resolve & FD_BUFFER_STENCIL))
emit_gmem2mem_surf(batch, true, gmem->zsbuf_base[1], pfb->zsbuf);
emit_gmem2mem_surf(batch, true, gmem->zsbuf_base[1], &pfb->zsbuf);
}
if (batch->resolve & FD_BUFFER_COLOR) {
unsigned i;
for (i = 0; i < pfb->nr_cbufs; i++) {
if (!pfb->cbufs[i])
if (!pfb->cbufs[i].texture)
continue;
if (!(batch->resolve & (PIPE_CLEAR_COLOR0 << i)))
continue;
emit_gmem2mem_surf(batch, false, gmem->cbuf_base[i], pfb->cbufs[i]);
emit_gmem2mem_surf(batch, false, gmem->cbuf_base[i], &pfb->cbufs[i]);
}
}
@ -297,14 +297,14 @@ fd4_emit_tile_gmem2mem(struct fd_batch *batch,
static void
emit_mem2gmem_surf(struct fd_batch *batch, const uint32_t *bases,
struct pipe_surface **bufs, uint32_t nr_bufs, uint32_t bin_w)
struct pipe_surface *bufs, uint32_t nr_bufs, uint32_t bin_w)
{
struct fd_ringbuffer *ring = batch->gmem;
struct pipe_surface *zsbufs[2];
struct pipe_surface zsbufs[2];
emit_mrt(ring, nr_bufs, bufs, bases, bin_w, false);
if (bufs[0] && (bufs[0]->format == PIPE_FORMAT_Z32_FLOAT_S8X24_UINT)) {
if (bufs[0].texture && (bufs[0].format == PIPE_FORMAT_Z32_FLOAT_S8X24_UINT)) {
/* The gmem_restore_tex logic will put the first buffer's stencil
* as color. Supply it with the proper information to make that
* happen.
@ -357,7 +357,7 @@ fd4_emit_tile_mem2gmem(struct fd_batch *batch,
OUT_RING(ring, fui(y1));
for (i = 0; i < A4XX_MAX_RENDER_TARGETS; i++) {
mrt_comp[i] = ((i < pfb->nr_cbufs) && pfb->cbufs[i]) ? 0xf : 0;
mrt_comp[i] = ((i < pfb->nr_cbufs) && pfb->cbufs[i].texture) ? 0xf : 0;
OUT_PKT0(ring, REG_A4XX_RB_MRT_CONTROL(i), 1);
OUT_RING(ring, A4XX_RB_MRT_CONTROL_ROP_CODE(ROP_COPY) |
@ -463,10 +463,10 @@ fd4_emit_tile_mem2gmem(struct fd_batch *batch,
if (fd_gmem_needs_restore(batch, tile,
FD_BUFFER_DEPTH | FD_BUFFER_STENCIL)) {
switch (pfb->zsbuf->format) {
switch (pfb->zsbuf.format) {
case PIPE_FORMAT_Z32_FLOAT_S8X24_UINT:
case PIPE_FORMAT_Z32_FLOAT:
if (pfb->zsbuf->format == PIPE_FORMAT_Z32_FLOAT)
if (pfb->zsbuf.format == PIPE_FORMAT_Z32_FLOAT)
fd4_gmem_emit_set_prog(ctx, &emit, &ctx->blit_z);
else
fd4_gmem_emit_set_prog(ctx, &emit, &ctx->blit_zs);
@ -705,14 +705,14 @@ fd4_emit_tile_prep(struct fd_batch *batch, const struct fd_tile *tile)
struct pipe_framebuffer_state *pfb = &batch->framebuffer;
const struct fd_gmem_stateobj *gmem = batch->gmem_state;
if (pfb->zsbuf) {
struct fd_resource *rsc = fd_resource(pfb->zsbuf->texture);
if (pfb->zsbuf.texture) {
struct fd_resource *rsc = fd_resource(pfb->zsbuf.texture);
uint32_t cpp = rsc->layout.cpp;
OUT_PKT0(ring, REG_A4XX_RB_DEPTH_INFO, 3);
OUT_RING(ring, A4XX_RB_DEPTH_INFO_DEPTH_BASE(gmem->zsbuf_base[0]) |
A4XX_RB_DEPTH_INFO_DEPTH_FORMAT(
fd4_pipe2depth(pfb->zsbuf->format)));
fd4_pipe2depth(pfb->zsbuf.format)));
OUT_RING(ring, A4XX_RB_DEPTH_PITCH(cpp * gmem->bin_w));
OUT_RING(ring, A4XX_RB_DEPTH_PITCH2(cpp * gmem->bin_w));
@ -739,9 +739,9 @@ fd4_emit_tile_prep(struct fd_batch *batch, const struct fd_tile *tile)
}
OUT_PKT0(ring, REG_A4XX_GRAS_DEPTH_CONTROL, 1);
if (pfb->zsbuf) {
if (pfb->zsbuf.texture) {
OUT_RING(ring, A4XX_GRAS_DEPTH_CONTROL_FORMAT(
fd4_pipe2depth(pfb->zsbuf->format)));
fd4_pipe2depth(pfb->zsbuf.format)));
} else {
OUT_RING(ring, A4XX_GRAS_DEPTH_CONTROL_FORMAT(DEPTH4_NONE));
}

View file

@ -134,7 +134,7 @@ setup_stages(struct fd4_emit *emit, struct stage *s)
void
fd4_program_emit(struct fd_ringbuffer *ring, struct fd4_emit *emit, int nr,
struct pipe_surface **bufs)
struct pipe_surface *bufs)
{
struct stage s[MAX_STAGES];
uint32_t pos_regid, posz_regid, psize_regid, color_regid[8];
@ -435,12 +435,12 @@ fd4_program_emit(struct fd_ringbuffer *ring, struct fd4_emit *emit, int nr,
bool uint = false;
bool sint = false;
if (i < nr) {
format = fd4_emit_format(bufs[i]);
if (bufs[i]) {
format = fd4_emit_format(&bufs[i]);
if (bufs[i].texture) {
if (!emit->no_decode_srgb)
srgb = util_format_is_srgb(bufs[i]->format);
uint = util_format_is_pure_uint(bufs[i]->format);
sint = util_format_is_pure_sint(bufs[i]->format);
srgb = util_format_is_srgb(bufs[i].format);
uint = util_format_is_pure_uint(bufs[i].format);
sint = util_format_is_pure_sint(bufs[i].format);
}
}
OUT_RING(ring, A4XX_SP_FS_MRT_REG_REGID(color_regid[i]) |

View file

@ -34,7 +34,7 @@ void fd4_emit_shader(struct fd_ringbuffer *ring,
const struct ir3_shader_variant *so);
void fd4_program_emit(struct fd_ringbuffer *ring, struct fd4_emit *emit, int nr,
struct pipe_surface **bufs);
struct pipe_surface *bufs);
void fd4_prog_init(struct pipe_context *pctx);

View file

@ -225,7 +225,7 @@ fd5_clear(struct fd_context *ctx, enum fd_buffer_mask buffers,
struct pipe_framebuffer_state *pfb = &ctx->batch->framebuffer;
if ((buffers & (FD_BUFFER_DEPTH | FD_BUFFER_STENCIL)) &&
is_z32(pfb->zsbuf->format))
is_z32(pfb->zsbuf.format))
return false;
fd5_emit_render_cntl(ctx, true, false);
@ -234,13 +234,13 @@ fd5_clear(struct fd_context *ctx, enum fd_buffer_mask buffers,
for (int i = 0; i < pfb->nr_cbufs; i++) {
union util_color uc = {0};
if (!pfb->cbufs[i])
if (!pfb->cbufs[i].texture)
continue;
if (!(buffers & (PIPE_CLEAR_COLOR0 << i)))
continue;
enum pipe_format pfmt = pfb->cbufs[i]->format;
enum pipe_format pfmt = pfb->cbufs[i].format;
// XXX I think RB_CLEAR_COLOR_DWn wants to take into account SWAP??
union pipe_color_union swapped;
@ -290,8 +290,8 @@ fd5_clear(struct fd_context *ctx, enum fd_buffer_mask buffers,
}
}
if (pfb->zsbuf && (buffers & (FD_BUFFER_DEPTH | FD_BUFFER_STENCIL))) {
uint32_t clear = util_pack_z_stencil(pfb->zsbuf->format, depth, stencil);
if (pfb->zsbuf.texture && (buffers & (FD_BUFFER_DEPTH | FD_BUFFER_STENCIL))) {
uint32_t clear = util_pack_z_stencil(pfb->zsbuf.format, depth, stencil);
uint32_t mask = 0;
if (buffers & FD_BUFFER_DEPTH)
@ -312,8 +312,8 @@ fd5_clear(struct fd_context *ctx, enum fd_buffer_mask buffers,
fd5_emit_blit(ctx->batch, ring);
if (pfb->zsbuf && (buffers & FD_BUFFER_DEPTH)) {
struct fd_resource *zsbuf = fd_resource(pfb->zsbuf->texture);
if (pfb->zsbuf.texture && (buffers & FD_BUFFER_DEPTH)) {
struct fd_resource *zsbuf = fd_resource(pfb->zsbuf.texture);
if (zsbuf->lrz) {
zsbuf->lrz_valid = true;
fd5_clear_lrz(ctx->batch, zsbuf, depth);

View file

@ -511,7 +511,7 @@ fd5_emit_state(struct fd_context *ctx, struct fd_ringbuffer *ring,
unsigned char mrt_comp[A5XX_MAX_RENDER_TARGETS] = {0};
for (unsigned i = 0; i < A5XX_MAX_RENDER_TARGETS; i++) {
mrt_comp[i] = ((i < pfb->nr_cbufs) && pfb->cbufs[i]) ? 0xf : 0;
mrt_comp[i] = ((i < pfb->nr_cbufs) && pfb->cbufs[i].texture) ? 0xf : 0;
}
OUT_PKT4(ring, REG_A5XX_RB_RENDER_COMPONENTS, 1);
@ -529,7 +529,7 @@ fd5_emit_state(struct fd_context *ctx, struct fd_ringbuffer *ring,
struct fd5_zsa_stateobj *zsa = fd5_zsa_stateobj(ctx->zsa);
uint32_t rb_alpha_control = zsa->rb_alpha_control;
if (util_format_is_pure_integer(pipe_surface_format(pfb->cbufs[0])))
if (util_format_is_pure_integer(pipe_surface_format(&pfb->cbufs[0])))
rb_alpha_control &= ~A5XX_RB_ALPHA_CONTROL_ALPHA_TEST;
OUT_PKT4(ring, REG_A5XX_RB_ALPHA_CONTROL, 1);
@ -543,8 +543,8 @@ fd5_emit_state(struct fd_context *ctx, struct fd_ringbuffer *ring,
struct fd5_blend_stateobj *blend = fd5_blend_stateobj(ctx->blend);
struct fd5_zsa_stateobj *zsa = fd5_zsa_stateobj(ctx->zsa);
if (pfb->zsbuf) {
struct fd_resource *rsc = fd_resource(pfb->zsbuf->texture);
if (pfb->zsbuf.texture) {
struct fd_resource *rsc = fd_resource(pfb->zsbuf.texture);
uint32_t gras_lrz_cntl = zsa->gras_lrz_cntl;
if (emit->no_lrz_write || !rsc->lrz || !rsc->lrz_valid)
@ -767,7 +767,7 @@ fd5_emit_state(struct fd_context *ctx, struct fd_ringbuffer *ring,
uint32_t i;
for (i = 0; i < A5XX_MAX_RENDER_TARGETS; i++) {
enum pipe_format format = pipe_surface_format(pfb->cbufs[i]);
enum pipe_format format = pipe_surface_format(&pfb->cbufs[i]);
bool is_int = util_format_is_pure_integer(format);
bool has_alpha = util_format_has_alpha(format);
uint32_t control = blend->rb_mrt[i].control;

View file

@ -26,7 +26,7 @@
static void
emit_mrt(struct fd_ringbuffer *ring, unsigned nr_bufs,
struct pipe_surface **bufs, const struct fd_gmem_stateobj *gmem)
struct pipe_surface *bufs, const struct fd_gmem_stateobj *gmem)
{
enum a5xx_tile_mode tile_mode;
unsigned i;
@ -47,8 +47,8 @@ emit_mrt(struct fd_ringbuffer *ring, unsigned nr_bufs,
tile_mode = TILE5_LINEAR;
}
if ((i < nr_bufs) && bufs[i]) {
struct pipe_surface *psurf = bufs[i];
if ((i < nr_bufs) && bufs[i].texture) {
struct pipe_surface *psurf = &bufs[i];
enum pipe_format pformat = psurf->format;
rsc = fd_resource(psurf->texture);
@ -88,7 +88,7 @@ emit_mrt(struct fd_ringbuffer *ring, unsigned nr_bufs,
COND(srgb, A5XX_RB_MRT_BUF_INFO_COLOR_SRGB));
OUT_RING(ring, A5XX_RB_MRT_PITCH(stride));
OUT_RING(ring, A5XX_RB_MRT_ARRAY_PITCH(size));
if (gmem || (i >= nr_bufs) || !bufs[i]) {
if (gmem || (i >= nr_bufs) || !bufs[i].texture) {
OUT_RING(ring, base); /* RB_MRT[i].BASE_LO */
OUT_RING(ring, 0x00000000); /* RB_MRT[i].BASE_HI */
} else {
@ -116,7 +116,7 @@ static void
emit_zs(struct fd_ringbuffer *ring, struct pipe_surface *zsbuf,
const struct fd_gmem_stateobj *gmem)
{
if (zsbuf) {
if (zsbuf->texture) {
struct fd_resource *rsc = fd_resource(zsbuf->texture);
enum a5xx_depth_format fmt = fd5_pipe2depth(zsbuf->format);
uint32_t cpp = rsc->layout.cpp;
@ -404,7 +404,7 @@ fd5_emit_tile_init(struct fd_batch *batch) assert_dt
OUT_PKT4(ring, REG_A5XX_RB_CCU_CNTL, 1);
OUT_RING(ring, 0x7c13c080); /* RB_CCU_CNTL */
emit_zs(ring, pfb->zsbuf, batch->gmem_state);
emit_zs(ring, &pfb->zsbuf, batch->gmem_state);
emit_mrt(ring, pfb->nr_cbufs, pfb->cbufs, batch->gmem_state);
/* Enable stream output for the first pass (likely the binning). */
@ -556,7 +556,7 @@ fd5_emit_tile_mem2gmem(struct fd_batch *batch, const struct fd_tile *tile)
*/
emit_mrt(ring, pfb->nr_cbufs, pfb->cbufs, NULL);
// emit_zs(ring, pfb->zsbuf, NULL);
// emit_zs(ring, &pfb->zsbuf, NULL);
OUT_PKT4(ring, REG_A5XX_RB_CNTL, 1);
OUT_RING(ring, A5XX_RB_CNTL_WIDTH(gmem->bin_w) |
@ -565,23 +565,23 @@ fd5_emit_tile_mem2gmem(struct fd_batch *batch, const struct fd_tile *tile)
if (fd_gmem_needs_restore(batch, tile, FD_BUFFER_COLOR)) {
unsigned i;
for (i = 0; i < pfb->nr_cbufs; i++) {
if (!pfb->cbufs[i])
if (!pfb->cbufs[i].texture)
continue;
if (!(batch->restore & (PIPE_CLEAR_COLOR0 << i)))
continue;
emit_mem2gmem_surf(batch, gmem->cbuf_base[i], pfb->cbufs[i],
emit_mem2gmem_surf(batch, gmem->cbuf_base[i], &pfb->cbufs[i],
BLIT_MRT0 + i);
}
}
if (fd_gmem_needs_restore(batch, tile,
FD_BUFFER_DEPTH | FD_BUFFER_STENCIL)) {
struct fd_resource *rsc = fd_resource(pfb->zsbuf->texture);
struct fd_resource *rsc = fd_resource(pfb->zsbuf.texture);
if (!rsc->stencil || fd_gmem_needs_restore(batch, tile, FD_BUFFER_DEPTH))
emit_mem2gmem_surf(batch, gmem->zsbuf_base[0], pfb->zsbuf, BLIT_ZS);
emit_mem2gmem_surf(batch, gmem->zsbuf_base[0], &pfb->zsbuf, BLIT_ZS);
if (rsc->stencil && fd_gmem_needs_restore(batch, tile, FD_BUFFER_STENCIL))
emit_mem2gmem_surf(batch, gmem->zsbuf_base[1], pfb->zsbuf, BLIT_S);
emit_mem2gmem_surf(batch, gmem->zsbuf_base[1], &pfb->zsbuf, BLIT_S);
}
}
@ -597,7 +597,7 @@ fd5_emit_tile_renderprep(struct fd_batch *batch, const struct fd_tile *tile)
OUT_RING(ring,
A5XX_RB_CNTL_WIDTH(gmem->bin_w) | A5XX_RB_CNTL_HEIGHT(gmem->bin_h));
emit_zs(ring, pfb->zsbuf, gmem);
emit_zs(ring, &pfb->zsbuf, gmem);
emit_mrt(ring, pfb->nr_cbufs, pfb->cbufs, gmem);
emit_msaa(ring, pfb->samples);
}
@ -660,22 +660,22 @@ fd5_emit_tile_gmem2mem(struct fd_batch *batch, const struct fd_tile *tile)
struct pipe_framebuffer_state *pfb = &batch->framebuffer;
if (batch->resolve & (FD_BUFFER_DEPTH | FD_BUFFER_STENCIL)) {
struct fd_resource *rsc = fd_resource(pfb->zsbuf->texture);
struct fd_resource *rsc = fd_resource(pfb->zsbuf.texture);
if (!rsc->stencil || (batch->resolve & FD_BUFFER_DEPTH))
emit_gmem2mem_surf(batch, gmem->zsbuf_base[0], pfb->zsbuf, BLIT_ZS);
emit_gmem2mem_surf(batch, gmem->zsbuf_base[0], &pfb->zsbuf, BLIT_ZS);
if (rsc->stencil && (batch->resolve & FD_BUFFER_STENCIL))
emit_gmem2mem_surf(batch, gmem->zsbuf_base[1], pfb->zsbuf, BLIT_S);
emit_gmem2mem_surf(batch, gmem->zsbuf_base[1], &pfb->zsbuf, BLIT_S);
}
if (batch->resolve & FD_BUFFER_COLOR) {
unsigned i;
for (i = 0; i < pfb->nr_cbufs; i++) {
if (!pfb->cbufs[i])
if (!pfb->cbufs[i].texture)
continue;
if (!(batch->resolve & (PIPE_CLEAR_COLOR0 << i)))
continue;
emit_gmem2mem_surf(batch, gmem->cbuf_base[i], pfb->cbufs[i],
emit_gmem2mem_surf(batch, gmem->cbuf_base[i], &pfb->cbufs[i],
BLIT_MRT0 + i);
}
}
@ -757,7 +757,7 @@ fd5_emit_sysmem_prep(struct fd_batch *batch) assert_dt
patch_draws(batch, IGNORE_VISIBILITY);
emit_zs(ring, pfb->zsbuf, NULL);
emit_zs(ring, &pfb->zsbuf, NULL);
emit_mrt(ring, pfb->nr_cbufs, pfb->cbufs, NULL);
emit_msaa(ring, pfb->samples);
}

View file

@ -1127,9 +1127,9 @@ fd6_resolve_tile(struct fd_batch *batch, struct fd_ringbuffer *ring,
OUT_REG(ring,
A6XX_GRAS_2D_SRC_TL_X(0),
A6XX_GRAS_2D_SRC_BR_X(width - 1),
A6XX_GRAS_2D_SRC_BR_X(pipe_surface_width(psurf) - 1),
A6XX_GRAS_2D_SRC_TL_Y(0),
A6XX_GRAS_2D_SRC_BR_Y(height - 1),
A6XX_GRAS_2D_SRC_BR_Y(pipe_surface_height(psurf) - 1),
);
/* Enable scissor bit, which will take into account the window scissor
@ -1160,8 +1160,8 @@ fd6_resolve_tile(struct fd_batch *batch, struct fd_ringbuffer *ring,
),
SP_PS_2D_SRC_SIZE(
CHIP,
.width = width,
.height = height,
.width = pipe_surface_width(psurf),
.height = pipe_surface_height(psurf),
),
SP_PS_2D_SRC(
CHIP,

View file

@ -118,7 +118,7 @@ fd6_vertex_state_delete(struct pipe_context *pctx, void *hwcso)
}
static void
validate_surface(struct pipe_context *pctx, struct pipe_surface *psurf)
validate_surface(struct pipe_context *pctx, const struct pipe_surface *psurf)
assert_dt
{
fd6_validate_format(fd_context(pctx), fd_resource(psurf->texture),
@ -130,13 +130,13 @@ fd6_set_framebuffer_state(struct pipe_context *pctx,
const struct pipe_framebuffer_state *pfb)
in_dt
{
if (pfb->zsbuf)
validate_surface(pctx, pfb->zsbuf);
if (pfb->zsbuf.texture)
validate_surface(pctx, &pfb->zsbuf);
for (unsigned i = 0; i < pfb->nr_cbufs; i++) {
if (!pfb->cbufs[i])
if (!pfb->cbufs[i].texture)
continue;
validate_surface(pctx, pfb->cbufs[i]);
validate_surface(pctx, &pfb->cbufs[i]);
}
fd_set_framebuffer_state(pctx, pfb);

View file

@ -583,10 +583,10 @@ do_lrz_clear(struct fd_context *ctx, enum fd_buffer_mask buffers)
{
struct pipe_framebuffer_state *pfb = &ctx->batch->framebuffer;
if (!pfb->zsbuf)
if (!pfb->zsbuf.texture)
return false;
struct fd_resource *zsbuf = fd_resource(pfb->zsbuf->texture);
struct fd_resource *zsbuf = fd_resource(pfb->zsbuf.texture);
return (buffers & FD_BUFFER_DEPTH) && zsbuf->lrz;
}
@ -626,7 +626,7 @@ fd6_clear(struct fd_context *ctx, enum fd_buffer_mask buffers,
* would cause LRZ state to be invalid.
*/
if (do_lrz_clear(ctx, buffers)) {
struct fd_resource *zsbuf = fd_resource(pfb->zsbuf->texture);
struct fd_resource *zsbuf = fd_resource(pfb->zsbuf.texture);
fd_bo_del(subpass->lrz);
subpass->lrz = fd_bo_new(ctx->screen->dev, fd_bo_size(zsbuf->lrz),
@ -637,7 +637,7 @@ fd6_clear(struct fd_context *ctx, enum fd_buffer_mask buffers,
}
if (do_lrz_clear(ctx, buffers)) {
struct fd_resource *zsbuf = fd_resource(pfb->zsbuf->texture);
struct fd_resource *zsbuf = fd_resource(pfb->zsbuf.texture);
zsbuf->lrz_valid = true;
zsbuf->lrz_direction = FD_LRZ_UNKNOWN;

View file

@ -116,7 +116,7 @@ compute_lrz_state(struct fd6_emit *emit) assert_dt
struct pipe_framebuffer_state *pfb = &ctx->batch->framebuffer;
struct fd6_lrz_state lrz;
if (!pfb->zsbuf) {
if (!pfb->zsbuf.texture) {
memset(&lrz, 0, sizeof(lrz));
lrz.z_mode = compute_ztest_mode(emit, false);
return lrz;
@ -124,7 +124,7 @@ compute_lrz_state(struct fd6_emit *emit) assert_dt
struct fd6_blend_stateobj *blend = fd6_blend_stateobj(ctx->blend);
struct fd6_zsa_stateobj *zsa = fd6_zsa_stateobj(ctx->zsa);
struct fd_resource *rsc = fd_resource(pfb->zsbuf->texture);
struct fd_resource *rsc = fd_resource(pfb->zsbuf.texture);
bool reads_dest = blend->reads_dest;
lrz = zsa->lrz;
@ -329,7 +329,7 @@ build_prog_fb_rast(struct fd6_emit *emit) assert_dt
unsigned mrt_components = 0;
for (unsigned i = 0; i < pfb->nr_cbufs; i++) {
if (!pfb->cbufs[i])
if (!pfb->cbufs[i].texture)
continue;
mrt_components |= 0xf << (i * 4);
}
@ -611,7 +611,7 @@ fd6_emit_3d_state(struct fd_ringbuffer *ring, struct fd6_emit *emit)
case FD6_GROUP_ZSA:
state = fd6_zsa_state(
ctx,
util_format_is_pure_integer(pipe_surface_format(pfb->cbufs[0])),
util_format_is_pure_integer(pipe_surface_format(&pfb->cbufs[0])),
fd_depth_clamp_enabled(ctx));
fd6_state_add_group(&emit->state, state, FD6_GROUP_ZSA);
break;

View file

@ -79,10 +79,10 @@ emit_mrt(struct fd_ringbuffer *ring, struct pipe_framebuffer_state *pfb,
uint32_t array_stride = 0;
uint32_t offset;
if (!pfb->cbufs[i])
if (!pfb->cbufs[i].texture)
continue;
struct pipe_surface *psurf = pfb->cbufs[i];
struct pipe_surface *psurf = &pfb->cbufs[i];
enum pipe_format pformat = psurf->format;
rsc = fd_resource(psurf->texture);
@ -133,8 +133,8 @@ emit_mrt(struct fd_ringbuffer *ring, struct pipe_framebuffer_state *pfb,
if (i == 0)
mrt0_format = format;
}
if (pfb->zsbuf)
max_layer_index = pfb->zsbuf->u.tex.last_layer - pfb->zsbuf->u.tex.first_layer;
if (pfb->zsbuf.texture)
max_layer_index = pfb->zsbuf.u.tex.last_layer - pfb->zsbuf.u.tex.first_layer;
OUT_REG(ring, A6XX_GRAS_LRZ_MRT_BUF_INFO_0(.color_format = mrt0_format));
@ -149,7 +149,7 @@ static void
emit_zs(struct fd_context *ctx, struct fd_ringbuffer *ring,
struct pipe_surface *zsbuf, const struct fd_gmem_stateobj *gmem)
{
if (zsbuf) {
if (zsbuf->texture) {
struct fd_resource *rsc = fd_resource(zsbuf->texture);
struct fd_resource *stencil = rsc->stencil;
uint32_t stride = fd_resource_pitch(rsc, zsbuf->u.tex.level);
@ -269,7 +269,7 @@ emit_lrz(struct fd_batch *batch, struct fd_batch_subpass *subpass)
*/
fd6_event_write<CHIP>(batch->ctx, ring, FD_LRZ_FLUSH);
struct fd_resource *zsbuf = fd_resource(pfb->zsbuf->texture);
struct fd_resource *zsbuf = fd_resource(pfb->zsbuf.texture);
OUT_REG(ring,
A6XX_GRAS_LRZ_BUFFER_BASE(.bo = subpass->lrz),
A6XX_GRAS_LRZ_BUFFER_PITCH(.pitch = zsbuf->lrz_layout.lrz_pitch),
@ -283,7 +283,7 @@ emit_lrz(struct fd_batch *batch, struct fd_batch_subpass *subpass)
if (CHIP >= A7XX) {
OUT_REG(ring,
A7XX_GRAS_LRZ_DEPTH_BUFFER_INFO(
.depth_format = fd6_pipe2depth(pfb->zsbuf->format),
.depth_format = fd6_pipe2depth(pfb->zsbuf.format),
)
);
}
@ -299,10 +299,10 @@ emit_lrz_clears(struct fd_batch *batch)
struct fd_context *ctx = batch->ctx;
unsigned count = 0;
if (!pfb->zsbuf)
if (!pfb->zsbuf.texture)
return;
struct fd_resource *zsbuf = fd_resource(pfb->zsbuf->texture);
struct fd_resource *zsbuf = fd_resource(pfb->zsbuf.texture);
foreach_subpass (subpass, batch) {
/* The lrz buffer isn't explicitly tracked by the batch resource
@ -393,7 +393,7 @@ patch_fb_read_gmem(struct fd_batch *batch)
struct fd_cs_patch *patch =
fd_patch_element(&batch->fb_read_patches, i);
int buf = patch->val;
struct pipe_surface *psurf = pfb->cbufs[buf];
struct pipe_surface *psurf = &pfb->cbufs[buf];
struct pipe_resource *prsc = psurf->texture;
struct fd_resource *rsc = fd_resource(prsc);
enum pipe_format format = psurf->format;
@ -449,8 +449,8 @@ patch_fb_read_sysmem(struct fd_batch *batch)
fd_patch_element(&batch->fb_read_patches, i);
int buf = patch->val;
struct pipe_surface *psurf = pfb->cbufs[buf];
if (!psurf)
struct pipe_surface *psurf = &pfb->cbufs[buf];
if (!psurf->texture)
return;
struct pipe_resource *prsc = psurf->texture;
@ -514,17 +514,17 @@ update_render_cntl(struct fd_batch *batch, struct pipe_framebuffer_state *pfb,
uint32_t mrts_ubwc_enable = 0;
int i;
if (pfb->zsbuf) {
struct fd_resource *rsc = fd_resource(pfb->zsbuf->texture);
if (pfb->zsbuf.texture) {
struct fd_resource *rsc = fd_resource(pfb->zsbuf.texture);
depth_ubwc_enable =
fd_resource_ubwc_enabled(rsc, pfb->zsbuf->u.tex.level);
fd_resource_ubwc_enabled(rsc, pfb->zsbuf.u.tex.level);
}
for (i = 0; i < pfb->nr_cbufs; i++) {
if (!pfb->cbufs[i])
if (!pfb->cbufs[i].texture)
continue;
struct pipe_surface *psurf = pfb->cbufs[i];
struct pipe_surface *psurf = &pfb->cbufs[i];
struct fd_resource *rsc = fd_resource(psurf->texture);
if (fd_resource_ubwc_enabled(rsc, psurf->u.tex.level))
@ -1143,7 +1143,7 @@ fd6_emit_tile_init(struct fd_batch *batch) assert_dt
fd6_emit_ccu_cntl<CHIP>(ring, screen, true);
emit_zs<CHIP>(batch->ctx, ring, pfb->zsbuf, batch->gmem_state);
emit_zs<CHIP>(batch->ctx, ring, &pfb->zsbuf, batch->gmem_state);
emit_mrt<CHIP>(ring, pfb, batch->gmem_state);
emit_msaa(ring, pfb->samples);
patch_fb_read_gmem(batch);
@ -1263,7 +1263,7 @@ fd6_emit_tile_prep(struct fd_batch *batch, const struct fd_tile *tile)
fd6_emit_ccu_cntl<CHIP>(ring, screen, true);
emit_zs<CHIP>(batch->ctx, ring, pfb->zsbuf, batch->gmem_state);
emit_zs<CHIP>(batch->ctx, ring, &pfb->zsbuf, batch->gmem_state);
emit_mrt<CHIP>(ring, pfb, batch->gmem_state);
emit_msaa(ring, pfb->samples);
@ -1466,13 +1466,13 @@ emit_subpass_clears(struct fd_batch *batch, struct fd_batch_subpass *subpass)
union pipe_color_union *color = &subpass->clear_color[i];
union util_color uc = {0};
if (!pfb->cbufs[i])
if (!pfb->cbufs[i].texture)
continue;
if (!(buffers & (PIPE_CLEAR_COLOR0 << i)))
continue;
enum pipe_format pfmt = pfb->cbufs[i]->format;
enum pipe_format pfmt = pfb->cbufs[i].format;
// XXX I think RB_CLEAR_COLOR_DWn wants to take into account SWAP??
union pipe_color_union swapped;
@ -1534,22 +1534,22 @@ emit_subpass_clears(struct fd_batch *batch, struct fd_batch_subpass *subpass)
}
}
const bool has_depth = pfb->zsbuf;
const bool has_depth = !!pfb->zsbuf.texture;
const bool has_separate_stencil =
has_depth && fd_resource(pfb->zsbuf->texture)->stencil;
has_depth && fd_resource(pfb->zsbuf.texture)->stencil;
/* First clear depth or combined depth/stencil. */
if ((has_depth && (buffers & PIPE_CLEAR_DEPTH)) ||
(!has_separate_stencil && (buffers & PIPE_CLEAR_STENCIL))) {
enum pipe_format pfmt = pfb->zsbuf->format;
enum pipe_format pfmt = pfb->zsbuf.format;
uint32_t clear_value;
uint32_t mask = 0;
if (has_separate_stencil) {
pfmt = util_format_get_depth_only(pfb->zsbuf->format);
pfmt = util_format_get_depth_only(pfb->zsbuf.format);
clear_value = util_pack_z(pfmt, subpass->clear_depth);
} else {
pfmt = pfb->zsbuf->format;
pfmt = pfb->zsbuf.format;
clear_value =
util_pack_z_stencil(pfmt, subpass->clear_depth, subpass->clear_stencil);
}
@ -1622,24 +1622,24 @@ emit_restore_blits(struct fd_batch *batch, struct fd_ringbuffer *ring)
if (batch->restore & FD_BUFFER_COLOR) {
unsigned i;
for (i = 0; i < pfb->nr_cbufs; i++) {
if (!pfb->cbufs[i])
if (!pfb->cbufs[i].texture)
continue;
if (!(batch->restore & (PIPE_CLEAR_COLOR0 << i)))
continue;
emit_restore_blit<CHIP>(batch, ring, gmem->cbuf_base[i], pfb->cbufs[i],
emit_restore_blit<CHIP>(batch, ring, gmem->cbuf_base[i], &pfb->cbufs[i],
FD_BUFFER_COLOR);
}
}
if (batch->restore & (FD_BUFFER_DEPTH | FD_BUFFER_STENCIL)) {
struct fd_resource *rsc = fd_resource(pfb->zsbuf->texture);
struct fd_resource *rsc = fd_resource(pfb->zsbuf.texture);
if (!rsc->stencil || (batch->restore & FD_BUFFER_DEPTH)) {
emit_restore_blit<CHIP>(batch, ring, gmem->zsbuf_base[0], pfb->zsbuf,
emit_restore_blit<CHIP>(batch, ring, gmem->zsbuf_base[0], &pfb->zsbuf,
FD_BUFFER_DEPTH);
}
if (rsc->stencil && (batch->restore & FD_BUFFER_STENCIL)) {
emit_restore_blit<CHIP>(batch, ring, gmem->zsbuf_base[1], pfb->zsbuf,
emit_restore_blit<CHIP>(batch, ring, gmem->zsbuf_base[1], &pfb->zsbuf,
FD_BUFFER_STENCIL);
}
}
@ -1821,27 +1821,27 @@ prepare_tile_fini(struct fd_batch *batch)
set_blit_scissor(batch, ring);
if (batch->resolve & (FD_BUFFER_DEPTH | FD_BUFFER_STENCIL)) {
struct fd_resource *rsc = fd_resource(pfb->zsbuf->texture);
struct fd_resource *rsc = fd_resource(pfb->zsbuf.texture);
if (!rsc->stencil || (batch->resolve & FD_BUFFER_DEPTH)) {
emit_resolve_blit<CHIP>(batch, ring, gmem->zsbuf_base[0],
pfb->zsbuf, FD_BUFFER_DEPTH);
&pfb->zsbuf, FD_BUFFER_DEPTH);
}
if (rsc->stencil && (batch->resolve & FD_BUFFER_STENCIL)) {
emit_resolve_blit<CHIP>(batch, ring, gmem->zsbuf_base[1],
pfb->zsbuf, FD_BUFFER_STENCIL);
&pfb->zsbuf, FD_BUFFER_STENCIL);
}
}
if (batch->resolve & FD_BUFFER_COLOR) {
unsigned i;
for (i = 0; i < pfb->nr_cbufs; i++) {
if (!pfb->cbufs[i])
if (!pfb->cbufs[i].texture)
continue;
if (!(batch->resolve & (PIPE_CLEAR_COLOR0 << i)))
continue;
emit_resolve_blit<CHIP>(batch, ring, gmem->cbuf_base[i],
pfb->cbufs[i], FD_BUFFER_COLOR);
&pfb->cbufs[i], FD_BUFFER_COLOR);
}
}
}
@ -1948,35 +1948,35 @@ emit_sysmem_clears(struct fd_batch *batch, struct fd_batch_subpass *subpass)
for (int i = 0; i < pfb->nr_cbufs; i++) {
union pipe_color_union color = subpass->clear_color[i];
if (!pfb->cbufs[i])
if (!pfb->cbufs[i].texture)
continue;
if (!(buffers & (PIPE_CLEAR_COLOR0 << i)))
continue;
fd6_clear_surface<CHIP>(ctx, ring, pfb->cbufs[i], &box2d, &color, 0);
fd6_clear_surface<CHIP>(ctx, ring, &pfb->cbufs[i], &box2d, &color, 0);
}
}
if (buffers & (PIPE_CLEAR_DEPTH | PIPE_CLEAR_STENCIL)) {
union pipe_color_union value = {};
const bool has_depth = pfb->zsbuf;
const bool has_depth = !!pfb->zsbuf.texture;
struct pipe_resource *separate_stencil =
has_depth && fd_resource(pfb->zsbuf->texture)->stencil
? &fd_resource(pfb->zsbuf->texture)->stencil->b.b
has_depth && fd_resource(pfb->zsbuf.texture)->stencil
? &fd_resource(pfb->zsbuf.texture)->stencil->b.b
: NULL;
if ((buffers & PIPE_CLEAR_DEPTH) || (!separate_stencil && (buffers & PIPE_CLEAR_STENCIL))) {
value.f[0] = subpass->clear_depth;
value.ui[1] = subpass->clear_stencil;
fd6_clear_surface<CHIP>(ctx, ring, pfb->zsbuf, &box2d,
&value, fd6_unknown_8c01(pfb->zsbuf->format, buffers));
fd6_clear_surface<CHIP>(ctx, ring, &pfb->zsbuf, &box2d,
&value, fd6_unknown_8c01(pfb->zsbuf.format, buffers));
}
if (separate_stencil && (buffers & PIPE_CLEAR_STENCIL)) {
value.ui[0] = subpass->clear_stencil;
struct pipe_surface stencil_surf = *pfb->zsbuf;
struct pipe_surface stencil_surf = pfb->zsbuf;
stencil_surf.format = PIPE_FORMAT_S8_UINT;
stencil_surf.texture = separate_stencil;
@ -2055,7 +2055,7 @@ fd6_emit_sysmem_prep(struct fd_batch *batch) assert_dt
OUT_PKT7(ring, CP_SET_VISIBILITY_OVERRIDE, 1);
OUT_RING(ring, 0x1);
emit_zs<CHIP>(batch->ctx, ring, pfb->zsbuf, NULL);
emit_zs<CHIP>(batch->ctx, ring, &pfb->zsbuf, NULL);
emit_mrt<CHIP>(ring, pfb, NULL);
emit_msaa(ring, pfb->samples);
patch_fb_read_sysmem<CHIP>(batch);

View file

@ -173,7 +173,7 @@ fd_autotune_use_bypass(struct fd_autotune *at, struct fd_batch *batch)
* implement a temporary render target that we can MSAA resolve
* from
*/
if (pfb->cbufs[i] && pfb->cbufs[i]->nr_samples)
if (pfb->cbufs[i].texture && pfb->cbufs[i].nr_samples)
return fallback_use_bypass(batch);
}

View file

@ -389,10 +389,10 @@ fd_batch_set_fb(struct fd_batch *batch, const struct pipe_framebuffer_state *pfb
util_copy_framebuffer_state(&batch->framebuffer, pfb);
if (!pfb->zsbuf)
if (!pfb->zsbuf.texture)
return;
struct fd_resource *zsbuf = fd_resource(pfb->zsbuf->texture);
struct fd_resource *zsbuf = fd_resource(pfb->zsbuf.texture);
/* Switching back to a batch we'd previously started constructing shouldn't
* result in a different lrz. The dependency tracking should avoid another

View file

@ -544,7 +544,7 @@ batch_from_key(struct fd_context *ctx, struct fd_batch_key *key) assert_dt
static void
key_surf(struct fd_batch_key *key, unsigned idx, unsigned pos,
struct pipe_surface *psurf)
const struct pipe_surface *psurf)
{
key->surf[idx].texture = psurf->texture;
key->surf[idx].u = psurf->u;
@ -557,7 +557,7 @@ struct fd_batch *
fd_batch_from_fb(struct fd_context *ctx,
const struct pipe_framebuffer_state *pfb)
{
unsigned idx = 0, n = pfb->nr_cbufs + (pfb->zsbuf ? 1 : 0);
unsigned idx = 0, n = pfb->nr_cbufs + (pfb->zsbuf.texture ? 1 : 0);
struct fd_batch_key *key = key_alloc(n);
key->width = pfb->width;
@ -566,12 +566,12 @@ fd_batch_from_fb(struct fd_context *ctx,
key->samples = util_framebuffer_get_num_samples(pfb);
key->ctx_seqno = ctx->seqno;
if (pfb->zsbuf)
key_surf(key, idx++, 0, pfb->zsbuf);
if (pfb->zsbuf.texture)
key_surf(key, idx++, 0, &pfb->zsbuf);
for (unsigned i = 0; i < pfb->nr_cbufs; i++)
if (pfb->cbufs[i])
key_surf(key, idx++, i + 1, pfb->cbufs[i]);
if (pfb->cbufs[i].texture)
key_surf(key, idx++, i + 1, &pfb->cbufs[i]);
key->num_surfs = idx;

View file

@ -57,12 +57,12 @@ batch_draw_tracking_for_dirty_bits(struct fd_batch *batch) assert_dt
if (dirty & (FD_DIRTY_FRAMEBUFFER | FD_DIRTY_ZSA)) {
if (fd_depth_enabled(ctx)) {
if (fd_resource(pfb->zsbuf->texture)->valid) {
if (fd_resource(pfb->zsbuf.texture)->valid) {
restore_buffers |= FD_BUFFER_DEPTH;
/* storing packed d/s depth also stores stencil, so we need
* the stencil restored too to avoid invalidating it.
*/
if (pfb->zsbuf->texture->format == PIPE_FORMAT_Z24_UNORM_S8_UINT)
if (pfb->zsbuf.texture->format == PIPE_FORMAT_Z24_UNORM_S8_UINT)
restore_buffers |= FD_BUFFER_STENCIL;
} else {
batch->invalidated |= FD_BUFFER_DEPTH;
@ -70,26 +70,26 @@ batch_draw_tracking_for_dirty_bits(struct fd_batch *batch) assert_dt
batch->gmem_reason |= FD_GMEM_DEPTH_ENABLED;
if (fd_depth_write_enabled(ctx)) {
buffers |= FD_BUFFER_DEPTH;
resource_written(batch, pfb->zsbuf->texture);
resource_written(batch, pfb->zsbuf.texture);
} else {
resource_read(batch, pfb->zsbuf->texture);
resource_read(batch, pfb->zsbuf.texture);
}
}
if (fd_stencil_enabled(ctx)) {
if (fd_resource(pfb->zsbuf->texture)->valid) {
if (fd_resource(pfb->zsbuf.texture)->valid) {
restore_buffers |= FD_BUFFER_STENCIL;
/* storing packed d/s stencil also stores depth, so we need
* the depth restored too to avoid invalidating it.
*/
if (pfb->zsbuf->texture->format == PIPE_FORMAT_Z24_UNORM_S8_UINT)
if (pfb->zsbuf.texture->format == PIPE_FORMAT_Z24_UNORM_S8_UINT)
restore_buffers |= FD_BUFFER_DEPTH;
} else {
batch->invalidated |= FD_BUFFER_STENCIL;
}
batch->gmem_reason |= FD_GMEM_STENCIL_ENABLED;
buffers |= FD_BUFFER_STENCIL;
resource_written(batch, pfb->zsbuf->texture);
resource_written(batch, pfb->zsbuf.texture);
}
}
@ -97,10 +97,10 @@ batch_draw_tracking_for_dirty_bits(struct fd_batch *batch) assert_dt
for (unsigned i = 0; i < pfb->nr_cbufs; i++) {
struct pipe_resource *surf;
if (!pfb->cbufs[i])
if (!pfb->cbufs[i].texture)
continue;
surf = pfb->cbufs[i]->texture;
surf = pfb->cbufs[i].texture;
if (fd_resource(surf)->valid) {
restore_buffers |= PIPE_CLEAR_COLOR0 << i;
@ -110,7 +110,7 @@ batch_draw_tracking_for_dirty_bits(struct fd_batch *batch) assert_dt
buffers |= PIPE_CLEAR_COLOR0 << i;
resource_written(batch, pfb->cbufs[i]->texture);
resource_written(batch, pfb->cbufs[i].texture);
}
}
@ -371,8 +371,8 @@ fd_draw_vbo(struct pipe_context *pctx, const struct pipe_draw_info *info,
struct pipe_framebuffer_state *pfb = &batch->framebuffer;
DBG("%p: %ux%u num_draws=%u (%s/%s)", batch, pfb->width, pfb->height,
batch->num_draws,
util_format_short_name(pipe_surface_format(pfb->cbufs[0])),
util_format_short_name(pipe_surface_format(pfb->zsbuf)));
util_format_short_name(pipe_surface_format(&pfb->cbufs[0])),
util_format_short_name(pipe_surface_format(&pfb->zsbuf)));
batch->cost += ctx->draw_cost;
@ -444,10 +444,10 @@ batch_clear_tracking(struct fd_batch *batch, unsigned buffers) assert_dt
if (buffers & PIPE_CLEAR_COLOR)
for (unsigned i = 0; i < pfb->nr_cbufs; i++)
if (buffers & (PIPE_CLEAR_COLOR0 << i))
resource_written(batch, pfb->cbufs[i]->texture);
resource_written(batch, pfb->cbufs[i].texture);
if (buffers & (PIPE_CLEAR_DEPTH | PIPE_CLEAR_STENCIL)) {
resource_written(batch, pfb->zsbuf->texture);
resource_written(batch, pfb->zsbuf.texture);
batch->gmem_reason |= FD_GMEM_CLEARS_DEPTH_STENCIL;
}
@ -495,8 +495,8 @@ fd_clear(struct pipe_context *pctx, unsigned buffers,
struct pipe_framebuffer_state *pfb = &batch->framebuffer;
DBG("%p: %x %ux%u depth=%f, stencil=%u (%s/%s)", batch, buffers, pfb->width,
pfb->height, depth, stencil,
util_format_short_name(pipe_surface_format(pfb->cbufs[0])),
util_format_short_name(pipe_surface_format(pfb->zsbuf)));
util_format_short_name(pipe_surface_format(&pfb->cbufs[0])),
util_format_short_name(pipe_surface_format(&pfb->zsbuf)));
/* if per-gen backend doesn't implement ctx->clear() generic
* blitter clear:

View file

@ -455,13 +455,13 @@ gmem_key_init(struct fd_batch *batch, bool assume_zs, bool no_scis_opt)
{
struct fd_screen *screen = batch->ctx->screen;
struct pipe_framebuffer_state *pfb = &batch->framebuffer;
bool has_zs = pfb->zsbuf &&
bool has_zs = pfb->zsbuf.texture &&
!!(batch->gmem_reason & (FD_GMEM_DEPTH_ENABLED | FD_GMEM_STENCIL_ENABLED |
FD_GMEM_CLEARS_DEPTH_STENCIL));
struct gmem_key *key = rzalloc(screen->gmem_cache.ht, struct gmem_key);
if (has_zs || assume_zs) {
struct fd_resource *rsc = fd_resource(pfb->zsbuf->texture);
struct fd_resource *rsc = fd_resource(pfb->zsbuf.texture);
key->zsbuf_cpp[0] = rsc->layout.cpp * pfb->samples;
if (rsc->stencil)
key->zsbuf_cpp[1] = rsc->stencil->layout.cpp * pfb->samples;
@ -478,7 +478,7 @@ gmem_key_init(struct fd_batch *batch, bool assume_zs, bool no_scis_opt)
unsigned zsclear = batch->cleared & (FD_BUFFER_DEPTH | FD_BUFFER_STENCIL);
if (zsclear) {
const struct util_format_description *desc =
util_format_description(pfb->zsbuf->format);
util_format_description(pfb->zsbuf.format);
if (util_format_has_depth(desc) && !(zsclear & FD_BUFFER_DEPTH))
batch->restore |= FD_BUFFER_DEPTH;
if (util_format_has_stencil(desc) && !(zsclear & FD_BUFFER_STENCIL))
@ -492,8 +492,8 @@ gmem_key_init(struct fd_batch *batch, bool assume_zs, bool no_scis_opt)
key->nr_cbufs = pfb->nr_cbufs;
for (unsigned i = 0; i < pfb->nr_cbufs; i++) {
if (pfb->cbufs[i])
key->cbuf_cpp[i] = util_format_get_blocksize(pfb->cbufs[i]->format);
if (pfb->cbufs[i].texture)
key->cbuf_cpp[i] = util_format_get_blocksize(pfb->cbufs[i].format);
else
key->cbuf_cpp[i] = 4;
/* if MSAA, color buffers are super-sampled in GMEM: */
@ -727,7 +727,7 @@ fd_gmem_render_tiles(struct fd_batch *batch)
}
/* For ARB_framebuffer_no_attachments: */
if ((pfb->nr_cbufs == 0) && !pfb->zsbuf) {
if ((pfb->nr_cbufs == 0) && !pfb->zsbuf.texture) {
sysmem = true;
}
}
@ -737,13 +737,13 @@ fd_gmem_render_tiles(struct fd_batch *batch)
/* Layered rendering always needs bypass. */
for (unsigned i = 0; i < pfb->nr_cbufs; i++) {
struct pipe_surface *psurf = pfb->cbufs[i];
if (!psurf)
struct pipe_surface *psurf = &pfb->cbufs[i];
if (!psurf->texture)
continue;
if (psurf->u.tex.first_layer < psurf->u.tex.last_layer)
sysmem = true;
}
if (pfb->zsbuf && pfb->zsbuf->u.tex.first_layer < pfb->zsbuf->u.tex.last_layer)
if (pfb->zsbuf.texture && pfb->zsbuf.u.tex.first_layer < pfb->zsbuf.u.tex.last_layer)
sysmem = true;
/* Tessellation doesn't seem to support tiled rendering so fall back to
@ -766,8 +766,8 @@ fd_gmem_render_tiles(struct fd_batch *batch)
} else if (sysmem) {
trace_render_sysmem(&batch->trace, batch->gmem);
trace_start_render_pass(&batch->trace, batch->gmem,
ctx->submit_count, pipe_surface_format(pfb->cbufs[0]),
pipe_surface_format(pfb->zsbuf), pfb->width, pfb->height,
ctx->submit_count, pipe_surface_format(&pfb->cbufs[0]),
pipe_surface_format(&pfb->zsbuf), pfb->width, pfb->height,
pfb->nr_cbufs, pfb->samples, 0, 0, 0);
if (ctx->query_prepare)
ctx->query_prepare(batch, 1);
@ -780,8 +780,8 @@ fd_gmem_render_tiles(struct fd_batch *batch)
trace_render_gmem(&batch->trace, batch->gmem, gmem->nbins_x, gmem->nbins_y,
gmem->bin_w, gmem->bin_h);
trace_start_render_pass(&batch->trace, batch->gmem,
ctx->submit_count, pipe_surface_format(pfb->cbufs[0]),
pipe_surface_format(pfb->zsbuf), pfb->width, pfb->height,
ctx->submit_count, pipe_surface_format(&pfb->cbufs[0]),
pipe_surface_format(&pfb->zsbuf), pfb->width, pfb->height,
pfb->nr_cbufs, pfb->samples, gmem->nbins_x * gmem->nbins_y,
gmem->bin_w, gmem->bin_h);
if (ctx->query_prepare)
@ -810,7 +810,7 @@ fd_gmem_estimate_bins_per_pipe(struct fd_batch *batch)
{
struct pipe_framebuffer_state *pfb = &batch->framebuffer;
struct fd_screen *screen = batch->ctx->screen;
struct fd_gmem_stateobj *gmem = lookup_gmem_state(batch, !!pfb->zsbuf, true);
struct fd_gmem_stateobj *gmem = lookup_gmem_state(batch, !!pfb->zsbuf.texture, true);
unsigned nbins = gmem->maxpw * gmem->maxph;
fd_screen_lock(screen);

View file

@ -1615,13 +1615,13 @@ fd_invalidate_resource(struct pipe_context *pctx,
struct fd_batch *batch = rsc->track->write_batch;
struct pipe_framebuffer_state *pfb = &batch->framebuffer;
if (pfb->zsbuf && pfb->zsbuf->texture == prsc) {
if (pfb->zsbuf.texture == prsc) {
batch->resolve &= ~(FD_BUFFER_DEPTH | FD_BUFFER_STENCIL);
fd_dirty_resource(ctx, prsc, FD_DIRTY_ZSA, true);
}
for (unsigned i = 0; i < pfb->nr_cbufs; i++) {
if (pfb->cbufs[i] && pfb->cbufs[i]->texture == prsc) {
if (pfb->cbufs[i].texture == prsc) {
batch->resolve &= ~(PIPE_CLEAR_COLOR0 << i);
fd_dirty_resource(ctx, prsc, FD_DIRTY_FRAMEBUFFER, true);
}

View file

@ -300,10 +300,10 @@ fd_set_framebuffer_state(struct pipe_context *pctx,
* created.
*/
for (unsigned i = 0; i < framebuffer->nr_cbufs; i++) {
if (!framebuffer->cbufs[i])
if (!framebuffer->cbufs[i].texture)
continue;
enum pipe_format format = framebuffer->cbufs[i]->format;
enum pipe_format format = framebuffer->cbufs[i].format;
unsigned nr = util_format_get_nr_components(format);
ctx->all_mrt_channel_mask |= BITFIELD_MASK(nr) << (4 * i);
@ -325,7 +325,7 @@ fd_set_framebuffer_state(struct pipe_context *pctx,
fd_batch_reference(&old_batch, NULL);
} else if (ctx->batch) {
DBG("%d: cbufs[0]=%p, zsbuf=%p", ctx->batch->needs_flush,
framebuffer->cbufs[0], framebuffer->zsbuf);
framebuffer->cbufs[0].texture, framebuffer->zsbuf.texture);
fd_batch_flush(ctx->batch);
}

View file

@ -17,12 +17,11 @@ struct pipe_surface *
fd_create_surface(struct pipe_context *pctx, struct pipe_resource *ptex,
const struct pipe_surface *surf_tmpl)
{
struct fd_surface *surface = CALLOC_STRUCT(fd_surface);
struct pipe_surface *psurf = CALLOC_STRUCT(pipe_surface);
if (!surface)
if (!psurf)
return NULL;
struct pipe_surface *psurf = &surface->base;
unsigned level = surf_tmpl->u.tex.level;
pipe_reference_init(&psurf->reference, 1);
@ -41,7 +40,7 @@ fd_create_surface(struct pipe_context *pctx, struct pipe_resource *ptex,
psurf->u.tex.last_layer = surf_tmpl->u.tex.last_layer;
}
return &surface->base;
return psurf;
}
void

View file

@ -11,16 +11,6 @@
#include "pipe/p_state.h"
struct fd_surface {
struct pipe_surface base;
};
static inline struct fd_surface *
fd_surface(struct pipe_surface *psurf)
{
return (struct fd_surface *)psurf;
}
struct pipe_surface *fd_create_surface(struct pipe_context *pctx,
struct pipe_resource *ptex,
const struct pipe_surface *surf_tmpl);

View file

@ -307,7 +307,7 @@ fd_half_precision(struct pipe_framebuffer_state *pfb)
unsigned i;
for (i = 0; i < pfb->nr_cbufs; i++)
if (!fd_surface_half_precision(pfb->cbufs[i]))
if (!fd_surface_half_precision(&pfb->cbufs[i]))
return false;
return true;

View file

@ -57,7 +57,7 @@ i915_clear_emit(struct pipe_context *pipe, unsigned buffers,
depth_clear_bbp = color_clear_bbp = 0;
if (buffers & PIPE_CLEAR_COLOR) {
struct pipe_surface *cbuf = i915->framebuffer.cbufs[0];
struct pipe_surface *cbuf = &i915->framebuffer.cbufs[0];
clear_params |= CLEARPARAM_WRITE_COLOR;
cbuf_tex = i915_texture(cbuf->texture);
@ -82,7 +82,7 @@ i915_clear_emit(struct pipe_context *pipe, unsigned buffers,
clear_depth = clear_stencil = 0;
if (buffers & PIPE_CLEAR_DEPTH) {
struct pipe_surface *zbuf = i915->framebuffer.zsbuf;
struct pipe_surface *zbuf = &i915->framebuffer.zsbuf;
clear_params |= CLEARPARAM_WRITE_DEPTH;
depth_tex = i915_texture(zbuf->texture);
@ -104,7 +104,7 @@ i915_clear_emit(struct pipe_context *pipe, unsigned buffers,
depth_clear_bbp = 16;
}
} else if (buffers & PIPE_CLEAR_STENCIL) {
struct pipe_surface *zbuf = i915->framebuffer.zsbuf;
struct pipe_surface *zbuf = &i915->framebuffer.zsbuf;
clear_params |= CLEARPARAM_WRITE_STENCIL;
depth_tex = i915_texture(zbuf->texture);
@ -228,9 +228,9 @@ i915_clear_blitter(struct pipe_context *pipe, unsigned buffers,
for (i = 0; i < framebuffer->nr_cbufs; i++) {
if (buffers & (PIPE_CLEAR_COLOR0 << i)) {
struct pipe_surface *ps = framebuffer->cbufs[i];
struct pipe_surface *ps = &framebuffer->cbufs[i];
if (ps) {
if (ps->texture) {
uint16_t width, height;
pipe_surface_size(ps, &width, &height);
pipe->clear_render_target(pipe, ps, color, 0, 0, width,
@ -240,7 +240,7 @@ i915_clear_blitter(struct pipe_context *pipe, unsigned buffers,
}
if (buffers & PIPE_CLEAR_DEPTHSTENCIL) {
struct pipe_surface *ps = framebuffer->zsbuf;
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,

View file

@ -152,6 +152,7 @@ i915_destroy(struct pipe_context *pipe)
i915->iws->batchbuffer_destroy(i915->batch);
/* unbind framebuffer */
util_framebuffer_init(pipe, NULL, i915->fb_cbufs, &i915->fb_zsbuf);
util_unreference_framebuffer_state(&i915->framebuffer);
/* unbind constant buffers */

View file

@ -40,6 +40,7 @@
#include "util/log.h"
#include "util/slab.h"
#include "util/u_blitter.h"
#include "util/u_framebuffer.h"
#include "i915_reg.h"
struct i915_winsys;
@ -278,6 +279,7 @@ struct i915_context {
struct pipe_stencil_ref stencil_ref;
struct pipe_clip_state clip;
struct pipe_resource *constants[PIPE_SHADER_TYPES];
PIPE_FB_SURFACES; //STOP USING THIS
struct pipe_framebuffer_state framebuffer;
struct pipe_poly_stipple poly_stipple;
struct pipe_scissor_state scissor;

View file

@ -867,9 +867,10 @@ i915_set_framebuffer_state(struct pipe_context *pipe,
{
struct i915_context *i915 = i915_context(pipe);
util_framebuffer_init(pipe, fb, i915->fb_cbufs, &i915->fb_zsbuf);
util_copy_framebuffer_state(&i915->framebuffer, fb);
if (fb->nr_cbufs) {
struct i915_surface *surf = i915_surface(i915->framebuffer.cbufs[0]);
struct i915_surface *surf = i915_surface(i915->fb_cbufs[0]);
if (i915->current.fixup_swizzle != surf->oc_swizzle) {
i915->current.fixup_swizzle = surf->oc_swizzle;
memcpy(i915->current.color_swizzle, surf->color_swizzle,
@ -877,8 +878,8 @@ i915_set_framebuffer_state(struct pipe_context *pipe,
i915->dirty |= I915_NEW_COLOR_SWIZZLE;
}
}
if (fb->zsbuf)
draw_set_zs_format(i915->draw, fb->zsbuf->format);
if (fb->zsbuf.texture)
draw_set_zs_format(i915->draw, fb->zsbuf.format);
i915->dirty |= I915_NEW_FRAMEBUFFER;
}

View file

@ -164,7 +164,7 @@ upload_IAB(struct i915_context *i915)
unsigned iab = 0;
if (i915->blend) {
struct i915_surface *cbuf = i915_surface(i915->framebuffer.cbufs[0]);
struct i915_surface *cbuf = i915_surface(i915->fb_cbufs[0]);
if (cbuf && cbuf->alpha_in_g)
iab |= i915->blend->iab_alpha_in_g;
else if (cbuf && cbuf->alpha_is_x)

View file

@ -112,7 +112,7 @@ validate_immediate(struct i915_context *i915, unsigned *batch_space)
static void
emit_immediate_s5(struct i915_context *i915, uint32_t imm)
{
struct i915_surface *surf = i915_surface(i915->framebuffer.cbufs[0]);
struct i915_surface *surf = i915_surface(i915->fb_cbufs[0]);
if (surf) {
uint32_t writemask = imm & S5_WRITEDISABLE_MASK;

View file

@ -153,13 +153,13 @@ upload_S6(struct i915_context *i915)
/* I915_NEW_FRAMEBUFFER
*/
if (i915->framebuffer.cbufs[0])
if (i915->framebuffer.cbufs[0].texture)
LIS6 |= S6_COLOR_WRITE_ENABLE;
/* I915_NEW_BLEND
*/
if (i915->blend) {
struct i915_surface *cbuf = i915_surface(i915->framebuffer.cbufs[0]);
struct i915_surface *cbuf = i915_surface(i915->fb_cbufs[0]);
if (cbuf && cbuf->alpha_in_g)
LIS6 |= i915->blend->LIS6_alpha_in_g;
else if (cbuf && cbuf->alpha_is_x)

View file

@ -78,8 +78,8 @@ translate_depth_format(enum pipe_format zformat)
static void
update_framebuffer(struct i915_context *i915)
{
struct pipe_surface *cbuf_surface = i915->framebuffer.cbufs[0];
struct pipe_surface *depth_surface = i915->framebuffer.zsbuf;
struct pipe_surface *cbuf_surface = i915->fb_cbufs[0];
struct pipe_surface *depth_surface = i915->fb_zsbuf;
unsigned x, y;
unsigned y1;
int layer;
@ -154,8 +154,8 @@ struct i915_tracked_state i915_hw_framebuffer = {
static void
update_dst_buf_vars(struct i915_context *i915)
{
struct pipe_surface *cbuf_surface = i915->framebuffer.cbufs[0];
struct pipe_surface *depth_surface = i915->framebuffer.zsbuf;
struct pipe_surface *cbuf_surface = i915->fb_cbufs[0];
struct pipe_surface *depth_surface = i915->fb_zsbuf;
uint32_t dst_buf_vars, cformat, zformat;
uint32_t early_z = 0;

View file

@ -136,15 +136,14 @@ i915_clear_render_target_render(struct pipe_context *pipe,
unsigned height, bool render_condition_enabled)
{
struct i915_context *i915 = i915_context(pipe);
struct pipe_framebuffer_state fb_state;
struct pipe_framebuffer_state fb_state = {0};
util_blitter_save_framebuffer(i915->blitter, &i915->framebuffer);
fb_state.width = width;
fb_state.height = height;
fb_state.nr_cbufs = 1;
fb_state.cbufs[0] = dst;
fb_state.zsbuf = NULL;
fb_state.cbufs[0] = *dst;
pipe->set_framebuffer_state(pipe, &fb_state);
if (i915->dirty)
@ -173,7 +172,7 @@ i915_clear_depth_stencil_render(struct pipe_context *pipe,
fb_state.width = width;
fb_state.height = height;
fb_state.nr_cbufs = 0;
fb_state.zsbuf = dst;
fb_state.zsbuf = *dst;
pipe->set_framebuffer_state(pipe, &fb_state);
if (i915->dirty)

View file

@ -743,7 +743,7 @@ iris_clear(struct pipe_context *ctx,
}
if (buffers & PIPE_CLEAR_DEPTHSTENCIL) {
struct pipe_surface *psurf = cso_fb->zsbuf;
struct pipe_surface *psurf = &cso_fb->zsbuf;
box.depth = psurf->u.tex.last_layer - psurf->u.tex.first_layer + 1;
box.z = psurf->u.tex.first_layer,
@ -756,7 +756,7 @@ iris_clear(struct pipe_context *ctx,
if (buffers & PIPE_CLEAR_COLOR) {
for (unsigned i = 0; i < cso_fb->nr_cbufs; i++) {
if (buffers & (PIPE_CLEAR_COLOR0 << i)) {
struct pipe_surface *psurf = cso_fb->cbufs[i];
struct pipe_surface *psurf = ice->state.fb_cbufs[i];
struct iris_surface *isurf = (void *) psurf;
box.depth = psurf->u.tex.last_layer - psurf->u.tex.first_layer + 1,
box.z = psurf->u.tex.first_layer,

View file

@ -229,6 +229,9 @@ iris_destroy_context(struct pipe_context *ctx)
screen->vtbl.destroy_state(ice);
util_framebuffer_init(ctx, NULL, ice->state.fb_cbufs, &ice->state.fb_zsbuf);
util_unreference_framebuffer_state(&ice->state.framebuffer);
for (unsigned i = 0; i < ARRAY_SIZE(ice->shaders.scratch_surfs); i++)
pipe_resource_reference(&ice->shaders.scratch_surfs[i].res, NULL);

View file

@ -30,6 +30,7 @@
#include "util/slab.h"
#include "util/u_debug.h"
#include "util/macros.h"
#include "util/u_framebuffer.h"
#include "util/u_threaded_context.h"
#include "intel/blorp/blorp.h"
#include "intel/dev/intel_debug.h"
@ -1008,6 +1009,7 @@ struct iris_context {
struct pipe_viewport_state viewports[IRIS_MAX_VIEWPORTS];
struct pipe_scissor_state scissors[IRIS_MAX_VIEWPORTS];
struct pipe_stencil_ref stencil_ref;
PIPE_FB_SURFACES; //STOP USING THIS
struct pipe_framebuffer_state framebuffer;
struct pipe_clip_state clip_planes;
/* width and height treated like x2 and y2 */

Some files were not shown because too many files have changed in this diff Show more