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

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

Issue 2594233002: Change GetIntegerv(IMPLEMENTATION_COLOR_READ_FORMAT/TYPE) behavior. (Closed)
Patch Set: 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 1911 matching lines...) Expand 10 before | Expand all | Expand 10 after
1922 case GL_INT_SAMPLER_2D_ARRAY: 1922 case GL_INT_SAMPLER_2D_ARRAY:
1923 case GL_UNSIGNED_INT_SAMPLER_2D_ARRAY: 1923 case GL_UNSIGNED_INT_SAMPLER_2D_ARRAY:
1924 return GL_TEXTURE_2D_ARRAY; 1924 return GL_TEXTURE_2D_ARRAY;
1925 default: 1925 default:
1926 NOTREACHED(); 1926 NOTREACHED();
1927 return 0; 1927 return 0;
1928 } 1928 }
1929 } 1929 }
1930 1930
1931 // Gets the framebuffer info for a particular target. 1931 // Gets the framebuffer info for a particular target.
1932 Framebuffer* GetFramebufferInfoForTarget(GLenum target) { 1932 Framebuffer* GetFramebufferInfoForTarget(GLenum target) const {
1933 Framebuffer* framebuffer = NULL; 1933 Framebuffer* framebuffer = nullptr;
1934 switch (target) { 1934 switch (target) {
1935 case GL_FRAMEBUFFER: 1935 case GL_FRAMEBUFFER:
1936 case GL_DRAW_FRAMEBUFFER_EXT: 1936 case GL_DRAW_FRAMEBUFFER_EXT:
1937 framebuffer = framebuffer_state_.bound_draw_framebuffer.get(); 1937 framebuffer = framebuffer_state_.bound_draw_framebuffer.get();
1938 break; 1938 break;
1939 case GL_READ_FRAMEBUFFER_EXT: 1939 case GL_READ_FRAMEBUFFER_EXT:
1940 framebuffer = framebuffer_state_.bound_read_framebuffer.get(); 1940 framebuffer = framebuffer_state_.bound_read_framebuffer.get();
1941 break; 1941 break;
1942 default: 1942 default:
1943 NOTREACHED(); 1943 NOTREACHED();
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
2121 // using GL_RGBA and glColorMask. 2121 // using GL_RGBA and glColorMask.
2122 bool ChromiumImageNeedsRGBEmulation(); 2122 bool ChromiumImageNeedsRGBEmulation();
2123 2123
2124 // The GL_CHROMIUM_schedule_ca_layer extension requires that SwapBuffers and 2124 // The GL_CHROMIUM_schedule_ca_layer extension requires that SwapBuffers and
2125 // equivalent functions reset shared state. 2125 // equivalent functions reset shared state.
2126 void ClearScheduleCALayerState(); 2126 void ClearScheduleCALayerState();
2127 2127
2128 // Helper method to call glClear workaround. 2128 // Helper method to call glClear workaround.
2129 void ClearFramebufferForWorkaround(GLbitfield mask); 2129 void ClearFramebufferForWorkaround(GLbitfield mask);
2130 2130
2131 bool SupportsSeparateFramebufferBinds() const {
2132 return (feature_info_->feature_flags().chromium_framebuffer_multisample ||
2133 feature_info_->IsWebGL2OrES3Context());
2134 }
2135
2136 GLenum GetDrawFramebufferTarget() const {
2137 return SupportsSeparateFramebufferBinds() ?
2138 GL_DRAW_FRAMEBUFFER : GL_FRAMEBUFFER;
2139 }
2140
2141 GLenum GetReadFramebufferTarget() const {
2142 return SupportsSeparateFramebufferBinds() ?
2143 GL_READ_FRAMEBUFFER : GL_FRAMEBUFFER;
2144 }
2145
2146 Framebuffer* GetBoundDrawFramebuffer() const {
2147 return framebuffer_state_.bound_draw_framebuffer.get();
2148 }
2149
2150 Framebuffer* GetBoundReadFramebuffer() const {
2151 GLenum target = GetReadFramebufferTarget();
2152 return GetFramebufferInfoForTarget(target);
2153 }
2154
2131 bool InitializeCopyTexImageBlitter(const char* function_name); 2155 bool InitializeCopyTexImageBlitter(const char* function_name);
2132 bool InitializeCopyTextureCHROMIUM(const char* function_name); 2156 bool InitializeCopyTextureCHROMIUM(const char* function_name);
2133 bool InitializeSRGBConverter(const char* function_name); 2157 bool InitializeSRGBConverter(const char* function_name);
2134 // Generate a member function prototype for each command in an automated and 2158 // Generate a member function prototype for each command in an automated and
2135 // typesafe way. 2159 // typesafe way.
2136 #define GLES2_CMD_OP(name) \ 2160 #define GLES2_CMD_OP(name) \
2137 Error Handle##name(uint32_t immediate_data_size, const volatile void* data); 2161 Error Handle##name(uint32_t immediate_data_size, const volatile void* data);
2138 2162
2139 GLES2_COMMAND_LIST(GLES2_CMD_OP) 2163 GLES2_COMMAND_LIST(GLES2_CMD_OP)
2140 2164
(...skipping 1844 matching lines...) Expand 10 before | Expand all | Expand 10 after
3985 buffer->RemoveMappedRange(); 4009 buffer->RemoveMappedRange();
3986 state_.RemoveBoundBuffer(buffer); 4010 state_.RemoveBoundBuffer(buffer);
3987 RemoveBuffer(client_id); 4011 RemoveBuffer(client_id);
3988 } 4012 }
3989 } 4013 }
3990 } 4014 }
3991 4015
3992 void GLES2DecoderImpl::DeleteFramebuffersHelper( 4016 void GLES2DecoderImpl::DeleteFramebuffersHelper(
3993 GLsizei n, 4017 GLsizei n,
3994 const volatile GLuint* client_ids) { 4018 const volatile GLuint* client_ids) {
3995 bool supports_separate_framebuffer_binds =
3996 features().chromium_framebuffer_multisample;
3997
3998 for (GLsizei ii = 0; ii < n; ++ii) { 4019 for (GLsizei ii = 0; ii < n; ++ii) {
3999 GLuint client_id = client_ids[ii]; 4020 GLuint client_id = client_ids[ii];
4000 Framebuffer* framebuffer = GetFramebuffer(client_id); 4021 Framebuffer* framebuffer = GetFramebuffer(client_id);
4001 if (framebuffer && !framebuffer->IsDeleted()) { 4022 if (framebuffer && !framebuffer->IsDeleted()) {
4002 if (framebuffer == framebuffer_state_.bound_draw_framebuffer.get()) { 4023 if (framebuffer == framebuffer_state_.bound_draw_framebuffer.get()) {
4003 GLenum target = supports_separate_framebuffer_binds ? 4024 GLenum target = GetDrawFramebufferTarget();
4004 GL_DRAW_FRAMEBUFFER_EXT : GL_FRAMEBUFFER;
4005 4025
4006 // Unbind attachments on FBO before deletion. 4026 // Unbind attachments on FBO before deletion.
4007 if (workarounds().unbind_attachments_on_bound_render_fbo_delete) 4027 if (workarounds().unbind_attachments_on_bound_render_fbo_delete)
4008 framebuffer->DoUnbindGLAttachmentsForWorkaround(target); 4028 framebuffer->DoUnbindGLAttachmentsForWorkaround(target);
4009 4029
4010 glBindFramebufferEXT(target, GetBackbufferServiceId()); 4030 glBindFramebufferEXT(target, GetBackbufferServiceId());
4011 framebuffer_state_.bound_draw_framebuffer = NULL; 4031 framebuffer_state_.bound_draw_framebuffer = NULL;
4012 framebuffer_state_.clear_state_dirty = true; 4032 framebuffer_state_.clear_state_dirty = true;
4013 } 4033 }
4014 if (framebuffer == framebuffer_state_.bound_read_framebuffer.get()) { 4034 if (framebuffer == framebuffer_state_.bound_read_framebuffer.get()) {
4015 framebuffer_state_.bound_read_framebuffer = NULL; 4035 framebuffer_state_.bound_read_framebuffer = NULL;
4016 GLenum target = supports_separate_framebuffer_binds ? 4036 GLenum target = GetReadFramebufferTarget();
4017 GL_READ_FRAMEBUFFER_EXT : GL_FRAMEBUFFER;
4018 glBindFramebufferEXT(target, GetBackbufferServiceId()); 4037 glBindFramebufferEXT(target, GetBackbufferServiceId());
4019 } 4038 }
4020 OnFboChanged(); 4039 OnFboChanged();
4021 RemoveFramebuffer(client_id); 4040 RemoveFramebuffer(client_id);
4022 } 4041 }
4023 } 4042 }
4024 } 4043 }
4025 4044
4026 void GLES2DecoderImpl::DeleteRenderbuffersHelper( 4045 void GLES2DecoderImpl::DeleteRenderbuffersHelper(
4027 GLsizei n, 4046 GLsizei n,
(...skipping 24 matching lines...) Expand all
4052 } 4071 }
4053 } 4072 }
4054 framebuffer_state_.clear_state_dirty = true; 4073 framebuffer_state_.clear_state_dirty = true;
4055 RemoveRenderbuffer(client_id); 4074 RemoveRenderbuffer(client_id);
4056 } 4075 }
4057 } 4076 }
4058 } 4077 }
4059 4078
4060 void GLES2DecoderImpl::DeleteTexturesHelper(GLsizei n, 4079 void GLES2DecoderImpl::DeleteTexturesHelper(GLsizei n,
4061 const volatile GLuint* client_ids) { 4080 const volatile GLuint* client_ids) {
4062 bool supports_separate_framebuffer_binds = 4081 bool supports_separate_framebuffer_binds = SupportsSeparateFramebufferBinds();
4063 features().chromium_framebuffer_multisample;
4064 for (GLsizei ii = 0; ii < n; ++ii) { 4082 for (GLsizei ii = 0; ii < n; ++ii) {
4065 GLuint client_id = client_ids[ii]; 4083 GLuint client_id = client_ids[ii];
4066 TextureRef* texture_ref = GetTexture(client_id); 4084 TextureRef* texture_ref = GetTexture(client_id);
4067 if (texture_ref) { 4085 if (texture_ref) {
4068 Texture* texture = texture_ref->texture(); 4086 Texture* texture = texture_ref->texture();
4069 if (texture->IsAttachedToFramebuffer()) { 4087 if (texture->IsAttachedToFramebuffer()) {
4070 framebuffer_state_.clear_state_dirty = true; 4088 framebuffer_state_.clear_state_dirty = true;
4071 } 4089 }
4072 // Unbind texture_ref from texture_ref units. 4090 // Unbind texture_ref from texture_ref units.
4073 state_.UnbindTexture(texture_ref); 4091 state_.UnbindTexture(texture_ref);
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
4195 if (framebuffer_id == 0) { 4213 if (framebuffer_id == 0) {
4196 framebuffer_id = back_buffer_service_id; 4214 framebuffer_id = back_buffer_service_id;
4197 } 4215 }
4198 4216
4199 glBindFramebufferEXT(target, framebuffer_id); 4217 glBindFramebufferEXT(target, framebuffer_id);
4200 } 4218 }
4201 4219
4202 void GLES2DecoderImpl::RestoreCurrentFramebufferBindings() { 4220 void GLES2DecoderImpl::RestoreCurrentFramebufferBindings() {
4203 framebuffer_state_.clear_state_dirty = true; 4221 framebuffer_state_.clear_state_dirty = true;
4204 4222
4205 if (!features().chromium_framebuffer_multisample) { 4223 if (!SupportsSeparateFramebufferBinds()) {
4206 RebindCurrentFramebuffer( 4224 RebindCurrentFramebuffer(
4207 GL_FRAMEBUFFER, 4225 GL_FRAMEBUFFER,
4208 framebuffer_state_.bound_draw_framebuffer.get(), 4226 framebuffer_state_.bound_draw_framebuffer.get(),
4209 GetBackbufferServiceId()); 4227 GetBackbufferServiceId());
4210 } else { 4228 } else {
4211 RebindCurrentFramebuffer( 4229 RebindCurrentFramebuffer(
4212 GL_READ_FRAMEBUFFER_EXT, 4230 GL_READ_FRAMEBUFFER_EXT,
4213 framebuffer_state_.bound_read_framebuffer.get(), 4231 framebuffer_state_.bound_read_framebuffer.get(),
4214 GetBackbufferServiceId()); 4232 GetBackbufferServiceId());
4215 RebindCurrentFramebuffer( 4233 RebindCurrentFramebuffer(
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
4281 if (renderbuffer_manager()->HaveUnclearedRenderbuffers() || 4299 if (renderbuffer_manager()->HaveUnclearedRenderbuffers() ||
4282 texture_manager()->HaveUnclearedMips()) { 4300 texture_manager()->HaveUnclearedMips()) {
4283 if (!framebuffer->IsCleared()) { 4301 if (!framebuffer->IsCleared()) {
4284 ClearUnclearedAttachments(target, framebuffer); 4302 ClearUnclearedAttachments(target, framebuffer);
4285 } 4303 }
4286 } 4304 }
4287 return true; 4305 return true;
4288 } 4306 }
4289 4307
4290 bool GLES2DecoderImpl::CheckBoundDrawFramebufferValid(const char* func_name) { 4308 bool GLES2DecoderImpl::CheckBoundDrawFramebufferValid(const char* func_name) {
4291 GLenum target = features().chromium_framebuffer_multisample ? 4309 Framebuffer* framebuffer = GetBoundDrawFramebuffer();
4292 GL_DRAW_FRAMEBUFFER : GL_FRAMEBUFFER;
4293 Framebuffer* framebuffer = GetFramebufferInfoForTarget(target);
4294 bool valid = CheckFramebufferValid( 4310 bool valid = CheckFramebufferValid(
4295 framebuffer, target, GL_INVALID_FRAMEBUFFER_OPERATION, func_name); 4311 framebuffer, GetDrawFramebufferTarget(),
4296 if (valid && !features().chromium_framebuffer_multisample) 4312 GL_INVALID_FRAMEBUFFER_OPERATION, func_name);
4313 if (!valid)
4314 return false;
4315
4316 if (!SupportsSeparateFramebufferBinds())
4297 OnUseFramebuffer(); 4317 OnUseFramebuffer();
4298 if (valid && feature_info_->feature_flags().desktop_srgb_support) { 4318 if (valid && feature_info_->feature_flags().desktop_srgb_support) {
4299 // If framebuffer contains sRGB images, then enable FRAMEBUFFER_SRGB. 4319 // If framebuffer contains sRGB images, then enable FRAMEBUFFER_SRGB.
4300 // Otherwise, disable FRAMEBUFFER_SRGB. Assume default fbo does not have 4320 // Otherwise, disable FRAMEBUFFER_SRGB. Assume default fbo does not have
4301 // sRGB image. 4321 // sRGB image.
4302 // In theory, we can just leave FRAMEBUFFER_SRGB on. However, many drivers 4322 // In theory, we can just leave FRAMEBUFFER_SRGB on. However, many drivers
4303 // behave incorrectly when all images are linear encoding, they still apply 4323 // behave incorrectly when all images are linear encoding, they still apply
4304 // the sRGB conversion, but when at least one image is sRGB, then they 4324 // the sRGB conversion, but when at least one image is sRGB, then they
4305 // behave correctly. 4325 // behave correctly.
4306 bool enable_framebuffer_srgb = 4326 bool enable_framebuffer_srgb =
4307 framebuffer && framebuffer->HasSRGBAttachments(); 4327 framebuffer && framebuffer->HasSRGBAttachments();
4308 state_.EnableDisableFramebufferSRGB(enable_framebuffer_srgb); 4328 state_.EnableDisableFramebufferSRGB(enable_framebuffer_srgb);
4309 } 4329 }
4310 return valid; 4330 return valid;
4311 } 4331 }
4312 4332
4313 bool GLES2DecoderImpl::CheckBoundReadFramebufferValid( 4333 bool GLES2DecoderImpl::CheckBoundReadFramebufferValid(
4314 const char* func_name, GLenum gl_error) { 4334 const char* func_name, GLenum gl_error) {
4315 GLenum target = features().chromium_framebuffer_multisample ? 4335 Framebuffer* framebuffer = GetBoundReadFramebuffer();
4316 GL_READ_FRAMEBUFFER : GL_FRAMEBUFFER;
4317 Framebuffer* framebuffer = GetFramebufferInfoForTarget(target);
4318 bool valid = CheckFramebufferValid( 4336 bool valid = CheckFramebufferValid(
4319 framebuffer, target, gl_error, func_name); 4337 framebuffer, GetReadFramebufferTarget(), gl_error, func_name);
4320 return valid; 4338 return valid;
4321 } 4339 }
4322 4340
4323 bool GLES2DecoderImpl::CheckBoundFramebufferValid(const char* func_name) { 4341 bool GLES2DecoderImpl::CheckBoundFramebufferValid(const char* func_name) {
4324 GLenum target = features().chromium_framebuffer_multisample ? 4342 GLenum gl_error = GL_INVALID_FRAMEBUFFER_OPERATION;
4325 GL_DRAW_FRAMEBUFFER : GL_FRAMEBUFFER; 4343 Framebuffer* draw_framebuffer = GetBoundDrawFramebuffer();
4326 Framebuffer* draw_framebuffer = GetFramebufferInfoForTarget(target);
4327 bool valid = CheckFramebufferValid( 4344 bool valid = CheckFramebufferValid(
4328 draw_framebuffer, target, GL_INVALID_FRAMEBUFFER_OPERATION, func_name); 4345 draw_framebuffer, GetDrawFramebufferTarget(), gl_error, func_name);
4329 4346
4330 target = features().chromium_framebuffer_multisample ? 4347 Framebuffer* read_framebuffer = GetBoundReadFramebuffer();
4331 GL_READ_FRAMEBUFFER : GL_FRAMEBUFFER;
4332 Framebuffer* read_framebuffer = GetFramebufferInfoForTarget(target);
4333 valid = valid && CheckFramebufferValid( 4348 valid = valid && CheckFramebufferValid(
4334 read_framebuffer, target, GL_INVALID_FRAMEBUFFER_OPERATION, func_name); 4349 read_framebuffer, GetReadFramebufferTarget(), gl_error, func_name);
4335 return valid; 4350 return valid;
4336 } 4351 }
4337 4352
4338 GLint GLES2DecoderImpl::GetColorEncodingFromInternalFormat( 4353 GLint GLES2DecoderImpl::GetColorEncodingFromInternalFormat(
4339 GLenum internalformat) { 4354 GLenum internalformat) {
4340 switch (internalformat) { 4355 switch (internalformat) {
4341 case GL_SRGB_EXT: 4356 case GL_SRGB_EXT:
4342 case GL_SRGB_ALPHA_EXT: 4357 case GL_SRGB_ALPHA_EXT:
4343 case GL_SRGB8: 4358 case GL_SRGB8:
4344 case GL_SRGB8_ALPHA8: 4359 case GL_SRGB8_ALPHA8:
4345 return GL_SRGB; 4360 return GL_SRGB;
4346 default: 4361 default:
4347 return GL_LINEAR; 4362 return GL_LINEAR;
4348 } 4363 }
4349 } 4364 }
4350 4365
4351 bool GLES2DecoderImpl::FormsTextureCopyingFeedbackLoop( 4366 bool GLES2DecoderImpl::FormsTextureCopyingFeedbackLoop(
4352 TextureRef* texture, GLint level, GLint layer) { 4367 TextureRef* texture, GLint level, GLint layer) {
4353 Framebuffer* framebuffer = features().chromium_framebuffer_multisample ? 4368 Framebuffer* framebuffer = GetBoundReadFramebuffer();
4354 framebuffer_state_.bound_read_framebuffer.get() :
4355 framebuffer_state_.bound_draw_framebuffer.get();
4356 if (!framebuffer) 4369 if (!framebuffer)
4357 return false; 4370 return false;
4358 const Framebuffer::Attachment* attachment = 4371 const Framebuffer::Attachment* attachment =
4359 framebuffer->GetReadBufferAttachment(); 4372 framebuffer->GetReadBufferAttachment();
4360 if (!attachment) 4373 if (!attachment)
4361 return false; 4374 return false;
4362 return attachment->FormsFeedbackLoop(texture, level, layer); 4375 return attachment->FormsFeedbackLoop(texture, level, layer);
4363 } 4376 }
4364 4377
4365 gfx::Size GLES2DecoderImpl::GetBoundReadFramebufferSize() { 4378 gfx::Size GLES2DecoderImpl::GetBoundReadFramebufferSize() {
4366 Framebuffer* framebuffer = 4379 Framebuffer* framebuffer = GetBoundReadFramebuffer();
4367 GetFramebufferInfoForTarget(GL_READ_FRAMEBUFFER_EXT); 4380 if (framebuffer) {
4368 if (framebuffer != NULL) {
4369 const Framebuffer::Attachment* attachment = 4381 const Framebuffer::Attachment* attachment =
4370 framebuffer->GetReadBufferAttachment(); 4382 framebuffer->GetReadBufferAttachment();
4371 if (attachment) { 4383 if (attachment) {
4372 return gfx::Size(attachment->width(), attachment->height()); 4384 return gfx::Size(attachment->width(), attachment->height());
4373 } 4385 }
4374 return gfx::Size(0, 0); 4386 return gfx::Size(0, 0);
4375 } else if (offscreen_target_frame_buffer_.get()) { 4387 } else if (offscreen_target_frame_buffer_.get()) {
4376 return offscreen_size_; 4388 return offscreen_size_;
4377 } else { 4389 } else {
4378 return surface_->GetSize(); 4390 return surface_->GetSize();
4379 } 4391 }
4380 } 4392 }
4381 4393
4382 GLuint GLES2DecoderImpl::GetBoundReadFramebufferServiceId() { 4394 GLuint GLES2DecoderImpl::GetBoundReadFramebufferServiceId() {
4383 Framebuffer* framebuffer = 4395 Framebuffer* framebuffer = GetBoundReadFramebuffer();
4384 GetFramebufferInfoForTarget(GL_READ_FRAMEBUFFER_EXT);
4385 if (framebuffer) { 4396 if (framebuffer) {
4386 return framebuffer->service_id(); 4397 return framebuffer->service_id();
4387 } 4398 }
4388 if (offscreen_resolved_frame_buffer_.get()) { 4399 if (offscreen_resolved_frame_buffer_.get()) {
4389 return offscreen_resolved_frame_buffer_->id(); 4400 return offscreen_resolved_frame_buffer_->id();
4390 } 4401 }
4391 if (offscreen_target_frame_buffer_.get()) { 4402 if (offscreen_target_frame_buffer_.get()) {
4392 return offscreen_target_frame_buffer_->id(); 4403 return offscreen_target_frame_buffer_->id();
4393 } 4404 }
4394 if (surface_.get()) { 4405 if (surface_.get()) {
4395 return surface_->GetBackingFramebufferObject(); 4406 return surface_->GetBackingFramebufferObject();
4396 } 4407 }
4397 return 0; 4408 return 0;
4398 } 4409 }
4399 4410
4400 GLuint GLES2DecoderImpl::GetBoundDrawFramebufferServiceId() { 4411 GLuint GLES2DecoderImpl::GetBoundDrawFramebufferServiceId() {
4401 Framebuffer* framebuffer = 4412 Framebuffer* framebuffer = GetBoundDrawFramebuffer();
4402 GetFramebufferInfoForTarget(GL_DRAW_FRAMEBUFFER_EXT);
4403 if (framebuffer) { 4413 if (framebuffer) {
4404 return framebuffer->service_id(); 4414 return framebuffer->service_id();
4405 } 4415 }
4406 if (offscreen_target_frame_buffer_.get()) { 4416 if (offscreen_target_frame_buffer_.get()) {
4407 return offscreen_target_frame_buffer_->id(); 4417 return offscreen_target_frame_buffer_->id();
4408 } 4418 }
4409 if (surface_.get()) { 4419 if (surface_.get()) {
4410 return surface_->GetBackingFramebufferObject(); 4420 return surface_->GetBackingFramebufferObject();
4411 } 4421 }
4412 return 0; 4422 return 0;
4413 } 4423 }
4414 4424
4415 GLenum GLES2DecoderImpl::GetBoundReadFramebufferTextureType() { 4425 GLenum GLES2DecoderImpl::GetBoundReadFramebufferTextureType() {
4416 Framebuffer* framebuffer = 4426 Framebuffer* framebuffer = GetBoundReadFramebuffer();
4417 GetFramebufferInfoForTarget(GL_READ_FRAMEBUFFER_EXT);
4418 if (framebuffer) { 4427 if (framebuffer) {
4419 return framebuffer->GetReadBufferTextureType(); 4428 return framebuffer->GetReadBufferTextureType();
4420 } else { // Back buffer. 4429 } else { // Back buffer.
4421 if (back_buffer_read_buffer_ == GL_NONE) 4430 if (back_buffer_read_buffer_ == GL_NONE)
4422 return 0; 4431 return 0;
4423 return GL_UNSIGNED_BYTE; 4432 return GL_UNSIGNED_BYTE;
4424 } 4433 }
4425 } 4434 }
4426 4435
4427 GLenum GLES2DecoderImpl::GetBoundReadFramebufferInternalFormat() { 4436 GLenum GLES2DecoderImpl::GetBoundReadFramebufferInternalFormat() {
4428 Framebuffer* framebuffer = 4437 Framebuffer* framebuffer = GetBoundReadFramebuffer();
4429 GetFramebufferInfoForTarget(GL_READ_FRAMEBUFFER_EXT);
4430 if (framebuffer) { 4438 if (framebuffer) {
4431 return framebuffer->GetReadBufferInternalFormat(); 4439 return framebuffer->GetReadBufferInternalFormat();
4432 } else { // Back buffer. 4440 } else { // Back buffer.
4433 if (back_buffer_read_buffer_ == GL_NONE) 4441 if (back_buffer_read_buffer_ == GL_NONE)
4434 return 0; 4442 return 0;
4435 if (offscreen_target_frame_buffer_.get()) { 4443 if (offscreen_target_frame_buffer_.get()) {
4436 return offscreen_target_color_format_; 4444 return offscreen_target_color_format_;
4437 } 4445 }
4438 return back_buffer_color_format_; 4446 return back_buffer_color_format_;
4439 } 4447 }
4440 } 4448 }
4441 4449
4442 GLenum GLES2DecoderImpl::GetBoundColorDrawBufferType(GLint drawbuffer_i) { 4450 GLenum GLES2DecoderImpl::GetBoundColorDrawBufferType(GLint drawbuffer_i) {
4443 DCHECK(drawbuffer_i >= 0 && 4451 DCHECK(drawbuffer_i >= 0 &&
4444 drawbuffer_i < static_cast<GLint>(group_->max_draw_buffers())); 4452 drawbuffer_i < static_cast<GLint>(group_->max_draw_buffers()));
4445 Framebuffer* framebuffer = GetFramebufferInfoForTarget(GL_DRAW_FRAMEBUFFER); 4453 Framebuffer* framebuffer = GetBoundDrawFramebuffer();
4446 if (!framebuffer) { 4454 if (!framebuffer) {
4447 return 0; 4455 return 0;
4448 } 4456 }
4449 GLenum drawbuffer = static_cast<GLenum>(GL_DRAW_BUFFER0 + drawbuffer_i); 4457 GLenum drawbuffer = static_cast<GLenum>(GL_DRAW_BUFFER0 + drawbuffer_i);
4450 if (framebuffer->GetDrawBuffer(drawbuffer) == GL_NONE) { 4458 if (framebuffer->GetDrawBuffer(drawbuffer) == GL_NONE) {
4451 return 0; 4459 return 0;
4452 } 4460 }
4453 GLenum attachment = static_cast<GLenum>(GL_COLOR_ATTACHMENT0 + drawbuffer_i); 4461 GLenum attachment = static_cast<GLenum>(GL_COLOR_ATTACHMENT0 + drawbuffer_i);
4454 const Framebuffer::Attachment* buffer = 4462 const Framebuffer::Attachment* buffer =
4455 framebuffer->GetAttachment(attachment); 4463 framebuffer->GetAttachment(attachment);
4456 if (!buffer) { 4464 if (!buffer) {
4457 return 0; 4465 return 0;
4458 } 4466 }
4459 return buffer->texture_type(); 4467 return buffer->texture_type();
4460 } 4468 }
4461 4469
4462 GLenum GLES2DecoderImpl::GetBoundColorDrawBufferInternalFormat( 4470 GLenum GLES2DecoderImpl::GetBoundColorDrawBufferInternalFormat(
4463 GLint drawbuffer_i) { 4471 GLint drawbuffer_i) {
4464 DCHECK(drawbuffer_i >= 0 && 4472 DCHECK(drawbuffer_i >= 0 &&
4465 drawbuffer_i < static_cast<GLint>(group_->max_draw_buffers())); 4473 drawbuffer_i < static_cast<GLint>(group_->max_draw_buffers()));
4466 Framebuffer* framebuffer = GetFramebufferInfoForTarget(GL_DRAW_FRAMEBUFFER); 4474 Framebuffer* framebuffer = GetBoundDrawFramebuffer();
4467 if (!framebuffer) { 4475 if (!framebuffer) {
4468 return 0; 4476 return 0;
4469 } 4477 }
4470 GLenum drawbuffer = static_cast<GLenum>(GL_DRAW_BUFFER0 + drawbuffer_i); 4478 GLenum drawbuffer = static_cast<GLenum>(GL_DRAW_BUFFER0 + drawbuffer_i);
4471 if (framebuffer->GetDrawBuffer(drawbuffer) == GL_NONE) { 4479 if (framebuffer->GetDrawBuffer(drawbuffer) == GL_NONE) {
4472 return 0; 4480 return 0;
4473 } 4481 }
4474 GLenum attachment = static_cast<GLenum>(GL_COLOR_ATTACHMENT0 + drawbuffer_i); 4482 GLenum attachment = static_cast<GLenum>(GL_COLOR_ATTACHMENT0 + drawbuffer_i);
4475 const Framebuffer::Attachment* buffer = 4483 const Framebuffer::Attachment* buffer =
4476 framebuffer->GetAttachment(attachment); 4484 framebuffer->GetAttachment(attachment);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
4523 return offscreen_target_stencil_format_; 4531 return offscreen_target_stencil_format_;
4524 } 4532 }
4525 if (back_buffer_has_stencil_) 4533 if (back_buffer_has_stencil_)
4526 return GL_STENCIL; 4534 return GL_STENCIL;
4527 return 0; 4535 return 0;
4528 } 4536 }
4529 } 4537 }
4530 4538
4531 void GLES2DecoderImpl::MarkDrawBufferAsCleared( 4539 void GLES2DecoderImpl::MarkDrawBufferAsCleared(
4532 GLenum buffer, GLint drawbuffer_i) { 4540 GLenum buffer, GLint drawbuffer_i) {
4533 Framebuffer* framebuffer = GetFramebufferInfoForTarget(GL_DRAW_FRAMEBUFFER); 4541 Framebuffer* framebuffer = GetBoundDrawFramebuffer();
4534 if (!framebuffer) 4542 if (!framebuffer)
4535 return; 4543 return;
4536 GLenum attachment = 0; 4544 GLenum attachment = 0;
4537 switch (buffer) { 4545 switch (buffer) {
4538 case GL_COLOR: 4546 case GL_COLOR:
4539 DCHECK(drawbuffer_i >= 0 && 4547 DCHECK(drawbuffer_i >= 0 &&
4540 drawbuffer_i < static_cast<GLint>(group_->max_draw_buffers())); 4548 drawbuffer_i < static_cast<GLint>(group_->max_draw_buffers()));
4541 attachment = static_cast<GLenum>(GL_COLOR_ATTACHMENT0 + drawbuffer_i); 4549 attachment = static_cast<GLenum>(GL_COLOR_ATTACHMENT0 + drawbuffer_i);
4542 break; 4550 break;
4543 case GL_DEPTH: 4551 case GL_DEPTH:
(...skipping 853 matching lines...) Expand 10 before | Expand all | Expand 10 after
5397 5405
5398 void GLES2DecoderImpl::DoBindBufferRange(GLenum target, GLuint index, 5406 void GLES2DecoderImpl::DoBindBufferRange(GLenum target, GLuint index,
5399 GLuint client_id, 5407 GLuint client_id,
5400 GLintptr offset, 5408 GLintptr offset,
5401 GLsizeiptr size) { 5409 GLsizeiptr size) {
5402 BindIndexedBufferImpl(target, index, client_id, offset, size, 5410 BindIndexedBufferImpl(target, index, client_id, offset, size,
5403 kBindBufferRange, "glBindBufferRange"); 5411 kBindBufferRange, "glBindBufferRange");
5404 } 5412 }
5405 5413
5406 bool GLES2DecoderImpl::BoundFramebufferAllowsChangesToAlphaChannel() { 5414 bool GLES2DecoderImpl::BoundFramebufferAllowsChangesToAlphaChannel() {
5407 Framebuffer* framebuffer = 5415 Framebuffer* framebuffer = GetBoundDrawFramebuffer();
5408 GetFramebufferInfoForTarget(GL_DRAW_FRAMEBUFFER_EXT);
5409 if (framebuffer) 5416 if (framebuffer)
5410 return framebuffer->HasAlphaMRT(); 5417 return framebuffer->HasAlphaMRT();
5411 if (back_buffer_draw_buffer_ == GL_NONE) 5418 if (back_buffer_draw_buffer_ == GL_NONE)
5412 return false; 5419 return false;
5413 if (offscreen_target_frame_buffer_.get()) { 5420 if (offscreen_target_frame_buffer_.get()) {
5414 GLenum format = offscreen_target_color_format_; 5421 GLenum format = offscreen_target_color_format_;
5415 return (format == GL_RGBA || format == GL_RGBA8) && 5422 return (format == GL_RGBA || format == GL_RGBA8) &&
5416 offscreen_buffer_should_have_alpha_; 5423 offscreen_buffer_should_have_alpha_;
5417 } 5424 }
5418 return (back_buffer_color_format_ == GL_RGBA || 5425 return (back_buffer_color_format_ == GL_RGBA ||
5419 back_buffer_color_format_ == GL_RGBA8); 5426 back_buffer_color_format_ == GL_RGBA8);
5420 } 5427 }
5421 5428
5422 bool GLES2DecoderImpl::BoundFramebufferHasDepthAttachment() { 5429 bool GLES2DecoderImpl::BoundFramebufferHasDepthAttachment() {
5423 Framebuffer* framebuffer = 5430 Framebuffer* framebuffer = GetBoundDrawFramebuffer();
5424 GetFramebufferInfoForTarget(GL_DRAW_FRAMEBUFFER_EXT);
5425 if (framebuffer) { 5431 if (framebuffer) {
5426 return framebuffer->HasDepthAttachment(); 5432 return framebuffer->HasDepthAttachment();
5427 } 5433 }
5428 if (offscreen_target_frame_buffer_.get()) { 5434 if (offscreen_target_frame_buffer_.get()) {
5429 return offscreen_target_depth_format_ != 0; 5435 return offscreen_target_depth_format_ != 0;
5430 } 5436 }
5431 return back_buffer_has_depth_; 5437 return back_buffer_has_depth_;
5432 } 5438 }
5433 5439
5434 bool GLES2DecoderImpl::BoundFramebufferHasStencilAttachment() { 5440 bool GLES2DecoderImpl::BoundFramebufferHasStencilAttachment() {
5435 Framebuffer* framebuffer = 5441 Framebuffer* framebuffer = GetBoundDrawFramebuffer();
5436 GetFramebufferInfoForTarget(GL_DRAW_FRAMEBUFFER_EXT);
5437 if (framebuffer) { 5442 if (framebuffer) {
5438 return framebuffer->HasStencilAttachment(); 5443 return framebuffer->HasStencilAttachment();
5439 } 5444 }
5440 if (offscreen_target_frame_buffer_.get()) { 5445 if (offscreen_target_frame_buffer_.get()) {
5441 return offscreen_target_stencil_format_ != 0 || 5446 return offscreen_target_stencil_format_ != 0 ||
5442 offscreen_target_depth_format_ == GL_DEPTH24_STENCIL8; 5447 offscreen_target_depth_format_ == GL_DEPTH24_STENCIL8;
5443 } 5448 }
5444 return back_buffer_has_stencil_; 5449 return back_buffer_has_stencil_;
5445 } 5450 }
5446 5451
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
5482 // the size of the current framebuffer object. 5487 // the size of the current framebuffer object.
5483 RestoreFramebufferBindings(); 5488 RestoreFramebufferBindings();
5484 state_.RestoreState(prev_state); 5489 state_.RestoreState(prev_state);
5485 } 5490 }
5486 5491
5487 void GLES2DecoderImpl::RestoreFramebufferBindings() const { 5492 void GLES2DecoderImpl::RestoreFramebufferBindings() const {
5488 GLuint service_id = 5493 GLuint service_id =
5489 framebuffer_state_.bound_draw_framebuffer.get() 5494 framebuffer_state_.bound_draw_framebuffer.get()
5490 ? framebuffer_state_.bound_draw_framebuffer->service_id() 5495 ? framebuffer_state_.bound_draw_framebuffer->service_id()
5491 : GetBackbufferServiceId(); 5496 : GetBackbufferServiceId();
5492 if (!features().chromium_framebuffer_multisample) { 5497 if (!SupportsSeparateFramebufferBinds()) {
5493 glBindFramebufferEXT(GL_FRAMEBUFFER, service_id); 5498 glBindFramebufferEXT(GL_FRAMEBUFFER, service_id);
5494 } else { 5499 } else {
5495 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER, service_id); 5500 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER, service_id);
5496 service_id = framebuffer_state_.bound_read_framebuffer.get() 5501 service_id = framebuffer_state_.bound_read_framebuffer.get()
5497 ? framebuffer_state_.bound_read_framebuffer->service_id() 5502 ? framebuffer_state_.bound_read_framebuffer->service_id()
5498 : GetBackbufferServiceId(); 5503 : GetBackbufferServiceId();
5499 glBindFramebufferEXT(GL_READ_FRAMEBUFFER, service_id); 5504 glBindFramebufferEXT(GL_READ_FRAMEBUFFER, service_id);
5500 } 5505 }
5501 OnFboChanged(); 5506 OnFboChanged();
5502 } 5507 }
(...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after
6165 texture_manager()->MarkMipmapsGenerated(texture_ref); 6170 texture_manager()->MarkMipmapsGenerated(texture_ref);
6166 } 6171 }
6167 } 6172 }
6168 6173
6169 bool GLES2DecoderImpl::GetHelper( 6174 bool GLES2DecoderImpl::GetHelper(
6170 GLenum pname, GLint* params, GLsizei* num_written) { 6175 GLenum pname, GLint* params, GLsizei* num_written) {
6171 DCHECK(num_written); 6176 DCHECK(num_written);
6172 switch (pname) { 6177 switch (pname) {
6173 case GL_IMPLEMENTATION_COLOR_READ_FORMAT: 6178 case GL_IMPLEMENTATION_COLOR_READ_FORMAT:
6174 case GL_IMPLEMENTATION_COLOR_READ_TYPE: 6179 case GL_IMPLEMENTATION_COLOR_READ_TYPE:
6175 // They are not supported on Desktop GL until 4.1, but could be exposed
6176 // through GL_OES_read_format extension. However, a conflicting extension
6177 // GL_ARB_ES2_compatibility specifies an error case when requested on
6178 // integer/floating point buffers.
6179 // To simpify the handling, we just query and check for GL errors. If an
6180 // GL error occur, we fall back to our internal implementation.
6181 *num_written = 1; 6180 *num_written = 1;
6182 if (!CheckBoundReadFramebufferValid("glGetIntegerv", 6181 {
6183 GL_INVALID_OPERATION)) { 6182 Framebuffer* framebuffer = GetBoundReadFramebuffer();
6184 if (params) { 6183 if (framebuffer &&
6185 *params = 0; 6184 framebuffer->IsPossiblyComplete(feature_info_.get()) !=
6185 GL_FRAMEBUFFER_COMPLETE) {
6186 // Here we avoid querying the driver framebuffer status because the
6187 // above should cover most cases. This is an effort to reduce crashes
6188 // on MacOSX. See crbug.com/662802.
6189 LOCAL_SET_GL_ERROR(
6190 GL_INVALID_OPERATION, "glGetIntegerv", "incomplete framebuffer");
6191 if (params) {
6192 *params = 0;
6193 }
6194 return true;
6186 } 6195 }
6187 return true;
6188 } 6196 }
6189 if (params) { 6197 if (params) {
6190 ScopedGLErrorSuppressor suppressor("GLES2DecoderImpl::GetHelper", 6198 if (feature_info_->gl_version_info().is_es) {
6191 GetErrorState()); 6199 glGetIntegerv(pname, params);
6192 glGetIntegerv(pname, params); 6200 } else {
6193 bool is_valid = glGetError() == GL_NO_ERROR; 6201 // On Desktop GL where these two enums can be queried, instead of
6194 if (is_valid) { 6202 // returning the second pair of read format/type, the preferred pair
6195 is_valid = pname == GL_IMPLEMENTATION_COLOR_READ_FORMAT ? 6203 // is returned. So this semantic is different from GL ES.
6196 validators_->read_pixel_format.IsValid(*params) :
6197 validators_->read_pixel_type.IsValid(*params);
6198 }
6199 if (!is_valid) {
6200 if (pname == GL_IMPLEMENTATION_COLOR_READ_FORMAT) { 6204 if (pname == GL_IMPLEMENTATION_COLOR_READ_FORMAT) {
6201 *params = GLES2Util::GetGLReadPixelsImplementationFormat( 6205 *params = GLES2Util::GetGLReadPixelsImplementationFormat(
6202 GetBoundReadFramebufferInternalFormat(), 6206 GetBoundReadFramebufferInternalFormat(),
6203 GetBoundReadFramebufferTextureType(), 6207 GetBoundReadFramebufferTextureType(),
6204 feature_info_->feature_flags().ext_read_format_bgra); 6208 feature_info_->feature_flags().ext_read_format_bgra);
6205 } else { 6209 } else {
6206 *params = GLES2Util::GetGLReadPixelsImplementationType( 6210 *params = GLES2Util::GetGLReadPixelsImplementationType(
6207 GetBoundReadFramebufferInternalFormat(), 6211 GetBoundReadFramebufferInternalFormat(),
6208 GetBoundReadFramebufferTextureType()); 6212 GetBoundReadFramebufferTextureType());
6209 } 6213 }
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
6262 glGetIntegerv(GL_MAX_VARYING_VECTORS, &max_varying_vectors); 6266 glGetIntegerv(GL_MAX_VARYING_VECTORS, &max_varying_vectors);
6263 *num_written = 1; 6267 *num_written = 1;
6264 if (params) { 6268 if (params) {
6265 *params = max_varying_vectors * 4; 6269 *params = max_varying_vectors * 4;
6266 } 6270 }
6267 return true; 6271 return true;
6268 } 6272 }
6269 case GL_READ_BUFFER: 6273 case GL_READ_BUFFER:
6270 *num_written = 1; 6274 *num_written = 1;
6271 if (params) { 6275 if (params) {
6272 Framebuffer* framebuffer = 6276 Framebuffer* framebuffer = GetBoundReadFramebuffer();
6273 GetFramebufferInfoForTarget(GL_READ_FRAMEBUFFER);
6274 GLenum read_buffer; 6277 GLenum read_buffer;
6275 if (framebuffer) { 6278 if (framebuffer) {
6276 read_buffer = framebuffer->read_buffer(); 6279 read_buffer = framebuffer->read_buffer();
6277 } else { 6280 } else {
6278 read_buffer = back_buffer_read_buffer_; 6281 read_buffer = back_buffer_read_buffer_;
6279 } 6282 }
6280 *params = static_cast<GLint>(read_buffer); 6283 *params = static_cast<GLint>(read_buffer);
6281 } 6284 }
6282 return true; 6285 return true;
6283 case GL_TRANSFORM_FEEDBACK_ACTIVE: 6286 case GL_TRANSFORM_FEEDBACK_ACTIVE:
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
6340 case GL_MAX_DRAW_BUFFERS_ARB: 6343 case GL_MAX_DRAW_BUFFERS_ARB:
6341 *num_written = 1; 6344 *num_written = 1;
6342 if (params) { 6345 if (params) {
6343 params[0] = group_->max_draw_buffers(); 6346 params[0] = group_->max_draw_buffers();
6344 } 6347 }
6345 return true; 6348 return true;
6346 case GL_ALPHA_BITS: 6349 case GL_ALPHA_BITS:
6347 *num_written = 1; 6350 *num_written = 1;
6348 if (params) { 6351 if (params) {
6349 GLint v = 0; 6352 GLint v = 0;
6350 Framebuffer* framebuffer = 6353 Framebuffer* framebuffer = GetBoundDrawFramebuffer();
6351 GetFramebufferInfoForTarget(GL_DRAW_FRAMEBUFFER_EXT);
6352 if (framebuffer) { 6354 if (framebuffer) {
6353 if (framebuffer->HasAlphaMRT() && 6355 if (framebuffer->HasAlphaMRT() &&
6354 framebuffer->HasSameInternalFormatsMRT()) { 6356 framebuffer->HasSameInternalFormatsMRT()) {
6355 if (gl_version_info().is_desktop_core_profile) { 6357 if (gl_version_info().is_desktop_core_profile) {
6356 for (uint32_t i = 0; i < group_->max_draw_buffers(); i++) { 6358 for (uint32_t i = 0; i < group_->max_draw_buffers(); i++) {
6357 if (framebuffer->HasColorAttachment(i)) { 6359 if (framebuffer->HasColorAttachment(i)) {
6358 glGetFramebufferAttachmentParameterivEXT( 6360 glGetFramebufferAttachmentParameterivEXT(
6359 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i, 6361 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i,
6360 GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE, &v); 6362 GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE, &v);
6361 break; 6363 break;
6362 } 6364 }
6363 } 6365 }
6364 } else { 6366 } else {
6365 glGetIntegerv(GL_ALPHA_BITS, &v); 6367 glGetIntegerv(GL_ALPHA_BITS, &v);
6366 } 6368 }
6367 } 6369 }
6368 } else { 6370 } else {
6369 v = (ClientExposedBackBufferHasAlpha() ? 8 : 0); 6371 v = (ClientExposedBackBufferHasAlpha() ? 8 : 0);
6370 } 6372 }
6371 params[0] = v; 6373 params[0] = v;
6372 } 6374 }
6373 return true; 6375 return true;
6374 case GL_DEPTH_BITS: 6376 case GL_DEPTH_BITS:
6375 *num_written = 1; 6377 *num_written = 1;
6376 if (params) { 6378 if (params) {
6377 GLint v = 0; 6379 GLint v = 0;
6378 if (gl_version_info().is_desktop_core_profile) { 6380 if (gl_version_info().is_desktop_core_profile) {
6379 Framebuffer* framebuffer = 6381 Framebuffer* framebuffer = GetBoundDrawFramebuffer();
6380 GetFramebufferInfoForTarget(GL_DRAW_FRAMEBUFFER_EXT);
6381 if (framebuffer) { 6382 if (framebuffer) {
6382 if (framebuffer->HasDepthAttachment()) { 6383 if (framebuffer->HasDepthAttachment()) {
6383 glGetFramebufferAttachmentParameterivEXT( 6384 glGetFramebufferAttachmentParameterivEXT(
6384 GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, 6385 GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
6385 GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE, &v); 6386 GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE, &v);
6386 } 6387 }
6387 } else { 6388 } else {
6388 v = (back_buffer_has_depth_ ? 24 : 0); 6389 v = (back_buffer_has_depth_ ? 24 : 0);
6389 } 6390 }
6390 } else { 6391 } else {
6391 glGetIntegerv(GL_DEPTH_BITS, &v); 6392 glGetIntegerv(GL_DEPTH_BITS, &v);
6392 } 6393 }
6393 params[0] = BoundFramebufferHasDepthAttachment() ? v : 0; 6394 params[0] = BoundFramebufferHasDepthAttachment() ? v : 0;
6394 } 6395 }
6395 return true; 6396 return true;
6396 case GL_RED_BITS: 6397 case GL_RED_BITS:
6397 case GL_GREEN_BITS: 6398 case GL_GREEN_BITS:
6398 case GL_BLUE_BITS: 6399 case GL_BLUE_BITS:
6399 *num_written = 1; 6400 *num_written = 1;
6400 if (params) { 6401 if (params) {
6401 GLint v = 0; 6402 GLint v = 0;
6402 if (gl_version_info().is_desktop_core_profile) { 6403 if (gl_version_info().is_desktop_core_profile) {
6403 Framebuffer* framebuffer = 6404 Framebuffer* framebuffer = GetBoundDrawFramebuffer();
6404 GetFramebufferInfoForTarget(GL_DRAW_FRAMEBUFFER_EXT);
6405 if (framebuffer) { 6405 if (framebuffer) {
6406 if (framebuffer->HasSameInternalFormatsMRT()) { 6406 if (framebuffer->HasSameInternalFormatsMRT()) {
6407 GLenum framebuffer_enum = 0; 6407 GLenum framebuffer_enum = 0;
6408 switch (pname) { 6408 switch (pname) {
6409 case GL_RED_BITS: 6409 case GL_RED_BITS:
6410 framebuffer_enum = GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE; 6410 framebuffer_enum = GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE;
6411 break; 6411 break;
6412 case GL_GREEN_BITS: 6412 case GL_GREEN_BITS:
6413 framebuffer_enum = GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE; 6413 framebuffer_enum = GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE;
6414 break; 6414 break;
(...skipping 17 matching lines...) Expand all
6432 glGetIntegerv(pname, &v); 6432 glGetIntegerv(pname, &v);
6433 } 6433 }
6434 params[0] = v; 6434 params[0] = v;
6435 } 6435 }
6436 return true; 6436 return true;
6437 case GL_STENCIL_BITS: 6437 case GL_STENCIL_BITS:
6438 *num_written = 1; 6438 *num_written = 1;
6439 if (params) { 6439 if (params) {
6440 GLint v = 0; 6440 GLint v = 0;
6441 if (gl_version_info().is_desktop_core_profile) { 6441 if (gl_version_info().is_desktop_core_profile) {
6442 Framebuffer* framebuffer = 6442 Framebuffer* framebuffer = GetBoundDrawFramebuffer();
6443 GetFramebufferInfoForTarget(GL_DRAW_FRAMEBUFFER_EXT);
6444 if (framebuffer) { 6443 if (framebuffer) {
6445 if (framebuffer->HasStencilAttachment()) { 6444 if (framebuffer->HasStencilAttachment()) {
6446 glGetFramebufferAttachmentParameterivEXT( 6445 glGetFramebufferAttachmentParameterivEXT(
6447 GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, 6446 GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT,
6448 GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE, &v); 6447 GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE, &v);
6449 } 6448 }
6450 } else { 6449 } else {
6451 v = (back_buffer_has_stencil_ ? 8 : 0); 6450 v = (back_buffer_has_stencil_ ? 8 : 0);
6452 } 6451 }
6453 } else { 6452 } else {
(...skipping 994 matching lines...) Expand 10 before | Expand all | Expand 10 after
7448 // Assumes framebuffer is complete. 7447 // Assumes framebuffer is complete.
7449 void GLES2DecoderImpl::ClearUnclearedAttachments( 7448 void GLES2DecoderImpl::ClearUnclearedAttachments(
7450 GLenum target, Framebuffer* framebuffer) { 7449 GLenum target, Framebuffer* framebuffer) {
7451 // Clear textures that we can't use glClear first. These textures will be 7450 // Clear textures that we can't use glClear first. These textures will be
7452 // marked as cleared after the call and no longer be part of the following 7451 // marked as cleared after the call and no longer be part of the following
7453 // code. 7452 // code.
7454 framebuffer->ClearUnclearedIntOr3DTexturesOrPartiallyClearedTextures( 7453 framebuffer->ClearUnclearedIntOr3DTexturesOrPartiallyClearedTextures(
7455 this, texture_manager()); 7454 this, texture_manager());
7456 7455
7457 bool cleared_int_renderbuffers = false; 7456 bool cleared_int_renderbuffers = false;
7458 Framebuffer* draw_framebuffer = 7457 Framebuffer* draw_framebuffer = GetBoundDrawFramebuffer();
7459 GetFramebufferInfoForTarget(GL_DRAW_FRAMEBUFFER);
7460 if (framebuffer->HasUnclearedIntRenderbufferAttachments()) { 7458 if (framebuffer->HasUnclearedIntRenderbufferAttachments()) {
7461 if (target == GL_READ_FRAMEBUFFER && draw_framebuffer != framebuffer) { 7459 if (target == GL_READ_FRAMEBUFFER && draw_framebuffer != framebuffer) {
7462 // TODO(zmo): There is no guarantee that an FBO that is complete on the 7460 // TODO(zmo): There is no guarantee that an FBO that is complete on the
7463 // READ attachment will be complete as a DRAW attachment. 7461 // READ attachment will be complete as a DRAW attachment.
7464 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER, framebuffer->service_id()); 7462 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER, framebuffer->service_id());
7465 } 7463 }
7466 state_.SetDeviceColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 7464 state_.SetDeviceColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
7467 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false); 7465 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false);
7468 7466
7469 // TODO(zmo): Assume DrawBuffers() does not affect ClearBuffer(). 7467 // TODO(zmo): Assume DrawBuffers() does not affect ClearBuffer().
(...skipping 6509 matching lines...) Expand 10 before | Expand all | Expand 10 after
13979 final_internal_format, channels_exist, &source_texture_service_id, 13977 final_internal_format, channels_exist, &source_texture_service_id,
13980 &source_texture_target); 13978 &source_texture_target);
13981 if (requires_luma_blit) { 13979 if (requires_luma_blit) {
13982 copy_tex_image_blit_->DoCopyTexImage2DToLUMACompatibilityTexture( 13980 copy_tex_image_blit_->DoCopyTexImage2DToLUMACompatibilityTexture(
13983 this, texture->service_id(), texture->target(), target, format, 13981 this, texture->service_id(), texture->target(), target, format,
13984 type, level, internal_format, x, y, width, height, 13982 type, level, internal_format, x, y, width, height,
13985 GetBoundReadFramebufferServiceId(), 13983 GetBoundReadFramebufferServiceId(),
13986 GetBoundReadFramebufferInternalFormat()); 13984 GetBoundReadFramebufferInternalFormat());
13987 } else if (use_workaround) { 13985 } else if (use_workaround) {
13988 GLenum dest_texture_target = target; 13986 GLenum dest_texture_target = target;
13989 GLenum framebuffer_target = features().chromium_framebuffer_multisample 13987 GLenum framebuffer_target = GetReadFramebufferTarget();
13990 ? GL_READ_FRAMEBUFFER_EXT
13991 : GL_FRAMEBUFFER;
13992 13988
13993 GLenum temp_internal_format = 0; 13989 GLenum temp_internal_format = 0;
13994 if (channels_exist == GLES2Util::kRGBA) { 13990 if (channels_exist == GLES2Util::kRGBA) {
13995 temp_internal_format = GL_RGBA; 13991 temp_internal_format = GL_RGBA;
13996 } else if (channels_exist == GLES2Util::kRGB) { 13992 } else if (channels_exist == GLES2Util::kRGB) {
13997 temp_internal_format = GL_RGB; 13993 temp_internal_format = GL_RGB;
13998 } else { 13994 } else {
13999 NOTREACHED(); 13995 NOTREACHED();
14000 } 13996 }
14001 13997
(...skipping 4649 matching lines...) Expand 10 before | Expand all | Expand 10 after
18651 // are met: 18647 // are met:
18652 // 1. The internal format of the new texture is not GL_RGB or GL_RGBA. 18648 // 1. The internal format of the new texture is not GL_RGB or GL_RGBA.
18653 // 2. The image of the read FBO is backed by an IOSurface. 18649 // 2. The image of the read FBO is backed by an IOSurface.
18654 // See https://crbug.com/581777#c4 for more details. 18650 // See https://crbug.com/581777#c4 for more details.
18655 if (!workarounds().use_intermediary_for_copy_texture_image) 18651 if (!workarounds().use_intermediary_for_copy_texture_image)
18656 return false; 18652 return false;
18657 18653
18658 if (internal_format == GL_RGB || internal_format == GL_RGBA) 18654 if (internal_format == GL_RGB || internal_format == GL_RGBA)
18659 return false; 18655 return false;
18660 18656
18661 GLenum framebuffer_target = features().chromium_framebuffer_multisample 18657 Framebuffer* framebuffer = GetBoundReadFramebuffer();
18662 ? GL_READ_FRAMEBUFFER_EXT
18663 : GL_FRAMEBUFFER;
18664 Framebuffer* framebuffer =
18665 GetFramebufferInfoForTarget(framebuffer_target);
18666 if (!framebuffer) 18658 if (!framebuffer)
18667 return false; 18659 return false;
18668 18660
18669 const Framebuffer::Attachment* attachment = 18661 const Framebuffer::Attachment* attachment =
18670 framebuffer->GetReadBufferAttachment(); 18662 framebuffer->GetReadBufferAttachment();
18671 if (!attachment) 18663 if (!attachment)
18672 return false; 18664 return false;
18673 18665
18674 if (!attachment->IsTextureAttachment()) 18666 if (!attachment->IsTextureAttachment())
18675 return false; 18667 return false;
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
18865 } 18857 }
18866 18858
18867 // Include the auto-generated part of this file. We split this because it means 18859 // Include the auto-generated part of this file. We split this because it means
18868 // we can easily edit the non-auto generated parts right here in this file 18860 // we can easily edit the non-auto generated parts right here in this file
18869 // instead of having to edit some template or the code generator. 18861 // instead of having to edit some template or the code generator.
18870 #include "base/macros.h" 18862 #include "base/macros.h"
18871 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 18863 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
18872 18864
18873 } // namespace gles2 18865 } // namespace gles2
18874 } // namespace gpu 18866 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698