mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-25 17:20:10 +01:00
v3d: refactor set tile buffer size function
Change it to not require a v3d job to compute the tile buffer parameters. v1: - Pass nr_cbufs parameter to get tile buffer size function (Iago) 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:
parent
487dd96c4f
commit
904f6b92ef
3 changed files with 59 additions and 44 deletions
|
|
@ -226,6 +226,52 @@ v3d_create_texture_shader_state_bo(struct v3d_context *v3d,
|
|||
v3d33_create_texture_shader_state_bo(v3d, so);
|
||||
}
|
||||
|
||||
void
|
||||
v3d_get_tile_buffer_size(bool is_msaa,
|
||||
uint32_t nr_cbufs,
|
||||
struct pipe_surface **cbufs,
|
||||
struct pipe_surface *bbuf,
|
||||
uint32_t *tile_width,
|
||||
uint32_t *tile_height,
|
||||
uint32_t *max_bpp)
|
||||
{
|
||||
static const uint8_t tile_sizes[] = {
|
||||
64, 64,
|
||||
64, 32,
|
||||
32, 32,
|
||||
32, 16,
|
||||
16, 16,
|
||||
};
|
||||
int tile_size_index = 0;
|
||||
if (is_msaa)
|
||||
tile_size_index += 2;
|
||||
|
||||
if (cbufs[3] || cbufs[2])
|
||||
tile_size_index += 2;
|
||||
else if (cbufs[1])
|
||||
tile_size_index++;
|
||||
|
||||
*max_bpp = 0;
|
||||
for (int i = 0; i < nr_cbufs; i++) {
|
||||
if (cbufs[i]) {
|
||||
struct v3d_surface *surf = v3d_surface(cbufs[i]);
|
||||
*max_bpp = MAX2(*max_bpp, surf->internal_bpp);
|
||||
}
|
||||
}
|
||||
|
||||
if (bbuf) {
|
||||
struct v3d_surface *bsurf = v3d_surface(bbuf);
|
||||
assert(bbuf->texture->nr_samples <= 1 || is_msaa);
|
||||
*max_bpp = MAX2(*max_bpp, bsurf->internal_bpp);
|
||||
}
|
||||
|
||||
tile_size_index += *max_bpp;
|
||||
|
||||
assert(tile_size_index < ARRAY_SIZE(tile_sizes));
|
||||
*tile_width = tile_sizes[tile_size_index * 2 + 0];
|
||||
*tile_height = tile_sizes[tile_size_index * 2 + 1];
|
||||
}
|
||||
|
||||
static void
|
||||
v3d_context_destroy(struct pipe_context *pctx)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -657,7 +657,6 @@ struct v3d_job *v3d_get_job(struct v3d_context *v3d,
|
|||
struct pipe_surface *zsbuf,
|
||||
struct pipe_surface *bbuf);
|
||||
struct v3d_job *v3d_get_job_for_fbo(struct v3d_context *v3d);
|
||||
void v3d_job_set_tile_buffer_size(struct v3d_job *job);
|
||||
void v3d_job_add_bo(struct v3d_job *job, struct v3d_bo *bo);
|
||||
void v3d_job_add_write_resource(struct v3d_job *job, struct pipe_resource *prsc);
|
||||
void v3d_job_add_tf_write_resource(struct v3d_job *job, struct pipe_resource *prsc);
|
||||
|
|
@ -721,6 +720,14 @@ void v3d_flag_dirty_sampler_state(struct v3d_context *v3d,
|
|||
void v3d_create_texture_shader_state_bo(struct v3d_context *v3d,
|
||||
struct v3d_sampler_view *so);
|
||||
|
||||
void v3d_get_tile_buffer_size(bool is_msaa,
|
||||
uint32_t nr_cbufs,
|
||||
struct pipe_surface **cbufs,
|
||||
struct pipe_surface *bbuf,
|
||||
uint32_t *tile_width,
|
||||
uint32_t *tile_height,
|
||||
uint32_t *max_bpp);
|
||||
|
||||
#ifdef v3dX
|
||||
# include "v3dx_context.h"
|
||||
#else
|
||||
|
|
|
|||
|
|
@ -276,48 +276,6 @@ v3d_flush_jobs_reading_resource(struct v3d_context *v3d,
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
v3d_job_set_tile_buffer_size(struct v3d_job *job)
|
||||
{
|
||||
static const uint8_t tile_sizes[] = {
|
||||
64, 64,
|
||||
64, 32,
|
||||
32, 32,
|
||||
32, 16,
|
||||
16, 16,
|
||||
};
|
||||
int tile_size_index = 0;
|
||||
if (job->msaa)
|
||||
tile_size_index += 2;
|
||||
|
||||
if (job->cbufs[3] || job->cbufs[2])
|
||||
tile_size_index += 2;
|
||||
else if (job->cbufs[1])
|
||||
tile_size_index++;
|
||||
|
||||
int max_bpp = RENDER_TARGET_MAXIMUM_32BPP;
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
if (job->bbuf) {
|
||||
struct v3d_surface *bsurf = v3d_surface(job->bbuf);
|
||||
assert(job->bbuf->texture->nr_samples <= 1 || job->msaa);
|
||||
max_bpp = MAX2(max_bpp, bsurf->internal_bpp);
|
||||
}
|
||||
|
||||
job->internal_bpp = max_bpp;
|
||||
STATIC_ASSERT(RENDER_TARGET_MAXIMUM_32BPP == 0);
|
||||
tile_size_index += max_bpp;
|
||||
|
||||
assert(tile_size_index < ARRAY_SIZE(tile_sizes));
|
||||
job->tile_width = tile_sizes[tile_size_index * 2 + 0];
|
||||
job->tile_height = tile_sizes[tile_size_index * 2 + 1];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a v3d_job struture for tracking V3D rendering to a particular FBO.
|
||||
*
|
||||
|
|
@ -420,7 +378,11 @@ v3d_get_job_for_fbo(struct v3d_context *v3d)
|
|||
if (v3d->framebuffer.samples >= 1)
|
||||
job->msaa = true;
|
||||
|
||||
v3d_job_set_tile_buffer_size(job);
|
||||
v3d_get_tile_buffer_size(job->msaa, job->nr_cbufs,
|
||||
job->cbufs, job->bbuf,
|
||||
&job->tile_width,
|
||||
&job->tile_height,
|
||||
&job->internal_bpp);
|
||||
|
||||
/* The dirty flags are tracking what's been updated while v3d->job has
|
||||
* been bound, so set them all to ~0 when switching between jobs. We
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue