create vulkan textures
This commit is contained in:
36
rendering_api/vulkan/src/textures/vulkan_texure.c
Normal file
36
rendering_api/vulkan/src/textures/vulkan_texure.c
Normal 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;
|
||||||
|
}
|
8
src/core/textures/gryphn_texture.c
Normal file
8
src/core/textures/gryphn_texture.c
Normal 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);
|
||||||
|
}
|
Reference in New Issue
Block a user