Removed mempools usage for normal draws.

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