2011-10-11 17:16:18 -07:00
|
|
|
/*
|
|
|
|
* Copyright © 2011 Intel Corporation
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice (including the next
|
|
|
|
* paragraph) shall be included in all copies or substantial portions of the
|
|
|
|
* Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
|
|
* DEALINGS IN THE SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef IR_UNIFORM_H
|
|
|
|
#define IR_UNIFORM_H
|
|
|
|
|
|
|
|
|
|
|
|
/* stdbool.h is necessary because this file is included in both C and C++ code.
|
|
|
|
*/
|
|
|
|
#include <stdbool.h>
|
2018-04-08 13:13:08 -04:00
|
|
|
#include "util/macros.h"
|
2011-10-11 17:16:18 -07:00
|
|
|
#include "program/prog_parameter.h" /* For union gl_constant_value. */
|
|
|
|
|
2014-04-08 08:45:36 +03:00
|
|
|
/**
|
|
|
|
* Used by GL_ARB_explicit_uniform_location extension code in the linker
|
|
|
|
* and glUniform* functions to identify inactive explicit uniform locations.
|
|
|
|
*/
|
|
|
|
#define INACTIVE_UNIFORM_EXPLICIT_LOCATION ((gl_uniform_storage *) -1)
|
2011-11-09 10:20:51 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2014-06-10 10:41:32 -07:00
|
|
|
enum PACKED gl_uniform_driver_format {
|
2011-10-11 17:16:18 -07:00
|
|
|
uniform_native = 0, /**< Store data in the native format. */
|
|
|
|
uniform_int_float, /**< Store integer data as floats. */
|
|
|
|
};
|
|
|
|
|
|
|
|
struct gl_uniform_driver_storage {
|
|
|
|
/**
|
|
|
|
* Number of bytes from one array element to the next.
|
|
|
|
*/
|
|
|
|
uint8_t element_stride;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Number of bytes from one vector in a matrix to the next.
|
|
|
|
*/
|
|
|
|
uint8_t vector_stride;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Base format of the stored data.
|
|
|
|
*/
|
2014-06-10 10:41:32 -07:00
|
|
|
enum gl_uniform_driver_format format;
|
2011-10-11 17:16:18 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Pointer to the base of the data.
|
|
|
|
*/
|
|
|
|
void *data;
|
|
|
|
};
|
|
|
|
|
2013-11-22 15:50:48 -08:00
|
|
|
struct gl_opaque_uniform_index {
|
|
|
|
/**
|
|
|
|
* Base opaque uniform index
|
|
|
|
*
|
|
|
|
* If \c gl_uniform_storage::base_type is an opaque type, this
|
|
|
|
* represents its uniform index. If \c
|
|
|
|
* gl_uniform_storage::array_elements is not zero, the array will
|
|
|
|
* use opaque uniform indices \c index through \c index + \c
|
|
|
|
* gl_uniform_storage::array_elements - 1, inclusive.
|
|
|
|
*
|
|
|
|
* Note that the index may be different in each shader stage.
|
|
|
|
*/
|
|
|
|
uint8_t index;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether this opaque uniform is used in this shader stage.
|
|
|
|
*/
|
|
|
|
bool active;
|
|
|
|
};
|
|
|
|
|
2011-10-11 17:16:18 -07:00
|
|
|
struct gl_uniform_storage {
|
|
|
|
char *name;
|
2012-11-20 18:53:34 -08:00
|
|
|
/** Type of this uniform data stored.
|
|
|
|
*
|
|
|
|
* In the case of an array, it's the type of a single array element.
|
|
|
|
*/
|
2011-10-11 17:16:18 -07:00
|
|
|
const struct glsl_type *type;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The number of elements in this uniform.
|
|
|
|
*
|
|
|
|
* For non-arrays, this is always 0. For arrays, the value is the size of
|
|
|
|
* the array.
|
|
|
|
*/
|
|
|
|
unsigned array_elements;
|
|
|
|
|
2015-09-30 11:00:02 +10:00
|
|
|
struct gl_opaque_uniform_index opaque[MESA_SHADER_STAGES];
|
2015-04-20 10:27:36 +10:00
|
|
|
|
2014-09-13 11:13:26 -07:00
|
|
|
/**
|
|
|
|
* Mask of shader stages (1 << MESA_SHADER_xxx) where this uniform is used.
|
|
|
|
*/
|
|
|
|
unsigned active_shader_mask;
|
|
|
|
|
2011-10-11 17:16:18 -07:00
|
|
|
/**
|
|
|
|
* Storage used by the driver for the uniform
|
|
|
|
*/
|
|
|
|
unsigned num_driver_storage;
|
|
|
|
struct gl_uniform_driver_storage *driver_storage;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Storage used by Mesa for the uniform
|
|
|
|
*
|
|
|
|
* This form of the uniform is used by Mesa's implementation of \c
|
|
|
|
* glGetUniform. It can also be used by drivers to obtain the value of the
|
|
|
|
* uniform if the \c ::driver_storage interface is not used.
|
|
|
|
*/
|
|
|
|
union gl_constant_value *storage;
|
2012-05-01 13:59:31 -07:00
|
|
|
|
|
|
|
/** Fields for GL_ARB_uniform_buffer_object
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* GL_UNIFORM_BLOCK_INDEX: index of the uniform block containing
|
|
|
|
* the uniform, or -1 for the default uniform block. Note that the
|
|
|
|
* index is into the linked program's UniformBlocks[] array, not
|
|
|
|
* the linked shader's.
|
|
|
|
*/
|
|
|
|
int block_index;
|
|
|
|
|
|
|
|
/** GL_UNIFORM_OFFSET: byte offset within the uniform block, or -1. */
|
|
|
|
int offset;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* GL_UNIFORM_MATRIX_STRIDE: byte stride between columns or rows of
|
|
|
|
* a matrix. Set to 0 for non-matrices in UBOs, or -1 for uniforms
|
|
|
|
* in the default uniform block.
|
|
|
|
*/
|
|
|
|
int matrix_stride;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* GL_UNIFORM_ARRAY_STRIDE: byte stride between elements of the
|
|
|
|
* array. Set to zero for non-arrays in UBOs, or -1 for uniforms
|
|
|
|
* in the default uniform block.
|
|
|
|
*/
|
|
|
|
int array_stride;
|
|
|
|
|
|
|
|
/** GL_UNIFORM_ROW_MAJOR: true iff it's a row-major matrix in a UBO */
|
|
|
|
bool row_major;
|
|
|
|
|
|
|
|
/** @} */
|
2013-10-07 18:53:40 -07:00
|
|
|
|
2015-10-13 14:17:49 +03:00
|
|
|
/**
|
|
|
|
* This is a compiler-generated uniform that should not be advertised
|
|
|
|
* via the API.
|
|
|
|
*/
|
|
|
|
bool hidden;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This is a built-in uniform that should not be modified through any gl API.
|
|
|
|
*/
|
|
|
|
bool builtin;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This is a shader storage buffer variable, not an uniform.
|
|
|
|
*/
|
|
|
|
bool is_shader_storage;
|
|
|
|
|
2013-10-07 18:53:40 -07:00
|
|
|
/**
|
|
|
|
* Index within gl_shader_program::AtomicBuffers[] of the atomic
|
|
|
|
* counter buffer this uniform is stored in, or -1 if this is not
|
|
|
|
* an atomic counter.
|
|
|
|
*/
|
|
|
|
int atomic_buffer_index;
|
2014-03-06 11:00:17 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The 'base location' for this uniform in the uniform remap table. For
|
|
|
|
* arrays this is the first element in the array.
|
2015-04-20 10:27:36 +10:00
|
|
|
* for subroutines this is in shader subroutine uniform remap table.
|
2014-03-06 11:00:17 +02:00
|
|
|
*/
|
|
|
|
unsigned remap_location;
|
2014-10-27 16:34:06 -07:00
|
|
|
|
2015-04-20 10:27:36 +10:00
|
|
|
/**
|
|
|
|
* The number of compatible subroutines with this subroutine uniform.
|
|
|
|
*/
|
|
|
|
unsigned num_compatible_subroutines;
|
|
|
|
|
2014-10-27 16:34:06 -07:00
|
|
|
/**
|
2015-10-13 14:17:49 +03:00
|
|
|
* A single integer identifying the number of active array elements of
|
|
|
|
* the top-level shader storage block member (GL_TOP_LEVEL_ARRAY_SIZE).
|
2014-10-27 16:34:06 -07:00
|
|
|
*/
|
2015-10-13 14:17:49 +03:00
|
|
|
unsigned top_level_array_size;
|
2015-05-21 15:51:09 +03:00
|
|
|
|
|
|
|
/**
|
2015-10-13 14:17:49 +03:00
|
|
|
* A single integer identifying the stride between array elements of the
|
|
|
|
* top-level shader storage block member. (GL_TOP_LEVEL_ARRAY_STRIDE).
|
2015-05-21 15:51:09 +03:00
|
|
|
*/
|
2015-10-13 14:17:49 +03:00
|
|
|
unsigned top_level_array_stride;
|
2017-02-24 19:24:56 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether this uniform variable has the bindless_sampler or bindless_image
|
|
|
|
* layout qualifier as specified by ARB_bindless_texture.
|
|
|
|
*/
|
|
|
|
bool is_bindless;
|
2011-10-11 17:16:18 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* IR_UNIFORM_H */
|