Skip to content

Vulkan 1.1 fallback for vkGetBufferMemoryRequirements2KHR #77

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions ffx-api/BuildFfxApiDllDx12.bat
Original file line number Diff line number Diff line change
@@ -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 ..
43 changes: 43 additions & 0 deletions ffx-api/BuildFfxApiDllVk.bat
Original file line number Diff line number Diff line change
@@ -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 ..
10 changes: 1 addition & 9 deletions ffx-api/include/ffx_api/vk/ffx_api_vk.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 10 additions & 5 deletions samples/fsrapi/fsrapirendermodule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1746,6 +1746,8 @@ HRESULT STDMETHODCALLTYPE FrameInterpolationSwapChainDX12::ResizeBuffers(UINT Bu

LeaveCriticalSection(&criticalSection);

verifyBackbufferDuplicateResources();

return hr;
}

Expand Down
11 changes: 10 additions & 1 deletion sdk/src/backends/vk/ffx_vk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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)
{
Expand All @@ -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.
Expand Down