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_KHR_external_memory_fd extension, on which the 112 // GL_EXT_memory_object_fd extension can be layered. 113 Feature supportsExternalMemoryFd = { 114 "supports_external_memory_fd", FeatureCategory::VulkanFeatures, 115 "VkDevice supports the VK_KHR_external_memory_fd extension", &members}; 116 117 // Whether the VkDevice supports the VK_FUCHSIA_external_memory 118 // extension, on which the GL_ANGLE_memory_object_fuchsia extension can be layered. 119 angle::Feature supportsExternalMemoryFuchsia = { 120 "supports_external_memory_fuchsia", FeatureCategory::VulkanFeatures, 121 "VkDevice supports the VK_FUCHSIA_external_memory extension", &members}; 122 123 // Whether the VkDevice supports the VK_KHR_external_semaphore_fd extension, on which the 124 // GL_EXT_semaphore_fd extension can be layered. 125 Feature supportsExternalSemaphoreFd = { 126 "supports_external_semaphore_fd", FeatureCategory::VulkanFeatures, 127 "VkDevice supports the VK_KHR_external_semaphore_fd extension", &members}; 128 129 // Whether the VkDevice supports the VK_FUCHSIA_external_semaphore 130 // extension, on which the GL_ANGLE_semaphore_fuchsia extension can be layered. 131 angle::Feature supportsExternalSemaphoreFuchsia = { 132 "supports_external_semaphore_fuchsia", FeatureCategory::VulkanFeatures, 133 "VkDevice supports the VK_FUCHSIA_external_semaphore extension", &members}; 134 135 // Whether the VkDevice supports the VK_EXT_shader_stencil_export extension, which is used to 136 // perform multisampled resolve of stencil buffer. A multi-step workaround is used instead if 137 // this extension is not available. 138 Feature supportsShaderStencilExport = { 139 "supports_shader_stencil_export", FeatureCategory::VulkanFeatures, 140 "VkDevice supports the VK_EXT_shader_stencil_export extension", &members}; 141 142 // Where VK_EXT_transform_feedback is not support, an emulation path is used. 143 // http://anglebug.com/3205 144 Feature emulateTransformFeedback = { 145 "emulate_transform_feedback", FeatureCategory::VulkanFeatures, 146 "Emulate transform feedback as the VK_EXT_transform_feedback is not present.", &members, 147 "http://anglebug.com/3205"}; 148 149 // Where VK_EXT_transform_feedback is supported, it's preferred over an emulation path. 150 // http://anglebug.com/3206 151 Feature supportsTransformFeedbackExtension = { 152 "supports_transform_feedback_extension", FeatureCategory::VulkanFeatures, 153 "Transform feedback uses the VK_EXT_transform_feedback extension.", &members, 154 "http://anglebug.com/3206"}; 155 156 // Whether the VkDevice supports the VK_EXT_index_type_uint8 extension 157 // http://anglebug.com/4405 158 Feature supportsIndexTypeUint8 = {"supports_index_type_uint8", FeatureCategory::VulkanFeatures, 159 "VkDevice supports the VK_EXT_index_type_uint8 extension", 160 &members, "http://anglebug.com/4405"}; 161 162 // VK_PRESENT_MODE_FIFO_KHR causes random timeouts on Linux Intel. http://anglebug.com/3153 163 Feature disableFifoPresentMode = { 164 "disable_fifo_present_mode", FeatureCategory::VulkanWorkarounds, 165 "VK_PRESENT_MODE_FIFO_KHR causes random timeouts", &members, "http://anglebug.com/3153"}; 166 167 // On Qualcomm, gaps in bound descriptor set indices causes the post-gap sets to misbehave. 168 // For example, binding only descriptor set 3 results in zero being read from a uniform buffer 169 // object within that set. This flag results in empty descriptor sets being bound for any 170 // unused descriptor set to work around this issue. http://anglebug.com/2727 171 Feature bindEmptyForUnusedDescriptorSets = { 172 "bind_empty_for_unused_descriptor_sets", FeatureCategory::VulkanWorkarounds, 173 "Gaps in bound descriptor set indices causes the post-gap sets to misbehave", &members, 174 "http://anglebug.com/2727"}; 175 176 // OES_depth_texture is a commonly expected feature on Android. However it 177 // requires that D16_UNORM support texture filtering 178 // (e.g. VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT) and some devices 179 // do not. Work-around this by setting saying D16_UNORM supports filtering 180 // anyway. 181 Feature forceD16TexFilter = { 182 "force_D16_texture_filter", FeatureCategory::VulkanWorkarounds, 183 "VK_FORMAT_D16_UNORM does not support VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT, " 184 "which prevents OES_depth_texture from being supported.", 185 &members, "http://anglebug.com/3452"}; 186 187 // On some android devices, vkCmdBlitImage with flipped coordinates blits incorrectly. This 188 // workaround makes sure this path is avoided. http://anglebug.com/3498 189 Feature disableFlippingBlitWithCommand = { 190 "disable_flipping_blit_with_command", FeatureCategory::VulkanWorkarounds, 191 "vkCmdBlitImage with flipped coordinates blits incorrectly.", &members, 192 "http://anglebug.com/3498"}; 193 194 // On platform with Intel or AMD GPU, a window resizing would not trigger the vulkan driver to 195 // return VK_ERROR_OUT_OF_DATE on swapchain present. Work-around by query current window extent 196 // every frame to detect a window resizing. 197 // http://anglebug.com/3623, http://anglebug.com/3624, http://anglebug.com/3625 198 Feature perFrameWindowSizeQuery = { 199 "per_frame_window_size_query", FeatureCategory::VulkanWorkarounds, 200 "Vulkan swapchain is not returning VK_ERROR_OUT_OF_DATE when window resizing", &members, 201 "http://anglebug.com/3623, http://anglebug.com/3624, http://anglebug.com/3625"}; 202 203 // Seamful cube map emulation misbehaves on the AMD windows driver, so it's disallowed. 204 Feature disallowSeamfulCubeMapEmulation = { 205 "disallow_seamful_cube_map_emulation", FeatureCategory::VulkanWorkarounds, 206 "Seamful cube map emulation misbehaves on some drivers, so it's disallowed", &members, 207 "http://anglebug.com/3243"}; 208 209 // Qualcomm and SwiftShader shader compiler doesn't support sampler arrays as parameters, so 210 // revert to old RewriteStructSamplers behavior, which produces fewer. 211 Feature forceOldRewriteStructSamplers = { 212 "force_old_rewrite_struct_samplers", FeatureCategory::VulkanWorkarounds, 213 "Some shader compilers don't support sampler arrays as parameters, so revert to old " 214 "RewriteStructSamplers behavior, which produces fewer.", 215 &members, "http://anglebug.com/2703"}; 216 217 // Vulkan considers vertex attribute accesses to count up to the last multiple of the stride. 218 // This additional access supports AMD's robust buffer access implementation. 219 // AMDVLK in particular will return incorrect values when the vertex access extends into the 220 // range that would be the stride padding and the buffer is too small. 221 // This workaround limits GL_MAX_VERTEX_ATTRIB_STRIDE to a reasonable value and pads out 222 // every buffer allocation size to be large enough to support a maximum vertex stride. 223 // http://anglebug.com/4428 224 Feature padBuffersToMaxVertexAttribStride = { 225 "pad_buffers_to_max_vertex_attrib_stride", FeatureCategory::VulkanWorkarounds, 226 "Vulkan considers vertex attribute accesses to count up to the last multiple of the " 227 "stride. This additional access supports AMD's robust buffer access implementation. " 228 "AMDVLK in particular will return incorrect values when the vertex access extends into " 229 "the range that would be the stride padding and the buffer is too small. " 230 "This workaround limits GL_MAX_VERTEX_ATTRIB_STRIDE to a maximum value and " 231 "pads up every buffer allocation size to be a multiple of the maximum stride.", 232 &members, "http://anglebug.com/4428"}; 233 234 // Whether the VkDevice supports the VK_EXT_swapchain_colorspace extension 235 // http://anglebug.com/2514 236 Feature supportsSwapchainColorspace = { 237 "supports_swapchain_colorspace", FeatureCategory::VulkanFeatures, 238 "VkDevice supports the VK_EXT_swapchain_colorspace extension", &members, 239 "http://anglebug.com/2514"}; 240 241 // Whether the VkDevice supports the VK_EXT_external_memory_host extension, on which the 242 // ANGLE_iosurface_client_buffer extension can be layered. 243 Feature supportsExternalMemoryHost = { 244 "supports_external_memory_host", FeatureCategory::VulkanFeatures, 245 "VkDevice supports the VK_EXT_external_memory_host extension", &members}; 246 247 // Whether to fill new buffers and textures with nonzero data to sanitize robust resource 248 // initialization and flush out assumptions about zero init. 249 Feature allocateNonZeroMemory = { 250 "allocate_non_zero_memory", FeatureCategory::VulkanFeatures, 251 "Fill new allocations with non-zero values to flush out errors.", &members, 252 "http://anglebug.com/4384"}; 253 254 // Persistently map buffer memory until destroy, saves on map/unmap IOCTL overhead 255 // for buffers that are updated frequently. 256 Feature persistentlyMappedBuffers = { 257 "persistently_mapped_buffers", FeatureCategory::VulkanFeatures, 258 "Persistently map buffer memory to reduce map/unmap IOCTL overhead.", &members, 259 "http://anglebug.com/2162"}; 260 261 // Android needs to pre-rotate surfaces that are not oriented per the native device's 262 // orientation (e.g. a landscape application on a Pixel phone). This feature works for 263 // full-screen applications. http://anglebug.com/3502 264 Feature enablePreRotateSurfaces = {"enable_pre_rotation_surfaces", 265 FeatureCategory::VulkanFeatures, 266 "Enable Android pre-rotation for landscape applications", 267 &members, "http://anglebug.com/3502"}; 268 269 // Cache FramebufferVk objects. Currently hitting a bug on Apple: http://anglebug.com/4442 270 Feature enableFramebufferVkCache = { 271 "enable_framebuffer_vk_cache", FeatureCategory::VulkanFeatures, 272 "Enable FramebufferVk objects to be cached", &members, "http://anglebug.com/4442"}; 273 274 // Enable precision qualifiers for shaders generated by Vulkan backend http://anglebug.com/3078 275 Feature enablePrecisionQualifiers = { 276 "enable_precision_qualifiers", FeatureCategory::VulkanFeatures, 277 "Enable precision qualifiers in shaders", &members, "http://anglebug.com/3078"}; 278 279 // Support Depth/Stencil rendering feedback loops by masking out the depth/stencil buffer. 280 // Manhattan uses this feature in a few draw calls. 281 Feature supportDepthStencilRenderingFeedbackLoops = { 282 "support_depth_stencil_rendering_feedback_loops", FeatureCategory::VulkanFeatures, 283 "Suport depth/stencil rendering feedback loops", &members, "http://anglebug.com/4490"}; 284 }; 285 286 inline FeaturesVk::FeaturesVk() = default; 287 inline FeaturesVk::~FeaturesVk() = default; 288 289 } // namespace angle 290 291 #endif // ANGLE_PLATFORM_FEATURESVK_H_ 292