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 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
6 | 6 |
7 #include <stdio.h> | 7 #include <stdio.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <list> | 10 #include <list> |
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
535 static_cast<unsigned int>(-1); | 535 static_cast<unsigned int>(-1); |
536 | 536 |
537 bool GLES2Decoder::GetServiceTextureId(uint32 client_texture_id, | 537 bool GLES2Decoder::GetServiceTextureId(uint32 client_texture_id, |
538 uint32* service_texture_id) { | 538 uint32* service_texture_id) { |
539 return false; | 539 return false; |
540 } | 540 } |
541 | 541 |
542 GLES2Decoder::GLES2Decoder() | 542 GLES2Decoder::GLES2Decoder() |
543 : initialized_(false), | 543 : initialized_(false), |
544 debug_(false), | 544 debug_(false), |
545 log_commands_(false) { | 545 log_commands_(false), |
| 546 unsafe_es3_apis_enabled_(false) { |
546 } | 547 } |
547 | 548 |
548 GLES2Decoder::~GLES2Decoder() { | 549 GLES2Decoder::~GLES2Decoder() { |
549 } | 550 } |
550 | 551 |
551 void GLES2Decoder::BeginDecoding() {} | 552 void GLES2Decoder::BeginDecoding() {} |
552 | 553 |
553 void GLES2Decoder::EndDecoding() {} | 554 void GLES2Decoder::EndDecoding() {} |
554 | 555 |
555 // This class implements GLES2Decoder so we don't have to expose all the GLES2 | 556 // This class implements GLES2Decoder so we don't have to expose all the GLES2 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
622 void RestoreTextureState(unsigned service_id) const override; | 623 void RestoreTextureState(unsigned service_id) const override; |
623 | 624 |
624 void ClearAllAttributes() const override; | 625 void ClearAllAttributes() const override; |
625 void RestoreAllAttributes() const override; | 626 void RestoreAllAttributes() const override; |
626 | 627 |
627 QueryManager* GetQueryManager() override { return query_manager_.get(); } | 628 QueryManager* GetQueryManager() override { return query_manager_.get(); } |
628 VertexArrayManager* GetVertexArrayManager() override { | 629 VertexArrayManager* GetVertexArrayManager() override { |
629 return vertex_array_manager_.get(); | 630 return vertex_array_manager_.get(); |
630 } | 631 } |
631 ImageManager* GetImageManager() override { return image_manager_.get(); } | 632 ImageManager* GetImageManager() override { return image_manager_.get(); } |
| 633 |
| 634 ValuebufferManager* GetValuebufferManager() override { |
| 635 return valuebuffer_manager(); |
| 636 } |
| 637 |
632 bool ProcessPendingQueries(bool did_finish) override; | 638 bool ProcessPendingQueries(bool did_finish) override; |
| 639 |
633 bool HasMoreIdleWork() override; | 640 bool HasMoreIdleWork() override; |
634 void PerformIdleWork() override; | 641 void PerformIdleWork() override; |
635 | 642 |
636 void WaitForReadPixels(base::Closure callback) override; | 643 void WaitForReadPixels(base::Closure callback) override; |
637 | 644 |
638 void SetResizeCallback( | 645 void SetResizeCallback( |
639 const base::Callback<void(gfx::Size, float)>& callback) override; | 646 const base::Callback<void(gfx::Size, float)>& callback) override; |
640 | 647 |
641 Logger* GetLogger() override; | 648 Logger* GetLogger() override; |
642 | 649 |
(...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1359 // Wrapper for glFramebufferTexture2DMultisampleEXT. | 1366 // Wrapper for glFramebufferTexture2DMultisampleEXT. |
1360 void DoFramebufferTexture2DMultisample( | 1367 void DoFramebufferTexture2DMultisample( |
1361 GLenum target, GLenum attachment, GLenum textarget, | 1368 GLenum target, GLenum attachment, GLenum textarget, |
1362 GLuint texture, GLint level, GLsizei samples); | 1369 GLuint texture, GLint level, GLsizei samples); |
1363 | 1370 |
1364 // Common implementation for both DoFramebufferTexture2D wrappers. | 1371 // Common implementation for both DoFramebufferTexture2D wrappers. |
1365 void DoFramebufferTexture2DCommon(const char* name, | 1372 void DoFramebufferTexture2DCommon(const char* name, |
1366 GLenum target, GLenum attachment, GLenum textarget, | 1373 GLenum target, GLenum attachment, GLenum textarget, |
1367 GLuint texture, GLint level, GLsizei samples); | 1374 GLuint texture, GLint level, GLsizei samples); |
1368 | 1375 |
| 1376 // Wrapper for glFramebufferTextureLayer. |
| 1377 void DoFramebufferTextureLayer( |
| 1378 GLenum target, GLenum attachment, GLuint texture, GLint level, |
| 1379 GLint layer); |
| 1380 |
1369 // Wrapper for glGenerateMipmap | 1381 // Wrapper for glGenerateMipmap |
1370 void DoGenerateMipmap(GLenum target); | 1382 void DoGenerateMipmap(GLenum target); |
1371 | 1383 |
1372 // Helper for DoGetBooleanv, Floatv, and Intergerv to adjust pname | 1384 // Helper for DoGetBooleanv, Floatv, and Intergerv to adjust pname |
1373 // to account for different pname values defined in different extension | 1385 // to account for different pname values defined in different extension |
1374 // variants. | 1386 // variants. |
1375 GLenum AdjustGetPname(GLenum pname); | 1387 GLenum AdjustGetPname(GLenum pname); |
1376 | 1388 |
1377 // Wrapper for DoGetBooleanv. | 1389 // Wrapper for DoGetBooleanv. |
1378 void DoGetBooleanv(GLenum pname, GLboolean* params); | 1390 void DoGetBooleanv(GLenum pname, GLboolean* params); |
(...skipping 1041 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2420 if (CommandLine::ForCurrentProcess()->HasSwitch( | 2432 if (CommandLine::ForCurrentProcess()->HasSwitch( |
2421 switches::kEnableGPUDebugging)) { | 2433 switches::kEnableGPUDebugging)) { |
2422 set_debug(true); | 2434 set_debug(true); |
2423 } | 2435 } |
2424 | 2436 |
2425 if (CommandLine::ForCurrentProcess()->HasSwitch( | 2437 if (CommandLine::ForCurrentProcess()->HasSwitch( |
2426 switches::kEnableGPUCommandLogging)) { | 2438 switches::kEnableGPUCommandLogging)) { |
2427 set_log_commands(true); | 2439 set_log_commands(true); |
2428 } | 2440 } |
2429 | 2441 |
| 2442 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 2443 switches::kEnableUnsafeES3APIs)) { |
| 2444 set_unsafe_es3_apis_enabled(true); |
| 2445 } |
| 2446 |
2430 compile_shader_always_succeeds_ = CommandLine::ForCurrentProcess()->HasSwitch( | 2447 compile_shader_always_succeeds_ = CommandLine::ForCurrentProcess()->HasSwitch( |
2431 switches::kCompileShaderAlwaysSucceeds); | 2448 switches::kCompileShaderAlwaysSucceeds); |
2432 | 2449 |
2433 | |
2434 // Take ownership of the context and surface. The surface can be replaced with | 2450 // Take ownership of the context and surface. The surface can be replaced with |
2435 // SetSurface. | 2451 // SetSurface. |
2436 context_ = context; | 2452 context_ = context; |
2437 surface_ = surface; | 2453 surface_ = surface; |
2438 | 2454 |
2439 ContextCreationAttribHelper attrib_parser; | 2455 ContextCreationAttribHelper attrib_parser; |
2440 if (!attrib_parser.Parse(attribs)) | 2456 if (!attrib_parser.Parse(attribs)) |
2441 return false; | 2457 return false; |
2442 | 2458 |
2443 // Save the loseContextWhenOutOfMemory context creation attribute. | 2459 // Save the loseContextWhenOutOfMemory context creation attribute. |
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2832 caps.iosurface = true; | 2848 caps.iosurface = true; |
2833 #endif | 2849 #endif |
2834 | 2850 |
2835 caps.post_sub_buffer = supports_post_sub_buffer_; | 2851 caps.post_sub_buffer = supports_post_sub_buffer_; |
2836 caps.image = true; | 2852 caps.image = true; |
2837 | 2853 |
2838 caps.blend_equation_advanced = | 2854 caps.blend_equation_advanced = |
2839 feature_info_->feature_flags().blend_equation_advanced; | 2855 feature_info_->feature_flags().blend_equation_advanced; |
2840 caps.blend_equation_advanced_coherent = | 2856 caps.blend_equation_advanced_coherent = |
2841 feature_info_->feature_flags().blend_equation_advanced_coherent; | 2857 feature_info_->feature_flags().blend_equation_advanced_coherent; |
| 2858 caps.texture_rg = feature_info_->feature_flags().ext_texture_rg; |
2842 return caps; | 2859 return caps; |
2843 } | 2860 } |
2844 | 2861 |
2845 void GLES2DecoderImpl::UpdateCapabilities() { | 2862 void GLES2DecoderImpl::UpdateCapabilities() { |
2846 util_.set_num_compressed_texture_formats( | 2863 util_.set_num_compressed_texture_formats( |
2847 validators_->compressed_texture_format.GetValues().size()); | 2864 validators_->compressed_texture_format.GetValues().size()); |
2848 util_.set_num_shader_binary_formats( | 2865 util_.set_num_shader_binary_formats( |
2849 validators_->shader_binary_format.GetValues().size()); | 2866 validators_->shader_binary_format.GetValues().size()); |
2850 } | 2867 } |
2851 | 2868 |
(...skipping 2505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5357 if (framebuffer == framebuffer_state_.bound_draw_framebuffer.get()) { | 5374 if (framebuffer == framebuffer_state_.bound_draw_framebuffer.get()) { |
5358 framebuffer_state_.clear_state_dirty = true; | 5375 framebuffer_state_.clear_state_dirty = true; |
5359 } | 5376 } |
5360 | 5377 |
5361 if (texture_ref) | 5378 if (texture_ref) |
5362 DoDidUseTexImageIfNeeded(texture_ref->texture(), textarget); | 5379 DoDidUseTexImageIfNeeded(texture_ref->texture(), textarget); |
5363 | 5380 |
5364 OnFboChanged(); | 5381 OnFboChanged(); |
5365 } | 5382 } |
5366 | 5383 |
| 5384 void GLES2DecoderImpl::DoFramebufferTextureLayer( |
| 5385 GLenum target, GLenum attachment, GLuint client_texture_id, |
| 5386 GLint level, GLint layer) { |
| 5387 // TODO(zmo): Unsafe ES3 API, missing states update. |
| 5388 GLuint service_id = 0; |
| 5389 TextureRef* texture_ref = NULL; |
| 5390 if (client_texture_id) { |
| 5391 texture_ref = GetTexture(client_texture_id); |
| 5392 if (!texture_ref) { |
| 5393 LOCAL_SET_GL_ERROR( |
| 5394 GL_INVALID_OPERATION, |
| 5395 "glFramebufferTextureLayer", "unknown texture_ref"); |
| 5396 return; |
| 5397 } |
| 5398 service_id = texture_ref->service_id(); |
| 5399 } |
| 5400 glFramebufferTextureLayer(target, attachment, service_id, level, layer); |
| 5401 } |
| 5402 |
5367 void GLES2DecoderImpl::DoGetFramebufferAttachmentParameteriv( | 5403 void GLES2DecoderImpl::DoGetFramebufferAttachmentParameteriv( |
5368 GLenum target, GLenum attachment, GLenum pname, GLint* params) { | 5404 GLenum target, GLenum attachment, GLenum pname, GLint* params) { |
5369 Framebuffer* framebuffer = GetFramebufferInfoForTarget(target); | 5405 Framebuffer* framebuffer = GetFramebufferInfoForTarget(target); |
5370 if (!framebuffer) { | 5406 if (!framebuffer) { |
5371 LOCAL_SET_GL_ERROR( | 5407 LOCAL_SET_GL_ERROR( |
5372 GL_INVALID_OPERATION, | 5408 GL_INVALID_OPERATION, |
5373 "glGetFramebufferAttachmentParameteriv", "no framebuffer bound"); | 5409 "glGetFramebufferAttachmentParameteriv", "no framebuffer bound"); |
5374 return; | 5410 return; |
5375 } | 5411 } |
5376 if (pname == GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME) { | 5412 if (pname == GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME) { |
(...skipping 2031 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7408 glVertexAttrib3fv(index, v); | 7444 glVertexAttrib3fv(index, v); |
7409 } | 7445 } |
7410 } | 7446 } |
7411 | 7447 |
7412 void GLES2DecoderImpl::DoVertexAttrib4fv(GLuint index, const GLfloat* v) { | 7448 void GLES2DecoderImpl::DoVertexAttrib4fv(GLuint index, const GLfloat* v) { |
7413 if (SetVertexAttribValue("glVertexAttrib4fv", index, v)) { | 7449 if (SetVertexAttribValue("glVertexAttrib4fv", index, v)) { |
7414 glVertexAttrib4fv(index, v); | 7450 glVertexAttrib4fv(index, v); |
7415 } | 7451 } |
7416 } | 7452 } |
7417 | 7453 |
| 7454 error::Error GLES2DecoderImpl::HandleVertexAttribIPointer( |
| 7455 uint32 immediate_data_size, |
| 7456 const void* cmd_data) { |
| 7457 // TODO(zmo): Unsafe ES3 API, missing states update. |
| 7458 if (!unsafe_es3_apis_enabled()) |
| 7459 return error::kUnknownCommand; |
| 7460 const gles2::cmds::VertexAttribIPointer& c = |
| 7461 *static_cast<const gles2::cmds::VertexAttribIPointer*>(cmd_data); |
| 7462 GLuint indx = c.indx; |
| 7463 GLint size = c.size; |
| 7464 GLenum type = c.type; |
| 7465 GLsizei stride = c.stride; |
| 7466 GLsizei offset = c.offset; |
| 7467 const void* ptr = reinterpret_cast<const void*>(offset); |
| 7468 glVertexAttribIPointer(indx, size, type, stride, ptr); |
| 7469 return error::kNoError; |
| 7470 } |
| 7471 |
7418 error::Error GLES2DecoderImpl::HandleVertexAttribPointer( | 7472 error::Error GLES2DecoderImpl::HandleVertexAttribPointer( |
7419 uint32 immediate_data_size, | 7473 uint32 immediate_data_size, |
7420 const void* cmd_data) { | 7474 const void* cmd_data) { |
7421 const gles2::cmds::VertexAttribPointer& c = | 7475 const gles2::cmds::VertexAttribPointer& c = |
7422 *static_cast<const gles2::cmds::VertexAttribPointer*>(cmd_data); | 7476 *static_cast<const gles2::cmds::VertexAttribPointer*>(cmd_data); |
7423 | 7477 |
7424 if (!state_.bound_array_buffer.get() || | 7478 if (!state_.bound_array_buffer.get() || |
7425 state_.bound_array_buffer->IsDeleted()) { | 7479 state_.bound_array_buffer->IsDeleted()) { |
7426 if (state_.vertex_attrib_manager.get() == | 7480 if (state_.vertex_attrib_manager.get() == |
7427 state_.default_vertex_attrib_manager.get()) { | 7481 state_.default_vertex_attrib_manager.get()) { |
(...skipping 4014 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11442 } | 11496 } |
11443 } | 11497 } |
11444 | 11498 |
11445 // Include the auto-generated part of this file. We split this because it means | 11499 // Include the auto-generated part of this file. We split this because it means |
11446 // we can easily edit the non-auto generated parts right here in this file | 11500 // we can easily edit the non-auto generated parts right here in this file |
11447 // instead of having to edit some template or the code generator. | 11501 // instead of having to edit some template or the code generator. |
11448 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 11502 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
11449 | 11503 |
11450 } // namespace gles2 | 11504 } // namespace gles2 |
11451 } // namespace gpu | 11505 } // namespace gpu |
OLD | NEW |