From dec4d15e6773ff9fd6b6d71d8f393419ae556a94 Mon Sep 17 00:00:00 2001 From: Boris Brezillon Date: Tue, 8 Dec 2020 11:42:15 +0100 Subject: [PATCH] panfrost: Take the number of samples into account in blend shaders Midgard has to split the writeout instruction if the number of bits per pixel exceeds 128. We thus need to take the number of samples into account when creating blend shaders. Signed-off-by: Boris Brezillon Reviewed-by: Alyssa Rosenzweig Part-of: --- .gitlab-ci/deqp-panfrost-t860-fails.txt | 3 --- src/gallium/drivers/panfrost/pan_blend.h | 5 ++++- src/gallium/drivers/panfrost/pan_blend_cso.c | 8 ++++++-- src/gallium/drivers/panfrost/pan_blend_shaders.c | 1 + src/gallium/drivers/panfrost/pan_job.c | 4 +++- 5 files changed, 14 insertions(+), 7 deletions(-) diff --git a/.gitlab-ci/deqp-panfrost-t860-fails.txt b/.gitlab-ci/deqp-panfrost-t860-fails.txt index a0f551b299a..462f206643d 100644 --- a/.gitlab-ci/deqp-panfrost-t860-fails.txt +++ b/.gitlab-ci/deqp-panfrost-t860-fails.txt @@ -29,9 +29,6 @@ dEQP-GLES3.functional.fbo.msaa.4_samples.depth32f_stencil8,Fail dEQP-GLES3.functional.fbo.msaa.4_samples.depth_component16,Fail dEQP-GLES3.functional.fbo.msaa.4_samples.depth_component24,Fail dEQP-GLES3.functional.fbo.msaa.4_samples.depth_component32f,Fail -dEQP-GLES3.functional.fbo.msaa.4_samples.rg32f,Fail -dEQP-GLES3.functional.fbo.msaa.4_samples.rgba16f,Fail -dEQP-GLES3.functional.fbo.msaa.4_samples.rgba32f,Fail dEQP-GLES3.functional.fbo.msaa.4_samples.stencil_index8,Fail dEQP-GLES2.functional.shaders.indexing.tmp_array.float_const_write_dynamic_loop_read_fragment,Crash dEQP-GLES2.functional.shaders.indexing.tmp_array.float_const_write_dynamic_loop_read_vertex,Crash diff --git a/src/gallium/drivers/panfrost/pan_blend.h b/src/gallium/drivers/panfrost/pan_blend.h index 901d54a4125..ba74edc19da 100644 --- a/src/gallium/drivers/panfrost/pan_blend.h +++ b/src/gallium/drivers/panfrost/pan_blend.h @@ -47,6 +47,9 @@ struct panfrost_blend_shader_key { unsigned logicop_enable : 1; unsigned logicop_func:4; + /* Number of samples */ + unsigned nr_samples : 5; + struct pipe_rt_blend_state equation; }; @@ -143,7 +146,7 @@ panfrost_get_blend_for_context(struct panfrost_context *ctx, unsigned rt, struct struct panfrost_blend_shader * panfrost_get_blend_shader(struct panfrost_context *ctx, struct panfrost_blend_state *blend, - enum pipe_format fmt, + enum pipe_format fmt, unsigned nr_samples, unsigned rt, const float *constants); diff --git a/src/gallium/drivers/panfrost/pan_blend_cso.c b/src/gallium/drivers/panfrost/pan_blend_cso.c index 370fe9f930f..dace098213a 100644 --- a/src/gallium/drivers/panfrost/pan_blend_cso.c +++ b/src/gallium/drivers/panfrost/pan_blend_cso.c @@ -69,7 +69,7 @@ struct panfrost_blend_shader * panfrost_get_blend_shader(struct panfrost_context *ctx, struct panfrost_blend_state *blend, - enum pipe_format fmt, + enum pipe_format fmt, unsigned nr_samples, unsigned rt, const float *constants) { @@ -81,6 +81,7 @@ panfrost_get_blend_shader(struct panfrost_context *ctx, struct panfrost_blend_shader_key key = { .rt = rt, .format = fmt, + .nr_samples = MAX2(nr_samples, 1), .has_constants = constants != NULL, .logicop_enable = blend->base.logicop_enable, }; @@ -254,9 +255,12 @@ panfrost_get_blend_for_context(struct panfrost_context *ctx, unsigned rti, struc } } + unsigned nr_samples = fb->cbufs[rti]->nr_samples ? : + fb->cbufs[rti]->texture->nr_samples; + /* Otherwise, we need to grab a shader */ struct panfrost_blend_shader *shader = - panfrost_get_blend_shader(ctx, blend, fmt, rti, + panfrost_get_blend_shader(ctx, blend, fmt, nr_samples, rti, rt->constant_mask ? ctx->blend_color.color : NULL); diff --git a/src/gallium/drivers/panfrost/pan_blend_shaders.c b/src/gallium/drivers/panfrost/pan_blend_shaders.c index 4a5e97e5796..8ff0649ad72 100644 --- a/src/gallium/drivers/panfrost/pan_blend_shaders.c +++ b/src/gallium/drivers/panfrost/pan_blend_shaders.c @@ -287,6 +287,7 @@ panfrost_compile_blend_shader(struct panfrost_blend_shader *shader, .gpu_id = dev->gpu_id, .is_blend = true, .blend.rt = shader->key.rt, + .blend.nr_samples = shader->key.nr_samples, .rt_formats = {shader->key.format}, }; diff --git a/src/gallium/drivers/panfrost/pan_job.c b/src/gallium/drivers/panfrost/pan_job.c index eec81a92f73..dedf66d11d6 100644 --- a/src/gallium/drivers/panfrost/pan_job.c +++ b/src/gallium/drivers/panfrost/pan_job.c @@ -825,7 +825,9 @@ panfrost_load_surface(struct panfrost_batch *batch, struct pipe_surface *surf, u if (loc >= FRAG_RESULT_DATA0 && !panfrost_can_fixed_blend(rsrc->base.format)) { struct panfrost_blend_shader *b = panfrost_get_blend_shader(batch->ctx, batch->ctx->blit_blend, - rsrc->base.format, loc - FRAG_RESULT_DATA0, + rsrc->base.format, + rsrc->base.nr_samples, + loc - FRAG_RESULT_DATA0, NULL); struct panfrost_bo *bo = panfrost_batch_create_bo(batch, b->size,