14b11b57ab47b98b335a7212080dbccef04542805Paul Berry/* 24b11b57ab47b98b335a7212080dbccef04542805Paul Berry * Copyright © 2012 Intel Corporation 34b11b57ab47b98b335a7212080dbccef04542805Paul Berry * 44b11b57ab47b98b335a7212080dbccef04542805Paul Berry * Permission is hereby granted, free of charge, to any person obtaining a 54b11b57ab47b98b335a7212080dbccef04542805Paul Berry * copy of this software and associated documentation files (the "Software"), 64b11b57ab47b98b335a7212080dbccef04542805Paul Berry * to deal in the Software without restriction, including without limitation 74b11b57ab47b98b335a7212080dbccef04542805Paul Berry * the rights to use, copy, modify, merge, publish, distribute, sublicense, 84b11b57ab47b98b335a7212080dbccef04542805Paul Berry * and/or sell copies of the Software, and to permit persons to whom the 94b11b57ab47b98b335a7212080dbccef04542805Paul Berry * Software is furnished to do so, subject to the following conditions: 104b11b57ab47b98b335a7212080dbccef04542805Paul Berry * 114b11b57ab47b98b335a7212080dbccef04542805Paul Berry * The above copyright notice and this permission notice (including the next 124b11b57ab47b98b335a7212080dbccef04542805Paul Berry * paragraph) shall be included in all copies or substantial portions of the 134b11b57ab47b98b335a7212080dbccef04542805Paul Berry * Software. 144b11b57ab47b98b335a7212080dbccef04542805Paul Berry * 154b11b57ab47b98b335a7212080dbccef04542805Paul Berry * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 164b11b57ab47b98b335a7212080dbccef04542805Paul Berry * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 174b11b57ab47b98b335a7212080dbccef04542805Paul Berry * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 184b11b57ab47b98b335a7212080dbccef04542805Paul Berry * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 194b11b57ab47b98b335a7212080dbccef04542805Paul Berry * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 204b11b57ab47b98b335a7212080dbccef04542805Paul Berry * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 214b11b57ab47b98b335a7212080dbccef04542805Paul Berry * DEALINGS IN THE SOFTWARE. 224b11b57ab47b98b335a7212080dbccef04542805Paul Berry */ 234b11b57ab47b98b335a7212080dbccef04542805Paul Berry 244b11b57ab47b98b335a7212080dbccef04542805Paul Berry#pragma once 254b11b57ab47b98b335a7212080dbccef04542805Paul Berry#ifndef GLSL_LINK_VARYINGS_H 264b11b57ab47b98b335a7212080dbccef04542805Paul Berry#define GLSL_LINK_VARYINGS_H 274b11b57ab47b98b335a7212080dbccef04542805Paul Berry 284b11b57ab47b98b335a7212080dbccef04542805Paul Berry/** 294b11b57ab47b98b335a7212080dbccef04542805Paul Berry * \file link_varyings.h 304b11b57ab47b98b335a7212080dbccef04542805Paul Berry * 314b11b57ab47b98b335a7212080dbccef04542805Paul Berry * Linker functions related specifically to linking varyings between shader 324b11b57ab47b98b335a7212080dbccef04542805Paul Berry * stages. 334b11b57ab47b98b335a7212080dbccef04542805Paul Berry */ 344b11b57ab47b98b335a7212080dbccef04542805Paul Berry 354b11b57ab47b98b335a7212080dbccef04542805Paul Berry 364b11b57ab47b98b335a7212080dbccef04542805Paul Berry#include "main/glheader.h" 374b11b57ab47b98b335a7212080dbccef04542805Paul Berry 384b11b57ab47b98b335a7212080dbccef04542805Paul Berry 394b11b57ab47b98b335a7212080dbccef04542805Paul Berrystruct gl_shader_program; 404b11b57ab47b98b335a7212080dbccef04542805Paul Berrystruct gl_shader; 414b11b57ab47b98b335a7212080dbccef04542805Paul Berryclass ir_variable; 424b11b57ab47b98b335a7212080dbccef04542805Paul Berry 434b11b57ab47b98b335a7212080dbccef04542805Paul Berry 444b11b57ab47b98b335a7212080dbccef04542805Paul Berry/** 4599b78337e38308480ee491493b045179f10ed579Paul Berry * Data structure describing a varying which is available for use in transform 4699b78337e38308480ee491493b045179f10ed579Paul Berry * feedback. 4799b78337e38308480ee491493b045179f10ed579Paul Berry * 4899b78337e38308480ee491493b045179f10ed579Paul Berry * For example, if the vertex shader contains: 4999b78337e38308480ee491493b045179f10ed579Paul Berry * 5099b78337e38308480ee491493b045179f10ed579Paul Berry * struct S { 5199b78337e38308480ee491493b045179f10ed579Paul Berry * vec4 foo; 5299b78337e38308480ee491493b045179f10ed579Paul Berry * float[3] bar; 5399b78337e38308480ee491493b045179f10ed579Paul Berry * }; 5499b78337e38308480ee491493b045179f10ed579Paul Berry * 5599b78337e38308480ee491493b045179f10ed579Paul Berry * varying S[2] v; 5699b78337e38308480ee491493b045179f10ed579Paul Berry * 5799b78337e38308480ee491493b045179f10ed579Paul Berry * Then there would be tfeedback_candidate objects corresponding to the 5899b78337e38308480ee491493b045179f10ed579Paul Berry * following varyings: 5999b78337e38308480ee491493b045179f10ed579Paul Berry * 6099b78337e38308480ee491493b045179f10ed579Paul Berry * v[0].foo 6199b78337e38308480ee491493b045179f10ed579Paul Berry * v[0].bar 6299b78337e38308480ee491493b045179f10ed579Paul Berry * v[1].foo 6399b78337e38308480ee491493b045179f10ed579Paul Berry * v[1].bar 6499b78337e38308480ee491493b045179f10ed579Paul Berry */ 6599b78337e38308480ee491493b045179f10ed579Paul Berrystruct tfeedback_candidate 6699b78337e38308480ee491493b045179f10ed579Paul Berry{ 6799b78337e38308480ee491493b045179f10ed579Paul Berry /** 6899b78337e38308480ee491493b045179f10ed579Paul Berry * Toplevel variable containing this varying. In the above example, this 6999b78337e38308480ee491493b045179f10ed579Paul Berry * would point to the declaration of the varying v. 7099b78337e38308480ee491493b045179f10ed579Paul Berry */ 7199b78337e38308480ee491493b045179f10ed579Paul Berry ir_variable *toplevel_var; 7299b78337e38308480ee491493b045179f10ed579Paul Berry 7399b78337e38308480ee491493b045179f10ed579Paul Berry /** 7499b78337e38308480ee491493b045179f10ed579Paul Berry * Type of this varying. In the above example, this would point to the 7599b78337e38308480ee491493b045179f10ed579Paul Berry * glsl_type for "vec4" or "float[3]". 7699b78337e38308480ee491493b045179f10ed579Paul Berry */ 7799b78337e38308480ee491493b045179f10ed579Paul Berry const glsl_type *type; 7899b78337e38308480ee491493b045179f10ed579Paul Berry 7999b78337e38308480ee491493b045179f10ed579Paul Berry /** 8099b78337e38308480ee491493b045179f10ed579Paul Berry * Offset within the toplevel variable where this varying occurs (counted 8199b78337e38308480ee491493b045179f10ed579Paul Berry * in multiples of the size of a float). 8299b78337e38308480ee491493b045179f10ed579Paul Berry */ 8399b78337e38308480ee491493b045179f10ed579Paul Berry unsigned offset; 8499b78337e38308480ee491493b045179f10ed579Paul Berry}; 8599b78337e38308480ee491493b045179f10ed579Paul Berry 8699b78337e38308480ee491493b045179f10ed579Paul Berry 8799b78337e38308480ee491493b045179f10ed579Paul Berry/** 884b11b57ab47b98b335a7212080dbccef04542805Paul Berry * Data structure tracking information about a transform feedback declaration 894b11b57ab47b98b335a7212080dbccef04542805Paul Berry * during linking. 904b11b57ab47b98b335a7212080dbccef04542805Paul Berry */ 914b11b57ab47b98b335a7212080dbccef04542805Paul Berryclass tfeedback_decl 924b11b57ab47b98b335a7212080dbccef04542805Paul Berry{ 934b11b57ab47b98b335a7212080dbccef04542805Paul Berrypublic: 94a974b915b6035d93f1739793094157272444cd1cIan Romanick void init(struct gl_context *ctx, const void *mem_ctx, const char *input); 954b11b57ab47b98b335a7212080dbccef04542805Paul Berry static bool is_same(const tfeedback_decl &x, const tfeedback_decl &y); 9699b78337e38308480ee491493b045179f10ed579Paul Berry bool assign_location(struct gl_context *ctx, 9799b78337e38308480ee491493b045179f10ed579Paul Berry struct gl_shader_program *prog); 984b11b57ab47b98b335a7212080dbccef04542805Paul Berry unsigned get_num_outputs() const; 994b11b57ab47b98b335a7212080dbccef04542805Paul Berry bool store(struct gl_context *ctx, struct gl_shader_program *prog, 1004b11b57ab47b98b335a7212080dbccef04542805Paul Berry struct gl_transform_feedback_info *info, unsigned buffer, 1019e317271d7694d912da99e524294156b6c2de96eTimothy Arceri unsigned buffer_index, const unsigned max_outputs, 1029e317271d7694d912da99e524294156b6c2de96eTimothy Arceri bool *explicit_stride, bool has_xfb_qualifiers) const; 10399b78337e38308480ee491493b045179f10ed579Paul Berry const tfeedback_candidate *find_candidate(gl_shader_program *prog, 10499b78337e38308480ee491493b045179f10ed579Paul Berry hash_table *tfeedback_candidates); 1054b11b57ab47b98b335a7212080dbccef04542805Paul Berry 1064b11b57ab47b98b335a7212080dbccef04542805Paul Berry bool is_next_buffer_separator() const 1074b11b57ab47b98b335a7212080dbccef04542805Paul Berry { 1084b11b57ab47b98b335a7212080dbccef04542805Paul Berry return this->next_buffer_separator; 1094b11b57ab47b98b335a7212080dbccef04542805Paul Berry } 1104b11b57ab47b98b335a7212080dbccef04542805Paul Berry 111c95e92b14d69c114b79d941c7e8902a0ea62c287Timothy Arceri bool is_varying_written() const 112c95e92b14d69c114b79d941c7e8902a0ea62c287Timothy Arceri { 113c95e92b14d69c114b79d941c7e8902a0ea62c287Timothy Arceri if (this->next_buffer_separator || this->skip_components) 114c95e92b14d69c114b79d941c7e8902a0ea62c287Timothy Arceri return false; 115c95e92b14d69c114b79d941c7e8902a0ea62c287Timothy Arceri 116c95e92b14d69c114b79d941c7e8902a0ea62c287Timothy Arceri return this->matched_candidate->toplevel_var->data.assigned; 117c95e92b14d69c114b79d941c7e8902a0ea62c287Timothy Arceri } 118c95e92b14d69c114b79d941c7e8902a0ea62c287Timothy Arceri 1194b11b57ab47b98b335a7212080dbccef04542805Paul Berry bool is_varying() const 1204b11b57ab47b98b335a7212080dbccef04542805Paul Berry { 1214b11b57ab47b98b335a7212080dbccef04542805Paul Berry return !this->next_buffer_separator && !this->skip_components; 1224b11b57ab47b98b335a7212080dbccef04542805Paul Berry } 1234b11b57ab47b98b335a7212080dbccef04542805Paul Berry 1241e1f071d25d67b7e82ac2248dbda419f992b10d7Iago Toral Quiroga const char *name() const 1251e1f071d25d67b7e82ac2248dbda419f992b10d7Iago Toral Quiroga { 1261e1f071d25d67b7e82ac2248dbda419f992b10d7Iago Toral Quiroga return this->orig_name; 1271e1f071d25d67b7e82ac2248dbda419f992b10d7Iago Toral Quiroga } 1281e1f071d25d67b7e82ac2248dbda419f992b10d7Iago Toral Quiroga 1291e1f071d25d67b7e82ac2248dbda419f992b10d7Iago Toral Quiroga unsigned get_stream_id() const 1301e1f071d25d67b7e82ac2248dbda419f992b10d7Iago Toral Quiroga { 1311e1f071d25d67b7e82ac2248dbda419f992b10d7Iago Toral Quiroga return this->stream_id; 1321e1f071d25d67b7e82ac2248dbda419f992b10d7Iago Toral Quiroga } 1331e1f071d25d67b7e82ac2248dbda419f992b10d7Iago Toral Quiroga 1344305a60173432635cde2f0f1dea8a715ed327bbcTimothy Arceri unsigned get_buffer() const 1354305a60173432635cde2f0f1dea8a715ed327bbcTimothy Arceri { 1364305a60173432635cde2f0f1dea8a715ed327bbcTimothy Arceri return this->buffer; 1374305a60173432635cde2f0f1dea8a715ed327bbcTimothy Arceri } 1384305a60173432635cde2f0f1dea8a715ed327bbcTimothy Arceri 1394305a60173432635cde2f0f1dea8a715ed327bbcTimothy Arceri unsigned get_offset() const 1404305a60173432635cde2f0f1dea8a715ed327bbcTimothy Arceri { 1414305a60173432635cde2f0f1dea8a715ed327bbcTimothy Arceri return this->offset; 1424305a60173432635cde2f0f1dea8a715ed327bbcTimothy Arceri } 1434305a60173432635cde2f0f1dea8a715ed327bbcTimothy Arceri 1444b11b57ab47b98b335a7212080dbccef04542805Paul Berry /** 1454b11b57ab47b98b335a7212080dbccef04542805Paul Berry * The total number of varying components taken up by this variable. Only 1464b11b57ab47b98b335a7212080dbccef04542805Paul Berry * valid if assign_location() has been called. 1474b11b57ab47b98b335a7212080dbccef04542805Paul Berry */ 1484b11b57ab47b98b335a7212080dbccef04542805Paul Berry unsigned num_components() const 1494b11b57ab47b98b335a7212080dbccef04542805Paul Berry { 15073a9a1539a85ae8fe22e11b4064105d588597736Fabian Bieler if (this->lowered_builtin_array_variable) 1514b11b57ab47b98b335a7212080dbccef04542805Paul Berry return this->size; 1524b11b57ab47b98b335a7212080dbccef04542805Paul Berry else 153b476c587e3c8ffd61e833c3252d69c5edd16c0f6Dave Airlie return this->vector_elements * this->matrix_columns * this->size * 1542df46519e4aeb330df30890c2702d96891c18964Dave Airlie (this->is_64bit() ? 2 : 1); 1554b11b57ab47b98b335a7212080dbccef04542805Paul Berry } 1564b11b57ab47b98b335a7212080dbccef04542805Paul Berry 157b3d8b4c0b423539f17c13713673cfeb6d66ff7edMarek Olšák unsigned get_location() const { 158b3d8b4c0b423539f17c13713673cfeb6d66ff7edMarek Olšák return this->location; 159b3d8b4c0b423539f17c13713673cfeb6d66ff7edMarek Olšák } 160b3d8b4c0b423539f17c13713673cfeb6d66ff7edMarek Olšák 1614b11b57ab47b98b335a7212080dbccef04542805Paul Berryprivate: 162b476c587e3c8ffd61e833c3252d69c5edd16c0f6Dave Airlie 1632df46519e4aeb330df30890c2702d96891c18964Dave Airlie bool is_64bit() const 164b476c587e3c8ffd61e833c3252d69c5edd16c0f6Dave Airlie { 165b476c587e3c8ffd61e833c3252d69c5edd16c0f6Dave Airlie switch (this->type) { 166b476c587e3c8ffd61e833c3252d69c5edd16c0f6Dave Airlie case GL_DOUBLE: 167b476c587e3c8ffd61e833c3252d69c5edd16c0f6Dave Airlie case GL_DOUBLE_VEC2: 168b476c587e3c8ffd61e833c3252d69c5edd16c0f6Dave Airlie case GL_DOUBLE_VEC3: 169b476c587e3c8ffd61e833c3252d69c5edd16c0f6Dave Airlie case GL_DOUBLE_VEC4: 170b476c587e3c8ffd61e833c3252d69c5edd16c0f6Dave Airlie case GL_DOUBLE_MAT2: 171b476c587e3c8ffd61e833c3252d69c5edd16c0f6Dave Airlie case GL_DOUBLE_MAT2x3: 172b476c587e3c8ffd61e833c3252d69c5edd16c0f6Dave Airlie case GL_DOUBLE_MAT2x4: 173b476c587e3c8ffd61e833c3252d69c5edd16c0f6Dave Airlie case GL_DOUBLE_MAT3: 174b476c587e3c8ffd61e833c3252d69c5edd16c0f6Dave Airlie case GL_DOUBLE_MAT3x2: 175b476c587e3c8ffd61e833c3252d69c5edd16c0f6Dave Airlie case GL_DOUBLE_MAT3x4: 176b476c587e3c8ffd61e833c3252d69c5edd16c0f6Dave Airlie case GL_DOUBLE_MAT4: 177b476c587e3c8ffd61e833c3252d69c5edd16c0f6Dave Airlie case GL_DOUBLE_MAT4x2: 178b476c587e3c8ffd61e833c3252d69c5edd16c0f6Dave Airlie case GL_DOUBLE_MAT4x3: 179b476c587e3c8ffd61e833c3252d69c5edd16c0f6Dave Airlie return true; 180b476c587e3c8ffd61e833c3252d69c5edd16c0f6Dave Airlie default: 181b476c587e3c8ffd61e833c3252d69c5edd16c0f6Dave Airlie return false; 182b476c587e3c8ffd61e833c3252d69c5edd16c0f6Dave Airlie } 183b476c587e3c8ffd61e833c3252d69c5edd16c0f6Dave Airlie } 184b476c587e3c8ffd61e833c3252d69c5edd16c0f6Dave Airlie 1854b11b57ab47b98b335a7212080dbccef04542805Paul Berry /** 1864b11b57ab47b98b335a7212080dbccef04542805Paul Berry * The name that was supplied to glTransformFeedbackVaryings. Used for 1874b11b57ab47b98b335a7212080dbccef04542805Paul Berry * error reporting and glGetTransformFeedbackVarying(). 1884b11b57ab47b98b335a7212080dbccef04542805Paul Berry */ 1894b11b57ab47b98b335a7212080dbccef04542805Paul Berry const char *orig_name; 1904b11b57ab47b98b335a7212080dbccef04542805Paul Berry 1914b11b57ab47b98b335a7212080dbccef04542805Paul Berry /** 1924b11b57ab47b98b335a7212080dbccef04542805Paul Berry * The name of the variable, parsed from orig_name. 1934b11b57ab47b98b335a7212080dbccef04542805Paul Berry */ 1944b11b57ab47b98b335a7212080dbccef04542805Paul Berry const char *var_name; 1954b11b57ab47b98b335a7212080dbccef04542805Paul Berry 1964b11b57ab47b98b335a7212080dbccef04542805Paul Berry /** 1974b11b57ab47b98b335a7212080dbccef04542805Paul Berry * True if the declaration in orig_name represents an array. 1984b11b57ab47b98b335a7212080dbccef04542805Paul Berry */ 1994b11b57ab47b98b335a7212080dbccef04542805Paul Berry bool is_subscripted; 2004b11b57ab47b98b335a7212080dbccef04542805Paul Berry 2014b11b57ab47b98b335a7212080dbccef04542805Paul Berry /** 2024b11b57ab47b98b335a7212080dbccef04542805Paul Berry * If is_subscripted is true, the subscript that was specified in orig_name. 2034b11b57ab47b98b335a7212080dbccef04542805Paul Berry */ 2044b11b57ab47b98b335a7212080dbccef04542805Paul Berry unsigned array_subscript; 2054b11b57ab47b98b335a7212080dbccef04542805Paul Berry 2064b11b57ab47b98b335a7212080dbccef04542805Paul Berry /** 20773a9a1539a85ae8fe22e11b4064105d588597736Fabian Bieler * Non-zero if the variable is gl_ClipDistance, glTessLevelOuter or 20873a9a1539a85ae8fe22e11b4064105d588597736Fabian Bieler * gl_TessLevelInner and the driver lowers it to gl_*MESA. 2094b11b57ab47b98b335a7212080dbccef04542805Paul Berry */ 21073a9a1539a85ae8fe22e11b4064105d588597736Fabian Bieler enum { 21173a9a1539a85ae8fe22e11b4064105d588597736Fabian Bieler none, 21273a9a1539a85ae8fe22e11b4064105d588597736Fabian Bieler clip_distance, 213d656736bbf926c219b6bcbc0ad59132fc82a7382Tobias Klausmann cull_distance, 21473a9a1539a85ae8fe22e11b4064105d588597736Fabian Bieler tess_level_outer, 21573a9a1539a85ae8fe22e11b4064105d588597736Fabian Bieler tess_level_inner, 21673a9a1539a85ae8fe22e11b4064105d588597736Fabian Bieler } lowered_builtin_array_variable; 2174b11b57ab47b98b335a7212080dbccef04542805Paul Berry 2184b11b57ab47b98b335a7212080dbccef04542805Paul Berry /** 2194b11b57ab47b98b335a7212080dbccef04542805Paul Berry * The vertex shader output location that the linker assigned for this 2204b11b57ab47b98b335a7212080dbccef04542805Paul Berry * variable. -1 if a location hasn't been assigned yet. 2214b11b57ab47b98b335a7212080dbccef04542805Paul Berry */ 2224b11b57ab47b98b335a7212080dbccef04542805Paul Berry int location; 2234b11b57ab47b98b335a7212080dbccef04542805Paul Berry 2244b11b57ab47b98b335a7212080dbccef04542805Paul Berry /** 2254305a60173432635cde2f0f1dea8a715ed327bbcTimothy Arceri * Used to store the buffer assigned by xfb_buffer. 2264305a60173432635cde2f0f1dea8a715ed327bbcTimothy Arceri */ 2274305a60173432635cde2f0f1dea8a715ed327bbcTimothy Arceri unsigned buffer; 2284305a60173432635cde2f0f1dea8a715ed327bbcTimothy Arceri 2294305a60173432635cde2f0f1dea8a715ed327bbcTimothy Arceri /** 2304305a60173432635cde2f0f1dea8a715ed327bbcTimothy Arceri * Used to store the offset assigned by xfb_offset. 2314305a60173432635cde2f0f1dea8a715ed327bbcTimothy Arceri */ 2324305a60173432635cde2f0f1dea8a715ed327bbcTimothy Arceri unsigned offset; 2334305a60173432635cde2f0f1dea8a715ed327bbcTimothy Arceri 2344305a60173432635cde2f0f1dea8a715ed327bbcTimothy Arceri /** 2354b11b57ab47b98b335a7212080dbccef04542805Paul Berry * If non-zero, then this variable may be packed along with other variables 2364b11b57ab47b98b335a7212080dbccef04542805Paul Berry * into a single varying slot, so this offset should be applied when 2374b11b57ab47b98b335a7212080dbccef04542805Paul Berry * accessing components. For example, an offset of 1 means that the x 2384b11b57ab47b98b335a7212080dbccef04542805Paul Berry * component of this variable is actually stored in component y of the 2394b11b57ab47b98b335a7212080dbccef04542805Paul Berry * location specified by \c location. 2404b11b57ab47b98b335a7212080dbccef04542805Paul Berry * 2414b11b57ab47b98b335a7212080dbccef04542805Paul Berry * Only valid if location != -1. 2424b11b57ab47b98b335a7212080dbccef04542805Paul Berry */ 2434b11b57ab47b98b335a7212080dbccef04542805Paul Berry unsigned location_frac; 2444b11b57ab47b98b335a7212080dbccef04542805Paul Berry 2454b11b57ab47b98b335a7212080dbccef04542805Paul Berry /** 2464b11b57ab47b98b335a7212080dbccef04542805Paul Berry * If location != -1, the number of vector elements in this variable, or 1 2474b11b57ab47b98b335a7212080dbccef04542805Paul Berry * if this variable is a scalar. 2484b11b57ab47b98b335a7212080dbccef04542805Paul Berry */ 2494b11b57ab47b98b335a7212080dbccef04542805Paul Berry unsigned vector_elements; 2504b11b57ab47b98b335a7212080dbccef04542805Paul Berry 2514b11b57ab47b98b335a7212080dbccef04542805Paul Berry /** 2524b11b57ab47b98b335a7212080dbccef04542805Paul Berry * If location != -1, the number of matrix columns in this variable, or 1 2534b11b57ab47b98b335a7212080dbccef04542805Paul Berry * if this variable is not a matrix. 2544b11b57ab47b98b335a7212080dbccef04542805Paul Berry */ 2554b11b57ab47b98b335a7212080dbccef04542805Paul Berry unsigned matrix_columns; 2564b11b57ab47b98b335a7212080dbccef04542805Paul Berry 2574b11b57ab47b98b335a7212080dbccef04542805Paul Berry /** Type of the varying returned by glGetTransformFeedbackVarying() */ 2584b11b57ab47b98b335a7212080dbccef04542805Paul Berry GLenum type; 2594b11b57ab47b98b335a7212080dbccef04542805Paul Berry 2604b11b57ab47b98b335a7212080dbccef04542805Paul Berry /** 2614b11b57ab47b98b335a7212080dbccef04542805Paul Berry * If location != -1, the size that should be returned by 2624b11b57ab47b98b335a7212080dbccef04542805Paul Berry * glGetTransformFeedbackVarying(). 2634b11b57ab47b98b335a7212080dbccef04542805Paul Berry */ 2644b11b57ab47b98b335a7212080dbccef04542805Paul Berry unsigned size; 2654b11b57ab47b98b335a7212080dbccef04542805Paul Berry 2664b11b57ab47b98b335a7212080dbccef04542805Paul Berry /** 2674b11b57ab47b98b335a7212080dbccef04542805Paul Berry * How many components to skip. If non-zero, this is 2684b11b57ab47b98b335a7212080dbccef04542805Paul Berry * gl_SkipComponents{1,2,3,4} from ARB_transform_feedback3. 2694b11b57ab47b98b335a7212080dbccef04542805Paul Berry */ 2704b11b57ab47b98b335a7212080dbccef04542805Paul Berry unsigned skip_components; 2714b11b57ab47b98b335a7212080dbccef04542805Paul Berry 2724b11b57ab47b98b335a7212080dbccef04542805Paul Berry /** 2734b11b57ab47b98b335a7212080dbccef04542805Paul Berry * Whether this is gl_NextBuffer from ARB_transform_feedback3. 2744b11b57ab47b98b335a7212080dbccef04542805Paul Berry */ 2754b11b57ab47b98b335a7212080dbccef04542805Paul Berry bool next_buffer_separator; 27699b78337e38308480ee491493b045179f10ed579Paul Berry 27799b78337e38308480ee491493b045179f10ed579Paul Berry /** 27899b78337e38308480ee491493b045179f10ed579Paul Berry * If find_candidate() has been called, pointer to the tfeedback_candidate 27999b78337e38308480ee491493b045179f10ed579Paul Berry * data structure that was found. Otherwise NULL. 28099b78337e38308480ee491493b045179f10ed579Paul Berry */ 28199b78337e38308480ee491493b045179f10ed579Paul Berry const tfeedback_candidate *matched_candidate; 282b908e85ed3f1c7601c2e56f85ff676b606af10b5Iago Toral Quiroga 283b908e85ed3f1c7601c2e56f85ff676b606af10b5Iago Toral Quiroga /** 284b908e85ed3f1c7601c2e56f85ff676b606af10b5Iago Toral Quiroga * StreamId assigned to this varying (defaults to 0). Can only be set to 285b908e85ed3f1c7601c2e56f85ff676b606af10b5Iago Toral Quiroga * values other than 0 in geometry shaders that use the stream layout 286b908e85ed3f1c7601c2e56f85ff676b606af10b5Iago Toral Quiroga * modifier. Accepted values must be in the range [0, MAX_VERTEX_STREAMS-1]. 287b908e85ed3f1c7601c2e56f85ff676b606af10b5Iago Toral Quiroga */ 288b908e85ed3f1c7601c2e56f85ff676b606af10b5Iago Toral Quiroga unsigned stream_id; 2894b11b57ab47b98b335a7212080dbccef04542805Paul Berry}; 2904b11b57ab47b98b335a7212080dbccef04542805Paul Berry 2914b11b57ab47b98b335a7212080dbccef04542805Paul Berry 292b95d237fe6731055dad2ff3eaa59e4d6fc14bfffPaul Berryvoid 2934b11b57ab47b98b335a7212080dbccef04542805Paul Berrycross_validate_outputs_to_inputs(struct gl_shader_program *prog, 2941fb8c6df884c2a17cf980c4ea32db4c214903b55Timothy Arceri gl_linked_shader *producer, 2951fb8c6df884c2a17cf980c4ea32db4c214903b55Timothy Arceri gl_linked_shader *consumer); 2964b11b57ab47b98b335a7212080dbccef04542805Paul Berry 2974b11b57ab47b98b335a7212080dbccef04542805Paul Berrybool 2984b11b57ab47b98b335a7212080dbccef04542805Paul Berryparse_tfeedback_decls(struct gl_context *ctx, struct gl_shader_program *prog, 2994b11b57ab47b98b335a7212080dbccef04542805Paul Berry const void *mem_ctx, unsigned num_names, 3004b11b57ab47b98b335a7212080dbccef04542805Paul Berry char **varying_names, tfeedback_decl *decls); 3010822517936d473f4889b07606e131e1dc3199644Timothy Arceri 3020822517936d473f4889b07606e131e1dc3199644Timothy Arceribool 3031fb8c6df884c2a17cf980c4ea32db4c214903b55Timothy Arceriprocess_xfb_layout_qualifiers(void *mem_ctx, const gl_linked_shader *sh, 3040822517936d473f4889b07606e131e1dc3199644Timothy Arceri unsigned *num_tfeedback_decls, 3050822517936d473f4889b07606e131e1dc3199644Timothy Arceri char ***varying_names); 3064b11b57ab47b98b335a7212080dbccef04542805Paul Berry 30730991d7389b6b475625ccce2aaae2f3f8cf8e95fTimothy Arcerivoid 30830991d7389b6b475625ccce2aaae2f3f8cf8e95fTimothy Arceriremove_unused_shader_inputs_and_outputs(bool is_separate_shader_object, 3091fb8c6df884c2a17cf980c4ea32db4c214903b55Timothy Arceri gl_linked_shader *sh, 31030991d7389b6b475625ccce2aaae2f3f8cf8e95fTimothy Arceri enum ir_variable_mode mode); 31130991d7389b6b475625ccce2aaae2f3f8cf8e95fTimothy Arceri 3124b11b57ab47b98b335a7212080dbccef04542805Paul Berrybool 3134b11b57ab47b98b335a7212080dbccef04542805Paul Berrystore_tfeedback_info(struct gl_context *ctx, struct gl_shader_program *prog, 3144b11b57ab47b98b335a7212080dbccef04542805Paul Berry unsigned num_tfeedback_decls, 3150c66460fc65e1c45ec2268c978ea11b259441212Timothy Arceri tfeedback_decl *tfeedback_decls, 3160c66460fc65e1c45ec2268c978ea11b259441212Timothy Arceri bool has_xfb_qualifiers); 3174b11b57ab47b98b335a7212080dbccef04542805Paul Berry 3184b11b57ab47b98b335a7212080dbccef04542805Paul Berrybool 3194b11b57ab47b98b335a7212080dbccef04542805Paul Berryassign_varying_locations(struct gl_context *ctx, 3204b11b57ab47b98b335a7212080dbccef04542805Paul Berry void *mem_ctx, 3214b11b57ab47b98b335a7212080dbccef04542805Paul Berry struct gl_shader_program *prog, 3221fb8c6df884c2a17cf980c4ea32db4c214903b55Timothy Arceri gl_linked_shader *producer, 3231fb8c6df884c2a17cf980c4ea32db4c214903b55Timothy Arceri gl_linked_shader *consumer, 3244b11b57ab47b98b335a7212080dbccef04542805Paul Berry unsigned num_tfeedback_decls, 325ad3def919e8bdb4f01db0f06d54961175a1910c4Timothy Arceri tfeedback_decl *tfeedback_decls, 326ad3def919e8bdb4f01db0f06d54961175a1910c4Timothy Arceri const uint64_t reserved_slots); 327ad3def919e8bdb4f01db0f06d54961175a1910c4Timothy Arceri 328ad3def919e8bdb4f01db0f06d54961175a1910c4Timothy Arceriuint64_t 3291fb8c6df884c2a17cf980c4ea32db4c214903b55Timothy Arcerireserved_varying_slot(struct gl_linked_shader *stage, 3301fb8c6df884c2a17cf980c4ea32db4c214903b55Timothy Arceri ir_variable_mode io_mode); 3314b11b57ab47b98b335a7212080dbccef04542805Paul Berry 3323c555827c3e2fdb84ee4b4b8fd8296985cbb1fdaMarek Olšákbool 33342305fb50256c12b8e7a516115e72ae7089ccd1bIan Romanickcheck_against_output_limit(struct gl_context *ctx, 33442305fb50256c12b8e7a516115e72ae7089ccd1bIan Romanick struct gl_shader_program *prog, 3351fb8c6df884c2a17cf980c4ea32db4c214903b55Timothy Arceri gl_linked_shader *producer, 336ad3def919e8bdb4f01db0f06d54961175a1910c4Timothy Arceri unsigned num_explicit_locations); 33742305fb50256c12b8e7a516115e72ae7089ccd1bIan Romanick 33842305fb50256c12b8e7a516115e72ae7089ccd1bIan Romanickbool 33942305fb50256c12b8e7a516115e72ae7089ccd1bIan Romanickcheck_against_input_limit(struct gl_context *ctx, 34042305fb50256c12b8e7a516115e72ae7089ccd1bIan Romanick struct gl_shader_program *prog, 3411fb8c6df884c2a17cf980c4ea32db4c214903b55Timothy Arceri gl_linked_shader *consumer, 342ad3def919e8bdb4f01db0f06d54961175a1910c4Timothy Arceri unsigned num_explicit_locations); 3433c555827c3e2fdb84ee4b4b8fd8296985cbb1fdaMarek Olšák 3444b11b57ab47b98b335a7212080dbccef04542805Paul Berry#endif /* GLSL_LINK_VARYINGS_H */ 345