[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
typedef enum {
QFV_passDepth, // geometry
QFV_passTranslucent, // geometry
QFV_passGBuffer, // geometry
QFV_passLighting, // single quad
QFV_passTranslucent, // geometry
QFV_passCompose, // single quad
QFV_NumPasses

View file

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

View file

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

View file

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