Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Buffer Render method incorrectly assumes all native data formats have 8bit elements #442

Open
Makuna opened this issue Feb 27, 2021 · 1 comment
Assignees
Labels

Comments

@Makuna
Copy link
Owner

Makuna commented Feb 27, 2021

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);
        }
    }
@Makuna
Copy link
Owner Author

Makuna commented Apr 21, 2023

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant