From 6eb71519f7d08344b7f9819db22980f9c6fade3c Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 3 Nov 2009 16:13:22 -0700 Subject: mesa: (GLint64) casts in get.c to silence Visual Studio warnings Revised version of a patch from Karl Schultz. --- src/mesa/main/get.c | 344 ++++++++++++++++++++++++++-------------------------- 1 file changed, 172 insertions(+), 172 deletions(-) (limited to 'src/mesa/main/get.c') diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c index 477ed01030..604b106217 100644 --- a/src/mesa/main/get.c +++ b/src/mesa/main/get.c @@ -5580,16 +5580,16 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params ) switch (pname) { case GL_ACCUM_RED_BITS: - params[0] = ctx->DrawBuffer->Visual.accumRedBits; + params[0] = (GLint64)(ctx->DrawBuffer->Visual.accumRedBits); break; case GL_ACCUM_GREEN_BITS: - params[0] = ctx->DrawBuffer->Visual.accumGreenBits; + params[0] = (GLint64)(ctx->DrawBuffer->Visual.accumGreenBits); break; case GL_ACCUM_BLUE_BITS: - params[0] = ctx->DrawBuffer->Visual.accumBlueBits; + params[0] = (GLint64)(ctx->DrawBuffer->Visual.accumBlueBits); break; case GL_ACCUM_ALPHA_BITS: - params[0] = ctx->DrawBuffer->Visual.accumAlphaBits; + params[0] = (GLint64)(ctx->DrawBuffer->Visual.accumAlphaBits); break; case GL_ACCUM_CLEAR_VALUE: params[0] = FLOAT_TO_INT64(ctx->Accum.ClearColor[0]); @@ -5601,7 +5601,7 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params ) params[0] = IROUND64(ctx->Pixel.AlphaBias); break; case GL_ALPHA_BITS: - params[0] = ctx->DrawBuffer->Visual.alphaBits; + params[0] = (GLint64)(ctx->DrawBuffer->Visual.alphaBits); break; case GL_ALPHA_SCALE: params[0] = IROUND64(ctx->Pixel.AlphaScale); @@ -5616,13 +5616,13 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params ) params[0] = FLOAT_TO_INT64(ctx->Color.AlphaRef); break; case GL_ATTRIB_STACK_DEPTH: - params[0] = ctx->AttribStackDepth; + params[0] = (GLint64)(ctx->AttribStackDepth); break; case GL_AUTO_NORMAL: params[0] = BOOLEAN_TO_INT64(ctx->Eval.AutoNormal); break; case GL_AUX_BUFFERS: - params[0] = ctx->DrawBuffer->Visual.numAuxBuffers; + params[0] = (GLint64)(ctx->DrawBuffer->Visual.numAuxBuffers); break; case GL_BLEND: params[0] = BOOLEAN_TO_INT64(ctx->Color.BlendEnabled); @@ -5661,13 +5661,13 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params ) params[0] = IROUND64(ctx->Pixel.BlueBias); break; case GL_BLUE_BITS: - params[0] = ctx->DrawBuffer->Visual.blueBits; + params[0] = (GLint64)(ctx->DrawBuffer->Visual.blueBits); break; case GL_BLUE_SCALE: params[0] = IROUND64(ctx->Pixel.BlueScale); break; case GL_CLIENT_ATTRIB_STACK_DEPTH: - params[0] = ctx->ClientAttribStackDepth; + params[0] = (GLint64)(ctx->ClientAttribStackDepth); break; case GL_CLIP_PLANE0: params[0] = BOOLEAN_TO_INT64((ctx->Transform.ClipPlanesEnabled >> 0) & 1); @@ -5703,10 +5703,10 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params ) params[0] = ENUM_TO_INT64(ctx->Light.ColorMaterialMode); break; case GL_COLOR_WRITEMASK: - params[0] = ctx->Color.ColorMask[RCOMP] ? 1 : 0; - params[1] = ctx->Color.ColorMask[GCOMP] ? 1 : 0; - params[2] = ctx->Color.ColorMask[BCOMP] ? 1 : 0; - params[3] = ctx->Color.ColorMask[ACOMP] ? 1 : 0; + params[0] = (GLint64)(ctx->Color.ColorMask[RCOMP] ? 1 : 0); + params[1] = (GLint64)(ctx->Color.ColorMask[GCOMP] ? 1 : 0); + params[2] = (GLint64)(ctx->Color.ColorMask[BCOMP] ? 1 : 0); + params[3] = (GLint64)(ctx->Color.ColorMask[ACOMP] ? 1 : 0); break; case GL_CULL_FACE: params[0] = BOOLEAN_TO_INT64(ctx->Polygon.CullFlag); @@ -5787,7 +5787,7 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params ) params[0] = IROUND64(ctx->Pixel.DepthBias); break; case GL_DEPTH_BITS: - params[0] = ctx->DrawBuffer->Visual.depthBits; + params[0] = (GLint64)(ctx->DrawBuffer->Visual.depthBits); break; case GL_DEPTH_CLEAR_VALUE: params[0] = FLOAT_TO_INT64(((GLfloat) ctx->Depth.Clear)); @@ -5824,7 +5824,7 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params ) } break; case GL_FEEDBACK_BUFFER_SIZE: - params[0] = ctx->Feedback.BufferSize; + params[0] = (GLint64)(ctx->Feedback.BufferSize); break; case GL_FEEDBACK_BUFFER_TYPE: params[0] = ENUM_TO_INT64(ctx->Feedback.Type); @@ -5863,28 +5863,28 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params ) params[0] = IROUND64(ctx->Pixel.GreenBias); break; case GL_GREEN_BITS: - params[0] = ctx->DrawBuffer->Visual.greenBits; + params[0] = (GLint64)(ctx->DrawBuffer->Visual.greenBits); break; case GL_GREEN_SCALE: params[0] = IROUND64(ctx->Pixel.GreenScale); break; case GL_INDEX_BITS: - params[0] = ctx->DrawBuffer->Visual.indexBits; + params[0] = (GLint64)(ctx->DrawBuffer->Visual.indexBits); break; case GL_INDEX_CLEAR_VALUE: - params[0] = ctx->Color.ClearIndex; + params[0] = (GLint64)(ctx->Color.ClearIndex); break; case GL_INDEX_MODE: params[0] = BOOLEAN_TO_INT64(!ctx->DrawBuffer->Visual.rgbMode); break; case GL_INDEX_OFFSET: - params[0] = ctx->Pixel.IndexOffset; + params[0] = (GLint64)(ctx->Pixel.IndexOffset); break; case GL_INDEX_SHIFT: - params[0] = ctx->Pixel.IndexShift; + params[0] = (GLint64)(ctx->Pixel.IndexShift); break; case GL_INDEX_WRITEMASK: - params[0] = ctx->Color.IndexMask; + params[0] = (GLint64)(ctx->Color.IndexMask); break; case GL_LIGHT0: params[0] = BOOLEAN_TO_INT64(ctx->Light.Light[0].Enabled); @@ -5938,10 +5938,10 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params ) params[0] = BOOLEAN_TO_INT64(ctx->Line.StippleFlag); break; case GL_LINE_STIPPLE_PATTERN: - params[0] = ctx->Line.StipplePattern; + params[0] = (GLint64)(ctx->Line.StipplePattern); break; case GL_LINE_STIPPLE_REPEAT: - params[0] = ctx->Line.StippleFactor; + params[0] = (GLint64)(ctx->Line.StippleFactor); break; case GL_LINE_WIDTH: params[0] = IROUND64(ctx->Line.Width); @@ -5958,10 +5958,10 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params ) params[1] = IROUND64(ctx->Const.MaxLineWidth); break; case GL_LIST_BASE: - params[0] = ctx->List.ListBase; + params[0] = (GLint64)(ctx->List.ListBase); break; case GL_LIST_INDEX: - params[0] = (ctx->ListState.CurrentList ? ctx->ListState.CurrentList->Name : 0); + params[0] = (GLint64)((ctx->ListState.CurrentList ? ctx->ListState.CurrentList->Name : 0)); break; case GL_LIST_MODE: { @@ -5992,7 +5992,7 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params ) params[1] = IROUND64(ctx->Eval.MapGrid1u2); break; case GL_MAP1_GRID_SEGMENTS: - params[0] = ctx->Eval.MapGrid1un; + params[0] = (GLint64)(ctx->Eval.MapGrid1un); break; case GL_MAP1_INDEX: params[0] = BOOLEAN_TO_INT64(ctx->Eval.Map1Index); @@ -6028,8 +6028,8 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params ) params[3] = IROUND64(ctx->Eval.MapGrid2v2); break; case GL_MAP2_GRID_SEGMENTS: - params[0] = ctx->Eval.MapGrid2un; - params[1] = ctx->Eval.MapGrid2vn; + params[0] = (GLint64)(ctx->Eval.MapGrid2un); + params[1] = (GLint64)(ctx->Eval.MapGrid2vn); break; case GL_MAP2_INDEX: params[0] = BOOLEAN_TO_INT64(ctx->Eval.Map2Index); @@ -6065,53 +6065,53 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params ) params[0] = ENUM_TO_INT64(ctx->Transform.MatrixMode); break; case GL_MAX_ATTRIB_STACK_DEPTH: - params[0] = MAX_ATTRIB_STACK_DEPTH; + params[0] = (GLint64)(MAX_ATTRIB_STACK_DEPTH); break; case GL_MAX_CLIENT_ATTRIB_STACK_DEPTH: - params[0] = MAX_CLIENT_ATTRIB_STACK_DEPTH; + params[0] = (GLint64)(MAX_CLIENT_ATTRIB_STACK_DEPTH); break; case GL_MAX_CLIP_PLANES: - params[0] = ctx->Const.MaxClipPlanes; + params[0] = (GLint64)(ctx->Const.MaxClipPlanes); break; case GL_MAX_ELEMENTS_VERTICES: - params[0] = ctx->Const.MaxArrayLockSize; + params[0] = (GLint64)(ctx->Const.MaxArrayLockSize); break; case GL_MAX_ELEMENTS_INDICES: - params[0] = ctx->Const.MaxArrayLockSize; + params[0] = (GLint64)(ctx->Const.MaxArrayLockSize); break; case GL_MAX_EVAL_ORDER: - params[0] = MAX_EVAL_ORDER; + params[0] = (GLint64)(MAX_EVAL_ORDER); break; case GL_MAX_LIGHTS: - params[0] = ctx->Const.MaxLights; + params[0] = (GLint64)(ctx->Const.MaxLights); break; case GL_MAX_LIST_NESTING: - params[0] = MAX_LIST_NESTING; + params[0] = (GLint64)(MAX_LIST_NESTING); break; case GL_MAX_MODELVIEW_STACK_DEPTH: - params[0] = MAX_MODELVIEW_STACK_DEPTH; + params[0] = (GLint64)(MAX_MODELVIEW_STACK_DEPTH); break; case GL_MAX_NAME_STACK_DEPTH: - params[0] = MAX_NAME_STACK_DEPTH; + params[0] = (GLint64)(MAX_NAME_STACK_DEPTH); break; case GL_MAX_PIXEL_MAP_TABLE: - params[0] = MAX_PIXEL_MAP_TABLE; + params[0] = (GLint64)(MAX_PIXEL_MAP_TABLE); break; case GL_MAX_PROJECTION_STACK_DEPTH: - params[0] = MAX_PROJECTION_STACK_DEPTH; + params[0] = (GLint64)(MAX_PROJECTION_STACK_DEPTH); break; case GL_MAX_TEXTURE_SIZE: - params[0] = 1 << (ctx->Const.MaxTextureLevels - 1); + params[0] = (GLint64)(1 << (ctx->Const.MaxTextureLevels - 1)); break; case GL_MAX_3D_TEXTURE_SIZE: - params[0] = 1 << (ctx->Const.Max3DTextureLevels - 1); + params[0] = (GLint64)(1 << (ctx->Const.Max3DTextureLevels - 1)); break; case GL_MAX_TEXTURE_STACK_DEPTH: - params[0] = MAX_TEXTURE_STACK_DEPTH; + params[0] = (GLint64)(MAX_TEXTURE_STACK_DEPTH); break; case GL_MAX_VIEWPORT_DIMS: - params[0] = ctx->Const.MaxViewportWidth; - params[1] = ctx->Const.MaxViewportHeight; + params[0] = (GLint64)(ctx->Const.MaxViewportWidth); + params[1] = (GLint64)(ctx->Const.MaxViewportHeight); break; case GL_MODELVIEW_MATRIX: { @@ -6135,37 +6135,37 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params ) } break; case GL_MODELVIEW_STACK_DEPTH: - params[0] = ctx->ModelviewMatrixStack.Depth + 1; + params[0] = (GLint64)(ctx->ModelviewMatrixStack.Depth + 1); break; case GL_NAME_STACK_DEPTH: - params[0] = ctx->Select.NameStackDepth; + params[0] = (GLint64)(ctx->Select.NameStackDepth); break; case GL_NORMALIZE: params[0] = BOOLEAN_TO_INT64(ctx->Transform.Normalize); break; case GL_PACK_ALIGNMENT: - params[0] = ctx->Pack.Alignment; + params[0] = (GLint64)(ctx->Pack.Alignment); break; case GL_PACK_LSB_FIRST: params[0] = BOOLEAN_TO_INT64(ctx->Pack.LsbFirst); break; case GL_PACK_ROW_LENGTH: - params[0] = ctx->Pack.RowLength; + params[0] = (GLint64)(ctx->Pack.RowLength); break; case GL_PACK_SKIP_PIXELS: - params[0] = ctx->Pack.SkipPixels; + params[0] = (GLint64)(ctx->Pack.SkipPixels); break; case GL_PACK_SKIP_ROWS: - params[0] = ctx->Pack.SkipRows; + params[0] = (GLint64)(ctx->Pack.SkipRows); break; case GL_PACK_SWAP_BYTES: params[0] = BOOLEAN_TO_INT64(ctx->Pack.SwapBytes); break; case GL_PACK_SKIP_IMAGES_EXT: - params[0] = ctx->Pack.SkipImages; + params[0] = (GLint64)(ctx->Pack.SkipImages); break; case GL_PACK_IMAGE_HEIGHT_EXT: - params[0] = ctx->Pack.ImageHeight; + params[0] = (GLint64)(ctx->Pack.ImageHeight); break; case GL_PACK_INVERT_MESA: params[0] = BOOLEAN_TO_INT64(ctx->Pack.Invert); @@ -6174,34 +6174,34 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params ) params[0] = ENUM_TO_INT64(ctx->Hint.PerspectiveCorrection); break; case GL_PIXEL_MAP_A_TO_A_SIZE: - params[0] = ctx->PixelMaps.AtoA.Size; + params[0] = (GLint64)(ctx->PixelMaps.AtoA.Size); break; case GL_PIXEL_MAP_B_TO_B_SIZE: - params[0] = ctx->PixelMaps.BtoB.Size; + params[0] = (GLint64)(ctx->PixelMaps.BtoB.Size); break; case GL_PIXEL_MAP_G_TO_G_SIZE: - params[0] = ctx->PixelMaps.GtoG.Size; + params[0] = (GLint64)(ctx->PixelMaps.GtoG.Size); break; case GL_PIXEL_MAP_I_TO_A_SIZE: - params[0] = ctx->PixelMaps.ItoA.Size; + params[0] = (GLint64)(ctx->PixelMaps.ItoA.Size); break; case GL_PIXEL_MAP_I_TO_B_SIZE: - params[0] = ctx->PixelMaps.ItoB.Size; + params[0] = (GLint64)(ctx->PixelMaps.ItoB.Size); break; case GL_PIXEL_MAP_I_TO_G_SIZE: - params[0] = ctx->PixelMaps.ItoG.Size; + params[0] = (GLint64)(ctx->PixelMaps.ItoG.Size); break; case GL_PIXEL_MAP_I_TO_I_SIZE: - params[0] = ctx->PixelMaps.ItoI.Size; + params[0] = (GLint64)(ctx->PixelMaps.ItoI.Size); break; case GL_PIXEL_MAP_I_TO_R_SIZE: - params[0] = ctx->PixelMaps.ItoR.Size; + params[0] = (GLint64)(ctx->PixelMaps.ItoR.Size); break; case GL_PIXEL_MAP_R_TO_R_SIZE: - params[0] = ctx->PixelMaps.RtoR.Size; + params[0] = (GLint64)(ctx->PixelMaps.RtoR.Size); break; case GL_PIXEL_MAP_S_TO_S_SIZE: - params[0] = ctx->PixelMaps.StoS.Size; + params[0] = (GLint64)(ctx->PixelMaps.StoS.Size); break; case GL_POINT_SIZE: params[0] = IROUND64(ctx->Point.Size); @@ -6290,7 +6290,7 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params ) } break; case GL_PROJECTION_STACK_DEPTH: - params[0] = ctx->ProjectionMatrixStack.Depth + 1; + params[0] = (GLint64)(ctx->ProjectionMatrixStack.Depth + 1); break; case GL_READ_BUFFER: params[0] = ENUM_TO_INT64(ctx->ReadBuffer->ColorReadBuffer); @@ -6299,7 +6299,7 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params ) params[0] = IROUND64(ctx->Pixel.RedBias); break; case GL_RED_BITS: - params[0] = ctx->DrawBuffer->Visual.redBits; + params[0] = (GLint64)(ctx->DrawBuffer->Visual.redBits); break; case GL_RED_SCALE: params[0] = IROUND64(ctx->Pixel.RedScale); @@ -6314,16 +6314,16 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params ) params[0] = BOOLEAN_TO_INT64(ctx->DrawBuffer->Visual.rgbMode); break; case GL_SCISSOR_BOX: - params[0] = ctx->Scissor.X; - params[1] = ctx->Scissor.Y; - params[2] = ctx->Scissor.Width; - params[3] = ctx->Scissor.Height; + params[0] = (GLint64)(ctx->Scissor.X); + params[1] = (GLint64)(ctx->Scissor.Y); + params[2] = (GLint64)(ctx->Scissor.Width); + params[3] = (GLint64)(ctx->Scissor.Height); break; case GL_SCISSOR_TEST: params[0] = BOOLEAN_TO_INT64(ctx->Scissor.Enabled); break; case GL_SELECTION_BUFFER_SIZE: - params[0] = ctx->Select.BufferSize; + params[0] = (GLint64)(ctx->Select.BufferSize); break; case GL_SHADE_MODEL: params[0] = ENUM_TO_INT64(ctx->Light.ShadeModel); @@ -6332,10 +6332,10 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params ) params[0] = BOOLEAN_TO_INT64(ctx->Texture.SharedPalette); break; case GL_STENCIL_BITS: - params[0] = ctx->DrawBuffer->Visual.stencilBits; + params[0] = (GLint64)(ctx->DrawBuffer->Visual.stencilBits); break; case GL_STENCIL_CLEAR_VALUE: - params[0] = ctx->Stencil.Clear; + params[0] = (GLint64)(ctx->Stencil.Clear); break; case GL_STENCIL_FAIL: params[0] = ENUM_TO_INT64(ctx->Stencil.FailFunc[ctx->Stencil.ActiveFace]); @@ -6350,22 +6350,22 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params ) params[0] = ENUM_TO_INT64(ctx->Stencil.ZPassFunc[ctx->Stencil.ActiveFace]); break; case GL_STENCIL_REF: - params[0] = ctx->Stencil.Ref[ctx->Stencil.ActiveFace]; + params[0] = (GLint64)(ctx->Stencil.Ref[ctx->Stencil.ActiveFace]); break; case GL_STENCIL_TEST: params[0] = BOOLEAN_TO_INT64(ctx->Stencil.Enabled); break; case GL_STENCIL_VALUE_MASK: - params[0] = ctx->Stencil.ValueMask[ctx->Stencil.ActiveFace]; + params[0] = (GLint64)(ctx->Stencil.ValueMask[ctx->Stencil.ActiveFace]); break; case GL_STENCIL_WRITEMASK: - params[0] = ctx->Stencil.WriteMask[ctx->Stencil.ActiveFace]; + params[0] = (GLint64)(ctx->Stencil.WriteMask[ctx->Stencil.ActiveFace]); break; case GL_STEREO: params[0] = BOOLEAN_TO_INT64(ctx->DrawBuffer->Visual.stereoMode); break; case GL_SUBPIXEL_BITS: - params[0] = ctx->Const.SubPixelBits; + params[0] = (GLint64)(ctx->Const.SubPixelBits); break; case GL_TEXTURE_1D: params[0] = BOOLEAN_TO_INT64(_mesa_IsEnabled(GL_TEXTURE_1D)); @@ -6385,21 +6385,21 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params ) params[0] = BOOLEAN_TO_INT64(_mesa_IsEnabled(GL_TEXTURE_2D_ARRAY_EXT)); break; case GL_TEXTURE_BINDING_1D: - params[0] = ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_1D_INDEX]->Name; + params[0] = (GLint64)(ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_1D_INDEX]->Name); break; case GL_TEXTURE_BINDING_2D: - params[0] = ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_2D_INDEX]->Name; + params[0] = (GLint64)(ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_2D_INDEX]->Name); break; case GL_TEXTURE_BINDING_3D: - params[0] = ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_3D_INDEX]->Name; + params[0] = (GLint64)(ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_3D_INDEX]->Name); break; case GL_TEXTURE_BINDING_1D_ARRAY_EXT: CHECK_EXT1(MESA_texture_array, "GetInteger64v"); - params[0] = ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_1D_ARRAY_INDEX]->Name; + params[0] = (GLint64)(ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_1D_ARRAY_INDEX]->Name); break; case GL_TEXTURE_BINDING_2D_ARRAY_EXT: CHECK_EXT1(MESA_texture_array, "GetInteger64v"); - params[0] = ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_2D_ARRAY_INDEX]->Name; + params[0] = (GLint64)(ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_2D_ARRAY_INDEX]->Name); break; case GL_TEXTURE_GEN_S: params[0] = BOOLEAN_TO_INT64(((ctx->Texture.Unit[ctx->Texture.CurrentUnit].TexGenEnabled & S_BIT) ? 1 : 0)); @@ -6435,40 +6435,40 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params ) } break; case GL_TEXTURE_STACK_DEPTH: - params[0] = ctx->TextureMatrixStack[ctx->Texture.CurrentUnit].Depth + 1; + params[0] = (GLint64)(ctx->TextureMatrixStack[ctx->Texture.CurrentUnit].Depth + 1); break; case GL_UNPACK_ALIGNMENT: - params[0] = ctx->Unpack.Alignment; + params[0] = (GLint64)(ctx->Unpack.Alignment); break; case GL_UNPACK_LSB_FIRST: params[0] = BOOLEAN_TO_INT64(ctx->Unpack.LsbFirst); break; case GL_UNPACK_ROW_LENGTH: - params[0] = ctx->Unpack.RowLength; + params[0] = (GLint64)(ctx->Unpack.RowLength); break; case GL_UNPACK_SKIP_PIXELS: - params[0] = ctx->Unpack.SkipPixels; + params[0] = (GLint64)(ctx->Unpack.SkipPixels); break; case GL_UNPACK_SKIP_ROWS: - params[0] = ctx->Unpack.SkipRows; + params[0] = (GLint64)(ctx->Unpack.SkipRows); break; case GL_UNPACK_SWAP_BYTES: params[0] = BOOLEAN_TO_INT64(ctx->Unpack.SwapBytes); break; case GL_UNPACK_SKIP_IMAGES_EXT: - params[0] = ctx->Unpack.SkipImages; + params[0] = (GLint64)(ctx->Unpack.SkipImages); break; case GL_UNPACK_IMAGE_HEIGHT_EXT: - params[0] = ctx->Unpack.ImageHeight; + params[0] = (GLint64)(ctx->Unpack.ImageHeight); break; case GL_UNPACK_CLIENT_STORAGE_APPLE: params[0] = BOOLEAN_TO_INT64(ctx->Unpack.ClientStorage); break; case GL_VIEWPORT: - params[0] = ctx->Viewport.X; - params[1] = ctx->Viewport.Y; - params[2] = ctx->Viewport.Width; - params[3] = ctx->Viewport.Height; + params[0] = (GLint64)(ctx->Viewport.X); + params[1] = (GLint64)(ctx->Viewport.Y); + params[2] = (GLint64)(ctx->Viewport.Width); + params[3] = (GLint64)(ctx->Viewport.Height); break; case GL_ZOOM_X: params[0] = IROUND64(ctx->Pixel.ZoomX); @@ -6480,16 +6480,16 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params ) params[0] = BOOLEAN_TO_INT64(ctx->Array.ArrayObj->Vertex.Enabled); break; case GL_VERTEX_ARRAY_SIZE: - params[0] = ctx->Array.ArrayObj->Vertex.Size; + params[0] = (GLint64)(ctx->Array.ArrayObj->Vertex.Size); break; case GL_VERTEX_ARRAY_TYPE: params[0] = ENUM_TO_INT64(ctx->Array.ArrayObj->Vertex.Type); break; case GL_VERTEX_ARRAY_STRIDE: - params[0] = ctx->Array.ArrayObj->Vertex.Stride; + params[0] = (GLint64)(ctx->Array.ArrayObj->Vertex.Stride); break; case GL_VERTEX_ARRAY_COUNT_EXT: - params[0] = 0; + params[0] = (GLint64)(0); break; case GL_NORMAL_ARRAY: params[0] = ENUM_TO_INT64(ctx->Array.ArrayObj->Normal.Enabled); @@ -6498,25 +6498,25 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params ) params[0] = ENUM_TO_INT64(ctx->Array.ArrayObj->Normal.Type); break; case GL_NORMAL_ARRAY_STRIDE: - params[0] = ctx->Array.ArrayObj->Normal.Stride; + params[0] = (GLint64)(ctx->Array.ArrayObj->Normal.Stride); break; case GL_NORMAL_ARRAY_COUNT_EXT: - params[0] = 0; + params[0] = (GLint64)(0); break; case GL_COLOR_ARRAY: params[0] = BOOLEAN_TO_INT64(ctx->Array.ArrayObj->Color.Enabled); break; case GL_COLOR_ARRAY_SIZE: - params[0] = ctx->Array.ArrayObj->Color.Size; + params[0] = (GLint64)(ctx->Array.ArrayObj->Color.Size); break; case GL_COLOR_ARRAY_TYPE: params[0] = ENUM_TO_INT64(ctx->Array.ArrayObj->Color.Type); break; case GL_COLOR_ARRAY_STRIDE: - params[0] = ctx->Array.ArrayObj->Color.Stride; + params[0] = (GLint64)(ctx->Array.ArrayObj->Color.Stride); break; case GL_COLOR_ARRAY_COUNT_EXT: - params[0] = 0; + params[0] = (GLint64)(0); break; case GL_INDEX_ARRAY: params[0] = BOOLEAN_TO_INT64(ctx->Array.ArrayObj->Index.Enabled); @@ -6525,46 +6525,46 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params ) params[0] = ENUM_TO_INT64(ctx->Array.ArrayObj->Index.Type); break; case GL_INDEX_ARRAY_STRIDE: - params[0] = ctx->Array.ArrayObj->Index.Stride; + params[0] = (GLint64)(ctx->Array.ArrayObj->Index.Stride); break; case GL_INDEX_ARRAY_COUNT_EXT: - params[0] = 0; + params[0] = (GLint64)(0); break; case GL_TEXTURE_COORD_ARRAY: params[0] = BOOLEAN_TO_INT64(ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].Enabled); break; case GL_TEXTURE_COORD_ARRAY_SIZE: - params[0] = ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].Size; + params[0] = (GLint64)(ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].Size); break; case GL_TEXTURE_COORD_ARRAY_TYPE: params[0] = ENUM_TO_INT64(ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].Type); break; case GL_TEXTURE_COORD_ARRAY_STRIDE: - params[0] = ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].Stride; + params[0] = (GLint64)(ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].Stride); break; case GL_TEXTURE_COORD_ARRAY_COUNT_EXT: - params[0] = 0; + params[0] = (GLint64)(0); break; case GL_EDGE_FLAG_ARRAY: params[0] = BOOLEAN_TO_INT64(ctx->Array.ArrayObj->EdgeFlag.Enabled); break; case GL_EDGE_FLAG_ARRAY_STRIDE: - params[0] = ctx->Array.ArrayObj->EdgeFlag.Stride; + params[0] = (GLint64)(ctx->Array.ArrayObj->EdgeFlag.Stride); break; case GL_EDGE_FLAG_ARRAY_COUNT_EXT: - params[0] = 0; + params[0] = (GLint64)(0); break; case GL_MAX_TEXTURE_UNITS_ARB: CHECK_EXT1(ARB_multitexture, "GetInteger64v"); - params[0] = ctx->Const.MaxTextureUnits; + params[0] = (GLint64)(ctx->Const.MaxTextureUnits); break; case GL_ACTIVE_TEXTURE_ARB: CHECK_EXT1(ARB_multitexture, "GetInteger64v"); - params[0] = GL_TEXTURE0_ARB + ctx->Texture.CurrentUnit; + params[0] = (GLint64)(GL_TEXTURE0_ARB + ctx->Texture.CurrentUnit); break; case GL_CLIENT_ACTIVE_TEXTURE_ARB: CHECK_EXT1(ARB_multitexture, "GetInteger64v"); - params[0] = GL_TEXTURE0_ARB + ctx->Array.ActiveTexture; + params[0] = (GLint64)(GL_TEXTURE0_ARB + ctx->Array.ActiveTexture); break; case GL_TEXTURE_CUBE_MAP_ARB: CHECK_EXT1(ARB_texture_cube_map, "GetInteger64v"); @@ -6572,17 +6572,17 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params ) break; case GL_TEXTURE_BINDING_CUBE_MAP_ARB: CHECK_EXT1(ARB_texture_cube_map, "GetInteger64v"); - params[0] = ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_CUBE_INDEX]->Name; + params[0] = (GLint64)(ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_CUBE_INDEX]->Name); break; case GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB: CHECK_EXT1(ARB_texture_cube_map, "GetInteger64v"); - params[0] = (1 << (ctx->Const.MaxCubeTextureLevels - 1)); + params[0] = (GLint64)((1 << (ctx->Const.MaxCubeTextureLevels - 1))); break; case GL_TEXTURE_COMPRESSION_HINT_ARB: - params[0] = ctx->Hint.TextureCompression; + params[0] = (GLint64)(ctx->Hint.TextureCompression); break; case GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB: - params[0] = _mesa_get_compressed_formats(ctx, NULL, GL_FALSE); + params[0] = (GLint64)(_mesa_get_compressed_formats(ctx, NULL, GL_FALSE)); break; case GL_COMPRESSED_TEXTURE_FORMATS_ARB: { @@ -6595,11 +6595,11 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params ) break; case GL_ARRAY_ELEMENT_LOCK_FIRST_EXT: CHECK_EXT1(EXT_compiled_vertex_array, "GetInteger64v"); - params[0] = ctx->Array.LockFirst; + params[0] = (GLint64)(ctx->Array.LockFirst); break; case GL_ARRAY_ELEMENT_LOCK_COUNT_EXT: CHECK_EXT1(EXT_compiled_vertex_array, "GetInteger64v"); - params[0] = ctx->Array.LockCount; + params[0] = (GLint64)(ctx->Array.LockCount); break; case GL_TRANSPOSE_COLOR_MATRIX_ARB: { @@ -6707,10 +6707,10 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params ) } break; case GL_COLOR_MATRIX_STACK_DEPTH_SGI: - params[0] = ctx->ColorMatrixStack.Depth + 1; + params[0] = (GLint64)(ctx->ColorMatrixStack.Depth + 1); break; case GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI: - params[0] = MAX_COLOR_STACK_DEPTH; + params[0] = (GLint64)(MAX_COLOR_STACK_DEPTH); break; case GL_POST_COLOR_MATRIX_RED_SCALE_SGI: params[0] = IROUND64(ctx->Pixel.PostColorMatrixScale[0]); @@ -6828,11 +6828,11 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params ) break; case GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT: CHECK_EXT1(EXT_secondary_color, "GetInteger64v"); - params[0] = ctx->Array.ArrayObj->SecondaryColor.Stride; + params[0] = (GLint64)(ctx->Array.ArrayObj->SecondaryColor.Stride); break; case GL_SECONDARY_COLOR_ARRAY_SIZE_EXT: CHECK_EXT1(EXT_secondary_color, "GetInteger64v"); - params[0] = ctx->Array.ArrayObj->SecondaryColor.Size; + params[0] = (GLint64)(ctx->Array.ArrayObj->SecondaryColor.Size); break; case GL_CURRENT_FOG_COORDINATE_EXT: CHECK_EXT1(EXT_fog_coord, "GetInteger64v"); @@ -6851,7 +6851,7 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params ) break; case GL_FOG_COORDINATE_ARRAY_STRIDE_EXT: CHECK_EXT1(EXT_fog_coord, "GetInteger64v"); - params[0] = ctx->Array.ArrayObj->FogCoord.Stride; + params[0] = (GLint64)(ctx->Array.ArrayObj->FogCoord.Stride); break; case GL_FOG_COORDINATE_SOURCE_EXT: CHECK_EXT1(EXT_fog_coord, "GetInteger64v"); @@ -6884,10 +6884,10 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params ) params[0] = BOOLEAN_TO_INT64(ctx->Multisample.SampleCoverageInvert); break; case GL_SAMPLE_BUFFERS_ARB: - params[0] = ctx->DrawBuffer->Visual.sampleBuffers; + params[0] = (GLint64)(ctx->DrawBuffer->Visual.sampleBuffers); break; case GL_SAMPLES_ARB: - params[0] = ctx->DrawBuffer->Visual.samples; + params[0] = (GLint64)(ctx->DrawBuffer->Visual.samples); break; case GL_RASTER_POSITION_UNCLIPPED_IBM: CHECK_EXT1(IBM_rasterpos_clip, "GetInteger64v"); @@ -6911,7 +6911,7 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params ) break; case GL_VERTEX_PROGRAM_BINDING_NV: CHECK_EXT1(NV_vertex_program, "GetInteger64v"); - params[0] = (ctx->VertexProgram.Current ? ctx->VertexProgram.Current->Base.Id : 0); + params[0] = (GLint64)((ctx->VertexProgram.Current ? ctx->VertexProgram.Current->Base.Id : 0)); break; case GL_VERTEX_ATTRIB_ARRAY0_NV: CHECK_EXT1(NV_vertex_program, "GetInteger64v"); @@ -7047,11 +7047,11 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params ) break; case GL_FRAGMENT_PROGRAM_BINDING_NV: CHECK_EXT1(NV_fragment_program, "GetInteger64v"); - params[0] = ctx->FragmentProgram.Current ? ctx->FragmentProgram.Current->Base.Id : 0; + params[0] = (GLint64)(ctx->FragmentProgram.Current ? ctx->FragmentProgram.Current->Base.Id : 0); break; case GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV: CHECK_EXT1(NV_fragment_program, "GetInteger64v"); - params[0] = MAX_NV_FRAGMENT_PROGRAM_PARAMS; + params[0] = (GLint64)(MAX_NV_FRAGMENT_PROGRAM_PARAMS); break; case GL_TEXTURE_RECTANGLE_NV: CHECK_EXT1(NV_texture_rectangle, "GetInteger64v"); @@ -7059,11 +7059,11 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params ) break; case GL_TEXTURE_BINDING_RECTANGLE_NV: CHECK_EXT1(NV_texture_rectangle, "GetInteger64v"); - params[0] = ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_RECT_INDEX]->Name; + params[0] = (GLint64)(ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_RECT_INDEX]->Name); break; case GL_MAX_RECTANGLE_TEXTURE_SIZE_NV: CHECK_EXT1(NV_texture_rectangle, "GetInteger64v"); - params[0] = ctx->Const.MaxTextureRectSize; + params[0] = (GLint64)(ctx->Const.MaxTextureRectSize); break; case GL_STENCIL_TEST_TWO_SIDE_EXT: CHECK_EXT1(EXT_stencil_two_side, "GetInteger64v"); @@ -7082,42 +7082,42 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params ) params[0] = IROUND64(ctx->Const.MaxSpotExponent); break; case GL_ARRAY_BUFFER_BINDING_ARB: - params[0] = ctx->Array.ArrayBufferObj->Name; + params[0] = (GLint64)(ctx->Array.ArrayBufferObj->Name); break; case GL_VERTEX_ARRAY_BUFFER_BINDING_ARB: - params[0] = ctx->Array.ArrayObj->Vertex.BufferObj->Name; + params[0] = (GLint64)(ctx->Array.ArrayObj->Vertex.BufferObj->Name); break; case GL_NORMAL_ARRAY_BUFFER_BINDING_ARB: - params[0] = ctx->Array.ArrayObj->Normal.BufferObj->Name; + params[0] = (GLint64)(ctx->Array.ArrayObj->Normal.BufferObj->Name); break; case GL_COLOR_ARRAY_BUFFER_BINDING_ARB: - params[0] = ctx->Array.ArrayObj->Color.BufferObj->Name; + params[0] = (GLint64)(ctx->Array.ArrayObj->Color.BufferObj->Name); break; case GL_INDEX_ARRAY_BUFFER_BINDING_ARB: - params[0] = ctx->Array.ArrayObj->Index.BufferObj->Name; + params[0] = (GLint64)(ctx->Array.ArrayObj->Index.BufferObj->Name); break; case GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB: - params[0] = ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].BufferObj->Name; + params[0] = (GLint64)(ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].BufferObj->Name); break; case GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB: - params[0] = ctx->Array.ArrayObj->EdgeFlag.BufferObj->Name; + params[0] = (GLint64)(ctx->Array.ArrayObj->EdgeFlag.BufferObj->Name); break; case GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB: - params[0] = ctx->Array.ArrayObj->SecondaryColor.BufferObj->Name; + params[0] = (GLint64)(ctx->Array.ArrayObj->SecondaryColor.BufferObj->Name); break; case GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB: - params[0] = ctx->Array.ArrayObj->FogCoord.BufferObj->Name; + params[0] = (GLint64)(ctx->Array.ArrayObj->FogCoord.BufferObj->Name); break; case GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB: - params[0] = ctx->Array.ElementArrayBufferObj->Name; + params[0] = (GLint64)(ctx->Array.ElementArrayBufferObj->Name); break; case GL_PIXEL_PACK_BUFFER_BINDING_EXT: CHECK_EXT1(EXT_pixel_buffer_object, "GetInteger64v"); - params[0] = ctx->Pack.BufferObj->Name; + params[0] = (GLint64)(ctx->Pack.BufferObj->Name); break; case GL_PIXEL_UNPACK_BUFFER_BINDING_EXT: CHECK_EXT1(EXT_pixel_buffer_object, "GetInteger64v"); - params[0] = ctx->Unpack.BufferObj->Name; + params[0] = (GLint64)(ctx->Unpack.BufferObj->Name); break; case GL_VERTEX_PROGRAM_ARB: CHECK_EXT2(ARB_vertex_program, NV_vertex_program, "GetInteger64v"); @@ -7133,11 +7133,11 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params ) break; case GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB: CHECK_EXT3(ARB_vertex_program, ARB_fragment_program, NV_vertex_program, "GetInteger64v"); - params[0] = ctx->Const.MaxProgramMatrixStackDepth; + params[0] = (GLint64)(ctx->Const.MaxProgramMatrixStackDepth); break; case GL_MAX_PROGRAM_MATRICES_ARB: CHECK_EXT3(ARB_vertex_program, ARB_fragment_program, NV_vertex_program, "GetInteger64v"); - params[0] = ctx->Const.MaxProgramMatrices; + params[0] = (GLint64)(ctx->Const.MaxProgramMatrices); break; case GL_CURRENT_MATRIX_STACK_DEPTH_ARB: CHECK_EXT3(ARB_vertex_program, ARB_fragment_program, NV_vertex_program, "GetInteger64v"); @@ -7189,11 +7189,11 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params ) break; case GL_MAX_VERTEX_ATTRIBS_ARB: CHECK_EXT1(ARB_vertex_program, "GetInteger64v"); - params[0] = ctx->Const.VertexProgram.MaxAttribs; + params[0] = (GLint64)(ctx->Const.VertexProgram.MaxAttribs); break; case GL_PROGRAM_ERROR_POSITION_ARB: CHECK_EXT4(NV_vertex_program, ARB_vertex_program, NV_fragment_program, ARB_fragment_program, "GetInteger64v"); - params[0] = ctx->Program.ErrorPos; + params[0] = (GLint64)(ctx->Program.ErrorPos); break; case GL_FRAGMENT_PROGRAM_ARB: CHECK_EXT1(ARB_fragment_program, "GetInteger64v"); @@ -7201,11 +7201,11 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params ) break; case GL_MAX_TEXTURE_COORDS_ARB: CHECK_EXT2(ARB_fragment_program, NV_fragment_program, "GetInteger64v"); - params[0] = ctx->Const.MaxTextureCoordUnits; + params[0] = (GLint64)(ctx->Const.MaxTextureCoordUnits); break; case GL_MAX_TEXTURE_IMAGE_UNITS_ARB: CHECK_EXT2(ARB_fragment_program, NV_fragment_program, "GetInteger64v"); - params[0] = ctx->Const.MaxTextureImageUnits; + params[0] = (GLint64)(ctx->Const.MaxTextureImageUnits); break; case GL_DEPTH_BOUNDS_TEST_EXT: CHECK_EXT1(EXT_depth_bounds_test, "GetInteger64v"); @@ -7217,7 +7217,7 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params ) params[1] = IROUND64(ctx->Depth.BoundsMax); break; case GL_MAX_DRAW_BUFFERS_ARB: - params[0] = ctx->Const.MaxDrawBuffers; + params[0] = (GLint64)(ctx->Const.MaxDrawBuffers); break; case GL_DRAW_BUFFER0_ARB: params[0] = ENUM_TO_INT64(ctx->DrawBuffer->ColorDrawBuffer[0]); @@ -7257,31 +7257,31 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params ) break; case GL_IMPLEMENTATION_COLOR_READ_TYPE_OES: CHECK_EXT1(OES_read_format, "GetInteger64v"); - params[0] = ctx->Const.ColorReadType; + params[0] = (GLint64)(ctx->Const.ColorReadType); break; case GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES: CHECK_EXT1(OES_read_format, "GetInteger64v"); - params[0] = ctx->Const.ColorReadFormat; + params[0] = (GLint64)(ctx->Const.ColorReadFormat); break; case GL_NUM_FRAGMENT_REGISTERS_ATI: CHECK_EXT1(ATI_fragment_shader, "GetInteger64v"); - params[0] = 6; + params[0] = (GLint64)(6); break; case GL_NUM_FRAGMENT_CONSTANTS_ATI: CHECK_EXT1(ATI_fragment_shader, "GetInteger64v"); - params[0] = 8; + params[0] = (GLint64)(8); break; case GL_NUM_PASSES_ATI: CHECK_EXT1(ATI_fragment_shader, "GetInteger64v"); - params[0] = 2; + params[0] = (GLint64)(2); break; case GL_NUM_INSTRUCTIONS_PER_PASS_ATI: CHECK_EXT1(ATI_fragment_shader, "GetInteger64v"); - params[0] = 8; + params[0] = (GLint64)(8); break; case GL_NUM_INSTRUCTIONS_TOTAL_ATI: CHECK_EXT1(ATI_fragment_shader, "GetInteger64v"); - params[0] = 16; + params[0] = (GLint64)(16); break; case GL_COLOR_ALPHA_PAIRING_ATI: CHECK_EXT1(ATI_fragment_shader, "GetInteger64v"); @@ -7289,23 +7289,23 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params ) break; case GL_NUM_LOOPBACK_COMPONENTS_ATI: CHECK_EXT1(ATI_fragment_shader, "GetInteger64v"); - params[0] = 3; + params[0] = (GLint64)(3); break; case GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI: CHECK_EXT1(ATI_fragment_shader, "GetInteger64v"); - params[0] = 3; + params[0] = (GLint64)(3); break; case GL_STENCIL_BACK_FUNC: params[0] = ENUM_TO_INT64(ctx->Stencil.Function[1]); break; case GL_STENCIL_BACK_VALUE_MASK: - params[0] = ctx->Stencil.ValueMask[1]; + params[0] = (GLint64)(ctx->Stencil.ValueMask[1]); break; case GL_STENCIL_BACK_WRITEMASK: - params[0] = ctx->Stencil.WriteMask[1]; + params[0] = (GLint64)(ctx->Stencil.WriteMask[1]); break; case GL_STENCIL_BACK_REF: - params[0] = ctx->Stencil.Ref[1]; + params[0] = (GLint64)(ctx->Stencil.Ref[1]); break; case GL_STENCIL_BACK_FAIL: params[0] = ENUM_TO_INT64(ctx->Stencil.FailFunc[1]); @@ -7318,23 +7318,23 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params ) break; case GL_FRAMEBUFFER_BINDING_EXT: CHECK_EXT1(EXT_framebuffer_object, "GetInteger64v"); - params[0] = ctx->DrawBuffer->Name; + params[0] = (GLint64)(ctx->DrawBuffer->Name); break; case GL_RENDERBUFFER_BINDING_EXT: CHECK_EXT1(EXT_framebuffer_object, "GetInteger64v"); - params[0] = ctx->CurrentRenderbuffer ? ctx->CurrentRenderbuffer->Name : 0; + params[0] = (GLint64)(ctx->CurrentRenderbuffer ? ctx->CurrentRenderbuffer->Name : 0); break; case GL_MAX_COLOR_ATTACHMENTS_EXT: CHECK_EXT1(EXT_framebuffer_object, "GetInteger64v"); - params[0] = ctx->Const.MaxColorAttachments; + params[0] = (GLint64)(ctx->Const.MaxColorAttachments); break; case GL_MAX_RENDERBUFFER_SIZE_EXT: CHECK_EXT1(EXT_framebuffer_object, "GetInteger64v"); - params[0] = ctx->Const.MaxRenderbufferSize; + params[0] = (GLint64)(ctx->Const.MaxRenderbufferSize); break; case GL_READ_FRAMEBUFFER_BINDING_EXT: CHECK_EXT1(EXT_framebuffer_blit, "GetInteger64v"); - params[0] = ctx->ReadBuffer->Name; + params[0] = (GLint64)(ctx->ReadBuffer->Name); break; case GL_PROVOKING_VERTEX_EXT: CHECK_EXT1(EXT_provoking_vertex, "GetInteger64v"); @@ -7346,7 +7346,7 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params ) break; case GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB: CHECK_EXT1(ARB_fragment_shader, "GetInteger64v"); - params[0] = ctx->Const.FragmentProgram.MaxUniformComponents; + params[0] = (GLint64)(ctx->Const.FragmentProgram.MaxUniformComponents); break; case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB: CHECK_EXT1(ARB_fragment_shader, "GetInteger64v"); @@ -7354,31 +7354,31 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params ) break; case GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB: CHECK_EXT1(ARB_vertex_shader, "GetInteger64v"); - params[0] = ctx->Const.VertexProgram.MaxUniformComponents; + params[0] = (GLint64)(ctx->Const.VertexProgram.MaxUniformComponents); break; case GL_MAX_VARYING_FLOATS_ARB: CHECK_EXT1(ARB_vertex_shader, "GetInteger64v"); - params[0] = ctx->Const.MaxVarying * 4; + params[0] = (GLint64)(ctx->Const.MaxVarying * 4); break; case GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB: CHECK_EXT1(ARB_vertex_shader, "GetInteger64v"); - params[0] = ctx->Const.MaxVertexTextureImageUnits; + params[0] = (GLint64)(ctx->Const.MaxVertexTextureImageUnits); break; case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB: CHECK_EXT1(ARB_vertex_shader, "GetInteger64v"); - params[0] = MAX_COMBINED_TEXTURE_IMAGE_UNITS; + params[0] = (GLint64)(MAX_COMBINED_TEXTURE_IMAGE_UNITS); break; case GL_CURRENT_PROGRAM: CHECK_EXT1(ARB_shader_objects, "GetInteger64v"); - params[0] = ctx->Shader.CurrentProgram ? ctx->Shader.CurrentProgram->Name : 0; + params[0] = (GLint64)(ctx->Shader.CurrentProgram ? ctx->Shader.CurrentProgram->Name : 0); break; case GL_MAX_SAMPLES: CHECK_EXT1(ARB_framebuffer_object, "GetInteger64v"); - params[0] = ctx->Const.MaxSamples; + params[0] = (GLint64)(ctx->Const.MaxSamples); break; case GL_VERTEX_ARRAY_BINDING_APPLE: CHECK_EXT1(APPLE_vertex_array_object, "GetInteger64v"); - params[0] = ctx->Array.ArrayObj->Name; + params[0] = (GLint64)(ctx->Array.ArrayObj->Name); break; case GL_TEXTURE_CUBE_MAP_SEAMLESS: CHECK_EXT1(ARB_seamless_cube_map, "GetInteger64v"); -- cgit v1.2.3 From 853d4807fe220b17cf5af5a76b24f2466238013b Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Tue, 1 Dec 2009 11:19:33 +0100 Subject: mesa: Update vertex texture code after gallium changes. --- src/mesa/drivers/dri/i965/brw_context.c | 1 + src/mesa/main/context.c | 1 + src/mesa/main/get.c | 8 ++++---- src/mesa/main/get_gen.py | 2 +- src/mesa/main/mtypes.h | 1 + src/mesa/state_tracker/st_atom_sampler.c | 9 +++++++++ src/mesa/state_tracker/st_atom_texture.c | 8 ++++++++ src/mesa/state_tracker/st_extensions.c | 4 ++++ 8 files changed, 29 insertions(+), 5 deletions(-) (limited to 'src/mesa/main/get.c') diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c index 48685c087b..8bdda60697 100644 --- a/src/mesa/drivers/dri/i965/brw_context.c +++ b/src/mesa/drivers/dri/i965/brw_context.c @@ -111,6 +111,7 @@ GLboolean brwCreateContext( const __GLcontextModes *mesaVis, ctx->Const.MaxTextureUnits = MIN2(ctx->Const.MaxTextureCoordUnits, ctx->Const.MaxTextureImageUnits); ctx->Const.MaxVertexTextureImageUnits = 0; /* no vertex shader textures */ + ctx->Const.MaxCombinedTextureImageUnits = 0; /* Mesa limits textures to 4kx4k; it would be nice to fix that someday */ diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index b5bf46718f..03fc57e665 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -575,6 +575,7 @@ _mesa_init_constants(GLcontext *ctx) #if FEATURE_ARB_vertex_shader ctx->Const.MaxVertexTextureImageUnits = MAX_VERTEX_TEXTURE_IMAGE_UNITS; + ctx->Const.MaxCombinedTextureImageUnits = MAX_COMBINED_TEXTURE_IMAGE_UNITS; ctx->Const.MaxVarying = MAX_VARYING; #endif diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c index 6c5ce02913..e8932f83b6 100644 --- a/src/mesa/main/get.c +++ b/src/mesa/main/get.c @@ -1876,7 +1876,7 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params ) break; case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB: CHECK_EXT1(ARB_vertex_shader, "GetBooleanv"); - params[0] = INT_TO_BOOLEAN(MAX_COMBINED_TEXTURE_IMAGE_UNITS); + params[0] = INT_TO_BOOLEAN(ctx->Const.MaxCombinedTextureImageUnits); break; case GL_CURRENT_PROGRAM: CHECK_EXT1(ARB_shader_objects, "GetBooleanv"); @@ -3711,7 +3711,7 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params ) break; case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB: CHECK_EXT1(ARB_vertex_shader, "GetFloatv"); - params[0] = (GLfloat)(MAX_COMBINED_TEXTURE_IMAGE_UNITS); + params[0] = (GLfloat)(ctx->Const.MaxCombinedTextureImageUnits); break; case GL_CURRENT_PROGRAM: CHECK_EXT1(ARB_shader_objects, "GetFloatv"); @@ -5546,7 +5546,7 @@ _mesa_GetIntegerv( GLenum pname, GLint *params ) break; case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB: CHECK_EXT1(ARB_vertex_shader, "GetIntegerv"); - params[0] = MAX_COMBINED_TEXTURE_IMAGE_UNITS; + params[0] = ctx->Const.MaxCombinedTextureImageUnits; break; case GL_CURRENT_PROGRAM: CHECK_EXT1(ARB_shader_objects, "GetIntegerv"); @@ -7382,7 +7382,7 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params ) break; case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB: CHECK_EXT1(ARB_vertex_shader, "GetInteger64v"); - params[0] = (GLint64)(MAX_COMBINED_TEXTURE_IMAGE_UNITS); + params[0] = (GLint64)(ctx->Const.MaxCombinedTextureImageUnits); break; case GL_CURRENT_PROGRAM: CHECK_EXT1(ARB_shader_objects, "GetInteger64v"); diff --git a/src/mesa/main/get_gen.py b/src/mesa/main/get_gen.py index 930c3362fa..a29962d334 100644 --- a/src/mesa/main/get_gen.py +++ b/src/mesa/main/get_gen.py @@ -1006,7 +1006,7 @@ StateVars = [ ( "GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB", GLint, ["ctx->Const.MaxVertexTextureImageUnits"], "", ["ARB_vertex_shader"] ), ( "GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB", GLint, - ["MAX_COMBINED_TEXTURE_IMAGE_UNITS"], "", ["ARB_vertex_shader"] ), + ["ctx->Const.MaxCombinedTextureImageUnits"], "", ["ARB_vertex_shader"] ), # GL_ARB_shader_objects # Actually, this token isn't part of GL_ARB_shader_objects, but is diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 881d233ca3..5f01244827 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -2319,6 +2319,7 @@ struct gl_constants GLuint MaxTextureCoordUnits; GLuint MaxTextureImageUnits; GLuint MaxVertexTextureImageUnits; + GLuint MaxCombinedTextureImageUnits; GLuint MaxTextureUnits; /**< = MIN(CoordUnits, ImageUnits) */ GLfloat MaxTextureMaxAnisotropy; /**< GL_EXT_texture_filter_anisotropic */ GLfloat MaxTextureLodBias; /**< GL_EXT_texture_lod_bias */ diff --git a/src/mesa/state_tracker/st_atom_sampler.c b/src/mesa/state_tracker/st_atom_sampler.c index 6611956ae8..d6e3a3e561 100644 --- a/src/mesa/state_tracker/st_atom_sampler.c +++ b/src/mesa/state_tracker/st_atom_sampler.c @@ -229,14 +229,23 @@ update_samplers(struct st_context *st) /*printf("%s su=%u non-null\n", __FUNCTION__, su);*/ cso_single_sampler(st->cso_context, su, sampler); + if (su < st->ctx->Const.MaxVertexTextureImageUnits) { + cso_single_vertex_sampler(st->cso_context, su, sampler); + } } else { /*printf("%s su=%u null\n", __FUNCTION__, su);*/ cso_single_sampler(st->cso_context, su, NULL); + if (su < st->ctx->Const.MaxVertexTextureImageUnits) { + cso_single_vertex_sampler(st->cso_context, su, NULL); + } } } cso_single_sampler_done(st->cso_context); + if (st->ctx->Const.MaxVertexTextureImageUnits > 0) { + cso_single_vertex_sampler_done(st->cso_context); + } } diff --git a/src/mesa/state_tracker/st_atom_texture.c b/src/mesa/state_tracker/st_atom_texture.c index 4d4f97da7e..0b68447d21 100644 --- a/src/mesa/state_tracker/st_atom_texture.c +++ b/src/mesa/state_tracker/st_atom_texture.c @@ -32,6 +32,8 @@ */ +#include "main/macros.h" + #include "st_context.h" #include "st_atom.h" #include "st_texture.h" @@ -99,6 +101,12 @@ update_textures(struct st_context *st) cso_set_sampler_textures(st->cso_context, st->state.num_textures, st->state.sampler_texture); + if (st->ctx->Const.MaxVertexTextureImageUnits > 0) { + cso_set_vertex_sampler_textures(st->cso_context, + MIN2(st->state.num_textures, + st->ctx->Const.MaxVertexTextureImageUnits), + st->state.sampler_texture); + } } diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c index 57fe72d76a..ef3cbc53ee 100644 --- a/src/mesa/state_tracker/st_extensions.c +++ b/src/mesa/state_tracker/st_extensions.c @@ -92,6 +92,10 @@ void st_init_limits(struct st_context *st) = _min(screen->get_param(screen, PIPE_CAP_MAX_VERTEX_TEXTURE_UNITS), MAX_VERTEX_TEXTURE_IMAGE_UNITS); + c->MaxCombinedTextureImageUnits + = _min(screen->get_param(screen, PIPE_CAP_MAX_COMBINED_SAMPLERS), + MAX_COMBINED_TEXTURE_IMAGE_UNITS); + c->MaxTextureCoordUnits = _min(c->MaxTextureImageUnits, MAX_TEXTURE_COORD_UNITS); -- cgit v1.2.3 From cd6b8dd9e82fedc55d033131fbc0f8ee950567c8 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 9 Dec 2009 10:08:07 -0800 Subject: mesa: Move OES_read_format support from drivers into the core. The assertion is that the correct read type to be using is the native type of the underlying read renderbuffer. For some fallback paths, this may be worse than GL_RGBA/GL_UNSIGNED_BYTE for reads today, but it gets all drivers the expected GL_BGRA/GL_UNSIGNED_BYTE for ARGB8888 or GL_BGR//GL_UNSIGNED_SHORT_5_6_5_REV for rgb565 with no work. This fixes the intel (and other) DRI drivers to report read formats that should hit blit PBO readpixels paths. --- src/mesa/main/context.c | 4 -- src/mesa/main/framebuffer.c | 26 ++++++++++ src/mesa/main/framebuffer.h | 5 ++ src/mesa/main/get.c | 17 ++++--- src/mesa/main/get_gen.py | 5 +- src/mesa/main/mtypes.h | 3 -- src/mesa/sources.mak | 1 - src/mesa/state_tracker/st_cb_get.c | 97 ------------------------------------- src/mesa/state_tracker/st_cb_get.h | 37 -------------- src/mesa/state_tracker/st_context.c | 2 - 10 files changed, 43 insertions(+), 154 deletions(-) delete mode 100644 src/mesa/state_tracker/st_cb_get.c delete mode 100644 src/mesa/state_tracker/st_cb_get.h (limited to 'src/mesa/main/get.c') diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index b5bf46718f..87eae96639 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -564,10 +564,6 @@ _mesa_init_constants(GLcontext *ctx) /* GL_ARB_draw_buffers */ ctx->Const.MaxDrawBuffers = MAX_DRAW_BUFFERS; - /* GL_OES_read_format */ - ctx->Const.ColorReadFormat = GL_RGBA; - ctx->Const.ColorReadType = GL_UNSIGNED_BYTE; - #if FEATURE_EXT_framebuffer_object ctx->Const.MaxColorAttachments = MAX_COLOR_ATTACHMENTS; ctx->Const.MaxRenderbufferSize = MAX_WIDTH; diff --git a/src/mesa/main/framebuffer.c b/src/mesa/main/framebuffer.c index 154dedacd5..d958dbf7d4 100644 --- a/src/mesa/main/framebuffer.c +++ b/src/mesa/main/framebuffer.c @@ -969,3 +969,29 @@ _mesa_dest_buffer_exists(GLcontext *ctx, GLenum format) /* OK */ return GL_TRUE; } + +GLenum +_mesa_get_color_read_format(GLcontext *ctx) +{ + switch (ctx->ReadBuffer->_ColorReadBuffer->Format) { + case MESA_FORMAT_ARGB8888: + return GL_BGRA; + case MESA_FORMAT_RGB565: + return GL_BGR; + default: + return GL_RGBA; + } +} + +GLenum +_mesa_get_color_read_type(GLcontext *ctx) +{ + switch (ctx->ReadBuffer->_ColorReadBuffer->Format) { + case MESA_FORMAT_ARGB8888: + return GL_UNSIGNED_BYTE; + case MESA_FORMAT_RGB565: + return GL_UNSIGNED_SHORT_5_6_5_REV; + default: + return GL_UNSIGNED_BYTE; + } +} diff --git a/src/mesa/main/framebuffer.h b/src/mesa/main/framebuffer.h index 45a4703ba9..ef21dd98e8 100644 --- a/src/mesa/main/framebuffer.h +++ b/src/mesa/main/framebuffer.h @@ -81,5 +81,10 @@ _mesa_source_buffer_exists(GLcontext *ctx, GLenum format); extern GLboolean _mesa_dest_buffer_exists(GLcontext *ctx, GLenum format); +extern GLenum +_mesa_get_color_read_type(GLcontext *ctx); + +extern GLenum +_mesa_get_color_read_format(GLcontext *ctx); #endif /* FRAMEBUFFER_H */ diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c index 6c5ce02913..3f6b03c88a 100644 --- a/src/mesa/main/get.c +++ b/src/mesa/main/get.c @@ -13,6 +13,7 @@ #include "mtypes.h" #include "state.h" #include "texcompress.h" +#include "framebuffer.h" #define FLOAT_TO_BOOLEAN(X) ( (X) ? GL_TRUE : GL_FALSE ) @@ -1767,11 +1768,11 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params ) break; case GL_IMPLEMENTATION_COLOR_READ_TYPE_OES: CHECK_EXT1(OES_read_format, "GetBooleanv"); - params[0] = INT_TO_BOOLEAN(ctx->Const.ColorReadType); + params[0] = INT_TO_BOOLEAN(_mesa_get_color_read_type(ctx)); break; case GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES: CHECK_EXT1(OES_read_format, "GetBooleanv"); - params[0] = INT_TO_BOOLEAN(ctx->Const.ColorReadFormat); + params[0] = INT_TO_BOOLEAN(_mesa_get_color_read_format(ctx)); break; case GL_NUM_FRAGMENT_REGISTERS_ATI: CHECK_EXT1(ATI_fragment_shader, "GetBooleanv"); @@ -3602,11 +3603,11 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params ) break; case GL_IMPLEMENTATION_COLOR_READ_TYPE_OES: CHECK_EXT1(OES_read_format, "GetFloatv"); - params[0] = (GLfloat)(ctx->Const.ColorReadType); + params[0] = (GLfloat)(_mesa_get_color_read_type(ctx)); break; case GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES: CHECK_EXT1(OES_read_format, "GetFloatv"); - params[0] = (GLfloat)(ctx->Const.ColorReadFormat); + params[0] = (GLfloat)(_mesa_get_color_read_format(ctx)); break; case GL_NUM_FRAGMENT_REGISTERS_ATI: CHECK_EXT1(ATI_fragment_shader, "GetFloatv"); @@ -5437,11 +5438,11 @@ _mesa_GetIntegerv( GLenum pname, GLint *params ) break; case GL_IMPLEMENTATION_COLOR_READ_TYPE_OES: CHECK_EXT1(OES_read_format, "GetIntegerv"); - params[0] = ctx->Const.ColorReadType; + params[0] = _mesa_get_color_read_type(ctx); break; case GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES: CHECK_EXT1(OES_read_format, "GetIntegerv"); - params[0] = ctx->Const.ColorReadFormat; + params[0] = _mesa_get_color_read_format(ctx); break; case GL_NUM_FRAGMENT_REGISTERS_ATI: CHECK_EXT1(ATI_fragment_shader, "GetIntegerv"); @@ -7273,11 +7274,11 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params ) break; case GL_IMPLEMENTATION_COLOR_READ_TYPE_OES: CHECK_EXT1(OES_read_format, "GetInteger64v"); - params[0] = (GLint64)(ctx->Const.ColorReadType); + params[0] = (GLint64)(_mesa_get_color_read_type(ctx)); break; case GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES: CHECK_EXT1(OES_read_format, "GetInteger64v"); - params[0] = (GLint64)(ctx->Const.ColorReadFormat); + params[0] = (GLint64)(_mesa_get_color_read_format(ctx)); break; case GL_NUM_FRAGMENT_REGISTERS_ATI: CHECK_EXT1(ATI_fragment_shader, "GetInteger64v"); diff --git a/src/mesa/main/get_gen.py b/src/mesa/main/get_gen.py index 930c3362fa..697c4cfd92 100644 --- a/src/mesa/main/get_gen.py +++ b/src/mesa/main/get_gen.py @@ -942,9 +942,9 @@ StateVars = [ # GL_OES_read_format ( "GL_IMPLEMENTATION_COLOR_READ_TYPE_OES", GLint, - ["ctx->Const.ColorReadType"], "", ["OES_read_format"] ), + ["_mesa_get_color_read_type(ctx)"], "", ["OES_read_format"] ), ( "GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES", GLint, - ["ctx->Const.ColorReadFormat"], "", ["OES_read_format"] ), + ["_mesa_get_color_read_format(ctx)"], "", ["OES_read_format"] ), # GL_ATI_fragment_shader ( "GL_NUM_FRAGMENT_REGISTERS_ATI", GLint, ["6"], "", ["ATI_fragment_shader"] ), @@ -1159,6 +1159,7 @@ def EmitHeader(): #include "mtypes.h" #include "state.h" #include "texcompress.h" +#include "framebuffer.h" #define FLOAT_TO_BOOLEAN(X) ( (X) ? GL_TRUE : GL_FALSE ) diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 881d233ca3..cde2f5fe06 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -2355,9 +2355,6 @@ struct gl_constants GLuint MaxDrawBuffers; /**< GL_ARB_draw_buffers */ - GLenum ColorReadFormat; /**< GL_OES_read_format */ - GLenum ColorReadType; /**< GL_OES_read_format */ - GLuint MaxColorAttachments; /**< GL_EXT_framebuffer_object */ GLuint MaxRenderbufferSize; /**< GL_EXT_framebuffer_object */ GLuint MaxSamples; /**< GL_ARB_framebuffer_object */ diff --git a/src/mesa/sources.mak b/src/mesa/sources.mak index 615a5588ea..a0d7dbbace 100644 --- a/src/mesa/sources.mak +++ b/src/mesa/sources.mak @@ -191,7 +191,6 @@ STATETRACKER_SOURCES = \ state_tracker/st_cb_bufferobjects.c \ state_tracker/st_cb_clear.c \ state_tracker/st_cb_flush.c \ - state_tracker/st_cb_get.c \ state_tracker/st_cb_drawpixels.c \ state_tracker/st_cb_fbo.c \ state_tracker/st_cb_feedback.c \ diff --git a/src/mesa/state_tracker/st_cb_get.c b/src/mesa/state_tracker/st_cb_get.c deleted file mode 100644 index e7d7f03bc9..0000000000 --- a/src/mesa/state_tracker/st_cb_get.c +++ /dev/null @@ -1,97 +0,0 @@ -/************************************************************************** - * - * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. - * 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. - * - **************************************************************************/ - - -/** - * glGet functions - * - * \author Brian Paul - */ - -#include "main/imports.h" -#include "main/context.h" - -#include "pipe/p_defines.h" - -#include "st_cb_fbo.h" -#include "st_cb_get.h" - - - -/** - * Examine the current color read buffer format to determine - * which GL pixel format/type combo is the best match. - */ -static void -get_preferred_read_format_type(GLcontext *ctx, GLint *format, GLint *type) -{ - struct gl_framebuffer *fb = ctx->ReadBuffer; - struct st_renderbuffer *strb = st_renderbuffer(fb->_ColorReadBuffer); - - /* defaults */ - *format = ctx->Const.ColorReadFormat; - *type = ctx->Const.ColorReadType; - - if (strb) { - /* XXX could add more cases here... */ - if (strb->format == PIPE_FORMAT_A8R8G8B8_UNORM) { - *format = GL_BGRA; - if (_mesa_little_endian()) - *type = GL_UNSIGNED_INT_8_8_8_8_REV; - else - *type = GL_UNSIGNED_INT_8_8_8_8; - } - } -} - - -/** - * We only intercept the OES preferred ReadPixels format/type. - * Everything else goes to the default _mesa_GetIntegerv. - */ -static GLboolean -st_GetIntegerv(GLcontext *ctx, GLenum pname, GLint *params) -{ - GLint dummy; - - switch (pname) { - case GL_IMPLEMENTATION_COLOR_READ_TYPE_OES: - get_preferred_read_format_type(ctx, &dummy, params); - return GL_TRUE; - case GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES: - get_preferred_read_format_type(ctx, params, &dummy); - return GL_TRUE; - default: - return GL_FALSE; - } -} - - -void st_init_get_functions(struct dd_function_table *functions) -{ - functions->GetIntegerv = st_GetIntegerv; -} diff --git a/src/mesa/state_tracker/st_cb_get.h b/src/mesa/state_tracker/st_cb_get.h deleted file mode 100644 index 8e9f3e9306..0000000000 --- a/src/mesa/state_tracker/st_cb_get.h +++ /dev/null @@ -1,37 +0,0 @@ -/************************************************************************** - * - * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. - * 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. - * - **************************************************************************/ - - -#ifndef ST_CB_GET_H -#define ST_CB_GET_H - - -extern void -st_init_get_functions(struct dd_function_table *functions); - - -#endif diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c index f0eddafd33..d18a25ab51 100644 --- a/src/mesa/state_tracker/st_context.c +++ b/src/mesa/state_tracker/st_context.c @@ -51,7 +51,6 @@ #include "st_cb_drawtex.h" #endif #include "st_cb_fbo.h" -#include "st_cb_get.h" #if FEATURE_feedback #include "st_cb_feedback.h" #endif @@ -331,7 +330,6 @@ void st_init_driver_functions(struct dd_function_table *functions) st_init_rasterpos_functions(functions); #endif st_init_fbo_functions(functions); - st_init_get_functions(functions); #if FEATURE_feedback st_init_feedback_functions(functions); #endif -- cgit v1.2.3 From 3728673bd1b974e54858fbab6ff62d3607b0d3f0 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 29 Dec 2009 15:04:03 -0700 Subject: mesa: per-buffer blend enabled flags ctx->Color.BlendEnabled is now a GLbitfield instead of a GLboolean to indicate blend on/off status for each color/draw buffer. This is infrastructure for GL_EXT_draw_buffers2 and OpenGL 3.x New functions include _mesa_EnableIndexed(), _mesa_DisableIndexed(), and _mesa_IsEnabledIndexed(). The enable function corresponds to glEnableIndexedEXT() for GL_EXT_draw_buffers2 or glEnablei() for GL3. Note that there's quite a few tests for ctx->Color.BlendEnabled != 0 in drivers, etc. Those tests can remain as-is since the mask will be 0 or ~0 unless GL_EXT_draw_buffers2 is enabled. --- src/mesa/drivers/common/meta.c | 18 ++++++--- src/mesa/main/attrib.c | 16 +++++++- src/mesa/main/blend.c | 2 +- src/mesa/main/enable.c | 84 +++++++++++++++++++++++++++++++++++++++--- src/mesa/main/enable.h | 12 ++++++ src/mesa/main/get.c | 8 ++-- src/mesa/main/get_gen.py | 2 +- src/mesa/main/mtypes.h | 2 +- src/mesa/swrast/s_span.c | 2 +- 9 files changed, 126 insertions(+), 20 deletions(-) (limited to 'src/mesa/main/get.c') diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c index cd9075b393..da2c06677a 100644 --- a/src/mesa/drivers/common/meta.c +++ b/src/mesa/drivers/common/meta.c @@ -107,7 +107,7 @@ struct save_state GLboolean AlphaEnabled; /** META_BLEND */ - GLboolean BlendEnabled; + GLbitfield BlendEnabled; GLboolean ColorLogicOpEnabled; /** META_COLOR_MASK */ @@ -335,8 +335,12 @@ _mesa_meta_begin(GLcontext *ctx, GLbitfield state) if (state & META_BLEND) { save->BlendEnabled = ctx->Color.BlendEnabled; - if (ctx->Color.BlendEnabled) - _mesa_set_enable(ctx, GL_BLEND, GL_FALSE); + if (ctx->Color.BlendEnabled) { + GLuint i; + for (i = 0; i < ctx->Const.MaxDrawBuffers; i++) { + _mesa_set_enablei(ctx, GL_BLEND, i, GL_FALSE); + } + } save->ColorLogicOpEnabled = ctx->Color.ColorLogicOpEnabled; if (ctx->Color.ColorLogicOpEnabled) _mesa_set_enable(ctx, GL_COLOR_LOGIC_OP, GL_FALSE); @@ -566,8 +570,12 @@ _mesa_meta_end(GLcontext *ctx) } if (state & META_BLEND) { - if (ctx->Color.BlendEnabled != save->BlendEnabled) - _mesa_set_enable(ctx, GL_BLEND, save->BlendEnabled); + if (ctx->Color.BlendEnabled != save->BlendEnabled) { + GLuint i; + for (i = 0; i < ctx->Const.MaxDrawBuffers; i++) { + _mesa_set_enablei(ctx, GL_BLEND, i, (save->BlendEnabled >> i) & 1); + } + } if (ctx->Color.ColorLogicOpEnabled != save->ColorLogicOpEnabled) _mesa_set_enable(ctx, GL_COLOR_LOGIC_OP, save->ColorLogicOpEnabled); } diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c index 246c5521b7..88ce0a4281 100644 --- a/src/mesa/main/attrib.c +++ b/src/mesa/main/attrib.c @@ -499,7 +499,12 @@ pop_enable_group(GLcontext *ctx, const struct gl_enable_attrib *enable) } TEST_AND_UPDATE(ctx->Color.AlphaEnabled, enable->AlphaTest, GL_ALPHA_TEST); - TEST_AND_UPDATE(ctx->Color.BlendEnabled, enable->Blend, GL_BLEND); + if (ctx->Color.BlendEnabled != enable->Blend) { + GLuint i; + for (i = 0; i < ctx->Const.MaxDrawBuffers; i++) { + _mesa_set_enablei(ctx, GL_BLEND, i, (enable->Blend >> i) & 1); + } + } for (i=0;idata; _mesa_ClearIndex((GLfloat) color->ClearIndex); _mesa_ClearColor(color->ClearColor[0], @@ -948,7 +954,13 @@ _mesa_PopAttrib(void) } _mesa_set_enable(ctx, GL_ALPHA_TEST, color->AlphaEnabled); _mesa_AlphaFunc(color->AlphaFunc, color->AlphaRef); - _mesa_set_enable(ctx, GL_BLEND, color->BlendEnabled); + if (ctx->Color.BlendEnabled != color->BlendEnabled) { + GLuint i; + for (i = 0; i < ctx->Const.MaxDrawBuffers; i++) { + _mesa_set_enablei(ctx, GL_BLEND, i, + (color->BlendEnabled >> i) & 1); + } + } _mesa_BlendFuncSeparateEXT(color->BlendSrcRGB, color->BlendDstRGB, color->BlendSrcA, diff --git a/src/mesa/main/blend.c b/src/mesa/main/blend.c index 830e3b2e51..5a9d94e12d 100644 --- a/src/mesa/main/blend.c +++ b/src/mesa/main/blend.c @@ -564,7 +564,7 @@ void _mesa_init_color( GLcontext * ctx ) ctx->Color.AlphaEnabled = GL_FALSE; ctx->Color.AlphaFunc = GL_ALWAYS; ctx->Color.AlphaRef = 0; - ctx->Color.BlendEnabled = GL_FALSE; + ctx->Color.BlendEnabled = 0x0; ctx->Color.BlendSrcRGB = GL_ONE; ctx->Color.BlendDstRGB = GL_ZERO; ctx->Color.BlendSrcA = GL_ONE; diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c index 12ce14c5d0..6f9f57f5cb 100644 --- a/src/mesa/main/enable.c +++ b/src/mesa/main/enable.c @@ -278,10 +278,13 @@ _mesa_set_enable(GLcontext *ctx, GLenum cap, GLboolean state) ctx->Eval.AutoNormal = state; break; case GL_BLEND: - if (ctx->Color.BlendEnabled == state) - return; - FLUSH_VERTICES(ctx, _NEW_COLOR); - ctx->Color.BlendEnabled = state; + { + GLbitfield newEnabled = state * ((1 << ctx->Const.MaxDrawBuffers) - 1); + if (newEnabled != ctx->Color.BlendEnabled) { + FLUSH_VERTICES(ctx, _NEW_COLOR); + ctx->Color.BlendEnabled = newEnabled; + } + } break; #if FEATURE_userclip case GL_CLIP_PLANE0: @@ -1020,6 +1023,77 @@ _mesa_Disable( GLenum cap ) } + +/** + * Enable/disable an indexed state var. + */ +void +_mesa_set_enablei(GLcontext *ctx, GLenum cap, GLuint index, GLboolean state) +{ + ASSERT(state == 0 || state == 1); + switch (cap) { + case GL_BLEND: + if (index >= ctx->Const.MaxDrawBuffers) { + _mesa_error(ctx, GL_INVALID_VALUE, "%s(index=%u)", + state ? "glEnableIndexed" : "glDisableIndexed", index); + return; + } + if (((ctx->Color.BlendEnabled >> index) & 1) != state) { + FLUSH_VERTICES(ctx, _NEW_COLOR); + if (state) + ctx->Color.BlendEnabled |= (1 << index); + else + ctx->Color.BlendEnabled &= ~(1 << index); + } + break; + default: + _mesa_error(ctx, GL_INVALID_ENUM, "%s(cap=%s)", + state ? "glEnableIndexed" : "glDisableIndexed", + _mesa_lookup_enum_by_nr(cap)); + } +} + + +void GLAPIENTRY +_mesa_DisableIndexed( GLenum cap, GLuint index ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + _mesa_set_enablei(ctx, cap, index, GL_FALSE); +} + + +void GLAPIENTRY +_mesa_EnableIndexed( GLenum cap, GLuint index ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + _mesa_set_enablei(ctx, cap, index, GL_TRUE); +} + + +GLboolean GLAPIENTRY +_mesa_IsEnabledIndexed( GLenum cap, GLuint index ) +{ + GET_CURRENT_CONTEXT(ctx); + switch (cap) { + case GL_BLEND: + if (index >= ctx->Const.MaxDrawBuffers) { + _mesa_error(ctx, GL_INVALID_VALUE, "glIsEnabledIndexed(index=%u)", + index); + return GL_FALSE; + } + return (ctx->Color.BlendEnabled >> index) & 1; + default: + _mesa_error(ctx, GL_INVALID_ENUM, "glIsEnabledIndexed(cap=%s)", + _mesa_lookup_enum_by_nr(cap)); + return GL_FALSE; + } +} + + + + #undef CHECK_EXTENSION #define CHECK_EXTENSION(EXTNAME) \ if (!ctx->Extensions.EXTNAME) { \ @@ -1066,7 +1140,7 @@ _mesa_IsEnabled( GLenum cap ) case GL_AUTO_NORMAL: return ctx->Eval.AutoNormal; case GL_BLEND: - return ctx->Color.BlendEnabled; + return ctx->Color.BlendEnabled & 1; /* return state for buffer[0] */ case GL_CLIP_PLANE0: case GL_CLIP_PLANE1: case GL_CLIP_PLANE2: diff --git a/src/mesa/main/enable.h b/src/mesa/main/enable.h index 25c90b0275..24e3181a8b 100644 --- a/src/mesa/main/enable.h +++ b/src/mesa/main/enable.h @@ -47,6 +47,18 @@ _mesa_Enable( GLenum cap ); extern GLboolean GLAPIENTRY _mesa_IsEnabled( GLenum cap ); +extern void +_mesa_set_enablei(GLcontext *ctx, GLenum cap, GLuint index, GLboolean state); + +extern void GLAPIENTRY +_mesa_DisableIndexed( GLenum cap, GLuint index ); + +extern void GLAPIENTRY +_mesa_EnableIndexed( GLenum cap, GLuint index ); + +extern GLboolean GLAPIENTRY +_mesa_IsEnabledIndexed( GLenum cap, GLuint index ); + extern void GLAPIENTRY _mesa_EnableClientState( GLenum cap ); diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c index 3d32649bad..07507414d7 100644 --- a/src/mesa/main/get.c +++ b/src/mesa/main/get.c @@ -132,7 +132,7 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params ) params[0] = INT_TO_BOOLEAN(ctx->DrawBuffer->Visual.numAuxBuffers); break; case GL_BLEND: - params[0] = ctx->Color.BlendEnabled; + params[0] = (ctx->Color.BlendEnabled & 1); break; case GL_BLEND_DST: params[0] = ENUM_TO_BOOLEAN(ctx->Color.BlendDstRGB); @@ -1967,7 +1967,7 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params ) params[0] = (GLfloat)(ctx->DrawBuffer->Visual.numAuxBuffers); break; case GL_BLEND: - params[0] = BOOLEAN_TO_FLOAT(ctx->Color.BlendEnabled); + params[0] = BOOLEAN_TO_FLOAT((ctx->Color.BlendEnabled & 1)); break; case GL_BLEND_DST: params[0] = ENUM_TO_FLOAT(ctx->Color.BlendDstRGB); @@ -3802,7 +3802,7 @@ _mesa_GetIntegerv( GLenum pname, GLint *params ) params[0] = ctx->DrawBuffer->Visual.numAuxBuffers; break; case GL_BLEND: - params[0] = BOOLEAN_TO_INT(ctx->Color.BlendEnabled); + params[0] = BOOLEAN_TO_INT((ctx->Color.BlendEnabled & 1)); break; case GL_BLEND_DST: params[0] = ENUM_TO_INT(ctx->Color.BlendDstRGB); @@ -5638,7 +5638,7 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params ) params[0] = (GLint64)(ctx->DrawBuffer->Visual.numAuxBuffers); break; case GL_BLEND: - params[0] = BOOLEAN_TO_INT64(ctx->Color.BlendEnabled); + params[0] = BOOLEAN_TO_INT64((ctx->Color.BlendEnabled & 1)); break; case GL_BLEND_DST: params[0] = ENUM_TO_INT64(ctx->Color.BlendDstRGB); diff --git a/src/mesa/main/get_gen.py b/src/mesa/main/get_gen.py index 01170a42a7..5aff9d3544 100644 --- a/src/mesa/main/get_gen.py +++ b/src/mesa/main/get_gen.py @@ -82,7 +82,7 @@ StateVars = [ ( "GL_AUTO_NORMAL", GLboolean, ["ctx->Eval.AutoNormal"], "", None ), ( "GL_AUX_BUFFERS", GLint, ["ctx->DrawBuffer->Visual.numAuxBuffers"], "", None ), - ( "GL_BLEND", GLboolean, ["ctx->Color.BlendEnabled"], "", None ), + ( "GL_BLEND", GLboolean, ["(ctx->Color.BlendEnabled & 1)"], "", None ), ( "GL_BLEND_DST", GLenum, ["ctx->Color.BlendDstRGB"], "", None ), ( "GL_BLEND_SRC", GLenum, ["ctx->Color.BlendSrcRGB"], "", None ), ( "GL_BLEND_SRC_RGB_EXT", GLenum, ["ctx->Color.BlendSrcRGB"], "", None ), diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index b52c84b491..170c35b11c 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -581,7 +581,7 @@ struct gl_colorbuffer_attrib * \name Blending */ /*@{*/ - GLboolean BlendEnabled; /**< Blending enabled flag */ + GLbitfield BlendEnabled; /**< Per-buffer blend enable flags */ GLenum BlendSrcRGB; /**< Blending source operator */ GLenum BlendDstRGB; /**< Blending destination operator */ GLenum BlendSrcA; /**< GL_INGR_blend_func_separate */ diff --git a/src/mesa/swrast/s_span.c b/src/mesa/swrast/s_span.c index d36c8132f6..00de13d495 100644 --- a/src/mesa/swrast/s_span.c +++ b/src/mesa/swrast/s_span.c @@ -1479,7 +1479,7 @@ _swrast_write_rgba_span( GLcontext *ctx, SWspan *span) if (ctx->Color._LogicOpEnabled) { _swrast_logicop_rgba_span(ctx, rb, span); } - else if (ctx->Color.BlendEnabled) { + else if ((ctx->Color.BlendEnabled >> buf) & 1) { _swrast_blend_span(ctx, rb, span); } -- cgit v1.2.3 From 126b35bd3acbf486471879531cd2e6f446b14497 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 29 Dec 2009 15:09:16 -0700 Subject: mesa: implement indexed glGet functions The functions are _mesa_GetBooleanIndexedv(), _mesa_GetIntegerIndexedv(), and _mesa_GetInteger64Indexedv(). These will be called from API functions such as glGetBooleanIndexedvEXT() and glGetBooleani_v(). Only the GL_BLEND query is supported at this time. --- src/mesa/main/get.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++ src/mesa/main/get.h | 9 ++++++ src/mesa/main/get_gen.py | 77 +++++++++++++++++++++++++++++++++++------------- 3 files changed, 140 insertions(+), 20 deletions(-) (limited to 'src/mesa/main/get.c') diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c index 07507414d7..aff67466bc 100644 --- a/src/mesa/main/get.c +++ b/src/mesa/main/get.c @@ -7434,3 +7434,77 @@ _mesa_GetDoublev( GLenum pname, GLdouble *params ) params[i] = (GLdouble) values[i]; } +void GLAPIENTRY +_mesa_GetBooleanIndexedv( GLenum pname, GLuint index, GLboolean *params ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (!params) + return; + + if (ctx->NewState) + _mesa_update_state(ctx); + + switch (pname) { + case GL_BLEND: + if (index >= MAX_DRAW_BUFFERS) { + _mesa_error(ctx, GL_INVALID_VALUE, "glGetBooleanIndexedv(index=%u), index", pname); + } + params[0] = INT_TO_BOOLEAN(((ctx->Color.BlendEnabled >> index) & 1)); + break; + default: + _mesa_error(ctx, GL_INVALID_ENUM, "glGetBooleanIndexedv(pname=0x%x)", pname); + } +} + +void GLAPIENTRY +_mesa_GetIntegerIndexedv( GLenum pname, GLuint index, GLint *params ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (!params) + return; + + if (ctx->NewState) + _mesa_update_state(ctx); + + switch (pname) { + case GL_BLEND: + if (index >= MAX_DRAW_BUFFERS) { + _mesa_error(ctx, GL_INVALID_VALUE, "glGetIntegerIndexedv(index=%u), index", pname); + } + params[0] = ((ctx->Color.BlendEnabled >> index) & 1); + break; + default: + _mesa_error(ctx, GL_INVALID_ENUM, "glGetIntegerIndexedv(pname=0x%x)", pname); + } +} + +#if FEATURE_ARB_sync +void GLAPIENTRY +_mesa_GetInteger64Indexedv( GLenum pname, GLuint index, GLint64 *params ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (!params) + return; + + if (ctx->NewState) + _mesa_update_state(ctx); + + switch (pname) { + case GL_BLEND: + if (index >= MAX_DRAW_BUFFERS) { + _mesa_error(ctx, GL_INVALID_VALUE, "glGetInteger64Indexedv(index=%u), index", pname); + } + params[0] = (GLint64)(((ctx->Color.BlendEnabled >> index) & 1)); + break; + default: + _mesa_error(ctx, GL_INVALID_ENUM, "glGetInteger64Indexedv(pname=0x%x)", pname); + } +} +#endif /* FEATURE_ARB_sync */ + diff --git a/src/mesa/main/get.h b/src/mesa/main/get.h index 77a9a7d04b..076ab7a58b 100644 --- a/src/mesa/main/get.h +++ b/src/mesa/main/get.h @@ -50,6 +50,15 @@ _mesa_GetIntegerv( GLenum pname, GLint *params ); extern void GLAPIENTRY _mesa_GetInteger64v( GLenum pname, GLint64 *params ); +extern void GLAPIENTRY +_mesa_GetBooleanIndexedv( GLenum pname, GLuint index, GLboolean *params ); + +extern void GLAPIENTRY +_mesa_GetIntegerIndexedv( GLenum pname, GLuint index, GLint *params ); + +extern void GLAPIENTRY +_mesa_GetInteger64Indexedv( GLenum pname, GLuint index, GLint64 *params ); + extern void GLAPIENTRY _mesa_GetPointerv( GLenum pname, GLvoid **params ); diff --git a/src/mesa/main/get_gen.py b/src/mesa/main/get_gen.py index 5aff9d3544..8b6500fae1 100644 --- a/src/mesa/main/get_gen.py +++ b/src/mesa/main/get_gen.py @@ -1033,6 +1033,14 @@ StateVars = [ ] +# These are queried via glGetIntegetIndexdvEXT() or glGetIntegeri_v() +IndexedStateVars = [ + ( "GL_BLEND", GLint, ["((ctx->Color.BlendEnabled >> index) & 1)"], "MAX_DRAW_BUFFERS", None ), + # XXX more to come... +] + + + def ConversionFunc(fromType, toType): """Return the name of the macro to convert between two data types.""" if fromType == toType: @@ -1059,7 +1067,7 @@ def ConversionFunc(fromType, toType): return fromStr + "_TO_" + toStr -def EmitGetFunction(stateVars, returnType): +def EmitGetFunction(stateVars, returnType, indexed): """Emit the code to implement glGetBooleanv, glGetIntegerv or glGetFloatv.""" assert (returnType == GLboolean or returnType == GLint or @@ -1068,22 +1076,35 @@ def EmitGetFunction(stateVars, returnType): strType = TypeStrings[returnType] # Capitalize first letter of return type - if returnType == GLint: - function = "GetIntegerv" - elif returnType == GLboolean: - function = "GetBooleanv" - elif returnType == GLfloat: - function = "GetFloatv" - elif returnType == GLint64: - function = "GetInteger64v" + if indexed: + if returnType == GLint: + function = "GetIntegerIndexedv" + elif returnType == GLboolean: + function = "GetBooleanIndexedv" + elif returnType == GLint64: + function = "GetInteger64Indexedv" + else: + function = "Foo" else: - abort() + if returnType == GLint: + function = "GetIntegerv" + elif returnType == GLboolean: + function = "GetBooleanv" + elif returnType == GLfloat: + function = "GetFloatv" + elif returnType == GLint64: + function = "GetInteger64v" + else: + abort() if returnType == GLint64: print "#if FEATURE_ARB_sync" print "void GLAPIENTRY" - print "_mesa_%s( GLenum pname, %s *params )" % (function, strType) + if indexed: + print "_mesa_%s( GLenum pname, GLuint index, %s *params )" % (function, strType) + else: + print "_mesa_%s( GLenum pname, %s *params )" % (function, strType) print "{" print " GET_CURRENT_CONTEXT(ctx);" print " ASSERT_OUTSIDE_BEGIN_END(ctx);" @@ -1094,14 +1115,26 @@ def EmitGetFunction(stateVars, returnType): print " if (ctx->NewState)" print " _mesa_update_state(ctx);" print "" - print " if (ctx->Driver.%s &&" % function - print " ctx->Driver.%s(ctx, pname, params))" % function - print " return;" - print "" + if indexed == 0: + print " if (ctx->Driver.%s &&" % function + print " ctx->Driver.%s(ctx, pname, params))" % function + print " return;" + print "" print " switch (pname) {" - for (name, varType, state, optionalCode, extensions) in stateVars: + for state in stateVars: + if indexed: + (name, varType, state, indexMax, extensions) = state + optionalCode = 0 + else: + (name, varType, state, optionalCode, extensions) = state + indexMax = 0 print " case " + name + ":" + if indexMax: + print (' if (index >= %s) {' % indexMax) + print (' _mesa_error(ctx, GL_INVALID_VALUE, "gl%s(index=%%u), index", pname);' % function) + print (' }') + if extensions: if len(extensions) == 1: print (' CHECK_EXT1(%s, "%s");' % @@ -1249,9 +1282,13 @@ _mesa_GetDoublev( GLenum pname, GLdouble *params ) EmitHeader() # XXX Maybe sort the StateVars list -EmitGetFunction(StateVars, GLboolean) -EmitGetFunction(StateVars, GLfloat) -EmitGetFunction(StateVars, GLint) -EmitGetFunction(StateVars, GLint64) +EmitGetFunction(StateVars, GLboolean, 0) +EmitGetFunction(StateVars, GLfloat, 0) +EmitGetFunction(StateVars, GLint, 0) +EmitGetFunction(StateVars, GLint64, 0) EmitGetDoublev() +EmitGetFunction(IndexedStateVars, GLboolean, 1) +EmitGetFunction(IndexedStateVars, GLint, 1) +EmitGetFunction(IndexedStateVars, GLint64, 1) + -- cgit v1.2.3 From fd5511d27fc44096117c47ab503fb5b47f993061 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 29 Dec 2009 16:17:14 -0700 Subject: mesa: implement per-buffer color masking This is part of the GL_EXT_draw_buffers2 extension and part of GL 3.0. The ctx->Color.ColorMask field is now a 2-D array. Until drivers are modified to support per-buffer color masking, they can just look at the 0th color mask. The new _mesa_ColorMaskIndexed() function will be called by glColorMaskIndexedEXT() or glColorMaski(). --- src/mesa/drivers/common/driverfuncs.c | 22 ++++++-- src/mesa/drivers/common/meta.c | 32 ++++++++--- src/mesa/drivers/directfb/idirectfbgl_mesa.c | 8 +-- src/mesa/drivers/dri/gamma/gamma_state.c | 8 +-- src/mesa/drivers/dri/i965/brw_wm_surface_state.c | 2 +- src/mesa/drivers/dri/intel/intel_clear.c | 2 +- src/mesa/drivers/dri/intel/intel_pixel.c | 8 +-- src/mesa/drivers/dri/intel/intel_pixel_copy.c | 8 +-- src/mesa/drivers/dri/mach64/mach64_state.c | 8 +-- src/mesa/drivers/dri/mga/mgapixel.c | 24 ++++---- src/mesa/drivers/dri/mga/mgastate.c | 10 ++-- src/mesa/drivers/dri/r128/r128_state.c | 8 +-- src/mesa/drivers/dri/r200/r200_pixel.c | 16 +++--- src/mesa/drivers/dri/r200/r200_state.c | 8 +-- src/mesa/drivers/dri/r300/r300_state.c | 7 ++- src/mesa/drivers/dri/r600/r700_clear.c | 2 +- src/mesa/drivers/dri/r600/r700_state.c | 8 +-- src/mesa/drivers/dri/radeon/radeon_state.c | 8 +-- src/mesa/drivers/dri/savage/savageioctl.c | 14 ++--- src/mesa/drivers/dri/tdfx/tdfx_pixels.c | 8 +-- src/mesa/drivers/dri/tdfx/tdfx_render.c | 6 +- src/mesa/drivers/dri/unichrome/via_state.c | 10 ++-- src/mesa/drivers/windows/gdi/wmesa.c | 8 +-- .../drivers/windows/gldirect/dx7/gld_driver_dx7.c | 10 ++-- .../drivers/windows/gldirect/dx8/gld_driver_dx8.c | 10 ++-- .../drivers/windows/gldirect/dx9/gld_driver_dx9.c | 10 ++-- src/mesa/drivers/x11/xm_dd.c | 2 +- src/mesa/main/attrib.c | 20 +++++-- src/mesa/main/blend.c | 59 +++++++++++++++++--- src/mesa/main/blend.h | 4 ++ src/mesa/main/dd.h | 2 + src/mesa/main/get.c | 65 +++++++++++++++------- src/mesa/main/get_gen.py | 17 ++++-- src/mesa/main/mtypes.h | 2 +- src/mesa/state_tracker/st_atom_blend.c | 8 +-- src/mesa/state_tracker/st_cb_accum.c | 2 +- src/mesa/state_tracker/st_cb_clear.c | 16 +++--- src/mesa/swrast/s_accum.c | 2 +- src/mesa/swrast/s_clear.c | 50 ++++++----------- src/mesa/swrast/s_context.c | 28 ++++++++-- src/mesa/swrast/s_masking.c | 20 +++---- src/mesa/swrast/s_masking.h | 2 +- src/mesa/swrast/s_span.c | 8 +-- src/mesa/swrast/s_triangle.c | 8 +-- 44 files changed, 350 insertions(+), 230 deletions(-) (limited to 'src/mesa/main/get.c') diff --git a/src/mesa/drivers/common/driverfuncs.c b/src/mesa/drivers/common/driverfuncs.c index 9b271f85e9..5c5e17820d 100644 --- a/src/mesa/drivers/common/driverfuncs.c +++ b/src/mesa/drivers/common/driverfuncs.c @@ -264,11 +264,23 @@ _mesa_init_driver_state(GLcontext *ctx) ctx->Color.BlendDstRGB, ctx->Color.BlendSrcA, ctx->Color.BlendDstA); - ctx->Driver.ColorMask(ctx, - ctx->Color.ColorMask[RCOMP], - ctx->Color.ColorMask[GCOMP], - ctx->Color.ColorMask[BCOMP], - ctx->Color.ColorMask[ACOMP]); + 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); diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c index da2c06677a..0676173745 100644 --- a/src/mesa/drivers/common/meta.c +++ b/src/mesa/drivers/common/meta.c @@ -111,7 +111,7 @@ struct save_state GLboolean ColorLogicOpEnabled; /** META_COLOR_MASK */ - GLubyte ColorMask[4]; + GLubyte ColorMask[MAX_DRAW_BUFFERS][4]; /** META_DEPTH_TEST */ struct gl_depthbuffer_attrib Depth; @@ -347,11 +347,12 @@ _mesa_meta_begin(GLcontext *ctx, GLbitfield state) } if (state & META_COLOR_MASK) { - COPY_4V(save->ColorMask, ctx->Color.ColorMask); - if (!ctx->Color.ColorMask[0] || - !ctx->Color.ColorMask[1] || - !ctx->Color.ColorMask[2] || - !ctx->Color.ColorMask[3]) + memcpy(save->ColorMask, ctx->Color.ColorMask, + sizeof(ctx->Color.ColorMask)); + if (!ctx->Color.ColorMask[0][0] || + !ctx->Color.ColorMask[0][1] || + !ctx->Color.ColorMask[0][2] || + !ctx->Color.ColorMask[0][3]) _mesa_ColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); } @@ -581,9 +582,22 @@ _mesa_meta_end(GLcontext *ctx) } if (state & META_COLOR_MASK) { - if (!TEST_EQ_4V(ctx->Color.ColorMask, save->ColorMask)) - _mesa_ColorMask(save->ColorMask[0], save->ColorMask[1], - save->ColorMask[2], save->ColorMask[3]); + GLuint i; + for (i = 0; i < ctx->Const.MaxDrawBuffers; i++) { + if (!TEST_EQ_4V(ctx->Color.ColorMask[i], save->ColorMask[i])) { + if (i == 0) { + _mesa_ColorMask(save->ColorMask[i][0], save->ColorMask[i][1], + save->ColorMask[i][2], save->ColorMask[i][3]); + } + else { + _mesa_ColorMaskIndexed(i, + save->ColorMask[i][0], + save->ColorMask[i][1], + save->ColorMask[i][2], + save->ColorMask[i][3]); + } + } + } } if (state & META_DEPTH_TEST) { diff --git a/src/mesa/drivers/directfb/idirectfbgl_mesa.c b/src/mesa/drivers/directfb/idirectfbgl_mesa.c index 93593403c1..62a3269d17 100644 --- a/src/mesa/drivers/directfb/idirectfbgl_mesa.c +++ b/src/mesa/drivers/directfb/idirectfbgl_mesa.c @@ -407,10 +407,10 @@ dfbClear( GLcontext *ctx, GLbitfield mask ) #define BUFFER_BIT_MASK (BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_FRONT_RIGHT | \ BUFFER_BIT_BACK_LEFT | BUFFER_BIT_BACK_RIGHT ) if (mask & BUFFER_BIT_MASK && - ctx->Color.ColorMask[0] && - ctx->Color.ColorMask[1] && - ctx->Color.ColorMask[2] && - ctx->Color.ColorMask[3]) + ctx->Color.ColorMask[0][0] && + ctx->Color.ColorMask[0][1] && + ctx->Color.ColorMask[0][2] && + ctx->Color.ColorMask[0][3]) { DFBRegion clip; GLubyte a, r, g, b; diff --git a/src/mesa/drivers/dri/gamma/gamma_state.c b/src/mesa/drivers/dri/gamma/gamma_state.c index 59272f9bc9..bdd1c86ab7 100644 --- a/src/mesa/drivers/dri/gamma/gamma_state.c +++ b/src/mesa/drivers/dri/gamma/gamma_state.c @@ -813,10 +813,10 @@ static void gammaUpdateMasks( GLcontext *ctx ) GLuint mask = gammaPackColor( gmesa->gammaScreen->cpp, - ctx->Color.ColorMask[RCOMP], - ctx->Color.ColorMask[GCOMP], - ctx->Color.ColorMask[BCOMP], - ctx->Color.ColorMask[ACOMP] ); + ctx->Color.ColorMask[0][RCOMP], + ctx->Color.ColorMask[0][GCOMP], + ctx->Color.ColorMask[0][BCOMP], + ctx->Color.ColorMask[0][ACOMP] ); if (gmesa->gammaScreen->cpp == 2) mask |= mask << 16; diff --git a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c index 8810f2a380..7aca3aac8e 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c +++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c @@ -575,7 +575,7 @@ brw_update_renderbuffer_surface(struct brw_context *brw, key.draw_offset = 0; } /* _NEW_COLOR */ - memcpy(key.color_mask, ctx->Color.ColorMask, + memcpy(key.color_mask, ctx->Color.ColorMask[0], sizeof(key.color_mask)); /* As mentioned above, disable writes to the alpha component when the diff --git a/src/mesa/drivers/dri/intel/intel_clear.c b/src/mesa/drivers/dri/intel/intel_clear.c index f682ee3de5..956f2339ff 100644 --- a/src/mesa/drivers/dri/intel/intel_clear.c +++ b/src/mesa/drivers/dri/intel/intel_clear.c @@ -68,7 +68,7 @@ static void intelClear(GLcontext *ctx, GLbitfield mask) { struct intel_context *intel = intel_context(ctx); - const GLuint colorMask = *((GLuint *) & ctx->Color.ColorMask); + const GLuint colorMask = *((GLuint *) & ctx->Color.ColorMask[0]); GLbitfield tri_mask = 0; GLbitfield blit_mask = 0; GLbitfield swrast_mask = 0; diff --git a/src/mesa/drivers/dri/intel/intel_pixel.c b/src/mesa/drivers/dri/intel/intel_pixel.c index 993e427a99..5142f3dcd9 100644 --- a/src/mesa/drivers/dri/intel/intel_pixel.c +++ b/src/mesa/drivers/dri/intel/intel_pixel.c @@ -88,10 +88,10 @@ intel_check_blit_fragment_ops(GLcontext * ctx, GLboolean src_alpha_is_one) return GL_FALSE; } - if (!(ctx->Color.ColorMask[0] && - ctx->Color.ColorMask[1] && - ctx->Color.ColorMask[2] && - ctx->Color.ColorMask[3])) { + if (!(ctx->Color.ColorMask[0][0] && + ctx->Color.ColorMask[0][1] && + ctx->Color.ColorMask[0][2] && + ctx->Color.ColorMask[0][3])) { DBG("fallback due to color masking\n"); return GL_FALSE; } diff --git a/src/mesa/drivers/dri/intel/intel_pixel_copy.c b/src/mesa/drivers/dri/intel/intel_pixel_copy.c index 622aaa22d6..689a00cb00 100644 --- a/src/mesa/drivers/dri/intel/intel_pixel_copy.c +++ b/src/mesa/drivers/dri/intel/intel_pixel_copy.c @@ -83,10 +83,10 @@ intel_check_copypixel_blit_fragment_ops(GLcontext * ctx) ctx->Depth.Test || ctx->Fog.Enabled || ctx->Stencil._Enabled || - !ctx->Color.ColorMask[0] || - !ctx->Color.ColorMask[1] || - !ctx->Color.ColorMask[2] || - !ctx->Color.ColorMask[3] || + !ctx->Color.ColorMask[0][0] || + !ctx->Color.ColorMask[0][1] || + !ctx->Color.ColorMask[0][2] || + !ctx->Color.ColorMask[0][3] || ctx->Texture._EnabledUnits || ctx->FragmentProgram._Enabled || ctx->Color.BlendEnabled); diff --git a/src/mesa/drivers/dri/mach64/mach64_state.c b/src/mesa/drivers/dri/mach64/mach64_state.c index 3a023187ce..902905de71 100644 --- a/src/mesa/drivers/dri/mach64/mach64_state.c +++ b/src/mesa/drivers/dri/mach64/mach64_state.c @@ -527,10 +527,10 @@ static void mach64UpdateMasks( GLcontext *ctx ) /* mach64 can't color mask with alpha blending enabled */ if ( !ctx->Color.BlendEnabled ) { mask = mach64PackColor( mmesa->mach64Screen->cpp, - ctx->Color.ColorMask[RCOMP], - ctx->Color.ColorMask[GCOMP], - ctx->Color.ColorMask[BCOMP], - ctx->Color.ColorMask[ACOMP] ); + ctx->Color.ColorMask[0][RCOMP], + ctx->Color.ColorMask[0][GCOMP], + ctx->Color.ColorMask[0][BCOMP], + ctx->Color.ColorMask[0][ACOMP] ); } if ( mmesa->setup.dp_write_mask != mask ) { diff --git a/src/mesa/drivers/dri/mga/mgapixel.c b/src/mesa/drivers/dri/mga/mgapixel.c index 977dfa0b76..05b30ba61e 100644 --- a/src/mesa/drivers/dri/mga/mgapixel.c +++ b/src/mesa/drivers/dri/mga/mgapixel.c @@ -134,10 +134,10 @@ check_color_per_fragment_ops( const GLcontext *ctx ) ctx->Fog.Enabled || ctx->Scissor.Enabled || ctx->Stencil._Enabled || - !ctx->Color.ColorMask[0] || - !ctx->Color.ColorMask[1] || - !ctx->Color.ColorMask[2] || - !ctx->Color.ColorMask[3] || + !ctx->Color.ColorMask[0][0] || + !ctx->Color.ColorMask[0][1] || + !ctx->Color.ColorMask[0][2] || + !ctx->Color.ColorMask[0][3] || ctx->Color.ColorLogicOpEnabled || ctx->Texture._EnabledUnits ) && @@ -150,10 +150,10 @@ static GLboolean check_depth_per_fragment_ops( const GLcontext *ctx ) { return ( ctx->Current.RasterPosValid && - ctx->Color.ColorMask[RCOMP] == 0 && - ctx->Color.ColorMask[BCOMP] == 0 && - ctx->Color.ColorMask[GCOMP] == 0 && - ctx->Color.ColorMask[ACOMP] == 0 && + ctx->Color.ColorMask[0][RCOMP] == 0 && + ctx->Color.ColorMask[0][BCOMP] == 0 && + ctx->Color.ColorMask[0][GCOMP] == 0 && + ctx->Color.ColorMask[0][ACOMP] == 0 && ctx->Pixel.ZoomX == 1.0F && ( ctx->Pixel.ZoomY == 1.0F || ctx->Pixel.ZoomY == -1.0F ) ); } @@ -525,10 +525,10 @@ mgaTryDrawPixels( GLcontext *ctx, mmesa->mgaScreen->backOffset); planemask = mgaPackColor(cpp, - ctx->Color.ColorMask[RCOMP], - ctx->Color.ColorMask[GCOMP], - ctx->Color.ColorMask[BCOMP], - ctx->Color.ColorMask[ACOMP]); + ctx->Color.ColorMask[0][RCOMP], + ctx->Color.ColorMask[0][GCOMP], + ctx->Color.ColorMask[0][BCOMP], + ctx->Color.ColorMask[0][ACOMP]); if (cpp == 2) planemask |= planemask << 16; diff --git a/src/mesa/drivers/dri/mga/mgastate.c b/src/mesa/drivers/dri/mga/mgastate.c index 7c830ec097..1e51057534 100644 --- a/src/mesa/drivers/dri/mga/mgastate.c +++ b/src/mesa/drivers/dri/mga/mgastate.c @@ -374,13 +374,11 @@ static void mgaDDColorMask(GLcontext *ctx, { mgaContextPtr mmesa = MGA_CONTEXT( ctx ); mgaScreenPrivate *mgaScreen = mmesa->mgaScreen; - - GLuint mask = mgaPackColor(mgaScreen->cpp, - ctx->Color.ColorMask[RCOMP], - ctx->Color.ColorMask[GCOMP], - ctx->Color.ColorMask[BCOMP], - ctx->Color.ColorMask[ACOMP]); + ctx->Color.ColorMask[0][RCOMP], + ctx->Color.ColorMask[0][GCOMP], + ctx->Color.ColorMask[0][BCOMP], + ctx->Color.ColorMask[0][ACOMP]); if (mgaScreen->cpp == 2) mask = mask | (mask << 16); diff --git a/src/mesa/drivers/dri/r128/r128_state.c b/src/mesa/drivers/dri/r128/r128_state.c index 4ae7bf5b97..ac175d59ec 100644 --- a/src/mesa/drivers/dri/r128/r128_state.c +++ b/src/mesa/drivers/dri/r128/r128_state.c @@ -702,10 +702,10 @@ static void r128UpdateMasks( GLcontext *ctx ) r128ContextPtr rmesa = R128_CONTEXT(ctx); GLuint mask = r128PackColor( rmesa->r128Screen->cpp, - ctx->Color.ColorMask[RCOMP], - ctx->Color.ColorMask[GCOMP], - ctx->Color.ColorMask[BCOMP], - ctx->Color.ColorMask[ACOMP] ); + ctx->Color.ColorMask[0][RCOMP], + ctx->Color.ColorMask[0][GCOMP], + ctx->Color.ColorMask[0][BCOMP], + ctx->Color.ColorMask[0][ACOMP] ); if ( rmesa->setup.plane_3d_mask_c != mask ) { rmesa->setup.plane_3d_mask_c = mask; diff --git a/src/mesa/drivers/dri/r200/r200_pixel.c b/src/mesa/drivers/dri/r200/r200_pixel.c index 95773871e0..94e43c7d66 100644 --- a/src/mesa/drivers/dri/r200/r200_pixel.c +++ b/src/mesa/drivers/dri/r200/r200_pixel.c @@ -88,10 +88,10 @@ check_color_per_fragment_ops( const GLcontext *ctx ) ctx->Fog.Enabled || ctx->Scissor.Enabled || ctx->Stencil._Enabled || - !ctx->Color.ColorMask[0] || - !ctx->Color.ColorMask[1] || - !ctx->Color.ColorMask[2] || - !ctx->Color.ColorMask[3] || + !ctx->Color.ColorMask[0][0] || + !ctx->Color.ColorMask[0][1] || + !ctx->Color.ColorMask[0][2] || + !ctx->Color.ColorMask[0][3] || ctx->Color.ColorLogicOpEnabled || ctx->Texture._EnabledUnits ) && @@ -400,10 +400,10 @@ r200TryDrawPixels( GLcontext *ctx, case GL_RGBA: case GL_BGRA: planemask = radeonPackColor(cpp, - ctx->Color.ColorMask[RCOMP], - ctx->Color.ColorMask[GCOMP], - ctx->Color.ColorMask[BCOMP], - ctx->Color.ColorMask[ACOMP]); + ctx->Color.ColorMask[0][RCOMP], + ctx->Color.ColorMask[0][GCOMP], + ctx->Color.ColorMask[0][BCOMP], + ctx->Color.ColorMask[0][ACOMP]); if (cpp == 2) planemask |= planemask << 16; diff --git a/src/mesa/drivers/dri/r200/r200_state.c b/src/mesa/drivers/dri/r200/r200_state.c index 6d99c039de..529cb62264 100644 --- a/src/mesa/drivers/dri/r200/r200_state.c +++ b/src/mesa/drivers/dri/r200/r200_state.c @@ -721,10 +721,10 @@ static void r200ColorMask( GLcontext *ctx, if (!rrb) return; mask = radeonPackColor( rrb->cpp, - ctx->Color.ColorMask[RCOMP], - ctx->Color.ColorMask[GCOMP], - ctx->Color.ColorMask[BCOMP], - ctx->Color.ColorMask[ACOMP] ); + ctx->Color.ColorMask[0][RCOMP], + ctx->Color.ColorMask[0][GCOMP], + ctx->Color.ColorMask[0][BCOMP], + ctx->Color.ColorMask[0][ACOMP] ); if (!(r && g && b && a)) diff --git a/src/mesa/drivers/dri/r300/r300_state.c b/src/mesa/drivers/dri/r300/r300_state.c index 23f81fe790..f90bfd4f4f 100644 --- a/src/mesa/drivers/dri/r300/r300_state.c +++ b/src/mesa/drivers/dri/r300/r300_state.c @@ -1768,9 +1768,10 @@ static void r300ResetHwState(r300ContextPtr r300) radeon_firevertices(&r300->radeon); r300ColorMask(ctx, - ctx->Color.ColorMask[RCOMP], - ctx->Color.ColorMask[GCOMP], - ctx->Color.ColorMask[BCOMP], ctx->Color.ColorMask[ACOMP]); + ctx->Color.ColorMask[0][RCOMP], + ctx->Color.ColorMask[0][GCOMP], + ctx->Color.ColorMask[0][BCOMP], + ctx->Color.ColorMask[0][ACOMP]); r300Enable(ctx, GL_DEPTH_TEST, ctx->Depth.Test); r300DepthMask(ctx, ctx->Depth.Mask); diff --git a/src/mesa/drivers/dri/r600/r700_clear.c b/src/mesa/drivers/dri/r600/r700_clear.c index 526d3843d1..c0ac54a844 100644 --- a/src/mesa/drivers/dri/r600/r700_clear.c +++ b/src/mesa/drivers/dri/r600/r700_clear.c @@ -50,7 +50,7 @@ void r700Clear(GLcontext * ctx, GLbitfield mask) { context_t *context = R700_CONTEXT(ctx); __DRIdrawablePrivate *dPriv = radeon_get_drawable(&context->radeon); - const GLuint colorMask = *((GLuint *) & ctx->Color.ColorMask); + const GLuint colorMask = *((GLuint *) & ctx->Color.ColorMask[0]); GLbitfield swrast_mask = 0, tri_mask = 0; int i; struct gl_framebuffer *fb = ctx->DrawBuffer; diff --git a/src/mesa/drivers/dri/r600/r700_state.c b/src/mesa/drivers/dri/r600/r700_state.c index 16b05d5cd9..fc6fb29fd6 100644 --- a/src/mesa/drivers/dri/r600/r700_state.c +++ b/src/mesa/drivers/dri/r600/r700_state.c @@ -1724,10 +1724,10 @@ void r700InitState(GLcontext * ctx) //------------------- r700InitSQConfig(ctx); r700ColorMask(ctx, - ctx->Color.ColorMask[RCOMP], - ctx->Color.ColorMask[GCOMP], - ctx->Color.ColorMask[BCOMP], - ctx->Color.ColorMask[ACOMP]); + ctx->Color.ColorMask[0][RCOMP], + ctx->Color.ColorMask[0][GCOMP], + ctx->Color.ColorMask[0][BCOMP], + ctx->Color.ColorMask[0][ACOMP]); r700Enable(ctx, GL_DEPTH_TEST, ctx->Depth.Test); r700DepthMask(ctx, ctx->Depth.Mask); diff --git a/src/mesa/drivers/dri/radeon/radeon_state.c b/src/mesa/drivers/dri/radeon/radeon_state.c index f6c733ab20..1fcb545204 100644 --- a/src/mesa/drivers/dri/radeon/radeon_state.c +++ b/src/mesa/drivers/dri/radeon/radeon_state.c @@ -521,10 +521,10 @@ static void radeonColorMask( GLcontext *ctx, return; mask = radeonPackColor( rrb->cpp, - ctx->Color.ColorMask[RCOMP], - ctx->Color.ColorMask[GCOMP], - ctx->Color.ColorMask[BCOMP], - ctx->Color.ColorMask[ACOMP] ); + ctx->Color.ColorMask[0][RCOMP], + ctx->Color.ColorMask[0][GCOMP], + ctx->Color.ColorMask[0][BCOMP], + ctx->Color.ColorMask[0][ACOMP] ); if ( rmesa->hw.msk.cmd[MSK_RB3D_PLANEMASK] != mask ) { RADEON_STATECHANGE( rmesa, msk ); diff --git a/src/mesa/drivers/dri/savage/savageioctl.c b/src/mesa/drivers/dri/savage/savageioctl.c index 77ab8d16e0..706fc97935 100644 --- a/src/mesa/drivers/dri/savage/savageioctl.c +++ b/src/mesa/drivers/dri/savage/savageioctl.c @@ -360,15 +360,15 @@ static void savageDDClear( GLcontext *ctx, GLbitfield mask ) depthMask = 0; switch (imesa->savageScreen->cpp) { case 2: - colorMask = PACK_COLOR_565(ctx->Color.ColorMask[0], - ctx->Color.ColorMask[1], - ctx->Color.ColorMask[2]); + colorMask = PACK_COLOR_565(ctx->Color.ColorMask[0][0], + ctx->Color.ColorMask[0][1], + ctx->Color.ColorMask[0][2]); break; case 4: - colorMask = PACK_COLOR_8888(ctx->Color.ColorMask[3], - ctx->Color.ColorMask[2], - ctx->Color.ColorMask[1], - ctx->Color.ColorMask[0]); + colorMask = PACK_COLOR_8888(ctx->Color.ColorMask[0][3], + ctx->Color.ColorMask[0][2], + ctx->Color.ColorMask[0][1], + ctx->Color.ColorMask[0][0]); break; } diff --git a/src/mesa/drivers/dri/tdfx/tdfx_pixels.c b/src/mesa/drivers/dri/tdfx/tdfx_pixels.c index 18729d5ae0..a3b1775e90 100644 --- a/src/mesa/drivers/dri/tdfx/tdfx_pixels.c +++ b/src/mesa/drivers/dri/tdfx/tdfx_pixels.c @@ -611,10 +611,10 @@ tdfx_drawpixels_R8G8B8A8(GLcontext * ctx, GLint x, GLint y, ctx->Fog.Enabled || ctx->Scissor.Enabled || ctx->Stencil._Enabled || - !ctx->Color.ColorMask[0] || - !ctx->Color.ColorMask[1] || - !ctx->Color.ColorMask[2] || - !ctx->Color.ColorMask[3] || + !ctx->Color.ColorMask[0][0] || + !ctx->Color.ColorMask[0][1] || + !ctx->Color.ColorMask[0][2] || + !ctx->Color.ColorMask[0][3] || ctx->Color.ColorLogicOpEnabled || ctx->Texture._EnabledUnits || fxMesa->Fallback) diff --git a/src/mesa/drivers/dri/tdfx/tdfx_render.c b/src/mesa/drivers/dri/tdfx/tdfx_render.c index 2cd8e12d95..79d63f72ac 100644 --- a/src/mesa/drivers/dri/tdfx/tdfx_render.c +++ b/src/mesa/drivers/dri/tdfx/tdfx_render.c @@ -76,8 +76,8 @@ static void tdfxClear( GLcontext *ctx, GLbitfield mask ) if (fxMesa->glCtx->Visual.redBits != 8) { /* can only do color masking if running in 24/32bpp on Napalm */ - if (ctx->Color.ColorMask[RCOMP] != ctx->Color.ColorMask[GCOMP] || - ctx->Color.ColorMask[GCOMP] != ctx->Color.ColorMask[BCOMP]) { + if (ctx->Color.ColorMask[0][RCOMP] != ctx->Color.ColorMask[0][GCOMP] || + ctx->Color.ColorMask[0][GCOMP] != ctx->Color.ColorMask[0][BCOMP]) { softwareMask |= (mask & (BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT)); mask &= ~(BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT); } @@ -721,7 +721,7 @@ void tdfxEmitHwStateLocked( tdfxContextPtr fxMesa ) fxMesa->Glide.grColorMask( fxMesa->Color.ColorMask[RCOMP] || fxMesa->Color.ColorMask[GCOMP] || fxMesa->Color.ColorMask[BCOMP], - /*fxMesa->Color.ColorMask[ACOMP]*/GL_FALSE/*[dBorca] no-no*/ ); + /*fxMesa->Color.ColorMask[0][ACOMP]*/GL_FALSE/*[dBorca] no-no*/ ); } fxMesa->dirty &= ~TDFX_UPLOAD_COLOR_MASK; } diff --git a/src/mesa/drivers/dri/unichrome/via_state.c b/src/mesa/drivers/dri/unichrome/via_state.c index 840e4e42da..a9db6c45f7 100644 --- a/src/mesa/drivers/dri/unichrome/via_state.c +++ b/src/mesa/drivers/dri/unichrome/via_state.c @@ -1238,12 +1238,12 @@ static void viaChooseColorState(GLcontext *ctx) else vmesa->regHROP = HC_HROP_P; - vmesa->regHFBBMSKL = PACK_COLOR_888(ctx->Color.ColorMask[0], - ctx->Color.ColorMask[1], - ctx->Color.ColorMask[2]); - vmesa->regHROP |= ctx->Color.ColorMask[3]; + vmesa->regHFBBMSKL = PACK_COLOR_888(ctx->Color.ColorMask[0][0], + ctx->Color.ColorMask[0][1], + ctx->Color.ColorMask[0][2]); + vmesa->regHROP |= ctx->Color.ColorMask[0][3]; - if (ctx->Color.ColorMask[3]) + if (ctx->Color.ColorMask[0][3]) vmesa->regEnable |= HC_HenAW_MASK; else vmesa->regEnable &= ~HC_HenAW_MASK; diff --git a/src/mesa/drivers/windows/gdi/wmesa.c b/src/mesa/drivers/windows/gdi/wmesa.c index 8929b22af1..76c825a090 100644 --- a/src/mesa/drivers/windows/gdi/wmesa.c +++ b/src/mesa/drivers/windows/gdi/wmesa.c @@ -301,10 +301,10 @@ static void clear(GLcontext *ctx, GLbitfield mask) /* Let swrast do all the work if the masks are not set to * clear all channels. */ - if (ctx->Color.ColorMask[0] != 0xff || - ctx->Color.ColorMask[1] != 0xff || - ctx->Color.ColorMask[2] != 0xff || - ctx->Color.ColorMask[3] != 0xff) { + if (!ctx->Color.ColorMask[0][0] || + !ctx->Color.ColorMask[0][1] || + !ctx->Color.ColorMask[0][2] || + !ctx->Color.ColorMask[0][3]) { _swrast_Clear(ctx, mask); return; } diff --git a/src/mesa/drivers/windows/gldirect/dx7/gld_driver_dx7.c b/src/mesa/drivers/windows/gldirect/dx7/gld_driver_dx7.c index d5fa642800..7b202dfda7 100644 --- a/src/mesa/drivers/windows/gldirect/dx7/gld_driver_dx7.c +++ b/src/mesa/drivers/windows/gldirect/dx7/gld_driver_dx7.c @@ -269,7 +269,7 @@ void gld_Clear_DX7( D3DRECT d3dClearRect; // TODO: Colourmask - const GLuint *colorMask = (GLuint *) &ctx->Color.ColorMask; + const GLuint *colorMask = (GLuint *) &ctx->Color.ColorMask[0]; if (!gld->pDev) return; @@ -427,10 +427,10 @@ void gld_NEW_COLOR( /* // Color mask - unsupported by DX7 - if (ctx->Color.ColorMask[0]) dwFlags |= D3DCOLORWRITEENABLE_RED; - if (ctx->Color.ColorMask[1]) dwFlags |= D3DCOLORWRITEENABLE_GREEN; - if (ctx->Color.ColorMask[2]) dwFlags |= D3DCOLORWRITEENABLE_BLUE; - if (ctx->Color.ColorMask[3]) dwFlags |= D3DCOLORWRITEENABLE_ALPHA; + if (ctx->Color.ColorMask[0][0]) dwFlags |= D3DCOLORWRITEENABLE_RED; + if (ctx->Color.ColorMask[0][1]) dwFlags |= D3DCOLORWRITEENABLE_GREEN; + if (ctx->Color.ColorMask[0][2]) dwFlags |= D3DCOLORWRITEENABLE_BLUE; + if (ctx->Color.ColorMask[0][3]) dwFlags |= D3DCOLORWRITEENABLE_ALPHA; _GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_COLORWRITEENABLE, dwFlags)); */ } diff --git a/src/mesa/drivers/windows/gldirect/dx8/gld_driver_dx8.c b/src/mesa/drivers/windows/gldirect/dx8/gld_driver_dx8.c index 7afa9190cd..7eeb9db2d1 100644 --- a/src/mesa/drivers/windows/gldirect/dx8/gld_driver_dx8.c +++ b/src/mesa/drivers/windows/gldirect/dx8/gld_driver_dx8.c @@ -269,7 +269,7 @@ void gld_Clear_DX8( D3DRECT d3dClearRect; // TODO: Colourmask - const GLuint *colorMask = (GLuint *) &ctx->Color.ColorMask; + const GLuint *colorMask = (GLuint *) &ctx->Color.ColorMask[0]; if (!gld->pDev) return; @@ -426,10 +426,10 @@ void gld_NEW_COLOR( _GLD_DX8_DEV(SetRenderState(gld->pDev, D3DRS_DESTBLEND, dest)); // Color mask - if (ctx->Color.ColorMask[0]) dwFlags |= D3DCOLORWRITEENABLE_RED; - if (ctx->Color.ColorMask[1]) dwFlags |= D3DCOLORWRITEENABLE_GREEN; - if (ctx->Color.ColorMask[2]) dwFlags |= D3DCOLORWRITEENABLE_BLUE; - if (ctx->Color.ColorMask[3]) dwFlags |= D3DCOLORWRITEENABLE_ALPHA; + if (ctx->Color.ColorMask[0][0]) dwFlags |= D3DCOLORWRITEENABLE_RED; + if (ctx->Color.ColorMask[0][1]) dwFlags |= D3DCOLORWRITEENABLE_GREEN; + if (ctx->Color.ColorMask[0][2]) dwFlags |= D3DCOLORWRITEENABLE_BLUE; + if (ctx->Color.ColorMask[0][3]) dwFlags |= D3DCOLORWRITEENABLE_ALPHA; _GLD_DX8_DEV(SetRenderState(gld->pDev, D3DRS_COLORWRITEENABLE, dwFlags)); } diff --git a/src/mesa/drivers/windows/gldirect/dx9/gld_driver_dx9.c b/src/mesa/drivers/windows/gldirect/dx9/gld_driver_dx9.c index c191564d6e..0558462dea 100644 --- a/src/mesa/drivers/windows/gldirect/dx9/gld_driver_dx9.c +++ b/src/mesa/drivers/windows/gldirect/dx9/gld_driver_dx9.c @@ -269,7 +269,7 @@ void gld_Clear_DX9( D3DRECT d3dClearRect; // TODO: Colourmask - const GLuint *colorMask = (GLuint *) &ctx->Color.ColorMask; + const GLuint *colorMask = (GLuint *) &ctx->Color.ColorMask[0]; if (!gld->pDev) return; @@ -424,10 +424,10 @@ void gld_NEW_COLOR( _GLD_DX9_DEV(SetRenderState(gld->pDev, D3DRS_DESTBLEND, dest)); // Color mask - if (ctx->Color.ColorMask[0]) dwFlags |= D3DCOLORWRITEENABLE_RED; - if (ctx->Color.ColorMask[1]) dwFlags |= D3DCOLORWRITEENABLE_GREEN; - if (ctx->Color.ColorMask[2]) dwFlags |= D3DCOLORWRITEENABLE_BLUE; - if (ctx->Color.ColorMask[3]) dwFlags |= D3DCOLORWRITEENABLE_ALPHA; + if (ctx->Color.ColorMask[0][0]) dwFlags |= D3DCOLORWRITEENABLE_RED; + if (ctx->Color.ColorMask[0][1]) dwFlags |= D3DCOLORWRITEENABLE_GREEN; + if (ctx->Color.ColorMask[0][2]) dwFlags |= D3DCOLORWRITEENABLE_BLUE; + if (ctx->Color.ColorMask[0][3]) dwFlags |= D3DCOLORWRITEENABLE_ALPHA; _GLD_DX9_DEV(SetRenderState(gld->pDev, D3DRS_COLORWRITEENABLE, dwFlags)); } diff --git a/src/mesa/drivers/x11/xm_dd.c b/src/mesa/drivers/x11/xm_dd.c index a27d7045ab..df04e3a101 100644 --- a/src/mesa/drivers/x11/xm_dd.c +++ b/src/mesa/drivers/x11/xm_dd.c @@ -381,7 +381,7 @@ clear_buffers(GLcontext *ctx, GLbitfield buffers) { if (ctx->DrawBuffer->Name == 0) { /* this is a window system framebuffer */ - const GLuint *colorMask = (GLuint *) &ctx->Color.ColorMask; + const GLuint *colorMask = (GLuint *) &ctx->Color.ColorMask[0]; XMesaBuffer b = XMESA_BUFFER(ctx->DrawBuffer); const GLint x = ctx->DrawBuffer->_Xmin; const GLint y = ctx->DrawBuffer->_Ymin; diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c index 88ce0a4281..30e97a6e38 100644 --- a/src/mesa/main/attrib.c +++ b/src/mesa/main/attrib.c @@ -919,10 +919,22 @@ _mesa_PopAttrib(void) color->ClearColor[2], color->ClearColor[3]); _mesa_IndexMask(color->IndexMask); - _mesa_ColorMask((GLboolean) (color->ColorMask[0] != 0), - (GLboolean) (color->ColorMask[1] != 0), - (GLboolean) (color->ColorMask[2] != 0), - (GLboolean) (color->ColorMask[3] != 0)); + if (1/*ctx->Extensions.EXT_draw_buffers2*/) { + _mesa_ColorMask((GLboolean) (color->ColorMask[0][0] != 0), + (GLboolean) (color->ColorMask[0][1] != 0), + (GLboolean) (color->ColorMask[0][2] != 0), + (GLboolean) (color->ColorMask[0][3] != 0)); + } + else { + GLuint i; + for (i = 0; i < ctx->Const.MaxDrawBuffers; i++) { + _mesa_ColorMaskIndexed(i, + (GLboolean) (color->ColorMask[i][0] != 0), + (GLboolean) (color->ColorMask[i][1] != 0), + (GLboolean) (color->ColorMask[i][2] != 0), + (GLboolean) (color->ColorMask[i][3] != 0)); + } + } { /* Need to determine if more than one color output is * specified. If so, call glDrawBuffersARB, else call diff --git a/src/mesa/main/blend.c b/src/mesa/main/blend.c index 5a9d94e12d..b8170dd468 100644 --- a/src/mesa/main/blend.c +++ b/src/mesa/main/blend.c @@ -484,6 +484,8 @@ _mesa_ColorMask( GLboolean red, GLboolean green, { GET_CURRENT_CONTEXT(ctx); GLubyte tmp[4]; + GLuint i; + GLboolean flushed; ASSERT_OUTSIDE_BEGIN_END(ctx); if (MESA_VERBOSE & VERBOSE_API) @@ -497,14 +499,58 @@ _mesa_ColorMask( GLboolean red, GLboolean green, tmp[BCOMP] = blue ? 0xff : 0x0; tmp[ACOMP] = alpha ? 0xff : 0x0; - if (TEST_EQ_4UBV(tmp, ctx->Color.ColorMask)) + flushed = GL_FALSE; + for (i = 0; i < ctx->Const.MaxDrawBuffers; i++) { + if (!TEST_EQ_4V(tmp, ctx->Color.ColorMask[i])) { + if (!flushed) { + FLUSH_VERTICES(ctx, _NEW_COLOR); + } + flushed = GL_TRUE; + COPY_4UBV(ctx->Color.ColorMask[i], tmp); + } + } + + if (ctx->Driver.ColorMask) + ctx->Driver.ColorMask( ctx, red, green, blue, alpha ); +} + + +/** + * For GL_EXT_draw_buffers2 and GL3 + */ +void GLAPIENTRY +_mesa_ColorMaskIndexed( GLuint buf, GLboolean red, GLboolean green, + GLboolean blue, GLboolean alpha ) +{ + GLubyte tmp[4]; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glColorMaskIndexed %u %d %d %d %d\n", + buf, red, green, blue, alpha); + + if (buf >= ctx->Const.MaxDrawBuffers) { + _mesa_error(ctx, GL_INVALID_VALUE, "glColorMaskIndexed(buf=%u)", buf); + return; + } + + /* Shouldn't have any information about channel depth in core mesa + * -- should probably store these as the native booleans: + */ + tmp[RCOMP] = red ? 0xff : 0x0; + tmp[GCOMP] = green ? 0xff : 0x0; + tmp[BCOMP] = blue ? 0xff : 0x0; + tmp[ACOMP] = alpha ? 0xff : 0x0; + + if (TEST_EQ_4V(tmp, ctx->Color.ColorMask[buf])) return; FLUSH_VERTICES(ctx, _NEW_COLOR); - COPY_4UBV(ctx->Color.ColorMask, tmp); + COPY_4UBV(ctx->Color.ColorMask[buf], tmp); - if (ctx->Driver.ColorMask) - ctx->Driver.ColorMask( ctx, red, green, blue, alpha ); + if (ctx->Driver.ColorMaskIndexed) + ctx->Driver.ColorMaskIndexed(ctx, buf, red, green, blue, alpha); } @@ -555,10 +601,7 @@ void _mesa_init_color( GLcontext * ctx ) { /* Color buffer group */ ctx->Color.IndexMask = ~0u; - ctx->Color.ColorMask[0] = 0xff; - ctx->Color.ColorMask[1] = 0xff; - ctx->Color.ColorMask[2] = 0xff; - ctx->Color.ColorMask[3] = 0xff; + memset(ctx->Color.ColorMask, 0xff, sizeof(ctx->Color.ColorMask)); ctx->Color.ClearIndex = 0; ASSIGN_4V( ctx->Color.ClearColor, 0, 0, 0, 0 ); ctx->Color.AlphaEnabled = GL_FALSE; diff --git a/src/mesa/main/blend.h b/src/mesa/main/blend.h index 5c0f2783a7..b4fd7470eb 100644 --- a/src/mesa/main/blend.h +++ b/src/mesa/main/blend.h @@ -72,6 +72,10 @@ extern void GLAPIENTRY _mesa_ColorMask( GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha ); +extern void GLAPIENTRY +_mesa_ColorMaskIndexed( GLuint buf, GLboolean red, GLboolean green, + GLboolean blue, GLboolean alpha ); + extern void GLAPIENTRY _mesa_ClampColorARB(GLenum target, GLenum clamp); diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h index 6dadf5c079..496b0d2ba8 100644 --- a/src/mesa/main/dd.h +++ b/src/mesa/main/dd.h @@ -625,6 +625,8 @@ struct dd_function_table { /** Enable and disable writing of frame buffer color components */ void (*ColorMask)(GLcontext *ctx, GLboolean rmask, GLboolean gmask, GLboolean bmask, GLboolean amask ); + void (*ColorMaskIndexed)(GLcontext *ctx, GLuint buf, GLboolean rmask, + GLboolean gmask, GLboolean bmask, GLboolean amask); /** Cause a material color to track the current color */ void (*ColorMaterial)(GLcontext *ctx, GLenum face, GLenum mode); /** Specify whether front- or back-facing facets can be culled */ diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c index aff67466bc..44396a0491 100644 --- a/src/mesa/main/get.c +++ b/src/mesa/main/get.c @@ -210,10 +210,10 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params ) params[0] = ENUM_TO_BOOLEAN(ctx->Light.ColorMaterialMode); break; case GL_COLOR_WRITEMASK: - params[0] = INT_TO_BOOLEAN(ctx->Color.ColorMask[RCOMP] ? 1 : 0); - params[1] = INT_TO_BOOLEAN(ctx->Color.ColorMask[GCOMP] ? 1 : 0); - params[2] = INT_TO_BOOLEAN(ctx->Color.ColorMask[BCOMP] ? 1 : 0); - params[3] = INT_TO_BOOLEAN(ctx->Color.ColorMask[ACOMP] ? 1 : 0); + params[0] = INT_TO_BOOLEAN(ctx->Color.ColorMask[0][RCOMP] ? 1 : 0); + params[1] = INT_TO_BOOLEAN(ctx->Color.ColorMask[0][GCOMP] ? 1 : 0); + params[2] = INT_TO_BOOLEAN(ctx->Color.ColorMask[0][BCOMP] ? 1 : 0); + params[3] = INT_TO_BOOLEAN(ctx->Color.ColorMask[0][ACOMP] ? 1 : 0); break; case GL_CULL_FACE: params[0] = ctx->Polygon.CullFlag; @@ -2045,10 +2045,10 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params ) params[0] = ENUM_TO_FLOAT(ctx->Light.ColorMaterialMode); break; case GL_COLOR_WRITEMASK: - params[0] = (GLfloat)(ctx->Color.ColorMask[RCOMP] ? 1 : 0); - params[1] = (GLfloat)(ctx->Color.ColorMask[GCOMP] ? 1 : 0); - params[2] = (GLfloat)(ctx->Color.ColorMask[BCOMP] ? 1 : 0); - params[3] = (GLfloat)(ctx->Color.ColorMask[ACOMP] ? 1 : 0); + params[0] = (GLfloat)(ctx->Color.ColorMask[0][RCOMP] ? 1 : 0); + params[1] = (GLfloat)(ctx->Color.ColorMask[0][GCOMP] ? 1 : 0); + params[2] = (GLfloat)(ctx->Color.ColorMask[0][BCOMP] ? 1 : 0); + params[3] = (GLfloat)(ctx->Color.ColorMask[0][ACOMP] ? 1 : 0); break; case GL_CULL_FACE: params[0] = BOOLEAN_TO_FLOAT(ctx->Polygon.CullFlag); @@ -3880,10 +3880,10 @@ _mesa_GetIntegerv( GLenum pname, GLint *params ) params[0] = ENUM_TO_INT(ctx->Light.ColorMaterialMode); break; case GL_COLOR_WRITEMASK: - params[0] = ctx->Color.ColorMask[RCOMP] ? 1 : 0; - params[1] = ctx->Color.ColorMask[GCOMP] ? 1 : 0; - params[2] = ctx->Color.ColorMask[BCOMP] ? 1 : 0; - params[3] = ctx->Color.ColorMask[ACOMP] ? 1 : 0; + params[0] = ctx->Color.ColorMask[0][RCOMP] ? 1 : 0; + params[1] = ctx->Color.ColorMask[0][GCOMP] ? 1 : 0; + params[2] = ctx->Color.ColorMask[0][BCOMP] ? 1 : 0; + params[3] = ctx->Color.ColorMask[0][ACOMP] ? 1 : 0; break; case GL_CULL_FACE: params[0] = BOOLEAN_TO_INT(ctx->Polygon.CullFlag); @@ -5716,10 +5716,10 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params ) params[0] = ENUM_TO_INT64(ctx->Light.ColorMaterialMode); break; case GL_COLOR_WRITEMASK: - params[0] = (GLint64)(ctx->Color.ColorMask[RCOMP] ? 1 : 0); - params[1] = (GLint64)(ctx->Color.ColorMask[GCOMP] ? 1 : 0); - params[2] = (GLint64)(ctx->Color.ColorMask[BCOMP] ? 1 : 0); - params[3] = (GLint64)(ctx->Color.ColorMask[ACOMP] ? 1 : 0); + params[0] = (GLint64)(ctx->Color.ColorMask[0][RCOMP] ? 1 : 0); + params[1] = (GLint64)(ctx->Color.ColorMask[0][GCOMP] ? 1 : 0); + params[2] = (GLint64)(ctx->Color.ColorMask[0][BCOMP] ? 1 : 0); + params[3] = (GLint64)(ctx->Color.ColorMask[0][ACOMP] ? 1 : 0); break; case GL_CULL_FACE: params[0] = BOOLEAN_TO_INT64(ctx->Polygon.CullFlag); @@ -7448,11 +7448,20 @@ _mesa_GetBooleanIndexedv( GLenum pname, GLuint index, GLboolean *params ) switch (pname) { case GL_BLEND: - if (index >= MAX_DRAW_BUFFERS) { + if (index >= ctx->Const.MaxDrawBuffers) { _mesa_error(ctx, GL_INVALID_VALUE, "glGetBooleanIndexedv(index=%u), index", pname); } params[0] = INT_TO_BOOLEAN(((ctx->Color.BlendEnabled >> index) & 1)); break; + case GL_COLOR_WRITEMASK: + if (index >= ctx->Const.MaxDrawBuffers) { + _mesa_error(ctx, GL_INVALID_VALUE, "glGetBooleanIndexedv(index=%u), index", pname); + } + params[0] = INT_TO_BOOLEAN(ctx->Color.ColorMask[index][RCOMP] ? 1 : 0); + params[1] = INT_TO_BOOLEAN(ctx->Color.ColorMask[index][GCOMP] ? 1 : 0); + params[2] = INT_TO_BOOLEAN(ctx->Color.ColorMask[index][BCOMP] ? 1 : 0); + params[3] = INT_TO_BOOLEAN(ctx->Color.ColorMask[index][ACOMP] ? 1 : 0); + break; default: _mesa_error(ctx, GL_INVALID_ENUM, "glGetBooleanIndexedv(pname=0x%x)", pname); } @@ -7472,11 +7481,20 @@ _mesa_GetIntegerIndexedv( GLenum pname, GLuint index, GLint *params ) switch (pname) { case GL_BLEND: - if (index >= MAX_DRAW_BUFFERS) { + if (index >= ctx->Const.MaxDrawBuffers) { _mesa_error(ctx, GL_INVALID_VALUE, "glGetIntegerIndexedv(index=%u), index", pname); } params[0] = ((ctx->Color.BlendEnabled >> index) & 1); break; + case GL_COLOR_WRITEMASK: + if (index >= ctx->Const.MaxDrawBuffers) { + _mesa_error(ctx, GL_INVALID_VALUE, "glGetIntegerIndexedv(index=%u), index", pname); + } + params[0] = ctx->Color.ColorMask[index][RCOMP] ? 1 : 0; + params[1] = ctx->Color.ColorMask[index][GCOMP] ? 1 : 0; + params[2] = ctx->Color.ColorMask[index][BCOMP] ? 1 : 0; + params[3] = ctx->Color.ColorMask[index][ACOMP] ? 1 : 0; + break; default: _mesa_error(ctx, GL_INVALID_ENUM, "glGetIntegerIndexedv(pname=0x%x)", pname); } @@ -7497,11 +7515,20 @@ _mesa_GetInteger64Indexedv( GLenum pname, GLuint index, GLint64 *params ) switch (pname) { case GL_BLEND: - if (index >= MAX_DRAW_BUFFERS) { + if (index >= ctx->Const.MaxDrawBuffers) { _mesa_error(ctx, GL_INVALID_VALUE, "glGetInteger64Indexedv(index=%u), index", pname); } params[0] = (GLint64)(((ctx->Color.BlendEnabled >> index) & 1)); break; + case GL_COLOR_WRITEMASK: + if (index >= ctx->Const.MaxDrawBuffers) { + _mesa_error(ctx, GL_INVALID_VALUE, "glGetInteger64Indexedv(index=%u), index", pname); + } + params[0] = (GLint64)(ctx->Color.ColorMask[index][RCOMP] ? 1 : 0); + params[1] = (GLint64)(ctx->Color.ColorMask[index][GCOMP] ? 1 : 0); + params[2] = (GLint64)(ctx->Color.ColorMask[index][BCOMP] ? 1 : 0); + params[3] = (GLint64)(ctx->Color.ColorMask[index][ACOMP] ? 1 : 0); + break; default: _mesa_error(ctx, GL_INVALID_ENUM, "glGetInteger64Indexedv(pname=0x%x)", pname); } diff --git a/src/mesa/main/get_gen.py b/src/mesa/main/get_gen.py index 8b6500fae1..18708be260 100644 --- a/src/mesa/main/get_gen.py +++ b/src/mesa/main/get_gen.py @@ -126,10 +126,10 @@ StateVars = [ ( "GL_COLOR_MATERIAL_PARAMETER", GLenum, ["ctx->Light.ColorMaterialMode"], "", None ), ( "GL_COLOR_WRITEMASK", GLint, - [ "ctx->Color.ColorMask[RCOMP] ? 1 : 0", - "ctx->Color.ColorMask[GCOMP] ? 1 : 0", - "ctx->Color.ColorMask[BCOMP] ? 1 : 0", - "ctx->Color.ColorMask[ACOMP] ? 1 : 0" ], "", None ), + [ "ctx->Color.ColorMask[0][RCOMP] ? 1 : 0", + "ctx->Color.ColorMask[0][GCOMP] ? 1 : 0", + "ctx->Color.ColorMask[0][BCOMP] ? 1 : 0", + "ctx->Color.ColorMask[0][ACOMP] ? 1 : 0" ], "", None ), ( "GL_CULL_FACE", GLboolean, ["ctx->Polygon.CullFlag"], "", None ), ( "GL_CULL_FACE_MODE", GLenum, ["ctx->Polygon.CullFaceMode"], "", None ), ( "GL_CURRENT_COLOR", GLfloatN, @@ -1035,7 +1035,14 @@ StateVars = [ # These are queried via glGetIntegetIndexdvEXT() or glGetIntegeri_v() IndexedStateVars = [ - ( "GL_BLEND", GLint, ["((ctx->Color.BlendEnabled >> index) & 1)"], "MAX_DRAW_BUFFERS", None ), + ( "GL_BLEND", GLint, ["((ctx->Color.BlendEnabled >> index) & 1)"], + "ctx->Const.MaxDrawBuffers", None ), + ( "GL_COLOR_WRITEMASK", GLint, + [ "ctx->Color.ColorMask[index][RCOMP] ? 1 : 0", + "ctx->Color.ColorMask[index][GCOMP] ? 1 : 0", + "ctx->Color.ColorMask[index][BCOMP] ? 1 : 0", + "ctx->Color.ColorMask[index][ACOMP] ? 1 : 0" ], + "ctx->Const.MaxDrawBuffers", None ), # XXX more to come... ] diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 170c35b11c..7ef2852242 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -564,7 +564,7 @@ struct gl_colorbuffer_attrib GLclampf ClearColor[4]; /**< Color to use for glClear */ GLuint IndexMask; /**< Color index write mask */ - GLubyte ColorMask[4]; /**< Each flag is 0xff or 0x0 */ + GLubyte ColorMask[MAX_DRAW_BUFFERS][4];/**< Each flag is 0xff or 0x0 */ GLenum DrawBuffer[MAX_DRAW_BUFFERS]; /**< Which buffer to draw into */ diff --git a/src/mesa/state_tracker/st_atom_blend.c b/src/mesa/state_tracker/st_atom_blend.c index 35c09c3e08..43e62c29f3 100644 --- a/src/mesa/state_tracker/st_atom_blend.c +++ b/src/mesa/state_tracker/st_atom_blend.c @@ -200,13 +200,13 @@ update_blend( struct st_context *st ) } /* Colormask - maybe reverse these bits? */ - if (st->ctx->Color.ColorMask[0]) + if (st->ctx->Color.ColorMask[0][0]) blend->colormask |= PIPE_MASK_R; - if (st->ctx->Color.ColorMask[1]) + if (st->ctx->Color.ColorMask[0][1]) blend->colormask |= PIPE_MASK_G; - if (st->ctx->Color.ColorMask[2]) + if (st->ctx->Color.ColorMask[0][2]) blend->colormask |= PIPE_MASK_B; - if (st->ctx->Color.ColorMask[3]) + if (st->ctx->Color.ColorMask[0][3]) blend->colormask |= PIPE_MASK_A; if (st->ctx->Color.DitherFlag) diff --git a/src/mesa/state_tracker/st_cb_accum.c b/src/mesa/state_tracker/st_cb_accum.c index a6b9765452..da7b97d325 100644 --- a/src/mesa/state_tracker/st_cb_accum.c +++ b/src/mesa/state_tracker/st_cb_accum.c @@ -229,7 +229,7 @@ accum_return(GLcontext *ctx, GLfloat value, { struct pipe_context *pipe = ctx->st->pipe; struct pipe_screen *screen = pipe->screen; - const GLubyte *colormask = ctx->Color.ColorMask; + const GLubyte *colormask = ctx->Color.ColorMask[0]; enum pipe_transfer_usage usage; struct pipe_transfer *color_trans; size_t stride = acc_strb->stride; diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c index 72b30e7c04..192d765f45 100644 --- a/src/mesa/state_tracker/st_cb_clear.c +++ b/src/mesa/state_tracker/st_cb_clear.c @@ -232,13 +232,13 @@ clear_with_quad(GLcontext *ctx, blend.rgb_dst_factor = PIPE_BLENDFACTOR_ZERO; blend.alpha_dst_factor = PIPE_BLENDFACTOR_ZERO; if (color) { - if (ctx->Color.ColorMask[0]) + if (ctx->Color.ColorMask[0][0]) blend.colormask |= PIPE_MASK_R; - if (ctx->Color.ColorMask[1]) + if (ctx->Color.ColorMask[0][1]) blend.colormask |= PIPE_MASK_G; - if (ctx->Color.ColorMask[2]) + if (ctx->Color.ColorMask[0][2]) blend.colormask |= PIPE_MASK_B; - if (ctx->Color.ColorMask[3]) + if (ctx->Color.ColorMask[0][3]) blend.colormask |= PIPE_MASK_A; if (st->ctx->Color.DitherFlag) blend.dither = 1; @@ -300,10 +300,10 @@ check_clear_color_with_quad(GLcontext *ctx, struct gl_renderbuffer *rb) ctx->Scissor.Height < rb->Height)) return TRUE; - if (!ctx->Color.ColorMask[0] || - !ctx->Color.ColorMask[1] || - !ctx->Color.ColorMask[2] || - !ctx->Color.ColorMask[3]) + if (!ctx->Color.ColorMask[0][0] || + !ctx->Color.ColorMask[0][1] || + !ctx->Color.ColorMask[0][2] || + !ctx->Color.ColorMask[0][3]) return TRUE; return FALSE; diff --git a/src/mesa/swrast/s_accum.c b/src/mesa/swrast/s_accum.c index c6c7dbf5cf..2d8c361e5d 100644 --- a/src/mesa/swrast/s_accum.c +++ b/src/mesa/swrast/s_accum.c @@ -528,7 +528,7 @@ accum_return(GLcontext *ctx, GLfloat value, for (buffer = 0; buffer < fb->_NumColorDrawBuffers; buffer++) { struct gl_renderbuffer *rb = fb->_ColorDrawBuffers[buffer]; if (masking) { - _swrast_mask_rgba_span(ctx, rb, &span); + _swrast_mask_rgba_span(ctx, rb, &span, buffer); } rb->PutRow(ctx, rb, width, xpos, ypos + i, span.array->rgba, NULL); } diff --git a/src/mesa/swrast/s_clear.c b/src/mesa/swrast/s_clear.c index 002718ded8..2d27797d43 100644 --- a/src/mesa/swrast/s_clear.c +++ b/src/mesa/swrast/s_clear.c @@ -40,7 +40,8 @@ * Clear the color buffer when glColorMask is in effect. */ static void -clear_rgba_buffer_with_masking(GLcontext *ctx, struct gl_renderbuffer *rb) +clear_rgba_buffer_with_masking(GLcontext *ctx, struct gl_renderbuffer *rb, + GLuint buf) { const GLint x = ctx->DrawBuffer->_Xmin; const GLint y = ctx->DrawBuffer->_Ymin; @@ -95,7 +96,7 @@ clear_rgba_buffer_with_masking(GLcontext *ctx, struct gl_renderbuffer *rb) for (i = 0; i < height; i++) { span.x = x; span.y = y + i; - _swrast_mask_rgba_span(ctx, rb, &span); + _swrast_mask_rgba_span(ctx, rb, &span, buf); /* write masked row */ rb->PutRow(ctx, rb, width, x, y + i, span.array->rgba, NULL); } @@ -145,7 +146,7 @@ clear_ci_buffer_with_masking(GLcontext *ctx, struct gl_renderbuffer *rb) * Clear an rgba color buffer without channel masking. */ static void -clear_rgba_buffer(GLcontext *ctx, struct gl_renderbuffer *rb) +clear_rgba_buffer(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint buf) { const GLint x = ctx->DrawBuffer->_Xmin; const GLint y = ctx->DrawBuffer->_Ymin; @@ -158,10 +159,10 @@ clear_rgba_buffer(GLcontext *ctx, struct gl_renderbuffer *rb) ASSERT(ctx->Visual.rgbMode); - ASSERT(ctx->Color.ColorMask[0] && - ctx->Color.ColorMask[1] && - ctx->Color.ColorMask[2] && - ctx->Color.ColorMask[3]); + ASSERT(ctx->Color.ColorMask[buf][0] && + ctx->Color.ColorMask[buf][1] && + ctx->Color.ColorMask[buf][2] && + ctx->Color.ColorMask[buf][3]); ASSERT(rb->PutMonoRow); @@ -246,43 +247,24 @@ clear_ci_buffer(GLcontext *ctx, struct gl_renderbuffer *rb) static void clear_color_buffers(GLcontext *ctx) { - GLboolean masking; GLuint buf; - if (ctx->Visual.rgbMode) { - if (ctx->Color.ColorMask[0] && - ctx->Color.ColorMask[1] && - ctx->Color.ColorMask[2] && - ctx->Color.ColorMask[3]) { - masking = GL_FALSE; - } - else { - masking = GL_TRUE; - } - } - else { - struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[0]; - const GLuint indexMask = (1 << _mesa_get_format_bits(rb->Format, GL_INDEX_BITS)) - 1; - if ((ctx->Color.IndexMask & indexMask) == indexMask) { - masking = GL_FALSE; - } - else { - masking = GL_TRUE; - } - } - for (buf = 0; buf < ctx->DrawBuffer->_NumColorDrawBuffers; buf++) { struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[buf]; if (ctx->Visual.rgbMode) { - if (masking) { - clear_rgba_buffer_with_masking(ctx, rb); + if (ctx->Color.ColorMask[buf][0] == 0 || + ctx->Color.ColorMask[buf][1] == 0 || + ctx->Color.ColorMask[buf][2] == 0 || + ctx->Color.ColorMask[buf][3] == 0) { + clear_rgba_buffer_with_masking(ctx, rb, buf); } else { - clear_rgba_buffer(ctx, rb); + clear_rgba_buffer(ctx, rb, buf); } } else { - if (masking) { + const GLuint indexMask = (1 << _mesa_get_format_bits(rb->Format, GL_INDEX_BITS)) - 1; + if ((ctx->Color.IndexMask & indexMask) != indexMask) { clear_ci_buffer_with_masking(ctx, rb); } else { diff --git a/src/mesa/swrast/s_context.c b/src/mesa/swrast/s_context.c index abf0008565..f9092c215a 100644 --- a/src/mesa/swrast/s_context.c +++ b/src/mesa/swrast/s_context.c @@ -55,6 +55,7 @@ _swrast_update_rasterflags( GLcontext *ctx ) { SWcontext *swrast = SWRAST_CONTEXT(ctx); GLbitfield rasterMask = 0; + GLuint i; if (ctx->Color.AlphaEnabled) rasterMask |= ALPHATEST_BIT; if (ctx->Color.BlendEnabled) rasterMask |= BLEND_BIT; @@ -63,8 +64,15 @@ _swrast_update_rasterflags( GLcontext *ctx ) if (ctx->Scissor.Enabled) rasterMask |= CLIP_BIT; if (ctx->Stencil._Enabled) rasterMask |= STENCIL_BIT; if (ctx->Visual.rgbMode) { - const GLuint colorMask = *((GLuint *) &ctx->Color.ColorMask); - if (colorMask != 0xffffffff) rasterMask |= MASKING_BIT; + for (i = 0; i < ctx->Const.MaxDrawBuffers; i++) { + if (!ctx->Color.ColorMask[i][0] || + !ctx->Color.ColorMask[i][1] || + !ctx->Color.ColorMask[i][2] || + !ctx->Color.ColorMask[i][3]) { + rasterMask |= MASKING_BIT; + break; + } + } if (ctx->Color._LogicOpEnabled) rasterMask |= LOGIC_OP_BIT; if (ctx->Texture._EnabledUnits) rasterMask |= TEXTURE_BIT; } @@ -92,13 +100,23 @@ _swrast_update_rasterflags( GLcontext *ctx ) /* more than one color buffer designated for writing (or zero buffers) */ rasterMask |= MULTI_DRAW_BIT; } - else if (ctx->Visual.rgbMode && *((GLuint *) ctx->Color.ColorMask) == 0) { - rasterMask |= MULTI_DRAW_BIT; /* all RGBA channels disabled */ - } else if (!ctx->Visual.rgbMode && ctx->Color.IndexMask==0) { rasterMask |= MULTI_DRAW_BIT; /* all color index bits disabled */ } + if (ctx->Visual.rgbMode) { + for (i = 0; i < ctx->Const.MaxDrawBuffers; i++) { + if (ctx->Color.ColorMask[i][0] + + ctx->Color.ColorMask[i][1] + + ctx->Color.ColorMask[i][2] + + ctx->Color.ColorMask[i][3] == 0) { + rasterMask |= MULTI_DRAW_BIT; /* all RGBA channels disabled */ + break; + } + } + } + + if (ctx->FragmentProgram._Current) { rasterMask |= FRAGPROG_BIT; } diff --git a/src/mesa/swrast/s_masking.c b/src/mesa/swrast/s_masking.c index df779b0739..69c2feb6da 100644 --- a/src/mesa/swrast/s_masking.c +++ b/src/mesa/swrast/s_masking.c @@ -41,7 +41,7 @@ */ void _swrast_mask_rgba_span(GLcontext *ctx, struct gl_renderbuffer *rb, - SWspan *span) + SWspan *span, GLuint buf) { const GLuint n = span->end; void *rbPixels; @@ -58,7 +58,7 @@ _swrast_mask_rgba_span(GLcontext *ctx, struct gl_renderbuffer *rb, */ if (span->array->ChanType == GL_UNSIGNED_BYTE) { /* treat 4xGLubyte as 1xGLuint */ - const GLuint srcMask = *((GLuint *) ctx->Color.ColorMask); + const GLuint srcMask = *((GLuint *) ctx->Color.ColorMask[buf]); const GLuint dstMask = ~srcMask; const GLuint *dst = (const GLuint *) rbPixels; GLuint *src = (GLuint *) span->array->rgba8; @@ -70,10 +70,10 @@ _swrast_mask_rgba_span(GLcontext *ctx, struct gl_renderbuffer *rb, else if (span->array->ChanType == GL_UNSIGNED_SHORT) { /* 2-byte components */ /* XXX try to use 64-bit arithmetic someday */ - const GLushort rMask = ctx->Color.ColorMask[RCOMP] ? 0xffff : 0x0; - const GLushort gMask = ctx->Color.ColorMask[GCOMP] ? 0xffff : 0x0; - const GLushort bMask = ctx->Color.ColorMask[BCOMP] ? 0xffff : 0x0; - const GLushort aMask = ctx->Color.ColorMask[ACOMP] ? 0xffff : 0x0; + const GLushort rMask = ctx->Color.ColorMask[buf][RCOMP] ? 0xffff : 0x0; + const GLushort gMask = ctx->Color.ColorMask[buf][GCOMP] ? 0xffff : 0x0; + const GLushort bMask = ctx->Color.ColorMask[buf][BCOMP] ? 0xffff : 0x0; + const GLushort aMask = ctx->Color.ColorMask[buf][ACOMP] ? 0xffff : 0x0; const GLushort (*dst)[4] = (const GLushort (*)[4]) rbPixels; GLushort (*src)[4] = span->array->rgba16; GLuint i; @@ -86,10 +86,10 @@ _swrast_mask_rgba_span(GLcontext *ctx, struct gl_renderbuffer *rb, } else { /* 4-byte components */ - const GLuint rMask = ctx->Color.ColorMask[RCOMP] ? ~0x0 : 0x0; - const GLuint gMask = ctx->Color.ColorMask[GCOMP] ? ~0x0 : 0x0; - const GLuint bMask = ctx->Color.ColorMask[BCOMP] ? ~0x0 : 0x0; - const GLuint aMask = ctx->Color.ColorMask[ACOMP] ? ~0x0 : 0x0; + const GLuint rMask = ctx->Color.ColorMask[buf][RCOMP] ? ~0x0 : 0x0; + const GLuint gMask = ctx->Color.ColorMask[buf][GCOMP] ? ~0x0 : 0x0; + const GLuint bMask = ctx->Color.ColorMask[buf][BCOMP] ? ~0x0 : 0x0; + const GLuint aMask = ctx->Color.ColorMask[buf][ACOMP] ? ~0x0 : 0x0; const GLuint (*dst)[4] = (const GLuint (*)[4]) rbPixels; GLuint (*src)[4] = (GLuint (*)[4]) span->array->attribs[FRAG_ATTRIB_COL0]; GLuint i; diff --git a/src/mesa/swrast/s_masking.h b/src/mesa/swrast/s_masking.h index 3260ca34e3..fed47f8cfb 100644 --- a/src/mesa/swrast/s_masking.h +++ b/src/mesa/swrast/s_masking.h @@ -32,7 +32,7 @@ extern void _swrast_mask_rgba_span(GLcontext *ctx, struct gl_renderbuffer *rb, - SWspan *span); + SWspan *span, GLuint buf); extern void diff --git a/src/mesa/swrast/s_span.c b/src/mesa/swrast/s_span.c index 00de13d495..a311d4b4bd 100644 --- a/src/mesa/swrast/s_span.c +++ b/src/mesa/swrast/s_span.c @@ -1278,7 +1278,7 @@ void _swrast_write_rgba_span( GLcontext *ctx, SWspan *span) { const SWcontext *swrast = SWRAST_CONTEXT(ctx); - const GLuint colorMask = *((GLuint *) ctx->Color.ColorMask); + const GLuint *colorMask = (GLuint *) ctx->Color.ColorMask; const GLbitfield origInterpMask = span->interpMask; const GLbitfield origArrayMask = span->arrayMask; const GLbitfield origArrayAttribs = span->arrayAttribs; @@ -1389,7 +1389,7 @@ _swrast_write_rgba_span( GLcontext *ctx, SWspan *span) /* We had to wait until now to check for glColorMask(0,0,0,0) because of * the occlusion test. */ - if (colorMask == 0x0) { + if (fb->_NumColorDrawBuffers == 1 && colorMask[0] == 0x0) { /* no colors to write */ goto end; } @@ -1483,8 +1483,8 @@ _swrast_write_rgba_span( GLcontext *ctx, SWspan *span) _swrast_blend_span(ctx, rb, span); } - if (colorMask != 0xffffffff) { - _swrast_mask_rgba_span(ctx, rb, span); + if (colorMask[buf] != 0xffffffff) { + _swrast_mask_rgba_span(ctx, rb, span, buf); } if (span->arrayMask & SPAN_XY) { diff --git a/src/mesa/swrast/s_triangle.c b/src/mesa/swrast/s_triangle.c index 5bec606696..11184b72ce 100644 --- a/src/mesa/swrast/s_triangle.c +++ b/src/mesa/swrast/s_triangle.c @@ -1030,10 +1030,10 @@ _swrast_choose_triangle( GLcontext *ctx ) ctx->Depth.Func == GL_LESS && !ctx->Stencil._Enabled) { if ((rgbmode && - ctx->Color.ColorMask[0] == 0 && - ctx->Color.ColorMask[1] == 0 && - ctx->Color.ColorMask[2] == 0 && - ctx->Color.ColorMask[3] == 0) + ctx->Color.ColorMask[0][0] == 0 && + ctx->Color.ColorMask[0][1] == 0 && + ctx->Color.ColorMask[0][2] == 0 && + ctx->Color.ColorMask[0][3] == 0) || (!rgbmode && ctx->Color.IndexMask == 0)) { USE(occlusion_zless_triangle); -- cgit v1.2.3 From 8f6f1124634cf659dde4c75549b84e35505d892d Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 29 Dec 2009 16:30:54 -0700 Subject: mesa: added infrastructure for GL_EXT_draw_buffers2 --- src/mesa/main/enable.c | 13 ++++++++++--- src/mesa/main/extensions.c | 1 + src/mesa/main/get.c | 6 ++++++ src/mesa/main/get_gen.py | 14 +++++++------- src/mesa/main/mtypes.h | 1 + 5 files changed, 25 insertions(+), 10 deletions(-) (limited to 'src/mesa/main/get.c') diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c index 6f9f57f5cb..cd6e881ad2 100644 --- a/src/mesa/main/enable.c +++ b/src/mesa/main/enable.c @@ -1033,6 +1033,9 @@ _mesa_set_enablei(GLcontext *ctx, GLenum cap, GLuint index, GLboolean state) ASSERT(state == 0 || state == 1); switch (cap) { case GL_BLEND: + if (!ctx->Extensions.EXT_draw_buffers2) { + goto bad_cap_error; + } if (index >= ctx->Const.MaxDrawBuffers) { _mesa_error(ctx, GL_INVALID_VALUE, "%s(index=%u)", state ? "glEnableIndexed" : "glDisableIndexed", index); @@ -1047,10 +1050,14 @@ _mesa_set_enablei(GLcontext *ctx, GLenum cap, GLuint index, GLboolean state) } break; default: - _mesa_error(ctx, GL_INVALID_ENUM, "%s(cap=%s)", - state ? "glEnableIndexed" : "glDisableIndexed", - _mesa_lookup_enum_by_nr(cap)); + goto bad_cap_error; } + return; + +bad_cap_error: + _mesa_error(ctx, GL_INVALID_ENUM, "%s(cap=%s)", + state ? "glEnablei" : "glDisablei", + _mesa_lookup_enum_by_nr(cap)); } diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c index 2138bfe40e..9e96eb0403 100644 --- a/src/mesa/main/extensions.c +++ b/src/mesa/main/extensions.c @@ -103,6 +103,7 @@ static const struct { { OFF, "GL_EXT_convolution", F(EXT_convolution) }, { ON, "GL_EXT_copy_texture", F(EXT_copy_texture) }, { OFF, "GL_EXT_depth_bounds_test", F(EXT_depth_bounds_test) }, + { OFF, "GL_EXT_draw_buffers2", F(EXT_draw_buffers2) }, { ON, "GL_EXT_draw_range_elements", F(EXT_draw_range_elements) }, { OFF, "GL_EXT_framebuffer_blit", F(EXT_framebuffer_blit) }, { OFF, "GL_EXT_framebuffer_multisample", F(EXT_framebuffer_multisample) }, diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c index 44396a0491..99478f0ec4 100644 --- a/src/mesa/main/get.c +++ b/src/mesa/main/get.c @@ -7448,12 +7448,14 @@ _mesa_GetBooleanIndexedv( GLenum pname, GLuint index, GLboolean *params ) switch (pname) { case GL_BLEND: + CHECK_EXT1(EXT_draw_buffers2, "GetBooleanIndexedv"); if (index >= ctx->Const.MaxDrawBuffers) { _mesa_error(ctx, GL_INVALID_VALUE, "glGetBooleanIndexedv(index=%u), index", pname); } params[0] = INT_TO_BOOLEAN(((ctx->Color.BlendEnabled >> index) & 1)); break; case GL_COLOR_WRITEMASK: + CHECK_EXT1(EXT_draw_buffers2, "GetBooleanIndexedv"); if (index >= ctx->Const.MaxDrawBuffers) { _mesa_error(ctx, GL_INVALID_VALUE, "glGetBooleanIndexedv(index=%u), index", pname); } @@ -7481,12 +7483,14 @@ _mesa_GetIntegerIndexedv( GLenum pname, GLuint index, GLint *params ) switch (pname) { case GL_BLEND: + CHECK_EXT1(EXT_draw_buffers2, "GetIntegerIndexedv"); if (index >= ctx->Const.MaxDrawBuffers) { _mesa_error(ctx, GL_INVALID_VALUE, "glGetIntegerIndexedv(index=%u), index", pname); } params[0] = ((ctx->Color.BlendEnabled >> index) & 1); break; case GL_COLOR_WRITEMASK: + CHECK_EXT1(EXT_draw_buffers2, "GetIntegerIndexedv"); if (index >= ctx->Const.MaxDrawBuffers) { _mesa_error(ctx, GL_INVALID_VALUE, "glGetIntegerIndexedv(index=%u), index", pname); } @@ -7515,12 +7519,14 @@ _mesa_GetInteger64Indexedv( GLenum pname, GLuint index, GLint64 *params ) switch (pname) { case GL_BLEND: + CHECK_EXT1(EXT_draw_buffers2, "GetInteger64Indexedv"); if (index >= ctx->Const.MaxDrawBuffers) { _mesa_error(ctx, GL_INVALID_VALUE, "glGetInteger64Indexedv(index=%u), index", pname); } params[0] = (GLint64)(((ctx->Color.BlendEnabled >> index) & 1)); break; case GL_COLOR_WRITEMASK: + CHECK_EXT1(EXT_draw_buffers2, "GetInteger64Indexedv"); if (index >= ctx->Const.MaxDrawBuffers) { _mesa_error(ctx, GL_INVALID_VALUE, "glGetInteger64Indexedv(index=%u), index", pname); } diff --git a/src/mesa/main/get_gen.py b/src/mesa/main/get_gen.py index 18708be260..82eacf0314 100644 --- a/src/mesa/main/get_gen.py +++ b/src/mesa/main/get_gen.py @@ -1036,13 +1036,13 @@ StateVars = [ # These are queried via glGetIntegetIndexdvEXT() or glGetIntegeri_v() IndexedStateVars = [ ( "GL_BLEND", GLint, ["((ctx->Color.BlendEnabled >> index) & 1)"], - "ctx->Const.MaxDrawBuffers", None ), + "ctx->Const.MaxDrawBuffers", ["EXT_draw_buffers2"] ), ( "GL_COLOR_WRITEMASK", GLint, [ "ctx->Color.ColorMask[index][RCOMP] ? 1 : 0", "ctx->Color.ColorMask[index][GCOMP] ? 1 : 0", "ctx->Color.ColorMask[index][BCOMP] ? 1 : 0", "ctx->Color.ColorMask[index][ACOMP] ? 1 : 0" ], - "ctx->Const.MaxDrawBuffers", None ), + "ctx->Const.MaxDrawBuffers", ["EXT_draw_buffers2"] ), # XXX more to come... ] @@ -1137,11 +1137,6 @@ def EmitGetFunction(stateVars, returnType, indexed): (name, varType, state, optionalCode, extensions) = state indexMax = 0 print " case " + name + ":" - if indexMax: - print (' if (index >= %s) {' % indexMax) - print (' _mesa_error(ctx, GL_INVALID_VALUE, "gl%s(index=%%u), index", pname);' % function) - print (' }') - if extensions: if len(extensions) == 1: print (' CHECK_EXT1(%s, "%s");' % @@ -1156,6 +1151,11 @@ def EmitGetFunction(stateVars, returnType, indexed): assert len(extensions) == 4 print (' CHECK_EXT4(%s, %s, %s, %s, "%s");' % (extensions[0], extensions[1], extensions[2], extensions[3], function)) + if indexMax: + print (' if (index >= %s) {' % indexMax) + print (' _mesa_error(ctx, GL_INVALID_VALUE, "gl%s(index=%%u), index", pname);' % function) + print (' }') + conversion = ConversionFunc(varType, returnType) if optionalCode: optionalCode = string.replace(optionalCode, "CONVERSION", conversion); diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 7ef2852242..3a48c8bf00 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -2434,6 +2434,7 @@ struct gl_extensions GLboolean EXT_compiled_vertex_array; GLboolean EXT_copy_texture; GLboolean EXT_depth_bounds_test; + GLboolean EXT_draw_buffers2; GLboolean EXT_draw_range_elements; GLboolean EXT_fog_coord; GLboolean EXT_framebuffer_blit; -- cgit v1.2.3 From 802b80893943cf129039a37fb2afe26444b09332 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 30 Dec 2009 10:16:01 -0700 Subject: mesa: implement GL3 GL_NUM_EXTENSIONS query --- src/mesa/main/extensions.c | 25 +++++++++++++++++++++++++ src/mesa/main/extensions.h | 4 ++++ src/mesa/main/get.c | 12 ++++++++++++ src/mesa/main/get_gen.py | 3 +++ src/mesa/main/mtypes.h | 2 ++ 5 files changed, 46 insertions(+) (limited to 'src/mesa/main/get.c') diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c index a1561b4065..88c025ee32 100644 --- a/src/mesa/main/extensions.c +++ b/src/mesa/main/extensions.c @@ -700,3 +700,28 @@ _mesa_make_extension_string( GLcontext *ctx ) return (GLubyte *) s; } + + +/** + * Return number of enabled extensions. + */ +GLuint +_mesa_get_extension_count(GLcontext *ctx) +{ + GLuint i; + + /* only count once */ + if (!ctx->Extensions.Count) { + for (i = 0; i < Elements(default_extensions); i++) { + if (extension_enabled(ctx, i)) { + ctx->Extensions.Count++; + } + } + } + + if (0) + _mesa_debug(ctx, "%u of %d extensions enabled\n", ctx->Extensions.Count, + Elements(default_extensions)); + + return ctx->Extensions.Count; +} diff --git a/src/mesa/main/extensions.h b/src/mesa/main/extensions.h index 05ad859a27..194c2efa40 100644 --- a/src/mesa/main/extensions.h +++ b/src/mesa/main/extensions.h @@ -64,6 +64,10 @@ extern void _mesa_init_extensions(GLcontext *ctx); extern GLubyte *_mesa_make_extension_string(GLcontext *ctx); +extern GLuint +_mesa_get_extension_count(GLcontext *ctx); + + #else /** No-op */ diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c index 99478f0ec4..618b5411cc 100644 --- a/src/mesa/main/get.c +++ b/src/mesa/main/get.c @@ -1899,6 +1899,9 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params ) CHECK_EXT1(ARB_sync, "GetBooleanv"); params[0] = INT64_TO_BOOLEAN(ctx->Const.MaxServerWaitTimeout); break; + case GL_NUM_EXTENSIONS: + params[0] = INT_TO_BOOLEAN(_mesa_get_extension_count(ctx)); + break; default: _mesa_error(ctx, GL_INVALID_ENUM, "glGetBooleanv(pname=0x%x)", pname); } @@ -3734,6 +3737,9 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params ) CHECK_EXT1(ARB_sync, "GetFloatv"); params[0] = (GLfloat)(ctx->Const.MaxServerWaitTimeout); break; + case GL_NUM_EXTENSIONS: + params[0] = (GLfloat)(_mesa_get_extension_count(ctx)); + break; default: _mesa_error(ctx, GL_INVALID_ENUM, "glGetFloatv(pname=0x%x)", pname); } @@ -5569,6 +5575,9 @@ _mesa_GetIntegerv( GLenum pname, GLint *params ) CHECK_EXT1(ARB_sync, "GetIntegerv"); params[0] = INT64_TO_INT(ctx->Const.MaxServerWaitTimeout); break; + case GL_NUM_EXTENSIONS: + params[0] = _mesa_get_extension_count(ctx); + break; default: _mesa_error(ctx, GL_INVALID_ENUM, "glGetIntegerv(pname=0x%x)", pname); } @@ -7405,6 +7414,9 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params ) CHECK_EXT1(ARB_sync, "GetInteger64v"); params[0] = ctx->Const.MaxServerWaitTimeout; break; + case GL_NUM_EXTENSIONS: + params[0] = (GLint64)(_mesa_get_extension_count(ctx)); + break; default: _mesa_error(ctx, GL_INVALID_ENUM, "glGetInteger64v(pname=0x%x)", pname); } diff --git a/src/mesa/main/get_gen.py b/src/mesa/main/get_gen.py index 82eacf0314..7540661187 100644 --- a/src/mesa/main/get_gen.py +++ b/src/mesa/main/get_gen.py @@ -1030,6 +1030,9 @@ StateVars = [ # GL_ARB_sync ( "GL_MAX_SERVER_WAIT_TIMEOUT", GLint64, ["ctx->Const.MaxServerWaitTimeout"], "", ["ARB_sync"] ), + + # GL3 + ( "GL_NUM_EXTENSIONS", GLint, ["_mesa_get_extension_count(ctx)"], "", None ), ] diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 3a48c8bf00..849d1689c3 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -2512,6 +2512,8 @@ struct gl_extensions GLboolean S3_s3tc; /** The extension string */ const GLubyte *String; + /** Number of supported extensions */ + GLuint Count; }; -- cgit v1.2.3 From d4f2d6556ec0bdaf7ef07fd34fa5d8a355fe2ec0 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 5 Jan 2010 21:24:48 -0700 Subject: mesa: added GL_MAJOR_VERSION and GL_MINOR_VERSION queries New in GL 3.0. --- src/mesa/main/get.c | 24 ++++++++++++++++++++++++ src/mesa/main/get_gen.py | 2 ++ 2 files changed, 26 insertions(+) (limited to 'src/mesa/main/get.c') diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c index 618b5411cc..22cf75f79d 100644 --- a/src/mesa/main/get.c +++ b/src/mesa/main/get.c @@ -1902,6 +1902,12 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params ) case GL_NUM_EXTENSIONS: params[0] = INT_TO_BOOLEAN(_mesa_get_extension_count(ctx)); break; + case GL_MAJOR_VERSION: + params[0] = INT_TO_BOOLEAN(ctx->VersionMajor); + break; + case GL_MINOR_VERSION: + params[0] = INT_TO_BOOLEAN(ctx->VersionMinor); + break; default: _mesa_error(ctx, GL_INVALID_ENUM, "glGetBooleanv(pname=0x%x)", pname); } @@ -3740,6 +3746,12 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params ) case GL_NUM_EXTENSIONS: params[0] = (GLfloat)(_mesa_get_extension_count(ctx)); break; + case GL_MAJOR_VERSION: + params[0] = (GLfloat)(ctx->VersionMajor); + break; + case GL_MINOR_VERSION: + params[0] = (GLfloat)(ctx->VersionMinor); + break; default: _mesa_error(ctx, GL_INVALID_ENUM, "glGetFloatv(pname=0x%x)", pname); } @@ -5578,6 +5590,12 @@ _mesa_GetIntegerv( GLenum pname, GLint *params ) case GL_NUM_EXTENSIONS: params[0] = _mesa_get_extension_count(ctx); break; + case GL_MAJOR_VERSION: + params[0] = ctx->VersionMajor; + break; + case GL_MINOR_VERSION: + params[0] = ctx->VersionMinor; + break; default: _mesa_error(ctx, GL_INVALID_ENUM, "glGetIntegerv(pname=0x%x)", pname); } @@ -7417,6 +7435,12 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params ) case GL_NUM_EXTENSIONS: params[0] = (GLint64)(_mesa_get_extension_count(ctx)); break; + case GL_MAJOR_VERSION: + params[0] = (GLint64)(ctx->VersionMajor); + break; + case GL_MINOR_VERSION: + params[0] = (GLint64)(ctx->VersionMinor); + break; default: _mesa_error(ctx, GL_INVALID_ENUM, "glGetInteger64v(pname=0x%x)", pname); } diff --git a/src/mesa/main/get_gen.py b/src/mesa/main/get_gen.py index 7540661187..b0beb59207 100644 --- a/src/mesa/main/get_gen.py +++ b/src/mesa/main/get_gen.py @@ -1033,6 +1033,8 @@ StateVars = [ # GL3 ( "GL_NUM_EXTENSIONS", GLint, ["_mesa_get_extension_count(ctx)"], "", None ), + ( "GL_MAJOR_VERSION", GLint, ["ctx->VersionMajor"], "", None ), + ( "GL_MINOR_VERSION", GLint, ["ctx->VersionMinor"], "", None ) ] -- cgit v1.2.3