aboutsummaryrefslogtreecommitdiffstats
path: root/src/glsl
Commit message (Collapse)AuthorAgeFilesLines
...
* glsl: Remove glsl_parser_state MaxVaryingFloats fieldIan Romanick2013-10-073-5/+4
| | | | | | | | | | Pull the data directly from the context like the other varying related limits. The parser state shadow copies were added back when the parser state didn't have a pointer to the context. There's no reason to do it now days. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Paul Berry <[email protected]>
* glsl: Set gl_MaxVertexOutputs from VertexProgram.MaxOutputComponents etcIan Romanick2013-10-071-2/+2
| | | | | | | | | | | | | | gl_MaxVertexOutputVectors => ctx->Const.VertexProgram.MaxOutputComponents gl_MaxFragmentInputVectors => ctx->Const.FragmentProgram.MaxInputComponents v2: Add types so that the code compiles. Pointed out by Brian. v3: Leave gl_MaxVaryingFloats et al. as-is. Suggested by Paul. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Brian Paul <[email protected]> [v2] Reviewed-by: Marek Olšák <[email protected]> [v2] Reviewed-by: Paul Berry <[email protected]> [v2]
* glsl: Count shader inputs and outputs separatelyIan Romanick2013-10-073-25/+91
| | | | | | | | | | | | Starting with OpenGL 3.2 input limits and output limits for stages may not match. This means they need to be accounted separately. No piglit regressions. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Brian Paul <[email protected]> Reviewed-by: Marek Olšák <[email protected]> Reviewed-by: Paul Berry <[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: add ARB_gpu_shader5's additional textureGather signaturesChris Forbes2013-10-061-1/+26
| | | | | | | | | | | - gsampler2DRect support - optional `comp` parameter Future patches will add shadow sampler support and textureGatherOffsets(). Signed-off-by: Chris Forbes <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Add support for specifying the component in textureGatherChris Forbes2013-10-068-7/+42
| | | | | | | | | | | ARB_gpu_shader5 introduces new variants of textureGather* which have an explicit component selector, rather than relying purely on the sampler's swizzle state. This patch adds the GLSL plumbing for the extra parameter. Signed-off-by: Chris Forbes <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: add plumbing for GL_ARB_texture_query_levelsChris Forbes2013-10-0513-6/+84
| | | | | Signed-off-by: Chris Forbes <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: Define isnormal for Oracle Solaris Studio.Vinson Lee2013-10-041-0/+6
| | | | | | | | This patch fixes this Oracle Solaris Studio build error. "../../src/glsl/ir_constant_expression.cpp", line 1398: Error: The function "isnormal" must have a prototype. Signed-off-by: Vinson Lee <[email protected]>
* glsl: flag shaders which use gather4 at allChris Forbes2013-10-031-0/+9
| | | | | Signed-off-by: Chris Forbes <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: add texture gather changesMaxence Le Dore2013-10-0313-4/+57
| | | | | | | | | | V2 [Chris Forbes]: - Add new pattern, fixup parameter reading. V3: Rebase onto new builtins machinery Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* ralloc: Remove the rzalloc-based new/delete operator definition macro.Francisco Jerez2013-10-011-14/+12
| | | | | | | | | | Using it encourages the (IMHO worrying) practice of leaving member variables uninitialized in constructor definitions. This macro shouldn't be necessary anymore after the last patch series fixing all its users to initialize all member variables from the class constructor. Remove it. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Switch ast_type_qualifier to the non-zeroing allocator.Francisco Jerez2013-10-011-1/+1
| | | | | | | | All member variables of ast_type_qualifier are already being initialized from its implicitly defined constructor, it's not necessary to use rzalloc to allocate its memory. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Switch ast_node to the non-zeroing allocator.Francisco Jerez2013-10-012-2/+11
| | | | | | | | | | | | | | | | | | All member variables of ast_node are already being initialized from its constructor, but some of its derived classes were leaving members uninitialized -- Fix them. Using rzalloc makes it more likely that we will start relying on the allocator to zero out all memory if the class is ever extended with new member variables. That's bad because it ties objects to some specific allocation scheme, and gives unpredictable results when an object is created with a different allocator -- Stack allocation, array allocation, or aggregation inside a different object are some of the useful possibilities that come to my mind. v2: Use NULL initialization instead of default construction for pointers. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Initialize all member variables of _mesa_glsl_parse_state on construction.Francisco Jerez2013-10-012-3/+15
| | | | | | | | | | | | | | | The _mesa_glsl_parse_state object relies on the memory allocator zeroing out its contents before it's initialized, which is quite an unusual practice in the C++ world because it ties objects to some specific allocation scheme, and gives unpredictable results when an object is created with a different allocator -- Stack allocation, array allocation, or aggregation inside a different object are some of the useful possibilities that come to my mind. Initialize all fields from the constructor and stop using the zeroing allocator. Reviewed-by: Paul Berry <[email protected]> Reviewed-by: Chad Versace <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Create and use a has_uniform_buffer_objects() helper.Kenneth Graunke2013-09-263-7/+8
| | | | | | | | | | | This is better than overriding the extension enable based on the language version; it's robust against shaders that do: #version 140 #extension GL_ARB_uniform_buffer_object : disable Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Create and use a has_explicit_attrib_location() helper.Kenneth Graunke2013-09-264-6/+7
| | | | | | | | | | | | | | | | | | | Explicit attribute locations are supported with GLSL 3.30, GLSL ES 3.00, or "#extension GL_ARB_explicit_attrib_location: enable". Using a helper function makes it easy to check for this. This enables support in GLSL 3.30, which was previously missing. Previously, we overrode the extension enable flag for ES 3.00. This is not robust against a shader such as: #version 330 #extension GL_ARB_explicit_attrib_location : disable Disabling extensions should not remove core language functionality. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Initialize ir_lower_jumps_visitor member variables.Vinson Lee2013-09-241-1/+6
| | | | | | | Fixes "Unintialized scalar field" defect reported by Coverity. Signed-off-by: Vinson Lee <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Initialize lower_vector_visitor::dont_lower_swz.Vinson Lee2013-09-241-1/+1
| | | | | | | Fixes "Uninitialized scalar field" defect reported by Coverity. Signed-off-by: Vinson Lee <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Initialize assignment_generator member variables.Vinson Lee2013-09-241-0/+6
| | | | | | | Fixes "Uninitialized pointer field" defect reported by Coverity. Signed-off-by: Vinson Lee <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Hide many classes local to individual .cpp files in anon namespaces.Eric Anholt2013-09-2332-0/+112
| | | | | | | | 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: Define isnormal and copysign for MSVC to fix build.Vinson Lee2013-09-221-0/+14
| | | | | | | | | | | | | This patch fixes these MSVC build errors. ir_constant_expression.cpp src\glsl\ir_constant_expression.cpp(564) : warning C4244: '=' : conversion from 'int' to 'float', possible loss of data src\glsl\ir_constant_expression.cpp(1384) : error C3861: 'isnormal': identifier not found src\glsl\ir_constant_expression.cpp(1385) : error C3861: 'copysign': identifier not found Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=69541 Signed-off-by: Vinson Lee <[email protected]> Acked-by: Matt Turner <[email protected]>
* glsl: Use the new DECLARE_R[Z]ALLOC_CXX_OPERATORS in a bunch of places.Kenneth Graunke2013-09-215-121/+7
| | | | | | | | | This eliminates a lot of boilerplate and should be 100% equivalent. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Chad Versace <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* ralloc: Introduce new macros for defining C++ new/delete operators.Kenneth Graunke2013-09-211-0/+26
| | | | | | | | | | | | | | | | Most of our C++ classes define placement new and delete operators so we can do convenient allocation via: thing *foo = new(mem_ctx) thing(...) Currently, this is done via a lot of boilerplate. By adding simple macros to ralloc, we can condense this to a single line, making it trivial to add this feature to a new class. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Chad Versace <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Set VertexProgram.MaxOutputComponents and ↵Ian Romanick2013-09-191-0/+2
| | | | | | | | | FragmentProgram.MaxInputComponents in standalone scaffolding Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Brian Paul <[email protected]> Reviewed-by: Marek Olšák <[email protected]> Reviewed-by: Paul Berry <[email protected]>
* glsl: Delete builtin_builder::shader when destroying built-ins.Kenneth Graunke2013-09-191-0/+3
| | | | | | | | | | I would use _mesa_delete_shader, but it's declared static, and we don't really need any of the stuff in it anyway. This fixes a memory leak caught by Valgrind. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* android: Remove builtin_compilerAdrian Negreanu2013-09-181-19/+0
| | | | | | | | | | | | The first part was done in: commit c845140a20efa6a30a5465301d1f9b4acea79155 Author: Kenneth Graunke <[email protected]> Date: Tue Sep 3 21:22:17 2013 -0700 Signed-off-by: Adrian Negreanu <[email protected]> Acked-by: Ian Romanick <[email protected]> Reviewed-by: Chad Versace <[email protected]>
* glsl: Correctly validate fma()'s types.Matt Turner2013-09-171-0/+6
| | | | | | lrp() can take a scalar as a third argument, and fma() cannot. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Add frexp signatures and implementation.Matt Turner2013-09-171-0/+56
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I initially implemented frexp() as an IR opcode with a lowering pass, but since it returns a value and has an out-parameter, it would break assumptions our optimization passes make about ir_expressions being pure (i.e., having no side effects). For example, if opt_tree_grafting encounters this code: uniform float u; void main() { int exp; float f = frexp(u, out exp); float g = float(exp)/256.0; float h = float(exp) + 1.0; gl_FragColor = vec4(f, g, h, g + h); } it may try to optimize it to this: uniform float u; void main() { int exp; float g = float(exp)/256.0; float h = float(exp) + 1.0; gl_FragColor = vec4(frexp(u, out exp), g, h, g + h); } Some hardware has an instruction which performs frexp(), but we would need some other compiler infrastructure to be able to generate it, such as an intrinsics system that would allow backends to emit specific code for particular bits of IR. Reviewed-by: Paul Berry <[email protected]>
* glsl: Add ldexp_to_arith lowering pass.Matt Turner2013-09-172-0/+129
| | | | Reviewed-by: Paul Berry <[email protected]>
* glsl: Allow vectors to be created from ir_constant().Matt Turner2013-09-173-29/+41
| | | | | | | | Note the parameter name change in the int version of ir_constant, to avoid the conflict with the loop iterator. v2: Make analogous change to builtin_builder::imm(). Reviewed-by: Paul Berry <[email protected]>
* glsl: Add support for ldexp.Matt Turner2013-09-175-0/+41
| | | | | v2: Drop frexp. Rebase on builtins rewrite. Reviewed-by: Paul Berry <[email protected]>
* glsl/tests: Update .gitignore for new unit test.Kenneth Graunke2013-09-161-0/+1
| | | | | | I rarely run 'git status', so I failed to notice this was missing. Signed-off-by: Kenneth Graunke <[email protected]>
* glsl/tests: Add a test for properties of sampler types.Kenneth Graunke2013-09-152-0/+114
| | | | | | | | | | | | For each sampler type, this tests that: - The base type is GLSL_TYPE_SAMPLER. - The dimensionality is set correctly. - The returned data type is correct. - The sampler_array and sampler_shadow flags are set correctly. - sampler_coordinate_components() returns the correct value. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl/builtins: Fix {texture1D,texture2D,shadow1D}ArrayLod availibility.Paul Berry2013-09-131-5/+5
| | | | | | | | | | | | | | These functions are defined in EXT_texture_array, which makes no mention of what shader types they should be allowed in. At the time EXT_texture_array was introduced, functions ending in "Lod" were available only in vertex shaders, however this restriction was lifted in later spec versions and extensions. We already have the function lod_exists_in_stage() for figuring out whether functions ending in "Lod" should be available, so just re-use that. Reviewed-by: Kenneth Graunke <[email protected]>
* mesa: Rename MESA_shader_integer_mix to EXT_shader_integer_mixIan Romanick2013-09-134-6/+6
| | | | | | | | | | | | | | Everyone at the Khronos meeting was as surprised that GLSL didn't already support this as we were. Several vendors said they'd ship it, but there didn't seem to be enough interest to put in the effort to make it ARB or KHR. v2: Fix a couple typos and rename the spec file to EXT_shader_integer_mix.spec. Suggested by Roland. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Roland Scheidegger <[email protected]>
* glsl: Use sampler_coordinate_components instead of passing it by hand.Kenneth Graunke2013-09-111-450/+450
| | | | | | | | | | | We used to pass the number of components actually used for the coordinate (rather than padding, shadow comparitors, and projectors) by hand, specifying it on every _texture() call. The new helper function can just compute this, eliminating a lot of potential mistakes. Signed-off-by: Kenneth Graunke <[email protected]>
* glsl: Add a new glsl_type::sampler_coordinate_components() function.Kenneth Graunke2013-09-112-0/+47
| | | | | | | This computes the number of components necessary to address a sampler based on its dimensionality. It will be useful for texturing built-ins. Signed-off-by: Kenneth Graunke <[email protected]>
* glsl: During linking, record whether a GS uses EndPrimitive().Paul Berry2013-09-111-0/+31
| | | | | | | | | This information will be useful in the i965 back end, since we can save some compilation effort if we know from the outset that the shader never calls EndPrimitive(). Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Add missing va_end in builtin_builder::add_function.Vinson Lee2013-09-101-0/+1
| | | | | | | Fixes "Missing varargs init or cleanup" defect reported by Coverity. Signed-off-by: Vinson Lee <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Initialize builtin_builder member variables.Vinson Lee2013-09-101-0/+3
| | | | | | | Fixes "Uninitialized pointer field" defect reported by Coverity. Signed-off-by: Vinson Lee <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: fix variadic macro for MSVCBrian Paul2013-09-091-2/+2
| | | | | | MSVC doesn't accept the rest... syntax. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: remove struct keyword from ir_variable declarationsBrian Paul2013-09-091-4/+4
| | | | | | To silence MSVC warnings. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Implement MESA_shader_integer_mix extension.Matt Turner2013-09-094-7/+38
| | | | | | | Because why doesn't GLSL allow you to do this already? Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Use conditional-select in mix().Matt Turner2013-09-091-8/+8
| | | | | Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Add conditional-select IR.Matt Turner2013-09-096-0/+36
| | | | | | | | | | | It's a ?: that operates per-component on vectors. Will be used in upcoming lowering pass for ldexp and the implementation of frexp. csel(selector, a, b): per-component result = selector ? a : b Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Rename ir_function_signature::builtin_info to builtin_avail.Kenneth Graunke2013-09-093-7/+7
| | | | | | | | | | | | builtin_info was originally going to be a structure containing a bunch of information, but after various rewrites, it turned into a boolean availability predicate. builtin_avail is a better name than builtin_info, since it doesn't store any information other than availability. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Paul Berry <[email protected]>
* glsl: Add missing type inference for ir_binop_bfm.Kenneth Graunke2013-09-091-0/+1
| | | | | | | | Matt noticed that this was missing. Nothing uses this currently. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Paul Berry <[email protected]>
* glsl: Delete old built-in function generation code.Kenneth Graunke2013-09-09135-11595/+0
| | | | | | | | None of this is used anymore. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]> Acked-by: Paul Berry <[email protected]>
* glsl: Remove builtin_compiler from the build system.Kenneth Graunke2013-09-098-249/+21
| | | | | | | | | We don't actually use anything from builtin_function.cpp, so we don't need to generate it anymore. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]> Acked-by: Paul Berry <[email protected]>
* glsl: Switch to the new built-in function module.Kenneth Graunke2013-09-093-29/+4
| | | | | | | | All built-ins are now handled by the new code; the old system is dead. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Paul Berry <[email protected]>