2020-12-05 13:08:24 +01:00
|
|
|
#pragma once
|
2021-05-12 23:56:01 +02:00
|
|
|
#include "../Program/VertexProgramDecompiler.h"
|
2020-05-16 07:50:28 +02:00
|
|
|
#include "GLHelpers.h"
|
2012-11-15 00:39:56 +01:00
|
|
|
|
2020-12-22 16:04:08 +01:00
|
|
|
#include <unordered_map>
|
|
|
|
|
|
2016-10-18 09:57:28 +02:00
|
|
|
enum
|
|
|
|
|
{
|
|
|
|
|
GL_VP_FORCE_ATTRIB_SCALING = 1, //Scale vertex read result
|
|
|
|
|
GL_VP_ATTRIB_S16_INT = (1 << 1), //Attrib is a signed 16-bit integer
|
|
|
|
|
GL_VP_ATTRIB_S32_INT = (1 << 2), //Attrib is a signed 32-bit integer
|
|
|
|
|
|
|
|
|
|
GL_VP_SINT_MASK = (GL_VP_ATTRIB_S16_INT|GL_VP_ATTRIB_S32_INT)
|
|
|
|
|
};
|
|
|
|
|
|
2020-03-24 22:22:21 +01:00
|
|
|
namespace gl
|
|
|
|
|
{
|
|
|
|
|
class shader_interpreter;
|
|
|
|
|
};
|
|
|
|
|
|
2015-07-01 00:25:52 +02:00
|
|
|
struct GLVertexDecompilerThread : public VertexProgramDecompiler
|
2012-11-15 00:39:56 +01:00
|
|
|
{
|
2020-03-24 22:22:21 +01:00
|
|
|
friend class gl::shader_interpreter;
|
|
|
|
|
|
2015-05-19 19:43:22 +02:00
|
|
|
std::string &m_shader;
|
|
|
|
|
protected:
|
2020-12-18 08:39:54 +01:00
|
|
|
std::string getFloatTypeName(usz elementCount) override;
|
|
|
|
|
std::string getIntTypeName(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&, bool scalar) override;
|
|
|
|
|
|
|
|
|
|
void insertHeader(std::stringstream &OS) override;
|
|
|
|
|
void insertInputs(std::stringstream &OS, const std::vector<ParamType> &inputs) override;
|
|
|
|
|
void insertConstants(std::stringstream &OS, const std::vector<ParamType> &constants) override;
|
|
|
|
|
void insertOutputs(std::stringstream &OS, const std::vector<ParamType> &outputs) override;
|
|
|
|
|
void insertMainStart(std::stringstream &OS) override;
|
|
|
|
|
void insertMainEnd(std::stringstream &OS) override;
|
2016-01-28 18:01:10 +01:00
|
|
|
|
|
|
|
|
const RSXVertexProgram &rsx_vertex_program;
|
2017-07-31 13:38:28 +02:00
|
|
|
std::unordered_map<std::string, int> input_locations;
|
2015-05-19 19:43:22 +02:00
|
|
|
public:
|
2017-06-18 16:53:02 +02:00
|
|
|
GLVertexDecompilerThread(const RSXVertexProgram &prog, std::string& shader, ParamArray&)
|
2016-01-10 20:09:56 +01:00
|
|
|
: VertexProgramDecompiler(prog)
|
2015-07-01 00:25:52 +02:00
|
|
|
, m_shader(shader)
|
2016-01-28 18:01:10 +01:00
|
|
|
, rsx_vertex_program(prog)
|
2012-11-15 00:39:56 +01:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-01 00:25:52 +02:00
|
|
|
void Task();
|
2012-11-15 00:39:56 +01:00
|
|
|
};
|
|
|
|
|
|
2014-06-01 08:41:57 +02:00
|
|
|
class GLVertexProgram
|
2020-05-16 07:50:28 +02:00
|
|
|
{
|
2014-06-01 08:41:57 +02:00
|
|
|
public:
|
2013-11-09 22:29:49 +01:00
|
|
|
GLVertexProgram();
|
|
|
|
|
~GLVertexProgram();
|
2012-11-15 00:39:56 +01:00
|
|
|
|
2015-05-19 19:43:22 +02:00
|
|
|
ParamArray parr;
|
2020-05-16 07:50:28 +02:00
|
|
|
u32 id;
|
|
|
|
|
gl::glsl::shader shader;
|
2022-03-23 20:53:18 +01:00
|
|
|
std::vector<u16> constant_ids;
|
|
|
|
|
bool has_indexed_constants;
|
2012-11-15 00:39:56 +01:00
|
|
|
|
2016-01-10 20:09:56 +01:00
|
|
|
void Decompile(const RSXVertexProgram& prog);
|
2014-06-01 08:41:57 +02:00
|
|
|
|
|
|
|
|
private:
|
2012-11-15 00:39:56 +01:00
|
|
|
void Delete();
|
|
|
|
|
};
|