diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc index 3c176ccf02d6c9..9d6f102021e9de 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc @@ -3880,14 +3880,9 @@ gpu::ContextResult GLES2DecoderImpl::Initialize( api()->glGetIntegervFn(GL_STENCIL_BITS, &stencil_bits); } - // This checks if the user requested RGBA and we have RGBA then RGBA. If - // the user requested RGB then RGB. If the user did not specify a - // preference than use whatever we were given. Same for DEPTH and STENCIL. - back_buffer_color_format_ = - (attrib_helper.alpha_size != 0 && alpha_bits > 0) ? GL_RGBA : GL_RGB; - back_buffer_has_depth_ = attrib_helper.depth_size != 0 && depth_bits > 0; - back_buffer_has_stencil_ = - attrib_helper.stencil_size != 0 && stencil_bits > 0; + back_buffer_color_format_ = alpha_bits > 0 ? GL_RGBA : GL_RGB; + back_buffer_has_depth_ = depth_bits > 0; + back_buffer_has_stencil_ = stencil_bits > 0; num_stencil_bits_ = stencil_bits; } else { num_stencil_bits_ = attrib_helper.stencil_size; 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 8ac8d4bed2db27..7452d48ccc4e25 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc @@ -498,9 +498,6 @@ ContextResult GLES2DecoderTestBase::MaybeInitDecoderWithWorkarounds( ClearSharedMemory(); ContextCreationAttribs attribs; - attribs.alpha_size = normalized_init.request_alpha ? 8 : 0; - attribs.depth_size = normalized_init.request_depth ? 24 : 0; - attribs.stencil_size = normalized_init.request_stencil ? 8 : 0; attribs.lose_context_when_out_of_memory = normalized_init.lose_context_when_out_of_memory; attribs.context_type = init.context_type; @@ -2429,7 +2426,6 @@ void GLES2DecoderPassthroughTestBase::SetUp() { ui::OzonePlatform::InitializeForGPU(params); #endif - context_creation_attribs_.offscreen_framebuffer_size = gfx::Size(4, 4); context_creation_attribs_.bind_generates_resource = true; gl::init::InitializeStaticGLBindingsImplementation( @@ -2451,8 +2447,7 @@ void GLES2DecoderPassthroughTestBase::SetUp() { nullptr /* progress_reporter */, GpuFeatureInfo(), &discardable_manager_, &passthrough_discardable_manager_, &shared_image_manager_); - surface_ = gl::init::CreateOffscreenGLSurface( - display_, context_creation_attribs_.offscreen_framebuffer_size); + surface_ = gl::init::CreateOffscreenGLSurface(display_, gfx::Size(4, 4)); context_ = gl::init::CreateGLContext( nullptr, surface_.get(), GenerateGLContextAttribs(context_creation_attribs_, group_.get())); diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_drawing.cc b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_drawing.cc index d0e3c3a6e1d57a..60324d1f31b1ee 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_drawing.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_drawing.cc @@ -431,57 +431,6 @@ TEST_P(GLES2DecoderManualInitTest, DepthEnableWithDepth) { EXPECT_EQ(1, result->GetData()[0]); } -TEST_P(GLES2DecoderManualInitTest, DepthEnableWithoutRequestedDepth) { - InitState init; - init.has_depth = true; - init.bind_generates_resource = true; - InitDecoder(init); - - cmds::Enable cmd; - cmd.Init(GL_DEPTH_TEST); - EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); - EXPECT_EQ(GL_NO_ERROR, GetGLError()); - - SetupDefaultProgram(); - SetupTexture(); - AddExpectationsForSimulatedAttrib0(kNumVertices, 0); - SetupExpectationsForApplyingDirtyState(true, // Framebuffer is RGB - false, // Framebuffer has depth - false, // Framebuffer has stencil - 0x1110, // color bits - false, // depth mask - false, // depth enabled - 0, // front stencil mask - 0, // back stencil mask - false); // stencil enabled - - EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices)) - .Times(1) - .RetiresOnSaturation(); - cmds::DrawArrays draw_cmd; - draw_cmd.Init(GL_TRIANGLES, 0, kNumVertices); - EXPECT_EQ(error::kNoError, ExecuteCmd(draw_cmd)); - EXPECT_EQ(GL_NO_ERROR, GetGLError()); - - EXPECT_CALL(*gl_, GetError()) - .WillOnce(Return(GL_NO_ERROR)) - .WillOnce(Return(GL_NO_ERROR)) - .RetiresOnSaturation(); - auto* result = - static_cast(shared_memory_address_); - EXPECT_CALL(*gl_, GetIntegerv(GL_DEPTH_TEST, _)) - .Times(0) - .RetiresOnSaturation(); - result->size = 0; - cmds::GetIntegerv cmd2; - cmd2.Init(GL_DEPTH_TEST, shared_memory_id_, shared_memory_offset_); - EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); - EXPECT_EQ(decoder_->GetGLES2Util()->GLGetNumValuesReturned(GL_DEPTH_TEST), - result->GetNumResults()); - EXPECT_EQ(GL_NO_ERROR, GetGLError()); - EXPECT_EQ(1, result->GetData()[0]); -} - TEST_P(GLES2DecoderManualInitTest, StencilEnableWithStencil) { InitState init; init.has_stencil = true; @@ -535,57 +484,6 @@ TEST_P(GLES2DecoderManualInitTest, StencilEnableWithStencil) { EXPECT_EQ(1, result->GetData()[0]); } -TEST_P(GLES2DecoderManualInitTest, StencilEnableWithoutRequestedStencil) { - InitState init; - init.has_stencil = true; - init.bind_generates_resource = true; - InitDecoder(init); - - cmds::Enable cmd; - cmd.Init(GL_STENCIL_TEST); - EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); - EXPECT_EQ(GL_NO_ERROR, GetGLError()); - - SetupDefaultProgram(); - SetupTexture(); - AddExpectationsForSimulatedAttrib0(kNumVertices, 0); - SetupExpectationsForApplyingDirtyState(true, // Framebuffer is RGB - false, // Framebuffer has depth - false, // Framebuffer has stencil - 0x1110, // color bits - false, // depth mask - false, // depth enabled - 0, // front stencil mask - 0, // back stencil mask - false); // stencil enabled - - EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices)) - .Times(1) - .RetiresOnSaturation(); - cmds::DrawArrays draw_cmd; - draw_cmd.Init(GL_TRIANGLES, 0, kNumVertices); - EXPECT_EQ(error::kNoError, ExecuteCmd(draw_cmd)); - EXPECT_EQ(GL_NO_ERROR, GetGLError()); - - EXPECT_CALL(*gl_, GetError()) - .WillOnce(Return(GL_NO_ERROR)) - .WillOnce(Return(GL_NO_ERROR)) - .RetiresOnSaturation(); - auto* result = - static_cast(shared_memory_address_); - EXPECT_CALL(*gl_, GetIntegerv(GL_STENCIL_TEST, _)) - .Times(0) - .RetiresOnSaturation(); - result->size = 0; - cmds::GetIntegerv cmd2; - cmd2.Init(GL_STENCIL_TEST, shared_memory_id_, shared_memory_offset_); - EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); - EXPECT_EQ(decoder_->GetGLES2Util()->GLGetNumValuesReturned(GL_STENCIL_TEST), - result->GetNumResults()); - EXPECT_EQ(GL_NO_ERROR, GetGLError()); - EXPECT_EQ(1, result->GetData()[0]); -} - TEST_P(GLES2DecoderManualInitTest, CachedColorMask) { InitState init; init.has_alpha = true; diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_framebuffers.cc b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_framebuffers.cc index fc46751363b01c..85a7280ebb9095 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_framebuffers.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_framebuffers.cc @@ -1640,130 +1640,6 @@ TEST_P(GLES2DecoderManualInitTest, ActualAlphaMatchesRequestedAlpha) { EXPECT_EQ(8, result->GetData()[0]); } -TEST_P(GLES2DecoderManualInitTest, ActualAlphaDoesNotMatchRequestedAlpha) { - InitState init; - init.has_alpha = true; - init.bind_generates_resource = true; - InitDecoder(init); - - EXPECT_CALL(*gl_, GetError()) - .WillOnce(Return(GL_NO_ERROR)) - .WillOnce(Return(GL_NO_ERROR)) - .RetiresOnSaturation(); - auto* result = - static_cast(shared_memory_address_); - result->size = 0; - cmds::GetIntegerv cmd2; - cmd2.Init(GL_ALPHA_BITS, shared_memory_id_, shared_memory_offset_); - EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); - EXPECT_EQ(decoder_->GetGLES2Util()->GLGetNumValuesReturned(GL_ALPHA_BITS), - result->GetNumResults()); - EXPECT_EQ(GL_NO_ERROR, GetGLError()); - EXPECT_EQ(0, result->GetData()[0]); -} - -TEST_P(GLES2DecoderManualInitTest, ActualDepthMatchesRequestedDepth) { - InitState init; - init.has_depth = true; - init.request_depth = true; - init.bind_generates_resource = true; - InitDecoder(init); - - EXPECT_CALL(*gl_, GetError()) - .WillOnce(Return(GL_NO_ERROR)) - .WillOnce(Return(GL_NO_ERROR)) - .RetiresOnSaturation(); - auto* result = - static_cast(shared_memory_address_); - EXPECT_CALL(*gl_, GetIntegerv(GL_DEPTH_BITS, _)) - .WillOnce(SetArgPointee<1>(24)) - .RetiresOnSaturation(); - result->size = 0; - cmds::GetIntegerv cmd2; - cmd2.Init(GL_DEPTH_BITS, shared_memory_id_, shared_memory_offset_); - EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); - EXPECT_EQ(decoder_->GetGLES2Util()->GLGetNumValuesReturned(GL_DEPTH_BITS), - result->GetNumResults()); - EXPECT_EQ(GL_NO_ERROR, GetGLError()); - EXPECT_EQ(24, result->GetData()[0]); -} - -TEST_P(GLES2DecoderManualInitTest, ActualDepthDoesNotMatchRequestedDepth) { - InitState init; - init.has_depth = true; - init.bind_generates_resource = true; - InitDecoder(init); - - EXPECT_CALL(*gl_, GetError()) - .WillOnce(Return(GL_NO_ERROR)) - .WillOnce(Return(GL_NO_ERROR)) - .RetiresOnSaturation(); - auto* result = - static_cast(shared_memory_address_); - EXPECT_CALL(*gl_, GetIntegerv(GL_DEPTH_BITS, _)) - .WillOnce(SetArgPointee<1>(24)) - .RetiresOnSaturation(); - result->size = 0; - cmds::GetIntegerv cmd2; - cmd2.Init(GL_DEPTH_BITS, shared_memory_id_, shared_memory_offset_); - EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); - EXPECT_EQ(decoder_->GetGLES2Util()->GLGetNumValuesReturned(GL_DEPTH_BITS), - result->GetNumResults()); - EXPECT_EQ(GL_NO_ERROR, GetGLError()); - EXPECT_EQ(0, result->GetData()[0]); -} - -TEST_P(GLES2DecoderManualInitTest, ActualStencilMatchesRequestedStencil) { - InitState init; - init.has_stencil = true; - init.request_stencil = true; - init.bind_generates_resource = true; - InitDecoder(init); - - EXPECT_CALL(*gl_, GetError()) - .WillOnce(Return(GL_NO_ERROR)) - .WillOnce(Return(GL_NO_ERROR)) - .RetiresOnSaturation(); - auto* result = - static_cast(shared_memory_address_); - EXPECT_CALL(*gl_, GetIntegerv(GL_STENCIL_BITS, _)) - .WillOnce(SetArgPointee<1>(8)) - .RetiresOnSaturation(); - result->size = 0; - cmds::GetIntegerv cmd2; - cmd2.Init(GL_STENCIL_BITS, shared_memory_id_, shared_memory_offset_); - EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); - EXPECT_EQ(decoder_->GetGLES2Util()->GLGetNumValuesReturned(GL_STENCIL_BITS), - result->GetNumResults()); - EXPECT_EQ(GL_NO_ERROR, GetGLError()); - EXPECT_EQ(8, result->GetData()[0]); -} - -TEST_P(GLES2DecoderManualInitTest, ActualStencilDoesNotMatchRequestedStencil) { - InitState init; - init.has_stencil = true; - init.bind_generates_resource = true; - InitDecoder(init); - - EXPECT_CALL(*gl_, GetError()) - .WillOnce(Return(GL_NO_ERROR)) - .WillOnce(Return(GL_NO_ERROR)) - .RetiresOnSaturation(); - auto* result = - static_cast(shared_memory_address_); - EXPECT_CALL(*gl_, GetIntegerv(GL_STENCIL_BITS, _)) - .WillOnce(SetArgPointee<1>(8)) - .RetiresOnSaturation(); - result->size = 0; - cmds::GetIntegerv cmd2; - cmd2.Init(GL_STENCIL_BITS, shared_memory_id_, shared_memory_offset_); - EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); - EXPECT_EQ(decoder_->GetGLES2Util()->GLGetNumValuesReturned(GL_STENCIL_BITS), - result->GetNumResults()); - EXPECT_EQ(GL_NO_ERROR, GetGLError()); - EXPECT_EQ(0, result->GetData()[0]); -} - TEST_P(GLES2DecoderManualInitTest, PackedDepthStencilReportsCorrectValues) { InitState init; init.extensions = "GL_OES_packed_depth_stencil"; @@ -1806,47 +1682,6 @@ TEST_P(GLES2DecoderManualInitTest, PackedDepthStencilReportsCorrectValues) { EXPECT_EQ(24, result->GetData()[0]); } -TEST_P(GLES2DecoderManualInitTest, PackedDepthStencilNoRequestedStencil) { - InitState init; - init.extensions = "GL_OES_packed_depth_stencil"; - init.gl_version = "OpenGL ES 2.0"; - init.has_depth = true; - init.has_stencil = true; - init.request_depth = true; - init.bind_generates_resource = true; - InitDecoder(init); - - EXPECT_CALL(*gl_, GetError()) - .WillOnce(Return(GL_NO_ERROR)) - .WillOnce(Return(GL_NO_ERROR)) - .WillOnce(Return(GL_NO_ERROR)) - .WillOnce(Return(GL_NO_ERROR)) - .RetiresOnSaturation(); - auto* result = - static_cast(shared_memory_address_); - result->size = 0; - cmds::GetIntegerv cmd2; - cmd2.Init(GL_STENCIL_BITS, shared_memory_id_, shared_memory_offset_); - EXPECT_CALL(*gl_, GetIntegerv(GL_STENCIL_BITS, _)) - .WillOnce(SetArgPointee<1>(8)) - .RetiresOnSaturation(); - EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); - EXPECT_EQ(decoder_->GetGLES2Util()->GLGetNumValuesReturned(GL_STENCIL_BITS), - result->GetNumResults()); - EXPECT_EQ(GL_NO_ERROR, GetGLError()); - EXPECT_EQ(0, result->GetData()[0]); - result->size = 0; - cmd2.Init(GL_DEPTH_BITS, shared_memory_id_, shared_memory_offset_); - EXPECT_CALL(*gl_, GetIntegerv(GL_DEPTH_BITS, _)) - .WillOnce(SetArgPointee<1>(24)) - .RetiresOnSaturation(); - EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); - EXPECT_EQ(decoder_->GetGLES2Util()->GLGetNumValuesReturned(GL_DEPTH_BITS), - result->GetNumResults()); - EXPECT_EQ(GL_NO_ERROR, GetGLError()); - EXPECT_EQ(24, result->GetData()[0]); -} - TEST_P(GLES2DecoderManualInitTest, PackedDepthStencilRenderbufferDepth) { InitState init; init.extensions = "GL_OES_packed_depth_stencil"; @@ -3529,6 +3364,7 @@ TEST_P(GLES2DecoderManualInitTest, init.extensions = "GL_EXT_discard_framebuffer"; init.gl_version = "OpenGL ES 2.0"; init.has_alpha = true; + init.request_alpha = true; init.bind_generates_resource = true; InitDecoder(init); diff --git a/gpu/gles2_conform_support/egl/context.cc b/gpu/gles2_conform_support/egl/context.cc index 18e75792517026..dc105d332681dc 100644 --- a/gpu/gles2_conform_support/egl/context.cc +++ b/gpu/gles2_conform_support/egl/context.cc @@ -277,11 +277,16 @@ bool Context::CreateService(gl::GLSurface* gl_surface) { gl_context->MakeCurrent(gl_surface); - gpu::ContextCreationAttribs helper; - config_->GetAttrib(EGL_ALPHA_SIZE, &helper.alpha_size); - config_->GetAttrib(EGL_DEPTH_SIZE, &helper.depth_size); - config_->GetAttrib(EGL_STENCIL_SIZE, &helper.stencil_size); + EGLint alpha_size, depth_size, stencil_size; + config_->GetAttrib(EGL_ALPHA_SIZE, &alpha_size); + config_->GetAttrib(EGL_DEPTH_SIZE, &depth_size); + config_->GetAttrib(EGL_STENCIL_SIZE, &stencil_size); + + CHECK_EQ(alpha_size, 0); + CHECK_EQ(depth_size, 0); + CHECK_EQ(stencil_size, 0); + gpu::ContextCreationAttribs helper; helper.buffer_preserved = false; helper.bind_generates_resource = kBindGeneratesResources; helper.fail_if_major_perf_caveat = false;