rpcsx/rpcs3/Emu/RSX/GL/GLFragmentProgram.h

70 lines
2 KiB
C
Raw Normal View History

#pragma once
2015-05-19 19:43:22 +02:00
#include "../Common/FragmentProgramDecompiler.h"
#include "../Common/GLSLTypes.h"
2014-08-04 01:33:57 +02:00
#include "Emu/RSX/RSXFragmentProgram.h"
namespace glsl
{
struct shader_properties;
}
2015-07-01 00:25:52 +02:00
struct GLFragmentDecompilerThread : public FragmentProgramDecompiler
{
2013-11-27 20:16:19 +01:00
std::string& m_shader;
2015-05-19 19:43:22 +02:00
ParamArray& m_parrDummy;
glsl::shader_properties m_shader_props{};
2015-05-19 19:43:22 +02:00
public:
GLFragmentDecompilerThread(std::string& shader, ParamArray& parr, const RSXFragmentProgram &prog, u32& size)
: FragmentProgramDecompiler(prog, size)
, m_shader(shader)
2015-05-19 19:43:22 +02:00
, m_parrDummy(parr)
2015-07-01 00:25:52 +02:00
{
}
2015-05-19 19:43:22 +02:00
void Task();
protected:
std::string getFloatTypeName(size_t elementCount) override;
std::string getHalfTypeName(size_t elementCount) override;
std::string getFunction(FUNCTION) override;
std::string compareFunction(COMPARE, const std::string&, const std::string&) override;
void insertHeader(std::stringstream &OS) override;
void insertInputs(std::stringstream &OS) override;
void insertOutputs(std::stringstream &OS) override;
void insertConstants(std::stringstream &OS) override;
void insertGlobalFunctions(std::stringstream &OS) override;
void insertMainStart(std::stringstream &OS) override;
void insertMainEnd(std::stringstream &OS) override;
};
/** Storage for an Fragment Program in the process of of recompilation.
* This class calls OpenGL functions and should only be used from the RSX/Graphics thread.
*/
class GLFragmentProgram
{
public:
GLFragmentProgram();
~GLFragmentProgram();
2015-05-19 19:43:22 +02:00
ParamArray parr;
2015-07-01 00:25:52 +02:00
u32 id = 0;
std::string shader;
2015-05-16 01:10:27 +02:00
std::vector<size_t> FragmentConstantOffsetCache;
/**
* Decompile a fragment shader located in the PS3's Memory. This function operates synchronously.
* @param prog RSXShaderProgram specifying the location and size of the shader in memory
* @param td texture dimensions of input textures
*/
void Decompile(const RSXFragmentProgram& prog);
/** Compile the decompiled fragment shader into a format we can use with OpenGL. */
void Compile();
private:
/** Deletes the shader and any stored information */
void Delete();
};