Adding some barriers

This commit is contained in:
Dynamitos
2024-01-26 16:26:22 +01:00
parent f1e1ce0541
commit 09790c4cbd
5 changed files with 36 additions and 17 deletions
@@ -124,7 +124,6 @@ void DebugPass::createRenderPass()
gfxInfo.vertexShader = vertexShader;
gfxInfo.fragmentShader = fragmentShader;
gfxInfo.rasterizationState.polygonMode = Gfx::SE_POLYGON_MODE_LINE;
gfxInfo.rasterizationState.lineWidth = 5.f;
gfxInfo.topology = Gfx::SE_PRIMITIVE_TOPOLOGY_LINE_LIST;
gfxInfo.pipelineLayout = std::move(pipelineLayout);
gfxInfo.renderPass = renderPass;
@@ -36,6 +36,11 @@ void RenderPass::beginFrame(const Component::Camera& cam)
.data = (uint8*)&viewParams,
};
viewParamsBuffer->updateContents(uniformUpdate);
viewParamsBuffer->pipelineBarrier(
Gfx::SE_ACCESS_TRANSFER_WRITE_BIT,
Gfx::SE_PIPELINE_STAGE_TRANSFER_BIT,
Gfx::SE_ACCESS_MEMORY_READ_BIT,
Gfx::SE_PIPELINE_STAGE_ALL_COMMANDS_BIT);
viewParamsLayout->reset();
viewParamsSet = viewParamsLayout->allocateDescriptorSet();
viewParamsSet->updateBuffer(0, viewParamsBuffer);
+12
View File
@@ -72,6 +72,12 @@ void VertexData::createDescriptors()
.numElements = instanceData.size(),
.dynamic = false,
});
matInst.instanceBuffer->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
);
matInst.descriptorSet = instanceDataLayout->allocateDescriptorSet();
matInst.meshDataBuffer = graphics->createShaderBuffer(ShaderBufferCreateInfo{
@@ -82,6 +88,12 @@ void VertexData::createDescriptors()
.numElements = meshes.size(),
.dynamic = false,
});
matInst.meshDataBuffer->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
);
matInst.descriptorSet->updateBuffer(0, matInst.instanceBuffer);
matInst.descriptorSet->updateBuffer(1, matInst.meshDataBuffer);
matInst.descriptorSet->updateBuffer(2, meshletBuffer);
+13 -12
View File
@@ -19,10 +19,10 @@
using namespace Seele;
using namespace Seele::Vulkan;
thread_local OCommandPool Seele::Vulkan::Graphics::graphicsCommands = nullptr;
thread_local OCommandPool Seele::Vulkan::Graphics::computeCommands = nullptr;
thread_local OCommandPool Seele::Vulkan::Graphics::transferCommands = nullptr;
thread_local OCommandPool Seele::Vulkan::Graphics::dedicatedTransferCommands = nullptr;
thread_local PCommandPool Seele::Vulkan::Graphics::graphicsCommands = nullptr;
thread_local PCommandPool Seele::Vulkan::Graphics::computeCommands = nullptr;
thread_local PCommandPool Seele::Vulkan::Graphics::transferCommands = nullptr;
thread_local PCommandPool Seele::Vulkan::Graphics::dedicatedTransferCommands = nullptr;
Graphics::Graphics()
: instance(VK_NULL_HANDLE)
@@ -35,15 +35,12 @@ Graphics::Graphics()
Graphics::~Graphics()
{
vkDeviceWaitIdle(handle);
graphicsCommands = nullptr;
computeCommands = nullptr;
transferCommands = nullptr;
dedicatedTransferCommands = nullptr;
pipelineCache = nullptr;
allocator = nullptr;
destructionManager = nullptr;
allocatedFramebuffers.clear();
shaderCompiler = nullptr;
pools.clear();
vkDestroyDevice(handle, nullptr);
DestroyDebugReportCallbackEXT(instance, nullptr, callback);
vkDestroyInstance(instance, nullptr);
@@ -315,7 +312,8 @@ PCommandPool Graphics::getGraphicsCommands()
{
if(graphicsCommands == nullptr)
{
graphicsCommands = new CommandPool(this, graphicsQueue);
std::unique_lock l(poolLock);
graphicsCommands = pools.add(new CommandPool(this, graphicsQueue));
}
return graphicsCommands;
}
@@ -323,7 +321,8 @@ PCommandPool Graphics::getComputeCommands()
{
if(computeCommands == nullptr)
{
computeCommands = new CommandPool(this, computeQueue);
std::unique_lock l(poolLock);
computeCommands = pools.add(new CommandPool(this, computeQueue));
}
return computeCommands;
}
@@ -331,7 +330,8 @@ PCommandPool Graphics::getTransferCommands()
{
if(transferCommands == nullptr)
{
transferCommands = new CommandPool(this, transferQueue);
std::unique_lock l(poolLock);
transferCommands = pools.add(new CommandPool(this, transferQueue));
}
return transferCommands;
}
@@ -339,7 +339,8 @@ PCommandPool Graphics::getDedicatedTransferCommands()
{
if(dedicatedTransferCommands == nullptr)
{
dedicatedTransferCommands = new CommandPool(this, dedicatedTransferQueue != nullptr ? dedicatedTransferQueue : transferQueue);
std::unique_lock l(poolLock);
dedicatedTransferCommands = pools.add(new CommandPool(this, dedicatedTransferQueue != nullptr ? dedicatedTransferQueue : transferQueue));
}
return dedicatedTransferCommands;
}
+6 -4
View File
@@ -88,10 +88,12 @@ protected:
OQueue computeQueue;
OQueue transferQueue;
OQueue dedicatedTransferQueue;
thread_local static OCommandPool graphicsCommands;
thread_local static OCommandPool computeCommands;
thread_local static OCommandPool transferCommands;
thread_local static OCommandPool dedicatedTransferCommands;
thread_local static PCommandPool graphicsCommands;
thread_local static PCommandPool computeCommands;
thread_local static PCommandPool transferCommands;
thread_local static PCommandPool dedicatedTransferCommands;
std::mutex poolLock;
Array<OCommandPool> pools;
VkPhysicalDeviceProperties props;
VkPhysicalDeviceFeatures2 features;
VkPhysicalDeviceVulkan11Features features11;