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 // UtilsVk.h: 7 // Defines the UtilsVk class, a helper for various internal draw/dispatch utilities such as 8 // buffer clear and copy, image clear and copy, texture mip map generation, etc. 9 // 10 // - Convert index buffer: 11 // * Used by VertexArrayVk::convertIndexBufferGPU() to convert a ubyte element array to ushort 12 // - Convert vertex buffer: 13 // * Used by VertexArrayVk::convertVertexBufferGPU() to convert vertex attributes from 14 // unsupported formats to their fallbacks. 15 // - Image clear: Used by FramebufferVk::clearWithDraw(). 16 // - Image copy: Used by TextureVk::copySubImageImplWithDraw(). 17 // - Image copy bits: Used by ImageHelper::CopyImageSubData() to perform bitwise copies between 18 // RGB formats where at least one of src and dst use RGBA as fallback. 19 // - Color blit/resolve: Used by FramebufferVk::blit() to implement blit or multisample resolve 20 // on color images. 21 // - Depth/Stencil blit/resolve: Used by FramebufferVk::blit() to implement blit or multisample 22 // resolve on depth/stencil images. 23 // - Generate mipmap: Used by TextureVk::generateMipmapsWithCompute(). 24 // - Overlay Draw: Used by OverlayVk to draw a UI for debugging. 25 // - Mipmap generation: Used by TextureVk to generate mipmaps more efficiently in compute. 26 // 27 28 #ifndef LIBANGLE_RENDERER_VULKAN_UTILSVK_H_ 29 #define LIBANGLE_RENDERER_VULKAN_UTILSVK_H_ 30 31 #include "libANGLE/renderer/vulkan/vk_cache_utils.h" 32 #include "libANGLE/renderer/vulkan/vk_helpers.h" 33 #include "libANGLE/renderer/vulkan/vk_internal_shaders_autogen.h" 34 35 namespace rx 36 { 37 class UtilsVk : angle::NonCopyable 38 { 39 public: 40 UtilsVk(); 41 ~UtilsVk(); 42 43 void destroy(ContextVk *contextVk); 44 45 struct ConvertIndexParameters 46 { 47 uint32_t srcOffset = 0; 48 uint32_t dstOffset = 0; 49 uint32_t maxIndex = 0; 50 }; 51 52 struct ConvertIndexIndirectParameters 53 { 54 uint32_t srcIndirectBufOffset = 0; 55 uint32_t srcIndexBufOffset = 0; 56 uint32_t dstIndexBufOffset = 0; 57 uint32_t maxIndex = 0; 58 uint32_t dstIndirectBufOffset = 0; 59 }; 60 61 struct ConvertLineLoopIndexIndirectParameters 62 { 63 uint32_t indirectBufferOffset = 0; 64 uint32_t dstIndirectBufferOffset = 0; 65 uint32_t srcIndexBufferOffset = 0; 66 uint32_t dstIndexBufferOffset = 0; 67 uint32_t indicesBitsWidth = 0; 68 }; 69 70 struct ConvertLineLoopArrayIndirectParameters 71 { 72 uint32_t indirectBufferOffset = 0; 73 uint32_t dstIndirectBufferOffset = 0; 74 uint32_t dstIndexBufferOffset = 0; 75 }; 76 77 struct ConvertVertexParameters 78 { 79 size_t vertexCount; 80 const angle::Format *srcFormat; 81 const angle::Format *dstFormat; 82 size_t srcStride; 83 size_t srcOffset; 84 size_t dstOffset; 85 }; 86 87 struct ClearFramebufferParameters 88 { 89 // Satisfy chromium-style with a constructor that does what = {} was already doing in a 90 // safer way. 91 ClearFramebufferParameters(); 92 93 gl::Rectangle clearArea; 94 95 bool clearColor; 96 bool clearDepth; 97 bool clearStencil; 98 99 uint8_t stencilMask; 100 VkColorComponentFlags colorMaskFlags; 101 uint32_t colorAttachmentIndexGL; 102 const angle::Format *colorFormat; 103 104 VkClearColorValue colorClearValue; 105 VkClearDepthStencilValue depthStencilClearValue; 106 }; 107 108 struct BlitResolveParameters 109 { 110 // |srcOffset| and |dstIndexBufferOffset| define the original blit/resolve offsets, possibly 111 // flipped. 112 int srcOffset[2]; 113 int dstOffset[2]; 114 // Amount to add to x and y axis for certain rotations 115 int rotatedOffsetFactor[2]; 116 // |stretch| is SourceDimension / DestDimension used to transfer dst coordinates to source. 117 float stretch[2]; 118 // |srcExtents| is used to normalize source coordinates for sampling. 119 int srcExtents[2]; 120 // |blitArea| is the area in destination where blit happens. It's expected that scissor 121 // and source clipping effects have already been applied to it. 122 gl::Rectangle blitArea; 123 int srcLayer; 124 // Whether linear or point sampling should be used. 125 bool linear; 126 bool flipX; 127 bool flipY; 128 SurfaceRotation rotation; 129 }; 130 131 struct ClearImageParameters 132 { 133 gl::Rectangle clearArea; 134 135 vk::LevelIndex dstMip; 136 int dstLayer; 137 138 VkColorComponentFlags colorMaskFlags; 139 VkClearColorValue colorClearValue; 140 }; 141 142 struct CopyImageParameters 143 { 144 int srcOffset[2]; 145 int srcExtents[2]; 146 int dstOffset[2]; 147 int srcMip; 148 int srcLayer; 149 int srcHeight; 150 gl::LevelIndex dstMip; 151 int dstLayer; 152 bool srcPremultiplyAlpha; 153 bool srcUnmultiplyAlpha; 154 bool srcFlipY; 155 bool dstFlipY; 156 SurfaceRotation srcRotation; 157 GLenum srcColorEncoding; 158 GLenum dstColorEncoding; 159 }; 160 161 struct CopyImageBitsParameters 162 { 163 int srcOffset[3]; 164 gl::LevelIndex srcLevel; 165 int dstOffset[3]; 166 gl::LevelIndex dstLevel; 167 uint32_t copyExtents[3]; 168 }; 169 170 struct CopyImageToBufferParameters 171 { 172 int srcOffset[2]; 173 vk::LevelIndex srcMip; 174 int srcLayer; 175 uint32_t size[2]; 176 ptrdiff_t outputOffset; 177 uint32_t outputPitch; 178 bool reverseRowOrder; 179 const angle::Format *outputFormat; 180 }; 181 182 struct OverlayDrawParameters 183 { 184 uint32_t textWidgetCount; 185 uint32_t graphWidgetCount; 186 bool rotateXY; 187 }; 188 189 struct GenerateMipmapParameters 190 { 191 uint32_t srcLevel; 192 uint32_t dstLevelCount; 193 }; 194 195 struct UnresolveParameters 196 { 197 gl::DrawBufferMask unresolveColorMask; 198 bool unresolveDepth; 199 bool unresolveStencil; 200 }; 201 202 // Based on the maximum number of levels in GenerateMipmap.comp. 203 static constexpr uint32_t kGenerateMipmapMaxLevels = 6; 204 static uint32_t GetGenerateMipmapMaxLevels(ContextVk *contextVk); 205 206 angle::Result convertIndexBuffer(ContextVk *contextVk, 207 vk::BufferHelper *dst, 208 vk::BufferHelper *src, 209 const ConvertIndexParameters ¶ms); 210 angle::Result convertIndexIndirectBuffer(ContextVk *contextVk, 211 vk::BufferHelper *srcIndirectBuf, 212 vk::BufferHelper *srcIndexBuf, 213 vk::BufferHelper *dstIndirectBuf, 214 vk::BufferHelper *dstIndexBuf, 215 const ConvertIndexIndirectParameters ¶ms); 216 217 angle::Result convertLineLoopIndexIndirectBuffer( 218 ContextVk *contextVk, 219 vk::BufferHelper *srcIndirectBuffer, 220 vk::BufferHelper *dstIndirectBuffer, 221 vk::BufferHelper *dstIndexBuffer, 222 vk::BufferHelper *srcIndexBuffer, 223 const ConvertLineLoopIndexIndirectParameters ¶ms); 224 225 angle::Result convertLineLoopArrayIndirectBuffer( 226 ContextVk *contextVk, 227 vk::BufferHelper *srcIndirectBuffer, 228 vk::BufferHelper *dstIndirectBuffer, 229 vk::BufferHelper *dstIndexBuffer, 230 const ConvertLineLoopArrayIndirectParameters ¶ms); 231 232 angle::Result convertVertexBuffer(ContextVk *contextVk, 233 vk::BufferHelper *dst, 234 vk::BufferHelper *src, 235 const ConvertVertexParameters ¶ms); 236 237 angle::Result clearFramebuffer(ContextVk *contextVk, 238 FramebufferVk *framebuffer, 239 const ClearFramebufferParameters ¶ms); 240 241 // Resolve images if multisampled. Blit otherwise. 242 angle::Result colorBlitResolve(ContextVk *contextVk, 243 FramebufferVk *framebuffer, 244 vk::ImageHelper *src, 245 const vk::ImageView *srcView, 246 const BlitResolveParameters ¶ms); 247 angle::Result depthStencilBlitResolve(ContextVk *contextVk, 248 FramebufferVk *framebuffer, 249 vk::ImageHelper *src, 250 const vk::ImageView *srcDepthView, 251 const vk::ImageView *srcStencilView, 252 const BlitResolveParameters ¶ms); 253 angle::Result stencilBlitResolveNoShaderExport(ContextVk *contextVk, 254 FramebufferVk *framebuffer, 255 vk::ImageHelper *src, 256 const vk::ImageView *srcStencilView, 257 const BlitResolveParameters ¶ms); 258 259 angle::Result clearImage(ContextVk *contextVk, 260 vk::ImageHelper *dst, 261 const ClearImageParameters ¶ms); 262 263 angle::Result copyImage(ContextVk *contextVk, 264 vk::ImageHelper *dst, 265 const vk::ImageView *dstView, 266 vk::ImageHelper *src, 267 const vk::ImageView *srcView, 268 const CopyImageParameters ¶ms); 269 270 angle::Result copyImageBits(ContextVk *contextVk, 271 vk::ImageHelper *dst, 272 vk::ImageHelper *src, 273 const CopyImageBitsParameters ¶ms); 274 275 angle::Result copyImageToBuffer(ContextVk *contextVk, 276 vk::BufferHelper *dst, 277 vk::ImageHelper *src, 278 const CopyImageToBufferParameters ¶ms); 279 280 angle::Result copyRgbToRgba(ContextVk *contextVk, 281 const angle::Format &srcFormat, 282 vk::BufferHelper *srcBuffer, 283 uint32_t srcOffset, 284 uint32_t pixelCount, 285 vk::BufferHelper *dstBuffer); 286 287 angle::Result transCodeEtcToBc(ContextVk *contextVk, 288 vk::BufferHelper *srcBuffer, 289 vk::ImageHelper *dstImage, 290 const VkBufferImageCopy *copyRegion); 291 292 using GenerateMipmapDestLevelViews = 293 std::array<const vk::ImageView *, kGenerateMipmapMaxLevels>; 294 angle::Result generateMipmap(ContextVk *contextVk, 295 vk::ImageHelper *src, 296 const vk::ImageView *srcLevelZeroView, 297 vk::ImageHelper *dst, 298 const GenerateMipmapDestLevelViews &dstLevelViews, 299 const vk::Sampler &sampler, 300 const GenerateMipmapParameters ¶ms); 301 302 angle::Result unresolve(ContextVk *contextVk, 303 const FramebufferVk *framebuffer, 304 const UnresolveParameters ¶ms); 305 306 // Overlay utilities. 307 angle::Result drawOverlay(ContextVk *contextVk, 308 vk::BufferHelper *textWidgetsBuffer, 309 vk::BufferHelper *graphWidgetsBuffer, 310 vk::ImageHelper *font, 311 const vk::ImageView *fontView, 312 vk::ImageHelper *dst, 313 const vk::ImageView *dstView, 314 const OverlayDrawParameters ¶ms); 315 316 private: 317 ANGLE_ENABLE_STRUCT_PADDING_WARNINGS 318 319 struct ConvertIndexShaderParams 320 { 321 uint32_t srcOffset = 0; 322 uint32_t dstOffsetDiv4 = 0; 323 uint32_t maxIndex = 0; 324 uint32_t _padding = 0; 325 }; 326 327 struct ConvertIndexIndirectShaderParams 328 { 329 uint32_t srcIndirectOffsetDiv4 = 0; 330 uint32_t srcOffset = 0; 331 uint32_t dstOffsetDiv4 = 0; 332 uint32_t maxIndex = 0; 333 uint32_t dstIndirectOffsetDiv4 = 0; 334 }; 335 336 struct ConvertIndexIndirectLineLoopShaderParams 337 { 338 uint32_t cmdOffsetDiv4 = 0; 339 uint32_t dstCmdOffsetDiv4 = 0; 340 uint32_t srcOffset = 0; 341 uint32_t dstOffsetDiv4 = 0; 342 uint32_t isRestartEnabled = 0; 343 }; 344 345 struct ConvertIndirectLineLoopShaderParams 346 { 347 uint32_t cmdOffsetDiv4 = 0; 348 uint32_t dstCmdOffsetDiv4 = 0; 349 uint32_t dstOffsetDiv4 = 0; 350 }; 351 352 struct ConvertVertexShaderParams 353 { 354 ConvertVertexShaderParams(); 355 356 // Structure matching PushConstants in ConvertVertex.comp 357 uint32_t outputCount = 0; 358 uint32_t componentCount = 0; 359 uint32_t srcOffset = 0; 360 uint32_t dstOffset = 0; 361 uint32_t Ns = 0; 362 uint32_t Bs = 0; 363 uint32_t Ss = 0; 364 uint32_t Es = 0; 365 uint32_t Nd = 0; 366 uint32_t Bd = 0; 367 uint32_t Sd = 0; 368 uint32_t Ed = 0; 369 uint32_t srcEmulatedAlpha = 0; 370 uint32_t isSrcHDR = 0; 371 uint32_t isSrcA2BGR10 = 0; 372 uint32_t _padding = 0; 373 }; 374 375 struct ImageClearShaderParams 376 { 377 // Structure matching PushConstants in ImageClear.frag 378 VkClearColorValue clearValue = {}; 379 float clearDepth = 0.0f; 380 }; 381 382 struct ImageCopyShaderParams 383 { 384 ImageCopyShaderParams(); 385 386 // Structure matching PushConstants in ImageCopy.frag 387 int32_t srcOffset[2] = {}; 388 int32_t dstOffset[2] = {}; 389 int32_t srcMip = 0; 390 int32_t srcLayer = 0; 391 uint32_t flipX = 0; 392 uint32_t flipY = 0; 393 uint32_t premultiplyAlpha = 0; 394 uint32_t unmultiplyAlpha = 0; 395 uint32_t dstHasLuminance = 0; 396 uint32_t dstIsAlpha = 0; 397 uint32_t srcIsSRGB = 0; 398 uint32_t dstIsSRGB = 0; 399 uint32_t dstDefaultChannelsMask = 0; 400 uint32_t rotateXY = 0; 401 }; 402 403 struct CopyImageToBufferShaderParams 404 { 405 // Structure matching PushConstants in CopyImageToBuffer.comp 406 int32_t srcOffset[2] = {}; 407 int32_t srcDepth = 0; 408 uint32_t reverseRowOrder = 0; 409 uint32_t size[2] = {}; 410 uint32_t outputOffset = 0; 411 uint32_t outputPitch = 0; 412 uint32_t isDstSnorm = 0; 413 }; 414 415 union BlitResolveOffset 416 { 417 int32_t resolve[2]; 418 float blit[2]; 419 }; 420 421 struct BlitResolveShaderParams 422 { 423 // Structure matching PushConstants in BlitResolve.frag 424 BlitResolveOffset offset = {}; 425 float stretch[2] = {}; 426 float invSrcExtent[2] = {}; 427 int32_t srcLayer = 0; 428 int32_t samples = 0; 429 float invSamples = 0; 430 uint32_t outputMask = 0; 431 uint32_t flipX = 0; 432 uint32_t flipY = 0; 433 uint32_t rotateXY = 0; 434 }; 435 436 struct BlitResolveStencilNoExportShaderParams 437 { 438 // Structure matching PushConstants in BlitResolveStencilNoExport.comp 439 BlitResolveOffset offset = {}; 440 float stretch[2] = {}; 441 float invSrcExtent[2] = {}; 442 int32_t srcLayer = 0; 443 int32_t srcWidth = 0; 444 int32_t blitArea[4] = {}; 445 int32_t dstPitch = 0; 446 uint32_t flipX = 0; 447 uint32_t flipY = 0; 448 uint32_t rotateXY = 0; 449 }; 450 451 struct ExportStencilShaderParams 452 { 453 uint32_t bit = 0; 454 }; 455 456 struct OverlayDrawShaderParams 457 { 458 // Structure matching PushConstants in OverlayDraw.vert and OverlayDraw.frag 459 uint32_t viewportSize[2] = {}; 460 uint32_t isText = 0; 461 uint32_t rotateXY = 0; 462 }; 463 464 struct GenerateMipmapShaderParams 465 { 466 // Structure matching PushConstants in GenerateMipmap.comp 467 float invSrcExtent[2] = {}; 468 uint32_t levelCount = 0; 469 }; 470 471 struct EtcToBcShaderParams 472 { 473 uint32_t offsetX; 474 uint32_t offsetY; 475 int32_t texelOffset; 476 uint32_t width; 477 uint32_t height; 478 uint32_t alphaBits; 479 uint32_t isSigned; 480 uint32_t isEacRg; 481 }; 482 483 ANGLE_DISABLE_STRUCT_PADDING_WARNINGS 484 485 // Functions implemented by the class: 486 enum class Function 487 { 488 // Functions implemented in graphics 489 ImageClear, 490 ImageCopy, 491 BlitResolve, 492 ExportStencil, 493 OverlayDraw, 494 // Note: unresolve is special as it has a different layout per attachment count. Depth and 495 // stencil each require a binding, so are counted separately. 496 Unresolve1Attachment, 497 Unresolve2Attachments, 498 Unresolve3Attachments, 499 Unresolve4Attachments, 500 Unresolve5Attachments, 501 Unresolve6Attachments, 502 Unresolve7Attachments, 503 Unresolve8Attachments, 504 Unresolve9Attachments, 505 Unresolve10Attachments, 506 507 // Functions implemented in compute 508 ComputeStartIndex, // Special value to separate draw and dispatch functions. 509 ConvertIndexBuffer = ComputeStartIndex, 510 ConvertVertexBuffer, 511 BlitResolveStencilNoExport, 512 ConvertIndexIndirectBuffer, 513 ConvertIndexIndirectLineLoopBuffer, 514 ConvertIndirectLineLoopBuffer, 515 GenerateMipmap, 516 TransCodeEtcToBc, 517 CopyImageToBuffer, 518 519 InvalidEnum, 520 EnumCount = InvalidEnum, 521 }; 522 523 struct GraphicsShaderProgramAndPipelines 524 { 525 vk::ShaderProgramHelper program; 526 CompleteGraphicsPipelineCache pipelines; 527 }; 528 struct ComputeShaderProgramAndPipelines 529 { 530 vk::ShaderProgramHelper program; 531 vk::ComputePipelineCache pipelines; 532 }; 533 534 // Common functions that create the pipeline for the specified function, binds it and prepares 535 // the draw/dispatch call. 536 angle::Result setupComputeProgram( 537 ContextVk *contextVk, 538 Function function, 539 vk::RefCounted<vk::ShaderModule> *csShader, 540 ComputeShaderProgramAndPipelines *programAndPipelines, 541 const VkDescriptorSet descriptorSet, 542 const void *pushConstants, 543 size_t pushConstantsSize, 544 vk::OutsideRenderPassCommandBufferHelper *commandBufferHelper); 545 angle::Result setupGraphicsProgramWithLayout( 546 ContextVk *contextVk, 547 const vk::PipelineLayout &pipelineLayout, 548 vk::RefCounted<vk::ShaderModule> *vsShader, 549 vk::RefCounted<vk::ShaderModule> *fsShader, 550 GraphicsShaderProgramAndPipelines *programAndPipelines, 551 const vk::GraphicsPipelineDesc *pipelineDesc, 552 const VkDescriptorSet descriptorSet, 553 const void *pushConstants, 554 size_t pushConstantsSize, 555 vk::RenderPassCommandBuffer *commandBuffer); 556 angle::Result setupGraphicsProgram(ContextVk *contextVk, 557 Function function, 558 vk::RefCounted<vk::ShaderModule> *vsShader, 559 vk::RefCounted<vk::ShaderModule> *fsShader, 560 GraphicsShaderProgramAndPipelines *programAndPipelines, 561 const vk::GraphicsPipelineDesc *pipelineDesc, 562 const VkDescriptorSet descriptorSet, 563 const void *pushConstants, 564 size_t pushConstantsSize, 565 vk::RenderPassCommandBuffer *commandBuffer); 566 567 // Initializes descriptor set layout, pipeline layout and descriptor pool corresponding to given 568 // function, if not already initialized. Uses setSizes to create the layout. For example, if 569 // this array has two entries {STORAGE_TEXEL_BUFFER, 1} and {UNIFORM_TEXEL_BUFFER, 3}, then the 570 // created set layout would be binding 0 for storage texel buffer and bindings 1 through 3 for 571 // uniform texel buffer. All resources are put in set 0. 572 angle::Result ensureResourcesInitialized(ContextVk *contextVk, 573 Function function, 574 VkDescriptorPoolSize *setSizes, 575 size_t setSizesCount, 576 size_t pushConstantsSize); 577 578 // Initializers corresponding to functions, calling into ensureResourcesInitialized with the 579 // appropriate parameters. 580 angle::Result ensureConvertIndexResourcesInitialized(ContextVk *contextVk); 581 angle::Result ensureConvertIndexIndirectResourcesInitialized(ContextVk *contextVk); 582 angle::Result ensureConvertIndexIndirectLineLoopResourcesInitialized(ContextVk *contextVk); 583 angle::Result ensureConvertIndirectLineLoopResourcesInitialized(ContextVk *contextVk); 584 angle::Result ensureConvertVertexResourcesInitialized(ContextVk *contextVk); 585 angle::Result ensureImageClearResourcesInitialized(ContextVk *contextVk); 586 angle::Result ensureImageCopyResourcesInitialized(ContextVk *contextVk); 587 angle::Result ensureCopyImageToBufferResourcesInitialized(ContextVk *contextVk); 588 angle::Result ensureBlitResolveResourcesInitialized(ContextVk *contextVk); 589 angle::Result ensureBlitResolveStencilNoExportResourcesInitialized(ContextVk *contextVk); 590 angle::Result ensureExportStencilResourcesInitialized(ContextVk *contextVk); 591 angle::Result ensureOverlayDrawResourcesInitialized(ContextVk *contextVk); 592 angle::Result ensureGenerateMipmapResourcesInitialized(ContextVk *contextVk); 593 angle::Result ensureTransCodeEtcToBcResourcesInitialized(ContextVk *contextVk); 594 angle::Result ensureUnresolveResourcesInitialized(ContextVk *contextVk, 595 Function function, 596 uint32_t attachmentIndex); 597 598 angle::Result ensureImageCopyResourcesInitializedWithSampler( 599 ContextVk *contextVk, 600 const vk::SamplerDesc &samplerDesc); 601 602 angle::Result ensureSamplersInitialized(ContextVk *context); 603 604 angle::Result startRenderPass(ContextVk *contextVk, 605 vk::ImageHelper *image, 606 const vk::ImageView *imageView, 607 const vk::RenderPassDesc &renderPassDesc, 608 const gl::Rectangle &renderArea, 609 vk::RenderPassCommandBuffer **commandBufferOut); 610 611 // Set up descriptor set and call dispatch. 612 angle::Result convertVertexBufferImpl( 613 ContextVk *contextVk, 614 vk::BufferHelper *dst, 615 vk::BufferHelper *src, 616 uint32_t flags, 617 vk::OutsideRenderPassCommandBufferHelper *commandBufferHelper, 618 const ConvertVertexShaderParams &shaderParams); 619 620 // Blits or resolves either color or depth/stencil, based on which view is given. 621 angle::Result blitResolveImpl(ContextVk *contextVk, 622 FramebufferVk *framebuffer, 623 vk::ImageHelper *src, 624 const vk::ImageView *srcColorView, 625 const vk::ImageView *srcDepthView, 626 const vk::ImageView *srcStencilView, 627 const BlitResolveParameters ¶ms); 628 629 // Allocates a single descriptor set. 630 angle::Result allocateDescriptorSetWithLayout( 631 ContextVk *contextVk, 632 vk::CommandBufferHelperCommon *commandBufferHelper, 633 vk::DynamicDescriptorPool &descriptorPool, 634 const vk::DescriptorSetLayout &descriptorSetLayout, 635 VkDescriptorSet *descriptorSetOut); 636 637 angle::Result allocateDescriptorSet(ContextVk *contextVk, 638 vk::CommandBufferHelperCommon *commandBufferHelper, 639 Function function, 640 VkDescriptorSet *descriptorSetOut); 641 642 angle::Result allocateDescriptorSetForImageCopyWithSampler( 643 ContextVk *contextVk, 644 vk::CommandBufferHelperCommon *commandBufferHelper, 645 const vk::SamplerDesc &samplerDesc, 646 VkDescriptorSet *descriptorSetOut); 647 648 angle::PackedEnumMap<Function, vk::DescriptorSetLayoutPointerArray> mDescriptorSetLayouts; 649 angle::PackedEnumMap<Function, vk::BindingPointer<vk::PipelineLayout>> mPipelineLayouts; 650 angle::PackedEnumMap<Function, vk::DynamicDescriptorPool> mDescriptorPools; 651 652 std::unordered_map<vk::SamplerDesc, vk::DescriptorSetLayoutPointerArray> 653 mImageCopyWithSamplerDescriptorSetLayouts; 654 std::unordered_map<vk::SamplerDesc, vk::BindingPointer<vk::PipelineLayout>> 655 mImageCopyWithSamplerPipelineLayouts; 656 std::unordered_map<vk::SamplerDesc, vk::DynamicDescriptorPool> 657 mImageCopyWithSamplerDescriptorPools; 658 659 ComputeShaderProgramAndPipelines 660 mConvertIndex[vk::InternalShader::ConvertIndex_comp::kArrayLen]; 661 ComputeShaderProgramAndPipelines mConvertIndexIndirectLineLoop 662 [vk::InternalShader::ConvertIndexIndirectLineLoop_comp::kArrayLen]; 663 ComputeShaderProgramAndPipelines 664 mConvertIndirectLineLoop[vk::InternalShader::ConvertIndirectLineLoop_comp::kArrayLen]; 665 ComputeShaderProgramAndPipelines 666 mConvertVertex[vk::InternalShader::ConvertVertex_comp::kArrayLen]; 667 GraphicsShaderProgramAndPipelines mImageClearVSOnly; 668 GraphicsShaderProgramAndPipelines mImageClear[vk::InternalShader::ImageClear_frag::kArrayLen]; 669 GraphicsShaderProgramAndPipelines mImageCopy[vk::InternalShader::ImageCopy_frag::kArrayLen]; 670 std::unordered_map<vk::SamplerDesc, GraphicsShaderProgramAndPipelines> 671 mImageCopyWithSampler[vk::InternalShader::ImageCopy_frag::kArrayLen]; 672 ComputeShaderProgramAndPipelines 673 mCopyImageToBuffer[vk::InternalShader::CopyImageToBuffer_comp::kArrayLen]; 674 GraphicsShaderProgramAndPipelines mBlitResolve[vk::InternalShader::BlitResolve_frag::kArrayLen]; 675 ComputeShaderProgramAndPipelines 676 mBlitResolveStencilNoExport[vk::InternalShader::BlitResolveStencilNoExport_comp::kArrayLen]; 677 GraphicsShaderProgramAndPipelines mExportStencil; 678 GraphicsShaderProgramAndPipelines mOverlayDraw; 679 ComputeShaderProgramAndPipelines 680 mGenerateMipmap[vk::InternalShader::GenerateMipmap_comp::kArrayLen]; 681 ComputeShaderProgramAndPipelines mEtcToBc[vk::InternalShader::EtcToBc_comp::kArrayLen]; 682 683 // Unresolve shaders are special as they are generated on the fly due to the large number of 684 // combinations. 685 std::unordered_map<uint32_t, vk::RefCounted<vk::ShaderModule>> mUnresolveFragShaders; 686 std::unordered_map<uint32_t, GraphicsShaderProgramAndPipelines> mUnresolve; 687 688 vk::Sampler mPointSampler; 689 vk::Sampler mLinearSampler; 690 }; 691 692 } // namespace rx 693 694 #endif // LIBANGLE_RENDERER_VULKAN_UTILSVK_H_ 695