Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(302)

Side by Side Diff: gpu/command_buffer/service/gles2_cmd_decoder.cc

Issue 7304002: Correct reporting of compressed texture formats and shader binary formats (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 759 matching lines...) Expand 10 before | Expand all | Expand 10 after
770 TextureManager::TextureInfo::Ref bound_texture_2d; 770 TextureManager::TextureInfo::Ref bound_texture_2d;
771 771
772 // texture currently bound to this unit's GL_TEXTURE_CUBE_MAP with 772 // texture currently bound to this unit's GL_TEXTURE_CUBE_MAP with
773 // glBindTexture 773 // glBindTexture
774 TextureManager::TextureInfo::Ref bound_texture_cube_map; 774 TextureManager::TextureInfo::Ref bound_texture_cube_map;
775 }; 775 };
776 776
777 // Initialize or re-initialize the shader translator. 777 // Initialize or re-initialize the shader translator.
778 bool InitializeShaderTranslator(); 778 bool InitializeShaderTranslator();
779 779
780 void UpdateCapabilities();
781
780 // Helpers for the glGen and glDelete functions. 782 // Helpers for the glGen and glDelete functions.
781 bool GenTexturesHelper(GLsizei n, const GLuint* client_ids); 783 bool GenTexturesHelper(GLsizei n, const GLuint* client_ids);
782 void DeleteTexturesHelper(GLsizei n, const GLuint* client_ids); 784 void DeleteTexturesHelper(GLsizei n, const GLuint* client_ids);
783 bool GenBuffersHelper(GLsizei n, const GLuint* client_ids); 785 bool GenBuffersHelper(GLsizei n, const GLuint* client_ids);
784 void DeleteBuffersHelper(GLsizei n, const GLuint* client_ids); 786 void DeleteBuffersHelper(GLsizei n, const GLuint* client_ids);
785 bool GenFramebuffersHelper(GLsizei n, const GLuint* client_ids); 787 bool GenFramebuffersHelper(GLsizei n, const GLuint* client_ids);
786 void DeleteFramebuffersHelper(GLsizei n, const GLuint* client_ids); 788 void DeleteFramebuffersHelper(GLsizei n, const GLuint* client_ids);
787 bool GenRenderbuffersHelper(GLsizei n, const GLuint* client_ids); 789 bool GenRenderbuffersHelper(GLsizei n, const GLuint* client_ids);
788 void DeleteRenderbuffersHelper(GLsizei n, const GLuint* client_ids); 790 void DeleteRenderbuffersHelper(GLsizei n, const GLuint* client_ids);
789 791
(...skipping 1054 matching lines...) Expand 10 before | Expand all | Expand 10 after
1844 ContextGroup* group) { 1846 ContextGroup* group) {
1845 return new GLES2DecoderImpl(surface_manager, group); 1847 return new GLES2DecoderImpl(surface_manager, group);
1846 } 1848 }
1847 1849
1848 GLES2DecoderImpl::GLES2DecoderImpl(SurfaceManager* surface_manager, 1850 GLES2DecoderImpl::GLES2DecoderImpl(SurfaceManager* surface_manager,
1849 ContextGroup* group) 1851 ContextGroup* group)
1850 : GLES2Decoder(), 1852 : GLES2Decoder(),
1851 surface_manager_(surface_manager), 1853 surface_manager_(surface_manager),
1852 group_(ContextGroup::Ref(group ? group : new ContextGroup())), 1854 group_(ContextGroup::Ref(group ? group : new ContextGroup())),
1853 error_bits_(0), 1855 error_bits_(0),
1854 util_(0), // TODO(gman): Set to actual num compress texture formats.
1855 pack_alignment_(4), 1856 pack_alignment_(4),
1856 unpack_alignment_(4), 1857 unpack_alignment_(4),
1857 attrib_0_buffer_id_(0), 1858 attrib_0_buffer_id_(0),
1858 attrib_0_buffer_matches_value_(true), 1859 attrib_0_buffer_matches_value_(true),
1859 attrib_0_size_(0), 1860 attrib_0_size_(0),
1860 fixed_attrib_buffer_id_(0), 1861 fixed_attrib_buffer_id_(0),
1861 fixed_attrib_buffer_size_(0), 1862 fixed_attrib_buffer_size_(0),
1862 active_texture_unit_(0), 1863 active_texture_unit_(0),
1863 clear_red_(0), 1864 clear_red_(0),
1864 clear_green_(0), 1865 clear_green_(0),
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
1951 << "failed to initialize."; 1952 << "failed to initialize.";
1952 Destroy(); 1953 Destroy();
1953 return false; 1954 return false;
1954 } 1955 }
1955 1956
1956 CHECK_GL_ERROR(); 1957 CHECK_GL_ERROR();
1957 disallowed_extensions_ = disallowed_extensions; 1958 disallowed_extensions_ = disallowed_extensions;
1958 1959
1959 vertex_attrib_manager_.Initialize(group_->max_vertex_attribs()); 1960 vertex_attrib_manager_.Initialize(group_->max_vertex_attribs());
1960 1961
1962 util_.set_num_compressed_texture_formats(
1963 validators_->compressed_texture_format.GetValues().size());
1964
1961 if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) { 1965 if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) {
1962 // We have to enable vertex array 0 on OpenGL or it won't render. Note that 1966 // We have to enable vertex array 0 on OpenGL or it won't render. Note that
1963 // OpenGL ES 2.0 does not have this issue. 1967 // OpenGL ES 2.0 does not have this issue.
1964 glEnableVertexAttribArray(0); 1968 glEnableVertexAttribArray(0);
1965 } 1969 }
1966 glGenBuffersARB(1, &attrib_0_buffer_id_); 1970 glGenBuffersARB(1, &attrib_0_buffer_id_);
1967 glBindBuffer(GL_ARRAY_BUFFER, attrib_0_buffer_id_); 1971 glBindBuffer(GL_ARRAY_BUFFER, attrib_0_buffer_id_);
1968 glVertexAttribPointer(0, 1, GL_FLOAT, GL_FALSE, 0, NULL); 1972 glVertexAttribPointer(0, 1, GL_FLOAT, GL_FALSE, 0, NULL);
1969 glBindBuffer(GL_ARRAY_BUFFER, 0); 1973 glBindBuffer(GL_ARRAY_BUFFER, 0);
1970 glGenBuffersARB(1, &fixed_attrib_buffer_id_); 1974 glGenBuffersARB(1, &fixed_attrib_buffer_id_);
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
2138 glEnable(GL_POINT_SPRITE); 2142 glEnable(GL_POINT_SPRITE);
2139 } 2143 }
2140 2144
2141 if (!InitializeShaderTranslator()) { 2145 if (!InitializeShaderTranslator()) {
2142 return false; 2146 return false;
2143 } 2147 }
2144 2148
2145 return true; 2149 return true;
2146 } 2150 }
2147 2151
2152 void GLES2DecoderImpl::UpdateCapabilities() {
2153 util_.set_num_compressed_texture_formats(
2154 validators_->compressed_texture_format.GetValues().size());
2155 util_.set_num_shader_binary_formats(
2156 validators_->shader_binary_format.GetValues().size());
2157 }
2158
2148 bool GLES2DecoderImpl::InitializeShaderTranslator() { 2159 bool GLES2DecoderImpl::InitializeShaderTranslator() {
2149 // Re-check the state of use_shader_translator_ each time this is called. 2160 // Re-check the state of use_shader_translator_ each time this is called.
2150 if (gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2 && 2161 if (gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2 &&
2151 feature_info_->feature_flags().chromium_webglsl && 2162 feature_info_->feature_flags().chromium_webglsl &&
2152 !use_shader_translator_) { 2163 !use_shader_translator_) {
2153 use_shader_translator_ = true; 2164 use_shader_translator_ = true;
2154 } 2165 }
2155 if (!use_shader_translator_) { 2166 if (!use_shader_translator_) {
2156 return true; 2167 return true;
2157 } 2168 }
(...skipping 1031 matching lines...) Expand 10 before | Expand all | Expand 10 after
3189 return true; 3200 return true;
3190 case GL_STENCIL_BITS: 3201 case GL_STENCIL_BITS:
3191 *num_written = 1; 3202 *num_written = 1;
3192 if (params) { 3203 if (params) {
3193 GLint v = 0; 3204 GLint v = 0;
3194 glGetIntegerv(GL_STENCIL_BITS, &v); 3205 glGetIntegerv(GL_STENCIL_BITS, &v);
3195 params[0] = BoundFramebufferHasStencilAttachment() ? v : 0; 3206 params[0] = BoundFramebufferHasStencilAttachment() ? v : 0;
3196 } 3207 }
3197 return true; 3208 return true;
3198 case GL_COMPRESSED_TEXTURE_FORMATS: 3209 case GL_COMPRESSED_TEXTURE_FORMATS:
3199 *num_written = 0; 3210 *num_written = validators_->compressed_texture_format.GetValues().size();
3200 // We don't support compressed textures. 3211 if (params) {
3212 for (GLint ii = 0; ii < *num_written; ++ii) {
3213 params[ii] = validators_->compressed_texture_format.GetValues()[ii];
3214 }
3215 }
3201 return true; 3216 return true;
3202 case GL_NUM_COMPRESSED_TEXTURE_FORMATS: 3217 case GL_NUM_COMPRESSED_TEXTURE_FORMATS:
3203 *num_written = 1; 3218 *num_written = 1;
3204 if (params) { 3219 if (params) {
3205 *params = 0; // We don't support compressed textures. 3220 *params = validators_->compressed_texture_format.GetValues().size();
3206 } 3221 }
3207 return true; 3222 return true;
3208 case GL_NUM_SHADER_BINARY_FORMATS: 3223 case GL_NUM_SHADER_BINARY_FORMATS:
3209 *num_written = 1; 3224 *num_written = 1;
3210 if (params) { 3225 if (params) {
3211 *params = 0; // We don't support binary shader formats. 3226 *params = validators_->shader_binary_format.GetValues().size();
3212 } 3227 }
3213 return true; 3228 return true;
3214 case GL_SHADER_BINARY_FORMATS: 3229 case GL_SHADER_BINARY_FORMATS:
3215 *num_written = 0; 3230 *num_written = validators_->shader_binary_format.GetValues().size();
3216 return true; // We don't support binary shader format.s 3231 if (params) {
3232 for (GLint ii = 0; ii < *num_written; ++ii) {
3233 params[ii] = validators_->shader_binary_format.GetValues()[ii];
3234 }
3235 }
3236 return true;
3217 case GL_SHADER_COMPILER: 3237 case GL_SHADER_COMPILER:
3218 *num_written = 1; 3238 *num_written = 1;
3219 if (params) { 3239 if (params) {
3220 *params = GL_TRUE; 3240 *params = GL_TRUE;
3221 } 3241 }
3222 return true; 3242 return true;
3223 case GL_ARRAY_BUFFER_BINDING: 3243 case GL_ARRAY_BUFFER_BINDING:
3224 *num_written = 1; 3244 *num_written = 1;
3225 if (params) { 3245 if (params) {
3226 if (bound_array_buffer_) { 3246 if (bound_array_buffer_) {
(...skipping 3621 matching lines...) Expand 10 before | Expand all | Expand 10 after
6848 6868
6849 // If we just enabled a feature which affects the shader translator, 6869 // If we just enabled a feature which affects the shader translator,
6850 // we may need to re-initialize it. 6870 // we may need to re-initialize it.
6851 if (std_derivatives_enabled != 6871 if (std_derivatives_enabled !=
6852 feature_info_->feature_flags().oes_standard_derivatives || 6872 feature_info_->feature_flags().oes_standard_derivatives ||
6853 webglsl_enabled != 6873 webglsl_enabled !=
6854 feature_info_->feature_flags().chromium_webglsl) { 6874 feature_info_->feature_flags().chromium_webglsl) {
6855 InitializeShaderTranslator(); 6875 InitializeShaderTranslator();
6856 } 6876 }
6857 6877
6878 UpdateCapabilities();
6879
6858 return error::kNoError; 6880 return error::kNoError;
6859 } 6881 }
6860 6882
6861 error::Error GLES2DecoderImpl::HandleGetMultipleIntegervCHROMIUM( 6883 error::Error GLES2DecoderImpl::HandleGetMultipleIntegervCHROMIUM(
6862 uint32 immediate_data_size, const gles2::GetMultipleIntegervCHROMIUM& c) { 6884 uint32 immediate_data_size, const gles2::GetMultipleIntegervCHROMIUM& c) {
6863 GLuint count = c.count; 6885 GLuint count = c.count;
6864 uint32 pnames_size; 6886 uint32 pnames_size;
6865 if (!SafeMultiplyUint32(count, sizeof(GLenum), &pnames_size)) { 6887 if (!SafeMultiplyUint32(count, sizeof(GLenum), &pnames_size)) {
6866 return error::kOutOfBounds; 6888 return error::kOutOfBounds;
6867 } 6889 }
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
6935 return error::kNoError; 6957 return error::kNoError;
6936 } 6958 }
6937 6959
6938 // Include the auto-generated part of this file. We split this because it means 6960 // Include the auto-generated part of this file. We split this because it means
6939 // we can easily edit the non-auto generated parts right here in this file 6961 // we can easily edit the non-auto generated parts right here in this file
6940 // instead of having to edit some template or the code generator. 6962 // instead of having to edit some template or the code generator.
6941 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 6963 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
6942 6964
6943 } // namespace gles2 6965 } // namespace gles2
6944 } // namespace gpu 6966 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/common/gles2_cmd_utils_unittest.cc ('k') | gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698