mirror of
https://github.com/seekrs/MacroLibX.git
synced 2026-01-11 22:53:34 +00:00
adding image optimizations control over make call
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/03/31 15:14:50 by maldavid #+# #+# */
|
||||
/* Updated: 2023/04/23 15:24:37 by maldavid ### ########.fr */
|
||||
/* Updated: 2023/08/02 05:28:49 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -21,29 +21,23 @@ namespace mlx
|
||||
_texture.setDescriptor(renderer.getFragDescriptorSet().duplicate());
|
||||
|
||||
_buffer.create(Buffer::kind::dynamic, sizeof(uint32_t) * (width * height), VK_BUFFER_USAGE_TRANSFER_SRC_BIT);
|
||||
_buffer.mapMem(&_map);
|
||||
_buffer.mapMem(&_buffer_map);
|
||||
_cpu_map = std::vector<uint32_t>(height * width, 0);
|
||||
_width = width;
|
||||
_height = height;
|
||||
}
|
||||
|
||||
VkDescriptorSet PixelPutPipeline::getDescriptorSet() noexcept
|
||||
{
|
||||
return _texture.getSet();
|
||||
}
|
||||
|
||||
void PixelPutPipeline::setPixel(uint32_t x, uint32_t y, uint32_t color) noexcept
|
||||
{
|
||||
if(x < 0 || y < 0 || x > _width || y > _height)
|
||||
return;
|
||||
unsigned char* mem = static_cast<unsigned char*>(_map) + (y * _width * sizeof(uint32_t)) + (x * sizeof(uint32_t));
|
||||
*reinterpret_cast<uint32_t*>(mem) = color;
|
||||
_cpu_map[(y * _width) + x] = color;
|
||||
_has_been_modified = true;
|
||||
}
|
||||
|
||||
void PixelPutPipeline::clear()
|
||||
{
|
||||
unsigned char* mem = static_cast<unsigned char*>(_map);
|
||||
std::memset(mem, 0, sizeof(uint32_t) * (_width * _height));
|
||||
_cpu_map.assign(_width * _height, 0);
|
||||
_has_been_modified = true;
|
||||
}
|
||||
|
||||
@@ -51,6 +45,7 @@ namespace mlx
|
||||
{
|
||||
if(_has_been_modified)
|
||||
{
|
||||
std::memcpy(_buffer_map, _cpu_map.data(), sizeof(uint32_t) * _cpu_map.size());
|
||||
_texture.copyFromBuffer(_buffer);
|
||||
_has_been_modified = false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user