Add support to remove SPIRV_Cross_BaseInstance uniform.
This commit is contained in:
parent
809631ce21
commit
b29629fd46
8
main.cpp
8
main.cpp
@ -478,6 +478,7 @@ struct CLIArguments
|
||||
bool fixup = false;
|
||||
bool yflip = false;
|
||||
bool sso = false;
|
||||
bool support_nonzero_baseinstance = true;
|
||||
vector<PLSArg> pls_in;
|
||||
vector<PLSArg> pls_out;
|
||||
vector<Remap> remaps;
|
||||
@ -530,6 +531,7 @@ static void print_help()
|
||||
"\t[--msl]\n"
|
||||
"\t[--msl-version <MMmmpp>]\n"
|
||||
"\t[--hlsl]\n"
|
||||
"\t[--reflect]\n"
|
||||
"\t[--shader-model]\n"
|
||||
"\t[--hlsl-enable-compat]\n"
|
||||
"\t[--separate-shader-objects]\n"
|
||||
@ -546,7 +548,8 @@ static void print_help()
|
||||
"\t[--rename-interface-variable <in|out> <location> <new_variable_name>]\n"
|
||||
"\t[--set-hlsl-vertex-input-semantic <location> <semantic>]\n"
|
||||
"\t[--rename-entry-point <old> <new> <stage>]\n"
|
||||
"\t[--combined-samplers-inherit-bindings]"
|
||||
"\t[--combined-samplers-inherit-bindings]\n"
|
||||
"\t[--no-support-nonzero-baseinstance]\n"
|
||||
"\n");
|
||||
}
|
||||
|
||||
@ -756,6 +759,8 @@ static int main_inner(int argc, char *argv[])
|
||||
cbs.add("--combined-samplers-inherit-bindings",
|
||||
[&args](CLIParser &) { args.combined_samplers_inherit_bindings = true; });
|
||||
|
||||
cbs.add("--no-support-nonzero-baseinstance", [&](CLIParser &) { args.support_nonzero_baseinstance = false; });
|
||||
|
||||
cbs.default_handler = [&args](const char *value) { args.input = value; };
|
||||
cbs.error_handler = [] { print_help(); };
|
||||
|
||||
@ -926,6 +931,7 @@ static int main_inner(int argc, char *argv[])
|
||||
opts.vulkan_semantics = args.vulkan_semantics;
|
||||
opts.vertex.fixup_clipspace = args.fixup;
|
||||
opts.vertex.flip_vert_y = args.yflip;
|
||||
opts.vertex.support_nonzero_base_instance = args.support_nonzero_baseinstance;
|
||||
compiler->set_common_options(opts);
|
||||
|
||||
// Set HLSL specific options.
|
||||
|
@ -2201,7 +2201,8 @@ void CompilerGLSL::emit_resources()
|
||||
{
|
||||
// For gl_InstanceIndex emulation on GLES, the API user needs to
|
||||
// supply this uniform.
|
||||
if (meta[var.self].decoration.builtin_type == BuiltInInstanceIndex && !options.vulkan_semantics)
|
||||
if (options.vertex.support_nonzero_base_instance &&
|
||||
meta[var.self].decoration.builtin_type == BuiltInInstanceIndex && !options.vulkan_semantics)
|
||||
{
|
||||
statement("uniform int SPIRV_Cross_BaseInstance;");
|
||||
emitted = true;
|
||||
@ -4916,8 +4917,10 @@ string CompilerGLSL::builtin_to_glsl(BuiltIn builtin, StorageClass storage)
|
||||
case BuiltInInstanceIndex:
|
||||
if (options.vulkan_semantics)
|
||||
return "gl_InstanceIndex";
|
||||
else
|
||||
else if (options.vertex.support_nonzero_base_instance)
|
||||
return "(gl_InstanceID + SPIRV_Cross_BaseInstance)"; // ... but not gl_InstanceID.
|
||||
else
|
||||
return "gl_InstanceID";
|
||||
case BuiltInPrimitiveId:
|
||||
return "gl_PrimitiveID";
|
||||
case BuiltInInvocationId:
|
||||
|
@ -105,6 +105,11 @@ public:
|
||||
|
||||
// Inverts gl_Position.y or equivalent.
|
||||
bool flip_vert_y = false;
|
||||
|
||||
// If true, the backend will assume that InstanceIndex will need to apply
|
||||
// a base instance offset. Set to false if you know you will never use base instance
|
||||
// functionality as it might remove some internal uniforms.
|
||||
bool support_nonzero_base_instance = true;
|
||||
} vertex;
|
||||
|
||||
struct
|
||||
|
Loading…
Reference in New Issue
Block a user