Skip to content

Commit

Permalink
Cauldron v1.4.4
Browse files Browse the repository at this point in the history
  • Loading branch information
rys committed Aug 16, 2022
1 parent 08e3881 commit ef84ae9
Show file tree
Hide file tree
Showing 28 changed files with 511 additions and 78 deletions.
1 change: 1 addition & 0 deletions src/VK/GLTF/GltfDepthPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,7 @@ namespace CAULDRON_VK

std::vector<VkDynamicState> dynamicStateEnables = {
VK_DYNAMIC_STATE_VIEWPORT,
VK_DYNAMIC_STATE_FRAGMENT_SHADING_RATE_KHR,
VK_DYNAMIC_STATE_SCISSOR
};
VkPipelineDynamicStateCreateInfo dynamicState = {};
Expand Down
1 change: 1 addition & 0 deletions src/VK/GLTF/GltfMotionVectorsPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,7 @@ namespace CAULDRON_VK

std::vector<VkDynamicState> dynamicStateEnables = {
VK_DYNAMIC_STATE_VIEWPORT,
VK_DYNAMIC_STATE_FRAGMENT_SHADING_RATE_KHR,
VK_DYNAMIC_STATE_SCISSOR
};
VkPipelineDynamicStateCreateInfo dynamicState = {};
Expand Down
1 change: 1 addition & 0 deletions src/VK/GLTF/GltfPbrPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,7 @@ namespace CAULDRON_VK

std::vector<VkDynamicState> dynamicStateEnables = {
VK_DYNAMIC_STATE_VIEWPORT,
VK_DYNAMIC_STATE_FRAGMENT_SHADING_RATE_KHR,
VK_DYNAMIC_STATE_SCISSOR
};
VkPipelineDynamicStateCreateInfo dynamicState = {};
Expand Down
31 changes: 25 additions & 6 deletions src/VK/PostProc/Bloom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,13 +226,32 @@ namespace CAULDRON_VK

for (int i = 0; i < m_mipCount; i++)
{
vkDestroyImageView(m_pDevice->GetDevice(), m_mip[i].m_SRV, NULL);
vkDestroyImageView(m_pDevice->GetDevice(), m_mip[i].m_RTV, NULL);
vkDestroyFramebuffer(m_pDevice->GetDevice(), m_mip[i].m_frameBuffer, NULL);
if (m_mip[i].m_SRV != nullptr)
{
vkDestroyImageView(m_pDevice->GetDevice(), m_mip[i].m_SRV, NULL);
m_mip[i].m_SRV = {};
}
if (m_mip[i].m_RTV != nullptr)
{
vkDestroyImageView(m_pDevice->GetDevice(), m_mip[i].m_RTV, NULL);
m_mip[i].m_RTV = {};
}
if (m_mip[i].m_frameBuffer != nullptr)
{
vkDestroyFramebuffer(m_pDevice->GetDevice(), m_mip[i].m_frameBuffer, NULL);
m_mip[i].m_frameBuffer = {};
}
}
if (m_output.m_RTV != nullptr)
{
vkDestroyImageView(m_pDevice->GetDevice(), m_output.m_RTV, NULL);
m_output.m_RTV = {};
}
if (m_output.m_frameBuffer != nullptr)
{
vkDestroyFramebuffer(m_pDevice->GetDevice(), m_output.m_frameBuffer, NULL);
m_output.m_frameBuffer = {};
}

vkDestroyImageView(m_pDevice->GetDevice(), m_output.m_RTV, NULL);
vkDestroyFramebuffer(m_pDevice->GetDevice(), m_output.m_frameBuffer, NULL);
}

void Bloom::OnDestroy()
Expand Down
18 changes: 11 additions & 7 deletions src/VK/PostProc/BlurPS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,13 +213,17 @@ namespace CAULDRON_VK
//
for (int i = 0; i < m_mipCount; i++)
{
vkDestroyImageView(m_pDevice->GetDevice(), m_horizontalMip[i].m_SRV, NULL);
vkDestroyImageView(m_pDevice->GetDevice(), m_horizontalMip[i].m_RTV, NULL);
vkDestroyFramebuffer(m_pDevice->GetDevice(), m_horizontalMip[i].m_frameBuffer, NULL);

vkDestroyImageView(m_pDevice->GetDevice(), m_verticalMip[i].m_SRV, NULL);
vkDestroyImageView(m_pDevice->GetDevice(), m_verticalMip[i].m_RTV, NULL);
vkDestroyFramebuffer(m_pDevice->GetDevice(), m_verticalMip[i].m_frameBuffer, NULL);
if (m_horizontalMip[i].m_SRV != nullptr)
{
vkDestroyImageView(m_pDevice->GetDevice(), m_horizontalMip[i].m_SRV, NULL);
vkDestroyImageView(m_pDevice->GetDevice(), m_horizontalMip[i].m_RTV, NULL);
vkDestroyFramebuffer(m_pDevice->GetDevice(), m_horizontalMip[i].m_frameBuffer, NULL);

vkDestroyImageView(m_pDevice->GetDevice(), m_verticalMip[i].m_SRV, NULL);
vkDestroyImageView(m_pDevice->GetDevice(), m_verticalMip[i].m_RTV, NULL);
vkDestroyFramebuffer(m_pDevice->GetDevice(), m_verticalMip[i].m_frameBuffer, NULL);
m_horizontalMip[i].m_SRV = {};
}
}

// Destroy temporary render target used to hold the horizontal pass
Expand Down
10 changes: 7 additions & 3 deletions src/VK/PostProc/DownSamplePS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,13 @@ namespace CAULDRON_VK
{
for (int i = 0; i < m_mipCount; i++)
{
vkDestroyImageView(m_pDevice->GetDevice(), m_mip[i].m_SRV, NULL);
vkDestroyImageView(m_pDevice->GetDevice(), m_mip[i].RTV, NULL);
vkDestroyFramebuffer(m_pDevice->GetDevice(), m_mip[i].frameBuffer, NULL);
if (m_mip[i].m_SRV != nullptr)
{
vkDestroyImageView(m_pDevice->GetDevice(), m_mip[i].m_SRV, NULL);
vkDestroyImageView(m_pDevice->GetDevice(), m_mip[i].RTV, NULL);
vkDestroyFramebuffer(m_pDevice->GetDevice(), m_mip[i].frameBuffer, NULL);
m_mip[i].m_SRV = {};
}
}

m_result.OnDestroy();
Expand Down
23 changes: 23 additions & 0 deletions src/VK/base/CommandListRing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,29 @@ namespace CAULDRON_VK
{
m_pCurrentFrame = &m_pCommandBuffers[m_frameIndex % m_numberOfAllocators];

// Wait for any work that is not finished for current frame

// NOTE: That code seems to not be working properly.
// DEFENSIVE HACK: Since we are moving to Cauldron2 we are adding a hack to fix samples by waiting on the device to be idle
#if 0
if(m_pCurrentFrame->m_cmdBufExecutedFences)
{
vkWaitForFences(m_pDevice->GetDevice(), 1, &m_pCurrentFrame->m_cmdBufExecutedFences, false, UINT64_MAX);
vkResetFences(m_pDevice->GetDevice(), 1, &m_pCurrentFrame->m_cmdBufExecutedFences);
}
else
{
VkFenceCreateInfo fence_ci = {};
fence_ci.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO;
fence_ci.flags = VK_FENCE_CREATE_SIGNALED_BIT;

auto res = vkCreateFence(m_pDevice->GetDevice(), &fence_ci, NULL, &m_pCurrentFrame->m_cmdBufExecutedFences);
}
#else
vkDeviceWaitIdle(m_pDevice->GetDevice());
#endif
// NOTE: vkResetCommandPool - resets entire pool causes following:
// Validation Error: [ VUID-vkResetCommandBuffer-commandBuffer-00045 ] Object 0: handle = 0x29ac6454070, type = VK_OBJECT_TYPE_COMMAND_BUFFER; | MessageID = 0x1e7883ea | Attempt to reset VkCommandBuffer 0x29ac6454070[] which is in use. The Vulkan spec states: commandBuffer must not be in the pending state (https://vulkan.lunarg.com/doc/view/1.3.204.1/windows/1.3-extensions/vkspec.html#VUID-vkResetCommandBuffer-commandBuffer-00045)
vkResetCommandPool(m_pDevice->GetDevice(), m_pCurrentFrame->m_commandPool, VK_COMMAND_POOL_RESET_RELEASE_RESOURCES_BIT);

m_pCurrentFrame->m_UsedCls = 0;
Expand Down
1 change: 1 addition & 0 deletions src/VK/base/CommandListRing.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ namespace CAULDRON_VK
{
VkCommandPool m_commandPool;
VkCommandBuffer *m_pCommandBuffer;
VkFence m_cmdBufExecutedFences;
uint32_t m_UsedCls;
} *m_pCommandBuffers, *m_pCurrentFrame;

Expand Down
12 changes: 10 additions & 2 deletions src/VK/base/Device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ namespace CAULDRON_VK
{
pIp->AddInstanceExtensionName(VK_KHR_WIN32_SURFACE_EXTENSION_NAME);
pIp->AddInstanceExtensionName(VK_KHR_SURFACE_EXTENSION_NAME);
pIp->AddInstanceExtensionName(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
ExtCheckHDRInstanceExtensions(pIp);
ExtDebugUtilsCheckInstanceExtensions(pIp);
if (cpuValidationLayerEnabled)
Expand All @@ -82,7 +83,7 @@ namespace CAULDRON_VK
{
m_usingFp16 = ExtFp16CheckExtensions(pDp);
ExtRTCheckExtensions(pDp, m_rt10Supported, m_rt11Supported);
ExtVRSCheckExtensions(pDp, m_vrs1Supported, m_vrs2Supported);
ExtVRSCheckExtensions(pDp, m_vrs1Supported, m_vrs2Supported, m_vrsTileSize, m_fragmentShadingRateAttachmentTexelSize);
ExtCheckHDRDeviceExtensions(pDp);
ExtCheckFSEDeviceExtensions(pDp);
ExtCheckFreeSyncHDRDeviceExtensions(pDp);
Expand Down Expand Up @@ -234,9 +235,16 @@ namespace CAULDRON_VK
physicalDeviceFeatures2.features = physicalDeviceFeatures;
physicalDeviceFeatures2.pNext = &robustness2;

VkPhysicalDeviceFragmentShadingRateFeaturesKHR physicalDeviceFragmentShadingRateFeaturesKHR = {};
physicalDeviceFragmentShadingRateFeaturesKHR.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_SHADING_RATE_FEATURES_KHR;
physicalDeviceFragmentShadingRateFeaturesKHR.attachmentFragmentShadingRate = VK_TRUE;
physicalDeviceFragmentShadingRateFeaturesKHR.pipelineFragmentShadingRate = VK_TRUE;
physicalDeviceFragmentShadingRateFeaturesKHR.primitiveFragmentShadingRate = VK_TRUE;
physicalDeviceFragmentShadingRateFeaturesKHR.pNext = &physicalDeviceFeatures2;

VkDeviceCreateInfo device_info = {};
device_info.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO;
device_info.pNext = &physicalDeviceFeatures2;
device_info.pNext = this->IsVRSTier1Supported() ? (void*) &physicalDeviceFragmentShadingRateFeaturesKHR : &physicalDeviceFeatures2;
device_info.queueCreateInfoCount = 2;
device_info.pQueueCreateInfos = queue_info;
device_info.enabledExtensionCount = (uint32_t)extension_names.size();
Expand Down
4 changes: 4 additions & 0 deletions src/VK/base/Device.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ namespace CAULDRON_VK
bool IsRT11Supported() { return m_rt11Supported; }
bool IsVRSTier1Supported() { return m_vrs1Supported; }
bool IsVRSTier2Supported() { return m_vrs2Supported; }
inline VkExtent2D GetVRSTileSize(){ return m_vrsTileSize; }
inline VkExtent2D GetFragmentShadingRateAttachmentTexelSize(){ return m_fragmentShadingRateAttachmentTexelSize; }

// pipeline cache
VkPipelineCache m_pipelineCache;
Expand Down Expand Up @@ -102,6 +104,8 @@ namespace CAULDRON_VK
bool m_rt11Supported = false;
bool m_vrs1Supported = false;
bool m_vrs2Supported = false;
VkExtent2D m_vrsTileSize = {0, 0};
VkExtent2D m_fragmentShadingRateAttachmentTexelSize = {0, 0};
#ifdef USE_VMA
VmaAllocator m_hAllocator = NULL;
#endif
Expand Down
17 changes: 16 additions & 1 deletion src/VK/base/ExtVRS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,35 @@ namespace CAULDRON_VK
{
static VkPhysicalDeviceFragmentShadingRateFeaturesKHR VRSQueryFeatures = {};

void ExtVRSCheckExtensions(DeviceProperties* pDP, bool& Tier1Supported, bool& Tier2Supported)
void ExtVRSCheckExtensions(DeviceProperties* pDP, bool& Tier1Supported, bool& Tier2Supported, VkExtent2D& MaxFragmentSize, VkExtent2D& FragmentShadingRateAttachmentTexelSize)
{
if (pDP->AddDeviceExtensionName(VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME))
{
pDP->AddDeviceExtensionName(VK_KHR_CREATE_RENDERPASS_2_EXTENSION_NAME);

VRSQueryFeatures.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_SHADING_RATE_FEATURES_KHR;
VRSQueryFeatures.attachmentFragmentShadingRate = VK_TRUE;
VRSQueryFeatures.pipelineFragmentShadingRate = VK_TRUE;
VRSQueryFeatures.primitiveFragmentShadingRate = VK_TRUE;
VkPhysicalDeviceFeatures2 features = {};
features.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
features.pNext = &VRSQueryFeatures;
vkGetPhysicalDeviceFeatures2(pDP->GetPhysicalDevice(), &features);

Tier1Supported = VRSQueryFeatures.pipelineFragmentShadingRate;
Tier2Supported = VRSQueryFeatures.attachmentFragmentShadingRate && VRSQueryFeatures.primitiveFragmentShadingRate;

VkPhysicalDeviceFragmentShadingRatePropertiesKHR physicalDeviceFragmentShadingRateProperties = {VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_SHADING_RATE_PROPERTIES_KHR};
{
VkPhysicalDeviceProperties2KHR deviceProperties = {};
{
deviceProperties.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2;
deviceProperties.pNext = &physicalDeviceFragmentShadingRateProperties;
}
vkGetPhysicalDeviceProperties2(pDP->GetPhysicalDevice(), &deviceProperties);
}
MaxFragmentSize = physicalDeviceFragmentShadingRateProperties.maxFragmentSize;
FragmentShadingRateAttachmentTexelSize = physicalDeviceFragmentShadingRateProperties.maxFragmentShadingRateAttachmentTexelSize;
}
}
}
2 changes: 1 addition & 1 deletion src/VK/base/ExtVRS.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@

namespace CAULDRON_VK
{
void ExtVRSCheckExtensions(DeviceProperties* pDP, bool& Tier1Supported, bool& Tier2Supported);
void ExtVRSCheckExtensions(DeviceProperties* pDP, bool& Tier1Supported, bool& Tier2Supported, VkExtent2D& FragmentShadingRateAttachmentTexelSize, VkExtent2D& MaxFragmentSize);
}

2 changes: 1 addition & 1 deletion src/VK/base/FrameworkWindows.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ namespace CAULDRON_VK
void HandleFullScreen();
void OnActivate(bool windowActive);
void OnWindowMove();
void UpdateDisplay(bool disableLocalDimming);
void UpdateDisplay(bool disableLocalDimming = 0);
void OnResize(uint32_t Width, uint32_t Height);
void OnLocalDimmingChanged();

Expand Down
Loading

0 comments on commit ef84ae9

Please sign in to comment.