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 36extern "C" { 37#endif 38 39struct hash_entry; 40struct _glapi_table; 41struct gl_context; 42struct gl_linked_shader; 43struct gl_pipeline_object; 44struct gl_program; 45struct gl_program_resource; 46struct gl_shader; 47struct gl_shader_program; 48struct gl_resource_name; 49struct gl_shared_state; 50struct gl_uniform_block; 51 52extern GLbitfield 53_mesa_get_shader_flags(void); 54 55extern const char * 56_mesa_get_shader_capture_path(void); 57 58extern void 59_mesa_copy_string(GLchar *dst, GLsizei maxLength, 60 GLsizei *length, const GLchar *src); 61 62extern void 63_mesa_use_shader_program(struct gl_context *ctx, 64 struct gl_shader_program *shProg); 65 66extern void 67_mesa_active_program(struct gl_context *ctx, struct gl_shader_program *shProg, 68 const char *caller); 69 70extern void 71_mesa_compile_shader(struct gl_context *ctx, struct gl_shader *sh); 72 73extern void 74_mesa_link_program(struct gl_context *ctx, struct gl_shader_program *sh_prog); 75 76extern unsigned 77_mesa_count_active_attribs(struct gl_shader_program *shProg); 78 79extern size_t 80_mesa_longest_attribute_name_length(struct gl_shader_program *shProg); 81 82extern void 83_mesa_shader_write_subroutine_indices(struct gl_context *ctx, 84 gl_shader_stage stage); 85 86void 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 91extern void 92_mesa_copy_linked_program_data(const struct gl_shader_program *src, 93 struct gl_linked_shader *dst_sh); 94 95extern bool 96_mesa_validate_shader_target(const struct gl_context *ctx, GLenum type); 97 98 99/* GL_ARB_program_resource_query */ 100extern const char* 101_mesa_program_resource_name(struct gl_program_resource *res); 102 103int 104_mesa_program_resource_name_length(struct gl_program_resource *res); 105 106bool 107_mesa_program_get_resource_name(struct gl_program_resource *res, 108 struct gl_resource_name *out); 109 110extern unsigned 111_mesa_program_resource_array_size(struct gl_program_resource *res); 112 113extern GLuint 114_mesa_program_resource_index(struct gl_shader_program *shProg, 115 struct gl_program_resource *res); 116 117extern 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 122extern struct gl_program_resource * 123_mesa_program_resource_find_index(struct gl_shader_program *shProg, 124 GLenum programInterface, GLuint index); 125 126extern 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 132extern 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 139extern unsigned 140_mesa_program_resource_name_length_array(struct gl_program_resource *res); 141 142extern GLint 143_mesa_program_resource_location(struct gl_shader_program *shProg, 144 GLenum programInterface, const char *name); 145 146extern GLint 147_mesa_program_resource_location_index(struct gl_shader_program *shProg, 148 GLenum programInterface, const char *name); 149 150extern 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 156extern 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 163extern void 164_mesa_get_program_interfaceiv(struct gl_shader_program *shProg, 165 GLenum programInterface, GLenum pname, 166 GLint *params); 167 168extern void 169_mesa_program_resource_hash_destroy(struct gl_shader_program *shProg); 170 171extern void 172_mesa_create_program_resource_hash(struct gl_shader_program *shProg); 173 174/* GL_ARB_shader_subroutine */ 175void 176_mesa_program_init_subroutine_defaults(struct gl_context *ctx, 177 struct gl_program *prog); 178 179GLcharARB * 180_mesa_read_shader_source(const gl_shader_stage stage, const char *source, 181 const uint8_t sha1[SHA1_DIGEST_LENGTH]); 182 183void 184_mesa_dump_shader_source(const gl_shader_stage stage, const char *source, 185 const uint8_t sha1[SHA1_DIGEST_LENGTH]); 186 187void 188_mesa_init_shader_includes(struct gl_shared_state *shared); 189 190size_t 191_mesa_get_shader_include_cursor(struct gl_shared_state *shared); 192 193void 194_mesa_set_shader_include_cursor(struct gl_shared_state *shared, size_t cusor); 195 196void 197_mesa_destroy_shader_includes(struct gl_shared_state *shared); 198 199const 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