NeoPixelBus
NeoPixelBus copied to clipboard
Buffer Render method incorrectly assumes all native data formats have 8bit elements
Describe the bug In the NeoPixelBufferShader.ino example, the shader implementation has two uint8_t* parameters that represent the pixel color; and assumes that each byte is a distinct element. There are several features that this is not true. This demonstrates a design flaw in how "buffers" implement shaders and they are different in how "DIBs" implement them.
Expected behavior The shader implementer should be given a standard color object and not a stream of bytes like how DIBs shaders work.
Additional context Buffer.h, Render should look like
template <typename T_SHADER> void Render(NeoBufferContext<typename T_BUFFER_METHOD::ColorFeature> destBuffer, T_SHADER& shader)
{
uint16_t countPixels = destBuffer.PixelCount();
if (countPixels > _method.PixelCount())
{
countPixels = _method.PixelCount();
}
for (uint16_t indexPixel = 0; indexPixel < countPixels; indexPixel++)
{
typename T_BUFFER_METHOD::ColorObject color = shader.Apply(indexPixel, _method.GetPixelColor(indexPixel));
T_BUFFER_METHOD::ColorFeature::applyPixelColor(destBuffer.Pixels, indexPixel, color);
}
}
But at this point, these non-DIB renders become more expensive than DIB renders as the bytes need to be converted to a DIB Color, manipulated in the shader, and then converted back to native format. With this then, why have native shaders at all?