Module: Mesa Branch: main Commit: 247c06d41997538e877619326d046f84887a48ab URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=247c06d41997538e877619326d046f84887a48ab
Author: Tapani Pälli <[email protected]> Date: Thu Jan 12 14:17:12 2023 +0200 iris: add restrictions for 3DSTATE_RASTER::AntiAliasingEnable Field must be disabled if any render targets have integer format, additionally for Gfx12+ field must be disabled when num multisamples > 1 or forced multisample count > 1. Cc: mesa-stable Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/7892 Signed-off-by: Tapani Pälli <[email protected]> Reviewed-by: Lionel Landwerlin <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20671> --- src/gallium/drivers/iris/iris_context.h | 3 +++ src/gallium/drivers/iris/iris_state.c | 45 +++++++++++++++++++++++++++++++-- 2 files changed, 46 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/iris/iris_context.h b/src/gallium/drivers/iris/iris_context.h index af447fb98fc..4947c8a0e81 100644 --- a/src/gallium/drivers/iris/iris_context.h +++ b/src/gallium/drivers/iris/iris_context.h @@ -796,6 +796,9 @@ struct iris_context { /** Are stencil writes enabled? (Stencil buffer may or may not exist.) */ bool stencil_writes_enabled; + /** Do we have integer RT in current framebuffer state? */ + bool has_integer_rt; + /** GenX-specific current state */ struct iris_genx_state *genx; diff --git a/src/gallium/drivers/iris/iris_state.c b/src/gallium/drivers/iris/iris_state.c index c6f61bbe723..ee020cd9293 100644 --- a/src/gallium/drivers/iris/iris_state.c +++ b/src/gallium/drivers/iris/iris_state.c @@ -1878,6 +1878,7 @@ struct iris_rasterizer_state { bool light_twoside; /* for shader state */ bool rasterizer_discard; /* for 3DSTATE_STREAMOUT and 3DSTATE_CLIP */ bool half_pixel_center; /* for 3DSTATE_MULTISAMPLE */ + bool line_smooth; bool line_stipple_enable; bool poly_stipple_enable; bool multisample; @@ -1943,6 +1944,7 @@ iris_create_rasterizer_state(struct pipe_context *ctx, cso->half_pixel_center = state->half_pixel_center; cso->sprite_coord_mode = state->sprite_coord_mode; cso->sprite_coord_enable = state->sprite_coord_enable; + cso->line_smooth = state->line_smooth; cso->line_stipple_enable = state->line_stipple_enable; cso->poly_stipple_enable = state->poly_stipple_enable; cso->conservative_rasterization = @@ -1999,7 +2001,6 @@ iris_create_rasterizer_state(struct pipe_context *ctx, rr.GlobalDepthOffsetScale = state->offset_scale; rr.GlobalDepthOffsetClamp = state->offset_clamp; rr.SmoothPointEnable = state->point_smooth; - rr.AntialiasingEnable = state->line_smooth; rr.ScissorRectangleEnable = state->scissor; #if GFX_VER >= 9 rr.ViewportZNearClipTestEnable = state->depth_clip_near; @@ -3347,10 +3348,27 @@ iris_set_framebuffer_state(struct pipe_context *ctx, ice->state.dirty |= IRIS_DIRTY_DEPTH_BUFFER; } + bool has_integer_rt = false; + for (unsigned i = 0; i < state->nr_cbufs; i++) { + if (state->cbufs[i]) { + enum isl_format ifmt = + isl_format_for_pipe_format(state->cbufs[i]->format); + has_integer_rt |= isl_format_has_int_channel(ifmt); + } + } + + /* 3DSTATE_RASTER::AntialiasingEnable */ + if (has_integer_rt != ice->state.has_integer_rt || + cso->samples != samples) { + ice->state.dirty |= IRIS_DIRTY_RASTER; + } + util_copy_framebuffer_state(cso, state); cso->samples = samples; cso->layers = layers; + ice->state.has_integer_rt = has_integer_rt; + struct iris_depth_buffer_state *cso_z = &ice->state.genx->depth_buffer; struct isl_view view = { @@ -6455,8 +6473,31 @@ iris_upload_dirty_render_state(struct iris_context *ice, } if (dirty & (IRIS_DIRTY_RASTER | IRIS_DIRTY_URB)) { + /* From the Browadwell PRM, Volume 2, documentation for + * 3DSTATE_RASTER, "Antialiasing Enable": + * + * "This field must be disabled if any of the render targets + * have integer (UINT or SINT) surface format." + * + * Additionally internal documentation for Gfx12+ states: + * + * "This bit MUST not be set when NUM_MULTISAMPLES > 1 OR + * FORCED_SAMPLE_COUNT > 1." + */ + struct pipe_framebuffer_state *cso_fb = &ice->state.framebuffer; + unsigned samples = util_framebuffer_get_num_samples(cso_fb); struct iris_rasterizer_state *cso = ice->state.cso_rast; - iris_batch_emit(batch, cso->raster, sizeof(cso->raster)); + + bool aa_enable = cso->line_smooth && + !ice->state.has_integer_rt && + !(batch->screen->devinfo->ver >= 12 && samples > 1); + + uint32_t dynamic_raster[GENX(3DSTATE_RASTER_length)]; + iris_pack_command(GENX(3DSTATE_RASTER), &dynamic_raster, raster) { + raster.AntialiasingEnable = aa_enable; + } + iris_emit_merge(batch, cso->raster, dynamic_raster, + ARRAY_SIZE(cso->raster)); uint32_t dynamic_sf[GENX(3DSTATE_SF_length)]; iris_pack_command(GENX(3DSTATE_SF), &dynamic_sf, sf) {
