mirror of
https://github.com/KytyPS5/KytyPS5.git
synced 2026-10-20 10:56:58 +02:00
centralize swizzles
This commit is contained in:
@@ -66,32 +66,42 @@ enum class VulkanImageType {
|
||||
RenderTexture
|
||||
};
|
||||
|
||||
struct ImageViewInfo {
|
||||
VkFormat format = VK_FORMAT_UNDEFINED;
|
||||
VkImageViewType type = VK_IMAGE_VIEW_TYPE_2D;
|
||||
VkImageAspectFlags aspect = 0;
|
||||
uint32_t base_level = 0;
|
||||
uint32_t level_count = 0;
|
||||
uint32_t base_layer = 0;
|
||||
uint32_t layer_count = 1;
|
||||
uint32_t swizzle = 0;
|
||||
bool is_storage = false;
|
||||
|
||||
bool operator==(const ImageViewInfo&) const = default;
|
||||
};
|
||||
|
||||
struct CachedImageView {
|
||||
ImageViewInfo info;
|
||||
VkImageView view = nullptr;
|
||||
};
|
||||
|
||||
struct ImageViewCache {
|
||||
std::mutex mutex;
|
||||
std::vector<CachedImageView> views;
|
||||
|
||||
ImageViewCache() = default;
|
||||
KYTY_CLASS_NO_COPY(ImageViewCache);
|
||||
};
|
||||
|
||||
struct VulkanImage {
|
||||
static constexpr int VIEW_MAX = 22;
|
||||
static constexpr int VIEW_DEFAULT = 0;
|
||||
static constexpr int VIEW_BGRA = 1;
|
||||
static constexpr int VIEW_DEPTH_TEXTURE = 2;
|
||||
static constexpr int VIEW_R001 = 3;
|
||||
static constexpr int VIEW_RGB1 = 4;
|
||||
static constexpr int VIEW_R000 = 5;
|
||||
static constexpr int VIEW_RG01 = 6;
|
||||
static constexpr int VIEW_000R = 7;
|
||||
static constexpr int VIEW_DEFAULT_ARRAY = 8;
|
||||
static constexpr int VIEW_BGRA_ARRAY = 9;
|
||||
static constexpr int VIEW_DEPTH_TEXTURE_ARRAY = 10;
|
||||
static constexpr int VIEW_R001_ARRAY = 11;
|
||||
static constexpr int VIEW_RGB1_ARRAY = 12;
|
||||
static constexpr int VIEW_R000_ARRAY = 13;
|
||||
static constexpr int VIEW_RG01_ARRAY = 14;
|
||||
static constexpr int VIEW_000R_ARRAY = 15;
|
||||
static constexpr int VIEW_STENCIL_TEXTURE = 16;
|
||||
static constexpr int VIEW_STENCIL_TEXTURE_ARRAY = 17;
|
||||
static constexpr int VIEW_STORAGE = 18;
|
||||
static constexpr int VIEW_STORAGE_ARRAY = 19;
|
||||
static constexpr int VIEW_BGRA_TO_RGBA = 20;
|
||||
static constexpr int VIEW_ABGR = 21;
|
||||
static constexpr int VIEW_MAX = 4;
|
||||
static constexpr int VIEW_DEFAULT = 0;
|
||||
static constexpr int VIEW_DEFAULT_ARRAY = 1;
|
||||
static constexpr int VIEW_STORAGE = 2;
|
||||
static constexpr int VIEW_STORAGE_ARRAY = 3;
|
||||
|
||||
explicit VulkanImage(VulkanImageType type): type(type) {}
|
||||
KYTY_CLASS_NO_COPY(VulkanImage);
|
||||
|
||||
VulkanImageType type = VulkanImageType::Unknown;
|
||||
VkFormat format = VK_FORMAT_UNDEFINED;
|
||||
@@ -103,6 +113,7 @@ struct VulkanImage {
|
||||
VkImageView image_view[VIEW_MAX] = {};
|
||||
VkImageLayout layout = VK_IMAGE_LAYOUT_UNDEFINED;
|
||||
Graphics::VulkanMemory memory;
|
||||
ImageViewCache view_cache;
|
||||
};
|
||||
|
||||
struct VideoOutVulkanImage: public VulkanImage {
|
||||
@@ -130,23 +141,7 @@ struct TextureVulkanImage: public GpuTextureVulkanImage {
|
||||
};
|
||||
|
||||
struct StorageTextureVulkanImage: public GpuTextureVulkanImage {
|
||||
struct StorageView {
|
||||
uint32_t base_level = 0;
|
||||
VkImageView view = nullptr;
|
||||
};
|
||||
struct SampledView {
|
||||
VkFormat format = VK_FORMAT_UNDEFINED;
|
||||
uint32_t swizzle = 0;
|
||||
uint32_t type = 0;
|
||||
uint32_t base_level = 0;
|
||||
uint32_t level_count = 0;
|
||||
VkImageView view = nullptr;
|
||||
};
|
||||
StorageTextureVulkanImage(): GpuTextureVulkanImage(VulkanImageType::StorageTexture) {}
|
||||
std::mutex sampled_view_mutex;
|
||||
std::vector<SampledView> sampled_views;
|
||||
std::mutex storage_view_mutex;
|
||||
std::vector<StorageView> storage_views;
|
||||
};
|
||||
|
||||
struct RenderTextureVulkanImage: public VulkanImage {
|
||||
@@ -157,33 +152,10 @@ struct RenderTextureVulkanImage: public VulkanImage {
|
||||
uint32_t layer_count = 1;
|
||||
VkImageView view = nullptr;
|
||||
};
|
||||
struct SampledView {
|
||||
VkFormat format = VK_FORMAT_UNDEFINED;
|
||||
VkImageViewType type = VK_IMAGE_VIEW_TYPE_2D;
|
||||
uint32_t base_level = 0;
|
||||
uint32_t level_count = 0;
|
||||
uint32_t base_layer = 0;
|
||||
uint32_t layer_count = 1;
|
||||
int variant = VIEW_DEFAULT;
|
||||
VkImageView view = nullptr;
|
||||
};
|
||||
struct StorageView {
|
||||
VkFormat format = VK_FORMAT_UNDEFINED;
|
||||
VkImageViewType type = VK_IMAGE_VIEW_TYPE_2D;
|
||||
uint32_t base_level = 0;
|
||||
uint32_t level_count = 0;
|
||||
uint32_t base_layer = 0;
|
||||
uint32_t layer_count = 1;
|
||||
VkImageView view = nullptr;
|
||||
};
|
||||
RenderTextureVulkanImage(): VulkanImage(VulkanImageType::RenderTexture) {}
|
||||
VkImageView render_view[16] = {};
|
||||
std::mutex attachment_view_mutex;
|
||||
std::vector<AttachmentView> attachment_views;
|
||||
std::mutex sampled_view_mutex;
|
||||
std::vector<SampledView> sampled_views;
|
||||
std::mutex storage_view_mutex;
|
||||
std::vector<StorageView> storage_views;
|
||||
};
|
||||
|
||||
struct VulkanBuffer {
|
||||
|
||||
Reference in New Issue
Block a user