Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix GLSL/ESSL OVR_multiview extension transpilation #10

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions src/compiler/translator/TranslatorESSL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,29 @@ void TranslatorESSL::writeExtensionBehavior(ShCompileOptions compileOptions)
sink << "#extension GL_NV_draw_buffers : " << getBehaviorString(iter->second)
<< "\n";
}
else if (isMultiview && isMultiviewExtEmulated)
else if (isMultiview)
{
if (getShaderType() == GL_VERTEX_SHADER &&
(compileOptions & SH_SELECT_VIEW_IN_NV_GLSL_VERTEX_SHADER) != 0u)
// Emit the OVR_multiview extension
sink << "#extension " << iter->first << " : " << getBehaviorString(iter->second)
<< "\n";

if (getShaderType() == GL_VERTEX_SHADER)
{
// Emit the NV_viewport_array2 extension in a vertex shader if the
// SH_SELECT_VIEW_IN_NV_GLSL_VERTEX_SHADER option is set and the
// OVR_multiview(2) extension is requested.
sink << "#extension GL_NV_viewport_array2 : require\n";
if (isMultiviewExtEmulated && (compileOptions & SH_SELECT_VIEW_IN_NV_GLSL_VERTEX_SHADER) != 0u)
{
sink << "#extension GL_NV_viewport_array2 : require\n";
}

// Vertex shaders allows the num_views layout qualifier.
// If this qualifier is not declared, the behavior is as if it had been set to 1.
if (getNumViews() >= 2)
{
sink << "layout(num_views=" << getNumViews() << ") in;"
<< "\n";
}
}
}
else if (iter->first == "GL_OES_geometry_shader")
Expand Down
29 changes: 23 additions & 6 deletions src/compiler/translator/TranslatorGLSL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,13 +285,30 @@ void TranslatorGLSL::writeExtensionBehavior(TIntermNode *root, ShCompileOptions

const bool isMultiview =
iter.first == "GL_OVR_multiview" || iter.first == "GL_OVR_multiview2";
if (isMultiview && getShaderType() == GL_VERTEX_SHADER &&
(compileOptions & SH_SELECT_VIEW_IN_NV_GLSL_VERTEX_SHADER) != 0u)
if (isMultiview)
{
// Emit the NV_viewport_array2 extension in a vertex shader if the
// SH_SELECT_VIEW_IN_NV_GLSL_VERTEX_SHADER option is set and the OVR_multiview(2)
// extension is requested.
sink << "#extension GL_NV_viewport_array2 : require\n";
// Emit the OVR_multiview extension
sink << "#extension " << iter.first << " : " << getBehaviorString(iter.second)
<< "\n";

if (getShaderType() == GL_VERTEX_SHADER)
{
// Emit the NV_viewport_array2 extension in a vertex shader if the
// SH_SELECT_VIEW_IN_NV_GLSL_VERTEX_SHADER option is set and the
// OVR_multiview(2) extension is requested.
if ((compileOptions & SH_SELECT_VIEW_IN_NV_GLSL_VERTEX_SHADER) != 0u)
{
sink << "#extension GL_NV_viewport_array2 : require\n";
}

// Vertex shaders allows the num_views layout qualifier.
// If this qualifier is not declared, the behavior is as if it had been set to 1.
if (getNumViews() >= 2)
{
sink << "layout(num_views=" << getNumViews() << ") in;"
<< "\n";
}
}
}
}

Expand Down