Skip to content

Commit

Permalink
webgl_rendering_context_base patch change.
Browse files Browse the repository at this point in the history
Shifted a couple of patches.

Chromium change:

https://source.chromium.org/chromium/chromium/src/+/c67854d8f41a3b02257e2acb2fb7480f609abd11

commit c67854d8f41a3b02257e2acb2fb7480f609abd11
Author: James Darpinian <[email protected]>
Date:   Thu Nov 26 00:22:24 2020 +0000

    COMPLETION_STATUS_KHR should be true on context loss

    KHR_parallel_shader_compile COMPLETION_STATUS_KHR queries should return
    true unconditionally when the context is lost. This is intended to
    prevent applications from entering an infinite polling loop.

    Spec clarification and test are landing upstream:
    KhronosGroup/WebGL#3188

    Bug: angleproject:3379
  • Loading branch information
mkarolin authored and mariospr committed Jan 12, 2021
1 parent 831b1cd commit 98cf3cf
Showing 1 changed file with 29 additions and 29 deletions.
Original file line number Diff line number Diff line change
@@ -1,176 +1,176 @@
diff --git a/third_party/blink/renderer/modules/webgl/webgl_rendering_context_base.cc b/third_party/blink/renderer/modules/webgl/webgl_rendering_context_base.cc
index 03d950b017d1211fceaf32c00910a583fe457db2..395698b67a5b096ad584b230116c7555da18714f 100644
index d85df2b63b469f935b5b5e8813ac1437e6ee5e99..596c6c3aba2785f6bbb7768bc352e33bd525c9bb 100644
--- a/third_party/blink/renderer/modules/webgl/webgl_rendering_context_base.cc
+++ b/third_party/blink/renderer/modules/webgl/webgl_rendering_context_base.cc
@@ -2916,6 +2916,7 @@ WebGLActiveInfo* WebGLRenderingContextBase::getActiveAttrib(
@@ -2972,6 +2972,7 @@ WebGLActiveInfo* WebGLRenderingContextBase::getActiveAttrib(
GLuint index) {
if (!ValidateWebGLProgramOrShader("getActiveAttrib", program))
return nullptr;
+ BRAVE_WEBGL_RENDERING_CONTEXT_BASE_NULLPTR
GLuint program_id = ObjectNonZero(program);
GLint max_name_length = -1;
ContextGL()->GetProgramiv(program_id, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH,
@@ -2947,6 +2948,7 @@ WebGLActiveInfo* WebGLRenderingContextBase::getActiveUniform(
@@ -3003,6 +3004,7 @@ WebGLActiveInfo* WebGLRenderingContextBase::getActiveUniform(
GLuint index) {
if (!ValidateWebGLProgramOrShader("getActiveUniform", program))
return nullptr;
+ BRAVE_WEBGL_RENDERING_CONTEXT_BASE_NULLPTR
GLuint program_id = ObjectNonZero(program);
GLint max_name_length = -1;
ContextGL()->GetProgramiv(program_id, GL_ACTIVE_UNIFORM_MAX_LENGTH,
@@ -2977,6 +2979,7 @@ base::Optional<HeapVector<Member<WebGLShader>>>
@@ -3033,6 +3035,7 @@ base::Optional<HeapVector<Member<WebGLShader>>>
WebGLRenderingContextBase::getAttachedShaders(WebGLProgram* program) {
if (!ValidateWebGLProgramOrShader("getAttachedShaders", program))
return base::nullopt;
+ BRAVE_WEBGL_RENDERING_CONTEXT_BASE_NULLOPT

HeapVector<Member<WebGLShader>> shader_objects;
for (GLenum shaderType : {GL_VERTEX_SHADER, GL_FRAGMENT_SHADER}) {
@@ -2991,6 +2994,7 @@ GLint WebGLRenderingContextBase::getAttribLocation(WebGLProgram* program,
@@ -3047,6 +3050,7 @@ GLint WebGLRenderingContextBase::getAttribLocation(WebGLProgram* program,
const String& name) {
if (!ValidateWebGLProgramOrShader("getAttribLocation", program))
return -1;
+ BRAVE_WEBGL_RENDERING_CONTEXT_BASE_MINUS_ONE
if (!ValidateLocationLength("getAttribLocation", name))
return -1;
if (!ValidateString("getAttribLocation", name))
@@ -3024,6 +3028,7 @@ ScriptValue WebGLRenderingContextBase::getBufferParameter(
@@ -3080,6 +3084,7 @@ ScriptValue WebGLRenderingContextBase::getBufferParameter(
GLenum pname) {
if (isContextLost() || !ValidateBufferTarget("getBufferParameter", target))
return ScriptValue::CreateNull(script_state->GetIsolate());
+ BRAVE_WEBGL_RENDERING_CONTEXT_BASE_SCRIPT_VALUE

switch (pname) {
case GL_BUFFER_USAGE: {
@@ -3160,6 +3165,7 @@ ScriptValue WebGLRenderingContextBase::getFramebufferAttachmentParameter(
@@ -3216,6 +3221,7 @@ ScriptValue WebGLRenderingContextBase::getFramebufferAttachmentParameter(
target, attachment))
return ScriptValue::CreateNull(script_state->GetIsolate());

+ BRAVE_WEBGL_RENDERING_CONTEXT_BASE_SCRIPT_VALUE
if (!framebuffer_binding_ || !framebuffer_binding_->Object()) {
SynthesizeGLError(GL_INVALID_OPERATION, "getFramebufferAttachmentParameter",
"no framebuffer bound");
@@ -3553,6 +3559,7 @@ ScriptValue WebGLRenderingContextBase::getParameter(ScriptState* script_state,
@@ -3617,6 +3623,7 @@ ScriptValue WebGLRenderingContextBase::getParameter(ScriptState* script_state,
"invalid parameter name, OES_standard_derivatives not enabled");
return ScriptValue::CreateNull(script_state->GetIsolate());
case WebGLDebugRendererInfo::kUnmaskedRendererWebgl:
+ BRAVE_WEBGL_GET_PARAMETER_UNMASKED_RENDERER
if (ExtensionEnabled(kWebGLDebugRendererInfoName)) {
if (IdentifiabilityStudySettings::Get()->ShouldSample(
blink::IdentifiableSurface::Type::kWebGLParameter)) {
@@ -3568,6 +3575,7 @@ ScriptValue WebGLRenderingContextBase::getParameter(ScriptState* script_state,
@@ -3632,6 +3639,7 @@ ScriptValue WebGLRenderingContextBase::getParameter(ScriptState* script_state,
"invalid parameter name, WEBGL_debug_renderer_info not enabled");
return ScriptValue::CreateNull(script_state->GetIsolate());
case WebGLDebugRendererInfo::kUnmaskedVendorWebgl:
+ BRAVE_WEBGL_GET_PARAMETER_UNMASKED_VENDOR
if (ExtensionEnabled(kWebGLDebugRendererInfoName)) {
if (IdentifiabilityStudySettings::Get()->ShouldSample(
blink::IdentifiableSurface::Type::kWebGLParameter)) {
@@ -3656,6 +3664,7 @@ ScriptValue WebGLRenderingContextBase::getProgramParameter(
ScriptState* script_state,
WebGLProgram* program,
GLenum pname) {
@@ -3724,6 +3732,7 @@ ScriptValue WebGLRenderingContextBase::getProgramParameter(
// intended to prevent applications from entering an infinite polling loop.
if (isContextLost() && pname == GL_COMPLETION_STATUS_KHR)
return WebGLAny(script_state, true);
+ BRAVE_WEBGL_RENDERING_CONTEXT_BASE_SCRIPT_VALUE
if (!ValidateWebGLProgramOrShader("getProgramParamter", program)) {
return ScriptValue::CreateNull(script_state->GetIsolate());
}
@@ -3711,6 +3720,7 @@ ScriptValue WebGLRenderingContextBase::getProgramParameter(
@@ -3779,6 +3788,7 @@ ScriptValue WebGLRenderingContextBase::getProgramParameter(
String WebGLRenderingContextBase::getProgramInfoLog(WebGLProgram* program) {
if (!ValidateWebGLProgramOrShader("getProgramInfoLog", program))
return String();
+ BRAVE_WEBGL_RENDERING_CONTEXT_BASE_STRING
GLStringQuery query(ContextGL());
return query.Run<GLStringQuery::ProgramInfoLog>(ObjectNonZero(program));
}
@@ -3721,6 +3731,7 @@ ScriptValue WebGLRenderingContextBase::getRenderbufferParameter(
@@ -3789,6 +3799,7 @@ ScriptValue WebGLRenderingContextBase::getRenderbufferParameter(
GLenum pname) {
if (isContextLost())
return ScriptValue::CreateNull(script_state->GetIsolate());
+ BRAVE_WEBGL_RENDERING_CONTEXT_BASE_SCRIPT_VALUE
if (target != GL_RENDERBUFFER) {
SynthesizeGLError(GL_INVALID_ENUM, "getRenderbufferParameter",
"invalid target");
@@ -3768,6 +3779,7 @@ ScriptValue WebGLRenderingContextBase::getShaderParameter(
ScriptState* script_state,
WebGLShader* shader,
GLenum pname) {
@@ -3840,6 +3851,7 @@ ScriptValue WebGLRenderingContextBase::getShaderParameter(
// intended to prevent applications from entering an infinite polling loop.
if (isContextLost() && pname == GL_COMPLETION_STATUS_KHR)
return WebGLAny(script_state, true);
+ BRAVE_WEBGL_RENDERING_CONTEXT_BASE_SCRIPT_VALUE
if (!ValidateWebGLProgramOrShader("getShaderParameter", shader)) {
return ScriptValue::CreateNull(script_state->GetIsolate());
}
@@ -3799,6 +3811,7 @@ ScriptValue WebGLRenderingContextBase::getShaderParameter(
@@ -3871,6 +3883,7 @@ ScriptValue WebGLRenderingContextBase::getShaderParameter(
String WebGLRenderingContextBase::getShaderInfoLog(WebGLShader* shader) {
if (!ValidateWebGLProgramOrShader("getShaderInfoLog", shader))
return String();
+ BRAVE_WEBGL_RENDERING_CONTEXT_BASE_STRING
GLStringQuery query(ContextGL());
return query.Run<GLStringQuery::ShaderInfoLog>(ObjectNonZero(shader));
}
@@ -3829,6 +3842,7 @@ WebGLShaderPrecisionFormat* WebGLRenderingContextBase::getShaderPrecisionFormat(
@@ -3901,6 +3914,7 @@ WebGLShaderPrecisionFormat* WebGLRenderingContextBase::getShaderPrecisionFormat(
GLint precision = 0;
ContextGL()->GetShaderPrecisionFormat(shader_type, precision_type, range,
&precision);
+ BRAVE_WEBGL_RENDERING_CONTEXT_BASE_GETSHADERINFOLOG
auto* result = MakeGarbageCollected<WebGLShaderPrecisionFormat>(
range[0], range[1], precision);
if (IdentifiabilityStudySettings::Get()->ShouldSample(
@@ -3841,6 +3855,7 @@ WebGLShaderPrecisionFormat* WebGLRenderingContextBase::getShaderPrecisionFormat(
@@ -3913,6 +3927,7 @@ WebGLShaderPrecisionFormat* WebGLRenderingContextBase::getShaderPrecisionFormat(
String WebGLRenderingContextBase::getShaderSource(WebGLShader* shader) {
if (!ValidateWebGLProgramOrShader("getShaderSource", shader))
return String();
+ BRAVE_WEBGL_RENDERING_CONTEXT_BASE_STRING
return EnsureNotNull(shader->Source());
}

@@ -3848,6 +3863,7 @@ base::Optional<Vector<String>>
@@ -3920,6 +3935,7 @@ base::Optional<Vector<String>>
WebGLRenderingContextBase::getSupportedExtensions() {
if (isContextLost())
return base::nullopt;
+ BRAVE_WEBGL_RENDERING_CONTEXT_BASE_NULLOPT

Vector<String> result;

@@ -3870,6 +3886,7 @@ ScriptValue WebGLRenderingContextBase::getTexParameter(
@@ -3942,6 +3958,7 @@ ScriptValue WebGLRenderingContextBase::getTexParameter(
GLenum pname) {
if (isContextLost())
return ScriptValue::CreateNull(script_state->GetIsolate());
+ BRAVE_WEBGL_RENDERING_CONTEXT_BASE_SCRIPT_VALUE
if (!ValidateTextureBinding("getTexParameter", target))
return ScriptValue::CreateNull(script_state->GetIsolate());
switch (pname) {
@@ -3904,6 +3921,7 @@ ScriptValue WebGLRenderingContextBase::getUniform(
@@ -3976,6 +3993,7 @@ ScriptValue WebGLRenderingContextBase::getUniform(
const WebGLUniformLocation* uniform_location) {
if (!ValidateWebGLProgramOrShader("getUniform", program))
return ScriptValue::CreateNull(script_state->GetIsolate());
+ BRAVE_WEBGL_RENDERING_CONTEXT_BASE_SCRIPT_VALUE
DCHECK(uniform_location);
if (uniform_location->Program() != program) {
SynthesizeGLError(GL_INVALID_OPERATION, "getUniform",
@@ -4163,6 +4181,7 @@ WebGLUniformLocation* WebGLRenderingContextBase::getUniformLocation(
@@ -4235,6 +4253,7 @@ WebGLUniformLocation* WebGLRenderingContextBase::getUniformLocation(
const String& name) {
if (!ValidateWebGLProgramOrShader("getUniformLocation", program))
return nullptr;
+ BRAVE_WEBGL_RENDERING_CONTEXT_BASE_NULLPTR
if (!ValidateLocationLength("getUniformLocation", name))
return nullptr;
if (!ValidateString("getUniformLocation", name))
@@ -4187,6 +4206,7 @@ ScriptValue WebGLRenderingContextBase::getVertexAttrib(
@@ -4259,6 +4278,7 @@ ScriptValue WebGLRenderingContextBase::getVertexAttrib(
GLenum pname) {
if (isContextLost())
return ScriptValue::CreateNull(script_state->GetIsolate());
+ BRAVE_WEBGL_RENDERING_CONTEXT_BASE_SCRIPT_VALUE
if (index >= max_vertex_attribs_) {
SynthesizeGLError(GL_INVALID_VALUE, "getVertexAttrib",
"index out of range");
@@ -4264,6 +4284,7 @@ int64_t WebGLRenderingContextBase::getVertexAttribOffset(GLuint index,
@@ -4336,6 +4356,7 @@ int64_t WebGLRenderingContextBase::getVertexAttribOffset(GLuint index,
GLenum pname) {
if (isContextLost())
return 0;
+ BRAVE_WEBGL_RENDERING_CONTEXT_BASE_ZERO
GLvoid* result = nullptr;
// NOTE: If pname is ever a value that returns more than 1 element
// this will corrupt memory.
@@ -4621,6 +4642,7 @@ void WebGLRenderingContextBase::ReadPixelsHelper(GLint x,
@@ -4693,6 +4714,7 @@ void WebGLRenderingContextBase::ReadPixelsHelper(GLint x,
int64_t offset) {
if (isContextLost())
return;
Expand Down

0 comments on commit 98cf3cf

Please sign in to comment.