Shaders are not compiling anymore...

This commit is contained in:
Dynamitos
2023-12-02 10:55:00 +01:00
parent 9114a6f252
commit 6c156d3bc2
23 changed files with 190 additions and 148 deletions
+1 -11
View File
@@ -66,7 +66,6 @@ Allocation::Allocation(PGraphics graphics, PAllocator pool, VkDeviceSize size, u
Allocation::~Allocation()
{
vkFreeMemory(device, allocatedMemory, nullptr);
assert(bytesUsed == 0);
}
OSubAllocation Allocation::getSuballocation(VkDeviceSize requestedSize, VkDeviceSize alignment)
@@ -177,16 +176,6 @@ Allocator::Allocator(PGraphics graphics)
Allocator::~Allocator()
{
for (auto& heap : heaps)
{
for (auto& alloc : heap.allocations)
{
assert(alloc->activeAllocations.empty());
assert(alloc->freeRanges.size() == 1);
}
heap.allocations.clear();
}
graphics = nullptr;
}
OSubAllocation Allocator::allocate(const VkMemoryRequirements2 &memRequirements2, VkMemoryPropertyFlags properties, VkMemoryDedicatedAllocateInfo *dedicatedInfo)
@@ -272,6 +261,7 @@ StagingBuffer::~StagingBuffer()
graphics->getDedicatedTransferCommands()->getCommands(), buffer);
graphics->getDestructionManager()->queueAllocation(
graphics->getDedicatedTransferCommands()->getCommands(), std::move(allocation));
graphics->getDedicatedTransferCommands()->submitCommands();
}
void* StagingBuffer::map()
+4
View File
@@ -469,6 +469,10 @@ CommandPool::CommandPool(PGraphics graphics, PQueue queue)
CommandPool::~CommandPool()
{
vkDeviceWaitIdle(graphics->getDevice());
for (auto& command : allocatedBuffers)
{
command->checkFence();
}
allocatedRenderCommands.clear();
allocatedComputeCommands.clear();
allocatedBuffers.clear();
+9 -2
View File
@@ -2,6 +2,7 @@
#include "Graphics.h"
#include "Texture.h"
#include "Buffer.h"
#include "Command.h"
using namespace Seele;
using namespace Seele::Vulkan;
@@ -345,8 +346,14 @@ DescriptorPool::DescriptorPool(PGraphics graphics, DescriptorLayout &layout)
DescriptorPool::~DescriptorPool()
{
vkDestroyDescriptorPool(graphics->getDevice(), poolHandle, nullptr);
graphics = nullptr;
for (uint32 setIndex = 0; setIndex < cachedHandles.size(); ++setIndex)
{
if (cachedHandles[setIndex] != nullptr && cachedHandles[setIndex]->setHandle != VK_NULL_HANDLE)
{
graphics->getDestructionManager()->queueDescriptorSet(graphics->getGraphicsCommands()->getCommands(), Pair<VkDescriptorSet, VkDescriptorPool>(cachedHandles[setIndex]->setHandle, poolHandle));
}
}
graphics->getDestructionManager()->queueDescriptorPool(graphics->getGraphicsCommands()->getCommands(), poolHandle);
if(nextAlloc)
{
delete nextAlloc;
+11
View File
@@ -32,6 +32,17 @@ Graphics::Graphics()
Graphics::~Graphics()
{
vkDeviceWaitIdle(handle);
graphicsCommands = nullptr;
computeCommands = nullptr;
transferCommands = nullptr;
dedicatedTransferCommands = nullptr;
pipelineCache = nullptr;
allocator = nullptr;
destructionManager = nullptr;
stagingManager = nullptr;
allocatedFramebuffers.clear();
shaderCompiler = nullptr;
vkDestroyDevice(handle, nullptr);
DestroyDebugReportCallbackEXT(instance, nullptr, callback);
vkDestroyInstance(instance, nullptr);
+1 -1
View File
@@ -85,7 +85,6 @@ protected:
OQueue computeQueue;
OQueue transferQueue;
OQueue dedicatedTransferQueue;
OPipelineCache pipelineCache;
thread_local static OCommandPool graphicsCommands;
thread_local static OCommandPool computeCommands;
thread_local static OCommandPool transferCommands;
@@ -96,6 +95,7 @@ protected:
VkDebugReportCallbackEXT callback;
Map<uint32, OFramebuffer> allocatedFramebuffers;
OAllocator allocator;
OPipelineCache pipelineCache;
OStagingManager stagingManager;
ODestructionManager destructionManager;
+2 -2
View File
@@ -37,9 +37,9 @@ PipelineCache::PipelineCache(PGraphics graphics, const std::string& cacheFilePat
PipelineCache::~PipelineCache()
{
VkDeviceSize cacheSize;
vkGetPipelineCacheData(graphics->getDevice(), cache, &cacheSize, nullptr);
VK_CHECK(vkGetPipelineCacheData(graphics->getDevice(), cache, &cacheSize, nullptr));
Array<uint8> cacheData(cacheSize);
vkGetPipelineCacheData(graphics->getDevice(), cache, &cacheSize, cacheData.data());
VK_CHECK(vkGetPipelineCacheData(graphics->getDevice(), cache, &cacheSize, cacheData.data()));
std::ofstream stream(cacheFile, std::ios::binary);
stream.write((char*)cacheData.data(), cacheSize);
stream.flush();
+3 -2
View File
@@ -2,7 +2,8 @@
#include "Graphics.h"
#include "Framebuffer.h"
#include "Texture.h"
#include "RenderPass.h"
#include "Resources.h"
#include "Command.h"
using namespace Seele;
using namespace Seele::Vulkan;
@@ -125,7 +126,7 @@ RenderPass::RenderPass(PGraphics graphics, Gfx::ORenderTargetLayout _layout, Gfx
RenderPass::~RenderPass()
{
vkDestroyRenderPass(graphics->getDevice(), renderPass, nullptr);
graphics->getDestructionManager()->queueRenderPass(graphics->getGraphicsCommands()->getCommands(), renderPass);
}
uint32 RenderPass::getFramebufferHash()
+29 -1
View File
@@ -20,7 +20,7 @@ Semaphore::Semaphore(PGraphics graphics)
Semaphore::~Semaphore()
{
graphics->getDestructionManager()->queueSemaphore(graphics->getGraphicsCommands()->getCommands(), handle);
vkDestroySemaphore(graphics->getDevice(), handle, nullptr);
}
Fence::Fence(PGraphics graphics)
@@ -114,6 +114,21 @@ void DestructionManager::queueSemaphore(PCommand cmd, VkSemaphore sem)
sems[cmd].add(sem);
}
void DestructionManager::queueRenderPass(PCommand cmd, VkRenderPass renderPass)
{
renderPasses[cmd].add(renderPass);
}
void DestructionManager::queueDescriptorPool(PCommand cmd, VkDescriptorPool pool)
{
pools[cmd].add(pool);
}
void DestructionManager::queueDescriptorSet(PCommand cmd, Pair<VkDescriptorSet, VkDescriptorPool> set)
{
sets[cmd].add(set);
}
void DestructionManager::queueAllocation(PCommand cmd, OSubAllocation alloc)
{
allocs[cmd].add(std::move(alloc));
@@ -137,9 +152,22 @@ void DestructionManager::notifyCmdComplete(PCommand cmd)
{
vkDestroySemaphore(graphics->getDevice(), sem, nullptr);
}
for (auto [set, pool] : sets[cmd])
{
vkFreeDescriptorSets(graphics->getDevice(), pool, 1, &set);
}
for (auto pool : pools[cmd])
{
vkDestroyDescriptorPool(graphics->getDevice(), pool, nullptr);
}
for (auto renderPass : renderPasses[cmd])
{
vkDestroyRenderPass(graphics->getDevice(), renderPass, nullptr);
}
buffers[cmd].clear();
images[cmd].clear();
views[cmd].clear();
sems[cmd].clear();
renderPasses[cmd].clear();
allocs[cmd].clear();
}
+6
View File
@@ -61,6 +61,9 @@ public:
void queueImage(PCommand cmd, VkImage image);
void queueImageView(PCommand cmd, VkImageView view);
void queueSemaphore(PCommand cmd, VkSemaphore sem);
void queueRenderPass(PCommand cmd, VkRenderPass renderPass);
void queueDescriptorPool(PCommand cmd, VkDescriptorPool pool);
void queueDescriptorSet(PCommand cmd, Pair<VkDescriptorSet, VkDescriptorPool> set);
void queueAllocation(PCommand cmd, OSubAllocation alloc);
void notifyCmdComplete(PCommand cmdbuffer);
private:
@@ -69,6 +72,9 @@ private:
Map<PCommand, List<VkImage>> images;
Map<PCommand, List<VkImageView>> views;
Map<PCommand, List<VkSemaphore>> sems;
Map<PCommand, List<VkRenderPass>> renderPasses;
Map<PCommand, List<VkDescriptorPool>> pools;
Map<PCommand, List<Pair<VkDescriptorSet, VkDescriptorPool>>> sets;
Map<PCommand, List<OSubAllocation>> allocs;
};
DEFINE_REF(DestructionManager)
+4 -7
View File
@@ -55,12 +55,8 @@ void Shader::create(const ShaderCreateInfo& createInfo)
slang::TargetDesc vulkan;
vulkan.profile = globalSession->findProfile("sm_6_6");
vulkan.format = SLANG_SPIRV;
slang::TargetDesc glsl;
glsl.profile = globalSession->findProfile("sm_6_6");
glsl.format = SLANG_GLSL;
slang::TargetDesc targets[2] = { vulkan, glsl };
sessionDesc.targetCount = 2;
sessionDesc.targets = targets;
sessionDesc.targetCount = 1;
sessionDesc.targets = &vulkan;
StaticArray<const char*, 3> searchPaths = {"shaders/", "shaders/lib/", "shaders/generated/"};
sessionDesc.searchPaths = searchPaths.data();
sessionDesc.searchPathCount = searchPaths.size();
@@ -136,7 +132,7 @@ void Shader::create(const ShaderCreateInfo& createInfo)
hash = CRC::Calculate(entryPointName.data(), entryPointName.size(), CRC::CRC_32());
hash = CRC::Calculate(kernelBlob->getBufferPointer(), kernelBlob->getBufferSize(), CRC::CRC_32(), hash);
/*
specializedComponent->getEntryPointCode(
0,
1,
@@ -147,4 +143,5 @@ void Shader::create(const ShaderCreateInfo& createInfo)
std::ofstream shaderStream(createInfo.name + createInfo.entryPoint + ".glsl");
shaderStream << (char*)kernelBlob->getBufferPointer();
shaderStream.close();
*/
}