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;
}
return;
}
- if (pro == ctx->ShaderObjects.current_program)
+ if (pro == ctx->ShaderObjects.CurrentProgram)
{
/* TODO re-install executable program */
}
}
}
- 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
{
GET_CURRENT_CONTEXT(ctx);
- if (ctx->ShaderObjects.current_program == NULL)
+ if (ctx->ShaderObjects.CurrentProgram == NULL)
{
_mesa_error (ctx, GL_INVALID_OPERATION, "glUniform1fARB");
return;
{
GET_CURRENT_CONTEXT(ctx);
- if (ctx->ShaderObjects.current_program == NULL)
+ if (ctx->ShaderObjects.CurrentProgram == NULL)
{
_mesa_error (ctx, GL_INVALID_OPERATION, "glUniform2fARB");
return;
{
GET_CURRENT_CONTEXT(ctx);
- if (ctx->ShaderObjects.current_program == NULL)
+ if (ctx->ShaderObjects.CurrentProgram == NULL)
{
_mesa_error (ctx, GL_INVALID_OPERATION, "glUniform3fARB");
return;
{
GET_CURRENT_CONTEXT(ctx);
- if (ctx->ShaderObjects.current_program == NULL)
+ if (ctx->ShaderObjects.CurrentProgram == NULL)
{
_mesa_error (ctx, GL_INVALID_OPERATION, "glUniform4fARB");
return;
{
GET_CURRENT_CONTEXT(ctx);
- if (ctx->ShaderObjects.current_program == NULL)
+ if (ctx->ShaderObjects.CurrentProgram == NULL)
{
_mesa_error (ctx, GL_INVALID_OPERATION, "glUniform1iARB");
return;
{
GET_CURRENT_CONTEXT(ctx);
- if (ctx->ShaderObjects.current_program == NULL)
+ if (ctx->ShaderObjects.CurrentProgram == NULL)
{
_mesa_error (ctx, GL_INVALID_OPERATION, "glUniform2iARB");
return;
{
GET_CURRENT_CONTEXT(ctx);
- if (ctx->ShaderObjects.current_program == NULL)
+ if (ctx->ShaderObjects.CurrentProgram == NULL)
{
_mesa_error (ctx, GL_INVALID_OPERATION, "glUniform3iARB");
return;
{
GET_CURRENT_CONTEXT(ctx);
- if (ctx->ShaderObjects.current_program == NULL)
+ if (ctx->ShaderObjects.CurrentProgram == NULL)
{
_mesa_error (ctx, GL_INVALID_OPERATION, "glUniform4iARB");
return;
{
GET_CURRENT_CONTEXT(ctx);
- if (ctx->ShaderObjects.current_program == NULL)
+ if (ctx->ShaderObjects.CurrentProgram == NULL)
{
_mesa_error (ctx, GL_INVALID_OPERATION, "glUniform1fvARB");
return;
{
GET_CURRENT_CONTEXT(ctx);
- if (ctx->ShaderObjects.current_program == NULL)
+ if (ctx->ShaderObjects.CurrentProgram == NULL)
{
_mesa_error (ctx, GL_INVALID_OPERATION, "glUniform2fvARB");
return;
{
GET_CURRENT_CONTEXT(ctx);
- if (ctx->ShaderObjects.current_program == NULL)
+ if (ctx->ShaderObjects.CurrentProgram == NULL)
{
_mesa_error (ctx, GL_INVALID_OPERATION, "glUniform3fvARB");
return;
{
GET_CURRENT_CONTEXT(ctx);
- if (ctx->ShaderObjects.current_program == NULL)
+ if (ctx->ShaderObjects.CurrentProgram == NULL)
{
_mesa_error (ctx, GL_INVALID_OPERATION, "glUniform4fvARB");
return;
{
GET_CURRENT_CONTEXT(ctx);
- if (ctx->ShaderObjects.current_program == NULL)
+ if (ctx->ShaderObjects.CurrentProgram == NULL)
{
_mesa_error (ctx, GL_INVALID_OPERATION, "glUniform1ivARB");
return;
{
GET_CURRENT_CONTEXT(ctx);
- if (ctx->ShaderObjects.current_program == NULL)
+ if (ctx->ShaderObjects.CurrentProgram == NULL)
{
_mesa_error (ctx, GL_INVALID_OPERATION, "glUniform2ivARB");
return;
{
GET_CURRENT_CONTEXT(ctx);
- if (ctx->ShaderObjects.current_program == NULL)
+ if (ctx->ShaderObjects.CurrentProgram == NULL)
{
_mesa_error (ctx, GL_INVALID_OPERATION, "glUniform3ivARB");
return;
{
GET_CURRENT_CONTEXT(ctx);
- if (ctx->ShaderObjects.current_program == NULL)
+ if (ctx->ShaderObjects.CurrentProgram == NULL)
{
_mesa_error (ctx, GL_INVALID_OPERATION, "glUniform4ivARB");
return;
{
GET_CURRENT_CONTEXT(ctx);
- if (ctx->ShaderObjects.current_program == NULL)
+ if (ctx->ShaderObjects.CurrentProgram == NULL)
{
_mesa_error (ctx, GL_INVALID_OPERATION, "glUniformMatrix2fvARB");
return;
{
GET_CURRENT_CONTEXT(ctx);
- if (ctx->ShaderObjects.current_program == NULL)
+ if (ctx->ShaderObjects.CurrentProgram == NULL)
{
_mesa_error (ctx, GL_INVALID_OPERATION, "glUniformMatrix3fvARB");
return;
{
GET_CURRENT_CONTEXT(ctx);
- if (ctx->ShaderObjects.current_program == NULL)
+ if (ctx->ShaderObjects.CurrentProgram == NULL)
{
_mesa_error (ctx, GL_INVALID_OPERATION, "glUniformMatrix4fvARB");
return;
void
_mesa_init_shaderobjects (GLcontext *ctx)
{
- ctx->ShaderObjects.current_program = NULL;
+ ctx->ShaderObjects.CurrentProgram = NULL;
_mesa_init_shaderobjects_3dlabs (ctx);
}
/*\r
* Mesa 3-D graphics library\r
- * Version: 6.3\r
+ * Version: 6.5\r
*\r
- * Copyright (C) 2005 Brian Paul All Rights Reserved.\r
+ * Copyright (C) 2005-2006 Brian Paul All Rights Reserved.\r
*\r
* Permission is hereby granted, free of charge, to any person obtaining a\r
* copy of this software and associated documentation files (the "Software"),\r
#include "slang_mesa.h"\r
#include "Public/ShaderLang.h"\r
#else\r
+#include "slang_utility.h"\r
#include "slang_compile.h"\r
#endif\r
\r
GLcharARB *source;\r
GLint *offsets;\r
GLsizei offset_count;\r
+ slang_translation_unit unit;\r
};\r
\r
struct gl2_shader_impl\r
char **strings;\r
TBuiltInResource res;\r
#else\r
- slang_translation_unit unit;\r
slang_unit_type type;\r
slang_info_log info_log;\r
#endif\r
else\r
type = slang_unit_vertex_shader;\r
slang_info_log_construct (&info_log);\r
- if (_slang_compile (impl->_obj.source, &unit, type, &info_log))\r
+ if (_slang_compile (impl->_obj.source, &impl->_obj.unit, type, &info_log))\r
{\r
impl->_obj.compile_status = GL_TRUE;\r
}\r
impl->_obj.link_status = GL_TRUE;\r
\r
impl->_obj._container._generic.info_log = _mesa_strdup (ShGetInfoLog (impl->_obj.linker));\r
+#else\r
+ /* TODO: do the real linking */\r
+ impl->_obj.link_status = GL_TRUE;\r
+ impl->_obj._container._generic.info_log = _mesa_strdup ("Link OK.\n");\r
#endif\r
}\r
\r
return 0;\r
}\r
\r
+#include "slang_assemble.h"\r
+#include "slang_execute.h"\r
+\r
+static GLubyte *get_address_of (struct gl2_vertex_shader_intf **vs, const char *name)\r
+{\r
+ struct gl2_vertex_shader_impl *impl = (struct gl2_vertex_shader_impl *) vs;\r
+ slang_translation_unit *unit;\r
+ slang_atom atom;\r
+ slang_variable *var;\r
+\r
+ impl = (struct gl2_vertex_shader_impl *) vs;\r
+ unit = &impl->_obj._shader.unit;\r
+ atom = slang_atom_pool_atom (unit->atom_pool, name);\r
+ var = _slang_locate_variable (&unit->globals, atom, 1);\r
+ if (var == NULL || var->address == ~0)\r
+ return NULL;\r
+ return (GLubyte *) unit->machine->mem + var->address;\r
+}\r
+\r
+static int fetch_mem (struct gl2_vertex_shader_intf **vs, const char *name, GLvoid *val,\r
+ GLuint size, GLuint index, int write)\r
+{\r
+ GLubyte *data;\r
+\r
+ data = get_address_of (vs, name) + index * size;\r
+ if (data == NULL)\r
+ return 0;\r
+ if (write)\r
+ _mesa_memcpy (data, val, size);\r
+ else\r
+ _mesa_memcpy (val, data, size);\r
+ return 1;\r
+}\r
+\r
+int _slang_fetch_float (struct gl2_vertex_shader_intf **vs, const char *name, GLfloat *val, int write)\r
+{\r
+ return fetch_mem (vs, name, val, 4, 0, write);\r
+}\r
+\r
+int _slang_fetch_vec3 (struct gl2_vertex_shader_intf **vs, const char *name, GLfloat *val, int write)\r
+{\r
+ return fetch_mem (vs, name, val, 12, 0, write);\r
+}\r
+\r
+int _slang_fetch_vec4 (struct gl2_vertex_shader_intf **vs, const char *name, GLfloat *val,\r
+ GLuint index, int write)\r
+{\r
+ return fetch_mem (vs, name, val, 16, index, write);\r
+}\r
+\r
+int _slang_fetch_mat4 (struct gl2_vertex_shader_intf **vs, const char *name, GLfloat *val,\r
+ GLuint index, int write)\r
+{\r
+ return fetch_mem (vs, name, val, 64, index, write);\r
+}\r
+\r
+/* XXX */\r
+int _slang_call_function (slang_assembly_file *file, slang_function *fun, slang_operation *params,\r
+ unsigned int param_count, int assignment, slang_assembly_name_space *space,\r
+ slang_assembly_local_info *info, struct slang_machine_ *pmach, slang_atom_pool *);\r
+\r
+void exec_vertex_shader (struct gl2_vertex_shader_intf **vs)\r
+{\r
+ struct gl2_vertex_shader_impl *impl = (struct gl2_vertex_shader_impl *) vs;\r
+ slang_translation_unit *unit;\r
+ slang_atom atom;\r
+ unsigned int i;\r
+\r
+ impl = (struct gl2_vertex_shader_impl *) vs;\r
+ unit = &impl->_obj._shader.unit;\r
+ atom = slang_atom_pool_atom (unit->atom_pool, "main");\r
+ for (i = 0; i < unit->functions.num_functions; i++)\r
+ if (atom == unit->functions.functions[i].header.a_name)\r
+ break;\r
+ if (i < unit->functions.num_functions)\r
+ {\r
+ slang_function *f;\r
+ slang_assembly_file_restore_point point;\r
+ slang_machine mach;\r
+ slang_assembly_local_info info;\r
+ slang_assembly_name_space space;\r
+\r
+ f = &unit->functions.functions[i];\r
+ slang_assembly_file_restore_point_save (unit->assembly, &point);\r
+ mach = *unit->machine;\r
+ mach.ip = unit->assembly->count;\r
+ info.ret_size = 0;\r
+ info.addr_tmp = 0;\r
+ info.swizzle_tmp = 4;\r
+ slang_assembly_file_push_label (unit->assembly, slang_asm_local_alloc, 20);\r
+ slang_assembly_file_push_label (unit->assembly, slang_asm_enter, 20);\r
+ space.funcs = &unit->functions;\r
+ space.structs = &unit->structs;\r
+ space.vars = &unit->globals;\r
+ _slang_call_function (unit->assembly, f, NULL, 0, 0, &space, &info, unit->machine,\r
+ unit->atom_pool);\r
+ slang_assembly_file_push (unit->assembly, slang_asm_exit);\r
+ _slang_execute2 (unit->assembly, &mach);\r
+ slang_assembly_file_restore_point_load (unit->assembly, &point);\r
+ _mesa_memcpy (unit->machine->mem, mach.mem, SLANG_MACHINE_MEMORY_SIZE * sizeof (slang_machine_slot));\r
+ }\r
+}\r
+\r
void\r
_mesa_init_shaderobjects_3dlabs (GLcontext *ctx)\r
{\r