Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(260)

Side by Side Diff: gpu/command_buffer/service/gles2_cmd_decoder.cc

Issue 2577293002: Change GetIntegerv(IMPLEMENTATION_COLOR_READ_FORMAT/TYPE) behavior. (Closed)
Patch Set: fix Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
6 6
7 #include <limits.h> 7 #include <limits.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 #include <stdio.h> 10 #include <stdio.h>
(...skipping 1918 matching lines...) Expand 10 before | Expand all | Expand 10 after
1929 case GL_INT_SAMPLER_2D_ARRAY: 1929 case GL_INT_SAMPLER_2D_ARRAY:
1930 case GL_UNSIGNED_INT_SAMPLER_2D_ARRAY: 1930 case GL_UNSIGNED_INT_SAMPLER_2D_ARRAY:
1931 return GL_TEXTURE_2D_ARRAY; 1931 return GL_TEXTURE_2D_ARRAY;
1932 default: 1932 default:
1933 NOTREACHED(); 1933 NOTREACHED();
1934 return 0; 1934 return 0;
1935 } 1935 }
1936 } 1936 }
1937 1937
1938 // Gets the framebuffer info for a particular target. 1938 // Gets the framebuffer info for a particular target.
1939 Framebuffer* GetFramebufferInfoForTarget(GLenum target) { 1939 Framebuffer* GetFramebufferInfoForTarget(GLenum target) const {
1940 Framebuffer* framebuffer = NULL; 1940 Framebuffer* framebuffer = nullptr;
1941 switch (target) { 1941 switch (target) {
1942 case GL_FRAMEBUFFER: 1942 case GL_FRAMEBUFFER:
1943 case GL_DRAW_FRAMEBUFFER_EXT: 1943 case GL_DRAW_FRAMEBUFFER_EXT:
1944 framebuffer = framebuffer_state_.bound_draw_framebuffer.get(); 1944 framebuffer = framebuffer_state_.bound_draw_framebuffer.get();
1945 break; 1945 break;
1946 case GL_READ_FRAMEBUFFER_EXT: 1946 case GL_READ_FRAMEBUFFER_EXT:
1947 framebuffer = framebuffer_state_.bound_read_framebuffer.get(); 1947 framebuffer = framebuffer_state_.bound_read_framebuffer.get();
1948 break; 1948 break;
1949 default: 1949 default:
1950 NOTREACHED(); 1950 NOTREACHED();
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
2128 // using GL_RGBA and glColorMask. 2128 // using GL_RGBA and glColorMask.
2129 bool ChromiumImageNeedsRGBEmulation(); 2129 bool ChromiumImageNeedsRGBEmulation();
2130 2130
2131 // The GL_CHROMIUM_schedule_ca_layer extension requires that SwapBuffers and 2131 // The GL_CHROMIUM_schedule_ca_layer extension requires that SwapBuffers and
2132 // equivalent functions reset shared state. 2132 // equivalent functions reset shared state.
2133 void ClearScheduleCALayerState(); 2133 void ClearScheduleCALayerState();
2134 2134
2135 // Helper method to call glClear workaround. 2135 // Helper method to call glClear workaround.
2136 void ClearFramebufferForWorkaround(GLbitfield mask); 2136 void ClearFramebufferForWorkaround(GLbitfield mask);
2137 2137
2138 bool SupportsSeparateFramebufferBinds() const {
2139 return (feature_info_->feature_flags().chromium_framebuffer_multisample ||
2140 feature_info_->IsWebGL2OrES3Context());
2141 }
2142
2143 GLenum GetDrawFramebufferTarget() const {
2144 return SupportsSeparateFramebufferBinds() ?
2145 GL_DRAW_FRAMEBUFFER : GL_FRAMEBUFFER;
2146 }
2147
2148 GLenum GetReadFramebufferTarget() const {
2149 return SupportsSeparateFramebufferBinds() ?
2150 GL_READ_FRAMEBUFFER : GL_FRAMEBUFFER;
2151 }
2152
2153 Framebuffer* GetBoundDrawFramebuffer() const {
2154 return framebuffer_state_.bound_draw_framebuffer.get();
2155 }
2156
2157 Framebuffer* GetBoundReadFramebuffer() const {
2158 GLenum target = GetReadFramebufferTarget();
2159 return GetFramebufferInfoForTarget(target);
2160 }
2161
2138 bool InitializeCopyTexImageBlitter(const char* function_name); 2162 bool InitializeCopyTexImageBlitter(const char* function_name);
2139 bool InitializeCopyTextureCHROMIUM(const char* function_name); 2163 bool InitializeCopyTextureCHROMIUM(const char* function_name);
2140 bool InitializeSRGBConverter(const char* function_name); 2164 bool InitializeSRGBConverter(const char* function_name);
2141 // Generate a member function prototype for each command in an automated and 2165 // Generate a member function prototype for each command in an automated and
2142 // typesafe way. 2166 // typesafe way.
2143 #define GLES2_CMD_OP(name) \ 2167 #define GLES2_CMD_OP(name) \
2144 Error Handle##name(uint32_t immediate_data_size, const volatile void* data); 2168 Error Handle##name(uint32_t immediate_data_size, const volatile void* data);
2145 2169
2146 GLES2_COMMAND_LIST(GLES2_CMD_OP) 2170 GLES2_COMMAND_LIST(GLES2_CMD_OP)
2147 2171
(...skipping 1853 matching lines...) Expand 10 before | Expand all | Expand 10 after
4001 buffer->RemoveMappedRange(); 4025 buffer->RemoveMappedRange();
4002 state_.RemoveBoundBuffer(buffer); 4026 state_.RemoveBoundBuffer(buffer);
4003 RemoveBuffer(client_id); 4027 RemoveBuffer(client_id);
4004 } 4028 }
4005 } 4029 }
4006 } 4030 }
4007 4031
4008 void GLES2DecoderImpl::DeleteFramebuffersHelper( 4032 void GLES2DecoderImpl::DeleteFramebuffersHelper(
4009 GLsizei n, 4033 GLsizei n,
4010 const volatile GLuint* client_ids) { 4034 const volatile GLuint* client_ids) {
4011 bool supports_separate_framebuffer_binds =
4012 features().chromium_framebuffer_multisample;
4013
4014 for (GLsizei ii = 0; ii < n; ++ii) { 4035 for (GLsizei ii = 0; ii < n; ++ii) {
4015 GLuint client_id = client_ids[ii]; 4036 GLuint client_id = client_ids[ii];
4016 Framebuffer* framebuffer = GetFramebuffer(client_id); 4037 Framebuffer* framebuffer = GetFramebuffer(client_id);
4017 if (framebuffer && !framebuffer->IsDeleted()) { 4038 if (framebuffer && !framebuffer->IsDeleted()) {
4018 if (framebuffer == framebuffer_state_.bound_draw_framebuffer.get()) { 4039 if (framebuffer == framebuffer_state_.bound_draw_framebuffer.get()) {
4019 GLenum target = supports_separate_framebuffer_binds ? 4040 GLenum target = GetDrawFramebufferTarget();
4020 GL_DRAW_FRAMEBUFFER_EXT : GL_FRAMEBUFFER;
4021 4041
4022 // Unbind attachments on FBO before deletion. 4042 // Unbind attachments on FBO before deletion.
4023 if (workarounds().unbind_attachments_on_bound_render_fbo_delete) 4043 if (workarounds().unbind_attachments_on_bound_render_fbo_delete)
4024 framebuffer->DoUnbindGLAttachmentsForWorkaround(target); 4044 framebuffer->DoUnbindGLAttachmentsForWorkaround(target);
4025 4045
4026 glBindFramebufferEXT(target, GetBackbufferServiceId()); 4046 glBindFramebufferEXT(target, GetBackbufferServiceId());
4027 framebuffer_state_.bound_draw_framebuffer = NULL; 4047 framebuffer_state_.bound_draw_framebuffer = NULL;
4028 framebuffer_state_.clear_state_dirty = true; 4048 framebuffer_state_.clear_state_dirty = true;
4029 } 4049 }
4030 if (framebuffer == framebuffer_state_.bound_read_framebuffer.get()) { 4050 if (framebuffer == framebuffer_state_.bound_read_framebuffer.get()) {
4031 framebuffer_state_.bound_read_framebuffer = NULL; 4051 framebuffer_state_.bound_read_framebuffer = NULL;
4032 GLenum target = supports_separate_framebuffer_binds ? 4052 GLenum target = GetReadFramebufferTarget();
4033 GL_READ_FRAMEBUFFER_EXT : GL_FRAMEBUFFER;
4034 glBindFramebufferEXT(target, GetBackbufferServiceId()); 4053 glBindFramebufferEXT(target, GetBackbufferServiceId());
4035 } 4054 }
4036 OnFboChanged(); 4055 OnFboChanged();
4037 RemoveFramebuffer(client_id); 4056 RemoveFramebuffer(client_id);
4038 } 4057 }
4039 } 4058 }
4040 } 4059 }
4041 4060
4042 void GLES2DecoderImpl::DeleteRenderbuffersHelper( 4061 void GLES2DecoderImpl::DeleteRenderbuffersHelper(
4043 GLsizei n, 4062 GLsizei n,
(...skipping 24 matching lines...) Expand all
4068 } 4087 }
4069 } 4088 }
4070 framebuffer_state_.clear_state_dirty = true; 4089 framebuffer_state_.clear_state_dirty = true;
4071 RemoveRenderbuffer(client_id); 4090 RemoveRenderbuffer(client_id);
4072 } 4091 }
4073 } 4092 }
4074 } 4093 }
4075 4094
4076 void GLES2DecoderImpl::DeleteTexturesHelper(GLsizei n, 4095 void GLES2DecoderImpl::DeleteTexturesHelper(GLsizei n,
4077 const volatile GLuint* client_ids) { 4096 const volatile GLuint* client_ids) {
4078 bool supports_separate_framebuffer_binds = 4097 bool supports_separate_framebuffer_binds = SupportsSeparateFramebufferBinds();
4079 features().chromium_framebuffer_multisample;
4080 for (GLsizei ii = 0; ii < n; ++ii) { 4098 for (GLsizei ii = 0; ii < n; ++ii) {
4081 GLuint client_id = client_ids[ii]; 4099 GLuint client_id = client_ids[ii];
4082 TextureRef* texture_ref = GetTexture(client_id); 4100 TextureRef* texture_ref = GetTexture(client_id);
4083 if (texture_ref) { 4101 if (texture_ref) {
4084 Texture* texture = texture_ref->texture(); 4102 Texture* texture = texture_ref->texture();
4085 if (texture->IsAttachedToFramebuffer()) { 4103 if (texture->IsAttachedToFramebuffer()) {
4086 framebuffer_state_.clear_state_dirty = true; 4104 framebuffer_state_.clear_state_dirty = true;
4087 } 4105 }
4088 // Unbind texture_ref from texture_ref units. 4106 // Unbind texture_ref from texture_ref units.
4089 state_.UnbindTexture(texture_ref); 4107 state_.UnbindTexture(texture_ref);
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
4211 if (framebuffer_id == 0) { 4229 if (framebuffer_id == 0) {
4212 framebuffer_id = back_buffer_service_id; 4230 framebuffer_id = back_buffer_service_id;
4213 } 4231 }
4214 4232
4215 glBindFramebufferEXT(target, framebuffer_id); 4233 glBindFramebufferEXT(target, framebuffer_id);
4216 } 4234 }
4217 4235
4218 void GLES2DecoderImpl::RestoreCurrentFramebufferBindings() { 4236 void GLES2DecoderImpl::RestoreCurrentFramebufferBindings() {
4219 framebuffer_state_.clear_state_dirty = true; 4237 framebuffer_state_.clear_state_dirty = true;
4220 4238
4221 if (!features().chromium_framebuffer_multisample) { 4239 if (!SupportsSeparateFramebufferBinds()) {
4222 RebindCurrentFramebuffer( 4240 RebindCurrentFramebuffer(
4223 GL_FRAMEBUFFER, 4241 GL_FRAMEBUFFER,
4224 framebuffer_state_.bound_draw_framebuffer.get(), 4242 framebuffer_state_.bound_draw_framebuffer.get(),
4225 GetBackbufferServiceId()); 4243 GetBackbufferServiceId());
4226 } else { 4244 } else {
4227 RebindCurrentFramebuffer( 4245 RebindCurrentFramebuffer(
4228 GL_READ_FRAMEBUFFER_EXT, 4246 GL_READ_FRAMEBUFFER_EXT,
4229 framebuffer_state_.bound_read_framebuffer.get(), 4247 framebuffer_state_.bound_read_framebuffer.get(),
4230 GetBackbufferServiceId()); 4248 GetBackbufferServiceId());
4231 RebindCurrentFramebuffer( 4249 RebindCurrentFramebuffer(
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
4299 if (renderbuffer_manager()->HaveUnclearedRenderbuffers() || 4317 if (renderbuffer_manager()->HaveUnclearedRenderbuffers() ||
4300 texture_manager()->HaveUnclearedMips()) { 4318 texture_manager()->HaveUnclearedMips()) {
4301 if (!framebuffer->IsCleared()) { 4319 if (!framebuffer->IsCleared()) {
4302 ClearUnclearedAttachments(target, framebuffer); 4320 ClearUnclearedAttachments(target, framebuffer);
4303 } 4321 }
4304 } 4322 }
4305 return true; 4323 return true;
4306 } 4324 }
4307 4325
4308 bool GLES2DecoderImpl::CheckBoundDrawFramebufferValid(const char* func_name) { 4326 bool GLES2DecoderImpl::CheckBoundDrawFramebufferValid(const char* func_name) {
4309 GLenum target = features().chromium_framebuffer_multisample ? 4327 Framebuffer* framebuffer = GetBoundDrawFramebuffer();
4310 GL_DRAW_FRAMEBUFFER : GL_FRAMEBUFFER;
4311 Framebuffer* framebuffer = GetFramebufferInfoForTarget(target);
4312 bool valid = CheckFramebufferValid( 4328 bool valid = CheckFramebufferValid(
4313 framebuffer, target, GL_INVALID_FRAMEBUFFER_OPERATION, func_name); 4329 framebuffer, GetDrawFramebufferTarget(),
4330 GL_INVALID_FRAMEBUFFER_OPERATION, func_name);
4314 if (!valid) 4331 if (!valid)
4315 return false; 4332 return false;
4316 4333
4317 if (!features().chromium_framebuffer_multisample) 4334 if (!SupportsSeparateFramebufferBinds())
4318 OnUseFramebuffer(); 4335 OnUseFramebuffer();
4319 4336
4320 UpdateFramebufferSRGB(framebuffer); 4337 UpdateFramebufferSRGB(framebuffer);
4321 return true; 4338 return true;
4322 } 4339 }
4323 4340
4324 void GLES2DecoderImpl::UpdateFramebufferSRGB(Framebuffer* framebuffer) { 4341 void GLES2DecoderImpl::UpdateFramebufferSRGB(Framebuffer* framebuffer) {
4325 // Manually set the value of FRAMEBUFFER_SRGB based on the state that was set 4342 // Manually set the value of FRAMEBUFFER_SRGB based on the state that was set
4326 // by the client. 4343 // by the client.
4327 bool needs_enable_disable_framebuffer_srgb = false; 4344 bool needs_enable_disable_framebuffer_srgb = false;
(...skipping 11 matching lines...) Expand all
4339 needs_enable_disable_framebuffer_srgb = true; 4356 needs_enable_disable_framebuffer_srgb = true;
4340 // Assume that the default fbo does not have an sRGB image. 4357 // Assume that the default fbo does not have an sRGB image.
4341 enable_framebuffer_srgb &= framebuffer && framebuffer->HasSRGBAttachments(); 4358 enable_framebuffer_srgb &= framebuffer && framebuffer->HasSRGBAttachments();
4342 } 4359 }
4343 if (needs_enable_disable_framebuffer_srgb) 4360 if (needs_enable_disable_framebuffer_srgb)
4344 state_.EnableDisableFramebufferSRGB(enable_framebuffer_srgb); 4361 state_.EnableDisableFramebufferSRGB(enable_framebuffer_srgb);
4345 } 4362 }
4346 4363
4347 bool GLES2DecoderImpl::CheckBoundReadFramebufferValid( 4364 bool GLES2DecoderImpl::CheckBoundReadFramebufferValid(
4348 const char* func_name, GLenum gl_error) { 4365 const char* func_name, GLenum gl_error) {
4349 GLenum target = features().chromium_framebuffer_multisample ? 4366 Framebuffer* framebuffer = GetBoundReadFramebuffer();
4350 GL_READ_FRAMEBUFFER : GL_FRAMEBUFFER;
4351 Framebuffer* framebuffer = GetFramebufferInfoForTarget(target);
4352 bool valid = CheckFramebufferValid( 4367 bool valid = CheckFramebufferValid(
4353 framebuffer, target, gl_error, func_name); 4368 framebuffer, GetReadFramebufferTarget(), gl_error, func_name);
4354 return valid; 4369 return valid;
4355 } 4370 }
4356 4371
4357 bool GLES2DecoderImpl::CheckBoundFramebufferValid(const char* func_name) { 4372 bool GLES2DecoderImpl::CheckBoundFramebufferValid(const char* func_name) {
4358 GLenum target = features().chromium_framebuffer_multisample ? 4373 GLenum gl_error = GL_INVALID_FRAMEBUFFER_OPERATION;
4359 GL_DRAW_FRAMEBUFFER : GL_FRAMEBUFFER; 4374 Framebuffer* draw_framebuffer = GetBoundDrawFramebuffer();
4360 Framebuffer* draw_framebuffer = GetFramebufferInfoForTarget(target);
4361 bool valid = CheckFramebufferValid( 4375 bool valid = CheckFramebufferValid(
4362 draw_framebuffer, target, GL_INVALID_FRAMEBUFFER_OPERATION, func_name); 4376 draw_framebuffer, GetDrawFramebufferTarget(), gl_error, func_name);
4363 4377
4364 target = features().chromium_framebuffer_multisample ? 4378 Framebuffer* read_framebuffer = GetBoundReadFramebuffer();
4365 GL_READ_FRAMEBUFFER : GL_FRAMEBUFFER;
4366 Framebuffer* read_framebuffer = GetFramebufferInfoForTarget(target);
4367 valid = valid && CheckFramebufferValid( 4379 valid = valid && CheckFramebufferValid(
4368 read_framebuffer, target, GL_INVALID_FRAMEBUFFER_OPERATION, func_name); 4380 read_framebuffer, GetReadFramebufferTarget(), gl_error, func_name);
4369 return valid; 4381 return valid;
4370 } 4382 }
4371 4383
4372 GLint GLES2DecoderImpl::GetColorEncodingFromInternalFormat( 4384 GLint GLES2DecoderImpl::GetColorEncodingFromInternalFormat(
4373 GLenum internalformat) { 4385 GLenum internalformat) {
4374 switch (internalformat) { 4386 switch (internalformat) {
4375 case GL_SRGB_EXT: 4387 case GL_SRGB_EXT:
4376 case GL_SRGB_ALPHA_EXT: 4388 case GL_SRGB_ALPHA_EXT:
4377 case GL_SRGB8: 4389 case GL_SRGB8:
4378 case GL_SRGB8_ALPHA8: 4390 case GL_SRGB8_ALPHA8:
4379 return GL_SRGB; 4391 return GL_SRGB;
4380 default: 4392 default:
4381 return GL_LINEAR; 4393 return GL_LINEAR;
4382 } 4394 }
4383 } 4395 }
4384 4396
4385 bool GLES2DecoderImpl::FormsTextureCopyingFeedbackLoop( 4397 bool GLES2DecoderImpl::FormsTextureCopyingFeedbackLoop(
4386 TextureRef* texture, GLint level, GLint layer) { 4398 TextureRef* texture, GLint level, GLint layer) {
4387 Framebuffer* framebuffer = features().chromium_framebuffer_multisample ? 4399 Framebuffer* framebuffer = GetBoundReadFramebuffer();
4388 framebuffer_state_.bound_read_framebuffer.get() :
4389 framebuffer_state_.bound_draw_framebuffer.get();
4390 if (!framebuffer) 4400 if (!framebuffer)
4391 return false; 4401 return false;
4392 const Framebuffer::Attachment* attachment = 4402 const Framebuffer::Attachment* attachment =
4393 framebuffer->GetReadBufferAttachment(); 4403 framebuffer->GetReadBufferAttachment();
4394 if (!attachment) 4404 if (!attachment)
4395 return false; 4405 return false;
4396 return attachment->FormsFeedbackLoop(texture, level, layer); 4406 return attachment->FormsFeedbackLoop(texture, level, layer);
4397 } 4407 }
4398 4408
4399 gfx::Size GLES2DecoderImpl::GetBoundReadFramebufferSize() { 4409 gfx::Size GLES2DecoderImpl::GetBoundReadFramebufferSize() {
4400 Framebuffer* framebuffer = 4410 Framebuffer* framebuffer = GetBoundReadFramebuffer();
4401 GetFramebufferInfoForTarget(GL_READ_FRAMEBUFFER_EXT); 4411 if (framebuffer) {
4402 if (framebuffer != NULL) {
4403 const Framebuffer::Attachment* attachment = 4412 const Framebuffer::Attachment* attachment =
4404 framebuffer->GetReadBufferAttachment(); 4413 framebuffer->GetReadBufferAttachment();
4405 if (attachment) { 4414 if (attachment) {
4406 return gfx::Size(attachment->width(), attachment->height()); 4415 return gfx::Size(attachment->width(), attachment->height());
4407 } 4416 }
4408 return gfx::Size(0, 0); 4417 return gfx::Size(0, 0);
4409 } else if (offscreen_target_frame_buffer_.get()) { 4418 } else if (offscreen_target_frame_buffer_.get()) {
4410 return offscreen_size_; 4419 return offscreen_size_;
4411 } else { 4420 } else {
4412 return surface_->GetSize(); 4421 return surface_->GetSize();
4413 } 4422 }
4414 } 4423 }
4415 4424
4416 GLuint GLES2DecoderImpl::GetBoundReadFramebufferServiceId() { 4425 GLuint GLES2DecoderImpl::GetBoundReadFramebufferServiceId() {
4417 Framebuffer* framebuffer = 4426 Framebuffer* framebuffer = GetBoundReadFramebuffer();
4418 GetFramebufferInfoForTarget(GL_READ_FRAMEBUFFER_EXT);
4419 if (framebuffer) { 4427 if (framebuffer) {
4420 return framebuffer->service_id(); 4428 return framebuffer->service_id();
4421 } 4429 }
4422 if (offscreen_resolved_frame_buffer_.get()) { 4430 if (offscreen_resolved_frame_buffer_.get()) {
4423 return offscreen_resolved_frame_buffer_->id(); 4431 return offscreen_resolved_frame_buffer_->id();
4424 } 4432 }
4425 if (offscreen_target_frame_buffer_.get()) { 4433 if (offscreen_target_frame_buffer_.get()) {
4426 return offscreen_target_frame_buffer_->id(); 4434 return offscreen_target_frame_buffer_->id();
4427 } 4435 }
4428 if (surface_.get()) { 4436 if (surface_.get()) {
4429 return surface_->GetBackingFramebufferObject(); 4437 return surface_->GetBackingFramebufferObject();
4430 } 4438 }
4431 return 0; 4439 return 0;
4432 } 4440 }
4433 4441
4434 GLuint GLES2DecoderImpl::GetBoundDrawFramebufferServiceId() { 4442 GLuint GLES2DecoderImpl::GetBoundDrawFramebufferServiceId() {
4435 Framebuffer* framebuffer = 4443 Framebuffer* framebuffer = GetBoundDrawFramebuffer();
4436 GetFramebufferInfoForTarget(GL_DRAW_FRAMEBUFFER_EXT);
4437 if (framebuffer) { 4444 if (framebuffer) {
4438 return framebuffer->service_id(); 4445 return framebuffer->service_id();
4439 } 4446 }
4440 if (offscreen_target_frame_buffer_.get()) { 4447 if (offscreen_target_frame_buffer_.get()) {
4441 return offscreen_target_frame_buffer_->id(); 4448 return offscreen_target_frame_buffer_->id();
4442 } 4449 }
4443 if (surface_.get()) { 4450 if (surface_.get()) {
4444 return surface_->GetBackingFramebufferObject(); 4451 return surface_->GetBackingFramebufferObject();
4445 } 4452 }
4446 return 0; 4453 return 0;
4447 } 4454 }
4448 4455
4449 GLenum GLES2DecoderImpl::GetBoundReadFramebufferTextureType() { 4456 GLenum GLES2DecoderImpl::GetBoundReadFramebufferTextureType() {
4450 Framebuffer* framebuffer = 4457 Framebuffer* framebuffer = GetBoundReadFramebuffer();
4451 GetFramebufferInfoForTarget(GL_READ_FRAMEBUFFER_EXT);
4452 if (framebuffer) { 4458 if (framebuffer) {
4453 return framebuffer->GetReadBufferTextureType(); 4459 return framebuffer->GetReadBufferTextureType();
4454 } else { // Back buffer. 4460 } else { // Back buffer.
4455 if (back_buffer_read_buffer_ == GL_NONE) 4461 if (back_buffer_read_buffer_ == GL_NONE)
4456 return 0; 4462 return 0;
4457 return GL_UNSIGNED_BYTE; 4463 return GL_UNSIGNED_BYTE;
4458 } 4464 }
4459 } 4465 }
4460 4466
4461 GLenum GLES2DecoderImpl::GetBoundReadFramebufferInternalFormat() { 4467 GLenum GLES2DecoderImpl::GetBoundReadFramebufferInternalFormat() {
4462 Framebuffer* framebuffer = 4468 Framebuffer* framebuffer = GetBoundReadFramebuffer();
4463 GetFramebufferInfoForTarget(GL_READ_FRAMEBUFFER_EXT);
4464 if (framebuffer) { 4469 if (framebuffer) {
4465 return framebuffer->GetReadBufferInternalFormat(); 4470 return framebuffer->GetReadBufferInternalFormat();
4466 } else { // Back buffer. 4471 } else { // Back buffer.
4467 if (back_buffer_read_buffer_ == GL_NONE) 4472 if (back_buffer_read_buffer_ == GL_NONE)
4468 return 0; 4473 return 0;
4469 if (offscreen_target_frame_buffer_.get()) { 4474 if (offscreen_target_frame_buffer_.get()) {
4470 return offscreen_target_color_format_; 4475 return offscreen_target_color_format_;
4471 } 4476 }
4472 return back_buffer_color_format_; 4477 return back_buffer_color_format_;
4473 } 4478 }
4474 } 4479 }
4475 4480
4476 GLenum GLES2DecoderImpl::GetBoundColorDrawBufferType(GLint drawbuffer_i) { 4481 GLenum GLES2DecoderImpl::GetBoundColorDrawBufferType(GLint drawbuffer_i) {
4477 DCHECK(drawbuffer_i >= 0 && 4482 DCHECK(drawbuffer_i >= 0 &&
4478 drawbuffer_i < static_cast<GLint>(group_->max_draw_buffers())); 4483 drawbuffer_i < static_cast<GLint>(group_->max_draw_buffers()));
4479 Framebuffer* framebuffer = GetFramebufferInfoForTarget(GL_DRAW_FRAMEBUFFER); 4484 Framebuffer* framebuffer = GetBoundDrawFramebuffer();
4480 if (!framebuffer) { 4485 if (!framebuffer) {
4481 return 0; 4486 return 0;
4482 } 4487 }
4483 GLenum drawbuffer = static_cast<GLenum>(GL_DRAW_BUFFER0 + drawbuffer_i); 4488 GLenum drawbuffer = static_cast<GLenum>(GL_DRAW_BUFFER0 + drawbuffer_i);
4484 if (framebuffer->GetDrawBuffer(drawbuffer) == GL_NONE) { 4489 if (framebuffer->GetDrawBuffer(drawbuffer) == GL_NONE) {
4485 return 0; 4490 return 0;
4486 } 4491 }
4487 GLenum attachment = static_cast<GLenum>(GL_COLOR_ATTACHMENT0 + drawbuffer_i); 4492 GLenum attachment = static_cast<GLenum>(GL_COLOR_ATTACHMENT0 + drawbuffer_i);
4488 const Framebuffer::Attachment* buffer = 4493 const Framebuffer::Attachment* buffer =
4489 framebuffer->GetAttachment(attachment); 4494 framebuffer->GetAttachment(attachment);
4490 if (!buffer) { 4495 if (!buffer) {
4491 return 0; 4496 return 0;
4492 } 4497 }
4493 return buffer->texture_type(); 4498 return buffer->texture_type();
4494 } 4499 }
4495 4500
4496 GLenum GLES2DecoderImpl::GetBoundColorDrawBufferInternalFormat( 4501 GLenum GLES2DecoderImpl::GetBoundColorDrawBufferInternalFormat(
4497 GLint drawbuffer_i) { 4502 GLint drawbuffer_i) {
4498 DCHECK(drawbuffer_i >= 0 && 4503 DCHECK(drawbuffer_i >= 0 &&
4499 drawbuffer_i < static_cast<GLint>(group_->max_draw_buffers())); 4504 drawbuffer_i < static_cast<GLint>(group_->max_draw_buffers()));
4500 Framebuffer* framebuffer = GetFramebufferInfoForTarget(GL_DRAW_FRAMEBUFFER); 4505 Framebuffer* framebuffer = GetBoundDrawFramebuffer();
4501 if (!framebuffer) { 4506 if (!framebuffer) {
4502 return 0; 4507 return 0;
4503 } 4508 }
4504 GLenum drawbuffer = static_cast<GLenum>(GL_DRAW_BUFFER0 + drawbuffer_i); 4509 GLenum drawbuffer = static_cast<GLenum>(GL_DRAW_BUFFER0 + drawbuffer_i);
4505 if (framebuffer->GetDrawBuffer(drawbuffer) == GL_NONE) { 4510 if (framebuffer->GetDrawBuffer(drawbuffer) == GL_NONE) {
4506 return 0; 4511 return 0;
4507 } 4512 }
4508 GLenum attachment = static_cast<GLenum>(GL_COLOR_ATTACHMENT0 + drawbuffer_i); 4513 GLenum attachment = static_cast<GLenum>(GL_COLOR_ATTACHMENT0 + drawbuffer_i);
4509 const Framebuffer::Attachment* buffer = 4514 const Framebuffer::Attachment* buffer =
4510 framebuffer->GetAttachment(attachment); 4515 framebuffer->GetAttachment(attachment);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
4557 return offscreen_target_stencil_format_; 4562 return offscreen_target_stencil_format_;
4558 } 4563 }
4559 if (back_buffer_has_stencil_) 4564 if (back_buffer_has_stencil_)
4560 return GL_STENCIL; 4565 return GL_STENCIL;
4561 return 0; 4566 return 0;
4562 } 4567 }
4563 } 4568 }
4564 4569
4565 void GLES2DecoderImpl::MarkDrawBufferAsCleared( 4570 void GLES2DecoderImpl::MarkDrawBufferAsCleared(
4566 GLenum buffer, GLint drawbuffer_i) { 4571 GLenum buffer, GLint drawbuffer_i) {
4567 Framebuffer* framebuffer = GetFramebufferInfoForTarget(GL_DRAW_FRAMEBUFFER); 4572 Framebuffer* framebuffer = GetBoundDrawFramebuffer();
4568 if (!framebuffer) 4573 if (!framebuffer)
4569 return; 4574 return;
4570 GLenum attachment = 0; 4575 GLenum attachment = 0;
4571 switch (buffer) { 4576 switch (buffer) {
4572 case GL_COLOR: 4577 case GL_COLOR:
4573 DCHECK(drawbuffer_i >= 0 && 4578 DCHECK(drawbuffer_i >= 0 &&
4574 drawbuffer_i < static_cast<GLint>(group_->max_draw_buffers())); 4579 drawbuffer_i < static_cast<GLint>(group_->max_draw_buffers()));
4575 attachment = static_cast<GLenum>(GL_COLOR_ATTACHMENT0 + drawbuffer_i); 4580 attachment = static_cast<GLenum>(GL_COLOR_ATTACHMENT0 + drawbuffer_i);
4576 break; 4581 break;
4577 case GL_DEPTH: 4582 case GL_DEPTH:
(...skipping 857 matching lines...) Expand 10 before | Expand all | Expand 10 after
5435 5440
5436 void GLES2DecoderImpl::DoBindBufferRange(GLenum target, GLuint index, 5441 void GLES2DecoderImpl::DoBindBufferRange(GLenum target, GLuint index,
5437 GLuint client_id, 5442 GLuint client_id,
5438 GLintptr offset, 5443 GLintptr offset,
5439 GLsizeiptr size) { 5444 GLsizeiptr size) {
5440 BindIndexedBufferImpl(target, index, client_id, offset, size, 5445 BindIndexedBufferImpl(target, index, client_id, offset, size,
5441 kBindBufferRange, "glBindBufferRange"); 5446 kBindBufferRange, "glBindBufferRange");
5442 } 5447 }
5443 5448
5444 bool GLES2DecoderImpl::BoundFramebufferAllowsChangesToAlphaChannel() { 5449 bool GLES2DecoderImpl::BoundFramebufferAllowsChangesToAlphaChannel() {
5445 Framebuffer* framebuffer = 5450 Framebuffer* framebuffer = GetBoundDrawFramebuffer();
5446 GetFramebufferInfoForTarget(GL_DRAW_FRAMEBUFFER_EXT);
5447 if (framebuffer) 5451 if (framebuffer)
5448 return framebuffer->HasAlphaMRT(); 5452 return framebuffer->HasAlphaMRT();
5449 if (back_buffer_draw_buffer_ == GL_NONE) 5453 if (back_buffer_draw_buffer_ == GL_NONE)
5450 return false; 5454 return false;
5451 if (offscreen_target_frame_buffer_.get()) { 5455 if (offscreen_target_frame_buffer_.get()) {
5452 GLenum format = offscreen_target_color_format_; 5456 GLenum format = offscreen_target_color_format_;
5453 return (format == GL_RGBA || format == GL_RGBA8) && 5457 return (format == GL_RGBA || format == GL_RGBA8) &&
5454 offscreen_buffer_should_have_alpha_; 5458 offscreen_buffer_should_have_alpha_;
5455 } 5459 }
5456 return (back_buffer_color_format_ == GL_RGBA || 5460 return (back_buffer_color_format_ == GL_RGBA ||
5457 back_buffer_color_format_ == GL_RGBA8); 5461 back_buffer_color_format_ == GL_RGBA8);
5458 } 5462 }
5459 5463
5460 bool GLES2DecoderImpl::BoundFramebufferHasDepthAttachment() { 5464 bool GLES2DecoderImpl::BoundFramebufferHasDepthAttachment() {
5461 Framebuffer* framebuffer = 5465 Framebuffer* framebuffer = GetBoundDrawFramebuffer();
5462 GetFramebufferInfoForTarget(GL_DRAW_FRAMEBUFFER_EXT);
5463 if (framebuffer) { 5466 if (framebuffer) {
5464 return framebuffer->HasDepthAttachment(); 5467 return framebuffer->HasDepthAttachment();
5465 } 5468 }
5466 if (offscreen_target_frame_buffer_.get()) { 5469 if (offscreen_target_frame_buffer_.get()) {
5467 return offscreen_target_depth_format_ != 0; 5470 return offscreen_target_depth_format_ != 0;
5468 } 5471 }
5469 return back_buffer_has_depth_; 5472 return back_buffer_has_depth_;
5470 } 5473 }
5471 5474
5472 bool GLES2DecoderImpl::BoundFramebufferHasStencilAttachment() { 5475 bool GLES2DecoderImpl::BoundFramebufferHasStencilAttachment() {
5473 Framebuffer* framebuffer = 5476 Framebuffer* framebuffer = GetBoundDrawFramebuffer();
5474 GetFramebufferInfoForTarget(GL_DRAW_FRAMEBUFFER_EXT);
5475 if (framebuffer) { 5477 if (framebuffer) {
5476 return framebuffer->HasStencilAttachment(); 5478 return framebuffer->HasStencilAttachment();
5477 } 5479 }
5478 if (offscreen_target_frame_buffer_.get()) { 5480 if (offscreen_target_frame_buffer_.get()) {
5479 return offscreen_target_stencil_format_ != 0 || 5481 return offscreen_target_stencil_format_ != 0 ||
5480 offscreen_target_depth_format_ == GL_DEPTH24_STENCIL8; 5482 offscreen_target_depth_format_ == GL_DEPTH24_STENCIL8;
5481 } 5483 }
5482 return back_buffer_has_stencil_; 5484 return back_buffer_has_stencil_;
5483 } 5485 }
5484 5486
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
5520 // the size of the current framebuffer object. 5522 // the size of the current framebuffer object.
5521 RestoreFramebufferBindings(); 5523 RestoreFramebufferBindings();
5522 state_.RestoreState(prev_state); 5524 state_.RestoreState(prev_state);
5523 } 5525 }
5524 5526
5525 void GLES2DecoderImpl::RestoreFramebufferBindings() const { 5527 void GLES2DecoderImpl::RestoreFramebufferBindings() const {
5526 GLuint service_id = 5528 GLuint service_id =
5527 framebuffer_state_.bound_draw_framebuffer.get() 5529 framebuffer_state_.bound_draw_framebuffer.get()
5528 ? framebuffer_state_.bound_draw_framebuffer->service_id() 5530 ? framebuffer_state_.bound_draw_framebuffer->service_id()
5529 : GetBackbufferServiceId(); 5531 : GetBackbufferServiceId();
5530 if (!features().chromium_framebuffer_multisample) { 5532 if (!SupportsSeparateFramebufferBinds()) {
5531 glBindFramebufferEXT(GL_FRAMEBUFFER, service_id); 5533 glBindFramebufferEXT(GL_FRAMEBUFFER, service_id);
5532 } else { 5534 } else {
5533 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER, service_id); 5535 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER, service_id);
5534 service_id = framebuffer_state_.bound_read_framebuffer.get() 5536 service_id = framebuffer_state_.bound_read_framebuffer.get()
5535 ? framebuffer_state_.bound_read_framebuffer->service_id() 5537 ? framebuffer_state_.bound_read_framebuffer->service_id()
5536 : GetBackbufferServiceId(); 5538 : GetBackbufferServiceId();
5537 glBindFramebufferEXT(GL_READ_FRAMEBUFFER, service_id); 5539 glBindFramebufferEXT(GL_READ_FRAMEBUFFER, service_id);
5538 } 5540 }
5539 OnFboChanged(); 5541 OnFboChanged();
5540 } 5542 }
(...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after
6202 texture_manager()->MarkMipmapsGenerated(texture_ref); 6204 texture_manager()->MarkMipmapsGenerated(texture_ref);
6203 } 6205 }
6204 } 6206 }
6205 6207
6206 bool GLES2DecoderImpl::GetHelper( 6208 bool GLES2DecoderImpl::GetHelper(
6207 GLenum pname, GLint* params, GLsizei* num_written) { 6209 GLenum pname, GLint* params, GLsizei* num_written) {
6208 DCHECK(num_written); 6210 DCHECK(num_written);
6209 switch (pname) { 6211 switch (pname) {
6210 case GL_IMPLEMENTATION_COLOR_READ_FORMAT: 6212 case GL_IMPLEMENTATION_COLOR_READ_FORMAT:
6211 case GL_IMPLEMENTATION_COLOR_READ_TYPE: 6213 case GL_IMPLEMENTATION_COLOR_READ_TYPE:
6212 // They are not supported on Desktop GL until 4.1, but could be exposed
6213 // through GL_OES_read_format extension. However, a conflicting extension
6214 // GL_ARB_ES2_compatibility specifies an error case when requested on
6215 // integer/floating point buffers.
6216 // To simpify the handling, we just query and check for GL errors. If an
6217 // GL error occur, we fall back to our internal implementation.
6218 *num_written = 1; 6214 *num_written = 1;
6219 if (!CheckBoundReadFramebufferValid("glGetIntegerv", 6215 {
6220 GL_INVALID_OPERATION)) { 6216 Framebuffer* framebuffer = GetBoundReadFramebuffer();
6221 if (params) { 6217 if (framebuffer &&
6222 *params = 0; 6218 framebuffer->IsPossiblyComplete(feature_info_.get()) !=
6219 GL_FRAMEBUFFER_COMPLETE) {
6220 // Here we avoid querying the driver framebuffer status because the
6221 // above should cover most cases. This is an effort to reduce crashes
6222 // on MacOSX. See crbug.com/662802.
6223 LOCAL_SET_GL_ERROR(
6224 GL_INVALID_OPERATION, "glGetIntegerv", "incomplete framebuffer");
6225 if (params) {
6226 *params = 0;
6227 }
6228 return true;
6223 } 6229 }
6224 return true;
6225 } 6230 }
6226 if (params) { 6231 if (params) {
6227 ScopedGLErrorSuppressor suppressor("GLES2DecoderImpl::GetHelper", 6232 if (feature_info_->gl_version_info().is_es) {
6228 GetErrorState()); 6233 glGetIntegerv(pname, params);
6229 glGetIntegerv(pname, params); 6234 } else {
6230 bool is_valid = glGetError() == GL_NO_ERROR; 6235 // On Desktop GL where these two enums can be queried, instead of
6231 if (is_valid) { 6236 // returning the second pair of read format/type, the preferred pair
6232 is_valid = pname == GL_IMPLEMENTATION_COLOR_READ_FORMAT ? 6237 // is returned. So this semantic is different from GL ES.
6233 validators_->read_pixel_format.IsValid(*params) :
6234 validators_->read_pixel_type.IsValid(*params);
6235 }
6236 if (!is_valid) {
6237 if (pname == GL_IMPLEMENTATION_COLOR_READ_FORMAT) { 6238 if (pname == GL_IMPLEMENTATION_COLOR_READ_FORMAT) {
6238 *params = GLES2Util::GetGLReadPixelsImplementationFormat( 6239 *params = GLES2Util::GetGLReadPixelsImplementationFormat(
6239 GetBoundReadFramebufferInternalFormat(), 6240 GetBoundReadFramebufferInternalFormat(),
6240 GetBoundReadFramebufferTextureType(), 6241 GetBoundReadFramebufferTextureType(),
6241 feature_info_->feature_flags().ext_read_format_bgra); 6242 feature_info_->feature_flags().ext_read_format_bgra);
6242 } else { 6243 } else {
6243 *params = GLES2Util::GetGLReadPixelsImplementationType( 6244 *params = GLES2Util::GetGLReadPixelsImplementationType(
6244 GetBoundReadFramebufferInternalFormat(), 6245 GetBoundReadFramebufferInternalFormat(),
6245 GetBoundReadFramebufferTextureType()); 6246 GetBoundReadFramebufferTextureType());
6246 } 6247 }
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
6299 glGetIntegerv(GL_MAX_VARYING_VECTORS, &max_varying_vectors); 6300 glGetIntegerv(GL_MAX_VARYING_VECTORS, &max_varying_vectors);
6300 *num_written = 1; 6301 *num_written = 1;
6301 if (params) { 6302 if (params) {
6302 *params = max_varying_vectors * 4; 6303 *params = max_varying_vectors * 4;
6303 } 6304 }
6304 return true; 6305 return true;
6305 } 6306 }
6306 case GL_READ_BUFFER: 6307 case GL_READ_BUFFER:
6307 *num_written = 1; 6308 *num_written = 1;
6308 if (params) { 6309 if (params) {
6309 Framebuffer* framebuffer = 6310 Framebuffer* framebuffer = GetBoundReadFramebuffer();
6310 GetFramebufferInfoForTarget(GL_READ_FRAMEBUFFER);
6311 GLenum read_buffer; 6311 GLenum read_buffer;
6312 if (framebuffer) { 6312 if (framebuffer) {
6313 read_buffer = framebuffer->read_buffer(); 6313 read_buffer = framebuffer->read_buffer();
6314 } else { 6314 } else {
6315 read_buffer = back_buffer_read_buffer_; 6315 read_buffer = back_buffer_read_buffer_;
6316 } 6316 }
6317 *params = static_cast<GLint>(read_buffer); 6317 *params = static_cast<GLint>(read_buffer);
6318 } 6318 }
6319 return true; 6319 return true;
6320 case GL_TRANSFORM_FEEDBACK_ACTIVE: 6320 case GL_TRANSFORM_FEEDBACK_ACTIVE:
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
6377 case GL_MAX_DRAW_BUFFERS_ARB: 6377 case GL_MAX_DRAW_BUFFERS_ARB:
6378 *num_written = 1; 6378 *num_written = 1;
6379 if (params) { 6379 if (params) {
6380 params[0] = group_->max_draw_buffers(); 6380 params[0] = group_->max_draw_buffers();
6381 } 6381 }
6382 return true; 6382 return true;
6383 case GL_ALPHA_BITS: 6383 case GL_ALPHA_BITS:
6384 *num_written = 1; 6384 *num_written = 1;
6385 if (params) { 6385 if (params) {
6386 GLint v = 0; 6386 GLint v = 0;
6387 Framebuffer* framebuffer = 6387 Framebuffer* framebuffer = GetBoundDrawFramebuffer();
6388 GetFramebufferInfoForTarget(GL_DRAW_FRAMEBUFFER_EXT);
6389 if (framebuffer) { 6388 if (framebuffer) {
6390 if (framebuffer->HasAlphaMRT() && 6389 if (framebuffer->HasAlphaMRT() &&
6391 framebuffer->HasSameInternalFormatsMRT()) { 6390 framebuffer->HasSameInternalFormatsMRT()) {
6392 if (gl_version_info().is_desktop_core_profile) { 6391 if (gl_version_info().is_desktop_core_profile) {
6393 for (uint32_t i = 0; i < group_->max_draw_buffers(); i++) { 6392 for (uint32_t i = 0; i < group_->max_draw_buffers(); i++) {
6394 if (framebuffer->HasColorAttachment(i)) { 6393 if (framebuffer->HasColorAttachment(i)) {
6395 glGetFramebufferAttachmentParameterivEXT( 6394 glGetFramebufferAttachmentParameterivEXT(
6396 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i, 6395 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i,
6397 GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE, &v); 6396 GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE, &v);
6398 break; 6397 break;
6399 } 6398 }
6400 } 6399 }
6401 } else { 6400 } else {
6402 glGetIntegerv(GL_ALPHA_BITS, &v); 6401 glGetIntegerv(GL_ALPHA_BITS, &v);
6403 } 6402 }
6404 } 6403 }
6405 } else { 6404 } else {
6406 v = (ClientExposedBackBufferHasAlpha() ? 8 : 0); 6405 v = (ClientExposedBackBufferHasAlpha() ? 8 : 0);
6407 } 6406 }
6408 params[0] = v; 6407 params[0] = v;
6409 } 6408 }
6410 return true; 6409 return true;
6411 case GL_DEPTH_BITS: 6410 case GL_DEPTH_BITS:
6412 *num_written = 1; 6411 *num_written = 1;
6413 if (params) { 6412 if (params) {
6414 GLint v = 0; 6413 GLint v = 0;
6415 if (gl_version_info().is_desktop_core_profile) { 6414 if (gl_version_info().is_desktop_core_profile) {
6416 Framebuffer* framebuffer = 6415 Framebuffer* framebuffer = GetBoundDrawFramebuffer();
6417 GetFramebufferInfoForTarget(GL_DRAW_FRAMEBUFFER_EXT);
6418 if (framebuffer) { 6416 if (framebuffer) {
6419 if (framebuffer->HasDepthAttachment()) { 6417 if (framebuffer->HasDepthAttachment()) {
6420 glGetFramebufferAttachmentParameterivEXT( 6418 glGetFramebufferAttachmentParameterivEXT(
6421 GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, 6419 GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
6422 GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE, &v); 6420 GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE, &v);
6423 } 6421 }
6424 } else { 6422 } else {
6425 v = (back_buffer_has_depth_ ? 24 : 0); 6423 v = (back_buffer_has_depth_ ? 24 : 0);
6426 } 6424 }
6427 } else { 6425 } else {
6428 glGetIntegerv(GL_DEPTH_BITS, &v); 6426 glGetIntegerv(GL_DEPTH_BITS, &v);
6429 } 6427 }
6430 params[0] = BoundFramebufferHasDepthAttachment() ? v : 0; 6428 params[0] = BoundFramebufferHasDepthAttachment() ? v : 0;
6431 } 6429 }
6432 return true; 6430 return true;
6433 case GL_RED_BITS: 6431 case GL_RED_BITS:
6434 case GL_GREEN_BITS: 6432 case GL_GREEN_BITS:
6435 case GL_BLUE_BITS: 6433 case GL_BLUE_BITS:
6436 *num_written = 1; 6434 *num_written = 1;
6437 if (params) { 6435 if (params) {
6438 GLint v = 0; 6436 GLint v = 0;
6439 if (gl_version_info().is_desktop_core_profile) { 6437 if (gl_version_info().is_desktop_core_profile) {
6440 Framebuffer* framebuffer = 6438 Framebuffer* framebuffer = GetBoundDrawFramebuffer();
6441 GetFramebufferInfoForTarget(GL_DRAW_FRAMEBUFFER_EXT);
6442 if (framebuffer) { 6439 if (framebuffer) {
6443 if (framebuffer->HasSameInternalFormatsMRT()) { 6440 if (framebuffer->HasSameInternalFormatsMRT()) {
6444 GLenum framebuffer_enum = 0; 6441 GLenum framebuffer_enum = 0;
6445 switch (pname) { 6442 switch (pname) {
6446 case GL_RED_BITS: 6443 case GL_RED_BITS:
6447 framebuffer_enum = GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE; 6444 framebuffer_enum = GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE;
6448 break; 6445 break;
6449 case GL_GREEN_BITS: 6446 case GL_GREEN_BITS:
6450 framebuffer_enum = GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE; 6447 framebuffer_enum = GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE;
6451 break; 6448 break;
(...skipping 17 matching lines...) Expand all
6469 glGetIntegerv(pname, &v); 6466 glGetIntegerv(pname, &v);
6470 } 6467 }
6471 params[0] = v; 6468 params[0] = v;
6472 } 6469 }
6473 return true; 6470 return true;
6474 case GL_STENCIL_BITS: 6471 case GL_STENCIL_BITS:
6475 *num_written = 1; 6472 *num_written = 1;
6476 if (params) { 6473 if (params) {
6477 GLint v = 0; 6474 GLint v = 0;
6478 if (gl_version_info().is_desktop_core_profile) { 6475 if (gl_version_info().is_desktop_core_profile) {
6479 Framebuffer* framebuffer = 6476 Framebuffer* framebuffer = GetBoundDrawFramebuffer();
6480 GetFramebufferInfoForTarget(GL_DRAW_FRAMEBUFFER_EXT);
6481 if (framebuffer) { 6477 if (framebuffer) {
6482 if (framebuffer->HasStencilAttachment()) { 6478 if (framebuffer->HasStencilAttachment()) {
6483 glGetFramebufferAttachmentParameterivEXT( 6479 glGetFramebufferAttachmentParameterivEXT(
6484 GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, 6480 GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT,
6485 GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE, &v); 6481 GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE, &v);
6486 } 6482 }
6487 } else { 6483 } else {
6488 v = (back_buffer_has_stencil_ ? 8 : 0); 6484 v = (back_buffer_has_stencil_ ? 8 : 0);
6489 } 6485 }
6490 } else { 6486 } else {
(...skipping 1006 matching lines...) Expand 10 before | Expand all | Expand 10 after
7497 // Assumes framebuffer is complete. 7493 // Assumes framebuffer is complete.
7498 void GLES2DecoderImpl::ClearUnclearedAttachments( 7494 void GLES2DecoderImpl::ClearUnclearedAttachments(
7499 GLenum target, Framebuffer* framebuffer) { 7495 GLenum target, Framebuffer* framebuffer) {
7500 // Clear textures that we can't use glClear first. These textures will be 7496 // Clear textures that we can't use glClear first. These textures will be
7501 // marked as cleared after the call and no longer be part of the following 7497 // marked as cleared after the call and no longer be part of the following
7502 // code. 7498 // code.
7503 framebuffer->ClearUnclearedIntOr3DTexturesOrPartiallyClearedTextures( 7499 framebuffer->ClearUnclearedIntOr3DTexturesOrPartiallyClearedTextures(
7504 this, texture_manager()); 7500 this, texture_manager());
7505 7501
7506 bool cleared_int_renderbuffers = false; 7502 bool cleared_int_renderbuffers = false;
7507 Framebuffer* draw_framebuffer = 7503 Framebuffer* draw_framebuffer = GetBoundDrawFramebuffer();
7508 GetFramebufferInfoForTarget(GL_DRAW_FRAMEBUFFER);
7509 if (framebuffer->HasUnclearedIntRenderbufferAttachments()) { 7504 if (framebuffer->HasUnclearedIntRenderbufferAttachments()) {
7510 if (target == GL_READ_FRAMEBUFFER && draw_framebuffer != framebuffer) { 7505 if (target == GL_READ_FRAMEBUFFER && draw_framebuffer != framebuffer) {
7511 // TODO(zmo): There is no guarantee that an FBO that is complete on the 7506 // TODO(zmo): There is no guarantee that an FBO that is complete on the
7512 // READ attachment will be complete as a DRAW attachment. 7507 // READ attachment will be complete as a DRAW attachment.
7513 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER, framebuffer->service_id()); 7508 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER, framebuffer->service_id());
7514 } 7509 }
7515 state_.SetDeviceColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 7510 state_.SetDeviceColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
7516 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false); 7511 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false);
7517 7512
7518 // TODO(zmo): Assume DrawBuffers() does not affect ClearBuffer(). 7513 // TODO(zmo): Assume DrawBuffers() does not affect ClearBuffer().
(...skipping 6568 matching lines...) Expand 10 before | Expand all | Expand 10 after
14087 final_internal_format, channels_exist, &source_texture_service_id, 14082 final_internal_format, channels_exist, &source_texture_service_id,
14088 &source_texture_target); 14083 &source_texture_target);
14089 if (requires_luma_blit) { 14084 if (requires_luma_blit) {
14090 copy_tex_image_blit_->DoCopyTexImage2DToLUMACompatibilityTexture( 14085 copy_tex_image_blit_->DoCopyTexImage2DToLUMACompatibilityTexture(
14091 this, texture->service_id(), texture->target(), target, format, 14086 this, texture->service_id(), texture->target(), target, format,
14092 type, level, internal_format, x, y, width, height, 14087 type, level, internal_format, x, y, width, height,
14093 GetBoundReadFramebufferServiceId(), 14088 GetBoundReadFramebufferServiceId(),
14094 GetBoundReadFramebufferInternalFormat()); 14089 GetBoundReadFramebufferInternalFormat());
14095 } else if (use_workaround) { 14090 } else if (use_workaround) {
14096 GLenum dest_texture_target = target; 14091 GLenum dest_texture_target = target;
14097 GLenum framebuffer_target = features().chromium_framebuffer_multisample 14092 GLenum framebuffer_target = GetReadFramebufferTarget();
14098 ? GL_READ_FRAMEBUFFER_EXT
14099 : GL_FRAMEBUFFER;
14100 14093
14101 GLenum temp_internal_format = 0; 14094 GLenum temp_internal_format = 0;
14102 if (channels_exist == GLES2Util::kRGBA) { 14095 if (channels_exist == GLES2Util::kRGBA) {
14103 temp_internal_format = GL_RGBA; 14096 temp_internal_format = GL_RGBA;
14104 } else if (channels_exist == GLES2Util::kRGB) { 14097 } else if (channels_exist == GLES2Util::kRGB) {
14105 temp_internal_format = GL_RGB; 14098 temp_internal_format = GL_RGB;
14106 } else { 14099 } else {
14107 NOTREACHED(); 14100 NOTREACHED();
14108 } 14101 }
14109 14102
(...skipping 4649 matching lines...) Expand 10 before | Expand all | Expand 10 after
18759 // are met: 18752 // are met:
18760 // 1. The internal format of the new texture is not GL_RGB or GL_RGBA. 18753 // 1. The internal format of the new texture is not GL_RGB or GL_RGBA.
18761 // 2. The image of the read FBO is backed by an IOSurface. 18754 // 2. The image of the read FBO is backed by an IOSurface.
18762 // See https://crbug.com/581777#c4 for more details. 18755 // See https://crbug.com/581777#c4 for more details.
18763 if (!workarounds().use_intermediary_for_copy_texture_image) 18756 if (!workarounds().use_intermediary_for_copy_texture_image)
18764 return false; 18757 return false;
18765 18758
18766 if (internal_format == GL_RGB || internal_format == GL_RGBA) 18759 if (internal_format == GL_RGB || internal_format == GL_RGBA)
18767 return false; 18760 return false;
18768 18761
18769 GLenum framebuffer_target = features().chromium_framebuffer_multisample 18762 Framebuffer* framebuffer = GetBoundReadFramebuffer();
18770 ? GL_READ_FRAMEBUFFER_EXT
18771 : GL_FRAMEBUFFER;
18772 Framebuffer* framebuffer =
18773 GetFramebufferInfoForTarget(framebuffer_target);
18774 if (!framebuffer) 18763 if (!framebuffer)
18775 return false; 18764 return false;
18776 18765
18777 const Framebuffer::Attachment* attachment = 18766 const Framebuffer::Attachment* attachment =
18778 framebuffer->GetReadBufferAttachment(); 18767 framebuffer->GetReadBufferAttachment();
18779 if (!attachment) 18768 if (!attachment)
18780 return false; 18769 return false;
18781 18770
18782 if (!attachment->IsTextureAttachment()) 18771 if (!attachment->IsTextureAttachment())
18783 return false; 18772 return false;
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
18973 } 18962 }
18974 18963
18975 // Include the auto-generated part of this file. We split this because it means 18964 // Include the auto-generated part of this file. We split this because it means
18976 // we can easily edit the non-auto generated parts right here in this file 18965 // we can easily edit the non-auto generated parts right here in this file
18977 // instead of having to edit some template or the code generator. 18966 // instead of having to edit some template or the code generator.
18978 #include "base/macros.h" 18967 #include "base/macros.h"
18979 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 18968 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
18980 18969
18981 } // namespace gles2 18970 } // namespace gles2
18982 } // namespace gpu 18971 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698