Changeset b794178 in opengl-game for vulkan-utils.hpp


Ignore:
Timestamp:
Oct 17, 2019, 9:30:18 PM (5 years ago)
Author:
Dmitry Portnoy <dmitry.portnoy@…>
Branches:
feature/imgui-sdl, master, points-test
Children:
e83b155
Parents:
771b33a
Message:

In vulkangame, add the ability to create vulkan resoirces and descriptor sets for shader uniforms (images and ubos)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vulkan-utils.hpp

    r771b33a rb794178  
    33
    44#include <optional>
     5#include <string>
    56#include <vector>
    67
    78#include <vulkan/vulkan.h>
     9
     10#include <SDL2/SDL.h>
     11#include <SDL2/SDL_image.h>
     12#include <SDL2/SDL_vulkan.h>
    813
    914using namespace std;
     
    2429};
    2530
     31struct VulkanImage {
     32   VkImage image;
     33   VkDeviceMemory imageMemory;
     34   VkImageView imageView;
     35};
     36
    2637class VulkanUtils {
    2738   public:
     
    3849
    3950      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);
    4255      static VkSurfaceFormatKHR chooseSwapSurfaceFormat(const vector<VkSurfaceFormatKHR>& availableFormats);
    4356      static VkPresentModeKHR chooseSwapPresentMode(const vector<VkPresentModeKHR>& availablePresentModes);
    4457      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);
    4660      static VkFormat findSupportedFormat(VkPhysicalDevice physicalDevice, const vector<VkFormat>& candidates,
    4761            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);
    4885};
    4986
Note: See TracChangeset for help on using the changeset viewer.