mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 15:22:04 +00:00
[vulkan] Start work on scripted pipeline
Nothing is actually done yet other than parsing the built-in property list to property list items (the actual parser is just a skeleton), but everything compiles
This commit is contained in:
parent
c6a8829a52
commit
79177e96e8
6 changed files with 303 additions and 23 deletions
|
@ -73,12 +73,13 @@ libs_video_renderer_vid_render_gl_la_SOURCES=\
|
|||
shader_src= libs/video/renderer/glsl/quakeforge.glsl
|
||||
shader_gen= libs/video/renderer/glsl/quakeforge.slc
|
||||
|
||||
BUILT_SOURCES += $(shader_gen)
|
||||
|
||||
SUFFICES=.frag .vert .fc .vc .slc .glsl
|
||||
SUFFICES=.frag .vert .fc .vc .slc .glsl .plist .plc
|
||||
.glsl.slc:
|
||||
sed -e 's/^/"/' -e 's/$$/\\n"/' $< > $@
|
||||
|
||||
.plist.plc:
|
||||
sed -e 's/"/\\"/g' -e 's/^/"/' -e 's/$$/\\n"/' $< > $@
|
||||
|
||||
video_renderer_glsl_libs= \
|
||||
libs/models/libmodels_glsl.la
|
||||
libs_video_renderer_vid_render_glsl_la_LDFLAGS= $(plugin_ldflags)
|
||||
|
@ -196,6 +197,9 @@ libs_video_renderer_vid_render_sw32_la_SOURCES=\
|
|||
libs/video/renderer/sw32/sw32_rsurf.c \
|
||||
libs/video/renderer/sw32/vid_common_sw32.c
|
||||
|
||||
pipeline_src = libs/video/renderer/vulkan/qfpipeline.plist
|
||||
pipeline_gen = libs/video/renderer/vulkan/qfpipeline.plc
|
||||
|
||||
vulkan_libs =
|
||||
libs_video_renderer_vid_render_vulkan_la_LDFLAGS= $(plugin_ldflags)
|
||||
libs_video_renderer_vid_render_vulkan_la_LIBADD= $(vulkan_libs)
|
||||
|
@ -216,10 +220,14 @@ libs_video_renderer_vid_render_vulkan_la_SOURCES = \
|
|||
libs/video/renderer/vulkan/swapchain.c \
|
||||
libs/video/renderer/vulkan/util.c \
|
||||
libs/video/renderer/vulkan/util.h \
|
||||
libs/video/renderer/vulkan/vkparse.c \
|
||||
libs/video/renderer/vulkan/vulkan_draw.c \
|
||||
libs/video/renderer/vulkan/vulkan_vid_common.c
|
||||
|
||||
libs/video/renderer/vulkan/vulkan_vid_common.c: $(vkparse_src)
|
||||
libs/video/renderer/vulkan/vkparse.lo: libs/video/renderer/vulkan/vkparse.c $(vkparse_src)
|
||||
|
||||
libs/video/renderer/vulkan/vulkan_vid_common.lo: libs/video/renderer/vulkan/vulkan_vid_common.c $(pipeline_gen)
|
||||
|
||||
|
||||
qwaq_curses = ruamoko/qwaq/qwaq-curses$(EXEEXT)
|
||||
vkparse_src = \
|
||||
|
@ -240,4 +248,7 @@ CLEANFILES += \
|
|||
libs/video/renderer/glsl/*.vc \
|
||||
libs/video/renderer/glsl/*.fc \
|
||||
libs/video/renderer/glsl/*.slc \
|
||||
libs/video/renderer/vulkan/*.plc \
|
||||
$(vkparse_src)
|
||||
|
||||
BUILT_SOURCES += $(shader_gen)
|
||||
|
|
71
libs/video/renderer/vulkan/qfpipeline.plist
Normal file
71
libs/video/renderer/vulkan/qfpipeline.plist
Normal file
|
@ -0,0 +1,71 @@
|
|||
{
|
||||
renderpass = {
|
||||
attachments = (
|
||||
{
|
||||
flags = 0;
|
||||
format = $swapchain.format;
|
||||
samples = $msaaSamples;
|
||||
loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR;
|
||||
storeOp = VK_ATTACHMENT_STORE_OP_STORE;
|
||||
stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
|
||||
stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
|
||||
initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
|
||||
finalLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
|
||||
},
|
||||
{
|
||||
flags = 0;
|
||||
format = $swapchain.format;
|
||||
samples = $msaaSamples;
|
||||
loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR;
|
||||
storeOp = VK_ATTACHMENT_STORE_OP_STORE;
|
||||
stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
|
||||
stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
|
||||
initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
|
||||
finalLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
|
||||
},
|
||||
{
|
||||
flags = 0;
|
||||
format = VK_FORMAT_D32_SFLOAT;
|
||||
samples = VK_SAMPLE_COUNT_1_BIT;
|
||||
loadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
|
||||
storeOp = VK_ATTACHMENT_STORE_OP_STORE;
|
||||
stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
|
||||
stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
|
||||
initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
|
||||
finalLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR;
|
||||
},
|
||||
);
|
||||
subpasses = (
|
||||
{
|
||||
inputAttachments = (
|
||||
{
|
||||
attachmeht = 0;
|
||||
layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
|
||||
}
|
||||
);
|
||||
resolveAttachments = (
|
||||
{
|
||||
attachmeht = 2;
|
||||
layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
|
||||
}
|
||||
);
|
||||
depthStencilAttachment = {
|
||||
attachmeht = 1;
|
||||
layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
|
||||
};
|
||||
preserveAttachments = ();
|
||||
},
|
||||
);
|
||||
dependencies = (
|
||||
{
|
||||
srcSubpass = VK_SUBPASS_EXTERNAL;
|
||||
dstSubpass = 0;
|
||||
srcStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
|
||||
dstStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
|
||||
srcAccessMask = 0;
|
||||
dstAccessMask = "VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT";
|
||||
dependencyFlags = 0;
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
186
libs/video/renderer/vulkan/vkparse.c
Normal file
186
libs/video/renderer/vulkan/vkparse.c
Normal file
|
@ -0,0 +1,186 @@
|
|||
/*
|
||||
vkparse.c
|
||||
|
||||
Parser for scripted vulkan structs
|
||||
|
||||
Copyright (C) 2020 Bill Currie <bill@taniwha.org>
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to:
|
||||
|
||||
Free Software Foundation, Inc.
|
||||
59 Temple Place - Suite 330
|
||||
Boston, MA 02111-1307, USA
|
||||
|
||||
*/
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_MATH_H
|
||||
# include <math.h>
|
||||
#endif
|
||||
#ifdef HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#endif
|
||||
#ifdef HAVE_STRINGS_H
|
||||
# include <strings.h>
|
||||
#endif
|
||||
|
||||
#include "QF/cvar.h"
|
||||
#include "QF/dstring.h"
|
||||
#include "QF/input.h"
|
||||
#include "QF/mathlib.h"
|
||||
#include "QF/qargs.h"
|
||||
#include "QF/qfplist.h"
|
||||
#include "QF/quakefs.h"
|
||||
#include "QF/sys.h"
|
||||
#include "QF/va.h"
|
||||
#include "QF/vid.h"
|
||||
#include "QF/Vulkan/qf_vid.h"
|
||||
#include "QF/Vulkan/device.h"
|
||||
#include "QF/Vulkan/command.h"
|
||||
#include "QF/Vulkan/instance.h"
|
||||
#include "QF/Vulkan/image.h"
|
||||
#include "QF/Vulkan/renderpass.h"
|
||||
#include "QF/Vulkan/swapchain.h"
|
||||
|
||||
#include "compat.h"
|
||||
#include "d_iface.h"
|
||||
#include "r_internal.h"
|
||||
#include "vid_vulkan.h"
|
||||
|
||||
#include "util.h"
|
||||
#include "vkparse.h"
|
||||
|
||||
typedef struct enumval_s {
|
||||
const char *name;
|
||||
int value;
|
||||
} enumval_t;
|
||||
|
||||
typedef struct parse_single_s {
|
||||
plparser_t parser;
|
||||
size_t value_offset;
|
||||
} parse_single_t;
|
||||
|
||||
typedef struct parse_array_s {
|
||||
plparser_t parser;
|
||||
size_t size_offset;
|
||||
size_t value_offset;
|
||||
} parse_array_t;
|
||||
|
||||
static int parse_uint32_t (const plfield_t *field, const plitem_t *item,
|
||||
void *data, plitem_t *messages)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int parse_enum (const plfield_t *field, const plitem_t *item,
|
||||
void *data, plitem_t *messages)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int parse_flags (const plfield_t *field, const plitem_t *item,
|
||||
void *data, plitem_t *messages)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int parse_single (const plfield_t *field, const plitem_t *item,
|
||||
void *data, plitem_t *messages)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int parse_array (const plfield_t *field, const plitem_t *item,
|
||||
void *data, plitem_t *messages)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#include "libs/video/renderer/vulkan/vkparse.inc"
|
||||
|
||||
typedef struct qfv_renderpass_s {
|
||||
qfv_attachmentdescription_t *attachments;
|
||||
qfv_subpassparametersset_t *subpasses;
|
||||
qfv_subpassdependency_t *dependencies;
|
||||
} qfv_renderpass_t;
|
||||
|
||||
static plelement_t parse_qfv_renderpass_attachments_data = {
|
||||
QFDictionary,
|
||||
sizeof (VkAttachmentDescription),
|
||||
malloc,
|
||||
parse_VkAttachmentDescription,
|
||||
0,
|
||||
};
|
||||
|
||||
static plelement_t parse_qfv_renderpass_subpasses_data = {
|
||||
QFDictionary,
|
||||
sizeof (VkSubpassDescription),
|
||||
malloc,
|
||||
parse_VkSubpassDescription,
|
||||
0,
|
||||
};
|
||||
|
||||
static plelement_t parse_qfv_renderpass_dependencies_data = {
|
||||
QFDictionary,
|
||||
sizeof (VkSubpassDependency),
|
||||
malloc,
|
||||
parse_VkSubpassDependency,
|
||||
0,
|
||||
};
|
||||
|
||||
static plfield_t renderpass_fields[] = {
|
||||
{ "attachments", field_offset (qfv_renderpass_t, attachments), QFArray,
|
||||
parse_array, &parse_qfv_renderpass_attachments_data },
|
||||
{ "subpasses", field_offset (qfv_renderpass_t, subpasses), QFArray,
|
||||
parse_array, &parse_qfv_renderpass_subpasses_data },
|
||||
{ "dependencies", field_offset (qfv_renderpass_t, dependencies), QFArray,
|
||||
parse_array, &parse_qfv_renderpass_dependencies_data },
|
||||
{}
|
||||
};
|
||||
|
||||
VkRenderPass
|
||||
QFV_ParseRenderPass (qfv_device_t *device, plitem_t *plist)
|
||||
{
|
||||
qfv_renderpass_t renderpass_data = {};
|
||||
plitem_t *messages = PL_NewArray ();
|
||||
VkRenderPass renderpass;
|
||||
|
||||
if (!PL_ParseDictionary (renderpass_fields, plist,
|
||||
&renderpass_data, messages)) {
|
||||
for (int i = 0; i < PL_A_NumObjects (messages); i++) {
|
||||
Sys_Printf ("%s\n", PL_String (PL_ObjectAtIndex (messages, i)));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
PL_Free (messages);
|
||||
renderpass = QFV_CreateRenderPass (device,
|
||||
renderpass_data.attachments,
|
||||
renderpass_data.subpasses,
|
||||
renderpass_data.dependencies);
|
||||
|
||||
free (renderpass_data.attachments);
|
||||
for (size_t i = 0; i < renderpass_data.subpasses->size; i++) {
|
||||
free ((void *) renderpass_data.subpasses->a[i].pInputAttachments);
|
||||
free ((void *) renderpass_data.subpasses->a[i].pColorAttachments);
|
||||
free ((void *) renderpass_data.subpasses->a[i].pResolveAttachments);
|
||||
free ((void *) renderpass_data.subpasses->a[i].pDepthStencilAttachment);
|
||||
free ((void *) renderpass_data.subpasses->a[i].pPreserveAttachments);
|
||||
}
|
||||
free (renderpass_data.subpasses);
|
||||
free (renderpass_data.dependencies);
|
||||
return renderpass;
|
||||
}
|
10
libs/video/renderer/vulkan/vkparse.h
Normal file
10
libs/video/renderer/vulkan/vkparse.h
Normal file
|
@ -0,0 +1,10 @@
|
|||
#ifndef __vkparse_h
|
||||
#define __vkparse_h
|
||||
|
||||
#include "QF/Vulkan/renderpass.h"
|
||||
|
||||
VkRenderPass
|
||||
QFV_ParseRenderPass (qfv_device_t *device, plitem_t *plist);
|
||||
|
||||
|
||||
#endif//__vkparse_h
|
|
@ -1,26 +1,10 @@
|
|||
{
|
||||
search = (
|
||||
VkRenderPassCreateInfo
|
||||
VkAttachmentDescription,
|
||||
VkSubpassDescription,
|
||||
VkSubpassDependency,
|
||||
);
|
||||
parse = {
|
||||
VkRenderPassCreateInfo = {
|
||||
flags = auto;
|
||||
attachments = {
|
||||
type = (array, VkAttachmentDescription);
|
||||
size = attachmentCount;
|
||||
values = pAttachments;
|
||||
};
|
||||
subpasses = {
|
||||
type = (array, VkSubpassDescription);
|
||||
size = subpassCount;
|
||||
values = pSubpasses;
|
||||
};
|
||||
dependencies = {
|
||||
type = (array, VkSubpassDependency);
|
||||
size = dependencyCount;
|
||||
values = pDependencies;
|
||||
};
|
||||
};
|
||||
VkSubpassDescription = {
|
||||
flags = auto;
|
||||
pipelineBindPoint = auto;
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#include "QF/input.h"
|
||||
#include "QF/mathlib.h"
|
||||
#include "QF/qargs.h"
|
||||
#include "QF/qfplist.h"
|
||||
#include "QF/quakefs.h"
|
||||
#include "QF/sys.h"
|
||||
#include "QF/va.h"
|
||||
|
@ -63,6 +64,10 @@
|
|||
|
||||
#include "util.h"
|
||||
|
||||
static const char quakeforge_pipeline[] =
|
||||
#include "libs/video/renderer/vulkan/qfpipeline.plc"
|
||||
;
|
||||
|
||||
cvar_t *vulkan_presentation_mode;
|
||||
|
||||
static void
|
||||
|
@ -232,9 +237,22 @@ static qfv_pipelinestagepair_t imageLayoutTransitionStages[] = {
|
|||
VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT },
|
||||
};
|
||||
|
||||
static plitem_t *
|
||||
qfv_load_pipeline (void)
|
||||
{
|
||||
return PL_GetPropertyList (quakeforge_pipeline);
|
||||
}
|
||||
|
||||
void
|
||||
Vulkan_CreateRenderPass (vulkan_ctx_t *ctx)
|
||||
{
|
||||
plitem_t *item = qfv_load_pipeline ();
|
||||
|
||||
if (!item || !(item = PL_ObjectForKey (item, "renderpass"))) {
|
||||
Sys_Printf ("error loading pipeline\n");
|
||||
} else {
|
||||
Sys_Printf ("Found renderer def\n");
|
||||
}
|
||||
qfv_device_t *device = ctx->device;
|
||||
VkDevice dev = device->dev;
|
||||
qfv_devfuncs_t *df = device->funcs;
|
||||
|
|
Loading…
Reference in a new issue