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

Unified Diff: gpu/command_buffer/service/gles2_cmd_decoder.cc

Issue 7782038: Prepare WebGL contexts for resource sharing with the compositor context. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: gpu/command_buffer/service/gles2_cmd_decoder.cc
===================================================================
--- gpu/command_buffer/service/gles2_cmd_decoder.cc (revision 99750)
+++ gpu/command_buffer/service/gles2_cmd_decoder.cc (working copy)
@@ -1311,6 +1311,18 @@
const Validators* validators_;
FeatureInfo* feature_info_;
+ // Per GLES2DecoderImpl instance set of validators, which are used if
+ // a more constrained set of extensions is required for this particular
+ // context, wrt the shared ContextGroup.
+ scoped_ptr<FeatureInfo> local_feature_info_;
+
+ // Get the set of validators to use for API parameter verification.
+ const Validators* validators() const {
+ if (local_feature_info_.get())
+ return local_feature_info_->validators();
+ return validators_;
+ }
+
// This indicates all the following texSubImage2D calls that are part of the
// failed texImage2D call should be ignored.
bool tex_image_2d_failed_;
@@ -1736,7 +1748,22 @@
return false;
}
- if (!group_->Initialize(disallowed_extensions, allowed_extensions)) {
+ // Initialization for a constrained set of extensions constructs a local
+ // set of validators, that override those of the sharing group.
+ if (0 == strcmp(allowed_extensions, "*")) {
Ken Russell (switch to Gerrit) 2011/09/15 23:57:27 Shouldn't this comparison be "0 != strcmp(...)"? W
Jeff Timanus 2011/09/16 15:00:17 Yes! Done.
+ local_feature_info_.reset(new FeatureInfo());
+ if (!local_feature_info_->Initialize(allowed_extensions)) {
+ LOG(ERROR) << "GpuScheduler::InitializeCommon failed because local "
+ << "FeatureInfo overrides failed to initialize.";
+ Destroy();
+ return false;
+ }
+ }
+
+ // The shared group should always be initialized with all extensions.
+ // This ensures that all contexts will have access to all of the exentsions
+ // they may need.
+ if (!group_->Initialize(disallowed_extensions, "*")) {
LOG(ERROR) << "GpuScheduler::InitializeCommon failed because group "
<< "failed to initialize.";
Destroy();
@@ -1749,7 +1776,7 @@
vertex_attrib_manager_.Initialize(group_->max_vertex_attribs());
util_.set_num_compressed_texture_formats(
- validators_->compressed_texture_format.GetValues().size());
+ validators()->compressed_texture_format.GetValues().size());
if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) {
// We have to enable vertex array 0 on OpenGL or it won't render. Note that
@@ -1951,9 +1978,9 @@
void GLES2DecoderImpl::UpdateCapabilities() {
util_.set_num_compressed_texture_formats(
- validators_->compressed_texture_format.GetValues().size());
+ validators()->compressed_texture_format.GetValues().size());
util_.set_num_shader_binary_formats(
- validators_->shader_binary_format.GetValues().size());
+ validators()->shader_binary_format.GetValues().size());
}
bool GLES2DecoderImpl::InitializeShaderTranslator() {
@@ -3005,30 +3032,30 @@
}
return true;
case GL_COMPRESSED_TEXTURE_FORMATS:
- *num_written = validators_->compressed_texture_format.GetValues().size();
+ *num_written = validators()->compressed_texture_format.GetValues().size();
if (params) {
for (GLint ii = 0; ii < *num_written; ++ii) {
- params[ii] = validators_->compressed_texture_format.GetValues()[ii];
+ params[ii] = validators()->compressed_texture_format.GetValues()[ii];
}
}
return true;
case GL_NUM_COMPRESSED_TEXTURE_FORMATS:
*num_written = 1;
if (params) {
- *params = validators_->compressed_texture_format.GetValues().size();
+ *params = validators()->compressed_texture_format.GetValues().size();
}
return true;
case GL_NUM_SHADER_BINARY_FORMATS:
*num_written = 1;
if (params) {
- *params = validators_->shader_binary_format.GetValues().size();
+ *params = validators()->shader_binary_format.GetValues().size();
}
return true;
case GL_SHADER_BINARY_FORMATS:
- *num_written = validators_->shader_binary_format.GetValues().size();
+ *num_written = validators()->shader_binary_format.GetValues().size();
if (params) {
for (GLint ii = 0; ii < *num_written; ++ii) {
- params[ii] = validators_->shader_binary_format.GetValues()[ii];
+ params[ii] = validators()->shader_binary_format.GetValues()[ii];
}
}
return true;
@@ -4399,7 +4426,7 @@
GLenum mode = static_cast<GLenum>(c.mode);
GLint first = static_cast<GLint>(c.first);
GLsizei count = static_cast<GLsizei>(c.count);
- if (!validators_->draw_mode.IsValid(mode)) {
+ if (!validators()->draw_mode.IsValid(mode)) {
SetGLError(GL_INVALID_ENUM, "glDrawArrays: mode GL_INVALID_ENUM");
return error::kNoError;
}
@@ -4468,11 +4495,11 @@
SetGLError(GL_INVALID_VALUE, "glDrawElements: offset < 0");
return error::kNoError;
}
- if (!validators_->draw_mode.IsValid(mode)) {
+ if (!validators()->draw_mode.IsValid(mode)) {
SetGLError(GL_INVALID_ENUM, "glDrawElements: mode GL_INVALID_ENUM");
return error::kNoError;
}
- if (!validators_->index_type.IsValid(type)) {
+ if (!validators()->index_type.IsValid(type)) {
SetGLError(GL_INVALID_ENUM, "glDrawElements: type GL_INVALID_ENUM");
return error::kNoError;
}
@@ -5020,12 +5047,12 @@
GLsizei stride = c.stride;
GLsizei offset = c.offset;
const void* ptr = reinterpret_cast<const void*>(offset);
- if (!validators_->vertex_attrib_type.IsValid(type)) {
+ if (!validators()->vertex_attrib_type.IsValid(type)) {
SetGLError(GL_INVALID_ENUM,
"glVertexAttribPointer: type GL_INVALID_ENUM");
return error::kNoError;
}
- if (!validators_->vertex_attrib_size.IsValid(size)) {
+ if (!validators()->vertex_attrib_size.IsValid(size)) {
SetGLError(GL_INVALID_VALUE,
"glVertexAttribPointer: size GL_INVALID_VALUE");
return error::kNoError;
@@ -5102,11 +5129,11 @@
return error::kOutOfBounds;
}
- if (!validators_->read_pixel_format.IsValid(format)) {
+ if (!validators()->read_pixel_format.IsValid(format)) {
SetGLError(GL_INVALID_ENUM, "glReadPixels: format GL_INVALID_ENUM");
return error::kNoError;
}
- if (!validators_->pixel_type.IsValid(type)) {
+ if (!validators()->pixel_type.IsValid(type)) {
SetGLError(GL_INVALID_ENUM, "glReadPixels: type GL_INVALID_ENUM");
return error::kNoError;
}
@@ -5238,11 +5265,11 @@
uint32 immediate_data_size, const gles2::PixelStorei& c) {
GLenum pname = c.pname;
GLenum param = c.param;
- if (!validators_->pixel_store.IsValid(pname)) {
+ if (!validators()->pixel_store.IsValid(pname)) {
SetGLError(GL_INVALID_ENUM, "glPixelStorei: pname GL_INVALID_ENUM");
return error::kNoError;
}
- if (!validators_->pixel_store_alignment.IsValid(param)) {
+ if (!validators()->pixel_store_alignment.IsValid(param)) {
SetGLError(GL_INVALID_VALUE, "glPixelSTore: param GL_INVALID_VALUE");
return error::kNoError;
}
@@ -5398,7 +5425,7 @@
error::Error GLES2DecoderImpl::HandleGetString(
uint32 immediate_data_size, const gles2::GetString& c) {
GLenum name = static_cast<GLenum>(c.name);
- if (!validators_->string_type.IsValid(name)) {
+ if (!validators()->string_type.IsValid(name)) {
SetGLError(GL_INVALID_ENUM, "glGetString: name GL_INVALID_ENUM");
return error::kNoError;
}
@@ -5425,11 +5452,11 @@
void GLES2DecoderImpl::DoBufferData(
GLenum target, GLsizeiptr size, const GLvoid * data, GLenum usage) {
- if (!validators_->buffer_target.IsValid(target)) {
+ if (!validators()->buffer_target.IsValid(target)) {
SetGLError(GL_INVALID_ENUM, "glBufferData: target GL_INVALID_ENUM");
return;
}
- if (!validators_->buffer_usage.IsValid(usage)) {
+ if (!validators()->buffer_usage.IsValid(usage)) {
SetGLError(GL_INVALID_ENUM, "glBufferData: usage GL_INVALID_ENUM");
return;
}
@@ -5527,12 +5554,12 @@
GLsizei image_size,
const void* data) {
// TODO(gman): Validate image_size is correct for width, height and format.
- if (!validators_->texture_target.IsValid(target)) {
+ if (!validators()->texture_target.IsValid(target)) {
SetGLError(GL_INVALID_ENUM,
"glCompressedTexImage2D: target GL_INVALID_ENUM");
return error::kNoError;
}
- if (!validators_->compressed_texture_format.IsValid(
+ if (!validators()->compressed_texture_format.IsValid(
internal_format)) {
SetGLError(GL_INVALID_ENUM,
"glCompressedTexImage2D: internal_format GL_INVALID_ENUM");
@@ -5638,12 +5665,12 @@
uint32 data_size = bucket->size();
GLsizei imageSize = data_size;
const void* data = bucket->GetData(0, data_size);
- if (!validators_->texture_target.IsValid(target)) {
+ if (!validators()->texture_target.IsValid(target)) {
SetGLError(
GL_INVALID_ENUM, "glCompressedTexSubImage2D: target GL_INVALID_ENUM");
return error::kNoError;
}
- if (!validators_->compressed_texture_format.IsValid(format)) {
+ if (!validators()->compressed_texture_format.IsValid(format)) {
SetGLError(GL_INVALID_ENUM,
"glCompressedTexSubImage2D: format GL_INVALID_ENUM");
return error::kNoError;
@@ -5676,20 +5703,20 @@
GLenum type,
const void* pixels,
uint32 pixels_size) {
- if (!validators_->texture_target.IsValid(target)) {
+ if (!validators()->texture_target.IsValid(target)) {
SetGLError(GL_INVALID_ENUM, "glTexImage2D: target GL_INVALID_ENUM");
return error::kNoError;
}
- if (!validators_->texture_format.IsValid(internal_format)) {
+ if (!validators()->texture_format.IsValid(internal_format)) {
SetGLError(GL_INVALID_ENUM,
"glTexImage2D: internal_format GL_INVALID_ENUM");
return error::kNoError;
}
- if (!validators_->texture_format.IsValid(format)) {
+ if (!validators()->texture_format.IsValid(format)) {
SetGLError(GL_INVALID_ENUM, "glTexImage2D: format GL_INVALID_ENUM");
return error::kNoError;
}
- if (!validators_->pixel_type.IsValid(type)) {
+ if (!validators()->pixel_type.IsValid(type)) {
SetGLError(GL_INVALID_ENUM, "glTexImage2D: type GL_INVALID_ENUM");
return error::kNoError;
}
@@ -6110,7 +6137,7 @@
}
const void* pixels = GetSharedMemoryAs<const void*>(
c.pixels_shm_id, c.pixels_shm_offset, data_size);
- if (!validators_->texture_target.IsValid(target)) {
+ if (!validators()->texture_target.IsValid(target)) {
SetGLError(GL_INVALID_ENUM, "glTexSubImage2D: target GL_INVALID_ENUM");
return error::kNoError;
}
@@ -6122,11 +6149,11 @@
SetGLError(GL_INVALID_VALUE, "glTexSubImage2D: height < 0");
return error::kNoError;
}
- if (!validators_->texture_format.IsValid(format)) {
+ if (!validators()->texture_format.IsValid(format)) {
SetGLError(GL_INVALID_ENUM, "glTexSubImage2D: format GL_INVALID_ENUM");
return error::kNoError;
}
- if (!validators_->pixel_type.IsValid(type)) {
+ if (!validators()->pixel_type.IsValid(type)) {
SetGLError(GL_INVALID_ENUM, "glTexSubImage2D: type GL_INVALID_ENUM");
return error::kNoError;
}
@@ -6159,7 +6186,7 @@
}
const void* pixels = GetImmediateDataAs<const void*>(
c, data_size, immediate_data_size);
- if (!validators_->texture_target.IsValid(target)) {
+ if (!validators()->texture_target.IsValid(target)) {
SetGLError(GL_INVALID_ENUM, "glTexSubImage2D: target GL_INVALID_ENUM");
return error::kNoError;
}
@@ -6171,11 +6198,11 @@
SetGLError(GL_INVALID_VALUE, "glTexSubImage2D: height < 0");
return error::kNoError;
}
- if (!validators_->texture_format.IsValid(format)) {
+ if (!validators()->texture_format.IsValid(format)) {
SetGLError(GL_INVALID_ENUM, "glTexSubImage2D: format GL_INVALID_ENUM");
return error::kNoError;
}
- if (!validators_->pixel_type.IsValid(type)) {
+ if (!validators()->pixel_type.IsValid(type)) {
SetGLError(GL_INVALID_ENUM, "glTexSubImage2D: type GL_INVALID_ENUM");
return error::kNoError;
}
@@ -6201,7 +6228,7 @@
if (result->size != 0) {
return error::kInvalidArguments;
}
- if (!validators_->vertex_pointer.IsValid(pname)) {
+ if (!validators()->vertex_pointer.IsValid(pname)) {
SetGLError(GL_INVALID_ENUM,
"glGetVertexAttribPointerv: pname GL_INVALID_ENUM");
return error::kNoError;
@@ -6334,12 +6361,12 @@
if (result->success != 0) {
return error::kInvalidArguments;
}
- if (!validators_->shader_type.IsValid(shader_type)) {
+ if (!validators()->shader_type.IsValid(shader_type)) {
SetGLError(GL_INVALID_ENUM,
"glGetShaderPrecisionFormat: shader_type GL_INVALID_ENUM");
return error::kNoError;
}
- if (!validators_->shader_precision.IsValid(precision_type)) {
+ if (!validators()->shader_precision.IsValid(precision_type)) {
SetGLError(GL_INVALID_ENUM,
"glGetShaderPrecisionFormat: precision_type GL_INVALID_ENUM");
return error::kNoError;
@@ -6647,7 +6674,7 @@
} else if (feature_str.compare("pepper3d_support_fixed_attribs") == 0) {
buffer_manager()->set_allow_buffers_on_multiple_targets(true);
// TODO(gman): decide how to remove the need for this const_cast.
- // I could make validators_ non const but that seems bad as this is the only
+ // I could make validators() non const but that seems bad as this is the only
// place it is needed. I could make some special friend class of validators
// just to allow this to set them. That seems silly. I could refactor this
// code to use the extension mechanism or the initialization attributes to
@@ -6655,7 +6682,8 @@
// the conformance tests pass and given that there is lots of real work that
// needs to be done it seems like refactoring for one to one of those
// methods is a very low priority.
- const_cast<Validators*>(validators_)->vertex_attrib_type.AddValue(GL_FIXED);
+ const_cast<Validators*>(validators())->vertex_attrib_type.AddValue(
+ GL_FIXED);
} else {
return error::kNoError;
}
« no previous file with comments | « gpu/command_buffer/build_gles2_cmd_buffer.py ('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