diff --git a/BuildUtils.cmake b/BuildTools/CMake/BuildUtils.cmake similarity index 100% rename from BuildUtils.cmake rename to BuildTools/CMake/BuildUtils.cmake diff --git a/BuildTools/CMake/CheckATL.cpp b/BuildTools/CMake/CheckATL.cpp new file mode 100644 index 0000000000..39b6a18e2e --- /dev/null +++ b/BuildTools/CMake/CheckATL.cpp @@ -0,0 +1,6 @@ +#include + +int main() +{ + return 0; +} diff --git a/BuildTools/CMake/CheckD3D11.cpp b/BuildTools/CMake/CheckD3D11.cpp new file mode 100644 index 0000000000..0eba52bebd --- /dev/null +++ b/BuildTools/CMake/CheckD3D11.cpp @@ -0,0 +1,6 @@ +#include + +int main() +{ + return 0; +} diff --git a/BuildTools/CMake/CheckD3D12.cpp b/BuildTools/CMake/CheckD3D12.cpp new file mode 100644 index 0000000000..374a50ef55 --- /dev/null +++ b/BuildTools/CMake/CheckD3D12.cpp @@ -0,0 +1,6 @@ +#include + +int main() +{ + return 0; +} diff --git a/CMakeLists.txt b/CMakeLists.txt index 49033651a4..c38962d757 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -99,12 +99,24 @@ endif() message("CMake generator: " ${CMAKE_GENERATOR}) if(WIN32) + if (CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION) + set(WINDOWS_SDK_VERSION ${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION} CACHE INTERNAL "Windows SDK version") + elseif(DEFINED ENV{WindowsSDKVersion}) + set(WINDOWS_SDK_VERSION $ENV{WindowsSDKVersion}) + # For unbeknown reason, the value ends with a backslash, so we need to remove it + string(REPLACE "\\" "" WINDOWS_SDK_VERSION ${WINDOWS_SDK_VERSION}) + set(WINDOWS_SDK_VERSION ${WINDOWS_SDK_VERSION} CACHE INTERNAL "Windows SDK version") + else() + set(WINDOWS_SDK_VERSION "0.0" CACHE INTERNAL "Windows SDK version") + message(WARNING "Unable to determine Windows SDK version: neither the CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION CMake variable nor the WindowsSDKVersion environment variable is set") + endif() + if(${CMAKE_SYSTEM_NAME} STREQUAL "WindowsStore") set(PLATFORM_UNIVERSAL_WINDOWS TRUE CACHE INTERNAL "Target platform: Windows Store") - message("Target platform: Universal Windows " ${ARCH} ". SDK Version: " ${CMAKE_SYSTEM_VERSION}) + message("Target platform: Universal Windows " ${ARCH} ". Windows SDK Version: " ${WINDOWS_SDK_VERSION}) else() set(PLATFORM_WIN32 TRUE CACHE INTERNAL "Target platform: Win32") #WIN32 is a variable, so we cannot use string "WIN32" - message("Target platform: Win32 " ${ARCH} ". SDK Version: " ${CMAKE_SYSTEM_VERSION}) + message("Target platform: Win32 " ${ARCH} ". Windows SDK Version: " ${WINDOWS_SDK_VERSION}) endif() else() if(${CMAKE_SYSTEM_NAME} STREQUAL "Android") @@ -141,28 +153,34 @@ endif() add_library(Diligent-PublicBuildSettings INTERFACE) -if(PLATFORM_WIN32) - if(MSVC) - set(D3D11_SUPPORTED TRUE CACHE INTERNAL "D3D11 is supported on Win32 platform") - if(CMAKE_SYSTEM_VERSION VERSION_GREATER_EQUAL "10.0") - set(D3D12_SUPPORTED TRUE CACHE INTERNAL "D3D12 is supported on Win32 platform") - endif() +if(PLATFORM_WIN32 OR PLATFORM_UNIVERSAL_WINDOWS) + try_compile(HAS_D3D11 "${CMAKE_CURRENT_BINARY_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/BuildTools/CMake/CheckD3D11.cpp") + try_compile(HAS_D3D12 "${CMAKE_CURRENT_BINARY_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/BuildTools/CMake/CheckD3D12.cpp") + try_compile(HAS_ATL "${CMAKE_CURRENT_BINARY_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/BuildTools/CMake/CheckATL.cpp") + + if (HAS_D3D11 AND HAS_ATL) + set(D3D11_SUPPORTED TRUE CACHE INTERNAL "D3D11 is supported") else() - message("Building with MinGW") - set(MINGW_BUILD TRUE CACHE INTERNAL "Building with MinGW") - set(D3D11_SUPPORTED FALSE CACHE INTERNAL "D3D11 requires compiling with MSVC") - set(D3D12_SUPPORTED FALSE CACHE INTERNAL "D3D12 requires compiling with MSVC") + set(D3D11_SUPPORTED FALSE CACHE INTERNAL "D3D11 is not supported") endif() + if (HAS_D3D12 AND HAS_ATL) + set(D3D12_SUPPORTED TRUE CACHE INTERNAL "D3D12 is supported") + else() + set(D3D12_SUPPORTED FALSE CACHE INTERNAL "D3D12 is not supported") + endif() +endif() + +if(${CMAKE_GENERATOR} MATCHES "MinGW") + message("Building with MinGW") + set(MINGW_BUILD TRUE CACHE INTERNAL "Building with MinGW") +endif() +if(PLATFORM_WIN32) set(GL_SUPPORTED TRUE CACHE INTERNAL "OpenGL is supported on Win32 platform") set(VULKAN_SUPPORTED TRUE CACHE INTERNAL "Vulkan is supported on Win32 platform") set(ARCHIVER_SUPPORTED TRUE CACHE INTERNAL "Archiver is supported on Win32 platform") target_compile_definitions(Diligent-PublicBuildSettings INTERFACE PLATFORM_WIN32=1) elseif(PLATFORM_UNIVERSAL_WINDOWS) - set(D3D11_SUPPORTED TRUE CACHE INTERNAL "D3D11 is supported on Universal Windows platform") - if(CMAKE_SYSTEM_VERSION VERSION_GREATER_EQUAL "10.0") - set(D3D12_SUPPORTED TRUE CACHE INTERNAL "D3D12 is supported on Universal Windows platform") - endif() set(ARCHIVER_SUPPORTED TRUE CACHE INTERNAL "Archiver is supported on Universal Windows platform") target_compile_definitions(Diligent-PublicBuildSettings INTERFACE PLATFORM_UNIVERSAL_WINDOWS=1) elseif(PLATFORM_ANDROID) @@ -496,7 +514,7 @@ elseif (NOT IS_ABSOLUTE ${CMAKE_INSTALL_PREFIX}) message("Transformed CMAKE_INSTALL_PREFIX into absolute path: " ${CMAKE_INSTALL_PREFIX}) endif() -include(BuildUtils.cmake) +include(BuildTools/CMake/BuildUtils.cmake) if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows") # Find available .NET SDKs diff --git a/Graphics/GraphicsEngineD3DBase/CMakeLists.txt b/Graphics/GraphicsEngineD3DBase/CMakeLists.txt index 8641e99ef5..61befc0485 100644 --- a/Graphics/GraphicsEngineD3DBase/CMakeLists.txt +++ b/Graphics/GraphicsEngineD3DBase/CMakeLists.txt @@ -80,7 +80,7 @@ if(MSVC) # Note that CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION is stated to be defined when targeting Windows 10 # and above, however it is also defined when targeting 8.1 and Visual Studio 2019 (but not VS2017) - if(CMAKE_SYSTEM_VERSION VERSION_GREATER_EQUAL "10.0") + if("${WINDOWS_SDK_VERSION}" VERSION_GREATER_EQUAL "10.0") if (DEFINED CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION) # Note that VS_WINDOWS_SDK_BIN_DIR as well as all derived paths can only be used in Visual Studio # commands and are not valid paths during CMake configuration @@ -94,7 +94,7 @@ if(MSVC) set(VS_DXIL_SIGNER_PATH "\"${VS_WINDOWS_SDK_BIN_DIR}\\dxil.dll\"" CACHE INTERNAL "dxil.dll path") endif() endif() - elseif(CMAKE_SYSTEM_VERSION VERSION_EQUAL "8.1") + elseif("${WINDOWS_SDK_VERSION}" VERSION_EQUAL "8.1") # D3Dcompiler_47.dll from Win8.1 SDK is ancient (from 2013) and fails to # compile a number of test shaders. Use the compiler from Visual Studio # executable path instead diff --git a/Tests/DiligentCoreAPITest/assets/shaders/PipelineResourceSignature/RunTimeResourceArray.hlsl b/Tests/DiligentCoreAPITest/assets/shaders/PipelineResourceSignature/RunTimeResourceArray.hlsl index 20e4cb3cd7..181e9d6e05 100644 --- a/Tests/DiligentCoreAPITest/assets/shaders/PipelineResourceSignature/RunTimeResourceArray.hlsl +++ b/Tests/DiligentCoreAPITest/assets/shaders/PipelineResourceSignature/RunTimeResourceArray.hlsl @@ -151,10 +151,6 @@ float4 VerifyResources(uint index, float2 coord) uint RWStructBuffIdx = index % NUM_RWSTRUCT_BUFFERS; uint RWFmtBuffIdx = index % NUM_RWFMT_BUFFERS; -#ifdef USE_D3D12_WARP_BUG_WORKAROUND - ConstBuffIdx = 0; -#endif - float4 AllCorrect = float4(1.0, 1.0, 1.0, 1.0); AllCorrect *= CheckValue(g_Textures[TEXTURES_NONUNIFORM(TexIdx)].SampleLevel(g_Samplers[NonUniformResourceIndex(SamIdx)], coord, 0.0), TexRefValues[TexIdx]); AllCorrect *= CheckValue(g_ConstantBuffers[CONST_BUFFERS_NONUNIFORM(ConstBuffIdx)].Data, ConstBuffRefValues[ConstBuffIdx]); diff --git a/Tests/DiligentCoreAPITest/src/PipelineResourceSignatureTest.cpp b/Tests/DiligentCoreAPITest/src/PipelineResourceSignatureTest.cpp index d0d45b6212..a5f881e6bc 100644 --- a/Tests/DiligentCoreAPITest/src/PipelineResourceSignatureTest.cpp +++ b/Tests/DiligentCoreAPITest/src/PipelineResourceSignatureTest.cpp @@ -1808,12 +1808,6 @@ static void TestRunTimeResourceArray(bool IsGLSL, IShaderSourceInputStreamFactor Macros.AddShaderMacro("RWSTRUCT_BUFFERS_NONUNIFORM_INDEXING", UAVBufferNonUniformIndexing ? 1 : 0); Macros.AddShaderMacro("RWFMT_BUFFERS_NONUNIFORM_INDEXING", UAVBufferNonUniformIndexing ? 1 : 0); - if (pEnv->NeedWARPResourceArrayIndexingBugWorkaround()) - { - // Constant buffer indexing does not work properly in D3D12 WARP - only the 0th element is accessed correctly - Macros.AddShaderMacro("USE_D3D12_WARP_BUG_WORKAROUND", 1); - } - if (IsGLSL) Macros.AddShaderMacro("float4", "vec4"); for (Uint32 i = 0; i < TexArraySize; ++i)