dfa2fd0e0d
* code: Prepare frontend for vulkan support * citra_qt: Add vulkan options to the GUI * vk_instance: Collect tooling info * renderer_vulkan: Add vulkan backend * qt: Fix fullscreen and resize issues on macOS. (#47) * qt: Fix bugged macOS full screen transition. * renderer/vulkan: Fix swapchain recreation destroying in-use semaphore. * renderer/vulkan: Make gl_Position invariant. (#48) This fixes an issue with black artifacts in Pokemon games on Apple GPUs. If the vertex calculations differ slightly between render passes, it can cause parts of model faces to fail depth test. * vk_renderpass_cache: Bump pixel format count * android: Custom driver code * vk_instance: Set moltenvk configuration * rasterizer_cache: Proper surface unregister * citra_qt: Fix invalid characters * vk_rasterizer: Correct special unbind * android: Allow async presentation toggle * vk_graphics_pipeline: Fix async shader compilation * We were actually waiting for the pipelines regardless of the setting, oops * vk_rasterizer: More robust attribute loading * android: Move PollEvents to OpenGL window * Vulkan does not need this and it causes problems * vk_instance: Enable robust buffer access * Improves stability on mali devices * vk_renderpass_cache: Bring back renderpass flushing * externals: Update vulkan-headers * gl_rasterizer: Separable shaders for everyone * vk_blit_helper: Corect depth to color convertion * renderer_vulkan: Implement reinterpretation with copy * Allows reinterpreteration with simply copy on AMD * vk_graphics_pipeline: Only fast compile if no shaders are pending * With this shaders weren't being compiled in parallel * vk_swapchain: Ensure vsync doesn't lock framerate * vk_present_window: Match guest swapchain size to vulkan image count * Less latency and fixes crashes that were caused by images being deleted before free * vk_instance: Blacklist VK_EXT_pipeline_creation_cache_control with nvidia gpus * Resolves crashes when async shader compilation is enabled * vk_rasterizer: Bump async threshold to 6 * Many games have fullscreen quads with 6 vertices. Fixes pokemon textures missing with async shaders * android: More robust surface recreation * renderer_vulkan: Fix dynamic state being lost * vk_pipeline_cache: Skip cache save when no pipeline cache exists * This is the cache when loading a save state * sdl: Fix surface initialization on macOS. (#49) * sdl: Fix surface initialization on macOS. * sdl: Fix render window events not being handled under Vulkan. * renderer/vulkan: Fix binding/unbinding of shadow rendering buffer. * vk_stream_buffer: Respect non coherent access alignment * Required by nvidia GPUs on MacOS * renderer/vulkan: Support VK_EXT_fragment_shader_interlock for shadow rendering. (#51) * renderer_vulkan: Port some recent shader fixes * vk_pipeline_cache: Improve shadow detection * vk_swapchain: Add missing check * renderer_vulkan: Fix hybrid screen * Revert "gl_rasterizer: Separable shaders for everyone" Causes crashes on mali GPUs, will need separate PR This reverts commit d22d556d30ff641b62dfece85738c96b7fbf7061. * renderer_vulkan: Fix flipped screenshot --------- Co-authored-by: Steveice10 <1269164+Steveice10@users.noreply.github.com>
86 lines
2.9 KiB
C++
86 lines
2.9 KiB
C++
// Copyright 2015 Citra Emulator Project
|
|
// Licensed under GPLv2 or any later version
|
|
// Refer to the license.txt file included.
|
|
|
|
#pragma once
|
|
|
|
#include <cstddef>
|
|
#include <cstring>
|
|
#include "common/cityhash.h"
|
|
#include "common/common_types.h"
|
|
|
|
namespace Common {
|
|
|
|
/**
|
|
* Computes a 64-bit hash over the specified block of data
|
|
* @param data Block of data 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
|
|
*/
|
|
static inline u64 ComputeHash64(const void* data, std::size_t len) noexcept {
|
|
return CityHash64(static_cast<const char*>(data), len);
|
|
}
|
|
|
|
/**
|
|
* Computes a 64-bit hash of a struct. In addition to being trivially copyable, it is also critical
|
|
* that either the struct includes no padding, or that any padding is initialized to a known value
|
|
* by memsetting the struct to 0 before filling it in.
|
|
*/
|
|
template <typename T>
|
|
static inline u64 ComputeStructHash64(const T& data) noexcept {
|
|
static_assert(std::is_trivially_copyable_v<T>,
|
|
"Type passed to ComputeStructHash64 must be trivially copyable");
|
|
return ComputeHash64(&data, sizeof(data));
|
|
}
|
|
|
|
/**
|
|
* Combines the seed parameter with the provided hash, producing a new unique hash
|
|
* Implementation from: http://boost.sourceforge.net/doc/html/boost/hash_combine.html
|
|
*/
|
|
inline u64 HashCombine(std::size_t seed, const u64 hash) {
|
|
return seed ^ (hash + 0x9e3779b9 + (seed << 6) + (seed >> 2));
|
|
}
|
|
|
|
template <typename T>
|
|
struct IdentityHash {
|
|
std::size_t operator()(const T& value) const {
|
|
return value;
|
|
}
|
|
};
|
|
|
|
/// A helper template that ensures the padding in a struct is initialized by memsetting to 0.
|
|
template <typename T>
|
|
struct HashableStruct {
|
|
// In addition to being trivially copyable, T must also have a trivial default constructor,
|
|
// because any member initialization would be overridden by memset
|
|
static_assert(std::is_trivial_v<T>, "Type passed to HashableStruct must be trivial");
|
|
/*
|
|
* We use a union because "implicitly-defined copy/move constructor for a union X copies the
|
|
* object representation of X." and "implicitly-defined copy assignment operator for a union X
|
|
* copies the object representation (3.9) of X." = Bytewise copy instead of memberwise copy.
|
|
* This is important because the padding bytes are included in the hash and comparison between
|
|
* objects.
|
|
*/
|
|
union {
|
|
T state;
|
|
};
|
|
|
|
HashableStruct() noexcept {
|
|
// Memset structure to zero padding bits, so that they will be deterministic when hashing
|
|
std::memset(&state, 0, sizeof(T));
|
|
}
|
|
|
|
bool operator==(const HashableStruct<T>& o) const noexcept {
|
|
return std::memcmp(&state, &o.state, sizeof(T)) == 0;
|
|
};
|
|
|
|
bool operator!=(const HashableStruct<T>& o) const noexcept {
|
|
return !(*this == o);
|
|
};
|
|
|
|
std::size_t Hash() const noexcept {
|
|
return Common::ComputeStructHash64(state);
|
|
}
|
|
};
|
|
|
|
} // namespace Common
|