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 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
506 const scoped_refptr<gfx::GLSurface>& surface) OVERRIDE; | 506 const scoped_refptr<gfx::GLSurface>& surface) OVERRIDE; |
507 virtual bool SetParent(GLES2Decoder* parent_decoder, | 507 virtual bool SetParent(GLES2Decoder* parent_decoder, |
508 uint32 parent_texture_id) OVERRIDE; | 508 uint32 parent_texture_id) OVERRIDE; |
509 virtual bool ResizeOffscreenFrameBuffer(const gfx::Size& size) OVERRIDE; | 509 virtual bool ResizeOffscreenFrameBuffer(const gfx::Size& size) OVERRIDE; |
510 void UpdateParentTextureInfo(); | 510 void UpdateParentTextureInfo(); |
511 virtual bool MakeCurrent() OVERRIDE; | 511 virtual bool MakeCurrent() OVERRIDE; |
512 virtual void ReleaseCurrent() OVERRIDE; | 512 virtual void ReleaseCurrent() OVERRIDE; |
513 virtual GLES2Util* GetGLES2Util() OVERRIDE { return &util_; } | 513 virtual GLES2Util* GetGLES2Util() OVERRIDE { return &util_; } |
514 virtual gfx::GLContext* GetGLContext() OVERRIDE { return context_.get(); } | 514 virtual gfx::GLContext* GetGLContext() OVERRIDE { return context_.get(); } |
515 virtual ContextGroup* GetContextGroup() OVERRIDE { return group_.get(); } | 515 virtual ContextGroup* GetContextGroup() OVERRIDE { return group_.get(); } |
| 516 virtual void RestoreState() const OVERRIDE; |
516 virtual QueryManager* GetQueryManager() OVERRIDE { | 517 virtual QueryManager* GetQueryManager() OVERRIDE { |
517 return query_manager_.get(); | 518 return query_manager_.get(); |
518 } | 519 } |
519 virtual VertexArrayManager* GetVertexArrayManager() OVERRIDE { | 520 virtual VertexArrayManager* GetVertexArrayManager() OVERRIDE { |
520 return vertex_array_manager_.get(); | 521 return vertex_array_manager_.get(); |
521 } | 522 } |
522 virtual bool ProcessPendingQueries() OVERRIDE; | 523 virtual bool ProcessPendingQueries() OVERRIDE; |
523 | 524 |
524 virtual void SetGLError(GLenum error, | 525 virtual void SetGLError(GLenum error, |
525 const char* function_name, | 526 const char* function_name, |
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
960 | 961 |
961 // Gets the type of a uniform for a location in the current program. Sets GL | 962 // Gets the type of a uniform for a location in the current program. Sets GL |
962 // errors if the current program is not valid. Returns true if the current | 963 // errors if the current program is not valid. Returns true if the current |
963 // program is valid and the location exists. Adjusts count so it | 964 // program is valid and the location exists. Adjusts count so it |
964 // does not overflow the uniform. | 965 // does not overflow the uniform. |
965 bool PrepForSetUniformByLocation( | 966 bool PrepForSetUniformByLocation( |
966 GLint fake_location, const char* function_name, | 967 GLint fake_location, const char* function_name, |
967 GLint* real_location, GLenum* type, GLsizei* count); | 968 GLint* real_location, GLenum* type, GLsizei* count); |
968 | 969 |
969 // Gets the service id for any simulated backbuffer fbo. | 970 // Gets the service id for any simulated backbuffer fbo. |
970 GLuint GetBackbufferServiceId(); | 971 GLuint GetBackbufferServiceId() const; |
971 | 972 |
972 // Helper for glGetBooleanv, glGetFloatv and glGetIntegerv | 973 // Helper for glGetBooleanv, glGetFloatv and glGetIntegerv |
973 bool GetHelper(GLenum pname, GLint* params, GLsizei* num_written); | 974 bool GetHelper(GLenum pname, GLint* params, GLsizei* num_written); |
974 // Same as GetHelper except for auto-generated state. | 975 // Same as GetHelper except for auto-generated state. |
975 bool GetStateAsGLint(GLenum pname, GLint* params, GLsizei* num_written); | 976 bool GetStateAsGLint(GLenum pname, GLint* params, GLsizei* num_written); |
976 bool GetStateAsGLfloat(GLenum pname, GLfloat* params, GLsizei* num_written); | 977 bool GetStateAsGLfloat(GLenum pname, GLfloat* params, GLsizei* num_written); |
977 | 978 |
978 // Wrapper for glCreateProgram | 979 // Wrapper for glCreateProgram |
979 bool CreateProgramHelper(GLuint client_id); | 980 bool CreateProgramHelper(GLuint client_id); |
980 | 981 |
(...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1550 #if defined(OS_MACOSX) | 1551 #if defined(OS_MACOSX) |
1551 typedef std::map<GLuint, CFTypeRef> TextureToIOSurfaceMap; | 1552 typedef std::map<GLuint, CFTypeRef> TextureToIOSurfaceMap; |
1552 TextureToIOSurfaceMap texture_to_io_surface_map_; | 1553 TextureToIOSurfaceMap texture_to_io_surface_map_; |
1553 #endif | 1554 #endif |
1554 | 1555 |
1555 typedef std::vector<GLES2DecoderImpl*> ChildList; | 1556 typedef std::vector<GLES2DecoderImpl*> ChildList; |
1556 ChildList children_; | 1557 ChildList children_; |
1557 | 1558 |
1558 scoped_ptr<CopyTextureCHROMIUMResourceManager> copy_texture_CHROMIUM_; | 1559 scoped_ptr<CopyTextureCHROMIUMResourceManager> copy_texture_CHROMIUM_; |
1559 | 1560 |
| 1561 // Cached values of the currently assigned viewport dimensions. |
| 1562 GLsizei viewport_max_width_; |
| 1563 GLsizei viewport_max_height_; |
| 1564 |
1560 // Command buffer stats. | 1565 // Command buffer stats. |
1561 int texture_upload_count_; | 1566 int texture_upload_count_; |
1562 base::TimeDelta total_texture_upload_time_; | 1567 base::TimeDelta total_texture_upload_time_; |
1563 base::TimeDelta total_processing_commands_time_; | 1568 base::TimeDelta total_processing_commands_time_; |
1564 | 1569 |
1565 DISALLOW_COPY_AND_ASSIGN(GLES2DecoderImpl); | 1570 DISALLOW_COPY_AND_ASSIGN(GLES2DecoderImpl); |
1566 }; | 1571 }; |
1567 | 1572 |
1568 ScopedGLErrorSuppressor::ScopedGLErrorSuppressor(GLES2DecoderImpl* decoder) | 1573 ScopedGLErrorSuppressor::ScopedGLErrorSuppressor(GLES2DecoderImpl* decoder) |
1569 : decoder_(decoder) { | 1574 : decoder_(decoder) { |
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1935 use_shader_translator_(true), | 1940 use_shader_translator_(true), |
1936 validators_(group_->feature_info()->validators()), | 1941 validators_(group_->feature_info()->validators()), |
1937 feature_info_(group_->feature_info()), | 1942 feature_info_(group_->feature_info()), |
1938 tex_image_2d_failed_(false), | 1943 tex_image_2d_failed_(false), |
1939 frame_number_(0), | 1944 frame_number_(0), |
1940 has_robustness_extension_(false), | 1945 has_robustness_extension_(false), |
1941 reset_status_(GL_NO_ERROR), | 1946 reset_status_(GL_NO_ERROR), |
1942 force_webgl_glsl_validation_(false), | 1947 force_webgl_glsl_validation_(false), |
1943 derivatives_explicitly_enabled_(false), | 1948 derivatives_explicitly_enabled_(false), |
1944 compile_shader_always_succeeds_(false), | 1949 compile_shader_always_succeeds_(false), |
| 1950 viewport_max_width_(0), |
| 1951 viewport_max_height_(0), |
1945 texture_upload_count_(0) { | 1952 texture_upload_count_(0) { |
1946 DCHECK(group); | 1953 DCHECK(group); |
1947 | 1954 |
1948 GLES2DecoderImpl* this_temp = this; | 1955 GLES2DecoderImpl* this_temp = this; |
1949 this_in_hex_ = HexEncode(&this_temp, sizeof(this_temp)); | 1956 this_in_hex_ = HexEncode(&this_temp, sizeof(this_temp)); |
1950 | 1957 |
1951 attrib_0_value_.v[0] = 0.0f; | 1958 attrib_0_value_.v[0] = 0.0f; |
1952 attrib_0_value_.v[1] = 0.0f; | 1959 attrib_0_value_.v[1] = 0.0f; |
1953 attrib_0_value_.v[2] = 0.0f; | 1960 attrib_0_value_.v[2] = 0.0f; |
1954 attrib_0_value_.v[3] = 1.0f; | 1961 attrib_0_value_.v[3] = 1.0f; |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2035 // We have to enable vertex array 0 on OpenGL or it won't render. Note that | 2042 // We have to enable vertex array 0 on OpenGL or it won't render. Note that |
2036 // OpenGL ES 2.0 does not have this issue. | 2043 // OpenGL ES 2.0 does not have this issue. |
2037 glEnableVertexAttribArray(0); | 2044 glEnableVertexAttribArray(0); |
2038 } | 2045 } |
2039 glGenBuffersARB(1, &attrib_0_buffer_id_); | 2046 glGenBuffersARB(1, &attrib_0_buffer_id_); |
2040 glBindBuffer(GL_ARRAY_BUFFER, attrib_0_buffer_id_); | 2047 glBindBuffer(GL_ARRAY_BUFFER, attrib_0_buffer_id_); |
2041 glVertexAttribPointer(0, 1, GL_FLOAT, GL_FALSE, 0, NULL); | 2048 glVertexAttribPointer(0, 1, GL_FLOAT, GL_FALSE, 0, NULL); |
2042 glBindBuffer(GL_ARRAY_BUFFER, 0); | 2049 glBindBuffer(GL_ARRAY_BUFFER, 0); |
2043 glGenBuffersARB(1, &fixed_attrib_buffer_id_); | 2050 glGenBuffersARB(1, &fixed_attrib_buffer_id_); |
2044 | 2051 |
2045 state_.texture_units.reset( | 2052 state_.texture_units.resize(group_->max_texture_units()); |
2046 new TextureUnit[group_->max_texture_units()]); | 2053 for (uint32 tt = 0; tt < state_.texture_units.size(); ++tt) { |
2047 for (uint32 tt = 0; tt < group_->max_texture_units(); ++tt) { | |
2048 glActiveTexture(GL_TEXTURE0 + tt); | 2054 glActiveTexture(GL_TEXTURE0 + tt); |
2049 // We want the last bind to be 2D. | 2055 // We want the last bind to be 2D. |
2050 TextureManager::TextureInfo* info; | 2056 TextureManager::TextureInfo* info; |
2051 if (features().oes_egl_image_external) { | 2057 if (features().oes_egl_image_external) { |
2052 info = texture_manager()->GetDefaultTextureInfo(GL_TEXTURE_EXTERNAL_OES); | 2058 info = texture_manager()->GetDefaultTextureInfo(GL_TEXTURE_EXTERNAL_OES); |
2053 state_.texture_units[tt].bound_texture_external_oes = info; | 2059 state_.texture_units[tt].bound_texture_external_oes = info; |
2054 glBindTexture(GL_TEXTURE_EXTERNAL_OES, info->service_id()); | 2060 glBindTexture(GL_TEXTURE_EXTERNAL_OES, info->service_id()); |
2055 } | 2061 } |
2056 if (features().arb_texture_rectangle) { | 2062 if (features().arb_texture_rectangle) { |
2057 info = texture_manager()->GetDefaultTextureInfo(GL_TEXTURE_RECTANGLE_ARB); | 2063 info = texture_manager()->GetDefaultTextureInfo(GL_TEXTURE_RECTANGLE_ARB); |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2228 | 2234 |
2229 if (!InitializeShaderTranslator()) { | 2235 if (!InitializeShaderTranslator()) { |
2230 return false; | 2236 return false; |
2231 } | 2237 } |
2232 | 2238 |
2233 state_.viewport_width = size.width(); | 2239 state_.viewport_width = size.width(); |
2234 state_.viewport_height = size.height(); | 2240 state_.viewport_height = size.height(); |
2235 | 2241 |
2236 GLint viewport_params[4] = { 0 }; | 2242 GLint viewport_params[4] = { 0 }; |
2237 glGetIntegerv(GL_MAX_VIEWPORT_DIMS, viewport_params); | 2243 glGetIntegerv(GL_MAX_VIEWPORT_DIMS, viewport_params); |
2238 state_.viewport_max_width = viewport_params[0]; | 2244 viewport_max_width_ = viewport_params[0]; |
2239 state_.viewport_max_height = viewport_params[1]; | 2245 viewport_max_height_ = viewport_params[1]; |
2240 | 2246 |
2241 state_.scissor_width = state_.viewport_width; | 2247 state_.scissor_width = state_.viewport_width; |
2242 state_.scissor_height = state_.viewport_height; | 2248 state_.scissor_height = state_.viewport_height; |
2243 | 2249 |
2244 // Set all the default state because some GL drivers get it wrong. | 2250 // Set all the default state because some GL drivers get it wrong. |
2245 state_.InitCapabilities(); | 2251 state_.InitCapabilities(); |
2246 state_.InitState(); | 2252 state_.InitState(); |
2247 glActiveTexture(GL_TEXTURE0 + state_.active_texture_unit); | 2253 glActiveTexture(GL_TEXTURE0 + state_.active_texture_unit); |
2248 glHint(GL_GENERATE_MIPMAP_HINT, state_.hint_generate_mipmap); | 2254 glHint(GL_GENERATE_MIPMAP_HINT, state_.hint_generate_mipmap); |
2249 glPixelStorei(GL_PACK_ALIGNMENT, state_.pack_alignment); | 2255 glPixelStorei(GL_PACK_ALIGNMENT, state_.pack_alignment); |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2475 GLsizei n, const GLuint* client_ids) { | 2481 GLsizei n, const GLuint* client_ids) { |
2476 bool supports_separate_framebuffer_binds = | 2482 bool supports_separate_framebuffer_binds = |
2477 features().chromium_framebuffer_multisample; | 2483 features().chromium_framebuffer_multisample; |
2478 for (GLsizei ii = 0; ii < n; ++ii) { | 2484 for (GLsizei ii = 0; ii < n; ++ii) { |
2479 TextureManager::TextureInfo* texture = GetTextureInfo(client_ids[ii]); | 2485 TextureManager::TextureInfo* texture = GetTextureInfo(client_ids[ii]); |
2480 if (texture && !texture->IsDeleted()) { | 2486 if (texture && !texture->IsDeleted()) { |
2481 if (texture->IsAttachedToFramebuffer()) { | 2487 if (texture->IsAttachedToFramebuffer()) { |
2482 clear_state_dirty_ = true; | 2488 clear_state_dirty_ = true; |
2483 } | 2489 } |
2484 // Unbind texture from texture units. | 2490 // Unbind texture from texture units. |
2485 for (size_t jj = 0; jj < group_->max_texture_units(); ++jj) { | 2491 for (size_t jj = 0; jj < state_.texture_units.size(); ++jj) { |
2486 state_.texture_units[jj].Unbind(texture); | 2492 state_.texture_units[jj].Unbind(texture); |
2487 } | 2493 } |
2488 // Unbind from current framebuffers. | 2494 // Unbind from current framebuffers. |
2489 if (supports_separate_framebuffer_binds) { | 2495 if (supports_separate_framebuffer_binds) { |
2490 if (state_.bound_read_framebuffer) { | 2496 if (state_.bound_read_framebuffer) { |
2491 state_.bound_read_framebuffer->UnbindTexture( | 2497 state_.bound_read_framebuffer->UnbindTexture( |
2492 GL_READ_FRAMEBUFFER_EXT, texture); | 2498 GL_READ_FRAMEBUFFER_EXT, texture); |
2493 } | 2499 } |
2494 if (state_.bound_draw_framebuffer) { | 2500 if (state_.bound_draw_framebuffer) { |
2495 state_.bound_draw_framebuffer->UnbindTexture( | 2501 state_.bound_draw_framebuffer->UnbindTexture( |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2772 | 2778 |
2773 ChildList children = children_; | 2779 ChildList children = children_; |
2774 for (ChildList::iterator it = children.begin(); it != children.end(); ++it) | 2780 for (ChildList::iterator it = children.begin(); it != children.end(); ++it) |
2775 (*it)->SetParent(NULL, 0); | 2781 (*it)->SetParent(NULL, 0); |
2776 DCHECK(children_.empty()); | 2782 DCHECK(children_.empty()); |
2777 SetParent(NULL, 0); | 2783 SetParent(NULL, 0); |
2778 | 2784 |
2779 // Unbind everything. | 2785 // Unbind everything. |
2780 state_.vertex_attrib_manager = NULL; | 2786 state_.vertex_attrib_manager = NULL; |
2781 default_vertex_attrib_manager_ = NULL; | 2787 default_vertex_attrib_manager_ = NULL; |
2782 state_.texture_units.reset(); | 2788 state_.texture_units.clear(); |
2783 state_.bound_array_buffer = NULL; | 2789 state_.bound_array_buffer = NULL; |
2784 state_.current_query = NULL; | 2790 state_.current_query = NULL; |
2785 state_.current_program = NULL; | 2791 state_.current_program = NULL; |
2786 state_.bound_read_framebuffer = NULL; | 2792 state_.bound_read_framebuffer = NULL; |
2787 state_.bound_draw_framebuffer = NULL; | 2793 state_.bound_draw_framebuffer = NULL; |
2788 state_.bound_renderbuffer = NULL; | 2794 state_.bound_renderbuffer = NULL; |
2789 | 2795 |
2790 if (have_context) { | 2796 if (have_context) { |
2791 if (copy_texture_CHROMIUM_.get()) { | 2797 if (copy_texture_CHROMIUM_.get()) { |
2792 copy_texture_CHROMIUM_->Destroy(); | 2798 copy_texture_CHROMIUM_->Destroy(); |
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3227 ProcessPendingQueries(); | 3233 ProcessPendingQueries(); |
3228 } | 3234 } |
3229 | 3235 |
3230 void GLES2DecoderImpl::DoFlush() { | 3236 void GLES2DecoderImpl::DoFlush() { |
3231 glFlush(); | 3237 glFlush(); |
3232 ProcessPendingQueries(); | 3238 ProcessPendingQueries(); |
3233 } | 3239 } |
3234 | 3240 |
3235 void GLES2DecoderImpl::DoActiveTexture(GLenum texture_unit) { | 3241 void GLES2DecoderImpl::DoActiveTexture(GLenum texture_unit) { |
3236 GLuint texture_index = texture_unit - GL_TEXTURE0; | 3242 GLuint texture_index = texture_unit - GL_TEXTURE0; |
3237 if (texture_index >= group_->max_texture_units()) { | 3243 if (texture_index >= state_.texture_units.size()) { |
3238 SetGLErrorInvalidEnum( | 3244 SetGLErrorInvalidEnum( |
3239 "glActiveTexture", texture_unit, "texture_unit"); | 3245 "glActiveTexture", texture_unit, "texture_unit"); |
3240 return; | 3246 return; |
3241 } | 3247 } |
3242 state_.active_texture_unit = texture_index; | 3248 state_.active_texture_unit = texture_index; |
3243 glActiveTexture(texture_unit); | 3249 glActiveTexture(texture_unit); |
3244 } | 3250 } |
3245 | 3251 |
3246 void GLES2DecoderImpl::DoBindBuffer(GLenum target, GLuint client_id) { | 3252 void GLES2DecoderImpl::DoBindBuffer(GLenum target, GLuint client_id) { |
3247 BufferManager::BufferInfo* info = NULL; | 3253 BufferManager::BufferInfo* info = NULL; |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3341 | 3347 |
3342 void GLES2DecoderImpl::BindAndApplyTextureParameters( | 3348 void GLES2DecoderImpl::BindAndApplyTextureParameters( |
3343 TextureManager::TextureInfo* info) { | 3349 TextureManager::TextureInfo* info) { |
3344 glBindTexture(info->target(), info->service_id()); | 3350 glBindTexture(info->target(), info->service_id()); |
3345 glTexParameteri(info->target(), GL_TEXTURE_MIN_FILTER, info->min_filter()); | 3351 glTexParameteri(info->target(), GL_TEXTURE_MIN_FILTER, info->min_filter()); |
3346 glTexParameteri(info->target(), GL_TEXTURE_MAG_FILTER, info->mag_filter()); | 3352 glTexParameteri(info->target(), GL_TEXTURE_MAG_FILTER, info->mag_filter()); |
3347 glTexParameteri(info->target(), GL_TEXTURE_WRAP_S, info->wrap_s()); | 3353 glTexParameteri(info->target(), GL_TEXTURE_WRAP_S, info->wrap_s()); |
3348 glTexParameteri(info->target(), GL_TEXTURE_WRAP_T, info->wrap_t()); | 3354 glTexParameteri(info->target(), GL_TEXTURE_WRAP_T, info->wrap_t()); |
3349 } | 3355 } |
3350 | 3356 |
3351 GLuint GLES2DecoderImpl::GetBackbufferServiceId() { | 3357 GLuint GLES2DecoderImpl::GetBackbufferServiceId() const { |
3352 return (offscreen_target_frame_buffer_.get()) ? | 3358 return (offscreen_target_frame_buffer_.get()) ? |
3353 offscreen_target_frame_buffer_->id() : | 3359 offscreen_target_frame_buffer_->id() : |
3354 surface_->GetBackingFrameBufferObject(); | 3360 (surface_ ? surface_->GetBackingFrameBufferObject() : 0); |
| 3361 } |
| 3362 |
| 3363 void GLES2DecoderImpl::RestoreState() const { |
| 3364 state_.RestoreState(); |
| 3365 |
| 3366 // TODO: Restore multisample bindings |
| 3367 GLuint service_id = state_.bound_draw_framebuffer ? |
| 3368 state_.bound_draw_framebuffer->service_id() : |
| 3369 GetBackbufferServiceId(); |
| 3370 glBindFramebufferEXT(GL_FRAMEBUFFER, service_id); |
3355 } | 3371 } |
3356 | 3372 |
3357 void GLES2DecoderImpl::DoBindFramebuffer(GLenum target, GLuint client_id) { | 3373 void GLES2DecoderImpl::DoBindFramebuffer(GLenum target, GLuint client_id) { |
3358 FramebufferManager::FramebufferInfo* info = NULL; | 3374 FramebufferManager::FramebufferInfo* info = NULL; |
3359 GLuint service_id = 0; | 3375 GLuint service_id = 0; |
3360 if (client_id != 0) { | 3376 if (client_id != 0) { |
3361 info = GetFramebufferInfo(client_id); | 3377 info = GetFramebufferInfo(client_id); |
3362 if (!info) { | 3378 if (!info) { |
3363 if (!group_->bind_generates_resource()) { | 3379 if (!group_->bind_generates_resource()) { |
3364 LOG(ERROR) | 3380 LOG(ERROR) |
(...skipping 1357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4722 | 4738 |
4723 void GLES2DecoderImpl::DoUniform1i(GLint fake_location, GLint v0) { | 4739 void GLES2DecoderImpl::DoUniform1i(GLint fake_location, GLint v0) { |
4724 GLenum type = 0; | 4740 GLenum type = 0; |
4725 GLsizei count = 1; | 4741 GLsizei count = 1; |
4726 GLint real_location = -1; | 4742 GLint real_location = -1; |
4727 if (!PrepForSetUniformByLocation( | 4743 if (!PrepForSetUniformByLocation( |
4728 fake_location, "glUniform1iv", &real_location, &type, &count)) { | 4744 fake_location, "glUniform1iv", &real_location, &type, &count)) { |
4729 return; | 4745 return; |
4730 } | 4746 } |
4731 if (!state_.current_program->SetSamplers( | 4747 if (!state_.current_program->SetSamplers( |
4732 group_->max_texture_units(), fake_location, 1, &v0)) { | 4748 state_.texture_units.size(), fake_location, 1, &v0)) { |
4733 SetGLError(GL_INVALID_VALUE, "glUniform1i", "texture unit out of range"); | 4749 SetGLError(GL_INVALID_VALUE, "glUniform1i", "texture unit out of range"); |
4734 return; | 4750 return; |
4735 } | 4751 } |
4736 glUniform1i(real_location, v0); | 4752 glUniform1i(real_location, v0); |
4737 } | 4753 } |
4738 | 4754 |
4739 void GLES2DecoderImpl::DoUniform1iv( | 4755 void GLES2DecoderImpl::DoUniform1iv( |
4740 GLint fake_location, GLsizei count, const GLint *value) { | 4756 GLint fake_location, GLsizei count, const GLint *value) { |
4741 GLenum type = 0; | 4757 GLenum type = 0; |
4742 GLint real_location = -1; | 4758 GLint real_location = -1; |
4743 if (!PrepForSetUniformByLocation( | 4759 if (!PrepForSetUniformByLocation( |
4744 fake_location, "glUniform1iv", &real_location, &type, &count)) { | 4760 fake_location, "glUniform1iv", &real_location, &type, &count)) { |
4745 return; | 4761 return; |
4746 } | 4762 } |
4747 if (type == GL_SAMPLER_2D || type == GL_SAMPLER_2D_RECT_ARB || | 4763 if (type == GL_SAMPLER_2D || type == GL_SAMPLER_2D_RECT_ARB || |
4748 type == GL_SAMPLER_CUBE || type == GL_SAMPLER_EXTERNAL_OES) { | 4764 type == GL_SAMPLER_CUBE || type == GL_SAMPLER_EXTERNAL_OES) { |
4749 if (!state_.current_program->SetSamplers( | 4765 if (!state_.current_program->SetSamplers( |
4750 group_->max_texture_units(), fake_location, count, value)) { | 4766 state_.texture_units.size(), fake_location, count, value)) { |
4751 SetGLError(GL_INVALID_VALUE, "glUniform1iv", "texture unit out of range"); | 4767 SetGLError(GL_INVALID_VALUE, "glUniform1iv", "texture unit out of range"); |
4752 return; | 4768 return; |
4753 } | 4769 } |
4754 } | 4770 } |
4755 glUniform1iv(real_location, count, value); | 4771 glUniform1iv(real_location, count, value); |
4756 } | 4772 } |
4757 | 4773 |
4758 void GLES2DecoderImpl::DoUniform1fv( | 4774 void GLES2DecoderImpl::DoUniform1fv( |
4759 GLint fake_location, GLsizei count, const GLfloat* value) { | 4775 GLint fake_location, GLsizei count, const GLfloat* value) { |
4760 GLenum type = 0; | 4776 GLenum type = 0; |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5052 } | 5068 } |
5053 bool textures_set = false; | 5069 bool textures_set = false; |
5054 const ProgramManager::ProgramInfo::SamplerIndices& sampler_indices = | 5070 const ProgramManager::ProgramInfo::SamplerIndices& sampler_indices = |
5055 state_.current_program->sampler_indices(); | 5071 state_.current_program->sampler_indices(); |
5056 for (size_t ii = 0; ii < sampler_indices.size(); ++ii) { | 5072 for (size_t ii = 0; ii < sampler_indices.size(); ++ii) { |
5057 const ProgramManager::ProgramInfo::UniformInfo* uniform_info = | 5073 const ProgramManager::ProgramInfo::UniformInfo* uniform_info = |
5058 state_.current_program->GetUniformInfo(sampler_indices[ii]); | 5074 state_.current_program->GetUniformInfo(sampler_indices[ii]); |
5059 DCHECK(uniform_info); | 5075 DCHECK(uniform_info); |
5060 for (size_t jj = 0; jj < uniform_info->texture_units.size(); ++jj) { | 5076 for (size_t jj = 0; jj < uniform_info->texture_units.size(); ++jj) { |
5061 GLuint texture_unit_index = uniform_info->texture_units[jj]; | 5077 GLuint texture_unit_index = uniform_info->texture_units[jj]; |
5062 if (texture_unit_index < group_->max_texture_units()) { | 5078 if (texture_unit_index < state_.texture_units.size()) { |
5063 TextureUnit& texture_unit = state_.texture_units[texture_unit_index]; | 5079 TextureUnit& texture_unit = state_.texture_units[texture_unit_index]; |
5064 TextureManager::TextureInfo* texture_info = | 5080 TextureManager::TextureInfo* texture_info = |
5065 texture_unit.GetInfoForSamplerType(uniform_info->type); | 5081 texture_unit.GetInfoForSamplerType(uniform_info->type); |
5066 if (!texture_info || !texture_manager()->CanRender(texture_info)) { | 5082 if (!texture_info || !texture_manager()->CanRender(texture_info)) { |
5067 textures_set = true; | 5083 textures_set = true; |
5068 glActiveTexture(GL_TEXTURE0 + texture_unit_index); | 5084 glActiveTexture(GL_TEXTURE0 + texture_unit_index); |
5069 glBindTexture( | 5085 glBindTexture( |
5070 GetBindTargetForSamplerType(uniform_info->type), | 5086 GetBindTargetForSamplerType(uniform_info->type), |
5071 texture_manager()->black_texture_id(uniform_info->type)); | 5087 texture_manager()->black_texture_id(uniform_info->type)); |
5072 RenderWarning( | 5088 RenderWarning( |
(...skipping 13 matching lines...) Expand all Loading... |
5086 void GLES2DecoderImpl::RestoreStateForNonRenderableTextures() { | 5102 void GLES2DecoderImpl::RestoreStateForNonRenderableTextures() { |
5087 DCHECK(state_.current_program); | 5103 DCHECK(state_.current_program); |
5088 const ProgramManager::ProgramInfo::SamplerIndices& sampler_indices = | 5104 const ProgramManager::ProgramInfo::SamplerIndices& sampler_indices = |
5089 state_.current_program->sampler_indices(); | 5105 state_.current_program->sampler_indices(); |
5090 for (size_t ii = 0; ii < sampler_indices.size(); ++ii) { | 5106 for (size_t ii = 0; ii < sampler_indices.size(); ++ii) { |
5091 const ProgramManager::ProgramInfo::UniformInfo* uniform_info = | 5107 const ProgramManager::ProgramInfo::UniformInfo* uniform_info = |
5092 state_.current_program->GetUniformInfo(sampler_indices[ii]); | 5108 state_.current_program->GetUniformInfo(sampler_indices[ii]); |
5093 DCHECK(uniform_info); | 5109 DCHECK(uniform_info); |
5094 for (size_t jj = 0; jj < uniform_info->texture_units.size(); ++jj) { | 5110 for (size_t jj = 0; jj < uniform_info->texture_units.size(); ++jj) { |
5095 GLuint texture_unit_index = uniform_info->texture_units[jj]; | 5111 GLuint texture_unit_index = uniform_info->texture_units[jj]; |
5096 if (texture_unit_index < group_->max_texture_units()) { | 5112 if (texture_unit_index < state_.texture_units.size()) { |
5097 TextureUnit& texture_unit = state_.texture_units[texture_unit_index]; | 5113 TextureUnit& texture_unit = state_.texture_units[texture_unit_index]; |
5098 TextureManager::TextureInfo* texture_info = | 5114 TextureManager::TextureInfo* texture_info = |
5099 uniform_info->type == GL_SAMPLER_2D ? | 5115 uniform_info->type == GL_SAMPLER_2D ? |
5100 texture_unit.bound_texture_2d : | 5116 texture_unit.bound_texture_2d : |
5101 texture_unit.bound_texture_cube_map; | 5117 texture_unit.bound_texture_cube_map; |
5102 if (!texture_info || !texture_manager()->CanRender(texture_info)) { | 5118 if (!texture_info || !texture_manager()->CanRender(texture_info)) { |
5103 glActiveTexture(GL_TEXTURE0 + texture_unit_index); | 5119 glActiveTexture(GL_TEXTURE0 + texture_unit_index); |
5104 // Get the texture info that was previously bound here. | 5120 // Get the texture info that was previously bound here. |
5105 texture_info = texture_unit.bind_target == GL_TEXTURE_2D ? | 5121 texture_info = texture_unit.bind_target == GL_TEXTURE_2D ? |
5106 texture_unit.bound_texture_2d : | 5122 texture_unit.bound_texture_2d : |
(...skipping 17 matching lines...) Expand all Loading... |
5124 // 1: Check all textures we are about to render with. | 5140 // 1: Check all textures we are about to render with. |
5125 if (state_.current_program) { | 5141 if (state_.current_program) { |
5126 const ProgramManager::ProgramInfo::SamplerIndices& sampler_indices = | 5142 const ProgramManager::ProgramInfo::SamplerIndices& sampler_indices = |
5127 state_.current_program->sampler_indices(); | 5143 state_.current_program->sampler_indices(); |
5128 for (size_t ii = 0; ii < sampler_indices.size(); ++ii) { | 5144 for (size_t ii = 0; ii < sampler_indices.size(); ++ii) { |
5129 const ProgramManager::ProgramInfo::UniformInfo* uniform_info = | 5145 const ProgramManager::ProgramInfo::UniformInfo* uniform_info = |
5130 state_.current_program->GetUniformInfo(sampler_indices[ii]); | 5146 state_.current_program->GetUniformInfo(sampler_indices[ii]); |
5131 DCHECK(uniform_info); | 5147 DCHECK(uniform_info); |
5132 for (size_t jj = 0; jj < uniform_info->texture_units.size(); ++jj) { | 5148 for (size_t jj = 0; jj < uniform_info->texture_units.size(); ++jj) { |
5133 GLuint texture_unit_index = uniform_info->texture_units[jj]; | 5149 GLuint texture_unit_index = uniform_info->texture_units[jj]; |
5134 if (texture_unit_index < group_->max_texture_units()) { | 5150 if (texture_unit_index < state_.texture_units.size()) { |
5135 TextureUnit& texture_unit = state_.texture_units[texture_unit_index]; | 5151 TextureUnit& texture_unit = state_.texture_units[texture_unit_index]; |
5136 TextureManager::TextureInfo* texture_info = | 5152 TextureManager::TextureInfo* texture_info = |
5137 texture_unit.GetInfoForSamplerType(uniform_info->type); | 5153 texture_unit.GetInfoForSamplerType(uniform_info->type); |
5138 if (texture_info && !texture_info->SafeToRenderFrom()) { | 5154 if (texture_info && !texture_info->SafeToRenderFrom()) { |
5139 if (!texture_manager()->ClearRenderableLevels(this, texture_info)) { | 5155 if (!texture_manager()->ClearRenderableLevels(this, texture_info)) { |
5140 return false; | 5156 return false; |
5141 } | 5157 } |
5142 } | 5158 } |
5143 } | 5159 } |
5144 } | 5160 } |
(...skipping 1067 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6212 if (type != GL_FIXED) { | 6228 if (type != GL_FIXED) { |
6213 glVertexAttribPointer(indx, size, type, normalized, stride, ptr); | 6229 glVertexAttribPointer(indx, size, type, normalized, stride, ptr); |
6214 } | 6230 } |
6215 return error::kNoError; | 6231 return error::kNoError; |
6216 } | 6232 } |
6217 | 6233 |
6218 void GLES2DecoderImpl::DoViewport(GLint x, GLint y, GLsizei width, | 6234 void GLES2DecoderImpl::DoViewport(GLint x, GLint y, GLsizei width, |
6219 GLsizei height) { | 6235 GLsizei height) { |
6220 state_.viewport_x = x; | 6236 state_.viewport_x = x; |
6221 state_.viewport_y = y; | 6237 state_.viewport_y = y; |
6222 state_.viewport_width = std::min(width, state_.viewport_max_width); | 6238 state_.viewport_width = std::min(width, viewport_max_width_); |
6223 state_.viewport_height = std::min(height, state_.viewport_max_height); | 6239 state_.viewport_height = std::min(height, viewport_max_height_); |
6224 glViewport(x, y, width, height); | 6240 glViewport(x, y, width, height); |
6225 } | 6241 } |
6226 | 6242 |
6227 error::Error GLES2DecoderImpl::HandleVertexAttribDivisorANGLE( | 6243 error::Error GLES2DecoderImpl::HandleVertexAttribDivisorANGLE( |
6228 uint32 immediate_data_size, const gles2::VertexAttribDivisorANGLE& c) { | 6244 uint32 immediate_data_size, const gles2::VertexAttribDivisorANGLE& c) { |
6229 if (!features().angle_instanced_arrays) { | 6245 if (!features().angle_instanced_arrays) { |
6230 SetGLError(GL_INVALID_OPERATION, | 6246 SetGLError(GL_INVALID_OPERATION, |
6231 "glVertexAttribDivisorANGLE", "function not available"); | 6247 "glVertexAttribDivisorANGLE", "function not available"); |
6232 } | 6248 } |
6233 GLuint index = c.index; | 6249 GLuint index = c.index; |
(...skipping 3056 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9290 GL_RGBA, GL_UNSIGNED_BYTE, false); | 9306 GL_RGBA, GL_UNSIGNED_BYTE, false); |
9291 } | 9307 } |
9292 | 9308 |
9293 // Include the auto-generated part of this file. We split this because it means | 9309 // Include the auto-generated part of this file. We split this because it means |
9294 // we can easily edit the non-auto generated parts right here in this file | 9310 // we can easily edit the non-auto generated parts right here in this file |
9295 // instead of having to edit some template or the code generator. | 9311 // instead of having to edit some template or the code generator. |
9296 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 9312 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
9297 | 9313 |
9298 } // namespace gles2 | 9314 } // namespace gles2 |
9299 } // namespace gpu | 9315 } // namespace gpu |
OLD | NEW |