[vulkan] Generate parse data for new render pass structs

There's still a lot of work to do, but the basics are in. The spec will
be parsed into info structs that can then be further processed to
generate all the actual structs, generally making things a little less
timing dependent (eg, image view info refers to its image by name).

The new render pass and subpass structs have their names mangled for now
until I can switch over to the new system.
This commit is contained in:
Bill Currie 2023-02-09 14:52:43 +09:00
parent 97b2f2afb0
commit e10b084d36
7 changed files with 279 additions and 14 deletions

View file

@ -6,9 +6,112 @@
#endif
#include <vulkan/vulkan.h>
#include "QF/darray.h"
#include "QF/simd/types.h"
typedef struct qfv_imageinfo_s {
const char *name;
VkImageCreateFlags flags;
VkImageType imageType;
VkFormat format;
VkExtent3D extent;
uint32_t mipLevels;
uint32_t arrayLayers;
VkSampleCountFlagBits samples;
VkImageTiling tiling;
VkImageUsageFlags usage;
} qfv_imageinfo_t;
typedef struct qfv_imageviewinfo_s {
const char *name;
VkImageViewCreateFlags flags;
//VkImage image;
const char *image;
VkImageViewType viewType;
VkFormat format;
VkComponentMapping components;
VkImageSubresourceRange subresourceRange;
} qfv_imageviewinfo_t;
typedef struct qfv_dependencymask_s {
VkPipelineStageFlags stage;
VkAccessFlags access;
} qfv_dependencymask_t;
typedef struct qfv_dependencyinfo_s {
const char *name;
qfv_dependencymask_t src;
qfv_dependencymask_t dst;
VkDependencyFlags flags;
} qfv_dependencyinfo_t;
typedef struct qfv_attachmentinfo_s {
vec4f_t color;
const char *name;
VkAttachmentDescriptionFlags flags;
VkFormat format;
VkSampleCountFlagBits samples;
VkAttachmentLoadOp loadOp;
VkAttachmentStoreOp storeOp;
VkAttachmentLoadOp stencilLoadOp;
VkAttachmentStoreOp stencilStoreOp;
VkImageLayout initialLayout;
VkImageLayout finalLayout;
} qfv_attachmentinfo_t;
typedef struct qfv_taskinfo_s {
struct exprfunc_s *func;
void *params;
} qfv_taskinfo_t;
typedef struct qfv_attachmentrefinfo_s {
uint32_t num_input;
const char **input;
uint32_t num_color;
const char **color;
const char **resolve;
const char **depth;
uint32_t num_preserve;
const char **preserve;
} qfv_attachmentrefinfo_t;
typedef struct qfv_pipelineinfo_s {
vec4f_t color;
const char *name;
VkGraphicsPipelineCreateInfo *pipeline;
uint32_t num_tasks;
qfv_taskinfo_t *tasks;
} qfv_pipelineinfo_t;
typedef struct qfv_subpassinfo_s {
vec4f_t color;
const char *name;
uint32_t num_dependencies;
qfv_dependencyinfo_t *dependencies;
uint32_t num_attachments;
qfv_attachmentrefinfo_t *attachments;
uint32_t num_pipelines;
qfv_pipelineinfo_t *pipelines;
} qfv_subpassinfo_t;
typedef struct qfv_renderpassinfo_s {
const char *name;
uint32_t num_attachments;
qfv_attachmentinfo_t *attachments;
VkFramebufferCreateInfo framebuffer;
uint32_t num_subpasses;
qfv_subpassinfo_t *subpasses;
} qfv_renderpassinfo_t;
typedef struct qfv_renderinfo_s {
struct plitem_s *properties;
uint32_t num_images;
qfv_imageinfo_t *images;
uint32_t num_views;
qfv_imageviewinfo_t *views;
uint32_t num_renderpasses;
qfv_renderpassinfo_t *renderpasses;
} qfv_renderinfo_t;
typedef struct qfv_label_s {
vec4f_t color;
const char *name;
@ -35,15 +138,15 @@ typedef struct qfv_pipeline_s {
VkDescriptorSet *descriptor_sets;
} qfv_pipeline_t;
typedef struct qfv_subpass_s {
typedef struct qfv_subpass_s_ {
qfv_label_t label;
VkCommandBufferBeginInfo beginInfo;
VkCommandBuffer cmd;
uint32_t pipline_count;
qfv_pipeline_t *pipelines;
} qfv_subpass_t;
} qfv_subpass_t_;
typedef struct qfv_renderpass_s {
typedef struct qfv_renderpass_s_ {
struct vulkan_ctx_s *vulkan_ctx;
qfv_label_t label; // for debugging
@ -58,9 +161,9 @@ typedef struct qfv_renderpass_s {
//qfv_output_t output;
uint32_t subpass_count;
qfv_subpass_t *subpasses;
} qfv_renderpass_t;
qfv_subpass_t_ *subpasses;
} qfv_renderpass_t_;
void QFV_RunRenderPass (qfv_renderpass_t *rp, struct vulkan_ctx_s *ctx)m
void QFV_RunRenderPass (qfv_renderpass_t_ *rp, struct vulkan_ctx_s *ctx);
#endif//__QF_Vulkan_render_h

View file

@ -231,6 +231,7 @@ libs_video_renderer_librender_vulkan_la_SOURCES = \
libs/video/renderer/vulkan/memory.c \
libs/video/renderer/vulkan/pipeline.c \
libs/video/renderer/vulkan/projection.c \
libs/video/renderer/vulkan/render.c \
libs/video/renderer/vulkan/resource.c \
libs/video/renderer/vulkan/scrap.c \
libs/video/renderer/vulkan/shader.c \

View file

@ -70,7 +70,7 @@ run_pipeline (qfv_pipeline_t *pipeline, VkCommandBuffer cmd, vulkan_ctx_t *ctx)
// https://themaister.net/blog/2019/08/14/yet-another-blog-explaining-vulkan-synchronization/
static void
run_subpass (qfv_subpass_t *sp, vulkan_ctx_t *ctx)
run_subpass (qfv_subpass_t_ *sp, vulkan_ctx_t *ctx)
{
qfv_device_t *device = ctx->device;
qfv_devfuncs_t *dfunc = device->funcs;
@ -90,7 +90,7 @@ run_subpass (qfv_subpass_t *sp, vulkan_ctx_t *ctx)
}
void
QFV_RunRenderPass (qfv_renderpass_t *rp, vulkan_ctx_t *ctx)
QFV_RunRenderPass (qfv_renderpass_t_ *rp, vulkan_ctx_t *ctx)
{
qfv_device_t *device = ctx->device;
qfv_devfuncs_t *dfunc = device->funcs;

View file

@ -224,7 +224,7 @@ renderpasses = {
};
translucent = {
color = "[ 0.25, 0.25, 0.6, 1]";
depend = {
dependencies = {
depth = $depth_dependency;
}
attachments = {
@ -260,7 +260,7 @@ renderpasses = {
};
gbuffer = {
color = "[ 0.3, 0.7, 0.3, 1]";
depend = {
dependencies = {
depth = $depth_dependency;
}
attachments = {
@ -309,7 +309,7 @@ renderpasses = {
};
lighting = {
color = "[ 0.8, 0.8, 0.8, 1]";
depend = {
dependencies = {
gbuffer = $color_dependency;
}
attachments = {
@ -337,7 +337,7 @@ renderpasses = {
};
compose = {
color = "[ 0.7, 0.3, 0.3, 1]";
depend = {
dependencies = {
lighting = $color_dependency;
}
attachments = {

View file

@ -1,6 +1,10 @@
#define __x86_64__
#include <vulkan/vulkan.h>
typedef vec4 vec4f_t;
#define __QF_simd_types_h
#include "QF/Vulkan/render.h"
//FIXME copy of qfv_subpass_t in qf_renderpass.h
//except it doesn't really matter because a custom spec is used
typedef struct qfv_subpass_s {

View file

@ -42,6 +42,7 @@
#include "QF/Vulkan/instance.h"
#include "QF/Vulkan/image.h"
#include "QF/Vulkan/pipeline.h"
#include "QF/Vulkan/render.h"
#include "QF/Vulkan/shader.h"
#include "QF/Vulkan/qf_renderpass.h"
@ -996,6 +997,22 @@ parse_specialization_data (const plitem_t *item, void **data,
return ret;
}
static int
parse_task_function (const plitem_t *item, void **data,
plitem_t *messages, parsectx_t *pctx)
{
PL_Message (messages, item, "parse_task_function: not implemented");
return 0;
}
static int
parse_task_params (const plitem_t *item, void **data,
plitem_t *messages, parsectx_t *pctx)
{
PL_Message (messages, item, "parse_task_params: not implemented");
return 0;
}
#include "libs/video/renderer/vulkan/vkparse.cinc"
static exprsym_t vulkan_frameset_t_symbols[] = {

View file

@ -33,6 +33,17 @@
qfv_subpass_t,
qfv_output_t,
qfv_imageinfo_t,
qfv_imageviewinfo_t,
qfv_dependencyinfo_t,
qfv_attachmentinfo_t,
qfv_attachmentrefinfo_t,
qfv_taskinfo_t,
qfv_pipelineinfo_t,
qfv_subpassinfo_t,
qfv_renderpassinfo_t,
qfv_renderinfo_t,
);
parse = {
VkSubpassDescription = {
@ -393,7 +404,6 @@
string = name;
};
};
qfv_output_s = {
.name = qfv_output_t;
extent = auto;
@ -409,5 +419,135 @@
frames = auto;
finalLayout = auto;
};
qfv_taskinfo_s = {
.name = qfv_taskinfo_t;
func = {
type = (custom, QFString, parse_task_function);
fields = (func);
};
params = {
type = (custom, QFArray, parse_task_params);
fields = (params, func);
};
};
qfv_attachmentrefinfo_s = {
.name = qfv_attachmentrefinfo_t;
input = {
type = (array, {
parse_type = QFString;
type = "char *";
parser = parse_string;
});
size = num_input;
values = input;
};
color = {
type = (array, {
parse_type = QFString;
type = "char *";
parser = parse_string;
});
size = num_color;
values = color;
};
resolve = {
type = (array, {
parse_type = QFString;
type = "char *";
parser = parse_string;
});
values = resolve;
matchSize = color;
};
depth = {
type = (single, {
parse_type = QFString;
type = "char *";
parser = parse_string;
});
value = depth;
};
preserve = {
type = (array, {
parse_type = QFString;
type = "char *";
parser = parse_string;
});
size = num_preserve;
values = preserve;
};
};
qfv_pipelineinfo_s = {
.name = qfv_pipelineinfo_t;
color = auto;
name = {
type = string;
string = name;
};
pipeline = {
type = (single, VkGraphicsPipelineCreateInfo);
value = pipeline;
};
tasks = {
type = (array, qfv_taskinfo_t);
size = num_tasks;
values = tasks;
}
};
qfv_subpassinfo_s = {
.name = qfv_subpassinfo_t;
name = {
type = string;
string = name;
};
dependencies = {
type = (array, qfv_dependencyinfo_t);
size = num_dependencies;
values = dependencies;
};
attachments = {
type = (single, qfv_attachmentrefinfo_t);
value = attachments;
};
pipelines = {
type = (array, qfv_pipelineinfo_t);
size = num_pipelines;
values = pipelines;
};
};
qfv_renderpassinfo_s = {
.name = qfv_renderpassinfo_t;
attachments = {
type = (array, qfv_attachmentinfo_t);
size = num_attachments;
values = attachments;
};
framebuffer = auto;
subpasses = {
type = (array, qfv_subpassinfo_t);
size = num_subpasses;
values = subpasses;
};
};
qfv_renderinfo_s = {
.name = qfv_renderinfo_t;
//properties = auto;
images = {
type = (array, qfv_imageinfo_t);
size = num_images;
values = images;
};
views = {
type = (array, qfv_imageviewinfo_t);
size = num_views;
values = views;
};
renderpasses = {
type = (array, qfv_renderpassinfo_t);
size = num_renderpasses;
values = renderpasses;
};
}
};
}