mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-06-04 04:47:22 +12:00
rework the lut system
This commit is contained in:
parent
90420160f2
commit
158be432fc
9 changed files with 273 additions and 152 deletions
|
@ -135,7 +135,10 @@ public:
|
|||
colorAttachment->setDestinationAlphaBlendFactor(toMTLBlendFactor(alphaDestFunc));
|
||||
}
|
||||
|
||||
desc->setDepthAttachmentPixelFormat(toMTLPixelFormatDepth(hash.depthFmt));
|
||||
MTL::PixelFormat depthFormat = toMTLPixelFormatDepth(hash.depthFmt);
|
||||
desc->setDepthAttachmentPixelFormat(depthFormat);
|
||||
if (hash.depthFmt == DepthFmt::Depth24Stencil8)
|
||||
desc->setStencilAttachmentPixelFormat(depthFormat);
|
||||
|
||||
NS::Error* error = nullptr;
|
||||
desc->setLabel(toNSString("Draw pipeline"));
|
||||
|
|
25
include/renderer_mtl/mtl_lut_texture.hpp
Normal file
25
include/renderer_mtl/mtl_lut_texture.hpp
Normal file
|
@ -0,0 +1,25 @@
|
|||
#pragma once
|
||||
|
||||
#include <Metal/Metal.hpp>
|
||||
|
||||
namespace Metal {
|
||||
|
||||
class LutTexture {
|
||||
public:
|
||||
LutTexture(MTL::Device* device, MTL::TextureType type, MTL::PixelFormat pixelFormat, u32 width, u32 height, const char* name);
|
||||
~LutTexture();
|
||||
|
||||
u32 getNextIndex();
|
||||
|
||||
// Getters
|
||||
MTL::Texture* getTexture() { return texture; }
|
||||
|
||||
u32 getCurrentIndex() { return currentIndex; }
|
||||
|
||||
private:
|
||||
MTL::Texture* texture;
|
||||
|
||||
u32 currentIndex = 0;
|
||||
};
|
||||
|
||||
} // namespace Metal
|
|
@ -1,4 +1,5 @@
|
|||
#pragma once
|
||||
|
||||
#include <array>
|
||||
#include <string>
|
||||
#include <Metal/Metal.hpp>
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
#pragma once
|
||||
|
||||
#include <Metal/Metal.hpp>
|
||||
#include <QuartzCore/QuartzCore.hpp>
|
||||
|
||||
|
@ -8,6 +10,8 @@
|
|||
#include "mtl_draw_pipeline_cache.hpp"
|
||||
#include "mtl_depth_stencil_cache.hpp"
|
||||
#include "mtl_vertex_buffer_cache.hpp"
|
||||
#include "mtl_lut_texture.hpp"
|
||||
|
||||
// HACK: use the OpenGL cache
|
||||
#include "../renderer_gl/surface_cache.hpp"
|
||||
|
||||
|
@ -54,12 +58,15 @@ class RendererMTL final : public Renderer {
|
|||
Metal::DepthStencilCache depthStencilCache;
|
||||
Metal::VertexBufferCache vertexBufferCache;
|
||||
|
||||
// Objects
|
||||
// Resources
|
||||
MTL::SamplerState* nearestSampler;
|
||||
MTL::SamplerState* linearSampler;
|
||||
MTL::Texture* lutTexture;
|
||||
MTL::Texture* nullTexture;
|
||||
MTL::DepthStencilState* defaultDepthStencilState;
|
||||
|
||||
Metal::LutTexture* lutLightingTexture;
|
||||
Metal::LutTexture* lutFogTexture;
|
||||
|
||||
// Pipelines
|
||||
MTL::RenderPipelineState* displayPipeline;
|
||||
MTL::RenderPipelineState* copyToLutTexturePipeline;
|
||||
|
@ -91,21 +98,7 @@ class RendererMTL final : public Renderer {
|
|||
}
|
||||
}
|
||||
|
||||
void beginRenderPassIfNeeded(MTL::RenderPassDescriptor* renderPassDescriptor, bool doesClears, MTL::Texture* colorTexture, MTL::Texture* depthTexture = nullptr) {
|
||||
createCommandBufferIfNeeded();
|
||||
|
||||
if (doesClears || !renderCommandEncoder || colorTexture != lastColorTexture || (depthTexture != lastDepthTexture && !(lastDepthTexture && !depthTexture))) {
|
||||
endRenderPass();
|
||||
|
||||
renderCommandEncoder = commandBuffer->renderCommandEncoder(renderPassDescriptor);
|
||||
renderCommandEncoder->setLabel(toNSString(nextRenderPassName));
|
||||
|
||||
lastColorTexture = colorTexture;
|
||||
lastDepthTexture = depthTexture;
|
||||
}
|
||||
|
||||
renderPassDescriptor->release();
|
||||
}
|
||||
void beginRenderPassIfNeeded(MTL::RenderPassDescriptor* renderPassDescriptor, bool doesClears, MTL::Texture* colorTexture, MTL::Texture* depthTexture = nullptr);
|
||||
|
||||
void commitCommandBuffer() {
|
||||
if (renderCommandEncoder) {
|
||||
|
@ -115,6 +108,8 @@ class RendererMTL final : public Renderer {
|
|||
}
|
||||
if (commandBuffer) {
|
||||
commandBuffer->commit();
|
||||
// HACK
|
||||
commandBuffer->waitUntilCompleted();
|
||||
commandBuffer->release();
|
||||
commandBuffer = nullptr;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue