create vulkan textures

This commit is contained in:
Greg Wells
2025-06-08 17:35:35 -04:00
parent 6587db282d
commit 01b1e1fb7a
2 changed files with 44 additions and 0 deletions

View File

@@ -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;
}

View File

@@ -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);
}