diff --git a/rpcs3/Emu/RSX/GL/GLCommonDecompiler.cpp b/rpcs3/Emu/RSX/GL/GLCommonDecompiler.cpp
new file mode 100644
index 0000000000..808646b4d8
--- /dev/null
+++ b/rpcs3/Emu/RSX/GL/GLCommonDecompiler.cpp
@@ -0,0 +1,69 @@
+#include "stdafx.h"
+#include "GLCommonDecompiler.h"
+
+std::string getFloatTypeNameImpl(size_t elementCount)
+{
+ switch (elementCount)
+ {
+ default:
+ abort();
+ case 1:
+ return "float";
+ case 2:
+ return "vec2";
+ case 3:
+ return "vec3";
+ case 4:
+ return "vec4";
+ }
+}
+
+std::string getFunctionImpl(FUNCTION f)
+{
+ switch (f)
+ {
+ default:
+ abort();
+ case FUNCTION::FUNCTION_DP2:
+ return "vec4(dot($0.xy, $1.xy))";
+ case FUNCTION::FUNCTION_DP2A:
+ return "";
+ case FUNCTION::FUNCTION_DP3:
+ return "vec4(dot($0.xyz, $1.xyz))";
+ case FUNCTION::FUNCTION_DP4:
+ return "vec4(dot($0, $1))";
+ case FUNCTION::FUNCTION_DPH:
+ return "vec4(dot(vec4($0.xyz, 1.0), $1))";
+ case FUNCTION::FUNCTION_SFL:
+ return "vec4(0., 0., 0., 0.)";
+ case FUNCTION::FUNCTION_STR:
+ return "vec4(1., 1., 1., 1.)";
+ case FUNCTION::FUNCTION_FRACT:
+ return "fract($0)";
+ case FUNCTION::FUNCTION_TEXTURE_SAMPLE:
+ return "texture($t, $0.xy)";
+ case FUNCTION::FUNCTION_DFDX:
+ return "dFdx($0)";
+ case FUNCTION::FUNCTION_DFDY:
+ return "dFdy($0)";
+ }
+}
+
+std::string compareFunctionImpl(COMPARE f, const std::string &Op0, const std::string &Op1)
+{
+ switch (f)
+ {
+ case COMPARE::FUNCTION_SEQ:
+ return "equal(" + Op0 + ", " + Op1 + ")";
+ case COMPARE::FUNCTION_SGE:
+ return "greaterThanEqual(" + Op0 + ", " + Op1 + ")";
+ case COMPARE::FUNCTION_SGT:
+ return "greaterThan(" + Op0 + ", " + Op1 + ")";
+ case COMPARE::FUNCTION_SLE:
+ return "lessThanEqual(" + Op0 + ", " + Op1 + ")";
+ case COMPARE::FUNCTION_SLT:
+ return "lessThan(" + Op0 + ", " + Op1 + ")";
+ case COMPARE::FUNCTION_SNE:
+ return "notEqual(" + Op0 + ", " + Op1 + ")";
+ }
+}
\ No newline at end of file
diff --git a/rpcs3/Emu/RSX/GL/GLCommonDecompiler.h b/rpcs3/Emu/RSX/GL/GLCommonDecompiler.h
new file mode 100644
index 0000000000..6ae1d5065a
--- /dev/null
+++ b/rpcs3/Emu/RSX/GL/GLCommonDecompiler.h
@@ -0,0 +1,6 @@
+#pragma once
+#include "../Common/ShaderParam.h"
+
+std::string getFloatTypeNameImpl(size_t elementCount);
+std::string getFunctionImpl(FUNCTION f);
+std::string compareFunctionImpl(COMPARE f, const std::string &Op0, const std::string &Op1);
\ No newline at end of file
diff --git a/rpcs3/Emu/RSX/GL/GLFragmentProgram.cpp b/rpcs3/Emu/RSX/GL/GLFragmentProgram.cpp
index f044e2fe90..de5a403275 100644
--- a/rpcs3/Emu/RSX/GL/GLFragmentProgram.cpp
+++ b/rpcs3/Emu/RSX/GL/GLFragmentProgram.cpp
@@ -4,50 +4,16 @@
#include "Emu/System.h"
#include "GLFragmentProgram.h"
+#include "GLCommonDecompiler.h"
+
std::string GLFragmentDecompilerThread::getFloatTypeName(size_t elementCount)
{
- switch (elementCount)
- {
- default:
- abort();
- case 1:
- return "float";
- case 2:
- return "vec2";
- case 3:
- return "vec3";
- case 4:
- return "vec4";
- }
+ return getFloatTypeNameImpl(elementCount);
}
std::string GLFragmentDecompilerThread::getFunction(FUNCTION f)
{
- switch (f)
- {
- default:
- abort();
- case FUNCTION::FUNCTION_DP2:
- return "vec4(dot($0.xy, $1.xy))";
- case FUNCTION::FUNCTION_DP2A:
- return "vec4(dot($0.xy, $1.xy) + $2.x)";
- case FUNCTION::FUNCTION_DP3:
- return "vec4(dot($0.xyz, $1.xyz))";
- case FUNCTION::FUNCTION_DP4:
- return "vec4(dot($0, $1))";
- case FUNCTION::FUNCTION_SFL:
- return "vec4(0., 0., 0., 0.)";
- case FUNCTION::FUNCTION_STR:
- return "vec4(1., 1., 1., 1.)";
- case FUNCTION::FUNCTION_FRACT:
- return "fract($0)";
- case FUNCTION::FUNCTION_TEXTURE_SAMPLE:
- return "texture($t, $0.xy)";
- case FUNCTION::FUNCTION_DFDX:
- return "dFdx($0)";
- case FUNCTION::FUNCTION_DFDY:
- return "dFdy($0)";
- }
+ return getFunctionImpl(f);
}
std::string GLFragmentDecompilerThread::saturate(const std::string & code)
@@ -57,24 +23,9 @@ std::string GLFragmentDecompilerThread::saturate(const std::string & code)
std::string GLFragmentDecompilerThread::compareFunction(COMPARE f, const std::string &Op0, const std::string &Op1)
{
- switch (f)
- {
- case COMPARE::FUNCTION_SEQ:
- return "equal(" + Op0 + ", " + Op1 + ")";
- case COMPARE::FUNCTION_SGE:
- return "greaterThanEqual(" + Op0 + ", " + Op1 + ")";
- case COMPARE::FUNCTION_SGT:
- return "greaterThan(" + Op0 + ", " + Op1 + ")";
- case COMPARE::FUNCTION_SLE:
- return "lessThanEqual(" + Op0 + ", " + Op1 + ")";
- case COMPARE::FUNCTION_SLT:
- return "lessThan(" + Op0 + ", " + Op1 + ")";
- case COMPARE::FUNCTION_SNE:
- return "notEqual(" + Op0 + ", " + Op1 + ")";
- }
+ return compareFunctionImpl(f, Op0, Op1);
}
-
void GLFragmentDecompilerThread::insertHeader(std::stringstream & OS)
{
OS << "#version 420" << std::endl;
diff --git a/rpcs3/Emu/RSX/GL/GLVertexProgram.cpp b/rpcs3/Emu/RSX/GL/GLVertexProgram.cpp
index 080bcf4403..bba7fc2677 100644
--- a/rpcs3/Emu/RSX/GL/GLVertexProgram.cpp
+++ b/rpcs3/Emu/RSX/GL/GLVertexProgram.cpp
@@ -3,72 +3,21 @@
#include "Emu/System.h"
#include "GLVertexProgram.h"
+#include "GLCommonDecompiler.h"
std::string GLVertexDecompilerThread::getFloatTypeName(size_t elementCount)
{
- switch (elementCount)
- {
- default:
- abort();
- case 1:
- return "float";
- case 2:
- return "vec2";
- case 3:
- return "vec3";
- case 4:
- return "vec4";
- }
+ return getFloatTypeNameImpl(elementCount);
}
std::string GLVertexDecompilerThread::getFunction(FUNCTION f)
{
- switch (f)
- {
- default:
- abort();
- case FUNCTION::FUNCTION_DP2:
- return "vec4(dot($0.xy, $1.xy))";
- case FUNCTION::FUNCTION_DP2A:
- return "";
- case FUNCTION::FUNCTION_DP3:
- return "vec4(dot($0.xyz, $1.xyz))";
- case FUNCTION::FUNCTION_DP4:
- return "vec4(dot($0, $1))";
- case FUNCTION::FUNCTION_DPH:
- return "vec4(dot(vec4($0.xyz, 1.0), $1))";
- case FUNCTION::FUNCTION_SFL:
- return "vec4(0., 0., 0., 0.)";
- case FUNCTION::FUNCTION_STR:
- return "vec4(1., 1., 1., 1.)";
- case FUNCTION::FUNCTION_FRACT:
- return "fract($0)";
- case FUNCTION::FUNCTION_TEXTURE_SAMPLE:
- return "texture($t, $0.xy)";
- case FUNCTION::FUNCTION_DFDX:
- return "dFdx($0)";
- case FUNCTION::FUNCTION_DFDY:
- return "dFdy($0)";
- }
+ return getFunctionImpl(f);
}
std::string GLVertexDecompilerThread::compareFunction(COMPARE f, const std::string &Op0, const std::string &Op1)
{
- switch (f)
- {
- case COMPARE::FUNCTION_SEQ:
- return "equal(" + Op0 + ", " + Op1 + ")";
- case COMPARE::FUNCTION_SGE:
- return "greaterThanEqual(" + Op0 + ", " + Op1 + ")";
- case COMPARE::FUNCTION_SGT:
- return "greaterThan(" + Op0 + ", " + Op1 + ")";
- case COMPARE::FUNCTION_SLE:
- return "lessThanEqual(" + Op0 + ", " + Op1 + ")";
- case COMPARE::FUNCTION_SLT:
- return "lessThan(" + Op0 + ", " + Op1 + ")";
- case COMPARE::FUNCTION_SNE:
- return "notEqual(" + Op0 + ", " + Op1 + ")";
- }
+ return compareFunctionImpl(f, Op0, Op1);
}
void GLVertexDecompilerThread::insertHeader(std::stringstream &OS)
diff --git a/rpcs3/emucore.vcxproj b/rpcs3/emucore.vcxproj
index 3086d22c45..70f6cb37cc 100644
--- a/rpcs3/emucore.vcxproj
+++ b/rpcs3/emucore.vcxproj
@@ -44,6 +44,7 @@
+
@@ -425,6 +426,7 @@
+
diff --git a/rpcs3/emucore.vcxproj.filters b/rpcs3/emucore.vcxproj.filters
index 678ef1cd18..9adbdd03c6 100644
--- a/rpcs3/emucore.vcxproj.filters
+++ b/rpcs3/emucore.vcxproj.filters
@@ -875,6 +875,9 @@
Emu\GPU\RSX\Common
+
+ Emu\GPU\RSX\GL
+
@@ -1570,5 +1573,8 @@
Emu\GPU\RSX\Common
+
+ Emu\GPU\RSX\GL
+
\ No newline at end of file