Commit 0b3d56aa by Alexis Hetu Committed by Alexis Hétu

Vulkan unit tests

Added small Vulkan unit tests: 1) Checks that all API functions are present 2) Verifies a few Physical Device properties The tests are currently only for Visual Studio, but should be easily ported to other platforms, as the code is similar to the GLES unit tests. Change-Id: Idb45d26734be80e352ba91544e6331c1192f9f3e Reviewed-on: https://swiftshader-review.googlesource.com/c/21648Tested-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent d16a5041
...@@ -260,6 +260,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Vulkan", "src\Vulkan\vulkan ...@@ -260,6 +260,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Vulkan", "src\Vulkan\vulkan
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ReactorUnitTests", "src\Reactor\ReactorUnitTests.vcxproj", "{4EC107AB-89E8-4A0B-8366-B3E81085AE07}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ReactorUnitTests", "src\Reactor\ReactorUnitTests.vcxproj", "{4EC107AB-89E8-4A0B-8366-B3E81085AE07}"
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "VulkanUnitTests", "tests\VulkanUnitTests\VulkanUnitTests.vcxproj", "{16E1EBC1-BB6B-4A82-A1A3-5A69AC8D58FE}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32 Debug|Win32 = Debug|Win32
...@@ -783,6 +785,18 @@ Global ...@@ -783,6 +785,18 @@ Global
{4EC107AB-89E8-4A0B-8366-B3E81085AE07}.Release|Win32.Build.0 = Release|Win32 {4EC107AB-89E8-4A0B-8366-B3E81085AE07}.Release|Win32.Build.0 = Release|Win32
{4EC107AB-89E8-4A0B-8366-B3E81085AE07}.Release|x64.ActiveCfg = Release|x64 {4EC107AB-89E8-4A0B-8366-B3E81085AE07}.Release|x64.ActiveCfg = Release|x64
{4EC107AB-89E8-4A0B-8366-B3E81085AE07}.Release|x64.Build.0 = Release|x64 {4EC107AB-89E8-4A0B-8366-B3E81085AE07}.Release|x64.Build.0 = Release|x64
{16E1EBC1-BB6B-4A82-A1A3-5A69AC8D58FE}.Debug|Win32.ActiveCfg = Debug|Win32
{16E1EBC1-BB6B-4A82-A1A3-5A69AC8D58FE}.Debug|Win32.Build.0 = Debug|Win32
{16E1EBC1-BB6B-4A82-A1A3-5A69AC8D58FE}.Debug|x64.ActiveCfg = Debug|x64
{16E1EBC1-BB6B-4A82-A1A3-5A69AC8D58FE}.Debug|x64.Build.0 = Debug|x64
{16E1EBC1-BB6B-4A82-A1A3-5A69AC8D58FE}.Profile|Win32.ActiveCfg = Release|Win32
{16E1EBC1-BB6B-4A82-A1A3-5A69AC8D58FE}.Profile|Win32.Build.0 = Release|Win32
{16E1EBC1-BB6B-4A82-A1A3-5A69AC8D58FE}.Profile|x64.ActiveCfg = Release|x64
{16E1EBC1-BB6B-4A82-A1A3-5A69AC8D58FE}.Profile|x64.Build.0 = Release|x64
{16E1EBC1-BB6B-4A82-A1A3-5A69AC8D58FE}.Release|Win32.ActiveCfg = Release|Win32
{16E1EBC1-BB6B-4A82-A1A3-5A69AC8D58FE}.Release|Win32.Build.0 = Release|Win32
{16E1EBC1-BB6B-4A82-A1A3-5A69AC8D58FE}.Release|x64.ActiveCfg = Release|x64
{16E1EBC1-BB6B-4A82-A1A3-5A69AC8D58FE}.Release|x64.Build.0 = Release|x64
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
...@@ -825,6 +839,7 @@ Global ...@@ -825,6 +839,7 @@ Global
{CF8EBC89-8762-49DC-9440-6C82B3499913} = {ED25C308-5BDB-43A7-BED6-C2C059FC2D7D} {CF8EBC89-8762-49DC-9440-6C82B3499913} = {ED25C308-5BDB-43A7-BED6-C2C059FC2D7D}
{FBDCFF88-0CE1-43C3-B694-8F45946FAFE3} = {ED25C308-5BDB-43A7-BED6-C2C059FC2D7D} {FBDCFF88-0CE1-43C3-B694-8F45946FAFE3} = {ED25C308-5BDB-43A7-BED6-C2C059FC2D7D}
{4EC107AB-89E8-4A0B-8366-B3E81085AE07} = {ED25C308-5BDB-43A7-BED6-C2C059FC2D7D} {4EC107AB-89E8-4A0B-8366-B3E81085AE07} = {ED25C308-5BDB-43A7-BED6-C2C059FC2D7D}
{16E1EBC1-BB6B-4A82-A1A3-5A69AC8D58FE} = {ED25C308-5BDB-43A7-BED6-C2C059FC2D7D}
EndGlobalSection EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {4DF423D2-8425-48A7-9CEC-835C4C3CA957} SolutionGuid = {4DF423D2-8425-48A7-9CEC-835C4C3CA957}
......
// Copyright 2017 The SwiftShader Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef SWIFTSHADER_TEST_H_
#define SWIFTSHADER_TEST_H_
#include <gtest/gtest.h>
class SwiftShaderTestEnvironment : public testing::Environment {
public:
void SetUp() override {}
void TearDown() override {}
};
#endif // SWIFTSHADER_TEST_H_
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{16E1EBC1-BB6B-4A82-A1A3-5A69AC8D58FE}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>GLESUnitTests</RootNamespace>
<WindowsTargetPlatformVersion>10.0.16299.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<IncludePath>$(IncludePath)</IncludePath>
<IntDir>$(SolutionDir)obj\$(MSBuildProjectName)\$(Platform)\$(Configuration)\</IntDir>
<OutDir>$(SolutionDir)bin\$(MSBuildProjectName)\$(Platform)\$(Configuration)\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
<IncludePath>$(IncludePath)</IncludePath>
<IntDir>$(SolutionDir)obj\$(MSBuildProjectName)\$(Platform)\$(Configuration)\</IntDir>
<OutDir>$(SolutionDir)bin\$(MSBuildProjectName)\$(Platform)\$(Configuration)\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<IncludePath>$(IncludePath)</IncludePath>
<IntDir>$(SolutionDir)obj\$(MSBuildProjectName)\$(Platform)\$(Configuration)\</IntDir>
<OutDir>$(SolutionDir)bin\$(MSBuildProjectName)\$(Platform)\$(Configuration)\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<IncludePath>$(IncludePath)</IncludePath>
<IntDir>$(SolutionDir)obj\$(MSBuildProjectName)\$(Platform)\$(Configuration)\</IntDir>
<OutDir>$(SolutionDir)bin\$(MSBuildProjectName)\$(Platform)\$(Configuration)\</OutDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>GL_GLEXT_PROTOTYPES;STANDALONE;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(SolutionDir)include\;$(SolutionDir)third_party\googletest\googletest\include\;$(SolutionDir)third_party\googletest\googletest\;$(SolutionDir)third_party\googletest\googlemock\include\;SubmoduleCheck;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<ForcedIncludeFiles>
</ForcedIncludeFiles>
<TreatSpecificWarningsAsErrors>4018;5038;4838</TreatSpecificWarningsAsErrors>
<AdditionalOptions>/permissive- %(AdditionalOptions)</AdditionalOptions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>GL_GLEXT_PROTOTYPES;STANDALONE;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(SolutionDir)include\;$(SolutionDir)third_party\googletest\googletest\include\;$(SolutionDir)third_party\googletest\googletest\;$(SolutionDir)third_party\googletest\googlemock\include\;SubmoduleCheck;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<ForcedIncludeFiles>
</ForcedIncludeFiles>
<TreatSpecificWarningsAsErrors>4018;5038;4838</TreatSpecificWarningsAsErrors>
<AdditionalOptions>/permissive- %(AdditionalOptions)</AdditionalOptions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>GL_GLEXT_PROTOTYPES;STANDALONE;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(SolutionDir)include\;$(SolutionDir)third_party\googletest\googletest\include\;$(SolutionDir)third_party\googletest\googletest\;$(SolutionDir)third_party\googletest\googlemock\include\;SubmoduleCheck;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<ForcedIncludeFiles>
</ForcedIncludeFiles>
<TreatSpecificWarningsAsErrors>4018;5038;4838</TreatSpecificWarningsAsErrors>
<AdditionalOptions>/permissive- %(AdditionalOptions)</AdditionalOptions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>GL_GLEXT_PROTOTYPES;STANDALONE;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(SolutionDir)include\;$(SolutionDir)third_party\googletest\googletest\include\;$(SolutionDir)third_party\googletest\googletest\;$(SolutionDir)third_party\googletest\googlemock\include\;SubmoduleCheck;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<ForcedIncludeFiles>
</ForcedIncludeFiles>
<TreatSpecificWarningsAsErrors>4018;5038;4838</TreatSpecificWarningsAsErrors>
<AdditionalOptions>/permissive- %(AdditionalOptions)</AdditionalOptions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\third_party\googletest\googletest\src\gtest-all.cc" />
<ClCompile Include="main.cpp" />
<ClCompile Include="unittests.cpp" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\OpenGL\libEGL\libEGL.vcxproj">
<Project>{e746fca9-64c3-433e-85e8-9a5a67ab7ed6}</Project>
</ProjectReference>
<ProjectReference Include="..\..\src\OpenGL\libGLESv2\libGLESv2.vcxproj">
<Project>{b5871a7a-968c-42e3-a33b-981e6f448e78}</Project>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\third_party\googletest\googletest\src\gtest-all.cc">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="unittests.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="main.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LocalDebuggerEnvironment>PATH=$(SolutionDir)out\$(Configuration)_$(Platform)</LocalDebuggerEnvironment>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
<LocalDebuggerCommandArguments>--gtest_break_on_failure --gtest_filter=*</LocalDebuggerCommandArguments>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LocalDebuggerEnvironment>PATH=$(SolutionDir)out\$(Configuration)_$(Platform)</LocalDebuggerEnvironment>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LocalDebuggerEnvironment>PATH=$(SolutionDir)out\$(Configuration)_$(Platform)</LocalDebuggerEnvironment>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
<LocalDebuggerCommandArguments>--gtest_break_on_failure --gtest_filter=*</LocalDebuggerCommandArguments>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LocalDebuggerEnvironment>PATH=$(SolutionDir)out\$(Configuration)_$(Platform)</LocalDebuggerEnvironment>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
</Project>
// Copyright 2017 The SwiftShader Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "gtest/gtest.h"
int main(int argc, char **argv)
{
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
// Copyright 2017 The SwiftShader Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// OpenGL ES unit tests that provide coverage for functionality not tested by
// the dEQP test suite. Also used as a smoke test.
#include "gtest/gtest.h"
#include "gmock/gmock.h"
#include <vulkan/vulkan.h>
#include <vulkan/vk_icd.h>
#include <cstring>
typedef PFN_vkVoidFunction(__stdcall *vk_icdGetInstanceProcAddrPtr)(VkInstance, const char*);
#if defined(_WIN32)
#include <Windows.h>
#endif
class SwiftShaderVulkanTest : public testing::Test
{
protected:
void SetUp() override
{
HMODULE libVulkan = nullptr;
const char* libVulkanName = nullptr;
#if defined(_WIN64)
#if defined(NDEBUG)
libVulkanName = "..\\..\\..\\vulkan\\x64\\Release\\vk_swiftshader.dll";
#else
libVulkanName = "..\\..\\..\\vulkan\\x64\\Debug\\vk_swiftshader.dll";
#endif
#elif defined(_WIN32)
#if defined(NDEBUG)
libVulkanName = "..\\..\\..\\vulkan\\Win32\\Release\\vk_swiftshader.dll";
#else
libVulkanName = "..\\..\\..\\vulkan\\Win32\\Debug\\vk_swiftshader.dll";
#endif
#endif
#if defined(_WIN32)
libVulkan = LoadLibraryA(libVulkanName);
EXPECT_NE((HMODULE)NULL, libVulkan);
vk_icdGetInstanceProcAddr = (vk_icdGetInstanceProcAddrPtr)GetProcAddress(libVulkan, "vk_icdGetInstanceProcAddr");
EXPECT_NE((vk_icdGetInstanceProcAddrPtr)nullptr, vk_icdGetInstanceProcAddr);
#endif
}
vk_icdGetInstanceProcAddrPtr vk_icdGetInstanceProcAddr = nullptr;
};
TEST_F(SwiftShaderVulkanTest, API_Check)
{
if(vk_icdGetInstanceProcAddr)
{
#define API_CHECK(function) auto function = vk_icdGetInstanceProcAddr(VK_NULL_HANDLE, #function); \
EXPECT_NE(function, nullptr);
API_CHECK(vkCreateInstance);
API_CHECK(vkDestroyInstance);
API_CHECK(vkEnumeratePhysicalDevices);
API_CHECK(vkGetPhysicalDeviceFeatures);
API_CHECK(vkGetPhysicalDeviceFormatProperties);
API_CHECK(vkGetPhysicalDeviceImageFormatProperties);
API_CHECK(vkGetPhysicalDeviceProperties);
API_CHECK(vkGetPhysicalDeviceQueueFamilyProperties);
API_CHECK(vkGetPhysicalDeviceMemoryProperties);
API_CHECK(vkGetInstanceProcAddr);
API_CHECK(vkGetDeviceProcAddr);
API_CHECK(vkCreateDevice);
API_CHECK(vkDestroyDevice);
API_CHECK(vkEnumerateInstanceExtensionProperties);
API_CHECK(vkEnumerateDeviceExtensionProperties);
API_CHECK(vkEnumerateInstanceLayerProperties);
API_CHECK(vkEnumerateDeviceLayerProperties);
API_CHECK(vkGetDeviceQueue);
API_CHECK(vkQueueSubmit);
API_CHECK(vkQueueWaitIdle);
API_CHECK(vkDeviceWaitIdle);
API_CHECK(vkAllocateMemory);
API_CHECK(vkFreeMemory);
API_CHECK(vkMapMemory);
API_CHECK(vkUnmapMemory);
API_CHECK(vkFlushMappedMemoryRanges);
API_CHECK(vkInvalidateMappedMemoryRanges);
API_CHECK(vkGetDeviceMemoryCommitment);
API_CHECK(vkBindBufferMemory);
API_CHECK(vkBindImageMemory);
API_CHECK(vkGetBufferMemoryRequirements);
API_CHECK(vkGetImageMemoryRequirements);
API_CHECK(vkGetImageSparseMemoryRequirements);
API_CHECK(vkGetPhysicalDeviceSparseImageFormatProperties);
API_CHECK(vkQueueBindSparse);
API_CHECK(vkCreateFence);
API_CHECK(vkDestroyFence);
API_CHECK(vkResetFences);
API_CHECK(vkGetFenceStatus);
API_CHECK(vkWaitForFences);
API_CHECK(vkCreateSemaphore);
API_CHECK(vkDestroySemaphore);
API_CHECK(vkCreateEvent);
API_CHECK(vkDestroyEvent);
API_CHECK(vkGetEventStatus);
API_CHECK(vkSetEvent);
API_CHECK(vkResetEvent);
API_CHECK(vkCreateQueryPool);
API_CHECK(vkDestroyQueryPool);
API_CHECK(vkGetQueryPoolResults);
API_CHECK(vkCreateBuffer);
API_CHECK(vkDestroyBuffer);
API_CHECK(vkCreateBufferView);
API_CHECK(vkDestroyBufferView);
API_CHECK(vkCreateImage);
API_CHECK(vkDestroyImage);
API_CHECK(vkGetImageSubresourceLayout);
API_CHECK(vkCreateImageView);
API_CHECK(vkDestroyImageView);
API_CHECK(vkCreateShaderModule);
API_CHECK(vkDestroyShaderModule);
API_CHECK(vkCreatePipelineCache);
API_CHECK(vkDestroyPipelineCache);
API_CHECK(vkGetPipelineCacheData);
API_CHECK(vkMergePipelineCaches);
API_CHECK(vkCreateGraphicsPipelines);
API_CHECK(vkCreateComputePipelines);
API_CHECK(vkDestroyPipeline);
API_CHECK(vkCreatePipelineLayout);
API_CHECK(vkDestroyPipelineLayout);
API_CHECK(vkCreateSampler);
API_CHECK(vkDestroySampler);
API_CHECK(vkCreateDescriptorSetLayout);
API_CHECK(vkDestroyDescriptorSetLayout);
API_CHECK(vkCreateDescriptorPool);
API_CHECK(vkDestroyDescriptorPool);
API_CHECK(vkResetDescriptorPool);
API_CHECK(vkAllocateDescriptorSets);
API_CHECK(vkFreeDescriptorSets);
API_CHECK(vkUpdateDescriptorSets);
API_CHECK(vkCreateFramebuffer);
API_CHECK(vkDestroyFramebuffer);
API_CHECK(vkCreateRenderPass);
API_CHECK(vkDestroyRenderPass);
API_CHECK(vkGetRenderAreaGranularity);
API_CHECK(vkCreateCommandPool);
API_CHECK(vkDestroyCommandPool);
API_CHECK(vkResetCommandPool);
API_CHECK(vkAllocateCommandBuffers);
API_CHECK(vkFreeCommandBuffers);
API_CHECK(vkBeginCommandBuffer);
API_CHECK(vkEndCommandBuffer);
API_CHECK(vkResetCommandBuffer);
API_CHECK(vkCmdBindPipeline);
API_CHECK(vkCmdSetViewport);
API_CHECK(vkCmdSetScissor);
API_CHECK(vkCmdSetLineWidth);
API_CHECK(vkCmdSetDepthBias);
API_CHECK(vkCmdSetBlendConstants);
API_CHECK(vkCmdSetDepthBounds);
API_CHECK(vkCmdSetStencilCompareMask);
API_CHECK(vkCmdSetStencilWriteMask);
API_CHECK(vkCmdSetStencilReference);
API_CHECK(vkCmdBindDescriptorSets);
API_CHECK(vkCmdBindIndexBuffer);
API_CHECK(vkCmdBindVertexBuffers);
API_CHECK(vkCmdDraw);
API_CHECK(vkCmdDrawIndexed);
API_CHECK(vkCmdDrawIndirect);
API_CHECK(vkCmdDrawIndexedIndirect);
API_CHECK(vkCmdDispatch);
API_CHECK(vkCmdDispatchIndirect);
API_CHECK(vkCmdCopyBuffer);
API_CHECK(vkCmdCopyImage);
API_CHECK(vkCmdBlitImage);
API_CHECK(vkCmdCopyBufferToImage);
API_CHECK(vkCmdCopyImageToBuffer);
API_CHECK(vkCmdUpdateBuffer);
API_CHECK(vkCmdFillBuffer);
API_CHECK(vkCmdClearColorImage);
API_CHECK(vkCmdClearDepthStencilImage);
API_CHECK(vkCmdClearAttachments);
API_CHECK(vkCmdResolveImage);
API_CHECK(vkCmdSetEvent);
API_CHECK(vkCmdResetEvent);
API_CHECK(vkCmdWaitEvents);
API_CHECK(vkCmdPipelineBarrier);
API_CHECK(vkCmdBeginQuery);
API_CHECK(vkCmdEndQuery);
API_CHECK(vkCmdResetQueryPool);
API_CHECK(vkCmdWriteTimestamp);
API_CHECK(vkCmdCopyQueryPoolResults);
API_CHECK(vkCmdPushConstants);
API_CHECK(vkCmdBeginRenderPass);
API_CHECK(vkCmdNextSubpass);
API_CHECK(vkCmdEndRenderPass);
API_CHECK(vkCmdExecuteCommands);
API_CHECK(vkEnumerateInstanceVersion);
API_CHECK(vkBindBufferMemory2);
API_CHECK(vkBindImageMemory2);
API_CHECK(vkGetDeviceGroupPeerMemoryFeatures);
API_CHECK(vkCmdSetDeviceMask);
API_CHECK(vkCmdDispatchBase);
API_CHECK(vkEnumeratePhysicalDeviceGroups);
API_CHECK(vkGetImageMemoryRequirements2);
API_CHECK(vkGetBufferMemoryRequirements2);
API_CHECK(vkGetImageSparseMemoryRequirements2);
API_CHECK(vkGetPhysicalDeviceFeatures2);
API_CHECK(vkGetPhysicalDeviceProperties2);
API_CHECK(vkGetPhysicalDeviceFormatProperties2);
API_CHECK(vkGetPhysicalDeviceImageFormatProperties2);
API_CHECK(vkGetPhysicalDeviceQueueFamilyProperties2);
API_CHECK(vkGetPhysicalDeviceMemoryProperties2);
API_CHECK(vkGetPhysicalDeviceSparseImageFormatProperties2);
API_CHECK(vkTrimCommandPool);
API_CHECK(vkGetDeviceQueue2);
API_CHECK(vkCreateSamplerYcbcrConversion);
API_CHECK(vkDestroySamplerYcbcrConversion);
API_CHECK(vkCreateDescriptorUpdateTemplate);
API_CHECK(vkDestroyDescriptorUpdateTemplate);
API_CHECK(vkUpdateDescriptorSetWithTemplate);
API_CHECK(vkGetPhysicalDeviceExternalBufferProperties);
API_CHECK(vkGetPhysicalDeviceExternalFenceProperties);
API_CHECK(vkGetPhysicalDeviceExternalSemaphoreProperties);
API_CHECK(vkGetDescriptorSetLayoutSupport);
// VK_KHR_bind_memory2
API_CHECK(vkBindBufferMemory2KHR);
API_CHECK(vkBindImageMemory2KHR);
// VK_KHR_descriptor_update_template
API_CHECK(vkCreateDescriptorUpdateTemplateKHR);
API_CHECK(vkDestroyDescriptorUpdateTemplateKHR);
API_CHECK(vkUpdateDescriptorSetWithTemplateKHR);
// VK_KHR_device_group
API_CHECK(vkGetDeviceGroupPeerMemoryFeaturesKHR);
API_CHECK(vkCmdSetDeviceMaskKHR);
API_CHECK(vkCmdDispatchBaseKHR);
// VK_KHR_device_group_creation
API_CHECK(vkEnumeratePhysicalDeviceGroupsKHR);
// VK_KHR_external_fence_capabilities
API_CHECK(vkGetPhysicalDeviceExternalFencePropertiesKHR);
// VK_KHR_external_memory_capabilities
API_CHECK(vkGetPhysicalDeviceExternalBufferPropertiesKHR);
// VK_KHR_external_semaphore_capabilities
API_CHECK(vkGetPhysicalDeviceExternalSemaphorePropertiesKHR);
// VK_KHR_get_memory_requirements2
API_CHECK(vkGetImageMemoryRequirements2KHR);
API_CHECK(vkGetBufferMemoryRequirements2KHR);
API_CHECK(vkGetImageSparseMemoryRequirements2KHR);
// VK_KHR_get_physical_device_properties2
API_CHECK(vkGetPhysicalDeviceFeatures2KHR);
API_CHECK(vkGetPhysicalDeviceProperties2KHR);
API_CHECK(vkGetPhysicalDeviceFormatProperties2KHR);
API_CHECK(vkGetPhysicalDeviceImageFormatProperties2KHR);
API_CHECK(vkGetPhysicalDeviceQueueFamilyProperties2KHR);
API_CHECK(vkGetPhysicalDeviceMemoryProperties2KHR);
API_CHECK(vkGetPhysicalDeviceSparseImageFormatProperties2KHR);
// VK_KHR_maintenance1
API_CHECK(vkTrimCommandPoolKHR);
// VK_KHR_maintenance3
API_CHECK(vkGetDescriptorSetLayoutSupportKHR);
// VK_KHR_sampler_ycbcr_conversion
API_CHECK(vkCreateSamplerYcbcrConversionKHR);
API_CHECK(vkDestroySamplerYcbcrConversionKHR);
#undef API_CHECK
auto bad_function = vk_icdGetInstanceProcAddr(VK_NULL_HANDLE, "bad_function");
EXPECT_EQ(bad_function, nullptr);
}
}
TEST_F(SwiftShaderVulkanTest, Version)
{
if(vk_icdGetInstanceProcAddr)
{
auto vkCreateInstance = (PFN_vkCreateInstance)vk_icdGetInstanceProcAddr(VK_NULL_HANDLE, "vkCreateInstance");
EXPECT_NE(vkCreateInstance, nullptr);
const VkInstanceCreateInfo createInfo =
{
VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO, // sType
nullptr, // pNext
0, // flags
nullptr, // pApplicationInfo
0, // enabledLayerCount
nullptr, // ppEnabledLayerNames
0, // enabledExtensionCount
nullptr, // ppEnabledExtensionNames
};
VkInstance instance;
VkResult result = vkCreateInstance(&createInfo, nullptr, &instance);
EXPECT_EQ(result, VK_SUCCESS);
auto vkEnumeratePhysicalDevices = (PFN_vkEnumeratePhysicalDevices)vk_icdGetInstanceProcAddr(VK_NULL_HANDLE, "vkEnumeratePhysicalDevices");
EXPECT_NE(vkEnumeratePhysicalDevices, nullptr);
uint32_t pPhysicalDeviceCount = 0;
result = vkEnumeratePhysicalDevices(instance, &pPhysicalDeviceCount, nullptr);
EXPECT_EQ(result, VK_SUCCESS);
EXPECT_EQ(pPhysicalDeviceCount, 1);
VkPhysicalDevice pPhysicalDevice = VK_NULL_HANDLE;
result = vkEnumeratePhysicalDevices(instance, &pPhysicalDeviceCount, &pPhysicalDevice);
EXPECT_EQ(result, VK_SUCCESS);
EXPECT_NE(pPhysicalDevice, (VkPhysicalDevice)VK_NULL_HANDLE);
auto vkGetPhysicalDeviceProperties = (PFN_vkGetPhysicalDeviceProperties)vk_icdGetInstanceProcAddr(VK_NULL_HANDLE, "vkGetPhysicalDeviceProperties");
EXPECT_NE(vkEnumeratePhysicalDevices, nullptr);
VkPhysicalDeviceProperties physicalDeviceProperties;
vkGetPhysicalDeviceProperties(pPhysicalDevice, &physicalDeviceProperties);
EXPECT_EQ(physicalDeviceProperties.apiVersion, VK_API_VERSION_1_1);
EXPECT_EQ(physicalDeviceProperties.deviceID, 0xC0DE);
EXPECT_EQ(physicalDeviceProperties.deviceType, VK_PHYSICAL_DEVICE_TYPE_CPU);
EXPECT_EQ(strncmp(physicalDeviceProperties.deviceName, "SwiftShader Device", VK_MAX_PHYSICAL_DEVICE_NAME_SIZE), 0);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment