mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-02-22 11:41:38 +00:00
[vulkan] Add buffer and buffer view support
Not fully implemented, but the parsing is done. Needed image view refs to be renamed.
This commit is contained in:
parent
aba057b827
commit
34ece7ad03
4 changed files with 69 additions and 25 deletions
|
@ -65,6 +65,23 @@ typedef struct qfv_imageviewinfo_s {
|
||||||
VkImageSubresourceRange subresourceRange;
|
VkImageSubresourceRange subresourceRange;
|
||||||
} qfv_imageviewinfo_t;
|
} qfv_imageviewinfo_t;
|
||||||
|
|
||||||
|
typedef struct qfv_bufferinfo_s {
|
||||||
|
const char *name;
|
||||||
|
VkBufferCreateFlags flags;
|
||||||
|
VkDeviceSize size;
|
||||||
|
VkBufferUsageFlags usage;
|
||||||
|
VkSharingMode sharingMode;
|
||||||
|
} qfv_bufferinfo_t;
|
||||||
|
|
||||||
|
typedef struct qfv_bufferviewinfo_s {
|
||||||
|
const char *name;
|
||||||
|
VkBufferViewCreateFlags flags;
|
||||||
|
qfv_reference_t buffer;
|
||||||
|
VkFormat format;
|
||||||
|
VkDeviceSize offset;
|
||||||
|
VkDeviceSize range;
|
||||||
|
} qfv_bufferviewinfo_t;
|
||||||
|
|
||||||
typedef struct qfv_dependencymask_s {
|
typedef struct qfv_dependencymask_s {
|
||||||
VkPipelineStageFlags stage;
|
VkPipelineStageFlags stage;
|
||||||
VkAccessFlags access;
|
VkAccessFlags access;
|
||||||
|
@ -215,9 +232,13 @@ typedef struct qfv_jobinfo_s {
|
||||||
qfv_stepinfo_t *steps;
|
qfv_stepinfo_t *steps;
|
||||||
|
|
||||||
uint32_t num_images;
|
uint32_t num_images;
|
||||||
|
uint32_t num_imageviews;
|
||||||
qfv_imageinfo_t *images;
|
qfv_imageinfo_t *images;
|
||||||
uint32_t num_views;
|
qfv_imageviewinfo_t *imageviews;
|
||||||
qfv_imageviewinfo_t *views;
|
uint32_t num_buffers;
|
||||||
|
uint32_t num_bufferviews;
|
||||||
|
qfv_imageinfo_t *buffers;
|
||||||
|
qfv_imageviewinfo_t *bufferviews;
|
||||||
|
|
||||||
uint32_t num_descriptorsets;
|
uint32_t num_descriptorsets;
|
||||||
qfv_descriptorsetinfo_t *descriptorsets;
|
qfv_descriptorsetinfo_t *descriptorsets;
|
||||||
|
|
|
@ -161,7 +161,9 @@ QFV_LoadRenderInfo (vulkan_ctx_t *ctx)
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint32_t num_images;
|
uint32_t num_images;
|
||||||
uint32_t num_views;
|
uint32_t num_imageviews;
|
||||||
|
uint32_t num_buffers;
|
||||||
|
uint32_t num_bufferviews;
|
||||||
uint32_t num_layouts;
|
uint32_t num_layouts;
|
||||||
|
|
||||||
uint32_t num_steps;
|
uint32_t num_steps;
|
||||||
|
@ -272,7 +274,9 @@ static void
|
||||||
count_stuff (qfv_jobinfo_t *jobinfo, objcount_t *counts)
|
count_stuff (qfv_jobinfo_t *jobinfo, objcount_t *counts)
|
||||||
{
|
{
|
||||||
counts->num_images += jobinfo->num_images;
|
counts->num_images += jobinfo->num_images;
|
||||||
counts->num_views += jobinfo->num_views;
|
counts->num_imageviews += jobinfo->num_imageviews;
|
||||||
|
counts->num_buffers += jobinfo->num_buffers;
|
||||||
|
counts->num_bufferviews += jobinfo->num_bufferviews;
|
||||||
for (uint32_t i = 0; i < jobinfo->num_steps; i++) {
|
for (uint32_t i = 0; i < jobinfo->num_steps; i++) {
|
||||||
count_step_stuff (&jobinfo->steps[i], counts);
|
count_step_stuff (&jobinfo->steps[i], counts);
|
||||||
}
|
}
|
||||||
|
@ -287,7 +291,7 @@ create_resources (vulkan_ctx_t *ctx, objcount_t *counts)
|
||||||
|
|
||||||
job->resources = malloc (sizeof(qfv_resource_t)
|
job->resources = malloc (sizeof(qfv_resource_t)
|
||||||
+ counts->num_images * sizeof (qfv_resobj_t)
|
+ counts->num_images * sizeof (qfv_resobj_t)
|
||||||
+ counts->num_views * sizeof (qfv_resobj_t));
|
+ counts->num_imageviews * sizeof (qfv_resobj_t));
|
||||||
job->images = (qfv_resobj_t *) &job->resources[1];
|
job->images = (qfv_resobj_t *) &job->resources[1];
|
||||||
job->image_views = &job->images[counts->num_images];
|
job->image_views = &job->images[counts->num_images];
|
||||||
|
|
||||||
|
@ -295,7 +299,7 @@ create_resources (vulkan_ctx_t *ctx, objcount_t *counts)
|
||||||
.name = "render",
|
.name = "render",
|
||||||
.va_ctx = ctx->va_ctx,
|
.va_ctx = ctx->va_ctx,
|
||||||
.memory_properties = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT,
|
.memory_properties = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT,
|
||||||
.num_objects = counts->num_images + counts->num_views,
|
.num_objects = counts->num_images + counts->num_imageviews,
|
||||||
.objects = job->images,
|
.objects = job->images,
|
||||||
};
|
};
|
||||||
for (uint32_t i = 0; i < counts->num_images; i++) {
|
for (uint32_t i = 0; i < counts->num_images; i++) {
|
||||||
|
@ -318,8 +322,8 @@ create_resources (vulkan_ctx_t *ctx, objcount_t *counts)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
int error = 0;
|
int error = 0;
|
||||||
for (uint32_t i = 0; i < counts->num_views; i++) {
|
for (uint32_t i = 0; i < counts->num_imageviews; i++) {
|
||||||
__auto_type view = &jinfo->views[i];
|
__auto_type view = &jinfo->imageviews[i];
|
||||||
job->image_views[i] = (qfv_resobj_t) {
|
job->image_views[i] = (qfv_resobj_t) {
|
||||||
.name = view->name,
|
.name = view->name,
|
||||||
.type = qfv_res_image_view,
|
.type = qfv_res_image_view,
|
||||||
|
@ -1125,24 +1129,24 @@ QFV_BuildRender (vulkan_ctx_t *ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VkImageView __attribute__((pure, used))
|
static VkImageView __attribute__((pure, used))
|
||||||
find_view (qfv_reference_t *ref, qfv_renderctx_t *rctx)
|
find_imageview (qfv_reference_t *ref, qfv_renderctx_t *rctx)
|
||||||
{
|
{
|
||||||
__auto_type jinfo = rctx->jobinfo;
|
__auto_type jinfo = rctx->jobinfo;
|
||||||
__auto_type job = rctx->job;
|
__auto_type job = rctx->job;
|
||||||
const char *name = ref->name;
|
const char *name = ref->name;
|
||||||
|
|
||||||
if (strncmp (name, "$views.", 7) == 0) {
|
if (strncmp (name, "$imageviews.", 7) == 0) {
|
||||||
name += 7;
|
name += 7;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (uint32_t i = 0; i < jinfo->num_views; i++) {
|
for (uint32_t i = 0; i < jinfo->num_imageviews; i++) {
|
||||||
__auto_type vi = &jinfo->views[i];
|
__auto_type vi = &jinfo->imageviews[i];
|
||||||
__auto_type vo = &job->image_views[i];
|
__auto_type vo = &job->image_views[i];
|
||||||
if (strcmp (name, vi->name) == 0) {
|
if (strcmp (name, vi->name) == 0) {
|
||||||
return vo->image_view.view;
|
return vo->image_view.view;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Sys_Error ("%d:invalid view: %s", ref->line, ref->name);
|
Sys_Error ("%d:invalid imageview: %s", ref->line, ref->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -1184,7 +1188,7 @@ QFV_CreateFramebuffer (vulkan_ctx_t *ctx)
|
||||||
.layers = rpInfo->framebuffer.layers,
|
.layers = rpInfo->framebuffer.layers,
|
||||||
};
|
};
|
||||||
for (uint32_t i = 0; i < rpInfo->num_attachments; i++) {
|
for (uint32_t i = 0; i < rpInfo->num_attachments; i++) {
|
||||||
attachments[i] = find_view (&rpInfo->attachments[i].view, rctx);
|
attachments[i] = find_imageview (&rpInfo->attachments[i].view, rctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
qfv_device_t *device = ctx->device;
|
qfv_device_t *device = ctx->device;
|
||||||
|
|
|
@ -822,7 +822,7 @@ images = {
|
||||||
format = $render_output.format;
|
format = $render_output.format;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
views = {
|
imageviews = {
|
||||||
depth = {
|
depth = {
|
||||||
@inherit = $view_base;
|
@inherit = $view_base;
|
||||||
image = depth;
|
image = depth;
|
||||||
|
@ -877,34 +877,34 @@ renderpasses = {
|
||||||
loadOp = clear;
|
loadOp = clear;
|
||||||
finalLayout = depth_stencil_attachment_optimal;
|
finalLayout = depth_stencil_attachment_optimal;
|
||||||
clearValue = { depthStencil = { depth = 1; stencil = 0; }; };
|
clearValue = { depthStencil = { depth = 1; stencil = 0; }; };
|
||||||
view = $views.depth;
|
view = $imageviews.depth;
|
||||||
};
|
};
|
||||||
color = {
|
color = {
|
||||||
@inherit = $attachment_base;
|
@inherit = $attachment_base;
|
||||||
format = $images.color.format;
|
format = $images.color.format;
|
||||||
loadOp = clear;
|
loadOp = clear;
|
||||||
view = $views.color;
|
view = $imageviews.color;
|
||||||
};
|
};
|
||||||
emission = {
|
emission = {
|
||||||
@inherit = $attachment_base;
|
@inherit = $attachment_base;
|
||||||
format = $images.emission.format;
|
format = $images.emission.format;
|
||||||
loadOp = clear;
|
loadOp = clear;
|
||||||
view = $views.emission;
|
view = $imageviews.emission;
|
||||||
};
|
};
|
||||||
normal = {
|
normal = {
|
||||||
@inherit = $attachment_base;
|
@inherit = $attachment_base;
|
||||||
format = $images.normal.format;
|
format = $images.normal.format;
|
||||||
view = $views.normal;
|
view = $imageviews.normal;
|
||||||
};
|
};
|
||||||
position = {
|
position = {
|
||||||
@inherit = $attachment_base;
|
@inherit = $attachment_base;
|
||||||
format = $images.position.format;
|
format = $images.position.format;
|
||||||
view = $views.position;
|
view = $imageviews.position;
|
||||||
};
|
};
|
||||||
opaque = {
|
opaque = {
|
||||||
@inherit = $attachment_base;
|
@inherit = $attachment_base;
|
||||||
format = $images.opaque.format;
|
format = $images.opaque.format;
|
||||||
view = $views.opaque;
|
view = $imageviews.opaque;
|
||||||
};
|
};
|
||||||
output = {
|
output = {
|
||||||
@inherit = $attachment_base;
|
@inherit = $attachment_base;
|
||||||
|
@ -912,7 +912,7 @@ renderpasses = {
|
||||||
loadOp = clear;
|
loadOp = clear;
|
||||||
storeOp = store;
|
storeOp = store;
|
||||||
finalLayout = $render_output.finalLayout;
|
finalLayout = $render_output.finalLayout;
|
||||||
view = $views.output;
|
view = $imageviews.output;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
framebuffer = {
|
framebuffer = {
|
||||||
|
|
|
@ -36,6 +36,8 @@ search = (
|
||||||
qfv_descriptorsetinfo_t,
|
qfv_descriptorsetinfo_t,
|
||||||
qfv_imageinfo_t,
|
qfv_imageinfo_t,
|
||||||
qfv_imageviewinfo_t,
|
qfv_imageviewinfo_t,
|
||||||
|
qfv_bufferinfo_t,
|
||||||
|
qfv_bufferviewinfo_t,
|
||||||
qfv_dependencyinfo_t,
|
qfv_dependencyinfo_t,
|
||||||
qfv_attachmentinfo_t,
|
qfv_attachmentinfo_t,
|
||||||
qfv_attachmentrefinfo_t,
|
qfv_attachmentrefinfo_t,
|
||||||
|
@ -623,6 +625,13 @@ parse = {
|
||||||
values = bindings;
|
values = bindings;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
qfv_bufferviewinfo_s = {
|
||||||
|
.name = qfv_bufferviewinfo_t;
|
||||||
|
buffer = auto;
|
||||||
|
format = auto;
|
||||||
|
offset = auto;
|
||||||
|
range = auto;
|
||||||
|
};
|
||||||
qfv_computeinfo_s = {
|
qfv_computeinfo_s = {
|
||||||
.name = qfv_computeinfo_t;
|
.name = qfv_computeinfo_t;
|
||||||
color = auto;
|
color = auto;
|
||||||
|
@ -684,10 +693,20 @@ parse = {
|
||||||
size = num_images;
|
size = num_images;
|
||||||
values = images;
|
values = images;
|
||||||
};
|
};
|
||||||
views = {
|
imageviews = {
|
||||||
type = (labeledarray, qfv_imageviewinfo_t, name);
|
type = (labeledarray, qfv_imageviewinfo_t, name);
|
||||||
size = num_views;
|
size = num_imageviews;
|
||||||
values = views;
|
values = imageviews;
|
||||||
|
};
|
||||||
|
buffers = {
|
||||||
|
type = (labeledarray, qfv_bufferinfo_t, name);
|
||||||
|
size = num_buffers;
|
||||||
|
values = buffers;
|
||||||
|
};
|
||||||
|
bufferviews = {
|
||||||
|
type = (labeledarray, qfv_bufferviewinfo_t, name);
|
||||||
|
size = num_bufferviews;
|
||||||
|
values = bufferviews;
|
||||||
};
|
};
|
||||||
steps = {
|
steps = {
|
||||||
type = (labeledarray, qfv_stepinfo_t, name);
|
type = (labeledarray, qfv_stepinfo_t, name);
|
||||||
|
|
Loading…
Reference in a new issue