summaryrefslogtreecommitdiffstats
path: root/src/glsl
Commit message (Collapse)AuthorAgeFilesLines
* glsl: Disallow interpolation qualifiers on non-input/output variables.Kenneth Graunke2013-08-021-7/+18
| | | | | | | | | | | | | Commit 2548092ad8015 switched the sense of interpolation qualifier checks in order to permit them on geometry shader in/out variables. In doing so, it accidentally allowed interpolation qualifiers to be applied to ordinary variables and function parameters. Fixes a regression in Piglit's local-smooth-01.frag. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Paul Berry <[email protected]>
* glsl: Fix NULL pointer dereferences when linking fails.Kenneth Graunke2013-08-021-8/+5
| | | | | | | | | | | | | | | Commit 7cfefe6965d50 introduced a check for whether linked->Type equals GL_GEOMETRY_SHADER. However, linked may be NULL due to an earlier error condition. Since the entire function after the error path is (or should be) guarded by linked != NULL checks, we may as well just return early and remove the checks. Fixes crashes in 9 Piglit tests. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Paul Berry <[email protected]>
* glsl: Implement rules for geometry shader input sizes.Paul Berry2013-08-013-0/+202
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Section 4.3.8.1 (Input Layout Qualifiers) of the GLSL 1.50 spec contains some tricky rules for how the sizes of geometry shader input arrays are related to the input layout specification. In essence, those rules boil down to the following: - If an input array declaration does not specify a size, and it follows an input layout declaration, it is sized according to the input layout. - If an input layout declaration follows an input array declaration that didn't specify a size, the input array declaration is given a size at the time the input layout declaration appears. - All input layout declarations and input array sizes must ultimately match. Inconsistencies are reported as soon as they are detected, at compile time if the inconsistency is within one compilation unit, otherwise at link time. - At least one compilation unit must contain an input layout declaration. (Note: the geom_array_resize_visitor class was contributed by Bryan Cain <[email protected]>.) Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Allow geometry shader input instance arrays to be unsized.Paul Berry2013-08-013-17/+49
| | | | | Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Permit non-ubo input interface arrays to use non-const indexing.Paul Berry2013-08-011-1/+2
| | | | | | | | | | | | | | | | | | | From the GLSL ES 3.00 spec: "All indexes used to index a uniform block array must be constant integral expressions." Similar text exists in GLSL specs since 1.50. When we implemented this, the only type of interface block supported by Mesa was uniform blocks, so we required all indexes used to index any interface block to be constant integral expressions. Now that we are adding interface block support for GLSL 1.50, we need a more specific check. Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Cross-validate GS layout qualifiers while intrastage linking.Eric Anholt2013-08-011-0/+96
| | | | | | | | | | | This gets piglit's geometry-basic test running. TODO: Still need to validate that the GS layout qualifiers don't get used in places they shouldn't (like an interface block, or a particular shader input or output) Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Export the compiler's GS layout qualifiers to the gl_shader.Eric Anholt2013-08-011-0/+31
| | | | | | | | | | | | | | | | Next step is to validate them at link time. v2 (Paul Berry <[email protected]>): Don't attempt to export the layout qualifiers in the event of a compile error, since some of them are set up by ast_to_hir(), and ast_to_hir() isn't guaranteed to have run in the event of a compile error. Reviewed-by: Kenneth Graunke <[email protected]> v3 (Paul Berry <[email protected]>): Use PRIM_UNKNOWN to represent "not set in this shader". Reviewed-by: Ian Romanick <[email protected]>
* glsl: Parse the GLSL 1.50 GS layout qualifiers.Eric Anholt2013-08-016-1/+177
| | | | | | | | | | | | | | | Limited semantic checking (compatibility between declarations, checking that they're in the right shader target, etc.) is done. v2: Remove stray debug printfs. v3 (Paul Berry <[email protected]>): Process input layout qualifiers at ast_to_hir time rather than at parse time, since certain error conditions depend on the relative ordering between input layout qualifiers, declarations, and calls to .length(). Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Make sure that we don't put too many bitfields in ast_type_qualifier.Eric Anholt2013-08-011-0/+2
| | | | | | | | | We do some tests of qualifiers using a union containing an int and the struct full of bitfields, so make sure the bitfields don't spill outside the int. Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl/linker: Fail to link geometry shader without vertex shader.Fabian Bieler2013-08-011-0/+8
| | | | | | | | | | | From section 2.15 (Geometry Shaders) the OpenGL 3.2 spec: A program object that includes a geometry shader must also include a vertex shader; otherwise a link error will occur. Reviewed-by: Paul Berry <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Properly pack GS output varyingsPaul Berry2013-08-011-2/+57
| | | | | | | | | | | | | | In geometry shaders, outputs are consumed at the time of a call to EmitVertex() (as opposed to all other shader types, where outputs are consumed when the shader exits). Therefore, when packing geometry shader output varyings using lower_packed_varyings, we need to do the packing at the time of the EmitVertex() call. This patch accomplishes that by adding a new visitor class, lower_packed_varyings_gs_splicer, which is responsible for splicing the varying packing code into place wherever EmitVertex() is found. Reviewed-by: Ian Romanick <[email protected]>
* glsl: Modify varying packing to use a temporary exec_list.Paul Berry2013-08-011-10/+18
| | | | | | | | | | | | | | This patch modifies lower_packed_varyings to store the packing code it generates in a temporary exec_list, and then splice that list into the shader's main() function when it's done. This paves the way for supporting geometry shader outputs, where we'll have to splice a clone of the packing code before every call to EmitVertex(). As a side benefit, varying packing code is now emitted in the same order for inputs and outputs; this should make debug output a little easier to read. Reviewed-by: Ian Romanick <[email protected]>
* glsl/linker: Properly pack GS input varyings.Paul Berry2013-08-015-35/+199
| | | | | | | | Since geometry shader inputs are arrays (where the array index indicates which vertex is being examined), varying packing needs to treat them differently. Reviewed-by: Ian Romanick <[email protected]>
* glsl/linker: Properly error check VS-GS linkage.Paul Berry2013-08-011-1/+10
| | | | | | | | | | | | | | | | From section 4.3.4 (Inputs) of the GLSL 1.50 spec: Geometry shader input variables get the per-vertex values written out by vertex shader output variables of the same names. Since a geometry shader operates on a set of vertices, each input varying variable (or input block, see interface blocks below) needs to be declared as an array. Therefore, the element type of each geometry shader input array should match the type of the corresponding vertex shader output. Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Require geometry shader inputs to be arrays.Paul Berry2013-08-011-1/+14
| | | | | Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: support compilation of geometry shadersBryan Cain2013-08-014-10/+100
| | | | | | | | | | | | | | | | | | | | | | | | | | | This commit adds all of the parsing and semantics for GLSL 150 style geometry shaders. v2 (Paul Berry <[email protected]>): Add a few missing calls to get_pipeline_stage(). Fix some signed/unsigned comparison warnings. Fix handling of NULL consumer in assign_varying_locations(). v3 (Bryan Cain <[email protected]>): fix indexing order of 2D arrays. Also, allow interpolation qualifiers in geometry shaders. v4 (Paul Berry <[email protected]>): Eliminate get_pipeline_stage()--it is no longer needed thanks to 030ca23 (mesa: renumber shader indices according to their placement in pipeline). Remove 2D stuff. Move vertices_per_prim() to ir.h, so that it will be accessible from outside the linker. Remove inject_num_vertices_visitor. Rework for GLSL 1.50. Reviewed-by: Ian Romanick <[email protected]> v5 (Paul Berry <[email protected]>): Split out do_set_program_inouts() argument refactoring to a separate patch. Move geom_array_resizing_visitor to later in the series. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl/linker: Make separate allocations to track vertex and fragment shaders.Paul Berry2013-08-011-2/+4
| | | | | | | | There's no reason to be clever about this. By making separate allocations for vertex and fragment shaders, we'll allow geometry shaders to be added without introducing any complication. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: add builtins for geometry shaders.Bryan Cain2013-08-015-4/+28
| | | | | | | | | | | | | | v2 (Paul Berry <[email protected]>): Account for rework of builtin_variables.cpp. Use INTERP_QUALIFIER_FLAT for gl_PrimitiveID so that it will obey provoking vertex conventions. Convert to GLSL 1.50 style geometry shaders. Reviewed-by: Ian Romanick <[email protected]> v3 (Paul Berry <[email protected]>): Be less obscure about setting interpolation field of gl_Primitive variables. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: add ir_emit_vertex and ir_end_primitive instruction typesBryan Cain2013-08-0110-1/+161
| | | | | | | | | | | | | | These correspond to the EmitVertex and EndPrimitive functions in GLSL. v2 (Paul Berry <[email protected]>): Add stub implementations of new pure visitor functions to i965's vec4_visitor and fs_visitor classes. v3 (Paul Berry <[email protected]>): Rename classes to be more consistent with the names used in the GL spec. Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Add EXT_texture_array support for geometry shaders.Paul Berry2013-08-011-0/+12
| | | | | | | | | We can't just use a ".glsl" file since the Lod variants are only available in vertex and geometry shaders, while the bias variants are only available in the fragment shader. Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl/linker: Make update_array_sizes apply to just uniforms.Paul Berry2013-08-011-3/+1
| | | | | | | | | | | | | | | | | | | | Commit 586b4b5 (glsl: Also update implicit sizes of varyings at link time) extended update_array_sizes() to apply to both uniforms and shader ins/outs. However, doing creates problems for geometry shaders, because update_array_sizes() assumes that variables with matching names in different parts of the pipeline should have the same sizes. With the addition of geometry shaders, this is no longer true (e.g. both vertex and geometry shaders have a gl_ClipDistance output variable, but there's no reason these variables should have the same sizes). The original reason for commit 586b4b5 (avoid problems with gl_TexCoord being 0 length) has since been addressed by commit 6f53921 (linker: Ensure that unsized arrays have a size after linking). So go ahead and switch update_array_sizes() back to only acting on uniforms. Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Modify ir_set_program_inouts to handle geometry shaders.Paul Berry2013-08-011-12/+75
| | | | | Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: In ir_set_program_inouts, handle indexing outside array/matrix bounds.Paul Berry2013-08-011-5/+26
| | | | | | | | | | | | | | | According to GLSL, indexing into an array or matrix with an out-of-range constant results in a compile error. However, indexing with an out-of-range value that isn't constant merely results in undefined results. Since optimization passes (e.g. loop unrolling) can convert non-constant array indices into constant array indices, it's possible that ir_set_program_inouts will encounter a constant array index that is out of range; if this happens, just mark the whole array as used. Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Fallback gracefully if ir_set_program_inouts sees unexpected indexing.Paul Berry2013-08-011-0/+23
| | | | | | | | | | | | | | | | | | | | | | | The code in ir_set_program_inouts that marks just a portion of a variable as used (rather than the whole variable) only works on a few kinds of indexing operations: - Indexing into matrices - Indexing into arrays of matrices, vectors, or scalars. Fortunately these are the only kinds of indexing operations that we expect to see; everything else is either handled by a previously-executed lowering pass or prohibited by GLSL. However, that could conceivably change in the future (the GLSL rules might change, or we might modify the lowering passes). To avoid mysterious bugs in the future, let's have ir_set_program_inouts report an assertion failure if it ever encounters an unexpected kind of indexing operation (and in release builds, fall back to just marking the whole variable as used). Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Extract marking functions from ir_set_program_inouts.Paul Berry2013-08-011-14/+45
| | | | | | | | | | This patch extracts the functions mark_whole_variable() and try_mark_partial_variable() from the ir_set_program_inouts visitor functions. This will make the code easier to follow when we add geometry shader support. Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Use count_attribute_slots() in ir_set_program_inouts.Paul Berry2013-08-011-8/+2
| | | | | Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Expand count_attribute_slots() to cover structs.Paul Berry2013-08-011-5/+32
| | | | | Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* Move count_attribute_slots() out of the linker and into glsl_type.Paul Berry2013-08-015-40/+42
| | | | | | | | | | | | | Our previous justification for leaving this function out of glsl_type was that it implemented counting rules that were specific to GLSL 1.50. However, these counting rules also describe the number of varying slots that Mesa will assign to a varying in the absence of varying packing. That's useful to be able to compute from outside of the linker code (a future patch will use it from ir_set_program_inouts.cpp). So go ahead and move it to glsl_type. Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Change do_set_program_inouts' is_fragment_shader arg to shader_type.Paul Berry2013-08-012-13/+13
| | | | | | | | This will allow us to add geometry shader support without having to add another boolean argument. Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Switch from the deprecated YYLEX_PARAM to %lex-param.Kenneth Graunke2013-07-311-5/+3
| | | | | | | | | | | | | | | | | | | | | YYLEX_PARAM is no longer supported as of Bison 3.0. Instead, the Bison developers recommend using %lex-param. %lex-param takes a type and variable name, similar to %parse-param, so you can't pass an arbitrary expression like state->scanner. But Flex insists on passing the actual scanner object, not an arbitrary object like state. To solve this, the parser defines a wrapper lex() function which accepts "state," and calls Flex's lex() function with state->scanner. Fixes the build with Bison 3.0. Also works with Bison 2.7.1. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=67354 Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]> Tested-by: Laurent Carlier <[email protected]> Cc: "9.2" [email protected]
* glsl: Change the lexer's namespace.Kenneth Graunke2013-07-313-3/+9
| | | | | | | | | | | | Bison 3.0 removes the YYLEX_PARAM macro. In preparation for handling this using %lex-param, the parser needs a wrapper function for the actual Flex lex() function. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=67354 Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]> Tested-by: Laurent Carlier <[email protected]> Cc: "9.2" [email protected]
* mesa,glsl,st/dri: add a new driconf option force_glsl_version for UnigineMarek Olšák2013-07-301-1/+2
| | | | | | | | See documentation in mtypes.h. Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Brian Paul <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Remove redundant writes to prog->LinkStatusPaul Berry2013-07-301-1/+0
| | | | | | | | The linker_error() function sets prog->LinkStatus to false. There's no reason for the caller of linker_error() to also do so. Reviewed-by: Jordan Justen <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Improve error message for interstage interface block mismatch.Paul Berry2013-07-301-1/+2
| | | | | | | | | | We're now emitting this error from a point where we have easy access to the name of the block that failed to match, so go ahead and include that in the error message, as we do for intrastage interface block mismatches. Reviewed-by: Jordan Justen <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Use a consistent technique for tracking link success/failure.Paul Berry2013-07-305-82/+75
| | | | | | | | | | | | | | | | | | This patch changes link_shaders() so that it sets prog->LinkStatus to true when it starts, and then relies on linker_error() to set it to false if a link failure occurs. Previously, link_shaders() would set prog->LinkStatus to true halfway through its execution; as a result, linker functions that executed during the first half of link_shaders() would have to do their own success/failure tracking; if they didn't, then calling linker_error() would add an error message to the log, but not cause the link to fail. Since it wasn't always obvious from looking at a linker function whether it was called before or after link_shaders() set prog->LinkStatus to true, this carried a high risk of bugs. Reviewed-by: Jordan Justen <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Add error message for intrastage interface block mismatch.Paul Berry2013-07-303-3/+8
| | | | | | | | Previously we failed to link (which is correct), but we did not output an error message, which could have been confusing for users. Reviewed-by: Jordan Justen <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Remove bogus check on return value of link_uniform_blocks().Paul Berry2013-07-303-6/+4
| | | | | | | | | | | | | | | | A comment in link_intrastage_shaders(), and an if-test that followed it, seemed to indicate that link_uniform_blocks() would return a negative value in the event of an error. But this is not the case--all error checking has already been performed by validate_intrastage_interface_blocks(), and link_uniform_blocks() can only return unsigned values. So get rid of the if-test and change the return type of link_intrastage_shaders() to clarify that it can only return unsigned values. Reviewed-by: Jordan Justen <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Remove shader stage checking for extension handling.Kenneth Graunke2013-07-291-61/+28
| | | | | | | | | | | | | | | | | Certain extensions only add functionality to particular shader stages. (For example, ARB_draw_instanced only adds variables to the vertex shader stage.) Previously, we only allowed such extensions to be enabled in the shader stages where they're useful. However, I've never found any text which mandates that behavior; in my opinion, you should be able to turn on extensions in any shader stage, even if they have no effect. Fixes Piglit tests glslparsertest/glsl2/draw_buffers-05.vert and ARB_draw_instanced/preprocessor/feature-macro-enabled.frag. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=29185 Signed-off-by: Kenneth Graunke <[email protected]>
* glsl: Less const for glsl_type convenience accessorsIan Romanick2013-07-272-8/+8
| | | | | | | | | | | | | The second 'const' says that the pointer itself is constant. This in unenforcible in C++, so GCC emits a warning (see) below for each of these functions in every file that includes glsl_types.h. It's a lot of warning spam. ../../../src/glsl/glsl_types.h:176:58: warning: type qualifiers ignored on function return type [-Wignored-qualifiers] Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Cc: [email protected]
* glsl: Disallow auxiliary storage qualifiers on FS outputs.Kenneth Graunke2013-07-271-0/+14
| | | | | | | | | | | This has always been an error; we just forgot to check for it. Fixes Piglit's no-aux-qual-on-fs-output.frag. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=67333 Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]> Cc: [email protected]
* glsl: Classify "layout" like other identifiers.Kenneth Graunke2013-07-271-1/+1
| | | | | | | | | | | | | When "layout" isn't being lexed as LAYOUT_TOK, we should treat it like an ordinary identifier. This means we need to classify it to determine whether we should return IDENTIFIER, TYPE_IDENTIFIER, or NEW_IDENTIFIER. Fixes the WebGL conformance test "shader-with-non-reserved-words." Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=64087 Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]> Cc: [email protected]
* glsl: Be consistent about '\n', '.', and capitalization in errors/warnings.Paul Berry2013-07-278-122/+122
| | | | | | | | | | | | The majority of calls to _mesa_glsl_error(), _mesa_glsl_warning(), and _mesa_glsl_parse_state::check_version() use a message that begins with a lower case letter and ends without a period. This patch makes all messages follow that convention. Also, error/warning messages shouldn't end in '\n', since _mesa_glsl_msg() automatically adds '\n' at the end of the message. Reviewed-by: Matt Turner <[email protected]>
* glsl: disable ARB_texture_cube_map_array_enable keywords for glsl esTapani Pälli2013-07-261-24/+5
| | | | | | | | | | | | Patch fixes a crash with Webgl 'shader-with-non-reserved-words' conformance test by ignoring desktop extension keywords on GLSL ES. v2: fix reserved and allowed desktop glsl versions (Chris) Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=64087 Signed-off-by: Tapani Pälli <[email protected]> Reviewed-by: Chris Forbes <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Handle empty if statement encountered during loop analysis.Paul Berry2013-07-251-1/+2
| | | | | | | | | | | | | | | | | | | | | The is_loop_terminator() function was asserting that the following kind of if statement could never occur: if (...) { } else { } (presumably based on the assumption that such an if statement would be eliminated by previous optimization stages). But that isn't the case--it's possible that previous optimization stages might simplify more complex code down to this empty if statement, in which case it won't be eliminated until the next time through the optimization loop. So is_loop_terminator() needs to handle it. Fortunately it's easy to handle--it's not a loop terminator because it does nothing. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=64330 CC: [email protected] Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: don't rename variables in interface block arrays.Paul Berry2013-07-251-6/+2
| | | | | | | | | | | | | | | | | | | | | | | | | The linker matches up variables in interface blocks according to their block name and variable name. When support for interface block arrays was added in commit d6863acb, we renamed variables appearing in interface blocks so that their name included the array size. For example, in a block like this: out foo { float bar } baz[3]; The variable "bar" would get renamed to "bar[3]". This is unnecessary, and leads to problems in supporting geometry shaders, since geometry shaders require vertex shader outputs which are non-arrays to be linked up to geometry shader inputs which are arrays. This patch makes the behaviour of interface block arrays the same as simple non-array interface blocks; in both cases, the variables contained within them are not renamed. Reviewed-by: Matt Turner <[email protected]>
* glsl: Initialize ast_function member variables.Vinson Lee2013-07-211-1/+2
| | | | | | Fixes "Uninitialized pointer field" defect reported by Coverity. Signed-off-by: Vinson Lee <[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: Propagate UBO binding qualifier into UBO member variables.Kenneth Graunke2013-07-181-0/+7
| | | | | | | | | | | | | Without an instance name, there is no ir_variable representing the actual uniform block declaration. When the linker goes to set uniform initializers, it only sees the members as ir_variables; never the block. So, unfortunately, the members need to know about the binding. There has to be a better way to do this. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-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]>