/**************************************************************************
*
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * Copyright 2007 VMware, Inc.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
**************************************************************************/
-/* Authors: Keith Whitwell <keith@tungstengraphics.com>
+/* Authors: Keith Whitwell <keithw@vmware.com>
*/
#include "util/u_memory.h"
+#include "util/u_math.h"
+#include "util/u_prim.h"
#include "pipe/p_defines.h"
#include "draw_private.h"
#include "draw_pipe.h"
#include "draw_context.h"
#include "draw_vbuf.h"
-static boolean points( unsigned prim )
-{
- return (prim == PIPE_PRIM_POINTS);
-}
-
-static boolean lines( unsigned prim )
-{
- return (prim == PIPE_PRIM_LINES ||
- prim == PIPE_PRIM_LINE_STRIP ||
- prim == PIPE_PRIM_LINE_LOOP);
-}
-
-static boolean triangles( unsigned prim )
-{
- return prim >= PIPE_PRIM_TRIANGLES;
-}
/**
* Default version of a function to check if we need any special
const struct pipe_rasterizer_state *rasterizer,
unsigned int prim )
{
+ unsigned reduced_prim = u_reduced_prim(prim);
+
/* If the driver has overridden this, use that version:
*/
if (draw->render &&
* and triggering the pipeline, because we have to trigger the
* pipeline *anyway* if unfilled mode is active.
*/
- if (lines(prim))
- {
+ if (reduced_prim == PIPE_PRIM_LINES) {
/* line stipple */
if (rasterizer->line_stipple_enable && draw->pipeline.line_stipple)
return TRUE;
/* wide lines */
- if (rasterizer->line_width > draw->pipeline.wide_line_threshold)
+ if (roundf(rasterizer->line_width) > draw->pipeline.wide_line_threshold)
return TRUE;
/* AA lines */
if (rasterizer->line_smooth && draw->pipeline.aaline)
return TRUE;
- }
- if (points(prim))
- {
+ if (draw_current_shader_num_written_culldistances(draw))
+ return TRUE;
+ }
+ else if (reduced_prim == PIPE_PRIM_POINTS) {
/* large points */
if (rasterizer->point_size > draw->pipeline.wide_point_threshold)
return TRUE;
if (rasterizer->sprite_coord_enable && draw->pipeline.point_sprite)
return TRUE;
}
-
-
- if (triangles(prim))
- {
+ else if (reduced_prim == PIPE_PRIM_TRIANGLES) {
/* polygon stipple */
if (rasterizer->poly_stipple_enable && draw->pipeline.pstipple)
return TRUE;
/* unfilled polygons */
- if (rasterizer->fill_cw != PIPE_POLYGON_MODE_FILL ||
- rasterizer->fill_ccw != PIPE_POLYGON_MODE_FILL)
+ if (rasterizer->fill_front != PIPE_POLYGON_MODE_FILL ||
+ rasterizer->fill_back != PIPE_POLYGON_MODE_FILL)
return TRUE;
/* polygon offset */
- if (rasterizer->offset_cw || rasterizer->offset_ccw)
+ if (rasterizer->offset_point ||
+ rasterizer->offset_line ||
+ rasterizer->offset_tri)
return TRUE;
/* two-side lighting */
if (rasterizer->light_twoside)
return TRUE;
+
+ if (draw_current_shader_num_written_culldistances(draw))
+ return TRUE;
}
/* polygon cull - this is difficult - hardware can cull just fine
*
if (rasterizer->cull_mode)
return TRUE;
- */
+ */
return FALSE;
}
*/
stage->next = next;
- /* drawing wide lines? */
- wide_lines = (rast->line_width > draw->pipeline.wide_line_threshold
- && !rast->line_smooth);
+ /* drawing wide, non-AA lines? */
+ wide_lines = rast->line_width != 1.0f &&
+ roundf(rast->line_width) > draw->pipeline.wide_line_threshold &&
+ !rast->line_smooth;
- /* drawing large points? */
+ /* drawing large/sprite points (but not AA points)? */
if (rast->sprite_coord_enable && draw->pipeline.point_sprite)
wide_points = TRUE;
else if (rast->point_smooth && draw->pipeline.aapoint)
if (rast->line_smooth && draw->pipeline.aaline) {
draw->pipeline.aaline->next = next;
next = draw->pipeline.aaline;
+ precalc_flat = TRUE;
}
if (rast->point_smooth && draw->pipeline.aapoint) {
precalc_flat = TRUE;
}
- if (wide_points || rast->sprite_coord_enable) {
+ if (wide_points) {
draw->pipeline.wide_point->next = next;
next = draw->pipeline.wide_point;
}
next = draw->pipeline.pstipple;
}
- if (rast->fill_cw != PIPE_POLYGON_MODE_FILL ||
- rast->fill_ccw != PIPE_POLYGON_MODE_FILL) {
+ if (rast->fill_front != PIPE_POLYGON_MODE_FILL ||
+ rast->fill_back != PIPE_POLYGON_MODE_FILL) {
draw->pipeline.unfilled->next = next;
next = draw->pipeline.unfilled;
precalc_flat = TRUE; /* only needed for triangles really */
need_det = TRUE;
}
- if (rast->flatshade && precalc_flat) {
+ if (precalc_flat) {
+ /*
+ * could only run the stage if either rast->flatshade is true
+ * or there's constant interpolated values.
+ */
draw->pipeline.flatshade->next = next;
next = draw->pipeline.flatshade;
}
- if (rast->offset_cw ||
- rast->offset_ccw) {
+ if (rast->offset_point ||
+ rast->offset_line ||
+ rast->offset_tri) {
draw->pipeline.offset->next = next;
next = draw->pipeline.offset;
need_det = TRUE;
* to less work emitting vertices, smaller vertex buffers, etc.
* It's difficult to say whether this will be true in general.
*/
- if (need_det || rast->cull_mode) {
+ if (need_det || rast->cull_face != PIPE_FACE_NONE ||
+ draw_current_shader_num_written_culldistances(draw)) {
draw->pipeline.cull->next = next;
next = draw->pipeline.cull;
}
/* Clip stage
*/
- if (!draw->bypass_clipping)
+ if (draw->clip_xy || draw->clip_z || draw->clip_user)
{
draw->pipeline.clip->next = next;
next = draw->pipeline.clip;
}
-
draw->pipeline.first = next;
if (0) {
struct draw_stage *draw_validate_stage( struct draw_context *draw )
{
struct draw_stage *stage = CALLOC_STRUCT(draw_stage);
- if (stage == NULL)
+ if (!stage)
return NULL;
stage->draw = draw;