mirror of
https://github.com/seekrs/MacroLibX.git
synced 2026-01-11 22:53:34 +00:00
adding profiler
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/03/31 18:03:35 by maldavid #+# #+# */
|
||||
/* Updated: 2023/12/31 00:49:16 by maldavid ### ########.fr */
|
||||
/* Updated: 2024/01/10 18:28:11 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include <renderer/images/texture.h>
|
||||
#include <renderer/buffers/vk_buffer.h>
|
||||
#include <renderer/renderer.h>
|
||||
#include <core/profiler.h>
|
||||
#include <cstring>
|
||||
|
||||
#define STB_IMAGE_IMPLEMENTATION
|
||||
@@ -31,6 +32,7 @@ namespace mlx
|
||||
{
|
||||
void Texture::create(uint8_t* pixels, uint32_t width, uint32_t height, VkFormat format, const char* name, bool dedicated_memory)
|
||||
{
|
||||
MLX_PROFILE_FUNCTION();
|
||||
Image::create(width, height, format, TILING, VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_SAMPLED_BIT, name, dedicated_memory);
|
||||
Image::createImageView(VK_IMAGE_VIEW_TYPE_2D, VK_IMAGE_ASPECT_COLOR_BIT);
|
||||
Image::createSampler();
|
||||
@@ -79,6 +81,7 @@ namespace mlx
|
||||
|
||||
void Texture::setPixel(int x, int y, uint32_t color) noexcept
|
||||
{
|
||||
MLX_PROFILE_FUNCTION();
|
||||
if(x < 0 || y < 0 || static_cast<uint32_t>(x) > getWidth() || static_cast<uint32_t>(y) > getHeight())
|
||||
return;
|
||||
if(_map == nullptr)
|
||||
@@ -89,6 +92,7 @@ namespace mlx
|
||||
|
||||
int Texture::getPixel(int x, int y) noexcept
|
||||
{
|
||||
MLX_PROFILE_FUNCTION();
|
||||
if(x < 0 || y < 0 || static_cast<uint32_t>(x) > getWidth() || static_cast<uint32_t>(y) > getHeight())
|
||||
return 0;
|
||||
if(_map == nullptr)
|
||||
@@ -99,6 +103,7 @@ namespace mlx
|
||||
|
||||
void Texture::openCPUmap()
|
||||
{
|
||||
MLX_PROFILE_FUNCTION();
|
||||
if(_map != nullptr)
|
||||
return;
|
||||
|
||||
@@ -123,6 +128,7 @@ namespace mlx
|
||||
|
||||
void Texture::render(Renderer& renderer, int x, int y)
|
||||
{
|
||||
MLX_PROFILE_FUNCTION();
|
||||
if(_has_been_modified)
|
||||
{
|
||||
std::memcpy(_map, _cpu_map.data(), _cpu_map.size() * formatSize(getFormat()));
|
||||
@@ -139,6 +145,7 @@ namespace mlx
|
||||
|
||||
void Texture::destroy() noexcept
|
||||
{
|
||||
MLX_PROFILE_FUNCTION();
|
||||
Image::destroy();
|
||||
if(_buf_map.has_value())
|
||||
_buf_map->destroy();
|
||||
@@ -148,6 +155,7 @@ namespace mlx
|
||||
|
||||
Texture stbTextureLoad(std::filesystem::path file, int* w, int* h)
|
||||
{
|
||||
MLX_PROFILE_FUNCTION();
|
||||
Texture texture;
|
||||
int channels;
|
||||
uint8_t* data = nullptr;
|
||||
|
||||
Reference in New Issue
Block a user