Commit 513a1165 by Nicolas Capens Committed by Nicolas Capens

Export Vulkan API entry functions.

This enables running the unit tests without manually querying each entry function. The compiler generates a .lib file for us which load the .dll file and retrieves the entry functions. Also fix project dependencies and DLL path. Bug b/116336664 Change-Id: I4cbd80bd071a20058b034db8fb12e31f9af2e081 Reviewed-on: https://swiftshader-review.googlesource.com/c/22489Tested-by: 's avatarNicolas Capens <nicolascapens@google.com> Reviewed-by: 's avatarCorentin Wallez <cwallez@google.com> Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com>
parent f27cb237
LIBRARY vk_swiftshader.dll LIBRARY vk_swiftshader
EXPORTS EXPORTS
vk_icdGetInstanceProcAddr ; Mandatory ICD entry function
vk_icdGetInstanceProcAddr
; Optional Vulkan API entry functions
vkCreateInstance
vkDestroyInstance
vkEnumeratePhysicalDevices
vkGetPhysicalDeviceFeatures
vkGetPhysicalDeviceFormatProperties
vkGetPhysicalDeviceImageFormatProperties
vkGetPhysicalDeviceProperties
vkGetPhysicalDeviceQueueFamilyProperties
vkGetPhysicalDeviceMemoryProperties
vkGetInstanceProcAddr
vkGetDeviceProcAddr
vkCreateDevice
vkDestroyDevice
vkEnumerateInstanceExtensionProperties
vkEnumerateDeviceExtensionProperties
vkEnumerateInstanceLayerProperties
vkEnumerateDeviceLayerProperties
vkGetDeviceQueue
vkQueueSubmit
vkQueueWaitIdle
vkDeviceWaitIdle
vkAllocateMemory
vkFreeMemory
vkMapMemory
vkUnmapMemory
vkFlushMappedMemoryRanges
vkInvalidateMappedMemoryRanges
vkGetDeviceMemoryCommitment
vkBindBufferMemory
vkBindImageMemory
vkGetBufferMemoryRequirements
vkGetImageMemoryRequirements
vkGetImageSparseMemoryRequirements
vkGetPhysicalDeviceSparseImageFormatProperties
vkQueueBindSparse
vkCreateFence
vkDestroyFence
vkResetFences
vkGetFenceStatus
vkWaitForFences
vkCreateSemaphore
vkDestroySemaphore
vkCreateEvent
vkDestroyEvent
vkGetEventStatus
vkSetEvent
vkResetEvent
vkCreateQueryPool
vkDestroyQueryPool
vkGetQueryPoolResults
vkCreateBuffer
vkDestroyBuffer
vkCreateBufferView
vkDestroyBufferView
vkCreateImage
vkDestroyImage
vkGetImageSubresourceLayout
vkCreateImageView
vkDestroyImageView
vkCreateShaderModule
vkDestroyShaderModule
vkCreatePipelineCache
vkDestroyPipelineCache
vkGetPipelineCacheData
vkMergePipelineCaches
vkCreateGraphicsPipelines
vkCreateComputePipelines
vkDestroyPipeline
vkCreatePipelineLayout
vkDestroyPipelineLayout
vkCreateSampler
vkDestroySampler
vkCreateDescriptorSetLayout
vkDestroyDescriptorSetLayout
vkCreateDescriptorPool
vkDestroyDescriptorPool
vkResetDescriptorPool
vkAllocateDescriptorSets
vkFreeDescriptorSets
vkUpdateDescriptorSets
vkCreateFramebuffer
vkDestroyFramebuffer
vkCreateRenderPass
vkDestroyRenderPass
vkGetRenderAreaGranularity
vkCreateCommandPool
vkDestroyCommandPool
vkResetCommandPool
vkAllocateCommandBuffers
vkFreeCommandBuffers
vkBeginCommandBuffer
vkEndCommandBuffer
vkResetCommandBuffer
vkCmdBindPipeline
vkCmdSetViewport
vkCmdSetScissor
vkCmdSetLineWidth
vkCmdSetDepthBias
vkCmdSetBlendConstants
vkCmdSetDepthBounds
vkCmdSetStencilCompareMask
vkCmdSetStencilWriteMask
vkCmdSetStencilReference
vkCmdBindDescriptorSets
vkCmdBindIndexBuffer
vkCmdBindVertexBuffers
vkCmdDraw
vkCmdDrawIndexed
vkCmdDrawIndirect
vkCmdDrawIndexedIndirect
vkCmdDispatch
vkCmdDispatchIndirect
vkCmdCopyBuffer
vkCmdCopyImage
vkCmdBlitImage
vkCmdCopyBufferToImage
vkCmdCopyImageToBuffer
vkCmdUpdateBuffer
vkCmdFillBuffer
vkCmdClearColorImage
vkCmdClearDepthStencilImage
vkCmdClearAttachments
vkCmdResolveImage
vkCmdSetEvent
vkCmdResetEvent
vkCmdWaitEvents
vkCmdPipelineBarrier
vkCmdBeginQuery
vkCmdEndQuery
vkCmdResetQueryPool
vkCmdWriteTimestamp
vkCmdCopyQueryPoolResults
vkCmdPushConstants
vkCmdBeginRenderPass
vkCmdNextSubpass
vkCmdEndRenderPass
vkCmdExecuteCommands
vkEnumerateInstanceVersion
vkBindBufferMemory2
vkBindImageMemory2
vkGetDeviceGroupPeerMemoryFeatures
vkCmdSetDeviceMask
vkCmdDispatchBase
vkEnumeratePhysicalDeviceGroups
vkGetImageMemoryRequirements2
vkGetBufferMemoryRequirements2
vkGetImageSparseMemoryRequirements2
vkGetPhysicalDeviceFeatures2
vkGetPhysicalDeviceProperties2
vkGetPhysicalDeviceFormatProperties2
vkGetPhysicalDeviceImageFormatProperties2
vkGetPhysicalDeviceQueueFamilyProperties2
vkGetPhysicalDeviceMemoryProperties2
vkGetPhysicalDeviceSparseImageFormatProperties2
vkTrimCommandPool
vkGetDeviceQueue2
vkCreateSamplerYcbcrConversion
vkDestroySamplerYcbcrConversion
vkCreateDescriptorUpdateTemplate
vkDestroyDescriptorUpdateTemplate
vkUpdateDescriptorSetWithTemplate
vkGetPhysicalDeviceExternalBufferProperties
vkGetPhysicalDeviceExternalFenceProperties
vkGetPhysicalDeviceExternalSemaphoreProperties
vkGetDescriptorSetLayoutSupport
; VK_KHR_bind_memory2
vkBindBufferMemory2KHR
vkBindImageMemory2KHR
; VK_KHR_descriptor_update_template
vkCreateDescriptorUpdateTemplateKHR
vkDestroyDescriptorUpdateTemplateKHR
vkUpdateDescriptorSetWithTemplateKHR
; VK_KHR_device_group
vkGetDeviceGroupPeerMemoryFeaturesKHR
vkCmdSetDeviceMaskKHR
vkCmdDispatchBaseKHR
; VK_KHR_device_group_creation
vkEnumeratePhysicalDeviceGroupsKHR
; VK_KHR_external_fence_capabilities
vkGetPhysicalDeviceExternalFencePropertiesKHR
; VK_KHR_external_memory_capabilities
vkGetPhysicalDeviceExternalBufferPropertiesKHR
; VK_KHR_external_semaphore_capabilities
vkGetPhysicalDeviceExternalSemaphorePropertiesKHR
; VK_KHR_get_memory_requirements2
vkGetImageMemoryRequirements2KHR
vkGetBufferMemoryRequirements2KHR
vkGetImageSparseMemoryRequirements2KHR
; VK_KHR_get_physical_device_properties2
vkGetPhysicalDeviceFeatures2KHR
vkGetPhysicalDeviceProperties2KHR
vkGetPhysicalDeviceFormatProperties2KHR
vkGetPhysicalDeviceImageFormatProperties2KHR
vkGetPhysicalDeviceQueueFamilyProperties2KHR
vkGetPhysicalDeviceMemoryProperties2KHR
vkGetPhysicalDeviceSparseImageFormatProperties2KHR
; VK_KHR_maintenance1
vkTrimCommandPoolKHR
; VK_KHR_maintenance3
vkGetDescriptorSetLayoutSupportKHR
; VK_KHR_sampler_ycbcr_conversion
vkCreateSamplerYcbcrConversionKHR
vkDestroySamplerYcbcrConversionKHR
...@@ -353,22 +353,22 @@ TEST_F(SwiftShaderTest, ClearIncomplete) ...@@ -353,22 +353,22 @@ TEST_F(SwiftShaderTest, ClearIncomplete)
{ {
Initialize(3, false); Initialize(3, false);
GLfloat zero_float = 0; GLfloat zero_float = 0;
GLuint renderbuffer; GLuint renderbuffer;
glGenRenderbuffers(1, &renderbuffer); glGenRenderbuffers(1, &renderbuffer);
GLuint framebuffer; GLuint framebuffer;
glGenFramebuffers(1, &framebuffer); glGenFramebuffers(1, &framebuffer);
glBindRenderbuffer(GL_RENDERBUFFER, renderbuffer); glBindRenderbuffer(GL_RENDERBUFFER, renderbuffer);
EXPECT_GLENUM_EQ(GL_NO_ERROR, glGetError()); EXPECT_GLENUM_EQ(GL_NO_ERROR, glGetError());
glRenderbufferStorage(GL_RENDERBUFFER, GL_R8I, 43, 27); glRenderbufferStorage(GL_RENDERBUFFER, GL_R8I, 43, 27);
EXPECT_GLENUM_EQ(GL_NO_ERROR, glGetError()); EXPECT_GLENUM_EQ(GL_NO_ERROR, glGetError());
glBindFramebuffer(GL_READ_FRAMEBUFFER, framebuffer); glBindFramebuffer(GL_READ_FRAMEBUFFER, framebuffer);
EXPECT_GLENUM_EQ(GL_NO_ERROR, glGetError()); EXPECT_GLENUM_EQ(GL_NO_ERROR, glGetError());
glFramebufferRenderbuffer(GL_READ_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, renderbuffer); glFramebufferRenderbuffer(GL_READ_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, renderbuffer);
EXPECT_GLENUM_EQ(GL_NO_ERROR, glGetError()); EXPECT_GLENUM_EQ(GL_NO_ERROR, glGetError());
glBindFramebuffer(GL_FRAMEBUFFER, framebuffer); glBindFramebuffer(GL_FRAMEBUFFER, framebuffer);
EXPECT_GLENUM_EQ(GL_NO_ERROR, glGetError()); EXPECT_GLENUM_EQ(GL_NO_ERROR, glGetError());
glClearBufferfv(GL_DEPTH, 0, &zero_float); glClearBufferfv(GL_DEPTH, 0, &zero_float);
EXPECT_GLENUM_EQ(GL_INVALID_FRAMEBUFFER_OPERATION, glGetError()); EXPECT_GLENUM_EQ(GL_INVALID_FRAMEBUFFER_OPERATION, glGetError());
......
...@@ -102,11 +102,8 @@ ...@@ -102,11 +102,8 @@
<ClCompile Include="unittests.cpp" /> <ClCompile Include="unittests.cpp" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\src\OpenGL\libEGL\libEGL.vcxproj"> <ProjectReference Include="..\..\src\Vulkan\vulkan.vcxproj">
<Project>{e746fca9-64c3-433e-85e8-9a5a67ab7ed6}</Project> <Project>{e1c34b66-c942-4b9a-b8c3-9a12625650d3}</Project>
</ProjectReference>
<ProjectReference Include="..\..\src\OpenGL\libGLESv2\libGLESv2.vcxproj">
<Project>{b5871a7a-968c-42e3-a33b-981e6f448e78}</Project>
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
......
// Copyright 2017 The SwiftShader Authors. All Rights Reserved. // Copyright 2018 The SwiftShader Authors. All Rights Reserved.
// //
// Licensed under the Apache License, Version 2.0 (the "License"); // Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
// OpenGL ES unit tests that provide coverage for functionality not tested by // Vulkan unit tests that provide coverage for functionality not tested by
// the dEQP test suite. Also used as a smoke test. // the dEQP test suite. Also used as a smoke test.
#include "gtest/gtest.h" #include "gtest/gtest.h"
...@@ -39,16 +39,12 @@ protected: ...@@ -39,16 +39,12 @@ protected:
#if defined(_WIN64) #if defined(_WIN64)
#if defined(NDEBUG) #if defined(NDEBUG)
libVulkanName = "..\\..\\..\\vulkan\\x64\\Release\\vk_swiftshader.dll"; libVulkanName = "../../out/Release_x64/vk_swiftshader.dll";
#else #else
libVulkanName = "..\\..\\..\\vulkan\\x64\\Debug\\vk_swiftshader.dll"; libVulkanName = "../../out/Debug_x64/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
#else
#error Unimplemented platform
#endif #endif
#if defined(_WIN32) #if defined(_WIN32)
...@@ -282,48 +278,36 @@ TEST_F(SwiftShaderVulkanTest, API_Check) ...@@ -282,48 +278,36 @@ TEST_F(SwiftShaderVulkanTest, API_Check)
TEST_F(SwiftShaderVulkanTest, Version) TEST_F(SwiftShaderVulkanTest, Version)
{ {
if(vk_icdGetInstanceProcAddr) const VkInstanceCreateInfo createInfo =
{ {
auto vkCreateInstance = (PFN_vkCreateInstance)vk_icdGetInstanceProcAddr(VK_NULL_HANDLE, "vkCreateInstance"); VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO, // sType
EXPECT_NE(vkCreateInstance, nullptr); 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);
const VkInstanceCreateInfo createInfo = uint32_t pPhysicalDeviceCount = 0;
{ result = vkEnumeratePhysicalDevices(instance, &pPhysicalDeviceCount, nullptr);
VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO, // sType EXPECT_EQ(result, VK_SUCCESS);
nullptr, // pNext EXPECT_EQ(pPhysicalDeviceCount, 1);
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"); VkPhysicalDevice pPhysicalDevice = VK_NULL_HANDLE;
EXPECT_NE(vkEnumeratePhysicalDevices, nullptr); result = vkEnumeratePhysicalDevices(instance, &pPhysicalDeviceCount, &pPhysicalDevice);
EXPECT_EQ(result, VK_SUCCESS);
EXPECT_NE(pPhysicalDevice, (VkPhysicalDevice)VK_NULL_HANDLE);
uint32_t pPhysicalDeviceCount = 0; VkPhysicalDeviceProperties physicalDeviceProperties;
result = vkEnumeratePhysicalDevices(instance, &pPhysicalDeviceCount, nullptr); vkGetPhysicalDeviceProperties(pPhysicalDevice, &physicalDeviceProperties);
EXPECT_EQ(result, VK_SUCCESS); EXPECT_EQ(physicalDeviceProperties.apiVersion, VK_API_VERSION_1_1);
EXPECT_EQ(pPhysicalDeviceCount, 1); EXPECT_EQ(physicalDeviceProperties.deviceID, 0xC0DE);
EXPECT_EQ(physicalDeviceProperties.deviceType, VK_PHYSICAL_DEVICE_TYPE_CPU);
VkPhysicalDevice pPhysicalDevice = VK_NULL_HANDLE; EXPECT_EQ(strncmp(physicalDeviceProperties.deviceName, "SwiftShader Device", VK_MAX_PHYSICAL_DEVICE_NAME_SIZE), 0);
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