Home | History | Annotate | Download | only in common
      1 /*
      2  * Mesa 3-D graphics library
      3  *
      4  * Copyright (C) 2009  VMware, Inc.  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 "Software"),
      8  * to deal in the Software without restriction, including without limitation
      9  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
     10  * and/or sell copies of the Software, and to permit persons to whom the
     11  * Software is furnished to do so, subject to the following conditions:
     12  *
     13  * The above copyright notice and this permission notice shall be included
     14  * in all copies or substantial portions of the Software.
     15  *
     16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
     17  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
     19  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
     20  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
     21  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
     22  * OTHER DEALINGS IN THE SOFTWARE.
     23  */
     24 
     25 
     26 #ifndef META_H
     27 #define META_H
     28 
     29 #include "main/mtypes.h"
     30 
     31 /**
     32  * \name Flags for meta operations
     33  * \{
     34  *
     35  * These flags are passed to _mesa_meta_begin().
     36  */
     37 #define MESA_META_ALL                      ~0x0
     38 #define MESA_META_ALPHA_TEST                0x1
     39 #define MESA_META_BLEND                     0x2  /**< includes logicop */
     40 #define MESA_META_COLOR_MASK                0x4
     41 #define MESA_META_DEPTH_TEST                0x8
     42 #define MESA_META_FOG                      0x10
     43 #define MESA_META_PIXEL_STORE              0x20
     44 #define MESA_META_PIXEL_TRANSFER           0x40
     45 #define MESA_META_RASTERIZATION            0x80
     46 #define MESA_META_SCISSOR                 0x100
     47 #define MESA_META_SHADER                  0x200
     48 #define MESA_META_STENCIL_TEST            0x400
     49 #define MESA_META_TRANSFORM               0x800 /**< modelview/projection matrix state */
     50 #define MESA_META_TEXTURE                0x1000
     51 #define MESA_META_VERTEX                 0x2000
     52 #define MESA_META_VIEWPORT               0x4000
     53 #define MESA_META_CLAMP_FRAGMENT_COLOR   0x8000
     54 #define MESA_META_CLAMP_VERTEX_COLOR    0x10000
     55 #define MESA_META_CONDITIONAL_RENDER    0x20000
     56 #define MESA_META_CLIP                  0x40000
     57 #define MESA_META_SELECT_FEEDBACK       0x80000
     58 #define MESA_META_MULTISAMPLE          0x100000
     59 #define MESA_META_FRAMEBUFFER_SRGB     0x200000
     60 #define MESA_META_OCCLUSION_QUERY      0x400000
     61 #define MESA_META_DRAW_BUFFERS         0x800000
     62 #define MESA_META_DITHER              0x1000000
     63 /**\}*/
     64 
     65 /**
     66  * State which we may save/restore across meta ops.
     67  * XXX this may be incomplete...
     68  */
     69 struct save_state
     70 {
     71    GLbitfield SavedState;  /**< bitmask of MESA_META_* flags */
     72 
     73    /* Always saved/restored with meta. */
     74    gl_api API;
     75    uint8_t ExtensionsVersion;
     76 
     77    /** MESA_META_CLEAR (and others?) */
     78    struct gl_query_object *CurrentOcclusionObject;
     79 
     80    /** MESA_META_ALPHA_TEST */
     81    GLboolean AlphaEnabled;
     82    GLenum AlphaFunc;
     83    GLclampf AlphaRef;
     84 
     85    /** MESA_META_BLEND */
     86    GLbitfield BlendEnabled;
     87    GLboolean ColorLogicOpEnabled;
     88 
     89    /** MESA_META_DITHER */
     90    GLboolean DitherFlag;
     91 
     92    /** MESA_META_COLOR_MASK */
     93    GLubyte ColorMask[MAX_DRAW_BUFFERS][4];
     94 
     95    /** MESA_META_DEPTH_TEST */
     96    struct gl_depthbuffer_attrib Depth;
     97 
     98    /** MESA_META_FOG */
     99    GLboolean Fog;
    100 
    101    /** MESA_META_PIXEL_STORE */
    102    struct gl_pixelstore_attrib Pack, Unpack;
    103 
    104    /** MESA_META_PIXEL_TRANSFER */
    105    GLfloat RedBias, RedScale;
    106    GLfloat GreenBias, GreenScale;
    107    GLfloat BlueBias, BlueScale;
    108    GLfloat AlphaBias, AlphaScale;
    109    GLfloat DepthBias, DepthScale;
    110    GLboolean MapColorFlag;
    111 
    112    /** MESA_META_RASTERIZATION */
    113    GLenum FrontPolygonMode, BackPolygonMode;
    114    GLboolean PolygonOffset;
    115    GLboolean PolygonSmooth;
    116    GLboolean PolygonStipple;
    117    GLboolean PolygonCull;
    118 
    119    /** MESA_META_SCISSOR */
    120    struct gl_scissor_attrib Scissor;
    121 
    122    /** MESA_META_SHADER */
    123    GLboolean VertexProgramEnabled;
    124    struct gl_program *VertexProgram;
    125    GLboolean FragmentProgramEnabled;
    126    struct gl_program *FragmentProgram;
    127    GLboolean ATIFragmentShaderEnabled;
    128    struct gl_shader_program *Shader[MESA_SHADER_STAGES];
    129    struct gl_shader_program *ActiveShader;
    130    struct gl_pipeline_object   *Pipeline;
    131 
    132    /** MESA_META_STENCIL_TEST */
    133    struct gl_stencil_attrib Stencil;
    134 
    135    /** MESA_META_TRANSFORM */
    136    GLenum MatrixMode;
    137    GLfloat ModelviewMatrix[16];
    138    GLfloat ProjectionMatrix[16];
    139    GLfloat TextureMatrix[16];
    140    /** GL_ARB_clip_control */
    141    GLenum ClipOrigin;     /**< GL_LOWER_LEFT or GL_UPPER_LEFT */
    142    GLenum ClipDepthMode;  /**< GL_NEGATIVE_ONE_TO_ONE or GL_ZERO_TO_ONE */
    143 
    144    /** MESA_META_CLIP */
    145    GLbitfield ClipPlanesEnabled;
    146 
    147    /** MESA_META_TEXTURE */
    148    GLuint ActiveUnit;
    149    /** for unit[0] only */
    150    struct gl_texture_object *CurrentTexture[NUM_TEXTURE_TARGETS];
    151    /** mask of TEXTURE_2D_BIT, etc */
    152    GLbitfield TexEnabled[MAX_TEXTURE_UNITS];
    153    GLbitfield TexGenEnabled[MAX_TEXTURE_UNITS];
    154    GLuint EnvMode;  /* unit[0] only */
    155 
    156    /** MESA_META_VERTEX */
    157    struct gl_vertex_array_object *VAO;
    158 
    159    /** MESA_META_VIEWPORT */
    160    GLfloat ViewportX, ViewportY, ViewportW, ViewportH;
    161    GLclampd DepthNear, DepthFar;
    162 
    163    /** MESA_META_CLAMP_FRAGMENT_COLOR */
    164    GLenum ClampFragmentColor;
    165 
    166    /** MESA_META_CLAMP_VERTEX_COLOR */
    167    GLenum ClampVertexColor;
    168 
    169    /** MESA_META_CONDITIONAL_RENDER */
    170    struct gl_query_object *CondRenderQuery;
    171    GLenum CondRenderMode;
    172 
    173    /** MESA_META_SELECT_FEEDBACK */
    174    GLenum RenderMode;
    175    struct gl_selection Select;
    176    struct gl_feedback Feedback;
    177 
    178    /** MESA_META_MULTISAMPLE */
    179    struct gl_multisample_attrib Multisample;
    180 
    181    /** MESA_META_FRAMEBUFFER_SRGB */
    182    GLboolean sRGBEnabled;
    183 
    184    /** Miscellaneous (always disabled) */
    185    GLboolean Lighting;
    186    GLboolean RasterDiscard;
    187    GLboolean TransformFeedbackNeedsResume;
    188 
    189    struct gl_framebuffer *DrawBuffer;
    190    struct gl_framebuffer *ReadBuffer;
    191 
    192    /** MESA_META_DRAW_BUFFERS */
    193    GLenum ColorDrawBuffers[MAX_DRAW_BUFFERS];
    194 };
    195 
    196 /**
    197  * Temporary texture used for glBlitFramebuffer, glDrawPixels, etc.
    198  * This is currently shared by all the meta ops.  But we could create a
    199  * separate one for each of glDrawPixel, glBlitFramebuffer, glCopyPixels, etc.
    200  */
    201 struct temp_texture
    202 {
    203    GLuint TexObj;
    204    GLenum Target;         /**< GL_TEXTURE_2D or GL_TEXTURE_RECTANGLE */
    205    GLsizei MinSize;       /**< Min texture size to allocate */
    206    GLsizei MaxSize;       /**< Max possible texture size */
    207    GLboolean NPOT;        /**< Non-power of two size OK? */
    208    GLsizei Width, Height; /**< Current texture size */
    209    GLenum IntFormat;
    210    GLfloat Sright, Ttop;  /**< right, top texcoords */
    211 };
    212 
    213 /**
    214  * State for GLSL texture sampler which is used to generate fragment
    215  * shader in _mesa_meta_generate_mipmap().
    216  */
    217 struct blit_shader {
    218    const char *type;
    219    const char *func;
    220    const char *texcoords;
    221    struct gl_shader_program *shader_prog;
    222 };
    223 
    224 /**
    225  * Table of all sampler types and shaders for accessing them.
    226  */
    227 struct blit_shader_table {
    228    struct blit_shader sampler_1d;
    229    struct blit_shader sampler_2d;
    230    struct blit_shader sampler_3d;
    231    struct blit_shader sampler_rect;
    232    struct blit_shader sampler_cubemap;
    233    struct blit_shader sampler_1d_array;
    234    struct blit_shader sampler_2d_array;
    235    struct blit_shader sampler_cubemap_array;
    236 };
    237 
    238 /**
    239  * Indices in the blit_state->msaa_shaders[] array
    240  *
    241  * Note that setup_glsl_msaa_blit_shader() assumes that the _INT enums are five
    242  * more than the corresponding non-_INT versions and _UINT are five beyond that.
    243  */
    244 enum blit_msaa_shader {
    245    BLIT_1X_MSAA_SHADER_2D_MULTISAMPLE_RESOLVE,
    246    BLIT_2X_MSAA_SHADER_2D_MULTISAMPLE_RESOLVE,
    247    BLIT_4X_MSAA_SHADER_2D_MULTISAMPLE_RESOLVE,
    248    BLIT_8X_MSAA_SHADER_2D_MULTISAMPLE_RESOLVE,
    249    BLIT_16X_MSAA_SHADER_2D_MULTISAMPLE_RESOLVE,
    250    BLIT_1X_MSAA_SHADER_2D_MULTISAMPLE_RESOLVE_INT,
    251    BLIT_2X_MSAA_SHADER_2D_MULTISAMPLE_RESOLVE_INT,
    252    BLIT_4X_MSAA_SHADER_2D_MULTISAMPLE_RESOLVE_INT,
    253    BLIT_8X_MSAA_SHADER_2D_MULTISAMPLE_RESOLVE_INT,
    254    BLIT_16X_MSAA_SHADER_2D_MULTISAMPLE_RESOLVE_INT,
    255    BLIT_1X_MSAA_SHADER_2D_MULTISAMPLE_RESOLVE_UINT,
    256    BLIT_2X_MSAA_SHADER_2D_MULTISAMPLE_RESOLVE_UINT,
    257    BLIT_4X_MSAA_SHADER_2D_MULTISAMPLE_RESOLVE_UINT,
    258    BLIT_8X_MSAA_SHADER_2D_MULTISAMPLE_RESOLVE_UINT,
    259    BLIT_16X_MSAA_SHADER_2D_MULTISAMPLE_RESOLVE_UINT,
    260    BLIT_MSAA_SHADER_2D_MULTISAMPLE_COPY,
    261    BLIT_MSAA_SHADER_2D_MULTISAMPLE_COPY_INT,
    262    BLIT_MSAA_SHADER_2D_MULTISAMPLE_COPY_UINT,
    263    BLIT_MSAA_SHADER_2D_MULTISAMPLE_DEPTH_RESOLVE,
    264    BLIT_MSAA_SHADER_2D_MULTISAMPLE_DEPTH_COPY,
    265    BLIT_1X_MSAA_SHADER_2D_MULTISAMPLE_ARRAY_RESOLVE,
    266    BLIT_2X_MSAA_SHADER_2D_MULTISAMPLE_ARRAY_RESOLVE,
    267    BLIT_4X_MSAA_SHADER_2D_MULTISAMPLE_ARRAY_RESOLVE,
    268    BLIT_8X_MSAA_SHADER_2D_MULTISAMPLE_ARRAY_RESOLVE,
    269    BLIT_16X_MSAA_SHADER_2D_MULTISAMPLE_ARRAY_RESOLVE,
    270    BLIT_1X_MSAA_SHADER_2D_MULTISAMPLE_ARRAY_RESOLVE_INT,
    271    BLIT_2X_MSAA_SHADER_2D_MULTISAMPLE_ARRAY_RESOLVE_INT,
    272    BLIT_4X_MSAA_SHADER_2D_MULTISAMPLE_ARRAY_RESOLVE_INT,
    273    BLIT_8X_MSAA_SHADER_2D_MULTISAMPLE_ARRAY_RESOLVE_INT,
    274    BLIT_16X_MSAA_SHADER_2D_MULTISAMPLE_ARRAY_RESOLVE_INT,
    275    BLIT_1X_MSAA_SHADER_2D_MULTISAMPLE_ARRAY_RESOLVE_UINT,
    276    BLIT_2X_MSAA_SHADER_2D_MULTISAMPLE_ARRAY_RESOLVE_UINT,
    277    BLIT_4X_MSAA_SHADER_2D_MULTISAMPLE_ARRAY_RESOLVE_UINT,
    278    BLIT_8X_MSAA_SHADER_2D_MULTISAMPLE_ARRAY_RESOLVE_UINT,
    279    BLIT_16X_MSAA_SHADER_2D_MULTISAMPLE_ARRAY_RESOLVE_UINT,
    280    BLIT_MSAA_SHADER_2D_MULTISAMPLE_ARRAY_COPY,
    281    BLIT_MSAA_SHADER_2D_MULTISAMPLE_ARRAY_COPY_INT,
    282    BLIT_MSAA_SHADER_2D_MULTISAMPLE_ARRAY_COPY_UINT,
    283    BLIT_MSAA_SHADER_2D_MULTISAMPLE_ARRAY_DEPTH_RESOLVE,
    284    BLIT_MSAA_SHADER_2D_MULTISAMPLE_ARRAY_DEPTH_COPY,
    285    BLIT_2X_MSAA_SHADER_2D_MULTISAMPLE_SCALED_RESOLVE,
    286    BLIT_4X_MSAA_SHADER_2D_MULTISAMPLE_SCALED_RESOLVE,
    287    BLIT_8X_MSAA_SHADER_2D_MULTISAMPLE_SCALED_RESOLVE,
    288    BLIT_16X_MSAA_SHADER_2D_MULTISAMPLE_SCALED_RESOLVE,
    289    BLIT_2X_MSAA_SHADER_2D_MULTISAMPLE_ARRAY_SCALED_RESOLVE,
    290    BLIT_4X_MSAA_SHADER_2D_MULTISAMPLE_ARRAY_SCALED_RESOLVE,
    291    BLIT_8X_MSAA_SHADER_2D_MULTISAMPLE_ARRAY_SCALED_RESOLVE,
    292    BLIT_16X_MSAA_SHADER_2D_MULTISAMPLE_ARRAY_SCALED_RESOLVE,
    293    BLIT_MSAA_SHADER_COUNT,
    294 };
    295 
    296 /**
    297  * State for glBlitFramebufer()
    298  */
    299 struct blit_state
    300 {
    301    GLuint VAO;
    302    struct gl_buffer_object *buf_obj;
    303    struct blit_shader_table shaders_with_depth;
    304    struct blit_shader_table shaders_without_depth;
    305    struct gl_shader_program *msaa_shaders[BLIT_MSAA_SHADER_COUNT];
    306    struct temp_texture depthTex;
    307    bool no_ctsi_fallback;
    308 };
    309 
    310 struct fb_tex_blit_state
    311 {
    312    GLint baseLevelSave, maxLevelSave;
    313    struct gl_sampler_object *samp_obj;
    314    struct gl_sampler_object *samp_obj_save;
    315    GLuint stencilSamplingSave;
    316    GLuint tempTex;
    317 };
    318 
    319 
    320 /**
    321  * State for glClear()
    322  */
    323 struct clear_state
    324 {
    325    GLuint VAO;
    326    struct gl_buffer_object *buf_obj;
    327    struct gl_shader_program *ShaderProg;
    328    struct gl_shader_program *IntegerShaderProg;
    329 };
    330 
    331 
    332 /**
    333  * State for glCopyPixels()
    334  */
    335 struct copypix_state
    336 {
    337    GLuint VAO;
    338    struct gl_buffer_object *buf_obj;
    339 };
    340 
    341 
    342 /**
    343  * State for glDrawPixels()
    344  */
    345 struct drawpix_state
    346 {
    347    GLuint VAO;
    348    struct gl_buffer_object *buf_obj;
    349 
    350    GLuint StencilFP;  /**< Fragment program for drawing stencil images */
    351    GLuint DepthFP;  /**< Fragment program for drawing depth images */
    352 };
    353 
    354 
    355 /**
    356  * State for glBitmap()
    357  */
    358 struct bitmap_state
    359 {
    360    GLuint VAO;
    361    struct gl_buffer_object *buf_obj;
    362    struct temp_texture Tex;  /**< separate texture from other meta ops */
    363 };
    364 
    365 /**
    366  * State for _mesa_meta_generate_mipmap()
    367  */
    368 struct gen_mipmap_state
    369 {
    370    GLuint VAO;
    371    struct gl_buffer_object *buf_obj;
    372    struct gl_framebuffer *fb;
    373    struct gl_sampler_object *samp_obj;
    374 
    375    struct blit_shader_table shaders;
    376 };
    377 
    378 /**
    379  * One of the FBO states for decompress_state. There will be one for each
    380  * required renderbuffer format.
    381  */
    382 struct decompress_fbo_state
    383 {
    384    struct gl_renderbuffer *rb;
    385    struct gl_framebuffer *fb;
    386    GLint Width, Height;
    387 };
    388 
    389 /**
    390  * State for texture decompression
    391  */
    392 struct decompress_state
    393 {
    394    GLuint VAO;
    395    struct decompress_fbo_state byteFBO, floatFBO;
    396    struct gl_buffer_object *buf_obj;
    397    struct gl_sampler_object *samp_obj;
    398 
    399    struct blit_shader_table shaders;
    400 };
    401 
    402 /**
    403  * State for glDrawTex()
    404  */
    405 struct drawtex_state
    406 {
    407    GLuint VAO;
    408    struct gl_buffer_object *buf_obj;
    409 };
    410 
    411 #define MAX_META_OPS_DEPTH      8
    412 /**
    413  * All per-context meta state.
    414  */
    415 struct gl_meta_state
    416 {
    417    /** Stack of state saved during meta-ops */
    418    struct save_state Save[MAX_META_OPS_DEPTH];
    419    /** Save stack depth */
    420    GLuint SaveStackDepth;
    421 
    422    struct temp_texture TempTex;
    423 
    424    struct blit_state Blit;    /**< For _mesa_meta_BlitFramebuffer() */
    425    struct clear_state Clear;  /**< For _mesa_meta_Clear() */
    426    struct copypix_state CopyPix;  /**< For _mesa_meta_CopyPixels() */
    427    struct drawpix_state DrawPix;  /**< For _mesa_meta_DrawPixels() */
    428    struct bitmap_state Bitmap;    /**< For _mesa_meta_Bitmap() */
    429    struct gen_mipmap_state Mipmap;    /**< For _mesa_meta_GenerateMipmap() */
    430    struct decompress_state Decompress;  /**< For texture decompression */
    431    struct drawtex_state DrawTex;  /**< For _mesa_meta_DrawTex() */
    432 };
    433 
    434 struct vertex {
    435    GLfloat x, y, z, tex[4];
    436    GLfloat r, g, b, a;
    437 };
    438 
    439 extern void
    440 _mesa_meta_init(struct gl_context *ctx);
    441 
    442 extern void
    443 _mesa_meta_free(struct gl_context *ctx);
    444 
    445 extern void
    446 _mesa_meta_begin(struct gl_context *ctx, GLbitfield state);
    447 
    448 extern void
    449 _mesa_meta_end(struct gl_context *ctx);
    450 
    451 static inline bool
    452 _mesa_meta_in_progress(struct gl_context *ctx)
    453 {
    454    return ctx->Meta->SaveStackDepth != 0;
    455 }
    456 
    457 extern void
    458 _mesa_meta_fb_tex_blit_begin(struct gl_context *ctx,
    459                              struct fb_tex_blit_state *blit);
    460 
    461 extern void
    462 _mesa_meta_fb_tex_blit_end(struct gl_context *ctx, GLenum target,
    463                            struct fb_tex_blit_state *blit);
    464 
    465 extern GLboolean
    466 _mesa_meta_bind_rb_as_tex_image(struct gl_context *ctx,
    467                                 struct gl_renderbuffer *rb,
    468                                 GLuint *tex,
    469                                 struct gl_texture_object **texObj,
    470                                 GLenum *target);
    471 
    472 struct gl_sampler_object *
    473 _mesa_meta_setup_sampler(struct gl_context *ctx,
    474                          struct gl_texture_object *texObj,
    475                          GLenum target, GLenum filter, GLuint srcLevel);
    476 
    477 extern GLbitfield
    478 _mesa_meta_BlitFramebuffer(struct gl_context *ctx,
    479                            const struct gl_framebuffer *readFb,
    480                            const struct gl_framebuffer *drawFb,
    481                            GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
    482                            GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
    483                            GLbitfield mask, GLenum filter);
    484 
    485 extern void
    486 _mesa_meta_and_swrast_BlitFramebuffer(struct gl_context *ctx,
    487                                       struct gl_framebuffer *readFb,
    488                                       struct gl_framebuffer *drawFb,
    489                                       GLint srcX0, GLint srcY0,
    490                                       GLint srcX1, GLint srcY1,
    491                                       GLint dstX0, GLint dstY0,
    492                                       GLint dstX1, GLint dstY1,
    493                                       GLbitfield mask, GLenum filter);
    494 
    495 extern void
    496 _mesa_meta_Clear(struct gl_context *ctx, GLbitfield buffers);
    497 
    498 extern void
    499 _mesa_meta_glsl_Clear(struct gl_context *ctx, GLbitfield buffers);
    500 
    501 extern void
    502 _mesa_meta_CopyPixels(struct gl_context *ctx, GLint srcx, GLint srcy,
    503                       GLsizei width, GLsizei height,
    504                       GLint dstx, GLint dsty, GLenum type);
    505 
    506 extern void
    507 _mesa_meta_DrawPixels(struct gl_context *ctx,
    508                       GLint x, GLint y, GLsizei width, GLsizei height,
    509                       GLenum format, GLenum type,
    510                       const struct gl_pixelstore_attrib *unpack,
    511                       const GLvoid *pixels);
    512 
    513 extern void
    514 _mesa_meta_Bitmap(struct gl_context *ctx,
    515                   GLint x, GLint y, GLsizei width, GLsizei height,
    516                   const struct gl_pixelstore_attrib *unpack,
    517                   const GLubyte *bitmap);
    518 
    519 extern void
    520 _mesa_meta_GenerateMipmap(struct gl_context *ctx, GLenum target,
    521                           struct gl_texture_object *texObj);
    522 
    523 extern bool
    524 _mesa_meta_pbo_TexSubImage(struct gl_context *ctx, GLuint dims,
    525                            struct gl_texture_image *tex_image,
    526                            int xoffset, int yoffset, int zoffset,
    527                            int width, int height, int depth,
    528                            GLenum format, GLenum type, const void *pixels,
    529                            bool create_pbo,
    530                            const struct gl_pixelstore_attrib *packing);
    531 
    532 extern bool
    533 _mesa_meta_pbo_GetTexSubImage(struct gl_context *ctx, GLuint dims,
    534                               struct gl_texture_image *tex_image,
    535                               int xoffset, int yoffset, int zoffset,
    536                               int width, int height, int depth,
    537                               GLenum format, GLenum type, const void *pixels,
    538                               const struct gl_pixelstore_attrib *packing);
    539 
    540 extern void
    541 _mesa_meta_CopyTexSubImage(struct gl_context *ctx, GLuint dims,
    542                            struct gl_texture_image *texImage,
    543                            GLint xoffset, GLint yoffset, GLint slice,
    544                            struct gl_renderbuffer *rb,
    545                            GLint x, GLint y,
    546                            GLsizei width, GLsizei height);
    547 
    548 extern void
    549 _mesa_meta_ClearTexSubImage(struct gl_context *ctx,
    550                             struct gl_texture_image *texImage,
    551                             GLint xoffset, GLint yoffset, GLint zoffset,
    552                             GLsizei width, GLsizei height, GLsizei depth,
    553                             const GLvoid *clearValue);
    554 
    555 extern void
    556 _mesa_meta_GetTexSubImage(struct gl_context *ctx,
    557                           GLint xoffset, GLint yoffset, GLint zoffset,
    558                           GLsizei width, GLsizei height, GLsizei depth,
    559                           GLenum format, GLenum type, GLvoid *pixels,
    560                           struct gl_texture_image *texImage);
    561 
    562 extern void
    563 _mesa_meta_DrawTex(struct gl_context *ctx, GLfloat x, GLfloat y, GLfloat z,
    564                    GLfloat width, GLfloat height);
    565 
    566 /* meta-internal functions */
    567 void
    568 _mesa_meta_drawbuffers_from_bitfield(GLbitfield bits);
    569 
    570 void
    571 _mesa_meta_link_program_with_debug(struct gl_context *ctx,
    572                                    struct gl_shader_program *sh_prog);
    573 
    574 void
    575 _mesa_meta_compile_and_link_program(struct gl_context *ctx,
    576                                     const char *vs_source,
    577                                     const char *fs_source,
    578                                     const char *name,
    579                                     struct gl_shader_program **sh_prog_ptr);
    580 
    581 extern void
    582 _mesa_meta_use_program(struct gl_context *ctx,
    583                        struct gl_shader_program *sh_prog);
    584 
    585 GLboolean
    586 _mesa_meta_alloc_texture(struct temp_texture *tex,
    587                          GLsizei width, GLsizei height, GLenum intFormat);
    588 
    589 void
    590 _mesa_meta_setup_texture_coords(GLenum faceTarget,
    591                                 GLint slice,
    592                                 GLint xoffset,
    593                                 GLint yoffset,
    594                                 GLint width,
    595                                 GLint height,
    596                                 GLint total_width,
    597                                 GLint total_height,
    598                                 GLint total_depth,
    599                                 GLfloat coords0[4],
    600                                 GLfloat coords1[4],
    601                                 GLfloat coords2[4],
    602                                 GLfloat coords3[4]);
    603 
    604 struct temp_texture *
    605 _mesa_meta_get_temp_texture(struct gl_context *ctx);
    606 
    607 struct temp_texture *
    608 _mesa_meta_get_temp_depth_texture(struct gl_context *ctx);
    609 
    610 void
    611 _mesa_meta_setup_vertex_objects(struct gl_context *ctx,
    612                                 GLuint *VAO, struct gl_buffer_object **buf_obj,
    613                                 bool use_generic_attributes,
    614                                 unsigned vertex_size, unsigned texcoord_size,
    615                                 unsigned color_size);
    616 
    617 void
    618 _mesa_meta_setup_ff_tnl_for_blit(struct gl_context *ctx,
    619                                  GLuint *VAO, struct gl_buffer_object **buf_obj,
    620                                  unsigned texcoord_size);
    621 
    622 void
    623 _mesa_meta_setup_drawpix_texture(struct gl_context *ctx,
    624                                  struct temp_texture *tex,
    625                                  GLboolean newTex,
    626                                  GLsizei width, GLsizei height,
    627                                  GLenum format, GLenum type,
    628                                  const GLvoid *pixels);
    629 
    630 void
    631 _mesa_meta_setup_copypix_texture(struct gl_context *ctx,
    632                                  struct temp_texture *tex,
    633                                  GLint srcX, GLint srcY,
    634                                  GLsizei width, GLsizei height,
    635                                  GLenum intFormat,
    636                                  GLenum filter);
    637 
    638 void
    639 _mesa_meta_setup_blit_shader(struct gl_context *ctx,
    640                              GLenum target,
    641                              bool do_depth,
    642                              struct blit_shader_table *table);
    643 
    644 void
    645 _mesa_meta_glsl_blit_cleanup(struct gl_context *ctx, struct blit_state *blit);
    646 
    647 void
    648 _mesa_meta_blit_shader_table_cleanup(struct gl_context *ctx,
    649                                      struct blit_shader_table *table);
    650 
    651 void
    652 _mesa_meta_glsl_generate_mipmap_cleanup(struct gl_context *ctx,
    653                                         struct gen_mipmap_state *mipmap);
    654 
    655 void
    656 _mesa_meta_framebuffer_texture_image(struct gl_context *ctx,
    657                                      struct gl_framebuffer *fb,
    658                                      GLenum attachment,
    659                                      struct gl_texture_image *texImage,
    660                                      GLuint layer);
    661 
    662 #endif /* META_H */
    663