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

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

Issue 12545014: Implement EXT_draw_buffers WebGL extention support in command buffer. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 9 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) 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 907 matching lines...) Expand 10 before | Expand all | Expand 10 after
918 918
919 void DoBindTexImage2DCHROMIUM( 919 void DoBindTexImage2DCHROMIUM(
920 GLenum target, 920 GLenum target,
921 GLint image_id); 921 GLint image_id);
922 void DoReleaseTexImage2DCHROMIUM( 922 void DoReleaseTexImage2DCHROMIUM(
923 GLenum target, 923 GLenum target,
924 GLint image_id); 924 GLint image_id);
925 925
926 void DoTraceEndCHROMIUM(void); 926 void DoTraceEndCHROMIUM(void);
927 927
928 void DoDrawBuffersEXT(GLsizei count, const GLenum* bufs);
929
928 // Creates a Program for the given program. 930 // Creates a Program for the given program.
929 Program* CreateProgram( 931 Program* CreateProgram(
930 GLuint client_id, GLuint service_id) { 932 GLuint client_id, GLuint service_id) {
931 return program_manager()->CreateProgram(client_id, service_id); 933 return program_manager()->CreateProgram(client_id, service_id);
932 } 934 }
933 935
934 // Gets the program info for the given program. Returns NULL if none exists. 936 // Gets the program info for the given program. Returns NULL if none exists.
935 Program* GetProgram(GLuint client_id) { 937 Program* GetProgram(GLuint client_id) {
936 return program_manager()->GetProgram(client_id); 938 return program_manager()->GetProgram(client_id);
937 } 939 }
(...skipping 1652 matching lines...) Expand 10 before | Expand all | Expand 10 after
2590 resources.MaxVertexAttribs = group_->max_vertex_attribs(); 2592 resources.MaxVertexAttribs = group_->max_vertex_attribs();
2591 resources.MaxVertexUniformVectors = 2593 resources.MaxVertexUniformVectors =
2592 group_->max_vertex_uniform_vectors(); 2594 group_->max_vertex_uniform_vectors();
2593 resources.MaxVaryingVectors = group_->max_varying_vectors(); 2595 resources.MaxVaryingVectors = group_->max_varying_vectors();
2594 resources.MaxVertexTextureImageUnits = 2596 resources.MaxVertexTextureImageUnits =
2595 group_->max_vertex_texture_image_units(); 2597 group_->max_vertex_texture_image_units();
2596 resources.MaxCombinedTextureImageUnits = group_->max_texture_units(); 2598 resources.MaxCombinedTextureImageUnits = group_->max_texture_units();
2597 resources.MaxTextureImageUnits = group_->max_texture_image_units(); 2599 resources.MaxTextureImageUnits = group_->max_texture_image_units();
2598 resources.MaxFragmentUniformVectors = 2600 resources.MaxFragmentUniformVectors =
2599 group_->max_fragment_uniform_vectors(); 2601 group_->max_fragment_uniform_vectors();
2600 resources.MaxDrawBuffers = 1; 2602 resources.MaxDrawBuffers = group_->max_draw_buffers();
2601 2603
2602 #if (ANGLE_SH_VERSION >= 110) 2604 #if (ANGLE_SH_VERSION >= 110)
2603 GLint range[2]; 2605 GLint range[2];
2604 GLint precision = 0; 2606 GLint precision = 0;
2605 GetShaderPrecisionFormatImpl(GL_FRAGMENT_SHADER, GL_HIGH_FLOAT, 2607 GetShaderPrecisionFormatImpl(GL_FRAGMENT_SHADER, GL_HIGH_FLOAT,
2606 range, &precision); 2608 range, &precision);
2607 resources.FragmentPrecisionHigh = ((range[0] >= 62) && 2609 resources.FragmentPrecisionHigh = ((range[0] >= 62) &&
2608 (range[1] >= 62) && 2610 (range[1] >= 62) &&
2609 (precision >= 16)); 2611 (precision >= 16));
2610 #endif 2612 #endif
2611 2613
2612 if (force_webgl_glsl_validation_) { 2614 if (force_webgl_glsl_validation_) {
2613 resources.OES_standard_derivatives = derivatives_explicitly_enabled_; 2615 resources.OES_standard_derivatives = derivatives_explicitly_enabled_;
2614 } else { 2616 } else {
2615 resources.OES_standard_derivatives = 2617 resources.OES_standard_derivatives =
2616 features().oes_standard_derivatives ? 1 : 0; 2618 features().oes_standard_derivatives ? 1 : 0;
2617 resources.ARB_texture_rectangle = 2619 resources.ARB_texture_rectangle =
2618 features().arb_texture_rectangle ? 1 : 0; 2620 features().arb_texture_rectangle ? 1 : 0;
2619 resources.OES_EGL_image_external = 2621 resources.OES_EGL_image_external =
2620 features().oes_egl_image_external ? 1 : 0; 2622 features().oes_egl_image_external ? 1 : 0;
2623 resources.EXT_draw_buffers =
2624 features().ext_draw_buffers ? 1 : 0;
2621 } 2625 }
2622 2626
2623 ShShaderSpec shader_spec = force_webgl_glsl_validation_ || 2627 ShShaderSpec shader_spec = force_webgl_glsl_validation_ ||
2624 force_webgl_glsl_validation_ ? SH_WEBGL_SPEC : SH_GLES2_SPEC; 2628 force_webgl_glsl_validation_ ? SH_WEBGL_SPEC : SH_GLES2_SPEC;
2625 if (shader_spec == SH_WEBGL_SPEC && features().enable_shader_name_hashing) 2629 if (shader_spec == SH_WEBGL_SPEC && features().enable_shader_name_hashing)
2626 #if !defined(ANGLE_SH_VERSION) || ANGLE_SH_VERSION < 108 2630 #if !defined(ANGLE_SH_VERSION) || ANGLE_SH_VERSION < 108
2627 resources.HashFunction = &CityHashForAngle; 2631 resources.HashFunction = &CityHashForAngle;
2628 #else 2632 #else
2629 resources.HashFunction = &CityHash64; 2633 resources.HashFunction = &CityHash64;
2630 #endif 2634 #endif
(...skipping 1489 matching lines...) Expand 10 before | Expand all | Expand 10 after
4120 if (params) { 4124 if (params) {
4121 params[0] = texture_manager()->MaxSizeForTarget(GL_TEXTURE_2D); 4125 params[0] = texture_manager()->MaxSizeForTarget(GL_TEXTURE_2D);
4122 } 4126 }
4123 return true; 4127 return true;
4124 case GL_MAX_CUBE_MAP_TEXTURE_SIZE: 4128 case GL_MAX_CUBE_MAP_TEXTURE_SIZE:
4125 *num_written = 1; 4129 *num_written = 1;
4126 if (params) { 4130 if (params) {
4127 params[0] = texture_manager()->MaxSizeForTarget(GL_TEXTURE_CUBE_MAP); 4131 params[0] = texture_manager()->MaxSizeForTarget(GL_TEXTURE_CUBE_MAP);
4128 } 4132 }
4129 return true; 4133 return true;
4134 case GL_MAX_COLOR_ATTACHMENTS_EXT:
4135 *num_written = 1;
4136 if (params) {
4137 params[0] = group_->max_color_attachments();
4138 }
4139 return true;
4140 case GL_MAX_DRAW_BUFFERS_ARB:
4141 *num_written = 1;
4142 if (params) {
4143 params[0] = group_->max_draw_buffers();
4144 }
4145 return true;
4130 case GL_ALPHA_BITS: 4146 case GL_ALPHA_BITS:
4131 *num_written = 1; 4147 *num_written = 1;
4132 if (params) { 4148 if (params) {
4133 GLint v = 0; 4149 GLint v = 0;
4134 glGetIntegerv(GL_ALPHA_BITS, &v); 4150 glGetIntegerv(GL_ALPHA_BITS, &v);
4135 params[0] = BoundFramebufferHasColorAttachmentWithAlpha() ? v : 0; 4151 params[0] = BoundFramebufferHasColorAttachmentWithAlpha() ? v : 0;
4136 } 4152 }
4137 return true; 4153 return true;
4138 case GL_DEPTH_BITS: 4154 case GL_DEPTH_BITS:
4139 *num_written = 1; 4155 *num_written = 1;
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
4352 params[0] = unpack_premultiply_alpha_; 4368 params[0] = unpack_premultiply_alpha_;
4353 } 4369 }
4354 return true; 4370 return true;
4355 case GL_UNPACK_UNPREMULTIPLY_ALPHA_CHROMIUM: 4371 case GL_UNPACK_UNPREMULTIPLY_ALPHA_CHROMIUM:
4356 *num_written = 1; 4372 *num_written = 1;
4357 if (params) { 4373 if (params) {
4358 params[0] = unpack_unpremultiply_alpha_; 4374 params[0] = unpack_unpremultiply_alpha_;
4359 } 4375 }
4360 return true; 4376 return true;
4361 default: 4377 default:
4378 if (pname >= GL_DRAW_BUFFER0_ARB &&
4379 pname < GL_DRAW_BUFFER0_ARB + group_->max_draw_buffers()) {
4380 *num_written = 1;
4381 if (params) {
4382 Framebuffer* framebuffer =
4383 GetFramebufferInfoForTarget(GL_FRAMEBUFFER);
4384 if (framebuffer) {
4385 params[0] = framebuffer->GetDrawBuffer(pname);
4386 } else { // backbuffer
4387 if (pname == GL_DRAW_BUFFER0_ARB)
4388 params[0] = group_->draw_buffer();
4389 else
4390 params[0] = GL_NONE;
4391 }
4392 }
4393 return true;
4394 }
4362 *num_written = util_.GLGetNumValuesReturned(pname); 4395 *num_written = util_.GLGetNumValuesReturned(pname);
4363 return false; 4396 return false;
4364 } 4397 }
4365 } 4398 }
4366 4399
4367 bool GLES2DecoderImpl::GetNumValuesReturnedForGLGet( 4400 bool GLES2DecoderImpl::GetNumValuesReturnedForGLGet(
4368 GLenum pname, GLsizei* num_values) { 4401 GLenum pname, GLsizei* num_values) {
4369 if (state_.GetStateAsGLint(pname, NULL, num_values)) { 4402 if (state_.GetStateAsGLint(pname, NULL, num_values)) {
4370 return true; 4403 return true;
4371 } 4404 }
(...skipping 5735 matching lines...) Expand 10 before | Expand all | Expand 10 after
10107 if (gpu_tracer_->CurrentName().empty()) { 10140 if (gpu_tracer_->CurrentName().empty()) {
10108 LOCAL_SET_GL_ERROR( 10141 LOCAL_SET_GL_ERROR(
10109 GL_INVALID_OPERATION, 10142 GL_INVALID_OPERATION,
10110 "glTraceEndCHROMIUM", "no trace begin found"); 10143 "glTraceEndCHROMIUM", "no trace begin found");
10111 return; 10144 return;
10112 } 10145 }
10113 TRACE_EVENT_COPY_ASYNC_END0("gpu", gpu_tracer_->CurrentName().c_str(), this); 10146 TRACE_EVENT_COPY_ASYNC_END0("gpu", gpu_tracer_->CurrentName().c_str(), this);
10114 gpu_tracer_->End(); 10147 gpu_tracer_->End();
10115 } 10148 }
10116 10149
10150 void GLES2DecoderImpl::DoDrawBuffersEXT(
10151 GLsizei count, const GLenum* bufs) {
10152 if (count > static_cast<GLsizei>(group_->max_draw_buffers())) {
10153 LOCAL_SET_GL_ERROR(
10154 GL_INVALID_VALUE,
10155 "glDrawBuffersEXT", "greater than GL_MAX_DRAW_BUFFERS_EXT");
10156 return;
10157 }
10158
10159 Framebuffer* framebuffer = GetFramebufferInfoForTarget(GL_FRAMEBUFFER);
10160 if (framebuffer) {
10161 for (GLsizei i = 0; i < count; ++i) {
10162 if (bufs[i] != static_cast<GLenum>(GL_COLOR_ATTACHMENT0 + i) &&
10163 bufs[i] != GL_NONE) {
10164 LOCAL_SET_GL_ERROR(
10165 GL_INVALID_OPERATION,
10166 "glDrawBuffersEXT",
10167 "bufs[i] not GL_NONE or GL_COLOR_ATTACHMENTi_EXT");
10168 return;
10169 }
10170 }
10171 glDrawBuffersARB(count, bufs);
10172 framebuffer->SetDrawBuffers(count, bufs);
10173 } else { // backbuffer
10174 if (count > 1 ||
10175 (bufs[0] != GL_BACK && bufs[0] != GL_NONE)) {
10176 LOCAL_SET_GL_ERROR(
10177 GL_INVALID_OPERATION,
10178 "glDrawBuffersEXT",
10179 "more than one buffer or bufs not GL_NONE or GL_BACK");
10180 return;
10181 }
10182 GLenum mapped_buf = bufs[0];
10183 if (GetBackbufferServiceId() != 0 && // emulated backbuffer
10184 bufs[0] == GL_BACK) {
10185 mapped_buf = GL_COLOR_ATTACHMENT0;
10186 }
10187 glDrawBuffersARB(count, &mapped_buf);
10188 group_->set_draw_buffer(bufs[0]);
10189 }
10190 }
10191
10117 bool GLES2DecoderImpl::ValidateAsyncTransfer( 10192 bool GLES2DecoderImpl::ValidateAsyncTransfer(
10118 const char* function_name, 10193 const char* function_name,
10119 Texture* texture, 10194 Texture* texture,
10120 GLenum target, 10195 GLenum target,
10121 GLint level, 10196 GLint level,
10122 const void * data) { 10197 const void * data) {
10123 // We only support async uploads to 2D textures for now. 10198 // We only support async uploads to 2D textures for now.
10124 if (GL_TEXTURE_2D != target) { 10199 if (GL_TEXTURE_2D != target) {
10125 LOCAL_SET_GL_ERROR_INVALID_ENUM(function_name, target, "target"); 10200 LOCAL_SET_GL_ERROR_INVALID_ENUM(function_name, target, "target");
10126 return false; 10201 return false;
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
10339 return error::kNoError; 10414 return error::kNoError;
10340 } 10415 }
10341 10416
10342 // Include the auto-generated part of this file. We split this because it means 10417 // Include the auto-generated part of this file. We split this because it means
10343 // we can easily edit the non-auto generated parts right here in this file 10418 // we can easily edit the non-auto generated parts right here in this file
10344 // instead of having to edit some template or the code generator. 10419 // instead of having to edit some template or the code generator.
10345 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 10420 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
10346 10421
10347 } // namespace gles2 10422 } // namespace gles2
10348 } // namespace gpu 10423 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/framebuffer_manager_unittest.cc ('k') | gpu/command_buffer/service/gles2_cmd_decoder_autogen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698