turnip: fix binning shader compilation
authorJonathan Marek <jonathan@marek.ca>
Tue, 24 Sep 2019 18:36:53 +0000 (14:36 -0400)
committerJonathan Marek <jonathan@marek.ca>
Wed, 25 Sep 2019 02:32:09 +0000 (22:32 -0400)
ir3 segfaults if nonbinning is NULL for the bininng pass shader.

Signed-off-by: Jonathan Marek <jonathan@marek.ca>
Reviewed-by: Kristian H. Kristensen <hoegsberg@google.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
src/freedreno/vulkan/tu_shader.c

index f6e13d7c42fa5550ecd66c5dffc63232c013afb5..f3d81675bb17e692f4407169ed13bb05efc9fb6e 100644 (file)
@@ -222,13 +222,14 @@ tu_shader_compile_options_init(
 static uint32_t *
 tu_compile_shader_variant(struct ir3_shader *shader,
                           const struct ir3_shader_key *key,
-                          bool binning_pass,
+                          struct ir3_shader_variant *nonbinning,
                           struct ir3_shader_variant *variant)
 {
    variant->shader = shader;
    variant->type = shader->type;
    variant->key = *key;
-   variant->binning_pass = binning_pass;
+   variant->binning_pass = !!nonbinning;
+   variant->nonbinning = nonbinning;
 
    int ret = ir3_compile_shader_nir(shader->compiler, variant);
    if (ret)
@@ -259,7 +260,7 @@ tu_shader_compile(struct tu_device *dev,
    }
 
    shader->binary = tu_compile_shader_variant(
-      &shader->ir3_shader, &options->key, false, &shader->variants[0]);
+      &shader->ir3_shader, &options->key, NULL, &shader->variants[0]);
    if (!shader->binary)
       return VK_ERROR_OUT_OF_HOST_MEMORY;
 
@@ -267,7 +268,8 @@ tu_shader_compile(struct tu_device *dev,
    if (options->include_binning_pass &&
        shader->ir3_shader.type == MESA_SHADER_VERTEX) {
       shader->binning_binary = tu_compile_shader_variant(
-         &shader->ir3_shader, &options->key, true, &shader->variants[1]);
+         &shader->ir3_shader, &options->key, &shader->variants[0],
+         &shader->variants[1]);
       if (!shader->binning_binary)
          return VK_ERROR_OUT_OF_HOST_MEMORY;