2015-05-24 04:55:12 +00:00
|
|
|
// Copyright 2008 Dolphin Emulator Project
|
2015-05-17 23:08:10 +00:00
|
|
|
// Licensed under GPLv2+
|
2013-04-18 03:29:41 +00:00
|
|
|
// Refer to the license.txt file included.
|
2008-12-08 04:46:09 +00:00
|
|
|
|
2014-02-10 18:54:46 +00:00
|
|
|
#pragma once
|
2008-12-08 04:46:09 +00:00
|
|
|
|
|
|
|
#include <map>
|
2017-09-17 05:54:03 +00:00
|
|
|
#include <utility>
|
2008-12-08 04:46:09 +00:00
|
|
|
|
2017-02-01 15:56:13 +00:00
|
|
|
#include "Common/CommonTypes.h"
|
2015-09-18 16:40:00 +00:00
|
|
|
#include "Common/GL/GLUtil.h"
|
2017-04-23 04:44:34 +00:00
|
|
|
#include "VideoBackends/OGL/ProgramShaderCache.h"
|
2015-09-18 16:40:00 +00:00
|
|
|
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "VideoCommon/TextureCacheBase.h"
|
2017-09-17 05:54:03 +00:00
|
|
|
#include "VideoCommon/TextureConversionShader.h"
|
2017-08-04 15:56:24 +00:00
|
|
|
#include "VideoCommon/TextureConverterShaderGen.h"
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "VideoCommon/VideoCommon.h"
|
2010-10-19 22:24:27 +00:00
|
|
|
|
2017-04-23 04:44:34 +00:00
|
|
|
class AbstractTexture;
|
2017-09-17 05:54:03 +00:00
|
|
|
class StreamBuffer;
|
2017-04-23 04:44:34 +00:00
|
|
|
struct TextureConfig;
|
|
|
|
|
2010-10-19 22:24:27 +00:00
|
|
|
namespace OGL
|
|
|
|
{
|
2015-11-06 00:28:05 +00:00
|
|
|
class TextureCache : public TextureCacheBase
|
2008-12-08 04:46:09 +00:00
|
|
|
{
|
|
|
|
public:
|
2016-06-24 08:43:46 +00:00
|
|
|
TextureCache();
|
|
|
|
~TextureCache();
|
2015-12-21 02:49:49 +00:00
|
|
|
|
2017-04-23 04:44:34 +00:00
|
|
|
static TextureCache* GetInstance();
|
2010-10-19 22:24:27 +00:00
|
|
|
|
2017-07-30 19:45:55 +00:00
|
|
|
bool SupportsGPUTextureDecode(TextureFormat format, TLUTFormat palette_format) override;
|
2017-04-23 04:44:34 +00:00
|
|
|
void DecodeTextureOnGPU(TCacheEntry* entry, u32 dst_level, const u8* data, size_t data_size,
|
2016-11-27 08:15:00 +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-11-27 08:15:00 +00:00
|
|
|
|
2017-04-23 04:44:34 +00:00
|
|
|
const SHADER& GetColorCopyProgram() const;
|
|
|
|
GLuint GetColorCopyPositionUniform() const;
|
2010-10-19 22:24:27 +00:00
|
|
|
|
2017-04-23 04:44:34 +00:00
|
|
|
private:
|
2017-09-17 05:54:03 +00:00
|
|
|
struct PaletteShader
|
|
|
|
{
|
|
|
|
SHADER shader;
|
|
|
|
GLuint buffer_offset_uniform;
|
|
|
|
GLuint multiplier_uniform;
|
|
|
|
GLuint copy_position_uniform;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct TextureDecodingProgramInfo
|
|
|
|
{
|
2017-11-25 10:13:22 +00:00
|
|
|
const TextureConversionShaderTiled::DecodingShaderInfo* base_info = nullptr;
|
2017-09-17 05:54:03 +00:00
|
|
|
SHADER program;
|
|
|
|
GLint uniform_dst_size = -1;
|
|
|
|
GLint uniform_src_size = -1;
|
|
|
|
GLint uniform_src_row_stride = -1;
|
|
|
|
GLint uniform_src_offset = -1;
|
|
|
|
GLint uniform_palette_offset = -1;
|
|
|
|
bool valid = false;
|
|
|
|
};
|
|
|
|
|
2017-07-30 19:45:55 +00:00
|
|
|
void ConvertTexture(TCacheEntry* destination, TCacheEntry* source, const void* palette,
|
|
|
|
TLUTFormat format) override;
|
2014-11-03 23:53:14 +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,
|
|
|
|
bool scale_by_half) override;
|
2015-10-29 16:48:35 +00:00
|
|
|
|
2017-04-23 04:44:34 +00:00
|
|
|
void CopyEFBToCacheEntry(TCacheEntry* entry, bool is_depth_copy, const EFBRectangle& src_rect,
|
2017-12-02 16:16:58 +00:00
|
|
|
bool scale_by_half, EFBCopyFormat dst_format,
|
|
|
|
bool is_intensity) override;
|
2017-04-23 04:44:34 +00:00
|
|
|
|
2016-08-13 12:56:01 +00:00
|
|
|
bool CompileShaders() override;
|
2016-06-24 08:43:46 +00:00
|
|
|
void DeleteShaders() override;
|
2017-04-23 04:44:34 +00:00
|
|
|
|
2017-09-17 05:54:03 +00:00
|
|
|
bool CompilePaletteShader(TLUTFormat tlutfmt, const std::string& vcode, const std::string& pcode,
|
|
|
|
const std::string& gcode);
|
|
|
|
|
|
|
|
void CreateTextureDecodingResources();
|
|
|
|
void DestroyTextureDecodingResources();
|
|
|
|
|
2017-08-04 15:56:24 +00:00
|
|
|
struct EFBCopyShader
|
|
|
|
{
|
|
|
|
SHADER shader;
|
|
|
|
GLuint position_uniform;
|
|
|
|
};
|
|
|
|
|
2017-11-25 10:07:14 +00:00
|
|
|
std::map<TextureConversionShaderGen::TCShaderUid, EFBCopyShader> m_efb_copy_programs;
|
2017-08-04 15:56:24 +00:00
|
|
|
|
2017-04-23 04:44:34 +00:00
|
|
|
SHADER m_colorCopyProgram;
|
|
|
|
GLuint m_colorCopyPositionUniform;
|
2017-09-17 05:54:03 +00:00
|
|
|
|
2017-09-17 06:26:45 +00:00
|
|
|
std::array<PaletteShader, 3> m_palette_shaders;
|
2017-09-17 05:54:03 +00:00
|
|
|
std::unique_ptr<StreamBuffer> m_palette_stream_buffer;
|
|
|
|
GLuint m_palette_resolv_texture = 0;
|
|
|
|
|
|
|
|
std::map<std::pair<u32, u32>, TextureDecodingProgramInfo> m_texture_decoding_program_info;
|
2017-11-25 10:13:22 +00:00
|
|
|
std::array<GLuint, TextureConversionShaderTiled::BUFFER_FORMAT_COUNT>
|
|
|
|
m_texture_decoding_buffer_views;
|
2008-12-08 04:46:09 +00:00
|
|
|
};
|
2010-10-19 22:24:27 +00:00
|
|
|
}
|