From ff5cbaa7be4411abf6fc6d77f8520bcb40a72bf6 Mon Sep 17 00:00:00 2001 From: assiduous Date: Tue, 28 Jan 2020 09:22:17 -0800 Subject: Added Vulkan C API tests --- Tests/IncludeTest/CMakeLists.txt | 3 ++ .../EngineFactoryOpenGLH_test.cpp | 7 ----- .../GraphicsEngineVk/BufferViewVkH_test.c | 6 ++++ .../IncludeTest/GraphicsEngineVk/BufferVkH_test.c | 9 ++++++ .../GraphicsEngineVk/CommandQueueVkH_test.c | 24 ++++++++++++++++ .../GraphicsEngineVk/DeviceContextVkH_test.c | 11 ++++++++ .../GraphicsEngineVk/EngineFactoryVkH_test.c | 32 ++++++++++++++++------ .../GraphicsEngineVk/EngineFactoryVkH_test.cpp | 7 ----- .../GraphicsEngineVk/PipelineStateVkH_test.c | 8 ++++++ .../GraphicsEngineVk/RenderDeviceVkH_test.c | 23 ++++++++++++++++ .../IncludeTest/GraphicsEngineVk/SamplerVkH_test.c | 6 ++++ .../GraphicsEngineVk/SwapChainVkH_test.c | 8 +++++- .../GraphicsEngineVk/TextureViewVkH_test.c | 6 ++++ .../IncludeTest/GraphicsEngineVk/TextureVkH_test.c | 11 ++++++++ 14 files changed, 137 insertions(+), 24 deletions(-) (limited to 'Tests/IncludeTest') diff --git a/Tests/IncludeTest/CMakeLists.txt b/Tests/IncludeTest/CMakeLists.txt index ee330698..ca8f1376 100644 --- a/Tests/IncludeTest/CMakeLists.txt +++ b/Tests/IncludeTest/CMakeLists.txt @@ -39,6 +39,9 @@ if(MSVC) set_target_properties(DiligentCore-IncludeTest PROPERTIES STATIC_LIBRARY_FLAGS "/IGNORE:4221" ) + + # Treat warnings as errors to catch c compilation issues + target_compile_options(DiligentCore-IncludeTest PRIVATE "/WX") endif() source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${SOURCE}) diff --git a/Tests/IncludeTest/GraphicsEngineOpenGL/EngineFactoryOpenGLH_test.cpp b/Tests/IncludeTest/GraphicsEngineOpenGL/EngineFactoryOpenGLH_test.cpp index c94e103f..4528a838 100644 --- a/Tests/IncludeTest/GraphicsEngineOpenGL/EngineFactoryOpenGLH_test.cpp +++ b/Tests/IncludeTest/GraphicsEngineOpenGL/EngineFactoryOpenGLH_test.cpp @@ -25,13 +25,6 @@ * of the possibility of such damages. */ -#if PLATFORM_WIN32 || PLATFORM_UNIVERSAL_WINDOWS -# ifndef NOMINMAX -# define NOMINMAX -# endif -# include -#endif - #ifndef ENGINE_DLL # define ENGINE_DLL 1 #endif diff --git a/Tests/IncludeTest/GraphicsEngineVk/BufferViewVkH_test.c b/Tests/IncludeTest/GraphicsEngineVk/BufferViewVkH_test.c index 1057b9ca..89abee67 100644 --- a/Tests/IncludeTest/GraphicsEngineVk/BufferViewVkH_test.c +++ b/Tests/IncludeTest/GraphicsEngineVk/BufferViewVkH_test.c @@ -27,3 +27,9 @@ #include "DiligentCore/ThirdParty/vulkan/vulkan.h" #include "DiligentCore/Graphics/GraphicsEngineVulkan/interface/BufferViewVk.h" + +void TestBufferViewVk_CInterface(IBufferViewVk* pView) +{ + VkBufferView vkView = IBufferViewVk_GetVkBufferView(pView); + (void)vkView; +} diff --git a/Tests/IncludeTest/GraphicsEngineVk/BufferVkH_test.c b/Tests/IncludeTest/GraphicsEngineVk/BufferVkH_test.c index f93a3f6d..c63a98dc 100644 --- a/Tests/IncludeTest/GraphicsEngineVk/BufferVkH_test.c +++ b/Tests/IncludeTest/GraphicsEngineVk/BufferVkH_test.c @@ -27,3 +27,12 @@ #include "DiligentCore/ThirdParty/vulkan/vulkan.h" #include "DiligentCore/Graphics/GraphicsEngineVulkan/interface/BufferVk.h" + +void TestBufferVk_CInterface(IBufferVk* pView) +{ + VkBuffer vkView = IBufferVk_GetVkBuffer(pView); + (void)vkView; + IBufferVk_SetAccessFlags(pView, VK_ACCESS_HOST_READ_BIT); + VkAccessFlags vkAccessFlag = IBufferVk_GetAccessFlags(pView); + (void)vkAccessFlag; +} diff --git a/Tests/IncludeTest/GraphicsEngineVk/CommandQueueVkH_test.c b/Tests/IncludeTest/GraphicsEngineVk/CommandQueueVkH_test.c index c3952ad6..f19ce217 100644 --- a/Tests/IncludeTest/GraphicsEngineVk/CommandQueueVkH_test.c +++ b/Tests/IncludeTest/GraphicsEngineVk/CommandQueueVkH_test.c @@ -27,3 +27,27 @@ #include "DiligentCore/ThirdParty/vulkan/vulkan.h" #include "DiligentCore/Graphics/GraphicsEngineVulkan/interface/CommandQueueVk.h" + +void TestCommandQueueVk_CInterface(ICommandQueueVk* pQueue) +{ + Uint64 FenceVal = ICommandQueueVk_GetNextFenceValue(pQueue); + (void)FenceVal; + + FenceVal = ICommandQueueVk_SubmitCmdBuffer(pQueue, (VkCommandBuffer)NULL); + + FenceVal = ICommandQueueVk_Submit(pQueue, (VkSubmitInfo*)NULL); + + ICommandQueueVk_Present(pQueue, (VkPresentInfoKHR*)NULL); + + VkQueue vkQueue = ICommandQueueVk_GetVkQueue(pQueue); + (void)vkQueue; + + uint32_t fam = ICommandQueueVk_GetQueueFamilyIndex(pQueue); + (void)fam; + + FenceVal = ICommandQueueVk_GetCompletedFenceValue(pQueue); + + ICommandQueueVk_WaitForIdle(pQueue); + + ICommandQueueVk_SignalFence(pQueue, (VkFence)NULL); +} diff --git a/Tests/IncludeTest/GraphicsEngineVk/DeviceContextVkH_test.c b/Tests/IncludeTest/GraphicsEngineVk/DeviceContextVkH_test.c index 61c0e3c3..ddde6f7e 100644 --- a/Tests/IncludeTest/GraphicsEngineVk/DeviceContextVkH_test.c +++ b/Tests/IncludeTest/GraphicsEngineVk/DeviceContextVkH_test.c @@ -27,3 +27,14 @@ #include "DiligentCore/ThirdParty/vulkan/vulkan.h" #include "DiligentCore/Graphics/GraphicsEngineVulkan/interface/DeviceContextVk.h" + +void TestDeviceContextVk_CInterface(IDeviceContextVk* pCtx) +{ + IDeviceContextVk_TransitionImageLayout(pCtx, (ITexture*)NULL, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL); + IDeviceContextVk_BufferMemoryBarrier(pCtx, (IBuffer*)NULL, VK_ACCESS_HOST_READ_BIT); + + ICommandQueueVk* pVkCmdQueue = IDeviceContextVk_LockCommandQueue(pCtx); + (void)pVkCmdQueue; + + IDeviceContextVk_UnlockCommandQueue(pCtx); +} diff --git a/Tests/IncludeTest/GraphicsEngineVk/EngineFactoryVkH_test.c b/Tests/IncludeTest/GraphicsEngineVk/EngineFactoryVkH_test.c index f83256b9..fa7c9c0b 100644 --- a/Tests/IncludeTest/GraphicsEngineVk/EngineFactoryVkH_test.c +++ b/Tests/IncludeTest/GraphicsEngineVk/EngineFactoryVkH_test.c @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. * - * In no event and under no legal theory, whether in tort (including negligence), + * In no event and under no legal theory, whether in tort (including neVkigence), * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent acts) or agreed to in writing, shall any Contributor be + * and grossly neVkigent acts) or agreed to in writing, shall any Contributor be * liable for any damages, including any direct, indirect, special, incidental, * or consequential damages of any character arising as a result of this License or * out of the use or inability to use the software (including but not limited to damages @@ -25,15 +25,29 @@ * of the possibility of such damages. */ -#if PLATFORM_WIN32 -# ifndef NOMINMAX -# define NOMINMAX -# endif -# include -#endif - #ifndef ENGINE_DLL # define ENGINE_DLL 1 #endif #include "DiligentCore/Graphics/GraphicsEngineVulkan/interface/EngineFactoryVk.h" + + +void TestEngineFactoryVk_CInterface() +{ +#if EXPLICITLY_LOAD_ENGINE_VK_DLL + GetEngineFactoryVkType GetEngineFactoryVk = LoadGraphicsEngineVk(); + IEngineFactoryVk* pFactory = GetEngineFactoryVk(); +#else + IEngineFactoryVk* pFactory = Diligent_GetEngineFactoryVk(); +#endif + + struct EngineVkCreateInfo EngineCI = {0}; + IRenderDevice* pDevice = NULL; + IDeviceContext* pCtx = NULL; + IEngineFactoryVk_CreateDeviceAndContextsVk(pFactory, &EngineCI, &pDevice, &pCtx); + + struct SwapChainDesc SCDesc = {0}; + void* pNativeWndHandle = NULL; + ISwapChain* pSwapChain = NULL; + IEngineFactoryVk_CreateSwapChainVk(pFactory, pDevice, pCtx, &SCDesc, pNativeWndHandle, &pSwapChain); +} diff --git a/Tests/IncludeTest/GraphicsEngineVk/EngineFactoryVkH_test.cpp b/Tests/IncludeTest/GraphicsEngineVk/EngineFactoryVkH_test.cpp index f83256b9..120b1181 100644 --- a/Tests/IncludeTest/GraphicsEngineVk/EngineFactoryVkH_test.cpp +++ b/Tests/IncludeTest/GraphicsEngineVk/EngineFactoryVkH_test.cpp @@ -25,13 +25,6 @@ * of the possibility of such damages. */ -#if PLATFORM_WIN32 -# ifndef NOMINMAX -# define NOMINMAX -# endif -# include -#endif - #ifndef ENGINE_DLL # define ENGINE_DLL 1 #endif diff --git a/Tests/IncludeTest/GraphicsEngineVk/PipelineStateVkH_test.c b/Tests/IncludeTest/GraphicsEngineVk/PipelineStateVkH_test.c index f54ee46a..5ba5bd48 100644 --- a/Tests/IncludeTest/GraphicsEngineVk/PipelineStateVkH_test.c +++ b/Tests/IncludeTest/GraphicsEngineVk/PipelineStateVkH_test.c @@ -27,3 +27,11 @@ #include "DiligentCore/ThirdParty/vulkan/vulkan.h" #include "DiligentCore/Graphics/GraphicsEngineVulkan/interface/PipelineStateVk.h" + +void TestPipelineStateVk_CInterface(IPipelineStateVk* pPSO) +{ + VkRenderPass vkPass = IPipelineStateVk_GetVkRenderPass(pPSO); + VkPipeline vkPipeline = IPipelineStateVk_GetVkPipeline(pPSO); + (void)vkPass; + (void)vkPipeline; +} diff --git a/Tests/IncludeTest/GraphicsEngineVk/RenderDeviceVkH_test.c b/Tests/IncludeTest/GraphicsEngineVk/RenderDeviceVkH_test.c index f421b717..d41c9a04 100644 --- a/Tests/IncludeTest/GraphicsEngineVk/RenderDeviceVkH_test.c +++ b/Tests/IncludeTest/GraphicsEngineVk/RenderDeviceVkH_test.c @@ -27,3 +27,26 @@ #include "DiligentCore/ThirdParty/vulkan/vulkan.h" #include "DiligentCore/Graphics/GraphicsEngineVulkan/interface/RenderDeviceVk.h" + +void TestRenderDeviceVkCInterface(IRenderDeviceVk* pDevice) +{ + VkDevice vkDevice = IRenderDeviceVk_GetVkDevice(pDevice); + (void)vkDevice; + + VkPhysicalDevice vkPhysDevice = IRenderDeviceVk_GetVkPhysicalDevice(pDevice); + (void)vkPhysDevice; + + VkInstance vkInst = IRenderDeviceVk_GetVkInstance(pDevice); + (void)vkInst; + + Uint64 Fence = IRenderDeviceVk_GetNextFenceValue(pDevice, (Uint32)0); + (void)Fence; + + Fence = IRenderDeviceVk_GetCompletedFenceValue(pDevice, (Uint32)0); + + bool IsSignaled = IRenderDeviceVk_IsFenceSignaled(pDevice, (Uint32)0, (Uint64)0); + (void)IsSignaled; + + IRenderDeviceVk_CreateTextureFromVulkanImage(pDevice, (VkImage)NULL, (TextureDesc*)NULL, RESOURCE_STATE_SHADER_RESOURCE, (ITexture**)NULL); + IRenderDeviceVk_CreateBufferFromVulkanResource(pDevice, (VkBuffer)NULL, (BufferDesc*)NULL, RESOURCE_STATE_CONSTANT_BUFFER, (IBuffer**)NULL); +} diff --git a/Tests/IncludeTest/GraphicsEngineVk/SamplerVkH_test.c b/Tests/IncludeTest/GraphicsEngineVk/SamplerVkH_test.c index 890fcb7e..25ad83d8 100644 --- a/Tests/IncludeTest/GraphicsEngineVk/SamplerVkH_test.c +++ b/Tests/IncludeTest/GraphicsEngineVk/SamplerVkH_test.c @@ -27,3 +27,9 @@ #include "DiligentCore/ThirdParty/vulkan/vulkan.h" #include "DiligentCore/Graphics/GraphicsEngineVulkan/interface/SamplerVk.h" + +void TestSamplerVk_CInterface(ISamplerVk* pSampler) +{ + VkSampler Handle = ISamplerVk_GetVkSampler(pSampler); + (void)Handle; +} diff --git a/Tests/IncludeTest/GraphicsEngineVk/SwapChainVkH_test.c b/Tests/IncludeTest/GraphicsEngineVk/SwapChainVkH_test.c index 3f066e05..06397e69 100644 --- a/Tests/IncludeTest/GraphicsEngineVk/SwapChainVkH_test.c +++ b/Tests/IncludeTest/GraphicsEngineVk/SwapChainVkH_test.c @@ -25,4 +25,10 @@ * of the possibility of such damages. */ #include "DiligentCore/ThirdParty/vulkan/vulkan.h" -#include "DiligentCore/Graphics/GraphicsEngineVulkan/interface/SwapChainVk.h" \ No newline at end of file +#include "DiligentCore/Graphics/GraphicsEngineVulkan/interface/SwapChainVk.h" + +void TestSwapChainVk_CInterface(ISwapChainVk* pSwapChain) +{ + VkSwapchainKHR sc = ISwapChainVk_GetVkSwapChain(pSwapChain); + (void)sc; +} diff --git a/Tests/IncludeTest/GraphicsEngineVk/TextureViewVkH_test.c b/Tests/IncludeTest/GraphicsEngineVk/TextureViewVkH_test.c index 92ea677b..183f6b7e 100644 --- a/Tests/IncludeTest/GraphicsEngineVk/TextureViewVkH_test.c +++ b/Tests/IncludeTest/GraphicsEngineVk/TextureViewVkH_test.c @@ -27,3 +27,9 @@ #include "DiligentCore/ThirdParty/vulkan/vulkan.h" #include "DiligentCore/Graphics/GraphicsEngineVulkan/interface/TextureViewVk.h" + +void TestTextureViewVk_CInterface(ITextureViewVk* pView) +{ + VkImageView vkView = ITextureViewVk_GetVulkanImageView(pView); + (void)vkView; +} diff --git a/Tests/IncludeTest/GraphicsEngineVk/TextureVkH_test.c b/Tests/IncludeTest/GraphicsEngineVk/TextureVkH_test.c index 51d06227..1c4239ed 100644 --- a/Tests/IncludeTest/GraphicsEngineVk/TextureVkH_test.c +++ b/Tests/IncludeTest/GraphicsEngineVk/TextureVkH_test.c @@ -27,3 +27,14 @@ #include "DiligentCore/ThirdParty/vulkan/vulkan.h" #include "DiligentCore/Graphics/GraphicsEngineVulkan/interface/TextureVk.h" + +void TestTextureVk_CInterface(ITextureVk* pTexture) +{ + VkImage vkImg = ITextureVk_GetVkImage(pTexture); + (void)vkImg; + + ITextureVk_SetLayout(pTexture, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL); + + VkImageLayout vkLayout = ITextureVk_GetLayout(pTexture); + (void)vkLayout; +} -- cgit v1.2.3