21#if defined(SK_USE_VMA)
33 SKGPU_LOG_E(
"Failed to create VulkanSharedContext because either fInstance,"
34 "fPhysicalDevice, fDevice, or fQueue in the VulkanBackendContext is"
39 SKGPU_LOG_E(
"Failed to create VulkanSharedContext because there is no valid VulkanGetProc"
40 "on the VulkanBackendContext");
47 uint32_t instanceVersion = 0;
48 if (!localEnumerateInstanceVersion) {
51 VkResult err = localEnumerateInstanceVersion(&instanceVersion);
53 SKGPU_LOG_E(
"Failed to enumerate instance version. Err: %d\n", err);
60 context.
fGetProc(
"vkGetPhysicalDeviceProperties",
64 if (!localGetPhysicalDeviceProperties) {
65 SKGPU_LOG_E(
"Failed to get function pointer to vkGetPhysicalDeviceProperties.");
69 localGetPhysicalDeviceProperties(context.
fPhysicalDevice, &physDeviceProperties);
70 uint32_t physDevVersion = physDeviceProperties.
apiVersion;
74 instanceVersion =
std::min(instanceVersion, apiVersion);
75 physDevVersion =
std::min(physDevVersion, apiVersion);
94 features.
pNext =
nullptr;
96 featuresPtr = &features;
110#if defined(SK_USE_VMA)
126 SKGPU_LOG_E(
"No supplied vulkan memory allocator and unable to create one internally.");
139 std::unique_ptr<const VulkanCaps> caps)
141 , fInterface(
std::move(interface))
142 , fMemoryAllocator(
std::move(memoryAllocator))
143 , fDevice(
std::move(backendContext.fDevice))
144 , fQueueIndex(backendContext.fGraphicsQueueIndex)
145 , fDeviceLostContext(backendContext.fDeviceLostContext)
146 , fDeviceLostProc(backendContext.fDeviceLostProc) {}
156 size_t resourceBudget) {
158 size_t alignedIntrinsicConstantSize =
160 this->
vulkanCaps().requiredUniformBufferAlignment());
163 if (!intrinsicConstantBuffer) {
164 SKGPU_LOG_E(
"Failed to create intrinsic constant uniform buffer");
169 intrinsicConstantBuffer->setLabel(
"IntrinsicConstantBuffer");
178 if (!loadMSAAVertexBuffer) {
179 SKGPU_LOG_E(
"Failed to create vertex buffer for loading MSAA from resolve");
184 loadMSAAVertexBuffer->setLabel(
"LoadMSAAVertexBuffer");
186 return std::unique_ptr<ResourceProvider>(
191 std::move(intrinsicConstantBuffer),
192 std::move(loadMSAAVertexBuffer)));
205 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, ThreadSafe)
const Caps * caps() const
GlobalCache * globalCache()
VkBufferUsageFlags bufferUsageFlags() const
static sk_sp< Buffer > Make(const VulkanSharedContext *, size_t, BufferType, AccessPattern)
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 &)
static float max(float r, float g, float b)
static float min(float r, float g, float b)
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)