GLuint i;
if (!shProg || !sh) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
+ _mesa_error(ctx, GL_INVALID_VALUE,
"glAttachShader(bad program or shader name)");
return;
}
= _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;
}
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;
}
GLuint i, j;
if (!shProg) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
+ _mesa_error(ctx, GL_INVALID_VALUE,
"glDetachShader(bad program or shader name)");
return;
}
}
/* not found */
- _mesa_error(ctx, GL_INVALID_OPERATION,
+ _mesa_error(ctx, GL_INVALID_VALUE,
"glDetachShader(shader not found)");
}
GLint sz;
if (!shProg) {
- _mesa_error(ctx, GL_INVALID_OPERATION, "glGetActiveUniform");
+ _mesa_error(ctx, GL_INVALID_VALUE, "glGetActiveUniform");
return;
}
GLint sz;
if (!shProg) {
- _mesa_error(ctx, GL_INVALID_OPERATION, "glGetActiveUniform");
+ _mesa_error(ctx, GL_INVALID_VALUE, "glGetActiveUniform");
return;
}
*count = i;
}
else {
- _mesa_error(ctx, GL_INVALID_OPERATION, "glGetAttachedShaders");
+ _mesa_error(ctx, GL_INVALID_VALUE, "glGetAttachedShaders");
}
}
= _mesa_lookup_shader_program(ctx, program);
if (!shProg) {
- _mesa_error(ctx, GL_INVALID_OPERATION, "glGetAttribLocation");
+ _mesa_error(ctx, GL_INVALID_VALUE, "glGetAttribLocation");
return -1;
}
}
}
else {
- _mesa_error(ctx, GL_INVALID_OPERATION, "glGetUniformfv(program)");
+ _mesa_error(ctx, GL_INVALID_VALUE, "glGetUniformfv(program)");
}
}
_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);
}
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;
}
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;
}
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 */
float __operator + (const float a, const float b)
{
-// __asm float_add __retVal, a, b;
__asm vec4_add __retVal.x, a, b;
}
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;
}
{
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 */
#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)
#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;
}
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
}