diff options
author | Erik Faye-Lund <[email protected]> | 2020-04-28 13:28:16 +0200 |
---|---|---|
committer | Marge Bot <[email protected]> | 2020-05-05 09:17:51 +0000 |
commit | 8471f7a5fa1d5c00de9f314eaccd23dd0e62e71b (patch) | |
tree | d3a03bc56454dc7fc3ceec38e9eb35f05f3730ac /src/compiler | |
parent | 8059f206da88a7a2147c66b3057d60d775cbbfce (diff) |
compiler/glsl: explicitly store NumUniformBlocks
It's not great to use shader_info for this information, because it
might have gone through lowering of uniforms to UBOs, which can change
the number of UBOs. So let's make sure we know the size of the
UniformBlocks array from when the shader was linked instead.
Reviewed-by: Alyssa Rosenzweig <[email protected]>
Reviewed-by: Eric Anholt <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4734>
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/glsl/gl_nir_link_uniform_blocks.c | 5 | ||||
-rw-r--r-- | src/compiler/glsl/linker.cpp | 1 | ||||
-rw-r--r-- | src/compiler/glsl/serialize.cpp | 10 |
3 files changed, 10 insertions, 6 deletions
diff --git a/src/compiler/glsl/gl_nir_link_uniform_blocks.c b/src/compiler/glsl/gl_nir_link_uniform_blocks.c index 53f03fe2a80..07f1614a40c 100644 --- a/src/compiler/glsl/gl_nir_link_uniform_blocks.c +++ b/src/compiler/glsl/gl_nir_link_uniform_blocks.c @@ -302,8 +302,10 @@ nir_interstage_cross_validate_uniform_blocks(struct gl_shader_program *prog, if (block_type == BLOCK_SSBO) prog->data->ShaderStorageBlocks = blks; - else + else { + prog->data->NumUniformBlocks = *num_blks; prog->data->UniformBlocks = blks; + } return true; } @@ -610,6 +612,7 @@ gl_nir_link_uniform_blocks(struct gl_context *ctx, linked->Program->sh.UniformBlocks = ralloc_array(linked, struct gl_uniform_block *, num_ubo_blocks); ralloc_steal(linked, ubo_blocks); + linked->Program->sh.NumUniformBlocks = num_ubo_blocks; for (unsigned i = 0; i < num_ubo_blocks; i++) { linked->Program->sh.UniformBlocks[i] = &ubo_blocks[i]; } diff --git a/src/compiler/glsl/linker.cpp b/src/compiler/glsl/linker.cpp index b3175090c71..a49c5e6ccc2 100644 --- a/src/compiler/glsl/linker.cpp +++ b/src/compiler/glsl/linker.cpp @@ -2568,6 +2568,7 @@ link_intrastage_shaders(void *mem_ctx, for (unsigned i = 0; i < num_ubo_blocks; i++) { linked->Program->sh.UniformBlocks[i] = &ubo_blocks[i]; } + linked->Program->sh.NumUniformBlocks = num_ubo_blocks; linked->Program->info.num_ubos = num_ubo_blocks; /* Copy ssbo blocks to linked shader list */ diff --git a/src/compiler/glsl/serialize.cpp b/src/compiler/glsl/serialize.cpp index d4aacc1cb95..2f68d1b9785 100644 --- a/src/compiler/glsl/serialize.cpp +++ b/src/compiler/glsl/serialize.cpp @@ -139,10 +139,10 @@ write_buffer_blocks(struct blob *metadata, struct gl_shader_program *prog) struct gl_program *glprog = sh->Program; - blob_write_uint32(metadata, glprog->info.num_ubos); + blob_write_uint32(metadata, glprog->sh.NumUniformBlocks); blob_write_uint32(metadata, glprog->info.num_ssbos); - for (unsigned j = 0; j < glprog->info.num_ubos; j++) { + for (unsigned j = 0; j < glprog->sh.NumUniformBlocks; j++) { uint32_t offset = glprog->sh.UniformBlocks[j] - prog->data->UniformBlocks; blob_write_uint32(metadata, offset); @@ -215,15 +215,15 @@ read_buffer_blocks(struct blob_reader *metadata, struct gl_program *glprog = sh->Program; - glprog->info.num_ubos = blob_read_uint32(metadata); + glprog->sh.NumUniformBlocks = blob_read_uint32(metadata); glprog->info.num_ssbos = blob_read_uint32(metadata); glprog->sh.UniformBlocks = - rzalloc_array(glprog, gl_uniform_block *, glprog->info.num_ubos); + rzalloc_array(glprog, gl_uniform_block *, glprog->sh.NumUniformBlocks); glprog->sh.ShaderStorageBlocks = rzalloc_array(glprog, gl_uniform_block *, glprog->info.num_ssbos); - for (unsigned j = 0; j < glprog->info.num_ubos; j++) { + for (unsigned j = 0; j < glprog->sh.NumUniformBlocks; j++) { uint32_t offset = blob_read_uint32(metadata); glprog->sh.UniformBlocks[j] = prog->data->UniformBlocks + offset; } |