mesa: Add gl_shader_program::AttributeBindings
This currently mirrors the state tracking gl_shader_program::Attributes, but I'm working towards eliminating that. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
This commit is contained in:
@@ -2146,8 +2146,17 @@ struct gl_shader_program
|
|||||||
GLuint NumShaders; /**< number of attached shaders */
|
GLuint NumShaders; /**< number of attached shaders */
|
||||||
struct gl_shader **Shaders; /**< List of attached the shaders */
|
struct gl_shader **Shaders; /**< List of attached the shaders */
|
||||||
|
|
||||||
/** User-defined attribute bindings (glBindAttribLocation) */
|
/**
|
||||||
|
* User-defined attribute bindings
|
||||||
|
*
|
||||||
|
* These are set via \c glBindAttribLocation and are used to direct the
|
||||||
|
* GLSL linker. These are \b not the values used in the compiled shader,
|
||||||
|
* and they are \b not the values returned by \c glGetAttribLocation.
|
||||||
|
*
|
||||||
|
* \sa gl_program::Attributes
|
||||||
|
*/
|
||||||
struct gl_program_parameter_list *Attributes;
|
struct gl_program_parameter_list *Attributes;
|
||||||
|
struct string_to_uint_map *AttributeBindings;
|
||||||
|
|
||||||
/** Transform feedback varyings */
|
/** Transform feedback varyings */
|
||||||
struct {
|
struct {
|
||||||
|
@@ -32,6 +32,7 @@
|
|||||||
#include "glsl_symbol_table.h"
|
#include "glsl_symbol_table.h"
|
||||||
#include "ir.h"
|
#include "ir.h"
|
||||||
#include "shaderobj.h"
|
#include "shaderobj.h"
|
||||||
|
#include "program/hash_table.h"
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include "shaderapi.h"
|
#include "shaderapi.h"
|
||||||
@@ -67,6 +68,10 @@ _mesa_BindAttribLocationARB(GLhandleARB program, GLuint index,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* this will replace the current value if it's already in the list */
|
/* this will replace the current value if it's already in the list */
|
||||||
|
/* Add VERT_ATTRIB_GENERIC0 because that's how the linker differentiates
|
||||||
|
* between built-in attributes and user-defined attributes.
|
||||||
|
*/
|
||||||
|
shProg->AttributeBindings->put(index + VERT_ATTRIB_GENERIC0, name);
|
||||||
i = _mesa_add_attribute(shProg->Attributes, name, size, datatype, index);
|
i = _mesa_add_attribute(shProg->Attributes, name, size, datatype, index);
|
||||||
if (i < 0) {
|
if (i < 0) {
|
||||||
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glBindAttribLocation");
|
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glBindAttribLocation");
|
||||||
|
@@ -38,6 +38,7 @@
|
|||||||
#include "program/program.h"
|
#include "program/program.h"
|
||||||
#include "program/prog_parameter.h"
|
#include "program/prog_parameter.h"
|
||||||
#include "program/prog_uniform.h"
|
#include "program/prog_uniform.h"
|
||||||
|
#include "program/hash_table.h"
|
||||||
#include "ralloc.h"
|
#include "ralloc.h"
|
||||||
|
|
||||||
/**********************************************************************/
|
/**********************************************************************/
|
||||||
@@ -239,6 +240,9 @@ _mesa_init_shader_program(struct gl_context *ctx, struct gl_shader_program *prog
|
|||||||
prog->Type = GL_SHADER_PROGRAM_MESA;
|
prog->Type = GL_SHADER_PROGRAM_MESA;
|
||||||
prog->RefCount = 1;
|
prog->RefCount = 1;
|
||||||
prog->Attributes = _mesa_new_parameter_list();
|
prog->Attributes = _mesa_new_parameter_list();
|
||||||
|
|
||||||
|
prog->AttributeBindings = string_to_uint_map_ctor();
|
||||||
|
|
||||||
#if FEATURE_ARB_geometry_shader4
|
#if FEATURE_ARB_geometry_shader4
|
||||||
prog->Geom.VerticesOut = 0;
|
prog->Geom.VerticesOut = 0;
|
||||||
prog->Geom.InputType = GL_TRIANGLES;
|
prog->Geom.InputType = GL_TRIANGLES;
|
||||||
@@ -312,6 +316,11 @@ _mesa_free_shader_program_data(struct gl_context *ctx,
|
|||||||
shProg->Attributes = NULL;
|
shProg->Attributes = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (shProg->AttributeBindings) {
|
||||||
|
string_to_uint_map_dtor(shProg->AttributeBindings);
|
||||||
|
shProg->AttributeBindings = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/* detach shaders */
|
/* detach shaders */
|
||||||
for (i = 0; i < shProg->NumShaders; i++) {
|
for (i = 0; i < shProg->NumShaders; i++) {
|
||||||
_mesa_reference_shader(ctx, &shProg->Shaders[i], NULL);
|
_mesa_reference_shader(ctx, &shProg->Shaders[i], NULL);
|
||||||
|
Reference in New Issue
Block a user