1 2 /* 3 * Copyright 2016 Google Inc. 4 * 5 * Use of this source code is governed by a BSD-style license that can be 6 * found in the LICENSE file. 7 */ 8 9 #ifndef GrVkTypes_DEFINED 10 #define GrVkTypes_DEFINED 11 12 #include "GrTypes.h" 13 #include "vk/GrVkDefines.h" 14 15 /** 16 * KHR_debug 17 */ 18 /*typedef void (GR_GL_FUNCTION_TYPE* GrVkDEBUGPROC)(GrVkenum source, 19 GrVkenum type, 20 GrVkuint id, 21 GrVkenum severity, 22 GrVksizei length, 23 const GrVkchar* message, 24 const void* userParam);*/ 25 26 27 28 /////////////////////////////////////////////////////////////////////////////// 29 /** 30 * Types for interacting with Vulkan resources created externally to Skia. GrBackendObjects for 31 * Vulkan textures are really const GrVkImageInfo* 32 */ 33 struct GrVkAlloc { 34 VkDeviceMemory fMemory; // can be VK_NULL_HANDLE iff Tex is an RT and uses borrow semantics 35 VkDeviceSize fOffset; 36 VkDeviceSize fSize; // this can be indeterminate iff Tex uses borrow semantics 37 uint32_t fFlags; 38 39 enum Flag { 40 kNoncoherent_Flag = 0x1, // memory must be flushed to device after mapping 41 }; 42 }; 43 44 struct GrVkImageInfo { 45 /** 46 * If the image's format is sRGB (GrVkFormatIsSRGB returns true), then the image must have 47 * been created with VkImageCreateFlags containing VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT. 48 */ 49 VkImage fImage; 50 GrVkAlloc fAlloc; 51 VkImageTiling fImageTiling; 52 VkImageLayout fImageLayout; 53 VkFormat fFormat; 54 uint32_t fLevelCount; 55 56 // This gives a way for a client to update the layout of the Image if they change the layout 57 // while we're still holding onto the wrapped texture. They will first need to get a handle 58 // to our internal GrVkImageInfo by calling getTextureHandle on a GrVkTexture. updateImageLayoutGrVkImageInfo59 void updateImageLayout(VkImageLayout layout) { fImageLayout = layout; } 60 }; 61 62 GR_STATIC_ASSERT(sizeof(GrBackendObject) >= sizeof(const GrVkImageInfo*)); 63 64 #endif 65