Added few more stubs so that control reaches to DestroyDevice().
[mesa.git] / src / mesa / main / shaderobj.c
index 7b73f5691dd54a8f6f81b8dae16e4d1cb101e8f3..9a4225d608a026df7e81e215bb6f28d46ccc403f 100644 (file)
  */
 
 
+#include "compiler/glsl/string_to_uint_map.h"
 #include "main/glheader.h"
 #include "main/context.h"
+#include "main/glspirv.h"
 #include "main/hash.h"
 #include "main/mtypes.h"
 #include "main/shaderapi.h"
@@ -40,7 +42,6 @@
 #include "program/program.h"
 #include "program/prog_parameter.h"
 #include "util/ralloc.h"
-#include "util/string_to_uint_map.h"
 #include "util/u_atomic.h"
 
 /**********************************************************************/
@@ -121,7 +122,9 @@ _mesa_new_shader(GLuint name, gl_shader_stage stage)
 void
 _mesa_delete_shader(struct gl_context *ctx, struct gl_shader *sh)
 {
+   _mesa_shader_spirv_data_reference(&sh->spirv_data, NULL);
    free((void *)sh->Source);
+   free((void *)sh->FallbackSource);
    free(sh->Label);
    ralloc_free(sh);
 }
@@ -134,6 +137,7 @@ void
 _mesa_delete_linked_shader(struct gl_context *ctx,
                            struct gl_linked_shader *sh)
 {
+   _mesa_shader_spirv_data_reference(&sh->spirv_data, NULL);
    _mesa_reference_program(ctx, &sh->Program, NULL);
    ralloc_free(sh);
 }
@@ -192,7 +196,6 @@ _mesa_lookup_shader_err(struct gl_context *ctx, GLuint name, const char *caller)
 /*** Shader Program object functions                                ***/
 /**********************************************************************/
 
-
 void
 _mesa_reference_shader_program_data(struct gl_context *ctx,
                                     struct gl_shader_program_data **ptr,
@@ -208,6 +211,12 @@ _mesa_reference_shader_program_data(struct gl_context *ctx,
 
       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);
       }
 
@@ -258,13 +267,15 @@ _mesa_reference_shader_program_(struct gl_context *ctx,
    }
 }
 
-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;
 }
@@ -280,15 +291,11 @@ init_shader_program(struct gl_shader_program *prog)
    prog->FragDataIndexBindings = string_to_uint_map_ctor();
 
    prog->Geom.UsesEndPrimitive = false;
-   prog->Geom.UsesStreams = false;
-
-   prog->Comp.LocalSizeVariable = false;
+   prog->Geom.ActiveStreamMask = 0;
 
    prog->TransformFeedback.BufferMode = GL_INTERLEAVED_ATTRIBS;
 
    exec_list_make_empty(&prog->EmptyUniformLocations);
-
-   prog->data->InfoLog = ralloc_strdup(prog->data, "");
 }
 
 /**
@@ -301,7 +308,7 @@ _mesa_new_shader_program(GLuint name)
    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;
@@ -326,17 +333,6 @@ _mesa_clear_shader_program_data(struct gl_context *ctx,
       }
    }
 
-   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;
@@ -348,27 +344,12 @@ _mesa_clear_shader_program_data(struct gl_context *ctx,
       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;
-
-   ralloc_free(shProg->data->AtomicBuffers);
-   shProg->data->AtomicBuffers = NULL;
-   shProg->data->NumAtomicBuffers = 0;
-
-   if (shProg->ProgramResourceList) {
-      ralloc_free(shProg->ProgramResourceList);
-      shProg->ProgramResourceList = NULL;
-      shProg->NumProgramResourceList = 0;
+   if (shProg->data && shProg->data->ProgramResourceHash) {
+      _mesa_hash_table_u64_destroy(shProg->data->ProgramResourceHash, NULL);
+      shProg->data->ProgramResourceHash = NULL;
    }
+
+   _mesa_reference_shader_program_data(ctx, &shProg->data, NULL);
 }
 
 
@@ -431,7 +412,6 @@ _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);
    ralloc_free(shProg);
 }