Removed mempools usage for normal draws.
This commit is contained in:
+4
-14
@@ -17,12 +17,8 @@
|
|||||||
|
|
||||||
#define PLUGIN_ID 0
|
#define PLUGIN_ID 0
|
||||||
|
|
||||||
extern uint16_t *gIndices;
|
|
||||||
extern float *gVertexBuffer;
|
|
||||||
extern uint16_t *gIndicesPtr;
|
|
||||||
uint16_t *gIndicesIm2DPtr;
|
uint16_t *gIndicesIm2DPtr;
|
||||||
uint16_t *gIndicesIm3DPtr;
|
uint16_t *gIndicesIm3DPtr;
|
||||||
extern float *gVertexBufferPtr;
|
|
||||||
float *gVertexBufferIm2DPtr;
|
float *gVertexBufferIm2DPtr;
|
||||||
float *gVertexBufferIm3DPtr;
|
float *gVertexBufferIm3DPtr;
|
||||||
|
|
||||||
@@ -1162,10 +1158,8 @@ showRaster(Raster *raster, uint32 flags)
|
|||||||
vglWaitVblankStart(GL_FALSE);
|
vglWaitVblankStart(GL_FALSE);
|
||||||
vglStopRendering();
|
vglStopRendering();
|
||||||
vglStartRendering();
|
vglStartRendering();
|
||||||
gVertexBuffer = gVertexBufferPtr;
|
|
||||||
gVertexBufferIm2D = gVertexBufferIm2DPtr;
|
gVertexBufferIm2D = gVertexBufferIm2DPtr;
|
||||||
gVertexBufferIm3D = gVertexBufferIm3DPtr;
|
gVertexBufferIm3D = gVertexBufferIm3DPtr;
|
||||||
gIndices = gIndicesPtr;
|
|
||||||
gIndicesIm2D = gIndicesIm2DPtr;
|
gIndicesIm2D = gIndicesIm2DPtr;
|
||||||
gIndicesIm3D = gIndicesIm3DPtr;
|
gIndicesIm3D = gIndicesIm3DPtr;
|
||||||
#endif
|
#endif
|
||||||
@@ -1417,23 +1411,19 @@ initOpenGL(void)
|
|||||||
|
|
||||||
resetRenderState();
|
resetRenderState();
|
||||||
|
|
||||||
gVertexBufferPtr = (float*)malloc(0x1800000);
|
|
||||||
gVertexBufferIm2DPtr = (float*)malloc(0x500000);
|
gVertexBufferIm2DPtr = (float*)malloc(0x500000);
|
||||||
gVertexBufferIm3DPtr = (float*)malloc(0x500000);
|
gVertexBufferIm3DPtr = (float*)malloc(0x1800000);
|
||||||
gIndicesPtr = (uint16_t*)malloc(0x600000);
|
|
||||||
gIndicesIm2DPtr = (uint16_t*)malloc(0x600000);
|
gIndicesIm2DPtr = (uint16_t*)malloc(0x600000);
|
||||||
gIndicesIm3DPtr = (uint16_t*)malloc(0x600000);
|
gIndicesIm3DPtr = (uint16_t*)malloc(0x1800000);
|
||||||
|
|
||||||
gConstIndices = (uint16_t*)malloc(sizeof(uint16_t) * 512);
|
gConstIndices = (uint16_t*)malloc(sizeof(uint16_t) * 0xFFFF);
|
||||||
|
|
||||||
gVertexBuffer = gVertexBufferPtr;
|
|
||||||
gVertexBufferIm2D = gVertexBufferIm2DPtr;
|
gVertexBufferIm2D = gVertexBufferIm2DPtr;
|
||||||
gVertexBufferIm3D = gVertexBufferIm3DPtr;
|
gVertexBufferIm3D = gVertexBufferIm3DPtr;
|
||||||
gIndices = gIndicesPtr;
|
|
||||||
gIndicesIm2D = gIndicesIm2DPtr;
|
gIndicesIm2D = gIndicesIm2DPtr;
|
||||||
gIndicesIm3D = gIndicesIm3DPtr;
|
gIndicesIm3D = gIndicesIm3DPtr;
|
||||||
|
|
||||||
for (uint16_t i = 0; i < 512; i++) {
|
for (uint16_t i = 0; i < 0xFFFF; i++) {
|
||||||
gConstIndices[i] = i;
|
gConstIndices[i] = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+15
-16
@@ -103,11 +103,6 @@ im2DRenderPrimitive(PrimitiveType primType, void *vertices, int32 numVertices)
|
|||||||
GLfloat xform[4];
|
GLfloat xform[4];
|
||||||
Camera *cam;
|
Camera *cam;
|
||||||
cam = (Camera*)engine->currentCamera;
|
cam = (Camera*)engine->currentCamera;
|
||||||
|
|
||||||
memcpy_neon(gVertexBufferIm2D, vertices, numVertices*sizeof(Im2DVertex));
|
|
||||||
vglVertexAttribPointerMapped(0, gVertexBufferIm2D);
|
|
||||||
vglIndexPointerMapped(gConstIndices);
|
|
||||||
gVertexBufferIm2D += numVertices*(sizeof(Im2DVertex)/sizeof(float));
|
|
||||||
|
|
||||||
xform[0] = 2.0f/cam->frameBuffer->width;
|
xform[0] = 2.0f/cam->frameBuffer->width;
|
||||||
xform[1] = -2.0f/cam->frameBuffer->height;
|
xform[1] = -2.0f/cam->frameBuffer->height;
|
||||||
@@ -122,6 +117,11 @@ im2DRenderPrimitive(PrimitiveType primType, void *vertices, int32 numVertices)
|
|||||||
flushCache();
|
flushCache();
|
||||||
glUniform4fv(currentShader->uniformLocations[u_xform], 1, xform);
|
glUniform4fv(currentShader->uniformLocations[u_xform], 1, xform);
|
||||||
|
|
||||||
|
memcpy_neon(gVertexBufferIm2D, vertices, numVertices*sizeof(Im2DVertex));
|
||||||
|
vglVertexAttribPointerMapped(0, gVertexBufferIm2D);
|
||||||
|
vglIndexPointerMapped(gConstIndices);
|
||||||
|
gVertexBufferIm2D += numVertices*(sizeof(Im2DVertex)/sizeof(float));
|
||||||
|
|
||||||
vglDrawObjects(primTypeMap[primType], numVertices, GL_FALSE);
|
vglDrawObjects(primTypeMap[primType], numVertices, GL_FALSE);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -135,14 +135,6 @@ im2DRenderIndexedPrimitive(PrimitiveType primType,
|
|||||||
Camera *cam;
|
Camera *cam;
|
||||||
cam = (Camera*)engine->currentCamera;
|
cam = (Camera*)engine->currentCamera;
|
||||||
|
|
||||||
memcpy_neon(gIndicesIm2D, indices, numIndices * 2);
|
|
||||||
vglIndexPointerMapped(gIndicesIm2D);
|
|
||||||
gIndicesIm2D += numIndices;
|
|
||||||
|
|
||||||
memcpy_neon(gVertexBufferIm2D, vertices, numVertices*sizeof(Im2DVertex));
|
|
||||||
vglVertexAttribPointerMapped(0, gVertexBufferIm2D);
|
|
||||||
gVertexBufferIm2D += numVertices*(sizeof(Im2DVertex)/sizeof(float));
|
|
||||||
|
|
||||||
xform[0] = 2.0f/cam->frameBuffer->width;
|
xform[0] = 2.0f/cam->frameBuffer->width;
|
||||||
xform[1] = -2.0f/cam->frameBuffer->height;
|
xform[1] = -2.0f/cam->frameBuffer->height;
|
||||||
xform[2] = -1.0f;
|
xform[2] = -1.0f;
|
||||||
@@ -155,6 +147,14 @@ im2DRenderIndexedPrimitive(PrimitiveType primType,
|
|||||||
|
|
||||||
flushCache();
|
flushCache();
|
||||||
glUniform4fv(currentShader->uniformLocations[u_xform], 1, xform);
|
glUniform4fv(currentShader->uniformLocations[u_xform], 1, xform);
|
||||||
|
|
||||||
|
memcpy_neon(gIndicesIm2D, indices, numIndices * 2);
|
||||||
|
vglIndexPointerMapped(gIndicesIm2D);
|
||||||
|
gIndicesIm2D += numIndices;
|
||||||
|
|
||||||
|
memcpy_neon(gVertexBufferIm2D, vertices, numVertices*sizeof(Im2DVertex));
|
||||||
|
vglVertexAttribPointerMapped(0, gVertexBufferIm2D);
|
||||||
|
gVertexBufferIm2D += numVertices*(sizeof(Im2DVertex)/sizeof(float));
|
||||||
|
|
||||||
vglDrawObjects(primTypeMap[primType], numIndices, GL_FALSE);
|
vglDrawObjects(primTypeMap[primType], numIndices, GL_FALSE);
|
||||||
}
|
}
|
||||||
@@ -205,7 +205,7 @@ void
|
|||||||
im3DTransform(void *vertices, int32 numVertices, Matrix *world, uint32 flags)
|
im3DTransform(void *vertices, int32 numVertices, Matrix *world, uint32 flags)
|
||||||
{
|
{
|
||||||
if(world == nil){
|
if(world == nil){
|
||||||
Matrix ident;
|
static Matrix ident;
|
||||||
ident.setIdentity();
|
ident.setIdentity();
|
||||||
world = &ident;
|
world = &ident;
|
||||||
}
|
}
|
||||||
@@ -236,13 +236,12 @@ im3DRenderPrimitive(PrimitiveType primType)
|
|||||||
void
|
void
|
||||||
im3DRenderIndexedPrimitive(PrimitiveType primType, void *indices, int32 numIndices)
|
im3DRenderIndexedPrimitive(PrimitiveType primType, void *indices, int32 numIndices)
|
||||||
{
|
{
|
||||||
|
flushCache();
|
||||||
memcpy_neon(gIndicesIm3D, indices, numIndices * 2);
|
memcpy_neon(gIndicesIm3D, indices, numIndices * 2);
|
||||||
vglIndexPointerMapped(gIndicesIm3D);
|
vglIndexPointerMapped(gIndicesIm3D);
|
||||||
vglVertexAttribPointerMapped(0, gVertexBufferIm3D);
|
vglVertexAttribPointerMapped(0, gVertexBufferIm3D);
|
||||||
gVertexBufferIm3D += num3DVertices*(sizeof(Im3DVertex)/sizeof(float));
|
gVertexBufferIm3D += num3DVertices*(sizeof(Im3DVertex)/sizeof(float));
|
||||||
gIndicesIm3D += numIndices;
|
gIndicesIm3D += numIndices;
|
||||||
|
|
||||||
flushCache();
|
|
||||||
vglDrawObjects(primTypeMap[primType], numIndices, GL_FALSE);
|
vglDrawObjects(primTypeMap[primType], numIndices, GL_FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+10
-7
@@ -33,17 +33,18 @@ static int32 u_colorClamp;
|
|||||||
void
|
void
|
||||||
matfxDefaultRender(InstanceDataHeader *header, InstanceData *inst)
|
matfxDefaultRender(InstanceDataHeader *header, InstanceData *inst)
|
||||||
{
|
{
|
||||||
Material *m;
|
Material *m = inst->material;
|
||||||
m = inst->material;
|
|
||||||
|
|
||||||
defaultShader->use();
|
defaultShader->use();
|
||||||
|
|
||||||
|
rw::SetRenderState(VERTEXALPHA, inst->vertexAlpha || m->color.alpha != 0xFF);
|
||||||
|
|
||||||
|
flushCache();
|
||||||
|
|
||||||
setMaterial(m->color, m->surfaceProps);
|
setMaterial(m->color, m->surfaceProps);
|
||||||
|
|
||||||
setTexture(0, m->texture);
|
setTexture(0, m->texture);
|
||||||
|
|
||||||
rw::SetRenderState(VERTEXALPHA, inst->vertexAlpha || m->color.alpha != 0xFF);
|
|
||||||
|
|
||||||
drawInst(header, inst);
|
drawInst(header, inst);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,6 +90,11 @@ matfxEnvRender(InstanceDataHeader *header, InstanceData *inst, MatFX::Env *env)
|
|||||||
}
|
}
|
||||||
|
|
||||||
envShader->use();
|
envShader->use();
|
||||||
|
|
||||||
|
rw::SetRenderState(VERTEXALPHA, 1);
|
||||||
|
rw::SetRenderState(SRCBLEND, BLENDONE);
|
||||||
|
|
||||||
|
flushCache();
|
||||||
|
|
||||||
setTexture(0, m->texture);
|
setTexture(0, m->texture);
|
||||||
setTexture(1, env->tex);
|
setTexture(1, env->tex);
|
||||||
@@ -109,9 +115,6 @@ matfxEnvRender(InstanceDataHeader *header, InstanceData *inst, MatFX::Env *env)
|
|||||||
else
|
else
|
||||||
glUniform4fv(U(u_colorClamp), 1, one);
|
glUniform4fv(U(u_colorClamp), 1, one);
|
||||||
|
|
||||||
rw::SetRenderState(VERTEXALPHA, 1);
|
|
||||||
rw::SetRenderState(SRCBLEND, BLENDONE);
|
|
||||||
|
|
||||||
drawInst(header, inst);
|
drawInst(header, inst);
|
||||||
|
|
||||||
rw::SetRenderState(SRCBLEND, BLENDSRCALPHA);
|
rw::SetRenderState(SRCBLEND, BLENDSRCALPHA);
|
||||||
|
|||||||
@@ -12,9 +12,6 @@
|
|||||||
#include "rwgl3.h"
|
#include "rwgl3.h"
|
||||||
#include "rwgl3shader.h"
|
#include "rwgl3shader.h"
|
||||||
|
|
||||||
extern float *gVertexBuffer;
|
|
||||||
extern uint16_t *gIndices;
|
|
||||||
|
|
||||||
namespace rw {
|
namespace rw {
|
||||||
namespace gl3 {
|
namespace gl3 {
|
||||||
|
|
||||||
|
|||||||
+6
-14
@@ -15,11 +15,6 @@
|
|||||||
|
|
||||||
#include "rwgl3impl.h"
|
#include "rwgl3impl.h"
|
||||||
|
|
||||||
extern uint16_t *gIndices;
|
|
||||||
extern float *gVertexBuffer;
|
|
||||||
extern uint16_t *gIndicesPtr;
|
|
||||||
extern float *gVertexBufferPtr;
|
|
||||||
|
|
||||||
namespace rw {
|
namespace rw {
|
||||||
namespace gl3 {
|
namespace gl3 {
|
||||||
|
|
||||||
@@ -28,13 +23,8 @@ namespace gl3 {
|
|||||||
void
|
void
|
||||||
drawInst_simple(InstanceDataHeader *header, InstanceData *inst)
|
drawInst_simple(InstanceDataHeader *header, InstanceData *inst)
|
||||||
{
|
{
|
||||||
flushCache();
|
vglIndexPointerMapped(header->indexBuffer + inst->offset);
|
||||||
memcpy_neon(gIndices, (uint8_t*)header->indexBuffer + inst->offset, inst->numIndex * 2);
|
vglVertexAttribPointerMapped(0, header->vertexBuffer);
|
||||||
vglIndexPointerMapped(gIndices);
|
|
||||||
gIndices += inst->numIndex;
|
|
||||||
memcpy_neon(gVertexBuffer, (uint8_t*)header->vertexBuffer, inst->numVertices * header->attribDesc[0].stride);
|
|
||||||
vglVertexAttribPointerMapped(0, gVertexBuffer);
|
|
||||||
gVertexBuffer += (inst->numVertices * header->attribDesc[0].stride) / sizeof(float);
|
|
||||||
vglDrawObjects(header->primType, inst->numIndex, GL_FALSE);
|
vglDrawObjects(header->primType, inst->numIndex, GL_FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -140,12 +130,14 @@ defaultRenderCB(Atomic *atomic, InstanceDataHeader *header)
|
|||||||
while(n--){
|
while(n--){
|
||||||
m = inst->material;
|
m = inst->material;
|
||||||
|
|
||||||
|
rw::SetRenderState(VERTEXALPHA, inst->vertexAlpha || m->color.alpha != 0xFF);
|
||||||
|
|
||||||
|
flushCache();
|
||||||
|
|
||||||
setMaterial(m->color, m->surfaceProps);
|
setMaterial(m->color, m->surfaceProps);
|
||||||
|
|
||||||
setTexture(0, m->texture);
|
setTexture(0, m->texture);
|
||||||
|
|
||||||
rw::SetRenderState(VERTEXALPHA, inst->vertexAlpha || m->color.alpha != 0xFF);
|
|
||||||
|
|
||||||
drawInst(header, inst);
|
drawInst(header, inst);
|
||||||
inst++;
|
inst++;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -149,12 +149,12 @@ linkprogram(GLint vs, GLint fs, GLuint *program, bool is_2d)
|
|||||||
|
|
||||||
int stride = 0;
|
int stride = 0;
|
||||||
int pos_size = is_2d ? 4 : 3;
|
int pos_size = is_2d ? 4 : 3;
|
||||||
stride += vglBindPackedAttribLocation(prog, "in_pos" , pos_size, GL_FLOAT, stride, stride + sizeof(float) * pos_size) * (sizeof(float) * pos_size);
|
stride += vglBindPackedAttribLocation(prog, "in_pos" , pos_size, GL_FLOAT, stride, stride + sizeof(float) * pos_size) * (sizeof(float) * pos_size);
|
||||||
stride += vglBindPackedAttribLocation(prog, "in_normal" , 3, GL_FLOAT, stride, stride + sizeof(float) * 3) * (sizeof(float) * 3);
|
stride += vglBindPackedAttribLocation(prog, "in_normal" , 3, GL_FLOAT, stride, stride + sizeof(float) * 3) * (sizeof(float) * 3);
|
||||||
stride += vglBindPackedAttribLocation(prog, "in_color" , 4, GL_UNSIGNED_BYTE, stride, stride + 4) * 4;
|
stride += vglBindPackedAttribLocation(prog, "in_color" , 4, GL_UNSIGNED_BYTE, stride, stride + 4) * 4;
|
||||||
stride += vglBindPackedAttribLocation(prog, "in_tex0" , 2, GL_FLOAT, stride, stride + sizeof(float) * 2) * (sizeof(float) * 2);
|
stride += vglBindPackedAttribLocation(prog, "in_tex0" , 2, GL_FLOAT, stride, stride + sizeof(float) * 2) * (sizeof(float) * 2);
|
||||||
stride += vglBindPackedAttribLocation(prog, "in_weights", 4, GL_FLOAT, stride, stride + sizeof(float) * 4) * (sizeof(float) * 4);
|
stride += vglBindPackedAttribLocation(prog, "in_weights", 4, GL_FLOAT, stride, stride + sizeof(float) * 4) * (sizeof(float) * 4);
|
||||||
vglBindPackedAttribLocation(prog, "in_indices", 4, GL_UNSIGNED_BYTE, stride, stride + 4);
|
vglBindPackedAttribLocation(prog, "in_indices", 4, GL_UNSIGNED_BYTE, stride, stride + 4);
|
||||||
|
|
||||||
glLinkProgram(prog);
|
glLinkProgram(prog);
|
||||||
|
|
||||||
|
|||||||
+8
-4
@@ -254,17 +254,21 @@ skinRenderCB(Atomic *atomic, InstanceDataHeader *header)
|
|||||||
|
|
||||||
skinShader->use();
|
skinShader->use();
|
||||||
|
|
||||||
uploadSkinMatrices(atomic);
|
|
||||||
|
|
||||||
while(n--){
|
while(n--){
|
||||||
m = inst->material;
|
m = inst->material;
|
||||||
|
|
||||||
|
rw::SetRenderState(VERTEXALPHA, inst->vertexAlpha || m->color.alpha != 0xFF);
|
||||||
|
|
||||||
|
flushCache();
|
||||||
|
|
||||||
setMaterial(m->color, m->surfaceProps);
|
setMaterial(m->color, m->surfaceProps);
|
||||||
|
|
||||||
setTexture(0, m->texture);
|
setTexture(0, m->texture);
|
||||||
|
|
||||||
rw::SetRenderState(VERTEXALPHA, inst->vertexAlpha || m->color.alpha != 0xFF);
|
uploadSkinMatrices(atomic);
|
||||||
|
|
||||||
drawInst(header, inst);
|
drawInst(header, inst);
|
||||||
inst++;
|
inst++;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,11 +28,6 @@
|
|||||||
|
|
||||||
#define PLUGIN_ID 2
|
#define PLUGIN_ID 2
|
||||||
|
|
||||||
uint16_t *gIndices;
|
|
||||||
float *gVertexBuffer;
|
|
||||||
uint16_t *gIndicesPtr;
|
|
||||||
float *gVertexBufferPtr;
|
|
||||||
|
|
||||||
namespace rw {
|
namespace rw {
|
||||||
namespace wdgl {
|
namespace wdgl {
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user