Trying to get metal backend to run
This commit is contained in:
@@ -319,6 +319,7 @@ CommandQueue::CommandQueue(PGraphics graphics) : graphics(graphics) {
|
||||
MTL::CommandBufferDescriptor* descriptor = MTL::CommandBufferDescriptor::alloc()->init();
|
||||
descriptor->setErrorOptions(MTL::CommandBufferErrorOptionEncoderExecutionStatus);
|
||||
activeCommand = new Command(graphics, queue->commandBuffer(descriptor));
|
||||
activeCommand->begin();
|
||||
descriptor->release();
|
||||
}
|
||||
|
||||
@@ -353,7 +354,7 @@ void CommandQueue::executeCommands(Array<Gfx::OComputeCommand> commands) {
|
||||
}
|
||||
|
||||
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++) {
|
||||
if ((*it)->getHandle() == cmdBuffer) {
|
||||
auto& cmd = *it;
|
||||
@@ -380,12 +381,7 @@ void CommandQueue::submitCommands(PEvent signalSemaphore) {
|
||||
activeCommand->begin();
|
||||
activeCommand->waitForEvent(prevCmdEvent);
|
||||
descriptor->release();
|
||||
}*/
|
||||
activeCommand->end();
|
||||
activeCommand->waitDeviceIdle();
|
||||
activeCommand->reset();
|
||||
activeCommand = new Command(graphics, queue->commandBuffer());
|
||||
activeCommand->begin();
|
||||
}
|
||||
}
|
||||
|
||||
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::PIndexBuffer uniformBuffer) 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::PTexture3D texture) override;
|
||||
virtual void updateTexture(const std::string& name, uint32 index, Gfx::PTextureCube texture) override;
|
||||
virtual void updateTexture(const std::string& name, uint32 index, Gfx::PTexture texture) override;
|
||||
virtual void updateAccelerationStructure(const std::string& name, uint32 index, Gfx::PTopLevelAS as) override;
|
||||
|
||||
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) {
|
||||
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) {
|
||||
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{
|
||||
|
||||
@@ -17,8 +17,7 @@ class Graphics : public Gfx::Graphics {
|
||||
virtual Gfx::OWindow createWindow(const WindowCreateInfo& createInfo) override;
|
||||
virtual Gfx::OViewport createViewport(Gfx::PWindow owner, const ViewportCreateInfo& createInfo) override;
|
||||
|
||||
virtual Gfx::ORenderPass createRenderPass(Gfx::RenderTargetLayout layout, Array<Gfx::SubPassDependency> dependencies,
|
||||
Gfx::PViewport renderArea, std::string name = "") override;
|
||||
virtual Gfx::ORenderPass createRenderPass(Gfx::RenderTargetLayout layout, Array<Gfx::SubPassDependency> dependencies, URect renderArea, std::string name, Array<uint32> viewMasks, Array<uint32> correlationMasks) override;
|
||||
virtual void beginRenderPass(Gfx::PRenderPass renderPass) override;
|
||||
virtual void endRenderPass() override;
|
||||
virtual void waitDeviceIdle() override;
|
||||
|
||||
@@ -38,8 +38,7 @@ Gfx::OViewport Graphics::createViewport(Gfx::PWindow owner, const ViewportCreate
|
||||
return new Viewport(owner, createInfo);
|
||||
}
|
||||
|
||||
Gfx::ORenderPass Graphics::createRenderPass(Gfx::RenderTargetLayout layout, Array<Gfx::SubPassDependency> dependencies,
|
||||
Gfx::PViewport renderArea, std::string name) {
|
||||
Gfx::ORenderPass Graphics::createRenderPass(Gfx::RenderTargetLayout layout, Array<Gfx::SubPassDependency> dependencies, URect renderArea, std::string name, Array<uint32> viewMask, Array<uint32> correlationMask) {
|
||||
return new RenderPass(this, layout, dependencies, renderArea, name);
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace Metal {
|
||||
DECLARE_REF(Graphics)
|
||||
class RenderPass : public Gfx::RenderPass {
|
||||
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 = "");
|
||||
virtual ~RenderPass();
|
||||
void updateRenderPass();
|
||||
@@ -16,7 +16,7 @@ class RenderPass : public Gfx::RenderPass {
|
||||
|
||||
private:
|
||||
PGraphics graphics;
|
||||
Gfx::PViewport viewport;
|
||||
URect renderArea;
|
||||
MTL::RenderPassDescriptor* renderPass;
|
||||
std::string name;
|
||||
};
|
||||
|
||||
@@ -8,13 +8,12 @@ using namespace Seele;
|
||||
using namespace Seele::Metal;
|
||||
|
||||
RenderPass::RenderPass(PGraphics graphics, Gfx::RenderTargetLayout _layout, Array<Gfx::SubPassDependency> dependencies,
|
||||
Gfx::PViewport viewport, const std::string& name)
|
||||
: Gfx::RenderPass(std::move(_layout), dependencies), graphics(graphics), viewport(viewport), name(name) {
|
||||
URect renderArea, const std::string& name)
|
||||
: Gfx::RenderPass(std::move(_layout), dependencies), graphics(graphics), renderArea(renderArea), name(name) {
|
||||
renderPass = MTL::RenderPassDescriptor::renderPassDescriptor();
|
||||
renderPass->setRenderTargetArrayLength(1);
|
||||
renderPass->setRenderTargetWidth(viewport->getWidth());
|
||||
renderPass->setRenderTargetHeight(viewport->getHeight());
|
||||
renderPass->setDefaultRasterSampleCount(viewport->getSamples());
|
||||
renderPass->setRenderTargetWidth(renderArea.size.x);
|
||||
renderPass->setRenderTargetHeight(renderArea.size.y);
|
||||
|
||||
for (size_t i = 0; i < layout.colorAttachments.size(); ++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)
|
||||
: 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,
|
||||
Gfx::SePipelineStageFlags dstStage) {
|
||||
|
||||
Reference in New Issue
Block a user