Commit 999cd22e authored by Dmitry Kazakov's avatar Dmitry Kazakov
Browse files

Recover AVX optimization for Float32 color spaces

The problem was in the fast-path branch which used wrong pixel type

Many thanks to Mathias Wein for tracking down this problem:
76c28d6a

BUG:404133
parent 23184897
...@@ -81,19 +81,9 @@ template<> ...@@ -81,19 +81,9 @@ template<>
struct OptimizedOpsSelector<KoRgbF32Traits> struct OptimizedOpsSelector<KoRgbF32Traits>
{ {
static KoCompositeOp* createAlphaDarkenOp(const KoColorSpace *cs) { static KoCompositeOp* createAlphaDarkenOp(const KoColorSpace *cs) {
return useCreamyAlphaDarken() ?
// TODO: optimized code is disabled for 4.2 release, KoOptimizedCompositeOpFactory::createAlphaDarkenOpCreamy128(cs) :
// because it causes bug https://bugs.kde.org/show_bug.cgi?id=404133 KoOptimizedCompositeOpFactory::createAlphaDarkenOpHard128(cs);
if (useCreamyAlphaDarken()) {
return new KoCompositeOpAlphaDarken<KoRgbF32Traits, KoAlphaDarkenParamsWrapperCreamy>(cs);
} else {
return new KoCompositeOpAlphaDarken<KoRgbF32Traits, KoAlphaDarkenParamsWrapperHard>(cs);
}
// TODO: please restore this optimized version when the bug is fixed
// return useCreamyAlphaDarken() ?
// KoOptimizedCompositeOpFactory::createAlphaDarkenOpCreamy128(cs) :
// KoOptimizedCompositeOpFactory::createAlphaDarkenOpHard128(cs);
} }
static KoCompositeOp* createOverOp(const KoColorSpace *cs) { static KoCompositeOp* createOverOp(const KoColorSpace *cs) {
......
...@@ -12,7 +12,8 @@ ...@@ -12,7 +12,8 @@
#include "KoStreamedMath.h" #include "KoStreamedMath.h"
#include "KoAlphaDarkenParamsWrapper.h" #include "KoAlphaDarkenParamsWrapper.h"
template<typename channels_type, typename pixel_type, typename _ParamsWrapper>
template<typename channels_type, typename _ParamsWrapper>
struct AlphaDarkenCompositor128 { struct AlphaDarkenCompositor128 {
using ParamsWrapper = _ParamsWrapper; using ParamsWrapper = _ParamsWrapper;
...@@ -154,8 +155,8 @@ struct AlphaDarkenCompositor128 { ...@@ -154,8 +155,8 @@ struct AlphaDarkenCompositor128 {
dst[1] = lerp(dst[1], src[1], srcAlphaNorm); dst[1] = lerp(dst[1], src[1], srcAlphaNorm);
dst[2] = lerp(dst[2], src[2], srcAlphaNorm); dst[2] = lerp(dst[2], src[2], srcAlphaNorm);
} else { } else {
const pixel_type *s = reinterpret_cast<const pixel_type*>(src); const Pixel *s = reinterpret_cast<const Pixel*>(src);
pixel_type *d = reinterpret_cast<pixel_type*>(dst); Pixel *d = reinterpret_cast<Pixel*>(dst);
*d = *s; *d = *s;
} }
...@@ -196,9 +197,9 @@ public: ...@@ -196,9 +197,9 @@ public:
virtual void composite(const KoCompositeOp::ParameterInfo& params) const override virtual void composite(const KoCompositeOp::ParameterInfo& params) const override
{ {
if(params.maskRowStart) { if(params.maskRowStart) {
KoStreamedMath<_impl>::template genericComposite128<true, true, AlphaDarkenCompositor128<float, quint32, ParamsWrapper> >(params); KoStreamedMath<_impl>::template genericComposite128<true, true, AlphaDarkenCompositor128<float, ParamsWrapper> >(params);
} else { } else {
KoStreamedMath<_impl>::template genericComposite128<false, true, AlphaDarkenCompositor128<float, quint32, ParamsWrapper> >(params); KoStreamedMath<_impl>::template genericComposite128<false, true, AlphaDarkenCompositor128<float, ParamsWrapper> >(params);
} }
} }
}; };
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
#define INFO_DEBUG 0 #define INFO_DEBUG 0
template<typename channels_type, typename pixel_type, bool alphaLocked, bool allChannelsFlag> template<typename channels_type, bool alphaLocked, bool allChannelsFlag>
struct OverCompositor128 { struct OverCompositor128 {
struct ParamsWrapper { struct ParamsWrapper {
ParamsWrapper(const KoCompositeOp::ParameterInfo& params) ParamsWrapper(const KoCompositeOp::ParameterInfo& params)
...@@ -253,7 +253,7 @@ public: ...@@ -253,7 +253,7 @@ public:
if (params.channelFlags.isEmpty() || if (params.channelFlags.isEmpty() ||
params.channelFlags == QBitArray(4, true)) { params.channelFlags == QBitArray(4, true)) {
KoStreamedMath<_impl>::template genericComposite128<haveMask, false, OverCompositor128<float, quint32, false, true> >(params); KoStreamedMath<_impl>::template genericComposite128<haveMask, false, OverCompositor128<float, false, true> >(params);
} else { } else {
const bool allChannelsFlag = const bool allChannelsFlag =
params.channelFlags.at(0) && params.channelFlags.at(0) &&
...@@ -264,11 +264,11 @@ public: ...@@ -264,11 +264,11 @@ public:
!params.channelFlags.at(3); !params.channelFlags.at(3);
if (allChannelsFlag && alphaLocked) { if (allChannelsFlag && alphaLocked) {
KoStreamedMath<_impl>::template genericComposite128_novector<haveMask, false, OverCompositor128<float, quint32, true, true> >(params); KoStreamedMath<_impl>::template genericComposite128_novector<haveMask, false, OverCompositor128<float, true, true> >(params);
} else if (!allChannelsFlag && !alphaLocked) { } else if (!allChannelsFlag && !alphaLocked) {
KoStreamedMath<_impl>::template genericComposite128_novector<haveMask, false, OverCompositor128<float, quint32, false, false> >(params); KoStreamedMath<_impl>::template genericComposite128_novector<haveMask, false, OverCompositor128<float, false, false> >(params);
} else /*if (!allChannelsFlag && alphaLocked) */{ } else /*if (!allChannelsFlag && alphaLocked) */{
KoStreamedMath<_impl>::template genericComposite128_novector<haveMask, false, OverCompositor128<float, quint32, true, false> >(params); KoStreamedMath<_impl>::template genericComposite128_novector<haveMask, false, OverCompositor128<float, true, false> >(params);
} }
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment