diff --git a/rendering_api/vulkan/src/textures/vulkan_texure.c b/rendering_api/vulkan/src/textures/vulkan_texure.c new file mode 100644 index 0000000..9ec106b --- /dev/null +++ b/rendering_api/vulkan/src/textures/vulkan_texure.c @@ -0,0 +1,36 @@ +#include "vulkan_surface/vulkan_surface.h" +#include "vulkan_texture.h" +#include "output_device/vulkan_output_devices.h" + +VkImageType vkGryphnTextureType(gnTextureType type) { +switch(type) { +case GN_TEXTURE_2D: return VK_IMAGE_TYPE_3D; +} +} + +gnReturnCode gnCreateTextureFn(gnTexture texture, gnDevice device, const gnTextureInfo info) { + texture->texture = malloc(sizeof(struct gnPlatformTexture_t)); + + VkImageCreateInfo imageInfo = { + .sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, + .sharingMode = VK_SHARING_MODE_EXCLUSIVE, + .tiling = VK_IMAGE_TILING_OPTIMAL, + .initialLayout = VK_IMAGE_LAYOUT_UNDEFINED, + .usage = VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT, + .samples = VK_SAMPLE_COUNT_1_BIT, + .extent = { + .width = info.width, + .height = info.height, + .depth = 1 + }, + .mipLevels = 1, + .arrayLayers = 1, + .imageType = vkGryphnTextureType(info.type), + .format = vkGryphnFormatToVulkanFormat(info.format) + }; + + if (vkCreateImage(device->outputDevice->device, &imageInfo, NULL, &texture->texture->image) != VK_SUCCESS) + return GN_FAILED_TO_CREATE_IMAGE; + + return GN_SUCCESS; +} diff --git a/src/core/textures/gryphn_texture.c b/src/core/textures/gryphn_texture.c new file mode 100644 index 0000000..c134218 --- /dev/null +++ b/src/core/textures/gryphn_texture.c @@ -0,0 +1,8 @@ +#include "gryphn_texture.h" +#include "core/gryphn_platform_functions.h" + +gnReturnCode gnCreateTexture(gnTexture* texture, gnDevice device, const gnTextureInfo info) { + *texture = malloc(sizeof(struct gnTexture_t)); + (*texture)->device = device; + return device->deviceFunctions->_gnCreateTexture(*texture, device, info); +}