Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 // A class to emulate GLES2 over command buffers. | 5 // A class to emulate GLES2 over command buffers. |
| 6 | 6 |
| 7 #include "../client/gles2_implementation.h" | 7 #include "../client/gles2_implementation.h" |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <map> | 10 #include <map> |
| 11 #include <queue> | 11 #include <queue> |
| 12 #include <set> | 12 #include <set> |
| 13 #include <limits> | 13 #include <limits> |
| 14 #include <stdio.h> | 14 #include <stdio.h> |
| 15 #include <string.h> | 15 #include <string.h> |
| 16 #include <GLES2/gl2ext.h> | 16 #include <GLES2/gl2ext.h> |
| 17 #include <GLES2/gl2extchromium.h> | 17 #include <GLES2/gl2extchromium.h> |
| 18 #include "../client/buffer_tracker.h" | 18 #include "../client/buffer_tracker.h" |
| 19 #include "../client/gpu_memory_buffer.h" | |
| 20 #include "../client/gpu_memory_buffer_factory.h" | |
| 19 #include "../client/mapped_memory.h" | 21 #include "../client/mapped_memory.h" |
| 20 #include "../client/program_info_manager.h" | 22 #include "../client/program_info_manager.h" |
| 21 #include "../client/query_tracker.h" | 23 #include "../client/query_tracker.h" |
| 22 #include "../client/transfer_buffer.h" | 24 #include "../client/transfer_buffer.h" |
| 23 #include "../client/vertex_array_object_manager.h" | 25 #include "../client/vertex_array_object_manager.h" |
| 24 #include "../common/gles2_cmd_utils.h" | 26 #include "../common/gles2_cmd_utils.h" |
| 25 #include "../common/trace_event.h" | 27 #include "../common/trace_event.h" |
| 26 | 28 |
| 27 #if defined(__native_client__) && !defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS) | 29 #if defined(__native_client__) && !defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS) |
| 28 #define GLES2_SUPPORT_CLIENT_SIDE_ARRAYS | 30 #define GLES2_SUPPORT_CLIENT_SIDE_ARRAYS |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 91 unpack_skip_pixels_(0), | 93 unpack_skip_pixels_(0), |
| 92 pack_reverse_row_order_(false), | 94 pack_reverse_row_order_(false), |
| 93 active_texture_unit_(0), | 95 active_texture_unit_(0), |
| 94 bound_framebuffer_(0), | 96 bound_framebuffer_(0), |
| 95 bound_read_framebuffer_(0), | 97 bound_read_framebuffer_(0), |
| 96 bound_renderbuffer_(0), | 98 bound_renderbuffer_(0), |
| 97 current_program_(0), | 99 current_program_(0), |
| 98 bound_array_buffer_id_(0), | 100 bound_array_buffer_id_(0), |
| 99 bound_pixel_pack_transfer_buffer_id_(0), | 101 bound_pixel_pack_transfer_buffer_id_(0), |
| 100 bound_pixel_unpack_transfer_buffer_id_(0), | 102 bound_pixel_unpack_transfer_buffer_id_(0), |
| 103 bound_gpu_memory_buffer_id_(0), | |
| 101 error_bits_(0), | 104 error_bits_(0), |
| 102 debug_(false), | 105 debug_(false), |
| 103 use_count_(0), | 106 use_count_(0), |
| 104 current_query_(NULL), | 107 current_query_(NULL), |
| 105 error_message_callback_(NULL) { | 108 error_message_callback_(NULL) { |
| 106 GPU_DCHECK(helper); | 109 GPU_DCHECK(helper); |
| 107 GPU_DCHECK(transfer_buffer); | 110 GPU_DCHECK(transfer_buffer); |
| 108 | 111 |
| 109 char temp[128]; | 112 char temp[128]; |
| 110 sprintf(temp, "%p", static_cast<void*>(this)); | 113 sprintf(temp, "%p", static_cast<void*>(this)); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 166 static_state_.int_state.num_compressed_texture_formats); | 169 static_state_.int_state.num_compressed_texture_formats); |
| 167 util_.set_num_shader_binary_formats( | 170 util_.set_num_shader_binary_formats( |
| 168 static_state_.int_state.num_shader_binary_formats); | 171 static_state_.int_state.num_shader_binary_formats); |
| 169 | 172 |
| 170 texture_units_.reset( | 173 texture_units_.reset( |
| 171 new TextureUnit[ | 174 new TextureUnit[ |
| 172 static_state_.int_state.max_combined_texture_image_units]); | 175 static_state_.int_state.max_combined_texture_image_units]); |
| 173 | 176 |
| 174 query_tracker_.reset(new QueryTracker(mapped_memory_.get())); | 177 query_tracker_.reset(new QueryTracker(mapped_memory_.get())); |
| 175 buffer_tracker_.reset(new BufferTracker(mapped_memory_.get())); | 178 buffer_tracker_.reset(new BufferTracker(mapped_memory_.get())); |
| 179 gpu_memory_buffer_tracker_.reset(new GpuMemoryBufferTracker()); | |
| 176 | 180 |
| 177 #if defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS) | 181 #if defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS) |
| 178 GetIdHandler(id_namespaces::kBuffers)->MakeIds( | 182 GetIdHandler(id_namespaces::kBuffers)->MakeIds( |
| 179 this, kClientSideArrayId, arraysize(reserved_ids_), &reserved_ids_[0]); | 183 this, kClientSideArrayId, arraysize(reserved_ids_), &reserved_ids_[0]); |
| 180 #endif | 184 #endif |
| 181 | 185 |
| 182 vertex_array_object_manager_.reset(new VertexArrayObjectManager( | 186 vertex_array_object_manager_.reset(new VertexArrayObjectManager( |
| 183 static_state_.int_state.max_vertex_attribs, | 187 static_state_.int_state.max_vertex_attribs, |
| 184 reserved_ids_[0], | 188 reserved_ids_[0], |
| 185 reserved_ids_[1])); | 189 reserved_ids_[1])); |
| (...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 623 *params = bound_read_framebuffer_; | 627 *params = bound_read_framebuffer_; |
| 624 return true; | 628 return true; |
| 625 } | 629 } |
| 626 return false; | 630 return false; |
| 627 case GL_RENDERBUFFER_BINDING: | 631 case GL_RENDERBUFFER_BINDING: |
| 628 if (share_group_->bind_generates_resource()) { | 632 if (share_group_->bind_generates_resource()) { |
| 629 *params = bound_renderbuffer_; | 633 *params = bound_renderbuffer_; |
| 630 return true; | 634 return true; |
| 631 } | 635 } |
| 632 return false; | 636 return false; |
| 637 case GL_BOUND_GPU_MEMORY_BUFFER_CHROMIUM: | |
|
greggman
2013/04/25 23:45:34
Seems like following the other ENUMs this should b
kaanb1
2013/04/26 03:01:21
Done.
| |
| 638 *params = bound_gpu_memory_buffer_id_; | |
| 639 return true; | |
| 633 default: | 640 default: |
| 634 return false; | 641 return false; |
| 635 } | 642 } |
| 636 } | 643 } |
| 637 | 644 |
| 638 bool GLES2Implementation::GetBooleanvHelper(GLenum pname, GLboolean* params) { | 645 bool GLES2Implementation::GetBooleanvHelper(GLenum pname, GLboolean* params) { |
| 639 // TODO(gman): Make this handle pnames that return more than 1 value. | 646 // TODO(gman): Make this handle pnames that return more than 1 value. |
| 640 GLint value; | 647 GLint value; |
| 641 if (!GetHelper(pname, &value)) { | 648 if (!GetHelper(pname, &value)) { |
| 642 return false; | 649 return false; |
| (...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1238 } | 1245 } |
| 1239 } | 1246 } |
| 1240 | 1247 |
| 1241 GPU_DCHECK_EQ(total_size, offset); | 1248 GPU_DCHECK_EQ(total_size, offset); |
| 1242 | 1249 |
| 1243 helper_->ShaderSourceBucket(shader, kResultBucketId); | 1250 helper_->ShaderSourceBucket(shader, kResultBucketId); |
| 1244 helper_->SetBucketSize(kResultBucketId, 0); | 1251 helper_->SetBucketSize(kResultBucketId, 0); |
| 1245 CheckGLError(); | 1252 CheckGLError(); |
| 1246 } | 1253 } |
| 1247 | 1254 |
| 1255 bool GLES2Implementation::GetBoundGpuMemoryBuffer( | |
|
greggman
2013/04/25 23:45:34
This function always returns true. Did you mean it
kaanb1
2013/04/26 03:01:21
GetBoundPixelTransferBuffer only returns false whe
| |
| 1256 const char* function_name, GLuint* buffer_id) { | |
| 1257 *buffer_id = bound_gpu_memory_buffer_id_; | |
| 1258 | |
| 1259 if (*buffer_id == 0) { | |
| 1260 SetGLError(GL_INVALID_OPERATION, function_name, "no buffer bound"); | |
| 1261 } | |
| 1262 | |
| 1263 return true; | |
| 1264 } | |
| 1265 | |
| 1248 void GLES2Implementation::BufferDataHelper( | 1266 void GLES2Implementation::BufferDataHelper( |
| 1249 GLenum target, GLsizeiptr size, const void* data, GLenum usage) { | 1267 GLenum target, GLsizeiptr size, const void* data, GLenum usage) { |
| 1250 if (size < 0) { | 1268 if (size < 0) { |
| 1251 SetGLError(GL_INVALID_VALUE, "glBufferData", "size < 0"); | 1269 SetGLError(GL_INVALID_VALUE, "glBufferData", "size < 0"); |
| 1252 return; | 1270 return; |
| 1253 } | 1271 } |
| 1254 | 1272 |
| 1255 GLuint buffer_id; | 1273 GLuint buffer_id; |
| 1256 if (GetBoundPixelTransferBuffer(target, "glBufferData", &buffer_id)) { | 1274 if (GetBoundPixelTransferBuffer(target, "glBufferData", &buffer_id)) { |
| 1257 if (!buffer_id) { | 1275 if (!buffer_id) { |
| (...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2010 precision[0] = result->precision; | 2028 precision[0] = result->precision; |
| 2011 GPU_CLIENT_LOG(" min_range: " << precision[0]); | 2029 GPU_CLIENT_LOG(" min_range: " << precision[0]); |
| 2012 } | 2030 } |
| 2013 } | 2031 } |
| 2014 CheckGLError(); | 2032 CheckGLError(); |
| 2015 } | 2033 } |
| 2016 | 2034 |
| 2017 const GLubyte* GLES2Implementation::GetStringHelper(GLenum name) { | 2035 const GLubyte* GLES2Implementation::GetStringHelper(GLenum name) { |
| 2018 const char* result = NULL; | 2036 const char* result = NULL; |
| 2019 // Clears the bucket so if the command fails nothing will be in it. | 2037 // Clears the bucket so if the command fails nothing will be in it. |
| 2038 if (name == GL_BOUND_GPU_MEMORY_BUFFER_CHROMIUM_POINTER) { | |
|
greggman
2013/04/25 23:45:34
Doesn't this seem like a kind of abuse of this fun
kaanb1
2013/04/26 03:01:21
Done.
| |
| 2039 return const_cast<const GLubyte*>(static_cast<GLubyte*>( | |
| 2040 GetNativeHandleForBoundGpuMemoryBuffer())); | |
|
jamesr
2013/04/25 23:24:15
this really seems like voodoo. are there no better
apatrick_chromium
2013/04/25 23:39:03
Agreed. I had a "wat?" moment.
kaanb1
2013/04/25 23:42:19
Would you be okay if I added a new public API that
no sievers
2013/04/26 00:17:43
You don't need a full-fledged GL API. This is only
kaanb1
2013/04/26 03:01:21
Looks like the test doesn't build when I just expo
| |
| 2041 } | |
| 2042 | |
| 2020 helper_->SetBucketSize(kResultBucketId, 0); | 2043 helper_->SetBucketSize(kResultBucketId, 0); |
| 2021 helper_->GetString(name, kResultBucketId); | 2044 helper_->GetString(name, kResultBucketId); |
| 2022 std::string str; | 2045 std::string str; |
| 2023 if (GetBucketAsString(kResultBucketId, &str)) { | 2046 if (GetBucketAsString(kResultBucketId, &str)) { |
| 2024 // Adds extensions implemented on client side only. | 2047 // Adds extensions implemented on client side only. |
| 2025 switch (name) { | 2048 switch (name) { |
| 2026 case GL_EXTENSIONS: | 2049 case GL_EXTENSIONS: |
| 2027 str += std::string(str.empty() ? "" : " ") + | 2050 str += std::string(str.empty() ? "" : " ") + |
| 2028 "GL_CHROMIUM_flipy " | 2051 "GL_CHROMIUM_flipy " |
| 2029 "GL_CHROMIUM_map_sub " | 2052 "GL_CHROMIUM_map_sub " |
|
greggman
2013/04/25 23:45:34
You should probably add a string here based on whi
kaanb1
2013/04/26 03:01:21
Done.
| |
| 2030 "GL_CHROMIUM_shallow_flush " | 2053 "GL_CHROMIUM_shallow_flush " |
| 2031 "GL_EXT_unpack_subimage"; | 2054 "GL_EXT_unpack_subimage"; |
| 2032 break; | 2055 break; |
| 2033 default: | 2056 default: |
| 2034 break; | 2057 break; |
| 2035 } | 2058 } |
| 2036 | 2059 |
| 2037 // Because of WebGL the extensions can change. We have to cache each unique | 2060 // Because of WebGL the extensions can change. We have to cache each unique |
| 2038 // result since we don't know when the client will stop referring to a | 2061 // result since we don't know when the client will stop referring to a |
| 2039 // previous one it queries. | 2062 // previous one it queries. |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2294 break; | 2317 break; |
| 2295 case GL_ELEMENT_ARRAY_BUFFER: | 2318 case GL_ELEMENT_ARRAY_BUFFER: |
| 2296 changed = vertex_array_object_manager_->BindElementArray(buffer); | 2319 changed = vertex_array_object_manager_->BindElementArray(buffer); |
| 2297 break; | 2320 break; |
| 2298 case GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM: | 2321 case GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM: |
| 2299 bound_pixel_pack_transfer_buffer_id_ = buffer; | 2322 bound_pixel_pack_transfer_buffer_id_ = buffer; |
| 2300 break; | 2323 break; |
| 2301 case GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM: | 2324 case GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM: |
| 2302 bound_pixel_unpack_transfer_buffer_id_ = buffer; | 2325 bound_pixel_unpack_transfer_buffer_id_ = buffer; |
| 2303 break; | 2326 break; |
| 2327 case GL_IMAGE_BUFFER_CHROMIUM: | |
| 2328 bound_gpu_memory_buffer_id_ = buffer; | |
| 2329 break; | |
| 2304 default: | 2330 default: |
| 2305 changed = true; | 2331 changed = true; |
| 2306 break; | 2332 break; |
| 2307 } | 2333 } |
| 2308 // TODO(gman): There's a bug here. If the target is invalid the ID will not be | 2334 // TODO(gman): There's a bug here. If the target is invalid the ID will not be |
| 2309 // used even though it's marked it as used here. | 2335 // used even though it's marked it as used here. |
| 2310 GetIdHandler(id_namespaces::kBuffers)->MarkAsUsedForBind(buffer); | 2336 GetIdHandler(id_namespaces::kBuffers)->MarkAsUsedForBind(buffer); |
| 2311 return changed; | 2337 return changed; |
| 2312 } | 2338 } |
| 2313 | 2339 |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2438 BufferTracker::Buffer* buffer = buffer_tracker_->GetBuffer(buffers[ii]); | 2464 BufferTracker::Buffer* buffer = buffer_tracker_->GetBuffer(buffers[ii]); |
| 2439 if (buffer) { | 2465 if (buffer) { |
| 2440 // Free buffer memory, pending the passage of a token. | 2466 // Free buffer memory, pending the passage of a token. |
| 2441 buffer_tracker_->FreePendingToken(buffer, helper_->InsertToken()); | 2467 buffer_tracker_->FreePendingToken(buffer, helper_->InsertToken()); |
| 2442 // Remove buffer. | 2468 // Remove buffer. |
| 2443 buffer_tracker_->RemoveBuffer(buffers[ii]); | 2469 buffer_tracker_->RemoveBuffer(buffers[ii]); |
| 2444 } | 2470 } |
| 2445 if (buffers[ii] == bound_pixel_unpack_transfer_buffer_id_) { | 2471 if (buffers[ii] == bound_pixel_unpack_transfer_buffer_id_) { |
| 2446 bound_pixel_unpack_transfer_buffer_id_ = 0; | 2472 bound_pixel_unpack_transfer_buffer_id_ = 0; |
| 2447 } | 2473 } |
| 2474 if (buffers[ii] == bound_gpu_memory_buffer_id_) { | |
| 2475 bound_gpu_memory_buffer_id_ = 0; | |
| 2476 } | |
| 2477 GpuMemoryBuffer* gpu_buffer = | |
| 2478 gpu_memory_buffer_tracker_->GetBuffer(buffers[ii]); | |
| 2479 if (gpu_buffer) { | |
| 2480 gpu_memory_buffer_tracker_->RemoveBuffer(buffers[ii]); | |
| 2481 } | |
| 2448 } | 2482 } |
| 2449 } | 2483 } |
| 2450 | 2484 |
| 2451 void GLES2Implementation::DeleteBuffersStub( | 2485 void GLES2Implementation::DeleteBuffersStub( |
| 2452 GLsizei n, const GLuint* buffers) { | 2486 GLsizei n, const GLuint* buffers) { |
| 2453 helper_->DeleteBuffersImmediate(n, buffers); | 2487 helper_->DeleteBuffersImmediate(n, buffers); |
| 2454 } | 2488 } |
| 2455 | 2489 |
| 2456 | 2490 |
| 2457 void GLES2Implementation::DeleteFramebuffersHelper( | 2491 void GLES2Implementation::DeleteFramebuffersHelper( |
| (...skipping 925 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3383 SetGLError(GL_INVALID_ENUM, "glMapBufferCHROMIUM", "bad access mode"); | 3417 SetGLError(GL_INVALID_ENUM, "glMapBufferCHROMIUM", "bad access mode"); |
| 3384 return NULL; | 3418 return NULL; |
| 3385 } | 3419 } |
| 3386 break; | 3420 break; |
| 3387 case GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM: | 3421 case GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM: |
| 3388 if (access != GL_WRITE_ONLY) { | 3422 if (access != GL_WRITE_ONLY) { |
| 3389 SetGLError(GL_INVALID_ENUM, "glMapBufferCHROMIUM", "bad access mode"); | 3423 SetGLError(GL_INVALID_ENUM, "glMapBufferCHROMIUM", "bad access mode"); |
| 3390 return NULL; | 3424 return NULL; |
| 3391 } | 3425 } |
| 3392 break; | 3426 break; |
| 3427 case GL_IMAGE_BUFFER_CHROMIUM: | |
| 3428 break; | |
| 3393 default: | 3429 default: |
| 3394 SetGLError( | 3430 SetGLError( |
| 3395 GL_INVALID_ENUM, "glMapBufferCHROMIUM", "invalid target"); | 3431 GL_INVALID_ENUM, "glMapBufferCHROMIUM", "invalid target"); |
| 3396 return NULL; | 3432 return NULL; |
| 3397 } | 3433 } |
| 3434 | |
| 3398 GLuint buffer_id; | 3435 GLuint buffer_id; |
| 3436 if (target == GL_IMAGE_BUFFER_CHROMIUM && | |
| 3437 GetBoundGpuMemoryBuffer("glMapBufferCHROMIUM", &buffer_id)) { | |
|
greggman
2013/04/25 23:45:34
If GetBoundGPUMemoryBuffer returns false (assuming
kaanb1
2013/04/26 03:01:21
Converted this function to use a switch statement.
| |
| 3438 if (buffer_id == 0) { | |
| 3439 return NULL; | |
| 3440 } | |
| 3441 | |
| 3442 GpuMemoryBuffer* gpu_buffer = | |
| 3443 gpu_memory_buffer_tracker_->GetBuffer(buffer_id); | |
| 3444 if (!gpu_buffer) { | |
| 3445 SetGLError(GL_INVALID_OPERATION, | |
| 3446 "glMapBufferCHROMIUM", | |
| 3447 "invalid GPU memory buffer"); | |
| 3448 return NULL; | |
| 3449 } | |
| 3450 GpuMemoryBuffer::AccessMode mode = GpuMemoryBuffer::READ_ONLY; | |
| 3451 switch (access) { | |
| 3452 case GL_WRITE_ONLY: | |
| 3453 mode = GpuMemoryBuffer::WRITE_ONLY; | |
| 3454 break; | |
| 3455 case GL_READ_ONLY: | |
| 3456 mode = GpuMemoryBuffer::READ_ONLY; | |
| 3457 break; | |
| 3458 // TODO(kaanb): should we add GL_READ_WRITE to gl2ext.h? | |
| 3459 default: | |
| 3460 SetGLError( | |
| 3461 GL_INVALID_ENUM, "glMapBufferCHROMIUM", "invalid GPU access mode"); | |
| 3462 return NULL; | |
| 3463 } | |
| 3464 | |
| 3465 void* mapped_buffer = NULL; | |
| 3466 gpu_buffer->Map(mode, &mapped_buffer); | |
|
greggman
2013/04/25 23:45:34
The semantics of map buffer require that you can o
kaanb1
2013/04/26 03:01:21
Done.
| |
| 3467 CheckGLError(); | |
| 3468 return mapped_buffer; | |
| 3469 } | |
| 3470 | |
| 3399 GetBoundPixelTransferBuffer(target, "glMapBufferCHROMIUM", &buffer_id); | 3471 GetBoundPixelTransferBuffer(target, "glMapBufferCHROMIUM", &buffer_id); |
| 3400 if (!buffer_id) { | 3472 if (!buffer_id) { |
| 3401 return NULL; | 3473 return NULL; |
| 3402 } | 3474 } |
| 3403 BufferTracker::Buffer* buffer = buffer_tracker_->GetBuffer(buffer_id); | 3475 BufferTracker::Buffer* buffer = buffer_tracker_->GetBuffer(buffer_id); |
| 3404 if (!buffer) { | 3476 if (!buffer) { |
| 3405 SetGLError(GL_INVALID_OPERATION, "glMapBufferCHROMIUM", "invalid buffer"); | 3477 SetGLError(GL_INVALID_OPERATION, "glMapBufferCHROMIUM", "invalid buffer"); |
| 3406 return NULL; | 3478 return NULL; |
| 3407 } | 3479 } |
| 3408 if (buffer->mapped()) { | 3480 if (buffer->mapped()) { |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 3424 GPU_CLIENT_LOG(" returned " << buffer->address()); | 3496 GPU_CLIENT_LOG(" returned " << buffer->address()); |
| 3425 CheckGLError(); | 3497 CheckGLError(); |
| 3426 return buffer->address(); | 3498 return buffer->address(); |
| 3427 } | 3499 } |
| 3428 | 3500 |
| 3429 GLboolean GLES2Implementation::UnmapBufferCHROMIUM(GLuint target) { | 3501 GLboolean GLES2Implementation::UnmapBufferCHROMIUM(GLuint target) { |
| 3430 GPU_CLIENT_SINGLE_THREAD_CHECK(); | 3502 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
| 3431 GPU_CLIENT_LOG( | 3503 GPU_CLIENT_LOG( |
| 3432 "[" << GetLogPrefix() << "] glUnmapBufferCHROMIUM(" << target << ")"); | 3504 "[" << GetLogPrefix() << "] glUnmapBufferCHROMIUM(" << target << ")"); |
| 3433 GLuint buffer_id; | 3505 GLuint buffer_id; |
| 3506 if (target == GL_IMAGE_BUFFER_CHROMIUM && | |
| 3507 GetBoundGpuMemoryBuffer("glUnmapBufferCHROMIUM", &buffer_id)) { | |
|
greggman
2013/04/25 23:45:34
Same here. If GetBoundGpuMemroyBuffer returns fals
kaanb1
2013/04/26 03:01:21
Done.
| |
| 3508 if (buffer_id == 0) { | |
| 3509 return false; | |
| 3510 } | |
| 3511 | |
| 3512 GpuMemoryBuffer* gpu_buffer = | |
| 3513 gpu_memory_buffer_tracker_->GetBuffer(buffer_id); | |
| 3514 | |
| 3515 gpu_buffer->Unmap(); | |
|
greggman
2013/04/25 23:45:34
The semantics of map buffer require if the buffer
kaanb1
2013/04/26 03:01:21
Done.
| |
| 3516 return true; | |
| 3517 } | |
| 3518 | |
| 3434 if (!GetBoundPixelTransferBuffer(target, "glMapBufferCHROMIUM", &buffer_id)) { | 3519 if (!GetBoundPixelTransferBuffer(target, "glMapBufferCHROMIUM", &buffer_id)) { |
| 3435 SetGLError(GL_INVALID_ENUM, "glUnmapBufferCHROMIUM", "invalid target"); | 3520 SetGLError(GL_INVALID_ENUM, "glUnmapBufferCHROMIUM", "invalid target"); |
| 3436 } | 3521 } |
| 3437 if (!buffer_id) { | 3522 if (!buffer_id) { |
| 3438 return false; | 3523 return false; |
| 3439 } | 3524 } |
| 3440 BufferTracker::Buffer* buffer = buffer_tracker_->GetBuffer(buffer_id); | 3525 BufferTracker::Buffer* buffer = buffer_tracker_->GetBuffer(buffer_id); |
| 3441 if (!buffer) { | 3526 if (!buffer) { |
| 3442 SetGLError(GL_INVALID_OPERATION, "glMapBufferCHROMIUM", "invalid buffer"); | 3527 SetGLError(GL_INVALID_OPERATION, "glMapBufferCHROMIUM", "invalid buffer"); |
| 3443 return false; | 3528 return false; |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3556 helper_->WaitAsyncTexImage2DCHROMIUM(target); | 3641 helper_->WaitAsyncTexImage2DCHROMIUM(target); |
| 3557 CheckGLError(); | 3642 CheckGLError(); |
| 3558 } | 3643 } |
| 3559 | 3644 |
| 3560 GLuint GLES2Implementation::InsertSyncPointCHROMIUM() { | 3645 GLuint GLES2Implementation::InsertSyncPointCHROMIUM() { |
| 3561 GPU_CLIENT_SINGLE_THREAD_CHECK(); | 3646 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
| 3562 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glInsertSyncPointCHROMIUM"); | 3647 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glInsertSyncPointCHROMIUM"); |
| 3563 return helper_->InsertSyncPointCHROMIUM(); | 3648 return helper_->InsertSyncPointCHROMIUM(); |
| 3564 } | 3649 } |
| 3565 | 3650 |
| 3651 void* GLES2Implementation::GetNativeHandleForBoundGpuMemoryBuffer() { | |
| 3652 if (bound_gpu_memory_buffer_id_ == 0) { | |
| 3653 return NULL; | |
| 3654 } | |
| 3655 | |
| 3656 GpuMemoryBuffer* buffer = | |
| 3657 gpu_memory_buffer_tracker_->GetBuffer(bound_gpu_memory_buffer_id_); | |
| 3658 | |
| 3659 return (buffer != NULL) ? buffer->GetNativeBuffer() : NULL; | |
| 3660 } | |
| 3661 | |
| 3662 void GLES2Implementation::ImageBufferDataHelperCHROMIUM( | |
| 3663 GLenum target, GLsizei width, GLsizei height) { | |
| 3664 if (width < 0) { | |
| 3665 SetGLError(GL_INVALID_VALUE, "glImageBufferDataCHROMIUM", "width < 0"); | |
| 3666 return; | |
| 3667 } | |
| 3668 | |
| 3669 if (height < 0) { | |
| 3670 SetGLError(GL_INVALID_VALUE, "glImageBufferDataCHROMIUM", "height < 0"); | |
| 3671 return; | |
| 3672 } | |
| 3673 | |
| 3674 if (target != GL_IMAGE_BUFFER_CHROMIUM) { | |
| 3675 SetGLErrorInvalidEnum("glImageBufferDataCHROMIUM", target, "target"); | |
| 3676 return; | |
| 3677 } | |
| 3678 | |
| 3679 GLuint buffer_id; | |
| 3680 bool found_buffer = GetBoundGpuMemoryBuffer( | |
| 3681 "glImageBufferDataCHROMIUM", &buffer_id); | |
| 3682 | |
| 3683 if (!found_buffer || buffer_id == 0) { | |
| 3684 return; | |
| 3685 } | |
| 3686 | |
| 3687 GpuMemoryBuffer* buffer = | |
| 3688 gpu_memory_buffer_tracker_->GetBuffer(buffer_id); | |
| 3689 if (buffer) { | |
| 3690 // Remove old buffer, deletes the buffer pointer. | |
| 3691 gpu_memory_buffer_tracker_->RemoveBuffer(buffer_id); | |
| 3692 } | |
| 3693 | |
| 3694 if (width != 0 && height != 0) { | |
| 3695 // Create new buffer. | |
| 3696 buffer = gpu_memory_buffer_tracker_->CreateBuffer(buffer_id, width, height); | |
| 3697 GPU_DCHECK(buffer); | |
| 3698 } | |
| 3699 | |
| 3700 return; | |
| 3701 } | |
| 3702 | |
| 3703 void GLES2Implementation::ImageBufferDataCHROMIUM( | |
| 3704 GLenum target, GLsizei width, GLsizei height) { | |
| 3705 GPU_CLIENT_SINGLE_THREAD_CHECK(); | |
| 3706 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glImageBufferDataCHROMIUM(" | |
| 3707 << GLES2Util::GetStringBufferTarget(target) << ", " | |
| 3708 << width << ", " | |
| 3709 << height << ")"); | |
| 3710 ImageBufferDataHelperCHROMIUM(target, width, height); | |
| 3711 CheckGLError(); | |
| 3712 } | |
| 3713 | |
| 3714 | |
| 3566 // Include the auto-generated part of this file. We split this because it means | 3715 // Include the auto-generated part of this file. We split this because it means |
| 3567 // we can easily edit the non-auto generated parts right here in this file | 3716 // we can easily edit the non-auto generated parts right here in this file |
| 3568 // instead of having to edit some template or the code generator. | 3717 // instead of having to edit some template or the code generator. |
| 3569 #include "../client/gles2_implementation_impl_autogen.h" | 3718 #include "../client/gles2_implementation_impl_autogen.h" |
| 3570 | 3719 |
| 3571 } // namespace gles2 | 3720 } // namespace gles2 |
| 3572 } // namespace gpu | 3721 } // namespace gpu |
| OLD | NEW |