[vulkan] Fix sky depth issues

There were actually several problems: translucency wasn't using or
depending on the depth buffer, and the depth buffer wasn't marked as
read-only in the g-buffer pass. Getting that correct seems to have given
bigass1 a 0.5% boost (hard to say, could be the usual noise).
This commit is contained in:
Bill Currie 2021-03-23 11:26:24 +09:00
parent 5ac807d4b2
commit 6e0312658d
4 changed files with 45 additions and 26 deletions

View file

@ -38,9 +38,9 @@
//FIXME location //FIXME location
typedef enum { typedef enum {
QFV_passDepth, // geometry QFV_passDepth, // geometry
QFV_passTranslucent, // geometry
QFV_passGBuffer, // geometry QFV_passGBuffer, // geometry
QFV_passLighting, // single quad QFV_passLighting, // single quad
QFV_passTranslucent, // geometry
QFV_passCompose, // single quad QFV_passCompose, // single quad
QFV_NumPasses QFV_NumPasses

View file

@ -329,7 +329,21 @@
layout = depth_stencil_attachment_optimal; layout = depth_stencil_attachment_optimal;
}; };
}, },
{ // 1 g-buffer generation { // 1 translucent
pipelineBindPoint = graphics;
colorAttachments = (
{ // translucent
attachment = 6;
layout = color_attachment_optimal;
},
);
depthStencilAttachment = {
attachment = 0;
layout = depth_stencil_read_only_optimal;
};
preserveAttachments = (1, 2, 3, 4, 5);
},
{ // 2 g-buffer generation
pipelineBindPoint = graphics; pipelineBindPoint = graphics;
colorAttachments = ( colorAttachments = (
{ // color { // color
@ -351,11 +365,11 @@
); );
depthStencilAttachment = { depthStencilAttachment = {
attachment = 0; attachment = 0;
layout = depth_stencil_attachment_optimal; layout = depth_stencil_read_only_optimal;
}; };
preserveAttachments = (6); preserveAttachments = (6);
}, },
{ // 2 lighting { // 3 lighting
pipelineBindPoint = graphics; pipelineBindPoint = graphics;
inputAttachments = ( inputAttachments = (
{ // depth { // depth
@ -387,16 +401,6 @@
); );
preserveAttachments = (6); preserveAttachments = (6);
}, },
{ // 3 translucent
pipelineBindPoint = graphics;
colorAttachments = (
{ // translucent
attachment = 6;
layout = color_attachment_optimal;
},
);
preserveAttachments = (0, 1, 2, 3, 4, 5);
},
{ // 4 compose { // 4 compose
pipelineBindPoint = graphics; pipelineBindPoint = graphics;
inputAttachments = ( inputAttachments = (
@ -421,7 +425,7 @@
dependencies = ( dependencies = (
{ {
srcSubpass = 0; // depth srcSubpass = 0; // depth
dstSubpass = 1; // g-buffer dstSubpass = 1; // translucent
srcStageMask = color_attachment_output; srcStageMask = color_attachment_output;
dstStageMask = fragment_shader; dstStageMask = fragment_shader;
srcAccessMask = color_attachment_write; srcAccessMask = color_attachment_write;
@ -429,8 +433,8 @@
dependencyFlags = by_region; dependencyFlags = by_region;
}, },
{ {
srcSubpass = 1; // g-buffer srcSubpass = 0; // depth
dstSubpass = 2; // lighting dstSubpass = 2; // g-buffer
srcStageMask = color_attachment_output; srcStageMask = color_attachment_output;
dstStageMask = fragment_shader; dstStageMask = fragment_shader;
srcAccessMask = color_attachment_write; srcAccessMask = color_attachment_write;
@ -438,7 +442,16 @@
dependencyFlags = by_region; dependencyFlags = by_region;
}, },
{ {
srcSubpass = 2; // lighting srcSubpass = 2; // g-buffer
dstSubpass = 3; // lighting
srcStageMask = color_attachment_output;
dstStageMask = fragment_shader;
srcAccessMask = color_attachment_write;
dstAccessMask = shader_read;
dependencyFlags = by_region;
},
{
srcSubpass = 3; // lighting
dstSubpass = 4; // compose dstSubpass = 4; // compose
srcStageMask = color_attachment_output; srcStageMask = color_attachment_output;
dstStageMask = fragment_shader; dstStageMask = fragment_shader;
@ -447,7 +460,7 @@
dependencyFlags = by_region; dependencyFlags = by_region;
}, },
{ {
srcSubpass = 3; // translucent srcSubpass = 1; // translucent
dstSubpass = 4; // compose dstSubpass = 4; // compose
srcStageMask = color_attachment_output; srcStageMask = color_attachment_output;
dstStageMask = fragment_shader; dstStageMask = fragment_shader;

View file

@ -534,7 +534,7 @@
//renderPass = renderpass; //renderPass = renderpass;
}; };
alias_gbuf = { alias_gbuf = {
subpass = 1; subpass = 2;
stages = ( stages = (
{ {
stage = vertex; stage = vertex;
@ -604,7 +604,7 @@
//renderPass = renderpass; //renderPass = renderpass;
}; };
bsp_gbuf = { bsp_gbuf = {
subpass = 1; subpass = 2;
stages = ( stages = (
{ {
stage = vertex; stage = vertex;
@ -653,7 +653,7 @@
//renderPass = renderpass; //renderPass = renderpass;
}; };
bsp_skysheet = { bsp_skysheet = {
subpass = 3; subpass = 1;
stages = ( stages = (
{ {
stage = vertex; stage = vertex;
@ -690,7 +690,7 @@
//renderPass = renderpass; //renderPass = renderpass;
}; };
twod = { twod = {
subpass = 3; subpass = 1;
stages = ( stages = (
{ {
stage = vertex; stage = vertex;
@ -708,7 +708,7 @@
viewport = $properties.viewport; viewport = $properties.viewport;
rasterization = $properties.rasterization.counter_cw_cull_back; rasterization = $properties.rasterization.counter_cw_cull_back;
multisample = $properties.multisample; multisample = $properties.multisample;
depthStencil = $properties.depthStencil.test_and_write; depthStencil = $properties.depthStencil.test_only;
colorBlend = { colorBlend = {
logicOpEnable = false; logicOpEnable = false;
attachments = ($properties.attachmentBlendOp.alpha_blend); attachments = ($properties.attachmentBlendOp.alpha_blend);
@ -720,7 +720,7 @@
//renderPass = renderpass; //renderPass = renderpass;
}; };
lighting = { lighting = {
subpass = 2; subpass = 3;
stages = ( stages = (
{ {
stage = vertex; stage = vertex;

View file

@ -70,6 +70,12 @@ static const char *alias_pass_names[] = {
"translucent", "translucent",
}; };
static QFV_Subpass subpass_map[] = {
QFV_passDepth, // QFV_aliasDepth
QFV_passGBuffer, // QFV_aliasGBuffer
QFV_passTranslucent, // QFV_aliasTranslucent
};
static void static void
emit_commands (VkCommandBuffer cmd, int pose1, int pose2, emit_commands (VkCommandBuffer cmd, int pose1, int pose2,
qfv_alias_skin_t *skin, qfv_alias_skin_t *skin,
@ -174,7 +180,7 @@ alias_begin_subpass (QFV_AliasSubpass subpass, VkPipeline pipeline,
dfunc->vkResetCommandBuffer (cmd, 0); dfunc->vkResetCommandBuffer (cmd, 0);
VkCommandBufferInheritanceInfo inherit = { VkCommandBufferInheritanceInfo inherit = {
VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, 0, VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, 0,
ctx->renderpass, subpass, ctx->renderpass, subpass_map[subpass],
cframe->framebuffer, cframe->framebuffer,
0, 0, 0, 0, 0, 0,
}; };