nir/linker: Add gl_nir_link_uniforms()
authorEduardo Lima Mitev <elima@igalia.com>
Tue, 14 Nov 2017 11:25:47 +0000 (12:25 +0100)
committerAlejandro Piñeiro <apinheiro@igalia.com>
Thu, 21 Jun 2018 12:25:05 +0000 (14:25 +0200)
commit7a9e5cdfbb99c4f7acd0a4a5910a99a2ce5b6119
tree068e65cee30af3d64d6fc0224b488044b1eec052
parentaa95f0bc5b05fdab4e258d02c1a69abd8317920e
nir/linker: Add gl_nir_link_uniforms()

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 <elima@igalia.com>
Signed-off-by: Neil Roberts <nroberts@igalia.com
Signed-off-by: Alejandro Piñeiro <apinheiro@igalia.com>
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
src/compiler/Makefile.sources
src/compiler/glsl/gl_nir_link_uniforms.c [new file with mode: 0644]
src/compiler/glsl/gl_nir_linker.h [new file with mode: 0644]
src/compiler/glsl/meson.build