/*** Shader Program object functions ***/
/**********************************************************************/
-
void
_mesa_reference_shader_program_data(struct gl_context *ctx,
struct gl_shader_program_data **ptr,
if (p_atomic_dec_zero(&oldData->RefCount)) {
assert(ctx);
+ assert(oldData->NumUniformStorage == 0 ||
+ oldData->UniformStorage);
+
+ for (unsigned i = 0; i < oldData->NumUniformStorage; ++i)
+ _mesa_uniform_detach_all_driver_storage(&oldData->UniformStorage[i]);
+
ralloc_free(oldData);
}
}
}
-static struct gl_shader_program_data *
-create_shader_program_data()
+struct gl_shader_program_data *
+_mesa_create_shader_program_data()
{
struct gl_shader_program_data *data;
data = rzalloc(NULL, struct gl_shader_program_data);
- if (data)
+ if (data) {
data->RefCount = 1;
+ data->InfoLog = ralloc_strdup(data, "");
+ }
return data;
}
prog->TransformFeedback.BufferMode = GL_INTERLEAVED_ATTRIBS;
exec_list_make_empty(&prog->EmptyUniformLocations);
-
- prog->data->InfoLog = ralloc_strdup(prog->data, "");
}
/**
shProg = rzalloc(NULL, struct gl_shader_program);
if (shProg) {
shProg->Name = name;
- shProg->data = create_shader_program_data();
+ shProg->data = _mesa_create_shader_program_data();
if (!shProg->data) {
ralloc_free(shProg);
return NULL;
}
}
- shProg->data->linked_stages = 0;
-
- if (shProg->data->UniformStorage) {
- for (unsigned i = 0; i < shProg->data->NumUniformStorage; ++i)
- _mesa_uniform_detach_all_driver_storage(&shProg->data->
- UniformStorage[i]);
- ralloc_free(shProg->data->UniformStorage);
- shProg->data->NumUniformStorage = 0;
- shProg->data->UniformStorage = NULL;
- }
-
if (shProg->UniformRemapTable) {
ralloc_free(shProg->UniformRemapTable);
shProg->NumUniformRemapTable = 0;
shProg->UniformHash = NULL;
}
- assert(shProg->data->InfoLog != NULL);
- ralloc_free(shProg->data->InfoLog);
- shProg->data->InfoLog = ralloc_strdup(shProg->data, "");
-
- ralloc_free(shProg->data->UniformBlocks);
- shProg->data->UniformBlocks = NULL;
- shProg->data->NumUniformBlocks = 0;
-
- ralloc_free(shProg->data->ShaderStorageBlocks);
- shProg->data->ShaderStorageBlocks = NULL;
- shProg->data->NumShaderStorageBlocks = 0;
-
- if (shProg->data->AtomicBuffers) {
- ralloc_free(shProg->data->AtomicBuffers);
- shProg->data->AtomicBuffers = NULL;
- shProg->data->NumAtomicBuffers = 0;
- }
-
- if (shProg->data->ProgramResourceList) {
- ralloc_free(shProg->data->ProgramResourceList);
- shProg->data->ProgramResourceList = NULL;
- shProg->data->NumProgramResourceList = 0;
- }
+ _mesa_reference_shader_program_data(ctx, &shProg->data, NULL);
}
struct gl_shader_program *shProg)
{
_mesa_free_shader_program_data(ctx, shProg);
- _mesa_reference_shader_program_data(ctx, &shProg->data, NULL);
ralloc_free(shProg);
}