Permalink
Browse files

GLES: Restore stencil/depth readback for debugger.

Only works on desktop GL.
  • Loading branch information...
unknownbrackets committed Jun 16, 2018
1 parent f0694ba commit 35ccd167467d95b82b1355c124575c49395c849f
Showing with 24 additions and 6 deletions.
  1. +20 −6 ext/native/thin3d/GLQueueRunner.cpp
  2. +4 −0 ext/native/thin3d/thin3d_gl.cpp
@@ -1085,13 +1085,27 @@ void GLQueueRunner::PerformReadback(const GLRStep &pass) {
CHECK_GL_ERROR_IF_DEBUG();
// Always read back in 8888 format.
const GLuint internalFormat = GL_RGBA;
const GLuint format = GL_RGBA;
const GLuint type = GL_UNSIGNED_BYTE;
const int srcAlignment = 4;
// Always read back in 8888 format for the color aspect.
GLuint internalFormat = GL_RGBA;
GLuint format = GL_RGBA;
GLuint type = GL_UNSIGNED_BYTE;
int srcAlignment = 4;
int dstAlignment = (int)DataFormatSizeInBytes(pass.readback.dstFormat);
#ifndef USING_GLES2
if (pass.readback.aspectMask & GL_DEPTH_BUFFER_BIT) {
internalFormat = GL_DEPTH_COMPONENT;
format = GL_DEPTH_COMPONENT;
type = GL_FLOAT;
srcAlignment = 4;
} else if (pass.readback.aspectMask & GL_STENCIL_BUFFER_BIT) {
internalFormat = GL_STENCIL_INDEX;
format = GL_STENCIL_INDEX;
type = GL_UNSIGNED_BYTE;
srcAlignment = 1;
}
#endif
int pixelStride = pass.readback.srcRect.w;
// Apply the correct alignment.
glPixelStorei(GL_PACK_ALIGNMENT, srcAlignment);
@@ -1102,7 +1116,7 @@ void GLQueueRunner::PerformReadback(const GLRStep &pass) {
GLRect2D rect = pass.readback.srcRect;
bool convert = pass.readback.dstFormat != DataFormat::R8G8B8A8_UNORM;
bool convert = internalFormat == GL_RGBA && pass.readback.dstFormat != DataFormat::R8G8B8A8_UNORM;
int tempSize = srcAlignment * rect.w * rect.h;
int readbackSize = dstAlignment * rect.w * rect.h;
@@ -720,6 +720,10 @@ static void LogReadPixelsError(GLenum error) {
#endif
bool OpenGLContext::CopyFramebufferToMemorySync(Framebuffer *src, int channelBits, int x, int y, int w, int h, Draw::DataFormat dataFormat, void *pixels, int pixelStride) {
if (gl_extensions.IsGLES && (channelBits & FB_COLOR_BIT) == 0) {
// Can't readback depth or stencil on GLES.
return false;
}
OpenGLFramebuffer *fb = (OpenGLFramebuffer *)src;
GLuint aspect = 0;
if (channelBits & FB_COLOR_BIT)

0 comments on commit 35ccd16

Please sign in to comment.