Moved wvp calculation to CPU.
This commit is contained in:
+11
-11
@@ -3,7 +3,9 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <vitashark.h>
|
#include <vitashark.h>
|
||||||
|
extern "C"{
|
||||||
|
#include <math_neon.h>
|
||||||
|
};
|
||||||
#include "../rwbase.h"
|
#include "../rwbase.h"
|
||||||
#include "../rwerror.h"
|
#include "../rwerror.h"
|
||||||
#include "../rwplg.h"
|
#include "../rwplg.h"
|
||||||
@@ -131,8 +133,7 @@ int32 u_fogData;
|
|||||||
int32 u_fogColor;
|
int32 u_fogColor;
|
||||||
|
|
||||||
// Scene
|
// Scene
|
||||||
int32 u_proj;
|
int32 u_wvp;
|
||||||
int32 u_view;
|
|
||||||
|
|
||||||
// Object
|
// Object
|
||||||
int32 u_world;
|
int32 u_world;
|
||||||
@@ -929,14 +930,14 @@ flushCache(void)
|
|||||||
uniformStateDirty[i] = true;
|
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){
|
//if(objectDirty){
|
||||||
glUniformMatrix4fv(U(u_world), 1, 0, (float*)&uniformObject.world);
|
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_ambLight), 1, (float*)&uniformObject.ambLight);
|
||||||
glUniform4fv(U(u_lightParams), MAX_LIGHTS, (float*)uniformObject.lightParams);
|
glUniform4fv(U(u_lightParams), MAX_LIGHTS, (float*)uniformObject.lightParams);
|
||||||
//glUniform4fv(U(u_lightPosition), MAX_LIGHTS, (float*)uniformObject.lightPosition);
|
//glUniform4fv(U(u_lightPosition), MAX_LIGHTS, (float*)uniformObject.lightPosition);
|
||||||
@@ -1414,8 +1415,7 @@ initOpenGL(void)
|
|||||||
// u_fogRange = registerUniform("u_fogRange");
|
// u_fogRange = registerUniform("u_fogRange");
|
||||||
// u_fogDisable = registerUniform("u_fogDisable");
|
// u_fogDisable = registerUniform("u_fogDisable");
|
||||||
u_fogColor = registerUniform("u_fogColor");
|
u_fogColor = registerUniform("u_fogColor");
|
||||||
u_proj = registerUniform("u_proj");
|
u_wvp = registerUniform("u_wvp");
|
||||||
u_view = registerUniform("u_view");
|
|
||||||
u_world = registerUniform("u_world");
|
u_world = registerUniform("u_world");
|
||||||
u_ambLight = registerUniform("u_ambLight");
|
u_ambLight = registerUniform("u_ambLight");
|
||||||
u_lightParams = registerUniform("u_lightParams");
|
u_lightParams = registerUniform("u_lightParams");
|
||||||
|
|||||||
@@ -3,9 +3,8 @@ void main(
|
|||||||
float3 in_normal,
|
float3 in_normal,
|
||||||
float4 in_color,
|
float4 in_color,
|
||||||
float2 in_tex0,
|
float2 in_tex0,
|
||||||
uniform float4x4 u_proj,
|
uniform float4x4 u_wvp,
|
||||||
uniform float4x4 u_world,
|
uniform float4x4 u_world,
|
||||||
uniform float4x4 u_view,
|
|
||||||
uniform float4 u_ambLight,
|
uniform float4 u_ambLight,
|
||||||
uniform float4 u_surfProps,
|
uniform float4 u_surfProps,
|
||||||
uniform float4 u_fogData,
|
uniform float4 u_fogData,
|
||||||
@@ -18,8 +17,7 @@ void main(
|
|||||||
float out v_fog : FOG,
|
float out v_fog : FOG,
|
||||||
float4 out gl_Position : POSITION
|
float4 out gl_Position : POSITION
|
||||||
) {
|
) {
|
||||||
float4 Vertex = mul(float4(in_pos, 1.0), u_world);
|
gl_Position = mul(float4(in_pos, 1.0), u_wvp);
|
||||||
gl_Position = mul(mul(Vertex, u_view), u_proj);
|
|
||||||
float3 Normal = mul(in_normal, float3x3(u_world));
|
float3 Normal = mul(in_normal, float3x3(u_world));
|
||||||
|
|
||||||
v_tex0 = in_tex0;
|
v_tex0 = in_tex0;
|
||||||
|
|||||||
@@ -4,9 +4,8 @@ const char *default_vert_src =
|
|||||||
" float3 in_normal,\n"
|
" float3 in_normal,\n"
|
||||||
" float4 in_color,\n"
|
" float4 in_color,\n"
|
||||||
" float2 in_tex0,\n"
|
" float2 in_tex0,\n"
|
||||||
" uniform float4x4 u_proj,\n"
|
" uniform float4x4 u_wvp,\n"
|
||||||
" uniform float4x4 u_world,\n"
|
" uniform float4x4 u_world,\n"
|
||||||
" uniform float4x4 u_view,\n"
|
|
||||||
" uniform float4 u_ambLight,\n"
|
" uniform float4 u_ambLight,\n"
|
||||||
" uniform float4 u_surfProps,\n"
|
" uniform float4 u_surfProps,\n"
|
||||||
" uniform float4 u_fogData,\n"
|
" uniform float4 u_fogData,\n"
|
||||||
@@ -19,8 +18,7 @@ const char *default_vert_src =
|
|||||||
" float out v_fog : FOG,\n"
|
" float out v_fog : FOG,\n"
|
||||||
" float4 out gl_Position : POSITION\n"
|
" float4 out gl_Position : POSITION\n"
|
||||||
") {\n"
|
") {\n"
|
||||||
" float4 Vertex = mul(float4(in_pos, 1.0), u_world);\n"
|
" gl_Position = mul(float4(in_pos, 1.0), u_wvp);\n"
|
||||||
" gl_Position = mul(mul(Vertex, u_view), u_proj);\n"
|
|
||||||
" float3 Normal = mul(in_normal, float3x3(u_world));\n"
|
" float3 Normal = mul(in_normal, float3x3(u_world));\n"
|
||||||
|
|
||||||
" v_tex0 = in_tex0;\n"
|
" v_tex0 = in_tex0;\n"
|
||||||
|
|||||||
@@ -3,17 +3,14 @@ void main(
|
|||||||
float4 in_color,
|
float4 in_color,
|
||||||
float2 in_tex0,
|
float2 in_tex0,
|
||||||
uniform float4 u_fogData,
|
uniform float4 u_fogData,
|
||||||
uniform float4x4 u_proj,
|
uniform float4x4 u_wvp,
|
||||||
uniform float4x4 u_world,
|
uniform float4x4 u_world,
|
||||||
uniform float4x4 u_view,
|
|
||||||
float4 out v_color : COLOR0,
|
float4 out v_color : COLOR0,
|
||||||
float2 out v_tex0 : TEXCOORD0,
|
float2 out v_tex0 : TEXCOORD0,
|
||||||
float out v_fog : FOG,
|
float out v_fog : FOG,
|
||||||
float4 out gl_Position : POSITION
|
float4 out gl_Position : POSITION
|
||||||
) {
|
) {
|
||||||
float4 Vertex = mul(float4(in_pos, 1.0), u_world);
|
gl_Position = mul(float4(in_pos, 1.0), u_wvp);
|
||||||
float4 CamVertex = mul(Vertex, u_view);
|
|
||||||
gl_Position = mul(CamVertex, u_proj);
|
|
||||||
v_color = in_color;
|
v_color = in_color;
|
||||||
v_tex0 = in_tex0;
|
v_tex0 = in_tex0;
|
||||||
v_fog = DoFog(gl_Position.w, u_fogData);
|
v_fog = DoFog(gl_Position.w, u_fogData);
|
||||||
|
|||||||
@@ -4,17 +4,14 @@ const char *im3d_vert_src =
|
|||||||
" float4 in_color,\n"
|
" float4 in_color,\n"
|
||||||
" float2 in_tex0,\n"
|
" float2 in_tex0,\n"
|
||||||
" uniform float4 u_fogData,\n"
|
" uniform float4 u_fogData,\n"
|
||||||
" uniform float4x4 u_proj,\n"
|
" uniform float4x4 u_wvp,\n"
|
||||||
" uniform float4x4 u_world,\n"
|
" uniform float4x4 u_world,\n"
|
||||||
" uniform float4x4 u_view,\n"
|
|
||||||
" float4 out v_color : COLOR0,\n"
|
" float4 out v_color : COLOR0,\n"
|
||||||
" float2 out v_tex0 : TEXCOORD0,\n"
|
" float2 out v_tex0 : TEXCOORD0,\n"
|
||||||
" float out v_fog : FOG,\n"
|
" float out v_fog : FOG,\n"
|
||||||
" float4 out gl_Position : POSITION\n"
|
" float4 out gl_Position : POSITION\n"
|
||||||
") {\n"
|
") {\n"
|
||||||
" float4 Vertex = mul(float4(in_pos, 1.0), u_world);\n"
|
" gl_Position = mul(float4(in_pos, 1.0), u_wvp);\n"
|
||||||
" float4 CamVertex = mul(Vertex, u_view);\n"
|
|
||||||
" gl_Position = mul(CamVertex, u_proj);\n"
|
|
||||||
" v_color = in_color;\n"
|
" v_color = in_color;\n"
|
||||||
" v_tex0 = in_tex0;\n"
|
" v_tex0 = in_tex0;\n"
|
||||||
" v_fog = DoFog(gl_Position.w, u_fogData);\n"
|
" v_fog = DoFog(gl_Position.w, u_fogData);\n"
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
#define disableFBA (u_fxparams.y)
|
#define disableFBA (u_fxparams.y)
|
||||||
|
|
||||||
float4 main(
|
float4 main(
|
||||||
float4 v_color : COLOR,
|
float4 v_color : COLOR0,
|
||||||
float2 v_tex0 : TEXCOORD0,
|
float2 v_tex0 : TEXCOORD0,
|
||||||
float2 v_tex1 : TEXCOORD1,
|
float2 v_tex1 : TEXCOORD1,
|
||||||
float v_fog : FOG,
|
float v_fog : FOG,
|
||||||
|
|||||||
@@ -3,9 +3,8 @@ void main(
|
|||||||
float3 in_normal,
|
float3 in_normal,
|
||||||
float4 in_color,
|
float4 in_color,
|
||||||
float2 in_tex0,
|
float2 in_tex0,
|
||||||
uniform float4x4 u_proj,
|
uniform float4x4 u_wvp,
|
||||||
uniform float4x4 u_world,
|
uniform float4x4 u_world,
|
||||||
uniform float4x4 u_view,
|
|
||||||
uniform float4x4 u_texMatrix,
|
uniform float4x4 u_texMatrix,
|
||||||
uniform float4 u_ambLight,
|
uniform float4 u_ambLight,
|
||||||
uniform float4 u_surfProps,
|
uniform float4 u_surfProps,
|
||||||
@@ -20,8 +19,7 @@ void main(
|
|||||||
float out v_fog : FOG,
|
float out v_fog : FOG,
|
||||||
float4 out gl_Position : POSITION
|
float4 out gl_Position : POSITION
|
||||||
) {
|
) {
|
||||||
float4 Vertex = mul(float4(in_pos, 1.0), u_world);
|
gl_Position = mul(float4(in_pos, 1.0), u_wvp);
|
||||||
gl_Position = mul(mul(Vertex, u_view), u_proj);
|
|
||||||
float3 Normal = mul(in_normal, float3x3(u_world));
|
float3 Normal = mul(in_normal, float3x3(u_world));
|
||||||
|
|
||||||
v_tex0 = in_tex0;
|
v_tex0 = in_tex0;
|
||||||
|
|||||||
@@ -4,9 +4,8 @@ const char *matfx_env_vert_src =
|
|||||||
" float3 in_normal,\n"
|
" float3 in_normal,\n"
|
||||||
" float4 in_color,\n"
|
" float4 in_color,\n"
|
||||||
" float2 in_tex0,\n"
|
" float2 in_tex0,\n"
|
||||||
" uniform float4x4 u_proj,\n"
|
" uniform float4x4 u_wvp,\n"
|
||||||
" uniform float4x4 u_world,\n"
|
" uniform float4x4 u_world,\n"
|
||||||
" uniform float4x4 u_view,\n"
|
|
||||||
" uniform float4x4 u_texMatrix,\n"
|
" uniform float4x4 u_texMatrix,\n"
|
||||||
" uniform float4 u_ambLight,\n"
|
" uniform float4 u_ambLight,\n"
|
||||||
" uniform float4 u_surfProps,\n"
|
" uniform float4 u_surfProps,\n"
|
||||||
@@ -21,8 +20,7 @@ const char *matfx_env_vert_src =
|
|||||||
" float out v_fog : FOG,\n"
|
" float out v_fog : FOG,\n"
|
||||||
" float4 out gl_Position : POSITION\n"
|
" float4 out gl_Position : POSITION\n"
|
||||||
") {\n"
|
") {\n"
|
||||||
" float4 Vertex = mul(float4(in_pos, 1.0), u_world);\n"
|
" gl_Position = mul(float4(in_pos, 1.0), u_wvp);\n"
|
||||||
" gl_Position = mul(mul(Vertex, u_view), u_proj);\n"
|
|
||||||
" float3 Normal = mul(in_normal, float3x3(u_world));\n"
|
" float3 Normal = mul(in_normal, float3x3(u_world));\n"
|
||||||
|
|
||||||
" v_tex0 = in_tex0;\n"
|
" v_tex0 = in_tex0;\n"
|
||||||
@@ -54,7 +52,7 @@ const char *matfx_env_frag_src =
|
|||||||
"#define disableFBA (u_fxparams.y)\n"
|
"#define disableFBA (u_fxparams.y)\n"
|
||||||
|
|
||||||
"float4 main(\n"
|
"float4 main(\n"
|
||||||
" float4 v_color : COLOR,\n"
|
" float4 v_color : COLOR0,\n"
|
||||||
" float2 v_tex0 : TEXCOORD0,\n"
|
" float2 v_tex0 : TEXCOORD0,\n"
|
||||||
" float2 v_tex1 : TEXCOORD1,\n"
|
" float2 v_tex1 : TEXCOORD1,\n"
|
||||||
" float v_fog : FOG,\n"
|
" float v_fog : FOG,\n"
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
float4 main(
|
float4 main(
|
||||||
float4 v_color : COLOR,
|
float4 v_color : COLOR0,
|
||||||
float2 v_tex0 : TEXCOORD0,
|
float2 v_tex0 : TEXCOORD0,
|
||||||
float v_fog : FOG,
|
float v_fog : FOG,
|
||||||
uniform float4 u_fogColor,
|
uniform float4 u_fogColor,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
const char *simple_frag_src =
|
const char *simple_frag_src =
|
||||||
"float4 main(\n"
|
"float4 main(\n"
|
||||||
" float4 v_color : COLOR,\n"
|
" float4 v_color : COLOR0,\n"
|
||||||
" float2 v_tex0 : TEXCOORD0,\n"
|
" float2 v_tex0 : TEXCOORD0,\n"
|
||||||
" float v_fog : FOG,\n"
|
" float v_fog : FOG,\n"
|
||||||
" uniform float4 u_fogColor,\n"
|
" uniform float4 u_fogColor,\n"
|
||||||
|
|||||||
@@ -5,9 +5,8 @@ void main(
|
|||||||
float2 in_tex0,
|
float2 in_tex0,
|
||||||
float4 in_weights,
|
float4 in_weights,
|
||||||
float4 in_indices,
|
float4 in_indices,
|
||||||
uniform float4x4 u_proj,
|
uniform float4x4 u_wvp,
|
||||||
uniform float4x4 u_world,
|
uniform float4x4 u_world,
|
||||||
uniform float4x4 u_view,
|
|
||||||
uniform float4 u_ambLight,
|
uniform float4 u_ambLight,
|
||||||
uniform float4 u_surfProps,
|
uniform float4 u_surfProps,
|
||||||
uniform float4 u_fogData,
|
uniform float4 u_fogData,
|
||||||
@@ -28,8 +27,7 @@ void main(
|
|||||||
SkinNormal += mul(in_normal, float3x3(u_boneMatrices[int(in_indices[i])])) * in_weights[i];
|
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(float4(SkinVertex, 1.0), u_wvp);
|
||||||
gl_Position = mul(mul(Vertex, u_view), u_proj);
|
|
||||||
float3 Normal = mul(SkinNormal, float3x3(u_world));
|
float3 Normal = mul(SkinNormal, float3x3(u_world));
|
||||||
|
|
||||||
v_tex0 = in_tex0;
|
v_tex0 = in_tex0;
|
||||||
|
|||||||
@@ -6,9 +6,8 @@ const char *skin_vert_src =
|
|||||||
" float2 in_tex0,\n"
|
" float2 in_tex0,\n"
|
||||||
" float4 in_weights,\n"
|
" float4 in_weights,\n"
|
||||||
" float4 in_indices,\n"
|
" float4 in_indices,\n"
|
||||||
" uniform float4x4 u_proj,\n"
|
" uniform float4x4 u_wvp,\n"
|
||||||
" uniform float4x4 u_world,\n"
|
" uniform float4x4 u_world,\n"
|
||||||
" uniform float4x4 u_view,\n"
|
|
||||||
" uniform float4 u_ambLight,\n"
|
" uniform float4 u_ambLight,\n"
|
||||||
" uniform float4 u_surfProps,\n"
|
" uniform float4 u_surfProps,\n"
|
||||||
" uniform float4 u_fogData,\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"
|
" SkinNormal += mul(in_normal, float3x3(u_boneMatrices[int(in_indices[i])])) * in_weights[i];\n"
|
||||||
" }\n"
|
" }\n"
|
||||||
" \n"
|
" \n"
|
||||||
" float4 Vertex = mul(float4(SkinVertex, 1.0), u_world);\n"
|
" gl_Position = mul(float4(SkinVertex, 1.0), u_wvp);\n"
|
||||||
" gl_Position = mul(mul(Vertex, u_view), u_proj);\n"
|
|
||||||
" float3 Normal = mul(SkinNormal, float3x3(u_world));\n"
|
" float3 Normal = mul(SkinNormal, float3x3(u_world));\n"
|
||||||
|
|
||||||
" v_tex0 = in_tex0;\n"
|
" v_tex0 = in_tex0;\n"
|
||||||
|
|||||||
Reference in New Issue
Block a user