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
+7 -34
View File
@@ -3,34 +3,6 @@
using namespace Seele;
using namespace Seele::Gfx;
DescriptorBinding::DescriptorBinding()
: binding(0)
, descriptorType(SE_DESCRIPTOR_TYPE_MAX_ENUM)
, descriptorCount(0x7fff)
, shaderStages(SE_SHADER_STAGE_ALL)
{
}
DescriptorBinding::DescriptorBinding(const DescriptorBinding& other)
: binding(other.binding)
, descriptorType(other.descriptorType)
, descriptorCount(other.descriptorCount)
, shaderStages(other.shaderStages)
{
}
DescriptorBinding& DescriptorBinding::operator=(const DescriptorBinding& other)
{
if (this != &other)
{
binding = other.binding;
descriptorType = other.descriptorType;
descriptorCount = other.descriptorCount;
shaderStages = other.shaderStages;
}
return *this;
}
DescriptorPool::DescriptorPool()
{
}
@@ -77,12 +49,13 @@ void DescriptorLayout::addDescriptorBinding(uint32 bindingIndex, SeDescriptorTyp
{
descriptorBindings.resize(bindingIndex + 1);
}
DescriptorBinding& binding = descriptorBindings[bindingIndex];
binding.binding = bindingIndex;
binding.descriptorType = type;
binding.descriptorCount = arrayCount;
binding.bindingFlags = bindingFlags;
binding.shaderStages = shaderStages;
descriptorBindings[bindingIndex] = DescriptorBinding{
.binding = bindingIndex,
.descriptorType = type,
.descriptorCount = arrayCount,
.bindingFlags = bindingFlags,
.shaderStages = shaderStages,
};
}
PDescriptorSet DescriptorLayout::allocateDescriptorSet()
+5 -9
View File
@@ -6,17 +6,13 @@ namespace Seele
{
namespace Gfx
{
class DescriptorBinding
struct DescriptorBinding
{
public:
DescriptorBinding();
DescriptorBinding(const DescriptorBinding& other);
DescriptorBinding& operator=(const DescriptorBinding& other);
uint32 binding;
SeDescriptorType descriptorType;
uint32 descriptorCount;
uint32 binding = 0;
SeDescriptorType descriptorType = SE_DESCRIPTOR_TYPE_MAX_ENUM;
uint32 descriptorCount = 0x7fff;
SeDescriptorBindingFlags bindingFlags = 0;
SeShaderStageFlags shaderStages;
SeShaderStageFlags shaderStages = SE_SHADER_STAGE_ALL;
};
DEFINE_REF(DescriptorBinding)
-1
View File
@@ -1,6 +1,5 @@
#include "Graphics.h"
#include "Shader.h"
#include "Graphics.h"
using namespace Seele::Gfx;
+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();
*/
}
+8 -11
View File
@@ -22,19 +22,16 @@ void Window::addView(PView view)
void Window::render()
{
while(owner->isActive())
gfxHandle->beginFrame();
for(auto& view : views)
{
gfxHandle->beginFrame();
for(auto& view : views)
{
view->beginUpdate();
view->update();
view->commitUpdate();
view->prepareRender();
view->render();
}
gfxHandle->endFrame();
view->beginUpdate();
view->update();
view->commitUpdate();
view->prepareRender();
view->render();
}
gfxHandle->endFrame();
}
Gfx::PWindow Window::getGfxHandle()
+12 -9
View File
@@ -11,19 +11,22 @@ WindowManager::~WindowManager()
{
}
PWindow WindowManager::addWindow(Gfx::PGraphics graphics, const WindowCreateInfo &createInfo)
OWindow WindowManager::addWindow(Gfx::PGraphics graphics, const WindowCreateInfo &createInfo)
{
OWindow window = new Window(this, graphics->createWindow(createInfo));
PWindow ref = window;
windows.add(std::move(window));
return ref;
windows.add(window);
return window;
}
void WindowManager::render()
{
for (auto& window : windows)
{
window->render();
}
}
void WindowManager::notifyWindowClosed(PWindow window)
{
windows.remove(windows.find([window] (const OWindow& w) { return window == w; }));
if(windows.empty())
{
exit(0);
}
windows.remove(window);
}
+4 -3
View File
@@ -10,15 +10,16 @@ class WindowManager
public:
WindowManager();
~WindowManager();
PWindow addWindow(Gfx::PGraphics graphics, const WindowCreateInfo &createInfo);
OWindow addWindow(Gfx::PGraphics graphics, const WindowCreateInfo &createInfo);
void render();
void notifyWindowClosed(PWindow window);
inline bool isActive() const
bool isActive() const
{
return windows.size();
}
private:
Array<OWindow> windows;
Array<PWindow> windows;
};
DEFINE_REF(WindowManager)
} // namespace Seele