Add support for additional ops in OpSpecConstantOp.
MSL: Support op OpQuantizeToF16 in OpSpecConstantOp. All: Support op OpSRem in OpSpecConstantOp.
This commit is contained in:
parent
51d8e7be94
commit
5fb1ca4f0d
@ -4712,6 +4712,14 @@ string CompilerGLSL::constant_op_expression(const SPIRConstantOp &cop)
|
||||
GLSL_BOP(UGreaterThanEqual, ">=");
|
||||
GLSL_BOP(SGreaterThanEqual, ">=");
|
||||
|
||||
case OpSRem:
|
||||
{
|
||||
uint32_t op0 = cop.arguments[0];
|
||||
uint32_t op1 = cop.arguments[1];
|
||||
return join(to_enclosed_expression(op0), " - ", to_enclosed_expression(op1), " * ", "(",
|
||||
to_enclosed_expression(op0), " / ", to_enclosed_expression(op1), ")");
|
||||
}
|
||||
|
||||
case OpSelect:
|
||||
{
|
||||
if (cop.arguments.size() < 3)
|
||||
|
@ -386,7 +386,7 @@ protected:
|
||||
virtual void emit_struct_padding_target(const SPIRType &type);
|
||||
virtual std::string image_type_glsl(const SPIRType &type, uint32_t id = 0);
|
||||
std::string constant_expression(const SPIRConstant &c);
|
||||
std::string constant_op_expression(const SPIRConstantOp &cop);
|
||||
virtual std::string constant_op_expression(const SPIRConstantOp &cop);
|
||||
virtual std::string constant_expression_vector(const SPIRConstant &c, uint32_t vector);
|
||||
virtual void emit_fixup();
|
||||
virtual std::string variable_decl(const SPIRType &type, const std::string &name, uint32_t id = 0);
|
||||
|
@ -13327,6 +13327,38 @@ string CompilerMSL::type_to_array_glsl(const SPIRType &type)
|
||||
}
|
||||
}
|
||||
|
||||
string CompilerMSL::constant_op_expression(const SPIRConstantOp &cop)
|
||||
{
|
||||
auto &type = get<SPIRType>(cop.basetype);
|
||||
string op;
|
||||
|
||||
switch (cop.opcode)
|
||||
{
|
||||
case OpQuantizeToF16:
|
||||
switch (type.vecsize)
|
||||
{
|
||||
case 1:
|
||||
op = "float(half(";
|
||||
break;
|
||||
case 2:
|
||||
op = "float2(half2(";
|
||||
break;
|
||||
case 3:
|
||||
op = "float3(half3(";
|
||||
break;
|
||||
case 4:
|
||||
op = "float4(half4(";
|
||||
break;
|
||||
default:
|
||||
SPIRV_CROSS_THROW("Illegal argument to OpSpecConstantOp QuantizeToF16.");
|
||||
}
|
||||
return join(op, to_expression(cop.arguments[0]), "))");
|
||||
|
||||
default:
|
||||
return CompilerGLSL::constant_op_expression(cop);
|
||||
}
|
||||
}
|
||||
|
||||
bool CompilerMSL::variable_decl_is_remapped_storage(const SPIRVariable &variable, spv::StorageClass storage) const
|
||||
{
|
||||
if (variable.storage == storage)
|
||||
|
@ -734,6 +734,7 @@ protected:
|
||||
|
||||
// Allow Metal to use the array<T> template to make arrays a value type
|
||||
std::string type_to_array_glsl(const SPIRType &type) override;
|
||||
std::string constant_op_expression(const SPIRConstantOp &cop) override;
|
||||
|
||||
// Threadgroup arrays can't have a wrapper type
|
||||
std::string variable_decl(const SPIRVariable &variable) override;
|
||||
|
Loading…
Reference in New Issue
Block a user