From 913b8391f82e9c1d3783c7b93cba8e8f9223d60b Mon Sep 17 00:00:00 2001 From: Dynamitos Date: Fri, 7 Mar 2025 21:48:27 +0100 Subject: [PATCH] Fixing some semaphore things --- src/Editor/main.cpp | 32 +++---- src/Engine/Asset/FontAsset.cpp | 2 +- src/Engine/Graphics/Metal/Buffer.h | 2 - src/Engine/Graphics/RenderPass/BasePass.h | 10 +-- .../Graphics/RenderPass/DepthCullingPass.h | 4 +- .../Graphics/RenderPass/LightCullingPass.cpp | 2 - .../Graphics/RenderPass/LightCullingPass.h | 16 ++-- .../Graphics/RenderPass/RayTracingPass.cpp | 28 +++---- .../Graphics/RenderPass/RayTracingPass.h | 8 +- src/Engine/Graphics/RenderPass/UIPass.cpp | 6 +- src/Engine/Graphics/RenderPass/UIPass.h | 8 +- .../Graphics/RenderPass/VisibilityPass.h | 4 +- src/Engine/Graphics/StaticMeshVertexData.h | 12 +-- src/Engine/Graphics/VertexData.h | 16 ++-- src/Engine/Graphics/Vulkan/Command.cpp | 12 +-- src/Engine/Graphics/Vulkan/Descriptor.cpp | 83 +++++++++++++------ src/Engine/Graphics/Vulkan/Descriptor.h | 8 +- src/Engine/Graphics/Vulkan/Graphics.cpp | 10 ++- src/Engine/Graphics/Vulkan/Graphics.h | 1 + src/Engine/Graphics/Vulkan/Queue.cpp | 3 +- src/Engine/Graphics/Vulkan/Resources.cpp | 22 ++++- src/Engine/Graphics/Vulkan/Resources.h | 73 +++++++++++----- src/Engine/Graphics/Vulkan/Window.cpp | 8 ++ src/Engine/Graphics/Vulkan/Window.h | 1 + src/Engine/Scene/LightEnvironment.cpp | 4 +- 25 files changed, 236 insertions(+), 139 deletions(-) diff --git a/src/Editor/main.cpp b/src/Editor/main.cpp index 8648159..036d38f 100644 --- a/src/Editor/main.cpp +++ b/src/Editor/main.cpp @@ -112,7 +112,7 @@ int main() { // AssetImporter::importTexture(TextureImportArgs{ // .filePath = sourcePath / "import/textures/wgen.png", //}); - //AssetImporter::importMesh(MeshImportArgs{ + // AssetImporter::importMesh(MeshImportArgs{ // .filePath = sourcePath / "import/models/after-the-rain-vr-sound/source/Whitechapel.glb", // .importPath = "Whitechapel", //}); @@ -120,10 +120,10 @@ int main() { // .filePath = sourcePath / "import/models/box.glb", // .importPath = "", //}); - //AssetImporter::importMesh(MeshImportArgs{ - // .filePath = sourcePath / "import/models/rttest.glb", - // .importPath = "", - //}); + AssetImporter::importMesh(MeshImportArgs{ + .filePath = sourcePath / "import/models/rttest.glb", + .importPath = "", + }); //AssetImporter::importMesh(MeshImportArgs{ // .filePath = sourcePath / "import/models/town_hall.glb", // .importPath = "", @@ -137,16 +137,16 @@ int main() { .preferredFormat = Gfx::SE_FORMAT_B8G8R8A8_SRGB, }; auto window = windowManager->addWindow(graphics, mainWindowInfo); - ViewportCreateInfo sceneViewInfo = { - .dimensions = - { - .size = {1920, 1080}, - .offset = {0, 0}, - }, - .numSamples = Gfx::SE_SAMPLE_COUNT_4_BIT, - }; - OGameView sceneView = new Editor::PlayView(graphics, window, sceneViewInfo, binaryPath.generic_string()); - sceneView->setFocused(); + ViewportCreateInfo sceneViewInfo = { + .dimensions = + { + .size = {1920, 1080}, + .offset = {0, 0}, + }, + .numSamples = Gfx::SE_SAMPLE_COUNT_4_BIT, + }; + OGameView sceneView = new Editor::PlayView(graphics, window, sceneViewInfo, binaryPath.generic_string()); + sceneView->setFocused(); //OInspectorView inspectorView = new Editor::InspectorView(graphics, window, // ViewportCreateInfo{ // .dimensions = @@ -157,7 +157,7 @@ int main() { // .fieldOfView = 0, // .numSamples = Gfx::SE_SAMPLE_COUNT_1_BIT, // }); - + // window->show(); while (windowManager->isActive() && getGlobals().running) { windowManager->render(); diff --git a/src/Engine/Asset/FontAsset.cpp b/src/Engine/Asset/FontAsset.cpp index d0676c9..4d6709c 100644 --- a/src/Engine/Asset/FontAsset.cpp +++ b/src/Engine/Asset/FontAsset.cpp @@ -74,7 +74,7 @@ UVector2 FontAsset::shapeText(std::string_view view, uint32 fontSize, Arraynum_glyphs; ++i) { - assert(FT_Load_Glyph(ft_face, i, FT_LOAD_RENDER | FT_LOAD_COLOR) == 0); + assert(FT_Load_Glyph(ft_face, i, FT_LOAD_RENDER) == 0); FontAsset::Glyph& glyph = fontSizes[fontSize].glyphs[i]; glyph.size = IVector2(ft_face->glyph->bitmap.width, ft_face->glyph->bitmap.rows); glyph.bearing = IVector2(ft_face->glyph->bitmap_left, ft_face->glyph->bitmap_top); diff --git a/src/Engine/Graphics/Metal/Buffer.h b/src/Engine/Graphics/Metal/Buffer.h index 140cf0d..af23e05 100644 --- a/src/Engine/Graphics/Metal/Buffer.h +++ b/src/Engine/Graphics/Metal/Buffer.h @@ -2,8 +2,6 @@ #include "Graphics/Buffer.h" #include "Graphics/Enums.h" #include "Graphics/Initializer.h" -#include "Metal/MTLResource.hpp" -#include "Metal/MTLTypes.hpp" #include "MinimalEngine.h" #include "Resources.h" diff --git a/src/Engine/Graphics/RenderPass/BasePass.h b/src/Engine/Graphics/RenderPass/BasePass.h index 6383735..be76023 100644 --- a/src/Engine/Graphics/RenderPass/BasePass.h +++ b/src/Engine/Graphics/RenderPass/BasePass.h @@ -28,8 +28,8 @@ class BasePass : public RenderPass { Gfx::PShaderBuffer tLightIndexList; Gfx::PTexture2D oLightGrid; Gfx::PTexture2D tLightGrid; - constexpr static std::string LIGHTINDEX_NAME = "lightIndexList"; - constexpr static std::string LIGHTGRID_NAME = "lightGrid"; + constexpr static const char* LIGHTINDEX_NAME = "lightIndexList"; + constexpr static const char* LIGHTGRID_NAME = "lightGrid"; Gfx::PDescriptorSet opaqueCulling; Gfx::PDescriptorSet transparentCulling; @@ -79,9 +79,9 @@ class BasePass : public RenderPass { float blendFactor; } skyboxData; Component::Skybox skybox; - constexpr static std::string SKYBOXDAY_NAME = "day"; - constexpr static std::string SKYBOXNIGHT_NAME = "night"; - constexpr static std::string SKYBOXSAMPLER_NAME = "sampler"; + const char* SKYBOXDAY_NAME = "day"; + const char* SKYBOXNIGHT_NAME = "night"; + const char* SKYBOXSAMPLER_NAME = "sampler"; PScene scene; }; DEFINE_REF(BasePass) diff --git a/src/Engine/Graphics/RenderPass/DepthCullingPass.h b/src/Engine/Graphics/RenderPass/DepthCullingPass.h index 289d3f7..9ac8670 100644 --- a/src/Engine/Graphics/RenderPass/DepthCullingPass.h +++ b/src/Engine/Graphics/RenderPass/DepthCullingPass.h @@ -29,9 +29,9 @@ class DepthCullingPass : public RenderPass { Array mipOffsets; Array mipDims; - constexpr static std::string DEPTHTEXTURE_NAME = "depthTexture"; + constexpr static const char* DEPTHTEXTURE_NAME = "depthTexture"; Gfx::OShaderBuffer depthMipBuffer; - constexpr static std::string DEPTHMIP_NAME = "depthMip"; + constexpr static const char* DEPTHMIP_NAME = "depthMip"; Gfx::RenderTargetAttachment depthAttachment; Gfx::RenderTargetAttachment visibilityAttachment; Gfx::ODescriptorLayout depthAttachmentLayout; diff --git a/src/Engine/Graphics/RenderPass/LightCullingPass.cpp b/src/Engine/Graphics/RenderPass/LightCullingPass.cpp index 7b27539..7aeb007 100644 --- a/src/Engine/Graphics/RenderPass/LightCullingPass.cpp +++ b/src/Engine/Graphics/RenderPass/LightCullingPass.cpp @@ -6,8 +6,6 @@ #include "Math/Vector.h" #include "RenderGraph.h" #include "Scene/Scene.h" -#include "Graphics/Metal/Descriptor.h" -#include "Graphics/Metal/Shader.h" using namespace Seele; diff --git a/src/Engine/Graphics/RenderPass/LightCullingPass.h b/src/Engine/Graphics/RenderPass/LightCullingPass.h index 782d50a..e6a3f4d 100644 --- a/src/Engine/Graphics/RenderPass/LightCullingPass.h +++ b/src/Engine/Graphics/RenderPass/LightCullingPass.h @@ -27,7 +27,7 @@ class LightCullingPass : public RenderPass { static constexpr uint32 INDEX_LIGHT_ENV = 1; Gfx::OShaderBuffer frustumBuffer; - constexpr static std::string FRUSTUMBUFFER_NAME = "frustums"; + const char* FRUSTUMBUFFER_NAME = "frustums"; Gfx::ODescriptorLayout dispatchParamsLayout; Gfx::PDescriptorSet dispatchParamsSet; Gfx::OComputeShader frustumShader; @@ -36,19 +36,19 @@ class LightCullingPass : public RenderPass { PLightEnvironment lightEnv; Gfx::PTexture2D depthAttachment; - constexpr static std::string DEPTHATTACHMENT_NAME = "depth"; + constexpr static const char* DEPTHATTACHMENT_NAME = "depth"; Gfx::OShaderBuffer oLightIndexCounter; - constexpr static std::string OLIGHTINDEXCOUNTER_NAME = "oLightIndexCounter"; + constexpr static const char* OLIGHTINDEXCOUNTER_NAME = "oLightIndexCounter"; Gfx::OShaderBuffer tLightIndexCounter; - constexpr static std::string TLIGHTINDEXCOUNTER_NAME = "tLightIndexCounter"; + constexpr static const char* TLIGHTINDEXCOUNTER_NAME = "tLightIndexCounter"; Gfx::OShaderBuffer oLightIndexList; - constexpr static std::string OLIGHTINDEXLIST_NAME = "oLightIndexList"; + constexpr static const char* OLIGHTINDEXLIST_NAME = "oLightIndexList"; Gfx::OShaderBuffer tLightIndexList; - constexpr static std::string TLIGHTINDEXLIST_NAME = "tLightIndexList"; + constexpr static const char* TLIGHTINDEXLIST_NAME = "tLightIndexList"; Gfx::OTexture2D oLightGrid; - constexpr static std::string OLIGHTGRID_NAME = "oLightGrid"; + constexpr static const char* OLIGHTGRID_NAME = "oLightGrid"; Gfx::OTexture2D tLightGrid; - constexpr static std::string TLIGHTGRID_NAME = "tLightGrid"; + constexpr static const char* TLIGHTGRID_NAME = "tLightGrid"; Gfx::PDescriptorSet cullingDescriptorSet; Gfx::ODescriptorLayout cullingDescriptorLayout; Gfx::OPipelineLayout cullingLayout; diff --git a/src/Engine/Graphics/RenderPass/RayTracingPass.cpp b/src/Engine/Graphics/RenderPass/RayTracingPass.cpp index 63b13b3..8b6bb0a 100644 --- a/src/Engine/Graphics/RenderPass/RayTracingPass.cpp +++ b/src/Engine/Graphics/RenderPass/RayTracingPass.cpp @@ -16,30 +16,30 @@ struct SampleParams { RayTracingPass::RayTracingPass(Gfx::PGraphics graphics, PScene scene) : RenderPass(graphics), scene(scene) { paramsLayout = graphics->createDescriptorLayout("pRayTracingParams"); - /*paramsLayout->addDescriptorBinding(Gfx::DescriptorBinding{ - .binding = 0, + paramsLayout->addDescriptorBinding(Gfx::DescriptorBinding{ + .name = TLAS_NAME, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR, }); paramsLayout->addDescriptorBinding(Gfx::DescriptorBinding{ - .binding = 1, + .name = ACCUMULATOR_NAME, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_IMAGE, }); paramsLayout->addDescriptorBinding(Gfx::DescriptorBinding{ - .binding = 2, + .name = TEXTURE_NAME, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_IMAGE, }); paramsLayout->addDescriptorBinding(Gfx::DescriptorBinding{ - .binding = 3, + .name = INDEXBUFFER_NAME, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER, }); paramsLayout->addDescriptorBinding(Gfx::DescriptorBinding{ - .binding = 4, + .name = SKYBOX_NAME, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_SAMPLED_IMAGE, }); paramsLayout->addDescriptorBinding(Gfx::DescriptorBinding{ - .binding = 5, + .name = SKYSAMPLER_NAME, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_SAMPLER, - });*/ + }); paramsLayout->create(); pipelineLayout = graphics->createPipelineLayout("RayTracing"); pipelineLayout->addDescriptorLayout(viewParamsLayout); @@ -137,12 +137,12 @@ void RayTracingPass::render() { .bottomLevelStructures = accelerationStructures, }); Gfx::PDescriptorSet desc = paramsLayout->allocateDescriptorSet(); - /*desc->updateAccelerationStructure(0, 0, tlas); - desc->updateTexture(1, 0, radianceAccumulator); - desc->updateTexture(2, 0, texture); - desc->updateBuffer(3, 0, StaticMeshVertexData::getInstance()->getIndexBuffer()); - desc->updateTexture(4, 0, skyBox); - desc->updateSampler(5, 0, skyBoxSampler);*/ + desc->updateAccelerationStructure(TLAS_NAME, 0, tlas); + desc->updateTexture(ACCUMULATOR_NAME, 0, radianceAccumulator); + desc->updateTexture(TEXTURE_NAME, 0, texture); + desc->updateBuffer(INDEXBUFFER_NAME, 0, StaticMeshVertexData::getInstance()->getIndexBuffer()); + desc->updateTexture(SKYBOX_NAME, 0, skyBox); + desc->updateSampler(SKYSAMPLER_NAME, 0, skyBoxSampler); desc->writeChanges(); Gfx::ORenderCommand command = graphics->createRenderCommand("RayTracing"); diff --git a/src/Engine/Graphics/RenderPass/RayTracingPass.h b/src/Engine/Graphics/RenderPass/RayTracingPass.h index 67bdb9c..a22f1fb 100644 --- a/src/Engine/Graphics/RenderPass/RayTracingPass.h +++ b/src/Engine/Graphics/RenderPass/RayTracingPass.h @@ -17,15 +17,21 @@ class RayTracingPass : public RenderPass { private: Gfx::ODescriptorLayout paramsLayout; Gfx::OPipelineLayout pipelineLayout; + constexpr static const char* TLAS_NAME = "scene"; + Gfx::OTopLevelAS tlas; + constexpr static const char* ACCUMULATOR_NAME = "accumulator"; Gfx::OTexture2D radianceAccumulator; + constexpr static const char* TEXTURE_NAME = "image"; Gfx::OTexture2D texture; + constexpr static const char* SKYBOX_NAME = "skybox"; Gfx::PTextureCube skyBox; + constexpr static const char* SKYSAMPLER_NAME = "sampler"; Gfx::OSampler skyBoxSampler; + constexpr static const char* INDEXBUFFER_NAME = "indexBuffer"; Gfx::ORayGenShader rayGen; Gfx::OAnyHitShader anyhit; Gfx::OMissShader miss; Gfx::PRayTracingPipeline pipeline; - Gfx::OTopLevelAS tlas; PScene scene; }; } // namespace Seele \ No newline at end of file diff --git a/src/Engine/Graphics/RenderPass/UIPass.cpp b/src/Engine/Graphics/RenderPass/UIPass.cpp index 8297a42..d019e03 100644 --- a/src/Engine/Graphics/RenderPass/UIPass.cpp +++ b/src/Engine/Graphics/RenderPass/UIPass.cpp @@ -32,7 +32,7 @@ UIPass::UIPass(Gfx::PGraphics graphics, UI::PSystem system) : RenderPass(graphic uiDescriptorLayout = graphics->createDescriptorLayout("pParams"); uiDescriptorLayout->addDescriptorBinding(Gfx::DescriptorBinding{ - .name = GLYPHINSTANCE_NAME, + .name = ELEMENT_NAME, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER, }); uiDescriptorLayout->addDescriptorBinding(Gfx::DescriptorBinding{ @@ -57,6 +57,7 @@ void UIPass::beginFrame(const Component::Camera& cam) { RenderPass::beginFrame(cam); glyphs.clear(); usedTextures.clear(); + elements.clear(); for (auto& render : renderElements) { float x = render.position.x; float y = render.position.y; @@ -112,9 +113,6 @@ void UIPass::render() { command->bindPipeline(uiPipeline); command->bindDescriptor({viewParamsSet, uiDescriptorSet}); command->draw(4, elements.size(), 0, 0); - command->bindPipeline(textPipeline); - command->bindDescriptor({viewParamsSet, textDescriptorSet}); - command->draw(4, glyphs.size(), 0, 0); commands.add(std::move(command)); graphics->executeCommands(std::move(commands)); graphics->endRenderPass(); diff --git a/src/Engine/Graphics/RenderPass/UIPass.h b/src/Engine/Graphics/RenderPass/UIPass.h index ddf81f2..55a94ac 100644 --- a/src/Engine/Graphics/RenderPass/UIPass.h +++ b/src/Engine/Graphics/RenderPass/UIPass.h @@ -72,13 +72,13 @@ class UIPass : public RenderPass { Array glyphs; Array elements; Gfx::OShaderBuffer glyphInstanceBuffer; - constexpr static std::string GLYPHINSTANCE_NAME = "glyphData"; + constexpr static const char* GLYPHINSTANCE_NAME = "glyphData"; Gfx::OShaderBuffer elementBuffer; - constexpr static std::string ELEMENT_NAME = "elements"; + constexpr static const char* ELEMENT_NAME = "elements"; Gfx::OSampler glyphSampler; - constexpr static std::string GLYPHSAMPLER_NAME = "glyphSampler"; + constexpr static const char* GLYPHSAMPLER_NAME = "glyphSampler"; Array usedTextures; - constexpr static std::string TEXTURES_NAME = "textures"; + constexpr static const char* TEXTURES_NAME = "textures"; }; DEFINE_REF(UIPass); } // namespace Seele diff --git a/src/Engine/Graphics/RenderPass/VisibilityPass.h b/src/Engine/Graphics/RenderPass/VisibilityPass.h index e1457d2..69859d1 100644 --- a/src/Engine/Graphics/RenderPass/VisibilityPass.h +++ b/src/Engine/Graphics/RenderPass/VisibilityPass.h @@ -27,10 +27,10 @@ class VisibilityPass : public RenderPass { Gfx::OPipelineStatisticsQuery query; Gfx::PTimestampQuery timestamps; - constexpr static std::string VISIBILITY_NAME = "visibilityTexture"; + constexpr static const char* VISIBILITY_NAME = "visibilityTexture"; // Holds culling information for every meshlet for each instance Gfx::OShaderBuffer cullingBuffer; - constexpr static std::string CULLINGBUFFER_NAME = "cullingBuffer"; + constexpr static const char* CULLINGBUFFER_NAME = "cullingBuffer"; UVector threadGroupSize; }; DEFINE_REF(VisibilityPass) diff --git a/src/Engine/Graphics/StaticMeshVertexData.h b/src/Engine/Graphics/StaticMeshVertexData.h index edba7e7..1e50915 100644 --- a/src/Engine/Graphics/StaticMeshVertexData.h +++ b/src/Engine/Graphics/StaticMeshVertexData.h @@ -41,17 +41,17 @@ class StaticMeshVertexData : public VertexData { Gfx::OShaderBuffer positions; - constexpr static std::string POSITIONS_NAME = "positions"; + constexpr static const char* POSITIONS_NAME = "positions"; Gfx::OShaderBuffer texCoords[MAX_TEXCOORDS]; - constexpr static std::string TEXCOORDS_NAME = "texCoords"; + constexpr static const char* TEXCOORDS_NAME = "texCoords"; Gfx::OShaderBuffer normals; - constexpr static std::string NORMALS_NAME = "normals"; + constexpr static const char* NORMALS_NAME = "normals"; Gfx::OShaderBuffer tangents; - constexpr static std::string TANGENTS_NAME = "tangents"; + constexpr static const char* TANGENTS_NAME = "tangents"; Gfx::OShaderBuffer biTangents; - constexpr static std::string BITANGENTS_NAME = "biTangents"; + constexpr static const char* BITANGENTS_NAME = "biTangents"; Gfx::OShaderBuffer colors; - constexpr static std::string COLORS_NAME = "colors"; + constexpr static const char* COLORS_NAME = "colors"; Array posData; Array texData[MAX_TEXCOORDS]; Array norData; diff --git a/src/Engine/Graphics/VertexData.h b/src/Engine/Graphics/VertexData.h index a517e75..a4419bf 100644 --- a/src/Engine/Graphics/VertexData.h +++ b/src/Engine/Graphics/VertexData.h @@ -128,27 +128,27 @@ class VertexData { Gfx::ODescriptorLayout instanceDataLayout; // for mesh shading Gfx::OShaderBuffer meshletBuffer; - constexpr static std::string MESHLET_NAME = "meshlets"; + constexpr static const char* MESHLET_NAME = "meshlets"; Gfx::OShaderBuffer vertexIndicesBuffer; - constexpr static std::string VERTEXINDICES_NAME = "vertexIndices"; + constexpr static const char* VERTEXINDICES_NAME = "vertexIndices"; Gfx::OShaderBuffer primitiveIndicesBuffer; - constexpr static std::string PRIMITIVEINDICES_NAME = "primitiveIndices"; + constexpr static const char* PRIMITIVEINDICES_NAME = "primitiveIndices"; Gfx::OShaderBuffer cullingOffsetBuffer; - constexpr static std::string CULLINGOFFSETS_NAME = "cullingOffsets"; - constexpr static std::string CULLINGDATA_NAME = "cullingData"; + constexpr static const char* CULLINGOFFSETS_NAME = "cullingOffsets"; + constexpr static const char* CULLINGDATA_NAME = "cullingData"; // for legacy pipeline Gfx::OIndexBuffer indexBuffer; - constexpr static std::string INDEXBUFFER_NAME = "indexBuffer"; + constexpr static const char* INDEXBUFFER_NAME = "indexBuffer"; Array dataToBuild; // Material data Array instanceData; Gfx::OShaderBuffer instanceBuffer; - constexpr static std::string INSTANCES_NAME = "instances"; + constexpr static const char* INSTANCES_NAME = "instances"; Array instanceMeshData; Gfx::OShaderBuffer instanceMeshDataBuffer; - constexpr static std::string MESHDATA_NAME = "meshData"; + constexpr static const char* MESHDATA_NAME = "meshData"; Array rayTracingScene; diff --git a/src/Engine/Graphics/Vulkan/Command.cpp b/src/Engine/Graphics/Vulkan/Command.cpp index 1b3dbd9..dd96e4c 100644 --- a/src/Engine/Graphics/Vulkan/Command.cpp +++ b/src/Engine/Graphics/Vulkan/Command.cpp @@ -45,6 +45,7 @@ void Command::begin() { void Command::end() { VK_CHECK(vkEndCommandBuffer(handle)); + signalSemaphore->rotateSemaphore(); state = State::End; } @@ -111,15 +112,14 @@ void Command::executeCommands(Array commands) { } void Command::waitForSemaphore(VkPipelineStageFlags flags, PSemaphore semaphore) { + bindResource(semaphore->getCurrentSemaphore()); waitSemaphores.add(semaphore); waitFlags.add(flags); - // std::cout << "Cmd " << handle << " wait for " << semaphore->getHandle() << std::endl; } void Command::checkFence() { assert(state == State::Submit || !fence->isSignaled()); if (fence->isSignaled()) { - // std::cout << "Cmd " << handle << " was signaled" << std::endl; vkResetCommandBuffer(handle, VK_COMMAND_BUFFER_RESET_RELEASE_RESOURCES_BIT); fence->reset(); for (auto& command : executingComputes) { @@ -132,8 +132,8 @@ void Command::checkFence() { pool->cacheCommands(std::move(executingRenders)); for (auto& descriptor : boundResources) { descriptor->unbind(); - // std::cout << "Cmd " << handle << " unbind " << descriptor->getHandle() << std::endl; } + signalSemaphore->resolveSignal(); boundResources.clear(); graphics->getDestructionManager()->notifyCommandComplete(); state = State::Init; @@ -561,11 +561,12 @@ void CommandPool::submitCommands(PSemaphore signalSemaphore) { assert(command->state == Command::State::Begin); // Not in a renderpass command->end(); Array semaphores = {command->signalSemaphore->getHandle()}; + command->signalSemaphore->encodeSignal(); if (signalSemaphore != nullptr) { semaphores.add(signalSemaphore->getHandle()); + signalSemaphore->encodeSignal(); } queue->submitCommandBuffer(command, semaphores); - // std::cout << "Cmd " << command->getHandle() << " signalling " << command->signalSemaphore->getHandle() << std::endl; PSemaphore waitSemaphore = command->signalSemaphore; for (uint32 i = 0; i < allocatedBuffers.size(); ++i) { @@ -587,8 +588,7 @@ void CommandPool::submitCommands(PSemaphore signalSemaphore) { } void CommandPool::refreshCommands() { - for (uint32 i = 0; i < allocatedBuffers.size(); ++i) - { + for (uint32 i = 0; i < allocatedBuffers.size(); ++i) { allocatedBuffers[i]->checkFence(); } } diff --git a/src/Engine/Graphics/Vulkan/Descriptor.cpp b/src/Engine/Graphics/Vulkan/Descriptor.cpp index 25e4bae..0e2c060 100644 --- a/src/Engine/Graphics/Vulkan/Descriptor.cpp +++ b/src/Engine/Graphics/Vulkan/Descriptor.cpp @@ -53,6 +53,7 @@ void DescriptorLayout::create() { } else { mappings[gfxBinding.name] = { .binding = (uint32)bindings.size(), + .type = cast(gfxBinding.descriptorType), }; bindings.add({ .binding = (uint32)bindings.size(), @@ -205,11 +206,11 @@ void DescriptorSet::updateConstants(const std::string& name, uint32 offset, void void DescriptorSet::updateBuffer(const std::string& name, uint32 index, Gfx::PShaderBuffer shaderBuffer) { PShaderBuffer vulkanBuffer = shaderBuffer.cast(); - uint32 binding = owner->getLayout()->mappings[name].binding; + const auto& map = owner->getLayout()->mappings[name]; + uint32 binding = map.binding; if (boundResources[binding][index] == vulkanBuffer->getAlloc() || vulkanBuffer->getAlloc() == nullptr) { return; } - bufferInfos.add(VkDescriptorBufferInfo{ .buffer = vulkanBuffer->getHandle(), .offset = 0, @@ -222,7 +223,7 @@ void DescriptorSet::updateBuffer(const std::string& name, uint32 index, Gfx::PSh .dstBinding = binding, .dstArrayElement = index, .descriptorCount = 1, - .descriptorType = cast(layout->getBindings()[binding].descriptorType), + .descriptorType = map.type, .pBufferInfo = &bufferInfos.back(), }); @@ -231,7 +232,8 @@ void DescriptorSet::updateBuffer(const std::string& name, uint32 index, Gfx::PSh void DescriptorSet::updateBuffer(const std::string& name, uint32 index, Gfx::PVertexBuffer indexBuffer) { PVertexBuffer vulkanBuffer = indexBuffer.cast(); - uint32 binding = owner->getLayout()->mappings[name].binding; + const auto& map = owner->getLayout()->mappings[name]; + uint32 binding = map.binding; if (boundResources[binding][index] == vulkanBuffer->getAlloc() || vulkanBuffer->getAlloc() == nullptr) { return; } @@ -248,7 +250,7 @@ void DescriptorSet::updateBuffer(const std::string& name, uint32 index, Gfx::PVe .dstBinding = binding, .dstArrayElement = index, .descriptorCount = 1, - .descriptorType = cast(layout->getBindings()[binding].descriptorType), + .descriptorType = map.type, .pBufferInfo = &bufferInfos.back(), }); @@ -257,7 +259,8 @@ void DescriptorSet::updateBuffer(const std::string& name, uint32 index, Gfx::PVe void DescriptorSet::updateBuffer(const std::string& name, uint32 index, Gfx::PIndexBuffer indexBuffer) { PIndexBuffer vulkanBuffer = indexBuffer.cast(); - uint32 binding = owner->getLayout()->mappings[name].binding; + const auto& map = owner->getLayout()->mappings[name]; + uint32 binding = map.binding; if (boundResources[binding][index] == vulkanBuffer->getAlloc() || vulkanBuffer->getAlloc() == nullptr) { return; } @@ -274,7 +277,7 @@ void DescriptorSet::updateBuffer(const std::string& name, uint32 index, Gfx::PIn .dstBinding = binding, .dstArrayElement = index, .descriptorCount = 1, - .descriptorType = cast(layout->getBindings()[binding].descriptorType), + .descriptorType = map.type, .pBufferInfo = &bufferInfos.back(), }); @@ -283,7 +286,8 @@ void DescriptorSet::updateBuffer(const std::string& name, uint32 index, Gfx::PIn void DescriptorSet::updateSampler(const std::string& name, uint32 index, Gfx::PSampler samplerState) { PSampler vulkanSampler = samplerState.cast(); - uint32 binding = owner->getLayout()->mappings[name].binding; + const auto& map = owner->getLayout()->mappings[name]; + uint32 binding = map.binding; if (boundResources[binding][index] == vulkanSampler->getHandle()) { return; } @@ -301,7 +305,7 @@ void DescriptorSet::updateSampler(const std::string& name, uint32 index, Gfx::PS .dstBinding = binding, .dstArrayElement = index, .descriptorCount = 1, - .descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER, + .descriptorType = map.type, .pImageInfo = &imageInfos.back(), }); @@ -310,7 +314,8 @@ void DescriptorSet::updateSampler(const std::string& name, uint32 index, Gfx::PS void DescriptorSet::updateTexture(const std::string& name, uint32 index, Gfx::PTexture2D texture) { TextureBase* vulkanTexture = texture.cast().getHandle(); - uint32 binding = owner->getLayout()->mappings[name].binding; + const auto& map = owner->getLayout()->mappings[name]; + uint32 binding = map.binding; if (boundResources[binding][index] == vulkanTexture->getHandle()) { return; } @@ -328,7 +333,7 @@ void DescriptorSet::updateTexture(const std::string& name, uint32 index, Gfx::PT .dstBinding = binding, .dstArrayElement = index, .descriptorCount = 1, - .descriptorType = cast(layout->getBindings()[binding].descriptorType), + .descriptorType = map.type, .pImageInfo = &imageInfos.back(), }); @@ -337,7 +342,8 @@ void DescriptorSet::updateTexture(const std::string& name, uint32 index, Gfx::PT void DescriptorSet::updateTexture(const std::string& name, uint32 index, Gfx::PTexture3D texture) { TextureBase* vulkanTexture = texture.cast().getHandle(); - uint32 binding = owner->getLayout()->mappings[name].binding; + const auto& map = owner->getLayout()->mappings[name]; + uint32 binding = map.binding; if (boundResources[binding][index] == vulkanTexture->getHandle()) { return; } @@ -355,7 +361,7 @@ void DescriptorSet::updateTexture(const std::string& name, uint32 index, Gfx::PT .dstBinding = binding, .dstArrayElement = index, .descriptorCount = 1, - .descriptorType = cast(layout->getBindings()[binding].descriptorType), + .descriptorType = map.type, .pImageInfo = &imageInfos.back(), }); @@ -364,7 +370,8 @@ void DescriptorSet::updateTexture(const std::string& name, uint32 index, Gfx::PT void DescriptorSet::updateTexture(const std::string& name, uint32 index, Gfx::PTextureCube texture) { TextureBase* vulkanTexture = texture.cast().getHandle(); - uint32 binding = owner->getLayout()->mappings[name].binding; + const auto& map = owner->getLayout()->mappings[name]; + uint32 binding = map.binding; if (boundResources[binding][index] == vulkanTexture->getHandle()) { return; } @@ -382,7 +389,7 @@ void DescriptorSet::updateTexture(const std::string& name, uint32 index, Gfx::PT .dstBinding = binding, .dstArrayElement = index, .descriptorCount = 1, - .descriptorType = cast(layout->getBindings()[binding].descriptorType), + .descriptorType = map.type, .pImageInfo = &imageInfos.back(), }); @@ -410,6 +417,42 @@ void DescriptorSet::updateAccelerationStructure(const std::string& name, uint32 } void DescriptorSet::writeChanges() { + if (constantData.size() > 0) { + if (constantsBuffer != nullptr) + { + graphics->getDestructionManager()->queueResourceForDestruction(std::move(constantsBuffer)); + } + constantsBuffer = new BufferAllocation(graphics, owner->getLayout()->getName(), + VkBufferCreateInfo{ + .sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO, + .pNext = nullptr, + .size = constantData.size(), + .usage = VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, + }, + VmaAllocationCreateInfo{ + .usage = VMA_MEMORY_USAGE_AUTO, + }, + Gfx::QueueType::GRAPHICS); + constantsBuffer->updateContents(0, constantData.size(), constantData.data()); + constantsBuffer->pipelineBarrier(Gfx::SE_ACCESS_TRANSFER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_TRANSFER_BIT, + Gfx::SE_ACCESS_UNIFORM_READ_BIT, Gfx::SE_PIPELINE_STAGE_ALL_COMMANDS_BIT); + bufferInfos.add(VkDescriptorBufferInfo{ + .buffer = constantsBuffer->buffer, + .offset = 0, + .range = constantsBuffer->size, + }); + writeDescriptors.add(VkWriteDescriptorSet{ + .sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET, + .pNext = nullptr, + .dstSet = setHandle, + .dstBinding = 0, + .dstArrayElement = 0, + .descriptorCount = 1, + .descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, + .pBufferInfo = &bufferInfos.back(), + }); + } + if (writeDescriptors.size() > 0) { if (isCurrentlyBound()) { std::cout << "Descriptor currently bound, allocate a new one instead" << std::endl; @@ -420,16 +463,6 @@ void DescriptorSet::writeChanges() { imageInfos.clear(); bufferInfos.clear(); } - constantsBuffer = graphics->createUniformBuffer(UniformBufferCreateInfo{ - .sourceData = - { - .size = constantData.size(), - .data = constantData.data(), - }, - .name = owner->getLayout()->getName(), - }); - constantsBuffer->pipelineBarrier(Gfx::SE_ACCESS_TRANSFER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_TRANSFER_BIT, - Gfx::SE_ACCESS_UNIFORM_READ_BIT, Gfx::SE_PIPELINE_STAGE_ALL_COMMANDS_BIT); } PipelineLayout::PipelineLayout(PGraphics graphics, const std::string& name, Gfx::PPipelineLayout baseLayout) diff --git a/src/Engine/Graphics/Vulkan/Descriptor.h b/src/Engine/Graphics/Vulkan/Descriptor.h index 082f8e4..ec23b38 100644 --- a/src/Engine/Graphics/Vulkan/Descriptor.h +++ b/src/Engine/Graphics/Vulkan/Descriptor.h @@ -8,11 +8,11 @@ namespace Seele { namespace Vulkan { DECLARE_REF(Graphics) -struct DescriptorMapping -{ +struct DescriptorMapping { uint32 binding; uint32 constantOffset; uint32 constantSize; + VkDescriptorType type; }; class DescriptorLayout : public Gfx::DescriptorLayout { public: @@ -23,7 +23,7 @@ class DescriptorLayout : public Gfx::DescriptorLayout { private: PGraphics graphics; - uint32 constantsSize; + uint32 constantsSize = 0; VkShaderStageFlags constantsStages; Array bindings; Map mappings; @@ -73,7 +73,7 @@ class DescriptorSet : public Gfx::DescriptorSet, public CommandBoundResource { private: std::vector constantData; - Gfx::OUniformBuffer constantsBuffer; + OBufferAllocation constantsBuffer; VkShaderStageFlags constantsStageFlags; List imageInfos; List bufferInfos; diff --git a/src/Engine/Graphics/Vulkan/Graphics.cpp b/src/Engine/Graphics/Vulkan/Graphics.cpp index 2ff3536..dfcefc1 100644 --- a/src/Engine/Graphics/Vulkan/Graphics.cpp +++ b/src/Engine/Graphics/Vulkan/Graphics.cpp @@ -142,7 +142,9 @@ Graphics::~Graphics() { void Graphics::init(GraphicsInitializer initInfo) { initInstance(initInfo); - //setupDebugCallback(); +#ifdef ENABLE_VALIDATION + setupDebugCallback(); +#endif pickPhysicalDevice(); createDevice(initInfo); VmaAllocatorCreateInfo createInfo = { @@ -197,6 +199,12 @@ void Graphics::waitDeviceIdle() { getGraphicsCommands()->refreshCommands(); } +void Graphics::executeCommands(Gfx::ORenderCommand commands) { + Array commandArray; + commandArray.add(std::move(commands)); + getGraphicsCommands()->getCommands()->executeCommands(std::move(commandArray)); +} + void Graphics::executeCommands(Array commands) { getGraphicsCommands()->getCommands()->executeCommands(std::move(commands)); } diff --git a/src/Engine/Graphics/Vulkan/Graphics.h b/src/Engine/Graphics/Vulkan/Graphics.h index d47ad24..58cb080 100644 --- a/src/Engine/Graphics/Vulkan/Graphics.h +++ b/src/Engine/Graphics/Vulkan/Graphics.h @@ -40,6 +40,7 @@ class Graphics : public Gfx::Graphics { virtual void endRenderPass() override; virtual void waitDeviceIdle() override; + virtual void executeCommands(Gfx::ORenderCommand commands) override; virtual void executeCommands(Array commands) override; virtual void executeCommands(Gfx::OComputeCommand commands) override; virtual void executeCommands(Array commands) override; diff --git a/src/Engine/Graphics/Vulkan/Queue.cpp b/src/Engine/Graphics/Vulkan/Queue.cpp index 0f5cb4b..0517a6a 100644 --- a/src/Engine/Graphics/Vulkan/Queue.cpp +++ b/src/Engine/Graphics/Vulkan/Queue.cpp @@ -25,6 +25,8 @@ void Queue::submitCommandBuffer(PCommand command, const Array& sign VkCommandBuffer cmdHandle = command->handle; Array waitSemaphores; + // wait semaphores get bound to the cmd when they are added + // and unbound when the command completes for (PSemaphore semaphore : command->waitSemaphores) { waitSemaphores.add(semaphore->getHandle()); } @@ -40,7 +42,6 @@ void Queue::submitCommandBuffer(PCommand command, const Array& sign .signalSemaphoreCount = static_cast(signalSemaphores.size()), .pSignalSemaphores = signalSemaphores.data(), }; - VK_CHECK(vkQueueSubmit(queue, 1, &submitInfo, command->fence->getHandle())); command->fence->submit(); command->state = Command::State::Submit; diff --git a/src/Engine/Graphics/Vulkan/Resources.cpp b/src/Engine/Graphics/Vulkan/Resources.cpp index 82aaf56..7cca67d 100644 --- a/src/Engine/Graphics/Vulkan/Resources.cpp +++ b/src/Engine/Graphics/Vulkan/Resources.cpp @@ -7,7 +7,7 @@ using namespace Seele; using namespace Seele::Vulkan; -Semaphore::Semaphore(PGraphics graphics) : graphics(graphics) { +SemaphoreHandle::SemaphoreHandle(PGraphics graphics, const std::string& name) : CommandBoundResource(graphics, name) { VkSemaphoreCreateInfo info = { .sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO, .pNext = nullptr, @@ -16,8 +16,26 @@ Semaphore::Semaphore(PGraphics graphics) : graphics(graphics) { VK_CHECK(vkCreateSemaphore(graphics->getDevice(), &info, nullptr, &handle)); } +SemaphoreHandle::~SemaphoreHandle() { vkDestroySemaphore(graphics->getDevice(), handle, nullptr); } + +Semaphore::Semaphore(PGraphics graphics) : graphics(graphics) {} + Semaphore::~Semaphore() { - // graphics->getDestructionManager()->queueSemaphore(graphics->getGraphicsCommands()->getCommands(), handle); + for (auto& h : handles) { + graphics->getDestructionManager()->queueResourceForDestruction(std::move(h)); + } +} + +void Semaphore::rotateSemaphore() { + for (uint32 i = 0; i < handles.size(); ++i) { + if (handles[i]->isCurrentlyBound()) { + continue; + } + currentHandle = i; + return; + } + currentHandle = handles.size(); + handles.add(new SemaphoreHandle(graphics, "Semaphore")); } Fence::Fence(PGraphics graphics) : graphics(graphics), status(Status::Ready) { diff --git a/src/Engine/Graphics/Vulkan/Resources.h b/src/Engine/Graphics/Vulkan/Resources.h index b1ca748..8290ecc 100644 --- a/src/Engine/Graphics/Vulkan/Resources.h +++ b/src/Engine/Graphics/Vulkan/Resources.h @@ -4,21 +4,67 @@ #include #include - namespace Seele { namespace Vulkan { DECLARE_REF(DescriptorPool) DECLARE_REF(CommandPool) DECLARE_REF(Command) DECLARE_REF(Graphics) -class Semaphore { + +class CommandBoundResource { public: - Semaphore(PGraphics graphics); - virtual ~Semaphore(); + CommandBoundResource(PGraphics graphics, const std::string& name) : graphics(graphics), name(name) {} + virtual ~CommandBoundResource() { + if (isCurrentlyBound()) + abort(); + } + constexpr bool isCurrentlyBound() const { return bindCount > 0; } + constexpr void bind() { bindCount++; } + constexpr void unbind() { bindCount--; } + + protected: + PGraphics graphics; + std::string name; + uint64 bindCount = 0; +}; +DEFINE_REF(CommandBoundResource) + +class SemaphoreHandle : public CommandBoundResource { + public: + SemaphoreHandle(PGraphics graphics, const std::string& name); + virtual ~SemaphoreHandle(); + constexpr VkSemaphore getHandle() const { return handle; } private: VkSemaphore handle; +}; +DEFINE_REF(SemaphoreHandle) + +class Semaphore { + public: + Semaphore(PGraphics graphics); + virtual ~Semaphore(); + // call when you need a new semaphore + void rotateSemaphore(); + // call when the semaphore is to signal something, for example after using it in vkAcquireImage + void encodeSignal() { + if (handles.size() == 0) + return; + handles[currentHandle]->bind(); + } + // call when the semaphore has been signalled + void resolveSignal() { + if (handles.size() == 0) + return; + handles[currentHandle]->unbind(); + } + constexpr VkSemaphore getHandle() const { return handles[currentHandle]->getHandle(); } + PSemaphoreHandle getCurrentSemaphore() const { return handles[currentHandle]; } + + private: + Array handles; + uint32 currentHandle = 0; PGraphics graphics; }; DEFINE_REF(Semaphore) @@ -45,7 +91,6 @@ class Fence { VkFence fence; }; DEFINE_REF(Fence) -DECLARE_REF(CommandBoundResource) class DestructionManager { public: DestructionManager(PGraphics graphics); @@ -59,24 +104,6 @@ class DestructionManager { }; DEFINE_REF(DestructionManager) -class CommandBoundResource { - public: - CommandBoundResource(PGraphics graphics, const std::string& name) : graphics(graphics), name(name) {} - virtual ~CommandBoundResource() { - if (isCurrentlyBound()) - abort(); - } - constexpr bool isCurrentlyBound() const { return bindCount > 0; } - constexpr void bind() { bindCount++; } - constexpr void unbind() { bindCount--; } - - protected: - PGraphics graphics; - std::string name; - uint64 bindCount = 0; -}; -DEFINE_REF(CommandBoundResource) - class SamplerHandle : public CommandBoundResource { public: SamplerHandle(PGraphics graphics, VkSamplerCreateInfo createInfo); diff --git a/src/Engine/Graphics/Vulkan/Window.cpp b/src/Engine/Graphics/Vulkan/Window.cpp index 0fbdda8..a5f0e18 100644 --- a/src/Engine/Graphics/Vulkan/Window.cpp +++ b/src/Engine/Graphics/Vulkan/Window.cpp @@ -59,6 +59,7 @@ Window::Window(PGraphics graphics, const WindowCreateInfo& createInfo) : graphics(graphics), preferences(createInfo), instance(graphics->getInstance()), swapchain(VK_NULL_HANDLE) { glfwGetMonitorContentScale(glfwGetPrimaryMonitor(), &contentScaleX, &contentScaleY); glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API); + glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE); GLFWwindow* handle = glfwCreateWindow(createInfo.width / contentScaleX, createInfo.height / contentScaleY, createInfo.title, nullptr, nullptr); windowHandle = handle; glfwSetWindowUserPointer(handle, this); @@ -92,11 +93,16 @@ Window::~Window() { void Window::pollInput() { glfwPollEvents(); } +void Window::show() { glfwShowWindow(static_cast(windowHandle)); } + void Window::beginFrame() { imageAvailableFences[currentSemaphoreIndex]->reset(); + imageAvailableSemaphores[currentSemaphoreIndex]->resolveSignal(); + imageAvailableSemaphores[currentSemaphoreIndex]->rotateSemaphore(); VK_CHECK(vkAcquireNextImageKHR(graphics->getDevice(), swapchain, std::numeric_limits::max(), imageAvailableSemaphores[currentSemaphoreIndex]->getHandle(), imageAvailableFences[currentSemaphoreIndex]->getHandle(), ¤tImageIndex)); + imageAvailableSemaphores[currentSemaphoreIndex]->encodeSignal(); imageAvailableFences[currentSemaphoreIndex]->submit(); graphics->getGraphicsCommands()->getCommands()->waitForSemaphore(VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, imageAvailableSemaphores[currentSemaphoreIndex]); @@ -111,6 +117,7 @@ void Window::endFrame() { swapChainTextures[currentImageIndex]->changeLayout(Gfx::SE_IMAGE_LAYOUT_PRESENT_SRC_KHR, Gfx::SE_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, Gfx::SE_ACCESS_MEMORY_READ_BIT, Gfx::SE_PIPELINE_STAGE_TOP_OF_PIPE_BIT); + renderingDoneSemaphores[currentSemaphoreIndex]->rotateSemaphore(); graphics->getGraphicsCommands()->submitCommands(renderingDoneSemaphores[currentSemaphoreIndex]); VkSemaphore renderDoneHandle = renderingDoneSemaphores[currentSemaphoreIndex]->getHandle(); VkPresentInfoKHR presentInfo = { @@ -130,6 +137,7 @@ void Window::endFrame() { } else { VK_CHECK(r); } + renderingDoneSemaphores[currentSemaphoreIndex]->resolveSignal(); currentSemaphoreIndex = (currentSemaphoreIndex + 1) % Gfx::numFramesBuffered; currentFrameIndex = currentSemaphoreIndex; // graphics->waitDeviceIdle(); diff --git a/src/Engine/Graphics/Vulkan/Window.h b/src/Engine/Graphics/Vulkan/Window.h index db81e82..0e50bd2 100644 --- a/src/Engine/Graphics/Vulkan/Window.h +++ b/src/Engine/Graphics/Vulkan/Window.h @@ -12,6 +12,7 @@ class Window : public Gfx::Window { Window(PGraphics graphics, const WindowCreateInfo& createInfo); virtual ~Window(); virtual void pollInput() override; + virtual void show() override; virtual void beginFrame() override; virtual void endFrame() override; virtual Gfx::PTexture2D getBackBuffer() const override; diff --git a/src/Engine/Scene/LightEnvironment.cpp b/src/Engine/Scene/LightEnvironment.cpp index c0994cb..52409da 100644 --- a/src/Engine/Scene/LightEnvironment.cpp +++ b/src/Engine/Scene/LightEnvironment.cpp @@ -11,7 +11,7 @@ LightEnvironment::LightEnvironment(Gfx::PGraphics graphics) : graphics(graphics) }); layout->addDescriptorBinding(Gfx::DescriptorBinding{ .name = "numDirectionalLights", - .uniformLength = sizeof(uint) + .uniformLength = sizeof(uint32), }); layout->addDescriptorBinding(Gfx::DescriptorBinding{ .name = "pointLights", @@ -19,7 +19,7 @@ LightEnvironment::LightEnvironment(Gfx::PGraphics graphics) : graphics(graphics) }); layout->addDescriptorBinding(Gfx::DescriptorBinding{ .name = "numPointLights", - .uniformLength = sizeof(uint) + .uniformLength = sizeof(uint32), }); layout->create();