mirror of
https://github.com/bkaradzic/bgfx.git
synced 2026-02-17 20:52:36 +01:00
Updated spirv-cross.
This commit is contained in:
committed by
Branimir Karadžić
parent
e55579ea69
commit
65a81c76c9
4
3rdparty/spirv-cross/main.cpp
vendored
4
3rdparty/spirv-cross/main.cpp
vendored
@@ -744,6 +744,7 @@ struct CLIArguments
|
||||
bool hlsl_enable_16bit_types = false;
|
||||
bool hlsl_flatten_matrix_vertex_input_semantics = false;
|
||||
bool hlsl_preserve_structured_buffers = false;
|
||||
bool hlsl_user_semantic = false;
|
||||
HLSLBindingFlags hlsl_binding_flags = 0;
|
||||
bool vulkan_semantics = false;
|
||||
bool flatten_multidimensional_arrays = false;
|
||||
@@ -852,6 +853,7 @@ static void print_help_hlsl()
|
||||
"\t[--hlsl-enable-16bit-types]:\n\t\tEnables native use of half/int16_t/uint16_t and ByteAddressBuffer interaction with these types. Requires SM 6.2.\n"
|
||||
"\t[--hlsl-flatten-matrix-vertex-input-semantics]:\n\t\tEmits matrix vertex inputs with input semantics as if they were independent vectors, e.g. TEXCOORD{2,3,4} rather than matrix form TEXCOORD2_{0,1,2}.\n"
|
||||
"\t[--hlsl-preserve-structured-buffers]:\n\t\tEmit SturucturedBuffer<T> rather than ByteAddressBuffer. Requires UserTypeGOOGLE to be emitted. Intended for DXC roundtrips.\n"
|
||||
"\t[--hlsl-user-semantic]:\n\t\tUses UserSemantic decoration to generate vertex input and output semantics.\n"
|
||||
);
|
||||
// clang-format on
|
||||
}
|
||||
@@ -1471,6 +1473,7 @@ static string compile_iteration(const CLIArguments &args, std::vector<uint32_t>
|
||||
hlsl_opts.enable_16bit_types = args.hlsl_enable_16bit_types;
|
||||
hlsl_opts.flatten_matrix_vertex_input_semantics = args.hlsl_flatten_matrix_vertex_input_semantics;
|
||||
hlsl_opts.preserve_structured_buffers = args.hlsl_preserve_structured_buffers;
|
||||
hlsl_opts.user_semantic = args.hlsl_user_semantic;
|
||||
hlsl->set_hlsl_options(hlsl_opts);
|
||||
hlsl->set_resource_binding_flags(args.hlsl_binding_flags);
|
||||
if (args.hlsl_base_vertex_index_explicit_binding)
|
||||
@@ -1673,6 +1676,7 @@ static int main_inner(int argc, char *argv[])
|
||||
cbs.add("--hlsl-flatten-matrix-vertex-input-semantics",
|
||||
[&args](CLIParser &) { args.hlsl_flatten_matrix_vertex_input_semantics = true; });
|
||||
cbs.add("--hlsl-preserve-structured-buffers", [&args](CLIParser &) { args.hlsl_preserve_structured_buffers = true; });
|
||||
cbs.add("--hlsl-user-semantic", [&args](CLIParser &) { args.hlsl_user_semantic = true; });
|
||||
cbs.add("--vulkan-semantics", [&args](CLIParser &) { args.vulkan_semantics = true; });
|
||||
cbs.add("-V", [&args](CLIParser &) { args.vulkan_semantics = true; });
|
||||
cbs.add("--flatten-multidimensional-arrays", [&args](CLIParser &) { args.flatten_multidimensional_arrays = true; });
|
||||
|
||||
4
3rdparty/spirv-cross/spirv_common.hpp
vendored
4
3rdparty/spirv-cross/spirv_common.hpp
vendored
@@ -1355,7 +1355,7 @@ struct SPIRConstant : IVariant
|
||||
|
||||
inline float scalar_bf8(uint32_t col = 0, uint32_t row = 0) const
|
||||
{
|
||||
return f16_to_f32(scalar_u8(col, row) << 8);
|
||||
return f16_to_f32(uint16_t(scalar_u8(col, row) << 8));
|
||||
}
|
||||
|
||||
inline float scalar_f32(uint32_t col = 0, uint32_t row = 0) const
|
||||
@@ -1790,7 +1790,7 @@ struct Meta
|
||||
{
|
||||
std::string alias;
|
||||
std::string qualified_alias;
|
||||
std::string hlsl_semantic;
|
||||
std::string user_semantic;
|
||||
std::string user_type;
|
||||
Bitset decoration_flags;
|
||||
spv::BuiltIn builtin_type = spv::BuiltInMax;
|
||||
|
||||
4
3rdparty/spirv-cross/spirv_cross_c.cpp
vendored
4
3rdparty/spirv-cross/spirv_cross_c.cpp
vendored
@@ -529,6 +529,10 @@ spvc_result spvc_compiler_options_set_uint(spvc_compiler_options options, spvc_c
|
||||
case SPVC_COMPILER_OPTION_HLSL_PRESERVE_STRUCTURED_BUFFERS:
|
||||
options->hlsl.preserve_structured_buffers = value != 0;
|
||||
break;
|
||||
|
||||
case SPVC_COMPILER_OPTION_HLSL_USER_SEMANTIC:
|
||||
options->hlsl.user_semantic = value != 0;
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if SPIRV_CROSS_C_API_MSL
|
||||
|
||||
4
3rdparty/spirv-cross/spirv_cross_c.h
vendored
4
3rdparty/spirv-cross/spirv_cross_c.h
vendored
@@ -40,7 +40,7 @@ extern "C" {
|
||||
/* Bumped if ABI or API breaks backwards compatibility. */
|
||||
#define SPVC_C_API_VERSION_MAJOR 0
|
||||
/* Bumped if APIs or enumerations are added in a backwards compatible way. */
|
||||
#define SPVC_C_API_VERSION_MINOR 67
|
||||
#define SPVC_C_API_VERSION_MINOR 68
|
||||
/* Bumped if internal implementation details change. */
|
||||
#define SPVC_C_API_VERSION_PATCH 0
|
||||
|
||||
@@ -753,6 +753,8 @@ typedef enum spvc_compiler_option
|
||||
|
||||
SPVC_COMPILER_OPTION_MSL_ENABLE_POINT_SIZE_DEFAULT = 93 | SPVC_COMPILER_OPTION_MSL_BIT,
|
||||
|
||||
SPVC_COMPILER_OPTION_HLSL_USER_SEMANTIC = 94 | SPVC_COMPILER_OPTION_HLSL_BIT,
|
||||
|
||||
SPVC_COMPILER_OPTION_INT_MAX = 0x7fffffff
|
||||
} spvc_compiler_option;
|
||||
|
||||
|
||||
24
3rdparty/spirv-cross/spirv_cross_parsed_ir.cpp
vendored
24
3rdparty/spirv-cross/spirv_cross_parsed_ir.cpp
vendored
@@ -366,8 +366,8 @@ void ParsedIR::set_decoration_string(ID id, Decoration decoration, const string
|
||||
|
||||
switch (decoration)
|
||||
{
|
||||
case DecorationHlslSemanticGOOGLE:
|
||||
dec.hlsl_semantic = argument;
|
||||
case DecorationUserSemantic:
|
||||
dec.user_semantic = argument;
|
||||
break;
|
||||
|
||||
case DecorationUserTypeGOOGLE:
|
||||
@@ -686,8 +686,8 @@ const string &ParsedIR::get_decoration_string(ID id, Decoration decoration) cons
|
||||
|
||||
switch (decoration)
|
||||
{
|
||||
case DecorationHlslSemanticGOOGLE:
|
||||
return dec.hlsl_semantic;
|
||||
case DecorationUserSemantic:
|
||||
return dec.user_semantic;
|
||||
|
||||
case DecorationUserTypeGOOGLE:
|
||||
return dec.user_type;
|
||||
@@ -747,8 +747,8 @@ void ParsedIR::unset_decoration(ID id, Decoration decoration)
|
||||
dec.spec_id = 0;
|
||||
break;
|
||||
|
||||
case DecorationHlslSemanticGOOGLE:
|
||||
dec.hlsl_semantic.clear();
|
||||
case DecorationUserSemantic:
|
||||
dec.user_semantic.clear();
|
||||
break;
|
||||
|
||||
case DecorationFPRoundingMode:
|
||||
@@ -843,8 +843,8 @@ void ParsedIR::set_member_decoration_string(TypeID id, uint32_t index, Decoratio
|
||||
|
||||
switch (decoration)
|
||||
{
|
||||
case DecorationHlslSemanticGOOGLE:
|
||||
dec.hlsl_semantic = argument;
|
||||
case DecorationUserSemantic:
|
||||
dec.user_semantic = argument;
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -864,8 +864,8 @@ const string &ParsedIR::get_member_decoration_string(TypeID id, uint32_t index,
|
||||
|
||||
switch (decoration)
|
||||
{
|
||||
case DecorationHlslSemanticGOOGLE:
|
||||
return dec.hlsl_semantic;
|
||||
case DecorationUserSemantic:
|
||||
return dec.user_semantic;
|
||||
|
||||
default:
|
||||
return empty_string;
|
||||
@@ -918,8 +918,8 @@ void ParsedIR::unset_member_decoration(TypeID id, uint32_t index, Decoration dec
|
||||
dec.spec_id = 0;
|
||||
break;
|
||||
|
||||
case DecorationHlslSemanticGOOGLE:
|
||||
dec.hlsl_semantic.clear();
|
||||
case DecorationUserSemantic:
|
||||
dec.user_semantic.clear();
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
29
3rdparty/spirv-cross/spirv_hlsl.cpp
vendored
29
3rdparty/spirv-cross/spirv_hlsl.cpp
vendored
@@ -1021,7 +1021,13 @@ void CompilerHLSL::emit_interface_block_member_in_struct(const SPIRVariable &var
|
||||
{
|
||||
auto &execution = get_entry_point();
|
||||
auto type = get<SPIRType>(var.basetype);
|
||||
auto semantic = to_semantic(location, execution.model, var.storage);
|
||||
|
||||
std::string semantic;
|
||||
if (hlsl_options.user_semantic && has_member_decoration(var.self, member_index, DecorationUserSemantic))
|
||||
semantic = get_member_decoration_string(var.self, member_index, DecorationUserSemantic);
|
||||
else
|
||||
semantic = to_semantic(location, execution.model, var.storage);
|
||||
|
||||
auto mbr_name = join(to_name(type.self), "_", to_member_name(type, member_index));
|
||||
auto &mbr_type = get<SPIRType>(type.member_types[member_index]);
|
||||
|
||||
@@ -1080,8 +1086,18 @@ void CompilerHLSL::emit_interface_block_in_struct(const SPIRVariable &var, unord
|
||||
auto name = to_name(var.self);
|
||||
if (use_location_number)
|
||||
{
|
||||
uint32_t location_number;
|
||||
uint32_t location_number = UINT32_MAX;
|
||||
|
||||
std::string semantic;
|
||||
bool has_user_semantic = false;
|
||||
|
||||
if (hlsl_options.user_semantic && has_decoration(var.self, DecorationUserSemantic))
|
||||
{
|
||||
semantic = get_decoration_string(var.self, DecorationUserSemantic);
|
||||
has_user_semantic = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// If an explicit location exists, use it with TEXCOORD[N] semantic.
|
||||
// Otherwise, pick a vacant location.
|
||||
if (has_decoration(var.self, DecorationLocation))
|
||||
@@ -1090,7 +1106,8 @@ void CompilerHLSL::emit_interface_block_in_struct(const SPIRVariable &var, unord
|
||||
location_number = get_vacant_location();
|
||||
|
||||
// Allow semantic remap if specified.
|
||||
auto semantic = to_semantic(location_number, execution.model, var.storage);
|
||||
semantic = to_semantic(location_number, execution.model, var.storage);
|
||||
}
|
||||
|
||||
if (need_matrix_unroll && type.columns > 1)
|
||||
{
|
||||
@@ -1104,13 +1121,14 @@ void CompilerHLSL::emit_interface_block_in_struct(const SPIRVariable &var, unord
|
||||
newtype.columns = 1;
|
||||
|
||||
string effective_semantic;
|
||||
if (hlsl_options.flatten_matrix_vertex_input_semantics)
|
||||
if (hlsl_options.flatten_matrix_vertex_input_semantics && !has_user_semantic)
|
||||
effective_semantic = to_semantic(location_number, execution.model, var.storage);
|
||||
else
|
||||
effective_semantic = join(semantic, "_", i);
|
||||
|
||||
statement(to_interpolation_qualifiers(get_decoration_bitset(var.self)),
|
||||
variable_decl(newtype, join(name, "_", i)), " : ", effective_semantic, ";");
|
||||
if (location_number != UINT32_MAX)
|
||||
active_locations.insert(location_number++);
|
||||
}
|
||||
}
|
||||
@@ -1127,12 +1145,15 @@ void CompilerHLSL::emit_interface_block_in_struct(const SPIRVariable &var, unord
|
||||
statement(to_interpolation_qualifiers(get_decoration_bitset(var.self)), variable_decl(decl_type, name), " : ",
|
||||
semantic, ";");
|
||||
|
||||
if (location_number != UINT32_MAX)
|
||||
{
|
||||
// Structs and arrays should consume more locations.
|
||||
uint32_t consumed_locations = type_to_consumed_locations(decl_type);
|
||||
for (uint32_t i = 0; i < consumed_locations; i++)
|
||||
active_locations.insert(location_number + i);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
statement(variable_decl(type, name), " : ", binding, ";");
|
||||
|
||||
3
3rdparty/spirv-cross/spirv_hlsl.hpp
vendored
3
3rdparty/spirv-cross/spirv_hlsl.hpp
vendored
@@ -151,6 +151,9 @@ public:
|
||||
// This relies on UserTypeGOOGLE to encode the buffer type either as "structuredbuffer" or "rwstructuredbuffer"
|
||||
// whereas the type can be extended with an optional subtype, e.g. "structuredbuffer:int".
|
||||
bool preserve_structured_buffers = false;
|
||||
|
||||
// Use UserSemantic decoration info (if specified), otherwise use default mechanism (such as add_vertex_attribute_remap or TEXCOORD#).
|
||||
bool user_semantic = false;
|
||||
};
|
||||
|
||||
explicit CompilerHLSL(std::vector<uint32_t> spirv_)
|
||||
|
||||
2
3rdparty/spirv-cross/spirv_parser.cpp
vendored
2
3rdparty/spirv-cross/spirv_parser.cpp
vendored
@@ -43,7 +43,7 @@ static bool decoration_is_string(Decoration decoration)
|
||||
{
|
||||
switch (decoration)
|
||||
{
|
||||
case DecorationHlslSemanticGOOGLE:
|
||||
case DecorationUserSemantic:
|
||||
return true;
|
||||
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user