use proper render targets

This commit is contained in:
Samuliak 2024-07-02 16:54:48 +02:00
parent 53c9611ac2
commit 56262c2c24
4 changed files with 130 additions and 31 deletions

View file

@ -17,7 +17,7 @@ struct RenderTarget {
MTL::Device* device;
u32 location;
PICA::TextureFmt format;
PICA::ColorFmt format;
OpenGL::uvec2 size;
bool valid;
@ -28,7 +28,7 @@ struct RenderTarget {
RenderTarget() : valid(false) {}
RenderTarget(MTL::Device* dev, u32 loc, PICA::TextureFmt format, u32 x, u32 y, bool valid = true)
RenderTarget(MTL::Device* dev, u32 loc, PICA::ColorFmt format, u32 x, u32 y, bool valid = true)
: device(dev), location(loc), format(format), size({x, y}), valid(valid) {
u64 endLoc = (u64)loc + sizeInBytes();
@ -45,7 +45,7 @@ struct RenderTarget {
// For 2 textures to "match" we only care about their locations, formats, and dimensions to match
// For other things, such as filtering mode, etc, we can just switch the attributes of the cached texture
bool matches(Texture& other) {
bool matches(RenderTarget& other) {
return location == other.location && format == other.format &&
size.x() == other.size.x() && size.y() == other.size.y();
}

View file

@ -35,13 +35,10 @@ class RendererMTL final : public Renderer {
MTL::CommandQueue* commandQueue;
// Caches
SurfaceCache<Metal::Texture, 16, true> colorRenderTargetCache;
SurfaceCache<Metal::Texture, 16, true> depthStencilRenderTargetCache;
SurfaceCache<Metal::RenderTarget, 16, true> colorRenderTargetCache;
SurfaceCache<Metal::RenderTarget, 16, true> depthStencilRenderTargetCache;
SurfaceCache<Metal::Texture, 256, true> textureCache;
// HACK
MTL::Texture* topScreenTexture;
// Helpers
MTL::SamplerState* basicSampler;
@ -58,6 +55,7 @@ class RendererMTL final : public Renderer {
}
}
std::optional<Metal::RenderTarget> getColorRenderTarget(u32 addr, PICA::ColorFmt format, u32 width, u32 height, bool createIfnotFound = true);
MTL::Texture* getTexture(Metal::Texture& tex);
void setupTextureEnvState(MTL::RenderCommandEncoder* encoder);
void bindTexturesToSlots(MTL::RenderCommandEncoder* encoder);