[GPU] XXH3 hash instead of XXH64
This commit is contained in:
@@ -552,14 +552,14 @@ std::pair<VkBuffer, VkDeviceSize> BufferCache::UploadVertexBuffer(
|
||||
}
|
||||
|
||||
void BufferCache::HashVertexBindings(
|
||||
XXH64_state_t* hash_state,
|
||||
XXH3_state_t* hash_state,
|
||||
const std::vector<Shader::VertexBinding>& vertex_bindings) {
|
||||
auto& regs = *register_file_;
|
||||
for (const auto& vertex_binding : vertex_bindings) {
|
||||
#if 0
|
||||
XXH64_update(hash_state, &vertex_binding.binding_index, sizeof(vertex_binding.binding_index));
|
||||
XXH64_update(hash_state, &vertex_binding.fetch_constant, sizeof(vertex_binding.fetch_constant));
|
||||
XXH64_update(hash_state, &vertex_binding.stride_words, sizeof(vertex_binding.stride_words));
|
||||
XXH3_64bits_update(hash_state, &vertex_binding.binding_index, sizeof(vertex_binding.binding_index));
|
||||
XXH3_64bits_update(hash_state, &vertex_binding.fetch_constant, sizeof(vertex_binding.fetch_constant));
|
||||
XXH3_64bits_update(hash_state, &vertex_binding.stride_words, sizeof(vertex_binding.stride_words));
|
||||
#endif
|
||||
int r = XE_GPU_REG_SHADER_CONSTANT_FETCH_00_0 +
|
||||
(vertex_binding.fetch_constant / 3) * 6;
|
||||
@@ -567,15 +567,15 @@ void BufferCache::HashVertexBindings(
|
||||
switch (vertex_binding.fetch_constant % 3) {
|
||||
case 0: {
|
||||
auto& fetch = group->vertex_fetch_0;
|
||||
XXH64_update(hash_state, &fetch, sizeof(fetch));
|
||||
XXH3_64bits_update(hash_state, &fetch, sizeof(fetch));
|
||||
} break;
|
||||
case 1: {
|
||||
auto& fetch = group->vertex_fetch_1;
|
||||
XXH64_update(hash_state, &fetch, sizeof(fetch));
|
||||
XXH3_64bits_update(hash_state, &fetch, sizeof(fetch));
|
||||
} break;
|
||||
case 2: {
|
||||
auto& fetch = group->vertex_fetch_2;
|
||||
XXH64_update(hash_state, &fetch, sizeof(fetch));
|
||||
XXH3_64bits_update(hash_state, &fetch, sizeof(fetch));
|
||||
} break;
|
||||
}
|
||||
}
|
||||
@@ -585,12 +585,12 @@ VkDescriptorSet BufferCache::PrepareVertexSet(
|
||||
VkCommandBuffer command_buffer, VkFence fence,
|
||||
const std::vector<Shader::VertexBinding>& vertex_bindings) {
|
||||
// (quickly) Generate a hash.
|
||||
XXH64_state_t hash_state;
|
||||
XXH64_reset(&hash_state, 0);
|
||||
XXH3_state_t hash_state;
|
||||
XXH3_64bits_reset(&hash_state);
|
||||
|
||||
// (quickly) Generate a hash.
|
||||
HashVertexBindings(&hash_state, vertex_bindings);
|
||||
uint64_t hash = XXH64_digest(&hash_state);
|
||||
uint64_t hash = XXH3_64bits_digest(&hash_state);
|
||||
for (auto it = vertex_sets_.find(hash); it != vertex_sets_.end(); ++it) {
|
||||
// TODO(DrChat): We need to compare the bindings and ensure they're equal.
|
||||
return it->second;
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#ifndef XENIA_GPU_VULKAN_BUFFER_CACHE_H_
|
||||
#define XENIA_GPU_VULKAN_BUFFER_CACHE_H_
|
||||
|
||||
#include "xenia/base/xxhash.h"
|
||||
#include "xenia/gpu/register_file.h"
|
||||
#include "xenia/gpu/shader.h"
|
||||
#include "xenia/gpu/xenos.h"
|
||||
@@ -20,7 +21,6 @@
|
||||
#include "xenia/ui/vulkan/vulkan_device.h"
|
||||
|
||||
#include "third_party/vulkan/vk_mem_alloc.h"
|
||||
#include "third_party/xxhash/xxhash.h"
|
||||
|
||||
#include <map>
|
||||
#include <unordered_map>
|
||||
@@ -127,7 +127,7 @@ class BufferCache {
|
||||
void FreeConstantDescriptorSet();
|
||||
|
||||
void HashVertexBindings(
|
||||
XXH64_state_t* hash_state,
|
||||
XXH3_state_t* hash_state,
|
||||
const std::vector<Shader::VertexBinding>& vertex_bindings);
|
||||
|
||||
// Allocates a block of memory in the transient buffer.
|
||||
|
||||
@@ -9,11 +9,11 @@
|
||||
|
||||
#include "xenia/gpu/vulkan/pipeline_cache.h"
|
||||
|
||||
#include "third_party/xxhash/xxhash.h"
|
||||
#include "xenia/base/logging.h"
|
||||
#include "xenia/base/math.h"
|
||||
#include "xenia/base/memory.h"
|
||||
#include "xenia/base/profiling.h"
|
||||
#include "xenia/base/xxhash.h"
|
||||
#include "xenia/gpu/gpu_flags.h"
|
||||
#include "xenia/gpu/vulkan/vulkan_gpu_flags.h"
|
||||
|
||||
@@ -208,7 +208,8 @@ VulkanShader* PipelineCache::LoadShader(xenos::ShaderType shader_type,
|
||||
const uint32_t* host_address,
|
||||
uint32_t dword_count) {
|
||||
// Hash the input memory and lookup the shader.
|
||||
uint64_t data_hash = XXH64(host_address, dword_count * sizeof(uint32_t), 0);
|
||||
uint64_t data_hash =
|
||||
XXH3_64bits(host_address, dword_count * sizeof(uint32_t));
|
||||
auto it = shader_map_.find(data_hash);
|
||||
if (it != shader_map_.end()) {
|
||||
// Shader has been previously loaded.
|
||||
@@ -259,7 +260,7 @@ PipelineCache::UpdateStatus PipelineCache::ConfigurePipeline(
|
||||
}
|
||||
if (!pipeline) {
|
||||
// Should have a hash key produced by the UpdateState pass.
|
||||
uint64_t hash_key = XXH64_digest(&hash_state_);
|
||||
uint64_t hash_key = XXH3_64bits_digest(&hash_state_);
|
||||
pipeline = GetPipeline(render_state, hash_key);
|
||||
current_pipeline_ = pipeline;
|
||||
if (!pipeline) {
|
||||
@@ -961,7 +962,7 @@ PipelineCache::UpdateStatus PipelineCache::UpdateState(
|
||||
bool mismatch = false;
|
||||
|
||||
// Reset hash so we can build it up.
|
||||
XXH64_reset(&hash_state_, 0);
|
||||
XXH3_64bits_reset(&hash_state_);
|
||||
|
||||
#define CHECK_UPDATE_STATUS(status, mismatch, error_message) \
|
||||
{ \
|
||||
@@ -1028,7 +1029,7 @@ PipelineCache::UpdateStatus PipelineCache::UpdateRenderTargetState() {
|
||||
regs.rb_color1_info.color_format = cur_regs->rb_color1_info.color_format;
|
||||
regs.rb_color2_info.color_format = cur_regs->rb_color2_info.color_format;
|
||||
regs.rb_color3_info.color_format = cur_regs->rb_color3_info.color_format;
|
||||
XXH64_update(&hash_state_, ®s, sizeof(regs));
|
||||
XXH3_64bits_update(&hash_state_, ®s, sizeof(regs));
|
||||
if (!dirty) {
|
||||
return UpdateStatus::kCompatible;
|
||||
}
|
||||
@@ -1061,7 +1062,7 @@ PipelineCache::UpdateStatus PipelineCache::UpdateShaderStages(
|
||||
regs.vertex_shader = vertex_shader;
|
||||
regs.pixel_shader = pixel_shader;
|
||||
regs.primitive_type = primitive_type;
|
||||
XXH64_update(&hash_state_, ®s, sizeof(regs));
|
||||
XXH3_64bits_update(&hash_state_, ®s, sizeof(regs));
|
||||
if (!dirty) {
|
||||
return UpdateStatus::kCompatible;
|
||||
}
|
||||
@@ -1148,7 +1149,7 @@ PipelineCache::UpdateStatus PipelineCache::UpdateVertexInputState(
|
||||
bool dirty = false;
|
||||
dirty |= vertex_shader != regs.vertex_shader;
|
||||
regs.vertex_shader = vertex_shader;
|
||||
XXH64_update(&hash_state_, ®s, sizeof(regs));
|
||||
XXH3_64bits_update(&hash_state_, ®s, sizeof(regs));
|
||||
if (!dirty) {
|
||||
return UpdateStatus::kCompatible;
|
||||
}
|
||||
@@ -1177,7 +1178,7 @@ PipelineCache::UpdateStatus PipelineCache::UpdateInputAssemblyState(
|
||||
dirty |= SetShadowRegister(®s.multi_prim_ib_reset_index,
|
||||
XE_GPU_REG_VGT_MULTI_PRIM_IB_RESET_INDX);
|
||||
regs.primitive_type = primitive_type;
|
||||
XXH64_update(&hash_state_, ®s, sizeof(regs));
|
||||
XXH3_64bits_update(&hash_state_, ®s, sizeof(regs));
|
||||
if (!dirty) {
|
||||
return UpdateStatus::kCompatible;
|
||||
}
|
||||
@@ -1303,7 +1304,7 @@ PipelineCache::UpdateStatus PipelineCache::UpdateRasterizationState(
|
||||
dirty = true;
|
||||
}
|
||||
|
||||
XXH64_update(&hash_state_, ®s, sizeof(regs));
|
||||
XXH3_64bits_update(&hash_state_, ®s, sizeof(regs));
|
||||
if (!dirty) {
|
||||
return UpdateStatus::kCompatible;
|
||||
}
|
||||
@@ -1385,7 +1386,7 @@ PipelineCache::UpdateStatus PipelineCache::UpdateMultisampleState() {
|
||||
dirty |= SetShadowRegister(®s.pa_su_sc_mode_cntl,
|
||||
XE_GPU_REG_PA_SU_SC_MODE_CNTL);
|
||||
dirty |= SetShadowRegister(®s.rb_surface_info, XE_GPU_REG_RB_SURFACE_INFO);
|
||||
XXH64_update(&hash_state_, ®s, sizeof(regs));
|
||||
XXH3_64bits_update(&hash_state_, ®s, sizeof(regs));
|
||||
if (!dirty) {
|
||||
return UpdateStatus::kCompatible;
|
||||
}
|
||||
@@ -1437,7 +1438,7 @@ PipelineCache::UpdateStatus PipelineCache::UpdateDepthStencilState() {
|
||||
dirty |= SetShadowRegister(®s.rb_depthcontrol, XE_GPU_REG_RB_DEPTHCONTROL);
|
||||
dirty |=
|
||||
SetShadowRegister(®s.rb_stencilrefmask, XE_GPU_REG_RB_STENCILREFMASK);
|
||||
XXH64_update(&hash_state_, ®s, sizeof(regs));
|
||||
XXH3_64bits_update(&hash_state_, ®s, sizeof(regs));
|
||||
if (!dirty) {
|
||||
return UpdateStatus::kCompatible;
|
||||
}
|
||||
@@ -1526,7 +1527,7 @@ PipelineCache::UpdateStatus PipelineCache::UpdateColorBlendState() {
|
||||
dirty |=
|
||||
SetShadowRegister(®s.rb_blendcontrol[3], XE_GPU_REG_RB_BLENDCONTROL3);
|
||||
dirty |= SetShadowRegister(®s.rb_modecontrol, XE_GPU_REG_RB_MODECONTROL);
|
||||
XXH64_update(&hash_state_, ®s, sizeof(regs));
|
||||
XXH3_64bits_update(&hash_state_, ®s, sizeof(regs));
|
||||
if (!dirty) {
|
||||
return UpdateStatus::kCompatible;
|
||||
}
|
||||
|
||||
@@ -12,8 +12,7 @@
|
||||
|
||||
#include <unordered_map>
|
||||
|
||||
#include "third_party/xxhash/xxhash.h"
|
||||
|
||||
#include "xenia/base/xxhash.h"
|
||||
#include "xenia/gpu/register_file.h"
|
||||
#include "xenia/gpu/spirv_shader_translator.h"
|
||||
#include "xenia/gpu/vulkan/render_cache.h"
|
||||
@@ -121,7 +120,7 @@ class PipelineCache {
|
||||
// Hash state used to incrementally produce pipeline hashes during update.
|
||||
// By the time the full update pass has run the hash will represent the
|
||||
// current state in a way that can uniquely identify the produced VkPipeline.
|
||||
XXH64_state_t hash_state_;
|
||||
XXH3_state_t hash_state_;
|
||||
// All previously generated pipelines mapped by hash.
|
||||
std::unordered_map<uint64_t, VkPipeline> cached_pipelines_;
|
||||
|
||||
|
||||
@@ -1377,7 +1377,7 @@ void TextureCache::WritebackTexture(Texture* texture) {
|
||||
}
|
||||
|
||||
void TextureCache::HashTextureBindings(
|
||||
XXH64_state_t* hash_state, uint32_t& fetch_mask,
|
||||
XXH3_state_t* hash_state, uint32_t& fetch_mask,
|
||||
const std::vector<Shader::TextureBinding>& bindings) {
|
||||
for (auto& binding : bindings) {
|
||||
uint32_t fetch_bit = 1 << binding.fetch_constant;
|
||||
@@ -1393,7 +1393,7 @@ void TextureCache::HashTextureBindings(
|
||||
reinterpret_cast<const xenos::xe_gpu_fetch_group_t*>(®s.values[r]);
|
||||
auto& fetch = group->texture_fetch;
|
||||
|
||||
XXH64_update(hash_state, &fetch, sizeof(fetch));
|
||||
XXH3_64bits_update(hash_state, &fetch, sizeof(fetch));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1401,14 +1401,14 @@ VkDescriptorSet TextureCache::PrepareTextureSet(
|
||||
VkCommandBuffer command_buffer, VkFence completion_fence,
|
||||
const std::vector<Shader::TextureBinding>& vertex_bindings,
|
||||
const std::vector<Shader::TextureBinding>& pixel_bindings) {
|
||||
XXH64_state_t hash_state;
|
||||
XXH64_reset(&hash_state, 0);
|
||||
XXH3_state_t hash_state;
|
||||
XXH3_64bits_reset(&hash_state);
|
||||
|
||||
// (quickly) Generate a hash.
|
||||
uint32_t fetch_mask = 0;
|
||||
HashTextureBindings(&hash_state, fetch_mask, vertex_bindings);
|
||||
HashTextureBindings(&hash_state, fetch_mask, pixel_bindings);
|
||||
uint64_t hash = XXH64_digest(&hash_state);
|
||||
uint64_t hash = XXH3_64bits_digest(&hash_state);
|
||||
for (auto it = texture_sets_.find(hash); it != texture_sets_.end(); ++it) {
|
||||
// TODO(DrChat): We need to compare the bindings and ensure they're equal.
|
||||
return it->second;
|
||||
|
||||
@@ -186,7 +186,7 @@ class TextureCache {
|
||||
bool UploadTexture(VkCommandBuffer command_buffer, VkFence completion_fence,
|
||||
Texture* dest, const TextureInfo& src);
|
||||
|
||||
void HashTextureBindings(XXH64_state_t* hash_state, uint32_t& fetch_mask,
|
||||
void HashTextureBindings(XXH3_state_t* hash_state, uint32_t& fetch_mask,
|
||||
const std::vector<Shader::TextureBinding>& bindings);
|
||||
bool SetupTextureBindings(
|
||||
VkCommandBuffer command_buffer, VkFence completion_fence,
|
||||
|
||||
Reference in New Issue
Block a user