xref: /aosp_15_r20/external/mesa3d/src/mesa/main/shaderapi.h (revision 6104692788411f58d303aa86923a9ff6ecaded22)
1 /*
2  * Mesa 3-D graphics library
3  *
4  * Copyright (C) 2004-2007  Brian Paul   All Rights Reserved.
5  * Copyright (C) 2010  VMware, Inc.  All Rights Reserved.
6  *
7  * Permission is hereby granted, free of charge, to any person obtaining a
8  * copy of this software and associated documentation files (the "Software"),
9  * to deal in the Software without restriction, including without limitation
10  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11  * and/or sell copies of the Software, and to permit persons to whom the
12  * Software is furnished to do so, subject to the following conditions:
13  *
14  * The above copyright notice and this permission notice shall be included
15  * in all copies or substantial portions of the Software.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
20  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
21  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23  * OTHER DEALINGS IN THE SOFTWARE.
24  */
25 
26 
27 #ifndef SHADERAPI_H
28 #define SHADERAPI_H
29 
30 
31 #include "util/glheader.h"
32 #include "compiler/shader_enums.h"
33 #include "util/mesa-blake3.h"
34 
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38 
39 struct hash_entry;
40 struct _glapi_table;
41 struct gl_context;
42 struct gl_linked_shader;
43 struct gl_pipeline_object;
44 struct gl_program;
45 struct gl_program_resource;
46 struct gl_shader;
47 struct gl_shader_program;
48 struct gl_resource_name;
49 struct gl_shared_state;
50 struct gl_uniform_block;
51 
52 extern GLbitfield
53 _mesa_get_shader_flags(void);
54 
55 extern const char *
56 _mesa_get_shader_capture_path(void);
57 
58 extern void
59 _mesa_copy_string(GLchar *dst, GLsizei maxLength,
60                   GLsizei *length, const GLchar *src);
61 
62 extern void
63 _mesa_use_shader_program(struct gl_context *ctx,
64                          struct gl_shader_program *shProg);
65 
66 extern void
67 _mesa_active_program(struct gl_context *ctx, struct gl_shader_program *shProg,
68 		     const char *caller);
69 
70 extern void
71 _mesa_compile_shader(struct gl_context *ctx, struct gl_shader *sh);
72 
73 extern void
74 _mesa_link_program(struct gl_context *ctx, struct gl_shader_program *sh_prog);
75 
76 extern unsigned
77 _mesa_count_active_attribs(struct gl_shader_program *shProg);
78 
79 extern size_t
80 _mesa_longest_attribute_name_length(struct gl_shader_program *shProg);
81 
82 extern void
83 _mesa_shader_write_subroutine_indices(struct gl_context *ctx,
84                                       gl_shader_stage stage);
85 
86 void
87 _mesa_use_program(struct gl_context *ctx, gl_shader_stage stage,
88                   struct gl_shader_program *shProg, struct gl_program *prog,
89                   struct gl_pipeline_object *shTarget);
90 
91 extern bool
92 _mesa_validate_shader_target(const struct gl_context *ctx, GLenum type);
93 
94 
95 /* GL_ARB_program_resource_query */
96 extern const char*
97 _mesa_program_resource_name(struct gl_program_resource *res);
98 
99 int
100 _mesa_program_resource_name_length(struct gl_program_resource *res);
101 
102 bool
103 _mesa_program_get_resource_name(struct gl_program_resource *res,
104                                 struct gl_resource_name *out);
105 
106 extern unsigned
107 _mesa_program_resource_array_size(struct gl_program_resource *res);
108 
109 extern GLuint
110 _mesa_program_resource_index(struct gl_shader_program *shProg,
111                              struct gl_program_resource *res);
112 
113 extern struct gl_program_resource *
114 _mesa_program_resource_find_name(struct gl_shader_program *shProg,
115                                  GLenum programInterface, const char *name,
116                                  unsigned *array_index);
117 
118 extern struct gl_program_resource *
119 _mesa_program_resource_find_index(struct gl_shader_program *shProg,
120                                   GLenum programInterface, GLuint index);
121 
122 extern struct gl_program_resource *
123 _mesa_program_resource_find_active_variable(struct gl_shader_program *shProg,
124                                             GLenum programInterface,
125                                             const struct gl_uniform_block *block,
126                                             unsigned index);
127 
128 extern bool
129 _mesa_get_program_resource_name(struct gl_shader_program *shProg,
130                                 GLenum programInterface, GLuint index,
131                                 GLsizei bufSize, GLsizei *length,
132                                 GLchar *name, bool glthread,
133                                 const char *caller);
134 
135 extern unsigned
136 _mesa_program_resource_name_length_array(struct gl_program_resource *res);
137 
138 extern GLint
139 _mesa_program_resource_location(struct gl_shader_program *shProg,
140                                 GLenum programInterface, const char *name);
141 
142 extern GLint
143 _mesa_program_resource_location_index(struct gl_shader_program *shProg,
144                                       GLenum programInterface, const char *name);
145 
146 extern unsigned
147 _mesa_program_resource_prop(struct gl_shader_program *shProg,
148                             struct gl_program_resource *res, GLuint index,
149                             const GLenum prop, GLint *val, bool glthread,
150                             const char *caller);
151 
152 extern void
153 _mesa_get_program_resourceiv(struct gl_shader_program *shProg,
154                              GLenum programInterface, GLuint index,
155                              GLsizei propCount, const GLenum *props,
156                              GLsizei bufSize, GLsizei *length,
157                              GLint *params);
158 
159 extern void
160 _mesa_get_program_interfaceiv(struct gl_shader_program *shProg,
161                               GLenum programInterface, GLenum pname,
162                               GLint *params);
163 
164 extern void
165 _mesa_program_resource_hash_destroy(struct gl_shader_program *shProg);
166 
167 extern void
168 _mesa_create_program_resource_hash(struct gl_shader_program *shProg);
169 
170 /* GL_ARB_shader_subroutine */
171 void
172 _mesa_program_init_subroutine_defaults(struct gl_context *ctx,
173                                        struct gl_program *prog);
174 
175 GLcharARB *
176 _mesa_read_shader_source(const gl_shader_stage stage, const char *source,
177                          const blake3_hash blake3);
178 
179 void
180 _mesa_dump_shader_source(const gl_shader_stage stage, const char *source,
181                          const blake3_hash blake3);
182 
183 void
184 _mesa_init_shader_includes(struct gl_shared_state *shared);
185 
186 size_t
187 _mesa_get_shader_include_cursor(struct gl_shared_state *shared);
188 
189 void
190 _mesa_set_shader_include_cursor(struct gl_shared_state *shared, size_t cusor);
191 
192 void
193 _mesa_destroy_shader_includes(struct gl_shared_state *shared);
194 
195 const char *
196 _mesa_lookup_shader_include(struct gl_context *ctx, char *path,
197                             bool error_check);
198 
199 GLuint
200 _mesa_CreateShaderProgramv_impl(struct gl_context *ctx,
201                                 GLenum type, GLsizei count,
202                                 const GLchar* const *strings);
203 #ifdef __cplusplus
204 }
205 #endif
206 
207 #endif /* SHADERAPI_H */
208