nir/linker: Initialize UniformDataDefaults when using SPIR-V
authorArcady Goldmints-Orlov <agoldmints@igalia.com>
Mon, 28 Jan 2019 16:19:28 +0000 (10:19 -0600)
committerAlejandro Piñeiro <apinheiro@igalia.com>
Fri, 12 Jul 2019 21:42:41 +0000 (23:42 +0200)
Allocate UniformDataDefaults and fill in the data defaults when
linking a SPIR-V program. Among other things, this allows program
serialization to work.

It allows the following piglit test (when run on SPIR-V mode) to pass:
  spec/arb_get_program_binary/execution/uniform-after-restore.shader_test

v2: use memcpy to initialize UniformDataDefaults

Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
src/compiler/glsl/gl_nir_link_uniform_initializers.c
src/compiler/glsl/gl_nir_link_uniforms.c

index 53a3ab9a0a2d0be6458e53a4cfe804f78cdb9437..1c4529c9307088bd3604145ffb732200c44fdc60 100644 (file)
@@ -295,4 +295,7 @@ gl_nir_set_uniform_initializers(struct gl_context *ctx,
          }
       }
    }
+   memcpy(prog->data->UniformDataDefaults, prog->data->UniformDataSlots,
+          sizeof(union gl_constant_value) * prog->data->NumUniformDataSlots);
+
 }
index 1478046c183b9f704f2476bbb13fed77f0761167..ac97334e9cdd54f48f891edba7cbf592318fe072 100644 (file)
@@ -54,6 +54,10 @@ nir_setup_uniform_remap_tables(struct gl_context *ctx,
    }
    prog->data->UniformDataSlots = data;
 
+   prog->data->UniformDataDefaults =
+         rzalloc_array(prog->data->UniformStorage,
+                       union gl_constant_value, prog->data->NumUniformDataSlots);
+
    unsigned data_pos = 0;
 
    /* Reserve all the explicit locations of the active uniforms. */