summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/swr
diff options
context:
space:
mode:
authorTim Rowley <[email protected]>2016-07-13 15:06:13 -0600
committerTim Rowley <[email protected]>2016-07-20 10:22:15 -0500
commite0529a4668c7f50fb51b2c4ae8bc5954934db55f (patch)
tree4303de295636d8080f993a76a8fad87cd830ee12 /src/gallium/drivers/swr
parent036301596477a4b6b54e8e3f4ecf051860cbc7c3 (diff)
swr: [rasterizer core] support range of values in TemplateArgUnroller
Fixes Linux warnings. Signed-off-by: Tim Rowley <[email protected]>
Diffstat (limited to 'src/gallium/drivers/swr')
-rw-r--r--src/gallium/drivers/swr/rasterizer/core/frontend.cpp13
-rw-r--r--src/gallium/drivers/swr/rasterizer/core/rasterizer.cpp6
-rw-r--r--src/gallium/drivers/swr/rasterizer/core/utils.h63
3 files changed, 56 insertions, 26 deletions
diff --git a/src/gallium/drivers/swr/rasterizer/core/frontend.cpp b/src/gallium/drivers/swr/rasterizer/core/frontend.cpp
index 8537c59033c..cb13b50df14 100644
--- a/src/gallium/drivers/swr/rasterizer/core/frontend.cpp
+++ b/src/gallium/drivers/swr/rasterizer/core/frontend.cpp
@@ -1481,7 +1481,6 @@ INLINE void ProcessAttributes(
}
__m128 attrib[3]; // triangle attribs (always 4 wide)
- static const uint32_t numVerts = NumVertsT::value < 3 ? NumVertsT::value : 3;
float* pAttribStart = pBuffer;
if (HasConstantInterpT::value)
@@ -1519,7 +1518,7 @@ INLINE void ProcessAttributes(
pa.AssembleSingle(inputSlot, adjustedTriIndex, attrib);
- for (uint32_t i = 0; i < numVerts; ++i)
+ for (uint32_t i = 0; i < NumVertsT::value; ++i)
{
_mm_store_ps(pBuffer, attrib[vid]);
pBuffer += 4;
@@ -1529,7 +1528,7 @@ INLINE void ProcessAttributes(
{
pa.AssembleSingle(inputSlot, triIndex, attrib);
- for (uint32_t i = 0; i < numVerts; ++i)
+ for (uint32_t i = 0; i < NumVertsT::value; ++i)
{
_mm_store_ps(pBuffer, attrib[i]);
pBuffer += 4;
@@ -1540,7 +1539,7 @@ INLINE void ProcessAttributes(
{
pa.AssembleSingle(inputSlot, triIndex, attrib);
- for (uint32_t i = 0; i < numVerts; ++i)
+ for (uint32_t i = 0; i < NumVertsT::value; ++i)
{
_mm_store_ps(pBuffer, attrib[i]);
pBuffer += 4;
@@ -1551,9 +1550,9 @@ INLINE void ProcessAttributes(
// interpolation code in the pixel shader works correctly for the
// 3 topologies - point, line, tri. This effectively zeros out the
// effect of the missing vertices in the triangle interpolation.
- for (uint32_t v = numVerts; v < 3; ++v)
+ for (uint32_t v = NumVertsT::value; v < 3; ++v)
{
- _mm_store_ps(pBuffer, attrib[numVerts - 1]);
+ _mm_store_ps(pBuffer, attrib[NumVertsT::value - 1]);
pBuffer += 4;
}
@@ -1608,7 +1607,7 @@ struct ProcessAttributesChooser
PFN_PROCESS_ATTRIBUTES GetProcessAttributesFunc(uint32_t NumVerts, bool IsSwizzled, bool HasConstantInterp)
{
- return TemplateArgUnroller<ProcessAttributesChooser>::GetFunc(NumVerts, IsSwizzled, HasConstantInterp);
+ return TemplateArgUnroller<ProcessAttributesChooser>::GetFunc(IntArg<1, 3>{NumVerts}, IsSwizzled, HasConstantInterp);
}
//////////////////////////////////////////////////////////////////////////
diff --git a/src/gallium/drivers/swr/rasterizer/core/rasterizer.cpp b/src/gallium/drivers/swr/rasterizer/core/rasterizer.cpp
index 1e7da2bf81e..408d1d5bb93 100644
--- a/src/gallium/drivers/swr/rasterizer/core/rasterizer.cpp
+++ b/src/gallium/drivers/swr/rasterizer/core/rasterizer.cpp
@@ -1544,5 +1544,9 @@ PFN_WORK_FUNC GetRasterizerFunc(
bool RasterizeScissorEdges
)
{
- return TemplateArgUnroller<RasterizerChooser>::GetFunc(numSamples, IsConservative, InputCoverage, RasterizeScissorEdges);
+ return TemplateArgUnroller<RasterizerChooser>::GetFunc(
+ IntArg<0,4>{numSamples},
+ IsConservative,
+ IntArg<SWR_INPUT_COVERAGE_NONE, SWR_INPUT_COVERAGE_MAX>{InputCoverage},
+ RasterizeScissorEdges);
}
diff --git a/src/gallium/drivers/swr/rasterizer/core/utils.h b/src/gallium/drivers/swr/rasterizer/core/utils.h
index 51d6c46ea08..0cfdb84c73b 100644
--- a/src/gallium/drivers/swr/rasterizer/core/utils.h
+++ b/src/gallium/drivers/swr/rasterizer/core/utils.h
@@ -989,11 +989,22 @@ public:
}
};
+// Ranged integer argument for TemplateArgUnroller
+template <uint32_t TMin, uint32_t TMax>
+struct IntArg
+{
+ uint32_t val;
+};
+
// Recursive template used to auto-nest conditionals. Converts dynamic boolean function
// arguments to static template arguments.
template <typename TermT, typename... ArgsB>
struct TemplateArgUnroller
{
+ //-----------------------------------------
+ // Boolean value
+ //-----------------------------------------
+
// Last Arg Terminator
static typename TermT::FuncType GetFunc(bool bArg)
{
@@ -1017,34 +1028,50 @@ struct TemplateArgUnroller
return TemplateArgUnroller<TermT, ArgsB..., std::false_type>::GetFunc(remainingArgs...);
}
+ //-----------------------------------------
+ // Integer value (within specified range)
+ //-----------------------------------------
+
// Last Arg Terminator
- template <typename... TArgsT>
- static typename TermT::FuncType GetFunc(uint32_t iArg)
+ template <uint32_t TMin, uint32_t TMax>
+ static typename TermT::FuncType GetFunc(IntArg<TMin, TMax> iArg)
{
- switch(iArg)
+ if (iArg.val == TMax)
+ {
+ return TermT::template GetFunc<ArgsB..., std::integral_constant<uint32_t, TMax>>();
+ }
+ if (TMax > TMin)
{
- case 0: return TermT::template GetFunc<ArgsB..., std::integral_constant<uint32_t, 0>>();
- case 1: return TermT::template GetFunc<ArgsB..., std::integral_constant<uint32_t, 1>>();
- case 2: return TermT::template GetFunc<ArgsB..., std::integral_constant<uint32_t, 2>>();
- case 3: return TermT::template GetFunc<ArgsB..., std::integral_constant<uint32_t, 3>>();
- case 4: return TermT::template GetFunc<ArgsB..., std::integral_constant<uint32_t, 4>>();
- default: SWR_ASSUME(false); return nullptr;
+ return TemplateArgUnroller<TermT, ArgsB...>::GetFunc(IntArg<TMin, TMax-1>{iArg.val});
}
+ SWR_ASSUME(false); return nullptr;
+ }
+ template <uint32_t TVal>
+ static typename TermT::FuncType GetFunc(IntArg<TVal, TVal> iArg)
+ {
+ SWR_ASSERT(iArg.val == TVal);
+ return TermT::template GetFunc<ArgsB..., std::integral_constant<uint32_t, TVal>>();
}
// Recursively parse args
- template <typename... TArgsT>
- static typename TermT::FuncType GetFunc(uint32_t iArg, TArgsT... remainingArgs)
+ template <uint32_t TMin, uint32_t TMax, typename... TArgsT>
+ static typename TermT::FuncType GetFunc(IntArg<TMin, TMax> iArg, TArgsT... remainingArgs)
{
- switch(iArg)
+ if (iArg.val == TMax)
{
- case 0: return TemplateArgUnroller<TermT, ArgsB..., std::integral_constant<uint32_t, 0>>::GetFunc(remainingArgs...);
- case 1: return TemplateArgUnroller<TermT, ArgsB..., std::integral_constant<uint32_t, 1>>::GetFunc(remainingArgs...);
- case 2: return TemplateArgUnroller<TermT, ArgsB..., std::integral_constant<uint32_t, 2>>::GetFunc(remainingArgs...);
- case 3: return TemplateArgUnroller<TermT, ArgsB..., std::integral_constant<uint32_t, 3>>::GetFunc(remainingArgs...);
- case 4: return TemplateArgUnroller<TermT, ArgsB..., std::integral_constant<uint32_t, 4>>::GetFunc(remainingArgs...);
- default: SWR_ASSUME(false); return nullptr;
+ return TemplateArgUnroller<TermT, ArgsB..., std::integral_constant<uint32_t, TMax>>::GetFunc(remainingArgs...);
}
+ if (TMax > TMin)
+ {
+ return TemplateArgUnroller<TermT, ArgsB...>::GetFunc(IntArg<TMin, TMax - 1>{iArg.val}, remainingArgs...);
+ }
+ SWR_ASSUME(false); return nullptr;
+ }
+ template <uint32_t TVal, typename... TArgsT>
+ static typename TermT::FuncType GetFunc(IntArg<TVal, TVal> iArg, TArgsT... remainingArgs)
+ {
+ SWR_ASSERT(iArg.val == TVal);
+ return TemplateArgUnroller<TermT, ArgsB..., std::integral_constant<uint32_t, TVal>>::GetFunc(remainingArgs...);
}
};