diff options
Diffstat (limited to 'src/mesa/main')
-rw-r--r-- | src/mesa/main/api_validate.c | 16 | ||||
-rw-r--r-- | src/mesa/main/context.c | 10 | ||||
-rw-r--r-- | src/mesa/main/dd.h | 5 | ||||
-rw-r--r-- | src/mesa/main/debug.c | 20 | ||||
-rw-r--r-- | src/mesa/main/enums.c | 43 | ||||
-rw-r--r-- | src/mesa/main/enums.h | 2 | ||||
-rw-r--r-- | src/mesa/main/mtypes.h | 36 | ||||
-rw-r--r-- | src/mesa/main/shaderapi.c | 49 |
8 files changed, 117 insertions, 64 deletions
diff --git a/src/mesa/main/api_validate.c b/src/mesa/main/api_validate.c index ac9709db3f1..7c4652f747f 100644 --- a/src/mesa/main/api_validate.c +++ b/src/mesa/main/api_validate.c @@ -329,7 +329,7 @@ _mesa_validate_DrawArrays(struct gl_context *ctx, GLboolean _mesa_validate_DrawArraysInstanced(struct gl_context *ctx, GLenum mode, GLint first, - GLsizei count, GLsizei primcount) + GLsizei count, GLsizei numInstances) { ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); @@ -346,10 +346,10 @@ _mesa_validate_DrawArraysInstanced(struct gl_context *ctx, GLenum mode, GLint fi return GL_FALSE; } - if (primcount <= 0) { - if (primcount < 0) + if (numInstances <= 0) { + if (numInstances < 0) _mesa_error(ctx, GL_INVALID_VALUE, - "glDrawArraysInstanced(primcount=%d)", primcount); + "glDrawArraysInstanced(numInstances=%d)", numInstances); return GL_FALSE; } @@ -374,7 +374,7 @@ _mesa_validate_DrawArraysInstanced(struct gl_context *ctx, GLenum mode, GLint fi GLboolean _mesa_validate_DrawElementsInstanced(struct gl_context *ctx, GLenum mode, GLsizei count, GLenum type, - const GLvoid *indices, GLsizei primcount) + const GLvoid *indices, GLsizei numInstances) { ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); @@ -399,10 +399,10 @@ _mesa_validate_DrawElementsInstanced(struct gl_context *ctx, return GL_FALSE; } - if (primcount <= 0) { - if (primcount < 0) + if (numInstances <= 0) { + if (numInstances < 0) _mesa_error(ctx, GL_INVALID_VALUE, - "glDrawElementsInstanced(primcount=%d)", primcount); + "glDrawElementsInstanced(numInstances=%d)", numInstances); return GL_FALSE; } diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index 958ea10a422..fe370fa369b 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -526,6 +526,16 @@ init_program_limits(GLenum type, struct gl_program_constants *prog) prog->MaxNativeTemps = 0; prog->MaxNativeAddressRegs = 0; prog->MaxNativeParameters = 0; + + /* Set GLSL datatype range/precision info assuming IEEE float values. + * Drivers should override these defaults as needed. + */ + prog->MediumFloat.RangeMin = 127; + prog->MediumFloat.RangeMax = 127; + prog->MediumFloat.Precision = 23; + prog->LowFloat = prog->HighFloat = prog->MediumFloat; + /* assume ints are stored as floats for now */ + prog->LowInt = prog->MediumInt = prog->HighInt = prog->MediumFloat; } diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h index 2eede4268ca..749c30a4cc1 100644 --- a/src/mesa/main/dd.h +++ b/src/mesa/main/dd.h @@ -881,11 +881,6 @@ struct dd_function_table { */ void (*ValidateTnlModule)( struct gl_context *ctx, GLuint new_state ); - -#define PRIM_OUTSIDE_BEGIN_END (GL_POLYGON+1) -#define PRIM_INSIDE_UNKNOWN_PRIM (GL_POLYGON+2) -#define PRIM_UNKNOWN (GL_POLYGON+3) - /** * Set by the driver-supplied T&L engine. * diff --git a/src/mesa/main/debug.c b/src/mesa/main/debug.c index 79aa53585f9..a6a909b48ce 100644 --- a/src/mesa/main/debug.c +++ b/src/mesa/main/debug.c @@ -37,26 +37,6 @@ #include "texobj.h" -/** - * Primitive names - */ -const char *_mesa_prim_name[GL_POLYGON+4] = { - "GL_POINTS", - "GL_LINES", - "GL_LINE_LOOP", - "GL_LINE_STRIP", - "GL_TRIANGLES", - "GL_TRIANGLE_STRIP", - "GL_TRIANGLE_FAN", - "GL_QUADS", - "GL_QUAD_STRIP", - "GL_POLYGON", - "outside begin/end", - "inside unknown primitive", - "unknown state" -}; - - static const char * tex_target_name(GLenum tgt) { diff --git a/src/mesa/main/enums.c b/src/mesa/main/enums.c index c358fb246bc..83d7fb66c0a 100644 --- a/src/mesa/main/enums.c +++ b/src/mesa/main/enums.c @@ -29,6 +29,7 @@ #include "main/mfeatures.h" #include "main/enums.h" #include "main/imports.h" +#include "main/mtypes.h" typedef struct { size_t offset; @@ -6243,29 +6244,39 @@ const char *_mesa_lookup_enum_by_nr( int nr ) } } +/** + * Primitive names + */ +static const char *prim_names[PRIM_UNKNOWN + 1] = { + "GL_POINTS", + "GL_LINES", + "GL_LINE_LOOP", + "GL_LINE_STRIP", + "GL_TRIANGLES", + "GL_TRIANGLE_STRIP", + "GL_TRIANGLE_FAN", + "GL_QUADS", + "GL_QUAD_STRIP", + "GL_POLYGON", + "outside begin/end", + "inside unknown primitive", + "unknown state" +}; + + /* Get the name of an enum given that it is a primitive type. Avoids * GL_FALSE/GL_POINTS ambiguity and others. */ -const char *_mesa_lookup_prim_by_nr( int nr ) +const char * +_mesa_lookup_prim_by_nr(unsigned nr) { - switch (nr) { - case GL_POINTS: return "GL_POINTS"; - case GL_LINES: return "GL_LINES"; - case GL_LINE_STRIP: return "GL_LINE_STRIP"; - case GL_LINE_LOOP: return "GL_LINE_LOOP"; - case GL_TRIANGLES: return "GL_TRIANGLES"; - case GL_TRIANGLE_STRIP: return "GL_TRIANGLE_STRIP"; - case GL_TRIANGLE_FAN: return "GL_TRIANGLE_FAN"; - case GL_QUADS: return "GL_QUADS"; - case GL_QUAD_STRIP: return "GL_QUAD_STRIP"; - case GL_POLYGON: return "GL_POLYGON"; - case GL_POLYGON+1: return "OUTSIDE_BEGIN_END"; - default: return "<invalid>"; - } + if (nr < Elements(prim_names)) + return prim_names[nr]; + else + return "invalid mode"; } - int _mesa_lookup_enum_by_name( const char *symbol ) { enum_elt * f = NULL; diff --git a/src/mesa/main/enums.h b/src/mesa/main/enums.h index c03cd34da92..7733df22f91 100644 --- a/src/mesa/main/enums.h +++ b/src/mesa/main/enums.h @@ -45,7 +45,7 @@ extern const char *_mesa_lookup_enum_by_nr( int nr ); /* Get the name of an enum given that it is a primitive type. Avoids * GL_FALSE/GL_POINTS ambiguity and others. */ -const char *_mesa_lookup_prim_by_nr( int nr ); +const char *_mesa_lookup_prim_by_nr( unsigned nr ); extern int _mesa_lookup_enum_by_name( const char *symbol ); diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index a6445b18368..49dad4d4024 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -121,6 +121,11 @@ struct st_context; /*@}*/ +/** Extra draw modes beyond GL_POINTS, GL_TRIANGLE_FAN, etc */ +#define PRIM_OUTSIDE_BEGIN_END (GL_POLYGON+1) +#define PRIM_INSIDE_UNKNOWN_PRIM (GL_POLYGON+2) +#define PRIM_UNKNOWN (GL_POLYGON+3) + /** * Shader stages. Note that these will become 5 with tessellation. @@ -296,8 +301,8 @@ typedef enum /** * Indexes for geometry program result attributes */ -/*@{*/ -typedef enum { +typedef enum +{ GEOM_RESULT_POS = 0, GEOM_RESULT_COL0 = 1, GEOM_RESULT_COL1 = 2, @@ -320,7 +325,7 @@ typedef enum { /* ### we need to -2 because var0 is 18 instead 16 like in the others */ GEOM_RESULT_MAX = (GEOM_RESULT_VAR0 + MAX_VARYING - 2) } gl_geom_result; -/*@}*/ + /** * Indexes for fragment program input attributes. @@ -1322,7 +1327,7 @@ struct gl_texture_object GLboolean _Complete; /**< Is texture object complete? */ GLboolean _RenderToTexture; /**< Any rendering to this texture? */ GLboolean Purgeable; /**< Is the buffer purgeable under memory pressure? */ - GLenum sRGBDecode; + GLenum sRGBDecode; /**< GL_DECODE_EXT or GL_SKIP_DECODE_EXT */ /** Actual texture images, indexed by [cube face] and [mipmap level] */ struct gl_texture_image *Image[MAX_FACES][MAX_TEXTURE_LEVELS]; @@ -2549,6 +2554,17 @@ struct gl_framebuffer /** + * Precision info for shader datatypes. See glGetShaderPrecisionFormat(). + */ +struct gl_precision +{ + GLushort RangeMin; /**< min value exponent */ + GLushort RangeMax; /**< max value exponent */ + GLushort Precision; /**< number of mantissa bits */ +}; + + +/** * Limits for vertex and fragment programs/shaders. */ struct gl_program_constants @@ -2582,6 +2598,9 @@ struct gl_program_constants GLuint MaxGeometryUniformComponents; GLuint MaxGeometryOutputVertices; GLuint MaxGeometryTotalOutputComponents; + /* ES 2.0 and GL_ARB_ES2_compatibility */ + struct gl_precision LowFloat, MediumFloat, HighFloat; + struct gl_precision LowInt, MediumInt, HighInt; }; @@ -3074,15 +3093,18 @@ struct gl_dlist_state } Current; }; + /** * Enum for the OpenGL APIs we know about and may support. */ -typedef enum { +typedef enum +{ API_OPENGL, API_OPENGLES, API_OPENGLES2 } gl_api; + /** * Mesa rendering context. * @@ -3295,10 +3317,6 @@ struct gl_context }; -/** The string names for GL_POINT, GL_LINE_LOOP, etc */ -extern const char *_mesa_prim_name[GL_POLYGON+4]; - - #ifdef DEBUG extern int MESA_VERBOSE; extern int MESA_DEBUG_FLAGS; diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c index 2ffd8be0eb4..e831175235e 100644 --- a/src/mesa/main/shaderapi.c +++ b/src/mesa/main/shaderapi.c @@ -1628,12 +1628,51 @@ void GLAPIENTRY _mesa_GetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision) { + const struct gl_program_constants *limits; + const struct gl_precision *p; GET_CURRENT_CONTEXT(ctx); - (void) shadertype; - (void) precisiontype; - (void) range; - (void) precision; - _mesa_error(ctx, GL_INVALID_OPERATION, __FUNCTION__); + + switch (shadertype) { + case GL_VERTEX_SHADER: + limits = &ctx->Const.VertexProgram; + break; + case GL_FRAGMENT_SHADER: + limits = &ctx->Const.FragmentProgram; + break; + default: + _mesa_error(ctx, GL_INVALID_ENUM, + "glGetShaderPrecisionFormat(shadertype)"); + return; + } + + switch (precisiontype) { + case GL_LOW_FLOAT: + p = &limits->LowFloat; + break; + case GL_MEDIUM_FLOAT: + p = &limits->MediumFloat; + break; + case GL_HIGH_FLOAT: + p = &limits->HighFloat; + break; + case GL_LOW_INT: + p = &limits->LowInt; + break; + case GL_MEDIUM_INT: + p = &limits->MediumInt; + break; + case GL_HIGH_INT: + p = &limits->HighInt; + break; + default: + _mesa_error(ctx, GL_INVALID_ENUM, + "glGetShaderPrecisionFormat(precisiontype)"); + return; + } + + range[0] = p->RangeMin; + range[1] = p->RangeMax; + precision[0] = p->Precision; } |