aboutsummaryrefslogtreecommitdiffstats
path: root/src/glsl/link_uniform_initializers.cpp
Commit message (Collapse)AuthorAgeFilesLines
* mesa: rename gl_shader_program's NumUniformBlocks to NumBufferInterfaceBlocksSamuel Iglesias Gonsalvez2015-09-291-1/+1
| | | | | | | | | | | Because it counts shader storage blocks too. v2: - Use NumBufferInterfaceBlocks instead (Jordan). Signed-off-by: Samuel Iglesias Gonsalvez <[email protected]> Reviewed-by: Jordan Justen <[email protected]> Reviewed-by: Kristian Høgsberg <[email protected]>
* glsl: Add support for image binding qualifiers.Francisco Jerez2015-08-201-7/+22
| | | | | | | | Support for binding an image to an image unit explicitly in the shader source is required by both GLSL 4.2 and GLSL ES 3.1, but not by the original ARB_shader_image_load_store extension. Reviewed-by: Timothy Arceri <[email protected]>
* glsl/types: add new subroutine type (v3.2)Dave Airlie2015-07-231-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | This type will be used to store the name of subroutine types as in subroutine void myfunc(void); will store myfunc into a subroutine type. This is required to the parser can identify a subroutine type in a uniform decleration as a valid type, and also for looking up the type later. Also add contains_subroutine method. v2: handle subroutine to int comparisons, needed for lowering pass. v3: do subroutine to int with it's own IR operation to avoid hacking on asserts (Kayden) v3.1: fix warnings in this patch, fix nir, fix tgsi v3.2: fixup tests Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Chris Forbes <[email protected]> Signed-off-by: Dave Airlie <[email protected]> tests: fix warnings
* glsl: link buffer variables and shader storage buffer interface blocksKristian Høgsberg2015-07-141-1/+2
| | | | Reviewed-by: Jordan Justen <[email protected]>
* mesa: rename is_in_uniform_block to is_in_buffer_blockIago Toral Quiroga2015-07-141-2/+2
| | | | | | | Since this now checks if a variable is inside a uniform or a shader storage block. Reviewed-by: Jordan Justen <[email protected]>
* mesa: reference built-in uniforms into gl_uniform_storageMartin Peres2015-06-041-2/+2
| | | | | | | | | | | | | | | This change introduces a new field in gl_uniform_storage to explicitely say that a uniform is built-in. In the case where it is, no storage is defined to make it clear that it is read-only from the mesa side. I fixed all the places in the code that made use of the structure that I changed. Any place making a wrong assumption and using the storage straight away will just crash. This patch seems to implement the path of least resistance towards listing built-in uniforms in GL_ACTIVE_UNIFORM (and other APIs). Reviewed-by: Tapani Pälli <[email protected]> Signed-off-by: Martin Peres <[email protected]>
* glsl: Linking support for doublesDave Airlie2015-02-191-1/+7
| | | | | | Signed-off-by: Dave Airlie <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Ilia Mirkin <[email protected]>
* glsl: Use the without_array predicate in some more placesTimothy Arceri2014-08-191-2/+1
| | | | | Reviewed-by: Matt Turner <[email protected]> Signed-off-by: Timothy Arceri <[email protected]>
* glsl: Use UniformBooleanTrue value for uniform initializers.Matt Turner2014-08-181-9/+15
| | | | Reviewed-by: Anuj Phogat <[email protected]>
* glsl: Use typed foreach_in_list instead of foreach_list.Matt Turner2014-07-011-2/+2
| | | | Reviewed-by: Ian Romanick <[email protected]>
* glsl: Remove unused includes in link_uniform_init.Thomas Helland2014-06-101-2/+0
| | | | | | | | | | | | Found with IWYU, confirmed with grepping for "hash" and "symbol". No negative effects on compilation. IWYU also reported core.h and linker.h could be removed, but I'm unsure if those are false positives. Reviewed-by: Tom Stellard <[email protected]> Reviewed-by: Matt Turner <[email protected]> Signed-off-by: Thomas Helland <[email protected]>
* glsl: Allow explicit binding on atomics againChris Forbes2014-04-181-1/+3
| | | | | | | | As of 943b2d52bf5, layout(binding) on an atomic would fail the assertion here. Signed-off-by: Chris Forbes <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* linker: Set binding for all elements of UBO arrayIan Romanick2014-04-111-2/+34
| | | | | | | | | | | | | | | | | | Previously, a UBO like layout(binding=2) uniform U { ... } my_constants[4]; wouldn't get any bindings set. The code would try to set the binding of U, but that would fail. It should instead set the bindings for U[0], U[1], ... Signed-off-by: Ian Romanick <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=76323 Reviewed-by: Kenneth Graunke <[email protected]> Cc: "10.1" <[email protected]> Cc: [email protected]
* linker: Set block bindings based on UniformBlocks rather than UniformStorageIan Romanick2014-04-111-11/+21
| | | | | | | | | | | | | | | | | | | For blocks, gl_shader_program::UniformStorage isn't very useful. The names stored there are the names of the elements of the block, so finding blocks with an instance name is hard. There is also only one entry in ::UniformStorage for each element of a block array, and that is a deal breaker. Using ::UniformBlocks is what _mesa_GetUniformBlockIndex does. I contemplated sharing code between set_block_binding and _mesa_GetUniformBlockIndex, but building the stand-alone compiler and the unit tests make this hard. I plan to return to this effort shortly. Signed-off-by: Ian Romanick <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=76323 Reviewed-by: Kenneth Graunke <[email protected]> Cc: "10.1" <[email protected]> Cc: [email protected]
* linker: Clean up "unused parameter" warningsIan Romanick2014-04-111-8/+4
| | | | | | | | | | | | | ../../src/glsl/link_uniform_initializers.cpp:87:1: warning: unused parameter 'mem_ctx' [-Wunused-parameter] ../../src/glsl/link_uniform_initializers.cpp:87:1: warning: unused parameter 'type' [-Wunused-parameter] ../../src/glsl/link_uniform_initializers.cpp:127:1: warning: unused parameter 'mem_ctx' [-Wunused-parameter] ../../src/glsl/link_uniform_initializers.cpp:127:1: warning: unused parameter 'type' [-Wunused-parameter] Signed-off-by: Ian Romanick <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=76323 Reviewed-by: Kenneth Graunke <[email protected]> Cc: "10.1" <[email protected]> Cc: [email protected]
* linker: Fold set_uniform_binding into call siteIan Romanick2014-04-111-21/+12
| | | | | | | | | | | | | | | | In the next patch, we'll see that using gl_shader_program::UniformStorage is not correct for uniform blocks. That means we can't use ::UniformStorage to select between the sampler path and the block path. Instead we want to just use the type of the variable. That's never passed to set_uniform_binding, and it's easier to just remove the function (especially for later patches in the series) than to add another parameter. Signed-off-by: Ian Romanick <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=76323 Reviewed-by: Kenneth Graunke <[email protected]> Cc: "10.1" <[email protected]> Cc: [email protected]
* linker: Various trivial clean-ups in set_sampler_bindingIan Romanick2014-04-111-18/+18
| | | | | | | | | | | | | | | - Remove the spurious block left from the previous commit and re-indent. - Constify elements. - Make the spec reference in the code look like other spec references in the compiler. Signed-off-by: Ian Romanick <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=76323 Reviewed-by: Kenneth Graunke <[email protected]> Cc: "10.1" <[email protected]> Cc: [email protected]
* linker: Split set_uniform_binding into separate functions for blocks and ↵Ian Romanick2014-04-111-3/+39
| | | | | | | | | | | | | | | | | | samplers The two code paths are quite different, and there are some problems in the handling of uniform blocks. Future changes will cause these paths to diverge further. Ultimately, selecting between the two functions will happen at the set_uniform_binding call site, and set_uniform_binding will be deleted. NOTE: This patch just moves code around. Signed-off-by: Ian Romanick <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=76323 Reviewed-by: Kenneth Graunke <[email protected]> Cc: "10.1" <[email protected]> Cc: [email protected]
* glsl: Add image type to the GLSL IR.Francisco Jerez2014-02-121-0/+1
| | | | | | | | | v2: Reuse the glsl_sampler_dim enum for images. Reuse the glsl_type::sampler_* fields instead of creating new ones specific to image types. Reuse the same constructor as for samplers adding a new 'base_type' argument. Reviewed-by: Paul Berry <[email protected]>
* mesa: Clean up nomenclature for pipeline stages.Paul Berry2014-01-081-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, we had an enum called gl_shader_type which represented pipeline stages in the order they occur in the pipeline (i.e. MESA_SHADER_VERTEX=0, MESA_SHADER_GEOMETRY=1, etc), and several inconsistently named functions for converting between it and other representations: - _mesa_shader_type_to_string: gl_shader_type -> string - _mesa_shader_type_to_index: GLenum (GL_*_SHADER) -> gl_shader_type - _mesa_program_target_to_index: GLenum (GL_*_PROGRAM) -> gl_shader_type - _mesa_shader_enum_to_string: GLenum (GL_*_{SHADER,PROGRAM}) -> string This patch tries to clean things up so that we use more consistent terminology: the enum is now called gl_shader_stage (to emphasize that it is in the order of pipeline stages), and the conversion functions are: - _mesa_shader_stage_to_string: gl_shader_stage -> string - _mesa_shader_enum_to_shader_stage: GLenum (GL_*_SHADER) -> gl_shader_stage - _mesa_program_enum_to_shader_stage: GLenum (GL_*_PROGRAM) -> gl_shader_stage - _mesa_progshader_enum_to_string: GLenum (GL_*_{SHADER,PROGRAM}) -> string In addition, MESA_SHADER_TYPES has been renamed to MESA_SHADER_STAGES, for consistency with the new name for the enum. Reviewed-by: Kenneth Graunke <[email protected]> v2: Also rename the "target" field of _mesa_glsl_parse_state and the "target" parameter of _mesa_shader_stage_to_string to "stage". Reviewed-by: Brian Paul <[email protected]>
* glsl: move variables in to ir_variable::data, part IITapani Pälli2013-12-121-2/+2
| | | | | | | | | | | | | This patch moves following bitfields and variables to the data structure: explicit_location, explicit_index, explicit_binding, has_initializer, is_unmatched_generic_inout, location_frac, from_named_ifc_block_nonarray, from_named_ifc_block_array, depth_layout, location, index, binding, max_array_access, atomic Signed-off-by: Tapani Pälli <[email protected]> Reviewed-by: Paul Berry <[email protected]>
* glsl: move variables in to ir_variable::data, part ITapani Pälli2013-12-121-1/+1
| | | | | | | | | | This patch moves following bitfields in to the data structure: used, assigned, how_declared, mode, interpolation, origin_upper_left, pixel_center_integer Signed-off-by: Tapani Pälli <[email protected]> Reviewed-by: Paul Berry <[email protected]>
* glsl: Add new atomic_uint built-in GLSL type.Francisco Jerez2013-10-291-0/+1
| | | | | | | | | v2: Fix GLSL version in which the type became available. Add contains_atomic() convenience method. Split off atomic counter comparison error checking to a separate patch that will handle all opaque types. Include new ir_variable fields for atomic types. Reviewed-by: Ian Romanick <[email protected]>
* glsl: Handle the binding qualifier for UBO variables.Kenneth Graunke2013-07-181-0/+10
| | | | | | | | | | | | | layout(binding = N) is equivalent to calling glUniformBlockBinding(_,N). This currently only handles the GLSL 1.40 case - no interface names, no arrays of uniform blocks. This is okay since we don't yet support GLSL 1.50, and don't expose ARB_shading_language_420pack in ES 3.0. v2: Move into the other function; use binding, not constant_value. Signed-off-by: Kenneth Graunke <[email protected]> Acked-by: Paul Berry <[email protected]>
* glsl: Handle the binding qualifier for arrays of samplers.Kenneth Graunke2013-07-181-0/+25
| | | | | | | | | | | | | | | | | | | | | Normally, uniform array variables are initialized by array literals. That is, val->type->array_elements >= storage->array_elements. However, samplers are different. Consider a declaration such as: layout(binding = 5) uniform sampler2D[3]; The initializer value is a single integer (5), while the storage has 3 array elements. The proper behavior here is to increment one for each element; they should be initialized to 5, 6, and 7. This patch introduces new code for sampler types which handles both arrays of samplers and single samplers correctly. v2: Move into the other function; use binding, not constant_value. Signed-off-by: Kenneth Graunke <[email protected]> Acked-by: Paul Berry <[email protected]>
* glsl: Add plumbing for handling uniform binding qualifiers.Kenneth Graunke2013-07-181-3/+23
| | | | | | | | | | | | | | | Sampler uniforms and uniform blocks do not have a var->constant_value. Instead, they have an integer var->binding value. This makes extending set_uniform_initializer() somewhat problematic: it assumes that there is an ir_constant * which represents the initializer, and that it's safe to dereference that without any NULL checks. Instead, this patch creates an analogous function for binding qualifiers, and calls one or the other as appropriate. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Paul Berry <[email protected]>
* glsl: Delete unused code for handling samplers in array-initializers.Kenneth Graunke2013-07-181-14/+0
| | | | | | | | | | | | | | | | | | | | | | There is existing code to handle sampler uniform initializers. Prior to GLSL 4.20's "binding" keyword, sampler uniforms don't have initializers at all, so this is somewhat surprising. The existing code is broken into two cases: one where both the variable and initializer are arrays, and a second where the variable and initializer are scalars. The first case should never occur, since array-typed initializers do not exist for sampler uniforms. Even with the binding keyword, the initializer is a single integer which represents the texture unit to use for the first array element. The second is apparently used for some fixed-function code. v2: Rewrite the commit message - suggested by Paul. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Paul Berry <[email protected]>
* mesa: fix GLSL program objects with more than 16 samplers combinedMarek Olšák2013-05-281-4/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | The problem is the sampler units are allocated from the same pool for all shader stages, so if a vertex shader uses 12 samplers (0..11), the fragment shader samplers start at index 12, leaving only 4 sampler units for the fragment shader. The main cause is probably the fact that samplers (texture unit -> sampler unit mapping, etc.) are tracked globally for an entire program object. This commit adapts the GLSL linker and core Mesa such that the sampler units are assigned to sampler uniforms for each shader stage separately (if a sampler uniform is used in all shader stages, it may occupy a different sampler unit in each, and vice versa, an i-th sampler unit may refer to a different sampler uniform in each shader stage), and the sampler-specific variables are moved from gl_shader_program to gl_shader. This doesn't require any driver changes, and it fixes piglit/max-samplers for gallium and classic swrast. It also works with any number of shader stages. v2: - converted tabs to spaces - added an assertion to _mesa_get_sampler_uniform_value Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* glsl: Add GLSL_TYPE_INTERFACEIan Romanick2013-01-251-0/+1
| | | | | | | | | | | | | | | | | | | | | Interfaces are structurally identical to structures from the compiler's point of view. They have some additional restrictions, and generally GPUs use different instructions to access them. Using a different base type should make this a bit easier. This commit also adds the glsl_type::interface_packing fields. For GLSL_TYPE_INTERFACE types, this will track the specified packing mode. It is analogous to gl_uniform_buffer::_Packing. v2: Add serveral missing GLSL_TYPE_INTERFACE cases in switch-statements. v3: Add information about glsl_type::interface_packing. Move row_major checking in glsl_type::record_key_compare from this patch to the previous patch. Both suggested by Paul Berry. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Paul Berry <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Replace most default cases in switches on GLSL typeIan Romanick2013-01-251-1/+4
| | | | | | | | | | | | | | | This makes it easier to find switch-statements that need to be updated after a new GLSL_TYPE_* is added because the compiler will generate a warning. Switch-statements that only had a small number of cases (e.g., everything in ir_constant_expression.cpp) were not modified. I may regret that decision when we eventually add support for doubles. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Carl Worth <[email protected]> Reviewed-by: Chad Versace <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Propagate sampler uniform initializers to gl_shader_program::SamplerUnitsIan Romanick2012-05-231-0/+9
| | | | | | Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Set initial values for uniforms in the linkerIan Romanick2012-05-231-0/+172
v2: Fix handling of arrays-of-structure. Thanks to Eric Anholt for pointing this out. v3: Minor comment change based on feedback from Ken. Fixes piglit glsl-1.20/execution/uniform-initializer/fs-structure-array and glsl-1.20/execution/uniform-initializer/vs-structure-array. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>