@@ -16,6 +16,7 @@ C_SOURCES = \ | |||
draw_pipe_stipple.c \ | |||
draw_pipe_twoside.c \ | |||
draw_pipe_unfilled.c \ | |||
draw_pipe_util.c \ | |||
draw_pipe_validate.c \ | |||
draw_pipe_vbuf.c \ | |||
draw_pipe_wide_line.c \ |
@@ -15,6 +15,7 @@ draw = env.ConvenienceLibrary( | |||
'draw_pipe_stipple.c', | |||
'draw_pipe_twoside.c', | |||
'draw_pipe_unfilled.c', | |||
'draw_pipe_util.c', | |||
'draw_pipe_validate.c', | |||
'draw_pipe_vbuf.c', | |||
'draw_pipe_wide_line.c', |
@@ -108,40 +108,6 @@ void draw_pipeline_destroy( struct draw_context *draw ) | |||
/* This is only used for temporary verts. | |||
*/ | |||
#define MAX_VERTEX_SIZE ((2 + PIPE_MAX_SHADER_OUTPUTS) * 4 * sizeof(float)) | |||
/** | |||
* Allocate space for temporary post-transform vertices, such as for clipping. | |||
*/ | |||
void draw_alloc_temp_verts( struct draw_stage *stage, unsigned nr ) | |||
{ | |||
assert(!stage->tmp); | |||
stage->nr_tmps = nr; | |||
if (nr) { | |||
ubyte *store = (ubyte *) MALLOC( MAX_VERTEX_SIZE * nr ); | |||
unsigned i; | |||
stage->tmp = (struct vertex_header **) MALLOC( sizeof(struct vertex_header *) * nr ); | |||
for (i = 0; i < nr; i++) | |||
stage->tmp[i] = (struct vertex_header *)(store + i * MAX_VERTEX_SIZE); | |||
} | |||
} | |||
void draw_free_temp_verts( struct draw_stage *stage ) | |||
{ | |||
if (stage->tmp) { | |||
FREE( stage->tmp[0] ); | |||
FREE( stage->tmp ); | |||
stage->tmp = NULL; | |||
} | |||
} | |||
@@ -195,35 +161,6 @@ static void do_triangle( struct draw_context *draw, | |||
} | |||
/* Reset vertex ids. This is basically a type of flush. | |||
* | |||
* Called only from draw_pipe_vbuf.c | |||
*/ | |||
void draw_reset_vertex_ids(struct draw_context *draw) | |||
{ | |||
struct draw_stage *stage = draw->pipeline.first; | |||
while (stage) { | |||
unsigned i; | |||
for (i = 0; i < stage->nr_tmps; i++) | |||
stage->tmp[i]->vertex_id = UNDEFINED_VERTEX_ID; | |||
stage = stage->next; | |||
} | |||
if (draw->pipeline.verts) | |||
{ | |||
unsigned i; | |||
char *verts = draw->pipeline.verts; | |||
unsigned stride = draw->pipeline.vertex_stride; | |||
for (i = 0; i < draw->pipeline.vertex_count; i++) { | |||
((struct vertex_header *)verts)->vertex_id = UNDEFINED_VERTEX_ID; | |||
verts += stride; | |||
} | |||
} | |||
} | |||
/* Code to run the pipeline on a fairly arbitary collection of vertices. |
@@ -81,10 +81,14 @@ extern struct draw_stage *draw_validate_stage( struct draw_context *context ); | |||
extern void draw_free_temp_verts( struct draw_stage *stage ); | |||
extern void draw_alloc_temp_verts( struct draw_stage *stage, unsigned nr ); | |||
extern boolean draw_alloc_temp_verts( struct draw_stage *stage, unsigned nr ); | |||
extern void draw_reset_vertex_ids( struct draw_context *draw ); | |||
void draw_pipe_passthrough_tri(struct draw_stage *stage, struct prim_header *header); | |||
void draw_pipe_passthrough_line(struct draw_stage *stage, struct prim_header *header); | |||
void draw_pipe_passthrough_point(struct draw_stage *stage, struct prim_header *header); | |||
/** |
@@ -334,7 +334,7 @@ aa_transform_inst(struct tgsi_transform_context *ctx, | |||
* Generate the frag shader we'll use for drawing AA lines. | |||
* This will be the user's shader plus some texture/modulate instructions. | |||
*/ | |||
static void | |||
static boolean | |||
generate_aaline_fs(struct aaline_stage *aaline) | |||
{ | |||
const struct pipe_shader_state *orig_fs = &aaline->fs->state; | |||
@@ -346,6 +346,8 @@ generate_aaline_fs(struct aaline_stage *aaline) | |||
aaline_fs = *orig_fs; /* copy to init */ | |||
aaline_fs.tokens = MALLOC(sizeof(struct tgsi_token) * MAX); | |||
if (aaline_fs.tokens == NULL) | |||
return FALSE; | |||
memset(&transform, 0, sizeof(transform)); | |||
transform.colorOutput = -1; | |||
@@ -372,6 +374,7 @@ generate_aaline_fs(struct aaline_stage *aaline) | |||
= aaline->driver_create_fs_state(aaline->pipe, &aaline_fs); | |||
aaline->fs->generic_attrib = transform.maxGeneric + 1; | |||
return TRUE; | |||
} | |||
@@ -469,13 +472,15 @@ aaline_create_sampler(struct aaline_stage *aaline) | |||
* When we're about to draw our first AA line in a batch, this function is | |||
* called to tell the driver to bind our modified fragment shader. | |||
*/ | |||
static void | |||
static boolean | |||
bind_aaline_fragment_shader(struct aaline_stage *aaline) | |||
{ | |||
if (!aaline->fs->aaline_fs) { | |||
generate_aaline_fs(aaline); | |||
} | |||
if (!aaline->fs->aaline_fs && | |||
!generate_aaline_fs(aaline)) | |||
return FALSE; | |||
aaline->driver_bind_fs_state(aaline->pipe, aaline->fs->aaline_fs); | |||
return TRUE; | |||
} | |||
@@ -487,20 +492,6 @@ aaline_stage( struct draw_stage *stage ) | |||
} | |||
static void | |||
passthrough_point(struct draw_stage *stage, struct prim_header *header) | |||
{ | |||
stage->next->point(stage->next, header); | |||
} | |||
static void | |||
passthrough_tri(struct draw_stage *stage, struct prim_header *header) | |||
{ | |||
stage->next->tri(stage->next, header); | |||
} | |||
/** | |||
* Draw a wide line by drawing a quad, using geometry which will | |||
* fullfill GL's antialiased line requirements. | |||
@@ -638,7 +629,10 @@ aaline_first_line(struct draw_stage *stage, struct prim_header *header) | |||
/* | |||
* Bind (generate) our fragprog, sampler and texture | |||
*/ | |||
bind_aaline_fragment_shader(aaline); | |||
if (!bind_aaline_fragment_shader(aaline)) { | |||
stage->line = draw_pipe_passthrough_line; | |||
return; | |||
} | |||
/* update vertex attrib info */ | |||
aaline->tex_slot = draw->num_vs_outputs; | |||
@@ -721,9 +715,9 @@ draw_aaline_stage(struct draw_context *draw) | |||
aaline->stage.draw = draw; | |||
aaline->stage.next = NULL; | |||
aaline->stage.point = passthrough_point; | |||
aaline->stage.point = draw_pipe_passthrough_point; | |||
aaline->stage.line = aaline_first_line; | |||
aaline->stage.tri = passthrough_tri; | |||
aaline->stage.tri = draw_pipe_passthrough_tri; | |||
aaline->stage.flush = aaline_flush; | |||
aaline->stage.reset_stipple_counter = aaline_reset_stipple_counter; | |||
aaline->stage.destroy = aaline_destroy; |
@@ -546,18 +546,6 @@ aapoint_stage( struct draw_stage *stage ) | |||
} | |||
static void | |||
passthrough_line(struct draw_stage *stage, struct prim_header *header) | |||
{ | |||
stage->next->line(stage->next, header); | |||
} | |||
static void | |||
passthrough_tri(struct draw_stage *stage, struct prim_header *header) | |||
{ | |||
stage->next->tri(stage->next, header); | |||
} | |||
/** | |||
@@ -749,8 +737,8 @@ draw_aapoint_stage(struct draw_context *draw) | |||
aapoint->stage.draw = draw; | |||
aapoint->stage.next = NULL; | |||
aapoint->stage.point = aapoint_first_point; | |||
aapoint->stage.line = passthrough_line; | |||
aapoint->stage.tri = passthrough_tri; | |||
aapoint->stage.line = draw_pipe_passthrough_line; | |||
aapoint->stage.tri = draw_pipe_passthrough_tri; | |||
aapoint->stage.flush = aapoint_flush; | |||
aapoint->stage.reset_stipple_counter = aapoint_reset_stipple_counter; | |||
aapoint->stage.destroy = aapoint_destroy; |
@@ -95,20 +95,6 @@ static void cull_first_tri( struct draw_stage *stage, | |||
static void cull_line( struct draw_stage *stage, | |||
struct prim_header *header ) | |||
{ | |||
stage->next->line( stage->next, header ); | |||
} | |||
static void cull_point( struct draw_stage *stage, | |||
struct prim_header *header ) | |||
{ | |||
stage->next->point( stage->next, header ); | |||
} | |||
static void cull_flush( struct draw_stage *stage, unsigned flags ) | |||
{ | |||
stage->tri = cull_first_tri; | |||
@@ -139,8 +125,8 @@ struct draw_stage *draw_cull_stage( struct draw_context *draw ) | |||
cull->stage.draw = draw; | |||
cull->stage.next = NULL; | |||
cull->stage.point = cull_point; | |||
cull->stage.line = cull_line; | |||
cull->stage.point = draw_pipe_passthrough_point; | |||
cull->stage.line = draw_pipe_passthrough_line; | |||
cull->stage.tri = cull_first_tri; | |||
cull->stage.flush = cull_flush; | |||
cull->stage.reset_stipple_counter = cull_reset_stipple_counter; |
@@ -152,13 +152,6 @@ static void flatshade_line_1( struct draw_stage *stage, | |||
} | |||
/* Flatshade point -- passthrough. | |||
*/ | |||
static void flatshade_point( struct draw_stage *stage, | |||
struct prim_header *header ) | |||
{ | |||
stage->next->point( stage->next, header ); | |||
} | |||
static void flatshade_init_state( struct draw_stage *stage ) | |||
@@ -236,7 +229,7 @@ struct draw_stage *draw_flatshade_stage( struct draw_context *draw ) | |||
flatshade->stage.draw = draw; | |||
flatshade->stage.next = NULL; | |||
flatshade->stage.point = flatshade_point; | |||
flatshade->stage.point = draw_pipe_passthrough_point; | |||
flatshade->stage.line = flatshade_first_line; | |||
flatshade->stage.tri = flatshade_first_tri; | |||
flatshade->stage.flush = flatshade_flush; |
@@ -129,18 +129,6 @@ static void offset_first_tri( struct draw_stage *stage, | |||
} | |||
static void offset_line( struct draw_stage *stage, | |||
struct prim_header *header ) | |||
{ | |||
stage->next->line( stage->next, header ); | |||
} | |||
static void offset_point( struct draw_stage *stage, | |||
struct prim_header *header ) | |||
{ | |||
stage->next->point( stage->next, header ); | |||
} | |||
static void offset_flush( struct draw_stage *stage, | |||
@@ -175,8 +163,8 @@ struct draw_stage *draw_offset_stage( struct draw_context *draw ) | |||
offset->stage.draw = draw; | |||
offset->stage.next = NULL; | |||
offset->stage.point = offset_point; | |||
offset->stage.line = offset_line; | |||
offset->stage.point = draw_pipe_passthrough_point; | |||
offset->stage.line = draw_pipe_passthrough_line; | |||
offset->stage.tri = offset_first_tri; | |||
offset->stage.flush = offset_flush; | |||
offset->stage.reset_stipple_counter = offset_reset_stipple_counter; |
@@ -473,25 +473,6 @@ pstip_stage( struct draw_stage *stage ) | |||
} | |||
static void | |||
passthrough_point(struct draw_stage *stage, struct prim_header *header) | |||
{ | |||
stage->next->point(stage->next, header); | |||
} | |||
static void | |||
passthrough_line(struct draw_stage *stage, struct prim_header *header) | |||
{ | |||
stage->next->line(stage->next, header); | |||
} | |||
static void | |||
passthrough_tri(struct draw_stage *stage, struct prim_header *header) | |||
{ | |||
stage->next->tri(stage->next, header); | |||
} | |||
@@ -523,7 +504,7 @@ pstip_first_tri(struct draw_stage *stage, struct prim_header *header) | |||
pstip->driver_set_sampler_textures(pipe, num_samplers, pstip->state.textures); | |||
/* now really draw first line */ | |||
stage->tri = passthrough_tri; | |||
stage->tri = draw_pipe_passthrough_tri; | |||
stage->tri(stage, header); | |||
} | |||
@@ -579,8 +560,8 @@ draw_pstip_stage(struct draw_context *draw) | |||
pstip->stage.draw = draw; | |||
pstip->stage.next = NULL; | |||
pstip->stage.point = passthrough_point; | |||
pstip->stage.line = passthrough_line; | |||
pstip->stage.point = draw_pipe_passthrough_point; | |||
pstip->stage.line = draw_pipe_passthrough_line; | |||
pstip->stage.tri = pstip_first_tri; | |||
pstip->stage.flush = pstip_flush; | |||
pstip->stage.reset_stipple_counter = pstip_reset_stipple_counter; |
@@ -195,18 +195,6 @@ stipple_flush(struct draw_stage *stage, unsigned flags) | |||
} | |||
static void | |||
passthrough_point(struct draw_stage *stage, struct prim_header *header) | |||
{ | |||
stage->next->point( stage->next, header ); | |||
} | |||
static void | |||
passthrough_tri(struct draw_stage *stage, struct prim_header *header) | |||
{ | |||
stage->next->tri(stage->next, header); | |||
} | |||
static void | |||
@@ -228,9 +216,9 @@ struct draw_stage *draw_stipple_stage( struct draw_context *draw ) | |||
stipple->stage.draw = draw; | |||
stipple->stage.next = NULL; | |||
stipple->stage.point = passthrough_point; | |||
stipple->stage.point = draw_pipe_passthrough_point; | |||
stipple->stage.line = stipple_first_line; | |||
stipple->stage.tri = passthrough_tri; | |||
stipple->stage.tri = draw_pipe_passthrough_tri; | |||
stipple->stage.reset_stipple_counter = reset_stipple_counter; | |||
stipple->stage.flush = stipple_flush; | |||
stipple->stage.destroy = stipple_destroy; |
@@ -99,21 +99,6 @@ static void twoside_tri( struct draw_stage *stage, | |||
} | |||
static void twoside_line( struct draw_stage *stage, | |||
struct prim_header *header ) | |||
{ | |||
/* pass-through */ | |||
stage->next->line( stage->next, header ); | |||
} | |||
static void twoside_point( struct draw_stage *stage, | |||
struct prim_header *header ) | |||
{ | |||
/* pass-through */ | |||
stage->next->point( stage->next, header ); | |||
} | |||
static void twoside_first_tri( struct draw_stage *stage, | |||
struct prim_header *header ) | |||
@@ -192,8 +177,8 @@ struct draw_stage *draw_twoside_stage( struct draw_context *draw ) | |||
twoside->stage.draw = draw; | |||
twoside->stage.next = NULL; | |||
twoside->stage.point = twoside_point; | |||
twoside->stage.line = twoside_line; | |||
twoside->stage.point = draw_pipe_passthrough_point; | |||
twoside->stage.line = draw_pipe_passthrough_line; | |||
twoside->stage.tri = twoside_first_tri; | |||
twoside->stage.flush = twoside_flush; | |||
twoside->stage.reset_stipple_counter = twoside_reset_stipple_counter; |
@@ -148,19 +148,6 @@ static void unfilled_first_tri( struct draw_stage *stage, | |||
} | |||
static void unfilled_line( struct draw_stage *stage, | |||
struct prim_header *header ) | |||
{ | |||
stage->next->line( stage->next, header ); | |||
} | |||
static void unfilled_point( struct draw_stage *stage, | |||
struct prim_header *header ) | |||
{ | |||
stage->next->point( stage->next, header ); | |||
} | |||
static void unfilled_flush( struct draw_stage *stage, | |||
unsigned flags ) | |||
@@ -196,8 +183,8 @@ struct draw_stage *draw_unfilled_stage( struct draw_context *draw ) | |||
unfilled->stage.draw = draw; | |||
unfilled->stage.next = NULL; | |||
unfilled->stage.tmp = NULL; | |||
unfilled->stage.point = unfilled_point; | |||
unfilled->stage.line = unfilled_line; | |||
unfilled->stage.point = draw_pipe_passthrough_point; | |||
unfilled->stage.line = draw_pipe_passthrough_line; | |||
unfilled->stage.tri = unfilled_first_tri; | |||
unfilled->stage.flush = unfilled_flush; | |||
unfilled->stage.reset_stipple_counter = unfilled_reset_stipple_counter; |
@@ -0,0 +1,133 @@ | |||
/************************************************************************** | |||
* | |||
* Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. | |||
* All Rights Reserved. | |||
* | |||
* Permission is hereby granted, free of charge, to any person obtaining a | |||
* copy of this software and associated documentation files (the | |||
* "Software"), to deal in the Software without restriction, including | |||
* without limitation the rights to use, copy, modify, merge, publish, | |||
* distribute, sub license, and/or sell copies of the Software, and to | |||
* permit persons to whom the Software is furnished to do so, subject to | |||
* the following conditions: | |||
* | |||
* The above copyright notice and this permission notice (including the | |||
* next paragraph) shall be included in all copies or substantial portions | |||
* of the Software. | |||
* | |||
* 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 | |||
* 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> | |||
*/ | |||
#include "pipe/p_util.h" | |||
#include "draw/draw_private.h" | |||
#include "draw/draw_pipe.h" | |||
void | |||
draw_pipe_passthrough_point(struct draw_stage *stage, struct prim_header *header) | |||
{ | |||
stage->next->point(stage->next, header); | |||
} | |||
void | |||
draw_pipe_passthrough_line(struct draw_stage *stage, struct prim_header *header) | |||
{ | |||
stage->next->line(stage->next, header); | |||
} | |||
void | |||
draw_pipe_passthrough_tri(struct draw_stage *stage, struct prim_header *header) | |||
{ | |||
stage->next->tri(stage->next, header); | |||
} | |||
/* This is only used for temporary verts. | |||
*/ | |||
#define MAX_VERTEX_SIZE ((2 + PIPE_MAX_SHADER_OUTPUTS) * 4 * sizeof(float)) | |||
/** | |||
* Allocate space for temporary post-transform vertices, such as for clipping. | |||
*/ | |||
boolean draw_alloc_temp_verts( struct draw_stage *stage, unsigned nr ) | |||
{ | |||
unsigned i; | |||
ubyte *store; | |||
assert(!stage->tmp); | |||
stage->tmp = NULL; | |||
stage->nr_tmps = nr; | |||
if (nr == 0) | |||
return FALSE; | |||
store = (ubyte *) MALLOC( MAX_VERTEX_SIZE * nr ); | |||
if (store == NULL) | |||
return FALSE; | |||
stage->tmp = (struct vertex_header **) MALLOC( sizeof(struct vertex_header *) * nr ); | |||
for (i = 0; i < nr; i++) | |||
stage->tmp[i] = (struct vertex_header *)(store + i * MAX_VERTEX_SIZE); | |||
return TRUE; | |||
} | |||
void draw_free_temp_verts( struct draw_stage *stage ) | |||
{ | |||
if (stage->tmp) { | |||
FREE( stage->tmp[0] ); | |||
FREE( stage->tmp ); | |||
stage->tmp = NULL; | |||
} | |||
} | |||
/* Reset vertex ids. This is basically a type of flush. | |||
* | |||
* Called only from draw_pipe_vbuf.c | |||
*/ | |||
void draw_reset_vertex_ids(struct draw_context *draw) | |||
{ | |||
struct draw_stage *stage = draw->pipeline.first; | |||
while (stage) { | |||
unsigned i; | |||
for (i = 0; i < stage->nr_tmps; i++) | |||
stage->tmp[i]->vertex_id = UNDEFINED_VERTEX_ID; | |||
stage = stage->next; | |||
} | |||
if (draw->pipeline.verts) | |||
{ | |||
unsigned i; | |||
char *verts = draw->pipeline.verts; | |||
unsigned stride = draw->pipeline.vertex_stride; | |||
for (i = 0; i < draw->pipeline.vertex_count; i++) { | |||
((struct vertex_header *)verts)->vertex_id = UNDEFINED_VERTEX_ID; | |||
verts += stride; | |||
} | |||
} | |||
} | |||
@@ -49,19 +49,6 @@ static INLINE struct wideline_stage *wideline_stage( struct draw_stage *stage ) | |||
} | |||
static void wideline_point( struct draw_stage *stage, | |||
struct prim_header *header ) | |||
{ | |||
stage->next->point( stage->next, header ); | |||
} | |||
static void wideline_tri( struct draw_stage *stage, | |||
struct prim_header *header ) | |||
{ | |||
stage->next->tri(stage->next, header); | |||
} | |||
/** | |||
* Draw a wide line by drawing a quad (two triangles). | |||
@@ -180,9 +167,9 @@ struct draw_stage *draw_wide_line_stage( struct draw_context *draw ) | |||
wide->stage.draw = draw; | |||
wide->stage.next = NULL; | |||
wide->stage.point = wideline_point; | |||
wide->stage.point = draw_pipe_passthrough_point; | |||
wide->stage.line = wideline_line; | |||
wide->stage.tri = wideline_tri; | |||
wide->stage.tri = draw_pipe_passthrough_point; | |||
wide->stage.flush = wideline_flush; | |||
wide->stage.reset_stipple_counter = wideline_reset_stipple_counter; | |||
wide->stage.destroy = wideline_destroy; |
@@ -61,23 +61,6 @@ widepoint_stage( struct draw_stage *stage ) | |||
} | |||
static void passthrough_point( struct draw_stage *stage, | |||
struct prim_header *header ) | |||
{ | |||
stage->next->point( stage->next, header ); | |||
} | |||
static void widepoint_line( struct draw_stage *stage, | |||
struct prim_header *header ) | |||
{ | |||
stage->next->line(stage->next, header); | |||
} | |||
static void widepoint_tri( struct draw_stage *stage, | |||
struct prim_header *header ) | |||
{ | |||
stage->next->tri(stage->next, header); | |||
} | |||
/** | |||
@@ -209,7 +192,7 @@ static void widepoint_first_point( struct draw_stage *stage, | |||
stage->point = widepoint_point; | |||
} | |||
else { | |||
stage->point = passthrough_point; | |||
stage->point = draw_pipe_passthrough_point; | |||
} | |||
if (draw->rasterizer->point_sprite) { | |||
@@ -272,8 +255,8 @@ struct draw_stage *draw_wide_point_stage( struct draw_context *draw ) | |||
wide->stage.draw = draw; | |||
wide->stage.next = NULL; | |||
wide->stage.point = widepoint_first_point; | |||
wide->stage.line = widepoint_line; | |||
wide->stage.tri = widepoint_tri; | |||
wide->stage.line = draw_pipe_passthrough_line; | |||
wide->stage.tri = draw_pipe_passthrough_tri; | |||
wide->stage.flush = widepoint_flush; | |||
wide->stage.reset_stipple_counter = widepoint_reset_stipple_counter; | |||
wide->stage.destroy = widepoint_destroy; |