Commit 39ec117e authored by dongseong.hwang's avatar dongseong.hwang Committed by Commit bot

Revert of webgl: use immutable texture for the default FBO. (patchset #2...

Revert of webgl: use immutable texture for the default FBO. (patchset #2 id:20001 of https://codereview.chromium.org/1449043005/ )

Reason for revert:
following test is broken.
WebglConformance.deqp_functional_gles3_readpixel

Original issue's description:
> webgl: use immutable texture for the default FBO.
>
> Use immutable texture for the default FBO like chromium compositor.
>
> In theory, it speeds up drawing speed, because immutable texture skips texture
> validation on drawing call.
>
> In addition, immutable texture allows GL_INTEL_framebuffer_CMAA more optimization.
>
> BUG=557848
> TEST=
> WebglConformance.conformance_renderbuffers_framebuffer_state_restoration
> WebglConformance.conformance_textures_misc_texture_size_cube_maps
> WebglConformance.conformance_textures_misc_texture_sub_image_cube_maps
> WebglConformance.conformance_textures_webgl_canvas_tex_image_and_sub_image_2d_with_webgl_canvas_rgb_rgb_unsigned_byte
> WebglConformance.conformance_textures_webgl_canvas_tex_image_and_sub_image_2d_with_webgl_canvas_rgb_rgb_unsigned_short_5_6_5
> WebglConformance.conformance_textures_webgl_canvas_tex_image_and_sub_image_2d_with_webgl_canvas_rgba_rgba_unsigned_byte
> WebglConformance.conformance_textures_webgl_canvas_tex_image_and_sub_image_2d_with_webgl_canvas_rgba_rgba_unsigned_short_4_4_4_4
> WebglConformance.conformance_textures_webgl_canvas_tex_image_and_sub_image_2d_with_webgl_canvas_rgba_rgba_unsigned_short_5_5_5_1
>
> Committed: https://crrev.com/fb9d8e245ac84c6c0806e86e7884b4775a84b4b5
> Cr-Commit-Position: refs/heads/master@{#361335}

TBR=kbr@chromium.org,adrian.belgun@intel.com
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=557848

Review URL: https://codereview.chromium.org/1474763002

Cr-Commit-Position: refs/heads/master@{#361368}
parent cdc0e15e
......@@ -151,7 +151,6 @@ DrawingBuffer::DrawingBuffer(PassOwnPtr<WebGraphicsContext3D> context,
, m_multisampleExtensionSupported(multisampleExtensionSupported)
, m_packedDepthStencilExtensionSupported(packedDepthStencilExtensionSupported)
, m_discardFramebufferSupported(discardFramebufferSupported)
, m_storageTextureSupported(false)
, m_fbo(0)
, m_depthStencilBuffer(0)
, m_depthBuffer(0)
......@@ -306,8 +305,7 @@ bool DrawingBuffer::prepareMailbox(WebExternalTextureMailbox* outMailbox, WebExt
m_context->discardFramebufferEXT(GL_FRAMEBUFFER, 3, attachments);
}
} else {
m_context->copySubTextureCHROMIUM(GL_TEXTURE_2D, m_colorBuffer.textureId, frontColorBufferMailbox->textureInfo.textureId,
0, 0, 0, 0, m_size.width(), m_size.height(), GL_FALSE, GL_FALSE, GL_FALSE);
m_context->copyTextureCHROMIUM(GL_TEXTURE_2D, m_colorBuffer.textureId, frontColorBufferMailbox->textureInfo.textureId, GL_RGBA, GL_UNSIGNED_BYTE, GL_FALSE, GL_FALSE, GL_FALSE);
}
restoreFramebufferBindings();
......@@ -451,7 +449,6 @@ bool DrawingBuffer::initialize(const IntSize& size)
}
}
m_sampleCount = std::min(4, maxSampleCount);
m_storageTextureSupported = m_extensionsUtil->supportsExtension("GL_EXT_texture_storage");
m_fbo = m_context->createFramebuffer();
......@@ -962,6 +959,12 @@ void DrawingBuffer::flipVertically(uint8_t* framebuffer, int width, int height)
}
}
void DrawingBuffer::texImage2DResourceSafe(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, GLint unpackAlignment)
{
ASSERT(unpackAlignment == 1 || unpackAlignment == 2 || unpackAlignment == 4 || unpackAlignment == 8);
m_context->texImage2D(target, level, internalformat, width, height, border, format, type, 0);
}
void DrawingBuffer::allocateTextureMemory(TextureInfo* info, const IntSize& size)
{
if (RuntimeEnabledFeatures::webGLImageChromiumEnabled()) {
......@@ -974,18 +977,7 @@ void DrawingBuffer::allocateTextureMemory(TextureInfo* info, const IntSize& size
}
}
if (m_storageTextureSupported) {
if (info->immutable) {
m_context->deleteTexture(info->textureId);
info->textureId = createColorTexture();
}
// TODO(dshwang): GL_BGRA8_EXT can be better in some platforms. crbug.com/557848
m_context->texStorage2DEXT(GL_TEXTURE_2D, 1, m_internalRenderbufferFormat, size.width(), size.height());
info->immutable = true;
return;
}
m_context->texImage2D(GL_TEXTURE_2D, 0, m_internalColorFormat, size.width(), size.height(), 0, m_colorFormat, GL_UNSIGNED_BYTE, 0);
texImage2DResourceSafe(GL_TEXTURE_2D, 0, m_internalColorFormat, size.width(), size.height(), 0, m_colorFormat, GL_UNSIGNED_BYTE);
}
void DrawingBuffer::deleteChromiumImageForTexture(TextureInfo* info)
......
......@@ -69,12 +69,10 @@ class PLATFORM_EXPORT DrawingBuffer : public RefCounted<DrawingBuffer>, public W
struct TextureInfo {
Platform3DObject textureId;
WGC3Duint imageId;
bool immutable;
TextureInfo()
: textureId(0)
, imageId(0)
, immutable(false)
{
}
};
......@@ -232,6 +230,9 @@ private:
// Helper function to flip a bitmap vertically.
void flipVertically(uint8_t* data, int width, int height);
// Helper to texImage2D with pixel==0 case: pixels are initialized to 0.
// By default, alignment is 4, the OpenGL default setting.
void texImage2DResourceSafe(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, GLint alignment = 4);
// Allocate buffer storage to be sent to compositor using either texImage2D or CHROMIUM_image based on available support.
void allocateTextureMemory(TextureInfo*, const IntSize&);
void deleteChromiumImageForTexture(TextureInfo*);
......@@ -250,7 +251,6 @@ private:
bool m_multisampleExtensionSupported;
bool m_packedDepthStencilExtensionSupported;
bool m_discardFramebufferSupported;
bool m_storageTextureSupported;
Platform3DObject m_fbo;
// DrawingBuffer's output is double-buffered. m_colorBuffer is the back buffer.
TextureInfo m_colorBuffer;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment