mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-24 04:08:10 +02:00
zink: rework custom sample locations
this is more consistent and comprehensible Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41707>
This commit is contained in:
parent
7eba054c5b
commit
c7758681f3
5 changed files with 22 additions and 33 deletions
|
|
@ -3055,8 +3055,6 @@ begin_rendering(struct zink_context *ctx, bool check_attachment_shadow)
|
|||
{
|
||||
unsigned clear_buffers = 0;
|
||||
struct zink_screen *screen = zink_screen(ctx->base.screen);
|
||||
if (ctx->gfx_pipeline_state.custom_sample_locations && ctx->sample_locations_changed)
|
||||
zink_update_vk_sample_locations(ctx);
|
||||
if (ctx->has_swapchain)
|
||||
zink_render_fixup_swapchain(ctx);
|
||||
bool has_depth = false;
|
||||
|
|
@ -3677,6 +3675,8 @@ void
|
|||
zink_init_vk_sample_locations(struct zink_context *ctx, VkSampleLocationsInfoEXT *loc)
|
||||
{
|
||||
struct zink_screen *screen = zink_screen(ctx->base.screen);
|
||||
if (ctx->sample_locations_changed)
|
||||
zink_update_vk_sample_locations(ctx);
|
||||
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;
|
||||
|
|
@ -4203,7 +4203,7 @@ zink_set_framebuffer_state(struct pipe_context *pctx,
|
|||
uint8_t rast_samples = ctx->fb_state.samples - 1;
|
||||
if (rast_samples != ctx->gfx_pipeline_state.rast_samples) {
|
||||
zink_update_fs_key_samples(ctx);
|
||||
ctx->sample_locations_changed |= ctx->gfx_pipeline_state.custom_sample_locations;
|
||||
ctx->sample_locations_changed |= ctx->sample_locations_enabled;
|
||||
if (screen->have_full_ds3)
|
||||
ctx->sample_mask_changed = true;
|
||||
else
|
||||
|
|
@ -4258,7 +4258,7 @@ zink_set_sample_locations(struct pipe_context *pctx, size_t size, const uint8_t
|
|||
{
|
||||
struct zink_context *ctx = zink_context(pctx);
|
||||
|
||||
ctx->gfx_pipeline_state.custom_sample_locations = size && locations;
|
||||
ctx->sample_locations_enabled = size && locations;
|
||||
ctx->sample_locations_changed = true;
|
||||
if (size > sizeof(ctx->sample_locations))
|
||||
size = sizeof(ctx->sample_locations);
|
||||
|
|
|
|||
|
|
@ -297,7 +297,6 @@ update_gfx_pipeline(struct zink_context *ctx, struct zink_batch_state *bs, enum
|
|||
}
|
||||
VKCTX(CmdSetDepthBiasEnable)(bs->cmdbuf, VK_TRUE);
|
||||
VKCTX(CmdSetTessellationDomainOriginEXT)(bs->cmdbuf, VK_TESSELLATION_DOMAIN_ORIGIN_LOWER_LEFT);
|
||||
VKCTX(CmdSetSampleLocationsEnableEXT)(bs->cmdbuf, ctx->gfx_pipeline_state.custom_sample_locations);
|
||||
VKCTX(CmdSetRasterizationStreamEXT)(bs->cmdbuf, 0);
|
||||
pipeline_changed = true;
|
||||
}
|
||||
|
|
@ -340,7 +339,7 @@ zink_rast_prim(const struct zink_context *ctx,
|
|||
|
||||
template <zink_dynamic_state DYNAMIC_STATE, bool BATCH_CHANGED>
|
||||
ALWAYS_INLINE static void
|
||||
emit_dynamic_state(struct zink_context *ctx, bool pipeline_changed, unsigned num_viewports)
|
||||
emit_dynamic_state(struct zink_context *ctx, bool pipeline_changed, unsigned num_viewports, bool uses_shobj)
|
||||
{
|
||||
struct zink_screen *screen = zink_screen(ctx->base.screen);
|
||||
struct zink_batch_state *bs = ctx->bs;
|
||||
|
|
@ -449,8 +448,9 @@ emit_dynamic_state(struct zink_context *ctx, bool pipeline_changed, unsigned num
|
|||
ctx->dsa_state_changed = false;
|
||||
}
|
||||
|
||||
if (ctx->sample_locations_changed) {
|
||||
if (ctx->gfx_pipeline_state.custom_sample_locations) {
|
||||
if ((BATCH_CHANGED && (screen->base.caps.programmable_sample_locations || uses_shobj)) || ctx->sample_locations_changed) {
|
||||
VKCTX(CmdSetSampleLocationsEnableEXT)(bs->cmdbuf, ctx->sample_locations_enabled);
|
||||
if (ctx->sample_locations_enabled) {
|
||||
VkSampleLocationsInfoEXT loc;
|
||||
zink_init_vk_sample_locations(ctx, &loc);
|
||||
VKCTX(CmdSetSampleLocationsEXT)(bs->cmdbuf, &loc);
|
||||
|
|
@ -732,7 +732,7 @@ zink_draw(struct pipe_context *pctx,
|
|||
update_gfx_pipeline<DYNAMIC_STATE, BATCH_CHANGED>(ctx, bs, mode) :
|
||||
false;
|
||||
|
||||
emit_dynamic_state<DYNAMIC_STATE, BATCH_CHANGED>(ctx, pipeline_changed, ctx->vp_state.num_viewports);
|
||||
emit_dynamic_state<DYNAMIC_STATE, BATCH_CHANGED>(ctx, pipeline_changed, ctx->vp_state.num_viewports, ctx->curr_program->base.uses_shobj);
|
||||
|
||||
bool using_depth_bias = zink_prim_type(ctx, dinfo) == MESA_PRIM_TRIANGLES && rast_state->offset_fill;
|
||||
if (BATCH_CHANGED || using_depth_bias != ctx->was_using_depth_bias || ctx->depth_bias_changed) {
|
||||
|
|
@ -1009,7 +1009,6 @@ update_mesh_pipeline(struct zink_context *ctx, struct zink_batch_state *bs)
|
|||
/* always rebind all stages */
|
||||
VKCTX(CmdBindShadersEXT)(bs->cmdbuf, ZINK_GFX_SHADER_COUNT, stages, ctx->mesh_program->objects);
|
||||
VKCTX(CmdBindShadersEXT)(bs->cmdbuf, 2, &stages[MESA_SHADER_TASK], &ctx->mesh_program->objects[MESA_SHADER_TASK]);
|
||||
VKCTX(CmdSetSampleLocationsEnableEXT)(bs->cmdbuf, ctx->gfx_pipeline_state.custom_sample_locations);
|
||||
VKCTX(CmdSetDepthBiasEnable)(bs->cmdbuf, VK_TRUE);
|
||||
pipeline_changed = true;
|
||||
}
|
||||
|
|
@ -1079,7 +1078,7 @@ zink_draw_mesh_tasks(struct pipe_context *pctx, const struct pipe_grid_info *inf
|
|||
update_mesh_pipeline<BATCH_CHANGED>(ctx, bs) :
|
||||
false;
|
||||
|
||||
emit_dynamic_state<ZINK_DYNAMIC_STATE3, BATCH_CHANGED>(ctx, pipeline_changed, ctx->vp_state.mesh_num_viewports);
|
||||
emit_dynamic_state<ZINK_DYNAMIC_STATE3, BATCH_CHANGED>(ctx, pipeline_changed, ctx->vp_state.mesh_num_viewports, ctx->mesh_program->base.uses_shobj);
|
||||
|
||||
struct zink_rasterizer_state *rast_state = ctx->rast_state;
|
||||
bool using_depth_bias = !!rast_state->offset_fill;
|
||||
|
|
|
|||
|
|
@ -138,12 +138,6 @@ zink_create_gfx_pipeline(struct zink_screen *screen,
|
|||
ms_state.sampleShadingEnable = VK_TRUE;
|
||||
ms_state.minSampleShading = MIN2((float)(state->rast_samples + 1) / (state->min_samples + 1), 1.0f);
|
||||
}
|
||||
VkPipelineSampleLocationsStateCreateInfoEXT pslsci = {
|
||||
VK_STRUCTURE_TYPE_PIPELINE_SAMPLE_LOCATIONS_STATE_CREATE_INFO_EXT,
|
||||
NULL,
|
||||
VK_TRUE,
|
||||
.sampleLocationsInfo.sType = VK_STRUCTURE_TYPE_SAMPLE_LOCATIONS_INFO_EXT
|
||||
};
|
||||
|
||||
VkPipelineViewportStateCreateInfo viewport_state = {0};
|
||||
VkPipelineViewportDepthClipControlCreateInfoEXT clip = {
|
||||
|
|
@ -214,10 +208,6 @@ zink_create_gfx_pipeline(struct zink_screen *screen,
|
|||
VK_DYNAMIC_STATE_STENCIL_REFERENCE,
|
||||
};
|
||||
unsigned state_count = 4;
|
||||
if (state->custom_sample_locations) {
|
||||
dynamicStateEnables[state_count++] = VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT;
|
||||
ms_state.pNext = &pslsci;
|
||||
}
|
||||
if (screen->info.have_EXT_extended_dynamic_state) {
|
||||
dynamicStateEnables[state_count++] = VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT;
|
||||
dynamicStateEnables[state_count++] = VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT;
|
||||
|
|
@ -282,6 +272,10 @@ zink_create_gfx_pipeline(struct zink_screen *screen,
|
|||
if (screen->info.dynamic_state3_feats.extendedDynamicState3RepresentativeFragmentTestEnable)
|
||||
dynamicStateEnables[state_count++] = VK_DYNAMIC_STATE_REPRESENTATIVE_FRAGMENT_TEST_ENABLE_NV;
|
||||
}
|
||||
if (screen->base.caps.programmable_sample_locations) {
|
||||
dynamicStateEnables[state_count++] = VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT;
|
||||
dynamicStateEnables[state_count++] = VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_ENABLE_EXT;
|
||||
}
|
||||
if (screen->info.have_EXT_color_write_enable)
|
||||
dynamicStateEnables[state_count++] = VK_DYNAMIC_STATE_COLOR_WRITE_ENABLE_EXT;
|
||||
|
||||
|
|
@ -542,24 +536,18 @@ zink_create_gfx_pipeline_output(struct zink_screen *screen, struct zink_gfx_pipe
|
|||
ms_state.sampleShadingEnable = VK_TRUE;
|
||||
ms_state.minSampleShading = MIN2((float)(state->rast_samples + 1) / (state->min_samples + 1), 1.0f);
|
||||
}
|
||||
VkPipelineSampleLocationsStateCreateInfoEXT pslsci = {
|
||||
VK_STRUCTURE_TYPE_PIPELINE_SAMPLE_LOCATIONS_STATE_CREATE_INFO_EXT,
|
||||
NULL,
|
||||
VK_TRUE,
|
||||
.sampleLocationsInfo.sType = VK_STRUCTURE_TYPE_SAMPLE_LOCATIONS_INFO_EXT
|
||||
};
|
||||
|
||||
VkDynamicState dynamicStateEnables[30] = {
|
||||
VK_DYNAMIC_STATE_BLEND_CONSTANTS,
|
||||
};
|
||||
unsigned state_count = 1;
|
||||
if (state->custom_sample_locations) {
|
||||
dynamicStateEnables[state_count++] = VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT;
|
||||
ms_state.pNext = &pslsci;
|
||||
}
|
||||
if (screen->info.have_EXT_color_write_enable)
|
||||
dynamicStateEnables[state_count++] = VK_DYNAMIC_STATE_COLOR_WRITE_ENABLE_EXT;
|
||||
|
||||
if (screen->base.caps.programmable_sample_locations) {
|
||||
dynamicStateEnables[state_count++] = VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT;
|
||||
dynamicStateEnables[state_count++] = VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_ENABLE_EXT;
|
||||
}
|
||||
if (screen->have_full_ds3) {
|
||||
dynamicStateEnables[state_count++] = VK_DYNAMIC_STATE_SAMPLE_MASK_EXT;
|
||||
dynamicStateEnables[state_count++] = VK_DYNAMIC_STATE_RASTERIZATION_SAMPLES_EXT;
|
||||
|
|
|
|||
|
|
@ -883,7 +883,8 @@ zink_init_screen_caps(struct zink_screen *screen)
|
|||
|
||||
caps->programmable_sample_locations =
|
||||
screen->info.have_EXT_sample_locations &&
|
||||
screen->info.sample_locations_props.variableSampleLocations;
|
||||
screen->info.sample_locations_props.variableSampleLocations &&
|
||||
screen->info.dynamic_state3_feats.extendedDynamicState3SampleLocationsEnable;
|
||||
|
||||
caps->query_time_elapsed = screen->timestamp_valid_bits > 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -881,7 +881,7 @@ struct zink_gfx_pipeline_state {
|
|||
uint32_t feedback_loop : 1;
|
||||
uint32_t feedback_loop_zs : 1;
|
||||
uint32_t rast_attachment_order : 1;
|
||||
uint32_t custom_sample_locations : 1;
|
||||
uint32_t pad : 1;
|
||||
uint32_t rp_state : 16;
|
||||
VkSampleMask sample_mask;
|
||||
uint32_t blend_id;
|
||||
|
|
@ -1851,6 +1851,7 @@ struct zink_context {
|
|||
float blend_constants[4];
|
||||
|
||||
bool sample_locations_changed;
|
||||
bool sample_locations_enabled;
|
||||
VkSampleLocationEXT vk_sample_locations[PIPE_MAX_SAMPLE_LOCATION_GRID_SIZE * PIPE_MAX_SAMPLE_LOCATION_GRID_SIZE];
|
||||
uint8_t sample_locations[2 * 4 * 8 * 16];
|
||||
unsigned num_sample_locations;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue