4#include "graphics/GPUObjects.hpp"
5#include "graphics/DescriptorAllocator.hpp"
6#include "graphics/QueryAllocator.hpp"
7#include "graphics/PipelineCache.hpp"
8#include "graphics/SamplerLibrary.hpp"
9#include "resources/Buffer.hpp"
25 #define VK_RETURN_CHECK(F, L) do {\
27 if(res != VK_SUCCESS){\
28 Log::Error() << Log::GPU << "Vulkan return error at line " << L << std::endl;\
29 VkUtils::checkResult(res);\
34#define VK_RETURN_CHECK(F, L) (F);
38#define VK_RET(F) VK_RETURN_CHECK((F), __LINE__)
47 VkImageView
view = VK_NULL_HANDLE;
51 VmaAllocation
data = VK_NULL_HANDLE;
137VKAPI_ATTR VkBool32 VKAPI_CALL
vkDebugCallback(VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity, VkDebugUtilsMessageTypeFlagsEXT messageType,
const VkDebugUtilsMessengerCallbackDataEXT* callbackData,
void* userData);
169 bool checkDeviceExtensionsSupport(VkPhysicalDevice device,
const std::vector<const char*> & requestedExtensions,
bool & hasPortability);
178 bool getQueueFamilies(VkPhysicalDevice device, VkSurfaceKHR surface,
int & graphicsFamily,
int & presentFamily);
193 Layout findSupportedFormat(
const VkPhysicalDevice & physicalDevice,
const std::vector<VkFormat>& candidates, VkImageTiling tiling, VkFormatFeatureFlags features);
223 void imageLayoutBarrier(VkCommandBuffer& commandBuffer,
GPUTexture& texture, VkImageLayout newLayout, uint mipStart, uint mipCount, uint layerStart, uint layerCount);
231 void mipLayoutBarrier(VkCommandBuffer& commandBuffer,
const Texture& texture, VkImageLayout newLayout, uint mip);
262 void getGPUFilters(
Filter filtering, VkFilter & imgFiltering, VkSamplerMipmapMode & mipFiltering);
284 glm::uvec2
copyTextureRegionToBuffer(VkCommandBuffer& commandBuffer,
const Texture & srcTexture, std::shared_ptr<Buffer> & dstBuffer, uint mipStart, uint mipCount, uint layerStart, uint layerCount,
const glm::uvec2& offset,
const glm::uvec2& size);
303 void blitTexture(VkCommandBuffer& commandBuffer,
const Texture& src,
const Texture& dst, uint mipStartSrc, uint mipStartDst, uint mipCount, uint layerStartSrc, uint layerStartDst, uint layerCount,
const glm::uvec2& srcBaseOffset,
const glm::uvec2& srcBaseSize,
const glm::uvec2& dstBaseOffset,
const glm::uvec2& dstBaseSize,
Filter filter);
317STD_HASH(VkImageLayout);
Manage descriptor set allocations by creating and reusing internal descriptor pools.
Definition: DescriptorAllocator.hpp:14
Store a texture data on the GPU.
Definition: GPUObjects.hpp:18
Create and reuse GPU pipelines based on a given state. This supports both graphics and compute pipeli...
Definition: PipelineCache.hpp:18
Manage all samplers for GPU textures. Samplers are shared between all shader programs,...
Definition: SamplerLibrary.hpp:13
Represents a texture containing one or more images, stored on the CPU and/or GPU.
Definition: Texture.hpp:12
VKAPI_ATTR VkBool32 VKAPI_CALL vkDebugCallback(VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity, VkDebugUtilsMessageTypeFlagsEXT messageType, const VkDebugUtilsMessengerCallbackDataEXT *callbackData, void *userData)
Definition: GPUInternal.cpp:136
Filter
The filtering mode of a texture: we deduce the magnification filter from the minification filter for ...
Definition: GPUTypes.hpp:198
TextureShape
The shape of a texture: dimensions, layers organisation.
Definition: GPUTypes.hpp:153
Layout
The layout of a texture: components count and type.
Definition: GPUTypes.hpp:225
Wrap
The wrapping mode of a texture.
Definition: GPUTypes.hpp:213
Utility functions for the Vulkan backend.
Definition: GPUInternal.hpp:142
unsigned int getGPULayout(Layout typedFormat, VkFormat &format)
Definition: GPUInternal.cpp:527
Layout findSupportedFormat(const VkPhysicalDevice &physicalDevice, const std::vector< VkFormat > &candidates, VkImageTiling tiling, VkFormatFeatureFlags features)
Definition: GPUInternal.cpp:226
VkCommandBuffer beginSyncOperations(GPUContext &context)
Definition: GPUInternal.cpp:269
Layout convertFormat(const VkFormat &format)
Definition: GPUInternal.cpp:175
std::vector< const char * > getRequiredInstanceExtensions(bool enableDebugMarkers, bool enablePortability)
Definition: GPUInternal.cpp:52
bool checkExtensionsSupport(const std::vector< const char * > &requestedExtensions)
Definition: GPUInternal.cpp:30
void createCommandBuffers(GPUContext &context, uint count)
Definition: GPUInternal.cpp:419
VkSamplerAddressMode getGPUWrapping(Wrap mode)
Definition: GPUInternal.cpp:502
bool getQueueFamilies(VkPhysicalDevice device, VkSurfaceKHR surface, int &graphicsFamily, int &presentFamily)
Definition: GPUInternal.cpp:101
glm::uvec2 copyTextureRegionToBuffer(VkCommandBuffer &commandBuffer, const Texture &srcTexture, std::shared_ptr< Buffer > &dstBuffer, uint mipStart, uint mipCount, uint layerStart, uint layerCount, const glm::uvec2 &offset, const glm::uvec2 &size)
Definition: GPUInternal.cpp:591
void endSyncOperations(VkCommandBuffer &commandBuffer, GPUContext &context)
Definition: GPUInternal.cpp:290
bool checkDeviceExtensionsSupport(VkPhysicalDevice device, const std::vector< const char * > &requestedExtensions, bool &hasPortability)
Definition: GPUInternal.cpp:68
void setDebugName(GPUContext &context, VkObjectType type, uint64_t handle, const char *format,...)
Definition: GPUInternal.cpp:721
void typesFromShape(const TextureShape &shape, VkImageType &imgType, VkImageViewType &viewType)
Definition: GPUInternal.cpp:243
void mipLayoutBarrier(VkCommandBuffer &commandBuffer, const Texture &texture, VkImageLayout newLayout, uint mip)
Definition: GPUInternal.cpp:405
void textureLayoutBarrier(VkCommandBuffer &commandBuffer, const Texture &texture, VkImageLayout newLayout)
Definition: GPUInternal.cpp:412
void blitTexture(VkCommandBuffer &commandBuffer, const Texture &src, const Texture &dst, uint mipStartSrc, uint mipStartDst, uint mipCount, uint layerStartSrc, uint layerStartDst, uint layerCount, const glm::uvec2 &srcBaseOffset, const glm::uvec2 &srcBaseSize, const glm::uvec2 &dstBaseOffset, const glm::uvec2 &dstBaseSize, Filter filter)
Definition: GPUInternal.cpp:663
void checkResult(VkResult status)
Definition: GPUInternal.cpp:452
void imageLayoutBarrier(VkCommandBuffer &commandBuffer, GPUTexture &texture, VkImageLayout newLayout, uint mipStart, uint mipCount, uint layerStart, uint layerCount)
Definition: GPUInternal.cpp:304
bool checkLayersSupport(const std::vector< const char * > &requestedLayers)
Definition: GPUInternal.cpp:8
void getGPUFilters(Filter filtering, VkFilter &imgFiltering, VkSamplerMipmapMode &mipFiltering)
Definition: GPUInternal.cpp:510
Request for an asynchronous texture download. Data has been copied from the source texture to a buffe...
Definition: GPUInternal.hpp:60
glm::uvec2 dstImageRange
First index and number of images to populate (some mips/layers can be skipped).
Definition: GPUInternal.hpp:64
std::unique_ptr< Texture > dstTexture
Destination texture whose images have to be populated.
Definition: GPUInternal.hpp:62
std::shared_ptr< Buffer > dstBuffer
Transfer buffer containing the texture data (mappable).
Definition: GPUInternal.hpp:61
uint64_t frame
Frame where the download was requested.
Definition: GPUInternal.hpp:65
std::function< void(const Texture &)> callback
Callback to execute once the images creation is complete.
Definition: GPUInternal.hpp:63
Global GPU context, storing all structures used for resource allocation and tracking,...
Definition: GPUInternal.hpp:72
PipelineCache pipelineCache
Pipeline cache and creation.
Definition: GPUInternal.hpp:86
uint32_t swapIndex
Current buffered frame (in 0, frameCount-1).
Definition: GPUInternal.hpp:100
std::deque< AsyncTextureTask > textureTasks
List of async tasks waiting for completion.
Definition: GPUInternal.hpp:90
uint32_t presentId
Present queue index.
Definition: GPUInternal.hpp:97
double timestep
Query timing timestep.
Definition: GPUInternal.hpp:102
VkPipeline graphicsPipeline
Current graphics pipeline.
Definition: GPUInternal.hpp:93
bool hadRenderPass
Has a render pass just ended.
Definition: GPUInternal.hpp:107
std::vector< VkCommandBuffer > uploadCommandBuffers
Per-frame command buffers.
Definition: GPUInternal.hpp:81
VkSurfaceKHR surface
Native surface handle.
Definition: GPUInternal.hpp:78
std::vector< VkCommandBuffer > renderCommandBuffers
Per-frame command buffers.
Definition: GPUInternal.hpp:80
DescriptorAllocator descriptorAllocator
Descriptor sets common allocator.
Definition: GPUInternal.hpp:84
uint32_t graphicsId
Graphics queue index.
Definition: GPUInternal.hpp:96
VkPhysicalDevice physicalDevice
Native physical device handle.
Definition: GPUInternal.hpp:76
bool inRenderPass
Is a rendering pass currently active.
Definition: GPUInternal.hpp:108
bool portability
If the portability extension is present, we have to enable it.
Definition: GPUInternal.hpp:104
VkCommandPool commandPool
Command pool for all frames.
Definition: GPUInternal.hpp:79
std::deque< ResourceToDelete > resourcesToDelete
List of resources waiting for deletion.
Definition: GPUInternal.hpp:89
VkCommandBuffer & getUploadCommandBuffer()
Definition: GPUInternal.hpp:123
uint64_t tasksCount
Number of async tasks created.
Definition: GPUInternal.hpp:91
void nextFrame()
Move to the next frame.
Definition: GPUInternal.hpp:112
bool markersEnabled
Are debug markers and labels enabled.
Definition: GPUInternal.hpp:109
VkDebugUtilsMessengerEXT debugMessenger
Native debug extension handle.
Definition: GPUInternal.hpp:75
VkQueue graphicsQueue
Graphics submission queue.
Definition: GPUInternal.hpp:82
VkQueue presentQueue
Presentation submission queue.
Definition: GPUInternal.hpp:83
SamplerLibrary samplerLibrary
List of static samplers shared by all programs.
Definition: GPUInternal.hpp:87
VkCommandBuffer & getRenderCommandBuffer()
Definition: GPUInternal.hpp:118
VkInstance instance
Native instance handle.
Definition: GPUInternal.hpp:74
uint64_t frameIndex
Current frame index.
Definition: GPUInternal.hpp:99
bool newRenderPass
Has a render pass just started (pipeline needs to be re-bound).
Definition: GPUInternal.hpp:106
std::unordered_map< GPUQuery::Type, QueryAllocator > queryAllocators
Per-type query buffered allocators.
Definition: GPUInternal.hpp:85
VkDevice device
Native logical device handle.
Definition: GPUInternal.hpp:77
size_t uniformAlignment
Minimal buffer alignment.
Definition: GPUInternal.hpp:103
VkPipeline computePipeline
Current compute pipeline.
Definition: GPUInternal.hpp:94
const uint frameCount
Number of buffered frames (should be lower or equal to the swapchain image count).
Definition: GPUInternal.hpp:105
Request for the buffered deletion of a resource. Any of the handles stored below is optional,...
Definition: GPUInternal.hpp:46
VkImageView view
Image view to delete.
Definition: GPUInternal.hpp:47
VkSampler sampler
Sampler to delete.
Definition: GPUInternal.hpp:48
VmaAllocation data
Internal allocation to free.
Definition: GPUInternal.hpp:51
VkImage image
Image to delete.
Definition: GPUInternal.hpp:49
uint64_t frame
Frame where the deletion was requested.
Definition: GPUInternal.hpp:52
VkBuffer buffer
Buffer to delete.
Definition: GPUInternal.hpp:50