1 /**************************************************************************
3 * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 **************************************************************************/
28 #include "pipe/p_util.h"
29 #include "draw/draw_context.h"
30 #include "draw/draw_vbuf.h"
31 #include "draw/draw_vertex.h"
32 #include "draw/draw_pt.h"
33 #include "draw/draw_vs.h"
34 #include "translate/translate.h"
37 struct fetch_pipeline_middle_end
{
38 struct draw_pt_middle_end base
;
39 struct draw_context
*draw
;
43 unsigned pipeline_vertex_size
;
49 static void fetch_pipeline_prepare( struct draw_pt_middle_end
*middle
,
53 struct fetch_pipeline_middle_end
*fpme
= (struct fetch_pipeline_middle_end
*)middle
;
58 if (!(opt
& PT_PIPELINE
))
59 draw_pt_emit_prepare( fpme
->emit
, prim
, opt
);
61 //fpme->pipeline_vertex_size = sizeof(struct vertex_header) + nr * 4 * sizeof(float);
62 fpme
->pipeline_vertex_size
= MAX_VERTEX_ALLOCATION
;
68 static void fetch_pipeline_run( struct draw_pt_middle_end
*middle
,
69 const unsigned *fetch_elts
,
71 const ushort
*draw_elts
,
74 struct fetch_pipeline_middle_end
*fpme
= (struct fetch_pipeline_middle_end
*)middle
;
75 struct draw_context
*draw
= fpme
->draw
;
76 struct draw_vertex_shader
*shader
= draw
->vertex_shader
;
78 unsigned pipeline
= PT_PIPELINE
;
80 pipeline_verts
= MALLOC(fpme
->pipeline_vertex_size
*
83 if (!pipeline_verts
) {
91 shader
->prepare(shader
, draw
);
93 if (shader
->run(shader
, draw
, fetch_elts
, fetch_count
, pipeline_verts
,
94 fpme
->pipeline_vertex_size
))
96 pipeline
|= PT_CLIPTEST
;
100 /* Do we need to run the pipeline?
102 if (fpme
->opt
& pipeline
) {
103 draw_pt_run_pipeline( fpme
->draw
,
106 fpme
->pipeline_vertex_size
,
111 draw_pt_emit( fpme
->emit
,
113 fpme
->pipeline_vertex_size
,
120 FREE(pipeline_verts
);
125 static void fetch_pipeline_finish( struct draw_pt_middle_end
*middle
)
130 static void fetch_pipeline_destroy( struct draw_pt_middle_end
*middle
)
136 struct draw_pt_middle_end
*draw_pt_fetch_pipeline_or_emit( struct draw_context
*draw
)
138 struct fetch_pipeline_middle_end
*fpme
= CALLOC_STRUCT( fetch_pipeline_middle_end
);
142 fpme
->base
.prepare
= fetch_pipeline_prepare
;
143 fpme
->base
.run
= fetch_pipeline_run
;
144 fpme
->base
.finish
= fetch_pipeline_finish
;
145 fpme
->base
.destroy
= fetch_pipeline_destroy
;
149 fpme
->emit
= draw_pt_emit_create( draw
);
157 fetch_pipeline_destroy( &fpme
->base
);