Commit 06c39376 by Shahbaz Youssefi Committed by Commit Bot

Vulkan: Minimize gl_PerVertex members

As ANGLE doesn't redeclare gl_PerVertex, glslang always defines it with: gl_Position gl_PointSize gl_ClipDistance gl_CullDistance The unused members here contribute to varying component limits. The last two are unlikely to be used, and the second member is rarely used as well. This change keeps it simple and strips the trailing inactive members, which for all intents and purposes accurately minimizes this struct. Bug: angleproject:5405 Change-Id: I59c22af4988a3da7b1e428913d0ea13be9031cea Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2562754 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: 's avatarTim Van Patten <timvp@google.com> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 0f083ab0
...@@ -124,10 +124,15 @@ void VaryingPacking::reset() ...@@ -124,10 +124,15 @@ void VaryingPacking::reset()
mRegisterList.clear(); mRegisterList.clear();
mPackedVaryings.clear(); mPackedVaryings.clear();
for (std::vector<std::string> inactiveVaryingMappedNames : mInactiveVaryingMappedNames) for (std::vector<std::string> &inactiveVaryingMappedNames : mInactiveVaryingMappedNames)
{ {
inactiveVaryingMappedNames.clear(); inactiveVaryingMappedNames.clear();
} }
for (std::vector<std::string> &activeBuiltIns : mActiveOutputBuiltIns)
{
activeBuiltIns.clear();
}
} }
void VaryingPacking::clearRegisterMap() void VaryingPacking::clearRegisterMap()
...@@ -364,12 +369,12 @@ void VaryingPacking::packUserVarying(const ProgramVaryingRef &ref, ...@@ -364,12 +369,12 @@ void VaryingPacking::packUserVarying(const ProgramVaryingRef &ref,
VaryingInShaderRef backVarying(ref.backShaderStage, output); VaryingInShaderRef backVarying(ref.backShaderStage, output);
mPackedVaryings.emplace_back(std::move(frontVarying), std::move(backVarying), interpolation); mPackedVaryings.emplace_back(std::move(frontVarying), std::move(backVarying), interpolation);
if (input) if (input && !input->isBuiltIn())
{ {
(*uniqueFullNames)[ref.frontShaderStage].insert( (*uniqueFullNames)[ref.frontShaderStage].insert(
mPackedVaryings.back().fullName(ref.frontShaderStage)); mPackedVaryings.back().fullName(ref.frontShaderStage));
} }
if (output) if (output && !output->isBuiltIn())
{ {
(*uniqueFullNames)[ref.backShaderStage].insert( (*uniqueFullNames)[ref.backShaderStage].insert(
mPackedVaryings.back().fullName(ref.backShaderStage)); mPackedVaryings.back().fullName(ref.backShaderStage));
...@@ -454,22 +459,31 @@ bool VaryingPacking::collectAndPackUserVaryings(gl::InfoLog &infoLog, ...@@ -454,22 +459,31 @@ bool VaryingPacking::collectAndPackUserVaryings(gl::InfoLog &infoLog,
const bool isSeparableProgram) const bool isSeparableProgram)
{ {
VaryingUniqueFullNames uniqueFullNames; VaryingUniqueFullNames uniqueFullNames;
mPackedVaryings.clear();
clearRegisterMap(); reset();
for (const ProgramVaryingRef &ref : mergedVaryings) for (const ProgramVaryingRef &ref : mergedVaryings)
{ {
const sh::ShaderVariable *input = ref.frontShader; const sh::ShaderVariable *input = ref.frontShader;
const sh::ShaderVariable *output = ref.backShader; const sh::ShaderVariable *output = ref.backShader;
const bool isActiveBuiltInInput = input && input->isBuiltIn() && input->active;
const bool isActiveBuiltInOutput = output && output->isBuiltIn() && output->active;
// Keep track of output builtins that are used by the shader, such as gl_Position,
// gl_PointSize etc.
if (isActiveBuiltInInput)
{
mActiveOutputBuiltIns[ref.frontShaderStage].push_back(input->name);
}
// Only pack statically used varyings that have a matched input or output, plus special // Only pack statically used varyings that have a matched input or output, plus special
// builtins. Note that we pack all statically used user-defined varyings even if they are // builtins. Note that we pack all statically used user-defined varyings even if they are
// not active. GLES specs are a bit vague on whether it's allowed to only pack active // not active. GLES specs are a bit vague on whether it's allowed to only pack active
// varyings, though GLES 3.1 spec section 11.1.2.1 says that "device-dependent // varyings, though GLES 3.1 spec section 11.1.2.1 says that "device-dependent
// optimizations" may be used to make vertex shader outputs fit. // optimizations" may be used to make vertex shader outputs fit.
if ((input && output && output->staticUse) || if ((input && output && output->staticUse) || isActiveBuiltInInput ||
(input && input->isBuiltIn() && input->active) || isActiveBuiltInOutput ||
(output && output->isBuiltIn() && output->active) ||
(isSeparableProgram && ((input && input->active) || (output && output->active)))) (isSeparableProgram && ((input && input->active) || (output && output->active))))
{ {
const sh::ShaderVariable *varying = output ? output : input; const sh::ShaderVariable *varying = output ? output : input;
...@@ -508,7 +522,10 @@ bool VaryingPacking::collectAndPackUserVaryings(gl::InfoLog &infoLog, ...@@ -508,7 +522,10 @@ bool VaryingPacking::collectAndPackUserVaryings(gl::InfoLog &infoLog,
// program, in which case the input shader may not exist in this program. // program, in which case the input shader may not exist in this program.
if (!input && !isSeparableProgram) if (!input && !isSeparableProgram)
{ {
mInactiveVaryingMappedNames[ref.backShaderStage].push_back(output->mappedName); if (!output->isBuiltIn())
{
mInactiveVaryingMappedNames[ref.backShaderStage].push_back(output->mappedName);
}
continue; continue;
} }
...@@ -560,11 +577,13 @@ bool VaryingPacking::collectAndPackUserVaryings(gl::InfoLog &infoLog, ...@@ -560,11 +577,13 @@ bool VaryingPacking::collectAndPackUserVaryings(gl::InfoLog &infoLog,
} }
} }
if (input && uniqueFullNames[ref.frontShaderStage].count(input->name) == 0) if (input && !input->isBuiltIn() &&
uniqueFullNames[ref.frontShaderStage].count(input->name) == 0)
{ {
mInactiveVaryingMappedNames[ref.frontShaderStage].push_back(input->mappedName); mInactiveVaryingMappedNames[ref.frontShaderStage].push_back(input->mappedName);
} }
if (output && uniqueFullNames[ref.backShaderStage].count(output->name) == 0) if (output && !output->isBuiltIn() &&
uniqueFullNames[ref.backShaderStage].count(output->name) == 0)
{ {
mInactiveVaryingMappedNames[ref.backShaderStage].push_back(output->mappedName); mInactiveVaryingMappedNames[ref.backShaderStage].push_back(output->mappedName);
} }
......
...@@ -221,6 +221,11 @@ class VaryingPacking final : angle::NonCopyable ...@@ -221,6 +221,11 @@ class VaryingPacking final : angle::NonCopyable
return mInactiveVaryingMappedNames; return mInactiveVaryingMappedNames;
} }
const ShaderMap<std::vector<std::string>> &getActiveOutputBuiltIns() const
{
return mActiveOutputBuiltIns;
}
void reset(); void reset();
private: private:
...@@ -249,6 +254,7 @@ class VaryingPacking final : angle::NonCopyable ...@@ -249,6 +254,7 @@ class VaryingPacking final : angle::NonCopyable
std::vector<PackedVaryingRegister> mRegisterList; std::vector<PackedVaryingRegister> mRegisterList;
std::vector<PackedVarying> mPackedVaryings; std::vector<PackedVarying> mPackedVaryings;
ShaderMap<std::vector<std::string>> mInactiveVaryingMappedNames; ShaderMap<std::vector<std::string>> mInactiveVaryingMappedNames;
ShaderMap<std::vector<std::string>> mActiveOutputBuiltIns;
PackMode mPackMode; PackMode mPackMode;
}; };
......
...@@ -86,7 +86,9 @@ struct ShaderInterfaceVariableInfo ...@@ -86,7 +86,9 @@ struct ShaderInterfaceVariableInfo
// mismatch between the shaders. For example, either the VS casts highp->mediump // mismatch between the shaders. For example, either the VS casts highp->mediump
// or the FS casts mediump->highp. // or the FS casts mediump->highp.
bool useRelaxedPrecision = false; bool useRelaxedPrecision = false;
// Indicate if varying is input or output // Indicate if varying is input or output, or both (in case of for example gl_Position in a
// geometry shader)
bool varyingIsInput = false;
bool varyingIsOutput = false; bool varyingIsOutput = false;
// For vertex attributes, this is the number of components / locations. These are used by the // For vertex attributes, this is the number of components / locations. These are used by the
// vertex attribute aliasing transformation only. // vertex attribute aliasing transformation only.
...@@ -120,6 +122,7 @@ void GlslangGenTransformFeedbackEmulationOutputs( ...@@ -120,6 +122,7 @@ void GlslangGenTransformFeedbackEmulationOutputs(
void GlslangAssignLocations(const GlslangSourceOptions &options, void GlslangAssignLocations(const GlslangSourceOptions &options,
const gl::ProgramExecutable &programExecutable, const gl::ProgramExecutable &programExecutable,
const gl::ShaderType shaderType, const gl::ShaderType shaderType,
const gl::ShaderType frontShaderType,
GlslangProgramInterfaceInfo *programInterfaceInfo, GlslangProgramInterfaceInfo *programInterfaceInfo,
gl::ShaderMap<ShaderInterfaceVariableInfoMap> *variableInfoMapOut); gl::ShaderMap<ShaderInterfaceVariableInfoMap> *variableInfoMapOut);
......
...@@ -432,7 +432,8 @@ void GlslangGetShaderSource(const gl::ProgramState &programState, ...@@ -432,7 +432,8 @@ void GlslangGetShaderSource(const gl::ProgramState &programState,
&xfbOnlyVariableMaps[gl::ShaderType::Vertex]); &xfbOnlyVariableMaps[gl::ShaderType::Vertex]);
GlslangAssignLocations(options, programState.getExecutable(), gl::ShaderType::Vertex, GlslangAssignLocations(options, programState.getExecutable(), gl::ShaderType::Vertex,
&xfbOnlyInterfaceInfo, &xfbOnlyVariableMaps); gl::ShaderType::InvalidEnum, &xfbOnlyInterfaceInfo,
&xfbOnlyVariableMaps);
*xfbOnlyVSVariableInfoMapOut = std::move(xfbOnlyVariableMaps[gl::ShaderType::Vertex]); *xfbOnlyVSVariableInfoMapOut = std::move(xfbOnlyVariableMaps[gl::ShaderType::Vertex]);
} }
} }
......
...@@ -227,6 +227,7 @@ std::unique_ptr<rx::LinkEvent> ProgramExecutableVk::load(gl::BinaryInputStream * ...@@ -227,6 +227,7 @@ std::unique_ptr<rx::LinkEvent> ProgramExecutableVk::load(gl::BinaryInputStream *
info->xfbOffset = stream->readInt<uint32_t>(); info->xfbOffset = stream->readInt<uint32_t>();
info->xfbStride = stream->readInt<uint32_t>(); info->xfbStride = stream->readInt<uint32_t>();
info->useRelaxedPrecision = stream->readBool(); info->useRelaxedPrecision = stream->readBool();
info->varyingIsInput = stream->readBool();
info->varyingIsOutput = stream->readBool(); info->varyingIsOutput = stream->readBool();
info->attributeComponentCount = stream->readInt<uint8_t>(); info->attributeComponentCount = stream->readInt<uint8_t>();
info->attributeLocationCount = stream->readInt<uint8_t>(); info->attributeLocationCount = stream->readInt<uint8_t>();
...@@ -254,6 +255,7 @@ void ProgramExecutableVk::save(gl::BinaryOutputStream *stream) ...@@ -254,6 +255,7 @@ void ProgramExecutableVk::save(gl::BinaryOutputStream *stream)
stream->writeInt(it.second.xfbOffset); stream->writeInt(it.second.xfbOffset);
stream->writeInt(it.second.xfbStride); stream->writeInt(it.second.xfbStride);
stream->writeBool(it.second.useRelaxedPrecision); stream->writeBool(it.second.useRelaxedPrecision);
stream->writeBool(it.second.varyingIsInput);
stream->writeBool(it.second.varyingIsOutput); stream->writeBool(it.second.varyingIsOutput);
stream->writeInt(it.second.attributeComponentCount); stream->writeInt(it.second.attributeComponentCount);
stream->writeInt(it.second.attributeLocationCount); stream->writeInt(it.second.attributeLocationCount);
...@@ -923,7 +925,7 @@ void ProgramExecutableVk::resolvePrecisionMismatch(const gl::ProgramMergedVaryin ...@@ -923,7 +925,7 @@ void ProgramExecutableVk::resolvePrecisionMismatch(const gl::ProgramMergedVaryin
// The output is lower precision than the input, adjust the input // The output is lower precision than the input, adjust the input
info = &mVariableInfoMap[mergedVarying.backShaderStage] info = &mVariableInfoMap[mergedVarying.backShaderStage]
[mergedVarying.backShader->mappedName]; [mergedVarying.backShader->mappedName];
info->varyingIsOutput = false; info->varyingIsInput = true;
info->useRelaxedPrecision = true; info->useRelaxedPrecision = true;
} }
} }
......
...@@ -67,6 +67,7 @@ angle::Result ProgramPipelineVk::link(const gl::Context *glContext, ...@@ -67,6 +67,7 @@ angle::Result ProgramPipelineVk::link(const gl::Context *glContext,
// Now that the program pipeline has all of the programs attached, the various descriptor // Now that the program pipeline has all of the programs attached, the various descriptor
// set/binding locations need to be re-assigned to their correct values. // set/binding locations need to be re-assigned to their correct values.
gl::ShaderType frontShaderType = gl::ShaderType::InvalidEnum;
for (const gl::ShaderType shaderType : glPipeline->getExecutable().getLinkedShaderStages()) for (const gl::ShaderType shaderType : glPipeline->getExecutable().getLinkedShaderStages())
{ {
gl::Program *glProgram = gl::Program *glProgram =
...@@ -82,8 +83,9 @@ angle::Result ProgramPipelineVk::link(const gl::Context *glContext, ...@@ -82,8 +83,9 @@ angle::Result ProgramPipelineVk::link(const gl::Context *glContext,
programProgramInterfaceInfo.locationsUsedForXfbExtension; programProgramInterfaceInfo.locationsUsedForXfbExtension;
GlslangAssignLocations(options, glProgram->getState().getExecutable(), shaderType, GlslangAssignLocations(options, glProgram->getState().getExecutable(), shaderType,
&glslangProgramInterfaceInfo, frontShaderType, &glslangProgramInterfaceInfo,
&mExecutable.getShaderInterfaceVariableInfoMap()); &mExecutable.getShaderInterfaceVariableInfoMap());
frontShaderType = shaderType;
} }
} }
......
...@@ -189,8 +189,6 @@ ...@@ -189,8 +189,6 @@
// Geometry shader support: // Geometry shader support:
3580 VULKAN : dEQP-GLES31.functional.shaders.linkage.es31.geometry.varying.types.float_struct = SKIP 3580 VULKAN : dEQP-GLES31.functional.shaders.linkage.es31.geometry.varying.types.float_struct = SKIP
5404 VULKAN : dEQP-GLES31.functional.geometry_shading.query.primitives_generated* = SKIP 5404 VULKAN : dEQP-GLES31.functional.geometry_shading.query.primitives_generated* = SKIP
5405 VULKAN : dEQP-GLES31.functional.geometry_shading.basic.output_* = FAIL
5405 VULKAN : dEQP-GLES31.functional.geometry_shading.instanced.invocation_output_vary_by_* = FAIL
5406 VULKAN : dEQP-GLES31.functional.geometry_shading.input.*adjacency* = SKIP 5406 VULKAN : dEQP-GLES31.functional.geometry_shading.input.*adjacency* = SKIP
5407 VULKAN : dEQP-GLES31.functional.geometry_shading.layered.* = SKIP 5407 VULKAN : dEQP-GLES31.functional.geometry_shading.layered.* = SKIP
5407 VULKAN : dEQP-GLES31.functional.geometry_shading.instanced.invocation_per_layer* = SKIP 5407 VULKAN : dEQP-GLES31.functional.geometry_shading.instanced.invocation_per_layer* = SKIP
......
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