Compare commits

...

2 Commits

Author SHA1 Message Date
ReinUsesLisp
c6e3c0e45c video_core: Replace most unordered hash tables with tsl-robin
Trivially replace most std::unordered_map usages with tsl::robin_map and
std::unordered_set with tsl::robin_set.

None std::unordered_* usage in video_core stores pointers or iterators
beyond their immediate scope. This allows us to swap to tsl::robin_*
tables without issues.
2020-07-17 21:47:51 -03:00
ReinUsesLisp
492c1a7dd4 cmake: Add tsl-robin-map as a conan dependency 2020-07-17 21:47:05 -03:00
35 changed files with 168 additions and 127 deletions

View File

@@ -165,6 +165,7 @@ macro(yuzu_find_packages)
#"libzip 1.5 libzip/1.5.2@bincrafters/stable"
"lz4 1.8 lz4/1.9.2"
"nlohmann_json 3.7 nlohmann_json/3.7.3"
"tsl-robin-map 0.6.2 tsl-robin-map/0.6.2@tessil/stable"
"ZLIB 1.2 zlib/1.2.11"
"zstd 1.4 zstd/1.4.4"
)

View File

@@ -239,6 +239,7 @@ create_target_directory_groups(video_core)
target_link_libraries(video_core PUBLIC common core)
target_link_libraries(video_core PRIVATE glad xbyak)
target_include_directories(video_core PRIVATE tsl-robin-map::tsl-robin-map)
if (ENABLE_VULKAN)
target_include_directories(video_core PRIVATE sirit ../../externals/Vulkan-Headers/include)

View File

@@ -4,7 +4,6 @@
#pragma once
#include <unordered_set>
#include <utility>
#include "common/alignment.h"

View File

@@ -7,8 +7,6 @@
#include <list>
#include <memory>
#include <mutex>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
@@ -16,6 +14,9 @@
#include <boost/icl/interval_set.hpp>
#include <boost/intrusive/set.hpp>
#include <tsl/robin_map.h>
#include <tsl/robin_set.h>
#include "common/alignment.h"
#include "common/assert.h"
#include "common/common_types.h"
@@ -526,7 +527,7 @@ private:
for (u64 page_start = start >> WRITE_PAGE_BIT; page_start <= page_end; ++page_start) {
auto it = written_pages.find(page_start);
if (it != written_pages.end()) {
it->second = it->second + 1;
it.value() += 1;
} else {
written_pages.insert_or_assign(page_start, 1);
}
@@ -537,12 +538,13 @@ private:
const u64 page_end = end >> WRITE_PAGE_BIT;
for (u64 page_start = start >> WRITE_PAGE_BIT; page_start <= page_end; ++page_start) {
auto it = written_pages.find(page_start);
if (it != written_pages.end()) {
if (it->second > 1) {
it->second = it->second - 1;
} else {
written_pages.erase(it);
}
if (it == written_pages.end()) {
continue;
}
u32& num_stores = it.value();
--num_stores;
if (num_stores == 0) {
written_pages.erase(it);
}
}
}
@@ -564,7 +566,7 @@ private:
void MarkForAsyncFlush(MapInterval* map) {
if (!uncommitted_flushes) {
uncommitted_flushes = std::make_shared<std::unordered_set<MapInterval*>>();
uncommitted_flushes = std::make_shared<tsl::robin_set<MapInterval*>>();
}
uncommitted_flushes->insert(map);
}
@@ -583,8 +585,8 @@ private:
boost::intrusive::set<MapInterval, boost::intrusive::compare<MapIntervalCompare>>
mapped_addresses;
std::unordered_map<u64, u32> written_pages;
std::unordered_map<u64, std::shared_ptr<Buffer>> blocks;
tsl::robin_map<u64, u32> written_pages;
tsl::robin_map<u64, std::shared_ptr<Buffer>> blocks;
std::queue<std::shared_ptr<Buffer>> pending_destruction;
u64 epoch = 0;
@@ -594,7 +596,7 @@ private:
std::list<MapInterval*> marked_for_unregister;
std::shared_ptr<std::unordered_set<MapInterval*>> uncommitted_flushes;
std::shared_ptr<tsl::robin_set<MapInterval*>> uncommitted_flushes;
std::list<std::shared_ptr<std::list<MapInterval*>>> committed_flushes;
std::recursive_mutex mutex;

View File

@@ -9,7 +9,6 @@
#include <limits>
#include <optional>
#include <type_traits>
#include <unordered_map>
#include <vector>
#include "common/assert.h"

View File

@@ -11,10 +11,11 @@
#include <memory>
#include <mutex>
#include <optional>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <tsl/robin_map.h>
#include <tsl/robin_set.h>
#include "common/assert.h"
#include "core/core.h"
#include "core/settings.h"
@@ -222,11 +223,11 @@ private:
const u64 page_end = addr_end >> PAGE_BITS;
for (u64 page = addr_begin >> PAGE_BITS; page <= page_end; ++page) {
const auto& it = cached_queries.find(page);
auto it = cached_queries.find(page);
if (it == std::end(cached_queries)) {
continue;
}
auto& contents = it->second;
auto& contents = it.value();
for (auto& query : contents) {
if (!in_range(query)) {
continue;
@@ -250,11 +251,11 @@ private:
/// Tries to a get a cached query. Returns nullptr on failure.
CachedQuery* TryGet(VAddr addr) {
const u64 page = static_cast<u64>(addr) >> PAGE_BITS;
const auto it = cached_queries.find(page);
auto it = cached_queries.find(page);
if (it == std::end(cached_queries)) {
return nullptr;
}
auto& contents = it->second;
auto& contents = it.value();
const auto found = std::find_if(std::begin(contents), std::end(contents),
[addr](auto& query) { return query.GetCpuAddr() == addr; });
return found != std::end(contents) ? &*found : nullptr;
@@ -262,7 +263,7 @@ private:
void AsyncFlushQuery(VAddr addr) {
if (!uncommitted_flushes) {
uncommitted_flushes = std::make_shared<std::unordered_set<VAddr>>();
uncommitted_flushes = std::make_shared<tsl::robin_set<VAddr>>();
}
uncommitted_flushes->insert(addr);
}
@@ -275,12 +276,12 @@ private:
std::recursive_mutex mutex;
std::unordered_map<u64, std::vector<CachedQuery>> cached_queries;
tsl::robin_map<u64, std::vector<CachedQuery>> cached_queries;
std::array<CounterStream, VideoCore::NumQueryTypes> streams;
std::shared_ptr<std::unordered_set<VAddr>> uncommitted_flushes{};
std::list<std::shared_ptr<std::unordered_set<VAddr>>> committed_flushes;
std::shared_ptr<tsl::robin_set<VAddr>> uncommitted_flushes{};
std::list<std::shared_ptr<tsl::robin_set<VAddr>>> committed_flushes;
};
template <class QueryCache, class HostCounter>

View File

@@ -3,9 +3,10 @@
// Refer to the license.txt file included.
#include <tuple>
#include <unordered_map>
#include <utility>
#include <tsl/robin_map.h>
#include <glad/glad.h>
#include "common/common_types.h"
@@ -22,8 +23,8 @@ FramebufferCacheOpenGL::FramebufferCacheOpenGL() = default;
FramebufferCacheOpenGL::~FramebufferCacheOpenGL() = default;
GLuint FramebufferCacheOpenGL::GetFramebuffer(const FramebufferCacheKey& key) {
const auto [entry, is_cache_miss] = cache.try_emplace(key);
auto& framebuffer{entry->second};
auto [entry, is_cache_miss] = cache.try_emplace(key);
auto& framebuffer = entry.value();
if (is_cache_miss) {
framebuffer = CreateFramebuffer(key);
}

View File

@@ -6,7 +6,8 @@
#include <array>
#include <cstddef>
#include <unordered_map>
#include <tsl/robin_map.h>
#include <glad/glad.h>
@@ -62,7 +63,10 @@ public:
private:
OGLFramebuffer CreateFramebuffer(const FramebufferCacheKey& key);
std::unordered_map<FramebufferCacheKey, OGLFramebuffer> cache;
tsl::robin_map<FramebufferCacheKey, OGLFramebuffer, std::hash<FramebufferCacheKey>,
std::equal_to<FramebufferCacheKey>,
std::allocator<std::pair<FramebufferCacheKey, OGLFramebuffer>>, true>
cache;
};
} // namespace OpenGL

View File

@@ -5,10 +5,11 @@
#include <algorithm>
#include <cstring>
#include <memory>
#include <unordered_map>
#include <utility>
#include <vector>
#include <tsl/robin_map.h>
#include <glad/glad.h>
#include "common/assert.h"

View File

@@ -8,7 +8,8 @@
#include <optional>
#include <string>
#include <thread>
#include <unordered_set>
#include <tsl/robin_set.h>
#include "common/alignment.h"
#include "common/assert.h"
@@ -181,18 +182,13 @@ ProgramSharedPtr BuildShader(const Device& device, ShaderType shader_type, u64 u
return program;
}
std::unordered_set<GLenum> GetSupportedFormats() {
std::vector<GLint> GetSupportedFormats() {
GLint num_formats;
glGetIntegerv(GL_NUM_PROGRAM_BINARY_FORMATS, &num_formats);
std::vector<GLint> formats(num_formats);
glGetIntegerv(GL_PROGRAM_BINARY_FORMATS, formats.data());
std::unordered_set<GLenum> supported_formats;
for (const GLint format : formats) {
supported_formats.insert(static_cast<GLenum>(format));
}
return supported_formats;
return formats;
}
} // Anonymous namespace
@@ -413,8 +409,10 @@ void ShaderCacheOpenGL::LoadDiskCache(const std::atomic_bool& stop_loading,
ProgramSharedPtr ShaderCacheOpenGL::GeneratePrecompiledProgram(
const ShaderDiskCacheEntry& entry, const ShaderDiskCachePrecompiled& precompiled_entry,
const std::unordered_set<GLenum>& supported_formats) {
if (supported_formats.find(precompiled_entry.binary_format) == supported_formats.end()) {
const std::vector<GLint>& supported_formats) {
const auto found = std::find(supported_formats.begin(), supported_formats.end(),
precompiled_entry.binary_format);
if (found == supported_formats.end()) {
LOG_INFO(Render_OpenGL, "Precompiled cache entry with unsupported format, removing");
return {};
}

View File

@@ -10,10 +10,10 @@
#include <memory>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <tsl/robin_map.h>
#include <glad/glad.h>
#include "common/common_types.h"
@@ -110,15 +110,15 @@ public:
Shader* GetComputeKernel(GPUVAddr code_addr);
private:
ProgramSharedPtr GeneratePrecompiledProgram(
const ShaderDiskCacheEntry& entry, const ShaderDiskCachePrecompiled& precompiled_entry,
const std::unordered_set<GLenum>& supported_formats);
ProgramSharedPtr GeneratePrecompiledProgram(const ShaderDiskCacheEntry& entry,
const ShaderDiskCachePrecompiled& precompiled_entry,
const std::vector<GLint>& supported_formats);
Core::System& system;
Core::Frontend::EmuWindow& emu_window;
const Device& device;
ShaderDiskCacheOpenGL disk_cache;
std::unordered_map<u64, PrecompiledShader> runtime_cache;
tsl::robin_map<u64, PrecompiledShader> runtime_cache;
std::unique_ptr<Shader> null_shader;
std::unique_ptr<Shader> null_kernel;

View File

@@ -2694,7 +2694,7 @@ private:
return AppendSuffix(GetGenericAttributeIndex(attribute), INPUT_ATTRIBUTE_NAME);
}
std::unordered_map<u8, GenericVaryingDescription> varying_description;
tsl::robin_map<u8, GenericVaryingDescription> varying_description;
std::string GetGenericOutputAttribute(Attribute::Index attribute, std::size_t element) const {
const u8 offset = static_cast<u8>(GetGenericAttributeIndex(attribute) * 4 + element);
@@ -2788,7 +2788,7 @@ private:
const std::string_view suffix;
const Header header;
const bool use_unified_uniforms;
std::unordered_map<u8, VaryingTFB> transform_feedback;
tsl::robin_map<u8, VaryingTFB> transform_feedback;
ShaderWriter code;

View File

@@ -8,11 +8,12 @@
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <tsl/robin_map.h>
#include <tsl/robin_set.h>
#include <glad/glad.h>
#include "common/assert.h"
@@ -166,7 +167,7 @@ private:
std::size_t precompiled_cache_virtual_file_offset = 0;
// Stored transferable shaders
std::unordered_set<u64> stored_transferable;
tsl::robin_set<u64> stored_transferable;
// The cache has been loaded at boot
bool is_usable{};

View File

@@ -7,10 +7,11 @@
#include <array>
#include <functional>
#include <memory>
#include <unordered_map>
#include <utility>
#include <vector>
#include <tsl/robin_map.h>
#include <glad/glad.h>
#include "common/common_types.h"
@@ -151,7 +152,7 @@ private:
OGLFramebuffer src_framebuffer;
OGLFramebuffer dst_framebuffer;
std::unordered_map<u32, OGLBuffer> copy_pbo_cache;
tsl::robin_map<u32, OGLBuffer> copy_pbo_cache;
};
} // namespace OpenGL

View File

@@ -7,7 +7,6 @@
#include <optional>
#include <string_view>
#include <thread>
#include <unordered_set>
#include <utility>
#include <vector>
@@ -78,8 +77,8 @@ VkFormatFeatureFlags GetFormatFeatures(VkFormatProperties properties, FormatType
}
}
std::unordered_map<VkFormat, VkFormatProperties> GetFormatProperties(
vk::PhysicalDevice physical, const vk::InstanceDispatch& dld) {
tsl::robin_map<VkFormat, VkFormatProperties> GetFormatProperties(vk::PhysicalDevice physical,
const vk::InstanceDispatch& dld) {
static constexpr std::array formats{
VK_FORMAT_A8B8G8R8_UNORM_PACK32,
VK_FORMAT_A8B8G8R8_UINT_PACK32,
@@ -153,7 +152,7 @@ std::unordered_map<VkFormat, VkFormatProperties> GetFormatProperties(
VK_FORMAT_ASTC_6x5_SRGB_BLOCK,
VK_FORMAT_E5B9G9R9_UFLOAT_PACK32,
};
std::unordered_map<VkFormat, VkFormatProperties> format_properties;
tsl::robin_map<VkFormat, VkFormatProperties> format_properties;
for (const auto format : formats) {
format_properties.emplace(format, physical.GetFormatProperties(format));
}
@@ -752,12 +751,9 @@ void VKDevice::CollectTelemetryParameters() {
std::vector<VkDeviceQueueCreateInfo> VKDevice::GetDeviceQueueCreateInfos() const {
static constexpr float QUEUE_PRIORITY = 1.0f;
std::unordered_set<u32> unique_queue_families{graphics_family, present_family};
std::vector<VkDeviceQueueCreateInfo> queue_cis;
queue_cis.reserve(unique_queue_families.size());
for (const u32 queue_family : unique_queue_families) {
auto& ci = queue_cis.emplace_back(VkDeviceQueueCreateInfo{
const auto insert_queue = [&queue_cis](u32 queue_family) {
auto& ci = queue_cis.emplace_back({
.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO,
.pNext = nullptr,
.flags = 0,
@@ -765,6 +761,11 @@ std::vector<VkDeviceQueueCreateInfo> VKDevice::GetDeviceQueueCreateInfos() const
});
ci.queueCount = 1;
ci.pQueuePriorities = &QUEUE_PRIORITY;
};
insert_queue(graphics_family);
if (present_family != graphics_family) {
insert_queue(present_family);
}
return queue_cis;

View File

@@ -6,9 +6,10 @@
#include <string>
#include <string_view>
#include <unordered_map>
#include <vector>
#include <tsl/robin_map.h>
#include "common/common_types.h"
#include "video_core/renderer_vulkan/nsight_aftermath_tracker.h"
#include "video_core/renderer_vulkan/wrapper.h"
@@ -252,7 +253,7 @@ private:
std::vector<std::string> reported_extensions; ///< Reported Vulkan extensions.
/// Format properties dictionary.
std::unordered_map<VkFormat, VkFormatProperties> format_properties;
tsl::robin_map<VkFormat, VkFormatProperties> format_properties;
/// Nsight Aftermath GPU crash tracker
NsightAftermathTracker nsight_aftermath_tracker;

View File

@@ -212,8 +212,8 @@ VKGraphicsPipeline& VKPipelineCache::GetGraphicsPipeline(const GraphicsPipelineC
}
last_graphics_key = key;
const auto [pair, is_cache_miss] = graphics_cache.try_emplace(key);
auto& entry = pair->second;
auto [pair, is_cache_miss] = graphics_cache.try_emplace(key);
auto& entry = pair.value();
if (is_cache_miss) {
LOG_INFO(Render_Vulkan, "Compile 0x{:016X}", key.Hash());
const auto [program, bindings] = DecompileShaders(key);
@@ -227,8 +227,8 @@ VKGraphicsPipeline& VKPipelineCache::GetGraphicsPipeline(const GraphicsPipelineC
VKComputePipeline& VKPipelineCache::GetComputePipeline(const ComputePipelineCacheKey& key) {
MICROPROFILE_SCOPE(Vulkan_PipelineCache);
const auto [pair, is_cache_miss] = compute_cache.try_emplace(key);
auto& entry = pair->second;
auto [pair, is_cache_miss] = compute_cache.try_emplace(key);
auto& entry = pair.value();
if (!is_cache_miss) {
return *entry;
}

View File

@@ -8,12 +8,13 @@
#include <cstddef>
#include <memory>
#include <type_traits>
#include <unordered_map>
#include <utility>
#include <vector>
#include <boost/functional/hash.hpp>
#include <tsl/robin_map.h>
#include "common/common_types.h"
#include "video_core/engines/const_buffer_engine_interface.h"
#include "video_core/engines/maxwell_3d.h"
@@ -178,9 +179,18 @@ private:
GraphicsPipelineCacheKey last_graphics_key;
VKGraphicsPipeline* last_graphics_pipeline = nullptr;
std::unordered_map<GraphicsPipelineCacheKey, std::unique_ptr<VKGraphicsPipeline>>
tsl::robin_map<
GraphicsPipelineCacheKey, std::unique_ptr<VKGraphicsPipeline>,
std::hash<GraphicsPipelineCacheKey>, std::equal_to<GraphicsPipelineCacheKey>,
std::allocator<std::pair<GraphicsPipelineCacheKey, std::unique_ptr<VKGraphicsPipeline>>>,
true>
graphics_cache;
std::unordered_map<ComputePipelineCacheKey, std::unique_ptr<VKComputePipeline>> compute_cache;
tsl::robin_map<
ComputePipelineCacheKey, std::unique_ptr<VKComputePipeline>,
std::hash<ComputePipelineCacheKey>, std::equal_to<ComputePipelineCacheKey>,
std::allocator<std::pair<ComputePipelineCacheKey, std::unique_ptr<VKComputePipeline>>>,
true>
compute_cache;
};
void FillDescriptorUpdateTemplateEntries(

View File

@@ -838,8 +838,8 @@ std::tuple<VkFramebuffer, VkExtent2D> RasterizerVulkan::ConfigureFramebuffers(
texture_cache.MarkDepthBufferInUse();
}
const auto [fbentry, is_cache_miss] = framebuffer_cache.try_emplace(key);
auto& framebuffer = fbentry->second;
auto [entry, is_cache_miss] = framebuffer_cache.try_emplace(key);
auto& framebuffer = entry.value();
if (is_cache_miss) {
VkFramebufferCreateInfo framebuffer_ci;
framebuffer_ci.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO;

View File

@@ -307,7 +307,10 @@ private:
u32 draw_counter = 0;
// TODO(Rodrigo): Invalidate on image destruction
std::unordered_map<FramebufferCacheKey, vk::Framebuffer> framebuffer_cache;
tsl::robin_map<FramebufferCacheKey, vk::Framebuffer, std::hash<FramebufferCacheKey>,
std::equal_to<FramebufferCacheKey>,
std::allocator<std::pair<FramebufferCacheKey, vk::Framebuffer>>, true>
framebuffer_cache;
};
} // namespace Vulkan

View File

@@ -29,12 +29,12 @@ VKRenderPassCache::VKRenderPassCache(const VKDevice& device) : device{device} {}
VKRenderPassCache::~VKRenderPassCache() = default;
VkRenderPass VKRenderPassCache::GetRenderPass(const RenderPassParams& params) {
const auto [pair, is_cache_miss] = cache.try_emplace(params);
auto& entry = pair->second;
auto [entry, is_cache_miss] = cache.try_emplace(params);
auto& renderpass = entry.value();
if (is_cache_miss) {
entry = CreateRenderPass(params);
renderpass = CreateRenderPass(params);
}
return *entry;
return *renderpass;
}
vk::RenderPass VKRenderPassCache::CreateRenderPass(const RenderPassParams& params) const {

View File

@@ -5,11 +5,12 @@
#pragma once
#include <type_traits>
#include <unordered_map>
#include <boost/container/static_vector.hpp>
#include <boost/functional/hash.hpp>
#include <tsl/robin_map.h>
#include "video_core/engines/maxwell_3d.h"
#include "video_core/renderer_vulkan/wrapper.h"
#include "video_core/surface.h"
@@ -64,7 +65,10 @@ private:
vk::RenderPass CreateRenderPass(const RenderPassParams& params) const;
const VKDevice& device;
std::unordered_map<RenderPassParams, vk::RenderPass> cache;
tsl::robin_map<RenderPassParams, vk::RenderPass, std::hash<RenderPassParams>,
std::equal_to<RenderPassParams>,
std::allocator<std::pair<RenderPassParams, vk::RenderPass>>, true>
cache;
};
} // namespace Vulkan

View File

@@ -2,7 +2,7 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include <unordered_map>
#include <tsl/robin_map.h>
#include "video_core/renderer_vulkan/maxwell_to_vk.h"
#include "video_core/renderer_vulkan/vk_sampler_cache.h"

View File

@@ -7,11 +7,12 @@
#include <map>
#include <optional>
#include <type_traits>
#include <unordered_map>
#include <utility>
#include <fmt/format.h>
#include <tsl/robin_map.h>
#include <sirit/sirit.h>
#include "common/alignment.h"
@@ -2701,7 +2702,7 @@ private:
const Tegra::Shader::Header header;
const Registry& registry;
const Specialization& specialization;
std::unordered_map<u8, VaryingTFB> transform_feedback;
tsl::robin_map<u8, VaryingTFB> transform_feedback;
const Id t_void = Name(TypeVoid(), "void");
@@ -2793,7 +2794,7 @@ private:
Id shared_memory{};
std::array<Id, INTERNAL_FLAGS_COUNT> internal_flags{};
std::map<Attribute::Index, Id> input_attributes;
std::unordered_map<u8, GenericVaryingDescription> output_attributes;
tsl::robin_map<u8, GenericVaryingDescription> output_attributes;
std::map<u32, Id> constant_buffers;
std::map<GlobalMemoryBase, Id> global_buffers;
std::map<u32, TexelBuffer> uniform_texels;

View File

@@ -3,10 +3,11 @@
// Refer to the license.txt file included.
#include <algorithm>
#include <unordered_map>
#include <utility>
#include <vector>
#include <tsl/robin_map.h>
#include "common/bit_util.h"
#include "common/common_types.h"
#include "video_core/renderer_vulkan/vk_device.h"

View File

@@ -372,8 +372,8 @@ VkImageView CachedSurfaceView::GetImageView(SwizzleSource x_source, SwizzleSourc
}
last_swizzle = new_swizzle;
const auto [entry, is_cache_miss] = view_cache.try_emplace(new_swizzle);
auto& image_view = entry->second;
auto [entry, is_cache_miss] = view_cache.try_emplace(new_swizzle);
auto& image_view = entry.value();
if (!is_cache_miss) {
return last_image_view = *image_view;
}

View File

@@ -5,7 +5,8 @@
#pragma once
#include <memory>
#include <unordered_map>
#include <tsl/robin_map.h>
#include "common/common_types.h"
#include "video_core/renderer_vulkan/vk_image.h"
@@ -196,7 +197,7 @@ private:
u32 last_swizzle = 0;
vk::ImageView render_target;
std::unordered_map<u32, vk::ImageView> view_cache;
tsl::robin_map<u32, vk::ImageView> view_cache;
};
class VKTextureCache final : public TextureCacheBase {

View File

@@ -5,7 +5,8 @@
#pragma once
#include <cstddef>
#include <unordered_map>
#include <tsl/robin_map.h>
#include "video_core/textures/texture.h"
@@ -40,8 +41,8 @@ template <typename SamplerType, typename SamplerStorageType>
class SamplerCache {
public:
SamplerType GetSampler(const Tegra::Texture::TSCEntry& tsc) {
const auto [entry, is_cache_miss] = cache.try_emplace(SamplerCacheKey{tsc});
auto& sampler = entry->second;
auto [entry, is_cache_miss] = cache.try_emplace(SamplerCacheKey{tsc});
auto& sampler = entry.value();
if (is_cache_miss) {
sampler = CreateSampler(tsc);
}
@@ -54,7 +55,10 @@ protected:
virtual SamplerType ToSamplerType(const SamplerStorageType& sampler) const = 0;
private:
std::unordered_map<SamplerCacheKey, SamplerStorageType> cache;
tsl::robin_map<SamplerCacheKey, SamplerStorageType, std::hash<SamplerCacheKey>,
std::equal_to<SamplerCacheKey>,
std::allocator<std::pair<SamplerCacheKey, SamplerStorageType>>, true>
cache;
};
} // namespace VideoCommon

View File

@@ -6,9 +6,10 @@
#include <map>
#include <set>
#include <stack>
#include <unordered_map>
#include <vector>
#include <tsl/robin_map.h>
#include "common/assert.h"
#include "common/common_types.h"
#include "video_core/shader/ast.h"
@@ -75,11 +76,11 @@ struct CFGRebuildState {
std::vector<BlockInfo> block_info;
std::list<u32> inspect_queries;
std::list<Query> queries;
std::unordered_map<u32, u32> registered;
tsl::robin_map<u32, u32> registered;
std::set<u32> labels;
std::map<u32, u32> ssy_labels;
std::map<u32, u32> pbk_labels;
std::unordered_map<u32, BlockStack> stacks;
tsl::robin_map<u32, BlockStack> stacks;
ASTManager* manager{};
};

View File

@@ -7,9 +7,10 @@
#include <array>
#include <optional>
#include <type_traits>
#include <unordered_map>
#include <utility>
#include <tsl/robin_map.h>
#include "common/common_types.h"
#include "common/hash.h"
#include "video_core/engines/const_buffer_engine_interface.h"
@@ -48,12 +49,11 @@ struct equal_to<VideoCommon::Shader::SeparateSamplerKey> {
namespace VideoCommon::Shader {
using KeyMap = std::unordered_map<std::pair<u32, u32>, u32, Common::PairHash>;
using BoundSamplerMap = std::unordered_map<u32, Tegra::Engines::SamplerDescriptor>;
using SeparateSamplerMap =
std::unordered_map<SeparateSamplerKey, Tegra::Engines::SamplerDescriptor>;
using KeyMap = tsl::robin_map<std::pair<u32, u32>, u32, Common::PairHash>;
using BoundSamplerMap = tsl::robin_map<u32, Tegra::Engines::SamplerDescriptor>;
using SeparateSamplerMap = tsl::robin_map<SeparateSamplerKey, Tegra::Engines::SamplerDescriptor>;
using BindlessSamplerMap =
std::unordered_map<std::pair<u32, u32>, Tegra::Engines::SamplerDescriptor, Common::PairHash>;
tsl::robin_map<std::pair<u32, u32>, Tegra::Engines::SamplerDescriptor, Common::PairHash>;
struct GraphicsInfo {
using Maxwell = Tegra::Engines::Maxwell3D::Regs;

View File

@@ -4,7 +4,8 @@
#include <algorithm>
#include <array>
#include <unordered_map>
#include <tsl/robin_map.h>
#include "common/assert.h"
#include "common/common_types.h"
@@ -70,9 +71,8 @@ constexpr std::array VECTORS = {
};
} // namespace
std::unordered_map<u8, VaryingTFB> BuildTransformFeedback(const GraphicsInfo& info) {
std::unordered_map<u8, VaryingTFB> tfb;
tsl::robin_map<u8, VaryingTFB> BuildTransformFeedback(const GraphicsInfo& info) {
tsl::robin_map<u8, VaryingTFB> tfb;
for (std::size_t buffer = 0; buffer < Maxwell::NumTransformFeedbackBuffers; ++buffer) {
const auto& locations = info.tfb_varying_locs[buffer];

View File

@@ -4,7 +4,7 @@
#pragma once
#include <unordered_map>
#include <tsl/robin_map.h>
#include "common/common_types.h"
#include "video_core/shader/registry.h"
@@ -18,6 +18,6 @@ struct VaryingTFB {
std::size_t components;
};
std::unordered_map<u8, VaryingTFB> BuildTransformFeedback(const GraphicsInfo& info);
tsl::robin_map<u8, VaryingTFB> BuildTransformFeedback(const GraphicsInfo& info);
} // namespace VideoCommon::Shader

View File

@@ -115,7 +115,7 @@ private:
if (it == invalidation_cache.end()) {
continue;
}
InvalidatePageEntries(it->second, addr, addr_end);
InvalidatePageEntries(it.value(), addr, addr_end);
}
}
@@ -175,9 +175,9 @@ private:
void RemoveEntryFromInvalidationCache(const Entry* entry) {
const u64 page_end = (entry->addr_end + PAGE_SIZE - 1) >> PAGE_BITS;
for (u64 page = entry->addr_start >> PAGE_BITS; page < page_end; ++page) {
const auto entries_it = invalidation_cache.find(page);
auto entries_it = invalidation_cache.find(page);
ASSERT(entries_it != invalidation_cache.end());
std::vector<Entry*>& entries = entries_it->second;
std::vector<Entry*>& entries = entries_it.value();
const auto entry_it = std::find(entries.begin(), entries.end(), entry);
ASSERT(entry_it != entries.end());
@@ -231,8 +231,8 @@ private:
mutable std::mutex lookup_mutex;
std::mutex invalidation_mutex;
std::unordered_map<u64, std::unique_ptr<Entry>> lookup_cache;
std::unordered_map<u64, std::vector<Entry*>> invalidation_cache;
tsl::robin_map<u64, std::unique_ptr<Entry>> lookup_cache;
tsl::robin_map<u64, std::vector<Entry*>> invalidation_cache;
std::vector<std::unique_ptr<T>> storage;
std::vector<Entry*> marked_for_removal;
};

View File

@@ -6,9 +6,10 @@
#include <optional>
#include <tuple>
#include <unordered_map>
#include <vector>
#include <tsl/robin_map.h>
#include "common/common_types.h"
#include "video_core/gpu.h"
#include "video_core/morton.h"
@@ -306,12 +307,12 @@ protected:
virtual TView CreateView(const ViewParams& view_key) = 0;
TView main_view;
std::unordered_map<ViewParams, TView> views;
tsl::robin_map<ViewParams, TView> views;
private:
TView GetView(const ViewParams& key) {
const auto [entry, is_cache_miss] = views.try_emplace(key);
auto& view{entry->second};
auto [entry, is_cache_miss] = views.try_emplace(key);
auto& view = entry.value();
if (is_cache_miss) {
view = CreateView(key);
}

View File

@@ -11,13 +11,14 @@
#include <mutex>
#include <set>
#include <tuple>
#include <unordered_map>
#include <vector>
#include <boost/container/small_vector.hpp>
#include <boost/icl/interval_map.hpp>
#include <boost/range/iterator_range.hpp>
#include <tsl/robin_map.h>
#include "common/assert.h"
#include "common/common_types.h"
#include "common/math_util.h"
@@ -833,8 +834,8 @@ private:
// Step 1
// Check Level 1 Cache for a fast structural match. If candidate surface
// matches at certain level we are pretty much done.
if (const auto iter = l1_cache.find(cpu_addr); iter != l1_cache.end()) {
TSurface& current_surface = iter->second;
if (auto iter = l1_cache.find(cpu_addr); iter != l1_cache.end()) {
TSurface& current_surface = iter.value();
const auto topological_result = current_surface->MatchesTopology(params);
if (topological_result != MatchTopologyResult::FullMatch) {
VectorSurface overlaps{current_surface};
@@ -963,8 +964,8 @@ private:
return result;
}
if (const auto iter = l1_cache.find(*cpu_addr); iter != l1_cache.end()) {
TSurface& current_surface = iter->second;
if (auto iter = l1_cache.find(*cpu_addr); iter != l1_cache.end()) {
TSurface& current_surface = iter.value();
const auto topological_result = current_surface->MatchesTopology(params);
if (topological_result != MatchTopologyResult::FullMatch) {
Deduction result{};
@@ -1273,19 +1274,22 @@ private:
// large in size.
static constexpr u64 registry_page_bits{20};
static constexpr u64 registry_page_size{1 << registry_page_bits};
std::unordered_map<VAddr, std::vector<TSurface>> registry;
tsl::robin_map<VAddr, std::vector<TSurface>> registry;
static constexpr u32 DEPTH_RT = 8;
static constexpr u32 NO_RT = 0xFFFFFFFF;
// The L1 Cache is used for fast texture lookup before checking the overlaps
// This avoids calculating size and other stuffs.
std::unordered_map<VAddr, TSurface> l1_cache;
tsl::robin_map<VAddr, TSurface> l1_cache;
/// The surface reserve is a "backup" cache, this is where we put unique surfaces that have
/// previously been used. This is to prevent surfaces from being constantly created and
/// destroyed when used with different surface parameters.
std::unordered_map<SurfaceParams, std::vector<TSurface>> surface_reserve;
tsl::robin_map<SurfaceParams, std::vector<TSurface>, std::hash<SurfaceParams>,
std::equal_to<SurfaceParams>,
std::allocator<std::pair<SurfaceParams, std::vector<TSurface>>>, true>
surface_reserve;
std::array<FramebufferTargetInfo, Tegra::Engines::Maxwell3D::Regs::NumRenderTargets>
render_targets;
FramebufferTargetInfo depth_buffer;
@@ -1294,7 +1298,7 @@ private:
/// This cache stores null surfaces in order to be used as a placeholder
/// for invalid texture calls.
std::unordered_map<u32, TSurface> invalid_cache;
tsl::robin_map<u32, TSurface> invalid_cache;
std::vector<u8> invalid_memory;
std::list<TSurface> marked_for_unregister;