15#ifndef GPUDISPLAYBACKENDVULKAN_H
16#define GPUDISPLAYBACKENDVULKAN_H
19#include <vulkan/vulkan.hpp>
22#include <unordered_map>
40 std::vector<vk::SurfaceFormatKHR>
formats;
58 std::unique_ptr<char[]>
data;
75 bool prepareDraw(
const hmm_mat4& proj,
const hmm_mat4& view,
bool requestScreenshot,
bool toMixBuffer,
float includeMixImage)
override;
76 void finishDraw(
bool doScreenshot,
bool toMixBuffer,
float includeMixImage)
override;
77 void finishFrame(
bool doScreenshot,
bool toMixBuffer,
float includeMixImage)
override;
80 void mixImages(vk::CommandBuffer cmdBuffer,
float mixSlaveImage);
81 void cmdPushDescriptors(vk::CommandBuffer commandBuffer, vk::PipelineLayout layout,
const VulkanBuffer& ubo, vk::ImageView textureView = {});
92 using FeatureChain = vk::StructureChain<vk::PhysicalDeviceFeatures2, vk::PhysicalDeviceVulkan11Features, vk::PhysicalDeviceVulkan12Features, vk::PhysicalDeviceVulkan13Features, vk::PhysicalDeviceVulkan14Features, vk::PhysicalDeviceSwapchainMaintenance1FeaturesKHR, vk::PhysicalDevicePresentIdFeaturesKHR, vk::PhysicalDevicePresentWaitFeaturesKHR>;
93 double checkDevice(vk::PhysicalDevice device,
const std::vector<const char*>& reqDeviceExtensions,
const FeatureChain& reqDeviceFeatures,
bool silent =
false);
94 vk::Extent2D
chooseSwapExtent(
const vk::SurfaceCapabilitiesKHR& capabilities);
96 VulkanBuffer createBuffer(
size_t size,
const void* srcData =
nullptr, vk::BufferUsageFlags
type = vk::BufferUsageFlagBits::eVertexBuffer, int32_t deviceMemory = 1);
99 VulkanImage createImage(uint32_t sizex, uint32_t sizey,
const void* srcData =
nullptr,
size_t srcSize = 0, vk::Format
format = vk::Format::eR8G8B8A8Srgb);
104 void startFillCommandBuffer(vk::CommandBuffer& commandBuffer, uint32_t imageIndex,
bool toMixBuffer =
false);
108 template <
class... Args>
109 uint64_t
queueSubmit(uint64_t* timelineSignalValue, Args&&... args);
136 void addFontSymbol(int32_t symbol, int32_t sizex, int32_t sizey, int32_t offsetx, int32_t offsety, int32_t advance,
void*
data)
override;
139 void OpenGLPrint(
const char* s,
float x,
float y,
float*
color,
float scale)
override;
166 std::unordered_map<std::string, vk::ShaderModuleCreateInfo>
mShaders;
void OpenGLPrint(const char *s, float x, float y, float *color, float scale) override
vk::CommandBuffer getSingleTimeCommandBuffer()
std::vector< vk::CommandBuffer > mCommandBuffersMix
std::vector< vk::CommandBuffer > mCommandBuffers
std::vector< vk::Semaphore > mPresentSemaphore
vk::DescriptorSetLayout mUniformDescriptor
VulkanBuffer mIndirectCommandBuffer
std::vector< vk::Image > mRenderTargetImage
bool canLimitToVSync() const override
std::vector< vk::Pipeline > mPipelines
vk::CommandBuffer mCurrentCommandBuffer
void createCommandBuffers()
void resizeScene(uint32_t width, uint32_t height) override
bool mFifoLatestReadySupported
int32_t mCurrentCommandBufferLastPipeline
uint32_t DepthBits() override
void submitSingleTimeCommandBuffer(vk::CommandBuffer commandBuffer)
uint8_t mSwapChainSuboptimal
std::vector< VulkanImage > mDownsampleImages
void clearUniformLayoutsAndBuffers()
float getYFactor() const override
void writeToBuffer(VulkanBuffer &buffer, size_t size, const void *srcData)
std::vector< vk::ImageView > mSwapChainImageViews
std::vector< vk::CommandBufferSubmitInfo > mFrameCommandBuffers
std::vector< VulkanImage > mMSAAImages
void pointSizeFactor(float factor) override
uint32_t mUpdateUBOmixMatrix
std::vector< FontSymbolVulkan > mFontSymbols
vk::SwapchainKHR mSwapChain
int32_t InitBackendA() override
void clearImage(VulkanImage &image)
std::vector< vk::ImageView * > mRenderTargetView
vk::PipelineCache mPipelineCache
void finishText() override
bool prepareDraw(const hmm_mat4 &proj, const hmm_mat4 &view, bool requestScreenshot, bool toMixBuffer, float includeMixImage) override
void addFontSymbol(int32_t symbol, int32_t sizex, int32_t sizey, int32_t offsetx, int32_t offsety, int32_t advance, void *data) override
bool backendNeedRedraw() override
vk::SampleCountFlagBits mMSAASampleCount
void mixImages(vk::CommandBuffer cmdBuffer, float mixSlaveImage)
void clearVertexBuffers()
bool mSmoothLinesSupported
void createTextureSampler()
void recreateRendering(bool forScreenshot=false, bool forMixing=false)
std::vector< VulkanBuffer > mFontVertexBuffer
double checkDevice(vk::PhysicalDevice device, const std::vector< const char * > &reqDeviceExtensions, const FeatureChain &reqDeviceFeatures, bool silent=false)
void endFillCommandBuffer(vk::CommandBuffer &commandBuffer)
std::vector< uint64_t > mImageTimelineValue
uint32_t drawVertices(const vboList &v, const drawType t) override
vk::SurfaceFormatKHR mSurfaceFormat
std::vector< vk::CommandBuffer > mCommandBuffersPresent
std::vector< vk::CommandBuffer > mCommandBuffersDownsample
void ActivateColor(std::array< float, 4 > &color) override
std::vector< vk::Image > mSwapChainImages
uint32_t mUpdateUBOdrawMatrix
uint32_t mUpdateUBOtextMatrix
uint64_t queueSubmit(uint64_t *timelineSignalValue, Args &&... args)
void initializeTextDrawing() override
void clearBuffer(VulkanBuffer &buffer)
VulkanBuffer mMixingTextureVertexArray
vk::Sampler mTextureSampler
vk::Semaphore mTimelineSemaphore
uint32_t mCurrentImageIndex
void createUniformLayoutsAndBuffers()
void needRecordCommandBuffers()
std::vector< VulkanBuffer > mUniformBuffersMat[3]
bool mCommandInfrastructureCreated
void updateSwapChainDetails(const vk::PhysicalDevice &device)
void handleSwapChainResult(vk::Result retVal, uint8_t suboptimalBit)
std::vector< VulkanImage > mMixImages
std::vector< uint64_t > mFrameTimelineValue
vk::CommandPool mCommandPool
vk::StructureChain< vk::PhysicalDeviceFeatures2, vk::PhysicalDeviceVulkan11Features, vk::PhysicalDeviceVulkan12Features, vk::PhysicalDeviceVulkan13Features, vk::PhysicalDeviceVulkan14Features, vk::PhysicalDeviceSwapchainMaintenance1FeaturesKHR, vk::PhysicalDevicePresentIdFeaturesKHR, vk::PhysicalDevicePresentWaitFeaturesKHR > FeatureChain
void finishDraw(bool doScreenshot, bool toMixBuffer, float includeMixImage) override
void writeToImage(VulkanImage &image, const void *srcData, size_t srcSize)
vecpod< float > mFontVertexBufferHost
vk::PresentModeKHR chooseSwapPresentMode()
vk::PipelineLayout mPipelineLayout
void clearOffscreenBuffers()
std::unordered_map< std::string, vk::ShaderModuleCreateInfo > mShaders
vk::DescriptorSetLayout mUniformDescriptorTexture
void setDepthBuffer() override
void downsampleToFramebuffer(vk::CommandBuffer &commandBuffer)
void createSwapChain(vk::SwapchainKHR oldSwapChain={})
void ExitBackendA() override
vk::Extent2D chooseSwapExtent(const vk::SurfaceCapabilitiesKHR &capabilities)
~GPUDisplayBackendVulkan() override
bool mPresentModeErrorShown
int32_t getMaxMSAA() const override
VulkanImage createImage(uint32_t sizex, uint32_t sizey, const void *srcData=nullptr, size_t srcSize=0, vk::Format format=vk::Format::eR8G8B8A8Srgb)
std::vector< TextDrawCommand > mTextDrawCommands
void clearTextureSampler()
vk::PipelineLayout mPipelineLayoutTexture
bool useSmoothLineShader() const
SwapChainSupportDetails mSwapChainDetails
uint32_t mMaxMSAAsupported
void cmdPushDescriptors(vk::CommandBuffer commandBuffer, vk::PipelineLayout layout, const VulkanBuffer &ubo, vk::ImageView textureView={})
void finishFrame(bool doScreenshot, bool toMixBuffer, float includeMixImage) override
bool mPresentModeForVSyncLimit
void clearSwapChain(bool keepSwapChain=false)
std::vector< vk::Semaphore > mImageAvailableSemaphore
void startFillCommandBuffer(vk::CommandBuffer &commandBuffer, uint32_t imageIndex, bool toMixBuffer=false)
void waitTimeline(uint64_t value)
std::vector< vk::CommandBuffer > mCommandBuffersTexture
vk::PhysicalDevice mPhysicalDevice
void SetVSync(bool enable) override
vk::DebugUtilsMessengerEXT mDebugMessenger
GPUDisplayBackendVulkan()
void clearFontSymbols() override
std::vector< vk::Fence > mPresentFences
void cmdDownsample(vk::CommandBuffer commandBuffer, vk::ImageView src, vk::ImageView dst, uint32_t width, uint32_t height, int32_t factor)
VulkanBuffer createBuffer(size_t size, const void *srcData=nullptr, vk::BufferUsageFlags type=vk::BufferUsageFlagBits::eVertexBuffer, int32_t deviceMemory=1)
std::vector< VulkanImage > mZImages
void createOffscreenBuffers(bool forScreenshot=false, bool forMixing=false)
bool mEnableValidationLayers
std::vector< bool > mCommandBufferUpToDate
void lineWidthFactor(float factor) override
void prepareText() override
void clearCommandBuffers()
void readImageToPixels(vk::Image image, vk::ImageView view, vk::ImageLayout layout, std::vector< char > &pixels)
std::vector< vk::CommandBuffer > mCommandBuffersText
bool mMustUpdateSwapChain
vk::PresentModeKHR mPresentMode
bool useNativeSmoothLines() const
void loadDataToGPU(size_t totalVertizes) override
std::tuple< uint32_t, uint32_t, int32_t > vboList
GLint GLsizei GLsizei height
GLsizei const GLfloat * value
GLint GLint GLsizei GLint GLenum GLenum type
GLint GLint GLsizei GLint GLenum GLenum const void * pixels
GLint GLint GLsizei GLint GLenum format
std::unique_ptr< char[]> data
std::vector< vk::SurfaceFormatKHR > formats
vk::SurfaceCapabilitiesKHR capabilities
std::vector< vk::PresentModeKHR > presentModes
typename std::vector< T, vecpod_allocator< T > > vecpod