Home | History | Annotate | Download | only in MachineIndependent
      1 //
      2 // Copyright (C) 2002-2005  3Dlabs Inc. Ltd.
      3 // Copyright (C) 2012-2013 LunarG, Inc.
      4 //
      5 // All rights reserved.
      6 //
      7 // Redistribution and use in source and binary forms, with or without
      8 // modification, are permitted provided that the following conditions
      9 // are met:
     10 //
     11 //    Redistributions of source code must retain the above copyright
     12 //    notice, this list of conditions and the following disclaimer.
     13 //
     14 //    Redistributions in binary form must reproduce the above
     15 //    copyright notice, this list of conditions and the following
     16 //    disclaimer in the documentation and/or other materials provided
     17 //    with the distribution.
     18 //
     19 //    Neither the name of 3Dlabs Inc. Ltd. nor the names of its
     20 //    contributors may be used to endorse or promote products derived
     21 //    from this software without specific prior written permission.
     22 //
     23 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     24 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     25 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
     26 // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
     27 // COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
     28 // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
     29 // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
     30 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
     31 // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     32 // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
     33 // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     34 // POSSIBILITY OF SUCH DAMAGE.
     35 //
     36 #ifndef _VERSIONS_INCLUDED_
     37 #define _VERSIONS_INCLUDED_
     38 
     39 //
     40 // Help manage multiple profiles, versions, extensions etc.
     41 //
     42 
     43 //
     44 // Profiles are set up for masking operations, so queries can be done on multiple
     45 // profiles at the same time.
     46 //
     47 // Don't maintain an ordinal set of enums (0,1,2,3...) to avoid all possible
     48 // defects from mixing the two different forms.
     49 //
     50 typedef enum {
     51     EBadProfile           = 0,
     52     ENoProfile            = (1 << 0), // only for desktop, before profiles showed up
     53     ECoreProfile          = (1 << 1),
     54     ECompatibilityProfile = (1 << 2),
     55     EEsProfile            = (1 << 3)
     56 } EProfile;
     57 
     58 namespace glslang {
     59 
     60 //
     61 // Map from profile enum to externally readable text name.
     62 //
     63 inline const char* ProfileName(EProfile profile)
     64 {
     65     switch (profile) {
     66     case ENoProfile:             return "none";
     67     case ECoreProfile:           return "core";
     68     case ECompatibilityProfile:  return "compatibility";
     69     case EEsProfile:             return "es";
     70     default:                     return "unknown profile";
     71     }
     72 }
     73 
     74 //
     75 // What source rules, validation rules, target language, etc. are needed
     76 // desired for SPIR-V?
     77 //
     78 // 0 means a target or rule set is not enabled (ignore rules from that entity).
     79 // Non-0 means to apply semantic rules arising from that version of its rule set.
     80 // The union of all requested rule sets will be applied.
     81 //
     82 struct SpvVersion {
     83     SpvVersion() : spv(0), vulkanGlsl(0), vulkan(0), openGl(0) {}
     84     unsigned int spv; // the version of SPIR-V to target, as defined by "word 1" of the SPIR-V binary header
     85     int vulkanGlsl;   // the version of GLSL semantics for Vulkan, from GL_KHR_vulkan_glsl, for "#define VULKAN XXX"
     86     int vulkan;       // the version of Vulkan, for which SPIR-V execution environment rules to use (100 means 1.0)
     87     int openGl;       // the version of GLSL semantics for OpenGL, from GL_ARB_gl_spirv, for "#define GL_SPIRV XXX"
     88 };
     89 
     90 //
     91 // The behaviors from the GLSL "#extension extension_name : behavior"
     92 //
     93 typedef enum {
     94     EBhMissing = 0,
     95     EBhRequire,
     96     EBhEnable,
     97     EBhWarn,
     98     EBhDisable,
     99     EBhDisablePartial    // use as initial state of an extension that is only partially implemented
    100 } TExtensionBehavior;
    101 
    102 //
    103 // Symbolic names for extensions.  Strings may be directly used when calling the
    104 // functions, but better to have the compiler do spelling checks.
    105 //
    106 const char* const E_GL_OES_texture_3D                   = "GL_OES_texture_3D";
    107 const char* const E_GL_OES_standard_derivatives         = "GL_OES_standard_derivatives";
    108 const char* const E_GL_EXT_frag_depth                   = "GL_EXT_frag_depth";
    109 const char* const E_GL_OES_EGL_image_external           = "GL_OES_EGL_image_external";
    110 const char* const E_GL_EXT_shader_texture_lod           = "GL_EXT_shader_texture_lod";
    111 const char* const E_GL_EXT_shadow_samplers              = "GL_EXT_shadow_samplers";
    112 
    113 const char* const E_GL_ARB_texture_rectangle            = "GL_ARB_texture_rectangle";
    114 const char* const E_GL_3DL_array_objects                = "GL_3DL_array_objects";
    115 const char* const E_GL_ARB_shading_language_420pack     = "GL_ARB_shading_language_420pack";
    116 const char* const E_GL_ARB_texture_gather               = "GL_ARB_texture_gather";
    117 const char* const E_GL_ARB_gpu_shader5                  = "GL_ARB_gpu_shader5";
    118 const char* const E_GL_ARB_separate_shader_objects      = "GL_ARB_separate_shader_objects";
    119 const char* const E_GL_ARB_compute_shader               = "GL_ARB_compute_shader";
    120 const char* const E_GL_ARB_tessellation_shader          = "GL_ARB_tessellation_shader";
    121 const char* const E_GL_ARB_enhanced_layouts             = "GL_ARB_enhanced_layouts";
    122 const char* const E_GL_ARB_texture_cube_map_array       = "GL_ARB_texture_cube_map_array";
    123 const char* const E_GL_ARB_shader_texture_lod           = "GL_ARB_shader_texture_lod";
    124 const char* const E_GL_ARB_explicit_attrib_location     = "GL_ARB_explicit_attrib_location";
    125 const char* const E_GL_ARB_shader_image_load_store      = "GL_ARB_shader_image_load_store";
    126 const char* const E_GL_ARB_shader_atomic_counters       = "GL_ARB_shader_atomic_counters";
    127 const char* const E_GL_ARB_shader_draw_parameters       = "GL_ARB_shader_draw_parameters";
    128 const char* const E_GL_ARB_shader_group_vote            = "GL_ARB_shader_group_vote";
    129 const char* const E_GL_ARB_derivative_control           = "GL_ARB_derivative_control";
    130 const char* const E_GL_ARB_shader_texture_image_samples = "GL_ARB_shader_texture_image_samples";
    131 const char* const E_GL_ARB_viewport_array               = "GL_ARB_viewport_array";
    132 const char* const E_GL_ARB_gpu_shader_int64             = "GL_ARB_gpu_shader_int64";
    133 const char* const E_GL_ARB_shader_ballot                = "GL_ARB_shader_ballot";
    134 const char* const E_GL_ARB_sparse_texture2              = "GL_ARB_sparse_texture2";
    135 const char* const E_GL_ARB_sparse_texture_clamp         = "GL_ARB_sparse_texture_clamp";
    136 const char* const E_GL_ARB_shader_stencil_export        = "GL_ARB_shader_stencil_export";
    137 // const char* const E_GL_ARB_cull_distance            = "GL_ARB_cull_distance";  // present for 4.5, but need extension control over block members
    138 const char* const E_GL_ARB_post_depth_coverage          = "GL_ARB_post_depth_coverage";
    139 const char* const E_GL_ARB_shader_viewport_layer_array  = "GL_ARB_shader_viewport_layer_array";
    140 
    141 const char* const E_GL_EXT_shader_non_constant_global_initializers = "GL_EXT_shader_non_constant_global_initializers";
    142 const char* const E_GL_EXT_shader_image_load_formatted = "GL_EXT_shader_image_load_formatted";
    143 
    144 // EXT extensions
    145 const char* const E_GL_EXT_device_group                 = "GL_EXT_device_group";
    146 const char* const E_GL_EXT_multiview                    = "GL_EXT_multiview";
    147 const char* const E_GL_EXT_post_depth_coverage          = "GL_EXT_post_depth_coverage";
    148 
    149 // Arrays of extensions for the above viewportEXTs duplications
    150 
    151 const char* const post_depth_coverageEXTs[] = { E_GL_ARB_post_depth_coverage, E_GL_EXT_post_depth_coverage };
    152 const int Num_post_depth_coverageEXTs = sizeof(post_depth_coverageEXTs) / sizeof(post_depth_coverageEXTs[0]);
    153 
    154 // OVR extensions
    155 const char* const E_GL_OVR_multiview                    = "GL_OVR_multiview";
    156 const char* const E_GL_OVR_multiview2                   = "GL_OVR_multiview2";
    157 
    158 const char* const OVR_multiview_EXTs[] = { E_GL_OVR_multiview, E_GL_OVR_multiview2 };
    159 const int Num_OVR_multiview_EXTs = sizeof(OVR_multiview_EXTs) / sizeof(OVR_multiview_EXTs[0]);
    160 
    161 // #line and #include
    162 const char* const E_GL_GOOGLE_cpp_style_line_directive          = "GL_GOOGLE_cpp_style_line_directive";
    163 const char* const E_GL_GOOGLE_include_directive                 = "GL_GOOGLE_include_directive";
    164 
    165 #ifdef AMD_EXTENSIONS
    166 const char* const E_GL_AMD_shader_ballot                        = "GL_AMD_shader_ballot";
    167 const char* const E_GL_AMD_shader_trinary_minmax                = "GL_AMD_shader_trinary_minmax";
    168 const char* const E_GL_AMD_shader_explicit_vertex_parameter     = "GL_AMD_shader_explicit_vertex_parameter";
    169 const char* const E_GL_AMD_gcn_shader                           = "GL_AMD_gcn_shader";
    170 const char* const E_GL_AMD_gpu_shader_half_float                = "GL_AMD_gpu_shader_half_float";
    171 const char* const E_GL_AMD_texture_gather_bias_lod              = "GL_AMD_texture_gather_bias_lod";
    172 const char* const E_GL_AMD_gpu_shader_int16                     = "GL_AMD_gpu_shader_int16";
    173 const char* const E_GL_AMD_shader_image_load_store_lod          = "GL_AMD_shader_image_load_store_lod";
    174 #endif
    175 
    176 #ifdef NV_EXTENSIONS
    177 
    178 const char* const E_GL_NV_sample_mask_override_coverage         = "GL_NV_sample_mask_override_coverage";
    179 const char* const E_SPV_NV_geometry_shader_passthrough          = "GL_NV_geometry_shader_passthrough";
    180 const char* const E_GL_NV_viewport_array2                       = "GL_NV_viewport_array2";
    181 const char* const E_GL_NV_stereo_view_rendering                 = "GL_NV_stereo_view_rendering";
    182 const char* const E_GL_NVX_multiview_per_view_attributes        = "GL_NVX_multiview_per_view_attributes";
    183 
    184 // Arrays of extensions for the above viewportEXTs duplications
    185 
    186 const char* const viewportEXTs[] = { E_GL_ARB_shader_viewport_layer_array, E_GL_NV_viewport_array2 };
    187 const int Num_viewportEXTs = sizeof(viewportEXTs) / sizeof(viewportEXTs[0]);
    188 #endif
    189 
    190 // AEP
    191 const char* const E_GL_ANDROID_extension_pack_es31a             = "GL_ANDROID_extension_pack_es31a";
    192 const char* const E_GL_KHR_blend_equation_advanced              = "GL_KHR_blend_equation_advanced";
    193 const char* const E_GL_OES_sample_variables                     = "GL_OES_sample_variables";
    194 const char* const E_GL_OES_shader_image_atomic                  = "GL_OES_shader_image_atomic";
    195 const char* const E_GL_OES_shader_multisample_interpolation     = "GL_OES_shader_multisample_interpolation";
    196 const char* const E_GL_OES_texture_storage_multisample_2d_array = "GL_OES_texture_storage_multisample_2d_array";
    197 const char* const E_GL_EXT_geometry_shader                      = "GL_EXT_geometry_shader";
    198 const char* const E_GL_EXT_geometry_point_size                  = "GL_EXT_geometry_point_size";
    199 const char* const E_GL_EXT_gpu_shader5                          = "GL_EXT_gpu_shader5";
    200 const char* const E_GL_EXT_primitive_bounding_box               = "GL_EXT_primitive_bounding_box";
    201 const char* const E_GL_EXT_shader_io_blocks                     = "GL_EXT_shader_io_blocks";
    202 const char* const E_GL_EXT_tessellation_shader                  = "GL_EXT_tessellation_shader";
    203 const char* const E_GL_EXT_tessellation_point_size              = "GL_EXT_tessellation_point_size";
    204 const char* const E_GL_EXT_texture_buffer                       = "GL_EXT_texture_buffer";
    205 const char* const E_GL_EXT_texture_cube_map_array               = "GL_EXT_texture_cube_map_array";
    206 
    207 // OES matching AEP
    208 const char* const E_GL_OES_geometry_shader                      = "GL_OES_geometry_shader";
    209 const char* const E_GL_OES_geometry_point_size                  = "GL_OES_geometry_point_size";
    210 const char* const E_GL_OES_gpu_shader5                          = "GL_OES_gpu_shader5";
    211 const char* const E_GL_OES_primitive_bounding_box               = "GL_OES_primitive_bounding_box";
    212 const char* const E_GL_OES_shader_io_blocks                     = "GL_OES_shader_io_blocks";
    213 const char* const E_GL_OES_tessellation_shader                  = "GL_OES_tessellation_shader";
    214 const char* const E_GL_OES_tessellation_point_size              = "GL_OES_tessellation_point_size";
    215 const char* const E_GL_OES_texture_buffer                       = "GL_OES_texture_buffer";
    216 const char* const E_GL_OES_texture_cube_map_array               = "GL_OES_texture_cube_map_array";
    217 
    218 // Arrays of extensions for the above AEP duplications
    219 
    220 const char* const AEP_geometry_shader[] = { E_GL_EXT_geometry_shader, E_GL_OES_geometry_shader };
    221 const int Num_AEP_geometry_shader = sizeof(AEP_geometry_shader)/sizeof(AEP_geometry_shader[0]);
    222 
    223 const char* const AEP_geometry_point_size[] = { E_GL_EXT_geometry_point_size, E_GL_OES_geometry_point_size };
    224 const int Num_AEP_geometry_point_size = sizeof(AEP_geometry_point_size)/sizeof(AEP_geometry_point_size[0]);
    225 
    226 const char* const AEP_gpu_shader5[] = { E_GL_EXT_gpu_shader5, E_GL_OES_gpu_shader5 };
    227 const int Num_AEP_gpu_shader5 = sizeof(AEP_gpu_shader5)/sizeof(AEP_gpu_shader5[0]);
    228 
    229 const char* const AEP_primitive_bounding_box[] = { E_GL_EXT_primitive_bounding_box, E_GL_OES_primitive_bounding_box };
    230 const int Num_AEP_primitive_bounding_box = sizeof(AEP_primitive_bounding_box)/sizeof(AEP_primitive_bounding_box[0]);
    231 
    232 const char* const AEP_shader_io_blocks[] = { E_GL_EXT_shader_io_blocks, E_GL_OES_shader_io_blocks };
    233 const int Num_AEP_shader_io_blocks = sizeof(AEP_shader_io_blocks)/sizeof(AEP_shader_io_blocks[0]);
    234 
    235 const char* const AEP_tessellation_shader[] = { E_GL_EXT_tessellation_shader, E_GL_OES_tessellation_shader };
    236 const int Num_AEP_tessellation_shader = sizeof(AEP_tessellation_shader)/sizeof(AEP_tessellation_shader[0]);
    237 
    238 const char* const AEP_tessellation_point_size[] = { E_GL_EXT_tessellation_point_size, E_GL_OES_tessellation_point_size };
    239 const int Num_AEP_tessellation_point_size = sizeof(AEP_tessellation_point_size)/sizeof(AEP_tessellation_point_size[0]);
    240 
    241 const char* const AEP_texture_buffer[] = { E_GL_EXT_texture_buffer, E_GL_OES_texture_buffer };
    242 const int Num_AEP_texture_buffer = sizeof(AEP_texture_buffer)/sizeof(AEP_texture_buffer[0]);
    243 
    244 const char* const AEP_texture_cube_map_array[] = { E_GL_EXT_texture_cube_map_array, E_GL_OES_texture_cube_map_array };
    245 const int Num_AEP_texture_cube_map_array = sizeof(AEP_texture_cube_map_array)/sizeof(AEP_texture_cube_map_array[0]);
    246 
    247 } // end namespace glslang
    248 
    249 #endif // _VERSIONS_INCLUDED_
    250