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
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
// varyings for later use.
void GenerateTransformFeedbackExtensionOutputs(const gl::ProgramState &programState,
......@@ -984,7 +984,6 @@ void AssignNonTextureBindings(const GlslangSourceOptions &options,
}
void AssignTextureBindings(const GlslangSourceOptions &options,
bool useOldRewriteStructSamplers,
const gl::ProgramState &programState,
gl::ShaderMap<IntermediateShaderSource> *shaderSources)
{
......@@ -998,7 +997,7 @@ void AssignTextureBindings(const GlslangSourceOptions &options,
{
const gl::LinkedUniform &samplerUniform = uniforms[uniformIndex];
if (!useOldRewriteStructSamplers &&
if (!options.useOldRewriteStructSamplers &&
gl::SamplerNameContainsNonZeroArrayElement(samplerUniform.name))
{
continue;
......@@ -1008,7 +1007,7 @@ void AssignTextureBindings(const GlslangSourceOptions &options,
texturesDescriptorSet + ", binding = " + Str(bindingIndex++);
// Samplers in structs are extracted and renamed.
const std::string samplerName = useOldRewriteStructSamplers
const std::string samplerName = options.useOldRewriteStructSamplers
? GetMappedSamplerNameOld(samplerUniform.name)
: GlslangGetMappedSamplerName(samplerUniform.name);
......@@ -1195,9 +1194,6 @@ std::string GlslangGetMappedSamplerName(const std::string &originalName)
}
void GlslangGetShaderSource(const GlslangSourceOptions &options,
bool useOldRewriteStructSamplers,
bool supportsTransformFeedbackExtension,
bool emulateTransformFeedback,
const gl::ProgramState &programState,
const gl::ProgramLinkedResources &resources,
gl::ShaderMap<std::string> *shaderSourcesOut)
......@@ -1229,12 +1225,12 @@ void GlslangGetShaderSource(const GlslangSourceOptions &options,
}
else
{
if (supportsTransformFeedbackExtension)
if (options.supportsTransformFeedbackExtension)
{
GenerateTransformFeedbackExtensionOutputs(programState, vertexSource, &xfbBufferMap,
resources);
}
else if (emulateTransformFeedback)
else if (options.emulateTransformFeedback)
{
GenerateTransformFeedbackEmulationOutputs(options, programState, vertexSource);
}
......@@ -1260,10 +1256,10 @@ void GlslangGetShaderSource(const GlslangSourceOptions &options,
}
AssignUniformBindings(options, &intermediateSources);
AssignTextureBindings(options, useOldRewriteStructSamplers, programState, &intermediateSources);
AssignTextureBindings(options, programState, &intermediateSources);
AssignNonTextureBindings(options, programState, &intermediateSources);
CleanupUnusedEntities(useOldRewriteStructSamplers, programState, resources,
CleanupUnusedEntities(options.useOldRewriteStructSamplers, programState, resources,
&intermediateSources);
for (const gl::ShaderType shaderType : gl::AllShaderTypes())
......
......@@ -33,6 +33,10 @@ struct GlslangSourceOptions
// Binding index start for transform feedback buffers:
uint32_t xfbBindingIndexStart = 16;
bool useOldRewriteStructSamplers = false;
bool supportsTransformFeedbackExtension = false;
bool emulateTransformFeedback = false;
};
using GlslangErrorCallback = std::function<angle::Result(GlslangError)>;
......@@ -46,9 +50,6 @@ std::string GlslangGetMappedSamplerName(const std::string &originalName);
// Transform the source to include actual binding points for various shader
// resources (textures, buffers, xfb, etc)
void GlslangGetShaderSource(const GlslangSourceOptions &options,
bool useOldRewriteStructSamplers,
bool supportsTransformFeedbackExtension,
bool emulateTransformFeedback,
const gl::ProgramState &programState,
const gl::ProgramLinkedResources &resources,
gl::ShaderMap<std::string> *shaderSourcesOut);
......
......@@ -45,8 +45,7 @@ void GlslangGetShaderSource(const gl::ProgramState &programState,
const gl::ProgramLinkedResources &resources,
gl::ShaderMap<std::string> *shaderSourcesOut)
{
rx::GlslangGetShaderSource(CreateSourceOptions(), false, false, false, programState, resources,
shaderSourcesOut);
rx::GlslangGetShaderSource(CreateSourceOptions(), programState, resources, shaderSourcesOut);
}
angle::Result GlslangGetShaderSpirvCode(ErrorHandler *context,
......
......@@ -22,7 +22,7 @@ angle::Result ErrorHandler(vk::Context *context, GlslangError)
return angle::Result::Stop;
}
GlslangSourceOptions CreateSourceOptions()
GlslangSourceOptions CreateSourceOptions(const angle::FeaturesVk &features)
{
GlslangSourceOptions options;
options.uniformsAndXfbDescriptorSetIndex = kUniformsAndXfbDescriptorSetIndex;
......@@ -30,6 +30,10 @@ GlslangSourceOptions CreateSourceOptions()
options.shaderResourceDescriptorSetIndex = kShaderResourceDescriptorSetIndex;
options.driverUniformsDescriptorSetIndex = kDriverUniformsDescriptorSetIndex;
options.xfbBindingIndexStart = kXfbBindingIndexStart;
options.useOldRewriteStructSamplers = features.forceOldRewriteStructSamplers.enabled;
options.supportsTransformFeedbackExtension =
features.supportsTransformFeedbackExtension.enabled;
options.emulateTransformFeedback = features.emulateTransformFeedback.enabled;
return options;
}
} // namespace
......@@ -40,9 +44,7 @@ void GlslangWrapperVk::GetShaderSource(const angle::FeaturesVk &features,
const gl::ProgramLinkedResources &resources,
gl::ShaderMap<std::string> *shaderSourcesOut)
{
GlslangGetShaderSource(CreateSourceOptions(), features.forceOldRewriteStructSamplers.enabled,
features.supportsTransformFeedbackExtension.enabled,
features.emulateTransformFeedback.enabled, programState, resources,
GlslangGetShaderSource(CreateSourceOptions(features), programState, resources,
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