xref: /third_party/mesa3d/src/mesa/main/uniforms.h (revision bf215546)
1/*
2 * Mesa 3-D graphics library
3 *
4 * Copyright (C) 2010  VMware, Inc.  All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included
14 * in all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 * OTHER DEALINGS IN THE SOFTWARE.
23 */
24
25
26#ifndef UNIFORMS_H
27#define UNIFORMS_H
28
29#include "main/glheader.h"
30#include "compiler/glsl_types.h"
31#include "compiler/glsl/ir_uniform.h"
32#include "program/prog_parameter.h"
33
34#ifdef __cplusplus
35extern "C" {
36#endif
37
38
39struct gl_program;
40struct _glapi_table;
41
42void
43_mesa_uniform(GLint location, GLsizei count, const GLvoid *values,
44              struct gl_context *, struct gl_shader_program *,
45              enum glsl_base_type basicType, unsigned src_components);
46
47void
48_mesa_uniform_matrix(GLint location, GLsizei count,
49                     GLboolean transpose, const void *values,
50                     struct gl_context *, struct gl_shader_program *,
51                     GLuint cols, GLuint rows, enum glsl_base_type basicType);
52
53void
54_mesa_uniform_handle(GLint location, GLsizei count, const GLvoid *values,
55                     struct gl_context *, struct gl_shader_program *);
56
57void
58_mesa_get_uniform(struct gl_context *ctx, GLuint program, GLint location,
59		  GLsizei bufSize, enum glsl_base_type returnType,
60		  GLvoid *paramsOut);
61
62extern void
63_mesa_uniform_attach_driver_storage(struct gl_uniform_storage *,
64				    unsigned element_stride,
65				    unsigned vector_stride,
66				    enum gl_uniform_driver_format format,
67				    void *data);
68
69extern void
70_mesa_uniform_detach_all_driver_storage(struct gl_uniform_storage *uni);
71
72extern void
73_mesa_propagate_uniforms_to_driver_storage(struct gl_uniform_storage *uni,
74					   unsigned array_index,
75					   unsigned count);
76
77void
78_mesa_ensure_and_associate_uniform_storage(struct gl_context *ctx,
79                             struct gl_shader_program *shader_program,
80                             struct gl_program *prog, unsigned required_space);
81
82extern void
83_mesa_update_shader_textures_used(struct gl_shader_program *shProg,
84				  struct gl_program *prog);
85
86extern bool
87_mesa_sampler_uniforms_are_valid(const struct gl_shader_program *shProg,
88				 char *errMsg, size_t errMsgLength);
89extern bool
90_mesa_sampler_uniforms_pipeline_are_valid(struct gl_pipeline_object *);
91
92extern void
93_mesa_flush_vertices_for_uniforms(struct gl_context *ctx,
94                                  const struct gl_uniform_storage *uni);
95
96extern GLint
97_mesa_GetUniformLocation_impl(GLuint programObj, const GLcharARB *name,
98                              bool glthread);
99
100extern void
101_mesa_GetActiveUniform_impl(GLuint program, GLuint index,
102                            GLsizei maxLength, GLsizei *length, GLint *size,
103                            GLenum *type, GLcharARB *nameOut, bool glthread);
104
105struct gl_builtin_uniform_element {
106   const char *field;
107   gl_state_index16 tokens[STATE_LENGTH];
108   int swizzle;
109};
110
111struct gl_builtin_uniform_desc {
112   const char *name;
113   const struct gl_builtin_uniform_element *elements;
114   unsigned int num_elements;
115};
116
117#ifdef __cplusplus
118}
119#endif
120
121
122#endif /* UNIFORMS_H */
123