aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/main/ff_fragment_shader.cpp
Commit message (Collapse)AuthorAgeFilesLines
* ff_fragment_shader: Don't do unnecessary (and dangerous) uniform setup.Paul Berry2013-03-191-16/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, right after calling _mesa_glsl_link_shader(), the fixed function fragment shader code made several calls with the ostensible purpose of setting up uniforms for the fragment shader it just created. These calls are unnecessary, since _mesa_glsl_link_shader() calls driver->LinkShader(), which takes care of calling these functions (or their equivalent). Also, they are dangerous to call after _mesa_glsl_link_shader() has returned, because on back-ends such as i965 which do precompilation, _mesa_glsl_link_shader() may have already cached pointers to the existing uniform structures; attempting to set up the uniforms again invalidates those cached pointers. It was only by sheer coincidence that this wasn't manifesting itself as a bug. It turns out that i965's precompile mechanism was always setting bit 0 of brw_wm_prog_key::proj_attrib_mask to 0 for fixed function fragment shaders, but during normal usage this bit usually gets set to 1. As a result, the precompiled shader (with its invalid uniform pointers) was not being used. I'm about to introduce some changes that cause bit 0 of proj_attrib_mask to be set consistently between precompilation and normal usage, so to avoid regressions I need to get rid of the dangerous duplicate uniform setup code first. Reviewed-by: Ian Romanick <[email protected]>
* Replace gl_frag_attrib enum with gl_varying_slot.Paul Berry2013-03-151-19/+19
| | | | | | | | | | | | This patch makes the following search-and-replace changes: gl_frag_attrib -> gl_varying_slot FRAG_ATTRIB_* -> VARYING_SLOT_* FRAG_BIT_* -> VARYING_BIT_* Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Tested-by: Brian Paul <[email protected]>
* Replace gl_vert_result enum with gl_varying_slot.Paul Berry2013-03-151-4/+3
| | | | | | | | | | | This patch makes the following search-and-replace changes: gl_vert_result -> gl_varying_slot VERT_RESULT_* -> VARYING_SLOT_* Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Tested-by: Brian Paul <[email protected]>
* Set es_version to false when using FF fragment shading in meta opsPaul Berry2012-12-071-0/+1
| | | | | Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* mesa: remove 'struct' from texenv_fragment_programBrian Paul2012-09-251-13/+13
| | | | | | texenv_fragment_program is declared as a class. Fixes warnings with MSVC. Reviewed-by: Kenneth Graunke <[email protected]>
* mesa: Silence narrowing warnings in ff_fragment_shader's emit_texenv().Kenneth Graunke2012-09-231-4/+4
| | | | | | | | | | | | | Recent version of GCC report a warning for the implicit conversion from int to float: ff_fragment_shader.cpp:897:3: warning: narrowing conversion of '(1 << ((int)rgb_shift))' from 'int' to 'float' inside { } is ill-formed in C++11 [-Wnarrowing] This is because floats cannot precisely represent all possible 32-bit integer values. However, texenv code is all expected to be floating point, so this should not be a problem. Signed-off-by: Kenneth Graunke <[email protected]>
* mesa: Use a new, more specific hook for shader uniform changes.Kenneth Graunke2012-08-251-1/+2
| | | | | | | | | | | | | | | Gallium drivers and i965 don't require special notification when sampler uniforms change. They simply see the _NEW_TEXTURE and adjust their indirection tables. These drivers don't want ProgramStringNotify: it simply causes pointless recompiles. Unfortunately, i915 still requires shader recompiles and needs ProgramStringNotify. Rather than trying to fix that, simply change the hook to a new, more specific one: ShaderUniformChange. On i915, this translates to ProgramStringNotify; others simply ignore it. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* mesa/ff_shader: Fix sampler state readingPauli Nieminen2012-08-011-1/+4
| | | | | | | | | | | Fixed function fragment shader generator was incorrectly read texture sampling state directly from texture object. To make sure that ARB_sampler_object works correctly shader generator has to use the bound sampler if one exist. Signed-off-by: Pauli Nieminen <[email protected]> Reviewed-by: Brian Paul <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* mesa: Use initializers to configure samplersIan Romanick2012-05-231-32/+9
| | | | | | | | | Now that the linker handles initializers of samplers just like any other uniform, a bunch of this annoying code is unnecessary. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* mesa: add _NEW_VARYING_VP_INPUTS for gl_context::varying_vp_inputsMarek Olšák2012-04-191-1/+1
| | | | | | | | | This is a frequently-updated state and _NEW_ARRAY already causes revalidation of the vbo module. It's kinda counter-productive to recompute arrays in the vbo module if _NEW_ARRAY is set and then set _NEW_ARRAY again. Reviewed-by: Brian Paul <[email protected]> Reviewed-by: Mathias Fröhlich <[email protected]>
* glsl: Add a helper for generating temporary variables in ir_builder.Eric Anholt2012-04-131-31/+11
| | | | Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Add a helper for ir_builder to make dereferences for assignments.Eric Anholt2012-04-131-49/+17
| | | | | | v2: Fix writemask setup for non-vec4 assignments. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Make a little tracking class for emitting IR lists.Eric Anholt2012-04-131-50/+28
| | | | | | | This lets us significantly shorten p->instructions->push_tail(ir), and will be used in a few more places. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Add common swizzles to ir_builder.Eric Anholt2012-04-131-48/+18
| | | | | | | | | | Now we can fold a bunch of our expression setup in ff_fragment_shader into single-line, parseable commits. v2: Make it actually work. I wasn't setting num_components in the mask structure, and not setting up a mask structure is way easier. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Let ir_builder expressions take un-dereferenced variables.Eric Anholt2012-04-131-13/+6
| | | | | | | | | | | Having to explicitly dereference is irritating and bloats the code, when the compiler can detect and do the right thing. v2: Use a little shim class to produce the automatic dereference generation at compile time as opposed to runtime, while also allowing compile-time type checking. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Create an ir_builder helper for hand-generating IR.Eric Anholt2012-04-131-82/+46
| | | | | | | | | | | | | | The C++ constructors with placement new, while functional, are extremely verbose, leading to generation of simple GLSL IR expressions like (a * b + c * d) expanding to many lines of code and using lots of temporary variables. By creating a new ir_builder.h that puts simple generators in our namespace and taking advantage of ralloc_parent(), we can generate much more compact code, at a minor runtime cost. v2: Replace ir_instruction usage with just ir_rvalue. v3: Drop remaining missed as_rvalue() in v2. Reviewed-by: Kenneth Graunke <[email protected]>
* ff_fragment_shader: Remove some dead fields.Eric Anholt2012-04-091-11/+0
| | | | Reviewed-by: Brian Paul <[email protected]>
* mesa: fix ir_variable declarationBrian Paul2012-01-121-1/+1
| | | | | | | | ir_variable is a class, not a struct. NOTE: This is a candidate for the 8.0 branch. Reviewed-by: José Fonseca <[email protected]>
* mesa: remove _mesa_ffs(), implement ffs() for non-GNU platformsBrian Paul2012-01-121-1/+1
| | | | | | | | | | | Call ffs() and ffsll() everywhere. Define our own ffs(), ffsll() functions when the platform doesn't have them. v2: remove #ifdef _WIN32, __IBMC__, __IBMCPP_ tests inside ffs() implementation. The #else clause was recursive. Reviewed-by: Kenneth Graunke <[email protected]> Tested-by: Alexander von Gluck <[email protected]>
* linker: Calculate the sampler to texture target mapping during linkingIan Romanick2012-01-111-1/+1
| | | | | | | | | Track the calculated data in gl_shader_program instead of the individual assembly shaders. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* mesa: Use static buffer for uniform nameIan Romanick2012-01-111-1/+6
| | | | | | Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* mesa: Use uniform interfaces in fixed-function fragment shader codeIan Romanick2012-01-111-5/+24
| | | | | | | | | | | Poking directly at the backing resources works only by luck. Core Mesa code should only know about the gl_uniform_storage structure. Soon other code that looks at samplers will use the gl_uniform_storage structures instead of the data in the gl_program. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Acked-by: Kenneth Graunke <[email protected]>
* ff_fragment_shader: Don't generate swizzles for scalar combiner inputsIan Romanick2012-01-031-6/+10
| | | | | | | | | | | There are a couple scenarios where the source could be zero and the operand could be either SRC_ALPHA or ONE_MINUS_SRC_ALPHA. For example, if the source was ZERO. This would result in something like (0).w, and a later call to ir_validate would get angry. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=42517
* mesa: Make gl_program::InputsRead 64 bits.Mathias Fröhlich2011-11-291-1/+1
| | | | | | | | | Make gl_program::InputsRead a 64 bits bitfield. Adapt the intel and radeon driver to handle a 64 bits InputsRead value. Signed-off-by: Mathias Froehlich <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* mesa: fix frag shader generation for alpha test with no color buffersBrian Paul2011-11-281-0/+6
| | | | | | | | | | | | If alpha test is enabled and there's no color buffers we still need the fragment shader to emit a color. v2: add _NEW_COLOR flag in _mesa_update_state_locked() Fixes piglit fbo-alphatest-nocolor-ff failures with Gallium drivers. Reviewed-by: Eric Anholt <[email protected]> Tested-by: Eric Anholt <[email protected]> (i965)
* mesa: add support for GL_OES_EGL_image_externalChia-I Wu2011-11-031-0/+7
| | | | | | | | | This is an OpenGL ES specific extension. External textures are textures that may be sampled from, but not be updated (no glTexSubImage* and etc.). The image data are taken from an EGLImage. Reviewed-by: Brian Paul <[email protected]> Acked-by: Jakob Bornecrantz <[email protected]>
* mesa, i965: prepare for more than 8 texture targetsChia-I Wu2011-11-031-1/+1
| | | | | | | | | 3-bit fields are used store texture target in several places. That will fail when TEXTURE_EXTERNAL_INDEX, which happends to be the 9th texture target, is added. Make them 4-bit fields. Reviewed-by: Brian Paul <[email protected]> Acked-by: Jakob Bornecrantz <[email protected]>
* glsl: Rename remaining internal builtins from gl_MESA* to gl_*MESA.Eric Anholt2011-10-261-3/+3
| | | | | | This matches the usual convention for extension builtin variables. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Add uniform_locations_assigned parameter to do_dead_code opt passIan Romanick2011-10-251-1/+1
| | | | | | | | | | | | | | | | | 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]>
* mesa: Convert fixed function fragment program generator to GLSL IR.Eric Anholt2011-10-181-749/+682
| | | | | | | | This is a step towards providing a direct route for drivers accepting GLSL IR for codegen. Perhaps more importantly, it runs the fixed function fragment program through the GLSL IR optimization. Having seen how easy it is to make ugly fixed function texenv code that can do unnecessary work, this may improve real applicatinos.
* ff_fragment_shader: Use FRAG_RESULT_COLOR to write all our colors at once.Eric Anholt2011-10-181-12/+3
| | | | | This is a slight simplification on the way to actually generating GLSL fragment shaders.
* mesa: Use gl_shader_program::_LinkedShaders instead of VertexProgramIan Romanick2011-10-071-5/+5
| | | | | | Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Brian Paul <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* Merge branch 'glsl-to-tgsi'Bryan Cain2011-08-041-1/+2
|\ | | | | | | | | | | Conflicts: src/mesa/state_tracker/st_atom_pixeltransfer.c src/mesa/state_tracker/st_program.c
| * mesa: support boolean and integer-based parameters in prog_parameterBryan Cain2011-08-011-1/+2
| | | | | | | | | | | | 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.
* | mesa: Fix ff fragment shader inputs calculation when enabling a VS.Eric Anholt2011-07-281-2/+1
|/ | | | | | | | | | | | | | | | | | 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 <[email protected]>
* mesa: Kill gl_fragment_program::FogOption with fireIan Romanick2011-04-211-8/+1
| | | | | | | | | | | | All drivers expect this to always be GL_NONE. Don't let there be any opportunity for a bad value to leak out and infect some unsuspecting driver. If any driver for hardware that had fixed-function per-fragment fog (i915 and perhaps some r300-ish) was ever going to add support, it would have done it by now. Reviewed-by: Eric Anholt <[email protected]> Acked-by: Corbin Simpson <[email protected]> Acked-by: Alex Deucher <[email protected]>
* mesa: Fix bugs in ff fragment shader fog handlingIan Romanick2011-04-211-19/+20
| | | | | | | | | | | | | | | | | | | | This patch fixes two bugs related to fog in the fixed-function fragment shader generation code. Fog was only lowered to instructions if MRTs were used. The fragment shader assembler always lowers "fog option" code to instructions, and many drivers (e.g., r300) expect this. When fog lowering did happen, it was after the instruction count was checked against implementation limits. Since fog lowering may add up to 5 instructions, a program that was below the limits before lowering may exceed the limits after lowering. NOTE: This is a candidate for the stable branches. Reviewed-by: Eric Anholt <[email protected]> Acked-by: Corbin Simpson <[email protected]> Acked-by: Alex Deucher <[email protected]>
* mesa: move sampler state into new gl_sampler_object typeBrian Paul2011-04-101-3/+4
| | | | | | gl_texture_object contains an instance of this type for the regular texture object sampling state. glGenSamplers() generates new instances of gl_sampler_object which can override that state with glBindSampler().
* mesa: implement clamping controls (ARB_color_buffer_float)Marek Olšák2011-03-291-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Squashed commit of the following: Author: Marek Olšák <[email protected]> mesa: fix getteximage so that it doesn't clamp values mesa: update the compute_version function mesa: add display list support for ARB_color_buffer_float mesa: fix glGet query with GL_ALPHA_TEST_REF and ARB_color_buffer_float commit b2f6ddf907935b2594d2831ddab38cf57a1729ce Author: Luca Barbieri <[email protected]> Date: Tue Aug 31 16:50:57 2010 +0200 mesa: document known possible deviations from ARB_color_buffer_float commit 5458935be800c1b19d1c9d1569dc4fa30a97e8b8 Author: Luca Barbieri <[email protected]> Date: Tue Aug 24 21:54:56 2010 +0200 mesa: expose GL_ARB_color_buffer_float commit aef5c3c6be6edd076e955e37c80905bc447f8a82 Author: Luca Barbieri <[email protected]> Date: Thu Aug 26 18:12:34 2010 +0200 mesa, mesa/st: handle read color clamping properly (I'll squash the st/mesa part to a separate commit. -Marek) We set IMAGE_CLAMP_BIT in the caller based on _ClampReadColor, where the operation mandates it. TODO: did I get the set of operations mandating it right? commit 3a9cb5e59b676b6148c50907ce6eef5441677e36 Author: Luca Barbieri <[email protected]> Date: Thu Aug 26 18:09:41 2010 +0200 mesa: respect color clamping in texenv programs (v2) Changes in v2: - Fix attributes other than vertex color sometimes getting clamped commit de26f9e47e886e176aab6e5a2c3d4481efb64362 Author: Luca Barbieri <[email protected]> Date: Thu Aug 26 18:05:53 2010 +0200 mesa: restore color clamps on glPopAttrib commit a55ac3c300c189616627c05d924c40a8b55bfafa Author: Luca Barbieri <[email protected]> Date: Thu Aug 26 18:04:26 2010 +0200 mesa: clamp color queries if and only if fragment clamping is enabled commit 9940a3e31c2fb76cc3d28b15ea78dde369825107 Author: Luca Barbieri <[email protected]> Date: Wed Aug 25 00:00:16 2010 +0200 mesa: introduce derived _ClampXxxColor state resolving FIXED_ONLY To do this, we make ClampColor call FLUSH_VERTICES with the appropriate _NEW flag. We introduce _NEW_FRAG_CLAMP since fragment clamping has wide-ranging effects, despite being in the Color attrib group. This may be easily changed by s/_NEW_FRAG_CLAMP/_NEW_COLOR/g commit 6244c446e3beed5473b4e811d10787e4019f59d6 Author: Luca Barbieri <[email protected]> Date: Thu Aug 26 17:58:24 2010 +0200 mesa: add unclamped color parameters
* Revert "mesa: Convert fixed function fragment program generator to GLSL IR."Eric Anholt2011-03-121-658/+777
| | | | | This reverts commit 7cb87dffce2c7a37f960f3a865cf92fd193dd8c5. There were regressions (Bug #35244) and more review has been requested.
* mesa: Convert fixed function fragment program generator to GLSL IR.Eric Anholt2011-03-111-777/+658
| | | | | | | | This is a step towards providing a direct route for drivers accepting GLSL IR for codegen. Perhaps more importantly, it runs the fixed function fragment program through the GLSL IR optimization. Having seen how easy it is to make ugly fixed function texenv code that can do unnecessary work, this may improve real applicatinos.
* mesa: Move texenvprogram.c to ff_fragment_shader.cpp.Eric Anholt2011-03-111-0/+1623
This file is about to change to generating a shader program instead of a fragment program.