From 41d9eb42da0ecdba30974566ac5ef32aa86415ab Mon Sep 17 00:00:00 2001 From: Daniel Kulp Date: Sat, 25 Jan 2025 10:26:49 -0500 Subject: [PATCH] Fix rendering of pinwheel with >8 arms --- xLights/effects/PinwheelEffect.cpp | 7 ++++--- xLights/effects/ispc/ISPCComputeUtilities.cpp | 3 ++- xLights/effects/ispc/PinwheelFunctions.ispc | 6 +++--- xLights/effects/ispc/PinwheelFunctions.ispc.h | 2 +- xLights/effects/ispc/SpacialColors.ispc.h | 9 +++++++-- 5 files changed, 17 insertions(+), 10 deletions(-) diff --git a/xLights/effects/PinwheelEffect.cpp b/xLights/effects/PinwheelEffect.cpp index 1bdf3952d..458b52fa2 100644 --- a/xLights/effects/PinwheelEffect.cpp +++ b/xLights/effects/PinwheelEffect.cpp @@ -206,14 +206,15 @@ void PinwheelEffect::RenderNewArms(RenderBuffer& buffer, PinwheelData &data) { rdata.numColors = data.colorsAsColor.size(); rdata.colorarray = &data.colorarray[0]; - std::vector colorsAsHSV; - colorsAsHSV.resize(rdata.numColors); + std::vector colorsAsHSV(rdata.numColors); + std::vector colorIsSpacial(rdata.numColors); for (int x = 0; x < rdata.numColors; x++) { colorsAsHSV[x] = {(float)data.colorsAsHSV[x].hue, (float)data.colorsAsHSV[x].saturation, (float)data.colorsAsHSV[x].value}; - rdata.colorIsSpacial[x] = data.colorIsSpacial[x]; + colorIsSpacial[x] = data.colorIsSpacial[x] ? 1 : 0; } rdata.colorsAsColor = (ispc::uint8_t4*)&data.colorsAsColor[0]; rdata.colorsAsHSV = &colorsAsHSV[0]; + rdata.colorIsSpacial = &colorIsSpacial[0]; rdata.bufferData = (void*)&buffer; int max = buffer.BufferHt * buffer.BufferWi; diff --git a/xLights/effects/ispc/ISPCComputeUtilities.cpp b/xLights/effects/ispc/ISPCComputeUtilities.cpp index e480e3f3a..25763b3d4 100644 --- a/xLights/effects/ispc/ISPCComputeUtilities.cpp +++ b/xLights/effects/ispc/ISPCComputeUtilities.cpp @@ -58,7 +58,7 @@ __ISPC_ALIGNED_STRUCT__(64) v16_varying_SpacialData { }; #endif extern "C" { - void getSpacialColorForGang(void *buffer, float xcenter, float ycenter, float maxradius, int active, int pc, void *d) { + uint32_t getSpacialColorForGang(void *buffer, float xcenter, float ycenter, float maxradius, int active, int pc, void *d) { RenderBuffer *b = (RenderBuffer*)buffer; if (pc == 8) { v8_varying_SpacialData *data = (v8_varying_SpacialData*)d; @@ -79,6 +79,7 @@ extern "C" { } } } + return 0; } } diff --git a/xLights/effects/ispc/PinwheelFunctions.ispc b/xLights/effects/ispc/PinwheelFunctions.ispc index b2560f326..c93b2bffe 100644 --- a/xLights/effects/ispc/PinwheelFunctions.ispc +++ b/xLights/effects/ispc/PinwheelFunctions.ispc @@ -22,7 +22,7 @@ struct PinwheelData { uint32 numColors; uint8<4> *colorsAsColor; float<3> *colorsAsHSV; - bool colorIsSpacial[8]; + uint8 *colorIsSpacial; uint32 *colorarray; void* bufferData; @@ -120,11 +120,11 @@ export void PinwheelEffectStyle0(const uniform PinwheelData &data, t2 = abs(t2 - (data.tmax / 2)) * 2; int ColorIdx2 = ((int)((theta / data.degrees_per_arm))) % data.pinwheel_arms; uint8<4> color = data.colorsAsColor[ColorIdx2]; - if (data.colorIsSpacial[ColorIdx2]) { + if (data.colorIsSpacial[ColorIdx2] > 0) { color = getSpacialColor(data.bufferData, data.colorarray[ColorIdx2], data.xc_adj + data.width / 2, data.yc_adj + data.height / 2, - x, y, round, data.max_radius); + x, y, round, data.max_radius); if (!data.allowAlpha) { hsv = data.colorsAsHSV[ColorIdx2]; } diff --git a/xLights/effects/ispc/PinwheelFunctions.ispc.h b/xLights/effects/ispc/PinwheelFunctions.ispc.h index 2ff9ea46c..aac8107fa 100644 --- a/xLights/effects/ispc/PinwheelFunctions.ispc.h +++ b/xLights/effects/ispc/PinwheelFunctions.ispc.h @@ -76,7 +76,7 @@ struct PinwheelData { uint32_t numColors; uint8_t4 * colorsAsColor; float3 * colorsAsHSV; - bool colorIsSpacial[8]; + uint8_t * colorIsSpacial; uint32_t * colorarray; void * bufferData; }; diff --git a/xLights/effects/ispc/SpacialColors.ispc.h b/xLights/effects/ispc/SpacialColors.ispc.h index d7aed01a7..011cbe8f4 100644 --- a/xLights/effects/ispc/SpacialColors.ispc.h +++ b/xLights/effects/ispc/SpacialColors.ispc.h @@ -10,12 +10,17 @@ struct SpacialData { }; -extern "C" uniform uint32 getSpacialColorForGang(void * uniform buffer, uniform float xcenter, uniform float ycenter, uniform float maxradius, uniform int activeLanes, uniform int programCount, SpacialData d[]); +extern "C" uniform int32 getSpacialColorForGang(void * uniform buffer, uniform float xcenter, uniform float ycenter, uniform float maxradius, uniform int activeLanes, uniform int programCount, SpacialData d[]); inline uint8<4> getSpacialColor(void * uniform buffer, uint32 colorIdx, uniform float xcenter, uniform float ycenter, float x, float y, float r, uniform float maxradius) { SpacialData d = { colorIdx, x, y, r, 0}; getSpacialColorForGang(buffer, xcenter, ycenter, maxradius, lanemask(), programCount, &d); - return d.result; + uint8<4> result; + result.r = (d.result & 0xFF); + result.g = ((d.result >> 8) & 0xFF); + result.b = ((d.result >> 16) & 0xFF); + result.a = ((d.result >> 24) & 0xFF); + return result; }