Commit 4dd167fb by Jamie Madill Committed by Commit Bot

Vulkan: Assign locations to varyings.

These were actually always required, but only was caught by the newer versions of the SPIR-V toolchain. BUG=angleproject:2237 Change-Id: I43fef179e8792e46a602b39a6decafcab03b19df Reviewed-on: https://chromium-review.googlesource.com/760638Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent 05fd3860
...@@ -44,7 +44,8 @@ void TOutputVulkanGLSL::writeLayoutQualifier(TIntermTyped *variable) ...@@ -44,7 +44,8 @@ void TOutputVulkanGLSL::writeLayoutQualifier(TIntermTyped *variable)
bool needsCustomLayout = bool needsCustomLayout =
(type.getQualifier() == EvqAttribute || type.getQualifier() == EvqFragmentOut || (type.getQualifier() == EvqAttribute || type.getQualifier() == EvqFragmentOut ||
type.getQualifier() == EvqVertexIn || IsSampler(type.getBasicType())); type.getQualifier() == EvqVertexIn || IsVarying(type.getQualifier()) ||
IsSampler(type.getBasicType()));
if (!NeedsToWriteLayoutQualifier(type) && !needsCustomLayout) if (!NeedsToWriteLayoutQualifier(type) && !needsCustomLayout)
{ {
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include "common/string_utils.h" #include "common/string_utils.h"
#include "common/utilities.h" #include "common/utilities.h"
#include "libANGLE/ProgramLinkedResources.h"
namespace rx namespace rx
{ {
...@@ -35,8 +36,7 @@ void InsertLayoutSpecifierString(std::string *shaderString, ...@@ -35,8 +36,7 @@ void InsertLayoutSpecifierString(std::string *shaderString,
searchStringBuilder << "@@ LAYOUT-" << variableName << " @@"; searchStringBuilder << "@@ LAYOUT-" << variableName << " @@";
std::string searchString = searchStringBuilder.str(); std::string searchString = searchStringBuilder.str();
bool success = angle::ReplaceSubstring(shaderString, searchString, layoutString); angle::ReplaceSubstring(shaderString, searchString, layoutString);
ASSERT(success);
} }
} // anonymous namespace } // anonymous namespace
...@@ -85,6 +85,7 @@ GlslangWrapper::~GlslangWrapper() ...@@ -85,6 +85,7 @@ GlslangWrapper::~GlslangWrapper()
gl::LinkResult GlslangWrapper::linkProgram(const gl::Context *glContext, gl::LinkResult GlslangWrapper::linkProgram(const gl::Context *glContext,
const gl::ProgramState &programState, const gl::ProgramState &programState,
const gl::ProgramLinkedResources &resources,
std::vector<uint32_t> *vertexCodeOut, std::vector<uint32_t> *vertexCodeOut,
std::vector<uint32_t> *fragmentCodeOut) std::vector<uint32_t> *fragmentCodeOut)
{ {
...@@ -106,6 +107,16 @@ gl::LinkResult GlslangWrapper::linkProgram(const gl::Context *glContext, ...@@ -106,6 +107,16 @@ gl::LinkResult GlslangWrapper::linkProgram(const gl::Context *glContext,
InsertLayoutSpecifierString(&vertexSource, attribute.name, locationString); InsertLayoutSpecifierString(&vertexSource, attribute.name, locationString);
} }
// Assign varying locations.
// TODO(jmadill): This might need to be redone.
for (const auto &varyingReg : resources.varyingPacking.getRegisterList())
{
const auto &varying = *varyingReg.packedVarying;
std::string locationString = "location = " + Str(varyingReg.registerRow);
InsertLayoutSpecifierString(&vertexSource, varying.varying->name, locationString);
InsertLayoutSpecifierString(&fragmentSource, varying.varying->name, locationString);
}
// Bind the default uniforms for vertex and fragment shaders. // Bind the default uniforms for vertex and fragment shaders.
// See corresponding code in OutputVulkanGLSL.cpp. // See corresponding code in OutputVulkanGLSL.cpp.
std::stringstream searchStringBuilder; std::stringstream searchStringBuilder;
......
...@@ -25,6 +25,7 @@ class GlslangWrapper : public gl::RefCountObjectNoID ...@@ -25,6 +25,7 @@ class GlslangWrapper : public gl::RefCountObjectNoID
gl::LinkResult linkProgram(const gl::Context *glContext, gl::LinkResult linkProgram(const gl::Context *glContext,
const gl::ProgramState &programState, const gl::ProgramState &programState,
const gl::ProgramLinkedResources &resources,
std::vector<uint32_t> *vertexCodeOut, std::vector<uint32_t> *vertexCodeOut,
std::vector<uint32_t> *fragmentCodeOut); std::vector<uint32_t> *fragmentCodeOut);
......
...@@ -212,8 +212,9 @@ gl::LinkResult ProgramVk::link(const gl::Context *glContext, ...@@ -212,8 +212,9 @@ gl::LinkResult ProgramVk::link(const gl::Context *glContext,
std::vector<uint32_t> vertexCode; std::vector<uint32_t> vertexCode;
std::vector<uint32_t> fragmentCode; std::vector<uint32_t> fragmentCode;
bool linkSuccess = false; bool linkSuccess = false;
ANGLE_TRY_RESULT(glslangWrapper->linkProgram(glContext, mState, &vertexCode, &fragmentCode), ANGLE_TRY_RESULT(
linkSuccess); glslangWrapper->linkProgram(glContext, mState, resources, &vertexCode, &fragmentCode),
linkSuccess);
if (!linkSuccess) if (!linkSuccess)
{ {
return false; return false;
......
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