glsl: fix the type of ir_constant_data::u16
[mesa.git] / src / compiler / glsl / gl_nir_link_uniform_blocks.c
index 28faa7e76263576603bb105ecfbbc4a039561f6c..07f1614a40c99322b673127f4aa9c42045d8975a 100644 (file)
 #include "linker_util.h"
 #include "main/mtypes.h"
 
-/* Summary: This file contains code to do a nir-based linking for uniform
- * blocks. This includes ubos and ssbos.  Note that it is tailored to
- * ARB_gl_spirv needs and particularities.
+/**
+ * This file contains code to do a nir-based linking for uniform blocks. This
+ * includes ubos and ssbos.
  *
- * More details:
+ * For the case of ARB_gl_spirv there are some differences compared with GLSL:
  *
  * 1. Linking doesn't use names: GLSL linking use names as core concept. But
  *    on SPIR-V, uniform block name, fields names, and other names are
@@ -67,8 +67,9 @@
  *    RESOLVED.  Pick (c), but also allow debug names to be returned if an
  *    implementation wants to."
  *
- * This implemention doesn't care for the names, as the main objective is
- * functional, and not support optional debug features.
+ * When linking SPIR-V shaders this implemention doesn't care for the names,
+ * as the main objective is functional, and not support optional debug
+ * features.
  *
  * 2. Terminology: this file handles both UBO and SSBO, including both as
  *    "uniform blocks" analogously to what is done in the GLSL (IR) path.
  *       <skip>
  *       buffer  blockN { ... } ...;  -> Uniform, with BufferBlock decoration"
  *
- * 3. Explicit data: The code assumes that all structure members have an
- *    Offset decoration, all arrays have an ArrayStride and all matrices have
- *    a MatrixStride, even for nested structures. That way we don’t have to
- *    worry about the different layout modes. This is explicitly required in
- *    the SPIR-V spec:
+ * 3. Explicit data: for the SPIR-V path the code assumes that all structure
+ *    members have an Offset decoration, all arrays have an ArrayStride and
+ *    all matrices have a MatrixStride, even for nested structures. That way
+ *    we don’t have to worry about the different layout modes. This is
+ *    explicitly required in the SPIR-V spec:
  *
  *    "Composite objects in the UniformConstant, Uniform, and PushConstant
  *     Storage Classes must be explicitly laid out. The following apply to all
@@ -301,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;
 }
@@ -609,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];
       }