30 SKGPU_LOG_E(
"Failed to create VulkanSharedContext because either fInstance,"
31 "fPhysicalDevice, fDevice, or fQueue in the VulkanBackendContext is"
36 SKGPU_LOG_E(
"Failed to create VulkanSharedContext because there is no valid VulkanGetProc"
37 "on the VulkanBackendContext");
44 uint32_t instanceVersion = 0;
45 if (!localEnumerateInstanceVersion) {
48 VkResult err = localEnumerateInstanceVersion(&instanceVersion);
50 SKGPU_LOG_E(
"Failed to enumerate instance version. Err: %d\n", err);
57 context.
fGetProc(
"vkGetPhysicalDeviceProperties",
61 if (!localGetPhysicalDeviceProperties) {
62 SKGPU_LOG_E(
"Failed to get function pointer to vkGetPhysicalDeviceProperties.");
66 localGetPhysicalDeviceProperties(context.
fPhysicalDevice, &physDeviceProperties);
67 uint32_t physDevVersion = physDeviceProperties.
apiVersion;
71 instanceVersion = std::min(instanceVersion, apiVersion);
72 physDevVersion = std::min(physDevVersion, apiVersion);
91 features.
pNext =
nullptr;
93 featuresPtr = &features;
109 bool threadSafe = !
options.fClientWillExternallySynchronizeAllThreads;
119 SKGPU_LOG_E(
"No supplied vulkan memory allocator and unable to create one internally.");
132 std::unique_ptr<const VulkanCaps> caps)
134 , fInterface(
std::move(interface))
135 , fMemoryAllocator(
std::move(memoryAllocator))
136 , fDevice(
std::move(backendContext.fDevice))
137 , fQueueIndex(backendContext.fGraphicsQueueIndex)
138 , fDeviceLostContext(backendContext.fDeviceLostContext)
139 , fDeviceLostProc(backendContext.fDeviceLostProc) {}
149 size_t resourceBudget) {
151 size_t alignedIntrinsicConstantSize =
153 this->
vulkanCaps().requiredUniformBufferAlignment());
155 alignedIntrinsicConstantSize,
158 "IntrinsicConstantBuffer");
159 if (!intrinsicConstantBuffer) {
160 SKGPU_LOG_E(
"Failed to create intrinsic constant uniform buffer");
173 "LoadMSAAVertexBuffer");
174 if (!loadMSAAVertexBuffer) {
175 SKGPU_LOG_E(
"Failed to create vertex buffer for loading MSAA from resolve");
181 return std::unique_ptr<ResourceProvider>(
186 std::move(intrinsicConstantBuffer),
187 std::move(loadMSAAVertexBuffer)));
200 fDeviceIsLost =
true;
#define SKGPU_LOG_E(fmt,...)
static sk_sp< VulkanMemoryAllocator > Make(VkInstance instance, VkPhysicalDevice physicalDevice, VkDevice device, uint32_t physicalDeviceVersion, const VulkanExtensions *extensions, const VulkanInterface *interface, bool threadSafe)
const Caps * caps() const
GlobalCache * globalCache()
VkBufferUsageFlags bufferUsageFlags() const
static sk_sp< Buffer > Make(const VulkanSharedContext *, size_t, BufferType, AccessPattern, std::string_view label)
static constexpr size_t kLoadMSAAVertexBufferSize
static constexpr size_t kIntrinsicConstantSize
skgpu::VulkanMemoryAllocator * memoryAllocator() const
~VulkanSharedContext() override
bool checkVkResult(VkResult result) const
const skgpu::VulkanInterface * interface() const
const VulkanCaps & vulkanCaps() const
std::unique_ptr< ResourceProvider > makeResourceProvider(SingleOwner *, uint32_t recorderID, size_t resourceBudget) override
static sk_sp< SharedContext > Make(const VulkanBackendContext &, const ContextOptions &)
void InvokeDeviceLostCallback(const skgpu::VulkanInterface *vulkanInterface, VkDevice vkDevice, skgpu::VulkanDeviceLostContext deviceLostContext, skgpu::VulkanDeviceLostProc deviceLostProc, bool supportsDeviceFaultInfoExtension)
VkPhysicalDeviceFeatures features
const VkPhysicalDeviceFeatures2 * fDeviceFeatures2
Protected fProtectedContext
sk_sp< VulkanMemoryAllocator > fMemoryAllocator
const VkPhysicalDeviceFeatures * fDeviceFeatures
skgpu::VulkanGetProc fGetProc
VkPhysicalDevice fPhysicalDevice
const skgpu::VulkanExtensions * fVkExtensions
bool validate(uint32_t instanceVersion, uint32_t physicalDeviceVersion, const VulkanExtensions *) const
void(VKAPI_PTR * PFN_vkGetPhysicalDeviceProperties)(VkPhysicalDevice physicalDevice, VkPhysicalDeviceProperties *pProperties)
#define VK_MAKE_VERSION(major, minor, patch)
@ VK_BUFFER_USAGE_TRANSFER_DST_BIT
@ VK_BUFFER_USAGE_VERTEX_BUFFER_BIT
@ VK_ERROR_OUT_OF_HOST_MEMORY
@ VK_ERROR_OUT_OF_DEVICE_MEMORY
VkResult(VKAPI_PTR * PFN_vkEnumerateInstanceVersion)(uint32_t *pApiVersion)