st_context.h

Go to the documentation of this file.
00001 /**************************************************************************
00002  * 
00003  * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
00004  * All Rights Reserved.
00005  * 
00006  * Permission is hereby granted, free of charge, to any person obtaining a
00007  * copy of this software and associated documentation files (the
00008  * "Software"), to deal in the Software without restriction, including
00009  * without limitation the rights to use, copy, modify, merge, publish,
00010  * distribute, sub license, and/or sell copies of the Software, and to
00011  * permit persons to whom the Software is furnished to do so, subject to
00012  * the following conditions:
00013  * 
00014  * The above copyright notice and this permission notice (including the
00015  * next paragraph) shall be included in all copies or substantial portions
00016  * of the Software.
00017  * 
00018  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
00019  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00020  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
00021  * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
00022  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
00023  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
00024  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00025  * 
00026  **************************************************************************/
00027 
00028 #ifndef ST_CONTEXT_H
00029 #define ST_CONTEXT_H
00030 
00031 #include "main/mtypes.h"
00032 #include "shader/prog_cache.h"
00033 #include "pipe/p_state.h"
00034 
00035 
00036 struct st_context;
00037 struct st_texture_object;
00038 struct st_fragment_program;
00039 struct draw_context;
00040 struct draw_stage;
00041 struct cso_cache;
00042 struct cso_blend;
00043 struct gen_mipmap_state;
00044 struct blit_state;
00045 struct bitmap_cache;
00046 
00047 
00048 #define FRONT_STATUS_UNDEFINED    0
00049 #define FRONT_STATUS_DIRTY        1
00050 #define FRONT_STATUS_COPY_OF_BACK 2
00051 
00052 
00053 #define ST_NEW_MESA                    0x1 /* Mesa state has changed */
00054 #define ST_NEW_FRAGMENT_PROGRAM        0x2
00055 #define ST_NEW_VERTEX_PROGRAM          0x4
00056 #define ST_NEW_FRAMEBUFFER             0x8
00057 
00058 
00059 struct st_state_flags {
00060    GLuint mesa;
00061    GLuint st;
00062 };
00063 
00064 struct st_tracked_state {
00065    const char *name;
00066    struct st_state_flags dirty;
00067    void (*update)( struct st_context *st );
00068 };
00069 
00070 
00071 
00072 struct st_context
00073 {
00074    GLcontext *ctx;
00075 
00076    struct pipe_context *pipe;
00077 
00078    struct draw_context *draw;  
00079    struct draw_stage *feedback_stage;  
00080    struct draw_stage *selection_stage;  
00081    struct draw_stage *rastpos_stage;  
00083    /* Some state is contained in constant objects.
00084     * Other state is just parameter values.
00085     */
00086    struct {
00087       struct pipe_blend_state               blend;
00088       struct pipe_depth_stencil_alpha_state depth_stencil;
00089       struct pipe_rasterizer_state          rasterizer;
00090       struct pipe_sampler_state             samplers[PIPE_MAX_SAMPLERS];
00091       struct pipe_sampler_state             *sampler_list[PIPE_MAX_SAMPLERS];
00092       struct pipe_clip_state clip;
00093       struct pipe_constant_buffer constants[2];
00094       struct pipe_framebuffer_state framebuffer;
00095       struct pipe_texture *sampler_texture[PIPE_MAX_SAMPLERS];
00096       struct pipe_poly_stipple poly_stipple;
00097       struct pipe_scissor_state scissor;
00098       struct pipe_viewport_state viewport;
00099 
00100       GLuint num_samplers;
00101       GLuint num_textures;
00102    } state;
00103 
00104    struct {
00105       struct st_tracked_state tracked_state[PIPE_SHADER_TYPES];
00106    } constants;
00107 
00108    /* XXX unused: */
00109    struct {
00110       struct gl_fragment_program *fragment_program;
00111    } cb;
00112 
00113    GLuint frontbuffer_status;  
00115    char vendor[100];
00116    char renderer[100];
00117 
00118    /* State to be validated:
00119     */
00120    struct st_tracked_state **atoms;
00121    GLuint nr_atoms;
00122 
00123    struct st_state_flags dirty;
00124 
00125    GLboolean missing_textures;
00126 
00127    GLfloat polygon_offset_scale; /* ?? */
00128 
00130    const GLuint *vertex_result_to_slot;
00131 
00132    struct st_vertex_program *vp;    
00133    struct st_fragment_program *fp;  
00135    struct gl_texture_object *default_texture;
00136 
00137    struct {
00138       struct gl_program_cache *cache;
00139       struct st_fragment_program *program;  
00140       GLuint xfer_prog_sn;  
00141       GLuint user_prog_sn;  
00142       struct st_fragment_program *combined_prog;
00143       GLuint combined_prog_sn;
00144       struct pipe_texture *pixelmap_texture;
00145       boolean pixelmap_enabled;  
00146    } pixel_xfer;
00147 
00149    struct {
00150       struct pipe_rasterizer_state rasterizer;
00151       struct pipe_sampler_state sampler;
00152       struct pipe_shader_state vert_shader;
00153       enum pipe_format tex_format;
00154       void *vs;
00155       float vertices[4][3][4];  
00156       struct pipe_buffer *vbuf;
00157       unsigned vbuf_slot;       /* next free slot in vbuf */
00158       struct bitmap_cache *cache;
00159    } bitmap;
00160 
00162    struct {
00163       struct st_fragment_program *z_shader;
00164       struct st_vertex_program *vert_shaders[2];
00165    } drawpix;
00166 
00168    struct {
00169       struct pipe_shader_state vert_shader;
00170       struct pipe_shader_state frag_shader;
00171       struct pipe_rasterizer_state raster;
00172       struct pipe_viewport_state viewport;
00173       void *vs;
00174       void *fs;
00175       float vertices[4][2][4];  
00176       struct pipe_buffer *vbuf;
00177       unsigned vbuf_slot;
00178    } clear;
00179 
00180    void *passthrough_fs;  
00182    struct gen_mipmap_state *gen_mipmap;
00183    struct blit_state *blit;
00184 
00185    struct cso_context *cso_context;
00186 
00187    int force_msaa;
00188 };
00189 
00190 
00191 /* Need this so that we can implement Mesa callbacks in this module.
00192  */
00193 static INLINE struct st_context *st_context(GLcontext *ctx)
00194 {
00195    return ctx->st;
00196 }
00197 
00198 
00203 struct st_framebuffer
00204 {
00205    GLframebuffer Base;
00206    void *Private;
00207    GLuint InitWidth, InitHeight;
00208 };
00209 
00210 
00211 extern void st_init_driver_functions(struct dd_function_table *functions);
00212 
00213 void st_invalidate_state(GLcontext * ctx, GLuint new_state);
00214 
00215 
00216 
00217 #define Y_0_TOP 1
00218 #define Y_0_BOTTOM 2
00219 
00220 static INLINE GLuint
00221 st_fb_orientation(const struct gl_framebuffer *fb)
00222 {
00223    if (fb && fb->Name == 0) {
00224       /* Drawing into a window (on-screen buffer).
00225        *
00226        * Negate Y scale to flip image vertically.
00227        * The NDC Y coords prior to viewport transformation are in the range
00228        * [y=-1=bottom, y=1=top]
00229        * Hardware window coords are in the range [y=0=top, y=H-1=bottom] where
00230        * H is the window height.
00231        * Use the viewport transformation to invert Y.
00232        */
00233       return Y_0_TOP;
00234    }
00235    else {
00236       /* Drawing into user-created FBO (very likely a texture).
00237        *
00238        * For textures, T=0=Bottom, so by extension Y=0=Bottom for rendering.
00239        */
00240       return Y_0_BOTTOM;
00241    }
00242 }
00243 
00244 
00245 extern int
00246 st_get_msaa(void);
00247 
00248 
00249 #endif

Generated on Tue Sep 29 06:25:18 2009 for Gallium3D by  doxygen 1.5.4