Skip to content

Commit

Permalink
Oops, fix for previous commit. And minor optimization.
Browse files Browse the repository at this point in the history
  • Loading branch information
hrydgard committed Nov 12, 2023
1 parent 2530bc8 commit cc6f9a7
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions GPU/Common/FramebufferManagerCommon.cpp
Expand Up @@ -1328,13 +1328,18 @@ Draw::Texture *FramebufferManagerCommon::MakePixelTexture(const u8 *srcPixels, G
int widthInBytes = width * bpp;

// Compute hash of contents.
XXH3_state_t *hashState = XXH3_createState();
XXH3_64bits_reset(hashState);
for (int y = 0; y < height; y++) {
XXH3_64bits_update(hashState, srcPixels + srcStrideInBytes, widthInBytes);
uint64_t imageHash;
if (widthInBytes == srcStrideInBytes) {
imageHash = XXH3_64bits(srcPixels, widthInBytes * height);
} else {
XXH3_state_t *hashState = XXH3_createState();
XXH3_64bits_reset(hashState);
for (int y = 0; y < height; y++) {
XXH3_64bits_update(hashState, srcPixels + srcStrideInBytes * y, widthInBytes);
}
imageHash = XXH3_64bits_digest(hashState);
XXH3_freeState(hashState);
}
uint64_t imageHash = XXH3_64bits_digest(hashState);
XXH3_freeState(hashState);

// TODO: We can just change the texture format and flip some bits around instead of this.
// Could share code with the texture cache perhaps.
Expand Down

0 comments on commit cc6f9a7

Please sign in to comment.