2020-12-05 13:08:24 +01:00
|
|
|
#pragma once
|
2021-05-12 23:56:01 +02:00
|
|
|
#include "../Program/FragmentProgramDecompiler.h"
|
|
|
|
|
#include "../Program/GLSLTypes.h"
|
2020-05-16 07:50:28 +02:00
|
|
|
#include "GLHelpers.h"
|
2012-11-15 00:39:56 +01:00
|
|
|
|
2019-10-14 00:24:04 +02:00
|
|
|
namespace glsl
|
|
|
|
|
{
|
|
|
|
|
struct shader_properties;
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-24 22:22:21 +01:00
|
|
|
namespace gl
|
|
|
|
|
{
|
|
|
|
|
class shader_interpreter;
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-01 00:25:52 +02:00
|
|
|
struct GLFragmentDecompilerThread : public FragmentProgramDecompiler
|
2012-11-15 00:39:56 +01:00
|
|
|
{
|
2020-03-24 22:22:21 +01:00
|
|
|
friend class gl::shader_interpreter;
|
|
|
|
|
|
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:
|
2020-12-18 08:39:54 +01:00
|
|
|
std::string getFloatTypeName(usz elementCount) override;
|
|
|
|
|
std::string getHalfTypeName(usz elementCount) override;
|
2019-06-08 09:49:47 +02:00
|
|
|
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;
|
2020-05-16 07:50:28 +02:00
|
|
|
u32 id;
|
|
|
|
|
gl::glsl::shader shader;
|
2020-12-18 08:39:54 +01:00
|
|
|
std::vector<usz> 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
|
|
|
|
|
*/
|
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
|
|
|
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
|
|
|
};
|