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

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<>
struct OptimizedOpsSelector<KoRgbF32Traits>
{
static KoCompositeOp* createAlphaDarkenOp(const KoColorSpace *cs) {
// TODO: optimized code is disabled for 4.2 release,
// because it causes bug https://bugs.kde.org/show_bug.cgi?id=404133
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);
return useCreamyAlphaDarken() ?
KoOptimizedCompositeOpFactory::createAlphaDarkenOpCreamy128(cs) :
KoOptimizedCompositeOpFactory::createAlphaDarkenOpHard128(cs);
}
static KoCompositeOp* createOverOp(const KoColorSpace *cs) {
......
......@@ -12,7 +12,8 @@
#include "KoStreamedMath.h"
#include "KoAlphaDarkenParamsWrapper.h"
template<typename channels_type, typename pixel_type, typename _ParamsWrapper>
template<typename channels_type, typename _ParamsWrapper>
struct AlphaDarkenCompositor128 {
using ParamsWrapper = _ParamsWrapper;
......@@ -154,8 +155,8 @@ struct AlphaDarkenCompositor128 {
dst[1] = lerp(dst[1], src[1], srcAlphaNorm);
dst[2] = lerp(dst[2], src[2], srcAlphaNorm);
} else {
const pixel_type *s = reinterpret_cast<const pixel_type*>(src);
pixel_type *d = reinterpret_cast<pixel_type*>(dst);
const Pixel *s = reinterpret_cast<const Pixel*>(src);
Pixel *d = reinterpret_cast<Pixel*>(dst);
*d = *s;
}
......@@ -196,9 +197,9 @@ public:
virtual void composite(const KoCompositeOp::ParameterInfo& params) const override
{
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 {
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 @@
#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 ParamsWrapper {
ParamsWrapper(const KoCompositeOp::ParameterInfo& params)
......@@ -253,7 +253,7 @@ public:
if (params.channelFlags.isEmpty() ||
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 {
const bool allChannelsFlag =
params.channelFlags.at(0) &&
......@@ -264,11 +264,11 @@ public:
!params.channelFlags.at(3);
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) {
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) */{
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