summaryrefslogtreecommitdiff
path: root/src/glsl/ir_set_program_inouts.cpp
AgeCommit message (Collapse)AuthorFilesLines
2013-10-03glsl: flag shaders which use gather4 at allChris Forbes1-0/+9
Signed-off-by: Chris Forbes <chrisf@ijw.co.nz> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2013-09-23glsl: Hide many classes local to individual .cpp files in anon namespaces.Eric Anholt1-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 <kenneth@whitecape.org> Reviewed-by: Ian Romanick <ian.d.romanick@.intel.com>
2013-08-14glsl: Fix incorrect pattern matching in ir_set_program_inoutsPaul Berry1-2/+2
In commit 8fc41df (glsl: Modify ir_set_program_inouts to handle geometry shaders), when attempting to pattern match the "foo" part of expressions such as: foo[i][j] foo[i] I incorrectly called as_dereference_variable() on the subexpression foo[i] instead of foo. As a result, the pattern never matched, so ir_set_program_inouts would fall back on marking the entire variable as used, rather than just the portion indexed by the array. This didn't result in incorrect behaviour, but it could have resulted in inefficiency by causing the back-end to allocate resources for unused parts of an input or output array. Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2013-08-01glsl: Modify ir_set_program_inouts to handle geometry shaders.Paul Berry1-12/+75
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
2013-08-01glsl: In ir_set_program_inouts, handle indexing outside array/matrix bounds.Paul Berry1-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 <ian.d.romanick@intel.com> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2013-08-01glsl: Fallback gracefully if ir_set_program_inouts sees unexpected indexing.Paul Berry1-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 <ian.d.romanick@intel.com> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2013-08-01glsl: Extract marking functions from ir_set_program_inouts.Paul Berry1-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 <ian.d.romanick@intel.com> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2013-08-01glsl: Use count_attribute_slots() in ir_set_program_inouts.Paul Berry1-8/+2
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2013-08-01glsl: Change do_set_program_inouts' is_fragment_shader arg to shader_type.Paul Berry1-12/+12
This will allow us to add geometry shader support without having to add another boolean argument. Reviewed-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2013-02-03glsl: Remove hash table from ir_set_program_inouts pass.Kenneth Graunke1-24/+14
Back when ir_var_in and ir_var_out signified both function parameters and shader input/outputs, we had trouble distinguishing the two when looking at a dereference. Now that we have separate ir_var_shader_in and ir_var_shader_out modes, we can determine this easily. Removing the hash table saves memory and CPU overhead. Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
2013-01-24glsl: Eliminate ambiguity between function ins/outs and shader ins/outsPaul Berry1-3/+3
This patch replaces the three ir_variable_mode enums: - ir_var_in - ir_var_out - ir_var_inout with the following five: - ir_var_shader_in - ir_var_shader_out - ir_var_function_in - ir_var_function_out - ir_var_function_inout This eliminates a frustrating ambiguity: it used to be impossible to tell whether an ir_var_{in,out} variable was a shader in/out or a function in/out without seeing where the variable was declared in the IR. This complicated some optimization and lowering passes, and would have become a problem for implementing varying structs. In the lisp-style serialization of GLSL IR to strings performed by ir_print_visitor.cpp and ir_reader.cpp, I've retained the names "in", "out", and "inout" for function parameters, to avoid introducing code churn to the src/glsl/builtins/ir/ directory. Note: a couple of comments in the code seemed to indicate that we were planning for a possible future in which geometry shaders could have shader-scope inout variables. Our GLSL grammar rejects shader-scope inout variables, and I've been unable to find any evidence in the GLSL standards documents (or extensions) that this will ever be allowed, so I've eliminated these comments. Reviewed-by: Carl Worth <cworth@cworth.org> Reviewed-by: Jordan Justen <jordan.l.justen@intel.com> Reviewed-by: Eric Anholt <eric@anholt.net>
2012-07-20mesa: Set gl_fragment_program::UsesKill in do_set_program_inouts.Paul Berry1-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 <eric@anholt.net>
2012-07-19glsl: Set UsesDFdy appropriately for GLSL shaders.Paul Berry1-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 <brianp@vmware.com> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
2012-06-25glsl: Add IsCentroid bitfield to gl_fragment_program.Paul Berry1-1/+5
This bitfield tells the back-ends which of a fragment shader's inputs require centroid interpolation. It is only set for GLSL fragment shaders, since assembly fragment shaders don't support centroid interpolation. Reviewed-by: Eric Anholt <eric@anholt.net>
2012-04-13glsl: add support for ARB_blend_func_extended (v3)Dave Airlie1-2/+2
This adds index support to the GLSL compiler. I'm not 100% sure of my approach here, esp without how output ordering happens wrt location, index pairs, in the "mark" function. Since current hw doesn't ever have a location > 0 with an index > 0, we don't have to work out if the output ordering the hw requires is location, index, location, index or location, location, index, index. But we have no hw to know, so punt on it for now. v2: index requires layout - catch and error setup explicit index properly. v3: drop idx_offset stuff, assume index follow location Signed-off-by: Dave Airlie <airlied@redhat.com>
2011-10-27mesa: Expose GLSL interpolation qualifiers in gl_fragment_program.Paul Berry1-13/+34
This patch makes GLSL interpolation qualifiers visible to drivers via the array InterpQualifier[] in gl_fragment_program, so that they can easily be used by driver back-ends to select the correct interpolation mode. Previous to this patch, the GLSL compiler was using the enum ir_variable_interpolation to represent interpolation types. Rather than make a duplicate enum in core mesa to represent the same thing, I moved the enum into mtypes.h and renamed it to be more consistent with the other enums defined there. Reviewed-by: Brian Paul <brianp@vmware.com> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Eric Anholt <eric@anholt.net>
2011-10-18ir_to_mesa: Move some things outside the 'extern "C"' blocksIan Romanick1-2/+0
Having a few of these includes or forward declarations inside the 'extern "C"' block can cause problems later. Specifically, it prevents C++ linkage functions from being added to ir_to_mesa.h and makes G++ angry if 'struct foo' is seen both inside and outside an 'extern "C"'. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2011-09-08glsl: Fix setting of OutputsWritten for whole array dereference.Eric Anholt1-4/+2
We just want to mark the whole thing used, not mark from each element the whole size in use. Fixes undefined URB entry writes on i965, which blew up with debugging enabled. Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
2011-01-15Merge branch 'draw-instanced'Brian Paul1-1/+5
Conflicts: src/gallium/auxiliary/draw/draw_llvm.c src/gallium/drivers/llvmpipe/lp_state_fs.c src/glsl/ir_set_program_inouts.cpp src/mesa/tnl/t_vb_program.c
2010-12-09glsl: Correct the marking of InputsRead/OutputsWritten on in/out matrices.Eric Anholt1-20/+15
If you used a constant array index to access the matrix, we'd flag a bunch of wrong inputs/outputs as being used because the index was multiplied by matrix columns and the actual used index was left out. Fixes glsl-mat-attribute.
2010-12-08glsl: add support for system values and GL_ARB_draw_instancedBrian Paul1-2/+7
2010-08-24glsl: Include main/core.h.Chia-I Wu1-1/+1
Make glsl include only main/core.h from core mesa.
2010-08-18glsl: Fix leak-causing typo in destructor that made it another constructor.Eric Anholt1-1/+1
2010-08-06glsl2: Move gl_program->InputsRead/OutputsWritten setting to an ir pass.Eric Anholt1-0/+167
This lets us handle arrays much better than trying to work backwards from assembly. Fixes fbo-drawbuffers-maxtargets on swrast (i965 needs loop unrolling)