summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon
diff options
context:
space:
mode:
authordegasus <wickmarkus@web.de>2013-01-14 22:59:08 +0100
committerdegasus <wickmarkus@web.de>2013-01-14 22:59:08 +0100
commitff889c0e651e2685d60eb201620de05d3650274a (patch)
tree4a1cc7861624ae469906368880b97161a25790b1 /Source/Core/VideoCommon
parent2f78986e2cc28c7093bb9b7a784d1b3c0ce2e682 (diff)
use attrib pointers in nativeVertexFormat
Diffstat (limited to 'Source/Core/VideoCommon')
-rw-r--r--Source/Core/VideoCommon/Src/VertexShaderGen.cpp14
-rw-r--r--Source/Core/VideoCommon/Src/VertexShaderGen.h21
2 files changed, 23 insertions, 12 deletions
diff --git a/Source/Core/VideoCommon/Src/VertexShaderGen.cpp b/Source/Core/VideoCommon/Src/VertexShaderGen.cpp
index 9c4d717c84..260d2de5e5 100644
--- a/Source/Core/VideoCommon/Src/VertexShaderGen.cpp
+++ b/Source/Core/VideoCommon/Src/VertexShaderGen.cpp
@@ -229,24 +229,25 @@ const char *GenerateVertexShaderCode(u32 components, API_TYPE ApiType)
if(ApiType == API_OPENGL)
{
- if (components & VB_HAS_NRM0)
- WRITE(p, " float3 rawnorm0 = gl_Normal; // NORMAL0,\n");
-
+ WRITE(p, "ATTRIN float4 rawpos; // ATTR%d,\n", SHADER_POSITION_ATTRIB);
if (components & VB_HAS_POSMTXIDX)
WRITE(p, "ATTRIN float fposmtx; // ATTR%d,\n", SHADER_POSMTX_ATTRIB);
+ if (components & VB_HAS_NRM0)
+ WRITE(p, "ATTRIN float3 rawnorm0; // ATTR%d,\n", SHADER_NORM0_ATTRIB);
if (components & VB_HAS_NRM1)
WRITE(p, "ATTRIN float3 rawnorm1; // ATTR%d,\n", SHADER_NORM1_ATTRIB);
if (components & VB_HAS_NRM2)
WRITE(p, "ATTRIN float3 rawnorm2; // ATTR%d,\n", SHADER_NORM2_ATTRIB);
if (components & VB_HAS_COL0)
- WRITE(p, " float4 color0 = gl_Color; // COLOR0,\n");
+ WRITE(p, "ATTRIN float4 color0; // ATTR%d,\n", SHADER_COLOR0_ATTRIB);
if (components & VB_HAS_COL1)
- WRITE(p, " float4 color1 = gl_SecondaryColor; // COLOR1,\n");
+ WRITE(p, "ATTRIN float4 color1; // ATTR%d,\n", SHADER_COLOR1_ATTRIB);
+
for (int i = 0; i < 8; ++i) {
u32 hastexmtx = (components & (VB_HAS_TEXMTXIDX0<<i));
if ((components & (VB_HAS_UV0<<i)) || hastexmtx)
- WRITE(p, " float%d tex%d = gl_MultiTexCoord%d.xy%s; // TEXCOORD%d,\n", hastexmtx ? 3 : 2, i, i, hastexmtx ? "z" : "", i);
+ WRITE(p, "ATTRIN float%d tex%d; // ATTR%d,\n", hastexmtx ? 3 : 2, i, SHADER_TEXTURE0_ATTRIB + i);
}
// Let's set up attributes
@@ -272,7 +273,6 @@ const char *GenerateVertexShaderCode(u32 components, API_TYPE ApiType)
WRITE(p, "VARYOUT float%d uv%d_2;\n", i < 4 ? 4 : 3 , i);
}
}
- WRITE(p, " float4 rawpos = gl_Vertex;\n");
WRITE(p, "VARYOUT float4 colors_02;\n");
WRITE(p, "VARYOUT float4 colors_12;\n");
diff --git a/Source/Core/VideoCommon/Src/VertexShaderGen.h b/Source/Core/VideoCommon/Src/VertexShaderGen.h
index 335b54d786..d50042a904 100644
--- a/Source/Core/VideoCommon/Src/VertexShaderGen.h
+++ b/Source/Core/VideoCommon/Src/VertexShaderGen.h
@@ -22,12 +22,23 @@
#include "VideoCommon.h"
// TODO should be reordered
+#define SHADER_POSITION_ATTRIB 0
#define SHADER_POSMTX_ATTRIB 1
-#define SHADER_POSITION_ATTRIB 2
-#define SHADER_TEXTURE0_ATTRIB 3
-#define SHADER_COLOR0_ATTRIB 4
-#define SHADER_NORM1_ATTRIB 6
-#define SHADER_NORM2_ATTRIB 7
+#define SHADER_NORM0_ATTRIB 2
+#define SHADER_NORM1_ATTRIB 3
+#define SHADER_NORM2_ATTRIB 4
+#define SHADER_COLOR0_ATTRIB 5
+#define SHADER_COLOR1_ATTRIB 6
+
+#define SHADER_TEXTURE0_ATTRIB 8
+#define SHADER_TEXTURE1_ATTRIB 9
+#define SHADER_TEXTURE2_ATTRIB 10
+#define SHADER_TEXTURE3_ATTRIB 11
+#define SHADER_TEXTURE4_ATTRIB 12
+#define SHADER_TEXTURE5_ATTRIB 13
+#define SHADER_TEXTURE6_ATTRIB 14
+#define SHADER_TEXTURE7_ATTRIB 15
+
// shader variables