diff --git a/CMakeLists.txt b/CMakeLists.txt index c7f5cd1..fac3163 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -49,9 +49,6 @@ find_package(Ktx CONFIG REQUIRED) find_package(nlohmann_json CONFIG REQUIRED) find_package(fmt CONFIG REQUIRED) find_package(VulkanMemoryAllocator CONFIG REQUIRED) -find_package(spirv_cross_core CONFIG REQUIRED) -find_package(spirv_cross_glsl CONFIG REQUIRED) -find_package(spirv_cross_msl CONFIG REQUIRED) find_package(glslang CONFIG REQUIRED) if(UNIX) diff --git a/src/Editor/Asset/MaterialLoader.cpp b/src/Editor/Asset/MaterialLoader.cpp index fba508b..720d497 100644 --- a/src/Editor/Asset/MaterialLoader.cpp +++ b/src/Editor/Asset/MaterialLoader.cpp @@ -69,7 +69,7 @@ void MaterialLoader::import(MaterialImportArgs args, PMaterialAsset asset) OFloatParameter p = new FloatParameter(param.key(), uniformBufferOffset, uniformBinding); if(uniformBinding == -1) { - layout->addDescriptorBinding(bindingCounter, Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER); + layout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = bindingCounter, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER,}); uniformBinding = bindingCounter++; } uniformBufferOffset += 4; @@ -86,7 +86,7 @@ void MaterialLoader::import(MaterialImportArgs args, PMaterialAsset asset) OVectorParameter p = new VectorParameter(param.key(), uniformBufferOffset, uniformBinding); if(uniformBinding == -1) { - layout->addDescriptorBinding(bindingCounter, Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER); + layout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = bindingCounter, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER,}); uniformBinding = bindingCounter++; } uniformBufferOffset += 12; @@ -100,7 +100,7 @@ void MaterialLoader::import(MaterialImportArgs args, PMaterialAsset asset) else if(type.compare("Texture2D") == 0) { OTextureParameter p = new TextureParameter(param.key(), 0, bindingCounter); - layout->addDescriptorBinding(bindingCounter++, Gfx::SE_DESCRIPTOR_TYPE_SAMPLED_IMAGE); + layout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = bindingCounter++, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_SAMPLED_IMAGE,}); if(defaultValue != param.value().end()) { std::string defaultString = defaultValue.value().get(); @@ -116,7 +116,7 @@ void MaterialLoader::import(MaterialImportArgs args, PMaterialAsset asset) else if(type.compare("Sampler") == 0) { OSamplerParameter p = new SamplerParameter(param.key(), 0, bindingCounter); - layout->addDescriptorBinding(bindingCounter++, Gfx::SE_DESCRIPTOR_TYPE_SAMPLER); + layout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = bindingCounter++, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_SAMPLER,}); p->data = graphics->createSampler({}); parameters.add(p->key); expressions.add(std::move(p)); diff --git a/src/Engine/Graphics/Descriptor.cpp b/src/Engine/Graphics/Descriptor.cpp index f280ec7..d71fcff 100644 --- a/src/Engine/Graphics/Descriptor.cpp +++ b/src/Engine/Graphics/Descriptor.cpp @@ -24,19 +24,11 @@ DescriptorLayout& DescriptorLayout::operator=(const DescriptorLayout& other) { DescriptorLayout::~DescriptorLayout() {} -void DescriptorLayout::addDescriptorBinding(uint32 bindingIndex, SeDescriptorType type, SeImageViewType textureType, uint32 arrayCount, - SeDescriptorBindingFlags bindingFlags, SeShaderStageFlags shaderStages) { - if (descriptorBindings.size() <= bindingIndex) { - descriptorBindings.resize(bindingIndex + 1); +void DescriptorLayout::addDescriptorBinding(DescriptorBinding binding) { + if (descriptorBindings.size() <= binding.binding) { + descriptorBindings.resize(binding.binding + 1); } - descriptorBindings[bindingIndex] = DescriptorBinding{ - .binding = bindingIndex, - .descriptorType = type, - .textureType = textureType, - .descriptorCount = arrayCount, - .bindingFlags = bindingFlags, - .shaderStages = shaderStages, - }; + descriptorBindings[binding.binding] = binding; } PDescriptorSet DescriptorLayout::allocateDescriptorSet() { return pool->allocateDescriptorSet(); } diff --git a/src/Engine/Graphics/Descriptor.h b/src/Engine/Graphics/Descriptor.h index 584e146..bbd2d8a 100644 --- a/src/Engine/Graphics/Descriptor.h +++ b/src/Engine/Graphics/Descriptor.h @@ -23,10 +23,7 @@ public: DescriptorLayout(const DescriptorLayout& other); DescriptorLayout& operator=(const DescriptorLayout& other); virtual ~DescriptorLayout(); - void addDescriptorBinding(uint32 binding, SeDescriptorType type, - SeImageViewType textureType = Gfx::SE_IMAGE_VIEW_TYPE_2D, uint32 arrayCount = 1, - SeDescriptorBindingFlags bindingFlags = 0, - SeShaderStageFlags shaderStages = SeShaderStageFlagBits::SE_SHADER_STAGE_ALL); + void addDescriptorBinding(DescriptorBinding binding); void reset(); PDescriptorSet allocateDescriptorSet(); virtual void create() = 0; diff --git a/src/Engine/Graphics/Initializer.h b/src/Engine/Graphics/Initializer.h index e7cbb6a..fc7000c 100644 --- a/src/Engine/Graphics/Initializer.h +++ b/src/Engine/Graphics/Initializer.h @@ -226,8 +226,6 @@ struct LegacyPipelineCreateInfo DepthStencilState depthStencilState; ColorBlendState colorBlend; LegacyPipelineCreateInfo(); - LegacyPipelineCreateInfo(LegacyPipelineCreateInfo&& rhs) = default; - LegacyPipelineCreateInfo& operator=(LegacyPipelineCreateInfo&& rhs) = default; ~LegacyPipelineCreateInfo(); }; @@ -243,8 +241,6 @@ struct MeshPipelineCreateInfo DepthStencilState depthStencilState; ColorBlendState colorBlend; MeshPipelineCreateInfo(); - MeshPipelineCreateInfo(MeshPipelineCreateInfo&& rhs) = default; - MeshPipelineCreateInfo& operator=(MeshPipelineCreateInfo&& rhs) = default; ~MeshPipelineCreateInfo(); }; struct ComputePipelineCreateInfo @@ -252,8 +248,6 @@ struct ComputePipelineCreateInfo Gfx::PComputeShader computeShader; Gfx::PPipelineLayout pipelineLayout; ComputePipelineCreateInfo(); - ComputePipelineCreateInfo(ComputePipelineCreateInfo&& rhs) = default; - ComputePipelineCreateInfo& operator=(ComputePipelineCreateInfo&& rhs) = default; ~ComputePipelineCreateInfo(); }; } // namespace Gfx diff --git a/src/Engine/Graphics/Metal/Command.h b/src/Engine/Graphics/Metal/Command.h index 2b43807..02fbf07 100644 --- a/src/Engine/Graphics/Metal/Command.h +++ b/src/Engine/Graphics/Metal/Command.h @@ -68,9 +68,10 @@ public: virtual void drawMesh(uint32 groupX, uint32 groupY, uint32 groupZ) override; private: + PGraphicsPipeline boundPipeline; + PIndexBuffer boundIndexBuffer; + MTL::Buffer* argumentBuffer; MTL::RenderCommandEncoder* encoder; - PIndexBuffer boundIndexBuffer; - PGraphicsPipeline boundPipeline; std::string name; }; DEFINE_REF(RenderCommand) @@ -90,6 +91,7 @@ private: PComputePipeline boundPipeline; MTL::CommandBuffer* commandBuffer; MTL::ComputeCommandEncoder* encoder; + MTL::Buffer* argumentBuffer; std::string name; }; DEFINE_REF(ComputeCommand) diff --git a/src/Engine/Graphics/Metal/Command.mm b/src/Engine/Graphics/Metal/Command.mm index cf9d0a4..14fd9e5 100644 --- a/src/Engine/Graphics/Metal/Command.mm +++ b/src/Engine/Graphics/Metal/Command.mm @@ -11,7 +11,6 @@ #include "Pipeline.h" #include "Resources.h" #include "Window.h" -#include using namespace Seele; using namespace Seele::Metal; @@ -123,7 +122,7 @@ void RenderCommand::drawIndexed(uint32 indexCount, uint32 instanceCount, int32 f void RenderCommand::drawMesh(uint32 groupX, uint32 groupY, uint32 groupZ) { // TODO: - encoder->drawMeshThreadgroups(MTL::Size(groupX, groupY, groupZ), MTL::Size(128, 128, 128), MTL::Size(32, 32, 32)); + encoder->drawMeshThreadgroups(MTL::Size(groupX, groupY, groupZ), MTL::Size(128, 1, 1), MTL::Size(32, 1, 1)); } ComputeCommand::ComputeCommand(MTL::CommandBuffer* cmdBuffer, const std::string& name) @@ -139,13 +138,15 @@ void ComputeCommand::end() { void ComputeCommand::bindPipeline(Gfx::PComputePipeline pipeline) { boundPipeline = pipeline.cast(); encoder->setComputePipelineState(boundPipeline->getHandle()); + argumentBuffer = boundPipeline->graphics->getDevice()->newBuffer(sizeof(uint64) * boundPipeline->getPipelineLayout()->getLayouts().size(), MTL::ResourceOptionCPUCacheModeDefault); } void ComputeCommand::bindDescriptor(Gfx::PDescriptorSet set) { auto metalSet = set.cast(); metalSet->bind(); uint32 parameterIndex = boundPipeline->getPipelineLayout()->findParameter(set->getLayout()->getName()); -encoder->setBuffer(metalSet->getBuffer(), 0, parameterIndex); + uint64* topLevelTable = (uint64*)argumentBuffer->contents(); + topLevelTable[parameterIndex] = metalSet->getBuffer()->gpuAddress(); auto bindings =metalSet->getLayout()->getBindings(); for(size_t i = 0; i < bindings.size(); ++i) { @@ -190,6 +191,7 @@ void ComputeCommand::pushConstants(Gfx::PPipelineLayout, Gfx::SeShaderStageFlags void ComputeCommand::dispatch(uint32 threadX, uint32 threadY, uint32 threadZ) { // TODO + encoder->setBuffer(argumentBuffer, 0, 2); encoder->dispatchThreadgroups(MTL::Size(threadX, threadY, threadZ), MTL::Size(32, 32, 1)); } diff --git a/src/Engine/Graphics/Metal/Descriptor.h b/src/Engine/Graphics/Metal/Descriptor.h index 2c9466f..d43055b 100644 --- a/src/Engine/Graphics/Metal/Descriptor.h +++ b/src/Engine/Graphics/Metal/Descriptor.h @@ -62,7 +62,7 @@ public: private: PGraphics graphics; PDescriptorPool owner; - MTL::Buffer* buffer; + MTL::Buffer* buffer = nullptr; MTL::ArgumentEncoder* encoder; Array boundResources; uint32 bindCount; diff --git a/src/Engine/Graphics/Metal/Descriptor.mm b/src/Engine/Graphics/Metal/Descriptor.mm index bc8e2f0..3226d1d 100644 --- a/src/Engine/Graphics/Metal/Descriptor.mm +++ b/src/Engine/Graphics/Metal/Descriptor.mm @@ -116,16 +116,14 @@ void DescriptorPool::reset() { DescriptorSet::DescriptorSet(PGraphics graphics, PDescriptorPool owner) : Gfx::DescriptorSet(owner->getLayout()), graphics(graphics), owner(owner), bindCount(0), currentlyInUse(false) { - // auto desc = (MTL::ArgumentDescriptor*)owner->getArguments()->object(0); - // std::cout << desc->access() << " " << desc->arrayLength() << " " << desc->index() << " " << desc->textureType() << - // " " << desc->dataType() << std::endl; - if (owner->getArguments()->count() == 0) { - buffer = graphics->getDevice()->newBuffer(0, MTL::ResourceOptionCPUCacheModeDefault); - } else { - boundResources.resize(owner->getArguments()->count()); - encoder = graphics->getDevice()->newArgumentEncoder(owner->getArguments()); - buffer = graphics->getDevice()->newBuffer(encoder->encodedLength(), MTL::ResourceOptionCPUCacheModeDefault); - encoder->setArgumentBuffer(buffer, 0); + if (owner->getArguments()->count() > 0) { + boundResources.resize(owner->getArguments()->count()); + encoder = graphics->getDevice()->newArgumentEncoder(owner->getArguments()); + buffer = graphics->getDevice()->newBuffer(encoder->encodedLength(), MTL::ResourceOptionCPUCacheModeDefault); + encoder->setArgumentBuffer(buffer, 0); + } else + { + buffer = graphics->getDevice()->newBuffer(8, MTL::ResourceOptionCPUCacheModeDefault); } } @@ -149,7 +147,13 @@ void DescriptorSet::updateSampler(uint32_t binding, Gfx::PSampler samplerState) } void DescriptorSet::updateTexture(uint32_t binding, Gfx::PTexture texture, Gfx::PSampler samplerState) { PTextureBase base = texture.cast(); - encoder->setTexture(base->getTexture(), binding); + if(layout->getBindings()[binding].access == Gfx::SE_DESCRIPTOR_ACCESS_READ_ONLY_BIT) + { + encoder->setTexture(base->getTexture(), binding); + + }else{ + encoder->setBuffer(base->getTexture()->buffer(), 0, binding); + } boundResources[binding] = base->getTexture(); } diff --git a/src/Engine/Graphics/Metal/Graphics.mm b/src/Engine/Graphics/Metal/Graphics.mm index cec352f..6ad4d08 100644 --- a/src/Engine/Graphics/Metal/Graphics.mm +++ b/src/Engine/Graphics/Metal/Graphics.mm @@ -31,7 +31,7 @@ void Graphics::init(GraphicsInitializer) queue = new CommandQueue(this); ioQueue = new IOCommandQueue(this); cache = new PipelineCache(this, "pipelines.metal"); - meshShadingEnabled = false; + meshShadingEnabled = true; } Gfx::OWindow Graphics::createWindow(const WindowCreateInfo &createInfo) diff --git a/src/Engine/Graphics/Metal/Pipeline.h b/src/Engine/Graphics/Metal/Pipeline.h index e3021ca..c6b16ae 100644 --- a/src/Engine/Graphics/Metal/Pipeline.h +++ b/src/Engine/Graphics/Metal/Pipeline.h @@ -31,8 +31,8 @@ public: virtual ~ComputePipeline(); constexpr MTL::ComputePipelineState* getHandle() const { return state; } -private: PGraphics graphics; +private: MTL::ComputePipelineState* state; }; DEFINE_REF(ComputePipeline) diff --git a/src/Engine/Graphics/Metal/Shader.mm b/src/Engine/Graphics/Metal/Shader.mm index efa18da..9251524 100644 --- a/src/Engine/Graphics/Metal/Shader.mm +++ b/src/Engine/Graphics/Metal/Shader.mm @@ -1,4 +1,5 @@ #include "Shader.h" +#include "Descriptor.h" #include "Foundation/NSError.hpp" #include "Foundation/NSString.hpp" #include "Graphics.h" @@ -6,7 +7,6 @@ #include "Graphics/slang-compile.h" #include "Metal/MTLDevice.hpp" #include "Metal/MTLLibrary.hpp" -#include "Descriptor.h" #include #include #include @@ -25,75 +25,83 @@ Shader::~Shader() { } void Shader::create(const ShaderCreateInfo& createInfo) { - Map test; + std::cout << "Compiling " << createInfo.name << std::endl; + Map test; Slang::ComPtr kernelBlob = generateShader(createInfo, SLANG_DXIL, test); hash = CRC::Calculate(kernelBlob->getBufferPointer(), kernelBlob->getBufferSize(), CRC::CRC_32()); IRCompiler* pCompiler = IRCompilerCreate(); - IRCompilerSetMinimumGPUFamily(pCompiler, IRGPUFamilyMetal3); - IRCompilerIgnoreRootSignature(pCompiler, true); + IRCompilerSetMinimumGPUFamily(pCompiler, IRGPUFamilyMetal3); + IRCompilerIgnoreRootSignature(pCompiler, true); IRCompilerSetEntryPointName(pCompiler, "main"); + IRCompilerSetValidationFlags(pCompiler, IRCompilerValidationFlagAll); IRObject* pDXIL = IRObjectCreateFromDXIL((const uint8*)kernelBlob->getBufferPointer(), kernelBlob->getBufferSize(), IRBytecodeOwnershipNone); - IRVersionedRootSignatureDescriptor descriptor; - descriptor.version = IRRootSignatureVersion_1_1; - Map layouts =createInfo.rootSignature->getLayouts(); - descriptor.desc_1_1.NumParameters = layouts.size(); - descriptor.desc_1_1.NumStaticSamplers = 0; - descriptor.desc_1_1.pStaticSamplers = nullptr; - Array parameters; - // each layout has an array for its bindings - Array> ranges; - for(const auto& [name, layout] : layouts) - { - uint32 textureReg = 0; // SRV - uint32 samplerReg = 0; // Sampler - uint32 uavReg = 0; // UAV - uint32 constantReg = 0; // CBV - auto& bindingRanges = ranges.add(); - for(auto binding : layout->getBindings()) - { - IRDescriptorRangeType type; - uint32 reg = 0; - switch(binding.descriptorType) - { - case Gfx::SE_DESCRIPTOR_TYPE_SAMPLED_IMAGE: - case Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER: - type = IRDescriptorRangeTypeSRV; - reg = textureReg++; - break; - case Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER: - case Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER: - type = IRDescriptorRangeTypeCBV; - reg = constantReg++; - break; - case Gfx::SE_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER: - case Gfx::SE_DESCRIPTOR_TYPE_STORAGE_IMAGE: - type = IRDescriptorRangeTypeUAV; - reg = uavReg++; - break; - default: throw std::logic_error("Not implemented"); - }; - bindingRanges.add() = IRDescriptorRange1{ - .BaseShaderRegister = reg, - .NumDescriptors = binding.descriptorCount, - .RangeType = type, - .RegisterSpace = createInfo.rootSignature->findParameter(name), - }; + IRVersionedRootSignatureDescriptor descriptor; + descriptor.version = IRRootSignatureVersion_1_1; + Map layouts = createInfo.rootSignature->getLayouts(); + descriptor.desc_1_1.NumParameters = layouts.size(); + descriptor.desc_1_1.NumStaticSamplers = 0; + descriptor.desc_1_1.pStaticSamplers = nullptr; + Array parameters; + // each layout has an array for its bindings + Array> ranges; + for (const auto& [name, layout] : layouts) { + uint32 textureReg = 0; // SRV + uint32 samplerReg = 0; // Sampler + uint32 uavReg = 0; // UAV + uint32 constantReg = 0; // CBV + auto& bindingRanges = ranges.add(); + for (auto binding : layout->getBindings()) { + IRDescriptorRangeType type; + uint32 reg = 0; + switch (binding.descriptorType) { + case Gfx::SE_DESCRIPTOR_TYPE_SAMPLED_IMAGE: + type = IRDescriptorRangeTypeSRV; + reg = textureReg++; + break; + case Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER: + case Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER: + type = IRDescriptorRangeTypeCBV; + reg = constantReg++; + break; + case Gfx::SE_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER: + case Gfx::SE_DESCRIPTOR_TYPE_STORAGE_IMAGE: + case Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER: + if (binding.access == Gfx::SE_DESCRIPTOR_ACCESS_READ_ONLY_BIT) { + type = IRDescriptorRangeTypeSRV; + reg = textureReg++; + break; + } else { + type = IRDescriptorRangeTypeUAV; + reg = uavReg++; + break; } - parameters.add() = IRRootParameter1{ - .ParameterType = IRRootParameterTypeDescriptorTable, - .DescriptorTable = IRRootDescriptorTable1{ .NumDescriptorRanges = (uint32)(bindingRanges.size()), bindingRanges.data() }, - .ShaderVisibility = IRShaderVisibilityAll, - }; + default: + throw std::logic_error("Not implemented"); + }; + bindingRanges.add() = IRDescriptorRange1{ + .BaseShaderRegister = reg, + .NumDescriptors = binding.descriptorCount, + .RangeType = type, + .RegisterSpace = createInfo.rootSignature->findParameter(name), + .Flags = IRDescriptorRangeFlagDescriptorsStaticKeepingBufferBoundsChecks, + }; } - IRError* signatureError = nullptr; - descriptor.desc_1_1.NumParameters = parameters.size(); - descriptor.desc_1_1.pParameters = parameters.data(); - IRRootSignature* rootSignature = IRRootSignatureCreateFromDescriptor(&descriptor, &signatureError); - assert(rootSignature); - IRCompilerSetGlobalRootSignature(pCompiler, rootSignature); - // Compile DXIL to Metal IR: + parameters.add() = IRRootParameter1{ + .ParameterType = IRRootParameterTypeDescriptorTable, + .DescriptorTable = + IRRootDescriptorTable1{.NumDescriptorRanges = (uint32)(bindingRanges.size()), bindingRanges.data()}, + .ShaderVisibility = IRShaderVisibilityAll, + }; + } + IRError* signatureError = nullptr; + descriptor.desc_1_1.NumParameters = parameters.size(); + descriptor.desc_1_1.pParameters = parameters.data(); + IRRootSignature* rootSignature = IRRootSignatureCreateFromDescriptor(&descriptor, &signatureError); + assert(rootSignature); + IRCompilerSetGlobalRootSignature(pCompiler, rootSignature); + // Compile DXIL to Metal IR: IRError* pError = nullptr; IRObject* pOutIR = IRCompilerAllocCompileAndLink(pCompiler, NULL, pDXIL, &pError); @@ -124,18 +132,16 @@ void Shader::create(const ShaderCreateInfo& createInfo) { IRObjectGetMetalLibBinary(pOutIR, irStage, pMetallib); dispatch_data_t data = IRMetalLibGetBytecodeData(pMetallib); - IRShaderReflection* reflection = IRShaderReflectionCreate(); - IRObjectGetReflection(pOutIR, irStage, reflection); - std::cout << " NumRes: " << IRShaderReflectionGetResourceCount(reflection) << std::endl; - std::cout << IRShaderReflectionAllocStringAndSerialize(reflection) << std::endl; - IRShaderReflectionDestroy(reflection); - + IRShaderReflection* reflection = IRShaderReflectionCreate(); + IRObjectGetReflection(pOutIR, irStage, reflection); + std::cout << IRShaderReflectionAllocStringAndSerialize(reflection) << std::endl; + IRShaderReflectionDestroy(reflection); + // Store the metallib to custom format or disk, or use to create a MTLLibrary. NS::Error* error; library = graphics->getDevice()->newLibrary(data, &error); function = library->newFunction(NS::String::string("main", NS::ASCIIStringEncoding)); - if(!function) - { + if (!function) { assert(false); } IRMetalLibBinaryDestroy(pMetallib); diff --git a/src/Engine/Graphics/Metal/Window.h b/src/Engine/Graphics/Metal/Window.h index 423faa2..42c18d6 100644 --- a/src/Engine/Graphics/Metal/Window.h +++ b/src/Engine/Graphics/Metal/Window.h @@ -51,7 +51,6 @@ private: CAMetalLayer* metalLayer; CA::MetalDrawable* drawable; OTexture2D backBuffer; - MTL::CaptureDescriptor* capture = nullptr; std::function keyCallback; std::function mouseMoveCallback; diff --git a/src/Engine/Graphics/Metal/Window.mm b/src/Engine/Graphics/Metal/Window.mm index f05fd13..834333e 100644 --- a/src/Engine/Graphics/Metal/Window.mm +++ b/src/Engine/Graphics/Metal/Window.mm @@ -94,17 +94,6 @@ Window::~Window() { glfwDestroyWindow(static_cast(windowHandle)); } void Window::pollInput() { glfwPollEvents(); } void Window::beginFrame() { - auto captureManager = MTL::CaptureManager::sharedCaptureManager(); - capture = MTL::CaptureDescriptor::alloc()->init(); - capture->setCaptureObject((__bridge id)graphics->getDevice()); - capture->setDestination(MTL::CaptureDestinationDeveloperTools); - capture->setOutputURL(NS::URL::fileURLWithPath(NS::String::string(fmt::format("frame{0}.trace", Gfx::getCurrentFrameIndex()).c_str(), NS::ASCIIStringEncoding))); - NS::Error* error; - captureManager->startCapture(capture, &error); - if(error) - { - std::cout << error->localizedDescription()->cString(NS::ASCIIStringEncoding) << std::endl; - } drawable = (__bridge CA::MetalDrawable*)[metalLayer nextDrawable]; createBackBuffer(); } @@ -112,7 +101,6 @@ void Window::beginFrame() { void Window::endFrame() { graphics->getQueue()->getCommands()->present(drawable); graphics->getQueue()->submitCommands(); - MTL::CaptureManager::sharedCaptureManager()->stopCapture(); currentFrameIndex++; } diff --git a/src/Engine/Graphics/RenderPass/BasePass.cpp b/src/Engine/Graphics/RenderPass/BasePass.cpp index f6b1310..0f9c1c2 100644 --- a/src/Engine/Graphics/RenderPass/BasePass.cpp +++ b/src/Engine/Graphics/RenderPass/BasePass.cpp @@ -49,16 +49,12 @@ void BasePass::render() Gfx::SE_ACCESS_SHADER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT, Gfx::SE_ACCESS_SHADER_READ_BIT, Gfx::SE_PIPELINE_STAGE_FRAGMENT_SHADER_BIT); - descriptorSets[INDEX_VIEW_PARAMS] = viewParamsSet; - descriptorSets[INDEX_LIGHT_ENV] = scene->getLightEnvironment()->getDescriptorSet(); - opaqueCulling->updateBuffer(0, oLightIndexList); opaqueCulling->updateTexture(1, oLightGrid); transparentCulling->updateBuffer(0, tLightIndexList); transparentCulling->updateTexture(1, tLightGrid); opaqueCulling->writeChanges(); transparentCulling->writeChanges(); - descriptorSets[INDEX_LIGHT_CULLING] = opaqueCulling; Gfx::ShaderPermutation permutation; if (graphics->supportMeshShading()) @@ -122,12 +118,14 @@ void BasePass::render() Gfx::PGraphicsPipeline pipeline = graphics->createGraphicsPipeline(std::move(pipelineInfo)); command->bindPipeline(pipeline); } - descriptorSets[INDEX_VERTEX_DATA] = vertexData->getVertexDataSet(); + command->bindDescriptor(vertexData->getVertexDataSet()); + command->bindDescriptor(viewParamsSet); + command->bindDescriptor(scene->getLightEnvironment()->getDescriptorSet()); + command->bindDescriptor(opaqueCulling); for (const auto& [_, instance] : materialData.instances) { - descriptorSets[INDEX_MATERIAL] = instance.materialInstance->getDescriptorSet(); - descriptorSets[INDEX_SCENE_DATA] = instance.descriptorSet; - command->bindDescriptor(descriptorSets); + command->bindDescriptor(instance.materialInstance->getDescriptorSet()); + command->bindDescriptor(instance.descriptorSet); if (graphics->supportMeshShading()) { command->drawMesh(instance.meshes.size(), 1, 1); @@ -166,9 +164,9 @@ void BasePass::publishOutputs() lightCullingLayout = graphics->createDescriptorLayout("pLightCullingData"); // oLightIndexList - lightCullingLayout->addDescriptorBinding(0, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER); + lightCullingLayout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = 0, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER,}); // oLightGrid - lightCullingLayout->addDescriptorBinding(1, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_IMAGE); + lightCullingLayout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = 1, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_IMAGE,}); lightCullingLayout->create(); basePassLayout->addDescriptorLayout(lightCullingLayout); diff --git a/src/Engine/Graphics/RenderPass/LightCullingPass.cpp b/src/Engine/Graphics/RenderPass/LightCullingPass.cpp index 5cd121c..2c3de74 100644 --- a/src/Engine/Graphics/RenderPass/LightCullingPass.cpp +++ b/src/Engine/Graphics/RenderPass/LightCullingPass.cpp @@ -100,19 +100,19 @@ void LightCullingPass::publishOutputs() cullingDescriptorLayout = graphics->createDescriptorLayout("pCullingParams"); //DepthTexture - cullingDescriptorLayout->addDescriptorBinding(0, Gfx::SE_DESCRIPTOR_TYPE_SAMPLED_IMAGE); + cullingDescriptorLayout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = 0, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_SAMPLED_IMAGE,}); //o_lightIndexCounter - cullingDescriptorLayout->addDescriptorBinding(1, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER); + cullingDescriptorLayout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = 1, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER, .access = Gfx::SE_DESCRIPTOR_ACCESS_READ_WRITE_BIT}); //t_lightIndexCounter - cullingDescriptorLayout->addDescriptorBinding(2, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER); + cullingDescriptorLayout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = 2, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER, .access = Gfx::SE_DESCRIPTOR_ACCESS_READ_WRITE_BIT}); //o_lightIndexList - cullingDescriptorLayout->addDescriptorBinding(3, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER); + cullingDescriptorLayout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = 3, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER, .access = Gfx::SE_DESCRIPTOR_ACCESS_READ_WRITE_BIT}); //t_lightIndexList - cullingDescriptorLayout->addDescriptorBinding(4, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER); + cullingDescriptorLayout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = 4, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER, .access = Gfx::SE_DESCRIPTOR_ACCESS_READ_WRITE_BIT}); //o_lightGrid - cullingDescriptorLayout->addDescriptorBinding(5, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_IMAGE); + cullingDescriptorLayout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = 5, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_IMAGE, .access = Gfx::SE_DESCRIPTOR_ACCESS_READ_WRITE_BIT}); //t_lightGrid - cullingDescriptorLayout->addDescriptorBinding(6, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_IMAGE); + cullingDescriptorLayout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = 6, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_IMAGE, .access = Gfx::SE_DESCRIPTOR_ACCESS_READ_WRITE_BIT}); lightEnv = scene->getLightEnvironment(); @@ -122,8 +122,10 @@ void LightCullingPass::publishOutputs() cullingLayout->addDescriptorLayout(cullingDescriptorLayout); cullingLayout->addDescriptorLayout(lightEnv->getDescriptorLayout()); Map mapping; - mapping["pViewParams"] = 0; - mapping["pDispatchParams"] = 1; + mapping["pViewParams"] = 1; + mapping["pDispatchParams"] = 2; + mapping["pCullingParams"] = 0; + mapping["pLightEnv"] = 3; cullingLayout->addMapping(mapping); cullingLayout->create(); @@ -209,8 +211,8 @@ void LightCullingPass::setupFrustums() dispatchParams.numThreadGroups = numThreadGroups; dispatchParamsLayout = graphics->createDescriptorLayout("pDispatchParams"); - dispatchParamsLayout->addDescriptorBinding(0, Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER); - dispatchParamsLayout->addDescriptorBinding(1, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER); + dispatchParamsLayout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = 0, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER, }); + dispatchParamsLayout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = 1, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER, .access = Gfx::SE_DESCRIPTOR_ACCESS_WRITE_ONLY_BIT }); frustumLayout = graphics->createPipelineLayout(); frustumLayout->addDescriptorLayout(viewParamsLayout); frustumLayout->addDescriptorLayout(dispatchParamsLayout); @@ -231,8 +233,8 @@ void LightCullingPass::setupFrustums() Gfx::ComputePipelineCreateInfo pipelineInfo; pipelineInfo.computeShader = frustumShader; - pipelineInfo.pipelineLayout = std::move(frustumLayout); - frustumPipeline = graphics->createComputePipeline(std::move(pipelineInfo)); + pipelineInfo.pipelineLayout = frustumLayout; + frustumPipeline = graphics->createComputePipeline(pipelineInfo); Gfx::OUniformBuffer frustumDispatchParamsBuffer = graphics->createUniformBuffer(UniformBufferCreateInfo{ .sourceData = { diff --git a/src/Engine/Graphics/RenderPass/RenderPass.cpp b/src/Engine/Graphics/RenderPass/RenderPass.cpp index c22a002..283cb7b 100644 --- a/src/Engine/Graphics/RenderPass/RenderPass.cpp +++ b/src/Engine/Graphics/RenderPass/RenderPass.cpp @@ -8,7 +8,7 @@ RenderPass::RenderPass(Gfx::PGraphics graphics, PScene scene) { viewParamsLayout = graphics->createDescriptorLayout("pViewParams"); - viewParamsLayout->addDescriptorBinding(0, Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER); + viewParamsLayout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = 0, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER,}); UniformBufferCreateInfo uniformInitializer = { .sourceData = { .size = sizeof(ViewParameter), @@ -56,5 +56,4 @@ void RenderPass::setResources(PRenderGraphResources _resources) void RenderPass::setViewport(Gfx::PViewport _viewport) { viewport = _viewport; - publishOutputs(); } diff --git a/src/Engine/Graphics/RenderPass/SkyboxRenderPass.cpp b/src/Engine/Graphics/RenderPass/SkyboxRenderPass.cpp index b7b78e5..db4b70c 100644 --- a/src/Engine/Graphics/RenderPass/SkyboxRenderPass.cpp +++ b/src/Engine/Graphics/RenderPass/SkyboxRenderPass.cpp @@ -75,12 +75,12 @@ void SkyboxRenderPass::endFrame() void SkyboxRenderPass::publishOutputs() { skyboxDataLayout = graphics->createDescriptorLayout("pSkyboxData"); - skyboxDataLayout->addDescriptorBinding(0, Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER); + skyboxDataLayout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = 0, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER,}); skyboxDataLayout->create(); textureLayout = graphics->createDescriptorLayout("pSkyboxTextures"); - textureLayout->addDescriptorBinding(0, Gfx::SE_DESCRIPTOR_TYPE_SAMPLED_IMAGE); - textureLayout->addDescriptorBinding(1, Gfx::SE_DESCRIPTOR_TYPE_SAMPLED_IMAGE); - textureLayout->addDescriptorBinding(2, Gfx::SE_DESCRIPTOR_TYPE_SAMPLER); + textureLayout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = 0, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_SAMPLED_IMAGE,}); + textureLayout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = 1, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_SAMPLED_IMAGE,}); + textureLayout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = 2, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_SAMPLER,}); textureLayout->create(); skyboxSampler = graphics->createSampler({}); diff --git a/src/Engine/Graphics/RenderPass/TextPass.cpp b/src/Engine/Graphics/RenderPass/TextPass.cpp index 7a1697e..9a15c8c 100644 --- a/src/Engine/Graphics/RenderPass/TextPass.cpp +++ b/src/Engine/Graphics/RenderPass/TextPass.cpp @@ -121,12 +121,12 @@ void TextPass::createRenderPass() createInfo.entryPoint = "fragmentMain"; fragmentShader = graphics->createFragmentShader(createInfo); generalLayout = graphics->createDescriptorLayout("pRender"); - generalLayout->addDescriptorBinding(0, Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER); - generalLayout->addDescriptorBinding(1, Gfx::SE_DESCRIPTOR_TYPE_SAMPLER); + generalLayout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = 0, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER,}); + generalLayout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = 1, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_SAMPLER,}); generalLayout->create(); textureArrayLayout = graphics->createDescriptorLayout("pGlyphTextures"); - textureArrayLayout->addDescriptorBinding(0, Gfx::SE_DESCRIPTOR_TYPE_SAMPLED_IMAGE, Gfx::SE_IMAGE_VIEW_TYPE_2D_ARRAY, 256, Gfx::SE_DESCRIPTOR_BINDING_VARIABLE_DESCRIPTOR_COUNT_BIT); + textureArrayLayout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = 0, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_SAMPLED_IMAGE, .textureType = Gfx::SE_IMAGE_VIEW_TYPE_2D_ARRAY, .descriptorCount = 256, .bindingFlags = Gfx::SE_DESCRIPTOR_BINDING_VARIABLE_DESCRIPTOR_COUNT_BIT,}); textureArrayLayout->create(); projectionBuffer = graphics->createUniformBuffer({ diff --git a/src/Engine/Graphics/RenderPass/UIPass.cpp b/src/Engine/Graphics/RenderPass/UIPass.cpp index f36e96a..ef69205 100644 --- a/src/Engine/Graphics/RenderPass/UIPass.cpp +++ b/src/Engine/Graphics/RenderPass/UIPass.cpp @@ -107,10 +107,10 @@ void UIPass::createRenderPass() fragmentShader = graphics->createFragmentShader(createInfo); descriptorLayout = graphics->createDescriptorLayout("pParams"); - descriptorLayout->addDescriptorBinding(0, Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER); - descriptorLayout->addDescriptorBinding(1, Gfx::SE_DESCRIPTOR_TYPE_SAMPLER); - descriptorLayout->addDescriptorBinding(2, Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER); - descriptorLayout->addDescriptorBinding(3, Gfx::SE_DESCRIPTOR_TYPE_SAMPLED_IMAGE, Gfx::SE_IMAGE_VIEW_TYPE_2D_ARRAY, 256, Gfx::SE_DESCRIPTOR_BINDING_VARIABLE_DESCRIPTOR_COUNT_BIT | Gfx::SE_DESCRIPTOR_BINDING_PARTIALLY_BOUND_BIT); + descriptorLayout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = 0, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER,}); + descriptorLayout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = 1, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_SAMPLER,}); + descriptorLayout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = 2, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER,}); + descriptorLayout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = 3, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_SAMPLED_IMAGE, .textureType = Gfx::SE_IMAGE_VIEW_TYPE_2D_ARRAY, .descriptorCount = 256, .bindingFlags = Gfx::SE_DESCRIPTOR_BINDING_VARIABLE_DESCRIPTOR_COUNT_BIT | Gfx::SE_DESCRIPTOR_BINDING_PARTIALLY_BOUND_BIT,}); descriptorLayout->create(); Matrix4 projectionMatrix = glm::ortho(0, 1, 1, 0); diff --git a/src/Engine/Graphics/Shader.cpp b/src/Engine/Graphics/Shader.cpp index 4a04ba5..aa0838f 100644 --- a/src/Engine/Graphics/Shader.cpp +++ b/src/Engine/Graphics/Shader.cpp @@ -81,6 +81,14 @@ void ShaderCompiler::compile() layout->addDescriptorLayout(vd->getVertexDataLayout()); layout->addDescriptorLayout(vd->getInstanceDataLayout()); layout->addDescriptorLayout(mat->getDescriptorLayout()); + Map mapping; + mapping["pLightCullingData"] = 1; + mapping["pMaterial"] = 2; + mapping["pViewParams"] = 3; + mapping["pVertexData"] = 4; + mapping["pScene"] = 5; + mapping["pLightEnv"] = 6; + layout->addMapping(mapping); permutation.setMaterial(mat->getName()); createShaders(permutation, std::move(layout)); } diff --git a/src/Engine/Graphics/StaticMeshVertexData.cpp b/src/Engine/Graphics/StaticMeshVertexData.cpp index 4128cf2..8a22654 100644 --- a/src/Engine/Graphics/StaticMeshVertexData.cpp +++ b/src/Engine/Graphics/StaticMeshVertexData.cpp @@ -117,12 +117,12 @@ void StaticMeshVertexData::init(Gfx::PGraphics _graphics) { VertexData::init(_graphics); descriptorLayout = _graphics->createDescriptorLayout("pVertexData"); - descriptorLayout->addDescriptorBinding(0, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER); - descriptorLayout->addDescriptorBinding(1, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER); - descriptorLayout->addDescriptorBinding(2, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER); - descriptorLayout->addDescriptorBinding(3, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER); - descriptorLayout->addDescriptorBinding(4, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER); - descriptorLayout->addDescriptorBinding(5, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER); + descriptorLayout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = 0, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER}); + descriptorLayout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = 1, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER}); + descriptorLayout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = 2, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER}); + descriptorLayout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = 3, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER}); + descriptorLayout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = 4, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER}); + descriptorLayout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = 5, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER}); descriptorLayout->create(); descriptorSet = descriptorLayout->allocateDescriptorSet(); } diff --git a/src/Engine/Graphics/VertexData.cpp b/src/Engine/Graphics/VertexData.cpp index c8cb06a..69df8fe 100644 --- a/src/Engine/Graphics/VertexData.cpp +++ b/src/Engine/Graphics/VertexData.cpp @@ -265,16 +265,16 @@ void Seele::VertexData::init(Gfx::PGraphics _graphics) graphics = _graphics; verticesAllocated = NUM_DEFAULT_ELEMENTS; instanceDataLayout = graphics->createDescriptorLayout("pScene"); - instanceDataLayout->addDescriptorBinding(0, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER); + instanceDataLayout->addDescriptorBinding(Gfx::DescriptorBinding{.binding =0, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER,}); // meshData - instanceDataLayout->addDescriptorBinding(1, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER); + instanceDataLayout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = 1, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER,}); // meshletData - instanceDataLayout->addDescriptorBinding(2, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER); + instanceDataLayout->addDescriptorBinding(Gfx::DescriptorBinding{.binding =2, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER}); // primitiveIndices - instanceDataLayout->addDescriptorBinding(3, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER); + instanceDataLayout->addDescriptorBinding(Gfx::DescriptorBinding{.binding =3, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER}); // vetexIndices - instanceDataLayout->addDescriptorBinding(4, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER); + instanceDataLayout->addDescriptorBinding(Gfx::DescriptorBinding{.binding =4, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER}); instanceDataLayout->create(); resizeBuffers(); diff --git a/src/Engine/Material/Material.cpp b/src/Engine/Material/Material.cpp index 6de6868..0b6f4c9 100644 --- a/src/Engine/Material/Material.cpp +++ b/src/Engine/Material/Material.cpp @@ -106,7 +106,7 @@ void Material::load(ArchiveBuffer& buffer) Gfx::SeShaderStageFlags shaderStages; Serialization::load(buffer, shaderStages); - layout->addDescriptorBinding(binding, descriptorType, textureType, descriptorCount, bindingFlags, shaderStages); + layout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = binding, .descriptorType = descriptorType, .textureType = textureType, .descriptorCount = descriptorCount, .bindingFlags = bindingFlags, .shaderStages = shaderStages,}); } layout->create(); } diff --git a/src/Engine/Scene/LightEnvironment.cpp b/src/Engine/Scene/LightEnvironment.cpp index 6065d05..b5cd04c 100644 --- a/src/Engine/Scene/LightEnvironment.cpp +++ b/src/Engine/Scene/LightEnvironment.cpp @@ -7,9 +7,9 @@ LightEnvironment::LightEnvironment(Gfx::PGraphics graphics) : graphics(graphics) { layout = graphics->createDescriptorLayout("pLightEnv"); - layout->addDescriptorBinding(0, Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER); - layout->addDescriptorBinding(1, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER); - layout->addDescriptorBinding(2, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER); + layout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = 0, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER,}); + layout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = 1, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER,}); + layout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = 2, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER,}); layout->create(); lightEnvBuffer = graphics->createUniformBuffer(UniformBufferCreateInfo{ .sourceData = { diff --git a/vcpkg.json b/vcpkg.json index e07c93c..a84c309 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -13,7 +13,6 @@ "gtest", "vulkan-memory-allocator", "shader-slang", - "spirv-cross", "glslang" ] } \ No newline at end of file