[Vulkan] Texture cache: Maximum dimensions, null images
This commit is contained in:
94
src/xenia/gpu/vulkan/vulkan_texture_cache.h
Normal file
94
src/xenia/gpu/vulkan/vulkan_texture_cache.h
Normal file
@@ -0,0 +1,94 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* Xenia : Xbox 360 Emulator Research Project *
|
||||
******************************************************************************
|
||||
* Copyright 2022 Ben Vanik. All rights reserved. *
|
||||
* Released under the BSD license - see LICENSE in the root for more details. *
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef XENIA_GPU_VULKAN_VULKAN_TEXTURE_CACHE_H_
|
||||
#define XENIA_GPU_VULKAN_VULKAN_TEXTURE_CACHE_H_
|
||||
|
||||
#include <array>
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
#include "xenia/gpu/texture_cache.h"
|
||||
#include "xenia/gpu/vulkan/vulkan_shared_memory.h"
|
||||
#include "xenia/ui/vulkan/vulkan_provider.h"
|
||||
|
||||
namespace xe {
|
||||
namespace gpu {
|
||||
namespace vulkan {
|
||||
|
||||
class VulkanCommandProcessor;
|
||||
|
||||
class VulkanTextureCache final : public TextureCache {
|
||||
public:
|
||||
static std::unique_ptr<VulkanTextureCache> Create(
|
||||
const RegisterFile& register_file, VulkanSharedMemory& shared_memory,
|
||||
uint32_t draw_resolution_scale_x, uint32_t draw_resolution_scale_y,
|
||||
VulkanCommandProcessor& command_processor,
|
||||
VkPipelineStageFlags guest_shader_pipeline_stages) {
|
||||
std::unique_ptr<VulkanTextureCache> texture_cache(new VulkanTextureCache(
|
||||
register_file, shared_memory, draw_resolution_scale_x,
|
||||
draw_resolution_scale_y, command_processor,
|
||||
guest_shader_pipeline_stages));
|
||||
if (!texture_cache->Initialize()) {
|
||||
return nullptr;
|
||||
}
|
||||
return std::move(texture_cache);
|
||||
}
|
||||
|
||||
~VulkanTextureCache();
|
||||
|
||||
void BeginSubmission(uint64_t new_submission_index) override;
|
||||
|
||||
protected:
|
||||
uint32_t GetHostFormatSwizzle(TextureKey key) const override;
|
||||
|
||||
uint32_t GetMaxHostTextureWidthHeight(
|
||||
xenos::DataDimension dimension) const override;
|
||||
uint32_t GetMaxHostTextureDepthOrArraySize(
|
||||
xenos::DataDimension dimension) const override;
|
||||
|
||||
std::unique_ptr<Texture> CreateTexture(TextureKey key) override;
|
||||
|
||||
bool LoadTextureDataFromResidentMemoryImpl(Texture& texture, bool load_base,
|
||||
bool load_mips) override;
|
||||
|
||||
private:
|
||||
class VulkanTexture final : public Texture {
|
||||
public:
|
||||
explicit VulkanTexture(VulkanTextureCache& texture_cache,
|
||||
const TextureKey& key);
|
||||
};
|
||||
|
||||
explicit VulkanTextureCache(
|
||||
const RegisterFile& register_file, VulkanSharedMemory& shared_memory,
|
||||
uint32_t draw_resolution_scale_x, uint32_t draw_resolution_scale_y,
|
||||
VulkanCommandProcessor& command_processor,
|
||||
VkPipelineStageFlags guest_shader_pipeline_stages);
|
||||
|
||||
bool Initialize();
|
||||
|
||||
VulkanCommandProcessor& command_processor_;
|
||||
VkPipelineStageFlags guest_shader_pipeline_stages_;
|
||||
|
||||
// If both images can be placed in the same allocation, it's one allocation,
|
||||
// otherwise it's two separate.
|
||||
std::array<VkDeviceMemory, 2> null_images_memory_{};
|
||||
VkImage null_image_2d_array_cube_ = VK_NULL_HANDLE;
|
||||
VkImage null_image_3d_ = VK_NULL_HANDLE;
|
||||
VkImageView null_image_view_2d_array_ = VK_NULL_HANDLE;
|
||||
VkImageView null_image_view_cube_ = VK_NULL_HANDLE;
|
||||
VkImageView null_image_view_3d_ = VK_NULL_HANDLE;
|
||||
bool null_images_cleared_ = false;
|
||||
};
|
||||
|
||||
} // namespace vulkan
|
||||
} // namespace gpu
|
||||
} // namespace xe
|
||||
|
||||
#endif // XENIA_GPU_VULKAN_VULKAN_TEXTURE_CACHE_H_
|
||||
Reference in New Issue
Block a user