Fixed all remaining glitches.
This commit is contained in:
+30
-11
@@ -2,6 +2,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <vitashark.h>
|
||||
|
||||
#include "../rwbase.h"
|
||||
#include "../rwerror.h"
|
||||
@@ -303,10 +304,10 @@ flushGlRenderState(void)
|
||||
void
|
||||
setAlphaBlend(bool32 enable)
|
||||
{
|
||||
if(rwStateCache.blendEnable != enable){
|
||||
//if(rwStateCache.blendEnable != enable){
|
||||
rwStateCache.blendEnable = enable;
|
||||
setGlRenderState(RWGL_BLEND, enable);
|
||||
}
|
||||
//}
|
||||
}
|
||||
|
||||
bool32
|
||||
@@ -417,16 +418,31 @@ bindFramebuffer(uint32 fbo)
|
||||
}
|
||||
|
||||
// TODO: support mipmaps
|
||||
#ifdef PSP2_MIPMAPS
|
||||
static GLint filterConvMap_NoMIP[] = {
|
||||
0, GL_NEAREST, GL_NEAREST_MIPMAP_LINEAR,
|
||||
GL_NEAREST, GL_NEAREST_MIPMAP_LINEAR,
|
||||
GL_NEAREST, GL_NEAREST_MIPMAP_LINEAR
|
||||
};
|
||||
#else
|
||||
static GLint filterConvMap_NoMIP[] = {
|
||||
0, GL_NEAREST, GL_LINEAR,
|
||||
GL_NEAREST, GL_LINEAR,
|
||||
GL_NEAREST, GL_LINEAR
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef PSP2
|
||||
static GLint addressConvMap[] = {
|
||||
0, GL_REPEAT, GL_REPEAT,
|
||||
GL_REPEAT, GL_REPEAT
|
||||
};
|
||||
#else
|
||||
static GLint addressConvMap[] = {
|
||||
0, GL_REPEAT, GL_MIRRORED_REPEAT,
|
||||
GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE
|
||||
};
|
||||
#endif
|
||||
|
||||
static void
|
||||
setFilterMode(uint32 stage, int32 filter)
|
||||
@@ -869,14 +885,15 @@ Shader *lastShaderUploaded;
|
||||
|
||||
#define U(i) currentShader->uniformLocations[i]
|
||||
|
||||
rw::RGBAf matColorCache;
|
||||
float surfPropsCache[4];
|
||||
|
||||
void
|
||||
setMaterial(const RGBA &color, const SurfaceProperties &surfaceprops)
|
||||
{
|
||||
//bool force = lastShaderUploaded != currentShader;
|
||||
//if(force || !equal(shaderState.matColor, color)){
|
||||
rw::RGBAf col;
|
||||
convColor(&col, &color);
|
||||
glUniform4fv(U(u_matColor), 1, (GLfloat*)&col);
|
||||
convColor(&matColorCache, &color);
|
||||
shaderState.matColor = color;
|
||||
//}
|
||||
|
||||
@@ -884,12 +901,10 @@ setMaterial(const RGBA &color, const SurfaceProperties &surfaceprops)
|
||||
// shaderState.surfProps.ambient != surfaceprops.ambient ||
|
||||
// shaderState.surfProps.specular != surfaceprops.specular ||
|
||||
// shaderState.surfProps.diffuse != surfaceprops.diffuse){
|
||||
float surfProps[4];
|
||||
surfProps[0] = surfaceprops.ambient;
|
||||
surfProps[1] = surfaceprops.specular;
|
||||
surfProps[2] = surfaceprops.diffuse;
|
||||
surfProps[3] = 0.0f;
|
||||
glUniform4fv(U(u_surfProps), 1, surfProps);
|
||||
surfPropsCache[0] = surfaceprops.ambient;
|
||||
surfPropsCache[1] = surfaceprops.specular;
|
||||
surfPropsCache[2] = surfaceprops.diffuse;
|
||||
surfPropsCache[3] = 0.0f;
|
||||
shaderState.surfProps = surfaceprops;
|
||||
//}
|
||||
}
|
||||
@@ -899,6 +914,9 @@ flushCache(void)
|
||||
{
|
||||
flushGlRenderState();
|
||||
|
||||
glUniform4fv(U(u_matColor), 1, (GLfloat*)&matColorCache);
|
||||
glUniform4fv(U(u_surfProps), 1, surfPropsCache);
|
||||
|
||||
// TODO: this is probably a stupid way to do it without UBOs
|
||||
/*if(lastShaderUploaded != currentShader){
|
||||
lastShaderUploaded = currentShader;
|
||||
@@ -1340,6 +1358,7 @@ openGLFW(EngineOpenParams *openparams)
|
||||
}
|
||||
|
||||
vglInitExtended(0x10000, 960, 544, 0x100000, SCE_GXM_MULTISAMPLE_4X);
|
||||
vglSetupRuntimeShaderCompiler(SHARK_OPT_UNSAFE, SHARK_ENABLE, SHARK_ENABLE, SHARK_ENABLE);
|
||||
vglUseVram(GL_TRUE);
|
||||
vglStartRendering();
|
||||
|
||||
|
||||
+6
-5
@@ -39,11 +39,11 @@ matfxDefaultRender(InstanceDataHeader *header, InstanceData *inst)
|
||||
|
||||
rw::SetRenderState(VERTEXALPHA, inst->vertexAlpha || m->color.alpha != 0xFF);
|
||||
|
||||
flushCache();
|
||||
setTexture(0, m->texture);
|
||||
|
||||
setMaterial(m->color, m->surfaceProps);
|
||||
|
||||
setTexture(0, m->texture);
|
||||
flushCache();
|
||||
|
||||
drawInst(header, inst);
|
||||
}
|
||||
@@ -94,14 +94,15 @@ matfxEnvRender(InstanceDataHeader *header, InstanceData *inst, MatFX::Env *env)
|
||||
rw::SetRenderState(VERTEXALPHA, 1);
|
||||
rw::SetRenderState(SRCBLEND, BLENDONE);
|
||||
|
||||
flushCache();
|
||||
|
||||
setTexture(0, m->texture);
|
||||
setTexture(1, env->tex);
|
||||
uploadEnvMatrix(env->frame);
|
||||
|
||||
setMaterial(m->color, m->surfaceProps);
|
||||
|
||||
flushCache();
|
||||
|
||||
uploadEnvMatrix(env->frame);
|
||||
|
||||
float fxparams[2];
|
||||
fxparams[0] = env->coefficient;
|
||||
fxparams[1] = env->fbAlpha ? 0.0f : 1.0f;
|
||||
|
||||
+20
-6
@@ -19,6 +19,8 @@ namespace gl3 {
|
||||
|
||||
int32 nativeRasterOffset;
|
||||
|
||||
#define RW_GLES
|
||||
|
||||
#ifdef RW_OPENGL
|
||||
static Raster*
|
||||
rasterCreateTexture(Raster *raster)
|
||||
@@ -56,7 +58,7 @@ rasterCreateTexture(Raster *raster)
|
||||
|
||||
#ifdef RW_GLES
|
||||
// glReadPixels only supports GL_RGBA
|
||||
natras->internalFormat = GL_RGBA8;
|
||||
natras->internalFormat = GL_RGBA;
|
||||
natras->format = GL_RGBA;
|
||||
natras->type = GL_UNSIGNED_BYTE;
|
||||
natras->bpp = 4;
|
||||
@@ -114,10 +116,10 @@ rasterCreateCameraTexture(Raster *raster)
|
||||
|
||||
#ifdef RW_GLES
|
||||
// glReadPixels only supports GL_RGBA
|
||||
// natras->internalFormat = GL_RGBA8;
|
||||
// natras->format = GL_RGBA;
|
||||
// natras->type = GL_UNSIGNED_BYTE;
|
||||
// natras->bpp = 4;
|
||||
natras->internalFormat = GL_RGBA;
|
||||
natras->format = GL_RGBA;
|
||||
natras->type = GL_UNSIGNED_BYTE;
|
||||
natras->bpp = 4;
|
||||
#endif
|
||||
|
||||
raster->stride = raster->width*natras->bpp;
|
||||
@@ -251,6 +253,8 @@ rasterCreate(Raster *raster)
|
||||
}
|
||||
}
|
||||
|
||||
#define ALIGN(x, a) (((x) + ((a)-1)) & ~((a)-1))
|
||||
|
||||
uint8*
|
||||
rasterLock(Raster *raster, int32 level, int32 lockMode)
|
||||
{
|
||||
@@ -271,7 +275,14 @@ memset(px, 0, raster->stride*raster->height);
|
||||
|
||||
if(lockMode & Raster::LOCKREAD || !(lockMode & Raster::LOCKNOFETCH)){
|
||||
uint32 prev = bindTexture(natras->texid);
|
||||
memcpy_neon(px, vglGetTexDataPointer(GL_TEXTURE_2D), raster->stride*raster->height);
|
||||
int y = 0;
|
||||
uint8_t *p = (uint8_t*)vglGetTexDataPointer(GL_TEXTURE_2D);
|
||||
uint32_t internal_stride = ALIGN(raster->width, 8) * natras->bpp;
|
||||
while (y < raster->height) {
|
||||
memcpy_neon(px, p, raster->stride);
|
||||
px += internal_stride;
|
||||
y++;
|
||||
}
|
||||
bindTexture(prev);
|
||||
}
|
||||
|
||||
@@ -302,6 +313,9 @@ rasterUnlock(Raster *raster, int32 level)
|
||||
glTexImage2D(GL_TEXTURE_2D, level, natras->internalFormat,
|
||||
raster->width, raster->height,
|
||||
0, natras->format, natras->type, raster->pixels);
|
||||
#ifdef PSP2_MIPMAPS
|
||||
glGenerateMipmap(GL_TEXTURE_2D);
|
||||
#endif
|
||||
bindTexture(prev);
|
||||
}
|
||||
|
||||
|
||||
@@ -64,9 +64,11 @@ drawInst_GSemu(InstanceDataHeader *header, InstanceData *inst)
|
||||
void
|
||||
drawInst(InstanceDataHeader *header, InstanceData *inst)
|
||||
{
|
||||
#ifndef PSP2
|
||||
if(rw::GetRenderState(rw::GSALPHATEST))
|
||||
drawInst_GSemu(header, inst);
|
||||
else
|
||||
#endif
|
||||
drawInst_simple(header, inst);
|
||||
}
|
||||
|
||||
@@ -132,11 +134,11 @@ defaultRenderCB(Atomic *atomic, InstanceDataHeader *header)
|
||||
|
||||
rw::SetRenderState(VERTEXALPHA, inst->vertexAlpha || m->color.alpha != 0xFF);
|
||||
|
||||
flushCache();
|
||||
setTexture(0, m->texture);
|
||||
|
||||
setMaterial(m->color, m->surfaceProps);
|
||||
|
||||
setTexture(0, m->texture);
|
||||
flushCache();
|
||||
|
||||
drawInst(header, inst);
|
||||
inst++;
|
||||
|
||||
+2
-2
@@ -275,11 +275,11 @@ skinRenderCB(Atomic *atomic, InstanceDataHeader *header)
|
||||
|
||||
rw::SetRenderState(VERTEXALPHA, inst->vertexAlpha || m->color.alpha != 0xFF);
|
||||
|
||||
flushCache();
|
||||
setTexture(0, m->texture);
|
||||
|
||||
setMaterial(m->color, m->surfaceProps);
|
||||
|
||||
setTexture(0, m->texture);
|
||||
flushCache();
|
||||
|
||||
uploadSkinMatrices(atomic);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user