Commit 0ee1586a authored by zmo's avatar zmo Committed by Commit bot

Distinguish ES2/ES3 contexts in GPU command buffer

BUG=463675
TEST=bots, WebGL2 demos
R=kbr@chromium.org,bajones@chromium.org

Review URL: https://codereview.chromium.org/978593003

Cr-Commit-Position: refs/heads/master@{#319016}
parent 6e37f17a
...@@ -1183,6 +1183,8 @@ void WebGraphicsContext3DImpl::ConvertAttributes( ...@@ -1183,6 +1183,8 @@ void WebGraphicsContext3DImpl::ConvertAttributes(
output_attribs->fail_if_major_perf_caveat = output_attribs->fail_if_major_perf_caveat =
attributes.failIfMajorPerformanceCaveat; attributes.failIfMajorPerformanceCaveat;
output_attribs->bind_generates_resource = false; output_attribs->bind_generates_resource = false;
output_attribs->es3_context_required =
(attributes.webGL && attributes.webGLVersion == 2);
} }
} // namespace gpu_blink } // namespace gpu_blink
...@@ -894,6 +894,7 @@ const int32 kBufferDestroyed = 0x3095; // EGL_BUFFER_DESTROYED ...@@ -894,6 +894,7 @@ const int32 kBufferDestroyed = 0x3095; // EGL_BUFFER_DESTROYED
const int32 kBindGeneratesResource = 0x10000; const int32 kBindGeneratesResource = 0x10000;
const int32 kFailIfMajorPerfCaveat = 0x10001; const int32 kFailIfMajorPerfCaveat = 0x10001;
const int32 kLoseContextWhenOutOfMemory = 0x10002; const int32 kLoseContextWhenOutOfMemory = 0x10002;
const int32 kES3ContextRequired = 0x10003;
} // namespace } // namespace
...@@ -909,7 +910,8 @@ ContextCreationAttribHelper::ContextCreationAttribHelper() ...@@ -909,7 +910,8 @@ ContextCreationAttribHelper::ContextCreationAttribHelper()
buffer_preserved(true), buffer_preserved(true),
bind_generates_resource(true), bind_generates_resource(true),
fail_if_major_perf_caveat(false), fail_if_major_perf_caveat(false),
lose_context_when_out_of_memory(false) {} lose_context_when_out_of_memory(false),
es3_context_required(false) {}
void ContextCreationAttribHelper::Serialize(std::vector<int32>* attribs) const { void ContextCreationAttribHelper::Serialize(std::vector<int32>* attribs) const {
if (alpha_size != -1) { if (alpha_size != -1) {
...@@ -952,6 +954,8 @@ void ContextCreationAttribHelper::Serialize(std::vector<int32>* attribs) const { ...@@ -952,6 +954,8 @@ void ContextCreationAttribHelper::Serialize(std::vector<int32>* attribs) const {
attribs->push_back(fail_if_major_perf_caveat ? 1 : 0); attribs->push_back(fail_if_major_perf_caveat ? 1 : 0);
attribs->push_back(kLoseContextWhenOutOfMemory); attribs->push_back(kLoseContextWhenOutOfMemory);
attribs->push_back(lose_context_when_out_of_memory ? 1 : 0); attribs->push_back(lose_context_when_out_of_memory ? 1 : 0);
attribs->push_back(kES3ContextRequired);
attribs->push_back(es3_context_required ? 1 : 0);
attribs->push_back(kNone); attribs->push_back(kNone);
} }
...@@ -1006,6 +1010,9 @@ bool ContextCreationAttribHelper::Parse(const std::vector<int32>& attribs) { ...@@ -1006,6 +1010,9 @@ bool ContextCreationAttribHelper::Parse(const std::vector<int32>& attribs) {
case kLoseContextWhenOutOfMemory: case kLoseContextWhenOutOfMemory:
lose_context_when_out_of_memory = value != 0; lose_context_when_out_of_memory = value != 0;
break; break;
case kES3ContextRequired:
es3_context_required = value != 0;
break;
case kNone: case kNone:
// Terminate list, even if more attributes. // Terminate list, even if more attributes.
return true; return true;
......
...@@ -223,6 +223,7 @@ struct GLES2_UTILS_EXPORT ContextCreationAttribHelper { ...@@ -223,6 +223,7 @@ struct GLES2_UTILS_EXPORT ContextCreationAttribHelper {
bool bind_generates_resource; bool bind_generates_resource;
bool fail_if_major_perf_caveat; bool fail_if_major_perf_caveat;
bool lose_context_when_out_of_memory; bool lose_context_when_out_of_memory;
bool es3_context_required;
}; };
} // namespace gles2 } // namespace gles2
......
...@@ -2441,6 +2441,10 @@ bool GLES2DecoderImpl::Initialize( ...@@ -2441,6 +2441,10 @@ bool GLES2DecoderImpl::Initialize(
DCHECK(context->IsCurrent(surface.get())); DCHECK(context->IsCurrent(surface.get()));
DCHECK(!context_.get()); DCHECK(!context_.get());
ContextCreationAttribHelper attrib_parser;
if (!attrib_parser.Parse(attribs))
return false;
surfaceless_ = surface->IsSurfaceless() && !offscreen; surfaceless_ = surface->IsSurfaceless() && !offscreen;
set_initialized(); set_initialized();
...@@ -2457,7 +2461,10 @@ bool GLES2DecoderImpl::Initialize( ...@@ -2457,7 +2461,10 @@ bool GLES2DecoderImpl::Initialize(
} }
if (base::CommandLine::ForCurrentProcess()->HasSwitch( if (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableUnsafeES3APIs)) { switches::kEnableUnsafeES3APIs) &&
attrib_parser.es3_context_required) {
// TODO(zmo): We need to implement capabilities check to ensure we can
// actually create ES3 contexts.
set_unsafe_es3_apis_enabled(true); set_unsafe_es3_apis_enabled(true);
} }
...@@ -2470,10 +2477,6 @@ bool GLES2DecoderImpl::Initialize( ...@@ -2470,10 +2477,6 @@ bool GLES2DecoderImpl::Initialize(
context_ = context; context_ = context;
surface_ = surface; surface_ = surface;
ContextCreationAttribHelper attrib_parser;
if (!attrib_parser.Parse(attribs))
return false;
// Create GPU Tracer for timing values. // Create GPU Tracer for timing values.
gpu_tracer_.reset(new GPUTracer(this)); gpu_tracer_.reset(new GPUTracer(this));
...@@ -2956,9 +2959,15 @@ bool GLES2DecoderImpl::InitializeShaderTranslator() { ...@@ -2956,9 +2959,15 @@ bool GLES2DecoderImpl::InitializeShaderTranslator() {
features().nv_draw_buffers ? 1 : 0; features().nv_draw_buffers ? 1 : 0;
} }
ShShaderSpec shader_spec = force_webgl_glsl_validation_ ? SH_WEBGL_SPEC ShShaderSpec shader_spec;
: SH_GLES2_SPEC; if (force_webgl_glsl_validation_) {
if (shader_spec == SH_WEBGL_SPEC && features().enable_shader_name_hashing) shader_spec = unsafe_es3_apis_enabled() ? SH_WEBGL2_SPEC : SH_WEBGL_SPEC;
} else {
shader_spec = unsafe_es3_apis_enabled() ? SH_GLES3_SPEC : SH_GLES2_SPEC;
}
if ((shader_spec == SH_WEBGL_SPEC || shader_spec == SH_WEBGL2_SPEC) &&
features().enable_shader_name_hashing)
resources.HashFunction = &CityHash64; resources.HashFunction = &CityHash64;
else else
resources.HashFunction = NULL; resources.HashFunction = NULL;
......
...@@ -110,13 +110,19 @@ bool ShaderTranslator::Init( ...@@ -110,13 +110,19 @@ bool ShaderTranslator::Init(
// Make sure Init is called only once. // Make sure Init is called only once.
DCHECK(compiler_ == NULL); DCHECK(compiler_ == NULL);
DCHECK(shader_type == GL_FRAGMENT_SHADER || shader_type == GL_VERTEX_SHADER); DCHECK(shader_type == GL_FRAGMENT_SHADER || shader_type == GL_VERTEX_SHADER);
DCHECK(shader_spec == SH_GLES2_SPEC || shader_spec == SH_WEBGL_SPEC); DCHECK(shader_spec == SH_GLES2_SPEC || shader_spec == SH_WEBGL_SPEC ||
shader_spec == SH_GLES3_SPEC || shader_spec == SH_WEBGL2_SPEC);
DCHECK(resources != NULL); DCHECK(resources != NULL);
g_translator_initializer.Get(); g_translator_initializer.Get();
ShShaderOutput shader_output = ShShaderOutput shader_output;
(glsl_implementation_type == kGlslES ? SH_ESSL_OUTPUT : SH_GLSL_OUTPUT); if (glsl_implementation_type == kGlslES) {
shader_output = SH_ESSL_OUTPUT;
} else {
shader_output = (shader_spec == SH_WEBGL2_SPEC) ? SH_GLSL_CORE_OUTPUT :
SH_GLSL_COMPATIBILITY_OUTPUT;
}
{ {
TRACE_EVENT0("gpu", "ShConstructCompiler"); TRACE_EVENT0("gpu", "ShConstructCompiler");
......
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