zink: add samples to rasterizer
authorDave Airlie <airlied@redhat.com>
Thu, 25 Oct 2018 02:02:15 +0000 (12:02 +1000)
committerErik Faye-Lund <erik.faye-lund@collabora.com>
Mon, 28 Oct 2019 08:51:45 +0000 (08:51 +0000)
Acked-by: Jordan Justen <jordan.l.justen@intel.com>
src/gallium/drivers/zink/zink_context.c
src/gallium/drivers/zink/zink_pipeline.c
src/gallium/drivers/zink/zink_pipeline.h
src/gallium/drivers/zink/zink_render_pass.c
src/gallium/drivers/zink/zink_render_pass.h

index fb3ee0f6b6ff33dfd345483bbea47d56cb77eeb6..23971d22762b96c89ab4f2c0e6229b6344e8edf0 100644 (file)
@@ -471,12 +471,14 @@ get_render_pass(struct zink_context *ctx)
    for (int i = 0; i < fb->nr_cbufs; i++) {
       struct zink_resource *cbuf = zink_resource(fb->cbufs[i]->texture);
       state.rts[i].format = cbuf->format;
+      state.rts[i].samples = cbuf->base.nr_samples > 0 ? cbuf->base.nr_samples : VK_SAMPLE_COUNT_1_BIT;
    }
    state.num_cbufs = fb->nr_cbufs;
 
    if (fb->zsbuf) {
       struct zink_resource *zsbuf = zink_resource(fb->zsbuf->texture);
       state.rts[fb->nr_cbufs].format = zsbuf->format;
+      state.rts[fb->nr_cbufs].samples = zsbuf->base.nr_samples > 0 ? zsbuf->base.nr_samples : VK_SAMPLE_COUNT_1_BIT;
    }
    state.have_zsbuf = fb->zsbuf != NULL;
 
@@ -602,12 +604,19 @@ zink_set_framebuffer_state(struct pipe_context *pctx,
    struct zink_context *ctx = zink_context(pctx);
    struct zink_screen *screen = zink_screen(pctx->screen);
 
+   VkSampleCountFlagBits rast_samples = VK_SAMPLE_COUNT_1_BIT;
+   for (int i = 0; i < state->nr_cbufs; i++)
+      rast_samples = MAX2(rast_samples, state->cbufs[i]->texture->nr_samples);
+   if (state->zsbuf && state->zsbuf->texture->nr_samples)
+      rast_samples = MAX2(rast_samples, state->zsbuf->texture->nr_samples);
+
    util_copy_framebuffer_state(&ctx->fb_state, state);
 
    struct zink_framebuffer *fb = get_framebuffer(ctx);
    zink_framebuffer_reference(screen, &ctx->framebuffer, fb);
    zink_render_pass_reference(screen, &ctx->gfx_pipeline_state.render_pass, fb->rp);
 
+   ctx->gfx_pipeline_state.rast_samples = rast_samples;
    ctx->gfx_pipeline_state.num_attachments = state->nr_cbufs;
 
    struct zink_batch *batch = zink_batch_no_rp(ctx);
index 3850395b6601ff7847a7f7d2a4e7424b0b1741c3..9516a8fbb82c6c2cbf7bf2c096bf28112bae9514 100644 (file)
@@ -59,7 +59,7 @@ zink_create_gfx_pipeline(VkDevice dev, struct zink_gfx_program *prog,
 
    VkPipelineMultisampleStateCreateInfo ms_state = {};
    ms_state.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO;
-   ms_state.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT;
+   ms_state.rasterizationSamples = state->rast_samples;
    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;
index ec896d0d5834cedfa7a52366edafb657d5110132..0a448be7b4ecb98b08f4a68c735c6d1e2d8cc4a6 100644 (file)
@@ -51,6 +51,7 @@ struct zink_gfx_pipeline_state {
    float line_width;
 
    VkSampleMask sample_mask;
+   uint8_t rast_samples;
 };
 
 VkPipeline
index 7db4ec2f632c82a5a693681dbb94ec3e10eb1de7..401b41c01e1d90db522fef7d01bc15c7aa5dbd7d 100644 (file)
@@ -39,7 +39,7 @@ create_render_pass(VkDevice dev, struct zink_render_pass_state *state)
       struct zink_rt_attrib *rt = state->rts + i;
       attachments[i].flags = 0;
       attachments[i].format = rt->format;
-      attachments[i].samples = VK_SAMPLE_COUNT_1_BIT;
+      attachments[i].samples = rt->samples;
       attachments[i].loadOp = VK_ATTACHMENT_LOAD_OP_LOAD;
       attachments[i].storeOp = VK_ATTACHMENT_STORE_OP_STORE;
       attachments[i].stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
@@ -55,7 +55,7 @@ create_render_pass(VkDevice dev, struct zink_render_pass_state *state)
       struct zink_rt_attrib *rt = state->rts + state->num_cbufs;
       attachments[num_attachments].flags = 0;
       attachments[num_attachments].format = rt->format;
-      attachments[num_attachments].samples = VK_SAMPLE_COUNT_1_BIT;
+      attachments[num_attachments].samples = rt->samples;
       attachments[num_attachments].loadOp = VK_ATTACHMENT_LOAD_OP_LOAD;
       attachments[num_attachments].storeOp = VK_ATTACHMENT_STORE_OP_STORE;
       attachments[num_attachments].stencilLoadOp = VK_ATTACHMENT_LOAD_OP_LOAD;
index 9ffb83b2486d7d9f922a12978952b5a26a6c51f5..2da246ee8f8bccd81be05cd66d7568a58e13112c 100644 (file)
@@ -33,6 +33,7 @@ struct zink_screen;
 
 struct zink_rt_attrib {
   VkFormat format;
+  VkSampleCountFlagBits samples;
 };
 
 struct zink_render_pass_state {