uint8_t StageReferences; /** Bitmask of shader stage references. */
};
+/**
+ * A data structure to be shared by gl_shader_program and gl_program.
+ */
+struct gl_shader_program_data
+{
+ GLint RefCount; /**< Reference count */
+
+ unsigned NumUniformStorage;
+ unsigned NumHiddenUniforms;
+ struct gl_uniform_storage *UniformStorage;
+
+ unsigned NumUniformBlocks;
+ struct gl_uniform_block *UniformBlocks;
+
+ unsigned NumShaderStorageBlocks;
+ struct gl_uniform_block *ShaderStorageBlocks;
+
+ struct gl_active_atomic_buffer *AtomicBuffers;
+ unsigned NumAtomicBuffers;
+
+ GLboolean LinkStatus; /**< GL_LINK_STATUS */
+ GLboolean Validated;
+ GLchar *InfoLog;
+};
+
/**
* A GLSL program object.
* Basically a linked collection of vertex and fragment shaders.
#include "program/prog_parameter.h"
#include "util/ralloc.h"
#include "util/string_to_uint_map.h"
+#include "util/u_atomic.h"
/**********************************************************************/
/*** Shader object functions ***/
/**********************************************************************/
+void
+_mesa_reference_shader_program_data(struct gl_context *ctx,
+ struct gl_shader_program_data **ptr,
+ struct gl_shader_program_data *data)
+{
+ if (*ptr == data)
+ return;
+
+ if (*ptr) {
+ struct gl_shader_program_data *oldData = *ptr;
+
+ assert(oldData->RefCount > 0);
+
+ if (p_atomic_dec_zero(&oldData->RefCount)) {
+ assert(ctx);
+ ralloc_free(oldData);
+ }
+
+ *ptr = NULL;
+ }
+
+ if (data)
+ p_atomic_inc(&data->RefCount);
+
+ *ptr = data;
+}
+
/**
* Set ptr to point to shProg.
* If ptr is pointing to another object, decrement its refcount (and delete
}
}
+static struct gl_shader_program_data *
+create_shader_program_data()
+{
+ struct gl_shader_program_data *data;
+ data = rzalloc(NULL, struct gl_shader_program_data);
+ if (data)
+ data->RefCount = 1;
+
+ return data;
+}
+
static void
init_shader_program(struct gl_shader_program *prog)
{
struct gl_shader_program **ptr,
struct gl_shader_program *shProg);
+void
+_mesa_reference_shader_program_data(struct gl_context *ctx,
+ struct gl_shader_program_data **ptr,
+ struct gl_shader_program_data *data);
+
static inline void
_mesa_reference_shader_program(struct gl_context *ctx,
struct gl_shader_program **ptr,