From: George Kyriazis Date: Fri, 6 Apr 2018 20:03:09 +0000 (-0500) Subject: swr/rast: Type-check TemplateArgUnroller X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a81c625cb7c63ebcc79ebd8bb52ea35eb5665d43;p=mesa.git swr/rast: Type-check TemplateArgUnroller Allows direct use of enum values in conversion to template args. Reviewed-by: Bruce Cherniak --- diff --git a/src/gallium/drivers/swr/rasterizer/core/utils.h b/src/gallium/drivers/swr/rasterizer/core/utils.h index c926f6ad7f2..d6cbf2436d3 100644 --- a/src/gallium/drivers/swr/rasterizer/core/utils.h +++ b/src/gallium/drivers/swr/rasterizer/core/utils.h @@ -268,12 +268,15 @@ public: }; // Ranged integer argument for TemplateArgUnroller -template -struct IntArg +template +struct RangedArg { - uint32_t val; + T val; }; +template +using IntArg = RangedArg; + // Recursive template used to auto-nest conditionals. Converts dynamic boolean function // arguments to static template arguments. template @@ -307,49 +310,49 @@ struct TemplateArgUnroller } //----------------------------------------- - // Integer value (within specified range) + // Ranged value (within specified range) //----------------------------------------- // Last Arg Terminator - template - static typename TermT::FuncType GetFunc(IntArg iArg) + template + static typename TermT::FuncType GetFunc(RangedArg iArg) { if (iArg.val == TMax) { - return TermT::template GetFunc>(); + return TermT::template GetFunc>(); } if (TMax > TMin) { - return TemplateArgUnroller::GetFunc(IntArg{iArg.val}); + return TemplateArgUnroller::GetFunc(RangedArg{iArg.val}); } SWR_ASSUME(false); return nullptr; } - template - static typename TermT::FuncType GetFunc(IntArg iArg) + template + static typename TermT::FuncType GetFunc(RangedArg iArg) { SWR_ASSERT(iArg.val == TVal); - return TermT::template GetFunc>(); + return TermT::template GetFunc>(); } // Recursively parse args - template - static typename TermT::FuncType GetFunc(IntArg iArg, TArgsT... remainingArgs) + template + static typename TermT::FuncType GetFunc(RangedArg iArg, TArgsT... remainingArgs) { if (iArg.val == TMax) { - return TemplateArgUnroller>::GetFunc(remainingArgs...); + return TemplateArgUnroller>::GetFunc(remainingArgs...); } if (TMax > TMin) { - return TemplateArgUnroller::GetFunc(IntArg{iArg.val}, remainingArgs...); + return TemplateArgUnroller::GetFunc(RangedArg{iArg.val}, remainingArgs...); } SWR_ASSUME(false); return nullptr; } - template - static typename TermT::FuncType GetFunc(IntArg iArg, TArgsT... remainingArgs) + template + static typename TermT::FuncType GetFunc(RangedArg iArg, TArgsT... remainingArgs) { SWR_ASSERT(iArg.val == TVal); - return TemplateArgUnroller>::GetFunc(remainingArgs...); + return TemplateArgUnroller>::GetFunc(remainingArgs...); } };