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 /* Authors: Keith Whitwell <keith@tungstengraphics.com>
34 #include "pipe/p_context.h"
36 #include "draw/draw_vertex.h"
38 #include "lp_quad_pipe.h"
39 #include "lp_tex_sample.h"
43 * This is a temporary variable for testing draw-stage polygon stipple.
44 * If zero, do stipple in lp_quad_stipple.c
46 #define USE_DRAW_STAGE_PSTIPPLE 1
48 /* Number of threads working on individual quads.
49 * Setting to 1 disables this feature.
51 #define SP_NUM_QUAD_THREADS 1
53 struct llvmpipe_vbuf_render
;
56 struct llvmpipe_tile_cache
;
57 struct lp_fragment_shader
;
58 struct lp_vertex_shader
;
61 struct llvmpipe_context
{
62 struct pipe_context pipe
; /**< base class */
64 /** Constant state objects */
65 const struct pipe_blend_state
*blend
;
66 const struct pipe_sampler_state
*sampler
[PIPE_MAX_SAMPLERS
];
67 const struct pipe_depth_stencil_alpha_state
*depth_stencil
;
68 const struct pipe_rasterizer_state
*rasterizer
;
69 const struct lp_fragment_shader
*fs
;
70 const struct lp_vertex_shader
*vs
;
72 /** Other rendering state */
73 struct pipe_blend_color blend_color
;
74 struct pipe_clip_state clip
;
75 struct pipe_constant_buffer constants
[PIPE_SHADER_TYPES
];
76 struct pipe_framebuffer_state framebuffer
;
77 struct pipe_poly_stipple poly_stipple
;
78 struct pipe_scissor_state scissor
;
79 struct pipe_texture
*texture
[PIPE_MAX_SAMPLERS
];
80 struct pipe_viewport_state viewport
;
81 struct pipe_vertex_buffer vertex_buffer
[PIPE_MAX_ATTRIBS
];
82 struct pipe_vertex_element vertex_element
[PIPE_MAX_ATTRIBS
];
84 unsigned num_samplers
;
85 unsigned num_textures
;
86 unsigned num_vertex_elements
;
87 unsigned num_vertex_buffers
;
89 unsigned dirty
; /**< Mask of SP_NEW_x flags */
91 /* Counter for occlusion queries. Note this supports overlapping
94 uint64_t occlusion_count
;
95 unsigned active_query_count
;
97 /** Mapped vertex buffers */
98 ubyte
*mapped_vbuffer
[PIPE_MAX_ATTRIBS
];
100 /** Mapped constant buffers */
101 void *mapped_constants
[PIPE_SHADER_TYPES
];
104 struct vertex_info vertex_info
;
105 struct vertex_info vertex_info_vbuf
;
107 /** Which vertex shader output slot contains point size */
110 unsigned reduced_api_prim
; /**< PIPE_PRIM_POINTS, _LINES or _TRIANGLES */
112 /** Derived from scissor and surface bounds: */
113 struct pipe_scissor_state cliprect
;
115 unsigned line_stipple_counter
;
117 /** Software quad rendering pipeline */
119 struct quad_stage
*polygon_stipple
;
120 struct quad_stage
*earlyz
;
121 struct quad_stage
*shade
;
122 struct quad_stage
*alpha_test
;
123 struct quad_stage
*stencil_test
;
124 struct quad_stage
*depth_test
;
125 struct quad_stage
*occlusion
;
126 struct quad_stage
*coverage
;
127 struct quad_stage
*blend
;
128 struct quad_stage
*colormask
;
129 struct quad_stage
*output
;
131 struct quad_stage
*first
; /**< points to one of the above stages */
132 } quad
[SP_NUM_QUAD_THREADS
];
134 /** TGSI exec things */
136 struct lp_shader_sampler vert_samplers
[PIPE_MAX_SAMPLERS
];
137 struct lp_shader_sampler
*vert_samplers_list
[PIPE_MAX_SAMPLERS
];
138 struct lp_shader_sampler frag_samplers
[PIPE_MAX_SAMPLERS
];
139 struct lp_shader_sampler
*frag_samplers_list
[PIPE_MAX_SAMPLERS
];
142 /** The primitive drawing context */
143 struct draw_context
*draw
;
144 struct draw_stage
*setup
;
145 struct draw_stage
*vbuf
;
146 struct llvmpipe_vbuf_render
*vbuf_render
;
148 boolean dirty_render_cache
;
150 struct llvmpipe_tile_cache
*cbuf_cache
[PIPE_MAX_COLOR_BUFS
];
151 struct llvmpipe_tile_cache
*zsbuf_cache
;
153 struct llvmpipe_tile_cache
*tex_cache
[PIPE_MAX_SAMPLERS
];
155 unsigned use_sse
: 1;
156 unsigned dump_fs
: 1;
157 unsigned no_rast
: 1;
161 static INLINE
struct llvmpipe_context
*
162 llvmpipe_context( struct pipe_context
*pipe
)
164 return (struct llvmpipe_context
*)pipe
;
167 #endif /* SP_CONTEXT_H */