Commit 252a8130 authored by Jiajia Qin's avatar Jiajia Qin Committed by Commit Bot

Create gles31 context for webgl2-compute in passthrough decoder

With this change, all webgl/webgl2 APIs can be run on webgl2-compute
context for passthrough command buffer.

Bug: 859249
Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel;luci.chromium.try:linux_optional_gpu_tests_rel;luci.chromium.try:mac_optional_gpu_tests_rel;luci.chromium.try:win_optional_gpu_tests_rel
Change-Id: Ia3c5febb7f5cbeb16d560ee05362c4746f97d5d6
Reviewed-on: https://chromium-review.googlesource.com/1141434Reviewed-by: default avatarKenneth Russell <kbr@chromium.org>
Commit-Queue: Jiajia Qin <jiajia.qin@intel.com>
Cr-Commit-Position: refs/heads/master@{#576293}
parent d180a5b0
...@@ -1086,7 +1086,7 @@ static_assert(offsetof(%(cmd_name)s::Result, %(field_name)s) == %(offset)d, ...@@ -1086,7 +1086,7 @@ static_assert(offsetof(%(cmd_name)s::Result, %(field_name)s) == %(offset)d,
uint32_t immediate_data_size, const volatile void* cmd_data) { uint32_t immediate_data_size, const volatile void* cmd_data) {
""" % {'name': func.name, 'prefix' : _prefix}) """ % {'name': func.name, 'prefix' : _prefix})
if func.IsES3(): if func.IsES3():
f.write("""if (!feature_info_->IsWebGL2OrES3Context()) f.write("""if (!feature_info_->IsWebGL2OrES3OrHigherContext())
return error::kUnknownCommand; return error::kUnknownCommand;
""") """)
if func.GetCmdArgs(): if func.GetCmdArgs():
...@@ -1165,7 +1165,7 @@ static_assert(offsetof(%(cmd_name)s::Result, %(field_name)s) == %(offset)d, ...@@ -1165,7 +1165,7 @@ static_assert(offsetof(%(cmd_name)s::Result, %(field_name)s) == %(offset)d,
uint32_t immediate_data_size, const volatile void* cmd_data) { uint32_t immediate_data_size, const volatile void* cmd_data) {
""" % {'name': func.name}) """ % {'name': func.name})
if func.IsES3(): if func.IsES3():
f.write("""if (!feature_info_->IsWebGL2OrES3Context()) f.write("""if (!feature_info_->IsWebGL2OrES3OrHigherContext())
return error::kUnknownCommand; return error::kUnknownCommand;
""") """)
if func.GetCmdArgs(): if func.GetCmdArgs():
......
...@@ -56,6 +56,38 @@ bool IsWebGL2OrES3ContextType(ContextType context_type) { ...@@ -56,6 +56,38 @@ bool IsWebGL2OrES3ContextType(ContextType context_type) {
return false; return false;
} }
bool IsWebGL2OrES3OrHigherContextType(ContextType context_type) {
// Switch statement to cause a compile-time error if we miss a case.
switch (context_type) {
case CONTEXT_TYPE_OPENGLES3:
case CONTEXT_TYPE_WEBGL2:
case CONTEXT_TYPE_WEBGL2_COMPUTE:
return true;
case CONTEXT_TYPE_WEBGL1:
case CONTEXT_TYPE_OPENGLES2:
return false;
}
NOTREACHED();
return false;
}
bool IsWebGL2ComputeContextType(ContextType context_type) {
// Switch statement to cause a compile-time error if we miss a case.
switch (context_type) {
case CONTEXT_TYPE_WEBGL2_COMPUTE:
return true;
case CONTEXT_TYPE_OPENGLES3:
case CONTEXT_TYPE_WEBGL2:
case CONTEXT_TYPE_WEBGL1:
case CONTEXT_TYPE_OPENGLES2:
return false;
}
NOTREACHED();
return false;
}
ContextCreationAttribs::ContextCreationAttribs() = default; ContextCreationAttribs::ContextCreationAttribs() = default;
ContextCreationAttribs::ContextCreationAttribs( ContextCreationAttribs::ContextCreationAttribs(
......
...@@ -25,6 +25,8 @@ enum ContextType { ...@@ -25,6 +25,8 @@ enum ContextType {
GPU_EXPORT bool IsWebGLContextType(ContextType context_type); GPU_EXPORT bool IsWebGLContextType(ContextType context_type);
GPU_EXPORT bool IsWebGL1OrES2ContextType(ContextType context_type); GPU_EXPORT bool IsWebGL1OrES2ContextType(ContextType context_type);
GPU_EXPORT bool IsWebGL2OrES3ContextType(ContextType context_type); GPU_EXPORT bool IsWebGL2OrES3ContextType(ContextType context_type);
GPU_EXPORT bool IsWebGL2OrES3OrHigherContextType(ContextType context_type);
GPU_EXPORT bool IsWebGL2ComputeContextType(ContextType context_type);
enum ColorSpace { enum ColorSpace {
COLOR_SPACE_UNSPECIFIED, COLOR_SPACE_UNSPECIFIED,
......
...@@ -421,7 +421,7 @@ void FeatureInfo::InitializeFeatures() { ...@@ -421,7 +421,7 @@ void FeatureInfo::InitializeFeatures() {
gl_version_info_.reset( gl_version_info_.reset(
new gl::GLVersionInfo(version_str, renderer_str, extensions)); new gl::GLVersionInfo(version_str, renderer_str, extensions));
bool enable_es3 = IsWebGL2OrES3Context(); bool enable_es3 = IsWebGL2OrES3OrHigherContext();
// Pixel buffer bindings can be manipulated by the client if ES3 is enabled or // Pixel buffer bindings can be manipulated by the client if ES3 is enabled or
// the GL_NV_pixel_buffer_object extension is exposed by ANGLE when using the // the GL_NV_pixel_buffer_object extension is exposed by ANGLE when using the
...@@ -1194,7 +1194,7 @@ void FeatureInfo::InitializeFeatures() { ...@@ -1194,7 +1194,7 @@ void FeatureInfo::InitializeFeatures() {
!have_es2_draw_buffers_vendor_agnostic; !have_es2_draw_buffers_vendor_agnostic;
} }
if (IsWebGL2OrES3Context() || have_es2_draw_buffers) { if (IsWebGL2OrES3OrHigherContext() || have_es2_draw_buffers) {
GLint max_color_attachments = 0; GLint max_color_attachments = 0;
glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS_EXT, &max_color_attachments); glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS_EXT, &max_color_attachments);
for (GLenum i = GL_COLOR_ATTACHMENT1_EXT; for (GLenum i = GL_COLOR_ATTACHMENT1_EXT;
...@@ -1506,7 +1506,7 @@ void FeatureInfo::InitializeFloatAndHalfFloatFeatures( ...@@ -1506,7 +1506,7 @@ void FeatureInfo::InitializeFloatAndHalfFloatFeatures(
bool may_enable_chromium_color_buffer_float = false; bool may_enable_chromium_color_buffer_float = false;
bool enable_es3 = IsWebGL2OrES3Context(); bool enable_es3 = IsWebGL2OrES3OrHigherContext();
// These extensions allow a variety of floating point formats to be // These extensions allow a variety of floating point formats to be
// rendered to via framebuffer objects. // rendered to via framebuffer objects.
...@@ -1825,6 +1825,14 @@ bool FeatureInfo::IsWebGL2OrES3Context() const { ...@@ -1825,6 +1825,14 @@ bool FeatureInfo::IsWebGL2OrES3Context() const {
return IsWebGL2OrES3ContextType(context_type_); return IsWebGL2OrES3ContextType(context_type_);
} }
bool FeatureInfo::IsWebGL2OrES3OrHigherContext() const {
return IsWebGL2OrES3OrHigherContextType(context_type_);
}
bool FeatureInfo::IsWebGL2ComputeContext() const {
return IsWebGL2ComputeContextType(context_type_);
}
void FeatureInfo::AddExtensionString(const base::StringPiece& extension) { void FeatureInfo::AddExtensionString(const base::StringPiece& extension) {
extensions_.insert(extension); extensions_.insert(extension);
} }
......
...@@ -180,6 +180,8 @@ class GPU_GLES2_EXPORT FeatureInfo : public base::RefCounted<FeatureInfo> { ...@@ -180,6 +180,8 @@ class GPU_GLES2_EXPORT FeatureInfo : public base::RefCounted<FeatureInfo> {
bool IsWebGLContext() const; bool IsWebGLContext() const;
bool IsWebGL1OrES2Context() const; bool IsWebGL1OrES2Context() const;
bool IsWebGL2OrES3Context() const; bool IsWebGL2OrES3Context() const;
bool IsWebGL2OrES3OrHigherContext() const;
bool IsWebGL2ComputeContext() const;
void EnableCHROMIUMTextureStorageImage(); void EnableCHROMIUMTextureStorageImage();
void EnableCHROMIUMColorBufferFloatRGBA(); void EnableCHROMIUMColorBufferFloatRGBA();
......
...@@ -209,7 +209,7 @@ void PopulateNumericCapabilities(Capabilities* caps, ...@@ -209,7 +209,7 @@ void PopulateNumericCapabilities(Capabilities* caps,
&caps->num_compressed_texture_formats); &caps->num_compressed_texture_formats);
glGetIntegerv(GL_NUM_SHADER_BINARY_FORMATS, &caps->num_shader_binary_formats); glGetIntegerv(GL_NUM_SHADER_BINARY_FORMATS, &caps->num_shader_binary_formats);
if (feature_info->IsWebGL2OrES3Context()) { if (feature_info->IsWebGL2OrES3OrHigherContext()) {
glGetIntegerv(GL_MAX_3D_TEXTURE_SIZE, &caps->max_3d_texture_size); glGetIntegerv(GL_MAX_3D_TEXTURE_SIZE, &caps->max_3d_texture_size);
glGetIntegerv(GL_MAX_ARRAY_TEXTURE_LAYERS, &caps->max_array_texture_layers); glGetIntegerv(GL_MAX_ARRAY_TEXTURE_LAYERS, &caps->max_array_texture_layers);
glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS, &caps->max_color_attachments); glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS, &caps->max_color_attachments);
...@@ -255,11 +255,15 @@ void PopulateNumericCapabilities(Capabilities* caps, ...@@ -255,11 +255,15 @@ void PopulateNumericCapabilities(Capabilities* caps,
glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT,
&caps->uniform_buffer_offset_alignment); &caps->uniform_buffer_offset_alignment);
caps->major_version = 3; caps->major_version = 3;
caps->minor_version = 0; if (feature_info->IsWebGL2ComputeContext()) {
caps->minor_version = 1;
} else {
caps->minor_version = 0;
}
} }
if (feature_info->feature_flags().multisampled_render_to_texture || if (feature_info->feature_flags().multisampled_render_to_texture ||
feature_info->feature_flags().chromium_framebuffer_multisample || feature_info->feature_flags().chromium_framebuffer_multisample ||
feature_info->IsWebGL2OrES3Context()) { feature_info->IsWebGL2OrES3OrHigherContext()) {
glGetIntegerv(GL_MAX_SAMPLES, &caps->max_samples); glGetIntegerv(GL_MAX_SAMPLES, &caps->max_samples);
} }
} }
...@@ -275,7 +279,9 @@ bool CheckUniqueAndNonNullIds(GLsizei n, const GLuint* client_ids) { ...@@ -275,7 +279,9 @@ bool CheckUniqueAndNonNullIds(GLsizei n, const GLuint* client_ids) {
const char* GetServiceVersionString(const FeatureInfo* feature_info) { const char* GetServiceVersionString(const FeatureInfo* feature_info) {
if (feature_info->IsWebGL2OrES3Context()) if (feature_info->IsWebGL2OrES3Context())
return "OpenGL ES 3.0 Chromium"; return "OpenGL ES 3.0 Chromium";
else else if (feature_info->IsWebGL2ComputeContext()) {
return "OpenGL ES 3.1 Chromium";
} else
return "OpenGL ES 2.0 Chromium"; return "OpenGL ES 2.0 Chromium";
} }
...@@ -283,7 +289,9 @@ const char* GetServiceShadingLanguageVersionString( ...@@ -283,7 +289,9 @@ const char* GetServiceShadingLanguageVersionString(
const FeatureInfo* feature_info) { const FeatureInfo* feature_info) {
if (feature_info->IsWebGL2OrES3Context()) if (feature_info->IsWebGL2OrES3Context())
return "OpenGL ES GLSL ES 3.0 Chromium"; return "OpenGL ES GLSL ES 3.0 Chromium";
else else if (feature_info->IsWebGL2ComputeContext()) {
return "OpenGL ES GLSL ES 3.1 Chromium";
} else
return "OpenGL ES GLSL ES 1.0 Chromium"; return "OpenGL ES GLSL ES 1.0 Chromium";
} }
...@@ -511,7 +519,7 @@ bool ValidateCopyTexFormatHelper(const FeatureInfo* feature_info, ...@@ -511,7 +519,7 @@ bool ValidateCopyTexFormatHelper(const FeatureInfo* feature_info,
*output_error_msg = std::string("incompatible format"); *output_error_msg = std::string("incompatible format");
return false; return false;
} }
if (feature_info->IsWebGL2OrES3Context()) { if (feature_info->IsWebGL2OrES3OrHigherContext()) {
GLint color_encoding = GLint color_encoding =
GLES2Util::GetColorEncodingFromInternalFormat(read_format); GLES2Util::GetColorEncodingFromInternalFormat(read_format);
bool float_mismatch = feature_info->ext_color_buffer_float_available() bool float_mismatch = feature_info->ext_color_buffer_float_available()
...@@ -534,7 +542,7 @@ bool ValidateCopyTexFormatHelper(const FeatureInfo* feature_info, ...@@ -534,7 +542,7 @@ bool ValidateCopyTexFormatHelper(const FeatureInfo* feature_info,
std::string("can not be used with depth or stencil textures"); std::string("can not be used with depth or stencil textures");
return false; return false;
} }
if (feature_info->IsWebGL2OrES3Context() || if (feature_info->IsWebGL2OrES3OrHigherContext() ||
(feature_info->feature_flags().chromium_color_buffer_float_rgb && (feature_info->feature_flags().chromium_color_buffer_float_rgb &&
internal_format == GL_RGB32F) || internal_format == GL_RGB32F) ||
(feature_info->feature_flags().chromium_color_buffer_float_rgba && (feature_info->feature_flags().chromium_color_buffer_float_rgba &&
...@@ -679,7 +687,7 @@ bool ValidateCopyTextureCHROMIUMInternalFormats(const FeatureInfo* feature_info, ...@@ -679,7 +687,7 @@ bool ValidateCopyTextureCHROMIUMInternalFormats(const FeatureInfo* feature_info,
case GL_RGBA4: case GL_RGBA4:
case GL_RGBA8UI: case GL_RGBA8UI:
case GL_RGB10_A2: case GL_RGB10_A2:
valid_dest_format = feature_info->IsWebGL2OrES3Context(); valid_dest_format = feature_info->IsWebGL2OrES3OrHigherContext();
break; break;
case GL_RGB9_E5: case GL_RGB9_E5:
case GL_R16F: case GL_R16F:
......
...@@ -59,7 +59,10 @@ gl::GLContextAttribs GenerateGLContextAttribs( ...@@ -59,7 +59,10 @@ gl::GLContextAttribs GenerateGLContextAttribs(
attribs.robust_buffer_access = true; attribs.robust_buffer_access = true;
// Request a specific context version instead of always 3.0 // Request a specific context version instead of always 3.0
if (IsWebGL2OrES3ContextType(attribs_helper.context_type)) { if (IsWebGL2ComputeContextType(attribs_helper.context_type)) {
attribs.client_major_es_version = 3;
attribs.client_minor_es_version = 1;
} else if (IsWebGL2OrES3ContextType(attribs_helper.context_type)) {
attribs.client_major_es_version = 3; attribs.client_major_es_version = 3;
attribs.client_minor_es_version = 0; attribs.client_minor_es_version = 0;
} else { } else {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment