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"
35 #include "pipe/p_defines.h"
37 #include "draw/draw_vertex.h"
43 * This is a temporary variable for testing draw-stage polygon stipple.
44 * If zero, do stipple in sp_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 softpipe_winsys
;
54 struct softpipe_vbuf_render
;
57 struct softpipe_tile_cache
;
58 struct sp_fragment_shader
;
59 struct sp_vertex_shader
;
62 struct softpipe_context
{
63 struct pipe_context pipe
; /**< base class */
65 /* The most recent drawing state as set by the driver:
67 const struct pipe_blend_state
*blend
;
68 const struct pipe_sampler_state
*sampler
[PIPE_MAX_SAMPLERS
];
69 const struct pipe_depth_stencil_alpha_state
*depth_stencil
;
70 const struct pipe_rasterizer_state
*rasterizer
;
71 const struct sp_fragment_shader
*fs
;
72 const struct sp_vertex_shader
*vs
;
74 struct pipe_blend_color blend_color
;
75 struct pipe_clip_state clip
;
76 struct pipe_constant_buffer constants
[PIPE_SHADER_TYPES
];
77 struct pipe_framebuffer_state framebuffer
;
78 struct pipe_poly_stipple poly_stipple
;
79 struct pipe_scissor_state scissor
;
80 struct pipe_texture
*texture
[PIPE_MAX_SAMPLERS
];
81 struct pipe_viewport_state viewport
;
82 struct pipe_vertex_buffer vertex_buffer
[PIPE_MAX_ATTRIBS
];
83 struct pipe_vertex_element vertex_element
[PIPE_MAX_ATTRIBS
];
86 unsigned num_samplers
;
87 unsigned num_textures
;
88 unsigned num_vertex_elements
;
89 unsigned num_vertex_buffers
;
93 /* Counter for occlusion queries. Note this supports overlapping
96 uint64 occlusion_count
;
99 * Mapped vertex buffers
101 ubyte
*mapped_vbuffer
[PIPE_MAX_ATTRIBS
];
103 /** Mapped constant buffers */
104 void *mapped_constants
[PIPE_SHADER_TYPES
];
107 struct vertex_info vertex_info
;
108 struct vertex_info vertex_info_vbuf
;
112 unsigned reduced_api_prim
; /**< PIPE_PRIM_POINTS, _LINES or _TRIANGLES */
115 /* Stipple derived state:
117 ubyte stipple_masks
[16][16];
120 /** Derived from scissor and surface bounds: */
121 struct pipe_scissor_state cliprect
;
123 unsigned line_stipple_counter
;
125 /** Software quad rendering pipeline */
127 struct quad_stage
*polygon_stipple
;
128 struct quad_stage
*earlyz
;
129 struct quad_stage
*shade
;
130 struct quad_stage
*alpha_test
;
131 struct quad_stage
*stencil_test
;
132 struct quad_stage
*depth_test
;
133 struct quad_stage
*occlusion
;
134 struct quad_stage
*coverage
;
135 struct quad_stage
*blend
;
136 struct quad_stage
*colormask
;
137 struct quad_stage
*output
;
139 struct quad_stage
*first
; /**< points to one of the above stages */
140 } quad
[SP_NUM_QUAD_THREADS
];
142 /** The primitive drawing context */
143 struct draw_context
*draw
;
144 struct draw_stage
*setup
;
145 struct draw_stage
*vbuf
;
146 struct softpipe_vbuf_render
*vbuf_render
;
148 struct softpipe_tile_cache
*cbuf_cache
[PIPE_MAX_COLOR_BUFS
];
149 struct softpipe_tile_cache
*zsbuf_cache
;
151 struct softpipe_tile_cache
*tex_cache
[PIPE_MAX_SAMPLERS
];
158 static INLINE
struct softpipe_context
*
159 softpipe_context( struct pipe_context
*pipe
)
161 return (struct softpipe_context
*)pipe
;
164 #endif /* SP_CONTEXT_H */