mesa: Use gl_shader_program::_LinkedShaders instead of VertexProgram
Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Brian Paul <brianp@vmware.com> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
This commit is contained in:
@@ -2347,7 +2347,8 @@ vec4_visitor::vec4_visitor(struct brw_vs_compile *c,
|
|||||||
this->current_annotation = NULL;
|
this->current_annotation = NULL;
|
||||||
|
|
||||||
this->c = c;
|
this->c = c;
|
||||||
this->vp = prog->VertexProgram;
|
this->vp = (struct gl_vertex_program *)
|
||||||
|
prog->_LinkedShaders[MESA_SHADER_VERTEX]->Program;
|
||||||
this->prog_data = &c->prog_data;
|
this->prog_data = &c->prog_data;
|
||||||
|
|
||||||
this->variable_ht = hash_table_ctor(0,
|
this->variable_ht = hash_table_ctor(0,
|
||||||
|
@@ -354,15 +354,17 @@ brw_vs_precompile(struct gl_context *ctx, struct gl_shader_program *prog)
|
|||||||
{
|
{
|
||||||
struct brw_context *brw = brw_context(ctx);
|
struct brw_context *brw = brw_context(ctx);
|
||||||
struct brw_vs_prog_key key;
|
struct brw_vs_prog_key key;
|
||||||
struct gl_vertex_program *vp = prog->VertexProgram;
|
|
||||||
struct brw_vertex_program *bvp = brw_vertex_program(vp);
|
|
||||||
uint32_t old_prog_offset = brw->vs.prog_offset;
|
uint32_t old_prog_offset = brw->vs.prog_offset;
|
||||||
struct brw_vs_prog_data *old_prog_data = brw->vs.prog_data;
|
struct brw_vs_prog_data *old_prog_data = brw->vs.prog_data;
|
||||||
bool success;
|
bool success;
|
||||||
|
|
||||||
if (!vp)
|
if (!prog->_LinkedShaders[MESA_SHADER_VERTEX])
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
struct gl_vertex_program *vp = (struct gl_vertex_program *)
|
||||||
|
prog->_LinkedShaders[MESA_SHADER_VERTEX]->Program;
|
||||||
|
struct brw_vertex_program *bvp = brw_vertex_program(vp);
|
||||||
|
|
||||||
memset(&key, 0, sizeof(key));
|
memset(&key, 0, sizeof(key));
|
||||||
|
|
||||||
key.program_string_id = bvp->id;
|
key.program_string_id = bvp->id;
|
||||||
|
@@ -1852,7 +1852,7 @@ _mesa_valid_to_render(struct gl_context *ctx, const char *where)
|
|||||||
sh = shProg[i]->_LinkedShaders[i];
|
sh = shProg[i]->_LinkedShaders[i];
|
||||||
switch (sh->Type) {
|
switch (sh->Type) {
|
||||||
case GL_VERTEX_SHADER:
|
case GL_VERTEX_SHADER:
|
||||||
_mesa_append_uniforms_to_file(sh, &shProg[i]->VertexProgram->Base);
|
_mesa_append_uniforms_to_file(sh, sh->Program);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GL_GEOMETRY_SHADER_ARB:
|
case GL_GEOMETRY_SHADER_ARB:
|
||||||
|
@@ -315,7 +315,7 @@ static GLbitfield get_fp_input_mask( struct gl_context *ctx )
|
|||||||
const GLboolean vertexShader =
|
const GLboolean vertexShader =
|
||||||
(ctx->Shader.CurrentVertexProgram &&
|
(ctx->Shader.CurrentVertexProgram &&
|
||||||
ctx->Shader.CurrentVertexProgram->LinkStatus &&
|
ctx->Shader.CurrentVertexProgram->LinkStatus &&
|
||||||
ctx->Shader.CurrentVertexProgram->VertexProgram);
|
ctx->Shader.CurrentVertexProgram->_LinkedShaders[MESA_SHADER_VERTEX]);
|
||||||
const GLboolean vertexProgram = ctx->VertexProgram._Enabled;
|
const GLboolean vertexProgram = ctx->VertexProgram._Enabled;
|
||||||
GLbitfield fp_inputs = 0x0;
|
GLbitfield fp_inputs = 0x0;
|
||||||
|
|
||||||
@@ -371,7 +371,7 @@ static GLbitfield get_fp_input_mask( struct gl_context *ctx )
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* calculate from vp->outputs */
|
/* calculate from vp->outputs */
|
||||||
struct gl_vertex_program *vprog;
|
struct gl_program *vprog;
|
||||||
GLbitfield64 vp_outputs;
|
GLbitfield64 vp_outputs;
|
||||||
|
|
||||||
/* Choose GLSL vertex shader over ARB vertex program. Need this
|
/* Choose GLSL vertex shader over ARB vertex program. Need this
|
||||||
@@ -379,11 +379,11 @@ static GLbitfield get_fp_input_mask( struct gl_context *ctx )
|
|||||||
* validation (see additional comments in state.c).
|
* validation (see additional comments in state.c).
|
||||||
*/
|
*/
|
||||||
if (vertexShader)
|
if (vertexShader)
|
||||||
vprog = ctx->Shader.CurrentVertexProgram->VertexProgram;
|
vprog = ctx->Shader.CurrentVertexProgram->_LinkedShaders[MESA_SHADER_VERTEX]->Program;
|
||||||
else
|
else
|
||||||
vprog = ctx->VertexProgram.Current;
|
vprog = &ctx->VertexProgram.Current->Base;
|
||||||
|
|
||||||
vp_outputs = vprog->Base.OutputsWritten;
|
vp_outputs = vprog->OutputsWritten;
|
||||||
|
|
||||||
/* These get generated in the setup routine regardless of the
|
/* These get generated in the setup routine regardless of the
|
||||||
* vertex program:
|
* vertex program:
|
||||||
|
@@ -2171,7 +2171,6 @@ struct gl_shader_program
|
|||||||
} Vert;
|
} Vert;
|
||||||
|
|
||||||
/* post-link info: */
|
/* post-link info: */
|
||||||
struct gl_vertex_program *VertexProgram; /**< Linked vertex program */
|
|
||||||
struct gl_fragment_program *FragmentProgram; /**< Linked fragment prog */
|
struct gl_fragment_program *FragmentProgram; /**< Linked fragment prog */
|
||||||
struct gl_geometry_program *GeometryProgram; /**< Linked geometry prog */
|
struct gl_geometry_program *GeometryProgram; /**< Linked geometry prog */
|
||||||
struct gl_uniform_list *Uniforms;
|
struct gl_uniform_list *Uniforms;
|
||||||
|
@@ -808,8 +808,9 @@ print_shader_info(const struct gl_shader_program *shProg)
|
|||||||
shProg->Shaders[i]->Name,
|
shProg->Shaders[i]->Name,
|
||||||
shProg->Shaders[i]->SourceChecksum);
|
shProg->Shaders[i]->SourceChecksum);
|
||||||
}
|
}
|
||||||
if (shProg->VertexProgram)
|
if (shProg->_LinkedShaders[MESA_SHADER_VERTEX])
|
||||||
printf(" vert prog %u\n", shProg->VertexProgram->Base.Id);
|
printf(" vert prog %u\n",
|
||||||
|
shProg->_LinkedShaders[MESA_SHADER_VERTEX]->Program->Id);
|
||||||
if (shProg->FragmentProgram)
|
if (shProg->FragmentProgram)
|
||||||
printf(" frag prog %u\n", shProg->FragmentProgram->Base.Id);
|
printf(" frag prog %u\n", shProg->FragmentProgram->Base.Id);
|
||||||
if (shProg->GeometryProgram)
|
if (shProg->GeometryProgram)
|
||||||
@@ -963,7 +964,7 @@ static GLboolean
|
|||||||
validate_shader_program(const struct gl_shader_program *shProg,
|
validate_shader_program(const struct gl_shader_program *shProg,
|
||||||
char *errMsg)
|
char *errMsg)
|
||||||
{
|
{
|
||||||
const struct gl_vertex_program *vp = shProg->VertexProgram;
|
const struct gl_shader *vs = shProg->_LinkedShaders[MESA_SHADER_VERTEX];
|
||||||
const struct gl_geometry_program *gp = shProg->GeometryProgram;
|
const struct gl_geometry_program *gp = shProg->GeometryProgram;
|
||||||
const struct gl_fragment_program *fp = shProg->FragmentProgram;
|
const struct gl_fragment_program *fp = shProg->FragmentProgram;
|
||||||
|
|
||||||
@@ -991,7 +992,7 @@ validate_shader_program(const struct gl_shader_program *shProg,
|
|||||||
* Check: any two active samplers in the current program object are of
|
* Check: any two active samplers in the current program object are of
|
||||||
* different types, but refer to the same texture image unit,
|
* different types, but refer to the same texture image unit,
|
||||||
*/
|
*/
|
||||||
if (vp && !validate_samplers(&vp->Base, errMsg)) {
|
if (vs && !validate_samplers(vs->Program, errMsg)) {
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
}
|
}
|
||||||
if (gp && !validate_samplers(&gp->Base, errMsg)) {
|
if (gp && !validate_samplers(&gp->Base, errMsg)) {
|
||||||
|
@@ -275,7 +275,6 @@ void
|
|||||||
_mesa_clear_shader_program_data(struct gl_context *ctx,
|
_mesa_clear_shader_program_data(struct gl_context *ctx,
|
||||||
struct gl_shader_program *shProg)
|
struct gl_shader_program *shProg)
|
||||||
{
|
{
|
||||||
_mesa_reference_vertprog(ctx, &shProg->VertexProgram, NULL);
|
|
||||||
_mesa_reference_fragprog(ctx, &shProg->FragmentProgram, NULL);
|
_mesa_reference_fragprog(ctx, &shProg->FragmentProgram, NULL);
|
||||||
_mesa_reference_geomprog(ctx, &shProg->GeometryProgram, NULL);
|
_mesa_reference_geomprog(ctx, &shProg->GeometryProgram, NULL);
|
||||||
|
|
||||||
|
@@ -281,10 +281,12 @@ update_program(struct gl_context *ctx)
|
|||||||
* _mesa_get_fixed_func_vertex_program() needs to know active
|
* _mesa_get_fixed_func_vertex_program() needs to know active
|
||||||
* fragprog inputs.
|
* fragprog inputs.
|
||||||
*/
|
*/
|
||||||
if (vsProg && vsProg->LinkStatus && vsProg->VertexProgram) {
|
if (vsProg && vsProg->LinkStatus
|
||||||
|
&& vsProg->_LinkedShaders[MESA_SHADER_VERTEX]) {
|
||||||
/* Use GLSL vertex shader */
|
/* Use GLSL vertex shader */
|
||||||
_mesa_reference_vertprog(ctx, &ctx->VertexProgram._Current,
|
_mesa_reference_vertprog(ctx, &ctx->VertexProgram._Current,
|
||||||
vsProg->VertexProgram);
|
(struct gl_vertex_program *)
|
||||||
|
vsProg->_LinkedShaders[MESA_SHADER_VERTEX]->Program);
|
||||||
}
|
}
|
||||||
else if (ctx->VertexProgram._Enabled) {
|
else if (ctx->VertexProgram._Enabled) {
|
||||||
/* Use user-defined vertex program */
|
/* Use user-defined vertex program */
|
||||||
|
@@ -490,16 +490,16 @@ update_texture_state( struct gl_context *ctx )
|
|||||||
{
|
{
|
||||||
GLuint unit;
|
GLuint unit;
|
||||||
struct gl_fragment_program *fprog = NULL;
|
struct gl_fragment_program *fprog = NULL;
|
||||||
struct gl_vertex_program *vprog = NULL;
|
struct gl_program *vprog = NULL;
|
||||||
GLbitfield enabledFragUnits = 0x0;
|
GLbitfield enabledFragUnits = 0x0;
|
||||||
|
|
||||||
if (ctx->Shader.CurrentVertexProgram &&
|
if (ctx->Shader.CurrentVertexProgram &&
|
||||||
ctx->Shader.CurrentVertexProgram->LinkStatus) {
|
ctx->Shader.CurrentVertexProgram->LinkStatus) {
|
||||||
vprog = ctx->Shader.CurrentVertexProgram->VertexProgram;
|
vprog = ctx->Shader.CurrentVertexProgram->_LinkedShaders[MESA_SHADER_VERTEX]->Program;
|
||||||
} else if (ctx->VertexProgram._Enabled) {
|
} else if (ctx->VertexProgram._Enabled) {
|
||||||
/* XXX enable this if/when non-shader vertex programs get
|
/* XXX enable this if/when non-shader vertex programs get
|
||||||
* texture fetches:
|
* texture fetches:
|
||||||
vprog = ctx->VertexProgram.Current;
|
vprog = &ctx->VertexProgram.Current->Base;
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -540,7 +540,7 @@ update_texture_state( struct gl_context *ctx )
|
|||||||
* settle on the one with highest priority (see below).
|
* settle on the one with highest priority (see below).
|
||||||
*/
|
*/
|
||||||
if (vprog) {
|
if (vprog) {
|
||||||
enabledVertTargets |= vprog->Base.TexturesUsed[unit];
|
enabledVertTargets |= vprog->TexturesUsed[unit];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fprog) {
|
if (fprog) {
|
||||||
|
@@ -180,7 +180,7 @@ find_uniform_parameter_pos(struct gl_shader_program *shProg, GLint index,
|
|||||||
|
|
||||||
pos = shProg->Uniforms->Uniforms[index].VertPos;
|
pos = shProg->Uniforms->Uniforms[index].VertPos;
|
||||||
if (pos >= 0) {
|
if (pos >= 0) {
|
||||||
prog = &shProg->VertexProgram->Base;
|
prog = shProg->_LinkedShaders[MESA_SHADER_VERTEX]->Program;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
pos = shProg->Uniforms->Uniforms[index].FragPos;
|
pos = shProg->Uniforms->Uniforms[index].FragPos;
|
||||||
@@ -911,11 +911,12 @@ _mesa_uniform(struct gl_context *ctx, struct gl_shader_program *shProg,
|
|||||||
/* A uniform var may be used by both a vertex shader and a fragment
|
/* A uniform var may be used by both a vertex shader and a fragment
|
||||||
* shader. We may need to update one or both shader's uniform here:
|
* shader. We may need to update one or both shader's uniform here:
|
||||||
*/
|
*/
|
||||||
if (shProg->VertexProgram) {
|
if (shProg->_LinkedShaders[MESA_SHADER_VERTEX]) {
|
||||||
/* convert uniform location to program parameter index */
|
/* convert uniform location to program parameter index */
|
||||||
GLint index = uniform->VertPos;
|
GLint index = uniform->VertPos;
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
set_program_uniform(ctx, &shProg->VertexProgram->Base,
|
set_program_uniform(ctx,
|
||||||
|
shProg->_LinkedShaders[MESA_SHADER_VERTEX]->Program,
|
||||||
index, offset, type, count, elems, values);
|
index, offset, type, count, elems, values);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1056,11 +1057,12 @@ _mesa_uniform_matrix(struct gl_context *ctx, struct gl_shader_program *shProg,
|
|||||||
|
|
||||||
uniform = &shProg->Uniforms->Uniforms[location];
|
uniform = &shProg->Uniforms->Uniforms[location];
|
||||||
|
|
||||||
if (shProg->VertexProgram) {
|
if (shProg->_LinkedShaders[MESA_SHADER_VERTEX]) {
|
||||||
/* convert uniform location to program parameter index */
|
/* convert uniform location to program parameter index */
|
||||||
GLint index = uniform->VertPos;
|
GLint index = uniform->VertPos;
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
set_program_uniform_matrix(ctx, &shProg->VertexProgram->Base,
|
set_program_uniform_matrix(ctx,
|
||||||
|
shProg->_LinkedShaders[MESA_SHADER_VERTEX]->Program,
|
||||||
index, offset,
|
index, offset,
|
||||||
count, rows, cols, transpose, values);
|
count, rows, cols, transpose, values);
|
||||||
}
|
}
|
||||||
|
@@ -3294,8 +3294,8 @@ _mesa_ir_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
|
|||||||
case GL_VERTEX_SHADER:
|
case GL_VERTEX_SHADER:
|
||||||
((struct gl_vertex_program *)linked_prog)->UsesClipDistance
|
((struct gl_vertex_program *)linked_prog)->UsesClipDistance
|
||||||
= prog->Vert.UsesClipDistance;
|
= prog->Vert.UsesClipDistance;
|
||||||
_mesa_reference_vertprog(ctx, &prog->VertexProgram,
|
_mesa_reference_program(ctx, &prog->_LinkedShaders[i]->Program,
|
||||||
(struct gl_vertex_program *)linked_prog);
|
linked_prog);
|
||||||
ok = ctx->Driver.ProgramStringNotify(ctx, GL_VERTEX_PROGRAM_ARB,
|
ok = ctx->Driver.ProgramStringNotify(ctx, GL_VERTEX_PROGRAM_ARB,
|
||||||
linked_prog);
|
linked_prog);
|
||||||
break;
|
break;
|
||||||
@@ -3427,7 +3427,6 @@ _mesa_glsl_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_mesa_reference_vertprog(ctx, &prog->VertexProgram, NULL);
|
|
||||||
_mesa_reference_fragprog(ctx, &prog->FragmentProgram, NULL);
|
_mesa_reference_fragprog(ctx, &prog->FragmentProgram, NULL);
|
||||||
_mesa_reference_geomprog(ctx, &prog->GeometryProgram, NULL);
|
_mesa_reference_geomprog(ctx, &prog->GeometryProgram, NULL);
|
||||||
|
|
||||||
|
@@ -5184,8 +5184,8 @@ st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
|
|||||||
|
|
||||||
switch (prog->_LinkedShaders[i]->Type) {
|
switch (prog->_LinkedShaders[i]->Type) {
|
||||||
case GL_VERTEX_SHADER:
|
case GL_VERTEX_SHADER:
|
||||||
_mesa_reference_vertprog(ctx, &prog->VertexProgram,
|
_mesa_reference_program(ctx, &prog->_LinkedShaders[i]->Program,
|
||||||
(struct gl_vertex_program *)linked_prog);
|
linked_prog);
|
||||||
ok = ctx->Driver.ProgramStringNotify(ctx, GL_VERTEX_PROGRAM_ARB,
|
ok = ctx->Driver.ProgramStringNotify(ctx, GL_VERTEX_PROGRAM_ARB,
|
||||||
linked_prog);
|
linked_prog);
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
|
@@ -1153,8 +1153,8 @@ destroy_shader_program_variants_cb(GLuint key, void *data, void *userData)
|
|||||||
destroy_program_variants(st, shProg->Shaders[i]->Program);
|
destroy_program_variants(st, shProg->Shaders[i]->Program);
|
||||||
}
|
}
|
||||||
|
|
||||||
destroy_program_variants(st, (struct gl_program *)
|
destroy_program_variants(st,
|
||||||
shProg->VertexProgram);
|
shProg->_LinkedShaders[MESA_SHADER_VERTEX]->Program);
|
||||||
destroy_program_variants(st, (struct gl_program *)
|
destroy_program_variants(st, (struct gl_program *)
|
||||||
shProg->FragmentProgram);
|
shProg->FragmentProgram);
|
||||||
destroy_program_variants(st, (struct gl_program *)
|
destroy_program_variants(st, (struct gl_program *)
|
||||||
|
Reference in New Issue
Block a user