diff options
author | Jonathan Gray <jsg@cvs.openbsd.org> | 2020-01-22 02:13:18 +0000 |
---|---|---|
committer | Jonathan Gray <jsg@cvs.openbsd.org> | 2020-01-22 02:13:18 +0000 |
commit | fdcc03929065b5bf5dd93553db219ea3e05c8c34 (patch) | |
tree | ca90dc8d9e89febdcd4160956c1b8ec098a4efc9 /lib/mesa/src/compiler/glsl/linker_util.cpp | |
parent | 3c9de4a7e13712b5696750bbd59a18c848742022 (diff) |
Import Mesa 19.2.8
Diffstat (limited to 'lib/mesa/src/compiler/glsl/linker_util.cpp')
-rw-r--r-- | lib/mesa/src/compiler/glsl/linker_util.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/lib/mesa/src/compiler/glsl/linker_util.cpp b/lib/mesa/src/compiler/glsl/linker_util.cpp index d2724c239..99e3693b5 100644 --- a/lib/mesa/src/compiler/glsl/linker_util.cpp +++ b/lib/mesa/src/compiler/glsl/linker_util.cpp @@ -28,6 +28,43 @@ /* Utility methods shared between the GLSL IR and the NIR */ +/* From the OpenGL 4.6 specification, 7.3.1.1 Naming Active Resources: + * + * "For an active shader storage block member declared as an array of an + * aggregate type, an entry will be generated only for the first array + * element, regardless of its type. Such block members are referred to as + * top-level arrays. If the block member is an aggregate type, the + * enumeration rules are then applied recursively." + */ +bool +link_util_should_add_buffer_variable(struct gl_shader_program *prog, + struct gl_uniform_storage *uniform, + int top_level_array_base_offset, + int top_level_array_size_in_bytes, + int second_element_offset, + int block_index) +{ + /* If the uniform is not a shader storage buffer or is not an array return + * true. + */ + if (!uniform->is_shader_storage || top_level_array_size_in_bytes == 0) + return true; + + int after_top_level_array = top_level_array_base_offset + + top_level_array_size_in_bytes; + + /* Check for a new block, or that we are not dealing with array elements of + * a top member array other than the first element. + */ + if (block_index != uniform->block_index || + uniform->offset >= after_top_level_array || + uniform->offset < second_element_offset) { + return true; + } + + return false; +} + bool link_util_add_program_resource(struct gl_shader_program *prog, struct set *resource_set, |