\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
+ struct gl2_vertex_shader_impl *impl;\r
slang_translation_unit *unit;\r
slang_atom atom;\r
slang_variable *var;\r
return (GLubyte *) unit->machine->mem + var->address;\r
}\r
\r
+static GLubyte *get_address_of_f (struct gl2_fragment_shader_intf **fs, const char *name)\r
+{\r
+ struct gl2_fragment_shader_impl *impl;\r
+ slang_translation_unit *unit;\r
+ slang_atom atom;\r
+ slang_variable *var;\r
+\r
+ impl = (struct gl2_fragment_shader_impl *) fs;\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
return 1;\r
}\r
\r
+static int fetch_mem_f (struct gl2_fragment_shader_intf **fs, const char *name, GLvoid *val,\r
+ GLuint size, GLuint index, int write)\r
+{\r
+ GLubyte *data;\r
+\r
+ data = get_address_of_f (fs, 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
return fetch_mem (vs, name, val, 16, index, write);\r
}\r
\r
+int _slang_fetch_vec4_f (struct gl2_fragment_shader_intf **fs, const char *name, GLfloat *val,\r
+ GLuint index, int write)\r
+{\r
+ return fetch_mem_f (fs, name, val, 16, index, write);\r
+}\r
+\r
+int _slang_fetch_mat3 (struct gl2_vertex_shader_intf **vs, const char *name, GLfloat *val,\r
+ GLuint index, int write)\r
+{\r
+ return fetch_mem (vs, name, val, 36, 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
+int _slang_fetch_discard (struct gl2_fragment_shader_intf **fs, GLboolean *val)\r
+{\r
+ struct gl2_fragment_shader_impl *impl;\r
+ slang_translation_unit *unit;\r
+\r
+ impl = (struct gl2_fragment_shader_impl *) fs;\r
+ unit = &impl->_obj._shader.unit;\r
+ *val = unit->machine->kill ? GL_TRUE : GL_FALSE;\r
+ return 1;\r
+}\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
+ struct gl2_vertex_shader_impl *impl;\r
slang_translation_unit *unit;\r
slang_atom atom;\r
unsigned int i;\r
slang_machine mach;\r
slang_assembly_local_info info;\r
slang_assembly_name_space space;\r
+ slang_assemble_ctx A;\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
+ A.file = unit->assembly;\r
+ A.mach = unit->machine;\r
+ A.atoms = unit->atom_pool;\r
+ A.space = space;\r
+ _slang_assemble_function_call (&A, f, NULL, 0, GL_FALSE);\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 exec_fragment_shader (struct gl2_fragment_shader_intf **fs)\r
+{\r
+ struct gl2_fragment_shader_impl *impl;\r
+ slang_translation_unit *unit;\r
+ slang_atom atom;\r
+ unsigned int i;\r
+\r
+ impl = (struct gl2_fragment_shader_impl *) fs;\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
+ slang_assemble_ctx A;\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
+ mach.kill = 0;\r
info.ret_size = 0;\r
info.addr_tmp = 0;\r
info.swizzle_tmp = 4;\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
+ A.file = unit->assembly;\r
+ A.mach = unit->machine;\r
+ A.atoms = unit->atom_pool;\r
+ A.space = space;\r
+ _slang_assemble_function_call (&A, f, NULL, 0, GL_FALSE);\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
+ unit->machine->kill = mach.kill;\r
}\r
}\r
\r