More metal changes
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#include "PipelineCache.h"
|
||||
#include "Descriptor.h"
|
||||
#include "Enums.h"
|
||||
#include "RenderPass.h"
|
||||
#include "Foundation/NSError.hpp"
|
||||
#include "Foundation/NSString.hpp"
|
||||
#include "Graphics.h"
|
||||
@@ -25,8 +26,7 @@ PipelineCache::PipelineCache(PGraphics graphics, const std::string& name) : grap
|
||||
PipelineCache::~PipelineCache() {}
|
||||
|
||||
PGraphicsPipeline PipelineCache::createPipeline(Gfx::LegacyPipelineCreateInfo createInfo) {
|
||||
PPipelineLayout layout = Gfx::PPipelineLayout(createInfo.pipelineLayout).cast<PipelineLayout>();
|
||||
|
||||
PRenderPass renderPass = createInfo.renderPass.cast<RenderPass>();
|
||||
MTL::RenderPipelineDescriptor* pipelineDescriptor = MTL::RenderPipelineDescriptor::alloc()->init();
|
||||
|
||||
MTL::VertexDescriptor* vertexDescriptor = pipelineDescriptor->vertexDescriptor()->init();
|
||||
@@ -68,6 +68,16 @@ PGraphicsPipeline PipelineCache::createPipeline(Gfx::LegacyPipelineCreateInfo cr
|
||||
pipelineDescriptor->setFragmentFunction(createInfo.fragmentShader.cast<FragmentShader>()->getFunction());
|
||||
}
|
||||
pipelineDescriptor->setInputPrimitiveTopology(cast(createInfo.topology));
|
||||
for(uint c = 0; c < renderPass->getLayout().colorAttachments.size(); ++c) {
|
||||
const auto& color = renderPass->getLayout().colorAttachments[c];
|
||||
MTL::RenderPipelineColorAttachmentDescriptor* desc = MTL::RenderPipelineColorAttachmentDescriptor::alloc()->init();
|
||||
desc->setWriteMask(MTL::ColorWriteMaskAll);
|
||||
desc->setPixelFormat(cast(color.getFormat()));
|
||||
desc->setAlphaBlendOperation(MTL::BlendOperationAdd);
|
||||
desc->setDestinationAlphaBlendFactor(MTL::BlendFactorDestinationAlpha);
|
||||
desc->setBlendingEnabled(false);
|
||||
pipelineDescriptor->colorAttachments()->setObject(desc, c);
|
||||
}
|
||||
if (createInfo.renderPass->getLayout().depthAttachment.getTexture() != nullptr) {
|
||||
pipelineDescriptor->setDepthAttachmentPixelFormat(
|
||||
cast(createInfo.renderPass->getLayout().depthAttachment.getTexture().cast<Texture2D>()->getFormat()));
|
||||
@@ -131,6 +141,7 @@ PGraphicsPipeline PipelineCache::createPipeline(Gfx::LegacyPipelineCreateInfo cr
|
||||
}
|
||||
|
||||
PGraphicsPipeline PipelineCache::createPipeline(Gfx::MeshPipelineCreateInfo createInfo) {
|
||||
PRenderPass renderPass = createInfo.renderPass.cast<RenderPass>();
|
||||
MTL::MeshRenderPipelineDescriptor* pipelineDescriptor = MTL::MeshRenderPipelineDescriptor::alloc()->init();
|
||||
|
||||
pipelineDescriptor->setMeshFunction(createInfo.meshShader.cast<MeshShader>()->getFunction());
|
||||
@@ -140,6 +151,16 @@ PGraphicsPipeline PipelineCache::createPipeline(Gfx::MeshPipelineCreateInfo crea
|
||||
if (createInfo.fragmentShader != nullptr) {
|
||||
pipelineDescriptor->setFragmentFunction(createInfo.fragmentShader.cast<FragmentShader>()->getFunction());
|
||||
}
|
||||
for(uint c = 0; c < renderPass->getLayout().colorAttachments.size(); ++c) {
|
||||
const auto& color = renderPass->getLayout().colorAttachments[c];
|
||||
MTL::RenderPipelineColorAttachmentDescriptor* desc = MTL::RenderPipelineColorAttachmentDescriptor::alloc()->init();
|
||||
desc->setWriteMask(MTL::ColorWriteMaskAll);
|
||||
desc->setPixelFormat(cast(color.getFormat()));
|
||||
desc->setAlphaBlendOperation(MTL::BlendOperationAdd);
|
||||
desc->setDestinationAlphaBlendFactor(MTL::BlendFactorDestinationAlpha);
|
||||
desc->setBlendingEnabled(false);
|
||||
pipelineDescriptor->colorAttachments()->setObject(desc, c);
|
||||
}
|
||||
if (createInfo.renderPass->getLayout().depthAttachment.getTexture() != nullptr) {
|
||||
pipelineDescriptor->setDepthAttachmentPixelFormat(
|
||||
cast(createInfo.renderPass->getLayout().depthAttachment.getTexture().cast<Texture2D>()->getFormat()));
|
||||
|
||||
@@ -90,7 +90,7 @@ Window::Window(PGraphics graphics, const WindowCreateInfo& createInfo) : graphic
|
||||
metalLayer.drawableSize = CGSizeMake(createInfo.width, createInfo.height);
|
||||
metalWindow.contentView.layer = metalLayer;
|
||||
metalWindow.contentView.wantsLayer = YES;
|
||||
framebufferFormat = Gfx::SE_FORMAT_R8G8B8A8_UNORM;
|
||||
framebufferFormat = Gfx::SE_FORMAT_B8G8R8A8_UNORM;
|
||||
|
||||
drawable = (__bridge CA::MetalDrawable*)[metalLayer nextDrawable];
|
||||
createBackBuffer();
|
||||
|
||||
Reference in New Issue
Block a user