[vulkan] Get the parsed pipeline working

It turned out the msaa setting defaulting to 1 instead of 8 was the
problem no idea why at this stage (need to read up on just how that
setting works). Once I understand just how it works, I'll rework the
msaa handling.
This commit is contained in:
Bill Currie 2020-12-21 19:30:00 +09:00
parent 96df447c45
commit ac8206555e
4 changed files with 68 additions and 72 deletions

View file

@ -296,6 +296,6 @@ QFV_GetMaxSampleCount (qfv_physdev_t *physdev)
while (maxSamples && maxSamples > counts) {
maxSamples >>= 1;
}
Sys_MaskPrintf (SYS_VULKAN, "Max samples: %x\n", maxSamples);
Sys_MaskPrintf (SYS_VULKAN, "Max samples: %x (%d)\n", maxSamples, counts);
return maxSamples;
}

View file

@ -71,6 +71,67 @@ QFV_CreateRenderPass (qfv_device_t *device,
VkDevice dev = device->dev;
qfv_devfuncs_t *dfunc = device->funcs;
if (developer->int_val & SYS_VULKAN) {
Sys_Printf ("attachments: %ld\n", attachments->size);
for (size_t i = 0; i < attachments->size; i++) {
Sys_Printf (" flags: %x\n", attachments->a[i].flags);
Sys_Printf (" format: %d\n", attachments->a[i].format);
Sys_Printf (" samples: %x\n", attachments->a[i].samples);
Sys_Printf (" loadOp: %d\n", attachments->a[i].loadOp);
Sys_Printf (" storeOp: %d\n", attachments->a[i].storeOp);
Sys_Printf (" stencilLoadOp: %d\n",
attachments->a[i].stencilLoadOp);
Sys_Printf (" stencilStoreOp: %d\n",
attachments->a[i].stencilStoreOp);
Sys_Printf (" initialLayout: %d\n",
attachments->a[i].initialLayout);
Sys_Printf (" finalLayout: %d\n",
attachments->a[i].finalLayout);
}
Sys_Printf ("subpassparams: %ld\n", subpassparams->size);
for (size_t i = 0; i < subpassparams->size; i++) {
VkSubpassDescription *sp = &subpassparams->a[i];
Sys_Printf (" flags: %x\n", sp->flags);
Sys_Printf (" piplineBindPoint: %d\n", sp->pipelineBindPoint);
Sys_Printf (" inputAttachmentCount: %d\n",
sp->inputAttachmentCount);
for (size_t j = 0; j < sp->inputAttachmentCount; j++) {
const VkAttachmentReference *ref = &sp->pInputAttachments[j];
Sys_Printf (" c %d %d\n", ref->attachment, ref->layout);
}
Sys_Printf (" colorAttachmentCount: %d\n",
sp->colorAttachmentCount);
for (size_t j = 0; j < sp->colorAttachmentCount; j++) {
const VkAttachmentReference *ref = &sp->pColorAttachments[j];
Sys_Printf (" c %d %d\n", ref->attachment, ref->layout);
}
for (size_t j = 0; j < sp->colorAttachmentCount; j++) {
const VkAttachmentReference *ref = &sp->pResolveAttachments[j];
Sys_Printf (" r %d %d\n", ref->attachment, ref->layout);
}
Sys_Printf (" pDepthStencilAttachment: %p\n",
sp->pDepthStencilAttachment);
if (sp->pDepthStencilAttachment) {
const VkAttachmentReference *ref = sp->pDepthStencilAttachment;
Sys_Printf (" %d %d\n", ref->attachment, ref->layout);
}
Sys_Printf (" preserveAttachmentCount: %d\n",
sp->preserveAttachmentCount);
for (size_t j = 0; j < sp->preserveAttachmentCount; j++) {
Sys_Printf (" %d\n", sp->pPreserveAttachments[j]);
}
}
Sys_Printf ("dependencies: %ld\n", dependencies->size);
for (size_t i = 0; i < dependencies->size; i++) {
Sys_Printf (" srcSubpass: %d\n", dependencies->a[i].srcSubpass);
Sys_Printf (" dstSubpass: %d\n", dependencies->a[i].dstSubpass);
Sys_Printf (" srcStageMask: %x\n", dependencies->a[i].srcStageMask);
Sys_Printf (" dstStageMask: %x\n", dependencies->a[i].dstStageMask);
Sys_Printf (" srcAccessMask: %x\n", dependencies->a[i].srcAccessMask);
Sys_Printf (" dstAccessMask: %x\n", dependencies->a[i].dstAccessMask);
Sys_Printf (" dependencyFlags: %x\n", dependencies->a[i].dependencyFlags);
}
}
VkRenderPassCreateInfo createInfo = {
VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO, 0, 0,
attachments->size, attachments->a,

View file

@ -155,11 +155,11 @@ static int parse_enum (const plfield_t *field, const plitem_t *item,
ectx.symtab = enm->symtab;
ectx.result = &result;
const char *valstr = PL_String (item);
Sys_Printf ("parse_enum: %s %zd %d %p %p %s\n",
field->name, field->offset, field->type, field->parser,
field->data, valstr);
//Sys_Printf ("parse_enum: %s %zd %d %p %p %s\n",
// field->name, field->offset, field->type, field->parser,
// field->data, valstr);
ret = !cexpr_parse_enum (enm, valstr, &ectx, data);
Sys_Printf (" %d\n", *(int *)data);
//Sys_Printf (" %d\n", *(int *)data);
return ret;
}

View file

@ -117,7 +117,7 @@ Vulkan_Init_Cvars (void)
CVAR_NONE, vulkan_presentation_mode_f,
"desired presentation mode (may fall "
"back to fifo).");
msaaSamples = Cvar_Get ("msaaSamples", "VK_SAMPLE_COUNT_1_BIT",
msaaSamples = Cvar_Get ("msaaSamples", "VK_SAMPLE_COUNT_8_BIT",
CVAR_NONE, msaaSamples_f,
"desired MSAA sample size.");
}
@ -366,72 +366,7 @@ Vulkan_CreateRenderPass (vulkan_ctx_t *ctx)
ctx->renderpass.colorImage = colorImage;
ctx->renderpass.depthImage = depthImage;
__auto_type attachments = QFV_AllocAttachmentDescription (3, alloca);
__auto_type attachmentRefs = QFV_AllocAttachmentReference (3, alloca);
// color attachment
attachments->a[0].flags = 0;
attachments->a[0].format = sc->format;
attachments->a[0].samples = msaaSamples;
attachments->a[0].loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR;
attachments->a[0].storeOp = VK_ATTACHMENT_STORE_OP_STORE;
attachments->a[0].stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
attachments->a[0].stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
attachments->a[0].initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
attachments->a[0].finalLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
attachmentRefs->a[0].attachment = 0;
attachmentRefs->a[0].layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
// depth attachment
attachments->a[1].flags = 0;
attachments->a[1].format = depthFormat;
attachments->a[1].samples = msaaSamples;
attachments->a[1].loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR;
attachments->a[1].storeOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
attachments->a[1].stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
attachments->a[1].stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
attachments->a[1].initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
attachments->a[1].finalLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
attachmentRefs->a[1].attachment = 1;
attachmentRefs->a[1].layout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
// resolve attachment
attachments->a[2].flags = 0;
attachments->a[2].format = sc->format;
attachments->a[2].samples = VK_SAMPLE_COUNT_1_BIT;
attachments->a[2].loadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
attachments->a[2].storeOp = VK_ATTACHMENT_STORE_OP_STORE;
attachments->a[2].stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
attachments->a[2].stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
attachments->a[2].initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
attachments->a[2].finalLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR;
attachmentRefs->a[2].attachment = 2;
attachmentRefs->a[2].layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
__auto_type subpasses = QFV_AllocSubpassParametersSet (1, alloca);
subpasses->a[0].flags = 0;
subpasses->a[0].pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS;
subpasses->a[0].inputAttachmentCount = 0;
subpasses->a[0].pInputAttachments = 0;
subpasses->a[0].colorAttachmentCount = 1;
subpasses->a[0].pColorAttachments = &attachmentRefs->a[0];
subpasses->a[0].pResolveAttachments = &attachmentRefs->a[2];
subpasses->a[0].pDepthStencilAttachment = &attachmentRefs->a[1];
subpasses->a[0].preserveAttachmentCount = 0;
subpasses->a[0].pPreserveAttachments = 0;
__auto_type depenencies = QFV_AllocSubpassDependencies (1, alloca);
depenencies->a[0].srcSubpass = VK_SUBPASS_EXTERNAL;
depenencies->a[0].dstSubpass = 0;
depenencies->a[0].srcStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
depenencies->a[0].dstStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
depenencies->a[0].srcAccessMask = 0;
depenencies->a[0].dstAccessMask = VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
depenencies->a[0].dependencyFlags = 0;
ctx->renderpass.renderpass = QFV_CreateRenderPass (device, attachments,
subpasses, depenencies);
ctx->renderpass.renderpass = QFV_ParseRenderPass (ctx, item);
}
void