NAP
renderutils.h
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2  * License, v. 2.0. If a copy of the MPL was not distributed with this
3  * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 
5 #pragma once
6 
7 // External Includes
8 #include <vulkan/vulkan_core.h>
9 #include <utility/dllexport.h>
10 #include <nap/numeric.h>
11 #include <utility/errorstate.h>
12 #include <assert.h>
13 
14 // Local Includes
15 #include "imagedata.h"
16 #include "bufferdata.h"
17 #include "vk_mem_alloc.h"
18 #include "surfacedescriptor.h"
19 
20 namespace nap
21 {
25  enum class ERasterizationSamples : int
26  {
27  One = 0x00000001,
28  Two = 0x00000002,
29  Four = 0x00000004,
30  Eight = 0x00000008,
31  Sixteen = 0x00000010,
32  Max = 0x00000000
33  };
34 
35 
36  namespace utility
37  {
41  bool NAPAPI createRenderPass(VkDevice device, VkFormat colorFormat, VkFormat depthFormat, VkSampleCountFlagBits samples, VkImageLayout targetLayout, bool consumeDepth, VkRenderPass& renderPass, utility::ErrorState& errorState);
42 
46  bool NAPAPI createRenderPass(VkDevice device, VkFormat colorFormat, VkFormat depthFormat, VkSampleCountFlagBits samples, VkImageLayout targetLayout, VkRenderPass& renderPass, utility::ErrorState& errorState);
47 
51  bool NAPAPI createDepthOnlyRenderPass(VkDevice device, VkFormat depthFormat, VkRenderPass& renderPass, utility::ErrorState& errorState);
52 
56  bool NAPAPI create2DImage(VmaAllocator allocator, uint32 width, uint32 height, VkFormat format, uint32 mipLevels, VkSampleCountFlagBits samples, VkImageTiling tiling, VkImageUsageFlags imageUsage, VmaMemoryUsage memoryUsage, VkImage& outImage, VmaAllocation& outAllocation, VmaAllocationInfo& outAllocationInfo, utility::ErrorState& errorState);
57 
61  bool NAPAPI create2DImageView(VkDevice device, VkImage image, VkFormat format, uint32 mipLevels, VkImageAspectFlags aspectFlags, VkImageView& outImageView, utility::ErrorState& errorState);
62 
66  bool NAPAPI createLayered2DImage(VmaAllocator allocator, uint32 width, uint32 height, VkFormat format, uint32 mipLevels, uint32 layerCount, VkSampleCountFlagBits samples, VkImageTiling tiling, VkImageUsageFlags imageUsage, VmaMemoryUsage memoryUsage, VkImageCreateFlags flags, VkImage& outImage, VmaAllocation& outAllocation, VmaAllocationInfo& outAllocationInfo, utility::ErrorState& errorState);
67 
71  bool NAPAPI createLayered2DImageView(VkDevice device, VkImage image, VkFormat format, uint32 mipLevels, VkImageAspectFlags aspectFlags, uint32 layerIndex, uint32 layerCount, VkImageView& outImageView, utility::ErrorState& errorState);
72 
76  bool NAPAPI createCubeImageView(VkDevice device, VkImage image, VkFormat format, uint32 mipLevels, VkImageAspectFlags aspectFlags, uint32 layerCount, VkImageView& outImageView, utility::ErrorState& errorState);
77 
81  void NAPAPI destroyImageAndView(ImageData& data, VkDevice device, VmaAllocator allocator);
82 
86  bool NAPAPI createBuffer(VmaAllocator allocator, uint32 size, VkBufferUsageFlags bufferUsage, VmaMemoryUsage memoryUsage, VmaAllocationCreateFlags allocationFlags, BufferData& outBuffer, utility::ErrorState& error);
87 
91  void NAPAPI destroyBuffer(VmaAllocator allocator, BufferData& buffer);
92 
96  bool NAPAPI uploadToBuffer(VmaAllocator allocator, uint32 size, const void* data, BufferData& buffer);
97  }
98 }
nap::utility::createLayered2DImageView
bool NAPAPI createLayered2DImageView(VkDevice device, VkImage image, VkFormat format, uint32 mipLevels, VkImageAspectFlags aspectFlags, uint32 layerIndex, uint32 layerCount, VkImageView &outImageView, utility::ErrorState &errorState)
nap::ERasterizationSamples::Four
@ Four
nap::ERasterizationSamples::One
@ One
nap::ERasterizationSamples::Two
@ Two
nap::ERasterizationSamples
ERasterizationSamples
Definition: renderutils.h:25
nap::utility::createDepthOnlyRenderPass
bool NAPAPI createDepthOnlyRenderPass(VkDevice device, VkFormat depthFormat, VkRenderPass &renderPass, utility::ErrorState &errorState)
nap::uint32
uint32_t uint32
Definition: numeric.h:20
nap::utility::destroyImageAndView
void NAPAPI destroyImageAndView(ImageData &data, VkDevice device, VmaAllocator allocator)
nap::utility::createLayered2DImage
bool NAPAPI createLayered2DImage(VmaAllocator allocator, uint32 width, uint32 height, VkFormat format, uint32 mipLevels, uint32 layerCount, VkSampleCountFlagBits samples, VkImageTiling tiling, VkImageUsageFlags imageUsage, VmaMemoryUsage memoryUsage, VkImageCreateFlags flags, VkImage &outImage, VmaAllocation &outAllocation, VmaAllocationInfo &outAllocationInfo, utility::ErrorState &errorState)
nap::ERasterizationSamples::Eight
@ Eight
nap::utility::create2DImageView
bool NAPAPI create2DImageView(VkDevice device, VkImage image, VkFormat format, uint32 mipLevels, VkImageAspectFlags aspectFlags, VkImageView &outImageView, utility::ErrorState &errorState)
nap::utility::createCubeImageView
bool NAPAPI createCubeImageView(VkDevice device, VkImage image, VkFormat format, uint32 mipLevels, VkImageAspectFlags aspectFlags, uint32 layerCount, VkImageView &outImageView, utility::ErrorState &errorState)
nap
Definition: templateapp.h:17
nap::ERasterizationSamples::Sixteen
@ Sixteen
nap::utility::create2DImage
bool NAPAPI create2DImage(VmaAllocator allocator, uint32 width, uint32 height, VkFormat format, uint32 mipLevels, VkSampleCountFlagBits samples, VkImageTiling tiling, VkImageUsageFlags imageUsage, VmaMemoryUsage memoryUsage, VkImage &outImage, VmaAllocation &outAllocation, VmaAllocationInfo &outAllocationInfo, utility::ErrorState &errorState)
nap::utility::destroyBuffer
void NAPAPI destroyBuffer(VmaAllocator allocator, BufferData &buffer)
nap::utility::uploadToBuffer
bool NAPAPI uploadToBuffer(VmaAllocator allocator, uint32 size, const void *data, BufferData &buffer)
nap::ERasterizationSamples::Max
@ Max
Request max available number of rasterization samples.
nap::utility::createBuffer
bool NAPAPI createBuffer(VmaAllocator allocator, uint32 size, VkBufferUsageFlags bufferUsage, VmaMemoryUsage memoryUsage, VmaAllocationCreateFlags allocationFlags, BufferData &outBuffer, utility::ErrorState &error)
nap::utility::createRenderPass
bool NAPAPI createRenderPass(VkDevice device, VkFormat colorFormat, VkFormat depthFormat, VkSampleCountFlagBits samples, VkImageLayout targetLayout, bool consumeDepth, VkRenderPass &renderPass, utility::ErrorState &errorState)