Mesa (master): tu: Support pipelines without a fragment shader
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Thu May 7 16:40:08 UTC 2020
Module: Mesa
Branch: master
Commit: 6d513eb0db25a272da65822f35907456b544f172
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=6d513eb0db25a272da65822f35907456b544f172
Author: Connor Abbott <cwabbott0 at gmail.com>
Date: Thu May 7 00:07:48 2020 +0200
tu: Support pipelines without a fragment shader
Apparently this is allowed, and the CTS started doing this more often
recently which resulted in frequent hangs running the entire CTS. I
copied the code to create an empty FS from radv.
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4928>
---
src/freedreno/vulkan/tu_pipeline.c | 2 +-
src/freedreno/vulkan/tu_shader.c | 26 +++++++++++++++++++-------
2 files changed, 20 insertions(+), 8 deletions(-)
diff --git a/src/freedreno/vulkan/tu_pipeline.c b/src/freedreno/vulkan/tu_pipeline.c
index 1e376a120b5..33629457289 100644
--- a/src/freedreno/vulkan/tu_pipeline.c
+++ b/src/freedreno/vulkan/tu_pipeline.c
@@ -2116,7 +2116,7 @@ tu_pipeline_builder_compile_shaders(struct tu_pipeline_builder *builder)
for (gl_shader_stage stage = MESA_SHADER_STAGES - 1;
stage > MESA_SHADER_NONE; stage--) {
const VkPipelineShaderStageCreateInfo *stage_info = stage_infos[stage];
- if (!stage_info)
+ if (!stage_info && stage != MESA_SHADER_FRAGMENT)
continue;
struct tu_shader *shader =
diff --git a/src/freedreno/vulkan/tu_shader.c b/src/freedreno/vulkan/tu_shader.c
index 33826e37691..4fda6538fdf 100644
--- a/src/freedreno/vulkan/tu_shader.c
+++ b/src/freedreno/vulkan/tu_shader.c
@@ -472,8 +472,6 @@ tu_shader_create(struct tu_device *dev,
struct tu_pipeline_layout *layout,
const VkAllocationCallbacks *alloc)
{
- const struct tu_shader_module *module =
- tu_shader_module_from_handle(stage_info->module);
struct tu_shader *shader;
const uint32_t max_variant_count = (stage == MESA_SHADER_VERTEX) ? 2 : 1;
@@ -484,11 +482,25 @@ tu_shader_create(struct tu_device *dev,
if (!shader)
return NULL;
- /* translate SPIR-V to NIR */
- assert(module->code_size % 4 == 0);
- nir_shader *nir = tu_spirv_to_nir(
- dev->compiler, (const uint32_t *) module->code, module->code_size / 4,
- stage, stage_info->pName, stage_info->pSpecializationInfo);
+ nir_shader *nir;
+ if (stage_info) {
+ /* translate SPIR-V to NIR */
+ const struct tu_shader_module *module =
+ tu_shader_module_from_handle(stage_info->module);
+ assert(module->code_size % 4 == 0);
+ nir = tu_spirv_to_nir(
+ dev->compiler, (const uint32_t *) module->code, module->code_size / 4,
+ stage, stage_info->pName, stage_info->pSpecializationInfo);
+ } else {
+ assert(stage == MESA_SHADER_FRAGMENT);
+ nir_builder fs_b;
+ const nir_shader_compiler_options *nir_options =
+ ir3_get_compiler_options(dev->compiler);
+ nir_builder_init_simple_shader(&fs_b, NULL, MESA_SHADER_FRAGMENT, nir_options);
+ fs_b.shader->info.name = ralloc_strdup(fs_b.shader, "noop_fs");
+ nir = fs_b.shader;
+ }
+
if (!nir) {
vk_free2(&dev->alloc, alloc, shader);
return NULL;
More information about the mesa-commit
mailing list