Commit ec3a9cbb by Olli Etuaho Committed by Commit Bot

Only support GL_OVR_multiview extension variant

The WebGL spec proposal was changed so that only GL_OVR_multiview extension name is supported, instead of having two variants OVR_multiview and OVR_multiview2. We're only supporting the WebGL version of the shader extension, so we drop compiler support for GL_OVR_multiview2. Shader restrictions were also removed from the WebGL spec, so no special validation for how ViewID_OVR gets used is needed. Tests that were testing for the shader restrictions are either removed or changed from negative tests to positive tests. BUG=angleproject:1669 TEST=angle_unittests Change-Id: I83f92b879376d41b727b5aca419fd75fb6f53477 Reviewed-on: https://chromium-review.googlesource.com/654608Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
parent 15c3406a
...@@ -145,8 +145,6 @@ ...@@ -145,8 +145,6 @@
'compiler/translator/ValidateLimitations.h', 'compiler/translator/ValidateLimitations.h',
'compiler/translator/ValidateMaxParameters.h', 'compiler/translator/ValidateMaxParameters.h',
'compiler/translator/ValidateMaxParameters.cpp', 'compiler/translator/ValidateMaxParameters.cpp',
'compiler/translator/ValidateMultiviewWebGL.cpp',
'compiler/translator/ValidateMultiviewWebGL.h',
'compiler/translator/ValidateOutputs.cpp', 'compiler/translator/ValidateOutputs.cpp',
'compiler/translator/ValidateOutputs.h', 'compiler/translator/ValidateOutputs.h',
'compiler/translator/ValidateSwitch.cpp', 'compiler/translator/ValidateSwitch.cpp',
......
...@@ -527,8 +527,7 @@ void CollectVariablesTraverser::visitSymbol(TIntermSymbol *symbol) ...@@ -527,8 +527,7 @@ void CollectVariablesTraverser::visitSymbol(TIntermSymbol *symbol)
else else
{ {
ASSERT(mShaderType == GL_VERTEX_SHADER && ASSERT(mShaderType == GL_VERTEX_SHADER &&
(IsExtensionEnabled(mExtensionBehavior, "GL_OVR_multiview") || IsExtensionEnabled(mExtensionBehavior, "GL_OVR_multiview"));
IsExtensionEnabled(mExtensionBehavior, "GL_OVR_multiview2")));
} }
break; break;
default: default:
......
...@@ -37,7 +37,6 @@ ...@@ -37,7 +37,6 @@
#include "compiler/translator/UseInterfaceBlockFields.h" #include "compiler/translator/UseInterfaceBlockFields.h"
#include "compiler/translator/ValidateLimitations.h" #include "compiler/translator/ValidateLimitations.h"
#include "compiler/translator/ValidateMaxParameters.h" #include "compiler/translator/ValidateMaxParameters.h"
#include "compiler/translator/ValidateMultiviewWebGL.h"
#include "compiler/translator/ValidateOutputs.h" #include "compiler/translator/ValidateOutputs.h"
#include "compiler/translator/VariablePacker.h" #include "compiler/translator/VariablePacker.h"
#include "third_party/compiler/ArrayBoundsClamper.h" #include "third_party/compiler/ArrayBoundsClamper.h"
...@@ -359,15 +358,6 @@ TIntermBlock *TCompiler::compileTreeImpl(const char *const shaderStrings[], ...@@ -359,15 +358,6 @@ TIntermBlock *TCompiler::compileTreeImpl(const char *const shaderStrings[],
// Highp might have been auto-enabled based on shader version // Highp might have been auto-enabled based on shader version
fragmentPrecisionHigh = parseContext.getFragmentPrecisionHigh(); fragmentPrecisionHigh = parseContext.getFragmentPrecisionHigh();
if (success && (IsWebGLBasedSpec(shaderSpec) &&
IsExtensionEnabled(extensionBehavior, "GL_OVR_multiview") &&
IsExtensionEnabled(extensionBehavior, "GL_OVR_multiview2")))
{
// Can't enable both extensions at the same time.
mDiagnostics.globalError("Can't enable both OVR_multiview and OVR_multiview2");
success = false;
}
if (success && shaderType == GL_GEOMETRY_SHADER_OES) if (success && shaderType == GL_GEOMETRY_SHADER_OES)
{ {
mGeometryShaderInputPrimitiveType = parseContext.getGeometryShaderInputPrimitiveType(); mGeometryShaderInputPrimitiveType = parseContext.getGeometryShaderInputPrimitiveType();
...@@ -414,12 +404,6 @@ TIntermBlock *TCompiler::compileTreeImpl(const char *const shaderStrings[], ...@@ -414,12 +404,6 @@ TIntermBlock *TCompiler::compileTreeImpl(const char *const shaderStrings[],
success = success =
ValidateLimitations(root, shaderType, &symbolTable, shaderVersion, &mDiagnostics); ValidateLimitations(root, shaderType, &symbolTable, shaderVersion, &mDiagnostics);
bool multiview2 = IsExtensionEnabled(extensionBehavior, "GL_OVR_multiview2");
if (success && compileResources.OVR_multiview && IsWebGLBasedSpec(shaderSpec) &&
(IsExtensionEnabled(extensionBehavior, "GL_OVR_multiview") || multiview2))
success = ValidateMultiviewWebGL(root, shaderType, symbolTable, shaderVersion,
multiview2, &mDiagnostics);
// Fail compilation if precision emulation not supported. // Fail compilation if precision emulation not supported.
if (success && getResources().WEBGL_debug_shader_precision && if (success && getResources().WEBGL_debug_shader_precision &&
getPragma().debugShaderPrecision) getPragma().debugShaderPrecision)
......
...@@ -1021,8 +1021,7 @@ void InitExtensionBehavior(const ShBuiltInResources &resources, TExtensionBehavi ...@@ -1021,8 +1021,7 @@ void InitExtensionBehavior(const ShBuiltInResources &resources, TExtensionBehavi
extBehavior["GL_ARM_shader_framebuffer_fetch"] = EBhUndefined; extBehavior["GL_ARM_shader_framebuffer_fetch"] = EBhUndefined;
if (resources.OVR_multiview) if (resources.OVR_multiview)
{ {
extBehavior["GL_OVR_multiview"] = EBhUndefined; extBehavior["GL_OVR_multiview"] = EBhUndefined;
extBehavior["GL_OVR_multiview2"] = EBhUndefined;
} }
if (resources.EXT_YUV_target) if (resources.EXT_YUV_target)
{ {
......
...@@ -130,8 +130,7 @@ OutputHLSL::OutputHLSL(sh::GLenum shaderType, ...@@ -130,8 +130,7 @@ OutputHLSL::OutputHLSL(sh::GLenum shaderType,
mUsesFrontFacing = false; mUsesFrontFacing = false;
mUsesPointSize = false; mUsesPointSize = false;
mUsesInstanceID = false; mUsesInstanceID = false;
mHasMultiviewExtensionEnabled = IsExtensionEnabled(mExtensionBehavior, "GL_OVR_multiview") || mHasMultiviewExtensionEnabled = IsExtensionEnabled(mExtensionBehavior, "GL_OVR_multiview");
IsExtensionEnabled(mExtensionBehavior, "GL_OVR_multiview2");
mUsesViewID = false; mUsesViewID = false;
mUsesVertexID = false; mUsesVertexID = false;
mUsesFragDepth = false; mUsesFragDepth = false;
......
...@@ -1158,12 +1158,6 @@ bool TParseContext::checkCanUseExtension(const TSourceLoc &line, const TString & ...@@ -1158,12 +1158,6 @@ bool TParseContext::checkCanUseExtension(const TSourceLoc &line, const TString &
// In GLSL ES, an extension's default behavior is "disable". // In GLSL ES, an extension's default behavior is "disable".
if (iter->second == EBhDisable || iter->second == EBhUndefined) if (iter->second == EBhDisable || iter->second == EBhUndefined)
{ {
// TODO(oetuaho@nvidia.com): This is slightly hacky. Might be better if symbols could be
// associated with more than one extension.
if (extension == "GL_OVR_multiview")
{
return checkCanUseExtension(line, "GL_OVR_multiview2");
}
error(line, "extension is disabled", extension.c_str()); error(line, "extension is disabled", extension.c_str());
return false; return false;
} }
...@@ -1776,14 +1770,6 @@ TIntermTyped *TParseContext::parseVariableIdentifier(const TSourceLoc &location, ...@@ -1776,14 +1770,6 @@ TIntermTyped *TParseContext::parseVariableIdentifier(const TSourceLoc &location,
return node; return node;
} }
if (variable->getType().getQualifier() == EvqViewIDOVR && IsWebGLBasedSpec(mShaderSpec) &&
mShaderType == GL_FRAGMENT_SHADER && !isExtensionEnabled("GL_OVR_multiview2"))
{
// WEBGL_multiview spec
error(location, "Need to enable OVR_multiview2 to use gl_ViewID_OVR in fragment shader",
"gl_ViewID_OVR");
}
TIntermTyped *node = nullptr; TIntermTyped *node = nullptr;
if (variable->getConstPointer()) if (variable->getConstPointer())
......
...@@ -172,8 +172,7 @@ class TParseContext : angle::NonCopyable ...@@ -172,8 +172,7 @@ class TParseContext : angle::NonCopyable
bool isExtensionEnabled(const char *extension) const; bool isExtensionEnabled(const char *extension) const;
bool isMultiviewExtensionEnabled() const bool isMultiviewExtensionEnabled() const
{ {
return mMultiviewAvailable && return mMultiviewAvailable && isExtensionEnabled("GL_OVR_multiview");
(isExtensionEnabled("GL_OVR_multiview") || isExtensionEnabled("GL_OVR_multiview2"));
} }
void handleExtensionDirective(const TSourceLoc &loc, const char *extName, const char *behavior); void handleExtensionDirective(const TSourceLoc &loc, const char *extName, const char *behavior);
void handlePragmaDirective(const TSourceLoc &loc, void handlePragmaDirective(const TSourceLoc &loc,
......
...@@ -136,8 +136,7 @@ void TranslatorESSL::writeExtensionBehavior(ShCompileOptions compileOptions) ...@@ -136,8 +136,7 @@ void TranslatorESSL::writeExtensionBehavior(ShCompileOptions compileOptions)
{ {
if (iter->second != EBhUndefined) if (iter->second != EBhUndefined)
{ {
const bool isMultiview = const bool isMultiview = (iter->first == "GL_OVR_multiview");
iter->first == "GL_OVR_multiview" || iter->first == "GL_OVR_multiview2";
if (getResources().NV_shader_framebuffer_fetch && if (getResources().NV_shader_framebuffer_fetch &&
iter->first == "GL_EXT_shader_framebuffer_fetch") iter->first == "GL_EXT_shader_framebuffer_fetch")
{ {
......
...@@ -283,8 +283,7 @@ void TranslatorGLSL::writeExtensionBehavior(TIntermNode *root, ShCompileOptions ...@@ -283,8 +283,7 @@ void TranslatorGLSL::writeExtensionBehavior(TIntermNode *root, ShCompileOptions
} }
} }
const bool isMultiview = const bool isMultiview = (iter.first == "GL_OVR_multiview");
iter.first == "GL_OVR_multiview" || iter.first == "GL_OVR_multiview2";
if (isMultiview && getShaderType() == GL_VERTEX_SHADER && if (isMultiview && getShaderType() == GL_VERTEX_SHADER &&
(compileOptions & SH_SELECT_VIEW_IN_NV_GLSL_VERTEX_SHADER) != 0u) (compileOptions & SH_SELECT_VIEW_IN_NV_GLSL_VERTEX_SHADER) != 0u)
{ {
......
//
// Copyright (c) 2002-2016 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.
//
// ValidateMultiviewWebGL.h:
// Validate the AST according to rules in the WEBGL_multiview extension spec. Only covers those
// rules not already covered in ParseContext.
//
#ifndef COMPILER_TRANSLATOR_VALIDATEMULTIVIEWWEBGL_H_
#define COMPILER_TRANSLATOR_VALIDATEMULTIVIEWWEBGL_H_
#include "GLSLANG/ShaderVars.h"
namespace sh
{
class TDiagnostics;
class TIntermBlock;
class TSymbolTable;
// Check for errors and output error messages with diagnostics.
// Returns true if there are no errors.
bool ValidateMultiviewWebGL(TIntermBlock *root,
sh::GLenum shaderType,
const TSymbolTable &symbolTable,
int shaderVersion,
bool multiview2,
TDiagnostics *diagnostics);
} // namespace sh
#endif // COMPILER_TRANSLATOR_VALIDATEMULTIVIEWWEBGL_H_
...@@ -830,7 +830,7 @@ TEST_P(MultiviewRenderTest, DrawArraysFourViews) ...@@ -830,7 +830,7 @@ TEST_P(MultiviewRenderTest, DrawArraysFourViews)
const std::string vsSource = const std::string vsSource =
"#version 300 es\n" "#version 300 es\n"
"#extension GL_OVR_multiview2 : require\n" "#extension GL_OVR_multiview : require\n"
"layout(num_views = 4) in;\n" "layout(num_views = 4) in;\n"
"in vec4 vPosition;\n" "in vec4 vPosition;\n"
"void main()\n" "void main()\n"
...@@ -849,7 +849,7 @@ TEST_P(MultiviewRenderTest, DrawArraysFourViews) ...@@ -849,7 +849,7 @@ TEST_P(MultiviewRenderTest, DrawArraysFourViews)
const std::string fsSource = const std::string fsSource =
"#version 300 es\n" "#version 300 es\n"
"#extension GL_OVR_multiview2 : require\n" "#extension GL_OVR_multiview : require\n"
"precision mediump float;\n" "precision mediump float;\n"
"out vec4 col;\n" "out vec4 col;\n"
"void main()\n" "void main()\n"
...@@ -958,7 +958,7 @@ TEST_P(MultiviewRenderTest, AttribDivisor) ...@@ -958,7 +958,7 @@ TEST_P(MultiviewRenderTest, AttribDivisor)
const std::string &vsSource = const std::string &vsSource =
"#version 300 es\n" "#version 300 es\n"
"#extension GL_OVR_multiview2 : require\n" "#extension GL_OVR_multiview : require\n"
"layout(num_views = 2) in;\n" "layout(num_views = 2) in;\n"
"in vec3 vPosition;\n" "in vec3 vPosition;\n"
"in float offsetX;\n" "in float offsetX;\n"
...@@ -973,7 +973,7 @@ TEST_P(MultiviewRenderTest, AttribDivisor) ...@@ -973,7 +973,7 @@ TEST_P(MultiviewRenderTest, AttribDivisor)
const std::string &fsSource = const std::string &fsSource =
"#version 300 es\n" "#version 300 es\n"
"#extension GL_OVR_multiview2 : require\n" "#extension GL_OVR_multiview : require\n"
"precision mediump float;\n" "precision mediump float;\n"
"out vec4 col;\n" "out vec4 col;\n"
"void main()\n" "void main()\n"
...@@ -1039,7 +1039,7 @@ TEST_P(MultiviewRenderTest, DivisorOrderOfOperation) ...@@ -1039,7 +1039,7 @@ TEST_P(MultiviewRenderTest, DivisorOrderOfOperation)
// Create multiview program. // Create multiview program.
const std::string &vs = const std::string &vs =
"#version 300 es\n" "#version 300 es\n"
"#extension GL_OVR_multiview2 : require\n" "#extension GL_OVR_multiview : require\n"
"layout(num_views = 2) in;\n" "layout(num_views = 2) in;\n"
"layout(location = 0) in vec2 vPosition;\n" "layout(location = 0) in vec2 vPosition;\n"
"layout(location = 1) in float offsetX;\n" "layout(location = 1) in float offsetX;\n"
...@@ -1052,7 +1052,7 @@ TEST_P(MultiviewRenderTest, DivisorOrderOfOperation) ...@@ -1052,7 +1052,7 @@ TEST_P(MultiviewRenderTest, DivisorOrderOfOperation)
const std::string &fs = const std::string &fs =
"#version 300 es\n" "#version 300 es\n"
"#extension GL_OVR_multiview2 : require\n" "#extension GL_OVR_multiview : require\n"
"precision mediump float;\n" "precision mediump float;\n"
"out vec4 col;\n" "out vec4 col;\n"
"void main()\n" "void main()\n"
...@@ -1331,7 +1331,7 @@ TEST_P(MultiviewProgramGenerationTest, UseViewIDInVertexShader) ...@@ -1331,7 +1331,7 @@ TEST_P(MultiviewProgramGenerationTest, UseViewIDInVertexShader)
const std::string vsSource = const std::string vsSource =
"#version 300 es\n" "#version 300 es\n"
"#extension GL_OVR_multiview2 : require\n" "#extension GL_OVR_multiview : require\n"
"layout(num_views = 2) in;\n" "layout(num_views = 2) in;\n"
"void main()\n" "void main()\n"
"{\n" "{\n"
...@@ -1344,7 +1344,7 @@ TEST_P(MultiviewProgramGenerationTest, UseViewIDInVertexShader) ...@@ -1344,7 +1344,7 @@ TEST_P(MultiviewProgramGenerationTest, UseViewIDInVertexShader)
const std::string fsSource = const std::string fsSource =
"#version 300 es\n" "#version 300 es\n"
"#extension GL_OVR_multiview2 : require\n" "#extension GL_OVR_multiview : require\n"
"precision mediump float;\n" "precision mediump float;\n"
"void main()\n" "void main()\n"
"{\n" "{\n"
...@@ -1367,7 +1367,7 @@ TEST_P(MultiviewProgramGenerationTest, UseViewIDInFragmentShader) ...@@ -1367,7 +1367,7 @@ TEST_P(MultiviewProgramGenerationTest, UseViewIDInFragmentShader)
const std::string vsSource = const std::string vsSource =
"#version 300 es\n" "#version 300 es\n"
"#extension GL_OVR_multiview2 : require\n" "#extension GL_OVR_multiview : require\n"
"layout(num_views = 2) in;\n" "layout(num_views = 2) in;\n"
"void main()\n" "void main()\n"
"{\n" "{\n"
...@@ -1375,7 +1375,7 @@ TEST_P(MultiviewProgramGenerationTest, UseViewIDInFragmentShader) ...@@ -1375,7 +1375,7 @@ TEST_P(MultiviewProgramGenerationTest, UseViewIDInFragmentShader)
const std::string fsSource = const std::string fsSource =
"#version 300 es\n" "#version 300 es\n"
"#extension GL_OVR_multiview2 : require\n" "#extension GL_OVR_multiview : require\n"
"precision mediump float;\n" "precision mediump float;\n"
"out vec4 col;\n" "out vec4 col;\n"
"void main()\n" "void main()\n"
...@@ -1639,7 +1639,7 @@ TEST_P(MultiviewSideBySideRenderTest, NoLeakingFragments) ...@@ -1639,7 +1639,7 @@ TEST_P(MultiviewSideBySideRenderTest, NoLeakingFragments)
const std::string vsSource = const std::string vsSource =
"#version 300 es\n" "#version 300 es\n"
"#extension GL_OVR_multiview2 : require\n" "#extension GL_OVR_multiview : require\n"
"layout(num_views = 2) in;\n" "layout(num_views = 2) in;\n"
"layout(location=0) in vec2 vPosition;\n" "layout(location=0) in vec2 vPosition;\n"
"void main()\n" "void main()\n"
...@@ -1650,7 +1650,7 @@ TEST_P(MultiviewSideBySideRenderTest, NoLeakingFragments) ...@@ -1650,7 +1650,7 @@ TEST_P(MultiviewSideBySideRenderTest, NoLeakingFragments)
const std::string fsSource = const std::string fsSource =
"#version 300 es\n" "#version 300 es\n"
"#extension GL_OVR_multiview2 : require\n" "#extension GL_OVR_multiview : require\n"
"precision mediump float;\n" "precision mediump float;\n"
"out vec4 col;\n" "out vec4 col;\n"
"void main()\n" "void main()\n"
...@@ -1713,7 +1713,7 @@ TEST_P(MultiviewRenderTest, ProgramRelinkUpdatesAttribDivisor) ...@@ -1713,7 +1713,7 @@ TEST_P(MultiviewRenderTest, ProgramRelinkUpdatesAttribDivisor)
const std::string &fsSource = const std::string &fsSource =
"#version 300 es\n" "#version 300 es\n"
"#extension GL_OVR_multiview2 : require\n" "#extension GL_OVR_multiview : require\n"
"precision mediump float;\n" "precision mediump float;\n"
"in vec4 oColor;\n" "in vec4 oColor;\n"
"out vec4 col;\n" "out vec4 col;\n"
...@@ -1725,7 +1725,7 @@ TEST_P(MultiviewRenderTest, ProgramRelinkUpdatesAttribDivisor) ...@@ -1725,7 +1725,7 @@ TEST_P(MultiviewRenderTest, ProgramRelinkUpdatesAttribDivisor)
auto generateVertexShaderSource = [](int numViews) -> std::string { auto generateVertexShaderSource = [](int numViews) -> std::string {
std::string source = std::string source =
"#version 300 es\n" "#version 300 es\n"
"#extension GL_OVR_multiview2 : require\n" "#extension GL_OVR_multiview : require\n"
"layout(num_views = " + "layout(num_views = " +
ToString(numViews) + ToString(numViews) +
") in;\n" ") in;\n"
...@@ -1895,7 +1895,7 @@ TEST_P(MultiviewRenderTest, SelectColorBasedOnViewIDOVR) ...@@ -1895,7 +1895,7 @@ TEST_P(MultiviewRenderTest, SelectColorBasedOnViewIDOVR)
const std::string vsSource = const std::string vsSource =
"#version 300 es\n" "#version 300 es\n"
"#extension GL_OVR_multiview2 : require\n" "#extension GL_OVR_multiview : require\n"
"layout(num_views = 3) in;\n" "layout(num_views = 3) in;\n"
"in vec3 vPosition;\n" "in vec3 vPosition;\n"
"void main()\n" "void main()\n"
...@@ -1905,7 +1905,7 @@ TEST_P(MultiviewRenderTest, SelectColorBasedOnViewIDOVR) ...@@ -1905,7 +1905,7 @@ TEST_P(MultiviewRenderTest, SelectColorBasedOnViewIDOVR)
const std::string fsSource = const std::string fsSource =
"#version 300 es\n" "#version 300 es\n"
"#extension GL_OVR_multiview2 : require\n" "#extension GL_OVR_multiview : require\n"
"precision mediump float;\n" "precision mediump float;\n"
"out vec4 col;\n" "out vec4 col;\n"
"void main()\n" "void main()\n"
...@@ -1994,7 +1994,7 @@ TEST_P(MultiviewRenderTest, FlatInterpolation) ...@@ -1994,7 +1994,7 @@ TEST_P(MultiviewRenderTest, FlatInterpolation)
const std::string vsSource = const std::string vsSource =
"#version 300 es\n" "#version 300 es\n"
"#extension GL_OVR_multiview2 : require\n" "#extension GL_OVR_multiview : require\n"
"layout(num_views = 2) in;\n" "layout(num_views = 2) in;\n"
"in vec3 vPosition;\n" "in vec3 vPosition;\n"
"flat out int oInstanceID;\n" "flat out int oInstanceID;\n"
...@@ -2006,7 +2006,7 @@ TEST_P(MultiviewRenderTest, FlatInterpolation) ...@@ -2006,7 +2006,7 @@ TEST_P(MultiviewRenderTest, FlatInterpolation)
const std::string fsSource = const std::string fsSource =
"#version 300 es\n" "#version 300 es\n"
"#extension GL_OVR_multiview2 : require\n" "#extension GL_OVR_multiview : require\n"
"precision mediump float;\n" "precision mediump float;\n"
"flat in int oInstanceID;\n" "flat in int oInstanceID;\n"
"out vec4 col;\n" "out vec4 col;\n"
......
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