diff --git a/src/intel/vulkan/anv_nir.h b/src/intel/vulkan/anv_nir.h index 5751f74c1cb..86705dfd4f6 100644 --- a/src/intel/vulkan/anv_nir.h +++ b/src/intel/vulkan/anv_nir.h @@ -31,11 +31,13 @@ extern "C" { #endif -bool anv_check_for_primitive_replication(nir_shader **shaders, - struct anv_graphics_pipeline *pipeline); +bool anv_check_for_primitive_replication(struct anv_device *device, + VkShaderStageFlags stages, + nir_shader **shaders, + uint32_t view_mask); -bool anv_nir_lower_multiview(nir_shader *shader, - struct anv_graphics_pipeline *pipeline); +bool anv_nir_lower_multiview(nir_shader *shader, uint32_t view_mask, + bool use_primitive_replication); bool anv_nir_lower_ycbcr_textures(nir_shader *shader, const struct anv_pipeline_layout *layout); diff --git a/src/intel/vulkan/anv_nir_lower_multiview.c b/src/intel/vulkan/anv_nir_lower_multiview.c index 3272b2fae33..dd591976ac4 100644 --- a/src/intel/vulkan/anv_nir_lower_multiview.c +++ b/src/intel/vulkan/anv_nir_lower_multiview.c @@ -176,11 +176,10 @@ replace_load_view_index_with_layer_id(struct nir_builder *b, } bool -anv_nir_lower_multiview(nir_shader *shader, - struct anv_graphics_pipeline *pipeline) +anv_nir_lower_multiview(nir_shader *shader, uint32_t view_mask, + bool use_primitive_replication) { assert(shader->info.stage != MESA_SHADER_COMPUTE); - uint32_t view_mask = pipeline->view_mask; /* If multiview isn't enabled, just lower the ViewIndex builtin to zero. */ if (view_mask == 0) { @@ -201,8 +200,8 @@ anv_nir_lower_multiview(nir_shader *shader, * view, then it is possible to use the feature instead of instancing to * implement multiview. */ - if (pipeline->use_primitive_replication) { - bool progress = nir_lower_multiview(shader, pipeline->view_mask); + if (use_primitive_replication) { + bool progress = nir_lower_multiview(shader, view_mask); if (progress) { nir_builder b; @@ -289,10 +288,12 @@ anv_nir_lower_multiview(nir_shader *shader, } bool -anv_check_for_primitive_replication(nir_shader **shaders, - struct anv_graphics_pipeline *pipeline) +anv_check_for_primitive_replication(struct anv_device *device, + VkShaderStageFlags stages, + nir_shader **shaders, + uint32_t view_mask) { - assert(pipeline->base.device->info->ver >= 12); + assert(device->info->ver >= 12); static int primitive_replication_max_views = -1; if (primitive_replication_max_views < 0) { @@ -312,11 +313,9 @@ anv_check_for_primitive_replication(nir_shader **shaders, * later than Vertex. In that case only the last stage can refer to * gl_ViewIndex. */ - if (pipeline->active_stages & ~(VK_SHADER_STAGE_VERTEX_BIT | - VK_SHADER_STAGE_FRAGMENT_BIT)) + if (stages & ~(VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT)) return false; - uint32_t view_mask = pipeline->view_mask; int view_count = util_bitcount(view_mask); if (view_count == 1 || view_count > primitive_replication_max_views) return false; diff --git a/src/intel/vulkan/anv_pipeline.c b/src/intel/vulkan/anv_pipeline.c index e50ccbe5221..cb40ab5d087 100644 --- a/src/intel/vulkan/anv_pipeline.c +++ b/src/intel/vulkan/anv_pipeline.c @@ -711,8 +711,10 @@ anv_pipeline_lower_nir(struct anv_pipeline *pipeline, NIR_PASS(_, nir, anv_nir_lower_ycbcr_textures, layout); if (pipeline->type == ANV_PIPELINE_GRAPHICS) { - NIR_PASS(_, nir, anv_nir_lower_multiview, - anv_pipeline_to_graphics(pipeline)); + struct anv_graphics_pipeline *gfx_pipeline = + anv_pipeline_to_graphics(pipeline); + NIR_PASS(_, nir, anv_nir_lower_multiview, gfx_pipeline->view_mask, + gfx_pipeline->use_primitive_replication); } nir_shader_gather_info(nir, nir_shader_get_entrypoint(nir)); @@ -1612,7 +1614,9 @@ anv_graphics_pipeline_compile(struct anv_graphics_pipeline *pipeline, shaders[s] = stages[s].nir; pipeline->use_primitive_replication = - anv_check_for_primitive_replication(shaders, pipeline); + anv_check_for_primitive_replication(pipeline->base.device, + pipeline->active_stages, + shaders, pipeline->view_mask); } else { pipeline->use_primitive_replication = false; }