1 // 2 // Copyright 2018 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 // FeaturesVk.h: Optional features for the Vulkan renderer. 7 // 8 9 #ifndef ANGLE_PLATFORM_FEATURESVK_H_ 10 #define ANGLE_PLATFORM_FEATURESVK_H_ 11 12 #include "platform/Feature.h" 13 14 namespace angle 15 { 16 17 struct FeaturesVk : FeatureSetBase 18 { 19 FeaturesVk(); 20 ~FeaturesVk(); 21 22 // Line segment rasterization must follow OpenGL rules. This means using an algorithm similar 23 // to Bresenham's. Vulkan uses a different algorithm. This feature enables the use of pixel 24 // shader patching to implement OpenGL basic line rasterization rules. This feature will 25 // normally always be enabled. Exposing it as an option enables performance testing. 26 Feature basicGLLineRasterization = { 27 "basic_gl_line_rasterization", FeatureCategory::VulkanFeatures, 28 "Enable the use of pixel shader patching to implement OpenGL basic line " 29 "rasterization rules", 30 &members}; 31 32 // If the VK_EXT_line_rasterization extension is available we'll use it to get 33 // Bresenham line rasterization. 34 Feature bresenhamLineRasterization = { 35 "bresenham_line_rasterization", FeatureCategory::VulkanFeatures, 36 "Enable Bresenham line rasterization via VK_EXT_line_rasterization extension", &members}; 37 38 // If the VK_EXT_provoking_vertex extension is available, we'll use it to set 39 // the provoking vertex mode 40 Feature provokingVertex = {"provoking_vertex", FeatureCategory::VulkanFeatures, 41 "Enable provoking vertex mode via VK_EXT_provoking_vertex extension", 42 &members}; 43 44 // Flips the viewport to render upside-down. This has the effect to render the same way as 45 // OpenGL. If this feature gets enabled, we enable the KHR_MAINTENANCE_1 extension to allow 46 // negative viewports. We inverse rendering to the backbuffer by reversing the height of the 47 // viewport and increasing Y by the height. So if the viewport was (0,0,width,height), it 48 // becomes (0, height, width, -height). Unfortunately, when we start doing this, we also need 49 // to adjust a lot of places since the rendering now happens upside-down. Affected places so 50 // far: 51 // -readPixels 52 // -copyTexImage 53 // -framebuffer blit 54 // -generating mipmaps 55 // -Point sprites tests 56 // -texStorage 57 Feature flipViewportY = {"flip_viewport_y", FeatureCategory::VulkanFeatures, 58 "Flips the viewport to render upside-down", &members}; 59 60 // Add an extra copy region when using vkCmdCopyBuffer as the Windows Intel driver seems 61 // to have a bug where the last region is ignored. 62 Feature extraCopyBufferRegion = { 63 "extra_copy_buffer_region", FeatureCategory::VulkanWorkarounds, 64 "Some drivers seem to have a bug where the last copy region in vkCmdCopyBuffer is ignored", 65 &members}; 66 67 // This flag is added for the sole purpose of end2end tests, to test the correctness 68 // of various algorithms when a fallback format is used, such as using a packed format to 69 // emulate a depth- or stencil-only format. 70 Feature forceFallbackFormat = {"force_fallback_format", FeatureCategory::VulkanWorkarounds, 71 "Force a fallback format for angle_end2end_tests", &members}; 72 73 // On some NVIDIA drivers the point size range reported from the API is inconsistent with the 74 // actual behavior. Clamp the point size to the value from the API to fix this. 75 // Tracked in http://anglebug.com/2970. 76 Feature clampPointSize = { 77 "clamp_point_size", FeatureCategory::VulkanWorkarounds, 78 "The point size range reported from the API is inconsistent with the actual behavior", 79 &members, "http://anglebug.com/2970"}; 80 81 // On some android devices, the memory barrier between the compute shader that converts vertex 82 // attributes and the vertex shader that reads from it is ineffective. Only known workaround is 83 // to perform a flush after the conversion. http://anglebug.com/3016 84 Feature flushAfterVertexConversion = { 85 "flush_after_vertex_conversion", FeatureCategory::VulkanWorkarounds, 86 "The memory barrier between the compute shader that converts vertex attributes and the " 87 "vertex shader that reads from it is ineffective", 88 &members, "http://anglebug.com/3016"}; 89 90 // Whether the VkDevice supports the VK_KHR_incremental_present extension, on which the 91 // EGL_KHR_swap_buffers_with_damage extension can be layered. 92 Feature supportsIncrementalPresent = { 93 "supports_incremental_present", FeatureCategory::VulkanFeatures, 94 "VkDevice supports the VK_KHR_incremental_present extension", &members}; 95 96 // Whether texture copies on cube map targets should be done on GPU. This is a workaround for 97 // Intel drivers on windows that have an issue with creating single-layer views on cube map 98 // textures. 99 Feature forceCPUPathForCubeMapCopy = { 100 "force_cpu_path_for_cube_map_copy", FeatureCategory::VulkanWorkarounds, 101 "Some drivers have an issue with creating single-layer views on cube map textures", 102 &members}; 103 104 // Whether the VkDevice supports the VK_ANDROID_external_memory_android_hardware_buffer 105 // extension, on which the EGL_ANDROID_image_native_buffer extension can be layered. 106 Feature supportsAndroidHardwareBuffer = { 107 "supports_android_hardware_buffer", FeatureCategory::VulkanFeatures, 108 "VkDevice supports the VK_ANDROID_external_memory_android_hardware_buffer extension", 109 &members}; 110 111 // Whether the VkDevice supports the VK_GGP_frame_token extension, on which 112 // the EGL_ANGLE_swap_with_frame_token extension can be layered. 113 Feature supportsGGPFrameToken = {"supports_ggp_frame_token", FeatureCategory::VulkanFeatures, 114 "VkDevice supports the VK_GGP_frame_token extension", 115 &members}; 116 117 // Whether the VkDevice supports the VK_KHR_external_memory_fd extension, on which the 118 // GL_EXT_memory_object_fd extension can be layered. 119 Feature supportsExternalMemoryFd = { 120 "supports_external_memory_fd", FeatureCategory::VulkanFeatures, 121 "VkDevice supports the VK_KHR_external_memory_fd extension", &members}; 122 123 // Whether the VkDevice supports the VK_FUCHSIA_external_memory 124 // extension, on which the GL_ANGLE_memory_object_fuchsia extension can be layered. 125 angle::Feature supportsExternalMemoryFuchsia = { 126 "supports_external_memory_fuchsia", FeatureCategory::VulkanFeatures, 127 "VkDevice supports the VK_FUCHSIA_external_memory extension", &members}; 128 129 angle::Feature supportsFilteringPrecision = { 130 "supports_filtering_precision_google", FeatureCategory::VulkanFeatures, 131 "VkDevice supports the VK_GOOGLE_sampler_filtering_precision extension", &members}; 132 133 // Whether the VkDevice supports the VK_KHR_external_fence_capabilities extension. 134 Feature supportsExternalFenceCapabilities = { 135 "supports_external_fence_capabilities", FeatureCategory::VulkanFeatures, 136 "VkDevice supports the VK_KHR_external_fence_capabilities extension", &members}; 137 138 // Whether the VkDevice supports the VK_KHR_external_semaphore_capabilities extension. 139 Feature supportsExternalSemaphoreCapabilities = { 140 "supports_external_semaphore_capabilities", FeatureCategory::VulkanFeatures, 141 "VkDevice supports the VK_KHR_external_semaphore_capabilities extension", &members}; 142 143 // Whether the VkDevice supports the VK_KHR_external_semaphore_fd extension, on which the 144 // GL_EXT_semaphore_fd extension can be layered. 145 Feature supportsExternalSemaphoreFd = { 146 "supports_external_semaphore_fd", FeatureCategory::VulkanFeatures, 147 "VkDevice supports the VK_KHR_external_semaphore_fd extension", &members}; 148 149 // Whether the VkDevice supports the VK_FUCHSIA_external_semaphore 150 // extension, on which the GL_ANGLE_semaphore_fuchsia extension can be layered. 151 angle::Feature supportsExternalSemaphoreFuchsia = { 152 "supports_external_semaphore_fuchsia", FeatureCategory::VulkanFeatures, 153 "VkDevice supports the VK_FUCHSIA_external_semaphore extension", &members}; 154 155 // Whether the VkDevice supports the VK_KHR_external_fence_fd extension, on which the 156 // EGL_ANDROID_native_fence extension can be layered. 157 Feature supportsExternalFenceFd = {"supports_external_fence_fd", 158 FeatureCategory::VulkanFeatures, 159 "VkDevice supports the VK_KHR_external_fence_fd extension", 160 &members, "http://anglebug.com/2517"}; 161 162 // Whether the VkDevice can support EGL_ANDROID_native_fence_sync extension. 163 Feature supportsAndroidNativeFenceSync = { 164 "supports_android_native_fence_sync", FeatureCategory::VulkanFeatures, 165 "VkDevice supports the EGL_ANDROID_native_fence_sync extension", &members, 166 "http://anglebug.com/2517"}; 167 168 // Whether the VkDevice supports the VK_EXT_shader_stencil_export extension, which is used to 169 // perform multisampled resolve of stencil buffer. A multi-step workaround is used instead if 170 // this extension is not available. 171 Feature supportsShaderStencilExport = { 172 "supports_shader_stencil_export", FeatureCategory::VulkanFeatures, 173 "VkDevice supports the VK_EXT_shader_stencil_export extension", &members}; 174 175 // Where VK_EXT_transform_feedback is not support, an emulation path is used. 176 // http://anglebug.com/3205 177 Feature emulateTransformFeedback = { 178 "emulate_transform_feedback", FeatureCategory::VulkanFeatures, 179 "Emulate transform feedback as the VK_EXT_transform_feedback is not present.", &members, 180 "http://anglebug.com/3205"}; 181 182 // Where VK_EXT_transform_feedback is supported, it's preferred over an emulation path. 183 // http://anglebug.com/3206 184 Feature supportsTransformFeedbackExtension = { 185 "supports_transform_feedback_extension", FeatureCategory::VulkanFeatures, 186 "Transform feedback uses the VK_EXT_transform_feedback extension.", &members, 187 "http://anglebug.com/3206"}; 188 189 // Whether the VkDevice supports the VK_EXT_index_type_uint8 extension 190 // http://anglebug.com/4405 191 Feature supportsIndexTypeUint8 = {"supports_index_type_uint8", FeatureCategory::VulkanFeatures, 192 "VkDevice supports the VK_EXT_index_type_uint8 extension", 193 &members, "http://anglebug.com/4405"}; 194 195 // VK_PRESENT_MODE_FIFO_KHR causes random timeouts on Linux Intel. http://anglebug.com/3153 196 Feature disableFifoPresentMode = { 197 "disable_fifo_present_mode", FeatureCategory::VulkanWorkarounds, 198 "VK_PRESENT_MODE_FIFO_KHR causes random timeouts", &members, "http://anglebug.com/3153"}; 199 200 // On Qualcomm, gaps in bound descriptor set indices causes the post-gap sets to misbehave. 201 // For example, binding only descriptor set 3 results in zero being read from a uniform buffer 202 // object within that set. This flag results in empty descriptor sets being bound for any 203 // unused descriptor set to work around this issue. http://anglebug.com/2727 204 Feature bindEmptyForUnusedDescriptorSets = { 205 "bind_empty_for_unused_descriptor_sets", FeatureCategory::VulkanWorkarounds, 206 "Gaps in bound descriptor set indices causes the post-gap sets to misbehave", &members, 207 "http://anglebug.com/2727"}; 208 209 // OES_depth_texture is a commonly expected feature on Android. However it 210 // requires that D16_UNORM support texture filtering 211 // (e.g. VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT) and some devices 212 // do not. Work-around this by setting saying D16_UNORM supports filtering 213 // anyway. 214 Feature forceD16TexFilter = { 215 "force_D16_texture_filter", FeatureCategory::VulkanWorkarounds, 216 "VK_FORMAT_D16_UNORM does not support VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT, " 217 "which prevents OES_depth_texture from being supported.", 218 &members, "http://anglebug.com/3452"}; 219 220 // On some android devices, vkCmdBlitImage with flipped coordinates blits incorrectly. This 221 // workaround makes sure this path is avoided. http://anglebug.com/3498 222 Feature disableFlippingBlitWithCommand = { 223 "disable_flipping_blit_with_command", FeatureCategory::VulkanWorkarounds, 224 "vkCmdBlitImage with flipped coordinates blits incorrectly.", &members, 225 "http://anglebug.com/3498"}; 226 227 // On platform with Intel or AMD GPU, a window resizing would not trigger the vulkan driver to 228 // return VK_ERROR_OUT_OF_DATE on swapchain present. Work-around by query current window extent 229 // every frame to detect a window resizing. 230 // http://anglebug.com/3623, http://anglebug.com/3624, http://anglebug.com/3625 231 Feature perFrameWindowSizeQuery = { 232 "per_frame_window_size_query", FeatureCategory::VulkanWorkarounds, 233 "Vulkan swapchain is not returning VK_ERROR_OUT_OF_DATE when window resizing", &members, 234 "http://anglebug.com/3623, http://anglebug.com/3624, http://anglebug.com/3625"}; 235 236 // Seamful cube map emulation misbehaves on the AMD windows driver, so it's disallowed. 237 Feature disallowSeamfulCubeMapEmulation = { 238 "disallow_seamful_cube_map_emulation", FeatureCategory::VulkanWorkarounds, 239 "Seamful cube map emulation misbehaves on some drivers, so it's disallowed", &members, 240 "http://anglebug.com/3243"}; 241 242 // Qualcomm and SwiftShader shader compiler doesn't support sampler arrays as parameters, so 243 // revert to old RewriteStructSamplers behavior, which produces fewer. 244 Feature forceOldRewriteStructSamplers = { 245 "force_old_rewrite_struct_samplers", FeatureCategory::VulkanWorkarounds, 246 "Some shader compilers don't support sampler arrays as parameters, so revert to old " 247 "RewriteStructSamplers behavior, which produces fewer.", 248 &members, "http://anglebug.com/2703"}; 249 250 // Vulkan considers vertex attribute accesses to count up to the last multiple of the stride. 251 // This additional access supports AMD's robust buffer access implementation. 252 // AMDVLK in particular will return incorrect values when the vertex access extends into the 253 // range that would be the stride padding and the buffer is too small. 254 // This workaround limits GL_MAX_VERTEX_ATTRIB_STRIDE to a reasonable value and pads out 255 // every buffer allocation size to be large enough to support a maximum vertex stride. 256 // http://anglebug.com/4428 257 Feature padBuffersToMaxVertexAttribStride = { 258 "pad_buffers_to_max_vertex_attrib_stride", FeatureCategory::VulkanWorkarounds, 259 "Vulkan considers vertex attribute accesses to count up to the last multiple of the " 260 "stride. This additional access supports AMD's robust buffer access implementation. " 261 "AMDVLK in particular will return incorrect values when the vertex access extends into " 262 "the range that would be the stride padding and the buffer is too small. " 263 "This workaround limits GL_MAX_VERTEX_ATTRIB_STRIDE to a maximum value and " 264 "pads up every buffer allocation size to be a multiple of the maximum stride.", 265 &members, "http://anglebug.com/4428"}; 266 267 // Whether the VkDevice supports the VK_EXT_swapchain_colorspace extension 268 // http://anglebug.com/2514 269 Feature supportsSwapchainColorspace = { 270 "supports_swapchain_colorspace", FeatureCategory::VulkanFeatures, 271 "VkDevice supports the VK_EXT_swapchain_colorspace extension", &members, 272 "http://anglebug.com/2514"}; 273 274 // Whether the VkDevice supports the VK_EXT_external_memory_host extension, on which the 275 // ANGLE_iosurface_client_buffer extension can be layered. 276 Feature supportsExternalMemoryHost = { 277 "supports_external_memory_host", FeatureCategory::VulkanFeatures, 278 "VkDevice supports the VK_EXT_external_memory_host extension", &members}; 279 280 // Whether to fill new buffers and textures with nonzero data to sanitize robust resource 281 // initialization and flush out assumptions about zero init. 282 Feature allocateNonZeroMemory = { 283 "allocate_non_zero_memory", FeatureCategory::VulkanFeatures, 284 "Fill new allocations with non-zero values to flush out errors.", &members, 285 "http://anglebug.com/4384"}; 286 287 // Persistently map buffer memory until destroy, saves on map/unmap IOCTL overhead 288 // for buffers that are updated frequently. 289 Feature persistentlyMappedBuffers = { 290 "persistently_mapped_buffers", FeatureCategory::VulkanFeatures, 291 "Persistently map buffer memory to reduce map/unmap IOCTL overhead.", &members, 292 "http://anglebug.com/2162"}; 293 294 // Android needs to pre-rotate surfaces that are not oriented per the native device's 295 // orientation (e.g. a landscape application on a Pixel phone). This feature works for 296 // full-screen applications. http://anglebug.com/3502 297 Feature enablePreRotateSurfaces = {"enable_pre_rotation_surfaces", 298 FeatureCategory::VulkanFeatures, 299 "Enable Android pre-rotation for landscape applications", 300 &members, "http://anglebug.com/3502"}; 301 302 // Cache FramebufferVk objects. Currently hitting a bug on Apple: http://anglebug.com/4442 303 Feature enableFramebufferVkCache = { 304 "enable_framebuffer_vk_cache", FeatureCategory::VulkanFeatures, 305 "Enable FramebufferVk objects to be cached", &members, "http://anglebug.com/4442"}; 306 307 // Enable precision qualifiers for shaders generated by Vulkan backend http://anglebug.com/3078 308 Feature enablePrecisionQualifiers = { 309 "enable_precision_qualifiers", FeatureCategory::VulkanFeatures, 310 "Enable precision qualifiers in shaders", &members, "http://anglebug.com/3078"}; 311 312 // Support Depth/Stencil rendering feedback loops by masking out the depth/stencil buffer. 313 // Manhattan uses this feature in a few draw calls. 314 Feature supportDepthStencilRenderingFeedbackLoops = { 315 "support_depth_stencil_rendering_feedback_loops", FeatureCategory::VulkanFeatures, 316 "Suport depth/stencil rendering feedback loops", &members, "http://anglebug.com/4490"}; 317 318 // Desktop (at least NVIDIA) drivers prefer combining barriers into one vkCmdPipelineBarrier 319 // call over issuing multiple barrier calls with fine grained dependency information to have 320 // better performance. http://anglebug.com/4633 321 Feature preferAggregateBarrierCalls = { 322 "prefer_aggregate_barrier_calls", FeatureCategory::VulkanWorkarounds, 323 "Single barrier call is preferred over multiple calls with " 324 "fine grained pipeline stage dependency information", 325 &members, "http://anglebug.com/4633"}; 326 327 // Enable parallel thread that processes and submits vulkan command buffers. 328 // Currently off by default to enable testing. 329 Feature enableCommandProcessingThread = { 330 "enable_command_processing_thread", FeatureCategory::VulkanFeatures, 331 "Enable parallel processing and submission of Vulkan commands in worker thread", &members, 332 "http://anglebug.com/4324"}; 333 }; 334 335 inline FeaturesVk::FeaturesVk() = default; 336 inline FeaturesVk::~FeaturesVk() = default; 337 338 } // namespace angle 339 340 #endif // ANGLE_PLATFORM_FEATURESVK_H_ 341