diff --git a/.vscode/launch.json b/.vscode/launch.json index f0bb606..614bf8d 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -26,7 +26,7 @@ }, { "name": "Editor (Mac)", - "type": "cppdbg", + "type": "lldb", "request": "launch", "program": "${workspaceRoot}/bin/Editor", "args": [], diff --git a/CMakeLists.txt b/CMakeLists.txt index 8654a8d..f29ecd9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -75,9 +75,12 @@ target_link_libraries(Engine PUBLIC fmt::fmt) target_link_libraries(Engine PUBLIC GPUOpen::VulkanMemoryAllocator) target_link_libraries(Engine PUBLIC shader-slang) if(APPLE) - target_link_directories(Engine PUBLIC /usr/local/lib) + target_link_libraries(Engine PUBLIC /usr/local/lib/libmetalirconverter.dylib) target_link_libraries(Engine PUBLIC metal) SET(CMAKE_OSX_DEPLOYMENT_TARGET 14.3) + install(FILES + ${EXTERNAL_ROOT}/dxc + DESTINATION ${CMAKE_INSTALL_PREFIX}/bin) endif() if(UNIX) target_link_libraries(Engine PUBLIC Threads::Threads) @@ -111,6 +114,11 @@ else() target_link_options(Engine PUBLIC -fsanitize=address) target_link_options(Editor PUBLIC -fsanitize=address) endif() +if(APPLE) + #Metal lib throws that internally for some reason + target_compile_options(Engine PUBLIC -Wno-gnu-anonymous-struct) + target_compile_options(Editor PUBLIC -Wno-gnu-anonymous-struct) +endif() target_compile_options(Engine PUBLIC "$<$:-DENABLE_VALIDATION>") target_compile_options(Engine PUBLIC "$<$:-DSEELE_DEBUG>") @@ -122,6 +130,12 @@ if(WIN32) COMMAND ${CMAKE_COMMAND} -E copy_if_different $ $ COMMAND_EXPAND_LISTS DEPENDS Editor) +elseif(APPLE) + add_custom_target(dll_copy ALL + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${SLANG_ROOT}bin/libslang.dylib $ + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${EXTERNAL_ROOT}/dxc $ + COMMAND_EXPAND_LISTS + DEPENDS Editor) else() add_custom_target(dll_copy ALL COMMAND ${CMAKE_COMMAND} -E true) diff --git a/cmake/SuperBuild.cmake b/cmake/SuperBuild.cmake index fda1c21..01591e2 100644 --- a/cmake/SuperBuild.cmake +++ b/cmake/SuperBuild.cmake @@ -19,7 +19,7 @@ if(WIN32) ${SLANG_ROOT}/lib/slang.lib DESTINATION ${CMAKE_INSTALL_PREFIX}/lib) elseif(APPLE) - set(SLANG_ROOT ${EXTERNAL_ROOT}/vcpkg/packages/shader-slang_${CMAKE_PLATFORM}-osx) + set(SLANG_ROOT ${EXTERNAL_ROOT}/vcpkg/packages/shader-slang_arm64-osx/) set_target_properties(shader-slang-glslang PROPERTIES IMPORTED_LOCATION ${SLANG_ROOT}/bin/libslang-glslang.dylib) set_target_properties(shader-slang PROPERTIES IMPORTED_LOCATION ${SLANG_ROOT}/bin/libslang.dylib) target_link_libraries(shader-slang INTERFACE shader-slang-glslang) diff --git a/external/dxc b/external/dxc new file mode 100755 index 0000000..d1aa98b Binary files /dev/null and b/external/dxc differ diff --git a/external/vcpkg b/external/vcpkg index 042c31e..c442507 160000 --- a/external/vcpkg +++ b/external/vcpkg @@ -1 +1 @@ -Subproject commit 042c31edc695ab91f6cf43f58f964baf33d53137 +Subproject commit c44250706fb0e336618e1a9bcb3a2783f2f18073 diff --git a/src/Editor/main.cpp b/src/Editor/main.cpp index c68c1d5..db01d8a 100644 --- a/src/Editor/main.cpp +++ b/src/Editor/main.cpp @@ -1,3 +1,4 @@ +#include "Graphics/Initializer.h" #include "Graphics/Metal/Graphics.h" #include "Window/WindowManager.h" #include "Window/SceneView.h" @@ -47,6 +48,12 @@ int main() #endif GraphicsInitializer initializer; graphics->init(initializer); + graphics->createComputeShader(ShaderCreateInfo { + .entryPoint = "cullLights", + .mainModule = "LightCulling", + .additionalModules = {"LightCulling"}, + .name = "Test", + }); StaticMeshVertexData* vd = StaticMeshVertexData::getInstance(); vd->init(graphics); OWindowManager windowManager = new WindowManager(); diff --git a/src/Engine/Graphics/Metal/Command.h b/src/Engine/Graphics/Metal/Command.h index eb4842e..00ed3e3 100644 --- a/src/Engine/Graphics/Metal/Command.h +++ b/src/Engine/Graphics/Metal/Command.h @@ -1,5 +1,6 @@ #pragma once #include "Graphics/Command.h" +#include "Metal/MTLCommandBuffer.hpp" #include "RenderPass.h" #include "Resources.h" @@ -12,7 +13,7 @@ DECLARE_REF(Graphics) class Command { public: - Command(PGraphics graphics, PCommandQueue owner); + Command(PGraphics graphics, MTL::CommandBuffer* cmdBuffer); ~Command(); void beginRenderPass(PRenderPass renderPass); void endRenderPass(); @@ -32,7 +33,6 @@ public: } private: PGraphics graphics; - PCommandQueue owner; OEvent completed; MTL::CommandBuffer* cmdBuffer; MTL::ParallelRenderCommandEncoder* renderEncoder; @@ -82,7 +82,7 @@ public: { return queue; } - PCommand getCommands(); + PCommand getCommands() {return activeCommand;} //TODO ORenderCommand getRenderCommand(const std::string& name); OComputeCommand getComputeCommand(const std::string& name); void submitCommands(PEvent signal = nullptr); @@ -100,7 +100,7 @@ public: { return queue; } - PCommand getCommands(); + PCommand getCommands() {return activeCommand;} // TODO void submitCommands(PEvent signal = nullptr); private: PGraphics graphics; diff --git a/src/Engine/Graphics/Metal/Command.mm b/src/Engine/Graphics/Metal/Command.mm index 64f731a..f68a8ee 100644 --- a/src/Engine/Graphics/Metal/Command.mm +++ b/src/Engine/Graphics/Metal/Command.mm @@ -1,6 +1,7 @@ #include "Command.h" #include "Graphics/Graphics.h" #include "Graphics/Metal/Resources.h" +#include "Metal/MTLCommandBuffer.hpp" #include "Metal/MTLIOCommandQueue.hpp" #include "Metal/MTLRenderCommandEncoder.hpp" #include "Window.h" @@ -8,9 +9,9 @@ using namespace Seele; using namespace Seele::Metal; -Command::Command(PGraphics graphics, PCommandQueue owner) - : graphics(graphics), owner(owner), completed(new Event(graphics)), - cmdBuffer(owner->getHandle()->commandBuffer()), renderEncoder(nullptr) {} +Command::Command(PGraphics graphics, MTL::CommandBuffer* cmdBuffer) + : graphics(graphics), completed(new Event(graphics)), + cmdBuffer(cmdBuffer), renderEncoder(nullptr) {} Command::~Command() { cmdBuffer->release(); } @@ -77,48 +78,48 @@ void RenderCommand::setViewport(Gfx::PViewport viewport) { } void RenderCommand::bindPipeline(Gfx::PGraphicsPipeline pipeline) { - encoder->setRenderPipelineState( - pipeline.cast()->getState()); + // encoder->setRenderPipelineState( + // pipeline.cast()->getState()); } void RenderCommand::bindDescriptor(Gfx::PDescriptorSet descriptorSet) { - encoder->set ? ? ? ? ? } void RenderCommand::bindDescriptor( const Array &descriptorSets) { - encoder->set ? ? ? ? ? + // encoder->set ? ? ? ? ? } void RenderCommand::bindVertexBuffer(const Array &buffers) { - encoder->setVertexBuffers(); + // encoder->setVertexBuffers(); } void RenderCommand::bindIndexBuffer(Gfx::PIndexBuffer indexBuffer) { - encoder->setObjectBuffer(??, NS::UInteger offset, NS::UInteger index) + // encoder->setObjectBuffer(??, NS::UInteger offset, NS::UInteger index) } void RenderCommand::pushConstants(Gfx::PPipelineLayout layout, Gfx::SeShaderStageFlags stage, uint32 offset, uint32 size, const void *data) { - ? ? ? + // ? ? ? } void RenderCommand::draw(uint32 vertexCount, uint32 instanceCount, int32 firstVertex, uint32 firstInstance) { - encoder->drawPrimitives(???, firstVertex, vertexCount, instanceCount, firstInstance); + // encoder->drawPrimitives(???, firstVertex, vertexCount, instanceCount, firstInstance); } void RenderCommand::drawIndexed(uint32 indexCount, uint32 instanceCount, int32 firstIndex, uint32 vertexOffset, uint32 firstInstance) { - encoder->drawIndexedPrimitives(???, indexCount, indexbuffer->getType(), indexBuffer->getBuffer(), firstIndex, instanceCount, vertexOffset, firstInstance); + // encoder->drawIndexedPrimitives(???, indexCount, indexbuffer->getType(), indexBuffer->getBuffer(), firstIndex, instanceCount, vertexOffset, firstInstance); } void RenderCommand::drawMesh(uint32 groupX, uint32 groupY, uint32 groupZ){ - encoder->drawMeshThreads(MTL::Size threadsPerGrid, - MTL::Size threadsPerObjectThreadgroup, - MTL::Size threadsPerMeshThreadgroup)} + // encoder->drawMeshThreads(MTL::Size threadsPerGrid, + // MTL::Size threadsPerObjectThreadgroup, + // MTL::Size threadsPerMeshThreadgroup) + } ComputeCommand::ComputeCommand(MTL::ComputeCommandEncoder *encoder) : encoder(encoder) {} @@ -128,30 +129,30 @@ ComputeCommand::~ComputeCommand() { encoder->release(); } void ComputeCommand::end() { encoder->endEncoding(); } void ComputeCommand::bindPipeline(Gfx::PComputePipeline pipeline) { - encoder->setComputePipelineState(pipeline.cast()); + // encoder->setComputePipelineState(pipeline.cast()); } void ComputeCommand::bindDescriptor(Gfx::PDescriptorSet set) { - encoder->set ? ? ? + // encoder->set ? ? ? } void ComputeCommand::bindDescriptor(const Array &sets) { - encoder->set ? ? ? + // encoder->set ? ? ? } void ComputeCommand::pushConstants(Gfx::PPipelineLayout layout, Gfx::SeShaderStageFlags stage, uint32 offset, uint32 size, const void *data) { - ? ? ? + // ? ? ? } void ComputeCommand::dispatch(uint32 threadX, uint32 threadY, uint32 threadZ) { - encoder->dispatchThreadgroups(???); + // encoder->dispatchThreadgroups(???); } CommandQueue::CommandQueue(PGraphics graphics) : graphics(graphics) { queue = graphics->getDevice()->newCommandQueue(); - activeCommand = new Command(graphics, this); + activeCommand = new Command(graphics, queue->commandBuffer()); } CommandQueue::~CommandQueue() { queue->release(); } @@ -166,8 +167,8 @@ OComputeCommand CommandQueue::getComputeCommand(const std::string &name) { void CommandQueue::submitCommands(PEvent signalSemaphore) { activeCommand->end(signalSemaphore); - MTL::Event *prevCmdEvent = activeCommand->getCompletedEvent(); - activeCommand = new Command(graphics, this); + PEvent prevCmdEvent = activeCommand->getCompletedEvent(); + activeCommand = new Command(graphics, queue->commandBuffer()); activeCommand->waitForEvent(prevCmdEvent); } @@ -175,8 +176,8 @@ IOCommandQueue::IOCommandQueue(PGraphics graphics) : graphics(graphics) { MTL::IOCommandQueueDescriptor* desc = MTL::IOCommandQueueDescriptor::alloc()->init(); desc->setType(MTL::IOCommandQueueTypeConcurrent); desc->setPriority(MTL::IOPriorityNormal); - queue = graphics->getDevice()->newIOCommandQueue(desc); - activeCommand = new Command(graphics, this); + queue = graphics->getDevice()->newIOCommandQueue(desc, nullptr); + //activeCommand = new Command(graphics, queue->commandBuffer()); desc->release(); } @@ -185,7 +186,7 @@ IOCommandQueue::~IOCommandQueue() { queue->release(); } void IOCommandQueue::submitCommands(PEvent signalSemaphore) { //TODO: scratch buffer activeCommand->end(signalSemaphore); - MTL::Event *prevCmdEvent = activeCommand->getCompletedEvent(); - activeCommand = new Command(graphics, this); + PEvent prevCmdEvent = activeCommand->getCompletedEvent(); + //activeCommand = new Command(graphics, queue->commandBuffer()); activeCommand->waitForEvent(prevCmdEvent); } diff --git a/src/Engine/Graphics/Metal/Descriptor.h b/src/Engine/Graphics/Metal/Descriptor.h index e10f36d..9018bab 100644 --- a/src/Engine/Graphics/Metal/Descriptor.h +++ b/src/Engine/Graphics/Metal/Descriptor.h @@ -1,53 +1,71 @@ #pragma once +#include "Foundation/NSArray.hpp" #include "Graphics/Descriptor.h" #include "Graphics/Initializer.h" +#include "Metal/MTLArgumentEncoder.hpp" #include "MinimalEngine.h" namespace Seele { namespace Metal { DECLARE_REF(Graphics) DECLARE_REF(DescriptorPool) -class DescriptorLayout : public Gfx::DescriptorLayout -{ +class DescriptorLayout : public Gfx::DescriptorLayout { public: - DescriptorLayout(PGraphics graphics, const std::string& name); + DescriptorLayout(PGraphics graphics, const std::string &name); virtual ~DescriptorLayout(); virtual void create() override; + NS::Array* getArguments() const + { + return arguments; + } private: PGraphics graphics; + NS::Array* arguments; }; -class PipelineLayout : public Gfx::PipelineLayout -{ +class PipelineLayout : public Gfx::PipelineLayout { public: PipelineLayout(PGraphics graphics, Gfx::PPipelineLayout baseLayout) - : Gfx::PipelineLayout(baseLayout) - , graphics(graphics) - {} + : Gfx::PipelineLayout(baseLayout), graphics(graphics) {} + private: PGraphics graphics; }; DEFINE_REF(PipelineLayout) -class DescriptorSet : public Gfx::DescriptorSet -{ +class DescriptorSet : public Gfx::DescriptorSet { public: - DescriptorSet(PGraphics graphics, PDescriptorPool owner) - : graphics(graphics) - , owner(owner) - {} + DescriptorSet(PGraphics graphics, PDescriptorPool owner); virtual ~DescriptorSet(); + virtual void writeChanges(); + virtual void updateBuffer(uint32_t binding, + Gfx::PUniformBuffer uniformBuffer); + virtual void updateBuffer(uint32_t binding, Gfx::PShaderBuffer uniformBuffer); + virtual void updateSampler(uint32_t binding, Gfx::PSampler samplerState); + virtual void updateTexture(uint32_t binding, Gfx::PTexture texture, + Gfx::PSampler sampler = nullptr); + virtual void updateTextureArray(uint32_t binding, + Array texture); + virtual bool operator<(Gfx::PDescriptorSet other); + private: PGraphics graphics; PDescriptorPool owner; + MTL::Buffer* buffer; + MTL::ArgumentEncoder* encoder; }; DEFINE_REF(DescriptorSet) -class DescriptorPool : public Gfx::DescriptorPool -{ +class DescriptorPool : public Gfx::DescriptorPool { public: - DescriptorPool(PGraphics graphics); + DescriptorPool(PGraphics graphics, DescriptorLayout& layout); + virtual ~DescriptorPool(); + NS::Array* getArguments() const + { + return layout.getArguments(); + } private: PGraphics graphics; + DescriptorLayout& layout; }; -} -} \ No newline at end of file +} // namespace Metal +} // namespace Seele \ No newline at end of file diff --git a/src/Engine/Graphics/Metal/Descriptor.mm b/src/Engine/Graphics/Metal/Descriptor.mm index e69de29..2c20fa6 100644 --- a/src/Engine/Graphics/Metal/Descriptor.mm +++ b/src/Engine/Graphics/Metal/Descriptor.mm @@ -0,0 +1,28 @@ +#include "Descriptor.h" +#include "Graphics.h" + +using namespace Seele; +using namespace Seele::Metal; + +DescriptorSet::DescriptorSet(PGraphics graphics, PDescriptorPool owner) + : graphics(graphics) + , owner(owner) +{ + encoder = graphics->getDevice()->newArgumentEncoder(owner->getArguments()); +} +DescriptorSet::~DescriptorSet() +{ +} +void DescriptorSet::writeChanges() +{ +} + + void DescriptorSet::updateBuffer(uint32_t binding, + Gfx::PUniformBuffer uniformBuffer){} + void DescriptorSet::updateBuffer(uint32_t binding, Gfx::PShaderBuffer uniformBuffer){} + void DescriptorSet::updateSampler(uint32_t binding, Gfx::PSampler samplerState){} + void DescriptorSet::updateTexture(uint32_t binding, Gfx::PTexture texture, + Gfx::PSampler sampler){} + void DescriptorSet::updateTextureArray(uint32_t binding, + Array texture){} + bool DescriptorSet::operator<(Gfx::PDescriptorSet other){return this < other.getHandle();} diff --git a/src/Engine/Graphics/Metal/Graphics.h b/src/Engine/Graphics/Metal/Graphics.h index 1189e38..a79c062 100644 --- a/src/Engine/Graphics/Metal/Graphics.h +++ b/src/Engine/Graphics/Metal/Graphics.h @@ -59,7 +59,6 @@ public: PIOCommandQueue getIOQueue() const { return ioQueue; } protected: MTL::Device* device; - MTL::Library* library; OCommandQueue queue; OIOCommandQueue ioQueue; }; diff --git a/src/Engine/Graphics/Metal/Graphics.mm b/src/Engine/Graphics/Metal/Graphics.mm index 78d788c..255d43d 100644 --- a/src/Engine/Graphics/Metal/Graphics.mm +++ b/src/Engine/Graphics/Metal/Graphics.mm @@ -1,4 +1,5 @@ #include "Graphics.h" +#include "Graphics/Metal/Shader.h" #include "RenderPass.h" #include "Command.h" #include "Window.h" @@ -19,8 +20,6 @@ Graphics::~Graphics() void Graphics::init(GraphicsInitializer) { device = MTL::CreateSystemDefaultDevice(); - library = device->newDefaultLibrary(); - assert(library); queue = new CommandQueue(this); ioQueue = new IOCommandQueue(this); } @@ -121,11 +120,16 @@ Gfx::OFragmentShader Graphics::createFragmentShader(const ShaderCreateInfo& crea } Gfx::OComputeShader Graphics::createComputeShader(const ShaderCreateInfo& createInfo) { - + OComputeShader result = new ComputeShader(this); + result->create(createInfo); + return result; } + Gfx::OMeshShader Graphics::createMeshShader(const ShaderCreateInfo& createInfo) { - + OMeshShader result = new MeshShader(this); + result->create(createInfo); + return result; } Gfx::OTaskShader Graphics::createTaskShader(const ShaderCreateInfo& createInfo) { diff --git a/src/Engine/Graphics/Metal/Shader.mm b/src/Engine/Graphics/Metal/Shader.mm index 710f8b4..eba39e5 100644 --- a/src/Engine/Graphics/Metal/Shader.mm +++ b/src/Engine/Graphics/Metal/Shader.mm @@ -2,8 +2,8 @@ #include "Graphics.h" #include "Graphics/Enums.h" #include "Graphics/slang-compile.h" -#include "Metal/MTLLibrary.hpp" -#include "metal_irconverter/metal_irconverter.h" +#include +#include #include using namespace Seele; @@ -55,6 +55,17 @@ void Shader::create(const ShaderCreateInfo &createInfo) { uint8_t *metallib = new uint8_t[metallibSize]; IRMetalLibGetBytecode(pMetallib, metallib); + IRShaderReflection* reflection = IRShaderReflectionCreate(); + IRObjectGetReflection(pOutIR, irStage, reflection); + Array locations( + IRShaderReflectionGetResourceCount(reflection)); + IRShaderReflectionGetResourceLocations(reflection, locations.data()); + for(auto l : locations) + { + std::cout << "Resource " << l.resourceName << " Type " << l.resourceType << " size " << l.sizeBytes << " slot " << l.slot << " space " << l.space << " offset " << l.topLevelOffset << std::endl; + } + IRShaderReflectionDestroy(reflection); + // Store the metallib to custom format or disk, or use to create a MTLLibrary. NS::Error *__autoreleasing error = nil; dispatch_data_t data = dispatch_data_create(metallib, metallibSize, diff --git a/src/Engine/Graphics/Vulkan/Command.cpp b/src/Engine/Graphics/Vulkan/Command.cpp index e169131..0eea9d9 100644 --- a/src/Engine/Graphics/Vulkan/Command.cpp +++ b/src/Engine/Graphics/Vulkan/Command.cpp @@ -82,7 +82,7 @@ void Command::endRenderPass() state = State::Begin; } -void Command::executeCommands(const Array& commands) +void Command::executeCommands(Array commands) { assert(state == State::RenderPass); if(commands.size() == 0) @@ -95,18 +95,18 @@ void Command::executeCommands(const Array& commands) { auto command = Gfx::PRenderCommand(commands[i]).cast(); command->end(); - executingRenders.add(command); for(auto& descriptor : command->boundDescriptors) { boundDescriptors.add(descriptor); //std::cout << "Cmd " << handle << " bound descriptor " << descriptor->getHandle() << std::endl; } cmdBuffers[i] = command->getHandle(); + executingRenders.add(std::move(commands[i])); } vkCmdExecuteCommands(handle, (uint32)cmdBuffers.size(), cmdBuffers.data()); } -void Command::executeCommands(const Array& commands) +void Command::executeCommands(Array commands) { if(commands.size() == 0) { @@ -117,13 +117,13 @@ void Command::executeCommands(const Array& commands) { auto command = Gfx::PComputeCommand(commands[i]).cast(); command->end(); - executingComputes.add(command); for(auto& descriptor : command->boundDescriptors) { boundDescriptors.add(descriptor); //std::cout << "Cmd " << handle << " bound descriptor " << descriptor->getHandle() << std::endl; } cmdBuffers[i] = command->getHandle(); + executingComputes.add(std::move(commands[i])); } vkCmdExecuteCommands(handle, (uint32)cmdBuffers.size(), cmdBuffers.data()); } @@ -487,12 +487,18 @@ PCommand CommandPool::getCommands() } void CommandPool::cacheCommands(Array commands) { - allocatedRenderCommands.addAll(commands); + for(auto&& command : commands) + { + allocatedRenderCommands.add(std::move(command)); + } } void CommandPool::cacheCommands(Array commands) { - allocatedComputeCommands.addAll(commands); + for(auto&& command : commands) + { + allocatedComputeCommands.add(std::move(command)); + } } ORenderCommand CommandPool::createRenderCommand(const std::string& name) diff --git a/src/Engine/Graphics/Vulkan/Command.h b/src/Engine/Graphics/Vulkan/Command.h index 253e9cd..32c51fd 100644 --- a/src/Engine/Graphics/Vulkan/Command.h +++ b/src/Engine/Graphics/Vulkan/Command.h @@ -22,8 +22,8 @@ public: void end(); void beginRenderPass(PRenderPass renderPass, PFramebuffer framebuffer); void endRenderPass(); - void executeCommands(const Array &secondaryCommands); - void executeCommands(const Array &secondaryCommands); + void executeCommands(Array secondaryCommands); + void executeCommands(Array secondaryCommands); void waitForSemaphore(VkPipelineStageFlags stages, PSemaphore waitSemaphore); void checkFence(); void waitForCommand(uint32 timeToWait = 1000000u); @@ -50,8 +50,8 @@ private: PFramebuffer boundFramebuffer; Array waitSemaphores; Array waitFlags; - Array executingRenders; - Array executingComputes; + Array executingRenders; + Array executingComputes; Array boundDescriptors; friend class RenderCommand; friend class CommandPool; @@ -123,7 +123,7 @@ public: private: PComputePipeline pipeline; bool ready; - Array boundDescriptors; + Array boundDescriptors; VkViewport currentViewport; VkRect2D currentScissor; PGraphics graphics; diff --git a/src/Engine/Graphics/Vulkan/Graphics.cpp b/src/Engine/Graphics/Vulkan/Graphics.cpp index 7df4569..3997d9b 100644 --- a/src/Engine/Graphics/Vulkan/Graphics.cpp +++ b/src/Engine/Graphics/Vulkan/Graphics.cpp @@ -118,12 +118,12 @@ void Graphics::waitDeviceIdle() void Graphics::executeCommands(Array commands) { - getGraphicsCommands()->getCommands()->executeCommands(commands); + getGraphicsCommands()->getCommands()->executeCommands(std::move(commands)); } void Graphics::executeCommands(Array commands) { - getComputeCommands()->getCommands()->executeCommands(commands); + getComputeCommands()->getCommands()->executeCommands(std::move(commands)); } Gfx::OTexture2D Graphics::createTexture2D(const TextureCreateInfo &createInfo) diff --git a/src/Engine/Graphics/Vulkan/Shader.cpp b/src/Engine/Graphics/Vulkan/Shader.cpp index 2fb0bec..8123e69 100644 --- a/src/Engine/Graphics/Vulkan/Shader.cpp +++ b/src/Engine/Graphics/Vulkan/Shader.cpp @@ -1,5 +1,6 @@ #include "Shader.h" #include "Graphics.h" +#include "Graphics/slang-compile.h" #include "slang.h" #include "slang-com-ptr.h" #include "stdlib.h" @@ -29,7 +30,7 @@ uint32 Seele::Vulkan::Shader::getShaderHash() const void Shader::create(const ShaderCreateInfo& createInfo) { - + Slang::ComPtr kernelBlob = generateShader(createInfo, SLANG_SPIRV); VkShaderModuleCreateInfo moduleInfo = { .sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO, @@ -40,7 +41,6 @@ void Shader::create(const ShaderCreateInfo& createInfo) }; VK_CHECK(vkCreateShaderModule(graphics->getDevice(), &moduleInfo, nullptr, &module)); - hash = CRC::Calculate(entryPointName.data(), entryPointName.size(), CRC::CRC_32()); hash = CRC::Calculate(kernelBlob->getBufferPointer(), kernelBlob->getBufferSize(), CRC::CRC_32(), hash); /* specializedComponent->getEntryPointCode(