Adding DXC
This commit is contained in:
Vendored
+1
-1
@@ -26,7 +26,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Editor (Mac)",
|
"name": "Editor (Mac)",
|
||||||
"type": "cppdbg",
|
"type": "lldb",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"program": "${workspaceRoot}/bin/Editor",
|
"program": "${workspaceRoot}/bin/Editor",
|
||||||
"args": [],
|
"args": [],
|
||||||
|
|||||||
+15
-1
@@ -75,9 +75,12 @@ target_link_libraries(Engine PUBLIC fmt::fmt)
|
|||||||
target_link_libraries(Engine PUBLIC GPUOpen::VulkanMemoryAllocator)
|
target_link_libraries(Engine PUBLIC GPUOpen::VulkanMemoryAllocator)
|
||||||
target_link_libraries(Engine PUBLIC shader-slang)
|
target_link_libraries(Engine PUBLIC shader-slang)
|
||||||
if(APPLE)
|
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)
|
target_link_libraries(Engine PUBLIC metal)
|
||||||
SET(CMAKE_OSX_DEPLOYMENT_TARGET 14.3)
|
SET(CMAKE_OSX_DEPLOYMENT_TARGET 14.3)
|
||||||
|
install(FILES
|
||||||
|
${EXTERNAL_ROOT}/dxc
|
||||||
|
DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
|
||||||
endif()
|
endif()
|
||||||
if(UNIX)
|
if(UNIX)
|
||||||
target_link_libraries(Engine PUBLIC Threads::Threads)
|
target_link_libraries(Engine PUBLIC Threads::Threads)
|
||||||
@@ -111,6 +114,11 @@ else()
|
|||||||
target_link_options(Engine PUBLIC -fsanitize=address)
|
target_link_options(Engine PUBLIC -fsanitize=address)
|
||||||
target_link_options(Editor PUBLIC -fsanitize=address)
|
target_link_options(Editor PUBLIC -fsanitize=address)
|
||||||
endif()
|
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 "$<$<CONFIG:DEBUG>:-DENABLE_VALIDATION>")
|
target_compile_options(Engine PUBLIC "$<$<CONFIG:DEBUG>:-DENABLE_VALIDATION>")
|
||||||
target_compile_options(Engine PUBLIC "$<$<CONFIG:DEBUG>:-DSEELE_DEBUG>")
|
target_compile_options(Engine PUBLIC "$<$<CONFIG:DEBUG>:-DSEELE_DEBUG>")
|
||||||
|
|
||||||
@@ -122,6 +130,12 @@ if(WIN32)
|
|||||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_RUNTIME_DLLS:Engine> $<TARGET_FILE_DIR:Editor>
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_RUNTIME_DLLS:Engine> $<TARGET_FILE_DIR:Editor>
|
||||||
COMMAND_EXPAND_LISTS
|
COMMAND_EXPAND_LISTS
|
||||||
DEPENDS Editor)
|
DEPENDS Editor)
|
||||||
|
elseif(APPLE)
|
||||||
|
add_custom_target(dll_copy ALL
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${SLANG_ROOT}bin/libslang.dylib $<TARGET_FILE_DIR:Editor>
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${EXTERNAL_ROOT}/dxc $<TARGET_FILE_DIR:Editor>
|
||||||
|
COMMAND_EXPAND_LISTS
|
||||||
|
DEPENDS Editor)
|
||||||
else()
|
else()
|
||||||
add_custom_target(dll_copy ALL
|
add_custom_target(dll_copy ALL
|
||||||
COMMAND ${CMAKE_COMMAND} -E true)
|
COMMAND ${CMAKE_COMMAND} -E true)
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ if(WIN32)
|
|||||||
${SLANG_ROOT}/lib/slang.lib
|
${SLANG_ROOT}/lib/slang.lib
|
||||||
DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
|
DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
|
||||||
elseif(APPLE)
|
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-glslang PROPERTIES IMPORTED_LOCATION ${SLANG_ROOT}/bin/libslang-glslang.dylib)
|
||||||
set_target_properties(shader-slang PROPERTIES IMPORTED_LOCATION ${SLANG_ROOT}/bin/libslang.dylib)
|
set_target_properties(shader-slang PROPERTIES IMPORTED_LOCATION ${SLANG_ROOT}/bin/libslang.dylib)
|
||||||
target_link_libraries(shader-slang INTERFACE shader-slang-glslang)
|
target_link_libraries(shader-slang INTERFACE shader-slang-glslang)
|
||||||
|
|||||||
BIN
Binary file not shown.
Vendored
+1
-1
Submodule external/vcpkg updated: 042c31edc6...c44250706f
@@ -1,3 +1,4 @@
|
|||||||
|
#include "Graphics/Initializer.h"
|
||||||
#include "Graphics/Metal/Graphics.h"
|
#include "Graphics/Metal/Graphics.h"
|
||||||
#include "Window/WindowManager.h"
|
#include "Window/WindowManager.h"
|
||||||
#include "Window/SceneView.h"
|
#include "Window/SceneView.h"
|
||||||
@@ -47,6 +48,12 @@ int main()
|
|||||||
#endif
|
#endif
|
||||||
GraphicsInitializer initializer;
|
GraphicsInitializer initializer;
|
||||||
graphics->init(initializer);
|
graphics->init(initializer);
|
||||||
|
graphics->createComputeShader(ShaderCreateInfo {
|
||||||
|
.entryPoint = "cullLights",
|
||||||
|
.mainModule = "LightCulling",
|
||||||
|
.additionalModules = {"LightCulling"},
|
||||||
|
.name = "Test",
|
||||||
|
});
|
||||||
StaticMeshVertexData* vd = StaticMeshVertexData::getInstance();
|
StaticMeshVertexData* vd = StaticMeshVertexData::getInstance();
|
||||||
vd->init(graphics);
|
vd->init(graphics);
|
||||||
OWindowManager windowManager = new WindowManager();
|
OWindowManager windowManager = new WindowManager();
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "Graphics/Command.h"
|
#include "Graphics/Command.h"
|
||||||
|
#include "Metal/MTLCommandBuffer.hpp"
|
||||||
#include "RenderPass.h"
|
#include "RenderPass.h"
|
||||||
#include "Resources.h"
|
#include "Resources.h"
|
||||||
|
|
||||||
@@ -12,7 +13,7 @@ DECLARE_REF(Graphics)
|
|||||||
class Command
|
class Command
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Command(PGraphics graphics, PCommandQueue owner);
|
Command(PGraphics graphics, MTL::CommandBuffer* cmdBuffer);
|
||||||
~Command();
|
~Command();
|
||||||
void beginRenderPass(PRenderPass renderPass);
|
void beginRenderPass(PRenderPass renderPass);
|
||||||
void endRenderPass();
|
void endRenderPass();
|
||||||
@@ -32,7 +33,6 @@ public:
|
|||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
PGraphics graphics;
|
PGraphics graphics;
|
||||||
PCommandQueue owner;
|
|
||||||
OEvent completed;
|
OEvent completed;
|
||||||
MTL::CommandBuffer* cmdBuffer;
|
MTL::CommandBuffer* cmdBuffer;
|
||||||
MTL::ParallelRenderCommandEncoder* renderEncoder;
|
MTL::ParallelRenderCommandEncoder* renderEncoder;
|
||||||
@@ -82,7 +82,7 @@ public:
|
|||||||
{
|
{
|
||||||
return queue;
|
return queue;
|
||||||
}
|
}
|
||||||
PCommand getCommands();
|
PCommand getCommands() {return activeCommand;} //TODO
|
||||||
ORenderCommand getRenderCommand(const std::string& name);
|
ORenderCommand getRenderCommand(const std::string& name);
|
||||||
OComputeCommand getComputeCommand(const std::string& name);
|
OComputeCommand getComputeCommand(const std::string& name);
|
||||||
void submitCommands(PEvent signal = nullptr);
|
void submitCommands(PEvent signal = nullptr);
|
||||||
@@ -100,7 +100,7 @@ public:
|
|||||||
{
|
{
|
||||||
return queue;
|
return queue;
|
||||||
}
|
}
|
||||||
PCommand getCommands();
|
PCommand getCommands() {return activeCommand;} // TODO
|
||||||
void submitCommands(PEvent signal = nullptr);
|
void submitCommands(PEvent signal = nullptr);
|
||||||
private:
|
private:
|
||||||
PGraphics graphics;
|
PGraphics graphics;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include "Command.h"
|
#include "Command.h"
|
||||||
#include "Graphics/Graphics.h"
|
#include "Graphics/Graphics.h"
|
||||||
#include "Graphics/Metal/Resources.h"
|
#include "Graphics/Metal/Resources.h"
|
||||||
|
#include "Metal/MTLCommandBuffer.hpp"
|
||||||
#include "Metal/MTLIOCommandQueue.hpp"
|
#include "Metal/MTLIOCommandQueue.hpp"
|
||||||
#include "Metal/MTLRenderCommandEncoder.hpp"
|
#include "Metal/MTLRenderCommandEncoder.hpp"
|
||||||
#include "Window.h"
|
#include "Window.h"
|
||||||
@@ -8,9 +9,9 @@
|
|||||||
using namespace Seele;
|
using namespace Seele;
|
||||||
using namespace Seele::Metal;
|
using namespace Seele::Metal;
|
||||||
|
|
||||||
Command::Command(PGraphics graphics, PCommandQueue owner)
|
Command::Command(PGraphics graphics, MTL::CommandBuffer* cmdBuffer)
|
||||||
: graphics(graphics), owner(owner), completed(new Event(graphics)),
|
: graphics(graphics), completed(new Event(graphics)),
|
||||||
cmdBuffer(owner->getHandle()->commandBuffer()), renderEncoder(nullptr) {}
|
cmdBuffer(cmdBuffer), renderEncoder(nullptr) {}
|
||||||
|
|
||||||
Command::~Command() { cmdBuffer->release(); }
|
Command::~Command() { cmdBuffer->release(); }
|
||||||
|
|
||||||
@@ -77,48 +78,48 @@ void RenderCommand::setViewport(Gfx::PViewport viewport) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void RenderCommand::bindPipeline(Gfx::PGraphicsPipeline pipeline) {
|
void RenderCommand::bindPipeline(Gfx::PGraphicsPipeline pipeline) {
|
||||||
encoder->setRenderPipelineState(
|
// encoder->setRenderPipelineState(
|
||||||
pipeline.cast<GraphicsPipeline>()->getState());
|
// pipeline.cast<GraphicsPipeline>()->getState());
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderCommand::bindDescriptor(Gfx::PDescriptorSet descriptorSet) {
|
void RenderCommand::bindDescriptor(Gfx::PDescriptorSet descriptorSet) {
|
||||||
encoder->set ? ? ? ? ?
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderCommand::bindDescriptor(
|
void RenderCommand::bindDescriptor(
|
||||||
const Array<Gfx::PDescriptorSet> &descriptorSets) {
|
const Array<Gfx::PDescriptorSet> &descriptorSets) {
|
||||||
encoder->set ? ? ? ? ?
|
// encoder->set ? ? ? ? ?
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderCommand::bindVertexBuffer(const Array<Gfx::PVertexBuffer> &buffers) {
|
void RenderCommand::bindVertexBuffer(const Array<Gfx::PVertexBuffer> &buffers) {
|
||||||
encoder->setVertexBuffers();
|
// encoder->setVertexBuffers();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderCommand::bindIndexBuffer(Gfx::PIndexBuffer indexBuffer) {
|
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,
|
void RenderCommand::pushConstants(Gfx::PPipelineLayout layout,
|
||||||
Gfx::SeShaderStageFlags stage, uint32 offset,
|
Gfx::SeShaderStageFlags stage, uint32 offset,
|
||||||
uint32 size, const void *data) {
|
uint32 size, const void *data) {
|
||||||
? ? ?
|
// ? ? ?
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderCommand::draw(uint32 vertexCount, uint32 instanceCount,
|
void RenderCommand::draw(uint32 vertexCount, uint32 instanceCount,
|
||||||
int32 firstVertex, uint32 firstInstance) {
|
int32 firstVertex, uint32 firstInstance) {
|
||||||
encoder->drawPrimitives(???, firstVertex, vertexCount, instanceCount, firstInstance);
|
// encoder->drawPrimitives(???, firstVertex, vertexCount, instanceCount, firstInstance);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderCommand::drawIndexed(uint32 indexCount, uint32 instanceCount,
|
void RenderCommand::drawIndexed(uint32 indexCount, uint32 instanceCount,
|
||||||
int32 firstIndex, uint32 vertexOffset,
|
int32 firstIndex, uint32 vertexOffset,
|
||||||
uint32 firstInstance) {
|
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){
|
void RenderCommand::drawMesh(uint32 groupX, uint32 groupY, uint32 groupZ){
|
||||||
encoder->drawMeshThreads(MTL::Size threadsPerGrid,
|
// encoder->drawMeshThreads(MTL::Size threadsPerGrid,
|
||||||
MTL::Size threadsPerObjectThreadgroup,
|
// MTL::Size threadsPerObjectThreadgroup,
|
||||||
MTL::Size threadsPerMeshThreadgroup)}
|
// MTL::Size threadsPerMeshThreadgroup)
|
||||||
|
}
|
||||||
|
|
||||||
ComputeCommand::ComputeCommand(MTL::ComputeCommandEncoder *encoder)
|
ComputeCommand::ComputeCommand(MTL::ComputeCommandEncoder *encoder)
|
||||||
: encoder(encoder) {}
|
: encoder(encoder) {}
|
||||||
@@ -128,30 +129,30 @@ ComputeCommand::~ComputeCommand() { encoder->release(); }
|
|||||||
void ComputeCommand::end() { encoder->endEncoding(); }
|
void ComputeCommand::end() { encoder->endEncoding(); }
|
||||||
|
|
||||||
void ComputeCommand::bindPipeline(Gfx::PComputePipeline pipeline) {
|
void ComputeCommand::bindPipeline(Gfx::PComputePipeline pipeline) {
|
||||||
encoder->setComputePipelineState(pipeline.cast<ComputePipeline>());
|
// encoder->setComputePipelineState(pipeline.cast<ComputePipeline>());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ComputeCommand::bindDescriptor(Gfx::PDescriptorSet set) {
|
void ComputeCommand::bindDescriptor(Gfx::PDescriptorSet set) {
|
||||||
encoder->set ? ? ?
|
// encoder->set ? ? ?
|
||||||
}
|
}
|
||||||
|
|
||||||
void ComputeCommand::bindDescriptor(const Array<Gfx::PDescriptorSet> &sets) {
|
void ComputeCommand::bindDescriptor(const Array<Gfx::PDescriptorSet> &sets) {
|
||||||
encoder->set ? ? ?
|
// encoder->set ? ? ?
|
||||||
}
|
}
|
||||||
|
|
||||||
void ComputeCommand::pushConstants(Gfx::PPipelineLayout layout,
|
void ComputeCommand::pushConstants(Gfx::PPipelineLayout layout,
|
||||||
Gfx::SeShaderStageFlags stage, uint32 offset,
|
Gfx::SeShaderStageFlags stage, uint32 offset,
|
||||||
uint32 size, const void *data) {
|
uint32 size, const void *data) {
|
||||||
? ? ?
|
// ? ? ?
|
||||||
}
|
}
|
||||||
|
|
||||||
void ComputeCommand::dispatch(uint32 threadX, uint32 threadY, uint32 threadZ) {
|
void ComputeCommand::dispatch(uint32 threadX, uint32 threadY, uint32 threadZ) {
|
||||||
encoder->dispatchThreadgroups(???);
|
// encoder->dispatchThreadgroups(???);
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandQueue::CommandQueue(PGraphics graphics) : graphics(graphics) {
|
CommandQueue::CommandQueue(PGraphics graphics) : graphics(graphics) {
|
||||||
queue = graphics->getDevice()->newCommandQueue();
|
queue = graphics->getDevice()->newCommandQueue();
|
||||||
activeCommand = new Command(graphics, this);
|
activeCommand = new Command(graphics, queue->commandBuffer());
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandQueue::~CommandQueue() { queue->release(); }
|
CommandQueue::~CommandQueue() { queue->release(); }
|
||||||
@@ -166,8 +167,8 @@ OComputeCommand CommandQueue::getComputeCommand(const std::string &name) {
|
|||||||
|
|
||||||
void CommandQueue::submitCommands(PEvent signalSemaphore) {
|
void CommandQueue::submitCommands(PEvent signalSemaphore) {
|
||||||
activeCommand->end(signalSemaphore);
|
activeCommand->end(signalSemaphore);
|
||||||
MTL::Event *prevCmdEvent = activeCommand->getCompletedEvent();
|
PEvent prevCmdEvent = activeCommand->getCompletedEvent();
|
||||||
activeCommand = new Command(graphics, this);
|
activeCommand = new Command(graphics, queue->commandBuffer());
|
||||||
activeCommand->waitForEvent(prevCmdEvent);
|
activeCommand->waitForEvent(prevCmdEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -175,8 +176,8 @@ IOCommandQueue::IOCommandQueue(PGraphics graphics) : graphics(graphics) {
|
|||||||
MTL::IOCommandQueueDescriptor* desc = MTL::IOCommandQueueDescriptor::alloc()->init();
|
MTL::IOCommandQueueDescriptor* desc = MTL::IOCommandQueueDescriptor::alloc()->init();
|
||||||
desc->setType(MTL::IOCommandQueueTypeConcurrent);
|
desc->setType(MTL::IOCommandQueueTypeConcurrent);
|
||||||
desc->setPriority(MTL::IOPriorityNormal);
|
desc->setPriority(MTL::IOPriorityNormal);
|
||||||
queue = graphics->getDevice()->newIOCommandQueue(desc);
|
queue = graphics->getDevice()->newIOCommandQueue(desc, nullptr);
|
||||||
activeCommand = new Command(graphics, this);
|
//activeCommand = new Command(graphics, queue->commandBuffer());
|
||||||
desc->release();
|
desc->release();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -185,7 +186,7 @@ IOCommandQueue::~IOCommandQueue() { queue->release(); }
|
|||||||
void IOCommandQueue::submitCommands(PEvent signalSemaphore) {
|
void IOCommandQueue::submitCommands(PEvent signalSemaphore) {
|
||||||
//TODO: scratch buffer
|
//TODO: scratch buffer
|
||||||
activeCommand->end(signalSemaphore);
|
activeCommand->end(signalSemaphore);
|
||||||
MTL::Event *prevCmdEvent = activeCommand->getCompletedEvent();
|
PEvent prevCmdEvent = activeCommand->getCompletedEvent();
|
||||||
activeCommand = new Command(graphics, this);
|
//activeCommand = new Command(graphics, queue->commandBuffer());
|
||||||
activeCommand->waitForEvent(prevCmdEvent);
|
activeCommand->waitForEvent(prevCmdEvent);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,53 +1,71 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
#include "Foundation/NSArray.hpp"
|
||||||
#include "Graphics/Descriptor.h"
|
#include "Graphics/Descriptor.h"
|
||||||
#include "Graphics/Initializer.h"
|
#include "Graphics/Initializer.h"
|
||||||
|
#include "Metal/MTLArgumentEncoder.hpp"
|
||||||
#include "MinimalEngine.h"
|
#include "MinimalEngine.h"
|
||||||
|
|
||||||
namespace Seele {
|
namespace Seele {
|
||||||
namespace Metal {
|
namespace Metal {
|
||||||
DECLARE_REF(Graphics)
|
DECLARE_REF(Graphics)
|
||||||
DECLARE_REF(DescriptorPool)
|
DECLARE_REF(DescriptorPool)
|
||||||
class DescriptorLayout : public Gfx::DescriptorLayout
|
class DescriptorLayout : public Gfx::DescriptorLayout {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
DescriptorLayout(PGraphics graphics, const std::string& name);
|
DescriptorLayout(PGraphics graphics, const std::string &name);
|
||||||
virtual ~DescriptorLayout();
|
virtual ~DescriptorLayout();
|
||||||
virtual void create() override;
|
virtual void create() override;
|
||||||
|
NS::Array* getArguments() const
|
||||||
|
{
|
||||||
|
return arguments;
|
||||||
|
}
|
||||||
private:
|
private:
|
||||||
PGraphics graphics;
|
PGraphics graphics;
|
||||||
|
NS::Array* arguments;
|
||||||
};
|
};
|
||||||
class PipelineLayout : public Gfx::PipelineLayout
|
class PipelineLayout : public Gfx::PipelineLayout {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
PipelineLayout(PGraphics graphics, Gfx::PPipelineLayout baseLayout)
|
PipelineLayout(PGraphics graphics, Gfx::PPipelineLayout baseLayout)
|
||||||
: Gfx::PipelineLayout(baseLayout)
|
: Gfx::PipelineLayout(baseLayout), graphics(graphics) {}
|
||||||
, graphics(graphics)
|
|
||||||
{}
|
|
||||||
private:
|
private:
|
||||||
PGraphics graphics;
|
PGraphics graphics;
|
||||||
};
|
};
|
||||||
DEFINE_REF(PipelineLayout)
|
DEFINE_REF(PipelineLayout)
|
||||||
|
|
||||||
class DescriptorSet : public Gfx::DescriptorSet
|
class DescriptorSet : public Gfx::DescriptorSet {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
DescriptorSet(PGraphics graphics, PDescriptorPool owner)
|
DescriptorSet(PGraphics graphics, PDescriptorPool owner);
|
||||||
: graphics(graphics)
|
|
||||||
, owner(owner)
|
|
||||||
{}
|
|
||||||
virtual ~DescriptorSet();
|
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<Gfx::PTexture> texture);
|
||||||
|
virtual bool operator<(Gfx::PDescriptorSet other);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PGraphics graphics;
|
PGraphics graphics;
|
||||||
PDescriptorPool owner;
|
PDescriptorPool owner;
|
||||||
|
MTL::Buffer* buffer;
|
||||||
|
MTL::ArgumentEncoder* encoder;
|
||||||
};
|
};
|
||||||
DEFINE_REF(DescriptorSet)
|
DEFINE_REF(DescriptorSet)
|
||||||
|
|
||||||
class DescriptorPool : public Gfx::DescriptorPool
|
class DescriptorPool : public Gfx::DescriptorPool {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
DescriptorPool(PGraphics graphics);
|
DescriptorPool(PGraphics graphics, DescriptorLayout& layout);
|
||||||
|
virtual ~DescriptorPool();
|
||||||
|
NS::Array* getArguments() const
|
||||||
|
{
|
||||||
|
return layout.getArguments();
|
||||||
|
}
|
||||||
private:
|
private:
|
||||||
PGraphics graphics;
|
PGraphics graphics;
|
||||||
|
DescriptorLayout& layout;
|
||||||
};
|
};
|
||||||
}
|
} // namespace Metal
|
||||||
}
|
} // namespace Seele
|
||||||
@@ -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<Gfx::PTexture> texture){}
|
||||||
|
bool DescriptorSet::operator<(Gfx::PDescriptorSet other){return this < other.getHandle();}
|
||||||
|
|||||||
@@ -59,7 +59,6 @@ public:
|
|||||||
PIOCommandQueue getIOQueue() const { return ioQueue; }
|
PIOCommandQueue getIOQueue() const { return ioQueue; }
|
||||||
protected:
|
protected:
|
||||||
MTL::Device* device;
|
MTL::Device* device;
|
||||||
MTL::Library* library;
|
|
||||||
OCommandQueue queue;
|
OCommandQueue queue;
|
||||||
OIOCommandQueue ioQueue;
|
OIOCommandQueue ioQueue;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
#include "Graphics.h"
|
#include "Graphics.h"
|
||||||
|
#include "Graphics/Metal/Shader.h"
|
||||||
#include "RenderPass.h"
|
#include "RenderPass.h"
|
||||||
#include "Command.h"
|
#include "Command.h"
|
||||||
#include "Window.h"
|
#include "Window.h"
|
||||||
@@ -19,8 +20,6 @@ Graphics::~Graphics()
|
|||||||
void Graphics::init(GraphicsInitializer)
|
void Graphics::init(GraphicsInitializer)
|
||||||
{
|
{
|
||||||
device = MTL::CreateSystemDefaultDevice();
|
device = MTL::CreateSystemDefaultDevice();
|
||||||
library = device->newDefaultLibrary();
|
|
||||||
assert(library);
|
|
||||||
queue = new CommandQueue(this);
|
queue = new CommandQueue(this);
|
||||||
ioQueue = new IOCommandQueue(this);
|
ioQueue = new IOCommandQueue(this);
|
||||||
}
|
}
|
||||||
@@ -121,11 +120,16 @@ Gfx::OFragmentShader Graphics::createFragmentShader(const ShaderCreateInfo& crea
|
|||||||
}
|
}
|
||||||
Gfx::OComputeShader Graphics::createComputeShader(const ShaderCreateInfo& createInfo)
|
Gfx::OComputeShader Graphics::createComputeShader(const ShaderCreateInfo& createInfo)
|
||||||
{
|
{
|
||||||
|
OComputeShader result = new ComputeShader(this);
|
||||||
|
result->create(createInfo);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Gfx::OMeshShader Graphics::createMeshShader(const ShaderCreateInfo& createInfo)
|
Gfx::OMeshShader Graphics::createMeshShader(const ShaderCreateInfo& createInfo)
|
||||||
{
|
{
|
||||||
|
OMeshShader result = new MeshShader(this);
|
||||||
|
result->create(createInfo);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
Gfx::OTaskShader Graphics::createTaskShader(const ShaderCreateInfo& createInfo)
|
Gfx::OTaskShader Graphics::createTaskShader(const ShaderCreateInfo& createInfo)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
#include "Graphics.h"
|
#include "Graphics.h"
|
||||||
#include "Graphics/Enums.h"
|
#include "Graphics/Enums.h"
|
||||||
#include "Graphics/slang-compile.h"
|
#include "Graphics/slang-compile.h"
|
||||||
#include "Metal/MTLLibrary.hpp"
|
#include <iostream>
|
||||||
#include "metal_irconverter/metal_irconverter.h"
|
#include </usr/local/include/metal_irconverter/metal_irconverter.h>
|
||||||
#include <slang.h>
|
#include <slang.h>
|
||||||
|
|
||||||
using namespace Seele;
|
using namespace Seele;
|
||||||
@@ -55,6 +55,17 @@ void Shader::create(const ShaderCreateInfo &createInfo) {
|
|||||||
uint8_t *metallib = new uint8_t[metallibSize];
|
uint8_t *metallib = new uint8_t[metallibSize];
|
||||||
IRMetalLibGetBytecode(pMetallib, metallib);
|
IRMetalLibGetBytecode(pMetallib, metallib);
|
||||||
|
|
||||||
|
IRShaderReflection* reflection = IRShaderReflectionCreate();
|
||||||
|
IRObjectGetReflection(pOutIR, irStage, reflection);
|
||||||
|
Array<IRResourceLocation> 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.
|
// Store the metallib to custom format or disk, or use to create a MTLLibrary.
|
||||||
NS::Error *__autoreleasing error = nil;
|
NS::Error *__autoreleasing error = nil;
|
||||||
dispatch_data_t data = dispatch_data_create(metallib, metallibSize,
|
dispatch_data_t data = dispatch_data_create(metallib, metallibSize,
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ void Command::endRenderPass()
|
|||||||
state = State::Begin;
|
state = State::Begin;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Command::executeCommands(const Array<Gfx::ORenderCommand>& commands)
|
void Command::executeCommands(Array<Gfx::ORenderCommand> commands)
|
||||||
{
|
{
|
||||||
assert(state == State::RenderPass);
|
assert(state == State::RenderPass);
|
||||||
if(commands.size() == 0)
|
if(commands.size() == 0)
|
||||||
@@ -95,18 +95,18 @@ void Command::executeCommands(const Array<Gfx::ORenderCommand>& commands)
|
|||||||
{
|
{
|
||||||
auto command = Gfx::PRenderCommand(commands[i]).cast<RenderCommand>();
|
auto command = Gfx::PRenderCommand(commands[i]).cast<RenderCommand>();
|
||||||
command->end();
|
command->end();
|
||||||
executingRenders.add(command);
|
|
||||||
for(auto& descriptor : command->boundDescriptors)
|
for(auto& descriptor : command->boundDescriptors)
|
||||||
{
|
{
|
||||||
boundDescriptors.add(descriptor);
|
boundDescriptors.add(descriptor);
|
||||||
//std::cout << "Cmd " << handle << " bound descriptor " << descriptor->getHandle() << std::endl;
|
//std::cout << "Cmd " << handle << " bound descriptor " << descriptor->getHandle() << std::endl;
|
||||||
}
|
}
|
||||||
cmdBuffers[i] = command->getHandle();
|
cmdBuffers[i] = command->getHandle();
|
||||||
|
executingRenders.add(std::move(commands[i]));
|
||||||
}
|
}
|
||||||
vkCmdExecuteCommands(handle, (uint32)cmdBuffers.size(), cmdBuffers.data());
|
vkCmdExecuteCommands(handle, (uint32)cmdBuffers.size(), cmdBuffers.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Command::executeCommands(const Array<Gfx::OComputeCommand>& commands)
|
void Command::executeCommands(Array<Gfx::OComputeCommand> commands)
|
||||||
{
|
{
|
||||||
if(commands.size() == 0)
|
if(commands.size() == 0)
|
||||||
{
|
{
|
||||||
@@ -117,13 +117,13 @@ void Command::executeCommands(const Array<Gfx::OComputeCommand>& commands)
|
|||||||
{
|
{
|
||||||
auto command = Gfx::PComputeCommand(commands[i]).cast<ComputeCommand>();
|
auto command = Gfx::PComputeCommand(commands[i]).cast<ComputeCommand>();
|
||||||
command->end();
|
command->end();
|
||||||
executingComputes.add(command);
|
|
||||||
for(auto& descriptor : command->boundDescriptors)
|
for(auto& descriptor : command->boundDescriptors)
|
||||||
{
|
{
|
||||||
boundDescriptors.add(descriptor);
|
boundDescriptors.add(descriptor);
|
||||||
//std::cout << "Cmd " << handle << " bound descriptor " << descriptor->getHandle() << std::endl;
|
//std::cout << "Cmd " << handle << " bound descriptor " << descriptor->getHandle() << std::endl;
|
||||||
}
|
}
|
||||||
cmdBuffers[i] = command->getHandle();
|
cmdBuffers[i] = command->getHandle();
|
||||||
|
executingComputes.add(std::move(commands[i]));
|
||||||
}
|
}
|
||||||
vkCmdExecuteCommands(handle, (uint32)cmdBuffers.size(), cmdBuffers.data());
|
vkCmdExecuteCommands(handle, (uint32)cmdBuffers.size(), cmdBuffers.data());
|
||||||
}
|
}
|
||||||
@@ -487,12 +487,18 @@ PCommand CommandPool::getCommands()
|
|||||||
}
|
}
|
||||||
void CommandPool::cacheCommands(Array<ORenderCommand> commands)
|
void CommandPool::cacheCommands(Array<ORenderCommand> commands)
|
||||||
{
|
{
|
||||||
allocatedRenderCommands.addAll(commands);
|
for(auto&& command : commands)
|
||||||
|
{
|
||||||
|
allocatedRenderCommands.add(std::move(command));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CommandPool::cacheCommands(Array<OComputeCommand> commands)
|
void CommandPool::cacheCommands(Array<OComputeCommand> commands)
|
||||||
{
|
{
|
||||||
allocatedComputeCommands.addAll(commands);
|
for(auto&& command : commands)
|
||||||
|
{
|
||||||
|
allocatedComputeCommands.add(std::move(command));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ORenderCommand CommandPool::createRenderCommand(const std::string& name)
|
ORenderCommand CommandPool::createRenderCommand(const std::string& name)
|
||||||
|
|||||||
@@ -22,8 +22,8 @@ public:
|
|||||||
void end();
|
void end();
|
||||||
void beginRenderPass(PRenderPass renderPass, PFramebuffer framebuffer);
|
void beginRenderPass(PRenderPass renderPass, PFramebuffer framebuffer);
|
||||||
void endRenderPass();
|
void endRenderPass();
|
||||||
void executeCommands(const Array<Gfx::ORenderCommand> &secondaryCommands);
|
void executeCommands(Array<Gfx::ORenderCommand> secondaryCommands);
|
||||||
void executeCommands(const Array<Gfx::OComputeCommand> &secondaryCommands);
|
void executeCommands(Array<Gfx::OComputeCommand> secondaryCommands);
|
||||||
void waitForSemaphore(VkPipelineStageFlags stages, PSemaphore waitSemaphore);
|
void waitForSemaphore(VkPipelineStageFlags stages, PSemaphore waitSemaphore);
|
||||||
void checkFence();
|
void checkFence();
|
||||||
void waitForCommand(uint32 timeToWait = 1000000u);
|
void waitForCommand(uint32 timeToWait = 1000000u);
|
||||||
@@ -50,8 +50,8 @@ private:
|
|||||||
PFramebuffer boundFramebuffer;
|
PFramebuffer boundFramebuffer;
|
||||||
Array<PSemaphore> waitSemaphores;
|
Array<PSemaphore> waitSemaphores;
|
||||||
Array<VkPipelineStageFlags> waitFlags;
|
Array<VkPipelineStageFlags> waitFlags;
|
||||||
Array<PRenderCommand> executingRenders;
|
Array<ORenderCommand> executingRenders;
|
||||||
Array<PComputeCommand> executingComputes;
|
Array<OComputeCommand> executingComputes;
|
||||||
Array<PDescriptorSet> boundDescriptors;
|
Array<PDescriptorSet> boundDescriptors;
|
||||||
friend class RenderCommand;
|
friend class RenderCommand;
|
||||||
friend class CommandPool;
|
friend class CommandPool;
|
||||||
@@ -123,7 +123,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
PComputePipeline pipeline;
|
PComputePipeline pipeline;
|
||||||
bool ready;
|
bool ready;
|
||||||
Array<DescriptorSet *> boundDescriptors;
|
Array<PDescriptorSet> boundDescriptors;
|
||||||
VkViewport currentViewport;
|
VkViewport currentViewport;
|
||||||
VkRect2D currentScissor;
|
VkRect2D currentScissor;
|
||||||
PGraphics graphics;
|
PGraphics graphics;
|
||||||
|
|||||||
@@ -118,12 +118,12 @@ void Graphics::waitDeviceIdle()
|
|||||||
|
|
||||||
void Graphics::executeCommands(Array<Gfx::ORenderCommand> commands)
|
void Graphics::executeCommands(Array<Gfx::ORenderCommand> commands)
|
||||||
{
|
{
|
||||||
getGraphicsCommands()->getCommands()->executeCommands(commands);
|
getGraphicsCommands()->getCommands()->executeCommands(std::move(commands));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Graphics::executeCommands(Array<Gfx::OComputeCommand> commands)
|
void Graphics::executeCommands(Array<Gfx::OComputeCommand> commands)
|
||||||
{
|
{
|
||||||
getComputeCommands()->getCommands()->executeCommands(commands);
|
getComputeCommands()->getCommands()->executeCommands(std::move(commands));
|
||||||
}
|
}
|
||||||
|
|
||||||
Gfx::OTexture2D Graphics::createTexture2D(const TextureCreateInfo &createInfo)
|
Gfx::OTexture2D Graphics::createTexture2D(const TextureCreateInfo &createInfo)
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#include "Shader.h"
|
#include "Shader.h"
|
||||||
#include "Graphics.h"
|
#include "Graphics.h"
|
||||||
|
#include "Graphics/slang-compile.h"
|
||||||
#include "slang.h"
|
#include "slang.h"
|
||||||
#include "slang-com-ptr.h"
|
#include "slang-com-ptr.h"
|
||||||
#include "stdlib.h"
|
#include "stdlib.h"
|
||||||
@@ -29,7 +30,7 @@ uint32 Seele::Vulkan::Shader::getShaderHash() const
|
|||||||
|
|
||||||
void Shader::create(const ShaderCreateInfo& createInfo)
|
void Shader::create(const ShaderCreateInfo& createInfo)
|
||||||
{
|
{
|
||||||
|
Slang::ComPtr<slang::IBlob> kernelBlob = generateShader(createInfo, SLANG_SPIRV);
|
||||||
VkShaderModuleCreateInfo moduleInfo =
|
VkShaderModuleCreateInfo moduleInfo =
|
||||||
{
|
{
|
||||||
.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO,
|
.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));
|
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);
|
hash = CRC::Calculate(kernelBlob->getBufferPointer(), kernelBlob->getBufferSize(), CRC::CRC_32(), hash);
|
||||||
/*
|
/*
|
||||||
specializedComponent->getEntryPointCode(
|
specializedComponent->getEntryPointCode(
|
||||||
|
|||||||
Reference in New Issue
Block a user