Using a separate mempool for Immediate 3D.
This commit is contained in:
+26
-10
@@ -20,11 +20,17 @@
|
|||||||
extern uint16_t *gIndices;
|
extern uint16_t *gIndices;
|
||||||
extern float *gVertexBuffer;
|
extern float *gVertexBuffer;
|
||||||
extern uint16_t *gIndicesPtr;
|
extern uint16_t *gIndicesPtr;
|
||||||
|
uint16_t *gIndicesIm2DPtr;
|
||||||
|
uint16_t *gIndicesIm3DPtr;
|
||||||
extern float *gVertexBufferPtr;
|
extern float *gVertexBufferPtr;
|
||||||
|
float *gVertexBufferIm2DPtr;
|
||||||
|
float *gVertexBufferIm3DPtr;
|
||||||
|
|
||||||
uint16_t *gConstIndices;
|
uint16_t *gConstIndices;
|
||||||
float *gVertexBufferIm2D;
|
float *gVertexBufferIm2D;
|
||||||
|
float *gVertexBufferIm3D;
|
||||||
uint16_t *gIndicesIm2D;
|
uint16_t *gIndicesIm2D;
|
||||||
|
uint16_t *gIndicesIm3D;
|
||||||
|
|
||||||
namespace rw {
|
namespace rw {
|
||||||
namespace gl3 {
|
namespace gl3 {
|
||||||
@@ -1156,10 +1162,12 @@ showRaster(Raster *raster, uint32 flags)
|
|||||||
vglWaitVblankStart(GL_FALSE);
|
vglWaitVblankStart(GL_FALSE);
|
||||||
vglStopRendering();
|
vglStopRendering();
|
||||||
vglStartRendering();
|
vglStartRendering();
|
||||||
gVertexBuffer = gVertexBufferPtr;
|
gVertexBuffer = gVertexBufferPtr;
|
||||||
gVertexBufferIm2D = gVertexBufferPtr + 0xC00000;
|
gVertexBufferIm2D = gVertexBufferIm2DPtr;
|
||||||
gIndices = gIndicesPtr;
|
gVertexBufferIm3D = gVertexBufferIm3DPtr;
|
||||||
gIndicesIm2D = gIndicesPtr + 0x300000;
|
gIndices = gIndicesPtr;
|
||||||
|
gIndicesIm2D = gIndicesIm2DPtr;
|
||||||
|
gIndicesIm3D = gIndicesIm3DPtr;
|
||||||
#endif
|
#endif
|
||||||
//log2file("showRaster called");
|
//log2file("showRaster called");
|
||||||
|
|
||||||
@@ -1409,13 +1417,21 @@ initOpenGL(void)
|
|||||||
|
|
||||||
resetRenderState();
|
resetRenderState();
|
||||||
|
|
||||||
gVertexBufferPtr = (float*)malloc(0x1800000);
|
gVertexBufferPtr = (float*)malloc(0x1800000);
|
||||||
gIndicesPtr = (uint16_t*)malloc(0x600000);
|
gVertexBufferIm2DPtr = (float*)malloc(0x500000);
|
||||||
|
gVertexBufferIm3DPtr = (float*)malloc(0x500000);
|
||||||
|
gIndicesPtr = (uint16_t*)malloc(0x600000);
|
||||||
|
gIndicesIm2DPtr = (uint16_t*)malloc(0x600000);
|
||||||
|
gIndicesIm3DPtr = (uint16_t*)malloc(0x600000);
|
||||||
|
|
||||||
gConstIndices = (uint16_t*)malloc(sizeof(uint16_t) * 512);
|
gConstIndices = (uint16_t*)malloc(sizeof(uint16_t) * 512);
|
||||||
gVertexBuffer = gVertexBufferPtr;
|
|
||||||
gVertexBufferIm2D = gVertexBufferPtr + 0xC00000;
|
gVertexBuffer = gVertexBufferPtr;
|
||||||
gIndices = gIndicesPtr;
|
gVertexBufferIm2D = gVertexBufferIm2DPtr;
|
||||||
gIndicesIm2D = gIndicesPtr + 0x300000;
|
gVertexBufferIm3D = gVertexBufferIm3DPtr;
|
||||||
|
gIndices = gIndicesPtr;
|
||||||
|
gIndicesIm2D = gIndicesIm2DPtr;
|
||||||
|
gIndicesIm3D = gIndicesIm3DPtr;
|
||||||
|
|
||||||
for (uint16_t i = 0; i < 512; i++) {
|
for (uint16_t i = 0; i < 512; i++) {
|
||||||
gConstIndices[i] = i;
|
gConstIndices[i] = i;
|
||||||
|
|||||||
+8
-6
@@ -18,6 +18,8 @@
|
|||||||
extern float *gVertexBuffer;
|
extern float *gVertexBuffer;
|
||||||
extern float *gVertexBufferIm2D;
|
extern float *gVertexBufferIm2D;
|
||||||
extern uint16_t *gIndicesIm2D;
|
extern uint16_t *gIndicesIm2D;
|
||||||
|
extern float *gVertexBufferIm3D;
|
||||||
|
extern uint16_t *gIndicesIm3D;
|
||||||
extern uint16_t *gIndices;
|
extern uint16_t *gIndices;
|
||||||
extern uint16_t *gConstIndices;
|
extern uint16_t *gConstIndices;
|
||||||
|
|
||||||
@@ -215,9 +217,9 @@ im3DTransform(void *vertices, int32 numVertices, Matrix *world, uint32 flags)
|
|||||||
if((flags & im3d::VERTEXUV) == 0)
|
if((flags & im3d::VERTEXUV) == 0)
|
||||||
SetRenderStatePtr(TEXTURERASTER, nil);
|
SetRenderStatePtr(TEXTURERASTER, nil);
|
||||||
|
|
||||||
memcpy_neon(gVertexBufferIm2D, vertices, numVertices*sizeof(Im3DVertex));
|
memcpy_neon(gVertexBufferIm3D, vertices, numVertices*sizeof(Im3DVertex));
|
||||||
vglVertexAttribPointerMapped(0, gVertexBufferIm2D);
|
vglVertexAttribPointerMapped(0, gVertexBufferIm3D);
|
||||||
gVertexBufferIm2D += numVertices*(sizeof(Im3DVertex)/sizeof(float));
|
gVertexBufferIm3D += numVertices*(sizeof(Im3DVertex)/sizeof(float));
|
||||||
|
|
||||||
#ifndef RW_GL_USE_VAOS
|
#ifndef RW_GL_USE_VAOS
|
||||||
//setAttribPointers(im3dattribDesc, 3);
|
//setAttribPointers(im3dattribDesc, 3);
|
||||||
@@ -236,9 +238,9 @@ im3DRenderPrimitive(PrimitiveType primType)
|
|||||||
void
|
void
|
||||||
im3DRenderIndexedPrimitive(PrimitiveType primType, void *indices, int32 numIndices)
|
im3DRenderIndexedPrimitive(PrimitiveType primType, void *indices, int32 numIndices)
|
||||||
{
|
{
|
||||||
memcpy_neon(gIndicesIm2D, indices, numIndices * 2);
|
memcpy_neon(gIndicesIm3D, indices, numIndices * 2);
|
||||||
vglIndexPointerMapped(gIndicesIm2D);
|
vglIndexPointerMapped(gIndicesIm3D);
|
||||||
gIndicesIm2D += numIndices;
|
gIndicesIm3D += numIndices;
|
||||||
|
|
||||||
flushCache();
|
flushCache();
|
||||||
vglDrawObjects(primTypeMap[primType], numIndices, GL_FALSE);
|
vglDrawObjects(primTypeMap[primType], numIndices, GL_FALSE);
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ void main(
|
|||||||
float4 out gl_Position : POSITION
|
float4 out gl_Position : POSITION
|
||||||
) {
|
) {
|
||||||
float4 Vertex = mul(float4(in_pos, 1.0), u_world);
|
float4 Vertex = mul(float4(in_pos, 1.0), u_world);
|
||||||
gl_Position = mul(Vertex, u_view * u_proj);
|
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;
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ const char *default_vert_src =
|
|||||||
" 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"
|
" float4 Vertex = mul(float4(in_pos, 1.0), u_world);\n"
|
||||||
" gl_Position = mul(Vertex, u_view * u_proj);\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"
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ void main(
|
|||||||
float4 out gl_Position : POSITION
|
float4 out gl_Position : POSITION
|
||||||
) {
|
) {
|
||||||
float4 Vertex = mul(float4(in_pos, 1.0), u_world);
|
float4 Vertex = mul(float4(in_pos, 1.0), u_world);
|
||||||
gl_Position = mul(Vertex, u_view * u_proj);
|
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;
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ const char *matfx_env_vert_src =
|
|||||||
" 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"
|
" float4 Vertex = mul(float4(in_pos, 1.0), u_world);\n"
|
||||||
" gl_Position = mul(Vertex, u_view * u_proj);\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"
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ void main(
|
|||||||
}
|
}
|
||||||
|
|
||||||
float4 Vertex = mul(float4(SkinVertex, 1.0), u_world);
|
float4 Vertex = mul(float4(SkinVertex, 1.0), u_world);
|
||||||
gl_Position = mul(Vertex, u_view * u_proj);
|
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;
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ const char *skin_vert_src =
|
|||||||
" }\n"
|
" }\n"
|
||||||
" \n"
|
" \n"
|
||||||
" float4 Vertex = mul(float4(SkinVertex, 1.0), u_world);\n"
|
" float4 Vertex = mul(float4(SkinVertex, 1.0), u_world);\n"
|
||||||
" gl_Position = mul(Vertex, u_view * u_proj);\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