v3d: store number of color buffers in job

Avoids requiring to calculate in other places.

Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Signed-off-by: Juan A. Suarez Romero <jasuarez@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7816>
This commit is contained in:
Juan A. Suarez Romero 2020-12-02 13:53:17 +01:00 committed by Marge Bot
parent e3d0abcb2a
commit 1ebdeb3c43
4 changed files with 19 additions and 19 deletions

View File

@ -337,6 +337,7 @@ struct v3d_job {
uint32_t bo_handles_size;
/** @{ Surfaces to submit rendering for. */
uint32_t nr_cbufs;
struct pipe_surface *cbufs[4];
struct pipe_surface *zsbuf;
/** @} */
@ -645,6 +646,7 @@ void v3d_job_init(struct v3d_context *v3d);
struct v3d_job *v3d_job_create(struct v3d_context *v3d);
void v3d_job_free(struct v3d_context *v3d, struct v3d_job *job);
struct v3d_job *v3d_get_job(struct v3d_context *v3d,
uint32_t nr_cbufs,
struct pipe_surface **cbufs,
struct pipe_surface *zsbuf);
struct v3d_job *v3d_get_job_for_fbo(struct v3d_context *v3d);

View File

@ -55,7 +55,7 @@ v3d_job_free(struct v3d_context *v3d, struct v3d_job *job)
}
}
for (int i = 0; i < V3D_MAX_DRAW_BUFFERS; i++) {
for (int i = 0; i < job->nr_cbufs; i++) {
if (job->cbufs[i]) {
_mesa_hash_table_remove_key(v3d->write_jobs,
job->cbufs[i]->texture);
@ -294,7 +294,7 @@ v3d_job_set_tile_buffer_size(struct v3d_job *job)
tile_size_index++;
int max_bpp = RENDER_TARGET_MAXIMUM_32BPP;
for (int i = 0; i < V3D_MAX_DRAW_BUFFERS; i++) {
for (int i = 0; i < job->nr_cbufs; i++) {
if (job->cbufs[i]) {
struct v3d_surface *surf = v3d_surface(job->cbufs[i]);
max_bpp = MAX2(max_bpp, surf->internal_bpp);
@ -319,7 +319,9 @@ v3d_job_set_tile_buffer_size(struct v3d_job *job)
*/
struct v3d_job *
v3d_get_job(struct v3d_context *v3d,
struct pipe_surface **cbufs, struct pipe_surface *zsbuf)
uint32_t nr_cbufs,
struct pipe_surface **cbufs,
struct pipe_surface *zsbuf)
{
/* Return the existing job for this FBO if we have one */
struct v3d_job_key local_key = {
@ -340,8 +342,9 @@ v3d_get_job(struct v3d_context *v3d,
* writing these buffers are flushed.
*/
struct v3d_job *job = v3d_job_create(v3d);
job->nr_cbufs = nr_cbufs;
for (int i = 0; i < V3D_MAX_DRAW_BUFFERS; i++) {
for (int i = 0; i < job->nr_cbufs; i++) {
if (cbufs[i]) {
v3d_flush_jobs_reading_resource(v3d, cbufs[i]->texture,
V3D_FLUSH_DEFAULT,
@ -361,7 +364,7 @@ v3d_get_job(struct v3d_context *v3d,
job->msaa = true;
}
for (int i = 0; i < V3D_MAX_DRAW_BUFFERS; i++) {
for (int i = 0; i < job->nr_cbufs; i++) {
if (cbufs[i])
_mesa_hash_table_insert(v3d->write_jobs,
cbufs[i]->texture, job);
@ -393,9 +396,10 @@ v3d_get_job_for_fbo(struct v3d_context *v3d)
if (v3d->job)
return v3d->job;
uint32_t nr_cbufs = v3d->framebuffer.nr_cbufs;
struct pipe_surface **cbufs = v3d->framebuffer.cbufs;
struct pipe_surface *zsbuf = v3d->framebuffer.zsbuf;
struct v3d_job *job = v3d_get_job(v3d, cbufs, zsbuf);
struct v3d_job *job = v3d_get_job(v3d, nr_cbufs, cbufs, zsbuf);
if (v3d->framebuffer.samples >= 1)
job->msaa = true;
@ -411,7 +415,7 @@ v3d_get_job_for_fbo(struct v3d_context *v3d)
/* If we're binding to uninitialized buffers, no need to load their
* contents before drawing.
*/
for (int i = 0; i < 4; i++) {
for (int i = 0; i < nr_cbufs; i++) {
if (cbufs[i]) {
struct v3d_resource *rsc = v3d_resource(cbufs[i]->texture);
if (!rsc->writes)

View File

@ -1417,7 +1417,7 @@ v3d_draw_vbo(struct pipe_context *pctx, const struct pipe_draw_info *info,
rsc->initialized_buffers |= PIPE_CLEAR_STENCIL;
}
for (int i = 0; i < V3D_MAX_DRAW_BUFFERS; i++) {
for (int i = 0; i < job->nr_cbufs; i++) {
uint32_t bit = PIPE_CLEAR_COLOR0 << i;
int blend_rt = v3d->blend->base.independent_blend_enable ? i : 0;
@ -1670,7 +1670,7 @@ v3d_tlb_clear(struct v3d_job *job, unsigned buffers,
buffers &= ~PIPE_CLEAR_DEPTHSTENCIL;
}
for (int i = 0; i < V3D_MAX_DRAW_BUFFERS; i++) {
for (int i = 0; i < job->nr_cbufs; i++) {
uint32_t bit = PIPE_CLEAR_COLOR0 << i;
if (!(buffers & bit))
continue;

View File

@ -214,7 +214,7 @@ v3d_rcl_emit_loads(struct v3d_job *job, struct v3d_cl *cl, int layer)
{
uint32_t loads_pending = job->load;
for (int i = 0; i < V3D_MAX_DRAW_BUFFERS; i++) {
for (int i = 0; i < job->nr_cbufs; i++) {
uint32_t bit = PIPE_CLEAR_COLOR0 << i;
if (!(loads_pending & bit))
continue;
@ -313,7 +313,7 @@ v3d_rcl_emit_stores(struct v3d_job *job, struct v3d_cl *cl, int layer)
* perspective. Non-MSAA surfaces will use
* STORE_MULTI_SAMPLE_RESOLVED_TILE_COLOR_BUFFER_EXTENDED.
*/
for (int i = 0; i < V3D_MAX_DRAW_BUFFERS; i++) {
for (int i = 0; i < job->nr_cbufs; i++) {
uint32_t bit = PIPE_CLEAR_COLOR0 << i;
if (!(job->store & bit))
continue;
@ -639,12 +639,6 @@ v3dX(emit_rcl)(struct v3d_job *job)
job->submit.rcl_start = job->rcl.bo->offset;
v3d_job_add_bo(job, job->rcl.bo);
int nr_cbufs = 0;
for (int i = 0; i < V3D_MAX_DRAW_BUFFERS; i++) {
if (job->cbufs[i])
nr_cbufs = i + 1;
}
/* Comon config must be the first TILE_RENDERING_MODE_CFG
* and Z_STENCIL_CLEAR_VALUES must be last. The ones in between are
* optional updates to the previous HW state.
@ -681,14 +675,14 @@ v3dX(emit_rcl)(struct v3d_job *job)
config.image_width_pixels = job->draw_width;
config.image_height_pixels = job->draw_height;
config.number_of_render_targets = MAX2(nr_cbufs, 1);
config.number_of_render_targets = MAX2(job->nr_cbufs, 1);
config.multisample_mode_4x = job->msaa;
config.maximum_bpp_of_all_render_targets = job->internal_bpp;
}
for (int i = 0; i < nr_cbufs; i++) {
for (int i = 0; i < job->nr_cbufs; i++) {
struct pipe_surface *psurf = job->cbufs[i];
if (!psurf)
continue;