2016-08-13 12:57:50 +00:00
|
|
|
// Copyright 2016 Dolphin Emulator Project
|
|
|
|
// Licensed under GPLv2+
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2017-08-04 15:56:24 +00:00
|
|
|
#include <map>
|
2016-08-13 12:57:50 +00:00
|
|
|
#include <memory>
|
|
|
|
|
2016-10-01 03:07:50 +00:00
|
|
|
#include "Common/CommonTypes.h"
|
2016-08-13 12:57:50 +00:00
|
|
|
#include "VideoBackends/Vulkan/StreamBuffer.h"
|
|
|
|
#include "VideoCommon/TextureCacheBase.h"
|
2017-08-04 15:56:24 +00:00
|
|
|
#include "VideoCommon/TextureConverterShaderGen.h"
|
2016-08-13 12:57:50 +00:00
|
|
|
|
|
|
|
namespace Vulkan
|
|
|
|
{
|
2016-11-19 13:25:23 +00:00
|
|
|
class TextureConverter;
|
2016-08-13 12:57:50 +00:00
|
|
|
class StateTracker;
|
|
|
|
class Texture2D;
|
2017-04-23 04:44:34 +00:00
|
|
|
class VKTexture;
|
2016-08-13 12:57:50 +00:00
|
|
|
|
|
|
|
class TextureCache : public TextureCacheBase
|
|
|
|
{
|
|
|
|
public:
|
2016-10-22 11:00:52 +00:00
|
|
|
TextureCache();
|
|
|
|
~TextureCache();
|
|
|
|
|
|
|
|
static TextureCache* GetInstance();
|
|
|
|
|
2016-11-19 14:43:50 +00:00
|
|
|
TextureConverter* GetTextureConverter() const { return m_texture_converter.get(); }
|
2016-10-22 11:00:52 +00:00
|
|
|
bool Initialize();
|
|
|
|
|
|
|
|
bool CompileShaders() override;
|
|
|
|
void DeleteShaders() override;
|
|
|
|
|
2017-07-30 19:45:55 +00:00
|
|
|
void ConvertTexture(TCacheEntry* destination, TCacheEntry* source, const void* palette,
|
|
|
|
TLUTFormat format) override;
|
2016-08-13 12:57:50 +00:00
|
|
|
|
2017-07-30 19:45:55 +00:00
|
|
|
void CopyEFB(u8* dst, const EFBCopyParams& params, u32 native_width, u32 bytes_per_row,
|
|
|
|
u32 num_blocks_y, u32 memory_stride, const EFBRectangle& src_rect,
|
2018-04-29 08:52:30 +00:00
|
|
|
bool scale_by_half, float y_scale, float gamma, bool clamp_top, bool clamp_bottom,
|
|
|
|
const CopyFilterCoefficientArray& filter_coefficients) override;
|
2016-10-22 11:00:52 +00:00
|
|
|
|
2017-07-30 19:45:55 +00:00
|
|
|
bool SupportsGPUTextureDecode(TextureFormat format, TLUTFormat palette_format) override;
|
2016-12-09 12:23:07 +00:00
|
|
|
|
2017-04-23 04:44:34 +00:00
|
|
|
void DecodeTextureOnGPU(TCacheEntry* entry, u32 dst_level, const u8* data, size_t data_size,
|
2016-12-09 12:23:07 +00:00
|
|
|
TextureFormat format, u32 width, u32 height, u32 aligned_width,
|
|
|
|
u32 aligned_height, u32 row_stride, const u8* palette,
|
2017-07-30 19:45:55 +00:00
|
|
|
TLUTFormat palette_format) override;
|
2016-12-09 12:23:07 +00:00
|
|
|
|
2017-04-23 04:44:34 +00:00
|
|
|
VkShaderModule GetCopyShader() const;
|
|
|
|
StreamBuffer* GetTextureUploadBuffer() const;
|
|
|
|
|
2016-10-22 11:00:52 +00:00
|
|
|
private:
|
2017-04-23 04:44:34 +00:00
|
|
|
void CopyEFBToCacheEntry(TCacheEntry* entry, bool is_depth_copy, const EFBRectangle& src_rect,
|
2018-04-29 08:52:30 +00:00
|
|
|
bool scale_by_half, EFBCopyFormat dst_format, bool is_intensity,
|
|
|
|
float gamma, bool clamp_top, bool clamp_bottom,
|
|
|
|
const CopyFilterCoefficientArray& filter_coefficients) override;
|
2016-10-22 11:19:09 +00:00
|
|
|
|
2016-08-13 12:57:50 +00:00
|
|
|
std::unique_ptr<StreamBuffer> m_texture_upload_buffer;
|
|
|
|
|
2016-11-19 13:25:23 +00:00
|
|
|
std::unique_ptr<TextureConverter> m_texture_converter;
|
2016-08-13 12:57:50 +00:00
|
|
|
|
|
|
|
VkShaderModule m_copy_shader = VK_NULL_HANDLE;
|
2017-11-25 10:07:14 +00:00
|
|
|
std::map<TextureConversionShaderGen::TCShaderUid, VkShaderModule> m_efb_copy_to_tex_shaders;
|
2016-08-13 12:57:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Vulkan
|