Merge pull request #1209 from KhronosGroup/hlsl-auto-binding-cli
HLSL: Add CLI support for --hlsl-auto-binding.
This commit is contained in:
commit
c8221ca875
27
main.cpp
27
main.cpp
@ -552,6 +552,7 @@ struct CLIArguments
|
||||
bool hlsl = false;
|
||||
bool hlsl_compat = false;
|
||||
bool hlsl_support_nonzero_base = false;
|
||||
HLSLBindingFlags hlsl_binding_flags = 0;
|
||||
bool vulkan_semantics = false;
|
||||
bool flatten_multidimensional_arrays = false;
|
||||
bool use_420pack_extension = true;
|
||||
@ -614,6 +615,7 @@ static void print_help()
|
||||
"\t[--shader-model]\n"
|
||||
"\t[--hlsl-enable-compat]\n"
|
||||
"\t[--hlsl-support-nonzero-basevertex-baseinstance]\n"
|
||||
"\t[--hlsl-auto-binding (push, cbv, srv, uav, sampler, all)]\n"
|
||||
"\t[--separate-shader-objects]\n"
|
||||
"\t[--pls-in format input-name]\n"
|
||||
"\t[--pls-out format output-name]\n"
|
||||
@ -736,6 +738,27 @@ static ExecutionModel stage_to_execution_model(const std::string &stage)
|
||||
SPIRV_CROSS_THROW("Invalid stage.");
|
||||
}
|
||||
|
||||
static HLSLBindingFlags hlsl_resource_type_to_flag(const std::string &arg)
|
||||
{
|
||||
if (arg == "push")
|
||||
return HLSL_BINDING_AUTO_PUSH_CONSTANT_BIT;
|
||||
else if (arg == "cbv")
|
||||
return HLSL_BINDING_AUTO_CBV_BIT;
|
||||
else if (arg == "srv")
|
||||
return HLSL_BINDING_AUTO_SRV_BIT;
|
||||
else if (arg == "uav")
|
||||
return HLSL_BINDING_AUTO_UAV_BIT;
|
||||
else if (arg == "sampler")
|
||||
return HLSL_BINDING_AUTO_SAMPLER_BIT;
|
||||
else if (arg == "all")
|
||||
return HLSL_BINDING_AUTO_ALL;
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "Invalid resource type for --hlsl-auto-binding: %s\n", arg.c_str());
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static string compile_iteration(const CLIArguments &args, std::vector<uint32_t> spirv_file)
|
||||
{
|
||||
Parser spirv_parser(move(spirv_file));
|
||||
@ -939,6 +962,7 @@ static string compile_iteration(const CLIArguments &args, std::vector<uint32_t>
|
||||
|
||||
hlsl_opts.support_nonzero_base_vertex_base_instance = args.hlsl_support_nonzero_base;
|
||||
hlsl->set_hlsl_options(hlsl_opts);
|
||||
hlsl->set_resource_binding_flags(args.hlsl_binding_flags);
|
||||
}
|
||||
|
||||
if (build_dummy_sampler)
|
||||
@ -1089,6 +1113,9 @@ static int main_inner(int argc, char *argv[])
|
||||
cbs.add("--hlsl-enable-compat", [&args](CLIParser &) { args.hlsl_compat = true; });
|
||||
cbs.add("--hlsl-support-nonzero-basevertex-baseinstance",
|
||||
[&args](CLIParser &) { args.hlsl_support_nonzero_base = true; });
|
||||
cbs.add("--hlsl-auto-binding", [&args](CLIParser &parser) {
|
||||
args.hlsl_binding_flags |= hlsl_resource_type_to_flag(parser.next_string());
|
||||
});
|
||||
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; });
|
||||
|
@ -783,6 +783,7 @@ spvc_result spvc_compiler_hlsl_set_resource_binding_flags(spvc_compiler compiler
|
||||
hlsl.set_resource_binding_flags(flags);
|
||||
return SPVC_SUCCESS;
|
||||
#else
|
||||
(void)flags;
|
||||
compiler->context->report_error("HLSL function used on a non-HLSL backend.");
|
||||
return SPVC_ERROR_INVALID_ARGUMENT;
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user