I want to invoke threads on these member functions (they take the exact same parameters). Note that this ALL takes place inside a class called Renderer.
template <class Pixel>
void DrawFlatBottom(Pixel& leftPixel, Vec2& leftScreen, Pixel& topPixel, Vec2& topScreen, Pixel& rightPixel, Vec2& rightScreen, Vec4 (*PixelShader)(Pixel& sd)) {
// DrawFlatBottom implementation
}
template <class Pixel>
void DrawFlatTop(Pixel& leftPixel, Vec2& leftScreen, Pixel& bottomPixel, Vec2& bottomScreen, Pixel& rightPixel, Vec2& rightScreen, Vec4 (*PixelShader)(Pixel& sd)) {
// DrawFlatTop implementation
}
Here is how I am trying to invoke the threads:
template <class Pixel>
void DrawTriangle(Pixel p1, Pixel p2, Pixel p3, Vec4 (*PixelShader)(Pixel& sd)) {
std::thread flatBottom(&Renderer::DrawFlatBottom<Pixel>, std::ref(*middlePixel), std::ref(*middleScreen), std::ref(*topPixel), std::ref(*topScreen), std::ref(cutPixel), std::ref(cutScreen), PixelShader);
std::thread flatTop(&Renderer::DrawFlatTop<Pixel>, std::ref(*middlePixel), std::ref(*middleScreen), std::ref(*bottomPixel), std::ref(*bottomScreen), std::ref(cutPixel), std::ref(cutScreen), PixelShader);
// rest of DrawTriangle implementation
}
Notice that these invocations are themselves inside a templated function, whose template parameter Pixel is being passed into another templated function (DrawFlatBottom and DrawFlatTop)
However, this causes the compilation errors
Error C2672 'std::invoke': no matching overloaded function found
Error C2893 Failed to specialize function template 'unknown-type std::invoke(_Callable &&,_Types &&...) noexcept(<expr>)'
I think all the parameters I am passing are correct (ie: they are all the correct types). Maybe I am passing the PixelShader function pointer (last parameter) incorrectly. I'm pretty sure it must have something to do with the template.