diff --git a/ffx-api/BuildFfxApiDllDx12.bat b/ffx-api/BuildFfxApiDllDx12.bat new file mode 100644 index 0000000..e497473 --- /dev/null +++ b/ffx-api/BuildFfxApiDllDx12.bat @@ -0,0 +1,43 @@ +:: This file is part of the FidelityFX SDK. +:: +:: Copyright (C) 2024 Advanced Micro Devices, Inc. +:: +:: Permission is hereby granted, free of charge, to any person obtaining a copy +:: of this software and associated documentation files(the "Software"), to deal +:: in the Software without restriction, including without limitation the rights +:: to use, copy, modify, merge, publish, distribute, sublicense, and /or sell +:: copies of the Software, and to permit persons to whom the Software is +:: furnished to do so, subject to the following conditions : +:: +:: The above copyright notice and this permission notice shall be included in +:: all copies or substantial portions of the Software. +:: +:: THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +:: IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +:: FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +:: AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +:: LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +:: OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +:: THE SOFTWARE. + +@echo off + +if not exist build\ ( + mkdir build +) + +cd build +:: Clear out CMakeCache +if exist CMakeFiles\ ( + rmdir /S /Q CMakeFiles +) +if exist CMakeCache.txt ( + del /S /Q CMakeCache.txt +) +cmake .. %*% -DFFX_API_BACKEND=DX12_X64 +::cmake --build ./ --config Debug --parallel 4 -- /p:CL_MPcount=16 +cmake --build ./ --config Release --parallel 4 -- /p:CL_MPcount=16 +::cmake --build ./ --config RelWithDebInfo --parallel 4 -- /p:CL_MPcount=16 + +:: Come back to root level +cd .. diff --git a/ffx-api/BuildFfxApiDllVk.bat b/ffx-api/BuildFfxApiDllVk.bat new file mode 100644 index 0000000..3a8524e --- /dev/null +++ b/ffx-api/BuildFfxApiDllVk.bat @@ -0,0 +1,43 @@ +:: This file is part of the FidelityFX SDK. +:: +:: Copyright (C) 2024 Advanced Micro Devices, Inc. +:: +:: Permission is hereby granted, free of charge, to any person obtaining a copy +:: of this software and associated documentation files(the "Software"), to deal +:: in the Software without restriction, including without limitation the rights +:: to use, copy, modify, merge, publish, distribute, sublicense, and /or sell +:: copies of the Software, and to permit persons to whom the Software is +:: furnished to do so, subject to the following conditions : +:: +:: The above copyright notice and this permission notice shall be included in +:: all copies or substantial portions of the Software. +:: +:: THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +:: IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +:: FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +:: AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +:: LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +:: OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +:: THE SOFTWARE. + +@echo off + +if not exist build\ ( + mkdir build +) + +cd build +:: Clear out CMakeCache +if exist CMakeFiles\ ( + rmdir /S /Q CMakeFiles +) +if exist CMakeCache.txt ( + del /S /Q CMakeCache.txt +) +cmake -DFFX_API_BACKEND=VK_X64 -A x64 .. %*% +::cmake --build ./ --config Debug --parallel 4 -- /p:CL_MPcount=16 +cmake --build ./ --config Release --parallel 4 -- /p:CL_MPcount=16 +::cmake --build ./ --config RelWithDebInfo --parallel 4 -- /p:CL_MPcount=16 + +:: Come back to root level +cd .. diff --git a/ffx-api/include/ffx_api/vk/ffx_api_vk.h b/ffx-api/include/ffx_api/vk/ffx_api_vk.h index 1f56ea6..0b17cff 100644 --- a/ffx-api/include/ffx_api/vk/ffx_api_vk.h +++ b/ffx-api/include/ffx_api/vk/ffx_api_vk.h @@ -102,15 +102,7 @@ struct ffxConfigureDescFrameGenerationSwapChainKeyValueVK //enum value matches enum FfxFrameInterpolationSwapchainConfigureKey enum FfxApiConfigureFrameGenerationSwapChainKeyVK { - FFX_API_CONFIGURE_FG_SWAPCHAIN_KEY_WAITCALLBACK = 0, ///< Sets FfxWaitCallbackFunc - FFX_API_CONFIGURE_FG_SWAPCHAIN_KEY_FRAMEPACINGTUNING = 2, ///< Sets FfxApiSwapchainFramePacingTuning casted from ptr -}; - -#define FFX_API_QUERY_DESC_TYPE_FRAMEGENERATIONSWAPCHAIN_GPU_MEMORY_USAGE_VK 0x00040009u -struct ffxQueryFrameGenerationSwapChainGetGPUMemoryUsageVK -{ - ffxQueryDescHeader header; - struct FfxApiEffectMemoryUsage* gpuMemoryUsageFrameGenerationSwapchain; + FFX_API_CONFIGURE_FG_SWAPCHAIN_KEY_WAITCALLBACK_VK = 0 ///< Sets FfxWaitCallbackFunc }; /// Function to get the number of presents. This is useful when using frame interpolation diff --git a/samples/fsrapi/fsrapirendermodule.cpp b/samples/fsrapi/fsrapirendermodule.cpp index 393a558..de0da49 100644 --- a/samples/fsrapi/fsrapirendermodule.cpp +++ b/samples/fsrapi/fsrapirendermodule.cpp @@ -599,10 +599,11 @@ void FSRRenderModule::InitUI(UISection* pUISection) [this](float, float) { #if defined(FFX_API_DX12) ffx::ConfigureDescFrameGenerationSwapChainKeyValueDX12 m_swapchainKeyValueConfig{}; + m_swapchainKeyValueConfig.key = FFX_API_CONFIGURE_FG_SWAPCHAIN_KEY_FRAMEPACINGTUNING; #elif defined(FFX_API_VK) ffx::ConfigureDescFrameGenerationSwapChainKeyValueVK m_swapchainKeyValueConfig{}; + m_swapchainKeyValueConfig.key = FFX_API_CONFIGURE_FG_SWAPCHAIN_KEY_FRAMEPACINGTUNING_VK; #endif - m_swapchainKeyValueConfig.key = FFX_API_CONFIGURE_FG_SWAPCHAIN_KEY_FRAMEPACINGTUNING; m_swapchainKeyValueConfig.ptr = &framePacingTuning; framePacingTuning.safetyMarginInMs = m_SafetyMarginInMs; @@ -618,10 +619,11 @@ void FSRRenderModule::InitUI(UISection* pUISection) [this](float, float) { #if defined(FFX_API_DX12) ffx::ConfigureDescFrameGenerationSwapChainKeyValueDX12 m_swapchainKeyValueConfig{}; + m_swapchainKeyValueConfig.key = FFX_API_CONFIGURE_FG_SWAPCHAIN_KEY_FRAMEPACINGTUNING; #elif defined(FFX_API_VK) ffx::ConfigureDescFrameGenerationSwapChainKeyValueVK m_swapchainKeyValueConfig{}; + m_swapchainKeyValueConfig.key = FFX_API_CONFIGURE_FG_SWAPCHAIN_KEY_FRAMEPACINGTUNING_VK; #endif - m_swapchainKeyValueConfig.key = FFX_API_CONFIGURE_FG_SWAPCHAIN_KEY_FRAMEPACINGTUNING; m_swapchainKeyValueConfig.ptr = &framePacingTuning; framePacingTuning.varianceFactor = m_VarianceFactor; @@ -636,10 +638,11 @@ void FSRRenderModule::InitUI(UISection* pUISection) [this](bool, bool) { #if defined(FFX_API_DX12) ffx::ConfigureDescFrameGenerationSwapChainKeyValueDX12 m_swapchainKeyValueConfig{}; + m_swapchainKeyValueConfig.key = FFX_API_CONFIGURE_FG_SWAPCHAIN_KEY_FRAMEPACINGTUNING; #elif defined(FFX_API_VK) ffx::ConfigureDescFrameGenerationSwapChainKeyValueVK m_swapchainKeyValueConfig{}; + m_swapchainKeyValueConfig.key = FFX_API_CONFIGURE_FG_SWAPCHAIN_KEY_FRAMEPACINGTUNING_VK; #endif - m_swapchainKeyValueConfig.key = FFX_API_CONFIGURE_FG_SWAPCHAIN_KEY_FRAMEPACINGTUNING; m_swapchainKeyValueConfig.ptr = &framePacingTuning; framePacingTuning.allowHybridSpin = m_AllowHybridSpin; @@ -654,10 +657,11 @@ void FSRRenderModule::InitUI(UISection* pUISection) [this](int32_t, int32_t) { #if defined(FFX_API_DX12) ffx::ConfigureDescFrameGenerationSwapChainKeyValueDX12 m_swapchainKeyValueConfig{}; + m_swapchainKeyValueConfig.key = FFX_API_CONFIGURE_FG_SWAPCHAIN_KEY_FRAMEPACINGTUNING; #elif defined(FFX_API_VK) ffx::ConfigureDescFrameGenerationSwapChainKeyValueVK m_swapchainKeyValueConfig{}; + m_swapchainKeyValueConfig.key = FFX_API_CONFIGURE_FG_SWAPCHAIN_KEY_FRAMEPACINGTUNING_VK; #endif - m_swapchainKeyValueConfig.key = FFX_API_CONFIGURE_FG_SWAPCHAIN_KEY_FRAMEPACINGTUNING; m_swapchainKeyValueConfig.ptr = &framePacingTuning; framePacingTuning.hybridSpinTime = m_HybridSpinTime; @@ -672,10 +676,11 @@ void FSRRenderModule::InitUI(UISection* pUISection) [this](bool, bool) { #if defined(FFX_API_DX12) ffx::ConfigureDescFrameGenerationSwapChainKeyValueDX12 m_swapchainKeyValueConfig{}; + m_swapchainKeyValueConfig.key = FFX_API_CONFIGURE_FG_SWAPCHAIN_KEY_FRAMEPACINGTUNING; #elif defined(FFX_API_VK) ffx::ConfigureDescFrameGenerationSwapChainKeyValueVK m_swapchainKeyValueConfig{}; + m_swapchainKeyValueConfig.key = FFX_API_CONFIGURE_FG_SWAPCHAIN_KEY_FRAMEPACINGTUNING_VK; #endif - m_swapchainKeyValueConfig.key = FFX_API_CONFIGURE_FG_SWAPCHAIN_KEY_FRAMEPACINGTUNING; m_swapchainKeyValueConfig.ptr = &framePacingTuning; framePacingTuning.allowWaitForSingleObjectOnFence = m_AllowWaitForSingleObjectOnFence; diff --git a/sdk/src/backends/dx12/FrameInterpolationSwapchain/FrameInterpolationSwapchainDX12.cpp b/sdk/src/backends/dx12/FrameInterpolationSwapchain/FrameInterpolationSwapchainDX12.cpp index 90cf777..0a5e0b7 100644 --- a/sdk/src/backends/dx12/FrameInterpolationSwapchain/FrameInterpolationSwapchainDX12.cpp +++ b/sdk/src/backends/dx12/FrameInterpolationSwapchain/FrameInterpolationSwapchainDX12.cpp @@ -1746,6 +1746,8 @@ HRESULT STDMETHODCALLTYPE FrameInterpolationSwapChainDX12::ResizeBuffers(UINT Bu LeaveCriticalSection(&criticalSection); + verifyBackbufferDuplicateResources(); + return hr; } diff --git a/sdk/src/backends/vk/ffx_vk.cpp b/sdk/src/backends/vk/ffx_vk.cpp index ef187c3..046a65e 100644 --- a/sdk/src/backends/vk/ffx_vk.cpp +++ b/sdk/src/backends/vk/ffx_vk.cpp @@ -1470,7 +1470,13 @@ FfxErrorCode CreateBackendContextVK(FfxInterface* backendInterface, FfxEffect ef backendContext->vkFunctionTable.vkDestroySampler = (PFN_vkDestroySampler)vkDeviceContext->vkDeviceProcAddr(backendContext->device, "vkDestroySampler"); backendContext->vkFunctionTable.vkDestroyShaderModule = (PFN_vkDestroyShaderModule)vkDeviceContext->vkDeviceProcAddr(backendContext->device, "vkDestroyShaderModule"); backendContext->vkFunctionTable.vkGetBufferMemoryRequirements = (PFN_vkGetBufferMemoryRequirements)vkDeviceContext->vkDeviceProcAddr(backendContext->device, "vkGetBufferMemoryRequirements"); + backendContext->vkFunctionTable.vkGetBufferMemoryRequirements2KHR = (PFN_vkGetBufferMemoryRequirements2KHR)vkDeviceContext->vkDeviceProcAddr(backendContext->device, "vkGetBufferMemoryRequirements2KHR"); + + // If extension not found try loading it from Core 1.1 + if (!backendContext->vkFunctionTable.vkGetBufferMemoryRequirements2KHR) + backendContext->vkFunctionTable.vkGetBufferMemoryRequirements2KHR = (PFN_vkGetBufferMemoryRequirements2KHR)vkDeviceContext->vkDeviceProcAddr(backendContext->device, "vkGetBufferMemoryRequirements2"); + backendContext->vkFunctionTable.vkGetImageMemoryRequirements = (PFN_vkGetImageMemoryRequirements)vkDeviceContext->vkDeviceProcAddr(backendContext->device, "vkGetImageMemoryRequirements"); backendContext->vkFunctionTable.vkAllocateDescriptorSets = (PFN_vkAllocateDescriptorSets)vkDeviceContext->vkDeviceProcAddr(backendContext->device, "vkAllocateDescriptorSets"); backendContext->vkFunctionTable.vkFreeDescriptorSets = (PFN_vkFreeDescriptorSets)vkDeviceContext->vkDeviceProcAddr(backendContext->device, "vkFreeDescriptorSets"); @@ -4154,11 +4160,12 @@ FfxErrorCode ExecuteGpuJobsVK(FfxInterface* backendInterface, FfxCommandList com { FfxGpuJobDescription* gpuJob = &backendContext->pGpuJobs[i]; +#ifdef _DEBUG // If we have a label for the job, drop a marker for it if (gpuJob->jobLabel[0]) { beginMarkerVK(backendContext, vkCommandBuffer, gpuJob->jobLabel); } - +#endif switch (gpuJob->jobType) { @@ -4185,9 +4192,11 @@ FfxErrorCode ExecuteGpuJobsVK(FfxInterface* backendInterface, FfxCommandList com default:; } +#ifdef _DEBUG if (gpuJob->jobLabel[0]) { endMarkerVK(backendContext, vkCommandBuffer); } +#endif } // check the execute function returned cleanly.