Add option to disable use of 420pack extension.
This commit is contained in:
parent
824d0ad8e7
commit
6599a41aad
5
main.cpp
5
main.cpp
@ -472,6 +472,7 @@ struct CLIArguments
|
||||
bool hlsl_compat = false;
|
||||
bool vulkan_semantics = false;
|
||||
bool flatten_multidimensional_arrays = false;
|
||||
bool use_420pack_extension = true;
|
||||
bool remove_unused = false;
|
||||
bool cfg_analysis = true;
|
||||
};
|
||||
@ -487,7 +488,7 @@ static void print_help()
|
||||
"[--separate-shader-objects]"
|
||||
"[--pls-in format input-name] [--pls-out format output-name] [--remap source_name target_name "
|
||||
"components] [--extension ext] [--entry name] [--remove-unused-variables] "
|
||||
"[--flatten-multidimensional-arrays] "
|
||||
"[--flatten-multidimensional-arrays] [--no-420pack-extension] "
|
||||
"[--remap-variable-type <variable_name> <new_variable_type>] "
|
||||
"[--rename-interface-variable <in|out> <location> <new_variable_name>] "
|
||||
"\n");
|
||||
@ -630,6 +631,7 @@ int main(int argc, char *argv[])
|
||||
cbs.add("--hlsl-enable-compat", [&args](CLIParser &) { args.hlsl_compat = true; });
|
||||
cbs.add("--vulkan-semantics", [&args](CLIParser &) { args.vulkan_semantics = true; });
|
||||
cbs.add("--flatten-multidimensional-arrays", [&args](CLIParser &) { args.flatten_multidimensional_arrays = true; });
|
||||
cbs.add("--no-420pack-extension", [&args](CLIParser &) { args.use_420pack_extension = false; });
|
||||
cbs.add("--extension", [&args](CLIParser &parser) { args.extensions.push_back(parser.next_string()); });
|
||||
cbs.add("--entry", [&args](CLIParser &parser) { args.entry = parser.next_string(); });
|
||||
cbs.add("--separate-shader-objects", [&args](CLIParser &) { args.sso = true; });
|
||||
@ -751,6 +753,7 @@ int main(int argc, char *argv[])
|
||||
opts.force_temporary = args.force_temporary;
|
||||
opts.separate_shader_objects = args.sso;
|
||||
opts.flatten_multidimensional_arrays = args.flatten_multidimensional_arrays;
|
||||
opts.enable_420pack_extension = args.use_420pack_extension;
|
||||
opts.vulkan_semantics = args.vulkan_semantics;
|
||||
opts.vertex.fixup_clipspace = args.fixup;
|
||||
opts.vertex.flip_vert_y = args.yflip;
|
||||
|
@ -349,7 +349,7 @@ void CompilerGLSL::emit_header()
|
||||
statement("#version ", options.version, options.es && options.version > 100 ? " es" : "");
|
||||
|
||||
// Needed for binding = # on UBOs, etc.
|
||||
if (!options.es && options.version < 420)
|
||||
if (!options.es && options.version < 420 && options.enable_420pack_extension)
|
||||
{
|
||||
statement("#ifdef GL_ARB_shading_language_420pack");
|
||||
statement("#extension GL_ARB_shading_language_420pack : require");
|
||||
@ -999,8 +999,15 @@ string CompilerGLSL::layout_for_variable(const SPIRVariable &var)
|
||||
attr.push_back(join("set = ", dec.set));
|
||||
}
|
||||
|
||||
if (flags & (1ull << DecorationBinding))
|
||||
bool can_use_binding;
|
||||
if (options.es)
|
||||
can_use_binding = options.version >= 310;
|
||||
else
|
||||
can_use_binding = options.enable_420pack_extension || (options.version >= 420);
|
||||
|
||||
if (can_use_binding && (flags & (1ull << DecorationBinding)))
|
||||
attr.push_back(join("binding = ", dec.binding));
|
||||
|
||||
if (flags & (1ull << DecorationOffset))
|
||||
attr.push_back(join("offset = ", dec.offset));
|
||||
|
||||
|
@ -56,8 +56,13 @@ class CompilerGLSL : public Compiler
|
||||
public:
|
||||
struct Options
|
||||
{
|
||||
// The shading language version. Corresponds to #version $VALUE.
|
||||
uint32_t version = 450;
|
||||
|
||||
// Emit the OpenGL ES shading language instead of desktop OpenGL.
|
||||
bool es = false;
|
||||
|
||||
// Debug option to always emit temporary variables for all expressions.
|
||||
bool force_temporary = false;
|
||||
|
||||
// If true, variables will be moved to their appropriate scope through CFG analysis.
|
||||
@ -79,6 +84,12 @@ public:
|
||||
// Only the generated code, including declarations of interface variables are changed to be single array dimension.
|
||||
bool flatten_multidimensional_arrays = false;
|
||||
|
||||
// For older desktop GLSL targets than version 420, the
|
||||
// GL_ARB_shading_language_420pack extensions is used to be able to support
|
||||
// layout(binding) on UBOs and samplers.
|
||||
// If disabled on older targets, binding decorations will be stripped.
|
||||
bool enable_420pack_extension = true;
|
||||
|
||||
enum Precision
|
||||
{
|
||||
DontCare,
|
||||
|
Loading…
Reference in New Issue
Block a user