Skip to content

Commit

Permalink
Integrate WEBGL_multiview extension
Browse files Browse the repository at this point in the history
This adds working WEBGL_multiview extension integration to the
passthrough command buffer. It's not implemented in the validating
command buffer. The implementation is built completely on top of
ANGLE_multiview, and doesn't support native OVR_multiview as a
backend.

This doesn't yet include support for opaque framebuffers either. That
is intended to be done as a follow-up.

The extension is set as a draft extension so it is not enabled by
default. It can be enabled with the --enable-webgl-draft-extensions
flag.

BUG=864524
TEST=WebGL conformance tests

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: I3153bfa3e5fcb6a9e044c8b0762a8a400b728c7a
Reviewed-on: https://chromium-review.googlesource.com/1140299
Commit-Queue: Kenneth Russell <kbr@chromium.org>
Reviewed-by: Kenneth Russell <kbr@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#578425}
  • Loading branch information
Olli Etuaho authored and Commit Bot committed Jul 26, 2018
1 parent 23bf5c2 commit ad806a3
Show file tree
Hide file tree
Showing 49 changed files with 682 additions and 10 deletions.
2 changes: 1 addition & 1 deletion content/test/data/gpu/webgl_extension_test.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
if (missing_list.length == 0) {
webglTestHarness.reportResults(name, true, "All " + context_type + " extensions are being tested.");
} else {
var error_string = "The following " + context_type + " extensions are not being tested and should be added to GetExtensionList() in content/test/gpu/gpu_tests/webgl_conformance.py:";
var error_string = "The following " + context_type + " extensions are not being tested and should be added to GetExtensionList() in content/test/gpu/gpu_tests/webgl_conformance_integration_test.py:";
for (var i in missing_list) {
error_string += "\n\t" + missing_list[i];
}
Expand Down
6 changes: 6 additions & 0 deletions content/test/gpu/gpu_tests/webgl2_conformance_expectations.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ def SetExpectations(self):
self.Skip('WebglExtension_WEBGL_compressed_texture_s3tc_srgb',
['win', 'mac', 'linux'])
self.Skip('WebglExtension_EXT_disjoint_timer_query_webgl2', bug=808744)
self.Skip('WebglExtension_WEBGL_multiview',
['mac', 'linux', 'android'], bug=864524)

# The multiview extension is only expected to be supported through ANGLE.
self.Skip('WebglExtension_WEBGL_multiview',
['win', 'no_passthrough'], bug=864524)

# ========================
# Conformance expectations
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ def _GetExtensionList(cls):
'WEBGL_debug_renderer_info',
'WEBGL_debug_shaders',
'WEBGL_lose_context',
'WEBGL_multiview',
]

def RunActualGpuTest(self, test_path, *args):
Expand Down
2 changes: 2 additions & 0 deletions gpu/GLES2/gl2chromium_autogen.h
Original file line number Diff line number Diff line change
Expand Up @@ -405,5 +405,7 @@
#define glDestroyGpuFenceCHROMIUM GLES2_GET_FUN(DestroyGpuFenceCHROMIUM)
#define glInvalidateReadbackBufferShadowDataCHROMIUM \
GLES2_GET_FUN(InvalidateReadbackBufferShadowDataCHROMIUM)
#define glFramebufferTextureMultiviewLayeredANGLE \
GLES2_GET_FUN(FramebufferTextureMultiviewLayeredANGLE)

#endif // GPU_GLES2_GL2CHROMIUM_AUTOGEN_H_
7 changes: 7 additions & 0 deletions gpu/command_buffer/build_gles2_cmd_buffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -4077,6 +4077,13 @@
'extension': 'MESA_framebuffer_flip_y',
'extension_flag': 'mesa_framebuffer_flip_y',
},
'FramebufferTextureMultiviewLayeredANGLE': {
'decoder_func': 'DoFramebufferTextureMultiviewLayeredANGLE',
'unit_test': False,
'extension': 'ANGLE_multiview',
'trace_level': 1,
'es3': True
},
}


Expand Down
15 changes: 15 additions & 0 deletions gpu/command_buffer/client/gles2_c_lib_autogen.h
Original file line number Diff line number Diff line change
Expand Up @@ -1807,6 +1807,16 @@ void GL_APIENTRY
GLES2InvalidateReadbackBufferShadowDataCHROMIUM(GLuint buffer_id) {
gles2::GetGLContext()->InvalidateReadbackBufferShadowDataCHROMIUM(buffer_id);
}
void GL_APIENTRY
GLES2FramebufferTextureMultiviewLayeredANGLE(GLenum target,
GLenum attachment,
GLuint texture,
GLint level,
GLint baseViewIndex,
GLsizei numViews) {
gles2::GetGLContext()->FramebufferTextureMultiviewLayeredANGLE(
target, attachment, texture, level, baseViewIndex, numViews);
}

namespace gles2 {

Expand Down Expand Up @@ -3168,6 +3178,11 @@ extern const NameToFunc g_gles2_function_table[] = {
reinterpret_cast<GLES2FunctionPointer>(
glInvalidateReadbackBufferShadowDataCHROMIUM),
},
{
"glFramebufferTextureMultiviewLayeredANGLE",
reinterpret_cast<GLES2FunctionPointer>(
glFramebufferTextureMultiviewLayeredANGLE),
},
{
NULL, NULL,
},
Expand Down
13 changes: 13 additions & 0 deletions gpu/command_buffer/client/gles2_cmd_helper_autogen.h
Original file line number Diff line number Diff line change
Expand Up @@ -3345,4 +3345,17 @@ void SetReadbackBufferShadowAllocationINTERNAL(GLuint buffer_id,
}
}

void FramebufferTextureMultiviewLayeredANGLE(GLenum target,
GLenum attachment,
GLuint texture,
GLint level,
GLint baseViewIndex,
GLsizei numViews) {
gles2::cmds::FramebufferTextureMultiviewLayeredANGLE* c =
GetCmdSpace<gles2::cmds::FramebufferTextureMultiviewLayeredANGLE>();
if (c) {
c->Init(target, attachment, texture, level, baseViewIndex, numViews);
}
}

#endif // GPU_COMMAND_BUFFER_CLIENT_GLES2_CMD_HELPER_AUTOGEN_H_
7 changes: 7 additions & 0 deletions gpu/command_buffer/client/gles2_implementation_autogen.h
Original file line number Diff line number Diff line change
Expand Up @@ -1266,4 +1266,11 @@ void DestroyGpuFenceCHROMIUM(GLuint gpu_fence_id) override;

void InvalidateReadbackBufferShadowDataCHROMIUM(GLuint buffer_id) override;

void FramebufferTextureMultiviewLayeredANGLE(GLenum target,
GLenum attachment,
GLuint texture,
GLint level,
GLint baseViewIndex,
GLsizei numViews) override;

#endif // GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_AUTOGEN_H_
23 changes: 23 additions & 0 deletions gpu/command_buffer/client/gles2_implementation_impl_autogen.h
Original file line number Diff line number Diff line change
Expand Up @@ -3639,4 +3639,27 @@ void GLES2Implementation::DestroyGpuFenceCHROMIUM(GLuint gpu_fence_id) {
CheckGLError();
}

void GLES2Implementation::FramebufferTextureMultiviewLayeredANGLE(
GLenum target,
GLenum attachment,
GLuint texture,
GLint level,
GLint baseViewIndex,
GLsizei numViews) {
GPU_CLIENT_SINGLE_THREAD_CHECK();
GPU_CLIENT_LOG(
"[" << GetLogPrefix() << "] glFramebufferTextureMultiviewLayeredANGLE("
<< GLES2Util::GetStringEnum(target) << ", "
<< GLES2Util::GetStringEnum(attachment) << ", " << texture << ", "
<< level << ", " << baseViewIndex << ", " << numViews << ")");
if (numViews < 0) {
SetGLError(GL_INVALID_VALUE, "glFramebufferTextureMultiviewLayeredANGLE",
"numViews < 0");
return;
}
helper_->FramebufferTextureMultiviewLayeredANGLE(
target, attachment, texture, level, baseViewIndex, numViews);
CheckGLError();
}

#endif // GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_IMPL_AUTOGEN_H_
11 changes: 11 additions & 0 deletions gpu/command_buffer/client/gles2_implementation_unittest_autogen.h
Original file line number Diff line number Diff line change
Expand Up @@ -3161,4 +3161,15 @@ TEST_F(GLES2ImplementationTest, DestroyGpuFenceCHROMIUM) {
gl_->DestroyGpuFenceCHROMIUM(1);
EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
}

TEST_F(GLES2ImplementationTest, FramebufferTextureMultiviewLayeredANGLE) {
struct Cmds {
cmds::FramebufferTextureMultiviewLayeredANGLE cmd;
};
Cmds expected;
expected.cmd.Init(1, 2, 3, 4, 5, 6);

gl_->FramebufferTextureMultiviewLayeredANGLE(1, 2, 3, 4, 5, 6);
EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
}
#endif // GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_UNITTEST_AUTOGEN_H_
6 changes: 6 additions & 0 deletions gpu/command_buffer/client/gles2_interface_autogen.h
Original file line number Diff line number Diff line change
Expand Up @@ -943,4 +943,10 @@ virtual GLuint CreateClientGpuFenceCHROMIUM(ClientGpuFence source) = 0;
virtual void WaitGpuFenceCHROMIUM(GLuint gpu_fence_id) = 0;
virtual void DestroyGpuFenceCHROMIUM(GLuint gpu_fence_id) = 0;
virtual void InvalidateReadbackBufferShadowDataCHROMIUM(GLuint buffer_id) = 0;
virtual void FramebufferTextureMultiviewLayeredANGLE(GLenum target,
GLenum attachment,
GLuint texture,
GLint level,
GLint baseViewIndex,
GLsizei numViews) = 0;
#endif // GPU_COMMAND_BUFFER_CLIENT_GLES2_INTERFACE_AUTOGEN_H_
6 changes: 6 additions & 0 deletions gpu/command_buffer/client/gles2_interface_stub_autogen.h
Original file line number Diff line number Diff line change
Expand Up @@ -912,4 +912,10 @@ GLuint CreateClientGpuFenceCHROMIUM(ClientGpuFence source) override;
void WaitGpuFenceCHROMIUM(GLuint gpu_fence_id) override;
void DestroyGpuFenceCHROMIUM(GLuint gpu_fence_id) override;
void InvalidateReadbackBufferShadowDataCHROMIUM(GLuint buffer_id) override;
void FramebufferTextureMultiviewLayeredANGLE(GLenum target,
GLenum attachment,
GLuint texture,
GLint level,
GLint baseViewIndex,
GLsizei numViews) override;
#endif // GPU_COMMAND_BUFFER_CLIENT_GLES2_INTERFACE_STUB_AUTOGEN_H_
7 changes: 7 additions & 0 deletions gpu/command_buffer/client/gles2_interface_stub_impl_autogen.h
Original file line number Diff line number Diff line change
Expand Up @@ -1229,4 +1229,11 @@ void GLES2InterfaceStub::WaitGpuFenceCHROMIUM(GLuint /* gpu_fence_id */) {}
void GLES2InterfaceStub::DestroyGpuFenceCHROMIUM(GLuint /* gpu_fence_id */) {}
void GLES2InterfaceStub::InvalidateReadbackBufferShadowDataCHROMIUM(
GLuint /* buffer_id */) {}
void GLES2InterfaceStub::FramebufferTextureMultiviewLayeredANGLE(
GLenum /* target */,
GLenum /* attachment */,
GLuint /* texture */,
GLint /* level */,
GLint /* baseViewIndex */,
GLsizei /* numViews */) {}
#endif // GPU_COMMAND_BUFFER_CLIENT_GLES2_INTERFACE_STUB_IMPL_AUTOGEN_H_
Original file line number Diff line number Diff line change
Expand Up @@ -912,4 +912,10 @@ GLuint CreateClientGpuFenceCHROMIUM(ClientGpuFence source) override;
void WaitGpuFenceCHROMIUM(GLuint gpu_fence_id) override;
void DestroyGpuFenceCHROMIUM(GLuint gpu_fence_id) override;
void InvalidateReadbackBufferShadowDataCHROMIUM(GLuint buffer_id) override;
void FramebufferTextureMultiviewLayeredANGLE(GLenum target,
GLenum attachment,
GLuint texture,
GLint level,
GLint baseViewIndex,
GLsizei numViews) override;
#endif // GPU_COMMAND_BUFFER_CLIENT_GLES2_TRACE_IMPLEMENTATION_AUTOGEN_H_
Original file line number Diff line number Diff line change
Expand Up @@ -2625,4 +2625,17 @@ void GLES2TraceImplementation::InvalidateReadbackBufferShadowDataCHROMIUM(
gl_->InvalidateReadbackBufferShadowDataCHROMIUM(buffer_id);
}

void GLES2TraceImplementation::FramebufferTextureMultiviewLayeredANGLE(
GLenum target,
GLenum attachment,
GLuint texture,
GLint level,
GLint baseViewIndex,
GLsizei numViews) {
TRACE_EVENT_BINARY_EFFICIENT0(
"gpu", "GLES2Trace::FramebufferTextureMultiviewLayeredANGLE");
gl_->FramebufferTextureMultiviewLayeredANGLE(target, attachment, texture,
level, baseViewIndex, numViews);
}

#endif // GPU_COMMAND_BUFFER_CLIENT_GLES2_TRACE_IMPLEMENTATION_IMPL_AUTOGEN_H_
73 changes: 73 additions & 0 deletions gpu/command_buffer/common/gles2_cmd_format_autogen.h
Original file line number Diff line number Diff line change
Expand Up @@ -16492,4 +16492,77 @@ static_assert(
offsetof(SetReadbackBufferShadowAllocationINTERNAL, size) == 16,
"offset of SetReadbackBufferShadowAllocationINTERNAL size should be 16");

struct FramebufferTextureMultiviewLayeredANGLE {
typedef FramebufferTextureMultiviewLayeredANGLE ValueType;
static const CommandId kCmdId = kFramebufferTextureMultiviewLayeredANGLE;
static const cmd::ArgFlags kArgFlags = cmd::kFixed;
static const uint8_t cmd_flags = CMD_FLAG_SET_TRACE_LEVEL(1);

static uint32_t ComputeSize() {
return static_cast<uint32_t>(sizeof(ValueType)); // NOLINT
}

void SetHeader() { header.SetCmd<ValueType>(); }

void Init(GLenum _target,
GLenum _attachment,
GLuint _texture,
GLint _level,
GLint _baseViewIndex,
GLsizei _numViews) {
SetHeader();
target = _target;
attachment = _attachment;
texture = _texture;
level = _level;
baseViewIndex = _baseViewIndex;
numViews = _numViews;
}

void* Set(void* cmd,
GLenum _target,
GLenum _attachment,
GLuint _texture,
GLint _level,
GLint _baseViewIndex,
GLsizei _numViews) {
static_cast<ValueType*>(cmd)->Init(_target, _attachment, _texture, _level,
_baseViewIndex, _numViews);
return NextCmdAddress<ValueType>(cmd);
}

gpu::CommandHeader header;
uint32_t target;
uint32_t attachment;
uint32_t texture;
int32_t level;
int32_t baseViewIndex;
int32_t numViews;
};

static_assert(sizeof(FramebufferTextureMultiviewLayeredANGLE) == 28,
"size of FramebufferTextureMultiviewLayeredANGLE should be 28");
static_assert(
offsetof(FramebufferTextureMultiviewLayeredANGLE, header) == 0,
"offset of FramebufferTextureMultiviewLayeredANGLE header should be 0");
static_assert(
offsetof(FramebufferTextureMultiviewLayeredANGLE, target) == 4,
"offset of FramebufferTextureMultiviewLayeredANGLE target should be 4");
static_assert(
offsetof(FramebufferTextureMultiviewLayeredANGLE, attachment) == 8,
"offset of FramebufferTextureMultiviewLayeredANGLE attachment should be 8");
static_assert(
offsetof(FramebufferTextureMultiviewLayeredANGLE, texture) == 12,
"offset of FramebufferTextureMultiviewLayeredANGLE texture should be 12");
static_assert(
offsetof(FramebufferTextureMultiviewLayeredANGLE, level) == 16,
"offset of FramebufferTextureMultiviewLayeredANGLE level should be 16");
static_assert(offsetof(FramebufferTextureMultiviewLayeredANGLE,
baseViewIndex) == 20,
"offset of FramebufferTextureMultiviewLayeredANGLE baseViewIndex "
"should be 20");
static_assert(
offsetof(FramebufferTextureMultiviewLayeredANGLE, numViews) == 24,
"offset of FramebufferTextureMultiviewLayeredANGLE numViews should be 24");

#endif // GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_FORMAT_AUTOGEN_H_
20 changes: 20 additions & 0 deletions gpu/command_buffer/common/gles2_cmd_format_test_autogen.h
Original file line number Diff line number Diff line change
Expand Up @@ -5462,4 +5462,24 @@ TEST_F(GLES2FormatTest, SetReadbackBufferShadowAllocationINTERNAL) {
CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
}

TEST_F(GLES2FormatTest, FramebufferTextureMultiviewLayeredANGLE) {
cmds::FramebufferTextureMultiviewLayeredANGLE& cmd =
*GetBufferAs<cmds::FramebufferTextureMultiviewLayeredANGLE>();
void* next_cmd =
cmd.Set(&cmd, static_cast<GLenum>(11), static_cast<GLenum>(12),
static_cast<GLuint>(13), static_cast<GLint>(14),
static_cast<GLint>(15), static_cast<GLsizei>(16));
EXPECT_EQ(static_cast<uint32_t>(
cmds::FramebufferTextureMultiviewLayeredANGLE::kCmdId),
cmd.header.command);
EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
EXPECT_EQ(static_cast<GLenum>(11), cmd.target);
EXPECT_EQ(static_cast<GLenum>(12), cmd.attachment);
EXPECT_EQ(static_cast<GLuint>(13), cmd.texture);
EXPECT_EQ(static_cast<GLint>(14), cmd.level);
EXPECT_EQ(static_cast<GLint>(15), cmd.baseViewIndex);
EXPECT_EQ(static_cast<GLsizei>(16), cmd.numViews);
CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
}

#endif // GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_FORMAT_TEST_AUTOGEN_H_
3 changes: 2 additions & 1 deletion gpu/command_buffer/common/gles2_cmd_ids_autogen.h
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,8 @@
OP(CreateGpuFenceINTERNAL) /* 584 */ \
OP(WaitGpuFenceCHROMIUM) /* 585 */ \
OP(DestroyGpuFenceCHROMIUM) /* 586 */ \
OP(SetReadbackBufferShadowAllocationINTERNAL) /* 587 */
OP(SetReadbackBufferShadowAllocationINTERNAL) /* 587 */ \
OP(FramebufferTextureMultiviewLayeredANGLE) /* 588 */

enum CommandId {
kOneBeforeStartPoint =
Expand Down
3 changes: 3 additions & 0 deletions gpu/command_buffer/gles2_cmd_buffer_functions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -397,3 +397,6 @@ GL_APICALL void GL_APIENTRY glDestroyGpuFenceCHROMIUM (GLuint gpu_fence_
GL_APICALL void GL_APIENTRY glInvalidateReadbackBufferShadowDataCHROMIUM (GLidBuffer buffer_id);
// (used for CHROMIUM_nonblocking_readback implementation)
GL_APICALL void GL_APIENTRY glSetReadbackBufferShadowAllocationINTERNAL (GLidBuffer buffer_id, GLint shm_id, GLuint shm_offset, GLuint size);

// Extension ANGLE_multiview
GL_APICALL void GL_APIENTRY glFramebufferTextureMultiviewLayeredANGLE (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint baseViewIndex, GLsizei numViews);
9 changes: 9 additions & 0 deletions gpu/command_buffer/service/feature_info.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1497,6 +1497,15 @@ void FeatureInfo::InitializeFeatures() {
validators_.framebuffer_parameter.AddValue(GL_FRAMEBUFFER_FLIP_Y_MESA);
AddExtensionString("GL_MESA_framebuffer_flip_y");
}

// Only supporting ANGLE_multiview in passthrough mode - not implemented in
// validating command decoder. The extension is only available in ANGLE and in
// that case Chromium should be using passthrough by default.
if (is_passthrough_cmd_decoder_ &&
gfx::HasExtension(extensions, "GL_ANGLE_multiview")) {
AddExtensionString("GL_ANGLE_multiview");
feature_flags_.angle_multiview = true;
}
}

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 @@ -130,6 +130,7 @@ class GPU_GLES2_EXPORT FeatureInfo : public base::RefCounted<FeatureInfo> {
bool unpremultiply_and_dither_copy = false;
bool separate_stencil_ref_mask_writemask = false;
bool mesa_framebuffer_flip_y = false;
bool angle_multiview = false;
};

FeatureInfo();
Expand Down
Loading

0 comments on commit ad806a3

Please sign in to comment.