p_context.h revision 364f8cad0f8f02fd39d9c51ea0774d349121b58d
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#ifndef PIPE_CONTEXT_H 29#define PIPE_CONTEXT_H 30 31#include "p_state.h" 32 33 34#ifdef __cplusplus 35extern "C" { 36#endif 37 38 39struct pipe_screen; 40 41struct pipe_state_cache; 42 43/* Opaque driver handles: 44 */ 45struct pipe_query; 46 47/** 48 * Gallium rendering context. Basically: 49 * - state setting functions 50 * - VBO drawing functions 51 * - surface functions 52 * - device queries 53 */ 54struct pipe_context { 55 struct pipe_winsys *winsys; 56 struct pipe_screen *screen; 57 58 void *priv; /** context private data (for DRI for example) */ 59 60 void (*destroy)( struct pipe_context * ); 61 62 /* 63 * Drawing. 64 * Return false on fallbacks (temporary??) 65 */ 66 boolean (*draw_arrays)( struct pipe_context *pipe, 67 unsigned mode, unsigned start, unsigned count); 68 69 boolean (*draw_elements)( struct pipe_context *pipe, 70 struct pipe_buffer *indexBuffer, 71 unsigned indexSize, 72 unsigned mode, unsigned start, unsigned count); 73 74 75 /** 76 * Query objects 77 */ 78 struct pipe_query *(*create_query)( struct pipe_context *pipe, 79 unsigned query_type ); 80 81 void (*destroy_query)(struct pipe_context *pipe, 82 struct pipe_query *q); 83 84 void (*begin_query)(struct pipe_context *pipe, struct pipe_query *q); 85 void (*end_query)(struct pipe_context *pipe, struct pipe_query *q); 86 87 boolean (*get_query_result)(struct pipe_context *pipe, 88 struct pipe_query *q, 89 boolean wait, 90 uint64 *result); 91 92 /* 93 * State functions 94 */ 95 void * (*create_blend_state)(struct pipe_context *, 96 const struct pipe_blend_state *); 97 void (*bind_blend_state)(struct pipe_context *, void *); 98 void (*delete_blend_state)(struct pipe_context *, void *); 99 100 void * (*create_sampler_state)(struct pipe_context *, 101 const struct pipe_sampler_state *); 102 void (*bind_sampler_state)(struct pipe_context *, unsigned unit, void *); 103 void (*delete_sampler_state)(struct pipe_context *, void *); 104 105 void * (*create_rasterizer_state)(struct pipe_context *, 106 const struct pipe_rasterizer_state *); 107 void (*bind_rasterizer_state)(struct pipe_context *, void *); 108 void (*delete_rasterizer_state)(struct pipe_context *, void *); 109 110 void * (*create_depth_stencil_alpha_state)(struct pipe_context *, 111 const struct pipe_depth_stencil_alpha_state *); 112 void (*bind_depth_stencil_alpha_state)(struct pipe_context *, void *); 113 void (*delete_depth_stencil_alpha_state)(struct pipe_context *, void *); 114 115 void * (*create_fs_state)(struct pipe_context *, 116 const struct pipe_shader_state *); 117 void (*bind_fs_state)(struct pipe_context *, void *); 118 void (*delete_fs_state)(struct pipe_context *, void *); 119 120 void * (*create_vs_state)(struct pipe_context *, 121 const struct pipe_shader_state *); 122 void (*bind_vs_state)(struct pipe_context *, void *); 123 void (*delete_vs_state)(struct pipe_context *, void *); 124 125 /* The following look more properties than states. 126 * maybe combine a few of them into states or pass them 127 * in the bind calls to the state */ 128 void (*set_blend_color)( struct pipe_context *, 129 const struct pipe_blend_color * ); 130 131 void (*set_clip_state)( struct pipe_context *, 132 const struct pipe_clip_state * ); 133 134 void (*set_constant_buffer)( struct pipe_context *, 135 uint shader, uint index, 136 const struct pipe_constant_buffer *buf ); 137 138 void (*set_framebuffer_state)( struct pipe_context *, 139 const struct pipe_framebuffer_state * ); 140 141 void (*set_polygon_stipple)( struct pipe_context *, 142 const struct pipe_poly_stipple * ); 143 144 void (*set_scissor_state)( struct pipe_context *, 145 const struct pipe_scissor_state * ); 146 147 148 /* Currently a sampler is constrained to sample from a single texture: 149 */ 150 void (*set_sampler_texture)( struct pipe_context *, 151 unsigned sampler, 152 struct pipe_texture * ); 153 154 void (*set_viewport_state)( struct pipe_context *, 155 const struct pipe_viewport_state * ); 156 157 /* 158 * Vertex arrays 159 */ 160 void (*set_vertex_buffer)( struct pipe_context *, 161 unsigned index, 162 const struct pipe_vertex_buffer * ); 163 164 void (*set_vertex_element)( struct pipe_context *, 165 unsigned index, 166 const struct pipe_vertex_element * ); 167 168 169 /* 170 * Surface functions 171 */ 172 173 void (*surface_copy)(struct pipe_context *pipe, 174 unsigned do_flip, /*<< flip surface contents vertically */ 175 struct pipe_surface *dest, 176 unsigned destx, unsigned desty, 177 struct pipe_surface *src, /* don't make this const - 178 need to map/unmap */ 179 unsigned srcx, unsigned srcy, 180 unsigned width, unsigned height); 181 182 void (*surface_fill)(struct pipe_context *pipe, 183 struct pipe_surface *dst, 184 unsigned dstx, unsigned dsty, 185 unsigned width, unsigned height, 186 unsigned value); 187 188 void (*clear)(struct pipe_context *pipe, 189 struct pipe_surface *ps, 190 unsigned clearValue); 191 192 193 /* 194 * Texture functions 195 * XXX these are moving to pipe_screen... 196 */ 197 struct pipe_texture * (*texture_create)(struct pipe_context *pipe, 198 const struct pipe_texture *templat); 199 200 void (*texture_release)(struct pipe_context *pipe, 201 struct pipe_texture **pt); 202 203 /** 204 * Called when texture data is changed. 205 * Note: we could pass some hints about which mip levels or cube faces 206 * have changed... 207 */ 208 void (*texture_update)(struct pipe_context *pipe, 209 struct pipe_texture *texture); 210 211 /** Get a surface which is a "view" into a texture */ 212 struct pipe_surface *(*get_tex_surface)(struct pipe_context *pipe, 213 struct pipe_texture *texture, 214 unsigned face, unsigned level, 215 unsigned zslice); 216 217 /* Flush rendering: 218 */ 219 void (*flush)( struct pipe_context *pipe, 220 unsigned flags ); 221}; 222 223 224#ifdef __cplusplus 225} 226#endif 227 228#endif /* PIPE_CONTEXT_H */ 229