aboutsummaryrefslogtreecommitdiffstats
path: root/src/compiler/glsl/gl_nir_linker.h
Commit message (Collapse)AuthorAgeFilesLines
* nir/linker: add gl_nir_link_uniform_blocks.cAlejandro Piñeiro2019-06-301-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Adding the ability to link uniform blocks and shader storage blocks using NIR, intended for ARB_gl_spirv support. Among other things, this linking needs to take into account that everything should work without names, as they could be not present, while the GLSL IR uniform block linking was wrote with the names on its core. The other major difference compared with the GLSL IR linker is that we don't deal with layouts. There are no references to std140, std430, etc. Layouts are expressed through explicit offset, array stride and matrix stride. That simplifies how the buffer size are computed. But also means that we couldn't use the existing methods at glsl_types, so we needed to implement new methods. It is worth to note that this linking do a iteration over the glsl_types, similarly to what the linking uniforms do. A possible future improvement would be refactor both cases to try to share more code that it sharing right now. On GLSL IR there are a class visitor, specialized on each case, for that sharing. As adding a class visitor on C would more complicated, for now we are just iterating on both. Signed-off-by: Alejandro Piñeiro <[email protected]> Signed-off-by: Neil Roberts <[email protected]> Signed-off-by: Antia Puentes <[email protected]> v2: (from Timothy review) * Fix variable name convention * Stop to use _function_name convention * Don't use // for comments * "nir/linker: Keep track of the stages referencing an UBO/SSBO" squashed with this patch v3: (from Caio review) * Don't delete the linked shader on failure * Use rzalloc_array to avoid some explicit initializations Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Caio Marcelo de Oliveira Filho <[email protected]>
* nir/linker: Add the start of a pure-NIR linker for XFBNeil Roberts2018-07-311-0/+3
| | | | | | | | | | | | | | | | | | | | v2: ignore names on purpose, for consistency with other places where we are doing the same (Alejandro) v3: changes proposed by Timothy Arceri, implemented by Alejandro Piñeiro: * Remove redundant 'struct active_xfb_varying' * Update several comments, including spec quotes if needed * Rename struct 'active_xfb_varying_array' to 'active_xfb_varyings' * Rename variable 'array' to 'active_varyings' * Replace one if condition for an assert (<MAX_FEEDBACK_BUFFERS) * Remove BufferMode initialization (was already done) v4: simplify output pointer handling (Timothy) Signed-off-by: Neil Roberts <[email protected]> Signed-off-by: Alejandro Piñeiro <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* nir/linker: Add a pure NIR implementation of the atomic counter linkerNeil Roberts2018-07-031-0/+3
| | | | | | | | | | | | This is mostly just a straight-forward conversion of link_assign_atomic_counter_resources to C directly using nir variables instead of GLSL IR variables. It is based on the version of link_assign_atomic_counter_resources in 6b8909f2d1906. I’m noting this here to make it easier to track changes and keep the NIR version up-to-date. Reviewed-by: Timothy Arceri <[email protected]>
* nir/linker: Add nir_build_program_resource_list()Eduardo Lima Mitev2018-06-211-0/+3
| | | | | | | | | | | | | | | | | | This function is equivalent to the linker.cpp build_program_resource_list() but will extract the resources from NIR shaders instead. For now, only uniforms and program inputs are implemented. v2: move from compiler/nir to compiler/glsl (Timothy Arceri) v3: remove support for inputs, that is still WIP (spotted by Timothy Arceri) Signed-off-by: Eduardo Lima <[email protected]> Signed-off-by: Alejandro Piñeiro <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* nir/linker: Set the uniform initial valuesNeil Roberts2018-06-211-0/+3
| | | | | | | | This is based on link_uniform_initializers.cpp. v2: move from compiler/nir to compiler/glsl (Timothy Arceri) Reviewed-by: Timothy Arceri <[email protected]>
* nir/linker: Add gl_nir_link_uniforms()Eduardo Lima Mitev2018-06-211-0/+41
This function will be the entry point for linking the uniforms from the nir_shader objects associated with the gl_linked_shaders of a program. This patch includes initial support for linking uniforms from NIR shaders. It is tailored for the ARB_gl_spirv needs, and it is far from complete, but it should handle most cases of uniforms, array uniforms, structs, samplers and images. There are some FIXMEs related to specific features that will be implemented in following patches, like atomic counters, UBOs and SSBOs. Also, note that ARB_gl_spirv makes mandatory explicit location for normal uniforms, so this code only handles uniforms with explicit location. But there are cases, like uniform atomic counters, that doesn't have a location from the OpenGL point of view (they have a binding), but that Mesa assign internally a location. That will be handled on following patches. A nir_linker.h file is also added. More NIR-linking related API will be added in subsequent patches and those will include stuff from Mesa, so reusing nir.h didn't seem a good idea. v2: move from compiler/nir to compiler/glsl (Timothy Arceri) v3: sets var->driver.location if the uniform was found from a previous stage (Neil Roberts). Signed-off-by: Eduardo Lima <[email protected]> Signed-off-by: Neil Roberts <[email protected] Signed-off-by: Alejandro Piñeiro <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>