citra-emu
/
citra
Archived
1
0
Fork 0

Merge pull request #5290 from lioncash/shader

gl_shader_gen: Minor interface cleanup
This commit is contained in:
Ben 2020-05-01 16:16:25 +02:00 committed by GitHub
commit fd1b254635
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 10 deletions

View File

@ -17,7 +17,7 @@ namespace Common {
* @param len Length of data (in bytes) to compute hash over * @param len Length of data (in bytes) to compute hash over
* @returns 64-bit hash value that was computed over the data block * @returns 64-bit hash value that was computed over the data block
*/ */
static inline u64 ComputeHash64(const void* data, std::size_t len) { static inline u64 ComputeHash64(const void* data, std::size_t len) noexcept {
return CityHash64(static_cast<const char*>(data), len); return CityHash64(static_cast<const char*>(data), len);
} }
@ -27,7 +27,7 @@ static inline u64 ComputeHash64(const void* data, std::size_t len) {
* by memsetting the struct to 0 before filling it in. * by memsetting the struct to 0 before filling it in.
*/ */
template <typename T> template <typename T>
static inline u64 ComputeStructHash64(const T& data) { static inline u64 ComputeStructHash64(const T& data) noexcept {
static_assert(std::is_trivially_copyable_v<T>, static_assert(std::is_trivially_copyable_v<T>,
"Type passed to ComputeStructHash64 must be trivially copyable"); "Type passed to ComputeStructHash64 must be trivially copyable");
return ComputeHash64(&data, sizeof(data)); return ComputeHash64(&data, sizeof(data));
@ -50,20 +50,20 @@ struct HashableStruct {
T state; T state;
}; };
HashableStruct() { HashableStruct() noexcept {
// Memset structure to zero padding bits, so that they will be deterministic when hashing // Memset structure to zero padding bits, so that they will be deterministic when hashing
std::memset(&state, 0, sizeof(T)); std::memset(&state, 0, sizeof(T));
} }
bool operator==(const HashableStruct<T>& o) const { bool operator==(const HashableStruct<T>& o) const noexcept {
return std::memcmp(&state, &o.state, sizeof(T)) == 0; return std::memcmp(&state, &o.state, sizeof(T)) == 0;
}; };
bool operator!=(const HashableStruct<T>& o) const { bool operator!=(const HashableStruct<T>& o) const noexcept {
return !(*this == o); return !(*this == o);
}; };
std::size_t Hash() const { std::size_t Hash() const noexcept {
return Common::ComputeStructHash64(state); return Common::ComputeStructHash64(state);
} }
}; };

View File

@ -170,7 +170,7 @@ struct PicaVSConfig : Common::HashableStruct<PicaShaderConfigCommon> {
explicit PicaVSConfig(const Pica::ShaderRegs& regs, Pica::Shader::ShaderSetup& setup) { explicit PicaVSConfig(const Pica::ShaderRegs& regs, Pica::Shader::ShaderSetup& setup) {
state.Init(regs, setup); state.Init(regs, setup);
} }
explicit PicaVSConfig(PicaShaderConfigCommon& conf) { explicit PicaVSConfig(const PicaShaderConfigCommon& conf) {
state = conf; state = conf;
} }
}; };
@ -237,21 +237,21 @@ ShaderDecompiler::ProgramResult GenerateFragmentShader(const PicaFSConfig& confi
namespace std { namespace std {
template <> template <>
struct hash<OpenGL::PicaFSConfig> { struct hash<OpenGL::PicaFSConfig> {
std::size_t operator()(const OpenGL::PicaFSConfig& k) const { std::size_t operator()(const OpenGL::PicaFSConfig& k) const noexcept {
return k.Hash(); return k.Hash();
} }
}; };
template <> template <>
struct hash<OpenGL::PicaVSConfig> { struct hash<OpenGL::PicaVSConfig> {
std::size_t operator()(const OpenGL::PicaVSConfig& k) const { std::size_t operator()(const OpenGL::PicaVSConfig& k) const noexcept {
return k.Hash(); return k.Hash();
} }
}; };
template <> template <>
struct hash<OpenGL::PicaFixedGSConfig> { struct hash<OpenGL::PicaFixedGSConfig> {
std::size_t operator()(const OpenGL::PicaFixedGSConfig& k) const { std::size_t operator()(const OpenGL::PicaFixedGSConfig& k) const noexcept {
return k.Hash(); return k.Hash();
} }
}; };