summaryrefslogtreecommitdiffstats
path: root/src/glsl/link_uniforms.cpp
Commit message (Collapse)AuthorAgeFilesLines
* glsl: make variables privateTimothy Arceri2015-09-171-11/+11
| | | | Reviewed-by: Jason Ekstrand <[email protected]>
* glsl: store uniform slot id in var location fieldTimothy Arceri2015-09-171-3/+21
| | | | | | | | | | | | | | This will allow us to access the uniform later on without resorting to building a name string and looking it up in UniformHash. V3: remove line wrap change from this patch V2: store slot number for all non-UBO uniforms to make code more consitent, renamed explicit_binding to explicit_location and added comment about what it does. Store the location at every shader stage. Updated data.location comments in ir/nir.h. Reviewed-by: Jason Ekstrand <[email protected]>
* glsl: assign hidden uniforms their slot id earlierTimothy Arceri2015-09-171-49/+41
| | | | | | | | | | | | This is required so that the next patch can safely assign the slot id to the var. The ids are now assigned in the order we want before allocating storage so there is no need to sort the storage array and move things around. V2: rename variable to make code easier to follow as suggested by Jason Reviewed-by: Jason Ekstrand <[email protected]>
* glsl: order indices for samplers inside a struct arrayTimothy Arceri2015-09-171-17/+100
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This allows the correct offset to be easily calculated for indirect indexing when a struct array contains multiple samplers, or any crazy nesting. The indices for the folling struct will now look like this: Sampler index: 0 Name: s[0].tex Sampler index: 1 Name: s[1].tex Sampler index: 2 Name: s[0].si.tex Sampler index: 3 Name: s[1].si.tex Sampler index: 4 Name: s[0].si.tex2 Sampler index: 5 Name: s[1].si.tex2 Before this change it looked like this: Sampler index: 0 Name: s[0].tex Sampler index: 3 Name: s[1].tex Sampler index: 1 Name: s[0].si.tex Sampler index: 4 Name: s[1].si.tex Sampler index: 2 Name: s[0].si.tex2 Sampler index: 5 Name: s[1].si.tex2 struct S_inner { sampler2D tex; sampler2D tex2; }; struct S { sampler2D tex; S_inner si; }; uniform S s[2]; V3: Update comments with suggestions from Jason V2: rename struct array counter to have better name Reviewed-by: Jason Ekstrand <[email protected]>
* glsl: remove specical case subroutine type countingTimothy Arceri2015-08-311-3/+2
| | | | | | | Unlike samplers we can get the correct value for subroutines from component_slots() Reviewed-by: Dave Airlie <[email protected]>
* glsl: add uniform and program resource support (v2)Dave Airlie2015-07-231-4/+99
| | | | | | | | | | | | | | | | | | | This adds linker support for subroutine uniforms, they have some subtle differences from real uniforms, we also hide them and they are given internal uniform names. This also adds the subroutine locations and subroutine uniforms to the program resource tracking for later use. v1.1: drop is_subroutine_def v2: handle explicit location properly, ARB_explicit_location has a lot of language for subroutine shaders. Calculate a link time the number of compatible subroutines for a uniform, to make program resource easier later. Acked-by: Kenneth Graunke <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
* glsl: link buffer variables and shader storage buffer interface blocksKristian Høgsberg2015-07-141-3/+5
| | | | Reviewed-by: Jordan Justen <[email protected]>
* mesa: rename is_in_uniform_block to is_in_buffer_blockIago Toral Quiroga2015-07-141-3/+3
| | | | | | | 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-29/+26
| | | | | | | | | | | | | | | 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: Silence unused parameter warningsIan Romanick2015-05-041-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I opted to comment out "last_field" because it was not obvious what the meaning of the dangling bool would be. For the other parameters, the meaning was more intuitive without the name. link_uniform_blocks.cpp:70:65: warning: unused parameter 'name' [-Wunused-parameter] virtual void enter_record(const glsl_type *type, const char *name, ^ link_uniform_blocks.cpp:77:65: warning: unused parameter 'name' [-Wunused-parameter] virtual void leave_record(const glsl_type *type, const char *name, ^ link_uniform_blocks.cpp:93:62: warning: unused parameter 'record_type' [-Wunused-parameter] bool row_major, const glsl_type *record_type, ^ link_uniform_blocks.cpp:94:34: warning: unused parameter 'last_field' [-Wunused-parameter] bool last_field) ^ link_uniforms.cpp:547:65: warning: unused parameter 'name' [-Wunused-parameter] virtual void enter_record(const glsl_type *type, const char *name, ^ link_uniforms.cpp:556:65: warning: unused parameter 'name' [-Wunused-parameter] virtual void leave_record(const glsl_type *type, const char *name, ^ link_uniforms.cpp:567:34: warning: unused parameter 'last_field' [-Wunused-parameter] bool last_field) ^ Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Anuj Phogat <[email protected]> Reviewed-by: Dylan Baker <[email protected]> Reviewed-by: Tapani Pälli <[email protected]>
* Fix a few typosZoë Blade2015-04-271-1/+1
| | | | Reviewed-by: Francisco Jerez <[email protected]>
* glsl: avoid calling base_alignment when samplers are involvedIlia Mirkin2015-03-241-0/+4
| | | | | | | | | | | | Earlier commit 53bf7c8fd2e changed the logic to always call base_alignment on structs. 1ec715ce8b12 hacked the function to return 0 for sampler fields, but didn't handle sampler arrays. Instead of extending the hack, avoid calling base_alignment in the first place on non-UBO uniforms. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89726 Signed-off-by: Ilia Mirkin <[email protected]> Reviewed-by: Tapani Palli <[email protected]>
* glsl: ensure that enter/leave record get a record typeIlia Mirkin2015-02-211-0/+2
| | | | | | | May make life easier for tools like Coverity. Signed-off-by: Ilia Mirkin <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: fix uniform linking logic in the presence of structsIlia Mirkin2015-02-191-6/+31
| | | | | | | | | | | | | Add a enter/leave record callback so that the offset may be aligned to the proper value. Otherwise only leaf fields are called, and the first field needs to be aligned to the outer struct's base alignment while the last field needs to be aligned to the inner struct's base alignment. This removes most usage of the last field/record type values passed into visit_field. Signed-off-by: Ilia Mirkin <[email protected]> Reviewed-by: Dave Airlie <[email protected]>
* glsl: Uniform linking support for doublesDave Airlie2015-02-191-1/+6
| | | | | Signed-off-by: Dave Airlie <[email protected]> Reviewed-by: Ilia Mirkin <[email protected]>
* glsl: Add infrastructure for "hidden" uniforms.Kenneth Graunke2014-11-061-0/+50
| | | | | | | | | | | | | | | In the compiler, we'd like to generate implicit uniforms for internal use. These should not be visible via the GL uniform introspection API. To support that, we add a new ir_variable::how_declared value of ir_var_hidden, and plumb that through to gl_uniform_storage. v2 (idr): Fix some memory management issues in move_hidden_uniforms_to_end. The comment block on the function has more details. Signed-off-by: Kenneth Graunke <[email protected]> Signed-off-by: Ian Romanick <[email protected]>
* glsl: remove unused link_assign_uniform_block_offsetsTapani Pälli2014-09-261-34/+0
| | | | | | | ubo offsets are assigned by link_uniform_blocks since 514f8c7e Signed-off-by: Tapani Pälli <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: use ptrdiff_t cast to silence g++ sign warningBrian Paul2014-09-221-1/+1
| | | | Reviewed-by: Ian Romanick <[email protected]>
* glsl: Use bit-flags image attributes and uint16_t for the image formatIan Romanick2014-08-291-2/+2
| | | | | | | | | | | | | | | | | | | | | | All of the GL image enums fit in 16-bits. Also move the fields from the anonymous "image" structucture to the next higher structure. This will enable packing the bits with the other bitfield. Valgrind massif results for a trimmed apitrace of dota2: n time(i) total(B) useful-heap(B) extra-heap(B) stacks(B) Before (32-bit): 76 40,572,916,873 68,831,248 63,328,783 5,502,465 0 After (32-bit): 70 40,577,421,777 68,487,584 62,973,695 5,513,889 0 Before (64-bit): 60 36,822,640,058 96,526,824 88,735,296 7,791,528 0 After (64-bit): 74 37,124,603,758 95,891,808 88,466,712 7,425,096 0 A real savings of 346KiB on 32-bit and 262KiB on 64-bit. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Use UniformBooleanTrue value for uniform initializers.Matt Turner2014-08-181-2/+3
| | | | Reviewed-by: Anuj Phogat <[email protected]>
* linker: Use the matrix layout information in ir_variable and glsl_type for ↵Ian Romanick2014-08-041-10/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | UBO layout Use the data that is stored in the ir_variable and the glsl_type to determine whether or not a UBO member is row-major. Fixes gles3conform failures in: ES3-CTS.shaders.uniform_block.instance_array_basic_type.shared.row_major_mat2 ES3-CTS.shaders.uniform_block.instance_array_basic_type.shared.row_major_mat3 ES3-CTS.shaders.uniform_block.instance_array_basic_type.shared.row_major_mat4 ES3-CTS.shaders.uniform_block.instance_array_basic_type.shared.row_major_mat2x3 ES3-CTS.shaders.uniform_block.instance_array_basic_type.shared.row_major_mat2x4 ES3-CTS.shaders.uniform_block.instance_array_basic_type.shared.row_major_mat3x2 ES3-CTS.shaders.uniform_block.instance_array_basic_type.shared.row_major_mat3x4 ES3-CTS.shaders.uniform_block.instance_array_basic_type.shared.row_major_mat4x2 ES3-CTS.shaders.uniform_block.instance_array_basic_type.shared.row_major_mat4x3 ES3-CTS.shaders.uniform_block.instance_array_basic_type.packed.row_major_mat2 ES3-CTS.shaders.uniform_block.instance_array_basic_type.packed.row_major_mat3 ES3-CTS.shaders.uniform_block.instance_array_basic_type.packed.row_major_mat4 ES3-CTS.shaders.uniform_block.instance_array_basic_type.packed.row_major_mat2x3 ES3-CTS.shaders.uniform_block.instance_array_basic_type.packed.row_major_mat2x4 ES3-CTS.shaders.uniform_block.instance_array_basic_type.packed.row_major_mat3x2 ES3-CTS.shaders.uniform_block.instance_array_basic_type.packed.row_major_mat3x4 ES3-CTS.shaders.uniform_block.instance_array_basic_type.packed.row_major_mat4x2 ES3-CTS.shaders.uniform_block.instance_array_basic_type.packed.row_major_mat4x3 ES3-CTS.shaders.uniform_block.instance_array_basic_type.std140.row_major_mat2 ES3-CTS.shaders.uniform_block.instance_array_basic_type.std140.row_major_mat3 ES3-CTS.shaders.uniform_block.instance_array_basic_type.std140.row_major_mat4 ES3-CTS.shaders.uniform_block.instance_array_basic_type.std140.row_major_mat2x3 ES3-CTS.shaders.uniform_block.instance_array_basic_type.std140.row_major_mat2x4 ES3-CTS.shaders.uniform_block.instance_array_basic_type.std140.row_major_mat3x2 ES3-CTS.shaders.uniform_block.instance_array_basic_type.std140.row_major_mat3x4 ES3-CTS.shaders.uniform_block.instance_array_basic_type.std140.row_major_mat4x2 ES3-CTS.shaders.uniform_block.instance_array_basic_type.std140.row_major_mat4x3 ES3-CTS.shaders.uniform_block.random.nested_structs_arrays.2 ES3-CTS.shaders.uniform_block.random.nested_structs_instance_arrays.5 ES3-CTS.shaders.uniform_block.random.nested_structs_instance_arrays.9 Causes gles3conform failures in: ES3-CTS.shaders.uniform_block.random.basic_types.8 ES3-CTS.shaders.uniform_block.random.basic_arrays.3 ES3-CTS.shaders.uniform_block.random.basic_instance_arrays.0 ES3-CTS.shaders.uniform_block.random.basic_instance_arrays.2 ES3-CTS.shaders.uniform_block.random.all_per_block_buffers.13 ES3-CTS.shaders.uniform_block.random.all_per_block_buffers.18 ES3-CTS.shaders.uniform_block.random.all_shared_buffer.4 These failures will be fixed shortly. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: Track matrix layout of variables using two bitsIan Romanick2014-08-041-7/+24
| | | | | | | | | | | | | | | | | | | | Fixes gles3conform failures in: ES3-CTS.shaders.uniform_block.random.nested_structs_arrays_instance_arrays.3 ES3-CTS.shaders.uniform_block.random.all_per_block_buffers.13 Causes gles3conform failures in: ES3-CTS.shaders.uniform_block.random.all_per_block_buffers.9 This failure will be fixed shortly. v2: Use without_array() instead of older predicates. v3: s/GLSL_MATRIX_LAYOUT_DEFAULT/GLSL_MATRIX_LAYOUT_INHERITED/g Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Matt Turner <[email protected]> [v1]
* glsl: Track matrix layout of structure fields using two bitsIan Romanick2014-08-041-1/+2
| | | | | | | | | v2: Rename GLSL_MATRIX_LAYOUT_DEFAULT to GLSL_MATRIX_LAYOUT_INHERITED. Add comments in glsl_types.h explaining the layouts. Suggested by Matt. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Jordan Justen <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* linker: Add padding after the last field of a structureIan Romanick2014-08-041-1/+4
| | | | | | | | | | | | This causes the thing following the structure to be vec4-aligned. Fixes gles3conform failures in: ES3-CTS.shaders.uniform_block.random.nested_structs.2 ES3-CTS.shaders.uniform_block.random.all_shared_buffer.5 Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* linker: Add a last_field parameter to various program_resource_visitor methodsIan Romanick2014-08-041-13/+18
| | | | | | | | | I also considered renaming visit_field(const glsl_struct_field *) to entry_record and adding an exit_record method. This would be more similar to the hierarchical visitor. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: Use the without_array predicate to simplify some codeIan Romanick2014-08-041-15/+8
| | | | | | Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Matt Turner <[email protected]> [v1] Reviewed-by: Timothy Arceri <[email protected]>
* glsl: Use typed foreach_in_list instead of foreach_list.Matt Turner2014-07-011-8/+8
| | | | Reviewed-by: Ian Romanick <[email protected]>
* glsl/linker: assign explicit uniform locationsTapani Pälli2014-06-161-5/+56
| | | | | | | | | | | | | | | | | | | Patch refactors the existing uniform processing so explicit locations are taken in to account during variable processing. These locations are temporarily stored in gl_uniform_storage before actual locations are set. UNMAPPED_UNIFORM_LOC marks unset location so that we can use 0 as a valid explicit location. When locations are set, UniformRemapTable is first populated with uniforms that have explicit location set (inactive and active ones), rest are put after explicit location slots. v2: introduce define for locations that have not been set yet (Ian) Signed-off-by: Tapani Pälli <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: replace strncmp("gl_") calls with new is_gl_identifier() helperBrian Paul2014-05-281-2/+2
| | | | | | Makes things a little easier to read. Reviewed-by: Ian Romanick <[email protected]>
* glsl: the number of samplers is already calculated so use itTimothy Arceri2014-05-131-2/+1
| | | | | Signed-off-by: Timothy Arceri <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Clean up "unused parameter" warningsIan Romanick2014-03-281-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ../../src/glsl/builtin_functions.cpp:72:1: warning: unused parameter 'state' [-Wunused-parameter] ../../src/glsl/ir_clone.cpp:31:1: warning: unused parameter 'ht' [-Wunused-parameter] ../../src/glsl/ir_equals.cpp:44:1: warning: unused parameter 'ir' [-Wunused-parameter] ../../src/glsl/ir_equals.cpp:50:1: warning: unused parameter 'ignore' [-Wunused-parameter] ../../src/glsl/ir_equals.cpp:68:1: warning: unused parameter 'ignore' [-Wunused-parameter] ../../src/glsl/ir_print_visitor.cpp:149:6: warning: unused parameter 'ir' [-Wunused-parameter] ../../src/glsl/ir_print_visitor.cpp:556:1: warning: unused parameter 'ir' [-Wunused-parameter] ../../src/glsl/ir_print_visitor.cpp:562:1: warning: unused parameter 'ir' [-Wunused-parameter] ../../src/glsl/link_uniforms.cpp:213:1: warning: unused parameter 'record_type' [-Wunused-parameter] ../../src/glsl/loop_analysis.cpp:225:1: warning: unused parameter 'ir' [-Wunused-parameter] ../../src/glsl/loop_unroll.cpp:73:30: warning: unused parameter 'ir' [-Wunused-parameter] ../../src/glsl/loop_unroll.cpp:79:30: warning: unused parameter 'ir' [-Wunused-parameter] ../../src/glsl/loop_unroll.cpp:85:30: warning: unused parameter 'ir' [-Wunused-parameter] ../../src/glsl/opt_copy_propagation_elements.cpp:189:1: warning: unused parameter 'ir' [-Wunused-parameter] ../../src/glsl/opt_cse.cpp:402:1: warning: unused parameter 'ir' [-Wunused-parameter] ../../src/glsl/opt_dead_code_local.cpp:117:30: warning: unused parameter 'ir' [-Wunused-parameter] ../../src/glsl/opt_redundant_jumps.cpp:53:1: warning: unused parameter 'ir' [-Wunused-parameter] ../../src/glsl/opt_vectorize.cpp:301:1: warning: unused parameter 'ir' [-Wunused-parameter] Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* mesa/glsl: introduce a remap table for uniform locationsTapani Pälli2014-03-101-11/+24
| | | | | | | | | | | | | | | | | Patch adds a remap table for uniforms that is used to provide a mapping from application specified uniform location to actual location in the UniformStorage. Existing UniformLocationBaseScale usage is removed as table can be used to set sequential values for array uniform elements. This mapping helps to implement GL_ARB_explicit_uniform_location so that uniforms locations can be reorganized and handled in a more easy manner. v2: small fixes + rename parameters for merge and split functions (Ian) improve documentation, remove old check for location bounds (Eric) Signed-off-by: Tapani Pälli <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* glsl: fix compiler warnings in link_uniforms.cppBrian Paul2014-03-061-1/+2
| | | | | | | | | With a non-debug build, gcc has two complaints: 1. 'found' var not used. Silence with '(void) found;' 2. 'id' not initialized. It's assigned by the UniformHash->get() call, actually. But init it to zero to silence gcc. Reviewed-by: Matt Turner <[email protected]>
* glsl/linker: Propagate image uniform access qualifiers to the driver.Francisco Jerez2014-02-121-0/+35
| | | | Reviewed-by: Paul Berry <[email protected]>
* glsl/linker: Assign image uniform indices.Francisco Jerez2014-02-121-1/+23
| | | | Reviewed-by: Paul Berry <[email protected]>
* glsl/linker: Count and check image resources.Francisco Jerez2014-02-121-1/+18
| | | | | | | v2: Add comment about the reason why image variables take up space from the default uniform block. Reviewed-by: Paul Berry <[email protected]>
* mesa: Clean up nomenclature for pipeline stages.Paul Berry2014-01-081-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-7/+7
| | | | | | | | | | | | | 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-3/+3
| | | | | | | | | | 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]>
* mesa: Add support for ARB_shader_atomic_counters.Francisco Jerez2013-10-291-0/+1
| | | | | | | | | | | | | | | This patch implements the common support code required for the ARB_shader_atomic_counters extension. It defines the necessary data structures for tracking atomic counter buffer objects (from now on "ABOs") associated with some specific context or shader program, it implements support for binding buffers to an ABO binding point and querying the existing atomic counters and buffers declared by GLSL shaders. v2: Fix extension checks. Drop unused MAX_ATOMIC_BUFFERS constant. Acked-by: Paul Berry <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Account for interface block lowering in program_resource_visitor.Paul Berry2013-10-241-1/+57
| | | | | | | | | | | | | | When program_resource_visitor visits variables that were created by lower_named_interface_blocks, it needs to do extra work to un-do the effects of lower_named_interface_blocks and construct the proper API names. Fixes piglit test spec/glsl-1.50/execution/interface-blocks-api-access-members. Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: Make accessor functions for ir_variable::interface_type.Paul Berry2013-10-091-6/+7
| | | | | | | In a future patch, this will allow us to enforce invariants when the interface type is updated. Reviewed-by: Jordan Justen <[email protected]>
* glsl: Fix usage of the wrong union member in ↵Francisco Jerez2013-10-061-2/+2
| | | | | | | | | | | | | | | program_resource_visitor::recursion. In the array-of-struct case, recursion() takes the row_major flag for each iteration from 't->fields.structure[i]', but 't' is not a record type. Inherit the array declaration row_major flag instead. This mistake was found by running piglit on valgrind. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=69449 Cc: "9.1 9.2" <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Tested-by: Kenneth Graunke <[email protected]>
* glsl: Hide many classes local to individual .cpp files in anon namespaces.Eric Anholt2013-09-231-0/+4
| | | | | | | | This gives the compiler the chance to inline and not export class symbols even in the absence of LTO. Saves about 60kb on disk. Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Use alignment of container record for its first fieldIan Romanick2013-08-191-1/+12
| | | | | | | | | | | | | | | | | | | | The first field of a record in a UBO has the aligment of the record itself. Fixes piglit vs-struct-pad, fs-struct-pad, and (with the patch posted to the piglit list that extends the test) layout-std140. NOTE: The bit of strangeness with the version of visit_field without the record_type poitner is because that method is pure virtual in the base class. The original implementation of the class did this to ensure derived classes remembered to implement that flavor. Now they can implement either flavor but not both. I don't know a C++ way to enforce that. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Paul Berry <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=68195 Cc: "9.2 9.1" [email protected]
* glsl: Add new overload of program_resource_visitor::visit_field methodIan Romanick2013-08-191-9/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The outer-most record is passed into the visit_field method for the first field. In other words, in the following structure: struct S1 { vec4 v; float f; }; struct S { S1 s1; S1 s2; }; uniform Ubo { S s; }; s.s1.v would get record_type = S (because s1.v is the first non-record field in S), and s.s2.v would get record_type = S1. s.s1.f and s.s2.f would get record_type = NULL becuase they aren't the first field of anything. This new overload isn't used yet, but the next patch will add several uses. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Paul Berry <[email protected]> Cc: "9.2 9.1" [email protected]
* glsl: Initialize member variable is_ubo_var in constructor.Vinson Lee2013-06-271-1/+1
| | | | | | | Fixes "Uninitialized scalar field" defect reported by Coverity. Signed-off-by: Vinson Lee <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Generate smaller values for uniform locationsIan Romanick2013-06-121-1/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | Previously we would generate uniform locations as (slot << 16) + array_index. We do this to handle applications that assume the location of a[2] will be +1 from the location of a[1]. This resulted in every uniform location being at least 0x10000. The OpenGL 4.3 spec was amended to require this behavior, but previous versions did not require locations of array (or structure) members be sequential. We've now encountered two applications that assume uniform values will be "small." As far as we can tell, these applications store the GLint returned by glGetUniformLocation in a int16_t or possibly an int8_t. THIS BEHAVIOR IS NOT GUARANTEED OR IMPLIED BY ANY VERSION OF OpenGL. Other implementations happen to have both these behaviors (sequential array elements and small values) since OpenGL 2.0, so let's just match their behavior. Fixes "3D Bowling" on Android. NOTE: This is a candidate for stable release branches. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Brian Paul <[email protected]> Reviewed-and-tested-by: Chad Versace <[email protected]>
* glsl: Add gl_shader_program::UniformLocationBaseScaleIan Romanick2013-06-121-0/+2
| | | | | | | | | | | | | | | | This is used by _mesa_uniform_merge_location_offset and _mesa_uniform_split_location_offset to determine how the base and offset are packed. Previously, this value was hard coded as (1U<<16) in those functions via the shift and mask contained therein. The value is still (1U<<16), but it can be changed in the future. The next patch dynamically generates this value. NOTE: This is a candidate for stable release branches. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Brian Paul <[email protected]> Reviewed-and-tested-by: Chad Versace <[email protected]>
* glsl: Fix uniform buffer object counting.Eric Anholt2013-06-061-1/+11
| | | | | | | | | | | | | | | | | | | | We were counting uniforms located in UBOs against the default uniform block limit, while not doing any counting against the specific combined limit. Note that I couldn't quite find justification for the way I did this, but I think it's the only sensible thing: The spec talks about components, so each "float" in a std140 block would count as 1 component and a "vec4" would count as 4, though they occupy the same amount of space. Since GPU limits on uniform buffer loads are surely going to be about the size of the blocks, I just counted them that way. Fixes link failures in piglit arb_uniform_buffer_object/maxuniformblocksize when ported to geometry shaders on Paul's GS branch, since in that case the max block size is bigger than the default uniform block component limit. Reviewed-by: Ian Romanick <[email protected]>