Add shader translator support for OVR_multiview
The OVR_multiview and OVR_multiview2 extensions add gl_ViewID_OVR to
shaders. gl_ViewID_OVR can be translated either as is in GLSL output
or as a uniform by setting the SH_TRANSLATE_VIEWID_OVR_AS_UNIFORM
compiler flag.
If WebGL output is selected, the shaders will be validated according
to proposed rules in the WEBGL_multiview spec.
BUG=angleproject:1669
TEST=angle_unittests
Change-Id: I19ea3a6c8b4edb78be03f1a50a96bfef018870d0
Reviewed-on: https://chromium-review.googlesource.com/422848
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
diff --git a/src/compiler/translator/ShaderLang.cpp b/src/compiler/translator/ShaderLang.cpp
index 9276233..da121e8 100644
--- a/src/compiler/translator/ShaderLang.cpp
+++ b/src/compiler/translator/ShaderLang.cpp
@@ -161,6 +161,7 @@
resources->EXT_shader_framebuffer_fetch = 0;
resources->NV_shader_framebuffer_fetch = 0;
resources->ARM_shader_framebuffer_fetch = 0;
+ resources->OVR_multiview = 0;
resources->NV_draw_buffers = 0;
@@ -176,6 +177,8 @@
// Extensions constants.
resources->MaxDualSourceDrawBuffers = 0;
+ resources->MaxViewsOVR = 2;
+
// Disable name hashing by default.
resources->HashFunction = NULL;
@@ -371,6 +374,16 @@
return compiler->getComputeShaderLocalSize();
}
+int ShGetVertexShaderNumViews(const ShHandle handle)
+{
+ ASSERT(handle);
+ TShHandleBase *base = static_cast<TShHandleBase *>(handle);
+ TCompiler *compiler = base->getAsCompiler();
+ ASSERT(compiler);
+
+ return compiler->getNumViews();
+}
+
bool ShCheckVariablesWithinPackingLimits(int maxVectors,
const std::vector<ShaderVariable> &variables)
{
@@ -512,6 +525,11 @@
return ShGetComputeShaderLocalGroupSize(handle);
}
+int GetVertexShaderNumViews(const ShHandle handle)
+{
+ return ShGetVertexShaderNumViews(handle);
+}
+
bool CheckVariablesWithinPackingLimits(int maxVectors,
const std::vector<sh::ShaderVariable> &variables)
{