Hash :
b0e9bbd7
Author :
Date :
2023-05-31T14:23:40
Vulkan: Split features for dynamic state When a driver bug with dynamic state is encountered, it is hard to debug which dynamic state exactly is causing an issue, due to the current granularity of disabling all entire state from an extension. With this change, every dynamic state gets its own ANGLE feature, and can be toggled as necessary. Disabling the supportsExtendedDynamicState* features implicitly disables all dependent features. Bug: b/285124778 Bug: b/275210062 Bug: fuchsia:107106 Bug: angleproject:5906 Change-Id: Ic291279872df2d0eb58618ff364ab118bdcc4a9f Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4577553 Reviewed-by: Cody Northrop <cnorthrop@google.com> Auto-Submit: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Yuxin Hu <yuxinhu@google.com>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157
//
// Copyright 2016 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// RendererVk.h:
// Defines the class interface for RendererVk.
//
#ifndef LIBANGLE_RENDERER_VULKAN_RENDERERVK_H_
#define LIBANGLE_RENDERER_VULKAN_RENDERERVK_H_
#include <condition_variable>
#include <deque>
#include <memory>
#include <mutex>
#include <queue>
#include <thread>
#include "common/PackedEnums.h"
#include "common/WorkerThread.h"
#include "common/angleutils.h"
#include "common/vulkan/vk_headers.h"
#include "common/vulkan/vulkan_icd.h"
#include "libANGLE/BlobCache.h"
#include "libANGLE/Caps.h"
#include "libANGLE/renderer/vulkan/CommandProcessor.h"
#include "libANGLE/renderer/vulkan/DebugAnnotatorVk.h"
#include "libANGLE/renderer/vulkan/MemoryTracking.h"
#include "libANGLE/renderer/vulkan/QueryVk.h"
#include "libANGLE/renderer/vulkan/ResourceVk.h"
#include "libANGLE/renderer/vulkan/UtilsVk.h"
#include "libANGLE/renderer/vulkan/vk_format_utils.h"
#include "libANGLE/renderer/vulkan/vk_helpers.h"
#include "libANGLE/renderer/vulkan/vk_internal_shaders_autogen.h"
#include "libANGLE/renderer/vulkan/vk_mem_alloc_wrapper.h"
namespace angle
{
class Library;
struct FrontendFeatures;
} // namespace angle
namespace egl
{
class Display;
class BlobCache;
} // namespace egl
namespace rx
{
class DisplayVk;
class FramebufferVk;
namespace vk
{
class Format;
static constexpr size_t kMaxExtensionNames = 400;
using ExtensionNameList = angle::FixedVector<const char *, kMaxExtensionNames>;
// Information used to accurately skip known synchronization issues in ANGLE.
struct SkippedSyncvalMessage
{
const char *messageId;
const char *messageContents1;
const char *messageContents2 = "";
bool isDueToNonConformantCoherentFramebufferFetch = false;
};
class ImageMemorySuballocator : angle::NonCopyable
{
public:
ImageMemorySuballocator();
~ImageMemorySuballocator();
void destroy(RendererVk *renderer);
// Allocates memory for the image and binds it.
VkResult allocateAndBindMemory(Context *context,
Image *image,
const VkImageCreateInfo *imageCreateInfo,
VkMemoryPropertyFlags requiredFlags,
VkMemoryPropertyFlags preferredFlags,
MemoryAllocationType memoryAllocationType,
Allocation *allocationOut,
VkMemoryPropertyFlags *memoryFlagsOut,
uint32_t *memoryTypeIndexOut,
VkDeviceSize *sizeOut);
// Maps the memory to initialize with non-zero value.
VkResult mapMemoryAndInitWithNonZeroValue(RendererVk *renderer,
Allocation *allocation,
VkDeviceSize size,
int value,
VkMemoryPropertyFlags flags);
};
} // namespace vk
// Supports one semaphore from current surface, and one semaphore passed to
// glSignalSemaphoreEXT.
using SignalSemaphoreVector = angle::FixedVector<VkSemaphore, 2>;
// Recursive function to process variable arguments for garbage collection
inline void CollectGarbage(std::vector<vk::GarbageObject> *garbageOut) {}
template <typename ArgT, typename... ArgsT>
void CollectGarbage(std::vector<vk::GarbageObject> *garbageOut, ArgT object, ArgsT... objectsIn)
{
if (object->valid())
{
garbageOut->emplace_back(vk::GarbageObject::Get(object));
}
CollectGarbage(garbageOut, objectsIn...);
}
// Recursive function to process variable arguments for garbage destroy
inline void DestroyGarbage(VkDevice device) {}
template <typename ArgT, typename... ArgsT>
void DestroyGarbage(VkDevice device, ArgT object, ArgsT... objectsIn)
{
if (object->valid())
{
object->destroy(device);
}
DestroyGarbage(device, objectsIn...);
}
class WaitableCompressEvent
{
public:
WaitableCompressEvent(std::shared_ptr<angle::WaitableEvent> waitableEvent)
: mWaitableEvent(waitableEvent)
{}
virtual ~WaitableCompressEvent() {}
void wait() { return mWaitableEvent->wait(); }
bool isReady() { return mWaitableEvent->isReady(); }
private:
std::shared_ptr<angle::WaitableEvent> mWaitableEvent;
};
class OneOffCommandPool : angle::NonCopyable
{
public:
OneOffCommandPool();
void init(vk::ProtectionType protectionType);
angle::Result getCommandBuffer(vk::Context *context,
vk::PrimaryCommandBuffer *commandBufferOut);
void releaseCommandBuffer(const QueueSerial &submitQueueSerial,
vk::PrimaryCommandBuffer &&primary);
void destroy(VkDevice device);
private:
vk::ProtectionType mProtectionType;
std::mutex mMutex;
vk::CommandPool mCommandPool;
struct PendingOneOffCommands
{
vk::ResourceUse use;
vk::PrimaryCommandBuffer commandBuffer;
};
std::deque<PendingOneOffCommands> mPendingCommands;
};
class RendererVk : angle::NonCopyable
{
public:
RendererVk();
~RendererVk();
angle::Result initialize(DisplayVk *displayVk,
egl::Display *display,
const char *wsiExtension,
const char *wsiLayer);
// Reload volk vk* function ptrs if needed for an already initialized RendererVk
void reloadVolkIfNeeded() const;
void onDestroy(vk::Context *context);
void notifyDeviceLost();
bool isDeviceLost() const;
bool hasSharedGarbage();
std::string getVendorString() const;
std::string getRendererDescription() const;
std::string getVersionString(bool includeFullVersion) const;
gl::Version getMaxSupportedESVersion() const;
gl::Version getMaxConformantESVersion() const;
uint32_t getDeviceVersion();
VkInstance getInstance() const { return mInstance; }
VkPhysicalDevice getPhysicalDevice() const { return mPhysicalDevice; }
const VkPhysicalDeviceProperties &getPhysicalDeviceProperties() const
{
return mPhysicalDeviceProperties;
}
const VkPhysicalDeviceDrmPropertiesEXT &getPhysicalDeviceDrmProperties() const
{
return mDrmProperties;
}
const VkPhysicalDevicePrimitivesGeneratedQueryFeaturesEXT &
getPhysicalDevicePrimitivesGeneratedQueryFeatures() const
{
return mPrimitivesGeneratedQueryFeatures;
}
const VkPhysicalDeviceFeatures &getPhysicalDeviceFeatures() const
{
return mPhysicalDeviceFeatures;
}
const VkPhysicalDeviceFeatures2KHR &getEnabledFeatures() const { return mEnabledFeatures; }
VkDevice getDevice() const { return mDevice; }
bool isVulkan11Instance() const;
bool isVulkan11Device() const;
const vk::Allocator &getAllocator() const { return mAllocator; }
vk::ImageMemorySuballocator &getImageMemorySuballocator() { return mImageMemorySuballocator; }
angle::Result selectPresentQueueForSurface(DisplayVk *displayVk,
VkSurfaceKHR surface,
uint32_t *presentQueueOut);
const gl::Caps &getNativeCaps() const;
const gl::TextureCapsMap &getNativeTextureCaps() const;
const gl::Extensions &getNativeExtensions() const;
const gl::Limitations &getNativeLimitations() const;
const ShPixelLocalStorageOptions &getNativePixelLocalStorageOptions() const;
void initializeFrontendFeatures(angle::FrontendFeatures *features) const;
uint32_t getQueueFamilyIndex() const { return mCurrentQueueFamilyIndex; }
const VkQueueFamilyProperties &getQueueFamilyProperties() const
{
return mQueueFamilyProperties[mCurrentQueueFamilyIndex];
}
const vk::MemoryProperties &getMemoryProperties() const { return mMemoryProperties; }
const vk::Format &getFormat(GLenum internalFormat) const
{
return mFormatTable[internalFormat];
}
const vk::Format &getFormat(angle::FormatID formatID) const { return mFormatTable[formatID]; }
angle::Result getPipelineCacheSize(DisplayVk *displayVk, size_t *pipelineCacheSizeOut);
angle::Result syncPipelineCacheVk(DisplayVk *displayVk, const gl::Context *context);
const angle::FeaturesVk &getFeatures() const { return mFeatures; }
uint32_t getMaxVertexAttribDivisor() const { return mMaxVertexAttribDivisor; }
VkDeviceSize getMaxVertexAttribStride() const { return mMaxVertexAttribStride; }
uint32_t getDefaultUniformBufferSize() const { return mDefaultUniformBufferSize; }
angle::vk::ICD getEnabledICD() const { return mEnabledICD; }
bool isMockICDEnabled() const { return mEnabledICD == angle::vk::ICD::Mock; }
// Query the format properties for select bits (linearTilingFeatures, optimalTilingFeatures
// and bufferFeatures). Looks through mandatory features first, and falls back to querying
// the device (first time only).
bool hasLinearImageFormatFeatureBits(angle::FormatID format,
const VkFormatFeatureFlags featureBits) const;
VkFormatFeatureFlags getLinearImageFormatFeatureBits(
angle::FormatID format,
const VkFormatFeatureFlags featureBits) const;
VkFormatFeatureFlags getImageFormatFeatureBits(angle::FormatID format,
const VkFormatFeatureFlags featureBits) const;
bool hasImageFormatFeatureBits(angle::FormatID format,
const VkFormatFeatureFlags featureBits) const;
bool hasBufferFormatFeatureBits(angle::FormatID format,
const VkFormatFeatureFlags featureBits) const;
bool isAsyncCommandQueueEnabled() const { return mFeatures.asyncCommandQueue.enabled; }
bool isAsyncCommandBufferResetEnabled() const
{
return mFeatures.asyncCommandBufferReset.enabled;
}
ANGLE_INLINE egl::ContextPriority getDriverPriority(egl::ContextPriority priority)
{
return mCommandQueue.getDriverPriority(priority);
}
ANGLE_INLINE uint32_t getDeviceQueueIndex() { return mCommandQueue.getDeviceQueueIndex(); }
VkQueue getQueue(egl::ContextPriority priority) { return mCommandQueue.getQueue(priority); }
// This command buffer should be submitted immediately via queueSubmitOneOff.
angle::Result getCommandBufferOneOff(vk::Context *context,
vk::ProtectionType protectionType,
vk::PrimaryCommandBuffer *commandBufferOut)
{
return mOneOffCommandPoolMap[protectionType].getCommandBuffer(context, commandBufferOut);
}
// Fire off a single command buffer immediately with default priority.
// Command buffer must be allocated with getCommandBufferOneOff and is reclaimed.
angle::Result queueSubmitOneOff(vk::Context *context,
vk::PrimaryCommandBuffer &&primary,
vk::ProtectionType protectionType,
egl::ContextPriority priority,
VkSemaphore waitSemaphore,
VkPipelineStageFlags waitSemaphoreStageMasks,
vk::SubmitPolicy submitPolicy,
QueueSerial *queueSerialOut);
angle::Result queueSubmitWaitSemaphore(vk::Context *context,
egl::ContextPriority priority,
const vk::Semaphore &waitSemaphore,
VkPipelineStageFlags waitSemaphoreStageMasks,
QueueSerial submitQueueSerial);
template <typename... ArgsT>
void collectGarbage(const vk::ResourceUse &use, ArgsT... garbageIn)
{
if (hasResourceUseFinished(use))
{
DestroyGarbage(mDevice, garbageIn...);
}
else
{
std::vector<vk::GarbageObject> sharedGarbage;
CollectGarbage(&sharedGarbage, garbageIn...);
if (!sharedGarbage.empty())
{
collectGarbage(use, std::move(sharedGarbage));
}
}
}
void collectAllocationGarbage(const vk::ResourceUse &use, vk::Allocation &allocationGarbageIn)
{
if (!allocationGarbageIn.valid())
{
return;
}
if (hasResourceUseFinished(use))
{
allocationGarbageIn.destroy(getAllocator());
}
else
{
std::vector<vk::GarbageObject> sharedGarbage;
CollectGarbage(&sharedGarbage, &allocationGarbageIn);
if (!sharedGarbage.empty())
{
collectGarbage(use, std::move(sharedGarbage));
}
}
}
void collectGarbage(const vk::ResourceUse &use, vk::GarbageList &&sharedGarbage)
{
ASSERT(!sharedGarbage.empty());
vk::SharedGarbage garbage(use, std::move(sharedGarbage));
if (!hasResourceUseSubmitted(use))
{
std::unique_lock<std::mutex> lock(mGarbageMutex);
mPendingSubmissionGarbage.push(std::move(garbage));
}
else if (!garbage.destroyIfComplete(this))
{
std::unique_lock<std::mutex> lock(mGarbageMutex);
mSharedGarbage.push(std::move(garbage));
}
}
void collectSuballocationGarbage(const vk::ResourceUse &use,
vk::BufferSuballocation &&suballocation,
vk::Buffer &&buffer)
{
if (hasResourceUseFinished(use))
{
// mSuballocationGarbageDestroyed is atomic, so we dont need mGarbageMutex to
// protect it.
mSuballocationGarbageDestroyed += suballocation.getSize();
buffer.destroy(mDevice);
suballocation.destroy(this);
}
else
{
std::unique_lock<std::mutex> lock(mGarbageMutex);
if (hasResourceUseSubmitted(use))
{
mSuballocationGarbageSizeInBytes += suballocation.getSize();
mSuballocationGarbage.emplace(use, std::move(suballocation), std::move(buffer));
}
else
{
mPendingSubmissionSuballocationGarbage.emplace(use, std::move(suballocation),
std::move(buffer));
}
}
}
angle::Result getPipelineCache(vk::PipelineCacheAccess *pipelineCacheOut);
angle::Result mergeIntoPipelineCache(const vk::PipelineCache &pipelineCache);
void onNewValidationMessage(const std::string &message);
std::string getAndClearLastValidationMessage(uint32_t *countSinceLastClear);
const std::vector<const char *> &getSkippedValidationMessages() const
{
return mSkippedValidationMessages;
}
const std::vector<vk::SkippedSyncvalMessage> &getSkippedSyncvalMessages() const
{
return mSkippedSyncvalMessages;
}
void onFramebufferFetchUsed();
bool isFramebufferFetchUsed() const { return mIsFramebufferFetchUsed; }
uint64_t getMaxFenceWaitTimeNs() const;
ANGLE_INLINE bool isCommandQueueBusy()
{
if (isAsyncCommandQueueEnabled())
{
return mCommandProcessor.isBusy(this);
}
else
{
return mCommandQueue.isBusy(this);
}
}
angle::Result waitForResourceUseToBeSubmittedToDevice(vk::Context *context,
const vk::ResourceUse &use)
{
// This is only needed for async submission code path. For immediate submission, it is a nop
// since everything is submitted immediately.
if (isAsyncCommandQueueEnabled())
{
ASSERT(mCommandProcessor.hasResourceUseEnqueued(use));
return mCommandProcessor.waitForResourceUseToBeSubmitted(context, use);
}
// This ResourceUse must have been submitted.
ASSERT(mCommandQueue.hasResourceUseSubmitted(use));
return angle::Result::Continue;
}
angle::Result waitForQueueSerialToBeSubmittedToDevice(vk::Context *context,
const QueueSerial &queueSerial)
{
// This is only needed for async submission code path. For immediate submission, it is a nop
// since everything is submitted immediately.
if (isAsyncCommandQueueEnabled())
{
ASSERT(mCommandProcessor.hasQueueSerialEnqueued(queueSerial));
return mCommandProcessor.waitForQueueSerialToBeSubmitted(context, queueSerial);
}
// This queueSerial must have been submitted.
ASSERT(mCommandQueue.hasQueueSerialSubmitted(queueSerial));
return angle::Result::Continue;
}
angle::VulkanPerfCounters getCommandQueuePerfCounters()
{
return mCommandQueue.getPerfCounters();
}
void resetCommandQueuePerFrameCounters() { mCommandQueue.resetPerFramePerfCounters(); }
egl::Display *getDisplay() const { return mDisplay; }
bool enableDebugUtils() const { return mEnableDebugUtils; }
bool angleDebuggerMode() const { return mAngleDebuggerMode; }
SamplerCache &getSamplerCache() { return mSamplerCache; }
SamplerYcbcrConversionCache &getYuvConversionCache() { return mYuvConversionCache; }
void onAllocateHandle(vk::HandleType handleType);
void onDeallocateHandle(vk::HandleType handleType);
bool getEnableValidationLayers() const { return mEnableValidationLayers; }
vk::ResourceSerialFactory &getResourceSerialFactory() { return mResourceSerialFactory; }
void setGlobalDebugAnnotator();
void outputVmaStatString();
bool haveSameFormatFeatureBits(angle::FormatID formatID1, angle::FormatID formatID2) const;
void cleanupGarbage();
void cleanupPendingSubmissionGarbage();
angle::Result submitCommands(vk::Context *context,
vk::ProtectionType protectionType,
egl::ContextPriority contextPriority,
const vk::Semaphore *signalSemaphore,
const vk::SharedExternalFence *externalFence,
const QueueSerial &submitQueueSerial);
angle::Result submitPriorityDependency(vk::Context *context,
vk::ProtectionTypes protectionTypes,
egl::ContextPriority srcContextPriority,
egl::ContextPriority dstContextPriority,
SerialIndex index);
void handleDeviceLost();
angle::Result finishResourceUse(vk::Context *context, const vk::ResourceUse &use);
angle::Result finishQueueSerial(vk::Context *context, const QueueSerial &queueSerial);
angle::Result waitForResourceUseToFinishWithUserTimeout(vk::Context *context,
const vk::ResourceUse &use,
uint64_t timeout,
VkResult *result);
angle::Result checkCompletedCommands(vk::Context *context);
angle::Result retireFinishedCommands(vk::Context *context);
angle::Result flushWaitSemaphores(vk::ProtectionType protectionType,
egl::ContextPriority priority,
std::vector<VkSemaphore> &&waitSemaphores,
std::vector<VkPipelineStageFlags> &&waitSemaphoreStageMasks);
angle::Result flushRenderPassCommands(vk::Context *context,
vk::ProtectionType protectionType,
egl::ContextPriority priority,
const vk::RenderPass &renderPass,
vk::RenderPassCommandBufferHelper **renderPassCommands);
angle::Result flushOutsideRPCommands(
vk::Context *context,
vk::ProtectionType protectionType,
egl::ContextPriority priority,
vk::OutsideRenderPassCommandBufferHelper **outsideRPCommands);
void queuePresent(vk::Context *context,
egl::ContextPriority priority,
const VkPresentInfoKHR &presentInfo,
vk::SwapchainStatus *swapchainStatus);
// Only useful if async submission is enabled
angle::Result waitForPresentToBeSubmitted(vk::SwapchainStatus *swapchainStatus);
angle::Result getOutsideRenderPassCommandBufferHelper(
vk::Context *context,
vk::SecondaryCommandPool *commandPool,
vk::SecondaryCommandMemoryAllocator *commandsAllocator,
vk::OutsideRenderPassCommandBufferHelper **commandBufferHelperOut);
angle::Result getRenderPassCommandBufferHelper(
vk::Context *context,
vk::SecondaryCommandPool *commandPool,
vk::SecondaryCommandMemoryAllocator *commandsAllocator,
vk::RenderPassCommandBufferHelper **commandBufferHelperOut);
void recycleOutsideRenderPassCommandBufferHelper(
vk::OutsideRenderPassCommandBufferHelper **commandBuffer);
void recycleRenderPassCommandBufferHelper(vk::RenderPassCommandBufferHelper **commandBuffer);
// Process GPU memory reports
void processMemoryReportCallback(const VkDeviceMemoryReportCallbackDataEXT &callbackData)
{
bool logCallback = getFeatures().logMemoryReportCallbacks.enabled;
mMemoryReport.processCallback(callbackData, logCallback);
}
// Accumulate cache stats for a specific cache
void accumulateCacheStats(VulkanCacheType cache, const CacheStats &stats)
{
std::unique_lock<std::mutex> localLock(mCacheStatsMutex);
mVulkanCacheStats[cache].accumulate(stats);
}
// Log cache stats for all caches
void logCacheStats() const;
VkPipelineStageFlags getSupportedVulkanPipelineStageMask() const
{
return mSupportedVulkanPipelineStageMask;
}
VkShaderStageFlags getSupportedVulkanShaderStageMask() const
{
return mSupportedVulkanShaderStageMask;
}
angle::Result getFormatDescriptorCountForVkFormat(ContextVk *contextVk,
VkFormat format,
uint32_t *descriptorCountOut);
angle::Result getFormatDescriptorCountForExternalFormat(ContextVk *contextVk,
uint64_t format,
uint32_t *descriptorCountOut);
VkDeviceSize getMaxCopyBytesUsingCPUWhenPreservingBufferData() const
{
return mMaxCopyBytesUsingCPUWhenPreservingBufferData;
}
const vk::ExtensionNameList &getEnabledInstanceExtensions() const
{
return mEnabledInstanceExtensions;
}
const vk::ExtensionNameList &getEnabledDeviceExtensions() const
{
return mEnabledDeviceExtensions;
}
VkDeviceSize getPreferedBufferBlockSize(uint32_t memoryTypeIndex) const;
size_t getDefaultBufferAlignment() const { return mDefaultBufferAlignment; }
uint32_t getStagingBufferMemoryTypeIndex(vk::MemoryCoherency coherency) const
{
return coherency == vk::MemoryCoherency::Coherent
? mCoherentStagingBufferMemoryTypeIndex
: mNonCoherentStagingBufferMemoryTypeIndex;
}
size_t getStagingBufferAlignment() const { return mStagingBufferAlignment; }
uint32_t getVertexConversionBufferMemoryTypeIndex(vk::MemoryHostVisibility hostVisibility) const
{
return hostVisibility == vk::MemoryHostVisibility::Visible
? mHostVisibleVertexConversionBufferMemoryTypeIndex
: mDeviceLocalVertexConversionBufferMemoryTypeIndex;
}
size_t getVertexConversionBufferAlignment() const { return mVertexConversionBufferAlignment; }
uint32_t getDeviceLocalMemoryTypeIndex() const
{
return mDeviceLocalVertexConversionBufferMemoryTypeIndex;
}
void addBufferBlockToOrphanList(vk::BufferBlock *block);
void pruneOrphanedBufferBlocks();
bool isShadingRateSupported(gl::ShadingRate shadingRate) const
{
return mSupportedFragmentShadingRates.test(shadingRate);
}
VkDeviceSize getSuballocationDestroyedSize() const
{
return mSuballocationGarbageDestroyed.load(std::memory_order_consume);
}
void onBufferPoolPrune() { mSuballocationGarbageDestroyed = 0; }
VkDeviceSize getSuballocationGarbageSize() const
{
return mSuballocationGarbageSizeInBytesCachedAtomic.load(std::memory_order_consume);
}
size_t getPendingSubmissionGarbageSize() const
{
std::unique_lock<std::mutex> lock(mGarbageMutex);
return mPendingSubmissionGarbage.size();
}
ANGLE_INLINE VkFilter getPreferredFilterForYUV(VkFilter defaultFilter)
{
return getFeatures().preferLinearFilterForYUV.enabled ? VK_FILTER_LINEAR : defaultFilter;
}
// Convenience helpers to check for dynamic state ANGLE features which depend on the more
// encompassing feature for support of the relevant extension. When the extension-support
// feature is disabled, the derived dynamic state is automatically disabled.
ANGLE_INLINE bool useVertexInputBindingStrideDynamicState()
{
return getFeatures().supportsExtendedDynamicState.enabled &&
getFeatures().useVertexInputBindingStrideDynamicState.enabled;
}
ANGLE_INLINE bool useCullModeDynamicState()
{
return getFeatures().supportsExtendedDynamicState.enabled &&
getFeatures().useCullModeDynamicState.enabled;
}
ANGLE_INLINE bool useDepthCompareOpDynamicState()
{
return getFeatures().supportsExtendedDynamicState.enabled &&
getFeatures().useDepthCompareOpDynamicState.enabled;
}
ANGLE_INLINE bool useDepthTestEnableDynamicState()
{
return getFeatures().supportsExtendedDynamicState.enabled &&
getFeatures().useDepthTestEnableDynamicState.enabled;
}
ANGLE_INLINE bool useDepthWriteEnableDynamicState()
{
return getFeatures().supportsExtendedDynamicState.enabled &&
getFeatures().useDepthWriteEnableDynamicState.enabled;
}
ANGLE_INLINE bool useFrontFaceDynamicState()
{
return getFeatures().supportsExtendedDynamicState.enabled &&
getFeatures().useFrontFaceDynamicState.enabled;
}
ANGLE_INLINE bool useStencilOpDynamicState()
{
return getFeatures().supportsExtendedDynamicState.enabled &&
getFeatures().useStencilOpDynamicState.enabled;
}
ANGLE_INLINE bool useStencilTestEnableDynamicState()
{
return getFeatures().supportsExtendedDynamicState.enabled &&
getFeatures().useStencilTestEnableDynamicState.enabled;
}
ANGLE_INLINE bool usePrimitiveRestartEnableDynamicState()
{
return getFeatures().supportsExtendedDynamicState2.enabled &&
getFeatures().usePrimitiveRestartEnableDynamicState.enabled;
}
ANGLE_INLINE bool useRasterizerDiscardEnableDynamicState()
{
return getFeatures().supportsExtendedDynamicState2.enabled &&
getFeatures().useRasterizerDiscardEnableDynamicState.enabled;
}
ANGLE_INLINE bool useDepthBiasEnableDynamicState()
{
return getFeatures().supportsExtendedDynamicState2.enabled &&
getFeatures().useDepthBiasEnableDynamicState.enabled;
}
ANGLE_INLINE bool useLogicOpDynamicState()
{
return getFeatures().supportsExtendedDynamicState2.enabled &&
getFeatures().supportsLogicOpDynamicState.enabled;
}
angle::Result allocateScopedQueueSerialIndex(vk::ScopedQueueSerialIndex *indexOut);
angle::Result allocateQueueSerialIndex(SerialIndex *serialIndexOut);
size_t getLargestQueueSerialIndexEverAllocated() const
{
return mQueueSerialIndexAllocator.getLargestIndexEverAllocated();
}
void releaseQueueSerialIndex(SerialIndex index);
Serial generateQueueSerial(SerialIndex index);
void reserveQueueSerials(SerialIndex index,
size_t count,
RangedSerialFactory *rangedSerialFactory);
// Return true if all serials in ResourceUse have been submitted.
bool hasResourceUseSubmitted(const vk::ResourceUse &use) const;
bool hasQueueSerialSubmitted(const QueueSerial &queueSerial) const;
Serial getLastSubmittedSerial(SerialIndex index) const;
// Return true if all serials in ResourceUse have been finished.
bool hasResourceUseFinished(const vk::ResourceUse &use) const;
bool hasQueueSerialFinished(const QueueSerial &queueSerial) const;
// Memory statistics can be updated on allocation and deallocation.
template <typename HandleT>
void onMemoryAlloc(vk::MemoryAllocationType allocType,
VkDeviceSize size,
uint32_t memoryTypeIndex,
HandleT handle)
{
mMemoryAllocationTracker.onMemoryAllocImpl(allocType, size, memoryTypeIndex,
reinterpret_cast<void *>(handle));
}
template <typename HandleT>
void onMemoryDealloc(vk::MemoryAllocationType allocType,
VkDeviceSize size,
uint32_t memoryTypeIndex,
HandleT handle)
{
mMemoryAllocationTracker.onMemoryDeallocImpl(allocType, size, memoryTypeIndex,
reinterpret_cast<void *>(handle));
}
MemoryAllocationTracker *getMemoryAllocationTracker() { return &mMemoryAllocationTracker; }
void requestAsyncCommandsAndGarbageCleanup(vk::Context *context);
// Static function to get Vulkan object type name.
static const char *GetVulkanObjectTypeName(VkObjectType type);
private:
angle::Result initializeDevice(DisplayVk *displayVk, uint32_t queueFamilyIndex);
void ensureCapsInitialized() const;
void initializeValidationMessageSuppressions();
void queryDeviceExtensionFeatures(const vk::ExtensionNameList &deviceExtensionNames);
void appendDeviceExtensionFeaturesNotPromoted(const vk::ExtensionNameList &deviceExtensionNames,
VkPhysicalDeviceFeatures2KHR *deviceFeatures,
VkPhysicalDeviceProperties2 *deviceProperties);
void appendDeviceExtensionFeaturesPromotedTo11(
const vk::ExtensionNameList &deviceExtensionNames,
VkPhysicalDeviceFeatures2KHR *deviceFeatures,
VkPhysicalDeviceProperties2 *deviceProperties);
void appendDeviceExtensionFeaturesPromotedTo12(
const vk::ExtensionNameList &deviceExtensionNames,
VkPhysicalDeviceFeatures2KHR *deviceFeatures,
VkPhysicalDeviceProperties2 *deviceProperties);
void appendDeviceExtensionFeaturesPromotedTo13(
const vk::ExtensionNameList &deviceExtensionNames,
VkPhysicalDeviceFeatures2KHR *deviceFeatures,
VkPhysicalDeviceProperties2 *deviceProperties);
angle::Result enableInstanceExtensions(DisplayVk *displayVk,
const VulkanLayerVector &enabledInstanceLayerNames,
const char *wsiExtension,
bool canLoadDebugUtils);
angle::Result enableDeviceExtensions(DisplayVk *displayVk,
const VulkanLayerVector &enabledDeviceLayerNames);
void enableDeviceExtensionsNotPromoted(const vk::ExtensionNameList &deviceExtensionNames);
void enableDeviceExtensionsPromotedTo11(const vk::ExtensionNameList &deviceExtensionNames);
void enableDeviceExtensionsPromotedTo12(const vk::ExtensionNameList &deviceExtensionNames);
void enableDeviceExtensionsPromotedTo13(const vk::ExtensionNameList &deviceExtensionNames);
void initInstanceExtensionEntryPoints();
void initDeviceExtensionEntryPoints();
// Initialize extension entry points from core ones if needed
void initializeInstanceExtensionEntryPointsFromCore() const;
void initializeDeviceExtensionEntryPointsFromCore() const;
void initFeatures(DisplayVk *display, const vk::ExtensionNameList &extensions);
void appBasedFeatureOverrides(DisplayVk *display, const vk::ExtensionNameList &extensions);
angle::Result initPipelineCache(DisplayVk *display,
vk::PipelineCache *pipelineCache,
bool *success);
template <VkFormatFeatureFlags VkFormatProperties::*features>
VkFormatFeatureFlags getFormatFeatureBits(angle::FormatID formatID,
const VkFormatFeatureFlags featureBits) const;
template <VkFormatFeatureFlags VkFormatProperties::*features>
bool hasFormatFeatureBits(angle::FormatID formatID,
const VkFormatFeatureFlags featureBits) const;
// Initialize VMA allocator and buffer suballocator related data.
angle::Result initializeMemoryAllocator(DisplayVk *displayVk);
// Query and cache supported fragment shading rates
bool canSupportFragmentShadingRate(const vk::ExtensionNameList &deviceExtensionNames);
// Prefer host visible device local via device local based on device type and heap size.
bool canPreferDeviceLocalMemoryHostVisible(VkPhysicalDeviceType deviceType);
template <typename CommandBufferHelperT, typename RecyclerT>
angle::Result getCommandBufferImpl(vk::Context *context,
vk::SecondaryCommandPool *commandPool,
vk::SecondaryCommandMemoryAllocator *commandsAllocator,
RecyclerT *recycler,
CommandBufferHelperT **commandBufferHelperOut);
egl::Display *mDisplay;
void *mLibVulkanLibrary;
mutable bool mCapsInitialized;
mutable gl::Caps mNativeCaps;
mutable gl::TextureCapsMap mNativeTextureCaps;
mutable gl::Extensions mNativeExtensions;
mutable gl::Limitations mNativeLimitations;
mutable ShPixelLocalStorageOptions mNativePLSOptions;
mutable angle::FeaturesVk mFeatures;
// The instance and device versions. The instance version is the one from the Vulkan loader,
// while the device version comes from VkPhysicalDeviceProperties::apiVersion. With instance
// version 1.0, only device version 1.0 can be used. If instance version is at least 1.1, any
// device version (even higher than that) can be used. Some extensions have been promoted to
// Vulkan 1.1 or higher, but the version check must be done against the instance or device
// version, depending on whether it's an instance or device extension.
//
// Note that mDeviceVersion is technically redundant with mPhysicalDeviceProperties.apiVersion,
// but ANGLE may use a smaller version with problematic ICDs.
uint32_t mInstanceVersion;
uint32_t mDeviceVersion;
VkInstance mInstance;
bool mEnableValidationLayers;
// True if ANGLE is enabling the VK_EXT_debug_utils extension.
bool mEnableDebugUtils;
// True if ANGLE should call the vkCmd*DebugUtilsLabelEXT functions in order to communicate
// to debuggers (e.g. AGI) the OpenGL ES commands that the application uses. This is
// independent of mEnableDebugUtils, as an external graphics debugger can enable the
// VK_EXT_debug_utils extension and cause this to be set true.
bool mAngleDebuggerMode;
angle::vk::ICD mEnabledICD;
VkDebugUtilsMessengerEXT mDebugUtilsMessenger;
VkPhysicalDevice mPhysicalDevice;
VkPhysicalDeviceProperties mPhysicalDeviceProperties;
VkPhysicalDeviceVulkan11Properties mPhysicalDevice11Properties;
VkPhysicalDeviceFeatures mPhysicalDeviceFeatures;
VkPhysicalDeviceVulkan11Features mPhysicalDevice11Features;
VkPhysicalDeviceLineRasterizationFeaturesEXT mLineRasterizationFeatures;
VkPhysicalDeviceProvokingVertexFeaturesEXT mProvokingVertexFeatures;
VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT mVertexAttributeDivisorFeatures;
VkPhysicalDeviceVertexAttributeDivisorPropertiesEXT mVertexAttributeDivisorProperties;
VkPhysicalDeviceTransformFeedbackFeaturesEXT mTransformFeedbackFeatures;
VkPhysicalDeviceIndexTypeUint8FeaturesEXT mIndexTypeUint8Features;
VkPhysicalDeviceSubgroupProperties mSubgroupProperties;
VkPhysicalDeviceShaderSubgroupExtendedTypesFeaturesKHR mSubgroupExtendedTypesFeatures;
VkPhysicalDeviceDeviceMemoryReportFeaturesEXT mMemoryReportFeatures;
VkDeviceDeviceMemoryReportCreateInfoEXT mMemoryReportCallback;
VkPhysicalDeviceShaderFloat16Int8FeaturesKHR mShaderFloat16Int8Features;
VkPhysicalDeviceDepthStencilResolvePropertiesKHR mDepthStencilResolveProperties;
VkPhysicalDeviceMultisampledRenderToSingleSampledFeaturesGOOGLEX
mMultisampledRenderToSingleSampledFeaturesGOOGLEX;
VkPhysicalDeviceMultisampledRenderToSingleSampledFeaturesEXT
mMultisampledRenderToSingleSampledFeatures;
VkPhysicalDeviceImage2DViewOf3DFeaturesEXT mImage2dViewOf3dFeatures;
VkPhysicalDeviceMultiviewFeatures mMultiviewFeatures;
VkPhysicalDeviceFeatures2KHR mEnabledFeatures;
VkPhysicalDeviceMultiviewProperties mMultiviewProperties;
VkPhysicalDeviceDriverPropertiesKHR mDriverProperties;
VkPhysicalDeviceCustomBorderColorFeaturesEXT mCustomBorderColorFeatures;
VkPhysicalDeviceProtectedMemoryFeatures mProtectedMemoryFeatures;
VkPhysicalDeviceHostQueryResetFeaturesEXT mHostQueryResetFeatures;
VkPhysicalDeviceDepthClampZeroOneFeaturesEXT mDepthClampZeroOneFeatures;
VkPhysicalDeviceDepthClipEnableFeaturesEXT mDepthClipEnableFeatures;
VkPhysicalDeviceDepthClipControlFeaturesEXT mDepthClipControlFeatures;
VkPhysicalDevicePrimitivesGeneratedQueryFeaturesEXT mPrimitivesGeneratedQueryFeatures;
VkPhysicalDevicePrimitiveTopologyListRestartFeaturesEXT mPrimitiveTopologyListRestartFeatures;
VkPhysicalDeviceSamplerYcbcrConversionFeatures mSamplerYcbcrConversionFeatures;
VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT mPipelineCreationCacheControlFeatures;
VkPhysicalDeviceExtendedDynamicStateFeaturesEXT mExtendedDynamicStateFeatures;
VkPhysicalDeviceExtendedDynamicState2FeaturesEXT mExtendedDynamicState2Features;
VkPhysicalDeviceGraphicsPipelineLibraryFeaturesEXT mGraphicsPipelineLibraryFeatures;
VkPhysicalDeviceGraphicsPipelineLibraryPropertiesEXT mGraphicsPipelineLibraryProperties;
VkPhysicalDeviceFragmentShadingRateFeaturesKHR mFragmentShadingRateFeatures;
VkPhysicalDeviceFragmentShaderInterlockFeaturesEXT mFragmentShaderInterlockFeatures;
VkPhysicalDeviceImagelessFramebufferFeaturesKHR mImagelessFramebufferFeatures;
VkPhysicalDevicePipelineRobustnessFeaturesEXT mPipelineRobustnessFeatures;
VkPhysicalDevicePipelineProtectedAccessFeaturesEXT mPipelineProtectedAccessFeatures;
VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesEXT
mRasterizationOrderAttachmentAccessFeatures;
VkPhysicalDeviceSwapchainMaintenance1FeaturesEXT mSwapchainMaintenance1Features;
VkPhysicalDeviceLegacyDitheringFeaturesEXT mDitheringFeatures;
VkPhysicalDeviceDrmPropertiesEXT mDrmProperties;
angle::PackedEnumBitSet<gl::ShadingRate, uint8_t> mSupportedFragmentShadingRates;
std::vector<VkQueueFamilyProperties> mQueueFamilyProperties;
uint32_t mMaxVertexAttribDivisor;
uint32_t mCurrentQueueFamilyIndex;
VkDeviceSize mMaxVertexAttribStride;
uint32_t mDefaultUniformBufferSize;
VkDevice mDevice;
AtomicSerialFactory mShaderSerialFactory;
VkDeviceSize mMaxCopyBytesUsingCPUWhenPreservingBufferData;
bool mDeviceLost;
// We group garbage into four categories: mSharedGarbage is the garbage that has already
// submitted to vulkan, we expect them to finish in finite time. mPendingSubmissionGarbage
// is the garbage that is still referenced in the recorded commands. suballocations have its
// own dedicated garbage list for performance optimization since they tend to be the most
// common garbage objects. All these four groups of garbage share the same mutex lock.
mutable std::mutex mGarbageMutex;
vk::SharedGarbageList mSharedGarbage;
vk::SharedGarbageList mPendingSubmissionGarbage;
vk::SharedBufferSuballocationGarbageList mSuballocationGarbage;
vk::SharedBufferSuballocationGarbageList mPendingSubmissionSuballocationGarbage;
// Total suballocation garbage size in bytes.
VkDeviceSize mSuballocationGarbageSizeInBytes;
// Total bytes of suballocation that been destroyed since last prune call. This can be
// accessed without mGarbageMutex, thus needs to be atomic to avoid tsan complain.
std::atomic<VkDeviceSize> mSuballocationGarbageDestroyed;
// This is the cached value of mSuballocationGarbageSizeInBytes but is accessed with atomic
// operation. This can be accessed from different threads without mGarbageMutex, so that
// thread sanitizer won't complain.
std::atomic<VkDeviceSize> mSuballocationGarbageSizeInBytesCachedAtomic;
vk::FormatTable mFormatTable;
// A cache of VkFormatProperties as queried from the device over time.
mutable angle::FormatMap<VkFormatProperties> mFormatProperties;
vk::Allocator mAllocator;
// Used to allocate memory for images using VMA, utilizing suballocation.
vk::ImageMemorySuballocator mImageMemorySuballocator;
vk::MemoryProperties mMemoryProperties;
VkDeviceSize mPreferredLargeHeapBlockSize;
// The default alignment for BufferVk object
size_t mDefaultBufferAlignment;
// The cached memory type index for staging buffer that is host visible.
uint32_t mCoherentStagingBufferMemoryTypeIndex;
uint32_t mNonCoherentStagingBufferMemoryTypeIndex;
size_t mStagingBufferAlignment;
// For vertex conversion buffers
uint32_t mHostVisibleVertexConversionBufferMemoryTypeIndex;
uint32_t mDeviceLocalVertexConversionBufferMemoryTypeIndex;
size_t mVertexConversionBufferAlignment;
// Holds orphaned BufferBlocks when ShareGroup gets destroyed
vk::BufferBlockPointerVector mOrphanedBufferBlocks;
// All access to the pipeline cache is done through EGL objects so it is thread safe to not
// use a lock.
std::mutex mPipelineCacheMutex;
vk::PipelineCache mPipelineCache;
uint32_t mPipelineCacheVkUpdateTimeout;
size_t mPipelineCacheSizeAtLastSync;
bool mPipelineCacheInitialized;
// Latest validation data for debug overlay.
std::string mLastValidationMessage;
uint32_t mValidationMessageCount;
// Skipped validation messages. The exact contents of the list depends on the availability
// of certain extensions.
std::vector<const char *> mSkippedValidationMessages;
// Syncval skipped messages. The exact contents of the list depends on the availability of
// certain extensions.
std::vector<vk::SkippedSyncvalMessage> mSkippedSyncvalMessages;
// Whether framebuffer fetch has been used, for the purposes of more accurate syncval error
// filtering.
bool mIsFramebufferFetchUsed;
// How close to VkPhysicalDeviceLimits::maxMemoryAllocationCount we allow ourselves to get
static constexpr double kPercentMaxMemoryAllocationCount = 0.3;
// How many objects to garbage collect before issuing a flush()
uint32_t mGarbageCollectionFlushThreshold;
// Only used for "one off" command buffers.
angle::PackedEnumMap<vk::ProtectionType, OneOffCommandPool> mOneOffCommandPoolMap;
// Synchronous Command Queue
vk::CommandQueue mCommandQueue;
// Async Command Queue
vk::CommandProcessor mCommandProcessor;
// Command buffer pool management.
vk::CommandBufferRecycler<vk::OutsideRenderPassCommandBufferHelper>
mOutsideRenderPassCommandBufferRecycler;
vk::CommandBufferRecycler<vk::RenderPassCommandBufferHelper> mRenderPassCommandBufferRecycler;
SamplerCache mSamplerCache;
SamplerYcbcrConversionCache mYuvConversionCache;
angle::HashMap<VkFormat, uint32_t> mVkFormatDescriptorCountMap;
vk::ActiveHandleCounter mActiveHandleCounts;
std::mutex mActiveHandleCountsMutex;
// Tracks resource serials.
vk::ResourceSerialFactory mResourceSerialFactory;
// QueueSerial generator
vk::QueueSerialIndexAllocator mQueueSerialIndexAllocator;
std::array<AtomicSerialFactory, kMaxQueueSerialIndexCount> mQueueSerialFactory;
// Application executable information
VkApplicationInfo mApplicationInfo;
// Process GPU memory reports
vk::MemoryReport mMemoryReport;
// Helpers for adding trace annotations
DebugAnnotatorVk mAnnotator;
// Stats about all Vulkan object caches
VulkanCacheStats mVulkanCacheStats;
mutable std::mutex mCacheStatsMutex;
// A mask to filter out Vulkan pipeline stages that are not supported, applied in situations
// where multiple stages are prespecified (for example with image layout transitions):
//
// - Excludes GEOMETRY if geometry shaders are not supported.
// - Excludes TESSELLATION_CONTROL and TESSELLATION_EVALUATION if tessellation shaders are
// not
// supported.
//
// Note that this mask can have bits set that don't correspond to valid stages, so it's
// strictly only useful for masking out unsupported stages in an otherwise valid set of
// stages.
VkPipelineStageFlags mSupportedVulkanPipelineStageMask;
VkShaderStageFlags mSupportedVulkanShaderStageMask;
// Use thread pool to compress cache data.
std::shared_ptr<rx::WaitableCompressEvent> mCompressEvent;
vk::ExtensionNameList mEnabledInstanceExtensions;
vk::ExtensionNameList mEnabledDeviceExtensions;
// Memory tracker for allocations and deallocations.
MemoryAllocationTracker mMemoryAllocationTracker;
};
ANGLE_INLINE Serial RendererVk::generateQueueSerial(SerialIndex index)
{
return mQueueSerialFactory[index].generate();
}
ANGLE_INLINE void RendererVk::reserveQueueSerials(SerialIndex index,
size_t count,
RangedSerialFactory *rangedSerialFactory)
{
mQueueSerialFactory[index].reserve(rangedSerialFactory, count);
}
ANGLE_INLINE bool RendererVk::hasResourceUseSubmitted(const vk::ResourceUse &use) const
{
if (isAsyncCommandQueueEnabled())
{
return mCommandProcessor.hasResourceUseEnqueued(use);
}
else
{
return mCommandQueue.hasResourceUseSubmitted(use);
}
}
ANGLE_INLINE bool RendererVk::hasQueueSerialSubmitted(const QueueSerial &queueSerial) const
{
if (isAsyncCommandQueueEnabled())
{
return mCommandProcessor.hasQueueSerialEnqueued(queueSerial);
}
else
{
return mCommandQueue.hasQueueSerialSubmitted(queueSerial);
}
}
ANGLE_INLINE Serial RendererVk::getLastSubmittedSerial(SerialIndex index) const
{
if (isAsyncCommandQueueEnabled())
{
return mCommandProcessor.getLastEnqueuedSerial(index);
}
else
{
return mCommandQueue.getLastSubmittedSerial(index);
}
}
ANGLE_INLINE bool RendererVk::hasResourceUseFinished(const vk::ResourceUse &use) const
{
return mCommandQueue.hasResourceUseFinished(use);
}
ANGLE_INLINE bool RendererVk::hasQueueSerialFinished(const QueueSerial &queueSerial) const
{
return mCommandQueue.hasQueueSerialFinished(queueSerial);
}
ANGLE_INLINE angle::Result RendererVk::waitForPresentToBeSubmitted(
vk::SwapchainStatus *swapchainStatus)
{
if (isAsyncCommandQueueEnabled())
{
return mCommandProcessor.waitForPresentToBeSubmitted(swapchainStatus);
}
ASSERT(!swapchainStatus->isPending);
return angle::Result::Continue;
}
ANGLE_INLINE void RendererVk::requestAsyncCommandsAndGarbageCleanup(vk::Context *context)
{
mCommandProcessor.requestCommandsAndGarbageCleanup();
}
ANGLE_INLINE angle::Result RendererVk::checkCompletedCommands(vk::Context *context)
{
return mCommandQueue.checkAndCleanupCompletedCommands(context);
}
ANGLE_INLINE angle::Result RendererVk::retireFinishedCommands(vk::Context *context)
{
return mCommandQueue.retireFinishedCommands(context);
}
} // namespace rx
#endif // LIBANGLE_RENDERER_VULKAN_RENDERERVK_H_