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

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

Issue 683113005: Update from chromium https://crrev.com/302282 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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
« no previous file with comments | « gpu/command_buffer/service/error_state.cc ('k') | gpu/command_buffer/service/image_factory.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <stdio.h> 7 #include <stdio.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <list> 10 #include <list>
(...skipping 664 matching lines...) Expand 10 before | Expand all | Expand 10 after
675 bool BoundFramebufferHasColorAttachmentWithAlpha(bool all_draw_buffers); 675 bool BoundFramebufferHasColorAttachmentWithAlpha(bool all_draw_buffers);
676 bool BoundFramebufferHasDepthAttachment(); 676 bool BoundFramebufferHasDepthAttachment();
677 bool BoundFramebufferHasStencilAttachment(); 677 bool BoundFramebufferHasStencilAttachment();
678 678
679 error::ContextLostReason GetContextLostReason() override; 679 error::ContextLostReason GetContextLostReason() override;
680 680
681 // Overridden from FramebufferManager::TextureDetachObserver: 681 // Overridden from FramebufferManager::TextureDetachObserver:
682 void OnTextureRefDetachedFromFramebuffer(TextureRef* texture) override; 682 void OnTextureRefDetachedFromFramebuffer(TextureRef* texture) override;
683 683
684 // Overriden from ErrorStateClient. 684 // Overriden from ErrorStateClient.
685 void OnContextLostError() override;
685 void OnOutOfMemoryError() override; 686 void OnOutOfMemoryError() override;
686 687
687 // Ensure Renderbuffer corresponding to last DoBindRenderbuffer() is bound. 688 // Ensure Renderbuffer corresponding to last DoBindRenderbuffer() is bound.
688 void EnsureRenderbufferBound(); 689 void EnsureRenderbufferBound();
689 690
690 // Helpers to facilitate calling into compatible extensions. 691 // Helpers to facilitate calling into compatible extensions.
691 static void RenderbufferStorageMultisampleHelper( 692 static void RenderbufferStorageMultisampleHelper(
692 const FeatureInfo* feature_info, 693 const FeatureInfo* feature_info,
693 GLenum target, 694 GLenum target,
694 GLsizei samples, 695 GLsizei samples,
(...skipping 1940 matching lines...) Expand 10 before | Expand all | Expand 10 after
2635 // mailing list archives. It also implicitly enables the desktop GL 2636 // mailing list archives. It also implicitly enables the desktop GL
2636 // capability GL_POINT_SPRITE to provide access to the gl_PointCoord 2637 // capability GL_POINT_SPRITE to provide access to the gl_PointCoord
2637 // variable in fragment shaders. 2638 // variable in fragment shaders.
2638 if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) { 2639 if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) {
2639 glEnable(GL_VERTEX_PROGRAM_POINT_SIZE); 2640 glEnable(GL_VERTEX_PROGRAM_POINT_SIZE);
2640 glEnable(GL_POINT_SPRITE); 2641 glEnable(GL_POINT_SPRITE);
2641 } 2642 }
2642 2643
2643 has_robustness_extension_ = 2644 has_robustness_extension_ =
2644 context->HasExtension("GL_ARB_robustness") || 2645 context->HasExtension("GL_ARB_robustness") ||
2646 context->HasExtension("GL_KHR_robustness") ||
2645 context->HasExtension("GL_EXT_robustness"); 2647 context->HasExtension("GL_EXT_robustness");
2646 2648
2647 if (!InitializeShaderTranslator()) { 2649 if (!InitializeShaderTranslator()) {
2648 return false; 2650 return false;
2649 } 2651 }
2650 2652
2651 state_.viewport_width = size.width(); 2653 state_.viewport_width = size.width();
2652 state_.viewport_height = size.height(); 2654 state_.viewport_height = size.height();
2653 2655
2654 GLint viewport_params[4] = { 0 }; 2656 GLint viewport_params[4] = { 0 };
(...skipping 3818 matching lines...) Expand 10 before | Expand all | Expand 10 after
6473 max_vertex_accessed); 6475 max_vertex_accessed);
6474 GLuint num_vertices = max_accessed + 1; 6476 GLuint num_vertices = max_accessed + 1;
6475 if (num_vertices == 0) { 6477 if (num_vertices == 0) {
6476 LOCAL_SET_GL_ERROR( 6478 LOCAL_SET_GL_ERROR(
6477 GL_OUT_OF_MEMORY, function_name, "Simulating attrib 0"); 6479 GL_OUT_OF_MEMORY, function_name, "Simulating attrib 0");
6478 return false; 6480 return false;
6479 } 6481 }
6480 if (attrib_info && 6482 if (attrib_info &&
6481 attrib->CanAccess(max_accessed) && 6483 attrib->CanAccess(max_accessed) &&
6482 attrib->type() == GL_FIXED) { 6484 attrib->type() == GL_FIXED) {
6483 int num_elements = attrib->size() * kSizeOfFloat; 6485 int num_elements = attrib->size() * num_vertices;
6484 int size = num_elements * num_vertices; 6486 const int src_size = num_elements * sizeof(int32);
6485 scoped_ptr<float[]> data(new float[size]); 6487 const int dst_size = num_elements * sizeof(float);
6488 scoped_ptr<float[]> data(new float[num_elements]);
6486 const int32* src = reinterpret_cast<const int32 *>( 6489 const int32* src = reinterpret_cast<const int32 *>(
6487 attrib->buffer()->GetRange(attrib->offset(), size)); 6490 attrib->buffer()->GetRange(attrib->offset(), src_size));
6488 const int32* end = src + num_elements; 6491 const int32* end = src + num_elements;
6489 float* dst = data.get(); 6492 float* dst = data.get();
6490 while (src != end) { 6493 while (src != end) {
6491 *dst++ = static_cast<float>(*src++) / 65536.0f; 6494 *dst++ = static_cast<float>(*src++) / 65536.0f;
6492 } 6495 }
6493 glBufferSubData(GL_ARRAY_BUFFER, offset, size, data.get()); 6496 glBufferSubData(GL_ARRAY_BUFFER, offset, dst_size, data.get());
6494 glVertexAttribPointer( 6497 glVertexAttribPointer(
6495 attrib->index(), attrib->size(), GL_FLOAT, false, 0, 6498 attrib->index(), attrib->size(), GL_FLOAT, false, 0,
6496 reinterpret_cast<GLvoid*>(offset)); 6499 reinterpret_cast<GLvoid*>(offset));
6497 offset += size; 6500 offset += dst_size;
6498 } 6501 }
6499 } 6502 }
6500 *simulated = true; 6503 *simulated = true;
6501 return true; 6504 return true;
6502 } 6505 }
6503 6506
6504 void GLES2DecoderImpl::RestoreStateForSimulatedFixedAttribs() { 6507 void GLES2DecoderImpl::RestoreStateForSimulatedFixedAttribs() {
6505 // There's no need to call glVertexAttribPointer because we shadow all the 6508 // There's no need to call glVertexAttribPointer because we shadow all the
6506 // settings and passing GL_FIXED to it will not work. 6509 // settings and passing GL_FIXED to it will not work.
6507 glBindBuffer( 6510 glBindBuffer(
(...skipping 3218 matching lines...) Expand 10 before | Expand all | Expand 10 after
9726 bool GLES2DecoderImpl::WasContextLostByRobustnessExtension() { 9729 bool GLES2DecoderImpl::WasContextLostByRobustnessExtension() {
9727 return WasContextLost() && reset_by_robustness_extension_; 9730 return WasContextLost() && reset_by_robustness_extension_;
9728 } 9731 }
9729 9732
9730 void GLES2DecoderImpl::LoseContext(uint32 reset_status) { 9733 void GLES2DecoderImpl::LoseContext(uint32 reset_status) {
9731 // Only loses the context once. 9734 // Only loses the context once.
9732 if (reset_status_ != GL_NO_ERROR) { 9735 if (reset_status_ != GL_NO_ERROR) {
9733 return; 9736 return;
9734 } 9737 }
9735 9738
9739 if (workarounds().use_virtualized_gl_contexts) {
9740 // If the context is virtual, the real context being guilty does not ensure
9741 // that the virtual context is guilty.
9742 if (reset_status == GL_GUILTY_CONTEXT_RESET_ARB) {
9743 reset_status = GL_UNKNOWN_CONTEXT_RESET_ARB;
9744 }
9745 } else if (reset_status == GL_UNKNOWN_CONTEXT_RESET_ARB &&
9746 has_robustness_extension_) {
9747 // If the reason for the call was a GL error, we can try to determine the
9748 // reset status more accurately.
9749 GLenum driver_status = glGetGraphicsResetStatusARB();
9750 if (driver_status == GL_GUILTY_CONTEXT_RESET_ARB ||
9751 driver_status == GL_INNOCENT_CONTEXT_RESET_ARB) {
9752 reset_status = driver_status;
9753 }
9754 }
9755
9736 // Marks this context as lost. 9756 // Marks this context as lost.
9737 reset_status_ = reset_status; 9757 reset_status_ = reset_status;
9738 current_decoder_error_ = error::kLostContext; 9758 current_decoder_error_ = error::kLostContext;
9739 } 9759 }
9740 9760
9741 error::Error GLES2DecoderImpl::HandleInsertSyncPointCHROMIUM( 9761 error::Error GLES2DecoderImpl::HandleInsertSyncPointCHROMIUM(
9742 uint32 immediate_data_size, 9762 uint32 immediate_data_size,
9743 const void* cmd_data) { 9763 const void* cmd_data) {
9744 return error::kUnknownCommand; 9764 return error::kUnknownCommand;
9745 } 9765 }
(...skipping 1471 matching lines...) Expand 10 before | Expand all | Expand 10 after
11217 ProcessFinishedAsyncTransfers(); 11237 ProcessFinishedAsyncTransfers();
11218 return error::kNoError; 11238 return error::kNoError;
11219 } 11239 }
11220 11240
11221 void GLES2DecoderImpl::OnTextureRefDetachedFromFramebuffer( 11241 void GLES2DecoderImpl::OnTextureRefDetachedFromFramebuffer(
11222 TextureRef* texture_ref) { 11242 TextureRef* texture_ref) {
11223 Texture* texture = texture_ref->texture(); 11243 Texture* texture = texture_ref->texture();
11224 DoDidUseTexImageIfNeeded(texture, texture->target()); 11244 DoDidUseTexImageIfNeeded(texture, texture->target());
11225 } 11245 }
11226 11246
11247 void GLES2DecoderImpl::OnContextLostError() {
11248 group_->LoseContexts(GL_UNKNOWN_CONTEXT_RESET_ARB);
11249 }
11250
11227 void GLES2DecoderImpl::OnOutOfMemoryError() { 11251 void GLES2DecoderImpl::OnOutOfMemoryError() {
11228 if (lose_context_when_out_of_memory_) { 11252 if (lose_context_when_out_of_memory_) {
11229 group_->LoseContexts(GL_UNKNOWN_CONTEXT_RESET_ARB); 11253 group_->LoseContexts(GL_UNKNOWN_CONTEXT_RESET_ARB);
11230 LoseContext(GL_GUILTY_CONTEXT_RESET_ARB);
11231 } 11254 }
11232 } 11255 }
11233 11256
11234 // Include the auto-generated part of this file. We split this because it means 11257 // Include the auto-generated part of this file. We split this because it means
11235 // we can easily edit the non-auto generated parts right here in this file 11258 // we can easily edit the non-auto generated parts right here in this file
11236 // instead of having to edit some template or the code generator. 11259 // instead of having to edit some template or the code generator.
11237 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 11260 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
11238 11261
11239 } // namespace gles2 11262 } // namespace gles2
11240 } // namespace gpu 11263 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/error_state.cc ('k') | gpu/command_buffer/service/image_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698