Kenneth Graunke [Fri, 4 Nov 2011 05:41:37 +0000 (22:41 -0700)]
i965: Rename gen6_*_constants tracked state atoms to "push_constants".
When reading the "brw_wm_constants" and "gen6_wm_constants" atoms
side-by-side, I initially failed to notice the crucial difference:
the Gen6 atoms are for Push Constants, while brw_wm_constants handles
Pull Constants. (Gen4/5 Push Constants are handled by "brw_curbe.")
Renaming these should clarify the code and save me from constant
confusion over the fact that "gen6_wm_constants" isn't just a newer
version of "brw_wm_constants."
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
Kenneth Graunke [Tue, 1 Nov 2011 23:08:03 +0000 (16:08 -0700)]
i965: Remove nr_surfaces computation from brw_update_wm_surfaces.
This code is fairly fragile, as it depends on the ordering of the
entries in the binding table, which will change soon.
Also, stop listening on the BRW_NEW_WM_CONSTBUF dirty bit as it's no
longer required.
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
Kenneth Graunke [Tue, 1 Nov 2011 17:54:08 +0000 (10:54 -0700)]
i965: Use 0 for the number of binding table entries in 3DSTATE_(VS|WM).
These fields control how many entries the hardware prefetches into the
state cache, so they only impact performance, not correctness. However,
it's not clear how to use this in a way that's beneficial.
According to the documentation, kernels "using a large number" of
entries may wish to program this to zero to avoid thrashing the cache;
it's unclear how many is too many. Also, Ironlake's WM was missing this
feature entirely---the count had to be zero.
The dirty bit tracking to handle this complicates the surface state
and binding table setup; removing it should simplify things and make
future refactoring easier. So just set 0 for the number of entries
rather than trying to compute and track it.
Appears to have no impact on Nexuiz and OpenArena on Sandybridge.
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
Kenneth Graunke [Tue, 1 Nov 2011 17:34:27 +0000 (10:34 -0700)]
i965: Remove outdated comment about CACHE_NEW_SURF_BIND dirty bit.
The comment states that brw_update_vs_constant_surface produces a
CACHE_NEW_SURF_BIND dirty bit, but it doesn't. In fact, that bit
no longer even exists.
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
Kenneth Graunke [Tue, 8 Nov 2011 19:32:52 +0000 (11:32 -0800)]
i965: Remove BRW_NEW_NR_VS_SURFACES dirty bit from brw_vs_surfaces.
brw_vs_surfaces _produces_ the BRW_NEW_NR_VS_SURFACES dirty bit, so it
makes no sense for it to subscribe to it.
Fixes an assertion failure in many piglit tests when INTEL_DEBUG is set:
brw_state_upload.c:484: void brw_upload_state(struct brw_context *):
Assertion `!check_state(&examined, &generated)' failed.
One such piglit test is vs-uniform-array-mat2-col-rd.shader_test.
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
Kenneth Graunke [Tue, 8 Nov 2011 19:21:00 +0000 (11:21 -0800)]
i965: Add missing CACHE_NEW_WM_PROG dirty bit to WM pull constants.
Comparing brw_upload_vs_pull_constants and brw_upload_wm_pull_constants,
it became evident that something was amiss: the VS code had both
CACHE_NEW_VS_PROG and BRW_NEW_VERTEX_PROGRAM, while the WM code was
missing the CACHE_NEW_WM_PROG flag.
Not observed to fix anything, but likely necessary.
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
Kenneth Graunke [Tue, 1 Nov 2011 22:41:48 +0000 (15:41 -0700)]
i965: Use new vtable entries for surface state updating functions.
Now that we have vtable entries in place, we should use them. This
allows us to drop the cut and pasted Gen7 brw_tracked_state atoms as
they now do exactly the same thing as their brw_wm_surface_state
counterparts.
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
Kenneth Graunke [Tue, 1 Nov 2011 21:30:26 +0000 (14:30 -0700)]
i965: Add new vtable entries for surface state updating functions.
Gen7+ SURFACE_STATE is different from Gen4-6, so we need separate
per-generation functions for creating and updating it. However, the
usage is the same, and callers just want to utilize the appropriate
functions with minimal pain. So, put them in the vtable.
Since these take a brw_context pointer and are only used on Gen4, just
add a forward declaration. This is the simplest (if not cleanest)
solution. It would be nicer to have a i965-specific vtable, but that's
a refactor for another day.
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
Marek Olšák [Thu, 10 Nov 2011 22:55:49 +0000 (23:55 +0100)]
r600g: don't set the query result to 0 after a call to get_query_result
get_query_result doesn't reset the result. Only begin_query does.
Marek Olšák [Thu, 10 Nov 2011 22:38:31 +0000 (23:38 +0100)]
r600g: the type of OCCLUSION_PREDICATE result should be boolean
Brian Paul [Thu, 10 Nov 2011 22:56:04 +0000 (15:56 -0700)]
mesa: silence uninitialized var warning
Brian Paul [Thu, 10 Nov 2011 22:55:46 +0000 (15:55 -0700)]
radeon: silence initializer warnings
Brian Paul [Thu, 10 Nov 2011 22:55:13 +0000 (15:55 -0700)]
draw/llvm: silence uninitialized variable warnings
Brian Paul [Thu, 10 Nov 2011 22:54:34 +0000 (15:54 -0700)]
radeon: silence unused var warnings
Brian Paul [Thu, 10 Nov 2011 22:54:15 +0000 (15:54 -0700)]
egl: silence unused var warning
Wayne E. Robertz [Thu, 10 Nov 2011 22:21:14 +0000 (15:21 -0700)]
mklib: fix static lib building by filtering out -L, -l options
Signed-off-by: Brian Paul <brianp@vmware.com>
Marek Olšák [Thu, 10 Nov 2011 22:11:57 +0000 (23:11 +0100)]
r600g: implement PIPE_QUERY_OCCLUSION_PREDICATE
Marek Olšák [Thu, 10 Nov 2011 21:58:34 +0000 (22:58 +0100)]
r300g: fix query result of GPU_FINISHED
Marek Olšák [Thu, 10 Nov 2011 21:25:21 +0000 (22:25 +0100)]
r300g: implement PIPE_QUERY_GPU_FINISHED
Marek Olšák [Thu, 10 Nov 2011 20:18:10 +0000 (21:18 +0100)]
r300g: implement PIPE_QUERY_OCCLUSION_PREDICATE
Dave Airlie [Mon, 7 Nov 2011 19:22:01 +0000 (19:22 +0000)]
llvmpipe/u_format: add support for EXT_texture_shared_exponent + EXT_packed_float
These two are fairly unique types so add specific cases for decoding them.
Passes piglit fbo-clear-format and fbo-generatemipmap-format tests for these
two extensions.
Signed-off-by: Dave Airlie <airlied@redhat.com>
Dave Airlie [Mon, 7 Nov 2011 17:31:49 +0000 (17:31 +0000)]
llvmpipe: add NV_conditional_render support.
This ports the softpipe NV_conditional_render support to llvmpipe.
This passes the nv_conditional_render-* piglit tests.
Signed-off-by: Dave Airlie <airlied@redhat.com>
Marek Olšák [Thu, 10 Nov 2011 17:47:20 +0000 (18:47 +0100)]
r600g: remove useless texture barrier
Marek Olšák [Thu, 10 Nov 2011 17:42:10 +0000 (18:42 +0100)]
r600g: flush the whole context when CS is full, not just hw_context
Because we disable render condition in r600_flush, but not in r600_context_flush.
Marek Olšák [Thu, 10 Nov 2011 16:52:36 +0000 (17:52 +0100)]
r600g: turn some CS overflow checks into assertions
They're not really exhaustive and not so useful either.
Marek Olšák [Thu, 10 Nov 2011 16:41:44 +0000 (17:41 +0100)]
r600g: put the rest of CS overflow checks in r600_need_cs_space
Marek Olšák [Thu, 10 Nov 2011 14:54:17 +0000 (15:54 +0100)]
r600g: flush caches regardless of render condition
What if somebody enables render condition just before we flush...
Marek Olšák [Thu, 10 Nov 2011 14:50:06 +0000 (15:50 +0100)]
r600g: disable render condition at the end of CS, re-enable at the beginning
Marek Olšák [Thu, 10 Nov 2011 14:22:34 +0000 (15:22 +0100)]
r600g: don't suspend queries if they have already been suspended by blitter
And add some assertions.
Marek Olšák [Thu, 10 Nov 2011 14:00:11 +0000 (15:00 +0100)]
r600g: properly reserve CS space for queries_suspend
Marek Olšák [Thu, 10 Nov 2011 12:35:22 +0000 (13:35 +0100)]
r600g: reserve CS space for a draw command in begin_query and render_condition
There's no point in emitting those if you can't emit a draw command too.
Marek Olšák [Wed, 9 Nov 2011 00:42:13 +0000 (01:42 +0100)]
r600g: consolidate checking whether CS is full
This adds a new function r600_need_cs_space. Currently, it's easy to overflow
the CS - queries are not counted in. I guess that's not the only case where
the driver may crap out.
Dave Airlie [Thu, 10 Nov 2011 13:47:12 +0000 (13:47 +0000)]
radeon: fix tex1d-border2d
Fixes pigit test with T wrap usage.
Signed-off-by: Dave Airlie <airlied@redhat.com>
Dave Airlie [Mon, 7 Nov 2011 13:46:36 +0000 (13:46 +0000)]
radeon: fix 3-coordinate swtcl emission
This fixes mipmap generation on swtcl rv100.
Signed-off-by: Dave Airlie <airlied@redhat.com>
Eric Anholt [Fri, 4 Nov 2011 00:27:23 +0000 (17:27 -0700)]
swrast: Add support for glReadPixels() to integer types.
With this change, i965 passes
GL_EXT_texture_integer/fbo_integer_precision_clear
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Eric Anholt [Fri, 4 Nov 2011 00:08:16 +0000 (17:08 -0700)]
mesa: Add support for unpacking 32-bit integer formats to int spans.
This is the inverse operation to _mesa_pack_rgba_span_int. The 16-bit
code isn't done because of lack of testing and not being sure how sign
extension/clamping should be handled between, say, 16-bit int and
32-bit int or uint.
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Eric Anholt [Wed, 2 Nov 2011 21:01:25 +0000 (14:01 -0700)]
meta: Add support for glClear() to integer color buffers.
This requires using a new fragment shader to get the integer color
output, and a new vertex shader because #version has to match between
the two.
v2: Clarify that there's no need for BindFragDataLocation.
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> (v1)
Eric Anholt [Wed, 2 Nov 2011 20:51:38 +0000 (13:51 -0700)]
i965: Claim to support rendering to integer FBOs.
We're missing support for the software paths still, but basic
rendering is working.
v2: Override RGB_INT32/UINT32 to not be renderable, since the hardware
can't do it but we do allow texturing from it now. Drop the
DataType override, since the _mesa_problem() isn't in that path
any more.
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> (v1)
Eric Anholt [Wed, 9 Nov 2011 03:27:46 +0000 (19:27 -0800)]
i965/fs: Add support for user-defined out variables.
Before, I was tracking the ir_variable * found for gl_FragColor or
gl_FragData[]. Instead, when visiting those variables, set up an
array of per-render-target fs_regs to copy the output data from. This
cleans up the color emit path, while making handling of multiple
user-defined out variables easier.
v2: incorporate idr's feedback about ir->location (changes by Kenneth Graunke)
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
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>
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>
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)
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>
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>
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>
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>
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().
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>
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>
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>
José Fonseca [Wed, 9 Nov 2011 10:33:21 +0000 (10:33 +0000)]
scons: Disable deprecated POSIX name MSVC warnings.
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.
José Fonseca [Wed, 9 Nov 2011 10:17:02 +0000 (10:17 +0000)]
scons: Don't list m_xform.c twice.
José Fonseca [Wed, 9 Nov 2011 09:08:58 +0000 (09:08 +0000)]
glu: Fix deprecated conversion from string constant to ‘char*’ warning.
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.
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.
Marek Olšák [Tue, 8 Nov 2011 22:05:36 +0000 (23:05 +0100)]
r600g: use modulo for computing index into query (ring) buffers
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.
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.
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>
Brian Paul [Tue, 8 Nov 2011 15:23:16 +0000 (08:23 -0700)]
glsl: remove trailing comma to silence warning
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
Brian Paul [Mon, 7 Nov 2011 23:35:38 +0000 (16:35 -0700)]
mesa: remove prog_uniform.c from SConscript
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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()).
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>
Brian Paul [Sat, 5 Nov 2011 16:48:18 +0000 (10:48 -0600)]
mesa: fix comment typo in intel_renderbuffer
Brian Paul [Sat, 5 Nov 2011 16:48:18 +0000 (10:48 -0600)]
intel: update intel_texture_image comment