Changeset b794178 in opengl-game for vulkan-utils.hpp
- Timestamp:
- Oct 17, 2019, 9:30:18 PM (5 years ago)
- Branches:
- feature/imgui-sdl, master, points-test
- Children:
- e83b155
- Parents:
- 771b33a
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vulkan-utils.hpp
r771b33a rb794178 3 3 4 4 #include <optional> 5 #include <string> 5 6 #include <vector> 6 7 7 8 #include <vulkan/vulkan.h> 9 10 #include <SDL2/SDL.h> 11 #include <SDL2/SDL_image.h> 12 #include <SDL2/SDL_vulkan.h> 8 13 9 14 using namespace std; … … 24 29 }; 25 30 31 struct VulkanImage { 32 VkImage image; 33 VkDeviceMemory imageMemory; 34 VkImageView imageView; 35 }; 36 26 37 class VulkanUtils { 27 38 public: … … 38 49 39 50 static QueueFamilyIndices findQueueFamilies(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface); 40 static bool checkDeviceExtensionSupport(VkPhysicalDevice physicalDevice, const vector<const char*>& deviceExtensions); 41 static SwapChainSupportDetails querySwapChainSupport(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface); 51 static bool checkDeviceExtensionSupport(VkPhysicalDevice physicalDevice, 52 const vector<const char*>& deviceExtensions); 53 static SwapChainSupportDetails querySwapChainSupport(VkPhysicalDevice physicalDevice, 54 VkSurfaceKHR surface); 42 55 static VkSurfaceFormatKHR chooseSwapSurfaceFormat(const vector<VkSurfaceFormatKHR>& availableFormats); 43 56 static VkPresentModeKHR chooseSwapPresentMode(const vector<VkPresentModeKHR>& availablePresentModes); 44 57 static VkExtent2D chooseSwapExtent(const VkSurfaceCapabilitiesKHR& capabilities, int width, int height); 45 static VkImageView createImageView(VkDevice device, VkImage image, VkFormat format, VkImageAspectFlags aspectFlags); 58 static VkImageView createImageView(VkDevice device, VkImage image, VkFormat format, 59 VkImageAspectFlags aspectFlags); 46 60 static VkFormat findSupportedFormat(VkPhysicalDevice physicalDevice, const vector<VkFormat>& candidates, 47 61 VkImageTiling tiling, VkFormatFeatureFlags features); 62 static void createBuffer(VkDevice device, VkPhysicalDevice physicalDevice, VkDeviceSize size, 63 VkBufferUsageFlags usage, VkMemoryPropertyFlags properties, VkBuffer& buffer, 64 VkDeviceMemory& bufferMemory); 65 static uint32_t findMemoryType(VkPhysicalDevice physicalDevice, uint32_t typeFilter, 66 VkMemoryPropertyFlags properties); 67 68 static void createVulkanImageFromFile(VkDevice device, VkPhysicalDevice physicalDevice, 69 VkCommandPool commandPool, string filename, VulkanImage& image, VkQueue graphicsQueue); 70 static void createVulkanImageFromSDLTexture(VkDevice device, VkPhysicalDevice physicalDevice, 71 SDL_Texture* texture, VulkanImage& image); 72 static void createImage(VkDevice device, VkPhysicalDevice physicalDevice, uint32_t width, uint32_t height, 73 VkFormat format, VkImageTiling tiling, VkImageUsageFlags usage, VkMemoryPropertyFlags properties, 74 VulkanImage& image); 75 76 static void transitionImageLayout(VkDevice device, VkCommandPool commandPool, VkImage image, 77 VkFormat format, VkImageLayout oldLayout, VkImageLayout newLayout, VkQueue graphicsQueue); 78 static VkCommandBuffer beginSingleTimeCommands(VkDevice device, VkCommandPool commandPool); 79 static void endSingleTimeCommands(VkDevice device, VkCommandPool commandPool, 80 VkCommandBuffer commandBuffer, VkQueue graphicsQueue); 81 static void copyBufferToImage(VkDevice device, VkCommandPool commandPool, VkBuffer buffer, VkImage image, 82 uint32_t width, uint32_t height, VkQueue graphicsQueue); 83 84 static bool hasStencilComponent(VkFormat format); 48 85 }; 49 86
Note:
See TracChangeset
for help on using the changeset viewer.