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

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

Issue 2317363005: Add basic GL functionality to the passthrough command buffer. (Closed)
Patch Set: Address piman's comments. Created 4 years, 3 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) 2016 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2016 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_passthrough.h" 5 #include "gpu/command_buffer/service/gles2_cmd_decoder_passthrough.h"
6 6
7 #include "gpu/command_buffer/service/feature_info.h" 7 #include "gpu/command_buffer/service/feature_info.h"
8 #include "gpu/command_buffer/service/gl_utils.h" 8 #include "gpu/command_buffer/service/gl_utils.h"
9 #include "ui/gl/gl_version_info.h" 9 #include "ui/gl/gl_version_info.h"
10 10
11 namespace gpu { 11 namespace gpu {
12 namespace gles2 { 12 namespace gles2 {
13 13
14 namespace {
15 template <typename ClientType, typename ServiceType, typename DeleteFunction>
16 void DeleteServiceObjects(ClientServiceMap<ClientType, ServiceType>* id_map,
17 bool have_context,
18 DeleteFunction delete_function) {
19 if (have_context) {
20 for (auto client_service_id_pair : *id_map) {
21 delete_function(client_service_id_pair.second);
22 }
23 }
24
25 id_map->Clear();
26 }
27
28 } // anonymous namespace
29
30 PassthroughResources::PassthroughResources() {}
31
32 PassthroughResources::~PassthroughResources() {}
33
34 void PassthroughResources::Destroy(bool have_context) {
35 DeleteServiceObjects(&texture_id_map, have_context,
36 [](GLuint texture) { glDeleteTextures(1, &texture); });
37 DeleteServiceObjects(&buffer_id_map, have_context,
38 [](GLuint buffer) { glDeleteBuffersARB(1, &buffer); });
39 DeleteServiceObjects(
40 &renderbuffer_id_map, have_context,
41 [](GLuint renderbuffer) { glDeleteRenderbuffersEXT(1, &renderbuffer); });
42 DeleteServiceObjects(&sampler_id_map, have_context,
43 [](GLuint sampler) { glDeleteSamplers(1, &sampler); });
44 DeleteServiceObjects(&program_id_map, have_context,
45 [](GLuint program) { glDeleteProgram(program); });
46 DeleteServiceObjects(&shader_id_map, have_context,
47 [](GLuint shader) { glDeleteShader(shader); });
48 DeleteServiceObjects(&sync_id_map, have_context, [](uintptr_t sync) {
49 glDeleteSync(reinterpret_cast<GLsync>(sync));
50 });
51
52 if (!have_context) {
53 for (auto passthrough_texture : texture_object_map) {
54 passthrough_texture.second->MarkContextLost();
55 }
56 }
57 texture_object_map.clear();
58 }
59
14 GLES2DecoderPassthroughImpl::GLES2DecoderPassthroughImpl(ContextGroup* group) 60 GLES2DecoderPassthroughImpl::GLES2DecoderPassthroughImpl(ContextGroup* group)
15 : commands_to_process_(0), 61 : commands_to_process_(0),
16 debug_marker_manager_(), 62 debug_marker_manager_(),
17 logger_(&debug_marker_manager_), 63 logger_(&debug_marker_manager_),
18 surface_(), 64 surface_(),
19 context_(), 65 context_(),
20 group_(group), 66 group_(group),
21 feature_info_(group->feature_info()) { 67 feature_info_(group->feature_info()) {
22 DCHECK(group); 68 DCHECK(group);
23 } 69 }
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 152
107 if (!group_->Initialize(this, attrib_helper.context_type, 153 if (!group_->Initialize(this, attrib_helper.context_type,
108 disallowed_features)) { 154 disallowed_features)) {
109 group_ = NULL; // Must not destroy ContextGroup if it is not initialized. 155 group_ = NULL; // Must not destroy ContextGroup if it is not initialized.
110 Destroy(true); 156 Destroy(true);
111 return false; 157 return false;
112 } 158 }
113 159
114 image_manager_.reset(new ImageManager()); 160 image_manager_.reset(new ImageManager());
115 161
162 resources_ = group_->passthrough_resources();
163
164 mailbox_manager_ = group_->mailbox_manager();
165
166 // Query information about the texture units
167 GLint num_texture_units = 0;
168 glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &num_texture_units);
169
170 active_texture_unit_ = 0;
171 bound_textures_.resize(num_texture_units, 0);
172
116 set_initialized(); 173 set_initialized();
117 return true; 174 return true;
118 } 175 }
119 176
120 void GLES2DecoderPassthroughImpl::Destroy(bool have_context) { 177 void GLES2DecoderPassthroughImpl::Destroy(bool have_context) {
121 if (image_manager_.get()) { 178 if (image_manager_.get()) {
122 image_manager_->Destroy(have_context); 179 image_manager_->Destroy(have_context);
123 image_manager_.reset(); 180 image_manager_.reset();
124 } 181 }
182
183 DeleteServiceObjects(
184 &framebuffer_id_map_, have_context,
185 [](GLuint framebuffer) { glDeleteFramebuffersEXT(1, &framebuffer); });
186 DeleteServiceObjects(&transform_feedback_id_map_, have_context,
187 [](GLuint transform_feedback) {
188 glDeleteTransformFeedbacks(1, &transform_feedback);
189 });
190 DeleteServiceObjects(&query_id_map_, have_context,
191 [](GLuint query) { glDeleteQueries(1, &query); });
192 DeleteServiceObjects(
193 &vertex_array_id_map_, have_context,
194 [](GLuint vertex_array) { glDeleteVertexArraysOES(1, &vertex_array); });
195
196 if (group_) {
197 group_->Destroy(this, have_context);
198 group_ = nullptr;
199 }
125 } 200 }
126 201
127 void GLES2DecoderPassthroughImpl::SetSurface( 202 void GLES2DecoderPassthroughImpl::SetSurface(
128 const scoped_refptr<gl::GLSurface>& surface) { 203 const scoped_refptr<gl::GLSurface>& surface) {
129 DCHECK(context_->IsCurrent(nullptr)); 204 DCHECK(context_->IsCurrent(nullptr));
130 DCHECK(surface_.get()); 205 DCHECK(surface_.get());
131 surface_ = surface; 206 surface_ = surface;
132 } 207 }
133 208
134 void GLES2DecoderPassthroughImpl::ReleaseSurface() { 209 void GLES2DecoderPassthroughImpl::ReleaseSurface() {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 243
169 gpu::gles2::GLES2Util* GLES2DecoderPassthroughImpl::GetGLES2Util() { 244 gpu::gles2::GLES2Util* GLES2DecoderPassthroughImpl::GetGLES2Util() {
170 return nullptr; 245 return nullptr;
171 } 246 }
172 247
173 gl::GLContext* GLES2DecoderPassthroughImpl::GetGLContext() { 248 gl::GLContext* GLES2DecoderPassthroughImpl::GetGLContext() {
174 return nullptr; 249 return nullptr;
175 } 250 }
176 251
177 gpu::gles2::ContextGroup* GLES2DecoderPassthroughImpl::GetContextGroup() { 252 gpu::gles2::ContextGroup* GLES2DecoderPassthroughImpl::GetContextGroup() {
178 return nullptr; 253 return group_.get();
179 } 254 }
180 255
181 const FeatureInfo* GLES2DecoderPassthroughImpl::GetFeatureInfo() const { 256 const FeatureInfo* GLES2DecoderPassthroughImpl::GetFeatureInfo() const {
182 return nullptr; 257 return group_->feature_info();
183 } 258 }
184 259
185 gpu::Capabilities GLES2DecoderPassthroughImpl::GetCapabilities() { 260 gpu::Capabilities GLES2DecoderPassthroughImpl::GetCapabilities() {
186 DCHECK(initialized()); 261 DCHECK(initialized());
187 Capabilities caps; 262 Capabilities caps;
188 263
189 PopulateNumericCapabilities(&caps, feature_info_.get()); 264 PopulateNumericCapabilities(&caps, feature_info_.get());
190 265
191 caps.bind_generates_resource_chromium = group_->bind_generates_resource(); 266 caps.bind_generates_resource_chromium = group_->bind_generates_resource();
192 caps.egl_image_external = 267 caps.egl_image_external =
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 362
288 size_t GLES2DecoderPassthroughImpl::GetSavedBackTextureCountForTest() { 363 size_t GLES2DecoderPassthroughImpl::GetSavedBackTextureCountForTest() {
289 return 0; 364 return 0;
290 } 365 }
291 366
292 size_t GLES2DecoderPassthroughImpl::GetCreatedBackTextureCountForTest() { 367 size_t GLES2DecoderPassthroughImpl::GetCreatedBackTextureCountForTest() {
293 return 0; 368 return 0;
294 } 369 }
295 370
296 void GLES2DecoderPassthroughImpl::SetFenceSyncReleaseCallback( 371 void GLES2DecoderPassthroughImpl::SetFenceSyncReleaseCallback(
297 const FenceSyncReleaseCallback& callback) {} 372 const FenceSyncReleaseCallback& callback) {
373 fence_sync_release_callback_ = callback;
374 }
298 375
299 void GLES2DecoderPassthroughImpl::SetWaitFenceSyncCallback( 376 void GLES2DecoderPassthroughImpl::SetWaitFenceSyncCallback(
300 const WaitFenceSyncCallback& callback) {} 377 const WaitFenceSyncCallback& callback) {
378 wait_fence_sync_callback_ = callback;
379 }
301 380
302 void GLES2DecoderPassthroughImpl::SetDescheduleUntilFinishedCallback( 381 void GLES2DecoderPassthroughImpl::SetDescheduleUntilFinishedCallback(
303 const NoParamCallback& callback) {} 382 const NoParamCallback& callback) {}
304 383
305 void GLES2DecoderPassthroughImpl::SetRescheduleAfterFinishedCallback( 384 void GLES2DecoderPassthroughImpl::SetRescheduleAfterFinishedCallback(
306 const NoParamCallback& callback) {} 385 const NoParamCallback& callback) {}
307 386
308 gpu::gles2::QueryManager* GLES2DecoderPassthroughImpl::GetQueryManager() { 387 gpu::gles2::QueryManager* GLES2DecoderPassthroughImpl::GetQueryManager() {
309 return nullptr; 388 return nullptr;
310 } 389 }
(...skipping 26 matching lines...) Expand all
337 416
338 bool GLES2DecoderPassthroughImpl::HasPollingWork() const { 417 bool GLES2DecoderPassthroughImpl::HasPollingWork() const {
339 return false; 418 return false;
340 } 419 }
341 420
342 void GLES2DecoderPassthroughImpl::PerformPollingWork() {} 421 void GLES2DecoderPassthroughImpl::PerformPollingWork() {}
343 422
344 bool GLES2DecoderPassthroughImpl::GetServiceTextureId( 423 bool GLES2DecoderPassthroughImpl::GetServiceTextureId(
345 uint32_t client_texture_id, 424 uint32_t client_texture_id,
346 uint32_t* service_texture_id) { 425 uint32_t* service_texture_id) {
347 return false; 426 return resources_->texture_id_map.GetServiceID(client_texture_id,
427 service_texture_id);
348 } 428 }
349 429
350 gpu::error::ContextLostReason 430 gpu::error::ContextLostReason
351 GLES2DecoderPassthroughImpl::GetContextLostReason() { 431 GLES2DecoderPassthroughImpl::GetContextLostReason() {
352 return error::kUnknown; 432 return error::kUnknown;
353 } 433 }
354 434
355 bool GLES2DecoderPassthroughImpl::ClearLevel(Texture* texture, 435 bool GLES2DecoderPassthroughImpl::ClearLevel(Texture* texture,
356 unsigned target, 436 unsigned target,
357 int level, 437 int level,
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 }, /* NOLINT */ 523 }, /* NOLINT */
444 524
445 const GLES2DecoderPassthroughImpl::CommandInfo 525 const GLES2DecoderPassthroughImpl::CommandInfo
446 GLES2DecoderPassthroughImpl::command_info[] = { 526 GLES2DecoderPassthroughImpl::command_info[] = {
447 GLES2_COMMAND_LIST(GLES2_CMD_OP)}; 527 GLES2_COMMAND_LIST(GLES2_CMD_OP)};
448 528
449 #undef GLES2_CMD_OP 529 #undef GLES2_CMD_OP
450 530
451 } // namespace gles2 531 } // namespace gles2
452 } // namespace gpu 532 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698