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 "gpu/command_buffer/client/gles2_implementation.h" | 7 #include "gpu/command_buffer/client/gles2_implementation.h" |
8 | 8 |
9 #include <GLES2/gl2ext.h> | 9 #include <GLES2/gl2ext.h> |
10 #include <GLES2/gl2extchromium.h> | 10 #include <GLES2/gl2extchromium.h> |
(...skipping 2303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2314 case GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM: | 2314 case GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM: |
2315 bound_pixel_unpack_transfer_buffer_id_ = buffer_id; | 2315 bound_pixel_unpack_transfer_buffer_id_ = buffer_id; |
2316 break; | 2316 break; |
2317 default: | 2317 default: |
2318 changed = true; | 2318 changed = true; |
2319 break; | 2319 break; |
2320 } | 2320 } |
2321 // TODO(gman): There's a bug here. If the target is invalid the ID will not be | 2321 // TODO(gman): There's a bug here. If the target is invalid the ID will not be |
2322 // used even though it's marked it as used here. | 2322 // used even though it's marked it as used here. |
2323 GetIdHandler(id_namespaces::kBuffers)->MarkAsUsedForBind(buffer_id); | 2323 GetIdHandler(id_namespaces::kBuffers)->MarkAsUsedForBind(buffer_id); |
2324 | |
2325 // In Pepper, BindBuffer() may need generate resource in GPU process, so we | |
2326 // have to flush command buffer to make the BindBuffer() being executed in | |
2327 // GPU process before any DeleteBuffer() which are issused in future from | |
2328 // other contexts. | |
2329 // TODO(penghuang): Get rid of the Flush(). | |
2330 if (changed && share_group_->bind_generates_resource()) | |
2331 helper_->CommandBufferHelper::Flush(); | |
2332 | |
2324 return changed; | 2333 return changed; |
2325 } | 2334 } |
2326 | 2335 |
2327 bool GLES2Implementation::BindFramebufferHelper( | 2336 bool GLES2Implementation::BindFramebufferHelper( |
2328 GLenum target, GLuint framebuffer) { | 2337 GLenum target, GLuint framebuffer) { |
2329 // TODO(gman): See note #1 above. | 2338 // TODO(gman): See note #1 above. |
2330 bool changed = false; | 2339 bool changed = false; |
2331 switch (target) { | 2340 switch (target) { |
2332 case GL_FRAMEBUFFER: | 2341 case GL_FRAMEBUFFER: |
2333 if (bound_framebuffer_ != framebuffer || | 2342 if (bound_framebuffer_ != framebuffer || |
(...skipping 20 matching lines...) Expand all Loading... | |
2354 } | 2363 } |
2355 if (bound_framebuffer_ != framebuffer) { | 2364 if (bound_framebuffer_ != framebuffer) { |
2356 bound_framebuffer_ = framebuffer; | 2365 bound_framebuffer_ = framebuffer; |
2357 changed = true; | 2366 changed = true; |
2358 } | 2367 } |
2359 break; | 2368 break; |
2360 default: | 2369 default: |
2361 SetGLErrorInvalidEnum("glBindFramebuffer", target, "target"); | 2370 SetGLErrorInvalidEnum("glBindFramebuffer", target, "target"); |
2362 return false; | 2371 return false; |
2363 } | 2372 } |
2373 | |
2364 GetIdHandler(id_namespaces::kFramebuffers)->MarkAsUsedForBind(framebuffer); | 2374 GetIdHandler(id_namespaces::kFramebuffers)->MarkAsUsedForBind(framebuffer); |
2375 | |
2376 // In Pepper, BindFramebuffer() may need generate resource in GPU process, | |
2377 // so we have to flush command buffer to make the BindFramebuffer() being | |
2378 // executed in GPU process before any DeleteFramebuffer() which are issused in | |
2379 // future from other contexts. | |
2380 // TODO(penghuang): Get rid of the Flush(). | |
2381 if (changed && share_group_->bind_generates_resource()) | |
2382 helper_->CommandBufferHelper::Flush(); | |
2383 | |
2365 return changed; | 2384 return changed; |
2366 } | 2385 } |
2367 | 2386 |
2368 bool GLES2Implementation::BindRenderbufferHelper( | 2387 bool GLES2Implementation::BindRenderbufferHelper( |
2369 GLenum target, GLuint renderbuffer) { | 2388 GLenum target, GLuint renderbuffer) { |
2370 // TODO(gman): See note #1 above. | 2389 // TODO(gman): See note #1 above. |
2371 bool changed = false; | 2390 bool changed = false; |
2372 switch (target) { | 2391 switch (target) { |
2373 case GL_RENDERBUFFER: | 2392 case GL_RENDERBUFFER: |
2374 if (bound_renderbuffer_ != renderbuffer) { | 2393 if (bound_renderbuffer_ != renderbuffer) { |
2375 bound_renderbuffer_ = renderbuffer; | 2394 bound_renderbuffer_ = renderbuffer; |
2376 changed = true; | 2395 changed = true; |
2377 } | 2396 } |
2378 break; | 2397 break; |
2379 default: | 2398 default: |
2380 changed = true; | 2399 changed = true; |
2381 break; | 2400 break; |
2382 } | 2401 } |
2383 // TODO(gman): There's a bug here. If the target is invalid the ID will not be | 2402 // TODO(gman): There's a bug here. If the target is invalid the ID will not be |
2384 // used even though it's marked it as used here. | 2403 // used even though it's marked it as used here. |
2385 GetIdHandler(id_namespaces::kRenderbuffers)->MarkAsUsedForBind(renderbuffer); | 2404 GetIdHandler(id_namespaces::kRenderbuffers)->MarkAsUsedForBind(renderbuffer); |
2405 | |
2406 // In Pepper, BindRenderbuffer() may need generate resource in GPU process, | |
2407 // so we have to flush command buffer to make the BindRenderbuffer() being | |
2408 // executed in GPU process before any DeleteRenderbuffer() which are issused | |
2409 // in future from other contexts. | |
2410 // TODO(penghuang): Get rid of the Flush(). | |
2411 if (changed && share_group_->bind_generates_resource()) | |
2412 helper_->CommandBufferHelper::Flush(); | |
2413 | |
2386 return changed; | 2414 return changed; |
2387 } | 2415 } |
2388 | 2416 |
2389 bool GLES2Implementation::BindTextureHelper(GLenum target, GLuint texture) { | 2417 bool GLES2Implementation::BindTextureHelper(GLenum target, GLuint texture) { |
2390 // TODO(gman): See note #1 above. | 2418 // TODO(gman): See note #1 above. |
2391 // TODO(gman): Change this to false once we figure out why it's failing | 2419 // TODO(gman): Change this to false once we figure out why it's failing |
2392 // on daisy. | 2420 // on daisy. |
2393 bool changed = true; | 2421 bool changed = true; |
2394 TextureUnit& unit = texture_units_[active_texture_unit_]; | 2422 TextureUnit& unit = texture_units_[active_texture_unit_]; |
2395 switch (target) { | 2423 switch (target) { |
(...skipping 15 matching lines...) Expand all Loading... | |
2411 changed = true; | 2439 changed = true; |
2412 } | 2440 } |
2413 break; | 2441 break; |
2414 default: | 2442 default: |
2415 changed = true; | 2443 changed = true; |
2416 break; | 2444 break; |
2417 } | 2445 } |
2418 // TODO(gman): There's a bug here. If the target is invalid the ID will not be | 2446 // TODO(gman): There's a bug here. If the target is invalid the ID will not be |
2419 // used. even though it's marked it as used here. | 2447 // used. even though it's marked it as used here. |
2420 GetIdHandler(id_namespaces::kTextures)->MarkAsUsedForBind(texture); | 2448 GetIdHandler(id_namespaces::kTextures)->MarkAsUsedForBind(texture); |
2449 | |
2450 // In Pepper, BindTexture() may need generate resource in GPU process, so we | |
2451 // have to flush command buffer to make the BindTexture() being executed in | |
2452 // GPU process before any DeleteTexture() which are issused in future from | |
2453 // other contexts. | |
2454 // TODO(penghuang): Get rid of the Flush(). | |
2455 if (changed && share_group_->bind_generates_resource()) | |
2456 helper_->CommandBufferHelper::Flush(); | |
piman
2014/12/01 21:41:53
This is racy, it needs to be done under the lock i
Peng
2014/12/02 19:32:36
For your mentioned case, it should be fine, unless
Peng
2014/12/04 17:45:01
Done. Flush() the command buffer under the lock in
| |
2457 | |
2421 return changed; | 2458 return changed; |
2422 } | 2459 } |
2423 | 2460 |
2424 bool GLES2Implementation::BindVertexArrayOESHelper(GLuint array) { | 2461 bool GLES2Implementation::BindVertexArrayOESHelper(GLuint array) { |
2425 // TODO(gman): See note #1 above. | 2462 // TODO(gman): See note #1 above. |
2426 bool changed = false; | 2463 bool changed = false; |
2427 if (!vertex_array_object_manager_->BindVertexArray(array, &changed)) { | 2464 if (!vertex_array_object_manager_->BindVertexArray(array, &changed)) { |
2428 SetGLError( | 2465 SetGLError( |
2429 GL_INVALID_OPERATION, "glBindVertexArrayOES", | 2466 GL_INVALID_OPERATION, "glBindVertexArrayOES", |
2430 "id was not generated with glGenVertexArrayOES"); | 2467 "id was not generated with glGenVertexArrayOES"); |
(...skipping 1474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3905 return true; | 3942 return true; |
3906 } | 3943 } |
3907 | 3944 |
3908 // Include the auto-generated part of this file. We split this because it means | 3945 // Include the auto-generated part of this file. We split this because it means |
3909 // we can easily edit the non-auto generated parts right here in this file | 3946 // we can easily edit the non-auto generated parts right here in this file |
3910 // instead of having to edit some template or the code generator. | 3947 // instead of having to edit some template or the code generator. |
3911 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h" | 3948 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h" |
3912 | 3949 |
3913 } // namespace gles2 | 3950 } // namespace gles2 |
3914 } // namespace gpu | 3951 } // namespace gpu |
OLD | NEW |