diff options
author | apatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-02 23:10:32 +0000 |
---|---|---|
committer | apatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-02 23:10:32 +0000 |
commit | 876f6fee7025b66f758b5fd50c2c89b5df748e19 (patch) | |
tree | b063ce5ecc756fa3be29a330da4cc8f7008356fc /gpu/command_buffer | |
parent | edd2f227a16ca579fb34a8da3da0b8fad67b0a1b (diff) | |
download | chromium_src-876f6fee7025b66f758b5fd50c2c89b5df748e19.zip chromium_src-876f6fee7025b66f758b5fd50c2c89b5df748e19.tar.gz chromium_src-876f6fee7025b66f758b5fd50c2c89b5df748e19.tar.bz2 |
GPU command decoder uses depth24_stencil8_oes extension if available.
This is now the only depth / stencil format supported by ANGLE. Other GLES2 implementations will only use it if the extension is supported.
Also changed all usage of GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2 to a runtime check since we no longer know at compile time whether the backend will be GL ot GLES2.
TEST=try, GPU unit tests locally, WebGL locally, Pepper 3D locally
BUG=none
Review URL: http://codereview.chromium.org/3046035
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@54627 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu/command_buffer')
5 files changed, 68 insertions, 93 deletions
diff --git a/gpu/command_buffer/service/context_group.cc b/gpu/command_buffer/service/context_group.cc index 7e3f0a5..8437c66 100644 --- a/gpu/command_buffer/service/context_group.cc +++ b/gpu/command_buffer/service/context_group.cc @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "app/gfx/gl/gl_implementation.h" #include "gpu/command_buffer/service/context_group.h" #include "gpu/command_buffer/common/id_allocator.h" #include "gpu/command_buffer/service/buffer_manager.h" @@ -157,23 +158,20 @@ bool ContextGroup::Initialize() { GetIntegerv( GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, &max_vertex_texture_image_units_); -#if defined(GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2) - - GetIntegerv(GL_MAX_FRAGMENT_UNIFORM_VECTORS, &max_fragment_uniform_vectors_); - GetIntegerv(GL_MAX_VARYING_VECTORS, &max_varying_vectors_); - GetIntegerv(GL_MAX_VERTEX_UNIFORM_VECTORS, &max_vertex_uniform_vectors_); - -#else // !defined(GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2) - - GetIntegerv( - GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, &max_fragment_uniform_vectors_); - max_fragment_uniform_vectors_ /= 4; - GetIntegerv(GL_MAX_VARYING_FLOATS, &max_varying_vectors_); - max_varying_vectors_ /= 4; - GetIntegerv(GL_MAX_VERTEX_UNIFORM_COMPONENTS, &max_vertex_uniform_vectors_); - max_vertex_uniform_vectors_ /= 4; - -#endif // !defined(GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2) + if (gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2) { + GetIntegerv(GL_MAX_FRAGMENT_UNIFORM_VECTORS, + &max_fragment_uniform_vectors_); + GetIntegerv(GL_MAX_VARYING_VECTORS, &max_varying_vectors_); + GetIntegerv(GL_MAX_VERTEX_UNIFORM_VECTORS, &max_vertex_uniform_vectors_); + } else { + GetIntegerv( + GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, &max_fragment_uniform_vectors_); + max_fragment_uniform_vectors_ /= 4; + GetIntegerv(GL_MAX_VARYING_FLOATS, &max_varying_vectors_); + max_varying_vectors_ /= 4; + GetIntegerv(GL_MAX_VERTEX_UNIFORM_COMPONENTS, &max_vertex_uniform_vectors_); + max_vertex_uniform_vectors_ /= 4; + } initialized_ = true; return true; diff --git a/gpu/command_buffer/service/context_group_unittest.cc b/gpu/command_buffer/service/context_group_unittest.cc index d619e9a..3f8c65e 100644 --- a/gpu/command_buffer/service/context_group_unittest.cc +++ b/gpu/command_buffer/service/context_group_unittest.cc @@ -96,21 +96,6 @@ void ContextGroupTest::SetupInitExpectations(const char* extensions) { EXPECT_CALL(*gl_, GetIntegerv(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, _)) .WillOnce(SetArgumentPointee<1>(kMaxVertexTextureImageUnits)) .RetiresOnSaturation(); - -#if defined(GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2) - - EXPECT_CALL(*gl_, GetIntegerv(GL_MAX_FRAGMENT_UNIFORM_VECTORS, _)) - .WillOnce(SetArgumentPointee<1>(kMaxFragmentUniformVectors * 4)) - .RetiresOnSaturation(); - EXPECT_CALL(*gl_, GetIntegerv(GL_MAX_VARYING_VECTORS, _)) - .WillOnce(SetArgumentPointee<1>(kMaxVaryingVectors * 4)) - .RetiresOnSaturation(); - EXPECT_CALL(*gl_, GetIntegerv(GL_MAX_VERTEX_UNIFORM_VECTORS, _)) - .WillOnce(SetArgumentPointee<1>(kMaxVertexUniformVectors * 4)) - .RetiresOnSaturation(); - -#else // !defined(GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2) - EXPECT_CALL(*gl_, GetIntegerv(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, _)) .WillOnce(SetArgumentPointee<1>(kMaxFragmentUniformVectors)) .RetiresOnSaturation(); @@ -120,8 +105,6 @@ void ContextGroupTest::SetupInitExpectations(const char* extensions) { EXPECT_CALL(*gl_, GetIntegerv(GL_MAX_VERTEX_UNIFORM_COMPONENTS, _)) .WillOnce(SetArgumentPointee<1>(kMaxVertexUniformVectors)) .RetiresOnSaturation(); - -#endif // !defined(GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2) } TEST_F(ContextGroupTest, Basic) { diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc index d75ce4b..ec09fd9 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc @@ -1195,6 +1195,9 @@ class GLES2DecoderImpl : public base::SupportsWeakPtr<GLES2DecoderImpl>, // Cached from the context group. const Validators* validators_; + // Supported extensions. + bool depth24_stencil8_oes_supported_; + DISALLOW_COPY_AND_ASSIGN(GLES2DecoderImpl); }; @@ -1458,7 +1461,8 @@ GLES2DecoderImpl::GLES2DecoderImpl(ContextGroup* group) use_shader_translator_(true), vertex_compiler_(NULL), fragment_compiler_(NULL), - validators_(group->validators()) { + validators_(group->validators()), + depth24_stencil8_oes_supported_(false) { attrib_0_value_.v[0] = 0.0f; attrib_0_value_.v[1] = 0.0f; attrib_0_value_.v[2] = 0.0f; @@ -1512,6 +1516,11 @@ bool GLES2DecoderImpl::Initialize(gfx::GLContext* context, } vertex_attrib_manager_.Initialize(group_->max_vertex_attribs()); + + // Check supported extensions. + depth24_stencil8_oes_supported_ = + context_->HasExtension("GL_OES_packed_depth_stencil"); + // We have to enable vertex array 0 on OpenGL or it won't render. Note that // OpenGL ES 2.0 does not have this issue. glEnableVertexAttribArray(0); @@ -1841,11 +1850,12 @@ bool GLES2DecoderImpl::UpdateOffscreenFrameBufferSize() { return false; } - if (gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2) { - // ANGLE only allows 16-bit depth buffers to be requested. As it happens, - // it creates a 24-bit depth buffer behind the scenes. - // TODO(apatrick): Attempt to use a packed 24/8 depth stencil buffer here if - // the extension is available. + // GLES2 may only allow a combination of 16-bit depth buffers and / or 8-bit + // stencil buffer. A packed 24/8 bit depth stencil buffer is preferred. + // ANGLE only supports the latter, i.e. is does not support core GLES2 in + // this respect. So we check for packed depth stencil support. + if (gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2 && + !depth24_stencil8_oes_supported_) { if (!offscreen_target_depth_render_buffer_->AllocateStorage( pending_offscreen_size_, GL_DEPTH_COMPONENT16)) { return false; @@ -1868,7 +1878,8 @@ bool GLES2DecoderImpl::UpdateOffscreenFrameBufferSize() { offscreen_target_frame_buffer_->AttachRenderBuffer( GL_DEPTH_ATTACHMENT, offscreen_target_depth_render_buffer_.get()); - if (gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2) { + if (gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2 && + !depth24_stencil8_oes_supported_) { offscreen_target_frame_buffer_->AttachRenderBuffer( GL_STENCIL_ATTACHMENT, offscreen_target_stencil_render_buffer_.get()); @@ -2804,20 +2815,22 @@ void GLES2DecoderImpl::DoRenderbufferStorage( return; } bound_renderbuffer_->set_internal_format(internalformat); -#if !defined(GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2) - switch (internalformat) { - case GL_DEPTH_COMPONENT16: - internalformat = GL_DEPTH_COMPONENT; - break; - case GL_RGBA4: - case GL_RGB5_A1: - internalformat = GL_RGBA; - break; - case GL_RGB565: - internalformat = GL_RGB; - break; + + if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) { + switch (internalformat) { + case GL_DEPTH_COMPONENT16: + internalformat = GL_DEPTH_COMPONENT; + break; + case GL_RGBA4: + case GL_RGB5_A1: + internalformat = GL_RGBA; + break; + case GL_RGB565: + internalformat = GL_RGB; + break; + } } -#endif // GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2 + glRenderbufferStorageEXT(target, internalformat, width, height); } @@ -3184,7 +3197,9 @@ bool GLES2DecoderImpl::IsDrawValid(GLuint max_vertex_accessed) { } bool GLES2DecoderImpl::SimulateAttrib0(GLuint max_vertex_accessed) { -#if !defined(GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2) + if (gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2) + return false; + const VertexAttribManager::VertexAttribInfo* info = vertex_attrib_manager_.GetVertexAttribInfo(0); // If it's enabled or it's not used then we don't need to do anything. @@ -3222,9 +3237,6 @@ bool GLES2DecoderImpl::SimulateAttrib0(GLuint max_vertex_accessed) { glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, NULL); return true; -#else // GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2 - return false; -#endif // GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2 } void GLES2DecoderImpl::RestoreStateForSimulatedAttrib0() { @@ -4395,23 +4407,25 @@ error::Error GLES2DecoderImpl::DoTexImage2D( memset(zero.get(), 0, pixels_size); pixels = zero.get(); } - #if !defined(GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2) - if (format == GL_BGRA_EXT && internal_format == GL_BGRA_EXT) { - internal_format = GL_RGBA; - } else if (type == GL_FLOAT) { - if (format == GL_RGBA) { - internal_format = GL_RGBA32F_ARB; - } else if (format == GL_RGB) { - internal_format = GL_RGB32F_ARB; - } - } else if (type == GL_HALF_FLOAT_OES) { - if (format == GL_RGBA) { - internal_format = GL_RGBA16F_ARB; - } else if (format == GL_RGB) { - internal_format = GL_RGB16F_ARB; + + if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) { + if (format == GL_BGRA_EXT && internal_format == GL_BGRA_EXT) { + internal_format = GL_RGBA; + } else if (type == GL_FLOAT) { + if (format == GL_RGBA) { + internal_format = GL_RGBA32F_ARB; + } else if (format == GL_RGB) { + internal_format = GL_RGB32F_ARB; + } + } else if (type == GL_HALF_FLOAT_OES) { + if (format == GL_RGBA) { + internal_format = GL_RGBA16F_ARB; + } else if (format == GL_RGB) { + internal_format = GL_RGB16F_ARB; + } } } - #endif + CopyRealGLErrorsToWrapper(); glTexImage2D( target, level, internal_format, width, height, border, format, type, diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc b/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc index e914ee2..2bb4612 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc @@ -48,7 +48,6 @@ class GLES2DecoderWithShaderTest : public GLES2DecoderWithShaderTestBase { void AddExpectationsForSimulatedAttrib0( GLsizei num_vertices, GLuint buffer_id) { -#if !defined(GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2) EXPECT_CALL(*gl_, BindBuffer(GL_ARRAY_BUFFER, kServiceAttrib0BufferId)) .Times(1) .RetiresOnSaturation(); @@ -70,7 +69,6 @@ class GLES2DecoderWithShaderTest : public GLES2DecoderWithShaderTestBase { .Times(1) .RetiresOnSaturation(); } -#endif // !GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2 }; TEST_F(GLES2DecoderWithShaderTest, DrawArraysNoAttributesSucceeds) { diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc index a157de9..9c5b924 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc @@ -62,21 +62,6 @@ void GLES2DecoderTestBase::InitDecoder(const char* extensions) { EXPECT_CALL(*gl_, GetIntegerv(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, _)) .WillOnce(SetArgumentPointee<1>(kMaxVertexTextureImageUnits)) .RetiresOnSaturation(); - -#if defined(GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2) - - EXPECT_CALL(*gl_, GetIntegerv(GL_MAX_FRAGMENT_UNIFORM_VECTORS, _)) - .WillOnce(SetArgumentPointee<1>(kMaxFragmentUniformVectors * 4)) - .RetiresOnSaturation(); - EXPECT_CALL(*gl_, GetIntegerv(GL_MAX_VARYING_VECTORS, _)) - .WillOnce(SetArgumentPointee<1>(kMaxVaryingVectors * 4)) - .RetiresOnSaturation(); - EXPECT_CALL(*gl_, GetIntegerv(GL_MAX_VERTEX_UNIFORM_VECTORS, _)) - .WillOnce(SetArgumentPointee<1>(kMaxVertexUniformVectors * 4)) - .RetiresOnSaturation(); - -#else // !defined(GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2) - EXPECT_CALL(*gl_, GetIntegerv(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, _)) .WillOnce(SetArgumentPointee<1>(kMaxFragmentUniformVectors)) .RetiresOnSaturation(); @@ -86,9 +71,6 @@ void GLES2DecoderTestBase::InitDecoder(const char* extensions) { EXPECT_CALL(*gl_, GetIntegerv(GL_MAX_VERTEX_UNIFORM_COMPONENTS, _)) .WillOnce(SetArgumentPointee<1>(kMaxVertexUniformVectors)) .RetiresOnSaturation(); - -#endif // !defined(GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2) - EXPECT_CALL(*gl_, EnableVertexAttribArray(0)) .Times(1) .RetiresOnSaturation(); |