Skip to content

Commit

Permalink
Merge remote-tracking branch 'gitlab/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
ravi688 committed May 10, 2024
2 parents 7afefc4 + f02d5a4 commit 84c7ea0
Show file tree
Hide file tree
Showing 26 changed files with 157 additions and 84 deletions.
11 changes: 11 additions & 0 deletions include/renderer/bitmap_glyph_pool.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <renderer/defines.h>
#include <renderer/font.h> // font_t, utf32_t
#include <renderer/buffer2d.h> // buffer2d_t
#include <renderer/object.h>
#include <hpml/vec2.h>

/* stores texture coordinates of a glyph */
Expand Down Expand Up @@ -57,18 +58,28 @@ typedef struct bitmap_glyph_pool_create_info_t

typedef struct bitmap_glyph_pool_t
{
__OBJECT__;
renderer_t* renderer;
font_t* font;
buffer2d_t pixels;
} bitmap_glyph_pool_t;

#define BITMAP_GLYPH_POOL(ptr) OBJECT_UP_CAST(bitmap_glyph_pool_t*, OBJECT_TYPE_BITMAP_GLYPH_POOL, ptr)
#define BITMAP_GLYPH_POOL_CONST(ptr) OBJECT_UP_CAST_CONST(const bitmap_glyph_pool_t*, OBJECT_TYPE_BITMAP_GLYPH_POOL, ptr)


BEGIN_CPP_COMPATIBLE

/* constructors and destructors */
RENDERER_API bitmap_glyph_pool_t* bitmap_glyph_pool_new(memory_allocator_t* allocator);
RENDERER_API bitmap_glyph_pool_t* bitmap_glyph_pool_create(renderer_t* renderer, bitmap_glyph_pool_create_info_t* create_info);
RENDERER_API void bitmap_glyph_pool_create_no_alloc(renderer_t* renderer, bitmap_glyph_pool_create_info_t* create_info, bitmap_glyph_pool_t OUT pool);
static CAN_BE_UNUSED_FUNCTION INLINE_IF_RELEASE_MODE void bitmap_glyph_pool_create_no_alloc_ext(renderer_t* renderer, bitmap_glyph_pool_create_info_t* create_info, bitmap_glyph_pool_t OUT pool)
{
OBJECT_INIT(pool, OBJECT_TYPE_BITMAP_GLYPH_POOL, OBJECT_NATIONALITY_EXTERNAL);
bitmap_glyph_pool_create_no_alloc(renderer, create_info, pool);
}

RENDERER_API void bitmap_glyph_pool_destroy(bitmap_glyph_pool_t* pool);
RENDERER_API void bitmap_glyph_pool_release_resources(bitmap_glyph_pool_t* pool);

Expand Down
10 changes: 10 additions & 0 deletions include/renderer/buffer2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include <renderer/hash_table.h> // hash_table_t, comparer_t, hash_function_t
#include <renderer/buffer2d_view.h> // buffer2d_view_t, isize2d_t, ioffset2d_t
#include <renderer/rect.h> // irect2d_t
#include <renderer/object.h>

#ifdef GLOBAL_DEBUG
# include <renderer/color.h> // color3_t
Expand Down Expand Up @@ -99,6 +100,7 @@ typedef void (*packed_rect_relocate_callback_t)(const rect2d_info_t* before, con

typedef struct buffer2d_t
{
__OBJECT__;
memory_allocator_t* allocator;

#if DBG_ENABLED(BUFFER2D_RESIZE)
Expand Down Expand Up @@ -128,12 +130,20 @@ typedef struct buffer2d_t

typedef buffer2d_t* buffer2d_ptr_t;

#define BUFFER2D(ptr) OBJECT_UP_CAST(buffer2d_t*, OBJECT_TYPE_BUFFER2D, ptr)
#define BUFFER2D_CONST(ptr) OBJECT_UP_CAST_CONST(const buffer2d_t*, OBJECT_TYPE_BUFFER2D, ptr)

BEGIN_CPP_COMPATIBLE

/* constructors and destructurs */
RENDERER_API buffer2d_t* buffer2d_new(memory_allocator_t* allocator);
RENDERER_API buffer2d_t* buffer2d_create(memory_allocator_t* allocator, buffer2d_create_info_t* create_info);
RENDERER_API void buffer2d_create_no_alloc(memory_allocator_t* allocator, buffer2d_create_info_t* create_info, buffer2d_t OUT buffer);
static CAN_BE_UNUSED_FUNCTION INLINE_IF_RELEASE_MODE void buffer2d_create_no_alloc_ext(memory_allocator_t* allocator, buffer2d_create_info_t* create_info, buffer2d_t OUT buffer)
{
OBJECT_INIT(buffer, OBJECT_TYPE_BUFFER2D, OBJECT_NATIONALITY_EXTERNAL);
buffer2d_create_no_alloc(allocator, create_info, buffer);
}
RENDERER_API void buffer2d_destroy(buffer2d_t* buffer);
RENDERER_API void buffer2d_release_resources(buffer2d_t* buffer);

Expand Down
10 changes: 9 additions & 1 deletion include/renderer/buffer2d_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <renderer/defines.h>
#include <bufferlib/buffer.h>
#include <renderer/rect.h> // iextent2d_t
#include <renderer/object.h>

typedef struct buffer2d_view_create_info_t
{
Expand All @@ -39,14 +40,16 @@ typedef struct buffer2d_view_create_info_t

typedef struct buffer2d_view_t
{
__OBJECT__;
memory_allocator_t* allocator;
buffer_t* backed_buffer;
iextent2d_t size;
} buffer2d_view_t;

typedef buffer2d_view_t* buffer2d_view_ptr_t;

#define BUFFER2D_VIEW(ptr) DYNAMIC_CAST(buffer2d_view_t*, ptr)
#define BUFFER2D_VIEW(ptr) OBJECT_UP_CAST(buffer2d_view_t*, OBJECT_TYPE_BUFFER2D_VIEW, ptr)
#define BUFFER2D_VIEW_CONST(ptr) OBJECT_UP_CAST_CONST(const buffer2d_view_t*, OBJECT_TYPE_BUFFER2D_VIEW, ptr)


BEGIN_CPP_COMPATIBLE
Expand All @@ -55,6 +58,11 @@ BEGIN_CPP_COMPATIBLE
RENDERER_API buffer2d_view_t* buffer2d_view_new(memory_allocator_t* allocator);
RENDERER_API buffer2d_view_t* buffer2d_view_create(memory_allocator_t* allocator, buffer2d_view_create_info_t* create_info);
RENDERER_API void buffer2d_view_create_no_alloc(memory_allocator_t* allocator, buffer2d_view_create_info_t* create_info, buffer2d_view_t OUT view);
static CAN_BE_UNUSED_FUNCTION INLINE_IF_RELEASE_MODE void buffer2d_view_create_no_alloc_ext(memory_allocator_t* allocator, buffer2d_view_create_info_t* create_info, buffer2d_view_t OUT view)
{
OBJECT_INIT(view, OBJECT_TYPE_BUFFER2D_VIEW, OBJECT_NATIONALITY_EXTERNAL);
buffer2d_view_create_no_alloc(allocator, create_info, view);
}
RENDERER_API void buffer2d_view_destroy(buffer2d_view_t* view);
RENDERER_API void buffer2d_view_release_resources(buffer2d_view_t* view);

Expand Down
5 changes: 3 additions & 2 deletions include/renderer/hash_table.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <renderer/hash_function.h> // hash_function_t
#include <renderer/multi_buffer.h> // multi_buffer_t

typedef struct memory_allocator_t memory_allocator_t;
typedef buffer_t /* sub_buffer_handle_t */ bucket_handle_list_t;

typedef struct hash_table_t
Expand All @@ -55,8 +56,8 @@ typedef hash_table_t* hash_table_ptr_t;
BEGIN_CPP_COMPATIBLE

/* constructor and destructors */
#define hash_table_create(Tkey, Tvalue, capacity, key_comparer, key_hash_function) __hash_table_create(sizeof(Tkey), sizeof(Tvalue), capacity, key_comparer, key_hash_function)
RENDERER_API hash_table_t __hash_table_create(u32 key_size, u32 value_size, u32 capacity, comparer_t key_comparer, hash_function_t key_hash_function);
#define hash_table_create(allocator, Tkey, Tvalue, capacity, key_comparer, key_hash_function) __hash_table_create(allocator, sizeof(Tkey), sizeof(Tvalue), capacity, key_comparer, key_hash_function)
RENDERER_API hash_table_t __hash_table_create(memory_allocator_t* allocator, u32 key_size, u32 value_size, u32 capacity, comparer_t key_comparer, hash_function_t key_hash_function);
RENDERER_API void hash_table_free(hash_table_t* table);

/* clears the hash table and ready to be used again */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@ typedef struct vulkan_render_pass_create_info_build_info_t
buffer_t attachment_usages;
/* non-null if set by vulkan_render_pass_create_info_builder_add_render_set_bindings_builder() */
vulkan_shader_resource_description_builder_t* render_set_bindings_builder;
bool is_destroy_render_set_bindings_builder;
/* non-null if allocated by vulkan_render_pass_create_info_builder_set_supplementary_attachment_bucket() */
VkImageView* vo_supplementary_attachments;
/* non-null if set by vulkan_render_pass_create_info_builder_set_subpasses_builder*/
vulkan_subpass_create_info_builder_t* subpasses_builder;
bool is_destroy_subpasses_builder;

bool is_use_render_set_bindings_builder;
bool is_use_subpasses_builder;
bool is_supplementary_attachments_internal;
Expand Down Expand Up @@ -59,9 +62,9 @@ RENDERER_API void vulkan_render_pass_create_info_builder_add_attachment_descript
RENDERER_API void vulkan_render_pass_create_info_builder_add_attachment_usages(vulkan_render_pass_create_info_builder_t* builder, vulkan_attachment_next_pass_usage_t* usages, u32 usage_count);

RENDERER_API void vulkan_render_pass_create_info_builder_set_render_set_bindings(vulkan_render_pass_create_info_builder_t* builder, vulkan_shader_resource_description_t* bindings, u32 binding_count);
RENDERER_API void vulkan_render_pass_create_info_builder_set_render_set_bindings_builder(vulkan_render_pass_create_info_builder_t* builder, vulkan_shader_resource_description_builder_t* srd_builder);
RENDERER_API void vulkan_render_pass_create_info_builder_set_render_set_bindings_builder(vulkan_render_pass_create_info_builder_t* builder, vulkan_shader_resource_description_builder_t* srd_builder, bool is_destroy);
RENDERER_API void vulkan_render_pass_create_info_builder_set_subpasses(vulkan_render_pass_create_info_builder_t* builder, vulkan_subpass_create_info_t* infos, u32 info_count);
RENDERER_API void vulkan_render_pass_create_info_builder_set_subpasses_builder(vulkan_render_pass_create_info_builder_t* builder, vulkan_subpass_create_info_builder_t* sci_builder);
RENDERER_API void vulkan_render_pass_create_info_builder_set_subpasses_builder(vulkan_render_pass_create_info_builder_t* builder, vulkan_subpass_create_info_builder_t* sci_builder, bool is_destroy);
RENDERER_API void vulkan_render_pass_create_info_builder_set_dependencies(vulkan_render_pass_create_info_builder_t* builder, VkSubpassDependency* dependencies, u32 dependency_count);


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ typedef struct vulkan_subpass_create_info_build_info_t
VkAttachmentReference depth_stencil_attachment;
/* non-null if set by vulkan_subpass_create_info_builder_set_render_set_bindings_builder() */
vulkan_shader_resource_description_builder_t* render_set_bindings_builder;
bool is_destroy_render_set_bindings_builder;
/* sub_render_set_bindings_internal */
bool is_render_set_bindings_internal;
bool is_color_attachments_internal;
Expand All @@ -44,7 +45,7 @@ typedef struct vulkan_subpass_create_info_builder_t
BEGIN_CPP_COMPATIBLE

RENDERER_API vulkan_subpass_create_info_builder_t* vulkan_subpass_create_info_builder_create(memory_allocator_t* allocator);
RENDERER_API void vulkan_subpass_create_info_destroy(vulkan_subpass_create_info_builder_t* builder);
RENDERER_API void vulkan_subpass_create_info_builder_destroy(vulkan_subpass_create_info_builder_t* builder);

RENDERER_API void vulkan_subpass_create_info_builder_add(vulkan_subpass_create_info_builder_t* builder, u32 count);
RENDERER_API void vulkan_subpass_create_info_builder_bind(vulkan_subpass_create_info_builder_t* builder, u32 index);
Expand All @@ -54,7 +55,7 @@ RENDERER_API u32 vulkan_subpass_create_info_builder_get_count(vulkan_subpass_cre


RENDERER_API void vulkan_subpass_create_info_builder_set_render_set_bindings(vulkan_subpass_create_info_builder_t* builder, vulkan_shader_resource_description_t* bindings, u32 binding_count);
RENDERER_API void vulkan_subpass_create_info_builder_set_render_set_bindings_builder(vulkan_subpass_create_info_builder_t* builder, vulkan_shader_resource_description_builder_t* srd_builder);
RENDERER_API void vulkan_subpass_create_info_builder_set_render_set_bindings_builder(vulkan_subpass_create_info_builder_t* builder, vulkan_shader_resource_description_builder_t* srd_builder, bool is_destroy);
RENDERER_API void vulkan_subpass_create_info_builder_set_bind_point(vulkan_subpass_create_info_builder_t* builder, VkPipelineBindPoint bind_point);
RENDERER_API void vulkan_subpass_create_info_builder_add_color_attachments(vulkan_subpass_create_info_builder_t* builder, VkAttachmentReference* attachments, u32 attachment_count);
RENDERER_API void vulkan_subpass_create_info_builder_add_input_attachments(vulkan_subpass_create_info_builder_t* builder, VkAttachmentReference* attachments, u32 attachment_count);
Expand Down
6 changes: 6 additions & 0 deletions include/renderer/object.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ typedef enum object_type_t
OBJECT_TYPE_VK_SWAPCHAIN,

OBJECT_TYPE_EVENT,
OBJECT_TYPE_BUFFER2D_VIEW,
OBJECT_TYPE_BUFFER2D,
OBJECT_TYPE_BITMAP_GLYPH_POOL,

OBJECT_TYPE_MAX,
OBJECT_TYPE_VK_AMBIENT_LIGHT = OBJECT_TYPE_VK_LIGHT,
Expand Down Expand Up @@ -136,6 +139,9 @@ static CAN_BE_UNUSED_FUNCTION const char* object_type_to_string(object_type_t ty
RETURN_STR_CASE(OBJECT_TYPE_VK_SHADER_LIBRARY);
RETURN_STR_CASE(OBJECT_TYPE_VK_SWAPCHAIN);
RETURN_STR_CASE(OBJECT_TYPE_EVENT);
RETURN_STR_CASE(OBJECT_TYPE_BUFFER2D_VIEW);
RETURN_STR_CASE(OBJECT_TYPE_BUFFER2D);
RETURN_STR_CASE(OBJECT_TYPE_BITMAP_GLYPH_POOL);
RETURN_STR_CASE(OBJECT_TYPE_MAX);
default: return "<Unknown Type>";
}
Expand Down
15 changes: 13 additions & 2 deletions include/renderer/string_builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,30 @@ BEGIN_CPP_COMPATIBLE
RENDERER_API string_builder_t* string_builder_create(memory_allocator_t* allocator, u32 capacity);
RENDERER_API void string_builder_destroy(string_builder_t* builder);

/* returns the internal string buffer */
RENDERER_API char* string_builder_get_str(string_builder_t* builder);

/* appends the formatted string to the internal character buffer */
RENDERER_API void string_builder_append(string_builder_t* builder, const char* const format, ...);
static CAN_BE_UNUSED_FUNCTION INLINE_IF_RELEASE_MODE void string_builder_append_builder(string_builder_t* builder, string_builder_t* _builder)
{
string_builder_append(builder, string_builder_get_str(_builder));
}
static CAN_BE_UNUSED_FUNCTION INLINE_IF_RELEASE_MODE void string_builder_append_builder_destroy(string_builder_t* builder, string_builder_t* _builder)
{
string_builder_append_builder(builder, _builder);
string_builder_destroy(_builder);
}

/* appends null termination character, sometimes we don't need to append that so lets keep it explicit not default */
RENDERER_API void string_builder_append_null(string_builder_t* builder);
RENDERER_API void string_builder_append_newline(string_builder_t* builder);

/* increments the indentation for the subsequent calls to string_builder_append() */
RENDERER_API void string_builder_increment_indentation(string_builder_t* builder);
/* decrements the indentiation for the subsequent calls to the string_builder_append() */
RENDERER_API void string_builder_decrement_indentation(string_builder_t* builder);

/* returns the internal string buffer */
RENDERER_API char* string_builder_get_str(string_builder_t* builder);

/* clears the string buffer and indentation buffer */
RENDERER_API void string_builder_clear(string_builder_t* builder);
Expand Down
8 changes: 5 additions & 3 deletions source/renderer/bitmap_glyph_pool.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ RENDERER_API bitmap_glyph_pool_t* bitmap_glyph_pool_new(memory_allocator_t* allo
{
bitmap_glyph_pool_t* pool = memory_allocator_alloc_obj(allocator, MEMORY_ALLOCATION_TYPE_OBJ_BITMAP_GLYPH_POOL, bitmap_glyph_pool_t);
memzero(pool, bitmap_glyph_pool_t);
OBJECT_INIT(pool, OBJECT_TYPE_BITMAP_GLYPH_POOL, OBJECT_NATIONALITY_INTERNAL);
return pool;
}

Expand All @@ -44,7 +45,7 @@ RENDERER_API bitmap_glyph_pool_t* bitmap_glyph_pool_create(renderer_t* renderer,

RENDERER_API void bitmap_glyph_pool_create_no_alloc(renderer_t* renderer, bitmap_glyph_pool_create_info_t* create_info, bitmap_glyph_pool_t OUT pool)
{
memzero(pool, bitmap_glyph_pool_t);
OBJECT_MEMZERO(pool, bitmap_glyph_pool_t);
pool->renderer = renderer;
pool->font = create_info->font;
buffer2d_create_info_t _create_info =
Expand All @@ -57,7 +58,7 @@ RENDERER_API void bitmap_glyph_pool_create_no_alloc(renderer_t* renderer, bitmap
.key_hash_function = utf32_u32_hash,
.key_comparer = utf32_u32_equal_to
};
buffer2d_create_no_alloc(renderer->allocator, &_create_info, &pool->pixels);
buffer2d_create_no_alloc_ext(renderer->allocator, &_create_info, &pool->pixels);
buffer2d_clear(&pool->pixels, NULL);
}

Expand All @@ -68,7 +69,8 @@ RENDERER_API void bitmap_glyph_pool_destroy(bitmap_glyph_pool_t* pool)

RENDERER_API void bitmap_glyph_pool_release_resources(bitmap_glyph_pool_t* pool)
{
memory_allocator_dealloc(pool->renderer->allocator, pool);
if(OBJECT_IS_INTERNAL(pool))
memory_allocator_dealloc(pool->renderer->allocator, pool);
}

RENDERER_API bool bitmap_glyph_pool_get_texcoord(bitmap_glyph_pool_t* pool, pair_t(utf32_t, u32) unicode, glyph_texcoord_t OUT texcoord, bool OUT is_resized)
Expand Down
22 changes: 13 additions & 9 deletions source/renderer/buffer2d.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ RENDERER_API buffer2d_t* buffer2d_new(memory_allocator_t* allocator)
{
buffer2d_t* buffer = memory_allocator_alloc_obj(allocator, MEMORY_ALLOCATION_TYPE_OBJ_BUFFER2D, buffer2d_t);
memzero(buffer, buffer2d_t);
OBJECT_INIT(buffer, OBJECT_TYPE_BUFFER2D, OBJECT_NATIONALITY_INTERNAL);
return buffer;
}

Expand All @@ -65,18 +66,18 @@ RENDERER_API void buffer2d_create_no_alloc(memory_allocator_t* allocator, buffer
{
debug_assert__(create_info->resize_mode == BUFFER2D_RESIZE_MODE_ASPECT_RATIO_STRICT, "For now we will only support BUFFER2D_RESIZE_MODE_ASPECT_RATIO_STRICT");

memzero(buffer, buffer2d_t);
OBJECT_MEMZERO(buffer, buffer2d_t);

buffer->allocator = allocator;

buffer->is_backed_buffer_owner = false,
buffer->resize_mode = create_info->resize_mode,
buffer->filled_rects = __hash_table_create(create_info->key_size,
buffer->filled_rects = __hash_table_create(allocator, create_info->key_size,
sizeof(filled_rect_info_t),
128,
create_info->key_comparer,
create_info->key_hash_function),
buffer->vacant_rects = hash_table_create(rect2d_info_key_t, rect2d_info_t, 512, u32_equal_to, u32_hash),
buffer->vacant_rects = hash_table_create(allocator, rect2d_info_key_t, rect2d_info_t, 512, u32_equal_to, u32_hash),
buffer->counter = 0;

/* create 2d view if not supplied by the user */
Expand Down Expand Up @@ -127,7 +128,8 @@ RENDERER_API void buffer2d_release_resources(buffer2d_t* buffer)
{
if(buffer->is_view_owner)
buffer2d_view_release_resources(buffer->view);
memory_allocator_dealloc(buffer->allocator, buffer);
if(OBJECT_IS_INTERNAL(buffer))
memory_allocator_dealloc(buffer->allocator, buffer);
}

RENDERER_API buffer_t* buffer2d_get_backed_buffer(buffer2d_t* buffer)
Expand Down Expand Up @@ -418,7 +420,7 @@ RENDERER_API void buffer2d_resize(buffer2d_t* buffer, u32 num_rows, u32 num_colu
.buffer = &old_backed_buffer
};
buffer2d_view_t old_view;
buffer2d_view_create_no_alloc(buffer->allocator, &view_create_info, &old_view);
buffer2d_view_create_no_alloc_ext(buffer->allocator, &view_create_info, &old_view);

/* resize the backed buffer (it will invalid the exisiting written data and vacant rects ) */
buffer2d_view_resize(view, num_rows, num_columns);
Expand All @@ -439,6 +441,7 @@ RENDERER_API void buffer2d_resize(buffer2d_t* buffer, u32 num_rows, u32 num_colu

/* destroy the old data */
buffer2d_view_destroy(&old_view);
buffer2d_view_release_resources(&old_view);
buf_free(&old_backed_buffer);
}

Expand Down Expand Up @@ -468,7 +471,7 @@ static void dump_filled_rect(void* key, void* value, void* user_data)

AUTO _rect = irect2d(ioffset2d(rect->rect_info.rect.offset.x * sizeof(icolor3_t), rect->rect_info.rect.offset.y),
iextent2d(rect->rect_info.rect.extent.x * sizeof(icolor3_t), rect->rect_info.rect.extent.y));
buffer2d_view_broadcast_rect(CAST_TO(buffer2d_view_t*, user_data), _rect, &rect->color, sizeof(icolor3_t));
buffer2d_view_broadcast_rect(BUFFER2D_VIEW(user_data), _rect, &rect->color, sizeof(icolor3_t));
}

static icolor3_t vacant_colors[] =
Expand All @@ -491,7 +494,7 @@ static void dump_vacant_rect(void* key, void* value, void* user_data)
static u32 counter = 0;
++counter;

buffer2d_view_broadcast_rect(CAST_TO(buffer2d_view_t*, user_data), _rect, &vacant_colors[counter % SIZEOF_ARRAY(vacant_colors)], sizeof(icolor3_t));
buffer2d_view_broadcast_rect(BUFFER2D_VIEW(user_data), _rect, &vacant_colors[counter % SIZEOF_ARRAY(vacant_colors)], sizeof(icolor3_t));
}

RENDERER_API void buffer2d_dump(buffer2d_t* buffer, const char* file_name)
Expand All @@ -500,7 +503,7 @@ RENDERER_API void buffer2d_dump(buffer2d_t* buffer, const char* file_name)
AUTO size = buffer->view->size;

/* allocate pixel data buffer */
buffer_t pixel_data = buf_create(sizeof(icolor3_t), IEXTENT2D_AREA(size), 0);
buffer_t pixel_data = memory_allocator_buf_create(buffer->allocator, sizeof(icolor3_t), IEXTENT2D_AREA(size), 0);

/* fill the pixel data buffer with WHITE color (as a background color) */
icolor3_t default_color = ICOLOR3_GREY;
Expand All @@ -518,7 +521,7 @@ RENDERER_API void buffer2d_dump(buffer2d_t* buffer, const char* file_name)
.buffer = &pixel_data
};
buffer2d_view_t view;
buffer2d_view_create_no_alloc(buffer->allocator, &view_create_info, &view);
buffer2d_view_create_no_alloc_ext(buffer->allocator, &view_create_info, &view);

/* write colors to the pixel data buffer */

Expand All @@ -533,6 +536,7 @@ RENDERER_API void buffer2d_dump(buffer2d_t* buffer, const char* file_name)

/* destroy pixel data */
buffer2d_view_destroy(&view);
buffer2d_view_release_resources(&view);
buf_free(&pixel_data);
}
#endif /* GLOBAL_DEBUG */
Loading

0 comments on commit 84c7ea0

Please sign in to comment.