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

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

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

Powered by Google App Engine
This is Rietveld 408576698