Commit graph

46627 commits

Author SHA1 Message Date
Kenneth Graunke
0fabf8e8dc glsl: Defer initialization of built-in functions until they're needed.
Very simple shaders don't actually use GLSL built-ins.  For example:
- gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
- gl_FragColor = vec4(0.0);
Both of the shaders used by _mesa_meta_glsl_Clear() also qualify.

By waiting to initialize the built-ins until the first time we need to
look for a signature, we can avoid the overhead entirely in these cases.

Makes piglit run roughly 18% faster (255 vs. 312 seconds).

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
2011-09-23 17:12:47 -07:00
Paul Berry
604173fb1c i965: Increase MaxClipPlanes to 8 for gen6+.
This is necessary for GLSL 1.30 compliance.

Reviewed-by: Eric Anholt <eric@anholt.net>
2011-09-23 15:32:46 -07:00
Paul Berry
2a6d432040 i965: Allow clip distances to be read back in fragment shaders.
Previously, we conditionally set up the SF pipline stage with a
urb_entry_read_offset of 2 when clipping was in use, and 1 otherwise,
causing the clip distance VUE slots to be skipped if present.  This
was an extremely minor savings (it saved the SF unit from reading 2
vec4s out of the URB, but it didn't affect any computation, since we
only instruct the SF unit to perform interpolation on VUE slots that
are actually used by the fragment shader).

GLSL 1.30 requires an interpolated version of gl_ClipDistance to be
available for reading in the fragment shader, so we need the SF's
urb_entry_read_offset to be 1 when the fragment shader reads from
gl_ClipDistance.

This patch just unconditionally sets the urb_entry_read_offset to 1 in
all cases; this is sufficient to make gl_ClipDistance available to the
fragment shader when it is needed, and the performance loss should be
negligible when it isn't.

Reviewed-by: Eric Anholt <eric@anholt.net>
2011-09-23 15:32:42 -07:00
Paul Berry
62bad54727 i965: Set up clip distance VUE slots appropriately for gl_ClipDistance.
When gl_ClipDistance is in use, the contents of the gl_ClipDistance
array just need to be copied directly into the clip distance VUE
slots, so we re-use the code that copies all other generic VUE slots
(this has been extracted to its own method).  When gl_ClipDistance is
not in use, the vertex shader needs to calculate the clip distances
based on user-specified clipping planes.

This patch also removes the i965-specific enum values
BRW_VERT_RESULT_CLIP[01], since we now have generic Mesa enums that
serve the same purpose (VERT_RESULT_CLIP_DIST[01]).

Reviewed-by: Eric Anholt <eric@anholt.net>
2011-09-23 15:32:39 -07:00
Paul Berry
d9cb683f81 i965: Don't upload clip planes when gl_ClipDistance is in use.
When the vertex shader writes to gl_ClipDistance, we do clipping based
on clip distances rather than user clip planes, so don't waste push
constant space storing user clip planes that won't be used.

Reviewed-by: Eric Anholt <eric@anholt.net>
2011-09-23 15:32:37 -07:00
Paul Berry
b9ef2b85b4 i965: Enable lower_clip_distance.
i965 requires gl_ClipDistance to be formatted as an array of 2 vec4's
(as opposed to an array of 8 floats), so enable the lowering pass that
performs this conversion.

Reviewed-by: Eric Anholt <eric@anholt.net>
2011-09-23 15:32:33 -07:00
Paul Berry
2d686fe911 mesa: Decode GL_CLIP_DISTANCE[67] properly in _mesa_set_enable().
In order to support 8 clip distances, we need to properly decode when
the user sets the GL_CLIP_DISTANCE6 and GL_CLIP_DISTANCE7 enable
flags.

For clarity, this patch changes the names GL_CLIP_PLANE[0-5] in the
switch statement to the equivalent names GL_CLIP_DISTANCE[0-5], since
the GL_CLIP_PLANE names are deprecated.

Reviewed-by: Eric Anholt <eric@anholt.net>
Tested-by: Brian Paul <brianp@vmware.com>
2011-09-23 13:30:08 -07:00
Paul Berry
3d7c5a4f6f mesa: set up gl_vert_result and gl_frag_attrib values for gl_ClipDistance.
This patch assigns enumerated values for gl_ClipDistance in the
gl_vert_result and gl_frag_attrib enums, so that driver back-ends can
assign gl_ClipDistance to the appropriate hardware registers.  It also
adjusts the functions _mesa_vert_result_to_frag_attrib() and
_mesa_frag_attrib_to_vert_result() (which translate between the two
enums) to correctly translate the new enumerated values.

Reviewed-by: Eric Anholt <eric@anholt.net>
Tested-by: Brian Paul <brianp@vmware.com>
2011-09-23 13:30:03 -07:00
Paul Berry
1ad54ae0b1 mesa: Add a flag to indicate whether a program uses gl_ClipDistance.
GLSL 1.30 requires us to use gl_ClipDistance for clipping if the
vertex shader contains a static write to it, and otherwise use
user-defined clipping planes.  Since the driver needs to behave
differently in these two cases, we need a flag to record whether the
shader has written to gl_ClipDistance.

The new flag is called UsesClipDistance.  We initially store it in
gl_shader_program (since that is the data structure that is available
when we check to see whethe gl_ClipDistance was written to), and we
later copy it to a flag with the same name in gl_vertex_program, since
that is a more convenient place for the driver to access it (in i965,
at least).

Reviewed-by: Eric Anholt <eric@anholt.net>
Tested-by: Brian Paul <brianp@vmware.com>
2011-09-23 13:28:51 -07:00
Paul Berry
c06e325967 glsl: Implement a lowering pass for gl_ClipDistance.
In i965 GEN6+ (and I suspect most other hardware), gl_ClipDistance
needs to be laid out as a pair of vec4's (the first containing clip
distances 0-3, and the second containing clip distances 4-7).
However, it is declared in GLSL as an array of 8 floats.

This lowering pass acts at the GLSL level, modifying the declaration
of gl_ClipDistance so that it is an array of vec4's rather than an
array of floats, and renaming it to gl_ClipDistanceMESA.  In addition,
it modifies all accesses to the array so that they access the
appropiate component of one of the vec4's.

Since some hardware may not internally represent gl_ClipDistance as a
pair of vec4's, this lowering pass is optional.  To enable it, set the
LowerClipDistance flag in gl_shader_compiler_options to true.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2011-09-23 13:28:43 -07:00
Paul Berry
cc81eb09b9 glsl hierarchical visitor: Do not overwrite base_ir for parameter lists.
This patch fixes a bug in ir_hirearchical_visitor: when traversing an
exec_list representing the formal or actual parameters of a function,
it modified base_ir to point to each parameter in turn, rather than
leaving it as a pointer to the enclosing statement.  This was a
problem, since base_ir is used by visitor classes to locate the
statement containing the node being visited (usually so that
additional statements can be inserted before or after it).  Without
this fix, visitors might attempt to insert statements into parameter
lists.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2011-09-23 13:28:00 -07:00
Chad Versace
deff7fff49 mesa: Add missing includes to meta.h
Include mtypes.h.

Signed-off-by: Chad Versace <chad@chad-versace.us>
2011-09-23 10:54:25 -07:00
Brian Paul
be928ecd8d docs: mention VMware svga driver updates in 7.12 release notes 2011-09-23 08:05:36 -06:00
Brian Paul
ea0cedce6a svga: indentation/formatting fixes 2011-09-23 07:59:21 -06:00
Brian Paul
2c308c66e2 svga: remove emit_consts() offset parameter
It was always zero.
2011-09-23 07:59:00 -06:00
Brian Paul
7c6a5134ba svga: s/int/unsigned/ in svga_state_constants.c
Be consistent with other functions in the file.  And add some comments.
2011-09-23 07:59:00 -06:00
Brian Paul
c27f24f6f0 svga: s/unit/shader/ and related clean-ups
'shader' is more intuitive.  Also s/int/unsigned/ and add assertions.
2011-09-23 07:59:00 -06:00
Brian Paul
5f053bf4ae svga: clean up return values and error codes
Previously we were using a hodge podge of int vs. pipe_enum and
0 vs. PIPE_OK.  Some functions that always returned PIPE_OK were
made void.
2011-09-23 07:59:00 -06:00
Brian Paul
681f92140c svga: add format translation for DXT/sRGB formats
Without this, apps/tests that tried to use a DXT/sRGB format would die on
a failed assertion (st_texture.c:80).
2011-09-23 07:58:48 -06:00
Brian Paul
2b2a69e088 svga: test register W component in emit_kil()
Only the XYZ components are checked to be negative by SVGA3DOP_TEXKILL.
GL_ARB_fp requires all four components be checked.  Emit a second texkill
for W if needed.
2011-09-23 07:58:48 -06:00
Brian Paul
7d09df0cbc svga: fix depth/shadow compare for non-projected texcoords
We only need to do the divide by Q step for TXP instructions.
This fixes the incorrectly rendered soft shadow test in Lightsmark.
Along with the previous texture swizzle commit, this also fixes all
the piglit glsl-fs-shadow2d-XX.shader_test failures.
2011-09-23 07:58:48 -06:00
Brian Paul
9bd15aef86 svga: implement texture swizzling
This exposes the GL_EXT_texture_swizzle extension and allows the various
depth texture modes to be implemented properly.  This, plus a follow-on
texture/shadow change fixes quite a few piglit GLSL shadow sampler test
failures.
2011-09-23 07:58:48 -06:00
Brian Paul
49a6f5e68e svga: check that we don't exceed input/ouput register limits 2011-09-23 07:58:47 -06:00
Brian Paul
2f40e4aac7 svga: implement point sprite suppport
Emit the SVGA3D_RS_POINTSPRITEENABLE render state.
When sprite_coord_mode=PIPE_SPRITE_COORD_LOWER_LEFT emit extra frag
shader code to invert the Y coordinate of the incoming texcoord.
2011-09-23 07:58:47 -06:00
Brian Paul
9a41ecaddd svga: add translation for float formats 2011-09-23 07:58:47 -06:00
Brian Paul
73e840ab7d svga: check to avoid writing beyond end of constant buffer
See bug 688394
2011-09-23 07:58:47 -06:00
José Fonseca
974b6413f4 svga: Cleanup format capability checking.
Accurately describe what operations are supported when a format caps
entry is not advertised by the host, and which formats are never
supported, instead of making ad-hoc and often incorrect assumptions.
2011-09-23 07:58:47 -06:00
José Fonseca
ffeed5da6e svga: Don't use the new depth formats for surfaces that will never be sampled from.
Mitigates issues with hosts where support for these new depth formats is
flaky.
2011-09-23 07:58:46 -06:00
Jakob Bornecrantz
8bf3fb4eca svga: Share one texcoord between depth and fog 2011-09-23 07:58:46 -06:00
Jakob Bornecrantz
4f17830b3d svga: Only emit Z depth work if it is actually read 2011-09-23 07:58:46 -06:00
Jakob Bornecrantz
3b32e51cb1 svga: Fix vPos usage 2011-09-23 07:58:45 -06:00
Jakob Bornecrantz
166e9421c8 svga: Wip for passing depth in a texcoord
TODO: Can we pass this as the same texcoord as fog?
2011-09-23 07:58:45 -06:00
José Fonseca
6759ad53e2 svga: Add a comment about depth format selection. 2011-09-23 07:58:45 -06:00
José Fonseca
846a21d352 svga: Consider the new depth formats in svga_texture_from_handle(). 2011-09-23 07:58:45 -06:00
José Fonseca
f74c04c22c svgadump: Dump the new depth format names. 2011-09-23 07:58:45 -06:00
Jakob Bornecrantz
4e0ae3e34f svga: Expose the new depth formats 2011-09-23 07:58:45 -06:00
José Fonseca
fd69fc8744 svga: Coalesce multiple shader constants in a single command.
HWv8 feature.

Tested with GoogleEarth, Mesa demos.
2011-09-23 07:58:44 -06:00
José Fonseca
157309348e svgadump: Update for svga3d_reg.h header changes. 2011-09-23 07:58:44 -06:00
Brian Paul
2b74fb139c svga: updated svga3d_reg.h to latest public version 2011-09-23 07:58:44 -06:00
Alex Corscadden
2883e3c0b5 Allow RBUG to start blocked
It is sometimes useful to examine the first frame or and early frame of a
quickly executing and non-repeating application, this chain introduces a new
environment variable that is checked when creating contexts.  If
GALLIUM_RBUG_START_BLOCKED is set, then each context that is created is started
in a blocked state.  This allows time to connect rbug before anything is
rendered in the context.
2011-09-23 07:58:44 -06:00
Brian Paul
ddfdea88d8 draw/llvm: add additional null pointer checkin draw_pt_fetch_pipeline_or_emit_llvm() 2011-09-23 07:58:44 -06:00
Yuanhan Liu
1a662e7c18 intel: fix the wrong code to detect null texture.
There is already comments show how to detect a null texture. Fix the
code to match the comments.

This would fix the oglc divzero(basic.texQOrWEqualsZero) and
divzero(basic.texTrivialPrim) test case fail.

Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
2011-09-23 13:34:26 +08:00
Yuanhan Liu
cd6b8421ca i965: fix the constant interp bitmask for flat mode
Fix the constant interpolation enable bit mask for flat light mode.
FRAG_BIT_COL0 attribute bit might be 0, in which case we need to
shift one more bit right.

This would fix the oglc specularColor test fail on both Sandybridge and
Ivybridge.

v2: move the constant interp bitmask setup code into for(; attr <
FRAG_ATTRIB_MAX; attr++) loop suggested by Eric.

Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Signed-off-by: Xiang, Haihao <haihao.xiang@intel.com>
2011-09-23 10:49:42 +08:00
Stéphane Marchesin
e3c94fac4e i915g: Don't generate useless swizzles before texture accesses.
That helps reduce the number of texture indirections, which are very limited on i915.
2011-09-22 19:26:33 -07:00
Stéphane Marchesin
79a0499369 i915g: Fix whitespace. 2011-09-22 19:26:32 -07:00
Marek Olšák
661b853f11 docs: update relnotes-7.12 with r600g changes 2011-09-23 03:03:45 +02:00
Brian Paul
7276ab2c36 st/mesa: remove unnecessary st_texture_match_image() parameters
We didn't use the face parameter and the level parameter can be found
in the gl_texture_image.
2011-09-22 16:43:45 -06:00
Stéphane Marchesin
687e62a5d7 i915g: Fix peephole optimization for MOVs. 2011-09-22 12:43:24 -07:00
Stéphane Marchesin
7cba40306e i915g: Add unsupported PIPE_CAP_MIN_TEXEL_OFFSET/PIPE_CAP_MAX_TEXEL_OFFSET. 2011-09-22 12:01:19 -07:00
Eric Anholt
86939e05d2 intel: Unindent the blit call in PBO blit uploads.
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2011-09-22 11:03:26 -07:00