mirror of
https://github.com/blawar/GLideN64.git
synced 2024-07-04 10:03:36 +00:00
Fix compilation of depth_compare_shader_float for GL ES 3.1
Note: the shader does not work properly yet on Android
This commit is contained in:
parent
e4b440ea1d
commit
5e56691dcf
|
@ -74,11 +74,11 @@ void DepthBuffer::initDepthImageTexture(FrameBuffer * _pBuffer)
|
|||
m_pDepthImageTexture->mirrorT = 0;
|
||||
m_pDepthImageTexture->realWidth = m_pDepthImageTexture->width;
|
||||
m_pDepthImageTexture->realHeight = m_pDepthImageTexture->height;
|
||||
m_pDepthImageTexture->textureBytes = m_pDepthImageTexture->realWidth * m_pDepthImageTexture->realHeight * 2 * sizeof(float); // Width*Height*RG*sizeof(GL_RGBA32F)
|
||||
m_pDepthImageTexture->textureBytes = m_pDepthImageTexture->realWidth * m_pDepthImageTexture->realHeight * fboFormats.depthImageFormatBytes;
|
||||
textureCache().addFrameBufferTextureSize(m_pDepthImageTexture->textureBytes);
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, m_pDepthImageTexture->glName);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RG32F, m_pDepthImageTexture->realWidth, m_pDepthImageTexture->realHeight, 0, GL_RG, GL_FLOAT, NULL);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, fboFormats.depthImageInternalFormat, m_pDepthImageTexture->realWidth, m_pDepthImageTexture->realHeight, 0, fboFormats.depthImageFormat, fboFormats.depthImageType, NULL);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
|
@ -218,7 +218,7 @@ void DepthBuffer::activateDepthBufferTexture(FrameBuffer * _pBuffer)
|
|||
void DepthBuffer::bindDepthImageTexture()
|
||||
{
|
||||
#ifdef GL_IMAGE_TEXTURES_SUPPORT
|
||||
glBindImageTexture(depthImageUnit, m_pDepthImageTexture->glName, 0, GL_FALSE, 0, GL_READ_WRITE, GL_RG32F);
|
||||
glBindImageTexture(depthImageUnit, m_pDepthImageTexture->glName, 0, GL_FALSE, 0, GL_READ_WRITE, fboFormats.depthImageInternalFormat);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -335,13 +335,13 @@ void DepthBufferList::clearBuffer(u32 _uly, u32 _lry)
|
|||
if (m_pCurrent->m_FBO == 0 || !video().getRender().isImageTexturesSupported() || config.frameBufferEmulation.N64DepthCompare == 0)
|
||||
return;
|
||||
float color[4] = {1.0f, 1.0f, 0.0f, 1.0f};
|
||||
glBindImageTexture(depthImageUnit, 0, 0, GL_FALSE, 0, GL_READ_WRITE, GL_RG32F);
|
||||
glBindImageTexture(depthImageUnit, 0, 0, GL_FALSE, 0, GL_READ_WRITE, fboFormats.depthImageInternalFormat);
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_pCurrent->m_FBO);
|
||||
const u32 cycleType = gDP.otherMode.cycleType;
|
||||
gDP.otherMode.cycleType = G_CYC_FILL;
|
||||
video().getRender().drawRect(0,0,VI.width, VI.height, color);
|
||||
gDP.otherMode.cycleType = cycleType;
|
||||
glBindImageTexture(depthImageUnit, m_pCurrent->m_pDepthImageTexture->glName, 0, GL_FALSE, 0, GL_READ_WRITE, GL_RG32F);
|
||||
glBindImageTexture(depthImageUnit, m_pCurrent->m_pDepthImageTexture->glName, 0, GL_FALSE, 0, GL_READ_WRITE, fboFormats.depthImageInternalFormat);
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, frameBufferList().getCurrent()->m_FBO);
|
||||
#endif // GL_IMAGE_TEXTURES_SUPPORT
|
||||
}
|
||||
|
|
|
@ -499,6 +499,9 @@ static const char* fragment_shader_dummy_noise =
|
|||
static const char* depth_compare_shader_float =
|
||||
#ifndef GLESX
|
||||
"#version 430 \n"
|
||||
"layout(binding = 2, rg32f) uniform coherent image2D uDepthImage;\n"
|
||||
#else
|
||||
"layout(binding = 2, rgba32f) highp uniform coherent image2D uDepthImage;\n"
|
||||
#endif
|
||||
//"uniform int uEnableDepth; \n"
|
||||
"uniform lowp int uDepthMode; \n"
|
||||
|
@ -506,7 +509,6 @@ static const char* depth_compare_shader_float =
|
|||
"uniform lowp int uEnableDepthCompare; \n"
|
||||
"uniform lowp int uEnableDepthUpdate; \n"
|
||||
"uniform mediump float uDeltaZ; \n"
|
||||
"layout(binding = 2, rg32f) uniform coherent image2D uDepthImage;\n"
|
||||
"bool depth_compare() \n"
|
||||
"{ \n"
|
||||
//" if (uEnableDepth == 0) return true; \n"
|
||||
|
@ -521,10 +523,10 @@ static const char* depth_compare_shader_float =
|
|||
" dz = 4.0*fwidth(gl_FragDepth); \n"
|
||||
" dzMin = min(dz, depth.g); \n"
|
||||
" } \n"
|
||||
" const bool bInfront = curZ < bufZ; \n"
|
||||
" const bool bFarther = (curZ + dzMin) >= bufZ; \n"
|
||||
" const bool bNearer = (curZ - dzMin) <= bufZ; \n"
|
||||
" const bool bMax = bufZ == 1.0; \n"
|
||||
" bool bInfront = curZ < bufZ; \n"
|
||||
" bool bFarther = (curZ + dzMin) >= bufZ; \n"
|
||||
" bool bNearer = (curZ - dzMin) <= bufZ; \n"
|
||||
" bool bMax = bufZ == 1.0; \n"
|
||||
" bool bRes; \n"
|
||||
" switch (uDepthMode) { \n"
|
||||
" case 1: \n"
|
||||
|
@ -576,7 +578,7 @@ MAIN_SHADER_VERSION
|
|||
" highp float n64z = clamp(float(iN64z)/65532.0, 0.0, 1.0);\n"
|
||||
" highp int index = min(255, int(n64z*255.0)); \n"
|
||||
" highp uint iAlpha = imageLoad(uTlutImage,ivec2(index,0)).r;\n"
|
||||
" return float(iAlpha/uint(256))/255.0; \n"
|
||||
" return float(iAlpha>>8)/255.0; \n"
|
||||
"} \n"
|
||||
"void main() \n"
|
||||
"{ \n"
|
||||
|
|
|
@ -1186,6 +1186,11 @@ void FBOTextureFormats::init()
|
|||
depthType = GL_FLOAT;
|
||||
depthFormatBytes = 4;
|
||||
|
||||
depthImageInternalFormat = GL_RGBA32F;
|
||||
depthImageFormat = GL_RGBA;
|
||||
depthImageType = GL_FLOAT;
|
||||
depthImageFormatBytes = 16;
|
||||
|
||||
lutInternalFormat = GL_R32UI;
|
||||
lutFormat = GL_RED;
|
||||
lutType = GL_UNSIGNED_INT;
|
||||
|
@ -1206,6 +1211,11 @@ void FBOTextureFormats::init()
|
|||
depthType = GL_FLOAT;
|
||||
depthFormatBytes = 4;
|
||||
|
||||
depthImageInternalFormat = GL_RG32F;
|
||||
depthImageFormat = GL_RG;
|
||||
depthImageType = GL_FLOAT;
|
||||
depthImageFormatBytes = 8;
|
||||
|
||||
lutInternalFormat = GL_R16;
|
||||
lutFormat = GL_RED;
|
||||
lutType = GL_UNSIGNED_SHORT;
|
||||
|
|
|
@ -236,6 +236,11 @@ struct FBOTextureFormats
|
|||
GLenum depthType;
|
||||
u32 depthFormatBytes;
|
||||
|
||||
GLint depthImageInternalFormat;
|
||||
GLenum depthImageFormat;
|
||||
GLenum depthImageType;
|
||||
u32 depthImageFormatBytes;
|
||||
|
||||
GLint lutInternalFormat;
|
||||
GLenum lutFormat;
|
||||
GLenum lutType;
|
||||
|
|
Loading…
Reference in New Issue
Block a user