mirror of
https://github.com/blawar/GLideN64.git
synced 2024-07-04 10:03:36 +00:00
Common implementation of N64 depth compare for Full GL and GLES
Also, fix small typo.
This commit is contained in:
parent
b6067bb90d
commit
8b08bddb91
|
@ -17,25 +17,31 @@
|
||||||
using namespace graphics;
|
using namespace graphics;
|
||||||
|
|
||||||
DepthBuffer::DepthBuffer() : m_address(0), m_width(0), m_ulx(0), m_uly(0), m_lrx(0), m_lry(0),
|
DepthBuffer::DepthBuffer() : m_address(0), m_width(0), m_ulx(0), m_uly(0), m_lrx(0), m_lry(0),
|
||||||
m_pDepthImageTexture(nullptr), m_pDepthBufferTexture(nullptr), m_depthRenderbufferWidth(0),
|
m_pDepthImageZTexture(nullptr), m_pDepthImageDeltaZTexture(nullptr), m_pDepthBufferTexture(nullptr),
|
||||||
m_cleared(false), m_pResolveDepthBufferTexture(nullptr), m_resolved(false),
|
m_depthRenderbufferWidth(0), m_cleared(false), m_pResolveDepthBufferTexture(nullptr), m_resolved(false),
|
||||||
m_pDepthBufferCopyTexture(nullptr), m_copied(false)
|
m_pDepthBufferCopyTexture(nullptr), m_copied(false)
|
||||||
{
|
{
|
||||||
m_copyFBO = gfxContext.createFramebuffer();
|
m_copyFBO = gfxContext.createFramebuffer();
|
||||||
if (config.frameBufferEmulation.N64DepthCompare != 0)
|
if (config.frameBufferEmulation.N64DepthCompare != 0) {
|
||||||
m_depthImageFBO = gfxContext.createFramebuffer();
|
m_depthImageZFBO = gfxContext.createFramebuffer();
|
||||||
|
m_depthImageDeltaZFBO = gfxContext.createFramebuffer();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DepthBuffer::DepthBuffer(DepthBuffer && _other) :
|
DepthBuffer::DepthBuffer(DepthBuffer && _other) :
|
||||||
m_address(_other.m_address), m_width(_other.m_width),
|
m_address(_other.m_address), m_width(_other.m_width),
|
||||||
m_ulx(_other.m_ulx), m_uly(_other.m_uly), m_lrx(_other.m_lrx), m_lry(_other.m_lry),
|
m_ulx(_other.m_ulx), m_uly(_other.m_uly), m_lrx(_other.m_lrx), m_lry(_other.m_lry),
|
||||||
m_depthImageFBO(_other.m_depthImageFBO), m_pDepthImageTexture(_other.m_pDepthImageTexture), m_pDepthBufferTexture(_other.m_pDepthBufferTexture),
|
m_depthImageZFBO(_other.m_depthImageZFBO), m_depthImageDeltaZFBO(_other.m_depthImageDeltaZFBO),
|
||||||
|
m_pDepthImageZTexture(_other.m_pDepthImageZTexture),
|
||||||
|
m_pDepthImageDeltaZTexture(_other.m_pDepthImageDeltaZTexture), m_pDepthBufferTexture(_other.m_pDepthBufferTexture),
|
||||||
m_depthRenderbuffer(_other.m_depthRenderbuffer), m_depthRenderbufferWidth(_other.m_depthRenderbufferWidth),
|
m_depthRenderbuffer(_other.m_depthRenderbuffer), m_depthRenderbufferWidth(_other.m_depthRenderbufferWidth),
|
||||||
m_cleared(_other.m_cleared), m_pResolveDepthBufferTexture(_other.m_pResolveDepthBufferTexture), m_resolved(_other.m_resolved),
|
m_cleared(_other.m_cleared), m_pResolveDepthBufferTexture(_other.m_pResolveDepthBufferTexture), m_resolved(_other.m_resolved),
|
||||||
m_pDepthBufferCopyTexture(_other.m_pDepthBufferCopyTexture), m_copied(_other.m_copied)
|
m_pDepthBufferCopyTexture(_other.m_pDepthBufferCopyTexture), m_copied(_other.m_copied)
|
||||||
{
|
{
|
||||||
_other.m_depthImageFBO = ObjectHandle();
|
_other.m_depthImageZFBO = ObjectHandle();
|
||||||
_other.m_pDepthImageTexture = nullptr;
|
_other.m_depthImageDeltaZFBO = ObjectHandle();
|
||||||
|
_other.m_pDepthImageZTexture = nullptr;
|
||||||
|
_other.m_pDepthImageDeltaZTexture = nullptr;
|
||||||
_other.m_pDepthBufferTexture = nullptr;
|
_other.m_pDepthBufferTexture = nullptr;
|
||||||
_other.m_depthRenderbuffer = ObjectHandle();
|
_other.m_depthRenderbuffer = ObjectHandle();
|
||||||
_other.m_pResolveDepthBufferTexture = nullptr;
|
_other.m_pResolveDepthBufferTexture = nullptr;
|
||||||
|
@ -46,48 +52,47 @@ DepthBuffer::DepthBuffer(DepthBuffer && _other) :
|
||||||
|
|
||||||
DepthBuffer::~DepthBuffer()
|
DepthBuffer::~DepthBuffer()
|
||||||
{
|
{
|
||||||
gfxContext.deleteFramebuffer(m_depthImageFBO);
|
gfxContext.deleteFramebuffer(m_depthImageZFBO);
|
||||||
|
gfxContext.deleteFramebuffer(m_depthImageDeltaZFBO);
|
||||||
gfxContext.deleteFramebuffer(m_depthRenderbuffer);
|
gfxContext.deleteFramebuffer(m_depthRenderbuffer);
|
||||||
gfxContext.deleteFramebuffer(m_copyFBO);
|
gfxContext.deleteFramebuffer(m_copyFBO);
|
||||||
|
|
||||||
textureCache().removeFrameBufferTexture(m_pDepthImageTexture);
|
textureCache().removeFrameBufferTexture(m_pDepthImageZTexture);
|
||||||
|
textureCache().removeFrameBufferTexture(m_pDepthImageDeltaZTexture);
|
||||||
textureCache().removeFrameBufferTexture(m_pDepthBufferTexture);
|
textureCache().removeFrameBufferTexture(m_pDepthBufferTexture);
|
||||||
textureCache().removeFrameBufferTexture(m_pResolveDepthBufferTexture);
|
textureCache().removeFrameBufferTexture(m_pResolveDepthBufferTexture);
|
||||||
textureCache().removeFrameBufferTexture(m_pDepthBufferCopyTexture);
|
textureCache().removeFrameBufferTexture(m_pDepthBufferCopyTexture);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DepthBuffer::initDepthImageTexture(FrameBuffer * _pBuffer)
|
void DepthBuffer::_initDepthImageTexture(FrameBuffer * _pBuffer, CachedTexture& _cachedTexture,
|
||||||
|
graphics::ObjectHandle& _depthImageFBO)
|
||||||
{
|
{
|
||||||
if (config.frameBufferEmulation.N64DepthCompare == 0 || m_pDepthImageTexture != nullptr)
|
|
||||||
return;
|
|
||||||
|
|
||||||
const FramebufferTextureFormats & fbTexFormat = gfxContext.getFramebufferTextureFormats();
|
const FramebufferTextureFormats & fbTexFormat = gfxContext.getFramebufferTextureFormats();
|
||||||
m_pDepthImageTexture = textureCache().addFrameBufferTexture(false);
|
|
||||||
|
|
||||||
m_pDepthImageTexture->width = (u32)(_pBuffer->m_pTexture->width);
|
_cachedTexture.width = (u32)(_pBuffer->m_pTexture->width);
|
||||||
m_pDepthImageTexture->height = (u32)(_pBuffer->m_pTexture->height);
|
_cachedTexture.height = (u32)(_pBuffer->m_pTexture->height);
|
||||||
m_pDepthImageTexture->format = 0;
|
_cachedTexture.format = 0;
|
||||||
m_pDepthImageTexture->size = 2;
|
_cachedTexture.size = 2;
|
||||||
m_pDepthImageTexture->clampS = 1;
|
_cachedTexture.clampS = 1;
|
||||||
m_pDepthImageTexture->clampT = 1;
|
_cachedTexture.clampT = 1;
|
||||||
m_pDepthImageTexture->address = _pBuffer->m_startAddress;
|
_cachedTexture.address = _pBuffer->m_startAddress;
|
||||||
m_pDepthImageTexture->clampWidth = _pBuffer->m_width;
|
_cachedTexture.clampWidth = _pBuffer->m_width;
|
||||||
m_pDepthImageTexture->clampHeight = _pBuffer->m_height;
|
_cachedTexture.clampHeight = _pBuffer->m_height;
|
||||||
m_pDepthImageTexture->frameBufferTexture = CachedTexture::fbOneSample;
|
_cachedTexture.frameBufferTexture = CachedTexture::fbOneSample;
|
||||||
m_pDepthImageTexture->maskS = 0;
|
_cachedTexture.maskS = 0;
|
||||||
m_pDepthImageTexture->maskT = 0;
|
_cachedTexture.maskT = 0;
|
||||||
m_pDepthImageTexture->mirrorS = 0;
|
_cachedTexture.mirrorS = 0;
|
||||||
m_pDepthImageTexture->mirrorT = 0;
|
_cachedTexture.mirrorT = 0;
|
||||||
m_pDepthImageTexture->realWidth = m_pDepthImageTexture->width;
|
_cachedTexture.realWidth = _cachedTexture.width;
|
||||||
m_pDepthImageTexture->realHeight = m_pDepthImageTexture->height;
|
_cachedTexture.realHeight = _cachedTexture.height;
|
||||||
m_pDepthImageTexture->textureBytes = m_pDepthImageTexture->realWidth * m_pDepthImageTexture->realHeight * fbTexFormat.depthImageFormatBytes;
|
_cachedTexture.textureBytes = _cachedTexture.realWidth * _cachedTexture.realHeight * fbTexFormat.depthImageFormatBytes;
|
||||||
textureCache().addFrameBufferTextureSize(m_pDepthImageTexture->textureBytes);
|
textureCache().addFrameBufferTextureSize(_cachedTexture.textureBytes);
|
||||||
|
|
||||||
{
|
{
|
||||||
Context::InitTextureParams params;
|
Context::InitTextureParams params;
|
||||||
params.handle = m_pDepthImageTexture->name;
|
params.handle = _cachedTexture.name;
|
||||||
params.width = m_pDepthImageTexture->realWidth;
|
params.width = _cachedTexture.realWidth;
|
||||||
params.height = m_pDepthImageTexture->realHeight;
|
params.height = _cachedTexture.realHeight;
|
||||||
params.internalFormat = fbTexFormat.depthImageInternalFormat;
|
params.internalFormat = fbTexFormat.depthImageInternalFormat;
|
||||||
params.format = fbTexFormat.depthImageFormat;
|
params.format = fbTexFormat.depthImageFormat;
|
||||||
params.dataType = fbTexFormat.depthImageType;
|
params.dataType = fbTexFormat.depthImageType;
|
||||||
|
@ -95,7 +100,7 @@ void DepthBuffer::initDepthImageTexture(FrameBuffer * _pBuffer)
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
Context::TexParameters params;
|
Context::TexParameters params;
|
||||||
params.handle =m_pDepthImageTexture->name;
|
params.handle = _cachedTexture.name;
|
||||||
params.target = textureTarget::TEXTURE_2D;
|
params.target = textureTarget::TEXTURE_2D;
|
||||||
params.textureUnitIndex = textureIndices::Tex[0];
|
params.textureUnitIndex = textureIndices::Tex[0];
|
||||||
params.minFilter = textureParameters::FILTER_NEAREST;
|
params.minFilter = textureParameters::FILTER_NEAREST;
|
||||||
|
@ -104,13 +109,25 @@ void DepthBuffer::initDepthImageTexture(FrameBuffer * _pBuffer)
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
Context::FrameBufferRenderTarget bufTarget;
|
Context::FrameBufferRenderTarget bufTarget;
|
||||||
bufTarget.bufferHandle = m_depthImageFBO;
|
bufTarget.bufferHandle = _depthImageFBO;
|
||||||
bufTarget.bufferTarget = bufferTarget::DRAW_FRAMEBUFFER;
|
bufTarget.bufferTarget = bufferTarget::DRAW_FRAMEBUFFER;
|
||||||
bufTarget.attachment = bufferAttachment::COLOR_ATTACHMENT0;
|
bufTarget.attachment = bufferAttachment::COLOR_ATTACHMENT0;
|
||||||
bufTarget.textureTarget = textureTarget::TEXTURE_2D;
|
bufTarget.textureTarget = textureTarget::TEXTURE_2D;
|
||||||
bufTarget.textureHandle = m_pDepthImageTexture->name;
|
bufTarget.textureHandle = _cachedTexture.name;
|
||||||
gfxContext.addFrameBufferRenderTarget(bufTarget);
|
gfxContext.addFrameBufferRenderTarget(bufTarget);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DepthBuffer::initDepthImageTexture(FrameBuffer * _pBuffer)
|
||||||
|
{
|
||||||
|
if (config.frameBufferEmulation.N64DepthCompare == 0 || m_pDepthImageZTexture != nullptr)
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_pDepthImageZTexture = textureCache().addFrameBufferTexture(false);
|
||||||
|
m_pDepthImageDeltaZTexture = textureCache().addFrameBufferTexture(false);
|
||||||
|
|
||||||
|
_initDepthImageTexture(_pBuffer, *m_pDepthImageZTexture, m_depthImageZFBO);
|
||||||
|
_initDepthImageTexture(_pBuffer, *m_pDepthImageDeltaZTexture, m_depthImageDeltaZFBO);
|
||||||
|
|
||||||
gfxContext.bindFramebuffer(bufferTarget::DRAW_FRAMEBUFFER, _pBuffer->m_FBO);
|
gfxContext.bindFramebuffer(bufferTarget::DRAW_FRAMEBUFFER, _pBuffer->m_FBO);
|
||||||
|
|
||||||
|
@ -342,11 +359,14 @@ void DepthBuffer::bindDepthImageTexture()
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Context::BindImageTextureParameters bindParams;
|
Context::BindImageTextureParameters bindParams;
|
||||||
bindParams.imageUnit = textureImageUnits::Depth;
|
bindParams.imageUnit = textureImageUnits::DepthZ;
|
||||||
bindParams.texture = m_pDepthImageTexture->name;
|
bindParams.texture = m_pDepthImageZTexture->name;
|
||||||
bindParams.accessMode = textureImageAccessMode::READ_WRITE;
|
bindParams.accessMode = textureImageAccessMode::READ_WRITE;
|
||||||
bindParams.textureFormat = gfxContext.getFramebufferTextureFormats().depthImageInternalFormat;
|
bindParams.textureFormat = gfxContext.getFramebufferTextureFormats().depthImageInternalFormat;
|
||||||
|
gfxContext.bindImageTexture(bindParams);
|
||||||
|
|
||||||
|
bindParams.imageUnit = textureImageUnits::DepthDeltaZ;
|
||||||
|
bindParams.texture = m_pDepthImageDeltaZTexture->name;
|
||||||
gfxContext.bindImageTexture(bindParams);
|
gfxContext.bindImageTexture(bindParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -471,26 +491,32 @@ void DepthBufferList::clearBuffer(u32 _ulx, u32 _uly, u32 _lrx, u32 _lry)
|
||||||
m_pCurrent->m_lrx = _lrx;
|
m_pCurrent->m_lrx = _lrx;
|
||||||
m_pCurrent->m_lry = _lry;
|
m_pCurrent->m_lry = _lry;
|
||||||
|
|
||||||
if (!m_pCurrent->m_depthImageFBO.isNotNull() || config.frameBufferEmulation.N64DepthCompare == 0)
|
if (!m_pCurrent->m_depthImageZFBO.isNotNull() || config.frameBufferEmulation.N64DepthCompare == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
||||||
Context::BindImageTextureParameters bindParams;
|
Context::BindImageTextureParameters bindParams;
|
||||||
bindParams.imageUnit = textureImageUnits::Depth;
|
bindParams.imageUnit = textureImageUnits::DepthZ;
|
||||||
bindParams.texture = ObjectHandle();
|
bindParams.texture = ObjectHandle();
|
||||||
bindParams.accessMode = textureImageAccessMode::READ_WRITE;
|
bindParams.accessMode = textureImageAccessMode::READ_WRITE;
|
||||||
bindParams.textureFormat = gfxContext.getFramebufferTextureFormats().depthImageInternalFormat;
|
bindParams.textureFormat = gfxContext.getFramebufferTextureFormats().depthImageInternalFormat;
|
||||||
gfxContext.bindImageTexture(bindParams);
|
gfxContext.bindImageTexture(bindParams);
|
||||||
|
bindParams.imageUnit = textureImageUnits::DepthDeltaZ;
|
||||||
gfxContext.bindFramebuffer(bufferTarget::DRAW_FRAMEBUFFER, m_pCurrent->m_depthImageFBO);
|
gfxContext.bindImageTexture(bindParams);
|
||||||
|
|
||||||
const u32 cycleType = gDP.otherMode.cycleType;
|
const u32 cycleType = gDP.otherMode.cycleType;
|
||||||
gDP.otherMode.cycleType = G_CYC_FILL;
|
gDP.otherMode.cycleType = G_CYC_FILL;
|
||||||
float color[4] = { 1.0f, 1.0f, 0.0f, 1.0f };
|
float color[4] = { 1.0f, 1.0f, 0.0f, 1.0f };
|
||||||
|
gfxContext.bindFramebuffer(bufferTarget::DRAW_FRAMEBUFFER, m_pCurrent->m_depthImageZFBO);
|
||||||
|
dwnd().getDrawer().drawRect(_ulx, _uly, _lrx, _lry, color);
|
||||||
|
gfxContext.bindFramebuffer(bufferTarget::DRAW_FRAMEBUFFER, m_pCurrent->m_depthImageDeltaZFBO);
|
||||||
dwnd().getDrawer().drawRect(_ulx, _uly, _lrx, _lry, color);
|
dwnd().getDrawer().drawRect(_ulx, _uly, _lrx, _lry, color);
|
||||||
gDP.otherMode.cycleType = cycleType;
|
gDP.otherMode.cycleType = cycleType;
|
||||||
|
|
||||||
bindParams.texture = m_pCurrent->m_pDepthImageTexture->name;
|
bindParams.texture = m_pCurrent->m_pDepthImageZTexture->name;
|
||||||
|
bindParams.imageUnit = textureImageUnits::DepthZ;
|
||||||
|
gfxContext.bindImageTexture(bindParams);
|
||||||
|
bindParams.texture = m_pCurrent->m_pDepthImageDeltaZTexture->name;
|
||||||
|
bindParams.imageUnit = textureImageUnits::DepthDeltaZ;
|
||||||
gfxContext.bindImageTexture(bindParams);
|
gfxContext.bindImageTexture(bindParams);
|
||||||
|
|
||||||
frameBufferList().setCurrentDrawBuffer();
|
frameBufferList().setCurrentDrawBuffer();
|
||||||
|
|
|
@ -25,8 +25,10 @@ struct DepthBuffer
|
||||||
|
|
||||||
u32 m_address, m_width;
|
u32 m_address, m_width;
|
||||||
u32 m_ulx, m_uly, m_lrx, m_lry; // Parameters of fillrect command.
|
u32 m_ulx, m_uly, m_lrx, m_lry; // Parameters of fillrect command.
|
||||||
graphics::ObjectHandle m_depthImageFBO;
|
graphics::ObjectHandle m_depthImageZFBO;
|
||||||
CachedTexture *m_pDepthImageTexture;
|
graphics::ObjectHandle m_depthImageDeltaZFBO;
|
||||||
|
CachedTexture *m_pDepthImageZTexture;
|
||||||
|
CachedTexture *m_pDepthImageDeltaZTexture;
|
||||||
CachedTexture *m_pDepthBufferTexture;
|
CachedTexture *m_pDepthBufferTexture;
|
||||||
graphics::ObjectHandle m_depthRenderbuffer;
|
graphics::ObjectHandle m_depthRenderbuffer;
|
||||||
u32 m_depthRenderbufferWidth;
|
u32 m_depthRenderbufferWidth;
|
||||||
|
@ -40,6 +42,8 @@ struct DepthBuffer
|
||||||
bool m_copied;
|
bool m_copied;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void _initDepthImageTexture(FrameBuffer * _pBuffer, CachedTexture& _cachedTexture,
|
||||||
|
graphics::ObjectHandle& _depthImageFBO);
|
||||||
void _initDepthBufferTexture(FrameBuffer * _pBuffer, CachedTexture *_pTexture, bool _multisample);
|
void _initDepthBufferTexture(FrameBuffer * _pBuffer, CachedTexture *_pTexture, bool _multisample);
|
||||||
void _initDepthBufferRenderbuffer(FrameBuffer * _pBuffer);
|
void _initDepthBufferRenderbuffer(FrameBuffer * _pBuffer);
|
||||||
void _DepthBufferTexture(FrameBuffer * _pBuffer);
|
void _DepthBufferTexture(FrameBuffer * _pBuffer);
|
||||||
|
|
|
@ -933,11 +933,10 @@ public:
|
||||||
ShaderFragmentHeaderDepthCompare(const opengl::GLInfo & _glinfo)
|
ShaderFragmentHeaderDepthCompare(const opengl::GLInfo & _glinfo)
|
||||||
{
|
{
|
||||||
if (config.frameBufferEmulation.N64DepthCompare != 0) {
|
if (config.frameBufferEmulation.N64DepthCompare != 0) {
|
||||||
m_part = _glinfo.isGLESX
|
|
||||||
? "layout(binding = 2, rgba32f) highp uniform coherent image2D uDepthImage;\n"
|
|
||||||
: "layout(binding = 2, rg32f) highp uniform coherent image2D uDepthImage;\n"
|
|
||||||
;
|
|
||||||
m_part +=
|
m_part +=
|
||||||
|
"layout(binding = 2, r32f) highp uniform coherent image2D uDepthImageZ; \n"
|
||||||
|
"layout(binding = 3, r32f) highp uniform coherent image2D uDepthImageDeltaZ;\n"
|
||||||
"bool depth_compare();\n"
|
"bool depth_compare();\n"
|
||||||
"bool depth_render(highp float Z);\n";
|
"bool depth_render(highp float Z);\n";
|
||||||
;
|
;
|
||||||
|
@ -1553,15 +1552,16 @@ public:
|
||||||
"bool depth_compare() \n"
|
"bool depth_compare() \n"
|
||||||
"{ \n"
|
"{ \n"
|
||||||
" ivec2 coord = ivec2(gl_FragCoord.xy); \n"
|
" ivec2 coord = ivec2(gl_FragCoord.xy); \n"
|
||||||
" highp vec4 depth = imageLoad(uDepthImage,coord); \n"
|
" highp vec4 depthZ = imageLoad(uDepthImageZ,coord); \n"
|
||||||
" highp float bufZ = depth.r; \n"
|
" highp vec4 depthDeltaZ = imageLoad(uDepthImageDeltaZ,coord);\n"
|
||||||
|
" highp float bufZ = depthZ.r; \n"
|
||||||
" highp float curZ = gl_FragDepth; \n"
|
" highp float curZ = gl_FragDepth; \n"
|
||||||
" highp float dz, dzMin; \n"
|
" highp float dz, dzMin; \n"
|
||||||
" if (uDepthSource == 1) { \n"
|
" if (uDepthSource == 1) { \n"
|
||||||
" dzMin = dz = uDeltaZ; \n"
|
" dzMin = dz = uDeltaZ; \n"
|
||||||
" } else { \n"
|
" } else { \n"
|
||||||
" dz = 4.0*fwidth(gl_FragDepth); \n"
|
" dz = 4.0*fwidth(gl_FragDepth); \n"
|
||||||
" dzMin = min(dz, depth.g); \n"
|
" dzMin = min(dz, depthDeltaZ.r); \n"
|
||||||
" } \n"
|
" } \n"
|
||||||
" bool bInfront = curZ < bufZ; \n"
|
" bool bInfront = curZ < bufZ; \n"
|
||||||
" bool bFarther = (curZ + dzMin) >= bufZ; \n"
|
" bool bFarther = (curZ + dzMin) >= bufZ; \n"
|
||||||
|
@ -1584,8 +1584,10 @@ public:
|
||||||
" break; \n"
|
" break; \n"
|
||||||
" } \n"
|
" } \n"
|
||||||
" if (uEnableDepthUpdate != 0 && bRes) { \n"
|
" if (uEnableDepthUpdate != 0 && bRes) { \n"
|
||||||
" highp vec4 depth_out = vec4(gl_FragDepth, dz, 1.0, 1.0); \n"
|
" highp vec4 depthOutZ = vec4(gl_FragDepth, 1.0, 1.0, 1.0); \n"
|
||||||
" imageStore(uDepthImage,coord, depth_out); \n"
|
" highp vec4 depthOutDeltaZ = vec4(dz, 1.0, 1.0, 1.0); \n"
|
||||||
|
" imageStore(uDepthImageZ, coord, depthOutZ); \n"
|
||||||
|
" imageStore(uDepthImageDeltaZ, coord, depthOutDeltaZ);\n"
|
||||||
" } \n"
|
" } \n"
|
||||||
" memoryBarrierImage(); \n"
|
" memoryBarrierImage(); \n"
|
||||||
" if (uEnableDepthCompare != 0) \n"
|
" if (uEnableDepthCompare != 0) \n"
|
||||||
|
@ -1608,13 +1610,15 @@ public:
|
||||||
"{ \n"
|
"{ \n"
|
||||||
" ivec2 coord = ivec2(gl_FragCoord.xy); \n"
|
" ivec2 coord = ivec2(gl_FragCoord.xy); \n"
|
||||||
" if (uEnableDepthCompare != 0) { \n"
|
" if (uEnableDepthCompare != 0) { \n"
|
||||||
" highp vec4 depth = imageLoad(uDepthImage,coord); \n"
|
" highp vec4 depthZ = imageLoad(uDepthImageZ,coord); \n"
|
||||||
" highp float bufZ = depth.r; \n"
|
" highp float bufZ = depthZ.r; \n"
|
||||||
" highp float curZ = gl_FragDepth; \n"
|
" highp float curZ = gl_FragDepth; \n"
|
||||||
" if (curZ >= bufZ) return false; \n"
|
" if (curZ >= bufZ) return false; \n"
|
||||||
" } \n"
|
" } \n"
|
||||||
" highp vec4 depth_out = vec4(Z, 0.0, 1.0, 1.0); \n"
|
" highp vec4 depthOutZ = vec4(Z, 1.0, 1.0, 1.0); \n"
|
||||||
" imageStore(uDepthImage,coord, depth_out); \n"
|
" highp vec4 depthOutDeltaZ = vec4(0.0, 1.0, 1.0, 1.0);\n"
|
||||||
|
" imageStore(uDepthImageZ,coord, depthOutZ); \n"
|
||||||
|
" imageStore(uDepthImageDeltaZ,coord, depthOutDeltaZ); \n"
|
||||||
" memoryBarrierImage(); \n"
|
" memoryBarrierImage(); \n"
|
||||||
" return true; \n"
|
" return true; \n"
|
||||||
"} \n"
|
"} \n"
|
||||||
|
|
|
@ -492,10 +492,10 @@ protected:
|
||||||
depthType = GL_UNSIGNED_INT;
|
depthType = GL_UNSIGNED_INT;
|
||||||
depthFormatBytes = 4;
|
depthFormatBytes = 4;
|
||||||
|
|
||||||
depthImageInternalFormat = GL_RGBA32F;
|
depthImageInternalFormat = GL_R32F;
|
||||||
depthImageFormat = GL_RGBA;
|
depthImageFormat = GL_RED;
|
||||||
depthImageType = GL_FLOAT;
|
depthImageType = GL_FLOAT;
|
||||||
depthImageFormatBytes = 16;
|
depthImageFormatBytes = 4;
|
||||||
|
|
||||||
lutInternalFormat = GL_R32UI;
|
lutInternalFormat = GL_R32UI;
|
||||||
lutFormat = GL_RED_INTEGER;
|
lutFormat = GL_RED_INTEGER;
|
||||||
|
@ -538,10 +538,10 @@ protected:
|
||||||
depthType = GL_FLOAT;
|
depthType = GL_FLOAT;
|
||||||
depthFormatBytes = 4;
|
depthFormatBytes = 4;
|
||||||
|
|
||||||
depthImageInternalFormat = GL_RG32F;
|
depthImageInternalFormat = GL_R32F;
|
||||||
depthImageFormat = GL_RG;
|
depthImageFormat = GL_RED;
|
||||||
depthImageType = GL_FLOAT;
|
depthImageType = GL_FLOAT;
|
||||||
depthImageFormatBytes = 8;
|
depthImageFormatBytes = 4;
|
||||||
|
|
||||||
lutInternalFormat = GL_R32UI;
|
lutInternalFormat = GL_R32UI;
|
||||||
lutFormat = GL_RED_INTEGER;
|
lutFormat = GL_RED_INTEGER;
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
#include <Graphics/ColorBufferReader.h>
|
#include <Graphics/ColorBufferReader.h>
|
||||||
#include "opengl_CachedFunctions.h"
|
#include "opengl_CachedFunctions.h"
|
||||||
|
|
||||||
#include <Graphics/OpenGLContext/GraphicBUfferPrivateApi/GraphicBuffer.h>
|
#include <Graphics/OpenGLContext/GraphicBufferPrivateApi/GraphicBuffer.h>
|
||||||
#include <EGL/egl.h>
|
#include <EGL/egl.h>
|
||||||
#include <EGL/eglext.h>
|
#include <EGL/eglext.h>
|
||||||
|
|
||||||
|
|
|
@ -72,7 +72,8 @@ namespace graphics {
|
||||||
namespace textureImageUnits {
|
namespace textureImageUnits {
|
||||||
ImageUnitParam Zlut(0U);
|
ImageUnitParam Zlut(0U);
|
||||||
ImageUnitParam Tlut(1U);
|
ImageUnitParam Tlut(1U);
|
||||||
ImageUnitParam Depth(2U);
|
ImageUnitParam DepthZ(2U);
|
||||||
|
ImageUnitParam DepthDeltaZ(3U);
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace textureImageAccessMode {
|
namespace textureImageAccessMode {
|
||||||
|
|
|
@ -72,7 +72,8 @@ namespace graphics {
|
||||||
namespace textureImageUnits {
|
namespace textureImageUnits {
|
||||||
extern ImageUnitParam Zlut;
|
extern ImageUnitParam Zlut;
|
||||||
extern ImageUnitParam Tlut;
|
extern ImageUnitParam Tlut;
|
||||||
extern ImageUnitParam Depth;
|
extern ImageUnitParam DepthZ;
|
||||||
|
extern ImageUnitParam DepthDeltaZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace textureImageAccessMode {
|
namespace textureImageAccessMode {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user