aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers/dri/i965/brw_shader.cpp
Commit message (Collapse)AuthorAgeFilesLines
* i965: Complain about variable index lowering when INTEL_DEBUG=perf.Kenneth Graunke2012-09-291-2/+8
| | | | | Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* i965: Dump linked shaders on MESA_GLSL=dump.Kenneth Graunke2012-09-291-0/+9
| | | | | | | | | | | Often, the original shader IR isn't terribly interesting because a lot of crucial optimizations haven't been done (such as inlining built-ins). ir_to_mesa used to print this out for us, but since we don't use it, we have to do it ourselves. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* intel: Mark some file-local code as static.Eric Anholt2012-09-271-1/+1
| | | | Reviewed-by: Kenneth Graunke <[email protected]>
* i965: Make VS programs obey the shader_precompile driconf option.Kenneth Graunke2012-08-271-1/+1
| | | | | | | | Now that it's on by default, we may as well make it obey the flag, for consistency's sake if nothing else. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* i965: Fix brw_link_shader to return false rather than NULL.Kenneth Graunke2012-08-251-1/+1
| | | | | | | | | | Fixes brw_shader.cpp:101:9: warning: converting to non-pointer type 'GLboolean {aka unsigned char}' from NULL [-Wconversion-null] Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-with-great-enthusiasm-by: Paul Berry <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Reviewed-by Eric Anholt <[email protected]>
* i965/fs: Add support for loading uniform buffer variables as pull constants.Eric Anholt2012-08-071-0/+3
| | | | | | | | Variable array indexing isn't finished, because the lowering pass turns it all into conditional moves of constant index accesses so I can't test it. Reviewed-by: Kenneth Graunke <[email protected]>
* mesa: Set gl_fragment_program::UsesKill in do_set_program_inouts.Paul Berry2012-07-201-25/+0
| | | | | | | | | | | | | | | | | | | | | 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]>
* i965: Add a lowering pass to convert TXD to TXL by computing the LOD.Kenneth Graunke2012-07-121-0/+1
| | | | | | | | | | | | | | | | | | Intel hardware doesn't natively support textureGrad with shadow comparisons. So we need to generate code to handle it somehow. Based on the equations of page 205 of the OpenGL 3.0 specification, it's possible to compute the LOD value that would be selected given the gradient values. Then, we can simply convert the TXD to a TXL. Currently, this passes 34/46 of oglconform's shadow-grad subtests; four cubemap tests are regressed. We should investigate this in the future. v2: Apply abs() to the scalar case (thanks to Eric). Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* i965: Fix refcount leak of the gl_program structure.Eric Anholt2012-01-181-0/+2
| | | | | | | Fixes a leak of almost 200kb on a minimal shader_runner program (algebraic-add-add-1). NOTE: This is a candidate for the 8.0 branch.
* i965: Don't use _mesa_ir_link_shader to do our dirty workIan Romanick2012-01-111-7/+85
| | | | | | | | | | | | | | | | | | | | | Instead, do the uniform setting and input / output mapping directly in brw_link_shader. Hurray for not generating Mesa IR! However, once the i965 driver stops calling _mesa_ir_link_shader, UsesClipDistance and UsesKill are no longer set. Ideally gen6_upload_vs_push_constants should use the gl_shader_program, but I don't see a way to propagate the information there. The other alternative, since this is the only usage, is to move gl_vertex_program::UsesClipDistance to brw_vertex_program. The compile (and precompile) stages use UsesKill to determine the cache key for the shader. This is then used to determine whether or not to compile the shader. Calculating this data during compilation is too late. Signed-off-by: Ian Romanick <[email protected]> Acked-by: Kenneth Graunke <[email protected]> Acked-by: Eric Anholt <[email protected]>
* i965/fs: Factor out texture offset bitfield computation.Kenneth Graunke2011-12-191-0/+23
| | | | | | | | | We'll want to reuse this for the VS, and it's complex enough that I'd rather not cut and paste it. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* i965: Don't perform the precompile on fragment shaders by default.Eric Anholt2011-11-301-1/+3
| | | | | | | | | | | | | | | | It is useful to have this option for shader-db, and it was also good at the time where we were rejecting shaders due to various internal limits we hadn't supported yet. However, at this point the precompile step takes extra time (since not all NOS is known at link time) and spews misleading debug in the common case of debugging a real app. This is left in place for VS, where we still have a couple of codegen failure paths that result in link failure through precompile. Those need to be fixed. shader-db can still get at the debug info it wants using "shader_precompile=true" driconf option. Long term, we can probably build a good-enough app for shader-db to trigger real codegen.
* i965: Make brw_type_for_base_type return the element type for arrays.Eric Anholt2011-11-091-0/+1
| | | | | | | | | | | | | | | | Previously, brw_type_for_base_type returned UD for array variables, similar to structures. For structures, each field may have a different type, so every field access must explicitly override the register's type with that field's type. We chose to return UD in this case since it was the least common, so errors would be more obvious. For arrays, it makes far more sense to return the type corresponding to an element of the array. This allows normal array access to work without the hassle of explicitly overriding the register's type. This should obsolete a bunch of type overrides throughout the code. Reviewed-by: Kenneth Graunke <[email protected]>
* i965: Move _mesa_ir_link_shader call before device-specific linkingIan Romanick2011-11-071-3/+3
| | | | | | | | | | | | | | | _mesa_ir_link_shader needs to be called before cloning the IR tree so that the var->location field for uniforms is set. WARNING: This change breaks several integer division related piglit tests. The tests break because _mesa_ir_link_shader lowers integer division to an RCP followed by a MUL. The fix is to factor out more of the code from ir_to_mesa so that _mesa_ir_link_shader does not need to be called at all by the i965 driver. This will be the subject of several follow-on patches. Signed-off-by: Ian Romanick <[email protected]> Tested-by: Tom Stellard <[email protected]>
* glsl: Add uniform_locations_assigned parameter to do_dead_code opt passIan Romanick2011-10-251-1/+2
| | | | | | | | | | | | | | | | | Setting this flag prevents declarations of uniforms from being removed from the IR. Since the IR is directly used by several API functions that query uniforms in shaders, uniform declarations cannot be removed after the locations have been set. However, it should still be safe to reorder the declarations (this is not tested). Signed-off-by: Ian Romanick <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=41980 Tested-by: Brian Paul <[email protected]> Reviewed-by: Bryan Cain <[email protected]> Cc: Vinson Lee <[email protected]> Cc: José Fonseca <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Yuanhan Liu <[email protected]>
* intel: Convert from GLboolean to 'bool' from stdbool.h.Kenneth Graunke2011-10-181-3/+3
| | | | | | | | | | | | | | | | | I initially produced the patch using this bash command: for file in {intel,i915,i965}/*.{c,cpp,h}; do [ ! -h $file ] && sed -i 's/GLboolean/bool/g' $file && sed -i 's/GL_TRUE/true/g' $file && sed -i 's/GL_FALSE/false/g' $file; done Then I manually added #include <stdbool.h> to fix compilation errors, and converted a few functions back to GLboolean that were used in core Mesa's function pointer table to avoid "incompatible pointer" warnings. Finally, I cleaned up some whitespace issues introduced by the change. Signed-off-by: Kenneth Graunke <[email protected]> Acked-by: Chad Versace <[email protected]> Acked-by: Paul Berry <[email protected]>
* i965: Stop lowering integer division to multiply and reciprocal.Kenneth Graunke2011-10-021-1/+0
| | | | | | | Signed-off-by: Kenneth Graunke <[email protected]> Tested-by: Ian Romanick <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* i965/fs: Implement integer quotient and remainder math operations.Kenneth Graunke2011-10-021-0/+4
| | | | | | | Signed-off-by: Kenneth Graunke <[email protected]> Tested-by: Ian Romanick <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* glsl: Use a separate div_to_mul_rcp lowering flag for integers.Bryan Cain2011-08-311-0/+1
| | | | | | | | | | | | | | Using multiply and reciprocal for integer division involves potentially lossy floating point conversions. This is okay for older GPUs that represent integers as floating point, but undesirable for GPUs with native integer division instructions. TGSI, for example, has UDIV/IDIV instructions for integer division, so it makes sense to handle this directly. Likewise for i965. Reviewed-by: Ian Romanick <[email protected]> Signed-off-by: Bryan Cain <[email protected]> Signed-off-by: Kenneth Graunke <[email protected]>
* i965/vs: Don't lower uniform array indexing.Eric Anholt2011-08-301-1/+1
| | | | | | | | | | This avoids the massive conditional move array access, and brings code generation quality for the new VS backend into the realm of efficiency of the old backend (roughly 20% more instructions generated than before across shader-db, instead of assertion failing for generating over 10,000 instructions on many shaders!). Reviewed-by: Kenneth Graunke <[email protected]>
* i965: Fix Android build by removing relative includesChad Versace2011-08-301-2/+2
| | | | | | | | | | Replace each occurence of #include "../glsl/*.h" with #include "glsl/*.h" Reviewed-by: Ian Romanick <[email protected]> Signed-off-by: Chad Versace <[email protected]>
* i965/vs: Run the shader backend at link time and return compile failures.Eric Anholt2011-08-161-0/+4
| | | | | | Link failure is something that shouldn't happen, but we sometimes want it during development. The precompile also allows analysis of shader codegen with shader-db.
* i965/vs: Enable variable array indexing in the VS.Eric Anholt2011-08-161-5/+7
|
* i965: Start adding the VS visitor and codegen.Eric Anholt2011-08-161-0/+26
| | | | | | The low-level IR is a mashup of brw_fs.cpp and ir_to_mesa.cpp. It's currently controlled by the INTEL_NEW_VS=1 environment variable, and only tested for the trivial "gl_Position = gl_Vertex;" shader so far.
* i965: Generate driver-specific IR for non-fragment shaders as well.Eric Anholt2011-08-161-5/+12
| | | | | | This will be used by the new vertex shader backend. The scalarizing passes are skipped for non-fragment, since vertex and geometry threads are based on vec4s.
* i965/fs: Do a FS compile up front at link time to produce link errors.Eric Anholt2011-05-271-0/+17
| | | | | | At glLinkShaders time, a fail() call in FS compile in 8-wide (the one that's required to succeed, though we may relax that at some point for pre-Ironlake performance) will now report out as a link error.
* i965: Move a couple of GLSL IR -> BRW helper functions to brw_shader.cpp.Eric Anholt2011-05-271-0/+50
| | | | | | These will be used by the VS backend as well. Reviewed-by: Kenneth Graunke <[email protected]>
* i965: Move non-FS-specific shader support to brw_shader.cpp.Eric Anholt2011-05-271-0/+127
These only existed in brw_fs.cpp because it was the only .cpp file in the area when I wrote them. Reviewed-by: Kenneth Graunke <[email protected]>