1 // 2 // Copyright 2002 The ANGLE Project Authors. All rights reserved. 3 // Use of this source code is governed by a BSD-style license that can be 4 // found in the LICENSE file. 5 // 6 7 #include "compiler/translator/Initialize.h" 8 9 namespace sh 10 { 11 InitExtensionBehavior(const ShBuiltInResources & resources,TExtensionBehavior & extBehavior)12void InitExtensionBehavior(const ShBuiltInResources &resources, TExtensionBehavior &extBehavior) 13 { 14 if (resources.OES_standard_derivatives) 15 { 16 extBehavior[TExtension::OES_standard_derivatives] = EBhUndefined; 17 } 18 if (resources.OES_EGL_image_external) 19 { 20 extBehavior[TExtension::OES_EGL_image_external] = EBhUndefined; 21 } 22 if (resources.OES_EGL_image_external_essl3) 23 { 24 extBehavior[TExtension::OES_EGL_image_external_essl3] = EBhUndefined; 25 } 26 if (resources.NV_EGL_stream_consumer_external) 27 { 28 extBehavior[TExtension::NV_EGL_stream_consumer_external] = EBhUndefined; 29 } 30 if (resources.ARB_texture_rectangle) 31 { 32 // Special: ARB_texture_rectangle extension does not follow the standard for #extension 33 // directives - it is enabled by default. An extension directive may still disable it. 34 extBehavior[TExtension::ARB_texture_rectangle] = EBhEnable; 35 } 36 if (resources.EXT_blend_func_extended) 37 { 38 extBehavior[TExtension::EXT_blend_func_extended] = EBhUndefined; 39 } 40 if (resources.EXT_conservative_depth) 41 { 42 extBehavior[TExtension::EXT_conservative_depth] = EBhUndefined; 43 } 44 if (resources.EXT_draw_buffers) 45 { 46 extBehavior[TExtension::EXT_draw_buffers] = EBhUndefined; 47 } 48 if (resources.EXT_frag_depth) 49 { 50 extBehavior[TExtension::EXT_frag_depth] = EBhUndefined; 51 } 52 if (resources.EXT_primitive_bounding_box) 53 { 54 extBehavior[TExtension::EXT_primitive_bounding_box] = EBhUndefined; 55 } 56 if (resources.OES_primitive_bounding_box) 57 { 58 extBehavior[TExtension::OES_primitive_bounding_box] = EBhUndefined; 59 } 60 if (resources.EXT_separate_shader_objects) 61 { 62 extBehavior[TExtension::EXT_separate_shader_objects] = EBhUndefined; 63 } 64 if (resources.EXT_shader_texture_lod) 65 { 66 extBehavior[TExtension::EXT_shader_texture_lod] = EBhUndefined; 67 } 68 if (resources.EXT_shader_framebuffer_fetch) 69 { 70 extBehavior[TExtension::EXT_shader_framebuffer_fetch] = EBhUndefined; 71 } 72 if (resources.EXT_shader_framebuffer_fetch_non_coherent) 73 { 74 extBehavior[TExtension::EXT_shader_framebuffer_fetch_non_coherent] = EBhUndefined; 75 } 76 if (resources.NV_shader_framebuffer_fetch) 77 { 78 extBehavior[TExtension::NV_shader_framebuffer_fetch] = EBhUndefined; 79 } 80 if (resources.NV_shader_noperspective_interpolation) 81 { 82 extBehavior[TExtension::NV_shader_noperspective_interpolation] = EBhUndefined; 83 } 84 if (resources.ARM_shader_framebuffer_fetch) 85 { 86 extBehavior[TExtension::ARM_shader_framebuffer_fetch] = EBhUndefined; 87 } 88 if (resources.ARM_shader_framebuffer_fetch_depth_stencil) 89 { 90 extBehavior[TExtension::ARM_shader_framebuffer_fetch_depth_stencil] = EBhUndefined; 91 } 92 if (resources.OVR_multiview) 93 { 94 extBehavior[TExtension::OVR_multiview] = EBhUndefined; 95 } 96 if (resources.OVR_multiview2) 97 { 98 extBehavior[TExtension::OVR_multiview2] = EBhUndefined; 99 } 100 if (resources.EXT_YUV_target) 101 { 102 extBehavior[TExtension::EXT_YUV_target] = EBhUndefined; 103 } 104 if (resources.EXT_geometry_shader) 105 { 106 extBehavior[TExtension::EXT_geometry_shader] = EBhUndefined; 107 } 108 if (resources.OES_geometry_shader) 109 { 110 extBehavior[TExtension::OES_geometry_shader] = EBhUndefined; 111 } 112 if (resources.OES_shader_io_blocks) 113 { 114 extBehavior[TExtension::OES_shader_io_blocks] = EBhUndefined; 115 } 116 if (resources.EXT_shader_io_blocks) 117 { 118 extBehavior[TExtension::EXT_shader_io_blocks] = EBhUndefined; 119 } 120 if (resources.EXT_gpu_shader5) 121 { 122 extBehavior[TExtension::EXT_gpu_shader5] = EBhUndefined; 123 } 124 if (resources.OES_gpu_shader5) 125 { 126 extBehavior[TExtension::OES_gpu_shader5] = EBhUndefined; 127 } 128 if (resources.EXT_shader_non_constant_global_initializers) 129 { 130 extBehavior[TExtension::EXT_shader_non_constant_global_initializers] = EBhUndefined; 131 } 132 if (resources.OES_texture_storage_multisample_2d_array) 133 { 134 extBehavior[TExtension::OES_texture_storage_multisample_2d_array] = EBhUndefined; 135 } 136 if (resources.OES_texture_3D) 137 { 138 extBehavior[TExtension::OES_texture_3D] = EBhUndefined; 139 } 140 if (resources.ANGLE_shader_pixel_local_storage) 141 { 142 extBehavior[TExtension::ANGLE_shader_pixel_local_storage] = EBhUndefined; 143 } 144 if (resources.ANGLE_texture_multisample) 145 { 146 extBehavior[TExtension::ANGLE_texture_multisample] = EBhUndefined; 147 } 148 if (resources.ANGLE_multi_draw) 149 { 150 extBehavior[TExtension::ANGLE_multi_draw] = EBhUndefined; 151 } 152 if (resources.ANGLE_base_vertex_base_instance_shader_builtin) 153 { 154 extBehavior[TExtension::ANGLE_base_vertex_base_instance_shader_builtin] = EBhUndefined; 155 } 156 if (resources.WEBGL_video_texture) 157 { 158 extBehavior[TExtension::WEBGL_video_texture] = EBhUndefined; 159 } 160 if (resources.APPLE_clip_distance) 161 { 162 extBehavior[TExtension::APPLE_clip_distance] = EBhUndefined; 163 } 164 if (resources.OES_texture_cube_map_array) 165 { 166 extBehavior[TExtension::OES_texture_cube_map_array] = EBhUndefined; 167 } 168 if (resources.EXT_texture_cube_map_array) 169 { 170 extBehavior[TExtension::EXT_texture_cube_map_array] = EBhUndefined; 171 } 172 if (resources.EXT_texture_query_lod) 173 { 174 extBehavior[TExtension::EXT_texture_query_lod] = EBhUndefined; 175 } 176 if (resources.EXT_texture_shadow_lod) 177 { 178 extBehavior[TExtension::EXT_texture_shadow_lod] = EBhUndefined; 179 } 180 if (resources.EXT_shadow_samplers) 181 { 182 extBehavior[TExtension::EXT_shadow_samplers] = EBhUndefined; 183 } 184 if (resources.OES_shader_multisample_interpolation) 185 { 186 extBehavior[TExtension::OES_shader_multisample_interpolation] = EBhUndefined; 187 } 188 if (resources.OES_shader_image_atomic) 189 { 190 extBehavior[TExtension::OES_shader_image_atomic] = EBhUndefined; 191 } 192 if (resources.EXT_tessellation_shader) 193 { 194 extBehavior[TExtension::EXT_tessellation_shader] = EBhUndefined; 195 } 196 if (resources.OES_tessellation_shader) 197 { 198 extBehavior[TExtension::OES_tessellation_shader] = EBhUndefined; 199 } 200 if (resources.OES_texture_buffer) 201 { 202 extBehavior[TExtension::OES_texture_buffer] = EBhUndefined; 203 } 204 if (resources.EXT_texture_buffer) 205 { 206 extBehavior[TExtension::EXT_texture_buffer] = EBhUndefined; 207 } 208 if (resources.OES_sample_variables) 209 { 210 extBehavior[TExtension::OES_sample_variables] = EBhUndefined; 211 } 212 if (resources.EXT_clip_cull_distance) 213 { 214 extBehavior[TExtension::EXT_clip_cull_distance] = EBhUndefined; 215 } 216 if (resources.ANGLE_clip_cull_distance) 217 { 218 extBehavior[TExtension::ANGLE_clip_cull_distance] = EBhUndefined; 219 } 220 if (resources.ANDROID_extension_pack_es31a) 221 { 222 extBehavior[TExtension::ANDROID_extension_pack_es31a] = EBhUndefined; 223 } 224 if (resources.KHR_blend_equation_advanced) 225 { 226 extBehavior[TExtension::KHR_blend_equation_advanced] = EBhUndefined; 227 } 228 } 229 ResetExtensionBehavior(const ShBuiltInResources & resources,TExtensionBehavior & extBehavior,const ShCompileOptions & compileOptions)230void ResetExtensionBehavior(const ShBuiltInResources &resources, 231 TExtensionBehavior &extBehavior, 232 const ShCompileOptions &compileOptions) 233 { 234 for (auto &ext : extBehavior) 235 { 236 ext.second = EBhUndefined; 237 } 238 if (resources.ARB_texture_rectangle) 239 { 240 if (compileOptions.disableARBTextureRectangle) 241 { 242 // Remove ARB_texture_rectangle so it can't be enabled by extension directives. 243 extBehavior.erase(TExtension::ARB_texture_rectangle); 244 } 245 else 246 { 247 // Restore ARB_texture_rectangle in case it was removed during an earlier reset. As 248 // noted above, it doesn't follow the standard for extension directives and is 249 // enabled by default. 250 extBehavior[TExtension::ARB_texture_rectangle] = EBhEnable; 251 } 252 } 253 } 254 255 } // namespace sh 256