Metal: IWYU fixes

This commit is contained in:
wheremyfoodat 2024-11-09 13:44:41 +02:00
parent 10451a676b
commit d7e4cf18b5
5 changed files with 17 additions and 13 deletions

View file

@ -2,6 +2,7 @@
#include <map>
#include "objc_helper.hpp"
#include "pica_to_mtl.hpp"
using namespace PICA;

View file

@ -2,6 +2,7 @@
#include <map>
#include "objc_helper.hpp"
#include "pica_to_mtl.hpp"
using namespace PICA;

View file

@ -11,7 +11,6 @@
#include "opengl.hpp"
#include "renderer_mtl/pica_to_mtl.hpp"
template <typename T>
using Interval = boost::icl::right_open_interval<T>;

View file

@ -1,13 +1,17 @@
#pragma once
#include <cstring>
#include "helpers.hpp"
#include "pica_to_mtl.hpp"
using namespace PICA;
namespace Metal {
struct BufferHandle {
MTL::Buffer* buffer;
size_t offset;
usize offset;
};
class VertexBufferCache {
@ -35,7 +39,7 @@ namespace Metal {
additionalAllocations.clear();
}
BufferHandle get(const void* data, size_t size) {
BufferHandle get(const void* data, usize size) {
// If the vertex buffer is too large, just create a new one
if (ptr + size > CACHE_BUFFER_SIZE) {
MTL::Buffer* newBuffer = device->newBuffer(data, size, MTL::ResourceStorageModeShared);
@ -47,9 +51,9 @@ namespace Metal {
}
// Copy the data into the buffer
memcpy((char*)buffer->contents() + ptr, data, size);
std::memcpy((char*)buffer->contents() + ptr, data, size);
size_t oldPtr = ptr;
auto oldPtr = ptr;
ptr += size;
return BufferHandle{buffer, oldPtr};
@ -57,6 +61,7 @@ namespace Metal {
void reset() {
endFrame();
if (buffer) {
buffer->release();
create();
@ -65,7 +70,7 @@ namespace Metal {
private:
MTL::Buffer* buffer = nullptr;
size_t ptr = 0;
usize ptr = 0;
std::vector<MTL::Buffer*> additionalAllocations;
MTL::Device* device;

View file

@ -4,7 +4,6 @@
#include "PICA/regs.hpp"
namespace PICA {
struct PixelFormatInfo {
MTL::PixelFormat pixelFormat;
@ -61,7 +60,7 @@ namespace PICA {
case 5: return MTL::CompareFunctionLessEqual;
case 6: return MTL::CompareFunctionGreater;
case 7: return MTL::CompareFunctionGreaterEqual;
default: panic("Unknown compare function %u", func);
default: Helpers::panic("Unknown compare function %u", func);
}
return MTL::CompareFunctionAlways;
@ -77,7 +76,7 @@ namespace PICA {
case 5: return MTL::BlendOperationAdd; // Unused (same as 0)
case 6: return MTL::BlendOperationAdd; // Unused (same as 0)
case 7: return MTL::BlendOperationAdd; // Unused (same as 0)
default: panic("Unknown blend operation %u", op);
default: Helpers::panic("Unknown blend operation %u", op);
}
return MTL::BlendOperationAdd;
@ -101,7 +100,7 @@ namespace PICA {
case 13: return MTL::BlendFactorOneMinusBlendAlpha;
case 14: return MTL::BlendFactorSourceAlphaSaturated;
case 15: return MTL::BlendFactorOne; // Undocumented
default: panic("Unknown blend factor %u", factor);
default: Helpers::panic("Unknown blend factor %u", factor);
}
return MTL::BlendFactorOne;
@ -117,7 +116,7 @@ namespace PICA {
case 5: return MTL::StencilOperationInvert;
case 6: return MTL::StencilOperationIncrementWrap;
case 7: return MTL::StencilOperationDecrementWrap;
default: panic("Unknown stencil operation %u", op);
default: Helpers::panic("Unknown stencil operation %u", op);
}
return MTL::StencilOperationKeep;
@ -131,7 +130,6 @@ namespace PICA {
Helpers::warn("Triangle fans are not supported on Metal, using triangles instead");
return MTL::PrimitiveTypeTriangle;
case PrimType::GeometryPrimitive:
// Helpers::warn("Geometry primitives are not yet, using triangles instead");
return MTL::PrimitiveTypeTriangle;
}
}
@ -146,7 +144,7 @@ namespace PICA {
case 5: return MTL::SamplerAddressModeClampToBorderColor;
case 6: return MTL::SamplerAddressModeRepeat;
case 7: return MTL::SamplerAddressModeRepeat;
default: panic("Unknown sampler address mode %u", addrMode);
default: Helpers::panic("Unknown sampler address mode %u", addrMode);
}
return MTL::SamplerAddressModeClampToEdge;