Skip to content

Commit

Permalink
[imgu]Add more color conversions into fast path.
Browse files Browse the repository at this point in the history
  • Loading branch information
XZiar committed Oct 29, 2024
1 parent 43409e6 commit b37e374
Show file tree
Hide file tree
Showing 14 changed files with 940 additions and 197 deletions.
60 changes: 42 additions & 18 deletions ImageUtil/ColorConvert.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,26 @@ class ColorConvertor final : public common::RuntimeFastPath<ColorConvertor>
friend ::common::fastpath::PathHack;
private:
common::CopyManager CopyEx;
void(*G8ToGA8 )(uint16_t* __restrict dest, const uint8_t* __restrict src, size_t count, std::byte alpha) noexcept = nullptr;
void(*G8ToRGB8 )(uint8_t* __restrict dest, const uint8_t* __restrict src, size_t count) noexcept = nullptr;
void(*G8ToRGBA8 )(uint32_t* __restrict dest, const uint8_t* __restrict src, size_t count, std::byte alpha) noexcept = nullptr;
void(*GA8ToRGBA8 )(uint32_t* __restrict dest, const uint16_t* __restrict src, size_t count) noexcept = nullptr;
void(*RGB8ToRGBA8)(uint32_t* __restrict dest, const uint8_t* __restrict src, size_t count, std::byte alpha) noexcept = nullptr;
void(*RGBA8ToRGB8)(uint8_t* __restrict dest, const uint32_t* __restrict src, size_t count) noexcept = nullptr;
void(*RGBA8ToR8 )(uint8_t* __restrict dest, const uint32_t* __restrict src, size_t count) noexcept = nullptr;
void(*RGBA8ToG8 )(uint8_t* __restrict dest, const uint32_t* __restrict src, size_t count) noexcept = nullptr;
void(*RGBA8ToB8 )(uint8_t* __restrict dest, const uint32_t* __restrict src, size_t count) noexcept = nullptr;
void(*RGBA8ToA8 )(uint8_t* __restrict dest, const uint32_t* __restrict src, size_t count) noexcept = nullptr;
void(*RGB8ToR8 )(uint8_t* __restrict dest, const uint8_t* __restrict src, size_t count) noexcept = nullptr;
void(*RGB8ToG8 )(uint8_t* __restrict dest, const uint8_t* __restrict src, size_t count) noexcept = nullptr;
void(*RGB8ToB8 )(uint8_t* __restrict dest, const uint8_t* __restrict src, size_t count) noexcept = nullptr;
void(*RGBA8ToRA8 )(uint16_t* __restrict dest, const uint32_t* __restrict src, size_t count) noexcept = nullptr;
void(*RGBA8ToGA8 )(uint16_t* __restrict dest, const uint32_t* __restrict src, size_t count) noexcept = nullptr;
void(*RGBA8ToBA8 )(uint16_t* __restrict dest, const uint32_t* __restrict src, size_t count) noexcept = nullptr;
void(*G8ToGA8 )(uint16_t* __restrict dest, const uint8_t* __restrict src, size_t count, std::byte alpha) noexcept = nullptr;
void(*G8ToRGB8 )(uint8_t* __restrict dest, const uint8_t* __restrict src, size_t count) noexcept = nullptr;
void(*G8ToRGBA8 )(uint32_t* __restrict dest, const uint8_t* __restrict src, size_t count, std::byte alpha) noexcept = nullptr;
void(*GA8ToRGBA8 )(uint32_t* __restrict dest, const uint16_t* __restrict src, size_t count) noexcept = nullptr;
void(*RGB8ToRGBA8 )(uint32_t* __restrict dest, const uint8_t* __restrict src, size_t count, std::byte alpha) noexcept = nullptr;
void(*BGR8ToRGBA8 )(uint32_t* __restrict dest, const uint8_t* __restrict src, size_t count, std::byte alpha) noexcept = nullptr;
void(*RGBA8ToRGB8 )(uint8_t* __restrict dest, const uint32_t* __restrict src, size_t count) noexcept = nullptr;
void(*RGBA8ToBGR8 )(uint8_t* __restrict dest, const uint32_t* __restrict src, size_t count) noexcept = nullptr;
void(*RGB8ToBGR8 )(uint8_t* __restrict dest, const uint8_t* __restrict src, size_t count) noexcept = nullptr;
void(*RGBA8ToBGRA8)(uint32_t* __restrict dest, const uint32_t* __restrict src, size_t count) noexcept = nullptr;
void(*RGBA8ToR8 )(uint8_t* __restrict dest, const uint32_t* __restrict src, size_t count) noexcept = nullptr;
void(*RGBA8ToG8 )(uint8_t* __restrict dest, const uint32_t* __restrict src, size_t count) noexcept = nullptr;
void(*RGBA8ToB8 )(uint8_t* __restrict dest, const uint32_t* __restrict src, size_t count) noexcept = nullptr;
void(*RGBA8ToA8 )(uint8_t* __restrict dest, const uint32_t* __restrict src, size_t count) noexcept = nullptr;
void(*RGB8ToR8 )(uint8_t* __restrict dest, const uint8_t* __restrict src, size_t count) noexcept = nullptr;
void(*RGB8ToG8 )(uint8_t* __restrict dest, const uint8_t* __restrict src, size_t count) noexcept = nullptr;
void(*RGB8ToB8 )(uint8_t* __restrict dest, const uint8_t* __restrict src, size_t count) noexcept = nullptr;
void(*RGBA8ToRA8 )(uint16_t* __restrict dest, const uint32_t* __restrict src, size_t count) noexcept = nullptr;
void(*RGBA8ToGA8 )(uint16_t* __restrict dest, const uint32_t* __restrict src, size_t count) noexcept = nullptr;
void(*RGBA8ToBA8 )(uint16_t* __restrict dest, const uint32_t* __restrict src, size_t count) noexcept = nullptr;
public:
IMGUTILAPI [[nodiscard]] static common::span<const PathInfo> GetSupportMap() noexcept;
IMGUTILAPI ColorConvertor(common::span<const VarItem> requests = {}) noexcept;
Expand All @@ -54,21 +58,41 @@ class ColorConvertor final : public common::RuntimeFastPath<ColorConvertor>
GA8ToRGBA8(dest, src, count);
}

forceinline void GrayAToGray(uint8_t* const dest, const uint16_t* src, const size_t count) const noexcept
{
CopyEx.TruncCopy(dest, src, count);
}

forceinline void RGBToRGBA(uint32_t* const dest, const uint8_t* src, const size_t count, const std::byte alpha = std::byte(0xff)) const noexcept
{
RGB8ToRGBA8(dest, src, count, alpha);
}

forceinline void GrayAToGray(uint8_t* const dest, const uint16_t* src, const size_t count) const noexcept
forceinline void BGRToRGBA(uint32_t* const dest, const uint8_t* src, const size_t count, const std::byte alpha = std::byte(0xff)) const noexcept
{
CopyEx.TruncCopy(dest, src, count);
BGR8ToRGBA8(dest, src, count, alpha);
}

forceinline void RGBAToRGB(uint8_t* const dest, const uint32_t* src, const size_t count) const noexcept
{
RGBA8ToRGB8(dest, src, count);
}

forceinline void RGBAToBGR(uint8_t* const dest, const uint32_t* src, const size_t count) const noexcept
{
RGBA8ToBGR8(dest, src, count);
}

forceinline void RGBToBGR(uint8_t* const dest, const uint8_t* src, const size_t count) const noexcept
{
RGB8ToBGR8(dest, src, count);
}

forceinline void RGBAToBGRA(uint32_t* const dest, const uint32_t* src, const size_t count) const noexcept
{
RGBA8ToBGRA8(dest, src, count);
}

forceinline void RGBAGetChannel(uint8_t* const dest, const uint32_t* src, const size_t count, const uint8_t channel) const noexcept
{
switch (channel)
Expand Down
Loading

0 comments on commit b37e374

Please sign in to comment.