mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-09-05 00:56:13 +00:00
VideoCommon: add hash functions for pipeline uid object
This commit is contained in:
parent
728b9e0c08
commit
c77adc9de8
2 changed files with 33 additions and 1 deletions
|
@ -148,4 +148,25 @@ GXPipelineUid ApplyDriverBugs(const GXPipelineUid& in)
|
|||
|
||||
return out;
|
||||
}
|
||||
|
||||
std::size_t PipelineToHash(const GXPipelineUid& in)
|
||||
{
|
||||
XXH3_state_t pipeline_hash_state;
|
||||
XXH3_INITSTATE(&pipeline_hash_state);
|
||||
XXH3_64bits_reset_withSeed(&pipeline_hash_state, static_cast<XXH64_hash_t>(1));
|
||||
UpdateHashWithPipeline(in, &pipeline_hash_state);
|
||||
return XXH3_64bits_digest(&pipeline_hash_state);
|
||||
}
|
||||
|
||||
void UpdateHashWithPipeline(const GXPipelineUid& in, XXH3_state_t* hash_state)
|
||||
{
|
||||
XXH3_64bits_update(hash_state, &in.vertex_format->GetVertexDeclaration(),
|
||||
sizeof(PortableVertexDeclaration));
|
||||
XXH3_64bits_update(hash_state, &in.blending_state, sizeof(BlendingState));
|
||||
XXH3_64bits_update(hash_state, &in.depth_state, sizeof(DepthState));
|
||||
XXH3_64bits_update(hash_state, &in.rasterization_state, sizeof(RasterizationState));
|
||||
XXH3_64bits_update(hash_state, &in.gs_uid, sizeof(GeometryShaderUid));
|
||||
XXH3_64bits_update(hash_state, &in.ps_uid, sizeof(PixelShaderUid));
|
||||
XXH3_64bits_update(hash_state, &in.vs_uid, sizeof(VertexShaderUid));
|
||||
}
|
||||
} // namespace VideoCommon
|
||||
|
|
|
@ -3,9 +3,20 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <xxh3.h>
|
||||
|
||||
#include "VideoCommon/GXPipelineTypes.h"
|
||||
|
||||
namespace VideoCommon
|
||||
{
|
||||
GXPipelineUid ApplyDriverBugs(const GXPipelineUid& in);
|
||||
}
|
||||
|
||||
// Returns a hash of the pipeline, hashing the
|
||||
// vertex declarations instead of the native vertex format
|
||||
// object
|
||||
std::size_t PipelineToHash(const GXPipelineUid& in);
|
||||
|
||||
// Updates an existing hash with the hash of the pipeline
|
||||
void UpdateHashWithPipeline(const GXPipelineUid& in, XXH3_state_t* hash_state);
|
||||
|
||||
} // namespace VideoCommon
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue