Restore gl scissor state when switching FBO targets on Qualcomm

This works around flickering on Qualcomm devices when
using virtual contexts. Qualcomm has a bug where switching
to FBO targets of different sizes corrupts the scissor rect.

BUG=165493

Review URL: https://chromiumcodereview.appspot.com/11734037

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@175630 0039d316-1c4b-4281-b951-d872f2087c98
parent 48861e28
...@@ -91,6 +91,7 @@ FeatureInfo::Workarounds::Workarounds() ...@@ -91,6 +91,7 @@ FeatureInfo::Workarounds::Workarounds()
reverse_point_sprite_coord_origin(false), reverse_point_sprite_coord_origin(false),
set_texture_filter_before_generating_mipmap(false), set_texture_filter_before_generating_mipmap(false),
use_current_program_after_successful_link(false), use_current_program_after_successful_link(false),
restore_scissor_on_fbo_change(false),
max_texture_size(0), max_texture_size(0),
max_cube_map_texture_size(0) { max_cube_map_texture_size(0) {
} }
...@@ -598,6 +599,10 @@ void FeatureInfo::AddFeatures() { ...@@ -598,6 +599,10 @@ void FeatureInfo::AddFeatures() {
workarounds_.use_current_program_after_successful_link = true; workarounds_.use_current_program_after_successful_link = true;
} }
if (is_qualcomm) {
workarounds_.restore_scissor_on_fbo_change = true;
}
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
workarounds_.needs_offscreen_buffer_workaround = is_nvidia; workarounds_.needs_offscreen_buffer_workaround = is_nvidia;
workarounds_.needs_glsl_built_in_function_emulation = is_amd; workarounds_.needs_glsl_built_in_function_emulation = is_amd;
......
...@@ -53,6 +53,7 @@ class GPU_EXPORT FeatureInfo : public base::RefCounted<FeatureInfo> { ...@@ -53,6 +53,7 @@ class GPU_EXPORT FeatureInfo : public base::RefCounted<FeatureInfo> {
bool reverse_point_sprite_coord_origin; bool reverse_point_sprite_coord_origin;
bool set_texture_filter_before_generating_mipmap; bool set_texture_filter_before_generating_mipmap;
bool use_current_program_after_successful_link; bool use_current_program_after_successful_link;
bool restore_scissor_on_fbo_change;
// Note: 0 here means use driver limit. // Note: 0 here means use driver limit.
GLint max_texture_size; GLint max_texture_size;
......
...@@ -598,6 +598,7 @@ class GLES2DecoderImpl : public GLES2Decoder { ...@@ -598,6 +598,7 @@ class GLES2DecoderImpl : public GLES2Decoder {
virtual error::ContextLostReason GetContextLostReason() OVERRIDE; virtual error::ContextLostReason GetContextLostReason() OVERRIDE;
private: private:
friend class ScopedFrameBufferBinder;
friend class ScopedGLErrorSuppressor; friend class ScopedGLErrorSuppressor;
friend class ScopedResolvedFrameBufferBinder; friend class ScopedResolvedFrameBufferBinder;
friend class ScopedTextureUploadTimer; friend class ScopedTextureUploadTimer;
...@@ -624,6 +625,9 @@ class GLES2DecoderImpl : public GLES2Decoder { ...@@ -624,6 +625,9 @@ class GLES2DecoderImpl : public GLES2Decoder {
bool GenVertexArraysOESHelper(GLsizei n, const GLuint* client_ids); bool GenVertexArraysOESHelper(GLsizei n, const GLuint* client_ids);
void DeleteVertexArraysOESHelper(GLsizei n, const GLuint* client_ids); void DeleteVertexArraysOESHelper(GLsizei n, const GLuint* client_ids);
// Workarounds
void OnFboChanged() const;
// TODO(gman): Cache these pointers? // TODO(gman): Cache these pointers?
BufferManager* buffer_manager() { BufferManager* buffer_manager() {
return group_->buffer_manager(); return group_->buffer_manager();
...@@ -1743,6 +1747,7 @@ ScopedFrameBufferBinder::ScopedFrameBufferBinder(GLES2DecoderImpl* decoder, ...@@ -1743,6 +1747,7 @@ ScopedFrameBufferBinder::ScopedFrameBufferBinder(GLES2DecoderImpl* decoder,
: decoder_(decoder) { : decoder_(decoder) {
ScopedGLErrorSuppressor suppressor(decoder_); ScopedGLErrorSuppressor suppressor(decoder_);
glBindFramebufferEXT(GL_FRAMEBUFFER, id); glBindFramebufferEXT(GL_FRAMEBUFFER, id);
decoder->OnFboChanged();
} }
ScopedFrameBufferBinder::~ScopedFrameBufferBinder() { ScopedFrameBufferBinder::~ScopedFrameBufferBinder() {
...@@ -2605,6 +2610,7 @@ void GLES2DecoderImpl::DeleteFramebuffersHelper( ...@@ -2605,6 +2610,7 @@ void GLES2DecoderImpl::DeleteFramebuffersHelper(
GL_READ_FRAMEBUFFER_EXT : GL_FRAMEBUFFER; GL_READ_FRAMEBUFFER_EXT : GL_FRAMEBUFFER;
glBindFramebufferEXT(target, GetBackbufferServiceId()); glBindFramebufferEXT(target, GetBackbufferServiceId());
} }
OnFboChanged();
RemoveFramebufferInfo(client_ids[ii]); RemoveFramebufferInfo(client_ids[ii]);
} }
} }
...@@ -2761,6 +2767,7 @@ void GLES2DecoderImpl::RestoreCurrentFramebufferBindings() { ...@@ -2761,6 +2767,7 @@ void GLES2DecoderImpl::RestoreCurrentFramebufferBindings() {
state_.bound_draw_framebuffer.get(), state_.bound_draw_framebuffer.get(),
GetBackbufferServiceId()); GetBackbufferServiceId());
} }
OnFboChanged();
} }
void GLES2DecoderImpl::RestoreCurrentTexture2DBindings() { void GLES2DecoderImpl::RestoreCurrentTexture2DBindings() {
...@@ -3580,6 +3587,13 @@ void GLES2DecoderImpl::RestoreState() const { ...@@ -3580,6 +3587,13 @@ void GLES2DecoderImpl::RestoreState() const {
state_.bound_draw_framebuffer->service_id() : state_.bound_draw_framebuffer->service_id() :
GetBackbufferServiceId(); GetBackbufferServiceId();
glBindFramebufferEXT(GL_FRAMEBUFFER, service_id); glBindFramebufferEXT(GL_FRAMEBUFFER, service_id);
OnFboChanged();
}
void GLES2DecoderImpl::OnFboChanged() const {
if (workarounds().restore_scissor_on_fbo_change)
glScissor(state_.scissor_x, state_.scissor_y,
state_.scissor_width, state_.scissor_height);
} }
void GLES2DecoderImpl::DoBindFramebuffer(GLenum target, GLuint client_id) { void GLES2DecoderImpl::DoBindFramebuffer(GLenum target, GLuint client_id) {
...@@ -3625,6 +3639,7 @@ void GLES2DecoderImpl::DoBindFramebuffer(GLenum target, GLuint client_id) { ...@@ -3625,6 +3639,7 @@ void GLES2DecoderImpl::DoBindFramebuffer(GLenum target, GLuint client_id) {
} }
glBindFramebufferEXT(target, service_id); glBindFramebufferEXT(target, service_id);
OnFboChanged();
} }
void GLES2DecoderImpl::DoBindRenderbuffer(GLenum target, GLuint client_id) { void GLES2DecoderImpl::DoBindRenderbuffer(GLenum target, GLuint client_id) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment