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 "glheader.h" 32 #include "compiler/shader_enums.h" 33 #include "util/mesa-sha1.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 void 92 _mesa_copy_linked_program_data(const struct gl_shader_program *src, 93 struct gl_linked_shader *dst_sh); 94 95 extern bool 96 _mesa_validate_shader_target(const struct gl_context *ctx, GLenum type); 97 98 99 /* GL_ARB_program_resource_query */ 100 extern const char* 101 _mesa_program_resource_name(struct gl_program_resource *res); 102 103 int 104 _mesa_program_resource_name_length(struct gl_program_resource *res); 105 106 bool 107 _mesa_program_get_resource_name(struct gl_program_resource *res, 108 struct gl_resource_name *out); 109 110 extern unsigned 111 _mesa_program_resource_array_size(struct gl_program_resource *res); 112 113 extern GLuint 114 _mesa_program_resource_index(struct gl_shader_program *shProg, 115 struct gl_program_resource *res); 116 117 extern struct gl_program_resource * 118 _mesa_program_resource_find_name(struct gl_shader_program *shProg, 119 GLenum programInterface, const char *name, 120 unsigned *array_index); 121 122 extern struct gl_program_resource * 123 _mesa_program_resource_find_index(struct gl_shader_program *shProg, 124 GLenum programInterface, GLuint index); 125 126 extern struct gl_program_resource * 127 _mesa_program_resource_find_active_variable(struct gl_shader_program *shProg, 128 GLenum programInterface, 129 const struct gl_uniform_block *block, 130 unsigned index); 131 132 extern bool 133 _mesa_get_program_resource_name(struct gl_shader_program *shProg, 134 GLenum programInterface, GLuint index, 135 GLsizei bufSize, GLsizei *length, 136 GLchar *name, bool glthread, 137 const char *caller); 138 139 extern unsigned 140 _mesa_program_resource_name_length_array(struct gl_program_resource *res); 141 142 extern GLint 143 _mesa_program_resource_location(struct gl_shader_program *shProg, 144 GLenum programInterface, const char *name); 145 146 extern GLint 147 _mesa_program_resource_location_index(struct gl_shader_program *shProg, 148 GLenum programInterface, const char *name); 149 150 extern unsigned 151 _mesa_program_resource_prop(struct gl_shader_program *shProg, 152 struct gl_program_resource *res, GLuint index, 153 const GLenum prop, GLint *val, bool glthread, 154 const char *caller); 155 156 extern void 157 _mesa_get_program_resourceiv(struct gl_shader_program *shProg, 158 GLenum programInterface, GLuint index, 159 GLsizei propCount, const GLenum *props, 160 GLsizei bufSize, GLsizei *length, 161 GLint *params); 162 163 extern void 164 _mesa_get_program_interfaceiv(struct gl_shader_program *shProg, 165 GLenum programInterface, GLenum pname, 166 GLint *params); 167 168 extern void 169 _mesa_program_resource_hash_destroy(struct gl_shader_program *shProg); 170 171 extern void 172 _mesa_create_program_resource_hash(struct gl_shader_program *shProg); 173 174 /* GL_ARB_shader_subroutine */ 175 void 176 _mesa_program_init_subroutine_defaults(struct gl_context *ctx, 177 struct gl_program *prog); 178 179 GLcharARB * 180 _mesa_read_shader_source(const gl_shader_stage stage, const char *source, 181 const uint8_t sha1[SHA1_DIGEST_LENGTH]); 182 183 void 184 _mesa_dump_shader_source(const gl_shader_stage stage, const char *source, 185 const uint8_t sha1[SHA1_DIGEST_LENGTH]); 186 187 void 188 _mesa_init_shader_includes(struct gl_shared_state *shared); 189 190 size_t 191 _mesa_get_shader_include_cursor(struct gl_shared_state *shared); 192 193 void 194 _mesa_set_shader_include_cursor(struct gl_shared_state *shared, size_t cusor); 195 196 void 197 _mesa_destroy_shader_includes(struct gl_shared_state *shared); 198 199 const char * 200 _mesa_lookup_shader_include(struct gl_context *ctx, char *path, 201 bool error_check); 202 203 #ifdef __cplusplus 204 } 205 #endif 206 207 #endif /* SHADERAPI_H */ 208