Skip to content

Commit

Permalink
Implement WEBGL_clip_cull_distance as draft extension.
Browse files Browse the repository at this point in the history
Extension is specified as:
https://registry.khronos.org/webgl/extensions/WEBGL_clip_cull_distance/

Skip the extension availability test on the validating command
decoder; the extension is only hooked up in ANGLE + the passthrough
command decoder.

Thanks to Alexey Knyazev for this patch.

Bug: 1410603
Change-Id: Ifb1933cded268d861a51adcefec0bf83cd667b20
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4201271
Auto-Submit: Kenneth Russell <kbr@chromium.org>
Reviewed-by: Gregg Tavares <gman@chromium.org>
Commit-Queue: Kenneth Russell <kbr@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1099005}
  • Loading branch information
kenrussell authored and Chromium LUCI CQ committed Jan 31, 2023
1 parent 8635d52 commit 2be4352
Show file tree
Hide file tree
Showing 15 changed files with 185 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,9 @@ crbug.com/1058744 [ no-passthrough ] WebglExtension_OES_draw_buffers_indexed [ S
[ android qualcomm ] WebglExtension_WEBGL_compressed_texture_s3tc [ Skip ]
[ android qualcomm ] WebglExtension_WEBGL_compressed_texture_s3tc_srgb [ Skip ]

# Extension only available via passthrough decoder.
# Extensions only available via passthrough decoder.
crbug.com/1194209 [ mac no-passthrough ] WebglExtension_WEBGL_webcodecs_video_frame [ Skip ]
crbug.com/1410603 [ no-passthrough ] WebglExtension_WEBGL_clip_cull_distance [ Skip ]

# Extension only available through passthrough decoder?
crbug.com/849576 [ no-passthrough ] WebglExtension_KHR_parallel_shader_compile [ Skip ]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def _GetExtensionList(cls) -> List[str]:
'OES_draw_buffers_indexed',
'OES_texture_float_linear',
'OVR_multiview2',
'WEBGL_clip_cull_distance',
'WEBGL_compressed_texture_astc',
'WEBGL_compressed_texture_etc',
'WEBGL_compressed_texture_etc1',
Expand Down
49 changes: 49 additions & 0 deletions gpu/GLES2/gl2extchromium.h
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,55 @@ GL_APICALL void GL_APIENTRY glProvokingVertexANGLE(GLenum provokeMode);
typedef void(GL_APIENTRYP PFNGLPROVOKINGVERTEXANGLEPROC)(GLenum provokeMode);
#endif /* GL_ANGLE_provoking_vertex */

/* GL_ANGLE_clip_cull_distance */
#ifndef GL_ANGLE_clip_cull_distance
#define GL_ANGLE_clip_cull_distance 1

#ifndef GL_MAX_CLIP_DISTANCES_ANGLE
#define GL_MAX_CLIP_DISTANCES_ANGLE 0x0D32
#endif

#ifndef GL_MAX_CULL_DISTANCES_ANGLE
#define GL_MAX_CULL_DISTANCES_ANGLE 0x82F9
#endif

#ifndef GL_MAX_COMBINED_CLIP_AND_CULL_DISTANCES_ANGLE
#define GL_MAX_COMBINED_CLIP_AND_CULL_DISTANCES_ANGLE 0x82FA
#endif

#ifndef GL_CLIP_DISTANCE0_ANGLE
#define GL_CLIP_DISTANCE0_ANGLE 0x3000
#endif

#ifndef GL_CLIP_DISTANCE1_ANGLE
#define GL_CLIP_DISTANCE1_ANGLE 0x3001
#endif

#ifndef GL_CLIP_DISTANCE2_ANGLE
#define GL_CLIP_DISTANCE2_ANGLE 0x3002
#endif

#ifndef GL_CLIP_DISTANCE3_ANGLE
#define GL_CLIP_DISTANCE3_ANGLE 0x3003
#endif

#ifndef GL_CLIP_DISTANCE4_ANGLE
#define GL_CLIP_DISTANCE4_ANGLE 0x3004
#endif

#ifndef GL_CLIP_DISTANCE5_ANGLE
#define GL_CLIP_DISTANCE5_ANGLE 0x3005
#endif

#ifndef GL_CLIP_DISTANCE6_ANGLE
#define GL_CLIP_DISTANCE6_ANGLE 0x3006
#endif

#ifndef GL_CLIP_DISTANCE7_ANGLE
#define GL_CLIP_DISTANCE7_ANGLE 0x3007
#endif
#endif /* GL_ANGLE_clip_cull_distance */

/* GL_CHROMIUM_async_pixel_transfers */
#ifndef GL_CHROMIUM_async_pixel_transfers
#define GL_CHROMIUM_async_pixel_transfers 1
Expand Down
5 changes: 5 additions & 0 deletions gpu/command_buffer/service/feature_info.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1736,6 +1736,11 @@ void FeatureInfo::InitializeFeatures() {
feature_flags_.angle_provoking_vertex = true;
AddExtensionString("GL_ANGLE_provoking_vertex");
}

if (gfx::HasExtension(extensions, "GL_ANGLE_clip_cull_distance")) {
feature_flags_.angle_clip_cull_distance = true;
AddExtensionString("GL_ANGLE_clip_cull_distance");
}
}

void FeatureInfo::InitializeFloatAndHalfFloatFeatures(
Expand Down
1 change: 1 addition & 0 deletions gpu/command_buffer/service/feature_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ class GPU_GLES2_EXPORT FeatureInfo : public base::RefCounted<FeatureInfo> {
bool ext_yuv_target = false;
bool angle_rgbx_internal_format = false;
bool angle_provoking_vertex = false;
bool angle_clip_cull_distance = false;
};

FeatureInfo();
Expand Down
2 changes: 2 additions & 0 deletions third_party/blink/renderer/bindings/generated_in_modules.gni
Original file line number Diff line number Diff line change
Expand Up @@ -2491,6 +2491,8 @@ generated_interface_sources_in_modules = [
"$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_webgl_active_info.h",
"$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_webgl_buffer.cc",
"$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_webgl_buffer.h",
"$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_webgl_clip_cull_distance.cc",
"$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_webgl_clip_cull_distance.h",
"$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_webgl_color_buffer_float.cc",
"$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_webgl_color_buffer_float.h",
"$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_webgl_compressed_texture_astc.cc",
Expand Down
1 change: 1 addition & 0 deletions third_party/blink/renderer/bindings/idl_in_modules.gni
Original file line number Diff line number Diff line change
Expand Up @@ -921,6 +921,7 @@ static_idl_files_in_modules = get_path_info(
"//third_party/blink/renderer/modules/webgl/webgl2_rendering_context_base.idl",
"//third_party/blink/renderer/modules/webgl/webgl_active_info.idl",
"//third_party/blink/renderer/modules/webgl/webgl_buffer.idl",
"//third_party/blink/renderer/modules/webgl/webgl_clip_cull_distance.idl",
"//third_party/blink/renderer/modules/webgl/webgl_color_buffer_float.idl",
"//third_party/blink/renderer/modules/webgl/webgl_compressed_texture_astc.idl",
"//third_party/blink/renderer/modules/webgl/webgl_compressed_texture_etc.idl",
Expand Down
2 changes: 2 additions & 0 deletions third_party/blink/renderer/modules/webgl/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ blink_modules_sources("webgl") {
"webgl_active_info.h",
"webgl_buffer.cc",
"webgl_buffer.h",
"webgl_clip_cull_distance.cc",
"webgl_clip_cull_distance.h",
"webgl_color_buffer_float.cc",
"webgl_color_buffer_float.h",
"webgl_compressed_texture_astc.cc",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "third_party/blink/renderer/modules/webgl/oes_draw_buffers_indexed.h"
#include "third_party/blink/renderer/modules/webgl/oes_texture_float_linear.h"
#include "third_party/blink/renderer/modules/webgl/ovr_multiview_2.h"
#include "third_party/blink/renderer/modules/webgl/webgl_clip_cull_distance.h"
#include "third_party/blink/renderer/modules/webgl/webgl_compressed_texture_astc.h"
#include "third_party/blink/renderer/modules/webgl/webgl_compressed_texture_etc.h"
#include "third_party/blink/renderer/modules/webgl/webgl_compressed_texture_etc1.h"
Expand Down Expand Up @@ -164,6 +165,7 @@ void WebGL2RenderingContext::RegisterContextExtensions() {
RegisterExtension(oes_draw_buffers_indexed_);
RegisterExtension(oes_texture_float_linear_);
RegisterExtension(ovr_multiview2_);
RegisterExtension(webgl_clip_cull_distance_, kDraftExtension);
RegisterExtension(webgl_compressed_texture_astc_);
RegisterExtension(webgl_compressed_texture_etc_);
RegisterExtension(webgl_compressed_texture_etc1_);
Expand Down Expand Up @@ -196,6 +198,7 @@ void WebGL2RenderingContext::Trace(Visitor* visitor) const {
visitor->Trace(oes_draw_buffers_indexed_);
visitor->Trace(oes_texture_float_linear_);
visitor->Trace(ovr_multiview2_);
visitor->Trace(webgl_clip_cull_distance_);
visitor->Trace(webgl_compressed_texture_astc_);
visitor->Trace(webgl_compressed_texture_etc_);
visitor->Trace(webgl_compressed_texture_etc1_);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class KHRParallelShaderCompile;
class OESDrawBuffersIndexed;
class OESTextureFloatLinear;
class OVRMultiview2;
class WebGLClipCullDistance;
class WebGLDebugRendererInfo;
class WebGLDrawInstancedBaseVertexBaseInstance;
class WebGLLoseContext;
Expand Down Expand Up @@ -84,6 +85,7 @@ class WebGL2RenderingContext : public WebGL2RenderingContextBase {
Member<OESDrawBuffersIndexed> oes_draw_buffers_indexed_;
Member<OESTextureFloatLinear> oes_texture_float_linear_;
Member<OVRMultiview2> ovr_multiview2_;
Member<WebGLClipCullDistance> webgl_clip_cull_distance_;
Member<WebGLCompressedTextureASTC> webgl_compressed_texture_astc_;
Member<WebGLCompressedTextureETC> webgl_compressed_texture_etc_;
Member<WebGLCompressedTextureETC1> webgl_compressed_texture_etc1_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5399,6 +5399,28 @@ ScriptValue WebGL2RenderingContextBase::getParameter(ScriptState* script_state,
"invalid parameter name, "
"WEBGL_provoking_vertex not enabled");
return ScriptValue::CreateNull(script_state->GetIsolate());
case GL_MAX_CLIP_DISTANCES_ANGLE:
case GL_MAX_CULL_DISTANCES_ANGLE:
case GL_MAX_COMBINED_CLIP_AND_CULL_DISTANCES_ANGLE:
case GL_CLIP_DISTANCE0_ANGLE:
case GL_CLIP_DISTANCE1_ANGLE:
case GL_CLIP_DISTANCE2_ANGLE:
case GL_CLIP_DISTANCE3_ANGLE:
case GL_CLIP_DISTANCE4_ANGLE:
case GL_CLIP_DISTANCE5_ANGLE:
case GL_CLIP_DISTANCE6_ANGLE:
case GL_CLIP_DISTANCE7_ANGLE:
if (ExtensionEnabled(kWebGLClipCullDistanceName)) {
if (pname >= GL_CLIP_DISTANCE0_ANGLE &&
pname <= GL_CLIP_DISTANCE7_ANGLE) {
return GetBooleanParameter(script_state, pname);
}
return GetUnsignedIntParameter(script_state, pname);
}
SynthesizeGLError(GL_INVALID_ENUM, "getParameter",
"invalid parameter name, "
"WEBGL_clip_cull_distance not enabled");
return ScriptValue::CreateNull(script_state->GetIsolate());

default:
return WebGLRenderingContextBase::getParameter(script_state, pname);
Expand All @@ -5417,6 +5439,21 @@ ScriptValue WebGL2RenderingContextBase::GetInt64Parameter(
bool WebGL2RenderingContextBase::ValidateCapability(const char* function_name,
GLenum cap) {
switch (cap) {
case GL_CLIP_DISTANCE0_ANGLE:
case GL_CLIP_DISTANCE1_ANGLE:
case GL_CLIP_DISTANCE2_ANGLE:
case GL_CLIP_DISTANCE3_ANGLE:
case GL_CLIP_DISTANCE4_ANGLE:
case GL_CLIP_DISTANCE5_ANGLE:
case GL_CLIP_DISTANCE6_ANGLE:
case GL_CLIP_DISTANCE7_ANGLE:
if (ExtensionEnabled(kWebGLClipCullDistanceName)) {
return true;
}
SynthesizeGLError(
GL_INVALID_ENUM, function_name,
"invalid capability, WEBGL_clip_cull_distance not enabled");
return false;
case GL_RASTERIZER_DISCARD:
return true;
default:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "third_party/blink/renderer/modules/webgl/webgl_clip_cull_distance.h"

#include "third_party/blink/renderer/modules/webgl/webgl_rendering_context_base.h"

namespace blink {

WebGLClipCullDistance::WebGLClipCullDistance(WebGLRenderingContextBase* context)
: WebGLExtension(context) {
context->ExtensionsUtil()->EnsureExtensionEnabled(
"GL_ANGLE_clip_cull_distance");
}

WebGLExtensionName WebGLClipCullDistance::GetName() const {
return kWebGLClipCullDistanceName;
}

bool WebGLClipCullDistance::Supported(WebGLRenderingContextBase* context) {
return context->ExtensionsUtil()->SupportsExtension(
"GL_ANGLE_clip_cull_distance");
}

const char* WebGLClipCullDistance::ExtensionName() {
return "WEBGL_clip_cull_distance";
}

} // namespace blink
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_WEBGL_WEBGL_CLIP_CULL_DISTANCE_H_
#define THIRD_PARTY_BLINK_RENDERER_MODULES_WEBGL_WEBGL_CLIP_CULL_DISTANCE_H_

#include "third_party/blink/renderer/modules/webgl/webgl_extension.h"
#include "third_party/khronos/GLES2/gl2.h"

namespace blink {

class WebGLClipCullDistance final : public WebGLExtension {
DEFINE_WRAPPERTYPEINFO();

public:
static bool Supported(WebGLRenderingContextBase*);
static const char* ExtensionName();

explicit WebGLClipCullDistance(WebGLRenderingContextBase*);

WebGLExtensionName GetName() const override;
};

} // namespace blink

#endif // THIRD_PARTY_BLINK_RENDERER_MODULES_WEBGL_WEBGL_CLIP_CULL_DISTANCE_H_
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// https://www.khronos.org/registry/webgl/extensions/WEBGL_clip_cull_distance/

[
LegacyNoInterfaceObject,
DoNotCheckConstants
] interface WebGLClipCullDistance {
const unsigned long MAX_CLIP_DISTANCES_WEBGL = 0x0D32;
const unsigned long MAX_CULL_DISTANCES_WEBGL = 0x82F9;
const unsigned long MAX_COMBINED_CLIP_AND_CULL_DISTANCES_WEBGL = 0x82FA;
const unsigned long CLIP_DISTANCE0_WEBGL = 0x3000;
const unsigned long CLIP_DISTANCE1_WEBGL = 0x3001;
const unsigned long CLIP_DISTANCE2_WEBGL = 0x3002;
const unsigned long CLIP_DISTANCE3_WEBGL = 0x3003;
const unsigned long CLIP_DISTANCE4_WEBGL = 0x3004;
const unsigned long CLIP_DISTANCE5_WEBGL = 0x3005;
const unsigned long CLIP_DISTANCE6_WEBGL = 0x3006;
const unsigned long CLIP_DISTANCE7_WEBGL = 0x3007;
};
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ enum WebGLExtensionName {
kOESTextureHalfFloatName,
kOESVertexArrayObjectName,
kOVRMultiview2Name,
kWebGLClipCullDistanceName,
kWebGLColorBufferFloatName,
kWebGLCompressedTextureASTCName,
kWebGLCompressedTextureETCName,
Expand Down

0 comments on commit 2be4352

Please sign in to comment.