p_state.h revision a1fa770c01d913658900de1c267fb4c41bc6300d
18e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell/************************************************************************** 28e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell * 38e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. 48e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell * All Rights Reserved. 58e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell * 68e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell * Permission is hereby granted, free of charge, to any person obtaining a 78e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell * copy of this software and associated documentation files (the 88e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell * "Software"), to deal in the Software without restriction, including 98e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell * without limitation the rights to use, copy, modify, merge, publish, 108e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell * distribute, sub license, and/or sell copies of the Software, and to 118e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell * permit persons to whom the Software is furnished to do so, subject to 128e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell * the following conditions: 138e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell * 148e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell * The above copyright notice and this permission notice (including the 158e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell * next paragraph) shall be included in all copies or substantial portions 168e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell * of the Software. 178e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell * 188e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 198e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 208e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 218e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR 228e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 238e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 248e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 258e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell * 268e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell **************************************************************************/ 278e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell 28f79c225d9e5adee6287a9bba35f014c3fe00d3f9Brian 29f79c225d9e5adee6287a9bba35f014c3fe00d3f9Brian/** 30984a7c4e9c42cf8ddfcff5b880b522a6dd58bce2José Fonseca * @file 31984a7c4e9c42cf8ddfcff5b880b522a6dd58bce2José Fonseca * 32f79c225d9e5adee6287a9bba35f014c3fe00d3f9Brian * Abstract graphics pipe state objects. 33f79c225d9e5adee6287a9bba35f014c3fe00d3f9Brian * 34f79c225d9e5adee6287a9bba35f014c3fe00d3f9Brian * Basic notes: 35f79c225d9e5adee6287a9bba35f014c3fe00d3f9Brian * 1. Want compact representations, so we use bitfields. 36f79c225d9e5adee6287a9bba35f014c3fe00d3f9Brian * 2. Put bitfields before other (GLfloat) fields. 37f79c225d9e5adee6287a9bba35f014c3fe00d3f9Brian */ 38f79c225d9e5adee6287a9bba35f014c3fe00d3f9Brian 39f79c225d9e5adee6287a9bba35f014c3fe00d3f9Brian 40943964a1e5bad86bdceb0a06d60fb3b302ebce6aKeith Whitwell#ifndef PIPE_STATE_H 41943964a1e5bad86bdceb0a06d60fb3b302ebce6aKeith Whitwell#define PIPE_STATE_H 428e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell 4340a86b20478024ca7c55400019c536cb5ff631d1Keith Whitwell#include "p_compiler.h" 441c5f27a18b775b3784fcd265d60e0affa0b31581Michel Dänzer#include "p_defines.h" 4554fc80ab31f89520d3119196bfa9c6332b35fe2fBrian#include "p_format.h" 465e27cd46c04a9e7b5904cc014bffd0f4daae31feMichel Dänzer#include "p_refcnt.h" 475e27cd46c04a9e7b5904cc014bffd0f4daae31feMichel Dänzer#include "p_screen.h" 4813682d959ddacde1ce65843aa8c5b43dc9017b32Brian 49e4e30089231831339815cccebf3a3a0ea6dcd2a9José Fonseca 50e4e30089231831339815cccebf3a3a0ea6dcd2a9José Fonseca#ifdef __cplusplus 51e4e30089231831339815cccebf3a3a0ea6dcd2a9José Fonsecaextern "C" { 52e4e30089231831339815cccebf3a3a0ea6dcd2a9José Fonseca#endif 53e4e30089231831339815cccebf3a3a0ea6dcd2a9José Fonseca 54e4e30089231831339815cccebf3a3a0ea6dcd2a9José Fonseca 5513682d959ddacde1ce65843aa8c5b43dc9017b32Brian/** 5613682d959ddacde1ce65843aa8c5b43dc9017b32Brian * Implementation limits 5713682d959ddacde1ce65843aa8c5b43dc9017b32Brian */ 58da8934034b33adef5dc41395cfde4bdd26ba207cBrian#define PIPE_MAX_ATTRIBS 32 59da8934034b33adef5dc41395cfde4bdd26ba207cBrian#define PIPE_MAX_CLIP_PLANES 6 60da8934034b33adef5dc41395cfde4bdd26ba207cBrian#define PIPE_MAX_COLOR_BUFS 8 61da8934034b33adef5dc41395cfde4bdd26ba207cBrian#define PIPE_MAX_CONSTANT 32 62da8934034b33adef5dc41395cfde4bdd26ba207cBrian#define PIPE_MAX_SAMPLERS 16 63da8934034b33adef5dc41395cfde4bdd26ba207cBrian#define PIPE_MAX_SHADER_INPUTS 16 64da8934034b33adef5dc41395cfde4bdd26ba207cBrian#define PIPE_MAX_SHADER_OUTPUTS 16 65da8934034b33adef5dc41395cfde4bdd26ba207cBrian#define PIPE_MAX_TEXTURE_LEVELS 16 6613682d959ddacde1ce65843aa8c5b43dc9017b32Brian 6713682d959ddacde1ce65843aa8c5b43dc9017b32Brian 6850eb29ed9492a34db4ba53f1f28a2868b808955aBrian/* fwd decls */ 69e62cf5c69ab605b78324639f5455ac9921e68dbaBrianstruct pipe_surface; 70e62cf5c69ab605b78324639f5455ac9921e68dbaBrian 711e0d30a515e4cac891b6c590f12a33e0e8a8e295Keith Whitwell 721e0d30a515e4cac891b6c590f12a33e0e8a8e295Keith Whitwell/** 731e0d30a515e4cac891b6c590f12a33e0e8a8e295Keith Whitwell * The driver will certainly subclass this to include actual memory 741e0d30a515e4cac891b6c590f12a33e0e8a8e295Keith Whitwell * management information. 751e0d30a515e4cac891b6c590f12a33e0e8a8e295Keith Whitwell */ 76d4d2e36a429fd015316c484fc40be7e6d2c69946Brianstruct pipe_buffer 77d4d2e36a429fd015316c484fc40be7e6d2c69946Brian{ 78124a6b1958c630ea049025e2b72547096fdc8f2cZack Rusin struct pipe_reference reference; 79124a6b1958c630ea049025e2b72547096fdc8f2cZack Rusin unsigned size; 80124a6b1958c630ea049025e2b72547096fdc8f2cZack Rusin struct pipe_screen *screen; 81124a6b1958c630ea049025e2b72547096fdc8f2cZack Rusin unsigned alignment; 82124a6b1958c630ea049025e2b72547096fdc8f2cZack Rusin unsigned usage; 831e0d30a515e4cac891b6c590f12a33e0e8a8e295Keith Whitwell}; 841e0d30a515e4cac891b6c590f12a33e0e8a8e295Keith Whitwell 85bec2230514ad2e8e52625ecb339fcadfabffd4dfBrian 86f79c225d9e5adee6287a9bba35f014c3fe00d3f9Brian/** 87294401814d1d89cc731de1c22c25333aa5d59374Zack Rusin * Primitive (point/line/tri) rasterization info 88f79c225d9e5adee6287a9bba35f014c3fe00d3f9Brian */ 89294401814d1d89cc731de1c22c25333aa5d59374Zack Rusinstruct pipe_rasterizer_state 90f79c225d9e5adee6287a9bba35f014c3fe00d3f9Brian{ 9140a86b20478024ca7c55400019c536cb5ff631d1Keith Whitwell unsigned flatshade:1; 9240a86b20478024ca7c55400019c536cb5ff631d1Keith Whitwell unsigned light_twoside:1; 9340a86b20478024ca7c55400019c536cb5ff631d1Keith Whitwell unsigned front_winding:2; /**< PIPE_WINDING_x */ 9440a86b20478024ca7c55400019c536cb5ff631d1Keith Whitwell unsigned cull_mode:2; /**< PIPE_WINDING_x */ 9540a86b20478024ca7c55400019c536cb5ff631d1Keith Whitwell unsigned fill_cw:2; /**< PIPE_POLYGON_MODE_x */ 9640a86b20478024ca7c55400019c536cb5ff631d1Keith Whitwell unsigned fill_ccw:2; /**< PIPE_POLYGON_MODE_x */ 9740a86b20478024ca7c55400019c536cb5ff631d1Keith Whitwell unsigned offset_cw:1; 9840a86b20478024ca7c55400019c536cb5ff631d1Keith Whitwell unsigned offset_ccw:1; 9940a86b20478024ca7c55400019c536cb5ff631d1Keith Whitwell unsigned scissor:1; 10040a86b20478024ca7c55400019c536cb5ff631d1Keith Whitwell unsigned poly_smooth:1; 10140a86b20478024ca7c55400019c536cb5ff631d1Keith Whitwell unsigned poly_stipple_enable:1; 10240a86b20478024ca7c55400019c536cb5ff631d1Keith Whitwell unsigned point_smooth:1; 103cd4d732773e06e462e78b8f5bc9f3f1552a198acBrian unsigned point_sprite:1; 104beefc6011bce9e99cb46430186de1c13f027cb05Brian unsigned point_size_per_vertex:1; /**< size computed in vertex shader */ 10540a86b20478024ca7c55400019c536cb5ff631d1Keith Whitwell unsigned multisample:1; /* XXX maybe more ms state in future */ 10640a86b20478024ca7c55400019c536cb5ff631d1Keith Whitwell unsigned line_smooth:1; 10740a86b20478024ca7c55400019c536cb5ff631d1Keith Whitwell unsigned line_stipple_enable:1; 10840a86b20478024ca7c55400019c536cb5ff631d1Keith Whitwell unsigned line_stipple_factor:8; /**< [1..256] actually */ 10940a86b20478024ca7c55400019c536cb5ff631d1Keith Whitwell unsigned line_stipple_pattern:16; 11099691f38c278f1d4aeb0617b149109644e3571fbKeith Whitwell unsigned line_last_pixel:1; 111683e7091a953204c9aee1410ac44be3b69bae9fcKeith Whitwell 112683e7091a953204c9aee1410ac44be3b69bae9fcKeith Whitwell /** 113683e7091a953204c9aee1410ac44be3b69bae9fcKeith Whitwell * Vertex coordinates are pre-transformed to screen space. Skip 114683e7091a953204c9aee1410ac44be3b69bae9fcKeith Whitwell * the vertex shader, clipping and viewport processing. Note that 115683e7091a953204c9aee1410ac44be3b69bae9fcKeith Whitwell * a vertex shader is still needed though, to indicate the mapping 116683e7091a953204c9aee1410ac44be3b69bae9fcKeith Whitwell * from vertex elements to fragment shader input semantics. 117a1fa770c01d913658900de1c267fb4c41bc6300dKeith Whitwell * 118a1fa770c01d913658900de1c267fb4c41bc6300dKeith Whitwell * XXX: considered for removal. 119683e7091a953204c9aee1410ac44be3b69bae9fcKeith Whitwell */ 120683e7091a953204c9aee1410ac44be3b69bae9fcKeith Whitwell unsigned bypass_vs_clip_and_viewport:1; 121683e7091a953204c9aee1410ac44be3b69bae9fcKeith Whitwell 122a1fa770c01d913658900de1c267fb4c41bc6300dKeith Whitwell /** 123a1fa770c01d913658900de1c267fb4c41bc6300dKeith Whitwell * Use the first vertex of a primitive as the provoking vertex for 124a1fa770c01d913658900de1c267fb4c41bc6300dKeith Whitwell * flat shading. 125a1fa770c01d913658900de1c267fb4c41bc6300dKeith Whitwell */ 126a1fa770c01d913658900de1c267fb4c41bc6300dKeith Whitwell unsigned flatshade_first:1; 127a1fa770c01d913658900de1c267fb4c41bc6300dKeith Whitwell 128a1fa770c01d913658900de1c267fb4c41bc6300dKeith Whitwell /** 129a1fa770c01d913658900de1c267fb4c41bc6300dKeith Whitwell * When true, triangle rasterization uses (0.5, 0.5) pixel centers 130a1fa770c01d913658900de1c267fb4c41bc6300dKeith Whitwell * for determining pixel ownership. 131a1fa770c01d913658900de1c267fb4c41bc6300dKeith Whitwell * 132a1fa770c01d913658900de1c267fb4c41bc6300dKeith Whitwell * When false, triangle rasterization uses (0,0) pixel centers for 133a1fa770c01d913658900de1c267fb4c41bc6300dKeith Whitwell * determining pixel ownership. 134a1fa770c01d913658900de1c267fb4c41bc6300dKeith Whitwell * 135a1fa770c01d913658900de1c267fb4c41bc6300dKeith Whitwell * Triangle rasterization always uses a 'top,left' rule for pixel 136a1fa770c01d913658900de1c267fb4c41bc6300dKeith Whitwell * ownership, this just alters which point we consider the pixel 137a1fa770c01d913658900de1c267fb4c41bc6300dKeith Whitwell * center for that test. 138a1fa770c01d913658900de1c267fb4c41bc6300dKeith Whitwell */ 139a1fa770c01d913658900de1c267fb4c41bc6300dKeith Whitwell unsigned gl_rasterization_rules:1; 14040a86b20478024ca7c55400019c536cb5ff631d1Keith Whitwell 14140a86b20478024ca7c55400019c536cb5ff631d1Keith Whitwell float line_width; 14240a86b20478024ca7c55400019c536cb5ff631d1Keith Whitwell float point_size; /**< used when no per-vertex size */ 143bc739440c29c551fcc44e9e12d0d9c170d8d24fbKeith Whitwell float point_size_min; /* XXX - temporary, will go away */ 144bc739440c29c551fcc44e9e12d0d9c170d8d24fbKeith Whitwell float point_size_max; /* XXX - temporary, will go away */ 14540a86b20478024ca7c55400019c536cb5ff631d1Keith Whitwell float offset_units; 14640a86b20478024ca7c55400019c536cb5ff631d1Keith Whitwell float offset_scale; 1471b4852345954af9b582b03a91a3d8399b8fb0e92Brian ubyte sprite_coord_mode[PIPE_MAX_SHADER_OUTPUTS]; /**< PIPE_SPRITE_COORD_ */ 1488e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell}; 1498e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell 15063a51aee86f76ae54fb1ce572d584fb0f01aaec5Brian 151d4d2e36a429fd015316c484fc40be7e6d2c69946Brianstruct pipe_poly_stipple 152d4d2e36a429fd015316c484fc40be7e6d2c69946Brian{ 15340a86b20478024ca7c55400019c536cb5ff631d1Keith Whitwell unsigned stipple[32]; 1548e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell}; 1558e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell 1568e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell 157d4d2e36a429fd015316c484fc40be7e6d2c69946Brianstruct pipe_viewport_state 158d4d2e36a429fd015316c484fc40be7e6d2c69946Brian{ 15940a86b20478024ca7c55400019c536cb5ff631d1Keith Whitwell float scale[4]; 16040a86b20478024ca7c55400019c536cb5ff631d1Keith Whitwell float translate[4]; 1618e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell}; 1628e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell 16350eb29ed9492a34db4ba53f1f28a2868b808955aBrian 164d4d2e36a429fd015316c484fc40be7e6d2c69946Brianstruct pipe_scissor_state 165d4d2e36a429fd015316c484fc40be7e6d2c69946Brian{ 16640a86b20478024ca7c55400019c536cb5ff631d1Keith Whitwell unsigned minx:16; 16740a86b20478024ca7c55400019c536cb5ff631d1Keith Whitwell unsigned miny:16; 16840a86b20478024ca7c55400019c536cb5ff631d1Keith Whitwell unsigned maxx:16; 16940a86b20478024ca7c55400019c536cb5ff631d1Keith Whitwell unsigned maxy:16; 1708e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell}; 1718e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell 17250eb29ed9492a34db4ba53f1f28a2868b808955aBrian 173d4d2e36a429fd015316c484fc40be7e6d2c69946Brianstruct pipe_clip_state 174d4d2e36a429fd015316c484fc40be7e6d2c69946Brian{ 17540a86b20478024ca7c55400019c536cb5ff631d1Keith Whitwell float ucp[PIPE_MAX_CLIP_PLANES][4]; 17640a86b20478024ca7c55400019c536cb5ff631d1Keith Whitwell unsigned nr; 1778e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell}; 1788e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell 1794824c342c864e870251a7d343c95e51274e50d23Keith Whitwell 180c0bb4ba9e665e40a325d82aa2ee48d7b8abd603bBrian/** 181c0bb4ba9e665e40a325d82aa2ee48d7b8abd603bBrian * Constants for vertex/fragment shaders 182c0bb4ba9e665e40a325d82aa2ee48d7b8abd603bBrian */ 183d4d2e36a429fd015316c484fc40be7e6d2c69946Brianstruct pipe_constant_buffer 184d4d2e36a429fd015316c484fc40be7e6d2c69946Brian{ 1851e0d30a515e4cac891b6c590f12a33e0e8a8e295Keith Whitwell struct pipe_buffer *buffer; 1868e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell}; 1878e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell 1888e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell 189d4d2e36a429fd015316c484fc40be7e6d2c69946Brianstruct pipe_shader_state 190d4d2e36a429fd015316c484fc40be7e6d2c69946Brian{ 19143d7c1fe9d2544b851afa2f1c1e245a63860e670Brian const struct tgsi_token *tokens; 19243d7c1fe9d2544b851afa2f1c1e245a63860e670Brian}; 19343d7c1fe9d2544b851afa2f1c1e245a63860e670Brian 19450eb29ed9492a34db4ba53f1f28a2868b808955aBrian 195b9a3952f8f04a25818aba69e235e3d250c064cb8Brian Paulstruct pipe_depth_state 196b9a3952f8f04a25818aba69e235e3d250c064cb8Brian Paul{ 197ca826d79a64d46e7f3bffff22640f148c044cdadJosé Fonseca unsigned enabled:1; /**< depth test enabled? */ 198ca826d79a64d46e7f3bffff22640f148c044cdadJosé Fonseca unsigned writemask:1; /**< allow depth buffer writes? */ 199ca826d79a64d46e7f3bffff22640f148c044cdadJosé Fonseca unsigned func:3; /**< depth test func (PIPE_FUNC_x) */ 200ca826d79a64d46e7f3bffff22640f148c044cdadJosé Fonseca unsigned occlusion_count:1; /**< do occlusion counting? */ 201ca826d79a64d46e7f3bffff22640f148c044cdadJosé Fonseca}; 202ca826d79a64d46e7f3bffff22640f148c044cdadJosé Fonseca 203ca826d79a64d46e7f3bffff22640f148c044cdadJosé Fonseca 204b9a3952f8f04a25818aba69e235e3d250c064cb8Brian Paulstruct pipe_stencil_state 205b9a3952f8f04a25818aba69e235e3d250c064cb8Brian Paul{ 206ca826d79a64d46e7f3bffff22640f148c044cdadJosé Fonseca unsigned enabled:1; /**< stencil[0]: stencil enabled, stencil[1]: two-side enabled */ 207ca826d79a64d46e7f3bffff22640f148c044cdadJosé Fonseca unsigned func:3; /**< PIPE_FUNC_x */ 208ca826d79a64d46e7f3bffff22640f148c044cdadJosé Fonseca unsigned fail_op:3; /**< PIPE_STENCIL_OP_x */ 209ca826d79a64d46e7f3bffff22640f148c044cdadJosé Fonseca unsigned zpass_op:3; /**< PIPE_STENCIL_OP_x */ 210ca826d79a64d46e7f3bffff22640f148c044cdadJosé Fonseca unsigned zfail_op:3; /**< PIPE_STENCIL_OP_x */ 211a7e72231e3c76a9410d192441da309002ea6422dZack Rusin ubyte ref_value; 212a7e72231e3c76a9410d192441da309002ea6422dZack Rusin ubyte valuemask; 213a7e72231e3c76a9410d192441da309002ea6422dZack Rusin ubyte writemask; 214ca826d79a64d46e7f3bffff22640f148c044cdadJosé Fonseca}; 215ca826d79a64d46e7f3bffff22640f148c044cdadJosé Fonseca 216ca826d79a64d46e7f3bffff22640f148c044cdadJosé Fonseca 217b9a3952f8f04a25818aba69e235e3d250c064cb8Brian Paulstruct pipe_alpha_state 218b9a3952f8f04a25818aba69e235e3d250c064cb8Brian Paul{ 219ca826d79a64d46e7f3bffff22640f148c044cdadJosé Fonseca unsigned enabled:1; 220ca826d79a64d46e7f3bffff22640f148c044cdadJosé Fonseca unsigned func:3; /**< PIPE_FUNC_x */ 221d6888e811d24eaa7e8d9093be606394f00435c05Zack Rusin float ref_value; /**< reference value */ 222ca826d79a64d46e7f3bffff22640f148c044cdadJosé Fonseca}; 223ca826d79a64d46e7f3bffff22640f148c044cdadJosé Fonseca 224ca826d79a64d46e7f3bffff22640f148c044cdadJosé Fonseca 225bfe79babf99e6b9435195178d1ea64687c60d161Keith Whitwellstruct pipe_depth_stencil_alpha_state 2268f2888758129b0a40d71fa4ce10d606b4bcf7631Brian{ 227ca826d79a64d46e7f3bffff22640f148c044cdadJosé Fonseca struct pipe_depth_state depth; 228ca826d79a64d46e7f3bffff22640f148c044cdadJosé Fonseca struct pipe_stencil_state stencil[2]; /**< [0] = front, [1] = back */ 229ca826d79a64d46e7f3bffff22640f148c044cdadJosé Fonseca struct pipe_alpha_state alpha; 230493f7b5f3ae2eb64eaa65e24e79a7a071c359b81Brian}; 2318f2888758129b0a40d71fa4ce10d606b4bcf7631Brian 232bfe79babf99e6b9435195178d1ea64687c60d161Keith Whitwell 233d4d2e36a429fd015316c484fc40be7e6d2c69946Brianstruct pipe_blend_state 234d4d2e36a429fd015316c484fc40be7e6d2c69946Brian{ 23540a86b20478024ca7c55400019c536cb5ff631d1Keith Whitwell unsigned blend_enable:1; 2368e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell 23740a86b20478024ca7c55400019c536cb5ff631d1Keith Whitwell unsigned rgb_func:3; /**< PIPE_BLEND_x */ 23840a86b20478024ca7c55400019c536cb5ff631d1Keith Whitwell unsigned rgb_src_factor:5; /**< PIPE_BLENDFACTOR_x */ 23940a86b20478024ca7c55400019c536cb5ff631d1Keith Whitwell unsigned rgb_dst_factor:5; /**< PIPE_BLENDFACTOR_x */ 2408e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell 24140a86b20478024ca7c55400019c536cb5ff631d1Keith Whitwell unsigned alpha_func:3; /**< PIPE_BLEND_x */ 24240a86b20478024ca7c55400019c536cb5ff631d1Keith Whitwell unsigned alpha_src_factor:5; /**< PIPE_BLENDFACTOR_x */ 24340a86b20478024ca7c55400019c536cb5ff631d1Keith Whitwell unsigned alpha_dst_factor:5; /**< PIPE_BLENDFACTOR_x */ 2448e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell 24540a86b20478024ca7c55400019c536cb5ff631d1Keith Whitwell unsigned logicop_enable:1; 24640a86b20478024ca7c55400019c536cb5ff631d1Keith Whitwell unsigned logicop_func:4; /**< PIPE_LOGICOP_x */ 24786352ff70d8c9a31fe0ebb4d02ce4bb4644fe54aBrian 24840a86b20478024ca7c55400019c536cb5ff631d1Keith Whitwell unsigned colormask:4; /**< bitmask of PIPE_MASK_R/G/B/A */ 24940a86b20478024ca7c55400019c536cb5ff631d1Keith Whitwell unsigned dither:1; 2508e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell}; 2518e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell 25250eb29ed9492a34db4ba53f1f28a2868b808955aBrian 253d4d2e36a429fd015316c484fc40be7e6d2c69946Brianstruct pipe_blend_color 254d4d2e36a429fd015316c484fc40be7e6d2c69946Brian{ 25540a86b20478024ca7c55400019c536cb5ff631d1Keith Whitwell float color[4]; 2568e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell}; 2578e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell 25850eb29ed9492a34db4ba53f1f28a2868b808955aBrian 2598f6b6eed35832733674372dea7bd5ce69a965c4eBrianstruct pipe_framebuffer_state 2608f6b6eed35832733674372dea7bd5ce69a965c4eBrian{ 26180567f9c9f84d9df1cdb2d91a3c0814888cc5d08Brian unsigned width, height; 26280567f9c9f84d9df1cdb2d91a3c0814888cc5d08Brian 263f0f9a22609ccf2b8edc5760480f1a7a78cb504d7Brian /** multiple colorbuffers for multiple render targets */ 2642299f21f8da816fc4588492965e7dac422da1a96Zack Rusin unsigned nr_cbufs; 265f0f9a22609ccf2b8edc5760480f1a7a78cb504d7Brian struct pipe_surface *cbufs[PIPE_MAX_COLOR_BUFS]; 266f0f9a22609ccf2b8edc5760480f1a7a78cb504d7Brian 2678de2331e432e2ea6f978acb6c80666da99c6c4a1Brian struct pipe_surface *zsbuf; /**< Z/stencil buffer */ 2688f6b6eed35832733674372dea7bd5ce69a965c4eBrian}; 2698f6b6eed35832733674372dea7bd5ce69a965c4eBrian 2708f6b6eed35832733674372dea7bd5ce69a965c4eBrian 27102a47549ad182d28d330063d4f452108e3a4b452Brian/** 27202a47549ad182d28d330063d4f452108e3a4b452Brian * Texture sampler state. 27302a47549ad182d28d330063d4f452108e3a4b452Brian */ 274943964a1e5bad86bdceb0a06d60fb3b302ebce6aKeith Whitwellstruct pipe_sampler_state 27502a47549ad182d28d330063d4f452108e3a4b452Brian{ 276d4d2e36a429fd015316c484fc40be7e6d2c69946Brian unsigned wrap_s:3; /**< PIPE_TEX_WRAP_x */ 277d4d2e36a429fd015316c484fc40be7e6d2c69946Brian unsigned wrap_t:3; /**< PIPE_TEX_WRAP_x */ 278d4d2e36a429fd015316c484fc40be7e6d2c69946Brian unsigned wrap_r:3; /**< PIPE_TEX_WRAP_x */ 27940a86b20478024ca7c55400019c536cb5ff631d1Keith Whitwell unsigned min_img_filter:2; /**< PIPE_TEX_FILTER_x */ 28040a86b20478024ca7c55400019c536cb5ff631d1Keith Whitwell unsigned min_mip_filter:2; /**< PIPE_TEX_MIPFILTER_x */ 28140a86b20478024ca7c55400019c536cb5ff631d1Keith Whitwell unsigned mag_img_filter:2; /**< PIPE_TEX_FILTER_x */ 282d4d2e36a429fd015316c484fc40be7e6d2c69946Brian unsigned compare_mode:1; /**< PIPE_TEX_COMPARE_x */ 283d4d2e36a429fd015316c484fc40be7e6d2c69946Brian unsigned compare_func:3; /**< PIPE_FUNC_x */ 284d4d2e36a429fd015316c484fc40be7e6d2c69946Brian unsigned normalized_coords:1; /**< Are coords normalized to [0,1]? */ 28599691f38c278f1d4aeb0617b149109644e3571fbKeith Whitwell unsigned prefilter:4; /**< Wierd sampling state exposed by some api's */ 286d4d2e36a429fd015316c484fc40be7e6d2c69946Brian float lod_bias; /**< LOD/lambda bias */ 287d4d2e36a429fd015316c484fc40be7e6d2c69946Brian float min_lod, max_lod; /**< LOD clamp range, after bias */ 288d45dd5672ae60f1f49648725974693bf4ebf4bf8Brian float border_color[4]; 28940a86b20478024ca7c55400019c536cb5ff631d1Keith Whitwell float max_anisotropy; 29002a47549ad182d28d330063d4f452108e3a4b452Brian}; 29102a47549ad182d28d330063d4f452108e3a4b452Brian 2925d69aeb0028f44d06093faede5c545908b0df89aBrian 29320adf45c23dd9ec86a1439ad87c1473395bbb1a7Brian/** 294b859cdf6f191b4d8b56537c8dc30082a7e2d94b3Michel Dänzer * 2D surface. This is basically a view into a memory buffer. 29520adf45c23dd9ec86a1439ad87c1473395bbb1a7Brian * May be a renderbuffer, texture mipmap level, etc. 29620adf45c23dd9ec86a1439ad87c1473395bbb1a7Brian */ 29720adf45c23dd9ec86a1439ad87c1473395bbb1a7Brianstruct pipe_surface 29820adf45c23dd9ec86a1439ad87c1473395bbb1a7Brian{ 2995e27cd46c04a9e7b5904cc014bffd0f4daae31feMichel Dänzer struct pipe_reference reference; 30054fc80ab31f89520d3119196bfa9c6332b35fe2fBrian enum pipe_format format; /**< PIPE_FORMAT_x */ 3015531c986bd34457e113163a68ff4ab98394738f0Brian Paul unsigned width; /**< logical width in pixels */ 3025531c986bd34457e113163a68ff4ab98394738f0Brian Paul unsigned height; /**< logical height in pixels */ 3038e6a3807981bb96bb6747683dbc9f92ae7117dd2Keith Whitwell unsigned layout; /**< PIPE_SURFACE_LAYOUT_x */ 304b859cdf6f191b4d8b56537c8dc30082a7e2d94b3Michel Dänzer unsigned offset; /**< offset from start of buffer, in bytes */ 305429a08384c2ea66d446e46beb28e33ee3b764d52Roland Scheidegger unsigned usage; /**< PIPE_BUFFER_USAGE_* */ 306c9ed86a96483063f3d6789ed16645a3dca77d726Keith Whitwell 307124a6b1958c630ea049025e2b72547096fdc8f2cZack Rusin unsigned zslice; 3085897383344da3320d158c26adae05de35480471fJosé Fonseca struct pipe_texture *texture; /**< texture into which this is a view */ 309b59f9c95c1f7aca60c5d6889d4dc388d19fbc3e1Keith Whitwell unsigned face; 310b59f9c95c1f7aca60c5d6889d4dc388d19fbc3e1Keith Whitwell unsigned level; 31120adf45c23dd9ec86a1439ad87c1473395bbb1a7Brian}; 31220adf45c23dd9ec86a1439ad87c1473395bbb1a7Brian 31320adf45c23dd9ec86a1439ad87c1473395bbb1a7Brian 3145d69aeb0028f44d06093faede5c545908b0df89aBrian/** 3154617981ec72f7985941bee4b03c534d97ff96bc6Michel Dänzer * Transfer object. For data transfer to/from a texture. 3164617981ec72f7985941bee4b03c534d97ff96bc6Michel Dänzer */ 3174617981ec72f7985941bee4b03c534d97ff96bc6Michel Dänzerstruct pipe_transfer 3184617981ec72f7985941bee4b03c534d97ff96bc6Michel Dänzer{ 3194617981ec72f7985941bee4b03c534d97ff96bc6Michel Dänzer enum pipe_format format; /**< PIPE_FORMAT_x */ 3204617981ec72f7985941bee4b03c534d97ff96bc6Michel Dänzer unsigned x; /**< x offset from start of texture image */ 3214617981ec72f7985941bee4b03c534d97ff96bc6Michel Dänzer unsigned y; /**< y offset from start of texture image */ 3224617981ec72f7985941bee4b03c534d97ff96bc6Michel Dänzer unsigned width; /**< logical width in pixels */ 3234617981ec72f7985941bee4b03c534d97ff96bc6Michel Dänzer unsigned height; /**< logical height in pixels */ 3244617981ec72f7985941bee4b03c534d97ff96bc6Michel Dänzer struct pipe_format_block block; 3254617981ec72f7985941bee4b03c534d97ff96bc6Michel Dänzer unsigned nblocksx; /**< allocated width in blocks */ 3264617981ec72f7985941bee4b03c534d97ff96bc6Michel Dänzer unsigned nblocksy; /**< allocated height in blocks */ 3274617981ec72f7985941bee4b03c534d97ff96bc6Michel Dänzer unsigned stride; /**< stride in bytes between rows of blocks */ 328a18301790cf2b6f494284cdda6eea8bb1ceacd8eJosé Fonseca enum pipe_transfer_usage usage; /**< PIPE_TRANSFER_* */ 3294617981ec72f7985941bee4b03c534d97ff96bc6Michel Dänzer 3304617981ec72f7985941bee4b03c534d97ff96bc6Michel Dänzer struct pipe_texture *texture; /**< texture to transfer to/from */ 3314617981ec72f7985941bee4b03c534d97ff96bc6Michel Dänzer unsigned face; 3324617981ec72f7985941bee4b03c534d97ff96bc6Michel Dänzer unsigned level; 3334617981ec72f7985941bee4b03c534d97ff96bc6Michel Dänzer unsigned zslice; 3344617981ec72f7985941bee4b03c534d97ff96bc6Michel Dänzer}; 3354617981ec72f7985941bee4b03c534d97ff96bc6Michel Dänzer 3364617981ec72f7985941bee4b03c534d97ff96bc6Michel Dänzer 3374617981ec72f7985941bee4b03c534d97ff96bc6Michel Dänzer/** 338d8bf051c8b4a1ebe44895413a109d4ab898f7579Brian * Texture object. 339d9605cdf7cbbd3c81c506d01eb8e88a11ccfc09bBrian */ 340753db0d8407147393a7b0622ae3fa28f68d0353dMichel Dänzerstruct pipe_texture 341753db0d8407147393a7b0622ae3fa28f68d0353dMichel Dänzer{ 3425e27cd46c04a9e7b5904cc014bffd0f4daae31feMichel Dänzer struct pipe_reference reference; 3435e27cd46c04a9e7b5904cc014bffd0f4daae31feMichel Dänzer 3441c5f27a18b775b3784fcd265d60e0affa0b31581Michel Dänzer enum pipe_texture_target target; /**< PIPE_TEXTURE_x */ 3451c5f27a18b775b3784fcd265d60e0affa0b31581Michel Dänzer enum pipe_format format; /**< PIPE_FORMAT_x */ 34688723b2fc84628c1bc1e0008b88602b85e8668beMichel Dänzer 347753db0d8407147393a7b0622ae3fa28f68d0353dMichel Dänzer unsigned width[PIPE_MAX_TEXTURE_LEVELS]; 348753db0d8407147393a7b0622ae3fa28f68d0353dMichel Dänzer unsigned height[PIPE_MAX_TEXTURE_LEVELS]; 349753db0d8407147393a7b0622ae3fa28f68d0353dMichel Dänzer unsigned depth[PIPE_MAX_TEXTURE_LEVELS]; 350d9605cdf7cbbd3c81c506d01eb8e88a11ccfc09bBrian 3514ddd65967915ca4846f2831bc676c878a29dae4aJosé Fonseca struct pipe_format_block block; 3525531c986bd34457e113163a68ff4ab98394738f0Brian Paul unsigned nblocksx[PIPE_MAX_TEXTURE_LEVELS]; /**< allocated width in blocks */ 3535531c986bd34457e113163a68ff4ab98394738f0Brian Paul unsigned nblocksy[PIPE_MAX_TEXTURE_LEVELS]; /**< allocated height in blocks */ 3544ddd65967915ca4846f2831bc676c878a29dae4aJosé Fonseca 35518e94e15c0ca881309ac5784075a04160cc1eeb6Keith Whitwell unsigned last_level:8; /**< Index of last mipmap level present/defined */ 356429a08384c2ea66d446e46beb28e33ee3b764d52Roland Scheidegger 357b9a3952f8f04a25818aba69e235e3d250c064cb8Brian Paul unsigned nr_samples:8; /**< for multisampled surfaces, nr of samples */ 358429a08384c2ea66d446e46beb28e33ee3b764d52Roland Scheidegger 359b9a3952f8f04a25818aba69e235e3d250c064cb8Brian Paul unsigned tex_usage; /* PIPE_TEXTURE_USAGE_* */ 360d9605cdf7cbbd3c81c506d01eb8e88a11ccfc09bBrian 361d8bf051c8b4a1ebe44895413a109d4ab898f7579Brian struct pipe_screen *screen; /**< screen that this texture belongs to */ 362d9605cdf7cbbd3c81c506d01eb8e88a11ccfc09bBrian}; 363d9605cdf7cbbd3c81c506d01eb8e88a11ccfc09bBrian 364d9605cdf7cbbd3c81c506d01eb8e88a11ccfc09bBrian 3656e02b4c7c3c6efc05ead2ffd46b0928f7c9316bfBrian/** 3666e02b4c7c3c6efc05ead2ffd46b0928f7c9316bfBrian * A vertex buffer. Typically, all the vertex data/attributes for 3676e02b4c7c3c6efc05ead2ffd46b0928f7c9316bfBrian * drawing something will be in one buffer. But it's also possible, for 3686e02b4c7c3c6efc05ead2ffd46b0928f7c9316bfBrian * example, to put colors in one buffer and texcoords in another. 3696e02b4c7c3c6efc05ead2ffd46b0928f7c9316bfBrian */ 3708269bc48d8fafaa432b58f4adf5e0dddd81d979dKeith Whitwellstruct pipe_vertex_buffer 3718269bc48d8fafaa432b58f4adf5e0dddd81d979dKeith Whitwell{ 372872b515e8f0bb1be5bad85fd9d01529c71f07ba2Zack Rusin unsigned stride; /**< stride to same attrib in next vertex, in bytes */ 3736e02b4c7c3c6efc05ead2ffd46b0928f7c9316bfBrian unsigned max_index; /**< number of vertices in this buffer */ 3746e02b4c7c3c6efc05ead2ffd46b0928f7c9316bfBrian unsigned buffer_offset; /**< offset to start of data in buffer, in bytes */ 3751e0d30a515e4cac891b6c590f12a33e0e8a8e295Keith Whitwell struct pipe_buffer *buffer; /**< the actual buffer */ 3768269bc48d8fafaa432b58f4adf5e0dddd81d979dKeith Whitwell}; 3778269bc48d8fafaa432b58f4adf5e0dddd81d979dKeith Whitwell 3788269bc48d8fafaa432b58f4adf5e0dddd81d979dKeith Whitwell 3796e02b4c7c3c6efc05ead2ffd46b0928f7c9316bfBrian/** 3806e02b4c7c3c6efc05ead2ffd46b0928f7c9316bfBrian * Information to describe a vertex attribute (position, color, etc) 3816e02b4c7c3c6efc05ead2ffd46b0928f7c9316bfBrian */ 3828269bc48d8fafaa432b58f4adf5e0dddd81d979dKeith Whitwellstruct pipe_vertex_element 3838269bc48d8fafaa432b58f4adf5e0dddd81d979dKeith Whitwell{ 3846e02b4c7c3c6efc05ead2ffd46b0928f7c9316bfBrian /** Offset of this attribute, in bytes, from the start of the vertex */ 38518e94e15c0ca881309ac5784075a04160cc1eeb6Keith Whitwell unsigned src_offset; 3866e02b4c7c3c6efc05ead2ffd46b0928f7c9316bfBrian 3876e02b4c7c3c6efc05ead2ffd46b0928f7c9316bfBrian /** Which vertex_buffer (as given to pipe->set_vertex_buffer()) does 3886e02b4c7c3c6efc05ead2ffd46b0928f7c9316bfBrian * this attribute live in? 3896e02b4c7c3c6efc05ead2ffd46b0928f7c9316bfBrian */ 39018e94e15c0ca881309ac5784075a04160cc1eeb6Keith Whitwell unsigned vertex_buffer_index:8; 39118e94e15c0ca881309ac5784075a04160cc1eeb6Keith Whitwell unsigned nr_components:8; 392c31416971e4eac148f8e82d6c4392bd6f9cbc05dKeith Whitwell 39354fc80ab31f89520d3119196bfa9c6332b35fe2fBrian enum pipe_format src_format; /**< PIPE_FORMAT_* */ 3948269bc48d8fafaa432b58f4adf5e0dddd81d979dKeith Whitwell}; 3958269bc48d8fafaa432b58f4adf5e0dddd81d979dKeith Whitwell 3968269bc48d8fafaa432b58f4adf5e0dddd81d979dKeith Whitwell 3975e27cd46c04a9e7b5904cc014bffd0f4daae31feMichel Dänzer/* Reference counting helper functions */ 3985e27cd46c04a9e7b5904cc014bffd0f4daae31feMichel Dänzerstatic INLINE void 3995e27cd46c04a9e7b5904cc014bffd0f4daae31feMichel Dänzerpipe_buffer_reference(struct pipe_buffer **ptr, struct pipe_buffer *buf) 4005e27cd46c04a9e7b5904cc014bffd0f4daae31feMichel Dänzer{ 4015e27cd46c04a9e7b5904cc014bffd0f4daae31feMichel Dänzer struct pipe_buffer *old_buf = *ptr; 4025e27cd46c04a9e7b5904cc014bffd0f4daae31feMichel Dänzer 4035e27cd46c04a9e7b5904cc014bffd0f4daae31feMichel Dänzer if (pipe_reference((struct pipe_reference **)ptr, &buf->reference)) 4045e27cd46c04a9e7b5904cc014bffd0f4daae31feMichel Dänzer old_buf->screen->buffer_destroy(old_buf); 4055e27cd46c04a9e7b5904cc014bffd0f4daae31feMichel Dänzer} 4065e27cd46c04a9e7b5904cc014bffd0f4daae31feMichel Dänzer 4075e27cd46c04a9e7b5904cc014bffd0f4daae31feMichel Dänzerstatic INLINE void 4085e27cd46c04a9e7b5904cc014bffd0f4daae31feMichel Dänzerpipe_surface_reference(struct pipe_surface **ptr, struct pipe_surface *surf) 4095e27cd46c04a9e7b5904cc014bffd0f4daae31feMichel Dänzer{ 4105e27cd46c04a9e7b5904cc014bffd0f4daae31feMichel Dänzer struct pipe_surface *old_surf = *ptr; 4115e27cd46c04a9e7b5904cc014bffd0f4daae31feMichel Dänzer 4125e27cd46c04a9e7b5904cc014bffd0f4daae31feMichel Dänzer if (pipe_reference((struct pipe_reference **)ptr, &surf->reference)) 4135e27cd46c04a9e7b5904cc014bffd0f4daae31feMichel Dänzer old_surf->texture->screen->tex_surface_destroy(old_surf); 4145e27cd46c04a9e7b5904cc014bffd0f4daae31feMichel Dänzer} 4155e27cd46c04a9e7b5904cc014bffd0f4daae31feMichel Dänzer 4165e27cd46c04a9e7b5904cc014bffd0f4daae31feMichel Dänzerstatic INLINE void 4175e27cd46c04a9e7b5904cc014bffd0f4daae31feMichel Dänzerpipe_texture_reference(struct pipe_texture **ptr, struct pipe_texture *tex) 4185e27cd46c04a9e7b5904cc014bffd0f4daae31feMichel Dänzer{ 4195e27cd46c04a9e7b5904cc014bffd0f4daae31feMichel Dänzer struct pipe_texture *old_tex = *ptr; 4205e27cd46c04a9e7b5904cc014bffd0f4daae31feMichel Dänzer 4215e27cd46c04a9e7b5904cc014bffd0f4daae31feMichel Dänzer if (pipe_reference((struct pipe_reference **)ptr, &tex->reference)) 4225e27cd46c04a9e7b5904cc014bffd0f4daae31feMichel Dänzer old_tex->screen->texture_destroy(old_tex); 4235e27cd46c04a9e7b5904cc014bffd0f4daae31feMichel Dänzer} 4245e27cd46c04a9e7b5904cc014bffd0f4daae31feMichel Dänzer 4255e27cd46c04a9e7b5904cc014bffd0f4daae31feMichel Dänzer 426e4e30089231831339815cccebf3a3a0ea6dcd2a9José Fonseca#ifdef __cplusplus 427e4e30089231831339815cccebf3a3a0ea6dcd2a9José Fonseca} 428e4e30089231831339815cccebf3a3a0ea6dcd2a9José Fonseca#endif 429e4e30089231831339815cccebf3a3a0ea6dcd2a9José Fonseca 4308e4a95a93d15a6707a29454cd47e10b08314cda2Keith Whitwell#endif 431