mirror of
https://github.com/seekrs/MacroLibX.git
synced 2026-01-11 14:43:34 +00:00
fixing gcc/msvc error
This commit is contained in:
@@ -53,12 +53,12 @@ namespace mlx
|
|||||||
|
|
||||||
void* MemManager::Realloc(void* ptr, std::size_t size)
|
void* MemManager::Realloc(void* ptr, std::size_t size)
|
||||||
{
|
{
|
||||||
void* ptr2 = std::realloc(ptr, size);
|
|
||||||
if(ptr2 != nullptr)
|
|
||||||
s_blocks.emplace_back(ptr, size, false);
|
|
||||||
auto it = std::find_if(s_blocks.begin(), s_blocks.end(), [=](const Descriptor& rhs){ return ptr == rhs.ptr; });
|
auto it = std::find_if(s_blocks.begin(), s_blocks.end(), [=](const Descriptor& rhs){ return ptr == rhs.ptr; });
|
||||||
if(it != s_blocks.end())
|
if(it != s_blocks.end())
|
||||||
s_blocks.erase(it);
|
s_blocks.erase(it);
|
||||||
|
void* ptr2 = std::realloc(ptr, size);
|
||||||
|
if(ptr2 != nullptr)
|
||||||
|
s_blocks.emplace_back(ptr2, size, false);
|
||||||
return ptr2;
|
return ptr2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,7 +79,7 @@ namespace mlx
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if(ptr2 != nullptr)
|
if(ptr2 != nullptr)
|
||||||
s_blocks.emplace_back(ptr, size, true);
|
s_blocks.emplace_back(ptr2, size, true);
|
||||||
return ptr2;
|
return ptr2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,16 @@
|
|||||||
|
|
||||||
namespace mlx
|
namespace mlx
|
||||||
{
|
{
|
||||||
|
mlx_color ReverseColor(mlx_color color)
|
||||||
|
{
|
||||||
|
mlx_color reversed_color;
|
||||||
|
reversed_color.r = color.a;
|
||||||
|
reversed_color.g = color.b;
|
||||||
|
reversed_color.b = color.g;
|
||||||
|
reversed_color.a = color.r;
|
||||||
|
return reversed_color;
|
||||||
|
}
|
||||||
|
|
||||||
void Image::Init(ImageType type, std::uint32_t width, std::uint32_t height, VkFormat format, VkImageTiling tiling, VkImageUsageFlags usage, bool is_multisampled, [[maybe_unused]] std::string_view debug_name)
|
void Image::Init(ImageType type, std::uint32_t width, std::uint32_t height, VkFormat format, VkImageTiling tiling, VkImageUsageFlags usage, bool is_multisampled, [[maybe_unused]] std::string_view debug_name)
|
||||||
{
|
{
|
||||||
MLX_PROFILE_FUNCTION();
|
MLX_PROFILE_FUNCTION();
|
||||||
@@ -207,7 +217,7 @@ namespace mlx
|
|||||||
if(!m_staging_buffer.has_value())
|
if(!m_staging_buffer.has_value())
|
||||||
OpenCPUBuffer();
|
OpenCPUBuffer();
|
||||||
if constexpr(std::endian::native == std::endian::little)
|
if constexpr(std::endian::native == std::endian::little)
|
||||||
m_cpu_buffer[(y * m_width) + x] = mlx_color{ .r = color.a, .g = color.b, .b = color.g, .a = color.r };
|
m_cpu_buffer[(y * m_width) + x] = ReverseColor(color);
|
||||||
else
|
else
|
||||||
m_cpu_buffer[(y * m_width) + x] = color;
|
m_cpu_buffer[(y * m_width) + x] = color;
|
||||||
m_has_been_modified = true;
|
m_has_been_modified = true;
|
||||||
@@ -232,7 +242,7 @@ namespace mlx
|
|||||||
moving_y++;
|
moving_y++;
|
||||||
}
|
}
|
||||||
if constexpr(std::endian::native == std::endian::little)
|
if constexpr(std::endian::native == std::endian::little)
|
||||||
m_cpu_buffer[(moving_y * m_width) + moving_x] = mlx_color{ .r = pixels[i].a, .g = pixels[i].b, .b = pixels[i].g, .a = pixels[i].r };
|
m_cpu_buffer[(moving_y * m_width) + moving_x] = ReverseColor(pixels[i]);
|
||||||
else
|
else
|
||||||
m_cpu_buffer[(moving_y * m_width) + moving_x] = pixels[i];
|
m_cpu_buffer[(moving_y * m_width) + moving_x] = pixels[i];
|
||||||
}
|
}
|
||||||
@@ -248,7 +258,7 @@ namespace mlx
|
|||||||
OpenCPUBuffer();
|
OpenCPUBuffer();
|
||||||
if constexpr(std::endian::native == std::endian::little)
|
if constexpr(std::endian::native == std::endian::little)
|
||||||
for(std::size_t i = 0; i < len; i++)
|
for(std::size_t i = 0; i < len; i++)
|
||||||
m_cpu_buffer[(y * m_width) + x + i] = mlx_color{ .r = pixels[i].a, .g = pixels[i].b, .b = pixels[i].g, .a = pixels[i].r };
|
m_cpu_buffer[(y * m_width) + x + i] = ReverseColor(pixels[i]);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::memcpy(&m_cpu_buffer[(y * m_width) + x], pixels, len);
|
std::memcpy(&m_cpu_buffer[(y * m_width) + x], pixels, len);
|
||||||
@@ -264,10 +274,7 @@ namespace mlx
|
|||||||
if(!m_staging_buffer.has_value())
|
if(!m_staging_buffer.has_value())
|
||||||
OpenCPUBuffer();
|
OpenCPUBuffer();
|
||||||
if constexpr(std::endian::native == std::endian::little)
|
if constexpr(std::endian::native == std::endian::little)
|
||||||
{
|
return ReverseColor(m_cpu_buffer[(y * m_width) + x]);
|
||||||
mlx_color color = m_cpu_buffer[(y * m_width) + x];
|
|
||||||
return { .r = color.a, .g = color.b, .b = color.g, .a = color.r };
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
return m_cpu_buffer[(y * m_width) + x];
|
return m_cpu_buffer[(y * m_width) + x];
|
||||||
}
|
}
|
||||||
@@ -289,10 +296,7 @@ namespace mlx
|
|||||||
moving_y++;
|
moving_y++;
|
||||||
}
|
}
|
||||||
if constexpr(std::endian::native == std::endian::little)
|
if constexpr(std::endian::native == std::endian::little)
|
||||||
{
|
dst[i] = ReverseColor(m_cpu_buffer[(moving_y * m_width) + moving_x]);
|
||||||
mlx_color color = m_cpu_buffer[(moving_y * m_width) + moving_x];
|
|
||||||
dst[i] = mlx_color{ .r = color.a, .g = color.b, .b = color.g, .a = color.r };
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
dst[i] = m_cpu_buffer[(moving_y * m_width) + moving_x];
|
dst[i] = m_cpu_buffer[(moving_y * m_width) + moving_x];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user