mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-07-08 00:02:58 +12:00
Add optional texture hashing
This commit is contained in:
parent
6182d4cfe9
commit
a0aa11dac0
10 changed files with 106 additions and 54 deletions
|
@ -9,6 +9,7 @@
|
|||
#undef NO
|
||||
|
||||
#include "PICA/gpu.hpp"
|
||||
#include "PICA/pica_hash.hpp"
|
||||
#include "SDL_metal.h"
|
||||
|
||||
using namespace PICA;
|
||||
|
@ -729,6 +730,19 @@ void RendererMTL::bindTexturesToSlots() {
|
|||
|
||||
if (addr != 0) [[likely]] {
|
||||
Metal::Texture targetTex(device, addr, static_cast<PICA::TextureFmt>(format), width, height, config);
|
||||
|
||||
if (hashTextures) {
|
||||
const u8* startPointer = gpu.getPointerPhys<u8>(targetTex.location);
|
||||
const usize sizeInBytes = targetTex.sizeInBytes();
|
||||
|
||||
if (startPointer == nullptr || (sizeInBytes > 0 && gpu.getPointerPhys<u8>(targetTex.location + sizeInBytes - 1) == nullptr))
|
||||
[[unlikely]] {
|
||||
Helpers::warn("Out-of-bounds texture fetch");
|
||||
} else {
|
||||
targetTex.hash = PICAHash::computeHash((const char*)startPointer, sizeInBytes);
|
||||
}
|
||||
}
|
||||
|
||||
auto tex = getTexture(targetTex);
|
||||
commandEncoder.setFragmentTexture(tex.texture, i);
|
||||
commandEncoder.setFragmentSamplerState(tex.sampler ? tex.sampler : nearestSampler, i);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue