This commit is contained in:
Robert Konrad 2017-03-24 14:13:59 +01:00
Родитель 9ec9dd0647
Коммит a7e2a69a6f
3 изменённых файлов: 32 добавлений и 1 удалений

Просмотреть файл

@ -371,7 +371,7 @@ protected:
uint32_t type_to_std430_size(const SPIRType &type, uint64_t flags); uint32_t type_to_std430_size(const SPIRType &type, uint64_t flags);
std::string bitcast_glsl(const SPIRType &result_type, uint32_t arg); std::string bitcast_glsl(const SPIRType &result_type, uint32_t arg);
std::string bitcast_glsl_op(const SPIRType &result_type, const SPIRType &argument_type); virtual std::string bitcast_glsl_op(const SPIRType &result_type, const SPIRType &argument_type);
std::string build_composite_combiner(const uint32_t *elems, uint32_t length); std::string build_composite_combiner(const uint32_t *elems, uint32_t length);
bool remove_duplicate_swizzle(std::string &op); bool remove_duplicate_swizzle(std::string &op);
bool remove_unity_swizzle(uint32_t base, std::string &op); bool remove_unity_swizzle(uint32_t base, std::string &op);

Просмотреть файл

@ -1242,6 +1242,36 @@ void CompilerHLSL::emit_uniform(const SPIRVariable &var)
statement(variable_decl(var), ";"); statement(variable_decl(var), ";");
} }
string CompilerHLSL::bitcast_glsl_op(const SPIRType &out_type, const SPIRType &in_type)
{
if (out_type.basetype == SPIRType::UInt && in_type.basetype == SPIRType::Int)
return type_to_glsl(out_type);
else if (out_type.basetype == SPIRType::UInt64 && in_type.basetype == SPIRType::Int64)
return type_to_glsl(out_type);
else if (out_type.basetype == SPIRType::UInt && in_type.basetype == SPIRType::Float)
return "asuint";
else if (out_type.basetype == SPIRType::Int && in_type.basetype == SPIRType::UInt)
return type_to_glsl(out_type);
else if (out_type.basetype == SPIRType::Int64 && in_type.basetype == SPIRType::UInt64)
return type_to_glsl(out_type);
else if (out_type.basetype == SPIRType::Int && in_type.basetype == SPIRType::Float)
return "asint";
else if (out_type.basetype == SPIRType::Float && in_type.basetype == SPIRType::UInt)
return "asfloat";
else if (out_type.basetype == SPIRType::Float && in_type.basetype == SPIRType::Int)
return "asfloat";
else if (out_type.basetype == SPIRType::Int64 && in_type.basetype == SPIRType::Double)
SPIRV_CROSS_THROW("Double to Int64 is not supported in HLSL.");
else if (out_type.basetype == SPIRType::UInt64 && in_type.basetype == SPIRType::Double)
SPIRV_CROSS_THROW("Double to UInt64 is not supported in HLSL.");
else if (out_type.basetype == SPIRType::Double && in_type.basetype == SPIRType::Int64)
return "asdouble";
else if (out_type.basetype == SPIRType::Double && in_type.basetype == SPIRType::UInt64)
return "asdouble";
else
return "";
}
void CompilerHLSL::emit_glsl_op(uint32_t result_type, uint32_t id, uint32_t eop, const uint32_t *args, uint32_t count) void CompilerHLSL::emit_glsl_op(uint32_t result_type, uint32_t id, uint32_t eop, const uint32_t *args, uint32_t count)
{ {
GLSLstd450 op = static_cast<GLSLstd450>(eop); GLSLstd450 op = static_cast<GLSLstd450>(eop);

Просмотреть файл

@ -69,6 +69,7 @@ private:
void emit_uniform(const SPIRVariable &var) override; void emit_uniform(const SPIRVariable &var) override;
std::string layout_for_member(const SPIRType &type, uint32_t index) override; std::string layout_for_member(const SPIRType &type, uint32_t index) override;
std::string to_interpolation_qualifiers(uint64_t flags) override; std::string to_interpolation_qualifiers(uint64_t flags) override;
std::string bitcast_glsl_op(const SPIRType &result_type, const SPIRType &argument_type) override;
const char *to_storage_qualifiers_glsl(const SPIRVariable &var) override; const char *to_storage_qualifiers_glsl(const SPIRVariable &var) override;