Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | RSS feed

  1. /*
  2.  * Mesa 3-D graphics library
  3.  *
  4.  * Copyright (C) 1999-2008  Brian Paul   All Rights Reserved.
  5.  * Copyright (C) 2009  VMware, Inc.  All Rights Reserved.
  6.  *
  7.  * Permission is hereby granted, free of charge, to any person obtaining a
  8.  * copy of this software and associated documentation files (the "Software"),
  9.  * to deal in the Software without restriction, including without limitation
  10.  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  11.  * and/or sell copies of the Software, and to permit persons to whom the
  12.  * Software is furnished to do so, subject to the following conditions:
  13.  *
  14.  * The above copyright notice and this permission notice shall be included
  15.  * in all copies or substantial portions of the Software.
  16.  *
  17.  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  18.  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  19.  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
  20.  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
  21.  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  22.  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  23.  * OTHER DEALINGS IN THE SOFTWARE.
  24.  */
  25.  
  26. #ifndef SHADER_ENUMS_H
  27. #define SHADER_ENUMS_H
  28.  
  29. /**
  30.  * Shader stages. Note that these will become 5 with tessellation.
  31.  *
  32.  * The order must match how shaders are ordered in the pipeline.
  33.  * The GLSL linker assumes that if i<j, then the j-th shader is
  34.  * executed later than the i-th shader.
  35.  */
  36. typedef enum
  37. {
  38.    MESA_SHADER_VERTEX = 0,
  39.    MESA_SHADER_GEOMETRY = 1,
  40.    MESA_SHADER_FRAGMENT = 2,
  41.    MESA_SHADER_COMPUTE = 3,
  42. } gl_shader_stage;
  43.  
  44. #define MESA_SHADER_STAGES (MESA_SHADER_COMPUTE + 1)
  45.  
  46. /**
  47.  * Bitflags for system values.
  48.  */
  49. #define SYSTEM_BIT_SAMPLE_ID ((uint64_t)1 << SYSTEM_VALUE_SAMPLE_ID)
  50. #define SYSTEM_BIT_SAMPLE_POS ((uint64_t)1 << SYSTEM_VALUE_SAMPLE_POS)
  51. #define SYSTEM_BIT_SAMPLE_MASK_IN ((uint64_t)1 << SYSTEM_VALUE_SAMPLE_MASK_IN)
  52. /**
  53.  * If the gl_register_file is PROGRAM_SYSTEM_VALUE, the register index will be
  54.  * one of these values.  If a NIR variable's mode is nir_var_system_value, it
  55.  * will be one of these values.
  56.  */
  57. typedef enum
  58. {
  59.    /**
  60.     * \name Vertex shader system values
  61.     */
  62.    /*@{*/
  63.    /**
  64.     * OpenGL-style vertex ID.
  65.     *
  66.     * Section 2.11.7 (Shader Execution), subsection Shader Inputs, of the
  67.     * OpenGL 3.3 core profile spec says:
  68.     *
  69.     *     "gl_VertexID holds the integer index i implicitly passed by
  70.     *     DrawArrays or one of the other drawing commands defined in section
  71.     *     2.8.3."
  72.     *
  73.     * Section 2.8.3 (Drawing Commands) of the same spec says:
  74.     *
  75.     *     "The commands....are equivalent to the commands with the same base
  76.     *     name (without the BaseVertex suffix), except that the ith element
  77.     *     transferred by the corresponding draw call will be taken from
  78.     *     element indices[i] + basevertex of each enabled array."
  79.     *
  80.     * Additionally, the overview in the GL_ARB_shader_draw_parameters spec
  81.     * says:
  82.     *
  83.     *     "In unextended GL, vertex shaders have inputs named gl_VertexID and
  84.     *     gl_InstanceID, which contain, respectively the index of the vertex
  85.     *     and instance. The value of gl_VertexID is the implicitly passed
  86.     *     index of the vertex being processed, which includes the value of
  87.     *     baseVertex, for those commands that accept it."
  88.     *
  89.     * gl_VertexID gets basevertex added in.  This differs from DirectX where
  90.     * SV_VertexID does \b not get basevertex added in.
  91.     *
  92.     * \note
  93.     * If all system values are available, \c SYSTEM_VALUE_VERTEX_ID will be
  94.     * equal to \c SYSTEM_VALUE_VERTEX_ID_ZERO_BASE plus
  95.     * \c SYSTEM_VALUE_BASE_VERTEX.
  96.     *
  97.     * \sa SYSTEM_VALUE_VERTEX_ID_ZERO_BASE, SYSTEM_VALUE_BASE_VERTEX
  98.     */
  99.    SYSTEM_VALUE_VERTEX_ID,
  100.  
  101.    /**
  102.     * Instanced ID as supplied to gl_InstanceID
  103.     *
  104.     * Values assigned to gl_InstanceID always begin with zero, regardless of
  105.     * the value of baseinstance.
  106.     *
  107.     * Section 11.1.3.9 (Shader Inputs) of the OpenGL 4.4 core profile spec
  108.     * says:
  109.     *
  110.     *     "gl_InstanceID holds the integer instance number of the current
  111.     *     primitive in an instanced draw call (see section 10.5)."
  112.     *
  113.     * Through a big chain of pseudocode, section 10.5 describes that
  114.     * baseinstance is not counted by gl_InstanceID.  In that section, notice
  115.     *
  116.     *     "If an enabled vertex attribute array is instanced (it has a
  117.     *     non-zero divisor as specified by VertexAttribDivisor), the element
  118.     *     index that is transferred to the GL, for all vertices, is given by
  119.     *
  120.     *         floor(instance/divisor) + baseinstance
  121.     *
  122.     *     If an array corresponding to an attribute required by a vertex
  123.     *     shader is not enabled, then the corresponding element is taken from
  124.     *     the current attribute state (see section 10.2)."
  125.     *
  126.     * Note that baseinstance is \b not included in the value of instance.
  127.     */
  128.    SYSTEM_VALUE_INSTANCE_ID,
  129.  
  130.    /**
  131.     * DirectX-style vertex ID.
  132.     *
  133.     * Unlike \c SYSTEM_VALUE_VERTEX_ID, this system value does \b not include
  134.     * the value of basevertex.
  135.     *
  136.     * \sa SYSTEM_VALUE_VERTEX_ID, SYSTEM_VALUE_BASE_VERTEX
  137.     */
  138.    SYSTEM_VALUE_VERTEX_ID_ZERO_BASE,
  139.  
  140.    /**
  141.     * Value of \c basevertex passed to \c glDrawElementsBaseVertex and similar
  142.     * functions.
  143.     *
  144.     * \sa SYSTEM_VALUE_VERTEX_ID, SYSTEM_VALUE_VERTEX_ID_ZERO_BASE
  145.     */
  146.    SYSTEM_VALUE_BASE_VERTEX,
  147.    /*@}*/
  148.  
  149.    /**
  150.     * \name Geometry shader system values
  151.     */
  152.    /*@{*/
  153.    SYSTEM_VALUE_INVOCATION_ID,
  154.    /*@}*/
  155.  
  156.    /**
  157.     * \name Fragment shader system values
  158.     */
  159.    /*@{*/
  160.    SYSTEM_VALUE_FRONT_FACE,     /**< (not done yet) */
  161.    SYSTEM_VALUE_SAMPLE_ID,
  162.    SYSTEM_VALUE_SAMPLE_POS,
  163.    SYSTEM_VALUE_SAMPLE_MASK_IN,
  164.    /*@}*/
  165.  
  166.    SYSTEM_VALUE_MAX             /**< Number of values */
  167. } gl_system_value;
  168.  
  169.  
  170. /**
  171.  * The possible interpolation qualifiers that can be applied to a fragment
  172.  * shader input in GLSL.
  173.  *
  174.  * Note: INTERP_QUALIFIER_NONE must be 0 so that memsetting the
  175.  * gl_fragment_program data structure to 0 causes the default behavior.
  176.  */
  177. enum glsl_interp_qualifier
  178. {
  179.    INTERP_QUALIFIER_NONE = 0,
  180.    INTERP_QUALIFIER_SMOOTH,
  181.    INTERP_QUALIFIER_FLAT,
  182.    INTERP_QUALIFIER_NOPERSPECTIVE,
  183.    INTERP_QUALIFIER_COUNT /**< Number of interpolation qualifiers */
  184. };
  185.  
  186.  
  187. #endif /* SHADER_ENUMS_H */
  188.