Trying to fix weird sync issue
This commit is contained in:
@@ -8,8 +8,6 @@ namespace Component
|
|||||||
struct Mesh
|
struct Mesh
|
||||||
{
|
{
|
||||||
PMeshAsset asset;
|
PMeshAsset asset;
|
||||||
Mesh() {}
|
|
||||||
Mesh(PMeshAsset asset) : asset(asset) {}
|
|
||||||
};
|
};
|
||||||
} // namespace Component
|
} // namespace Component
|
||||||
} // namespace Seele
|
} // namespace Seele
|
||||||
|
|||||||
@@ -72,8 +72,8 @@ void BasePass::render()
|
|||||||
Gfx::SE_ACCESS_SHADER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
|
Gfx::SE_ACCESS_SHADER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
|
||||||
Gfx::SE_ACCESS_SHADER_READ_BIT, Gfx::SE_PIPELINE_STAGE_FRAGMENT_SHADER_BIT);
|
Gfx::SE_ACCESS_SHADER_READ_BIT, Gfx::SE_PIPELINE_STAGE_FRAGMENT_SHADER_BIT);
|
||||||
depthAttachment->getTexture()->pipelineBarrier(
|
depthAttachment->getTexture()->pipelineBarrier(
|
||||||
Gfx::SE_ACCESS_SHADER_READ_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
|
Gfx::SE_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
|
||||||
Gfx::SE_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT);
|
Gfx::SE_ACCESS_MEMORY_READ_BIT, Gfx::SE_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT);
|
||||||
depthAttachment->getTexture()->transferOwnership(Gfx::QueueType::GRAPHICS);
|
depthAttachment->getTexture()->transferOwnership(Gfx::QueueType::GRAPHICS);
|
||||||
depthAttachment->getTexture()->changeLayout(Gfx::SE_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL);
|
depthAttachment->getTexture()->changeLayout(Gfx::SE_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL);
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,8 @@
|
|||||||
#include "Math/Vector.h"
|
#include "Math/Vector.h"
|
||||||
#include "RenderGraph.h"
|
#include "RenderGraph.h"
|
||||||
#include "Graphics/Command.h"
|
#include "Graphics/Command.h"
|
||||||
|
#include <vulkan/vulkan.h>
|
||||||
|
#include "Graphics/Vulkan/Graphics.h"
|
||||||
|
|
||||||
using namespace Seele;
|
using namespace Seele;
|
||||||
|
|
||||||
@@ -130,6 +132,7 @@ void DepthPrepass::render()
|
|||||||
}
|
}
|
||||||
graphics->executeCommands(commands);
|
graphics->executeCommands(commands);
|
||||||
graphics->endRenderPass();
|
graphics->endRenderPass();
|
||||||
|
//vkDeviceWaitIdle(((Vulkan::Graphics*)graphics.getHandle())->getDevice());
|
||||||
}
|
}
|
||||||
|
|
||||||
void DepthPrepass::endFrame()
|
void DepthPrepass::endFrame()
|
||||||
|
|||||||
@@ -34,6 +34,10 @@ void SkyboxRenderPass::beginFrame(const Component::Camera& cam)
|
|||||||
skyboxDataSet = skyboxDataLayout->allocateDescriptorSet();
|
skyboxDataSet = skyboxDataLayout->allocateDescriptorSet();
|
||||||
skyboxDataSet->updateBuffer(0, skyboxBuffer);
|
skyboxDataSet->updateBuffer(0, skyboxBuffer);
|
||||||
skyboxDataSet->writeChanges();
|
skyboxDataSet->writeChanges();
|
||||||
|
skyboxBuffer->pipelineBarrier(
|
||||||
|
Gfx::SE_ACCESS_TRANSFER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_TRANSFER_BIT,
|
||||||
|
Gfx::SE_ACCESS_MEMORY_READ_BIT, Gfx::SE_PIPELINE_STAGE_VERTEX_SHADER_BIT
|
||||||
|
);
|
||||||
textureSet = textureLayout->allocateDescriptorSet();
|
textureSet = textureLayout->allocateDescriptorSet();
|
||||||
textureSet->updateTexture(0, skybox.day);
|
textureSet->updateTexture(0, skybox.day);
|
||||||
textureSet->updateTexture(1, skybox.night);
|
textureSet->updateTexture(1, skybox.night);
|
||||||
@@ -43,6 +47,14 @@ void SkyboxRenderPass::beginFrame(const Component::Camera& cam)
|
|||||||
|
|
||||||
void SkyboxRenderPass::render()
|
void SkyboxRenderPass::render()
|
||||||
{
|
{
|
||||||
|
colorAttachment->getTexture()->pipelineBarrier(
|
||||||
|
Gfx::SE_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
|
||||||
|
Gfx::SE_ACCESS_COLOR_ATTACHMENT_READ_BIT, Gfx::SE_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT
|
||||||
|
);
|
||||||
|
depthAttachment->getTexture()->pipelineBarrier(
|
||||||
|
Gfx::SE_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
|
||||||
|
Gfx::SE_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT, Gfx::SE_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT
|
||||||
|
);
|
||||||
graphics->beginRenderPass(renderPass);
|
graphics->beginRenderPass(renderPass);
|
||||||
Gfx::PRenderCommand renderCommand = graphics->createRenderCommand("SkyboxRender");
|
Gfx::PRenderCommand renderCommand = graphics->createRenderCommand("SkyboxRender");
|
||||||
renderCommand->setViewport(viewport);
|
renderCommand->setViewport(viewport);
|
||||||
@@ -74,12 +86,12 @@ void SkyboxRenderPass::publishOutputs()
|
|||||||
|
|
||||||
void SkyboxRenderPass::createRenderPass()
|
void SkyboxRenderPass::createRenderPass()
|
||||||
{
|
{
|
||||||
baseColorAttachment = resources->requestRenderTarget("BASEPASS_COLOR");
|
colorAttachment = resources->requestRenderTarget("BASEPASS_COLOR");
|
||||||
baseColorAttachment->loadOp = Gfx::SE_ATTACHMENT_LOAD_OP_LOAD;
|
colorAttachment->loadOp = Gfx::SE_ATTACHMENT_LOAD_OP_LOAD;
|
||||||
Gfx::PRenderTargetAttachment depthAttachment = resources->requestRenderTarget("DEPTHPREPASS_DEPTH");
|
depthAttachment = resources->requestRenderTarget("DEPTHPREPASS_DEPTH");
|
||||||
depthAttachment->loadOp = Gfx::SE_ATTACHMENT_LOAD_OP_LOAD;
|
depthAttachment->loadOp = Gfx::SE_ATTACHMENT_LOAD_OP_LOAD;
|
||||||
Gfx::ORenderTargetLayout layout = new Gfx::RenderTargetLayout{
|
Gfx::ORenderTargetLayout layout = new Gfx::RenderTargetLayout{
|
||||||
.colorAttachments = { baseColorAttachment },
|
.colorAttachments = { colorAttachment },
|
||||||
.depthAttachment = depthAttachment
|
.depthAttachment = depthAttachment
|
||||||
};
|
};
|
||||||
renderPass = graphics->createRenderPass(std::move(layout), viewport);
|
renderPass = graphics->createRenderPass(std::move(layout), viewport);
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ public:
|
|||||||
virtual void publishOutputs() override;
|
virtual void publishOutputs() override;
|
||||||
virtual void createRenderPass() override;
|
virtual void createRenderPass() override;
|
||||||
private:
|
private:
|
||||||
Gfx::PRenderTargetAttachment baseColorAttachment;
|
Gfx::PRenderTargetAttachment colorAttachment;
|
||||||
Gfx::OVertexBuffer cubeBuffer;
|
Gfx::PRenderTargetAttachment depthAttachment;
|
||||||
Gfx::ODescriptorLayout skyboxDataLayout;
|
Gfx::ODescriptorLayout skyboxDataLayout;
|
||||||
Gfx::PDescriptorSet skyboxDataSet;
|
Gfx::PDescriptorSet skyboxDataSet;
|
||||||
Gfx::ODescriptorLayout textureLayout;
|
Gfx::ODescriptorLayout textureLayout;
|
||||||
|
|||||||
@@ -459,7 +459,7 @@ CommandPool::CommandPool(PGraphics graphics, PQueue queue)
|
|||||||
.queueFamilyIndex = queue->getFamilyIndex(),
|
.queueFamilyIndex = queue->getFamilyIndex(),
|
||||||
};
|
};
|
||||||
VK_CHECK(vkCreateCommandPool(graphics->getDevice(), &info, nullptr, &commandPool));
|
VK_CHECK(vkCreateCommandPool(graphics->getDevice(), &info, nullptr, &commandPool));
|
||||||
|
// TODO: dont reset individual commands, reset pool instead
|
||||||
allocatedBuffers.add(new Command(graphics, commandPool, this));
|
allocatedBuffers.add(new Command(graphics, commandPool, this));
|
||||||
|
|
||||||
command = allocatedBuffers.back();
|
command = allocatedBuffers.back();
|
||||||
|
|||||||
@@ -3,15 +3,19 @@
|
|||||||
|
|
||||||
using namespace Seele::Vulkan;
|
using namespace Seele::Vulkan;
|
||||||
|
|
||||||
VkBool32 Seele::Vulkan::debugCallback(VkDebugReportFlagsEXT, VkDebugReportObjectTypeEXT, uint64_t, size_t, int32_t, const char *layerPrefix, const char *msg, void *)
|
VkBool32 Seele::Vulkan::debugCallback(
|
||||||
|
VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity,
|
||||||
|
VkDebugUtilsMessageTypeFlagsEXT messageTypes,
|
||||||
|
const VkDebugUtilsMessengerCallbackDataEXT* pCallbackData,
|
||||||
|
void* pUserData)
|
||||||
{
|
{
|
||||||
std::cerr << layerPrefix << ": " << msg << std::endl;
|
std::cerr << pCallbackData->pMessage << std::endl;
|
||||||
return VK_FALSE;
|
return VK_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
VkResult Seele::Vulkan::CreateDebugReportCallbackEXT(VkInstance instance, const VkDebugReportCallbackCreateInfoEXT *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkDebugReportCallbackEXT *pCallback)
|
VkResult Seele::Vulkan::CreateDebugUtilsMessengerEXT(VkInstance instance, const VkDebugUtilsMessengerCreateInfoEXT *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkDebugUtilsMessengerEXT *pCallback)
|
||||||
{
|
{
|
||||||
auto func = (PFN_vkCreateDebugReportCallbackEXT)vkGetInstanceProcAddr(instance, "vkCreateDebugReportCallbackEXT");
|
auto func = (PFN_vkCreateDebugUtilsMessengerEXT)vkGetInstanceProcAddr(instance, "vkCreateDebugUtilsMessengerEXT");
|
||||||
if (func != nullptr)
|
if (func != nullptr)
|
||||||
{
|
{
|
||||||
return func(instance, pCreateInfo, pAllocator, pCallback);
|
return func(instance, pCreateInfo, pAllocator, pCallback);
|
||||||
@@ -22,9 +26,9 @@ VkResult Seele::Vulkan::CreateDebugReportCallbackEXT(VkInstance instance, const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Seele::Vulkan::DestroyDebugReportCallbackEXT(VkInstance instance, const VkAllocationCallbacks *pAllocator, VkDebugReportCallbackEXT pCallback)
|
void Seele::Vulkan::DestroyDebugUtilsMessengerEXT(VkInstance instance, const VkAllocationCallbacks *pAllocator, VkDebugUtilsMessengerEXT pCallback)
|
||||||
{
|
{
|
||||||
auto func = (PFN_vkDestroyDebugReportCallbackEXT)vkGetInstanceProcAddr(instance, "vkDestroyDebugReportCallbackEXT");
|
auto func = (PFN_vkDestroyDebugUtilsMessengerEXT)vkGetInstanceProcAddr(instance, "vkDestroyDebugUtilsMessengerEXT");
|
||||||
if (func != nullptr)
|
if (func != nullptr)
|
||||||
{
|
{
|
||||||
func(instance, pCallback, pAllocator);
|
func(instance, pCallback, pAllocator);
|
||||||
|
|||||||
@@ -6,9 +6,13 @@ namespace Seele
|
|||||||
{
|
{
|
||||||
namespace Vulkan
|
namespace Vulkan
|
||||||
{
|
{
|
||||||
VkBool32 debugCallback(VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT objType, uint64_t obj, size_t location, int32_t code, const char *layerPrefix, const char *msg, void *userData);
|
VkBool32 debugCallback(
|
||||||
|
VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity,
|
||||||
|
VkDebugUtilsMessageTypeFlagsEXT messageTypes,
|
||||||
|
const VkDebugUtilsMessengerCallbackDataEXT* pCallbackData,
|
||||||
|
void* pUserData);
|
||||||
|
|
||||||
VkResult CreateDebugReportCallbackEXT(VkInstance instance, const VkDebugReportCallbackCreateInfoEXT *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkDebugReportCallbackEXT *pCallback);
|
VkResult CreateDebugUtilsMessengerEXT(VkInstance instance, const VkDebugUtilsMessengerCreateInfoEXT *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkDebugUtilsMessengerEXT *pCallback);
|
||||||
void DestroyDebugReportCallbackEXT(VkInstance instance, const VkAllocationCallbacks *pAllocator, VkDebugReportCallbackEXT pCallback);
|
void DestroyDebugUtilsMessengerEXT(VkInstance instance, const VkAllocationCallbacks *pAllocator, VkDebugUtilsMessengerEXT pCallback);
|
||||||
} // namespace Vulkan
|
} // namespace Vulkan
|
||||||
} // namespace Seele
|
} // namespace Seele
|
||||||
@@ -42,7 +42,7 @@ Graphics::~Graphics()
|
|||||||
shaderCompiler = nullptr;
|
shaderCompiler = nullptr;
|
||||||
pools.clear();
|
pools.clear();
|
||||||
vkDestroyDevice(handle, nullptr);
|
vkDestroyDevice(handle, nullptr);
|
||||||
DestroyDebugReportCallbackEXT(instance, nullptr, callback);
|
DestroyDebugUtilsMessengerEXT(instance, nullptr, callback);
|
||||||
vkDestroyInstance(instance, nullptr);
|
vkDestroyInstance(instance, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -367,7 +367,7 @@ Array<const char *> Graphics::getRequiredExtensions()
|
|||||||
extensions.add(glfwExtensions[i]);
|
extensions.add(glfwExtensions[i]);
|
||||||
}
|
}
|
||||||
#if ENABLE_VALIDATION
|
#if ENABLE_VALIDATION
|
||||||
extensions.add(VK_EXT_DEBUG_REPORT_EXTENSION_NAME);
|
extensions.add(VK_EXT_DEBUG_UTILS_EXTENSION_NAME);
|
||||||
#endif // ENABLE_VALIDATION
|
#endif // ENABLE_VALIDATION
|
||||||
return extensions;
|
return extensions;
|
||||||
}
|
}
|
||||||
@@ -381,7 +381,7 @@ void Graphics::initInstance(GraphicsInitializer initInfo)
|
|||||||
.applicationVersion = VK_MAKE_VERSION(0, 0, 1),
|
.applicationVersion = VK_MAKE_VERSION(0, 0, 1),
|
||||||
.pEngineName = initInfo.engineName,
|
.pEngineName = initInfo.engineName,
|
||||||
.engineVersion = VK_MAKE_VERSION(0, 0, 1),
|
.engineVersion = VK_MAKE_VERSION(0, 0, 1),
|
||||||
.apiVersion = VK_API_VERSION_1_3,
|
.apiVersion = VK_API_VERSION_1_2,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -411,15 +411,16 @@ void Graphics::initInstance(GraphicsInitializer initInfo)
|
|||||||
}
|
}
|
||||||
void Graphics::setupDebugCallback()
|
void Graphics::setupDebugCallback()
|
||||||
{
|
{
|
||||||
VkDebugReportCallbackCreateInfoEXT createInfo = {
|
VkDebugUtilsMessengerCreateInfoEXT createInfo = {
|
||||||
.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT,
|
.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT,
|
||||||
.pNext = nullptr,
|
.pNext = nullptr,
|
||||||
.flags = VK_DEBUG_REPORT_ERROR_BIT_EXT | VK_DEBUG_REPORT_WARNING_BIT_EXT,
|
.flags = 0,
|
||||||
.pfnCallback = &debugCallback,
|
.messageSeverity = VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT,
|
||||||
|
.messageType = VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT,
|
||||||
|
.pfnUserCallback = &debugCallback,
|
||||||
.pUserData = nullptr,
|
.pUserData = nullptr,
|
||||||
};
|
};
|
||||||
|
VK_CHECK(CreateDebugUtilsMessengerEXT(instance, &createInfo, nullptr, &callback));
|
||||||
VK_CHECK(CreateDebugReportCallbackEXT(instance, &createInfo, nullptr, &callback));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Graphics::pickPhysicalDevice()
|
void Graphics::pickPhysicalDevice()
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ protected:
|
|||||||
VkPhysicalDeviceFeatures2 features;
|
VkPhysicalDeviceFeatures2 features;
|
||||||
VkPhysicalDeviceVulkan11Features features11;
|
VkPhysicalDeviceVulkan11Features features11;
|
||||||
VkPhysicalDeviceVulkan12Features features12;
|
VkPhysicalDeviceVulkan12Features features12;
|
||||||
VkDebugReportCallbackEXT callback;
|
VkDebugUtilsMessengerEXT callback;
|
||||||
Map<uint32, OFramebuffer> allocatedFramebuffers;
|
Map<uint32, OFramebuffer> allocatedFramebuffers;
|
||||||
VmaAllocator allocator;
|
VmaAllocator allocator;
|
||||||
OPipelineCache pipelineCache;
|
OPipelineCache pipelineCache;
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
Map<uint32, OGraphicsPipeline> graphicsPipelines;
|
Map<uint32, OGraphicsPipeline> graphicsPipelines;
|
||||||
Map<uint32, OComputePipeline> computePipelines;
|
Map<uint32, OComputePipeline> computePipelines;
|
||||||
|
std::mutex cacheLock;
|
||||||
VkPipelineCache cache;
|
VkPipelineCache cache;
|
||||||
PGraphics graphics;
|
PGraphics graphics;
|
||||||
std::string cacheFile;
|
std::string cacheFile;
|
||||||
|
|||||||
@@ -111,8 +111,8 @@ void Window::beginFrame()
|
|||||||
imageAvailableFences[currentSemaphoreIndex]->wait(100000);
|
imageAvailableFences[currentSemaphoreIndex]->wait(100000);
|
||||||
imageAvailableFences[currentSemaphoreIndex]->reset();
|
imageAvailableFences[currentSemaphoreIndex]->reset();
|
||||||
vkAcquireNextImageKHR(graphics->getDevice(), swapchain, std::numeric_limits<uint64>::max(), imageAvailableSemaphores[currentSemaphoreIndex]->getHandle(), imageAvailableFences[currentSemaphoreIndex]->getHandle(), ¤tImageIndex);
|
vkAcquireNextImageKHR(graphics->getDevice(), swapchain, std::numeric_limits<uint64>::max(), imageAvailableSemaphores[currentSemaphoreIndex]->getHandle(), imageAvailableFences[currentSemaphoreIndex]->getHandle(), ¤tImageIndex);
|
||||||
swapChainTextures[currentImageIndex]->changeLayout(Gfx::SE_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL);
|
|
||||||
graphics->getGraphicsCommands()->getCommands()->waitForSemaphore(VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, imageAvailableSemaphores[currentSemaphoreIndex]);
|
graphics->getGraphicsCommands()->getCommands()->waitForSemaphore(VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, imageAvailableSemaphores[currentSemaphoreIndex]);
|
||||||
|
swapChainTextures[currentImageIndex]->changeLayout(Gfx::SE_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window::endFrame()
|
void Window::endFrame()
|
||||||
|
|||||||
Reference in New Issue
Block a user