[vulkan] Use a template for the deferred image views

That certainly makes it nicer to work with large sets, and shows one way
to be careful with allocated resources: don't allocate them in the
inherited data and use a template that needs a few things filled in to
be valid. Also, it seems that overriding values in sub-structures "just
works" :)
This commit is contained in:
Bill Currie 2022-04-03 11:47:53 +09:00
parent eb4d566801
commit 39e7c4a9b2

View file

@ -106,118 +106,58 @@
initialLayout = undefined;
};
};
flat_color_view_template = {
viewType = VK_IMAGE_VIEW_TYPE_2D;
components = {
r = identity;
g = identity;
b = identity;
a = identity;
};
subresourceRange = {
aspectMask = color;
levelCount = 1;
layerCount = 1;
};
};
imageViews = {
depth = {
@inherit = $properties.flat_color_view_template;
image = depth;
viewType = VK_IMAGE_VIEW_TYPE_2D;
format = $properties.images.depth.format;
components = {
r = identity;
g = identity;
b = identity;
a = identity;
};
subresourceRange = {
aspectMask = depth;
levelCount = 1;
layerCount = 1;
};
};
color = {
@inherit = $properties.flat_color_view_template;
image = color;
viewType = VK_IMAGE_VIEW_TYPE_2D;
format = $properties.images.color.format;
components = {
r = identity;
g = identity;
b = identity;
a = identity;
};
subresourceRange = {
aspectMask = color;
levelCount = 1;
layerCount = 1;
};
};
emission = {
@inherit = $properties.flat_color_view_template;
image = emission;
viewType = VK_IMAGE_VIEW_TYPE_2D;
format = $properties.images.emission.format;
components = {
r = identity;
g = identity;
b = identity;
a = identity;
};
subresourceRange = {
aspectMask = color;
levelCount = 1;
layerCount = 1;
};
};
normal = {
@inherit = $properties.flat_color_view_template;
image = normal;
viewType = VK_IMAGE_VIEW_TYPE_2D;
format = $properties.images.normal.format;
components = {
r = identity;
g = identity;
b = identity;
a = identity;
};
subresourceRange = {
aspectMask = color;
levelCount = 1;
layerCount = 1;
};
};
position = {
@inherit = $properties.flat_color_view_template;
image = position;
viewType = VK_IMAGE_VIEW_TYPE_2D;
format = $properties.images.position.format;
components = {
r = identity;
g = identity;
b = identity;
a = identity;
};
subresourceRange = {
aspectMask = color;
levelCount = 1;
layerCount = 1;
};
};
opaque = {
@inherit = $properties.flat_color_view_template;
image = opaque;
viewType = VK_IMAGE_VIEW_TYPE_2D;
format = $properties.images.opaque.format;
components = {
r = identity;
g = identity;
b = identity;
a = identity;
};
subresourceRange = {
aspectMask = color;
levelCount = 1;
layerCount = 1;
};
};
translucent = {
@inherit = $properties.flat_color_view_template;
image = translucent;
viewType = VK_IMAGE_VIEW_TYPE_2D;
format = $properties.images.translucent.format;
components = {
r = identity;
g = identity;
b = identity;
a = identity;
};
subresourceRange = {
aspectMask = color;
levelCount = 1;
layerCount = 1;
};
};
};
framebuffer = {