Mesa (main): zink: steal a bit from rast_samples in pipeline state

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Aug 27 11:07:15 UTC 2021


Module: Mesa
Branch: main
Commit: c73adf8c9018be65f197a6efdb8dd02e05079bdb
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=c73adf8c9018be65f197a6efdb8dd02e05079bdb

Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date:   Thu Jul 15 09:20:27 2021 -0400

zink: steal a bit from rast_samples in pipeline state

zink only handles values up to 64, so this still has an extra bit

Reviewed-by: Dave Airlie <airlied at redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12586>

---

 src/gallium/drivers/zink/zink_context.c  | 10 +++++-----
 src/gallium/drivers/zink/zink_pipeline.c |  2 +-
 src/gallium/drivers/zink/zink_pipeline.h |  2 +-
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/gallium/drivers/zink/zink_context.c b/src/gallium/drivers/zink/zink_context.c
index 08a31da8287..9a631788005 100644
--- a/src/gallium/drivers/zink/zink_context.c
+++ b/src/gallium/drivers/zink/zink_context.c
@@ -1599,7 +1599,7 @@ setup_framebuffer(struct zink_context *ctx)
    struct zink_render_pass *rp = ctx->gfx_pipeline_state.render_pass;
 
    if (ctx->gfx_pipeline_state.sample_locations_enabled && ctx->sample_locations_changed) {
-      unsigned samples = ctx->gfx_pipeline_state.rast_samples;
+      unsigned samples = ctx->gfx_pipeline_state.rast_samples + 1;
       unsigned idx = util_logbase2_ceil(MAX2(samples, 1));
       VkExtent2D grid_size = screen->maxSampleLocationGridSize[idx];
  
@@ -1718,11 +1718,11 @@ void
 zink_init_vk_sample_locations(struct zink_context *ctx, VkSampleLocationsInfoEXT *loc)
 {
    struct zink_screen *screen = zink_screen(ctx->base.screen);
-   unsigned idx = util_logbase2_ceil(MAX2(ctx->gfx_pipeline_state.rast_samples, 1));
+   unsigned idx = util_logbase2_ceil(MAX2(ctx->gfx_pipeline_state.rast_samples + 1, 1));
    loc->sType = VK_STRUCTURE_TYPE_SAMPLE_LOCATIONS_INFO_EXT;
    loc->pNext = NULL;
    loc->sampleLocationsPerPixel = 1 << idx;
-   loc->sampleLocationsCount = ctx->gfx_pipeline_state.rast_samples;
+   loc->sampleLocationsCount = ctx->gfx_pipeline_state.rast_samples + 1;
    loc->sampleLocationGridSize = screen->maxSampleLocationGridSize[idx];
    loc->pSampleLocations = ctx->vk_sample_locations;
 }
@@ -2018,9 +2018,9 @@ zink_set_framebuffer_state(struct pipe_context *pctx,
    ctx->fb_changed |= ctx->framebuffer != fb;
    ctx->framebuffer = fb;
 
-   uint8_t rast_samples = util_framebuffer_get_num_samples(state);
+   uint8_t rast_samples = util_framebuffer_get_num_samples(state) - 1;
    /* in vulkan, gl_SampleMask needs to be explicitly ignored for sampleCount == 1 */
-   if ((ctx->gfx_pipeline_state.rast_samples > 1) != (rast_samples > 1))
+   if ((ctx->gfx_pipeline_state.rast_samples > 0) != (rast_samples > 0))
       ctx->dirty_shader_stages |= 1 << PIPE_SHADER_FRAGMENT;
    if (ctx->gfx_pipeline_state.rast_samples != rast_samples) {
       ctx->sample_locations_changed |= ctx->gfx_pipeline_state.sample_locations_enabled;
diff --git a/src/gallium/drivers/zink/zink_pipeline.c b/src/gallium/drivers/zink/zink_pipeline.c
index 9794d1cad4e..b7373a315d4 100644
--- a/src/gallium/drivers/zink/zink_pipeline.c
+++ b/src/gallium/drivers/zink/zink_pipeline.c
@@ -114,7 +114,7 @@ zink_create_gfx_pipeline(struct zink_screen *screen,
 
    VkPipelineMultisampleStateCreateInfo ms_state = {0};
    ms_state.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO;
-   ms_state.rasterizationSamples = state->rast_samples;
+   ms_state.rasterizationSamples = state->rast_samples + 1;
    ms_state.alphaToCoverageEnable = state->blend_state->alpha_to_coverage;
    ms_state.alphaToOneEnable = state->blend_state->alpha_to_one;
    ms_state.pSampleMask = state->sample_mask ? &state->sample_mask : NULL;
diff --git a/src/gallium/drivers/zink/zink_pipeline.h b/src/gallium/drivers/zink/zink_pipeline.h
index e16f19ccdf6..8d4d6bd273f 100644
--- a/src/gallium/drivers/zink/zink_pipeline.h
+++ b/src/gallium/drivers/zink/zink_pipeline.h
@@ -46,7 +46,7 @@ struct zink_gfx_pipeline_state {
    struct zink_rasterizer_hw_state *rast_state;
 
    VkSampleMask sample_mask;
-   uint8_t rast_samples;
+   uint8_t rast_samples:7;
    uint8_t vertices_per_patch;
 
    /* Pre-hashed value for table lookup, invalid when zero.



More information about the mesa-commit mailing list