Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
4358 Serge 1
/*
2
 * Copyright © 2011 Intel Corporation
3
 *
4
 * Permission is hereby granted, free of charge, to any person obtaining a
5
 * copy of this software and associated documentation files (the "Software"),
6
 * to deal in the Software without restriction, including without limitation
7
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8
 * and/or sell copies of the Software, and to permit persons to whom the
9
 * Software is furnished to do so, subject to the following conditions:
10
 *
11
 * The above copyright notice and this permission notice (including the next
12
 * paragraph) shall be included in all copies or substantial portions of the
13
 * Software.
14
 *
15
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21
 * DEALINGS IN THE SOFTWARE.
22
 */
23
 
24
#pragma once
25
#ifndef IR_UNIFORM_H
26
#define IR_UNIFORM_H
27
 
28
 
29
/* stdbool.h is necessary because this file is included in both C and C++ code.
30
 */
31
#include 
32
 
33
#include "program/prog_parameter.h"  /* For union gl_constant_value. */
34
 
35
 
36
#ifdef __cplusplus
37
extern "C" {
38
#endif
39
 
40
enum gl_uniform_driver_format {
41
   uniform_native = 0,          /**< Store data in the native format. */
42
   uniform_int_float,           /**< Store integer data as floats. */
43
   uniform_bool_float,          /**< Store boolean data as floats. */
44
 
45
   /**
46
    * Store boolean data as integer using 1 for \c true.
47
    */
48
   uniform_bool_int_0_1,
49
 
50
   /**
51
    * Store boolean data as integer using ~0 for \c true.
52
    */
53
   uniform_bool_int_0_not0
54
};
55
 
56
struct gl_uniform_driver_storage {
57
   /**
58
    * Number of bytes from one array element to the next.
59
    */
60
   uint8_t element_stride;
61
 
62
   /**
63
    * Number of bytes from one vector in a matrix to the next.
64
    */
65
   uint8_t vector_stride;
66
 
67
   /**
68
    * Base format of the stored data.
69
    *
70
    * This field must have a value from \c GLSL_TYPE_UINT through \c
71
    * GLSL_TYPE_SAMPLER.
72
    */
73
   uint8_t format;
74
 
75
   /**
76
    * Pointer to the base of the data.
77
    */
78
   void *data;
79
};
80
 
81
struct gl_uniform_storage {
82
   char *name;
83
   /** Type of this uniform data stored.
84
    *
85
    * In the case of an array, it's the type of a single array element.
86
    */
87
   const struct glsl_type *type;
88
 
89
   /**
90
    * The number of elements in this uniform.
91
    *
92
    * For non-arrays, this is always 0.  For arrays, the value is the size of
93
    * the array.
94
    */
95
   unsigned array_elements;
96
 
97
   /**
98
    * Has this uniform ever been set?
99
    */
100
   bool initialized;
101
 
102
   struct {
103
      /**
104
       * Base sampler index
105
       *
106
       * If \c ::base_type is \c GLSL_TYPE_SAMPLER, this represents the index
107
       * of this sampler.  If \c ::array_elements is not zero, the array will
108
       * use sampler indices \c ::sampler through \c ::sampler +
109
       * \c ::array_elements - 1, inclusive.
110
       *
111
       * Note that the index may be different in each shader stage.
112
       */
113
      uint8_t index;
114
 
115
      /**
116
       * Whether this sampler is used in this shader stage.
117
       */
118
      bool active;
119
   } sampler[MESA_SHADER_TYPES];
120
 
121
   /**
122
    * Storage used by the driver for the uniform
123
    */
124
   unsigned num_driver_storage;
125
   struct gl_uniform_driver_storage *driver_storage;
126
 
127
   /**
128
    * Storage used by Mesa for the uniform
129
    *
130
    * This form of the uniform is used by Mesa's implementation of \c
131
    * glGetUniform.  It can also be used by drivers to obtain the value of the
132
    * uniform if the \c ::driver_storage interface is not used.
133
    */
134
   union gl_constant_value *storage;
135
 
136
   /** Fields for GL_ARB_uniform_buffer_object
137
    * @{
138
    */
139
 
140
   /**
141
    * GL_UNIFORM_BLOCK_INDEX: index of the uniform block containing
142
    * the uniform, or -1 for the default uniform block.  Note that the
143
    * index is into the linked program's UniformBlocks[] array, not
144
    * the linked shader's.
145
    */
146
   int block_index;
147
 
148
   /** GL_UNIFORM_OFFSET: byte offset within the uniform block, or -1. */
149
   int offset;
150
 
151
   /**
152
    * GL_UNIFORM_MATRIX_STRIDE: byte stride between columns or rows of
153
    * a matrix.  Set to 0 for non-matrices in UBOs, or -1 for uniforms
154
    * in the default uniform block.
155
    */
156
   int matrix_stride;
157
 
158
   /**
159
    * GL_UNIFORM_ARRAY_STRIDE: byte stride between elements of the
160
    * array.  Set to zero for non-arrays in UBOs, or -1 for uniforms
161
    * in the default uniform block.
162
    */
163
   int array_stride;
164
 
165
   /** GL_UNIFORM_ROW_MAJOR: true iff it's a row-major matrix in a UBO */
166
   bool row_major;
167
 
168
   /** @} */
169
};
170
 
171
#ifdef __cplusplus
172
}
173
#endif
174
 
175
#endif /* IR_UNIFORM_H */