#include "hecl/Backend/ProgrammableCommon.hpp" #include namespace hecl::Backend { const char* ProgrammableCommon::BlendFactorToDefine(BlendFactor factor, BlendFactor defaultFactor) { switch (factor) { case BlendFactor::Zero: return "ZERO"; case BlendFactor::One: return "ONE"; case BlendFactor::SrcColor: return "SRCCOLOR"; case BlendFactor::InvSrcColor: return "INVSRCCOLOR"; case BlendFactor::DstColor: return "DSTCOLOR"; case BlendFactor::InvDstColor: return "INVDSTCOLOR"; case BlendFactor::SrcAlpha: return "SRCALPHA"; case BlendFactor::InvSrcAlpha: return "INVSRCALPHA"; case BlendFactor::DstAlpha: return "DSTALPHA"; case BlendFactor::InvDstAlpha: return "INVDSTALPHA"; case BlendFactor::SrcColor1: return "SRCCOLOR1"; case BlendFactor::InvSrcColor1: return "INVSRCCOLOR1"; default: return BlendFactorToDefine(defaultFactor, BlendFactor::Zero); } } unsigned ProgrammableCommon::addTexCoordGen(TexGenSrc src, int uvIdx, int mtx, bool normalize) { for (unsigned i=0 ; i 1) { const IR::Instruction& alphaRoot = ir.m_instructions.at(rootCall.m_call.m_argInstIdxs.at(1)); m_alphaExpr = RecursiveTraceAlpha(ir, diag, alphaRoot, false); } } static const char SWIZZLE_CHARS[] = "rgba"; std::string ProgrammableCommon::EmitSwizzle3(Diagnostics& diag, const SourceLocation& loc, const std::string& a, const atInt8 swiz[4]) const { std::string retval = a + '.'; for (int i=0 ; i<3 ; ++i) { if (swiz[i] < 0 || swiz[i] > 3) diag.reportBackendErr(loc, "unable to use swizzle as RGB value"); retval += SWIZZLE_CHARS[swiz[i]]; } return retval; } std::string ProgrammableCommon::EmitSwizzle1(Diagnostics& diag, const SourceLocation& loc, const std::string& a, const atInt8 swiz[4]) const { std::string retval = a + '.'; if (swiz[0] < 0 || swiz[0] > 3) diag.reportBackendErr(loc, "unable to use swizzle as Alpha value"); retval += SWIZZLE_CHARS[swiz[0]]; return retval; } }