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 "pipe/draw/draw_vertex.h"
42 struct softpipe_winsys
;
45 struct softpipe_tile_cache
;
48 #define SP_NEW_VIEWPORT 0x1
49 #define SP_NEW_RASTERIZER 0x2
51 #define SP_NEW_BLEND 0x8
52 #define SP_NEW_CLIP 0x10
53 #define SP_NEW_SCISSOR 0x20
54 #define SP_NEW_STIPPLE 0x40
55 #define SP_NEW_FRAMEBUFFER 0x80
56 #define SP_NEW_ALPHA_TEST 0x100
57 #define SP_NEW_DEPTH_STENCIL 0x200
58 #define SP_NEW_SAMPLER 0x400
59 #define SP_NEW_TEXTURE 0x800
60 #define SP_NEW_VERTEX 0x1000
61 #define SP_NEW_VS 0x2000
62 #define SP_NEW_CONSTANTS 0x4000
64 struct sp_vertex_shader_state
{
65 struct pipe_shader_state
*state
;
69 struct softpipe_context
{
70 struct pipe_context pipe
; /**< base class */
71 struct softpipe_winsys
*winsys
; /**< window system interface */
74 /* The most recent drawing state as set by the driver:
76 const struct pipe_alpha_test_state
*alpha_test
;
77 const struct pipe_blend_state
*blend
;
78 const struct pipe_sampler_state
*sampler
[PIPE_MAX_SAMPLERS
];
79 const struct pipe_depth_stencil_state
*depth_stencil
;
80 const struct pipe_rasterizer_state
*rasterizer
;
81 const struct sp_fragment_shader_state
*fs
;
82 const struct sp_vertex_shader_state
*vs
;
84 struct pipe_blend_color blend_color
;
85 struct pipe_clear_color_state clear_color
;
86 struct pipe_clip_state clip
;
87 struct pipe_constant_buffer constants
[2];
88 struct pipe_feedback_state feedback
;
89 struct pipe_framebuffer_state framebuffer
;
90 struct pipe_poly_stipple poly_stipple
;
91 struct pipe_scissor_state scissor
;
92 struct pipe_mipmap_tree
*texture
[PIPE_MAX_SAMPLERS
];
93 struct pipe_viewport_state viewport
;
94 struct pipe_vertex_buffer vertex_buffer
[PIPE_ATTRIB_MAX
];
95 struct pipe_vertex_element vertex_element
[PIPE_ATTRIB_MAX
];
96 uint sampler_units
[PIPE_MAX_SAMPLERS
];
102 struct pipe_query_object
*queries
[PIPE_QUERY_TYPES
];
105 * Mapped vertex buffers
107 ubyte
*mapped_vbuffer
[PIPE_ATTRIB_MAX
];
109 /** Mapped constant buffers */
110 void *mapped_constants
[PIPE_SHADER_TYPES
];
113 struct vertex_info vertex_info
;
115 unsigned nr_frag_attrs
; /**< number of active fragment attribs */
116 boolean need_z
; /**< produce quad/fragment Z values? */
117 boolean need_w
; /**< produce quad/fragment W values? */
120 /** Feedback buffers */
121 struct pipe_feedback_buffer feedback_buffer
[PIPE_MAX_FEEDBACK_ATTRIBS
];
124 /* Stipple derived state:
126 ubyte stipple_masks
[16][16];
129 /** Derived from scissor and surface bounds: */
130 struct pipe_scissor_state cliprect
;
132 unsigned line_stipple_counter
;
134 /** Software quad rendering pipeline */
136 struct quad_stage
*polygon_stipple
;
137 struct quad_stage
*shade
;
138 struct quad_stage
*alpha_test
;
139 struct quad_stage
*stencil_test
;
140 struct quad_stage
*depth_test
;
141 struct quad_stage
*occlusion
;
142 struct quad_stage
*coverage
;
143 struct quad_stage
*bufloop
;
144 struct quad_stage
*blend
;
145 struct quad_stage
*colormask
;
146 struct quad_stage
*output
;
148 struct quad_stage
*first
; /**< points to one of the above stages */
151 /** The primitive drawing context */
152 struct draw_context
*draw
;
153 struct draw_stage
*setup
;
154 struct draw_stage
*vbuf
;
156 struct pipe_surface
*cbuf
; /**< current color buffer (one of cbufs) */
158 struct softpipe_tile_cache
*cbuf_cache
[PIPE_MAX_COLOR_BUFS
];
159 struct softpipe_tile_cache
*zbuf_cache
;
160 /** Stencil buffer cache, for stencil separate from Z */
161 struct softpipe_tile_cache
*sbuf_cache_sep
;
162 /** This either points to zbuf_cache or sbuf_cache_sep */
163 struct softpipe_tile_cache
*sbuf_cache
;
165 struct softpipe_tile_cache
*tex_cache
[PIPE_MAX_SAMPLERS
];
174 static INLINE
struct softpipe_context
*
175 softpipe_context( struct pipe_context
*pipe
)
177 return (struct softpipe_context
*)pipe
;
181 #endif /* SP_CONTEXT_H */