Merge pull request #87 from wheremyfoodat/superskyler

Make colour/depth buffers to also do ringing for now, add exp2/log2 approximations in x87 to the shader JIT
This commit is contained in:
wheremyfoodat 2023-07-09 02:10:42 +03:00 committed by GitHub
commit 482233f601
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 90 additions and 16 deletions

View file

@ -82,11 +82,13 @@ class ShaderEmitter : public Xbyak::CodeGenerator {
void recDP4(const PICAShader& shader, u32 instruction);
void recEMIT(const PICAShader& shader, u32 instruction);
void recEND(const PICAShader& shader, u32 instruction);
void recEX2(const PICAShader& shader, u32 instruction);
void recFLR(const PICAShader& shader, u32 instruction);
void recIFC(const PICAShader& shader, u32 instruction);
void recIFU(const PICAShader& shader, u32 instruction);
void recJMPC(const PICAShader& shader, u32 instruction);
void recJMPU(const PICAShader& shader, u32 instruction);
void recLG2(const PICAShader& shader, u32 instruction);
void recLOOP(const PICAShader& shader, u32 instruction);
void recMAD(const PICAShader& shader, u32 instruction);
void recMAX(const PICAShader& shader, u32 instruction);

View file

@ -43,8 +43,8 @@ class Renderer {
float oldDepthOffset = 0.0;
bool oldDepthmapEnable = false;
SurfaceCache<DepthBuffer, 10> depthBufferCache;
SurfaceCache<ColourBuffer, 10> colourBufferCache;
SurfaceCache<DepthBuffer, 10, true> depthBufferCache;
SurfaceCache<ColourBuffer, 10, true> colourBufferCache;
SurfaceCache<Texture, 256, true> textureCache;
OpenGL::uvec2 fbSize; // The size of the framebuffer (ie both the colour and depth buffer)'

View file

@ -46,7 +46,7 @@ public:
OptionalRef findFromAddress(u32 address) {
for (auto& e : buffer) {
if (e.location == address && e.valid)
if (e.location <= address && e.location + e.sizeInBytes() > address && e.valid)
return e;
}
@ -57,6 +57,10 @@ public:
SurfaceType& add(const SurfaceType& surface) {
if (size >= capacity) {
if constexpr (evictOnOverflow) { // Do a ring buffer if evictOnOverflow is true
if constexpr (std::is_same<SurfaceType, ColourBuffer>() || std::is_same<SurfaceType, DepthBuffer>()) {
Helpers::panicDev("Colour/Depth buffer cache overflowed, currently stubbed to do a ring-buffer. This might snap in half");
}
auto& e = buffer[evictionIndex];
evictionIndex = (evictionIndex + 1) % capacity;

View file

@ -58,11 +58,13 @@ struct ColourBuffer {
}
void free() {
valid = false;
valid = false;
if (texture.exists() || fbo.exists())
Helpers::panic("Make this buffer free itself");
}
if (texture.exists() || fbo.exists()) {
texture.free();
fbo.free();
}
}
bool matches(ColourBuffer& other) {
return location == other.location && format == other.format &&
@ -128,9 +130,11 @@ struct DepthBuffer {
}
void free() {
valid = false;
printf("Make this depth buffer free itself\n");
}
valid = false;
if (texture.exists()) {
texture.free();
}
}
bool matches(DepthBuffer& other) {
return location == other.location && format == other.format &&