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

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

Issue 2814583002: Service/ClientDiscardableManager (Closed)
Patch Set: Feedback Created 3 years, 7 months 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 #include "gpu/command_buffer/service/image_factory.h" 53 #include "gpu/command_buffer/service/image_factory.h"
54 #include "gpu/command_buffer/service/image_manager.h" 54 #include "gpu/command_buffer/service/image_manager.h"
55 #include "gpu/command_buffer/service/logger.h" 55 #include "gpu/command_buffer/service/logger.h"
56 #include "gpu/command_buffer/service/mailbox_manager.h" 56 #include "gpu/command_buffer/service/mailbox_manager.h"
57 #include "gpu/command_buffer/service/memory_tracking.h" 57 #include "gpu/command_buffer/service/memory_tracking.h"
58 #include "gpu/command_buffer/service/path_manager.h" 58 #include "gpu/command_buffer/service/path_manager.h"
59 #include "gpu/command_buffer/service/program_manager.h" 59 #include "gpu/command_buffer/service/program_manager.h"
60 #include "gpu/command_buffer/service/query_manager.h" 60 #include "gpu/command_buffer/service/query_manager.h"
61 #include "gpu/command_buffer/service/renderbuffer_manager.h" 61 #include "gpu/command_buffer/service/renderbuffer_manager.h"
62 #include "gpu/command_buffer/service/sampler_manager.h" 62 #include "gpu/command_buffer/service/sampler_manager.h"
63 #include "gpu/command_buffer/service/service_discardable_manager.h"
63 #include "gpu/command_buffer/service/shader_manager.h" 64 #include "gpu/command_buffer/service/shader_manager.h"
64 #include "gpu/command_buffer/service/shader_translator.h" 65 #include "gpu/command_buffer/service/shader_translator.h"
65 #include "gpu/command_buffer/service/texture_manager.h" 66 #include "gpu/command_buffer/service/texture_manager.h"
66 #include "gpu/command_buffer/service/transform_feedback_manager.h" 67 #include "gpu/command_buffer/service/transform_feedback_manager.h"
67 #include "gpu/command_buffer/service/vertex_array_manager.h" 68 #include "gpu/command_buffer/service/vertex_array_manager.h"
68 #include "gpu/command_buffer/service/vertex_attrib_manager.h" 69 #include "gpu/command_buffer/service/vertex_attrib_manager.h"
69 #include "third_party/angle/src/image_util/loadimage.h" 70 #include "third_party/angle/src/image_util/loadimage.h"
70 #include "third_party/smhasher/src/City.h" 71 #include "third_party/smhasher/src/City.h"
71 #include "ui/gfx/buffer_types.h" 72 #include "ui/gfx/buffer_types.h"
72 #include "ui/gfx/geometry/point.h" 73 #include "ui/gfx/geometry/point.h"
(...skipping 2138 matching lines...) Expand 10 before | Expand all | Expand 10 after
2211 } 2212 }
2212 2213
2213 Framebuffer* GetBoundReadFramebuffer() const { 2214 Framebuffer* GetBoundReadFramebuffer() const {
2214 GLenum target = GetReadFramebufferTarget(); 2215 GLenum target = GetReadFramebufferTarget();
2215 return GetFramebufferInfoForTarget(target); 2216 return GetFramebufferInfoForTarget(target);
2216 } 2217 }
2217 2218
2218 bool InitializeCopyTexImageBlitter(const char* function_name); 2219 bool InitializeCopyTexImageBlitter(const char* function_name);
2219 bool InitializeCopyTextureCHROMIUM(const char* function_name); 2220 bool InitializeCopyTextureCHROMIUM(const char* function_name);
2220 bool InitializeSRGBConverter(const char* function_name); 2221 bool InitializeSRGBConverter(const char* function_name);
2222
2223 void UnbindTexture(TextureRef* texture_ref,
2224 bool supports_separate_framebuffer_binds);
2225
2221 // Generate a member function prototype for each command in an automated and 2226 // Generate a member function prototype for each command in an automated and
2222 // typesafe way. 2227 // typesafe way.
2223 #define GLES2_CMD_OP(name) \ 2228 #define GLES2_CMD_OP(name) \
2224 Error Handle##name(uint32_t immediate_data_size, const volatile void* data); 2229 Error Handle##name(uint32_t immediate_data_size, const volatile void* data);
2225 2230
2226 GLES2_COMMAND_LIST(GLES2_CMD_OP) 2231 GLES2_COMMAND_LIST(GLES2_CMD_OP)
2227 2232
2228 #undef GLES2_CMD_OP 2233 #undef GLES2_CMD_OP
2229 2234
2230 // The GL context this decoder renders to on behalf of the client. 2235 // The GL context this decoder renders to on behalf of the client.
(...skipping 1963 matching lines...) Expand 10 before | Expand all | Expand 10 after
4194 } 4199 }
4195 } 4200 }
4196 4201
4197 void GLES2DecoderImpl::DeleteTexturesHelper(GLsizei n, 4202 void GLES2DecoderImpl::DeleteTexturesHelper(GLsizei n,
4198 const volatile GLuint* client_ids) { 4203 const volatile GLuint* client_ids) {
4199 bool supports_separate_framebuffer_binds = SupportsSeparateFramebufferBinds(); 4204 bool supports_separate_framebuffer_binds = SupportsSeparateFramebufferBinds();
4200 for (GLsizei ii = 0; ii < n; ++ii) { 4205 for (GLsizei ii = 0; ii < n; ++ii) {
4201 GLuint client_id = client_ids[ii]; 4206 GLuint client_id = client_ids[ii];
4202 TextureRef* texture_ref = GetTexture(client_id); 4207 TextureRef* texture_ref = GetTexture(client_id);
4203 if (texture_ref) { 4208 if (texture_ref) {
4204 Texture* texture = texture_ref->texture(); 4209 UnbindTexture(texture_ref, supports_separate_framebuffer_binds);
4205 if (texture->IsAttachedToFramebuffer()) {
4206 framebuffer_state_.clear_state_dirty = true;
4207 }
4208 // Unbind texture_ref from texture_ref units.
4209 state_.UnbindTexture(texture_ref);
4210
4211 // Unbind from current framebuffers.
4212 if (supports_separate_framebuffer_binds) {
4213 if (framebuffer_state_.bound_read_framebuffer.get()) {
4214 framebuffer_state_.bound_read_framebuffer
4215 ->UnbindTexture(GL_READ_FRAMEBUFFER_EXT, texture_ref);
4216 }
4217 if (framebuffer_state_.bound_draw_framebuffer.get()) {
4218 framebuffer_state_.bound_draw_framebuffer
4219 ->UnbindTexture(GL_DRAW_FRAMEBUFFER_EXT, texture_ref);
4220 }
4221 } else {
4222 if (framebuffer_state_.bound_draw_framebuffer.get()) {
4223 framebuffer_state_.bound_draw_framebuffer
4224 ->UnbindTexture(GL_FRAMEBUFFER, texture_ref);
4225 }
4226 }
4227 RemoveTexture(client_id); 4210 RemoveTexture(client_id);
4228 } 4211 }
4229 } 4212 }
4230 } 4213 }
4231 4214
4232 void GLES2DecoderImpl::DeleteSamplersHelper(GLsizei n, 4215 void GLES2DecoderImpl::DeleteSamplersHelper(GLsizei n,
4233 const volatile GLuint* client_ids) { 4216 const volatile GLuint* client_ids) {
4234 for (GLsizei ii = 0; ii < n; ++ii) { 4217 for (GLsizei ii = 0; ii < n; ++ii) {
4235 GLuint client_id = client_ids[ii]; 4218 GLuint client_id = client_ids[ii];
4236 Sampler* sampler = GetSampler(client_id); 4219 Sampler* sampler = GetSampler(client_id);
(...skipping 4134 matching lines...) Expand 10 before | Expand all | Expand 10 after
8371 srgb_converter_.reset( 8354 srgb_converter_.reset(
8372 new SRGBConverter(feature_info_.get())); 8355 new SRGBConverter(feature_info_.get()));
8373 srgb_converter_->InitializeSRGBConverter(this); 8356 srgb_converter_->InitializeSRGBConverter(this);
8374 if (LOCAL_PEEK_GL_ERROR(function_name) != GL_NO_ERROR) { 8357 if (LOCAL_PEEK_GL_ERROR(function_name) != GL_NO_ERROR) {
8375 return false; 8358 return false;
8376 } 8359 }
8377 } 8360 }
8378 return true; 8361 return true;
8379 } 8362 }
8380 8363
8364 void GLES2DecoderImpl::UnbindTexture(TextureRef* texture_ref,
8365 bool supports_separate_framebuffer_binds) {
8366 Texture* texture = texture_ref->texture();
8367 if (texture->IsAttachedToFramebuffer()) {
8368 framebuffer_state_.clear_state_dirty = true;
8369 }
8370 // Unbind texture_ref from texture_ref units.
8371 state_.UnbindTexture(texture_ref);
8372
8373 // Unbind from current framebuffers.
8374 if (supports_separate_framebuffer_binds) {
8375 if (framebuffer_state_.bound_read_framebuffer.get()) {
8376 framebuffer_state_.bound_read_framebuffer->UnbindTexture(
8377 GL_READ_FRAMEBUFFER_EXT, texture_ref);
8378 }
8379 if (framebuffer_state_.bound_draw_framebuffer.get()) {
8380 framebuffer_state_.bound_draw_framebuffer->UnbindTexture(
8381 GL_DRAW_FRAMEBUFFER_EXT, texture_ref);
8382 }
8383 } else {
8384 if (framebuffer_state_.bound_draw_framebuffer.get()) {
8385 framebuffer_state_.bound_draw_framebuffer->UnbindTexture(GL_FRAMEBUFFER,
8386 texture_ref);
8387 }
8388 }
8389 }
8390
8381 void GLES2DecoderImpl::EnsureRenderbufferBound() { 8391 void GLES2DecoderImpl::EnsureRenderbufferBound() {
8382 if (!state_.bound_renderbuffer_valid) { 8392 if (!state_.bound_renderbuffer_valid) {
8383 state_.bound_renderbuffer_valid = true; 8393 state_.bound_renderbuffer_valid = true;
8384 glBindRenderbufferEXT(GL_RENDERBUFFER, 8394 glBindRenderbufferEXT(GL_RENDERBUFFER,
8385 state_.bound_renderbuffer.get() 8395 state_.bound_renderbuffer.get()
8386 ? state_.bound_renderbuffer->service_id() 8396 ? state_.bound_renderbuffer->service_id()
8387 : 0); 8397 : 0);
8388 } 8398 }
8389 } 8399 }
8390 8400
(...skipping 11261 matching lines...) Expand 10 before | Expand all | Expand 10 after
19652 glBindTexture(GL_TEXTURE_EXTERNAL_OES, texture_ref->service_id()); 19662 glBindTexture(GL_TEXTURE_EXTERNAL_OES, texture_ref->service_id());
19653 } 19663 }
19654 } 19664 }
19655 19665
19656 glActiveTexture(GL_TEXTURE0 + state_.active_texture_unit); 19666 glActiveTexture(GL_TEXTURE0 + state_.active_texture_unit);
19657 19667
19658 texture_manager_service_id_generation_ = 19668 texture_manager_service_id_generation_ =
19659 texture_manager()->GetServiceIdGeneration(); 19669 texture_manager()->GetServiceIdGeneration();
19660 } 19670 }
19661 19671
19672 error::Error GLES2DecoderImpl::HandleInitializeDiscardableTextureCHROMIUM(
19673 uint32_t immediate_data_size,
19674 const volatile void* cmd_data) {
19675 const volatile gles2::cmds::InitializeDiscardableTextureCHROMIUM& c =
19676 *static_cast<
19677 const volatile gles2::cmds::InitializeDiscardableTextureCHROMIUM*>(
19678 cmd_data);
19679 TextureRef* texture = texture_manager()->GetTexture(c.texture_id);
19680 if (!texture) {
19681 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE,
19682 "glInitializeDiscardableTextureCHROMIUM",
19683 "Invalid texture ID");
19684 return error::kNoError;
19685 }
19686 size_t size = texture->texture()->estimated_size();
19687 ServiceDiscardableHandle handle(GetSharedMemoryBuffer(c.shm_id), c.shm_offset,
19688 c.shm_id);
19689 GetContextGroup()->discardable_manager()->InsertLockedTexture(
19690 c.texture_id, size, group_->texture_manager(), std::move(handle));
19691 return error::kNoError;
19692 }
19693
19694 error::Error GLES2DecoderImpl::HandleUnlockDiscardableTextureCHROMIUM(
19695 uint32_t immediate_data_size,
19696 const volatile void* cmd_data) {
19697 const volatile gles2::cmds::UnlockDiscardableTextureCHROMIUM& c =
19698 *static_cast<
19699 const volatile gles2::cmds::UnlockDiscardableTextureCHROMIUM*>(
19700 cmd_data);
19701 ServiceDiscardableManager* discardable_manager =
19702 GetContextGroup()->discardable_manager();
19703 TextureRef* texture_to_unbind;
19704 if (!discardable_manager->UnlockTexture(
19705 c.texture_id, group_->texture_manager(), &texture_to_unbind)) {
19706 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glUnlockDiscardableTextureCHROMIUM",
19707 "Texture ID not initialized");
19708 }
19709 if (texture_to_unbind)
19710 UnbindTexture(texture_to_unbind, SupportsSeparateFramebufferBinds());
19711
19712 return error::kNoError;
19713 }
19714
19715 error::Error GLES2DecoderImpl::HandleLockDiscardableTextureCHROMIUM(
19716 uint32_t immediate_data_size,
19717 const volatile void* cmd_data) {
19718 const volatile gles2::cmds::LockDiscardableTextureCHROMIUM& c =
19719 *static_cast<const volatile gles2::cmds::LockDiscardableTextureCHROMIUM*>(
19720 cmd_data);
19721 if (!GetContextGroup()->discardable_manager()->LockTexture(
19722 c.texture_id, group_->texture_manager())) {
19723 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glLockDiscardableTextureCHROMIUM",
19724 "Texture ID not initialized");
19725 }
19726 return error::kNoError;
19727 }
19728
19662 // Include the auto-generated part of this file. We split this because it means 19729 // Include the auto-generated part of this file. We split this because it means
19663 // we can easily edit the non-auto generated parts right here in this file 19730 // we can easily edit the non-auto generated parts right here in this file
19664 // instead of having to edit some template or the code generator. 19731 // instead of having to edit some template or the code generator.
19665 #include "base/macros.h" 19732 #include "base/macros.h"
19666 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 19733 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
19667 19734
19668 } // namespace gles2 19735 } // namespace gles2
19669 } // namespace gpu 19736 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698