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() ...@@ -685,12 +685,14 @@ void TCompiler::setResourceString()
<< ":EXT_shader_framebuffer_fetch:" << compileResources.EXT_shader_framebuffer_fetch << ":EXT_shader_framebuffer_fetch:" << compileResources.EXT_shader_framebuffer_fetch
<< ":NV_shader_framebuffer_fetch:" << compileResources.NV_shader_framebuffer_fetch << ":NV_shader_framebuffer_fetch:" << compileResources.NV_shader_framebuffer_fetch
<< ":ARM_shader_framebuffer_fetch:" << compileResources.ARM_shader_framebuffer_fetch << ":ARM_shader_framebuffer_fetch:" << compileResources.ARM_shader_framebuffer_fetch
<< ":OVR_multiview:" << compileResources.OVR_multiview
<< ":EXT_YUV_target:" << compileResources.EXT_YUV_target << ":EXT_YUV_target:" << compileResources.EXT_YUV_target
<< ":MaxVertexOutputVectors:" << compileResources.MaxVertexOutputVectors << ":MaxVertexOutputVectors:" << compileResources.MaxVertexOutputVectors
<< ":MaxFragmentInputVectors:" << compileResources.MaxFragmentInputVectors << ":MaxFragmentInputVectors:" << compileResources.MaxFragmentInputVectors
<< ":MinProgramTexelOffset:" << compileResources.MinProgramTexelOffset << ":MinProgramTexelOffset:" << compileResources.MinProgramTexelOffset
<< ":MaxProgramTexelOffset:" << compileResources.MaxProgramTexelOffset << ":MaxProgramTexelOffset:" << compileResources.MaxProgramTexelOffset
<< ":MaxDualSourceDrawBuffers:" << compileResources.MaxDualSourceDrawBuffers << ":MaxDualSourceDrawBuffers:" << compileResources.MaxDualSourceDrawBuffers
<< ":MaxViewsOVR:" << compileResources.MaxViewsOVR
<< ":NV_draw_buffers:" << compileResources.NV_draw_buffers << ":NV_draw_buffers:" << compileResources.NV_draw_buffers
<< ":WEBGL_debug_shader_precision:" << compileResources.WEBGL_debug_shader_precision << ":WEBGL_debug_shader_precision:" << compileResources.WEBGL_debug_shader_precision
<< ":MaxImageUnits:" << compileResources.MaxImageUnits << ":MaxImageUnits:" << compileResources.MaxImageUnits
......
...@@ -179,7 +179,7 @@ void InitBuiltInResources(ShBuiltInResources *resources) ...@@ -179,7 +179,7 @@ void InitBuiltInResources(ShBuiltInResources *resources)
// Extensions constants. // Extensions constants.
resources->MaxDualSourceDrawBuffers = 0; resources->MaxDualSourceDrawBuffers = 0;
resources->MaxViewsOVR = 2; resources->MaxViewsOVR = 4;
// Disable name hashing by default. // Disable name hashing by default.
resources->HashFunction = nullptr; resources->HashFunction = nullptr;
......
...@@ -188,6 +188,8 @@ Extensions::Extensions() ...@@ -188,6 +188,8 @@ Extensions::Extensions()
ARMshaderFramebufferFetch(false), ARMshaderFramebufferFetch(false),
NVshaderFramebufferFetch(false), NVshaderFramebufferFetch(false),
fragDepth(false), fragDepth(false),
multiview(false),
maxViews(1u),
textureUsage(false), textureUsage(false),
translatedShaderSource(false), translatedShaderSource(false),
fboRenderMipmap(false), fboRenderMipmap(false),
...@@ -659,6 +661,7 @@ const ExtensionInfoMap &GetExtensionInfoMap() ...@@ -659,6 +661,7 @@ const ExtensionInfoMap &GetExtensionInfoMap()
map["GL_ARM_shader_framebuffer_fetch"] = esOnlyExtension(&Extensions::ARMshaderFramebufferFetch); map["GL_ARM_shader_framebuffer_fetch"] = esOnlyExtension(&Extensions::ARMshaderFramebufferFetch);
map["GL_EXT_shader_framebuffer_fetch"] = esOnlyExtension(&Extensions::shaderFramebufferFetch); map["GL_EXT_shader_framebuffer_fetch"] = esOnlyExtension(&Extensions::shaderFramebufferFetch);
map["GL_EXT_frag_depth"] = enableableExtension(&Extensions::fragDepth); 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_texture_usage"] = esOnlyExtension(&Extensions::textureUsage);
map["GL_ANGLE_translated_shader_source"] = esOnlyExtension(&Extensions::translatedShaderSource); map["GL_ANGLE_translated_shader_source"] = esOnlyExtension(&Extensions::translatedShaderSource);
map["GL_OES_fbo_render_mipmap"] = esOnlyExtension(&Extensions::fboRenderMipmap); map["GL_OES_fbo_render_mipmap"] = esOnlyExtension(&Extensions::fboRenderMipmap);
......
...@@ -251,6 +251,10 @@ struct Extensions ...@@ -251,6 +251,10 @@ struct Extensions
// GL_EXT_frag_depth // GL_EXT_frag_depth
bool fragDepth; bool fragDepth;
// ANGLE_multiview
bool multiview;
GLuint maxViews;
// GL_ANGLE_texture_usage // GL_ANGLE_texture_usage
bool textureUsage; bool textureUsage;
......
...@@ -76,6 +76,10 @@ Compiler::Compiler(rx::GLImplFactory *implFactory, const ContextState &state) ...@@ -76,6 +76,10 @@ Compiler::Compiler(rx::GLImplFactory *implFactory, const ContextState &state)
mResources.FragmentPrecisionHigh = 1; mResources.FragmentPrecisionHigh = 1;
mResources.EXT_frag_depth = extensions.fragDepth; mResources.EXT_frag_depth = extensions.fragDepth;
// OVR_multiview state
mResources.OVR_multiview = extensions.multiview;
mResources.MaxViewsOVR = extensions.maxViews;
// GLSL ES 3.0 constants // GLSL ES 3.0 constants
mResources.MaxVertexOutputVectors = caps.maxVertexOutputComponents / 4; mResources.MaxVertexOutputVectors = caps.maxVertexOutputComponents / 4;
mResources.MaxFragmentInputVectors = caps.maxFragmentInputComponents / 4; mResources.MaxFragmentInputVectors = caps.maxFragmentInputComponents / 4;
......
...@@ -52,7 +52,8 @@ CompilerImpl *ContextGL::createCompiler() ...@@ -52,7 +52,8 @@ CompilerImpl *ContextGL::createCompiler()
ShaderImpl *ContextGL::createShader(const gl::ShaderState &data) ShaderImpl *ContextGL::createShader(const gl::ShaderState &data)
{ {
return new ShaderGL(data, getFunctions(), getWorkaroundsGL(), return new ShaderGL(data, getFunctions(), getWorkaroundsGL(),
getExtensions().webglCompatibility); getExtensions().webglCompatibility,
mRenderer->getMultiviewImplementationType());
} }
ProgramImpl *ContextGL::createProgram(const gl::ProgramState &data) ProgramImpl *ContextGL::createProgram(const gl::ProgramState &data)
......
...@@ -170,7 +170,8 @@ RendererGL::RendererGL(const FunctionsGL *functions, const egl::AttributeMap &at ...@@ -170,7 +170,8 @@ RendererGL::RendererGL(const FunctionsGL *functions, const egl::AttributeMap &at
mBlitter(nullptr), mBlitter(nullptr),
mHasDebugOutput(false), mHasDebugOutput(false),
mSkipDrawCalls(false), mSkipDrawCalls(false),
mCapsInitialized(false) mCapsInitialized(false),
mMultiviewImplementationType(MultiviewImplementationTypeGL::UNSPECIFIED)
{ {
ASSERT(mFunctions); ASSERT(mFunctions);
nativegl_gl::GenerateWorkarounds(mFunctions, &mWorkarounds); nativegl_gl::GenerateWorkarounds(mFunctions, &mWorkarounds);
...@@ -606,7 +607,7 @@ void RendererGL::generateCaps(gl::Caps *outCaps, ...@@ -606,7 +607,7 @@ void RendererGL::generateCaps(gl::Caps *outCaps,
gl::Limitations * /* outLimitations */) const gl::Limitations * /* outLimitations */) const
{ {
nativegl_gl::GenerateCaps(mFunctions, mWorkarounds, outCaps, outTextureCaps, outExtensions, nativegl_gl::GenerateCaps(mFunctions, mWorkarounds, outCaps, outTextureCaps, outExtensions,
&mMaxSupportedESVersion); &mMaxSupportedESVersion, &mMultiviewImplementationType);
} }
GLint RendererGL::getGPUDisjoint() GLint RendererGL::getGPUDisjoint()
...@@ -655,6 +656,12 @@ const gl::Limitations &RendererGL::getNativeLimitations() const ...@@ -655,6 +656,12 @@ const gl::Limitations &RendererGL::getNativeLimitations() const
return mNativeLimitations; return mNativeLimitations;
} }
MultiviewImplementationTypeGL RendererGL::getMultiviewImplementationType() const
{
ensureCapsInitialized();
return mMultiviewImplementationType;
}
void RendererGL::applyNativeWorkarounds(gl::Workarounds *workarounds) const void RendererGL::applyNativeWorkarounds(gl::Workarounds *workarounds) const
{ {
ensureCapsInitialized(); ensureCapsInitialized();
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "libANGLE/Error.h" #include "libANGLE/Error.h"
#include "libANGLE/Version.h" #include "libANGLE/Version.h"
#include "libANGLE/renderer/gl/WorkaroundsGL.h" #include "libANGLE/renderer/gl/WorkaroundsGL.h"
#include "libANGLE/renderer/gl/renderergl_utils.h"
namespace gl namespace gl
{ {
...@@ -162,6 +163,7 @@ class RendererGL : angle::NonCopyable ...@@ -162,6 +163,7 @@ class RendererGL : angle::NonCopyable
const WorkaroundsGL &getWorkarounds() const { return mWorkarounds; } const WorkaroundsGL &getWorkarounds() const { return mWorkarounds; }
BlitGL *getBlitter() const { return mBlitter; } BlitGL *getBlitter() const { return mBlitter; }
MultiviewImplementationTypeGL getMultiviewImplementationType() const;
const gl::Caps &getNativeCaps() const; const gl::Caps &getNativeCaps() const;
const gl::TextureCapsMap &getNativeTextureCaps() const; const gl::TextureCapsMap &getNativeTextureCaps() const;
const gl::Extensions &getNativeExtensions() const; const gl::Extensions &getNativeExtensions() const;
...@@ -199,6 +201,7 @@ class RendererGL : angle::NonCopyable ...@@ -199,6 +201,7 @@ class RendererGL : angle::NonCopyable
mutable gl::TextureCapsMap mNativeTextureCaps; mutable gl::TextureCapsMap mNativeTextureCaps;
mutable gl::Extensions mNativeExtensions; mutable gl::Extensions mNativeExtensions;
mutable gl::Limitations mNativeLimitations; mutable gl::Limitations mNativeLimitations;
mutable MultiviewImplementationTypeGL mMultiviewImplementationType;
}; };
} // namespace rx } // namespace rx
......
...@@ -22,12 +22,14 @@ namespace rx ...@@ -22,12 +22,14 @@ namespace rx
ShaderGL::ShaderGL(const gl::ShaderState &data, ShaderGL::ShaderGL(const gl::ShaderState &data,
const FunctionsGL *functions, const FunctionsGL *functions,
const WorkaroundsGL &workarounds, const WorkaroundsGL &workarounds,
bool isWebGL) bool isWebGL,
MultiviewImplementationTypeGL multiviewImplementationType)
: ShaderImpl(data), : ShaderImpl(data),
mFunctions(functions), mFunctions(functions),
mWorkarounds(workarounds), mWorkarounds(workarounds),
mShaderID(0), mShaderID(0),
mIsWebGL(isWebGL) mIsWebGL(isWebGL),
mMultiviewImplementationType(multiviewImplementationType)
{ {
ASSERT(mFunctions); ASSERT(mFunctions);
} }
...@@ -110,6 +112,12 @@ ShCompileOptions ShaderGL::prepareSourceAndReturnOptions(std::stringstream *sour ...@@ -110,6 +112,12 @@ ShCompileOptions ShaderGL::prepareSourceAndReturnOptions(std::stringstream *sour
options |= SH_INITIALIZE_UNINITIALIZED_LOCALS; 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; return options;
} }
......
...@@ -15,6 +15,7 @@ namespace rx ...@@ -15,6 +15,7 @@ namespace rx
{ {
class FunctionsGL; class FunctionsGL;
struct WorkaroundsGL; struct WorkaroundsGL;
enum class MultiviewImplementationTypeGL;
class ShaderGL : public ShaderImpl class ShaderGL : public ShaderImpl
{ {
...@@ -22,7 +23,8 @@ class ShaderGL : public ShaderImpl ...@@ -22,7 +23,8 @@ class ShaderGL : public ShaderImpl
ShaderGL(const gl::ShaderState &data, ShaderGL(const gl::ShaderState &data,
const FunctionsGL *functions, const FunctionsGL *functions,
const WorkaroundsGL &workarounds, const WorkaroundsGL &workarounds,
bool isWebGL); bool isWebGL,
MultiviewImplementationTypeGL multiviewImplementationType);
~ShaderGL() override; ~ShaderGL() override;
// ShaderImpl implementation // ShaderImpl implementation
...@@ -39,6 +41,7 @@ class ShaderGL : public ShaderImpl ...@@ -39,6 +41,7 @@ class ShaderGL : public ShaderImpl
GLuint mShaderID; GLuint mShaderID;
bool mIsWebGL; bool mIsWebGL;
MultiviewImplementationTypeGL mMultiviewImplementationType;
}; };
} }
......
...@@ -222,7 +222,8 @@ void GenerateCaps(const FunctionsGL *functions, ...@@ -222,7 +222,8 @@ void GenerateCaps(const FunctionsGL *functions,
gl::Caps *caps, gl::Caps *caps,
gl::TextureCapsMap *textureCapsMap, gl::TextureCapsMap *textureCapsMap,
gl::Extensions *extensions, gl::Extensions *extensions,
gl::Version *maxSupportedESVersion) gl::Version *maxSupportedESVersion,
MultiviewImplementationTypeGL *multiviewImplementationType)
{ {
// Texture format support checks // Texture format support checks
const gl::FormatSet &allFormats = gl::GetAllSizedInternalFormats(); const gl::FormatSet &allFormats = gl::GetAllSizedInternalFormats();
...@@ -873,6 +874,18 @@ void GenerateCaps(const FunctionsGL *functions, ...@@ -873,6 +874,18 @@ void GenerateCaps(const FunctionsGL *functions,
functions->hasGLESExtension("GL_EXT_shader_texture_lod"); functions->hasGLESExtension("GL_EXT_shader_texture_lod");
extensions->fragDepth = functions->standard == STANDARD_GL_DESKTOP || extensions->fragDepth = functions->standard == STANDARD_GL_DESKTOP ||
functions->hasGLESExtension("GL_EXT_frag_depth"); 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") || 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"); functions->isAtLeastGLES(gl::Version(3, 0)) || functions->hasGLESExtension("GL_OES_fbo_render_mipmap");
extensions->instancedArrays = functions->isAtLeastGL(gl::Version(3, 1)) || extensions->instancedArrays = functions->isAtLeastGL(gl::Version(3, 1)) ||
......
...@@ -32,6 +32,11 @@ namespace rx ...@@ -32,6 +32,11 @@ namespace rx
{ {
class FunctionsGL; class FunctionsGL;
struct WorkaroundsGL; struct WorkaroundsGL;
enum class MultiviewImplementationTypeGL
{
NV_VIEWPORT_ARRAY2,
UNSPECIFIED
};
VendorID GetVendorID(const FunctionsGL *functions); VendorID GetVendorID(const FunctionsGL *functions);
std::string GetDriverVersion(const FunctionsGL *functions); std::string GetDriverVersion(const FunctionsGL *functions);
...@@ -44,7 +49,8 @@ void GenerateCaps(const FunctionsGL *functions, ...@@ -44,7 +49,8 @@ void GenerateCaps(const FunctionsGL *functions,
gl::Caps *caps, gl::Caps *caps,
gl::TextureCapsMap *textureCapsMap, gl::TextureCapsMap *textureCapsMap,
gl::Extensions *extensions, gl::Extensions *extensions,
gl::Version *maxSupportedESVersion); gl::Version *maxSupportedESVersion,
MultiviewImplementationTypeGL *multiviewImplementationType);
void GenerateWorkarounds(const FunctionsGL *functions, WorkaroundsGL *workarounds); void GenerateWorkarounds(const FunctionsGL *functions, WorkaroundsGL *workarounds);
void ApplyWorkarounds(const FunctionsGL *functions, gl::Workarounds *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