Skip to content
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

Vulkan 1.1 fallback for vkGetBufferMemoryRequirements2KHR #77

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
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 ..
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