diff options
author | José Fonseca <jfonseca@vmware.com> | 2009-03-03 13:18:15 +0000 |
---|---|---|
committer | José Fonseca <jfonseca@vmware.com> | 2009-03-03 13:18:15 +0000 |
commit | c7e46c1857b744a35c086dddb651f38df948a5fa (patch) | |
tree | 6d984aea871340574cd7286c11a53a7b9b094f81 /src/mesa/main | |
parent | 97a1fd158c9acfaa3a8deda7eb5bf0b253e85c15 (diff) | |
parent | dceb09909ea9d6eaef0334897ebed6da45db6faa (diff) |
Merge commit 'origin/master' into gallium-map-range
Diffstat (limited to 'src/mesa/main')
-rw-r--r-- | src/mesa/main/api_validate.c | 15 | ||||
-rw-r--r-- | src/mesa/main/buffers.c | 12 | ||||
-rw-r--r-- | src/mesa/main/config.h | 2 | ||||
-rw-r--r-- | src/mesa/main/dd.h | 32 | ||||
-rw-r--r-- | src/mesa/main/debug.c | 22 | ||||
-rw-r--r-- | src/mesa/main/enable.c | 5 | ||||
-rw-r--r-- | src/mesa/main/mtypes.h | 33 | ||||
-rw-r--r-- | src/mesa/main/state.c | 2 | ||||
-rw-r--r-- | src/mesa/main/stencil.c | 6 | ||||
-rw-r--r-- | src/mesa/main/texstate.c | 75 | ||||
-rw-r--r-- | src/mesa/main/vtxfmt.c | 9 |
11 files changed, 133 insertions, 80 deletions
diff --git a/src/mesa/main/api_validate.c b/src/mesa/main/api_validate.c index 5c8955d7c8..42d1e579e0 100644 --- a/src/mesa/main/api_validate.c +++ b/src/mesa/main/api_validate.c @@ -87,11 +87,20 @@ check_valid_to_render(GLcontext *ctx, char *function) return GL_FALSE; } - /* Always need vertex positions, unless a vertex program is in use */ - if (!ctx->VertexProgram._Current && - !ctx->Array.ArrayObj->Vertex.Enabled && +#if FEATURE_es2_glsl + /* For ES2, we can draw if any vertex array is enabled (and we should + * always have a vertex program/shader). + */ + if (ctx->Array.ArrayObj->_Enabled == 0x0 || !ctx->VertexProgram._Current) + return GL_FALSE; +#else + /* For regular OpenGL, only draw if we have vertex positions (regardless + * of whether or not we have a vertex program/shader). + */ + if (!ctx->Array.ArrayObj->Vertex.Enabled && !ctx->Array.ArrayObj->VertexAttrib[0].Enabled) return GL_FALSE; +#endif return GL_TRUE; } diff --git a/src/mesa/main/buffers.c b/src/mesa/main/buffers.c index 85db3868c4..1580487ffd 100644 --- a/src/mesa/main/buffers.c +++ b/src/mesa/main/buffers.c @@ -119,12 +119,6 @@ draw_buffer_enum_to_bitmask(GLenum buffer) return BUFFER_BIT_FRONT_LEFT; case GL_AUX0: return BUFFER_BIT_AUX0; - case GL_AUX1: - return BUFFER_BIT_AUX1; - case GL_AUX2: - return BUFFER_BIT_AUX2; - case GL_AUX3: - return BUFFER_BIT_AUX3; case GL_COLOR_ATTACHMENT0_EXT: return BUFFER_BIT_COLOR0; case GL_COLOR_ATTACHMENT1_EXT: @@ -176,12 +170,6 @@ read_buffer_enum_to_index(GLenum buffer) return BUFFER_FRONT_LEFT; case GL_AUX0: return BUFFER_AUX0; - case GL_AUX1: - return BUFFER_AUX1; - case GL_AUX2: - return BUFFER_AUX2; - case GL_AUX3: - return BUFFER_AUX3; case GL_COLOR_ATTACHMENT0_EXT: return BUFFER_COLOR0; case GL_COLOR_ATTACHMENT1_EXT: diff --git a/src/mesa/main/config.h b/src/mesa/main/config.h index bb3e980bfa..282ad9514c 100644 --- a/src/mesa/main/config.h +++ b/src/mesa/main/config.h @@ -68,7 +68,7 @@ #define MAX_PIXEL_MAP_TABLE 256 /** Maximum number of auxillary color buffers */ -#define MAX_AUX_BUFFERS 4 +#define MAX_AUX_BUFFERS 1 /** Maximum order (degree) of curves */ #ifdef AMIGA diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h index 411b6a7b21..a335f77479 100644 --- a/src/mesa/main/dd.h +++ b/src/mesa/main/dd.h @@ -36,6 +36,22 @@ struct gl_pixelstore_attrib; struct gl_display_list; +#if FEATURE_ARB_vertex_buffer_object +/* Modifies GL_MAP_UNSYNCHRONIZED_BIT to allow driver to fail (return + * NULL) if buffer is unavailable for immediate mapping. + * + * Does GL_MAP_INVALIDATE_RANGE_BIT do this? It seems so, but it + * would require more book-keeping in the driver than seems necessary + * at this point. + * + * Does GL_MAP_INVALDIATE_BUFFER_BIT do this? Not really -- we don't + * want to provoke the driver to throw away the old storage, we will + * respect the contents of already referenced data. + */ +#define MESA_MAP_NOWAIT_BIT 0x0040 +#endif + + /** * Device driver function table. * Core Mesa uses these function pointers to call into device drivers. @@ -785,6 +801,16 @@ struct dd_function_table { void * (*MapBuffer)( GLcontext *ctx, GLenum target, GLenum access, struct gl_buffer_object *obj ); + /* May return NULL if MESA_MAP_NOWAIT_BIT is set in access: + */ + void * (*MapBufferRange)( GLcontext *ctx, GLenum target, + GLintptr offset, GLsizeiptr length, GLbitfield access, + struct gl_buffer_object *obj); + + void (*FlushMappedBufferRange) (GLcontext *ctx, GLenum target, + GLintptr offset, GLsizeiptr length, + struct gl_buffer_object *obj); + GLboolean (*UnmapBuffer)( GLcontext *ctx, GLenum target, struct gl_buffer_object *obj ); /*@}*/ @@ -954,6 +980,12 @@ struct dd_function_table { GLuint NeedFlush; GLuint SaveNeedFlush; + + /* Called prior to any of the GLvertexformat functions being + * called. Paired with Driver.FlushVertices(). + */ + void (*BeginVertices)( GLcontext *ctx ); + /** * If inside glBegin()/glEnd(), it should ASSERT(0). Otherwise, if * FLUSH_STORED_VERTICES bit in \p flags is set flushes any buffered diff --git a/src/mesa/main/debug.c b/src/mesa/main/debug.c index fcef093ac3..fdd10dd307 100644 --- a/src/mesa/main/debug.c +++ b/src/mesa/main/debug.c @@ -23,6 +23,7 @@ */ #include "mtypes.h" +#include "colormac.h" #include "context.h" #include "hash.h" #include "imports.h" @@ -274,6 +275,27 @@ write_texture_image(struct gl_texture_object *texObj) case MESA_FORMAT_ARGB8888: write_ppm(s, img->Data, img->Width, img->Height, 4, 2, 1, 0); break; + case MESA_FORMAT_RGB888: + write_ppm(s, img->Data, img->Width, img->Height, 3, 2, 1, 0); + break; + case MESA_FORMAT_RGB565: + { + GLubyte *buf2 = (GLubyte *) _mesa_malloc(img->Width * img->Height * 3); + GLint i; + for (i = 0; i < img->Width * img->Height; i++) { + GLint r, g, b; + GLushort s = ((GLushort *) img->Data)[i]; + r = UBYTE_TO_CHAN( ((s >> 8) & 0xf8) | ((s >> 13) & 0x7) ); + g = UBYTE_TO_CHAN( ((s >> 3) & 0xfc) | ((s >> 9) & 0x3) ); + b = UBYTE_TO_CHAN( ((s << 3) & 0xf8) | ((s >> 2) & 0x7) ); + buf2[i*3+1] = r; + buf2[i*3+2] = g; + buf2[i*3+3] = b; + } + write_ppm(s, buf2, img->Width, img->Height, 3, 2, 1, 0); + _mesa_free(buf2); + } + break; default: printf("XXXX unsupported mesa tex format %d in %s\n", img->TexFormat->MesaFormat, __FUNCTION__); diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c index 7ff3b15c84..a824705bdc 100644 --- a/src/mesa/main/enable.c +++ b/src/mesa/main/enable.c @@ -602,11 +602,6 @@ _mesa_set_enable(GLcontext *ctx, GLenum cap, GLboolean state) ctx->Texture.SharedPalette = state; break; case GL_STENCIL_TEST: - if (state && ctx->DrawBuffer->Visual.stencilBits == 0) { - _mesa_warning(ctx, - "glEnable(GL_STENCIL_TEST) but no stencil buffer"); - return; - } if (ctx->Stencil.Enabled == state) return; FLUSH_VERTICES(ctx, _NEW_STENCIL); diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index f17b9e1e71..f906de8357 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -285,14 +285,11 @@ typedef enum BUFFER_BACK_LEFT, BUFFER_FRONT_RIGHT, BUFFER_BACK_RIGHT, - /* optional aux buffers */ - BUFFER_AUX0, - BUFFER_AUX1, - BUFFER_AUX2, - BUFFER_AUX3, BUFFER_DEPTH, BUFFER_STENCIL, BUFFER_ACCUM, + /* optional aux buffer */ + BUFFER_AUX0, /* generic renderbuffers */ BUFFER_COLOR0, BUFFER_COLOR1, @@ -336,9 +333,6 @@ typedef enum BUFFER_BIT_FRONT_RIGHT | \ BUFFER_BIT_BACK_RIGHT | \ BUFFER_BIT_AUX0 | \ - BUFFER_BIT_AUX1 | \ - BUFFER_BIT_AUX2 | \ - BUFFER_BIT_AUX3 | \ BUFFER_BIT_COLOR0 | \ BUFFER_BIT_COLOR1 | \ BUFFER_BIT_COLOR2 | \ @@ -1018,6 +1012,7 @@ struct gl_stencil_attrib GLboolean Enabled; /**< Enabled flag */ GLboolean TestTwoSide; /**< GL_EXT_stencil_two_side */ GLubyte ActiveFace; /**< GL_EXT_stencil_two_side (0 or 2) */ + GLboolean _Enabled; /**< Enabled and stencil buffer present */ GLboolean _TestTwoSide; GLubyte _BackFace; /**< Current back stencil state (1 or 2) */ GLenum Function[3]; /**< Stencil function */ @@ -1446,14 +1441,20 @@ struct gl_texture_attrib GLboolean SharedPalette; struct gl_color_table Palette; - /** Per-unit flags */ - /*@{*/ - GLbitfield _EnabledUnits; /**< one bit set for each really-enabled unit */ - GLbitfield _EnabledCoordUnits; /**< one bit per enabled coordinate unit */ - GLbitfield _GenFlags; /**< for texgen */ - GLbitfield _TexGenEnabled; /**< Mask of ENABLE_TEXGEN flags */ - GLbitfield _TexMatEnabled; /**< Mask of ENABLE_TEXMAT flags */ - /*@}*/ + /** Texture units/samplers used by vertex or fragment texturing */ + GLbitfield _EnabledUnits; + + /** Texture coord units/sets used for fragment texturing */ + GLbitfield _EnabledCoordUnits; + + /** Texture coord units that have texgen enabled */ + GLbitfield _TexGenEnabled; + + /** Texture coord units that have non-identity matrices */ + GLbitfield _TexMatEnabled; + + /** Bitwise-OR of all Texture.Unit[i]._GenFlags */ + GLbitfield _GenFlags; }; diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c index 0a39279bff..9ea932ea96 100644 --- a/src/mesa/main/state.c +++ b/src/mesa/main/state.c @@ -490,7 +490,7 @@ _mesa_update_state_locked( GLcontext *ctx ) if (new_state & _NEW_LIGHT) _mesa_update_lighting( ctx ); - if (new_state & _NEW_STENCIL) + if (new_state & (_NEW_STENCIL | _NEW_BUFFERS)) _mesa_update_stencil( ctx ); #if FEATURE_pixel_transfer diff --git a/src/mesa/main/stencil.c b/src/mesa/main/stencil.c index e4a255d0a7..15c98e2015 100644 --- a/src/mesa/main/stencil.c +++ b/src/mesa/main/stencil.c @@ -536,7 +536,11 @@ _mesa_update_stencil(GLcontext *ctx) { const GLint face = ctx->Stencil._BackFace; - ctx->Stencil._TestTwoSide = + ctx->Stencil._Enabled = (ctx->Stencil.Enabled && + ctx->DrawBuffer->Visual.stencilBits > 0); + + ctx->Stencil._TestTwoSide = + ctx->Stencil._Enabled && (ctx->Stencil.Function[0] != ctx->Stencil.Function[face] || ctx->Stencil.FailFunc[0] != ctx->Stencil.FailFunc[face] || ctx->Stencil.ZPassFunc[0] != ctx->Stencil.ZPassFunc[face] || diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c index e25c9e732c..2b07da805c 100644 --- a/src/mesa/main/texstate.c +++ b/src/mesa/main/texstate.c @@ -385,28 +385,6 @@ update_texture_compare_function(GLcontext *ctx, /** - * Helper function for determining which texture object (1D, 2D, cube, etc) - * should actually be used. - */ -static void -texture_override(GLcontext *ctx, - struct gl_texture_unit *texUnit, GLbitfield enableBits, - struct gl_texture_object *texObj, GLuint textureBit) -{ - if (!texUnit->_ReallyEnabled && (enableBits & textureBit)) { - if (!texObj->_Complete) { - _mesa_test_texobj_completeness(ctx, texObj); - } - if (texObj->_Complete) { - texUnit->_ReallyEnabled = textureBit; - texUnit->_Current = texObj; - update_texture_compare_function(ctx, texObj); - } - } -} - - -/** * Examine texture unit's combine/env state to update derived state. */ static void @@ -514,6 +492,7 @@ update_texture_state( GLcontext *ctx ) GLuint unit; struct gl_fragment_program *fprog = NULL; struct gl_vertex_program *vprog = NULL; + GLbitfield enabledFragUnits = 0x0; if (ctx->Shader.CurrentProgram && ctx->Shader.CurrentProgram->LinkStatus) { @@ -545,44 +524,60 @@ update_texture_state( GLcontext *ctx ) */ for (unit = 0; unit < ctx->Const.MaxTextureImageUnits; unit++) { struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit]; - GLbitfield enableBits; + GLbitfield enabledVertTargets = 0x0; + GLbitfield enabledFragTargets = 0x0; + GLbitfield enabledTargets = 0x0; GLuint texIndex; - texUnit->_Current = NULL; - texUnit->_ReallyEnabled = 0x0; - /* Get the bitmask of texture target enables. * enableBits will be a mask of the TEXTURE_*_BIT flags indicating * which texture targets are enabled (fixed function) or referenced * by a fragment shader/program. When multiple flags are set, we'll - * settle on the one with highest priority (see texture_override below). + * settle on the one with highest priority (see below). */ - enableBits = 0x0; if (vprog) { - enableBits |= vprog->Base.TexturesUsed[unit]; + enabledVertTargets |= vprog->Base.TexturesUsed[unit]; } + if (fprog) { - enableBits |= fprog->Base.TexturesUsed[unit]; + enabledFragTargets |= fprog->Base.TexturesUsed[unit]; } else { /* fixed-function fragment program */ - enableBits |= texUnit->Enabled; + enabledFragTargets |= texUnit->Enabled; } - if (enableBits == 0x0) + enabledTargets = enabledVertTargets | enabledFragTargets; + + texUnit->_ReallyEnabled = 0x0; + + if (enabledTargets == 0x0) { + /* neither vertex nor fragment processing uses this unit */ continue; + } - /* Look for the highest-priority texture target that's enabled and - * complete. That's the one we'll use for texturing. If we're using - * a fragment program we're guaranteed that bitcount(enabledBits) <= 1. + /* Look for the highest priority texture target that's enabled (or used + * by the vert/frag shaders) and "complete". That's the one we'll use + * for texturing. If we're using vert/frag program we're guaranteed + * that bitcount(enabledBits) <= 1. * Note that the TEXTURE_x_INDEX values are in high to low priority. */ for (texIndex = 0; texIndex < NUM_TEXTURE_TARGETS; texIndex++) { - texture_override(ctx, texUnit, enableBits, - texUnit->CurrentTex[texIndex], 1 << texIndex); + if (enabledTargets & (1 << texIndex)) { + struct gl_texture_object *texObj = texUnit->CurrentTex[texIndex]; + if (!texObj->_Complete) { + _mesa_test_texobj_completeness(ctx, texObj); + } + if (texObj->_Complete) { + texUnit->_ReallyEnabled = 1 << texIndex; + _mesa_reference_texobj(&texUnit->_Current, texObj); + break; + } + } } if (!texUnit->_ReallyEnabled) { + _mesa_reference_texobj(&texUnit->_Current, NULL); continue; } @@ -590,7 +585,11 @@ update_texture_state( GLcontext *ctx ) ctx->Texture._EnabledUnits |= (1 << unit); + if (enabledFragTargets) + enabledFragUnits |= (1 << unit); + update_tex_combine(ctx, texUnit); + update_texture_compare_function(ctx, texUnit->_Current); } @@ -601,7 +600,7 @@ update_texture_state( GLcontext *ctx ) = (fprog->Base.InputsRead >> FRAG_ATTRIB_TEX0) & coordMask; } else { - ctx->Texture._EnabledCoordUnits = ctx->Texture._EnabledUnits; + ctx->Texture._EnabledCoordUnits = enabledFragUnits; } /* Setup texgen for those texture coordinate sets that are in use */ diff --git a/src/mesa/main/vtxfmt.c b/src/mesa/main/vtxfmt.c index 0204979003..1f807dc3dc 100644 --- a/src/mesa/main/vtxfmt.c +++ b/src/mesa/main/vtxfmt.c @@ -54,9 +54,12 @@ ASSERT( tnl->Current ); \ ASSERT( tnl->SwapCount < NUM_VERTEX_FORMAT_ENTRIES ); \ ASSERT( tmp_offset >= 0 ); \ - \ - /* Save the swapped function's dispatch entry so it can be */ \ - /* restored later. */ \ + \ + if (tnl->SwapCount == 0) \ + ctx->Driver.BeginVertices( ctx ); \ + \ + /* Save the swapped function's dispatch entry so it can be */ \ + /* restored later. */ \ tnl->Swapped[tnl->SwapCount].location = & (((_glapi_proc *)ctx->Exec)[tmp_offset]); \ tnl->Swapped[tnl->SwapCount].function = (_glapi_proc)TAG(FUNC); \ tnl->SwapCount++; \ |