mesa.git
13 years agoi965/fs: Preserve the source register type when doing color writes.
Eric Anholt [Wed, 9 Nov 2011 03:26:39 +0000 (19:26 -0800)]
i965/fs: Preserve the source register type when doing color writes.

When rendering to integer color buffers, we need to be careful to use
MRFs of the correct type when emitting color writes.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
13 years agoi965: Make brw_type_for_base_type return the element type for arrays.
Eric Anholt [Wed, 9 Nov 2011 03:26:38 +0000 (19:26 -0800)]
i965: Make brw_type_for_base_type return the element type for arrays.

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 <kenneth@whitecape.org>
13 years agoi965: Enable ChooseTexFormat for supported GL_EXT_texture_integer formats.
Eric Anholt [Wed, 5 Oct 2011 20:42:19 +0000 (13:42 -0700)]
i965: Enable ChooseTexFormat for supported GL_EXT_texture_integer formats.

v2: s/GL_TRUE/true/, and re-enable RGB_INT32 based on discussion
    yesterday about required RB formats vs texture formats.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> (v1)
13 years agoi965: Add mapping from MESA_FORMAT to BRW_SURFACEFORMAT for integer.
Eric Anholt [Wed, 5 Oct 2011 20:38:03 +0000 (13:38 -0700)]
i965: Add mapping from MESA_FORMAT to BRW_SURFACEFORMAT for integer.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
13 years agointel: Expose GL_EXT_texture_integer when GL 3.0 override is set.
Eric Anholt [Wed, 5 Oct 2011 20:25:36 +0000 (13:25 -0700)]
intel: Expose GL_EXT_texture_integer when GL 3.0 override is set.

This will let the feature be incrementally developed, hidden behind
the flag we're all using as we work on GL 3.0 support.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
13 years agodocs: Note EXT_texture_array on i965.
Eric Anholt [Wed, 5 Oct 2011 20:26:42 +0000 (13:26 -0700)]
docs: Note EXT_texture_array on i965.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
13 years agoi965: Add support for 16-bit unorm L, A, and I textures.
Eric Anholt [Tue, 8 Nov 2011 19:05:17 +0000 (11:05 -0800)]
i965: Add support for 16-bit unorm L, A, and I textures.

While not required by any particular spec version, mplayer was asking
for L16 and hoping for actual L16 without checking.  The 8 bits
allocated led to 10-bit planar video data stored in the lower 10 bits
giving only 2 bits of precision in video.  While it was an amusing
effect, give them what they actually wanted instead.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=41461

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
13 years agointel: Don't _mesa_problem when asked for an RB of a texturing-only type.
Eric Anholt [Tue, 8 Nov 2011 19:19:45 +0000 (11:19 -0800)]
intel: Don't _mesa_problem when asked for an RB of a texturing-only type.

We want to be able to support some formats for texturing that we can't
render to, which means that some choices for RenderbufferStorage end
up being incomplete (for example, L8 currently).  For these, where we
don't render to them, we don't want to have to make up an rb->DataType
that's only used for GetRow()/PutRow().

13 years agor200: remove dangling radeon.h symlink.
Paul Berry [Tue, 8 Nov 2011 15:50:56 +0000 (07:50 -0800)]
r200: remove dangling radeon.h symlink.

Commit 1401b96b (radeon: cleanup radeon shared code after r300 and
r600 classic drivers removal) removed the file
src/mesa/drivers/dri/radeon/server/radeon.h, but it left behind the
symlink which was used to share that file into the
src/mesa/drivers/dri/r200/server directory.

This patch removes the dangling symlink.

Reviewed-by: Alex Deucher <alexdeucher@gmail.com>
13 years agoglsl: Assign transform feedback varying slots in linker.
Paul Berry [Sat, 5 Nov 2011 18:17:32 +0000 (11:17 -0700)]
glsl: Assign transform feedback varying slots in linker.

This patch modifies the GLSL linker to assign additional slots for
varying variables used by transform feedback, and record the varying
slots used by transform feedback for use by the driver back-end.

This required modifying assign_varying_locations() so that it assigns
a varying location if either (a) the varying is used by the next stage
of the GL pipeline, or (b) the varying is required by transform
feedback.  In order to avoid duplicating the code to assign a single
varying location, I moved it into its own function,
assign_varying_location().

In addition, to support transform feedback in the case where there is
no fragment shader, it is now possible to call
assign_varying_locations() with a consumer of NULL.

Reviewed-by: Marek Olšák <maraeo@gmail.com>
Tested-by: Marek Olšák <maraeo@gmail.com>
13 years agoglsl: Clamp vector indices when lowering to swizzles
Ian Romanick [Mon, 7 Nov 2011 18:58:00 +0000 (10:58 -0800)]
glsl: Clamp vector indices when lowering to swizzles

This prevents other code from seeing a swizzle of the 16th component
of a vector, for example.

NOTE: This is a candidate for the 7.11 branch.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=42517
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
Tested-by: Christian Holler <choller@mozilla.com>
13 years agoscons: Disable deprecated POSIX name MSVC warnings.
José Fonseca [Wed, 9 Nov 2011 10:33:21 +0000 (10:33 +0000)]
scons: Disable deprecated POSIX name MSVC warnings.

13 years agomesa,glsl,mapi: Put extern "C" { ... } where appropriate.
José Fonseca [Wed, 9 Nov 2011 10:20:51 +0000 (10:20 +0000)]
mesa,glsl,mapi: Put extern "C" { ... } where appropriate.

Probably a several places missing, but enough to cover all headers
(in)directly included by uniform_query.cpp, and fix the MSVC build.

13 years agoscons: Don't list m_xform.c twice.
José Fonseca [Wed, 9 Nov 2011 10:17:02 +0000 (10:17 +0000)]
scons: Don't list m_xform.c twice.

13 years agoglu: Fix deprecated conversion from string constant to ‘char*’ warning.
José Fonseca [Wed, 9 Nov 2011 09:08:58 +0000 (09:08 +0000)]
glu: Fix deprecated conversion from string constant to ‘char*’ warning.

13 years agor600g: clarify meaning of one variable in shader codegen
Marek Olšák [Tue, 8 Nov 2011 22:19:03 +0000 (23:19 +0100)]
r600g: clarify meaning of one variable in shader codegen

It's easier to read now.

13 years agor600g: cosmetic changes in query code
Marek Olšák [Tue, 8 Nov 2011 22:09:33 +0000 (23:09 +0100)]
r600g: cosmetic changes in query code

Mainly updating comments and removing one use of a magic number.

13 years agor600g: use modulo for computing index into query (ring) buffers
Marek Olšák [Tue, 8 Nov 2011 22:05:36 +0000 (23:05 +0100)]
r600g: use modulo for computing index into query (ring) buffers

13 years agor600g: make r600_query_result more generic
Marek Olšák [Tue, 8 Nov 2011 21:02:03 +0000 (22:02 +0100)]
r600g: make r600_query_result more generic

We'll soon start adding new query types, maybe even querying more than
one value per query.

13 years agoRemove tgsi_sse2.
José Fonseca [Tue, 8 Nov 2011 00:10:47 +0000 (00:10 +0000)]
Remove tgsi_sse2.

tgsi_exec is simple. llvm is fast. tgsi_sse2 ends up being neither.

13 years agomesa: fix signed/unsigned integer comparison warnings
Brian Paul [Tue, 8 Nov 2011 15:23:41 +0000 (08:23 -0700)]
mesa: fix signed/unsigned integer comparison warnings

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
13 years agoglsl: remove trailing comma to silence warning
Brian Paul [Tue, 8 Nov 2011 15:23:16 +0000 (08:23 -0700)]
glsl: remove trailing comma to silence warning

13 years agomesa: Implement glGetFragDataLocation
Ian Romanick [Fri, 4 Nov 2011 23:32:02 +0000 (16:32 -0700)]
mesa: Implement glGetFragDataLocation

Fixes piglit's getfragdatalocation test.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
13 years agolinker: Use app-specified fragment data location during linking
Ian Romanick [Fri, 4 Nov 2011 23:08:52 +0000 (16:08 -0700)]
linker: Use app-specified fragment data location during linking

Fixes piglit's bindfragdata-link-error.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
13 years agomesa: Stub implementation of glBindFragDataLocation
Ian Romanick [Fri, 4 Nov 2011 22:48:41 +0000 (15:48 -0700)]
mesa: Stub implementation of glBindFragDataLocation

This just validates the input parameters so far.

Fixes piglit's bindfragdata-invalid-parameters test.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
13 years agosoftpipe: don't clamp or do logical operations on floating-point buffers.
Morgan Armand [Mon, 7 Nov 2011 19:43:28 +0000 (20:43 +0100)]
softpipe: don't clamp or do logical operations on floating-point buffers.

Signed-off-by: Brian Paul <brianp@vmware.com>
13 years agost/mesa: Fix memory leak on error path.
Vinson Lee [Sun, 6 Nov 2011 05:36:08 +0000 (22:36 -0700)]
st/mesa: Fix memory leak on error path.

Fixes Coverity resource leak defect.

Reviewed-by: José Fonseca <jfonseca@vmware.com>
13 years agost/dri: Fix memory leak on error path.
Vinson Lee [Sun, 6 Nov 2011 05:19:31 +0000 (22:19 -0700)]
st/dri: Fix memory leak on error path.

Fixes Coverity resource leak defect.

Reviewed-by: José Fonseca <jfonseca@vmware.com>
13 years agoglsl: Generate IR for switch statements
Dan McCabe [Tue, 8 Nov 2011 00:17:58 +0000 (16:17 -0800)]
glsl: Generate IR for switch statements

Up until now modifying the GLSL compiler has been pretty straightforward.
This is where things get interesting. But still pretty straightforward.

Switch statements can be thought of a series of if/then/else statements.
Case labels are compared with the value of a test expression and the case
statements are executed if the comparison is true.

There are a couple of aspects of switch statements that complicate this simple
view of the world. The primary one is that cases can fall through sequentially
to subsequent case, unless a break statement is encountered, in which case,
the switch statement exits completely.

But break handling is further complicated by the fact that a break statement
can impact the exit of a loop. Thus, we need to coordinate break processing
between switch statements and loop statements.

The code generated by a switch statement maintains three temporary state
variables:
    int test_value;
    bool is_fallthru;
    bool is_break;

test_value is initialized to the value of the test expression at the head of
the switch statement. This is the value that case labels are compared against.

is_fallthru is used to sequentially fall through to subsequent cases and is
initialized to false. When a case label matches the test expression, this
state variable is set to true. It will also be forced to false if a break
statement has been encountered. This forcing to false on break MUST be
after every case test. In practice, we defer that forcing to immediately after
the last case comparison prior to executing a case statement, but that is
an optimization.

is_break is used to indicate that a break statement has been executed and is
initialized to false. When a break statement is encountered, it is set to true.
This state variable is then used to conditionally force is_fallthru to to false
to prevent subsequent case statements from executing.

Code generation for break statements depends on whether the break statement is
inside a switch statement or inside a loop statement. If it inside a loop
statement is inside a break statement, the same code as before gets generated.
But if a switch statement is inside a loop statement, code is emitted to set
the is_break state to true.

Just as ASTs for loop statements are managed in a stack-like
manner to handle nesting, we also add a bool to capture the innermost switch
or loop condition. Note that we still need to maintain a loop AST stack to
properly handle for-loop code generation on a continue statement. Technically,
we don't (yet) need a switch AST stack, but I am using one for orthogonality
with loop statements, in anticipation of future use. Note that a simple
boolean stack would have sufficed.

We will illustrate a switch statement with its analogous conditional code that
a switch statement corresponds to by examining an example.

Consider the following switch statement:
switch (42) {
case 0:
case 1:
gl_FragColor = vec4(1.0, 2.0, 3.0, 4.0);
case 2:
case 3:
gl_FragColor = vec4(4.0, 3.0, 2.0, 1.0);
break;
case 4:
default:
gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);
}

Note that case 0 and case 1 fall through to cases 2 and 3 if they occur.

Note that case 4 and the default case must be reached explicitly, since cases
2 and 3 break at the end of their case.

Finally, note that case 4 and the default case don't break but simply fall
through to the end of the switch.

For this code, the equivalent code can be expressed as:
int test_val = 42; // capture value of test expression
bool is_fallthru = false; // prevent initial fall through
bool is_break = false; // capture the execution of a break stmt

is_fallthru |= (test_val == 0); // enable fallthru on case 0
is_fallthru |= (test_val == 1); // enable fallthru on case 1
is_fallthru &= !is_break; // inhibit fallthru on previous break
if (is_fallthru) {
gl_FragColor = vec4(1.0, 2.0, 3.0, 4.0);
}

is_fallthru |= (test_val == 2); // enable fallthru on case 2
is_fallthru |= (test_val == 3); // enable fallthru on case 3
is_fallthru &= !is_break; // inhibit fallthru on previous break
if (is_fallthru) {
gl_FragColor = vec4(4.0, 3.0, 2.0, 1.0);
is_break = true; // inhibit all subsequent fallthru for break
}

is_fallthru |= (test_val == 4); // enable fallthru on case 4
is_fallthru = true; // enable fallthru for default case
is_fallthru &= !is_break; // inhibit fallthru on previous break
if (is_fallthru) {
gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);
}

The code generate for |= and &= uses the conditional assignment capabilities
of the IR.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
13 years agoglsl: Reference data structure ctors in grammar
Dan McCabe [Mon, 7 Nov 2011 23:11:04 +0000 (15:11 -0800)]
glsl: Reference data structure ctors in grammar

We now tie the grammar to the ctors of the ASTs they reference.

This requires that we actually have definitions of the ctors.

In addition, we also need to define "print" and "hir" methods for the AST
classes. The Print methods are pretty simple to flesh out. However, at this
stage of the development, we simply stub out the "hir" methods and flesh
them out later.

Also, since actual class instances get returned by the productions in the
grammar, we also need to designate the type of the productions that
reference those instances.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
13 years agoglsl: Create AST structs corresponding to new productions in grammar
Dan McCabe [Mon, 7 Nov 2011 23:09:40 +0000 (15:09 -0800)]
glsl: Create AST structs corresponding to new productions in grammar

Previously we added productions for:
switch_body
case_label_list
case_statement
case_statement_list
Now add AST structs corresponding to those productions.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
13 years agoglsl: Add productions to GLSL grammar for switch statement
Dan McCabe [Mon, 7 Nov 2011 23:07:43 +0000 (15:07 -0800)]
glsl: Add productions to GLSL grammar for switch statement

The grammar is modified to support switch statements. Rather than follow the
grammar in the appendix, which allows case labels to be placed ANYWHERE
as a regular statement, we follow the development of the grammar as
described in the body of the GLSL spec.

In this variation, the switch statement has a body which consists of a list
of case statements. A case statement is preceded by a list of case labels and
ends with a list of statements.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
13 years agoglsl: Create AST data structures for switch statement and case label
Dan McCabe [Mon, 7 Nov 2011 23:05:16 +0000 (15:05 -0800)]
glsl: Create AST data structures for switch statement and case label

Data structures for switch statement and case label are created that parallel
the structure of other AST data.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
13 years agoutil: add log2f for Android
Chia-I Wu [Sun, 6 Nov 2011 21:48:11 +0000 (14:48 -0700)]
util: add log2f for Android

It is needed for nv50's new shader backend.  With this change, both u_math.h
and imports.h in core mesa define the same function.  I have to #undef log2f
here to avoid the conflict.  Not sure if there is a better way to deal with
the situation.

Acked-by: José Fonseca <jfonseca@vmware.com>
13 years agomesa: remove prog_uniform.c from SConscript
Brian Paul [Mon, 7 Nov 2011 23:35:38 +0000 (16:35 -0700)]
mesa: remove prog_uniform.c from SConscript

13 years agoDelete code made dead by previous uniform related patches
Ian Romanick [Tue, 18 Oct 2011 23:50:10 +0000 (16:50 -0700)]
Delete code made dead by previous uniform related patches

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Tested-by: Tom Stellard <thomas.stellard@amd.com>
13 years agomesa: Add missing check for glUniform*v count > 1 on non-array
Ian Romanick [Tue, 18 Oct 2011 23:28:21 +0000 (16:28 -0700)]
mesa: Add missing check for glUniform*v count > 1 on non-array

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Tested-by: Tom Stellard <thomas.stellard@amd.com>
13 years agomesa: Rewrite the way uniforms are tracked and handled
Ian Romanick [Tue, 18 Oct 2011 23:01:49 +0000 (16:01 -0700)]
mesa: Rewrite the way uniforms are tracked and handled

Switch all of the code in ir_to_mesa, st_glsl_to_tgsi, glUniform*,
glGetUniform, glGetUniformLocation, and glGetActiveUniforms to use the
gl_uniform_storage structures in the gl_shader_program.

A couple of notes:

 * Like most rewrite-the-world patches, this should be reviewed by
   applying the patch and examining the modified functions.

 * This leaves a lot of dead code around in linker.cpp and
   uniform_query.cpp.  This will be deleted in the next patches.

v2: Update the comment block (previously a FINISHME) in _mesa_uniform
about generating GL_INVALID_VALUE when an out-of-range sampler index
is specified.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Tested-by: Tom Stellard <thomas.stellard@amd.com>
13 years agoi965: Move _mesa_ir_link_shader call before device-specific linking
Ian Romanick [Mon, 24 Oct 2011 23:37:01 +0000 (16:37 -0700)]
i965: Move _mesa_ir_link_shader call before device-specific linking

_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 <ian.d.romanick@intel.com>
Tested-by: Tom Stellard <thomas.stellard@amd.com>
13 years agomesa: Add log_uniform and log_program_parameters to dump data
Ian Romanick [Tue, 18 Oct 2011 22:21:04 +0000 (15:21 -0700)]
mesa: Add log_uniform and log_program_parameters to dump data

These were both useful debugging aids while developing this code.
log_uniform will be used to keep the MESA_GLSL=uniform behavior.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Tested-by: Tom Stellard <thomas.stellard@amd.com>
13 years agoir_to_mesa: Add _mesa_associate_uniform_storage
Ian Romanick [Tue, 18 Oct 2011 22:07:45 +0000 (15:07 -0700)]
ir_to_mesa: Add _mesa_associate_uniform_storage

Connects all of the gl_program_parameter structures with the correct
gl_uniform_storage structures.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Tested-by: Tom Stellard <thomas.stellard@amd.com>
13 years agomesa: Add _mesa_uniform_{attach,detach_all}_driver_storage functions
Ian Romanick [Tue, 18 Oct 2011 21:38:12 +0000 (14:38 -0700)]
mesa: Add _mesa_uniform_{attach,detach_all}_driver_storage functions

These functions are used to create and destroy the connections between
a uniform and the storage used by the driver to hold its value.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Tested-by: Tom Stellard <thomas.stellard@amd.com>
13 years agomesa: Add _mesa_propagate_uniforms_to_driver_storage
Ian Romanick [Tue, 18 Oct 2011 21:29:43 +0000 (14:29 -0700)]
mesa: Add _mesa_propagate_uniforms_to_driver_storage

This function propagates the values from the backing storage of a
gl_uniform_storage structure to the driver supplied data locations.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Tested-by: Tom Stellard <thomas.stellard@amd.com>
13 years agolinker: Track uniform locations to new tracking structures
Ian Romanick [Tue, 18 Oct 2011 18:54:48 +0000 (11:54 -0700)]
linker: Track uniform locations to new tracking structures

This is just the infrastructure and the code.  It's not used yet.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Tested-by: Tom Stellard <thomas.stellard@amd.com>
13 years agomesa: Add structures for "new style" uniform tracking in shader programs
Ian Romanick [Tue, 18 Oct 2011 18:53:19 +0000 (11:53 -0700)]
mesa: Add structures for "new style" uniform tracking in shader programs

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Tested-by: Tom Stellard <thomas.stellard@amd.com>
13 years agolinker: Add helper class for parcelling out backing storage to uniforms
Ian Romanick [Tue, 18 Oct 2011 18:24:58 +0000 (11:24 -0700)]
linker: Add helper class for parcelling out backing storage to uniforms

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Tested-by: Tom Stellard <thomas.stellard@amd.com>
13 years agolinker: Add helper class for determining uniform usage
Ian Romanick [Tue, 18 Oct 2011 18:09:14 +0000 (11:09 -0700)]
linker: Add helper class for determining uniform usage

v2: Remane class count_uniform_size based on feedback from Eric:

    "Maybe just "count_uniform_size"?  "usage" makes me think "way it's
    dereferenced" or something."

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Tested-by: Tom Stellard <thomas.stellard@amd.com>
13 years agomesa: Move most of uniforms.c to uniform_query.cpp
Ian Romanick [Thu, 13 Oct 2011 20:45:39 +0000 (13:45 -0700)]
mesa: Move most of uniforms.c to uniform_query.cpp

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Tested-by: Tom Stellard <thomas.stellard@amd.com>
13 years agomesa: Refactor parameter validate for GetUniform, Uniform, and UniformMatrix
Ian Romanick [Fri, 14 Oct 2011 03:18:31 +0000 (20:18 -0700)]
mesa: Refactor parameter validate for GetUniform, Uniform, and UniformMatrix

v2: Update a comment block about the different treatment of
location=-1 based on feedback from Ken.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Tested-by: Tom Stellard <thomas.stellard@amd.com>
13 years agomesa: Move {split,merge}_location_offset to uniforms.h
Ian Romanick [Thu, 13 Oct 2011 20:42:56 +0000 (13:42 -0700)]
mesa: Move {split,merge}_location_offset to uniforms.h

Prepend _mesa_uniform_ to the names and rework the calling
convention.  The calling convention was changed for a couple reasons.

1. Having a single variable named 'location' have completely different
meanings at different places in the function is confusing.  Before
calling split_location_offset the location is the encoded value
returned by glGetUniformLocation.  After calling split_location_offset
it's the index of the uniform in the gl_uniform_list::Uniforms array.

2. In a later commit the original value of 'location' is needed after
split_location_offset has been called.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Tested-by: Tom Stellard <thomas.stellard@amd.com>
13 years agoglsl: Add new structures for tracking uniforms in linked shaders
Ian Romanick [Wed, 12 Oct 2011 00:16:18 +0000 (17:16 -0700)]
glsl: Add new structures for tracking uniforms in linked shaders

v2: Update some comments based on feedback from Eric Anholt.

v3: Remove gl_uniform_storage::dirty field.  Make
gl_uniform_storage::initialized be bool, and make
gl_uniform_storage::sampler be uint8_t.

v4: Include stdbool.h after Tom Stellard noticed a build failure that
was introduced by the changes in v2.  Oops.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Tested-by: Tom Stellard <thomas.stellard@amd.com>
13 years agomesa: Make get_uniform available outside compilation unit
Ian Romanick [Wed, 12 Oct 2011 00:02:06 +0000 (17:02 -0700)]
mesa: Make get_uniform available outside compilation unit

Also rename to _mesa_get_uniform.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Tested-by: Tom Stellard <thomas.stellard@amd.com>
13 years agomesa: Move the link check from _mesa_get_uniform_location to _mesa_GetUniformLocationARB
Ian Romanick [Tue, 11 Oct 2011 23:55:54 +0000 (16:55 -0700)]
mesa: Move the link check from _mesa_get_uniform_location to _mesa_GetUniformLocationARB

There are cases where we might want to internally query the location
of a uniform in a shader that failed linking.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Tested-by: Tom Stellard <thomas.stellard@amd.com>
13 years agolinker: Make invalidate_variable_locations available outside the compilation unit
Ian Romanick [Tue, 11 Oct 2011 23:15:47 +0000 (16:15 -0700)]
linker: Make invalidate_variable_locations available outside the compilation unit

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Tested-by: Tom Stellard <thomas.stellard@amd.com>
13 years agoglsl: Allow glsl_types.h to be included in C sources
Ian Romanick [Tue, 11 Oct 2011 23:11:40 +0000 (16:11 -0700)]
glsl: Allow glsl_types.h to be included in C sources

Some C code will want access to the glsl_base_type and
glsl_sampler_dim enums in the near future.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Tested-by: Tom Stellard <thomas.stellard@amd.com>
13 years agomesa: Add string_to_uint_map::clear method to clear the map
Ian Romanick [Tue, 11 Oct 2011 22:25:00 +0000 (15:25 -0700)]
mesa: Add string_to_uint_map::clear method to clear the map

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Tested-by: Tom Stellard <thomas.stellard@amd.com>
13 years agomesa: Fix error generation for glClearBuffer{i ui}v with GL_DEPTH or GL_STENCIL
Ian Romanick [Tue, 1 Nov 2011 22:11:12 +0000 (15:11 -0700)]
mesa: Fix error generation for glClearBuffer{i ui}v with GL_DEPTH or GL_STENCIL

The spec says "Only ClearBufferiv should be used to clear
stencil buffers." and "Only ClearBufferfv should be used to clear
depth buffers."  However, on the following page it also says:

    "The result of ClearBuffer is undefined if no conversion between
    the type of the specified value and the type of the buffer being
    cleared is defined (for example, if ClearBufferiv is called for a
    fixed- or floating-point buffer, or if ClearBufferfv is called
    for a signed or unsigned integer buffer). *This is not an error.*"

Emphasis mine.

Fixes problems with piglit's clearbuffer-invalid-drawbuffer test.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
13 years agomesa: fix the selection of soft renderbuffer color formats
Brian Paul [Sat, 5 Nov 2011 18:59:12 +0000 (12:59 -0600)]
mesa: fix the selection of soft renderbuffer color formats

This fixes a regression from the recent glReadPixels changes found
with the piglit hiz tests.

Use either MESA_FORMAT_RGBA8888 or MESA_FORMAT_RGBA8888_REV for color
buffers depending on endian-ness.  Before, the gl_renderbuffer::Format
field was MESA_FORMAT_RGBA8888 but the data was really stored as
MESA_FORMAT_RGBA8888_REV when using a little endian machine.

Getting this right matters now that we can access renderbuffer data
without going through the span functions (namely glReadPixels() +
MapRenderbuffer()).

13 years agomesa: remove unneeded soft renderbuffer format-setting code
Brian Paul [Sat, 5 Nov 2011 18:54:06 +0000 (12:54 -0600)]
mesa: remove unneeded soft renderbuffer format-setting code

These vars will just get overwritten when we call _mesa_add_renderbuffer()
anyway.  We only need to set the InternalFormat field when we create the
software renderbuffer.

Reviewed-by: Eric Anholt <eric@anholt.net>
13 years agomesa: fix comment typo in intel_renderbuffer
Brian Paul [Sat, 5 Nov 2011 16:48:18 +0000 (10:48 -0600)]
mesa: fix comment typo in intel_renderbuffer

13 years agointel: update intel_texture_image comment
Brian Paul [Sat, 5 Nov 2011 16:48:18 +0000 (10:48 -0600)]
intel: update intel_texture_image comment

13 years agointel: wrap comment and fix typo
Brian Paul [Sat, 5 Nov 2011 16:48:18 +0000 (10:48 -0600)]
intel: wrap comment and fix typo

13 years agost/mesa: first implementation of Map/UnmapRenderbuffer()
Brian Paul [Sat, 5 Nov 2011 16:48:18 +0000 (10:48 -0600)]
st/mesa: first implementation of Map/UnmapRenderbuffer()

Untested, but also unused at this point.

13 years agoxlib: implement renderbuffer mapping/unmapping
Brian Paul [Sat, 5 Nov 2011 16:48:18 +0000 (10:48 -0600)]
xlib: implement renderbuffer mapping/unmapping

This fixes the glReadPixels() regression for reading from the front/back
color buffers.

Note, we only allow one mapping of an XImage/Pixmap renderbuffer
at any time.  That might need to be revisited in the future.

13 years agomesa: check for immutable texture in _mesa_test_texobj_completeness()
Brian Paul [Fri, 4 Nov 2011 01:56:51 +0000 (19:56 -0600)]
mesa: check for immutable texture in _mesa_test_texobj_completeness()

One of the points of GL_ARB_texture_storage is to make it impossible
to have malformed mipmap stacks.  If we know the texture object is
immutable, we can skip a bunch of size checking.

13 years agoswrast: update program type assertion
Brian Paul [Fri, 4 Nov 2011 01:56:51 +0000 (19:56 -0600)]
swrast: update program type assertion

Fixes bogus failed assertion when using NV_fragment_program, such
as with demos/fplight.c

Note: This is a candidate for the 7.11 branch.

13 years agost/mesa: clean-up st_translate_interp()
Brian Paul [Fri, 4 Nov 2011 01:56:51 +0000 (19:56 -0600)]
st/mesa: clean-up st_translate_interp()

13 years agost/mesa: add some null pointer checking to better handle out of memory
Brian Paul [Mon, 7 Nov 2011 19:28:26 +0000 (12:28 -0700)]
st/mesa: add some null pointer checking to better handle out of memory

Reviewed-by: José Fonseca <jfonseca@vmware.com>
13 years agost/mesa: fix memory leaks
Morgan Armand [Mon, 7 Nov 2011 18:38:32 +0000 (19:38 +0100)]
st/mesa: fix memory leaks

Signed-off-by: Brian Paul <brianp@vmware.com>
13 years agost/mesa: fix indentation
Morgan Armand [Mon, 7 Nov 2011 18:38:13 +0000 (19:38 +0100)]
st/mesa: fix indentation

Signed-off-by: Brian Paul <brianp@vmware.com>
13 years agosoftpipe: fix memory leaks
Morgan Armand [Mon, 7 Nov 2011 18:37:48 +0000 (19:37 +0100)]
softpipe: fix memory leaks

This series of patches is a splitted version of my previous one, as suggested by Brian.

Signed-off-by: Brian Paul <brianp@vmware.com>
13 years agoi965: Fix Sandybridge regression introduced by workaround-free math.
Kenneth Graunke [Mon, 7 Nov 2011 20:07:44 +0000 (12:07 -0800)]
i965: Fix Sandybridge regression introduced by workaround-free math.

Commit a73c65c5342bf41fa0dfefe7daa9197ce6a11db4 had a typo which
accidentally enabled the workaround-free Gen7 code on Gen6.

Fixes GPU hangs in anything using pow() or integer division/modulus.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
13 years agoi965: Enable faster workaround-free math on Ivybridge.
Kenneth Graunke [Tue, 18 Oct 2011 19:24:47 +0000 (12:24 -0700)]
i965: Enable faster workaround-free math on Ivybridge.

According to the documentation, Ivybridge's math instruction works in
SIMD16 mode for the fragment shader, and no longer forbids align16 mode
for the vertex shader.

The documentation claims that SIMD16 mode isn't supported for INT DIV,
but empirical evidence shows that it works fine.  Presumably the note
is trying to warn us that the variant that returns both quotient and
remainder in (dst, dst + 1) doesn't work in SIMD16 mode since dst + 1
would be sechalf(dst), trashing half your results.  Since we don't use
that variant, we don't care and can just enable SIMD16 everywhere.

The documentation also still claims that source modifiers and
conditional modifiers aren't supported, but empirical evidence and
study of the simulator both show that they work just fine.

Goodbye workarounds.  Math just works now.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
13 years agomesa: add missing checks to compute_version
Marek Olšák [Fri, 4 Nov 2011 18:12:16 +0000 (19:12 +0100)]
mesa: add missing checks to compute_version

Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
13 years agoradeon: cleanup radeon shared code after r300 and r600 classic drivers removal
Fabio Pedretti [Mon, 7 Nov 2011 09:21:38 +0000 (09:21 +0000)]
radeon: cleanup radeon shared code after r300 and r600 classic drivers removal

Signed-off-by: Dave Airlie <airlied@redhat.com>
13 years agoi965: Fix struct vs class warnings in brw_fs_vector_splitting.cpp.
Kenneth Graunke [Tue, 1 Nov 2011 22:30:52 +0000 (15:30 -0700)]
i965: Fix struct vs class warnings in brw_fs_vector_splitting.cpp.

Makes clang happier.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
13 years agollvmpipe: fix typo in the depth sampling aos code.
Dave Airlie [Sun, 6 Nov 2011 20:55:25 +0000 (20:55 +0000)]
llvmpipe: fix typo in the depth sampling aos code.

Just found by reading llvmpipe code for no great reason.

Signed-off-by: Dave Airlie <airlied@redhat.com>
13 years agollvmpipe: enable RGTC after u_format fix.
Dave Airlie [Sun, 6 Nov 2011 19:33:00 +0000 (19:33 +0000)]
llvmpipe: enable RGTC after u_format fix.

The two piglit tests pass + render correctly.

Signed-off-by: Dave Airlie <airlied@redhat.com>
13 years agou_format: fix RGTC support in fits 8unorm.
Dave Airlie [Sun, 6 Nov 2011 19:32:22 +0000 (19:32 +0000)]
u_format: fix RGTC support in fits 8unorm.

Signed RGTC won't fit in a unorm, so don't allow them.

Signed-off-by: Dave Airlie <airlied@redhat.com>
13 years agoscons: add CPP_SOURCES for nv50/nvc0
Chia-I Wu [Sun, 6 Nov 2011 13:59:47 +0000 (06:59 -0700)]
scons: add CPP_SOURCES for nv50/nvc0

13 years agoandroid: add CPP_SOURCES for nv50/nvc0
Chia-I Wu [Sun, 6 Nov 2011 14:02:04 +0000 (07:02 -0700)]
android: add CPP_SOURCES for nv50/nvc0

13 years agoandroid: reorder nouveau pipe drivers
Chia-I Wu [Sun, 6 Nov 2011 14:43:32 +0000 (07:43 -0700)]
android: reorder nouveau pipe drivers

To match targerts/dri-nouveau, and to fix a potential

  "undefined reference to `nv50_ir::getTargetNVC0(unsigned int)'"

error.

13 years agogl3.txt: update for ARB_texture_storage.
Dave Airlie [Sun, 6 Nov 2011 19:38:50 +0000 (19:38 +0000)]
gl3.txt: update for ARB_texture_storage.

As per Brian's suggestion.

Signed-off-by: Dave Airlie <airlied@redhat.com>
13 years agor600g: add initial linestipple support.
Dave Airlie [Sun, 6 Nov 2011 12:49:21 +0000 (12:49 +0000)]
r600g: add initial linestipple support.

It seems line loop stipple in hardware needs something I don't know, it might
need a proper geometry shader who knows.

Signed-off-by: Dave Airlie <airlied@redhat.com>
13 years agogallivm: change sys::getHostTriple to sys::getDefaultTargetTriple for LLVM >= 0x0301
Christian Inci [Sun, 6 Nov 2011 07:32:54 +0000 (07:32 +0000)]
gallivm: change sys::getHostTriple to sys::getDefaultTargetTriple for LLVM >= 0x0301

LLVM change r143502

Signed-off-by: José Fonseca <jose.r.fonseca@gmail.com>
13 years agog3dvl: Fix memory leaks on error paths.
Vinson Lee [Fri, 4 Nov 2011 04:10:45 +0000 (21:10 -0700)]
g3dvl: Fix memory leaks on error paths.

Fixes Coverity resource leak defect.

Reviewed-by: Brian Paul <brianp@vmware.com>
13 years agopp: Reorder calloc to avoid memory leak on error path.
Vinson Lee [Fri, 4 Nov 2011 03:55:10 +0000 (20:55 -0700)]
pp: Reorder calloc to avoid memory leak on error path.

Fixes Coverity resource leak defect.

Reviewed-by: Brian Paul <brianp@vmware.com>
13 years agor600g: move SPI setup to PS setup
Vadim Girlin [Fri, 4 Nov 2011 17:24:03 +0000 (21:24 +0400)]
r600g: move SPI setup to PS setup

SPI semantic indices for PS/VS are now static, so we don't
need to update spi config for every shaders combination. We can move
the functionality of r600_spi_update to r600(evergreen)_pipe_shader_ps.

Flatshade state is now controlled by the global FLAT_SHADE_ENA flag
instead of updating FLAT_SHADE for all inputs.

Sprite coord still requires the update of spi setup when
sprite_coord_enable is first changed from zero (enabled), and then
only when it's changed to other non-zero value (enabled for other input).
Change to zero (disabling) and back to the same value is handled via
global SPRITE_COORD_ENA.

New field "sprite_coord_enable" added to "struct r600_pipe_shader"
to track current state for the pixel shader. It's checked in the
r600_update_derived_state.

Signed-off-by: Vadim Girlin <vadimgirlin@gmail.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
13 years agor600g: precalculate semantic indices for SPI setup
Vadim Girlin [Sat, 5 Nov 2011 04:48:02 +0000 (08:48 +0400)]
r600g: precalculate semantic indices for SPI setup

There is no need to duplicate semantic mapping which is done in hw, so get
rid of r600_find_vs_semantic_index.

TGSI name/sid pair is mapped to the 8-bit semantic index for SPI.

Signed-off-by: Vadim Girlin <vadimgirlin@gmail.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
13 years agodocs: fix grammar and punctuation in llvmpipe docs.
Matt Turner [Sat, 5 Nov 2011 21:11:59 +0000 (17:11 -0400)]
docs: fix grammar and punctuation in llvmpipe docs.

13 years agogl3.txt: add not of ARB_texture_storage work started.
Dave Airlie [Sat, 5 Nov 2011 17:18:34 +0000 (17:18 +0000)]
gl3.txt: add not of ARB_texture_storage work started.

13 years agodocs: Update llvmpipe docs.
José Fonseca [Sat, 5 Nov 2011 10:38:16 +0000 (10:38 +0000)]
docs: Update llvmpipe docs.

Recommend LLVM 2.9, it has been working quite well, and unlike earlier
versions, it works out-of-the-box without patches.

Update Windows instructions.

13 years agoconfigure.ac: gbm_gallium requires DRI_LIB_DEPS to link
Chia-I Wu [Sat, 5 Nov 2011 07:09:36 +0000 (15:09 +0800)]
configure.ac: gbm_gallium requires DRI_LIB_DEPS to link

gbm_gallium does not depend on DRI, but its build rules depend on DRI_LIB_DEPS
being set.  Output an error when the user enables gbm_gallium but disables
DRI.  This is just a workaround.

13 years agoshared-glapi: fix a linking error for SELinux
Chia-I Wu [Fri, 4 Nov 2011 08:32:17 +0000 (16:32 +0800)]
shared-glapi: fix a linking error for SELinux

Link with -lselinux when SELinux is enabled.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=41571

13 years agoRevert "r600g: precalculate semantic indices for SPI setup"
Alex Deucher [Fri, 4 Nov 2011 22:33:31 +0000 (18:33 -0400)]
Revert "r600g: precalculate semantic indices for SPI setup"

This reverts commit c15f8569fddac5f8aee77863922fd5bb992cfe8a.

This breaks r6xx.

13 years agoRevert "r600g: move SPI setup to PS setup"
Alex Deucher [Fri, 4 Nov 2011 22:32:42 +0000 (18:32 -0400)]
Revert "r600g: move SPI setup to PS setup"

This reverts commit 9804cf3118ae7249098af2a9c78b36f4fb576ee4.

This breaks r6xx.

13 years agosvga: fix varying var remapping for unused FS outputs
Brian Paul [Fri, 4 Nov 2011 20:36:59 +0000 (14:36 -0600)]
svga: fix varying var remapping for unused FS outputs

If the VS has outputs that aren't consumed by the FS we were mapping
them all to one unused VS output index, but that's illegal.  Instead,
map unused VS outputs to unique indexes.

Reviewed-by: José Fonseca <jfonseca@vmware.com>
13 years agosvga: add comments and reformat code in svga_tgsi_decl_sm30.c
Brian Paul [Fri, 4 Nov 2011 19:39:19 +0000 (13:39 -0600)]
svga: add comments and reformat code in svga_tgsi_decl_sm30.c

13 years agost/mesa: set geometry shader to NULL when doing internal drawing
Marek Olšák [Fri, 4 Nov 2011 17:10:16 +0000 (18:10 +0100)]
st/mesa: set geometry shader to NULL when doing internal drawing

The code expects the geometry shader to be NULL.
We don't have geometry shaders now, but it's good to be prepared.

v2: check for support in the cso context

13 years agomesa/st: Be nice with the stack -- use malloc for large structures/arrays.
José Fonseca [Fri, 4 Nov 2011 16:57:09 +0000 (16:57 +0000)]
mesa/st: Be nice with the stack -- use malloc for large structures/arrays.

st_translate_program's data was taking 51K off the stack, causing stack
overflow on Windows.