summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/glsl/linker.cpp16
-rw-r--r--src/glsl/main.cpp4
-rw-r--r--src/glsl/program.h34
-rw-r--r--src/mesa/main/mtypes.h3
-rw-r--r--src/mesa/shader/ir_to_mesa.cpp39
-rw-r--r--src/mesa/shader/shader_api.c6
6 files changed, 36 insertions, 66 deletions
diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
index df71f21b54..719cae2f27 100644
--- a/src/glsl/linker.cpp
+++ b/src/glsl/linker.cpp
@@ -116,7 +116,7 @@ private:
void
-linker_error_printf(glsl_program *prog, const char *fmt, ...)
+linker_error_printf(gl_shader_program *prog, const char *fmt, ...)
{
va_list ap;
@@ -186,7 +186,7 @@ count_attribute_slots(const glsl_type *t)
* \param shader Vertex shader executable to be verified
*/
bool
-validate_vertex_shader_executable(struct glsl_program *prog,
+validate_vertex_shader_executable(struct gl_shader_program *prog,
struct gl_shader *shader)
{
if (shader == NULL)
@@ -215,7 +215,7 @@ validate_vertex_shader_executable(struct glsl_program *prog,
* \param shader Fragment shader executable to be verified
*/
bool
-validate_fragment_shader_executable(struct glsl_program *prog,
+validate_fragment_shader_executable(struct gl_shader_program *prog,
struct gl_shader *shader)
{
if (shader == NULL)
@@ -252,7 +252,7 @@ validate_fragment_shader_executable(struct glsl_program *prog,
* Perform validation of uniforms used across multiple shader stages
*/
bool
-cross_validate_uniforms(struct glsl_program *prog)
+cross_validate_uniforms(struct gl_shader_program *prog)
{
/* Examine all of the uniforms in all of the shaders and cross validate
* them.
@@ -308,7 +308,7 @@ cross_validate_uniforms(struct glsl_program *prog)
* Validate that outputs from one stage match inputs of another
*/
bool
-cross_validate_outputs_to_inputs(struct glsl_program *prog,
+cross_validate_outputs_to_inputs(struct gl_shader_program *prog,
gl_shader *producer, gl_shader *consumer)
{
glsl_symbol_table parameters;
@@ -412,7 +412,7 @@ struct uniform_node {
};
void
-assign_uniform_locations(struct glsl_program *prog)
+assign_uniform_locations(struct gl_shader_program *prog)
{
/* */
exec_list uniforms;
@@ -533,7 +533,7 @@ find_available_slots(unsigned used_mask, unsigned needed_count)
bool
-assign_attribute_locations(glsl_program *prog, unsigned max_attribute_index)
+assign_attribute_locations(gl_shader_program *prog, unsigned max_attribute_index)
{
/* Mark invalid attribute locations as being used.
*/
@@ -767,7 +767,7 @@ assign_varying_locations(gl_shader *producer, gl_shader *consumer)
void
-link_shaders(struct glsl_program *prog)
+link_shaders(struct gl_shader_program *prog)
{
prog->LinkStatus = false;
prog->Validated = false;
diff --git a/src/glsl/main.cpp b/src/glsl/main.cpp
index e78af42ac6..1ed22e1f33 100644
--- a/src/glsl/main.cpp
+++ b/src/glsl/main.cpp
@@ -206,9 +206,9 @@ main(int argc, char **argv)
if (argc <= optind)
usage_fail(argv[0]);
- struct glsl_program *whole_program;
+ struct gl_shader_program *whole_program;
- whole_program = talloc_zero (NULL, struct glsl_program);
+ whole_program = talloc_zero (NULL, struct gl_shader_program);
assert(whole_program != NULL);
for (/* empty */; argc > optind; optind++) {
diff --git a/src/glsl/program.h b/src/glsl/program.h
index 19c3a3e611..bb1cd919cd 100644
--- a/src/glsl/program.h
+++ b/src/glsl/program.h
@@ -29,37 +29,5 @@ extern "C" {
#include "shader/prog_uniform.h"
}
-/**
- * Based on gl_shader_program in Mesa's mtypes.h.
- */
-struct glsl_program {
- GLenum Type; /**< Always GL_SHADER_PROGRAM (internal token) */
- GLuint Name; /**< aka handle or ID */
- GLint RefCount; /**< Reference count */
- GLboolean DeletePending;
-
- GLuint NumShaders; /**< number of attached shaders */
- struct gl_shader **Shaders; /**< List of attached the shaders */
-
- /**
- * Per-stage shaders resulting from the first stage of linking.
- */
- /*@{*/
- unsigned _NumLinkedShaders;
- struct gl_shader **_LinkedShaders;
- /*@}*/
-
- /** User-defined attribute bindings (glBindAttribLocation) */
- struct gl_program_parameter_list *Attributes;
-
- /* post-link info: */
- struct gl_uniform_list *Uniforms;
- struct gl_program_parameter_list *Varying;
- GLboolean LinkStatus; /**< GL_LINK_STATUS */
- GLboolean Validated;
- GLboolean _Used; /**< Ever used for drawing? */
- GLchar *InfoLog;
-};
-
extern void
-link_shaders(struct glsl_program *prog);
+link_shaders(struct gl_shader_program *prog);
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 6fc7e29baf..bc90b1e044 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2005,6 +2005,9 @@ struct gl_shader_program
GLboolean Validated;
GLboolean _Used; /**< Ever used for drawing? */
GLchar *InfoLog;
+
+ GLuint _NumLinkedShaders;
+ struct gl_shader **_LinkedShaders;
};
diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp
index c2dde312ef..f0eb46a3ee 100644
--- a/src/mesa/shader/ir_to_mesa.cpp
+++ b/src/mesa/shader/ir_to_mesa.cpp
@@ -1709,48 +1709,49 @@ _mesa_glsl_compile_shader(GLcontext *ctx, struct gl_shader *shader)
void
_mesa_glsl_link_shader(GLcontext *ctx, struct gl_shader_program *prog)
{
- struct glsl_program *whole_program;
unsigned int i;
+
_mesa_clear_shader_program_data(ctx, prog);
- whole_program = talloc_zero(NULL, struct glsl_program);
- whole_program->LinkStatus = GL_TRUE;
- whole_program->NumShaders = prog->NumShaders;
- whole_program->Shaders = talloc_array(whole_program, struct gl_shader *,
- prog->NumShaders);
+ prog->LinkStatus = GL_TRUE;
for (i = 0; i < prog->NumShaders; i++) {
- whole_program->Shaders[i] = prog->Shaders[i];
- if (!whole_program->Shaders[i]->CompileStatus) {
- whole_program->InfoLog =
- talloc_asprintf_append(whole_program->InfoLog,
+ if (!prog->Shaders[i]->CompileStatus) {
+ prog->InfoLog =
+ talloc_asprintf_append(prog->InfoLog,
"linking with uncompiled shader");
- whole_program->LinkStatus = GL_FALSE;
+ prog->LinkStatus = GL_FALSE;
}
}
- prog->Uniforms = _mesa_new_uniform_list();
prog->Varying = _mesa_new_parameter_list();
_mesa_reference_vertprog(ctx, &prog->VertexProgram, NULL);
_mesa_reference_fragprog(ctx, &prog->FragmentProgram, NULL);
- if (whole_program->LinkStatus)
- link_shaders(whole_program);
+ if (prog->LinkStatus) {
+ link_shaders(prog);
+
+ /* We don't use the linker's uniforms list, and cook up our own at
+ * generate time.
+ */
+ free(prog->Uniforms);
+ prog->Uniforms = _mesa_new_uniform_list();
+ }
- prog->LinkStatus = whole_program->LinkStatus;
+ prog->LinkStatus = prog->LinkStatus;
/* FINISHME: This should use the linker-generated code */
if (prog->LinkStatus) {
for (i = 0; i < prog->NumShaders; i++) {
struct gl_program *linked_prog;
- linked_prog = get_mesa_program(ctx, whole_program,
- whole_program->Shaders[i]);
+ linked_prog = get_mesa_program(ctx, prog,
+ prog->Shaders[i]);
count_resources(linked_prog);
link_uniforms_to_shared_uniform_list(prog->Uniforms, linked_prog);
- switch (whole_program->Shaders[i]->Type) {
+ switch (prog->Shaders[i]->Type) {
case GL_VERTEX_SHADER:
_mesa_reference_vertprog(ctx, &prog->VertexProgram,
(struct gl_vertex_program *)linked_prog);
@@ -1766,8 +1767,6 @@ _mesa_glsl_link_shader(GLcontext *ctx, struct gl_shader_program *prog)
}
}
}
-
- talloc_free(whole_program);
}
} /* extern "C" */
diff --git a/src/mesa/shader/shader_api.c b/src/mesa/shader/shader_api.c
index 40b8286a13..f05ebc9fcb 100644
--- a/src/mesa/shader/shader_api.c
+++ b/src/mesa/shader/shader_api.c
@@ -53,7 +53,7 @@ static struct gl_shader_program *
_mesa_new_shader_program(GLcontext *ctx, GLuint name)
{
struct gl_shader_program *shProg;
- shProg = CALLOC_STRUCT(gl_shader_program);
+ shProg = talloc_zero(NULL, struct gl_shader_program);
if (shProg) {
shProg->Type = GL_SHADER_PROGRAM_MESA;
shProg->Name = name;
@@ -117,7 +117,7 @@ _mesa_free_shader_program_data(GLcontext *ctx,
}
if (shProg->InfoLog) {
- free(shProg->InfoLog);
+ talloc_free(shProg->InfoLog);
shProg->InfoLog = NULL;
}
@@ -139,7 +139,7 @@ _mesa_free_shader_program(GLcontext *ctx, struct gl_shader_program *shProg)
{
_mesa_free_shader_program_data(ctx, shProg);
- free(shProg);
+ talloc_free(shProg);
}