Skip to content

Commit 4644170

Browse files
committed
Render all the output attachments for PASS_G_OPAQUE
In Dawntrail they now write to several outputs during this pass, such as diffuse and motion vectors. We will need these eventually - especially diffuse - so now they should be written to.
1 parent 9b9a092 commit 4644170

File tree

2 files changed

+104
-6
lines changed

2 files changed

+104
-6
lines changed

renderer/include/gamerenderer.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,10 @@ class GameRenderer : public BaseRenderer
120120
Buffer m_dummyBuffer;
121121
Texture m_tileNormal;
122122
Texture m_tileDiffuse;
123+
Texture m_diffuseGBuffer;
124+
Texture m_motionGBuffer;
125+
Texture m_motionGBuffer2;
126+
Texture m_unkGBuffer;
123127

124128
// Dawntrail changes part of the rendering system
125129
bool m_dawntrailMode = false;

renderer/src/gamerenderer.cpp

Lines changed: 100 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -727,6 +727,74 @@ void GameRenderer::beginPass(VkCommandBuffer commandBuffer, const std::string_vi
727727
colorAttachments.push_back(attachmentInfo);
728728
}
729729

730+
// test for another
731+
{
732+
VkRenderingAttachmentInfo attachmentInfo{};
733+
attachmentInfo.sType = VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO;
734+
attachmentInfo.imageView = m_motionGBuffer.imageView;
735+
attachmentInfo.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; // VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL
736+
attachmentInfo.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR;
737+
attachmentInfo.storeOp = VK_ATTACHMENT_STORE_OP_STORE;
738+
739+
attachmentInfo.clearValue.color.float32[0] = 0.24;
740+
attachmentInfo.clearValue.color.float32[1] = 0.24;
741+
attachmentInfo.clearValue.color.float32[2] = 0.24;
742+
attachmentInfo.clearValue.color.float32[3] = 1.0;
743+
744+
colorAttachments.push_back(attachmentInfo);
745+
}
746+
747+
// test for another
748+
{
749+
VkRenderingAttachmentInfo attachmentInfo{};
750+
attachmentInfo.sType = VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO;
751+
attachmentInfo.imageView = m_diffuseGBuffer.imageView;
752+
attachmentInfo.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; // VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL
753+
attachmentInfo.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR;
754+
attachmentInfo.storeOp = VK_ATTACHMENT_STORE_OP_STORE;
755+
756+
attachmentInfo.clearValue.color.float32[0] = 0.24;
757+
attachmentInfo.clearValue.color.float32[1] = 0.24;
758+
attachmentInfo.clearValue.color.float32[2] = 0.24;
759+
attachmentInfo.clearValue.color.float32[3] = 1.0;
760+
761+
colorAttachments.push_back(attachmentInfo);
762+
}
763+
764+
// test for another
765+
{
766+
VkRenderingAttachmentInfo attachmentInfo{};
767+
attachmentInfo.sType = VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO;
768+
attachmentInfo.imageView = m_unkGBuffer.imageView;
769+
attachmentInfo.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; // VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL
770+
attachmentInfo.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR;
771+
attachmentInfo.storeOp = VK_ATTACHMENT_STORE_OP_STORE;
772+
773+
attachmentInfo.clearValue.color.float32[0] = 0.24;
774+
attachmentInfo.clearValue.color.float32[1] = 0.24;
775+
attachmentInfo.clearValue.color.float32[2] = 0.24;
776+
attachmentInfo.clearValue.color.float32[3] = 1.0;
777+
778+
colorAttachments.push_back(attachmentInfo);
779+
}
780+
781+
// test for another
782+
{
783+
VkRenderingAttachmentInfo attachmentInfo{};
784+
attachmentInfo.sType = VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO;
785+
attachmentInfo.imageView = m_motionGBuffer2.imageView;
786+
attachmentInfo.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; // VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL
787+
attachmentInfo.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR;
788+
attachmentInfo.storeOp = VK_ATTACHMENT_STORE_OP_STORE;
789+
790+
attachmentInfo.clearValue.color.float32[0] = 0.24;
791+
attachmentInfo.clearValue.color.float32[1] = 0.24;
792+
attachmentInfo.clearValue.color.float32[2] = 0.24;
793+
attachmentInfo.clearValue.color.float32[3] = 1.0;
794+
795+
colorAttachments.push_back(attachmentInfo);
796+
}
797+
730798
m_device.transitionTexture(commandBuffer, m_depthBuffer, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL);
731799

732800
// depth
@@ -1161,6 +1229,8 @@ GameRenderer::CachedPipeline &GameRenderer::bindPipeline(VkCommandBuffer command
11611229
// TODO: hardcoded, should be a reusable function to get the color attachments
11621230
if (passName == "PASS_LIGHTING_OPAQUE") {
11631231
colorAttachmentCount = 2;
1232+
} else if (passName == "PASS_G_OPAQUE") {
1233+
colorAttachmentCount = 5;
11641234
}
11651235

11661236
for (int i = 0; i < colorAttachmentCount; i++) {
@@ -1208,15 +1278,15 @@ GameRenderer::CachedPipeline &GameRenderer::bindPipeline(VkCommandBuffer command
12081278
depthStencil.depthCompareOp = VK_COMPARE_OP_LESS_OR_EQUAL;
12091279
depthStencil.maxDepthBounds = 1.0f;
12101280

1211-
std::array<VkFormat, 3> colorAttachmentFormats = {VK_FORMAT_R8G8B8A8_UNORM, VK_FORMAT_R8G8B8A8_UNORM, VK_FORMAT_R8G8B8A8_UNORM};
1281+
const std::array colorAttachmentFormats = {VK_FORMAT_R8G8B8A8_UNORM,
1282+
VK_FORMAT_R8G8B8A8_UNORM,
1283+
VK_FORMAT_R8G8B8A8_UNORM,
1284+
VK_FORMAT_R8G8B8A8_UNORM,
1285+
VK_FORMAT_R8G8B8A8_UNORM};
12121286

12131287
VkPipelineRenderingCreateInfo pipelineRenderingCreateInfo = {};
12141288
pipelineRenderingCreateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_RENDERING_CREATE_INFO;
1215-
if (passName == "PASS_LIGHTING_OPAQUE") {
1216-
pipelineRenderingCreateInfo.colorAttachmentCount = 2; // TODO: hardcoded
1217-
} else {
1218-
pipelineRenderingCreateInfo.colorAttachmentCount = 1;
1219-
}
1289+
pipelineRenderingCreateInfo.colorAttachmentCount = colorAttachmentCount;
12201290
pipelineRenderingCreateInfo.pColorAttachmentFormats = colorAttachmentFormats.data();
12211291
pipelineRenderingCreateInfo.depthAttachmentFormat = VK_FORMAT_D32_SFLOAT; // TODO: hardcoded
12221292

@@ -1507,6 +1577,30 @@ void GameRenderer::createImageResources()
15071577
VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_SAMPLED_BIT);
15081578
m_device.nameTexture(m_depthBuffer, "Depth");
15091579

1580+
m_motionGBuffer = m_device.createTexture(m_device.swapChain->extent.width,
1581+
m_device.swapChain->extent.height,
1582+
VK_FORMAT_R8G8B8A8_UNORM,
1583+
VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_SAMPLED_BIT);
1584+
m_device.nameTexture(m_motionGBuffer, "Motion GBuffer");
1585+
1586+
m_diffuseGBuffer = m_device.createTexture(m_device.swapChain->extent.width,
1587+
m_device.swapChain->extent.height,
1588+
VK_FORMAT_R8G8B8A8_UNORM,
1589+
VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_SAMPLED_BIT);
1590+
m_device.nameTexture(m_diffuseGBuffer, "Diffuse GBuffer");
1591+
1592+
m_motionGBuffer2 = m_device.createTexture(m_device.swapChain->extent.width,
1593+
m_device.swapChain->extent.height,
1594+
VK_FORMAT_R8G8B8A8_UNORM,
1595+
VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_SAMPLED_BIT);
1596+
m_device.nameTexture(m_motionGBuffer2, "Motion 2 GBuffer");
1597+
1598+
m_unkGBuffer = m_device.createTexture(m_device.swapChain->extent.width,
1599+
m_device.swapChain->extent.height,
1600+
VK_FORMAT_R8G8B8A8_UNORM,
1601+
VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_SAMPLED_BIT);
1602+
m_device.nameTexture(m_unkGBuffer, "Unk GBuffer");
1603+
15101604
CommonParameter commonParam{};
15111605
commonParam.m_RenderTarget = {1.0f / m_device.swapChain->extent.width,
15121606
1.0f / m_device.swapChain->extent.height,

0 commit comments

Comments
 (0)