mirror of
https://github.com/blawar/GLideN64.git
synced 2024-07-04 10:03:36 +00:00
Fix verious GL errors in GLES 3.1 mode and Mario tennis.
This commit is contained in:
parent
428f3ad637
commit
df366f0f6b
|
@ -146,7 +146,7 @@ void DepthBuffer::_initDepthBufferTexture(FrameBuffer * _pBuffer, CachedTexture
|
||||||
if (_multisample) {
|
if (_multisample) {
|
||||||
glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, _pTexture->glName);
|
glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, _pTexture->glName);
|
||||||
#if defined(GLES3_1)
|
#if defined(GLES3_1)
|
||||||
glTexStorage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, config.video.multisampling, GL_DEPTH_COMPONENT, _pTexture->realWidth, _pTexture->realHeight, false);
|
glTexStorage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, config.video.multisampling, GL_DEPTH_COMPONENT24, _pTexture->realWidth, _pTexture->realHeight, false);
|
||||||
#else
|
#else
|
||||||
glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, config.video.multisampling, GL_DEPTH_COMPONENT, _pTexture->realWidth, _pTexture->realHeight, false);
|
glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, config.video.multisampling, GL_DEPTH_COMPONENT, _pTexture->realWidth, _pTexture->realHeight, false);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -54,7 +54,7 @@ void FBOTextureFormats::init()
|
||||||
depthImageFormatBytes = 16;
|
depthImageFormatBytes = 16;
|
||||||
|
|
||||||
lutInternalFormat = GL_R32UI;
|
lutInternalFormat = GL_R32UI;
|
||||||
lutFormat = GL_RED;
|
lutFormat = GL_RED_INTEGER;
|
||||||
lutType = GL_UNSIGNED_INT;
|
lutType = GL_UNSIGNED_INT;
|
||||||
lutFormatBytes = 4;
|
lutFormatBytes = 4;
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -736,7 +736,7 @@ void FrameBufferList::attachDepthBuffer()
|
||||||
pDepthBuffer->initDepthImageTexture(m_pCurrent);
|
pDepthBuffer->initDepthImageTexture(m_pCurrent);
|
||||||
pDepthBuffer->initDepthBufferTexture(m_pCurrent);
|
pDepthBuffer->initDepthBufferTexture(m_pCurrent);
|
||||||
#ifndef USE_DEPTH_RENDERBUFFER
|
#ifndef USE_DEPTH_RENDERBUFFER
|
||||||
#ifdef GLES2
|
#ifdef GLESX
|
||||||
if (pDepthBuffer->m_pDepthBufferTexture->realWidth == m_pCurrent->m_pTexture->realWidth) {
|
if (pDepthBuffer->m_pDepthBufferTexture->realWidth == m_pCurrent->m_pTexture->realWidth) {
|
||||||
#else
|
#else
|
||||||
if (pDepthBuffer->m_pDepthBufferTexture->realWidth >= m_pCurrent->m_pTexture->realWidth) {
|
if (pDepthBuffer->m_pDepthBufferTexture->realWidth >= m_pCurrent->m_pTexture->realWidth) {
|
||||||
|
|
|
@ -142,10 +142,10 @@ void InitZlutTexture()
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, fboFormats.lutInternalFormat,
|
//glBindImageTexture requires an immutable texture object, glTexStorage2D does this
|
||||||
512, 512, 0, fboFormats.lutFormat, fboFormats.lutType,
|
glTexStorage2D(GL_TEXTURE_2D, 1, fboFormats.lutInternalFormat, 512, 512);
|
||||||
zLUT);
|
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 512, 512, fboFormats.lutFormat, fboFormats.lutType, zLUT);
|
||||||
glBindImageTexture(ZlutImageUnit, g_zlut_tex, 0, GL_FALSE, 0, GL_READ_ONLY, fboFormats.lutInternalFormat);
|
glBindImageTexture(ZlutImageUnit, g_zlut_tex, 0, GL_FALSE, GL_FALSE, GL_READ_ONLY, fboFormats.lutInternalFormat);
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
|
@ -153,7 +153,8 @@ void DestroyZlutTexture()
|
||||||
{
|
{
|
||||||
if (!video().getRender().isImageTexturesSupported())
|
if (!video().getRender().isImageTexturesSupported())
|
||||||
return;
|
return;
|
||||||
glBindImageTexture(ZlutImageUnit, 0, 0, GL_FALSE, 0, GL_READ_ONLY, fboFormats.lutInternalFormat);
|
|
||||||
|
glBindImageTexture(ZlutImageUnit, 0, 0, GL_FALSE, GL_FALSE, GL_READ_ONLY, fboFormats.lutInternalFormat);
|
||||||
if (g_zlut_tex > 0) {
|
if (g_zlut_tex > 0) {
|
||||||
glBindTexture(GL_TEXTURE_2D, 0);
|
glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
glDeleteTextures(1, &g_zlut_tex);
|
glDeleteTextures(1, &g_zlut_tex);
|
||||||
|
|
|
@ -743,53 +743,59 @@ MAIN_SHADER_VERSION
|
||||||
// 3 point texture filtering.
|
// 3 point texture filtering.
|
||||||
// Original author: ArthurCarvalho
|
// Original author: ArthurCarvalho
|
||||||
// GLSL implementation: twinaphex, mupen64plus-libretro project.
|
// GLSL implementation: twinaphex, mupen64plus-libretro project.
|
||||||
"#define TEX_OFFSET(off) texture(tex, texCoord - (off)/texSize) \n"
|
"#define TEX_OFFSET(off, tex, texCoord, texSize) texture(tex, texCoord - (off)/texSize) \n"
|
||||||
"lowp vec4 texFilter(in sampler2D tex, in mediump vec2 texCoord) \n"
|
"#define TEX_FILTER(name, tex, texCoord) \\\n"
|
||||||
"{ \n"
|
"{ \\\n"
|
||||||
" mediump vec2 texSize = vec2(textureSize(tex,0)); \n"
|
" mediump vec2 texSize = vec2(textureSize(tex,0)); \\\n"
|
||||||
" mediump vec2 texelSize = vec2(1.0) / texSize; \n"
|
" mediump vec2 texelSize = vec2(1.0) / texSize; \\\n"
|
||||||
" lowp vec4 c = texture(tex, texCoord); \n"
|
" lowp vec4 c = texture(tex, texCoord); \\\n"
|
||||||
" if (abs(texCoord.s - uTextureBounds[0]) < texelSize.x || abs(texCoord.s - uTextureBounds[2]) < texelSize.x) return c; \n"
|
" if (abs(texCoord.s - uTextureBounds[0]) < texelSize.x || abs(texCoord.s - uTextureBounds[2]) < texelSize.x){ \\\n"
|
||||||
" if (abs(texCoord.t - uTextureBounds[1]) < texelSize.y || abs(texCoord.t - uTextureBounds[3]) < texelSize.y) return c; \n"
|
" name = c; \\\n"
|
||||||
" \n"
|
" } else if (abs(texCoord.t - uTextureBounds[1]) < texelSize.y || abs(texCoord.t - uTextureBounds[3]) < texelSize.y){ \\\n"
|
||||||
" mediump vec2 offset = fract(texCoord*texSize - vec2(0.5)); \n"
|
" name = c; \\\n"
|
||||||
" offset -= step(1.0, offset.x + offset.y); \n"
|
" } else { \\\n"
|
||||||
" lowp vec4 zero = vec4(0.0); \n"
|
" mediump vec2 offset = fract(texCoord*texSize - vec2(0.5)); \\\n"
|
||||||
" lowp vec4 c0 = TEX_OFFSET(offset); \n"
|
" offset -= step(1.0, offset.x + offset.y); \\\n"
|
||||||
" lowp vec4 c1 = TEX_OFFSET(vec2(offset.x - sign(offset.x), offset.y)); \n"
|
" lowp vec4 zero = vec4(0.0); \\\n"
|
||||||
" lowp vec4 c2 = TEX_OFFSET(vec2(offset.x, offset.y - sign(offset.y))); \n"
|
" lowp vec4 c0 = TEX_OFFSET(offset, tex, texCoord, texSize); \\\n"
|
||||||
" return c0 + abs(offset.x)*(c1-c0) + abs(offset.y)*(c2-c0); \n"
|
" lowp vec4 c1 = TEX_OFFSET(vec2(offset.x - sign(offset.x), offset.y), tex, texCoord, texSize); \\\n"
|
||||||
"} \n"
|
" lowp vec4 c2 = TEX_OFFSET(vec2(offset.x, offset.y - sign(offset.y)), tex, texCoord, texSize); \\\n"
|
||||||
|
" name = c0 + abs(offset.x)*(c1-c0) + abs(offset.y)*(c2-c0); \\\n"
|
||||||
|
" } \\\n"
|
||||||
|
"} \\\n"
|
||||||
" \n"
|
" \n"
|
||||||
;
|
;
|
||||||
|
|
||||||
const char * strTexrectDrawerTexBilinearFilter =
|
const char * strTexrectDrawerTexBilinearFilter =
|
||||||
MAIN_SHADER_VERSION
|
MAIN_SHADER_VERSION
|
||||||
"uniform mediump vec4 uTextureBounds; \n"
|
"uniform mediump vec4 uTextureBounds; \n"
|
||||||
"#define TEX_OFFSET(off) texture(tex, texCoord - (off)/texSize) \n"
|
"#define TEX_OFFSET(off, tex, texCoord, texSize) texture(tex, texCoord - (off)/texSize) \n"
|
||||||
"lowp vec4 texFilter(in sampler2D tex, in mediump vec2 texCoord) \n"
|
"#define TEX_FILTER(name, tex, texCoord) \\\n"
|
||||||
"{ \n"
|
"{ \\\n"
|
||||||
" mediump vec2 texSize = vec2(textureSize(tex,0)); \n"
|
" mediump vec2 texSize = vec2(textureSize(tex,0)); \\\n"
|
||||||
" mediump vec2 texelSize = vec2(1.0) / texSize; \n"
|
" mediump vec2 texelSize = vec2(1.0) / texSize; \\\n"
|
||||||
" lowp vec4 c = texture(tex, texCoord); \n"
|
" lowp vec4 c = texture(tex, texCoord); \\\n"
|
||||||
" if (abs(texCoord.s - uTextureBounds[0]) < texelSize.x || abs(texCoord.s - uTextureBounds[2]) < texelSize.x) return c; \n"
|
" if (abs(texCoord.s - uTextureBounds[0]) < texelSize.x || abs(texCoord.s - uTextureBounds[2]) < texelSize.x){ \\\n"
|
||||||
" if (abs(texCoord.t - uTextureBounds[1]) < texelSize.y || abs(texCoord.t - uTextureBounds[3]) < texelSize.y) return c; \n"
|
" name = c; \\\n"
|
||||||
" \n"
|
" } else if (abs(texCoord.t - uTextureBounds[1]) < texelSize.y || abs(texCoord.t - uTextureBounds[3]) < texelSize.y){ \\\n"
|
||||||
" mediump vec2 offset = fract(texCoord*texSize - vec2(0.5)); \n"
|
" name = c; \\\n"
|
||||||
" offset -= step(1.0, offset.x + offset.y); \n"
|
" } else { \\\n"
|
||||||
" lowp vec4 zero = vec4(0.0); \n"
|
" mediump vec2 offset = fract(texCoord*texSize - vec2(0.5)); \\\n"
|
||||||
" \n"
|
" offset -= step(1.0, offset.x + offset.y); \\\n"
|
||||||
" lowp vec4 p0q0 = TEX_OFFSET(offset); \n"
|
" lowp vec4 zero = vec4(0.0); \\\n"
|
||||||
" lowp vec4 p1q0 = TEX_OFFSET(vec2(offset.x - sign(offset.x), offset.y)); \n"
|
" \\\n"
|
||||||
" \n"
|
" lowp vec4 p0q0 = TEX_OFFSET(offset, tex, texCoord, texSize); \\\n"
|
||||||
" lowp vec4 p0q1 = TEX_OFFSET(vec2(offset.x, offset.y - sign(offset.y))); \n"
|
" lowp vec4 p1q0 = TEX_OFFSET(vec2(offset.x - sign(offset.x), offset.y), tex, texCoord, texSize); \\\n"
|
||||||
" lowp vec4 p1q1 = TEX_OFFSET(vec2(offset.x - sign(offset.x), offset.y - sign(offset.y))); \n"
|
" \\\n"
|
||||||
" \n"
|
" lowp vec4 p0q1 = TEX_OFFSET(vec2(offset.x, offset.y - sign(offset.y)), tex, texCoord, texSize); \\\n"
|
||||||
" mediump vec2 interpolationFactor = abs(offset); \n"
|
" lowp vec4 p1q1 = TEX_OFFSET(vec2(offset.x - sign(offset.x), offset.y - sign(offset.y)), tex, texCoord, texSize); \\\n"
|
||||||
" lowp vec4 pInterp_q0 = mix( p0q0, p1q0, interpolationFactor.x ); // Interpolates top row in X direction. \n"
|
" \\\n"
|
||||||
" lowp vec4 pInterp_q1 = mix( p0q1, p1q1, interpolationFactor.x ); // Interpolates bottom row in X direction. \n"
|
" mediump vec2 interpolationFactor = abs(offset); \\\n"
|
||||||
" return mix( pInterp_q0, pInterp_q1, interpolationFactor.y ); // Interpolate in Y direction. \n"
|
" lowp vec4 pInterp_q0 = mix( p0q0, p1q0, interpolationFactor.x ); \\\n" // Interpolates top row in X direction.
|
||||||
"} \n"
|
" lowp vec4 pInterp_q1 = mix( p0q1, p1q1, interpolationFactor.x ); \\\n" // Interpolates bottom row in X direction.
|
||||||
|
" name = mix( pInterp_q0, pInterp_q1, interpolationFactor.y ); \\\n" // Interpolate in Y direction.
|
||||||
|
" } \\\n"
|
||||||
|
"} \\\n"
|
||||||
" \n"
|
" \n"
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -801,7 +807,7 @@ const char * strTexrectDrawerFragmentShaderTex =
|
||||||
"out lowp vec4 fragColor; \n"
|
"out lowp vec4 fragColor; \n"
|
||||||
"void main() \n"
|
"void main() \n"
|
||||||
"{ \n"
|
"{ \n"
|
||||||
" fragColor = texFilter(uTex0, vTexCoord0); \n"
|
" TEX_FILTER(fragColor, uTex0, vTexCoord0); \n"
|
||||||
" if (fragColor == uTestColor) discard; \n"
|
" if (fragColor == uTestColor) discard; \n"
|
||||||
" if (uEnableAlphaTest == 1 && !(fragColor.a > 0.0)) discard; \n"
|
" if (uEnableAlphaTest == 1 && !(fragColor.a > 0.0)) discard; \n"
|
||||||
"} \n"
|
"} \n"
|
||||||
|
|
|
@ -63,11 +63,17 @@ GLuint createShaderProgram(const char * _strVertex, const char * _strFragment)
|
||||||
glCompileShader(vertex_shader_object);
|
glCompileShader(vertex_shader_object);
|
||||||
assert(checkShaderCompileStatus(vertex_shader_object));
|
assert(checkShaderCompileStatus(vertex_shader_object));
|
||||||
|
|
||||||
|
if (!checkShaderCompileStatus(vertex_shader_object))
|
||||||
|
logErrorShader(GL_VERTEX_SHADER, _strVertex);
|
||||||
|
|
||||||
GLuint fragment_shader_object = glCreateShader(GL_FRAGMENT_SHADER);
|
GLuint fragment_shader_object = glCreateShader(GL_FRAGMENT_SHADER);
|
||||||
glShaderSource(fragment_shader_object, 1, &_strFragment, nullptr);
|
glShaderSource(fragment_shader_object, 1, &_strFragment, nullptr);
|
||||||
glCompileShader(fragment_shader_object);
|
glCompileShader(fragment_shader_object);
|
||||||
assert(checkShaderCompileStatus(fragment_shader_object));
|
assert(checkShaderCompileStatus(fragment_shader_object));
|
||||||
|
|
||||||
|
if (!checkShaderCompileStatus(fragment_shader_object))
|
||||||
|
logErrorShader(GL_VERTEX_SHADER, _strFragment);
|
||||||
|
|
||||||
GLuint program = glCreateProgram();
|
GLuint program = glCreateProgram();
|
||||||
glBindAttribLocation(program, SC_POSITION, "aPosition");
|
glBindAttribLocation(program, SC_POSITION, "aPosition");
|
||||||
glBindAttribLocation(program, SC_TEXCOORD0, "aTexCoord0");
|
glBindAttribLocation(program, SC_TEXCOORD0, "aTexCoord0");
|
||||||
|
|
|
@ -20,6 +20,8 @@
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
#include "GLSLCombiner.h"
|
#include "GLSLCombiner.h"
|
||||||
#include "ShaderUtils.h"
|
#include "ShaderUtils.h"
|
||||||
|
#include <FBOTextureFormats.h>
|
||||||
|
#include "Log.h"
|
||||||
|
|
||||||
struct point {
|
struct point {
|
||||||
GLfloat x;
|
GLfloat x;
|
||||||
|
@ -45,8 +47,10 @@ struct point {
|
||||||
|
|
||||||
#ifdef GLES2
|
#ifdef GLES2
|
||||||
const GLenum monohromeformat = GL_LUMINANCE;
|
const GLenum monohromeformat = GL_LUMINANCE;
|
||||||
|
const GLenum monohromeInternalformat = GL_LUMINANCE;
|
||||||
#else
|
#else
|
||||||
const GLenum monohromeformat = GL_RED;
|
const GLenum monohromeformat = GL_RED;
|
||||||
|
const GLenum monohromeInternalformat = GL_R8;
|
||||||
#endif // GLES2
|
#endif // GLES2
|
||||||
|
|
||||||
static
|
static
|
||||||
|
@ -153,7 +157,7 @@ struct Atlas {
|
||||||
glGenTextures(1, &tex);
|
glGenTextures(1, &tex);
|
||||||
glBindTexture(GL_TEXTURE_2D, tex);
|
glBindTexture(GL_TEXTURE_2D, tex);
|
||||||
|
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, monohromeformat, w, h, 0, monohromeformat, GL_UNSIGNED_BYTE, 0);
|
glTexImage2D(GL_TEXTURE_2D, 0, monohromeInternalformat, w, h, 0, monohromeformat, GL_UNSIGNED_BYTE, 0);
|
||||||
|
|
||||||
/* We require 1 byte alignment when uploading texture data */
|
/* We require 1 byte alignment when uploading texture data */
|
||||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user