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_state.h"
35 #include "pipe/p_context.h"
36 #include "pipe/p_defines.h"
38 #include "pipe/draw/draw_vertex.h"
43 struct softpipe_surface
;
44 struct softpipe_winsys
;
49 #define SP_NEW_VIEWPORT 0x1
50 #define SP_NEW_RASTERIZER 0x2
52 #define SP_NEW_BLEND 0x8
53 #define SP_NEW_CLIP 0x10
54 #define SP_NEW_SCISSOR 0x20
55 #define SP_NEW_STIPPLE 0x40
56 #define SP_NEW_FRAMEBUFFER 0x80
57 #define SP_NEW_ALPHA_TEST 0x100
58 #define SP_NEW_DEPTH_STENCIL 0x200
59 #define SP_NEW_SAMPLER 0x400
60 #define SP_NEW_TEXTURE 0x800
61 #define SP_NEW_VERTEX 0x1000
62 #define SP_NEW_VS 0x2000
63 #define SP_NEW_CONSTANTS 0x4000
66 struct softpipe_context
{
67 struct pipe_context pipe
; /**< base class */
68 struct softpipe_winsys
*winsys
; /**< window system interface */
71 /* The most recent drawing state as set by the driver:
73 const struct pipe_blend_state
*blend
;
74 const struct pipe_sampler_state
*sampler
[PIPE_MAX_SAMPLERS
];
75 const struct pipe_depth_stencil_state
*depth_stencil
;
76 const struct pipe_rasterizer_state
*rasterizer
;
77 const struct pipe_shader_state
*fs
;
78 const struct pipe_shader_state
*vs
;
80 struct pipe_alpha_test_state alpha_test
;
81 struct pipe_blend_color blend_color
;
82 struct pipe_clear_color_state clear_color
;
83 struct pipe_clip_state clip
;
84 struct pipe_constant_buffer constants
[2];
85 struct pipe_feedback_state feedback
;
86 struct pipe_framebuffer_state framebuffer
;
87 struct pipe_poly_stipple poly_stipple
;
88 struct pipe_scissor_state scissor
;
89 struct pipe_mipmap_tree
*texture
[PIPE_MAX_SAMPLERS
];
90 struct pipe_viewport_state viewport
;
91 struct pipe_vertex_buffer vertex_buffer
[PIPE_ATTRIB_MAX
];
92 struct pipe_vertex_element vertex_element
[PIPE_ATTRIB_MAX
];
98 struct pipe_query_object
*queries
[PIPE_QUERY_TYPES
];
101 * Mapped vertex buffers
103 ubyte
*mapped_vbuffer
[PIPE_ATTRIB_MAX
];
105 /** Mapped constant buffers */
106 void *mapped_constants
[PIPE_SHADER_TYPES
];
109 struct vertex_info vertex_info
;
111 unsigned nr_frag_attrs
; /**< number of active fragment attribs */
112 boolean need_z
; /**< produce quad/fragment Z values? */
113 boolean need_w
; /**< produce quad/fragment W values? */
116 /** Feedback buffers */
117 struct pipe_feedback_buffer feedback_buffer
[PIPE_MAX_FEEDBACK_ATTRIBS
];
120 /* Stipple derived state:
122 ubyte stipple_masks
[16][16];
125 /** Derived from scissor and surface bounds: */
126 struct pipe_scissor_state cliprect
;
128 unsigned line_stipple_counter
;
130 /** Software quad rendering pipeline */
132 struct quad_stage
*polygon_stipple
;
133 struct quad_stage
*shade
;
134 struct quad_stage
*alpha_test
;
135 struct quad_stage
*stencil_test
;
136 struct quad_stage
*depth_test
;
137 struct quad_stage
*occlusion
;
138 struct quad_stage
*coverage
;
139 struct quad_stage
*bufloop
;
140 struct quad_stage
*blend
;
141 struct quad_stage
*colormask
;
142 struct quad_stage
*output
;
144 struct quad_stage
*first
; /**< points to one of the above stages */
147 /** The primitive drawing context */
148 struct draw_context
*draw
;
150 struct pipe_surface
*cbuf
; /**< current color buffer (one of cbufs) */
156 static INLINE
struct softpipe_context
*
157 softpipe_context( struct pipe_context
*pipe
)
159 return (struct softpipe_context
*)pipe
;
163 #endif /* SP_CONTEXT_H */