Run format_all.sh.
This commit is contained in:
parent
de26e08195
commit
3ccfbce264
@ -937,7 +937,8 @@ struct SPIRConstant : IVariant
|
||||
type = TypeConstant
|
||||
};
|
||||
|
||||
union Constant {
|
||||
union Constant
|
||||
{
|
||||
uint32_t u32;
|
||||
int32_t i32;
|
||||
float f32;
|
||||
@ -985,7 +986,8 @@ struct SPIRConstant : IVariant
|
||||
int e = (u16_value >> 10) & 0x1f;
|
||||
int m = (u16_value >> 0) & 0x3ff;
|
||||
|
||||
union {
|
||||
union
|
||||
{
|
||||
float f32;
|
||||
uint32_t u32;
|
||||
} u;
|
||||
|
@ -2151,8 +2151,10 @@ bool Compiler::CombinedImageSamplerHandler::end_function_scope(const uint32_t *a
|
||||
return true;
|
||||
}
|
||||
|
||||
void Compiler::CombinedImageSamplerHandler::register_combined_image_sampler(SPIRFunction &caller, uint32_t combined_module_id,
|
||||
uint32_t image_id, uint32_t sampler_id, bool depth)
|
||||
void Compiler::CombinedImageSamplerHandler::register_combined_image_sampler(SPIRFunction &caller,
|
||||
uint32_t combined_module_id,
|
||||
uint32_t image_id, uint32_t sampler_id,
|
||||
bool depth)
|
||||
{
|
||||
// We now have a texture ID and a sampler ID which will either be found as a global
|
||||
// or a parameter in our own function. If both are global, they will not need a parameter,
|
||||
@ -2215,9 +2217,9 @@ void Compiler::CombinedImageSamplerHandler::register_combined_image_sampler(SPIR
|
||||
// Inherit RelaxedPrecision.
|
||||
// If any of OpSampledImage, underlying image or sampler are marked, inherit the decoration.
|
||||
bool relaxed_precision =
|
||||
compiler.has_decoration(sampler_id, DecorationRelaxedPrecision) ||
|
||||
compiler.has_decoration(image_id, DecorationRelaxedPrecision) ||
|
||||
(combined_module_id && compiler.has_decoration(combined_module_id, DecorationRelaxedPrecision));
|
||||
compiler.has_decoration(sampler_id, DecorationRelaxedPrecision) ||
|
||||
compiler.has_decoration(image_id, DecorationRelaxedPrecision) ||
|
||||
(combined_module_id && compiler.has_decoration(combined_module_id, DecorationRelaxedPrecision));
|
||||
|
||||
if (relaxed_precision)
|
||||
compiler.set_decoration(combined_id, DecorationRelaxedPrecision);
|
||||
@ -2486,9 +2488,9 @@ bool Compiler::CombinedImageSamplerHandler::handle(Op opcode, const uint32_t *ar
|
||||
// Inherit RelaxedPrecision (and potentially other useful flags if deemed relevant).
|
||||
// If any of OpSampledImage, underlying image or sampler are marked, inherit the decoration.
|
||||
bool relaxed_precision =
|
||||
(sampler_id && compiler.has_decoration(sampler_id, DecorationRelaxedPrecision)) ||
|
||||
(image_id && compiler.has_decoration(image_id, DecorationRelaxedPrecision)) ||
|
||||
(combined_module_id && compiler.has_decoration(combined_module_id, DecorationRelaxedPrecision));
|
||||
(sampler_id && compiler.has_decoration(sampler_id, DecorationRelaxedPrecision)) ||
|
||||
(image_id && compiler.has_decoration(image_id, DecorationRelaxedPrecision)) ||
|
||||
(combined_module_id && compiler.has_decoration(combined_module_id, DecorationRelaxedPrecision));
|
||||
|
||||
if (relaxed_precision)
|
||||
compiler.set_decoration(combined_id, DecorationRelaxedPrecision);
|
||||
|
@ -772,8 +772,8 @@ protected:
|
||||
uint32_t remap_parameter(uint32_t id);
|
||||
void push_remap_parameters(const SPIRFunction &func, const uint32_t *args, uint32_t length);
|
||||
void pop_remap_parameters();
|
||||
void register_combined_image_sampler(SPIRFunction &caller, uint32_t combined_id, uint32_t texture_id, uint32_t sampler_id,
|
||||
bool depth);
|
||||
void register_combined_image_sampler(SPIRFunction &caller, uint32_t combined_id, uint32_t texture_id,
|
||||
uint32_t sampler_id, bool depth);
|
||||
};
|
||||
|
||||
struct DummySamplerForCombinedImageHandler : OpcodeHandler
|
||||
|
@ -61,7 +61,8 @@ public:
|
||||
private:
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1900
|
||||
// MSVC 2013 workarounds, sigh ...
|
||||
union {
|
||||
union
|
||||
{
|
||||
char aligned_char[sizeof(T) * N];
|
||||
double dummy_aligner;
|
||||
} u;
|
||||
|
@ -4230,8 +4230,7 @@ void CompilerGLSL::emit_unary_func_op_cast(uint32_t result_type, uint32_t result
|
||||
void CompilerGLSL::emit_trinary_func_op_bitextract(uint32_t result_type, uint32_t result_id, uint32_t op0, uint32_t op1,
|
||||
uint32_t op2, const char *op,
|
||||
SPIRType::BaseType expected_result_type,
|
||||
SPIRType::BaseType input_type0,
|
||||
SPIRType::BaseType input_type1,
|
||||
SPIRType::BaseType input_type0, SPIRType::BaseType input_type1,
|
||||
SPIRType::BaseType input_type2)
|
||||
{
|
||||
auto &out_type = get<SPIRType>(result_type);
|
||||
@ -4239,7 +4238,7 @@ void CompilerGLSL::emit_trinary_func_op_bitextract(uint32_t result_type, uint32_
|
||||
expected_type.basetype = input_type0;
|
||||
|
||||
string cast_op0 =
|
||||
expression_type(op0).basetype != input_type0 ? bitcast_glsl(expected_type, op0) : to_unpacked_expression(op0);
|
||||
expression_type(op0).basetype != input_type0 ? bitcast_glsl(expected_type, op0) : to_unpacked_expression(op0);
|
||||
|
||||
auto op1_expr = to_unpacked_expression(op1);
|
||||
auto op2_expr = to_unpacked_expression(op2);
|
||||
@ -4247,13 +4246,15 @@ void CompilerGLSL::emit_trinary_func_op_bitextract(uint32_t result_type, uint32_
|
||||
// Use value casts here instead. Input must be exactly int or uint, but SPIR-V might be 16-bit.
|
||||
expected_type.basetype = input_type1;
|
||||
expected_type.vecsize = 1;
|
||||
string cast_op1 =
|
||||
expression_type(op1).basetype != input_type1 ? join(type_to_glsl_constructor(expected_type), "(", op1_expr, ")") : op1_expr;
|
||||
string cast_op1 = expression_type(op1).basetype != input_type1 ?
|
||||
join(type_to_glsl_constructor(expected_type), "(", op1_expr, ")") :
|
||||
op1_expr;
|
||||
|
||||
expected_type.basetype = input_type2;
|
||||
expected_type.vecsize = 1;
|
||||
string cast_op2 =
|
||||
expression_type(op2).basetype != input_type2 ? join(type_to_glsl_constructor(expected_type), "(", op2_expr, ")") : op2_expr;
|
||||
string cast_op2 = expression_type(op2).basetype != input_type2 ?
|
||||
join(type_to_glsl_constructor(expected_type), "(", op2_expr, ")") :
|
||||
op2_expr;
|
||||
|
||||
string expr;
|
||||
if (out_type.basetype != expected_result_type)
|
||||
@ -4370,8 +4371,7 @@ void CompilerGLSL::emit_bitfield_insert_op(uint32_t result_type, uint32_t result
|
||||
{
|
||||
// Only need to cast offset/count arguments. Types of base/insert must be same as result type,
|
||||
// and bitfieldInsert is sign invariant.
|
||||
bool forward = should_forward(op0) && should_forward(op1) &&
|
||||
should_forward(op2) && should_forward(op3);
|
||||
bool forward = should_forward(op0) && should_forward(op1) && should_forward(op2) && should_forward(op3);
|
||||
|
||||
auto op0_expr = to_unpacked_expression(op0);
|
||||
auto op1_expr = to_unpacked_expression(op1);
|
||||
@ -4394,8 +4394,7 @@ void CompilerGLSL::emit_bitfield_insert_op(uint32_t result_type, uint32_t result
|
||||
op3_expr = join(type_to_glsl_constructor(target_type), "(", op3_expr, ")");
|
||||
}
|
||||
|
||||
emit_op(result_type, result_id,
|
||||
join(op, "(", op0_expr, ", ", op1_expr, ", ", op2_expr, ", ", op3_expr, ")"),
|
||||
emit_op(result_type, result_id, join(op, "(", op0_expr, ", ", op1_expr, ", ", op2_expr, ", ", op3_expr, ")"),
|
||||
forward);
|
||||
|
||||
inherit_expression_dependencies(result_id, op0);
|
||||
@ -9098,23 +9097,20 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction)
|
||||
// Bitfield
|
||||
case OpBitFieldInsert:
|
||||
{
|
||||
emit_bitfield_insert_op(ops[0], ops[1], ops[2], ops[3], ops[4], ops[5],
|
||||
"bitfieldInsert", SPIRType::Int);
|
||||
emit_bitfield_insert_op(ops[0], ops[1], ops[2], ops[3], ops[4], ops[5], "bitfieldInsert", SPIRType::Int);
|
||||
break;
|
||||
}
|
||||
|
||||
case OpBitFieldSExtract:
|
||||
{
|
||||
emit_trinary_func_op_bitextract(ops[0], ops[1], ops[2], ops[3], ops[4], "bitfieldExtract",
|
||||
int_type, int_type,
|
||||
emit_trinary_func_op_bitextract(ops[0], ops[1], ops[2], ops[3], ops[4], "bitfieldExtract", int_type, int_type,
|
||||
SPIRType::Int, SPIRType::Int);
|
||||
break;
|
||||
}
|
||||
|
||||
case OpBitFieldUExtract:
|
||||
{
|
||||
emit_trinary_func_op_bitextract(ops[0], ops[1], ops[2], ops[3], ops[4], "bitfieldExtract",
|
||||
uint_type, uint_type,
|
||||
emit_trinary_func_op_bitextract(ops[0], ops[1], ops[2], ops[3], ops[4], "bitfieldExtract", uint_type, uint_type,
|
||||
SPIRType::Int, SPIRType::Int);
|
||||
break;
|
||||
}
|
||||
@ -12238,8 +12234,8 @@ void CompilerGLSL::emit_block_chain(SPIRBlock &block)
|
||||
// The backend is responsible for setting this up, and redirection the return values as appropriate.
|
||||
if (ir.ids[block.return_value].get_type() != TypeUndef)
|
||||
{
|
||||
emit_array_copy("SPIRV_Cross_return_value", block.return_value,
|
||||
StorageClassFunction, get_backing_variable_storage(block.return_value));
|
||||
emit_array_copy("SPIRV_Cross_return_value", block.return_value, StorageClassFunction,
|
||||
get_backing_variable_storage(block.return_value));
|
||||
}
|
||||
|
||||
if (!cfg.node_terminates_control_flow_in_sub_graph(current_function->entry_block, block.self) ||
|
||||
|
@ -458,16 +458,12 @@ protected:
|
||||
SPIRType::BaseType input_type, bool skip_cast_if_equal_type);
|
||||
void emit_trinary_func_op_cast(uint32_t result_type, uint32_t result_id, uint32_t op0, uint32_t op1, uint32_t op2,
|
||||
const char *op, SPIRType::BaseType input_type);
|
||||
void emit_trinary_func_op_bitextract(uint32_t result_type, uint32_t result_id, uint32_t op0, uint32_t op1, uint32_t op2,
|
||||
const char *op,
|
||||
SPIRType::BaseType expected_result_type,
|
||||
SPIRType::BaseType input_type0,
|
||||
SPIRType::BaseType input_type1,
|
||||
void emit_trinary_func_op_bitextract(uint32_t result_type, uint32_t result_id, uint32_t op0, uint32_t op1,
|
||||
uint32_t op2, const char *op, SPIRType::BaseType expected_result_type,
|
||||
SPIRType::BaseType input_type0, SPIRType::BaseType input_type1,
|
||||
SPIRType::BaseType input_type2);
|
||||
void emit_bitfield_insert_op(uint32_t result_type, uint32_t result_id,
|
||||
uint32_t op0, uint32_t op1, uint32_t op2, uint32_t op3,
|
||||
const char *op,
|
||||
SPIRType::BaseType offset_count_type);
|
||||
void emit_bitfield_insert_op(uint32_t result_type, uint32_t result_id, uint32_t op0, uint32_t op1, uint32_t op2,
|
||||
uint32_t op3, const char *op, SPIRType::BaseType offset_count_type);
|
||||
|
||||
void emit_unary_func_op(uint32_t result_type, uint32_t result_id, uint32_t op0, const char *op);
|
||||
void emit_unrolled_unary_op(uint32_t result_type, uint32_t result_id, uint32_t operand, const char *op);
|
||||
@ -546,8 +542,8 @@ protected:
|
||||
std::string layout_for_variable(const SPIRVariable &variable);
|
||||
std::string to_combined_image_sampler(uint32_t image_id, uint32_t samp_id);
|
||||
virtual bool skip_argument(uint32_t id) const;
|
||||
virtual void emit_array_copy(const std::string &lhs, uint32_t rhs_id,
|
||||
spv::StorageClass lhs_storage, spv::StorageClass rhs_storage);
|
||||
virtual void emit_array_copy(const std::string &lhs, uint32_t rhs_id, spv::StorageClass lhs_storage,
|
||||
spv::StorageClass rhs_storage);
|
||||
virtual void emit_block_hints(const SPIRBlock &block);
|
||||
virtual std::string to_initializer_expression(const SPIRVariable &var);
|
||||
|
||||
|
@ -3193,30 +3193,16 @@ void CompilerMSL::emit_custom_functions()
|
||||
{
|
||||
// Unfortunately we cannot template on the address space, so combinatorial explosion it is.
|
||||
static const char *function_name_tags[] = {
|
||||
"FromConstantToStack",
|
||||
"FromConstantToThreadGroup",
|
||||
"FromStackToStack",
|
||||
"FromStackToThreadGroup",
|
||||
"FromThreadGroupToStack",
|
||||
"FromThreadGroupToThreadGroup",
|
||||
"FromConstantToStack", "FromConstantToThreadGroup", "FromStackToStack",
|
||||
"FromStackToThreadGroup", "FromThreadGroupToStack", "FromThreadGroupToThreadGroup",
|
||||
};
|
||||
|
||||
static const char *src_address_space[] = {
|
||||
"constant",
|
||||
"constant",
|
||||
"thread const",
|
||||
"thread const",
|
||||
"threadgroup const",
|
||||
"threadgroup const",
|
||||
"constant", "constant", "thread const", "thread const", "threadgroup const", "threadgroup const",
|
||||
};
|
||||
|
||||
static const char *dst_address_space[] = {
|
||||
"thread",
|
||||
"threadgroup",
|
||||
"thread",
|
||||
"threadgroup",
|
||||
"thread",
|
||||
"threadgroup",
|
||||
"thread", "threadgroup", "thread", "threadgroup", "thread", "threadgroup",
|
||||
};
|
||||
|
||||
for (uint32_t variant = 0; variant < 6; variant++)
|
||||
@ -3240,9 +3226,7 @@ void CompilerMSL::emit_custom_functions()
|
||||
}
|
||||
|
||||
statement("void spvArrayCopy", function_name_tags[variant], dimensions, "(", dst_address_space[variant],
|
||||
" T (&dst)",
|
||||
array_arg,
|
||||
", ", src_address_space[variant], " T (&src)", array_arg, ")");
|
||||
" T (&dst)", array_arg, ", ", src_address_space[variant], " T (&src)", array_arg, ")");
|
||||
|
||||
begin_scope();
|
||||
statement("for (uint i = 0; i < A; i++)");
|
||||
@ -4238,23 +4222,20 @@ void CompilerMSL::emit_instruction(const Instruction &instruction)
|
||||
// Bitfield
|
||||
case OpBitFieldInsert:
|
||||
{
|
||||
emit_bitfield_insert_op(ops[0], ops[1], ops[2], ops[3], ops[4], ops[5],
|
||||
"insert_bits", SPIRType::UInt);
|
||||
emit_bitfield_insert_op(ops[0], ops[1], ops[2], ops[3], ops[4], ops[5], "insert_bits", SPIRType::UInt);
|
||||
break;
|
||||
}
|
||||
|
||||
case OpBitFieldSExtract:
|
||||
{
|
||||
emit_trinary_func_op_bitextract(ops[0], ops[1], ops[2], ops[3], ops[4], "extract_bits",
|
||||
int_type, int_type,
|
||||
emit_trinary_func_op_bitextract(ops[0], ops[1], ops[2], ops[3], ops[4], "extract_bits", int_type, int_type,
|
||||
SPIRType::UInt, SPIRType::UInt);
|
||||
break;
|
||||
}
|
||||
|
||||
case OpBitFieldUExtract:
|
||||
{
|
||||
emit_trinary_func_op_bitextract(ops[0], ops[1], ops[2], ops[3], ops[4], "extract_bits",
|
||||
uint_type, uint_type,
|
||||
emit_trinary_func_op_bitextract(ops[0], ops[1], ops[2], ops[3], ops[4], "extract_bits", uint_type, uint_type,
|
||||
SPIRType::UInt, SPIRType::UInt);
|
||||
break;
|
||||
}
|
||||
@ -4898,8 +4879,8 @@ void CompilerMSL::emit_barrier(uint32_t id_exe_scope, uint32_t id_mem_scope, uin
|
||||
flush_all_active_variables();
|
||||
}
|
||||
|
||||
void CompilerMSL::emit_array_copy(const string &lhs, uint32_t rhs_id,
|
||||
StorageClass lhs_storage, StorageClass rhs_storage)
|
||||
void CompilerMSL::emit_array_copy(const string &lhs, uint32_t rhs_id, StorageClass lhs_storage,
|
||||
StorageClass rhs_storage)
|
||||
{
|
||||
// Assignment from an array initializer is fine.
|
||||
auto &type = expression_type(rhs_id);
|
||||
@ -4941,12 +4922,10 @@ void CompilerMSL::emit_array_copy(const string &lhs, uint32_t rhs_id,
|
||||
force_recompile();
|
||||
}
|
||||
|
||||
bool lhs_thread = lhs_storage == StorageClassFunction ||
|
||||
lhs_storage == StorageClassGeneric ||
|
||||
lhs_storage == StorageClassPrivate;
|
||||
bool rhs_thread = rhs_storage == StorageClassFunction ||
|
||||
rhs_storage == StorageClassGeneric ||
|
||||
rhs_storage == StorageClassPrivate;
|
||||
bool lhs_thread =
|
||||
lhs_storage == StorageClassFunction || lhs_storage == StorageClassGeneric || lhs_storage == StorageClassPrivate;
|
||||
bool rhs_thread =
|
||||
rhs_storage == StorageClassFunction || rhs_storage == StorageClassGeneric || rhs_storage == StorageClassPrivate;
|
||||
|
||||
const char *tag = nullptr;
|
||||
if (lhs_thread && is_constant)
|
||||
@ -5000,7 +4979,8 @@ bool CompilerMSL::maybe_emit_array_assignment(uint32_t id_lhs, uint32_t id_rhs)
|
||||
if (p_v_lhs)
|
||||
flush_variable_declaration(p_v_lhs->self);
|
||||
|
||||
emit_array_copy(to_expression(id_lhs), id_rhs, get_backing_variable_storage(id_lhs), get_backing_variable_storage(id_rhs));
|
||||
emit_array_copy(to_expression(id_lhs), id_rhs, get_backing_variable_storage(id_lhs),
|
||||
get_backing_variable_storage(id_rhs));
|
||||
register_write(id_lhs);
|
||||
|
||||
return true;
|
||||
|
@ -555,8 +555,8 @@ protected:
|
||||
void add_pragma_line(const std::string &line);
|
||||
void add_typedef_line(const std::string &line);
|
||||
void emit_barrier(uint32_t id_exe_scope, uint32_t id_mem_scope, uint32_t id_mem_sem);
|
||||
void emit_array_copy(const std::string &lhs, uint32_t rhs_id,
|
||||
spv::StorageClass lhs_storage, spv::StorageClass rhs_storage) override;
|
||||
void emit_array_copy(const std::string &lhs, uint32_t rhs_id, spv::StorageClass lhs_storage,
|
||||
spv::StorageClass rhs_storage) override;
|
||||
void build_implicit_builtins();
|
||||
uint32_t build_constant_uint_array_pointer();
|
||||
void emit_entry_point_declarations() override;
|
||||
|
Loading…
Reference in New Issue
Block a user