1
0
mirror of https://github.com/blawar/GLideN64.git synced 2024-07-04 10:03:36 +00:00

Fix some differences between GLES2 and GLES3 code.

This commit is contained in:
Francisco Zurita 2016-11-13 22:33:23 -05:00 committed by Sergey Lipskiy
parent 6e15de2e09
commit 16262e52ad
3 changed files with 16 additions and 13 deletions

View File

@ -788,8 +788,8 @@ void FrameBuffer_Destroy()
RDRAMtoColorBuffer::get().destroy(); RDRAMtoColorBuffer::get().destroy();
#ifndef GLES2 #ifndef GLES2
DepthBufferToRDRAM::get().destroy(); DepthBufferToRDRAM::get().destroy();
ColorBufferToRDRAM::get().destroy();
#endif #endif
ColorBufferToRDRAM::get().destroy();
frameBufferList().destroy(); frameBufferList().destroy();
} }

View File

@ -62,7 +62,7 @@ void NoiseTexture::init()
m_pTexture->textureBytes = m_pTexture->realWidth * m_pTexture->realHeight; m_pTexture->textureBytes = m_pTexture->realWidth * m_pTexture->realHeight;
textureCache().addFrameBufferTextureSize(m_pTexture->textureBytes); textureCache().addFrameBufferTextureSize(m_pTexture->textureBytes);
glBindTexture(GL_TEXTURE_2D, m_pTexture->glName); glBindTexture(GL_TEXTURE_2D, m_pTexture->glName);
glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, m_pTexture->realWidth, m_pTexture->realHeight, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, NULL); glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, m_pTexture->realWidth, m_pTexture->realHeight, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, nullptr);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glBindTexture(GL_TEXTURE_2D, 0); glBindTexture(GL_TEXTURE_2D, 0);
@ -100,7 +100,7 @@ static
GLuint _createShader(GLenum _type, const char * _strShader) GLuint _createShader(GLenum _type, const char * _strShader)
{ {
GLuint shader_object = glCreateShader(_type); GLuint shader_object = glCreateShader(_type);
glShaderSource(shader_object, 1, &_strShader, NULL); glShaderSource(shader_object, 1, &_strShader, nullptr);
glCompileShader(shader_object); glCompileShader(shader_object);
assert(checkShaderCompileStatus(shader_object)); assert(checkShaderCompileStatus(shader_object));
return shader_object; return shader_object;
@ -108,9 +108,9 @@ GLuint _createShader(GLenum _type, const char * _strShader)
void InitShaderCombiner() void InitShaderCombiner()
{ {
if (strstr((const char*)glGetString(GL_VERSION), "OpenGL ES 2") != NULL) { if (strstr((const char*)glGetString(GL_VERSION), "OpenGL ES 2") != nullptr) {
const char * strRenderer = reinterpret_cast<const char*>(glGetString(GL_RENDERER)); const char * strRenderer = reinterpret_cast<const char*>(glGetString(GL_RENDERER));
if (strstr(strRenderer, "PowerVR") != NULL || strstr(strRenderer, "Adreno") != NULL) { if (strstr(strRenderer, "PowerVR") != nullptr || strstr(strRenderer, "Adreno") != nullptr) {
g_weakGLSL = true; g_weakGLSL = true;
LOG(LOG_MINIMAL, "GPU with week GLSL detected: %s\n", strRenderer); LOG(LOG_MINIMAL, "GPU with week GLSL detected: %s\n", strRenderer);
} }
@ -234,7 +234,7 @@ ShaderCombiner::ShaderCombiner(Combiner & _color, Combiner & _alpha, const gDPCo
GLuint fragmentShader = glCreateShader(GL_FRAGMENT_SHADER); GLuint fragmentShader = glCreateShader(GL_FRAGMENT_SHADER);
const GLchar * strShaderData = strFragmentShader.data(); const GLchar * strShaderData = strFragmentShader.data();
glShaderSource(fragmentShader, 1, &strShaderData, NULL); glShaderSource(fragmentShader, 1, &strShaderData, nullptr);
glCompileShader(fragmentShader); glCompileShader(fragmentShader);
if (!checkShaderCompileStatus(fragmentShader)) if (!checkShaderCompileStatus(fragmentShader))
logErrorShader(GL_FRAGMENT_SHADER, strFragmentShader); logErrorShader(GL_FRAGMENT_SHADER, strFragmentShader);
@ -311,6 +311,8 @@ void ShaderCombiner::_locate_attributes() const {
} }
void ShaderCombiner::update(bool _bForce) { void ShaderCombiner::update(bool _bForce) {
_bForce |= m_bNeedUpdate;
m_bNeedUpdate = false;
glUseProgram(m_program); glUseProgram(m_program);
if (_bForce) { if (_bForce) {
@ -341,8 +343,8 @@ void ShaderCombiner::updateRenderState(bool _bForce)
void ShaderCombiner::updateScreenCoordsScale(bool _bForce) void ShaderCombiner::updateScreenCoordsScale(bool _bForce)
{ {
FrameBuffer * pCurrentBuffer = frameBufferList().getCurrent(); FrameBuffer * pCurrentBuffer = frameBufferList().getCurrent();
const float scaleX = pCurrentBuffer != NULL ? 1.0f / pCurrentBuffer->m_width : VI.rwidth; const float scaleX = pCurrentBuffer != nullptr ? 1.0f / pCurrentBuffer->m_width : VI.rwidth;
const float scaleY = pCurrentBuffer != NULL ? 1.0f / pCurrentBuffer->m_height : VI.rheight; const float scaleY = pCurrentBuffer != nullptr ? 1.0f / pCurrentBuffer->m_height : VI.rheight;
m_uniforms.uScreenCoordsScale.set(2.0f*scaleX, -2.0f*scaleY, _bForce); m_uniforms.uScreenCoordsScale.set(2.0f*scaleX, -2.0f*scaleY, _bForce);
} }
@ -438,7 +440,8 @@ void ShaderCombiner::updateLOD(bool _bForce)
} }
void ShaderCombiner::updateTextureInfo(bool _bForce) { void ShaderCombiner::updateTextureInfo(bool _bForce) {
m_uniforms.uTexturePersp.set(gDP.otherMode.texturePersp, _bForce); const u32 texturePersp = (RSP.bLLE || GBI.isTexturePersp()) ? gDP.otherMode.texturePersp : 1U;
m_uniforms.uTexturePersp.set(texturePersp, _bForce);
if (config.texture.bilinearMode == BILINEAR_3POINT) if (config.texture.bilinearMode == BILINEAR_3POINT)
m_uniforms.uTextureFilterMode.set(gDP.otherMode.textureFilter | (gSP.objRendermode&G_OBJRM_BILERP), _bForce); m_uniforms.uTextureFilterMode.set(gDP.otherMode.textureFilter | (gSP.objRendermode&G_OBJRM_BILERP), _bForce);
} }
@ -451,7 +454,7 @@ void ShaderCombiner::updateFrameBufferInfo(bool _bForce) {
int nFbFixedAlpha0 = 0, nFbFixedAlpha1 = 0; int nFbFixedAlpha0 = 0, nFbFixedAlpha1 = 0;
int nMSTex0Enabled = 0, nMSTex1Enabled = 0; int nMSTex0Enabled = 0, nMSTex1Enabled = 0;
TextureCache & cache = textureCache(); TextureCache & cache = textureCache();
if (cache.current[0] != NULL && cache.current[0]->frameBufferTexture != CachedTexture::fbNone) { if (cache.current[0] != nullptr && cache.current[0]->frameBufferTexture != CachedTexture::fbNone) {
if (cache.current[0]->size == G_IM_SIZ_8b) { if (cache.current[0]->size == G_IM_SIZ_8b) {
nFbMonochromeMode0 = 1; nFbMonochromeMode0 = 1;
if (gDP.otherMode.imageRead == 0) if (gDP.otherMode.imageRead == 0)
@ -459,7 +462,7 @@ void ShaderCombiner::updateFrameBufferInfo(bool _bForce) {
} else if (gSP.textureTile[0]->size == G_IM_SIZ_16b && gSP.textureTile[0]->format == G_IM_FMT_IA) } else if (gSP.textureTile[0]->size == G_IM_SIZ_16b && gSP.textureTile[0]->format == G_IM_FMT_IA)
nFbMonochromeMode0 = 2; nFbMonochromeMode0 = 2;
} }
if (cache.current[1] != NULL && cache.current[1]->frameBufferTexture != CachedTexture::fbNone) { if (cache.current[1] != nullptr && cache.current[1]->frameBufferTexture != CachedTexture::fbNone) {
if (cache.current[1]->size == G_IM_SIZ_8b) { if (cache.current[1]->size == G_IM_SIZ_8b) {
nFbMonochromeMode1 = 1; nFbMonochromeMode1 = 1;
if (gDP.otherMode.imageRead == 0) if (gDP.otherMode.imageRead == 0)
@ -478,7 +481,7 @@ void ShaderCombiner::updateDepthInfo(bool _bForce) {
return; return;
FrameBuffer * pBuffer = frameBufferList().getCurrent(); FrameBuffer * pBuffer = frameBufferList().getCurrent();
if (pBuffer == NULL || pBuffer->m_pDepthBuffer == NULL) if (pBuffer == nullptr || pBuffer->m_pDepthBuffer == nullptr)
return; return;
const int nDepthEnabled = (gSP.geometryMode & G_ZBUFFER) > 0 ? 1 : 0; const int nDepthEnabled = (gSP.geometryMode & G_ZBUFFER) > 0 ? 1 : 0;

View File

@ -56,7 +56,7 @@ SHADER_VERSION
" if (uTexturePersp == 0 && aModify[2] == 0.0) texCoord *= 0.5;\n" " if (uTexturePersp == 0 && aModify[2] == 0.0) texCoord *= 0.5;\n"
" vTexCoord0 = calcTexCoord(texCoord, 0); \n" " vTexCoord0 = calcTexCoord(texCoord, 0); \n"
" vTexCoord1 = calcTexCoord(texCoord, 1); \n" " vTexCoord1 = calcTexCoord(texCoord, 1); \n"
" vLodTexCoord = texCoord * uCacheShiftScale[0]; \n" " vLodTexCoord = texCoord; \n"
" vNumLights = aNumLights; \n" " vNumLights = aNumLights; \n"
" if (aModify != vec4(0.0)) { \n" " if (aModify != vec4(0.0)) { \n"
" if (aModify[0] != 0.0) { \n" " if (aModify[0] != 0.0) { \n"