From 637b168470190507c89eca8a7d0479103fe236ae Mon Sep 17 00:00:00 2001 From: Arcady Goldmints-Orlov Date: Mon, 28 Jan 2019 10:19:28 -0600 Subject: [PATCH] nir/linker: Initialize UniformDataDefaults when using SPIR-V 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 --- src/compiler/glsl/gl_nir_link_uniform_initializers.c | 3 +++ src/compiler/glsl/gl_nir_link_uniforms.c | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/src/compiler/glsl/gl_nir_link_uniform_initializers.c b/src/compiler/glsl/gl_nir_link_uniform_initializers.c index 53a3ab9a0a2..1c4529c9307 100644 --- a/src/compiler/glsl/gl_nir_link_uniform_initializers.c +++ b/src/compiler/glsl/gl_nir_link_uniform_initializers.c @@ -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); + } diff --git a/src/compiler/glsl/gl_nir_link_uniforms.c b/src/compiler/glsl/gl_nir_link_uniforms.c index 1478046c183..ac97334e9cd 100644 --- a/src/compiler/glsl/gl_nir_link_uniforms.c +++ b/src/compiler/glsl/gl_nir_link_uniforms.c @@ -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. */ -- 2.30.2