mirror of
https://github.com/blawar/GLideN64.git
synced 2024-07-04 10:03:36 +00:00
use gl_LastFragDepthARM and glTextureBarrier
This commit is contained in:
parent
18e9a73eba
commit
c01c0d5166
|
@ -314,6 +314,7 @@ CachedTexture * DepthBuffer::copyDepthBufferTexture(FrameBuffer * _pBuffer)
|
|||
void DepthBuffer::activateDepthBufferTexture(FrameBuffer * _pBuffer)
|
||||
{
|
||||
textureCache().activateTexture(0, resolveDepthBufferTexture(_pBuffer));
|
||||
gfxContext.textureBarrier();
|
||||
}
|
||||
|
||||
void DepthBuffer::bindDepthImageTexture()
|
||||
|
|
|
@ -1278,6 +1278,7 @@ void FrameBuffer_ActivateBufferTexture(u32 t, u32 _frameBufferAddress)
|
|||
|
||||
// frameBufferList().renderBuffer(pBuffer->m_startAddress);
|
||||
textureCache().activateTexture(t, pTexture);
|
||||
gfxContext.textureBarrier();
|
||||
gDP.changed |= CHANGED_FB_TEXTURE;
|
||||
}
|
||||
|
||||
|
@ -1293,6 +1294,7 @@ void FrameBuffer_ActivateBufferTextureBG(u32 t, u32 _frameBufferAddress)
|
|||
|
||||
// frameBufferList().renderBuffer(pBuffer->m_startAddress);
|
||||
textureCache().activateTexture(t, pTexture);
|
||||
gfxContext.textureBarrier();
|
||||
gDP.changed |= CHANGED_FB_TEXTURE;
|
||||
}
|
||||
|
||||
|
|
|
@ -167,6 +167,11 @@ u32 Context::convertInternalTextureFormat(u32 _format) const
|
|||
return m_impl->convertInternalTextureFormat(_format);
|
||||
}
|
||||
|
||||
void Context::textureBarrier()
|
||||
{
|
||||
m_impl->textureBarrier();
|
||||
}
|
||||
|
||||
/*---------------Framebuffer-------------*/
|
||||
|
||||
const FramebufferTextureFormats & Context::getFramebufferTextureFormats()
|
||||
|
|
|
@ -152,6 +152,8 @@ namespace graphics {
|
|||
|
||||
u32 convertInternalTextureFormat(u32 _format) const;
|
||||
|
||||
void textureBarrier();
|
||||
|
||||
/*---------------Framebuffer-------------*/
|
||||
|
||||
const FramebufferTextureFormats & getFramebufferTextureFormats();
|
||||
|
|
|
@ -37,6 +37,7 @@ namespace graphics {
|
|||
virtual s32 getMaxTextureSize() const = 0;
|
||||
virtual void bindImageTexture(const Context::BindImageTextureParameters & _params) = 0;
|
||||
virtual u32 convertInternalTextureFormat(u32 _format) const = 0;
|
||||
virtual void textureBarrier() = 0;
|
||||
virtual FramebufferTextureFormats * getFramebufferTextureFormats() = 0;
|
||||
virtual ObjectHandle createFramebuffer() = 0;
|
||||
virtual void deleteFramebuffer(ObjectHandle _name) = 0;
|
||||
|
|
|
@ -190,6 +190,8 @@ PFNGLCREATEFRAMEBUFFERSPROC g_glCreateFramebuffers;
|
|||
PFNGLNAMEDFRAMEBUFFERTEXTUREPROC g_glNamedFramebufferTexture;
|
||||
PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC g_glDrawRangeElementsBaseVertex;
|
||||
PFNGLFLUSHMAPPEDBUFFERRANGEPROC g_glFlushMappedBufferRange;
|
||||
PFNGLTEXTUREBARRIERPROC g_glTextureBarrier;
|
||||
PFNGLTEXTUREBARRIERNVPROC g_glTextureBarrierNV;
|
||||
|
||||
void initGLFunctions()
|
||||
{
|
||||
|
@ -330,4 +332,6 @@ void initGLFunctions()
|
|||
GL_GET_PROC_ADR(PFNGLNAMEDFRAMEBUFFERTEXTUREPROC, glNamedFramebufferTexture);
|
||||
GL_GET_PROC_ADR(PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC, glDrawRangeElementsBaseVertex);
|
||||
GL_GET_PROC_ADR(PFNGLFLUSHMAPPEDBUFFERRANGEPROC, glFlushMappedBufferRange);
|
||||
GL_GET_PROC_ADR(PFNGLTEXTUREBARRIERPROC, glTextureBarrier);
|
||||
GL_GET_PROC_ADR(PFNGLTEXTUREBARRIERNVPROC, glTextureBarrierNV);
|
||||
}
|
||||
|
|
|
@ -214,6 +214,8 @@ extern PFNGLBLENDCOLORPROC g_glBlendColor;
|
|||
#define glNamedFramebufferTexture(...) CHECKED_GL_FUNCTION(g_glNamedFramebufferTexture, __VA_ARGS__)
|
||||
#define glDrawRangeElementsBaseVertex(...) CHECKED_GL_FUNCTION(g_glDrawRangeElementsBaseVertex, __VA_ARGS__)
|
||||
#define glFlushMappedBufferRange(...) CHECKED_GL_FUNCTION(g_glFlushMappedBufferRange, __VA_ARGS__)
|
||||
#define glTextureBarrier(...) CHECKED_GL_FUNCTION(g_glTextureBarrier, __VA_ARGS__)
|
||||
#define glTextureBarrierNV(...) CHECKED_GL_FUNCTION(g_glTextureBarrierNV, __VA_ARGS__)
|
||||
|
||||
extern PFNGLCREATESHADERPROC g_glCreateShader;
|
||||
extern PFNGLCOMPILESHADERPROC g_glCompileShader;
|
||||
|
@ -308,6 +310,8 @@ extern PFNGLCREATEFRAMEBUFFERSPROC g_glCreateFramebuffers;
|
|||
extern PFNGLNAMEDFRAMEBUFFERTEXTUREPROC g_glNamedFramebufferTexture;
|
||||
extern PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC g_glDrawRangeElementsBaseVertex;
|
||||
extern PFNGLFLUSHMAPPEDBUFFERRANGEPROC g_glFlushMappedBufferRange;
|
||||
extern PFNGLTEXTUREBARRIERPROC g_glTextureBarrier;
|
||||
extern PFNGLTEXTUREBARRIERNVPROC g_glTextureBarrierNV;
|
||||
|
||||
void initGLFunctions();
|
||||
|
||||
|
|
|
@ -63,8 +63,18 @@ namespace glsl {
|
|||
"OUT lowp vec4 fragColor; \n"
|
||||
"lowp float get_alpha() \n"
|
||||
"{ \n"
|
||||
" mediump ivec2 coord = ivec2(gl_FragCoord.xy); \n"
|
||||
" highp float bufZ = texelFetch(uDepthImage,coord, 0).r; \n"
|
||||
;
|
||||
if (_glinfo.fetch_depth) {
|
||||
m_part +=
|
||||
" highp float bufZ = gl_LastFragDepthARM; \n"
|
||||
;
|
||||
} else {
|
||||
m_part +=
|
||||
" mediump ivec2 coord = ivec2(gl_FragCoord.xy); \n"
|
||||
" highp float bufZ = texelFetch(uDepthImage,coord, 0).r; \n"
|
||||
;
|
||||
}
|
||||
m_part +=
|
||||
" highp int iZ = bufZ > 0.999 ? 262143 : int(floor(bufZ * 262143.0));\n"
|
||||
" mediump int y0 = clamp(iZ/512, 0, 511); \n"
|
||||
" mediump int x0 = iZ - 512*y0; \n"
|
||||
|
@ -79,6 +89,9 @@ namespace glsl {
|
|||
" fragColor = vec4(uFogColor.rgb, get_alpha()); \n"
|
||||
"} \n"
|
||||
;
|
||||
|
||||
if (_glinfo.fetch_depth)
|
||||
m_part = "#extension GL_ARM_shader_framebuffer_fetch_depth_stencil : enable \n" + m_part;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -276,6 +276,14 @@ u32 ContextImpl::convertInternalTextureFormat(u32 _format) const
|
|||
return _format;
|
||||
}
|
||||
|
||||
void ContextImpl::textureBarrier()
|
||||
{
|
||||
if (m_glInfo.texture_barrier)
|
||||
glTextureBarrier();
|
||||
else if (m_glInfo.texture_barrierNV)
|
||||
glTextureBarrierNV();
|
||||
}
|
||||
|
||||
/*---------------Framebuffer-------------*/
|
||||
|
||||
graphics::FramebufferTextureFormats * ContextImpl::getFramebufferTextureFormats()
|
||||
|
|
|
@ -76,6 +76,8 @@ namespace opengl {
|
|||
|
||||
u32 convertInternalTextureFormat(u32 _format) const override;
|
||||
|
||||
void textureBarrier() override;
|
||||
|
||||
/*---------------Framebuffer-------------*/
|
||||
|
||||
graphics::FramebufferTextureFormats * getFramebufferTextureFormats() override;
|
||||
|
|
|
@ -102,4 +102,8 @@ void GLInfo::init() {
|
|||
|
||||
depthTexture = !isGLES2 || Utils::isExtensionSupported(*this, "GL_OES_depth_texture");
|
||||
noPerspective = Utils::isExtensionSupported(*this, "GL_NV_shader_noperspective_interpolation");
|
||||
|
||||
fetch_depth = Utils::isExtensionSupported(*this, "GL_ARM_shader_framebuffer_fetch_depth_stencil");
|
||||
texture_barrier = (!isGLESX && numericVersion >= 45) || Utils::isExtensionSupported(*this, "GL_ARB_texture_barrier");
|
||||
texture_barrierNV = Utils::isExtensionSupported(*this, "GL_NV_texture_barrier");
|
||||
}
|
||||
|
|
|
@ -25,6 +25,9 @@ struct GLInfo {
|
|||
bool msaa = false;
|
||||
bool depthTexture = false;
|
||||
bool noPerspective = false;
|
||||
bool fetch_depth = false;
|
||||
bool texture_barrier = false;
|
||||
bool texture_barrierNV = false;
|
||||
Renderer renderer = Renderer::Other;
|
||||
|
||||
void init();
|
||||
|
|
Loading…
Reference in New Issue
Block a user