mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 23:32:09 +00:00
[vulkan] Complete resource image and image view
I don't remember why I kept the abbreviated configs for images and image views, but it because such that I need to be able to specify them completely. In addition, image views support external images. The rest was just cleaning up after the changes to qfv_resobj_t.
This commit is contained in:
parent
ed74a6420b
commit
fd36147749
6 changed files with 56 additions and 29 deletions
|
@ -31,23 +31,30 @@ typedef struct qfv_resobj_s {
|
|||
VkBufferView view;
|
||||
} buffer_view;
|
||||
struct {
|
||||
int cubemap;
|
||||
VkImageCreateFlags flags;
|
||||
VkImageType type;
|
||||
VkFormat format;
|
||||
VkExtent3D extent;
|
||||
uint32_t num_mipmaps;
|
||||
uint32_t num_layers;
|
||||
VkSampleCountFlags samples;
|
||||
VkImageTiling tiling;
|
||||
VkImageUsageFlags usage;
|
||||
VkSharingMode sharing;
|
||||
uint32_t num_queue_inds;
|
||||
const uint32_t *queue_inds;
|
||||
VkImageLayout initialLayout;
|
||||
VkImage image;
|
||||
VkDeviceSize offset;
|
||||
} image;
|
||||
struct {
|
||||
unsigned image;
|
||||
VkImage external_image;
|
||||
VkImageViewCreateFlags flags;
|
||||
VkImageViewType type;
|
||||
VkFormat format;
|
||||
VkImageAspectFlags aspect;
|
||||
VkComponentMapping components;
|
||||
VkImageSubresourceRange subresourceRange;
|
||||
VkImageView view;
|
||||
} image_view;
|
||||
};
|
||||
|
|
|
@ -439,7 +439,11 @@ Vulkan_Mod_IQMFinish (model_t *mod, vulkan_ctx_t *ctx)
|
|||
.image = image_ind,
|
||||
.type = VK_IMAGE_VIEW_TYPE_2D,
|
||||
.format = mesh->mesh->objects[image_ind].image.format,
|
||||
.aspect = VK_IMAGE_ASPECT_COLOR_BIT,
|
||||
.subresourceRange = {
|
||||
.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
|
||||
.levelCount = VK_REMAINING_MIP_LEVELS,
|
||||
.layerCount = VK_REMAINING_ARRAY_LAYERS,
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
|
|
|
@ -42,17 +42,25 @@ create_image (qfv_device_t *device, qfv_resobj_t *image_obj)
|
|||
{
|
||||
qfv_devfuncs_t *dfunc = device->funcs;
|
||||
__auto_type image = &image_obj->image;
|
||||
if (image->image) {
|
||||
// the image was created externally and is being
|
||||
return;
|
||||
}
|
||||
VkImageCreateInfo createInfo = {
|
||||
VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, 0,
|
||||
image->cubemap ? VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT : 0,
|
||||
image->type, image->format, image->extent, image->num_mipmaps,
|
||||
image->num_layers,
|
||||
image->samples,
|
||||
VK_IMAGE_TILING_OPTIMAL,
|
||||
image->usage,
|
||||
VK_SHARING_MODE_EXCLUSIVE,
|
||||
0, 0,
|
||||
VK_IMAGE_LAYOUT_UNDEFINED,
|
||||
.flags = image->flags,
|
||||
.imageType = image->type,
|
||||
.format = image->format,
|
||||
.extent = image->extent,
|
||||
.mipLevels = image->num_mipmaps,
|
||||
.arrayLayers = image->num_layers,
|
||||
.samples = image->samples,
|
||||
.tiling = image->tiling,
|
||||
.usage = image->usage,
|
||||
.sharingMode = image->sharing,
|
||||
.queueFamilyIndexCount = image->num_queue_inds,
|
||||
.pQueueFamilyIndices = image->queue_inds,
|
||||
.initialLayout = image->initialLayout,
|
||||
};
|
||||
dfunc->vkCreateImage (device->dev, &createInfo, 0, &image->image);
|
||||
}
|
||||
|
@ -63,23 +71,17 @@ create_image_view (qfv_device_t *device, qfv_resobj_t *imgview_obj,
|
|||
{
|
||||
qfv_devfuncs_t *dfunc = device->funcs;
|
||||
__auto_type view = &imgview_obj->image_view;
|
||||
__auto_type image = &imgobj->image;
|
||||
VkImage image = view->external_image ? view->external_image
|
||||
: imgobj->image.image;
|
||||
|
||||
VkImageViewCreateInfo createInfo = {
|
||||
VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, 0,
|
||||
//FIXME flags should be input for both image and image view
|
||||
.flags = image->cubemap ? VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT : 0,
|
||||
.image = image->image,
|
||||
.flags = view->flags,
|
||||
.image = image,
|
||||
.viewType = view->type,
|
||||
.format = view->format,
|
||||
.components = view->components,
|
||||
.subresourceRange = {
|
||||
.aspectMask = view->aspect,
|
||||
.baseMipLevel = 0,
|
||||
.levelCount = VK_REMAINING_MIP_LEVELS,
|
||||
.baseArrayLayer = 0,
|
||||
.layerCount = VK_REMAINING_ARRAY_LAYERS,
|
||||
},
|
||||
.subresourceRange = view->subresourceRange,
|
||||
};
|
||||
dfunc->vkCreateImageView (device->dev, &createInfo, 0, &view->view);
|
||||
}
|
||||
|
@ -137,8 +139,9 @@ QFV_CreateResource (qfv_device_t *device, qfv_resource_t *resource)
|
|||
{
|
||||
__auto_type imgview = &obj->image_view;
|
||||
__auto_type imgobj = &resource->objects[imgview->image];
|
||||
if (imgview->image >= resource->num_objects
|
||||
|| imgobj->type != qfv_res_image) {
|
||||
if (!imgview->external_image
|
||||
&& (imgview->image >= resource->num_objects
|
||||
|| imgobj->type != qfv_res_image)) {
|
||||
Sys_Error ("%s:%s invalid image for view",
|
||||
resource->name, obj->name);
|
||||
}
|
||||
|
|
|
@ -691,7 +691,11 @@ load_lmp (const char *path, vulkan_ctx_t *ctx)
|
|||
.image = 0,
|
||||
.type = VK_IMAGE_VIEW_TYPE_2D,
|
||||
.format = font->resource->glyph_image.image.format,
|
||||
.aspect = VK_IMAGE_ASPECT_COLOR_BIT,
|
||||
.subresourceRange = {
|
||||
.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
|
||||
.levelCount = VK_REMAINING_MIP_LEVELS,
|
||||
.layerCount = VK_REMAINING_ARRAY_LAYERS,
|
||||
},
|
||||
.components = {
|
||||
.r = VK_COMPONENT_SWIZZLE_IDENTITY,
|
||||
.g = VK_COMPONENT_SWIZZLE_IDENTITY,
|
||||
|
@ -1649,7 +1653,11 @@ Vulkan_Draw_AddFont (font_t *rfont, vulkan_ctx_t *ctx)
|
|||
.image = 2,
|
||||
.type = VK_IMAGE_VIEW_TYPE_2D,
|
||||
.format = font->resource->glyph_image.image.format,
|
||||
.aspect = VK_IMAGE_ASPECT_COLOR_BIT,
|
||||
.subresourceRange = {
|
||||
.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
|
||||
.levelCount = VK_REMAINING_MIP_LEVELS,
|
||||
.layerCount = VK_REMAINING_ARRAY_LAYERS,
|
||||
},
|
||||
.components = {
|
||||
.r = VK_COMPONENT_SWIZZLE_R,
|
||||
.g = VK_COMPONENT_SWIZZLE_R,
|
||||
|
|
|
@ -790,11 +790,12 @@ build_shadow_maps (lightingctx_t *lctx, vulkan_ctx_t *ctx)
|
|||
.objects = (qfv_resobj_t *) &shad[1],
|
||||
};
|
||||
for (int i = 0; i < numMaps; i++) {
|
||||
int cube = maps[i].layers < 6 ? 0 : maps[i].cube;
|
||||
shad->objects[i] = (qfv_resobj_t) {
|
||||
.name = "map",
|
||||
.type = qfv_res_image,
|
||||
.image = {
|
||||
.cubemap = maps[i].layers < 6 ? 0 : maps[i].cube,
|
||||
.flags = cube ? VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT : 0,
|
||||
.type = VK_IMAGE_TYPE_2D,
|
||||
.format = VK_FORMAT_X8_D24_UNORM_PACK32,
|
||||
.extent = { maps[i].size, maps[i].size, 1 },
|
||||
|
|
|
@ -194,7 +194,11 @@ Vulkan_Translucent_CreateBuffers (vulkan_ctx_t *ctx, VkExtent2D extent)
|
|||
.image = i,
|
||||
.type = VK_IMAGE_VIEW_TYPE_2D_ARRAY,
|
||||
.format = VK_FORMAT_R32_SINT,
|
||||
.aspect = VK_IMAGE_ASPECT_COLOR_BIT,
|
||||
.subresourceRange = {
|
||||
.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
|
||||
.levelCount = VK_REMAINING_MIP_LEVELS,
|
||||
.layerCount = VK_REMAINING_ARRAY_LAYERS,
|
||||
},
|
||||
},
|
||||
};
|
||||
buffer_objs[i] = (qfv_resobj_t) {
|
||||
|
|
Loading…
Reference in a new issue