adding vulkan images, start using images for put_pixel

This commit is contained in:
Kbz-8
2023-01-25 21:46:58 +01:00
parent 659f6cc14e
commit b170354e7f
16 changed files with 374 additions and 95 deletions

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/12/17 23:33:34 by maldavid #+# #+# */
/* Updated: 2023/01/23 18:28:12 by maldavid ### ########.fr */
/* Updated: 2023/01/25 15:24:19 by maldavid ### ########.fr */
/* */
/* ************************************************************************** */
@@ -27,45 +27,21 @@ namespace mlx
{
namespace RCore
{
const char* verbaliseResultVk(VkResult result)
uint32_t findMemoryType(uint32_t typeFilter, VkMemoryPropertyFlags properties)
{
switch(result)
VkPhysicalDeviceMemoryProperties memProperties;
vkGetPhysicalDeviceMemoryProperties(Render_Core::get().getDevice().getPhysicalDevice(), &memProperties);
for(uint32_t i = 0; i < memProperties.memoryTypeCount; i++)
{
case VK_SUCCESS: return "Success";
case VK_NOT_READY: return "A fence or query has not yet completed";
case VK_TIMEOUT: return "A wait operation has not completed in the specified time";
case VK_EVENT_SET: return "An event is signaled";
case VK_EVENT_RESET: return "An event is unsignaled";
case VK_INCOMPLETE: return "A return array was too small for the result";
case VK_ERROR_OUT_OF_HOST_MEMORY: return "A host memory allocation has failed";
case VK_ERROR_OUT_OF_DEVICE_MEMORY: return "A device memory allocation has failed";
case VK_ERROR_INITIALIZATION_FAILED: return "Initialization of an object could not be completed for implementation-specific reasons";
case VK_ERROR_DEVICE_LOST: return "The logical or physical device has been lost";
case VK_ERROR_MEMORY_MAP_FAILED: return "Mapping of a memory object has failed";
case VK_ERROR_LAYER_NOT_PRESENT: return "A requested layer is not present or could not be loaded";
case VK_ERROR_EXTENSION_NOT_PRESENT: return "A requested extension is not supported";
case VK_ERROR_FEATURE_NOT_PRESENT: return "A requested feature is not supported";
case VK_ERROR_INCOMPATIBLE_DRIVER: return "The requested version of Vulkan is not supported by the driver or is otherwise incompatible";
case VK_ERROR_TOO_MANY_OBJECTS: return "Too many objects of the type have already been created";
case VK_ERROR_FORMAT_NOT_SUPPORTED: return "A requested format is not supported on this device";
case VK_ERROR_SURFACE_LOST_KHR: return "A surface is no longer available";
case VK_SUBOPTIMAL_KHR: return "A swapchain no longer matches the surface properties exactly, but can still be used";
case VK_ERROR_OUT_OF_DATE_KHR: return "A surface has changed in such a way that it is no longer compatible with the swapchain";
case VK_ERROR_INCOMPATIBLE_DISPLAY_KHR: return "The display used by a swapchain does not use the same presentable image layout";
case VK_ERROR_NATIVE_WINDOW_IN_USE_KHR: return "The requested window is already connected to a VkSurfaceKHR, or to some other non-Vulkan API";
case VK_ERROR_VALIDATION_FAILED_EXT: return "A validation layer found an error";
default: return "Unknown Vulkan error";
if((typeFilter & (1 << i)) && (memProperties.memoryTypes[i].propertyFlags & properties) == properties)
return i;
}
}
void checkVk(VkResult result)
{
if(result != 0)
core::error::report(result < 0 ? e_kind::fatal_error : e_kind::error, "Vulkan error : %s", verbaliseResultVk(result));
core::error::report(e_kind::fatal_error, "Vulkan : failed to find suitable memory type");
return -1; // just to avoid warning
}
}
void Render_Core::init()
{
volkInitialize();

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/08 19:16:32 by maldavid #+# #+# */
/* Updated: 2022/12/19 14:16:25 by maldavid ### ########.fr */
/* Updated: 2023/01/25 15:23:19 by maldavid ### ########.fr */
/* */
/* ************************************************************************** */
@@ -25,10 +25,10 @@
namespace mlx
{
namespace RCore
{
void checkVk(VkResult result);
}
namespace RCore
{
uint32_t findMemoryType(uint32_t typeFilter, VkMemoryPropertyFlags properties);
}
#ifndef NDEBUG
constexpr const bool enableValidationLayers = true;

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/08 19:04:21 by maldavid #+# #+# */
/* Updated: 2022/12/19 14:26:31 by maldavid ### ########.fr */
/* Updated: 2023/01/25 15:28:18 by maldavid ### ########.fr */
/* */
/* ************************************************************************** */
@@ -17,8 +17,6 @@
namespace mlx
{
namespace RCore { const char* verbaliseResultVk(VkResult result); }
void Instance::init()
{
VkApplicationInfo appInfo{};
@@ -56,7 +54,7 @@ namespace mlx
VkResult res;
if((res = vkCreateInstance(&createInfo, nullptr, &_instance)) != VK_SUCCESS)
core::error::report(e_kind::fatal_error, "Vulkan : failed to create Vulkan instance : %s", RCore::verbaliseResultVk(res));
core::error::report(e_kind::fatal_error, "Vulkan : failed to create Vulkan instance");
volkLoadInstance(_instance);
}