summaryrefslogtreecommitdiff
path: root/src/mesa/main/shaderapi.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/main/shaderapi.c')
-rw-r--r--src/mesa/main/shaderapi.c83
1 files changed, 71 insertions, 12 deletions
diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
index 96df58d35c..2c5f2a147c 100644
--- a/src/mesa/main/shaderapi.c
+++ b/src/mesa/main/shaderapi.c
@@ -41,13 +41,16 @@
#include "main/dispatch.h"
#include "main/enums.h"
#include "main/hash.h"
+#include "main/mfeatures.h"
+#include "main/mtypes.h"
#include "main/shaderapi.h"
#include "main/shaderobj.h"
#include "program/program.h"
#include "program/prog_parameter.h"
#include "program/prog_uniform.h"
-#include "talloc.h"
+#include "ralloc.h"
#include <stdbool.h>
+#include "../glsl/glsl_parser_extras.h"
/** Define this to enable shader substitution (see below) */
#define SHADER_SUBST 0
@@ -1134,9 +1137,9 @@ validate_program(struct gl_context *ctx, GLuint program)
if (!shProg->Validated) {
/* update info log */
if (shProg->InfoLog) {
- talloc_free(shProg->InfoLog);
+ ralloc_free(shProg->InfoLog);
}
- shProg->InfoLog = talloc_strdup(shProg, errMsg);
+ shProg->InfoLog = ralloc_strdup(shProg, errMsg);
}
}
@@ -1181,6 +1184,8 @@ void GLAPIENTRY
_mesa_CompileShaderARB(GLhandleARB shaderObj)
{
GET_CURRENT_CONTEXT(ctx);
+ if (MESA_VERBOSE & VERBOSE_API)
+ _mesa_debug(ctx, "glCompileShader %u\n", shaderObj);
compile_shader(ctx, shaderObj);
}
@@ -1189,6 +1194,8 @@ GLuint GLAPIENTRY
_mesa_CreateShader(GLenum type)
{
GET_CURRENT_CONTEXT(ctx);
+ if (MESA_VERBOSE & VERBOSE_API)
+ _mesa_debug(ctx, "glCreateShader %s\n", _mesa_lookup_enum_by_nr(type));
return create_shader(ctx, type);
}
@@ -1205,6 +1212,8 @@ GLuint GLAPIENTRY
_mesa_CreateProgram(void)
{
GET_CURRENT_CONTEXT(ctx);
+ if (MESA_VERBOSE & VERBOSE_API)
+ _mesa_debug(ctx, "glCreateProgram\n");
return create_shader_program(ctx);
}
@@ -1220,8 +1229,14 @@ _mesa_CreateProgramObjectARB(void)
void GLAPIENTRY
_mesa_DeleteObjectARB(GLhandleARB obj)
{
+ if (MESA_VERBOSE & VERBOSE_API) {
+ GET_CURRENT_CONTEXT(ctx);
+ _mesa_debug(ctx, "glDeleteObjectARB(%u)\n", obj);
+ }
+
if (obj) {
GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0);
if (is_program(ctx, obj)) {
delete_shader_program(ctx, obj);
}
@@ -1240,6 +1255,7 @@ _mesa_DeleteProgram(GLuint name)
{
if (name) {
GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0);
delete_shader_program(ctx, name);
}
}
@@ -1250,6 +1266,7 @@ _mesa_DeleteShader(GLuint name)
{
if (name) {
GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0);
delete_shader(ctx, name);
}
}
@@ -1625,20 +1642,58 @@ 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;
}
void GLAPIENTRY
_mesa_ReleaseShaderCompiler(void)
{
- GET_CURRENT_CONTEXT(ctx);
- _mesa_error(ctx, GL_INVALID_OPERATION, __FUNCTION__);
+ _mesa_destroy_shader_compiler_caches();
}
@@ -1677,7 +1732,7 @@ _mesa_ProgramParameteriARB(GLuint program, GLenum pname,
switch (pname) {
case GL_GEOMETRY_VERTICES_OUT_ARB:
if (value < 1 ||
- (unsigned) value > ctx->Const.GeometryProgram.MaxGeometryOutputVertices) {
+ (unsigned) value > ctx->Const.MaxGeometryOutputVertices) {
_mesa_error(ctx, GL_INVALID_VALUE,
"glProgramParameteri(GL_GEOMETRY_VERTICES_OUT_ARB=%d",
value);
@@ -1814,7 +1869,7 @@ _mesa_CreateShaderProgramEXT(GLenum type, const GLchar *string)
#endif
}
- shProg->InfoLog = talloc_strdup_append(shProg->InfoLog, sh->InfoLog);
+ ralloc_strcat(&shProg->InfoLog, sh->InfoLog);
}
delete_shader(ctx, shader);
@@ -1881,6 +1936,10 @@ _mesa_init_shader_dispatch(struct _glapi_table *exec)
SET_BindFragDataLocationEXT(exec, _mesa_BindFragDataLocation);
SET_GetFragDataLocationEXT(exec, _mesa_GetFragDataLocation);
+ /* GL_ARB_ES2_compatibility */
+ SET_ReleaseShaderCompiler(exec, _mesa_ReleaseShaderCompiler);
+ SET_GetShaderPrecisionFormat(exec, _mesa_GetShaderPrecisionFormat);
+
#endif /* FEATURE_GL */
}