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