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

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

Issue 139013008: Implement support for rendering to 32-bit float textures on ES3 (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Check that framebuffers really are supported and add tests Created 6 years, 10 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
OLDNEW
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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 extern uint64 CityHash64(const char*, size_t); 73 extern uint64 CityHash64(const char*, size_t);
74 74
75 namespace gpu { 75 namespace gpu {
76 namespace gles2 { 76 namespace gles2 {
77 77
78 namespace { 78 namespace {
79 79
80 static const char kOESDerivativeExtension[] = "GL_OES_standard_derivatives"; 80 static const char kOESDerivativeExtension[] = "GL_OES_standard_derivatives";
81 static const char kEXTFragDepthExtension[] = "GL_EXT_frag_depth"; 81 static const char kEXTFragDepthExtension[] = "GL_EXT_frag_depth";
82 static const char kEXTDrawBuffersExtension[] = "GL_EXT_draw_buffers"; 82 static const char kEXTDrawBuffersExtension[] = "GL_EXT_draw_buffers";
83 static const char kCHROMIUMColorBufferFloatExtension[] =
84 "GL_CHROMIUM_color_buffer_float";
83 85
84 #if !defined(ANGLE_SH_VERSION) || ANGLE_SH_VERSION < 108 86 #if !defined(ANGLE_SH_VERSION) || ANGLE_SH_VERSION < 108
85 khronos_uint64_t CityHashForAngle(const char* name, unsigned int len) { 87 khronos_uint64_t CityHashForAngle(const char* name, unsigned int len) {
86 return static_cast<khronos_uint64_t>( 88 return static_cast<khronos_uint64_t>(
87 CityHash64(name, static_cast<size_t>(len))); 89 CityHash64(name, static_cast<size_t>(len)));
88 } 90 }
89 #endif 91 #endif
90 92
91 static bool PrecisionMeetsSpecForHighpFloat(GLint rangeMin, 93 static bool PrecisionMeetsSpecForHighpFloat(GLint rangeMin,
92 GLint rangeMax, 94 GLint rangeMax,
(...skipping 1568 matching lines...) Expand 10 before | Expand all | Expand 10 after
1661 1663
1662 // These flags are used to override the state of the shared feature_info_ 1664 // These flags are used to override the state of the shared feature_info_
1663 // member. Because the same FeatureInfo instance may be shared among many 1665 // member. Because the same FeatureInfo instance may be shared among many
1664 // contexts, the assumptions on the availablity of extensions in WebGL 1666 // contexts, the assumptions on the availablity of extensions in WebGL
1665 // contexts may be broken. These flags override the shared state to preserve 1667 // contexts may be broken. These flags override the shared state to preserve
1666 // WebGL semantics. 1668 // WebGL semantics.
1667 bool force_webgl_glsl_validation_; 1669 bool force_webgl_glsl_validation_;
1668 bool derivatives_explicitly_enabled_; 1670 bool derivatives_explicitly_enabled_;
1669 bool frag_depth_explicitly_enabled_; 1671 bool frag_depth_explicitly_enabled_;
1670 bool draw_buffers_explicitly_enabled_; 1672 bool draw_buffers_explicitly_enabled_;
1673 bool chromium_color_buffer_float_explicitly_enabled_;
piman 2014/02/07 00:43:10 I don't think we need this. Since we decided that
oetuaho-nv 2014/02/07 09:26:58 Okay. I just got the idea from earlier reviews tha
1671 1674
1672 bool compile_shader_always_succeeds_; 1675 bool compile_shader_always_succeeds_;
1673 1676
1674 // Log extra info. 1677 // Log extra info.
1675 bool service_logging_; 1678 bool service_logging_;
1676 1679
1677 #if defined(OS_MACOSX) 1680 #if defined(OS_MACOSX)
1678 typedef std::map<GLuint, CFTypeRef> TextureToIOSurfaceMap; 1681 typedef std::map<GLuint, CFTypeRef> TextureToIOSurfaceMap;
1679 TextureToIOSurfaceMap texture_to_io_surface_map_; 1682 TextureToIOSurfaceMap texture_to_io_surface_map_;
1680 #endif 1683 #endif
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after
2160 validators_(group_->feature_info()->validators()), 2163 validators_(group_->feature_info()->validators()),
2161 feature_info_(group_->feature_info()), 2164 feature_info_(group_->feature_info()),
2162 frame_number_(0), 2165 frame_number_(0),
2163 has_robustness_extension_(false), 2166 has_robustness_extension_(false),
2164 reset_status_(GL_NO_ERROR), 2167 reset_status_(GL_NO_ERROR),
2165 reset_by_robustness_extension_(false), 2168 reset_by_robustness_extension_(false),
2166 force_webgl_glsl_validation_(false), 2169 force_webgl_glsl_validation_(false),
2167 derivatives_explicitly_enabled_(false), 2170 derivatives_explicitly_enabled_(false),
2168 frag_depth_explicitly_enabled_(false), 2171 frag_depth_explicitly_enabled_(false),
2169 draw_buffers_explicitly_enabled_(false), 2172 draw_buffers_explicitly_enabled_(false),
2173 chromium_color_buffer_float_explicitly_enabled_(false),
2170 compile_shader_always_succeeds_(false), 2174 compile_shader_always_succeeds_(false),
2171 service_logging_(CommandLine::ForCurrentProcess()->HasSwitch( 2175 service_logging_(CommandLine::ForCurrentProcess()->HasSwitch(
2172 switches::kEnableGPUServiceLoggingGPU)), 2176 switches::kEnableGPUServiceLoggingGPU)),
2173 viewport_max_width_(0), 2177 viewport_max_width_(0),
2174 viewport_max_height_(0), 2178 viewport_max_height_(0),
2175 texture_state_(group_->feature_info() 2179 texture_state_(group_->feature_info()
2176 ->workarounds() 2180 ->workarounds()
2177 .texsubimage2d_faster_than_teximage2d), 2181 .texsubimage2d_faster_than_teximage2d),
2178 validation_texture_(0), 2182 validation_texture_(0),
2179 validation_fbo_multisample_(0), 2183 validation_fbo_multisample_(0),
(...skipping 772 matching lines...) Expand 10 before | Expand all | Expand 10 after
2952 backbuffer_needs_clear_bits_ = 0; 2956 backbuffer_needs_clear_bits_ = 0;
2953 RestoreClearState(); 2957 RestoreClearState();
2954 } 2958 }
2955 return true; 2959 return true;
2956 } 2960 }
2957 2961
2958 if (framebuffer_manager()->IsComplete(framebuffer)) { 2962 if (framebuffer_manager()->IsComplete(framebuffer)) {
2959 return true; 2963 return true;
2960 } 2964 }
2961 2965
2962 GLenum completeness = framebuffer->IsPossiblyComplete(); 2966 GLenum completeness = framebuffer->IsPossiblyComplete(
2967 chromium_color_buffer_float_explicitly_enabled_);
2963 if (completeness != GL_FRAMEBUFFER_COMPLETE) { 2968 if (completeness != GL_FRAMEBUFFER_COMPLETE) {
2964 LOCAL_SET_GL_ERROR( 2969 LOCAL_SET_GL_ERROR(
2965 GL_INVALID_FRAMEBUFFER_OPERATION, func_name, "framebuffer incomplete"); 2970 GL_INVALID_FRAMEBUFFER_OPERATION, func_name, "framebuffer incomplete");
2966 return false; 2971 return false;
2967 } 2972 }
2968 2973
2969 // Are all the attachments cleared? 2974 // Are all the attachments cleared?
2970 if (renderbuffer_manager()->HaveUnclearedRenderbuffers() || 2975 if (renderbuffer_manager()->HaveUnclearedRenderbuffers() ||
2971 texture_manager()->HaveUnclearedMips()) { 2976 texture_manager()->HaveUnclearedMips()) {
2972 if (!framebuffer->IsCleared()) { 2977 if (!framebuffer->IsCleared()) {
(...skipping 1915 matching lines...) Expand 10 before | Expand all | Expand 10 after
4888 glEnable(GL_SCISSOR_TEST); 4893 glEnable(GL_SCISSOR_TEST);
4889 } 4894 }
4890 } 4895 }
4891 4896
4892 GLenum GLES2DecoderImpl::DoCheckFramebufferStatus(GLenum target) { 4897 GLenum GLES2DecoderImpl::DoCheckFramebufferStatus(GLenum target) {
4893 Framebuffer* framebuffer = 4898 Framebuffer* framebuffer =
4894 GetFramebufferInfoForTarget(target); 4899 GetFramebufferInfoForTarget(target);
4895 if (!framebuffer) { 4900 if (!framebuffer) {
4896 return GL_FRAMEBUFFER_COMPLETE; 4901 return GL_FRAMEBUFFER_COMPLETE;
4897 } 4902 }
4898 GLenum completeness = framebuffer->IsPossiblyComplete(); 4903 GLenum completeness = framebuffer->IsPossiblyComplete(
4904 chromium_color_buffer_float_explicitly_enabled_);
4899 if (completeness != GL_FRAMEBUFFER_COMPLETE) { 4905 if (completeness != GL_FRAMEBUFFER_COMPLETE) {
4900 return completeness; 4906 return completeness;
4901 } 4907 }
4902 return framebuffer->GetStatus(texture_manager(), target); 4908 return framebuffer->GetStatus(texture_manager(), target);
4903 } 4909 }
4904 4910
4905 void GLES2DecoderImpl::DoFramebufferTexture2D( 4911 void GLES2DecoderImpl::DoFramebufferTexture2D(
4906 GLenum target, GLenum attachment, GLenum textarget, 4912 GLenum target, GLenum attachment, GLenum textarget,
4907 GLuint client_texture_id, GLint level) { 4913 GLuint client_texture_id, GLint level) {
4908 DoFramebufferTexture2DCommon( 4914 DoFramebufferTexture2DCommon(
(...skipping 2684 matching lines...) Expand 10 before | Expand all | Expand 10 after
7593 if (!draw_buffers_explicitly_enabled_) { 7599 if (!draw_buffers_explicitly_enabled_) {
7594 size_t offset = extensions.find(kEXTDrawBuffersExtension); 7600 size_t offset = extensions.find(kEXTDrawBuffersExtension);
7595 if (std::string::npos != offset) { 7601 if (std::string::npos != offset) {
7596 extensions.replace(offset, arraysize(kEXTDrawBuffersExtension), 7602 extensions.replace(offset, arraysize(kEXTDrawBuffersExtension),
7597 std::string()); 7603 std::string());
7598 } 7604 }
7599 } 7605 }
7600 } else { 7606 } else {
7601 extensions = feature_info_->extensions().c_str(); 7607 extensions = feature_info_->extensions().c_str();
7602 } 7608 }
7609 // Strip out CHROMIUM_color_buffer_float for all contexts that have
7610 // not enabled it to emulate GLES2 more closely.
7611 if (!chromium_color_buffer_float_explicitly_enabled_) {
7612 size_t offset = extensions.find(
7613 kCHROMIUMColorBufferFloatExtension);
7614 if (std::string::npos != offset) {
7615 extensions.replace(offset,
7616 arraysize(kCHROMIUMColorBufferFloatExtension),
7617 std::string());
7618 }
7619 }
7603 std::string surface_extensions = surface_->GetExtensions(); 7620 std::string surface_extensions = surface_->GetExtensions();
7604 if (!surface_extensions.empty()) 7621 if (!surface_extensions.empty())
7605 extensions += " " + surface_extensions; 7622 extensions += " " + surface_extensions;
7606 str = extensions.c_str(); 7623 str = extensions.c_str();
7607 } 7624 }
7608 break; 7625 break;
7609 default: 7626 default:
7610 break; 7627 break;
7611 } 7628 }
7612 Bucket* bucket = CreateBucket(c.bucket_id); 7629 Bucket* bucket = CreateBucket(c.bucket_id);
(...skipping 1446 matching lines...) Expand 10 before | Expand all | Expand 10 after
9059 uint32 immediate_data_size, const cmds::RequestExtensionCHROMIUM& c) { 9076 uint32 immediate_data_size, const cmds::RequestExtensionCHROMIUM& c) {
9060 Bucket* bucket = GetBucket(c.bucket_id); 9077 Bucket* bucket = GetBucket(c.bucket_id);
9061 if (!bucket || bucket->size() == 0) { 9078 if (!bucket || bucket->size() == 0) {
9062 return error::kInvalidArguments; 9079 return error::kInvalidArguments;
9063 } 9080 }
9064 std::string feature_str; 9081 std::string feature_str;
9065 if (!bucket->GetAsString(&feature_str)) { 9082 if (!bucket->GetAsString(&feature_str)) {
9066 return error::kInvalidArguments; 9083 return error::kInvalidArguments;
9067 } 9084 }
9068 9085
9086 bool desire_chromium_color_buffer_float =
9087 feature_str.find("GL_CHROMIUM_color_buffer_float") != std::string::npos;
9088
9089 if (desire_chromium_color_buffer_float &&
9090 feature_info_->feature_flags().chromium_color_buffer_float) {
9091 chromium_color_buffer_float_explicitly_enabled_ = true;
9092 }
9093
9069 bool desire_webgl_glsl_validation = 9094 bool desire_webgl_glsl_validation =
9070 feature_str.find("GL_CHROMIUM_webglsl") != std::string::npos; 9095 feature_str.find("GL_CHROMIUM_webglsl") != std::string::npos;
9071 bool desire_standard_derivatives = false; 9096 bool desire_standard_derivatives = false;
9072 bool desire_frag_depth = false; 9097 bool desire_frag_depth = false;
9073 bool desire_draw_buffers = false; 9098 bool desire_draw_buffers = false;
9074 if (force_webgl_glsl_validation_) { 9099 if (force_webgl_glsl_validation_) {
9075 desire_standard_derivatives = 9100 desire_standard_derivatives =
9076 feature_str.find("GL_OES_standard_derivatives") != std::string::npos; 9101 feature_str.find("GL_OES_standard_derivatives") != std::string::npos;
9077 desire_frag_depth = 9102 desire_frag_depth =
9078 feature_str.find("GL_EXT_frag_depth") != std::string::npos; 9103 feature_str.find("GL_EXT_frag_depth") != std::string::npos;
(...skipping 1437 matching lines...) Expand 10 before | Expand all | Expand 10 after
10516 DoDidUseTexImageIfNeeded(texture, texture->target()); 10541 DoDidUseTexImageIfNeeded(texture, texture->target());
10517 } 10542 }
10518 10543
10519 // Include the auto-generated part of this file. We split this because it means 10544 // Include the auto-generated part of this file. We split this because it means
10520 // we can easily edit the non-auto generated parts right here in this file 10545 // we can easily edit the non-auto generated parts right here in this file
10521 // instead of having to edit some template or the code generator. 10546 // instead of having to edit some template or the code generator.
10522 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 10547 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
10523 10548
10524 } // namespace gles2 10549 } // namespace gles2
10525 } // namespace gpu 10550 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698