Hash :
2c8f0845
Author :
Date :
2018-09-12T14:44:55
Add ANGLE_multiview_multisample We add a novel multiview multisampling extension that includes the requirement to explicitly resolve the multisampled framebuffer. The explicit resolve is much more straightforward to implement on top of OpenGL and D3D11 than implicit resolve found in the native extension OVR_multiview_multisampled_render_to_texture. It also has predictable performance characteristics. The extension allows multiview drawing to 2D multisample texture arrays and is now enabled on both the GL backend and the D3D11 backend. The implementation is fairly simple, as it involves just small changes in validation to allow multisampled framebuffer attachments. The multiview rendering logic is exactly the same regardless of whether multisampling is enabled. For the most part the same tests are used to test both multisampled and non-multisampled rendering. The tests will use a different framebuffer setup depending on the test param. They resolve the multisampled framebuffer to a non-multisampled framebuffer prior to any readbacks from the framebuffer. Some of the tests are adjusted so that they have the correct sub-pixel positioning of multisampled quads, so there won't be any pixels that would be just partially covered. The tests don't have any tolerance for partially covered pixels - if we find any platforms where the tests run into a sub-pixel positioning corner case, tolerance may need to be added later. BUG=angleproject:2775 TEST=angle_end2end_tests Change-Id: I590d7f300a92ea5439f2720d9db14a7976db2e1d Reviewed-on: https://chromium-review.googlesource.com/1221214 Commit-Queue: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Geoff Lang <geofflang@chromium.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
//
// Copyright 2018 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// MultiviewTest:
// Implementation of helpers for multiview testing.
//
#ifndef ANGLE_TESTS_TESTUTILS_MULTIVIEWTEST_H_
#define ANGLE_TESTS_TESTUTILS_MULTIVIEWTEST_H_
#include "test_utils/ANGLETest.h"
namespace angle
{
// Creates a simple program that passes through two-dimensional vertices and renders green
// fragments.
GLuint CreateSimplePassthroughProgram(int numViews);
// Create a set of textures to use for multiview rendering. If multiviewLayout is
// GL_FRAMEBUFFER_MULTIVIEW_SIDE_BY_SIDE_ANGLE, then 2D textures are created. If multiviewLayout is
// GL_FRAMEBUFFER_MULTIVIEW_LAYERED_ANGLE, then 2D texture arrays are created. Texture ids should be
// created beforehand. If depthTexture or stencilTexture is 0, it will not be initialized.
// If samples is 0, then non-multisampled textures are created. Otherwise multisampled textures are
// created with the requested sample count.
void CreateMultiviewBackingTextures(GLenum multiviewLayout,
int samples,
int viewWidth,
int height,
int numLayers,
std::vector<GLuint> colorTextures,
GLuint depthTexture,
GLuint depthStencilTexture);
void CreateMultiviewBackingTextures(GLenum multiviewLayout,
int samples,
int viewWidth,
int height,
int numLayers,
GLuint colorTexture,
GLuint depthTexture,
GLuint depthStencilTexture);
// Attach multiview textures to the framebuffer denoted by target. If there are multiple color
// textures they get attached to different color attachments starting from 0. If multiviewLayout is
// GL_FRAMEBUFFER_MULTIVIEW_SIDE_BY_SIDE_ANGLE, then the viewport offsets are set so that the views
// are tightly packed inside the attachments.
void AttachMultiviewTextures(GLenum target,
GLenum multiviewLayout,
int viewWidth,
int numViews,
int baseViewIndex,
std::vector<GLuint> colorTextures,
GLuint depthTexture,
GLuint depthStencilTexture);
void AttachMultiviewTextures(GLenum target,
GLenum multiviewLayout,
int viewWidth,
int numViews,
int baseViewIndex,
GLuint colorTexture,
GLuint depthTexture,
GLuint depthStencilTexture);
struct MultiviewImplementationParams : public PlatformParameters
{
MultiviewImplementationParams(GLint majorVersion,
GLint minorVersion,
bool forceUseGeometryShaderOnD3D,
const EGLPlatformParameters &eglPlatformParameters)
: PlatformParameters(majorVersion, minorVersion, eglPlatformParameters),
mForceUseGeometryShaderOnD3D(forceUseGeometryShaderOnD3D)
{
}
bool mForceUseGeometryShaderOnD3D;
};
std::ostream &operator<<(std::ostream &os, const MultiviewImplementationParams ¶ms);
MultiviewImplementationParams VertexShaderOpenGL(GLint majorVersion, GLint minorVersion);
MultiviewImplementationParams VertexShaderD3D11(GLint majorVersion, GLint minorVersion);
MultiviewImplementationParams GeomShaderD3D11(GLint majorVersion, GLint minorVersion);
class MultiviewTestBase : public ANGLETestBase
{
protected:
MultiviewTestBase(const PlatformParameters ¶ms) : ANGLETestBase(params)
{
setWindowWidth(128);
setWindowHeight(128);
setWebGLCompatibilityEnabled(true);
}
virtual ~MultiviewTestBase() {}
void MultiviewTestBaseSetUp()
{
ANGLETestBase::ANGLETestSetUp();
glRequestExtensionANGLE = reinterpret_cast<PFNGLREQUESTEXTENSIONANGLEPROC>(
eglGetProcAddress("glRequestExtensionANGLE"));
}
void MultiviewTestBaseTearDown() { ANGLETestBase::ANGLETestTearDown(); }
// Requests the ANGLE_multiview extension and returns true if the operation succeeds.
bool requestMultiviewExtension(bool requireMultiviewMultisample)
{
if (extensionRequestable("GL_ANGLE_multiview"))
{
glRequestExtensionANGLE("GL_ANGLE_multiview");
}
if (!extensionEnabled("GL_ANGLE_multiview"))
{
std::cout << "Test skipped due to missing GL_ANGLE_multiview." << std::endl;
return false;
}
if (requireMultiviewMultisample)
{
if (extensionRequestable("GL_OES_texture_storage_multisample_2d_array"))
{
glRequestExtensionANGLE("GL_OES_texture_storage_multisample_2d_array");
}
if (extensionRequestable("GL_ANGLE_multiview_multisample"))
{
glRequestExtensionANGLE("GL_ANGLE_multiview_multisample");
}
if (!extensionEnabled("GL_ANGLE_multiview_multisample"))
{
std::cout << "Test skipped due to missing GL_ANGLE_multiview_multisample."
<< std::endl;
return false;
}
}
return true;
}
bool requestMultiviewExtension() { return requestMultiviewExtension(false); }
PFNGLREQUESTEXTENSIONANGLEPROC glRequestExtensionANGLE = nullptr;
};
// Base class for multiview tests that don't need specific helper functions.
class MultiviewTest : public MultiviewTestBase,
public ::testing::TestWithParam<MultiviewImplementationParams>
{
protected:
MultiviewTest() : MultiviewTestBase(GetParam()) {}
void SetUp() override { MultiviewTestBase::MultiviewTestBaseSetUp(); }
void TearDown() override { MultiviewTestBase::MultiviewTestBaseTearDown(); }
void overrideWorkaroundsD3D(WorkaroundsD3D *workarounds) final;
};
} // namespace angle
#endif // ANGLE_TESTS_TESTUTILS_MULTIVIEWTEST_H_