Mesa (master): turnip: fix a crash when rasterizerDiscardEnable is set
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Thu Jun 18 03:39:57 UTC 2020
Module: Mesa
Branch: master
Commit: ff2efd095e5a7543268e40112978b293a82518a7
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=ff2efd095e5a7543268e40112978b293a82518a7
Author: Jonathan Marek <jonathan at marek.ca>
Date: Wed Jun 17 14:23:37 2020 -0400
turnip: fix a crash when rasterizerDiscardEnable is set
pMultisampleState needs to be ignored when rasterizerDiscardEnable, so the
current code can crash when trying to load msaa_info->pNext.
At the same time this simplifies tu_pipeline_shader_key_init a bit, by not
calling it for the compute shader case (which doesn't need to set anything
in the key struct).
Signed-off-by: Jonathan Marek <jonathan at marek.ca>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5499>
---
src/freedreno/vulkan/tu_pipeline.c | 43 ++++++++++++++++----------------------
1 file changed, 18 insertions(+), 25 deletions(-)
diff --git a/src/freedreno/vulkan/tu_pipeline.c b/src/freedreno/vulkan/tu_pipeline.c
index 418023eb4bf..f48958321d3 100644
--- a/src/freedreno/vulkan/tu_pipeline.c
+++ b/src/freedreno/vulkan/tu_pipeline.c
@@ -1856,33 +1856,27 @@ static void
tu_pipeline_shader_key_init(struct ir3_shader_key *key,
const VkGraphicsPipelineCreateInfo *pipeline_info)
{
- bool has_gs = false;
- bool msaa = false;
- if (pipeline_info) {
- for (uint32_t i = 0; i < pipeline_info->stageCount; i++) {
- if (pipeline_info->pStages[i].stage == VK_SHADER_STAGE_GEOMETRY_BIT) {
- has_gs = true;
- break;
- }
+ for (uint32_t i = 0; i < pipeline_info->stageCount; i++) {
+ if (pipeline_info->pStages[i].stage == VK_SHADER_STAGE_GEOMETRY_BIT) {
+ key->has_gs = true;
+ break;
}
+ }
- const VkPipelineMultisampleStateCreateInfo *msaa_info = pipeline_info->pMultisampleState;
- const struct VkPipelineSampleLocationsStateCreateInfoEXT *sample_locations =
- vk_find_struct_const(msaa_info->pNext, PIPELINE_SAMPLE_LOCATIONS_STATE_CREATE_INFO_EXT);
- if (!pipeline_info->pRasterizationState->rasterizerDiscardEnable &&
- (msaa_info->rasterizationSamples > 1 ||
- /* also set msaa key when sample location is not the default
- * since this affects varying interpolation */
- (sample_locations && sample_locations->sampleLocationsEnable))) {
- msaa = true;
- }
+ if (pipeline_info->pRasterizationState->rasterizerDiscardEnable)
+ return;
+
+ const VkPipelineMultisampleStateCreateInfo *msaa_info = pipeline_info->pMultisampleState;
+ const struct VkPipelineSampleLocationsStateCreateInfoEXT *sample_locations =
+ vk_find_struct_const(msaa_info->pNext, PIPELINE_SAMPLE_LOCATIONS_STATE_CREATE_INFO_EXT);
+ if (msaa_info->rasterizationSamples > 1 ||
+ /* also set msaa key when sample location is not the default
+ * since this affects varying interpolation */
+ (sample_locations && sample_locations->sampleLocationsEnable)) {
+ key->msaa = true;
}
/* TODO: Populate the remaining fields of ir3_shader_key. */
- *key = (struct ir3_shader_key) {
- .has_gs = has_gs,
- .msaa = msaa,
- };
}
static VkResult
@@ -1897,7 +1891,7 @@ tu_pipeline_builder_compile_shaders(struct tu_pipeline_builder *builder)
stage_infos[stage] = &builder->create_info->pStages[i];
}
- struct ir3_shader_key key;
+ struct ir3_shader_key key = {};
tu_pipeline_shader_key_init(&key, builder->create_info);
for (gl_shader_stage stage = MESA_SHADER_VERTEX;
@@ -2512,8 +2506,7 @@ tu_compute_pipeline_create(VkDevice device,
pipeline->layout = layout;
- struct ir3_shader_key key;
- tu_pipeline_shader_key_init(&key, NULL);
+ struct ir3_shader_key key = {};
struct tu_shader *shader =
tu_shader_create(dev, MESA_SHADER_COMPUTE, stage_info, layout, pAllocator);
More information about the mesa-commit
mailing list