glsl: don't lose uniform values when falling back to full compile
[mesa.git] / src / mesa / main / shaderobj.c
index b41137fbce3b3820bb51fb3a77bd28ca21ec6d07..8cc90736801f517f824ff912af8b424d665628a7 100644 (file)
@@ -122,6 +122,7 @@ void
 _mesa_delete_shader(struct gl_context *ctx, struct gl_shader *sh)
 {
    free((void *)sh->Source);
+   free((void *)sh->FallbackSource);
    free(sh->Label);
    ralloc_free(sh);
 }
@@ -326,7 +327,7 @@ _mesa_clear_shader_program_data(struct gl_context *ctx,
 
    shProg->data->linked_stages = 0;
 
-   if (shProg->data->UniformStorage) {
+   if (shProg->data->UniformStorage && !shProg->data->cache_fallback) {
       for (unsigned i = 0; i < shProg->data->NumUniformStorage; ++i)
          _mesa_uniform_detach_all_driver_storage(&shProg->data->
                                                     UniformStorage[i]);
@@ -335,7 +336,7 @@ _mesa_clear_shader_program_data(struct gl_context *ctx,
       shProg->data->UniformStorage = NULL;
    }
 
-   if (shProg->UniformRemapTable) {
+   if (shProg->UniformRemapTable && !shProg->data->cache_fallback) {
       ralloc_free(shProg->UniformRemapTable);
       shProg->NumUniformRemapTable = 0;
       shProg->UniformRemapTable = NULL;
@@ -429,7 +430,8 @@ _mesa_delete_shader_program(struct gl_context *ctx,
                             struct gl_shader_program *shProg)
 {
    _mesa_free_shader_program_data(ctx, shProg);
-   _mesa_reference_shader_program_data(ctx, &shProg->data, NULL);
+   if (!shProg->data->cache_fallback)
+      _mesa_reference_shader_program_data(ctx, &shProg->data, NULL);
    ralloc_free(shProg);
 }