Moved wvp calculation to CPU.

This commit is contained in:
Rinnegatamante
2020-10-22 18:32:47 +02:00
parent 0b88723fe1
commit f0c66692f8
12 changed files with 31 additions and 49 deletions
+11 -11
View File
@@ -3,7 +3,9 @@
#include <string.h>
#include <assert.h>
#include <vitashark.h>
extern "C"{
#include <math_neon.h>
};
#include "../rwbase.h"
#include "../rwerror.h"
#include "../rwplg.h"
@@ -131,8 +133,7 @@ int32 u_fogData;
int32 u_fogColor;
// Scene
int32 u_proj;
int32 u_view;
int32 u_wvp;
// Object
int32 u_world;
@@ -929,14 +930,14 @@ flushCache(void)
uniformStateDirty[i] = true;
}*/
//if(sceneDirty){
glUniformMatrix4fv(U(u_proj), 1, 0, uniformScene.proj);
glUniformMatrix4fv(U(u_view), 1, 0, uniformScene.view);
// sceneDirty = 0;
//}
//if(objectDirty){
glUniformMatrix4fv(U(u_world), 1, 0, (float*)&uniformObject.world);
float wv[16], wvp[16];
matmul4_neon((float *)uniformScene.view, (float *)&uniformObject.world, (float *)wv);
matmul4_neon((float *)uniformScene.proj, (float *)wv, (float *)wvp);
glUniformMatrix4fv(U(u_wvp), 1, 0, (float*)wvp);
glUniform4fv(U(u_ambLight), 1, (float*)&uniformObject.ambLight);
glUniform4fv(U(u_lightParams), MAX_LIGHTS, (float*)uniformObject.lightParams);
//glUniform4fv(U(u_lightPosition), MAX_LIGHTS, (float*)uniformObject.lightPosition);
@@ -1414,8 +1415,7 @@ initOpenGL(void)
// u_fogRange = registerUniform("u_fogRange");
// u_fogDisable = registerUniform("u_fogDisable");
u_fogColor = registerUniform("u_fogColor");
u_proj = registerUniform("u_proj");
u_view = registerUniform("u_view");
u_wvp = registerUniform("u_wvp");
u_world = registerUniform("u_world");
u_ambLight = registerUniform("u_ambLight");
u_lightParams = registerUniform("u_lightParams");
+2 -4
View File
@@ -3,9 +3,8 @@ void main(
float3 in_normal,
float4 in_color,
float2 in_tex0,
uniform float4x4 u_proj,
uniform float4x4 u_wvp,
uniform float4x4 u_world,
uniform float4x4 u_view,
uniform float4 u_ambLight,
uniform float4 u_surfProps,
uniform float4 u_fogData,
@@ -18,8 +17,7 @@ void main(
float out v_fog : FOG,
float4 out gl_Position : POSITION
) {
float4 Vertex = mul(float4(in_pos, 1.0), u_world);
gl_Position = mul(mul(Vertex, u_view), u_proj);
gl_Position = mul(float4(in_pos, 1.0), u_wvp);
float3 Normal = mul(in_normal, float3x3(u_world));
v_tex0 = in_tex0;
+2 -4
View File
@@ -4,9 +4,8 @@ const char *default_vert_src =
" float3 in_normal,\n"
" float4 in_color,\n"
" float2 in_tex0,\n"
" uniform float4x4 u_proj,\n"
" uniform float4x4 u_wvp,\n"
" uniform float4x4 u_world,\n"
" uniform float4x4 u_view,\n"
" uniform float4 u_ambLight,\n"
" uniform float4 u_surfProps,\n"
" uniform float4 u_fogData,\n"
@@ -19,8 +18,7 @@ const char *default_vert_src =
" float out v_fog : FOG,\n"
" float4 out gl_Position : POSITION\n"
") {\n"
" float4 Vertex = mul(float4(in_pos, 1.0), u_world);\n"
" gl_Position = mul(mul(Vertex, u_view), u_proj);\n"
" gl_Position = mul(float4(in_pos, 1.0), u_wvp);\n"
" float3 Normal = mul(in_normal, float3x3(u_world));\n"
" v_tex0 = in_tex0;\n"
+2 -5
View File
@@ -3,17 +3,14 @@ void main(
float4 in_color,
float2 in_tex0,
uniform float4 u_fogData,
uniform float4x4 u_proj,
uniform float4x4 u_wvp,
uniform float4x4 u_world,
uniform float4x4 u_view,
float4 out v_color : COLOR0,
float2 out v_tex0 : TEXCOORD0,
float out v_fog : FOG,
float4 out gl_Position : POSITION
) {
float4 Vertex = mul(float4(in_pos, 1.0), u_world);
float4 CamVertex = mul(Vertex, u_view);
gl_Position = mul(CamVertex, u_proj);
gl_Position = mul(float4(in_pos, 1.0), u_wvp);
v_color = in_color;
v_tex0 = in_tex0;
v_fog = DoFog(gl_Position.w, u_fogData);
+2 -5
View File
@@ -4,17 +4,14 @@ const char *im3d_vert_src =
" float4 in_color,\n"
" float2 in_tex0,\n"
" uniform float4 u_fogData,\n"
" uniform float4x4 u_proj,\n"
" uniform float4x4 u_wvp,\n"
" uniform float4x4 u_world,\n"
" uniform float4x4 u_view,\n"
" float4 out v_color : COLOR0,\n"
" float2 out v_tex0 : TEXCOORD0,\n"
" float out v_fog : FOG,\n"
" float4 out gl_Position : POSITION\n"
") {\n"
" float4 Vertex = mul(float4(in_pos, 1.0), u_world);\n"
" float4 CamVertex = mul(Vertex, u_view);\n"
" gl_Position = mul(CamVertex, u_proj);\n"
" gl_Position = mul(float4(in_pos, 1.0), u_wvp);\n"
" v_color = in_color;\n"
" v_tex0 = in_tex0;\n"
" v_fog = DoFog(gl_Position.w, u_fogData);\n"
+1 -1
View File
@@ -2,7 +2,7 @@
#define disableFBA (u_fxparams.y)
float4 main(
float4 v_color : COLOR,
float4 v_color : COLOR0,
float2 v_tex0 : TEXCOORD0,
float2 v_tex1 : TEXCOORD1,
float v_fog : FOG,
+2 -4
View File
@@ -3,9 +3,8 @@ void main(
float3 in_normal,
float4 in_color,
float2 in_tex0,
uniform float4x4 u_proj,
uniform float4x4 u_wvp,
uniform float4x4 u_world,
uniform float4x4 u_view,
uniform float4x4 u_texMatrix,
uniform float4 u_ambLight,
uniform float4 u_surfProps,
@@ -20,8 +19,7 @@ void main(
float out v_fog : FOG,
float4 out gl_Position : POSITION
) {
float4 Vertex = mul(float4(in_pos, 1.0), u_world);
gl_Position = mul(mul(Vertex, u_view), u_proj);
gl_Position = mul(float4(in_pos, 1.0), u_wvp);
float3 Normal = mul(in_normal, float3x3(u_world));
v_tex0 = in_tex0;
+3 -5
View File
@@ -4,9 +4,8 @@ const char *matfx_env_vert_src =
" float3 in_normal,\n"
" float4 in_color,\n"
" float2 in_tex0,\n"
" uniform float4x4 u_proj,\n"
" uniform float4x4 u_wvp,\n"
" uniform float4x4 u_world,\n"
" uniform float4x4 u_view,\n"
" uniform float4x4 u_texMatrix,\n"
" uniform float4 u_ambLight,\n"
" uniform float4 u_surfProps,\n"
@@ -21,8 +20,7 @@ const char *matfx_env_vert_src =
" float out v_fog : FOG,\n"
" float4 out gl_Position : POSITION\n"
") {\n"
" float4 Vertex = mul(float4(in_pos, 1.0), u_world);\n"
" gl_Position = mul(mul(Vertex, u_view), u_proj);\n"
" gl_Position = mul(float4(in_pos, 1.0), u_wvp);\n"
" float3 Normal = mul(in_normal, float3x3(u_world));\n"
" v_tex0 = in_tex0;\n"
@@ -54,7 +52,7 @@ const char *matfx_env_frag_src =
"#define disableFBA (u_fxparams.y)\n"
"float4 main(\n"
" float4 v_color : COLOR,\n"
" float4 v_color : COLOR0,\n"
" float2 v_tex0 : TEXCOORD0,\n"
" float2 v_tex1 : TEXCOORD1,\n"
" float v_fog : FOG,\n"
+1 -1
View File
@@ -1,5 +1,5 @@
float4 main(
float4 v_color : COLOR,
float4 v_color : COLOR0,
float2 v_tex0 : TEXCOORD0,
float v_fog : FOG,
uniform float4 u_fogColor,
+1 -1
View File
@@ -1,6 +1,6 @@
const char *simple_frag_src =
"float4 main(\n"
" float4 v_color : COLOR,\n"
" float4 v_color : COLOR0,\n"
" float2 v_tex0 : TEXCOORD0,\n"
" float v_fog : FOG,\n"
" uniform float4 u_fogColor,\n"
+2 -4
View File
@@ -5,9 +5,8 @@ void main(
float2 in_tex0,
float4 in_weights,
float4 in_indices,
uniform float4x4 u_proj,
uniform float4x4 u_wvp,
uniform float4x4 u_world,
uniform float4x4 u_view,
uniform float4 u_ambLight,
uniform float4 u_surfProps,
uniform float4 u_fogData,
@@ -28,8 +27,7 @@ void main(
SkinNormal += mul(in_normal, float3x3(u_boneMatrices[int(in_indices[i])])) * in_weights[i];
}
float4 Vertex = mul(float4(SkinVertex, 1.0), u_world);
gl_Position = mul(mul(Vertex, u_view), u_proj);
gl_Position = mul(float4(SkinVertex, 1.0), u_wvp);
float3 Normal = mul(SkinNormal, float3x3(u_world));
v_tex0 = in_tex0;
+2 -4
View File
@@ -6,9 +6,8 @@ const char *skin_vert_src =
" float2 in_tex0,\n"
" float4 in_weights,\n"
" float4 in_indices,\n"
" uniform float4x4 u_proj,\n"
" uniform float4x4 u_wvp,\n"
" uniform float4x4 u_world,\n"
" uniform float4x4 u_view,\n"
" uniform float4 u_ambLight,\n"
" uniform float4 u_surfProps,\n"
" uniform float4 u_fogData,\n"
@@ -29,8 +28,7 @@ const char *skin_vert_src =
" SkinNormal += mul(in_normal, float3x3(u_boneMatrices[int(in_indices[i])])) * in_weights[i];\n"
" }\n"
" \n"
" float4 Vertex = mul(float4(SkinVertex, 1.0), u_world);\n"
" gl_Position = mul(mul(Vertex, u_view), u_proj);\n"
" gl_Position = mul(float4(SkinVertex, 1.0), u_wvp);\n"
" float3 Normal = mul(SkinNormal, float3x3(u_world));\n"
" v_tex0 = in_tex0;\n"