[Vulkan] Use pipeline layout key structures directly
This commit is contained in:
parent
b80361ee3c
commit
0db94a700f
|
@ -1109,7 +1109,7 @@ VulkanCommandProcessor::GetPipelineLayout(uint32_t texture_count_pixel,
|
||||||
pipeline_layout_key.texture_count_pixel = texture_count_pixel;
|
pipeline_layout_key.texture_count_pixel = texture_count_pixel;
|
||||||
pipeline_layout_key.texture_count_vertex = texture_count_vertex;
|
pipeline_layout_key.texture_count_vertex = texture_count_vertex;
|
||||||
{
|
{
|
||||||
auto it = pipeline_layouts_.find(pipeline_layout_key.key);
|
auto it = pipeline_layouts_.find(pipeline_layout_key);
|
||||||
if (it != pipeline_layouts_.end()) {
|
if (it != pipeline_layouts_.end()) {
|
||||||
return &it->second;
|
return &it->second;
|
||||||
}
|
}
|
||||||
|
@ -1125,7 +1125,7 @@ VulkanCommandProcessor::GetPipelineLayout(uint32_t texture_count_pixel,
|
||||||
texture_descriptor_set_layout_key.is_vertex = 0;
|
texture_descriptor_set_layout_key.is_vertex = 0;
|
||||||
texture_descriptor_set_layout_key.texture_count = texture_count_pixel;
|
texture_descriptor_set_layout_key.texture_count = texture_count_pixel;
|
||||||
auto it = descriptor_set_layouts_textures_.find(
|
auto it = descriptor_set_layouts_textures_.find(
|
||||||
texture_descriptor_set_layout_key.key);
|
texture_descriptor_set_layout_key);
|
||||||
if (it != descriptor_set_layouts_textures_.end()) {
|
if (it != descriptor_set_layouts_textures_.end()) {
|
||||||
descriptor_set_layout_textures_pixel = it->second;
|
descriptor_set_layout_textures_pixel = it->second;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1154,7 +1154,7 @@ VulkanCommandProcessor::GetPipelineLayout(uint32_t texture_count_pixel,
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
descriptor_set_layouts_textures_.emplace(
|
descriptor_set_layouts_textures_.emplace(
|
||||||
texture_descriptor_set_layout_key.key,
|
texture_descriptor_set_layout_key,
|
||||||
descriptor_set_layout_textures_pixel);
|
descriptor_set_layout_textures_pixel);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -1167,7 +1167,7 @@ VulkanCommandProcessor::GetPipelineLayout(uint32_t texture_count_pixel,
|
||||||
texture_descriptor_set_layout_key.is_vertex = 0;
|
texture_descriptor_set_layout_key.is_vertex = 0;
|
||||||
texture_descriptor_set_layout_key.texture_count = texture_count_vertex;
|
texture_descriptor_set_layout_key.texture_count = texture_count_vertex;
|
||||||
auto it = descriptor_set_layouts_textures_.find(
|
auto it = descriptor_set_layouts_textures_.find(
|
||||||
texture_descriptor_set_layout_key.key);
|
texture_descriptor_set_layout_key);
|
||||||
if (it != descriptor_set_layouts_textures_.end()) {
|
if (it != descriptor_set_layouts_textures_.end()) {
|
||||||
descriptor_set_layout_textures_vertex = it->second;
|
descriptor_set_layout_textures_vertex = it->second;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1196,7 +1196,7 @@ VulkanCommandProcessor::GetPipelineLayout(uint32_t texture_count_pixel,
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
descriptor_set_layouts_textures_.emplace(
|
descriptor_set_layouts_textures_.emplace(
|
||||||
texture_descriptor_set_layout_key.key,
|
texture_descriptor_set_layout_key,
|
||||||
descriptor_set_layout_textures_vertex);
|
descriptor_set_layout_textures_vertex);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -1248,7 +1248,7 @@ VulkanCommandProcessor::GetPipelineLayout(uint32_t texture_count_pixel,
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
auto emplaced_pair = pipeline_layouts_.emplace(
|
auto emplaced_pair = pipeline_layouts_.emplace(
|
||||||
std::piecewise_construct, std::forward_as_tuple(pipeline_layout_key.key),
|
std::piecewise_construct, std::forward_as_tuple(pipeline_layout_key),
|
||||||
std::forward_as_tuple(pipeline_layout,
|
std::forward_as_tuple(pipeline_layout,
|
||||||
descriptor_set_layout_textures_vertex,
|
descriptor_set_layout_textures_vertex,
|
||||||
descriptor_set_layout_textures_pixel));
|
descriptor_set_layout_textures_pixel));
|
||||||
|
|
|
@ -14,11 +14,14 @@
|
||||||
#include <climits>
|
#include <climits>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <deque>
|
#include <deque>
|
||||||
|
#include <functional>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "xenia/base/assert.h"
|
||||||
|
#include "xenia/base/hash.h"
|
||||||
#include "xenia/gpu/command_processor.h"
|
#include "xenia/gpu/command_processor.h"
|
||||||
#include "xenia/gpu/draw_util.h"
|
#include "xenia/gpu/draw_util.h"
|
||||||
#include "xenia/gpu/registers.h"
|
#include "xenia/gpu/registers.h"
|
||||||
|
@ -167,26 +170,54 @@ class VulkanCommandProcessor : public CommandProcessor {
|
||||||
};
|
};
|
||||||
|
|
||||||
union TextureDescriptorSetLayoutKey {
|
union TextureDescriptorSetLayoutKey {
|
||||||
|
uint32_t key;
|
||||||
struct {
|
struct {
|
||||||
uint32_t is_vertex : 1;
|
uint32_t is_vertex : 1;
|
||||||
// For 0, use descriptor_set_layout_empty_ instead as these are owning
|
// For 0, use descriptor_set_layout_empty_ instead as these are owning
|
||||||
// references.
|
// references.
|
||||||
uint32_t texture_count : 31;
|
uint32_t texture_count : 31;
|
||||||
};
|
};
|
||||||
uint32_t key = 0;
|
|
||||||
|
TextureDescriptorSetLayoutKey() : key(0) {
|
||||||
|
static_assert_size(*this, sizeof(key));
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Hasher {
|
||||||
|
size_t operator()(const TextureDescriptorSetLayoutKey& key) const {
|
||||||
|
return std::hash<decltype(key.key)>{}(key.key);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
bool operator==(const TextureDescriptorSetLayoutKey& other_key) const {
|
||||||
|
return key == other_key.key;
|
||||||
|
}
|
||||||
|
bool operator!=(const TextureDescriptorSetLayoutKey& other_key) const {
|
||||||
|
return !(*this == other_key);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
static_assert(sizeof(TextureDescriptorSetLayoutKey) == sizeof(uint32_t));
|
|
||||||
|
|
||||||
union PipelineLayoutKey {
|
union PipelineLayoutKey {
|
||||||
|
uint32_t key;
|
||||||
struct {
|
struct {
|
||||||
// Pixel textures in the low bits since those are varied much more
|
// Pixel textures in the low bits since those are varied much more
|
||||||
// commonly.
|
// commonly.
|
||||||
uint32_t texture_count_pixel : 16;
|
uint32_t texture_count_pixel : 16;
|
||||||
uint32_t texture_count_vertex : 16;
|
uint32_t texture_count_vertex : 16;
|
||||||
};
|
};
|
||||||
uint32_t key = 0;
|
|
||||||
|
PipelineLayoutKey() : key(0) { static_assert_size(*this, sizeof(key)); }
|
||||||
|
|
||||||
|
struct Hasher {
|
||||||
|
size_t operator()(const PipelineLayoutKey& key) const {
|
||||||
|
return std::hash<decltype(key.key)>{}(key.key);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
bool operator==(const PipelineLayoutKey& other_key) const {
|
||||||
|
return key == other_key.key;
|
||||||
|
}
|
||||||
|
bool operator!=(const PipelineLayoutKey& other_key) const {
|
||||||
|
return !(*this == other_key);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
static_assert(sizeof(PipelineLayoutKey) == sizeof(uint32_t));
|
|
||||||
|
|
||||||
class PipelineLayout : public VulkanPipelineCache::PipelineLayoutProvider {
|
class PipelineLayout : public VulkanPipelineCache::PipelineLayoutProvider {
|
||||||
public:
|
public:
|
||||||
|
@ -319,13 +350,14 @@ class VulkanCommandProcessor : public CommandProcessor {
|
||||||
VkDescriptorSetLayout descriptor_set_layout_shared_memory_and_edram_ =
|
VkDescriptorSetLayout descriptor_set_layout_shared_memory_and_edram_ =
|
||||||
VK_NULL_HANDLE;
|
VK_NULL_HANDLE;
|
||||||
|
|
||||||
// TextureDescriptorSetLayoutKey::key -> VkDescriptorSetLayout.
|
// Descriptor set layouts are referenced by pipeline_layouts_.
|
||||||
// Layouts are referenced by pipeline_layouts_.
|
std::unordered_map<TextureDescriptorSetLayoutKey, VkDescriptorSetLayout,
|
||||||
std::unordered_map<uint32_t, VkDescriptorSetLayout>
|
TextureDescriptorSetLayoutKey::Hasher>
|
||||||
descriptor_set_layouts_textures_;
|
descriptor_set_layouts_textures_;
|
||||||
// PipelineLayoutKey::key -> PipelineLayout.
|
// Pipeline layouts are referenced by VulkanPipelineCache.
|
||||||
// Layouts are referenced by VulkanPipelineCache.
|
std::unordered_map<PipelineLayoutKey, PipelineLayout,
|
||||||
std::unordered_map<uint32_t, PipelineLayout> pipeline_layouts_;
|
PipelineLayoutKey::Hasher>
|
||||||
|
pipeline_layouts_;
|
||||||
|
|
||||||
std::unique_ptr<VulkanSharedMemory> shared_memory_;
|
std::unique_ptr<VulkanSharedMemory> shared_memory_;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue