@@ -132,7 +132,6 @@ class IntermediateShaderSource final : angle::NonCopyable
132132 void init (const std::string &source);
133133 bool empty () const { return mTokens .empty (); }
134134
135- bool findTokenName (const std::string &name);
136135 // Find @@ LAYOUT-name(extra, args) @@ and replace it with:
137136 //
138137 // layout(specifier, extra, args)
@@ -311,18 +310,6 @@ void IntermediateShaderSource::init(const std::string &source)
311310 }
312311}
313312
314- bool IntermediateShaderSource::findTokenName (const std::string &name)
315- {
316- for (Token &block : mTokens )
317- {
318- if (block.text == name)
319- {
320- return true ;
321- }
322- }
323- return false ;
324- }
325-
326313void IntermediateShaderSource::insertLayoutSpecifier (const std::string &name,
327314 const std::string &specifier)
328315{
@@ -728,10 +715,15 @@ void AssignOutputLocations(const gl::ProgramState &programState,
728715
729716void AssignVaryingLocations (const gl::ProgramState &programState,
730717 const gl::ProgramLinkedResources &resources,
731- IntermediateShaderSource *outStageSource,
732- IntermediateShaderSource *inStageSource,
718+ gl::ShaderType outStage,
719+ gl::ShaderType inStage,
720+ gl::ShaderMap<IntermediateShaderSource> *shaderSources,
733721 XfbBufferMap *xfbBufferMap)
734722{
723+
724+ IntermediateShaderSource *outStageSource = &(*shaderSources)[outStage];
725+ IntermediateShaderSource *inStageSource = &(*shaderSources)[inStage];
726+
735727 // Assign varying locations.
736728 for (const gl::PackedVaryingRegister &varyingReg : resources.varyingPacking .getRegisterList ())
737729 {
@@ -768,13 +760,13 @@ void AssignVaryingLocations(const gl::ProgramState &programState,
768760 const std::string &name =
769761 varying.isStructField () ? varying.parentStructName : varying.varying ->name ;
770762
771- // Varings are from 3 stage of shader sources
763+ // Varyings are from multiple shader stages
772764 // To match pair of (out - in) qualifier, varying should be in the pair of shader source
773- if (!outStageSource-> findTokenName (name ) || !inStageSource-> findTokenName (name ))
765+ if (!varying. shaderStages . test (outStage ) || !varying. shaderStages . test (inStage ))
774766 {
775767 // Pair can be unmatching at transform feedback case,
776768 // But it requires qualifier.
777- if (!varying.vertexOnly )
769+ if (!varying.vertexOnly () )
778770 continue ;
779771 }
780772
@@ -1262,28 +1254,28 @@ void GlslangGetShaderSource(const GlslangSourceOptions &options,
12621254 if (!geometrySource->empty ())
12631255 {
12641256 AssignOutputLocations (programState, fragmentSource);
1265- AssignVaryingLocations (programState, resources, geometrySource, fragmentSource ,
1266- &xfbBufferMap);
1257+ AssignVaryingLocations (programState, resources, gl::ShaderType::Geometry ,
1258+ gl::ShaderType::Fragment, &intermediateSources, &xfbBufferMap);
12671259 if (!vertexSource->empty ())
12681260 {
12691261 AssignAttributeLocations (programState, vertexSource);
1270- AssignVaryingLocations (programState, resources, vertexSource, geometrySource ,
1271- &xfbBufferMap);
1262+ AssignVaryingLocations (programState, resources, gl::ShaderType::Vertex ,
1263+ gl::ShaderType::Geometry, &intermediateSources, &xfbBufferMap);
12721264 }
12731265 }
12741266 else if (!vertexSource->empty ())
12751267 {
12761268 AssignAttributeLocations (programState, vertexSource);
12771269 AssignOutputLocations (programState, fragmentSource);
1278- AssignVaryingLocations (programState, resources, vertexSource, fragmentSource ,
1279- &xfbBufferMap);
1270+ AssignVaryingLocations (programState, resources, gl::ShaderType::Vertex ,
1271+ gl::ShaderType::Fragment, &intermediateSources, &xfbBufferMap);
12801272 }
12811273 else if (!fragmentSource->empty ())
12821274 {
12831275 AssignAttributeLocations (programState, fragmentSource);
12841276 AssignOutputLocations (programState, fragmentSource);
1285- AssignVaryingLocations (programState, resources, vertexSource, fragmentSource ,
1286- &xfbBufferMap);
1277+ AssignVaryingLocations (programState, resources, gl::ShaderType::Vertex ,
1278+ gl::ShaderType::Fragment, &intermediateSources, &xfbBufferMap);
12871279 }
12881280 AssignUniformBindings (options, &intermediateSources);
12891281 AssignTextureBindings (options, useOldRewriteStructSamplers, programState, &intermediateSources);
0 commit comments