Commit f02490d1 by Shahbaz Youssefi Committed by Commit Bot

Vulkan: clean up arguments to glslang wrapper

Some flags were sent as parameters while an Options parameter was added. This change moves those flags to the GlslangSourceOptions struct. Bug: angleproject:3394 Change-Id: Iff5c1c83dd564d7bcfcbd84e6df244b7356d669d Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1984108Reviewed-by: 's avatarYuly Novikov <ynovikov@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
parent 7fad424e
...@@ -524,7 +524,7 @@ void GenerateTransformFeedbackEmulationOutputs(const GlslangSourceOptions &optio ...@@ -524,7 +524,7 @@ void GenerateTransformFeedbackEmulationOutputs(const GlslangSourceOptions &optio
vertexShader->insertTransformFeedbackOutput(std::move(xfbOut)); vertexShader->insertTransformFeedbackOutput(std::move(xfbOut));
} }
// Calculates XFB layout quaifier arguments for each tranform feedback varyings, inserts // Calculates XFB layout qualifier arguments for each tranform feedback varying, inserts
// layout quailifier for built-in varyings here and gathers calculated arguments for non built-in // layout quailifier for built-in varyings here and gathers calculated arguments for non built-in
// varyings for later use. // varyings for later use.
void GenerateTransformFeedbackExtensionOutputs(const gl::ProgramState &programState, void GenerateTransformFeedbackExtensionOutputs(const gl::ProgramState &programState,
...@@ -984,7 +984,6 @@ void AssignNonTextureBindings(const GlslangSourceOptions &options, ...@@ -984,7 +984,6 @@ void AssignNonTextureBindings(const GlslangSourceOptions &options,
} }
void AssignTextureBindings(const GlslangSourceOptions &options, void AssignTextureBindings(const GlslangSourceOptions &options,
bool useOldRewriteStructSamplers,
const gl::ProgramState &programState, const gl::ProgramState &programState,
gl::ShaderMap<IntermediateShaderSource> *shaderSources) gl::ShaderMap<IntermediateShaderSource> *shaderSources)
{ {
...@@ -998,7 +997,7 @@ void AssignTextureBindings(const GlslangSourceOptions &options, ...@@ -998,7 +997,7 @@ void AssignTextureBindings(const GlslangSourceOptions &options,
{ {
const gl::LinkedUniform &samplerUniform = uniforms[uniformIndex]; const gl::LinkedUniform &samplerUniform = uniforms[uniformIndex];
if (!useOldRewriteStructSamplers && if (!options.useOldRewriteStructSamplers &&
gl::SamplerNameContainsNonZeroArrayElement(samplerUniform.name)) gl::SamplerNameContainsNonZeroArrayElement(samplerUniform.name))
{ {
continue; continue;
...@@ -1008,7 +1007,7 @@ void AssignTextureBindings(const GlslangSourceOptions &options, ...@@ -1008,7 +1007,7 @@ void AssignTextureBindings(const GlslangSourceOptions &options,
texturesDescriptorSet + ", binding = " + Str(bindingIndex++); texturesDescriptorSet + ", binding = " + Str(bindingIndex++);
// Samplers in structs are extracted and renamed. // Samplers in structs are extracted and renamed.
const std::string samplerName = useOldRewriteStructSamplers const std::string samplerName = options.useOldRewriteStructSamplers
? GetMappedSamplerNameOld(samplerUniform.name) ? GetMappedSamplerNameOld(samplerUniform.name)
: GlslangGetMappedSamplerName(samplerUniform.name); : GlslangGetMappedSamplerName(samplerUniform.name);
...@@ -1195,9 +1194,6 @@ std::string GlslangGetMappedSamplerName(const std::string &originalName) ...@@ -1195,9 +1194,6 @@ std::string GlslangGetMappedSamplerName(const std::string &originalName)
} }
void GlslangGetShaderSource(const GlslangSourceOptions &options, void GlslangGetShaderSource(const GlslangSourceOptions &options,
bool useOldRewriteStructSamplers,
bool supportsTransformFeedbackExtension,
bool emulateTransformFeedback,
const gl::ProgramState &programState, const gl::ProgramState &programState,
const gl::ProgramLinkedResources &resources, const gl::ProgramLinkedResources &resources,
gl::ShaderMap<std::string> *shaderSourcesOut) gl::ShaderMap<std::string> *shaderSourcesOut)
...@@ -1229,12 +1225,12 @@ void GlslangGetShaderSource(const GlslangSourceOptions &options, ...@@ -1229,12 +1225,12 @@ void GlslangGetShaderSource(const GlslangSourceOptions &options,
} }
else else
{ {
if (supportsTransformFeedbackExtension) if (options.supportsTransformFeedbackExtension)
{ {
GenerateTransformFeedbackExtensionOutputs(programState, vertexSource, &xfbBufferMap, GenerateTransformFeedbackExtensionOutputs(programState, vertexSource, &xfbBufferMap,
resources); resources);
} }
else if (emulateTransformFeedback) else if (options.emulateTransformFeedback)
{ {
GenerateTransformFeedbackEmulationOutputs(options, programState, vertexSource); GenerateTransformFeedbackEmulationOutputs(options, programState, vertexSource);
} }
...@@ -1260,10 +1256,10 @@ void GlslangGetShaderSource(const GlslangSourceOptions &options, ...@@ -1260,10 +1256,10 @@ void GlslangGetShaderSource(const GlslangSourceOptions &options,
} }
AssignUniformBindings(options, &intermediateSources); AssignUniformBindings(options, &intermediateSources);
AssignTextureBindings(options, useOldRewriteStructSamplers, programState, &intermediateSources); AssignTextureBindings(options, programState, &intermediateSources);
AssignNonTextureBindings(options, programState, &intermediateSources); AssignNonTextureBindings(options, programState, &intermediateSources);
CleanupUnusedEntities(useOldRewriteStructSamplers, programState, resources, CleanupUnusedEntities(options.useOldRewriteStructSamplers, programState, resources,
&intermediateSources); &intermediateSources);
for (const gl::ShaderType shaderType : gl::AllShaderTypes()) for (const gl::ShaderType shaderType : gl::AllShaderTypes())
......
...@@ -33,6 +33,10 @@ struct GlslangSourceOptions ...@@ -33,6 +33,10 @@ struct GlslangSourceOptions
// Binding index start for transform feedback buffers: // Binding index start for transform feedback buffers:
uint32_t xfbBindingIndexStart = 16; uint32_t xfbBindingIndexStart = 16;
bool useOldRewriteStructSamplers = false;
bool supportsTransformFeedbackExtension = false;
bool emulateTransformFeedback = false;
}; };
using GlslangErrorCallback = std::function<angle::Result(GlslangError)>; using GlslangErrorCallback = std::function<angle::Result(GlslangError)>;
...@@ -46,9 +50,6 @@ std::string GlslangGetMappedSamplerName(const std::string &originalName); ...@@ -46,9 +50,6 @@ std::string GlslangGetMappedSamplerName(const std::string &originalName);
// Transform the source to include actual binding points for various shader // Transform the source to include actual binding points for various shader
// resources (textures, buffers, xfb, etc) // resources (textures, buffers, xfb, etc)
void GlslangGetShaderSource(const GlslangSourceOptions &options, void GlslangGetShaderSource(const GlslangSourceOptions &options,
bool useOldRewriteStructSamplers,
bool supportsTransformFeedbackExtension,
bool emulateTransformFeedback,
const gl::ProgramState &programState, const gl::ProgramState &programState,
const gl::ProgramLinkedResources &resources, const gl::ProgramLinkedResources &resources,
gl::ShaderMap<std::string> *shaderSourcesOut); gl::ShaderMap<std::string> *shaderSourcesOut);
......
...@@ -45,8 +45,7 @@ void GlslangGetShaderSource(const gl::ProgramState &programState, ...@@ -45,8 +45,7 @@ void GlslangGetShaderSource(const gl::ProgramState &programState,
const gl::ProgramLinkedResources &resources, const gl::ProgramLinkedResources &resources,
gl::ShaderMap<std::string> *shaderSourcesOut) gl::ShaderMap<std::string> *shaderSourcesOut)
{ {
rx::GlslangGetShaderSource(CreateSourceOptions(), false, false, false, programState, resources, rx::GlslangGetShaderSource(CreateSourceOptions(), programState, resources, shaderSourcesOut);
shaderSourcesOut);
} }
angle::Result GlslangGetShaderSpirvCode(ErrorHandler *context, angle::Result GlslangGetShaderSpirvCode(ErrorHandler *context,
......
...@@ -22,7 +22,7 @@ angle::Result ErrorHandler(vk::Context *context, GlslangError) ...@@ -22,7 +22,7 @@ angle::Result ErrorHandler(vk::Context *context, GlslangError)
return angle::Result::Stop; return angle::Result::Stop;
} }
GlslangSourceOptions CreateSourceOptions() GlslangSourceOptions CreateSourceOptions(const angle::FeaturesVk &features)
{ {
GlslangSourceOptions options; GlslangSourceOptions options;
options.uniformsAndXfbDescriptorSetIndex = kUniformsAndXfbDescriptorSetIndex; options.uniformsAndXfbDescriptorSetIndex = kUniformsAndXfbDescriptorSetIndex;
...@@ -30,6 +30,10 @@ GlslangSourceOptions CreateSourceOptions() ...@@ -30,6 +30,10 @@ GlslangSourceOptions CreateSourceOptions()
options.shaderResourceDescriptorSetIndex = kShaderResourceDescriptorSetIndex; options.shaderResourceDescriptorSetIndex = kShaderResourceDescriptorSetIndex;
options.driverUniformsDescriptorSetIndex = kDriverUniformsDescriptorSetIndex; options.driverUniformsDescriptorSetIndex = kDriverUniformsDescriptorSetIndex;
options.xfbBindingIndexStart = kXfbBindingIndexStart; options.xfbBindingIndexStart = kXfbBindingIndexStart;
options.useOldRewriteStructSamplers = features.forceOldRewriteStructSamplers.enabled;
options.supportsTransformFeedbackExtension =
features.supportsTransformFeedbackExtension.enabled;
options.emulateTransformFeedback = features.emulateTransformFeedback.enabled;
return options; return options;
} }
} // namespace } // namespace
...@@ -40,9 +44,7 @@ void GlslangWrapperVk::GetShaderSource(const angle::FeaturesVk &features, ...@@ -40,9 +44,7 @@ void GlslangWrapperVk::GetShaderSource(const angle::FeaturesVk &features,
const gl::ProgramLinkedResources &resources, const gl::ProgramLinkedResources &resources,
gl::ShaderMap<std::string> *shaderSourcesOut) gl::ShaderMap<std::string> *shaderSourcesOut)
{ {
GlslangGetShaderSource(CreateSourceOptions(), features.forceOldRewriteStructSamplers.enabled, GlslangGetShaderSource(CreateSourceOptions(features), programState, resources,
features.supportsTransformFeedbackExtension.enabled,
features.emulateTransformFeedback.enabled, programState, resources,
shaderSourcesOut); shaderSourcesOut);
} }
......
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