2019-10-14 00:24:04 +02:00
|
|
|
|
#pragma once
|
2015-05-19 19:43:22 +02:00
|
|
|
|
#include "../Common/FragmentProgramDecompiler.h"
|
2019-10-14 00:24:04 +02:00
|
|
|
|
#include "../Common/GLSLTypes.h"
|
2014-08-04 01:33:57 +02:00
|
|
|
|
#include "Emu/RSX/RSXFragmentProgram.h"
|
2012-11-15 00:39:56 +01:00
|
|
|
|
|
2019-10-14 00:24:04 +02:00
|
|
|
|
namespace glsl
|
|
|
|
|
|
{
|
|
|
|
|
|
struct shader_properties;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2015-07-01 00:25:52 +02:00
|
|
|
|
struct GLFragmentDecompilerThread : public FragmentProgramDecompiler
|
2012-11-15 00:39:56 +01:00
|
|
|
|
{
|
2013-11-27 20:16:19 +01:00
|
|
|
|
std::string& m_shader;
|
2015-05-19 19:43:22 +02:00
|
|
|
|
ParamArray& m_parrDummy;
|
2019-10-14 00:24:04 +02:00
|
|
|
|
glsl::shader_properties m_shader_props{};
|
|
|
|
|
|
|
2015-05-19 19:43:22 +02:00
|
|
|
|
public:
|
2016-01-10 20:09:56 +01:00
|
|
|
|
GLFragmentDecompilerThread(std::string& shader, ParamArray& parr, const RSXFragmentProgram &prog, u32& size)
|
|
|
|
|
|
: FragmentProgramDecompiler(prog, size)
|
2012-11-15 00:39:56 +01:00
|
|
|
|
, 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:
|
2019-06-08 09:49:47 +02:00
|
|
|
|
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;
|
2012-11-15 00:39:56 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
2014-04-15 16:12:15 +02:00
|
|
|
|
/** 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.
|
|
|
|
|
|
*/
|
2015-01-01 23:55:02 +01:00
|
|
|
|
class GLFragmentProgram
|
2012-11-15 00:39:56 +01:00
|
|
|
|
{
|
2014-04-15 16:12:15 +02:00
|
|
|
|
public:
|
2015-01-01 23:55:02 +01:00
|
|
|
|
GLFragmentProgram();
|
|
|
|
|
|
~GLFragmentProgram();
|
|
|
|
|
|
|
2015-05-19 19:43:22 +02:00
|
|
|
|
ParamArray parr;
|
2015-07-01 00:25:52 +02:00
|
|
|
|
u32 id = 0;
|
2015-01-01 23:55:02 +01:00
|
|
|
|
std::string shader;
|
2015-05-16 01:10:27 +02:00
|
|
|
|
std::vector<size_t> FragmentConstantOffsetCache;
|
2012-11-15 00:39:56 +01:00
|
|
|
|
|
2014-04-15 16:12:15 +02:00
|
|
|
|
/**
|
|
|
|
|
|
* 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
|
2015-12-10 02:52:27 +01:00
|
|
|
|
* @param td texture dimensions of input textures
|
2014-04-15 16:12:15 +02:00
|
|
|
|
*/
|
2016-01-10 20:09:56 +01:00
|
|
|
|
void Decompile(const RSXFragmentProgram& prog);
|
2012-11-15 00:39:56 +01:00
|
|
|
|
|
2014-04-15 16:12:15 +02:00
|
|
|
|
/** Compile the decompiled fragment shader into a format we can use with OpenGL. */
|
2012-11-15 00:39:56 +01:00
|
|
|
|
void Compile();
|
|
|
|
|
|
|
2014-04-15 16:12:15 +02:00
|
|
|
|
private:
|
|
|
|
|
|
/** Deletes the shader and any stored information */
|
2012-11-15 00:39:56 +01:00
|
|
|
|
void Delete();
|
2014-04-15 16:12:15 +02:00
|
|
|
|
};
|