summaryrefslogtreecommitdiffstats
path: root/src/glsl
Commit message (Collapse)AuthorAgeFilesLines
* glsl: s/class/struct/ for ast_type_qualifierBrian Paul2012-08-291-1/+1
| | | | | | To silence an MSVC compiler warning about class vs. struct. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl/linker: Avoid buffer over-run in parcel_out_uniform_storage::visit_fieldStéphane Marchesin2012-08-231-1/+1
| | | | | | | | | | | When too may uniforms are used, the error will be caught in check_resources (src/glsl/linker.cpp). NOTE: This is a candidate for the 8.0 branch. Signed-off-by: Stéphane Marchesin <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Tested-by: Benoit Jacob <[email protected]>
* build/glsl: fix android build v2Tapani Pälli2012-08-231-1/+1
| | | | | | | | | | Commit 77a3efc6b907943903190b385fdf107c4acfcdca broke android build that sets its own value for GLSL_SRCDIR before including Makefile.sources. Patch moves overriding the value after include, this works as GLSL_SRCDIR variable gets expanded only later. Reviewed-by: Matt Turner <[email protected]> Signed-off-by: Tapani Pälli <[email protected]>
* build: Fix out-of-tree generation of builtin_function.cppMatt Turner2012-08-141-2/+2
| | | | Reviewed-by: Kenneth Graunke <[email protected]>
* build/glsl: fix location of generated files.Christopher James Halse Rogers2012-08-133-15/+8
| | | | | | | | Like in src/mesa, use GLSL_BUILDDIR/GLSL_SRCDIR to unambiguously distinguish between in-tree and generated files. Reviewed-by: Eric Anholt <[email protected]> Signed-off-by: Christopher James Halse Rogers <[email protected]>
* glsl: Refuse to parse uniform block declarations when UBOs aren't available.Eric Anholt2012-08-071-0/+20
| | | | | | | Fixes piglit GL_ARB_uniform_buffer_object/compiler/extension-disabled-block.frag Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Align GL_UNIFORM_BLOCK_DATA_SIZE according to std140 rules.Eric Anholt2012-08-071-1/+13
| | | | | | Fixes piglit GL_ARB_uniform_buffer_object/data-size test. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Only flag RowMajor on matrix-type variables.Eric Anholt2012-08-071-5/+9
| | | | | | | | We were only propagating it to the API when the variable was a matrix type, but we were still tripping over it in lower_ubo_reference when it was set on a vector. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Fix calculation of std140 offset alignment for mat2s.Eric Anholt2012-08-071-4/+9
| | | | | | | | | We were getting the base offset of a vec2, not of a vec2[2] like the quoted spec text says we should. v2: Fix swapped then/else cases. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Fix glGetActiveUniformsiv(GL_UNIFORM_BLOCK_INDEX).Eric Anholt2012-08-071-3/+13
| | | | | | | | | Previously, we were returning the index into the UniformBlocks of one of the linked shaders, when it's supposed to be the program global index. Fixes piglit getactiveuniformsiv-uniform_block_index. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Add a lowering pass to turn complicated UBO references to vector loads.Eric Anholt2012-08-073-0/+315
| | | | | | | | | | | v2: Reduce the impenetrable code in emit_ubo_loads() by 23 lines by keeping the ir_variable as the variable part of the offset from handle_rvalue(), and track the constant offsets from that with a plain old integer value, avoiding a bunch of temporary variables in the array and struct handling. Also, fix file description doxygen. v3: Fix a row vs col typo, and fix spelling in a comment. Reviewed-by: Eric Anholt <[email protected]>
* glsl: Add a variant of the rvalue visitor for handle_rvalue() on the way down.Eric Anholt2012-08-072-11/+147
| | | | | | | For the UBO lowering pass, I want to see the whole dereference chain for replacing, not the innermost ir_dereference_variable. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Add a "ubo_load" expression type for fetches from UBOs.Eric Anholt2012-08-073-1/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Drivers will probably want to be able to take UBO references in a shader like: uniform ubo1 { float a; float b; float c; float d; } void main() { gl_FragColor = vec4(a, b, c, d); } and generate a single aligned vec4 load out of the UBO. For intel, this involves recognizing the shared offset of the aligned loads and CSEing them out. Obviously that involves breaking things down to loads from an offset from a particular UBO first. Thus, the driver doesn't want to see variable_ref(ir_variable("a")), and even more so does it not want to see array_ref(record_ref(variable_ref(ir_variable("a")), "field1"), variable_ref(ir_variable("i"))). where a.field1[i] is a row_major matrix. Instead, we're going to make a lowering pass to break UBO references down to expressions that are obvious to codegen, and amenable to merging through CSE. v2: Fix some partial thoughts in the ir_binop comment (review by Kenneth) Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Fix a reference to UniformBlocks during uniform linking.Eric Anholt2012-08-071-3/+3
| | | | | | | | | | | | | When converting var->location from pointing at the program's UniformBlocks to pointing at the linked shader's UniformBlocks, I missed this change. It usually worked out in the end because the two lists happen to be the same in many testcases. Fixes a valgrind complaint on oglconform ubo-compile.cpp advanced.std140.2stage Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Update the notes on adding a new expression type.Eric Anholt2012-08-071-1/+0
| | | | | Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* scons: set YACCHXXFILESUFFIX to stop needless rebuilding of the parserJosé Fonseca2012-08-021-0/+4
| | | | | | | | Before, the GLSL parser was getting rebuilt every time that scons was run. The problem was scons was expecting a glsl_parser.hpp file but we were generating a glsl_parser.h file. Signed-off-by: Brian Paul <[email protected]>
* glsl: Add support for OES_standard_derivatives in GLSL ES.Tomeu Vizoso2012-08-013-0/+23
| | | | | | | | | | | Previously, we advertised the extension but the builtin functions were enabled only for GLSL and not for ES. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=52003 Signed-off-by: Tomeu Vizoso <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Reject linking shaders with too many uniform blocks.Eric Anholt2012-07-311-0/+34
| | | | | | | Part of fixing piglit maxblocks. Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Assign array and matrix stride values according to std140 layout.Eric Anholt2012-07-311-4/+15
| | | | | Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Add support for default layout qualifiers for uniforms.Eric Anholt2012-07-315-38/+99
| | | | | | | | | | | I ended up having to add rallocing of the ast_type_qualifier in order to avoid pulling in ast.h for glsl_parser_extras.h, because I wanted to track an ast_type_qualifier in the state. Fixes piglit ARB_uniform_buffer_object/row-major. Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Merge UBO layout qualifiers in a qualifier list.Eric Anholt2012-07-311-1/+23
| | | | | | | | | | Yes, you get to say things like "layout(row_major, column_major)" and get column major. Part of fixing piglit ARB_uniform_buffer_object/row_major. Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Incorporate all UBO language changes into GLSL 1.40.Eric Anholt2012-07-311-0/+4
| | | | | Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Refactor #version validation to be more future-proof.Kenneth Graunke2012-07-313-38/+16
| | | | | | | | | | | | | | | | | The previous implementation required a flag in _mesa_glsl_parse_state and line of code to initialize it for every version of the shading language we intend to support. As we look to add 150, 330, 400, 410, 420, and beyond, this gets rather unwieldy. This patch retains the switch statement (to reject, say, #version 111), but removes all the bits. Code to check for ctx->API == API_OPENGL_CORE could easily be added to the 110 and 120 cases to reject those. v2: Use _mesa_is_desktop_gl to preserve the existing behavior in the presence of the new API_OPENGL_CORE enumeration. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Eric Anholt <[email protected]> [v1]
* glsl: Fix #pragma invariant(all) language version check.Kenneth Graunke2012-07-311-1/+1
| | | | | | | | | | | | | It was using state->Const.GLSL_100ES, which is set if the driver supports ARB_ES2_compatibility or we're in ES2 mode. Instead, it should use state->language_version, as that represents the actual GLSL version of the shader being compiled. Since the correct logic is < 120 && !100, just make it == 110. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: add support for using API_OPENGL_COREJordan Justen2012-07-301-8/+7
| | | | | | | Signed-off-by: Jordan Justen <[email protected]> Reviewed-by: Brian Paul <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Fix ir_last_opcode value.Ian Romanick2012-07-301-1/+1
| | | | | | | | | | Now that ir_quadop_vector exists, ir_last_binop and ir_last_opcode are no longer the same. Only one place currently uses this enumeration, and already handles ir_quadop_vector correctly. Signed-off-by: Ian Romanick <[email protected]> Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Olivier Galibert <[email protected]>
* glsl: Request an Nx1 type instance in ir_quadop_vector lowering pass.Ian Romanick2012-07-301-1/+1
| | | | | | | | | | | | | No types have 0 columns. The glsl_type::get_instance method contains if ((rows < 1) || (rows > 4) || (columns < 1) || (columns > 4)) return error_type; To get a vector, use columns = 1. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Olivier Galibert <[email protected]>
* glsl: Make bvec and ivec types accessible without using get_instance.Kenneth Graunke2012-07-302-0/+10
| | | | | | | | | It's more convenient to use shortcuts like glsl_type::bvec2_type than the longwinded glsl_type::get_instance(GLSL_TYPE_BOOL, 2, 1). Signed-off-by: Ian Romanick <[email protected]> Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Olivier Galibert <[email protected]>
* glcpp: Add a newline to expanded #line directives.Kenneth Graunke2012-07-281-2/+2
| | | | | | | | | | | | | | | | | | | | Otherwise, the preprocessor happily outputs #line 2 4 <your next line of code> and the main compiler gets horribly confused and fails to compile. This is not the right solution (line numbers in error messages will likely be off-by-one in certain circumstances), but until Carl comes up with a proper fix, this gets programs running again. Fixes regressions in Regnum Online, Overgrowth, Piglit, and others since commit aac78ce8234d96932c38b3f48b1d828077bc0027. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=51802 Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=51506 Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=41152 Signed-off-by: Kenneth Graunke <[email protected]>
* glsl: warning: pragma `invariant(all)' not supported in GLSL ES 1.00Oliver McFadden2012-07-261-1/+1
| | | | | | | | | | | | The OpenGL(R) ES Shading Language Version 1.00 Revision 17 (12 May, 2009) > 4.6.1 The Invariant Qualifier > ... To force all output variables to be invariant, use the pragma > #pragma STDGL invariant(all) Signed-off-by: Oliver McFadden <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* Fix compile time errors when building against uclibcAnthony G. Basile2012-07-241-1/+1
| | | | | | | | | | Mesa misses a few checks when compiling on a uclibc system which cause it to fall back on glibc-ism. This patch addresses those issues. Acked-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]> Signed-off-by: Anthony G. Basile <[email protected]>
* glsl: Assign locations for uniforms in UBOs using the std140 rules.Eric Anholt2012-07-205-2/+270
| | | | | | Fixes piglit layout-std140. Reviewed-by: Ian Romanick <[email protected]>
* glsl: Don't resize arrays in uniform blocks.Eric Anholt2012-07-201-0/+7
| | | | | | | This is a requirement for std140 uniform blocks, and optional for packed/shared blocks. Reviewed-by: Ian Romanick <[email protected]>
* glsl: Don't dead-code eliminiate uniforms declared in uniform blocks.Eric Anholt2012-07-201-1/+7
| | | | | | | This is a requirement for std140 uniform blocks, and optional for packed/shared blocks. Reviewed-by: Ian Romanick <[email protected]>
* glsl: Propagate uniform block information into gl_uniform_storage.Eric Anholt2012-07-202-1/+74
| | | | | | | Now we can actually return information on uniforms in uniform blocks in the new queries. Reviewed-by: Ian Romanick <[email protected]>
* glsl: Set the uniform_block index for the linked shader variables.Eric Anholt2012-07-201-0/+45
| | | | | | | | | | | | At this point in the linking, we've totally lost track of the struct gl_uniform_buffer that this pointed to in the original unlinked shader, so we do a nasty n^2 walk to find it the new one based on the variable name. Note that these point into the shader's list of gl_uniform_buffers, not the linked program's. Reviewed-by: Ian Romanick <[email protected]>
* glsl: Merge the lists of uniform blocks into the linked shader program.Eric Anholt2012-07-203-4/+145
| | | | | | This attempts error-checking, but the layout isn't done yet. Reviewed-by: Ian Romanick <[email protected]>
* glsl: Translate the AST for uniform blocks into some IR structures.Eric Anholt2012-07-205-1/+85
| | | | | | | | | | We're going to need this structure to cross-validate the uniform blocks between shader stages, since unused ir_variables might get dropped. It's also the place we store the RowMajor qualifier, which is not part of the GLSL type (since that would cause a bunch of type equality checks to fail). Reviewed-by: Ian Romanick <[email protected]>
* glsl: Turn UBO variable declarations into ir_variables and check qualifiers.Eric Anholt2012-07-204-3/+39
| | | | | | Fixes piglit layout-*-non-uniform and layout-*-within-block. Reviewed-by: Ian Romanick <[email protected]>
* mesa: Set gl_fragment_program::UsesKill in do_set_program_inouts.Paul Berry2012-07-201-0/+14
| | | | | | | | | | | | | | | | | | | | | Previously, the code for setting this flag for GLSL programs was duplicated in three places: brw_link_shader(), glsl_to_tgsi_visitor, and ir_to_mesa_visitor. In addition to the unnecessary duplication, there was a performance problem on i965: brw_link_shader() set the flag before doing its final round of optimizations, which meant that if the optimizations managed to eliminate all the discard operations, the flag would still be set, resulting (at least in theory) in slower performance. This patch consolidates all of the code that sets UsesKill for GLSL programs into do_set_program_inouts(), which already is doing a similar job for UsesDFdy, and which occurs after i965's final round of optimizations. Non-GLSL programs (ARB programs and the state tracker's glBitmap program) are unaffected. Reviewed-by: Eric Anholt <[email protected]>
* glsl: Remove open coded version of ir_variable::interpolation_string().Kenneth Graunke2012-07-191-15/+1
| | | | | | | | Presumably the function didn't exist when we wrote this code. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Set UsesDFdy appropriately for GLSL shaders.Paul Berry2012-07-191-5/+17
| | | | | | | | | | | | | | | | This patch updates the ir_set_program_inouts_visitor so that it also sets gl_fragment_program::UsesDFdy. This is a bit of a hack (since dFdy() isn't an input or an output), but there's no other obvious visitor to squeeze this functionality into, and it would be silly to create a brand new visitor just for this purpose. v2: use local 'fprog' var to avoid repeated casting. Reviewed-by: Brian Paul <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Drop obsolete .gitignore entries.Michel Dänzer2012-07-171-2/+0
| | | | | | | | Helps spotting and removing the obsolete generated files, which otherwise break the build. Signed-off-by: Michel Dänzer <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* Fix building glsl when using automake-1.12 after 68e04cc6Jon TURNEY2012-07-151-4/+10
| | | | | | | | | | | | | | | | Commit 68e04cc6 was tested using automake-1.11. Unfortunately, automake-1.12 made a "slightly backward-incompatible change" in the use of yacc with C++, and for a .yy file, the generated header file is now named .hh, not .h To work with both, write our own rule for running yacc, which generates a header file named .h, rather than using automake's rule. Also, remove things from BUILD_SOURCES which don't need to be there Also, update EXCLUDE rules in doxygen/glsl.doxy, for change of generated files from .cpp -> .cc, and glsl_lexer.h has never existed. Signed-off-by: Jon TURNEY <[email protected]>
* automake: convert libmesa and libmesagalliumJon TURNEY2012-07-131-1/+1
| | | | | | | | | | | | | | | | | * "configure substitutions are not allowed in _SOURCES variables" in automake, so instead of MESA_ASM_FILES, use some AM_CONDITIONALS to choose which architecture's asm sources are used in libmesa_la_SOURCES. (Can't remove MESA_ASM_FILES autoconf variable as it's still used in sources.mak) * Update to link with the .la file in other Makefile.am files, and make a link to the .a file for the convenience of other Makefiles which have not yet been converted to automake v2: Remove stray -static from LDFLAGS v3: Remove .a compatibility link on clean Signed-off-by: Jon TURNEY <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Tested-by: Matt Turner <[email protected]>
* automake: convert libglslJon TURNEY2012-07-137-147/+170
| | | | | | | | | | | | | | | | | | | | v2: Use AM_V_GEN to silence generated code rules. Add BUILT_SOURCES to CLEANFILES v3: - Fix an accidental // in a path - Use automake make rules for lex/yacc rather than writing our own - Update .gitignore appropriately - Build a libglcpp convenience library rather than awkwardly including the files in libglsl and delegating the generation - Remove libglsl.a compatibility link on clean v4: - Automake's rules for lex/yacc make .cc if source is .ll or .yy, and apparently we must use those extensions "because of scons", so update everywhere glsl_parser.cpp -> glsl_parser.cc and glsl_lexer.cpp -> glsl_lexer.cc. This fixes 'make tarballs' and building with dricore enabled. Signed-off-by: Jon TURNEY <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Tested-by: Matt Turner <[email protected]>
* glsl/ir_builder: Add a new swizzle_for_size() function.Kenneth Graunke2012-07-122-0/+20
| | | | | | | | This swizzles away unwanted components, while preserving the order of the ones that remain. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* glsl/ir_builder: Add a generic constructor for unary expressions.Kenneth Graunke2012-07-122-0/+9
| | | | | | | | | I needed to compute logs and square roots in a patch I was working on, and wanted to use the convenient interface. We already have a similar constructor for binops; adding one for unops seems reasonable. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* glsl: Initialize coordinate to NULL in ir_texture constructor.Kenneth Graunke2012-07-121-1/+2
| | | | | | | | | | | I ran into this while trying to create a TXS query, which doesn't have a coordinate. Since it didn't get initialized to NULL, a bunch of visitors tried to access it and crashed. Most of the time, this won't be a problem, but it's just a good idea. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* glsl: implement ARB_transform_feedback3 in the linkerMarek Olšák2012-07-121-15/+104
| | | | Acked-by: Ian Romanick <[email protected]>