diff options
author | marha <marha@users.sourceforge.net> | 2011-01-25 07:15:07 +0000 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2011-01-25 07:15:07 +0000 |
commit | db83ae15824cd5a710d61684733f3dc09517748b (patch) | |
tree | 0593f2485d27f1e21bfa883eb9e8a6446018b83a /mesalib/src/mesa | |
parent | 75c2deab5262ebfb4aea4fe63e144488150f921a (diff) | |
download | vcxsrv-db83ae15824cd5a710d61684733f3dc09517748b.tar.gz vcxsrv-db83ae15824cd5a710d61684733f3dc09517748b.tar.bz2 vcxsrv-db83ae15824cd5a710d61684733f3dc09517748b.zip |
mesa git update 25 jan 2011
Diffstat (limited to 'mesalib/src/mesa')
-rw-r--r-- | mesalib/src/mesa/drivers/common/driverfuncs.c | 651 | ||||
-rw-r--r-- | mesalib/src/mesa/main/APIspec.xml | 8755 | ||||
-rw-r--r-- | mesalib/src/mesa/main/fbobject.c | 135 | ||||
-rw-r--r-- | mesalib/src/mesa/main/fbobject.h | 345 | ||||
-rw-r--r-- | mesalib/src/mesa/main/renderbuffer.c | 4020 | ||||
-rw-r--r-- | mesalib/src/mesa/main/teximage.c | 6981 | ||||
-rw-r--r-- | mesalib/src/mesa/state_tracker/st_extensions.c | 2 | ||||
-rw-r--r-- | mesalib/src/mesa/state_tracker/st_format.c | 2191 | ||||
-rw-r--r-- | mesalib/src/mesa/x86/read_rgba_span_x86.S | 1356 |
9 files changed, 12299 insertions, 12137 deletions
diff --git a/mesalib/src/mesa/drivers/common/driverfuncs.c b/mesalib/src/mesa/drivers/common/driverfuncs.c index e5a5a6174..5389a5001 100644 --- a/mesalib/src/mesa/drivers/common/driverfuncs.c +++ b/mesalib/src/mesa/drivers/common/driverfuncs.c @@ -1,325 +1,326 @@ -/*
- * Mesa 3-D graphics library
- * Version: 7.1
- *
- * Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-
-#include "main/glheader.h"
-#include "main/imports.h"
-#include "main/arrayobj.h"
-#include "main/context.h"
-#include "main/framebuffer.h"
-#include "main/mipmap.h"
-#include "main/queryobj.h"
-#include "main/renderbuffer.h"
-#include "main/shaderobj.h"
-#include "main/texcompress.h"
-#include "main/texformat.h"
-#include "main/texgetimage.h"
-#include "main/teximage.h"
-#include "main/texobj.h"
-#include "main/texstore.h"
-#include "main/bufferobj.h"
-#include "main/fbobject.h"
-#include "main/texrender.h"
-#include "main/syncobj.h"
-#include "main/transformfeedback.h"
-
-#include "program/program.h"
-#include "tnl/tnl.h"
-#include "swrast/swrast.h"
-
-#include "driverfuncs.h"
-#include "meta.h"
-
-
-
-/**
- * Plug in default functions for all pointers in the dd_function_table
- * structure.
- * Device drivers should call this function and then plug in any
- * functions which it wants to override.
- * Some functions (pointers) MUST be implemented by all drivers (REQUIRED).
- *
- * \param table the dd_function_table to initialize
- */
-void
-_mesa_init_driver_functions(struct dd_function_table *driver)
-{
- memset(driver, 0, sizeof(*driver));
-
- driver->GetString = NULL; /* REQUIRED! */
- driver->UpdateState = NULL; /* REQUIRED! */
- driver->GetBufferSize = NULL; /* REQUIRED! */
- driver->ResizeBuffers = _mesa_resize_framebuffer;
- driver->Error = NULL;
-
- driver->Finish = NULL;
- driver->Flush = NULL;
-
- /* framebuffer/image functions */
- driver->Clear = _swrast_Clear;
- driver->Accum = _swrast_Accum;
- driver->RasterPos = _tnl_RasterPos;
- driver->DrawPixels = _swrast_DrawPixels;
- driver->ReadPixels = _swrast_ReadPixels;
- driver->CopyPixels = _swrast_CopyPixels;
- driver->Bitmap = _swrast_Bitmap;
-
- /* Texture functions */
- driver->ChooseTextureFormat = _mesa_choose_tex_format;
- driver->TexImage1D = _mesa_store_teximage1d;
- driver->TexImage2D = _mesa_store_teximage2d;
- driver->TexImage3D = _mesa_store_teximage3d;
- driver->TexSubImage1D = _mesa_store_texsubimage1d;
- driver->TexSubImage2D = _mesa_store_texsubimage2d;
- driver->TexSubImage3D = _mesa_store_texsubimage3d;
- driver->GetTexImage = _mesa_get_teximage;
- driver->CopyTexImage1D = _mesa_meta_CopyTexImage1D;
- driver->CopyTexImage2D = _mesa_meta_CopyTexImage2D;
- driver->CopyTexSubImage1D = _mesa_meta_CopyTexSubImage1D;
- driver->CopyTexSubImage2D = _mesa_meta_CopyTexSubImage2D;
- driver->CopyTexSubImage3D = _mesa_meta_CopyTexSubImage3D;
- driver->GenerateMipmap = _mesa_meta_GenerateMipmap;
- driver->TestProxyTexImage = _mesa_test_proxy_teximage;
- driver->CompressedTexImage1D = _mesa_store_compressed_teximage1d;
- driver->CompressedTexImage2D = _mesa_store_compressed_teximage2d;
- driver->CompressedTexImage3D = _mesa_store_compressed_teximage3d;
- driver->CompressedTexSubImage1D = _mesa_store_compressed_texsubimage1d;
- driver->CompressedTexSubImage2D = _mesa_store_compressed_texsubimage2d;
- driver->CompressedTexSubImage3D = _mesa_store_compressed_texsubimage3d;
- driver->GetCompressedTexImage = _mesa_get_compressed_teximage;
- driver->BindTexture = NULL;
- driver->NewTextureObject = _mesa_new_texture_object;
- driver->DeleteTexture = _mesa_delete_texture_object;
- driver->NewTextureImage = _mesa_new_texture_image;
- driver->FreeTexImageData = _mesa_free_texture_image_data;
- driver->MapTexture = NULL;
- driver->UnmapTexture = NULL;
- driver->TextureMemCpy = memcpy;
- driver->IsTextureResident = NULL;
- driver->UpdateTexturePalette = NULL;
-
- /* imaging */
- driver->CopyColorTable = _mesa_meta_CopyColorTable;
- driver->CopyColorSubTable = _mesa_meta_CopyColorSubTable;
-
- /* Vertex/fragment programs */
- driver->BindProgram = NULL;
- driver->NewProgram = _mesa_new_program;
- driver->DeleteProgram = _mesa_delete_program;
-
- /* simple state commands */
- driver->AlphaFunc = NULL;
- driver->BlendColor = NULL;
- driver->BlendEquationSeparate = NULL;
- driver->BlendFuncSeparate = NULL;
- driver->ClearColor = NULL;
- driver->ClearDepth = NULL;
- driver->ClearStencil = NULL;
- driver->ClipPlane = NULL;
- driver->ColorMask = NULL;
- driver->ColorMaterial = NULL;
- driver->CullFace = NULL;
- driver->DrawBuffer = NULL;
- driver->DrawBuffers = NULL;
- driver->FrontFace = NULL;
- driver->DepthFunc = NULL;
- driver->DepthMask = NULL;
- driver->DepthRange = NULL;
- driver->Enable = NULL;
- driver->Fogfv = NULL;
- driver->Hint = NULL;
- driver->Lightfv = NULL;
- driver->LightModelfv = NULL;
- driver->LineStipple = NULL;
- driver->LineWidth = NULL;
- driver->LogicOpcode = NULL;
- driver->PointParameterfv = NULL;
- driver->PointSize = NULL;
- driver->PolygonMode = NULL;
- driver->PolygonOffset = NULL;
- driver->PolygonStipple = NULL;
- driver->ReadBuffer = NULL;
- driver->RenderMode = NULL;
- driver->Scissor = NULL;
- driver->ShadeModel = NULL;
- driver->StencilFuncSeparate = NULL;
- driver->StencilOpSeparate = NULL;
- driver->StencilMaskSeparate = NULL;
- driver->TexGen = NULL;
- driver->TexEnv = NULL;
- driver->TexParameter = NULL;
- driver->Viewport = NULL;
-
- /* buffer objects */
- _mesa_init_buffer_object_functions(driver);
-
- /* query objects */
- _mesa_init_query_object_functions(driver);
-
- _mesa_init_sync_object_functions(driver);
-
- driver->NewFramebuffer = _mesa_new_framebuffer;
- driver->NewRenderbuffer = _mesa_new_soft_renderbuffer;
- driver->RenderTexture = _mesa_render_texture;
- driver->FinishRenderTexture = _mesa_finish_render_texture;
- driver->FramebufferRenderbuffer = _mesa_framebuffer_renderbuffer;
-
- driver->BlitFramebuffer = _swrast_BlitFramebuffer;
-
- /* APPLE_vertex_array_object */
- driver->NewArrayObject = _mesa_new_array_object;
- driver->DeleteArrayObject = _mesa_delete_array_object;
- driver->BindArrayObject = NULL;
-
- _mesa_init_shader_object_functions(driver);
-
- _mesa_init_transform_feedback_functions(driver);
-
- /* T&L stuff */
- driver->NeedValidate = GL_FALSE;
- driver->ValidateTnlModule = NULL;
- driver->CurrentExecPrimitive = 0;
- driver->CurrentSavePrimitive = 0;
- driver->NeedFlush = 0;
- driver->SaveNeedFlush = 0;
-
- driver->ProgramStringNotify = _tnl_program_string;
- driver->FlushVertices = NULL;
- driver->SaveFlushVertices = NULL;
- driver->NotifySaveBegin = NULL;
- driver->LightingSpaceChange = NULL;
-
- /* display list */
- driver->NewList = NULL;
- driver->EndList = NULL;
- driver->BeginCallList = NULL;
- driver->EndCallList = NULL;
-}
-
-
-/**
- * Call the ctx->Driver.* state functions with current values to initialize
- * driver state.
- * Only the Intel drivers use this so far.
- */
-void
-_mesa_init_driver_state(struct gl_context *ctx)
-{
- ctx->Driver.AlphaFunc(ctx, ctx->Color.AlphaFunc, ctx->Color.AlphaRef);
-
- ctx->Driver.BlendColor(ctx, ctx->Color.BlendColor);
-
- ctx->Driver.BlendEquationSeparate(ctx,
- ctx->Color.Blend[0].EquationRGB,
- ctx->Color.Blend[0].EquationA);
-
- ctx->Driver.BlendFuncSeparate(ctx,
- ctx->Color.Blend[0].SrcRGB,
- ctx->Color.Blend[0].DstRGB,
- ctx->Color.Blend[0].SrcA,
- ctx->Color.Blend[0].DstA);
-
- if (ctx->Driver.ColorMaskIndexed) {
- GLuint i;
- for (i = 0; i < ctx->Const.MaxDrawBuffers; i++) {
- ctx->Driver.ColorMaskIndexed(ctx, i,
- ctx->Color.ColorMask[0][RCOMP],
- ctx->Color.ColorMask[0][GCOMP],
- ctx->Color.ColorMask[0][BCOMP],
- ctx->Color.ColorMask[0][ACOMP]);
- }
- }
- else {
- ctx->Driver.ColorMask(ctx,
- ctx->Color.ColorMask[0][RCOMP],
- ctx->Color.ColorMask[0][GCOMP],
- ctx->Color.ColorMask[0][BCOMP],
- ctx->Color.ColorMask[0][ACOMP]);
- }
-
- ctx->Driver.CullFace(ctx, ctx->Polygon.CullFaceMode);
- ctx->Driver.DepthFunc(ctx, ctx->Depth.Func);
- ctx->Driver.DepthMask(ctx, ctx->Depth.Mask);
-
- ctx->Driver.Enable(ctx, GL_ALPHA_TEST, ctx->Color.AlphaEnabled);
- ctx->Driver.Enable(ctx, GL_BLEND, ctx->Color.BlendEnabled);
- ctx->Driver.Enable(ctx, GL_COLOR_LOGIC_OP, ctx->Color.ColorLogicOpEnabled);
- ctx->Driver.Enable(ctx, GL_COLOR_SUM, ctx->Fog.ColorSumEnabled);
- ctx->Driver.Enable(ctx, GL_CULL_FACE, ctx->Polygon.CullFlag);
- ctx->Driver.Enable(ctx, GL_DEPTH_TEST, ctx->Depth.Test);
- ctx->Driver.Enable(ctx, GL_DITHER, ctx->Color.DitherFlag);
- ctx->Driver.Enable(ctx, GL_FOG, ctx->Fog.Enabled);
- ctx->Driver.Enable(ctx, GL_LIGHTING, ctx->Light.Enabled);
- ctx->Driver.Enable(ctx, GL_LINE_SMOOTH, ctx->Line.SmoothFlag);
- ctx->Driver.Enable(ctx, GL_POLYGON_STIPPLE, ctx->Polygon.StippleFlag);
- ctx->Driver.Enable(ctx, GL_SCISSOR_TEST, ctx->Scissor.Enabled);
- ctx->Driver.Enable(ctx, GL_STENCIL_TEST, ctx->Stencil._Enabled);
- ctx->Driver.Enable(ctx, GL_TEXTURE_1D, GL_FALSE);
- ctx->Driver.Enable(ctx, GL_TEXTURE_2D, GL_FALSE);
- ctx->Driver.Enable(ctx, GL_TEXTURE_RECTANGLE_NV, GL_FALSE);
- ctx->Driver.Enable(ctx, GL_TEXTURE_3D, GL_FALSE);
- ctx->Driver.Enable(ctx, GL_TEXTURE_CUBE_MAP, GL_FALSE);
-
- ctx->Driver.Fogfv(ctx, GL_FOG_COLOR, ctx->Fog.Color);
- ctx->Driver.Fogfv(ctx, GL_FOG_MODE, 0);
- ctx->Driver.Fogfv(ctx, GL_FOG_DENSITY, &ctx->Fog.Density);
- ctx->Driver.Fogfv(ctx, GL_FOG_START, &ctx->Fog.Start);
- ctx->Driver.Fogfv(ctx, GL_FOG_END, &ctx->Fog.End);
-
- ctx->Driver.FrontFace(ctx, ctx->Polygon.FrontFace);
-
- {
- GLfloat f = (GLfloat) ctx->Light.Model.ColorControl;
- ctx->Driver.LightModelfv(ctx, GL_LIGHT_MODEL_COLOR_CONTROL, &f);
- }
-
- ctx->Driver.LineWidth(ctx, ctx->Line.Width);
- ctx->Driver.LogicOpcode(ctx, ctx->Color.LogicOp);
- ctx->Driver.PointSize(ctx, ctx->Point.Size);
- ctx->Driver.PolygonStipple(ctx, (const GLubyte *) ctx->PolygonStipple);
- ctx->Driver.Scissor(ctx, ctx->Scissor.X, ctx->Scissor.Y,
- ctx->Scissor.Width, ctx->Scissor.Height);
- ctx->Driver.ShadeModel(ctx, ctx->Light.ShadeModel);
- ctx->Driver.StencilFuncSeparate(ctx, GL_FRONT,
- ctx->Stencil.Function[0],
- ctx->Stencil.Ref[0],
- ctx->Stencil.ValueMask[0]);
- ctx->Driver.StencilFuncSeparate(ctx, GL_BACK,
- ctx->Stencil.Function[1],
- ctx->Stencil.Ref[1],
- ctx->Stencil.ValueMask[1]);
- ctx->Driver.StencilMaskSeparate(ctx, GL_FRONT, ctx->Stencil.WriteMask[0]);
- ctx->Driver.StencilMaskSeparate(ctx, GL_BACK, ctx->Stencil.WriteMask[1]);
- ctx->Driver.StencilOpSeparate(ctx, GL_FRONT,
- ctx->Stencil.FailFunc[0],
- ctx->Stencil.ZFailFunc[0],
- ctx->Stencil.ZPassFunc[0]);
- ctx->Driver.StencilOpSeparate(ctx, GL_BACK,
- ctx->Stencil.FailFunc[1],
- ctx->Stencil.ZFailFunc[1],
- ctx->Stencil.ZPassFunc[1]);
-
-
- ctx->Driver.DrawBuffer(ctx, ctx->Color.DrawBuffer[0]);
-}
+/* + * Mesa 3-D graphics library + * Version: 7.1 + * + * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#include "main/glheader.h" +#include "main/imports.h" +#include "main/arrayobj.h" +#include "main/context.h" +#include "main/framebuffer.h" +#include "main/mipmap.h" +#include "main/queryobj.h" +#include "main/renderbuffer.h" +#include "main/shaderobj.h" +#include "main/texcompress.h" +#include "main/texformat.h" +#include "main/texgetimage.h" +#include "main/teximage.h" +#include "main/texobj.h" +#include "main/texstore.h" +#include "main/bufferobj.h" +#include "main/fbobject.h" +#include "main/texrender.h" +#include "main/syncobj.h" +#include "main/transformfeedback.h" + +#include "program/program.h" +#include "tnl/tnl.h" +#include "swrast/swrast.h" + +#include "driverfuncs.h" +#include "meta.h" + + + +/** + * Plug in default functions for all pointers in the dd_function_table + * structure. + * Device drivers should call this function and then plug in any + * functions which it wants to override. + * Some functions (pointers) MUST be implemented by all drivers (REQUIRED). + * + * \param table the dd_function_table to initialize + */ +void +_mesa_init_driver_functions(struct dd_function_table *driver) +{ + memset(driver, 0, sizeof(*driver)); + + driver->GetString = NULL; /* REQUIRED! */ + driver->UpdateState = NULL; /* REQUIRED! */ + driver->GetBufferSize = NULL; /* REQUIRED! */ + driver->ResizeBuffers = _mesa_resize_framebuffer; + driver->Error = NULL; + + driver->Finish = NULL; + driver->Flush = NULL; + + /* framebuffer/image functions */ + driver->Clear = _swrast_Clear; + driver->Accum = _swrast_Accum; + driver->RasterPos = _tnl_RasterPos; + driver->DrawPixels = _swrast_DrawPixels; + driver->ReadPixels = _swrast_ReadPixels; + driver->CopyPixels = _swrast_CopyPixels; + driver->Bitmap = _swrast_Bitmap; + + /* Texture functions */ + driver->ChooseTextureFormat = _mesa_choose_tex_format; + driver->TexImage1D = _mesa_store_teximage1d; + driver->TexImage2D = _mesa_store_teximage2d; + driver->TexImage3D = _mesa_store_teximage3d; + driver->TexSubImage1D = _mesa_store_texsubimage1d; + driver->TexSubImage2D = _mesa_store_texsubimage2d; + driver->TexSubImage3D = _mesa_store_texsubimage3d; + driver->GetTexImage = _mesa_get_teximage; + driver->CopyTexImage1D = _mesa_meta_CopyTexImage1D; + driver->CopyTexImage2D = _mesa_meta_CopyTexImage2D; + driver->CopyTexSubImage1D = _mesa_meta_CopyTexSubImage1D; + driver->CopyTexSubImage2D = _mesa_meta_CopyTexSubImage2D; + driver->CopyTexSubImage3D = _mesa_meta_CopyTexSubImage3D; + driver->GenerateMipmap = _mesa_meta_GenerateMipmap; + driver->TestProxyTexImage = _mesa_test_proxy_teximage; + driver->CompressedTexImage1D = _mesa_store_compressed_teximage1d; + driver->CompressedTexImage2D = _mesa_store_compressed_teximage2d; + driver->CompressedTexImage3D = _mesa_store_compressed_teximage3d; + driver->CompressedTexSubImage1D = _mesa_store_compressed_texsubimage1d; + driver->CompressedTexSubImage2D = _mesa_store_compressed_texsubimage2d; + driver->CompressedTexSubImage3D = _mesa_store_compressed_texsubimage3d; + driver->GetCompressedTexImage = _mesa_get_compressed_teximage; + driver->BindTexture = NULL; + driver->NewTextureObject = _mesa_new_texture_object; + driver->DeleteTexture = _mesa_delete_texture_object; + driver->NewTextureImage = _mesa_new_texture_image; + driver->FreeTexImageData = _mesa_free_texture_image_data; + driver->MapTexture = NULL; + driver->UnmapTexture = NULL; + driver->TextureMemCpy = memcpy; + driver->IsTextureResident = NULL; + driver->UpdateTexturePalette = NULL; + + /* imaging */ + driver->CopyColorTable = _mesa_meta_CopyColorTable; + driver->CopyColorSubTable = _mesa_meta_CopyColorSubTable; + + /* Vertex/fragment programs */ + driver->BindProgram = NULL; + driver->NewProgram = _mesa_new_program; + driver->DeleteProgram = _mesa_delete_program; + + /* simple state commands */ + driver->AlphaFunc = NULL; + driver->BlendColor = NULL; + driver->BlendEquationSeparate = NULL; + driver->BlendFuncSeparate = NULL; + driver->ClearColor = NULL; + driver->ClearDepth = NULL; + driver->ClearStencil = NULL; + driver->ClipPlane = NULL; + driver->ColorMask = NULL; + driver->ColorMaterial = NULL; + driver->CullFace = NULL; + driver->DrawBuffer = NULL; + driver->DrawBuffers = NULL; + driver->FrontFace = NULL; + driver->DepthFunc = NULL; + driver->DepthMask = NULL; + driver->DepthRange = NULL; + driver->Enable = NULL; + driver->Fogfv = NULL; + driver->Hint = NULL; + driver->Lightfv = NULL; + driver->LightModelfv = NULL; + driver->LineStipple = NULL; + driver->LineWidth = NULL; + driver->LogicOpcode = NULL; + driver->PointParameterfv = NULL; + driver->PointSize = NULL; + driver->PolygonMode = NULL; + driver->PolygonOffset = NULL; + driver->PolygonStipple = NULL; + driver->ReadBuffer = NULL; + driver->RenderMode = NULL; + driver->Scissor = NULL; + driver->ShadeModel = NULL; + driver->StencilFuncSeparate = NULL; + driver->StencilOpSeparate = NULL; + driver->StencilMaskSeparate = NULL; + driver->TexGen = NULL; + driver->TexEnv = NULL; + driver->TexParameter = NULL; + driver->Viewport = NULL; + + /* buffer objects */ + _mesa_init_buffer_object_functions(driver); + + /* query objects */ + _mesa_init_query_object_functions(driver); + + _mesa_init_sync_object_functions(driver); + + driver->NewFramebuffer = _mesa_new_framebuffer; + driver->NewRenderbuffer = _mesa_new_soft_renderbuffer; + driver->RenderTexture = _mesa_render_texture; + driver->FinishRenderTexture = _mesa_finish_render_texture; + driver->FramebufferRenderbuffer = _mesa_framebuffer_renderbuffer; + driver->ValidateFramebuffer = _mesa_validate_framebuffer; + + driver->BlitFramebuffer = _swrast_BlitFramebuffer; + + /* APPLE_vertex_array_object */ + driver->NewArrayObject = _mesa_new_array_object; + driver->DeleteArrayObject = _mesa_delete_array_object; + driver->BindArrayObject = NULL; + + _mesa_init_shader_object_functions(driver); + + _mesa_init_transform_feedback_functions(driver); + + /* T&L stuff */ + driver->NeedValidate = GL_FALSE; + driver->ValidateTnlModule = NULL; + driver->CurrentExecPrimitive = 0; + driver->CurrentSavePrimitive = 0; + driver->NeedFlush = 0; + driver->SaveNeedFlush = 0; + + driver->ProgramStringNotify = _tnl_program_string; + driver->FlushVertices = NULL; + driver->SaveFlushVertices = NULL; + driver->NotifySaveBegin = NULL; + driver->LightingSpaceChange = NULL; + + /* display list */ + driver->NewList = NULL; + driver->EndList = NULL; + driver->BeginCallList = NULL; + driver->EndCallList = NULL; +} + + +/** + * Call the ctx->Driver.* state functions with current values to initialize + * driver state. + * Only the Intel drivers use this so far. + */ +void +_mesa_init_driver_state(struct gl_context *ctx) +{ + ctx->Driver.AlphaFunc(ctx, ctx->Color.AlphaFunc, ctx->Color.AlphaRef); + + ctx->Driver.BlendColor(ctx, ctx->Color.BlendColor); + + ctx->Driver.BlendEquationSeparate(ctx, + ctx->Color.Blend[0].EquationRGB, + ctx->Color.Blend[0].EquationA); + + ctx->Driver.BlendFuncSeparate(ctx, + ctx->Color.Blend[0].SrcRGB, + ctx->Color.Blend[0].DstRGB, + ctx->Color.Blend[0].SrcA, + ctx->Color.Blend[0].DstA); + + if (ctx->Driver.ColorMaskIndexed) { + GLuint i; + for (i = 0; i < ctx->Const.MaxDrawBuffers; i++) { + ctx->Driver.ColorMaskIndexed(ctx, i, + ctx->Color.ColorMask[0][RCOMP], + ctx->Color.ColorMask[0][GCOMP], + ctx->Color.ColorMask[0][BCOMP], + ctx->Color.ColorMask[0][ACOMP]); + } + } + else { + ctx->Driver.ColorMask(ctx, + ctx->Color.ColorMask[0][RCOMP], + ctx->Color.ColorMask[0][GCOMP], + ctx->Color.ColorMask[0][BCOMP], + ctx->Color.ColorMask[0][ACOMP]); + } + + ctx->Driver.CullFace(ctx, ctx->Polygon.CullFaceMode); + ctx->Driver.DepthFunc(ctx, ctx->Depth.Func); + ctx->Driver.DepthMask(ctx, ctx->Depth.Mask); + + ctx->Driver.Enable(ctx, GL_ALPHA_TEST, ctx->Color.AlphaEnabled); + ctx->Driver.Enable(ctx, GL_BLEND, ctx->Color.BlendEnabled); + ctx->Driver.Enable(ctx, GL_COLOR_LOGIC_OP, ctx->Color.ColorLogicOpEnabled); + ctx->Driver.Enable(ctx, GL_COLOR_SUM, ctx->Fog.ColorSumEnabled); + ctx->Driver.Enable(ctx, GL_CULL_FACE, ctx->Polygon.CullFlag); + ctx->Driver.Enable(ctx, GL_DEPTH_TEST, ctx->Depth.Test); + ctx->Driver.Enable(ctx, GL_DITHER, ctx->Color.DitherFlag); + ctx->Driver.Enable(ctx, GL_FOG, ctx->Fog.Enabled); + ctx->Driver.Enable(ctx, GL_LIGHTING, ctx->Light.Enabled); + ctx->Driver.Enable(ctx, GL_LINE_SMOOTH, ctx->Line.SmoothFlag); + ctx->Driver.Enable(ctx, GL_POLYGON_STIPPLE, ctx->Polygon.StippleFlag); + ctx->Driver.Enable(ctx, GL_SCISSOR_TEST, ctx->Scissor.Enabled); + ctx->Driver.Enable(ctx, GL_STENCIL_TEST, ctx->Stencil._Enabled); + ctx->Driver.Enable(ctx, GL_TEXTURE_1D, GL_FALSE); + ctx->Driver.Enable(ctx, GL_TEXTURE_2D, GL_FALSE); + ctx->Driver.Enable(ctx, GL_TEXTURE_RECTANGLE_NV, GL_FALSE); + ctx->Driver.Enable(ctx, GL_TEXTURE_3D, GL_FALSE); + ctx->Driver.Enable(ctx, GL_TEXTURE_CUBE_MAP, GL_FALSE); + + ctx->Driver.Fogfv(ctx, GL_FOG_COLOR, ctx->Fog.Color); + ctx->Driver.Fogfv(ctx, GL_FOG_MODE, 0); + ctx->Driver.Fogfv(ctx, GL_FOG_DENSITY, &ctx->Fog.Density); + ctx->Driver.Fogfv(ctx, GL_FOG_START, &ctx->Fog.Start); + ctx->Driver.Fogfv(ctx, GL_FOG_END, &ctx->Fog.End); + + ctx->Driver.FrontFace(ctx, ctx->Polygon.FrontFace); + + { + GLfloat f = (GLfloat) ctx->Light.Model.ColorControl; + ctx->Driver.LightModelfv(ctx, GL_LIGHT_MODEL_COLOR_CONTROL, &f); + } + + ctx->Driver.LineWidth(ctx, ctx->Line.Width); + ctx->Driver.LogicOpcode(ctx, ctx->Color.LogicOp); + ctx->Driver.PointSize(ctx, ctx->Point.Size); + ctx->Driver.PolygonStipple(ctx, (const GLubyte *) ctx->PolygonStipple); + ctx->Driver.Scissor(ctx, ctx->Scissor.X, ctx->Scissor.Y, + ctx->Scissor.Width, ctx->Scissor.Height); + ctx->Driver.ShadeModel(ctx, ctx->Light.ShadeModel); + ctx->Driver.StencilFuncSeparate(ctx, GL_FRONT, + ctx->Stencil.Function[0], + ctx->Stencil.Ref[0], + ctx->Stencil.ValueMask[0]); + ctx->Driver.StencilFuncSeparate(ctx, GL_BACK, + ctx->Stencil.Function[1], + ctx->Stencil.Ref[1], + ctx->Stencil.ValueMask[1]); + ctx->Driver.StencilMaskSeparate(ctx, GL_FRONT, ctx->Stencil.WriteMask[0]); + ctx->Driver.StencilMaskSeparate(ctx, GL_BACK, ctx->Stencil.WriteMask[1]); + ctx->Driver.StencilOpSeparate(ctx, GL_FRONT, + ctx->Stencil.FailFunc[0], + ctx->Stencil.ZFailFunc[0], + ctx->Stencil.ZPassFunc[0]); + ctx->Driver.StencilOpSeparate(ctx, GL_BACK, + ctx->Stencil.FailFunc[1], + ctx->Stencil.ZFailFunc[1], + ctx->Stencil.ZPassFunc[1]); + + + ctx->Driver.DrawBuffer(ctx, ctx->Color.DrawBuffer[0]); +} diff --git a/mesalib/src/mesa/main/APIspec.xml b/mesalib/src/mesa/main/APIspec.xml index 81b832841..0f82d0a38 100644 --- a/mesalib/src/mesa/main/APIspec.xml +++ b/mesalib/src/mesa/main/APIspec.xml @@ -1,4351 +1,4404 @@ -<?xml version="1.0"?>
-<!DOCTYPE apispec SYSTEM "APIspec.dtd">
-
-<!-- A function is generated from a template. Multiple functions can be
- generated from a single template with different arguments. For example,
- glColor3f can be generated from
-
- <function name="Color3f" template="Color" gltype="GLfloat" vector_size="3" expand_vector="true"/>
-
- and glColor4iv can be generated from
-
- <function name="Color4iv" template="Color" gltype="GLint" vector_size="4"/>
-
- In a template, there are <desc>s that describe the properties of
- parameters. A <desc> can enumerate the valid values of a parameter. It
- can also specify the error code when an invalid value is given, and etc.
- By nesting <desc>s, they can create dependency between parameters.
-
- A function can be marked as external. It means that the function cannot
- be dispatched to the corresponding mesa function, if one exists, directly,
- and requires an external implementation.
--->
-
-<apispec>
-
-<template name="Color">
- <proto>
- <return type="void"/>
- <vector name="v" type="const GLtype *" size="dynamic">
- <param name="red" type="GLtype"/>
- <param name="green" type="GLtype"/>
- <param name="blue" type="GLtype"/>
- <param name="alpha" type="GLtype"/>
- </vector>
- </proto>
-</template>
-
-<template name="ClipPlane">
- <proto>
- <return type="void"/>
- <param name="plane" type="GLenum"/>
- <vector name="equation" type="const GLtype *" size="4"/>
- </proto>
-
- <desc name="plane">
- <range base="GL_CLIP_PLANE" from="0" to="5"/>
- </desc>
-</template>
-
-<template name="CullFace">
- <proto>
- <return type="void"/>
- <param name="mode" type="GLenum"/>
- </proto>
-
- <desc name="mode">
- <value name="GL_FRONT"/>
- <value name="GL_BACK"/>
- <value name="GL_FRONT_AND_BACK"/>
- </desc>
-</template>
-
-<template name="Fog">
- <proto>
- <return type="void"/>
- <param name="pname" type="GLenum"/>
- <vector name="params" type="const GLtype *" size="dynamic">
- <param name="param" type="GLtype"/>
- </vector>
- </proto>
-
- <desc name="pname">
- <value name="GL_FOG_MODE"/>
- <desc name="param">
- <value name="GL_EXP"/>
- <value name="GL_EXP2"/>
- <value name="GL_LINEAR"/>
- </desc>
- </desc>
-
- <desc name="pname">
- <value name="GL_FOG_COLOR"/>
-
- <desc name="params" vector_size="4"/>
- </desc>
-
- <desc name="pname">
- <value name="GL_FOG_DENSITY"/>
- <value name="GL_FOG_START"/>
- <value name="GL_FOG_END"/>
-
- <desc name="params" vector_size="1"/>
- </desc>
-</template>
-
-<template name="FrontFace">
- <proto>
- <return type="void"/>
- <param name="mode" type="GLenum"/>
- </proto>
-
- <desc name="mode">
- <value name="GL_CW"/>
- <value name="GL_CCW"/>
- </desc>
-</template>
-
-<template name="Hint">
- <proto>
- <return type="void"/>
- <param name="target" type="GLenum"/>
- <param name="mode" type="GLenum"/>
- </proto>
-
- <desc name="target" category="GLES1.1">
- <value name="GL_FOG_HINT"/>
- <value name="GL_LINE_SMOOTH_HINT"/>
- <value name="GL_PERSPECTIVE_CORRECTION_HINT"/>
- <value name="GL_POINT_SMOOTH_HINT"/>
- </desc>
- <desc name="target" category="OES_standard_derivatives">
- <value name="GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES"/>
- </desc>
- <desc name="target">
- <value name="GL_GENERATE_MIPMAP_HINT"/>
- </desc>
-
- <desc name="mode">
- <value name="GL_FASTEST"/>
- <value name="GL_NICEST"/>
- <value name="GL_DONT_CARE"/>
- </desc>
-</template>
-
-<template name="Light">
- <proto>
- <return type="void"/>
- <param name="light" type="GLenum"/>
- <param name="pname" type="GLenum"/>
- <vector name="params" type="const GLtype *" size="dynamic">
- <param name="param" type="GLtype"/>
- </vector>
- </proto>
-
- <desc name="light">
- <range base="GL_LIGHT" from="0" to="7"/>
- </desc>
-
- <desc name="pname">
- <value name="GL_AMBIENT"/>
- <value name="GL_DIFFUSE"/>
- <value name="GL_SPECULAR"/>
- <value name="GL_POSITION"/>
-
- <desc name="params" vector_size="4"/>
- </desc>
-
- <desc name="pname">
- <value name="GL_SPOT_DIRECTION"/>
-
- <desc name="params" vector_size="3"/>
- </desc>
-
- <desc name="pname">
- <value name="GL_SPOT_EXPONENT"/>
- <value name="GL_SPOT_CUTOFF"/>
- <value name="GL_CONSTANT_ATTENUATION"/>
- <value name="GL_LINEAR_ATTENUATION"/>
- <value name="GL_QUADRATIC_ATTENUATION"/>
-
- <desc name="params" vector_size="1"/>
- </desc>
-</template>
-
-<template name="LightModel">
- <proto>
- <return type="void"/>
- <param name="pname" type="GLenum"/>
- <vector name="params" type="const GLtype *" size="dynamic">
- <param name="param" type="GLtype"/>
- </vector>
- </proto>
-
- <desc name="pname">
- <value name="GL_LIGHT_MODEL_AMBIENT"/>
-
- <desc name="params" vector_size="4"/>
- </desc>
-
- <desc name="pname">
- <value name="GL_LIGHT_MODEL_TWO_SIDE"/>
- <desc name="param">
- <value name="GL_TRUE"/>
- <value name="GL_FALSE"/>
- </desc>
- </desc>
-</template>
-
-<template name="LineWidth">
- <proto>
- <return type="void"/>
- <param name="width" type="GLtype"/>
- </proto>
-</template>
-
-<template name="Material">
- <proto>
- <return type="void"/>
- <param name="face" type="GLenum"/>
- <param name="pname" type="GLenum"/>
- <vector name="params" type="const GLtype *" size="dynamic">
- <param name="param" type="GLtype"/>
- </vector>
- </proto>
-
- <desc name="face">
- <value name="GL_FRONT_AND_BACK"/>
- </desc>
-
- <desc name="pname">
- <value name="GL_AMBIENT"/>
- <value name="GL_DIFFUSE"/>
- <value name="GL_AMBIENT_AND_DIFFUSE"/>
- <value name="GL_SPECULAR"/>
- <value name="GL_EMISSION"/>
-
- <desc name="params" vector_size="4"/>
- </desc>
-
- <desc name="pname">
- <value name="GL_SHININESS"/>
-
- <desc name="params" vector_size="1"/>
- </desc>
-</template>
-
-<template name="PointSize">
- <proto>
- <return type="void"/>
- <param name="size" type="GLtype"/>
- </proto>
-</template>
-
-<template name="PointSizePointer">
- <proto>
- <return type="void"/>
- <param name="type" type="GLenum"/>
- <param name="stride" type="GLsizei"/>
- <param name="pointer" type="const GLvoid *"/>
- </proto>
-
- <desc name="type">
- <value name="GL_FLOAT"/>
- <value name="GL_FIXED"/>
- </desc>
-</template>
-
-<template name="Scissor">
- <proto>
- <return type="void"/>
- <param name="x" type="GLint"/>
- <param name="y" type="GLint"/>
- <param name="width" type="GLsizei"/>
- <param name="height" type="GLsizei"/>
- </proto>
-</template>
-
-<template name="ShadeModel">
- <proto>
- <return type="void"/>
- <param name="mode" type="GLenum"/>
- </proto>
-
- <desc name="mode">
- <value name="GL_FLAT"/>
- <value name="GL_SMOOTH"/>
- </desc>
-</template>
-
-<template name="TexParameter">
- <proto>
- <return type="void"/>
- <param name="target" type="GLenum"/>
- <param name="pname" type="GLenum"/>
- <vector name="params" type="const GLtype *" size="dynamic">
- <param name="param" type="GLtype"/>
- </vector>
- </proto>
-
- <desc name="target">
- <value name="GL_TEXTURE_2D"/>
- <value name="GL_TEXTURE_CUBE_MAP" category="GLES2.0"/>
- <value name="GL_TEXTURE_CUBE_MAP_OES" category="OES_texture_cube_map"/>
- <value name="GL_TEXTURE_3D_OES" category="OES_texture_3D"/>
- </desc>
-
- <desc name="pname">
- <value name="GL_TEXTURE_WRAP_S"/>
- <value name="GL_TEXTURE_WRAP_T"/>
- <value name="GL_TEXTURE_WRAP_R_OES" category="OES_texture_3D"/>
-
- <desc name="param">
- <value name="GL_CLAMP_TO_EDGE"/>
- <value name="GL_REPEAT"/>
- <value name="GL_MIRRORED_REPEAT" category="GLES2.0"/>
- <value name="GL_MIRRORED_REPEAT_OES" category="OES_texture_mirrored_repeat"/>
- </desc>
- </desc>
-
- <desc name="pname">
- <value name="GL_TEXTURE_MIN_FILTER"/>
-
- <desc name="param">
- <value name="GL_NEAREST"/>
- <value name="GL_LINEAR"/>
- <value name="GL_NEAREST_MIPMAP_NEAREST"/>
- <value name="GL_NEAREST_MIPMAP_LINEAR"/>
- <value name="GL_LINEAR_MIPMAP_NEAREST"/>
- <value name="GL_LINEAR_MIPMAP_LINEAR"/>
- </desc>
- </desc>
-
- <desc name="pname">
- <value name="GL_TEXTURE_MAG_FILTER"/>
-
- <desc name="param">
- <value name="GL_NEAREST"/>
- <value name="GL_LINEAR"/>
- </desc>
- </desc>
-
- <desc name="pname" category="GLES1.1">
- <value name="GL_GENERATE_MIPMAP"/>
-
- <desc name="param">
- <value name="GL_TRUE"/>
- <value name="GL_FALSE"/>
- </desc>
- </desc>
-
- <desc name="pname" category="EXT_texture_filter_anisotropic">
- <value name="GL_TEXTURE_MAX_ANISOTROPY_EXT"/>
- <desc name="params" vector_size="1"/>
- </desc>
-
- <desc name="pname" category="OES_draw_texture">
- <value name="GL_TEXTURE_CROP_RECT_OES"/>
- <desc name="params" vector_size="4"/>
- </desc>
-</template>
-
-<template name="TexImage2D">
- <proto>
- <return type="void"/>
- <param name="target" type="GLenum"/>
- <param name="level" type="GLint"/>
- <param name="internalFormat" type="GLint"/> <!-- should be GLenum -->
- <param name="width" type="GLsizei"/>
- <param name="height" type="GLsizei"/>
- <param name="border" type="GLint"/>
- <param name="format" type="GLenum"/>
- <param name="type" type="GLenum"/>
- <param name="pixels" type="const GLvoid *"/>
- </proto>
-
- <desc name="target">
- <value name="GL_TEXTURE_2D"/>
- <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_X" category="GLES2.0"/>
- <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Y" category="GLES2.0"/>
- <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Z" category="GLES2.0"/>
- <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_X" category="GLES2.0"/>
- <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Y" category="GLES2.0"/>
- <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Z" category="GLES2.0"/>
- <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_X_OES" category="OES_texture_cube_map"/>
- <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Y_OES" category="OES_texture_cube_map"/>
- <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Z_OES" category="OES_texture_cube_map"/>
- <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_X_OES" category="OES_texture_cube_map"/>
- <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_OES" category="OES_texture_cube_map"/>
- <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_OES" category="OES_texture_cube_map"/>
- </desc>
-
- <desc name="internalFormat" error="GL_INVALID_VALUE">
- <value name="GL_ALPHA"/>
- <value name="GL_RGB"/>
- <value name="GL_RGBA"/>
- <value name="GL_BGRA_EXT"/>
- <value name="GL_LUMINANCE"/>
- <value name="GL_LUMINANCE_ALPHA"/>
- <value name="GL_DEPTH_COMPONENT" category="OES_depth_texture"/>
- <value name="GL_DEPTH_STENCIL_OES" category="OES_packed_depth_stencil"/>
- </desc>
-
- <desc name="border" error="GL_INVALID_VALUE">
- <value name="0"/>
- </desc>
-
- <desc name="format">
- <value name="GL_ALPHA"/>
-
- <desc name="type" error="GL_INVALID_OPERATION">
- <value name="GL_UNSIGNED_BYTE"/>
- <value name="GL_FLOAT" category="OES_texture_float"/>
- <value name="GL_HALF_FLOAT_OES" category="OES_texture_half_float"/>
- </desc>
- </desc>
-
- <desc name="format">
- <value name="GL_RGB"/>
-
- <desc name="type" error="GL_INVALID_OPERATION">
- <value name="GL_UNSIGNED_BYTE"/>
- <value name="GL_UNSIGNED_SHORT_5_6_5"/>
- <value name="GL_FLOAT" category="OES_texture_float"/>
- <value name="GL_HALF_FLOAT_OES" category="OES_texture_half_float"/>
- </desc>
- </desc>
-
- <desc name="format">
- <value name="GL_RGBA"/>
-
- <desc name="type" error="GL_INVALID_OPERATION">
- <value name="GL_UNSIGNED_BYTE"/>
- <value name="GL_UNSIGNED_SHORT_4_4_4_4"/>
- <value name="GL_UNSIGNED_SHORT_5_5_5_1"/>
- <value name="GL_FLOAT" category="OES_texture_float"/>
- <value name="GL_HALF_FLOAT_OES" category="OES_texture_half_float"/>
- <value name="GL_UNSIGNED_INT_2_10_10_10_REV_EXT" category="EXT_texture_type_2_10_10_10_REV"/>
- </desc>
- </desc>
-
- <desc name="format">
- <value name="GL_LUMINANCE"/>
-
- <desc name="type" error="GL_INVALID_OPERATION">
- <value name="GL_UNSIGNED_BYTE"/>
- <value name="GL_FLOAT" category="OES_texture_float"/>
- <value name="GL_HALF_FLOAT_OES" category="OES_texture_half_float"/>
- </desc>
- </desc>
-
- <desc name="format">
- <value name="GL_LUMINANCE_ALPHA"/>
-
- <desc name="type" error="GL_INVALID_OPERATION">
- <value name="GL_UNSIGNED_BYTE"/>
- <value name="GL_FLOAT" category="OES_texture_float"/>
- <value name="GL_HALF_FLOAT_OES" category="OES_texture_half_float"/>
- </desc>
- </desc>
-
- <desc name="format" category="OES_depth_texture">
- <value name="GL_DEPTH_COMPONENT"/>
-
- <desc name="type" error="GL_INVALID_OPERATION">
- <value name="GL_UNSIGNED_SHORT"/>
- <value name="GL_UNSIGNED_INT"/>
- </desc>
- </desc>
-
- <desc name="format" category="OES_packed_depth_stencil">
- <value name="GL_DEPTH_STENCIL_OES"/>
- <desc name="type" error="GL_INVALID_OPERATION">
- <value name="GL_UNSIGNED_INT_24_8_OES"/>
- </desc>
- </desc>
-
- <desc name="format" category="EXT_texture_format_BGRA8888">
- <value name="GL_BGRA_EXT"/>
-
- <desc name="type" error="GL_INVALID_OPERATION">
- <value name="GL_UNSIGNED_BYTE"/>
- </desc>
- </desc>
-</template>
-
-<template name="TexEnv">
- <proto>
- <return type="void"/>
- <param name="target" type="GLenum"/>
- <param name="pname" type="GLenum"/>
- <vector name="params" type="const GLtype *" size="dynamic">
- <param name="param" type="GLtype"/>
- </vector>
- </proto>
-
- <desc name="target" category="OES_point_sprite">
- <value name="GL_POINT_SPRITE_OES"/>
-
- <desc name="pname">
- <value name="GL_COORD_REPLACE_OES"/>
- </desc>
- </desc>
-
- <desc name="pname" category="OES_point_sprite">
- <value name="GL_COORD_REPLACE_OES"/>
-
- <desc name="param">
- <value name="GL_TRUE"/>
- <value name="GL_FALSE"/>
- </desc>
- </desc>
-
- <desc name="target" category="EXT_texture_lod_bias">
- <value name="GL_TEXTURE_FILTER_CONTROL_EXT"/>
-
- <desc name="pname">
- <value name="GL_TEXTURE_LOD_BIAS_EXT"/>
- </desc>
- </desc>
-
- <desc name="pname" category="EXT_texture_lod_bias">
- <value name="GL_TEXTURE_LOD_BIAS_EXT"/>
- <desc name="params" vector_size="1"/>
- </desc>
-
- <desc name="target">
- <value name="GL_TEXTURE_ENV"/>
-
- <desc name="pname">
- <value name="GL_TEXTURE_ENV_MODE"/>
- <value name="GL_COMBINE_RGB"/>
- <value name="GL_COMBINE_ALPHA"/>
- <value name="GL_RGB_SCALE"/>
- <value name="GL_ALPHA_SCALE"/>
- <value name="GL_SRC0_RGB"/>
- <value name="GL_SRC1_RGB"/>
- <value name="GL_SRC2_RGB"/>
- <value name="GL_SRC0_ALPHA"/>
- <value name="GL_SRC1_ALPHA"/>
- <value name="GL_SRC2_ALPHA"/>
- <value name="GL_OPERAND0_RGB"/>
- <value name="GL_OPERAND1_RGB"/>
- <value name="GL_OPERAND2_RGB"/>
- <value name="GL_OPERAND0_ALPHA"/>
- <value name="GL_OPERAND1_ALPHA"/>
- <value name="GL_OPERAND2_ALPHA"/>
- <value name="GL_TEXTURE_ENV_COLOR"/>
- </desc>
- </desc>
-
- <desc name="pname">
- <value name="GL_TEXTURE_ENV_MODE"/>
-
- <desc name="param">
- <value name="GL_REPLACE"/>
- <value name="GL_MODULATE"/>
- <value name="GL_DECAL"/>
- <value name="GL_BLEND"/>
- <value name="GL_ADD"/>
- <value name="GL_COMBINE"/>
- </desc>
- </desc>
-
- <desc name="pname">
- <value name="GL_COMBINE_RGB"/>
-
- <desc name="param">
- <value name="GL_REPLACE"/>
- <value name="GL_MODULATE"/>
- <value name="GL_ADD"/>
- <value name="GL_ADD_SIGNED"/>
- <value name="GL_INTERPOLATE"/>
- <value name="GL_SUBTRACT"/>
- <value name="GL_DOT3_RGB"/>
- <value name="GL_DOT3_RGBA"/>
- </desc>
- </desc>
-
- <desc name="pname">
- <value name="GL_COMBINE_ALPHA"/>
-
- <desc name="param">
- <value name="GL_REPLACE"/>
- <value name="GL_MODULATE"/>
- <value name="GL_ADD"/>
- <value name="GL_ADD_SIGNED"/>
- <value name="GL_INTERPOLATE"/>
- <value name="GL_SUBTRACT"/>
- </desc>
- </desc>
-
- <desc name="pname">
- <value name="GL_RGB_SCALE"/>
- <value name="GL_ALPHA_SCALE"/>
-
- <desc name="param" convert="true" error="GL_INVALID_VALUE">
- <value name="1.0"/>
- <value name="2.0"/>
- <value name="4.0"/>
- </desc>
- </desc>
-
- <desc name="pname">
- <value name="GL_SRC0_RGB"/>
- <value name="GL_SRC1_RGB"/>
- <value name="GL_SRC2_RGB"/>
- <value name="GL_SRC0_ALPHA"/>
- <value name="GL_SRC1_ALPHA"/>
- <value name="GL_SRC2_ALPHA"/>
-
- <desc name="param">
- <value name="GL_TEXTURE"/>
- <value name="GL_CONSTANT"/>
- <value name="GL_PRIMARY_COLOR"/>
- <value name="GL_PREVIOUS"/>
-
- <range base="GL_TEXTURE" from="0" to="31" category="OES_texture_env_crossbar"/>
- </desc>
- </desc>
-
- <desc name="pname">
- <value name="GL_OPERAND0_RGB"/>
- <value name="GL_OPERAND1_RGB"/>
- <value name="GL_OPERAND2_RGB"/>
-
- <desc name="param">
- <value name="GL_SRC_COLOR"/>
- <value name="GL_ONE_MINUS_SRC_COLOR"/>
- <value name="GL_SRC_ALPHA"/>
- <value name="GL_ONE_MINUS_SRC_ALPHA"/>
- </desc>
- </desc>
-
- <desc name="pname">
- <value name="GL_OPERAND0_ALPHA"/>
- <value name="GL_OPERAND1_ALPHA"/>
- <value name="GL_OPERAND2_ALPHA"/>
-
- <desc name="param">
- <value name="GL_SRC_ALPHA"/>
- <value name="GL_ONE_MINUS_SRC_ALPHA"/>
- </desc>
- </desc>
-
- <desc name="pname">
- <value name="GL_TEXTURE_ENV_COLOR"/>
-
- <desc name="params" vector_size="4"/>
- </desc>
-</template>
-
-<template name="TexGen">
- <proto>
- <return type="void"/>
- <param name="coord" type="GLenum"/>
- <param name="pname" type="GLenum"/>
- <vector name="params" type="const GLtype *" size="dynamic">
- <param name="param" type="GLtype"/>
- </vector>
- </proto>
-
- <desc name="coord" category="OES_texture_cube_map">
- <value name="GL_TEXTURE_GEN_STR_OES"/>
- </desc>
-
- <desc name="pname" category="OES_texture_cube_map">
- <value name="GL_TEXTURE_GEN_MODE_OES"/>
-
- <desc name="param">
- <value name="GL_NORMAL_MAP_OES"/>
- <value name="GL_REFLECTION_MAP_OES"/>
- </desc>
- </desc>
-</template>
-
-<template name="Clear">
- <proto>
- <return type="void"/>
- <param name="mask" type="GLbitfield"/>
- </proto>
-
- <desc name="mask" error="GL_INVALID_VALUE">
- <value name="0"/>
- <value name="(GL_COLOR_BUFFER_BIT)"/>
- <value name="(GL_DEPTH_BUFFER_BIT)"/>
- <value name="(GL_STENCIL_BUFFER_BIT)"/>
- <value name="(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT)"/>
- <value name="(GL_COLOR_BUFFER_BIT|GL_STENCIL_BUFFER_BIT)"/>
- <value name="(GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT)"/>
- <value name="(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT)"/>
- </desc>
-</template>
-
-<template name="ClearColor">
- <proto>
- <return type="void"/>
- <param name="red" type="GLtype"/>
- <param name="green" type="GLtype"/>
- <param name="blue" type="GLtype"/>
- <param name="alpha" type="GLtype"/>
- </proto>
-</template>
-
-<template name="ClearStencil">
- <proto>
- <return type="void"/>
- <param name="s" type="GLint"/>
- </proto>
-</template>
-
-<template name="ClearDepth">
- <proto>
- <return type="void"/>
- <param name="depth" type="GLtype"/>
- </proto>
-</template>
-
-<template name="StencilMask">
- <proto>
- <return type="void"/>
- <param name="mask" type="GLuint"/>
- </proto>
-</template>
-
-<template name="StencilMaskSeparate">
- <proto>
- <return type="void"/>
- <param name="face" type="GLenum"/>
- <param name="mask" type="GLuint"/>
- </proto>
-
- <desc name="face">
- <value name="GL_FRONT"/>
- <value name="GL_BACK"/>
- <value name="GL_FRONT_AND_BACK"/>
- </desc>
-</template>
-
-<template name="ColorMask">
- <proto>
- <return type="void"/>
- <param name="red" type="GLboolean"/>
- <param name="green" type="GLboolean"/>
- <param name="blue" type="GLboolean"/>
- <param name="alpha" type="GLboolean"/>
- </proto>
-</template>
-
-<template name="DepthMask">
- <proto>
- <return type="void"/>
- <param name="flag" type="GLboolean"/>
- </proto>
-</template>
-
-<template name="Disable">
- <proto>
- <return type="void"/>
- <param name="cap" type="GLenum"/>
- </proto>
-
- <desc name="cap" category="GLES1.1">
- <value name="GL_NORMALIZE"/>
- <value name="GL_RESCALE_NORMAL"/>
-
- <range base="GL_CLIP_PLANE" from="0" to="5"/>
-
- <value name="GL_FOG"/>
- <value name="GL_LIGHTING"/>
- <value name="GL_COLOR_MATERIAL"/>
-
- <range base="GL_LIGHT" from="0" to="7"/>
-
- <value name="GL_POINT_SMOOTH"/>
- <value name="GL_LINE_SMOOTH"/>
- <value name="GL_CULL_FACE"/>
- <value name="GL_POLYGON_OFFSET_FILL"/>
- <value name="GL_MULTISAMPLE"/>
- <value name="GL_SAMPLE_ALPHA_TO_COVERAGE"/>
- <value name="GL_SAMPLE_ALPHA_TO_ONE"/>
- <value name="GL_SAMPLE_COVERAGE"/>
- <value name="GL_TEXTURE_2D"/>
- <value name="GL_SCISSOR_TEST"/>
- <value name="GL_ALPHA_TEST"/>
- <value name="GL_STENCIL_TEST"/>
- <value name="GL_DEPTH_TEST"/>
- <value name="GL_BLEND"/>
- <value name="GL_DITHER"/>
- <value name="GL_COLOR_LOGIC_OP"/>
-
- <value name="GL_POINT_SPRITE_OES" category="OES_point_sprite"/>
- <value name="GL_MATRIX_PALETTE_OES" category="OES_matrix_palette"/>
- <value name="GL_TEXTURE_CUBE_MAP_OES" category="OES_texture_cube_map"/>
- <value name="GL_TEXTURE_GEN_STR_OES" category="OES_texture_cube_map"/>
- </desc>
-
- <desc name="cap" category="GLES2.0">
- <value name="GL_CULL_FACE"/>
- <value name="GL_SCISSOR_TEST"/>
- <value name="GL_POLYGON_OFFSET_FILL"/>
- <value name="GL_SAMPLE_ALPHA_TO_COVERAGE"/>
- <value name="GL_SAMPLE_COVERAGE"/>
- <value name="GL_STENCIL_TEST"/>
- <value name="GL_DEPTH_TEST"/>
- <value name="GL_DITHER"/>
- <value name="GL_BLEND"/>
- </desc>
-</template>
-
-<!-- it is exactly the same as Disable -->
-<template name="Enable">
- <proto>
- <return type="void"/>
- <param name="cap" type="GLenum"/>
- </proto>
-
- <desc name="cap" category="GLES1.1">
- <value name="GL_NORMALIZE"/>
- <value name="GL_RESCALE_NORMAL"/>
-
- <range base="GL_CLIP_PLANE" from="0" to="5"/>
-
- <value name="GL_FOG"/>
- <value name="GL_LIGHTING"/>
- <value name="GL_COLOR_MATERIAL"/>
-
- <range base="GL_LIGHT" from="0" to="7"/>
-
- <value name="GL_POINT_SMOOTH"/>
- <value name="GL_LINE_SMOOTH"/>
- <value name="GL_CULL_FACE"/>
- <value name="GL_POLYGON_OFFSET_FILL"/>
- <value name="GL_MULTISAMPLE"/>
- <value name="GL_SAMPLE_ALPHA_TO_COVERAGE"/>
- <value name="GL_SAMPLE_ALPHA_TO_ONE"/>
- <value name="GL_SAMPLE_COVERAGE"/>
- <value name="GL_TEXTURE_2D"/>
- <value name="GL_SCISSOR_TEST"/>
- <value name="GL_ALPHA_TEST"/>
- <value name="GL_STENCIL_TEST"/>
- <value name="GL_DEPTH_TEST"/>
- <value name="GL_BLEND"/>
- <value name="GL_DITHER"/>
- <value name="GL_COLOR_LOGIC_OP"/>
-
- <value name="GL_POINT_SPRITE_OES" category="OES_point_sprite"/>
- <value name="GL_MATRIX_PALETTE_OES" category="OES_matrix_palette"/>
- <value name="GL_TEXTURE_CUBE_MAP_OES" category="OES_texture_cube_map"/>
- <value name="GL_TEXTURE_GEN_STR_OES" category="OES_texture_cube_map"/>
- </desc>
-
- <desc name="cap" category="GLES2.0">
- <value name="GL_CULL_FACE"/>
- <value name="GL_SCISSOR_TEST"/>
- <value name="GL_POLYGON_OFFSET_FILL"/>
- <value name="GL_SAMPLE_ALPHA_TO_COVERAGE"/>
- <value name="GL_SAMPLE_COVERAGE"/>
- <value name="GL_STENCIL_TEST"/>
- <value name="GL_DEPTH_TEST"/>
- <value name="GL_DITHER"/>
- <value name="GL_BLEND"/>
- </desc>
-</template>
-
-<template name="Finish">
- <proto>
- <return type="void"/>
- </proto>
-</template>
-
-<template name="Flush">
- <proto>
- <return type="void"/>
- </proto>
-</template>
-
-<template name="AlphaFunc">
- <proto>
- <return type="void"/>
- <param name="func" type="GLenum"/>
- <param name="ref" type="GLtype"/>
- </proto>
- <desc name="func">
- <value name="GL_NEVER"/>
- <value name="GL_LESS"/>
- <value name="GL_EQUAL"/>
- <value name="GL_LEQUAL"/>
- <value name="GL_GREATER"/>
- <value name="GL_NOTEQUAL"/>
- <value name="GL_GEQUAL"/>
- <value name="GL_ALWAYS"/>
- </desc>
-</template>
-
-<template name="BlendFunc">
- <proto>
- <return type="void"/>
- <param name="sfactor" type="GLenum"/>
- <param name="dfactor" type="GLenum"/>
- </proto>
-
- <desc name="sfactor">
- <value name="GL_ZERO"/>
- <value name="GL_ONE"/>
- <value name="GL_SRC_COLOR"/>
- <value name="GL_ONE_MINUS_SRC_COLOR"/>
- <value name="GL_SRC_ALPHA"/>
- <value name="GL_ONE_MINUS_SRC_ALPHA"/>
- <value name="GL_DST_ALPHA"/>
- <value name="GL_ONE_MINUS_DST_ALPHA"/>
- <value name="GL_DST_COLOR"/>
- <value name="GL_ONE_MINUS_DST_COLOR"/>
- <value name="GL_SRC_ALPHA_SATURATE"/>
-
- <value name="GL_CONSTANT_COLOR" category="GLES2.0"/>
- <value name="GL_CONSTANT_ALPHA" category="GLES2.0"/>
- <value name="GL_ONE_MINUS_CONSTANT_COLOR" category="GLES2.0"/>
- <value name="GL_ONE_MINUS_CONSTANT_ALPHA" category="GLES2.0"/>
- </desc>
-
- <desc name="dfactor">
- <value name="GL_ZERO"/>
- <value name="GL_ONE"/>
- <value name="GL_SRC_COLOR"/>
- <value name="GL_ONE_MINUS_SRC_COLOR"/>
- <value name="GL_SRC_ALPHA"/>
- <value name="GL_ONE_MINUS_SRC_ALPHA"/>
- <value name="GL_DST_ALPHA"/>
- <value name="GL_ONE_MINUS_DST_ALPHA"/>
- <value name="GL_DST_COLOR"/>
- <value name="GL_ONE_MINUS_DST_COLOR"/>
-
- <value name="GL_CONSTANT_COLOR" category="GLES2.0"/>
- <value name="GL_CONSTANT_ALPHA" category="GLES2.0"/>
- <value name="GL_ONE_MINUS_CONSTANT_COLOR" category="GLES2.0"/>
- <value name="GL_ONE_MINUS_CONSTANT_ALPHA" category="GLES2.0"/>
- </desc>
-</template>
-
-<template name="LogicOp">
- <proto>
- <return type="void"/>
- <param name="opcode" type="GLenum"/>
- </proto>
-
- <desc name="opcode">
- <value name="GL_CLEAR"/>
- <value name="GL_SET"/>
- <value name="GL_COPY"/>
- <value name="GL_COPY_INVERTED"/>
- <value name="GL_NOOP"/>
- <value name="GL_INVERT"/>
- <value name="GL_AND"/>
- <value name="GL_NAND"/>
- <value name="GL_OR"/>
- <value name="GL_NOR"/>
- <value name="GL_XOR"/>
- <value name="GL_EQUIV"/>
- <value name="GL_AND_REVERSE"/>
- <value name="GL_AND_INVERTED"/>
- <value name="GL_OR_REVERSE"/>
- <value name="GL_OR_INVERTED"/>
- </desc>
-</template>
-
-<template name="StencilFunc">
- <proto>
- <return type="void"/>
- <param name="func" type="GLenum"/>
- <param name="ref" type="GLint"/>
- <param name="mask" type="GLuint"/>
- </proto>
-
- <desc name="func">
- <value name="GL_NEVER"/>
- <value name="GL_LESS"/>
- <value name="GL_LEQUAL"/>
- <value name="GL_GREATER"/>
- <value name="GL_GEQUAL"/>
- <value name="GL_EQUAL"/>
- <value name="GL_NOTEQUAL"/>
- <value name="GL_ALWAYS"/>
- </desc>
-</template>
-
-<template name="StencilFuncSeparate">
- <proto>
- <return type="void"/>
- <param name="face" type="GLenum"/>
- <param name="func" type="GLenum"/>
- <param name="ref" type="GLint"/>
- <param name="mask" type="GLuint"/>
- </proto>
-
- <desc name="face">
- <value name="GL_FRONT"/>
- <value name="GL_BACK"/>
- <value name="GL_FRONT_AND_BACK"/>
- </desc>
-
- <desc name="func">
- <value name="GL_NEVER"/>
- <value name="GL_LESS"/>
- <value name="GL_LEQUAL"/>
- <value name="GL_GREATER"/>
- <value name="GL_GEQUAL"/>
- <value name="GL_EQUAL"/>
- <value name="GL_NOTEQUAL"/>
- <value name="GL_ALWAYS"/>
- </desc>
-</template>
-
-<template name="StencilOp">
- <proto>
- <return type="void"/>
- <param name="fail" type="GLenum"/>
- <param name="zfail" type="GLenum"/>
- <param name="zpass" type="GLenum"/>
- </proto>
-
- <desc name="fail">
- <value name="GL_KEEP"/>
- <value name="GL_ZERO"/>
- <value name="GL_REPLACE"/>
- <value name="GL_INCR"/>
- <value name="GL_DECR"/>
- <value name="GL_INVERT"/>
- <value name="GL_INCR_WRAP" category="GLES2.0"/>
- <value name="GL_DECR_WRAP" category="GLES2.0"/>
- <value name="GL_INCR_WRAP_OES" category="OES_stencil_wrap"/>
- <value name="GL_DECR_WRAP_OES" category="OES_stencil_wrap"/>
- </desc>
-
- <desc name="zfail">
- <value name="GL_KEEP"/>
- <value name="GL_ZERO"/>
- <value name="GL_REPLACE"/>
- <value name="GL_INCR"/>
- <value name="GL_DECR"/>
- <value name="GL_INVERT"/>
- <value name="GL_INCR_WRAP" category="GLES2.0"/>
- <value name="GL_DECR_WRAP" category="GLES2.0"/>
- <value name="GL_INCR_WRAP_OES" category="OES_stencil_wrap"/>
- <value name="GL_DECR_WRAP_OES" category="OES_stencil_wrap"/>
- </desc>
-
- <desc name="zpass">
- <value name="GL_KEEP"/>
- <value name="GL_ZERO"/>
- <value name="GL_REPLACE"/>
- <value name="GL_INCR"/>
- <value name="GL_DECR"/>
- <value name="GL_INVERT"/>
- <value name="GL_INCR_WRAP" category="GLES2.0"/>
- <value name="GL_DECR_WRAP" category="GLES2.0"/>
- <value name="GL_INCR_WRAP_OES" category="OES_stencil_wrap"/>
- <value name="GL_DECR_WRAP_OES" category="OES_stencil_wrap"/>
- </desc>
-</template>
-
-<template name="StencilOpSeparate">
- <proto>
- <return type="void"/>
- <param name="face" type="GLenum"/>
- <param name="fail" type="GLenum"/>
- <param name="zfail" type="GLenum"/>
- <param name="zpass" type="GLenum"/>
- </proto>
-
- <desc name="face">
- <value name="GL_FRONT"/>
- <value name="GL_BACK"/>
- <value name="GL_FRONT_AND_BACK"/>
- </desc>
-
- <desc name="fail">
- <value name="GL_KEEP"/>
- <value name="GL_ZERO"/>
- <value name="GL_REPLACE"/>
- <value name="GL_INCR"/>
- <value name="GL_DECR"/>
- <value name="GL_INVERT"/>
- <value name="GL_INCR_WRAP"/>
- <value name="GL_DECR_WRAP"/>
- </desc>
-
- <desc name="zfail">
- <value name="GL_KEEP"/>
- <value name="GL_ZERO"/>
- <value name="GL_REPLACE"/>
- <value name="GL_INCR"/>
- <value name="GL_DECR"/>
- <value name="GL_INVERT"/>
- <value name="GL_INCR_WRAP"/>
- <value name="GL_DECR_WRAP"/>
- </desc>
-
- <desc name="zpass">
- <value name="GL_KEEP"/>
- <value name="GL_ZERO"/>
- <value name="GL_REPLACE"/>
- <value name="GL_INCR"/>
- <value name="GL_DECR"/>
- <value name="GL_INVERT"/>
- <value name="GL_INCR_WRAP"/>
- <value name="GL_DECR_WRAP"/>
- </desc>
-</template>
-
-<template name="DepthFunc">
- <proto>
- <return type="void"/>
- <param name="func" type="GLenum"/>
- </proto>
-
- <desc name="func">
- <value name="GL_NEVER"/>
- <value name="GL_LESS"/>
- <value name="GL_EQUAL"/>
- <value name="GL_LEQUAL"/>
- <value name="GL_GREATER"/>
- <value name="GL_NOTEQUAL"/>
- <value name="GL_GEQUAL"/>
- <value name="GL_ALWAYS"/>
- </desc>
-</template>
-
-<template name="PixelStore">
- <proto>
- <return type="void"/>
- <param name="pname" type="GLenum"/>
- <param name="param" type="GLtype"/>
- </proto>
-
- <desc name="pname">
- <value name="GL_PACK_ALIGNMENT"/>
- <value name="GL_UNPACK_ALIGNMENT"/>
- </desc>
-
- <desc name="param" error="GL_INVALID_VALUE">
- <value name="1"/>
- <value name="2"/>
- <value name="4"/>
- <value name="8"/>
- </desc>
-</template>
-
-<template name="ReadPixels" direction="get">
- <proto>
- <return type="void"/>
- <param name="x" type="GLint"/>
- <param name="y" type="GLint"/>
- <param name="width" type="GLsizei"/>
- <param name="height" type="GLsizei"/>
- <param name="format" type="GLenum"/>
- <param name="type" type="GLenum"/>
- <param name="pixels" type="GLvoid *"/>
- </proto>
-
- <!-- Technically, only two combinations are actually allowed:
- GL_RGBA/GL_UNSIGNED_BYTE, and some implementation-specific
- internal preferred combination. I don't know what that is, so I'm
- allowing any valid combination for now; the underlying support
- should fail when necessary.-->
- <desc name="format">
- <value name="GL_ALPHA"/>
- <desc name="type" error="GL_INVALID_OPERATION">
- <value name="GL_UNSIGNED_BYTE"/>
- </desc>
- </desc>
-
- <desc name="format">
- <value name="GL_RGB"/>
- <desc name="type" error="GL_INVALID_OPERATION">
- <value name="GL_UNSIGNED_BYTE"/>
- <value name="GL_UNSIGNED_SHORT_5_6_5"/>
- </desc>
- </desc>
-
- <desc name="format">
- <value name="GL_RGBA"/>
- <desc name="type" error="GL_INVALID_OPERATION">
- <value name="GL_UNSIGNED_BYTE"/>
- <value name="GL_UNSIGNED_SHORT_4_4_4_4"/>
- <value name="GL_UNSIGNED_SHORT_5_5_5_1"/>
- </desc>
- </desc>
-
- <desc name="format">
- <value name="GL_LUMINANCE"/>
- <desc name="type" error="GL_INVALID_OPERATION">
- <value name="GL_UNSIGNED_BYTE"/>
- </desc>
- </desc>
-
- <desc name="format">
- <value name="GL_LUMINANCE_ALPHA"/>
- <desc name="type" error="GL_INVALID_OPERATION">
- <value name="GL_UNSIGNED_BYTE"/>
- </desc>
- </desc>
-
- <desc name="format" category="EXT_read_format_bgra">
- <value name="GL_BGRA_EXT"/>
-
- <desc name="type" error="GL_INVALID_OPERATION">
- <value name="GL_UNSIGNED_BYTE"/>
- <value name="GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT"/>
- <value name="GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT"/>
- </desc>
- </desc>
-</template>
-
-<template name="GetClipPlane" direction="get">
- <proto>
- <return type="void"/>
- <param name="plane" type="GLenum"/>
- <vector name="equation" type="GLtype *" size="4"/>
- </proto>
-
- <desc name="plane">
- <range base="GL_CLIP_PLANE" from="0" to="5"/>
- </desc>
-</template>
-
-<template name="GetError" direction="get">
- <proto>
- <return type="GLenum"/>
- </proto>
-</template>
-
-<!-- template for GetFloatv, GetIntegerv, GetBoolean, and GetFixedv -->
-<template name="GetState" direction="get">
- <proto>
- <return type="void"/>
- <param name="pname" type="GLenum"/>
- <vector name="params" type="GLtype *" size="dynamic"/>
- </proto>
- <!-- param checking is done in mesa -->
-</template>
-
-<template name="GetLight" direction="get">
- <proto>
- <return type="void"/>
- <param name="light" type="GLenum"/>
- <param name="pname" type="GLenum"/>
- <vector name="params" type="GLtype *" size="dynamic"/>
- </proto>
-
- <desc name="light">
- <range base="GL_LIGHT" from="0" to="7"/>
- </desc>
-
- <desc name="pname">
- <value name="GL_AMBIENT"/>
- <value name="GL_DIFFUSE"/>
- <value name="GL_SPECULAR"/>
- <value name="GL_POSITION"/>
-
- <desc name="params" vector_size="4"/>
- </desc>
-
- <desc name="pname">
- <value name="GL_SPOT_DIRECTION"/>
-
- <desc name="params" vector_size="3"/>
- </desc>
-
- <desc name="pname">
- <value name="GL_SPOT_EXPONENT"/>
- <value name="GL_SPOT_CUTOFF"/>
- <value name="GL_CONSTANT_ATTENUATION"/>
- <value name="GL_LINEAR_ATTENUATION"/>
- <value name="GL_QUADRATIC_ATTENUATION"/>
-
- <desc name="params" vector_size="1"/>
- </desc>
-</template>
-
-<template name="GetMaterial" direction="get">
- <proto>
- <return type="void"/>
- <param name="face" type="GLenum"/>
- <param name="pname" type="GLenum"/>
- <vector name="params" type="GLtype *" size="dynamic">
- <param name="param" type="GLtype"/>
- </vector>
- </proto>
-
- <desc name="face">
- <value name="GL_FRONT"/>
- <value name="GL_BACK"/>
- </desc>
-
- <desc name="pname">
- <value name="GL_SHININESS"/>
- <desc name="params" vector_size="1"/>
- </desc>
-
- <desc name="pname">
- <value name="GL_AMBIENT"/>
- <value name="GL_DIFFUSE"/>
- <value name="GL_AMBIENT_AND_DIFFUSE"/>
- <value name="GL_SPECULAR"/>
- <value name="GL_EMISSION"/>
-
- <desc name="params" vector_size="4"/>
- </desc>
-</template>
-
-<template name="GetString" direction="get">
- <proto>
- <return type="const GLubyte *"/>
- <param name="name" type="GLenum"/>
- </proto>
-
- <desc name="name">
- <value name="GL_VENDOR"/>
- <value name="GL_RENDERER"/>
- <value name="GL_VERSION"/>
- <value name="GL_EXTENSIONS"/>
- <value name="GL_SHADING_LANGUAGE_VERSION" category="GLES2.0"/>
- </desc>
-</template>
-
-<template name="GetTexEnv" direction="get">
- <proto>
- <return type="void"/>
- <param name="target" type="GLenum"/>
- <param name="pname" type="GLenum"/>
- <vector name="params" type="GLtype *" size="dynamic"/>
- </proto>
-
- <desc name="target" category="OES_point_sprite">
- <value name="GL_POINT_SPRITE_OES"/>
- <desc name="pname">
- <value name="GL_COORD_REPLACE_OES"/>
- </desc>
- </desc>
-
- <desc name="pname" category="OES_point_sprite">
- <value name="GL_COORD_REPLACE_OES"/>
- <desc name="params" vector_size="1" convert="false"/>
- </desc>
-
- <desc name="target" category="EXT_texture_lod_bias">
- <value name="GL_TEXTURE_FILTER_CONTROL_EXT"/>
-
- <desc name="pname">
- <value name="GL_TEXTURE_LOD_BIAS_EXT"/>
- </desc>
- </desc>
-
- <desc name="pname" category="EXT_texture_lod_bias">
- <value name="GL_TEXTURE_LOD_BIAS_EXT"/>
- <desc name="params" vector_size="1"/>
- </desc>
-
- <desc name="target">
- <value name="GL_TEXTURE_ENV"/>
-
- <desc name="pname">
- <value name="GL_TEXTURE_ENV_COLOR"/>
- <value name="GL_RGB_SCALE"/>
- <value name="GL_ALPHA_SCALE"/>
- <value name="GL_TEXTURE_ENV_MODE"/>
- <value name="GL_COMBINE_RGB"/>
- <value name="GL_COMBINE_ALPHA"/>
- <value name="GL_SRC0_RGB"/>
- <value name="GL_SRC1_RGB"/>
- <value name="GL_SRC2_RGB"/>
- <value name="GL_SRC0_ALPHA"/>
- <value name="GL_SRC1_ALPHA"/>
- <value name="GL_SRC2_ALPHA"/>
- <value name="GL_OPERAND0_RGB"/>
- <value name="GL_OPERAND1_RGB"/>
- <value name="GL_OPERAND2_RGB"/>
- <value name="GL_OPERAND0_ALPHA"/>
- <value name="GL_OPERAND1_ALPHA"/>
- <value name="GL_OPERAND2_ALPHA"/>
- </desc>
- </desc>
-
- <desc name="pname">
- <value name="GL_TEXTURE_ENV_COLOR"/>
- <desc name="params" vector_size="4"/>
- </desc>
-
- <desc name="pname">
- <value name="GL_RGB_SCALE"/>
- <value name="GL_ALPHA_SCALE"/>
-
- <desc name="params" vector_size="1"/>
- </desc>
-
- <desc name="pname">
- <value name="GL_TEXTURE_ENV_MODE"/>
- <value name="GL_COMBINE_RGB"/>
- <value name="GL_COMBINE_ALPHA"/>
- <value name="GL_SRC0_RGB"/>
- <value name="GL_SRC1_RGB"/>
- <value name="GL_SRC2_RGB"/>
- <value name="GL_SRC0_ALPHA"/>
- <value name="GL_SRC1_ALPHA"/>
- <value name="GL_SRC2_ALPHA"/>
- <value name="GL_OPERAND0_RGB"/>
- <value name="GL_OPERAND1_RGB"/>
- <value name="GL_OPERAND2_RGB"/>
- <value name="GL_OPERAND0_ALPHA"/>
- <value name="GL_OPERAND1_ALPHA"/>
- <value name="GL_OPERAND2_ALPHA"/>
-
- <desc name="params" vector_size="1" convert="false"/>
- </desc>
-</template>
-
-<template name="GetTexGen" direction="get">
- <proto>
- <return type="void"/>
- <param name="coord" type="GLenum"/>
- <param name="pname" type="GLenum"/>
- <vector name="params" type="GLtype *" size="dynamic"/>
- </proto>
-
- <desc name="coord">
- <value name="GL_TEXTURE_GEN_STR_OES"/>
- </desc>
- <desc name="pname">
- <value name="GL_TEXTURE_GEN_MODE_OES"/>
- <desc name="params" vector_size="1" convert="false"/>
- </desc>
-</template>
-
-<template name="GetTexParameter" direction="get">
- <proto>
- <return type="void"/>
- <param name="target" type="GLenum"/>
- <param name="pname" type="GLenum"/>
- <vector name="params" type="GLtype *" size="dynamic"/>
- </proto>
-
- <desc name="target">
- <value name="GL_TEXTURE_2D"/>
- <value name="GL_TEXTURE_CUBE_MAP" category="GLES2.0"/>
- <value name="GL_TEXTURE_CUBE_MAP_OES" category="OES_texture_cube_map"/>
- <value name="GL_TEXTURE_3D_OES" category="OES_texture_3D"/>
- </desc>
-
- <desc name="pname">
- <value name="GL_TEXTURE_WRAP_S"/>
- <value name="GL_TEXTURE_WRAP_T"/>
- <value name="GL_TEXTURE_WRAP_R_OES" category="OES_texture_3D"/>
- <value name="GL_TEXTURE_MIN_FILTER"/>
- <value name="GL_TEXTURE_MAG_FILTER"/>
- <value name="GL_GENERATE_MIPMAP" category="GLES1.1"/>
-
- <desc name="params" vector_size="1" convert="false"/>
- </desc>
-
- <desc name="pname" category="OES_draw_texture">
- <value name="GL_TEXTURE_CROP_RECT_OES"/>
- <desc name="params" vector_size="4"/>
- </desc>
-</template>
-
-<template name="IsEnabled" direction="get">
- <proto>
- <return type="GLboolean"/>
- <param name="cap" type="GLenum"/>
- </proto>
-
- <desc name="cap" category="GLES1.1">
- <value name="GL_NORMALIZE"/>
- <value name="GL_RESCALE_NORMAL"/>
-
- <range base="GL_CLIP_PLANE" from="0" to="5"/>
-
- <value name="GL_FOG"/>
- <value name="GL_LIGHTING"/>
- <value name="GL_COLOR_MATERIAL"/>
-
- <range base="GL_LIGHT" from="0" to="7"/>
-
- <value name="GL_POINT_SMOOTH"/>
- <value name="GL_LINE_SMOOTH"/>
- <value name="GL_CULL_FACE"/>
- <value name="GL_POLYGON_OFFSET_FILL"/>
- <value name="GL_MULTISAMPLE"/>
- <value name="GL_SAMPLE_ALPHA_TO_COVERAGE"/>
- <value name="GL_SAMPLE_ALPHA_TO_ONE"/>
- <value name="GL_SAMPLE_COVERAGE"/>
- <value name="GL_TEXTURE_2D"/>
- <value name="GL_SCISSOR_TEST"/>
- <value name="GL_ALPHA_TEST"/>
- <value name="GL_STENCIL_TEST"/>
- <value name="GL_DEPTH_TEST"/>
- <value name="GL_BLEND"/>
- <value name="GL_DITHER"/>
- <value name="GL_COLOR_LOGIC_OP"/>
-
- <value name="GL_POINT_SPRITE_OES" category="OES_point_sprite"/>
- <value name="GL_TEXTURE_CUBE_MAP_OES" category="OES_texture_cube_map"/>
- <value name="GL_TEXTURE_GEN_STR_OES" category="OES_texture_cube_map"/>
-
- <value name="GL_VERTEX_ARRAY"/>
- <value name="GL_NORMAL_ARRAY"/>
- <value name="GL_COLOR_ARRAY"/>
- <value name="GL_TEXTURE_COORD_ARRAY"/>
- <value name="GL_MATRIX_INDEX_ARRAY_OES" category="OES_matrix_palette"/>
- <value name="GL_WEIGHT_ARRAY_OES" category="OES_matrix_palette"/>
- <value name="GL_POINT_SIZE_ARRAY_OES" category="OES_point_size_array"/>
- </desc>
-
- <desc name="cap" category="GLES2.0">
- <value name="GL_CULL_FACE"/>
- <value name="GL_SCISSOR_TEST"/>
- <value name="GL_POLYGON_OFFSET_FILL"/>
- <value name="GL_SAMPLE_ALPHA_TO_COVERAGE"/>
- <value name="GL_SAMPLE_COVERAGE"/>
- <value name="GL_STENCIL_TEST"/>
- <value name="GL_DEPTH_TEST"/>
- <value name="GL_DITHER"/>
- <value name="GL_BLEND"/>
- </desc>
-</template>
-
-<template name="DepthRange">
- <proto>
- <return type="void"/>
- <param name="zNear" type="GLtype"/>
- <param name="zFar" type="GLtype"/>
- </proto>
-</template>
-
-<template name="Frustum">
- <proto>
- <return type="void"/>
- <param name="left" type="GLtype"/>
- <param name="right" type="GLtype"/>
- <param name="bottom" type="GLtype"/>
- <param name="top" type="GLtype"/>
- <param name="zNear" type="GLtype"/>
- <param name="zFar" type="GLtype"/>
- </proto>
-</template>
-
-<template name="LoadIdentity">
- <proto>
- <return type="void"/>
- </proto>
-</template>
-
-<template name="LoadMatrix">
- <proto>
- <return type="void"/>
- <vector name="m" type="const GLtype *" size="16"/>
- </proto>
-</template>
-
-<template name="MatrixMode">
- <proto>
- <return type="void"/>
- <param name="mode" type="GLenum"/>
- </proto>
-
- <desc name="mode">
- <value name="GL_MODELVIEW"/>
- <value name="GL_PROJECTION"/>
- <value name="GL_TEXTURE"/>
- <value name="GL_MATRIX_PALETTE_OES" category="OES_matrix_palette"/>
- </desc>
-</template>
-
-<template name="MultMatrix">
- <proto>
- <return type="void"/>
- <vector name="m" type="const GLtype *" size="16"/>
- </proto>
-</template>
-
-<template name="Ortho">
- <proto>
- <return type="void"/>
- <param name="left" type="GLtype"/>
- <param name="right" type="GLtype"/>
- <param name="bottom" type="GLtype"/>
- <param name="top" type="GLtype"/>
- <param name="zNear" type="GLtype"/>
- <param name="zFar" type="GLtype"/>
- </proto>
-</template>
-
-<template name="PopMatrix">
- <proto>
- <return type="void"/>
- </proto>
-</template>
-
-<template name="PushMatrix">
- <proto>
- <return type="void"/>
- </proto>
-</template>
-
-<template name="Rotate">
- <proto>
- <return type="void"/>
- <param name="angle" type="GLtype"/>
- <param name="x" type="GLtype"/>
- <param name="y" type="GLtype"/>
- <param name="z" type="GLtype"/>
- </proto>
-</template>
-
-<template name="Scale">
- <proto>
- <return type="void"/>
- <param name="x" type="GLtype"/>
- <param name="y" type="GLtype"/>
- <param name="z" type="GLtype"/>
- </proto>
-</template>
-
-<template name="Translate">
- <proto>
- <return type="void"/>
- <param name="x" type="GLtype"/>
- <param name="y" type="GLtype"/>
- <param name="z" type="GLtype"/>
- </proto>
-</template>
-
-<template name="Viewport">
- <proto>
- <return type="void"/>
- <param name="x" type="GLint"/>
- <param name="y" type="GLint"/>
- <param name="width" type="GLsizei"/>
- <param name="height" type="GLsizei"/>
- </proto>
-</template>
-
-<template name="ColorPointer">
- <proto>
- <return type="void"/>
- <param name="size" type="GLint"/>
- <param name="type" type="GLenum"/>
- <param name="stride" type="GLsizei"/>
- <param name="pointer" type="const GLvoid *"/>
- </proto>
-
- <desc name="size" error="GL_INVALID_VALUE">
- <value name="4"/>
- </desc>
-
- <desc name="type">
- <value name="GL_UNSIGNED_BYTE"/>
- <value name="GL_FLOAT"/>
- <value name="GL_FIXED"/>
- <value name="GL_HALF_FLOAT_OES" category="OES_vertex_half_float"/>
- </desc>
-</template>
-
-<template name="DisableClientState">
- <proto>
- <return type="void"/>
- <param name="array" type="GLenum"/>
- </proto>
-
- <desc name="array">
- <value name="GL_VERTEX_ARRAY"/>
- <value name="GL_NORMAL_ARRAY"/>
- <value name="GL_COLOR_ARRAY"/>
- <value name="GL_TEXTURE_COORD_ARRAY"/>
- <value name="GL_MATRIX_INDEX_ARRAY_OES" category="OES_matrix_palette"/>
- <value name="GL_WEIGHT_ARRAY_OES" category="OES_matrix_palette"/>
- <value name="GL_POINT_SIZE_ARRAY_OES" category="OES_point_size_array"/>
- </desc>
-</template>
-
-<template name="DrawArrays">
- <proto>
- <return type="void"/>
- <param name="mode" type="GLenum"/>
- <param name="first" type="GLint"/>
- <param name="count" type="GLsizei"/>
- </proto>
-
- <desc name="mode">
- <value name="GL_POINTS"/>
- <value name="GL_LINES"/>
- <value name="GL_LINE_LOOP"/>
- <value name="GL_LINE_STRIP"/>
- <value name="GL_TRIANGLES"/>
- <value name="GL_TRIANGLE_STRIP"/>
- <value name="GL_TRIANGLE_FAN"/>
- </desc>
-</template>
-
-<template name="DrawElements">
- <proto>
- <return type="void"/>
- <param name="mode" type="GLenum"/>
- <param name="count" type="GLsizei"/>
- <param name="type" type="GLenum"/>
- <param name="indices" type="const GLvoid *"/>
- </proto>
-
- <desc name="mode">
- <value name="GL_POINTS"/>
- <value name="GL_LINES"/>
- <value name="GL_LINE_LOOP"/>
- <value name="GL_LINE_STRIP"/>
- <value name="GL_TRIANGLES"/>
- <value name="GL_TRIANGLE_STRIP"/>
- <value name="GL_TRIANGLE_FAN"/>
- </desc>
-
- <desc name="type">
- <value name="GL_UNSIGNED_BYTE"/>
- <value name="GL_UNSIGNED_SHORT"/>
- <value name="GL_UNSIGNED_INT" category="OES_element_index_uint"/>
- </desc>
-</template>
-
-<template name="EnableClientState">
- <proto>
- <return type="void"/>
- <param name="array" type="GLenum"/>
- </proto>
-
- <desc name="array">
- <value name="GL_VERTEX_ARRAY"/>
- <value name="GL_NORMAL_ARRAY"/>
- <value name="GL_COLOR_ARRAY"/>
- <value name="GL_TEXTURE_COORD_ARRAY"/>
- <value name="GL_MATRIX_INDEX_ARRAY_OES" category="OES_matrix_palette"/>
- <value name="GL_WEIGHT_ARRAY_OES" category="OES_matrix_palette"/>
- <value name="GL_POINT_SIZE_ARRAY_OES" category="OES_point_size_array"/>
- </desc>
-</template>
-
-<template name="GetPointer" direction="get">
- <proto>
- <return type="void"/>
- <param name="pname" type="GLenum"/>
- <vector name="params" type="GLvoid **" size="dynamic"/>
- </proto>
-
- <desc name="pname">
- <value name="GL_VERTEX_ARRAY_POINTER"/>
- <value name="GL_NORMAL_ARRAY_POINTER"/>
- <value name="GL_COLOR_ARRAY_POINTER"/>
- <value name="GL_TEXTURE_COORD_ARRAY_POINTER"/>
- <value name="GL_MATRIX_INDEX_ARRAY_POINTER_OES" category="OES_matrix_palette"/>
- <value name="GL_WEIGHT_ARRAY_POINTER_OES" category="OES_matrix_palette"/>
- <value name="GL_POINT_SIZE_ARRAY_POINTER_OES" category="OES_point_size_array"/>
- </desc>
-</template>
-
-<template name="Normal">
- <proto>
- <return type="void"/>
- <vector name="v" type="const GLtype *" size="3">
- <param name="nx" type="GLtype"/>
- <param name="ny" type="GLtype"/>
- <param name="nz" type="GLtype"/>
- </vector>
- </proto>
-</template>
-
-<template name="NormalPointer">
- <proto>
- <return type="void"/>
- <param name="type" type="GLenum"/>
- <param name="stride" type="GLsizei"/>
- <param name="pointer" type="const GLvoid *"/>
- </proto>
-
- <desc name="type">
- <value name="GL_BYTE"/>
- <value name="GL_SHORT"/>
- <value name="GL_FLOAT"/>
- <value name="GL_FIXED"/>
- <value name="GL_HALF_FLOAT_OES" category="OES_vertex_half_float"/>
- </desc>
-</template>
-
-<template name="TexCoordPointer">
- <proto>
- <return type="void"/>
- <param name="size" type="GLint"/>
- <param name="type" type="GLenum"/>
- <param name="stride" type="GLsizei"/>
- <param name="pointer" type="const GLvoid *"/>
- </proto>
-
- <desc name="size" error="GL_INVALID_VALUE">
- <value name="2"/>
- <value name="3"/>
- <value name="4"/>
- </desc>
-
- <desc name="type">
- <value name="GL_BYTE"/>
- <value name="GL_SHORT"/>
- <value name="GL_FLOAT"/>
- <value name="GL_FIXED"/>
- <value name="GL_HALF_FLOAT_OES" category="OES_vertex_half_float"/>
- </desc>
-</template>
-
-<template name="VertexPointer">
- <proto>
- <return type="void"/>
- <param name="size" type="GLint"/>
- <param name="type" type="GLenum"/>
- <param name="stride" type="GLsizei"/>
- <param name="pointer" type="const GLvoid *"/>
- </proto>
-
- <desc name="size" error="GL_INVALID_VALUE">
- <value name="2"/>
- <value name="3"/>
- <value name="4"/>
- </desc>
-
- <desc name="type">
- <value name="GL_BYTE"/>
- <value name="GL_SHORT"/>
- <value name="GL_FLOAT"/>
- <value name="GL_FIXED"/>
- <value name="GL_HALF_FLOAT_OES" category="OES_vertex_half_float"/>
- </desc>
-</template>
-
-<template name="PolygonOffset">
- <proto>
- <return type="void"/>
- <param name="factor" type="GLtype"/>
- <param name="units" type="GLtype"/>
- </proto>
-</template>
-
-<template name="CopyTexImage2D">
- <proto>
- <return type="void"/>
- <param name="target" type="GLenum"/>
- <param name="level" type="GLint"/>
- <param name="internalFormat" type="GLenum"/>
- <param name="x" type="GLint"/>
- <param name="y" type="GLint"/>
- <param name="width" type="GLsizei"/>
- <param name="height" type="GLsizei"/>
- <param name="border" type="GLint"/>
- </proto>
-
- <desc name="target">
- <value name="GL_TEXTURE_2D"/>
- <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_X" category="GLES2.0"/>
- <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Y" category="GLES2.0"/>
- <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Z" category="GLES2.0"/>
- <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_X" category="GLES2.0"/>
- <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Y" category="GLES2.0"/>
- <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Z" category="GLES2.0"/>
- <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_X_OES" category="OES_texture_cube_map"/>
- <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Y_OES" category="OES_texture_cube_map"/>
- <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Z_OES" category="OES_texture_cube_map"/>
- <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_X_OES" category="OES_texture_cube_map"/>
- <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_OES" category="OES_texture_cube_map"/>
- <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_OES" category="OES_texture_cube_map"/>
- </desc>
-
- <desc name="internalFormat" error="GL_INVALID_VALUE">
- <value name="GL_ALPHA"/>
- <value name="GL_RGB"/>
- <value name="GL_RGBA"/>
- <value name="GL_LUMINANCE"/>
- <value name="GL_LUMINANCE_ALPHA"/>
- </desc>
-
- <desc name="border" error="GL_INVALID_VALUE">
- <value name="0"/>
- </desc>
-</template>
-
-<template name="CopyTexSubImage2D">
- <proto>
- <return type="void"/>
- <param name="target" type="GLenum"/>
- <param name="level" type="GLint"/>
- <param name="xoffset" type="GLint"/>
- <param name="yoffset" type="GLint"/>
- <param name="x" type="GLint"/>
- <param name="y" type="GLint"/>
- <param name="width" type="GLsizei"/>
- <param name="height" type="GLsizei"/>
- </proto>
-
- <desc name="target">
- <value name="GL_TEXTURE_2D"/>
- <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_X" category="GLES2.0"/>
- <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Y" category="GLES2.0"/>
- <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Z" category="GLES2.0"/>
- <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_X" category="GLES2.0"/>
- <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Y" category="GLES2.0"/>
- <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Z" category="GLES2.0"/>
- <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_X_OES" category="OES_texture_cube_map"/>
- <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Y_OES" category="OES_texture_cube_map"/>
- <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Z_OES" category="OES_texture_cube_map"/>
- <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_X_OES" category="OES_texture_cube_map"/>
- <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_OES" category="OES_texture_cube_map"/>
- <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_OES" category="OES_texture_cube_map"/>
- </desc>
-</template>
-
-<template name="TexSubImage2D">
- <proto>
- <return type="void"/>
- <param name="target" type="GLenum"/>
- <param name="level" type="GLint"/>
- <param name="xoffset" type="GLint"/>
- <param name="yoffset" type="GLint"/>
- <param name="width" type="GLsizei"/>
- <param name="height" type="GLsizei"/>
- <param name="format" type="GLenum"/>
- <param name="type" type="GLenum"/>
- <param name="pixels" type="const GLvoid *"/>
- </proto>
-
- <desc name="target">
- <value name="GL_TEXTURE_2D"/>
- <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_X" category="GLES2.0"/>
- <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Y" category="GLES2.0"/>
- <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Z" category="GLES2.0"/>
- <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_X" category="GLES2.0"/>
- <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Y" category="GLES2.0"/>
- <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Z" category="GLES2.0"/>
- <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_X_OES" category="OES_texture_cube_map"/>
- <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Y_OES" category="OES_texture_cube_map"/>
- <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Z_OES" category="OES_texture_cube_map"/>
- <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_X_OES" category="OES_texture_cube_map"/>
- <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_OES" category="OES_texture_cube_map"/>
- <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_OES" category="OES_texture_cube_map"/>
- </desc>
-
- <desc name="format">
- <value name="GL_ALPHA"/>
-
- <desc name="type" error="GL_INVALID_OPERATION">
- <value name="GL_UNSIGNED_BYTE"/>
- <value name="GL_FLOAT" category="OES_texture_float"/>
- <value name="GL_HALF_FLOAT_OES" category="OES_texture_half_float"/>
- </desc>
- </desc>
-
- <desc name="format">
- <value name="GL_RGB"/>
-
- <desc name="type" error="GL_INVALID_OPERATION">
- <value name="GL_UNSIGNED_BYTE"/>
- <value name="GL_UNSIGNED_SHORT_5_6_5"/>
- <value name="GL_FLOAT" category="OES_texture_float"/>
- <value name="GL_HALF_FLOAT_OES" category="OES_texture_half_float"/>
- </desc>
- </desc>
-
- <desc name="format">
- <value name="GL_RGBA"/>
-
- <desc name="type" error="GL_INVALID_OPERATION">
- <value name="GL_UNSIGNED_BYTE"/>
- <value name="GL_UNSIGNED_SHORT_4_4_4_4"/>
- <value name="GL_UNSIGNED_SHORT_5_5_5_1"/>
- <value name="GL_FLOAT" category="OES_texture_float"/>
- <value name="GL_HALF_FLOAT_OES" category="OES_texture_half_float"/>
- <value name="GL_UNSIGNED_INT_2_10_10_10_REV_EXT" category="EXT_texture_type_2_10_10_10_REV"/>
- </desc>
- </desc>
-
- <desc name="format">
- <value name="GL_LUMINANCE"/>
-
- <desc name="type" error="GL_INVALID_OPERATION">
- <value name="GL_UNSIGNED_BYTE"/>
- <value name="GL_FLOAT" category="OES_texture_float"/>
- <value name="GL_HALF_FLOAT_OES" category="OES_texture_half_float"/>
- </desc>
- </desc>
-
- <desc name="format">
- <value name="GL_LUMINANCE_ALPHA"/>
-
- <desc name="type" error="GL_INVALID_OPERATION">
- <value name="GL_UNSIGNED_BYTE"/>
- <value name="GL_FLOAT" category="OES_texture_float"/>
- <value name="GL_HALF_FLOAT_OES" category="OES_texture_half_float"/>
- </desc>
- </desc>
-
- <desc name="format" category="OES_depth_texture">
- <value name="GL_DEPTH_COMPONENT"/>
-
- <desc name="type" error="GL_INVALID_OPERATION">
- <value name="GL_UNSIGNED_SHORT"/>
- <value name="GL_UNSIGNED_INT"/>
- </desc>
- </desc>
-
- <desc name="format" category="OES_packed_depth_stencil">
- <value name="GL_DEPTH_STENCIL_OES"/>
-
- <desc name="type" error="GL_INVALID_OPERATION">
- <value name="GL_UNSIGNED_INT_24_8_OES"/>
- </desc>
- </desc>
-
- <desc name="format" category="EXT_texture_format_BGRA8888">
- <value name="GL_BGRA_EXT"/>
-
- <desc name="type" error="GL_INVALID_OPERATION">
- <value name="GL_UNSIGNED_BYTE"/>
- </desc>
- </desc>
-</template>
-
-<template name="BindTexture">
- <proto>
- <return type="void"/>
- <param name="target" type="GLenum"/>
- <param name="texture" type="GLuint"/>
- </proto>
-
- <desc name="target">
- <value name="GL_TEXTURE_2D"/>
- <value name="GL_TEXTURE_CUBE_MAP" category="GLES2.0"/>
- <value name="GL_TEXTURE_CUBE_MAP_OES" category="OES_texture_cube_map"/>
- <value name="GL_TEXTURE_3D_OES" category="OES_texture_3D"/>
- </desc>
-</template>
-
-<template name="DeleteTextures">
- <proto>
- <return type="void"/>
- <param name="n" type="GLsizei"/>
- <param name="textures" type="const GLuint *"/>
- </proto>
-</template>
-
-<template name="GenTextures" direction="get">
- <proto>
- <return type="void"/>
- <param name="n" type="GLsizei"/>
- <param name="textures" type="GLuint *"/>
- </proto>
-</template>
-
-<template name="IsTexture" direction="get">
- <proto>
- <return type="GLboolean"/>
- <param name="texture" type="GLuint"/>
- </proto>
-</template>
-
-<template name="BlendColor">
- <proto>
- <return type="void"/>
- <param name="red" type="GLtype"/>
- <param name="green" type="GLtype"/>
- <param name="blue" type="GLtype"/>
- <param name="alpha" type="GLtype"/>
- </proto>
-</template>
-
-<template name="BlendEquation">
- <proto>
- <return type="void"/>
- <param name="mode" type="GLenum"/>
- </proto>
-
- <desc name="mode">
- <value name="GL_FUNC_ADD" category="GLES2.0"/>
- <value name="GL_FUNC_SUBTRACT" category="GLES2.0"/>
- <value name="GL_FUNC_REVERSE_SUBTRACT" category="GLES2.0"/>
- <value name="GL_FUNC_ADD_OES" category="OES_blend_subtract"/>
- <value name="GL_FUNC_SUBTRACT_OES" category="OES_blend_subtract"/>
- <value name="GL_FUNC_REVERSE_SUBTRACT_OES" category="OES_blend_subtract"/>
-
- <value name="GL_MIN_EXT" category="EXT_blend_minmax"/>
- <value name="GL_MAX_EXT" category="EXT_blend_minmax"/>
- </desc>
-</template>
-
-<template name="BlendEquationSeparate">
- <proto>
- <return type="void"/>
- <param name="modeRGB" type="GLenum"/>
- <param name="modeAlpha" type="GLenum"/>
- </proto>
-
- <desc name="modeRGB">
- <value name="GL_FUNC_ADD" category="GLES2.0"/>
- <value name="GL_FUNC_SUBTRACT" category="GLES2.0"/>
- <value name="GL_FUNC_REVERSE_SUBTRACT" category="GLES2.0"/>
- <value name="GL_FUNC_ADD_OES" category="OES_blend_subtract"/>
- <value name="GL_FUNC_SUBTRACT_OES" category="OES_blend_subtract"/>
- <value name="GL_FUNC_REVERSE_SUBTRACT_OES" category="OES_blend_subtract"/>
-
- <value name="GL_MIN_EXT" category="EXT_blend_minmax"/>
- <value name="GL_MAX_EXT" category="EXT_blend_minmax"/>
- </desc>
-
- <desc name="modeAlpha">
- <value name="GL_FUNC_ADD" category="GLES2.0"/>
- <value name="GL_FUNC_SUBTRACT" category="GLES2.0"/>
- <value name="GL_FUNC_REVERSE_SUBTRACT" category="GLES2.0"/>
- <value name="GL_FUNC_ADD_OES" category="OES_blend_subtract"/>
- <value name="GL_FUNC_SUBTRACT_OES" category="OES_blend_subtract"/>
- <value name="GL_FUNC_REVERSE_SUBTRACT_OES" category="OES_blend_subtract"/>
-
- <value name="GL_MIN_EXT" category="EXT_blend_minmax"/>
- <value name="GL_MAX_EXT" category="EXT_blend_minmax"/>
- </desc>
-</template>
-
-<template name="TexImage3D">
- <proto>
- <return type="void"/>
- <param name="target" type="GLenum"/>
- <param name="level" type="GLint"/>
- <param name="internalFormat" type="GLenum"/>
- <param name="width" type="GLsizei"/>
- <param name="height" type="GLsizei"/>
- <param name="depth" type="GLsizei"/>
- <param name="border" type="GLint"/>
- <param name="format" type="GLenum"/>
- <param name="type" type="GLenum"/>
- <param name="pixels" type="const GLvoid *"/>
- </proto>
-
- <desc name="target">
- <value name="GL_TEXTURE_3D_OES"/>
- </desc>
-
- <desc name="internalFormat">
- <value name="GL_ALPHA"/>
- <value name="GL_RGB"/>
- <value name="GL_RGBA"/>
- <value name="GL_LUMINANCE"/>
- <value name="GL_LUMINANCE_ALPHA"/>
- </desc>
-
- <desc name="format">
- <value name="GL_ALPHA"/>
-
- <desc name="type" error="GL_INVALID_OPERATION">
- <value name="GL_UNSIGNED_BYTE"/>
- <value name="GL_FLOAT" category="OES_texture_float"/>
- <value name="GL_HALF_FLOAT_OES" category="OES_texture_half_float"/>
- </desc>
- </desc>
-
- <desc name="format">
- <value name="GL_RGB"/>
-
- <desc name="type" error="GL_INVALID_OPERATION">
- <value name="GL_UNSIGNED_BYTE"/>
- <value name="GL_UNSIGNED_SHORT_5_6_5"/>
- <value name="GL_FLOAT" category="OES_texture_float"/>
- <value name="GL_HALF_FLOAT_OES" category="OES_texture_half_float"/>
- </desc>
- </desc>
-
- <desc name="format">
- <value name="GL_RGBA"/>
-
- <desc name="type" error="GL_INVALID_OPERATION">
- <value name="GL_UNSIGNED_BYTE"/>
- <value name="GL_UNSIGNED_SHORT_4_4_4_4"/>
- <value name="GL_UNSIGNED_SHORT_5_5_5_1"/>
- <value name="GL_FLOAT" category="OES_texture_float"/>
- <value name="GL_HALF_FLOAT_OES" category="OES_texture_half_float"/>
- <value name="GL_UNSIGNED_INT_2_10_10_10_REV_EXT" category="EXT_texture_type_2_10_10_10_REV"/>
- </desc>
- </desc>
-
- <desc name="format">
- <value name="GL_LUMINANCE"/>
-
- <desc name="type" error="GL_INVALID_OPERATION">
- <value name="GL_UNSIGNED_BYTE"/>
- <value name="GL_FLOAT" category="OES_texture_float"/>
- <value name="GL_HALF_FLOAT_OES" category="OES_texture_half_float"/>
- </desc>
- </desc>
-
- <desc name="format">
- <value name="GL_LUMINANCE_ALPHA"/>
-
- <desc name="type" error="GL_INVALID_OPERATION">
- <value name="GL_UNSIGNED_BYTE"/>
- <value name="GL_FLOAT" category="OES_texture_float"/>
- <value name="GL_HALF_FLOAT_OES" category="OES_texture_half_float"/>
- </desc>
- </desc>
-</template>
-
-<template name="TexSubImage3D">
- <proto>
- <return type="void"/>
- <param name="target" type="GLenum"/>
- <param name="level" type="GLint"/>
- <param name="xoffset" type="GLint"/>
- <param name="yoffset" type="GLint"/>
- <param name="zoffset" type="GLint"/>
- <param name="width" type="GLsizei"/>
- <param name="height" type="GLsizei"/>
- <param name="depth" type="GLsizei"/>
- <param name="format" type="GLenum"/>
- <param name="type" type="GLenum"/>
- <param name="pixels" type="const GLvoid *"/>
- </proto>
-
- <desc name="target">
- <value name="GL_TEXTURE_3D_OES"/>
- </desc>
-
- <desc name="format">
- <value name="GL_ALPHA"/>
-
- <desc name="type" error="GL_INVALID_OPERATION">
- <value name="GL_UNSIGNED_BYTE"/>
- <value name="GL_FLOAT" category="OES_texture_float"/>
- <value name="GL_HALF_FLOAT_OES" category="OES_texture_half_float"/>
- </desc>
- </desc>
-
- <desc name="format">
- <value name="GL_RGB"/>
-
- <desc name="type" error="GL_INVALID_OPERATION">
- <value name="GL_UNSIGNED_BYTE"/>
- <value name="GL_UNSIGNED_SHORT_5_6_5"/>
- <value name="GL_FLOAT" category="OES_texture_float"/>
- <value name="GL_HALF_FLOAT_OES" category="OES_texture_half_float"/>
- </desc>
- </desc>
-
- <desc name="format">
- <value name="GL_RGBA"/>
-
- <desc name="type" error="GL_INVALID_OPERATION">
- <value name="GL_UNSIGNED_BYTE"/>
- <value name="GL_UNSIGNED_SHORT_4_4_4_4"/>
- <value name="GL_UNSIGNED_SHORT_5_5_5_1"/>
- <value name="GL_FLOAT" category="OES_texture_float"/>
- <value name="GL_HALF_FLOAT_OES" category="OES_texture_half_float"/>
- <value name="GL_UNSIGNED_INT_2_10_10_10_REV_EXT" category="EXT_texture_type_2_10_10_10_REV"/>
- </desc>
- </desc>
-
- <desc name="format">
- <value name="GL_LUMINANCE"/>
-
- <desc name="type" error="GL_INVALID_OPERATION">
- <value name="GL_UNSIGNED_BYTE"/>
- <value name="GL_FLOAT" category="OES_texture_float"/>
- <value name="GL_HALF_FLOAT_OES" category="OES_texture_half_float"/>
- </desc>
- </desc>
-
- <desc name="format">
- <value name="GL_LUMINANCE_ALPHA"/>
-
- <desc name="type" error="GL_INVALID_OPERATION">
- <value name="GL_UNSIGNED_BYTE"/>
- <value name="GL_FLOAT" category="OES_texture_float"/>
- <value name="GL_HALF_FLOAT_OES" category="OES_texture_half_float"/>
- </desc>
- </desc>
-</template>
-
-<template name="CopyTexSubImage3D">
- <proto>
- <return type="void"/>
- <param name="target" type="GLenum"/>
- <param name="level" type="GLint"/>
- <param name="xoffset" type="GLint"/>
- <param name="yoffset" type="GLint"/>
- <param name="zoffset" type="GLint"/>
- <param name="x" type="GLint"/>
- <param name="y" type="GLint"/>
- <param name="width" type="GLsizei"/>
- <param name="height" type="GLsizei"/>
- </proto>
-
- <desc name="target">
- <value name="GL_TEXTURE_3D_OES"/>
- </desc>
-</template>
-
-<template name="MultiTexCoord">
- <proto>
- <return type="void"/>
- <param name="texture" type="GLenum"/>
- <vector name="v" type="const GLtype *" size="dynamic">
- <param name="s" type="GLtype"/>
- <param name="t" type="GLtype"/>
- <param name="r" type="GLtype"/>
- <param name="q" type="GLtype"/>
- </vector>
- </proto>
-
- <desc name="texture">
- <range base="GL_TEXTURE" from="0" to="31"/>
- </desc>
-</template>
-
-<template name="CompressedTexImage3D">
- <proto>
- <return type="void"/>
- <param name="target" type="GLenum"/>
- <param name="level" type="GLint"/>
- <param name="internalFormat" type="GLenum"/>
- <param name="width" type="GLsizei"/>
- <param name="height" type="GLsizei"/>
- <param name="depth" type="GLsizei"/>
- <param name="border" type="GLint"/>
- <param name="imagesize" type="GLsizei"/>
- <param name="data" type="const GLvoid *"/>
- </proto>
-
- <desc name="target">
- <value name="GL_TEXTURE_3D_OES"/>
- </desc>
-
- <desc name="internalFormat">
- <value name="GL_3DC_X_AMD" category="AMD_compressed_3DC_texture"/>
- <value name="GL_3DC_XY_AMD" category="AMD_compressed_3DC_texture"/>
- <value name="GL_ATC_RGB_AMD" category="AMD_compressed_ATC_texture"/>
- <value name="GL_ATC_RGBA_EXPLICIT_ALPHA_AMD" category="AMD_compressed_ATC_texture"/>
- <value name="GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD" category="AMD_compressed_ATC_texture"/>
- </desc>
-</template>
-
-<template name="CompressedTexSubImage3D">
- <proto>
- <return type="void"/>
- <param name="target" type="GLenum"/>
- <param name="level" type="GLint"/>
- <param name="xoffset" type="GLint"/>
- <param name="yoffset" type="GLint"/>
- <param name="zoffset" type="GLint"/>
- <param name="width" type="GLsizei"/>
- <param name="height" type="GLsizei"/>
- <param name="depth" type="GLsizei"/>
- <param name="format" type="GLenum"/>
- <param name="imagesize" type="GLsizei"/>
- <param name="data" type="const GLvoid *"/>
- </proto>
-
- <desc name="target">
- <value name="GL_TEXTURE_3D_OES"/>
- </desc>
-</template>
-
-<template name="ActiveTexture">
- <proto>
- <return type="void"/>
- <param name="texture" type="GLenum"/>
- </proto>
-
- <desc name="texture">
- <range base="GL_TEXTURE" from="0" to="31"/>
- </desc>
-</template>
-
-<template name="ClientActiveTexture">
- <proto>
- <return type="void"/>
- <param name="texture" type="GLenum"/>
- </proto>
-
- <desc name="texture">
- <range base="GL_TEXTURE" from="0" to="31"/>
- </desc>
-</template>
-
-<template name="SampleCoverage">
- <proto>
- <return type="void"/>
- <param name="value" type="GLtype"/>
- <param name="invert" type="GLboolean"/>
- </proto>
-</template>
-
-<template name="CompressedTexImage2D">
- <proto>
- <return type="void"/>
- <param name="target" type="GLenum"/>
- <param name="level" type="GLint"/>
- <param name="internalFormat" type="GLenum"/>
- <param name="width" type="GLsizei"/>
- <param name="height" type="GLsizei"/>
- <param name="border" type="GLint"/>
- <param name="imageSize" type="GLsizei"/>
- <param name="data" type="const GLvoid *"/>
- </proto>
-
- <desc name="target">
- <value name="GL_TEXTURE_2D"/>
- <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_X" category="GLES2.0"/>
- <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Y" category="GLES2.0"/>
- <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Z" category="GLES2.0"/>
- <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_X" category="GLES2.0"/>
- <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Y" category="GLES2.0"/>
- <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Z" category="GLES2.0"/>
- <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_X_OES" category="OES_texture_cube_map"/>
- <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Y_OES" category="OES_texture_cube_map"/>
- <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Z_OES" category="OES_texture_cube_map"/>
- <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_X_OES" category="OES_texture_cube_map"/>
- <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_OES" category="OES_texture_cube_map"/>
- <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_OES" category="OES_texture_cube_map"/>
- </desc>
-
- <desc name="internalFormat">
- <value name="GL_ETC1_RGB8_OES" category="OES_compressed_ETC1_RGB8_texture"/>
-
- <value name="GL_PALETTE4_RGB8_OES" category="OES_compressed_paletted_texture"/>
- <value name="GL_PALETTE4_RGBA8_OES" category="OES_compressed_paletted_texture"/>
- <value name="GL_PALETTE4_R5_G6_B5_OES" category="OES_compressed_paletted_texture"/>
- <value name="GL_PALETTE4_RGBA4_OES" category="OES_compressed_paletted_texture"/>
- <value name="GL_PALETTE4_RGB5_A1_OES" category="OES_compressed_paletted_texture"/>
- <value name="GL_PALETTE8_RGB8_OES" category="OES_compressed_paletted_texture"/>
- <value name="GL_PALETTE8_RGBA8_OES" category="OES_compressed_paletted_texture"/>
- <value name="GL_PALETTE8_R5_G6_B5_OES" category="OES_compressed_paletted_texture"/>
- <value name="GL_PALETTE8_RGBA4_OES" category="OES_compressed_paletted_texture"/>
- <value name="GL_PALETTE8_RGB5_A1_OES" category="OES_compressed_paletted_texture"/>
-
- <value name="GL_3DC_X_AMD" category="AMD_compressed_3DC_texture"/>
- <value name="GL_3DC_XY_AMD" category="AMD_compressed_3DC_texture"/>
-
- <value name="GL_ATC_RGB_AMD" category="AMD_compressed_ATC_texture"/>
- <value name="GL_ATC_RGBA_EXPLICIT_ALPHA_AMD" category="AMD_compressed_ATC_texture"/>
- <value name="GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD" category="AMD_compressed_ATC_texture"/>
-
- <value name="GL_COMPRESSED_RGB_S3TC_DXT1_EXT" category="EXT_texture_compression_dxt1"/>
- <value name="GL_COMPRESSED_RGBA_S3TC_DXT1_EXT" category="EXT_texture_compression_dxt1"/>
- </desc>
-
- <desc name="border" error="GL_INVALID_VALUE">
- <value name="0"/>
- </desc>
-</template>
-
-<template name="CompressedTexSubImage2D">
- <proto>
- <return type="void"/>
- <param name="target" type="GLenum"/>
- <param name="level" type="GLint"/>
- <param name="xoffset" type="GLint"/>
- <param name="yoffset" type="GLint"/>
- <param name="width" type="GLsizei"/>
- <param name="height" type="GLsizei"/>
- <param name="format" type="GLenum"/>
- <param name="imageSize" type="GLsizei"/>
- <param name="data" type="const GLvoid *"/>
- </proto>
-
- <desc name="target">
- <value name="GL_TEXTURE_2D"/>
- <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_X" category="GLES2.0"/>
- <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Y" category="GLES2.0"/>
- <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Z" category="GLES2.0"/>
- <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_X" category="GLES2.0"/>
- <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Y" category="GLES2.0"/>
- <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Z" category="GLES2.0"/>
- <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_X_OES" category="OES_texture_cube_map"/>
- <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Y_OES" category="OES_texture_cube_map"/>
- <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Z_OES" category="OES_texture_cube_map"/>
- <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_X_OES" category="OES_texture_cube_map"/>
- <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_OES" category="OES_texture_cube_map"/>
- <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_OES" category="OES_texture_cube_map"/>
- </desc>
-
- <desc name="format">
- <value name="GL_COMPRESSED_RGB_S3TC_DXT1_EXT" category="EXT_texture_compression_dxt1"/>
- <value name="GL_COMPRESSED_RGBA_S3TC_DXT1_EXT" category="EXT_texture_compression_dxt1"/>
- </desc>
-</template>
-
-<template name="BlendFuncSeparate">
- <proto>
- <return type="void"/>
- <param name="srcRGB" type="GLenum"/>
- <param name="dstRGB" type="GLenum"/>
- <param name="srcAlpha" type="GLenum"/>
- <param name="dstAlpha" type="GLenum"/>
- </proto>
-
- <desc name="srcRGB">
- <value name="GL_ZERO"/>
- <value name="GL_ONE"/>
- <value name="GL_SRC_COLOR"/>
- <value name="GL_ONE_MINUS_SRC_COLOR"/>
- <value name="GL_SRC_ALPHA"/>
- <value name="GL_ONE_MINUS_SRC_ALPHA"/>
- <value name="GL_DST_ALPHA"/>
- <value name="GL_ONE_MINUS_DST_ALPHA"/>
- <value name="GL_DST_COLOR"/>
- <value name="GL_ONE_MINUS_DST_COLOR"/>
- <value name="GL_SRC_ALPHA_SATURATE"/>
-
- <value name="GL_CONSTANT_COLOR" category="GLES2.0"/>
- <value name="GL_ONE_MINUS_CONSTANT_COLOR" category="GLES2.0"/>
- <value name="GL_CONSTANT_ALPHA" category="GLES2.0"/>
- <value name="GL_ONE_MINUS_CONSTANT_ALPHA" category="GLES2.0"/>
- </desc>
-
- <desc name="dstRGB">
- <value name="GL_ZERO"/>
- <value name="GL_ONE"/>
- <value name="GL_SRC_COLOR"/>
- <value name="GL_ONE_MINUS_SRC_COLOR"/>
- <value name="GL_SRC_ALPHA"/>
- <value name="GL_ONE_MINUS_SRC_ALPHA"/>
- <value name="GL_DST_ALPHA"/>
- <value name="GL_ONE_MINUS_DST_ALPHA"/>
- <value name="GL_DST_COLOR"/>
- <value name="GL_ONE_MINUS_DST_COLOR"/>
-
- <value name="GL_CONSTANT_COLOR" category="GLES2.0"/>
- <value name="GL_ONE_MINUS_CONSTANT_COLOR" category="GLES2.0"/>
- <value name="GL_CONSTANT_ALPHA" category="GLES2.0"/>
- <value name="GL_ONE_MINUS_CONSTANT_ALPHA" category="GLES2.0"/>
- </desc>
-
- <desc name="srcAlpha">
- <value name="GL_ZERO"/>
- <value name="GL_ONE"/>
- <value name="GL_SRC_COLOR"/>
- <value name="GL_ONE_MINUS_SRC_COLOR"/>
- <value name="GL_SRC_ALPHA"/>
- <value name="GL_ONE_MINUS_SRC_ALPHA"/>
- <value name="GL_DST_ALPHA"/>
- <value name="GL_ONE_MINUS_DST_ALPHA"/>
- <value name="GL_DST_COLOR"/>
- <value name="GL_ONE_MINUS_DST_COLOR"/>
- <value name="GL_SRC_ALPHA_SATURATE"/>
-
- <value name="GL_CONSTANT_COLOR" category="GLES2.0"/>
- <value name="GL_ONE_MINUS_CONSTANT_COLOR" category="GLES2.0"/>
- <value name="GL_CONSTANT_ALPHA" category="GLES2.0"/>
- <value name="GL_ONE_MINUS_CONSTANT_ALPHA" category="GLES2.0"/>
- </desc>
-
- <desc name="dstAlpha">
- <value name="GL_ZERO"/>
- <value name="GL_ONE"/>
- <value name="GL_SRC_COLOR"/>
- <value name="GL_ONE_MINUS_SRC_COLOR"/>
- <value name="GL_SRC_ALPHA"/>
- <value name="GL_ONE_MINUS_SRC_ALPHA"/>
- <value name="GL_DST_ALPHA"/>
- <value name="GL_ONE_MINUS_DST_ALPHA"/>
- <value name="GL_DST_COLOR"/>
- <value name="GL_ONE_MINUS_DST_COLOR"/>
-
- <value name="GL_CONSTANT_COLOR" category="GLES2.0"/>
- <value name="GL_ONE_MINUS_CONSTANT_COLOR" category="GLES2.0"/>
- <value name="GL_CONSTANT_ALPHA" category="GLES2.0"/>
- <value name="GL_ONE_MINUS_CONSTANT_ALPHA" category="GLES2.0"/>
- </desc>
-</template>
-
-<template name="PointParameter">
- <proto>
- <return type="void"/>
- <param name="pname" type="GLenum"/>
- <vector name="params" type="const GLtype *" size="dynamic">
- <param name="param" type="GLtype"/>
- </vector>
- </proto>
-
- <desc name="pname">
- <value name="GL_POINT_SIZE_MIN"/>
- <value name="GL_POINT_SIZE_MAX"/>
- <value name="GL_POINT_FADE_THRESHOLD_SIZE"/>
-
- <desc name="params" vector_size="1"/>
- </desc>
-
- <desc name="pname">
- <value name="GL_POINT_DISTANCE_ATTENUATION"/>
- <desc name="params" vector_size="3"/>
- </desc>
-</template>
-
-<template name="VertexAttrib">
- <proto>
- <return type="void"/>
- <param name="index" type="GLuint"/>
- <vector name="v" type="const GLtype *" size="dynamic">
- <param name="x" type="GLtype"/>
- <param name="y" type="GLtype"/>
- <param name="z" type="GLtype"/>
- <param name="w" type="GLtype"/>
- </vector>
- </proto>
-</template>
-
-<template name="VertexAttribPointer">
- <proto>
- <return type="void"/>
- <param name="index" type="GLuint"/>
- <param name="size" type="GLint"/>
- <param name="type" type="GLenum"/>
- <param name="normalized" type="GLboolean"/>
- <param name="stride" type="GLsizei"/>
- <param name="pointer" type="const GLvoid *"/>
- </proto>
-
- <desc name="size" error="GL_INVALID_VALUE">
- <value name="1"/>
- <value name="2"/>
- <value name="3"/>
- <value name="4"/>
- </desc>
-
- <desc name="type" error="GL_INVALID_VALUE">
- <value name="GL_BYTE"/>
- <value name="GL_UNSIGNED_BYTE"/>
- <value name="GL_SHORT"/>
- <value name="GL_UNSIGNED_SHORT"/>
- <value name="GL_FLOAT"/>
- <value name="GL_FIXED"/>
- <value name="GL_HALF_FLOAT_OES" category="OES_vertex_half_float"/>
- <value name="GL_UNSIGNED_INT_10_10_10_2_OES" category="OES_vertex_type_10_10_10_2"/>
- <value name="GL_INT_10_10_10_2_OES" category="OES_vertex_type_10_10_10_2"/>
- </desc>
-
- <desc name="type" category="OES_vertex_type_10_10_10_2">
- <value name="GL_UNSIGNED_INT_10_10_10_2_OES"/>
- <value name="GL_INT_10_10_10_2_OES"/>
-
- <desc name="size">
- <value name="3"/>
- <value name="4"/>
- </desc>
- </desc>
-</template>
-
-<template name="EnableVertexAttribArray">
- <proto>
- <return type="void"/>
- <param name="index" type="GLuint"/>
- </proto>
-</template>
-
-<template name="DisableVertexAttribArray">
- <proto>
- <return type="void"/>
- <param name="index" type="GLuint"/>
- </proto>
-</template>
-
-<template name="IsProgram" direction="get">
- <proto>
- <return type="GLboolean"/>
- <param name="program" type="GLuint"/>
- </proto>
-</template>
-
-<template name="GetProgram" direction="get">
- <proto>
- <return type="void"/>
- <param name="program" type="GLuint"/>
- <param name="pname" type="GLenum"/>
- <vector name="params" type="GLtype *" size="dynamic"/>
- </proto>
-
- <desc name="pname">
- <value name="GL_DELETE_STATUS"/>
- <value name="GL_LINK_STATUS"/>
- <value name="GL_VALIDATE_STATUS"/>
- <value name="GL_INFO_LOG_LENGTH"/>
- <value name="GL_ATTACHED_SHADERS"/>
- <value name="GL_ACTIVE_ATTRIBUTES"/>
- <value name="GL_ACTIVE_ATTRIBUTE_MAX_LENGTH"/>
- <value name="GL_ACTIVE_UNIFORMS"/>
- <value name="GL_ACTIVE_UNIFORM_MAX_LENGTH"/>
- <value name="GL_PROGRAM_BINARY_LENGTH_OES" category="OES_get_program_binary"/>
-
- <desc name="params" convert="false"/>
- </desc>
-</template>
-
-<template name="GetVertexAttrib" direction="get">
- <proto>
- <return type="void"/>
- <param name="index" type="GLuint"/>
- <param name="pname" type="GLenum"/>
- <vector name="params" type="GLtype *" size="dynamic"/>
- </proto>
-
- <desc name="pname">
- <value name="GL_VERTEX_ATTRIB_ARRAY_ENABLED"/>
- <value name="GL_VERTEX_ATTRIB_ARRAY_SIZE"/>
- <value name="GL_VERTEX_ATTRIB_ARRAY_STRIDE"/>
- <value name="GL_VERTEX_ATTRIB_ARRAY_TYPE"/>
- <value name="GL_VERTEX_ATTRIB_ARRAY_NORMALIZED"/>
- <value name="GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING"/>
-
- <desc name="params" vector_size="1" convert="false"/>
- </desc>
-
- <desc name="pname">
- <value name="GL_CURRENT_VERTEX_ATTRIB"/>
- <desc name="params" vector_size="16?" convert="false"/>
- </desc>
-</template>
-
-<template name="GetVertexAttribPointer" direction="get">
- <proto>
- <return type="void"/>
- <param name="index" type="GLuint"/>
- <param name="pname" type="GLenum"/>
- <vector name="pointer" type="GLvoid **" size="dynamic"/>
- </proto>
-
- <desc name="pname">
- <value name="GL_VERTEX_ATTRIB_ARRAY_POINTER"/>
- </desc>
-</template>
-
-<template name="GetBufferPointer" direction="get">
- <proto>
- <return type="void"/>
- <param name="target" type="GLenum"/>
- <param name="pname" type="GLenum"/>
- <vector name="params" type="GLvoid **" size="dynamic"/>
- </proto>
-
- <desc name="target">
- <value name="GL_ARRAY_BUFFER"/>
- <value name="GL_ELEMENT_ARRAY_BUFFER"/>
- </desc>
-
- <desc name="pname">
- <value name="GL_BUFFER_MAP_POINTER_OES"/>
- </desc>
-</template>
-
-<template name="MapBuffer" direction="get">
- <proto>
- <return type="void *"/>
- <param name="target" type="GLenum"/>
- <param name="access" type="GLenum"/>
- </proto>
-
- <desc name="target">
- <value name="GL_ARRAY_BUFFER"/>
- <value name="GL_ELEMENT_ARRAY_BUFFER"/>
- </desc>
-
- <desc name="access">
- <value name="GL_WRITE_ONLY_OES"/>
- </desc>
-</template>
-
-<template name="UnmapBuffer" direction="get">
- <proto>
- <return type="GLboolean"/>
- <param name="target" type="GLenum"/>
- </proto>
-
- <desc name="target">
- <value name="GL_ARRAY_BUFFER"/>
- <value name="GL_ELEMENT_ARRAY_BUFFER"/>
- </desc>
-</template>
-
-<template name="BindBuffer">
- <proto>
- <return type="void"/>
- <param name="target" type="GLenum"/>
- <param name="buffer" type="GLuint"/>
- </proto>
-
- <desc name="target">
- <value name="GL_ARRAY_BUFFER"/>
- <value name="GL_ELEMENT_ARRAY_BUFFER"/>
- </desc>
-</template>
-
-<template name="BufferData">
- <proto>
- <return type="void"/>
- <param name="target" type="GLenum"/>
- <param name="size" type="GLsizeiptr"/>
- <param name="data" type="const GLvoid *"/>
- <param name="usage" type="GLenum"/>
- </proto>
-
- <desc name="target">
- <value name="GL_ARRAY_BUFFER"/>
- <value name="GL_ELEMENT_ARRAY_BUFFER"/>
- </desc>
-
- <desc name="usage">
- <value name="GL_STATIC_DRAW"/>
- <value name="GL_DYNAMIC_DRAW"/>
- <value name="GL_STREAM_DRAW" category="GLES2.0"/>
- </desc>
-</template>
-
-<template name="BufferSubData">
- <proto>
- <return type="void"/>
- <param name="target" type="GLenum"/>
- <param name="offset" type="GLintptr"/>
- <param name="size" type="GLsizeiptr"/>
- <param name="data" type="const GLvoid *"/>
- </proto>
-
- <desc name="target">
- <value name="GL_ARRAY_BUFFER"/>
- <value name="GL_ELEMENT_ARRAY_BUFFER"/>
- </desc>
-</template>
-
-<template name="DeleteBuffers">
- <proto>
- <return type="void"/>
- <param name="n" type="GLsizei"/>
- <param name="buffer" type="const GLuint *"/>
- </proto>
-</template>
-
-<template name="GenBuffers" direction="get">
- <proto>
- <return type="void"/>
- <param name="n" type="GLsizei"/>
- <param name="buffer" type="GLuint *"/>
- </proto>
-</template>
-
-<template name="GetBufferParameter" direction="get">
- <proto>
- <return type="void"/>
- <param name="target" type="GLenum"/>
- <param name="pname" type="GLenum"/>
- <vector name="params" type="GLtype *" size="dynamic"/>
- </proto>
-
- <desc name="target">
- <value name="GL_ARRAY_BUFFER"/>
- <value name="GL_ELEMENT_ARRAY_BUFFER"/>
- </desc>
-
- <desc name="pname">
- <value name="GL_BUFFER_SIZE"/>
- <value name="GL_BUFFER_USAGE"/>
- <value name="GL_BUFFER_ACCESS_OES" category="OES_mapbuffer"/>
- <value name="GL_BUFFER_MAPPED_OES" category="OES_mapbuffer"/>
- </desc>
-</template>
-
-<template name="IsBuffer" direction="get">
- <proto>
- <return type="GLboolean"/>
- <param name="buffer" type="GLuint"/>
- </proto>
-</template>
-
-<template name="CreateShader">
- <proto>
- <return type="GLuint"/>
- <param name="type" type="GLenum"/>
- </proto>
-
- <desc name="type">
- <value name="GL_VERTEX_SHADER"/>
- <value name="GL_FRAGMENT_SHADER"/>
- </desc>
-</template>
-
-<template name="ShaderSource">
- <proto>
- <return type="void"/>
- <param name="shader" type="GLuint"/>
- <param name="count" type="GLsizei"/>
- <param name="string" type="const GLchar **"/>
- <param name="length" type="const int *"/>
- </proto>
-</template>
-
-<template name="CompileShader">
- <proto>
- <return type="void"/>
- <param name="shader" type="GLuint"/>
- </proto>
-</template>
-
-<template name="ReleaseShaderCompiler">
- <proto>
- <return type="void"/>
- </proto>
-</template>
-
-<template name="DeleteShader">
- <proto>
- <return type="void"/>
- <param name="shader" type="GLuint"/>
- </proto>
-</template>
-
-<template name="ShaderBinary">
- <proto>
- <return type="void"/>
- <param name="n" type="GLsizei"/>
- <param name="shaders" type="const GLuint *"/>
- <param name="binaryformat" type="GLenum"/>
- <param name="binary" type="const GLvoid *"/>
- <param name="length" type="GLsizei"/>
- </proto>
-</template>
-
-<template name="CreateProgram">
- <proto>
- <return type="GLuint"/>
- </proto>
-</template>
-
-<template name="AttachShader">
- <proto>
- <return type="void"/>
- <param name="program" type="GLuint"/>
- <param name="shader" type="GLuint"/>
- </proto>
-</template>
-
-<template name="DetachShader">
- <proto>
- <return type="void"/>
- <param name="program" type="GLuint"/>
- <param name="shader" type="GLuint"/>
- </proto>
-</template>
-
-<template name="LinkProgram">
- <proto>
- <return type="void"/>
- <param name="program" type="GLuint"/>
- </proto>
-</template>
-
-<template name="UseProgram">
- <proto>
- <return type="void"/>
- <param name="program" type="GLuint"/>
- </proto>
-</template>
-
-<template name="DeleteProgram">
- <proto>
- <return type="void"/>
- <param name="program" type="GLuint"/>
- </proto>
-</template>
-
-<template name="GetActiveAttrib" direction="get">
- <proto>
- <return type="void"/>
- <param name="program" type="GLuint"/>
- <param name="index" type="GLuint"/>
- <param name="bufSize" type="GLsizei"/>
- <param name="length" type="GLsizei *"/>
- <param name="size" type="GLint *"/>
- <param name="type" type="GLenum *"/>
- <param name="name" type="GLchar *"/>
- </proto>
-</template>
-
-<template name="GetAttribLocation" direction="get">
- <proto>
- <return type="GLint"/>
- <param name="program" type="GLuint"/>
- <param name="name" type="const char *"/>
- </proto>
-</template>
-
-<template name="BindAttribLocation">
- <proto>
- <return type="void"/>
- <param name="program" type="GLuint"/>
- <param name="index" type="GLuint"/>
- <param name="name" type="const char *"/>
- </proto>
-</template>
-
-<template name="GetUniformLocation" direction="get">
- <proto>
- <return type="GLint"/>
- <param name="program" type="GLuint"/>
- <param name="name" type="const char *"/>
- </proto>
-</template>
-
-<template name="GetActiveUniform" direction="get">
- <proto>
- <return type="void"/>
- <param name="program" type="GLuint"/>
- <param name="index" type="GLuint"/>
- <param name="bufSize" type="GLsizei"/>
- <param name="length" type="GLsizei *"/>
- <param name="size" type="GLint *"/>
- <param name="type" type="GLenum *"/>
- <param name="name" type="GLchar *"/>
- </proto>
-</template>
-
-<template name="Uniform">
- <proto>
- <return type="void"/>
- <param name="location" type="GLint"/>
- <param name="count" type="GLsizei" hide_if_expanded="true"/>
- <vector name="values" type="const GLtype *" size="dynamic">
- <param name="v0" type="GLtype"/>
- <param name="v1" type="GLtype"/>
- <param name="v2" type="GLtype"/>
- <param name="v3" type="GLtype"/>
- </vector>
- </proto>
-</template>
-
-<template name="UniformMatrix">
- <proto>
- <return type="void"/>
- <param name="location" type="GLint"/>
- <param name="count" type="GLsizei"/>
- <param name="transpose" type="GLboolean"/>
- <vector name="value" type="const GLtype *" size="dynamic"/>
- </proto>
-</template>
-
-<template name="ValidateProgram">
- <proto>
- <return type="void"/>
- <param name="program" type="GLuint"/>
- </proto>
-</template>
-
-<template name="GenerateMipmap">
- <proto>
- <return type="void"/>
- <param name="target" type="GLenum"/>
- </proto>
-
- <desc name="target">
- <value name="GL_TEXTURE_2D"/>
- <value name="GL_TEXTURE_CUBE_MAP" category="GLES2.0"/>
- <value name="GL_TEXTURE_CUBE_MAP_OES" category="OES_texture_cube_map"/>
- <value name="GL_TEXTURE_3D_OES" category="OES_texture_3D"/>
- </desc>
-</template>
-
-<template name="BindFramebuffer">
- <proto>
- <return type="void"/>
- <param name="target" type="GLenum"/>
- <param name="framebuffer" type="GLuint"/>
- </proto>
-
- <desc name="target">
- <value name="GL_FRAMEBUFFER_OES" category="OES_framebuffer_object"/>
- <value name="GL_FRAMEBUFFER" category="GLES2.0"/>
- </desc>
-</template>
-
-<template name="DeleteFramebuffers">
- <proto>
- <return type="void"/>
- <param name="n" type="GLsizei"/>
- <param name="framebuffers" type="const GLuint *"/>
- </proto>
-</template>
-
-<template name="GenFramebuffers">
- <proto>
- <return type="void"/>
- <param name="n" type="GLsizei"/>
- <param name="ids" type="GLuint *"/>
- </proto>
-</template>
-
-<template name="BindRenderbuffer">
- <proto>
- <return type="void"/>
- <param name="target" type="GLenum"/>
- <param name="renderbuffer" type="GLuint"/>
- </proto>
-
- <desc name="target">
- <value name="GL_RENDERBUFFER_OES" category="OES_framebuffer_object"/>
- <value name="GL_RENDERBUFFER" category="GLES2.0"/>
- </desc>
-</template>
-
-<template name="DeleteRenderbuffers">
- <proto>
- <return type="void"/>
- <param name="n" type="GLsizei"/>
- <param name="renderbuffers" type="const GLuint *"/>
- </proto>
-</template>
-
-<template name="GenRenderbuffers">
- <proto>
- <return type="void"/>
- <param name="n" type="GLsizei"/>
- <param name="renderbuffers" type="GLuint *"/>
- </proto>
-</template>
-
-<template name="RenderbufferStorage">
- <proto>
- <return type="void"/>
- <param name="target" type="GLenum"/>
- <param name="internalFormat" type="GLenum"/>
- <param name="width" type="GLsizei"/>
- <param name="height" type="GLsizei"/>
- </proto>
-
- <desc name="target">
- <value name="GL_RENDERBUFFER_OES" category="OES_framebuffer_object"/>
- <value name="GL_RENDERBUFFER" category="GLES2.0"/>
- </desc>
-
- <desc name="internalFormat">
- <value name="GL_DEPTH_COMPONENT16_OES" category="OES_framebuffer_object"/>
- <value name="GL_RGBA4_OES" category="OES_framebuffer_object"/>
- <value name="GL_RGB5_A1_OES" category="OES_framebuffer_object"/>
- <value name="GL_RGB565_OES" category="OES_framebuffer_object"/>
- <value name="GL_STENCIL_INDEX8_OES" category="OES_stencil8"/>
-
- <value name="GL_DEPTH_COMPONENT16" category="GLES2.0"/>
- <value name="GL_RGBA4" category="GLES2.0"/>
- <value name="GL_RGB5_A1" category="GLES2.0"/>
- <value name="GL_RGB565" category="GLES2.0"/>
- <value name="GL_STENCIL_INDEX8" category="GLES2.0"/>
-
- <value name="GL_DEPTH_COMPONENT24_OES" category="OES_depth24"/>
- <value name="GL_DEPTH_COMPONENT32_OES" category="OES_depth32"/>
- <value name="GL_RGB8_OES" category="OES_rgb8_rgba8"/>
- <value name="GL_RGBA8_OES" category="OES_rgb8_rgba8"/>
- <value name="GL_STENCIL_INDEX1_OES" category="OES_stencil1"/>
- <value name="GL_STENCIL_INDEX4_OES" category="OES_stencil4"/>
- <value name="GL_DEPTH24_STENCIL8_OES" category="OES_packed_depth_stencil"/>
- </desc>
-</template>
-
-<template name="FramebufferRenderbuffer">
- <proto>
- <return type="void"/>
- <param name="target" type="GLenum"/>
- <param name="attachment" type="GLenum"/>
- <param name="renderbuffertarget" type="GLenum"/>
- <param name="renderbuffer" type="GLuint"/>
- </proto>
-
- <desc name="target">
- <value name="GL_FRAMEBUFFER_OES" category="OES_framebuffer_object"/>
- <value name="GL_FRAMEBUFFER" category="GLES2.0"/>
- </desc>
-
- <desc name="attachment">
- <value name="GL_COLOR_ATTACHMENT0_OES" category="OES_framebuffer_object"/>
- <value name="GL_DEPTH_ATTACHMENT_OES" category="OES_framebuffer_object"/>
- <value name="GL_STENCIL_ATTACHMENT_OES" category="OES_framebuffer_object"/>
- <value name="GL_COLOR_ATTACHMENT0" category="GLES2.0"/>
- <value name="GL_DEPTH_ATTACHMENT" category="GLES2.0"/>
- <value name="GL_STENCIL_ATTACHMENT" category="GLES2.0"/>
- </desc>
-
- <desc name="renderbuffertarget">
- <value name="GL_RENDERBUFFER_OES" category="OES_framebuffer_object"/>
- <value name="GL_RENDERBUFFER" category="GLES2.0"/>
- </desc>
-</template>
-
-<template name="FramebufferTexture2D">
- <proto>
- <return type="void"/>
- <param name="target" type="GLenum"/>
- <param name="attachment" type="GLenum"/>
- <param name="textarget" type="GLenum"/>
- <param name="texture" type="GLuint"/>
- <param name="level" type="GLint"/>
- </proto>
-
- <desc name="target">
- <value name="GL_FRAMEBUFFER_OES" category="OES_framebuffer_object"/>
- <value name="GL_FRAMEBUFFER" category="GLES2.0"/>
- </desc>
-
- <desc name="attachment">
- <value name="GL_COLOR_ATTACHMENT0_OES" category="OES_framebuffer_object"/>
- <value name="GL_DEPTH_ATTACHMENT_OES" category="OES_framebuffer_object"/>
- <value name="GL_STENCIL_ATTACHMENT_OES" category="OES_framebuffer_object"/>
- <value name="GL_COLOR_ATTACHMENT0" category="GLES2.0"/>
- <value name="GL_DEPTH_ATTACHMENT" category="GLES2.0"/>
- <value name="GL_STENCIL_ATTACHMENT" category="GLES2.0"/>
- </desc>
-
- <desc name="textarget" error="GL_INVALID_OPERATION">
- <value name="GL_TEXTURE_2D"/>
- <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_X" category="GLES2.0"/>
- <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Y" category="GLES2.0"/>
- <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Z" category="GLES2.0"/>
- <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_X" category="GLES2.0"/>
- <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Y" category="GLES2.0"/>
- <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Z" category="GLES2.0"/>
- <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_X_OES" category="OES_texture_cube_map"/>
- <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Y_OES" category="OES_texture_cube_map"/>
- <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Z_OES" category="OES_texture_cube_map"/>
- <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_X_OES" category="OES_texture_cube_map"/>
- <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_OES" category="OES_texture_cube_map"/>
- <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_OES" category="OES_texture_cube_map"/>
- </desc>
- <!-- According to the base specification, "level" must be 0. But
- extension GL_OES_fbo_render_mipmap lifts that restriction,
- so no restriction is placed here. -->
-</template>
-
-<template name="FramebufferTexture3D">
- <proto>
- <return type="void"/>
- <param name="target" type="GLenum"/>
- <param name="attachment" type="GLenum"/>
- <param name="textarget" type="GLenum"/>
- <param name="texture" type="GLuint"/>
- <param name="level" type="GLint"/>
- <param name="zoffset" type="GLint"/>
- </proto>
-
- <desc name="target">
- <value name="GL_FRAMEBUFFER_OES" category="OES_framebuffer_object"/>
- <value name="GL_FRAMEBUFFER" category="GLES2.0"/>
- </desc>
-
- <desc name="attachment">
- <value name="GL_COLOR_ATTACHMENT0_OES" category="OES_framebuffer_object"/>
- <value name="GL_DEPTH_ATTACHMENT_OES" category="OES_framebuffer_object"/>
- <value name="GL_STENCIL_ATTACHMENT_OES" category="OES_framebuffer_object"/>
- <value name="GL_COLOR_ATTACHMENT0" category="GLES2.0"/>
- <value name="GL_DEPTH_ATTACHMENT" category="GLES2.0"/>
- <value name="GL_STENCIL_ATTACHMENT" category="GLES2.0"/>
- </desc>
-
- <desc name="textarget" error="GL_INVALID_OPERATION">
- <value name="GL_TEXTURE_3D_OES" category="OES_texture_3D"/>
- </desc>
-</template>
-
-<template name="CheckFramebufferStatus" direction="get">
- <proto>
- <return type="GLenum"/>
- <param name="target" type="GLenum"/>
- </proto>
-
- <desc name="target">
- <value name="GL_FRAMEBUFFER_OES" category="OES_framebuffer_object"/>
- <value name="GL_FRAMEBUFFER" category="GLES2.0"/>
- </desc>
-</template>
-
-<template name="GetFramebufferAttachmentParameter" direction="get">
- <proto>
- <return type="void"/>
- <param name="target" type="GLenum"/>
- <param name="attachment" type="GLenum"/>
- <param name="pname" type="GLenum"/>
- <vector name="params" type="GLtype *" size="dynamic"/>
- </proto>
-
- <desc name="target">
- <value name="GL_FRAMEBUFFER_OES" category="OES_framebuffer_object"/>
- <value name="GL_FRAMEBUFFER" category="GLES2.0"/>
- </desc>
-
- <desc name="pname">
- <value name="GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_OES" category="OES_framebuffer_object"/>
- <value name="GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_OES" category="OES_framebuffer_object"/>
- <value name="GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_OES" category="OES_framebuffer_object"/>
- <value name="GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_OES" category="OES_framebuffer_object"/>
-
- <value name="GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE" category="GLES2.0"/>
- <value name="GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME" category="GLES2.0"/>
- <value name="GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL" category="GLES2.0"/>
- <value name="GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE" category="GLES2.0"/>
- <value name="GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_OES" category="OES_texture_3D"/>
-
- <desc name="params" vector_size="1" convert="false"/>
- </desc>
-</template>
-
-<template name="GetRenderbufferParameter" direction="get">
- <proto>
- <return type="void"/>
- <param name="target" type="GLenum"/>
- <param name="pname" type="GLenum"/>
- <vector name="params" type="GLtype *" size="dynamic"/>
- </proto>
-
- <desc name="target">
- <value name="GL_RENDERBUFFER_OES" category="OES_framebuffer_object"/>
- <value name="GL_RENDERBUFFER" category="GLES2.0"/>
- </desc>
-
- <desc name="pname" category="OES_framebuffer_object">
- <value name="GL_RENDERBUFFER_WIDTH_OES"/>
- <value name="GL_RENDERBUFFER_HEIGHT_OES"/>
- <value name="GL_RENDERBUFFER_INTERNAL_FORMAT_OES"/>
- <value name="GL_RENDERBUFFER_RED_SIZE_OES"/>
- <value name="GL_RENDERBUFFER_GREEN_SIZE_OES"/>
- <value name="GL_RENDERBUFFER_BLUE_SIZE_OES"/>
- <value name="GL_RENDERBUFFER_ALPHA_SIZE_OES"/>
- <value name="GL_RENDERBUFFER_DEPTH_SIZE_OES"/>
- <value name="GL_RENDERBUFFER_STENCIL_SIZE_OES"/>
-
- <desc name="params" vector_size="1" convert="false"/>
- </desc>
-
- <desc name="pname" category="GLES2.0">
- <value name="GL_RENDERBUFFER_WIDTH"/>
- <value name="GL_RENDERBUFFER_HEIGHT"/>
- <value name="GL_RENDERBUFFER_INTERNAL_FORMAT"/>
- <value name="GL_RENDERBUFFER_RED_SIZE"/>
- <value name="GL_RENDERBUFFER_GREEN_SIZE"/>
- <value name="GL_RENDERBUFFER_BLUE_SIZE"/>
- <value name="GL_RENDERBUFFER_ALPHA_SIZE"/>
- <value name="GL_RENDERBUFFER_DEPTH_SIZE"/>
- <value name="GL_RENDERBUFFER_STENCIL_SIZE"/>
-
- <desc name="params" vector_size="1" convert="false"/>
- </desc>
-</template>
-
-<template name="IsRenderbuffer" direction="get">
- <proto>
- <return type="GLboolean"/>
- <param name="renderbuffer" type="GLuint"/>
- </proto>
-</template>
-
-<template name="IsFramebuffer" direction="get">
- <proto>
- <return type="GLboolean"/>
- <param name="framebuffer" type="GLuint"/>
- </proto>
-</template>
-
-<template name="IsShader" direction="get">
- <proto>
- <return type="GLboolean"/>
- <param name="shader" type="GLuint"/>
- </proto>
-</template>
-
-<template name="GetShader" direction="get">
- <proto>
- <return type="void"/>
- <param name="shader" type="GLuint"/>
- <param name="pname" type="GLenum"/>
- <vector name="params" type="GLtype *" size="dynamic"/>
- </proto>
-
- <desc name="pname">
- <value name="GL_SHADER_TYPE"/>
- <value name="GL_COMPILE_STATUS"/>
- <value name="GL_DELETE_STATUS"/>
- <value name="GL_INFO_LOG_LENGTH"/>
- <value name="GL_SHADER_SOURCE_LENGTH"/>
- </desc>
-</template>
-
-<template name="GetAttachedShaders" direction="get">
- <proto>
- <return type="void"/>
- <param name="program" type="GLuint"/>
- <param name="maxCount" type="GLsizei"/>
- <param name="count" type="GLsizei *"/>
- <param name="shaders" type="GLuint *"/>
- </proto>
-</template>
-
-<template name="GetShaderInfoLog" direction="get">
- <proto>
- <return type="void"/>
- <param name="shader" type="GLuint"/>
- <param name="bufSize" type="GLsizei"/>
- <param name="length" type="GLsizei *"/>
- <param name="infoLog" type="GLchar *"/>
- </proto>
-</template>
-
-<template name="GetProgramInfoLog" direction="get">
- <proto>
- <return type="void"/>
- <param name="program" type="GLuint"/>
- <param name="bufSize" type="GLsizei"/>
- <param name="length" type="GLsizei *"/>
- <param name="infoLog" type="GLchar *"/>
- </proto>
-</template>
-
-<template name="GetShaderSource" direction="get">
- <proto>
- <return type="void"/>
- <param name="shader" type="GLuint"/>
- <param name="bufSize" type="GLsizei"/>
- <param name="length" type="GLsizei *"/>
- <param name="source" type="GLchar *"/>
- </proto>
-</template>
-
-<template name="GetShaderPrecisionFormat" direction="get">
- <proto>
- <return type="void"/>
- <param name="shadertype" type="GLenum"/>
- <param name="precisiontype" type="GLenum"/>
- <param name="range" type="GLint *"/>
- <param name="precision" type="GLint *"/>
- </proto>
-
- <desc name="shadertype">
- <value name="GL_VERTEX_SHADER"/>
- <value name="GL_FRAGMENT_SHADER"/>
- </desc>
-
- <desc name="precisiontype">
- <value name="GL_LOW_FLOAT"/>
- <value name="GL_MEDIUM_FLOAT"/>
- <value name="GL_HIGH_FLOAT"/>
- <value name="GL_LOW_INT"/>
- <value name="GL_MEDIUM_INT"/>
- <value name="GL_HIGH_INT"/>
- </desc>
-</template>
-
-<template name="GetUniform" direction="get">
- <proto>
- <return type="void"/>
- <param name="program" type="GLuint"/>
- <param name="location" type="GLint"/>
- <vector name="params" type="GLtype *" size="dynamic"/>
- </proto>
-</template>
-
-<template name="QueryMatrix" direction="get">
- <proto>
- <return type="GLbitfield"/>
- <vector name="mantissa" type="GLtype *" size="16"/>
- <vector name="exponent" type="GLint *" size="16"/>
- </proto>
-</template>
-
-<template name="DrawTex">
- <proto>
- <return type="void"/>
- <vector name="coords" type="const GLtype *" size="5">
- <param name="x" type="GLtype"/>
- <param name="y" type="GLtype"/>
- <param name="z" type="GLtype"/>
- <param name="w" type="GLtype"/>
- <param name="h" type="GLtype"/>
- </vector>
- </proto>
-</template>
-
-<template name="MultiDrawArrays">
- <proto>
- <return type="void"/>
- <param name="mode" type="GLenum"/>
- <param name="first" type="const GLint *"/>
- <param name="count" type="const GLsizei *"/>
- <param name="primcount" type="GLsizei"/>
- </proto>
-
- <desc name="mode">
- <value name="GL_POINTS"/>
- <value name="GL_LINES"/>
- <value name="GL_LINE_LOOP"/>
- <value name="GL_LINE_STRIP"/>
- <value name="GL_TRIANGLES"/>
- <value name="GL_TRIANGLE_STRIP"/>
- <value name="GL_TRIANGLE_FAN"/>
- </desc>
-</template>
-
-<template name="MultiDrawElements">
- <proto>
- <return type="void"/>
- <param name="mode" type="GLenum"/>
- <param name="count" type="const GLsizei *"/>
- <param name="type" type="GLenum"/>
- <param name="indices" type="const GLvoid **"/>
- <param name="primcount" type="GLsizei"/>
- </proto>
-
- <desc name="mode">
- <value name="GL_POINTS"/>
- <value name="GL_LINES"/>
- <value name="GL_LINE_LOOP"/>
- <value name="GL_LINE_STRIP"/>
- <value name="GL_TRIANGLES"/>
- <value name="GL_TRIANGLE_STRIP"/>
- <value name="GL_TRIANGLE_FAN"/>
- </desc>
-
- <desc name="type">
- <value name="GL_UNSIGNED_BYTE"/>
- <value name="GL_UNSIGNED_SHORT"/>
- <value name="GL_UNSIGNED_INT" category="OES_element_index_uint"/>
- </desc>
-</template>
-
-<template name="EGLImageTargetTexture2D">
- <proto>
- <return type="void"/>
- <param name="target" type="GLenum"/>
- <param name="image" type="GLeglImageOES"/>
- </proto>
-
- <desc name="target">
- <value name="GL_TEXTURE_2D"/>
- </desc>
-</template>
-
-<template name="EGLImageTargetRenderbufferStorage">
- <proto>
- <return type="void"/>
- <param name="target" type="GLenum"/>
- <param name="image" type="GLeglImageOES"/>
- </proto>
-
- <desc name="target">
- <value name="GL_RENDERBUFFER_OES" category="OES_framebuffer_object"/>
- <value name="GL_RENDERBUFFER" category="GLES2.0"/>
- </desc>
-</template>
-
-<api name="mesa" implementation="true">
- <category name="MESA"/>
-
- <function name="Color4f" default_prefix="_es_" template="Color" gltype="GLfloat" vector_size="4" expand_vector="true"/>
- <function name="ClipPlane" template="ClipPlane" gltype="GLdouble"/>
- <function name="CullFace" template="CullFace"/>
-
- <function name="Fogf" template="Fog" gltype="GLfloat" expand_vector="true"/>
- <function name="Fogfv" template="Fog" gltype="GLfloat"/>
-
- <function name="FrontFace" template="FrontFace"/>
- <function name="Hint" template="Hint"/>
-
- <function name="Lightf" template="Light" gltype="GLfloat" expand_vector="true"/>
- <function name="Lightfv" template="Light" gltype="GLfloat"/>
-
- <function name="LightModelf" template="LightModel" gltype="GLfloat" expand_vector="true"/>
- <function name="LightModelfv" template="LightModel" gltype="GLfloat"/>
-
- <function name="LineWidth" template="LineWidth" gltype="GLfloat"/>
-
- <function name="Materialf" default_prefix="_es_" template="Material" gltype="GLfloat" expand_vector="true"/>
- <function name="Materialfv" default_prefix="_es_" template="Material" gltype="GLfloat"/>
-
- <function name="PointSize" template="PointSize" gltype="GLfloat"/>
- <function name="PointSizePointer" template="PointSizePointer"/>
-
- <function name="Scissor" template="Scissor"/>
- <function name="ShadeModel" template="ShadeModel"/>
-
- <function name="TexParameterf" template="TexParameter" gltype="GLfloat" expand_vector="true"/>
- <function name="TexParameterfv" template="TexParameter" gltype="GLfloat"/>
- <function name="TexParameteri" template="TexParameter" gltype="GLint" expand_vector="true"/>
- <function name="TexParameteriv" template="TexParameter" gltype="GLint"/>
-
- <function name="TexImage2D" template="TexImage2D"/>
-
- <function name="TexEnvf" template="TexEnv" gltype="GLfloat" expand_vector="true"/>
- <function name="TexEnvi" template="TexEnv" gltype="GLint" expand_vector="true"/>
- <function name="TexEnvfv" template="TexEnv" gltype="GLfloat"/>
- <function name="TexEnviv" template="TexEnv" gltype="GLint"/>
-
- <function name="TexGenf" template="TexGen" gltype="GLfloat" expand_vector="true"/>
- <function name="TexGenfv" template="TexGen" gltype="GLfloat"/>
-
- <function name="Clear" template="Clear"/>
- <function name="ClearColor" template="ClearColor" gltype="GLclampf"/>
- <function name="ClearStencil" template="ClearStencil"/>
- <function name="ClearDepth" template="ClearDepth" gltype="GLclampd"/>
- <function name="ClearDepthf" template="ClearDepth" gltype="GLclampf"/>
-
- <function name="StencilMask" template="StencilMask"/>
- <function name="StencilMaskSeparate" template="StencilMaskSeparate"/>
- <function name="ColorMask" template="ColorMask"/>
- <function name="DepthMask" template="DepthMask"/>
- <function name="Disable" template="Disable"/>
- <function name="Enable" template="Enable"/>
- <function name="Finish" template="Finish"/>
- <function name="Flush" template="Flush"/>
-
- <function name="AlphaFunc" template="AlphaFunc" gltype="GLclampf"/>
-
- <function name="BlendFunc" template="BlendFunc"/>
- <function name="LogicOp" template="LogicOp"/>
- <function name="StencilFunc" template="StencilFunc"/>
- <function name="StencilFuncSeparate" template="StencilFuncSeparate"/>
- <function name="StencilOp" template="StencilOp"/>
- <function name="StencilOpSeparate" template="StencilOpSeparate"/>
- <function name="DepthFunc" template="DepthFunc"/>
- <function name="PixelStorei" template="PixelStore" gltype="GLint"/>
-
- <function name="ReadPixels" template="ReadPixels"/>
- <function name="GetBooleanv" template="GetState" gltype="GLboolean"/>
- <function name="GetClipPlane" template="GetClipPlane" gltype="GLdouble"/>
- <function name="GetError" template="GetError"/>
- <function name="GetFloatv" template="GetState" gltype="GLfloat"/>
- <function name="GetFixedv" template="GetState" gltype="GLfixed"/>
- <function name="GetIntegerv" template="GetState" gltype="GLint"/>
-
- <function name="GetLightfv" template="GetLight" gltype="GLfloat"/>
- <function name="GetMaterialfv" template="GetMaterial" gltype="GLfloat"/>
- <function name="GetMaterialiv" template="GetMaterial" gltype="GLint"/>
-
- <function name="GetString" template="GetString"/>
-
- <function name="GetTexEnvfv" template="GetTexEnv" gltype="GLfloat"/>
- <function name="GetTexEnviv" template="GetTexEnv" gltype="GLint"/>
- <function name="GetTexGenfv" template="GetTexGen" gltype="GLfloat"/>
- <function name="GetTexParameterfv" template="GetTexParameter" gltype="GLfloat"/>
- <function name="GetTexParameteriv" template="GetTexParameter" gltype="GLint"/>
-
- <function name="IsEnabled" template="IsEnabled"/>
-
- <function name="DepthRange" template="DepthRange" gltype="GLclampd"/>
- <function name="DepthRangef" template="DepthRange" gltype="GLclampf"/>
- <function name="Frustum" template="Frustum" gltype="GLdouble"/>
-
- <function name="LoadIdentity" template="LoadIdentity"/>
- <function name="LoadMatrixf" template="LoadMatrix" gltype="GLfloat"/>
- <function name="MatrixMode" template="MatrixMode"/>
-
- <function name="MultMatrixf" template="MultMatrix" gltype="GLfloat"/>
- <function name="Ortho" template="Ortho" gltype="GLdouble"/>
- <function name="PopMatrix" template="PopMatrix"/>
- <function name="PushMatrix" template="PushMatrix"/>
-
- <function name="Rotatef" template="Rotate" gltype="GLfloat"/>
- <function name="Scalef" template="Scale" gltype="GLfloat"/>
- <function name="Translatef" template="Translate" gltype="GLfloat"/>
-
- <function name="Viewport" template="Viewport"/>
-
- <function name="ColorPointer" template="ColorPointer"/>
- <function name="DisableClientState" template="DisableClientState"/>
- <function name="DrawArrays" template="DrawArrays"/>
- <function name="DrawElements" template="DrawElements"/>
- <function name="EnableClientState" template="EnableClientState"/>
-
- <function name="GetPointerv" template="GetPointer"/>
- <function name="Normal3f" default_prefix="_es_" template="Normal" gltype="GLfloat" expand_vector="true"/>
- <function name="NormalPointer" template="NormalPointer"/>
- <function name="TexCoordPointer" template="TexCoordPointer"/>
- <function name="VertexPointer" template="VertexPointer"/>
-
- <function name="PolygonOffset" template="PolygonOffset" gltype="GLfloat"/>
- <function name="CopyTexImage2D" template="CopyTexImage2D"/>
- <function name="CopyTexSubImage2D" template="CopyTexSubImage2D"/>
- <function name="TexSubImage2D" template="TexSubImage2D"/>
-
- <function name="BindTexture" template="BindTexture"/>
- <function name="DeleteTextures" template="DeleteTextures"/>
- <function name="GenTextures" template="GenTextures"/>
- <function name="IsTexture" template="IsTexture"/>
-
- <function name="BlendColor" template="BlendColor" gltype="GLclampf"/>
- <function name="BlendEquation" template="BlendEquation"/>
- <function name="BlendEquationSeparateEXT" template="BlendEquationSeparate"/>
-
- <function name="TexImage3D" template="TexImage3D"/>
- <function name="TexSubImage3D" template="TexSubImage3D"/>
- <function name="CopyTexSubImage3D" template="CopyTexSubImage3D"/>
-
- <function name="CompressedTexImage3DARB" template="CompressedTexImage3D"/>
- <function name="CompressedTexSubImage3DARB" template="CompressedTexSubImage3D"/>
-
- <function name="ActiveTextureARB" template="ActiveTexture"/>
- <function name="ClientActiveTextureARB" template="ClientActiveTexture"/>
-
- <function name="MultiTexCoord4f" default_prefix="_es_" template="MultiTexCoord" gltype="GLfloat" vector_size="4" expand_vector="true"/>
-
- <function name="SampleCoverageARB" template="SampleCoverage" gltype="GLclampf"/>
-
- <function name="CompressedTexImage2DARB" template="CompressedTexImage2D"/>
- <function name="CompressedTexSubImage2DARB" template="CompressedTexSubImage2D"/>
-
- <function name="BlendFuncSeparateEXT" template="BlendFuncSeparate"/>
-
- <function name="PointParameterf" template="PointParameter" gltype="GLfloat" expand_vector="true"/>
- <function name="PointParameterfv" template="PointParameter" gltype="GLfloat"/>
-
- <function name="VertexAttrib1f" default_prefix="_es_" template="VertexAttrib" gltype="GLfloat" vector_size="1" expand_vector="true"/>
- <function name="VertexAttrib2f" default_prefix="_es_" template="VertexAttrib" gltype="GLfloat" vector_size="2" expand_vector="true"/>
- <function name="VertexAttrib3f" default_prefix="_es_" template="VertexAttrib" gltype="GLfloat" vector_size="3" expand_vector="true"/>
- <function name="VertexAttrib4f" default_prefix="_es_" template="VertexAttrib" gltype="GLfloat" vector_size="4" expand_vector="true"/>
- <function name="VertexAttrib1fv" default_prefix="_es_" template="VertexAttrib" gltype="GLfloat" vector_size="1"/>
- <function name="VertexAttrib2fv" default_prefix="_es_" template="VertexAttrib" gltype="GLfloat" vector_size="2"/>
- <function name="VertexAttrib3fv" default_prefix="_es_" template="VertexAttrib" gltype="GLfloat" vector_size="3"/>
- <function name="VertexAttrib4fv" default_prefix="_es_" template="VertexAttrib" gltype="GLfloat" vector_size="4"/>
-
- <function name="VertexAttribPointerARB" template="VertexAttribPointer"/>
- <function name="EnableVertexAttribArrayARB" template="EnableVertexAttribArray"/>
- <function name="DisableVertexAttribArrayARB" template="DisableVertexAttribArray"/>
-
- <function name="IsProgram" template="IsProgram"/>
- <function name="GetProgramiv" template="GetProgram" gltype="GLint"/>
-
- <function name="GetVertexAttribfvARB" template="GetVertexAttrib" gltype="GLfloat"/>
- <function name="GetVertexAttribivARB" template="GetVertexAttrib" gltype="GLint"/>
- <function name="GetVertexAttribPointervARB" template="GetVertexAttribPointer"/>
-
- <function name="GetBufferPointervARB" template="GetBufferPointer"/>
- <function name="MapBufferARB" template="MapBuffer"/>
- <function name="UnmapBufferARB" template="UnmapBuffer"/>
- <function name="BindBufferARB" template="BindBuffer"/>
- <function name="BufferDataARB" template="BufferData"/>
- <function name="BufferSubDataARB" template="BufferSubData"/>
- <function name="DeleteBuffersARB" template="DeleteBuffers"/>
- <function name="GenBuffersARB" template="GenBuffers"/>
- <function name="GetBufferParameterivARB" template="GetBufferParameter" gltype="GLint"/>
- <function name="IsBufferARB" template="IsBuffer"/>
-
- <function name="CreateShader" template="CreateShader"/>
- <function name="ShaderSourceARB" template="ShaderSource"/>
- <function name="CompileShaderARB" template="CompileShader"/>
- <function name="ReleaseShaderCompiler" template="ReleaseShaderCompiler"/>
- <function name="DeleteShader" template="DeleteShader"/>
- <function name="ShaderBinary" template="ShaderBinary"/>
- <function name="CreateProgram" template="CreateProgram"/>
- <function name="AttachShader" template="AttachShader"/>
- <function name="DetachShader" template="DetachShader"/>
- <function name="LinkProgramARB" template="LinkProgram"/>
- <function name="UseProgramObjectARB" template="UseProgram"/>
- <function name="DeleteProgram" template="DeleteProgram"/>
-
- <function name="GetActiveAttribARB" template="GetActiveAttrib"/>
- <function name="GetAttribLocationARB" template="GetAttribLocation"/>
- <function name="BindAttribLocationARB" template="BindAttribLocation"/>
- <function name="GetUniformLocationARB" template="GetUniformLocation"/>
- <function name="GetActiveUniformARB" template="GetActiveUniform"/>
-
- <function name="Uniform1fARB" template="Uniform" gltype="GLfloat" vector_size="1" expand_vector="true"/>
- <function name="Uniform2fARB" template="Uniform" gltype="GLfloat" vector_size="2" expand_vector="true"/>
- <function name="Uniform3fARB" template="Uniform" gltype="GLfloat" vector_size="3" expand_vector="true"/>
- <function name="Uniform4fARB" template="Uniform" gltype="GLfloat" vector_size="4" expand_vector="true"/>
- <function name="Uniform1iARB" template="Uniform" gltype="GLint" vector_size="1" expand_vector="true"/>
- <function name="Uniform2iARB" template="Uniform" gltype="GLint" vector_size="2" expand_vector="true"/>
- <function name="Uniform3iARB" template="Uniform" gltype="GLint" vector_size="3" expand_vector="true"/>
- <function name="Uniform4iARB" template="Uniform" gltype="GLint" vector_size="4" expand_vector="true"/>
- <function name="Uniform1fvARB" template="Uniform" gltype="GLfloat" vector_size="1"/>
- <function name="Uniform2fvARB" template="Uniform" gltype="GLfloat" vector_size="2"/>
- <function name="Uniform3fvARB" template="Uniform" gltype="GLfloat" vector_size="3"/>
- <function name="Uniform4fvARB" template="Uniform" gltype="GLfloat" vector_size="4"/>
- <function name="Uniform1ivARB" template="Uniform" gltype="GLint" vector_size="1"/>
- <function name="Uniform2ivARB" template="Uniform" gltype="GLint" vector_size="2"/>
- <function name="Uniform3ivARB" template="Uniform" gltype="GLint" vector_size="3"/>
- <function name="Uniform4ivARB" template="Uniform" gltype="GLint" vector_size="4"/>
-
- <function name="UniformMatrix2fvARB" template="UniformMatrix" gltype="GLfloat" vector_size="2"/>
- <function name="UniformMatrix3fvARB" template="UniformMatrix" gltype="GLfloat" vector_size="3"/>
- <function name="UniformMatrix4fvARB" template="UniformMatrix" gltype="GLfloat" vector_size="4"/>
-
- <function name="ValidateProgramARB" template="ValidateProgram"/>
-
- <function name="GenerateMipmapEXT" template="GenerateMipmap"/>
- <function name="BindFramebufferEXT" template="BindFramebuffer"/>
- <function name="DeleteFramebuffersEXT" template="DeleteFramebuffers"/>
- <function name="GenFramebuffersEXT" template="GenFramebuffers"/>
- <function name="BindRenderbufferEXT" template="BindRenderbuffer"/>
- <function name="DeleteRenderbuffersEXT" template="DeleteRenderbuffers"/>
- <function name="GenRenderbuffersEXT" template="GenRenderbuffers"/>
- <function name="RenderbufferStorageEXT" template="RenderbufferStorage"/>
- <function name="FramebufferRenderbufferEXT" template="FramebufferRenderbuffer"/>
- <function name="FramebufferTexture2DEXT" template="FramebufferTexture2D"/>
- <function name="FramebufferTexture3DEXT" template="FramebufferTexture3D"/>
- <function name="CheckFramebufferStatusEXT" template="CheckFramebufferStatus"/>
- <function name="GetFramebufferAttachmentParameterivEXT" template="GetFramebufferAttachmentParameter" gltype="GLint"/>
- <function name="GetRenderbufferParameterivEXT" template="GetRenderbufferParameter" gltype="GLint"/>
- <function name="IsRenderbufferEXT" template="IsRenderbuffer"/>
- <function name="IsFramebufferEXT" template="IsFramebuffer"/>
-
- <function name="IsShader" template="IsShader"/>
- <function name="GetShaderiv" template="GetShader" gltype="GLint"/>
- <function name="GetAttachedShaders" template="GetAttachedShaders"/>
- <function name="GetShaderInfoLog" template="GetShaderInfoLog"/>
- <function name="GetProgramInfoLog" template="GetProgramInfoLog"/>
- <function name="GetShaderSourceARB" template="GetShaderSource"/>
- <function name="GetShaderPrecisionFormat" template="GetShaderPrecisionFormat"/>
- <function name="GetUniformfvARB" template="GetUniform" gltype="GLfloat"/>
- <function name="GetUniformivARB" template="GetUniform" gltype="GLint"/>
-
- <function name="DrawTexf" template="DrawTex" gltype="GLfloat" expand_vector="true"/>
- <function name="DrawTexfv" template="DrawTex" gltype="GLfloat"/>
- <function name="DrawTexi" template="DrawTex" gltype="GLint" expand_vector="true"/>
- <function name="DrawTexiv" template="DrawTex" gltype="GLint"/>
- <function name="DrawTexs" template="DrawTex" gltype="GLshort" expand_vector="true"/>
- <function name="DrawTexsv" template="DrawTex" gltype="GLshort"/>
-
- <!-- EXT_multi_draw_arrays -->
- <function name="MultiDrawArraysEXT" template="MultiDrawArrays"/>
- <function name="MultiDrawElementsEXT" template="MultiDrawElements"/>
-
- <!-- OES_EGL_image -->
- <function name="EGLImageTargetTexture2DOES" template="EGLImageTargetTexture2D"/>
- <function name="EGLImageTargetRenderbufferStorageOES" template="EGLImageTargetRenderbufferStorage"/>
-</api>
-
-<api name="GLES1.1">
- <category name="GLES1.1"/>
-
- <category name="OES_byte_coordinates"/>
- <category name="OES_fixed_point"/>
- <category name="OES_single_precision"/>
- <category name="OES_matrix_get"/>
- <category name="OES_read_format"/>
- <category name="OES_compressed_paletted_texture"/>
- <category name="OES_point_size_array"/>
- <category name="OES_point_sprite"/>
- <category name="OES_query_matrix"/>
- <category name="OES_draw_texture"/>
- <category name="OES_blend_equation_separate"/>
- <category name="OES_blend_func_separate"/>
- <category name="OES_blend_subtract"/>
- <category name="OES_stencil_wrap"/>
- <category name="OES_texture_cube_map"/>
- <category name="OES_texture_env_crossbar"/>
- <category name="OES_texture_mirrored_repeat"/>
- <category name="OES_framebuffer_object"/>
- <category name="OES_depth24"/>
- <category name="OES_depth32"/>
- <category name="OES_fbo_render_mipmap"/>
- <category name="OES_rgb8_rgba8"/>
- <category name="OES_stencil1"/>
- <category name="OES_stencil4"/>
- <category name="OES_stencil8"/>
- <category name="OES_element_index_uint"/>
- <category name="OES_mapbuffer"/>
- <category name="EXT_texture_filter_anisotropic"/>
-
- <category name="ARB_texture_non_power_of_two"/>
- <!-- disabled due to missing enums
- <category name="EXT_texture_compression_dxt1"/>
- -->
- <category name="EXT_texture_lod_bias"/>
- <category name="EXT_blend_minmax"/>
- <category name="EXT_multi_draw_arrays"/>
- <category name="OES_EGL_image"/>
-
- <category name="OES_matrix_palette"/>
-
- <function name="Color4f" external="true" template="Color" gltype="GLfloat" vector_size="4" expand_vector="true"/>
- <function name="Color4ub" template="Color" gltype="GLubyte" vector_size="4" expand_vector="true"/>
- <function name="Color4x" template="Color" gltype="GLfixed" vector_size="4" expand_vector="true"/>
-
- <function name="ClipPlanef" template="ClipPlane" gltype="GLfloat"/>
- <function name="ClipPlanex" template="ClipPlane" gltype="GLfixed"/>
-
- <function name="CullFace" template="CullFace"/>
-
- <function name="Fogf" template="Fog" gltype="GLfloat" expand_vector="true"/>
- <function name="Fogx" template="Fog" gltype="GLfixed" expand_vector="true"/>
- <function name="Fogfv" template="Fog" gltype="GLfloat"/>
- <function name="Fogxv" template="Fog" gltype="GLfixed"/>
-
- <function name="FrontFace" template="FrontFace"/>
- <function name="Hint" template="Hint"/>
-
- <function name="Lightf" template="Light" gltype="GLfloat" expand_vector="true"/>
- <function name="Lightx" template="Light" gltype="GLfixed" expand_vector="true"/>
- <function name="Lightfv" template="Light" gltype="GLfloat"/>
- <function name="Lightxv" template="Light" gltype="GLfixed"/>
-
- <function name="LightModelf" template="LightModel" gltype="GLfloat" expand_vector="true"/>
- <function name="LightModelx" template="LightModel" gltype="GLfixed" expand_vector="true"/>
- <function name="LightModelfv" template="LightModel" gltype="GLfloat"/>
- <function name="LightModelxv" template="LightModel" gltype="GLfixed"/>
-
- <function name="LineWidth" template="LineWidth" gltype="GLfloat"/>
- <function name="LineWidthx" template="LineWidth" gltype="GLfixed"/>
-
- <function name="Materialf" external="true" template="Material" gltype="GLfloat" expand_vector="true"/>
- <function name="Materialfv" external="true" template="Material" gltype="GLfloat"/>
- <function name="Materialx" template="Material" gltype="GLfixed" expand_vector="true"/>
- <function name="Materialxv" template="Material" gltype="GLfixed"/>
-
- <function name="PointSize" template="PointSize" gltype="GLfloat"/>
- <function name="PointSizex" template="PointSize" gltype="GLfixed"/>
- <function name="PointSizePointerOES" template="PointSizePointer"/>
-
- <function name="Scissor" template="Scissor"/>
- <function name="ShadeModel" template="ShadeModel"/>
-
- <function name="TexParameterf" template="TexParameter" gltype="GLfloat" expand_vector="true"/>
- <function name="TexParameterfv" template="TexParameter" gltype="GLfloat"/>
- <function name="TexParameteri" template="TexParameter" gltype="GLint" expand_vector="true"/>
- <function name="TexParameteriv" template="TexParameter" gltype="GLint"/>
- <function name="TexParameterx" template="TexParameter" gltype="GLfixed" expand_vector="true"/>
- <function name="TexParameterxv" template="TexParameter" gltype="GLfixed"/>
-
- <function name="TexImage2D" template="TexImage2D"/>
-
- <function name="TexEnvf" template="TexEnv" gltype="GLfloat" expand_vector="true"/>
- <function name="TexEnvfv" template="TexEnv" gltype="GLfloat"/>
- <function name="TexEnvi" template="TexEnv" gltype="GLint" expand_vector="true"/>
- <function name="TexEnviv" template="TexEnv" gltype="GLint"/>
- <function name="TexEnvx" template="TexEnv" gltype="GLfixed" expand_vector="true"/>
- <function name="TexEnvxv" template="TexEnv" gltype="GLfixed"/>
-
- <function name="TexGenfOES" external="true" template="TexGen" gltype="GLfloat" expand_vector="true"/>
- <function name="TexGenfvOES" external="true" template="TexGen" gltype="GLfloat"/>
- <function name="TexGeniOES" external="true" template="TexGen" gltype="GLint" expand_vector="true"/>
- <function name="TexGenivOES" external="true" template="TexGen" gltype="GLint"/>
- <function name="TexGenxOES" external="true" template="TexGen" gltype="GLfixed" expand_vector="true"/>
- <function name="TexGenxvOES" external="true" template="TexGen" gltype="GLfixed"/>
-
- <function name="Clear" template="Clear"/>
- <function name="ClearColor" template="ClearColor" gltype="GLclampf"/>
- <function name="ClearColorx" template="ClearColor" gltype="GLclampx"/>
-
- <function name="ClearStencil" template="ClearStencil"/>
- <function name="ClearDepthf" template="ClearDepth" gltype="GLclampf"/>
- <function name="ClearDepthx" template="ClearDepth" gltype="GLclampx"/>
-
- <function name="StencilMask" template="StencilMask"/>
- <function name="ColorMask" template="ColorMask"/>
- <function name="DepthMask" template="DepthMask"/>
-
- <function name="Disable" template="Disable"/>
- <function name="Enable" template="Enable"/>
- <function name="Finish" template="Finish"/>
- <function name="Flush" template="Flush"/>
-
- <function name="AlphaFunc" template="AlphaFunc" gltype="GLclampf"/>
- <function name="AlphaFuncx" template="AlphaFunc" gltype="GLclampx"/>
-
- <function name="BlendFunc" template="BlendFunc"/>
- <function name="LogicOp" template="LogicOp"/>
- <function name="StencilFunc" template="StencilFunc"/>
-
- <function name="StencilOp" template="StencilOp"/>
- <function name="DepthFunc" template="DepthFunc"/>
-
- <function name="PixelStorei" template="PixelStore" gltype="GLint"/>
- <function name="ReadPixels" template="ReadPixels"/>
-
- <function name="GetBooleanv" template="GetState" gltype="GLboolean"/>
-
- <function name="GetClipPlanef" template="GetClipPlane" gltype="GLfloat"/>
- <function name="GetClipPlanex" template="GetClipPlane" gltype="GLfixed"/>
-
- <function name="GetError" template="GetError"/>
- <function name="GetFloatv" template="GetState" gltype="GLfloat"/>
- <function name="GetFixedv" template="GetState" gltype="GLfixed"/>
- <function name="GetIntegerv" template="GetState" gltype="GLint"/>
-
- <function name="GetLightfv" template="GetLight" gltype="GLfloat"/>
- <function name="GetLightxv" template="GetLight" gltype="GLfixed"/>
-
- <function name="GetMaterialfv" template="GetMaterial" gltype="GLfloat"/>
- <function name="GetMaterialxv" template="GetMaterial" gltype="GLfixed"/>
-
- <function name="GetString" template="GetString"/>
-
- <function name="GetTexEnvfv" template="GetTexEnv" gltype="GLfloat"/>
- <function name="GetTexEnviv" template="GetTexEnv" gltype="GLint"/>
- <function name="GetTexEnvxv" template="GetTexEnv" gltype="GLfixed"/>
-
- <function name="GetTexGenfvOES" external="true" template="GetTexGen" gltype="GLfloat"/>
- <function name="GetTexGenivOES" external="true" template="GetTexGen" gltype="GLint"/>
- <function name="GetTexGenxvOES" external="true" template="GetTexGen" gltype="GLfixed"/>
-
- <function name="GetTexParameterfv" template="GetTexParameter" gltype="GLfloat"/>
- <function name="GetTexParameteriv" template="GetTexParameter" gltype="GLint"/>
- <function name="GetTexParameterxv" template="GetTexParameter" gltype="GLfixed"/>
-
- <function name="IsEnabled" template="IsEnabled"/>
-
- <function name="DepthRangef" template="DepthRange" gltype="GLclampf"/>
- <function name="DepthRangex" template="DepthRange" gltype="GLclampx"/>
-
- <function name="Frustumf" template="Frustum" gltype="GLfloat"/>
- <function name="Frustumx" template="Frustum" gltype="GLfixed"/>
-
- <function name="LoadIdentity" template="LoadIdentity"/>
- <function name="LoadMatrixf" template="LoadMatrix" gltype="GLfloat"/>
- <function name="LoadMatrixx" template="LoadMatrix" gltype="GLfixed"/>
- <function name="MatrixMode" template="MatrixMode"/>
-
- <function name="MultMatrixf" template="MultMatrix" gltype="GLfloat"/>
- <function name="MultMatrixx" template="MultMatrix" gltype="GLfixed"/>
- <function name="Orthof" template="Ortho" gltype="GLfloat"/>
- <function name="Orthox" template="Ortho" gltype="GLfixed"/>
-
- <function name="PopMatrix" template="PopMatrix"/>
- <function name="PushMatrix" template="PushMatrix"/>
-
- <function name="Rotatef" template="Rotate" gltype="GLfloat"/>
- <function name="Rotatex" template="Rotate" gltype="GLfixed"/>
- <function name="Scalef" template="Scale" gltype="GLfloat"/>
- <function name="Scalex" template="Scale" gltype="GLfixed"/>
- <function name="Translatef" template="Translate" gltype="GLfloat"/>
- <function name="Translatex" template="Translate" gltype="GLfixed"/>
-
- <function name="Viewport" template="Viewport"/>
- <function name="ColorPointer" template="ColorPointer"/>
- <function name="DisableClientState" template="DisableClientState"/>
- <function name="DrawArrays" template="DrawArrays"/>
- <function name="DrawElements" template="DrawElements"/>
- <function name="EnableClientState" template="EnableClientState"/>
-
- <function name="GetPointerv" template="GetPointer"/>
-
- <function name="Normal3f" external="true" template="Normal" gltype="GLfloat" expand_vector="true"/>
- <function name="Normal3x" template="Normal" gltype="GLfixed" expand_vector="true"/>
- <function name="NormalPointer" template="NormalPointer"/>
- <function name="TexCoordPointer" template="TexCoordPointer"/>
- <function name="VertexPointer" template="VertexPointer"/>
-
- <function name="PolygonOffset" template="PolygonOffset" gltype="GLfloat"/>
- <function name="PolygonOffsetx" template="PolygonOffset" gltype="GLfixed"/>
-
- <function name="CopyTexImage2D" template="CopyTexImage2D"/>
- <function name="CopyTexSubImage2D" template="CopyTexSubImage2D"/>
-
- <function name="TexSubImage2D" template="TexSubImage2D"/>
-
- <function name="BindTexture" template="BindTexture"/>
- <function name="DeleteTextures" template="DeleteTextures"/>
- <function name="GenTextures" template="GenTextures"/>
- <function name="IsTexture" template="IsTexture"/>
-
- <function name="BlendEquationOES" template="BlendEquation"/>
- <function name="BlendEquationSeparateOES" template="BlendEquationSeparate"/>
-
- <function name="MultiTexCoord4x" template="MultiTexCoord" gltype="GLfixed" vector_size="4" expand_vector="true"/>
-
- <function name="ActiveTexture" template="ActiveTexture"/>
- <function name="ClientActiveTexture" template="ClientActiveTexture"/>
-
- <function name="MultiTexCoord4f" external="true" template="MultiTexCoord" gltype="GLfloat" vector_size="4" expand_vector="true"/>
-
- <function name="SampleCoverage" template="SampleCoverage" gltype="GLclampf"/>
- <function name="SampleCoveragex" template="SampleCoverage" gltype="GLclampx"/>
-
- <!-- CompressedTexImage2D calls out to two different functions based on
- whether the image is a paletted image or not -->
- <function name="CompressedTexImage2D" template="CompressedTexImage2D"/>
- <function name="CompressedTexSubImage2D" template="CompressedTexSubImage2D"/>
-
- <function name="BlendFuncSeparateOES" template="BlendFuncSeparate"/>
-
- <function name="PointParameterf" template="PointParameter" gltype="GLfloat" expand_vector="true"/>
- <function name="PointParameterfv" template="PointParameter" gltype="GLfloat"/>
- <function name="PointParameterx" template="PointParameter" gltype="GLfixed" expand_vector="true"/>
- <function name="PointParameterxv" template="PointParameter" gltype="GLfixed"/>
-
- <!-- OES_mapbuffer -->
- <function name="GetBufferPointervOES" template="GetBufferPointer"/>
- <function name="MapBufferOES" template="MapBuffer"/>
- <function name="UnmapBufferOES" template="UnmapBuffer"/>
-
- <function name="BindBuffer" template="BindBuffer"/>
- <function name="BufferData" template="BufferData"/>
- <function name="BufferSubData" template="BufferSubData"/>
- <function name="DeleteBuffers" template="DeleteBuffers"/>
- <function name="GenBuffers" template="GenBuffers"/>
- <function name="GetBufferParameteriv" template="GetBufferParameter" gltype="GLint"/>
- <function name="IsBuffer" template="IsBuffer"/>
-
- <!-- OES_framebuffer_object -->
- <function name="GenerateMipmapOES" template="GenerateMipmap"/>
- <function name="BindFramebufferOES" template="BindFramebuffer"/>
- <function name="DeleteFramebuffersOES" template="DeleteFramebuffers"/>
- <function name="GenFramebuffersOES" template="GenFramebuffers"/>
- <function name="BindRenderbufferOES" template="BindRenderbuffer"/>
- <function name="DeleteRenderbuffersOES" template="DeleteRenderbuffers"/>
- <function name="GenRenderbuffersOES" template="GenRenderbuffers"/>
- <function name="RenderbufferStorageOES" external="true" template="RenderbufferStorage"/>
- <function name="FramebufferRenderbufferOES" template="FramebufferRenderbuffer"/>
- <function name="FramebufferTexture2DOES" template="FramebufferTexture2D"/>
- <function name="CheckFramebufferStatusOES" template="CheckFramebufferStatus"/>
- <function name="GetFramebufferAttachmentParameterivOES" template="GetFramebufferAttachmentParameter" gltype="GLint"/>
- <function name="GetRenderbufferParameterivOES" template="GetRenderbufferParameter" gltype="GLint"/>
- <function name="IsRenderbufferOES" template="IsRenderbuffer"/>
- <function name="IsFramebufferOES" template="IsFramebuffer"/>
-
- <!-- OES_query_matrix -->
- <!-- QueryMatrixx returns values in an unusual, decomposed, fixed-value
- form; it has its own code for this -->
- <function name="QueryMatrixxOES" external="true" template="QueryMatrix" gltype="GLfixed"/>
-
- <!-- OES_draw_texture -->
- <function name="DrawTexfOES" template="DrawTex" gltype="GLfloat" expand_vector="true"/>
- <function name="DrawTexiOES" template="DrawTex" gltype="GLint" expand_vector="true"/>
- <function name="DrawTexsOES" template="DrawTex" gltype="GLshort" expand_vector="true"/>
- <function name="DrawTexxOES" template="DrawTex" gltype="GLfixed" expand_vector="true"/>
- <function name="DrawTexfvOES" template="DrawTex" gltype="GLfloat"/>
- <function name="DrawTexivOES" template="DrawTex" gltype="GLint"/>
- <function name="DrawTexsvOES" template="DrawTex" gltype="GLshort"/>
- <function name="DrawTexxvOES" template="DrawTex" gltype="GLfixed"/>
-
- <!-- EXT_multi_draw_arrays -->
- <function name="MultiDrawArraysEXT" template="MultiDrawArrays"/>
- <function name="MultiDrawElementsEXT" template="MultiDrawElements"/>
-
- <!-- OES_EGL_image -->
- <function name="EGLImageTargetTexture2DOES" template="EGLImageTargetTexture2D"/>
- <function name="EGLImageTargetRenderbufferStorageOES" template="EGLImageTargetRenderbufferStorage"/>
-</api>
-
-<api name="GLES2.0">
- <category name="GLES2.0"/>
-
- <category name="OES_compressed_paletted_texture"/>
- <category name="OES_depth24"/>
- <category name="OES_depth32"/>
- <category name="OES_fbo_render_mipmap"/>
- <category name="OES_rgb8_rgba8"/>
- <category name="OES_stencil1"/>
- <category name="OES_stencil4"/>
- <category name="OES_element_index_uint"/>
- <category name="OES_mapbuffer"/>
- <category name="OES_texture_3D"/>
- <category name="OES_texture_npot"/>
- <category name="EXT_texture_filter_anisotropic"/>
- <category name="EXT_texture_type_2_10_10_10_REV"/>
- <category name="OES_depth_texture"/>
- <category name="OES_packed_depth_stencil"/>
- <category name="OES_standard_derivatives"/>
- <category name="EXT_texture_format_BGRA8888"/>
-
- <category name="EXT_texture_compression_dxt1"/>
- <category name="EXT_blend_minmax"/>
- <category name="EXT_multi_draw_arrays"/>
- <category name="OES_EGL_image"/>
-
- <function name="CullFace" template="CullFace"/>
-
- <function name="FrontFace" template="FrontFace"/>
- <function name="Hint" template="Hint"/>
-
- <function name="LineWidth" template="LineWidth" gltype="GLfloat"/>
-
- <function name="Scissor" template="Scissor"/>
-
- <function name="TexParameterf" template="TexParameter" gltype="GLfloat" expand_vector="true"/>
- <function name="TexParameterfv" template="TexParameter" gltype="GLfloat"/>
- <function name="TexParameteri" template="TexParameter" gltype="GLint" expand_vector="true"/>
- <function name="TexParameteriv" template="TexParameter" gltype="GLint"/>
-
- <function name="TexImage2D" template="TexImage2D"/>
-
- <function name="Clear" template="Clear"/>
- <function name="ClearColor" template="ClearColor" gltype="GLclampf"/>
- <function name="ClearStencil" template="ClearStencil"/>
- <function name="ClearDepthf" template="ClearDepth" gltype="GLclampf"/>
-
- <function name="StencilMask" template="StencilMask"/>
- <function name="StencilMaskSeparate" template="StencilMaskSeparate"/>
- <function name="ColorMask" template="ColorMask"/>
- <function name="DepthMask" template="DepthMask"/>
- <function name="Disable" template="Disable"/>
- <function name="Enable" template="Enable"/>
- <function name="Finish" template="Finish"/>
- <function name="Flush" template="Flush"/>
-
- <function name="BlendFunc" template="BlendFunc"/>
-
- <function name="StencilFunc" template="StencilFunc"/>
- <function name="StencilFuncSeparate" template="StencilFuncSeparate"/>
- <function name="StencilOp" template="StencilOp"/>
- <function name="StencilOpSeparate" template="StencilOpSeparate"/>
-
- <function name="DepthFunc" template="DepthFunc"/>
-
- <function name="PixelStorei" template="PixelStore" gltype="GLint"/>
- <function name="ReadPixels" template="ReadPixels"/>
-
- <function name="GetBooleanv" template="GetState" gltype="GLboolean"/>
- <function name="GetError" template="GetError"/>
- <function name="GetFloatv" template="GetState" gltype="GLfloat"/>
- <function name="GetIntegerv" template="GetState" gltype="GLint"/>
-
- <function name="GetString" template="GetString"/>
-
- <function name="GetTexParameterfv" template="GetTexParameter" gltype="GLfloat"/>
- <function name="GetTexParameteriv" template="GetTexParameter" gltype="GLint"/>
-
- <function name="IsEnabled" template="IsEnabled"/>
-
- <function name="DepthRangef" template="DepthRange" gltype="GLclampf"/>
-
- <function name="Viewport" template="Viewport"/>
-
- <function name="DrawArrays" template="DrawArrays"/>
- <function name="DrawElements" template="DrawElements"/>
-
- <function name="PolygonOffset" template="PolygonOffset" gltype="GLfloat"/>
- <function name="CopyTexImage2D" template="CopyTexImage2D"/>
- <function name="CopyTexSubImage2D" template="CopyTexSubImage2D"/>
- <function name="TexSubImage2D" template="TexSubImage2D"/>
-
- <function name="BindTexture" template="BindTexture"/>
- <function name="DeleteTextures" template="DeleteTextures"/>
- <function name="GenTextures" template="GenTextures"/>
- <function name="IsTexture" template="IsTexture"/>
-
- <function name="BlendColor" template="BlendColor" gltype="GLclampf"/>
- <function name="BlendEquation" template="BlendEquation"/>
- <function name="BlendEquationSeparate" template="BlendEquationSeparate"/>
-
- <function name="TexImage3DOES" template="TexImage3D"/>
- <function name="TexSubImage3DOES" template="TexSubImage3D"/>
- <function name="CopyTexSubImage3DOES" template="CopyTexSubImage3D"/>
-
- <function name="CompressedTexImage3DOES" template="CompressedTexImage3D"/>
- <function name="CompressedTexSubImage3DOES" template="CompressedTexSubImage3D"/>
-
- <function name="ActiveTexture" template="ActiveTexture"/>
-
- <function name="SampleCoverage" template="SampleCoverage" gltype="GLclampf"/>
-
- <function name="CompressedTexImage2D" template="CompressedTexImage2D"/>
- <function name="CompressedTexSubImage2D" template="CompressedTexSubImage2D"/>
-
- <function name="BlendFuncSeparate" template="BlendFuncSeparate"/>
-
- <function name="VertexAttrib1f" external="true" template="VertexAttrib" gltype="GLfloat" vector_size="1" expand_vector="true"/>
- <function name="VertexAttrib2f" external="true" template="VertexAttrib" gltype="GLfloat" vector_size="2" expand_vector="true"/>
- <function name="VertexAttrib3f" external="true" template="VertexAttrib" gltype="GLfloat" vector_size="3" expand_vector="true"/>
- <function name="VertexAttrib4f" external="true" template="VertexAttrib" gltype="GLfloat" vector_size="4" expand_vector="true"/>
- <function name="VertexAttrib1fv" external="true" template="VertexAttrib" gltype="GLfloat" vector_size="1"/>
- <function name="VertexAttrib2fv" external="true" template="VertexAttrib" gltype="GLfloat" vector_size="2"/>
- <function name="VertexAttrib3fv" external="true" template="VertexAttrib" gltype="GLfloat" vector_size="3"/>
- <function name="VertexAttrib4fv" external="true" template="VertexAttrib" gltype="GLfloat" vector_size="4"/>
-
- <function name="VertexAttribPointer" template="VertexAttribPointer"/>
-
- <function name="EnableVertexAttribArray" template="EnableVertexAttribArray"/>
- <function name="DisableVertexAttribArray" template="DisableVertexAttribArray"/>
-
- <function name="IsProgram" template="IsProgram"/>
- <function name="GetProgramiv" template="GetProgram" gltype="GLint"/>
-
- <function name="GetVertexAttribfv" template="GetVertexAttrib" gltype="GLfloat"/>
- <function name="GetVertexAttribiv" template="GetVertexAttrib" gltype="GLint"/>
- <function name="GetVertexAttribPointerv" template="GetVertexAttribPointer"/>
-
- <function name="GetBufferPointervOES" template="GetBufferPointer"/>
- <function name="MapBufferOES" template="MapBuffer"/>
- <function name="UnmapBufferOES" template="UnmapBuffer"/>
- <function name="BindBuffer" template="BindBuffer"/>
- <function name="BufferData" template="BufferData"/>
- <function name="BufferSubData" template="BufferSubData"/>
- <function name="DeleteBuffers" template="DeleteBuffers"/>
- <function name="GenBuffers" template="GenBuffers"/>
- <function name="GetBufferParameteriv" template="GetBufferParameter" gltype="GLint"/>
- <function name="IsBuffer" template="IsBuffer"/>
-
- <function name="CreateShader" template="CreateShader"/>
- <function name="ShaderSource" template="ShaderSource"/>
- <function name="CompileShader" template="CompileShader"/>
- <function name="ReleaseShaderCompiler" template="ReleaseShaderCompiler"/>
- <function name="DeleteShader" template="DeleteShader"/>
- <function name="ShaderBinary" template="ShaderBinary"/>
- <function name="CreateProgram" template="CreateProgram"/>
- <function name="AttachShader" template="AttachShader"/>
- <function name="DetachShader" template="DetachShader"/>
- <function name="LinkProgram" template="LinkProgram"/>
- <function name="UseProgram" template="UseProgram"/>
- <function name="DeleteProgram" template="DeleteProgram"/>
-
- <function name="GetActiveAttrib" template="GetActiveAttrib"/>
- <function name="GetAttribLocation" template="GetAttribLocation"/>
- <function name="BindAttribLocation" template="BindAttribLocation"/>
- <function name="GetUniformLocation" template="GetUniformLocation"/>
- <function name="GetActiveUniform" template="GetActiveUniform"/>
-
- <function name="Uniform1f" template="Uniform" gltype="GLfloat" vector_size="1" expand_vector="true"/>
- <function name="Uniform2f" template="Uniform" gltype="GLfloat" vector_size="2" expand_vector="true"/>
- <function name="Uniform3f" template="Uniform" gltype="GLfloat" vector_size="3" expand_vector="true"/>
- <function name="Uniform4f" template="Uniform" gltype="GLfloat" vector_size="4" expand_vector="true"/>
- <function name="Uniform1i" template="Uniform" gltype="GLint" vector_size="1" expand_vector="true"/>
- <function name="Uniform2i" template="Uniform" gltype="GLint" vector_size="2" expand_vector="true"/>
- <function name="Uniform3i" template="Uniform" gltype="GLint" vector_size="3" expand_vector="true"/>
- <function name="Uniform4i" template="Uniform" gltype="GLint" vector_size="4" expand_vector="true"/>
-
- <function name="Uniform1fv" template="Uniform" gltype="GLfloat" vector_size="1"/>
- <function name="Uniform2fv" template="Uniform" gltype="GLfloat" vector_size="2"/>
- <function name="Uniform3fv" template="Uniform" gltype="GLfloat" vector_size="3"/>
- <function name="Uniform4fv" template="Uniform" gltype="GLfloat" vector_size="4"/>
- <function name="Uniform1iv" template="Uniform" gltype="GLint" vector_size="1"/>
- <function name="Uniform2iv" template="Uniform" gltype="GLint" vector_size="2"/>
- <function name="Uniform3iv" template="Uniform" gltype="GLint" vector_size="3"/>
- <function name="Uniform4iv" template="Uniform" gltype="GLint" vector_size="4"/>
-
- <function name="UniformMatrix2fv" template="UniformMatrix" gltype="GLfloat" vector_size="2"/>
- <function name="UniformMatrix3fv" template="UniformMatrix" gltype="GLfloat" vector_size="3"/>
- <function name="UniformMatrix4fv" template="UniformMatrix" gltype="GLfloat" vector_size="4"/>
-
- <function name="ValidateProgram" template="ValidateProgram"/>
-
- <function name="GenerateMipmap" template="GenerateMipmap"/>
- <function name="BindFramebuffer" template="BindFramebuffer"/>
- <function name="DeleteFramebuffers" template="DeleteFramebuffers"/>
- <function name="GenFramebuffers" template="GenFramebuffers"/>
- <function name="BindRenderbuffer" template="BindRenderbuffer"/>
- <function name="DeleteRenderbuffers" template="DeleteRenderbuffers"/>
- <function name="GenRenderbuffers" template="GenRenderbuffers"/>
- <function name="RenderbufferStorage" external="true" template="RenderbufferStorage"/>
- <function name="FramebufferRenderbuffer" template="FramebufferRenderbuffer"/>
- <function name="FramebufferTexture2D" template="FramebufferTexture2D"/>
- <function name="FramebufferTexture3DOES" template="FramebufferTexture3D"/>
- <function name="CheckFramebufferStatus" template="CheckFramebufferStatus"/>
- <function name="GetFramebufferAttachmentParameteriv" template="GetFramebufferAttachmentParameter" gltype="GLint"/>
- <function name="GetRenderbufferParameteriv" template="GetRenderbufferParameter" gltype="GLint"/>
- <function name="IsRenderbuffer" template="IsRenderbuffer"/>
- <function name="IsFramebuffer" template="IsFramebuffer"/>
-
- <function name="IsShader" template="IsShader"/>
- <function name="GetShaderiv" template="GetShader" gltype="GLint"/>
- <function name="GetAttachedShaders" template="GetAttachedShaders"/>
- <function name="GetShaderInfoLog" template="GetShaderInfoLog"/>
- <function name="GetProgramInfoLog" template="GetProgramInfoLog"/>
- <function name="GetShaderSource" template="GetShaderSource"/>
- <function name="GetShaderPrecisionFormat" template="GetShaderPrecisionFormat"/>
- <function name="GetUniformfv" template="GetUniform" gltype="GLfloat"/>
- <function name="GetUniformiv" template="GetUniform" gltype="GLint"/>
-
- <!-- EXT_multi_draw_arrays -->
- <function name="MultiDrawArraysEXT" template="MultiDrawArrays"/>
- <function name="MultiDrawElementsEXT" template="MultiDrawElements"/>
-
- <!-- OES_EGL_image -->
- <function name="EGLImageTargetTexture2DOES" template="EGLImageTargetTexture2D"/>
- <function name="EGLImageTargetRenderbufferStorageOES" template="EGLImageTargetRenderbufferStorage"/>
-</api>
-
-</apispec>
+<?xml version="1.0"?> +<!DOCTYPE apispec SYSTEM "APIspec.dtd"> + +<!-- A function is generated from a template. Multiple functions can be + generated from a single template with different arguments. For example, + glColor3f can be generated from + + <function name="Color3f" template="Color" gltype="GLfloat" vector_size="3" expand_vector="true"/> + + and glColor4iv can be generated from + + <function name="Color4iv" template="Color" gltype="GLint" vector_size="4"/> + + In a template, there are <desc>s that describe the properties of + parameters. A <desc> can enumerate the valid values of a parameter. It + can also specify the error code when an invalid value is given, and etc. + By nesting <desc>s, they can create dependency between parameters. + + A function can be marked as external. It means that the function cannot + be dispatched to the corresponding mesa function, if one exists, directly, + and requires an external implementation. +--> + +<apispec> + +<template name="Color"> + <proto> + <return type="void"/> + <vector name="v" type="const GLtype *" size="dynamic"> + <param name="red" type="GLtype"/> + <param name="green" type="GLtype"/> + <param name="blue" type="GLtype"/> + <param name="alpha" type="GLtype"/> + </vector> + </proto> +</template> + +<template name="ClipPlane"> + <proto> + <return type="void"/> + <param name="plane" type="GLenum"/> + <vector name="equation" type="const GLtype *" size="4"/> + </proto> + + <desc name="plane"> + <range base="GL_CLIP_PLANE" from="0" to="5"/> + </desc> +</template> + +<template name="CullFace"> + <proto> + <return type="void"/> + <param name="mode" type="GLenum"/> + </proto> + + <desc name="mode"> + <value name="GL_FRONT"/> + <value name="GL_BACK"/> + <value name="GL_FRONT_AND_BACK"/> + </desc> +</template> + +<template name="Fog"> + <proto> + <return type="void"/> + <param name="pname" type="GLenum"/> + <vector name="params" type="const GLtype *" size="dynamic"> + <param name="param" type="GLtype"/> + </vector> + </proto> + + <desc name="pname"> + <value name="GL_FOG_MODE"/> + <desc name="param"> + <value name="GL_EXP"/> + <value name="GL_EXP2"/> + <value name="GL_LINEAR"/> + </desc> + </desc> + + <desc name="pname"> + <value name="GL_FOG_COLOR"/> + + <desc name="params" vector_size="4"/> + </desc> + + <desc name="pname"> + <value name="GL_FOG_DENSITY"/> + <value name="GL_FOG_START"/> + <value name="GL_FOG_END"/> + + <desc name="params" vector_size="1"/> + </desc> +</template> + +<template name="FrontFace"> + <proto> + <return type="void"/> + <param name="mode" type="GLenum"/> + </proto> + + <desc name="mode"> + <value name="GL_CW"/> + <value name="GL_CCW"/> + </desc> +</template> + +<template name="Hint"> + <proto> + <return type="void"/> + <param name="target" type="GLenum"/> + <param name="mode" type="GLenum"/> + </proto> + + <desc name="target" category="GLES1.1"> + <value name="GL_FOG_HINT"/> + <value name="GL_LINE_SMOOTH_HINT"/> + <value name="GL_PERSPECTIVE_CORRECTION_HINT"/> + <value name="GL_POINT_SMOOTH_HINT"/> + </desc> + <desc name="target" category="OES_standard_derivatives"> + <value name="GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES"/> + </desc> + <desc name="target"> + <value name="GL_GENERATE_MIPMAP_HINT"/> + </desc> + + <desc name="mode"> + <value name="GL_FASTEST"/> + <value name="GL_NICEST"/> + <value name="GL_DONT_CARE"/> + </desc> +</template> + +<template name="Light"> + <proto> + <return type="void"/> + <param name="light" type="GLenum"/> + <param name="pname" type="GLenum"/> + <vector name="params" type="const GLtype *" size="dynamic"> + <param name="param" type="GLtype"/> + </vector> + </proto> + + <desc name="light"> + <range base="GL_LIGHT" from="0" to="7"/> + </desc> + + <desc name="pname"> + <value name="GL_AMBIENT"/> + <value name="GL_DIFFUSE"/> + <value name="GL_SPECULAR"/> + <value name="GL_POSITION"/> + + <desc name="params" vector_size="4"/> + </desc> + + <desc name="pname"> + <value name="GL_SPOT_DIRECTION"/> + + <desc name="params" vector_size="3"/> + </desc> + + <desc name="pname"> + <value name="GL_SPOT_EXPONENT"/> + <value name="GL_SPOT_CUTOFF"/> + <value name="GL_CONSTANT_ATTENUATION"/> + <value name="GL_LINEAR_ATTENUATION"/> + <value name="GL_QUADRATIC_ATTENUATION"/> + + <desc name="params" vector_size="1"/> + </desc> +</template> + +<template name="LightModel"> + <proto> + <return type="void"/> + <param name="pname" type="GLenum"/> + <vector name="params" type="const GLtype *" size="dynamic"> + <param name="param" type="GLtype"/> + </vector> + </proto> + + <desc name="pname"> + <value name="GL_LIGHT_MODEL_AMBIENT"/> + + <desc name="params" vector_size="4"/> + </desc> + + <desc name="pname"> + <value name="GL_LIGHT_MODEL_TWO_SIDE"/> + <desc name="param"> + <value name="GL_TRUE"/> + <value name="GL_FALSE"/> + </desc> + </desc> +</template> + +<template name="LineWidth"> + <proto> + <return type="void"/> + <param name="width" type="GLtype"/> + </proto> +</template> + +<template name="Material"> + <proto> + <return type="void"/> + <param name="face" type="GLenum"/> + <param name="pname" type="GLenum"/> + <vector name="params" type="const GLtype *" size="dynamic"> + <param name="param" type="GLtype"/> + </vector> + </proto> + + <desc name="face"> + <value name="GL_FRONT_AND_BACK"/> + </desc> + + <desc name="pname"> + <value name="GL_AMBIENT"/> + <value name="GL_DIFFUSE"/> + <value name="GL_AMBIENT_AND_DIFFUSE"/> + <value name="GL_SPECULAR"/> + <value name="GL_EMISSION"/> + + <desc name="params" vector_size="4"/> + </desc> + + <desc name="pname"> + <value name="GL_SHININESS"/> + + <desc name="params" vector_size="1"/> + </desc> +</template> + +<template name="PointSize"> + <proto> + <return type="void"/> + <param name="size" type="GLtype"/> + </proto> +</template> + +<template name="PointSizePointer"> + <proto> + <return type="void"/> + <param name="type" type="GLenum"/> + <param name="stride" type="GLsizei"/> + <param name="pointer" type="const GLvoid *"/> + </proto> + + <desc name="type"> + <value name="GL_FLOAT"/> + <value name="GL_FIXED"/> + </desc> +</template> + +<template name="Scissor"> + <proto> + <return type="void"/> + <param name="x" type="GLint"/> + <param name="y" type="GLint"/> + <param name="width" type="GLsizei"/> + <param name="height" type="GLsizei"/> + </proto> +</template> + +<template name="ShadeModel"> + <proto> + <return type="void"/> + <param name="mode" type="GLenum"/> + </proto> + + <desc name="mode"> + <value name="GL_FLAT"/> + <value name="GL_SMOOTH"/> + </desc> +</template> + +<template name="TexParameter"> + <proto> + <return type="void"/> + <param name="target" type="GLenum"/> + <param name="pname" type="GLenum"/> + <vector name="params" type="const GLtype *" size="dynamic"> + <param name="param" type="GLtype"/> + </vector> + </proto> + + <desc name="target"> + <value name="GL_TEXTURE_2D"/> + <value name="GL_TEXTURE_CUBE_MAP" category="GLES2.0"/> + <value name="GL_TEXTURE_CUBE_MAP_OES" category="OES_texture_cube_map"/> + <value name="GL_TEXTURE_3D_OES" category="OES_texture_3D"/> + </desc> + + <desc name="pname"> + <value name="GL_TEXTURE_WRAP_S"/> + <value name="GL_TEXTURE_WRAP_T"/> + <value name="GL_TEXTURE_WRAP_R_OES" category="OES_texture_3D"/> + + <desc name="param"> + <value name="GL_CLAMP_TO_EDGE"/> + <value name="GL_REPEAT"/> + <value name="GL_MIRRORED_REPEAT" category="GLES2.0"/> + <value name="GL_MIRRORED_REPEAT_OES" category="OES_texture_mirrored_repeat"/> + </desc> + </desc> + + <desc name="pname"> + <value name="GL_TEXTURE_MIN_FILTER"/> + + <desc name="param"> + <value name="GL_NEAREST"/> + <value name="GL_LINEAR"/> + <value name="GL_NEAREST_MIPMAP_NEAREST"/> + <value name="GL_NEAREST_MIPMAP_LINEAR"/> + <value name="GL_LINEAR_MIPMAP_NEAREST"/> + <value name="GL_LINEAR_MIPMAP_LINEAR"/> + </desc> + </desc> + + <desc name="pname"> + <value name="GL_TEXTURE_MAG_FILTER"/> + + <desc name="param"> + <value name="GL_NEAREST"/> + <value name="GL_LINEAR"/> + </desc> + </desc> + + <desc name="pname" category="GLES1.1"> + <value name="GL_GENERATE_MIPMAP"/> + + <desc name="param"> + <value name="GL_TRUE"/> + <value name="GL_FALSE"/> + </desc> + </desc> + + <desc name="pname" category="EXT_texture_filter_anisotropic"> + <value name="GL_TEXTURE_MAX_ANISOTROPY_EXT"/> + <desc name="params" vector_size="1"/> + </desc> + + <desc name="pname" category="OES_draw_texture"> + <value name="GL_TEXTURE_CROP_RECT_OES"/> + <desc name="params" vector_size="4"/> + </desc> +</template> + +<template name="TexImage2D"> + <proto> + <return type="void"/> + <param name="target" type="GLenum"/> + <param name="level" type="GLint"/> + <param name="internalFormat" type="GLint"/> <!-- should be GLenum --> + <param name="width" type="GLsizei"/> + <param name="height" type="GLsizei"/> + <param name="border" type="GLint"/> + <param name="format" type="GLenum"/> + <param name="type" type="GLenum"/> + <param name="pixels" type="const GLvoid *"/> + </proto> + + <desc name="target"> + <value name="GL_TEXTURE_2D"/> + <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_X" category="GLES2.0"/> + <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Y" category="GLES2.0"/> + <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Z" category="GLES2.0"/> + <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_X" category="GLES2.0"/> + <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Y" category="GLES2.0"/> + <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Z" category="GLES2.0"/> + <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_X_OES" category="OES_texture_cube_map"/> + <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Y_OES" category="OES_texture_cube_map"/> + <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Z_OES" category="OES_texture_cube_map"/> + <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_X_OES" category="OES_texture_cube_map"/> + <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_OES" category="OES_texture_cube_map"/> + <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_OES" category="OES_texture_cube_map"/> + </desc> + + <desc name="internalFormat"> + <value name="GL_ALPHA"/> + + <desc name="format" error="GL_INVALID_VALUE"> + <value name="GL_ALPHA"/> + </desc> + </desc> + + <desc name="internalFormat"> + <value name="GL_RGB"/> + + <desc name="format" error="GL_INVALID_VALUE"> + <value name="GL_RGB"/> + </desc> + </desc> + + <desc name="internalFormat"> + <value name="GL_RGBA"/> + + <desc name="format" error="GL_INVALID_VALUE"> + <value name="GL_RGBA"/> + </desc> + </desc> + + <desc name="internalFormat"> + <value name="GL_LUMINANCE"/> + + <desc name="format" error="GL_INVALID_VALUE"> + <value name="GL_LUMINANCE"/> + </desc> + </desc> + + <desc name="internalFormat"> + <value name="GL_LUMINANCE_ALPHA"/> + + <desc name="format" error="GL_INVALID_VALUE"> + <value name="GL_LUMINANCE_ALPHA"/> + </desc> + </desc> + + <desc name="internalFormat" category="OES_depth_texture"> + <value name="GL_DEPTH_COMPONENT"/> + + <desc name="format" error="GL_INVALID_VALUE"> + <value name="GL_DEPTH_COMPONENT"/> + </desc> + </desc> + + <desc name="internalFormat" category="OES_packed_depth_stencil"> + <value name="GL_DEPTH_STENCIL_OES"/> + + <desc name="format" error="GL_INVALID_VALUE"> + <value name="GL_DEPTH_STENCIL_OES"/> + </desc> + </desc> + + <desc name="internalFormat" category="EXT_texture_format_BGRA8888"> + <value name="GL_BGRA_EXT"/> + + <desc name="format" error="GL_INVALID_VALUE"> + <value name="GL_BGRA_EXT"/> + </desc> + </desc> + + <desc name="border" error="GL_INVALID_VALUE"> + <value name="0"/> + </desc> + + <desc name="format"> + <value name="GL_ALPHA"/> + + <desc name="type" error="GL_INVALID_OPERATION"> + <value name="GL_UNSIGNED_BYTE"/> + <value name="GL_FLOAT" category="OES_texture_float"/> + <value name="GL_HALF_FLOAT_OES" category="OES_texture_half_float"/> + </desc> + </desc> + + <desc name="format"> + <value name="GL_RGB"/> + + <desc name="type" error="GL_INVALID_OPERATION"> + <value name="GL_UNSIGNED_BYTE"/> + <value name="GL_UNSIGNED_SHORT_5_6_5"/> + <value name="GL_FLOAT" category="OES_texture_float"/> + <value name="GL_HALF_FLOAT_OES" category="OES_texture_half_float"/> + </desc> + </desc> + + <desc name="format"> + <value name="GL_RGBA"/> + + <desc name="type" error="GL_INVALID_OPERATION"> + <value name="GL_UNSIGNED_BYTE"/> + <value name="GL_UNSIGNED_SHORT_4_4_4_4"/> + <value name="GL_UNSIGNED_SHORT_5_5_5_1"/> + <value name="GL_FLOAT" category="OES_texture_float"/> + <value name="GL_HALF_FLOAT_OES" category="OES_texture_half_float"/> + <value name="GL_UNSIGNED_INT_2_10_10_10_REV_EXT" category="EXT_texture_type_2_10_10_10_REV"/> + </desc> + </desc> + + <desc name="format"> + <value name="GL_LUMINANCE"/> + + <desc name="type" error="GL_INVALID_OPERATION"> + <value name="GL_UNSIGNED_BYTE"/> + <value name="GL_FLOAT" category="OES_texture_float"/> + <value name="GL_HALF_FLOAT_OES" category="OES_texture_half_float"/> + </desc> + </desc> + + <desc name="format"> + <value name="GL_LUMINANCE_ALPHA"/> + + <desc name="type" error="GL_INVALID_OPERATION"> + <value name="GL_UNSIGNED_BYTE"/> + <value name="GL_FLOAT" category="OES_texture_float"/> + <value name="GL_HALF_FLOAT_OES" category="OES_texture_half_float"/> + </desc> + </desc> + + <desc name="format" category="OES_depth_texture"> + <value name="GL_DEPTH_COMPONENT"/> + + <desc name="type" error="GL_INVALID_OPERATION"> + <value name="GL_UNSIGNED_SHORT"/> + <value name="GL_UNSIGNED_INT"/> + </desc> + </desc> + + <desc name="format" category="OES_packed_depth_stencil"> + <value name="GL_DEPTH_STENCIL_OES"/> + <desc name="type" error="GL_INVALID_OPERATION"> + <value name="GL_UNSIGNED_INT_24_8_OES"/> + </desc> + </desc> + + <desc name="format" category="EXT_texture_format_BGRA8888"> + <value name="GL_BGRA_EXT"/> + + <desc name="type" error="GL_INVALID_OPERATION"> + <value name="GL_UNSIGNED_BYTE"/> + </desc> + </desc> +</template> + +<template name="TexEnv"> + <proto> + <return type="void"/> + <param name="target" type="GLenum"/> + <param name="pname" type="GLenum"/> + <vector name="params" type="const GLtype *" size="dynamic"> + <param name="param" type="GLtype"/> + </vector> + </proto> + + <desc name="target" category="OES_point_sprite"> + <value name="GL_POINT_SPRITE_OES"/> + + <desc name="pname"> + <value name="GL_COORD_REPLACE_OES"/> + </desc> + </desc> + + <desc name="pname" category="OES_point_sprite"> + <value name="GL_COORD_REPLACE_OES"/> + + <desc name="param"> + <value name="GL_TRUE"/> + <value name="GL_FALSE"/> + </desc> + </desc> + + <desc name="target" category="EXT_texture_lod_bias"> + <value name="GL_TEXTURE_FILTER_CONTROL_EXT"/> + + <desc name="pname"> + <value name="GL_TEXTURE_LOD_BIAS_EXT"/> + </desc> + </desc> + + <desc name="pname" category="EXT_texture_lod_bias"> + <value name="GL_TEXTURE_LOD_BIAS_EXT"/> + <desc name="params" vector_size="1"/> + </desc> + + <desc name="target"> + <value name="GL_TEXTURE_ENV"/> + + <desc name="pname"> + <value name="GL_TEXTURE_ENV_MODE"/> + <value name="GL_COMBINE_RGB"/> + <value name="GL_COMBINE_ALPHA"/> + <value name="GL_RGB_SCALE"/> + <value name="GL_ALPHA_SCALE"/> + <value name="GL_SRC0_RGB"/> + <value name="GL_SRC1_RGB"/> + <value name="GL_SRC2_RGB"/> + <value name="GL_SRC0_ALPHA"/> + <value name="GL_SRC1_ALPHA"/> + <value name="GL_SRC2_ALPHA"/> + <value name="GL_OPERAND0_RGB"/> + <value name="GL_OPERAND1_RGB"/> + <value name="GL_OPERAND2_RGB"/> + <value name="GL_OPERAND0_ALPHA"/> + <value name="GL_OPERAND1_ALPHA"/> + <value name="GL_OPERAND2_ALPHA"/> + <value name="GL_TEXTURE_ENV_COLOR"/> + </desc> + </desc> + + <desc name="pname"> + <value name="GL_TEXTURE_ENV_MODE"/> + + <desc name="param"> + <value name="GL_REPLACE"/> + <value name="GL_MODULATE"/> + <value name="GL_DECAL"/> + <value name="GL_BLEND"/> + <value name="GL_ADD"/> + <value name="GL_COMBINE"/> + </desc> + </desc> + + <desc name="pname"> + <value name="GL_COMBINE_RGB"/> + + <desc name="param"> + <value name="GL_REPLACE"/> + <value name="GL_MODULATE"/> + <value name="GL_ADD"/> + <value name="GL_ADD_SIGNED"/> + <value name="GL_INTERPOLATE"/> + <value name="GL_SUBTRACT"/> + <value name="GL_DOT3_RGB"/> + <value name="GL_DOT3_RGBA"/> + </desc> + </desc> + + <desc name="pname"> + <value name="GL_COMBINE_ALPHA"/> + + <desc name="param"> + <value name="GL_REPLACE"/> + <value name="GL_MODULATE"/> + <value name="GL_ADD"/> + <value name="GL_ADD_SIGNED"/> + <value name="GL_INTERPOLATE"/> + <value name="GL_SUBTRACT"/> + </desc> + </desc> + + <desc name="pname"> + <value name="GL_RGB_SCALE"/> + <value name="GL_ALPHA_SCALE"/> + + <desc name="param" convert="true" error="GL_INVALID_VALUE"> + <value name="1.0"/> + <value name="2.0"/> + <value name="4.0"/> + </desc> + </desc> + + <desc name="pname"> + <value name="GL_SRC0_RGB"/> + <value name="GL_SRC1_RGB"/> + <value name="GL_SRC2_RGB"/> + <value name="GL_SRC0_ALPHA"/> + <value name="GL_SRC1_ALPHA"/> + <value name="GL_SRC2_ALPHA"/> + + <desc name="param"> + <value name="GL_TEXTURE"/> + <value name="GL_CONSTANT"/> + <value name="GL_PRIMARY_COLOR"/> + <value name="GL_PREVIOUS"/> + + <range base="GL_TEXTURE" from="0" to="31" category="OES_texture_env_crossbar"/> + </desc> + </desc> + + <desc name="pname"> + <value name="GL_OPERAND0_RGB"/> + <value name="GL_OPERAND1_RGB"/> + <value name="GL_OPERAND2_RGB"/> + + <desc name="param"> + <value name="GL_SRC_COLOR"/> + <value name="GL_ONE_MINUS_SRC_COLOR"/> + <value name="GL_SRC_ALPHA"/> + <value name="GL_ONE_MINUS_SRC_ALPHA"/> + </desc> + </desc> + + <desc name="pname"> + <value name="GL_OPERAND0_ALPHA"/> + <value name="GL_OPERAND1_ALPHA"/> + <value name="GL_OPERAND2_ALPHA"/> + + <desc name="param"> + <value name="GL_SRC_ALPHA"/> + <value name="GL_ONE_MINUS_SRC_ALPHA"/> + </desc> + </desc> + + <desc name="pname"> + <value name="GL_TEXTURE_ENV_COLOR"/> + + <desc name="params" vector_size="4"/> + </desc> +</template> + +<template name="TexGen"> + <proto> + <return type="void"/> + <param name="coord" type="GLenum"/> + <param name="pname" type="GLenum"/> + <vector name="params" type="const GLtype *" size="dynamic"> + <param name="param" type="GLtype"/> + </vector> + </proto> + + <desc name="coord" category="OES_texture_cube_map"> + <value name="GL_TEXTURE_GEN_STR_OES"/> + </desc> + + <desc name="pname" category="OES_texture_cube_map"> + <value name="GL_TEXTURE_GEN_MODE_OES"/> + + <desc name="param"> + <value name="GL_NORMAL_MAP_OES"/> + <value name="GL_REFLECTION_MAP_OES"/> + </desc> + </desc> +</template> + +<template name="Clear"> + <proto> + <return type="void"/> + <param name="mask" type="GLbitfield"/> + </proto> + + <desc name="mask" error="GL_INVALID_VALUE"> + <value name="0"/> + <value name="(GL_COLOR_BUFFER_BIT)"/> + <value name="(GL_DEPTH_BUFFER_BIT)"/> + <value name="(GL_STENCIL_BUFFER_BIT)"/> + <value name="(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT)"/> + <value name="(GL_COLOR_BUFFER_BIT|GL_STENCIL_BUFFER_BIT)"/> + <value name="(GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT)"/> + <value name="(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT)"/> + </desc> +</template> + +<template name="ClearColor"> + <proto> + <return type="void"/> + <param name="red" type="GLtype"/> + <param name="green" type="GLtype"/> + <param name="blue" type="GLtype"/> + <param name="alpha" type="GLtype"/> + </proto> +</template> + +<template name="ClearStencil"> + <proto> + <return type="void"/> + <param name="s" type="GLint"/> + </proto> +</template> + +<template name="ClearDepth"> + <proto> + <return type="void"/> + <param name="depth" type="GLtype"/> + </proto> +</template> + +<template name="StencilMask"> + <proto> + <return type="void"/> + <param name="mask" type="GLuint"/> + </proto> +</template> + +<template name="StencilMaskSeparate"> + <proto> + <return type="void"/> + <param name="face" type="GLenum"/> + <param name="mask" type="GLuint"/> + </proto> + + <desc name="face"> + <value name="GL_FRONT"/> + <value name="GL_BACK"/> + <value name="GL_FRONT_AND_BACK"/> + </desc> +</template> + +<template name="ColorMask"> + <proto> + <return type="void"/> + <param name="red" type="GLboolean"/> + <param name="green" type="GLboolean"/> + <param name="blue" type="GLboolean"/> + <param name="alpha" type="GLboolean"/> + </proto> +</template> + +<template name="DepthMask"> + <proto> + <return type="void"/> + <param name="flag" type="GLboolean"/> + </proto> +</template> + +<template name="Disable"> + <proto> + <return type="void"/> + <param name="cap" type="GLenum"/> + </proto> + + <desc name="cap" category="GLES1.1"> + <value name="GL_NORMALIZE"/> + <value name="GL_RESCALE_NORMAL"/> + + <range base="GL_CLIP_PLANE" from="0" to="5"/> + + <value name="GL_FOG"/> + <value name="GL_LIGHTING"/> + <value name="GL_COLOR_MATERIAL"/> + + <range base="GL_LIGHT" from="0" to="7"/> + + <value name="GL_POINT_SMOOTH"/> + <value name="GL_LINE_SMOOTH"/> + <value name="GL_CULL_FACE"/> + <value name="GL_POLYGON_OFFSET_FILL"/> + <value name="GL_MULTISAMPLE"/> + <value name="GL_SAMPLE_ALPHA_TO_COVERAGE"/> + <value name="GL_SAMPLE_ALPHA_TO_ONE"/> + <value name="GL_SAMPLE_COVERAGE"/> + <value name="GL_TEXTURE_2D"/> + <value name="GL_SCISSOR_TEST"/> + <value name="GL_ALPHA_TEST"/> + <value name="GL_STENCIL_TEST"/> + <value name="GL_DEPTH_TEST"/> + <value name="GL_BLEND"/> + <value name="GL_DITHER"/> + <value name="GL_COLOR_LOGIC_OP"/> + + <value name="GL_POINT_SPRITE_OES" category="OES_point_sprite"/> + <value name="GL_MATRIX_PALETTE_OES" category="OES_matrix_palette"/> + <value name="GL_TEXTURE_CUBE_MAP_OES" category="OES_texture_cube_map"/> + <value name="GL_TEXTURE_GEN_STR_OES" category="OES_texture_cube_map"/> + </desc> + + <desc name="cap" category="GLES2.0"> + <value name="GL_CULL_FACE"/> + <value name="GL_SCISSOR_TEST"/> + <value name="GL_POLYGON_OFFSET_FILL"/> + <value name="GL_SAMPLE_ALPHA_TO_COVERAGE"/> + <value name="GL_SAMPLE_COVERAGE"/> + <value name="GL_STENCIL_TEST"/> + <value name="GL_DEPTH_TEST"/> + <value name="GL_DITHER"/> + <value name="GL_BLEND"/> + </desc> +</template> + +<!-- it is exactly the same as Disable --> +<template name="Enable"> + <proto> + <return type="void"/> + <param name="cap" type="GLenum"/> + </proto> + + <desc name="cap" category="GLES1.1"> + <value name="GL_NORMALIZE"/> + <value name="GL_RESCALE_NORMAL"/> + + <range base="GL_CLIP_PLANE" from="0" to="5"/> + + <value name="GL_FOG"/> + <value name="GL_LIGHTING"/> + <value name="GL_COLOR_MATERIAL"/> + + <range base="GL_LIGHT" from="0" to="7"/> + + <value name="GL_POINT_SMOOTH"/> + <value name="GL_LINE_SMOOTH"/> + <value name="GL_CULL_FACE"/> + <value name="GL_POLYGON_OFFSET_FILL"/> + <value name="GL_MULTISAMPLE"/> + <value name="GL_SAMPLE_ALPHA_TO_COVERAGE"/> + <value name="GL_SAMPLE_ALPHA_TO_ONE"/> + <value name="GL_SAMPLE_COVERAGE"/> + <value name="GL_TEXTURE_2D"/> + <value name="GL_SCISSOR_TEST"/> + <value name="GL_ALPHA_TEST"/> + <value name="GL_STENCIL_TEST"/> + <value name="GL_DEPTH_TEST"/> + <value name="GL_BLEND"/> + <value name="GL_DITHER"/> + <value name="GL_COLOR_LOGIC_OP"/> + + <value name="GL_POINT_SPRITE_OES" category="OES_point_sprite"/> + <value name="GL_MATRIX_PALETTE_OES" category="OES_matrix_palette"/> + <value name="GL_TEXTURE_CUBE_MAP_OES" category="OES_texture_cube_map"/> + <value name="GL_TEXTURE_GEN_STR_OES" category="OES_texture_cube_map"/> + </desc> + + <desc name="cap" category="GLES2.0"> + <value name="GL_CULL_FACE"/> + <value name="GL_SCISSOR_TEST"/> + <value name="GL_POLYGON_OFFSET_FILL"/> + <value name="GL_SAMPLE_ALPHA_TO_COVERAGE"/> + <value name="GL_SAMPLE_COVERAGE"/> + <value name="GL_STENCIL_TEST"/> + <value name="GL_DEPTH_TEST"/> + <value name="GL_DITHER"/> + <value name="GL_BLEND"/> + </desc> +</template> + +<template name="Finish"> + <proto> + <return type="void"/> + </proto> +</template> + +<template name="Flush"> + <proto> + <return type="void"/> + </proto> +</template> + +<template name="AlphaFunc"> + <proto> + <return type="void"/> + <param name="func" type="GLenum"/> + <param name="ref" type="GLtype"/> + </proto> + <desc name="func"> + <value name="GL_NEVER"/> + <value name="GL_LESS"/> + <value name="GL_EQUAL"/> + <value name="GL_LEQUAL"/> + <value name="GL_GREATER"/> + <value name="GL_NOTEQUAL"/> + <value name="GL_GEQUAL"/> + <value name="GL_ALWAYS"/> + </desc> +</template> + +<template name="BlendFunc"> + <proto> + <return type="void"/> + <param name="sfactor" type="GLenum"/> + <param name="dfactor" type="GLenum"/> + </proto> + + <desc name="sfactor"> + <value name="GL_ZERO"/> + <value name="GL_ONE"/> + <value name="GL_SRC_COLOR"/> + <value name="GL_ONE_MINUS_SRC_COLOR"/> + <value name="GL_SRC_ALPHA"/> + <value name="GL_ONE_MINUS_SRC_ALPHA"/> + <value name="GL_DST_ALPHA"/> + <value name="GL_ONE_MINUS_DST_ALPHA"/> + <value name="GL_DST_COLOR"/> + <value name="GL_ONE_MINUS_DST_COLOR"/> + <value name="GL_SRC_ALPHA_SATURATE"/> + + <value name="GL_CONSTANT_COLOR" category="GLES2.0"/> + <value name="GL_CONSTANT_ALPHA" category="GLES2.0"/> + <value name="GL_ONE_MINUS_CONSTANT_COLOR" category="GLES2.0"/> + <value name="GL_ONE_MINUS_CONSTANT_ALPHA" category="GLES2.0"/> + </desc> + + <desc name="dfactor"> + <value name="GL_ZERO"/> + <value name="GL_ONE"/> + <value name="GL_SRC_COLOR"/> + <value name="GL_ONE_MINUS_SRC_COLOR"/> + <value name="GL_SRC_ALPHA"/> + <value name="GL_ONE_MINUS_SRC_ALPHA"/> + <value name="GL_DST_ALPHA"/> + <value name="GL_ONE_MINUS_DST_ALPHA"/> + <value name="GL_DST_COLOR"/> + <value name="GL_ONE_MINUS_DST_COLOR"/> + + <value name="GL_CONSTANT_COLOR" category="GLES2.0"/> + <value name="GL_CONSTANT_ALPHA" category="GLES2.0"/> + <value name="GL_ONE_MINUS_CONSTANT_COLOR" category="GLES2.0"/> + <value name="GL_ONE_MINUS_CONSTANT_ALPHA" category="GLES2.0"/> + </desc> +</template> + +<template name="LogicOp"> + <proto> + <return type="void"/> + <param name="opcode" type="GLenum"/> + </proto> + + <desc name="opcode"> + <value name="GL_CLEAR"/> + <value name="GL_SET"/> + <value name="GL_COPY"/> + <value name="GL_COPY_INVERTED"/> + <value name="GL_NOOP"/> + <value name="GL_INVERT"/> + <value name="GL_AND"/> + <value name="GL_NAND"/> + <value name="GL_OR"/> + <value name="GL_NOR"/> + <value name="GL_XOR"/> + <value name="GL_EQUIV"/> + <value name="GL_AND_REVERSE"/> + <value name="GL_AND_INVERTED"/> + <value name="GL_OR_REVERSE"/> + <value name="GL_OR_INVERTED"/> + </desc> +</template> + +<template name="StencilFunc"> + <proto> + <return type="void"/> + <param name="func" type="GLenum"/> + <param name="ref" type="GLint"/> + <param name="mask" type="GLuint"/> + </proto> + + <desc name="func"> + <value name="GL_NEVER"/> + <value name="GL_LESS"/> + <value name="GL_LEQUAL"/> + <value name="GL_GREATER"/> + <value name="GL_GEQUAL"/> + <value name="GL_EQUAL"/> + <value name="GL_NOTEQUAL"/> + <value name="GL_ALWAYS"/> + </desc> +</template> + +<template name="StencilFuncSeparate"> + <proto> + <return type="void"/> + <param name="face" type="GLenum"/> + <param name="func" type="GLenum"/> + <param name="ref" type="GLint"/> + <param name="mask" type="GLuint"/> + </proto> + + <desc name="face"> + <value name="GL_FRONT"/> + <value name="GL_BACK"/> + <value name="GL_FRONT_AND_BACK"/> + </desc> + + <desc name="func"> + <value name="GL_NEVER"/> + <value name="GL_LESS"/> + <value name="GL_LEQUAL"/> + <value name="GL_GREATER"/> + <value name="GL_GEQUAL"/> + <value name="GL_EQUAL"/> + <value name="GL_NOTEQUAL"/> + <value name="GL_ALWAYS"/> + </desc> +</template> + +<template name="StencilOp"> + <proto> + <return type="void"/> + <param name="fail" type="GLenum"/> + <param name="zfail" type="GLenum"/> + <param name="zpass" type="GLenum"/> + </proto> + + <desc name="fail"> + <value name="GL_KEEP"/> + <value name="GL_ZERO"/> + <value name="GL_REPLACE"/> + <value name="GL_INCR"/> + <value name="GL_DECR"/> + <value name="GL_INVERT"/> + <value name="GL_INCR_WRAP" category="GLES2.0"/> + <value name="GL_DECR_WRAP" category="GLES2.0"/> + <value name="GL_INCR_WRAP_OES" category="OES_stencil_wrap"/> + <value name="GL_DECR_WRAP_OES" category="OES_stencil_wrap"/> + </desc> + + <desc name="zfail"> + <value name="GL_KEEP"/> + <value name="GL_ZERO"/> + <value name="GL_REPLACE"/> + <value name="GL_INCR"/> + <value name="GL_DECR"/> + <value name="GL_INVERT"/> + <value name="GL_INCR_WRAP" category="GLES2.0"/> + <value name="GL_DECR_WRAP" category="GLES2.0"/> + <value name="GL_INCR_WRAP_OES" category="OES_stencil_wrap"/> + <value name="GL_DECR_WRAP_OES" category="OES_stencil_wrap"/> + </desc> + + <desc name="zpass"> + <value name="GL_KEEP"/> + <value name="GL_ZERO"/> + <value name="GL_REPLACE"/> + <value name="GL_INCR"/> + <value name="GL_DECR"/> + <value name="GL_INVERT"/> + <value name="GL_INCR_WRAP" category="GLES2.0"/> + <value name="GL_DECR_WRAP" category="GLES2.0"/> + <value name="GL_INCR_WRAP_OES" category="OES_stencil_wrap"/> + <value name="GL_DECR_WRAP_OES" category="OES_stencil_wrap"/> + </desc> +</template> + +<template name="StencilOpSeparate"> + <proto> + <return type="void"/> + <param name="face" type="GLenum"/> + <param name="fail" type="GLenum"/> + <param name="zfail" type="GLenum"/> + <param name="zpass" type="GLenum"/> + </proto> + + <desc name="face"> + <value name="GL_FRONT"/> + <value name="GL_BACK"/> + <value name="GL_FRONT_AND_BACK"/> + </desc> + + <desc name="fail"> + <value name="GL_KEEP"/> + <value name="GL_ZERO"/> + <value name="GL_REPLACE"/> + <value name="GL_INCR"/> + <value name="GL_DECR"/> + <value name="GL_INVERT"/> + <value name="GL_INCR_WRAP"/> + <value name="GL_DECR_WRAP"/> + </desc> + + <desc name="zfail"> + <value name="GL_KEEP"/> + <value name="GL_ZERO"/> + <value name="GL_REPLACE"/> + <value name="GL_INCR"/> + <value name="GL_DECR"/> + <value name="GL_INVERT"/> + <value name="GL_INCR_WRAP"/> + <value name="GL_DECR_WRAP"/> + </desc> + + <desc name="zpass"> + <value name="GL_KEEP"/> + <value name="GL_ZERO"/> + <value name="GL_REPLACE"/> + <value name="GL_INCR"/> + <value name="GL_DECR"/> + <value name="GL_INVERT"/> + <value name="GL_INCR_WRAP"/> + <value name="GL_DECR_WRAP"/> + </desc> +</template> + +<template name="DepthFunc"> + <proto> + <return type="void"/> + <param name="func" type="GLenum"/> + </proto> + + <desc name="func"> + <value name="GL_NEVER"/> + <value name="GL_LESS"/> + <value name="GL_EQUAL"/> + <value name="GL_LEQUAL"/> + <value name="GL_GREATER"/> + <value name="GL_NOTEQUAL"/> + <value name="GL_GEQUAL"/> + <value name="GL_ALWAYS"/> + </desc> +</template> + +<template name="PixelStore"> + <proto> + <return type="void"/> + <param name="pname" type="GLenum"/> + <param name="param" type="GLtype"/> + </proto> + + <desc name="pname"> + <value name="GL_PACK_ALIGNMENT"/> + <value name="GL_UNPACK_ALIGNMENT"/> + </desc> + + <desc name="param" error="GL_INVALID_VALUE"> + <value name="1"/> + <value name="2"/> + <value name="4"/> + <value name="8"/> + </desc> +</template> + +<template name="ReadPixels" direction="get"> + <proto> + <return type="void"/> + <param name="x" type="GLint"/> + <param name="y" type="GLint"/> + <param name="width" type="GLsizei"/> + <param name="height" type="GLsizei"/> + <param name="format" type="GLenum"/> + <param name="type" type="GLenum"/> + <param name="pixels" type="GLvoid *"/> + </proto> + + <!-- Technically, only two combinations are actually allowed: + GL_RGBA/GL_UNSIGNED_BYTE, and some implementation-specific + internal preferred combination. I don't know what that is, so I'm + allowing any valid combination for now; the underlying support + should fail when necessary.--> + <desc name="format"> + <value name="GL_ALPHA"/> + <desc name="type" error="GL_INVALID_OPERATION"> + <value name="GL_UNSIGNED_BYTE"/> + </desc> + </desc> + + <desc name="format"> + <value name="GL_RGB"/> + <desc name="type" error="GL_INVALID_OPERATION"> + <value name="GL_UNSIGNED_BYTE"/> + <value name="GL_UNSIGNED_SHORT_5_6_5"/> + </desc> + </desc> + + <desc name="format"> + <value name="GL_RGBA"/> + <desc name="type" error="GL_INVALID_OPERATION"> + <value name="GL_UNSIGNED_BYTE"/> + <value name="GL_UNSIGNED_SHORT_4_4_4_4"/> + <value name="GL_UNSIGNED_SHORT_5_5_5_1"/> + </desc> + </desc> + + <desc name="format"> + <value name="GL_LUMINANCE"/> + <desc name="type" error="GL_INVALID_OPERATION"> + <value name="GL_UNSIGNED_BYTE"/> + </desc> + </desc> + + <desc name="format"> + <value name="GL_LUMINANCE_ALPHA"/> + <desc name="type" error="GL_INVALID_OPERATION"> + <value name="GL_UNSIGNED_BYTE"/> + </desc> + </desc> + + <desc name="format" category="EXT_read_format_bgra"> + <value name="GL_BGRA_EXT"/> + + <desc name="type" error="GL_INVALID_OPERATION"> + <value name="GL_UNSIGNED_BYTE"/> + <value name="GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT"/> + <value name="GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT"/> + </desc> + </desc> +</template> + +<template name="GetClipPlane" direction="get"> + <proto> + <return type="void"/> + <param name="plane" type="GLenum"/> + <vector name="equation" type="GLtype *" size="4"/> + </proto> + + <desc name="plane"> + <range base="GL_CLIP_PLANE" from="0" to="5"/> + </desc> +</template> + +<template name="GetError" direction="get"> + <proto> + <return type="GLenum"/> + </proto> +</template> + +<!-- template for GetFloatv, GetIntegerv, GetBoolean, and GetFixedv --> +<template name="GetState" direction="get"> + <proto> + <return type="void"/> + <param name="pname" type="GLenum"/> + <vector name="params" type="GLtype *" size="dynamic"/> + </proto> + <!-- param checking is done in mesa --> +</template> + +<template name="GetLight" direction="get"> + <proto> + <return type="void"/> + <param name="light" type="GLenum"/> + <param name="pname" type="GLenum"/> + <vector name="params" type="GLtype *" size="dynamic"/> + </proto> + + <desc name="light"> + <range base="GL_LIGHT" from="0" to="7"/> + </desc> + + <desc name="pname"> + <value name="GL_AMBIENT"/> + <value name="GL_DIFFUSE"/> + <value name="GL_SPECULAR"/> + <value name="GL_POSITION"/> + + <desc name="params" vector_size="4"/> + </desc> + + <desc name="pname"> + <value name="GL_SPOT_DIRECTION"/> + + <desc name="params" vector_size="3"/> + </desc> + + <desc name="pname"> + <value name="GL_SPOT_EXPONENT"/> + <value name="GL_SPOT_CUTOFF"/> + <value name="GL_CONSTANT_ATTENUATION"/> + <value name="GL_LINEAR_ATTENUATION"/> + <value name="GL_QUADRATIC_ATTENUATION"/> + + <desc name="params" vector_size="1"/> + </desc> +</template> + +<template name="GetMaterial" direction="get"> + <proto> + <return type="void"/> + <param name="face" type="GLenum"/> + <param name="pname" type="GLenum"/> + <vector name="params" type="GLtype *" size="dynamic"> + <param name="param" type="GLtype"/> + </vector> + </proto> + + <desc name="face"> + <value name="GL_FRONT"/> + <value name="GL_BACK"/> + </desc> + + <desc name="pname"> + <value name="GL_SHININESS"/> + <desc name="params" vector_size="1"/> + </desc> + + <desc name="pname"> + <value name="GL_AMBIENT"/> + <value name="GL_DIFFUSE"/> + <value name="GL_AMBIENT_AND_DIFFUSE"/> + <value name="GL_SPECULAR"/> + <value name="GL_EMISSION"/> + + <desc name="params" vector_size="4"/> + </desc> +</template> + +<template name="GetString" direction="get"> + <proto> + <return type="const GLubyte *"/> + <param name="name" type="GLenum"/> + </proto> + + <desc name="name"> + <value name="GL_VENDOR"/> + <value name="GL_RENDERER"/> + <value name="GL_VERSION"/> + <value name="GL_EXTENSIONS"/> + <value name="GL_SHADING_LANGUAGE_VERSION" category="GLES2.0"/> + </desc> +</template> + +<template name="GetTexEnv" direction="get"> + <proto> + <return type="void"/> + <param name="target" type="GLenum"/> + <param name="pname" type="GLenum"/> + <vector name="params" type="GLtype *" size="dynamic"/> + </proto> + + <desc name="target" category="OES_point_sprite"> + <value name="GL_POINT_SPRITE_OES"/> + <desc name="pname"> + <value name="GL_COORD_REPLACE_OES"/> + </desc> + </desc> + + <desc name="pname" category="OES_point_sprite"> + <value name="GL_COORD_REPLACE_OES"/> + <desc name="params" vector_size="1" convert="false"/> + </desc> + + <desc name="target" category="EXT_texture_lod_bias"> + <value name="GL_TEXTURE_FILTER_CONTROL_EXT"/> + + <desc name="pname"> + <value name="GL_TEXTURE_LOD_BIAS_EXT"/> + </desc> + </desc> + + <desc name="pname" category="EXT_texture_lod_bias"> + <value name="GL_TEXTURE_LOD_BIAS_EXT"/> + <desc name="params" vector_size="1"/> + </desc> + + <desc name="target"> + <value name="GL_TEXTURE_ENV"/> + + <desc name="pname"> + <value name="GL_TEXTURE_ENV_COLOR"/> + <value name="GL_RGB_SCALE"/> + <value name="GL_ALPHA_SCALE"/> + <value name="GL_TEXTURE_ENV_MODE"/> + <value name="GL_COMBINE_RGB"/> + <value name="GL_COMBINE_ALPHA"/> + <value name="GL_SRC0_RGB"/> + <value name="GL_SRC1_RGB"/> + <value name="GL_SRC2_RGB"/> + <value name="GL_SRC0_ALPHA"/> + <value name="GL_SRC1_ALPHA"/> + <value name="GL_SRC2_ALPHA"/> + <value name="GL_OPERAND0_RGB"/> + <value name="GL_OPERAND1_RGB"/> + <value name="GL_OPERAND2_RGB"/> + <value name="GL_OPERAND0_ALPHA"/> + <value name="GL_OPERAND1_ALPHA"/> + <value name="GL_OPERAND2_ALPHA"/> + </desc> + </desc> + + <desc name="pname"> + <value name="GL_TEXTURE_ENV_COLOR"/> + <desc name="params" vector_size="4"/> + </desc> + + <desc name="pname"> + <value name="GL_RGB_SCALE"/> + <value name="GL_ALPHA_SCALE"/> + + <desc name="params" vector_size="1"/> + </desc> + + <desc name="pname"> + <value name="GL_TEXTURE_ENV_MODE"/> + <value name="GL_COMBINE_RGB"/> + <value name="GL_COMBINE_ALPHA"/> + <value name="GL_SRC0_RGB"/> + <value name="GL_SRC1_RGB"/> + <value name="GL_SRC2_RGB"/> + <value name="GL_SRC0_ALPHA"/> + <value name="GL_SRC1_ALPHA"/> + <value name="GL_SRC2_ALPHA"/> + <value name="GL_OPERAND0_RGB"/> + <value name="GL_OPERAND1_RGB"/> + <value name="GL_OPERAND2_RGB"/> + <value name="GL_OPERAND0_ALPHA"/> + <value name="GL_OPERAND1_ALPHA"/> + <value name="GL_OPERAND2_ALPHA"/> + + <desc name="params" vector_size="1" convert="false"/> + </desc> +</template> + +<template name="GetTexGen" direction="get"> + <proto> + <return type="void"/> + <param name="coord" type="GLenum"/> + <param name="pname" type="GLenum"/> + <vector name="params" type="GLtype *" size="dynamic"/> + </proto> + + <desc name="coord"> + <value name="GL_TEXTURE_GEN_STR_OES"/> + </desc> + <desc name="pname"> + <value name="GL_TEXTURE_GEN_MODE_OES"/> + <desc name="params" vector_size="1" convert="false"/> + </desc> +</template> + +<template name="GetTexParameter" direction="get"> + <proto> + <return type="void"/> + <param name="target" type="GLenum"/> + <param name="pname" type="GLenum"/> + <vector name="params" type="GLtype *" size="dynamic"/> + </proto> + + <desc name="target"> + <value name="GL_TEXTURE_2D"/> + <value name="GL_TEXTURE_CUBE_MAP" category="GLES2.0"/> + <value name="GL_TEXTURE_CUBE_MAP_OES" category="OES_texture_cube_map"/> + <value name="GL_TEXTURE_3D_OES" category="OES_texture_3D"/> + </desc> + + <desc name="pname"> + <value name="GL_TEXTURE_WRAP_S"/> + <value name="GL_TEXTURE_WRAP_T"/> + <value name="GL_TEXTURE_WRAP_R_OES" category="OES_texture_3D"/> + <value name="GL_TEXTURE_MIN_FILTER"/> + <value name="GL_TEXTURE_MAG_FILTER"/> + <value name="GL_GENERATE_MIPMAP" category="GLES1.1"/> + + <desc name="params" vector_size="1" convert="false"/> + </desc> + + <desc name="pname" category="OES_draw_texture"> + <value name="GL_TEXTURE_CROP_RECT_OES"/> + <desc name="params" vector_size="4"/> + </desc> +</template> + +<template name="IsEnabled" direction="get"> + <proto> + <return type="GLboolean"/> + <param name="cap" type="GLenum"/> + </proto> + + <desc name="cap" category="GLES1.1"> + <value name="GL_NORMALIZE"/> + <value name="GL_RESCALE_NORMAL"/> + + <range base="GL_CLIP_PLANE" from="0" to="5"/> + + <value name="GL_FOG"/> + <value name="GL_LIGHTING"/> + <value name="GL_COLOR_MATERIAL"/> + + <range base="GL_LIGHT" from="0" to="7"/> + + <value name="GL_POINT_SMOOTH"/> + <value name="GL_LINE_SMOOTH"/> + <value name="GL_CULL_FACE"/> + <value name="GL_POLYGON_OFFSET_FILL"/> + <value name="GL_MULTISAMPLE"/> + <value name="GL_SAMPLE_ALPHA_TO_COVERAGE"/> + <value name="GL_SAMPLE_ALPHA_TO_ONE"/> + <value name="GL_SAMPLE_COVERAGE"/> + <value name="GL_TEXTURE_2D"/> + <value name="GL_SCISSOR_TEST"/> + <value name="GL_ALPHA_TEST"/> + <value name="GL_STENCIL_TEST"/> + <value name="GL_DEPTH_TEST"/> + <value name="GL_BLEND"/> + <value name="GL_DITHER"/> + <value name="GL_COLOR_LOGIC_OP"/> + + <value name="GL_POINT_SPRITE_OES" category="OES_point_sprite"/> + <value name="GL_TEXTURE_CUBE_MAP_OES" category="OES_texture_cube_map"/> + <value name="GL_TEXTURE_GEN_STR_OES" category="OES_texture_cube_map"/> + + <value name="GL_VERTEX_ARRAY"/> + <value name="GL_NORMAL_ARRAY"/> + <value name="GL_COLOR_ARRAY"/> + <value name="GL_TEXTURE_COORD_ARRAY"/> + <value name="GL_MATRIX_INDEX_ARRAY_OES" category="OES_matrix_palette"/> + <value name="GL_WEIGHT_ARRAY_OES" category="OES_matrix_palette"/> + <value name="GL_POINT_SIZE_ARRAY_OES" category="OES_point_size_array"/> + </desc> + + <desc name="cap" category="GLES2.0"> + <value name="GL_CULL_FACE"/> + <value name="GL_SCISSOR_TEST"/> + <value name="GL_POLYGON_OFFSET_FILL"/> + <value name="GL_SAMPLE_ALPHA_TO_COVERAGE"/> + <value name="GL_SAMPLE_COVERAGE"/> + <value name="GL_STENCIL_TEST"/> + <value name="GL_DEPTH_TEST"/> + <value name="GL_DITHER"/> + <value name="GL_BLEND"/> + </desc> +</template> + +<template name="DepthRange"> + <proto> + <return type="void"/> + <param name="zNear" type="GLtype"/> + <param name="zFar" type="GLtype"/> + </proto> +</template> + +<template name="Frustum"> + <proto> + <return type="void"/> + <param name="left" type="GLtype"/> + <param name="right" type="GLtype"/> + <param name="bottom" type="GLtype"/> + <param name="top" type="GLtype"/> + <param name="zNear" type="GLtype"/> + <param name="zFar" type="GLtype"/> + </proto> +</template> + +<template name="LoadIdentity"> + <proto> + <return type="void"/> + </proto> +</template> + +<template name="LoadMatrix"> + <proto> + <return type="void"/> + <vector name="m" type="const GLtype *" size="16"/> + </proto> +</template> + +<template name="MatrixMode"> + <proto> + <return type="void"/> + <param name="mode" type="GLenum"/> + </proto> + + <desc name="mode"> + <value name="GL_MODELVIEW"/> + <value name="GL_PROJECTION"/> + <value name="GL_TEXTURE"/> + <value name="GL_MATRIX_PALETTE_OES" category="OES_matrix_palette"/> + </desc> +</template> + +<template name="MultMatrix"> + <proto> + <return type="void"/> + <vector name="m" type="const GLtype *" size="16"/> + </proto> +</template> + +<template name="Ortho"> + <proto> + <return type="void"/> + <param name="left" type="GLtype"/> + <param name="right" type="GLtype"/> + <param name="bottom" type="GLtype"/> + <param name="top" type="GLtype"/> + <param name="zNear" type="GLtype"/> + <param name="zFar" type="GLtype"/> + </proto> +</template> + +<template name="PopMatrix"> + <proto> + <return type="void"/> + </proto> +</template> + +<template name="PushMatrix"> + <proto> + <return type="void"/> + </proto> +</template> + +<template name="Rotate"> + <proto> + <return type="void"/> + <param name="angle" type="GLtype"/> + <param name="x" type="GLtype"/> + <param name="y" type="GLtype"/> + <param name="z" type="GLtype"/> + </proto> +</template> + +<template name="Scale"> + <proto> + <return type="void"/> + <param name="x" type="GLtype"/> + <param name="y" type="GLtype"/> + <param name="z" type="GLtype"/> + </proto> +</template> + +<template name="Translate"> + <proto> + <return type="void"/> + <param name="x" type="GLtype"/> + <param name="y" type="GLtype"/> + <param name="z" type="GLtype"/> + </proto> +</template> + +<template name="Viewport"> + <proto> + <return type="void"/> + <param name="x" type="GLint"/> + <param name="y" type="GLint"/> + <param name="width" type="GLsizei"/> + <param name="height" type="GLsizei"/> + </proto> +</template> + +<template name="ColorPointer"> + <proto> + <return type="void"/> + <param name="size" type="GLint"/> + <param name="type" type="GLenum"/> + <param name="stride" type="GLsizei"/> + <param name="pointer" type="const GLvoid *"/> + </proto> + + <desc name="size" error="GL_INVALID_VALUE"> + <value name="4"/> + </desc> + + <desc name="type"> + <value name="GL_UNSIGNED_BYTE"/> + <value name="GL_FLOAT"/> + <value name="GL_FIXED"/> + <value name="GL_HALF_FLOAT_OES" category="OES_vertex_half_float"/> + </desc> +</template> + +<template name="DisableClientState"> + <proto> + <return type="void"/> + <param name="array" type="GLenum"/> + </proto> + + <desc name="array"> + <value name="GL_VERTEX_ARRAY"/> + <value name="GL_NORMAL_ARRAY"/> + <value name="GL_COLOR_ARRAY"/> + <value name="GL_TEXTURE_COORD_ARRAY"/> + <value name="GL_MATRIX_INDEX_ARRAY_OES" category="OES_matrix_palette"/> + <value name="GL_WEIGHT_ARRAY_OES" category="OES_matrix_palette"/> + <value name="GL_POINT_SIZE_ARRAY_OES" category="OES_point_size_array"/> + </desc> +</template> + +<template name="DrawArrays"> + <proto> + <return type="void"/> + <param name="mode" type="GLenum"/> + <param name="first" type="GLint"/> + <param name="count" type="GLsizei"/> + </proto> + + <desc name="mode"> + <value name="GL_POINTS"/> + <value name="GL_LINES"/> + <value name="GL_LINE_LOOP"/> + <value name="GL_LINE_STRIP"/> + <value name="GL_TRIANGLES"/> + <value name="GL_TRIANGLE_STRIP"/> + <value name="GL_TRIANGLE_FAN"/> + </desc> +</template> + +<template name="DrawElements"> + <proto> + <return type="void"/> + <param name="mode" type="GLenum"/> + <param name="count" type="GLsizei"/> + <param name="type" type="GLenum"/> + <param name="indices" type="const GLvoid *"/> + </proto> + + <desc name="mode"> + <value name="GL_POINTS"/> + <value name="GL_LINES"/> + <value name="GL_LINE_LOOP"/> + <value name="GL_LINE_STRIP"/> + <value name="GL_TRIANGLES"/> + <value name="GL_TRIANGLE_STRIP"/> + <value name="GL_TRIANGLE_FAN"/> + </desc> + + <desc name="type"> + <value name="GL_UNSIGNED_BYTE"/> + <value name="GL_UNSIGNED_SHORT"/> + <value name="GL_UNSIGNED_INT" category="OES_element_index_uint"/> + </desc> +</template> + +<template name="EnableClientState"> + <proto> + <return type="void"/> + <param name="array" type="GLenum"/> + </proto> + + <desc name="array"> + <value name="GL_VERTEX_ARRAY"/> + <value name="GL_NORMAL_ARRAY"/> + <value name="GL_COLOR_ARRAY"/> + <value name="GL_TEXTURE_COORD_ARRAY"/> + <value name="GL_MATRIX_INDEX_ARRAY_OES" category="OES_matrix_palette"/> + <value name="GL_WEIGHT_ARRAY_OES" category="OES_matrix_palette"/> + <value name="GL_POINT_SIZE_ARRAY_OES" category="OES_point_size_array"/> + </desc> +</template> + +<template name="GetPointer" direction="get"> + <proto> + <return type="void"/> + <param name="pname" type="GLenum"/> + <vector name="params" type="GLvoid **" size="dynamic"/> + </proto> + + <desc name="pname"> + <value name="GL_VERTEX_ARRAY_POINTER"/> + <value name="GL_NORMAL_ARRAY_POINTER"/> + <value name="GL_COLOR_ARRAY_POINTER"/> + <value name="GL_TEXTURE_COORD_ARRAY_POINTER"/> + <value name="GL_MATRIX_INDEX_ARRAY_POINTER_OES" category="OES_matrix_palette"/> + <value name="GL_WEIGHT_ARRAY_POINTER_OES" category="OES_matrix_palette"/> + <value name="GL_POINT_SIZE_ARRAY_POINTER_OES" category="OES_point_size_array"/> + </desc> +</template> + +<template name="Normal"> + <proto> + <return type="void"/> + <vector name="v" type="const GLtype *" size="3"> + <param name="nx" type="GLtype"/> + <param name="ny" type="GLtype"/> + <param name="nz" type="GLtype"/> + </vector> + </proto> +</template> + +<template name="NormalPointer"> + <proto> + <return type="void"/> + <param name="type" type="GLenum"/> + <param name="stride" type="GLsizei"/> + <param name="pointer" type="const GLvoid *"/> + </proto> + + <desc name="type"> + <value name="GL_BYTE"/> + <value name="GL_SHORT"/> + <value name="GL_FLOAT"/> + <value name="GL_FIXED"/> + <value name="GL_HALF_FLOAT_OES" category="OES_vertex_half_float"/> + </desc> +</template> + +<template name="TexCoordPointer"> + <proto> + <return type="void"/> + <param name="size" type="GLint"/> + <param name="type" type="GLenum"/> + <param name="stride" type="GLsizei"/> + <param name="pointer" type="const GLvoid *"/> + </proto> + + <desc name="size" error="GL_INVALID_VALUE"> + <value name="2"/> + <value name="3"/> + <value name="4"/> + </desc> + + <desc name="type"> + <value name="GL_BYTE"/> + <value name="GL_SHORT"/> + <value name="GL_FLOAT"/> + <value name="GL_FIXED"/> + <value name="GL_HALF_FLOAT_OES" category="OES_vertex_half_float"/> + </desc> +</template> + +<template name="VertexPointer"> + <proto> + <return type="void"/> + <param name="size" type="GLint"/> + <param name="type" type="GLenum"/> + <param name="stride" type="GLsizei"/> + <param name="pointer" type="const GLvoid *"/> + </proto> + + <desc name="size" error="GL_INVALID_VALUE"> + <value name="2"/> + <value name="3"/> + <value name="4"/> + </desc> + + <desc name="type"> + <value name="GL_BYTE"/> + <value name="GL_SHORT"/> + <value name="GL_FLOAT"/> + <value name="GL_FIXED"/> + <value name="GL_HALF_FLOAT_OES" category="OES_vertex_half_float"/> + </desc> +</template> + +<template name="PolygonOffset"> + <proto> + <return type="void"/> + <param name="factor" type="GLtype"/> + <param name="units" type="GLtype"/> + </proto> +</template> + +<template name="CopyTexImage2D"> + <proto> + <return type="void"/> + <param name="target" type="GLenum"/> + <param name="level" type="GLint"/> + <param name="internalFormat" type="GLenum"/> + <param name="x" type="GLint"/> + <param name="y" type="GLint"/> + <param name="width" type="GLsizei"/> + <param name="height" type="GLsizei"/> + <param name="border" type="GLint"/> + </proto> + + <desc name="target"> + <value name="GL_TEXTURE_2D"/> + <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_X" category="GLES2.0"/> + <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Y" category="GLES2.0"/> + <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Z" category="GLES2.0"/> + <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_X" category="GLES2.0"/> + <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Y" category="GLES2.0"/> + <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Z" category="GLES2.0"/> + <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_X_OES" category="OES_texture_cube_map"/> + <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Y_OES" category="OES_texture_cube_map"/> + <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Z_OES" category="OES_texture_cube_map"/> + <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_X_OES" category="OES_texture_cube_map"/> + <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_OES" category="OES_texture_cube_map"/> + <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_OES" category="OES_texture_cube_map"/> + </desc> + + <desc name="internalFormat" error="GL_INVALID_VALUE"> + <value name="GL_ALPHA"/> + <value name="GL_RGB"/> + <value name="GL_RGBA"/> + <value name="GL_LUMINANCE"/> + <value name="GL_LUMINANCE_ALPHA"/> + </desc> + + <desc name="border" error="GL_INVALID_VALUE"> + <value name="0"/> + </desc> +</template> + +<template name="CopyTexSubImage2D"> + <proto> + <return type="void"/> + <param name="target" type="GLenum"/> + <param name="level" type="GLint"/> + <param name="xoffset" type="GLint"/> + <param name="yoffset" type="GLint"/> + <param name="x" type="GLint"/> + <param name="y" type="GLint"/> + <param name="width" type="GLsizei"/> + <param name="height" type="GLsizei"/> + </proto> + + <desc name="target"> + <value name="GL_TEXTURE_2D"/> + <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_X" category="GLES2.0"/> + <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Y" category="GLES2.0"/> + <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Z" category="GLES2.0"/> + <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_X" category="GLES2.0"/> + <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Y" category="GLES2.0"/> + <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Z" category="GLES2.0"/> + <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_X_OES" category="OES_texture_cube_map"/> + <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Y_OES" category="OES_texture_cube_map"/> + <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Z_OES" category="OES_texture_cube_map"/> + <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_X_OES" category="OES_texture_cube_map"/> + <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_OES" category="OES_texture_cube_map"/> + <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_OES" category="OES_texture_cube_map"/> + </desc> +</template> + +<template name="TexSubImage2D"> + <proto> + <return type="void"/> + <param name="target" type="GLenum"/> + <param name="level" type="GLint"/> + <param name="xoffset" type="GLint"/> + <param name="yoffset" type="GLint"/> + <param name="width" type="GLsizei"/> + <param name="height" type="GLsizei"/> + <param name="format" type="GLenum"/> + <param name="type" type="GLenum"/> + <param name="pixels" type="const GLvoid *"/> + </proto> + + <desc name="target"> + <value name="GL_TEXTURE_2D"/> + <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_X" category="GLES2.0"/> + <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Y" category="GLES2.0"/> + <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Z" category="GLES2.0"/> + <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_X" category="GLES2.0"/> + <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Y" category="GLES2.0"/> + <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Z" category="GLES2.0"/> + <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_X_OES" category="OES_texture_cube_map"/> + <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Y_OES" category="OES_texture_cube_map"/> + <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Z_OES" category="OES_texture_cube_map"/> + <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_X_OES" category="OES_texture_cube_map"/> + <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_OES" category="OES_texture_cube_map"/> + <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_OES" category="OES_texture_cube_map"/> + </desc> + + <desc name="format"> + <value name="GL_ALPHA"/> + + <desc name="type" error="GL_INVALID_OPERATION"> + <value name="GL_UNSIGNED_BYTE"/> + <value name="GL_FLOAT" category="OES_texture_float"/> + <value name="GL_HALF_FLOAT_OES" category="OES_texture_half_float"/> + </desc> + </desc> + + <desc name="format"> + <value name="GL_RGB"/> + + <desc name="type" error="GL_INVALID_OPERATION"> + <value name="GL_UNSIGNED_BYTE"/> + <value name="GL_UNSIGNED_SHORT_5_6_5"/> + <value name="GL_FLOAT" category="OES_texture_float"/> + <value name="GL_HALF_FLOAT_OES" category="OES_texture_half_float"/> + </desc> + </desc> + + <desc name="format"> + <value name="GL_RGBA"/> + + <desc name="type" error="GL_INVALID_OPERATION"> + <value name="GL_UNSIGNED_BYTE"/> + <value name="GL_UNSIGNED_SHORT_4_4_4_4"/> + <value name="GL_UNSIGNED_SHORT_5_5_5_1"/> + <value name="GL_FLOAT" category="OES_texture_float"/> + <value name="GL_HALF_FLOAT_OES" category="OES_texture_half_float"/> + <value name="GL_UNSIGNED_INT_2_10_10_10_REV_EXT" category="EXT_texture_type_2_10_10_10_REV"/> + </desc> + </desc> + + <desc name="format"> + <value name="GL_LUMINANCE"/> + + <desc name="type" error="GL_INVALID_OPERATION"> + <value name="GL_UNSIGNED_BYTE"/> + <value name="GL_FLOAT" category="OES_texture_float"/> + <value name="GL_HALF_FLOAT_OES" category="OES_texture_half_float"/> + </desc> + </desc> + + <desc name="format"> + <value name="GL_LUMINANCE_ALPHA"/> + + <desc name="type" error="GL_INVALID_OPERATION"> + <value name="GL_UNSIGNED_BYTE"/> + <value name="GL_FLOAT" category="OES_texture_float"/> + <value name="GL_HALF_FLOAT_OES" category="OES_texture_half_float"/> + </desc> + </desc> + + <desc name="format" category="OES_depth_texture"> + <value name="GL_DEPTH_COMPONENT"/> + + <desc name="type" error="GL_INVALID_OPERATION"> + <value name="GL_UNSIGNED_SHORT"/> + <value name="GL_UNSIGNED_INT"/> + </desc> + </desc> + + <desc name="format" category="OES_packed_depth_stencil"> + <value name="GL_DEPTH_STENCIL_OES"/> + + <desc name="type" error="GL_INVALID_OPERATION"> + <value name="GL_UNSIGNED_INT_24_8_OES"/> + </desc> + </desc> + + <desc name="format" category="EXT_texture_format_BGRA8888"> + <value name="GL_BGRA_EXT"/> + + <desc name="type" error="GL_INVALID_OPERATION"> + <value name="GL_UNSIGNED_BYTE"/> + </desc> + </desc> +</template> + +<template name="BindTexture"> + <proto> + <return type="void"/> + <param name="target" type="GLenum"/> + <param name="texture" type="GLuint"/> + </proto> + + <desc name="target"> + <value name="GL_TEXTURE_2D"/> + <value name="GL_TEXTURE_CUBE_MAP" category="GLES2.0"/> + <value name="GL_TEXTURE_CUBE_MAP_OES" category="OES_texture_cube_map"/> + <value name="GL_TEXTURE_3D_OES" category="OES_texture_3D"/> + </desc> +</template> + +<template name="DeleteTextures"> + <proto> + <return type="void"/> + <param name="n" type="GLsizei"/> + <param name="textures" type="const GLuint *"/> + </proto> +</template> + +<template name="GenTextures" direction="get"> + <proto> + <return type="void"/> + <param name="n" type="GLsizei"/> + <param name="textures" type="GLuint *"/> + </proto> +</template> + +<template name="IsTexture" direction="get"> + <proto> + <return type="GLboolean"/> + <param name="texture" type="GLuint"/> + </proto> +</template> + +<template name="BlendColor"> + <proto> + <return type="void"/> + <param name="red" type="GLtype"/> + <param name="green" type="GLtype"/> + <param name="blue" type="GLtype"/> + <param name="alpha" type="GLtype"/> + </proto> +</template> + +<template name="BlendEquation"> + <proto> + <return type="void"/> + <param name="mode" type="GLenum"/> + </proto> + + <desc name="mode"> + <value name="GL_FUNC_ADD" category="GLES2.0"/> + <value name="GL_FUNC_SUBTRACT" category="GLES2.0"/> + <value name="GL_FUNC_REVERSE_SUBTRACT" category="GLES2.0"/> + <value name="GL_FUNC_ADD_OES" category="OES_blend_subtract"/> + <value name="GL_FUNC_SUBTRACT_OES" category="OES_blend_subtract"/> + <value name="GL_FUNC_REVERSE_SUBTRACT_OES" category="OES_blend_subtract"/> + + <value name="GL_MIN_EXT" category="EXT_blend_minmax"/> + <value name="GL_MAX_EXT" category="EXT_blend_minmax"/> + </desc> +</template> + +<template name="BlendEquationSeparate"> + <proto> + <return type="void"/> + <param name="modeRGB" type="GLenum"/> + <param name="modeAlpha" type="GLenum"/> + </proto> + + <desc name="modeRGB"> + <value name="GL_FUNC_ADD" category="GLES2.0"/> + <value name="GL_FUNC_SUBTRACT" category="GLES2.0"/> + <value name="GL_FUNC_REVERSE_SUBTRACT" category="GLES2.0"/> + <value name="GL_FUNC_ADD_OES" category="OES_blend_subtract"/> + <value name="GL_FUNC_SUBTRACT_OES" category="OES_blend_subtract"/> + <value name="GL_FUNC_REVERSE_SUBTRACT_OES" category="OES_blend_subtract"/> + + <value name="GL_MIN_EXT" category="EXT_blend_minmax"/> + <value name="GL_MAX_EXT" category="EXT_blend_minmax"/> + </desc> + + <desc name="modeAlpha"> + <value name="GL_FUNC_ADD" category="GLES2.0"/> + <value name="GL_FUNC_SUBTRACT" category="GLES2.0"/> + <value name="GL_FUNC_REVERSE_SUBTRACT" category="GLES2.0"/> + <value name="GL_FUNC_ADD_OES" category="OES_blend_subtract"/> + <value name="GL_FUNC_SUBTRACT_OES" category="OES_blend_subtract"/> + <value name="GL_FUNC_REVERSE_SUBTRACT_OES" category="OES_blend_subtract"/> + + <value name="GL_MIN_EXT" category="EXT_blend_minmax"/> + <value name="GL_MAX_EXT" category="EXT_blend_minmax"/> + </desc> +</template> + +<template name="TexImage3D"> + <proto> + <return type="void"/> + <param name="target" type="GLenum"/> + <param name="level" type="GLint"/> + <param name="internalFormat" type="GLenum"/> + <param name="width" type="GLsizei"/> + <param name="height" type="GLsizei"/> + <param name="depth" type="GLsizei"/> + <param name="border" type="GLint"/> + <param name="format" type="GLenum"/> + <param name="type" type="GLenum"/> + <param name="pixels" type="const GLvoid *"/> + </proto> + + <desc name="target"> + <value name="GL_TEXTURE_3D_OES"/> + </desc> + + <desc name="internalFormat"> + <value name="GL_ALPHA"/> + <value name="GL_RGB"/> + <value name="GL_RGBA"/> + <value name="GL_LUMINANCE"/> + <value name="GL_LUMINANCE_ALPHA"/> + </desc> + + <desc name="format"> + <value name="GL_ALPHA"/> + + <desc name="type" error="GL_INVALID_OPERATION"> + <value name="GL_UNSIGNED_BYTE"/> + <value name="GL_FLOAT" category="OES_texture_float"/> + <value name="GL_HALF_FLOAT_OES" category="OES_texture_half_float"/> + </desc> + </desc> + + <desc name="format"> + <value name="GL_RGB"/> + + <desc name="type" error="GL_INVALID_OPERATION"> + <value name="GL_UNSIGNED_BYTE"/> + <value name="GL_UNSIGNED_SHORT_5_6_5"/> + <value name="GL_FLOAT" category="OES_texture_float"/> + <value name="GL_HALF_FLOAT_OES" category="OES_texture_half_float"/> + </desc> + </desc> + + <desc name="format"> + <value name="GL_RGBA"/> + + <desc name="type" error="GL_INVALID_OPERATION"> + <value name="GL_UNSIGNED_BYTE"/> + <value name="GL_UNSIGNED_SHORT_4_4_4_4"/> + <value name="GL_UNSIGNED_SHORT_5_5_5_1"/> + <value name="GL_FLOAT" category="OES_texture_float"/> + <value name="GL_HALF_FLOAT_OES" category="OES_texture_half_float"/> + <value name="GL_UNSIGNED_INT_2_10_10_10_REV_EXT" category="EXT_texture_type_2_10_10_10_REV"/> + </desc> + </desc> + + <desc name="format"> + <value name="GL_LUMINANCE"/> + + <desc name="type" error="GL_INVALID_OPERATION"> + <value name="GL_UNSIGNED_BYTE"/> + <value name="GL_FLOAT" category="OES_texture_float"/> + <value name="GL_HALF_FLOAT_OES" category="OES_texture_half_float"/> + </desc> + </desc> + + <desc name="format"> + <value name="GL_LUMINANCE_ALPHA"/> + + <desc name="type" error="GL_INVALID_OPERATION"> + <value name="GL_UNSIGNED_BYTE"/> + <value name="GL_FLOAT" category="OES_texture_float"/> + <value name="GL_HALF_FLOAT_OES" category="OES_texture_half_float"/> + </desc> + </desc> +</template> + +<template name="TexSubImage3D"> + <proto> + <return type="void"/> + <param name="target" type="GLenum"/> + <param name="level" type="GLint"/> + <param name="xoffset" type="GLint"/> + <param name="yoffset" type="GLint"/> + <param name="zoffset" type="GLint"/> + <param name="width" type="GLsizei"/> + <param name="height" type="GLsizei"/> + <param name="depth" type="GLsizei"/> + <param name="format" type="GLenum"/> + <param name="type" type="GLenum"/> + <param name="pixels" type="const GLvoid *"/> + </proto> + + <desc name="target"> + <value name="GL_TEXTURE_3D_OES"/> + </desc> + + <desc name="format"> + <value name="GL_ALPHA"/> + + <desc name="type" error="GL_INVALID_OPERATION"> + <value name="GL_UNSIGNED_BYTE"/> + <value name="GL_FLOAT" category="OES_texture_float"/> + <value name="GL_HALF_FLOAT_OES" category="OES_texture_half_float"/> + </desc> + </desc> + + <desc name="format"> + <value name="GL_RGB"/> + + <desc name="type" error="GL_INVALID_OPERATION"> + <value name="GL_UNSIGNED_BYTE"/> + <value name="GL_UNSIGNED_SHORT_5_6_5"/> + <value name="GL_FLOAT" category="OES_texture_float"/> + <value name="GL_HALF_FLOAT_OES" category="OES_texture_half_float"/> + </desc> + </desc> + + <desc name="format"> + <value name="GL_RGBA"/> + + <desc name="type" error="GL_INVALID_OPERATION"> + <value name="GL_UNSIGNED_BYTE"/> + <value name="GL_UNSIGNED_SHORT_4_4_4_4"/> + <value name="GL_UNSIGNED_SHORT_5_5_5_1"/> + <value name="GL_FLOAT" category="OES_texture_float"/> + <value name="GL_HALF_FLOAT_OES" category="OES_texture_half_float"/> + <value name="GL_UNSIGNED_INT_2_10_10_10_REV_EXT" category="EXT_texture_type_2_10_10_10_REV"/> + </desc> + </desc> + + <desc name="format"> + <value name="GL_LUMINANCE"/> + + <desc name="type" error="GL_INVALID_OPERATION"> + <value name="GL_UNSIGNED_BYTE"/> + <value name="GL_FLOAT" category="OES_texture_float"/> + <value name="GL_HALF_FLOAT_OES" category="OES_texture_half_float"/> + </desc> + </desc> + + <desc name="format"> + <value name="GL_LUMINANCE_ALPHA"/> + + <desc name="type" error="GL_INVALID_OPERATION"> + <value name="GL_UNSIGNED_BYTE"/> + <value name="GL_FLOAT" category="OES_texture_float"/> + <value name="GL_HALF_FLOAT_OES" category="OES_texture_half_float"/> + </desc> + </desc> +</template> + +<template name="CopyTexSubImage3D"> + <proto> + <return type="void"/> + <param name="target" type="GLenum"/> + <param name="level" type="GLint"/> + <param name="xoffset" type="GLint"/> + <param name="yoffset" type="GLint"/> + <param name="zoffset" type="GLint"/> + <param name="x" type="GLint"/> + <param name="y" type="GLint"/> + <param name="width" type="GLsizei"/> + <param name="height" type="GLsizei"/> + </proto> + + <desc name="target"> + <value name="GL_TEXTURE_3D_OES"/> + </desc> +</template> + +<template name="MultiTexCoord"> + <proto> + <return type="void"/> + <param name="texture" type="GLenum"/> + <vector name="v" type="const GLtype *" size="dynamic"> + <param name="s" type="GLtype"/> + <param name="t" type="GLtype"/> + <param name="r" type="GLtype"/> + <param name="q" type="GLtype"/> + </vector> + </proto> + + <desc name="texture"> + <range base="GL_TEXTURE" from="0" to="31"/> + </desc> +</template> + +<template name="CompressedTexImage3D"> + <proto> + <return type="void"/> + <param name="target" type="GLenum"/> + <param name="level" type="GLint"/> + <param name="internalFormat" type="GLenum"/> + <param name="width" type="GLsizei"/> + <param name="height" type="GLsizei"/> + <param name="depth" type="GLsizei"/> + <param name="border" type="GLint"/> + <param name="imagesize" type="GLsizei"/> + <param name="data" type="const GLvoid *"/> + </proto> + + <desc name="target"> + <value name="GL_TEXTURE_3D_OES"/> + </desc> + + <desc name="internalFormat"> + <value name="GL_3DC_X_AMD" category="AMD_compressed_3DC_texture"/> + <value name="GL_3DC_XY_AMD" category="AMD_compressed_3DC_texture"/> + <value name="GL_ATC_RGB_AMD" category="AMD_compressed_ATC_texture"/> + <value name="GL_ATC_RGBA_EXPLICIT_ALPHA_AMD" category="AMD_compressed_ATC_texture"/> + <value name="GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD" category="AMD_compressed_ATC_texture"/> + </desc> +</template> + +<template name="CompressedTexSubImage3D"> + <proto> + <return type="void"/> + <param name="target" type="GLenum"/> + <param name="level" type="GLint"/> + <param name="xoffset" type="GLint"/> + <param name="yoffset" type="GLint"/> + <param name="zoffset" type="GLint"/> + <param name="width" type="GLsizei"/> + <param name="height" type="GLsizei"/> + <param name="depth" type="GLsizei"/> + <param name="format" type="GLenum"/> + <param name="imagesize" type="GLsizei"/> + <param name="data" type="const GLvoid *"/> + </proto> + + <desc name="target"> + <value name="GL_TEXTURE_3D_OES"/> + </desc> +</template> + +<template name="ActiveTexture"> + <proto> + <return type="void"/> + <param name="texture" type="GLenum"/> + </proto> + + <desc name="texture"> + <range base="GL_TEXTURE" from="0" to="31"/> + </desc> +</template> + +<template name="ClientActiveTexture"> + <proto> + <return type="void"/> + <param name="texture" type="GLenum"/> + </proto> + + <desc name="texture"> + <range base="GL_TEXTURE" from="0" to="31"/> + </desc> +</template> + +<template name="SampleCoverage"> + <proto> + <return type="void"/> + <param name="value" type="GLtype"/> + <param name="invert" type="GLboolean"/> + </proto> +</template> + +<template name="CompressedTexImage2D"> + <proto> + <return type="void"/> + <param name="target" type="GLenum"/> + <param name="level" type="GLint"/> + <param name="internalFormat" type="GLenum"/> + <param name="width" type="GLsizei"/> + <param name="height" type="GLsizei"/> + <param name="border" type="GLint"/> + <param name="imageSize" type="GLsizei"/> + <param name="data" type="const GLvoid *"/> + </proto> + + <desc name="target"> + <value name="GL_TEXTURE_2D"/> + <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_X" category="GLES2.0"/> + <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Y" category="GLES2.0"/> + <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Z" category="GLES2.0"/> + <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_X" category="GLES2.0"/> + <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Y" category="GLES2.0"/> + <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Z" category="GLES2.0"/> + <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_X_OES" category="OES_texture_cube_map"/> + <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Y_OES" category="OES_texture_cube_map"/> + <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Z_OES" category="OES_texture_cube_map"/> + <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_X_OES" category="OES_texture_cube_map"/> + <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_OES" category="OES_texture_cube_map"/> + <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_OES" category="OES_texture_cube_map"/> + </desc> + + <desc name="internalFormat"> + <value name="GL_ETC1_RGB8_OES" category="OES_compressed_ETC1_RGB8_texture"/> + + <value name="GL_PALETTE4_RGB8_OES" category="OES_compressed_paletted_texture"/> + <value name="GL_PALETTE4_RGBA8_OES" category="OES_compressed_paletted_texture"/> + <value name="GL_PALETTE4_R5_G6_B5_OES" category="OES_compressed_paletted_texture"/> + <value name="GL_PALETTE4_RGBA4_OES" category="OES_compressed_paletted_texture"/> + <value name="GL_PALETTE4_RGB5_A1_OES" category="OES_compressed_paletted_texture"/> + <value name="GL_PALETTE8_RGB8_OES" category="OES_compressed_paletted_texture"/> + <value name="GL_PALETTE8_RGBA8_OES" category="OES_compressed_paletted_texture"/> + <value name="GL_PALETTE8_R5_G6_B5_OES" category="OES_compressed_paletted_texture"/> + <value name="GL_PALETTE8_RGBA4_OES" category="OES_compressed_paletted_texture"/> + <value name="GL_PALETTE8_RGB5_A1_OES" category="OES_compressed_paletted_texture"/> + + <value name="GL_3DC_X_AMD" category="AMD_compressed_3DC_texture"/> + <value name="GL_3DC_XY_AMD" category="AMD_compressed_3DC_texture"/> + + <value name="GL_ATC_RGB_AMD" category="AMD_compressed_ATC_texture"/> + <value name="GL_ATC_RGBA_EXPLICIT_ALPHA_AMD" category="AMD_compressed_ATC_texture"/> + <value name="GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD" category="AMD_compressed_ATC_texture"/> + + <value name="GL_COMPRESSED_RGB_S3TC_DXT1_EXT" category="EXT_texture_compression_dxt1"/> + <value name="GL_COMPRESSED_RGBA_S3TC_DXT1_EXT" category="EXT_texture_compression_dxt1"/> + </desc> + + <desc name="border" error="GL_INVALID_VALUE"> + <value name="0"/> + </desc> +</template> + +<template name="CompressedTexSubImage2D"> + <proto> + <return type="void"/> + <param name="target" type="GLenum"/> + <param name="level" type="GLint"/> + <param name="xoffset" type="GLint"/> + <param name="yoffset" type="GLint"/> + <param name="width" type="GLsizei"/> + <param name="height" type="GLsizei"/> + <param name="format" type="GLenum"/> + <param name="imageSize" type="GLsizei"/> + <param name="data" type="const GLvoid *"/> + </proto> + + <desc name="target"> + <value name="GL_TEXTURE_2D"/> + <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_X" category="GLES2.0"/> + <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Y" category="GLES2.0"/> + <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Z" category="GLES2.0"/> + <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_X" category="GLES2.0"/> + <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Y" category="GLES2.0"/> + <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Z" category="GLES2.0"/> + <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_X_OES" category="OES_texture_cube_map"/> + <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Y_OES" category="OES_texture_cube_map"/> + <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Z_OES" category="OES_texture_cube_map"/> + <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_X_OES" category="OES_texture_cube_map"/> + <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_OES" category="OES_texture_cube_map"/> + <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_OES" category="OES_texture_cube_map"/> + </desc> + + <desc name="format"> + <value name="GL_COMPRESSED_RGB_S3TC_DXT1_EXT" category="EXT_texture_compression_dxt1"/> + <value name="GL_COMPRESSED_RGBA_S3TC_DXT1_EXT" category="EXT_texture_compression_dxt1"/> + </desc> +</template> + +<template name="BlendFuncSeparate"> + <proto> + <return type="void"/> + <param name="srcRGB" type="GLenum"/> + <param name="dstRGB" type="GLenum"/> + <param name="srcAlpha" type="GLenum"/> + <param name="dstAlpha" type="GLenum"/> + </proto> + + <desc name="srcRGB"> + <value name="GL_ZERO"/> + <value name="GL_ONE"/> + <value name="GL_SRC_COLOR"/> + <value name="GL_ONE_MINUS_SRC_COLOR"/> + <value name="GL_SRC_ALPHA"/> + <value name="GL_ONE_MINUS_SRC_ALPHA"/> + <value name="GL_DST_ALPHA"/> + <value name="GL_ONE_MINUS_DST_ALPHA"/> + <value name="GL_DST_COLOR"/> + <value name="GL_ONE_MINUS_DST_COLOR"/> + <value name="GL_SRC_ALPHA_SATURATE"/> + + <value name="GL_CONSTANT_COLOR" category="GLES2.0"/> + <value name="GL_ONE_MINUS_CONSTANT_COLOR" category="GLES2.0"/> + <value name="GL_CONSTANT_ALPHA" category="GLES2.0"/> + <value name="GL_ONE_MINUS_CONSTANT_ALPHA" category="GLES2.0"/> + </desc> + + <desc name="dstRGB"> + <value name="GL_ZERO"/> + <value name="GL_ONE"/> + <value name="GL_SRC_COLOR"/> + <value name="GL_ONE_MINUS_SRC_COLOR"/> + <value name="GL_SRC_ALPHA"/> + <value name="GL_ONE_MINUS_SRC_ALPHA"/> + <value name="GL_DST_ALPHA"/> + <value name="GL_ONE_MINUS_DST_ALPHA"/> + <value name="GL_DST_COLOR"/> + <value name="GL_ONE_MINUS_DST_COLOR"/> + + <value name="GL_CONSTANT_COLOR" category="GLES2.0"/> + <value name="GL_ONE_MINUS_CONSTANT_COLOR" category="GLES2.0"/> + <value name="GL_CONSTANT_ALPHA" category="GLES2.0"/> + <value name="GL_ONE_MINUS_CONSTANT_ALPHA" category="GLES2.0"/> + </desc> + + <desc name="srcAlpha"> + <value name="GL_ZERO"/> + <value name="GL_ONE"/> + <value name="GL_SRC_COLOR"/> + <value name="GL_ONE_MINUS_SRC_COLOR"/> + <value name="GL_SRC_ALPHA"/> + <value name="GL_ONE_MINUS_SRC_ALPHA"/> + <value name="GL_DST_ALPHA"/> + <value name="GL_ONE_MINUS_DST_ALPHA"/> + <value name="GL_DST_COLOR"/> + <value name="GL_ONE_MINUS_DST_COLOR"/> + <value name="GL_SRC_ALPHA_SATURATE"/> + + <value name="GL_CONSTANT_COLOR" category="GLES2.0"/> + <value name="GL_ONE_MINUS_CONSTANT_COLOR" category="GLES2.0"/> + <value name="GL_CONSTANT_ALPHA" category="GLES2.0"/> + <value name="GL_ONE_MINUS_CONSTANT_ALPHA" category="GLES2.0"/> + </desc> + + <desc name="dstAlpha"> + <value name="GL_ZERO"/> + <value name="GL_ONE"/> + <value name="GL_SRC_COLOR"/> + <value name="GL_ONE_MINUS_SRC_COLOR"/> + <value name="GL_SRC_ALPHA"/> + <value name="GL_ONE_MINUS_SRC_ALPHA"/> + <value name="GL_DST_ALPHA"/> + <value name="GL_ONE_MINUS_DST_ALPHA"/> + <value name="GL_DST_COLOR"/> + <value name="GL_ONE_MINUS_DST_COLOR"/> + + <value name="GL_CONSTANT_COLOR" category="GLES2.0"/> + <value name="GL_ONE_MINUS_CONSTANT_COLOR" category="GLES2.0"/> + <value name="GL_CONSTANT_ALPHA" category="GLES2.0"/> + <value name="GL_ONE_MINUS_CONSTANT_ALPHA" category="GLES2.0"/> + </desc> +</template> + +<template name="PointParameter"> + <proto> + <return type="void"/> + <param name="pname" type="GLenum"/> + <vector name="params" type="const GLtype *" size="dynamic"> + <param name="param" type="GLtype"/> + </vector> + </proto> + + <desc name="pname"> + <value name="GL_POINT_SIZE_MIN"/> + <value name="GL_POINT_SIZE_MAX"/> + <value name="GL_POINT_FADE_THRESHOLD_SIZE"/> + + <desc name="params" vector_size="1"/> + </desc> + + <desc name="pname"> + <value name="GL_POINT_DISTANCE_ATTENUATION"/> + <desc name="params" vector_size="3"/> + </desc> +</template> + +<template name="VertexAttrib"> + <proto> + <return type="void"/> + <param name="index" type="GLuint"/> + <vector name="v" type="const GLtype *" size="dynamic"> + <param name="x" type="GLtype"/> + <param name="y" type="GLtype"/> + <param name="z" type="GLtype"/> + <param name="w" type="GLtype"/> + </vector> + </proto> +</template> + +<template name="VertexAttribPointer"> + <proto> + <return type="void"/> + <param name="index" type="GLuint"/> + <param name="size" type="GLint"/> + <param name="type" type="GLenum"/> + <param name="normalized" type="GLboolean"/> + <param name="stride" type="GLsizei"/> + <param name="pointer" type="const GLvoid *"/> + </proto> + + <desc name="size" error="GL_INVALID_VALUE"> + <value name="1"/> + <value name="2"/> + <value name="3"/> + <value name="4"/> + </desc> + + <desc name="type" error="GL_INVALID_VALUE"> + <value name="GL_BYTE"/> + <value name="GL_UNSIGNED_BYTE"/> + <value name="GL_SHORT"/> + <value name="GL_UNSIGNED_SHORT"/> + <value name="GL_FLOAT"/> + <value name="GL_FIXED"/> + <value name="GL_HALF_FLOAT_OES" category="OES_vertex_half_float"/> + <value name="GL_UNSIGNED_INT_10_10_10_2_OES" category="OES_vertex_type_10_10_10_2"/> + <value name="GL_INT_10_10_10_2_OES" category="OES_vertex_type_10_10_10_2"/> + </desc> + + <desc name="type" category="OES_vertex_type_10_10_10_2"> + <value name="GL_UNSIGNED_INT_10_10_10_2_OES"/> + <value name="GL_INT_10_10_10_2_OES"/> + + <desc name="size"> + <value name="3"/> + <value name="4"/> + </desc> + </desc> +</template> + +<template name="EnableVertexAttribArray"> + <proto> + <return type="void"/> + <param name="index" type="GLuint"/> + </proto> +</template> + +<template name="DisableVertexAttribArray"> + <proto> + <return type="void"/> + <param name="index" type="GLuint"/> + </proto> +</template> + +<template name="IsProgram" direction="get"> + <proto> + <return type="GLboolean"/> + <param name="program" type="GLuint"/> + </proto> +</template> + +<template name="GetProgram" direction="get"> + <proto> + <return type="void"/> + <param name="program" type="GLuint"/> + <param name="pname" type="GLenum"/> + <vector name="params" type="GLtype *" size="dynamic"/> + </proto> + + <desc name="pname"> + <value name="GL_DELETE_STATUS"/> + <value name="GL_LINK_STATUS"/> + <value name="GL_VALIDATE_STATUS"/> + <value name="GL_INFO_LOG_LENGTH"/> + <value name="GL_ATTACHED_SHADERS"/> + <value name="GL_ACTIVE_ATTRIBUTES"/> + <value name="GL_ACTIVE_ATTRIBUTE_MAX_LENGTH"/> + <value name="GL_ACTIVE_UNIFORMS"/> + <value name="GL_ACTIVE_UNIFORM_MAX_LENGTH"/> + <value name="GL_PROGRAM_BINARY_LENGTH_OES" category="OES_get_program_binary"/> + + <desc name="params" convert="false"/> + </desc> +</template> + +<template name="GetVertexAttrib" direction="get"> + <proto> + <return type="void"/> + <param name="index" type="GLuint"/> + <param name="pname" type="GLenum"/> + <vector name="params" type="GLtype *" size="dynamic"/> + </proto> + + <desc name="pname"> + <value name="GL_VERTEX_ATTRIB_ARRAY_ENABLED"/> + <value name="GL_VERTEX_ATTRIB_ARRAY_SIZE"/> + <value name="GL_VERTEX_ATTRIB_ARRAY_STRIDE"/> + <value name="GL_VERTEX_ATTRIB_ARRAY_TYPE"/> + <value name="GL_VERTEX_ATTRIB_ARRAY_NORMALIZED"/> + <value name="GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING"/> + + <desc name="params" vector_size="1" convert="false"/> + </desc> + + <desc name="pname"> + <value name="GL_CURRENT_VERTEX_ATTRIB"/> + <desc name="params" vector_size="16?" convert="false"/> + </desc> +</template> + +<template name="GetVertexAttribPointer" direction="get"> + <proto> + <return type="void"/> + <param name="index" type="GLuint"/> + <param name="pname" type="GLenum"/> + <vector name="pointer" type="GLvoid **" size="dynamic"/> + </proto> + + <desc name="pname"> + <value name="GL_VERTEX_ATTRIB_ARRAY_POINTER"/> + </desc> +</template> + +<template name="GetBufferPointer" direction="get"> + <proto> + <return type="void"/> + <param name="target" type="GLenum"/> + <param name="pname" type="GLenum"/> + <vector name="params" type="GLvoid **" size="dynamic"/> + </proto> + + <desc name="target"> + <value name="GL_ARRAY_BUFFER"/> + <value name="GL_ELEMENT_ARRAY_BUFFER"/> + </desc> + + <desc name="pname"> + <value name="GL_BUFFER_MAP_POINTER_OES"/> + </desc> +</template> + +<template name="MapBuffer" direction="get"> + <proto> + <return type="void *"/> + <param name="target" type="GLenum"/> + <param name="access" type="GLenum"/> + </proto> + + <desc name="target"> + <value name="GL_ARRAY_BUFFER"/> + <value name="GL_ELEMENT_ARRAY_BUFFER"/> + </desc> + + <desc name="access"> + <value name="GL_WRITE_ONLY_OES"/> + </desc> +</template> + +<template name="UnmapBuffer" direction="get"> + <proto> + <return type="GLboolean"/> + <param name="target" type="GLenum"/> + </proto> + + <desc name="target"> + <value name="GL_ARRAY_BUFFER"/> + <value name="GL_ELEMENT_ARRAY_BUFFER"/> + </desc> +</template> + +<template name="BindBuffer"> + <proto> + <return type="void"/> + <param name="target" type="GLenum"/> + <param name="buffer" type="GLuint"/> + </proto> + + <desc name="target"> + <value name="GL_ARRAY_BUFFER"/> + <value name="GL_ELEMENT_ARRAY_BUFFER"/> + </desc> +</template> + +<template name="BufferData"> + <proto> + <return type="void"/> + <param name="target" type="GLenum"/> + <param name="size" type="GLsizeiptr"/> + <param name="data" type="const GLvoid *"/> + <param name="usage" type="GLenum"/> + </proto> + + <desc name="target"> + <value name="GL_ARRAY_BUFFER"/> + <value name="GL_ELEMENT_ARRAY_BUFFER"/> + </desc> + + <desc name="usage"> + <value name="GL_STATIC_DRAW"/> + <value name="GL_DYNAMIC_DRAW"/> + <value name="GL_STREAM_DRAW" category="GLES2.0"/> + </desc> +</template> + +<template name="BufferSubData"> + <proto> + <return type="void"/> + <param name="target" type="GLenum"/> + <param name="offset" type="GLintptr"/> + <param name="size" type="GLsizeiptr"/> + <param name="data" type="const GLvoid *"/> + </proto> + + <desc name="target"> + <value name="GL_ARRAY_BUFFER"/> + <value name="GL_ELEMENT_ARRAY_BUFFER"/> + </desc> +</template> + +<template name="DeleteBuffers"> + <proto> + <return type="void"/> + <param name="n" type="GLsizei"/> + <param name="buffer" type="const GLuint *"/> + </proto> +</template> + +<template name="GenBuffers" direction="get"> + <proto> + <return type="void"/> + <param name="n" type="GLsizei"/> + <param name="buffer" type="GLuint *"/> + </proto> +</template> + +<template name="GetBufferParameter" direction="get"> + <proto> + <return type="void"/> + <param name="target" type="GLenum"/> + <param name="pname" type="GLenum"/> + <vector name="params" type="GLtype *" size="dynamic"/> + </proto> + + <desc name="target"> + <value name="GL_ARRAY_BUFFER"/> + <value name="GL_ELEMENT_ARRAY_BUFFER"/> + </desc> + + <desc name="pname"> + <value name="GL_BUFFER_SIZE"/> + <value name="GL_BUFFER_USAGE"/> + <value name="GL_BUFFER_ACCESS_OES" category="OES_mapbuffer"/> + <value name="GL_BUFFER_MAPPED_OES" category="OES_mapbuffer"/> + </desc> +</template> + +<template name="IsBuffer" direction="get"> + <proto> + <return type="GLboolean"/> + <param name="buffer" type="GLuint"/> + </proto> +</template> + +<template name="CreateShader"> + <proto> + <return type="GLuint"/> + <param name="type" type="GLenum"/> + </proto> + + <desc name="type"> + <value name="GL_VERTEX_SHADER"/> + <value name="GL_FRAGMENT_SHADER"/> + </desc> +</template> + +<template name="ShaderSource"> + <proto> + <return type="void"/> + <param name="shader" type="GLuint"/> + <param name="count" type="GLsizei"/> + <param name="string" type="const GLchar **"/> + <param name="length" type="const int *"/> + </proto> +</template> + +<template name="CompileShader"> + <proto> + <return type="void"/> + <param name="shader" type="GLuint"/> + </proto> +</template> + +<template name="ReleaseShaderCompiler"> + <proto> + <return type="void"/> + </proto> +</template> + +<template name="DeleteShader"> + <proto> + <return type="void"/> + <param name="shader" type="GLuint"/> + </proto> +</template> + +<template name="ShaderBinary"> + <proto> + <return type="void"/> + <param name="n" type="GLsizei"/> + <param name="shaders" type="const GLuint *"/> + <param name="binaryformat" type="GLenum"/> + <param name="binary" type="const GLvoid *"/> + <param name="length" type="GLsizei"/> + </proto> +</template> + +<template name="CreateProgram"> + <proto> + <return type="GLuint"/> + </proto> +</template> + +<template name="AttachShader"> + <proto> + <return type="void"/> + <param name="program" type="GLuint"/> + <param name="shader" type="GLuint"/> + </proto> +</template> + +<template name="DetachShader"> + <proto> + <return type="void"/> + <param name="program" type="GLuint"/> + <param name="shader" type="GLuint"/> + </proto> +</template> + +<template name="LinkProgram"> + <proto> + <return type="void"/> + <param name="program" type="GLuint"/> + </proto> +</template> + +<template name="UseProgram"> + <proto> + <return type="void"/> + <param name="program" type="GLuint"/> + </proto> +</template> + +<template name="DeleteProgram"> + <proto> + <return type="void"/> + <param name="program" type="GLuint"/> + </proto> +</template> + +<template name="GetActiveAttrib" direction="get"> + <proto> + <return type="void"/> + <param name="program" type="GLuint"/> + <param name="index" type="GLuint"/> + <param name="bufSize" type="GLsizei"/> + <param name="length" type="GLsizei *"/> + <param name="size" type="GLint *"/> + <param name="type" type="GLenum *"/> + <param name="name" type="GLchar *"/> + </proto> +</template> + +<template name="GetAttribLocation" direction="get"> + <proto> + <return type="GLint"/> + <param name="program" type="GLuint"/> + <param name="name" type="const char *"/> + </proto> +</template> + +<template name="BindAttribLocation"> + <proto> + <return type="void"/> + <param name="program" type="GLuint"/> + <param name="index" type="GLuint"/> + <param name="name" type="const char *"/> + </proto> +</template> + +<template name="GetUniformLocation" direction="get"> + <proto> + <return type="GLint"/> + <param name="program" type="GLuint"/> + <param name="name" type="const char *"/> + </proto> +</template> + +<template name="GetActiveUniform" direction="get"> + <proto> + <return type="void"/> + <param name="program" type="GLuint"/> + <param name="index" type="GLuint"/> + <param name="bufSize" type="GLsizei"/> + <param name="length" type="GLsizei *"/> + <param name="size" type="GLint *"/> + <param name="type" type="GLenum *"/> + <param name="name" type="GLchar *"/> + </proto> +</template> + +<template name="Uniform"> + <proto> + <return type="void"/> + <param name="location" type="GLint"/> + <param name="count" type="GLsizei" hide_if_expanded="true"/> + <vector name="values" type="const GLtype *" size="dynamic"> + <param name="v0" type="GLtype"/> + <param name="v1" type="GLtype"/> + <param name="v2" type="GLtype"/> + <param name="v3" type="GLtype"/> + </vector> + </proto> +</template> + +<template name="UniformMatrix"> + <proto> + <return type="void"/> + <param name="location" type="GLint"/> + <param name="count" type="GLsizei"/> + <param name="transpose" type="GLboolean"/> + <vector name="value" type="const GLtype *" size="dynamic"/> + </proto> +</template> + +<template name="ValidateProgram"> + <proto> + <return type="void"/> + <param name="program" type="GLuint"/> + </proto> +</template> + +<template name="GenerateMipmap"> + <proto> + <return type="void"/> + <param name="target" type="GLenum"/> + </proto> + + <desc name="target"> + <value name="GL_TEXTURE_2D"/> + <value name="GL_TEXTURE_CUBE_MAP" category="GLES2.0"/> + <value name="GL_TEXTURE_CUBE_MAP_OES" category="OES_texture_cube_map"/> + <value name="GL_TEXTURE_3D_OES" category="OES_texture_3D"/> + </desc> +</template> + +<template name="BindFramebuffer"> + <proto> + <return type="void"/> + <param name="target" type="GLenum"/> + <param name="framebuffer" type="GLuint"/> + </proto> + + <desc name="target"> + <value name="GL_FRAMEBUFFER_OES" category="OES_framebuffer_object"/> + <value name="GL_FRAMEBUFFER" category="GLES2.0"/> + </desc> +</template> + +<template name="DeleteFramebuffers"> + <proto> + <return type="void"/> + <param name="n" type="GLsizei"/> + <param name="framebuffers" type="const GLuint *"/> + </proto> +</template> + +<template name="GenFramebuffers"> + <proto> + <return type="void"/> + <param name="n" type="GLsizei"/> + <param name="ids" type="GLuint *"/> + </proto> +</template> + +<template name="BindRenderbuffer"> + <proto> + <return type="void"/> + <param name="target" type="GLenum"/> + <param name="renderbuffer" type="GLuint"/> + </proto> + + <desc name="target"> + <value name="GL_RENDERBUFFER_OES" category="OES_framebuffer_object"/> + <value name="GL_RENDERBUFFER" category="GLES2.0"/> + </desc> +</template> + +<template name="DeleteRenderbuffers"> + <proto> + <return type="void"/> + <param name="n" type="GLsizei"/> + <param name="renderbuffers" type="const GLuint *"/> + </proto> +</template> + +<template name="GenRenderbuffers"> + <proto> + <return type="void"/> + <param name="n" type="GLsizei"/> + <param name="renderbuffers" type="GLuint *"/> + </proto> +</template> + +<template name="RenderbufferStorage"> + <proto> + <return type="void"/> + <param name="target" type="GLenum"/> + <param name="internalFormat" type="GLenum"/> + <param name="width" type="GLsizei"/> + <param name="height" type="GLsizei"/> + </proto> + + <desc name="target"> + <value name="GL_RENDERBUFFER_OES" category="OES_framebuffer_object"/> + <value name="GL_RENDERBUFFER" category="GLES2.0"/> + </desc> + + <desc name="internalFormat"> + <value name="GL_DEPTH_COMPONENT16_OES" category="OES_framebuffer_object"/> + <value name="GL_RGBA4_OES" category="OES_framebuffer_object"/> + <value name="GL_RGB5_A1_OES" category="OES_framebuffer_object"/> + <value name="GL_RGB565_OES" category="OES_framebuffer_object"/> + <value name="GL_STENCIL_INDEX8_OES" category="OES_stencil8"/> + + <value name="GL_DEPTH_COMPONENT16" category="GLES2.0"/> + <value name="GL_RGBA4" category="GLES2.0"/> + <value name="GL_RGB5_A1" category="GLES2.0"/> + <value name="GL_RGB565" category="GLES2.0"/> + <value name="GL_STENCIL_INDEX8" category="GLES2.0"/> + + <value name="GL_DEPTH_COMPONENT24_OES" category="OES_depth24"/> + <value name="GL_DEPTH_COMPONENT32_OES" category="OES_depth32"/> + <value name="GL_RGB8_OES" category="OES_rgb8_rgba8"/> + <value name="GL_RGBA8_OES" category="OES_rgb8_rgba8"/> + <value name="GL_STENCIL_INDEX1_OES" category="OES_stencil1"/> + <value name="GL_STENCIL_INDEX4_OES" category="OES_stencil4"/> + <value name="GL_DEPTH24_STENCIL8_OES" category="OES_packed_depth_stencil"/> + </desc> +</template> + +<template name="FramebufferRenderbuffer"> + <proto> + <return type="void"/> + <param name="target" type="GLenum"/> + <param name="attachment" type="GLenum"/> + <param name="renderbuffertarget" type="GLenum"/> + <param name="renderbuffer" type="GLuint"/> + </proto> + + <desc name="target"> + <value name="GL_FRAMEBUFFER_OES" category="OES_framebuffer_object"/> + <value name="GL_FRAMEBUFFER" category="GLES2.0"/> + </desc> + + <desc name="attachment"> + <value name="GL_COLOR_ATTACHMENT0_OES" category="OES_framebuffer_object"/> + <value name="GL_DEPTH_ATTACHMENT_OES" category="OES_framebuffer_object"/> + <value name="GL_STENCIL_ATTACHMENT_OES" category="OES_framebuffer_object"/> + <value name="GL_COLOR_ATTACHMENT0" category="GLES2.0"/> + <value name="GL_DEPTH_ATTACHMENT" category="GLES2.0"/> + <value name="GL_STENCIL_ATTACHMENT" category="GLES2.0"/> + </desc> + + <desc name="renderbuffertarget"> + <value name="GL_RENDERBUFFER_OES" category="OES_framebuffer_object"/> + <value name="GL_RENDERBUFFER" category="GLES2.0"/> + </desc> +</template> + +<template name="FramebufferTexture2D"> + <proto> + <return type="void"/> + <param name="target" type="GLenum"/> + <param name="attachment" type="GLenum"/> + <param name="textarget" type="GLenum"/> + <param name="texture" type="GLuint"/> + <param name="level" type="GLint"/> + </proto> + + <desc name="target"> + <value name="GL_FRAMEBUFFER_OES" category="OES_framebuffer_object"/> + <value name="GL_FRAMEBUFFER" category="GLES2.0"/> + </desc> + + <desc name="attachment"> + <value name="GL_COLOR_ATTACHMENT0_OES" category="OES_framebuffer_object"/> + <value name="GL_DEPTH_ATTACHMENT_OES" category="OES_framebuffer_object"/> + <value name="GL_STENCIL_ATTACHMENT_OES" category="OES_framebuffer_object"/> + <value name="GL_COLOR_ATTACHMENT0" category="GLES2.0"/> + <value name="GL_DEPTH_ATTACHMENT" category="GLES2.0"/> + <value name="GL_STENCIL_ATTACHMENT" category="GLES2.0"/> + </desc> + + <desc name="textarget" error="GL_INVALID_OPERATION"> + <value name="GL_TEXTURE_2D"/> + <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_X" category="GLES2.0"/> + <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Y" category="GLES2.0"/> + <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Z" category="GLES2.0"/> + <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_X" category="GLES2.0"/> + <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Y" category="GLES2.0"/> + <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Z" category="GLES2.0"/> + <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_X_OES" category="OES_texture_cube_map"/> + <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Y_OES" category="OES_texture_cube_map"/> + <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Z_OES" category="OES_texture_cube_map"/> + <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_X_OES" category="OES_texture_cube_map"/> + <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_OES" category="OES_texture_cube_map"/> + <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_OES" category="OES_texture_cube_map"/> + </desc> + <!-- According to the base specification, "level" must be 0. But + extension GL_OES_fbo_render_mipmap lifts that restriction, + so no restriction is placed here. --> +</template> + +<template name="FramebufferTexture3D"> + <proto> + <return type="void"/> + <param name="target" type="GLenum"/> + <param name="attachment" type="GLenum"/> + <param name="textarget" type="GLenum"/> + <param name="texture" type="GLuint"/> + <param name="level" type="GLint"/> + <param name="zoffset" type="GLint"/> + </proto> + + <desc name="target"> + <value name="GL_FRAMEBUFFER_OES" category="OES_framebuffer_object"/> + <value name="GL_FRAMEBUFFER" category="GLES2.0"/> + </desc> + + <desc name="attachment"> + <value name="GL_COLOR_ATTACHMENT0_OES" category="OES_framebuffer_object"/> + <value name="GL_DEPTH_ATTACHMENT_OES" category="OES_framebuffer_object"/> + <value name="GL_STENCIL_ATTACHMENT_OES" category="OES_framebuffer_object"/> + <value name="GL_COLOR_ATTACHMENT0" category="GLES2.0"/> + <value name="GL_DEPTH_ATTACHMENT" category="GLES2.0"/> + <value name="GL_STENCIL_ATTACHMENT" category="GLES2.0"/> + </desc> + + <desc name="textarget" error="GL_INVALID_OPERATION"> + <value name="GL_TEXTURE_3D_OES" category="OES_texture_3D"/> + </desc> +</template> + +<template name="CheckFramebufferStatus" direction="get"> + <proto> + <return type="GLenum"/> + <param name="target" type="GLenum"/> + </proto> + + <desc name="target"> + <value name="GL_FRAMEBUFFER_OES" category="OES_framebuffer_object"/> + <value name="GL_FRAMEBUFFER" category="GLES2.0"/> + </desc> +</template> + +<template name="GetFramebufferAttachmentParameter" direction="get"> + <proto> + <return type="void"/> + <param name="target" type="GLenum"/> + <param name="attachment" type="GLenum"/> + <param name="pname" type="GLenum"/> + <vector name="params" type="GLtype *" size="dynamic"/> + </proto> + + <desc name="target"> + <value name="GL_FRAMEBUFFER_OES" category="OES_framebuffer_object"/> + <value name="GL_FRAMEBUFFER" category="GLES2.0"/> + </desc> + + <desc name="pname"> + <value name="GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_OES" category="OES_framebuffer_object"/> + <value name="GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_OES" category="OES_framebuffer_object"/> + <value name="GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_OES" category="OES_framebuffer_object"/> + <value name="GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_OES" category="OES_framebuffer_object"/> + + <value name="GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE" category="GLES2.0"/> + <value name="GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME" category="GLES2.0"/> + <value name="GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL" category="GLES2.0"/> + <value name="GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE" category="GLES2.0"/> + <value name="GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_OES" category="OES_texture_3D"/> + + <desc name="params" vector_size="1" convert="false"/> + </desc> +</template> + +<template name="GetRenderbufferParameter" direction="get"> + <proto> + <return type="void"/> + <param name="target" type="GLenum"/> + <param name="pname" type="GLenum"/> + <vector name="params" type="GLtype *" size="dynamic"/> + </proto> + + <desc name="target"> + <value name="GL_RENDERBUFFER_OES" category="OES_framebuffer_object"/> + <value name="GL_RENDERBUFFER" category="GLES2.0"/> + </desc> + + <desc name="pname" category="OES_framebuffer_object"> + <value name="GL_RENDERBUFFER_WIDTH_OES"/> + <value name="GL_RENDERBUFFER_HEIGHT_OES"/> + <value name="GL_RENDERBUFFER_INTERNAL_FORMAT_OES"/> + <value name="GL_RENDERBUFFER_RED_SIZE_OES"/> + <value name="GL_RENDERBUFFER_GREEN_SIZE_OES"/> + <value name="GL_RENDERBUFFER_BLUE_SIZE_OES"/> + <value name="GL_RENDERBUFFER_ALPHA_SIZE_OES"/> + <value name="GL_RENDERBUFFER_DEPTH_SIZE_OES"/> + <value name="GL_RENDERBUFFER_STENCIL_SIZE_OES"/> + + <desc name="params" vector_size="1" convert="false"/> + </desc> + + <desc name="pname" category="GLES2.0"> + <value name="GL_RENDERBUFFER_WIDTH"/> + <value name="GL_RENDERBUFFER_HEIGHT"/> + <value name="GL_RENDERBUFFER_INTERNAL_FORMAT"/> + <value name="GL_RENDERBUFFER_RED_SIZE"/> + <value name="GL_RENDERBUFFER_GREEN_SIZE"/> + <value name="GL_RENDERBUFFER_BLUE_SIZE"/> + <value name="GL_RENDERBUFFER_ALPHA_SIZE"/> + <value name="GL_RENDERBUFFER_DEPTH_SIZE"/> + <value name="GL_RENDERBUFFER_STENCIL_SIZE"/> + + <desc name="params" vector_size="1" convert="false"/> + </desc> +</template> + +<template name="IsRenderbuffer" direction="get"> + <proto> + <return type="GLboolean"/> + <param name="renderbuffer" type="GLuint"/> + </proto> +</template> + +<template name="IsFramebuffer" direction="get"> + <proto> + <return type="GLboolean"/> + <param name="framebuffer" type="GLuint"/> + </proto> +</template> + +<template name="IsShader" direction="get"> + <proto> + <return type="GLboolean"/> + <param name="shader" type="GLuint"/> + </proto> +</template> + +<template name="GetShader" direction="get"> + <proto> + <return type="void"/> + <param name="shader" type="GLuint"/> + <param name="pname" type="GLenum"/> + <vector name="params" type="GLtype *" size="dynamic"/> + </proto> + + <desc name="pname"> + <value name="GL_SHADER_TYPE"/> + <value name="GL_COMPILE_STATUS"/> + <value name="GL_DELETE_STATUS"/> + <value name="GL_INFO_LOG_LENGTH"/> + <value name="GL_SHADER_SOURCE_LENGTH"/> + </desc> +</template> + +<template name="GetAttachedShaders" direction="get"> + <proto> + <return type="void"/> + <param name="program" type="GLuint"/> + <param name="maxCount" type="GLsizei"/> + <param name="count" type="GLsizei *"/> + <param name="shaders" type="GLuint *"/> + </proto> +</template> + +<template name="GetShaderInfoLog" direction="get"> + <proto> + <return type="void"/> + <param name="shader" type="GLuint"/> + <param name="bufSize" type="GLsizei"/> + <param name="length" type="GLsizei *"/> + <param name="infoLog" type="GLchar *"/> + </proto> +</template> + +<template name="GetProgramInfoLog" direction="get"> + <proto> + <return type="void"/> + <param name="program" type="GLuint"/> + <param name="bufSize" type="GLsizei"/> + <param name="length" type="GLsizei *"/> + <param name="infoLog" type="GLchar *"/> + </proto> +</template> + +<template name="GetShaderSource" direction="get"> + <proto> + <return type="void"/> + <param name="shader" type="GLuint"/> + <param name="bufSize" type="GLsizei"/> + <param name="length" type="GLsizei *"/> + <param name="source" type="GLchar *"/> + </proto> +</template> + +<template name="GetShaderPrecisionFormat" direction="get"> + <proto> + <return type="void"/> + <param name="shadertype" type="GLenum"/> + <param name="precisiontype" type="GLenum"/> + <param name="range" type="GLint *"/> + <param name="precision" type="GLint *"/> + </proto> + + <desc name="shadertype"> + <value name="GL_VERTEX_SHADER"/> + <value name="GL_FRAGMENT_SHADER"/> + </desc> + + <desc name="precisiontype"> + <value name="GL_LOW_FLOAT"/> + <value name="GL_MEDIUM_FLOAT"/> + <value name="GL_HIGH_FLOAT"/> + <value name="GL_LOW_INT"/> + <value name="GL_MEDIUM_INT"/> + <value name="GL_HIGH_INT"/> + </desc> +</template> + +<template name="GetUniform" direction="get"> + <proto> + <return type="void"/> + <param name="program" type="GLuint"/> + <param name="location" type="GLint"/> + <vector name="params" type="GLtype *" size="dynamic"/> + </proto> +</template> + +<template name="QueryMatrix" direction="get"> + <proto> + <return type="GLbitfield"/> + <vector name="mantissa" type="GLtype *" size="16"/> + <vector name="exponent" type="GLint *" size="16"/> + </proto> +</template> + +<template name="DrawTex"> + <proto> + <return type="void"/> + <vector name="coords" type="const GLtype *" size="5"> + <param name="x" type="GLtype"/> + <param name="y" type="GLtype"/> + <param name="z" type="GLtype"/> + <param name="w" type="GLtype"/> + <param name="h" type="GLtype"/> + </vector> + </proto> +</template> + +<template name="MultiDrawArrays"> + <proto> + <return type="void"/> + <param name="mode" type="GLenum"/> + <param name="first" type="const GLint *"/> + <param name="count" type="const GLsizei *"/> + <param name="primcount" type="GLsizei"/> + </proto> + + <desc name="mode"> + <value name="GL_POINTS"/> + <value name="GL_LINES"/> + <value name="GL_LINE_LOOP"/> + <value name="GL_LINE_STRIP"/> + <value name="GL_TRIANGLES"/> + <value name="GL_TRIANGLE_STRIP"/> + <value name="GL_TRIANGLE_FAN"/> + </desc> +</template> + +<template name="MultiDrawElements"> + <proto> + <return type="void"/> + <param name="mode" type="GLenum"/> + <param name="count" type="const GLsizei *"/> + <param name="type" type="GLenum"/> + <param name="indices" type="const GLvoid **"/> + <param name="primcount" type="GLsizei"/> + </proto> + + <desc name="mode"> + <value name="GL_POINTS"/> + <value name="GL_LINES"/> + <value name="GL_LINE_LOOP"/> + <value name="GL_LINE_STRIP"/> + <value name="GL_TRIANGLES"/> + <value name="GL_TRIANGLE_STRIP"/> + <value name="GL_TRIANGLE_FAN"/> + </desc> + + <desc name="type"> + <value name="GL_UNSIGNED_BYTE"/> + <value name="GL_UNSIGNED_SHORT"/> + <value name="GL_UNSIGNED_INT" category="OES_element_index_uint"/> + </desc> +</template> + +<template name="EGLImageTargetTexture2D"> + <proto> + <return type="void"/> + <param name="target" type="GLenum"/> + <param name="image" type="GLeglImageOES"/> + </proto> + + <desc name="target"> + <value name="GL_TEXTURE_2D"/> + </desc> +</template> + +<template name="EGLImageTargetRenderbufferStorage"> + <proto> + <return type="void"/> + <param name="target" type="GLenum"/> + <param name="image" type="GLeglImageOES"/> + </proto> + + <desc name="target"> + <value name="GL_RENDERBUFFER_OES" category="OES_framebuffer_object"/> + <value name="GL_RENDERBUFFER" category="GLES2.0"/> + </desc> +</template> + +<api name="mesa" implementation="true"> + <category name="MESA"/> + + <function name="Color4f" default_prefix="_es_" template="Color" gltype="GLfloat" vector_size="4" expand_vector="true"/> + <function name="ClipPlane" template="ClipPlane" gltype="GLdouble"/> + <function name="CullFace" template="CullFace"/> + + <function name="Fogf" template="Fog" gltype="GLfloat" expand_vector="true"/> + <function name="Fogfv" template="Fog" gltype="GLfloat"/> + + <function name="FrontFace" template="FrontFace"/> + <function name="Hint" template="Hint"/> + + <function name="Lightf" template="Light" gltype="GLfloat" expand_vector="true"/> + <function name="Lightfv" template="Light" gltype="GLfloat"/> + + <function name="LightModelf" template="LightModel" gltype="GLfloat" expand_vector="true"/> + <function name="LightModelfv" template="LightModel" gltype="GLfloat"/> + + <function name="LineWidth" template="LineWidth" gltype="GLfloat"/> + + <function name="Materialf" default_prefix="_es_" template="Material" gltype="GLfloat" expand_vector="true"/> + <function name="Materialfv" default_prefix="_es_" template="Material" gltype="GLfloat"/> + + <function name="PointSize" template="PointSize" gltype="GLfloat"/> + <function name="PointSizePointer" template="PointSizePointer"/> + + <function name="Scissor" template="Scissor"/> + <function name="ShadeModel" template="ShadeModel"/> + + <function name="TexParameterf" template="TexParameter" gltype="GLfloat" expand_vector="true"/> + <function name="TexParameterfv" template="TexParameter" gltype="GLfloat"/> + <function name="TexParameteri" template="TexParameter" gltype="GLint" expand_vector="true"/> + <function name="TexParameteriv" template="TexParameter" gltype="GLint"/> + + <function name="TexImage2D" template="TexImage2D"/> + + <function name="TexEnvf" template="TexEnv" gltype="GLfloat" expand_vector="true"/> + <function name="TexEnvi" template="TexEnv" gltype="GLint" expand_vector="true"/> + <function name="TexEnvfv" template="TexEnv" gltype="GLfloat"/> + <function name="TexEnviv" template="TexEnv" gltype="GLint"/> + + <function name="TexGenf" template="TexGen" gltype="GLfloat" expand_vector="true"/> + <function name="TexGenfv" template="TexGen" gltype="GLfloat"/> + + <function name="Clear" template="Clear"/> + <function name="ClearColor" template="ClearColor" gltype="GLclampf"/> + <function name="ClearStencil" template="ClearStencil"/> + <function name="ClearDepth" template="ClearDepth" gltype="GLclampd"/> + <function name="ClearDepthf" template="ClearDepth" gltype="GLclampf"/> + + <function name="StencilMask" template="StencilMask"/> + <function name="StencilMaskSeparate" template="StencilMaskSeparate"/> + <function name="ColorMask" template="ColorMask"/> + <function name="DepthMask" template="DepthMask"/> + <function name="Disable" template="Disable"/> + <function name="Enable" template="Enable"/> + <function name="Finish" template="Finish"/> + <function name="Flush" template="Flush"/> + + <function name="AlphaFunc" template="AlphaFunc" gltype="GLclampf"/> + + <function name="BlendFunc" template="BlendFunc"/> + <function name="LogicOp" template="LogicOp"/> + <function name="StencilFunc" template="StencilFunc"/> + <function name="StencilFuncSeparate" template="StencilFuncSeparate"/> + <function name="StencilOp" template="StencilOp"/> + <function name="StencilOpSeparate" template="StencilOpSeparate"/> + <function name="DepthFunc" template="DepthFunc"/> + <function name="PixelStorei" template="PixelStore" gltype="GLint"/> + + <function name="ReadPixels" template="ReadPixels"/> + <function name="GetBooleanv" template="GetState" gltype="GLboolean"/> + <function name="GetClipPlane" template="GetClipPlane" gltype="GLdouble"/> + <function name="GetError" template="GetError"/> + <function name="GetFloatv" template="GetState" gltype="GLfloat"/> + <function name="GetFixedv" template="GetState" gltype="GLfixed"/> + <function name="GetIntegerv" template="GetState" gltype="GLint"/> + + <function name="GetLightfv" template="GetLight" gltype="GLfloat"/> + <function name="GetMaterialfv" template="GetMaterial" gltype="GLfloat"/> + <function name="GetMaterialiv" template="GetMaterial" gltype="GLint"/> + + <function name="GetString" template="GetString"/> + + <function name="GetTexEnvfv" template="GetTexEnv" gltype="GLfloat"/> + <function name="GetTexEnviv" template="GetTexEnv" gltype="GLint"/> + <function name="GetTexGenfv" template="GetTexGen" gltype="GLfloat"/> + <function name="GetTexParameterfv" template="GetTexParameter" gltype="GLfloat"/> + <function name="GetTexParameteriv" template="GetTexParameter" gltype="GLint"/> + + <function name="IsEnabled" template="IsEnabled"/> + + <function name="DepthRange" template="DepthRange" gltype="GLclampd"/> + <function name="DepthRangef" template="DepthRange" gltype="GLclampf"/> + <function name="Frustum" template="Frustum" gltype="GLdouble"/> + + <function name="LoadIdentity" template="LoadIdentity"/> + <function name="LoadMatrixf" template="LoadMatrix" gltype="GLfloat"/> + <function name="MatrixMode" template="MatrixMode"/> + + <function name="MultMatrixf" template="MultMatrix" gltype="GLfloat"/> + <function name="Ortho" template="Ortho" gltype="GLdouble"/> + <function name="PopMatrix" template="PopMatrix"/> + <function name="PushMatrix" template="PushMatrix"/> + + <function name="Rotatef" template="Rotate" gltype="GLfloat"/> + <function name="Scalef" template="Scale" gltype="GLfloat"/> + <function name="Translatef" template="Translate" gltype="GLfloat"/> + + <function name="Viewport" template="Viewport"/> + + <function name="ColorPointer" template="ColorPointer"/> + <function name="DisableClientState" template="DisableClientState"/> + <function name="DrawArrays" template="DrawArrays"/> + <function name="DrawElements" template="DrawElements"/> + <function name="EnableClientState" template="EnableClientState"/> + + <function name="GetPointerv" template="GetPointer"/> + <function name="Normal3f" default_prefix="_es_" template="Normal" gltype="GLfloat" expand_vector="true"/> + <function name="NormalPointer" template="NormalPointer"/> + <function name="TexCoordPointer" template="TexCoordPointer"/> + <function name="VertexPointer" template="VertexPointer"/> + + <function name="PolygonOffset" template="PolygonOffset" gltype="GLfloat"/> + <function name="CopyTexImage2D" template="CopyTexImage2D"/> + <function name="CopyTexSubImage2D" template="CopyTexSubImage2D"/> + <function name="TexSubImage2D" template="TexSubImage2D"/> + + <function name="BindTexture" template="BindTexture"/> + <function name="DeleteTextures" template="DeleteTextures"/> + <function name="GenTextures" template="GenTextures"/> + <function name="IsTexture" template="IsTexture"/> + + <function name="BlendColor" template="BlendColor" gltype="GLclampf"/> + <function name="BlendEquation" template="BlendEquation"/> + <function name="BlendEquationSeparateEXT" template="BlendEquationSeparate"/> + + <function name="TexImage3D" template="TexImage3D"/> + <function name="TexSubImage3D" template="TexSubImage3D"/> + <function name="CopyTexSubImage3D" template="CopyTexSubImage3D"/> + + <function name="CompressedTexImage3DARB" template="CompressedTexImage3D"/> + <function name="CompressedTexSubImage3DARB" template="CompressedTexSubImage3D"/> + + <function name="ActiveTextureARB" template="ActiveTexture"/> + <function name="ClientActiveTextureARB" template="ClientActiveTexture"/> + + <function name="MultiTexCoord4f" default_prefix="_es_" template="MultiTexCoord" gltype="GLfloat" vector_size="4" expand_vector="true"/> + + <function name="SampleCoverageARB" template="SampleCoverage" gltype="GLclampf"/> + + <function name="CompressedTexImage2DARB" template="CompressedTexImage2D"/> + <function name="CompressedTexSubImage2DARB" template="CompressedTexSubImage2D"/> + + <function name="BlendFuncSeparateEXT" template="BlendFuncSeparate"/> + + <function name="PointParameterf" template="PointParameter" gltype="GLfloat" expand_vector="true"/> + <function name="PointParameterfv" template="PointParameter" gltype="GLfloat"/> + + <function name="VertexAttrib1f" default_prefix="_es_" template="VertexAttrib" gltype="GLfloat" vector_size="1" expand_vector="true"/> + <function name="VertexAttrib2f" default_prefix="_es_" template="VertexAttrib" gltype="GLfloat" vector_size="2" expand_vector="true"/> + <function name="VertexAttrib3f" default_prefix="_es_" template="VertexAttrib" gltype="GLfloat" vector_size="3" expand_vector="true"/> + <function name="VertexAttrib4f" default_prefix="_es_" template="VertexAttrib" gltype="GLfloat" vector_size="4" expand_vector="true"/> + <function name="VertexAttrib1fv" default_prefix="_es_" template="VertexAttrib" gltype="GLfloat" vector_size="1"/> + <function name="VertexAttrib2fv" default_prefix="_es_" template="VertexAttrib" gltype="GLfloat" vector_size="2"/> + <function name="VertexAttrib3fv" default_prefix="_es_" template="VertexAttrib" gltype="GLfloat" vector_size="3"/> + <function name="VertexAttrib4fv" default_prefix="_es_" template="VertexAttrib" gltype="GLfloat" vector_size="4"/> + + <function name="VertexAttribPointerARB" template="VertexAttribPointer"/> + <function name="EnableVertexAttribArrayARB" template="EnableVertexAttribArray"/> + <function name="DisableVertexAttribArrayARB" template="DisableVertexAttribArray"/> + + <function name="IsProgram" template="IsProgram"/> + <function name="GetProgramiv" template="GetProgram" gltype="GLint"/> + + <function name="GetVertexAttribfvARB" template="GetVertexAttrib" gltype="GLfloat"/> + <function name="GetVertexAttribivARB" template="GetVertexAttrib" gltype="GLint"/> + <function name="GetVertexAttribPointervARB" template="GetVertexAttribPointer"/> + + <function name="GetBufferPointervARB" template="GetBufferPointer"/> + <function name="MapBufferARB" template="MapBuffer"/> + <function name="UnmapBufferARB" template="UnmapBuffer"/> + <function name="BindBufferARB" template="BindBuffer"/> + <function name="BufferDataARB" template="BufferData"/> + <function name="BufferSubDataARB" template="BufferSubData"/> + <function name="DeleteBuffersARB" template="DeleteBuffers"/> + <function name="GenBuffersARB" template="GenBuffers"/> + <function name="GetBufferParameterivARB" template="GetBufferParameter" gltype="GLint"/> + <function name="IsBufferARB" template="IsBuffer"/> + + <function name="CreateShader" template="CreateShader"/> + <function name="ShaderSourceARB" template="ShaderSource"/> + <function name="CompileShaderARB" template="CompileShader"/> + <function name="ReleaseShaderCompiler" template="ReleaseShaderCompiler"/> + <function name="DeleteShader" template="DeleteShader"/> + <function name="ShaderBinary" template="ShaderBinary"/> + <function name="CreateProgram" template="CreateProgram"/> + <function name="AttachShader" template="AttachShader"/> + <function name="DetachShader" template="DetachShader"/> + <function name="LinkProgramARB" template="LinkProgram"/> + <function name="UseProgramObjectARB" template="UseProgram"/> + <function name="DeleteProgram" template="DeleteProgram"/> + + <function name="GetActiveAttribARB" template="GetActiveAttrib"/> + <function name="GetAttribLocationARB" template="GetAttribLocation"/> + <function name="BindAttribLocationARB" template="BindAttribLocation"/> + <function name="GetUniformLocationARB" template="GetUniformLocation"/> + <function name="GetActiveUniformARB" template="GetActiveUniform"/> + + <function name="Uniform1fARB" template="Uniform" gltype="GLfloat" vector_size="1" expand_vector="true"/> + <function name="Uniform2fARB" template="Uniform" gltype="GLfloat" vector_size="2" expand_vector="true"/> + <function name="Uniform3fARB" template="Uniform" gltype="GLfloat" vector_size="3" expand_vector="true"/> + <function name="Uniform4fARB" template="Uniform" gltype="GLfloat" vector_size="4" expand_vector="true"/> + <function name="Uniform1iARB" template="Uniform" gltype="GLint" vector_size="1" expand_vector="true"/> + <function name="Uniform2iARB" template="Uniform" gltype="GLint" vector_size="2" expand_vector="true"/> + <function name="Uniform3iARB" template="Uniform" gltype="GLint" vector_size="3" expand_vector="true"/> + <function name="Uniform4iARB" template="Uniform" gltype="GLint" vector_size="4" expand_vector="true"/> + <function name="Uniform1fvARB" template="Uniform" gltype="GLfloat" vector_size="1"/> + <function name="Uniform2fvARB" template="Uniform" gltype="GLfloat" vector_size="2"/> + <function name="Uniform3fvARB" template="Uniform" gltype="GLfloat" vector_size="3"/> + <function name="Uniform4fvARB" template="Uniform" gltype="GLfloat" vector_size="4"/> + <function name="Uniform1ivARB" template="Uniform" gltype="GLint" vector_size="1"/> + <function name="Uniform2ivARB" template="Uniform" gltype="GLint" vector_size="2"/> + <function name="Uniform3ivARB" template="Uniform" gltype="GLint" vector_size="3"/> + <function name="Uniform4ivARB" template="Uniform" gltype="GLint" vector_size="4"/> + + <function name="UniformMatrix2fvARB" template="UniformMatrix" gltype="GLfloat" vector_size="2"/> + <function name="UniformMatrix3fvARB" template="UniformMatrix" gltype="GLfloat" vector_size="3"/> + <function name="UniformMatrix4fvARB" template="UniformMatrix" gltype="GLfloat" vector_size="4"/> + + <function name="ValidateProgramARB" template="ValidateProgram"/> + + <function name="GenerateMipmapEXT" template="GenerateMipmap"/> + <function name="BindFramebufferEXT" template="BindFramebuffer"/> + <function name="DeleteFramebuffersEXT" template="DeleteFramebuffers"/> + <function name="GenFramebuffersEXT" template="GenFramebuffers"/> + <function name="BindRenderbufferEXT" template="BindRenderbuffer"/> + <function name="DeleteRenderbuffersEXT" template="DeleteRenderbuffers"/> + <function name="GenRenderbuffersEXT" template="GenRenderbuffers"/> + <function name="RenderbufferStorageEXT" template="RenderbufferStorage"/> + <function name="FramebufferRenderbufferEXT" template="FramebufferRenderbuffer"/> + <function name="FramebufferTexture2DEXT" template="FramebufferTexture2D"/> + <function name="FramebufferTexture3DEXT" template="FramebufferTexture3D"/> + <function name="CheckFramebufferStatusEXT" template="CheckFramebufferStatus"/> + <function name="GetFramebufferAttachmentParameterivEXT" template="GetFramebufferAttachmentParameter" gltype="GLint"/> + <function name="GetRenderbufferParameterivEXT" template="GetRenderbufferParameter" gltype="GLint"/> + <function name="IsRenderbufferEXT" template="IsRenderbuffer"/> + <function name="IsFramebufferEXT" template="IsFramebuffer"/> + + <function name="IsShader" template="IsShader"/> + <function name="GetShaderiv" template="GetShader" gltype="GLint"/> + <function name="GetAttachedShaders" template="GetAttachedShaders"/> + <function name="GetShaderInfoLog" template="GetShaderInfoLog"/> + <function name="GetProgramInfoLog" template="GetProgramInfoLog"/> + <function name="GetShaderSourceARB" template="GetShaderSource"/> + <function name="GetShaderPrecisionFormat" template="GetShaderPrecisionFormat"/> + <function name="GetUniformfvARB" template="GetUniform" gltype="GLfloat"/> + <function name="GetUniformivARB" template="GetUniform" gltype="GLint"/> + + <function name="DrawTexf" template="DrawTex" gltype="GLfloat" expand_vector="true"/> + <function name="DrawTexfv" template="DrawTex" gltype="GLfloat"/> + <function name="DrawTexi" template="DrawTex" gltype="GLint" expand_vector="true"/> + <function name="DrawTexiv" template="DrawTex" gltype="GLint"/> + <function name="DrawTexs" template="DrawTex" gltype="GLshort" expand_vector="true"/> + <function name="DrawTexsv" template="DrawTex" gltype="GLshort"/> + + <!-- EXT_multi_draw_arrays --> + <function name="MultiDrawArraysEXT" template="MultiDrawArrays"/> + <function name="MultiDrawElementsEXT" template="MultiDrawElements"/> + + <!-- OES_EGL_image --> + <function name="EGLImageTargetTexture2DOES" template="EGLImageTargetTexture2D"/> + <function name="EGLImageTargetRenderbufferStorageOES" template="EGLImageTargetRenderbufferStorage"/> +</api> + +<api name="GLES1.1"> + <category name="GLES1.1"/> + + <category name="OES_byte_coordinates"/> + <category name="OES_fixed_point"/> + <category name="OES_single_precision"/> + <category name="OES_matrix_get"/> + <category name="OES_read_format"/> + <category name="OES_compressed_paletted_texture"/> + <category name="OES_point_size_array"/> + <category name="OES_point_sprite"/> + <category name="OES_query_matrix"/> + <category name="OES_draw_texture"/> + <category name="OES_blend_equation_separate"/> + <category name="OES_blend_func_separate"/> + <category name="OES_blend_subtract"/> + <category name="OES_stencil_wrap"/> + <category name="OES_texture_cube_map"/> + <category name="OES_texture_env_crossbar"/> + <category name="OES_texture_mirrored_repeat"/> + <category name="OES_framebuffer_object"/> + <category name="OES_depth24"/> + <category name="OES_depth32"/> + <category name="OES_fbo_render_mipmap"/> + <category name="OES_rgb8_rgba8"/> + <category name="OES_stencil1"/> + <category name="OES_stencil4"/> + <category name="OES_stencil8"/> + <category name="OES_element_index_uint"/> + <category name="OES_mapbuffer"/> + <category name="EXT_texture_filter_anisotropic"/> + + <category name="ARB_texture_non_power_of_two"/> + <!-- disabled due to missing enums + <category name="EXT_texture_compression_dxt1"/> + --> + <category name="EXT_texture_lod_bias"/> + <category name="EXT_blend_minmax"/> + <category name="EXT_multi_draw_arrays"/> + <category name="OES_EGL_image"/> + + <category name="OES_matrix_palette"/> + + <function name="Color4f" external="true" template="Color" gltype="GLfloat" vector_size="4" expand_vector="true"/> + <function name="Color4ub" template="Color" gltype="GLubyte" vector_size="4" expand_vector="true"/> + <function name="Color4x" template="Color" gltype="GLfixed" vector_size="4" expand_vector="true"/> + + <function name="ClipPlanef" template="ClipPlane" gltype="GLfloat"/> + <function name="ClipPlanex" template="ClipPlane" gltype="GLfixed"/> + + <function name="CullFace" template="CullFace"/> + + <function name="Fogf" template="Fog" gltype="GLfloat" expand_vector="true"/> + <function name="Fogx" template="Fog" gltype="GLfixed" expand_vector="true"/> + <function name="Fogfv" template="Fog" gltype="GLfloat"/> + <function name="Fogxv" template="Fog" gltype="GLfixed"/> + + <function name="FrontFace" template="FrontFace"/> + <function name="Hint" template="Hint"/> + + <function name="Lightf" template="Light" gltype="GLfloat" expand_vector="true"/> + <function name="Lightx" template="Light" gltype="GLfixed" expand_vector="true"/> + <function name="Lightfv" template="Light" gltype="GLfloat"/> + <function name="Lightxv" template="Light" gltype="GLfixed"/> + + <function name="LightModelf" template="LightModel" gltype="GLfloat" expand_vector="true"/> + <function name="LightModelx" template="LightModel" gltype="GLfixed" expand_vector="true"/> + <function name="LightModelfv" template="LightModel" gltype="GLfloat"/> + <function name="LightModelxv" template="LightModel" gltype="GLfixed"/> + + <function name="LineWidth" template="LineWidth" gltype="GLfloat"/> + <function name="LineWidthx" template="LineWidth" gltype="GLfixed"/> + + <function name="Materialf" external="true" template="Material" gltype="GLfloat" expand_vector="true"/> + <function name="Materialfv" external="true" template="Material" gltype="GLfloat"/> + <function name="Materialx" template="Material" gltype="GLfixed" expand_vector="true"/> + <function name="Materialxv" template="Material" gltype="GLfixed"/> + + <function name="PointSize" template="PointSize" gltype="GLfloat"/> + <function name="PointSizex" template="PointSize" gltype="GLfixed"/> + <function name="PointSizePointerOES" template="PointSizePointer"/> + + <function name="Scissor" template="Scissor"/> + <function name="ShadeModel" template="ShadeModel"/> + + <function name="TexParameterf" template="TexParameter" gltype="GLfloat" expand_vector="true"/> + <function name="TexParameterfv" template="TexParameter" gltype="GLfloat"/> + <function name="TexParameteri" template="TexParameter" gltype="GLint" expand_vector="true"/> + <function name="TexParameteriv" template="TexParameter" gltype="GLint"/> + <function name="TexParameterx" template="TexParameter" gltype="GLfixed" expand_vector="true"/> + <function name="TexParameterxv" template="TexParameter" gltype="GLfixed"/> + + <function name="TexImage2D" template="TexImage2D"/> + + <function name="TexEnvf" template="TexEnv" gltype="GLfloat" expand_vector="true"/> + <function name="TexEnvfv" template="TexEnv" gltype="GLfloat"/> + <function name="TexEnvi" template="TexEnv" gltype="GLint" expand_vector="true"/> + <function name="TexEnviv" template="TexEnv" gltype="GLint"/> + <function name="TexEnvx" template="TexEnv" gltype="GLfixed" expand_vector="true"/> + <function name="TexEnvxv" template="TexEnv" gltype="GLfixed"/> + + <function name="TexGenfOES" external="true" template="TexGen" gltype="GLfloat" expand_vector="true"/> + <function name="TexGenfvOES" external="true" template="TexGen" gltype="GLfloat"/> + <function name="TexGeniOES" external="true" template="TexGen" gltype="GLint" expand_vector="true"/> + <function name="TexGenivOES" external="true" template="TexGen" gltype="GLint"/> + <function name="TexGenxOES" external="true" template="TexGen" gltype="GLfixed" expand_vector="true"/> + <function name="TexGenxvOES" external="true" template="TexGen" gltype="GLfixed"/> + + <function name="Clear" template="Clear"/> + <function name="ClearColor" template="ClearColor" gltype="GLclampf"/> + <function name="ClearColorx" template="ClearColor" gltype="GLclampx"/> + + <function name="ClearStencil" template="ClearStencil"/> + <function name="ClearDepthf" template="ClearDepth" gltype="GLclampf"/> + <function name="ClearDepthx" template="ClearDepth" gltype="GLclampx"/> + + <function name="StencilMask" template="StencilMask"/> + <function name="ColorMask" template="ColorMask"/> + <function name="DepthMask" template="DepthMask"/> + + <function name="Disable" template="Disable"/> + <function name="Enable" template="Enable"/> + <function name="Finish" template="Finish"/> + <function name="Flush" template="Flush"/> + + <function name="AlphaFunc" template="AlphaFunc" gltype="GLclampf"/> + <function name="AlphaFuncx" template="AlphaFunc" gltype="GLclampx"/> + + <function name="BlendFunc" template="BlendFunc"/> + <function name="LogicOp" template="LogicOp"/> + <function name="StencilFunc" template="StencilFunc"/> + + <function name="StencilOp" template="StencilOp"/> + <function name="DepthFunc" template="DepthFunc"/> + + <function name="PixelStorei" template="PixelStore" gltype="GLint"/> + <function name="ReadPixels" template="ReadPixels"/> + + <function name="GetBooleanv" template="GetState" gltype="GLboolean"/> + + <function name="GetClipPlanef" template="GetClipPlane" gltype="GLfloat"/> + <function name="GetClipPlanex" template="GetClipPlane" gltype="GLfixed"/> + + <function name="GetError" template="GetError"/> + <function name="GetFloatv" template="GetState" gltype="GLfloat"/> + <function name="GetFixedv" template="GetState" gltype="GLfixed"/> + <function name="GetIntegerv" template="GetState" gltype="GLint"/> + + <function name="GetLightfv" template="GetLight" gltype="GLfloat"/> + <function name="GetLightxv" template="GetLight" gltype="GLfixed"/> + + <function name="GetMaterialfv" template="GetMaterial" gltype="GLfloat"/> + <function name="GetMaterialxv" template="GetMaterial" gltype="GLfixed"/> + + <function name="GetString" template="GetString"/> + + <function name="GetTexEnvfv" template="GetTexEnv" gltype="GLfloat"/> + <function name="GetTexEnviv" template="GetTexEnv" gltype="GLint"/> + <function name="GetTexEnvxv" template="GetTexEnv" gltype="GLfixed"/> + + <function name="GetTexGenfvOES" external="true" template="GetTexGen" gltype="GLfloat"/> + <function name="GetTexGenivOES" external="true" template="GetTexGen" gltype="GLint"/> + <function name="GetTexGenxvOES" external="true" template="GetTexGen" gltype="GLfixed"/> + + <function name="GetTexParameterfv" template="GetTexParameter" gltype="GLfloat"/> + <function name="GetTexParameteriv" template="GetTexParameter" gltype="GLint"/> + <function name="GetTexParameterxv" template="GetTexParameter" gltype="GLfixed"/> + + <function name="IsEnabled" template="IsEnabled"/> + + <function name="DepthRangef" template="DepthRange" gltype="GLclampf"/> + <function name="DepthRangex" template="DepthRange" gltype="GLclampx"/> + + <function name="Frustumf" template="Frustum" gltype="GLfloat"/> + <function name="Frustumx" template="Frustum" gltype="GLfixed"/> + + <function name="LoadIdentity" template="LoadIdentity"/> + <function name="LoadMatrixf" template="LoadMatrix" gltype="GLfloat"/> + <function name="LoadMatrixx" template="LoadMatrix" gltype="GLfixed"/> + <function name="MatrixMode" template="MatrixMode"/> + + <function name="MultMatrixf" template="MultMatrix" gltype="GLfloat"/> + <function name="MultMatrixx" template="MultMatrix" gltype="GLfixed"/> + <function name="Orthof" template="Ortho" gltype="GLfloat"/> + <function name="Orthox" template="Ortho" gltype="GLfixed"/> + + <function name="PopMatrix" template="PopMatrix"/> + <function name="PushMatrix" template="PushMatrix"/> + + <function name="Rotatef" template="Rotate" gltype="GLfloat"/> + <function name="Rotatex" template="Rotate" gltype="GLfixed"/> + <function name="Scalef" template="Scale" gltype="GLfloat"/> + <function name="Scalex" template="Scale" gltype="GLfixed"/> + <function name="Translatef" template="Translate" gltype="GLfloat"/> + <function name="Translatex" template="Translate" gltype="GLfixed"/> + + <function name="Viewport" template="Viewport"/> + <function name="ColorPointer" template="ColorPointer"/> + <function name="DisableClientState" template="DisableClientState"/> + <function name="DrawArrays" template="DrawArrays"/> + <function name="DrawElements" template="DrawElements"/> + <function name="EnableClientState" template="EnableClientState"/> + + <function name="GetPointerv" template="GetPointer"/> + + <function name="Normal3f" external="true" template="Normal" gltype="GLfloat" expand_vector="true"/> + <function name="Normal3x" template="Normal" gltype="GLfixed" expand_vector="true"/> + <function name="NormalPointer" template="NormalPointer"/> + <function name="TexCoordPointer" template="TexCoordPointer"/> + <function name="VertexPointer" template="VertexPointer"/> + + <function name="PolygonOffset" template="PolygonOffset" gltype="GLfloat"/> + <function name="PolygonOffsetx" template="PolygonOffset" gltype="GLfixed"/> + + <function name="CopyTexImage2D" template="CopyTexImage2D"/> + <function name="CopyTexSubImage2D" template="CopyTexSubImage2D"/> + + <function name="TexSubImage2D" template="TexSubImage2D"/> + + <function name="BindTexture" template="BindTexture"/> + <function name="DeleteTextures" template="DeleteTextures"/> + <function name="GenTextures" template="GenTextures"/> + <function name="IsTexture" template="IsTexture"/> + + <function name="BlendEquationOES" template="BlendEquation"/> + <function name="BlendEquationSeparateOES" template="BlendEquationSeparate"/> + + <function name="MultiTexCoord4x" template="MultiTexCoord" gltype="GLfixed" vector_size="4" expand_vector="true"/> + + <function name="ActiveTexture" template="ActiveTexture"/> + <function name="ClientActiveTexture" template="ClientActiveTexture"/> + + <function name="MultiTexCoord4f" external="true" template="MultiTexCoord" gltype="GLfloat" vector_size="4" expand_vector="true"/> + + <function name="SampleCoverage" template="SampleCoverage" gltype="GLclampf"/> + <function name="SampleCoveragex" template="SampleCoverage" gltype="GLclampx"/> + + <!-- CompressedTexImage2D calls out to two different functions based on + whether the image is a paletted image or not --> + <function name="CompressedTexImage2D" template="CompressedTexImage2D"/> + <function name="CompressedTexSubImage2D" template="CompressedTexSubImage2D"/> + + <function name="BlendFuncSeparateOES" template="BlendFuncSeparate"/> + + <function name="PointParameterf" template="PointParameter" gltype="GLfloat" expand_vector="true"/> + <function name="PointParameterfv" template="PointParameter" gltype="GLfloat"/> + <function name="PointParameterx" template="PointParameter" gltype="GLfixed" expand_vector="true"/> + <function name="PointParameterxv" template="PointParameter" gltype="GLfixed"/> + + <!-- OES_mapbuffer --> + <function name="GetBufferPointervOES" template="GetBufferPointer"/> + <function name="MapBufferOES" template="MapBuffer"/> + <function name="UnmapBufferOES" template="UnmapBuffer"/> + + <function name="BindBuffer" template="BindBuffer"/> + <function name="BufferData" template="BufferData"/> + <function name="BufferSubData" template="BufferSubData"/> + <function name="DeleteBuffers" template="DeleteBuffers"/> + <function name="GenBuffers" template="GenBuffers"/> + <function name="GetBufferParameteriv" template="GetBufferParameter" gltype="GLint"/> + <function name="IsBuffer" template="IsBuffer"/> + + <!-- OES_framebuffer_object --> + <function name="GenerateMipmapOES" template="GenerateMipmap"/> + <function name="BindFramebufferOES" template="BindFramebuffer"/> + <function name="DeleteFramebuffersOES" template="DeleteFramebuffers"/> + <function name="GenFramebuffersOES" template="GenFramebuffers"/> + <function name="BindRenderbufferOES" template="BindRenderbuffer"/> + <function name="DeleteRenderbuffersOES" template="DeleteRenderbuffers"/> + <function name="GenRenderbuffersOES" template="GenRenderbuffers"/> + <function name="RenderbufferStorageOES" external="true" template="RenderbufferStorage"/> + <function name="FramebufferRenderbufferOES" template="FramebufferRenderbuffer"/> + <function name="FramebufferTexture2DOES" template="FramebufferTexture2D"/> + <function name="CheckFramebufferStatusOES" template="CheckFramebufferStatus"/> + <function name="GetFramebufferAttachmentParameterivOES" template="GetFramebufferAttachmentParameter" gltype="GLint"/> + <function name="GetRenderbufferParameterivOES" template="GetRenderbufferParameter" gltype="GLint"/> + <function name="IsRenderbufferOES" template="IsRenderbuffer"/> + <function name="IsFramebufferOES" template="IsFramebuffer"/> + + <!-- OES_query_matrix --> + <!-- QueryMatrixx returns values in an unusual, decomposed, fixed-value + form; it has its own code for this --> + <function name="QueryMatrixxOES" external="true" template="QueryMatrix" gltype="GLfixed"/> + + <!-- OES_draw_texture --> + <function name="DrawTexfOES" template="DrawTex" gltype="GLfloat" expand_vector="true"/> + <function name="DrawTexiOES" template="DrawTex" gltype="GLint" expand_vector="true"/> + <function name="DrawTexsOES" template="DrawTex" gltype="GLshort" expand_vector="true"/> + <function name="DrawTexxOES" template="DrawTex" gltype="GLfixed" expand_vector="true"/> + <function name="DrawTexfvOES" template="DrawTex" gltype="GLfloat"/> + <function name="DrawTexivOES" template="DrawTex" gltype="GLint"/> + <function name="DrawTexsvOES" template="DrawTex" gltype="GLshort"/> + <function name="DrawTexxvOES" template="DrawTex" gltype="GLfixed"/> + + <!-- EXT_multi_draw_arrays --> + <function name="MultiDrawArraysEXT" template="MultiDrawArrays"/> + <function name="MultiDrawElementsEXT" template="MultiDrawElements"/> + + <!-- OES_EGL_image --> + <function name="EGLImageTargetTexture2DOES" template="EGLImageTargetTexture2D"/> + <function name="EGLImageTargetRenderbufferStorageOES" template="EGLImageTargetRenderbufferStorage"/> +</api> + +<api name="GLES2.0"> + <category name="GLES2.0"/> + + <category name="OES_compressed_paletted_texture"/> + <category name="OES_depth24"/> + <category name="OES_depth32"/> + <category name="OES_fbo_render_mipmap"/> + <category name="OES_rgb8_rgba8"/> + <category name="OES_stencil1"/> + <category name="OES_stencil4"/> + <category name="OES_element_index_uint"/> + <category name="OES_mapbuffer"/> + <category name="OES_texture_3D"/> + <category name="OES_texture_npot"/> + <category name="EXT_texture_filter_anisotropic"/> + <category name="EXT_texture_type_2_10_10_10_REV"/> + <category name="OES_depth_texture"/> + <category name="OES_packed_depth_stencil"/> + <category name="OES_standard_derivatives"/> + <category name="EXT_texture_format_BGRA8888"/> + + <category name="EXT_texture_compression_dxt1"/> + <category name="EXT_blend_minmax"/> + <category name="EXT_multi_draw_arrays"/> + <category name="OES_EGL_image"/> + + <function name="CullFace" template="CullFace"/> + + <function name="FrontFace" template="FrontFace"/> + <function name="Hint" template="Hint"/> + + <function name="LineWidth" template="LineWidth" gltype="GLfloat"/> + + <function name="Scissor" template="Scissor"/> + + <function name="TexParameterf" template="TexParameter" gltype="GLfloat" expand_vector="true"/> + <function name="TexParameterfv" template="TexParameter" gltype="GLfloat"/> + <function name="TexParameteri" template="TexParameter" gltype="GLint" expand_vector="true"/> + <function name="TexParameteriv" template="TexParameter" gltype="GLint"/> + + <function name="TexImage2D" template="TexImage2D"/> + + <function name="Clear" template="Clear"/> + <function name="ClearColor" template="ClearColor" gltype="GLclampf"/> + <function name="ClearStencil" template="ClearStencil"/> + <function name="ClearDepthf" template="ClearDepth" gltype="GLclampf"/> + + <function name="StencilMask" template="StencilMask"/> + <function name="StencilMaskSeparate" template="StencilMaskSeparate"/> + <function name="ColorMask" template="ColorMask"/> + <function name="DepthMask" template="DepthMask"/> + <function name="Disable" template="Disable"/> + <function name="Enable" template="Enable"/> + <function name="Finish" template="Finish"/> + <function name="Flush" template="Flush"/> + + <function name="BlendFunc" template="BlendFunc"/> + + <function name="StencilFunc" template="StencilFunc"/> + <function name="StencilFuncSeparate" template="StencilFuncSeparate"/> + <function name="StencilOp" template="StencilOp"/> + <function name="StencilOpSeparate" template="StencilOpSeparate"/> + + <function name="DepthFunc" template="DepthFunc"/> + + <function name="PixelStorei" template="PixelStore" gltype="GLint"/> + <function name="ReadPixels" template="ReadPixels"/> + + <function name="GetBooleanv" template="GetState" gltype="GLboolean"/> + <function name="GetError" template="GetError"/> + <function name="GetFloatv" template="GetState" gltype="GLfloat"/> + <function name="GetIntegerv" template="GetState" gltype="GLint"/> + + <function name="GetString" template="GetString"/> + + <function name="GetTexParameterfv" template="GetTexParameter" gltype="GLfloat"/> + <function name="GetTexParameteriv" template="GetTexParameter" gltype="GLint"/> + + <function name="IsEnabled" template="IsEnabled"/> + + <function name="DepthRangef" template="DepthRange" gltype="GLclampf"/> + + <function name="Viewport" template="Viewport"/> + + <function name="DrawArrays" template="DrawArrays"/> + <function name="DrawElements" template="DrawElements"/> + + <function name="PolygonOffset" template="PolygonOffset" gltype="GLfloat"/> + <function name="CopyTexImage2D" template="CopyTexImage2D"/> + <function name="CopyTexSubImage2D" template="CopyTexSubImage2D"/> + <function name="TexSubImage2D" template="TexSubImage2D"/> + + <function name="BindTexture" template="BindTexture"/> + <function name="DeleteTextures" template="DeleteTextures"/> + <function name="GenTextures" template="GenTextures"/> + <function name="IsTexture" template="IsTexture"/> + + <function name="BlendColor" template="BlendColor" gltype="GLclampf"/> + <function name="BlendEquation" template="BlendEquation"/> + <function name="BlendEquationSeparate" template="BlendEquationSeparate"/> + + <function name="TexImage3DOES" template="TexImage3D"/> + <function name="TexSubImage3DOES" template="TexSubImage3D"/> + <function name="CopyTexSubImage3DOES" template="CopyTexSubImage3D"/> + + <function name="CompressedTexImage3DOES" template="CompressedTexImage3D"/> + <function name="CompressedTexSubImage3DOES" template="CompressedTexSubImage3D"/> + + <function name="ActiveTexture" template="ActiveTexture"/> + + <function name="SampleCoverage" template="SampleCoverage" gltype="GLclampf"/> + + <function name="CompressedTexImage2D" template="CompressedTexImage2D"/> + <function name="CompressedTexSubImage2D" template="CompressedTexSubImage2D"/> + + <function name="BlendFuncSeparate" template="BlendFuncSeparate"/> + + <function name="VertexAttrib1f" external="true" template="VertexAttrib" gltype="GLfloat" vector_size="1" expand_vector="true"/> + <function name="VertexAttrib2f" external="true" template="VertexAttrib" gltype="GLfloat" vector_size="2" expand_vector="true"/> + <function name="VertexAttrib3f" external="true" template="VertexAttrib" gltype="GLfloat" vector_size="3" expand_vector="true"/> + <function name="VertexAttrib4f" external="true" template="VertexAttrib" gltype="GLfloat" vector_size="4" expand_vector="true"/> + <function name="VertexAttrib1fv" external="true" template="VertexAttrib" gltype="GLfloat" vector_size="1"/> + <function name="VertexAttrib2fv" external="true" template="VertexAttrib" gltype="GLfloat" vector_size="2"/> + <function name="VertexAttrib3fv" external="true" template="VertexAttrib" gltype="GLfloat" vector_size="3"/> + <function name="VertexAttrib4fv" external="true" template="VertexAttrib" gltype="GLfloat" vector_size="4"/> + + <function name="VertexAttribPointer" template="VertexAttribPointer"/> + + <function name="EnableVertexAttribArray" template="EnableVertexAttribArray"/> + <function name="DisableVertexAttribArray" template="DisableVertexAttribArray"/> + + <function name="IsProgram" template="IsProgram"/> + <function name="GetProgramiv" template="GetProgram" gltype="GLint"/> + + <function name="GetVertexAttribfv" template="GetVertexAttrib" gltype="GLfloat"/> + <function name="GetVertexAttribiv" template="GetVertexAttrib" gltype="GLint"/> + <function name="GetVertexAttribPointerv" template="GetVertexAttribPointer"/> + + <function name="GetBufferPointervOES" template="GetBufferPointer"/> + <function name="MapBufferOES" template="MapBuffer"/> + <function name="UnmapBufferOES" template="UnmapBuffer"/> + <function name="BindBuffer" template="BindBuffer"/> + <function name="BufferData" template="BufferData"/> + <function name="BufferSubData" template="BufferSubData"/> + <function name="DeleteBuffers" template="DeleteBuffers"/> + <function name="GenBuffers" template="GenBuffers"/> + <function name="GetBufferParameteriv" template="GetBufferParameter" gltype="GLint"/> + <function name="IsBuffer" template="IsBuffer"/> + + <function name="CreateShader" template="CreateShader"/> + <function name="ShaderSource" template="ShaderSource"/> + <function name="CompileShader" template="CompileShader"/> + <function name="ReleaseShaderCompiler" template="ReleaseShaderCompiler"/> + <function name="DeleteShader" template="DeleteShader"/> + <function name="ShaderBinary" template="ShaderBinary"/> + <function name="CreateProgram" template="CreateProgram"/> + <function name="AttachShader" template="AttachShader"/> + <function name="DetachShader" template="DetachShader"/> + <function name="LinkProgram" template="LinkProgram"/> + <function name="UseProgram" template="UseProgram"/> + <function name="DeleteProgram" template="DeleteProgram"/> + + <function name="GetActiveAttrib" template="GetActiveAttrib"/> + <function name="GetAttribLocation" template="GetAttribLocation"/> + <function name="BindAttribLocation" template="BindAttribLocation"/> + <function name="GetUniformLocation" template="GetUniformLocation"/> + <function name="GetActiveUniform" template="GetActiveUniform"/> + + <function name="Uniform1f" template="Uniform" gltype="GLfloat" vector_size="1" expand_vector="true"/> + <function name="Uniform2f" template="Uniform" gltype="GLfloat" vector_size="2" expand_vector="true"/> + <function name="Uniform3f" template="Uniform" gltype="GLfloat" vector_size="3" expand_vector="true"/> + <function name="Uniform4f" template="Uniform" gltype="GLfloat" vector_size="4" expand_vector="true"/> + <function name="Uniform1i" template="Uniform" gltype="GLint" vector_size="1" expand_vector="true"/> + <function name="Uniform2i" template="Uniform" gltype="GLint" vector_size="2" expand_vector="true"/> + <function name="Uniform3i" template="Uniform" gltype="GLint" vector_size="3" expand_vector="true"/> + <function name="Uniform4i" template="Uniform" gltype="GLint" vector_size="4" expand_vector="true"/> + + <function name="Uniform1fv" template="Uniform" gltype="GLfloat" vector_size="1"/> + <function name="Uniform2fv" template="Uniform" gltype="GLfloat" vector_size="2"/> + <function name="Uniform3fv" template="Uniform" gltype="GLfloat" vector_size="3"/> + <function name="Uniform4fv" template="Uniform" gltype="GLfloat" vector_size="4"/> + <function name="Uniform1iv" template="Uniform" gltype="GLint" vector_size="1"/> + <function name="Uniform2iv" template="Uniform" gltype="GLint" vector_size="2"/> + <function name="Uniform3iv" template="Uniform" gltype="GLint" vector_size="3"/> + <function name="Uniform4iv" template="Uniform" gltype="GLint" vector_size="4"/> + + <function name="UniformMatrix2fv" template="UniformMatrix" gltype="GLfloat" vector_size="2"/> + <function name="UniformMatrix3fv" template="UniformMatrix" gltype="GLfloat" vector_size="3"/> + <function name="UniformMatrix4fv" template="UniformMatrix" gltype="GLfloat" vector_size="4"/> + + <function name="ValidateProgram" template="ValidateProgram"/> + + <function name="GenerateMipmap" template="GenerateMipmap"/> + <function name="BindFramebuffer" template="BindFramebuffer"/> + <function name="DeleteFramebuffers" template="DeleteFramebuffers"/> + <function name="GenFramebuffers" template="GenFramebuffers"/> + <function name="BindRenderbuffer" template="BindRenderbuffer"/> + <function name="DeleteRenderbuffers" template="DeleteRenderbuffers"/> + <function name="GenRenderbuffers" template="GenRenderbuffers"/> + <function name="RenderbufferStorage" external="true" template="RenderbufferStorage"/> + <function name="FramebufferRenderbuffer" template="FramebufferRenderbuffer"/> + <function name="FramebufferTexture2D" template="FramebufferTexture2D"/> + <function name="FramebufferTexture3DOES" template="FramebufferTexture3D"/> + <function name="CheckFramebufferStatus" template="CheckFramebufferStatus"/> + <function name="GetFramebufferAttachmentParameteriv" template="GetFramebufferAttachmentParameter" gltype="GLint"/> + <function name="GetRenderbufferParameteriv" template="GetRenderbufferParameter" gltype="GLint"/> + <function name="IsRenderbuffer" template="IsRenderbuffer"/> + <function name="IsFramebuffer" template="IsFramebuffer"/> + + <function name="IsShader" template="IsShader"/> + <function name="GetShaderiv" template="GetShader" gltype="GLint"/> + <function name="GetAttachedShaders" template="GetAttachedShaders"/> + <function name="GetShaderInfoLog" template="GetShaderInfoLog"/> + <function name="GetProgramInfoLog" template="GetProgramInfoLog"/> + <function name="GetShaderSource" template="GetShaderSource"/> + <function name="GetShaderPrecisionFormat" template="GetShaderPrecisionFormat"/> + <function name="GetUniformfv" template="GetUniform" gltype="GLfloat"/> + <function name="GetUniformiv" template="GetUniform" gltype="GLint"/> + + <!-- EXT_multi_draw_arrays --> + <function name="MultiDrawArraysEXT" template="MultiDrawArrays"/> + <function name="MultiDrawElementsEXT" template="MultiDrawElements"/> + + <!-- OES_EGL_image --> + <function name="EGLImageTargetTexture2DOES" template="EGLImageTargetTexture2D"/> + <function name="EGLImageTargetRenderbufferStorageOES" template="EGLImageTargetRenderbufferStorage"/> +</api> + +</apispec> diff --git a/mesalib/src/mesa/main/fbobject.c b/mesalib/src/mesa/main/fbobject.c index 17c629544..2fe84754b 100644 --- a/mesalib/src/mesa/main/fbobject.c +++ b/mesalib/src/mesa/main/fbobject.c @@ -373,6 +373,37 @@ _mesa_framebuffer_renderbuffer(struct gl_context *ctx, /** + * Fallback for ctx->Driver.ValidateFramebuffer() + * Check if the renderbuffer's formats are supported by the software + * renderer. + * Drivers should probably override this. + */ +void +_mesa_validate_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb) +{ + gl_buffer_index buf; + for (buf = 0; buf < BUFFER_COUNT; buf++) { + const struct gl_renderbuffer *rb = fb->Attachment[buf].Renderbuffer; + if (rb) { + switch (rb->_BaseFormat) { + case GL_ALPHA: + case GL_LUMINANCE_ALPHA: + case GL_LUMINANCE: + case GL_INTENSITY: + case GL_RED: + case GL_RG: + fb->_Status = GL_FRAMEBUFFER_UNSUPPORTED; + return; + default: + /* render buffer format is supported by software rendering */ + ; + } + } + } +} + + +/** * For debug only. */ static void @@ -960,42 +991,104 @@ _mesa_GenRenderbuffersEXT(GLsizei n, GLuint *renderbuffers) /** - * Given an internal format token for a renderbuffer, return the - * corresponding base format. + * Given an internal format token for a render buffer, return the + * corresponding base format (one of GL_RGB, GL_RGBA, GL_STENCIL_INDEX, + * GL_DEPTH_COMPONENT, GL_DEPTH_STENCIL_EXT, GL_ALPHA, GL_LUMINANCE, + * GL_LUMINANCE_ALPHA, GL_INTENSITY, etc). + * + * This is similar to _mesa_base_tex_format() but the set of valid + * internal formats is different. + * + * Note that even if a format is determined to be legal here, validation + * of the FBO may fail if the format is not suppoted by the driver/GPU. + * + * \param internalFormat as passed to glRenderbufferStorage() + * \return the base internal format, or 0 if internalFormat is illegal */ GLenum _mesa_base_fbo_format(struct gl_context *ctx, GLenum internalFormat) { - GLenum baseFormat; - + /* + * Notes: some formats such as alpha, luminance, etc. were added + * with GL_ARB_framebuffer_object. + */ switch (internalFormat) { + case GL_ALPHA: + case GL_ALPHA4: + case GL_ALPHA8: + case GL_ALPHA12: + case GL_ALPHA16: + return ctx->Extensions.ARB_framebuffer_object ? GL_ALPHA : 0; + case GL_LUMINANCE: + case GL_LUMINANCE4: + case GL_LUMINANCE8: + case GL_LUMINANCE12: + case GL_LUMINANCE16: + return ctx->Extensions.ARB_framebuffer_object ? GL_LUMINANCE : 0; + case GL_LUMINANCE_ALPHA: + case GL_LUMINANCE4_ALPHA4: + case GL_LUMINANCE6_ALPHA2: + case GL_LUMINANCE8_ALPHA8: + case GL_LUMINANCE12_ALPHA4: + case GL_LUMINANCE12_ALPHA12: + case GL_LUMINANCE16_ALPHA16: + return ctx->Extensions.ARB_framebuffer_object ? GL_LUMINANCE_ALPHA : 0; + case GL_INTENSITY: + case GL_INTENSITY4: + case GL_INTENSITY8: + case GL_INTENSITY12: + case GL_INTENSITY16: + return ctx->Extensions.ARB_framebuffer_object ? GL_INTENSITY : 0; + case GL_RGB: + case GL_R3_G3_B2: + case GL_RGB4: + case GL_RGB5: + case GL_RGB8: + case GL_RGB10: + case GL_RGB12: + case GL_RGB16: + case GL_SRGB8_EXT: + return GL_RGB; + case GL_RGBA: + case GL_RGBA2: + case GL_RGBA4: + case GL_RGB5_A1: + case GL_RGBA8: + case GL_RGB10_A2: + case GL_RGBA12: + case GL_RGBA16: case GL_RGBA16_SNORM: - /* This is used internally by Mesa for accum buffers. */ + case GL_SRGB8_ALPHA8_EXT: return GL_RGBA; case GL_STENCIL_INDEX: case GL_STENCIL_INDEX1_EXT: case GL_STENCIL_INDEX4_EXT: case GL_STENCIL_INDEX8_EXT: case GL_STENCIL_INDEX16_EXT: - /* This is not a valid texture internalFormat, but valid for - * renderbuffers. - */ return GL_STENCIL_INDEX; case GL_DEPTH_COMPONENT: case GL_DEPTH_COMPONENT16: case GL_DEPTH_COMPONENT24: case GL_DEPTH_COMPONENT32: - /* This is an override of _mesa_base_tex_format's check that - * ARB_depth_texture is present. We allow depth RBs without it. - */ return GL_DEPTH_COMPONENT; - } - - baseFormat = _mesa_base_tex_format(ctx, internalFormat); - if (baseFormat < 0) + case GL_DEPTH_STENCIL_EXT: + case GL_DEPTH24_STENCIL8_EXT: + if (ctx->Extensions.EXT_packed_depth_stencil) + return GL_DEPTH_STENCIL_EXT; + else + return 0; + case GL_RED: + case GL_R8: + case GL_R16: + return ctx->Extensions.ARB_texture_rg ? GL_RED : 0; + case GL_RG: + case GL_RG8: + case GL_RG16: + return ctx->Extensions.ARB_texture_rg ? GL_RG : 0; + /* XXX add floating point and integer formats eventually */ + default: return 0; - - return baseFormat; + } } @@ -1031,14 +1124,6 @@ renderbuffer_storage(GLenum target, GLenum internalFormat, return; } - if (baseFormat != GL_DEPTH_COMPONENT && - baseFormat != GL_STENCIL_INDEX && - baseFormat != GL_DEPTH_STENCIL && - !_mesa_is_legal_color_format(ctx, baseFormat)) { - _mesa_error(ctx, GL_INVALID_ENUM, "%s(internalFormat)", func); - return; - } - if (width < 1 || width > (GLsizei) ctx->Const.MaxRenderbufferSize) { _mesa_error(ctx, GL_INVALID_VALUE, "%s(width)", func); return; diff --git a/mesalib/src/mesa/main/fbobject.h b/mesalib/src/mesa/main/fbobject.h index 0e0e348a6..ba74a95b7 100644 --- a/mesalib/src/mesa/main/fbobject.h +++ b/mesalib/src/mesa/main/fbobject.h @@ -1,171 +1,174 @@ -/*
- * Mesa 3-D graphics library
- * Version: 7.1
- *
- * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-
-#ifndef FBOBJECT_H
-#define FBOBJECT_H
-
-#include "glheader.h"
-
-struct gl_context;
-struct gl_texture_object;
-
-extern void
-_mesa_init_fbobjects(struct gl_context *ctx);
-
-extern struct gl_framebuffer *
-_mesa_get_incomplete_framebuffer(void);
-
-extern struct gl_renderbuffer *
-_mesa_lookup_renderbuffer(struct gl_context *ctx, GLuint id);
-
-extern struct gl_framebuffer *
-_mesa_lookup_framebuffer(struct gl_context *ctx, GLuint id);
-
-extern struct gl_renderbuffer_attachment *
-_mesa_get_attachment(struct gl_context *ctx, struct gl_framebuffer *fb,
- GLenum attachment);
-
-
-extern void
-_mesa_remove_attachment(struct gl_context *ctx,
- struct gl_renderbuffer_attachment *att);
-
-extern void
-_mesa_set_texture_attachment(struct gl_context *ctx,
- struct gl_framebuffer *fb,
- struct gl_renderbuffer_attachment *att,
- struct gl_texture_object *texObj,
- GLenum texTarget, GLuint level, GLuint zoffset);
-
-extern void
-_mesa_set_renderbuffer_attachment(struct gl_context *ctx,
- struct gl_renderbuffer_attachment *att,
- struct gl_renderbuffer *rb);
-
-extern void
-_mesa_framebuffer_renderbuffer(struct gl_context *ctx, struct gl_framebuffer *fb,
- GLenum attachment, struct gl_renderbuffer *rb);
-
-extern void
-_mesa_test_framebuffer_completeness(struct gl_context *ctx, struct gl_framebuffer *fb);
-
-extern GLboolean
-_mesa_is_legal_color_format(const struct gl_context *ctx, GLenum baseFormat);
-
-extern GLenum
-_mesa_base_fbo_format(struct gl_context *ctx, GLenum internalFormat);
-
-extern GLboolean GLAPIENTRY
-_mesa_IsRenderbufferEXT(GLuint renderbuffer);
-
-extern void GLAPIENTRY
-_mesa_BindRenderbufferEXT(GLenum target, GLuint renderbuffer);
-
-extern void GLAPIENTRY
-_mesa_DeleteRenderbuffersEXT(GLsizei n, const GLuint *renderbuffers);
-
-extern void GLAPIENTRY
-_mesa_GenRenderbuffersEXT(GLsizei n, GLuint *renderbuffers);
-
-extern void GLAPIENTRY
-_mesa_RenderbufferStorageEXT(GLenum target, GLenum internalformat,
- GLsizei width, GLsizei height);
-
-extern void GLAPIENTRY
-_mesa_RenderbufferStorageMultisample(GLenum target, GLsizei samples,
- GLenum internalformat,
- GLsizei width, GLsizei height);
-
-extern void GLAPIENTRY
-_es_RenderbufferStorageEXT(GLenum target, GLenum internalFormat,
- GLsizei width, GLsizei height);
-
-extern void GLAPIENTRY
-_mesa_EGLImageTargetRenderbufferStorageOES(GLenum target, GLeglImageOES image);
-
-extern void GLAPIENTRY
-_mesa_GetRenderbufferParameterivEXT(GLenum target, GLenum pname,
- GLint *params);
-
-extern GLboolean GLAPIENTRY
-_mesa_IsFramebufferEXT(GLuint framebuffer);
-
-extern void GLAPIENTRY
-_mesa_BindFramebufferEXT(GLenum target, GLuint framebuffer);
-
-extern void GLAPIENTRY
-_mesa_DeleteFramebuffersEXT(GLsizei n, const GLuint *framebuffers);
-
-extern void GLAPIENTRY
-_mesa_GenFramebuffersEXT(GLsizei n, GLuint *framebuffers);
-
-extern GLenum GLAPIENTRY
-_mesa_CheckFramebufferStatusEXT(GLenum target);
-
-extern void GLAPIENTRY
-_mesa_FramebufferTexture1DEXT(GLenum target, GLenum attachment,
- GLenum textarget, GLuint texture, GLint level);
-
-extern void GLAPIENTRY
-_mesa_FramebufferTexture2DEXT(GLenum target, GLenum attachment,
- GLenum textarget, GLuint texture, GLint level);
-
-extern void GLAPIENTRY
-_mesa_FramebufferTexture3DEXT(GLenum target, GLenum attachment,
- GLenum textarget, GLuint texture,
- GLint level, GLint zoffset);
-
-extern void GLAPIENTRY
-_mesa_FramebufferTextureLayerEXT(GLenum target, GLenum attachment,
- GLuint texture, GLint level, GLint layer);
-
-extern void GLAPIENTRY
-_mesa_FramebufferRenderbufferEXT(GLenum target, GLenum attachment,
- GLenum renderbuffertarget,
- GLuint renderbuffer);
-
-extern void GLAPIENTRY
-_mesa_GetFramebufferAttachmentParameterivEXT(GLenum target, GLenum attachment,
- GLenum pname, GLint *params);
-
-extern void GLAPIENTRY
-_mesa_GenerateMipmapEXT(GLenum target);
-
-
-extern void GLAPIENTRY
-_mesa_BlitFramebufferEXT(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
- GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
- GLbitfield mask, GLenum filter);
-
-extern void GLAPIENTRY
-_mesa_FramebufferTextureARB(GLenum target, GLenum attachment,
- GLuint texture, GLint level);
-
-extern void GLAPIENTRY
-_mesa_FramebufferTextureFaceARB(GLenum target, GLenum attachment,
- GLuint texture, GLint level, GLenum face);
-
-
-#endif /* FBOBJECT_H */
+/* + * Mesa 3-D graphics library + * Version: 7.1 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#ifndef FBOBJECT_H +#define FBOBJECT_H + +#include "glheader.h" + +struct gl_context; +struct gl_texture_object; + +extern void +_mesa_init_fbobjects(struct gl_context *ctx); + +extern struct gl_framebuffer * +_mesa_get_incomplete_framebuffer(void); + +extern struct gl_renderbuffer * +_mesa_lookup_renderbuffer(struct gl_context *ctx, GLuint id); + +extern struct gl_framebuffer * +_mesa_lookup_framebuffer(struct gl_context *ctx, GLuint id); + +extern struct gl_renderbuffer_attachment * +_mesa_get_attachment(struct gl_context *ctx, struct gl_framebuffer *fb, + GLenum attachment); + + +extern void +_mesa_remove_attachment(struct gl_context *ctx, + struct gl_renderbuffer_attachment *att); + +extern void +_mesa_set_texture_attachment(struct gl_context *ctx, + struct gl_framebuffer *fb, + struct gl_renderbuffer_attachment *att, + struct gl_texture_object *texObj, + GLenum texTarget, GLuint level, GLuint zoffset); + +extern void +_mesa_set_renderbuffer_attachment(struct gl_context *ctx, + struct gl_renderbuffer_attachment *att, + struct gl_renderbuffer *rb); + +extern void +_mesa_framebuffer_renderbuffer(struct gl_context *ctx, struct gl_framebuffer *fb, + GLenum attachment, struct gl_renderbuffer *rb); + +extern void +_mesa_validate_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb); + +extern void +_mesa_test_framebuffer_completeness(struct gl_context *ctx, struct gl_framebuffer *fb); + +extern GLboolean +_mesa_is_legal_color_format(const struct gl_context *ctx, GLenum baseFormat); + +extern GLenum +_mesa_base_fbo_format(struct gl_context *ctx, GLenum internalFormat); + +extern GLboolean GLAPIENTRY +_mesa_IsRenderbufferEXT(GLuint renderbuffer); + +extern void GLAPIENTRY +_mesa_BindRenderbufferEXT(GLenum target, GLuint renderbuffer); + +extern void GLAPIENTRY +_mesa_DeleteRenderbuffersEXT(GLsizei n, const GLuint *renderbuffers); + +extern void GLAPIENTRY +_mesa_GenRenderbuffersEXT(GLsizei n, GLuint *renderbuffers); + +extern void GLAPIENTRY +_mesa_RenderbufferStorageEXT(GLenum target, GLenum internalformat, + GLsizei width, GLsizei height); + +extern void GLAPIENTRY +_mesa_RenderbufferStorageMultisample(GLenum target, GLsizei samples, + GLenum internalformat, + GLsizei width, GLsizei height); + +extern void GLAPIENTRY +_es_RenderbufferStorageEXT(GLenum target, GLenum internalFormat, + GLsizei width, GLsizei height); + +extern void GLAPIENTRY +_mesa_EGLImageTargetRenderbufferStorageOES(GLenum target, GLeglImageOES image); + +extern void GLAPIENTRY +_mesa_GetRenderbufferParameterivEXT(GLenum target, GLenum pname, + GLint *params); + +extern GLboolean GLAPIENTRY +_mesa_IsFramebufferEXT(GLuint framebuffer); + +extern void GLAPIENTRY +_mesa_BindFramebufferEXT(GLenum target, GLuint framebuffer); + +extern void GLAPIENTRY +_mesa_DeleteFramebuffersEXT(GLsizei n, const GLuint *framebuffers); + +extern void GLAPIENTRY +_mesa_GenFramebuffersEXT(GLsizei n, GLuint *framebuffers); + +extern GLenum GLAPIENTRY +_mesa_CheckFramebufferStatusEXT(GLenum target); + +extern void GLAPIENTRY +_mesa_FramebufferTexture1DEXT(GLenum target, GLenum attachment, + GLenum textarget, GLuint texture, GLint level); + +extern void GLAPIENTRY +_mesa_FramebufferTexture2DEXT(GLenum target, GLenum attachment, + GLenum textarget, GLuint texture, GLint level); + +extern void GLAPIENTRY +_mesa_FramebufferTexture3DEXT(GLenum target, GLenum attachment, + GLenum textarget, GLuint texture, + GLint level, GLint zoffset); + +extern void GLAPIENTRY +_mesa_FramebufferTextureLayerEXT(GLenum target, GLenum attachment, + GLuint texture, GLint level, GLint layer); + +extern void GLAPIENTRY +_mesa_FramebufferRenderbufferEXT(GLenum target, GLenum attachment, + GLenum renderbuffertarget, + GLuint renderbuffer); + +extern void GLAPIENTRY +_mesa_GetFramebufferAttachmentParameterivEXT(GLenum target, GLenum attachment, + GLenum pname, GLint *params); + +extern void GLAPIENTRY +_mesa_GenerateMipmapEXT(GLenum target); + + +extern void GLAPIENTRY +_mesa_BlitFramebufferEXT(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, + GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, + GLbitfield mask, GLenum filter); + +extern void GLAPIENTRY +_mesa_FramebufferTextureARB(GLenum target, GLenum attachment, + GLuint texture, GLint level); + +extern void GLAPIENTRY +_mesa_FramebufferTextureFaceARB(GLenum target, GLenum attachment, + GLuint texture, GLint level, GLenum face); + + +#endif /* FBOBJECT_H */ diff --git a/mesalib/src/mesa/main/renderbuffer.c b/mesalib/src/mesa/main/renderbuffer.c index 0b51ac123..67ee589d7 100644 --- a/mesalib/src/mesa/main/renderbuffer.c +++ b/mesalib/src/mesa/main/renderbuffer.c @@ -1,2010 +1,2010 @@ -/*
- * Mesa 3-D graphics library
- * Version: 6.5
- *
- * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-
-/**
- * Functions for allocating/managing renderbuffers.
- * Also, routines for reading/writing software-based renderbuffer data as
- * ubytes, ushorts, uints, etc.
- *
- * The 'alpha8' renderbuffer is interesting. It's used to add a software-based
- * alpha channel to RGB renderbuffers. This is done by wrapping the RGB
- * renderbuffer with the alpha renderbuffer. We can do this because of the
- * OO-nature of renderbuffers.
- *
- * Down the road we'll use this for run-time support of 8, 16 and 32-bit
- * color channels. For example, Mesa may use 32-bit/float color channels
- * internally (swrast) and use wrapper renderbuffers to convert 32-bit
- * values down to 16 or 8-bit values for whatever kind of framebuffer we have.
- */
-
-
-#include "glheader.h"
-#include "imports.h"
-#include "context.h"
-#include "fbobject.h"
-#include "formats.h"
-#include "mtypes.h"
-#include "renderbuffer.h"
-
-
-/*
- * Routines for get/put values in common buffer formats follow.
- * Someday add support for arbitrary row stride to make them more
- * flexible.
- */
-
-/**********************************************************************
- * Functions for buffers of 1 X GLubyte values.
- * Typically stencil.
- */
-
-static void *
-get_pointer_ubyte(struct gl_context *ctx, struct gl_renderbuffer *rb,
- GLint x, GLint y)
-{
- if (!rb->Data)
- return NULL;
- ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
- /* Can't assert rb->Format since these funcs may be used for serveral
- * different formats (GL_ALPHA8, GL_STENCIL_INDEX8, etc).
- */
- return (GLubyte *) rb->Data + y * rb->Width + x;
-}
-
-
-static void
-get_row_ubyte(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- GLint x, GLint y, void *values)
-{
- const GLubyte *src = (const GLubyte *) rb->Data + y * rb->Width + x;
- ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
- memcpy(values, src, count * sizeof(GLubyte));
-}
-
-
-static void
-get_values_ubyte(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- const GLint x[], const GLint y[], void *values)
-{
- GLubyte *dst = (GLubyte *) values;
- GLuint i;
- ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
- for (i = 0; i < count; i++) {
- const GLubyte *src = (GLubyte *) rb->Data + y[i] * rb->Width + x[i];
- dst[i] = *src;
- }
-}
-
-
-static void
-put_row_ubyte(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- GLint x, GLint y, const void *values, const GLubyte *mask)
-{
- const GLubyte *src = (const GLubyte *) values;
- GLubyte *dst = (GLubyte *) rb->Data + y * rb->Width + x;
- ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
- if (mask) {
- GLuint i;
- for (i = 0; i < count; i++) {
- if (mask[i]) {
- dst[i] = src[i];
- }
- }
- }
- else {
- memcpy(dst, values, count * sizeof(GLubyte));
- }
-}
-
-
-static void
-put_mono_row_ubyte(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- GLint x, GLint y, const void *value, const GLubyte *mask)
-{
- const GLubyte val = *((const GLubyte *) value);
- GLubyte *dst = (GLubyte *) rb->Data + y * rb->Width + x;
- ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
- if (mask) {
- GLuint i;
- for (i = 0; i < count; i++) {
- if (mask[i]) {
- dst[i] = val;
- }
- }
- }
- else {
- GLuint i;
- for (i = 0; i < count; i++) {
- dst[i] = val;
- }
- }
-}
-
-
-static void
-put_values_ubyte(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- const GLint x[], const GLint y[],
- const void *values, const GLubyte *mask)
-{
- const GLubyte *src = (const GLubyte *) values;
- GLuint i;
- ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- GLubyte *dst = (GLubyte *) rb->Data + y[i] * rb->Width + x[i];
- *dst = src[i];
- }
- }
-}
-
-
-static void
-put_mono_values_ubyte(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- const GLint x[], const GLint y[],
- const void *value, const GLubyte *mask)
-{
- const GLubyte val = *((const GLubyte *) value);
- GLuint i;
- ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- GLubyte *dst = (GLubyte *) rb->Data + y[i] * rb->Width + x[i];
- *dst = val;
- }
- }
-}
-
-
-/**********************************************************************
- * Functions for buffers of 1 X GLushort values.
- * Typically depth/Z.
- */
-
-static void *
-get_pointer_ushort(struct gl_context *ctx, struct gl_renderbuffer *rb,
- GLint x, GLint y)
-{
- if (!rb->Data)
- return NULL;
- ASSERT(rb->DataType == GL_UNSIGNED_SHORT);
- ASSERT(rb->Width > 0);
- return (GLushort *) rb->Data + y * rb->Width + x;
-}
-
-
-static void
-get_row_ushort(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- GLint x, GLint y, void *values)
-{
- const void *src = rb->GetPointer(ctx, rb, x, y);
- ASSERT(rb->DataType == GL_UNSIGNED_SHORT);
- memcpy(values, src, count * sizeof(GLushort));
-}
-
-
-static void
-get_values_ushort(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- const GLint x[], const GLint y[], void *values)
-{
- GLushort *dst = (GLushort *) values;
- GLuint i;
- ASSERT(rb->DataType == GL_UNSIGNED_SHORT);
- for (i = 0; i < count; i++) {
- const GLushort *src = (GLushort *) rb->Data + y[i] * rb->Width + x[i];
- dst[i] = *src;
- }
-}
-
-
-static void
-put_row_ushort(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- GLint x, GLint y, const void *values, const GLubyte *mask)
-{
- const GLushort *src = (const GLushort *) values;
- GLushort *dst = (GLushort *) rb->Data + y * rb->Width + x;
- ASSERT(rb->DataType == GL_UNSIGNED_SHORT);
- if (mask) {
- GLuint i;
- for (i = 0; i < count; i++) {
- if (mask[i]) {
- dst[i] = src[i];
- }
- }
- }
- else {
- memcpy(dst, src, count * sizeof(GLushort));
- }
-}
-
-
-static void
-put_mono_row_ushort(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- GLint x, GLint y, const void *value, const GLubyte *mask)
-{
- const GLushort val = *((const GLushort *) value);
- GLushort *dst = (GLushort *) rb->Data + y * rb->Width + x;
- ASSERT(rb->DataType == GL_UNSIGNED_SHORT);
- if (mask) {
- GLuint i;
- for (i = 0; i < count; i++) {
- if (mask[i]) {
- dst[i] = val;
- }
- }
- }
- else {
- GLuint i;
- for (i = 0; i < count; i++) {
- dst[i] = val;
- }
- }
-}
-
-
-static void
-put_values_ushort(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- const GLint x[], const GLint y[], const void *values,
- const GLubyte *mask)
-{
- const GLushort *src = (const GLushort *) values;
- GLuint i;
- ASSERT(rb->DataType == GL_UNSIGNED_SHORT);
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- GLushort *dst = (GLushort *) rb->Data + y[i] * rb->Width + x[i];
- *dst = src[i];
- }
- }
-}
-
-
-static void
-put_mono_values_ushort(struct gl_context *ctx, struct gl_renderbuffer *rb,
- GLuint count, const GLint x[], const GLint y[],
- const void *value, const GLubyte *mask)
-{
- const GLushort val = *((const GLushort *) value);
- ASSERT(rb->DataType == GL_UNSIGNED_SHORT);
- if (mask) {
- GLuint i;
- for (i = 0; i < count; i++) {
- if (mask[i]) {
- GLushort *dst = (GLushort *) rb->Data + y[i] * rb->Width + x[i];
- *dst = val;
- }
- }
- }
- else {
- GLuint i;
- for (i = 0; i < count; i++) {
- GLushort *dst = (GLushort *) rb->Data + y[i] * rb->Width + x[i];
- *dst = val;
- }
- }
-}
-
-
-/**********************************************************************
- * Functions for buffers of 1 X GLuint values.
- * Typically depth/Z or color index.
- */
-
-static void *
-get_pointer_uint(struct gl_context *ctx, struct gl_renderbuffer *rb,
- GLint x, GLint y)
-{
- if (!rb->Data)
- return NULL;
- ASSERT(rb->DataType == GL_UNSIGNED_INT ||
- rb->DataType == GL_UNSIGNED_INT_24_8_EXT);
- return (GLuint *) rb->Data + y * rb->Width + x;
-}
-
-
-static void
-get_row_uint(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- GLint x, GLint y, void *values)
-{
- const void *src = rb->GetPointer(ctx, rb, x, y);
- ASSERT(rb->DataType == GL_UNSIGNED_INT ||
- rb->DataType == GL_UNSIGNED_INT_24_8_EXT);
- memcpy(values, src, count * sizeof(GLuint));
-}
-
-
-static void
-get_values_uint(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- const GLint x[], const GLint y[], void *values)
-{
- GLuint *dst = (GLuint *) values;
- GLuint i;
- ASSERT(rb->DataType == GL_UNSIGNED_INT ||
- rb->DataType == GL_UNSIGNED_INT_24_8_EXT);
- for (i = 0; i < count; i++) {
- const GLuint *src = (GLuint *) rb->Data + y[i] * rb->Width + x[i];
- dst[i] = *src;
- }
-}
-
-
-static void
-put_row_uint(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- GLint x, GLint y, const void *values, const GLubyte *mask)
-{
- const GLuint *src = (const GLuint *) values;
- GLuint *dst = (GLuint *) rb->Data + y * rb->Width + x;
- ASSERT(rb->DataType == GL_UNSIGNED_INT ||
- rb->DataType == GL_UNSIGNED_INT_24_8_EXT);
- if (mask) {
- GLuint i;
- for (i = 0; i < count; i++) {
- if (mask[i]) {
- dst[i] = src[i];
- }
- }
- }
- else {
- memcpy(dst, src, count * sizeof(GLuint));
- }
-}
-
-
-static void
-put_mono_row_uint(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- GLint x, GLint y, const void *value, const GLubyte *mask)
-{
- const GLuint val = *((const GLuint *) value);
- GLuint *dst = (GLuint *) rb->Data + y * rb->Width + x;
- ASSERT(rb->DataType == GL_UNSIGNED_INT ||
- rb->DataType == GL_UNSIGNED_INT_24_8_EXT);
- if (mask) {
- GLuint i;
- for (i = 0; i < count; i++) {
- if (mask[i]) {
- dst[i] = val;
- }
- }
- }
- else {
- GLuint i;
- for (i = 0; i < count; i++) {
- dst[i] = val;
- }
- }
-}
-
-
-static void
-put_values_uint(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- const GLint x[], const GLint y[], const void *values,
- const GLubyte *mask)
-{
- const GLuint *src = (const GLuint *) values;
- GLuint i;
- ASSERT(rb->DataType == GL_UNSIGNED_INT ||
- rb->DataType == GL_UNSIGNED_INT_24_8_EXT);
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- GLuint *dst = (GLuint *) rb->Data + y[i] * rb->Width + x[i];
- *dst = src[i];
- }
- }
-}
-
-
-static void
-put_mono_values_uint(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- const GLint x[], const GLint y[], const void *value,
- const GLubyte *mask)
-{
- const GLuint val = *((const GLuint *) value);
- GLuint i;
- ASSERT(rb->DataType == GL_UNSIGNED_INT ||
- rb->DataType == GL_UNSIGNED_INT_24_8_EXT);
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- GLuint *dst = (GLuint *) rb->Data + y[i] * rb->Width + x[i];
- *dst = val;
- }
- }
-}
-
-
-/**********************************************************************
- * Functions for buffers of 3 X GLubyte (or GLbyte) values.
- * Typically color buffers.
- * NOTE: the incoming and outgoing colors are RGBA! We ignore incoming
- * alpha values and return 255 for outgoing alpha values.
- */
-
-static void *
-get_pointer_ubyte3(struct gl_context *ctx, struct gl_renderbuffer *rb,
- GLint x, GLint y)
-{
- ASSERT(rb->Format == MESA_FORMAT_RGB888);
- /* No direct access since this buffer is RGB but caller will be
- * treating it as if it were RGBA.
- */
- return NULL;
-}
-
-
-static void
-get_row_ubyte3(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- GLint x, GLint y, void *values)
-{
- const GLubyte *src = (const GLubyte *) rb->Data + 3 * (y * rb->Width + x);
- GLubyte *dst = (GLubyte *) values;
- GLuint i;
- ASSERT(rb->Format == MESA_FORMAT_RGB888);
- ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
- for (i = 0; i < count; i++) {
- dst[i * 4 + 0] = src[i * 3 + 0];
- dst[i * 4 + 1] = src[i * 3 + 1];
- dst[i * 4 + 2] = src[i * 3 + 2];
- dst[i * 4 + 3] = 255;
- }
-}
-
-
-static void
-get_values_ubyte3(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- const GLint x[], const GLint y[], void *values)
-{
- GLubyte *dst = (GLubyte *) values;
- GLuint i;
- ASSERT(rb->Format == MESA_FORMAT_RGB888);
- ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
- for (i = 0; i < count; i++) {
- const GLubyte *src
- = (GLubyte *) rb->Data + 3 * (y[i] * rb->Width + x[i]);
- dst[i * 4 + 0] = src[0];
- dst[i * 4 + 1] = src[1];
- dst[i * 4 + 2] = src[2];
- dst[i * 4 + 3] = 255;
- }
-}
-
-
-static void
-put_row_ubyte3(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- GLint x, GLint y, const void *values, const GLubyte *mask)
-{
- /* note: incoming values are RGB+A! */
- const GLubyte *src = (const GLubyte *) values;
- GLubyte *dst = (GLubyte *) rb->Data + 3 * (y * rb->Width + x);
- GLuint i;
- ASSERT(rb->Format == MESA_FORMAT_RGB888);
- ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- dst[i * 3 + 0] = src[i * 4 + 0];
- dst[i * 3 + 1] = src[i * 4 + 1];
- dst[i * 3 + 2] = src[i * 4 + 2];
- }
- }
-}
-
-
-static void
-put_row_rgb_ubyte3(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- GLint x, GLint y, const void *values, const GLubyte *mask)
-{
- /* note: incoming values are RGB+A! */
- const GLubyte *src = (const GLubyte *) values;
- GLubyte *dst = (GLubyte *) rb->Data + 3 * (y * rb->Width + x);
- GLuint i;
- ASSERT(rb->Format == MESA_FORMAT_RGB888);
- ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- dst[i * 3 + 0] = src[i * 3 + 0];
- dst[i * 3 + 1] = src[i * 3 + 1];
- dst[i * 3 + 2] = src[i * 3 + 2];
- }
- }
-}
-
-
-static void
-put_mono_row_ubyte3(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- GLint x, GLint y, const void *value, const GLubyte *mask)
-{
- /* note: incoming value is RGB+A! */
- const GLubyte val0 = ((const GLubyte *) value)[0];
- const GLubyte val1 = ((const GLubyte *) value)[1];
- const GLubyte val2 = ((const GLubyte *) value)[2];
- GLubyte *dst = (GLubyte *) rb->Data + 3 * (y * rb->Width + x);
- ASSERT(rb->Format == MESA_FORMAT_RGB888);
- ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
- if (!mask && val0 == val1 && val1 == val2) {
- /* optimized case */
- memset(dst, val0, 3 * count);
- }
- else {
- GLuint i;
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- dst[i * 3 + 0] = val0;
- dst[i * 3 + 1] = val1;
- dst[i * 3 + 2] = val2;
- }
- }
- }
-}
-
-
-static void
-put_values_ubyte3(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- const GLint x[], const GLint y[], const void *values,
- const GLubyte *mask)
-{
- /* note: incoming values are RGB+A! */
- const GLubyte *src = (const GLubyte *) values;
- GLuint i;
- ASSERT(rb->Format == MESA_FORMAT_RGB888);
- ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- GLubyte *dst = (GLubyte *) rb->Data + 3 * (y[i] * rb->Width + x[i]);
- dst[0] = src[i * 4 + 0];
- dst[1] = src[i * 4 + 1];
- dst[2] = src[i * 4 + 2];
- }
- }
-}
-
-
-static void
-put_mono_values_ubyte3(struct gl_context *ctx, struct gl_renderbuffer *rb,
- GLuint count, const GLint x[], const GLint y[],
- const void *value, const GLubyte *mask)
-{
- /* note: incoming value is RGB+A! */
- const GLubyte val0 = ((const GLubyte *) value)[0];
- const GLubyte val1 = ((const GLubyte *) value)[1];
- const GLubyte val2 = ((const GLubyte *) value)[2];
- GLuint i;
- ASSERT(rb->Format == MESA_FORMAT_RGB888);
- ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- GLubyte *dst = (GLubyte *) rb->Data + 3 * (y[i] * rb->Width + x[i]);
- dst[0] = val0;
- dst[1] = val1;
- dst[2] = val2;
- }
- }
-}
-
-
-/**********************************************************************
- * Functions for buffers of 4 X GLubyte (or GLbyte) values.
- * Typically color buffers.
- */
-
-static void *
-get_pointer_ubyte4(struct gl_context *ctx, struct gl_renderbuffer *rb,
- GLint x, GLint y)
-{
- if (!rb->Data)
- return NULL;
- ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
- ASSERT(rb->Format == MESA_FORMAT_RGBA8888);
- return (GLubyte *) rb->Data + 4 * (y * rb->Width + x);
-}
-
-
-static void
-get_row_ubyte4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- GLint x, GLint y, void *values)
-{
- const GLubyte *src = (const GLubyte *) rb->Data + 4 * (y * rb->Width + x);
- ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
- ASSERT(rb->Format == MESA_FORMAT_RGBA8888);
- memcpy(values, src, 4 * count * sizeof(GLubyte));
-}
-
-
-static void
-get_values_ubyte4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- const GLint x[], const GLint y[], void *values)
-{
- /* treat 4*GLubyte as 1*GLuint */
- GLuint *dst = (GLuint *) values;
- GLuint i;
- ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
- ASSERT(rb->Format == MESA_FORMAT_RGBA8888);
- for (i = 0; i < count; i++) {
- const GLuint *src = (GLuint *) rb->Data + (y[i] * rb->Width + x[i]);
- dst[i] = *src;
- }
-}
-
-
-static void
-put_row_ubyte4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- GLint x, GLint y, const void *values, const GLubyte *mask)
-{
- /* treat 4*GLubyte as 1*GLuint */
- const GLuint *src = (const GLuint *) values;
- GLuint *dst = (GLuint *) rb->Data + (y * rb->Width + x);
- ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
- ASSERT(rb->Format == MESA_FORMAT_RGBA8888);
- if (mask) {
- GLuint i;
- for (i = 0; i < count; i++) {
- if (mask[i]) {
- dst[i] = src[i];
- }
- }
- }
- else {
- memcpy(dst, src, 4 * count * sizeof(GLubyte));
- }
-}
-
-
-static void
-put_row_rgb_ubyte4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- GLint x, GLint y, const void *values, const GLubyte *mask)
-{
- /* Store RGB values in RGBA buffer */
- const GLubyte *src = (const GLubyte *) values;
- GLubyte *dst = (GLubyte *) rb->Data + 4 * (y * rb->Width + x);
- GLuint i;
- ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
- ASSERT(rb->Format == MESA_FORMAT_RGBA8888);
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- dst[i * 4 + 0] = src[i * 3 + 0];
- dst[i * 4 + 1] = src[i * 3 + 1];
- dst[i * 4 + 2] = src[i * 3 + 2];
- dst[i * 4 + 3] = 0xff;
- }
- }
-}
-
-
-static void
-put_mono_row_ubyte4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- GLint x, GLint y, const void *value, const GLubyte *mask)
-{
- /* treat 4*GLubyte as 1*GLuint */
- const GLuint val = *((const GLuint *) value);
- GLuint *dst = (GLuint *) rb->Data + (y * rb->Width + x);
- ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
- ASSERT(rb->Format == MESA_FORMAT_RGBA8888);
- if (!mask && val == 0) {
- /* common case */
- memset(dst, 0, count * 4 * sizeof(GLubyte));
- }
- else {
- /* general case */
- if (mask) {
- GLuint i;
- for (i = 0; i < count; i++) {
- if (mask[i]) {
- dst[i] = val;
- }
- }
- }
- else {
- GLuint i;
- for (i = 0; i < count; i++) {
- dst[i] = val;
- }
- }
- }
-}
-
-
-static void
-put_values_ubyte4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- const GLint x[], const GLint y[], const void *values,
- const GLubyte *mask)
-{
- /* treat 4*GLubyte as 1*GLuint */
- const GLuint *src = (const GLuint *) values;
- GLuint i;
- ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
- ASSERT(rb->Format == MESA_FORMAT_RGBA8888);
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- GLuint *dst = (GLuint *) rb->Data + (y[i] * rb->Width + x[i]);
- *dst = src[i];
- }
- }
-}
-
-
-static void
-put_mono_values_ubyte4(struct gl_context *ctx, struct gl_renderbuffer *rb,
- GLuint count, const GLint x[], const GLint y[],
- const void *value, const GLubyte *mask)
-{
- /* treat 4*GLubyte as 1*GLuint */
- const GLuint val = *((const GLuint *) value);
- GLuint i;
- ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
- ASSERT(rb->Format == MESA_FORMAT_RGBA8888);
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- GLuint *dst = (GLuint *) rb->Data + (y[i] * rb->Width + x[i]);
- *dst = val;
- }
- }
-}
-
-
-/**********************************************************************
- * Functions for buffers of 4 X GLushort (or GLshort) values.
- * Typically accum buffer.
- */
-
-static void *
-get_pointer_ushort4(struct gl_context *ctx, struct gl_renderbuffer *rb,
- GLint x, GLint y)
-{
- if (!rb->Data)
- return NULL;
- ASSERT(rb->DataType == GL_UNSIGNED_SHORT || rb->DataType == GL_SHORT);
- return (GLushort *) rb->Data + 4 * (y * rb->Width + x);
-}
-
-
-static void
-get_row_ushort4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- GLint x, GLint y, void *values)
-{
- const GLshort *src = (const GLshort *) rb->Data + 4 * (y * rb->Width + x);
- ASSERT(rb->DataType == GL_UNSIGNED_SHORT || rb->DataType == GL_SHORT);
- memcpy(values, src, 4 * count * sizeof(GLshort));
-}
-
-
-static void
-get_values_ushort4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- const GLint x[], const GLint y[], void *values)
-{
- GLushort *dst = (GLushort *) values;
- GLuint i;
- ASSERT(rb->DataType == GL_UNSIGNED_SHORT || rb->DataType == GL_SHORT);
- for (i = 0; i < count; i++) {
- const GLushort *src
- = (GLushort *) rb->Data + 4 * (y[i] * rb->Width + x[i]);
- dst[i] = *src;
- }
-}
-
-
-static void
-put_row_ushort4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- GLint x, GLint y, const void *values, const GLubyte *mask)
-{
- const GLushort *src = (const GLushort *) values;
- GLushort *dst = (GLushort *) rb->Data + 4 * (y * rb->Width + x);
- ASSERT(rb->DataType == GL_UNSIGNED_SHORT || rb->DataType == GL_SHORT);
- if (mask) {
- GLuint i;
- for (i = 0; i < count; i++) {
- if (mask[i]) {
- dst[i * 4 + 0] = src[i * 4 + 0];
- dst[i * 4 + 1] = src[i * 4 + 1];
- dst[i * 4 + 2] = src[i * 4 + 2];
- dst[i * 4 + 3] = src[i * 4 + 3];
- }
- }
- }
- else {
- memcpy(dst, src, 4 * count * sizeof(GLushort));
- }
-}
-
-
-static void
-put_row_rgb_ushort4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- GLint x, GLint y, const void *values, const GLubyte *mask)
-{
- /* Put RGB values in RGBA buffer */
- const GLushort *src = (const GLushort *) values;
- GLushort *dst = (GLushort *) rb->Data + 4 * (y * rb->Width + x);
- ASSERT(rb->DataType == GL_UNSIGNED_SHORT || rb->DataType == GL_SHORT);
- if (mask) {
- GLuint i;
- for (i = 0; i < count; i++) {
- if (mask[i]) {
- dst[i * 4 + 0] = src[i * 3 + 0];
- dst[i * 4 + 1] = src[i * 3 + 1];
- dst[i * 4 + 2] = src[i * 3 + 2];
- dst[i * 4 + 3] = 0xffff;
- }
- }
- }
- else {
- memcpy(dst, src, 4 * count * sizeof(GLushort));
- }
-}
-
-
-static void
-put_mono_row_ushort4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- GLint x, GLint y, const void *value, const GLubyte *mask)
-{
- const GLushort val0 = ((const GLushort *) value)[0];
- const GLushort val1 = ((const GLushort *) value)[1];
- const GLushort val2 = ((const GLushort *) value)[2];
- const GLushort val3 = ((const GLushort *) value)[3];
- GLushort *dst = (GLushort *) rb->Data + 4 * (y * rb->Width + x);
- ASSERT(rb->DataType == GL_UNSIGNED_SHORT || rb->DataType == GL_SHORT);
- if (!mask && val0 == 0 && val1 == 0 && val2 == 0 && val3 == 0) {
- /* common case for clearing accum buffer */
- memset(dst, 0, count * 4 * sizeof(GLushort));
- }
- else {
- GLuint i;
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- dst[i * 4 + 0] = val0;
- dst[i * 4 + 1] = val1;
- dst[i * 4 + 2] = val2;
- dst[i * 4 + 3] = val3;
- }
- }
- }
-}
-
-
-static void
-put_values_ushort4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- const GLint x[], const GLint y[], const void *values,
- const GLubyte *mask)
-{
- const GLushort *src = (const GLushort *) values;
- GLuint i;
- ASSERT(rb->DataType == GL_UNSIGNED_SHORT || rb->DataType == GL_SHORT);
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- GLushort *dst = (GLushort *) rb->Data + 4 * (y[i] * rb->Width + x[i]);
- dst[0] = src[i * 4 + 0];
- dst[1] = src[i * 4 + 1];
- dst[2] = src[i * 4 + 2];
- dst[3] = src[i * 4 + 3];
- }
- }
-}
-
-
-static void
-put_mono_values_ushort4(struct gl_context *ctx, struct gl_renderbuffer *rb,
- GLuint count, const GLint x[], const GLint y[],
- const void *value, const GLubyte *mask)
-{
- const GLushort val0 = ((const GLushort *) value)[0];
- const GLushort val1 = ((const GLushort *) value)[1];
- const GLushort val2 = ((const GLushort *) value)[2];
- const GLushort val3 = ((const GLushort *) value)[3];
- GLuint i;
- ASSERT(rb->DataType == GL_UNSIGNED_SHORT || rb->DataType == GL_SHORT);
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- GLushort *dst = (GLushort *) rb->Data + 4 * (y[i] * rb->Width + x[i]);
- dst[0] = val0;
- dst[1] = val1;
- dst[2] = val2;
- dst[3] = val3;
- }
- }
-}
-
-
-
-/**
- * This is a software fallback for the gl_renderbuffer->AllocStorage
- * function.
- * Device drivers will typically override this function for the buffers
- * which it manages (typically color buffers, Z and stencil).
- * Other buffers (like software accumulation and aux buffers) which the driver
- * doesn't manage can be handled with this function.
- *
- * This one multi-purpose function can allocate stencil, depth, accum, color
- * or color-index buffers!
- *
- * This function also plugs in the appropriate GetPointer, Get/PutRow and
- * Get/PutValues functions.
- */
-GLboolean
-_mesa_soft_renderbuffer_storage(struct gl_context *ctx, struct gl_renderbuffer *rb,
- GLenum internalFormat,
- GLuint width, GLuint height)
-{
- GLuint pixelSize;
-
- switch (internalFormat) {
- case GL_RGB:
- case GL_R3_G3_B2:
- case GL_RGB4:
- case GL_RGB5:
- case GL_RGB8:
- case GL_RGB10:
- case GL_RGB12:
- case GL_RGB16:
- rb->Format = MESA_FORMAT_RGB888;
- rb->DataType = GL_UNSIGNED_BYTE;
- rb->GetPointer = get_pointer_ubyte3;
- rb->GetRow = get_row_ubyte3;
- rb->GetValues = get_values_ubyte3;
- rb->PutRow = put_row_ubyte3;
- rb->PutRowRGB = put_row_rgb_ubyte3;
- rb->PutMonoRow = put_mono_row_ubyte3;
- rb->PutValues = put_values_ubyte3;
- rb->PutMonoValues = put_mono_values_ubyte3;
- pixelSize = 3 * sizeof(GLubyte);
- break;
- case GL_RGBA:
- case GL_RGBA2:
- case GL_RGBA4:
- case GL_RGB5_A1:
- case GL_RGBA8:
-#if 1
- case GL_RGB10_A2:
- case GL_RGBA12:
-#endif
- rb->Format = MESA_FORMAT_RGBA8888;
- rb->DataType = GL_UNSIGNED_BYTE;
- rb->GetPointer = get_pointer_ubyte4;
- rb->GetRow = get_row_ubyte4;
- rb->GetValues = get_values_ubyte4;
- rb->PutRow = put_row_ubyte4;
- rb->PutRowRGB = put_row_rgb_ubyte4;
- rb->PutMonoRow = put_mono_row_ubyte4;
- rb->PutValues = put_values_ubyte4;
- rb->PutMonoValues = put_mono_values_ubyte4;
- pixelSize = 4 * sizeof(GLubyte);
- break;
- case GL_RGBA16:
- case GL_RGBA16_SNORM:
- /* for accum buffer */
- rb->Format = MESA_FORMAT_SIGNED_RGBA_16;
- rb->DataType = GL_SHORT;
- rb->GetPointer = get_pointer_ushort4;
- rb->GetRow = get_row_ushort4;
- rb->GetValues = get_values_ushort4;
- rb->PutRow = put_row_ushort4;
- rb->PutRowRGB = put_row_rgb_ushort4;
- rb->PutMonoRow = put_mono_row_ushort4;
- rb->PutValues = put_values_ushort4;
- rb->PutMonoValues = put_mono_values_ushort4;
- pixelSize = 4 * sizeof(GLushort);
- break;
-#if 0
- case GL_ALPHA8:
- rb->Format = MESA_FORMAT_A8;
- rb->DataType = GL_UNSIGNED_BYTE;
- rb->GetPointer = get_pointer_alpha8;
- rb->GetRow = get_row_alpha8;
- rb->GetValues = get_values_alpha8;
- rb->PutRow = put_row_alpha8;
- rb->PutRowRGB = NULL;
- rb->PutMonoRow = put_mono_row_alpha8;
- rb->PutValues = put_values_alpha8;
- rb->PutMonoValues = put_mono_values_alpha8;
- pixelSize = sizeof(GLubyte);
- break;
-#endif
- case GL_STENCIL_INDEX:
- case GL_STENCIL_INDEX1_EXT:
- case GL_STENCIL_INDEX4_EXT:
- case GL_STENCIL_INDEX8_EXT:
- case GL_STENCIL_INDEX16_EXT:
- rb->Format = MESA_FORMAT_S8;
- rb->DataType = GL_UNSIGNED_BYTE;
- rb->GetPointer = get_pointer_ubyte;
- rb->GetRow = get_row_ubyte;
- rb->GetValues = get_values_ubyte;
- rb->PutRow = put_row_ubyte;
- rb->PutRowRGB = NULL;
- rb->PutMonoRow = put_mono_row_ubyte;
- rb->PutValues = put_values_ubyte;
- rb->PutMonoValues = put_mono_values_ubyte;
- pixelSize = sizeof(GLubyte);
- break;
- case GL_DEPTH_COMPONENT:
- case GL_DEPTH_COMPONENT16:
- rb->Format = MESA_FORMAT_Z16;
- rb->DataType = GL_UNSIGNED_SHORT;
- rb->GetPointer = get_pointer_ushort;
- rb->GetRow = get_row_ushort;
- rb->GetValues = get_values_ushort;
- rb->PutRow = put_row_ushort;
- rb->PutRowRGB = NULL;
- rb->PutMonoRow = put_mono_row_ushort;
- rb->PutValues = put_values_ushort;
- rb->PutMonoValues = put_mono_values_ushort;
- pixelSize = sizeof(GLushort);
- break;
- case GL_DEPTH_COMPONENT24:
- rb->DataType = GL_UNSIGNED_INT;
- rb->GetPointer = get_pointer_uint;
- rb->GetRow = get_row_uint;
- rb->GetValues = get_values_uint;
- rb->PutRow = put_row_uint;
- rb->PutRowRGB = NULL;
- rb->PutMonoRow = put_mono_row_uint;
- rb->PutValues = put_values_uint;
- rb->PutMonoValues = put_mono_values_uint;
- rb->Format = MESA_FORMAT_X8_Z24;
- pixelSize = sizeof(GLuint);
- break;
- case GL_DEPTH_COMPONENT32:
- rb->DataType = GL_UNSIGNED_INT;
- rb->GetPointer = get_pointer_uint;
- rb->GetRow = get_row_uint;
- rb->GetValues = get_values_uint;
- rb->PutRow = put_row_uint;
- rb->PutRowRGB = NULL;
- rb->PutMonoRow = put_mono_row_uint;
- rb->PutValues = put_values_uint;
- rb->PutMonoValues = put_mono_values_uint;
- rb->Format = MESA_FORMAT_Z32;
- pixelSize = sizeof(GLuint);
- break;
- case GL_DEPTH_STENCIL_EXT:
- case GL_DEPTH24_STENCIL8_EXT:
- rb->Format = MESA_FORMAT_Z24_S8;
- rb->DataType = GL_UNSIGNED_INT_24_8_EXT;
- rb->GetPointer = get_pointer_uint;
- rb->GetRow = get_row_uint;
- rb->GetValues = get_values_uint;
- rb->PutRow = put_row_uint;
- rb->PutRowRGB = NULL;
- rb->PutMonoRow = put_mono_row_uint;
- rb->PutValues = put_values_uint;
- rb->PutMonoValues = put_mono_values_uint;
- pixelSize = sizeof(GLuint);
- break;
- default:
- _mesa_problem(ctx, "Bad internalFormat in _mesa_soft_renderbuffer_storage");
- return GL_FALSE;
- }
-
- ASSERT(rb->DataType);
- ASSERT(rb->GetPointer);
- ASSERT(rb->GetRow);
- ASSERT(rb->GetValues);
- ASSERT(rb->PutRow);
- ASSERT(rb->PutMonoRow);
- ASSERT(rb->PutValues);
- ASSERT(rb->PutMonoValues);
-
- /* free old buffer storage */
- if (rb->Data) {
- free(rb->Data);
- rb->Data = NULL;
- }
-
- if (width > 0 && height > 0) {
- /* allocate new buffer storage */
- rb->Data = malloc(width * height * pixelSize);
-
- if (rb->Data == NULL) {
- rb->Width = 0;
- rb->Height = 0;
- _mesa_error(ctx, GL_OUT_OF_MEMORY,
- "software renderbuffer allocation (%d x %d x %d)",
- width, height, pixelSize);
- return GL_FALSE;
- }
- }
-
- rb->Width = width;
- rb->Height = height;
- rb->_BaseFormat = _mesa_base_fbo_format(ctx, internalFormat);
- ASSERT(rb->_BaseFormat);
-
- return GL_TRUE;
-}
-
-
-
-/**********************************************************************/
-/**********************************************************************/
-/**********************************************************************/
-
-
-/**
- * Here we utilize the gl_renderbuffer->Wrapper field to put an alpha
- * buffer wrapper around an existing RGB renderbuffer (hw or sw).
- *
- * When PutRow is called (for example), we store the alpha values in
- * this buffer, then pass on the PutRow call to the wrapped RGB
- * buffer.
- */
-
-
-static GLboolean
-alloc_storage_alpha8(struct gl_context *ctx, struct gl_renderbuffer *arb,
- GLenum internalFormat, GLuint width, GLuint height)
-{
- ASSERT(arb != arb->Wrapped);
- ASSERT(arb->Format == MESA_FORMAT_A8);
-
- /* first, pass the call to the wrapped RGB buffer */
- if (!arb->Wrapped->AllocStorage(ctx, arb->Wrapped, internalFormat,
- width, height)) {
- return GL_FALSE;
- }
-
- /* next, resize my alpha buffer */
- if (arb->Data) {
- free(arb->Data);
- }
-
- arb->Data = malloc(width * height * sizeof(GLubyte));
- if (arb->Data == NULL) {
- arb->Width = 0;
- arb->Height = 0;
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "software alpha buffer allocation");
- return GL_FALSE;
- }
-
- arb->Width = width;
- arb->Height = height;
-
- return GL_TRUE;
-}
-
-
-/**
- * Delete an alpha_renderbuffer object, as well as the wrapped RGB buffer.
- */
-static void
-delete_renderbuffer_alpha8(struct gl_renderbuffer *arb)
-{
- if (arb->Data) {
- free(arb->Data);
- }
- ASSERT(arb->Wrapped);
- ASSERT(arb != arb->Wrapped);
- arb->Wrapped->Delete(arb->Wrapped);
- arb->Wrapped = NULL;
- free(arb);
-}
-
-
-static void *
-get_pointer_alpha8(struct gl_context *ctx, struct gl_renderbuffer *arb,
- GLint x, GLint y)
-{
- return NULL; /* don't allow direct access! */
-}
-
-
-static void
-get_row_alpha8(struct gl_context *ctx, struct gl_renderbuffer *arb, GLuint count,
- GLint x, GLint y, void *values)
-{
- /* NOTE: 'values' is RGBA format! */
- const GLubyte *src = (const GLubyte *) arb->Data + y * arb->Width + x;
- GLubyte *dst = (GLubyte *) values;
- GLuint i;
- ASSERT(arb != arb->Wrapped);
- ASSERT(arb->DataType == GL_UNSIGNED_BYTE);
- /* first, pass the call to the wrapped RGB buffer */
- arb->Wrapped->GetRow(ctx, arb->Wrapped, count, x, y, values);
- /* second, fill in alpha values from this buffer! */
- for (i = 0; i < count; i++) {
- dst[i * 4 + 3] = src[i];
- }
-}
-
-
-static void
-get_values_alpha8(struct gl_context *ctx, struct gl_renderbuffer *arb, GLuint count,
- const GLint x[], const GLint y[], void *values)
-{
- GLubyte *dst = (GLubyte *) values;
- GLuint i;
- ASSERT(arb != arb->Wrapped);
- ASSERT(arb->DataType == GL_UNSIGNED_BYTE);
- /* first, pass the call to the wrapped RGB buffer */
- arb->Wrapped->GetValues(ctx, arb->Wrapped, count, x, y, values);
- /* second, fill in alpha values from this buffer! */
- for (i = 0; i < count; i++) {
- const GLubyte *src = (GLubyte *) arb->Data + y[i] * arb->Width + x[i];
- dst[i * 4 + 3] = *src;
- }
-}
-
-
-static void
-put_row_alpha8(struct gl_context *ctx, struct gl_renderbuffer *arb, GLuint count,
- GLint x, GLint y, const void *values, const GLubyte *mask)
-{
- const GLubyte *src = (const GLubyte *) values;
- GLubyte *dst = (GLubyte *) arb->Data + y * arb->Width + x;
- GLuint i;
- ASSERT(arb != arb->Wrapped);
- ASSERT(arb->DataType == GL_UNSIGNED_BYTE);
- /* first, pass the call to the wrapped RGB buffer */
- arb->Wrapped->PutRow(ctx, arb->Wrapped, count, x, y, values, mask);
- /* second, store alpha in our buffer */
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- dst[i] = src[i * 4 + 3];
- }
- }
-}
-
-
-static void
-put_row_rgb_alpha8(struct gl_context *ctx, struct gl_renderbuffer *arb, GLuint count,
- GLint x, GLint y, const void *values, const GLubyte *mask)
-{
- const GLubyte *src = (const GLubyte *) values;
- GLubyte *dst = (GLubyte *) arb->Data + y * arb->Width + x;
- GLuint i;
- ASSERT(arb != arb->Wrapped);
- ASSERT(arb->DataType == GL_UNSIGNED_BYTE);
- /* first, pass the call to the wrapped RGB buffer */
- arb->Wrapped->PutRowRGB(ctx, arb->Wrapped, count, x, y, values, mask);
- /* second, store alpha in our buffer */
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- dst[i] = src[i * 4 + 3];
- }
- }
-}
-
-
-static void
-put_mono_row_alpha8(struct gl_context *ctx, struct gl_renderbuffer *arb, GLuint count,
- GLint x, GLint y, const void *value, const GLubyte *mask)
-{
- const GLubyte val = ((const GLubyte *) value)[3];
- GLubyte *dst = (GLubyte *) arb->Data + y * arb->Width + x;
- ASSERT(arb != arb->Wrapped);
- ASSERT(arb->DataType == GL_UNSIGNED_BYTE);
- /* first, pass the call to the wrapped RGB buffer */
- arb->Wrapped->PutMonoRow(ctx, arb->Wrapped, count, x, y, value, mask);
- /* second, store alpha in our buffer */
- if (mask) {
- GLuint i;
- for (i = 0; i < count; i++) {
- if (mask[i]) {
- dst[i] = val;
- }
- }
- }
- else {
- memset(dst, val, count);
- }
-}
-
-
-static void
-put_values_alpha8(struct gl_context *ctx, struct gl_renderbuffer *arb, GLuint count,
- const GLint x[], const GLint y[],
- const void *values, const GLubyte *mask)
-{
- const GLubyte *src = (const GLubyte *) values;
- GLuint i;
- ASSERT(arb != arb->Wrapped);
- ASSERT(arb->DataType == GL_UNSIGNED_BYTE);
- /* first, pass the call to the wrapped RGB buffer */
- arb->Wrapped->PutValues(ctx, arb->Wrapped, count, x, y, values, mask);
- /* second, store alpha in our buffer */
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- GLubyte *dst = (GLubyte *) arb->Data + y[i] * arb->Width + x[i];
- *dst = src[i * 4 + 3];
- }
- }
-}
-
-
-static void
-put_mono_values_alpha8(struct gl_context *ctx, struct gl_renderbuffer *arb,
- GLuint count, const GLint x[], const GLint y[],
- const void *value, const GLubyte *mask)
-{
- const GLubyte val = ((const GLubyte *) value)[3];
- GLuint i;
- ASSERT(arb != arb->Wrapped);
- ASSERT(arb->DataType == GL_UNSIGNED_BYTE);
- /* first, pass the call to the wrapped RGB buffer */
- arb->Wrapped->PutValues(ctx, arb->Wrapped, count, x, y, value, mask);
- /* second, store alpha in our buffer */
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- GLubyte *dst = (GLubyte *) arb->Data + y[i] * arb->Width + x[i];
- *dst = val;
- }
- }
-}
-
-
-static void
-copy_buffer_alpha8(struct gl_renderbuffer* dst, struct gl_renderbuffer* src)
-{
- ASSERT(dst->Format == MESA_FORMAT_A8);
- ASSERT(src->Format == MESA_FORMAT_A8);
- ASSERT(dst->Width == src->Width);
- ASSERT(dst->Height == src->Height);
-
- memcpy(dst->Data, src->Data, dst->Width * dst->Height * sizeof(GLubyte));
-}
-
-
-/**********************************************************************/
-/**********************************************************************/
-/**********************************************************************/
-
-
-/**
- * Default GetPointer routine. Always return NULL to indicate that
- * direct buffer access is not supported.
- */
-static void *
-nop_get_pointer(struct gl_context *ctx, struct gl_renderbuffer *rb, GLint x, GLint y)
-{
- return NULL;
-}
-
-
-/**
- * Initialize the fields of a gl_renderbuffer to default values.
- */
-void
-_mesa_init_renderbuffer(struct gl_renderbuffer *rb, GLuint name)
-{
- _glthread_INIT_MUTEX(rb->Mutex);
-
- rb->Magic = RB_MAGIC;
- rb->ClassID = 0;
- rb->Name = name;
- rb->RefCount = 0;
- rb->Delete = _mesa_delete_renderbuffer;
-
- /* The rest of these should be set later by the caller of this function or
- * the AllocStorage method:
- */
- rb->AllocStorage = NULL;
-
- rb->Width = 0;
- rb->Height = 0;
- rb->InternalFormat = GL_NONE;
- rb->Format = MESA_FORMAT_NONE;
-
- rb->DataType = GL_NONE;
- rb->Data = NULL;
-
- /* Point back to ourself so that we don't have to check for Wrapped==NULL
- * all over the drivers.
- */
- rb->Wrapped = rb;
-
- rb->GetPointer = nop_get_pointer;
- rb->GetRow = NULL;
- rb->GetValues = NULL;
- rb->PutRow = NULL;
- rb->PutRowRGB = NULL;
- rb->PutMonoRow = NULL;
- rb->PutValues = NULL;
- rb->PutMonoValues = NULL;
-}
-
-
-/**
- * Allocate a new gl_renderbuffer object. This can be used for user-created
- * renderbuffers or window-system renderbuffers.
- */
-struct gl_renderbuffer *
-_mesa_new_renderbuffer(struct gl_context *ctx, GLuint name)
-{
- struct gl_renderbuffer *rb = CALLOC_STRUCT(gl_renderbuffer);
- if (rb) {
- _mesa_init_renderbuffer(rb, name);
- }
- return rb;
-}
-
-
-/**
- * Delete a gl_framebuffer.
- * This is the default function for renderbuffer->Delete().
- */
-void
-_mesa_delete_renderbuffer(struct gl_renderbuffer *rb)
-{
- if (rb->Data) {
- free(rb->Data);
- }
- free(rb);
-}
-
-
-/**
- * Allocate a software-based renderbuffer. This is called via the
- * ctx->Driver.NewRenderbuffer() function when the user creates a new
- * renderbuffer.
- * This would not be used for hardware-based renderbuffers.
- */
-struct gl_renderbuffer *
-_mesa_new_soft_renderbuffer(struct gl_context *ctx, GLuint name)
-{
- struct gl_renderbuffer *rb = _mesa_new_renderbuffer(ctx, name);
- if (rb) {
- rb->AllocStorage = _mesa_soft_renderbuffer_storage;
- /* Normally, one would setup the PutRow, GetRow, etc functions here.
- * But we're doing that in the _mesa_soft_renderbuffer_storage() function
- * instead.
- */
- }
- return rb;
-}
-
-
-/**
- * Add software-based color renderbuffers to the given framebuffer.
- * This is a helper routine for device drivers when creating a
- * window system framebuffer (not a user-created render/framebuffer).
- * Once this function is called, you can basically forget about this
- * renderbuffer; core Mesa will handle all the buffer management and
- * rendering!
- */
-GLboolean
-_mesa_add_color_renderbuffers(struct gl_context *ctx, struct gl_framebuffer *fb,
- GLuint rgbBits, GLuint alphaBits,
- GLboolean frontLeft, GLboolean backLeft,
- GLboolean frontRight, GLboolean backRight)
-{
- gl_buffer_index b;
-
- if (rgbBits > 16 || alphaBits > 16) {
- _mesa_problem(ctx,
- "Unsupported bit depth in _mesa_add_color_renderbuffers");
- return GL_FALSE;
- }
-
- assert(MAX_COLOR_ATTACHMENTS >= 4);
-
- for (b = BUFFER_FRONT_LEFT; b <= BUFFER_BACK_RIGHT; b++) {
- struct gl_renderbuffer *rb;
-
- if (b == BUFFER_FRONT_LEFT && !frontLeft)
- continue;
- else if (b == BUFFER_BACK_LEFT && !backLeft)
- continue;
- else if (b == BUFFER_FRONT_RIGHT && !frontRight)
- continue;
- else if (b == BUFFER_BACK_RIGHT && !backRight)
- continue;
-
- assert(fb->Attachment[b].Renderbuffer == NULL);
-
- rb = _mesa_new_renderbuffer(ctx, 0);
- if (!rb) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "Allocating color buffer");
- return GL_FALSE;
- }
-
- if (rgbBits <= 8) {
- if (alphaBits)
- rb->Format = MESA_FORMAT_RGBA8888;
- else
- rb->Format = MESA_FORMAT_RGB888;
- }
- else {
- assert(rgbBits <= 16);
- rb->Format = MESA_FORMAT_NONE; /*XXX RGBA16;*/
- }
- rb->InternalFormat = GL_RGBA;
-
- rb->AllocStorage = _mesa_soft_renderbuffer_storage;
- _mesa_add_renderbuffer(fb, b, rb);
- }
-
- return GL_TRUE;
-}
-
-
-/**
- * Add software-based alpha renderbuffers to the given framebuffer.
- * This is a helper routine for device drivers when creating a
- * window system framebuffer (not a user-created render/framebuffer).
- * Once this function is called, you can basically forget about this
- * renderbuffer; core Mesa will handle all the buffer management and
- * rendering!
- */
-GLboolean
-_mesa_add_alpha_renderbuffers(struct gl_context *ctx, struct gl_framebuffer *fb,
- GLuint alphaBits,
- GLboolean frontLeft, GLboolean backLeft,
- GLboolean frontRight, GLboolean backRight)
-{
- gl_buffer_index b;
-
- /* for window system framebuffers only! */
- assert(fb->Name == 0);
-
- if (alphaBits > 8) {
- _mesa_problem(ctx,
- "Unsupported bit depth in _mesa_add_alpha_renderbuffers");
- return GL_FALSE;
- }
-
- assert(MAX_COLOR_ATTACHMENTS >= 4);
-
- /* Wrap each of the RGB color buffers with an alpha renderbuffer.
- */
- for (b = BUFFER_FRONT_LEFT; b <= BUFFER_BACK_RIGHT; b++) {
- struct gl_renderbuffer *arb;
-
- if (b == BUFFER_FRONT_LEFT && !frontLeft)
- continue;
- else if (b == BUFFER_BACK_LEFT && !backLeft)
- continue;
- else if (b == BUFFER_FRONT_RIGHT && !frontRight)
- continue;
- else if (b == BUFFER_BACK_RIGHT && !backRight)
- continue;
-
- /* the RGB buffer to wrap must already exist!! */
- assert(fb->Attachment[b].Renderbuffer);
-
- /* only GLubyte supported for now */
- assert(fb->Attachment[b].Renderbuffer->DataType == GL_UNSIGNED_BYTE);
-
- /* allocate alpha renderbuffer */
- arb = _mesa_new_renderbuffer(ctx, 0);
- if (!arb) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "Allocating alpha buffer");
- return GL_FALSE;
- }
-
- /* wrap the alpha renderbuffer around the RGB renderbuffer */
- arb->Wrapped = fb->Attachment[b].Renderbuffer;
-
- /* Set up my alphabuffer fields and plug in my functions.
- * The functions will put/get the alpha values from/to RGBA arrays
- * and then call the wrapped buffer's functions to handle the RGB
- * values.
- */
- arb->InternalFormat = arb->Wrapped->InternalFormat;
- arb->Format = MESA_FORMAT_A8;
- arb->DataType = arb->Wrapped->DataType;
- arb->AllocStorage = alloc_storage_alpha8;
- arb->Delete = delete_renderbuffer_alpha8;
- arb->GetPointer = get_pointer_alpha8;
- arb->GetRow = get_row_alpha8;
- arb->GetValues = get_values_alpha8;
- arb->PutRow = put_row_alpha8;
- arb->PutRowRGB = put_row_rgb_alpha8;
- arb->PutMonoRow = put_mono_row_alpha8;
- arb->PutValues = put_values_alpha8;
- arb->PutMonoValues = put_mono_values_alpha8;
-
- /* clear the pointer to avoid assertion/sanity check failure later */
- fb->Attachment[b].Renderbuffer = NULL;
-
- /* plug the alpha renderbuffer into the colorbuffer attachment */
- _mesa_add_renderbuffer(fb, b, arb);
- }
-
- return GL_TRUE;
-}
-
-
-/**
- * For framebuffers that use a software alpha channel wrapper
- * created by _mesa_add_alpha_renderbuffer or _mesa_add_soft_renderbuffers,
- * copy the back buffer alpha channel into the front buffer alpha channel.
- */
-void
-_mesa_copy_soft_alpha_renderbuffers(struct gl_context *ctx, struct gl_framebuffer *fb)
-{
- if (fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer &&
- fb->Attachment[BUFFER_BACK_LEFT].Renderbuffer)
- copy_buffer_alpha8(fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer,
- fb->Attachment[BUFFER_BACK_LEFT].Renderbuffer);
-
-
- if (fb->Attachment[BUFFER_FRONT_RIGHT].Renderbuffer &&
- fb->Attachment[BUFFER_BACK_RIGHT].Renderbuffer)
- copy_buffer_alpha8(fb->Attachment[BUFFER_FRONT_RIGHT].Renderbuffer,
- fb->Attachment[BUFFER_BACK_RIGHT].Renderbuffer);
-}
-
-
-/**
- * Add a software-based depth renderbuffer to the given framebuffer.
- * This is a helper routine for device drivers when creating a
- * window system framebuffer (not a user-created render/framebuffer).
- * Once this function is called, you can basically forget about this
- * renderbuffer; core Mesa will handle all the buffer management and
- * rendering!
- */
-GLboolean
-_mesa_add_depth_renderbuffer(struct gl_context *ctx, struct gl_framebuffer *fb,
- GLuint depthBits)
-{
- struct gl_renderbuffer *rb;
-
- if (depthBits > 32) {
- _mesa_problem(ctx,
- "Unsupported depthBits in _mesa_add_depth_renderbuffer");
- return GL_FALSE;
- }
-
- assert(fb->Attachment[BUFFER_DEPTH].Renderbuffer == NULL);
-
- rb = _mesa_new_renderbuffer(ctx, 0);
- if (!rb) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "Allocating depth buffer");
- return GL_FALSE;
- }
-
- if (depthBits <= 16) {
- rb->Format = MESA_FORMAT_Z16;
- rb->InternalFormat = GL_DEPTH_COMPONENT16;
- }
- else if (depthBits <= 24) {
- rb->Format = MESA_FORMAT_X8_Z24;
- rb->InternalFormat = GL_DEPTH_COMPONENT24;
- }
- else {
- rb->Format = MESA_FORMAT_Z32;
- rb->InternalFormat = GL_DEPTH_COMPONENT32;
- }
-
- rb->AllocStorage = _mesa_soft_renderbuffer_storage;
- _mesa_add_renderbuffer(fb, BUFFER_DEPTH, rb);
-
- return GL_TRUE;
-}
-
-
-/**
- * Add a software-based stencil renderbuffer to the given framebuffer.
- * This is a helper routine for device drivers when creating a
- * window system framebuffer (not a user-created render/framebuffer).
- * Once this function is called, you can basically forget about this
- * renderbuffer; core Mesa will handle all the buffer management and
- * rendering!
- */
-GLboolean
-_mesa_add_stencil_renderbuffer(struct gl_context *ctx, struct gl_framebuffer *fb,
- GLuint stencilBits)
-{
- struct gl_renderbuffer *rb;
-
- if (stencilBits > 16) {
- _mesa_problem(ctx,
- "Unsupported stencilBits in _mesa_add_stencil_renderbuffer");
- return GL_FALSE;
- }
-
- assert(fb->Attachment[BUFFER_STENCIL].Renderbuffer == NULL);
-
- rb = _mesa_new_renderbuffer(ctx, 0);
- if (!rb) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "Allocating stencil buffer");
- return GL_FALSE;
- }
-
- assert(stencilBits <= 8);
- rb->Format = MESA_FORMAT_S8;
- rb->InternalFormat = GL_STENCIL_INDEX8;
-
- rb->AllocStorage = _mesa_soft_renderbuffer_storage;
- _mesa_add_renderbuffer(fb, BUFFER_STENCIL, rb);
-
- return GL_TRUE;
-}
-
-
-/**
- * Add a software-based accumulation renderbuffer to the given framebuffer.
- * This is a helper routine for device drivers when creating a
- * window system framebuffer (not a user-created render/framebuffer).
- * Once this function is called, you can basically forget about this
- * renderbuffer; core Mesa will handle all the buffer management and
- * rendering!
- */
-GLboolean
-_mesa_add_accum_renderbuffer(struct gl_context *ctx, struct gl_framebuffer *fb,
- GLuint redBits, GLuint greenBits,
- GLuint blueBits, GLuint alphaBits)
-{
- struct gl_renderbuffer *rb;
-
- if (redBits > 16 || greenBits > 16 || blueBits > 16 || alphaBits > 16) {
- _mesa_problem(ctx,
- "Unsupported accumBits in _mesa_add_accum_renderbuffer");
- return GL_FALSE;
- }
-
- assert(fb->Attachment[BUFFER_ACCUM].Renderbuffer == NULL);
-
- rb = _mesa_new_renderbuffer(ctx, 0);
- if (!rb) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "Allocating accum buffer");
- return GL_FALSE;
- }
-
- rb->Format = MESA_FORMAT_SIGNED_RGBA_16;
- rb->InternalFormat = GL_RGBA16_SNORM;
- rb->AllocStorage = _mesa_soft_renderbuffer_storage;
- _mesa_add_renderbuffer(fb, BUFFER_ACCUM, rb);
-
- return GL_TRUE;
-}
-
-
-
-/**
- * Add a software-based aux renderbuffer to the given framebuffer.
- * This is a helper routine for device drivers when creating a
- * window system framebuffer (not a user-created render/framebuffer).
- * Once this function is called, you can basically forget about this
- * renderbuffer; core Mesa will handle all the buffer management and
- * rendering!
- *
- * NOTE: color-index aux buffers not supported.
- */
-GLboolean
-_mesa_add_aux_renderbuffers(struct gl_context *ctx, struct gl_framebuffer *fb,
- GLuint colorBits, GLuint numBuffers)
-{
- GLuint i;
-
- if (colorBits > 16) {
- _mesa_problem(ctx,
- "Unsupported accumBits in _mesa_add_aux_renderbuffers");
- return GL_FALSE;
- }
-
- assert(numBuffers <= MAX_AUX_BUFFERS);
-
- for (i = 0; i < numBuffers; i++) {
- struct gl_renderbuffer *rb = _mesa_new_renderbuffer(ctx, 0);
-
- assert(fb->Attachment[BUFFER_AUX0 + i].Renderbuffer == NULL);
-
- if (!rb) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "Allocating aux buffer");
- return GL_FALSE;
- }
-
- assert (colorBits <= 8);
- rb->Format = MESA_FORMAT_RGBA8888;
- rb->InternalFormat = GL_RGBA;
-
- rb->AllocStorage = _mesa_soft_renderbuffer_storage;
- _mesa_add_renderbuffer(fb, BUFFER_AUX0 + i, rb);
- }
- return GL_TRUE;
-}
-
-
-/**
- * Create/attach software-based renderbuffers to the given framebuffer.
- * This is a helper routine for device drivers. Drivers can just as well
- * call the individual _mesa_add_*_renderbuffer() routines directly.
- */
-void
-_mesa_add_soft_renderbuffers(struct gl_framebuffer *fb,
- GLboolean color,
- GLboolean depth,
- GLboolean stencil,
- GLboolean accum,
- GLboolean alpha,
- GLboolean aux)
-{
- GLboolean frontLeft = GL_TRUE;
- GLboolean backLeft = fb->Visual.doubleBufferMode;
- GLboolean frontRight = fb->Visual.stereoMode;
- GLboolean backRight = fb->Visual.stereoMode && fb->Visual.doubleBufferMode;
-
- if (color) {
- assert(fb->Visual.redBits == fb->Visual.greenBits);
- assert(fb->Visual.redBits == fb->Visual.blueBits);
- _mesa_add_color_renderbuffers(NULL, fb,
- fb->Visual.redBits,
- fb->Visual.alphaBits,
- frontLeft, backLeft,
- frontRight, backRight);
- }
-
- if (depth) {
- assert(fb->Visual.depthBits > 0);
- _mesa_add_depth_renderbuffer(NULL, fb, fb->Visual.depthBits);
- }
-
- if (stencil) {
- assert(fb->Visual.stencilBits > 0);
- _mesa_add_stencil_renderbuffer(NULL, fb, fb->Visual.stencilBits);
- }
-
- if (accum) {
- assert(fb->Visual.accumRedBits > 0);
- assert(fb->Visual.accumGreenBits > 0);
- assert(fb->Visual.accumBlueBits > 0);
- _mesa_add_accum_renderbuffer(NULL, fb,
- fb->Visual.accumRedBits,
- fb->Visual.accumGreenBits,
- fb->Visual.accumBlueBits,
- fb->Visual.accumAlphaBits);
- }
-
- if (aux) {
- assert(fb->Visual.numAuxBuffers > 0);
- _mesa_add_aux_renderbuffers(NULL, fb, fb->Visual.redBits,
- fb->Visual.numAuxBuffers);
- }
-
- if (alpha) {
- assert(fb->Visual.alphaBits > 0);
- _mesa_add_alpha_renderbuffers(NULL, fb, fb->Visual.alphaBits,
- frontLeft, backLeft,
- frontRight, backRight);
- }
-
-#if 0
- if (multisample) {
- /* maybe someday */
- }
-#endif
-}
-
-
-/**
- * Attach a renderbuffer to a framebuffer.
- * \param bufferName one of the BUFFER_x tokens
- */
-void
-_mesa_add_renderbuffer(struct gl_framebuffer *fb,
- gl_buffer_index bufferName, struct gl_renderbuffer *rb)
-{
- assert(fb);
- assert(rb);
- assert(bufferName < BUFFER_COUNT);
-
- /* There should be no previous renderbuffer on this attachment point,
- * with the exception of depth/stencil since the same renderbuffer may
- * be used for both.
- */
- assert(bufferName == BUFFER_DEPTH ||
- bufferName == BUFFER_STENCIL ||
- fb->Attachment[bufferName].Renderbuffer == NULL);
-
- /* winsys vs. user-created buffer cross check */
- if (fb->Name) {
- assert(rb->Name);
- }
- else {
- assert(!rb->Name);
- }
-
- fb->Attachment[bufferName].Type = GL_RENDERBUFFER_EXT;
- fb->Attachment[bufferName].Complete = GL_TRUE;
- _mesa_reference_renderbuffer(&fb->Attachment[bufferName].Renderbuffer, rb);
-}
-
-
-/**
- * Remove the named renderbuffer from the given framebuffer.
- * \param bufferName one of the BUFFER_x tokens
- */
-void
-_mesa_remove_renderbuffer(struct gl_framebuffer *fb,
- gl_buffer_index bufferName)
-{
- struct gl_renderbuffer *rb;
-
- assert(bufferName < BUFFER_COUNT);
-
- rb = fb->Attachment[bufferName].Renderbuffer;
- if (!rb)
- return;
-
- _mesa_reference_renderbuffer(&rb, NULL);
-
- fb->Attachment[bufferName].Renderbuffer = NULL;
-}
-
-
-/**
- * Set *ptr to point to rb. If *ptr points to another renderbuffer,
- * dereference that buffer first. The new renderbuffer's refcount will
- * be incremented. The old renderbuffer's refcount will be decremented.
- */
-void
-_mesa_reference_renderbuffer(struct gl_renderbuffer **ptr,
- struct gl_renderbuffer *rb)
-{
- assert(ptr);
- if (*ptr == rb) {
- /* no change */
- return;
- }
-
- if (*ptr) {
- /* Unreference the old renderbuffer */
- GLboolean deleteFlag = GL_FALSE;
- struct gl_renderbuffer *oldRb = *ptr;
-
- assert(oldRb->Magic == RB_MAGIC);
- _glthread_LOCK_MUTEX(oldRb->Mutex);
- assert(oldRb->Magic == RB_MAGIC);
- ASSERT(oldRb->RefCount > 0);
- oldRb->RefCount--;
- /*printf("RB DECR %p (%d) to %d\n", (void*) oldRb, oldRb->Name, oldRb->RefCount);*/
- deleteFlag = (oldRb->RefCount == 0);
- _glthread_UNLOCK_MUTEX(oldRb->Mutex);
-
- if (deleteFlag) {
- oldRb->Magic = 0; /* now invalid memory! */
- oldRb->Delete(oldRb);
- }
-
- *ptr = NULL;
- }
- assert(!*ptr);
-
- if (rb) {
- assert(rb->Magic == RB_MAGIC);
- /* reference new renderbuffer */
- _glthread_LOCK_MUTEX(rb->Mutex);
- rb->RefCount++;
- /*printf("RB INCR %p (%d) to %d\n", (void*) rb, rb->Name, rb->RefCount);*/
- _glthread_UNLOCK_MUTEX(rb->Mutex);
- *ptr = rb;
- }
-}
-
-
-/**
- * Create a new combined depth/stencil renderbuffer for implementing
- * the GL_EXT_packed_depth_stencil extension.
- * \return new depth/stencil renderbuffer
- */
-struct gl_renderbuffer *
-_mesa_new_depthstencil_renderbuffer(struct gl_context *ctx, GLuint name)
-{
- struct gl_renderbuffer *dsrb;
-
- dsrb = _mesa_new_renderbuffer(ctx, name);
- if (!dsrb)
- return NULL;
-
- /* init fields not covered by _mesa_new_renderbuffer() */
- dsrb->InternalFormat = GL_DEPTH24_STENCIL8_EXT;
- dsrb->Format = MESA_FORMAT_Z24_S8;
- dsrb->AllocStorage = _mesa_soft_renderbuffer_storage;
-
- return dsrb;
-}
+/* + * Mesa 3-D graphics library + * Version: 6.5 + * + * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +/** + * Functions for allocating/managing renderbuffers. + * Also, routines for reading/writing software-based renderbuffer data as + * ubytes, ushorts, uints, etc. + * + * The 'alpha8' renderbuffer is interesting. It's used to add a software-based + * alpha channel to RGB renderbuffers. This is done by wrapping the RGB + * renderbuffer with the alpha renderbuffer. We can do this because of the + * OO-nature of renderbuffers. + * + * Down the road we'll use this for run-time support of 8, 16 and 32-bit + * color channels. For example, Mesa may use 32-bit/float color channels + * internally (swrast) and use wrapper renderbuffers to convert 32-bit + * values down to 16 or 8-bit values for whatever kind of framebuffer we have. + */ + + +#include "glheader.h" +#include "imports.h" +#include "context.h" +#include "fbobject.h" +#include "formats.h" +#include "mtypes.h" +#include "renderbuffer.h" + + +/* + * Routines for get/put values in common buffer formats follow. + * Someday add support for arbitrary row stride to make them more + * flexible. + */ + +/********************************************************************** + * Functions for buffers of 1 X GLubyte values. + * Typically stencil. + */ + +static void * +get_pointer_ubyte(struct gl_context *ctx, struct gl_renderbuffer *rb, + GLint x, GLint y) +{ + if (!rb->Data) + return NULL; + ASSERT(rb->DataType == GL_UNSIGNED_BYTE); + /* Can't assert rb->Format since these funcs may be used for serveral + * different formats (GL_ALPHA8, GL_STENCIL_INDEX8, etc). + */ + return (GLubyte *) rb->Data + y * rb->Width + x; +} + + +static void +get_row_ubyte(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + GLint x, GLint y, void *values) +{ + const GLubyte *src = (const GLubyte *) rb->Data + y * rb->Width + x; + ASSERT(rb->DataType == GL_UNSIGNED_BYTE); + memcpy(values, src, count * sizeof(GLubyte)); +} + + +static void +get_values_ubyte(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + const GLint x[], const GLint y[], void *values) +{ + GLubyte *dst = (GLubyte *) values; + GLuint i; + ASSERT(rb->DataType == GL_UNSIGNED_BYTE); + for (i = 0; i < count; i++) { + const GLubyte *src = (GLubyte *) rb->Data + y[i] * rb->Width + x[i]; + dst[i] = *src; + } +} + + +static void +put_row_ubyte(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + GLint x, GLint y, const void *values, const GLubyte *mask) +{ + const GLubyte *src = (const GLubyte *) values; + GLubyte *dst = (GLubyte *) rb->Data + y * rb->Width + x; + ASSERT(rb->DataType == GL_UNSIGNED_BYTE); + if (mask) { + GLuint i; + for (i = 0; i < count; i++) { + if (mask[i]) { + dst[i] = src[i]; + } + } + } + else { + memcpy(dst, values, count * sizeof(GLubyte)); + } +} + + +static void +put_mono_row_ubyte(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + GLint x, GLint y, const void *value, const GLubyte *mask) +{ + const GLubyte val = *((const GLubyte *) value); + GLubyte *dst = (GLubyte *) rb->Data + y * rb->Width + x; + ASSERT(rb->DataType == GL_UNSIGNED_BYTE); + if (mask) { + GLuint i; + for (i = 0; i < count; i++) { + if (mask[i]) { + dst[i] = val; + } + } + } + else { + GLuint i; + for (i = 0; i < count; i++) { + dst[i] = val; + } + } +} + + +static void +put_values_ubyte(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + const GLint x[], const GLint y[], + const void *values, const GLubyte *mask) +{ + const GLubyte *src = (const GLubyte *) values; + GLuint i; + ASSERT(rb->DataType == GL_UNSIGNED_BYTE); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + GLubyte *dst = (GLubyte *) rb->Data + y[i] * rb->Width + x[i]; + *dst = src[i]; + } + } +} + + +static void +put_mono_values_ubyte(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + const GLint x[], const GLint y[], + const void *value, const GLubyte *mask) +{ + const GLubyte val = *((const GLubyte *) value); + GLuint i; + ASSERT(rb->DataType == GL_UNSIGNED_BYTE); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + GLubyte *dst = (GLubyte *) rb->Data + y[i] * rb->Width + x[i]; + *dst = val; + } + } +} + + +/********************************************************************** + * Functions for buffers of 1 X GLushort values. + * Typically depth/Z. + */ + +static void * +get_pointer_ushort(struct gl_context *ctx, struct gl_renderbuffer *rb, + GLint x, GLint y) +{ + if (!rb->Data) + return NULL; + ASSERT(rb->DataType == GL_UNSIGNED_SHORT); + ASSERT(rb->Width > 0); + return (GLushort *) rb->Data + y * rb->Width + x; +} + + +static void +get_row_ushort(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + GLint x, GLint y, void *values) +{ + const void *src = rb->GetPointer(ctx, rb, x, y); + ASSERT(rb->DataType == GL_UNSIGNED_SHORT); + memcpy(values, src, count * sizeof(GLushort)); +} + + +static void +get_values_ushort(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + const GLint x[], const GLint y[], void *values) +{ + GLushort *dst = (GLushort *) values; + GLuint i; + ASSERT(rb->DataType == GL_UNSIGNED_SHORT); + for (i = 0; i < count; i++) { + const GLushort *src = (GLushort *) rb->Data + y[i] * rb->Width + x[i]; + dst[i] = *src; + } +} + + +static void +put_row_ushort(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + GLint x, GLint y, const void *values, const GLubyte *mask) +{ + const GLushort *src = (const GLushort *) values; + GLushort *dst = (GLushort *) rb->Data + y * rb->Width + x; + ASSERT(rb->DataType == GL_UNSIGNED_SHORT); + if (mask) { + GLuint i; + for (i = 0; i < count; i++) { + if (mask[i]) { + dst[i] = src[i]; + } + } + } + else { + memcpy(dst, src, count * sizeof(GLushort)); + } +} + + +static void +put_mono_row_ushort(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + GLint x, GLint y, const void *value, const GLubyte *mask) +{ + const GLushort val = *((const GLushort *) value); + GLushort *dst = (GLushort *) rb->Data + y * rb->Width + x; + ASSERT(rb->DataType == GL_UNSIGNED_SHORT); + if (mask) { + GLuint i; + for (i = 0; i < count; i++) { + if (mask[i]) { + dst[i] = val; + } + } + } + else { + GLuint i; + for (i = 0; i < count; i++) { + dst[i] = val; + } + } +} + + +static void +put_values_ushort(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + const GLint x[], const GLint y[], const void *values, + const GLubyte *mask) +{ + const GLushort *src = (const GLushort *) values; + GLuint i; + ASSERT(rb->DataType == GL_UNSIGNED_SHORT); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + GLushort *dst = (GLushort *) rb->Data + y[i] * rb->Width + x[i]; + *dst = src[i]; + } + } +} + + +static void +put_mono_values_ushort(struct gl_context *ctx, struct gl_renderbuffer *rb, + GLuint count, const GLint x[], const GLint y[], + const void *value, const GLubyte *mask) +{ + const GLushort val = *((const GLushort *) value); + ASSERT(rb->DataType == GL_UNSIGNED_SHORT); + if (mask) { + GLuint i; + for (i = 0; i < count; i++) { + if (mask[i]) { + GLushort *dst = (GLushort *) rb->Data + y[i] * rb->Width + x[i]; + *dst = val; + } + } + } + else { + GLuint i; + for (i = 0; i < count; i++) { + GLushort *dst = (GLushort *) rb->Data + y[i] * rb->Width + x[i]; + *dst = val; + } + } +} + + +/********************************************************************** + * Functions for buffers of 1 X GLuint values. + * Typically depth/Z or color index. + */ + +static void * +get_pointer_uint(struct gl_context *ctx, struct gl_renderbuffer *rb, + GLint x, GLint y) +{ + if (!rb->Data) + return NULL; + ASSERT(rb->DataType == GL_UNSIGNED_INT || + rb->DataType == GL_UNSIGNED_INT_24_8_EXT); + return (GLuint *) rb->Data + y * rb->Width + x; +} + + +static void +get_row_uint(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + GLint x, GLint y, void *values) +{ + const void *src = rb->GetPointer(ctx, rb, x, y); + ASSERT(rb->DataType == GL_UNSIGNED_INT || + rb->DataType == GL_UNSIGNED_INT_24_8_EXT); + memcpy(values, src, count * sizeof(GLuint)); +} + + +static void +get_values_uint(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + const GLint x[], const GLint y[], void *values) +{ + GLuint *dst = (GLuint *) values; + GLuint i; + ASSERT(rb->DataType == GL_UNSIGNED_INT || + rb->DataType == GL_UNSIGNED_INT_24_8_EXT); + for (i = 0; i < count; i++) { + const GLuint *src = (GLuint *) rb->Data + y[i] * rb->Width + x[i]; + dst[i] = *src; + } +} + + +static void +put_row_uint(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + GLint x, GLint y, const void *values, const GLubyte *mask) +{ + const GLuint *src = (const GLuint *) values; + GLuint *dst = (GLuint *) rb->Data + y * rb->Width + x; + ASSERT(rb->DataType == GL_UNSIGNED_INT || + rb->DataType == GL_UNSIGNED_INT_24_8_EXT); + if (mask) { + GLuint i; + for (i = 0; i < count; i++) { + if (mask[i]) { + dst[i] = src[i]; + } + } + } + else { + memcpy(dst, src, count * sizeof(GLuint)); + } +} + + +static void +put_mono_row_uint(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + GLint x, GLint y, const void *value, const GLubyte *mask) +{ + const GLuint val = *((const GLuint *) value); + GLuint *dst = (GLuint *) rb->Data + y * rb->Width + x; + ASSERT(rb->DataType == GL_UNSIGNED_INT || + rb->DataType == GL_UNSIGNED_INT_24_8_EXT); + if (mask) { + GLuint i; + for (i = 0; i < count; i++) { + if (mask[i]) { + dst[i] = val; + } + } + } + else { + GLuint i; + for (i = 0; i < count; i++) { + dst[i] = val; + } + } +} + + +static void +put_values_uint(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + const GLint x[], const GLint y[], const void *values, + const GLubyte *mask) +{ + const GLuint *src = (const GLuint *) values; + GLuint i; + ASSERT(rb->DataType == GL_UNSIGNED_INT || + rb->DataType == GL_UNSIGNED_INT_24_8_EXT); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + GLuint *dst = (GLuint *) rb->Data + y[i] * rb->Width + x[i]; + *dst = src[i]; + } + } +} + + +static void +put_mono_values_uint(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + const GLint x[], const GLint y[], const void *value, + const GLubyte *mask) +{ + const GLuint val = *((const GLuint *) value); + GLuint i; + ASSERT(rb->DataType == GL_UNSIGNED_INT || + rb->DataType == GL_UNSIGNED_INT_24_8_EXT); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + GLuint *dst = (GLuint *) rb->Data + y[i] * rb->Width + x[i]; + *dst = val; + } + } +} + + +/********************************************************************** + * Functions for buffers of 3 X GLubyte (or GLbyte) values. + * Typically color buffers. + * NOTE: the incoming and outgoing colors are RGBA! We ignore incoming + * alpha values and return 255 for outgoing alpha values. + */ + +static void * +get_pointer_ubyte3(struct gl_context *ctx, struct gl_renderbuffer *rb, + GLint x, GLint y) +{ + ASSERT(rb->Format == MESA_FORMAT_RGB888); + /* No direct access since this buffer is RGB but caller will be + * treating it as if it were RGBA. + */ + return NULL; +} + + +static void +get_row_ubyte3(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + GLint x, GLint y, void *values) +{ + const GLubyte *src = (const GLubyte *) rb->Data + 3 * (y * rb->Width + x); + GLubyte *dst = (GLubyte *) values; + GLuint i; + ASSERT(rb->Format == MESA_FORMAT_RGB888); + ASSERT(rb->DataType == GL_UNSIGNED_BYTE); + for (i = 0; i < count; i++) { + dst[i * 4 + 0] = src[i * 3 + 0]; + dst[i * 4 + 1] = src[i * 3 + 1]; + dst[i * 4 + 2] = src[i * 3 + 2]; + dst[i * 4 + 3] = 255; + } +} + + +static void +get_values_ubyte3(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + const GLint x[], const GLint y[], void *values) +{ + GLubyte *dst = (GLubyte *) values; + GLuint i; + ASSERT(rb->Format == MESA_FORMAT_RGB888); + ASSERT(rb->DataType == GL_UNSIGNED_BYTE); + for (i = 0; i < count; i++) { + const GLubyte *src + = (GLubyte *) rb->Data + 3 * (y[i] * rb->Width + x[i]); + dst[i * 4 + 0] = src[0]; + dst[i * 4 + 1] = src[1]; + dst[i * 4 + 2] = src[2]; + dst[i * 4 + 3] = 255; + } +} + + +static void +put_row_ubyte3(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + GLint x, GLint y, const void *values, const GLubyte *mask) +{ + /* note: incoming values are RGB+A! */ + const GLubyte *src = (const GLubyte *) values; + GLubyte *dst = (GLubyte *) rb->Data + 3 * (y * rb->Width + x); + GLuint i; + ASSERT(rb->Format == MESA_FORMAT_RGB888); + ASSERT(rb->DataType == GL_UNSIGNED_BYTE); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + dst[i * 3 + 0] = src[i * 4 + 0]; + dst[i * 3 + 1] = src[i * 4 + 1]; + dst[i * 3 + 2] = src[i * 4 + 2]; + } + } +} + + +static void +put_row_rgb_ubyte3(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + GLint x, GLint y, const void *values, const GLubyte *mask) +{ + /* note: incoming values are RGB+A! */ + const GLubyte *src = (const GLubyte *) values; + GLubyte *dst = (GLubyte *) rb->Data + 3 * (y * rb->Width + x); + GLuint i; + ASSERT(rb->Format == MESA_FORMAT_RGB888); + ASSERT(rb->DataType == GL_UNSIGNED_BYTE); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + dst[i * 3 + 0] = src[i * 3 + 0]; + dst[i * 3 + 1] = src[i * 3 + 1]; + dst[i * 3 + 2] = src[i * 3 + 2]; + } + } +} + + +static void +put_mono_row_ubyte3(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + GLint x, GLint y, const void *value, const GLubyte *mask) +{ + /* note: incoming value is RGB+A! */ + const GLubyte val0 = ((const GLubyte *) value)[0]; + const GLubyte val1 = ((const GLubyte *) value)[1]; + const GLubyte val2 = ((const GLubyte *) value)[2]; + GLubyte *dst = (GLubyte *) rb->Data + 3 * (y * rb->Width + x); + ASSERT(rb->Format == MESA_FORMAT_RGB888); + ASSERT(rb->DataType == GL_UNSIGNED_BYTE); + if (!mask && val0 == val1 && val1 == val2) { + /* optimized case */ + memset(dst, val0, 3 * count); + } + else { + GLuint i; + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + dst[i * 3 + 0] = val0; + dst[i * 3 + 1] = val1; + dst[i * 3 + 2] = val2; + } + } + } +} + + +static void +put_values_ubyte3(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + const GLint x[], const GLint y[], const void *values, + const GLubyte *mask) +{ + /* note: incoming values are RGB+A! */ + const GLubyte *src = (const GLubyte *) values; + GLuint i; + ASSERT(rb->Format == MESA_FORMAT_RGB888); + ASSERT(rb->DataType == GL_UNSIGNED_BYTE); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + GLubyte *dst = (GLubyte *) rb->Data + 3 * (y[i] * rb->Width + x[i]); + dst[0] = src[i * 4 + 0]; + dst[1] = src[i * 4 + 1]; + dst[2] = src[i * 4 + 2]; + } + } +} + + +static void +put_mono_values_ubyte3(struct gl_context *ctx, struct gl_renderbuffer *rb, + GLuint count, const GLint x[], const GLint y[], + const void *value, const GLubyte *mask) +{ + /* note: incoming value is RGB+A! */ + const GLubyte val0 = ((const GLubyte *) value)[0]; + const GLubyte val1 = ((const GLubyte *) value)[1]; + const GLubyte val2 = ((const GLubyte *) value)[2]; + GLuint i; + ASSERT(rb->Format == MESA_FORMAT_RGB888); + ASSERT(rb->DataType == GL_UNSIGNED_BYTE); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + GLubyte *dst = (GLubyte *) rb->Data + 3 * (y[i] * rb->Width + x[i]); + dst[0] = val0; + dst[1] = val1; + dst[2] = val2; + } + } +} + + +/********************************************************************** + * Functions for buffers of 4 X GLubyte (or GLbyte) values. + * Typically color buffers. + */ + +static void * +get_pointer_ubyte4(struct gl_context *ctx, struct gl_renderbuffer *rb, + GLint x, GLint y) +{ + if (!rb->Data) + return NULL; + ASSERT(rb->DataType == GL_UNSIGNED_BYTE); + ASSERT(rb->Format == MESA_FORMAT_RGBA8888); + return (GLubyte *) rb->Data + 4 * (y * rb->Width + x); +} + + +static void +get_row_ubyte4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + GLint x, GLint y, void *values) +{ + const GLubyte *src = (const GLubyte *) rb->Data + 4 * (y * rb->Width + x); + ASSERT(rb->DataType == GL_UNSIGNED_BYTE); + ASSERT(rb->Format == MESA_FORMAT_RGBA8888); + memcpy(values, src, 4 * count * sizeof(GLubyte)); +} + + +static void +get_values_ubyte4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + const GLint x[], const GLint y[], void *values) +{ + /* treat 4*GLubyte as 1*GLuint */ + GLuint *dst = (GLuint *) values; + GLuint i; + ASSERT(rb->DataType == GL_UNSIGNED_BYTE); + ASSERT(rb->Format == MESA_FORMAT_RGBA8888); + for (i = 0; i < count; i++) { + const GLuint *src = (GLuint *) rb->Data + (y[i] * rb->Width + x[i]); + dst[i] = *src; + } +} + + +static void +put_row_ubyte4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + GLint x, GLint y, const void *values, const GLubyte *mask) +{ + /* treat 4*GLubyte as 1*GLuint */ + const GLuint *src = (const GLuint *) values; + GLuint *dst = (GLuint *) rb->Data + (y * rb->Width + x); + ASSERT(rb->DataType == GL_UNSIGNED_BYTE); + ASSERT(rb->Format == MESA_FORMAT_RGBA8888); + if (mask) { + GLuint i; + for (i = 0; i < count; i++) { + if (mask[i]) { + dst[i] = src[i]; + } + } + } + else { + memcpy(dst, src, 4 * count * sizeof(GLubyte)); + } +} + + +static void +put_row_rgb_ubyte4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + GLint x, GLint y, const void *values, const GLubyte *mask) +{ + /* Store RGB values in RGBA buffer */ + const GLubyte *src = (const GLubyte *) values; + GLubyte *dst = (GLubyte *) rb->Data + 4 * (y * rb->Width + x); + GLuint i; + ASSERT(rb->DataType == GL_UNSIGNED_BYTE); + ASSERT(rb->Format == MESA_FORMAT_RGBA8888); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + dst[i * 4 + 0] = src[i * 3 + 0]; + dst[i * 4 + 1] = src[i * 3 + 1]; + dst[i * 4 + 2] = src[i * 3 + 2]; + dst[i * 4 + 3] = 0xff; + } + } +} + + +static void +put_mono_row_ubyte4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + GLint x, GLint y, const void *value, const GLubyte *mask) +{ + /* treat 4*GLubyte as 1*GLuint */ + const GLuint val = *((const GLuint *) value); + GLuint *dst = (GLuint *) rb->Data + (y * rb->Width + x); + ASSERT(rb->DataType == GL_UNSIGNED_BYTE); + ASSERT(rb->Format == MESA_FORMAT_RGBA8888); + if (!mask && val == 0) { + /* common case */ + memset(dst, 0, count * 4 * sizeof(GLubyte)); + } + else { + /* general case */ + if (mask) { + GLuint i; + for (i = 0; i < count; i++) { + if (mask[i]) { + dst[i] = val; + } + } + } + else { + GLuint i; + for (i = 0; i < count; i++) { + dst[i] = val; + } + } + } +} + + +static void +put_values_ubyte4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + const GLint x[], const GLint y[], const void *values, + const GLubyte *mask) +{ + /* treat 4*GLubyte as 1*GLuint */ + const GLuint *src = (const GLuint *) values; + GLuint i; + ASSERT(rb->DataType == GL_UNSIGNED_BYTE); + ASSERT(rb->Format == MESA_FORMAT_RGBA8888); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + GLuint *dst = (GLuint *) rb->Data + (y[i] * rb->Width + x[i]); + *dst = src[i]; + } + } +} + + +static void +put_mono_values_ubyte4(struct gl_context *ctx, struct gl_renderbuffer *rb, + GLuint count, const GLint x[], const GLint y[], + const void *value, const GLubyte *mask) +{ + /* treat 4*GLubyte as 1*GLuint */ + const GLuint val = *((const GLuint *) value); + GLuint i; + ASSERT(rb->DataType == GL_UNSIGNED_BYTE); + ASSERT(rb->Format == MESA_FORMAT_RGBA8888); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + GLuint *dst = (GLuint *) rb->Data + (y[i] * rb->Width + x[i]); + *dst = val; + } + } +} + + +/********************************************************************** + * Functions for buffers of 4 X GLushort (or GLshort) values. + * Typically accum buffer. + */ + +static void * +get_pointer_ushort4(struct gl_context *ctx, struct gl_renderbuffer *rb, + GLint x, GLint y) +{ + if (!rb->Data) + return NULL; + ASSERT(rb->DataType == GL_UNSIGNED_SHORT || rb->DataType == GL_SHORT); + return (GLushort *) rb->Data + 4 * (y * rb->Width + x); +} + + +static void +get_row_ushort4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + GLint x, GLint y, void *values) +{ + const GLshort *src = (const GLshort *) rb->Data + 4 * (y * rb->Width + x); + ASSERT(rb->DataType == GL_UNSIGNED_SHORT || rb->DataType == GL_SHORT); + memcpy(values, src, 4 * count * sizeof(GLshort)); +} + + +static void +get_values_ushort4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + const GLint x[], const GLint y[], void *values) +{ + GLushort *dst = (GLushort *) values; + GLuint i; + ASSERT(rb->DataType == GL_UNSIGNED_SHORT || rb->DataType == GL_SHORT); + for (i = 0; i < count; i++) { + const GLushort *src + = (GLushort *) rb->Data + 4 * (y[i] * rb->Width + x[i]); + dst[i] = *src; + } +} + + +static void +put_row_ushort4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + GLint x, GLint y, const void *values, const GLubyte *mask) +{ + const GLushort *src = (const GLushort *) values; + GLushort *dst = (GLushort *) rb->Data + 4 * (y * rb->Width + x); + ASSERT(rb->DataType == GL_UNSIGNED_SHORT || rb->DataType == GL_SHORT); + if (mask) { + GLuint i; + for (i = 0; i < count; i++) { + if (mask[i]) { + dst[i * 4 + 0] = src[i * 4 + 0]; + dst[i * 4 + 1] = src[i * 4 + 1]; + dst[i * 4 + 2] = src[i * 4 + 2]; + dst[i * 4 + 3] = src[i * 4 + 3]; + } + } + } + else { + memcpy(dst, src, 4 * count * sizeof(GLushort)); + } +} + + +static void +put_row_rgb_ushort4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + GLint x, GLint y, const void *values, const GLubyte *mask) +{ + /* Put RGB values in RGBA buffer */ + const GLushort *src = (const GLushort *) values; + GLushort *dst = (GLushort *) rb->Data + 4 * (y * rb->Width + x); + ASSERT(rb->DataType == GL_UNSIGNED_SHORT || rb->DataType == GL_SHORT); + if (mask) { + GLuint i; + for (i = 0; i < count; i++) { + if (mask[i]) { + dst[i * 4 + 0] = src[i * 3 + 0]; + dst[i * 4 + 1] = src[i * 3 + 1]; + dst[i * 4 + 2] = src[i * 3 + 2]; + dst[i * 4 + 3] = 0xffff; + } + } + } + else { + memcpy(dst, src, 4 * count * sizeof(GLushort)); + } +} + + +static void +put_mono_row_ushort4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + GLint x, GLint y, const void *value, const GLubyte *mask) +{ + const GLushort val0 = ((const GLushort *) value)[0]; + const GLushort val1 = ((const GLushort *) value)[1]; + const GLushort val2 = ((const GLushort *) value)[2]; + const GLushort val3 = ((const GLushort *) value)[3]; + GLushort *dst = (GLushort *) rb->Data + 4 * (y * rb->Width + x); + ASSERT(rb->DataType == GL_UNSIGNED_SHORT || rb->DataType == GL_SHORT); + if (!mask && val0 == 0 && val1 == 0 && val2 == 0 && val3 == 0) { + /* common case for clearing accum buffer */ + memset(dst, 0, count * 4 * sizeof(GLushort)); + } + else { + GLuint i; + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + dst[i * 4 + 0] = val0; + dst[i * 4 + 1] = val1; + dst[i * 4 + 2] = val2; + dst[i * 4 + 3] = val3; + } + } + } +} + + +static void +put_values_ushort4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + const GLint x[], const GLint y[], const void *values, + const GLubyte *mask) +{ + const GLushort *src = (const GLushort *) values; + GLuint i; + ASSERT(rb->DataType == GL_UNSIGNED_SHORT || rb->DataType == GL_SHORT); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + GLushort *dst = (GLushort *) rb->Data + 4 * (y[i] * rb->Width + x[i]); + dst[0] = src[i * 4 + 0]; + dst[1] = src[i * 4 + 1]; + dst[2] = src[i * 4 + 2]; + dst[3] = src[i * 4 + 3]; + } + } +} + + +static void +put_mono_values_ushort4(struct gl_context *ctx, struct gl_renderbuffer *rb, + GLuint count, const GLint x[], const GLint y[], + const void *value, const GLubyte *mask) +{ + const GLushort val0 = ((const GLushort *) value)[0]; + const GLushort val1 = ((const GLushort *) value)[1]; + const GLushort val2 = ((const GLushort *) value)[2]; + const GLushort val3 = ((const GLushort *) value)[3]; + GLuint i; + ASSERT(rb->DataType == GL_UNSIGNED_SHORT || rb->DataType == GL_SHORT); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + GLushort *dst = (GLushort *) rb->Data + 4 * (y[i] * rb->Width + x[i]); + dst[0] = val0; + dst[1] = val1; + dst[2] = val2; + dst[3] = val3; + } + } +} + + + +/** + * This is a software fallback for the gl_renderbuffer->AllocStorage + * function. + * Device drivers will typically override this function for the buffers + * which it manages (typically color buffers, Z and stencil). + * Other buffers (like software accumulation and aux buffers) which the driver + * doesn't manage can be handled with this function. + * + * This one multi-purpose function can allocate stencil, depth, accum, color + * or color-index buffers! + * + * This function also plugs in the appropriate GetPointer, Get/PutRow and + * Get/PutValues functions. + */ +GLboolean +_mesa_soft_renderbuffer_storage(struct gl_context *ctx, struct gl_renderbuffer *rb, + GLenum internalFormat, + GLuint width, GLuint height) +{ + GLuint pixelSize; + + switch (internalFormat) { + case GL_RGB: + case GL_R3_G3_B2: + case GL_RGB4: + case GL_RGB5: + case GL_RGB8: + case GL_RGB10: + case GL_RGB12: + case GL_RGB16: + rb->Format = MESA_FORMAT_RGB888; + rb->DataType = GL_UNSIGNED_BYTE; + rb->GetPointer = get_pointer_ubyte3; + rb->GetRow = get_row_ubyte3; + rb->GetValues = get_values_ubyte3; + rb->PutRow = put_row_ubyte3; + rb->PutRowRGB = put_row_rgb_ubyte3; + rb->PutMonoRow = put_mono_row_ubyte3; + rb->PutValues = put_values_ubyte3; + rb->PutMonoValues = put_mono_values_ubyte3; + pixelSize = 3 * sizeof(GLubyte); + break; + case GL_RGBA: + case GL_RGBA2: + case GL_RGBA4: + case GL_RGB5_A1: + case GL_RGBA8: +#if 1 + case GL_RGB10_A2: + case GL_RGBA12: +#endif + rb->Format = MESA_FORMAT_RGBA8888; + rb->DataType = GL_UNSIGNED_BYTE; + rb->GetPointer = get_pointer_ubyte4; + rb->GetRow = get_row_ubyte4; + rb->GetValues = get_values_ubyte4; + rb->PutRow = put_row_ubyte4; + rb->PutRowRGB = put_row_rgb_ubyte4; + rb->PutMonoRow = put_mono_row_ubyte4; + rb->PutValues = put_values_ubyte4; + rb->PutMonoValues = put_mono_values_ubyte4; + pixelSize = 4 * sizeof(GLubyte); + break; + case GL_RGBA16: + case GL_RGBA16_SNORM: + /* for accum buffer */ + rb->Format = MESA_FORMAT_SIGNED_RGBA_16; + rb->DataType = GL_SHORT; + rb->GetPointer = get_pointer_ushort4; + rb->GetRow = get_row_ushort4; + rb->GetValues = get_values_ushort4; + rb->PutRow = put_row_ushort4; + rb->PutRowRGB = put_row_rgb_ushort4; + rb->PutMonoRow = put_mono_row_ushort4; + rb->PutValues = put_values_ushort4; + rb->PutMonoValues = put_mono_values_ushort4; + pixelSize = 4 * sizeof(GLushort); + break; +#if 0 + case GL_ALPHA8: + rb->Format = MESA_FORMAT_A8; + rb->DataType = GL_UNSIGNED_BYTE; + rb->GetPointer = get_pointer_alpha8; + rb->GetRow = get_row_alpha8; + rb->GetValues = get_values_alpha8; + rb->PutRow = put_row_alpha8; + rb->PutRowRGB = NULL; + rb->PutMonoRow = put_mono_row_alpha8; + rb->PutValues = put_values_alpha8; + rb->PutMonoValues = put_mono_values_alpha8; + pixelSize = sizeof(GLubyte); + break; +#endif + case GL_STENCIL_INDEX: + case GL_STENCIL_INDEX1_EXT: + case GL_STENCIL_INDEX4_EXT: + case GL_STENCIL_INDEX8_EXT: + case GL_STENCIL_INDEX16_EXT: + rb->Format = MESA_FORMAT_S8; + rb->DataType = GL_UNSIGNED_BYTE; + rb->GetPointer = get_pointer_ubyte; + rb->GetRow = get_row_ubyte; + rb->GetValues = get_values_ubyte; + rb->PutRow = put_row_ubyte; + rb->PutRowRGB = NULL; + rb->PutMonoRow = put_mono_row_ubyte; + rb->PutValues = put_values_ubyte; + rb->PutMonoValues = put_mono_values_ubyte; + pixelSize = sizeof(GLubyte); + break; + case GL_DEPTH_COMPONENT: + case GL_DEPTH_COMPONENT16: + rb->Format = MESA_FORMAT_Z16; + rb->DataType = GL_UNSIGNED_SHORT; + rb->GetPointer = get_pointer_ushort; + rb->GetRow = get_row_ushort; + rb->GetValues = get_values_ushort; + rb->PutRow = put_row_ushort; + rb->PutRowRGB = NULL; + rb->PutMonoRow = put_mono_row_ushort; + rb->PutValues = put_values_ushort; + rb->PutMonoValues = put_mono_values_ushort; + pixelSize = sizeof(GLushort); + break; + case GL_DEPTH_COMPONENT24: + rb->DataType = GL_UNSIGNED_INT; + rb->GetPointer = get_pointer_uint; + rb->GetRow = get_row_uint; + rb->GetValues = get_values_uint; + rb->PutRow = put_row_uint; + rb->PutRowRGB = NULL; + rb->PutMonoRow = put_mono_row_uint; + rb->PutValues = put_values_uint; + rb->PutMonoValues = put_mono_values_uint; + rb->Format = MESA_FORMAT_X8_Z24; + pixelSize = sizeof(GLuint); + break; + case GL_DEPTH_COMPONENT32: + rb->DataType = GL_UNSIGNED_INT; + rb->GetPointer = get_pointer_uint; + rb->GetRow = get_row_uint; + rb->GetValues = get_values_uint; + rb->PutRow = put_row_uint; + rb->PutRowRGB = NULL; + rb->PutMonoRow = put_mono_row_uint; + rb->PutValues = put_values_uint; + rb->PutMonoValues = put_mono_values_uint; + rb->Format = MESA_FORMAT_Z32; + pixelSize = sizeof(GLuint); + break; + case GL_DEPTH_STENCIL_EXT: + case GL_DEPTH24_STENCIL8_EXT: + rb->Format = MESA_FORMAT_Z24_S8; + rb->DataType = GL_UNSIGNED_INT_24_8_EXT; + rb->GetPointer = get_pointer_uint; + rb->GetRow = get_row_uint; + rb->GetValues = get_values_uint; + rb->PutRow = put_row_uint; + rb->PutRowRGB = NULL; + rb->PutMonoRow = put_mono_row_uint; + rb->PutValues = put_values_uint; + rb->PutMonoValues = put_mono_values_uint; + pixelSize = sizeof(GLuint); + break; + default: + /* unsupported format */ + return GL_FALSE; + } + + ASSERT(rb->DataType); + ASSERT(rb->GetPointer); + ASSERT(rb->GetRow); + ASSERT(rb->GetValues); + ASSERT(rb->PutRow); + ASSERT(rb->PutMonoRow); + ASSERT(rb->PutValues); + ASSERT(rb->PutMonoValues); + + /* free old buffer storage */ + if (rb->Data) { + free(rb->Data); + rb->Data = NULL; + } + + if (width > 0 && height > 0) { + /* allocate new buffer storage */ + rb->Data = malloc(width * height * pixelSize); + + if (rb->Data == NULL) { + rb->Width = 0; + rb->Height = 0; + _mesa_error(ctx, GL_OUT_OF_MEMORY, + "software renderbuffer allocation (%d x %d x %d)", + width, height, pixelSize); + return GL_FALSE; + } + } + + rb->Width = width; + rb->Height = height; + rb->_BaseFormat = _mesa_base_fbo_format(ctx, internalFormat); + ASSERT(rb->_BaseFormat); + + return GL_TRUE; +} + + + +/**********************************************************************/ +/**********************************************************************/ +/**********************************************************************/ + + +/** + * Here we utilize the gl_renderbuffer->Wrapper field to put an alpha + * buffer wrapper around an existing RGB renderbuffer (hw or sw). + * + * When PutRow is called (for example), we store the alpha values in + * this buffer, then pass on the PutRow call to the wrapped RGB + * buffer. + */ + + +static GLboolean +alloc_storage_alpha8(struct gl_context *ctx, struct gl_renderbuffer *arb, + GLenum internalFormat, GLuint width, GLuint height) +{ + ASSERT(arb != arb->Wrapped); + ASSERT(arb->Format == MESA_FORMAT_A8); + + /* first, pass the call to the wrapped RGB buffer */ + if (!arb->Wrapped->AllocStorage(ctx, arb->Wrapped, internalFormat, + width, height)) { + return GL_FALSE; + } + + /* next, resize my alpha buffer */ + if (arb->Data) { + free(arb->Data); + } + + arb->Data = malloc(width * height * sizeof(GLubyte)); + if (arb->Data == NULL) { + arb->Width = 0; + arb->Height = 0; + _mesa_error(ctx, GL_OUT_OF_MEMORY, "software alpha buffer allocation"); + return GL_FALSE; + } + + arb->Width = width; + arb->Height = height; + + return GL_TRUE; +} + + +/** + * Delete an alpha_renderbuffer object, as well as the wrapped RGB buffer. + */ +static void +delete_renderbuffer_alpha8(struct gl_renderbuffer *arb) +{ + if (arb->Data) { + free(arb->Data); + } + ASSERT(arb->Wrapped); + ASSERT(arb != arb->Wrapped); + arb->Wrapped->Delete(arb->Wrapped); + arb->Wrapped = NULL; + free(arb); +} + + +static void * +get_pointer_alpha8(struct gl_context *ctx, struct gl_renderbuffer *arb, + GLint x, GLint y) +{ + return NULL; /* don't allow direct access! */ +} + + +static void +get_row_alpha8(struct gl_context *ctx, struct gl_renderbuffer *arb, GLuint count, + GLint x, GLint y, void *values) +{ + /* NOTE: 'values' is RGBA format! */ + const GLubyte *src = (const GLubyte *) arb->Data + y * arb->Width + x; + GLubyte *dst = (GLubyte *) values; + GLuint i; + ASSERT(arb != arb->Wrapped); + ASSERT(arb->DataType == GL_UNSIGNED_BYTE); + /* first, pass the call to the wrapped RGB buffer */ + arb->Wrapped->GetRow(ctx, arb->Wrapped, count, x, y, values); + /* second, fill in alpha values from this buffer! */ + for (i = 0; i < count; i++) { + dst[i * 4 + 3] = src[i]; + } +} + + +static void +get_values_alpha8(struct gl_context *ctx, struct gl_renderbuffer *arb, GLuint count, + const GLint x[], const GLint y[], void *values) +{ + GLubyte *dst = (GLubyte *) values; + GLuint i; + ASSERT(arb != arb->Wrapped); + ASSERT(arb->DataType == GL_UNSIGNED_BYTE); + /* first, pass the call to the wrapped RGB buffer */ + arb->Wrapped->GetValues(ctx, arb->Wrapped, count, x, y, values); + /* second, fill in alpha values from this buffer! */ + for (i = 0; i < count; i++) { + const GLubyte *src = (GLubyte *) arb->Data + y[i] * arb->Width + x[i]; + dst[i * 4 + 3] = *src; + } +} + + +static void +put_row_alpha8(struct gl_context *ctx, struct gl_renderbuffer *arb, GLuint count, + GLint x, GLint y, const void *values, const GLubyte *mask) +{ + const GLubyte *src = (const GLubyte *) values; + GLubyte *dst = (GLubyte *) arb->Data + y * arb->Width + x; + GLuint i; + ASSERT(arb != arb->Wrapped); + ASSERT(arb->DataType == GL_UNSIGNED_BYTE); + /* first, pass the call to the wrapped RGB buffer */ + arb->Wrapped->PutRow(ctx, arb->Wrapped, count, x, y, values, mask); + /* second, store alpha in our buffer */ + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + dst[i] = src[i * 4 + 3]; + } + } +} + + +static void +put_row_rgb_alpha8(struct gl_context *ctx, struct gl_renderbuffer *arb, GLuint count, + GLint x, GLint y, const void *values, const GLubyte *mask) +{ + const GLubyte *src = (const GLubyte *) values; + GLubyte *dst = (GLubyte *) arb->Data + y * arb->Width + x; + GLuint i; + ASSERT(arb != arb->Wrapped); + ASSERT(arb->DataType == GL_UNSIGNED_BYTE); + /* first, pass the call to the wrapped RGB buffer */ + arb->Wrapped->PutRowRGB(ctx, arb->Wrapped, count, x, y, values, mask); + /* second, store alpha in our buffer */ + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + dst[i] = src[i * 4 + 3]; + } + } +} + + +static void +put_mono_row_alpha8(struct gl_context *ctx, struct gl_renderbuffer *arb, GLuint count, + GLint x, GLint y, const void *value, const GLubyte *mask) +{ + const GLubyte val = ((const GLubyte *) value)[3]; + GLubyte *dst = (GLubyte *) arb->Data + y * arb->Width + x; + ASSERT(arb != arb->Wrapped); + ASSERT(arb->DataType == GL_UNSIGNED_BYTE); + /* first, pass the call to the wrapped RGB buffer */ + arb->Wrapped->PutMonoRow(ctx, arb->Wrapped, count, x, y, value, mask); + /* second, store alpha in our buffer */ + if (mask) { + GLuint i; + for (i = 0; i < count; i++) { + if (mask[i]) { + dst[i] = val; + } + } + } + else { + memset(dst, val, count); + } +} + + +static void +put_values_alpha8(struct gl_context *ctx, struct gl_renderbuffer *arb, GLuint count, + const GLint x[], const GLint y[], + const void *values, const GLubyte *mask) +{ + const GLubyte *src = (const GLubyte *) values; + GLuint i; + ASSERT(arb != arb->Wrapped); + ASSERT(arb->DataType == GL_UNSIGNED_BYTE); + /* first, pass the call to the wrapped RGB buffer */ + arb->Wrapped->PutValues(ctx, arb->Wrapped, count, x, y, values, mask); + /* second, store alpha in our buffer */ + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + GLubyte *dst = (GLubyte *) arb->Data + y[i] * arb->Width + x[i]; + *dst = src[i * 4 + 3]; + } + } +} + + +static void +put_mono_values_alpha8(struct gl_context *ctx, struct gl_renderbuffer *arb, + GLuint count, const GLint x[], const GLint y[], + const void *value, const GLubyte *mask) +{ + const GLubyte val = ((const GLubyte *) value)[3]; + GLuint i; + ASSERT(arb != arb->Wrapped); + ASSERT(arb->DataType == GL_UNSIGNED_BYTE); + /* first, pass the call to the wrapped RGB buffer */ + arb->Wrapped->PutValues(ctx, arb->Wrapped, count, x, y, value, mask); + /* second, store alpha in our buffer */ + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + GLubyte *dst = (GLubyte *) arb->Data + y[i] * arb->Width + x[i]; + *dst = val; + } + } +} + + +static void +copy_buffer_alpha8(struct gl_renderbuffer* dst, struct gl_renderbuffer* src) +{ + ASSERT(dst->Format == MESA_FORMAT_A8); + ASSERT(src->Format == MESA_FORMAT_A8); + ASSERT(dst->Width == src->Width); + ASSERT(dst->Height == src->Height); + + memcpy(dst->Data, src->Data, dst->Width * dst->Height * sizeof(GLubyte)); +} + + +/**********************************************************************/ +/**********************************************************************/ +/**********************************************************************/ + + +/** + * Default GetPointer routine. Always return NULL to indicate that + * direct buffer access is not supported. + */ +static void * +nop_get_pointer(struct gl_context *ctx, struct gl_renderbuffer *rb, GLint x, GLint y) +{ + return NULL; +} + + +/** + * Initialize the fields of a gl_renderbuffer to default values. + */ +void +_mesa_init_renderbuffer(struct gl_renderbuffer *rb, GLuint name) +{ + _glthread_INIT_MUTEX(rb->Mutex); + + rb->Magic = RB_MAGIC; + rb->ClassID = 0; + rb->Name = name; + rb->RefCount = 0; + rb->Delete = _mesa_delete_renderbuffer; + + /* The rest of these should be set later by the caller of this function or + * the AllocStorage method: + */ + rb->AllocStorage = NULL; + + rb->Width = 0; + rb->Height = 0; + rb->InternalFormat = GL_NONE; + rb->Format = MESA_FORMAT_NONE; + + rb->DataType = GL_NONE; + rb->Data = NULL; + + /* Point back to ourself so that we don't have to check for Wrapped==NULL + * all over the drivers. + */ + rb->Wrapped = rb; + + rb->GetPointer = nop_get_pointer; + rb->GetRow = NULL; + rb->GetValues = NULL; + rb->PutRow = NULL; + rb->PutRowRGB = NULL; + rb->PutMonoRow = NULL; + rb->PutValues = NULL; + rb->PutMonoValues = NULL; +} + + +/** + * Allocate a new gl_renderbuffer object. This can be used for user-created + * renderbuffers or window-system renderbuffers. + */ +struct gl_renderbuffer * +_mesa_new_renderbuffer(struct gl_context *ctx, GLuint name) +{ + struct gl_renderbuffer *rb = CALLOC_STRUCT(gl_renderbuffer); + if (rb) { + _mesa_init_renderbuffer(rb, name); + } + return rb; +} + + +/** + * Delete a gl_framebuffer. + * This is the default function for renderbuffer->Delete(). + */ +void +_mesa_delete_renderbuffer(struct gl_renderbuffer *rb) +{ + if (rb->Data) { + free(rb->Data); + } + free(rb); +} + + +/** + * Allocate a software-based renderbuffer. This is called via the + * ctx->Driver.NewRenderbuffer() function when the user creates a new + * renderbuffer. + * This would not be used for hardware-based renderbuffers. + */ +struct gl_renderbuffer * +_mesa_new_soft_renderbuffer(struct gl_context *ctx, GLuint name) +{ + struct gl_renderbuffer *rb = _mesa_new_renderbuffer(ctx, name); + if (rb) { + rb->AllocStorage = _mesa_soft_renderbuffer_storage; + /* Normally, one would setup the PutRow, GetRow, etc functions here. + * But we're doing that in the _mesa_soft_renderbuffer_storage() function + * instead. + */ + } + return rb; +} + + +/** + * Add software-based color renderbuffers to the given framebuffer. + * This is a helper routine for device drivers when creating a + * window system framebuffer (not a user-created render/framebuffer). + * Once this function is called, you can basically forget about this + * renderbuffer; core Mesa will handle all the buffer management and + * rendering! + */ +GLboolean +_mesa_add_color_renderbuffers(struct gl_context *ctx, struct gl_framebuffer *fb, + GLuint rgbBits, GLuint alphaBits, + GLboolean frontLeft, GLboolean backLeft, + GLboolean frontRight, GLboolean backRight) +{ + gl_buffer_index b; + + if (rgbBits > 16 || alphaBits > 16) { + _mesa_problem(ctx, + "Unsupported bit depth in _mesa_add_color_renderbuffers"); + return GL_FALSE; + } + + assert(MAX_COLOR_ATTACHMENTS >= 4); + + for (b = BUFFER_FRONT_LEFT; b <= BUFFER_BACK_RIGHT; b++) { + struct gl_renderbuffer *rb; + + if (b == BUFFER_FRONT_LEFT && !frontLeft) + continue; + else if (b == BUFFER_BACK_LEFT && !backLeft) + continue; + else if (b == BUFFER_FRONT_RIGHT && !frontRight) + continue; + else if (b == BUFFER_BACK_RIGHT && !backRight) + continue; + + assert(fb->Attachment[b].Renderbuffer == NULL); + + rb = _mesa_new_renderbuffer(ctx, 0); + if (!rb) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "Allocating color buffer"); + return GL_FALSE; + } + + if (rgbBits <= 8) { + if (alphaBits) + rb->Format = MESA_FORMAT_RGBA8888; + else + rb->Format = MESA_FORMAT_RGB888; + } + else { + assert(rgbBits <= 16); + rb->Format = MESA_FORMAT_NONE; /*XXX RGBA16;*/ + } + rb->InternalFormat = GL_RGBA; + + rb->AllocStorage = _mesa_soft_renderbuffer_storage; + _mesa_add_renderbuffer(fb, b, rb); + } + + return GL_TRUE; +} + + +/** + * Add software-based alpha renderbuffers to the given framebuffer. + * This is a helper routine for device drivers when creating a + * window system framebuffer (not a user-created render/framebuffer). + * Once this function is called, you can basically forget about this + * renderbuffer; core Mesa will handle all the buffer management and + * rendering! + */ +GLboolean +_mesa_add_alpha_renderbuffers(struct gl_context *ctx, struct gl_framebuffer *fb, + GLuint alphaBits, + GLboolean frontLeft, GLboolean backLeft, + GLboolean frontRight, GLboolean backRight) +{ + gl_buffer_index b; + + /* for window system framebuffers only! */ + assert(fb->Name == 0); + + if (alphaBits > 8) { + _mesa_problem(ctx, + "Unsupported bit depth in _mesa_add_alpha_renderbuffers"); + return GL_FALSE; + } + + assert(MAX_COLOR_ATTACHMENTS >= 4); + + /* Wrap each of the RGB color buffers with an alpha renderbuffer. + */ + for (b = BUFFER_FRONT_LEFT; b <= BUFFER_BACK_RIGHT; b++) { + struct gl_renderbuffer *arb; + + if (b == BUFFER_FRONT_LEFT && !frontLeft) + continue; + else if (b == BUFFER_BACK_LEFT && !backLeft) + continue; + else if (b == BUFFER_FRONT_RIGHT && !frontRight) + continue; + else if (b == BUFFER_BACK_RIGHT && !backRight) + continue; + + /* the RGB buffer to wrap must already exist!! */ + assert(fb->Attachment[b].Renderbuffer); + + /* only GLubyte supported for now */ + assert(fb->Attachment[b].Renderbuffer->DataType == GL_UNSIGNED_BYTE); + + /* allocate alpha renderbuffer */ + arb = _mesa_new_renderbuffer(ctx, 0); + if (!arb) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "Allocating alpha buffer"); + return GL_FALSE; + } + + /* wrap the alpha renderbuffer around the RGB renderbuffer */ + arb->Wrapped = fb->Attachment[b].Renderbuffer; + + /* Set up my alphabuffer fields and plug in my functions. + * The functions will put/get the alpha values from/to RGBA arrays + * and then call the wrapped buffer's functions to handle the RGB + * values. + */ + arb->InternalFormat = arb->Wrapped->InternalFormat; + arb->Format = MESA_FORMAT_A8; + arb->DataType = arb->Wrapped->DataType; + arb->AllocStorage = alloc_storage_alpha8; + arb->Delete = delete_renderbuffer_alpha8; + arb->GetPointer = get_pointer_alpha8; + arb->GetRow = get_row_alpha8; + arb->GetValues = get_values_alpha8; + arb->PutRow = put_row_alpha8; + arb->PutRowRGB = put_row_rgb_alpha8; + arb->PutMonoRow = put_mono_row_alpha8; + arb->PutValues = put_values_alpha8; + arb->PutMonoValues = put_mono_values_alpha8; + + /* clear the pointer to avoid assertion/sanity check failure later */ + fb->Attachment[b].Renderbuffer = NULL; + + /* plug the alpha renderbuffer into the colorbuffer attachment */ + _mesa_add_renderbuffer(fb, b, arb); + } + + return GL_TRUE; +} + + +/** + * For framebuffers that use a software alpha channel wrapper + * created by _mesa_add_alpha_renderbuffer or _mesa_add_soft_renderbuffers, + * copy the back buffer alpha channel into the front buffer alpha channel. + */ +void +_mesa_copy_soft_alpha_renderbuffers(struct gl_context *ctx, struct gl_framebuffer *fb) +{ + if (fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer && + fb->Attachment[BUFFER_BACK_LEFT].Renderbuffer) + copy_buffer_alpha8(fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer, + fb->Attachment[BUFFER_BACK_LEFT].Renderbuffer); + + + if (fb->Attachment[BUFFER_FRONT_RIGHT].Renderbuffer && + fb->Attachment[BUFFER_BACK_RIGHT].Renderbuffer) + copy_buffer_alpha8(fb->Attachment[BUFFER_FRONT_RIGHT].Renderbuffer, + fb->Attachment[BUFFER_BACK_RIGHT].Renderbuffer); +} + + +/** + * Add a software-based depth renderbuffer to the given framebuffer. + * This is a helper routine for device drivers when creating a + * window system framebuffer (not a user-created render/framebuffer). + * Once this function is called, you can basically forget about this + * renderbuffer; core Mesa will handle all the buffer management and + * rendering! + */ +GLboolean +_mesa_add_depth_renderbuffer(struct gl_context *ctx, struct gl_framebuffer *fb, + GLuint depthBits) +{ + struct gl_renderbuffer *rb; + + if (depthBits > 32) { + _mesa_problem(ctx, + "Unsupported depthBits in _mesa_add_depth_renderbuffer"); + return GL_FALSE; + } + + assert(fb->Attachment[BUFFER_DEPTH].Renderbuffer == NULL); + + rb = _mesa_new_renderbuffer(ctx, 0); + if (!rb) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "Allocating depth buffer"); + return GL_FALSE; + } + + if (depthBits <= 16) { + rb->Format = MESA_FORMAT_Z16; + rb->InternalFormat = GL_DEPTH_COMPONENT16; + } + else if (depthBits <= 24) { + rb->Format = MESA_FORMAT_X8_Z24; + rb->InternalFormat = GL_DEPTH_COMPONENT24; + } + else { + rb->Format = MESA_FORMAT_Z32; + rb->InternalFormat = GL_DEPTH_COMPONENT32; + } + + rb->AllocStorage = _mesa_soft_renderbuffer_storage; + _mesa_add_renderbuffer(fb, BUFFER_DEPTH, rb); + + return GL_TRUE; +} + + +/** + * Add a software-based stencil renderbuffer to the given framebuffer. + * This is a helper routine for device drivers when creating a + * window system framebuffer (not a user-created render/framebuffer). + * Once this function is called, you can basically forget about this + * renderbuffer; core Mesa will handle all the buffer management and + * rendering! + */ +GLboolean +_mesa_add_stencil_renderbuffer(struct gl_context *ctx, struct gl_framebuffer *fb, + GLuint stencilBits) +{ + struct gl_renderbuffer *rb; + + if (stencilBits > 16) { + _mesa_problem(ctx, + "Unsupported stencilBits in _mesa_add_stencil_renderbuffer"); + return GL_FALSE; + } + + assert(fb->Attachment[BUFFER_STENCIL].Renderbuffer == NULL); + + rb = _mesa_new_renderbuffer(ctx, 0); + if (!rb) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "Allocating stencil buffer"); + return GL_FALSE; + } + + assert(stencilBits <= 8); + rb->Format = MESA_FORMAT_S8; + rb->InternalFormat = GL_STENCIL_INDEX8; + + rb->AllocStorage = _mesa_soft_renderbuffer_storage; + _mesa_add_renderbuffer(fb, BUFFER_STENCIL, rb); + + return GL_TRUE; +} + + +/** + * Add a software-based accumulation renderbuffer to the given framebuffer. + * This is a helper routine for device drivers when creating a + * window system framebuffer (not a user-created render/framebuffer). + * Once this function is called, you can basically forget about this + * renderbuffer; core Mesa will handle all the buffer management and + * rendering! + */ +GLboolean +_mesa_add_accum_renderbuffer(struct gl_context *ctx, struct gl_framebuffer *fb, + GLuint redBits, GLuint greenBits, + GLuint blueBits, GLuint alphaBits) +{ + struct gl_renderbuffer *rb; + + if (redBits > 16 || greenBits > 16 || blueBits > 16 || alphaBits > 16) { + _mesa_problem(ctx, + "Unsupported accumBits in _mesa_add_accum_renderbuffer"); + return GL_FALSE; + } + + assert(fb->Attachment[BUFFER_ACCUM].Renderbuffer == NULL); + + rb = _mesa_new_renderbuffer(ctx, 0); + if (!rb) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "Allocating accum buffer"); + return GL_FALSE; + } + + rb->Format = MESA_FORMAT_SIGNED_RGBA_16; + rb->InternalFormat = GL_RGBA16_SNORM; + rb->AllocStorage = _mesa_soft_renderbuffer_storage; + _mesa_add_renderbuffer(fb, BUFFER_ACCUM, rb); + + return GL_TRUE; +} + + + +/** + * Add a software-based aux renderbuffer to the given framebuffer. + * This is a helper routine for device drivers when creating a + * window system framebuffer (not a user-created render/framebuffer). + * Once this function is called, you can basically forget about this + * renderbuffer; core Mesa will handle all the buffer management and + * rendering! + * + * NOTE: color-index aux buffers not supported. + */ +GLboolean +_mesa_add_aux_renderbuffers(struct gl_context *ctx, struct gl_framebuffer *fb, + GLuint colorBits, GLuint numBuffers) +{ + GLuint i; + + if (colorBits > 16) { + _mesa_problem(ctx, + "Unsupported accumBits in _mesa_add_aux_renderbuffers"); + return GL_FALSE; + } + + assert(numBuffers <= MAX_AUX_BUFFERS); + + for (i = 0; i < numBuffers; i++) { + struct gl_renderbuffer *rb = _mesa_new_renderbuffer(ctx, 0); + + assert(fb->Attachment[BUFFER_AUX0 + i].Renderbuffer == NULL); + + if (!rb) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "Allocating aux buffer"); + return GL_FALSE; + } + + assert (colorBits <= 8); + rb->Format = MESA_FORMAT_RGBA8888; + rb->InternalFormat = GL_RGBA; + + rb->AllocStorage = _mesa_soft_renderbuffer_storage; + _mesa_add_renderbuffer(fb, BUFFER_AUX0 + i, rb); + } + return GL_TRUE; +} + + +/** + * Create/attach software-based renderbuffers to the given framebuffer. + * This is a helper routine for device drivers. Drivers can just as well + * call the individual _mesa_add_*_renderbuffer() routines directly. + */ +void +_mesa_add_soft_renderbuffers(struct gl_framebuffer *fb, + GLboolean color, + GLboolean depth, + GLboolean stencil, + GLboolean accum, + GLboolean alpha, + GLboolean aux) +{ + GLboolean frontLeft = GL_TRUE; + GLboolean backLeft = fb->Visual.doubleBufferMode; + GLboolean frontRight = fb->Visual.stereoMode; + GLboolean backRight = fb->Visual.stereoMode && fb->Visual.doubleBufferMode; + + if (color) { + assert(fb->Visual.redBits == fb->Visual.greenBits); + assert(fb->Visual.redBits == fb->Visual.blueBits); + _mesa_add_color_renderbuffers(NULL, fb, + fb->Visual.redBits, + fb->Visual.alphaBits, + frontLeft, backLeft, + frontRight, backRight); + } + + if (depth) { + assert(fb->Visual.depthBits > 0); + _mesa_add_depth_renderbuffer(NULL, fb, fb->Visual.depthBits); + } + + if (stencil) { + assert(fb->Visual.stencilBits > 0); + _mesa_add_stencil_renderbuffer(NULL, fb, fb->Visual.stencilBits); + } + + if (accum) { + assert(fb->Visual.accumRedBits > 0); + assert(fb->Visual.accumGreenBits > 0); + assert(fb->Visual.accumBlueBits > 0); + _mesa_add_accum_renderbuffer(NULL, fb, + fb->Visual.accumRedBits, + fb->Visual.accumGreenBits, + fb->Visual.accumBlueBits, + fb->Visual.accumAlphaBits); + } + + if (aux) { + assert(fb->Visual.numAuxBuffers > 0); + _mesa_add_aux_renderbuffers(NULL, fb, fb->Visual.redBits, + fb->Visual.numAuxBuffers); + } + + if (alpha) { + assert(fb->Visual.alphaBits > 0); + _mesa_add_alpha_renderbuffers(NULL, fb, fb->Visual.alphaBits, + frontLeft, backLeft, + frontRight, backRight); + } + +#if 0 + if (multisample) { + /* maybe someday */ + } +#endif +} + + +/** + * Attach a renderbuffer to a framebuffer. + * \param bufferName one of the BUFFER_x tokens + */ +void +_mesa_add_renderbuffer(struct gl_framebuffer *fb, + gl_buffer_index bufferName, struct gl_renderbuffer *rb) +{ + assert(fb); + assert(rb); + assert(bufferName < BUFFER_COUNT); + + /* There should be no previous renderbuffer on this attachment point, + * with the exception of depth/stencil since the same renderbuffer may + * be used for both. + */ + assert(bufferName == BUFFER_DEPTH || + bufferName == BUFFER_STENCIL || + fb->Attachment[bufferName].Renderbuffer == NULL); + + /* winsys vs. user-created buffer cross check */ + if (fb->Name) { + assert(rb->Name); + } + else { + assert(!rb->Name); + } + + fb->Attachment[bufferName].Type = GL_RENDERBUFFER_EXT; + fb->Attachment[bufferName].Complete = GL_TRUE; + _mesa_reference_renderbuffer(&fb->Attachment[bufferName].Renderbuffer, rb); +} + + +/** + * Remove the named renderbuffer from the given framebuffer. + * \param bufferName one of the BUFFER_x tokens + */ +void +_mesa_remove_renderbuffer(struct gl_framebuffer *fb, + gl_buffer_index bufferName) +{ + struct gl_renderbuffer *rb; + + assert(bufferName < BUFFER_COUNT); + + rb = fb->Attachment[bufferName].Renderbuffer; + if (!rb) + return; + + _mesa_reference_renderbuffer(&rb, NULL); + + fb->Attachment[bufferName].Renderbuffer = NULL; +} + + +/** + * Set *ptr to point to rb. If *ptr points to another renderbuffer, + * dereference that buffer first. The new renderbuffer's refcount will + * be incremented. The old renderbuffer's refcount will be decremented. + */ +void +_mesa_reference_renderbuffer(struct gl_renderbuffer **ptr, + struct gl_renderbuffer *rb) +{ + assert(ptr); + if (*ptr == rb) { + /* no change */ + return; + } + + if (*ptr) { + /* Unreference the old renderbuffer */ + GLboolean deleteFlag = GL_FALSE; + struct gl_renderbuffer *oldRb = *ptr; + + assert(oldRb->Magic == RB_MAGIC); + _glthread_LOCK_MUTEX(oldRb->Mutex); + assert(oldRb->Magic == RB_MAGIC); + ASSERT(oldRb->RefCount > 0); + oldRb->RefCount--; + /*printf("RB DECR %p (%d) to %d\n", (void*) oldRb, oldRb->Name, oldRb->RefCount);*/ + deleteFlag = (oldRb->RefCount == 0); + _glthread_UNLOCK_MUTEX(oldRb->Mutex); + + if (deleteFlag) { + oldRb->Magic = 0; /* now invalid memory! */ + oldRb->Delete(oldRb); + } + + *ptr = NULL; + } + assert(!*ptr); + + if (rb) { + assert(rb->Magic == RB_MAGIC); + /* reference new renderbuffer */ + _glthread_LOCK_MUTEX(rb->Mutex); + rb->RefCount++; + /*printf("RB INCR %p (%d) to %d\n", (void*) rb, rb->Name, rb->RefCount);*/ + _glthread_UNLOCK_MUTEX(rb->Mutex); + *ptr = rb; + } +} + + +/** + * Create a new combined depth/stencil renderbuffer for implementing + * the GL_EXT_packed_depth_stencil extension. + * \return new depth/stencil renderbuffer + */ +struct gl_renderbuffer * +_mesa_new_depthstencil_renderbuffer(struct gl_context *ctx, GLuint name) +{ + struct gl_renderbuffer *dsrb; + + dsrb = _mesa_new_renderbuffer(ctx, name); + if (!dsrb) + return NULL; + + /* init fields not covered by _mesa_new_renderbuffer() */ + dsrb->InternalFormat = GL_DEPTH24_STENCIL8_EXT; + dsrb->Format = MESA_FORMAT_Z24_S8; + dsrb->AllocStorage = _mesa_soft_renderbuffer_storage; + + return dsrb; +} diff --git a/mesalib/src/mesa/main/teximage.c b/mesalib/src/mesa/main/teximage.c index 857893866..c3cd6b66a 100644 --- a/mesalib/src/mesa/main/teximage.c +++ b/mesalib/src/mesa/main/teximage.c @@ -1,3486 +1,3495 @@ -/*
- * mesa 3-D graphics library
- * Version: 7.6
- *
- * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
- * Copyright (C) 2009 VMware, Inc. All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-
-/**
- * \file teximage.c
- * Texture image-related functions.
- */
-
-
-#include "glheader.h"
-#include "bufferobj.h"
-#include "context.h"
-#include "enums.h"
-#include "fbobject.h"
-#include "framebuffer.h"
-#include "hash.h"
-#include "image.h"
-#include "imports.h"
-#include "macros.h"
-#include "mfeatures.h"
-#include "state.h"
-#include "texcompress.h"
-#include "texfetch.h"
-#include "teximage.h"
-#include "texstate.h"
-#include "texpal.h"
-#include "mtypes.h"
-
-
-/**
- * State changes which we care about for glCopyTex[Sub]Image() calls.
- * In particular, we care about pixel transfer state and buffer state
- * (such as glReadBuffer to make sure we read from the right renderbuffer).
- */
-#define NEW_COPY_TEX_STATE (_MESA_NEW_TRANSFER_STATE | \
- _NEW_BUFFERS | \
- _NEW_PIXEL)
-
-
-
-/**
- * We allocate texture memory on 512-byte boundaries so we can use MMX/SSE
- * elsewhere.
- */
-void *
-_mesa_alloc_texmemory(GLsizei bytes)
-{
- return _mesa_align_malloc(bytes, 512);
-}
-
-
-/**
- * Free texture memory allocated with _mesa_alloc_texmemory()
- */
-void
-_mesa_free_texmemory(void *m)
-{
- _mesa_align_free(m);
-}
-
-
-/*
- * Compute floor(log_base_2(n)).
- * If n < 0 return -1.
- */
-static int
-logbase2( int n )
-{
- GLint i = 1;
- GLint log2 = 0;
-
- if (n < 0)
- return -1;
-
- if (n == 0)
- return 0;
-
- while ( n > i ) {
- i *= 2;
- log2++;
- }
- if (i != n) {
- return log2 - 1;
- }
- else {
- return log2;
- }
-}
-
-
-
-/**
- * Return the simple base format for a given internal texture format.
- * For example, given GL_LUMINANCE12_ALPHA4, return GL_LUMINANCE_ALPHA.
- *
- * \param ctx GL context.
- * \param internalFormat the internal texture format token or 1, 2, 3, or 4.
- *
- * \return the corresponding \u base internal format (GL_ALPHA, GL_LUMINANCE,
- * GL_LUMANCE_ALPHA, GL_INTENSITY, GL_RGB, or GL_RGBA), or -1 if invalid enum.
- *
- * This is the format which is used during texture application (i.e. the
- * texture format and env mode determine the arithmetic used.
- *
- * XXX this could be static
- */
-GLint
-_mesa_base_tex_format( struct gl_context *ctx, GLint internalFormat )
-{
- switch (internalFormat) {
- case GL_ALPHA:
- case GL_ALPHA4:
- case GL_ALPHA8:
- case GL_ALPHA12:
- case GL_ALPHA16:
- return GL_ALPHA;
- case 1:
- case GL_LUMINANCE:
- case GL_LUMINANCE4:
- case GL_LUMINANCE8:
- case GL_LUMINANCE12:
- case GL_LUMINANCE16:
- return GL_LUMINANCE;
- case 2:
- case GL_LUMINANCE_ALPHA:
- case GL_LUMINANCE4_ALPHA4:
- case GL_LUMINANCE6_ALPHA2:
- case GL_LUMINANCE8_ALPHA8:
- case GL_LUMINANCE12_ALPHA4:
- case GL_LUMINANCE12_ALPHA12:
- case GL_LUMINANCE16_ALPHA16:
- return GL_LUMINANCE_ALPHA;
- case GL_INTENSITY:
- case GL_INTENSITY4:
- case GL_INTENSITY8:
- case GL_INTENSITY12:
- case GL_INTENSITY16:
- return GL_INTENSITY;
- case 3:
- case GL_RGB:
- case GL_R3_G3_B2:
- case GL_RGB4:
- case GL_RGB5:
- case GL_RGB8:
- case GL_RGB10:
- case GL_RGB12:
- case GL_RGB16:
- return GL_RGB;
- case 4:
- case GL_RGBA:
- case GL_RGBA2:
- case GL_RGBA4:
- case GL_RGB5_A1:
- case GL_RGBA8:
- case GL_RGB10_A2:
- case GL_RGBA12:
- case GL_RGBA16:
- return GL_RGBA;
- default:
- ; /* fallthrough */
- }
-
- if (ctx->Extensions.EXT_paletted_texture) {
- switch (internalFormat) {
- case GL_COLOR_INDEX:
- case GL_COLOR_INDEX1_EXT:
- case GL_COLOR_INDEX2_EXT:
- case GL_COLOR_INDEX4_EXT:
- case GL_COLOR_INDEX8_EXT:
- case GL_COLOR_INDEX12_EXT:
- case GL_COLOR_INDEX16_EXT:
- return GL_COLOR_INDEX;
- default:
- ; /* fallthrough */
- }
- }
-
- if (ctx->Extensions.ARB_depth_texture) {
- switch (internalFormat) {
- case GL_DEPTH_COMPONENT:
- case GL_DEPTH_COMPONENT16:
- case GL_DEPTH_COMPONENT24:
- case GL_DEPTH_COMPONENT32:
- return GL_DEPTH_COMPONENT;
- default:
- ; /* fallthrough */
- }
- }
-
- switch (internalFormat) {
- case GL_COMPRESSED_ALPHA:
- return GL_ALPHA;
- case GL_COMPRESSED_LUMINANCE:
- return GL_LUMINANCE;
- case GL_COMPRESSED_LUMINANCE_ALPHA:
- return GL_LUMINANCE_ALPHA;
- case GL_COMPRESSED_INTENSITY:
- return GL_INTENSITY;
- case GL_COMPRESSED_RGB:
- return GL_RGB;
- case GL_COMPRESSED_RGBA:
- return GL_RGBA;
- default:
- ; /* fallthrough */
- }
-
- if (ctx->Extensions.TDFX_texture_compression_FXT1) {
- switch (internalFormat) {
- case GL_COMPRESSED_RGB_FXT1_3DFX:
- return GL_RGB;
- case GL_COMPRESSED_RGBA_FXT1_3DFX:
- return GL_RGBA;
- default:
- ; /* fallthrough */
- }
- }
-
- if (ctx->Extensions.EXT_texture_compression_s3tc) {
- switch (internalFormat) {
- case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
- return GL_RGB;
- case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
- case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
- case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
- return GL_RGBA;
- default:
- ; /* fallthrough */
- }
- }
-
- if (ctx->Extensions.S3_s3tc) {
- switch (internalFormat) {
- case GL_RGB_S3TC:
- case GL_RGB4_S3TC:
- return GL_RGB;
- case GL_RGBA_S3TC:
- case GL_RGBA4_S3TC:
- return GL_RGBA;
- default:
- ; /* fallthrough */
- }
- }
-
- if (ctx->Extensions.MESA_ycbcr_texture) {
- if (internalFormat == GL_YCBCR_MESA)
- return GL_YCBCR_MESA;
- }
-
- if (ctx->Extensions.ARB_texture_float) {
- switch (internalFormat) {
- case GL_ALPHA16F_ARB:
- case GL_ALPHA32F_ARB:
- return GL_ALPHA;
- case GL_RGBA16F_ARB:
- case GL_RGBA32F_ARB:
- return GL_RGBA;
- case GL_RGB16F_ARB:
- case GL_RGB32F_ARB:
- return GL_RGB;
- case GL_INTENSITY16F_ARB:
- case GL_INTENSITY32F_ARB:
- return GL_INTENSITY;
- case GL_LUMINANCE16F_ARB:
- case GL_LUMINANCE32F_ARB:
- return GL_LUMINANCE;
- case GL_LUMINANCE_ALPHA16F_ARB:
- case GL_LUMINANCE_ALPHA32F_ARB:
- return GL_LUMINANCE_ALPHA;
- default:
- ; /* fallthrough */
- }
- }
-
- if (ctx->Extensions.ATI_envmap_bumpmap) {
- switch (internalFormat) {
- case GL_DUDV_ATI:
- case GL_DU8DV8_ATI:
- return GL_DUDV_ATI;
- default:
- ; /* fallthrough */
- }
- }
-
- if (ctx->Extensions.MESA_texture_signed_rgba) {
- switch (internalFormat) {
- case GL_RGBA_SNORM:
- case GL_RGBA8_SNORM:
- return GL_RGBA;
- default:
- ; /* fallthrough */
- }
- }
-
- if (ctx->Extensions.EXT_packed_depth_stencil) {
- switch (internalFormat) {
- case GL_DEPTH_STENCIL_EXT:
- case GL_DEPTH24_STENCIL8_EXT:
- return GL_DEPTH_STENCIL_EXT;
- default:
- ; /* fallthrough */
- }
- }
-
-#if FEATURE_EXT_texture_sRGB
- if (ctx->Extensions.EXT_texture_sRGB) {
- switch (internalFormat) {
- case GL_SRGB_EXT:
- case GL_SRGB8_EXT:
- case GL_COMPRESSED_SRGB_EXT:
- case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT:
- return GL_RGB;
- case GL_SRGB_ALPHA_EXT:
- case GL_SRGB8_ALPHA8_EXT:
- case GL_COMPRESSED_SRGB_ALPHA_EXT:
- case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:
- case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT:
- case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT:
- return GL_RGBA;
- case GL_SLUMINANCE_ALPHA_EXT:
- case GL_SLUMINANCE8_ALPHA8_EXT:
- case GL_COMPRESSED_SLUMINANCE_ALPHA_EXT:
- return GL_LUMINANCE_ALPHA;
- case GL_SLUMINANCE_EXT:
- case GL_SLUMINANCE8_EXT:
- case GL_COMPRESSED_SLUMINANCE_EXT:
- return GL_LUMINANCE;
- default:
- ; /* fallthrough */
- }
- }
-#endif /* FEATURE_EXT_texture_sRGB */
-
- if (ctx->Extensions.EXT_texture_integer) {
- switch (internalFormat) {
- case GL_RGBA8UI_EXT:
- case GL_RGBA16UI_EXT:
- case GL_RGBA32UI_EXT:
- case GL_RGBA8I_EXT:
- case GL_RGBA16I_EXT:
- case GL_RGBA32I_EXT:
- return GL_RGBA;
- case GL_RGB8UI_EXT:
- case GL_RGB16UI_EXT:
- case GL_RGB32UI_EXT:
- case GL_RGB8I_EXT:
- case GL_RGB16I_EXT:
- case GL_RGB32I_EXT:
- return GL_RGB;
- case GL_ALPHA8UI_EXT:
- case GL_ALPHA16UI_EXT:
- case GL_ALPHA32UI_EXT:
- case GL_ALPHA8I_EXT:
- case GL_ALPHA16I_EXT:
- case GL_ALPHA32I_EXT:
- return GL_ALPHA;
- case GL_INTENSITY8UI_EXT:
- case GL_INTENSITY16UI_EXT:
- case GL_INTENSITY32UI_EXT:
- case GL_INTENSITY8I_EXT:
- case GL_INTENSITY16I_EXT:
- case GL_INTENSITY32I_EXT:
- return GL_INTENSITY;
- case GL_LUMINANCE8UI_EXT:
- case GL_LUMINANCE16UI_EXT:
- case GL_LUMINANCE32UI_EXT:
- case GL_LUMINANCE8I_EXT:
- case GL_LUMINANCE16I_EXT:
- case GL_LUMINANCE32I_EXT:
- return GL_LUMINANCE;
- case GL_LUMINANCE_ALPHA8UI_EXT:
- case GL_LUMINANCE_ALPHA16UI_EXT:
- case GL_LUMINANCE_ALPHA32UI_EXT:
- case GL_LUMINANCE_ALPHA8I_EXT:
- case GL_LUMINANCE_ALPHA16I_EXT:
- case GL_LUMINANCE_ALPHA32I_EXT:
- return GL_LUMINANCE_ALPHA;
- default:
- ; /* fallthrough */
- }
- }
-
- if (ctx->Extensions.ARB_texture_rg) {
- switch (internalFormat) {
- case GL_R16F:
- /* R16F depends on both ARB_half_float_pixel and ARB_texture_float.
- */
- if (!ctx->Extensions.ARB_half_float_pixel)
- break;
- /* FALLTHROUGH */
- case GL_R32F:
- if (!ctx->Extensions.ARB_texture_float)
- break;
- return GL_RED;
- case GL_R8I:
- case GL_R8UI:
- case GL_R16I:
- case GL_R16UI:
- case GL_R32I:
- case GL_R32UI:
- if (!ctx->Extensions.EXT_texture_integer)
- break;
- /* FALLTHROUGH */
- case GL_R8:
- case GL_R16:
- case GL_RED:
- case GL_COMPRESSED_RED:
- return GL_RED;
-
- case GL_RG16F:
- /* RG16F depends on both ARB_half_float_pixel and ARB_texture_float.
- */
- if (!ctx->Extensions.ARB_half_float_pixel)
- break;
- /* FALLTHROUGH */
- case GL_RG32F:
- if (!ctx->Extensions.ARB_texture_float)
- break;
- return GL_RG;
- case GL_RG8I:
- case GL_RG8UI:
- case GL_RG16I:
- case GL_RG16UI:
- case GL_RG32I:
- case GL_RG32UI:
- if (!ctx->Extensions.EXT_texture_integer)
- break;
- /* FALLTHROUGH */
- case GL_RG:
- case GL_RG8:
- case GL_RG16:
- case GL_COMPRESSED_RG:
- return GL_RG;
- default:
- ; /* fallthrough */
- }
- }
-
- if (ctx->Extensions.EXT_texture_shared_exponent) {
- switch (internalFormat) {
- case GL_RGB9_E5_EXT:
- return GL_RGB;
- default:
- ; /* fallthrough */
- }
- }
-
- if (ctx->Extensions.EXT_packed_float) {
- switch (internalFormat) {
- case GL_R11F_G11F_B10F_EXT:
- return GL_RGB;
- default:
- ; /* fallthrough */
- }
- }
-
- if (ctx->Extensions.ARB_depth_buffer_float) {
- switch (internalFormat) {
- case GL_DEPTH_COMPONENT32F:
- return GL_DEPTH_COMPONENT;
- case GL_DEPTH32F_STENCIL8:
- return GL_DEPTH_STENCIL;
- default:
- ; /* fallthrough */
- }
- }
-
- if (ctx->Extensions.ARB_texture_compression_rgtc) {
- switch (internalFormat) {
- case GL_COMPRESSED_RED_RGTC1:
- case GL_COMPRESSED_SIGNED_RED_RGTC1:
- return GL_RED;
- case GL_COMPRESSED_RG_RGTC2:
- case GL_COMPRESSED_SIGNED_RG_RGTC2:
- return GL_RG;
- default:
- ; /* fallthrough */
- }
- }
-
- return -1; /* error */
-}
-
-
-/**
- * For cube map faces, return a face index in [0,5].
- * For other targets return 0;
- */
-GLuint
-_mesa_tex_target_to_face(GLenum target)
-{
- if (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB &&
- target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB)
- return (GLuint) target - (GLuint) GL_TEXTURE_CUBE_MAP_POSITIVE_X;
- else
- return 0;
-}
-
-
-
-/**
- * Store a gl_texture_image pointer in a gl_texture_object structure
- * according to the target and level parameters.
- *
- * \param tObj texture object.
- * \param target texture target.
- * \param level image level.
- * \param texImage texture image.
- *
- * This was basically prompted by the introduction of cube maps.
- */
-void
-_mesa_set_tex_image(struct gl_texture_object *tObj,
- GLenum target, GLint level,
- struct gl_texture_image *texImage)
-{
- const GLuint face = _mesa_tex_target_to_face(target);
-
- ASSERT(tObj);
- ASSERT(texImage);
- ASSERT(target != GL_TEXTURE_RECTANGLE_NV || level == 0);
-
- tObj->Image[face][level] = texImage;
-
- /* Set the 'back' pointer */
- texImage->TexObject = tObj;
-}
-
-
-/**
- * Allocate a texture image structure.
- *
- * Called via ctx->Driver.NewTextureImage() unless overriden by a device
- * driver.
- *
- * \return a pointer to gl_texture_image struct with all fields initialized to
- * zero.
- */
-struct gl_texture_image *
-_mesa_new_texture_image( struct gl_context *ctx )
-{
- (void) ctx;
- return CALLOC_STRUCT(gl_texture_image);
-}
-
-
-/**
- * Free texture image data.
- * This function is a fallback called via ctx->Driver.FreeTexImageData().
- *
- * \param texImage texture image.
- *
- * Free the texture image data if it's not marked as client data.
- */
-void
-_mesa_free_texture_image_data(struct gl_context *ctx,
- struct gl_texture_image *texImage)
-{
- (void) ctx;
-
- if (texImage->Data && !texImage->IsClientData) {
- /* free the old texture data */
- _mesa_free_texmemory(texImage->Data);
- }
-
- texImage->Data = NULL;
-}
-
-
-/**
- * Free texture image.
- *
- * \param texImage texture image.
- *
- * Free the texture image structure and the associated image data.
- */
-void
-_mesa_delete_texture_image(struct gl_context *ctx,
- struct gl_texture_image *texImage)
-{
- /* Free texImage->Data and/or any other driver-specific texture
- * image storage.
- */
- ASSERT(ctx->Driver.FreeTexImageData);
- ctx->Driver.FreeTexImageData( ctx, texImage );
-
- ASSERT(texImage->Data == NULL);
- if (texImage->ImageOffsets)
- free(texImage->ImageOffsets);
- free(texImage);
-}
-
-
-/**
- * Test if a target is a proxy target.
- *
- * \param target texture target.
- *
- * \return GL_TRUE if the target is a proxy target, GL_FALSE otherwise.
- */
-GLboolean
-_mesa_is_proxy_texture(GLenum target)
-{
- /* NUM_TEXTURE_TARGETS should match number of terms below */
- assert(NUM_TEXTURE_TARGETS == 7);
-
- return (target == GL_PROXY_TEXTURE_1D ||
- target == GL_PROXY_TEXTURE_2D ||
- target == GL_PROXY_TEXTURE_3D ||
- target == GL_PROXY_TEXTURE_CUBE_MAP_ARB ||
- target == GL_PROXY_TEXTURE_RECTANGLE_NV ||
- target == GL_PROXY_TEXTURE_1D_ARRAY_EXT ||
- target == GL_PROXY_TEXTURE_2D_ARRAY_EXT);
-}
-
-
-/**
- * Return the proxy target which corresponds to the given texture target
- */
-static GLenum
-get_proxy_target(GLenum target)
-{
- switch (target) {
- case GL_TEXTURE_1D:
- case GL_PROXY_TEXTURE_1D:
- return GL_PROXY_TEXTURE_1D;
- case GL_TEXTURE_2D:
- case GL_PROXY_TEXTURE_2D:
- return GL_PROXY_TEXTURE_2D;
- case GL_TEXTURE_3D:
- case GL_PROXY_TEXTURE_3D:
- return GL_PROXY_TEXTURE_3D;
- case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB:
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB:
- case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB:
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB:
- case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB:
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB:
- case GL_TEXTURE_CUBE_MAP_ARB:
- case GL_PROXY_TEXTURE_CUBE_MAP_ARB:
- return GL_PROXY_TEXTURE_CUBE_MAP_ARB;
- case GL_TEXTURE_RECTANGLE_NV:
- case GL_PROXY_TEXTURE_RECTANGLE_NV:
- return GL_PROXY_TEXTURE_RECTANGLE_NV;
- case GL_TEXTURE_1D_ARRAY_EXT:
- case GL_PROXY_TEXTURE_1D_ARRAY_EXT:
- return GL_PROXY_TEXTURE_1D_ARRAY_EXT;
- case GL_TEXTURE_2D_ARRAY_EXT:
- case GL_PROXY_TEXTURE_2D_ARRAY_EXT:
- return GL_PROXY_TEXTURE_2D_ARRAY_EXT;
- default:
- _mesa_problem(NULL, "unexpected target in get_proxy_target()");
- return 0;
- }
-}
-
-
-/**
- * Get the texture object that corresponds to the target of the given
- * texture unit.
- *
- * \param ctx GL context.
- * \param texUnit texture unit.
- * \param target texture target.
- *
- * \return pointer to the texture object on success, or NULL on failure.
- *
- * \sa gl_texture_unit.
- */
-struct gl_texture_object *
-_mesa_select_tex_object(struct gl_context *ctx,
- const struct gl_texture_unit *texUnit,
- GLenum target)
-{
- switch (target) {
- case GL_TEXTURE_1D:
- return texUnit->CurrentTex[TEXTURE_1D_INDEX];
- case GL_PROXY_TEXTURE_1D:
- return ctx->Texture.ProxyTex[TEXTURE_1D_INDEX];
- case GL_TEXTURE_2D:
- return texUnit->CurrentTex[TEXTURE_2D_INDEX];
- case GL_PROXY_TEXTURE_2D:
- return ctx->Texture.ProxyTex[TEXTURE_2D_INDEX];
- case GL_TEXTURE_3D:
- return texUnit->CurrentTex[TEXTURE_3D_INDEX];
- case GL_PROXY_TEXTURE_3D:
- return ctx->Texture.ProxyTex[TEXTURE_3D_INDEX];
- case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB:
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB:
- case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB:
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB:
- case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB:
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB:
- case GL_TEXTURE_CUBE_MAP_ARB:
- return ctx->Extensions.ARB_texture_cube_map
- ? texUnit->CurrentTex[TEXTURE_CUBE_INDEX] : NULL;
- case GL_PROXY_TEXTURE_CUBE_MAP_ARB:
- return ctx->Extensions.ARB_texture_cube_map
- ? ctx->Texture.ProxyTex[TEXTURE_CUBE_INDEX] : NULL;
- case GL_TEXTURE_RECTANGLE_NV:
- return ctx->Extensions.NV_texture_rectangle
- ? texUnit->CurrentTex[TEXTURE_RECT_INDEX] : NULL;
- case GL_PROXY_TEXTURE_RECTANGLE_NV:
- return ctx->Extensions.NV_texture_rectangle
- ? ctx->Texture.ProxyTex[TEXTURE_RECT_INDEX] : NULL;
- case GL_TEXTURE_1D_ARRAY_EXT:
- return ctx->Extensions.MESA_texture_array
- ? texUnit->CurrentTex[TEXTURE_1D_ARRAY_INDEX] : NULL;
- case GL_PROXY_TEXTURE_1D_ARRAY_EXT:
- return ctx->Extensions.MESA_texture_array
- ? ctx->Texture.ProxyTex[TEXTURE_1D_ARRAY_INDEX] : NULL;
- case GL_TEXTURE_2D_ARRAY_EXT:
- return ctx->Extensions.MESA_texture_array
- ? texUnit->CurrentTex[TEXTURE_2D_ARRAY_INDEX] : NULL;
- case GL_PROXY_TEXTURE_2D_ARRAY_EXT:
- return ctx->Extensions.MESA_texture_array
- ? ctx->Texture.ProxyTex[TEXTURE_2D_ARRAY_INDEX] : NULL;
- default:
- _mesa_problem(NULL, "bad target in _mesa_select_tex_object()");
- return NULL;
- }
-}
-
-
-/**
- * Return pointer to texture object for given target on current texture unit.
- */
-struct gl_texture_object *
-_mesa_get_current_tex_object(struct gl_context *ctx, GLenum target)
-{
- struct gl_texture_unit *texUnit = _mesa_get_current_tex_unit(ctx);
- return _mesa_select_tex_object(ctx, texUnit, target);
-}
-
-
-/**
- * Get a texture image pointer from a texture object, given a texture
- * target and mipmap level. The target and level parameters should
- * have already been error-checked.
- *
- * \param ctx GL context.
- * \param texObj texture unit.
- * \param target texture target.
- * \param level image level.
- *
- * \return pointer to the texture image structure, or NULL on failure.
- */
-struct gl_texture_image *
-_mesa_select_tex_image(struct gl_context *ctx,
- const struct gl_texture_object *texObj,
- GLenum target, GLint level)
-{
- const GLuint face = _mesa_tex_target_to_face(target);
-
- ASSERT(texObj);
- ASSERT(level >= 0);
- ASSERT(level < MAX_TEXTURE_LEVELS);
-
- return texObj->Image[face][level];
-}
-
-
-/**
- * Like _mesa_select_tex_image() but if the image doesn't exist, allocate
- * it and install it. Only return NULL if passed a bad parameter or run
- * out of memory.
- */
-struct gl_texture_image *
-_mesa_get_tex_image(struct gl_context *ctx, struct gl_texture_object *texObj,
- GLenum target, GLint level)
-{
- struct gl_texture_image *texImage;
-
- if (!texObj)
- return NULL;
-
- texImage = _mesa_select_tex_image(ctx, texObj, target, level);
- if (!texImage) {
- texImage = ctx->Driver.NewTextureImage(ctx);
- if (!texImage) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "texture image allocation");
- return NULL;
- }
-
- _mesa_set_tex_image(texObj, target, level, texImage);
- }
-
- return texImage;
-}
-
-
-/**
- * Return pointer to the specified proxy texture image.
- * Note that proxy textures are per-context, not per-texture unit.
- * \return pointer to texture image or NULL if invalid target, invalid
- * level, or out of memory.
- */
-struct gl_texture_image *
-_mesa_get_proxy_tex_image(struct gl_context *ctx, GLenum target, GLint level)
-{
- struct gl_texture_image *texImage;
- GLuint texIndex;
-
- if (level < 0 )
- return NULL;
-
- switch (target) {
- case GL_PROXY_TEXTURE_1D:
- if (level >= ctx->Const.MaxTextureLevels)
- return NULL;
- texIndex = TEXTURE_1D_INDEX;
- break;
- case GL_PROXY_TEXTURE_2D:
- if (level >= ctx->Const.MaxTextureLevels)
- return NULL;
- texIndex = TEXTURE_2D_INDEX;
- break;
- case GL_PROXY_TEXTURE_3D:
- if (level >= ctx->Const.Max3DTextureLevels)
- return NULL;
- texIndex = TEXTURE_3D_INDEX;
- break;
- case GL_PROXY_TEXTURE_CUBE_MAP:
- if (level >= ctx->Const.MaxCubeTextureLevels)
- return NULL;
- texIndex = TEXTURE_CUBE_INDEX;
- break;
- case GL_PROXY_TEXTURE_RECTANGLE_NV:
- if (level > 0)
- return NULL;
- texIndex = TEXTURE_RECT_INDEX;
- break;
- case GL_PROXY_TEXTURE_1D_ARRAY_EXT:
- if (level >= ctx->Const.MaxTextureLevels)
- return NULL;
- texIndex = TEXTURE_1D_ARRAY_INDEX;
- break;
- case GL_PROXY_TEXTURE_2D_ARRAY_EXT:
- if (level >= ctx->Const.MaxTextureLevels)
- return NULL;
- texIndex = TEXTURE_2D_ARRAY_INDEX;
- break;
- default:
- return NULL;
- }
-
- texImage = ctx->Texture.ProxyTex[texIndex]->Image[0][level];
- if (!texImage) {
- texImage = ctx->Driver.NewTextureImage(ctx);
- if (!texImage) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "proxy texture allocation");
- return NULL;
- }
- ctx->Texture.ProxyTex[texIndex]->Image[0][level] = texImage;
- /* Set the 'back' pointer */
- texImage->TexObject = ctx->Texture.ProxyTex[texIndex];
- }
- return texImage;
-}
-
-
-/**
- * Get the maximum number of allowed mipmap levels.
- *
- * \param ctx GL context.
- * \param target texture target.
- *
- * \return the maximum number of allowed mipmap levels for the given
- * texture target, or zero if passed a bad target.
- *
- * \sa gl_constants.
- */
-GLint
-_mesa_max_texture_levels(struct gl_context *ctx, GLenum target)
-{
- switch (target) {
- case GL_TEXTURE_1D:
- case GL_PROXY_TEXTURE_1D:
- case GL_TEXTURE_2D:
- case GL_PROXY_TEXTURE_2D:
- return ctx->Const.MaxTextureLevels;
- case GL_TEXTURE_3D:
- case GL_PROXY_TEXTURE_3D:
- return ctx->Const.Max3DTextureLevels;
- case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB:
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB:
- case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB:
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB:
- case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB:
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB:
- case GL_TEXTURE_CUBE_MAP_ARB:
- case GL_PROXY_TEXTURE_CUBE_MAP_ARB:
- return ctx->Extensions.ARB_texture_cube_map
- ? ctx->Const.MaxCubeTextureLevels : 0;
- case GL_TEXTURE_RECTANGLE_NV:
- case GL_PROXY_TEXTURE_RECTANGLE_NV:
- return ctx->Extensions.NV_texture_rectangle ? 1 : 0;
- case GL_TEXTURE_1D_ARRAY_EXT:
- case GL_PROXY_TEXTURE_1D_ARRAY_EXT:
- case GL_TEXTURE_2D_ARRAY_EXT:
- case GL_PROXY_TEXTURE_2D_ARRAY_EXT:
- return ctx->Extensions.MESA_texture_array
- ? ctx->Const.MaxTextureLevels : 0;
- default:
- return 0; /* bad target */
- }
-}
-
-
-/**
- * Return number of dimensions per mipmap level for the given texture target.
- */
-GLint
-_mesa_get_texture_dimensions(GLenum target)
-{
- switch (target) {
- case GL_TEXTURE_1D:
- case GL_PROXY_TEXTURE_1D:
- return 1;
- case GL_TEXTURE_2D:
- case GL_TEXTURE_RECTANGLE:
- case GL_TEXTURE_CUBE_MAP:
- case GL_PROXY_TEXTURE_2D:
- case GL_PROXY_TEXTURE_RECTANGLE:
- case GL_PROXY_TEXTURE_CUBE_MAP:
- case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
- case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
- case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
- case GL_TEXTURE_1D_ARRAY:
- case GL_PROXY_TEXTURE_1D_ARRAY:
- return 2;
- case GL_TEXTURE_3D:
- case GL_PROXY_TEXTURE_3D:
- case GL_TEXTURE_2D_ARRAY:
- case GL_PROXY_TEXTURE_2D_ARRAY:
- return 3;
- default:
- _mesa_problem(NULL, "invalid target 0x%x in get_texture_dimensions()",
- target);
- return 2;
- }
-}
-
-
-
-
-#if 000 /* not used anymore */
-/*
- * glTexImage[123]D can accept a NULL image pointer. In this case we
- * create a texture image with unspecified image contents per the OpenGL
- * spec.
- */
-static GLubyte *
-make_null_texture(GLint width, GLint height, GLint depth, GLenum format)
-{
- const GLint components = _mesa_components_in_format(format);
- const GLint numPixels = width * height * depth;
- GLubyte *data = (GLubyte *) MALLOC(numPixels * components * sizeof(GLubyte));
-
-#ifdef DEBUG
- /*
- * Let's see if anyone finds this. If glTexImage2D() is called with
- * a NULL image pointer then load the texture image with something
- * interesting instead of leaving it indeterminate.
- */
- if (data) {
- static const char message[8][32] = {
- " X X XXXXX XXX X ",
- " XX XX X X X X X ",
- " X X X X X X X ",
- " X X XXXX XXX XXXXX ",
- " X X X X X X ",
- " X X X X X X X ",
- " X X XXXXX XXX X X ",
- " "
- };
-
- GLubyte *imgPtr = data;
- GLint h, i, j, k;
- for (h = 0; h < depth; h++) {
- for (i = 0; i < height; i++) {
- GLint srcRow = 7 - (i % 8);
- for (j = 0; j < width; j++) {
- GLint srcCol = j % 32;
- GLubyte texel = (message[srcRow][srcCol]=='X') ? 255 : 70;
- for (k = 0; k < components; k++) {
- *imgPtr++ = texel;
- }
- }
- }
- }
- }
-#endif
-
- return data;
-}
-#endif
-
-
-
-/**
- * Reset the fields of a gl_texture_image struct to zero.
- *
- * \param img texture image structure.
- *
- * This is called when a proxy texture test fails, we set all the
- * image members (except DriverData) to zero.
- * It's also used in glTexImage[123]D as a safeguard to be sure all
- * required fields get initialized properly by the Driver.TexImage[123]D
- * functions.
- */
-static void
-clear_teximage_fields(struct gl_texture_image *img)
-{
- ASSERT(img);
- img->_BaseFormat = 0;
- img->InternalFormat = 0;
- img->Border = 0;
- img->Width = 0;
- img->Height = 0;
- img->Depth = 0;
- img->RowStride = 0;
- if (img->ImageOffsets) {
- free(img->ImageOffsets);
- img->ImageOffsets = NULL;
- }
- img->Width2 = 0;
- img->Height2 = 0;
- img->Depth2 = 0;
- img->WidthLog2 = 0;
- img->HeightLog2 = 0;
- img->DepthLog2 = 0;
- img->Data = NULL;
- img->TexFormat = MESA_FORMAT_NONE;
- img->FetchTexelc = NULL;
- img->FetchTexelf = NULL;
-}
-
-
-/**
- * Initialize basic fields of the gl_texture_image struct.
- *
- * \param ctx GL context.
- * \param target texture target (GL_TEXTURE_1D, GL_TEXTURE_RECTANGLE, etc).
- * \param img texture image structure to be initialized.
- * \param width image width.
- * \param height image height.
- * \param depth image depth.
- * \param border image border.
- * \param internalFormat internal format.
- * \param format the actual hardware format (one of MESA_FORMAT_*)
- *
- * Fills in the fields of \p img with the given information.
- * Note: width, height and depth include the border.
- */
-void
-_mesa_init_teximage_fields(struct gl_context *ctx, GLenum target,
- struct gl_texture_image *img,
- GLsizei width, GLsizei height, GLsizei depth,
- GLint border, GLenum internalFormat,
- gl_format format)
-{
- GLint i, dims;
-
- ASSERT(img);
- ASSERT(width >= 0);
- ASSERT(height >= 0);
- ASSERT(depth >= 0);
-
- img->_BaseFormat = _mesa_base_tex_format( ctx, internalFormat );
- ASSERT(img->_BaseFormat > 0);
- img->InternalFormat = internalFormat;
- img->Border = border;
- img->Width = width;
- img->Height = height;
- img->Depth = depth;
-
- img->Width2 = width - 2 * border; /* == 1 << img->WidthLog2; */
- img->WidthLog2 = logbase2(img->Width2);
-
- if (height == 1) { /* 1-D texture */
- img->Height2 = 1;
- img->HeightLog2 = 0;
- }
- else {
- img->Height2 = height - 2 * border; /* == 1 << img->HeightLog2; */
- img->HeightLog2 = logbase2(img->Height2);
- }
-
- if (depth == 1) { /* 2-D texture */
- img->Depth2 = 1;
- img->DepthLog2 = 0;
- }
- else {
- img->Depth2 = depth - 2 * border; /* == 1 << img->DepthLog2; */
- img->DepthLog2 = logbase2(img->Depth2);
- }
-
- img->MaxLog2 = MAX2(img->WidthLog2, img->HeightLog2);
-
- if ((width == 1 || _mesa_is_pow_two(img->Width2)) &&
- (height == 1 || _mesa_is_pow_two(img->Height2)) &&
- (depth == 1 || _mesa_is_pow_two(img->Depth2)))
- img->_IsPowerOfTwo = GL_TRUE;
- else
- img->_IsPowerOfTwo = GL_FALSE;
-
- /* RowStride and ImageOffsets[] describe how to address texels in 'Data' */
- img->RowStride = width;
- /* Allocate the ImageOffsets array and initialize to typical values.
- * We allocate the array for 1D/2D textures too in order to avoid special-
- * case code in the texstore routines.
- */
- if (img->ImageOffsets)
- free(img->ImageOffsets);
- img->ImageOffsets = (GLuint *) malloc(depth * sizeof(GLuint));
- for (i = 0; i < depth; i++) {
- img->ImageOffsets[i] = i * width * height;
- }
-
- /* Compute Width/Height/DepthScale for mipmap lod computation */
- if (target == GL_TEXTURE_RECTANGLE_NV) {
- /* scale = 1.0 since texture coords directly map to texels */
- img->WidthScale = 1.0;
- img->HeightScale = 1.0;
- img->DepthScale = 1.0;
- }
- else {
- img->WidthScale = (GLfloat) img->Width;
- img->HeightScale = (GLfloat) img->Height;
- img->DepthScale = (GLfloat) img->Depth;
- }
-
- img->TexFormat = format;
-
- dims = _mesa_get_texture_dimensions(target);
-
- _mesa_set_fetch_functions(img, dims);
-}
-
-
-/**
- * Free and clear fields of the gl_texture_image struct.
- *
- * \param ctx GL context.
- * \param texImage texture image structure to be cleared.
- *
- * After the call, \p texImage will have no data associated with it. Its
- * fields are cleared so that its parent object will test incomplete.
- */
-void
-_mesa_clear_texture_image(struct gl_context *ctx,
- struct gl_texture_image *texImage)
-{
- ctx->Driver.FreeTexImageData(ctx, texImage);
- clear_teximage_fields(texImage);
-}
-
-
-/**
- * This is the fallback for Driver.TestProxyTexImage(). Test the texture
- * level, width, height and depth against the ctx->Const limits for textures.
- *
- * A hardware driver might override this function if, for example, the
- * max 3D texture size is 512x512x64 (i.e. not a cube).
- *
- * Note that width, height, depth == 0 is not an error. However, a
- * texture with zero width/height/depth will be considered "incomplete"
- * and texturing will effectively be disabled.
- *
- * \param target one of GL_PROXY_TEXTURE_1D, GL_PROXY_TEXTURE_2D,
- * GL_PROXY_TEXTURE_3D, GL_PROXY_TEXTURE_RECTANGLE_NV,
- * GL_PROXY_TEXTURE_CUBE_MAP_ARB.
- * \param level as passed to glTexImage
- * \param internalFormat as passed to glTexImage
- * \param format as passed to glTexImage
- * \param type as passed to glTexImage
- * \param width as passed to glTexImage
- * \param height as passed to glTexImage
- * \param depth as passed to glTexImage
- * \param border as passed to glTexImage
- * \return GL_TRUE if the image is acceptable, GL_FALSE if not acceptable.
- */
-GLboolean
-_mesa_test_proxy_teximage(struct gl_context *ctx, GLenum target, GLint level,
- GLint internalFormat, GLenum format, GLenum type,
- GLint width, GLint height, GLint depth, GLint border)
-{
- GLint maxSize;
-
- (void) internalFormat;
- (void) format;
- (void) type;
-
- switch (target) {
- case GL_PROXY_TEXTURE_1D:
- maxSize = 1 << (ctx->Const.MaxTextureLevels - 1);
- if (width < 2 * border || width > 2 + maxSize)
- return GL_FALSE;
- if (level >= ctx->Const.MaxTextureLevels)
- return GL_FALSE;
- if (!ctx->Extensions.ARB_texture_non_power_of_two) {
- if (width > 0 && !_mesa_is_pow_two(width - 2 * border))
- return GL_FALSE;
- }
- return GL_TRUE;
-
- case GL_PROXY_TEXTURE_2D:
- maxSize = 1 << (ctx->Const.MaxTextureLevels - 1);
- if (width < 2 * border || width > 2 + maxSize)
- return GL_FALSE;
- if (height < 2 * border || height > 2 + maxSize)
- return GL_FALSE;
- if (level >= ctx->Const.MaxTextureLevels)
- return GL_FALSE;
- if (!ctx->Extensions.ARB_texture_non_power_of_two) {
- if (width > 0 && !_mesa_is_pow_two(width - 2 * border))
- return GL_FALSE;
- if (height > 0 && !_mesa_is_pow_two(height - 2 * border))
- return GL_FALSE;
- }
- return GL_TRUE;
-
- case GL_PROXY_TEXTURE_3D:
- maxSize = 1 << (ctx->Const.Max3DTextureLevels - 1);
- if (width < 2 * border || width > 2 + maxSize)
- return GL_FALSE;
- if (height < 2 * border || height > 2 + maxSize)
- return GL_FALSE;
- if (depth < 2 * border || depth > 2 + maxSize)
- return GL_FALSE;
- if (level >= ctx->Const.Max3DTextureLevels)
- return GL_FALSE;
- if (!ctx->Extensions.ARB_texture_non_power_of_two) {
- if (width > 0 && !_mesa_is_pow_two(width - 2 * border))
- return GL_FALSE;
- if (height > 0 && !_mesa_is_pow_two(height - 2 * border))
- return GL_FALSE;
- if (depth > 0 && !_mesa_is_pow_two(depth - 2 * border))
- return GL_FALSE;
- }
- return GL_TRUE;
-
- case GL_PROXY_TEXTURE_RECTANGLE_NV:
- maxSize = ctx->Const.MaxTextureRectSize;
- if (width < 0 || width > maxSize)
- return GL_FALSE;
- if (height < 0 || height > maxSize)
- return GL_FALSE;
- if (level != 0)
- return GL_FALSE;
- return GL_TRUE;
-
- case GL_PROXY_TEXTURE_CUBE_MAP_ARB:
- maxSize = 1 << (ctx->Const.MaxCubeTextureLevels - 1);
- if (width < 2 * border || width > 2 + maxSize)
- return GL_FALSE;
- if (height < 2 * border || height > 2 + maxSize)
- return GL_FALSE;
- if (level >= ctx->Const.MaxCubeTextureLevels)
- return GL_FALSE;
- if (!ctx->Extensions.ARB_texture_non_power_of_two) {
- if (width > 0 && !_mesa_is_pow_two(width - 2 * border))
- return GL_FALSE;
- if (height > 0 && !_mesa_is_pow_two(height - 2 * border))
- return GL_FALSE;
- }
- return GL_TRUE;
-
- case GL_PROXY_TEXTURE_1D_ARRAY_EXT:
- maxSize = 1 << (ctx->Const.MaxTextureLevels - 1);
- if (width < 2 * border || width > 2 + maxSize)
- return GL_FALSE;
- if (height < 1 || height > ctx->Const.MaxArrayTextureLayers)
- return GL_FALSE;
- if (level >= ctx->Const.MaxTextureLevels)
- return GL_FALSE;
- if (!ctx->Extensions.ARB_texture_non_power_of_two) {
- if (width > 0 && !_mesa_is_pow_two(width - 2 * border))
- return GL_FALSE;
- }
- return GL_TRUE;
-
- case GL_PROXY_TEXTURE_2D_ARRAY_EXT:
- maxSize = 1 << (ctx->Const.MaxTextureLevels - 1);
- if (width < 2 * border || width > 2 + maxSize)
- return GL_FALSE;
- if (height < 2 * border || height > 2 + maxSize)
- return GL_FALSE;
- if (depth < 1 || depth > ctx->Const.MaxArrayTextureLayers)
- return GL_FALSE;
- if (level >= ctx->Const.MaxTextureLevels)
- return GL_FALSE;
- if (!ctx->Extensions.ARB_texture_non_power_of_two) {
- if (width > 0 && !_mesa_is_pow_two(width - 2 * border))
- return GL_FALSE;
- if (height > 0 && !_mesa_is_pow_two(height - 2 * border))
- return GL_FALSE;
- }
- return GL_TRUE;
-
- default:
- _mesa_problem(ctx, "Invalid target in _mesa_test_proxy_teximage");
- return GL_FALSE;
- }
-}
-
-
-/**
- * Check if the memory used by the texture would exceed the driver's limit.
- * This lets us support a max 3D texture size of 8K (for example) but
- * prevents allocating a full 8K x 8K x 8K texture.
- * XXX this could be rolled into the proxy texture size test (above) but
- * we don't have the actual texture internal format at that point.
- */
-static GLboolean
-legal_texture_size(struct gl_context *ctx, gl_format format,
- GLint width, GLint height, GLint depth)
-{
- uint64_t bytes = _mesa_format_image_size64(format, width, height, depth);
- uint64_t mbytes = bytes / (1024 * 1024); /* convert to MB */
- return mbytes <= (uint64_t) ctx->Const.MaxTextureMbytes;
-}
-
-
-
-/**
- * Helper function to determine whether a target and specific compression
- * format are supported.
- */
-static GLboolean
-target_can_be_compressed(const struct gl_context *ctx, GLenum target,
- GLenum intFormat)
-{
- (void) intFormat; /* not used yet */
-
- switch (target) {
- case GL_TEXTURE_2D:
- case GL_PROXY_TEXTURE_2D:
- return GL_TRUE; /* true for any compressed format so far */
- case GL_PROXY_TEXTURE_CUBE_MAP:
- case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
- case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
- case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
- return ctx->Extensions.ARB_texture_cube_map;
- case GL_PROXY_TEXTURE_2D_ARRAY_EXT:
- case GL_TEXTURE_2D_ARRAY_EXT:
- return ctx->Extensions.MESA_texture_array;
- default:
- return GL_FALSE;
- }
-}
-
-
-/**
- * Check if the given texture target value is legal for a
- * glTexImage1/2/3D call.
- */
-static GLboolean
-legal_teximage_target(struct gl_context *ctx, GLuint dims, GLenum target)
-{
- switch (dims) {
- case 1:
- switch (target) {
- case GL_TEXTURE_1D:
- case GL_PROXY_TEXTURE_1D:
- return GL_TRUE;
- default:
- return GL_FALSE;
- }
- case 2:
- switch (target) {
- case GL_TEXTURE_2D:
- case GL_PROXY_TEXTURE_2D:
- return GL_TRUE;
- case GL_PROXY_TEXTURE_CUBE_MAP:
- case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
- case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
- case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
- return ctx->Extensions.ARB_texture_cube_map;
- case GL_TEXTURE_RECTANGLE_NV:
- case GL_PROXY_TEXTURE_RECTANGLE_NV:
- return ctx->Extensions.NV_texture_rectangle;
- case GL_TEXTURE_1D_ARRAY_EXT:
- case GL_PROXY_TEXTURE_1D_ARRAY_EXT:
- return ctx->Extensions.MESA_texture_array;
- default:
- return GL_FALSE;
- }
- case 3:
- switch (target) {
- case GL_TEXTURE_3D:
- case GL_PROXY_TEXTURE_3D:
- return GL_TRUE;
- case GL_TEXTURE_2D_ARRAY_EXT:
- case GL_PROXY_TEXTURE_2D_ARRAY_EXT:
- return ctx->Extensions.MESA_texture_array;
- default:
- return GL_FALSE;
- }
- default:
- _mesa_problem(ctx, "invalid dims=%u in legal_teximage_target()", dims);
- return GL_FALSE;
- }
-}
-
-
-/**
- * Check if the given texture target value is legal for a
- * glTexSubImage, glCopyTexSubImage or glCopyTexImage call.
- * The difference compared to legal_teximage_target() above is that
- * proxy targets are not supported.
- */
-static GLboolean
-legal_texsubimage_target(struct gl_context *ctx, GLuint dims, GLenum target)
-{
- switch (dims) {
- case 1:
- return target == GL_TEXTURE_1D;
- case 2:
- switch (target) {
- case GL_TEXTURE_2D:
- return GL_TRUE;
- case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
- case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
- case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
- return ctx->Extensions.ARB_texture_cube_map;
- case GL_TEXTURE_RECTANGLE_NV:
- return ctx->Extensions.NV_texture_rectangle;
- case GL_TEXTURE_1D_ARRAY_EXT:
- return ctx->Extensions.MESA_texture_array;
- default:
- return GL_FALSE;
- }
- case 3:
- switch (target) {
- case GL_TEXTURE_3D:
- return GL_TRUE;
- case GL_TEXTURE_2D_ARRAY_EXT:
- return ctx->Extensions.MESA_texture_array;
- default:
- return GL_FALSE;
- }
- default:
- _mesa_problem(ctx, "invalid dims=%u in legal_texsubimage_target()",
- dims);
- return GL_FALSE;
- }
-}
-
-
-/**
- * Test the glTexImage[123]D() parameters for errors.
- *
- * \param ctx GL context.
- * \param dimensions texture image dimensions (must be 1, 2 or 3).
- * \param target texture target given by the user.
- * \param level image level given by the user.
- * \param internalFormat internal format given by the user.
- * \param format pixel data format given by the user.
- * \param type pixel data type given by the user.
- * \param width image width given by the user.
- * \param height image height given by the user.
- * \param depth image depth given by the user.
- * \param border image border given by the user.
- *
- * \return GL_TRUE if an error was detected, or GL_FALSE if no errors.
- *
- * Verifies each of the parameters against the constants specified in
- * __struct gl_contextRec::Const and the supported extensions, and according
- * to the OpenGL specification.
- */
-static GLboolean
-texture_error_check( struct gl_context *ctx,
- GLuint dimensions, GLenum target,
- GLint level, GLint internalFormat,
- GLenum format, GLenum type,
- GLint width, GLint height,
- GLint depth, GLint border )
-{
- const GLenum proxyTarget = get_proxy_target(target);
- const GLboolean isProxy = target == proxyTarget;
- GLboolean sizeOK = GL_TRUE;
- GLboolean colorFormat, indexFormat;
-
- /* Basic level check (more checking in ctx->Driver.TestProxyTexImage) */
- if (level < 0 || level >= MAX_TEXTURE_LEVELS) {
- if (!isProxy) {
- _mesa_error(ctx, GL_INVALID_VALUE,
- "glTexImage%dD(level=%d)", dimensions, level);
- }
- return GL_TRUE;
- }
-
- /* Check border */
- if (border < 0 || border > 1 ||
- ((target == GL_TEXTURE_RECTANGLE_NV ||
- target == GL_PROXY_TEXTURE_RECTANGLE_NV) && border != 0)) {
- if (!isProxy) {
- _mesa_error(ctx, GL_INVALID_VALUE,
- "glTexImage%dD(border=%d)", dimensions, border);
- }
- return GL_TRUE;
- }
-
- if (width < 0 || height < 0 || depth < 0) {
- if (!isProxy) {
- _mesa_error(ctx, GL_INVALID_VALUE,
- "glTexImage%dD(width, height or depth < 0)", dimensions);
- }
- return GL_TRUE;
- }
-
- /* Do this simple check before calling the TestProxyTexImage() function */
- if (proxyTarget == GL_PROXY_TEXTURE_CUBE_MAP_ARB) {
- sizeOK = (width == height);
- }
-
- /*
- * Use the proxy texture driver hook to see if the size/level/etc are
- * legal.
- */
- sizeOK = sizeOK && ctx->Driver.TestProxyTexImage(ctx, proxyTarget, level,
- internalFormat, format,
- type, width, height,
- depth, border);
- if (!sizeOK) {
- if (!isProxy) {
- _mesa_error(ctx, GL_INVALID_VALUE,
- "glTexImage%dD(level=%d, width=%d, height=%d, depth=%d)",
- dimensions, level, width, height, depth);
- }
- return GL_TRUE;
- }
-
- /* Check internalFormat */
- if (_mesa_base_tex_format(ctx, internalFormat) < 0) {
- if (!isProxy) {
- _mesa_error(ctx, GL_INVALID_VALUE,
- "glTexImage%dD(internalFormat=%s)",
- dimensions, _mesa_lookup_enum_by_nr(internalFormat));
- }
- return GL_TRUE;
- }
-
- /* Check incoming image format and type */
- if (!_mesa_is_legal_format_and_type(ctx, format, type)) {
- /* Normally, GL_INVALID_OPERATION is generated by a format/type
- * mismatch (see the 1.2 spec page 94, sec 3.6.4.). But with the
- * GL_EXT_texture_integer extension, some combinations should generate
- * GL_INVALID_ENUM instead (grr!).
- */
- if (!isProxy) {
- GLenum error = _mesa_is_integer_format(format)
- ? GL_INVALID_ENUM : GL_INVALID_OPERATION;
- _mesa_error(ctx, error,
- "glTexImage%dD(incompatible format 0x%x, type 0x%x)",
- dimensions, format, type);
- }
- return GL_TRUE;
- }
-
- /* make sure internal format and format basically agree */
- colorFormat = _mesa_is_color_format(format);
- indexFormat = _mesa_is_index_format(format);
- if ((_mesa_is_color_format(internalFormat) && !colorFormat && !indexFormat) ||
- (_mesa_is_index_format(internalFormat) && !indexFormat) ||
- (_mesa_is_depth_format(internalFormat) != _mesa_is_depth_format(format)) ||
- (_mesa_is_ycbcr_format(internalFormat) != _mesa_is_ycbcr_format(format)) ||
- (_mesa_is_depthstencil_format(internalFormat) != _mesa_is_depthstencil_format(format)) ||
- (_mesa_is_dudv_format(internalFormat) != _mesa_is_dudv_format(format))) {
- if (!isProxy)
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glTexImage%dD(incompatible internalFormat 0x%x, format 0x%x)",
- dimensions, internalFormat, format);
- return GL_TRUE;
- }
-
- /* additional checks for ycbcr textures */
- if (internalFormat == GL_YCBCR_MESA) {
- ASSERT(ctx->Extensions.MESA_ycbcr_texture);
- if (type != GL_UNSIGNED_SHORT_8_8_MESA &&
- type != GL_UNSIGNED_SHORT_8_8_REV_MESA) {
- char message[100];
- _mesa_snprintf(message, sizeof(message),
- "glTexImage%dD(format/type YCBCR mismatch", dimensions);
- _mesa_error(ctx, GL_INVALID_ENUM, "%s", message);
- return GL_TRUE; /* error */
- }
- if (target != GL_TEXTURE_2D &&
- target != GL_PROXY_TEXTURE_2D &&
- target != GL_TEXTURE_RECTANGLE_NV &&
- target != GL_PROXY_TEXTURE_RECTANGLE_NV) {
- if (!isProxy)
- _mesa_error(ctx, GL_INVALID_ENUM, "glTexImage(target)");
- return GL_TRUE;
- }
- if (border != 0) {
- if (!isProxy) {
- char message[100];
- _mesa_snprintf(message, sizeof(message),
- "glTexImage%dD(format=GL_YCBCR_MESA and border=%d)",
- dimensions, border);
- _mesa_error(ctx, GL_INVALID_VALUE, "%s", message);
- }
- return GL_TRUE;
- }
- }
-
- /* additional checks for depth textures */
- if (_mesa_base_tex_format(ctx, internalFormat) == GL_DEPTH_COMPONENT) {
- /* Only 1D, 2D and rectangular textures supported, not 3D or cubes */
- if (target != GL_TEXTURE_1D &&
- target != GL_PROXY_TEXTURE_1D &&
- target != GL_TEXTURE_2D &&
- target != GL_PROXY_TEXTURE_2D &&
- target != GL_TEXTURE_RECTANGLE_ARB &&
- target != GL_PROXY_TEXTURE_RECTANGLE_ARB) {
- if (!isProxy)
- _mesa_error(ctx, GL_INVALID_ENUM,
- "glTexImage(target/internalFormat)");
- return GL_TRUE;
- }
- }
-
- /* additional checks for compressed textures */
- if (_mesa_is_compressed_format(ctx, internalFormat)) {
- if (!target_can_be_compressed(ctx, target, internalFormat)) {
- if (!isProxy)
- _mesa_error(ctx, GL_INVALID_ENUM,
- "glTexImage%dD(target)", dimensions);
- return GL_TRUE;
- }
- if (border != 0) {
- if (!isProxy) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glTexImage%dD(border!=0)", dimensions);
- }
- return GL_TRUE;
- }
- }
-
- /* additional checks for integer textures */
- if (ctx->Extensions.EXT_texture_integer &&
- (_mesa_is_integer_format(format) !=
- _mesa_is_integer_format(internalFormat))) {
- if (!isProxy) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glTexImage%dD(integer/non-integer format mismatch)",
- dimensions);
- }
- return GL_TRUE;
- }
-
- /* if we get here, the parameters are OK */
- return GL_FALSE;
-}
-
-
-/**
- * Test glTexSubImage[123]D() parameters for errors.
- *
- * \param ctx GL context.
- * \param dimensions texture image dimensions (must be 1, 2 or 3).
- * \param target texture target given by the user.
- * \param level image level given by the user.
- * \param xoffset sub-image x offset given by the user.
- * \param yoffset sub-image y offset given by the user.
- * \param zoffset sub-image z offset given by the user.
- * \param format pixel data format given by the user.
- * \param type pixel data type given by the user.
- * \param width image width given by the user.
- * \param height image height given by the user.
- * \param depth image depth given by the user.
- *
- * \return GL_TRUE if an error was detected, or GL_FALSE if no errors.
- *
- * Verifies each of the parameters against the constants specified in
- * __struct gl_contextRec::Const and the supported extensions, and according
- * to the OpenGL specification.
- */
-static GLboolean
-subtexture_error_check( struct gl_context *ctx, GLuint dimensions,
- GLenum target, GLint level,
- GLint xoffset, GLint yoffset, GLint zoffset,
- GLint width, GLint height, GLint depth,
- GLenum format, GLenum type )
-{
- /* Basic level check */
- if (level < 0 || level >= MAX_TEXTURE_LEVELS) {
- _mesa_error(ctx, GL_INVALID_ENUM, "glTexSubImage2D(level=%d)", level);
- return GL_TRUE;
- }
-
- /* Check for negative sizes */
- if (width < 0) {
- _mesa_error(ctx, GL_INVALID_VALUE,
- "glTexSubImage%dD(width=%d)", dimensions, width);
- return GL_TRUE;
- }
- if (height < 0 && dimensions > 1) {
- _mesa_error(ctx, GL_INVALID_VALUE,
- "glTexSubImage%dD(height=%d)", dimensions, height);
- return GL_TRUE;
- }
- if (depth < 0 && dimensions > 2) {
- _mesa_error(ctx, GL_INVALID_VALUE,
- "glTexSubImage%dD(depth=%d)", dimensions, depth);
- return GL_TRUE;
- }
-
- if (!_mesa_is_legal_format_and_type(ctx, format, type)) {
- /* As with the glTexImage2D check above, the error code here
- * depends on texture integer.
- */
- GLenum error = _mesa_is_integer_format(format)
- ? GL_INVALID_OPERATION : GL_INVALID_ENUM;
- _mesa_error(ctx, error,
- "glTexSubImage%dD(incompatible format 0x%x, type 0x%x)",
- dimensions, format, type);
- return GL_TRUE;
- }
-
- return GL_FALSE;
-}
-
-
-/**
- * Do second part of glTexSubImage which depends on the destination texture.
- * \return GL_TRUE if error recorded, GL_FALSE otherwise
- */
-static GLboolean
-subtexture_error_check2( struct gl_context *ctx, GLuint dimensions,
- GLenum target, GLint level,
- GLint xoffset, GLint yoffset, GLint zoffset,
- GLint width, GLint height, GLint depth,
- GLenum format, GLenum type,
- const struct gl_texture_image *destTex )
-{
- if (!destTex) {
- /* undefined image level */
- _mesa_error(ctx, GL_INVALID_OPERATION, "glTexSubImage%dD", dimensions);
- return GL_TRUE;
- }
-
- if (xoffset < -((GLint)destTex->Border)) {
- _mesa_error(ctx, GL_INVALID_VALUE, "glTexSubImage%dD(xoffset)",
- dimensions);
- return GL_TRUE;
- }
- if (xoffset + width > (GLint) (destTex->Width + destTex->Border)) {
- _mesa_error(ctx, GL_INVALID_VALUE, "glTexSubImage%dD(xoffset+width)",
- dimensions);
- return GL_TRUE;
- }
- if (dimensions > 1) {
- if (yoffset < -((GLint)destTex->Border)) {
- _mesa_error(ctx, GL_INVALID_VALUE, "glTexSubImage%dD(yoffset)",
- dimensions);
- return GL_TRUE;
- }
- if (yoffset + height > (GLint) (destTex->Height + destTex->Border)) {
- _mesa_error(ctx, GL_INVALID_VALUE, "glTexSubImage%dD(yoffset+height)",
- dimensions);
- return GL_TRUE;
- }
- }
- if (dimensions > 2) {
- if (zoffset < -((GLint)destTex->Border)) {
- _mesa_error(ctx, GL_INVALID_VALUE, "glTexSubImage3D(zoffset)");
- return GL_TRUE;
- }
- if (zoffset + depth > (GLint) (destTex->Depth + destTex->Border)) {
- _mesa_error(ctx, GL_INVALID_VALUE, "glTexSubImage3D(zoffset+depth)");
- return GL_TRUE;
- }
- }
-
- if (_mesa_is_format_compressed(destTex->TexFormat)) {
- GLuint bw, bh;
-
- /* do tests which depend on compression block size */
- _mesa_get_format_block_size(destTex->TexFormat, &bw, &bh);
-
- /* offset must be multiple of block size */
- if ((xoffset % bw != 0) || (yoffset % bh != 0)) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glTexSubImage%dD(xoffset = %d, yoffset = %d)",
- dimensions, xoffset, yoffset);
- return GL_TRUE;
- }
- /* size must be multiple of bw by bh or equal to whole texture size */
- if ((width % bw != 0) && (GLuint) width != destTex->Width) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glTexSubImage%dD(width = %d)", dimensions, width);
- return GL_TRUE;
- }
- if ((height % bh != 0) && (GLuint) height != destTex->Height) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glTexSubImage%dD(height = %d)", dimensions, height);
- return GL_TRUE;
- }
- }
-
- return GL_FALSE;
-}
-
-
-/**
- * Test glCopyTexImage[12]D() parameters for errors.
- *
- * \param ctx GL context.
- * \param dimensions texture image dimensions (must be 1, 2 or 3).
- * \param target texture target given by the user.
- * \param level image level given by the user.
- * \param internalFormat internal format given by the user.
- * \param width image width given by the user.
- * \param height image height given by the user.
- * \param border texture border.
- *
- * \return GL_TRUE if an error was detected, or GL_FALSE if no errors.
- *
- * Verifies each of the parameters against the constants specified in
- * __struct gl_contextRec::Const and the supported extensions, and according
- * to the OpenGL specification.
- */
-static GLboolean
-copytexture_error_check( struct gl_context *ctx, GLuint dimensions,
- GLenum target, GLint level, GLint internalFormat,
- GLint width, GLint height, GLint border )
-{
- const GLenum proxyTarget = get_proxy_target(target);
- const GLenum type = GL_FLOAT;
- GLboolean sizeOK;
- GLint format;
-
- /* check target */
- if (!legal_texsubimage_target(ctx, dimensions, target)) {
- _mesa_error(ctx, GL_INVALID_ENUM, "glCopyTexImage%uD(target=%s)",
- dimensions, _mesa_lookup_enum_by_nr(target));
- return GL_TRUE;
- }
-
- /* Basic level check (more checking in ctx->Driver.TestProxyTexImage) */
- if (level < 0 || level >= MAX_TEXTURE_LEVELS) {
- _mesa_error(ctx, GL_INVALID_VALUE,
- "glCopyTexImage%dD(level=%d)", dimensions, level);
- return GL_TRUE;
- }
-
- /* Check that the source buffer is complete */
- if (ctx->ReadBuffer->Name) {
- _mesa_test_framebuffer_completeness(ctx, ctx->ReadBuffer);
- if (ctx->ReadBuffer->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) {
- _mesa_error(ctx, GL_INVALID_FRAMEBUFFER_OPERATION_EXT,
- "glCopyTexImage%dD(invalid readbuffer)", dimensions);
- return GL_TRUE;
- }
- }
-
- /* Check border */
- if (border < 0 || border > 1 ||
- ((target == GL_TEXTURE_RECTANGLE_NV ||
- target == GL_PROXY_TEXTURE_RECTANGLE_NV) && border != 0)) {
- return GL_TRUE;
- }
-
- format = _mesa_base_tex_format(ctx, internalFormat);
- if (format < 0) {
- _mesa_error(ctx, GL_INVALID_VALUE,
- "glCopyTexImage%dD(internalFormat)", dimensions);
- return GL_TRUE;
- }
-
- if (!_mesa_source_buffer_exists(ctx, format)) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glCopyTexImage%dD(missing readbuffer)", dimensions);
- return GL_TRUE;
- }
-
- /* Do size, level checking */
- sizeOK = (proxyTarget == GL_PROXY_TEXTURE_CUBE_MAP_ARB)
- ? (width == height) : 1;
-
- sizeOK = sizeOK && ctx->Driver.TestProxyTexImage(ctx, proxyTarget, level,
- internalFormat, format,
- type, width, height,
- 1, border);
-
- if (!sizeOK) {
- if (dimensions == 1) {
- _mesa_error(ctx, GL_INVALID_VALUE,
- "glCopyTexImage1D(width=%d)", width);
- }
- else {
- ASSERT(dimensions == 2);
- _mesa_error(ctx, GL_INVALID_VALUE,
- "glCopyTexImage2D(width=%d, height=%d)", width, height);
- }
- return GL_TRUE;
- }
-
- if (_mesa_is_compressed_format(ctx, internalFormat)) {
- if (!target_can_be_compressed(ctx, target, internalFormat)) {
- _mesa_error(ctx, GL_INVALID_ENUM,
- "glCopyTexImage%dD(target)", dimensions);
- return GL_TRUE;
- }
- if (border != 0) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glCopyTexImage%dD(border!=0)", dimensions);
- return GL_TRUE;
- }
- }
- else if (_mesa_is_depth_format(internalFormat)) {
- /* make sure we have depth/stencil buffers */
- if (!ctx->ReadBuffer->_DepthBuffer) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glCopyTexImage%dD(no depth)", dimensions);
- return GL_TRUE;
- }
- }
- else if (_mesa_is_depthstencil_format(internalFormat)) {
- /* make sure we have depth/stencil buffers */
- if (!ctx->ReadBuffer->_DepthBuffer || !ctx->ReadBuffer->_StencilBuffer) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glCopyTexImage%dD(no depth/stencil buffer)", dimensions);
- return GL_TRUE;
- }
- }
-
- /* if we get here, the parameters are OK */
- return GL_FALSE;
-}
-
-
-/**
- * Test glCopyTexSubImage[12]D() parameters for errors.
- * Note that this is the first part of error checking.
- * See also copytexsubimage_error_check2() below for the second part.
- *
- * \param ctx GL context.
- * \param dimensions texture image dimensions (must be 1, 2 or 3).
- * \param target texture target given by the user.
- * \param level image level given by the user.
- *
- * \return GL_TRUE if an error was detected, or GL_FALSE if no errors.
- */
-static GLboolean
-copytexsubimage_error_check1( struct gl_context *ctx, GLuint dimensions,
- GLenum target, GLint level)
-{
- /* Check that the source buffer is complete */
- if (ctx->ReadBuffer->Name) {
- _mesa_test_framebuffer_completeness(ctx, ctx->ReadBuffer);
- if (ctx->ReadBuffer->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) {
- _mesa_error(ctx, GL_INVALID_FRAMEBUFFER_OPERATION_EXT,
- "glCopyTexImage%dD(invalid readbuffer)", dimensions);
- return GL_TRUE;
- }
- }
-
- /* check target (proxies not allowed) */
- if (!legal_texsubimage_target(ctx, dimensions, target)) {
- _mesa_error(ctx, GL_INVALID_ENUM, "glCopyTexSubImage%uD(target=%s)",
- dimensions, _mesa_lookup_enum_by_nr(target));
- return GL_TRUE;
- }
-
- /* Check level */
- if (level < 0 || level >= MAX_TEXTURE_LEVELS) {
- _mesa_error(ctx, GL_INVALID_VALUE,
- "glCopyTexSubImage%dD(level=%d)", dimensions, level);
- return GL_TRUE;
- }
-
- return GL_FALSE;
-}
-
-
-/**
- * Second part of error checking for glCopyTexSubImage[12]D().
- * \param xoffset sub-image x offset given by the user.
- * \param yoffset sub-image y offset given by the user.
- * \param zoffset sub-image z offset given by the user.
- * \param width image width given by the user.
- * \param height image height given by the user.
- */
-static GLboolean
-copytexsubimage_error_check2( struct gl_context *ctx, GLuint dimensions,
- GLenum target, GLint level,
- GLint xoffset, GLint yoffset, GLint zoffset,
- GLsizei width, GLsizei height,
- const struct gl_texture_image *teximage )
-{
- /* check that dest tex image exists */
- if (!teximage) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glCopyTexSubImage%dD(undefined texture level: %d)",
- dimensions, level);
- return GL_TRUE;
- }
-
- /* Check size */
- if (width < 0) {
- _mesa_error(ctx, GL_INVALID_VALUE,
- "glCopyTexSubImage%dD(width=%d)", dimensions, width);
- return GL_TRUE;
- }
- if (dimensions > 1 && height < 0) {
- _mesa_error(ctx, GL_INVALID_VALUE,
- "glCopyTexSubImage%dD(height=%d)", dimensions, height);
- return GL_TRUE;
- }
-
- /* check x/y offsets */
- if (xoffset < -((GLint)teximage->Border)) {
- _mesa_error(ctx, GL_INVALID_VALUE,
- "glCopyTexSubImage%dD(xoffset=%d)", dimensions, xoffset);
- return GL_TRUE;
- }
- if (xoffset + width > (GLint) (teximage->Width + teximage->Border)) {
- _mesa_error(ctx, GL_INVALID_VALUE,
- "glCopyTexSubImage%dD(xoffset+width)", dimensions);
- return GL_TRUE;
- }
- if (dimensions > 1) {
- if (yoffset < -((GLint)teximage->Border)) {
- _mesa_error(ctx, GL_INVALID_VALUE,
- "glCopyTexSubImage%dD(yoffset=%d)", dimensions, yoffset);
- return GL_TRUE;
- }
- /* NOTE: we're adding the border here, not subtracting! */
- if (yoffset + height > (GLint) (teximage->Height + teximage->Border)) {
- _mesa_error(ctx, GL_INVALID_VALUE,
- "glCopyTexSubImage%dD(yoffset+height)", dimensions);
- return GL_TRUE;
- }
- }
-
- /* check z offset */
- if (dimensions > 2) {
- if (zoffset < -((GLint)teximage->Border)) {
- _mesa_error(ctx, GL_INVALID_VALUE,
- "glCopyTexSubImage%dD(zoffset)", dimensions);
- return GL_TRUE;
- }
- if (zoffset > (GLint) (teximage->Depth + teximage->Border)) {
- _mesa_error(ctx, GL_INVALID_VALUE,
- "glCopyTexSubImage%dD(zoffset+depth)", dimensions);
- return GL_TRUE;
- }
- }
-
- if (_mesa_is_format_compressed(teximage->TexFormat)) {
- /* offset must be multiple of 4 */
- if ((xoffset & 3) || (yoffset & 3)) {
- _mesa_error(ctx, GL_INVALID_VALUE,
- "glCopyTexSubImage%dD(xoffset or yoffset)", dimensions);
- return GL_TRUE;
- }
- /* size must be multiple of 4 */
- if ((width & 3) != 0 && (GLuint) width != teximage->Width) {
- _mesa_error(ctx, GL_INVALID_VALUE,
- "glCopyTexSubImage%dD(width)", dimensions);
- return GL_TRUE;
- }
- if ((height & 3) != 0 && (GLuint) height != teximage->Height) {
- _mesa_error(ctx, GL_INVALID_VALUE,
- "glCopyTexSubImage%dD(height)", dimensions);
- return GL_TRUE;
- }
- }
-
- if (teximage->InternalFormat == GL_YCBCR_MESA) {
- _mesa_error(ctx, GL_INVALID_OPERATION, "glCopyTexSubImage2D");
- return GL_TRUE;
- }
-
- if (!_mesa_source_buffer_exists(ctx, teximage->_BaseFormat)) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glCopyTexSubImage%dD(missing readbuffer, format=0x%x)",
- dimensions, teximage->_BaseFormat);
- return GL_TRUE;
- }
-
- if (teximage->_BaseFormat == GL_DEPTH_COMPONENT) {
- if (!ctx->ReadBuffer->_DepthBuffer) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glCopyTexSubImage%dD(no depth buffer)",
- dimensions);
- return GL_TRUE;
- }
- }
- else if (teximage->_BaseFormat == GL_DEPTH_STENCIL_EXT) {
- if (!ctx->ReadBuffer->_DepthBuffer || !ctx->ReadBuffer->_StencilBuffer) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glCopyTexSubImage%dD(no depth/stencil buffer)",
- dimensions);
- return GL_TRUE;
- }
- }
-
- /* If copying into an integer texture, the source buffer must also be
- * integer-valued.
- */
- if (_mesa_is_format_integer_color(teximage->TexFormat)) {
- struct gl_renderbuffer *rb = ctx->ReadBuffer->_ColorReadBuffer;
- if (!_mesa_is_format_integer_color(rb->Format)) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glCopyTexSubImage%dD(source buffer is not integer format)",
- dimensions);
- return GL_TRUE;
- }
- }
-
- /* if we get here, the parameters are OK */
- return GL_FALSE;
-}
-
-
-/** Callback info for walking over FBO hash table */
-struct cb_info
-{
- struct gl_context *ctx;
- struct gl_texture_object *texObj;
- GLuint level, face;
-};
-
-
-/**
- * Check render to texture callback. Called from _mesa_HashWalk().
- */
-static void
-check_rtt_cb(GLuint key, void *data, void *userData)
-{
- struct gl_framebuffer *fb = (struct gl_framebuffer *) data;
- const struct cb_info *info = (struct cb_info *) userData;
- struct gl_context *ctx = info->ctx;
- const struct gl_texture_object *texObj = info->texObj;
- const GLuint level = info->level, face = info->face;
-
- /* If this is a user-created FBO */
- if (fb->Name) {
- GLuint i;
- /* check if any of the FBO's attachments point to 'texObj' */
- for (i = 0; i < BUFFER_COUNT; i++) {
- struct gl_renderbuffer_attachment *att = fb->Attachment + i;
- if (att->Type == GL_TEXTURE &&
- att->Texture == texObj &&
- att->TextureLevel == level &&
- att->CubeMapFace == face) {
- ASSERT(att->Texture->Image[att->CubeMapFace][att->TextureLevel]);
- /* Tell driver about the new renderbuffer texture */
- ctx->Driver.RenderTexture(ctx, ctx->DrawBuffer, att);
- /* Mark fb status as indeterminate to force re-validation */
- fb->_Status = 0;
- }
- }
- }
-}
-
-
-/**
- * When a texture image is specified we have to check if it's bound to
- * any framebuffer objects (render to texture) in order to detect changes
- * in size or format since that effects FBO completeness.
- * Any FBOs rendering into the texture must be re-validated.
- */
-static void
-update_fbo_texture(struct gl_context *ctx, struct gl_texture_object *texObj,
- GLuint face, GLuint level)
-{
- /* Only check this texture if it's been marked as RenderToTexture */
- if (texObj->_RenderToTexture) {
- struct cb_info info;
- info.ctx = ctx;
- info.texObj = texObj;
- info.level = level;
- info.face = face;
- _mesa_HashWalk(ctx->Shared->FrameBuffers, check_rtt_cb, &info);
- }
-}
-
-
-/**
- * If the texture object's GenerateMipmap flag is set and we've
- * changed the texture base level image, regenerate the rest of the
- * mipmap levels now.
- */
-static INLINE void
-check_gen_mipmap(struct gl_context *ctx, GLenum target,
- struct gl_texture_object *texObj, GLint level)
-{
- ASSERT(target != GL_TEXTURE_CUBE_MAP);
- if (texObj->GenerateMipmap &&
- level == texObj->BaseLevel &&
- level < texObj->MaxLevel) {
- ASSERT(ctx->Driver.GenerateMipmap);
- ctx->Driver.GenerateMipmap(ctx, target, texObj);
- }
-}
-
-
-/** Debug helper: override the user-requested internal format */
-static GLenum
-override_internal_format(GLenum internalFormat, GLint width, GLint height)
-{
-#if 0
- if (internalFormat == GL_RGBA16F_ARB ||
- internalFormat == GL_RGBA32F_ARB) {
- printf("Convert rgba float tex to int %d x %d\n", width, height);
- return GL_RGBA;
- }
- else if (internalFormat == GL_RGB16F_ARB ||
- internalFormat == GL_RGB32F_ARB) {
- printf("Convert rgb float tex to int %d x %d\n", width, height);
- return GL_RGB;
- }
- else if (internalFormat == GL_LUMINANCE_ALPHA16F_ARB ||
- internalFormat == GL_LUMINANCE_ALPHA32F_ARB) {
- printf("Convert luminance float tex to int %d x %d\n", width, height);
- return GL_LUMINANCE_ALPHA;
- }
- else if (internalFormat == GL_LUMINANCE16F_ARB ||
- internalFormat == GL_LUMINANCE32F_ARB) {
- printf("Convert luminance float tex to int %d x %d\n", width, height);
- return GL_LUMINANCE;
- }
- else if (internalFormat == GL_ALPHA16F_ARB ||
- internalFormat == GL_ALPHA32F_ARB) {
- printf("Convert luminance float tex to int %d x %d\n", width, height);
- return GL_ALPHA;
- }
- /*
- else if (internalFormat == GL_COMPRESSED_RGBA_S3TC_DXT1_EXT) {
- internalFormat = GL_RGBA;
- }
- */
- else {
- return internalFormat;
- }
-#else
- return internalFormat;
-#endif
-}
-
-
-/**
- * Choose the actual hardware format for a texture image.
- * Try to use the same format as the previous image level when possible.
- * Otherwise, ask the driver for the best format.
- * It's important to try to choose a consistant format for all levels
- * for efficient texture memory layout/allocation. In particular, this
- * comes up during automatic mipmap generation.
- */
-gl_format
-_mesa_choose_texture_format(struct gl_context *ctx,
- struct gl_texture_object *texObj,
- GLenum target, GLint level,
- GLenum internalFormat, GLenum format, GLenum type)
-{
- gl_format f;
-
- /* see if we've already chosen a format for the previous level */
- if (level > 0) {
- struct gl_texture_image *prevImage =
- _mesa_select_tex_image(ctx, texObj, target, level - 1);
- /* See if the prev level is defined and has an internal format which
- * matches the new internal format.
- */
- if (prevImage &&
- prevImage->Width > 0 &&
- prevImage->InternalFormat == internalFormat) {
- /* use the same format */
- ASSERT(prevImage->TexFormat != MESA_FORMAT_NONE);
- return prevImage->TexFormat;
- }
- }
-
- /* choose format from scratch */
- f = ctx->Driver.ChooseTextureFormat(ctx, internalFormat, format, type);
- ASSERT(f != MESA_FORMAT_NONE);
- return f;
-}
-
-
-/**
- * Common code to implement all the glTexImage1D/2D/3D functions.
- */
-static void
-teximage(struct gl_context *ctx, GLuint dims,
- GLenum target, GLint level, GLint internalFormat,
- GLsizei width, GLsizei height, GLsizei depth,
- GLint border, GLenum format, GLenum type,
- const GLvoid *pixels)
-{
- GLboolean error;
-
- ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
-
- if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE))
- _mesa_debug(ctx, "glTexImage%uD %s %d %s %d %d %d %d %s %s %p\n",
- dims,
- _mesa_lookup_enum_by_nr(target), level,
- _mesa_lookup_enum_by_nr(internalFormat),
- width, height, depth, border,
- _mesa_lookup_enum_by_nr(format),
- _mesa_lookup_enum_by_nr(type), pixels);
-
- internalFormat = override_internal_format(internalFormat, width, height);
-
- /* target error checking */
- if (!legal_teximage_target(ctx, dims, target)) {
- _mesa_error(ctx, GL_INVALID_ENUM, "glTexImage%uD(target=%s)",
- dims, _mesa_lookup_enum_by_nr(target));
- return;
- }
-
- /* general error checking */
- error = texture_error_check(ctx, dims, target, level, internalFormat,
- format, type, width, height, depth, border);
-
- if (_mesa_is_proxy_texture(target)) {
- /* Proxy texture: just clear or set state depending on error checking */
- struct gl_texture_image *texImage =
- _mesa_get_proxy_tex_image(ctx, target, level);
-
- if (error) {
- /* when error, clear all proxy texture image parameters */
- if (texImage)
- clear_teximage_fields(texImage);
- }
- else {
- /* no error, set the tex image parameters */
- struct gl_texture_object *texObj =
- _mesa_get_current_tex_object(ctx, target);
- gl_format texFormat = _mesa_choose_texture_format(ctx, texObj,
- target, level,
- internalFormat,
- format, type);
-
- if (legal_texture_size(ctx, texFormat, width, height, depth)) {
- _mesa_init_teximage_fields(ctx, target, texImage, width, height,
- depth, border, internalFormat,
- texFormat);
- }
- else if (texImage) {
- clear_teximage_fields(texImage);
- }
- }
- }
- else {
- /* non-proxy target */
- const GLuint face = _mesa_tex_target_to_face(target);
- struct gl_texture_object *texObj;
- struct gl_texture_image *texImage;
-
- if (error) {
- return; /* error was recorded */
- }
-
- if (ctx->NewState & _MESA_NEW_TRANSFER_STATE)
- _mesa_update_state(ctx);
-
- texObj = _mesa_get_current_tex_object(ctx, target);
-
- _mesa_lock_texture(ctx, texObj);
- {
- texImage = _mesa_get_tex_image(ctx, texObj, target, level);
-
- if (!texImage) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage%uD", dims);
- }
- else {
- gl_format texFormat;
-
- if (texImage->Data) {
- ctx->Driver.FreeTexImageData( ctx, texImage );
- }
-
- ASSERT(texImage->Data == NULL);
- texFormat = _mesa_choose_texture_format(ctx, texObj, target, level,
- internalFormat, format,
- type);
-
- if (legal_texture_size(ctx, texFormat, width, height, depth)) {
- _mesa_init_teximage_fields(ctx, target, texImage,
- width, height, depth,
- border, internalFormat, texFormat);
-
- /* Give the texture to the driver. <pixels> may be null. */
- ASSERT(ctx->Driver.TexImage3D);
- switch (dims) {
- case 1:
- ctx->Driver.TexImage1D(ctx, target, level, internalFormat,
- width, border, format,
- type, pixels, &ctx->Unpack, texObj,
- texImage);
- break;
- case 2:
- ctx->Driver.TexImage2D(ctx, target, level, internalFormat,
- width, height, border, format,
- type, pixels, &ctx->Unpack, texObj,
- texImage);
- break;
- case 3:
- ctx->Driver.TexImage3D(ctx, target, level, internalFormat,
- width, height, depth, border, format,
- type, pixels, &ctx->Unpack, texObj,
- texImage);
- break;
- default:
- _mesa_problem(ctx, "invalid dims=%u in teximage()", dims);
- }
-
- check_gen_mipmap(ctx, target, texObj, level);
-
- update_fbo_texture(ctx, texObj, face, level);
-
- /* state update */
- texObj->_Complete = GL_FALSE;
- ctx->NewState |= _NEW_TEXTURE;
- }
- else {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage%uD", dims);
- }
- }
- }
- _mesa_unlock_texture(ctx, texObj);
- }
-}
-
-
-/*
- * Called from the API. Note that width includes the border.
- */
-void GLAPIENTRY
-_mesa_TexImage1D( GLenum target, GLint level, GLint internalFormat,
- GLsizei width, GLint border, GLenum format,
- GLenum type, const GLvoid *pixels )
-{
- GET_CURRENT_CONTEXT(ctx);
- teximage(ctx, 1, target, level, internalFormat, width, 1, 1,
- border, format, type, pixels);
-}
-
-
-void GLAPIENTRY
-_mesa_TexImage2D( GLenum target, GLint level, GLint internalFormat,
- GLsizei width, GLsizei height, GLint border,
- GLenum format, GLenum type,
- const GLvoid *pixels )
-{
- GET_CURRENT_CONTEXT(ctx);
- teximage(ctx, 2, target, level, internalFormat, width, height, 1,
- border, format, type, pixels);
-}
-
-
-/*
- * Called by the API or display list executor.
- * Note that width and height include the border.
- */
-void GLAPIENTRY
-_mesa_TexImage3D( GLenum target, GLint level, GLint internalFormat,
- GLsizei width, GLsizei height, GLsizei depth,
- GLint border, GLenum format, GLenum type,
- const GLvoid *pixels )
-{
- GET_CURRENT_CONTEXT(ctx);
- teximage(ctx, 3, target, level, internalFormat, width, height, depth,
- border, format, type, pixels);
-}
-
-
-void GLAPIENTRY
-_mesa_TexImage3DEXT( GLenum target, GLint level, GLenum internalFormat,
- GLsizei width, GLsizei height, GLsizei depth,
- GLint border, GLenum format, GLenum type,
- const GLvoid *pixels )
-{
- _mesa_TexImage3D(target, level, (GLint) internalFormat, width, height,
- depth, border, format, type, pixels);
-}
-
-
-#if FEATURE_OES_EGL_image
-void GLAPIENTRY
-_mesa_EGLImageTargetTexture2DOES (GLenum target, GLeglImageOES image)
-{
- struct gl_texture_object *texObj;
- struct gl_texture_image *texImage;
- GET_CURRENT_CONTEXT(ctx);
- ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
-
- if (!ctx->Extensions.OES_EGL_image) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glEGLImageTargetTexture2DOES(unsupported)");
- return;
- }
-
- if (target != GL_TEXTURE_2D) {
- _mesa_error(ctx, GL_INVALID_ENUM,
- "glEGLImageTargetTexture2D(target=%d)", target);
- return;
- }
-
- if (ctx->NewState & _MESA_NEW_TRANSFER_STATE)
- _mesa_update_state(ctx);
-
- texObj = _mesa_get_current_tex_object(ctx, target);
- _mesa_lock_texture(ctx, texObj);
-
- texImage = _mesa_get_tex_image(ctx, texObj, target, 0);
- if (!texImage) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "glEGLImageTargetTexture2D");
- } else {
- if (texImage->Data)
- ctx->Driver.FreeTexImageData( ctx, texImage );
-
- ASSERT(texImage->Data == NULL);
- ctx->Driver.EGLImageTargetTexture2D(ctx, target,
- texObj, texImage, image);
-
- /* state update */
- texObj->_Complete = GL_FALSE;
- ctx->NewState |= _NEW_TEXTURE;
- }
- _mesa_unlock_texture(ctx, texObj);
-
-}
-#endif
-
-
-
-/**
- * Implement all the glTexSubImage1/2/3D() functions.
- */
-static void
-texsubimage(struct gl_context *ctx, GLuint dims, GLenum target, GLint level,
- GLint xoffset, GLint yoffset, GLint zoffset,
- GLsizei width, GLsizei height, GLsizei depth,
- GLenum format, GLenum type, const GLvoid *pixels )
-{
- struct gl_texture_object *texObj;
- struct gl_texture_image *texImage;
-
- ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
-
- if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE))
- _mesa_debug(ctx, "glTexSubImage%uD %s %d %d %d %d %d %d %d %s %s %p\n",
- dims,
- _mesa_lookup_enum_by_nr(target), level,
- xoffset, yoffset, zoffset, width, height, depth,
- _mesa_lookup_enum_by_nr(format),
- _mesa_lookup_enum_by_nr(type), pixels);
-
- /* check target (proxies not allowed) */
- if (!legal_texsubimage_target(ctx, dims, target)) {
- _mesa_error(ctx, GL_INVALID_ENUM, "glTexSubImage%uD(target=%s)",
- dims, _mesa_lookup_enum_by_nr(target));
- return;
- }
-
- if (ctx->NewState & _MESA_NEW_TRANSFER_STATE)
- _mesa_update_state(ctx);
-
- if (subtexture_error_check(ctx, dims, target, level, xoffset, yoffset, zoffset,
- width, height, depth, format, type)) {
- return; /* error was detected */
- }
-
- texObj = _mesa_get_current_tex_object(ctx, target);
-
- _mesa_lock_texture(ctx, texObj);
- {
- texImage = _mesa_select_tex_image(ctx, texObj, target, level);
-
- if (subtexture_error_check2(ctx, dims, target, level,
- xoffset, yoffset, zoffset,
- width, height, depth,
- format, type, texImage)) {
- /* error was recorded */
- }
- else if (width > 0 && height > 0 && height > 0) {
- /* If we have a border, offset=-1 is legal. Bias by border width. */
- switch (dims) {
- case 3:
- zoffset += texImage->Border;
- /* fall-through */
- case 2:
- yoffset += texImage->Border;
- /* fall-through */
- case 1:
- xoffset += texImage->Border;
- }
-
- switch (dims) {
- case 1:
- ctx->Driver.TexSubImage1D(ctx, target, level,
- xoffset, width,
- format, type, pixels,
- &ctx->Unpack, texObj, texImage );
- break;
- case 2:
- ctx->Driver.TexSubImage2D(ctx, target, level,
- xoffset, yoffset, width, height,
- format, type, pixels,
- &ctx->Unpack, texObj, texImage );
- break;
- case 3:
- ctx->Driver.TexSubImage3D(ctx, target, level,
- xoffset, yoffset, zoffset,
- width, height, depth,
- format, type, pixels,
- &ctx->Unpack, texObj, texImage );
- break;
- default:
- _mesa_problem(ctx, "unexpected dims in subteximage()");
- }
-
- check_gen_mipmap(ctx, target, texObj, level);
-
- ctx->NewState |= _NEW_TEXTURE;
- }
- }
- _mesa_unlock_texture(ctx, texObj);
-}
-
-
-void GLAPIENTRY
-_mesa_TexSubImage1D( GLenum target, GLint level,
- GLint xoffset, GLsizei width,
- GLenum format, GLenum type,
- const GLvoid *pixels )
-{
- GET_CURRENT_CONTEXT(ctx);
- texsubimage(ctx, 1, target, level,
- xoffset, 0, 0,
- width, 1, 1,
- format, type, pixels);
-}
-
-
-void GLAPIENTRY
-_mesa_TexSubImage2D( GLenum target, GLint level,
- GLint xoffset, GLint yoffset,
- GLsizei width, GLsizei height,
- GLenum format, GLenum type,
- const GLvoid *pixels )
-{
- GET_CURRENT_CONTEXT(ctx);
- texsubimage(ctx, 2, target, level,
- xoffset, yoffset, 0,
- width, height, 1,
- format, type, pixels);
-}
-
-
-
-void GLAPIENTRY
-_mesa_TexSubImage3D( GLenum target, GLint level,
- GLint xoffset, GLint yoffset, GLint zoffset,
- GLsizei width, GLsizei height, GLsizei depth,
- GLenum format, GLenum type,
- const GLvoid *pixels )
-{
- GET_CURRENT_CONTEXT(ctx);
- texsubimage(ctx, 3, target, level,
- xoffset, yoffset, zoffset,
- width, height, depth,
- format, type, pixels);
-}
-
-
-
-/**
- * Implement the glCopyTexImage1/2D() functions.
- */
-static void
-copyteximage(struct gl_context *ctx, GLuint dims,
- GLenum target, GLint level, GLenum internalFormat,
- GLint x, GLint y, GLsizei width, GLsizei height, GLint border )
-{
- struct gl_texture_object *texObj;
- struct gl_texture_image *texImage;
- const GLuint face = _mesa_tex_target_to_face(target);
-
- ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
-
- if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE))
- _mesa_debug(ctx, "glCopyTexImage%uD %s %d %s %d %d %d %d %d\n",
- dims,
- _mesa_lookup_enum_by_nr(target), level,
- _mesa_lookup_enum_by_nr(internalFormat),
- x, y, width, height, border);
-
- if (ctx->NewState & NEW_COPY_TEX_STATE)
- _mesa_update_state(ctx);
-
- if (copytexture_error_check(ctx, dims, target, level, internalFormat,
- width, height, border))
- return;
-
- texObj = _mesa_get_current_tex_object(ctx, target);
-
- _mesa_lock_texture(ctx, texObj);
- {
- texImage = _mesa_get_tex_image(ctx, texObj, target, level);
-
- if (!texImage) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyTexImage%uD", dims);
- }
- else {
- gl_format texFormat;
-
- if (texImage->Data) {
- ctx->Driver.FreeTexImageData( ctx, texImage );
- }
-
- ASSERT(texImage->Data == NULL);
-
- texFormat = _mesa_choose_texture_format(ctx, texObj, target, level,
- internalFormat, GL_NONE,
- GL_NONE);
-
- if (legal_texture_size(ctx, texFormat, width, height, 1)) {
- _mesa_init_teximage_fields(ctx, target, texImage, width, height, 1,
- border, internalFormat, texFormat);
-
- ASSERT(ctx->Driver.CopyTexImage2D);
- if (dims == 1)
- ctx->Driver.CopyTexImage1D(ctx, target, level, internalFormat,
- x, y, width, border);
- else
- ctx->Driver.CopyTexImage2D(ctx, target, level, internalFormat,
- x, y, width, height, border);
-
- check_gen_mipmap(ctx, target, texObj, level);
-
- update_fbo_texture(ctx, texObj, face, level);
-
- /* state update */
- texObj->_Complete = GL_FALSE;
- ctx->NewState |= _NEW_TEXTURE;
- }
- else {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyTexImage%uD", dims);
- }
- }
- }
- _mesa_unlock_texture(ctx, texObj);
-}
-
-
-
-void GLAPIENTRY
-_mesa_CopyTexImage1D( GLenum target, GLint level,
- GLenum internalFormat,
- GLint x, GLint y,
- GLsizei width, GLint border )
-{
- GET_CURRENT_CONTEXT(ctx);
- copyteximage(ctx, 1, target, level, internalFormat, x, y, width, 1, border);
-}
-
-
-
-void GLAPIENTRY
-_mesa_CopyTexImage2D( GLenum target, GLint level, GLenum internalFormat,
- GLint x, GLint y, GLsizei width, GLsizei height,
- GLint border )
-{
- GET_CURRENT_CONTEXT(ctx);
- copyteximage(ctx, 2, target, level, internalFormat,
- x, y, width, height, border);
-}
-
-
-
-/**
- * Implementation for glCopyTexSubImage1/2/3D() functions.
- */
-static void
-copytexsubimage(struct gl_context *ctx, GLuint dims, GLenum target, GLint level,
- GLint xoffset, GLint yoffset, GLint zoffset,
- GLint x, GLint y, GLsizei width, GLsizei height)
-{
- struct gl_texture_object *texObj;
- struct gl_texture_image *texImage;
-
- ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
-
- if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE))
- _mesa_debug(ctx, "glCopyTexSubImage%uD %s %d %d %d %d %d %d %d %d\n",
- dims,
- _mesa_lookup_enum_by_nr(target),
- level, xoffset, yoffset, zoffset, x, y, width, height);
-
- if (ctx->NewState & NEW_COPY_TEX_STATE)
- _mesa_update_state(ctx);
-
- if (copytexsubimage_error_check1(ctx, dims, target, level))
- return;
-
- texObj = _mesa_get_current_tex_object(ctx, target);
-
- _mesa_lock_texture(ctx, texObj);
- {
- texImage = _mesa_select_tex_image(ctx, texObj, target, level);
-
- if (copytexsubimage_error_check2(ctx, dims, target, level, xoffset, yoffset,
- zoffset, width, height, texImage)) {
- /* error was recored */
- }
- else {
- /* If we have a border, offset=-1 is legal. Bias by border width. */
- switch (dims) {
- case 3:
- zoffset += texImage->Border;
- /* fall-through */
- case 2:
- yoffset += texImage->Border;
- /* fall-through */
- case 1:
- xoffset += texImage->Border;
- }
-
- if (_mesa_clip_copytexsubimage(ctx, &xoffset, &yoffset, &x, &y,
- &width, &height)) {
- switch (dims) {
- case 1:
- ctx->Driver.CopyTexSubImage1D(ctx, target, level,
- xoffset, x, y, width);
- break;
- case 2:
- ctx->Driver.CopyTexSubImage2D(ctx, target, level,
- xoffset, yoffset,
- x, y, width, height);
- break;
- case 3:
- ctx->Driver.CopyTexSubImage3D(ctx, target, level,
- xoffset, yoffset, zoffset,
- x, y, width, height);
- break;
- default:
- _mesa_problem(ctx, "bad dims in copytexsubimage()");
- }
-
- check_gen_mipmap(ctx, target, texObj, level);
-
- ctx->NewState |= _NEW_TEXTURE;
- }
- }
- }
- _mesa_unlock_texture(ctx, texObj);
-}
-
-
-void GLAPIENTRY
-_mesa_CopyTexSubImage1D( GLenum target, GLint level,
- GLint xoffset, GLint x, GLint y, GLsizei width )
-{
- GET_CURRENT_CONTEXT(ctx);
- copytexsubimage(ctx, 1, target, level, xoffset, 0, 0, x, y, width, 1);
-}
-
-
-
-void GLAPIENTRY
-_mesa_CopyTexSubImage2D( GLenum target, GLint level,
- GLint xoffset, GLint yoffset,
- GLint x, GLint y, GLsizei width, GLsizei height )
-{
- GET_CURRENT_CONTEXT(ctx);
- copytexsubimage(ctx, 2, target, level, xoffset, yoffset, 0, x, y,
- width, height);
-}
-
-
-
-void GLAPIENTRY
-_mesa_CopyTexSubImage3D( GLenum target, GLint level,
- GLint xoffset, GLint yoffset, GLint zoffset,
- GLint x, GLint y, GLsizei width, GLsizei height )
-{
- GET_CURRENT_CONTEXT(ctx);
- copytexsubimage(ctx, 3, target, level, xoffset, yoffset, zoffset,
- x, y, width, height);
-}
-
-
-
-
-/**********************************************************************/
-/****** Compressed Textures ******/
-/**********************************************************************/
-
-
-/**
- * Return expected size of a compressed texture.
- */
-static GLuint
-compressed_tex_size(GLsizei width, GLsizei height, GLsizei depth,
- GLenum glformat)
-{
- gl_format mesaFormat = _mesa_glenum_to_compressed_format(glformat);
- return _mesa_format_image_size(mesaFormat, width, height, depth);
-}
-
-
-/*
- * Return compressed texture block size, in pixels.
- */
-static void
-get_compressed_block_size(GLenum glformat, GLuint *bw, GLuint *bh)
-{
- gl_format mesaFormat = _mesa_glenum_to_compressed_format(glformat);
- _mesa_get_format_block_size(mesaFormat, bw, bh);
-}
-
-
-/**
- * Error checking for glCompressedTexImage[123]D().
- * \return error code or GL_NO_ERROR.
- */
-static GLenum
-compressed_texture_error_check(struct gl_context *ctx, GLint dimensions,
- GLenum target, GLint level,
- GLenum internalFormat, GLsizei width,
- GLsizei height, GLsizei depth, GLint border,
- GLsizei imageSize)
-{
- const GLenum proxyTarget = get_proxy_target(target);
- const GLint maxLevels = _mesa_max_texture_levels(ctx, target);
- GLint expectedSize;
-
- /* check level */
- if (level < 0 || level >= maxLevels)
- return GL_INVALID_VALUE;
-
- if (!target_can_be_compressed(ctx, target, internalFormat)) {
- return GL_INVALID_ENUM;
- }
-
- /* This will detect any invalid internalFormat value */
- if (!_mesa_is_compressed_format(ctx, internalFormat))
- return GL_INVALID_ENUM;
-
- /* This should really never fail */
- if (_mesa_base_tex_format(ctx, internalFormat) < 0)
- return GL_INVALID_ENUM;
-
- /* No compressed formats support borders at this time */
- if (border != 0)
- return GL_INVALID_VALUE;
-
- /* For cube map, width must equal height */
- if (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB &&
- target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB && width != height)
- return GL_INVALID_VALUE;
-
- /* check image size against compression block size */
- {
- gl_format texFormat =
- ctx->Driver.ChooseTextureFormat(ctx, internalFormat,
- GL_NONE, GL_NONE);
- GLuint bw, bh;
-
- _mesa_get_format_block_size(texFormat, &bw, &bh);
- if ((width > bw && width % bw > 0) ||
- (height > bh && height % bh > 0)) {
- /*
- * Per GL_ARB_texture_compression: GL_INVALID_OPERATION is
- * generated [...] if any parameter combinations are not
- * supported by the specific compressed internal format.
- */
- return GL_INVALID_OPERATION;
- }
- }
-
- /* check image sizes */
- if (!ctx->Driver.TestProxyTexImage(ctx, proxyTarget, level,
- internalFormat, GL_NONE, GL_NONE,
- width, height, depth, border)) {
- /* See error comment above */
- return GL_INVALID_OPERATION;
- }
-
- /* check image size in bytes */
- expectedSize = compressed_tex_size(width, height, depth, internalFormat);
- if (expectedSize != imageSize) {
- /* Per GL_ARB_texture_compression: GL_INVALID_VALUE is generated [...]
- * if <imageSize> is not consistent with the format, dimensions, and
- * contents of the specified image.
- */
- return GL_INVALID_VALUE;
- }
-
- return GL_NO_ERROR;
-}
-
-
-/**
- * Error checking for glCompressedTexSubImage[123]D().
- * \warning There are some bad assumptions here about the size of compressed
- * texture tiles (multiple of 4) used to test the validity of the
- * offset and size parameters.
- * \return error code or GL_NO_ERROR.
- */
-static GLenum
-compressed_subtexture_error_check(struct gl_context *ctx, GLint dimensions,
- GLenum target, GLint level,
- GLint xoffset, GLint yoffset, GLint zoffset,
- GLsizei width, GLsizei height, GLsizei depth,
- GLenum format, GLsizei imageSize)
-{
- GLint expectedSize, maxLevels = 0, maxTextureSize;
- GLuint bw, bh;
- (void) zoffset;
-
- if (dimensions == 1) {
- /* 1D compressed textures not allowed */
- return GL_INVALID_ENUM;
- }
- else if (dimensions == 2) {
- if (target == GL_PROXY_TEXTURE_2D) {
- maxLevels = ctx->Const.MaxTextureLevels;
- }
- else if (target == GL_TEXTURE_2D) {
- maxLevels = ctx->Const.MaxTextureLevels;
- }
- else if (target == GL_PROXY_TEXTURE_CUBE_MAP_ARB) {
- if (!ctx->Extensions.ARB_texture_cube_map)
- return GL_INVALID_ENUM; /*target*/
- maxLevels = ctx->Const.MaxCubeTextureLevels;
- }
- else if (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB &&
- target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB) {
- if (!ctx->Extensions.ARB_texture_cube_map)
- return GL_INVALID_ENUM; /*target*/
- maxLevels = ctx->Const.MaxCubeTextureLevels;
- }
- else {
- return GL_INVALID_ENUM; /*target*/
- }
- }
- else if (dimensions == 3) {
- /* 3D compressed textures not allowed */
- return GL_INVALID_ENUM;
- }
-
- maxTextureSize = 1 << (maxLevels - 1);
-
- /* this will catch any invalid compressed format token */
- if (!_mesa_is_compressed_format(ctx, format))
- return GL_INVALID_ENUM;
-
- if (width < 1 || width > maxTextureSize)
- return GL_INVALID_VALUE;
-
- if ((height < 1 || height > maxTextureSize)
- && dimensions > 1)
- return GL_INVALID_VALUE;
-
- if (level < 0 || level >= maxLevels)
- return GL_INVALID_VALUE;
-
- /*
- * do checks which depend on compression block size
- */
- get_compressed_block_size(format, &bw, &bh);
-
- if ((xoffset % bw != 0) || (yoffset % bh != 0))
- return GL_INVALID_VALUE;
-
- if ((width % bw != 0) && width != 2 && width != 1)
- return GL_INVALID_VALUE;
-
- if ((height % bh != 0) && height != 2 && height != 1)
- return GL_INVALID_VALUE;
-
- expectedSize = compressed_tex_size(width, height, depth, format);
- if (expectedSize != imageSize)
- return GL_INVALID_VALUE;
-
- return GL_NO_ERROR;
-}
-
-
-/**
- * Do second part of glCompressedTexSubImage error checking.
- * \return GL_TRUE if error found, GL_FALSE otherwise.
- */
-static GLboolean
-compressed_subtexture_error_check2(struct gl_context *ctx, GLuint dims,
- GLsizei width, GLsizei height,
- GLsizei depth, GLenum format,
- struct gl_texture_image *texImage)
-{
-
- if ((GLint) format != texImage->InternalFormat) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glCompressedTexSubImage%uD(format=0x%x)", dims, format);
- return GL_TRUE;
- }
-
- if (((width == 1 || width == 2) &&
- width != (GLsizei) texImage->Width) ||
- (width > (GLsizei) texImage->Width)) {
- _mesa_error(ctx, GL_INVALID_VALUE,
- "glCompressedTexSubImage%uD(width=%d)", dims, width);
- return GL_TRUE;
- }
-
- if (dims >= 2) {
- if (((height == 1 || height == 2) &&
- height != (GLsizei) texImage->Height) ||
- (height > (GLsizei) texImage->Height)) {
- _mesa_error(ctx, GL_INVALID_VALUE,
- "glCompressedTexSubImage%uD(height=%d)", dims, height);
- return GL_TRUE;
- }
- }
-
- if (dims >= 3) {
- if (((depth == 1 || depth == 2) &&
- depth != (GLsizei) texImage->Depth) ||
- (depth > (GLsizei) texImage->Depth)) {
- _mesa_error(ctx, GL_INVALID_VALUE,
- "glCompressedTexSubImage%uD(depth=%d)", dims, depth);
- return GL_TRUE;
- }
- }
-
- return GL_FALSE;
-}
-
-
-/**
- * Implementation of the glCompressedTexImage1/2/3D() functions.
- */
-static void
-compressedteximage(struct gl_context *ctx, GLuint dims,
- GLenum target, GLint level,
- GLenum internalFormat, GLsizei width,
- GLsizei height, GLsizei depth, GLint border,
- GLsizei imageSize, const GLvoid *data)
-{
- GLenum error;
-
- ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
-
- if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE))
- _mesa_debug(ctx,
- "glCompressedTexImage%uDARB %s %d %s %d %d %d %d %d %p\n",
- dims,
- _mesa_lookup_enum_by_nr(target), level,
- _mesa_lookup_enum_by_nr(internalFormat),
- width, height, depth, border, imageSize, data);
-
- /* check target */
- if (!legal_teximage_target(ctx, dims, target)) {
- _mesa_error(ctx, GL_INVALID_ENUM, "glCompressedTexImage%uD(target=%s)",
- dims, _mesa_lookup_enum_by_nr(target));
- return;
- }
-
- error = compressed_texture_error_check(ctx, dims, target, level,
- internalFormat, width, height, depth,
- border, imageSize);
-
-#if FEATURE_ES
- /* XXX this is kind of a hack */
- if (error) {
- _mesa_error(ctx, error, "glTexImage2D");
- return;
- }
-
- if (dims == 2) {
- switch (internalFormat) {
- case GL_PALETTE4_RGB8_OES:
- case GL_PALETTE4_RGBA8_OES:
- case GL_PALETTE4_R5_G6_B5_OES:
- case GL_PALETTE4_RGBA4_OES:
- case GL_PALETTE4_RGB5_A1_OES:
- case GL_PALETTE8_RGB8_OES:
- case GL_PALETTE8_RGBA8_OES:
- case GL_PALETTE8_R5_G6_B5_OES:
- case GL_PALETTE8_RGBA4_OES:
- case GL_PALETTE8_RGB5_A1_OES:
- _mesa_cpal_compressed_teximage2d(target, level, internalFormat,
- width, height, imageSize, data);
- return;
- }
- }
-#endif
-
- if (_mesa_is_proxy_texture(target)) {
- /* Proxy texture: just check for errors and update proxy state */
- struct gl_texture_image *texImage;
-
- if (!error) {
- struct gl_texture_object *texObj =
- _mesa_get_current_tex_object(ctx, target);
- gl_format texFormat =
- _mesa_choose_texture_format(ctx, texObj, target, level,
- internalFormat, GL_NONE, GL_NONE);
- if (!legal_texture_size(ctx, texFormat, width, height, depth)) {
- error = GL_OUT_OF_MEMORY;
- }
- }
-
- texImage = _mesa_get_proxy_tex_image(ctx, target, level);
- if (texImage) {
- if (error) {
- /* if error, clear all proxy texture image parameters */
- clear_teximage_fields(texImage);
- }
- else {
- /* no error: store the teximage parameters */
- _mesa_init_teximage_fields(ctx, target, texImage, width, height,
- depth, border, internalFormat,
- MESA_FORMAT_NONE);
- }
- }
- }
- else {
- /* non-proxy target */
- struct gl_texture_object *texObj;
- struct gl_texture_image *texImage;
-
- if (error) {
- _mesa_error(ctx, error, "glCompressedTexImage%uD", dims);
- return;
- }
-
- texObj = _mesa_get_current_tex_object(ctx, target);
-
- _mesa_lock_texture(ctx, texObj);
- {
- texImage = _mesa_get_tex_image(ctx, texObj, target, level);
- if (!texImage) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY,
- "glCompressedTexImage%uD", dims);
- }
- else {
- gl_format texFormat;
-
- if (texImage->Data) {
- ctx->Driver.FreeTexImageData( ctx, texImage );
- }
- ASSERT(texImage->Data == NULL);
-
- texFormat = _mesa_choose_texture_format(ctx, texObj, target, level,
- internalFormat, GL_NONE,
- GL_NONE);
-
- if (legal_texture_size(ctx, texFormat, width, height, depth)) {
- _mesa_init_teximage_fields(ctx, target, texImage,
- width, height, depth,
- border, internalFormat, texFormat);
-
- switch (dims) {
- case 1:
- ASSERT(ctx->Driver.CompressedTexImage1D);
- ctx->Driver.CompressedTexImage1D(ctx, target, level,
- internalFormat,
- width,
- border, imageSize, data,
- texObj, texImage);
- break;
- case 2:
- ASSERT(ctx->Driver.CompressedTexImage2D);
- ctx->Driver.CompressedTexImage2D(ctx, target, level,
- internalFormat,
- width, height,
- border, imageSize, data,
- texObj, texImage);
- break;
- case 3:
- ASSERT(ctx->Driver.CompressedTexImage3D);
- ctx->Driver.CompressedTexImage3D(ctx, target, level,
- internalFormat,
- width, height, depth,
- border, imageSize, data,
- texObj, texImage);
- break;
- default:
- _mesa_problem(ctx, "bad dims in compressedteximage");
- }
-
- check_gen_mipmap(ctx, target, texObj, level);
-
- /* state update */
- texObj->_Complete = GL_FALSE;
- ctx->NewState |= _NEW_TEXTURE;
- }
- else {
- _mesa_error(ctx, GL_OUT_OF_MEMORY,
- "glCompressedTexImage%uD", dims);
- }
- }
- }
- _mesa_unlock_texture(ctx, texObj);
- }
-}
-
-
-void GLAPIENTRY
-_mesa_CompressedTexImage1DARB(GLenum target, GLint level,
- GLenum internalFormat, GLsizei width,
- GLint border, GLsizei imageSize,
- const GLvoid *data)
-{
- GET_CURRENT_CONTEXT(ctx);
- compressedteximage(ctx, 1, target, level, internalFormat,
- width, 1, 1, border, imageSize, data);
-}
-
-
-void GLAPIENTRY
-_mesa_CompressedTexImage2DARB(GLenum target, GLint level,
- GLenum internalFormat, GLsizei width,
- GLsizei height, GLint border, GLsizei imageSize,
- const GLvoid *data)
-{
- GET_CURRENT_CONTEXT(ctx);
- compressedteximage(ctx, 2, target, level, internalFormat,
- width, height, 1, border, imageSize, data);
-}
-
-
-void GLAPIENTRY
-_mesa_CompressedTexImage3DARB(GLenum target, GLint level,
- GLenum internalFormat, GLsizei width,
- GLsizei height, GLsizei depth, GLint border,
- GLsizei imageSize, const GLvoid *data)
-{
- GET_CURRENT_CONTEXT(ctx);
- compressedteximage(ctx, 3, target, level, internalFormat,
- width, height, depth, border, imageSize, data);
-}
-
-
-/**
- * Common helper for glCompressedTexSubImage1/2/3D().
- */
-static void
-compressed_tex_sub_image(GLuint dims, GLenum target, GLint level,
- GLint xoffset, GLint yoffset, GLint zoffset,
- GLsizei width, GLsizei height, GLsizei depth,
- GLenum format, GLsizei imageSize, const GLvoid *data)
-{
- struct gl_texture_object *texObj;
- struct gl_texture_image *texImage;
- GLenum error;
- GET_CURRENT_CONTEXT(ctx);
- ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
-
- error = compressed_subtexture_error_check(ctx, dims, target, level,
- xoffset, 0, 0, /* pos */
- width, height, depth, /* size */
- format, imageSize);
- if (error) {
- _mesa_error(ctx, error, "glCompressedTexSubImage%uD", dims);
- return;
- }
-
- texObj = _mesa_get_current_tex_object(ctx, target);
-
- _mesa_lock_texture(ctx, texObj);
- {
- texImage = _mesa_select_tex_image(ctx, texObj, target, level);
- assert(texImage);
-
- if (compressed_subtexture_error_check2(ctx, dims, width, height, depth,
- format, texImage)) {
- /* error was recorded */
- }
- else if (width > 0 && height > 0 && depth > 0) {
- switch (dims) {
- case 1:
- if (ctx->Driver.CompressedTexSubImage1D) {
- ctx->Driver.CompressedTexSubImage1D(ctx, target, level,
- xoffset, width,
- format, imageSize, data,
- texObj, texImage);
- }
- break;
- case 2:
- if (ctx->Driver.CompressedTexSubImage2D) {
- ctx->Driver.CompressedTexSubImage2D(ctx, target, level,
- xoffset, yoffset,
- width, height,
- format, imageSize, data,
- texObj, texImage);
- }
- break;
- case 3:
- if (ctx->Driver.CompressedTexSubImage3D) {
- ctx->Driver.CompressedTexSubImage3D(ctx, target, level,
- xoffset, yoffset, zoffset,
- width, height, depth,
- format, imageSize, data,
- texObj, texImage);
- }
- break;
- default:
- ;
- }
-
- check_gen_mipmap(ctx, target, texObj, level);
-
- ctx->NewState |= _NEW_TEXTURE;
- }
- }
- _mesa_unlock_texture(ctx, texObj);
-}
-
-
-void GLAPIENTRY
-_mesa_CompressedTexSubImage1DARB(GLenum target, GLint level, GLint xoffset,
- GLsizei width, GLenum format,
- GLsizei imageSize, const GLvoid *data)
-{
- compressed_tex_sub_image(1, target, level, xoffset, 0, 0, width, 1, 1,
- format, imageSize, data);
-}
-
-
-void GLAPIENTRY
-_mesa_CompressedTexSubImage2DARB(GLenum target, GLint level, GLint xoffset,
- GLint yoffset, GLsizei width, GLsizei height,
- GLenum format, GLsizei imageSize,
- const GLvoid *data)
-{
- compressed_tex_sub_image(2, target, level, xoffset, yoffset, 0,
- width, height, 1, format, imageSize, data);
-}
-
-
-void GLAPIENTRY
-_mesa_CompressedTexSubImage3DARB(GLenum target, GLint level, GLint xoffset,
- GLint yoffset, GLint zoffset, GLsizei width,
- GLsizei height, GLsizei depth, GLenum format,
- GLsizei imageSize, const GLvoid *data)
-{
- compressed_tex_sub_image(3, target, level, xoffset, yoffset, zoffset,
- width, height, depth, format, imageSize, data);
-}
+/* + * mesa 3-D graphics library + * Version: 7.6 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * Copyright (C) 2009 VMware, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +/** + * \file teximage.c + * Texture image-related functions. + */ + + +#include "glheader.h" +#include "bufferobj.h" +#include "context.h" +#include "enums.h" +#include "fbobject.h" +#include "framebuffer.h" +#include "hash.h" +#include "image.h" +#include "imports.h" +#include "macros.h" +#include "mfeatures.h" +#include "state.h" +#include "texcompress.h" +#include "texfetch.h" +#include "teximage.h" +#include "texstate.h" +#include "texpal.h" +#include "mtypes.h" + + +/** + * State changes which we care about for glCopyTex[Sub]Image() calls. + * In particular, we care about pixel transfer state and buffer state + * (such as glReadBuffer to make sure we read from the right renderbuffer). + */ +#define NEW_COPY_TEX_STATE (_MESA_NEW_TRANSFER_STATE | \ + _NEW_BUFFERS | \ + _NEW_PIXEL) + + + +/** + * We allocate texture memory on 512-byte boundaries so we can use MMX/SSE + * elsewhere. + */ +void * +_mesa_alloc_texmemory(GLsizei bytes) +{ + return _mesa_align_malloc(bytes, 512); +} + + +/** + * Free texture memory allocated with _mesa_alloc_texmemory() + */ +void +_mesa_free_texmemory(void *m) +{ + _mesa_align_free(m); +} + + +/* + * Compute floor(log_base_2(n)). + * If n < 0 return -1. + */ +static int +logbase2( int n ) +{ + GLint i = 1; + GLint log2 = 0; + + if (n < 0) + return -1; + + if (n == 0) + return 0; + + while ( n > i ) { + i *= 2; + log2++; + } + if (i != n) { + return log2 - 1; + } + else { + return log2; + } +} + + + +/** + * Return the simple base format for a given internal texture format. + * For example, given GL_LUMINANCE12_ALPHA4, return GL_LUMINANCE_ALPHA. + * + * \param ctx GL context. + * \param internalFormat the internal texture format token or 1, 2, 3, or 4. + * + * \return the corresponding \u base internal format (GL_ALPHA, GL_LUMINANCE, + * GL_LUMANCE_ALPHA, GL_INTENSITY, GL_RGB, or GL_RGBA), or -1 if invalid enum. + * + * This is the format which is used during texture application (i.e. the + * texture format and env mode determine the arithmetic used. + * + * XXX this could be static + */ +GLint +_mesa_base_tex_format( struct gl_context *ctx, GLint internalFormat ) +{ + switch (internalFormat) { + case GL_ALPHA: + case GL_ALPHA4: + case GL_ALPHA8: + case GL_ALPHA12: + case GL_ALPHA16: + return GL_ALPHA; + case 1: + case GL_LUMINANCE: + case GL_LUMINANCE4: + case GL_LUMINANCE8: + case GL_LUMINANCE12: + case GL_LUMINANCE16: + return GL_LUMINANCE; + case 2: + case GL_LUMINANCE_ALPHA: + case GL_LUMINANCE4_ALPHA4: + case GL_LUMINANCE6_ALPHA2: + case GL_LUMINANCE8_ALPHA8: + case GL_LUMINANCE12_ALPHA4: + case GL_LUMINANCE12_ALPHA12: + case GL_LUMINANCE16_ALPHA16: + return GL_LUMINANCE_ALPHA; + case GL_INTENSITY: + case GL_INTENSITY4: + case GL_INTENSITY8: + case GL_INTENSITY12: + case GL_INTENSITY16: + return GL_INTENSITY; + case 3: + case GL_RGB: + case GL_R3_G3_B2: + case GL_RGB4: + case GL_RGB5: + case GL_RGB8: + case GL_RGB10: + case GL_RGB12: + case GL_RGB16: + return GL_RGB; + case 4: + case GL_RGBA: + case GL_RGBA2: + case GL_RGBA4: + case GL_RGB5_A1: + case GL_RGBA8: + case GL_RGB10_A2: + case GL_RGBA12: + case GL_RGBA16: + return GL_RGBA; + default: + ; /* fallthrough */ + } + + if (ctx->Extensions.EXT_texture_format_BGRA8888) { + switch (internalFormat) { + case GL_BGRA_EXT: + return GL_RGBA; + default: + ; /* fallthrough */ + } + } + + if (ctx->Extensions.EXT_paletted_texture) { + switch (internalFormat) { + case GL_COLOR_INDEX: + case GL_COLOR_INDEX1_EXT: + case GL_COLOR_INDEX2_EXT: + case GL_COLOR_INDEX4_EXT: + case GL_COLOR_INDEX8_EXT: + case GL_COLOR_INDEX12_EXT: + case GL_COLOR_INDEX16_EXT: + return GL_COLOR_INDEX; + default: + ; /* fallthrough */ + } + } + + if (ctx->Extensions.ARB_depth_texture) { + switch (internalFormat) { + case GL_DEPTH_COMPONENT: + case GL_DEPTH_COMPONENT16: + case GL_DEPTH_COMPONENT24: + case GL_DEPTH_COMPONENT32: + return GL_DEPTH_COMPONENT; + default: + ; /* fallthrough */ + } + } + + switch (internalFormat) { + case GL_COMPRESSED_ALPHA: + return GL_ALPHA; + case GL_COMPRESSED_LUMINANCE: + return GL_LUMINANCE; + case GL_COMPRESSED_LUMINANCE_ALPHA: + return GL_LUMINANCE_ALPHA; + case GL_COMPRESSED_INTENSITY: + return GL_INTENSITY; + case GL_COMPRESSED_RGB: + return GL_RGB; + case GL_COMPRESSED_RGBA: + return GL_RGBA; + default: + ; /* fallthrough */ + } + + if (ctx->Extensions.TDFX_texture_compression_FXT1) { + switch (internalFormat) { + case GL_COMPRESSED_RGB_FXT1_3DFX: + return GL_RGB; + case GL_COMPRESSED_RGBA_FXT1_3DFX: + return GL_RGBA; + default: + ; /* fallthrough */ + } + } + + if (ctx->Extensions.EXT_texture_compression_s3tc) { + switch (internalFormat) { + case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: + return GL_RGB; + case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: + case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: + case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: + return GL_RGBA; + default: + ; /* fallthrough */ + } + } + + if (ctx->Extensions.S3_s3tc) { + switch (internalFormat) { + case GL_RGB_S3TC: + case GL_RGB4_S3TC: + return GL_RGB; + case GL_RGBA_S3TC: + case GL_RGBA4_S3TC: + return GL_RGBA; + default: + ; /* fallthrough */ + } + } + + if (ctx->Extensions.MESA_ycbcr_texture) { + if (internalFormat == GL_YCBCR_MESA) + return GL_YCBCR_MESA; + } + + if (ctx->Extensions.ARB_texture_float) { + switch (internalFormat) { + case GL_ALPHA16F_ARB: + case GL_ALPHA32F_ARB: + return GL_ALPHA; + case GL_RGBA16F_ARB: + case GL_RGBA32F_ARB: + return GL_RGBA; + case GL_RGB16F_ARB: + case GL_RGB32F_ARB: + return GL_RGB; + case GL_INTENSITY16F_ARB: + case GL_INTENSITY32F_ARB: + return GL_INTENSITY; + case GL_LUMINANCE16F_ARB: + case GL_LUMINANCE32F_ARB: + return GL_LUMINANCE; + case GL_LUMINANCE_ALPHA16F_ARB: + case GL_LUMINANCE_ALPHA32F_ARB: + return GL_LUMINANCE_ALPHA; + default: + ; /* fallthrough */ + } + } + + if (ctx->Extensions.ATI_envmap_bumpmap) { + switch (internalFormat) { + case GL_DUDV_ATI: + case GL_DU8DV8_ATI: + return GL_DUDV_ATI; + default: + ; /* fallthrough */ + } + } + + if (ctx->Extensions.MESA_texture_signed_rgba) { + switch (internalFormat) { + case GL_RGBA_SNORM: + case GL_RGBA8_SNORM: + return GL_RGBA; + default: + ; /* fallthrough */ + } + } + + if (ctx->Extensions.EXT_packed_depth_stencil) { + switch (internalFormat) { + case GL_DEPTH_STENCIL_EXT: + case GL_DEPTH24_STENCIL8_EXT: + return GL_DEPTH_STENCIL_EXT; + default: + ; /* fallthrough */ + } + } + +#if FEATURE_EXT_texture_sRGB + if (ctx->Extensions.EXT_texture_sRGB) { + switch (internalFormat) { + case GL_SRGB_EXT: + case GL_SRGB8_EXT: + case GL_COMPRESSED_SRGB_EXT: + case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT: + return GL_RGB; + case GL_SRGB_ALPHA_EXT: + case GL_SRGB8_ALPHA8_EXT: + case GL_COMPRESSED_SRGB_ALPHA_EXT: + case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: + case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: + case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: + return GL_RGBA; + case GL_SLUMINANCE_ALPHA_EXT: + case GL_SLUMINANCE8_ALPHA8_EXT: + case GL_COMPRESSED_SLUMINANCE_ALPHA_EXT: + return GL_LUMINANCE_ALPHA; + case GL_SLUMINANCE_EXT: + case GL_SLUMINANCE8_EXT: + case GL_COMPRESSED_SLUMINANCE_EXT: + return GL_LUMINANCE; + default: + ; /* fallthrough */ + } + } +#endif /* FEATURE_EXT_texture_sRGB */ + + if (ctx->Extensions.EXT_texture_integer) { + switch (internalFormat) { + case GL_RGBA8UI_EXT: + case GL_RGBA16UI_EXT: + case GL_RGBA32UI_EXT: + case GL_RGBA8I_EXT: + case GL_RGBA16I_EXT: + case GL_RGBA32I_EXT: + return GL_RGBA; + case GL_RGB8UI_EXT: + case GL_RGB16UI_EXT: + case GL_RGB32UI_EXT: + case GL_RGB8I_EXT: + case GL_RGB16I_EXT: + case GL_RGB32I_EXT: + return GL_RGB; + case GL_ALPHA8UI_EXT: + case GL_ALPHA16UI_EXT: + case GL_ALPHA32UI_EXT: + case GL_ALPHA8I_EXT: + case GL_ALPHA16I_EXT: + case GL_ALPHA32I_EXT: + return GL_ALPHA; + case GL_INTENSITY8UI_EXT: + case GL_INTENSITY16UI_EXT: + case GL_INTENSITY32UI_EXT: + case GL_INTENSITY8I_EXT: + case GL_INTENSITY16I_EXT: + case GL_INTENSITY32I_EXT: + return GL_INTENSITY; + case GL_LUMINANCE8UI_EXT: + case GL_LUMINANCE16UI_EXT: + case GL_LUMINANCE32UI_EXT: + case GL_LUMINANCE8I_EXT: + case GL_LUMINANCE16I_EXT: + case GL_LUMINANCE32I_EXT: + return GL_LUMINANCE; + case GL_LUMINANCE_ALPHA8UI_EXT: + case GL_LUMINANCE_ALPHA16UI_EXT: + case GL_LUMINANCE_ALPHA32UI_EXT: + case GL_LUMINANCE_ALPHA8I_EXT: + case GL_LUMINANCE_ALPHA16I_EXT: + case GL_LUMINANCE_ALPHA32I_EXT: + return GL_LUMINANCE_ALPHA; + default: + ; /* fallthrough */ + } + } + + if (ctx->Extensions.ARB_texture_rg) { + switch (internalFormat) { + case GL_R16F: + /* R16F depends on both ARB_half_float_pixel and ARB_texture_float. + */ + if (!ctx->Extensions.ARB_half_float_pixel) + break; + /* FALLTHROUGH */ + case GL_R32F: + if (!ctx->Extensions.ARB_texture_float) + break; + return GL_RED; + case GL_R8I: + case GL_R8UI: + case GL_R16I: + case GL_R16UI: + case GL_R32I: + case GL_R32UI: + if (!ctx->Extensions.EXT_texture_integer) + break; + /* FALLTHROUGH */ + case GL_R8: + case GL_R16: + case GL_RED: + case GL_COMPRESSED_RED: + return GL_RED; + + case GL_RG16F: + /* RG16F depends on both ARB_half_float_pixel and ARB_texture_float. + */ + if (!ctx->Extensions.ARB_half_float_pixel) + break; + /* FALLTHROUGH */ + case GL_RG32F: + if (!ctx->Extensions.ARB_texture_float) + break; + return GL_RG; + case GL_RG8I: + case GL_RG8UI: + case GL_RG16I: + case GL_RG16UI: + case GL_RG32I: + case GL_RG32UI: + if (!ctx->Extensions.EXT_texture_integer) + break; + /* FALLTHROUGH */ + case GL_RG: + case GL_RG8: + case GL_RG16: + case GL_COMPRESSED_RG: + return GL_RG; + default: + ; /* fallthrough */ + } + } + + if (ctx->Extensions.EXT_texture_shared_exponent) { + switch (internalFormat) { + case GL_RGB9_E5_EXT: + return GL_RGB; + default: + ; /* fallthrough */ + } + } + + if (ctx->Extensions.EXT_packed_float) { + switch (internalFormat) { + case GL_R11F_G11F_B10F_EXT: + return GL_RGB; + default: + ; /* fallthrough */ + } + } + + if (ctx->Extensions.ARB_depth_buffer_float) { + switch (internalFormat) { + case GL_DEPTH_COMPONENT32F: + return GL_DEPTH_COMPONENT; + case GL_DEPTH32F_STENCIL8: + return GL_DEPTH_STENCIL; + default: + ; /* fallthrough */ + } + } + + if (ctx->Extensions.ARB_texture_compression_rgtc) { + switch (internalFormat) { + case GL_COMPRESSED_RED_RGTC1: + case GL_COMPRESSED_SIGNED_RED_RGTC1: + return GL_RED; + case GL_COMPRESSED_RG_RGTC2: + case GL_COMPRESSED_SIGNED_RG_RGTC2: + return GL_RG; + default: + ; /* fallthrough */ + } + } + + return -1; /* error */ +} + + +/** + * For cube map faces, return a face index in [0,5]. + * For other targets return 0; + */ +GLuint +_mesa_tex_target_to_face(GLenum target) +{ + if (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB && + target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB) + return (GLuint) target - (GLuint) GL_TEXTURE_CUBE_MAP_POSITIVE_X; + else + return 0; +} + + + +/** + * Store a gl_texture_image pointer in a gl_texture_object structure + * according to the target and level parameters. + * + * \param tObj texture object. + * \param target texture target. + * \param level image level. + * \param texImage texture image. + * + * This was basically prompted by the introduction of cube maps. + */ +void +_mesa_set_tex_image(struct gl_texture_object *tObj, + GLenum target, GLint level, + struct gl_texture_image *texImage) +{ + const GLuint face = _mesa_tex_target_to_face(target); + + ASSERT(tObj); + ASSERT(texImage); + ASSERT(target != GL_TEXTURE_RECTANGLE_NV || level == 0); + + tObj->Image[face][level] = texImage; + + /* Set the 'back' pointer */ + texImage->TexObject = tObj; +} + + +/** + * Allocate a texture image structure. + * + * Called via ctx->Driver.NewTextureImage() unless overriden by a device + * driver. + * + * \return a pointer to gl_texture_image struct with all fields initialized to + * zero. + */ +struct gl_texture_image * +_mesa_new_texture_image( struct gl_context *ctx ) +{ + (void) ctx; + return CALLOC_STRUCT(gl_texture_image); +} + + +/** + * Free texture image data. + * This function is a fallback called via ctx->Driver.FreeTexImageData(). + * + * \param texImage texture image. + * + * Free the texture image data if it's not marked as client data. + */ +void +_mesa_free_texture_image_data(struct gl_context *ctx, + struct gl_texture_image *texImage) +{ + (void) ctx; + + if (texImage->Data && !texImage->IsClientData) { + /* free the old texture data */ + _mesa_free_texmemory(texImage->Data); + } + + texImage->Data = NULL; +} + + +/** + * Free texture image. + * + * \param texImage texture image. + * + * Free the texture image structure and the associated image data. + */ +void +_mesa_delete_texture_image(struct gl_context *ctx, + struct gl_texture_image *texImage) +{ + /* Free texImage->Data and/or any other driver-specific texture + * image storage. + */ + ASSERT(ctx->Driver.FreeTexImageData); + ctx->Driver.FreeTexImageData( ctx, texImage ); + + ASSERT(texImage->Data == NULL); + if (texImage->ImageOffsets) + free(texImage->ImageOffsets); + free(texImage); +} + + +/** + * Test if a target is a proxy target. + * + * \param target texture target. + * + * \return GL_TRUE if the target is a proxy target, GL_FALSE otherwise. + */ +GLboolean +_mesa_is_proxy_texture(GLenum target) +{ + /* NUM_TEXTURE_TARGETS should match number of terms below */ + assert(NUM_TEXTURE_TARGETS == 7); + + return (target == GL_PROXY_TEXTURE_1D || + target == GL_PROXY_TEXTURE_2D || + target == GL_PROXY_TEXTURE_3D || + target == GL_PROXY_TEXTURE_CUBE_MAP_ARB || + target == GL_PROXY_TEXTURE_RECTANGLE_NV || + target == GL_PROXY_TEXTURE_1D_ARRAY_EXT || + target == GL_PROXY_TEXTURE_2D_ARRAY_EXT); +} + + +/** + * Return the proxy target which corresponds to the given texture target + */ +static GLenum +get_proxy_target(GLenum target) +{ + switch (target) { + case GL_TEXTURE_1D: + case GL_PROXY_TEXTURE_1D: + return GL_PROXY_TEXTURE_1D; + case GL_TEXTURE_2D: + case GL_PROXY_TEXTURE_2D: + return GL_PROXY_TEXTURE_2D; + case GL_TEXTURE_3D: + case GL_PROXY_TEXTURE_3D: + return GL_PROXY_TEXTURE_3D; + case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB: + case GL_TEXTURE_CUBE_MAP_ARB: + case GL_PROXY_TEXTURE_CUBE_MAP_ARB: + return GL_PROXY_TEXTURE_CUBE_MAP_ARB; + case GL_TEXTURE_RECTANGLE_NV: + case GL_PROXY_TEXTURE_RECTANGLE_NV: + return GL_PROXY_TEXTURE_RECTANGLE_NV; + case GL_TEXTURE_1D_ARRAY_EXT: + case GL_PROXY_TEXTURE_1D_ARRAY_EXT: + return GL_PROXY_TEXTURE_1D_ARRAY_EXT; + case GL_TEXTURE_2D_ARRAY_EXT: + case GL_PROXY_TEXTURE_2D_ARRAY_EXT: + return GL_PROXY_TEXTURE_2D_ARRAY_EXT; + default: + _mesa_problem(NULL, "unexpected target in get_proxy_target()"); + return 0; + } +} + + +/** + * Get the texture object that corresponds to the target of the given + * texture unit. + * + * \param ctx GL context. + * \param texUnit texture unit. + * \param target texture target. + * + * \return pointer to the texture object on success, or NULL on failure. + * + * \sa gl_texture_unit. + */ +struct gl_texture_object * +_mesa_select_tex_object(struct gl_context *ctx, + const struct gl_texture_unit *texUnit, + GLenum target) +{ + switch (target) { + case GL_TEXTURE_1D: + return texUnit->CurrentTex[TEXTURE_1D_INDEX]; + case GL_PROXY_TEXTURE_1D: + return ctx->Texture.ProxyTex[TEXTURE_1D_INDEX]; + case GL_TEXTURE_2D: + return texUnit->CurrentTex[TEXTURE_2D_INDEX]; + case GL_PROXY_TEXTURE_2D: + return ctx->Texture.ProxyTex[TEXTURE_2D_INDEX]; + case GL_TEXTURE_3D: + return texUnit->CurrentTex[TEXTURE_3D_INDEX]; + case GL_PROXY_TEXTURE_3D: + return ctx->Texture.ProxyTex[TEXTURE_3D_INDEX]; + case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB: + case GL_TEXTURE_CUBE_MAP_ARB: + return ctx->Extensions.ARB_texture_cube_map + ? texUnit->CurrentTex[TEXTURE_CUBE_INDEX] : NULL; + case GL_PROXY_TEXTURE_CUBE_MAP_ARB: + return ctx->Extensions.ARB_texture_cube_map + ? ctx->Texture.ProxyTex[TEXTURE_CUBE_INDEX] : NULL; + case GL_TEXTURE_RECTANGLE_NV: + return ctx->Extensions.NV_texture_rectangle + ? texUnit->CurrentTex[TEXTURE_RECT_INDEX] : NULL; + case GL_PROXY_TEXTURE_RECTANGLE_NV: + return ctx->Extensions.NV_texture_rectangle + ? ctx->Texture.ProxyTex[TEXTURE_RECT_INDEX] : NULL; + case GL_TEXTURE_1D_ARRAY_EXT: + return ctx->Extensions.MESA_texture_array + ? texUnit->CurrentTex[TEXTURE_1D_ARRAY_INDEX] : NULL; + case GL_PROXY_TEXTURE_1D_ARRAY_EXT: + return ctx->Extensions.MESA_texture_array + ? ctx->Texture.ProxyTex[TEXTURE_1D_ARRAY_INDEX] : NULL; + case GL_TEXTURE_2D_ARRAY_EXT: + return ctx->Extensions.MESA_texture_array + ? texUnit->CurrentTex[TEXTURE_2D_ARRAY_INDEX] : NULL; + case GL_PROXY_TEXTURE_2D_ARRAY_EXT: + return ctx->Extensions.MESA_texture_array + ? ctx->Texture.ProxyTex[TEXTURE_2D_ARRAY_INDEX] : NULL; + default: + _mesa_problem(NULL, "bad target in _mesa_select_tex_object()"); + return NULL; + } +} + + +/** + * Return pointer to texture object for given target on current texture unit. + */ +struct gl_texture_object * +_mesa_get_current_tex_object(struct gl_context *ctx, GLenum target) +{ + struct gl_texture_unit *texUnit = _mesa_get_current_tex_unit(ctx); + return _mesa_select_tex_object(ctx, texUnit, target); +} + + +/** + * Get a texture image pointer from a texture object, given a texture + * target and mipmap level. The target and level parameters should + * have already been error-checked. + * + * \param ctx GL context. + * \param texObj texture unit. + * \param target texture target. + * \param level image level. + * + * \return pointer to the texture image structure, or NULL on failure. + */ +struct gl_texture_image * +_mesa_select_tex_image(struct gl_context *ctx, + const struct gl_texture_object *texObj, + GLenum target, GLint level) +{ + const GLuint face = _mesa_tex_target_to_face(target); + + ASSERT(texObj); + ASSERT(level >= 0); + ASSERT(level < MAX_TEXTURE_LEVELS); + + return texObj->Image[face][level]; +} + + +/** + * Like _mesa_select_tex_image() but if the image doesn't exist, allocate + * it and install it. Only return NULL if passed a bad parameter or run + * out of memory. + */ +struct gl_texture_image * +_mesa_get_tex_image(struct gl_context *ctx, struct gl_texture_object *texObj, + GLenum target, GLint level) +{ + struct gl_texture_image *texImage; + + if (!texObj) + return NULL; + + texImage = _mesa_select_tex_image(ctx, texObj, target, level); + if (!texImage) { + texImage = ctx->Driver.NewTextureImage(ctx); + if (!texImage) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "texture image allocation"); + return NULL; + } + + _mesa_set_tex_image(texObj, target, level, texImage); + } + + return texImage; +} + + +/** + * Return pointer to the specified proxy texture image. + * Note that proxy textures are per-context, not per-texture unit. + * \return pointer to texture image or NULL if invalid target, invalid + * level, or out of memory. + */ +struct gl_texture_image * +_mesa_get_proxy_tex_image(struct gl_context *ctx, GLenum target, GLint level) +{ + struct gl_texture_image *texImage; + GLuint texIndex; + + if (level < 0 ) + return NULL; + + switch (target) { + case GL_PROXY_TEXTURE_1D: + if (level >= ctx->Const.MaxTextureLevels) + return NULL; + texIndex = TEXTURE_1D_INDEX; + break; + case GL_PROXY_TEXTURE_2D: + if (level >= ctx->Const.MaxTextureLevels) + return NULL; + texIndex = TEXTURE_2D_INDEX; + break; + case GL_PROXY_TEXTURE_3D: + if (level >= ctx->Const.Max3DTextureLevels) + return NULL; + texIndex = TEXTURE_3D_INDEX; + break; + case GL_PROXY_TEXTURE_CUBE_MAP: + if (level >= ctx->Const.MaxCubeTextureLevels) + return NULL; + texIndex = TEXTURE_CUBE_INDEX; + break; + case GL_PROXY_TEXTURE_RECTANGLE_NV: + if (level > 0) + return NULL; + texIndex = TEXTURE_RECT_INDEX; + break; + case GL_PROXY_TEXTURE_1D_ARRAY_EXT: + if (level >= ctx->Const.MaxTextureLevels) + return NULL; + texIndex = TEXTURE_1D_ARRAY_INDEX; + break; + case GL_PROXY_TEXTURE_2D_ARRAY_EXT: + if (level >= ctx->Const.MaxTextureLevels) + return NULL; + texIndex = TEXTURE_2D_ARRAY_INDEX; + break; + default: + return NULL; + } + + texImage = ctx->Texture.ProxyTex[texIndex]->Image[0][level]; + if (!texImage) { + texImage = ctx->Driver.NewTextureImage(ctx); + if (!texImage) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "proxy texture allocation"); + return NULL; + } + ctx->Texture.ProxyTex[texIndex]->Image[0][level] = texImage; + /* Set the 'back' pointer */ + texImage->TexObject = ctx->Texture.ProxyTex[texIndex]; + } + return texImage; +} + + +/** + * Get the maximum number of allowed mipmap levels. + * + * \param ctx GL context. + * \param target texture target. + * + * \return the maximum number of allowed mipmap levels for the given + * texture target, or zero if passed a bad target. + * + * \sa gl_constants. + */ +GLint +_mesa_max_texture_levels(struct gl_context *ctx, GLenum target) +{ + switch (target) { + case GL_TEXTURE_1D: + case GL_PROXY_TEXTURE_1D: + case GL_TEXTURE_2D: + case GL_PROXY_TEXTURE_2D: + return ctx->Const.MaxTextureLevels; + case GL_TEXTURE_3D: + case GL_PROXY_TEXTURE_3D: + return ctx->Const.Max3DTextureLevels; + case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB: + case GL_TEXTURE_CUBE_MAP_ARB: + case GL_PROXY_TEXTURE_CUBE_MAP_ARB: + return ctx->Extensions.ARB_texture_cube_map + ? ctx->Const.MaxCubeTextureLevels : 0; + case GL_TEXTURE_RECTANGLE_NV: + case GL_PROXY_TEXTURE_RECTANGLE_NV: + return ctx->Extensions.NV_texture_rectangle ? 1 : 0; + case GL_TEXTURE_1D_ARRAY_EXT: + case GL_PROXY_TEXTURE_1D_ARRAY_EXT: + case GL_TEXTURE_2D_ARRAY_EXT: + case GL_PROXY_TEXTURE_2D_ARRAY_EXT: + return ctx->Extensions.MESA_texture_array + ? ctx->Const.MaxTextureLevels : 0; + default: + return 0; /* bad target */ + } +} + + +/** + * Return number of dimensions per mipmap level for the given texture target. + */ +GLint +_mesa_get_texture_dimensions(GLenum target) +{ + switch (target) { + case GL_TEXTURE_1D: + case GL_PROXY_TEXTURE_1D: + return 1; + case GL_TEXTURE_2D: + case GL_TEXTURE_RECTANGLE: + case GL_TEXTURE_CUBE_MAP: + case GL_PROXY_TEXTURE_2D: + case GL_PROXY_TEXTURE_RECTANGLE: + case GL_PROXY_TEXTURE_CUBE_MAP: + case GL_TEXTURE_CUBE_MAP_POSITIVE_X: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: + case GL_TEXTURE_1D_ARRAY: + case GL_PROXY_TEXTURE_1D_ARRAY: + return 2; + case GL_TEXTURE_3D: + case GL_PROXY_TEXTURE_3D: + case GL_TEXTURE_2D_ARRAY: + case GL_PROXY_TEXTURE_2D_ARRAY: + return 3; + default: + _mesa_problem(NULL, "invalid target 0x%x in get_texture_dimensions()", + target); + return 2; + } +} + + + + +#if 000 /* not used anymore */ +/* + * glTexImage[123]D can accept a NULL image pointer. In this case we + * create a texture image with unspecified image contents per the OpenGL + * spec. + */ +static GLubyte * +make_null_texture(GLint width, GLint height, GLint depth, GLenum format) +{ + const GLint components = _mesa_components_in_format(format); + const GLint numPixels = width * height * depth; + GLubyte *data = (GLubyte *) MALLOC(numPixels * components * sizeof(GLubyte)); + +#ifdef DEBUG + /* + * Let's see if anyone finds this. If glTexImage2D() is called with + * a NULL image pointer then load the texture image with something + * interesting instead of leaving it indeterminate. + */ + if (data) { + static const char message[8][32] = { + " X X XXXXX XXX X ", + " XX XX X X X X X ", + " X X X X X X X ", + " X X XXXX XXX XXXXX ", + " X X X X X X ", + " X X X X X X X ", + " X X XXXXX XXX X X ", + " " + }; + + GLubyte *imgPtr = data; + GLint h, i, j, k; + for (h = 0; h < depth; h++) { + for (i = 0; i < height; i++) { + GLint srcRow = 7 - (i % 8); + for (j = 0; j < width; j++) { + GLint srcCol = j % 32; + GLubyte texel = (message[srcRow][srcCol]=='X') ? 255 : 70; + for (k = 0; k < components; k++) { + *imgPtr++ = texel; + } + } + } + } + } +#endif + + return data; +} +#endif + + + +/** + * Reset the fields of a gl_texture_image struct to zero. + * + * \param img texture image structure. + * + * This is called when a proxy texture test fails, we set all the + * image members (except DriverData) to zero. + * It's also used in glTexImage[123]D as a safeguard to be sure all + * required fields get initialized properly by the Driver.TexImage[123]D + * functions. + */ +static void +clear_teximage_fields(struct gl_texture_image *img) +{ + ASSERT(img); + img->_BaseFormat = 0; + img->InternalFormat = 0; + img->Border = 0; + img->Width = 0; + img->Height = 0; + img->Depth = 0; + img->RowStride = 0; + if (img->ImageOffsets) { + free(img->ImageOffsets); + img->ImageOffsets = NULL; + } + img->Width2 = 0; + img->Height2 = 0; + img->Depth2 = 0; + img->WidthLog2 = 0; + img->HeightLog2 = 0; + img->DepthLog2 = 0; + img->Data = NULL; + img->TexFormat = MESA_FORMAT_NONE; + img->FetchTexelc = NULL; + img->FetchTexelf = NULL; +} + + +/** + * Initialize basic fields of the gl_texture_image struct. + * + * \param ctx GL context. + * \param target texture target (GL_TEXTURE_1D, GL_TEXTURE_RECTANGLE, etc). + * \param img texture image structure to be initialized. + * \param width image width. + * \param height image height. + * \param depth image depth. + * \param border image border. + * \param internalFormat internal format. + * \param format the actual hardware format (one of MESA_FORMAT_*) + * + * Fills in the fields of \p img with the given information. + * Note: width, height and depth include the border. + */ +void +_mesa_init_teximage_fields(struct gl_context *ctx, GLenum target, + struct gl_texture_image *img, + GLsizei width, GLsizei height, GLsizei depth, + GLint border, GLenum internalFormat, + gl_format format) +{ + GLint i, dims; + + ASSERT(img); + ASSERT(width >= 0); + ASSERT(height >= 0); + ASSERT(depth >= 0); + + img->_BaseFormat = _mesa_base_tex_format( ctx, internalFormat ); + ASSERT(img->_BaseFormat > 0); + img->InternalFormat = internalFormat; + img->Border = border; + img->Width = width; + img->Height = height; + img->Depth = depth; + + img->Width2 = width - 2 * border; /* == 1 << img->WidthLog2; */ + img->WidthLog2 = logbase2(img->Width2); + + if (height == 1) { /* 1-D texture */ + img->Height2 = 1; + img->HeightLog2 = 0; + } + else { + img->Height2 = height - 2 * border; /* == 1 << img->HeightLog2; */ + img->HeightLog2 = logbase2(img->Height2); + } + + if (depth == 1) { /* 2-D texture */ + img->Depth2 = 1; + img->DepthLog2 = 0; + } + else { + img->Depth2 = depth - 2 * border; /* == 1 << img->DepthLog2; */ + img->DepthLog2 = logbase2(img->Depth2); + } + + img->MaxLog2 = MAX2(img->WidthLog2, img->HeightLog2); + + if ((width == 1 || _mesa_is_pow_two(img->Width2)) && + (height == 1 || _mesa_is_pow_two(img->Height2)) && + (depth == 1 || _mesa_is_pow_two(img->Depth2))) + img->_IsPowerOfTwo = GL_TRUE; + else + img->_IsPowerOfTwo = GL_FALSE; + + /* RowStride and ImageOffsets[] describe how to address texels in 'Data' */ + img->RowStride = width; + /* Allocate the ImageOffsets array and initialize to typical values. + * We allocate the array for 1D/2D textures too in order to avoid special- + * case code in the texstore routines. + */ + if (img->ImageOffsets) + free(img->ImageOffsets); + img->ImageOffsets = (GLuint *) malloc(depth * sizeof(GLuint)); + for (i = 0; i < depth; i++) { + img->ImageOffsets[i] = i * width * height; + } + + /* Compute Width/Height/DepthScale for mipmap lod computation */ + if (target == GL_TEXTURE_RECTANGLE_NV) { + /* scale = 1.0 since texture coords directly map to texels */ + img->WidthScale = 1.0; + img->HeightScale = 1.0; + img->DepthScale = 1.0; + } + else { + img->WidthScale = (GLfloat) img->Width; + img->HeightScale = (GLfloat) img->Height; + img->DepthScale = (GLfloat) img->Depth; + } + + img->TexFormat = format; + + dims = _mesa_get_texture_dimensions(target); + + _mesa_set_fetch_functions(img, dims); +} + + +/** + * Free and clear fields of the gl_texture_image struct. + * + * \param ctx GL context. + * \param texImage texture image structure to be cleared. + * + * After the call, \p texImage will have no data associated with it. Its + * fields are cleared so that its parent object will test incomplete. + */ +void +_mesa_clear_texture_image(struct gl_context *ctx, + struct gl_texture_image *texImage) +{ + ctx->Driver.FreeTexImageData(ctx, texImage); + clear_teximage_fields(texImage); +} + + +/** + * This is the fallback for Driver.TestProxyTexImage(). Test the texture + * level, width, height and depth against the ctx->Const limits for textures. + * + * A hardware driver might override this function if, for example, the + * max 3D texture size is 512x512x64 (i.e. not a cube). + * + * Note that width, height, depth == 0 is not an error. However, a + * texture with zero width/height/depth will be considered "incomplete" + * and texturing will effectively be disabled. + * + * \param target one of GL_PROXY_TEXTURE_1D, GL_PROXY_TEXTURE_2D, + * GL_PROXY_TEXTURE_3D, GL_PROXY_TEXTURE_RECTANGLE_NV, + * GL_PROXY_TEXTURE_CUBE_MAP_ARB. + * \param level as passed to glTexImage + * \param internalFormat as passed to glTexImage + * \param format as passed to glTexImage + * \param type as passed to glTexImage + * \param width as passed to glTexImage + * \param height as passed to glTexImage + * \param depth as passed to glTexImage + * \param border as passed to glTexImage + * \return GL_TRUE if the image is acceptable, GL_FALSE if not acceptable. + */ +GLboolean +_mesa_test_proxy_teximage(struct gl_context *ctx, GLenum target, GLint level, + GLint internalFormat, GLenum format, GLenum type, + GLint width, GLint height, GLint depth, GLint border) +{ + GLint maxSize; + + (void) internalFormat; + (void) format; + (void) type; + + switch (target) { + case GL_PROXY_TEXTURE_1D: + maxSize = 1 << (ctx->Const.MaxTextureLevels - 1); + if (width < 2 * border || width > 2 + maxSize) + return GL_FALSE; + if (level >= ctx->Const.MaxTextureLevels) + return GL_FALSE; + if (!ctx->Extensions.ARB_texture_non_power_of_two) { + if (width > 0 && !_mesa_is_pow_two(width - 2 * border)) + return GL_FALSE; + } + return GL_TRUE; + + case GL_PROXY_TEXTURE_2D: + maxSize = 1 << (ctx->Const.MaxTextureLevels - 1); + if (width < 2 * border || width > 2 + maxSize) + return GL_FALSE; + if (height < 2 * border || height > 2 + maxSize) + return GL_FALSE; + if (level >= ctx->Const.MaxTextureLevels) + return GL_FALSE; + if (!ctx->Extensions.ARB_texture_non_power_of_two) { + if (width > 0 && !_mesa_is_pow_two(width - 2 * border)) + return GL_FALSE; + if (height > 0 && !_mesa_is_pow_two(height - 2 * border)) + return GL_FALSE; + } + return GL_TRUE; + + case GL_PROXY_TEXTURE_3D: + maxSize = 1 << (ctx->Const.Max3DTextureLevels - 1); + if (width < 2 * border || width > 2 + maxSize) + return GL_FALSE; + if (height < 2 * border || height > 2 + maxSize) + return GL_FALSE; + if (depth < 2 * border || depth > 2 + maxSize) + return GL_FALSE; + if (level >= ctx->Const.Max3DTextureLevels) + return GL_FALSE; + if (!ctx->Extensions.ARB_texture_non_power_of_two) { + if (width > 0 && !_mesa_is_pow_two(width - 2 * border)) + return GL_FALSE; + if (height > 0 && !_mesa_is_pow_two(height - 2 * border)) + return GL_FALSE; + if (depth > 0 && !_mesa_is_pow_two(depth - 2 * border)) + return GL_FALSE; + } + return GL_TRUE; + + case GL_PROXY_TEXTURE_RECTANGLE_NV: + maxSize = ctx->Const.MaxTextureRectSize; + if (width < 0 || width > maxSize) + return GL_FALSE; + if (height < 0 || height > maxSize) + return GL_FALSE; + if (level != 0) + return GL_FALSE; + return GL_TRUE; + + case GL_PROXY_TEXTURE_CUBE_MAP_ARB: + maxSize = 1 << (ctx->Const.MaxCubeTextureLevels - 1); + if (width < 2 * border || width > 2 + maxSize) + return GL_FALSE; + if (height < 2 * border || height > 2 + maxSize) + return GL_FALSE; + if (level >= ctx->Const.MaxCubeTextureLevels) + return GL_FALSE; + if (!ctx->Extensions.ARB_texture_non_power_of_two) { + if (width > 0 && !_mesa_is_pow_two(width - 2 * border)) + return GL_FALSE; + if (height > 0 && !_mesa_is_pow_two(height - 2 * border)) + return GL_FALSE; + } + return GL_TRUE; + + case GL_PROXY_TEXTURE_1D_ARRAY_EXT: + maxSize = 1 << (ctx->Const.MaxTextureLevels - 1); + if (width < 2 * border || width > 2 + maxSize) + return GL_FALSE; + if (height < 1 || height > ctx->Const.MaxArrayTextureLayers) + return GL_FALSE; + if (level >= ctx->Const.MaxTextureLevels) + return GL_FALSE; + if (!ctx->Extensions.ARB_texture_non_power_of_two) { + if (width > 0 && !_mesa_is_pow_two(width - 2 * border)) + return GL_FALSE; + } + return GL_TRUE; + + case GL_PROXY_TEXTURE_2D_ARRAY_EXT: + maxSize = 1 << (ctx->Const.MaxTextureLevels - 1); + if (width < 2 * border || width > 2 + maxSize) + return GL_FALSE; + if (height < 2 * border || height > 2 + maxSize) + return GL_FALSE; + if (depth < 1 || depth > ctx->Const.MaxArrayTextureLayers) + return GL_FALSE; + if (level >= ctx->Const.MaxTextureLevels) + return GL_FALSE; + if (!ctx->Extensions.ARB_texture_non_power_of_two) { + if (width > 0 && !_mesa_is_pow_two(width - 2 * border)) + return GL_FALSE; + if (height > 0 && !_mesa_is_pow_two(height - 2 * border)) + return GL_FALSE; + } + return GL_TRUE; + + default: + _mesa_problem(ctx, "Invalid target in _mesa_test_proxy_teximage"); + return GL_FALSE; + } +} + + +/** + * Check if the memory used by the texture would exceed the driver's limit. + * This lets us support a max 3D texture size of 8K (for example) but + * prevents allocating a full 8K x 8K x 8K texture. + * XXX this could be rolled into the proxy texture size test (above) but + * we don't have the actual texture internal format at that point. + */ +static GLboolean +legal_texture_size(struct gl_context *ctx, gl_format format, + GLint width, GLint height, GLint depth) +{ + uint64_t bytes = _mesa_format_image_size64(format, width, height, depth); + uint64_t mbytes = bytes / (1024 * 1024); /* convert to MB */ + return mbytes <= (uint64_t) ctx->Const.MaxTextureMbytes; +} + + + +/** + * Helper function to determine whether a target and specific compression + * format are supported. + */ +static GLboolean +target_can_be_compressed(const struct gl_context *ctx, GLenum target, + GLenum intFormat) +{ + (void) intFormat; /* not used yet */ + + switch (target) { + case GL_TEXTURE_2D: + case GL_PROXY_TEXTURE_2D: + return GL_TRUE; /* true for any compressed format so far */ + case GL_PROXY_TEXTURE_CUBE_MAP: + case GL_TEXTURE_CUBE_MAP_POSITIVE_X: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: + return ctx->Extensions.ARB_texture_cube_map; + case GL_PROXY_TEXTURE_2D_ARRAY_EXT: + case GL_TEXTURE_2D_ARRAY_EXT: + return ctx->Extensions.MESA_texture_array; + default: + return GL_FALSE; + } +} + + +/** + * Check if the given texture target value is legal for a + * glTexImage1/2/3D call. + */ +static GLboolean +legal_teximage_target(struct gl_context *ctx, GLuint dims, GLenum target) +{ + switch (dims) { + case 1: + switch (target) { + case GL_TEXTURE_1D: + case GL_PROXY_TEXTURE_1D: + return GL_TRUE; + default: + return GL_FALSE; + } + case 2: + switch (target) { + case GL_TEXTURE_2D: + case GL_PROXY_TEXTURE_2D: + return GL_TRUE; + case GL_PROXY_TEXTURE_CUBE_MAP: + case GL_TEXTURE_CUBE_MAP_POSITIVE_X: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: + return ctx->Extensions.ARB_texture_cube_map; + case GL_TEXTURE_RECTANGLE_NV: + case GL_PROXY_TEXTURE_RECTANGLE_NV: + return ctx->Extensions.NV_texture_rectangle; + case GL_TEXTURE_1D_ARRAY_EXT: + case GL_PROXY_TEXTURE_1D_ARRAY_EXT: + return ctx->Extensions.MESA_texture_array; + default: + return GL_FALSE; + } + case 3: + switch (target) { + case GL_TEXTURE_3D: + case GL_PROXY_TEXTURE_3D: + return GL_TRUE; + case GL_TEXTURE_2D_ARRAY_EXT: + case GL_PROXY_TEXTURE_2D_ARRAY_EXT: + return ctx->Extensions.MESA_texture_array; + default: + return GL_FALSE; + } + default: + _mesa_problem(ctx, "invalid dims=%u in legal_teximage_target()", dims); + return GL_FALSE; + } +} + + +/** + * Check if the given texture target value is legal for a + * glTexSubImage, glCopyTexSubImage or glCopyTexImage call. + * The difference compared to legal_teximage_target() above is that + * proxy targets are not supported. + */ +static GLboolean +legal_texsubimage_target(struct gl_context *ctx, GLuint dims, GLenum target) +{ + switch (dims) { + case 1: + return target == GL_TEXTURE_1D; + case 2: + switch (target) { + case GL_TEXTURE_2D: + return GL_TRUE; + case GL_TEXTURE_CUBE_MAP_POSITIVE_X: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: + return ctx->Extensions.ARB_texture_cube_map; + case GL_TEXTURE_RECTANGLE_NV: + return ctx->Extensions.NV_texture_rectangle; + case GL_TEXTURE_1D_ARRAY_EXT: + return ctx->Extensions.MESA_texture_array; + default: + return GL_FALSE; + } + case 3: + switch (target) { + case GL_TEXTURE_3D: + return GL_TRUE; + case GL_TEXTURE_2D_ARRAY_EXT: + return ctx->Extensions.MESA_texture_array; + default: + return GL_FALSE; + } + default: + _mesa_problem(ctx, "invalid dims=%u in legal_texsubimage_target()", + dims); + return GL_FALSE; + } +} + + +/** + * Test the glTexImage[123]D() parameters for errors. + * + * \param ctx GL context. + * \param dimensions texture image dimensions (must be 1, 2 or 3). + * \param target texture target given by the user. + * \param level image level given by the user. + * \param internalFormat internal format given by the user. + * \param format pixel data format given by the user. + * \param type pixel data type given by the user. + * \param width image width given by the user. + * \param height image height given by the user. + * \param depth image depth given by the user. + * \param border image border given by the user. + * + * \return GL_TRUE if an error was detected, or GL_FALSE if no errors. + * + * Verifies each of the parameters against the constants specified in + * __struct gl_contextRec::Const and the supported extensions, and according + * to the OpenGL specification. + */ +static GLboolean +texture_error_check( struct gl_context *ctx, + GLuint dimensions, GLenum target, + GLint level, GLint internalFormat, + GLenum format, GLenum type, + GLint width, GLint height, + GLint depth, GLint border ) +{ + const GLenum proxyTarget = get_proxy_target(target); + const GLboolean isProxy = target == proxyTarget; + GLboolean sizeOK = GL_TRUE; + GLboolean colorFormat, indexFormat; + + /* Basic level check (more checking in ctx->Driver.TestProxyTexImage) */ + if (level < 0 || level >= MAX_TEXTURE_LEVELS) { + if (!isProxy) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glTexImage%dD(level=%d)", dimensions, level); + } + return GL_TRUE; + } + + /* Check border */ + if (border < 0 || border > 1 || + ((target == GL_TEXTURE_RECTANGLE_NV || + target == GL_PROXY_TEXTURE_RECTANGLE_NV) && border != 0)) { + if (!isProxy) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glTexImage%dD(border=%d)", dimensions, border); + } + return GL_TRUE; + } + + if (width < 0 || height < 0 || depth < 0) { + if (!isProxy) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glTexImage%dD(width, height or depth < 0)", dimensions); + } + return GL_TRUE; + } + + /* Do this simple check before calling the TestProxyTexImage() function */ + if (proxyTarget == GL_PROXY_TEXTURE_CUBE_MAP_ARB) { + sizeOK = (width == height); + } + + /* + * Use the proxy texture driver hook to see if the size/level/etc are + * legal. + */ + sizeOK = sizeOK && ctx->Driver.TestProxyTexImage(ctx, proxyTarget, level, + internalFormat, format, + type, width, height, + depth, border); + if (!sizeOK) { + if (!isProxy) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glTexImage%dD(level=%d, width=%d, height=%d, depth=%d)", + dimensions, level, width, height, depth); + } + return GL_TRUE; + } + + /* Check internalFormat */ + if (_mesa_base_tex_format(ctx, internalFormat) < 0) { + if (!isProxy) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glTexImage%dD(internalFormat=%s)", + dimensions, _mesa_lookup_enum_by_nr(internalFormat)); + } + return GL_TRUE; + } + + /* Check incoming image format and type */ + if (!_mesa_is_legal_format_and_type(ctx, format, type)) { + /* Normally, GL_INVALID_OPERATION is generated by a format/type + * mismatch (see the 1.2 spec page 94, sec 3.6.4.). But with the + * GL_EXT_texture_integer extension, some combinations should generate + * GL_INVALID_ENUM instead (grr!). + */ + if (!isProxy) { + GLenum error = _mesa_is_integer_format(format) + ? GL_INVALID_ENUM : GL_INVALID_OPERATION; + _mesa_error(ctx, error, + "glTexImage%dD(incompatible format 0x%x, type 0x%x)", + dimensions, format, type); + } + return GL_TRUE; + } + + /* make sure internal format and format basically agree */ + colorFormat = _mesa_is_color_format(format); + indexFormat = _mesa_is_index_format(format); + if ((_mesa_is_color_format(internalFormat) && !colorFormat && !indexFormat) || + (_mesa_is_index_format(internalFormat) && !indexFormat) || + (_mesa_is_depth_format(internalFormat) != _mesa_is_depth_format(format)) || + (_mesa_is_ycbcr_format(internalFormat) != _mesa_is_ycbcr_format(format)) || + (_mesa_is_depthstencil_format(internalFormat) != _mesa_is_depthstencil_format(format)) || + (_mesa_is_dudv_format(internalFormat) != _mesa_is_dudv_format(format))) { + if (!isProxy) + _mesa_error(ctx, GL_INVALID_OPERATION, + "glTexImage%dD(incompatible internalFormat 0x%x, format 0x%x)", + dimensions, internalFormat, format); + return GL_TRUE; + } + + /* additional checks for ycbcr textures */ + if (internalFormat == GL_YCBCR_MESA) { + ASSERT(ctx->Extensions.MESA_ycbcr_texture); + if (type != GL_UNSIGNED_SHORT_8_8_MESA && + type != GL_UNSIGNED_SHORT_8_8_REV_MESA) { + char message[100]; + _mesa_snprintf(message, sizeof(message), + "glTexImage%dD(format/type YCBCR mismatch", dimensions); + _mesa_error(ctx, GL_INVALID_ENUM, "%s", message); + return GL_TRUE; /* error */ + } + if (target != GL_TEXTURE_2D && + target != GL_PROXY_TEXTURE_2D && + target != GL_TEXTURE_RECTANGLE_NV && + target != GL_PROXY_TEXTURE_RECTANGLE_NV) { + if (!isProxy) + _mesa_error(ctx, GL_INVALID_ENUM, "glTexImage(target)"); + return GL_TRUE; + } + if (border != 0) { + if (!isProxy) { + char message[100]; + _mesa_snprintf(message, sizeof(message), + "glTexImage%dD(format=GL_YCBCR_MESA and border=%d)", + dimensions, border); + _mesa_error(ctx, GL_INVALID_VALUE, "%s", message); + } + return GL_TRUE; + } + } + + /* additional checks for depth textures */ + if (_mesa_base_tex_format(ctx, internalFormat) == GL_DEPTH_COMPONENT) { + /* Only 1D, 2D and rectangular textures supported, not 3D or cubes */ + if (target != GL_TEXTURE_1D && + target != GL_PROXY_TEXTURE_1D && + target != GL_TEXTURE_2D && + target != GL_PROXY_TEXTURE_2D && + target != GL_TEXTURE_RECTANGLE_ARB && + target != GL_PROXY_TEXTURE_RECTANGLE_ARB) { + if (!isProxy) + _mesa_error(ctx, GL_INVALID_ENUM, + "glTexImage(target/internalFormat)"); + return GL_TRUE; + } + } + + /* additional checks for compressed textures */ + if (_mesa_is_compressed_format(ctx, internalFormat)) { + if (!target_can_be_compressed(ctx, target, internalFormat)) { + if (!isProxy) + _mesa_error(ctx, GL_INVALID_ENUM, + "glTexImage%dD(target)", dimensions); + return GL_TRUE; + } + if (border != 0) { + if (!isProxy) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glTexImage%dD(border!=0)", dimensions); + } + return GL_TRUE; + } + } + + /* additional checks for integer textures */ + if (ctx->Extensions.EXT_texture_integer && + (_mesa_is_integer_format(format) != + _mesa_is_integer_format(internalFormat))) { + if (!isProxy) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glTexImage%dD(integer/non-integer format mismatch)", + dimensions); + } + return GL_TRUE; + } + + /* if we get here, the parameters are OK */ + return GL_FALSE; +} + + +/** + * Test glTexSubImage[123]D() parameters for errors. + * + * \param ctx GL context. + * \param dimensions texture image dimensions (must be 1, 2 or 3). + * \param target texture target given by the user. + * \param level image level given by the user. + * \param xoffset sub-image x offset given by the user. + * \param yoffset sub-image y offset given by the user. + * \param zoffset sub-image z offset given by the user. + * \param format pixel data format given by the user. + * \param type pixel data type given by the user. + * \param width image width given by the user. + * \param height image height given by the user. + * \param depth image depth given by the user. + * + * \return GL_TRUE if an error was detected, or GL_FALSE if no errors. + * + * Verifies each of the parameters against the constants specified in + * __struct gl_contextRec::Const and the supported extensions, and according + * to the OpenGL specification. + */ +static GLboolean +subtexture_error_check( struct gl_context *ctx, GLuint dimensions, + GLenum target, GLint level, + GLint xoffset, GLint yoffset, GLint zoffset, + GLint width, GLint height, GLint depth, + GLenum format, GLenum type ) +{ + /* Basic level check */ + if (level < 0 || level >= MAX_TEXTURE_LEVELS) { + _mesa_error(ctx, GL_INVALID_ENUM, "glTexSubImage2D(level=%d)", level); + return GL_TRUE; + } + + /* Check for negative sizes */ + if (width < 0) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glTexSubImage%dD(width=%d)", dimensions, width); + return GL_TRUE; + } + if (height < 0 && dimensions > 1) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glTexSubImage%dD(height=%d)", dimensions, height); + return GL_TRUE; + } + if (depth < 0 && dimensions > 2) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glTexSubImage%dD(depth=%d)", dimensions, depth); + return GL_TRUE; + } + + if (!_mesa_is_legal_format_and_type(ctx, format, type)) { + /* As with the glTexImage2D check above, the error code here + * depends on texture integer. + */ + GLenum error = _mesa_is_integer_format(format) + ? GL_INVALID_OPERATION : GL_INVALID_ENUM; + _mesa_error(ctx, error, + "glTexSubImage%dD(incompatible format 0x%x, type 0x%x)", + dimensions, format, type); + return GL_TRUE; + } + + return GL_FALSE; +} + + +/** + * Do second part of glTexSubImage which depends on the destination texture. + * \return GL_TRUE if error recorded, GL_FALSE otherwise + */ +static GLboolean +subtexture_error_check2( struct gl_context *ctx, GLuint dimensions, + GLenum target, GLint level, + GLint xoffset, GLint yoffset, GLint zoffset, + GLint width, GLint height, GLint depth, + GLenum format, GLenum type, + const struct gl_texture_image *destTex ) +{ + if (!destTex) { + /* undefined image level */ + _mesa_error(ctx, GL_INVALID_OPERATION, "glTexSubImage%dD", dimensions); + return GL_TRUE; + } + + if (xoffset < -((GLint)destTex->Border)) { + _mesa_error(ctx, GL_INVALID_VALUE, "glTexSubImage%dD(xoffset)", + dimensions); + return GL_TRUE; + } + if (xoffset + width > (GLint) (destTex->Width + destTex->Border)) { + _mesa_error(ctx, GL_INVALID_VALUE, "glTexSubImage%dD(xoffset+width)", + dimensions); + return GL_TRUE; + } + if (dimensions > 1) { + if (yoffset < -((GLint)destTex->Border)) { + _mesa_error(ctx, GL_INVALID_VALUE, "glTexSubImage%dD(yoffset)", + dimensions); + return GL_TRUE; + } + if (yoffset + height > (GLint) (destTex->Height + destTex->Border)) { + _mesa_error(ctx, GL_INVALID_VALUE, "glTexSubImage%dD(yoffset+height)", + dimensions); + return GL_TRUE; + } + } + if (dimensions > 2) { + if (zoffset < -((GLint)destTex->Border)) { + _mesa_error(ctx, GL_INVALID_VALUE, "glTexSubImage3D(zoffset)"); + return GL_TRUE; + } + if (zoffset + depth > (GLint) (destTex->Depth + destTex->Border)) { + _mesa_error(ctx, GL_INVALID_VALUE, "glTexSubImage3D(zoffset+depth)"); + return GL_TRUE; + } + } + + if (_mesa_is_format_compressed(destTex->TexFormat)) { + GLuint bw, bh; + + /* do tests which depend on compression block size */ + _mesa_get_format_block_size(destTex->TexFormat, &bw, &bh); + + /* offset must be multiple of block size */ + if ((xoffset % bw != 0) || (yoffset % bh != 0)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glTexSubImage%dD(xoffset = %d, yoffset = %d)", + dimensions, xoffset, yoffset); + return GL_TRUE; + } + /* size must be multiple of bw by bh or equal to whole texture size */ + if ((width % bw != 0) && (GLuint) width != destTex->Width) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glTexSubImage%dD(width = %d)", dimensions, width); + return GL_TRUE; + } + if ((height % bh != 0) && (GLuint) height != destTex->Height) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glTexSubImage%dD(height = %d)", dimensions, height); + return GL_TRUE; + } + } + + return GL_FALSE; +} + + +/** + * Test glCopyTexImage[12]D() parameters for errors. + * + * \param ctx GL context. + * \param dimensions texture image dimensions (must be 1, 2 or 3). + * \param target texture target given by the user. + * \param level image level given by the user. + * \param internalFormat internal format given by the user. + * \param width image width given by the user. + * \param height image height given by the user. + * \param border texture border. + * + * \return GL_TRUE if an error was detected, or GL_FALSE if no errors. + * + * Verifies each of the parameters against the constants specified in + * __struct gl_contextRec::Const and the supported extensions, and according + * to the OpenGL specification. + */ +static GLboolean +copytexture_error_check( struct gl_context *ctx, GLuint dimensions, + GLenum target, GLint level, GLint internalFormat, + GLint width, GLint height, GLint border ) +{ + const GLenum proxyTarget = get_proxy_target(target); + const GLenum type = GL_FLOAT; + GLboolean sizeOK; + GLint format; + + /* check target */ + if (!legal_texsubimage_target(ctx, dimensions, target)) { + _mesa_error(ctx, GL_INVALID_ENUM, "glCopyTexImage%uD(target=%s)", + dimensions, _mesa_lookup_enum_by_nr(target)); + return GL_TRUE; + } + + /* Basic level check (more checking in ctx->Driver.TestProxyTexImage) */ + if (level < 0 || level >= MAX_TEXTURE_LEVELS) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glCopyTexImage%dD(level=%d)", dimensions, level); + return GL_TRUE; + } + + /* Check that the source buffer is complete */ + if (ctx->ReadBuffer->Name) { + _mesa_test_framebuffer_completeness(ctx, ctx->ReadBuffer); + if (ctx->ReadBuffer->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) { + _mesa_error(ctx, GL_INVALID_FRAMEBUFFER_OPERATION_EXT, + "glCopyTexImage%dD(invalid readbuffer)", dimensions); + return GL_TRUE; + } + } + + /* Check border */ + if (border < 0 || border > 1 || + ((target == GL_TEXTURE_RECTANGLE_NV || + target == GL_PROXY_TEXTURE_RECTANGLE_NV) && border != 0)) { + return GL_TRUE; + } + + format = _mesa_base_tex_format(ctx, internalFormat); + if (format < 0) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glCopyTexImage%dD(internalFormat)", dimensions); + return GL_TRUE; + } + + if (!_mesa_source_buffer_exists(ctx, format)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glCopyTexImage%dD(missing readbuffer)", dimensions); + return GL_TRUE; + } + + /* Do size, level checking */ + sizeOK = (proxyTarget == GL_PROXY_TEXTURE_CUBE_MAP_ARB) + ? (width == height) : 1; + + sizeOK = sizeOK && ctx->Driver.TestProxyTexImage(ctx, proxyTarget, level, + internalFormat, format, + type, width, height, + 1, border); + + if (!sizeOK) { + if (dimensions == 1) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glCopyTexImage1D(width=%d)", width); + } + else { + ASSERT(dimensions == 2); + _mesa_error(ctx, GL_INVALID_VALUE, + "glCopyTexImage2D(width=%d, height=%d)", width, height); + } + return GL_TRUE; + } + + if (_mesa_is_compressed_format(ctx, internalFormat)) { + if (!target_can_be_compressed(ctx, target, internalFormat)) { + _mesa_error(ctx, GL_INVALID_ENUM, + "glCopyTexImage%dD(target)", dimensions); + return GL_TRUE; + } + if (border != 0) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glCopyTexImage%dD(border!=0)", dimensions); + return GL_TRUE; + } + } + else if (_mesa_is_depth_format(internalFormat)) { + /* make sure we have depth/stencil buffers */ + if (!ctx->ReadBuffer->_DepthBuffer) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glCopyTexImage%dD(no depth)", dimensions); + return GL_TRUE; + } + } + else if (_mesa_is_depthstencil_format(internalFormat)) { + /* make sure we have depth/stencil buffers */ + if (!ctx->ReadBuffer->_DepthBuffer || !ctx->ReadBuffer->_StencilBuffer) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glCopyTexImage%dD(no depth/stencil buffer)", dimensions); + return GL_TRUE; + } + } + + /* if we get here, the parameters are OK */ + return GL_FALSE; +} + + +/** + * Test glCopyTexSubImage[12]D() parameters for errors. + * Note that this is the first part of error checking. + * See also copytexsubimage_error_check2() below for the second part. + * + * \param ctx GL context. + * \param dimensions texture image dimensions (must be 1, 2 or 3). + * \param target texture target given by the user. + * \param level image level given by the user. + * + * \return GL_TRUE if an error was detected, or GL_FALSE if no errors. + */ +static GLboolean +copytexsubimage_error_check1( struct gl_context *ctx, GLuint dimensions, + GLenum target, GLint level) +{ + /* Check that the source buffer is complete */ + if (ctx->ReadBuffer->Name) { + _mesa_test_framebuffer_completeness(ctx, ctx->ReadBuffer); + if (ctx->ReadBuffer->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) { + _mesa_error(ctx, GL_INVALID_FRAMEBUFFER_OPERATION_EXT, + "glCopyTexImage%dD(invalid readbuffer)", dimensions); + return GL_TRUE; + } + } + + /* check target (proxies not allowed) */ + if (!legal_texsubimage_target(ctx, dimensions, target)) { + _mesa_error(ctx, GL_INVALID_ENUM, "glCopyTexSubImage%uD(target=%s)", + dimensions, _mesa_lookup_enum_by_nr(target)); + return GL_TRUE; + } + + /* Check level */ + if (level < 0 || level >= MAX_TEXTURE_LEVELS) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glCopyTexSubImage%dD(level=%d)", dimensions, level); + return GL_TRUE; + } + + return GL_FALSE; +} + + +/** + * Second part of error checking for glCopyTexSubImage[12]D(). + * \param xoffset sub-image x offset given by the user. + * \param yoffset sub-image y offset given by the user. + * \param zoffset sub-image z offset given by the user. + * \param width image width given by the user. + * \param height image height given by the user. + */ +static GLboolean +copytexsubimage_error_check2( struct gl_context *ctx, GLuint dimensions, + GLenum target, GLint level, + GLint xoffset, GLint yoffset, GLint zoffset, + GLsizei width, GLsizei height, + const struct gl_texture_image *teximage ) +{ + /* check that dest tex image exists */ + if (!teximage) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glCopyTexSubImage%dD(undefined texture level: %d)", + dimensions, level); + return GL_TRUE; + } + + /* Check size */ + if (width < 0) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glCopyTexSubImage%dD(width=%d)", dimensions, width); + return GL_TRUE; + } + if (dimensions > 1 && height < 0) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glCopyTexSubImage%dD(height=%d)", dimensions, height); + return GL_TRUE; + } + + /* check x/y offsets */ + if (xoffset < -((GLint)teximage->Border)) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glCopyTexSubImage%dD(xoffset=%d)", dimensions, xoffset); + return GL_TRUE; + } + if (xoffset + width > (GLint) (teximage->Width + teximage->Border)) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glCopyTexSubImage%dD(xoffset+width)", dimensions); + return GL_TRUE; + } + if (dimensions > 1) { + if (yoffset < -((GLint)teximage->Border)) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glCopyTexSubImage%dD(yoffset=%d)", dimensions, yoffset); + return GL_TRUE; + } + /* NOTE: we're adding the border here, not subtracting! */ + if (yoffset + height > (GLint) (teximage->Height + teximage->Border)) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glCopyTexSubImage%dD(yoffset+height)", dimensions); + return GL_TRUE; + } + } + + /* check z offset */ + if (dimensions > 2) { + if (zoffset < -((GLint)teximage->Border)) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glCopyTexSubImage%dD(zoffset)", dimensions); + return GL_TRUE; + } + if (zoffset > (GLint) (teximage->Depth + teximage->Border)) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glCopyTexSubImage%dD(zoffset+depth)", dimensions); + return GL_TRUE; + } + } + + if (_mesa_is_format_compressed(teximage->TexFormat)) { + /* offset must be multiple of 4 */ + if ((xoffset & 3) || (yoffset & 3)) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glCopyTexSubImage%dD(xoffset or yoffset)", dimensions); + return GL_TRUE; + } + /* size must be multiple of 4 */ + if ((width & 3) != 0 && (GLuint) width != teximage->Width) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glCopyTexSubImage%dD(width)", dimensions); + return GL_TRUE; + } + if ((height & 3) != 0 && (GLuint) height != teximage->Height) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glCopyTexSubImage%dD(height)", dimensions); + return GL_TRUE; + } + } + + if (teximage->InternalFormat == GL_YCBCR_MESA) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glCopyTexSubImage2D"); + return GL_TRUE; + } + + if (!_mesa_source_buffer_exists(ctx, teximage->_BaseFormat)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glCopyTexSubImage%dD(missing readbuffer, format=0x%x)", + dimensions, teximage->_BaseFormat); + return GL_TRUE; + } + + if (teximage->_BaseFormat == GL_DEPTH_COMPONENT) { + if (!ctx->ReadBuffer->_DepthBuffer) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glCopyTexSubImage%dD(no depth buffer)", + dimensions); + return GL_TRUE; + } + } + else if (teximage->_BaseFormat == GL_DEPTH_STENCIL_EXT) { + if (!ctx->ReadBuffer->_DepthBuffer || !ctx->ReadBuffer->_StencilBuffer) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glCopyTexSubImage%dD(no depth/stencil buffer)", + dimensions); + return GL_TRUE; + } + } + + /* If copying into an integer texture, the source buffer must also be + * integer-valued. + */ + if (_mesa_is_format_integer_color(teximage->TexFormat)) { + struct gl_renderbuffer *rb = ctx->ReadBuffer->_ColorReadBuffer; + if (!_mesa_is_format_integer_color(rb->Format)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glCopyTexSubImage%dD(source buffer is not integer format)", + dimensions); + return GL_TRUE; + } + } + + /* if we get here, the parameters are OK */ + return GL_FALSE; +} + + +/** Callback info for walking over FBO hash table */ +struct cb_info +{ + struct gl_context *ctx; + struct gl_texture_object *texObj; + GLuint level, face; +}; + + +/** + * Check render to texture callback. Called from _mesa_HashWalk(). + */ +static void +check_rtt_cb(GLuint key, void *data, void *userData) +{ + struct gl_framebuffer *fb = (struct gl_framebuffer *) data; + const struct cb_info *info = (struct cb_info *) userData; + struct gl_context *ctx = info->ctx; + const struct gl_texture_object *texObj = info->texObj; + const GLuint level = info->level, face = info->face; + + /* If this is a user-created FBO */ + if (fb->Name) { + GLuint i; + /* check if any of the FBO's attachments point to 'texObj' */ + for (i = 0; i < BUFFER_COUNT; i++) { + struct gl_renderbuffer_attachment *att = fb->Attachment + i; + if (att->Type == GL_TEXTURE && + att->Texture == texObj && + att->TextureLevel == level && + att->CubeMapFace == face) { + ASSERT(att->Texture->Image[att->CubeMapFace][att->TextureLevel]); + /* Tell driver about the new renderbuffer texture */ + ctx->Driver.RenderTexture(ctx, ctx->DrawBuffer, att); + /* Mark fb status as indeterminate to force re-validation */ + fb->_Status = 0; + } + } + } +} + + +/** + * When a texture image is specified we have to check if it's bound to + * any framebuffer objects (render to texture) in order to detect changes + * in size or format since that effects FBO completeness. + * Any FBOs rendering into the texture must be re-validated. + */ +static void +update_fbo_texture(struct gl_context *ctx, struct gl_texture_object *texObj, + GLuint face, GLuint level) +{ + /* Only check this texture if it's been marked as RenderToTexture */ + if (texObj->_RenderToTexture) { + struct cb_info info; + info.ctx = ctx; + info.texObj = texObj; + info.level = level; + info.face = face; + _mesa_HashWalk(ctx->Shared->FrameBuffers, check_rtt_cb, &info); + } +} + + +/** + * If the texture object's GenerateMipmap flag is set and we've + * changed the texture base level image, regenerate the rest of the + * mipmap levels now. + */ +static INLINE void +check_gen_mipmap(struct gl_context *ctx, GLenum target, + struct gl_texture_object *texObj, GLint level) +{ + ASSERT(target != GL_TEXTURE_CUBE_MAP); + if (texObj->GenerateMipmap && + level == texObj->BaseLevel && + level < texObj->MaxLevel) { + ASSERT(ctx->Driver.GenerateMipmap); + ctx->Driver.GenerateMipmap(ctx, target, texObj); + } +} + + +/** Debug helper: override the user-requested internal format */ +static GLenum +override_internal_format(GLenum internalFormat, GLint width, GLint height) +{ +#if 0 + if (internalFormat == GL_RGBA16F_ARB || + internalFormat == GL_RGBA32F_ARB) { + printf("Convert rgba float tex to int %d x %d\n", width, height); + return GL_RGBA; + } + else if (internalFormat == GL_RGB16F_ARB || + internalFormat == GL_RGB32F_ARB) { + printf("Convert rgb float tex to int %d x %d\n", width, height); + return GL_RGB; + } + else if (internalFormat == GL_LUMINANCE_ALPHA16F_ARB || + internalFormat == GL_LUMINANCE_ALPHA32F_ARB) { + printf("Convert luminance float tex to int %d x %d\n", width, height); + return GL_LUMINANCE_ALPHA; + } + else if (internalFormat == GL_LUMINANCE16F_ARB || + internalFormat == GL_LUMINANCE32F_ARB) { + printf("Convert luminance float tex to int %d x %d\n", width, height); + return GL_LUMINANCE; + } + else if (internalFormat == GL_ALPHA16F_ARB || + internalFormat == GL_ALPHA32F_ARB) { + printf("Convert luminance float tex to int %d x %d\n", width, height); + return GL_ALPHA; + } + /* + else if (internalFormat == GL_COMPRESSED_RGBA_S3TC_DXT1_EXT) { + internalFormat = GL_RGBA; + } + */ + else { + return internalFormat; + } +#else + return internalFormat; +#endif +} + + +/** + * Choose the actual hardware format for a texture image. + * Try to use the same format as the previous image level when possible. + * Otherwise, ask the driver for the best format. + * It's important to try to choose a consistant format for all levels + * for efficient texture memory layout/allocation. In particular, this + * comes up during automatic mipmap generation. + */ +gl_format +_mesa_choose_texture_format(struct gl_context *ctx, + struct gl_texture_object *texObj, + GLenum target, GLint level, + GLenum internalFormat, GLenum format, GLenum type) +{ + gl_format f; + + /* see if we've already chosen a format for the previous level */ + if (level > 0) { + struct gl_texture_image *prevImage = + _mesa_select_tex_image(ctx, texObj, target, level - 1); + /* See if the prev level is defined and has an internal format which + * matches the new internal format. + */ + if (prevImage && + prevImage->Width > 0 && + prevImage->InternalFormat == internalFormat) { + /* use the same format */ + ASSERT(prevImage->TexFormat != MESA_FORMAT_NONE); + return prevImage->TexFormat; + } + } + + /* choose format from scratch */ + f = ctx->Driver.ChooseTextureFormat(ctx, internalFormat, format, type); + ASSERT(f != MESA_FORMAT_NONE); + return f; +} + + +/** + * Common code to implement all the glTexImage1D/2D/3D functions. + */ +static void +teximage(struct gl_context *ctx, GLuint dims, + GLenum target, GLint level, GLint internalFormat, + GLsizei width, GLsizei height, GLsizei depth, + GLint border, GLenum format, GLenum type, + const GLvoid *pixels) +{ + GLboolean error; + + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + + if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE)) + _mesa_debug(ctx, "glTexImage%uD %s %d %s %d %d %d %d %s %s %p\n", + dims, + _mesa_lookup_enum_by_nr(target), level, + _mesa_lookup_enum_by_nr(internalFormat), + width, height, depth, border, + _mesa_lookup_enum_by_nr(format), + _mesa_lookup_enum_by_nr(type), pixels); + + internalFormat = override_internal_format(internalFormat, width, height); + + /* target error checking */ + if (!legal_teximage_target(ctx, dims, target)) { + _mesa_error(ctx, GL_INVALID_ENUM, "glTexImage%uD(target=%s)", + dims, _mesa_lookup_enum_by_nr(target)); + return; + } + + /* general error checking */ + error = texture_error_check(ctx, dims, target, level, internalFormat, + format, type, width, height, depth, border); + + if (_mesa_is_proxy_texture(target)) { + /* Proxy texture: just clear or set state depending on error checking */ + struct gl_texture_image *texImage = + _mesa_get_proxy_tex_image(ctx, target, level); + + if (error) { + /* when error, clear all proxy texture image parameters */ + if (texImage) + clear_teximage_fields(texImage); + } + else { + /* no error, set the tex image parameters */ + struct gl_texture_object *texObj = + _mesa_get_current_tex_object(ctx, target); + gl_format texFormat = _mesa_choose_texture_format(ctx, texObj, + target, level, + internalFormat, + format, type); + + if (legal_texture_size(ctx, texFormat, width, height, depth)) { + _mesa_init_teximage_fields(ctx, target, texImage, width, height, + depth, border, internalFormat, + texFormat); + } + else if (texImage) { + clear_teximage_fields(texImage); + } + } + } + else { + /* non-proxy target */ + const GLuint face = _mesa_tex_target_to_face(target); + struct gl_texture_object *texObj; + struct gl_texture_image *texImage; + + if (error) { + return; /* error was recorded */ + } + + if (ctx->NewState & _MESA_NEW_TRANSFER_STATE) + _mesa_update_state(ctx); + + texObj = _mesa_get_current_tex_object(ctx, target); + + _mesa_lock_texture(ctx, texObj); + { + texImage = _mesa_get_tex_image(ctx, texObj, target, level); + + if (!texImage) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage%uD", dims); + } + else { + gl_format texFormat; + + if (texImage->Data) { + ctx->Driver.FreeTexImageData( ctx, texImage ); + } + + ASSERT(texImage->Data == NULL); + texFormat = _mesa_choose_texture_format(ctx, texObj, target, level, + internalFormat, format, + type); + + if (legal_texture_size(ctx, texFormat, width, height, depth)) { + _mesa_init_teximage_fields(ctx, target, texImage, + width, height, depth, + border, internalFormat, texFormat); + + /* Give the texture to the driver. <pixels> may be null. */ + ASSERT(ctx->Driver.TexImage3D); + switch (dims) { + case 1: + ctx->Driver.TexImage1D(ctx, target, level, internalFormat, + width, border, format, + type, pixels, &ctx->Unpack, texObj, + texImage); + break; + case 2: + ctx->Driver.TexImage2D(ctx, target, level, internalFormat, + width, height, border, format, + type, pixels, &ctx->Unpack, texObj, + texImage); + break; + case 3: + ctx->Driver.TexImage3D(ctx, target, level, internalFormat, + width, height, depth, border, format, + type, pixels, &ctx->Unpack, texObj, + texImage); + break; + default: + _mesa_problem(ctx, "invalid dims=%u in teximage()", dims); + } + + check_gen_mipmap(ctx, target, texObj, level); + + update_fbo_texture(ctx, texObj, face, level); + + /* state update */ + texObj->_Complete = GL_FALSE; + ctx->NewState |= _NEW_TEXTURE; + } + else { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage%uD", dims); + } + } + } + _mesa_unlock_texture(ctx, texObj); + } +} + + +/* + * Called from the API. Note that width includes the border. + */ +void GLAPIENTRY +_mesa_TexImage1D( GLenum target, GLint level, GLint internalFormat, + GLsizei width, GLint border, GLenum format, + GLenum type, const GLvoid *pixels ) +{ + GET_CURRENT_CONTEXT(ctx); + teximage(ctx, 1, target, level, internalFormat, width, 1, 1, + border, format, type, pixels); +} + + +void GLAPIENTRY +_mesa_TexImage2D( GLenum target, GLint level, GLint internalFormat, + GLsizei width, GLsizei height, GLint border, + GLenum format, GLenum type, + const GLvoid *pixels ) +{ + GET_CURRENT_CONTEXT(ctx); + teximage(ctx, 2, target, level, internalFormat, width, height, 1, + border, format, type, pixels); +} + + +/* + * Called by the API or display list executor. + * Note that width and height include the border. + */ +void GLAPIENTRY +_mesa_TexImage3D( GLenum target, GLint level, GLint internalFormat, + GLsizei width, GLsizei height, GLsizei depth, + GLint border, GLenum format, GLenum type, + const GLvoid *pixels ) +{ + GET_CURRENT_CONTEXT(ctx); + teximage(ctx, 3, target, level, internalFormat, width, height, depth, + border, format, type, pixels); +} + + +void GLAPIENTRY +_mesa_TexImage3DEXT( GLenum target, GLint level, GLenum internalFormat, + GLsizei width, GLsizei height, GLsizei depth, + GLint border, GLenum format, GLenum type, + const GLvoid *pixels ) +{ + _mesa_TexImage3D(target, level, (GLint) internalFormat, width, height, + depth, border, format, type, pixels); +} + + +#if FEATURE_OES_EGL_image +void GLAPIENTRY +_mesa_EGLImageTargetTexture2DOES (GLenum target, GLeglImageOES image) +{ + struct gl_texture_object *texObj; + struct gl_texture_image *texImage; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + + if (!ctx->Extensions.OES_EGL_image) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glEGLImageTargetTexture2DOES(unsupported)"); + return; + } + + if (target != GL_TEXTURE_2D) { + _mesa_error(ctx, GL_INVALID_ENUM, + "glEGLImageTargetTexture2D(target=%d)", target); + return; + } + + if (ctx->NewState & _MESA_NEW_TRANSFER_STATE) + _mesa_update_state(ctx); + + texObj = _mesa_get_current_tex_object(ctx, target); + _mesa_lock_texture(ctx, texObj); + + texImage = _mesa_get_tex_image(ctx, texObj, target, 0); + if (!texImage) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glEGLImageTargetTexture2D"); + } else { + if (texImage->Data) + ctx->Driver.FreeTexImageData( ctx, texImage ); + + ASSERT(texImage->Data == NULL); + ctx->Driver.EGLImageTargetTexture2D(ctx, target, + texObj, texImage, image); + + /* state update */ + texObj->_Complete = GL_FALSE; + ctx->NewState |= _NEW_TEXTURE; + } + _mesa_unlock_texture(ctx, texObj); + +} +#endif + + + +/** + * Implement all the glTexSubImage1/2/3D() functions. + */ +static void +texsubimage(struct gl_context *ctx, GLuint dims, GLenum target, GLint level, + GLint xoffset, GLint yoffset, GLint zoffset, + GLsizei width, GLsizei height, GLsizei depth, + GLenum format, GLenum type, const GLvoid *pixels ) +{ + struct gl_texture_object *texObj; + struct gl_texture_image *texImage; + + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + + if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE)) + _mesa_debug(ctx, "glTexSubImage%uD %s %d %d %d %d %d %d %d %s %s %p\n", + dims, + _mesa_lookup_enum_by_nr(target), level, + xoffset, yoffset, zoffset, width, height, depth, + _mesa_lookup_enum_by_nr(format), + _mesa_lookup_enum_by_nr(type), pixels); + + /* check target (proxies not allowed) */ + if (!legal_texsubimage_target(ctx, dims, target)) { + _mesa_error(ctx, GL_INVALID_ENUM, "glTexSubImage%uD(target=%s)", + dims, _mesa_lookup_enum_by_nr(target)); + return; + } + + if (ctx->NewState & _MESA_NEW_TRANSFER_STATE) + _mesa_update_state(ctx); + + if (subtexture_error_check(ctx, dims, target, level, xoffset, yoffset, zoffset, + width, height, depth, format, type)) { + return; /* error was detected */ + } + + texObj = _mesa_get_current_tex_object(ctx, target); + + _mesa_lock_texture(ctx, texObj); + { + texImage = _mesa_select_tex_image(ctx, texObj, target, level); + + if (subtexture_error_check2(ctx, dims, target, level, + xoffset, yoffset, zoffset, + width, height, depth, + format, type, texImage)) { + /* error was recorded */ + } + else if (width > 0 && height > 0 && height > 0) { + /* If we have a border, offset=-1 is legal. Bias by border width. */ + switch (dims) { + case 3: + zoffset += texImage->Border; + /* fall-through */ + case 2: + yoffset += texImage->Border; + /* fall-through */ + case 1: + xoffset += texImage->Border; + } + + switch (dims) { + case 1: + ctx->Driver.TexSubImage1D(ctx, target, level, + xoffset, width, + format, type, pixels, + &ctx->Unpack, texObj, texImage ); + break; + case 2: + ctx->Driver.TexSubImage2D(ctx, target, level, + xoffset, yoffset, width, height, + format, type, pixels, + &ctx->Unpack, texObj, texImage ); + break; + case 3: + ctx->Driver.TexSubImage3D(ctx, target, level, + xoffset, yoffset, zoffset, + width, height, depth, + format, type, pixels, + &ctx->Unpack, texObj, texImage ); + break; + default: + _mesa_problem(ctx, "unexpected dims in subteximage()"); + } + + check_gen_mipmap(ctx, target, texObj, level); + + ctx->NewState |= _NEW_TEXTURE; + } + } + _mesa_unlock_texture(ctx, texObj); +} + + +void GLAPIENTRY +_mesa_TexSubImage1D( GLenum target, GLint level, + GLint xoffset, GLsizei width, + GLenum format, GLenum type, + const GLvoid *pixels ) +{ + GET_CURRENT_CONTEXT(ctx); + texsubimage(ctx, 1, target, level, + xoffset, 0, 0, + width, 1, 1, + format, type, pixels); +} + + +void GLAPIENTRY +_mesa_TexSubImage2D( GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLsizei width, GLsizei height, + GLenum format, GLenum type, + const GLvoid *pixels ) +{ + GET_CURRENT_CONTEXT(ctx); + texsubimage(ctx, 2, target, level, + xoffset, yoffset, 0, + width, height, 1, + format, type, pixels); +} + + + +void GLAPIENTRY +_mesa_TexSubImage3D( GLenum target, GLint level, + GLint xoffset, GLint yoffset, GLint zoffset, + GLsizei width, GLsizei height, GLsizei depth, + GLenum format, GLenum type, + const GLvoid *pixels ) +{ + GET_CURRENT_CONTEXT(ctx); + texsubimage(ctx, 3, target, level, + xoffset, yoffset, zoffset, + width, height, depth, + format, type, pixels); +} + + + +/** + * Implement the glCopyTexImage1/2D() functions. + */ +static void +copyteximage(struct gl_context *ctx, GLuint dims, + GLenum target, GLint level, GLenum internalFormat, + GLint x, GLint y, GLsizei width, GLsizei height, GLint border ) +{ + struct gl_texture_object *texObj; + struct gl_texture_image *texImage; + const GLuint face = _mesa_tex_target_to_face(target); + + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + + if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE)) + _mesa_debug(ctx, "glCopyTexImage%uD %s %d %s %d %d %d %d %d\n", + dims, + _mesa_lookup_enum_by_nr(target), level, + _mesa_lookup_enum_by_nr(internalFormat), + x, y, width, height, border); + + if (ctx->NewState & NEW_COPY_TEX_STATE) + _mesa_update_state(ctx); + + if (copytexture_error_check(ctx, dims, target, level, internalFormat, + width, height, border)) + return; + + texObj = _mesa_get_current_tex_object(ctx, target); + + _mesa_lock_texture(ctx, texObj); + { + texImage = _mesa_get_tex_image(ctx, texObj, target, level); + + if (!texImage) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyTexImage%uD", dims); + } + else { + gl_format texFormat; + + if (texImage->Data) { + ctx->Driver.FreeTexImageData( ctx, texImage ); + } + + ASSERT(texImage->Data == NULL); + + texFormat = _mesa_choose_texture_format(ctx, texObj, target, level, + internalFormat, GL_NONE, + GL_NONE); + + if (legal_texture_size(ctx, texFormat, width, height, 1)) { + _mesa_init_teximage_fields(ctx, target, texImage, width, height, 1, + border, internalFormat, texFormat); + + ASSERT(ctx->Driver.CopyTexImage2D); + if (dims == 1) + ctx->Driver.CopyTexImage1D(ctx, target, level, internalFormat, + x, y, width, border); + else + ctx->Driver.CopyTexImage2D(ctx, target, level, internalFormat, + x, y, width, height, border); + + check_gen_mipmap(ctx, target, texObj, level); + + update_fbo_texture(ctx, texObj, face, level); + + /* state update */ + texObj->_Complete = GL_FALSE; + ctx->NewState |= _NEW_TEXTURE; + } + else { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyTexImage%uD", dims); + } + } + } + _mesa_unlock_texture(ctx, texObj); +} + + + +void GLAPIENTRY +_mesa_CopyTexImage1D( GLenum target, GLint level, + GLenum internalFormat, + GLint x, GLint y, + GLsizei width, GLint border ) +{ + GET_CURRENT_CONTEXT(ctx); + copyteximage(ctx, 1, target, level, internalFormat, x, y, width, 1, border); +} + + + +void GLAPIENTRY +_mesa_CopyTexImage2D( GLenum target, GLint level, GLenum internalFormat, + GLint x, GLint y, GLsizei width, GLsizei height, + GLint border ) +{ + GET_CURRENT_CONTEXT(ctx); + copyteximage(ctx, 2, target, level, internalFormat, + x, y, width, height, border); +} + + + +/** + * Implementation for glCopyTexSubImage1/2/3D() functions. + */ +static void +copytexsubimage(struct gl_context *ctx, GLuint dims, GLenum target, GLint level, + GLint xoffset, GLint yoffset, GLint zoffset, + GLint x, GLint y, GLsizei width, GLsizei height) +{ + struct gl_texture_object *texObj; + struct gl_texture_image *texImage; + + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + + if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE)) + _mesa_debug(ctx, "glCopyTexSubImage%uD %s %d %d %d %d %d %d %d %d\n", + dims, + _mesa_lookup_enum_by_nr(target), + level, xoffset, yoffset, zoffset, x, y, width, height); + + if (ctx->NewState & NEW_COPY_TEX_STATE) + _mesa_update_state(ctx); + + if (copytexsubimage_error_check1(ctx, dims, target, level)) + return; + + texObj = _mesa_get_current_tex_object(ctx, target); + + _mesa_lock_texture(ctx, texObj); + { + texImage = _mesa_select_tex_image(ctx, texObj, target, level); + + if (copytexsubimage_error_check2(ctx, dims, target, level, xoffset, yoffset, + zoffset, width, height, texImage)) { + /* error was recored */ + } + else { + /* If we have a border, offset=-1 is legal. Bias by border width. */ + switch (dims) { + case 3: + zoffset += texImage->Border; + /* fall-through */ + case 2: + yoffset += texImage->Border; + /* fall-through */ + case 1: + xoffset += texImage->Border; + } + + if (_mesa_clip_copytexsubimage(ctx, &xoffset, &yoffset, &x, &y, + &width, &height)) { + switch (dims) { + case 1: + ctx->Driver.CopyTexSubImage1D(ctx, target, level, + xoffset, x, y, width); + break; + case 2: + ctx->Driver.CopyTexSubImage2D(ctx, target, level, + xoffset, yoffset, + x, y, width, height); + break; + case 3: + ctx->Driver.CopyTexSubImage3D(ctx, target, level, + xoffset, yoffset, zoffset, + x, y, width, height); + break; + default: + _mesa_problem(ctx, "bad dims in copytexsubimage()"); + } + + check_gen_mipmap(ctx, target, texObj, level); + + ctx->NewState |= _NEW_TEXTURE; + } + } + } + _mesa_unlock_texture(ctx, texObj); +} + + +void GLAPIENTRY +_mesa_CopyTexSubImage1D( GLenum target, GLint level, + GLint xoffset, GLint x, GLint y, GLsizei width ) +{ + GET_CURRENT_CONTEXT(ctx); + copytexsubimage(ctx, 1, target, level, xoffset, 0, 0, x, y, width, 1); +} + + + +void GLAPIENTRY +_mesa_CopyTexSubImage2D( GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLint x, GLint y, GLsizei width, GLsizei height ) +{ + GET_CURRENT_CONTEXT(ctx); + copytexsubimage(ctx, 2, target, level, xoffset, yoffset, 0, x, y, + width, height); +} + + + +void GLAPIENTRY +_mesa_CopyTexSubImage3D( GLenum target, GLint level, + GLint xoffset, GLint yoffset, GLint zoffset, + GLint x, GLint y, GLsizei width, GLsizei height ) +{ + GET_CURRENT_CONTEXT(ctx); + copytexsubimage(ctx, 3, target, level, xoffset, yoffset, zoffset, + x, y, width, height); +} + + + + +/**********************************************************************/ +/****** Compressed Textures ******/ +/**********************************************************************/ + + +/** + * Return expected size of a compressed texture. + */ +static GLuint +compressed_tex_size(GLsizei width, GLsizei height, GLsizei depth, + GLenum glformat) +{ + gl_format mesaFormat = _mesa_glenum_to_compressed_format(glformat); + return _mesa_format_image_size(mesaFormat, width, height, depth); +} + + +/* + * Return compressed texture block size, in pixels. + */ +static void +get_compressed_block_size(GLenum glformat, GLuint *bw, GLuint *bh) +{ + gl_format mesaFormat = _mesa_glenum_to_compressed_format(glformat); + _mesa_get_format_block_size(mesaFormat, bw, bh); +} + + +/** + * Error checking for glCompressedTexImage[123]D(). + * \return error code or GL_NO_ERROR. + */ +static GLenum +compressed_texture_error_check(struct gl_context *ctx, GLint dimensions, + GLenum target, GLint level, + GLenum internalFormat, GLsizei width, + GLsizei height, GLsizei depth, GLint border, + GLsizei imageSize) +{ + const GLenum proxyTarget = get_proxy_target(target); + const GLint maxLevels = _mesa_max_texture_levels(ctx, target); + GLint expectedSize; + + /* check level */ + if (level < 0 || level >= maxLevels) + return GL_INVALID_VALUE; + + if (!target_can_be_compressed(ctx, target, internalFormat)) { + return GL_INVALID_ENUM; + } + + /* This will detect any invalid internalFormat value */ + if (!_mesa_is_compressed_format(ctx, internalFormat)) + return GL_INVALID_ENUM; + + /* This should really never fail */ + if (_mesa_base_tex_format(ctx, internalFormat) < 0) + return GL_INVALID_ENUM; + + /* No compressed formats support borders at this time */ + if (border != 0) + return GL_INVALID_VALUE; + + /* For cube map, width must equal height */ + if (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB && + target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB && width != height) + return GL_INVALID_VALUE; + + /* check image size against compression block size */ + { + gl_format texFormat = + ctx->Driver.ChooseTextureFormat(ctx, internalFormat, + GL_NONE, GL_NONE); + GLuint bw, bh; + + _mesa_get_format_block_size(texFormat, &bw, &bh); + if ((width > bw && width % bw > 0) || + (height > bh && height % bh > 0)) { + /* + * Per GL_ARB_texture_compression: GL_INVALID_OPERATION is + * generated [...] if any parameter combinations are not + * supported by the specific compressed internal format. + */ + return GL_INVALID_OPERATION; + } + } + + /* check image sizes */ + if (!ctx->Driver.TestProxyTexImage(ctx, proxyTarget, level, + internalFormat, GL_NONE, GL_NONE, + width, height, depth, border)) { + /* See error comment above */ + return GL_INVALID_OPERATION; + } + + /* check image size in bytes */ + expectedSize = compressed_tex_size(width, height, depth, internalFormat); + if (expectedSize != imageSize) { + /* Per GL_ARB_texture_compression: GL_INVALID_VALUE is generated [...] + * if <imageSize> is not consistent with the format, dimensions, and + * contents of the specified image. + */ + return GL_INVALID_VALUE; + } + + return GL_NO_ERROR; +} + + +/** + * Error checking for glCompressedTexSubImage[123]D(). + * \warning There are some bad assumptions here about the size of compressed + * texture tiles (multiple of 4) used to test the validity of the + * offset and size parameters. + * \return error code or GL_NO_ERROR. + */ +static GLenum +compressed_subtexture_error_check(struct gl_context *ctx, GLint dimensions, + GLenum target, GLint level, + GLint xoffset, GLint yoffset, GLint zoffset, + GLsizei width, GLsizei height, GLsizei depth, + GLenum format, GLsizei imageSize) +{ + GLint expectedSize, maxLevels = 0, maxTextureSize; + GLuint bw, bh; + (void) zoffset; + + if (dimensions == 1) { + /* 1D compressed textures not allowed */ + return GL_INVALID_ENUM; + } + else if (dimensions == 2) { + if (target == GL_PROXY_TEXTURE_2D) { + maxLevels = ctx->Const.MaxTextureLevels; + } + else if (target == GL_TEXTURE_2D) { + maxLevels = ctx->Const.MaxTextureLevels; + } + else if (target == GL_PROXY_TEXTURE_CUBE_MAP_ARB) { + if (!ctx->Extensions.ARB_texture_cube_map) + return GL_INVALID_ENUM; /*target*/ + maxLevels = ctx->Const.MaxCubeTextureLevels; + } + else if (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB && + target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB) { + if (!ctx->Extensions.ARB_texture_cube_map) + return GL_INVALID_ENUM; /*target*/ + maxLevels = ctx->Const.MaxCubeTextureLevels; + } + else { + return GL_INVALID_ENUM; /*target*/ + } + } + else if (dimensions == 3) { + /* 3D compressed textures not allowed */ + return GL_INVALID_ENUM; + } + + maxTextureSize = 1 << (maxLevels - 1); + + /* this will catch any invalid compressed format token */ + if (!_mesa_is_compressed_format(ctx, format)) + return GL_INVALID_ENUM; + + if (width < 1 || width > maxTextureSize) + return GL_INVALID_VALUE; + + if ((height < 1 || height > maxTextureSize) + && dimensions > 1) + return GL_INVALID_VALUE; + + if (level < 0 || level >= maxLevels) + return GL_INVALID_VALUE; + + /* + * do checks which depend on compression block size + */ + get_compressed_block_size(format, &bw, &bh); + + if ((xoffset % bw != 0) || (yoffset % bh != 0)) + return GL_INVALID_VALUE; + + if ((width % bw != 0) && width != 2 && width != 1) + return GL_INVALID_VALUE; + + if ((height % bh != 0) && height != 2 && height != 1) + return GL_INVALID_VALUE; + + expectedSize = compressed_tex_size(width, height, depth, format); + if (expectedSize != imageSize) + return GL_INVALID_VALUE; + + return GL_NO_ERROR; +} + + +/** + * Do second part of glCompressedTexSubImage error checking. + * \return GL_TRUE if error found, GL_FALSE otherwise. + */ +static GLboolean +compressed_subtexture_error_check2(struct gl_context *ctx, GLuint dims, + GLsizei width, GLsizei height, + GLsizei depth, GLenum format, + struct gl_texture_image *texImage) +{ + + if ((GLint) format != texImage->InternalFormat) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glCompressedTexSubImage%uD(format=0x%x)", dims, format); + return GL_TRUE; + } + + if (((width == 1 || width == 2) && + width != (GLsizei) texImage->Width) || + (width > (GLsizei) texImage->Width)) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glCompressedTexSubImage%uD(width=%d)", dims, width); + return GL_TRUE; + } + + if (dims >= 2) { + if (((height == 1 || height == 2) && + height != (GLsizei) texImage->Height) || + (height > (GLsizei) texImage->Height)) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glCompressedTexSubImage%uD(height=%d)", dims, height); + return GL_TRUE; + } + } + + if (dims >= 3) { + if (((depth == 1 || depth == 2) && + depth != (GLsizei) texImage->Depth) || + (depth > (GLsizei) texImage->Depth)) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glCompressedTexSubImage%uD(depth=%d)", dims, depth); + return GL_TRUE; + } + } + + return GL_FALSE; +} + + +/** + * Implementation of the glCompressedTexImage1/2/3D() functions. + */ +static void +compressedteximage(struct gl_context *ctx, GLuint dims, + GLenum target, GLint level, + GLenum internalFormat, GLsizei width, + GLsizei height, GLsizei depth, GLint border, + GLsizei imageSize, const GLvoid *data) +{ + GLenum error; + + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + + if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE)) + _mesa_debug(ctx, + "glCompressedTexImage%uDARB %s %d %s %d %d %d %d %d %p\n", + dims, + _mesa_lookup_enum_by_nr(target), level, + _mesa_lookup_enum_by_nr(internalFormat), + width, height, depth, border, imageSize, data); + + /* check target */ + if (!legal_teximage_target(ctx, dims, target)) { + _mesa_error(ctx, GL_INVALID_ENUM, "glCompressedTexImage%uD(target=%s)", + dims, _mesa_lookup_enum_by_nr(target)); + return; + } + + error = compressed_texture_error_check(ctx, dims, target, level, + internalFormat, width, height, depth, + border, imageSize); + +#if FEATURE_ES + /* XXX this is kind of a hack */ + if (error) { + _mesa_error(ctx, error, "glTexImage2D"); + return; + } + + if (dims == 2) { + switch (internalFormat) { + case GL_PALETTE4_RGB8_OES: + case GL_PALETTE4_RGBA8_OES: + case GL_PALETTE4_R5_G6_B5_OES: + case GL_PALETTE4_RGBA4_OES: + case GL_PALETTE4_RGB5_A1_OES: + case GL_PALETTE8_RGB8_OES: + case GL_PALETTE8_RGBA8_OES: + case GL_PALETTE8_R5_G6_B5_OES: + case GL_PALETTE8_RGBA4_OES: + case GL_PALETTE8_RGB5_A1_OES: + _mesa_cpal_compressed_teximage2d(target, level, internalFormat, + width, height, imageSize, data); + return; + } + } +#endif + + if (_mesa_is_proxy_texture(target)) { + /* Proxy texture: just check for errors and update proxy state */ + struct gl_texture_image *texImage; + + if (!error) { + struct gl_texture_object *texObj = + _mesa_get_current_tex_object(ctx, target); + gl_format texFormat = + _mesa_choose_texture_format(ctx, texObj, target, level, + internalFormat, GL_NONE, GL_NONE); + if (!legal_texture_size(ctx, texFormat, width, height, depth)) { + error = GL_OUT_OF_MEMORY; + } + } + + texImage = _mesa_get_proxy_tex_image(ctx, target, level); + if (texImage) { + if (error) { + /* if error, clear all proxy texture image parameters */ + clear_teximage_fields(texImage); + } + else { + /* no error: store the teximage parameters */ + _mesa_init_teximage_fields(ctx, target, texImage, width, height, + depth, border, internalFormat, + MESA_FORMAT_NONE); + } + } + } + else { + /* non-proxy target */ + struct gl_texture_object *texObj; + struct gl_texture_image *texImage; + + if (error) { + _mesa_error(ctx, error, "glCompressedTexImage%uD", dims); + return; + } + + texObj = _mesa_get_current_tex_object(ctx, target); + + _mesa_lock_texture(ctx, texObj); + { + texImage = _mesa_get_tex_image(ctx, texObj, target, level); + if (!texImage) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, + "glCompressedTexImage%uD", dims); + } + else { + gl_format texFormat; + + if (texImage->Data) { + ctx->Driver.FreeTexImageData( ctx, texImage ); + } + ASSERT(texImage->Data == NULL); + + texFormat = _mesa_choose_texture_format(ctx, texObj, target, level, + internalFormat, GL_NONE, + GL_NONE); + + if (legal_texture_size(ctx, texFormat, width, height, depth)) { + _mesa_init_teximage_fields(ctx, target, texImage, + width, height, depth, + border, internalFormat, texFormat); + + switch (dims) { + case 1: + ASSERT(ctx->Driver.CompressedTexImage1D); + ctx->Driver.CompressedTexImage1D(ctx, target, level, + internalFormat, + width, + border, imageSize, data, + texObj, texImage); + break; + case 2: + ASSERT(ctx->Driver.CompressedTexImage2D); + ctx->Driver.CompressedTexImage2D(ctx, target, level, + internalFormat, + width, height, + border, imageSize, data, + texObj, texImage); + break; + case 3: + ASSERT(ctx->Driver.CompressedTexImage3D); + ctx->Driver.CompressedTexImage3D(ctx, target, level, + internalFormat, + width, height, depth, + border, imageSize, data, + texObj, texImage); + break; + default: + _mesa_problem(ctx, "bad dims in compressedteximage"); + } + + check_gen_mipmap(ctx, target, texObj, level); + + /* state update */ + texObj->_Complete = GL_FALSE; + ctx->NewState |= _NEW_TEXTURE; + } + else { + _mesa_error(ctx, GL_OUT_OF_MEMORY, + "glCompressedTexImage%uD", dims); + } + } + } + _mesa_unlock_texture(ctx, texObj); + } +} + + +void GLAPIENTRY +_mesa_CompressedTexImage1DARB(GLenum target, GLint level, + GLenum internalFormat, GLsizei width, + GLint border, GLsizei imageSize, + const GLvoid *data) +{ + GET_CURRENT_CONTEXT(ctx); + compressedteximage(ctx, 1, target, level, internalFormat, + width, 1, 1, border, imageSize, data); +} + + +void GLAPIENTRY +_mesa_CompressedTexImage2DARB(GLenum target, GLint level, + GLenum internalFormat, GLsizei width, + GLsizei height, GLint border, GLsizei imageSize, + const GLvoid *data) +{ + GET_CURRENT_CONTEXT(ctx); + compressedteximage(ctx, 2, target, level, internalFormat, + width, height, 1, border, imageSize, data); +} + + +void GLAPIENTRY +_mesa_CompressedTexImage3DARB(GLenum target, GLint level, + GLenum internalFormat, GLsizei width, + GLsizei height, GLsizei depth, GLint border, + GLsizei imageSize, const GLvoid *data) +{ + GET_CURRENT_CONTEXT(ctx); + compressedteximage(ctx, 3, target, level, internalFormat, + width, height, depth, border, imageSize, data); +} + + +/** + * Common helper for glCompressedTexSubImage1/2/3D(). + */ +static void +compressed_tex_sub_image(GLuint dims, GLenum target, GLint level, + GLint xoffset, GLint yoffset, GLint zoffset, + GLsizei width, GLsizei height, GLsizei depth, + GLenum format, GLsizei imageSize, const GLvoid *data) +{ + struct gl_texture_object *texObj; + struct gl_texture_image *texImage; + GLenum error; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + + error = compressed_subtexture_error_check(ctx, dims, target, level, + xoffset, 0, 0, /* pos */ + width, height, depth, /* size */ + format, imageSize); + if (error) { + _mesa_error(ctx, error, "glCompressedTexSubImage%uD", dims); + return; + } + + texObj = _mesa_get_current_tex_object(ctx, target); + + _mesa_lock_texture(ctx, texObj); + { + texImage = _mesa_select_tex_image(ctx, texObj, target, level); + assert(texImage); + + if (compressed_subtexture_error_check2(ctx, dims, width, height, depth, + format, texImage)) { + /* error was recorded */ + } + else if (width > 0 && height > 0 && depth > 0) { + switch (dims) { + case 1: + if (ctx->Driver.CompressedTexSubImage1D) { + ctx->Driver.CompressedTexSubImage1D(ctx, target, level, + xoffset, width, + format, imageSize, data, + texObj, texImage); + } + break; + case 2: + if (ctx->Driver.CompressedTexSubImage2D) { + ctx->Driver.CompressedTexSubImage2D(ctx, target, level, + xoffset, yoffset, + width, height, + format, imageSize, data, + texObj, texImage); + } + break; + case 3: + if (ctx->Driver.CompressedTexSubImage3D) { + ctx->Driver.CompressedTexSubImage3D(ctx, target, level, + xoffset, yoffset, zoffset, + width, height, depth, + format, imageSize, data, + texObj, texImage); + } + break; + default: + ; + } + + check_gen_mipmap(ctx, target, texObj, level); + + ctx->NewState |= _NEW_TEXTURE; + } + } + _mesa_unlock_texture(ctx, texObj); +} + + +void GLAPIENTRY +_mesa_CompressedTexSubImage1DARB(GLenum target, GLint level, GLint xoffset, + GLsizei width, GLenum format, + GLsizei imageSize, const GLvoid *data) +{ + compressed_tex_sub_image(1, target, level, xoffset, 0, 0, width, 1, 1, + format, imageSize, data); +} + + +void GLAPIENTRY +_mesa_CompressedTexSubImage2DARB(GLenum target, GLint level, GLint xoffset, + GLint yoffset, GLsizei width, GLsizei height, + GLenum format, GLsizei imageSize, + const GLvoid *data) +{ + compressed_tex_sub_image(2, target, level, xoffset, yoffset, 0, + width, height, 1, format, imageSize, data); +} + + +void GLAPIENTRY +_mesa_CompressedTexSubImage3DARB(GLenum target, GLint level, GLint xoffset, + GLint yoffset, GLint zoffset, GLsizei width, + GLsizei height, GLsizei depth, GLenum format, + GLsizei imageSize, const GLvoid *data) +{ + compressed_tex_sub_image(3, target, level, xoffset, yoffset, zoffset, + width, height, depth, format, imageSize, data); +} diff --git a/mesalib/src/mesa/state_tracker/st_extensions.c b/mesalib/src/mesa/state_tracker/st_extensions.c index 974fd78d7..d7ed7ea3a 100644 --- a/mesalib/src/mesa/state_tracker/st_extensions.c +++ b/mesalib/src/mesa/state_tracker/st_extensions.c @@ -260,6 +260,8 @@ void st_init_extensions(struct st_context *st) ctx->Extensions.EXT_texture_env_dot3 = GL_TRUE; ctx->Extensions.EXT_texture_lod_bias = GL_TRUE; ctx->Extensions.EXT_vertex_array_bgra = GL_TRUE; + if (ctx->API == API_OPENGLES || ctx->API == API_OPENGLES2) + ctx->Extensions.EXT_texture_format_BGRA8888 = GL_TRUE; ctx->Extensions.APPLE_vertex_array_object = GL_TRUE; diff --git a/mesalib/src/mesa/state_tracker/st_format.c b/mesalib/src/mesa/state_tracker/st_format.c index bd20548ac..a532e089c 100644 --- a/mesalib/src/mesa/state_tracker/st_format.c +++ b/mesalib/src/mesa/state_tracker/st_format.c @@ -1,1091 +1,1100 @@ -/**************************************************************************
- *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * Copyright (c) 2008-2010 VMware, Inc.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-
-/**
- * Mesa / Gallium format conversion and format selection code.
- * \author Brian Paul
- */
-
-#include "main/imports.h"
-#include "main/context.h"
-#include "main/texstore.h"
-#include "main/image.h"
-#include "main/macros.h"
-#include "main/mfeatures.h"
-
-#include "pipe/p_context.h"
-#include "pipe/p_defines.h"
-#include "pipe/p_screen.h"
-#include "util/u_format.h"
-#include "st_context.h"
-#include "st_format.h"
-
-
-static GLuint
-format_max_bits(enum pipe_format format)
-{
- GLuint size = util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, 0);
-
- size = MAX2(size, util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, 1));
- size = MAX2(size, util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, 2));
- size = MAX2(size, util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, 3));
- size = MAX2(size, util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_ZS, 0));
- size = MAX2(size, util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_ZS, 1));
- return size;
-}
-
-
-/**
- * Return basic GL datatype for the given gallium format.
- */
-GLenum
-st_format_datatype(enum pipe_format format)
-{
- const struct util_format_description *desc;
-
- desc = util_format_description(format);
- assert(desc);
-
- if (desc->layout == UTIL_FORMAT_LAYOUT_PLAIN) {
- if (format == PIPE_FORMAT_B5G5R5A1_UNORM ||
- format == PIPE_FORMAT_B5G6R5_UNORM) {
- return GL_UNSIGNED_SHORT;
- }
- else if (format == PIPE_FORMAT_Z24_UNORM_S8_USCALED ||
- format == PIPE_FORMAT_S8_USCALED_Z24_UNORM ||
- format == PIPE_FORMAT_Z24X8_UNORM ||
- format == PIPE_FORMAT_X8Z24_UNORM) {
- return GL_UNSIGNED_INT_24_8;
- }
- else {
- const GLuint size = format_max_bits(format);
- if (size == 8) {
- if (desc->channel[0].type == UTIL_FORMAT_TYPE_UNSIGNED)
- return GL_UNSIGNED_BYTE;
- else
- return GL_BYTE;
- }
- else if (size == 16) {
- if (desc->channel[0].type == UTIL_FORMAT_TYPE_UNSIGNED)
- return GL_UNSIGNED_SHORT;
- else
- return GL_SHORT;
- }
- else {
- assert( size <= 32 );
- if (desc->channel[0].type == UTIL_FORMAT_TYPE_UNSIGNED)
- return GL_UNSIGNED_INT;
- else
- return GL_INT;
- }
- }
- }
- else if (format == PIPE_FORMAT_UYVY) {
- return GL_UNSIGNED_SHORT;
- }
- else if (format == PIPE_FORMAT_YUYV) {
- return GL_UNSIGNED_SHORT;
- }
- else {
- /* compressed format? */
- assert(0);
- }
-
- assert(0);
- return GL_NONE;
-}
-
-
-/**
- * Translate Mesa format to Gallium format.
- */
-enum pipe_format
-st_mesa_format_to_pipe_format(gl_format mesaFormat)
-{
- switch (mesaFormat) {
- case MESA_FORMAT_RGBA8888:
- return PIPE_FORMAT_A8B8G8R8_UNORM;
- case MESA_FORMAT_RGBA8888_REV:
- return PIPE_FORMAT_R8G8B8A8_UNORM;
- case MESA_FORMAT_ARGB8888:
- return PIPE_FORMAT_B8G8R8A8_UNORM;
- case MESA_FORMAT_ARGB8888_REV:
- return PIPE_FORMAT_A8R8G8B8_UNORM;
- case MESA_FORMAT_XRGB8888:
- return PIPE_FORMAT_B8G8R8X8_UNORM;
- case MESA_FORMAT_XRGB8888_REV:
- return PIPE_FORMAT_X8R8G8B8_UNORM;
- case MESA_FORMAT_ARGB1555:
- return PIPE_FORMAT_B5G5R5A1_UNORM;
- case MESA_FORMAT_ARGB4444:
- return PIPE_FORMAT_B4G4R4A4_UNORM;
- case MESA_FORMAT_RGB565:
- return PIPE_FORMAT_B5G6R5_UNORM;
- case MESA_FORMAT_RGB332:
- return PIPE_FORMAT_B2G3R3_UNORM;
- case MESA_FORMAT_ARGB2101010:
- return PIPE_FORMAT_B10G10R10A2_UNORM;
- case MESA_FORMAT_AL44:
- return PIPE_FORMAT_L4A4_UNORM;
- case MESA_FORMAT_AL88:
- return PIPE_FORMAT_L8A8_UNORM;
- case MESA_FORMAT_AL1616:
- return PIPE_FORMAT_L16A16_UNORM;
- case MESA_FORMAT_A8:
- return PIPE_FORMAT_A8_UNORM;
- case MESA_FORMAT_A16:
- return PIPE_FORMAT_A16_UNORM;
- case MESA_FORMAT_L8:
- return PIPE_FORMAT_L8_UNORM;
- case MESA_FORMAT_L16:
- return PIPE_FORMAT_L16_UNORM;
- case MESA_FORMAT_I8:
- return PIPE_FORMAT_I8_UNORM;
- case MESA_FORMAT_I16:
- return PIPE_FORMAT_I16_UNORM;
- case MESA_FORMAT_Z16:
- return PIPE_FORMAT_Z16_UNORM;
- case MESA_FORMAT_Z32:
- return PIPE_FORMAT_Z32_UNORM;
- case MESA_FORMAT_Z24_S8:
- return PIPE_FORMAT_S8_USCALED_Z24_UNORM;
- case MESA_FORMAT_S8_Z24:
- return PIPE_FORMAT_Z24_UNORM_S8_USCALED;
- case MESA_FORMAT_Z24_X8:
- return PIPE_FORMAT_X8Z24_UNORM;
- case MESA_FORMAT_X8_Z24:
- return PIPE_FORMAT_Z24X8_UNORM;
- case MESA_FORMAT_S8:
- return PIPE_FORMAT_S8_USCALED;
- case MESA_FORMAT_YCBCR:
- return PIPE_FORMAT_UYVY;
-#if FEATURE_texture_s3tc
- case MESA_FORMAT_RGB_DXT1:
- return PIPE_FORMAT_DXT1_RGB;
- case MESA_FORMAT_RGBA_DXT1:
- return PIPE_FORMAT_DXT1_RGBA;
- case MESA_FORMAT_RGBA_DXT3:
- return PIPE_FORMAT_DXT3_RGBA;
- case MESA_FORMAT_RGBA_DXT5:
- return PIPE_FORMAT_DXT5_RGBA;
-#if FEATURE_EXT_texture_sRGB
- case MESA_FORMAT_SRGB_DXT1:
- return PIPE_FORMAT_DXT1_SRGB;
- case MESA_FORMAT_SRGBA_DXT1:
- return PIPE_FORMAT_DXT1_SRGBA;
- case MESA_FORMAT_SRGBA_DXT3:
- return PIPE_FORMAT_DXT3_SRGBA;
- case MESA_FORMAT_SRGBA_DXT5:
- return PIPE_FORMAT_DXT5_SRGBA;
-#endif
-#endif
-#if FEATURE_EXT_texture_sRGB
- case MESA_FORMAT_SLA8:
- return PIPE_FORMAT_L8A8_SRGB;
- case MESA_FORMAT_SL8:
- return PIPE_FORMAT_L8_SRGB;
- case MESA_FORMAT_SRGB8:
- return PIPE_FORMAT_R8G8B8_SRGB;
- case MESA_FORMAT_SRGBA8:
- return PIPE_FORMAT_A8B8G8R8_SRGB;
- case MESA_FORMAT_SARGB8:
- return PIPE_FORMAT_B8G8R8A8_SRGB;
-#endif
- case MESA_FORMAT_R8:
- return PIPE_FORMAT_R8_UNORM;
- case MESA_FORMAT_R16:
- return PIPE_FORMAT_R16_UNORM;
- case MESA_FORMAT_RG88:
- return PIPE_FORMAT_R8G8_UNORM;
- case MESA_FORMAT_RG1616:
- return PIPE_FORMAT_R16G16_UNORM;
- case MESA_FORMAT_RGBA_16:
- return PIPE_FORMAT_R16G16B16A16_UNORM;
-
- /* signed int formats */
- case MESA_FORMAT_RGBA_INT8:
- return PIPE_FORMAT_R8G8B8A8_SSCALED;
- case MESA_FORMAT_RGBA_INT16:
- return PIPE_FORMAT_R16G16B16A16_SSCALED;
- case MESA_FORMAT_RGBA_INT32:
- return PIPE_FORMAT_R32G32B32A32_SSCALED;
-
- /* unsigned int formats */
- case MESA_FORMAT_RGBA_UINT8:
- return PIPE_FORMAT_R8G8B8A8_USCALED;
- case MESA_FORMAT_RGBA_UINT16:
- return PIPE_FORMAT_R16G16B16A16_USCALED;
- case MESA_FORMAT_RGBA_UINT32:
- return PIPE_FORMAT_R32G32B32A32_USCALED;
-
- default:
- assert(0);
- return PIPE_FORMAT_NONE;
- }
-}
-
-
-/**
- * Translate Gallium format to Mesa format.
- */
-gl_format
-st_pipe_format_to_mesa_format(enum pipe_format format)
-{
- switch (format) {
- case PIPE_FORMAT_A8B8G8R8_UNORM:
- return MESA_FORMAT_RGBA8888;
- case PIPE_FORMAT_R8G8B8A8_UNORM:
- return MESA_FORMAT_RGBA8888_REV;
- case PIPE_FORMAT_B8G8R8A8_UNORM:
- return MESA_FORMAT_ARGB8888;
- case PIPE_FORMAT_A8R8G8B8_UNORM:
- return MESA_FORMAT_ARGB8888_REV;
- case PIPE_FORMAT_B8G8R8X8_UNORM:
- return MESA_FORMAT_XRGB8888;
- case PIPE_FORMAT_X8R8G8B8_UNORM:
- return MESA_FORMAT_XRGB8888_REV;
- case PIPE_FORMAT_B5G5R5A1_UNORM:
- return MESA_FORMAT_ARGB1555;
- case PIPE_FORMAT_B4G4R4A4_UNORM:
- return MESA_FORMAT_ARGB4444;
- case PIPE_FORMAT_B5G6R5_UNORM:
- return MESA_FORMAT_RGB565;
- case PIPE_FORMAT_B2G3R3_UNORM:
- return MESA_FORMAT_RGB332;
- case PIPE_FORMAT_B10G10R10A2_UNORM:
- return MESA_FORMAT_ARGB2101010;
- case PIPE_FORMAT_L4A4_UNORM:
- return MESA_FORMAT_AL44;
- case PIPE_FORMAT_L8A8_UNORM:
- return MESA_FORMAT_AL88;
- case PIPE_FORMAT_L16A16_UNORM:
- return MESA_FORMAT_AL1616;
- case PIPE_FORMAT_A8_UNORM:
- return MESA_FORMAT_A8;
- case PIPE_FORMAT_A16_UNORM:
- return MESA_FORMAT_A16;
- case PIPE_FORMAT_L8_UNORM:
- return MESA_FORMAT_L8;
- case PIPE_FORMAT_L16_UNORM:
- return MESA_FORMAT_L16;
- case PIPE_FORMAT_I8_UNORM:
- return MESA_FORMAT_I8;
- case PIPE_FORMAT_I16_UNORM:
- return MESA_FORMAT_I16;
- case PIPE_FORMAT_S8_USCALED:
- return MESA_FORMAT_S8;
-
- case PIPE_FORMAT_R16G16B16A16_UNORM:
- return MESA_FORMAT_RGBA_16;
- case PIPE_FORMAT_R16G16B16A16_SNORM:
- return MESA_FORMAT_SIGNED_RGBA_16;
-
- case PIPE_FORMAT_Z16_UNORM:
- return MESA_FORMAT_Z16;
- case PIPE_FORMAT_Z32_UNORM:
- return MESA_FORMAT_Z32;
- case PIPE_FORMAT_S8_USCALED_Z24_UNORM:
- return MESA_FORMAT_Z24_S8;
- case PIPE_FORMAT_X8Z24_UNORM:
- return MESA_FORMAT_Z24_X8;
- case PIPE_FORMAT_Z24X8_UNORM:
- return MESA_FORMAT_X8_Z24;
- case PIPE_FORMAT_Z24_UNORM_S8_USCALED:
- return MESA_FORMAT_S8_Z24;
-
- case PIPE_FORMAT_UYVY:
- return MESA_FORMAT_YCBCR;
- case PIPE_FORMAT_YUYV:
- return MESA_FORMAT_YCBCR_REV;
-
-#if FEATURE_texture_s3tc
- case PIPE_FORMAT_DXT1_RGB:
- return MESA_FORMAT_RGB_DXT1;
- case PIPE_FORMAT_DXT1_RGBA:
- return MESA_FORMAT_RGBA_DXT1;
- case PIPE_FORMAT_DXT3_RGBA:
- return MESA_FORMAT_RGBA_DXT3;
- case PIPE_FORMAT_DXT5_RGBA:
- return MESA_FORMAT_RGBA_DXT5;
-#if FEATURE_EXT_texture_sRGB
- case PIPE_FORMAT_DXT1_SRGB:
- return MESA_FORMAT_SRGB_DXT1;
- case PIPE_FORMAT_DXT1_SRGBA:
- return MESA_FORMAT_SRGBA_DXT1;
- case PIPE_FORMAT_DXT3_SRGBA:
- return MESA_FORMAT_SRGBA_DXT3;
- case PIPE_FORMAT_DXT5_SRGBA:
- return MESA_FORMAT_SRGBA_DXT5;
-#endif
-#endif
-
-#if FEATURE_EXT_texture_sRGB
- case PIPE_FORMAT_L8A8_SRGB:
- return MESA_FORMAT_SLA8;
- case PIPE_FORMAT_L8_SRGB:
- return MESA_FORMAT_SL8;
- case PIPE_FORMAT_R8G8B8_SRGB:
- return MESA_FORMAT_SRGB8;
- case PIPE_FORMAT_A8B8G8R8_SRGB:
- return MESA_FORMAT_SRGBA8;
- case PIPE_FORMAT_B8G8R8A8_SRGB:
- return MESA_FORMAT_SARGB8;
-#endif
-
- case PIPE_FORMAT_R8_UNORM:
- return MESA_FORMAT_R8;
- case PIPE_FORMAT_R16_UNORM:
- return MESA_FORMAT_R16;
- case PIPE_FORMAT_R8G8_UNORM:
- return MESA_FORMAT_RG88;
- case PIPE_FORMAT_R16G16_UNORM:
- return MESA_FORMAT_RG1616;
-
- /* signed int formats */
- case PIPE_FORMAT_R8G8B8A8_SSCALED:
- return MESA_FORMAT_RGBA_INT8;
- case PIPE_FORMAT_R16G16B16A16_SSCALED:
- return MESA_FORMAT_RGBA_INT16;
- case PIPE_FORMAT_R32G32B32A32_SSCALED:
- return MESA_FORMAT_RGBA_INT32;
-
- /* unsigned int formats */
- case PIPE_FORMAT_R8G8B8A8_USCALED:
- return MESA_FORMAT_RGBA_UINT8;
- case PIPE_FORMAT_R16G16B16A16_USCALED:
- return MESA_FORMAT_RGBA_UINT16;
- case PIPE_FORMAT_R32G32B32A32_USCALED:
- return MESA_FORMAT_RGBA_UINT32;
-
- default:
- assert(0);
- return MESA_FORMAT_NONE;
- }
-}
-
-
-/**
- * Return first supported format from the given list.
- */
-static enum pipe_format
-find_supported_format(struct pipe_screen *screen,
- const enum pipe_format formats[],
- uint num_formats,
- enum pipe_texture_target target,
- unsigned sample_count,
- unsigned tex_usage,
- unsigned geom_flags)
-{
- uint i;
- for (i = 0; i < num_formats; i++) {
- if (screen->is_format_supported(screen, formats[i], target,
- sample_count, tex_usage, geom_flags)) {
- return formats[i];
- }
- }
- return PIPE_FORMAT_NONE;
-}
-
-
-/**
- * Find an RGBA format supported by the context/winsys.
- */
-static enum pipe_format
-default_rgba_format(struct pipe_screen *screen,
- enum pipe_texture_target target,
- unsigned sample_count,
- unsigned tex_usage,
- unsigned geom_flags)
-{
- static const enum pipe_format colorFormats[] = {
- PIPE_FORMAT_B8G8R8A8_UNORM,
- PIPE_FORMAT_A8R8G8B8_UNORM,
- PIPE_FORMAT_A8B8G8R8_UNORM,
- PIPE_FORMAT_B5G6R5_UNORM
- };
- return find_supported_format(screen, colorFormats, Elements(colorFormats),
- target, sample_count, tex_usage, geom_flags);
-}
-
-
-/**
- * Find an RGB format supported by the context/winsys.
- */
-static enum pipe_format
-default_rgb_format(struct pipe_screen *screen,
- enum pipe_texture_target target,
- unsigned sample_count,
- unsigned tex_usage,
- unsigned geom_flags)
-{
- static const enum pipe_format colorFormats[] = {
- PIPE_FORMAT_B8G8R8X8_UNORM,
- PIPE_FORMAT_X8R8G8B8_UNORM,
- PIPE_FORMAT_X8B8G8R8_UNORM,
- PIPE_FORMAT_B8G8R8A8_UNORM,
- PIPE_FORMAT_A8R8G8B8_UNORM,
- PIPE_FORMAT_A8B8G8R8_UNORM,
- PIPE_FORMAT_B5G6R5_UNORM
- };
- return find_supported_format(screen, colorFormats, Elements(colorFormats),
- target, sample_count, tex_usage, geom_flags);
-}
-
-/**
- * Find an sRGBA format supported by the context/winsys.
- */
-static enum pipe_format
-default_srgba_format(struct pipe_screen *screen,
- enum pipe_texture_target target,
- unsigned sample_count,
- unsigned tex_usage,
- unsigned geom_flags)
-{
- static const enum pipe_format colorFormats[] = {
- PIPE_FORMAT_B8G8R8A8_SRGB,
- PIPE_FORMAT_A8R8G8B8_SRGB,
- PIPE_FORMAT_A8B8G8R8_SRGB,
- };
- return find_supported_format(screen, colorFormats, Elements(colorFormats),
- target, sample_count, tex_usage, geom_flags);
-}
-
-
-/**
- * Given an OpenGL internalFormat value for a texture or surface, return
- * the best matching PIPE_FORMAT_x, or PIPE_FORMAT_NONE if there's no match.
- * This is called during glTexImage2D, for example.
- *
- * The bindings parameter typically has PIPE_BIND_SAMPLER_VIEW set, plus
- * either PIPE_BINDING_RENDER_TARGET or PIPE_BINDING_DEPTH_STENCIL if
- * we want render-to-texture ability.
- *
- * \param internalFormat the user value passed to glTexImage2D
- * \param target one of PIPE_TEXTURE_x
- * \param bindings bitmask of PIPE_BIND_x flags.
- */
-enum pipe_format
-st_choose_format(struct pipe_screen *screen, GLenum internalFormat,
- enum pipe_texture_target target, unsigned sample_count,
- unsigned bindings)
-{
- unsigned geom_flags = 0; /* we don't care about POT vs. NPOT here, yet */
-
- switch (internalFormat) {
- case GL_RGB10:
- case GL_RGB10_A2:
- if (screen->is_format_supported( screen, PIPE_FORMAT_B10G10R10A2_UNORM,
- target, sample_count, bindings,
- geom_flags ))
- return PIPE_FORMAT_B10G10R10A2_UNORM;
- /* Pass through. */
- case 4:
- case GL_RGBA:
- case GL_RGBA8:
- return default_rgba_format( screen, target, sample_count, bindings,
- geom_flags );
-
- case 3:
- case GL_RGB:
- case GL_RGB8:
- return default_rgb_format( screen, target, sample_count, bindings,
- geom_flags );
-
- case GL_RGB12:
- case GL_RGB16:
- case GL_RGBA12:
- case GL_RGBA16:
- if (screen->is_format_supported( screen, PIPE_FORMAT_R16G16B16A16_UNORM,
- target, sample_count, bindings,
- geom_flags ))
- return PIPE_FORMAT_R16G16B16A16_UNORM;
- return default_rgba_format( screen, target, sample_count, bindings,
- geom_flags );
-
- case GL_RGBA4:
- case GL_RGBA2:
- if (screen->is_format_supported( screen, PIPE_FORMAT_B4G4R4A4_UNORM,
- target, sample_count, bindings,
- geom_flags ))
- return PIPE_FORMAT_B4G4R4A4_UNORM;
- return default_rgba_format( screen, target, sample_count, bindings,
- geom_flags );
-
- case GL_RGB5_A1:
- if (screen->is_format_supported( screen, PIPE_FORMAT_B5G5R5A1_UNORM,
- target, sample_count, bindings,
- geom_flags ))
- return PIPE_FORMAT_B5G5R5A1_UNORM;
- return default_rgba_format( screen, target, sample_count, bindings,
- geom_flags );
-
- case GL_R3_G3_B2:
- if (screen->is_format_supported( screen, PIPE_FORMAT_B2G3R3_UNORM,
- target, sample_count, bindings,
- geom_flags ))
- return PIPE_FORMAT_B2G3R3_UNORM;
- /* Pass through. */
- case GL_RGB5:
- case GL_RGB4:
- if (screen->is_format_supported( screen, PIPE_FORMAT_B5G6R5_UNORM,
- target, sample_count, bindings,
- geom_flags ))
- return PIPE_FORMAT_B5G6R5_UNORM;
- if (screen->is_format_supported( screen, PIPE_FORMAT_B5G5R5A1_UNORM,
- target, sample_count, bindings,
- geom_flags ))
- return PIPE_FORMAT_B5G5R5A1_UNORM;
- return default_rgba_format( screen, target, sample_count, bindings,
- geom_flags );
-
- case GL_ALPHA12:
- case GL_ALPHA16:
- if (screen->is_format_supported( screen, PIPE_FORMAT_A16_UNORM, target,
- sample_count, bindings, geom_flags ))
- return PIPE_FORMAT_A16_UNORM;
- /* Pass through. */
- case GL_ALPHA:
- case GL_ALPHA4:
- case GL_ALPHA8:
- case GL_COMPRESSED_ALPHA:
- if (screen->is_format_supported( screen, PIPE_FORMAT_A8_UNORM, target,
- sample_count, bindings, geom_flags ))
- return PIPE_FORMAT_A8_UNORM;
- return default_rgba_format( screen, target, sample_count, bindings,
- geom_flags );
-
- case GL_LUMINANCE12:
- case GL_LUMINANCE16:
- if (screen->is_format_supported( screen, PIPE_FORMAT_L16_UNORM, target,
- sample_count, bindings, geom_flags ))
- return PIPE_FORMAT_L16_UNORM;
- /* Pass through. */
- case 1:
- case GL_LUMINANCE:
- case GL_LUMINANCE4:
- case GL_LUMINANCE8:
- case GL_COMPRESSED_LUMINANCE:
- if (screen->is_format_supported( screen, PIPE_FORMAT_L8_UNORM, target,
- sample_count, bindings, geom_flags ))
- return PIPE_FORMAT_L8_UNORM;
- return default_rgba_format( screen, target, sample_count, bindings,
- geom_flags );
-
- case GL_LUMINANCE12_ALPHA4:
- case GL_LUMINANCE12_ALPHA12:
- case GL_LUMINANCE16_ALPHA16:
- if (screen->is_format_supported( screen, PIPE_FORMAT_L16A16_UNORM, target,
- sample_count, bindings, geom_flags ))
- return PIPE_FORMAT_L16A16_UNORM;
- /* Pass through. */
- case 2:
- case GL_LUMINANCE_ALPHA:
- case GL_LUMINANCE6_ALPHA2:
- case GL_LUMINANCE8_ALPHA8:
- case GL_COMPRESSED_LUMINANCE_ALPHA:
- if (screen->is_format_supported( screen, PIPE_FORMAT_L8A8_UNORM, target,
- sample_count, bindings, geom_flags ))
- return PIPE_FORMAT_L8A8_UNORM;
- return default_rgba_format( screen, target, sample_count, bindings,
- geom_flags );
-
- case GL_LUMINANCE4_ALPHA4:
- if (screen->is_format_supported( screen, PIPE_FORMAT_L4A4_UNORM, target,
- sample_count, bindings, geom_flags ))
- return PIPE_FORMAT_L4A4_UNORM;
- if (screen->is_format_supported( screen, PIPE_FORMAT_L8A8_UNORM, target,
- sample_count, bindings, geom_flags ))
- return PIPE_FORMAT_L8A8_UNORM;
- return default_rgba_format( screen, target, sample_count, bindings,
- geom_flags );
-
- case GL_INTENSITY12:
- case GL_INTENSITY16:
- if (screen->is_format_supported( screen, PIPE_FORMAT_I16_UNORM, target,
- sample_count, bindings, geom_flags ))
- return PIPE_FORMAT_I16_UNORM;
- /* Pass through. */
- case GL_INTENSITY:
- case GL_INTENSITY4:
- case GL_INTENSITY8:
- case GL_COMPRESSED_INTENSITY:
- if (screen->is_format_supported( screen, PIPE_FORMAT_I8_UNORM, target,
- sample_count, bindings, geom_flags ))
- return PIPE_FORMAT_I8_UNORM;
- return default_rgba_format( screen, target, sample_count, bindings,
- geom_flags );
-
- case GL_YCBCR_MESA:
- if (screen->is_format_supported(screen, PIPE_FORMAT_UYVY, target,
- sample_count, bindings, geom_flags)) {
- return PIPE_FORMAT_UYVY;
- }
- if (screen->is_format_supported(screen, PIPE_FORMAT_YUYV, target,
- sample_count, bindings, geom_flags)) {
- return PIPE_FORMAT_YUYV;
- }
- return PIPE_FORMAT_NONE;
-
- case GL_COMPRESSED_RED:
- case GL_COMPRESSED_RG:
- case GL_COMPRESSED_RGB:
- /* can only sample from compressed formats */
- if (bindings & ~PIPE_BIND_SAMPLER_VIEW)
- return PIPE_FORMAT_NONE;
- else if (screen->is_format_supported(screen, PIPE_FORMAT_DXT1_RGB,
- target, sample_count, bindings,
- geom_flags))
- return PIPE_FORMAT_DXT1_RGB;
- else
- return default_rgb_format(screen, target, sample_count, bindings,
- geom_flags);
-
- case GL_COMPRESSED_RGBA:
- /* can only sample from compressed formats */
- if (bindings & ~PIPE_BIND_SAMPLER_VIEW)
- return PIPE_FORMAT_NONE;
- else if (screen->is_format_supported(screen, PIPE_FORMAT_DXT3_RGBA,
- target, sample_count, bindings,
- geom_flags))
- return PIPE_FORMAT_DXT3_RGBA;
- else
- return default_rgba_format(screen, target, sample_count, bindings,
- geom_flags);
-
- case GL_RGB_S3TC:
- case GL_RGB4_S3TC:
- case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
- if (screen->is_format_supported(screen, PIPE_FORMAT_DXT1_RGB,
- target, sample_count, bindings,
- geom_flags))
- return PIPE_FORMAT_DXT1_RGB;
- else
- return PIPE_FORMAT_NONE;
-
- case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
- if (screen->is_format_supported(screen, PIPE_FORMAT_DXT1_RGBA,
- target, sample_count, bindings,
- geom_flags))
- return PIPE_FORMAT_DXT1_RGBA;
- else
- return PIPE_FORMAT_NONE;
-
- case GL_RGBA_S3TC:
- case GL_RGBA4_S3TC:
- case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
- if (screen->is_format_supported(screen, PIPE_FORMAT_DXT3_RGBA,
- target, sample_count, bindings,
- geom_flags))
- return PIPE_FORMAT_DXT3_RGBA;
- else
- return PIPE_FORMAT_NONE;
-
- case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
- if (screen->is_format_supported(screen, PIPE_FORMAT_DXT5_RGBA,
- target, sample_count, bindings,
- geom_flags))
- return PIPE_FORMAT_DXT5_RGBA;
- else
- return PIPE_FORMAT_NONE;
-
-#if 0
- case GL_COMPRESSED_RGB_FXT1_3DFX:
- return PIPE_FORMAT_RGB_FXT1;
- case GL_COMPRESSED_RGBA_FXT1_3DFX:
- return PIPE_FORMAT_RGB_FXT1;
-#endif
-
- case GL_DEPTH_COMPONENT16:
- if (screen->is_format_supported(screen, PIPE_FORMAT_Z16_UNORM, target,
- sample_count, bindings, geom_flags))
- return PIPE_FORMAT_Z16_UNORM;
- /* fall-through */
- case GL_DEPTH_COMPONENT24:
- if (screen->is_format_supported(screen, PIPE_FORMAT_Z24_UNORM_S8_USCALED,
- target, sample_count, bindings, geom_flags))
- return PIPE_FORMAT_Z24_UNORM_S8_USCALED;
- if (screen->is_format_supported(screen, PIPE_FORMAT_S8_USCALED_Z24_UNORM,
- target, sample_count, bindings, geom_flags))
- return PIPE_FORMAT_S8_USCALED_Z24_UNORM;
- /* fall-through */
- case GL_DEPTH_COMPONENT32:
- if (screen->is_format_supported(screen, PIPE_FORMAT_Z32_UNORM, target,
- sample_count, bindings, geom_flags))
- return PIPE_FORMAT_Z32_UNORM;
- /* fall-through */
- case GL_DEPTH_COMPONENT:
- {
- static const enum pipe_format formats[] = {
- PIPE_FORMAT_Z32_UNORM,
- PIPE_FORMAT_Z24_UNORM_S8_USCALED,
- PIPE_FORMAT_S8_USCALED_Z24_UNORM,
- PIPE_FORMAT_Z16_UNORM
- };
- return find_supported_format(screen, formats, Elements(formats),
- target, sample_count, bindings, geom_flags);
- }
-
- case GL_STENCIL_INDEX:
- case GL_STENCIL_INDEX1_EXT:
- case GL_STENCIL_INDEX4_EXT:
- case GL_STENCIL_INDEX8_EXT:
- case GL_STENCIL_INDEX16_EXT:
- {
- static const enum pipe_format formats[] = {
- PIPE_FORMAT_S8_USCALED,
- PIPE_FORMAT_Z24_UNORM_S8_USCALED,
- PIPE_FORMAT_S8_USCALED_Z24_UNORM
- };
- return find_supported_format(screen, formats, Elements(formats),
- target, sample_count, bindings, geom_flags);
- }
-
- case GL_DEPTH_STENCIL_EXT:
- case GL_DEPTH24_STENCIL8_EXT:
- {
- static const enum pipe_format formats[] = {
- PIPE_FORMAT_Z24_UNORM_S8_USCALED,
- PIPE_FORMAT_S8_USCALED_Z24_UNORM
- };
- return find_supported_format(screen, formats, Elements(formats),
- target, sample_count, bindings, geom_flags);
- }
-
- case GL_SRGB_EXT:
- case GL_SRGB8_EXT:
- case GL_SRGB_ALPHA_EXT:
- case GL_SRGB8_ALPHA8_EXT:
- return default_srgba_format( screen, target, sample_count, bindings,
- geom_flags );
-
- case GL_COMPRESSED_SRGB_EXT:
- case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT:
- if (screen->is_format_supported(screen, PIPE_FORMAT_DXT1_SRGB, target,
- sample_count, bindings, geom_flags))
- return PIPE_FORMAT_DXT1_SRGB;
- return default_srgba_format( screen, target, sample_count, bindings,
- geom_flags );
-
- case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:
- return PIPE_FORMAT_DXT1_SRGBA;
-
- case GL_COMPRESSED_SRGB_ALPHA_EXT:
- case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT:
- if (screen->is_format_supported(screen, PIPE_FORMAT_DXT3_SRGBA, target,
- sample_count, bindings, geom_flags))
- return PIPE_FORMAT_DXT3_SRGBA;
- return default_srgba_format( screen, target, sample_count, bindings,
- geom_flags );
-
- case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT:
- return PIPE_FORMAT_DXT5_SRGBA;
-
- case GL_SLUMINANCE_ALPHA_EXT:
- case GL_SLUMINANCE8_ALPHA8_EXT:
- case GL_COMPRESSED_SLUMINANCE_EXT:
- case GL_COMPRESSED_SLUMINANCE_ALPHA_EXT:
- if (screen->is_format_supported(screen, PIPE_FORMAT_L8A8_SRGB, target,
- sample_count, bindings, geom_flags))
- return PIPE_FORMAT_L8A8_SRGB;
- return default_srgba_format( screen, target, sample_count, bindings,
- geom_flags );
-
- case GL_SLUMINANCE_EXT:
- case GL_SLUMINANCE8_EXT:
- if (screen->is_format_supported(screen, PIPE_FORMAT_L8_SRGB, target,
- sample_count, bindings, geom_flags))
- return PIPE_FORMAT_L8_SRGB;
- return default_srgba_format( screen, target, sample_count, bindings,
- geom_flags );
-
- case GL_RED:
- case GL_R8:
- if (screen->is_format_supported(screen, PIPE_FORMAT_R8_UNORM, target,
- sample_count, bindings, geom_flags))
- return PIPE_FORMAT_R8_UNORM;
- return PIPE_FORMAT_NONE;
- case GL_RG:
- case GL_RG8:
- if (screen->is_format_supported(screen, PIPE_FORMAT_R8G8_UNORM, target,
- sample_count, bindings, geom_flags))
- return PIPE_FORMAT_R8G8_UNORM;
- return PIPE_FORMAT_NONE;
-
- case GL_R16:
- if (screen->is_format_supported(screen, PIPE_FORMAT_R16_UNORM, target,
- sample_count, bindings, geom_flags))
- return PIPE_FORMAT_R16_UNORM;
- return PIPE_FORMAT_NONE;
-
- case GL_RG16:
- if (screen->is_format_supported(screen, PIPE_FORMAT_R16G16_UNORM, target,
- sample_count, bindings, geom_flags))
- return PIPE_FORMAT_R16G16_UNORM;
- return PIPE_FORMAT_NONE;
-
- case GL_COMPRESSED_RED_RGTC1:
- if (screen->is_format_supported(screen, PIPE_FORMAT_RGTC1_UNORM, target,
- sample_count, bindings, geom_flags))
- return PIPE_FORMAT_RGTC1_UNORM;
- return PIPE_FORMAT_NONE;
-
- case GL_COMPRESSED_SIGNED_RED_RGTC1:
- if (screen->is_format_supported(screen, PIPE_FORMAT_RGTC1_SNORM, target,
- sample_count, bindings, geom_flags))
- return PIPE_FORMAT_RGTC1_SNORM;
- return PIPE_FORMAT_NONE;
-
- case GL_COMPRESSED_RG_RGTC2:
- if (screen->is_format_supported(screen, PIPE_FORMAT_RGTC2_UNORM, target,
- sample_count, bindings, geom_flags))
- return PIPE_FORMAT_RGTC2_UNORM;
- return PIPE_FORMAT_NONE;
-
- case GL_COMPRESSED_SIGNED_RG_RGTC2:
- if (screen->is_format_supported(screen, PIPE_FORMAT_RGTC2_SNORM, target,
- sample_count, bindings, geom_flags))
- return PIPE_FORMAT_RGTC2_SNORM;
- return PIPE_FORMAT_NONE;
-
- /* signed/unsigned integer formats.
- * XXX Mesa only has formats for RGBA signed/unsigned integer formats.
- * If/when new formats are added this code should be updated.
- */
- case GL_RED_INTEGER_EXT:
- case GL_GREEN_INTEGER_EXT:
- case GL_BLUE_INTEGER_EXT:
- case GL_ALPHA_INTEGER_EXT:
- case GL_RGB_INTEGER_EXT:
- case GL_RGBA_INTEGER_EXT:
- case GL_BGR_INTEGER_EXT:
- case GL_BGRA_INTEGER_EXT:
- case GL_LUMINANCE_INTEGER_EXT:
- case GL_LUMINANCE_ALPHA_INTEGER_EXT:
- /* fall-through */
- case GL_RGBA8I_EXT:
- case GL_RGB8I_EXT:
- case GL_ALPHA8I_EXT:
- case GL_INTENSITY8I_EXT:
- case GL_LUMINANCE8I_EXT:
- case GL_LUMINANCE_ALPHA8I_EXT:
- if (screen->is_format_supported(screen, PIPE_FORMAT_R8G8B8A8_SSCALED,
- target,
- sample_count, bindings, geom_flags))
- return PIPE_FORMAT_R8G8B8A8_SSCALED;
- return PIPE_FORMAT_NONE;
- case GL_RGBA16I_EXT:
- case GL_RGB16I_EXT:
- case GL_ALPHA16I_EXT:
- case GL_INTENSITY16I_EXT:
- case GL_LUMINANCE16I_EXT:
- case GL_LUMINANCE_ALPHA16I_EXT:
- if (screen->is_format_supported(screen, PIPE_FORMAT_R16G16B16A16_SSCALED,
- target,
- sample_count, bindings, geom_flags))
- return PIPE_FORMAT_R16G16B16A16_SSCALED;
- return PIPE_FORMAT_NONE;
- case GL_RGBA32I_EXT:
- case GL_RGB32I_EXT:
- case GL_ALPHA32I_EXT:
- case GL_INTENSITY32I_EXT:
- case GL_LUMINANCE32I_EXT:
- case GL_LUMINANCE_ALPHA32I_EXT:
- /* xxx */
- if (screen->is_format_supported(screen, PIPE_FORMAT_R32G32B32A32_SSCALED,
- target,
- sample_count, bindings, geom_flags))
- return PIPE_FORMAT_R32G32B32A32_SSCALED;
- return PIPE_FORMAT_NONE;
-
- case GL_RGBA8UI_EXT:
- case GL_RGB8UI_EXT:
- case GL_ALPHA8UI_EXT:
- case GL_INTENSITY8UI_EXT:
- case GL_LUMINANCE8UI_EXT:
- case GL_LUMINANCE_ALPHA8UI_EXT:
- if (screen->is_format_supported(screen, PIPE_FORMAT_R8G8B8A8_USCALED,
- target,
- sample_count, bindings, geom_flags))
- return PIPE_FORMAT_R8G8B8A8_USCALED;
- return PIPE_FORMAT_NONE;
-
- case GL_RGBA16UI_EXT:
- case GL_RGB16UI_EXT:
- case GL_ALPHA16UI_EXT:
- case GL_INTENSITY16UI_EXT:
- case GL_LUMINANCE16UI_EXT:
- case GL_LUMINANCE_ALPHA16UI_EXT:
- if (screen->is_format_supported(screen, PIPE_FORMAT_R16G16B16A16_USCALED,
- target,
- sample_count, bindings, geom_flags))
- return PIPE_FORMAT_R16G16B16A16_USCALED;
- return PIPE_FORMAT_NONE;
-
- case GL_RGBA32UI_EXT:
- case GL_RGB32UI_EXT:
- case GL_ALPHA32UI_EXT:
- case GL_INTENSITY32UI_EXT:
- case GL_LUMINANCE32UI_EXT:
- case GL_LUMINANCE_ALPHA32UI_EXT:
- if (screen->is_format_supported(screen, PIPE_FORMAT_R32G32B32A32_USCALED,
- target,
- sample_count, bindings, geom_flags))
- return PIPE_FORMAT_R32G32B32A32_USCALED;
- return PIPE_FORMAT_NONE;
-
- default:
- return PIPE_FORMAT_NONE;
- }
-}
-
-
-/**
- * Called by FBO code to choose a PIPE_FORMAT_ for drawing surfaces.
- */
-enum pipe_format
-st_choose_renderbuffer_format(struct pipe_screen *screen,
- GLenum internalFormat, unsigned sample_count)
-{
- uint usage;
- if (_mesa_is_depth_or_stencil_format(internalFormat))
- usage = PIPE_BIND_DEPTH_STENCIL;
- else
- usage = PIPE_BIND_RENDER_TARGET;
- return st_choose_format(screen, internalFormat, PIPE_TEXTURE_2D,
- sample_count, usage);
-}
-
-
-/**
- * Called via ctx->Driver.chooseTextureFormat().
- */
-gl_format
-st_ChooseTextureFormat_renderable(struct gl_context *ctx, GLint internalFormat,
- GLenum format, GLenum type, GLboolean renderable)
-{
- struct pipe_screen *screen = st_context(ctx)->pipe->screen;
- enum pipe_format pFormat;
- uint bindings;
-
- (void) format;
- (void) type;
-
- /* GL textures may wind up being render targets, but we don't know
- * that in advance. Specify potential render target flags now.
- */
- bindings = PIPE_BIND_SAMPLER_VIEW;
- if (renderable == GL_TRUE) {
- if (_mesa_is_depth_format(internalFormat) ||
- _mesa_is_depth_or_stencil_format(internalFormat))
- bindings |= PIPE_BIND_DEPTH_STENCIL;
- else
- bindings |= PIPE_BIND_RENDER_TARGET;
- }
-
- pFormat = st_choose_format(screen, internalFormat,
- PIPE_TEXTURE_2D, 0, bindings);
-
- if (pFormat == PIPE_FORMAT_NONE) {
- /* try choosing format again, this time without render target bindings */
- pFormat = st_choose_format(screen, internalFormat,
- PIPE_TEXTURE_2D, 0, PIPE_BIND_SAMPLER_VIEW);
- }
-
- if (pFormat == PIPE_FORMAT_NONE) {
- /* no luck at all */
- return MESA_FORMAT_NONE;
- }
-
- return st_pipe_format_to_mesa_format(pFormat);
-}
-
-gl_format
-st_ChooseTextureFormat(struct gl_context *ctx, GLint internalFormat,
- GLenum format, GLenum type)
-{
- boolean want_renderable =
- internalFormat == 3 || internalFormat == 4 ||
- internalFormat == GL_RGB || internalFormat == GL_RGBA ||
- internalFormat == GL_RGB8 || internalFormat == GL_RGBA8;
-
- return st_ChooseTextureFormat_renderable(ctx, internalFormat,
- format, type, want_renderable);
-}
-
-/**
- * Test if a gallium format is equivalent to a GL format/type.
- */
-GLboolean
-st_equal_formats(enum pipe_format pFormat, GLenum format, GLenum type)
-{
- switch (pFormat) {
- case PIPE_FORMAT_A8B8G8R8_UNORM:
- return format == GL_RGBA && type == GL_UNSIGNED_BYTE;
- case PIPE_FORMAT_A8R8G8B8_UNORM:
- return format == GL_BGRA && type == GL_UNSIGNED_BYTE;
- case PIPE_FORMAT_B5G6R5_UNORM:
- return format == GL_RGB && type == GL_UNSIGNED_SHORT_5_6_5;
- /* XXX more combos... */
- default:
- return GL_FALSE;
- }
-}
-
-GLboolean
-st_sampler_compat_formats(enum pipe_format format1, enum pipe_format format2)
-{
- if (format1 == format2)
- return GL_TRUE;
-
- if (format1 == PIPE_FORMAT_B8G8R8A8_UNORM &&
- format2 == PIPE_FORMAT_B8G8R8X8_UNORM)
- return GL_TRUE;
-
- if (format1 == PIPE_FORMAT_B8G8R8X8_UNORM &&
- format2 == PIPE_FORMAT_B8G8R8A8_UNORM)
- return GL_TRUE;
-
- if (format1 == PIPE_FORMAT_A8B8G8R8_UNORM &&
- format2 == PIPE_FORMAT_X8B8G8R8_UNORM)
- return GL_TRUE;
-
- if (format1 == PIPE_FORMAT_X8B8G8R8_UNORM &&
- format2 == PIPE_FORMAT_A8B8G8R8_UNORM)
- return GL_TRUE;
-
- if (format1 == PIPE_FORMAT_A8R8G8B8_UNORM &&
- format2 == PIPE_FORMAT_X8R8G8B8_UNORM)
- return GL_TRUE;
-
- if (format1 == PIPE_FORMAT_X8R8G8B8_UNORM &&
- format2 == PIPE_FORMAT_A8R8G8B8_UNORM)
- return GL_TRUE;
-
- return GL_FALSE;
-}
+/************************************************************************** + * + * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. + * Copyright (c) 2008-2010 VMware, Inc. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + + +/** + * Mesa / Gallium format conversion and format selection code. + * \author Brian Paul + */ + +#include "main/imports.h" +#include "main/context.h" +#include "main/texstore.h" +#include "main/image.h" +#include "main/macros.h" +#include "main/mfeatures.h" + +#include "pipe/p_context.h" +#include "pipe/p_defines.h" +#include "pipe/p_screen.h" +#include "util/u_format.h" +#include "st_context.h" +#include "st_format.h" + + +static GLuint +format_max_bits(enum pipe_format format) +{ + GLuint size = util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, 0); + + size = MAX2(size, util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, 1)); + size = MAX2(size, util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, 2)); + size = MAX2(size, util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, 3)); + size = MAX2(size, util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_ZS, 0)); + size = MAX2(size, util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_ZS, 1)); + return size; +} + + +/** + * Return basic GL datatype for the given gallium format. + */ +GLenum +st_format_datatype(enum pipe_format format) +{ + const struct util_format_description *desc; + + desc = util_format_description(format); + assert(desc); + + if (desc->layout == UTIL_FORMAT_LAYOUT_PLAIN) { + if (format == PIPE_FORMAT_B5G5R5A1_UNORM || + format == PIPE_FORMAT_B5G6R5_UNORM) { + return GL_UNSIGNED_SHORT; + } + else if (format == PIPE_FORMAT_Z24_UNORM_S8_USCALED || + format == PIPE_FORMAT_S8_USCALED_Z24_UNORM || + format == PIPE_FORMAT_Z24X8_UNORM || + format == PIPE_FORMAT_X8Z24_UNORM) { + return GL_UNSIGNED_INT_24_8; + } + else { + const GLuint size = format_max_bits(format); + if (size == 8) { + if (desc->channel[0].type == UTIL_FORMAT_TYPE_UNSIGNED) + return GL_UNSIGNED_BYTE; + else + return GL_BYTE; + } + else if (size == 16) { + if (desc->channel[0].type == UTIL_FORMAT_TYPE_UNSIGNED) + return GL_UNSIGNED_SHORT; + else + return GL_SHORT; + } + else { + assert( size <= 32 ); + if (desc->channel[0].type == UTIL_FORMAT_TYPE_UNSIGNED) + return GL_UNSIGNED_INT; + else + return GL_INT; + } + } + } + else if (format == PIPE_FORMAT_UYVY) { + return GL_UNSIGNED_SHORT; + } + else if (format == PIPE_FORMAT_YUYV) { + return GL_UNSIGNED_SHORT; + } + else { + /* compressed format? */ + assert(0); + } + + assert(0); + return GL_NONE; +} + + +/** + * Translate Mesa format to Gallium format. + */ +enum pipe_format +st_mesa_format_to_pipe_format(gl_format mesaFormat) +{ + switch (mesaFormat) { + case MESA_FORMAT_RGBA8888: + return PIPE_FORMAT_A8B8G8R8_UNORM; + case MESA_FORMAT_RGBA8888_REV: + return PIPE_FORMAT_R8G8B8A8_UNORM; + case MESA_FORMAT_ARGB8888: + return PIPE_FORMAT_B8G8R8A8_UNORM; + case MESA_FORMAT_ARGB8888_REV: + return PIPE_FORMAT_A8R8G8B8_UNORM; + case MESA_FORMAT_XRGB8888: + return PIPE_FORMAT_B8G8R8X8_UNORM; + case MESA_FORMAT_XRGB8888_REV: + return PIPE_FORMAT_X8R8G8B8_UNORM; + case MESA_FORMAT_ARGB1555: + return PIPE_FORMAT_B5G5R5A1_UNORM; + case MESA_FORMAT_ARGB4444: + return PIPE_FORMAT_B4G4R4A4_UNORM; + case MESA_FORMAT_RGB565: + return PIPE_FORMAT_B5G6R5_UNORM; + case MESA_FORMAT_RGB332: + return PIPE_FORMAT_B2G3R3_UNORM; + case MESA_FORMAT_ARGB2101010: + return PIPE_FORMAT_B10G10R10A2_UNORM; + case MESA_FORMAT_AL44: + return PIPE_FORMAT_L4A4_UNORM; + case MESA_FORMAT_AL88: + return PIPE_FORMAT_L8A8_UNORM; + case MESA_FORMAT_AL1616: + return PIPE_FORMAT_L16A16_UNORM; + case MESA_FORMAT_A8: + return PIPE_FORMAT_A8_UNORM; + case MESA_FORMAT_A16: + return PIPE_FORMAT_A16_UNORM; + case MESA_FORMAT_L8: + return PIPE_FORMAT_L8_UNORM; + case MESA_FORMAT_L16: + return PIPE_FORMAT_L16_UNORM; + case MESA_FORMAT_I8: + return PIPE_FORMAT_I8_UNORM; + case MESA_FORMAT_I16: + return PIPE_FORMAT_I16_UNORM; + case MESA_FORMAT_Z16: + return PIPE_FORMAT_Z16_UNORM; + case MESA_FORMAT_Z32: + return PIPE_FORMAT_Z32_UNORM; + case MESA_FORMAT_Z24_S8: + return PIPE_FORMAT_S8_USCALED_Z24_UNORM; + case MESA_FORMAT_S8_Z24: + return PIPE_FORMAT_Z24_UNORM_S8_USCALED; + case MESA_FORMAT_Z24_X8: + return PIPE_FORMAT_X8Z24_UNORM; + case MESA_FORMAT_X8_Z24: + return PIPE_FORMAT_Z24X8_UNORM; + case MESA_FORMAT_S8: + return PIPE_FORMAT_S8_USCALED; + case MESA_FORMAT_YCBCR: + return PIPE_FORMAT_UYVY; +#if FEATURE_texture_s3tc + case MESA_FORMAT_RGB_DXT1: + return PIPE_FORMAT_DXT1_RGB; + case MESA_FORMAT_RGBA_DXT1: + return PIPE_FORMAT_DXT1_RGBA; + case MESA_FORMAT_RGBA_DXT3: + return PIPE_FORMAT_DXT3_RGBA; + case MESA_FORMAT_RGBA_DXT5: + return PIPE_FORMAT_DXT5_RGBA; +#if FEATURE_EXT_texture_sRGB + case MESA_FORMAT_SRGB_DXT1: + return PIPE_FORMAT_DXT1_SRGB; + case MESA_FORMAT_SRGBA_DXT1: + return PIPE_FORMAT_DXT1_SRGBA; + case MESA_FORMAT_SRGBA_DXT3: + return PIPE_FORMAT_DXT3_SRGBA; + case MESA_FORMAT_SRGBA_DXT5: + return PIPE_FORMAT_DXT5_SRGBA; +#endif +#endif +#if FEATURE_EXT_texture_sRGB + case MESA_FORMAT_SLA8: + return PIPE_FORMAT_L8A8_SRGB; + case MESA_FORMAT_SL8: + return PIPE_FORMAT_L8_SRGB; + case MESA_FORMAT_SRGB8: + return PIPE_FORMAT_R8G8B8_SRGB; + case MESA_FORMAT_SRGBA8: + return PIPE_FORMAT_A8B8G8R8_SRGB; + case MESA_FORMAT_SARGB8: + return PIPE_FORMAT_B8G8R8A8_SRGB; +#endif + case MESA_FORMAT_R8: + return PIPE_FORMAT_R8_UNORM; + case MESA_FORMAT_R16: + return PIPE_FORMAT_R16_UNORM; + case MESA_FORMAT_RG88: + return PIPE_FORMAT_R8G8_UNORM; + case MESA_FORMAT_RG1616: + return PIPE_FORMAT_R16G16_UNORM; + case MESA_FORMAT_RGBA_16: + return PIPE_FORMAT_R16G16B16A16_UNORM; + + /* signed int formats */ + case MESA_FORMAT_RGBA_INT8: + return PIPE_FORMAT_R8G8B8A8_SSCALED; + case MESA_FORMAT_RGBA_INT16: + return PIPE_FORMAT_R16G16B16A16_SSCALED; + case MESA_FORMAT_RGBA_INT32: + return PIPE_FORMAT_R32G32B32A32_SSCALED; + + /* unsigned int formats */ + case MESA_FORMAT_RGBA_UINT8: + return PIPE_FORMAT_R8G8B8A8_USCALED; + case MESA_FORMAT_RGBA_UINT16: + return PIPE_FORMAT_R16G16B16A16_USCALED; + case MESA_FORMAT_RGBA_UINT32: + return PIPE_FORMAT_R32G32B32A32_USCALED; + + default: + assert(0); + return PIPE_FORMAT_NONE; + } +} + + +/** + * Translate Gallium format to Mesa format. + */ +gl_format +st_pipe_format_to_mesa_format(enum pipe_format format) +{ + switch (format) { + case PIPE_FORMAT_A8B8G8R8_UNORM: + return MESA_FORMAT_RGBA8888; + case PIPE_FORMAT_R8G8B8A8_UNORM: + return MESA_FORMAT_RGBA8888_REV; + case PIPE_FORMAT_B8G8R8A8_UNORM: + return MESA_FORMAT_ARGB8888; + case PIPE_FORMAT_A8R8G8B8_UNORM: + return MESA_FORMAT_ARGB8888_REV; + case PIPE_FORMAT_B8G8R8X8_UNORM: + return MESA_FORMAT_XRGB8888; + case PIPE_FORMAT_X8R8G8B8_UNORM: + return MESA_FORMAT_XRGB8888_REV; + case PIPE_FORMAT_B5G5R5A1_UNORM: + return MESA_FORMAT_ARGB1555; + case PIPE_FORMAT_B4G4R4A4_UNORM: + return MESA_FORMAT_ARGB4444; + case PIPE_FORMAT_B5G6R5_UNORM: + return MESA_FORMAT_RGB565; + case PIPE_FORMAT_B2G3R3_UNORM: + return MESA_FORMAT_RGB332; + case PIPE_FORMAT_B10G10R10A2_UNORM: + return MESA_FORMAT_ARGB2101010; + case PIPE_FORMAT_L4A4_UNORM: + return MESA_FORMAT_AL44; + case PIPE_FORMAT_L8A8_UNORM: + return MESA_FORMAT_AL88; + case PIPE_FORMAT_L16A16_UNORM: + return MESA_FORMAT_AL1616; + case PIPE_FORMAT_A8_UNORM: + return MESA_FORMAT_A8; + case PIPE_FORMAT_A16_UNORM: + return MESA_FORMAT_A16; + case PIPE_FORMAT_L8_UNORM: + return MESA_FORMAT_L8; + case PIPE_FORMAT_L16_UNORM: + return MESA_FORMAT_L16; + case PIPE_FORMAT_I8_UNORM: + return MESA_FORMAT_I8; + case PIPE_FORMAT_I16_UNORM: + return MESA_FORMAT_I16; + case PIPE_FORMAT_S8_USCALED: + return MESA_FORMAT_S8; + + case PIPE_FORMAT_R16G16B16A16_UNORM: + return MESA_FORMAT_RGBA_16; + case PIPE_FORMAT_R16G16B16A16_SNORM: + return MESA_FORMAT_SIGNED_RGBA_16; + + case PIPE_FORMAT_Z16_UNORM: + return MESA_FORMAT_Z16; + case PIPE_FORMAT_Z32_UNORM: + return MESA_FORMAT_Z32; + case PIPE_FORMAT_S8_USCALED_Z24_UNORM: + return MESA_FORMAT_Z24_S8; + case PIPE_FORMAT_X8Z24_UNORM: + return MESA_FORMAT_Z24_X8; + case PIPE_FORMAT_Z24X8_UNORM: + return MESA_FORMAT_X8_Z24; + case PIPE_FORMAT_Z24_UNORM_S8_USCALED: + return MESA_FORMAT_S8_Z24; + + case PIPE_FORMAT_UYVY: + return MESA_FORMAT_YCBCR; + case PIPE_FORMAT_YUYV: + return MESA_FORMAT_YCBCR_REV; + +#if FEATURE_texture_s3tc + case PIPE_FORMAT_DXT1_RGB: + return MESA_FORMAT_RGB_DXT1; + case PIPE_FORMAT_DXT1_RGBA: + return MESA_FORMAT_RGBA_DXT1; + case PIPE_FORMAT_DXT3_RGBA: + return MESA_FORMAT_RGBA_DXT3; + case PIPE_FORMAT_DXT5_RGBA: + return MESA_FORMAT_RGBA_DXT5; +#if FEATURE_EXT_texture_sRGB + case PIPE_FORMAT_DXT1_SRGB: + return MESA_FORMAT_SRGB_DXT1; + case PIPE_FORMAT_DXT1_SRGBA: + return MESA_FORMAT_SRGBA_DXT1; + case PIPE_FORMAT_DXT3_SRGBA: + return MESA_FORMAT_SRGBA_DXT3; + case PIPE_FORMAT_DXT5_SRGBA: + return MESA_FORMAT_SRGBA_DXT5; +#endif +#endif + +#if FEATURE_EXT_texture_sRGB + case PIPE_FORMAT_L8A8_SRGB: + return MESA_FORMAT_SLA8; + case PIPE_FORMAT_L8_SRGB: + return MESA_FORMAT_SL8; + case PIPE_FORMAT_R8G8B8_SRGB: + return MESA_FORMAT_SRGB8; + case PIPE_FORMAT_A8B8G8R8_SRGB: + return MESA_FORMAT_SRGBA8; + case PIPE_FORMAT_B8G8R8A8_SRGB: + return MESA_FORMAT_SARGB8; +#endif + + case PIPE_FORMAT_R8_UNORM: + return MESA_FORMAT_R8; + case PIPE_FORMAT_R16_UNORM: + return MESA_FORMAT_R16; + case PIPE_FORMAT_R8G8_UNORM: + return MESA_FORMAT_RG88; + case PIPE_FORMAT_R16G16_UNORM: + return MESA_FORMAT_RG1616; + + /* signed int formats */ + case PIPE_FORMAT_R8G8B8A8_SSCALED: + return MESA_FORMAT_RGBA_INT8; + case PIPE_FORMAT_R16G16B16A16_SSCALED: + return MESA_FORMAT_RGBA_INT16; + case PIPE_FORMAT_R32G32B32A32_SSCALED: + return MESA_FORMAT_RGBA_INT32; + + /* unsigned int formats */ + case PIPE_FORMAT_R8G8B8A8_USCALED: + return MESA_FORMAT_RGBA_UINT8; + case PIPE_FORMAT_R16G16B16A16_USCALED: + return MESA_FORMAT_RGBA_UINT16; + case PIPE_FORMAT_R32G32B32A32_USCALED: + return MESA_FORMAT_RGBA_UINT32; + + default: + assert(0); + return MESA_FORMAT_NONE; + } +} + + +/** + * Return first supported format from the given list. + */ +static enum pipe_format +find_supported_format(struct pipe_screen *screen, + const enum pipe_format formats[], + uint num_formats, + enum pipe_texture_target target, + unsigned sample_count, + unsigned tex_usage, + unsigned geom_flags) +{ + uint i; + for (i = 0; i < num_formats; i++) { + if (screen->is_format_supported(screen, formats[i], target, + sample_count, tex_usage, geom_flags)) { + return formats[i]; + } + } + return PIPE_FORMAT_NONE; +} + + +/** + * Find an RGBA format supported by the context/winsys. + */ +static enum pipe_format +default_rgba_format(struct pipe_screen *screen, + enum pipe_texture_target target, + unsigned sample_count, + unsigned tex_usage, + unsigned geom_flags) +{ + static const enum pipe_format colorFormats[] = { + PIPE_FORMAT_B8G8R8A8_UNORM, + PIPE_FORMAT_A8R8G8B8_UNORM, + PIPE_FORMAT_A8B8G8R8_UNORM, + PIPE_FORMAT_B5G6R5_UNORM + }; + return find_supported_format(screen, colorFormats, Elements(colorFormats), + target, sample_count, tex_usage, geom_flags); +} + + +/** + * Find an RGB format supported by the context/winsys. + */ +static enum pipe_format +default_rgb_format(struct pipe_screen *screen, + enum pipe_texture_target target, + unsigned sample_count, + unsigned tex_usage, + unsigned geom_flags) +{ + static const enum pipe_format colorFormats[] = { + PIPE_FORMAT_B8G8R8X8_UNORM, + PIPE_FORMAT_X8R8G8B8_UNORM, + PIPE_FORMAT_X8B8G8R8_UNORM, + PIPE_FORMAT_B8G8R8A8_UNORM, + PIPE_FORMAT_A8R8G8B8_UNORM, + PIPE_FORMAT_A8B8G8R8_UNORM, + PIPE_FORMAT_B5G6R5_UNORM + }; + return find_supported_format(screen, colorFormats, Elements(colorFormats), + target, sample_count, tex_usage, geom_flags); +} + +/** + * Find an sRGBA format supported by the context/winsys. + */ +static enum pipe_format +default_srgba_format(struct pipe_screen *screen, + enum pipe_texture_target target, + unsigned sample_count, + unsigned tex_usage, + unsigned geom_flags) +{ + static const enum pipe_format colorFormats[] = { + PIPE_FORMAT_B8G8R8A8_SRGB, + PIPE_FORMAT_A8R8G8B8_SRGB, + PIPE_FORMAT_A8B8G8R8_SRGB, + }; + return find_supported_format(screen, colorFormats, Elements(colorFormats), + target, sample_count, tex_usage, geom_flags); +} + + +/** + * Given an OpenGL internalFormat value for a texture or surface, return + * the best matching PIPE_FORMAT_x, or PIPE_FORMAT_NONE if there's no match. + * This is called during glTexImage2D, for example. + * + * The bindings parameter typically has PIPE_BIND_SAMPLER_VIEW set, plus + * either PIPE_BINDING_RENDER_TARGET or PIPE_BINDING_DEPTH_STENCIL if + * we want render-to-texture ability. + * + * \param internalFormat the user value passed to glTexImage2D + * \param target one of PIPE_TEXTURE_x + * \param bindings bitmask of PIPE_BIND_x flags. + */ +enum pipe_format +st_choose_format(struct pipe_screen *screen, GLenum internalFormat, + enum pipe_texture_target target, unsigned sample_count, + unsigned bindings) +{ + unsigned geom_flags = 0; /* we don't care about POT vs. NPOT here, yet */ + + switch (internalFormat) { + case GL_RGB10: + case GL_RGB10_A2: + if (screen->is_format_supported( screen, PIPE_FORMAT_B10G10R10A2_UNORM, + target, sample_count, bindings, + geom_flags )) + return PIPE_FORMAT_B10G10R10A2_UNORM; + /* Pass through. */ + case 4: + case GL_RGBA: + case GL_RGBA8: + return default_rgba_format( screen, target, sample_count, bindings, + geom_flags ); + + case GL_BGRA: + if (screen->is_format_supported( screen, PIPE_FORMAT_B8G8R8A8_UNORM, + target, sample_count, bindings, + geom_flags )) + return PIPE_FORMAT_B8G8R8A8_UNORM; + return default_rgba_format( screen, target, sample_count, bindings, + geom_flags ); + + case 3: + case GL_RGB: + case GL_RGB8: + return default_rgb_format( screen, target, sample_count, bindings, + geom_flags ); + + case GL_RGB12: + case GL_RGB16: + case GL_RGBA12: + case GL_RGBA16: + if (screen->is_format_supported( screen, PIPE_FORMAT_R16G16B16A16_UNORM, + target, sample_count, bindings, + geom_flags )) + return PIPE_FORMAT_R16G16B16A16_UNORM; + return default_rgba_format( screen, target, sample_count, bindings, + geom_flags ); + + case GL_RGBA4: + case GL_RGBA2: + if (screen->is_format_supported( screen, PIPE_FORMAT_B4G4R4A4_UNORM, + target, sample_count, bindings, + geom_flags )) + return PIPE_FORMAT_B4G4R4A4_UNORM; + return default_rgba_format( screen, target, sample_count, bindings, + geom_flags ); + + case GL_RGB5_A1: + if (screen->is_format_supported( screen, PIPE_FORMAT_B5G5R5A1_UNORM, + target, sample_count, bindings, + geom_flags )) + return PIPE_FORMAT_B5G5R5A1_UNORM; + return default_rgba_format( screen, target, sample_count, bindings, + geom_flags ); + + case GL_R3_G3_B2: + if (screen->is_format_supported( screen, PIPE_FORMAT_B2G3R3_UNORM, + target, sample_count, bindings, + geom_flags )) + return PIPE_FORMAT_B2G3R3_UNORM; + /* Pass through. */ + case GL_RGB5: + case GL_RGB4: + if (screen->is_format_supported( screen, PIPE_FORMAT_B5G6R5_UNORM, + target, sample_count, bindings, + geom_flags )) + return PIPE_FORMAT_B5G6R5_UNORM; + if (screen->is_format_supported( screen, PIPE_FORMAT_B5G5R5A1_UNORM, + target, sample_count, bindings, + geom_flags )) + return PIPE_FORMAT_B5G5R5A1_UNORM; + return default_rgba_format( screen, target, sample_count, bindings, + geom_flags ); + + case GL_ALPHA12: + case GL_ALPHA16: + if (screen->is_format_supported( screen, PIPE_FORMAT_A16_UNORM, target, + sample_count, bindings, geom_flags )) + return PIPE_FORMAT_A16_UNORM; + /* Pass through. */ + case GL_ALPHA: + case GL_ALPHA4: + case GL_ALPHA8: + case GL_COMPRESSED_ALPHA: + if (screen->is_format_supported( screen, PIPE_FORMAT_A8_UNORM, target, + sample_count, bindings, geom_flags )) + return PIPE_FORMAT_A8_UNORM; + return default_rgba_format( screen, target, sample_count, bindings, + geom_flags ); + + case GL_LUMINANCE12: + case GL_LUMINANCE16: + if (screen->is_format_supported( screen, PIPE_FORMAT_L16_UNORM, target, + sample_count, bindings, geom_flags )) + return PIPE_FORMAT_L16_UNORM; + /* Pass through. */ + case 1: + case GL_LUMINANCE: + case GL_LUMINANCE4: + case GL_LUMINANCE8: + case GL_COMPRESSED_LUMINANCE: + if (screen->is_format_supported( screen, PIPE_FORMAT_L8_UNORM, target, + sample_count, bindings, geom_flags )) + return PIPE_FORMAT_L8_UNORM; + return default_rgba_format( screen, target, sample_count, bindings, + geom_flags ); + + case GL_LUMINANCE12_ALPHA4: + case GL_LUMINANCE12_ALPHA12: + case GL_LUMINANCE16_ALPHA16: + if (screen->is_format_supported( screen, PIPE_FORMAT_L16A16_UNORM, target, + sample_count, bindings, geom_flags )) + return PIPE_FORMAT_L16A16_UNORM; + /* Pass through. */ + case 2: + case GL_LUMINANCE_ALPHA: + case GL_LUMINANCE6_ALPHA2: + case GL_LUMINANCE8_ALPHA8: + case GL_COMPRESSED_LUMINANCE_ALPHA: + if (screen->is_format_supported( screen, PIPE_FORMAT_L8A8_UNORM, target, + sample_count, bindings, geom_flags )) + return PIPE_FORMAT_L8A8_UNORM; + return default_rgba_format( screen, target, sample_count, bindings, + geom_flags ); + + case GL_LUMINANCE4_ALPHA4: + if (screen->is_format_supported( screen, PIPE_FORMAT_L4A4_UNORM, target, + sample_count, bindings, geom_flags )) + return PIPE_FORMAT_L4A4_UNORM; + if (screen->is_format_supported( screen, PIPE_FORMAT_L8A8_UNORM, target, + sample_count, bindings, geom_flags )) + return PIPE_FORMAT_L8A8_UNORM; + return default_rgba_format( screen, target, sample_count, bindings, + geom_flags ); + + case GL_INTENSITY12: + case GL_INTENSITY16: + if (screen->is_format_supported( screen, PIPE_FORMAT_I16_UNORM, target, + sample_count, bindings, geom_flags )) + return PIPE_FORMAT_I16_UNORM; + /* Pass through. */ + case GL_INTENSITY: + case GL_INTENSITY4: + case GL_INTENSITY8: + case GL_COMPRESSED_INTENSITY: + if (screen->is_format_supported( screen, PIPE_FORMAT_I8_UNORM, target, + sample_count, bindings, geom_flags )) + return PIPE_FORMAT_I8_UNORM; + return default_rgba_format( screen, target, sample_count, bindings, + geom_flags ); + + case GL_YCBCR_MESA: + if (screen->is_format_supported(screen, PIPE_FORMAT_UYVY, target, + sample_count, bindings, geom_flags)) { + return PIPE_FORMAT_UYVY; + } + if (screen->is_format_supported(screen, PIPE_FORMAT_YUYV, target, + sample_count, bindings, geom_flags)) { + return PIPE_FORMAT_YUYV; + } + return PIPE_FORMAT_NONE; + + case GL_COMPRESSED_RED: + case GL_COMPRESSED_RG: + case GL_COMPRESSED_RGB: + /* can only sample from compressed formats */ + if (bindings & ~PIPE_BIND_SAMPLER_VIEW) + return PIPE_FORMAT_NONE; + else if (screen->is_format_supported(screen, PIPE_FORMAT_DXT1_RGB, + target, sample_count, bindings, + geom_flags)) + return PIPE_FORMAT_DXT1_RGB; + else + return default_rgb_format(screen, target, sample_count, bindings, + geom_flags); + + case GL_COMPRESSED_RGBA: + /* can only sample from compressed formats */ + if (bindings & ~PIPE_BIND_SAMPLER_VIEW) + return PIPE_FORMAT_NONE; + else if (screen->is_format_supported(screen, PIPE_FORMAT_DXT3_RGBA, + target, sample_count, bindings, + geom_flags)) + return PIPE_FORMAT_DXT3_RGBA; + else + return default_rgba_format(screen, target, sample_count, bindings, + geom_flags); + + case GL_RGB_S3TC: + case GL_RGB4_S3TC: + case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: + if (screen->is_format_supported(screen, PIPE_FORMAT_DXT1_RGB, + target, sample_count, bindings, + geom_flags)) + return PIPE_FORMAT_DXT1_RGB; + else + return PIPE_FORMAT_NONE; + + case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: + if (screen->is_format_supported(screen, PIPE_FORMAT_DXT1_RGBA, + target, sample_count, bindings, + geom_flags)) + return PIPE_FORMAT_DXT1_RGBA; + else + return PIPE_FORMAT_NONE; + + case GL_RGBA_S3TC: + case GL_RGBA4_S3TC: + case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: + if (screen->is_format_supported(screen, PIPE_FORMAT_DXT3_RGBA, + target, sample_count, bindings, + geom_flags)) + return PIPE_FORMAT_DXT3_RGBA; + else + return PIPE_FORMAT_NONE; + + case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: + if (screen->is_format_supported(screen, PIPE_FORMAT_DXT5_RGBA, + target, sample_count, bindings, + geom_flags)) + return PIPE_FORMAT_DXT5_RGBA; + else + return PIPE_FORMAT_NONE; + +#if 0 + case GL_COMPRESSED_RGB_FXT1_3DFX: + return PIPE_FORMAT_RGB_FXT1; + case GL_COMPRESSED_RGBA_FXT1_3DFX: + return PIPE_FORMAT_RGB_FXT1; +#endif + + case GL_DEPTH_COMPONENT16: + if (screen->is_format_supported(screen, PIPE_FORMAT_Z16_UNORM, target, + sample_count, bindings, geom_flags)) + return PIPE_FORMAT_Z16_UNORM; + /* fall-through */ + case GL_DEPTH_COMPONENT24: + if (screen->is_format_supported(screen, PIPE_FORMAT_Z24_UNORM_S8_USCALED, + target, sample_count, bindings, geom_flags)) + return PIPE_FORMAT_Z24_UNORM_S8_USCALED; + if (screen->is_format_supported(screen, PIPE_FORMAT_S8_USCALED_Z24_UNORM, + target, sample_count, bindings, geom_flags)) + return PIPE_FORMAT_S8_USCALED_Z24_UNORM; + /* fall-through */ + case GL_DEPTH_COMPONENT32: + if (screen->is_format_supported(screen, PIPE_FORMAT_Z32_UNORM, target, + sample_count, bindings, geom_flags)) + return PIPE_FORMAT_Z32_UNORM; + /* fall-through */ + case GL_DEPTH_COMPONENT: + { + static const enum pipe_format formats[] = { + PIPE_FORMAT_Z32_UNORM, + PIPE_FORMAT_Z24_UNORM_S8_USCALED, + PIPE_FORMAT_S8_USCALED_Z24_UNORM, + PIPE_FORMAT_Z16_UNORM + }; + return find_supported_format(screen, formats, Elements(formats), + target, sample_count, bindings, geom_flags); + } + + case GL_STENCIL_INDEX: + case GL_STENCIL_INDEX1_EXT: + case GL_STENCIL_INDEX4_EXT: + case GL_STENCIL_INDEX8_EXT: + case GL_STENCIL_INDEX16_EXT: + { + static const enum pipe_format formats[] = { + PIPE_FORMAT_S8_USCALED, + PIPE_FORMAT_Z24_UNORM_S8_USCALED, + PIPE_FORMAT_S8_USCALED_Z24_UNORM + }; + return find_supported_format(screen, formats, Elements(formats), + target, sample_count, bindings, geom_flags); + } + + case GL_DEPTH_STENCIL_EXT: + case GL_DEPTH24_STENCIL8_EXT: + { + static const enum pipe_format formats[] = { + PIPE_FORMAT_Z24_UNORM_S8_USCALED, + PIPE_FORMAT_S8_USCALED_Z24_UNORM + }; + return find_supported_format(screen, formats, Elements(formats), + target, sample_count, bindings, geom_flags); + } + + case GL_SRGB_EXT: + case GL_SRGB8_EXT: + case GL_SRGB_ALPHA_EXT: + case GL_SRGB8_ALPHA8_EXT: + return default_srgba_format( screen, target, sample_count, bindings, + geom_flags ); + + case GL_COMPRESSED_SRGB_EXT: + case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT: + if (screen->is_format_supported(screen, PIPE_FORMAT_DXT1_SRGB, target, + sample_count, bindings, geom_flags)) + return PIPE_FORMAT_DXT1_SRGB; + return default_srgba_format( screen, target, sample_count, bindings, + geom_flags ); + + case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: + return PIPE_FORMAT_DXT1_SRGBA; + + case GL_COMPRESSED_SRGB_ALPHA_EXT: + case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: + if (screen->is_format_supported(screen, PIPE_FORMAT_DXT3_SRGBA, target, + sample_count, bindings, geom_flags)) + return PIPE_FORMAT_DXT3_SRGBA; + return default_srgba_format( screen, target, sample_count, bindings, + geom_flags ); + + case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: + return PIPE_FORMAT_DXT5_SRGBA; + + case GL_SLUMINANCE_ALPHA_EXT: + case GL_SLUMINANCE8_ALPHA8_EXT: + case GL_COMPRESSED_SLUMINANCE_EXT: + case GL_COMPRESSED_SLUMINANCE_ALPHA_EXT: + if (screen->is_format_supported(screen, PIPE_FORMAT_L8A8_SRGB, target, + sample_count, bindings, geom_flags)) + return PIPE_FORMAT_L8A8_SRGB; + return default_srgba_format( screen, target, sample_count, bindings, + geom_flags ); + + case GL_SLUMINANCE_EXT: + case GL_SLUMINANCE8_EXT: + if (screen->is_format_supported(screen, PIPE_FORMAT_L8_SRGB, target, + sample_count, bindings, geom_flags)) + return PIPE_FORMAT_L8_SRGB; + return default_srgba_format( screen, target, sample_count, bindings, + geom_flags ); + + case GL_RED: + case GL_R8: + if (screen->is_format_supported(screen, PIPE_FORMAT_R8_UNORM, target, + sample_count, bindings, geom_flags)) + return PIPE_FORMAT_R8_UNORM; + return PIPE_FORMAT_NONE; + case GL_RG: + case GL_RG8: + if (screen->is_format_supported(screen, PIPE_FORMAT_R8G8_UNORM, target, + sample_count, bindings, geom_flags)) + return PIPE_FORMAT_R8G8_UNORM; + return PIPE_FORMAT_NONE; + + case GL_R16: + if (screen->is_format_supported(screen, PIPE_FORMAT_R16_UNORM, target, + sample_count, bindings, geom_flags)) + return PIPE_FORMAT_R16_UNORM; + return PIPE_FORMAT_NONE; + + case GL_RG16: + if (screen->is_format_supported(screen, PIPE_FORMAT_R16G16_UNORM, target, + sample_count, bindings, geom_flags)) + return PIPE_FORMAT_R16G16_UNORM; + return PIPE_FORMAT_NONE; + + case GL_COMPRESSED_RED_RGTC1: + if (screen->is_format_supported(screen, PIPE_FORMAT_RGTC1_UNORM, target, + sample_count, bindings, geom_flags)) + return PIPE_FORMAT_RGTC1_UNORM; + return PIPE_FORMAT_NONE; + + case GL_COMPRESSED_SIGNED_RED_RGTC1: + if (screen->is_format_supported(screen, PIPE_FORMAT_RGTC1_SNORM, target, + sample_count, bindings, geom_flags)) + return PIPE_FORMAT_RGTC1_SNORM; + return PIPE_FORMAT_NONE; + + case GL_COMPRESSED_RG_RGTC2: + if (screen->is_format_supported(screen, PIPE_FORMAT_RGTC2_UNORM, target, + sample_count, bindings, geom_flags)) + return PIPE_FORMAT_RGTC2_UNORM; + return PIPE_FORMAT_NONE; + + case GL_COMPRESSED_SIGNED_RG_RGTC2: + if (screen->is_format_supported(screen, PIPE_FORMAT_RGTC2_SNORM, target, + sample_count, bindings, geom_flags)) + return PIPE_FORMAT_RGTC2_SNORM; + return PIPE_FORMAT_NONE; + + /* signed/unsigned integer formats. + * XXX Mesa only has formats for RGBA signed/unsigned integer formats. + * If/when new formats are added this code should be updated. + */ + case GL_RED_INTEGER_EXT: + case GL_GREEN_INTEGER_EXT: + case GL_BLUE_INTEGER_EXT: + case GL_ALPHA_INTEGER_EXT: + case GL_RGB_INTEGER_EXT: + case GL_RGBA_INTEGER_EXT: + case GL_BGR_INTEGER_EXT: + case GL_BGRA_INTEGER_EXT: + case GL_LUMINANCE_INTEGER_EXT: + case GL_LUMINANCE_ALPHA_INTEGER_EXT: + /* fall-through */ + case GL_RGBA8I_EXT: + case GL_RGB8I_EXT: + case GL_ALPHA8I_EXT: + case GL_INTENSITY8I_EXT: + case GL_LUMINANCE8I_EXT: + case GL_LUMINANCE_ALPHA8I_EXT: + if (screen->is_format_supported(screen, PIPE_FORMAT_R8G8B8A8_SSCALED, + target, + sample_count, bindings, geom_flags)) + return PIPE_FORMAT_R8G8B8A8_SSCALED; + return PIPE_FORMAT_NONE; + case GL_RGBA16I_EXT: + case GL_RGB16I_EXT: + case GL_ALPHA16I_EXT: + case GL_INTENSITY16I_EXT: + case GL_LUMINANCE16I_EXT: + case GL_LUMINANCE_ALPHA16I_EXT: + if (screen->is_format_supported(screen, PIPE_FORMAT_R16G16B16A16_SSCALED, + target, + sample_count, bindings, geom_flags)) + return PIPE_FORMAT_R16G16B16A16_SSCALED; + return PIPE_FORMAT_NONE; + case GL_RGBA32I_EXT: + case GL_RGB32I_EXT: + case GL_ALPHA32I_EXT: + case GL_INTENSITY32I_EXT: + case GL_LUMINANCE32I_EXT: + case GL_LUMINANCE_ALPHA32I_EXT: + /* xxx */ + if (screen->is_format_supported(screen, PIPE_FORMAT_R32G32B32A32_SSCALED, + target, + sample_count, bindings, geom_flags)) + return PIPE_FORMAT_R32G32B32A32_SSCALED; + return PIPE_FORMAT_NONE; + + case GL_RGBA8UI_EXT: + case GL_RGB8UI_EXT: + case GL_ALPHA8UI_EXT: + case GL_INTENSITY8UI_EXT: + case GL_LUMINANCE8UI_EXT: + case GL_LUMINANCE_ALPHA8UI_EXT: + if (screen->is_format_supported(screen, PIPE_FORMAT_R8G8B8A8_USCALED, + target, + sample_count, bindings, geom_flags)) + return PIPE_FORMAT_R8G8B8A8_USCALED; + return PIPE_FORMAT_NONE; + + case GL_RGBA16UI_EXT: + case GL_RGB16UI_EXT: + case GL_ALPHA16UI_EXT: + case GL_INTENSITY16UI_EXT: + case GL_LUMINANCE16UI_EXT: + case GL_LUMINANCE_ALPHA16UI_EXT: + if (screen->is_format_supported(screen, PIPE_FORMAT_R16G16B16A16_USCALED, + target, + sample_count, bindings, geom_flags)) + return PIPE_FORMAT_R16G16B16A16_USCALED; + return PIPE_FORMAT_NONE; + + case GL_RGBA32UI_EXT: + case GL_RGB32UI_EXT: + case GL_ALPHA32UI_EXT: + case GL_INTENSITY32UI_EXT: + case GL_LUMINANCE32UI_EXT: + case GL_LUMINANCE_ALPHA32UI_EXT: + if (screen->is_format_supported(screen, PIPE_FORMAT_R32G32B32A32_USCALED, + target, + sample_count, bindings, geom_flags)) + return PIPE_FORMAT_R32G32B32A32_USCALED; + return PIPE_FORMAT_NONE; + + default: + return PIPE_FORMAT_NONE; + } +} + + +/** + * Called by FBO code to choose a PIPE_FORMAT_ for drawing surfaces. + */ +enum pipe_format +st_choose_renderbuffer_format(struct pipe_screen *screen, + GLenum internalFormat, unsigned sample_count) +{ + uint usage; + if (_mesa_is_depth_or_stencil_format(internalFormat)) + usage = PIPE_BIND_DEPTH_STENCIL; + else + usage = PIPE_BIND_RENDER_TARGET; + return st_choose_format(screen, internalFormat, PIPE_TEXTURE_2D, + sample_count, usage); +} + + +/** + * Called via ctx->Driver.chooseTextureFormat(). + */ +gl_format +st_ChooseTextureFormat_renderable(struct gl_context *ctx, GLint internalFormat, + GLenum format, GLenum type, GLboolean renderable) +{ + struct pipe_screen *screen = st_context(ctx)->pipe->screen; + enum pipe_format pFormat; + uint bindings; + + (void) format; + (void) type; + + /* GL textures may wind up being render targets, but we don't know + * that in advance. Specify potential render target flags now. + */ + bindings = PIPE_BIND_SAMPLER_VIEW; + if (renderable == GL_TRUE) { + if (_mesa_is_depth_format(internalFormat) || + _mesa_is_depth_or_stencil_format(internalFormat)) + bindings |= PIPE_BIND_DEPTH_STENCIL; + else + bindings |= PIPE_BIND_RENDER_TARGET; + } + + pFormat = st_choose_format(screen, internalFormat, + PIPE_TEXTURE_2D, 0, bindings); + + if (pFormat == PIPE_FORMAT_NONE) { + /* try choosing format again, this time without render target bindings */ + pFormat = st_choose_format(screen, internalFormat, + PIPE_TEXTURE_2D, 0, PIPE_BIND_SAMPLER_VIEW); + } + + if (pFormat == PIPE_FORMAT_NONE) { + /* no luck at all */ + return MESA_FORMAT_NONE; + } + + return st_pipe_format_to_mesa_format(pFormat); +} + +gl_format +st_ChooseTextureFormat(struct gl_context *ctx, GLint internalFormat, + GLenum format, GLenum type) +{ + boolean want_renderable = + internalFormat == 3 || internalFormat == 4 || + internalFormat == GL_RGB || internalFormat == GL_RGBA || + internalFormat == GL_RGB8 || internalFormat == GL_RGBA8 || + internalFormat == GL_BGRA; + + return st_ChooseTextureFormat_renderable(ctx, internalFormat, + format, type, want_renderable); +} + +/** + * Test if a gallium format is equivalent to a GL format/type. + */ +GLboolean +st_equal_formats(enum pipe_format pFormat, GLenum format, GLenum type) +{ + switch (pFormat) { + case PIPE_FORMAT_A8B8G8R8_UNORM: + return format == GL_RGBA && type == GL_UNSIGNED_BYTE; + case PIPE_FORMAT_A8R8G8B8_UNORM: + return format == GL_BGRA && type == GL_UNSIGNED_BYTE; + case PIPE_FORMAT_B5G6R5_UNORM: + return format == GL_RGB && type == GL_UNSIGNED_SHORT_5_6_5; + /* XXX more combos... */ + default: + return GL_FALSE; + } +} + +GLboolean +st_sampler_compat_formats(enum pipe_format format1, enum pipe_format format2) +{ + if (format1 == format2) + return GL_TRUE; + + if (format1 == PIPE_FORMAT_B8G8R8A8_UNORM && + format2 == PIPE_FORMAT_B8G8R8X8_UNORM) + return GL_TRUE; + + if (format1 == PIPE_FORMAT_B8G8R8X8_UNORM && + format2 == PIPE_FORMAT_B8G8R8A8_UNORM) + return GL_TRUE; + + if (format1 == PIPE_FORMAT_A8B8G8R8_UNORM && + format2 == PIPE_FORMAT_X8B8G8R8_UNORM) + return GL_TRUE; + + if (format1 == PIPE_FORMAT_X8B8G8R8_UNORM && + format2 == PIPE_FORMAT_A8B8G8R8_UNORM) + return GL_TRUE; + + if (format1 == PIPE_FORMAT_A8R8G8B8_UNORM && + format2 == PIPE_FORMAT_X8R8G8B8_UNORM) + return GL_TRUE; + + if (format1 == PIPE_FORMAT_X8R8G8B8_UNORM && + format2 == PIPE_FORMAT_A8R8G8B8_UNORM) + return GL_TRUE; + + return GL_FALSE; +} diff --git a/mesalib/src/mesa/x86/read_rgba_span_x86.S b/mesalib/src/mesa/x86/read_rgba_span_x86.S index cd7596026..817729973 100644 --- a/mesalib/src/mesa/x86/read_rgba_span_x86.S +++ b/mesalib/src/mesa/x86/read_rgba_span_x86.S @@ -1,678 +1,678 @@ -/*
- * (C) Copyright IBM Corporation 2004
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * on the rights to use, copy, modify, merge, publish, distribute, sub
- * license, and/or sell copies of the Software, and to permit persons to whom
- * the Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * IBM AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- * USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-/**
- * \file read_rgba_span_x86.S
- * Optimized routines to transfer pixel data from the framebuffer to a
- * buffer in main memory.
- *
- * \author Ian Romanick <idr@us.ibm.com>
- */
-
- .file "read_rgba_span_x86.S"
-#if !defined(__DJGPP__) && !defined(__MINGW32__) && !defined(__APPLE__) /* this one cries for assyntax.h */
-/* Kevin F. Quinn 2nd July 2006
- * Replaced data segment constants with text-segment instructions.
- */
-#define LOAD_MASK(mvins,m1,m2) \
- pushl $0xff00ff00 ;\
- pushl $0xff00ff00 ;\
- pushl $0xff00ff00 ;\
- pushl $0xff00ff00 ;\
- mvins (%esp), m1 ;\
- pushl $0x00ff0000 ;\
- pushl $0x00ff0000 ;\
- pushl $0x00ff0000 ;\
- pushl $0x00ff0000 ;\
- mvins (%esp), m2 ;\
- addl $32, %esp
-
-/* I implemented these as macros because they appear in several places,
- * and I've tweaked them a number of times. I got tired of changing every
- * place they appear. :)
- */
-
-#define DO_ONE_PIXEL() \
- movl (%ebx), %eax ; \
- addl $4, %ebx ; \
- bswap %eax /* ARGB -> BGRA */ ; \
- rorl $8, %eax /* BGRA -> ABGR */ ; \
- movl %eax, (%ecx) /* ABGR -> R, G, B, A */ ; \
- addl $4, %ecx
-
-#define DO_ONE_LAST_PIXEL() \
- movl (%ebx), %eax ; \
- bswap %eax /* ARGB -> BGRA */ ; \
- rorl $8, %eax /* BGRA -> ABGR */ ; \
- movl %eax, (%ecx) /* ABGR -> R, G, B, A */ ; \
-
-
-/**
- * MMX optimized version of the BGRA8888_REV to RGBA copy routine.
- *
- * \warning
- * This function assumes that the caller will issue the EMMS instruction
- * at the correct places.
- */
-
-.globl _generic_read_RGBA_span_BGRA8888_REV_MMX
-.hidden _generic_read_RGBA_span_BGRA8888_REV_MMX
- .type _generic_read_RGBA_span_BGRA8888_REV_MMX, @function
-_generic_read_RGBA_span_BGRA8888_REV_MMX:
- pushl %ebx
-
-#ifdef USE_INNER_EMMS
- emms
-#endif
- LOAD_MASK(movq,%mm1,%mm2)
-
- movl 8(%esp), %ebx /* source pointer */
- movl 16(%esp), %edx /* number of pixels to copy */
- movl 12(%esp), %ecx /* destination pointer */
-
- testl %edx, %edx
- jle .L20 /* Bail if there's nothing to do. */
-
- movl %ebx, %eax
-
- negl %eax
- sarl $2, %eax
- andl $1, %eax
- je .L17
-
- subl %eax, %edx
- DO_ONE_PIXEL()
-.L17:
-
- /* Would it be faster to unroll this loop once and process 4 pixels
- * per pass, instead of just two?
- */
-
- movl %edx, %eax
- shrl %eax
- jmp .L18
-.L19:
- movq (%ebx), %mm0
- addl $8, %ebx
-
- /* These 9 instructions do what PSHUFB (if there were such an
- * instruction) could do in 1. :(
- */
-
- movq %mm0, %mm3
- movq %mm0, %mm4
-
- pand %mm2, %mm3
- psllq $16, %mm4
- psrlq $16, %mm3
- pand %mm2, %mm4
-
- pand %mm1, %mm0
- por %mm4, %mm3
- por %mm3, %mm0
-
- movq %mm0, (%ecx)
- addl $8, %ecx
- subl $1, %eax
-.L18:
- jne .L19
-
-#ifdef USE_INNER_EMMS
- emms
-#endif
-
- /* At this point there are either 1 or 0 pixels remaining to be
- * converted. Convert the last pixel, if needed.
- */
-
- testl $1, %edx
- je .L20
-
- DO_ONE_LAST_PIXEL()
-
-.L20:
- popl %ebx
- ret
- .size _generic_read_RGBA_span_BGRA8888_REV_MMX, .-_generic_read_RGBA_span_BGRA8888_REV_MMX
-
-
-/**
- * SSE optimized version of the BGRA8888_REV to RGBA copy routine. SSE
- * instructions are only actually used to read data from the framebuffer.
- * In practice, the speed-up is pretty small.
- *
- * \todo
- * Do some more testing and determine if there's any reason to have this
- * function in addition to the MMX version.
- *
- * \warning
- * This function assumes that the caller will issue the EMMS instruction
- * at the correct places.
- */
-
-.globl _generic_read_RGBA_span_BGRA8888_REV_SSE
-.hidden _generic_read_RGBA_span_BGRA8888_REV_SSE
- .type _generic_read_RGBA_span_BGRA8888_REV_SSE, @function
-_generic_read_RGBA_span_BGRA8888_REV_SSE:
- pushl %esi
- pushl %ebx
- pushl %ebp
-
-#ifdef USE_INNER_EMMS
- emms
-#endif
-
- LOAD_MASK(movq,%mm1,%mm2)
-
- movl 16(%esp), %ebx /* source pointer */
- movl 24(%esp), %edx /* number of pixels to copy */
- movl 20(%esp), %ecx /* destination pointer */
-
- testl %edx, %edx
- jle .L35 /* Bail if there's nothing to do. */
-
- movl %esp, %ebp
- subl $16, %esp
- andl $0xfffffff0, %esp
-
- movl %ebx, %eax
- movl %edx, %esi
-
- negl %eax
- andl $15, %eax
- sarl $2, %eax
- cmpl %edx, %eax
- cmovle %eax, %esi
-
- subl %esi, %edx
-
- testl $1, %esi
- je .L32
-
- DO_ONE_PIXEL()
-.L32:
-
- testl $2, %esi
- je .L31
-
- movq (%ebx), %mm0
- addl $8, %ebx
-
- movq %mm0, %mm3
- movq %mm0, %mm4
-
- pand %mm2, %mm3
- psllq $16, %mm4
- psrlq $16, %mm3
- pand %mm2, %mm4
-
- pand %mm1, %mm0
- por %mm4, %mm3
- por %mm3, %mm0
-
- movq %mm0, (%ecx)
- addl $8, %ecx
-.L31:
-
- movl %edx, %eax
- shrl $2, %eax
- jmp .L33
-.L34:
- movaps (%ebx), %xmm0
- addl $16, %ebx
-
- /* This would be so much better if we could just move directly from
- * an SSE register to an MMX register. Unfortunately, that
- * functionality wasn't introduced until SSE2 with the MOVDQ2Q
- * instruction.
- */
-
- movaps %xmm0, (%esp)
- movq (%esp), %mm0
- movq 8(%esp), %mm5
-
- movq %mm0, %mm3
- movq %mm0, %mm4
- movq %mm5, %mm6
- movq %mm5, %mm7
-
- pand %mm2, %mm3
- pand %mm2, %mm6
-
- psllq $16, %mm4
- psllq $16, %mm7
-
- psrlq $16, %mm3
- psrlq $16, %mm6
-
- pand %mm2, %mm4
- pand %mm2, %mm7
-
- pand %mm1, %mm0
- pand %mm1, %mm5
-
- por %mm4, %mm3
- por %mm7, %mm6
-
- por %mm3, %mm0
- por %mm6, %mm5
-
- movq %mm0, (%ecx)
- movq %mm5, 8(%ecx)
- addl $16, %ecx
-
- subl $1, %eax
-.L33:
- jne .L34
-
-#ifdef USE_INNER_EMMS
- emms
-#endif
- movl %ebp, %esp
-
- /* At this point there are either [0, 3] pixels remaining to be
- * converted.
- */
-
- testl $2, %edx
- je .L36
-
- movq (%ebx), %mm0
- addl $8, %ebx
-
- movq %mm0, %mm3
- movq %mm0, %mm4
-
- pand %mm2, %mm3
- psllq $16, %mm4
- psrlq $16, %mm3
- pand %mm2, %mm4
-
- pand %mm1, %mm0
- por %mm4, %mm3
- por %mm3, %mm0
-
- movq %mm0, (%ecx)
- addl $8, %ecx
-.L36:
-
- testl $1, %edx
- je .L35
-
- DO_ONE_LAST_PIXEL()
-.L35:
- popl %ebp
- popl %ebx
- popl %esi
- ret
- .size _generic_read_RGBA_span_BGRA8888_REV_SSE, .-_generic_read_RGBA_span_BGRA8888_REV_SSE
-
-
-/**
- * SSE2 optimized version of the BGRA8888_REV to RGBA copy routine.
- */
-
- .text
-.globl _generic_read_RGBA_span_BGRA8888_REV_SSE2
-.hidden _generic_read_RGBA_span_BGRA8888_REV_SSE2
- .type _generic_read_RGBA_span_BGRA8888_REV_SSE2, @function
-_generic_read_RGBA_span_BGRA8888_REV_SSE2:
- pushl %esi
- pushl %ebx
-
- LOAD_MASK(movdqu,%xmm1,%xmm2)
-
- movl 12(%esp), %ebx /* source pointer */
- movl 20(%esp), %edx /* number of pixels to copy */
- movl 16(%esp), %ecx /* destination pointer */
-
- movl %ebx, %eax
- movl %edx, %esi
-
- testl %edx, %edx
- jle .L46 /* Bail if there's nothing to do. */
-
- /* If the source pointer isn't a multiple of 16 we have to process
- * a few pixels the "slow" way to get the address aligned for
- * the SSE fetch intsructions.
- */
-
- negl %eax
- andl $15, %eax
- sarl $2, %eax
-
- cmpl %edx, %eax
- cmovbe %eax, %esi
- subl %esi, %edx
-
- testl $1, %esi
- je .L41
-
- DO_ONE_PIXEL()
-.L41:
- testl $2, %esi
- je .L40
-
- movq (%ebx), %xmm0
- addl $8, %ebx
-
- movdqa %xmm0, %xmm3
- movdqa %xmm0, %xmm4
- andps %xmm1, %xmm0
-
- andps %xmm2, %xmm3
- pslldq $2, %xmm4
- psrldq $2, %xmm3
- andps %xmm2, %xmm4
-
- orps %xmm4, %xmm3
- orps %xmm3, %xmm0
-
- movq %xmm0, (%ecx)
- addl $8, %ecx
-.L40:
-
- /* Would it be worth having a specialized version of this loop for
- * the case where the destination is 16-byte aligned? That version
- * would be identical except that it could use movedqa instead of
- * movdqu.
- */
-
- movl %edx, %eax
- shrl $2, %eax
- jmp .L42
-.L43:
- movdqa (%ebx), %xmm0
- addl $16, %ebx
-
- movdqa %xmm0, %xmm3
- movdqa %xmm0, %xmm4
- andps %xmm1, %xmm0
-
- andps %xmm2, %xmm3
- pslldq $2, %xmm4
- psrldq $2, %xmm3
- andps %xmm2, %xmm4
-
- orps %xmm4, %xmm3
- orps %xmm3, %xmm0
-
- movdqu %xmm0, (%ecx)
- addl $16, %ecx
- subl $1, %eax
-.L42:
- jne .L43
-
-
- /* There may be upto 3 pixels remaining to be copied. Take care
- * of them now. We do the 2 pixel case first because the data
- * will be aligned.
- */
-
- testl $2, %edx
- je .L47
-
- movq (%ebx), %xmm0
- addl $8, %ebx
-
- movdqa %xmm0, %xmm3
- movdqa %xmm0, %xmm4
- andps %xmm1, %xmm0
-
- andps %xmm2, %xmm3
- pslldq $2, %xmm4
- psrldq $2, %xmm3
- andps %xmm2, %xmm4
-
- orps %xmm4, %xmm3
- orps %xmm3, %xmm0
-
- movq %xmm0, (%ecx)
- addl $8, %ecx
-.L47:
-
- testl $1, %edx
- je .L46
-
- DO_ONE_LAST_PIXEL()
-.L46:
-
- popl %ebx
- popl %esi
- ret
- .size _generic_read_RGBA_span_BGRA8888_REV_SSE2, .-_generic_read_RGBA_span_BGRA8888_REV_SSE2
-
-
-
-#define MASK_565_L 0x07e0f800
-#define MASK_565_H 0x0000001f
-/* Setting SCALE_ADJUST to 5 gives a perfect match with the
- * classic C implementation in Mesa. Setting SCALE_ADJUST
- * to 0 is slightly faster but at a small cost to accuracy.
- */
-#define SCALE_ADJUST 5
-#if SCALE_ADJUST == 5
-#define PRESCALE_L 0x00100001
-#define PRESCALE_H 0x00000200
-#define SCALE_L 0x40C620E8
-#define SCALE_H 0x0000839d
-#elif SCALE_ADJUST == 0
-#define PRESCALE_L 0x00200001
-#define PRESCALE_H 0x00000800
-#define SCALE_L 0x01040108
-#define SCALE_H 0x00000108
-#else
-#error SCALE_ADJUST must either be 5 or 0.
-#endif
-#define ALPHA_L 0x00000000
-#define ALPHA_H 0x00ff0000
-
-/**
- * MMX optimized version of the RGB565 to RGBA copy routine.
- */
-
- .text
- .globl _generic_read_RGBA_span_RGB565_MMX
- .hidden _generic_read_RGBA_span_RGB565_MMX
- .type _generic_read_RGBA_span_RGB565_MMX, @function
-
-_generic_read_RGBA_span_RGB565_MMX:
-
-#ifdef USE_INNER_EMMS
- emms
-#endif
-
- movl 4(%esp), %eax /* source pointer */
- movl 8(%esp), %edx /* destination pointer */
- movl 12(%esp), %ecx /* number of pixels to copy */
-
- pushl $MASK_565_H
- pushl $MASK_565_L
- movq (%esp), %mm5
- pushl $PRESCALE_H
- pushl $PRESCALE_L
- movq (%esp), %mm6
- pushl $SCALE_H
- pushl $SCALE_L
- movq (%esp), %mm7
- pushl $ALPHA_H
- pushl $ALPHA_L
- movq (%esp), %mm3
- addl $32,%esp
-
- sarl $2, %ecx
- jl .L01 /* Bail early if the count is negative. */
- jmp .L02
-
-.L03:
- /* Fetch 4 RGB565 pixels into %mm4. Distribute the first and
- * second pixels into the four words of %mm0 and %mm2.
- */
-
- movq (%eax), %mm4
- addl $8, %eax
-
- pshufw $0x00, %mm4, %mm0
- pshufw $0x55, %mm4, %mm2
-
-
- /* Mask the pixels so that each word of each register contains only
- * one color component.
- */
-
- pand %mm5, %mm0
- pand %mm5, %mm2
-
-
- /* Adjust the component values so that they are as small as possible,
- * but large enough so that we can multiply them by an unsigned 16-bit
- * number and get a value as large as 0x00ff0000.
- */
-
- pmullw %mm6, %mm0
- pmullw %mm6, %mm2
-#if SCALE_ADJUST > 0
- psrlw $SCALE_ADJUST, %mm0
- psrlw $SCALE_ADJUST, %mm2
-#endif
-
- /* Scale the input component values to be on the range
- * [0, 0x00ff0000]. This it the real magic of the whole routine.
- */
-
- pmulhuw %mm7, %mm0
- pmulhuw %mm7, %mm2
-
-
- /* Always set the alpha value to 0xff.
- */
-
- por %mm3, %mm0
- por %mm3, %mm2
-
-
- /* Pack the 16-bit values to 8-bit values and store the converted
- * pixel data.
- */
-
- packuswb %mm2, %mm0
- movq %mm0, (%edx)
- addl $8, %edx
-
- pshufw $0xaa, %mm4, %mm0
- pshufw $0xff, %mm4, %mm2
-
- pand %mm5, %mm0
- pand %mm5, %mm2
- pmullw %mm6, %mm0
- pmullw %mm6, %mm2
-#if SCALE_ADJUST > 0
- psrlw $SCALE_ADJUST, %mm0
- psrlw $SCALE_ADJUST, %mm2
-#endif
- pmulhuw %mm7, %mm0
- pmulhuw %mm7, %mm2
-
- por %mm3, %mm0
- por %mm3, %mm2
-
- packuswb %mm2, %mm0
-
- movq %mm0, (%edx)
- addl $8, %edx
-
- subl $1, %ecx
-.L02:
- jne .L03
-
-
- /* At this point there can be at most 3 pixels left to process. If
- * there is either 2 or 3 left, process 2.
- */
-
- movl 12(%esp), %ecx
- testl $0x02, %ecx
- je .L04
-
- movd (%eax), %mm4
- addl $4, %eax
-
- pshufw $0x00, %mm4, %mm0
- pshufw $0x55, %mm4, %mm2
-
- pand %mm5, %mm0
- pand %mm5, %mm2
- pmullw %mm6, %mm0
- pmullw %mm6, %mm2
-#if SCALE_ADJUST > 0
- psrlw $SCALE_ADJUST, %mm0
- psrlw $SCALE_ADJUST, %mm2
-#endif
- pmulhuw %mm7, %mm0
- pmulhuw %mm7, %mm2
-
- por %mm3, %mm0
- por %mm3, %mm2
-
- packuswb %mm2, %mm0
-
- movq %mm0, (%edx)
- addl $8, %edx
-
-.L04:
- /* At this point there can be at most 1 pixel left to process.
- * Process it if needed.
- */
-
- testl $0x01, %ecx
- je .L01
-
- movzxw (%eax), %ecx
- movd %ecx, %mm4
-
- pshufw $0x00, %mm4, %mm0
-
- pand %mm5, %mm0
- pmullw %mm6, %mm0
-#if SCALE_ADJUST > 0
- psrlw $SCALE_ADJUST, %mm0
-#endif
- pmulhuw %mm7, %mm0
-
- por %mm3, %mm0
-
- packuswb %mm0, %mm0
-
- movd %mm0, (%edx)
-
-.L01:
-#ifdef USE_INNER_EMMS
- emms
-#endif
- ret
-#endif /* !defined(__DJGPP__) && !defined(__MINGW32__) && !defined(__APPLE__) */
-
-#if defined (__ELF__) && defined (__linux__)
- .section .note.GNU-stack,"",%progbits
-#endif
+/* + * (C) Copyright IBM Corporation 2004 + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * on the rights to use, copy, modify, merge, publish, distribute, sub + * license, and/or sell copies of the Software, and to permit persons to whom + * the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * IBM AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + * USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/** + * \file read_rgba_span_x86.S + * Optimized routines to transfer pixel data from the framebuffer to a + * buffer in main memory. + * + * \author Ian Romanick <idr@us.ibm.com> + */ + + .file "read_rgba_span_x86.S" +#if !defined(__DJGPP__) && !defined(__MINGW32__) && !defined(__APPLE__) /* this one cries for assyntax.h */ +/* Kevin F. Quinn 2nd July 2006 + * Replaced data segment constants with text-segment instructions. + */ +#define LOAD_MASK(mvins,m1,m2) \ + pushl $0xff00ff00 ;\ + pushl $0xff00ff00 ;\ + pushl $0xff00ff00 ;\ + pushl $0xff00ff00 ;\ + mvins (%esp), m1 ;\ + pushl $0x00ff0000 ;\ + pushl $0x00ff0000 ;\ + pushl $0x00ff0000 ;\ + pushl $0x00ff0000 ;\ + mvins (%esp), m2 ;\ + addl $32, %esp + +/* I implemented these as macros because they appear in several places, + * and I've tweaked them a number of times. I got tired of changing every + * place they appear. :) + */ + +#define DO_ONE_PIXEL() \ + movl (%ebx), %eax ; \ + addl $4, %ebx ; \ + bswap %eax /* ARGB -> BGRA */ ; \ + rorl $8, %eax /* BGRA -> ABGR */ ; \ + movl %eax, (%ecx) /* ABGR -> R, G, B, A */ ; \ + addl $4, %ecx + +#define DO_ONE_LAST_PIXEL() \ + movl (%ebx), %eax ; \ + bswap %eax /* ARGB -> BGRA */ ; \ + rorl $8, %eax /* BGRA -> ABGR */ ; \ + movl %eax, (%ecx) /* ABGR -> R, G, B, A */ ; \ + + +/** + * MMX optimized version of the BGRA8888_REV to RGBA copy routine. + * + * \warning + * This function assumes that the caller will issue the EMMS instruction + * at the correct places. + */ + +.globl _generic_read_RGBA_span_BGRA8888_REV_MMX +.hidden _generic_read_RGBA_span_BGRA8888_REV_MMX + .type _generic_read_RGBA_span_BGRA8888_REV_MMX, @function +_generic_read_RGBA_span_BGRA8888_REV_MMX: + pushl %ebx + +#ifdef USE_INNER_EMMS + emms +#endif + LOAD_MASK(movq,%mm1,%mm2) + + movl 8(%esp), %ebx /* source pointer */ + movl 16(%esp), %edx /* number of pixels to copy */ + movl 12(%esp), %ecx /* destination pointer */ + + testl %edx, %edx + jle .L20 /* Bail if there's nothing to do. */ + + movl %ebx, %eax + + negl %eax + sarl $2, %eax + andl $1, %eax + je .L17 + + subl %eax, %edx + DO_ONE_PIXEL() +.L17: + + /* Would it be faster to unroll this loop once and process 4 pixels + * per pass, instead of just two? + */ + + movl %edx, %eax + shrl %eax + jmp .L18 +.L19: + movq (%ebx), %mm0 + addl $8, %ebx + + /* These 9 instructions do what PSHUFB (if there were such an + * instruction) could do in 1. :( + */ + + movq %mm0, %mm3 + movq %mm0, %mm4 + + pand %mm2, %mm3 + psllq $16, %mm4 + psrlq $16, %mm3 + pand %mm2, %mm4 + + pand %mm1, %mm0 + por %mm4, %mm3 + por %mm3, %mm0 + + movq %mm0, (%ecx) + addl $8, %ecx + subl $1, %eax +.L18: + jne .L19 + +#ifdef USE_INNER_EMMS + emms +#endif + + /* At this point there are either 1 or 0 pixels remaining to be + * converted. Convert the last pixel, if needed. + */ + + testl $1, %edx + je .L20 + + DO_ONE_LAST_PIXEL() + +.L20: + popl %ebx + ret + .size _generic_read_RGBA_span_BGRA8888_REV_MMX, .-_generic_read_RGBA_span_BGRA8888_REV_MMX + + +/** + * SSE optimized version of the BGRA8888_REV to RGBA copy routine. SSE + * instructions are only actually used to read data from the framebuffer. + * In practice, the speed-up is pretty small. + * + * \todo + * Do some more testing and determine if there's any reason to have this + * function in addition to the MMX version. + * + * \warning + * This function assumes that the caller will issue the EMMS instruction + * at the correct places. + */ + +.globl _generic_read_RGBA_span_BGRA8888_REV_SSE +.hidden _generic_read_RGBA_span_BGRA8888_REV_SSE + .type _generic_read_RGBA_span_BGRA8888_REV_SSE, @function +_generic_read_RGBA_span_BGRA8888_REV_SSE: + pushl %esi + pushl %ebx + pushl %ebp + +#ifdef USE_INNER_EMMS + emms +#endif + + LOAD_MASK(movq,%mm1,%mm2) + + movl 16(%esp), %ebx /* source pointer */ + movl 24(%esp), %edx /* number of pixels to copy */ + movl 20(%esp), %ecx /* destination pointer */ + + testl %edx, %edx + jle .L35 /* Bail if there's nothing to do. */ + + movl %esp, %ebp + subl $16, %esp + andl $0xfffffff0, %esp + + movl %ebx, %eax + movl %edx, %esi + + negl %eax + andl $15, %eax + sarl $2, %eax + cmpl %edx, %eax + cmovle %eax, %esi + + subl %esi, %edx + + testl $1, %esi + je .L32 + + DO_ONE_PIXEL() +.L32: + + testl $2, %esi + je .L31 + + movq (%ebx), %mm0 + addl $8, %ebx + + movq %mm0, %mm3 + movq %mm0, %mm4 + + pand %mm2, %mm3 + psllq $16, %mm4 + psrlq $16, %mm3 + pand %mm2, %mm4 + + pand %mm1, %mm0 + por %mm4, %mm3 + por %mm3, %mm0 + + movq %mm0, (%ecx) + addl $8, %ecx +.L31: + + movl %edx, %eax + shrl $2, %eax + jmp .L33 +.L34: + movaps (%ebx), %xmm0 + addl $16, %ebx + + /* This would be so much better if we could just move directly from + * an SSE register to an MMX register. Unfortunately, that + * functionality wasn't introduced until SSE2 with the MOVDQ2Q + * instruction. + */ + + movaps %xmm0, (%esp) + movq (%esp), %mm0 + movq 8(%esp), %mm5 + + movq %mm0, %mm3 + movq %mm0, %mm4 + movq %mm5, %mm6 + movq %mm5, %mm7 + + pand %mm2, %mm3 + pand %mm2, %mm6 + + psllq $16, %mm4 + psllq $16, %mm7 + + psrlq $16, %mm3 + psrlq $16, %mm6 + + pand %mm2, %mm4 + pand %mm2, %mm7 + + pand %mm1, %mm0 + pand %mm1, %mm5 + + por %mm4, %mm3 + por %mm7, %mm6 + + por %mm3, %mm0 + por %mm6, %mm5 + + movq %mm0, (%ecx) + movq %mm5, 8(%ecx) + addl $16, %ecx + + subl $1, %eax +.L33: + jne .L34 + +#ifdef USE_INNER_EMMS + emms +#endif + movl %ebp, %esp + + /* At this point there are either [0, 3] pixels remaining to be + * converted. + */ + + testl $2, %edx + je .L36 + + movq (%ebx), %mm0 + addl $8, %ebx + + movq %mm0, %mm3 + movq %mm0, %mm4 + + pand %mm2, %mm3 + psllq $16, %mm4 + psrlq $16, %mm3 + pand %mm2, %mm4 + + pand %mm1, %mm0 + por %mm4, %mm3 + por %mm3, %mm0 + + movq %mm0, (%ecx) + addl $8, %ecx +.L36: + + testl $1, %edx + je .L35 + + DO_ONE_LAST_PIXEL() +.L35: + popl %ebp + popl %ebx + popl %esi + ret + .size _generic_read_RGBA_span_BGRA8888_REV_SSE, .-_generic_read_RGBA_span_BGRA8888_REV_SSE + + +/** + * SSE2 optimized version of the BGRA8888_REV to RGBA copy routine. + */ + + .text +.globl _generic_read_RGBA_span_BGRA8888_REV_SSE2 +.hidden _generic_read_RGBA_span_BGRA8888_REV_SSE2 + .type _generic_read_RGBA_span_BGRA8888_REV_SSE2, @function +_generic_read_RGBA_span_BGRA8888_REV_SSE2: + pushl %esi + pushl %ebx + + LOAD_MASK(movdqu,%xmm1,%xmm2) + + movl 12(%esp), %ebx /* source pointer */ + movl 20(%esp), %edx /* number of pixels to copy */ + movl 16(%esp), %ecx /* destination pointer */ + + movl %ebx, %eax + movl %edx, %esi + + testl %edx, %edx + jle .L46 /* Bail if there's nothing to do. */ + + /* If the source pointer isn't a multiple of 16 we have to process + * a few pixels the "slow" way to get the address aligned for + * the SSE fetch intsructions. + */ + + negl %eax + andl $15, %eax + sarl $2, %eax + + cmpl %edx, %eax + cmovbe %eax, %esi + subl %esi, %edx + + testl $1, %esi + je .L41 + + DO_ONE_PIXEL() +.L41: + testl $2, %esi + je .L40 + + movq (%ebx), %xmm0 + addl $8, %ebx + + movdqa %xmm0, %xmm3 + movdqa %xmm0, %xmm4 + andps %xmm1, %xmm0 + + andps %xmm2, %xmm3 + pslldq $2, %xmm4 + psrldq $2, %xmm3 + andps %xmm2, %xmm4 + + orps %xmm4, %xmm3 + orps %xmm3, %xmm0 + + movq %xmm0, (%ecx) + addl $8, %ecx +.L40: + + /* Would it be worth having a specialized version of this loop for + * the case where the destination is 16-byte aligned? That version + * would be identical except that it could use movedqa instead of + * movdqu. + */ + + movl %edx, %eax + shrl $2, %eax + jmp .L42 +.L43: + movdqa (%ebx), %xmm0 + addl $16, %ebx + + movdqa %xmm0, %xmm3 + movdqa %xmm0, %xmm4 + andps %xmm1, %xmm0 + + andps %xmm2, %xmm3 + pslldq $2, %xmm4 + psrldq $2, %xmm3 + andps %xmm2, %xmm4 + + orps %xmm4, %xmm3 + orps %xmm3, %xmm0 + + movdqu %xmm0, (%ecx) + addl $16, %ecx + subl $1, %eax +.L42: + jne .L43 + + + /* There may be upto 3 pixels remaining to be copied. Take care + * of them now. We do the 2 pixel case first because the data + * will be aligned. + */ + + testl $2, %edx + je .L47 + + movq (%ebx), %xmm0 + addl $8, %ebx + + movdqa %xmm0, %xmm3 + movdqa %xmm0, %xmm4 + andps %xmm1, %xmm0 + + andps %xmm2, %xmm3 + pslldq $2, %xmm4 + psrldq $2, %xmm3 + andps %xmm2, %xmm4 + + orps %xmm4, %xmm3 + orps %xmm3, %xmm0 + + movq %xmm0, (%ecx) + addl $8, %ecx +.L47: + + testl $1, %edx + je .L46 + + DO_ONE_LAST_PIXEL() +.L46: + + popl %ebx + popl %esi + ret + .size _generic_read_RGBA_span_BGRA8888_REV_SSE2, .-_generic_read_RGBA_span_BGRA8888_REV_SSE2 + + + +#define MASK_565_L 0x07e0f800 +#define MASK_565_H 0x0000001f +/* Setting SCALE_ADJUST to 5 gives a perfect match with the + * classic C implementation in Mesa. Setting SCALE_ADJUST + * to 0 is slightly faster but at a small cost to accuracy. + */ +#define SCALE_ADJUST 5 +#if SCALE_ADJUST == 5 +#define PRESCALE_L 0x00100001 +#define PRESCALE_H 0x00000200 +#define SCALE_L 0x40C620E8 +#define SCALE_H 0x0000839d +#elif SCALE_ADJUST == 0 +#define PRESCALE_L 0x00200001 +#define PRESCALE_H 0x00000800 +#define SCALE_L 0x01040108 +#define SCALE_H 0x00000108 +#else +#error SCALE_ADJUST must either be 5 or 0. +#endif +#define ALPHA_L 0x00000000 +#define ALPHA_H 0x00ff0000 + +/** + * MMX optimized version of the RGB565 to RGBA copy routine. + */ + + .text + .globl _generic_read_RGBA_span_RGB565_MMX + .hidden _generic_read_RGBA_span_RGB565_MMX + .type _generic_read_RGBA_span_RGB565_MMX, @function + +_generic_read_RGBA_span_RGB565_MMX: + +#ifdef USE_INNER_EMMS + emms +#endif + + movl 4(%esp), %eax /* source pointer */ + movl 8(%esp), %edx /* destination pointer */ + movl 12(%esp), %ecx /* number of pixels to copy */ + + pushl $MASK_565_H + pushl $MASK_565_L + movq (%esp), %mm5 + pushl $PRESCALE_H + pushl $PRESCALE_L + movq (%esp), %mm6 + pushl $SCALE_H + pushl $SCALE_L + movq (%esp), %mm7 + pushl $ALPHA_H + pushl $ALPHA_L + movq (%esp), %mm3 + addl $32,%esp + + sarl $2, %ecx + jl .L01 /* Bail early if the count is negative. */ + jmp .L02 + +.L03: + /* Fetch 4 RGB565 pixels into %mm4. Distribute the first and + * second pixels into the four words of %mm0 and %mm2. + */ + + movq (%eax), %mm4 + addl $8, %eax + + pshufw $0x00, %mm4, %mm0 + pshufw $0x55, %mm4, %mm2 + + + /* Mask the pixels so that each word of each register contains only + * one color component. + */ + + pand %mm5, %mm0 + pand %mm5, %mm2 + + + /* Adjust the component values so that they are as small as possible, + * but large enough so that we can multiply them by an unsigned 16-bit + * number and get a value as large as 0x00ff0000. + */ + + pmullw %mm6, %mm0 + pmullw %mm6, %mm2 +#if SCALE_ADJUST > 0 + psrlw $SCALE_ADJUST, %mm0 + psrlw $SCALE_ADJUST, %mm2 +#endif + + /* Scale the input component values to be on the range + * [0, 0x00ff0000]. This it the real magic of the whole routine. + */ + + pmulhuw %mm7, %mm0 + pmulhuw %mm7, %mm2 + + + /* Always set the alpha value to 0xff. + */ + + por %mm3, %mm0 + por %mm3, %mm2 + + + /* Pack the 16-bit values to 8-bit values and store the converted + * pixel data. + */ + + packuswb %mm2, %mm0 + movq %mm0, (%edx) + addl $8, %edx + + pshufw $0xaa, %mm4, %mm0 + pshufw $0xff, %mm4, %mm2 + + pand %mm5, %mm0 + pand %mm5, %mm2 + pmullw %mm6, %mm0 + pmullw %mm6, %mm2 +#if SCALE_ADJUST > 0 + psrlw $SCALE_ADJUST, %mm0 + psrlw $SCALE_ADJUST, %mm2 +#endif + pmulhuw %mm7, %mm0 + pmulhuw %mm7, %mm2 + + por %mm3, %mm0 + por %mm3, %mm2 + + packuswb %mm2, %mm0 + + movq %mm0, (%edx) + addl $8, %edx + + subl $1, %ecx +.L02: + jne .L03 + + + /* At this point there can be at most 3 pixels left to process. If + * there is either 2 or 3 left, process 2. + */ + + movl 12(%esp), %ecx + testl $0x02, %ecx + je .L04 + + movd (%eax), %mm4 + addl $4, %eax + + pshufw $0x00, %mm4, %mm0 + pshufw $0x55, %mm4, %mm2 + + pand %mm5, %mm0 + pand %mm5, %mm2 + pmullw %mm6, %mm0 + pmullw %mm6, %mm2 +#if SCALE_ADJUST > 0 + psrlw $SCALE_ADJUST, %mm0 + psrlw $SCALE_ADJUST, %mm2 +#endif + pmulhuw %mm7, %mm0 + pmulhuw %mm7, %mm2 + + por %mm3, %mm0 + por %mm3, %mm2 + + packuswb %mm2, %mm0 + + movq %mm0, (%edx) + addl $8, %edx + +.L04: + /* At this point there can be at most 1 pixel left to process. + * Process it if needed. + */ + + testl $0x01, %ecx + je .L01 + + movzwl (%eax), %ecx + movd %ecx, %mm4 + + pshufw $0x00, %mm4, %mm0 + + pand %mm5, %mm0 + pmullw %mm6, %mm0 +#if SCALE_ADJUST > 0 + psrlw $SCALE_ADJUST, %mm0 +#endif + pmulhuw %mm7, %mm0 + + por %mm3, %mm0 + + packuswb %mm0, %mm0 + + movd %mm0, (%edx) + +.L01: +#ifdef USE_INNER_EMMS + emms +#endif + ret +#endif /* !defined(__DJGPP__) && !defined(__MINGW32__) && !defined(__APPLE__) */ + +#if defined (__ELF__) && defined (__linux__) + .section .note.GNU-stack,"",%progbits +#endif |