aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Airlie <[email protected]>2018-10-25 12:02:15 +1000
committerErik Faye-Lund <[email protected]>2019-10-28 08:51:45 +0000
commite234116a96604d787bcc05a3b9ebcf8701682e6f (patch)
tree81bce0747ba2e31ee10a4b084e2d7a245e0d72c3
parent0c5f3e50aea46b1aa9456c40ac0607253fcd06cd (diff)
zink: add samples to rasterizer
Acked-by: Jordan Justen <[email protected]>
-rw-r--r--src/gallium/drivers/zink/zink_context.c9
-rw-r--r--src/gallium/drivers/zink/zink_pipeline.c2
-rw-r--r--src/gallium/drivers/zink/zink_pipeline.h1
-rw-r--r--src/gallium/drivers/zink/zink_render_pass.c4
-rw-r--r--src/gallium/drivers/zink/zink_render_pass.h1
5 files changed, 14 insertions, 3 deletions
diff --git a/src/gallium/drivers/zink/zink_context.c b/src/gallium/drivers/zink/zink_context.c
index fb3ee0f6b6f..23971d22762 100644
--- a/src/gallium/drivers/zink/zink_context.c
+++ b/src/gallium/drivers/zink/zink_context.c
@@ -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);
diff --git a/src/gallium/drivers/zink/zink_pipeline.c b/src/gallium/drivers/zink/zink_pipeline.c
index 3850395b660..9516a8fbb82 100644
--- a/src/gallium/drivers/zink/zink_pipeline.c
+++ b/src/gallium/drivers/zink/zink_pipeline.c
@@ -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;
diff --git a/src/gallium/drivers/zink/zink_pipeline.h b/src/gallium/drivers/zink/zink_pipeline.h
index ec896d0d583..0a448be7b4e 100644
--- a/src/gallium/drivers/zink/zink_pipeline.h
+++ b/src/gallium/drivers/zink/zink_pipeline.h
@@ -51,6 +51,7 @@ struct zink_gfx_pipeline_state {
float line_width;
VkSampleMask sample_mask;
+ uint8_t rast_samples;
};
VkPipeline
diff --git a/src/gallium/drivers/zink/zink_render_pass.c b/src/gallium/drivers/zink/zink_render_pass.c
index 7db4ec2f632..401b41c01e1 100644
--- a/src/gallium/drivers/zink/zink_render_pass.c
+++ b/src/gallium/drivers/zink/zink_render_pass.c
@@ -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;
diff --git a/src/gallium/drivers/zink/zink_render_pass.h b/src/gallium/drivers/zink/zink_render_pass.h
index 9ffb83b2486..2da246ee8f8 100644
--- a/src/gallium/drivers/zink/zink_render_pass.h
+++ b/src/gallium/drivers/zink/zink_render_pass.h
@@ -33,6 +33,7 @@ struct zink_screen;
struct zink_rt_attrib {
VkFormat format;
+ VkSampleCountFlagBits samples;
};
struct zink_render_pass_state {