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 15 matching lines...) Expand all Loading... | |
26 #define GLES2_GPU_SERVICE 1 | 26 #define GLES2_GPU_SERVICE 1 |
27 #include "gpu/command_buffer/common/gles2_cmd_format.h" | 27 #include "gpu/command_buffer/common/gles2_cmd_format.h" |
28 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 28 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
29 #include "gpu/command_buffer/common/id_allocator.h" | 29 #include "gpu/command_buffer/common/id_allocator.h" |
30 #include "gpu/command_buffer/service/buffer_manager.h" | 30 #include "gpu/command_buffer/service/buffer_manager.h" |
31 #include "gpu/command_buffer/service/cmd_buffer_engine.h" | 31 #include "gpu/command_buffer/service/cmd_buffer_engine.h" |
32 #include "gpu/command_buffer/service/context_group.h" | 32 #include "gpu/command_buffer/service/context_group.h" |
33 #include "gpu/command_buffer/service/feature_info.h" | 33 #include "gpu/command_buffer/service/feature_info.h" |
34 #include "gpu/command_buffer/service/framebuffer_manager.h" | 34 #include "gpu/command_buffer/service/framebuffer_manager.h" |
35 #include "gpu/command_buffer/service/gl_utils.h" | 35 #include "gpu/command_buffer/service/gl_utils.h" |
36 #include "gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.h" | |
36 #include "gpu/command_buffer/service/gles2_cmd_validation.h" | 37 #include "gpu/command_buffer/service/gles2_cmd_validation.h" |
37 #include "gpu/command_buffer/service/gpu_switches.h" | 38 #include "gpu/command_buffer/service/gpu_switches.h" |
38 #include "gpu/command_buffer/service/program_manager.h" | 39 #include "gpu/command_buffer/service/program_manager.h" |
39 #include "gpu/command_buffer/service/query_manager.h" | 40 #include "gpu/command_buffer/service/query_manager.h" |
40 #include "gpu/command_buffer/service/renderbuffer_manager.h" | 41 #include "gpu/command_buffer/service/renderbuffer_manager.h" |
41 #include "gpu/command_buffer/service/shader_manager.h" | 42 #include "gpu/command_buffer/service/shader_manager.h" |
42 #include "gpu/command_buffer/service/shader_translator.h" | 43 #include "gpu/command_buffer/service/shader_translator.h" |
43 #include "gpu/command_buffer/service/stream_texture.h" | 44 #include "gpu/command_buffer/service/stream_texture.h" |
44 #include "gpu/command_buffer/service/stream_texture_manager.h" | 45 #include "gpu/command_buffer/service/stream_texture_manager.h" |
45 #include "gpu/command_buffer/service/texture_manager.h" | 46 #include "gpu/command_buffer/service/texture_manager.h" |
(...skipping 768 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
814 const void * data); | 815 const void * data); |
815 | 816 |
816 // Wrapper for TexImageIOSurface2DCHROMIUM. | 817 // Wrapper for TexImageIOSurface2DCHROMIUM. |
817 void DoTexImageIOSurface2DCHROMIUM( | 818 void DoTexImageIOSurface2DCHROMIUM( |
818 GLenum target, | 819 GLenum target, |
819 GLsizei width, | 820 GLsizei width, |
820 GLsizei height, | 821 GLsizei height, |
821 GLuint io_surface_id, | 822 GLuint io_surface_id, |
822 GLuint plane); | 823 GLuint plane); |
823 | 824 |
825 void DoCopyTextureCHROMIUM( | |
826 GLenum target, | |
827 GLuint source_id, | |
828 GLuint target_id, | |
829 GLint level); | |
830 | |
824 // Wrapper for TexStorage2DEXT. | 831 // Wrapper for TexStorage2DEXT. |
825 void DoTexStorage2DEXT( | 832 void DoTexStorage2DEXT( |
826 GLenum target, | 833 GLenum target, |
827 GLint levels, | 834 GLint levels, |
828 GLenum internal_format, | 835 GLenum internal_format, |
829 GLsizei width, | 836 GLsizei width, |
830 GLsizei height); | 837 GLsizei height); |
831 | 838 |
832 // Creates a ProgramInfo for the given program. | 839 // Creates a ProgramInfo for the given program. |
833 ProgramManager::ProgramInfo* CreateProgramInfo( | 840 ProgramManager::ProgramInfo* CreateProgramInfo( |
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1220 void DoVertexAttrib1f(GLuint index, GLfloat v0); | 1227 void DoVertexAttrib1f(GLuint index, GLfloat v0); |
1221 void DoVertexAttrib2f(GLuint index, GLfloat v0, GLfloat v1); | 1228 void DoVertexAttrib2f(GLuint index, GLfloat v0, GLfloat v1); |
1222 void DoVertexAttrib3f(GLuint index, GLfloat v0, GLfloat v1, GLfloat v2); | 1229 void DoVertexAttrib3f(GLuint index, GLfloat v0, GLfloat v1, GLfloat v2); |
1223 void DoVertexAttrib4f( | 1230 void DoVertexAttrib4f( |
1224 GLuint index, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); | 1231 GLuint index, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); |
1225 void DoVertexAttrib1fv(GLuint index, const GLfloat *v); | 1232 void DoVertexAttrib1fv(GLuint index, const GLfloat *v); |
1226 void DoVertexAttrib2fv(GLuint index, const GLfloat *v); | 1233 void DoVertexAttrib2fv(GLuint index, const GLfloat *v); |
1227 void DoVertexAttrib3fv(GLuint index, const GLfloat *v); | 1234 void DoVertexAttrib3fv(GLuint index, const GLfloat *v); |
1228 void DoVertexAttrib4fv(GLuint index, const GLfloat *v); | 1235 void DoVertexAttrib4fv(GLuint index, const GLfloat *v); |
1229 | 1236 |
1237 // Wrapper for glViewport | |
1238 void DoViewport(GLint x, GLint y, GLsizei width, GLsizei height); | |
1239 | |
1230 // Wrapper for glUseProgram | 1240 // Wrapper for glUseProgram |
1231 void DoUseProgram(GLuint program); | 1241 void DoUseProgram(GLuint program); |
1232 | 1242 |
1233 // Wrapper for glValidateProgram. | 1243 // Wrapper for glValidateProgram. |
1234 void DoValidateProgram(GLuint program_client_id); | 1244 void DoValidateProgram(GLuint program_client_id); |
1235 | 1245 |
1236 // Gets the number of values that will be returned by glGetXXX. Returns | 1246 // Gets the number of values that will be returned by glGetXXX. Returns |
1237 // false if pname is unknown. | 1247 // false if pname is unknown. |
1238 bool GetNumValuesReturnedForGLGet(GLenum pname, GLsizei* num_values); | 1248 bool GetNumValuesReturnedForGLGet(GLenum pname, GLsizei* num_values); |
1239 | 1249 |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1420 | 1430 |
1421 // Util to help with GL. | 1431 // Util to help with GL. |
1422 GLES2Util util_; | 1432 GLES2Util util_; |
1423 | 1433 |
1424 // pack alignment as last set by glPixelStorei | 1434 // pack alignment as last set by glPixelStorei |
1425 GLint pack_alignment_; | 1435 GLint pack_alignment_; |
1426 | 1436 |
1427 // unpack alignment as last set by glPixelStorei | 1437 // unpack alignment as last set by glPixelStorei |
1428 GLint unpack_alignment_; | 1438 GLint unpack_alignment_; |
1429 | 1439 |
1440 // unpack flip y as last set by glPixelStorei | |
1441 bool unpack_flip_y_; | |
1442 | |
1443 // unpack premultiply alpha as last set by glPixelStorei | |
1444 bool unpack_premultiply_alpha_; | |
1445 | |
1430 // The currently bound array buffer. If this is 0 it is illegal to call | 1446 // The currently bound array buffer. If this is 0 it is illegal to call |
1431 // glVertexAttribPointer. | 1447 // glVertexAttribPointer. |
1432 BufferManager::BufferInfo::Ref bound_array_buffer_; | 1448 BufferManager::BufferInfo::Ref bound_array_buffer_; |
1433 | 1449 |
1434 // The currently bound element array buffer. If this is 0 it is illegal | 1450 // The currently bound element array buffer. If this is 0 it is illegal |
1435 // to call glDrawElements. | 1451 // to call glDrawElements. |
1436 BufferManager::BufferInfo::Ref bound_element_array_buffer_; | 1452 BufferManager::BufferInfo::Ref bound_element_array_buffer_; |
1437 | 1453 |
1438 // Class that manages vertex attribs. | 1454 // Class that manages vertex attribs. |
1439 scoped_ptr<VertexAttribManager> vertex_attrib_manager_; | 1455 scoped_ptr<VertexAttribManager> vertex_attrib_manager_; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1472 GLclampf clear_alpha_; | 1488 GLclampf clear_alpha_; |
1473 GLboolean mask_red_; | 1489 GLboolean mask_red_; |
1474 GLboolean mask_green_; | 1490 GLboolean mask_green_; |
1475 GLboolean mask_blue_; | 1491 GLboolean mask_blue_; |
1476 GLboolean mask_alpha_; | 1492 GLboolean mask_alpha_; |
1477 GLint clear_stencil_; | 1493 GLint clear_stencil_; |
1478 GLuint mask_stencil_front_; | 1494 GLuint mask_stencil_front_; |
1479 GLuint mask_stencil_back_; | 1495 GLuint mask_stencil_back_; |
1480 GLclampf clear_depth_; | 1496 GLclampf clear_depth_; |
1481 GLboolean mask_depth_; | 1497 GLboolean mask_depth_; |
1498 bool enable_cull_face_; | |
1482 bool enable_scissor_test_; | 1499 bool enable_scissor_test_; |
1483 bool enable_depth_test_; | 1500 bool enable_depth_test_; |
1484 bool enable_stencil_test_; | 1501 bool enable_stencil_test_; |
1485 bool state_dirty_; | 1502 bool state_dirty_; |
1486 | 1503 |
1487 // The program in use by glUseProgram | 1504 // The program in use by glUseProgram |
1488 ProgramManager::ProgramInfo::Ref current_program_; | 1505 ProgramManager::ProgramInfo::Ref current_program_; |
1489 | 1506 |
1490 // The currently bound framebuffers | 1507 // The currently bound framebuffers |
1491 FramebufferManager::FramebufferInfo::Ref bound_read_framebuffer_; | 1508 FramebufferManager::FramebufferInfo::Ref bound_read_framebuffer_; |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1575 bool compile_shader_always_succeeds_; | 1592 bool compile_shader_always_succeeds_; |
1576 | 1593 |
1577 #if defined(OS_MACOSX) | 1594 #if defined(OS_MACOSX) |
1578 typedef std::map<GLuint, CFTypeRef> TextureToIOSurfaceMap; | 1595 typedef std::map<GLuint, CFTypeRef> TextureToIOSurfaceMap; |
1579 TextureToIOSurfaceMap texture_to_io_surface_map_; | 1596 TextureToIOSurfaceMap texture_to_io_surface_map_; |
1580 #endif | 1597 #endif |
1581 | 1598 |
1582 typedef std::vector<GLES2DecoderImpl*> ChildList; | 1599 typedef std::vector<GLES2DecoderImpl*> ChildList; |
1583 ChildList children_; | 1600 ChildList children_; |
1584 | 1601 |
1602 scoped_ptr<CopyTextureCHROMIUMResourceManager> copy_texture_CHROMIUM_; | |
1603 | |
1604 // Cached values of the currently assigned viewport dimensions. | |
1605 GLint viewport_x_, viewport_y_; | |
1606 GLsizei viewport_width_, viewport_height_; | |
1607 GLsizei viewport_max_width_, viewport_max_height_; | |
1608 | |
1585 DISALLOW_COPY_AND_ASSIGN(GLES2DecoderImpl); | 1609 DISALLOW_COPY_AND_ASSIGN(GLES2DecoderImpl); |
1586 }; | 1610 }; |
1587 | 1611 |
1588 ScopedGLErrorSuppressor::ScopedGLErrorSuppressor(GLES2DecoderImpl* decoder) | 1612 ScopedGLErrorSuppressor::ScopedGLErrorSuppressor(GLES2DecoderImpl* decoder) |
1589 : decoder_(decoder) { | 1613 : decoder_(decoder) { |
1590 decoder_->CopyRealGLErrorsToWrapper(); | 1614 decoder_->CopyRealGLErrorsToWrapper(); |
1591 } | 1615 } |
1592 | 1616 |
1593 ScopedGLErrorSuppressor::~ScopedGLErrorSuppressor() { | 1617 ScopedGLErrorSuppressor::~ScopedGLErrorSuppressor() { |
1594 decoder_->ClearRealGLErrors(); | 1618 decoder_->ClearRealGLErrors(); |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1917 GLES2Decoder* GLES2Decoder::Create(ContextGroup* group) { | 1941 GLES2Decoder* GLES2Decoder::Create(ContextGroup* group) { |
1918 return new GLES2DecoderImpl(group); | 1942 return new GLES2DecoderImpl(group); |
1919 } | 1943 } |
1920 | 1944 |
1921 GLES2DecoderImpl::GLES2DecoderImpl(ContextGroup* group) | 1945 GLES2DecoderImpl::GLES2DecoderImpl(ContextGroup* group) |
1922 : GLES2Decoder(), | 1946 : GLES2Decoder(), |
1923 group_(group), | 1947 group_(group), |
1924 error_bits_(0), | 1948 error_bits_(0), |
1925 pack_alignment_(4), | 1949 pack_alignment_(4), |
1926 unpack_alignment_(4), | 1950 unpack_alignment_(4), |
1951 unpack_flip_y_(false), | |
1952 unpack_premultiply_alpha_(false), | |
1927 attrib_0_buffer_id_(0), | 1953 attrib_0_buffer_id_(0), |
1928 attrib_0_buffer_matches_value_(true), | 1954 attrib_0_buffer_matches_value_(true), |
1929 attrib_0_size_(0), | 1955 attrib_0_size_(0), |
1930 fixed_attrib_buffer_id_(0), | 1956 fixed_attrib_buffer_id_(0), |
1931 fixed_attrib_buffer_size_(0), | 1957 fixed_attrib_buffer_size_(0), |
1932 active_texture_unit_(0), | 1958 active_texture_unit_(0), |
1933 clear_red_(0), | 1959 clear_red_(0), |
1934 clear_green_(0), | 1960 clear_green_(0), |
1935 clear_blue_(0), | 1961 clear_blue_(0), |
1936 clear_alpha_(0), | 1962 clear_alpha_(0), |
1937 mask_red_(true), | 1963 mask_red_(true), |
1938 mask_green_(true), | 1964 mask_green_(true), |
1939 mask_blue_(true), | 1965 mask_blue_(true), |
1940 mask_alpha_(true), | 1966 mask_alpha_(true), |
1941 clear_stencil_(0), | 1967 clear_stencil_(0), |
1942 mask_stencil_front_(-1), | 1968 mask_stencil_front_(-1), |
1943 mask_stencil_back_(-1), | 1969 mask_stencil_back_(-1), |
1944 clear_depth_(1.0f), | 1970 clear_depth_(1.0f), |
1945 mask_depth_(true), | 1971 mask_depth_(true), |
1972 enable_cull_face_(false), | |
1946 enable_scissor_test_(false), | 1973 enable_scissor_test_(false), |
1947 enable_depth_test_(false), | 1974 enable_depth_test_(false), |
1948 enable_stencil_test_(false), | 1975 enable_stencil_test_(false), |
1949 state_dirty_(true), | 1976 state_dirty_(true), |
1950 offscreen_target_color_format_(0), | 1977 offscreen_target_color_format_(0), |
1951 offscreen_target_depth_format_(0), | 1978 offscreen_target_depth_format_(0), |
1952 offscreen_target_stencil_format_(0), | 1979 offscreen_target_stencil_format_(0), |
1953 offscreen_target_samples_(0), | 1980 offscreen_target_samples_(0), |
1954 offscreen_target_buffer_preserved_(true), | 1981 offscreen_target_buffer_preserved_(true), |
1955 offscreen_saved_color_format_(0), | 1982 offscreen_saved_color_format_(0), |
1956 stream_texture_manager_(NULL), | 1983 stream_texture_manager_(NULL), |
1957 back_buffer_color_format_(0), | 1984 back_buffer_color_format_(0), |
1958 back_buffer_has_depth_(false), | 1985 back_buffer_has_depth_(false), |
1959 back_buffer_has_stencil_(false), | 1986 back_buffer_has_stencil_(false), |
1960 teximage2d_faster_than_texsubimage2d_(true), | 1987 teximage2d_faster_than_texsubimage2d_(true), |
1961 bufferdata_faster_than_buffersubdata_(true), | 1988 bufferdata_faster_than_buffersubdata_(true), |
1962 current_decoder_error_(error::kNoError), | 1989 current_decoder_error_(error::kNoError), |
1963 use_shader_translator_(true), | 1990 use_shader_translator_(true), |
1964 validators_(group_->feature_info()->validators()), | 1991 validators_(group_->feature_info()->validators()), |
1965 feature_info_(group_->feature_info()), | 1992 feature_info_(group_->feature_info()), |
1966 tex_image_2d_failed_(false), | 1993 tex_image_2d_failed_(false), |
1967 frame_number_(0), | 1994 frame_number_(0), |
1968 has_arb_robustness_(false), | 1995 has_arb_robustness_(false), |
1969 reset_status_(GL_NO_ERROR), | 1996 reset_status_(GL_NO_ERROR), |
1970 needs_mac_nvidia_driver_workaround_(false), | 1997 needs_mac_nvidia_driver_workaround_(false), |
1971 needs_glsl_built_in_function_emulation_(false), | 1998 needs_glsl_built_in_function_emulation_(false), |
1972 force_webgl_glsl_validation_(false), | 1999 force_webgl_glsl_validation_(false), |
1973 derivatives_explicitly_enabled_(false), | 2000 derivatives_explicitly_enabled_(false), |
1974 compile_shader_always_succeeds_(false) { | 2001 compile_shader_always_succeeds_(false), |
2002 viewport_x_(0), | |
2003 viewport_y_(0), | |
2004 viewport_width_(0), | |
2005 viewport_height_(0), | |
2006 viewport_max_width_(0), | |
2007 viewport_max_height_(0) { | |
1975 DCHECK(group); | 2008 DCHECK(group); |
1976 | 2009 |
1977 attrib_0_value_.v[0] = 0.0f; | 2010 attrib_0_value_.v[0] = 0.0f; |
1978 attrib_0_value_.v[1] = 0.0f; | 2011 attrib_0_value_.v[1] = 0.0f; |
1979 attrib_0_value_.v[2] = 0.0f; | 2012 attrib_0_value_.v[2] = 0.0f; |
1980 attrib_0_value_.v[3] = 1.0f; | 2013 attrib_0_value_.v[3] = 1.0f; |
1981 | 2014 |
1982 // The shader translator is used for WebGL even when running on EGL | 2015 // The shader translator is used for WebGL even when running on EGL |
1983 // because additional restrictions are needed (like only enabling | 2016 // because additional restrictions are needed (like only enabling |
1984 // GL_OES_standard_derivatives on demand). It is used for the unit | 2017 // GL_OES_standard_derivatives on demand). It is used for the unit |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2039 return false; | 2072 return false; |
2040 } | 2073 } |
2041 | 2074 |
2042 if (!group_->Initialize(disallowed_features, allowed_extensions)) { | 2075 if (!group_->Initialize(disallowed_features, allowed_extensions)) { |
2043 LOG(ERROR) << "GpuScheduler::InitializeCommon failed because group " | 2076 LOG(ERROR) << "GpuScheduler::InitializeCommon failed because group " |
2044 << "failed to initialize."; | 2077 << "failed to initialize."; |
2045 group_ = NULL; // Must not destroy ContextGroup if it is not initialized. | 2078 group_ = NULL; // Must not destroy ContextGroup if it is not initialized. |
2046 Destroy(); | 2079 Destroy(); |
2047 return false; | 2080 return false; |
2048 } | 2081 } |
2082 CHECK_GL_ERROR(); | |
2049 | 2083 |
2084 copy_texture_CHROMIUM_.reset(new CopyTextureCHROMIUMResourceManager()); | |
2085 copy_texture_CHROMIUM_->Initialize(); | |
2050 CHECK_GL_ERROR(); | 2086 CHECK_GL_ERROR(); |
2087 | |
2051 disallowed_features_ = disallowed_features; | 2088 disallowed_features_ = disallowed_features; |
2052 | 2089 |
2053 vertex_attrib_manager_.reset(new VertexAttribManager()); | 2090 vertex_attrib_manager_.reset(new VertexAttribManager()); |
2054 vertex_attrib_manager_->Initialize(group_->max_vertex_attribs()); | 2091 vertex_attrib_manager_->Initialize(group_->max_vertex_attribs()); |
2055 | 2092 |
2056 query_manager_.reset(new QueryManager(this, feature_info_->feature_flags( | 2093 query_manager_.reset(new QueryManager(this, feature_info_->feature_flags( |
2057 ).use_arb_occlusion_query2_for_occlusion_query_boolean)); | 2094 ).use_arb_occlusion_query2_for_occlusion_query_boolean)); |
2058 | 2095 |
2059 util_.set_num_compressed_texture_formats( | 2096 util_.set_num_compressed_texture_formats( |
2060 validators_->compressed_texture_format.GetValues().size()); | 2097 validators_->compressed_texture_format.GetValues().size()); |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2263 #elif defined(OS_WIN) | 2300 #elif defined(OS_WIN) |
2264 if (gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2) | 2301 if (gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2) |
2265 needs_glsl_built_in_function_emulation_ = true; | 2302 needs_glsl_built_in_function_emulation_ = true; |
2266 #endif | 2303 #endif |
2267 } | 2304 } |
2268 | 2305 |
2269 if (!InitializeShaderTranslator()) { | 2306 if (!InitializeShaderTranslator()) { |
2270 return false; | 2307 return false; |
2271 } | 2308 } |
2272 | 2309 |
2310 GLint viewport_params[4]; | |
2311 glGetIntegerv(GL_VIEWPORT, viewport_params); | |
2312 viewport_x_ = viewport_params[0]; | |
2313 viewport_y_ = viewport_params[1]; | |
2314 viewport_width_ = viewport_params[2]; | |
2315 viewport_height_ = viewport_params[3]; | |
2316 | |
2317 glGetIntegerv(GL_MAX_VIEWPORT_DIMS, viewport_params); | |
2318 viewport_max_width_ = viewport_params[0]; | |
2319 viewport_max_height_ = viewport_params[0]; | |
2320 | |
2273 return true; | 2321 return true; |
2274 } | 2322 } |
2275 | 2323 |
2276 void GLES2DecoderImpl::UpdateCapabilities() { | 2324 void GLES2DecoderImpl::UpdateCapabilities() { |
2277 util_.set_num_compressed_texture_formats( | 2325 util_.set_num_compressed_texture_formats( |
2278 validators_->compressed_texture_format.GetValues().size()); | 2326 validators_->compressed_texture_format.GetValues().size()); |
2279 util_.set_num_shader_binary_formats( | 2327 util_.set_num_shader_binary_formats( |
2280 validators_->shader_binary_format.GetValues().size()); | 2328 validators_->shader_binary_format.GetValues().size()); |
2281 } | 2329 } |
2282 | 2330 |
(...skipping 1005 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3288 glColorMask( | 3336 glColorMask( |
3289 mask_red_, mask_green_, mask_blue_, | 3337 mask_red_, mask_green_, mask_blue_, |
3290 mask_alpha_ && BoundFramebufferHasColorAttachmentWithAlpha()); | 3338 mask_alpha_ && BoundFramebufferHasColorAttachmentWithAlpha()); |
3291 bool have_depth = BoundFramebufferHasDepthAttachment(); | 3339 bool have_depth = BoundFramebufferHasDepthAttachment(); |
3292 glDepthMask(mask_depth_ && have_depth); | 3340 glDepthMask(mask_depth_ && have_depth); |
3293 EnableDisable(GL_DEPTH_TEST, enable_depth_test_ && have_depth); | 3341 EnableDisable(GL_DEPTH_TEST, enable_depth_test_ && have_depth); |
3294 bool have_stencil = BoundFramebufferHasStencilAttachment(); | 3342 bool have_stencil = BoundFramebufferHasStencilAttachment(); |
3295 glStencilMaskSeparate(GL_FRONT, have_stencil ? mask_stencil_front_ : 0); | 3343 glStencilMaskSeparate(GL_FRONT, have_stencil ? mask_stencil_front_ : 0); |
3296 glStencilMaskSeparate(GL_BACK, have_stencil ? mask_stencil_back_ : 0); | 3344 glStencilMaskSeparate(GL_BACK, have_stencil ? mask_stencil_back_ : 0); |
3297 EnableDisable(GL_STENCIL_TEST, enable_stencil_test_ && have_stencil); | 3345 EnableDisable(GL_STENCIL_TEST, enable_stencil_test_ && have_stencil); |
3346 EnableDisable(GL_CULL_FACE, enable_cull_face_); | |
3347 EnableDisable(GL_SCISSOR_TEST, enable_scissor_test_); | |
3298 state_dirty_ = false; | 3348 state_dirty_ = false; |
3299 } | 3349 } |
3300 } | 3350 } |
3301 | 3351 |
3302 GLuint GLES2DecoderImpl::GetBackbufferServiceId() { | 3352 GLuint GLES2DecoderImpl::GetBackbufferServiceId() { |
3303 return (offscreen_target_frame_buffer_.get()) ? | 3353 return (offscreen_target_frame_buffer_.get()) ? |
3304 offscreen_target_frame_buffer_->id() : | 3354 offscreen_target_frame_buffer_->id() : |
3305 surface_->GetBackingFrameBufferObject(); | 3355 surface_->GetBackingFrameBufferObject(); |
3306 } | 3356 } |
3307 | 3357 |
(...skipping 782 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4090 if (error == GL_NO_ERROR) { | 4140 if (error == GL_NO_ERROR) { |
4091 framebuffer_info->AttachRenderbuffer(attachment, info); | 4141 framebuffer_info->AttachRenderbuffer(attachment, info); |
4092 } | 4142 } |
4093 if (framebuffer_info == bound_draw_framebuffer_) { | 4143 if (framebuffer_info == bound_draw_framebuffer_) { |
4094 state_dirty_ = true; | 4144 state_dirty_ = true; |
4095 } | 4145 } |
4096 } | 4146 } |
4097 | 4147 |
4098 bool GLES2DecoderImpl::SetCapabilityState(GLenum cap, bool enabled) { | 4148 bool GLES2DecoderImpl::SetCapabilityState(GLenum cap, bool enabled) { |
4099 switch (cap) { | 4149 switch (cap) { |
4150 case GL_CULL_FACE: | |
4151 enable_cull_face_ = enabled; | |
4152 return true; | |
4100 case GL_SCISSOR_TEST: | 4153 case GL_SCISSOR_TEST: |
4101 enable_scissor_test_ = enabled; | 4154 enable_scissor_test_ = enabled; |
4102 return true; | 4155 return true; |
4103 case GL_DEPTH_TEST: { | 4156 case GL_DEPTH_TEST: { |
4104 if (enable_depth_test_ != enabled) { | 4157 if (enable_depth_test_ != enabled) { |
4105 enable_depth_test_ = enabled; | 4158 enable_depth_test_ = enabled; |
4106 state_dirty_ = true; | 4159 state_dirty_ = true; |
4107 } | 4160 } |
4108 return false; | 4161 return false; |
4109 } | 4162 } |
(...skipping 1903 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6013 normalized, | 6066 normalized, |
6014 stride, | 6067 stride, |
6015 stride != 0 ? stride : component_size * size, | 6068 stride != 0 ? stride : component_size * size, |
6016 offset); | 6069 offset); |
6017 if (type != GL_FIXED) { | 6070 if (type != GL_FIXED) { |
6018 glVertexAttribPointer(indx, size, type, normalized, stride, ptr); | 6071 glVertexAttribPointer(indx, size, type, normalized, stride, ptr); |
6019 } | 6072 } |
6020 return error::kNoError; | 6073 return error::kNoError; |
6021 } | 6074 } |
6022 | 6075 |
6076 void GLES2DecoderImpl::DoViewport(GLint x, GLint y, GLsizei width, | |
6077 GLsizei height) { | |
6078 viewport_x_ = x; | |
6079 viewport_y_ = y; | |
6080 viewport_width_ = std::min(width, viewport_max_width_); | |
6081 viewport_height_ = std::min(height, viewport_max_height_); | |
6082 glViewport(x, y, width, height); | |
6083 } | |
6084 | |
6023 error::Error GLES2DecoderImpl::HandleVertexAttribDivisorANGLE( | 6085 error::Error GLES2DecoderImpl::HandleVertexAttribDivisorANGLE( |
6024 uint32 immediate_data_size, const gles2::VertexAttribDivisorANGLE& c) { | 6086 uint32 immediate_data_size, const gles2::VertexAttribDivisorANGLE& c) { |
6025 if (!feature_info_->feature_flags().angle_instanced_arrays) { | 6087 if (!feature_info_->feature_flags().angle_instanced_arrays) { |
6026 SetGLError(GL_INVALID_OPERATION, | 6088 SetGLError(GL_INVALID_OPERATION, |
6027 "glVertexAttribDivisorANGLE: function not available"); | 6089 "glVertexAttribDivisorANGLE: function not available"); |
6028 } | 6090 } |
6029 GLuint index = c.index; | 6091 GLuint index = c.index; |
6030 GLuint divisor = c.divisor; | 6092 GLuint divisor = c.divisor; |
6031 if (index >= group_->max_vertex_attribs()) { | 6093 if (index >= group_->max_vertex_attribs()) { |
6032 SetGLError(GL_INVALID_VALUE, | 6094 SetGLError(GL_INVALID_VALUE, |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6225 glPixelStorei(pname, param); | 6287 glPixelStorei(pname, param); |
6226 switch (pname) { | 6288 switch (pname) { |
6227 case GL_PACK_ALIGNMENT: | 6289 case GL_PACK_ALIGNMENT: |
6228 pack_alignment_ = param; | 6290 pack_alignment_ = param; |
6229 break; | 6291 break; |
6230 case GL_PACK_REVERSE_ROW_ORDER_ANGLE: | 6292 case GL_PACK_REVERSE_ROW_ORDER_ANGLE: |
6231 break; | 6293 break; |
6232 case GL_UNPACK_ALIGNMENT: | 6294 case GL_UNPACK_ALIGNMENT: |
6233 unpack_alignment_ = param; | 6295 unpack_alignment_ = param; |
6234 break; | 6296 break; |
6297 case GL_UNPACK_FLIP_Y_CHROMIUM: | |
6298 unpack_flip_y_ = (param != 0); | |
6299 break; | |
6300 case GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM: | |
6301 unpack_premultiply_alpha_ = (param != 0); | |
6302 break; | |
6235 default: | 6303 default: |
6236 // Validation should have prevented us from getting here. | 6304 // Validation should have prevented us from getting here. |
6237 NOTREACHED(); | 6305 NOTREACHED(); |
6238 break; | 6306 break; |
6239 } | 6307 } |
6240 return error::kNoError; | 6308 return error::kNoError; |
6241 } | 6309 } |
6242 | 6310 |
6243 error::Error GLES2DecoderImpl::HandlePostSubBufferCHROMIUM( | 6311 error::Error GLES2DecoderImpl::HandlePostSubBufferCHROMIUM( |
6244 uint32 immediate_data_size, const gles2::PostSubBufferCHROMIUM& c) { | 6312 uint32 immediate_data_size, const gles2::PostSubBufferCHROMIUM& c) { |
(...skipping 2059 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8304 return GL_LUMINANCE; | 8372 return GL_LUMINANCE; |
8305 case GL_LUMINANCE_ALPHA16F_EXT: | 8373 case GL_LUMINANCE_ALPHA16F_EXT: |
8306 return GL_LUMINANCE_ALPHA; | 8374 return GL_LUMINANCE_ALPHA; |
8307 case GL_BGRA8_EXT: | 8375 case GL_BGRA8_EXT: |
8308 return GL_BGRA_EXT; | 8376 return GL_BGRA_EXT; |
8309 default: | 8377 default: |
8310 return GL_NONE; | 8378 return GL_NONE; |
8311 } | 8379 } |
8312 } | 8380 } |
8313 | 8381 |
8382 void GLES2DecoderImpl::DoCopyTextureCHROMIUM( | |
8383 GLenum target, GLuint source_id, GLuint dest_id, GLint level) { | |
8384 TextureManager::TextureInfo* dest_info = GetTextureInfo(dest_id); | |
8385 TextureManager::TextureInfo* source_info = GetTextureInfo(source_id); | |
8386 | |
8387 if (!source_info || !dest_info) { | |
8388 SetGLError(GL_INVALID_VALUE, "glCopyTextureCHROMIUM: unknown texture id"); | |
8389 return; | |
8390 } | |
8391 | |
8392 if (GL_TEXTURE_2D != target) { | |
8393 SetGLError(GL_INVALID_VALUE, | |
8394 "glCopyTextureCHROMIUM: invalid texture target"); | |
8395 return; | |
8396 } | |
8397 | |
8398 int source_width, source_height, dest_width, dest_height; | |
8399 if (!source_info->GetLevelSize(GL_TEXTURE_2D, 0, &source_width, | |
8400 &source_height)) { | |
8401 SetGLError(GL_INVALID_VALUE, | |
8402 "glCopyTextureChromium: source texture has no level 0"); | |
8403 return; | |
8404 } | |
8405 | |
8406 if (!dest_info->GetLevelSize(GL_TEXTURE_2D, level,&dest_width,&dest_height)) { | |
8407 SetGLError(GL_INVALID_VALUE, | |
8408 "glCopyTextureChromium: destination texture has no level"); | |
8409 return; | |
8410 } | |
8411 | |
8412 // Resize the destination texture to the dimensions of the source texture. | |
8413 if (dest_width != source_width && dest_height != source_height) { | |
8414 GLenum type; | |
8415 GLenum internal_format; | |
8416 dest_info->GetLevelType(GL_TEXTURE_2D, level, &type, &internal_format); | |
8417 glTexImage2D(GL_TEXTURE_2D, level, internal_format, source_width, | |
8418 source_height, 0, GL_RGBA, type, NULL); | |
apatrick_chromium
2012/04/05 21:58:39
GL_RGBA -> internal_format. I don't know of any ex
Jeff Timanus
2012/04/13 00:13:29
Done.
| |
8419 | |
8420 // TODO: Update the size of the level in the TextureInfo struct. | |
8421 } | |
8422 | |
8423 state_dirty_ = true; | |
8424 glViewport(0, 0, dest_width, dest_height); | |
8425 copy_texture_CHROMIUM_->DoCopyTexture(target, source_info->service_id(), | |
8426 dest_info->service_id(), level, | |
8427 unpack_flip_y_, | |
8428 unpack_premultiply_alpha_); | |
8429 glViewport(viewport_x_, viewport_y_, viewport_width_, viewport_height_); | |
8430 | |
8431 // Restore all of the state touched by the extension. | |
8432 if (current_program_) | |
8433 glUseProgram(current_program_->service_id()); | |
apatrick_chromium
2012/04/05 21:58:39
If there was no program in use before, should prob
Jeff Timanus
2012/04/13 00:13:29
Done.
| |
8434 | |
8435 RestoreCurrentFramebufferBindings(); | |
8436 | |
8437 if (!bound_array_buffer_) | |
8438 glBindBuffer(GL_ARRAY_BUFFER, 0); | |
8439 else | |
8440 glBindBuffer(GL_ARRAY_BUFFER, bound_array_buffer_->service_id()); | |
8441 | |
8442 ApplyDirtyState(); | |
8443 } | |
8444 | |
8314 static GLenum ExtractTypeFromStorageFormat(GLenum internalformat) { | 8445 static GLenum ExtractTypeFromStorageFormat(GLenum internalformat) { |
8315 switch (internalformat) { | 8446 switch (internalformat) { |
8316 case GL_RGB565: | 8447 case GL_RGB565: |
8317 return GL_UNSIGNED_SHORT_5_6_5; | 8448 return GL_UNSIGNED_SHORT_5_6_5; |
8318 case GL_RGBA4: | 8449 case GL_RGBA4: |
8319 return GL_UNSIGNED_SHORT_4_4_4_4; | 8450 return GL_UNSIGNED_SHORT_4_4_4_4; |
8320 case GL_RGB5_A1: | 8451 case GL_RGB5_A1: |
8321 return GL_UNSIGNED_SHORT_5_5_5_1; | 8452 return GL_UNSIGNED_SHORT_5_5_5_1; |
8322 case GL_RGB8_OES: | 8453 case GL_RGB8_OES: |
8323 return GL_UNSIGNED_BYTE; | 8454 return GL_UNSIGNED_BYTE; |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8401 } | 8532 } |
8402 } | 8533 } |
8403 | 8534 |
8404 // Include the auto-generated part of this file. We split this because it means | 8535 // Include the auto-generated part of this file. We split this because it means |
8405 // we can easily edit the non-auto generated parts right here in this file | 8536 // we can easily edit the non-auto generated parts right here in this file |
8406 // instead of having to edit some template or the code generator. | 8537 // instead of having to edit some template or the code generator. |
8407 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 8538 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
8408 | 8539 |
8409 } // namespace gles2 | 8540 } // namespace gles2 |
8410 } // namespace gpu | 8541 } // namespace gpu |
OLD | NEW |