Trying to get metal backend to run
This commit is contained in:
+2
-3
@@ -13,7 +13,6 @@ set(BUILD_SHARED_LIBS OFF)
|
|||||||
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
|
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
|
||||||
|
|
||||||
set(VCPKG_INSTALL_OPTIONS "--allow-unsupported")
|
set(VCPKG_INSTALL_OPTIONS "--allow-unsupported")
|
||||||
set(VCPKG_BUILD_TYPE release)
|
|
||||||
|
|
||||||
set(ENGINE_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/src/Engine)
|
set(ENGINE_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/src/Engine)
|
||||||
set(EXTERNAL_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/external)
|
set(EXTERNAL_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/external)
|
||||||
@@ -25,7 +24,7 @@ set(METAL_ROOT ${EXTERNAL_ROOT}/metal-cpp)
|
|||||||
if(WIN32)
|
if(WIN32)
|
||||||
set(VCPKG_BASE_FOLDER ${CMAKE_BINARY_DIR}/vcpkg_installed/x64-windows/)
|
set(VCPKG_BASE_FOLDER ${CMAKE_BINARY_DIR}/vcpkg_installed/x64-windows/)
|
||||||
elseif(APPLE)
|
elseif(APPLE)
|
||||||
set(VCPKG_BASE_FOLDER ${CMAKE_CURRENT_SOURCE_DIR}/build/vcpkg_installed/arm64-osx/)
|
set(VCPKG_BASE_FOLDER ${CMAKE_BINARY_DIR}/vcpkg_installed/arm64-osx/)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(Boost_NO_WARN_NEW_VERSIONS 1)
|
set(Boost_NO_WARN_NEW_VERSIONS 1)
|
||||||
@@ -78,7 +77,7 @@ target_link_libraries(Engine PUBLIC GPUOpen::VulkanMemoryAllocator)
|
|||||||
if(WIN32)
|
if(WIN32)
|
||||||
target_link_libraries(Engine PUBLIC ${VCPKG_BASE_FOLDER}/lib/slang.lib)
|
target_link_libraries(Engine PUBLIC ${VCPKG_BASE_FOLDER}/lib/slang.lib)
|
||||||
elseif(APPLE)
|
elseif(APPLE)
|
||||||
target_link_libraries(Engine PUBLIC ${VCPKG_BASE_FOLDER}/lib/libslang.dylib)
|
target_link_libraries(Engine PUBLIC ${VCPKG_BASE_FOLDER}/debug/lib/libslang.dylib)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(APPLE)
|
if(APPLE)
|
||||||
|
|||||||
Vendored
+1
-1
Submodule external/vcpkg updated: f9a99aa79c...0bf1354d67
@@ -133,15 +133,17 @@ void EnvironmentLoader::import(EnvironmentImportArgs args, PEnvironmentMapAsset
|
|||||||
Gfx::SE_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
|
Gfx::SE_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
|
||||||
Gfx::SE_ATTACHMENT_LOAD_OP_DONT_CARE, Gfx::SE_ATTACHMENT_STORE_OP_STORE)},
|
Gfx::SE_ATTACHMENT_LOAD_OP_DONT_CARE, Gfx::SE_ATTACHMENT_STORE_OP_STORE)},
|
||||||
},
|
},
|
||||||
{
|
{Gfx::SubPassDependency{
|
||||||
Gfx::SubPassDependency{
|
|
||||||
.srcSubpass = 0,
|
.srcSubpass = 0,
|
||||||
.dstSubpass = ~0U,
|
.dstSubpass = ~0U,
|
||||||
.srcStage = Gfx::SE_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
|
.srcStage = Gfx::SE_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
|
||||||
.dstStage = Gfx::SE_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
|
.dstStage = Gfx::SE_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
|
||||||
.srcAccess = Gfx::SE_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
|
.srcAccess = Gfx::SE_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
|
||||||
.dstAccess = Gfx::SE_ACCESS_SHADER_READ_BIT,
|
.dstAccess = Gfx::SE_ACCESS_SHADER_READ_BIT,
|
||||||
}
|
}},
|
||||||
|
{
|
||||||
|
.offset = {0, 0},
|
||||||
|
.size = {SOURCE_RESOLUTION, SOURCE_RESOLUTION},
|
||||||
},
|
},
|
||||||
"EnvironmentRenderPass", {0b111111}, {0b111111});
|
"EnvironmentRenderPass", {0b111111}, {0b111111});
|
||||||
cubeRenderPipeline = graphics->createGraphicsPipeline(Gfx::LegacyPipelineCreateInfo{
|
cubeRenderPipeline = graphics->createGraphicsPipeline(Gfx::LegacyPipelineCreateInfo{
|
||||||
@@ -176,6 +178,10 @@ void EnvironmentLoader::import(EnvironmentImportArgs args, PEnvironmentMapAsset
|
|||||||
Gfx::SE_ATTACHMENT_LOAD_OP_DONT_CARE, Gfx::SE_ATTACHMENT_STORE_OP_STORE)},
|
Gfx::SE_ATTACHMENT_LOAD_OP_DONT_CARE, Gfx::SE_ATTACHMENT_STORE_OP_STORE)},
|
||||||
},
|
},
|
||||||
{},
|
{},
|
||||||
|
{
|
||||||
|
.offset = {0, 0},
|
||||||
|
.size = {CONVOLUTED_RESOLUTION, CONVOLUTED_RESOLUTION},
|
||||||
|
},
|
||||||
"EnvironmentRenderPass", {0b111111}, {0b111111});
|
"EnvironmentRenderPass", {0b111111}, {0b111111});
|
||||||
convolutionPipeline = graphics->createGraphicsPipeline(Gfx::LegacyPipelineCreateInfo{
|
convolutionPipeline = graphics->createGraphicsPipeline(Gfx::LegacyPipelineCreateInfo{
|
||||||
.vertexShader = cubeRenderVertex,
|
.vertexShader = cubeRenderVertex,
|
||||||
|
|||||||
+9
-2
@@ -9,8 +9,8 @@
|
|||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
#include "Graphics/Metal/Graphics.h"
|
#include "Graphics/Metal/Graphics.h"
|
||||||
#else
|
#else
|
||||||
#include "Graphics/Vulkan/Graphics.h"
|
|
||||||
#endif
|
#endif
|
||||||
|
#include "Graphics/Vulkan/Graphics.h"
|
||||||
#include "Graphics/StaticMeshVertexData.h"
|
#include "Graphics/StaticMeshVertexData.h"
|
||||||
#include "Window/InspectorView.h"
|
#include "Window/InspectorView.h"
|
||||||
#include "Window/PlayView.h"
|
#include "Window/PlayView.h"
|
||||||
@@ -28,7 +28,14 @@ int main() {
|
|||||||
std::string gameName = "MinecraftClone";
|
std::string gameName = "MinecraftClone";
|
||||||
std::filesystem::path outputPath = fmt::format("../../{0}Game", gameName);
|
std::filesystem::path outputPath = fmt::format("../../{0}Game", gameName);
|
||||||
std::filesystem::path sourcePath = fmt::format("../../{0}", gameName);
|
std::filesystem::path sourcePath = fmt::format("../../{0}", gameName);
|
||||||
std::filesystem::path binaryPath = sourcePath / "bin" / fmt::format("{0}.dll", gameName);
|
#ifdef WIN32
|
||||||
|
std::string libraryEnding = "dll";
|
||||||
|
#elif __APPLE__
|
||||||
|
std::string libraryEnding = "dylib";
|
||||||
|
#else
|
||||||
|
std::string libraryEnding = "so";
|
||||||
|
#endif
|
||||||
|
std::filesystem::path binaryPath = sourcePath / "bin" / fmt::format("{}.{}", gameName, libraryEnding);
|
||||||
std::filesystem::path cmakePath = outputPath / "cmake";
|
std::filesystem::path cmakePath = outputPath / "cmake";
|
||||||
if (true) {
|
if (true) {
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ class Graphics {
|
|||||||
virtual OWindow createWindow(const WindowCreateInfo& createInfo) = 0;
|
virtual OWindow createWindow(const WindowCreateInfo& createInfo) = 0;
|
||||||
virtual OViewport createViewport(PWindow owner, const ViewportCreateInfo& createInfo) = 0;
|
virtual OViewport createViewport(PWindow owner, const ViewportCreateInfo& createInfo) = 0;
|
||||||
|
|
||||||
virtual ORenderPass createRenderPass(RenderTargetLayout layout, Array<SubPassDependency> dependencies,
|
virtual ORenderPass createRenderPass(RenderTargetLayout layout, Array<SubPassDependency> dependencies, URect renderArea,
|
||||||
std::string name = "", Array<uint32> viewMasks = {0}, Array<uint32> correlationMasks = {}) = 0;
|
std::string name = "", Array<uint32> viewMasks = {0}, Array<uint32> correlationMasks = {}) = 0;
|
||||||
virtual void beginRenderPass(PRenderPass renderPass) = 0;
|
virtual void beginRenderPass(PRenderPass renderPass) = 0;
|
||||||
virtual void endRenderPass() = 0;
|
virtual void endRenderPass() = 0;
|
||||||
|
|||||||
@@ -319,6 +319,7 @@ CommandQueue::CommandQueue(PGraphics graphics) : graphics(graphics) {
|
|||||||
MTL::CommandBufferDescriptor* descriptor = MTL::CommandBufferDescriptor::alloc()->init();
|
MTL::CommandBufferDescriptor* descriptor = MTL::CommandBufferDescriptor::alloc()->init();
|
||||||
descriptor->setErrorOptions(MTL::CommandBufferErrorOptionEncoderExecutionStatus);
|
descriptor->setErrorOptions(MTL::CommandBufferErrorOptionEncoderExecutionStatus);
|
||||||
activeCommand = new Command(graphics, queue->commandBuffer(descriptor));
|
activeCommand = new Command(graphics, queue->commandBuffer(descriptor));
|
||||||
|
activeCommand->begin();
|
||||||
descriptor->release();
|
descriptor->release();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -353,7 +354,7 @@ void CommandQueue::executeCommands(Array<Gfx::OComputeCommand> commands) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CommandQueue::submitCommands(PEvent signalSemaphore) {
|
void CommandQueue::submitCommands(PEvent signalSemaphore) {
|
||||||
/*activeCommand->getHandle()->addCompletedHandler(MTL::CommandBufferHandler([&](MTL::CommandBuffer* cmdBuffer) {
|
activeCommand->getHandle()->addCompletedHandler(MTL::CommandBufferHandler([&](MTL::CommandBuffer* cmdBuffer) {
|
||||||
for (auto it = pendingCommands.begin(); it != pendingCommands.end(); it++) {
|
for (auto it = pendingCommands.begin(); it != pendingCommands.end(); it++) {
|
||||||
if ((*it)->getHandle() == cmdBuffer) {
|
if ((*it)->getHandle() == cmdBuffer) {
|
||||||
auto& cmd = *it;
|
auto& cmd = *it;
|
||||||
@@ -380,12 +381,7 @@ void CommandQueue::submitCommands(PEvent signalSemaphore) {
|
|||||||
activeCommand->begin();
|
activeCommand->begin();
|
||||||
activeCommand->waitForEvent(prevCmdEvent);
|
activeCommand->waitForEvent(prevCmdEvent);
|
||||||
descriptor->release();
|
descriptor->release();
|
||||||
}*/
|
}
|
||||||
activeCommand->end();
|
|
||||||
activeCommand->waitDeviceIdle();
|
|
||||||
activeCommand->reset();
|
|
||||||
activeCommand = new Command(graphics, queue->commandBuffer());
|
|
||||||
activeCommand->begin();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
IOCommandQueue::IOCommandQueue(PGraphics graphics) : graphics(graphics) {
|
IOCommandQueue::IOCommandQueue(PGraphics graphics) : graphics(graphics) {
|
||||||
|
|||||||
@@ -70,9 +70,7 @@ class DescriptorSet : public Gfx::DescriptorSet, public CommandBoundResource {
|
|||||||
virtual void updateBuffer(const std::string& name, uint32 index, Gfx::PVertexBuffer uniformBuffer) override;
|
virtual void updateBuffer(const std::string& name, uint32 index, Gfx::PVertexBuffer uniformBuffer) override;
|
||||||
virtual void updateBuffer(const std::string& name, uint32 index, Gfx::PIndexBuffer uniformBuffer) override;
|
virtual void updateBuffer(const std::string& name, uint32 index, Gfx::PIndexBuffer uniformBuffer) override;
|
||||||
virtual void updateSampler(const std::string& name, uint32 index, Gfx::PSampler samplerState) override;
|
virtual void updateSampler(const std::string& name, uint32 index, Gfx::PSampler samplerState) override;
|
||||||
virtual void updateTexture(const std::string& name, uint32 index, Gfx::PTexture2D texture) override;
|
virtual void updateTexture(const std::string& name, uint32 index, Gfx::PTexture texture) override;
|
||||||
virtual void updateTexture(const std::string& name, uint32 index, Gfx::PTexture3D texture) override;
|
|
||||||
virtual void updateTexture(const std::string& name, uint32 index, Gfx::PTextureCube texture) override;
|
|
||||||
virtual void updateAccelerationStructure(const std::string& name, uint32 index, Gfx::PTopLevelAS as) override;
|
virtual void updateAccelerationStructure(const std::string& name, uint32 index, Gfx::PTopLevelAS as) override;
|
||||||
|
|
||||||
constexpr bool isPlainDescriptor() const { return owner->getLayout()->isPlainDescriptor(); }
|
constexpr bool isPlainDescriptor() const { return owner->getLayout()->isPlainDescriptor(); }
|
||||||
|
|||||||
@@ -152,29 +152,7 @@ void DescriptorSet::updateSampler(const std::string& name, uint32 index, Gfx::PS
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void DescriptorSet::updateTexture(const std::string& name, uint32 index, Gfx::PTexture2D texture) {
|
void DescriptorSet::updateTexture(const std::string& name, uint32 index, Gfx::PTexture texture) {
|
||||||
uint32 flattenedIndex = owner->getLayout()->variableMapping[name].index + index;
|
|
||||||
PTextureBase tex = texture.cast<TextureBase>();
|
|
||||||
textureWrites.add(TextureWriteInfo{
|
|
||||||
.index = flattenedIndex,
|
|
||||||
.texture = tex->getHandle(),
|
|
||||||
.access = owner->getLayout()->variableMapping[name].access,
|
|
||||||
});
|
|
||||||
boundResources.add(tex->getHandle());
|
|
||||||
}
|
|
||||||
|
|
||||||
void DescriptorSet::updateTexture(const std::string& name, uint32 index, Gfx::PTexture3D texture) {
|
|
||||||
uint32 flattenedIndex = owner->getLayout()->variableMapping[name].index + index;
|
|
||||||
PTextureBase tex = texture.cast<TextureBase>();
|
|
||||||
textureWrites.add(TextureWriteInfo{
|
|
||||||
.index = flattenedIndex,
|
|
||||||
.texture = tex->getHandle(),
|
|
||||||
.access = owner->getLayout()->variableMapping[name].access,
|
|
||||||
});
|
|
||||||
boundResources.add(tex->getHandle());
|
|
||||||
}
|
|
||||||
|
|
||||||
void DescriptorSet::updateTexture(const std::string& name, uint32 index, Gfx::PTextureCube texture) {
|
|
||||||
uint32 flattenedIndex = owner->getLayout()->variableMapping[name].index + index;
|
uint32 flattenedIndex = owner->getLayout()->variableMapping[name].index + index;
|
||||||
PTextureBase tex = texture.cast<TextureBase>();
|
PTextureBase tex = texture.cast<TextureBase>();
|
||||||
textureWrites.add(TextureWriteInfo{
|
textureWrites.add(TextureWriteInfo{
|
||||||
|
|||||||
@@ -17,8 +17,7 @@ class Graphics : public Gfx::Graphics {
|
|||||||
virtual Gfx::OWindow createWindow(const WindowCreateInfo& createInfo) override;
|
virtual Gfx::OWindow createWindow(const WindowCreateInfo& createInfo) override;
|
||||||
virtual Gfx::OViewport createViewport(Gfx::PWindow owner, const ViewportCreateInfo& createInfo) override;
|
virtual Gfx::OViewport createViewport(Gfx::PWindow owner, const ViewportCreateInfo& createInfo) override;
|
||||||
|
|
||||||
virtual Gfx::ORenderPass createRenderPass(Gfx::RenderTargetLayout layout, Array<Gfx::SubPassDependency> dependencies,
|
virtual Gfx::ORenderPass createRenderPass(Gfx::RenderTargetLayout layout, Array<Gfx::SubPassDependency> dependencies, URect renderArea, std::string name, Array<uint32> viewMasks, Array<uint32> correlationMasks) override;
|
||||||
Gfx::PViewport renderArea, std::string name = "") override;
|
|
||||||
virtual void beginRenderPass(Gfx::PRenderPass renderPass) override;
|
virtual void beginRenderPass(Gfx::PRenderPass renderPass) override;
|
||||||
virtual void endRenderPass() override;
|
virtual void endRenderPass() override;
|
||||||
virtual void waitDeviceIdle() override;
|
virtual void waitDeviceIdle() override;
|
||||||
|
|||||||
@@ -38,8 +38,7 @@ Gfx::OViewport Graphics::createViewport(Gfx::PWindow owner, const ViewportCreate
|
|||||||
return new Viewport(owner, createInfo);
|
return new Viewport(owner, createInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
Gfx::ORenderPass Graphics::createRenderPass(Gfx::RenderTargetLayout layout, Array<Gfx::SubPassDependency> dependencies,
|
Gfx::ORenderPass Graphics::createRenderPass(Gfx::RenderTargetLayout layout, Array<Gfx::SubPassDependency> dependencies, URect renderArea, std::string name, Array<uint32> viewMask, Array<uint32> correlationMask) {
|
||||||
Gfx::PViewport renderArea, std::string name) {
|
|
||||||
return new RenderPass(this, layout, dependencies, renderArea, name);
|
return new RenderPass(this, layout, dependencies, renderArea, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ namespace Metal {
|
|||||||
DECLARE_REF(Graphics)
|
DECLARE_REF(Graphics)
|
||||||
class RenderPass : public Gfx::RenderPass {
|
class RenderPass : public Gfx::RenderPass {
|
||||||
public:
|
public:
|
||||||
RenderPass(PGraphics graphics, Gfx::RenderTargetLayout layout, Array<Gfx::SubPassDependency> dependencies, Gfx::PViewport viewport,
|
RenderPass(PGraphics graphics, Gfx::RenderTargetLayout layout, Array<Gfx::SubPassDependency> dependencies, URect viewport,
|
||||||
const std::string& name = "");
|
const std::string& name = "");
|
||||||
virtual ~RenderPass();
|
virtual ~RenderPass();
|
||||||
void updateRenderPass();
|
void updateRenderPass();
|
||||||
@@ -16,7 +16,7 @@ class RenderPass : public Gfx::RenderPass {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
PGraphics graphics;
|
PGraphics graphics;
|
||||||
Gfx::PViewport viewport;
|
URect renderArea;
|
||||||
MTL::RenderPassDescriptor* renderPass;
|
MTL::RenderPassDescriptor* renderPass;
|
||||||
std::string name;
|
std::string name;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -8,13 +8,12 @@ using namespace Seele;
|
|||||||
using namespace Seele::Metal;
|
using namespace Seele::Metal;
|
||||||
|
|
||||||
RenderPass::RenderPass(PGraphics graphics, Gfx::RenderTargetLayout _layout, Array<Gfx::SubPassDependency> dependencies,
|
RenderPass::RenderPass(PGraphics graphics, Gfx::RenderTargetLayout _layout, Array<Gfx::SubPassDependency> dependencies,
|
||||||
Gfx::PViewport viewport, const std::string& name)
|
URect renderArea, const std::string& name)
|
||||||
: Gfx::RenderPass(std::move(_layout), dependencies), graphics(graphics), viewport(viewport), name(name) {
|
: Gfx::RenderPass(std::move(_layout), dependencies), graphics(graphics), renderArea(renderArea), name(name) {
|
||||||
renderPass = MTL::RenderPassDescriptor::renderPassDescriptor();
|
renderPass = MTL::RenderPassDescriptor::renderPassDescriptor();
|
||||||
renderPass->setRenderTargetArrayLength(1);
|
renderPass->setRenderTargetArrayLength(1);
|
||||||
renderPass->setRenderTargetWidth(viewport->getWidth());
|
renderPass->setRenderTargetWidth(renderArea.size.x);
|
||||||
renderPass->setRenderTargetHeight(viewport->getHeight());
|
renderPass->setRenderTargetHeight(renderArea.size.y);
|
||||||
renderPass->setDefaultRasterSampleCount(viewport->getSamples());
|
|
||||||
|
|
||||||
for (size_t i = 0; i < layout.colorAttachments.size(); ++i) {
|
for (size_t i = 0; i < layout.colorAttachments.size(); ++i) {
|
||||||
const auto& color = layout.colorAttachments[i];
|
const auto& color = layout.colorAttachments[i];
|
||||||
|
|||||||
@@ -94,7 +94,9 @@ void TextureHandle::generateMipmaps() {}
|
|||||||
TextureBase::TextureBase(PGraphics graphics, MTL::TextureType viewType, const TextureCreateInfo& createInfo, MTL::Texture* existingImage)
|
TextureBase::TextureBase(PGraphics graphics, MTL::TextureType viewType, const TextureCreateInfo& createInfo, MTL::Texture* existingImage)
|
||||||
: handle(new TextureHandle(graphics, viewType, createInfo, existingImage)), graphics(graphics) {}
|
: handle(new TextureHandle(graphics, viewType, createInfo, existingImage)), graphics(graphics) {}
|
||||||
|
|
||||||
TextureBase::~TextureBase() {}
|
TextureBase::~TextureBase() {
|
||||||
|
graphics->getDestructionManager()->queueResourceForDestruction(std::move(handle));
|
||||||
|
}
|
||||||
|
|
||||||
void TextureBase::pipelineBarrier(Gfx::SeAccessFlags srcAccess, Gfx::SePipelineStageFlags srcStage, Gfx::SeAccessFlags dstAccess,
|
void TextureBase::pipelineBarrier(Gfx::SeAccessFlags srcAccess, Gfx::SePipelineStageFlags srcStage, Gfx::SeAccessFlags dstAccess,
|
||||||
Gfx::SePipelineStageFlags dstStage) {
|
Gfx::SePipelineStageFlags dstStage) {
|
||||||
|
|||||||
@@ -472,7 +472,7 @@ void BasePass::createRenderPass() {
|
|||||||
Gfx::SE_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
|
Gfx::SE_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
renderPass = graphics->createRenderPass(std::move(layout), std::move(dependency), "BasePass");
|
renderPass = graphics->createRenderPass(std::move(layout), std::move(dependency), viewport->getRenderArea(), "BasePass");
|
||||||
oLightIndexList = resources->requestBuffer("LIGHTCULLING_OLIGHTLIST");
|
oLightIndexList = resources->requestBuffer("LIGHTCULLING_OLIGHTLIST");
|
||||||
tLightIndexList = resources->requestBuffer("LIGHTCULLING_TLIGHTLIST");
|
tLightIndexList = resources->requestBuffer("LIGHTCULLING_TLIGHTLIST");
|
||||||
oLightGrid = resources->requestTexture("LIGHTCULLING_OLIGHTGRID");
|
oLightGrid = resources->requestTexture("LIGHTCULLING_OLIGHTGRID");
|
||||||
|
|||||||
@@ -203,5 +203,5 @@ void CachedDepthPass::createRenderPass() {
|
|||||||
Gfx::SE_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
|
Gfx::SE_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
renderPass = graphics->createRenderPass(std::move(layout), std::move(dependency), "CachedDepthPass");
|
renderPass = graphics->createRenderPass(std::move(layout), std::move(dependency), viewport->getRenderArea(), "CachedDepthPass");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -306,5 +306,5 @@ void DepthCullingPass::createRenderPass() {
|
|||||||
Gfx::SE_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
|
Gfx::SE_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
renderPass = graphics->createRenderPass(std::move(layout), std::move(dependency), "DepthCullingPass");
|
renderPass = graphics->createRenderPass(std::move(layout), std::move(dependency), viewport->getRenderArea(), "DepthCullingPass");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -216,7 +216,7 @@ void ToneMappingPass::createRenderPass() {
|
|||||||
.dstAccess = Gfx::SE_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
|
.dstAccess = Gfx::SE_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
renderPass = graphics->createRenderPass(targetLayout, dependency, "ToneMappingPass");
|
renderPass = graphics->createRenderPass(targetLayout, dependency, viewport->getRenderArea(), "ToneMappingPass");
|
||||||
pipeline = graphics->createGraphicsPipeline(Gfx::LegacyPipelineCreateInfo{
|
pipeline = graphics->createGraphicsPipeline(Gfx::LegacyPipelineCreateInfo{
|
||||||
.vertexShader = vert,
|
.vertexShader = vert,
|
||||||
.fragmentShader = frag,
|
.fragmentShader = frag,
|
||||||
|
|||||||
@@ -170,7 +170,7 @@ void UIPass::createRenderPass() {
|
|||||||
Gfx::SE_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
|
Gfx::SE_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
renderPass = graphics->createRenderPass(std::move(layout), dependency, "TextPass");
|
renderPass = graphics->createRenderPass(std::move(layout), dependency, viewport->getRenderArea(), "TextPass");
|
||||||
|
|
||||||
graphics->beginShaderCompilation(ShaderCompilationInfo{
|
graphics->beginShaderCompilation(ShaderCompilationInfo{
|
||||||
.name = "TextVertex",
|
.name = "TextVertex",
|
||||||
|
|||||||
@@ -140,11 +140,16 @@ void VertexData::createDescriptors() {
|
|||||||
|
|
||||||
void VertexData::loadMesh(MeshId id, Array<uint32> loadedIndices, Array<Meshlet> loadedMeshlets) {
|
void VertexData::loadMesh(MeshId id, Array<uint32> loadedIndices, Array<Meshlet> loadedMeshlets) {
|
||||||
std::unique_lock l(vertexDataLock);
|
std::unique_lock l(vertexDataLock);
|
||||||
for (auto&& chunk : loadedMeshlets | std::views::chunk(2048)) {
|
uint32 numChunks = (loadedMeshlets.size() + 2047) / 2048;
|
||||||
|
for(uint32 chunkIdx = 0; chunkIdx < numChunks; ++chunkIdx)
|
||||||
|
{
|
||||||
uint32 meshletOffset = (uint32)meshlets.size();
|
uint32 meshletOffset = (uint32)meshlets.size();
|
||||||
AABB meshAABB;
|
AABB meshAABB;
|
||||||
uint32 numMeshlets = 0;
|
uint32 numMeshlets = 0;
|
||||||
for (auto&& m : chunk) {
|
uint32 chunkOffset = chunkIdx * 2048;
|
||||||
|
uint32 numRemaining = loadedMeshlets.size() - chunkOffset;
|
||||||
|
for (uint32 chunk = 0; chunk < std::min(numRemaining, 2048u); chunk++) {
|
||||||
|
Meshlet& m = loadedMeshlets[chunkOffset + chunk];
|
||||||
numMeshlets++;
|
numMeshlets++;
|
||||||
//...
|
//...
|
||||||
meshAABB = meshAABB.combine(m.boundingBox);
|
meshAABB = meshAABB.combine(m.boundingBox);
|
||||||
@@ -169,6 +174,7 @@ void VertexData::loadMesh(MeshId id, Array<uint32> loadedIndices, Array<Meshlet>
|
|||||||
.numMeshlets = numMeshlets,
|
.numMeshlets = numMeshlets,
|
||||||
.meshletOffset = meshletOffset,
|
.meshletOffset = meshletOffset,
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
// todo: in case of a index split for 16 bit, do something here
|
// todo: in case of a index split for 16 bit, do something here
|
||||||
meshData[id][0].firstIndex = (uint32)indices.size();
|
meshData[id][0].firstIndex = (uint32)indices.size();
|
||||||
|
|||||||
@@ -171,8 +171,9 @@ Gfx::OViewport Graphics::createViewport(Gfx::PWindow owner, const ViewportCreate
|
|||||||
return new Viewport(owner, viewportInfo);
|
return new Viewport(owner, viewportInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
Gfx::ORenderPass Graphics::createRenderPass(Gfx::RenderTargetLayout layout, Array<Gfx::SubPassDependency> dependencies, std::string name,
|
Gfx::ORenderPass Graphics::createRenderPass(Gfx::RenderTargetLayout layout, Array<Gfx::SubPassDependency> dependencies, URect renderArea, std::string name,
|
||||||
Array<uint32> viewMasks, Array<uint32> correlationMasks) {
|
Array<uint32> viewMasks, Array<uint32> correlationMasks) {
|
||||||
|
// todo: re-introduce render area to renderpass
|
||||||
return new RenderPass(this, std::move(layout), std::move(dependencies), name, std::move(viewMasks), std::move(correlationMasks));
|
return new RenderPass(this, std::move(layout), std::move(dependencies), name, std::move(viewMasks), std::move(correlationMasks));
|
||||||
}
|
}
|
||||||
void Graphics::beginRenderPass(Gfx::PRenderPass renderPass) {
|
void Graphics::beginRenderPass(Gfx::PRenderPass renderPass) {
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ class Graphics : public Gfx::Graphics {
|
|||||||
virtual Gfx::OWindow createWindow(const WindowCreateInfo& createInfo) override;
|
virtual Gfx::OWindow createWindow(const WindowCreateInfo& createInfo) override;
|
||||||
virtual Gfx::OViewport createViewport(Gfx::PWindow owner, const ViewportCreateInfo& createInfo) override;
|
virtual Gfx::OViewport createViewport(Gfx::PWindow owner, const ViewportCreateInfo& createInfo) override;
|
||||||
|
|
||||||
virtual Gfx::ORenderPass createRenderPass(Gfx::RenderTargetLayout layout, Array<Gfx::SubPassDependency> dependencies, std::string name,
|
virtual Gfx::ORenderPass createRenderPass(Gfx::RenderTargetLayout layout, Array<Gfx::SubPassDependency> dependencies, URect renderArea, std::string name,
|
||||||
Array<uint32> viewMasks, Array<uint32> correlationMasks) override;
|
Array<uint32> viewMasks, Array<uint32> correlationMasks) override;
|
||||||
virtual void beginRenderPass(Gfx::PRenderPass renderPass) override;
|
virtual void beginRenderPass(Gfx::PRenderPass renderPass) override;
|
||||||
virtual void endRenderPass() override;
|
virtual void endRenderPass() override;
|
||||||
|
|||||||
@@ -170,7 +170,9 @@ void Material::compile() {
|
|||||||
for (const auto& expr : codeExpressions) {
|
for (const auto& expr : codeExpressions) {
|
||||||
codeStream << "\t\t" << expr->evaluate(varState);
|
codeStream << "\t\t" << expr->evaluate(varState);
|
||||||
}
|
}
|
||||||
for (const auto& [name, exp] : brdf.variables) {
|
//for (const auto& [name, exp] : brdf.variables) {
|
||||||
|
for(auto it = brdf.variables.begin(); it != brdf.variables.end(); ++it){
|
||||||
|
auto [name, exp] = *it;
|
||||||
codeStream << "\t\tresult." << name << " = " << varState[exp] << ";" << std::endl;
|
codeStream << "\t\tresult." << name << " = " << varState[exp] << ";" << std::endl;
|
||||||
}
|
}
|
||||||
codeStream << "\t\tresult.transformNormal(input.tangentToWorld);" << std::endl;
|
codeStream << "\t\tresult.transformNormal(input.tangentToWorld);" << std::endl;
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
#include "GameInterface.h"
|
#include "GameInterface.h"
|
||||||
|
#include "dlfcn.h"
|
||||||
|
#include <filesystem>
|
||||||
|
|
||||||
using namespace Seele;
|
using namespace Seele;
|
||||||
|
|
||||||
GameInterface::GameInterface(std::string soPath) : lib(NULL), soPath(soPath) {}
|
GameInterface::GameInterface(std::filesystem::path soPath) : lib(NULL), soPath(soPath) {}
|
||||||
|
|
||||||
GameInterface::~GameInterface() {}
|
GameInterface::~GameInterface() {}
|
||||||
|
|
||||||
@@ -13,6 +15,7 @@ void GameInterface::reload() {
|
|||||||
destroyInstance(game);
|
destroyInstance(game);
|
||||||
dlclose(lib);
|
dlclose(lib);
|
||||||
}
|
}
|
||||||
|
std::filesystem::copy(soPath.parent_path().parent_path() / "res" / "shaders", "shaders/game", std::filesystem::copy_options::overwrite_existing);
|
||||||
lib = dlopen(soPath.c_str(), RTLD_NOW);
|
lib = dlopen(soPath.c_str(), RTLD_NOW);
|
||||||
createInstance = (decltype(createInstance))dlsym(lib, "createInstance");
|
createInstance = (decltype(createInstance))dlsym(lib, "createInstance");
|
||||||
destroyInstance = (decltype(destroyInstance))dlsym(lib, "destroyInstance");
|
destroyInstance = (decltype(destroyInstance))dlsym(lib, "destroyInstance");
|
||||||
|
|||||||
@@ -1,18 +1,18 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "Game.h"
|
#include "Game.h"
|
||||||
#include "dlfcn.h"
|
#include <filesystem>
|
||||||
|
|
||||||
namespace Seele {
|
namespace Seele {
|
||||||
class GameInterface {
|
class GameInterface {
|
||||||
public:
|
public:
|
||||||
GameInterface(std::string soPath);
|
GameInterface(std::filesystem::path soPath);
|
||||||
~GameInterface();
|
~GameInterface();
|
||||||
Game* getGame();
|
Game* getGame();
|
||||||
void reload();
|
void reload();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void* lib;
|
void* lib;
|
||||||
std::string soPath;
|
std::filesystem::path soPath;
|
||||||
Game* game;
|
Game* game;
|
||||||
Game* (*createInstance)() = nullptr;
|
Game* (*createInstance)() = nullptr;
|
||||||
void (*destroyInstance)(Game*) = nullptr;
|
void (*destroyInstance)(Game*) = nullptr;
|
||||||
|
|||||||
Reference in New Issue
Block a user