p_state.h revision f79c225d9e5adee6287a9bba35f014c3fe00d3f9
1/************************************************************************** 2 * 3 * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. 4 * All Rights Reserved. 5 * 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: 13 * 14 * The above copyright notice and this permission notice (including the 15 * next paragraph) shall be included in all copies or substantial portions 16 * of the Software. 17 * 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. 25 * 26 **************************************************************************/ 27 28 29/** 30 * Abstract graphics pipe state objects. 31 * 32 * Basic notes: 33 * 1. Want compact representations, so we use bitfields. 34 * 2. Put bitfields before other (GLfloat) fields. 35 */ 36 37 38#ifndef PIPE_STATE_H 39#define PIPE_STATE_H 40 41#include "mtypes.h" 42 43 44/** 45 * Primitive (point/line/tri) setup info 46 */ 47struct pipe_setup_state 48{ 49 GLuint flatshade:1; 50 GLuint light_twoside:1; 51 52 GLuint front_winding:2; /**< PIPE_WINDING_x */ 53 54 GLuint cull_mode:2; /**< PIPE_WINDING_x */ 55 56 GLuint fill_cw:2; /**< PIPE_POLYGON_MODE_x */ 57 GLuint fill_ccw:2; /**< PIPE_POLYGON_MODE_x */ 58 59 GLuint offset_cw:1; 60 GLuint offset_ccw:1; 61 62 GLuint scissor:1; 63 GLuint poly_stipple:1; 64 GLuint poly_smooth:1; 65 66 GLfloat offset_units; 67 GLfloat offset_scale; 68}; 69 70struct pipe_poly_stipple { 71 GLuint stipple[32]; 72}; 73 74 75struct pipe_viewport { 76 GLfloat scale[4]; 77 GLfloat translate[4]; 78}; 79 80struct pipe_scissor_rect { 81 GLshort minx; 82 GLshort miny; 83 GLshort maxx; 84 GLshort maxy; 85}; 86 87 88#define PIPE_MAX_CLIP_PLANES 6 89 90struct pipe_clip_state { 91 GLfloat ucp[PIPE_MAX_CLIP_PLANES][4]; 92 GLuint nr; 93}; 94 95struct pipe_fs_state { 96 struct gl_fragment_program *fp; 97}; 98 99#define PIPE_MAX_CONSTANT 32 100 101struct pipe_constant_buffer { 102 GLfloat constant[PIPE_MAX_CONSTANT][4]; 103 GLuint nr_constants; 104}; 105 106 107struct pipe_depth_state 108{ 109 GLuint enabled:1; /**< depth test enabled? */ 110 GLuint writemask:1; /**< allow depth buffer writes? */ 111 GLuint func:3; /**< depth test func (PIPE_FUNC_x) */ 112 GLfloat clear; /**< Clear value in [0,1] (XXX correct place?) */ 113}; 114 115struct pipe_alpha_test_state { 116 GLuint enabled:1; 117 GLuint func:3; /**< PIPE_FUNC_x */ 118 GLfloat ref; /**< reference value */ 119}; 120 121struct pipe_blend_state { 122 GLuint blend_enable:1; 123 124 GLuint rgb_func:3; 125 GLuint rgb_src_factor:5; 126 GLuint rgb_dst_factor:5; 127 128 GLuint alpha_func:3; 129 GLuint alpha_src_factor:5; 130 GLuint alpha_dst_factor:5; 131 132 GLuint logicop_enable:1; 133 GLuint logicop_func:4; 134}; 135 136struct pipe_blend_color { 137 GLfloat color[4]; 138}; 139 140struct pipe_clear_color_state 141{ 142 GLfloat color[4]; 143}; 144 145/** XXXX probably merge into pipe_setup_state */ 146struct pipe_line_state 147{ 148 GLuint smooth:1; 149 GLuint stipple:1; 150 GLushort stipple_pattern; 151 GLint stipple_factor; 152 GLfloat width; 153}; 154 155/** XXXX probably merge into pipe_setup_state */ 156struct pipe_point_state 157{ 158 GLuint smooth:1; 159 GLfloat size; 160 GLfloat min_size, max_size; 161 GLfloat attenuation[3]; 162}; 163 164struct pipe_stencil_state { 165 GLuint front_enabled:1; 166 GLuint front_func:3; /**< PIPE_FUNC_x */ 167 GLuint front_fail_op:3; /**< PIPE_STENCIL_OP_x */ 168 GLuint front_zpass_op:3; /**< PIPE_STENCIL_OP_x */ 169 GLuint front_zfail_op:3; /**< PIPE_STENCIL_OP_x */ 170 GLuint back_enabled:1; 171 GLuint back_func:3; 172 GLuint back_fail_op:3; 173 GLuint back_zpass_op:3; 174 GLuint back_zfail_op:3; 175 GLubyte ref_value[2]; /**< [0] = front, [1] = back */ 176 GLubyte value_mask[2]; 177 GLubyte write_mask[2]; 178 GLubyte clear_value; 179}; 180 181 182/* This will change for hardware pipes... 183 */ 184struct pipe_surface 185{ 186 GLuint width, height; 187 GLubyte *ptr; 188 GLint stride; 189 GLuint cpp; 190 GLuint format; 191}; 192 193 194struct pipe_framebuffer_state 195{ 196 GLuint num_cbufs; /**< Number of color bufs to draw to */ 197 struct pipe_surface *cbufs[4]; /**< OpenGL can write to as many as 198 4 color buffers at once */ 199 struct pipe_surface *zbuf; /**< Z buffer */ 200 struct pipe_surface *sbuf; /**< Stencil buffer */ 201 struct pipe_surface *abuf; /**< Accum buffer */ 202}; 203 204 205/** 206 * Texture sampler state. 207 */ 208struct pipe_sampler_state 209{ 210 GLuint wrap_s:3; /**< PIPE_TEX_WRAP_x */ 211 GLuint wrap_t:3; /**< PIPE_TEX_WRAP_x */ 212 GLuint wrap_r:3; /**< PIPE_TEX_WRAP_x */ 213 GLuint min_filter:3; /**< PIPE_TEX_FILTER_x */ 214 GLuint mag_filter:1; /**< PIPE_TEX_FILTER_LINEAR or _NEAREST */ 215 GLuint compare:1; /**< shadow/depth compare enabled? */ 216 GLenum compare_mode:1; /**< PIPE_TEX_COMPARE_x */ 217 GLenum compare_func:3; /**< PIPE_FUNC_x */ 218 GLfloat shadow_ambient; /**< shadow test fail color/intensity */ 219 GLfloat min_lod; 220 GLfloat max_lod; 221 GLfloat lod_bias; 222#if 0 /* need these? */ 223 GLint BaseLevel; /**< min mipmap level, OpenGL 1.2 */ 224 GLint MaxLevel; /**< max mipmap level, OpenGL 1.2 */ 225#endif 226 GLfloat max_anisotropy; 227}; 228 229#endif 230