1 #include <stdlib.h>
2 #include <assert.h>
3
4 #include <GLES2/gl2.h>
5
6 #include "src/mesa/main/mtypes.h"
7 #include "src/talloc/hieralloc.h"
8
_mesa_reference_shader(const void * ctx,struct gl_shader ** ptr,struct gl_shader * sh)9 void _mesa_reference_shader(const void * ctx, struct gl_shader **ptr,
10 struct gl_shader *sh)
11 {
12 *ptr = sh;
13 }
14
_mesa_new_shader(const void * ctx,GLuint name,GLenum type)15 struct gl_shader * _mesa_new_shader(const void * ctx, GLuint name, GLenum type)
16 {
17 assert(type == GL_FRAGMENT_SHADER || type == GL_VERTEX_SHADER);
18 struct gl_shader * shader = (struct gl_shader *)_hieralloc_zero(ctx, sizeof(struct gl_shader), "zr:gl_shader");
19 if (shader) {
20 shader->Type = type;
21 shader->Name = name;
22 shader->RefCount = 1;
23 }
24 return shader;
25 }
26
_mesa_delete_shader(const void * ctx,struct gl_shader * shader)27 void _mesa_delete_shader(const void * ctx, struct gl_shader *shader)
28 {
29 if (!shader)
30 return;
31 if (shader->RefCount > 1) {
32 shader->DeletePending = GL_TRUE;
33 return;
34 }
35 hieralloc_free(shader);
36 }
37