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 84c7ea0 + 1de92f9 commit 9899f18
Show file tree
Hide file tree
Showing 14 changed files with 176 additions and 6 deletions.
3 changes: 2 additions & 1 deletion include/renderer/alloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@

# ifdef PLATFORM_LINUX
# ifndef _aligned_malloc
# define _aligned_malloc(...) aligned_alloc(__VA_ARGS__)
/* NOTE: size and alignment are swapped with each other on the right */
# define _aligned_malloc(size, alignment) aligned_alloc(alignment, size)
# endif /* _aligned_malloc */
# ifndef _aligned_free
# define _aligned_free(...) free(__VA_ARGS__)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
/*
***This is computer generated notice - Do not modify it***
VulkanRenderer (inclusive of its dependencies and subprojects
such as toolchains written by the same author) is a software to render
2D & 3D geometries by writing C/C++ code and shaders.
File: vulkan_render_pass_create_info_builder.h is a part of VulkanRenderer
Copyright (C) 2021 - 2024 Author: Ravi Prakash Singh
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

#pragma once

#include <renderer/defines.h>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
/*
***This is computer generated notice - Do not modify it***
VulkanRenderer (inclusive of its dependencies and subprojects
such as toolchains written by the same author) is a software to render
2D & 3D geometries by writing C/C++ code and shaders.
File: vulkan_shader_resource_description_builder.h is a part of VulkanRenderer
Copyright (C) 2021 - 2024 Author: Ravi Prakash Singh
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

#pragma once

#include <renderer/defines.h>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
/*
***This is computer generated notice - Do not modify it***
VulkanRenderer (inclusive of its dependencies and subprojects
such as toolchains written by the same author) is a software to render
2D & 3D geometries by writing C/C++ code and shaders.
File: vulkan_subpass_create_info_builder.h is a part of VulkanRenderer
Copyright (C) 2021 - 2024 Author: Ravi Prakash Singh
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

#pragma once

#include <renderer/defines.h>
Expand Down
2 changes: 1 addition & 1 deletion include/renderer/object.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
such as toolchains written by the same author) is a software to render
2D & 3D geometries by writing C/C++ code and shaders.
File: vulkan_object.h is a part of VulkanRenderer
File: object.h is a part of VulkanRenderer
Copyright (C) 2021 - 2024 Author: Ravi Prakash Singh
Expand Down
9 changes: 9 additions & 0 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,15 @@ ifeq ($(METRICS),1)
DEFINES += -DMEMORY_METRICS
endif

ifeq ($(VULKAN_ALLOCATOR),1)
DEFINES += -DUSE_VULKAN_ALLOCATOR
endif

ifeq ($(GCC_G),1)
COMPILER_FLAGS += -g
LINKER_FLAGS += -g
endif

DEBUG_COMPILER_FLAGS= -g #-fsanitize=integer-divide-by-zero // why it is not working on windows 64 bit?
DEBUG_LINKER_FLAGS= -g #-fsanitize=integer-divide-by-zero // why it is not working on windows 64 bit?

Expand Down
6 changes: 4 additions & 2 deletions source/renderer/vulkan/vulkan_allocator.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
static void* VKAPI_CALL vulkan_allocation(void* user_data, size_t size, size_t align, VkSystemAllocationScope allocation_scope)
{
vulkan_allocator_t* vk_allocator = CAST_TO(vulkan_allocator_t*, user_data);
size = size + (align - (size % align)) % align;
void* address = memory_allocator_aligned_alloc(vk_allocator->allocator, MEMORY_ALLOCATION_TYPE_VKAPI, size, align);
_debug_assert__((CAST_TO(u64, address) % align) == 0);
return address;
Expand All @@ -45,8 +46,9 @@ static void* VKAPI_CALL vulkan_reallocation(void* user_data, void* original, siz

static void VKAPI_CALL vulkan_free(void* user_data, void* memory)
{
heap_silent_aligned_free(memory);
// memory_allocator_dealloc(CAST_TO(vulkan_allocator_t*, user_data)->allocator, memory);
if(memory == NULL)
return;
memory_allocator_dealloc(CAST_TO(vulkan_allocator_t*, user_data)->allocator, memory);
}

static void VKAPI_CALL vulkan_internal_allocation_notification(void* user_data, size_t size, VkInternalAllocationType allocation_type, VkSystemAllocationScope allocation_scope)
Expand Down
6 changes: 5 additions & 1 deletion source/renderer/vulkan/vulkan_instance.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,11 @@ RENDERER_API vulkan_instance_t* vulkan_instance_create(vulkan_renderer_t* render
else
DEBUG_LOG_WARNING("Layer %s is not supported, ignored", layers[i]);
}
memory_allocator_dealloc(renderer->allocator, layer_filter);
if(layer_count > 0)
{
_debug_assert__(layer_filter != NULL);
memory_allocator_dealloc(renderer->allocator, layer_filter);
}

VkInstanceCreateInfo create_info =
{
Expand Down
25 changes: 25 additions & 0 deletions source/renderer/vulkan/vulkan_render_pass_create_info_builder.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
/*
***This is computer generated notice - Do not modify it***
VulkanRenderer (inclusive of its dependencies and subprojects
such as toolchains written by the same author) is a software to render
2D & 3D geometries by writing C/C++ code and shaders.
File: vulkan_render_pass_create_info_builder.c is a part of VulkanRenderer
Copyright (C) 2021 - 2024 Author: Ravi Prakash Singh
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

#include <renderer/internal/vulkan/vulkan_render_pass_create_info_builder.h>
#include <renderer/internal/vulkan/vulkan_subpass_create_info_builder.h>
#include <renderer/internal/vulkan/vulkan_shader_resource_description_builder.h>
Expand Down
2 changes: 1 addition & 1 deletion source/renderer/vulkan/vulkan_render_queue.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ RENDERER_API void vulkan_render_queue_destroy(vulkan_render_queue_t* queue)
subpass_shader_list_t* lists = DEREF_TO(subpass_shader_list_t*, dictionary_get_value_ptr_at(&queue->render_pass_handles, i));
u32 subpass_count = vulkan_render_pass_pool_getH(queue->renderer->render_pass_pool, DEREF_TO(vulkan_render_pass_handle_t, dictionary_get_key_ptr_at(&queue->render_pass_handles, i)))->subpass_count;
for(u32 j = 0; j < subpass_count; j++)
buf_free(&lists[i]);
buf_free(&lists[j]);
memory_allocator_dealloc(queue->renderer->allocator, lists);
}
dictionary_clear(&queue->render_pass_handles);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
/*
***This is computer generated notice - Do not modify it***
VulkanRenderer (inclusive of its dependencies and subprojects
such as toolchains written by the same author) is a software to render
2D & 3D geometries by writing C/C++ code and shaders.
File: vulkan_shader_resource_description_builder.c is a part of VulkanRenderer
Copyright (C) 2021 - 2024 Author: Ravi Prakash Singh
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

#include <renderer/internal/vulkan/vulkan_shader_resource_description_builder.h>
#include <renderer/memory_allocator.h>
#include <renderer/assert.h>
Expand Down
25 changes: 25 additions & 0 deletions source/renderer/vulkan/vulkan_subpass_create_info_builder.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
/*
***This is computer generated notice - Do not modify it***
VulkanRenderer (inclusive of its dependencies and subprojects
such as toolchains written by the same author) is a software to render
2D & 3D geometries by writing C/C++ code and shaders.
File: vulkan_subpass_create_info_builder.c is a part of VulkanRenderer
Copyright (C) 2021 - 2024 Author: Ravi Prakash Singh
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

#include <renderer/internal/vulkan/vulkan_subpass_create_info_builder.h>
#include <renderer/internal/vulkan/vulkan_shader_resource_description_builder.h>
#include <renderer/memory_allocator.h>
Expand Down
2 changes: 2 additions & 0 deletions source/tests/depth_cube_render_texture.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ TEST_ON_INITIALIZE(DEPTH_CUBE_RENDER_TEXTURE)
mesh3d_transform_set(torusMeshData, mat4_rotation(0, 0, 30 DEG));

this->mesh = mesh_create(renderer, torusMeshData);
mesh3d_destroy(torusMeshData);
this->render_object = render_scene_getH(this->scene, render_scene_create_object(this->scene, RENDER_OBJECT_TYPE_MESH, RENDER_QUEUE_TYPE_QUEUE0));
render_object_set_material(this->render_object, this->material);
render_object_attach(this->render_object, this->mesh);
Expand All @@ -155,6 +156,7 @@ TEST_ON_INITIALIZE(DEPTH_CUBE_RENDER_TEXTURE)

mesh3d_flip_triangles(cubeMeshData);
this->skyboxMesh = mesh_create(renderer, cubeMeshData);
mesh3d_destroy(cubeMeshData);
this->skyboxObject = render_scene_getH(this->scene, render_scene_create_object(this->scene, RENDER_OBJECT_TYPE_MESH, RENDER_QUEUE_TYPE_BACKGROUND));
render_object_set_material(this->skyboxObject, this->skyboxMaterial);
render_object_attach(this->skyboxObject, this->skyboxMesh);
Expand Down
2 changes: 2 additions & 0 deletions source/tests/depth_cube_render_texture.load.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ TEST_ON_INITIALIZE(DEPTH_CUBE_RENDER_TEXTURE_LOAD)
mesh3d_transform_set(torusMeshData, mat4_rotation(0, 0, 30 DEG));

this->mesh = mesh_create(renderer, torusMeshData);
mesh3d_destroy(torusMeshData);
this->render_object = render_scene_getH(this->scene, render_scene_create_object(this->scene, RENDER_OBJECT_TYPE_MESH, RENDER_QUEUE_TYPE_QUEUE0));
render_object_set_material(this->render_object, this->material);
render_object_attach(this->render_object, this->mesh);
Expand All @@ -156,6 +157,7 @@ TEST_ON_INITIALIZE(DEPTH_CUBE_RENDER_TEXTURE_LOAD)

mesh3d_flip_triangles(cubeMeshData);
this->skyboxMesh = mesh_create(renderer, cubeMeshData);
mesh3d_destroy(cubeMeshData);
this->skyboxObject = render_scene_getH(this->scene, render_scene_create_object(this->scene, RENDER_OBJECT_TYPE_MESH, RENDER_QUEUE_TYPE_BACKGROUND));
render_object_set_material(this->skyboxObject, this->skyboxMaterial);
render_object_attach(this->skyboxObject, this->skyboxMesh);
Expand Down

0 comments on commit 9899f18

Please sign in to comment.