OGL/TextureCache: Move file statics to the TextureCache class

These rely on instance state, or are used within instance-based class
member functions, so they should belong to the instance itself instead
of being file statics.
This commit is contained in:
Lioncash
2017-09-17 01:54:03 -04:00
parent d7aa49a1a7
commit 6d9ed9dc32
2 changed files with 78 additions and 73 deletions

View File

@ -5,15 +5,18 @@
#pragma once
#include <map>
#include <utility>
#include "Common/CommonTypes.h"
#include "Common/GL/GLUtil.h"
#include "VideoBackends/OGL/ProgramShaderCache.h"
#include "VideoCommon/TextureCacheBase.h"
#include "VideoCommon/TextureConversionShader.h"
#include "VideoCommon/VideoCommon.h"
class AbstractTexture;
class StreamBuffer;
struct TextureConfig;
namespace OGL
@ -36,6 +39,26 @@ public:
GLuint GetColorCopyPositionUniform() const;
private:
struct PaletteShader
{
SHADER shader;
GLuint buffer_offset_uniform;
GLuint multiplier_uniform;
GLuint copy_position_uniform;
};
struct TextureDecodingProgramInfo
{
const TextureConversionShader::DecodingShaderInfo* base_info = nullptr;
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;
};
std::unique_ptr<AbstractTexture> CreateTexture(const TextureConfig& config) override;
void ConvertTexture(TCacheEntry* destination, TCacheEntry* source, const void* palette,
TLUTFormat format) override;
@ -50,6 +73,12 @@ private:
bool CompileShaders() override;
void DeleteShaders() override;
bool CompilePaletteShader(TLUTFormat tlutfmt, const std::string& vcode, const std::string& pcode,
const std::string& gcode);
void CreateTextureDecodingResources();
void DestroyTextureDecodingResources();
SHADER m_colorCopyProgram;
SHADER m_colorMatrixProgram;
SHADER m_depthMatrixProgram;
@ -58,6 +87,16 @@ private:
GLuint m_colorCopyPositionUniform;
GLuint m_colorMatrixPositionUniform;
GLuint m_depthCopyPositionUniform;
u32 m_color_cbuf_id;
u32 m_depth_cbuf_id;
PaletteShader m_palette_shaders[3];
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;
std::array<GLuint, TextureConversionShader::BUFFER_FORMAT_COUNT> m_texture_decoding_buffer_views;
};
bool SaveTexture(const std::string& filename, u32 textarget, u32 tex, int virtual_width,