diff options
author | Brian <[email protected]> | 2007-01-04 08:21:09 -0700 |
---|---|---|
committer | Brian <[email protected]> | 2007-01-04 08:21:09 -0700 |
commit | 439758353aea3ede1f6d7fc1be14777df8697db5 (patch) | |
tree | b11a21fff74cc918df93ef08d215cc0253cbfc2b | |
parent | d8babcfc570ef97b284f88f01151f00eb188a2fd (diff) |
Fix some incorrect GL error values. Reorganize _mesa_compile_shader() code.
-rw-r--r-- | src/mesa/shader/shader_api.c | 49 | ||||
-rw-r--r-- | src/mesa/shader/slang/library/slang_core.gc | 1 | ||||
-rw-r--r-- | src/mesa/shader/slang/slang_compile.c | 94 | ||||
-rw-r--r-- | src/mesa/shader/slang/slang_compile.h | 2 |
4 files changed, 81 insertions, 65 deletions
diff --git a/src/mesa/shader/shader_api.c b/src/mesa/shader/shader_api.c index 1e282e7373a..5af236cfff5 100644 --- a/src/mesa/shader/shader_api.c +++ b/src/mesa/shader/shader_api.c @@ -240,7 +240,7 @@ _mesa_attach_shader(GLcontext *ctx, GLuint program, GLuint shader) GLuint i; if (!shProg || !sh) { - _mesa_error(ctx, GL_INVALID_OPERATION, + _mesa_error(ctx, GL_INVALID_VALUE, "glAttachShader(bad program or shader name)"); return; } @@ -277,7 +277,7 @@ _mesa_bind_attrib_location(GLcontext *ctx, GLuint program, GLuint index, = _mesa_lookup_shader_program(ctx, program); if (!shProg) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glBindAttribLocation(program)"); + _mesa_error(ctx, GL_INVALID_VALUE, "glBindAttribLocation(program)"); return; } @@ -348,7 +348,7 @@ _mesa_delete_program2(GLcontext *ctx, GLuint name) shProg = _mesa_lookup_shader_program(ctx, name); if (!shProg) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glDeleteProgram(name)"); + _mesa_error(ctx, GL_INVALID_VALUE, "glDeleteProgram(name)"); return; } @@ -390,7 +390,7 @@ _mesa_detach_shader(GLcontext *ctx, GLuint program, GLuint shader) GLuint i, j; if (!shProg) { - _mesa_error(ctx, GL_INVALID_OPERATION, + _mesa_error(ctx, GL_INVALID_VALUE, "glDetachShader(bad program or shader name)"); return; } @@ -424,7 +424,7 @@ _mesa_detach_shader(GLcontext *ctx, GLuint program, GLuint shader) } /* not found */ - _mesa_error(ctx, GL_INVALID_OPERATION, + _mesa_error(ctx, GL_INVALID_VALUE, "glDetachShader(shader not found)"); } @@ -442,7 +442,7 @@ _mesa_get_active_attrib(GLcontext *ctx, GLuint program, GLuint index, GLint sz; if (!shProg) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glGetActiveUniform"); + _mesa_error(ctx, GL_INVALID_VALUE, "glGetActiveUniform"); return; } @@ -477,7 +477,7 @@ _mesa_get_active_uniform(GLcontext *ctx, GLuint program, GLuint index, GLint sz; if (!shProg) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glGetActiveUniform"); + _mesa_error(ctx, GL_INVALID_VALUE, "glGetActiveUniform"); return; } @@ -514,7 +514,7 @@ _mesa_get_attached_shaders(GLcontext *ctx, GLuint program, GLsizei maxCount, *count = i; } else { - _mesa_error(ctx, GL_INVALID_OPERATION, "glGetAttachedShaders"); + _mesa_error(ctx, GL_INVALID_VALUE, "glGetAttachedShaders"); } } @@ -527,7 +527,7 @@ _mesa_get_attrib_location(GLcontext *ctx, GLuint program, = _mesa_lookup_shader_program(ctx, program); if (!shProg) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glGetAttribLocation"); + _mesa_error(ctx, GL_INVALID_VALUE, "glGetAttribLocation"); return -1; } @@ -720,7 +720,7 @@ _mesa_get_uniformfv(GLcontext *ctx, GLuint program, GLint location, } } else { - _mesa_error(ctx, GL_INVALID_OPERATION, "glGetUniformfv(program)"); + _mesa_error(ctx, GL_INVALID_VALUE, "glGetUniformfv(program)"); } } @@ -796,34 +796,13 @@ void _mesa_compile_shader(GLcontext *ctx, GLuint shaderObj) { struct gl_shader *sh = _mesa_lookup_shader(ctx, shaderObj); - slang_info_log info_log; - slang_code_object obj; - slang_unit_type type; if (!sh) { _mesa_error(ctx, GL_INVALID_VALUE, "glCompileShader(shaderObj)"); return; } - slang_info_log_construct(&info_log); - _slang_code_object_ctr(&obj); - - if (sh->Type == GL_VERTEX_SHADER) { - type = slang_unit_vertex_shader; - } - else { - assert(sh->Type == GL_FRAGMENT_SHADER); - type = slang_unit_fragment_shader; - } - - if (_slang_compile(sh->Source, &obj, type, &info_log, sh)) { - sh->CompileStatus = GL_TRUE; - } - else { - sh->CompileStatus = GL_FALSE; - /* XXX temporary */ - _mesa_problem(ctx, "Program did not compile!"); - } + sh->CompileStatus = _slang_compile(ctx, sh); } @@ -837,7 +816,7 @@ _mesa_link_program(GLcontext *ctx, GLuint program) shProg = _mesa_lookup_shader_program(ctx, program); if (!shProg) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glLinkProgram(program)"); + _mesa_error(ctx, GL_INVALID_VALUE, "glLinkProgram(program)"); return; } @@ -865,7 +844,7 @@ _mesa_use_program(GLcontext *ctx, GLuint program) struct gl_shader_program *shProg; shProg = _mesa_lookup_shader_program(ctx, program); if (!shProg) { - _mesa_error(ctx, GL_INVALID_OPERATION, + _mesa_error(ctx, GL_INVALID_VALUE, "glUseProgramObjectARB(programObj)"); return; } @@ -975,7 +954,7 @@ _mesa_validate_program(GLcontext *ctx, GLuint program) struct gl_shader_program *shProg; shProg = _mesa_lookup_shader_program(ctx, program); if (!shProg) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glValidateProgram(program)"); + _mesa_error(ctx, GL_INVALID_VALUE, "glValidateProgram(program)"); return; } /* XXX temporary */ diff --git a/src/mesa/shader/slang/library/slang_core.gc b/src/mesa/shader/slang/library/slang_core.gc index 30fea370e36..f8ee17eedaa 100644 --- a/src/mesa/shader/slang/library/slang_core.gc +++ b/src/mesa/shader/slang/library/slang_core.gc @@ -452,7 +452,6 @@ ivec4 __operator / (const ivec4 v, const ivec4 u) float __operator + (const float a, const float b) { -// __asm float_add __retVal, a, b; __asm vec4_add __retVal.x, a, b; } diff --git a/src/mesa/shader/slang/slang_compile.c b/src/mesa/shader/slang/slang_compile.c index 286e25d54bd..da77de709c3 100644 --- a/src/mesa/shader/slang/slang_compile.c +++ b/src/mesa/shader/slang/slang_compile.c @@ -682,7 +682,7 @@ parse_type_specifier(slang_parse_ctx * C, slang_output_ctx * O, stru = slang_struct_scope_find(O->structs, a_name, 1); if (stru == NULL) { - slang_info_log_error(C->L, "%s: undeclared type name.", + slang_info_log_error(C->L, "undeclared type name '%s'", slang_atom_pool_id(C->atoms, a_name)); return 0; } @@ -714,7 +714,9 @@ parse_fully_specified_type(slang_parse_ctx * C, slang_output_ctx * O, { if (!parse_type_qualifier(C, &type->qualifier)) return 0; - return parse_type_specifier(C, O, &type->specifier); + if (!parse_type_specifier(C, O, &type->specifier)) + return 0; + return 1; } /* operation */ @@ -2241,35 +2243,21 @@ slang_create_uniforms(const slang_export_data_table *exports, #endif -GLboolean -_slang_compile(const char *source, slang_code_object * object, +static GLboolean +compile_shader(GLcontext *ctx, slang_code_object * object, slang_unit_type type, slang_info_log * infolog, struct gl_shader *shader) { - GET_CURRENT_CONTEXT(ctx); - struct gl_program *program; + struct gl_program *program = shader->Programs[0]; GLboolean success; grammar id = 0; - /* XXX temporary hack */ - if (!shader->Programs) { - GLenum progTarget; - if (shader->Type == GL_VERTEX_SHADER) - progTarget = GL_VERTEX_PROGRAM_ARB; - else - progTarget = GL_FRAGMENT_PROGRAM_ARB; - shader->Programs - = (struct gl_program **) malloc(sizeof(struct gl_program*)); - shader->Programs[0] = _mesa_new_program(ctx, progTarget, 1); - shader->NumPrograms = 1; - } - program = shader->Programs[0]; assert(program); _slang_code_object_dtr(object); _slang_code_object_ctr(object); - success = compile_object(&id, source, object, type, infolog, program); + success = compile_object(&id, shader->Source, object, type, infolog, program); if (id != 0) grammar_destroy(id); if (!success) @@ -2283,22 +2271,72 @@ _slang_compile(const char *source, slang_code_object * object, #if NEW_SLANG { - GET_CURRENT_CONTEXT(ctx); slang_create_uniforms(&object->expdata, shader); _mesa_print_program(program); _mesa_print_program_parameters(ctx, program); } #endif + return GL_TRUE; +} -#if defined(USE_X86_ASM) || defined(SLANG_X86) - /* XXX: lookup the @main label */ - if (!_slang_x86_codegen - (&object->machine, &object->assembly, - object->expcode.entries[0].address)) - return GL_FALSE; + + +GLboolean +_slang_compile(GLcontext *ctx, struct gl_shader *shader) +{ + GLboolean success; + slang_info_log info_log; + slang_code_object obj; + slang_unit_type type; + + if (shader->Type == GL_VERTEX_SHADER) { + type = slang_unit_vertex_shader; + } + else { + assert(shader->Type == GL_FRAGMENT_SHADER); + type = slang_unit_fragment_shader; + } + + /* XXX temporary hack */ + if (!shader->Programs) { + GLenum progTarget; + if (shader->Type == GL_VERTEX_SHADER) + progTarget = GL_VERTEX_PROGRAM_ARB; + else + progTarget = GL_FRAGMENT_PROGRAM_ARB; + shader->Programs + = (struct gl_program **) malloc(sizeof(struct gl_program*)); + shader->Programs[0] = _mesa_new_program(ctx, progTarget, 1); + shader->NumPrograms = 1; + } + + slang_info_log_construct(&info_log); + _slang_code_object_ctr(&obj); + + success = compile_shader(ctx, &obj, type, &info_log, shader); + + if (success) { +#if 0 + slang_create_uniforms(&object->expdata, shader); + _mesa_print_program(program); + _mesa_print_program_parameters(ctx, program); #endif + } + else { + /* XXX more work on info log needed here */ + if (info_log.text) { + if (shader->InfoLog) { + free(shader->InfoLog); + shader->InfoLog = NULL; + } + shader->InfoLog = strdup(info_log.text); + } + } - return GL_TRUE; + slang_info_log_destruct(&info_log); + _slang_code_object_dtr(&obj); + + return success; } diff --git a/src/mesa/shader/slang/slang_compile.h b/src/mesa/shader/slang/slang_compile.h index 8a72f43486a..ba129df8e33 100644 --- a/src/mesa/shader/slang/slang_compile.h +++ b/src/mesa/shader/slang/slang_compile.h @@ -109,7 +109,7 @@ int slang_info_log_warning (slang_info_log *, const char *, ...); void slang_info_log_memory (slang_info_log *); extern GLboolean -_slang_compile (const char *, slang_code_object *, slang_unit_type, slang_info_log *, struct gl_shader *shader); +_slang_compile (GLcontext *ctx, struct gl_shader *shader); #ifdef __cplusplus } |