mirror of
https://github.com/seekrs/MacroLibX.git
synced 2026-01-12 23:23:34 +00:00
adding pixel put pipeline
This commit is contained in:
35
src/renderer/images/texture.cpp
git.filemode.normal_file
35
src/renderer/images/texture.cpp
git.filemode.normal_file
@@ -0,0 +1,35 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* texture.cpp :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/03/31 18:03:35 by maldavid #+# #+# */
|
||||
/* Updated: 2023/03/31 18:06:26 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <renderer/images/texture.h>
|
||||
#include <renderer/buffers/vk_buffer.h>
|
||||
|
||||
namespace mlx
|
||||
{
|
||||
void Texture::create(uint8_t* pixels, uint32_t width, uint32_t height, VkFormat format)
|
||||
{
|
||||
Image::create(width, height, format,
|
||||
VK_IMAGE_TILING_OPTIMAL,
|
||||
VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_SAMPLED_BIT,
|
||||
VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT
|
||||
);
|
||||
|
||||
Image::createImageView(VK_IMAGE_VIEW_TYPE_2D, VK_IMAGE_ASPECT_COLOR_BIT);
|
||||
Image::createSampler();
|
||||
|
||||
Buffer staging_buffer;
|
||||
std::size_t size = width * height * (format == VK_FORMAT_R32G32B32A32_SFLOAT ? 16 : 4);
|
||||
staging_buffer.create(Buffer::kind::dynamic, size, VK_BUFFER_USAGE_TRANSFER_SRC_BIT, pixels);
|
||||
Image::copyBuffer(staging_buffer);
|
||||
staging_buffer.destroy();
|
||||
}
|
||||
}
|
||||
@@ -6,11 +6,24 @@
|
||||
/* By: maldavid <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/03/08 02:24:58 by maldavid #+# #+# */
|
||||
/* Updated: 2023/03/08 02:25:18 by maldavid ### ########.fr */
|
||||
/* Updated: 2023/03/31 18:06:09 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef __MLX_TEXTURE__
|
||||
#define __MLX_TEXTURE__
|
||||
|
||||
#include <renderer/images/vk_image.h>
|
||||
|
||||
namespace mlx
|
||||
{
|
||||
class Texture : public Image
|
||||
{
|
||||
public:
|
||||
Texture() = default;
|
||||
void create(uint8_t* pixels, uint32_t width, uint32_t height, VkFormat format);
|
||||
~Texture() = default;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -6,12 +6,14 @@
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/01/25 11:59:07 by maldavid #+# #+# */
|
||||
/* Updated: 2023/03/08 02:24:10 by maldavid ### ########.fr */
|
||||
/* Updated: 2023/03/31 12:26:08 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "vk_image.h"
|
||||
#include <renderer/core/render_core.h>
|
||||
#include <renderer/buffers/vk_buffer.h>
|
||||
#include <renderer/command/vk_cmd_pool.h>
|
||||
|
||||
namespace mlx
|
||||
{
|
||||
@@ -100,7 +102,7 @@ namespace mlx
|
||||
info.maxAnisotropy = 1.0f;
|
||||
|
||||
if(vkCreateSampler(Render_Core::get().getDevice().get(), &info, nullptr, &_sampler) != VK_SUCCESS)
|
||||
Core::log::report(FATAL_ERROR, "Vulkan : unable to create image sampler");
|
||||
core::error::report(e_kind::fatal_error, "Vulkan : failed to create an image");
|
||||
}
|
||||
|
||||
void Image::copyBuffer(Buffer& buffer)
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/01/25 11:54:21 by maldavid #+# #+# */
|
||||
/* Updated: 2023/03/08 02:15:00 by maldavid ### ########.fr */
|
||||
/* Updated: 2023/03/31 18:04:35 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -27,6 +27,8 @@ namespace mlx
|
||||
Image() = default;
|
||||
|
||||
void create(uint32_t width, uint32_t height, VkFormat format, VkImageTiling tiling, VkImageUsageFlags usage, VkMemoryPropertyFlags properties);
|
||||
void createImageView(VkImageViewType type, VkImageAspectFlags aspectFlags) noexcept;
|
||||
void createSampler() noexcept;
|
||||
void copyBuffer(class Buffer& buffer);
|
||||
void destroy() noexcept;
|
||||
|
||||
@@ -39,10 +41,6 @@ namespace mlx
|
||||
|
||||
virtual ~Image() = default;
|
||||
|
||||
protected:
|
||||
void createImageView(VkImageViewType type, VkImageAspectFlags aspectFlags) noexcept;
|
||||
void createSampler() noexcept;
|
||||
|
||||
private:
|
||||
DescriptorSet _desc;
|
||||
VkImage _image = VK_NULL_HANDLE;
|
||||
|
||||
Reference in New Issue
Block a user