diff options
author | Jonathan Gray <jsg@cvs.openbsd.org> | 2023-11-02 04:53:47 +0000 |
---|---|---|
committer | Jonathan Gray <jsg@cvs.openbsd.org> | 2023-11-02 04:53:47 +0000 |
commit | b44518130b33cadb5c1d619e9e936ae0e0dbf7cb (patch) | |
tree | 6069eb03c39fbc79808a7d94f857118cce75cbe3 /lib/mesa/src/gallium/drivers/freedreno/freedreno_state.c | |
parent | 32aeb3c41fedbbd7b11aacfec48e8f699d16bff0 (diff) |
Merge Mesa 23.1.9
Diffstat (limited to 'lib/mesa/src/gallium/drivers/freedreno/freedreno_state.c')
-rw-r--r-- | lib/mesa/src/gallium/drivers/freedreno/freedreno_state.c | 70 |
1 files changed, 47 insertions, 23 deletions
diff --git a/lib/mesa/src/gallium/drivers/freedreno/freedreno_state.c b/lib/mesa/src/gallium/drivers/freedreno/freedreno_state.c index f5bcd886c..a5da323c4 100644 --- a/lib/mesa/src/gallium/drivers/freedreno/freedreno_state.c +++ b/lib/mesa/src/gallium/drivers/freedreno/freedreno_state.c @@ -147,14 +147,10 @@ fd_set_constant_buffer(struct pipe_context *pctx, enum pipe_shader_type shader, fd_context_dirty_shader(ctx, shader, FD_DIRTY_SHADER_CONST); fd_resource_set_usage(cb->buffer, FD_DIRTY_CONST); - - if (index > 0) { - assert(!cb->user_buffer); - ctx->dirty |= FD_DIRTY_RESOURCE; - } + fd_dirty_shader_resource(ctx, cb->buffer, shader, FD_DIRTY_SHADER_CONST, false); } -static void +void fd_set_shader_buffers(struct pipe_context *pctx, enum pipe_shader_type shader, unsigned start, unsigned count, const struct pipe_shader_buffer *buffers, @@ -172,20 +168,19 @@ fd_set_shader_buffers(struct pipe_context *pctx, enum pipe_shader_type shader, struct pipe_shader_buffer *buf = &so->sb[n]; if (buffers && buffers[i].buffer) { - if ((buf->buffer == buffers[i].buffer) && - (buf->buffer_offset == buffers[i].buffer_offset) && - (buf->buffer_size == buffers[i].buffer_size)) - continue; - buf->buffer_offset = buffers[i].buffer_offset; buf->buffer_size = buffers[i].buffer_size; pipe_resource_reference(&buf->buffer, buffers[i].buffer); + bool write = writable_bitmask & BIT(i); + fd_resource_set_usage(buffers[i].buffer, FD_DIRTY_SSBO); + fd_dirty_shader_resource(ctx, buffers[i].buffer, shader, + FD_DIRTY_SHADER_SSBO, write); so->enabled_mask |= BIT(n); - if (writable_bitmask & BIT(i)) { + if (write) { struct fd_resource *rsc = fd_resource(buf->buffer); util_range_add(&rsc->b.b, &rsc->valid_buffer_range, buf->buffer_offset, @@ -227,12 +222,14 @@ fd_set_shader_images(struct pipe_context *pctx, enum pipe_shader_type shader, util_copy_image_view(buf, &images[i]); if (buf->resource) { + bool write = buf->access & PIPE_IMAGE_ACCESS_WRITE; + fd_resource_set_usage(buf->resource, FD_DIRTY_IMAGE); + fd_dirty_shader_resource(ctx, buf->resource, shader, + FD_DIRTY_SHADER_IMAGE, write); so->enabled_mask |= BIT(n); - if ((buf->access & PIPE_IMAGE_ACCESS_WRITE) && - (buf->resource->target == PIPE_BUFFER)) { - + if (write && (buf->resource->target == PIPE_BUFFER)) { struct fd_resource *rsc = fd_resource(buf->resource); util_range_add(&rsc->b.b, &rsc->valid_buffer_range, buf->u.buf.offset, @@ -290,6 +287,25 @@ fd_set_framebuffer_state(struct pipe_context *pctx, util_copy_framebuffer_state(cso, framebuffer); + STATIC_ASSERT((4 * PIPE_MAX_COLOR_BUFS) == (8 * sizeof(ctx->all_mrt_channel_mask))); + ctx->all_mrt_channel_mask = 0; + + /* Generate a bitmask of all valid channels for all MRTs. Blend + * state with unwritten channels essentially acts as blend enabled, + * which disables LRZ write. But only if the cbuf *has* the masked + * channels, which is not known at the time the blend state is + * created. + */ + for (unsigned i = 0; i < framebuffer->nr_cbufs; i++) { + if (!framebuffer->cbufs[i]) + continue; + + 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); + } + cso->samples = util_framebuffer_get_num_samples(cso); if (ctx->screen->reorder) { @@ -302,7 +318,6 @@ fd_set_framebuffer_state(struct pipe_context *pctx, fd_batch_reference(&ctx->batch, NULL); fd_context_all_dirty(ctx); - ctx->update_active_queries = true; fd_batch_reference(&old_batch, NULL); } else if (ctx->batch) { @@ -394,10 +409,10 @@ fd_set_viewport_states(struct pipe_context *pctx, unsigned start_slot, /* Handle inverted viewports. */ if (minx > maxx) { - swap(minx, maxx); + SWAP(minx, maxx); } if (miny > maxy) { - swap(miny, maxy); + SWAP(miny, maxy); } const float max_dims = ctx->screen->gen >= 4 ? 16384.f : 4096.f; @@ -475,6 +490,7 @@ fd_set_vertex_buffers(struct pipe_context *pctx, unsigned start_slot, for (unsigned i = 0; i < count; i++) { assert(!vb[i].is_user_buffer); fd_resource_set_usage(vb[i].buffer.resource, FD_DIRTY_VTXBUF); + fd_dirty_resource(ctx, vb[i].buffer.resource, FD_DIRTY_VTXBUF, false); /* Robust buffer access: Return undefined data (the start of the buffer) * instead of process termination or a GPU hang in case of overflow. @@ -496,10 +512,16 @@ fd_blend_state_bind(struct pipe_context *pctx, void *hwcso) in_dt : false; bool new_is_dual = cso ? cso->rt[0].blend_enable && util_blend_state_is_dual(cso, 0) : false; - ctx->blend = hwcso; fd_context_dirty(ctx, FD_DIRTY_BLEND); if (old_is_dual != new_is_dual) fd_context_dirty(ctx, FD_DIRTY_BLEND_DUAL); + + bool old_coherent = get_safe(ctx->blend, blend_coherent); + bool new_coherent = get_safe(cso, blend_coherent); + if (new_coherent != old_coherent) { + fd_context_dirty(ctx, FD_DIRTY_BLEND_COHERENT); + } + ctx->blend = hwcso; update_draw_cost(ctx); } @@ -658,6 +680,11 @@ fd_set_stream_output_targets(struct pipe_context *pctx, unsigned num_targets, so->reset |= (reset << i); + if (targets[i]) { + fd_resource_set_usage(targets[i]->buffer, FD_DIRTY_STREAMOUT); + fd_dirty_resource(ctx, targets[i]->buffer, FD_DIRTY_STREAMOUT, true); + } + if (!changed && !reset) continue; @@ -669,8 +696,6 @@ fd_set_stream_output_targets(struct pipe_context *pctx, unsigned num_targets, ctx->streamout.verts_written = 0; } - if (so->targets[i]) - fd_resource_set_usage(so->targets[i]->buffer, FD_DIRTY_STREAMOUT); pipe_so_target_reference(&so->targets[i], targets[i]); } @@ -688,8 +713,7 @@ fd_bind_compute_state(struct pipe_context *pctx, void *state) in_dt { struct fd_context *ctx = fd_context(pctx); ctx->compute = state; - /* NOTE: Don't mark FD_DIRTY_PROG for compute specific state */ - ctx->dirty_shader[PIPE_SHADER_COMPUTE] |= FD_DIRTY_SHADER_PROG; + fd_context_dirty_shader(ctx, PIPE_SHADER_COMPUTE, FD_DIRTY_SHADER_PROG); } /* TODO pipe_context::set_compute_resources() should DIAF and clover |