@@ -1638,8 +1638,8 @@ bool gpu_pipeline_init_graphics(gpu_pipeline* pipeline, gpu_pipeline_info* info,
1638
1638
} else {
1639
1639
bool depth = info -> depth .format ;
1640
1640
uint32_t colorCount = info -> attachmentCount ;
1641
- VkAttachmentDescription2 attachments [5 ];
1642
- VkAttachmentReference2 references [5 ];
1641
+ VkAttachmentDescription2 attachments [6 ];
1642
+ VkAttachmentReference2 references [6 ];
1643
1643
1644
1644
for (uint32_t i = 0 ; i < colorCount ; i ++ ) {
1645
1645
references [i ] = (VkAttachmentReference2 ) {
@@ -1679,6 +1679,20 @@ bool gpu_pipeline_init_graphics(gpu_pipeline* pipeline, gpu_pipeline_info* info,
1679
1679
};
1680
1680
}
1681
1681
1682
+ if (info -> foveated ) {
1683
+ uint32_t index = colorCount + depth ;
1684
+
1685
+ attachments [index ] = (VkAttachmentDescription2 ) {
1686
+ .sType = VK_STRUCTURE_TYPE_ATTACHMENT_DESCRIPTION_2 ,
1687
+ .format = VK_FORMAT_R8G8_UNORM ,
1688
+ .samples = VK_SAMPLE_COUNT_1_BIT ,
1689
+ .loadOp = VK_ATTACHMENT_LOAD_OP_LOAD ,
1690
+ .storeOp = VK_ATTACHMENT_STORE_OP_DONT_CARE ,
1691
+ .initialLayout = VK_IMAGE_LAYOUT_FRAGMENT_DENSITY_MAP_OPTIMAL_EXT ,
1692
+ .finalLayout = VK_IMAGE_LAYOUT_FRAGMENT_DENSITY_MAP_OPTIMAL_EXT
1693
+ };
1694
+ }
1695
+
1682
1696
VkSubpassDescription2 subpass = {
1683
1697
.sType = VK_STRUCTURE_TYPE_SUBPASS_DESCRIPTION_2 ,
1684
1698
.viewMask = (1 << info -> viewCount ) - 1 ,
@@ -1689,7 +1703,14 @@ bool gpu_pipeline_init_graphics(gpu_pipeline* pipeline, gpu_pipeline_info* info,
1689
1703
1690
1704
VkRenderPassCreateInfo2 passInfo = {
1691
1705
.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO_2 ,
1692
- .attachmentCount = colorCount + depth ,
1706
+ .pNext = info -> foveated ? & (VkRenderPassFragmentDensityMapCreateInfoEXT ) {
1707
+ .sType = VK_STRUCTURE_TYPE_RENDER_PASS_FRAGMENT_DENSITY_MAP_CREATE_INFO_EXT ,
1708
+ .fragmentDensityMapAttachment = {
1709
+ .attachment = colorCount + depth ,
1710
+ .layout = VK_IMAGE_LAYOUT_FRAGMENT_DENSITY_MAP_OPTIMAL_EXT
1711
+ }
1712
+ } : NULL ,
1713
+ .attachmentCount = colorCount + depth + info -> foveated ,
1693
1714
.pAttachments = attachments ,
1694
1715
.subpassCount = 1 ,
1695
1716
.pSubpasses = & subpass
0 commit comments