mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-07 15:10:12 +01:00
zink: add new framebuffer_is_layered state
This state is needed to make sure gl_Layer values are set to 0, when the framebuffer is not layered accorfing to GL spec. Specifically Section 9.8 Layered Framebuffers of GL46 spec: A layer number written by a geometry shader has no effect if the framebuffer is not layered. Vulkan has no carve out for this, so zink must handle this by sanitising gl_Layer (next commit in the series). Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19163>
This commit is contained in:
parent
fd89690795
commit
72d18325dd
4 changed files with 27 additions and 5 deletions
|
|
@ -61,6 +61,7 @@ fields[member_idx].offset = offsetof(struct zink_gfx_push_constant, field);
|
|||
struct glsl_struct_field *fields = rzalloc_array(nir, struct glsl_struct_field, ZINK_GFX_PUSHCONST_MAX);
|
||||
PUSHCONST_MEMBER(ZINK_GFX_PUSHCONST_DRAW_MODE_IS_INDEXED, draw_mode_is_indexed);
|
||||
PUSHCONST_MEMBER(ZINK_GFX_PUSHCONST_DRAW_ID, draw_id);
|
||||
PUSHCONST_MEMBER(ZINK_GFX_PUSHCONST_FRAMEBUFFER_IS_LAYERED, framebuffer_is_layered);
|
||||
PUSHCONST_MEMBER(ZINK_GFX_PUSHCONST_DEFAULT_INNER_LEVEL, default_inner_level);
|
||||
PUSHCONST_MEMBER(ZINK_GFX_PUSHCONST_DEFAULT_OUTER_LEVEL, default_outer_level);
|
||||
|
||||
|
|
|
|||
|
|
@ -2436,6 +2436,18 @@ begin_rendering(struct zink_context *ctx)
|
|||
return clear_buffers;
|
||||
}
|
||||
|
||||
ALWAYS_INLINE static void
|
||||
update_layered_rendering_state(struct zink_context *ctx)
|
||||
{
|
||||
unsigned framebffer_is_layered = zink_framebuffer_get_num_layers(&ctx->fb_state) > 1;
|
||||
VKCTX(CmdPushConstants)(
|
||||
ctx->batch.state->cmdbuf,
|
||||
zink_screen(ctx->base.screen)->gfx_push_constant_layout,
|
||||
VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_GEOMETRY_BIT | VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT,
|
||||
offsetof(struct zink_gfx_push_constant, framebuffer_is_layered), sizeof(unsigned),
|
||||
&framebffer_is_layered);
|
||||
}
|
||||
|
||||
void
|
||||
zink_batch_rp(struct zink_context *ctx)
|
||||
{
|
||||
|
|
@ -2775,6 +2787,7 @@ flush_batch(struct zink_context *ctx, bool sync)
|
|||
if (conditional_render_active)
|
||||
zink_start_conditional_render(ctx);
|
||||
reapply_color_write(ctx);
|
||||
update_layered_rendering_state(ctx);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -3034,6 +3047,8 @@ zink_set_framebuffer_state(struct pipe_context *pctx,
|
|||
/* this is an ideal time to oom flush since it won't split a renderpass */
|
||||
if (ctx->oom_flush)
|
||||
flush_batch(ctx, false);
|
||||
else
|
||||
update_layered_rendering_state(ctx);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -792,7 +792,7 @@ zink_pipeline_layout_create(struct zink_screen *screen, VkDescriptorSetLayout *d
|
|||
plci.pSetLayouts = dsl;
|
||||
plci.setLayoutCount = num_dsl;
|
||||
|
||||
VkPushConstantRange pcr[2] = {0};
|
||||
VkPushConstantRange pcr[3] = {0};
|
||||
if (is_compute) {
|
||||
pcr[0].stageFlags = VK_SHADER_STAGE_COMPUTE_BIT;
|
||||
pcr[0].offset = 0;
|
||||
|
|
@ -802,10 +802,14 @@ zink_pipeline_layout_create(struct zink_screen *screen, VkDescriptorSetLayout *d
|
|||
pcr[0].stageFlags = VK_SHADER_STAGE_VERTEX_BIT;
|
||||
pcr[0].offset = offsetof(struct zink_gfx_push_constant, draw_mode_is_indexed);
|
||||
pcr[0].size = 2 * sizeof(unsigned);
|
||||
pcr[1].stageFlags = VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT;
|
||||
pcr[1].offset = offsetof(struct zink_gfx_push_constant, default_inner_level);
|
||||
pcr[1].size = sizeof(float) * 6;
|
||||
plci.pushConstantRangeCount = 2;
|
||||
pcr[1].stageFlags =
|
||||
VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_GEOMETRY_BIT | VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT;
|
||||
pcr[1].offset = offsetof(struct zink_gfx_push_constant, framebuffer_is_layered);
|
||||
pcr[1].size = 1 * sizeof(unsigned);
|
||||
pcr[2].stageFlags = VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT;
|
||||
pcr[2].offset = offsetof(struct zink_gfx_push_constant, default_inner_level);
|
||||
pcr[2].size = sizeof(float) * 6;
|
||||
plci.pushConstantRangeCount = ARRAY_SIZE(pcr);
|
||||
}
|
||||
plci.pPushConstantRanges = pcr;
|
||||
|
||||
|
|
|
|||
|
|
@ -794,6 +794,7 @@ struct zink_compute_pipeline_state {
|
|||
struct zink_gfx_push_constant {
|
||||
unsigned draw_mode_is_indexed;
|
||||
unsigned draw_id;
|
||||
unsigned framebuffer_is_layered;
|
||||
float default_inner_level[2];
|
||||
float default_outer_level[4];
|
||||
};
|
||||
|
|
@ -804,6 +805,7 @@ struct zink_gfx_push_constant {
|
|||
enum zink_gfx_push_constant_member {
|
||||
ZINK_GFX_PUSHCONST_DRAW_MODE_IS_INDEXED,
|
||||
ZINK_GFX_PUSHCONST_DRAW_ID,
|
||||
ZINK_GFX_PUSHCONST_FRAMEBUFFER_IS_LAYERED,
|
||||
ZINK_GFX_PUSHCONST_DEFAULT_INNER_LEVEL,
|
||||
ZINK_GFX_PUSHCONST_DEFAULT_OUTER_LEVEL,
|
||||
ZINK_GFX_PUSHCONST_MAX
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue