Commit 318f9aa5 by Martin Radev Committed by Commit Bot

Initialize ANGLE_multiview caps and workaround state

The patch checks whether ANGLE_multiview can be supported in the OpenGL renderer, updates the caps and adds a workaround field to enable multiview support through the NV_viewport_array2 extension. BUG=angleproject:2062 TEST=angle_end2end_tests Change-Id: I99dae10564db7bcca41d7624f8de272c1d996e09 Reviewed-on: https://chromium-review.googlesource.com/567934Reviewed-by: 's avatarOlli Etuaho <oetuaho@nvidia.com> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
parent e71afb87
......@@ -685,12 +685,14 @@ void TCompiler::setResourceString()
<< ":EXT_shader_framebuffer_fetch:" << compileResources.EXT_shader_framebuffer_fetch
<< ":NV_shader_framebuffer_fetch:" << compileResources.NV_shader_framebuffer_fetch
<< ":ARM_shader_framebuffer_fetch:" << compileResources.ARM_shader_framebuffer_fetch
<< ":OVR_multiview:" << compileResources.OVR_multiview
<< ":EXT_YUV_target:" << compileResources.EXT_YUV_target
<< ":MaxVertexOutputVectors:" << compileResources.MaxVertexOutputVectors
<< ":MaxFragmentInputVectors:" << compileResources.MaxFragmentInputVectors
<< ":MinProgramTexelOffset:" << compileResources.MinProgramTexelOffset
<< ":MaxProgramTexelOffset:" << compileResources.MaxProgramTexelOffset
<< ":MaxDualSourceDrawBuffers:" << compileResources.MaxDualSourceDrawBuffers
<< ":MaxViewsOVR:" << compileResources.MaxViewsOVR
<< ":NV_draw_buffers:" << compileResources.NV_draw_buffers
<< ":WEBGL_debug_shader_precision:" << compileResources.WEBGL_debug_shader_precision
<< ":MaxImageUnits:" << compileResources.MaxImageUnits
......
......@@ -179,7 +179,7 @@ void InitBuiltInResources(ShBuiltInResources *resources)
// Extensions constants.
resources->MaxDualSourceDrawBuffers = 0;
resources->MaxViewsOVR = 2;
resources->MaxViewsOVR = 4;
// Disable name hashing by default.
resources->HashFunction = nullptr;
......
......@@ -188,6 +188,8 @@ Extensions::Extensions()
ARMshaderFramebufferFetch(false),
NVshaderFramebufferFetch(false),
fragDepth(false),
multiview(false),
maxViews(1u),
textureUsage(false),
translatedShaderSource(false),
fboRenderMipmap(false),
......@@ -659,6 +661,7 @@ const ExtensionInfoMap &GetExtensionInfoMap()
map["GL_ARM_shader_framebuffer_fetch"] = esOnlyExtension(&Extensions::ARMshaderFramebufferFetch);
map["GL_EXT_shader_framebuffer_fetch"] = esOnlyExtension(&Extensions::shaderFramebufferFetch);
map["GL_EXT_frag_depth"] = enableableExtension(&Extensions::fragDepth);
map["GL_ANGLE_multiview"] = enableableExtension(&Extensions::multiview);
map["GL_ANGLE_texture_usage"] = esOnlyExtension(&Extensions::textureUsage);
map["GL_ANGLE_translated_shader_source"] = esOnlyExtension(&Extensions::translatedShaderSource);
map["GL_OES_fbo_render_mipmap"] = esOnlyExtension(&Extensions::fboRenderMipmap);
......
......@@ -251,6 +251,10 @@ struct Extensions
// GL_EXT_frag_depth
bool fragDepth;
// ANGLE_multiview
bool multiview;
GLuint maxViews;
// GL_ANGLE_texture_usage
bool textureUsage;
......
......@@ -76,6 +76,10 @@ Compiler::Compiler(rx::GLImplFactory *implFactory, const ContextState &state)
mResources.FragmentPrecisionHigh = 1;
mResources.EXT_frag_depth = extensions.fragDepth;
// OVR_multiview state
mResources.OVR_multiview = extensions.multiview;
mResources.MaxViewsOVR = extensions.maxViews;
// GLSL ES 3.0 constants
mResources.MaxVertexOutputVectors = caps.maxVertexOutputComponents / 4;
mResources.MaxFragmentInputVectors = caps.maxFragmentInputComponents / 4;
......
......@@ -52,7 +52,8 @@ CompilerImpl *ContextGL::createCompiler()
ShaderImpl *ContextGL::createShader(const gl::ShaderState &data)
{
return new ShaderGL(data, getFunctions(), getWorkaroundsGL(),
getExtensions().webglCompatibility);
getExtensions().webglCompatibility,
mRenderer->getMultiviewImplementationType());
}
ProgramImpl *ContextGL::createProgram(const gl::ProgramState &data)
......
......@@ -170,7 +170,8 @@ RendererGL::RendererGL(const FunctionsGL *functions, const egl::AttributeMap &at
mBlitter(nullptr),
mHasDebugOutput(false),
mSkipDrawCalls(false),
mCapsInitialized(false)
mCapsInitialized(false),
mMultiviewImplementationType(MultiviewImplementationTypeGL::UNSPECIFIED)
{
ASSERT(mFunctions);
nativegl_gl::GenerateWorkarounds(mFunctions, &mWorkarounds);
......@@ -606,7 +607,7 @@ void RendererGL::generateCaps(gl::Caps *outCaps,
gl::Limitations * /* outLimitations */) const
{
nativegl_gl::GenerateCaps(mFunctions, mWorkarounds, outCaps, outTextureCaps, outExtensions,
&mMaxSupportedESVersion);
&mMaxSupportedESVersion, &mMultiviewImplementationType);
}
GLint RendererGL::getGPUDisjoint()
......@@ -655,6 +656,12 @@ const gl::Limitations &RendererGL::getNativeLimitations() const
return mNativeLimitations;
}
MultiviewImplementationTypeGL RendererGL::getMultiviewImplementationType() const
{
ensureCapsInitialized();
return mMultiviewImplementationType;
}
void RendererGL::applyNativeWorkarounds(gl::Workarounds *workarounds) const
{
ensureCapsInitialized();
......
......@@ -13,6 +13,7 @@
#include "libANGLE/Error.h"
#include "libANGLE/Version.h"
#include "libANGLE/renderer/gl/WorkaroundsGL.h"
#include "libANGLE/renderer/gl/renderergl_utils.h"
namespace gl
{
......@@ -162,6 +163,7 @@ class RendererGL : angle::NonCopyable
const WorkaroundsGL &getWorkarounds() const { return mWorkarounds; }
BlitGL *getBlitter() const { return mBlitter; }
MultiviewImplementationTypeGL getMultiviewImplementationType() const;
const gl::Caps &getNativeCaps() const;
const gl::TextureCapsMap &getNativeTextureCaps() const;
const gl::Extensions &getNativeExtensions() const;
......@@ -199,6 +201,7 @@ class RendererGL : angle::NonCopyable
mutable gl::TextureCapsMap mNativeTextureCaps;
mutable gl::Extensions mNativeExtensions;
mutable gl::Limitations mNativeLimitations;
mutable MultiviewImplementationTypeGL mMultiviewImplementationType;
};
} // namespace rx
......
......@@ -22,12 +22,14 @@ namespace rx
ShaderGL::ShaderGL(const gl::ShaderState &data,
const FunctionsGL *functions,
const WorkaroundsGL &workarounds,
bool isWebGL)
bool isWebGL,
MultiviewImplementationTypeGL multiviewImplementationType)
: ShaderImpl(data),
mFunctions(functions),
mWorkarounds(workarounds),
mShaderID(0),
mIsWebGL(isWebGL)
mIsWebGL(isWebGL),
mMultiviewImplementationType(multiviewImplementationType)
{
ASSERT(mFunctions);
}
......@@ -110,6 +112,12 @@ ShCompileOptions ShaderGL::prepareSourceAndReturnOptions(std::stringstream *sour
options |= SH_INITIALIZE_UNINITIALIZED_LOCALS;
}
if (mMultiviewImplementationType == MultiviewImplementationTypeGL::NV_VIEWPORT_ARRAY2)
{
options |= SH_INITIALIZE_BUILTINS_FOR_INSTANCED_MULTIVIEW;
options |= SH_SELECT_VIEW_IN_NV_GLSL_VERTEX_SHADER;
}
return options;
}
......
......@@ -15,6 +15,7 @@ namespace rx
{
class FunctionsGL;
struct WorkaroundsGL;
enum class MultiviewImplementationTypeGL;
class ShaderGL : public ShaderImpl
{
......@@ -22,7 +23,8 @@ class ShaderGL : public ShaderImpl
ShaderGL(const gl::ShaderState &data,
const FunctionsGL *functions,
const WorkaroundsGL &workarounds,
bool isWebGL);
bool isWebGL,
MultiviewImplementationTypeGL multiviewImplementationType);
~ShaderGL() override;
// ShaderImpl implementation
......@@ -39,6 +41,7 @@ class ShaderGL : public ShaderImpl
GLuint mShaderID;
bool mIsWebGL;
MultiviewImplementationTypeGL mMultiviewImplementationType;
};
}
......
......@@ -222,7 +222,8 @@ void GenerateCaps(const FunctionsGL *functions,
gl::Caps *caps,
gl::TextureCapsMap *textureCapsMap,
gl::Extensions *extensions,
gl::Version *maxSupportedESVersion)
gl::Version *maxSupportedESVersion,
MultiviewImplementationTypeGL *multiviewImplementationType)
{
// Texture format support checks
const gl::FormatSet &allFormats = gl::GetAllSizedInternalFormats();
......@@ -873,6 +874,18 @@ void GenerateCaps(const FunctionsGL *functions,
functions->hasGLESExtension("GL_EXT_shader_texture_lod");
extensions->fragDepth = functions->standard == STANDARD_GL_DESKTOP ||
functions->hasGLESExtension("GL_EXT_frag_depth");
if (functions->hasGLExtension("GL_NV_viewport_array2"))
{
extensions->multiview = true;
// GL_MAX_ARRAY_TEXTURE_LAYERS is guaranteed to be at least 256.
const int maxLayers = QuerySingleGLInt(functions, GL_MAX_ARRAY_TEXTURE_LAYERS);
// GL_MAX_VIEWPORTS is guaranteed to be at least 16.
const int maxViewports = QuerySingleGLInt(functions, GL_MAX_VIEWPORTS);
extensions->maxViews = static_cast<GLuint>(std::min(maxLayers, maxViewports));
*multiviewImplementationType = MultiviewImplementationTypeGL::NV_VIEWPORT_ARRAY2;
}
extensions->fboRenderMipmap = functions->isAtLeastGL(gl::Version(3, 0)) || functions->hasGLExtension("GL_EXT_framebuffer_object") ||
functions->isAtLeastGLES(gl::Version(3, 0)) || functions->hasGLESExtension("GL_OES_fbo_render_mipmap");
extensions->instancedArrays = functions->isAtLeastGL(gl::Version(3, 1)) ||
......
......@@ -32,6 +32,11 @@ namespace rx
{
class FunctionsGL;
struct WorkaroundsGL;
enum class MultiviewImplementationTypeGL
{
NV_VIEWPORT_ARRAY2,
UNSPECIFIED
};
VendorID GetVendorID(const FunctionsGL *functions);
std::string GetDriverVersion(const FunctionsGL *functions);
......@@ -44,7 +49,8 @@ void GenerateCaps(const FunctionsGL *functions,
gl::Caps *caps,
gl::TextureCapsMap *textureCapsMap,
gl::Extensions *extensions,
gl::Version *maxSupportedESVersion);
gl::Version *maxSupportedESVersion,
MultiviewImplementationTypeGL *multiviewImplementationType);
void GenerateWorkarounds(const FunctionsGL *functions, WorkaroundsGL *workarounds);
void ApplyWorkarounds(const FunctionsGL *functions, gl::Workarounds *workarounds);
......
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