Skip to content

Commit 6540e09

Browse files
committed
Make use of STORE_OP_NONE when appropriate.
1 parent ac540cf commit 6540e09

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

renderer/render_graph.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1214,7 +1214,7 @@ void RenderGraph::build_render_pass_info()
12141214
if (preserve_depth)
12151215
{
12161216
// Have to store here, or the attachment becomes undefined in future passes.
1217-
rp.op_flags |= Vulkan::RENDER_PASS_OP_STORE_DEPTH_STENCIL_BIT;
1217+
rp.op_flags |= Vulkan::RENDER_PASS_OP_PRESERVE_DEPTH_STENCIL_BIT;
12181218
}
12191219
}
12201220

vulkan/render_pass.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,17 @@ RenderPass::RenderPass(Hash hash, Device *device_, const RenderPassInfo &info)
177177
ds_load_op = VK_ATTACHMENT_LOAD_OP_LOAD;
178178

179179
if (info.op_flags & RENDER_PASS_OP_STORE_DEPTH_STENCIL_BIT)
180+
{
180181
ds_store_op = VK_ATTACHMENT_STORE_OP_STORE;
182+
}
183+
else if (info.op_flags & RENDER_PASS_OP_PRESERVE_DEPTH_STENCIL_BIT)
184+
{
185+
ds_store_op = device->get_device_features().device_api_core_version >= VK_API_VERSION_1_3 ?
186+
VK_ATTACHMENT_STORE_OP_NONE : VK_ATTACHMENT_STORE_OP_STORE;
187+
188+
if (ds_load_op != VK_ATTACHMENT_LOAD_OP_LOAD)
189+
ds_store_op = VK_ATTACHMENT_STORE_OP_STORE;
190+
}
181191

182192
bool ds_read_only = (info.op_flags & RENDER_PASS_OP_DEPTH_STENCIL_READ_ONLY_BIT) != 0;
183193
VkImageLayout depth_stencil_layout = VK_IMAGE_LAYOUT_UNDEFINED;

vulkan/render_pass.hpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ enum RenderPassOp
4040
RENDER_PASS_OP_STORE_DEPTH_STENCIL_BIT = 1 << 2,
4141
RENDER_PASS_OP_DEPTH_STENCIL_READ_ONLY_BIT = 1 << 3,
4242
RENDER_PASS_OP_ENABLE_TRANSIENT_STORE_BIT = 1 << 4,
43-
RENDER_PASS_OP_ENABLE_TRANSIENT_LOAD_BIT = 1 << 5
43+
RENDER_PASS_OP_ENABLE_TRANSIENT_LOAD_BIT = 1 << 5,
44+
RENDER_PASS_OP_PRESERVE_DEPTH_STENCIL_BIT = 1 << 6
4445
};
4546
using RenderPassOpFlags = uint32_t;
4647

0 commit comments

Comments
 (0)