summaryrefslogtreecommitdiffstats
path: root/src/mesa/shader
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/shader')
-rw-r--r--src/mesa/shader/shaderobjects.c56
-rwxr-xr-xsrc/mesa/shader/shaderobjects_3dlabs.c116
2 files changed, 140 insertions, 32 deletions
diff --git a/src/mesa/shader/shaderobjects.c b/src/mesa/shader/shaderobjects.c
index ac8ff1af487..edd74d0f4a6 100644
--- a/src/mesa/shader/shaderobjects.c
+++ b/src/mesa/shader/shaderobjects.c
@@ -73,9 +73,9 @@ _mesa_GetHandleARB (GLenum pname)
switch (pname)
{
case GL_PROGRAM_OBJECT_ARB:
- if (ctx->ShaderObjects.current_program != NULL)
- return (**ctx->ShaderObjects.current_program)._container._generic.GetName (
- (struct gl2_generic_intf **) ctx->ShaderObjects.current_program);
+ if (ctx->ShaderObjects.CurrentProgram != NULL)
+ return (**ctx->ShaderObjects.CurrentProgram)._container._generic.GetName (
+ (struct gl2_generic_intf **) ctx->ShaderObjects.CurrentProgram);
break;
}
@@ -305,7 +305,7 @@ _mesa_LinkProgramARB (GLhandleARB programObj)
return;
}
- if (pro == ctx->ShaderObjects.current_program)
+ if (pro == ctx->ShaderObjects.CurrentProgram)
{
/* TODO re-install executable program */
}
@@ -353,13 +353,13 @@ _mesa_UseProgramObjectARB (GLhandleARB programObj)
}
}
- if (ctx->ShaderObjects.current_program != NULL)
+ if (ctx->ShaderObjects.CurrentProgram != NULL)
{
- (**ctx->ShaderObjects.current_program)._container._generic._unknown.Release (
- (struct gl2_unknown_intf **) ctx->ShaderObjects.current_program);
+ (**ctx->ShaderObjects.CurrentProgram)._container._generic._unknown.Release (
+ (struct gl2_unknown_intf **) ctx->ShaderObjects.CurrentProgram);
}
- ctx->ShaderObjects.current_program = pro;
+ ctx->ShaderObjects.CurrentProgram = pro;
}
void GLAPIENTRY
@@ -418,7 +418,7 @@ _mesa_Uniform1fARB (GLint location, GLfloat v0)
{
GET_CURRENT_CONTEXT(ctx);
- if (ctx->ShaderObjects.current_program == NULL)
+ if (ctx->ShaderObjects.CurrentProgram == NULL)
{
_mesa_error (ctx, GL_INVALID_OPERATION, "glUniform1fARB");
return;
@@ -430,7 +430,7 @@ _mesa_Uniform2fARB (GLint location, GLfloat v0, GLfloat v1)
{
GET_CURRENT_CONTEXT(ctx);
- if (ctx->ShaderObjects.current_program == NULL)
+ if (ctx->ShaderObjects.CurrentProgram == NULL)
{
_mesa_error (ctx, GL_INVALID_OPERATION, "glUniform2fARB");
return;
@@ -442,7 +442,7 @@ _mesa_Uniform3fARB (GLint location, GLfloat v0, GLfloat v1, GLfloat v2)
{
GET_CURRENT_CONTEXT(ctx);
- if (ctx->ShaderObjects.current_program == NULL)
+ if (ctx->ShaderObjects.CurrentProgram == NULL)
{
_mesa_error (ctx, GL_INVALID_OPERATION, "glUniform3fARB");
return;
@@ -454,7 +454,7 @@ _mesa_Uniform4fARB (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat
{
GET_CURRENT_CONTEXT(ctx);
- if (ctx->ShaderObjects.current_program == NULL)
+ if (ctx->ShaderObjects.CurrentProgram == NULL)
{
_mesa_error (ctx, GL_INVALID_OPERATION, "glUniform4fARB");
return;
@@ -466,7 +466,7 @@ _mesa_Uniform1iARB (GLint location, GLint v0)
{
GET_CURRENT_CONTEXT(ctx);
- if (ctx->ShaderObjects.current_program == NULL)
+ if (ctx->ShaderObjects.CurrentProgram == NULL)
{
_mesa_error (ctx, GL_INVALID_OPERATION, "glUniform1iARB");
return;
@@ -478,7 +478,7 @@ _mesa_Uniform2iARB (GLint location, GLint v0, GLint v1)
{
GET_CURRENT_CONTEXT(ctx);
- if (ctx->ShaderObjects.current_program == NULL)
+ if (ctx->ShaderObjects.CurrentProgram == NULL)
{
_mesa_error (ctx, GL_INVALID_OPERATION, "glUniform2iARB");
return;
@@ -490,7 +490,7 @@ _mesa_Uniform3iARB (GLint location, GLint v0, GLint v1, GLint v2)
{
GET_CURRENT_CONTEXT(ctx);
- if (ctx->ShaderObjects.current_program == NULL)
+ if (ctx->ShaderObjects.CurrentProgram == NULL)
{
_mesa_error (ctx, GL_INVALID_OPERATION, "glUniform3iARB");
return;
@@ -502,7 +502,7 @@ _mesa_Uniform4iARB (GLint location, GLint v0, GLint v1, GLint v2, GLint v3)
{
GET_CURRENT_CONTEXT(ctx);
- if (ctx->ShaderObjects.current_program == NULL)
+ if (ctx->ShaderObjects.CurrentProgram == NULL)
{
_mesa_error (ctx, GL_INVALID_OPERATION, "glUniform4iARB");
return;
@@ -514,7 +514,7 @@ _mesa_Uniform1fvARB (GLint location, GLsizei count, const GLfloat *value)
{
GET_CURRENT_CONTEXT(ctx);
- if (ctx->ShaderObjects.current_program == NULL)
+ if (ctx->ShaderObjects.CurrentProgram == NULL)
{
_mesa_error (ctx, GL_INVALID_OPERATION, "glUniform1fvARB");
return;
@@ -526,7 +526,7 @@ _mesa_Uniform2fvARB (GLint location, GLsizei count, const GLfloat *value)
{
GET_CURRENT_CONTEXT(ctx);
- if (ctx->ShaderObjects.current_program == NULL)
+ if (ctx->ShaderObjects.CurrentProgram == NULL)
{
_mesa_error (ctx, GL_INVALID_OPERATION, "glUniform2fvARB");
return;
@@ -538,7 +538,7 @@ _mesa_Uniform3fvARB (GLint location, GLsizei count, const GLfloat *value)
{
GET_CURRENT_CONTEXT(ctx);
- if (ctx->ShaderObjects.current_program == NULL)
+ if (ctx->ShaderObjects.CurrentProgram == NULL)
{
_mesa_error (ctx, GL_INVALID_OPERATION, "glUniform3fvARB");
return;
@@ -550,7 +550,7 @@ _mesa_Uniform4fvARB (GLint location, GLsizei count, const GLfloat *value)
{
GET_CURRENT_CONTEXT(ctx);
- if (ctx->ShaderObjects.current_program == NULL)
+ if (ctx->ShaderObjects.CurrentProgram == NULL)
{
_mesa_error (ctx, GL_INVALID_OPERATION, "glUniform4fvARB");
return;
@@ -562,7 +562,7 @@ _mesa_Uniform1ivARB (GLint location, GLsizei count, const GLint *value)
{
GET_CURRENT_CONTEXT(ctx);
- if (ctx->ShaderObjects.current_program == NULL)
+ if (ctx->ShaderObjects.CurrentProgram == NULL)
{
_mesa_error (ctx, GL_INVALID_OPERATION, "glUniform1ivARB");
return;
@@ -574,7 +574,7 @@ _mesa_Uniform2ivARB (GLint location, GLsizei count, const GLint *value)
{
GET_CURRENT_CONTEXT(ctx);
- if (ctx->ShaderObjects.current_program == NULL)
+ if (ctx->ShaderObjects.CurrentProgram == NULL)
{
_mesa_error (ctx, GL_INVALID_OPERATION, "glUniform2ivARB");
return;
@@ -586,7 +586,7 @@ _mesa_Uniform3ivARB (GLint location, GLsizei count, const GLint *value)
{
GET_CURRENT_CONTEXT(ctx);
- if (ctx->ShaderObjects.current_program == NULL)
+ if (ctx->ShaderObjects.CurrentProgram == NULL)
{
_mesa_error (ctx, GL_INVALID_OPERATION, "glUniform3ivARB");
return;
@@ -598,7 +598,7 @@ _mesa_Uniform4ivARB (GLint location, GLsizei count, const GLint *value)
{
GET_CURRENT_CONTEXT(ctx);
- if (ctx->ShaderObjects.current_program == NULL)
+ if (ctx->ShaderObjects.CurrentProgram == NULL)
{
_mesa_error (ctx, GL_INVALID_OPERATION, "glUniform4ivARB");
return;
@@ -610,7 +610,7 @@ _mesa_UniformMatrix2fvARB (GLint location, GLsizei count, GLboolean transpose, c
{
GET_CURRENT_CONTEXT(ctx);
- if (ctx->ShaderObjects.current_program == NULL)
+ if (ctx->ShaderObjects.CurrentProgram == NULL)
{
_mesa_error (ctx, GL_INVALID_OPERATION, "glUniformMatrix2fvARB");
return;
@@ -622,7 +622,7 @@ _mesa_UniformMatrix3fvARB (GLint location, GLsizei count, GLboolean transpose, c
{
GET_CURRENT_CONTEXT(ctx);
- if (ctx->ShaderObjects.current_program == NULL)
+ if (ctx->ShaderObjects.CurrentProgram == NULL)
{
_mesa_error (ctx, GL_INVALID_OPERATION, "glUniformMatrix3fvARB");
return;
@@ -634,7 +634,7 @@ _mesa_UniformMatrix4fvARB (GLint location, GLsizei count, GLboolean transpose, c
{
GET_CURRENT_CONTEXT(ctx);
- if (ctx->ShaderObjects.current_program == NULL)
+ if (ctx->ShaderObjects.CurrentProgram == NULL)
{
_mesa_error (ctx, GL_INVALID_OPERATION, "glUniformMatrix4fvARB");
return;
@@ -1175,7 +1175,7 @@ _mesa_GetAttribLocationARB (GLhandleARB programObj, const GLcharARB *name)
void
_mesa_init_shaderobjects (GLcontext *ctx)
{
- ctx->ShaderObjects.current_program = NULL;
+ ctx->ShaderObjects.CurrentProgram = NULL;
_mesa_init_shaderobjects_3dlabs (ctx);
}
diff --git a/src/mesa/shader/shaderobjects_3dlabs.c b/src/mesa/shader/shaderobjects_3dlabs.c
index f03f65d7016..e55b243da0c 100755
--- a/src/mesa/shader/shaderobjects_3dlabs.c
+++ b/src/mesa/shader/shaderobjects_3dlabs.c
@@ -1,8 +1,8 @@
/*
* Mesa 3-D graphics library
- * Version: 6.3
+ * Version: 6.5
*
- * Copyright (C) 2005 Brian Paul All Rights Reserved.
+ * Copyright (C) 2005-2006 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -42,6 +42,7 @@
#include "slang_mesa.h"
#include "Public/ShaderLang.h"
#else
+#include "slang_utility.h"
#include "slang_compile.h"
#endif
@@ -465,6 +466,7 @@ struct gl2_shader_obj
GLcharARB *source;
GLint *offsets;
GLsizei offset_count;
+ slang_translation_unit unit;
};
struct gl2_shader_impl
@@ -548,7 +550,6 @@ _shader_Compile (struct gl2_shader_intf **intf)
char **strings;
TBuiltInResource res;
#else
- slang_translation_unit unit;
slang_unit_type type;
slang_info_log info_log;
#endif
@@ -627,7 +628,7 @@ _shader_Compile (struct gl2_shader_intf **intf)
else
type = slang_unit_vertex_shader;
slang_info_log_construct (&info_log);
- if (_slang_compile (impl->_obj.source, &unit, type, &info_log))
+ if (_slang_compile (impl->_obj.source, &impl->_obj.unit, type, &info_log))
{
impl->_obj.compile_status = GL_TRUE;
}
@@ -794,6 +795,10 @@ _program_Link (struct gl2_program_intf **intf)
impl->_obj.link_status = GL_TRUE;
impl->_obj._container._generic.info_log = _mesa_strdup (ShGetInfoLog (impl->_obj.linker));
+#else
+ /* TODO: do the real linking */
+ impl->_obj.link_status = GL_TRUE;
+ impl->_obj._container._generic.info_log = _mesa_strdup ("Link OK.\n");
#endif
}
@@ -1041,6 +1046,109 @@ _mesa_3dlabs_create_program_object (void)
return 0;
}
+#include "slang_assemble.h"
+#include "slang_execute.h"
+
+static GLubyte *get_address_of (struct gl2_vertex_shader_intf **vs, const char *name)
+{
+ struct gl2_vertex_shader_impl *impl = (struct gl2_vertex_shader_impl *) vs;
+ slang_translation_unit *unit;
+ slang_atom atom;
+ slang_variable *var;
+
+ impl = (struct gl2_vertex_shader_impl *) vs;
+ unit = &impl->_obj._shader.unit;
+ atom = slang_atom_pool_atom (unit->atom_pool, name);
+ var = _slang_locate_variable (&unit->globals, atom, 1);
+ if (var == NULL || var->address == ~0)
+ return NULL;
+ return (GLubyte *) unit->machine->mem + var->address;
+}
+
+static int fetch_mem (struct gl2_vertex_shader_intf **vs, const char *name, GLvoid *val,
+ GLuint size, GLuint index, int write)
+{
+ GLubyte *data;
+
+ data = get_address_of (vs, name) + index * size;
+ if (data == NULL)
+ return 0;
+ if (write)
+ _mesa_memcpy (data, val, size);
+ else
+ _mesa_memcpy (val, data, size);
+ return 1;
+}
+
+int _slang_fetch_float (struct gl2_vertex_shader_intf **vs, const char *name, GLfloat *val, int write)
+{
+ return fetch_mem (vs, name, val, 4, 0, write);
+}
+
+int _slang_fetch_vec3 (struct gl2_vertex_shader_intf **vs, const char *name, GLfloat *val, int write)
+{
+ return fetch_mem (vs, name, val, 12, 0, write);
+}
+
+int _slang_fetch_vec4 (struct gl2_vertex_shader_intf **vs, const char *name, GLfloat *val,
+ GLuint index, int write)
+{
+ return fetch_mem (vs, name, val, 16, index, write);
+}
+
+int _slang_fetch_mat4 (struct gl2_vertex_shader_intf **vs, const char *name, GLfloat *val,
+ GLuint index, int write)
+{
+ return fetch_mem (vs, name, val, 64, index, write);
+}
+
+/* XXX */
+int _slang_call_function (slang_assembly_file *file, slang_function *fun, slang_operation *params,
+ unsigned int param_count, int assignment, slang_assembly_name_space *space,
+ slang_assembly_local_info *info, struct slang_machine_ *pmach, slang_atom_pool *);
+
+void exec_vertex_shader (struct gl2_vertex_shader_intf **vs)
+{
+ struct gl2_vertex_shader_impl *impl = (struct gl2_vertex_shader_impl *) vs;
+ slang_translation_unit *unit;
+ slang_atom atom;
+ unsigned int i;
+
+ impl = (struct gl2_vertex_shader_impl *) vs;
+ unit = &impl->_obj._shader.unit;
+ atom = slang_atom_pool_atom (unit->atom_pool, "main");
+ for (i = 0; i < unit->functions.num_functions; i++)
+ if (atom == unit->functions.functions[i].header.a_name)
+ break;
+ if (i < unit->functions.num_functions)
+ {
+ slang_function *f;
+ slang_assembly_file_restore_point point;
+ slang_machine mach;
+ slang_assembly_local_info info;
+ slang_assembly_name_space space;
+
+ f = &unit->functions.functions[i];
+ slang_assembly_file_restore_point_save (unit->assembly, &point);
+ mach = *unit->machine;
+ mach.ip = unit->assembly->count;
+ info.ret_size = 0;
+ info.addr_tmp = 0;
+ info.swizzle_tmp = 4;
+ slang_assembly_file_push_label (unit->assembly, slang_asm_local_alloc, 20);
+ slang_assembly_file_push_label (unit->assembly, slang_asm_enter, 20);
+ space.funcs = &unit->functions;
+ space.structs = &unit->structs;
+ space.vars = &unit->globals;
+ _slang_call_function (unit->assembly, f, NULL, 0, 0, &space, &info, unit->machine,
+ unit->atom_pool);
+ slang_assembly_file_push (unit->assembly, slang_asm_exit);
+ _slang_execute2 (unit->assembly, &mach);
+ slang_assembly_file_restore_point_load (unit->assembly, &point);
+ _mesa_memcpy (unit->machine->mem, mach.mem, SLANG_MACHINE_MEMORY_SIZE * sizeof (slang_machine_slot));
+ }
+}
+
void
_mesa_init_shaderobjects_3dlabs (GLcontext *ctx)
{