Commit Graph

45742 Commits

Author SHA1 Message Date
Bryan Cain 71cbc9e3c4 glsl_to_tgsi: improve eliminate_dead_code_advanced() 2011-08-01 17:59:09 -05:00
Bryan Cain 3bd06e5b82 glsl_to_tgsi: use the correct writemask in try_emit_mad() and try_emit_sat() 2011-08-01 17:59:09 -05:00
Bryan Cain 194732fd72 glsl_to_tgsi: use a more specific condition for gl_FragDepth hack in generating assignments
This reduces the number of instructions in the fragment shader of
glsl-fs-atan-2 from 174 to 146 with EmitNoIfs enabled.
2011-08-01 17:59:09 -05:00
Bryan Cain 41472f7809 glsl_to_tgsi: add a better, more advanced dead code elimination pass 2011-08-01 17:59:08 -05:00
Bryan Cain 7ec7dd4fb6 glsl_to_tgsi: remove handling of XPD opcode in compile_tgsi_instruction()
The opcode is never emitted by the glsl_to_tgsi_visitor, so its special case in
compile_tgsi_instruction() was dead code.
2011-08-01 17:59:08 -05:00
Bryan Cain 8b881ad1c3 glsl_to_tgsi: use swizzle_for_size for src reg in conditional moves
This prevents the copy propagation pass from being confused by undefined
channels and thus missing optimization opportunities.
2011-08-01 17:59:08 -05:00
Emil Velikov 8c50f18b29 glsl_to_tgsi: execute merge_registers() after eliminate_dead_code()
Fixes a regression unintentionally introduced by "glsl_to_tgsi: fix shaders with
indirect addressing of temps" that caused missing leaves in 3dmark01 test 4 (Nature)
and missing/displaced textures on human models in Counter-Strike: Source.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Signed-off-by: Bryan Cain <bryancain3@gmail.com>
2011-08-01 17:59:08 -05:00
Bryan Cain 29d21417e3 glsl_to_tgsi: implement simplify_cmp pass needed by r300g 2011-08-01 17:59:08 -05:00
Bryan Cain 552cc48fca glsl_to_tgsi: fix compile error with g++ 4.6 2011-08-01 17:59:08 -05:00
Bryan Cain 1141c3f4c4 glsl: remove glsl_type::get_vec4_type()
Thanks to Kenneth Graunke for pointing out that glsl_type::get_instance(base, 4, 1)
is the same as glsl_type::get_vec4_type(base).

The function was only used in st_glsl_to_tgsi, and this commit replaces that usage
with get_instance.
2011-08-01 17:59:08 -05:00
Bryan Cain b30bbd7436 glsl_to_tgsi: silence compiler warning 2011-08-01 17:59:08 -05:00
Bryan Cain bf1cee9f24 glsl_to_tgsi: finish some loose ends 2011-08-01 17:59:08 -05:00
Bryan Cain b2c067e307 glsl-to-tgsi: fix piglit tests
This commit fixes all of the piglit tests regressed by "mesa, glsl_to_tgsi: add
native support for integers in shaders" on softpipe.
2011-08-01 17:59:08 -05:00
Bryan Cain b191382c60 mesa, glsl_to_tgsi: add native support for integers in shaders
Disabled by default on all drivers.  To enable it, change ctx->GLSLVersion to 130
in st_extensions.c.  Currently, softpipe is the only driver with integer support.
2011-08-01 17:59:08 -05:00
Bryan Cain f95169deb4 tgsi: add support for TGSI_OPCODE_MOD in tgsi_exec 2011-08-01 17:59:08 -05:00
Bryan Cain 6d89abadbc mesa: support boolean and integer-based parameters in prog_parameter
The functionality is not used by anything yet, and the glUniform functions will
need to be reworked before this can reach its full usefulness.  It is
nonetheless a step towards integer support in the state tracker and classic drivers.
2011-08-01 17:59:07 -05:00
Bryan Cain 17b695e6e7 gallium: add PIPE_SHADER_CAP_INTEGERS 2011-08-01 17:59:07 -05:00
Bryan Cain 16d7a717d5 glsl_to_tgsi: fix shaders with indirect addressing of temps
Fixes several Piglit tests, although it's a step backwards for optimization.
2011-08-01 17:59:07 -05:00
Bryan Cain 56dc2c176c glsl_to_tgsi: use TGSI opcodes when converting from GLSL IR
Before, the translator used Mesa IR opcodes (a holdover from ir_to_mesa) and
converted them to TGSI opcodes during TGSI emission.
2011-08-01 17:59:07 -05:00
Bryan Cain 3b0858f1ae glsl_to_tgsi: support DDY (ir_unop_dFdy) 2011-08-01 17:59:07 -05:00
Bryan Cain a6705aa5ca glsl_to_tgsi: lower noise opcodes when converting from GLSL IR, not when generating TGSI 2011-08-01 17:59:07 -05:00
Bryan Cain 5768ed6429 glsl_to_tgsi: define the sampler objects used
Fixes the Nexuiz title screen and the water in 0 A.D.
2011-08-01 17:59:07 -05:00
Bryan Cain 556bd82ce1 glsl_to_tgsi: remove a bad assertion
It was triggered by Alien Arena.
2011-08-01 17:59:07 -05:00
Bryan Cain c341d3cfd0 glsl_to_tgsi: remove reads to output registers
Fixes a regression in 0 A.D. introduced by 809a11c77073e999fd47.
2011-08-01 17:59:07 -05:00
Bryan Cain 44867da354 glsl_to_tgsi: stop generating Mesa IR
Before, it was still generating unused Mesa IR as a remnant of ir_to_mesa, and
depended on some of the information from it.
2011-08-01 17:59:07 -05:00
Bryan Cain 1e5fd8e480 mesa: fix segfault when no Mesa IR is generated 2011-08-01 17:59:07 -05:00
Bryan Cain f379d8f730 st/mesa: Add a GLSL IR to TGSI translator.
It is still a work in progress at this point, but it produces working and
reasonably well-optimized code.

Originally based on ir_to_mesa and st_mesa_to_tgsi, but does not directly use
Mesa IR instructions in TGSI generation, instead generating TGSI from the
intermediate class glsl_to_tgsi_instruction.  It also has new optimization
passes to replace _mesa_optimize_program.
2011-08-01 17:59:07 -05:00
Paul Berry b1b4ea0b36 glsl: improve the accuracy of the atan(x,y) builtin function.
The previous formula for atan(x,y) returned a value of +/- pi whenever
|x|<0.0001, and used a formula based on atan(y/x) otherwise.  This
broke in cases where both x and y were small (e.g. atan(1e-5, 1e-5)).

This patch modifies the formula so that it returns a value of +/- pi
whenever |x|<1e-8*|y|, and uses the formula based on atan(y/x)
otherwise.
2011-08-01 14:37:38 -07:00
Paul Berry d4c80f5f85 glsl: improve the accuracy of the asin() builtin function.
The previous formula for asin(x) was algebraically equivalent to:

sign(x)*(pi/2 - sqrt(1-|x|)*(A + B|x| + C|x|^2))

where A, B, and C were arbitrary constants determined by a curve fit.

This formula had a worst case absolute error of 0.00448, an unbounded
worst case relative error, and a discontinuity near x=0.

Changed the formula to:

sign(x)*(pi/2 - sqrt(1-|x|)*(pi/2 + (pi/4-1)|x| + A|x|^2 + B|x|^3))

where A and B are arbitrary constants determined by a curve fit.  This
has a worst case absolute error of 0.00039, a worst case relative
error of 0.000405, and no discontinuities.

I don't expect a significant performance degradation, since the extra
multiply-accumulate should be fast compared to the sqrt() computation.

Fixes piglit tests {vs,fs}-asin-float and {vs,fs}-atan-*
2011-08-01 14:37:38 -07:00
Chad Versace 5541920e0a glsl: Remove duplicate comment
Remove duplicate doxgen comment for
ir_function.cpp:parameter_lists_match().

Signed-off-by: Chad Versace <chad@chad-versace.us>
2011-08-01 09:37:06 -07:00
Jeremy Huddleston 5b3c719983 darwin: Use machine/endian.h to determine endianness
Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
2011-07-31 09:43:52 -07:00
Jeremy Huddleston e737a99a6f Fix PPC detection on darwin
Fixes regression introduced by 7004582c18

Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
2011-07-31 09:24:35 -07:00
Chad Versace 5081d31a0e glsl: Clarify ir_function::matching_sigature()
The function used a variable named 'score', which was an outright lie.
A signature matches or it doesn't; there is no fuzzy scoring.

Change the return type of parameter_lists_match() to an enum, and
let ir_function::matching_sigature() switch on that enum.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Signed-off-by: Chad Versace <chad@chad-versace.us>
2011-07-30 07:27:38 -07:00
Chad Versace a5ab9398e3 glsl: Fix conversions in array constructors
Array constructors obey narrower conversion rules than other constructors
[1] --- they use the implicit conversion rules [2] instead of the scalar
constructor conversions [3].  But process_array_constructor() was
incorrectly applying the broader rules.

[1] GLSL 1.50 spec, Section 5.4.4 Array Constructors, page 52 (58 of pdf)
[2] GLSL 1.50 spec, Section 4.1.10 Implicit Conversions, page 25 (31 of pdf)
[3] GLSL 1.50 spec, Section 5.4.1 Conversion, page 48 (54 of pdf)

To fix this, first check (with glsl_type::can_be_implicitly_converted_to)
if an implicit conversion is legal before performing the conversion.

Fixes:
piglit:spec/glsl-1.20/compiler/structure-and-array-operations/array-ctor-implicit-conversion-bool-float.vert
piglit:spec/glsl-1.20/compiler/structure-and-array-operations/array-ctor-implicit-conversion-bvec*-vec*.vert

Note: This is a candidate for the 7.10 and 7.11 branches.
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Signed-off-by: Chad Versace <chad@chad-versace.us>
2011-07-30 07:27:30 -07:00
Chad Versace 6efe1a8495 glsl: Remove ir_function.cpp:type_compare()
The function is no longer used and has been replaced by
glsl_type::can_implicitly_convert_to().

Note: This is a candidate for the 7.10 and 7.11 branches.
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Signed-off-by: Chad Versace <chad@chad-versace.us>
2011-07-30 07:27:25 -07:00
Chad Versace 8b3627fd7b glsl: Fix implicit conversions in non-constructor function calls
Context
-------
In ast_function_expression::hir(), parameter_lists_match() checks if the
function call's actual parameter list matches the signature's parameter
list, where the match may require implicit conversion of some arguments.
To check if an implicit conversion exists between individual arguments,
type_compare() is used.

Problems
--------
type_compare() allowed the following illegal implicit conversions:
    bool -> float
    bvecN -> vecN

    int -> uint
    ivecN -> uvecN

    uint -> int
    uvecN -> ivecN

Change
------
type_compare() is buggy, so replace it with glsl_type::can_be_implicitly_converted_to().
This comprises a rewrite of parameter_lists_match().

Fixes piglit:spec/glsl-1.20/compiler/built-in-functions/outerProduct-bvec*.vert

Note: This is a candidate for the 7.10 and 7.11 branches.
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Signed-off-by: Chad Versace <chad@chad-versace.us>
2011-07-30 07:27:14 -07:00
Chad Versace 200e4972c1 glsl: Add method glsl_type::can_implicitly_convert_to()
This method checks if a source type is identical to or can be implicitly
converted to a target type according to the GLSL 1.20 spec, Section 4.1.10
Implicit Conversions.

The following commits use the method for a bugfix:
    glsl: Fix implicit conversions in non-constructor function calls
    glsl: Fix implicit conversions in array constructors

Note: This is a candidate for the 7.10 and 7.11 branches.
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Signed-off-by: Chad Versace <chad@chad-versace.us>
2011-07-30 07:26:59 -07:00
Brian Paul 120d71a45c mesa: minor comment changes in teximage.c 2011-07-29 16:49:55 -06:00
Brian Paul dc1f32deae mesa: add missing breaks for GL_TEXTURE_CUBE_MAP_SEAMLESS queries
And fix indentation.

NOTE: This is a candidate for the 7.11 branch.
2011-07-29 16:49:55 -06:00
Eric Anholt f710b8c750 i965/fs: Allow register coalescing where the source is a uniform.
Removes 0.8% of the fragment shader instructions on Unigine Tropics.
2011-07-29 12:17:03 -07:00
Eric Anholt a8b86459a1 i965/fs: Optimize a * 1.0 -> a.
This appears in our instruction stream as a result of the
brw_vs_constval.c handling.
2011-07-29 12:17:03 -07:00
Eric Anholt 6d8d6b41b8 i965/fs: If we see a RCP of a constant, try to constant fold it. 2011-07-29 12:17:03 -07:00
Eric Anholt eb30820f26 i965/fs: Port texture projection avoidance optimization from the old backend.
This is part of fixing a ~1% performance regression in OpenArena when
changing the fixed function fragment shader to using the new backend.
Right now this just avoids the LINTERP of the projector, not the math
using it.
2011-07-29 12:17:03 -07:00
Eric Anholt 652ef8569c Revert "i965: Don't compute brw->wm.input_size_masks when it's unused."
This reverts commit 3412069e23.  We're
about to start using it in fragment shaders to handle avoiding
projection for fixed function.
2011-07-29 12:17:03 -07:00
Eric Anholt 44ffb4ae20 i965/fs: Stop using the exec_list iterator.
The old style has gone out of favor in the project, but I kept copy
and pasting from existing iterator code.
2011-07-29 12:17:03 -07:00
Alex Deucher dc1c0ca22a r600g: fix up vs export handling
Certain attributes (position, psize, etc.) don't
count as params; they are handled separately by the hw.
However, the VS is required to export at least one param
and r600_shader_from_tgsi() takes care of adding a dummy
export if there is none.  Make sure the VS param export
count in the SPI properly accounts for this.

Note: This is a candidate for the 7.11 branch.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2011-07-29 11:34:02 -04:00
Chia-I Wu 5c9e0ad5fd st/egl: create pbuffers with PIPE_BIND_SAMPLER_VIEW
So that eglBindTexImage works.
2011-07-29 14:16:51 +09:00
Eric Anholt 4fdd289805 i965/fs: Respect ARB_color_buffer_float clamping.
This was done in the old codegen path, but not the new one.  Caught by
piglit fbo tests after the conversion to GLSL ff_fragment_shader.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2011-07-28 20:58:18 -07:00
Eric Anholt ef1854d090 mesa: Fix ff fragment shader inputs calculation when enabling a VS.
The FF VS generation happens just after the FF FS generation in
state.c, so the ctx->VP._Current value is for the previous state
update's vertex shader, not the one that will be chosen as a result of
this state update.  The vertexShader and vertexProgram variables
should be accurately telling us whether there's going to be a
ctx->VP._Current (except on _MaintainTnlProgram drivers, where it's
always true).

The glsl-vs-statechange-1 test was created to test for this, but it
turns out that the bug is hidden by the fact that we call
_mesa_update_state() twice per draw call -- once from
_mesa_valid_to_render() and once from vbo_draw_arrays(), and the
second one was fixing up the first one.

Reviewed-by: Brian Paul <brianp@vmware.com>
2011-07-28 20:51:53 -07:00
Chia-I Wu 96ca6a6262 targets/{egl,gbm}: omit unneeded libdrm_radeon 2011-07-29 10:24:45 +09:00