From c376f42b73fe548cbd6fa0fb529df8dc7020be76 Mon Sep 17 00:00:00 2001 From: assiduous Date: Thu, 19 Dec 2019 18:51:54 -0800 Subject: Renamed UnitTests folder to Tests --- .../FormatValidation/validate_format_win.bat | 4 +- CMakeLists.txt | 2 +- Tests/CMakeLists.txt | 7 + Tests/DiligentCoreAPITest/CMakeLists.txt | 130 ++ .../shaders/HLSL2GLSLConverter/CS_RWBuff.hlsl | 81 ++ .../shaders/HLSL2GLSLConverter/CS_RWTex1D.hlsl | 134 ++ .../shaders/HLSL2GLSLConverter/CS_RWTex2D_1.hlsl | 216 +++ .../shaders/HLSL2GLSLConverter/CS_RWTex2D_2.hlsl | 123 ++ .../shaders/HLSL2GLSLConverter/IncludeTest.h | 12 + .../assets/shaders/HLSL2GLSLConverter/VS_PS.hlsl | 1283 +++++++++++++++++ .../assets/shaders/ShaderResourceArrayTest.psh | 31 + .../assets/shaders/ShaderResourceArrayTest.vsh | 15 + .../ShaderResourceLayout/ConstantBuffers.hlsl | 67 + .../ShaderResourceLayout/FormattedBuffers.hlsl | 44 + .../ShaderResourceLayout/RWFormattedBuffers.hlsl | 39 + .../ShaderResourceLayout/RWStructuredBuffers.glsl | 62 + .../ShaderResourceLayout/RWStructuredBuffers.hlsl | 44 + .../shaders/ShaderResourceLayout/RWTextures.hlsl | 39 + .../shaders/ShaderResourceLayout/Samplers.hlsl | 49 + .../ShaderResourceLayout/StaticSamplers.hlsl | 54 + .../ShaderResourceLayout/StructuredBuffers.glsl | 89 ++ .../ShaderResourceLayout/StructuredBuffers.hlsl | 49 + .../shaders/ShaderResourceLayout/Textures.hlsl | 47 + .../assets/shaders/ShaderVariableAccessTestDX.psh | 79 ++ .../assets/shaders/ShaderVariableAccessTestDX.vsh | 69 + .../assets/shaders/ShaderVariableAccessTestGL.psh | 78 + .../assets/shaders/ShaderVariableAccessTestGL.vsh | 61 + .../include/CreateObjFromNativeResTestBase.h | 55 + .../include/D3D11/CreateObjFromNativeResD3D11.h | 47 + .../include/D3D11/TestingEnvironmentD3D11.h | 115 ++ .../include/D3D11/TestingSwapChainD3D11.h | 81 ++ .../include/D3D12/CreateObjFromNativeResD3D12.h | 47 + .../D3D12/D3D12DebugLayerSetNameBugWorkaround.h | 57 + .../include/D3D12/TestingEnvironmentD3D12.h | 79 ++ .../include/D3D12/TestingSwapChainD3D12.h | 87 ++ .../include/GL/CreateObjFromNativeResGL.h | 47 + .../include/GL/TestingEnvironmentGL.h | 62 + .../include/GL/TestingSwapChainGL.h | 54 + Tests/DiligentCoreAPITest/include/PSOTestBase.h | 62 + .../include/TestingEnvironment.h | 120 ++ .../include/TestingSwapChainBase.h | 209 +++ .../include/Vulkan/CreateObjFromNativeResVK.h | 47 + .../include/Vulkan/TestingEnvironmentVk.h | 102 ++ .../include/Vulkan/TestingSwapChainVk.h | 96 ++ Tests/DiligentCoreAPITest/src/BlendStateTest.cpp | 428 ++++++ Tests/DiligentCoreAPITest/src/BrokenShaderTest.cpp | 69 + .../DiligentCoreAPITest/src/BufferCreationTest.cpp | 256 ++++ .../src/ClearRenderTargetTest.cpp | 127 ++ Tests/DiligentCoreAPITest/src/CopyTextureTest.cpp | 278 ++++ .../src/D3D11/ClearRenderTargetRefenceD3D11.cpp | 47 + .../src/D3D11/CreateObjFromNativeResD3D11.cpp | 136 ++ .../src/D3D11/DrawCommandReferenceD3D11.cpp | 121 ++ .../src/D3D11/TestingEnvironmentD3D11.cpp | 244 ++++ .../src/D3D11/TestingSwapChainD3D11.cpp | 134 ++ .../src/D3D12/ClearRenderTargetRefenceD3D12.cpp | 64 + .../src/D3D12/CreateObjFromNativeResD3D12.cpp | 104 ++ .../D3D12/D3D12DebugLayerSetNameBugWorkaround.cpp | 76 + .../src/D3D12/DrawCommandReferenceD3D12.cpp | 180 +++ .../src/D3D12/TestingEnvironmentD3D12.cpp | 94 ++ .../src/D3D12/TestingSwapChainD3D12.cpp | 257 ++++ .../src/DepthStencilStateTest.cpp | 111 ++ Tests/DiligentCoreAPITest/src/DrawCommandTest.cpp | 1492 ++++++++++++++++++++ .../src/GL/ClearRenderTargetRefenceGL.cpp | 53 + .../src/GL/CreateObjFromNativeResGL.cpp | 167 +++ .../src/GL/DrawCommandReferenceGL.cpp | 131 ++ .../src/GL/TestingEnvironmentGL.cpp | 144 ++ .../src/GL/TestingSwapChainGL.cpp | 158 +++ Tests/DiligentCoreAPITest/src/GenerateMipsTest.cpp | 129 ++ .../src/HLSL2GLSLConverterTest.cpp | 131 ++ .../src/MTResourceCreationTest.cpp | 311 ++++ .../src/PSOCompatibilityTest.cpp | 325 +++++ Tests/DiligentCoreAPITest/src/PSOTestBase.cpp | 99 ++ .../src/RasterizerStateTest.cpp | 109 ++ .../src/SamplerCreationTest.cpp | 218 +++ .../src/SeparateTextureSamplerTest.cpp | 181 +++ .../src/ShaderResourceArrayTest.cpp | 244 ++++ .../src/ShaderResourceLayoutTest.cpp | 1121 +++++++++++++++ .../src/ShaderVariableAccessTest.cpp | 827 +++++++++++ .../DiligentCoreAPITest/src/TestingEnvironment.cpp | 406 ++++++ .../src/TestingSwapChainBase.cpp | 111 ++ .../src/TextureCreationTest.cpp | 747 ++++++++++ .../src/Vulkan/ClearRenderTargetReferenceVk.cpp | 83 ++ .../src/Vulkan/CreateObjFromNativeResVK.cpp | 104 ++ .../src/Vulkan/DrawCommandReferenceVk.cpp | 274 ++++ .../src/Vulkan/TestingEnvironmentVk.cpp | 641 +++++++++ .../src/Vulkan/TestingSwapChainVk.cpp | 297 ++++ .../src/Win32/TestingEnvironmentWin32.cpp | 69 + Tests/DiligentCoreAPITest/src/main.cpp | 176 +++ Tests/DiligentCoreTest/CMakeLists.txt | 28 + .../DiligentCoreTest/src/Common/AllocatorTest.cpp | 79 ++ Tests/DiligentCoreTest/src/Common/MathLibTest.cpp | 929 ++++++++++++ .../src/Common/RefCntAutoPtrTest.cpp | 903 ++++++++++++ .../src/Common/StringToolsTest.cpp | 55 + .../GraphicsAccessoriesTest.cpp | 450 ++++++ .../ResourceReleaseQueueTest.cpp | 127 ++ .../src/GraphicsAccessories/RingBufferTest.cpp | 288 ++++ .../VariableSizeGPUAllocationsManagerTest.cpp | 195 +++ .../src/Platforms/PlatformMiscTest.cpp | 78 + Tests/IncludeTest/CMakeLists.txt | 48 + Tests/IncludeTest/Common/AdvancedMathH_test.cpp | 24 + Tests/IncludeTest/Common/BasicFileStreamH_test.cpp | 24 + Tests/IncludeTest/Common/BasicMathH_test.cpp | 24 + Tests/IncludeTest/Common/DataBlobImplH_test.cpp | 24 + .../Common/DefaultRawMemoryAllocatorH_test.cpp | 24 + Tests/IncludeTest/Common/FileWrapperH_test.cpp | 24 + .../Common/FixedBlockMemoryAllocatorH_test.cpp | 24 + Tests/IncludeTest/Common/HashUtilsH_test.cpp | 24 + Tests/IncludeTest/Common/LockHelperH_test.cpp | 24 + Tests/IncludeTest/Common/ObjectBaseH_test.cpp | 24 + Tests/IncludeTest/Common/RefCntAutoPtrH_test.cpp | 24 + .../Common/RefCountedObjectImplH_test.cpp | 24 + Tests/IncludeTest/Common/STDAllocatorH_test.cpp | 24 + .../Common/StringDataBlobImplH_test.cpp | 24 + Tests/IncludeTest/Common/StringPool_test.cpp | 24 + Tests/IncludeTest/Common/StringToolsH_test.cpp | 24 + Tests/IncludeTest/Common/ThreadSignalH_test.cpp | 24 + Tests/IncludeTest/Common/TimerH_test.cpp | 24 + .../IncludeTest/Common/UniqueIdentifierH_test.cpp | 24 + Tests/IncludeTest/Common/ValidatedCastH_test.cpp | 24 + .../GraphicsAccessories/ColorConversionH_test.cpp | 24 + .../GraphicsAccessoriesH_test.cpp | 24 + .../ResourceReleaseQueueH_test.cpp | 24 + .../GraphicsAccessories/RingBufferH_test.cpp | 24 + .../SRBMemortAllocatorH_test.cpp | 24 + .../VariableSizeAllocationsManagerH_test.cpp | 24 + .../VariableSizeGPUAllocationsManagerH_test.cpp | 24 + .../GraphicsEngine/BlendStateH_test.cpp | 24 + Tests/IncludeTest/GraphicsEngine/BufferH_test.cpp | 24 + .../GraphicsEngine/BufferViewH_test.cpp | 24 + .../GraphicsEngine/CommandListH_test.cpp | 24 + .../IncludeTest/GraphicsEngine/ConstantsH_test.cpp | 24 + .../DefaultShaderSourceStreamFactoryH_test.cpp | 24 + .../GraphicsEngine/DepthStencilStateH_test.cpp | 24 + .../GraphicsEngine/DeviceCapsH_test.cpp | 24 + .../GraphicsEngine/DeviceContextH_test.cpp | 24 + .../GraphicsEngine/DeviceObjectH_test.cpp | 24 + .../GraphicsEngine/EngineFactoryH_test.cpp | 24 + Tests/IncludeTest/GraphicsEngine/FenceH_test.cpp | 24 + .../GraphicsEngine/GraphicsTypesH_test.cpp | 24 + .../GraphicsEngine/InputLayoutH_test.cpp | 24 + .../IncludeTest/GraphicsEngine/MapHelperH_test.cpp | 24 + .../GraphicsEngine/PipelineStateH_test.cpp | 24 + .../GraphicsEngine/RasterizerStateH_test.cpp | 24 + .../GraphicsEngine/RenderDeviceH_test.cpp | 24 + .../GraphicsEngine/ResourceMappingH_test.cpp | 24 + Tests/IncludeTest/GraphicsEngine/SamplerH_test.cpp | 24 + Tests/IncludeTest/GraphicsEngine/ShaderH_test.cpp | 24 + .../GraphicsEngine/ShaderResourceBindingH_test.cpp | 24 + .../ShaderResourceVaraibleH_test.cpp | 24 + .../IncludeTest/GraphicsEngine/SwapChainH_test.cpp | 24 + Tests/IncludeTest/GraphicsEngine/TextureH_test.cpp | 24 + .../GraphicsEngine/TextureViewH_test.cpp | 24 + .../GraphicsEngineD3D11/BufferD3D11H_test.cpp | 25 + .../GraphicsEngineD3D11/BufferViewD3D11H_test.cpp | 25 + .../DeviceContextD3D11H_test.cpp | 25 + .../EngineFactoryD3D11H_test.cpp | 33 + .../GraphicsEngineD3D11/FenceD3D11H_test.cpp | 25 + .../PipelineStateD3D11H_test.cpp | 25 + .../RenderDeviceD3D11H_test.cpp | 25 + .../GraphicsEngineD3D11/SamplerD3D11H_test.cpp | 25 + .../GraphicsEngineD3D11/ShaderD3D11H_test.cpp | 25 + .../ShaderResourceBindingD3D11H_test.cpp | 25 + .../GraphicsEngineD3D11/SwapChainD3D11H_test.cpp | 24 + .../GraphicsEngineD3D11/TextureD3D11H_test.cpp | 25 + .../GraphicsEngineD3D11/TextureViewD3D11H_test.cpp | 25 + .../GraphicsEngineD3D12/BufferD3D12H_test.cpp | 25 + .../GraphicsEngineD3D12/BufferViewD3D12H_test.cpp | 25 + .../CommandQueueD3D12H_test.cpp | 25 + .../DeviceContextD3D12H_test.cpp | 25 + .../EngineFactoryD3D12H_test.cpp | 33 + .../GraphicsEngineD3D12/FenceD3D12H_test.cpp | 25 + .../PipelineStateD3D12H_test.cpp | 25 + .../RenderDeviceD3D12H_test.cpp | 25 + .../GraphicsEngineD3D12/SamplerD3D12H_test.cpp | 25 + .../GraphicsEngineD3D12/ShaderD3D12H_test.cpp | 24 + .../ShaderResourceBindingD3D12H_test.cpp | 24 + .../GraphicsEngineD3D12/SwapChainD3D12H_test.cpp | 24 + .../GraphicsEngineD3D12/TextureD3D12H_test.cpp | 24 + .../GraphicsEngineD3D12/TextureViewD3D12H_test.cpp | 25 + .../GraphicsEngineD3DBase/ShaderD3DH_test.cpp | 24 + .../ShaderResourceVariableD3DH_test.cpp | 23 + .../BaseInterfacesGLH_test.cpp | 24 + .../GraphicsEngineOpenGL/BufferGLH_test.cpp | 25 + .../GraphicsEngineOpenGL/BufferViewGLH_test.cpp | 24 + .../GraphicsEngineOpenGL/DeviceContextGLH_test.cpp | 24 + .../EngineFactoryOpenGLH_test.cpp | 35 + .../GraphicsEngineOpenGL/FenceGLH_test .cpp | 25 + .../GraphicsEngineOpenGL/PipelineStateGLH_test.cpp | 24 + .../GraphicsEngineOpenGL/RenderDeviceGL_test.cpp | 24 + .../GraphicsEngineOpenGL/SamplerGLH_test.cpp | 24 + .../GraphicsEngineOpenGL/ShaderGLH_test.cpp | 24 + .../ShaderResourceBindingGLH_test.cpp | 23 + .../GraphicsEngineOpenGL/SwapChainGLH_test.cpp | 24 + .../GraphicsEngineOpenGL/TextureGLH_test.cpp | 25 + .../GraphicsEngineOpenGL/TextureViewGLH_test.cpp | 24 + .../GraphicsEngineVk/BufferViewVkH_test.cpp | 25 + .../GraphicsEngineVk/BufferVkH_test.cpp | 25 + .../GraphicsEngineVk/CommandQueueVkH_test.cpp | 25 + .../GraphicsEngineVk/DeviceContextVkH_test.cpp | 25 + .../GraphicsEngineVk/EngineFactoryVkH_test.cpp | 35 + .../IncludeTest/GraphicsEngineVk/FenceVkH_test.cpp | 25 + .../GraphicsEngineVk/PipelineStateVkH_test.cpp | 25 + .../GraphicsEngineVk/RenderDeviceVkH_test.cpp | 25 + .../GraphicsEngineVk/SamplerVkH_test.cpp | 25 + .../ShaderResourceBindingVkH_test.cpp | 24 + .../GraphicsEngineVk/ShaderVkH_test.cpp | 24 + .../GraphicsEngineVk/SwapChainVkH_test.cpp | 24 + .../GraphicsEngineVk/TextureViewVkH_test.cpp | 25 + .../GraphicsEngineVk/TextureVkH_test.cpp | 25 + .../GraphicsTools/CommonlyUsedStatesH_test.cpp | 24 + .../GraphicsTools/GraphicsUtilitiesH_test.cpp | 24 + .../GraphicsTools/ShaderMacroHelperH_test.cpp | 24 + .../GraphicsTools/TextureUploaderBaseH_test.cpp | 24 + .../GraphicsTools/TextureUploaderD3D11H_test.cpp | 26 + .../TextureUploaderD3D12_VkH_test.cpp | 26 + .../GraphicsTools/TextureUploaderGLH_test.cpp | 26 + .../GraphicsTools/TextureUploaderH_test.cpp | 24 + Tests/IncludeTest/Platforms/AtomicsH_test.cpp | 24 + Tests/IncludeTest/Platforms/FileSystemH_test.cpp | 24 + .../IncludeTest/Platforms/PlatformDebugH_test.cpp | 24 + .../Platforms/PlatformDefinitionsH_test.cpp | 24 + Tests/IncludeTest/Platforms/PlatformMiscH_test.cpp | 24 + UnitTests/CMakeLists.txt | 7 - UnitTests/DiligentCoreAPITest/CMakeLists.txt | 130 -- .../shaders/HLSL2GLSLConverter/CS_RWBuff.hlsl | 81 -- .../shaders/HLSL2GLSLConverter/CS_RWTex1D.hlsl | 134 -- .../shaders/HLSL2GLSLConverter/CS_RWTex2D_1.hlsl | 216 --- .../shaders/HLSL2GLSLConverter/CS_RWTex2D_2.hlsl | 123 -- .../shaders/HLSL2GLSLConverter/IncludeTest.h | 12 - .../assets/shaders/HLSL2GLSLConverter/VS_PS.hlsl | 1283 ----------------- .../assets/shaders/ShaderResourceArrayTest.psh | 31 - .../assets/shaders/ShaderResourceArrayTest.vsh | 15 - .../ShaderResourceLayout/ConstantBuffers.hlsl | 67 - .../ShaderResourceLayout/FormattedBuffers.hlsl | 44 - .../ShaderResourceLayout/RWFormattedBuffers.hlsl | 39 - .../ShaderResourceLayout/RWStructuredBuffers.glsl | 62 - .../ShaderResourceLayout/RWStructuredBuffers.hlsl | 44 - .../shaders/ShaderResourceLayout/RWTextures.hlsl | 39 - .../shaders/ShaderResourceLayout/Samplers.hlsl | 49 - .../ShaderResourceLayout/StaticSamplers.hlsl | 54 - .../ShaderResourceLayout/StructuredBuffers.glsl | 89 -- .../ShaderResourceLayout/StructuredBuffers.hlsl | 49 - .../shaders/ShaderResourceLayout/Textures.hlsl | 47 - .../assets/shaders/ShaderVariableAccessTestDX.psh | 79 -- .../assets/shaders/ShaderVariableAccessTestDX.vsh | 69 - .../assets/shaders/ShaderVariableAccessTestGL.psh | 78 - .../assets/shaders/ShaderVariableAccessTestGL.vsh | 61 - .../include/CreateObjFromNativeResTestBase.h | 55 - .../include/D3D11/CreateObjFromNativeResD3D11.h | 47 - .../include/D3D11/TestingEnvironmentD3D11.h | 115 -- .../include/D3D11/TestingSwapChainD3D11.h | 81 -- .../include/D3D12/CreateObjFromNativeResD3D12.h | 47 - .../D3D12/D3D12DebugLayerSetNameBugWorkaround.h | 57 - .../include/D3D12/TestingEnvironmentD3D12.h | 79 -- .../include/D3D12/TestingSwapChainD3D12.h | 87 -- .../include/GL/CreateObjFromNativeResGL.h | 47 - .../include/GL/TestingEnvironmentGL.h | 62 - .../include/GL/TestingSwapChainGL.h | 54 - .../DiligentCoreAPITest/include/PSOTestBase.h | 62 - .../include/TestingEnvironment.h | 120 -- .../include/TestingSwapChainBase.h | 209 --- .../include/Vulkan/CreateObjFromNativeResVK.h | 47 - .../include/Vulkan/TestingEnvironmentVk.h | 102 -- .../include/Vulkan/TestingSwapChainVk.h | 96 -- .../DiligentCoreAPITest/src/BlendStateTest.cpp | 428 ------ .../DiligentCoreAPITest/src/BrokenShaderTest.cpp | 69 - .../DiligentCoreAPITest/src/BufferCreationTest.cpp | 256 ---- .../src/ClearRenderTargetTest.cpp | 127 -- .../DiligentCoreAPITest/src/CopyTextureTest.cpp | 278 ---- .../src/D3D11/ClearRenderTargetRefenceD3D11.cpp | 47 - .../src/D3D11/CreateObjFromNativeResD3D11.cpp | 136 -- .../src/D3D11/DrawCommandRefenceD3D11.cpp | 121 -- .../src/D3D11/TestingEnvironmentD3D11.cpp | 244 ---- .../src/D3D11/TestingSwapChainD3D11.cpp | 134 -- .../src/D3D12/ClearRenderTargetRefenceD3D12.cpp | 64 - .../src/D3D12/CreateObjFromNativeResD3D12.cpp | 104 -- .../D3D12/D3D12DebugLayerSetNameBugWorkaround.cpp | 76 - .../src/D3D12/DrawCommandRefenceD3D12.cpp | 180 --- .../src/D3D12/TestingEnvironmentD3D12.cpp | 94 -- .../src/D3D12/TestingSwapChainD3D12.cpp | 257 ---- .../src/DepthStencilStateTest.cpp | 111 -- .../DiligentCoreAPITest/src/DrawCommandTest.cpp | 1492 -------------------- .../src/GL/ClearRenderTargetRefenceGL.cpp | 53 - .../src/GL/CreateObjFromNativeResGL.cpp | 167 --- .../src/GL/DrawCommandRefenceGL.cpp | 131 -- .../src/GL/TestingEnvironmentGL.cpp | 144 -- .../src/GL/TestingSwapChainGL.cpp | 158 --- .../DiligentCoreAPITest/src/GenerateMipsTest.cpp | 129 -- .../src/HLSL2GLSLConverterTest.cpp | 131 -- .../src/MTResourceCreationTest.cpp | 311 ---- .../src/PSOCompatibilityTest.cpp | 325 ----- UnitTests/DiligentCoreAPITest/src/PSOTestBase.cpp | 99 -- .../src/RasterizerStateTest.cpp | 109 -- .../src/SamplerCreationTest.cpp | 218 --- .../src/SeparateTextureSamplerTest.cpp | 181 --- .../src/ShaderResourceArrayTest.cpp | 244 ---- .../src/ShaderResourceLayoutTest.cpp | 1121 --------------- .../src/ShaderVariableAccessTest.cpp | 827 ----------- .../DiligentCoreAPITest/src/TestingEnvironment.cpp | 406 ------ .../src/TestingSwapChainBase.cpp | 111 -- .../src/TextureCreationTest.cpp | 747 ---------- .../src/Vulkan/ClearRenderTargetReferenceVk.cpp | 83 -- .../src/Vulkan/CreateObjFromNativeResVK.cpp | 104 -- .../src/Vulkan/DrawCommandRefenceVk.cpp | 274 ---- .../src/Vulkan/TestingEnvironmentVk.cpp | 641 --------- .../src/Vulkan/TestingSwapChainVk.cpp | 297 ---- .../src/Win32/TestingEnvironmentWin32.cpp | 69 - UnitTests/DiligentCoreAPITest/src/main.cpp | 176 --- UnitTests/DiligentCoreTest/CMakeLists.txt | 28 - .../DiligentCoreTest/src/Common/AllocatorTest.cpp | 79 -- .../DiligentCoreTest/src/Common/MathLibTest.cpp | 929 ------------ .../src/Common/RefCntAutoPtrTest.cpp | 903 ------------ .../src/Common/StringToolsTest.cpp | 55 - .../GraphicsAccessoriesTest.cpp | 450 ------ .../ResourceReleaseQueueTest.cpp | 127 -- .../src/GraphicsAccessories/RingBufferTest.cpp | 288 ---- .../VariableSizeGPUAllocationsManagerTest.cpp | 195 --- .../src/Platforms/PlatformMiscTest.cpp | 78 - UnitTests/IncludeTest/CMakeLists.txt | 48 - .../IncludeTest/Common/AdvancedMathH_test.cpp | 24 - .../IncludeTest/Common/BasicFileStreamH_test.cpp | 24 - UnitTests/IncludeTest/Common/BasicMathH_test.cpp | 24 - .../IncludeTest/Common/DataBlobImplH_test.cpp | 24 - .../Common/DefaultRawMemoryAllocatorH_test.cpp | 24 - UnitTests/IncludeTest/Common/FileWrapperH_test.cpp | 24 - .../Common/FixedBlockMemoryAllocatorH_test.cpp | 24 - UnitTests/IncludeTest/Common/HashUtilsH_test.cpp | 24 - UnitTests/IncludeTest/Common/LockHelperH_test.cpp | 24 - UnitTests/IncludeTest/Common/ObjectBaseH_test.cpp | 24 - .../IncludeTest/Common/RefCntAutoPtrH_test.cpp | 24 - .../Common/RefCountedObjectImplH_test.cpp | 24 - .../IncludeTest/Common/STDAllocatorH_test.cpp | 24 - .../Common/StringDataBlobImplH_test.cpp | 24 - UnitTests/IncludeTest/Common/StringPool_test.cpp | 24 - UnitTests/IncludeTest/Common/StringToolsH_test.cpp | 24 - .../IncludeTest/Common/ThreadSignalH_test.cpp | 24 - UnitTests/IncludeTest/Common/TimerH_test.cpp | 24 - .../IncludeTest/Common/UniqueIdentifierH_test.cpp | 24 - .../IncludeTest/Common/ValidatedCastH_test.cpp | 24 - .../GraphicsAccessories/ColorConversionH_test.cpp | 24 - .../GraphicsAccessoriesH_test.cpp | 24 - .../ResourceReleaseQueueH_test.cpp | 24 - .../GraphicsAccessories/RingBufferH_test.cpp | 24 - .../SRBMemortAllocatorH_test.cpp | 24 - .../VariableSizeAllocationsManagerH_test.cpp | 24 - .../VariableSizeGPUAllocationsManagerH_test.cpp | 24 - .../GraphicsEngine/BlendStateH_test.cpp | 24 - .../IncludeTest/GraphicsEngine/BufferH_test.cpp | 24 - .../GraphicsEngine/BufferViewH_test.cpp | 24 - .../GraphicsEngine/CommandListH_test.cpp | 24 - .../IncludeTest/GraphicsEngine/ConstantsH_test.cpp | 24 - .../DefaultShaderSourceStreamFactoryH_test.cpp | 24 - .../GraphicsEngine/DepthStencilStateH_test.cpp | 24 - .../GraphicsEngine/DeviceCapsH_test.cpp | 24 - .../GraphicsEngine/DeviceContextH_test.cpp | 24 - .../GraphicsEngine/DeviceObjectH_test.cpp | 24 - .../GraphicsEngine/EngineFactoryH_test.cpp | 24 - .../IncludeTest/GraphicsEngine/FenceH_test.cpp | 24 - .../GraphicsEngine/GraphicsTypesH_test.cpp | 24 - .../GraphicsEngine/InputLayoutH_test.cpp | 24 - .../IncludeTest/GraphicsEngine/MapHelperH_test.cpp | 24 - .../GraphicsEngine/PipelineStateH_test.cpp | 24 - .../GraphicsEngine/RasterizerStateH_test.cpp | 24 - .../GraphicsEngine/RenderDeviceH_test.cpp | 24 - .../GraphicsEngine/ResourceMappingH_test.cpp | 24 - .../IncludeTest/GraphicsEngine/SamplerH_test.cpp | 24 - .../IncludeTest/GraphicsEngine/ShaderH_test.cpp | 24 - .../GraphicsEngine/ShaderResourceBindingH_test.cpp | 24 - .../ShaderResourceVaraibleH_test.cpp | 24 - .../IncludeTest/GraphicsEngine/SwapChainH_test.cpp | 24 - .../IncludeTest/GraphicsEngine/TextureH_test.cpp | 24 - .../GraphicsEngine/TextureViewH_test.cpp | 24 - .../GraphicsEngineD3D11/BufferD3D11H_test.cpp | 25 - .../GraphicsEngineD3D11/BufferViewD3D11H_test.cpp | 25 - .../DeviceContextD3D11H_test.cpp | 25 - .../EngineFactoryD3D11H_test.cpp | 33 - .../GraphicsEngineD3D11/FenceD3D11H_test.cpp | 25 - .../PipelineStateD3D11H_test.cpp | 25 - .../RenderDeviceD3D11H_test.cpp | 25 - .../GraphicsEngineD3D11/SamplerD3D11H_test.cpp | 25 - .../GraphicsEngineD3D11/ShaderD3D11H_test.cpp | 25 - .../ShaderResourceBindingD3D11H_test.cpp | 25 - .../GraphicsEngineD3D11/SwapChainD3D11H_test.cpp | 24 - .../GraphicsEngineD3D11/TextureD3D11H_test.cpp | 25 - .../GraphicsEngineD3D11/TextureViewD3D11H_test.cpp | 25 - .../GraphicsEngineD3D12/BufferD3D12H_test.cpp | 25 - .../GraphicsEngineD3D12/BufferViewD3D12H_test.cpp | 25 - .../CommandQueueD3D12H_test.cpp | 25 - .../DeviceContextD3D12H_test.cpp | 25 - .../EngineFactoryD3D12H_test.cpp | 33 - .../GraphicsEngineD3D12/FenceD3D12H_test.cpp | 25 - .../PipelineStateD3D12H_test.cpp | 25 - .../RenderDeviceD3D12H_test.cpp | 25 - .../GraphicsEngineD3D12/SamplerD3D12H_test.cpp | 25 - .../GraphicsEngineD3D12/ShaderD3D12H_test.cpp | 24 - .../ShaderResourceBindingD3D12H_test.cpp | 24 - .../GraphicsEngineD3D12/SwapChainD3D12H_test.cpp | 24 - .../GraphicsEngineD3D12/TextureD3D12H_test.cpp | 24 - .../GraphicsEngineD3D12/TextureViewD3D12H_test.cpp | 25 - .../GraphicsEngineD3DBase/ShaderD3DH_test.cpp | 24 - .../ShaderResourceVariableD3DH_test.cpp | 23 - .../BaseInterfacesGLH_test.cpp | 24 - .../GraphicsEngineOpenGL/BufferGLH_test.cpp | 25 - .../GraphicsEngineOpenGL/BufferViewGLH_test.cpp | 24 - .../GraphicsEngineOpenGL/DeviceContextGLH_test.cpp | 24 - .../EngineFactoryOpenGLH_test.cpp | 35 - .../GraphicsEngineOpenGL/FenceGLH_test .cpp | 25 - .../GraphicsEngineOpenGL/PipelineStateGLH_test.cpp | 24 - .../GraphicsEngineOpenGL/RenderDeviceGL_test.cpp | 24 - .../GraphicsEngineOpenGL/SamplerGLH_test.cpp | 24 - .../GraphicsEngineOpenGL/ShaderGLH_test.cpp | 24 - .../ShaderResourceBindingGLH_test.cpp | 23 - .../GraphicsEngineOpenGL/SwapChainGLH_test.cpp | 24 - .../GraphicsEngineOpenGL/TextureGLH_test.cpp | 25 - .../GraphicsEngineOpenGL/TextureViewGLH_test.cpp | 24 - .../GraphicsEngineVk/BufferViewVkH_test.cpp | 25 - .../GraphicsEngineVk/BufferVkH_test.cpp | 25 - .../GraphicsEngineVk/CommandQueueVkH_test.cpp | 25 - .../GraphicsEngineVk/DeviceContextVkH_test.cpp | 25 - .../GraphicsEngineVk/EngineFactoryVkH_test.cpp | 35 - .../IncludeTest/GraphicsEngineVk/FenceVkH_test.cpp | 25 - .../GraphicsEngineVk/PipelineStateVkH_test.cpp | 25 - .../GraphicsEngineVk/RenderDeviceVkH_test.cpp | 25 - .../GraphicsEngineVk/SamplerVkH_test.cpp | 25 - .../ShaderResourceBindingVkH_test.cpp | 24 - .../GraphicsEngineVk/ShaderVkH_test.cpp | 24 - .../GraphicsEngineVk/SwapChainVkH_test.cpp | 24 - .../GraphicsEngineVk/TextureViewVkH_test.cpp | 25 - .../GraphicsEngineVk/TextureVkH_test.cpp | 25 - .../GraphicsTools/CommonlyUsedStatesH_test.cpp | 24 - .../GraphicsTools/GraphicsUtilitiesH_test.cpp | 24 - .../GraphicsTools/ShaderMacroHelperH_test.cpp | 24 - .../GraphicsTools/TextureUploaderBaseH_test.cpp | 24 - .../GraphicsTools/TextureUploaderD3D11H_test.cpp | 26 - .../TextureUploaderD3D12_VkH_test.cpp | 26 - .../GraphicsTools/TextureUploaderGLH_test.cpp | 26 - .../GraphicsTools/TextureUploaderH_test.cpp | 24 - UnitTests/IncludeTest/Platforms/AtomicsH_test.cpp | 24 - .../IncludeTest/Platforms/FileSystemH_test.cpp | 24 - .../IncludeTest/Platforms/PlatformDebugH_test.cpp | 24 - .../Platforms/PlatformDefinitionsH_test.cpp | 24 - .../IncludeTest/Platforms/PlatformMiscH_test.cpp | 24 - 442 files changed, 21955 insertions(+), 21955 deletions(-) create mode 100644 Tests/CMakeLists.txt create mode 100644 Tests/DiligentCoreAPITest/CMakeLists.txt create mode 100644 Tests/DiligentCoreAPITest/assets/shaders/HLSL2GLSLConverter/CS_RWBuff.hlsl create mode 100644 Tests/DiligentCoreAPITest/assets/shaders/HLSL2GLSLConverter/CS_RWTex1D.hlsl create mode 100644 Tests/DiligentCoreAPITest/assets/shaders/HLSL2GLSLConverter/CS_RWTex2D_1.hlsl create mode 100644 Tests/DiligentCoreAPITest/assets/shaders/HLSL2GLSLConverter/CS_RWTex2D_2.hlsl create mode 100644 Tests/DiligentCoreAPITest/assets/shaders/HLSL2GLSLConverter/IncludeTest.h create mode 100644 Tests/DiligentCoreAPITest/assets/shaders/HLSL2GLSLConverter/VS_PS.hlsl create mode 100644 Tests/DiligentCoreAPITest/assets/shaders/ShaderResourceArrayTest.psh create mode 100644 Tests/DiligentCoreAPITest/assets/shaders/ShaderResourceArrayTest.vsh create mode 100644 Tests/DiligentCoreAPITest/assets/shaders/ShaderResourceLayout/ConstantBuffers.hlsl create mode 100644 Tests/DiligentCoreAPITest/assets/shaders/ShaderResourceLayout/FormattedBuffers.hlsl create mode 100644 Tests/DiligentCoreAPITest/assets/shaders/ShaderResourceLayout/RWFormattedBuffers.hlsl create mode 100644 Tests/DiligentCoreAPITest/assets/shaders/ShaderResourceLayout/RWStructuredBuffers.glsl create mode 100644 Tests/DiligentCoreAPITest/assets/shaders/ShaderResourceLayout/RWStructuredBuffers.hlsl create mode 100644 Tests/DiligentCoreAPITest/assets/shaders/ShaderResourceLayout/RWTextures.hlsl create mode 100644 Tests/DiligentCoreAPITest/assets/shaders/ShaderResourceLayout/Samplers.hlsl create mode 100644 Tests/DiligentCoreAPITest/assets/shaders/ShaderResourceLayout/StaticSamplers.hlsl create mode 100644 Tests/DiligentCoreAPITest/assets/shaders/ShaderResourceLayout/StructuredBuffers.glsl create mode 100644 Tests/DiligentCoreAPITest/assets/shaders/ShaderResourceLayout/StructuredBuffers.hlsl create mode 100644 Tests/DiligentCoreAPITest/assets/shaders/ShaderResourceLayout/Textures.hlsl create mode 100644 Tests/DiligentCoreAPITest/assets/shaders/ShaderVariableAccessTestDX.psh create mode 100644 Tests/DiligentCoreAPITest/assets/shaders/ShaderVariableAccessTestDX.vsh create mode 100644 Tests/DiligentCoreAPITest/assets/shaders/ShaderVariableAccessTestGL.psh create mode 100644 Tests/DiligentCoreAPITest/assets/shaders/ShaderVariableAccessTestGL.vsh create mode 100644 Tests/DiligentCoreAPITest/include/CreateObjFromNativeResTestBase.h create mode 100644 Tests/DiligentCoreAPITest/include/D3D11/CreateObjFromNativeResD3D11.h create mode 100644 Tests/DiligentCoreAPITest/include/D3D11/TestingEnvironmentD3D11.h create mode 100644 Tests/DiligentCoreAPITest/include/D3D11/TestingSwapChainD3D11.h create mode 100644 Tests/DiligentCoreAPITest/include/D3D12/CreateObjFromNativeResD3D12.h create mode 100644 Tests/DiligentCoreAPITest/include/D3D12/D3D12DebugLayerSetNameBugWorkaround.h create mode 100644 Tests/DiligentCoreAPITest/include/D3D12/TestingEnvironmentD3D12.h create mode 100644 Tests/DiligentCoreAPITest/include/D3D12/TestingSwapChainD3D12.h create mode 100644 Tests/DiligentCoreAPITest/include/GL/CreateObjFromNativeResGL.h create mode 100644 Tests/DiligentCoreAPITest/include/GL/TestingEnvironmentGL.h create mode 100644 Tests/DiligentCoreAPITest/include/GL/TestingSwapChainGL.h create mode 100644 Tests/DiligentCoreAPITest/include/PSOTestBase.h create mode 100644 Tests/DiligentCoreAPITest/include/TestingEnvironment.h create mode 100644 Tests/DiligentCoreAPITest/include/TestingSwapChainBase.h create mode 100644 Tests/DiligentCoreAPITest/include/Vulkan/CreateObjFromNativeResVK.h create mode 100644 Tests/DiligentCoreAPITest/include/Vulkan/TestingEnvironmentVk.h create mode 100644 Tests/DiligentCoreAPITest/include/Vulkan/TestingSwapChainVk.h create mode 100644 Tests/DiligentCoreAPITest/src/BlendStateTest.cpp create mode 100644 Tests/DiligentCoreAPITest/src/BrokenShaderTest.cpp create mode 100644 Tests/DiligentCoreAPITest/src/BufferCreationTest.cpp create mode 100644 Tests/DiligentCoreAPITest/src/ClearRenderTargetTest.cpp create mode 100644 Tests/DiligentCoreAPITest/src/CopyTextureTest.cpp create mode 100644 Tests/DiligentCoreAPITest/src/D3D11/ClearRenderTargetRefenceD3D11.cpp create mode 100644 Tests/DiligentCoreAPITest/src/D3D11/CreateObjFromNativeResD3D11.cpp create mode 100644 Tests/DiligentCoreAPITest/src/D3D11/DrawCommandReferenceD3D11.cpp create mode 100644 Tests/DiligentCoreAPITest/src/D3D11/TestingEnvironmentD3D11.cpp create mode 100644 Tests/DiligentCoreAPITest/src/D3D11/TestingSwapChainD3D11.cpp create mode 100644 Tests/DiligentCoreAPITest/src/D3D12/ClearRenderTargetRefenceD3D12.cpp create mode 100644 Tests/DiligentCoreAPITest/src/D3D12/CreateObjFromNativeResD3D12.cpp create mode 100644 Tests/DiligentCoreAPITest/src/D3D12/D3D12DebugLayerSetNameBugWorkaround.cpp create mode 100644 Tests/DiligentCoreAPITest/src/D3D12/DrawCommandReferenceD3D12.cpp create mode 100644 Tests/DiligentCoreAPITest/src/D3D12/TestingEnvironmentD3D12.cpp create mode 100644 Tests/DiligentCoreAPITest/src/D3D12/TestingSwapChainD3D12.cpp create mode 100644 Tests/DiligentCoreAPITest/src/DepthStencilStateTest.cpp create mode 100644 Tests/DiligentCoreAPITest/src/DrawCommandTest.cpp create mode 100644 Tests/DiligentCoreAPITest/src/GL/ClearRenderTargetRefenceGL.cpp create mode 100644 Tests/DiligentCoreAPITest/src/GL/CreateObjFromNativeResGL.cpp create mode 100644 Tests/DiligentCoreAPITest/src/GL/DrawCommandReferenceGL.cpp create mode 100644 Tests/DiligentCoreAPITest/src/GL/TestingEnvironmentGL.cpp create mode 100644 Tests/DiligentCoreAPITest/src/GL/TestingSwapChainGL.cpp create mode 100644 Tests/DiligentCoreAPITest/src/GenerateMipsTest.cpp create mode 100644 Tests/DiligentCoreAPITest/src/HLSL2GLSLConverterTest.cpp create mode 100644 Tests/DiligentCoreAPITest/src/MTResourceCreationTest.cpp create mode 100644 Tests/DiligentCoreAPITest/src/PSOCompatibilityTest.cpp create mode 100644 Tests/DiligentCoreAPITest/src/PSOTestBase.cpp create mode 100644 Tests/DiligentCoreAPITest/src/RasterizerStateTest.cpp create mode 100644 Tests/DiligentCoreAPITest/src/SamplerCreationTest.cpp create mode 100644 Tests/DiligentCoreAPITest/src/SeparateTextureSamplerTest.cpp create mode 100644 Tests/DiligentCoreAPITest/src/ShaderResourceArrayTest.cpp create mode 100644 Tests/DiligentCoreAPITest/src/ShaderResourceLayoutTest.cpp create mode 100644 Tests/DiligentCoreAPITest/src/ShaderVariableAccessTest.cpp create mode 100644 Tests/DiligentCoreAPITest/src/TestingEnvironment.cpp create mode 100644 Tests/DiligentCoreAPITest/src/TestingSwapChainBase.cpp create mode 100644 Tests/DiligentCoreAPITest/src/TextureCreationTest.cpp create mode 100644 Tests/DiligentCoreAPITest/src/Vulkan/ClearRenderTargetReferenceVk.cpp create mode 100644 Tests/DiligentCoreAPITest/src/Vulkan/CreateObjFromNativeResVK.cpp create mode 100644 Tests/DiligentCoreAPITest/src/Vulkan/DrawCommandReferenceVk.cpp create mode 100644 Tests/DiligentCoreAPITest/src/Vulkan/TestingEnvironmentVk.cpp create mode 100644 Tests/DiligentCoreAPITest/src/Vulkan/TestingSwapChainVk.cpp create mode 100644 Tests/DiligentCoreAPITest/src/Win32/TestingEnvironmentWin32.cpp create mode 100644 Tests/DiligentCoreAPITest/src/main.cpp create mode 100644 Tests/DiligentCoreTest/CMakeLists.txt create mode 100644 Tests/DiligentCoreTest/src/Common/AllocatorTest.cpp create mode 100644 Tests/DiligentCoreTest/src/Common/MathLibTest.cpp create mode 100644 Tests/DiligentCoreTest/src/Common/RefCntAutoPtrTest.cpp create mode 100644 Tests/DiligentCoreTest/src/Common/StringToolsTest.cpp create mode 100644 Tests/DiligentCoreTest/src/GraphicsAccessories/GraphicsAccessoriesTest.cpp create mode 100644 Tests/DiligentCoreTest/src/GraphicsAccessories/ResourceReleaseQueueTest.cpp create mode 100644 Tests/DiligentCoreTest/src/GraphicsAccessories/RingBufferTest.cpp create mode 100644 Tests/DiligentCoreTest/src/GraphicsAccessories/VariableSizeGPUAllocationsManagerTest.cpp create mode 100644 Tests/DiligentCoreTest/src/Platforms/PlatformMiscTest.cpp create mode 100644 Tests/IncludeTest/CMakeLists.txt create mode 100644 Tests/IncludeTest/Common/AdvancedMathH_test.cpp create mode 100644 Tests/IncludeTest/Common/BasicFileStreamH_test.cpp create mode 100644 Tests/IncludeTest/Common/BasicMathH_test.cpp create mode 100644 Tests/IncludeTest/Common/DataBlobImplH_test.cpp create mode 100644 Tests/IncludeTest/Common/DefaultRawMemoryAllocatorH_test.cpp create mode 100644 Tests/IncludeTest/Common/FileWrapperH_test.cpp create mode 100644 Tests/IncludeTest/Common/FixedBlockMemoryAllocatorH_test.cpp create mode 100644 Tests/IncludeTest/Common/HashUtilsH_test.cpp create mode 100644 Tests/IncludeTest/Common/LockHelperH_test.cpp create mode 100644 Tests/IncludeTest/Common/ObjectBaseH_test.cpp create mode 100644 Tests/IncludeTest/Common/RefCntAutoPtrH_test.cpp create mode 100644 Tests/IncludeTest/Common/RefCountedObjectImplH_test.cpp create mode 100644 Tests/IncludeTest/Common/STDAllocatorH_test.cpp create mode 100644 Tests/IncludeTest/Common/StringDataBlobImplH_test.cpp create mode 100644 Tests/IncludeTest/Common/StringPool_test.cpp create mode 100644 Tests/IncludeTest/Common/StringToolsH_test.cpp create mode 100644 Tests/IncludeTest/Common/ThreadSignalH_test.cpp create mode 100644 Tests/IncludeTest/Common/TimerH_test.cpp create mode 100644 Tests/IncludeTest/Common/UniqueIdentifierH_test.cpp create mode 100644 Tests/IncludeTest/Common/ValidatedCastH_test.cpp create mode 100644 Tests/IncludeTest/GraphicsAccessories/ColorConversionH_test.cpp create mode 100644 Tests/IncludeTest/GraphicsAccessories/GraphicsAccessoriesH_test.cpp create mode 100644 Tests/IncludeTest/GraphicsAccessories/ResourceReleaseQueueH_test.cpp create mode 100644 Tests/IncludeTest/GraphicsAccessories/RingBufferH_test.cpp create mode 100644 Tests/IncludeTest/GraphicsAccessories/SRBMemortAllocatorH_test.cpp create mode 100644 Tests/IncludeTest/GraphicsAccessories/VariableSizeAllocationsManagerH_test.cpp create mode 100644 Tests/IncludeTest/GraphicsAccessories/VariableSizeGPUAllocationsManagerH_test.cpp create mode 100644 Tests/IncludeTest/GraphicsEngine/BlendStateH_test.cpp create mode 100644 Tests/IncludeTest/GraphicsEngine/BufferH_test.cpp create mode 100644 Tests/IncludeTest/GraphicsEngine/BufferViewH_test.cpp create mode 100644 Tests/IncludeTest/GraphicsEngine/CommandListH_test.cpp create mode 100644 Tests/IncludeTest/GraphicsEngine/ConstantsH_test.cpp create mode 100644 Tests/IncludeTest/GraphicsEngine/DefaultShaderSourceStreamFactoryH_test.cpp create mode 100644 Tests/IncludeTest/GraphicsEngine/DepthStencilStateH_test.cpp create mode 100644 Tests/IncludeTest/GraphicsEngine/DeviceCapsH_test.cpp create mode 100644 Tests/IncludeTest/GraphicsEngine/DeviceContextH_test.cpp create mode 100644 Tests/IncludeTest/GraphicsEngine/DeviceObjectH_test.cpp create mode 100644 Tests/IncludeTest/GraphicsEngine/EngineFactoryH_test.cpp create mode 100644 Tests/IncludeTest/GraphicsEngine/FenceH_test.cpp create mode 100644 Tests/IncludeTest/GraphicsEngine/GraphicsTypesH_test.cpp create mode 100644 Tests/IncludeTest/GraphicsEngine/InputLayoutH_test.cpp create mode 100644 Tests/IncludeTest/GraphicsEngine/MapHelperH_test.cpp create mode 100644 Tests/IncludeTest/GraphicsEngine/PipelineStateH_test.cpp create mode 100644 Tests/IncludeTest/GraphicsEngine/RasterizerStateH_test.cpp create mode 100644 Tests/IncludeTest/GraphicsEngine/RenderDeviceH_test.cpp create mode 100644 Tests/IncludeTest/GraphicsEngine/ResourceMappingH_test.cpp create mode 100644 Tests/IncludeTest/GraphicsEngine/SamplerH_test.cpp create mode 100644 Tests/IncludeTest/GraphicsEngine/ShaderH_test.cpp create mode 100644 Tests/IncludeTest/GraphicsEngine/ShaderResourceBindingH_test.cpp create mode 100644 Tests/IncludeTest/GraphicsEngine/ShaderResourceVaraibleH_test.cpp create mode 100644 Tests/IncludeTest/GraphicsEngine/SwapChainH_test.cpp create mode 100644 Tests/IncludeTest/GraphicsEngine/TextureH_test.cpp create mode 100644 Tests/IncludeTest/GraphicsEngine/TextureViewH_test.cpp create mode 100644 Tests/IncludeTest/GraphicsEngineD3D11/BufferD3D11H_test.cpp create mode 100644 Tests/IncludeTest/GraphicsEngineD3D11/BufferViewD3D11H_test.cpp create mode 100644 Tests/IncludeTest/GraphicsEngineD3D11/DeviceContextD3D11H_test.cpp create mode 100644 Tests/IncludeTest/GraphicsEngineD3D11/EngineFactoryD3D11H_test.cpp create mode 100644 Tests/IncludeTest/GraphicsEngineD3D11/FenceD3D11H_test.cpp create mode 100644 Tests/IncludeTest/GraphicsEngineD3D11/PipelineStateD3D11H_test.cpp create mode 100644 Tests/IncludeTest/GraphicsEngineD3D11/RenderDeviceD3D11H_test.cpp create mode 100644 Tests/IncludeTest/GraphicsEngineD3D11/SamplerD3D11H_test.cpp create mode 100644 Tests/IncludeTest/GraphicsEngineD3D11/ShaderD3D11H_test.cpp create mode 100644 Tests/IncludeTest/GraphicsEngineD3D11/ShaderResourceBindingD3D11H_test.cpp create mode 100644 Tests/IncludeTest/GraphicsEngineD3D11/SwapChainD3D11H_test.cpp create mode 100644 Tests/IncludeTest/GraphicsEngineD3D11/TextureD3D11H_test.cpp create mode 100644 Tests/IncludeTest/GraphicsEngineD3D11/TextureViewD3D11H_test.cpp create mode 100644 Tests/IncludeTest/GraphicsEngineD3D12/BufferD3D12H_test.cpp create mode 100644 Tests/IncludeTest/GraphicsEngineD3D12/BufferViewD3D12H_test.cpp create mode 100644 Tests/IncludeTest/GraphicsEngineD3D12/CommandQueueD3D12H_test.cpp create mode 100644 Tests/IncludeTest/GraphicsEngineD3D12/DeviceContextD3D12H_test.cpp create mode 100644 Tests/IncludeTest/GraphicsEngineD3D12/EngineFactoryD3D12H_test.cpp create mode 100644 Tests/IncludeTest/GraphicsEngineD3D12/FenceD3D12H_test.cpp create mode 100644 Tests/IncludeTest/GraphicsEngineD3D12/PipelineStateD3D12H_test.cpp create mode 100644 Tests/IncludeTest/GraphicsEngineD3D12/RenderDeviceD3D12H_test.cpp create mode 100644 Tests/IncludeTest/GraphicsEngineD3D12/SamplerD3D12H_test.cpp create mode 100644 Tests/IncludeTest/GraphicsEngineD3D12/ShaderD3D12H_test.cpp create mode 100644 Tests/IncludeTest/GraphicsEngineD3D12/ShaderResourceBindingD3D12H_test.cpp create mode 100644 Tests/IncludeTest/GraphicsEngineD3D12/SwapChainD3D12H_test.cpp create mode 100644 Tests/IncludeTest/GraphicsEngineD3D12/TextureD3D12H_test.cpp create mode 100644 Tests/IncludeTest/GraphicsEngineD3D12/TextureViewD3D12H_test.cpp create mode 100644 Tests/IncludeTest/GraphicsEngineD3DBase/ShaderD3DH_test.cpp create mode 100644 Tests/IncludeTest/GraphicsEngineD3DBase/ShaderResourceVariableD3DH_test.cpp create mode 100644 Tests/IncludeTest/GraphicsEngineOpenGL/BaseInterfacesGLH_test.cpp create mode 100644 Tests/IncludeTest/GraphicsEngineOpenGL/BufferGLH_test.cpp create mode 100644 Tests/IncludeTest/GraphicsEngineOpenGL/BufferViewGLH_test.cpp create mode 100644 Tests/IncludeTest/GraphicsEngineOpenGL/DeviceContextGLH_test.cpp create mode 100644 Tests/IncludeTest/GraphicsEngineOpenGL/EngineFactoryOpenGLH_test.cpp create mode 100644 Tests/IncludeTest/GraphicsEngineOpenGL/FenceGLH_test .cpp create mode 100644 Tests/IncludeTest/GraphicsEngineOpenGL/PipelineStateGLH_test.cpp create mode 100644 Tests/IncludeTest/GraphicsEngineOpenGL/RenderDeviceGL_test.cpp create mode 100644 Tests/IncludeTest/GraphicsEngineOpenGL/SamplerGLH_test.cpp create mode 100644 Tests/IncludeTest/GraphicsEngineOpenGL/ShaderGLH_test.cpp create mode 100644 Tests/IncludeTest/GraphicsEngineOpenGL/ShaderResourceBindingGLH_test.cpp create mode 100644 Tests/IncludeTest/GraphicsEngineOpenGL/SwapChainGLH_test.cpp create mode 100644 Tests/IncludeTest/GraphicsEngineOpenGL/TextureGLH_test.cpp create mode 100644 Tests/IncludeTest/GraphicsEngineOpenGL/TextureViewGLH_test.cpp create mode 100644 Tests/IncludeTest/GraphicsEngineVk/BufferViewVkH_test.cpp create mode 100644 Tests/IncludeTest/GraphicsEngineVk/BufferVkH_test.cpp create mode 100644 Tests/IncludeTest/GraphicsEngineVk/CommandQueueVkH_test.cpp create mode 100644 Tests/IncludeTest/GraphicsEngineVk/DeviceContextVkH_test.cpp create mode 100644 Tests/IncludeTest/GraphicsEngineVk/EngineFactoryVkH_test.cpp create mode 100644 Tests/IncludeTest/GraphicsEngineVk/FenceVkH_test.cpp create mode 100644 Tests/IncludeTest/GraphicsEngineVk/PipelineStateVkH_test.cpp create mode 100644 Tests/IncludeTest/GraphicsEngineVk/RenderDeviceVkH_test.cpp create mode 100644 Tests/IncludeTest/GraphicsEngineVk/SamplerVkH_test.cpp create mode 100644 Tests/IncludeTest/GraphicsEngineVk/ShaderResourceBindingVkH_test.cpp create mode 100644 Tests/IncludeTest/GraphicsEngineVk/ShaderVkH_test.cpp create mode 100644 Tests/IncludeTest/GraphicsEngineVk/SwapChainVkH_test.cpp create mode 100644 Tests/IncludeTest/GraphicsEngineVk/TextureViewVkH_test.cpp create mode 100644 Tests/IncludeTest/GraphicsEngineVk/TextureVkH_test.cpp create mode 100644 Tests/IncludeTest/GraphicsTools/CommonlyUsedStatesH_test.cpp create mode 100644 Tests/IncludeTest/GraphicsTools/GraphicsUtilitiesH_test.cpp create mode 100644 Tests/IncludeTest/GraphicsTools/ShaderMacroHelperH_test.cpp create mode 100644 Tests/IncludeTest/GraphicsTools/TextureUploaderBaseH_test.cpp create mode 100644 Tests/IncludeTest/GraphicsTools/TextureUploaderD3D11H_test.cpp create mode 100644 Tests/IncludeTest/GraphicsTools/TextureUploaderD3D12_VkH_test.cpp create mode 100644 Tests/IncludeTest/GraphicsTools/TextureUploaderGLH_test.cpp create mode 100644 Tests/IncludeTest/GraphicsTools/TextureUploaderH_test.cpp create mode 100644 Tests/IncludeTest/Platforms/AtomicsH_test.cpp create mode 100644 Tests/IncludeTest/Platforms/FileSystemH_test.cpp create mode 100644 Tests/IncludeTest/Platforms/PlatformDebugH_test.cpp create mode 100644 Tests/IncludeTest/Platforms/PlatformDefinitionsH_test.cpp create mode 100644 Tests/IncludeTest/Platforms/PlatformMiscH_test.cpp delete mode 100644 UnitTests/CMakeLists.txt delete mode 100644 UnitTests/DiligentCoreAPITest/CMakeLists.txt delete mode 100644 UnitTests/DiligentCoreAPITest/assets/shaders/HLSL2GLSLConverter/CS_RWBuff.hlsl delete mode 100644 UnitTests/DiligentCoreAPITest/assets/shaders/HLSL2GLSLConverter/CS_RWTex1D.hlsl delete mode 100644 UnitTests/DiligentCoreAPITest/assets/shaders/HLSL2GLSLConverter/CS_RWTex2D_1.hlsl delete mode 100644 UnitTests/DiligentCoreAPITest/assets/shaders/HLSL2GLSLConverter/CS_RWTex2D_2.hlsl delete mode 100644 UnitTests/DiligentCoreAPITest/assets/shaders/HLSL2GLSLConverter/IncludeTest.h delete mode 100644 UnitTests/DiligentCoreAPITest/assets/shaders/HLSL2GLSLConverter/VS_PS.hlsl delete mode 100644 UnitTests/DiligentCoreAPITest/assets/shaders/ShaderResourceArrayTest.psh delete mode 100644 UnitTests/DiligentCoreAPITest/assets/shaders/ShaderResourceArrayTest.vsh delete mode 100644 UnitTests/DiligentCoreAPITest/assets/shaders/ShaderResourceLayout/ConstantBuffers.hlsl delete mode 100644 UnitTests/DiligentCoreAPITest/assets/shaders/ShaderResourceLayout/FormattedBuffers.hlsl delete mode 100644 UnitTests/DiligentCoreAPITest/assets/shaders/ShaderResourceLayout/RWFormattedBuffers.hlsl delete mode 100644 UnitTests/DiligentCoreAPITest/assets/shaders/ShaderResourceLayout/RWStructuredBuffers.glsl delete mode 100644 UnitTests/DiligentCoreAPITest/assets/shaders/ShaderResourceLayout/RWStructuredBuffers.hlsl delete mode 100644 UnitTests/DiligentCoreAPITest/assets/shaders/ShaderResourceLayout/RWTextures.hlsl delete mode 100644 UnitTests/DiligentCoreAPITest/assets/shaders/ShaderResourceLayout/Samplers.hlsl delete mode 100644 UnitTests/DiligentCoreAPITest/assets/shaders/ShaderResourceLayout/StaticSamplers.hlsl delete mode 100644 UnitTests/DiligentCoreAPITest/assets/shaders/ShaderResourceLayout/StructuredBuffers.glsl delete mode 100644 UnitTests/DiligentCoreAPITest/assets/shaders/ShaderResourceLayout/StructuredBuffers.hlsl delete mode 100644 UnitTests/DiligentCoreAPITest/assets/shaders/ShaderResourceLayout/Textures.hlsl delete mode 100644 UnitTests/DiligentCoreAPITest/assets/shaders/ShaderVariableAccessTestDX.psh delete mode 100644 UnitTests/DiligentCoreAPITest/assets/shaders/ShaderVariableAccessTestDX.vsh delete mode 100644 UnitTests/DiligentCoreAPITest/assets/shaders/ShaderVariableAccessTestGL.psh delete mode 100644 UnitTests/DiligentCoreAPITest/assets/shaders/ShaderVariableAccessTestGL.vsh delete mode 100644 UnitTests/DiligentCoreAPITest/include/CreateObjFromNativeResTestBase.h delete mode 100644 UnitTests/DiligentCoreAPITest/include/D3D11/CreateObjFromNativeResD3D11.h delete mode 100644 UnitTests/DiligentCoreAPITest/include/D3D11/TestingEnvironmentD3D11.h delete mode 100644 UnitTests/DiligentCoreAPITest/include/D3D11/TestingSwapChainD3D11.h delete mode 100644 UnitTests/DiligentCoreAPITest/include/D3D12/CreateObjFromNativeResD3D12.h delete mode 100644 UnitTests/DiligentCoreAPITest/include/D3D12/D3D12DebugLayerSetNameBugWorkaround.h delete mode 100644 UnitTests/DiligentCoreAPITest/include/D3D12/TestingEnvironmentD3D12.h delete mode 100644 UnitTests/DiligentCoreAPITest/include/D3D12/TestingSwapChainD3D12.h delete mode 100644 UnitTests/DiligentCoreAPITest/include/GL/CreateObjFromNativeResGL.h delete mode 100644 UnitTests/DiligentCoreAPITest/include/GL/TestingEnvironmentGL.h delete mode 100644 UnitTests/DiligentCoreAPITest/include/GL/TestingSwapChainGL.h delete mode 100644 UnitTests/DiligentCoreAPITest/include/PSOTestBase.h delete mode 100644 UnitTests/DiligentCoreAPITest/include/TestingEnvironment.h delete mode 100644 UnitTests/DiligentCoreAPITest/include/TestingSwapChainBase.h delete mode 100644 UnitTests/DiligentCoreAPITest/include/Vulkan/CreateObjFromNativeResVK.h delete mode 100644 UnitTests/DiligentCoreAPITest/include/Vulkan/TestingEnvironmentVk.h delete mode 100644 UnitTests/DiligentCoreAPITest/include/Vulkan/TestingSwapChainVk.h delete mode 100644 UnitTests/DiligentCoreAPITest/src/BlendStateTest.cpp delete mode 100644 UnitTests/DiligentCoreAPITest/src/BrokenShaderTest.cpp delete mode 100644 UnitTests/DiligentCoreAPITest/src/BufferCreationTest.cpp delete mode 100644 UnitTests/DiligentCoreAPITest/src/ClearRenderTargetTest.cpp delete mode 100644 UnitTests/DiligentCoreAPITest/src/CopyTextureTest.cpp delete mode 100644 UnitTests/DiligentCoreAPITest/src/D3D11/ClearRenderTargetRefenceD3D11.cpp delete mode 100644 UnitTests/DiligentCoreAPITest/src/D3D11/CreateObjFromNativeResD3D11.cpp delete mode 100644 UnitTests/DiligentCoreAPITest/src/D3D11/DrawCommandRefenceD3D11.cpp delete mode 100644 UnitTests/DiligentCoreAPITest/src/D3D11/TestingEnvironmentD3D11.cpp delete mode 100644 UnitTests/DiligentCoreAPITest/src/D3D11/TestingSwapChainD3D11.cpp delete mode 100644 UnitTests/DiligentCoreAPITest/src/D3D12/ClearRenderTargetRefenceD3D12.cpp delete mode 100644 UnitTests/DiligentCoreAPITest/src/D3D12/CreateObjFromNativeResD3D12.cpp delete mode 100644 UnitTests/DiligentCoreAPITest/src/D3D12/D3D12DebugLayerSetNameBugWorkaround.cpp delete mode 100644 UnitTests/DiligentCoreAPITest/src/D3D12/DrawCommandRefenceD3D12.cpp delete mode 100644 UnitTests/DiligentCoreAPITest/src/D3D12/TestingEnvironmentD3D12.cpp delete mode 100644 UnitTests/DiligentCoreAPITest/src/D3D12/TestingSwapChainD3D12.cpp delete mode 100644 UnitTests/DiligentCoreAPITest/src/DepthStencilStateTest.cpp delete mode 100644 UnitTests/DiligentCoreAPITest/src/DrawCommandTest.cpp delete mode 100644 UnitTests/DiligentCoreAPITest/src/GL/ClearRenderTargetRefenceGL.cpp delete mode 100644 UnitTests/DiligentCoreAPITest/src/GL/CreateObjFromNativeResGL.cpp delete mode 100644 UnitTests/DiligentCoreAPITest/src/GL/DrawCommandRefenceGL.cpp delete mode 100644 UnitTests/DiligentCoreAPITest/src/GL/TestingEnvironmentGL.cpp delete mode 100644 UnitTests/DiligentCoreAPITest/src/GL/TestingSwapChainGL.cpp delete mode 100644 UnitTests/DiligentCoreAPITest/src/GenerateMipsTest.cpp delete mode 100644 UnitTests/DiligentCoreAPITest/src/HLSL2GLSLConverterTest.cpp delete mode 100644 UnitTests/DiligentCoreAPITest/src/MTResourceCreationTest.cpp delete mode 100644 UnitTests/DiligentCoreAPITest/src/PSOCompatibilityTest.cpp delete mode 100644 UnitTests/DiligentCoreAPITest/src/PSOTestBase.cpp delete mode 100644 UnitTests/DiligentCoreAPITest/src/RasterizerStateTest.cpp delete mode 100644 UnitTests/DiligentCoreAPITest/src/SamplerCreationTest.cpp delete mode 100644 UnitTests/DiligentCoreAPITest/src/SeparateTextureSamplerTest.cpp delete mode 100644 UnitTests/DiligentCoreAPITest/src/ShaderResourceArrayTest.cpp delete mode 100644 UnitTests/DiligentCoreAPITest/src/ShaderResourceLayoutTest.cpp delete mode 100644 UnitTests/DiligentCoreAPITest/src/ShaderVariableAccessTest.cpp delete mode 100644 UnitTests/DiligentCoreAPITest/src/TestingEnvironment.cpp delete mode 100644 UnitTests/DiligentCoreAPITest/src/TestingSwapChainBase.cpp delete mode 100644 UnitTests/DiligentCoreAPITest/src/TextureCreationTest.cpp delete mode 100644 UnitTests/DiligentCoreAPITest/src/Vulkan/ClearRenderTargetReferenceVk.cpp delete mode 100644 UnitTests/DiligentCoreAPITest/src/Vulkan/CreateObjFromNativeResVK.cpp delete mode 100644 UnitTests/DiligentCoreAPITest/src/Vulkan/DrawCommandRefenceVk.cpp delete mode 100644 UnitTests/DiligentCoreAPITest/src/Vulkan/TestingEnvironmentVk.cpp delete mode 100644 UnitTests/DiligentCoreAPITest/src/Vulkan/TestingSwapChainVk.cpp delete mode 100644 UnitTests/DiligentCoreAPITest/src/Win32/TestingEnvironmentWin32.cpp delete mode 100644 UnitTests/DiligentCoreAPITest/src/main.cpp delete mode 100644 UnitTests/DiligentCoreTest/CMakeLists.txt delete mode 100644 UnitTests/DiligentCoreTest/src/Common/AllocatorTest.cpp delete mode 100644 UnitTests/DiligentCoreTest/src/Common/MathLibTest.cpp delete mode 100644 UnitTests/DiligentCoreTest/src/Common/RefCntAutoPtrTest.cpp delete mode 100644 UnitTests/DiligentCoreTest/src/Common/StringToolsTest.cpp delete mode 100644 UnitTests/DiligentCoreTest/src/GraphicsAccessories/GraphicsAccessoriesTest.cpp delete mode 100644 UnitTests/DiligentCoreTest/src/GraphicsAccessories/ResourceReleaseQueueTest.cpp delete mode 100644 UnitTests/DiligentCoreTest/src/GraphicsAccessories/RingBufferTest.cpp delete mode 100644 UnitTests/DiligentCoreTest/src/GraphicsAccessories/VariableSizeGPUAllocationsManagerTest.cpp delete mode 100644 UnitTests/DiligentCoreTest/src/Platforms/PlatformMiscTest.cpp delete mode 100644 UnitTests/IncludeTest/CMakeLists.txt delete mode 100644 UnitTests/IncludeTest/Common/AdvancedMathH_test.cpp delete mode 100644 UnitTests/IncludeTest/Common/BasicFileStreamH_test.cpp delete mode 100644 UnitTests/IncludeTest/Common/BasicMathH_test.cpp delete mode 100644 UnitTests/IncludeTest/Common/DataBlobImplH_test.cpp delete mode 100644 UnitTests/IncludeTest/Common/DefaultRawMemoryAllocatorH_test.cpp delete mode 100644 UnitTests/IncludeTest/Common/FileWrapperH_test.cpp delete mode 100644 UnitTests/IncludeTest/Common/FixedBlockMemoryAllocatorH_test.cpp delete mode 100644 UnitTests/IncludeTest/Common/HashUtilsH_test.cpp delete mode 100644 UnitTests/IncludeTest/Common/LockHelperH_test.cpp delete mode 100644 UnitTests/IncludeTest/Common/ObjectBaseH_test.cpp delete mode 100644 UnitTests/IncludeTest/Common/RefCntAutoPtrH_test.cpp delete mode 100644 UnitTests/IncludeTest/Common/RefCountedObjectImplH_test.cpp delete mode 100644 UnitTests/IncludeTest/Common/STDAllocatorH_test.cpp delete mode 100644 UnitTests/IncludeTest/Common/StringDataBlobImplH_test.cpp delete mode 100644 UnitTests/IncludeTest/Common/StringPool_test.cpp delete mode 100644 UnitTests/IncludeTest/Common/StringToolsH_test.cpp delete mode 100644 UnitTests/IncludeTest/Common/ThreadSignalH_test.cpp delete mode 100644 UnitTests/IncludeTest/Common/TimerH_test.cpp delete mode 100644 UnitTests/IncludeTest/Common/UniqueIdentifierH_test.cpp delete mode 100644 UnitTests/IncludeTest/Common/ValidatedCastH_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsAccessories/ColorConversionH_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsAccessories/GraphicsAccessoriesH_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsAccessories/ResourceReleaseQueueH_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsAccessories/RingBufferH_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsAccessories/SRBMemortAllocatorH_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsAccessories/VariableSizeAllocationsManagerH_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsAccessories/VariableSizeGPUAllocationsManagerH_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsEngine/BlendStateH_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsEngine/BufferH_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsEngine/BufferViewH_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsEngine/CommandListH_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsEngine/ConstantsH_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsEngine/DefaultShaderSourceStreamFactoryH_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsEngine/DepthStencilStateH_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsEngine/DeviceCapsH_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsEngine/DeviceContextH_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsEngine/DeviceObjectH_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsEngine/EngineFactoryH_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsEngine/FenceH_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsEngine/GraphicsTypesH_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsEngine/InputLayoutH_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsEngine/MapHelperH_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsEngine/PipelineStateH_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsEngine/RasterizerStateH_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsEngine/RenderDeviceH_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsEngine/ResourceMappingH_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsEngine/SamplerH_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsEngine/ShaderH_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsEngine/ShaderResourceBindingH_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsEngine/ShaderResourceVaraibleH_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsEngine/SwapChainH_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsEngine/TextureH_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsEngine/TextureViewH_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsEngineD3D11/BufferD3D11H_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsEngineD3D11/BufferViewD3D11H_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsEngineD3D11/DeviceContextD3D11H_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsEngineD3D11/EngineFactoryD3D11H_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsEngineD3D11/FenceD3D11H_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsEngineD3D11/PipelineStateD3D11H_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsEngineD3D11/RenderDeviceD3D11H_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsEngineD3D11/SamplerD3D11H_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsEngineD3D11/ShaderD3D11H_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsEngineD3D11/ShaderResourceBindingD3D11H_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsEngineD3D11/SwapChainD3D11H_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsEngineD3D11/TextureD3D11H_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsEngineD3D11/TextureViewD3D11H_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsEngineD3D12/BufferD3D12H_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsEngineD3D12/BufferViewD3D12H_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsEngineD3D12/CommandQueueD3D12H_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsEngineD3D12/DeviceContextD3D12H_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsEngineD3D12/EngineFactoryD3D12H_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsEngineD3D12/FenceD3D12H_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsEngineD3D12/PipelineStateD3D12H_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsEngineD3D12/RenderDeviceD3D12H_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsEngineD3D12/SamplerD3D12H_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsEngineD3D12/ShaderD3D12H_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsEngineD3D12/ShaderResourceBindingD3D12H_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsEngineD3D12/SwapChainD3D12H_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsEngineD3D12/TextureD3D12H_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsEngineD3D12/TextureViewD3D12H_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsEngineD3DBase/ShaderD3DH_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsEngineD3DBase/ShaderResourceVariableD3DH_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsEngineOpenGL/BaseInterfacesGLH_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsEngineOpenGL/BufferGLH_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsEngineOpenGL/BufferViewGLH_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsEngineOpenGL/DeviceContextGLH_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsEngineOpenGL/EngineFactoryOpenGLH_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsEngineOpenGL/FenceGLH_test .cpp delete mode 100644 UnitTests/IncludeTest/GraphicsEngineOpenGL/PipelineStateGLH_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsEngineOpenGL/RenderDeviceGL_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsEngineOpenGL/SamplerGLH_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsEngineOpenGL/ShaderGLH_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsEngineOpenGL/ShaderResourceBindingGLH_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsEngineOpenGL/SwapChainGLH_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsEngineOpenGL/TextureGLH_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsEngineOpenGL/TextureViewGLH_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsEngineVk/BufferViewVkH_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsEngineVk/BufferVkH_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsEngineVk/CommandQueueVkH_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsEngineVk/DeviceContextVkH_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsEngineVk/EngineFactoryVkH_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsEngineVk/FenceVkH_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsEngineVk/PipelineStateVkH_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsEngineVk/RenderDeviceVkH_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsEngineVk/SamplerVkH_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsEngineVk/ShaderResourceBindingVkH_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsEngineVk/ShaderVkH_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsEngineVk/SwapChainVkH_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsEngineVk/TextureViewVkH_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsEngineVk/TextureVkH_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsTools/CommonlyUsedStatesH_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsTools/GraphicsUtilitiesH_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsTools/ShaderMacroHelperH_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsTools/TextureUploaderBaseH_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsTools/TextureUploaderD3D11H_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsTools/TextureUploaderD3D12_VkH_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsTools/TextureUploaderGLH_test.cpp delete mode 100644 UnitTests/IncludeTest/GraphicsTools/TextureUploaderH_test.cpp delete mode 100644 UnitTests/IncludeTest/Platforms/AtomicsH_test.cpp delete mode 100644 UnitTests/IncludeTest/Platforms/FileSystemH_test.cpp delete mode 100644 UnitTests/IncludeTest/Platforms/PlatformDebugH_test.cpp delete mode 100644 UnitTests/IncludeTest/Platforms/PlatformDefinitionsH_test.cpp delete mode 100644 UnitTests/IncludeTest/Platforms/PlatformMiscH_test.cpp diff --git a/BuildTools/FormatValidation/validate_format_win.bat b/BuildTools/FormatValidation/validate_format_win.bat index fad47419..10a0bf5d 100644 --- a/BuildTools/FormatValidation/validate_format_win.bat +++ b/BuildTools/FormatValidation/validate_format_win.bat @@ -1,6 +1,6 @@ python clang-format-validate.py --color never --clang-format-executable clang-format_10.0.0.exe ^ --r ../../Common ../../Graphics ../../Platforms ../../Primitives ../../UnitTests ^ +-r ../../Common ../../Graphics ../../Platforms ../../Primitives ../../Tests ^ --exclude ../../Graphics/HLSL2GLSLConverterLib/include/GLSLDefinitions.h ^ --exclude ../../Graphics/HLSL2GLSLConverterLib/include/GLSLDefinitions_inc.h ^ --exclude ../../Graphics/GraphicsEngineVulkan/shaders/* ^ ---exclude ../../UnitTests/DiligentCoreAPITest/assets/* +--exclude ../../Tests/DiligentCoreAPITest/assets/* diff --git a/CMakeLists.txt b/CMakeLists.txt index def4dff4..605e9828 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -306,7 +306,7 @@ add_subdirectory(Common) add_subdirectory(Graphics) if(DILIGENT_BUILD_TESTS) - add_subdirectory(UnitTests) + add_subdirectory(Tests) endif() diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt new file mode 100644 index 00000000..4a867e45 --- /dev/null +++ b/Tests/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required (VERSION 3.6) + +if(TARGET gtest) + add_subdirectory(DiligentCoreTest) + add_subdirectory(DiligentCoreAPITest) +endif() +add_subdirectory(IncludeTest) diff --git a/Tests/DiligentCoreAPITest/CMakeLists.txt b/Tests/DiligentCoreAPITest/CMakeLists.txt new file mode 100644 index 00000000..f0c2673c --- /dev/null +++ b/Tests/DiligentCoreAPITest/CMakeLists.txt @@ -0,0 +1,130 @@ +cmake_minimum_required (VERSION 3.6) + +project(DiligentCoreAPITest) + +file(GLOB COMMON_SOURCE LIST_DIRECTORIES false src/*) +file(GLOB COMMON_INCLUDE LIST_DIRECTORIES false include/*) +file(GLOB_RECURSE SHADERS LIST_DIRECTORIES false assets/shaders/*.*) + +set_source_files_properties(${SHADERS} PROPERTIES VS_TOOL_OVERRIDE "None") + +set(SOURCE ${COMMON_SOURCE}) +set(INCLUDE ${COMMON_INCLUDE}) + +if(NOT GL_SUPPORTED AND NOT GLES_SUPPORTED) + list(REMOVE_ITEM SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/src/HLSL2GLSLConverterTest.cpp) + list(REMOVE_ITEM SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/src/CreateObjFromNativeResGL.cpp) + + list(REMOVE_ITEM INCLUDE ${CMAKE_CURRENT_SOURCE_DIR}/include/CreateObjFromNativeResGL.h) +endif() + +if(NOT D3D11_SUPPORTED) + list(REMOVE_ITEM SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/src/CreateObjFromNativeResD3D11.cpp) + list(REMOVE_ITEM INCLUDE ${CMAKE_CURRENT_SOURCE_DIR}/include/CreateObjFromNativeResD3D11.h) +endif() + +if(NOT D3D12_SUPPORTED) + list(REMOVE_ITEM SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/src/CreateObjFromNativeResD3D12.cpp) + list(REMOVE_ITEM INCLUDE ${CMAKE_CURRENT_SOURCE_DIR}/include/CreateObjFromNativeResD3D12.h) +endif() + +if(NOT VULKAN_SUPPORTED) + list(REMOVE_ITEM SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/src/CreateObjFromNativeResVK.cpp) + list(REMOVE_ITEM INCLUDE ${CMAKE_CURRENT_SOURCE_DIR}/include/CreateObjFromNativeResVK.h) +endif() + +if(PLATFORM_WIN32) + file(GLOB SOURCE_WIN32 LIST_DIRECTORIES false src/Win32/*) + list(APPEND SOURCE ${SOURCE_WIN32}) +endif() + +if(D3D11_SUPPORTED) + file(GLOB D3D11_SOURCE LIST_DIRECTORIES false src/D3D11/*) + file(GLOB D3D11_INCLUDE LIST_DIRECTORIES false include/D3D11/*) + list(APPEND INCLUDE ${D3D11_INCLUDE}) + list(APPEND SOURCE ${D3D11_SOURCE}) +endif() + +if(D3D12_SUPPORTED) + file(GLOB D3D12_SOURCE LIST_DIRECTORIES false src/D3D12/*) + file(GLOB D3D12_INCLUDE LIST_DIRECTORIES false include/D3D12/*) + list(APPEND INCLUDE ${D3D12_INCLUDE}) + list(APPEND SOURCE ${D3D12_SOURCE}) +endif() + +if(VULKAN_SUPPORTED) + file(GLOB VK_SOURCE LIST_DIRECTORIES false src/Vulkan/*) + file(GLOB VK_INCLUDE LIST_DIRECTORIES false include/Vulkan/*) + list(APPEND INCLUDE ${VK_INCLUDE}) + list(APPEND SOURCE ${VK_SOURCE}) +endif() + +if(GL_SUPPORTED OR GLES_SUPPORTED) + file(GLOB GL_SOURCE LIST_DIRECTORIES false src/GL/*) + file(GLOB GL_INCLUDE LIST_DIRECTORIES false include/GL/*) + list(APPEND INCLUDE ${GL_INCLUDE}) + list(APPEND SOURCE ${GL_SOURCE}) +endif() + +add_executable(DiligentCoreAPITest ${SOURCE} ${INCLUDE} ${SHADERS}) +set_common_target_properties(DiligentCoreAPITest) + +get_supported_backends(ENGINE_LIBRARIES) + +target_link_libraries(DiligentCoreAPITest +PRIVATE + gtest + Diligent-BuildSettings + Diligent-TargetPlatform + Diligent-GraphicsAccessories + Diligent-Common + Diligent-GraphicsTools + ${ENGINE_LIBRARIES} +) + +if(D3D11_SUPPORTED OR D3D12_SUPPORTED) + target_link_libraries(DiligentCoreAPITest PRIVATE d3dcompiler.lib) +endif() + +if(GL_SUPPORTED OR GLES_SUPPORTED) + target_link_libraries(DiligentCoreAPITest PRIVATE Diligent-HLSL2GLSLConverterLib) + + if(PLATFORM_WIN32) + target_link_libraries(DiligentCoreAPITest PRIVATE glew-static opengl32.lib) + elseif(PLATFORM_LINUX) + target_link_libraries(DiligentCoreAPITest PRIVATE glew-static) + elseif(PLATFORM_MACOS) + find_package(OpenGL REQUIRED) + target_link_libraries(DiligentCoreAPITest PRIVATE glew-static ${OPENGL_LIBRARY}) + else() + message(FATAL_ERROR "Unsupported platform") + endif() + +endif() + +if(VULKAN_SUPPORTED) + target_link_libraries(DiligentCoreAPITest PRIVATE Diligent-GLSLTools) + target_include_directories(DiligentCoreAPITest PRIVATE ../../ThirdParty) +endif() + +target_include_directories(DiligentCoreAPITest +PRIVATE + include +) + + +set_target_properties(DiligentCoreAPITest +PROPERTIES + VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/assets" +) + +if(PLATFORM_WIN32) + copy_required_dlls(DiligentCoreAPITest) +endif() + + +source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${SOURCE} ${INCLUDE} ${SHADERS}) + +set_target_properties(DiligentCoreAPITest PROPERTIES + FOLDER "DiligentCore/Tests" +) diff --git a/Tests/DiligentCoreAPITest/assets/shaders/HLSL2GLSLConverter/CS_RWBuff.hlsl b/Tests/DiligentCoreAPITest/assets/shaders/HLSL2GLSLConverter/CS_RWBuff.hlsl new file mode 100644 index 00000000..fdfdb2ec --- /dev/null +++ b/Tests/DiligentCoreAPITest/assets/shaders/HLSL2GLSLConverter/CS_RWBuff.hlsl @@ -0,0 +1,81 @@ +RWBuffer TexBuff_F; +RWBuffer TexBuff_I; +RWBuffer TexBuff_U; + +struct StorageBufferStruct +{ + float4 Data; +}; + +RWStructuredBuffer RWStructBuff0; +RWStructuredBuffer RWStructBuff1; +RWStructuredBuffer RWStructBuff2; + +void TestGetDimensions() +{ + //RWBuffer + { + uint uWidth; + int iWidth; + float fWidth; + TexBuff_F.GetDimensions(uWidth); + //TexBuff_I.GetDimensions(iWidth); + //TexBuff_U.GetDimensions(fWidth); + } +} + + +void TestLoad() +{ + int4 Location = int4(2, 5, 1, 10); + + //Buffer + { + TexBuff_F.Load(Location.x); + TexBuff_I.Load(Location.x); + TexBuff_U.Load(Location.x); + } + StorageBufferStruct Data0 = RWStructBuff0[Location.x]; + StorageBufferStruct Data1 = RWStructBuff1[Location.y]; + StorageBufferStruct Data3 = RWStructBuff2[Location.w]; +} + + + +void TestStore() +{ + int4 Location = int4(2, 5, 1, 10); + + //Buffer + { + TexBuff_F[Location.x] = 1.0; + TexBuff_I[Location.x] = int2(1,2); + TexBuff_U[Location.x] = uint4(1,2,3,4); + } + StorageBufferStruct Data0; + Data0.Data = float4(0.0, 1.0, 2.0, 3.0); + RWStructBuff0[Location.x] = Data0; + RWStructBuff1[Location.z] = Data0; + RWStructBuff2[Location.w] = Data0; + +} + +struct CSInputSubstr +{ + uint3 DTid : SV_DispatchThreadID; +}; +struct CSInput +{ + uint GroupInd : SV_GroupIndex; + CSInputSubstr substr; +}; + +[numthreads(2,4,8)] +void TestCS(CSInput In, + uint3 Gid : SV_GroupID, + uint3 GTid : SV_GroupThreadID) +{ + TestGetDimensions(); + TestLoad(); + TestStore(); +} diff --git a/Tests/DiligentCoreAPITest/assets/shaders/HLSL2GLSLConverter/CS_RWTex1D.hlsl b/Tests/DiligentCoreAPITest/assets/shaders/HLSL2GLSLConverter/CS_RWTex1D.hlsl new file mode 100644 index 00000000..306ec599 --- /dev/null +++ b/Tests/DiligentCoreAPITest/assets/shaders/HLSL2GLSLConverter/CS_RWTex1D.hlsl @@ -0,0 +1,134 @@ +#include "IncludeTest.h" +// # include <- fix commented include + + +//#define TEXTURE2D Texture2D <- Macros do not work currently +//TEXTURE2D MacroTex2D; + +/******//* /* /**** / */ +void EmptyFunc(){}cbuffer cbTest1{int a;}cbuffer cbTest2{int b;}/*comment +test + +*/cbuffer cbTest3{int c;}//Single line comment +cbuffer cbTest4{int d;} + +cbuffer cbTest5 +{ + float4 e; +} + +cbuffer cbTest6 +{ + float4 f; +}; + +int cbuffer_fake; +int fakecbuffer; + +RWTexture1DTex1D_F1; +RWTexture1DTex1D_I; +RWTexture1DTex1D_U; + +RWTexture1DArray Tex1D_F_A; +RWTexture1DArray Tex1D_I_A; +RWTexture1DArray Tex1D_U_A; + +void TestGetDimensions() +{ + // RWTexture1D + { + uint uWidth; + float fWidth; + int iWidth; + Tex1D_F1.GetDimensions(uWidth); + Tex1D_I.GetDimensions( uWidth); + Tex1D_U.GetDimensions( uWidth ); + + Tex1D_F1.GetDimensions(fWidth); + Tex1D_I.GetDimensions( fWidth); + Tex1D_U.GetDimensions( fWidth ); + + Tex1D_F1.GetDimensions(iWidth); + Tex1D_I.GetDimensions( iWidth); + Tex1D_U.GetDimensions( iWidth ); + } + + // RWTexture1DArray + { + uint uWidth, uElems; + int iWidth, iElems; + float fWidth, fElems; + Tex1D_F_A.GetDimensions(uWidth, uElems); + Tex1D_U_A.GetDimensions( uWidth, uElems); + Tex1D_I_A.GetDimensions( uWidth , uElems ); + + Tex1D_F_A.GetDimensions(iWidth, iElems); + Tex1D_U_A.GetDimensions( iWidth, iElems); + Tex1D_I_A.GetDimensions( iWidth , iElems ); + + Tex1D_F_A.GetDimensions(fWidth, fElems); + Tex1D_U_A.GetDimensions( fWidth, fElems); + Tex1D_I_A.GetDimensions( fWidth , fElems ); + } +} + +void TestLoad() +{ + int4 Location = int4(2, 5, 1, 10); + + // Texture1D + { + float f = Tex1D_F1.Load(Location.x); + int2 i2 = Tex1D_I.Load(Location.x).xy; + uint4 u4 = Tex1D_U.Load(Location.x); + } + + // Texture1DArray + { + float f = Tex1D_F_A.Load(Location.xy); + uint4 u4 = Tex1D_U_A.Load(Location.xy); + int2 i2 = Tex1D_I_A.Load(Location.xy); + } +} + + + +void TestStore() +{ + int4 Location = int4(2, 5, 1, 10); + + // Texture1D + { + Tex1D_F1[Location.x] = 1.0; + Tex1D_I[ Location.x] = int2(3,6); + Tex1D_U[ Location.x ] = uint4(0,4,7,8); + } + + // Texture1DArray + { + Tex1D_F_A[Location.xy] = 3.5; + Tex1D_U_A[ Location.xy] = uint4(2,4,2,5); + Tex1D_I_A[Location.xy ] = int2( 13, 19); + } +} + +struct CSInputSubstr +{ + uint3 DTid : SV_DispatchThreadID; +}; + +struct CSInput +{ + uint GroupInd : SV_GroupIndex; + CSInputSubstr substr; +}; + +[numthreads(2,4,8)] +void TestCS(CSInput In, + uint3 Gid : SV_GroupID, + uint3 GTid : SV_GroupThreadID) +{ + TestGetDimensions(); + TestLoad(); + TestStore(); +} diff --git a/Tests/DiligentCoreAPITest/assets/shaders/HLSL2GLSLConverter/CS_RWTex2D_1.hlsl b/Tests/DiligentCoreAPITest/assets/shaders/HLSL2GLSLConverter/CS_RWTex2D_1.hlsl new file mode 100644 index 00000000..a60f8413 --- /dev/null +++ b/Tests/DiligentCoreAPITest/assets/shaders/HLSL2GLSLConverter/CS_RWTex2D_1.hlsl @@ -0,0 +1,216 @@ +#include "IncludeTest.h" +// # include <- fix commented include + + +//#define TEXTURE2D Texture2D <- Macros do not work currently +//TEXTURE2D MacroTex2D; + +/******//* /* /**** / */ +void EmptyFunc(){}cbuffer cbTest1{int a;}cbuffer cbTest2{int b;}/*comment +test + +*/cbuffer cbTest3{int c;}//Single line comment +cbuffer cbTest4{int d;} + +cbuffer cbTest5 +{ + float4 e; +} + +cbuffer cbTest6 +{ + float4 f; +}; + +int cbuffer_fake; +int fakecbuffer; + +RWTexture2DTex2D_F1; +RWTexture2DTex2D_F2[2],Tex2D_F3,/*cmt*/Tex2D_F4, Tex2D_F5; +RWTexture2DTex2D_I; +RWTexture2DTex2D_U; + + +int GlobalIntVar;Texture2D Tex2D_Test1;Texture2D Tex2D_Test2;/*Comment* / *//* /** Comment2*/Texture2D Tex2D_Test3 /*Cmnt*/, +// Comment +Tex2D_Test4 +; + +Texture2D Tex2D_M1, Tex2D_M2; + +groupshared float4 g_f4TestSharedArr[10]; +groupshared int4 g_i4TestSharedArr[10]; +groupshared uint4 g_u4TestSharedArr[10]; +groupshared float4 g_f4TestSharedVar; +groupshared int4 g_i4TestSharedVar; +groupshared uint4 g_u4TestSharedVar; + + +void TestGetDimensions() +{ + //RWTexture2D + { + uint uWidth, uHeight; + int iWidth, iHeight; + float fWidth, fHeight; + Tex2D_F1.GetDimensions(uWidth, uHeight); + Tex2D_F3.GetDimensions(uWidth, uHeight); + Tex2D_F4.GetDimensions(uWidth, uHeight); + Tex2D_F2[0].GetDimensions( uWidth, uHeight); + Tex2D_I.GetDimensions (uWidth, uHeight ); + Tex2D_U.GetDimensions ( uWidth, uHeight ); + + Tex2D_F1.GetDimensions(iWidth, iHeight); + Tex2D_F2[0].GetDimensions( iWidth, iHeight); + Tex2D_I.GetDimensions (iWidth, iHeight ); + Tex2D_U.GetDimensions ( iWidth, iHeight ); + + Tex2D_F1.GetDimensions(fWidth, fHeight); + Tex2D_F2[0].GetDimensions( fWidth, fHeight); + Tex2D_I.GetDimensions (fWidth, fHeight ); + Tex2D_U.GetDimensions ( fWidth, fHeight ); + } +} + + +void TestLoad() +{ + int4 Location = int4(2, 5, 1, 10); + + //Texture2D + { + float f = Tex2D_F1.Load(Location.xy); + f = Tex2D_F1.Load(Tex2D_I.Load(Location.xy) + Tex2D_I.Load(Location.xy).yx); + int2 i2 = Tex2D_I.Load(Location.xy); + uint4 u4= Tex2D_U.Load(Location.xy).xyzw; + } + +} + + + +void TestStore() +{ + int4 Location = int4(2, 5, 1, 10); + + //Texture2D + { + Tex2D_F1[Location.xy] = 10.0; + Tex2D_F1[Tex2D_I.Load(Location.xy).xy + Tex2D_I.Load(Location.xy).xy] = 20.0; + Tex2D_I[Location.xy] = int2( 43, 23); + Tex2D_U[Location.xy] = uint4( 3,7,1,7); + } +} + + +/* +void TestImageArgs1(RWTexture2D in_RWTex, int2 Location) +{ + int Width, Height; + in_RWTex.GetDimensions (Width, Height ); + in_RWTex[Location] = Width; + InterlockedAdd(in_RWTex[Location], 3); + int i = in_RWTex.Load(Location.xy); +} + +void TestImageArgs2(RWTexture3D in_RWTex) +{ + int Width, Height, Depth; + in_RWTex.GetDimensions (Width, Height, Depth ); + float f = in_RWTex.Load(int3(10,11,23)); + in_RWTex[int3(1,2,3)] = float4(10.0, 25.0, 26.0, 27.0); +} +*/ + + + +int2 GetCoords( uint x, uint y ) +{ + return int2(x, y); +} + +struct CSInputSubstr +{ + uint3 DTid : SV_DispatchThreadID; +}; +struct CSInput +{ + uint GroupInd : SV_GroupIndex; + CSInputSubstr substr; +}; + +[numthreads(2,4,8)] +void TestCS(CSInput In, + uint3 Gid : SV_GroupID, + uint3 GTid : SV_GroupThreadID) +{ + TestGetDimensions(); + TestLoad(); + TestStore(); + + uint uOldVal; + int iOldVal; + + if( GTid.y == 0u ) + { + g_i4TestSharedVar = int4(0, 0, 0, 0); + g_u4TestSharedVar = uint4(0u, 0u, 0u, 0u); + } + g_i4TestSharedArr[In.GroupInd] = int4(0, 0, 0, 0); + g_u4TestSharedArr[In.GroupInd] = uint4(0u, 0u, 0u, 0u); + + InterlockedAdd(g_i4TestSharedVar.x, 1); + InterlockedAdd(g_u4TestSharedVar.x, 1u); + InterlockedAdd(g_i4TestSharedArr[GTid.x].x, 1, iOldVal); + InterlockedAdd(g_u4TestSharedArr[Gid.x].x, 1u, uOldVal); + + InterlockedAnd(g_i4TestSharedVar.x, 1); + InterlockedAnd(g_u4TestSharedVar.x, 1u); + InterlockedAnd(g_i4TestSharedArr[GTid.x].x, 1, iOldVal); + InterlockedAnd(g_u4TestSharedArr[Gid.x].x, 1u, uOldVal); + + InterlockedOr(g_i4TestSharedVar.x, 1); + InterlockedOr(g_u4TestSharedVar.x, 1u); + InterlockedOr(g_i4TestSharedArr[GTid.x].x, 1, iOldVal); + InterlockedOr(g_u4TestSharedArr[Gid.x].x, 1u, uOldVal); + + InterlockedXor(g_i4TestSharedVar.x, 1); + InterlockedXor(g_u4TestSharedVar.x, 1u); + InterlockedXor(g_i4TestSharedArr[GTid.x].x, 1, iOldVal); + InterlockedXor(g_u4TestSharedArr[Gid.x].x, 1u, uOldVal); + + InterlockedMax(g_i4TestSharedVar.x, 1); + InterlockedMax(g_u4TestSharedVar.x, 1u); + InterlockedMax(g_i4TestSharedArr[GTid.x].x, 1, iOldVal); + InterlockedMax(g_u4TestSharedArr[Gid.x].x, 1u, uOldVal); + + InterlockedMin(g_i4TestSharedVar.x, 1); + InterlockedMin(g_u4TestSharedVar.x, 1u); + InterlockedMin(g_i4TestSharedArr[GTid.x].x, 1, iOldVal); + InterlockedMin(g_u4TestSharedArr[Gid.x].x, 1u, uOldVal); + + // There is actually no InterlockedExchange() with 2 arguments + //InterlockedExchange(g_i4TestSharedVar.x, 1); + //InterlockedExchange(g_u4TestSharedVar.x, 1u); + InterlockedExchange(g_i4TestSharedArr[GTid.x].x, 1, iOldVal); + InterlockedExchange(g_u4TestSharedArr[Gid.x].x, 1u, uOldVal); + + InterlockedCompareStore(g_i4TestSharedVar.x, 1, 10); + InterlockedCompareStore(g_u4TestSharedVar.x, 1u, 10u); + InterlockedCompareExchange(g_i4TestSharedArr[GTid.x].x, 1, 10, iOldVal); + InterlockedCompareExchange(g_u4TestSharedArr[Gid.x].x, 1u, 10u, uOldVal); + + //uint2 ui2Dim; + //g_tex2DTestUAV.GetDimensions(ui2Dim.x, ui2Dim.y); + //if( DTid.x >= ui2Dim.x || DTid.y >= ui2Dim.y )return; + + //float2 f2UV = float2(DTid.xy) / float2(ui2Dim); + //float DistFromCenter = length(f2UV - float2(0.5,0.5)); + //g_tex2DTestUAV[DTid.xy] = float4((1-DistFromCenter), abs(f2UV.x-0.5), abs(0.5-f2UV.y), 0); + GroupMemoryBarrier(); + GroupMemoryBarrierWithGroupSync(); + DeviceMemoryBarrier(); + DeviceMemoryBarrierWithGroupSync(); + AllMemoryBarrier(); + //AllMemoryBarrierWithGroupSync(); +} diff --git a/Tests/DiligentCoreAPITest/assets/shaders/HLSL2GLSLConverter/CS_RWTex2D_2.hlsl b/Tests/DiligentCoreAPITest/assets/shaders/HLSL2GLSLConverter/CS_RWTex2D_2.hlsl new file mode 100644 index 00000000..bfaa4050 --- /dev/null +++ b/Tests/DiligentCoreAPITest/assets/shaders/HLSL2GLSLConverter/CS_RWTex2D_2.hlsl @@ -0,0 +1,123 @@ +RWTexture2DTex2D_I1; +RWTexture2DTex2D_U1; + +RWTexture2DArray Tex2D_F_A; +RWTexture2DArray Tex2D_I_A; +RWTexture2DArray Tex2D_U_A; + +RWTexture3D< float4/* +format += +rgba32f +*/> Tex3D_F; +RWTexture3D< int /* format = r8i */> Tex3D_I; +RWTexture3D< uint2 /* format = rg8ui */> Tex3D_U; + +void TestGetDimensions() +{ + //RWTexture2DArray + { + uint uWidth, uHeight, uElems; + float fWidth, fHeight, fElems; + int iWidth, iHeight, iElems; + Tex2D_F_A.GetDimensions(uWidth,uHeight,uElems); + Tex2D_U_A.GetDimensions( uWidth, uHeight, uElems ); + Tex2D_I_A.GetDimensions (uWidth , uHeight , uElems ) ; + + Tex2D_F_A.GetDimensions(iWidth,iHeight,iElems); + Tex2D_U_A.GetDimensions( iWidth, iHeight, iElems ); + Tex2D_I_A.GetDimensions (iWidth , iHeight , iElems ) ; + + Tex2D_F_A.GetDimensions(fWidth,fHeight,fElems); + Tex2D_U_A.GetDimensions( fWidth, fHeight, fElems ); + Tex2D_I_A.GetDimensions (fWidth , fHeight , fElems ) ; + } + + //RWTexture3D + { + uint uWidth, uHeight, uDepth; + int iWidth, iHeight, iDepth; + float fWidth, fHeight, fDepth; + Tex3D_F.GetDimensions ( uWidth, uHeight, uDepth ); + Tex3D_U.GetDimensions(uWidth,uHeight,uDepth); + Tex3D_I.GetDimensions ( uWidth , uHeight , uDepth ); + + Tex3D_F.GetDimensions ( iWidth, iHeight, iDepth ); + Tex3D_U.GetDimensions(iWidth,iHeight,iDepth); + Tex3D_I.GetDimensions ( iWidth , iHeight , iDepth ); + + Tex3D_F.GetDimensions ( fWidth, fHeight, fDepth ); + Tex3D_U.GetDimensions(fWidth,fHeight,fDepth); + Tex3D_I.GetDimensions ( fWidth , fHeight , fDepth ); + } +} + + +void TestLoad() +{ + int4 Location = int4(2, 5, 1, 10); + + //Texture2DArray + { + float f = Tex2D_F_A.Load(Location.xyz); + uint4 u4 = Tex2D_U_A.Load(Location.xyz); + int2 i2 = Tex2D_I_A.Load(Location.xyz); + } + + //Texture3D + { + float4 f4 = Tex3D_F.Load(Location.xyz).xyzw; + uint2 u2 = Tex3D_U.Load(Location.xyz).xy; + int i = Tex3D_I.Load(Location.xyz); + } +} + + + +void TestStore() +{ + int4 Location = int4(2, 5, 1, 10); + + //Texture2DArray + { + Tex2D_F_A[Location.xyz] = 30.0; + Tex2D_U_A[Location.xyz] = uint4(0,5,7,87); + Tex2D_I_A[Location.xyz] = int2(-3, 5); + } + + //Texture3D + { + Tex3D_F[Location.xyz] = float4(10.0, 25.0, 26.0, 27.0); + Tex3D_U[Location.xyz] = uint2(0,6); + Tex3D_I[Location.xyz] = -5; + } +} + + +int2 GetCoords( uint x, uint y ) +{ + return int2(x, y); +} + +struct CSInputSubstr +{ + uint3 DTid : SV_DispatchThreadID; +}; +struct CSInput +{ + uint GroupInd : SV_GroupIndex; + CSInputSubstr substr; +}; + +[numthreads(2,4,8)] +void TestCS(CSInput In, + uint3 Gid : SV_GroupID, + uint3 GTid : SV_GroupThreadID) +{ + TestGetDimensions(); + TestLoad(); + TestStore(); +} diff --git a/Tests/DiligentCoreAPITest/assets/shaders/HLSL2GLSLConverter/IncludeTest.h b/Tests/DiligentCoreAPITest/assets/shaders/HLSL2GLSLConverter/IncludeTest.h new file mode 100644 index 00000000..dd6128d5 --- /dev/null +++ b/Tests/DiligentCoreAPITest/assets/shaders/HLSL2GLSLConverter/IncludeTest.h @@ -0,0 +1,12 @@ +#ifndef _INCLUDE_TEST_FXH_ +#define _INCLUDE_TEST_FXH_ + +#define PI (3.1415928f) + +struct SomeStruct +{ + float a; + int b; +}; + +#endif //_INCLUDE_TEST_FXH_ diff --git a/Tests/DiligentCoreAPITest/assets/shaders/HLSL2GLSLConverter/VS_PS.hlsl b/Tests/DiligentCoreAPITest/assets/shaders/HLSL2GLSLConverter/VS_PS.hlsl new file mode 100644 index 00000000..7560231d --- /dev/null +++ b/Tests/DiligentCoreAPITest/assets/shaders/HLSL2GLSLConverter/VS_PS.hlsl @@ -0,0 +1,1283 @@ +#if defined(GL_ES) && (__VERSION__<=300) +# define GLES30 1 +#else +# define GLES30 0 +#endif + +/***//* Some comment * ** * * * / ** //// */ //Another comment +// +// Comment + +/* More *//*com*///ments/**/ +// +// + + +# include /*Comment*/ +// #include "NonExistingFile.h" + + +//#define TEXTURE2D Texture2D <- Macros do not work currently +//TEXTURE2D MacroTex2D; + +/******//* /* /**** / */ +void EmptyFunc(){}cbuffer cbTest1{int a;}cbuffer cbTest2{int b;}/*comment +test + +**/cbuffer cbTest3{int c;}//Single line comment +cbuffer cbTest4{int d;} + +cbuffer cbTest5 +{ + float4 e; +} + +cbuffer cbTest6 +{ + float4 f; +}; + +int cbuffer_fake; +int fakecbuffer; + +int GlobalIntVar;Texture2D Tex2D_Test1;Texture2D Tex2D_Test2;/*Comment* / *//* /** Comment2**/Texture2D Tex2D_Test3; + +Texture2D Tex2D_M1, Tex2D_M2; + +// Test texture declaration + +#ifndef GL_ES + +Texture1D Tex1D_F1; +Texture1DTex1D_F2; +Texture1DTex1D_I; +Texture1DTex1D_U; + +SamplerState Tex1D_F1_sampler; + +Texture1DArray Tex1D_F_A1; +Texture1DArray Tex1D_F_A2; +Texture1DArray Tex1D_I_A; +Texture1DArray Tex1D_U_A; + +SamplerState Tex1D_F_A1_sampler; + +Texture1D Tex1DS1; +Texture1DTex1DS2,Tex1DS3; +SamplerComparisonState Tex1DS1_sampler, Tex1DS2_sampler, TestCmpSamplerArr[2], Tex1DS3_sampler; + +Texture1DArray Tex1DAS1; +SamplerComparisonState Tex1DAS1_sampler, Tex1DAS2_sampler; +Texture1DArrayTex1DAS2; + +#endif + +Texture2D Tex2D_F1; +Texture2DTex2D_F3[2],Tex2D_F2,Tex2DS_F4,Tex2DS_F5; +Texture2DTex2D_F6; +Texture2DTex2D_I; +Texture2DTex2D_U; + +SamplerState Tex2D_F1_sampler,Tex2D_F6_sampler; +SamplerComparisonState DummySampler, Tex2DS_F4_sampler,Tex2DS_F5_sampler; + +Texture2DArray Tex2D_F_A1; +Texture2DArray Tex2D_F_A2; +Texture2DArray Tex2D_F_A3; +Texture2DArray Tex2D_I_A; +Texture2DArray Tex2D_U_A; + +SamplerState Tex2D_F_A1_sampler,Tex2D_F_A3_sampler; + +#if !GLES30 +Texture2DMS < float2 > Tex2DMS_F1; +Texture2DMS < float, 4 > Tex2DMS_F2; +Texture2DMS < int > Tex2DMS_I; +Texture2DMS < uint > Tex2DMS_U; +#endif + +#ifndef GL_ES +Texture2DMSArray < float3 > Tex2DMS_F_A1; +Texture2DMSArray < float, 4> Tex2DMS_F_A2; +Texture2DMSArray < int2 > Tex2DMS_I_A; +Texture2DMSArray < uint4 > Tex2DMS_U_A; +#endif + +Texture3D Tex3D_F1; +Texture3D< float4 > Tex3D_F2; +Texture3D< float > Tex3D_F3; +Texture3D< int > Tex3D_I; +Texture3D< uint2 > Tex3D_U; + +SamplerState Tex3D_F1_sampler; + +TextureCube TexC_F1; +TextureCube TexC_F2; +TextureCube TexC_I; +TextureCube TexC_U; + +SamplerState TexC_F1_sampler; + +#ifndef GL_ES +TextureCubeArray TexC_F_A1; +TextureCubeArray TexC_F_A2; +TextureCubeArray TexC_I_A; +TextureCubeArray TexC_U_A; + +SamplerState TexC_F_A1_sampler; +#endif + +Texture2D Tex2DS1; +SamplerComparisonState Tex2DS1_sampler; +Texture2DTex2DS2; +SamplerComparisonState Tex2DS2_sampler; + +Texture2DArray Tex2DAS1; +SamplerComparisonState Tex2DAS1_sampler; +Texture2DArrayTex2DAS2; +SamplerComparisonState Tex2DAS2_sampler; + +TextureCube TexCS1; +SamplerComparisonState TexCS1_sampler; +TextureCube< float > TexCS2; +SamplerComparisonState TexCS2_sampler; + +#ifndef GL_ES +TextureCubeArray TexCAS1; +SamplerComparisonState TexCAS1_sampler; +TextureCubeArray TexCAS2; +SamplerComparisonState TexCAS2_sampler; +#endif + +Buffer TexBuffer_F1; +BufferTexBuffer_F4; +BufferTexBuffer_I; +BufferTexBuffer_U; + +int intvar1;SamplerState Dummy;int intvar2; + +int Texture2D_fake, Texture2DArray_fake, fakeTexture2D, fakeTexture2DArray; +int Texture2DMS_fake; +int fakeTexture2DMS; +int Texture2DMSArray_fake; +int fakeTexture2DMSArray; +int Texture3D_fake; +int fakeTexture3D; +int TextureCube_fake, TextureCubeArray_fake; +int fakeTextureCube, fakeTextureCubeArray; +int SamplerState_fake; +int SamplerComparisonState_fake; +int fakeSamplerState; +int fakeSamplerComparisonState; +int Texture4D; +int Texture2d; +int TextureCub; +int Texture2DArr; +int Texture2DM; +int Texture2DMSArr; + +void TestGetDimensions() +{ +#ifndef GL_ES + // Texture1D + { + uint uWidth, uMipLevels; + int iWidth, iMipLevels; + float fWidth, fMipLevels; + Tex1D_F1.GetDimensions(uWidth); + Tex1D_F1.GetDimensions(0, uWidth, uMipLevels); + Tex1D_I.GetDimensions(uWidth); + Tex1D_I.GetDimensions(0, uWidth, uMipLevels); + Tex1D_U.GetDimensions(uWidth); + Tex1D_U.GetDimensions(0, uWidth, uMipLevels); + Tex1DS1.GetDimensions(uWidth); + Tex1DS1.GetDimensions(0, uWidth, uMipLevels); + + Tex1D_F1.GetDimensions(fWidth); + Tex1D_F1.GetDimensions(0, fWidth, fMipLevels); + Tex1D_I.GetDimensions(fWidth); + Tex1D_I.GetDimensions(0, fWidth, fMipLevels); + Tex1D_U.GetDimensions(fWidth); + Tex1D_U.GetDimensions(0, fWidth, fMipLevels); + Tex1DS1.GetDimensions(fWidth); + Tex1DS1.GetDimensions(0, fWidth, fMipLevels); + + Tex1D_F1.GetDimensions(iWidth); + Tex1D_F1.GetDimensions(0, iWidth, iMipLevels); + Tex1D_I.GetDimensions(iWidth); + Tex1D_I.GetDimensions(0, iWidth, iMipLevels); + Tex1D_U.GetDimensions(iWidth); + Tex1D_U.GetDimensions(0, iWidth, iMipLevels); + Tex1DS1.GetDimensions(iWidth); + Tex1DS1.GetDimensions(0, iWidth, iMipLevels); + } + + // Texture1DArray + { + uint uWidth, uMipLevels, uElems; + float fWidth, fMipLevels, fElems; + int iWidth, iMipLevels, iElems; + + Tex1D_F_A1.GetDimensions(0, uWidth, uElems, uMipLevels); + Tex1D_F_A1.GetDimensions(uWidth, uElems); + Tex1D_U_A.GetDimensions(0, uWidth, uElems, uMipLevels); + Tex1D_U_A.GetDimensions(uWidth, uElems); + Tex1D_I_A.GetDimensions(0, uWidth, uElems, uMipLevels); + Tex1D_I_A.GetDimensions(uWidth, uElems); + Tex1DAS1.GetDimensions(0, uWidth, uElems, uMipLevels); + Tex1DAS1.GetDimensions(uWidth, uElems); + + Tex1D_F_A1.GetDimensions(0, iWidth, iElems, iMipLevels); + Tex1D_F_A1.GetDimensions(iWidth, iElems); + Tex1D_U_A.GetDimensions(0, iWidth, iElems, iMipLevels); + Tex1D_U_A.GetDimensions(iWidth, iElems); + Tex1D_I_A.GetDimensions(0, iWidth, iElems, iMipLevels); + Tex1D_I_A.GetDimensions(iWidth, iElems); + Tex1DAS1.GetDimensions(0, iWidth, iElems, iMipLevels); + Tex1DAS1.GetDimensions(iWidth, iElems); + + Tex1D_F_A1.GetDimensions(0, fWidth, fElems, fMipLevels); + Tex1D_F_A1.GetDimensions(fWidth, fElems); + Tex1D_U_A.GetDimensions(0, fWidth, fElems, fMipLevels); + Tex1D_U_A.GetDimensions(fWidth, fElems); + Tex1D_I_A.GetDimensions(0, fWidth, fElems, fMipLevels); + Tex1D_I_A.GetDimensions(fWidth, fElems); + Tex1DAS1.GetDimensions(0, fWidth, fElems, fMipLevels); + Tex1DAS1.GetDimensions(fWidth, fElems); + } +#endif + + //Texture2D + { + uint uWidth, uHeight, uMipLevels; + int iWidth, iHeight, iMipLevels; + float fWidth, fHeight, fMipLevels; + + Tex2D_F1.GetDimensions(uWidth, uHeight); + Tex2D_F1.GetDimensions(0, uWidth, uHeight, uMipLevels); + Tex2D_F3[0].GetDimensions( 0, uWidth, uHeight, uMipLevels ); + Tex2D_I.GetDimensions(uWidth, uHeight); + Tex2D_I.GetDimensions(0, uWidth, uHeight, uMipLevels); + Tex2D_U.GetDimensions(uWidth, uHeight); + Tex2D_U.GetDimensions(0, uWidth, uHeight, uMipLevels); + Tex2DS1.GetDimensions(uWidth, uHeight); + Tex2DS1.GetDimensions(0, uWidth, uHeight, uMipLevels); + + Tex2D_F1.GetDimensions(iWidth, iHeight); + Tex2D_F1.GetDimensions(0, iWidth, iHeight, iMipLevels); + Tex2D_F3[0].GetDimensions( 0, iWidth, iHeight, iMipLevels ); + Tex2D_I.GetDimensions(iWidth, iHeight); + Tex2D_I.GetDimensions(0, iWidth, iHeight, iMipLevels); + Tex2D_U.GetDimensions(iWidth, iHeight); + Tex2D_U.GetDimensions(0, iWidth, iHeight, iMipLevels); + Tex2DS1.GetDimensions(iWidth, iHeight); + Tex2DS1.GetDimensions(0, iWidth, iHeight, iMipLevels); + + + Tex2D_F1.GetDimensions(fWidth, fHeight); + Tex2D_F1.GetDimensions(0, fWidth, fHeight, fMipLevels); + Tex2D_F3[0].GetDimensions( 0, fWidth, fHeight, fMipLevels ); + Tex2D_I.GetDimensions(fWidth, fHeight); + Tex2D_I.GetDimensions(0, fWidth, fHeight, fMipLevels); + Tex2D_U.GetDimensions(fWidth, fHeight); + Tex2D_U.GetDimensions(0, fWidth, fHeight, fMipLevels); + Tex2DS1.GetDimensions(fWidth, fHeight); + Tex2DS1.GetDimensions(0, fWidth, fHeight, fMipLevels); + } + + //Texture2DArray + { + uint uWidth, uHeight, uMipLevels, uElems; + int iWidth, iHeight, iMipLevels, iElems; + float fWidth, fHeight, fMipLevels, fElems; + + Tex2D_F_A1.GetDimensions(0, uWidth, uHeight, uElems, uMipLevels); + Tex2D_F_A1.GetDimensions(uWidth, uHeight, uElems); + Tex2D_U_A.GetDimensions(0, uWidth, uHeight, uElems, uMipLevels); + Tex2D_U_A.GetDimensions(uWidth, uHeight, uElems); + Tex2D_I_A.GetDimensions(0, uWidth, uHeight, uElems, uMipLevels); + Tex2D_I_A.GetDimensions(uWidth, uHeight, uElems); + Tex2DAS1.GetDimensions(0, uWidth, uHeight, uElems, uMipLevels); + Tex2DAS1.GetDimensions(uWidth, uHeight, uElems); + + Tex2D_F_A1.GetDimensions(0, iWidth, iHeight, iElems, iMipLevels); + Tex2D_F_A1.GetDimensions(iWidth, iHeight, iElems); + Tex2D_U_A.GetDimensions(0, iWidth, iHeight, iElems, iMipLevels); + Tex2D_U_A.GetDimensions(iWidth, iHeight, iElems); + Tex2D_I_A.GetDimensions(0, iWidth, iHeight, iElems, iMipLevels); + Tex2D_I_A.GetDimensions(iWidth, iHeight, iElems); + Tex2DAS1.GetDimensions(0, iWidth, iHeight, iElems, iMipLevels); + Tex2DAS1.GetDimensions(iWidth, iHeight, iElems); + + Tex2D_F_A1.GetDimensions(0, fWidth, fHeight, fElems, fMipLevels); + Tex2D_F_A1.GetDimensions(fWidth, fHeight, fElems); + Tex2D_U_A.GetDimensions(0, fWidth, fHeight, fElems, fMipLevels); + Tex2D_U_A.GetDimensions(fWidth, fHeight, fElems); + Tex2D_I_A.GetDimensions(0, fWidth, fHeight, fElems, fMipLevels); + Tex2D_I_A.GetDimensions(fWidth, fHeight, fElems); + Tex2DAS1.GetDimensions(0, fWidth, fHeight, fElems, fMipLevels); + Tex2DAS1.GetDimensions(fWidth, fHeight, fElems); + } + + //Texture3D + { + uint uWidth, uHeight, uDepth, uMipLevels; + int iWidth, iHeight, iDepth, iMipLevels; + float fWidth, fHeight, fDepth, fMipLevels; + Tex3D_F1.GetDimensions(0, uWidth, uHeight, uDepth, uMipLevels); + Tex3D_F1.GetDimensions(uWidth, uHeight, uDepth); + Tex3D_U.GetDimensions(0, uWidth, uHeight, uDepth, uMipLevels); + Tex3D_U.GetDimensions(uWidth, uHeight, uDepth); + Tex3D_I.GetDimensions(0, uWidth, uHeight, uDepth, uMipLevels); + Tex3D_I.GetDimensions(uWidth, uHeight, uDepth); + + Tex3D_F1.GetDimensions(0, iWidth, iHeight, iDepth, iMipLevels); + Tex3D_F1.GetDimensions(iWidth, iHeight, iDepth); + Tex3D_U.GetDimensions(0, iWidth, iHeight, iDepth, iMipLevels); + Tex3D_U.GetDimensions(iWidth, iHeight, iDepth); + Tex3D_I.GetDimensions(0, iWidth, iHeight, iDepth, iMipLevels); + Tex3D_I.GetDimensions(iWidth, iHeight, iDepth); + + Tex3D_F1.GetDimensions(0, fWidth, fHeight, fDepth, fMipLevels); + Tex3D_F1.GetDimensions(fWidth, fHeight, fDepth); + Tex3D_U.GetDimensions(0, fWidth, fHeight, fDepth, fMipLevels); + Tex3D_U.GetDimensions(fWidth, fHeight, fDepth); + Tex3D_I.GetDimensions(0, fWidth, fHeight, fDepth, fMipLevels); + Tex3D_I.GetDimensions(fWidth, fHeight, fDepth); + } + + //TextureCube ~ Texture2D + { + uint uWidth, uHeight, uMipLevels; + int iWidth, iHeight, iMipLevels; + float fWidth, fHeight, fMipLevels; + + TexC_F1.GetDimensions(0, uWidth, uHeight, uMipLevels); + TexC_F1.GetDimensions(uWidth, uHeight); + TexC_I.GetDimensions(0, uWidth, uHeight, uMipLevels); + TexC_I.GetDimensions(uWidth, uHeight); + TexC_U.GetDimensions(0, uWidth, uHeight, uMipLevels); + TexC_U.GetDimensions(uWidth, uHeight); + TexCS1.GetDimensions(0, uWidth, uHeight, uMipLevels); + TexCS1.GetDimensions(uWidth, uHeight); + + TexC_F1.GetDimensions(0, iWidth, iHeight, iMipLevels); + TexC_F1.GetDimensions(iWidth, iHeight); + TexC_I.GetDimensions(0, iWidth, iHeight, iMipLevels); + TexC_I.GetDimensions(iWidth, iHeight); + TexC_U.GetDimensions(0, iWidth, iHeight, iMipLevels); + TexC_U.GetDimensions(iWidth, iHeight); + TexCS1.GetDimensions(0, iWidth, iHeight, iMipLevels); + TexCS1.GetDimensions(iWidth, iHeight); + + TexC_F1.GetDimensions(0, fWidth, fHeight, fMipLevels); + TexC_F1.GetDimensions(fWidth, fHeight); + TexC_I.GetDimensions(0, fWidth, fHeight, fMipLevels); + TexC_I.GetDimensions(fWidth, fHeight); + TexC_U.GetDimensions(0, fWidth, fHeight, fMipLevels); + TexC_U.GetDimensions(fWidth, fHeight); + TexCS1.GetDimensions(0, fWidth, fHeight, fMipLevels); + TexCS1.GetDimensions(fWidth, fHeight); + } + +#ifndef GL_ES + //TextureCubeArray ~ Texture2DArray + { + uint uWidth, uHeight, uMipLevels, uElems; + float fWidth, fHeight, fMipLevels, fElems; + int iWidth, iHeight, iMipLevels, iElems; + + TexC_F_A1.GetDimensions(0, uWidth, uHeight, uElems, uMipLevels); + TexC_F_A1.GetDimensions(uWidth, uHeight, uElems); + TexC_I_A.GetDimensions(0, uWidth, uHeight, uElems, uMipLevels); + TexC_I_A.GetDimensions(uWidth, uHeight, uElems); + TexC_U_A.GetDimensions(0, uWidth, uHeight, uElems, uMipLevels); + TexC_U_A.GetDimensions(uWidth, uHeight, uElems); + TexCAS1.GetDimensions(0, uWidth, uHeight, uElems, uMipLevels); + TexCAS1.GetDimensions(uWidth, uHeight, uElems); + + TexC_F_A1.GetDimensions(0, iWidth, iHeight, iElems, iMipLevels); + TexC_F_A1.GetDimensions(iWidth, iHeight, iElems); + TexC_I_A.GetDimensions(0, iWidth, iHeight, iElems, iMipLevels); + TexC_I_A.GetDimensions(iWidth, iHeight, iElems); + TexC_U_A.GetDimensions(0, iWidth, iHeight, iElems, iMipLevels); + TexC_U_A.GetDimensions(iWidth, iHeight, iElems); + TexCAS1.GetDimensions(0, iWidth, iHeight, iElems, iMipLevels); + TexCAS1.GetDimensions(iWidth, iHeight, iElems); + + TexC_F_A1.GetDimensions(0, fWidth, fHeight, fElems, fMipLevels); + TexC_F_A1.GetDimensions(fWidth, fHeight, fElems); + TexC_I_A.GetDimensions(0, fWidth, fHeight, fElems, fMipLevels); + TexC_I_A.GetDimensions(fWidth, fHeight, fElems); + TexC_U_A.GetDimensions(0, fWidth, fHeight, fElems, fMipLevels); + TexC_U_A.GetDimensions(fWidth, fHeight, fElems); + TexCAS1.GetDimensions(0, fWidth, fHeight, fElems, fMipLevels); + TexCAS1.GetDimensions(fWidth, fHeight, fElems); + } +#endif + + +#ifndef GL_ES // This should work on ES3.1, but compiler fails for no reason + // Texture2DMS + { + uint uWidth, uHeight, uNumSamples; + float fWidth, fHeight, fNumSamples; + int iWidth, iHeight, iNumSamples; + Tex2DMS_F1.GetDimensions(uWidth, uHeight, uNumSamples); + Tex2DMS_I.GetDimensions(uWidth, uHeight, uNumSamples); + Tex2DMS_U.GetDimensions(uWidth, uHeight, uNumSamples); + + Tex2DMS_F1.GetDimensions(fWidth, fHeight, fNumSamples); + Tex2DMS_I.GetDimensions(fWidth, fHeight, fNumSamples); + Tex2DMS_U.GetDimensions(fWidth, fHeight, fNumSamples); + + Tex2DMS_F1.GetDimensions(iWidth, iHeight, iNumSamples); + Tex2DMS_I.GetDimensions(iWidth, iHeight, iNumSamples); + Tex2DMS_U.GetDimensions(iWidth, iHeight, iNumSamples); + } +#endif + +#ifndef GL_ES + // Texture2DMSArray + { + uint uWidth, uHeight, uElems, uNumSamples; + int iWidth, iHeight, iElems, iNumSamples; + float fWidth, fHeight, fElems, fNumSamples; + Tex2DMS_F_A1.GetDimensions(uWidth, uHeight, uElems, uNumSamples); + Tex2DMS_I_A.GetDimensions(uWidth, uHeight, uElems, uNumSamples); + // OpenGL4.2 only supports 32 texture units and this one is 33rd: + // Tex2DMS_U_A.GetDimensions(Width, Height, Elems, NumSamples); + + Tex2DMS_F_A1.GetDimensions(fWidth, fHeight, fElems, fNumSamples); + Tex2DMS_I_A.GetDimensions(fWidth, fHeight, fElems, fNumSamples); + + Tex2DMS_F_A1.GetDimensions(iWidth, iHeight, iElems, iNumSamples); + Tex2DMS_I_A.GetDimensions(iWidth, iHeight, iElems, iNumSamples); + } +#endif + + // Buffer + { + uint uWidth; + //int iWidth; + //float fWidth; + TexBuffer_F1.GetDimensions(uWidth); + //TexBuffer_F4.GetDimensions(iWidth); + //TexBuffer_I.GetDimensions(fWidth); + } +} + + + +void TestSample() +{ + float2 f2UV = float2(0.2, 0.3); + float3 f3UVW = float3(0.2, 0.3, 0.5); + const int3 Offset = int3(3, 6, 2); + float4 f4UVWQ = float4(0.2, 0.3, 0.5, 10.0); + +#ifndef GL_ES + // Texture1D + Tex1D_F1.Sample(Tex1D_F1_sampler, f3UVW.x); + Tex1D_F1.Sample(Tex1D_F1_sampler, f3UVW.x, Offset.x); + + // Texture1DArray + Tex1D_F_A1.Sample(Tex1D_F_A1_sampler, f3UVW.xy); + Tex1D_F_A1.Sample(Tex1D_F_A1_sampler, f3UVW.xy, Offset.x); +#endif + + //Texture2D + Tex2D_F1.Sample( Tex2D_F1_sampler, f3UVW.xy ).xyzw.xyzw; + Tex2D_F1.Sample( Tex2D_F1_sampler, f3UVW.xy, Offset.xy ); + Tex2D_F1.Sample( Tex2D_F1_sampler, float2(0.1, 0.3) ); + Tex2D_F1.Sample( Tex2D_F1_sampler, float2(0.1, (0.3+0.1) ), int2( (3-1) ,5) ); + + //Texture2DArray + Tex2D_F_A1.Sample( Tex2D_F_A1_sampler, f3UVW.xyz ); + Tex2D_F_A1.Sample( Tex2D_F_A1_sampler, f3UVW.xyz, Offset.xy ); + + //Texture3D + Tex3D_F1.Sample(Tex3D_F1_sampler, f3UVW.xyz ); + Tex3D_F1.Sample(Tex3D_F1_sampler, f3UVW.xyz, Offset.xyz ); + + //TextureCube + TexC_F1.Sample(TexC_F1_sampler, f3UVW.xyz ); + // Offset not supported + +#ifndef GL_ES + // TextureCubeArray + TexC_F_A1.Sample( TexC_F_A1_sampler, f4UVWQ.xyzw ); + TexC_F_A1.Sample( TexC_F_A1_sampler, float4(0.5, (0.2+(0.01+0.02)), 0.4, 7.0) ); + // Offset not supported +#endif +} + + + +void TestSampleBias() +{ + float2 f2UV = float2(0.2, 0.3); + float3 f3UVW = float3(0.2, 0.3, 0.5); + const int3 Offset = int3(3, 6, 2); + float4 f4UVWQ = float4(0.2, 0.3, 0.5, 10.0); + +#ifndef GL_ES + // Texture1D + Tex1D_F1.SampleBias(Tex1D_F1_sampler, f3UVW.x, 1.5); + Tex1D_F1.SampleBias(Tex1D_F1_sampler, f3UVW.x, 1.5, Offset.x); + + // Texture1DArray + Tex1D_F_A1.SampleBias(Tex1D_F_A1_sampler, f3UVW.xy, 1.5); + Tex1D_F_A1.SampleBias(Tex1D_F_A1_sampler, f3UVW.xy, 1.5, Offset.x); +#endif + + //Texture2D + Tex2D_F1.SampleBias( Tex2D_F1_sampler, f3UVW.xy, 1.5 ); + Tex2D_F1.SampleBias( Tex2D_F1_sampler, f3UVW.xy, 1.5, Offset.xy ); + Tex2D_F1.SampleBias( Tex2D_F1_sampler, float2(0.1, 0.3), 1.5 ); + Tex2D_F1.SampleBias( Tex2D_F1_sampler, float2(0.1, (0.3+0.1) ), 1.5, int2( (3-1) ,5) ); + + //Texture2DArray + Tex2D_F_A1.SampleBias( Tex2D_F_A1_sampler, f3UVW.xyz, 1.5 ); + Tex2D_F_A1.SampleBias( Tex2D_F_A1_sampler, f3UVW.xyz, 1.5, Offset.xy ); + + //Texture3D + Tex3D_F1.SampleBias(Tex3D_F1_sampler, f3UVW.xyz, 1.5 ); + Tex3D_F1.SampleBias(Tex3D_F1_sampler, f3UVW.xyz, 1.5, Offset.xyz ); + + //TextureCube + TexC_F1.SampleBias(TexC_F1_sampler, f3UVW.xyz, 1.5 ); + // Offset not supported + +#ifndef GL_ES + // TextureCubeArray + TexC_F_A1.SampleBias( TexC_F_A1_sampler, f4UVWQ.xyzw, 1.5 ); + TexC_F_A1.SampleBias( TexC_F_A1_sampler, float4(0.5, (0.2+(0.01+0.02)), 0.4, 7.0), 1.6 ); + // Offset not supported +#endif +} + +void TestSampleLevel() +{ + float2 f2UV = float2(0.2, 0.3); + float3 f3UVW = float3(0.2, 0.3, 0.5); + float Level = 1.8; + const int3 Offset = int3(3, 6, 2); + float4 f4UVWQ = float4(0.2, 0.3, 0.5, 10.0); + +#ifndef GL_ES + // Texture1D + Tex1D_F1.SampleLevel(Tex1D_F1_sampler, f3UVW.x, Level); + Tex1D_F1.SampleLevel(Tex1D_F1_sampler, f3UVW.x, Level, Offset.x); + + // Texture1DArray + Tex1D_F_A1.SampleLevel(Tex1D_F_A1_sampler, f3UVW.xy, Level); + Tex1D_F_A1.SampleLevel(Tex1D_F_A1_sampler, f3UVW.xy, Level, Offset.x); +#endif + + //Texture2D + Tex2D_F1.SampleLevel( Tex2D_F1_sampler, f3UVW.xy, Level ); + Tex2D_F1.SampleLevel( Tex2D_F1_sampler, Tex2D_F1.SampleLevel( Tex2D_F1_sampler, f3UVW.xy, Level ).xy + Tex2D_F1.SampleLevel( Tex2D_F1_sampler, f3UVW.xy, Level ).xy, Level ); + Tex2D_F1.SampleLevel( Tex2D_F1_sampler, f3UVW.xy, Level, Offset.xy ); + Tex2D_F1.SampleLevel( Tex2D_F1_sampler, float2(0.1, 0.3), 4.0 ); + Tex2D_F1.SampleLevel( Tex2D_F1_sampler, float2(0.1, (0.3+0.1) ), 4.0, int2( (3-1) ,5) ); + + //Texture2DArray + Tex2D_F_A1.SampleLevel( Tex2D_F_A1_sampler, f3UVW.xyz, Level ); + Tex2D_F_A1.SampleLevel( Tex2D_F_A1_sampler, f3UVW.xyz, Level, Offset.xy ); + + //Texture3D + Tex3D_F1.SampleLevel(Tex3D_F1_sampler, f3UVW.xyz, Level ); + Tex3D_F1.SampleLevel(Tex3D_F1_sampler, f3UVW.xyz, Level, Offset.xyz ); + + //TextureCube + TexC_F1.SampleLevel(TexC_F1_sampler, f3UVW.xyz, Level ); + // Offset not supported + +#ifndef GL_ES + // TextureCubeArray + TexC_F_A1.SampleLevel( TexC_F_A1_sampler, f4UVWQ.xyzw, Level ); + TexC_F_A1.SampleLevel( TexC_F_A1_sampler, float4(0.5, (0.2+(0.01+0.02)), 0.4, 7.0), 5 ); + // Offset not supported +#endif +} + + +void TestSampleGrad() +{ + float2 f2UV = float2(0.2, 0.3); + float2 f2ddxUV = float2(0.01, -0.02); + float2 f2ddyUV = float2(-0.01, 0.01); + float3 f3UVW = float3(0.2, 0.3, 0.5); + float3 f3ddxUVW = float3(-0.02, 0.03, 0.05); + float3 f3ddyUVW = float3( 0.01, -0.02, 0.02); + const int3 Offset = int3(3, 6, 2); + float4 f4UVWQ = float4(0.2, 0.3, 0.5, 10.0); + +#ifndef GL_ES + // Texture1D + Tex1D_F1.SampleGrad(Tex1D_F1_sampler, f3UVW.x, f2ddxUV.x, f2ddyUV.x); + Tex1D_F1.SampleGrad(Tex1D_F1_sampler, f3UVW.x, f2ddxUV.x, f2ddyUV.x, Offset.x); + + // Texture1DArray + Tex1D_F_A1.SampleGrad(Tex1D_F_A1_sampler, f3UVW.xy, f2ddxUV.x, f2ddyUV.x); + Tex1D_F_A1.SampleGrad(Tex1D_F_A1_sampler, f3UVW.xy, f2ddxUV.x, f2ddyUV.x, Offset.x); +#endif + + //Texture2D + Tex2D_F1.SampleGrad( Tex2D_F1_sampler, f3UVW.xy, f2ddxUV.xy, f2ddyUV.xy ); + Tex2D_F1.SampleGrad( Tex2D_F1_sampler, f3UVW.xy, f2ddxUV.xy, f2ddyUV.xy, Offset.xy ); + Tex2D_F1.SampleGrad( Tex2D_F1_sampler, float2(0.1, 0.3), float2(0.01, 0.02), float2(-0.02, 0.01) ); + Tex2D_F1.SampleGrad( Tex2D_F1_sampler, float2(0.1, (0.3+0.1) ), float2(0.01, 0.02), float2(-0.02, 0.01), int2( (3-1) ,5) ); + + //Texture2DArray + Tex2D_F_A1.SampleGrad( Tex2D_F_A1_sampler, f3UVW.xyz, f2ddxUV.xy, f2ddyUV.xy ); + Tex2D_F_A1.SampleGrad( Tex2D_F_A1_sampler, f3UVW.xyz, f2ddxUV.xy, f2ddyUV.xy, Offset.xy ); + + //Texture3D + Tex3D_F1.SampleGrad(Tex3D_F1_sampler, f3UVW.xyz, f3ddxUVW.xyz, f3ddyUVW.xyz ); + Tex3D_F1.SampleGrad(Tex3D_F1_sampler, f3UVW.xyz, f3ddxUVW.xyz, f3ddyUVW.xyz, Offset.xyz ); + + //TextureCube + TexC_F1.SampleGrad(TexC_F1_sampler, f3UVW.xyz, f3ddxUVW.xyz, f3ddyUVW.xyz ); + // Offset not supported + +#ifndef GL_ES + // TextureCubeArray + TexC_F_A1.SampleGrad( TexC_F_A1_sampler, f4UVWQ.xyzw, f3ddxUVW.xyz, f3ddyUVW.xyz ); + TexC_F_A1.SampleGrad( TexC_F_A1_sampler, float4(0.5, (0.2+(0.01+0.02)), 0.4, 7.0), float3(0.01,0.02,0.03), float3(-0.01,-0.02,-0.03) ); + // Offset not supported +#endif +} + + + +void TestSampleCmp() +{ + float3 f3UVW = float3(0.2, 0.3, 0.5); + const int3 Offset = int3(3, 6, 2); + float4 f4UVWQ = float4(0.2, 0.3, 0.5, 10.0); + float CompareVal = 0.7; + +#ifndef GL_ES + // Texture1D + Tex1DS1.SampleCmp(Tex1DS1_sampler, f3UVW.x, CompareVal); + Tex1DS1.SampleCmp(Tex1DS1_sampler, f3UVW.x, CompareVal, Offset.x); + + // Texture1DArray + Tex1DAS1.SampleCmp(Tex1DAS1_sampler, f3UVW.xy, CompareVal); + Tex1DAS1.SampleCmp(Tex1DAS1_sampler, f3UVW.xy, CompareVal, Offset.x); +#endif + + //Texture2D + Tex2DS1.SampleCmp( Tex2DS1_sampler, f3UVW.xy, CompareVal ); + Tex2DS1.SampleCmp( Tex2DS1_sampler, f3UVW.xy, CompareVal, Offset.xy ); + Tex2DS1.SampleCmp( Tex2DS1_sampler, float2(0.1, 0.3), 4.0 ); + Tex2DS1.SampleCmp( Tex2DS1_sampler, float2(0.1, (0.3+0.1) ), 4.0, int2( (3-1) ,5) ); + Tex2DS_F5.SampleCmp( Tex2DS_F5_sampler, f3UVW.xy, CompareVal ); + + //Texture2DArray + Tex2DAS1.SampleCmp( Tex2DAS1_sampler, f3UVW.xyz, CompareVal ); + // This seems to be another bug on Intel driver: the following line does not compile: + // Tex2DAS1.SampleCmp( Tex2DAS1_sampler, f3UVW.xyz, CompareVal, Offset.xy ); + + //TextureCube + TexCS1.SampleCmp(TexCS1_sampler, f3UVW.xyz, CompareVal ); + // Offset not supported + +#ifndef GL_ES + // TextureCubeArray + TexCAS1.SampleCmp( TexCAS1_sampler, f4UVWQ.xyzw, CompareVal ); + TexCAS1.SampleCmp( TexCAS1_sampler, float4(0.5, (0.2+(0.01+0.02)), 0.4, 7.0), 0.5 ); + // Offset not supported +#endif +} + + + +void TestSampleCmpLevelZero() +{ + float3 f3UVW = float3(0.2, 0.3, 0.5); + const int3 Offset = int3(3, 6, 2); + float4 f4UVWQ = float4(0.2, 0.3, 0.5, 10.0); + float CompareVal = 0.7; + +#ifndef GL_ES + // Texture1D + Tex1DS1.SampleCmpLevelZero(Tex1DS1_sampler, f3UVW.x, CompareVal); + Tex1DS1.SampleCmpLevelZero(Tex1DS1_sampler, f3UVW.x, CompareVal, Offset.x); + + // Texture1DArray + Tex1DAS1.SampleCmpLevelZero(Tex1DAS1_sampler, f3UVW.xy, CompareVal); + Tex1DAS1.SampleCmpLevelZero(Tex1DAS1_sampler, f3UVW.xy, CompareVal, Offset.x); +#endif + + //Texture2D + Tex2DS1.SampleCmpLevelZero( Tex2DS1_sampler, f3UVW.xy, CompareVal ); + Tex2DS1.SampleCmpLevelZero( Tex2DS1_sampler, f3UVW.xy, CompareVal, Offset.xy ); + Tex2DS1.SampleCmpLevelZero( Tex2DS1_sampler, float2(0.1, 0.3), 4.0 ); + Tex2DS1.SampleCmpLevelZero( Tex2DS1_sampler, float2(0.1, (0.3+0.1) ), 4.0, int2( (3-1) ,5) ); + + //Texture2DArray + Tex2DAS1.SampleCmpLevelZero( Tex2DAS1_sampler, f3UVW.xyz, CompareVal ); + // This seems to be another bug on Intel driver: the following line does not compile: + // Tex2DAS1.SampleCmpLevelZero( Tex2DAS1_sampler, f3UVW.xyz, CompareVal, Offset.xy ); + + //TextureCube + TexCS1.SampleCmpLevelZero(TexCS1_sampler, f3UVW.xyz, CompareVal ); + // Offset not supported + +#ifndef GL_ES + // TextureCubeArray + TexCAS1.SampleCmpLevelZero( TexCAS1_sampler, f4UVWQ.xyzw, CompareVal ); + TexCAS1.SampleCmpLevelZero( TexCAS1_sampler, float4(0.5, (0.2+(0.01+0.02)), 0.4, 7.0), 0.5 ); + // Offset not supported +#endif +} + + + +void TestLoad() +{ + int4 Location = int4(2, 5, 1, 10); + const int3 Offset = int3(5, 7, -6); + +#ifndef GL_ES + // Texture1D + { + Tex1D_F1.Load(Location.xy); + Tex1D_F1.Load(Location.xy, Offset.x); + Tex1D_I.Load(Location.xy); + Tex1D_I.Load(Location.xy, Offset.x); + Tex1D_U.Load(Location.xy); + Tex1D_U.Load(Location.xy, Offset.x); + } + + // Texture1DArray + { + Tex1D_F_A1.Load(Location.xyz); + Tex1D_F_A1.Load(Location.xyz, Offset.x); + Tex1D_U_A.Load(Location.xyz); + Tex1D_U_A.Load(Location.xyz, Offset.x); + Tex1D_I_A.Load(Location.xyz); + Tex1D_I_A.Load(Location.xyz, Offset.x); + } +#endif + + //Texture2D + { + Tex2D_F1.Load(Location.xyz); + Tex2D_F1.Load(Location.xyz, Offset.xy); + Tex2D_F1.Load(Tex2D_I.Load(Location.xyz).xyz + Tex2D_I.Load(Location.xyz).xyz); + Tex2D_I.Load(Location.xyz); + Tex2D_I.Load(Location.xyz, Offset.xy); + Tex2D_U.Load(Location.xyz); + Tex2D_U.Load(Location.xyz, Offset.xy); + } + + //Texture2DArray + { + Tex2D_F_A1.Load(Location.xyzw); + Tex2D_F_A1.Load(Location.xyzw, Offset.xy); + Tex2D_U_A.Load(Location.xyzw); + Tex2D_U_A.Load(Location.xyzw, Offset.xy); + Tex2D_I_A.Load(Location.xyzw); + Tex2D_I_A.Load(Location.xyzw, Offset.xy); + } + + //Texture3D + { + Tex3D_F1.Load(Location.xyzw); + Tex3D_F1.Load(Location.xyzw, Offset.xyz); + Tex3D_U.Load(Location.xyzw); + Tex3D_U.Load(Location.xyzw, Offset.xyz); + Tex3D_I.Load(Location.xyzw); + Tex3D_I.Load(Location.xyzw, Offset.xyz); + } + +#ifndef GL_ES // This should work on ES3.1, but compiler fails for no reason + // Texture2DMS + { + Tex2DMS_F1.Load(Location.xy, 1); + Tex2DMS_F1.Load(Location.xy, 1, Offset.xy); + Tex2DMS_I.Load(Location.xy, 1); + Tex2DMS_I.Load(Location.xy, 1, Offset.xy); + Tex2DMS_U.Load(Location.xy, 1); + Tex2DMS_U.Load(Location.xy, 1, Offset.xy); + } +#endif + +#ifndef GL_ES + // Texture2DMSArray + { + Tex2DMS_F_A1.Load(Location.xyz, 1); + Tex2DMS_F_A1.Load(Location.xyz, 1, Offset.xy); + Tex2DMS_I_A.Load(Location.xyz, 1); + Tex2DMS_I_A.Load(Location.xyz, 1, Offset.xy); + Tex2DMS_U_A.Load(Location.xyz, 1); + Tex2DMS_U_A.Load(Location.xyz, 1, Offset.xy); + } +#endif + + // Buffer + { + TexBuffer_F1.Load(Location.x); + TexBuffer_F4.Load(Location.x); + TexBuffer_I.Load(Location.x); + TexBuffer_U.Load(Location.x); + } +} + + + + +void TestGather() +{ +#if !GLES30 // no textureGather in GLES3.0 + float4 Location = float4(0.2, 0.5, 0.1, 0.7); + const int3 Offset = int3(5, 10, 20); + + //Texture2D + { + Tex2D_F1.Gather(Tex2D_F1_sampler, Location.xy); + Tex2D_F1.Gather(Tex2D_F1_sampler, Location.xy, Offset.xy); + //Tex2D_I.Gather(Location.xyz); + //Tex2D_I.Gather(Location.xyz, Offset.xy); + //Tex2D_U.Gather(Location.xyz); + //Tex2D_U.Gather(Location.xyz, Offset.xy); + } + + //Texture2DArray + { + Tex2D_F_A1.Gather(Tex2D_F_A1_sampler, Location.xyz); + Tex2D_F_A1.Gather(Tex2D_F_A1_sampler, Location.xyz, Offset.xy); + //Tex2D_U_A.Gather(Location.xyzw); + //Tex2D_U_A.Gather(Location.xyzw, Offset.xy); + //Tex2D_I_A.Gather(Location.xyzw); + //Tex2D_I_A.Gather(Location.xyzw, Offset.xy); + } + + // TextureCube + { + TexC_F1.Gather(TexC_F1_sampler, Location.xyz); + //TexC_I.Gather(Location.xyz); + //TexC_U.Gather(Location.xyz); + } +#ifndef GL_ES + // TextureCubeArray + { + TexC_F_A1.Gather(TexC_F_A1_sampler, Location.xyzw); + //TexC_I_A.Gather(Location.xyzw); + //TexC_U_A.Gather(Location.xyzw); + } +#endif + +#endif +} + + + +void TestGatherCmp() +{ +#if !GLES30 // no textureGather in GLES3.0 + float4 Location = float4(0.2, 0.5, 0.1, 0.7); + const int3 Offset = int3(5, 10, 20); + float CompareVal = 0.01; + + //Texture2D + { + Tex2DS1.GatherCmp(Tex2DS1_sampler, Location.xy, CompareVal); + Tex2DS1.GatherCmp(Tex2DS1_sampler, Location.xy, CompareVal, Offset.xy); + } + + //Texture2DArray + { + Tex2DAS1.GatherCmp(Tex2DAS1_sampler, Location.xyz, CompareVal); + Tex2DAS1.GatherCmp(Tex2DAS1_sampler, Location.xyz, CompareVal, Offset.xy); + } + + // TextureCube + { + TexCS1.GatherCmp(TexCS1_sampler, Location.xyz, CompareVal); + } +#ifndef GL_ES + // TextureCubeArray + { + TexCAS1.GatherCmp(TexCAS1_sampler, Location.xyzw, CompareVal); + } +#endif + +#endif +} + +struct InnerStruct +{ + float f[4]; + int i; + uint u; + bool b; +}; + +struct OuterStruct +{ + InnerStruct inner; + float f; + int i; + uint u; + bool b; +}; + +struct VSInputSubStruct +{ + float3 f3Normal : ATTRIB2; + uint VertexId : SV_VertexId; +}; + +struct VSInput +{ + float3 f3PosWS : ATTRIB0; + float2 f2UV : ATTRIB1; + VSInputSubStruct SubStruct; +}; + +struct VSOutputSubStruct +{ + float4 f4Attrib : F4_ATTRIB2; + int iAttrib : I_ATTRIB2; +}; +struct VSOutput +{ + float2 f2Attrib : F2_ATTRIB; + float3 f3Attrib : F3_ATTRIB; + float4 f4Attrib : F4_ATTRIB; + uint uiAttrib : UI_ATTRIB; + uint3 ui3Attrib : UI3_ATTRIB; + int iAttrib : I_ATTRIB; + float4 f4PosPS : SV_Position; + VSOutputSubStruct SubStruct; +}; + +void TestVS ( VSInput In, + in float3 f3UV : ATTRIB3, + in uint InstID : SV_InstanceID, + out VSOutput Out, + out float fAttrib : F_ATTRIB, + out int4 i4Attrib : I4_ATTRIB) +{ + Out.f4PosPS = float4(1.0, 2.0, 3.0, 4.0); + fAttrib = 1.0; + Out.f2Attrib = float2(5.0, 6.0) + In.f2UV; + Out.f3Attrib = float3(7.0, 8.0, 9.0) + In.f3PosWS + f3UV + In.SubStruct.f3Normal; + Out.f4Attrib = float4(10.0, 11.0, 12.0, 13.0); + + Out.SubStruct.f4Attrib = float4(10.0, 11.0, 12.0, 13.0); + Out.uiAttrib = 1u; + Out.ui3Attrib = uint3(2u, 3u, 4u); + Out.iAttrib = 5; + Out.SubStruct.iAttrib = 20; + i4Attrib = int4(5, 6, 7, 8); + + if( In.f2UV.x < 0.5 ) + return; + + Out.f4Attrib.z = 0.1; + Out.SubStruct.f4Attrib.zw = float2(12.0, 31.0); + Out.ui3Attrib.y = 2u; + i4Attrib.yzw = int3(15, 16, 17); +} + + +void TestFuncArgs1( Texture2D Arg1, + SamplerState Arg1_sampler, + Texture2D Arg2, + SamplerComparisonState Arg2_sampler, + Texture3D Arg3) +{ + uint uWidth, uHeight, uMipLevels; + Arg1.GetDimensions(uWidth, uHeight); + + Arg2.SampleCmp( Arg2_sampler, float2(0.5,0.5), 0.1 ); + + Arg3.Load( int4(1, 2, 3, 0) ); +} + +void TestFuncArgs2( Texture3D Arg1, + Texture2DArray Arg2, + SamplerState Arg2_sampler, + Texture2D Arg3) +{ + Arg1.Load( int4(1, 2, 3, 0) ); + + uint uWidth, uHeight, uElems; + Arg2.GetDimensions(uWidth, uHeight, uElems); + + Arg3.Load(int3(10,15,3) ); +} + +struct PSOutputSubStruct +{ + float4 Color4 : SV_Target1; +}; +struct PSOutput +{ + float4 Color3 : SV_Target3; + PSOutputSubStruct substr; +}; + +void TestPS ( in VSOutput In, + out float4 Color : SV_Target, + out float3 Color2 : SV_Target2, + out PSOutput Out) +{ + float4 Pos = In.f4PosPS; + + Out.Color3 = float4(0.0 + a, 1.0 + b, 2.0 + c, 3.0 + d); + Out.substr.Color4 = float4(0.0, 1.0, 2.0, 3.0); + + TestFuncArgs1( Tex2D_F6, + Tex2D_F6_sampler, + Tex2DS_F5, + Tex2DS_F5_sampler, + Tex3D_F3); + TestFuncArgs2( Tex3D_I, + Tex2D_F_A3, + Tex2D_F_A3_sampler, + Tex2D_F2); + { + float2 a = float2(0.0, 0.0); + float2 b = float2(1.0, 1.0); + float2 c = float2(2.0, 2.0); + a += b; + a-=b; + a *=c; + a/= c; + float2 d = a; + + int2 x = int2(1, 2); + int2 y = int2(2, 1); + x %= y; + x &= y; + x |= y; + x ^= y; + x >>= y; + x <<= y; + x = x | y; + x = x & y; + x = x % y; + x = x ^ y; + x = ~y; + x = x >> y; + x = x << y; + x++; + ++x; + y--; + --y; + if( x.x>= y.x || y.y >=x.y && x.y == y.x && y.y==x.y && !(x.x==y.y) ) + x += y; + + [flatten] + if(x.x==y.x) + x.x=y.x; + + [branch] + if(x.x==y.x) + x.x+=y.x; + { + [loop] + for(int i=0;i<10;++i) + x.x+=1; + } + + { + [unroll] + for(int i=0;i<10;++i) + y.x+=1; + } + + Color = In.f4Attrib; + Color2 = In.f3Attrib; + if( Pos.x < 0.2 ) return; + } + + { + int i1 = 1; + int2 i2 = int2(1, 2); + int3 i3 = int3(1, 2, 3); + int4 i4 = int4(1,2,3,4); + + float f1 = 1.0; + float2 f2 = float2(1.0, 2.0); + float3 f3 = float3(1.0, 2.0, 3.0); + float4 f4 = float4(1.0,2.0,3.0,4.0); + float f1_ = 2.0; + float2 f2_ = float2(11.0, 12.0); + float3 f3_ = float3(11.0, 12.0, 13.0); + float4 f4_ = float4(11.0,12.0,13.0,14.0); + + uint u1 = 1u; + uint2 u2 = uint2(1u, 2u); + uint3 u3 = uint3(1u, 2u, 3u); + uint4 u4 = uint4(1u, 2u,3u,4u); + + bool b1 = true; + bool2 b2 = bool2(true, false); + bool3 b3 = bool3(true, false, true); + bool4 b4 = bool4(true, false, true, false); + + i1 = abs ( i1 ); i2 = abs ( i2 ); i3 = abs ( i3 ); i4 = abs ( i4 ); + f1 = abs ( f1 ); f2 = abs ( f2 ); f3 = abs ( f3 ); f4 = abs ( f4 ); + + b1 = all ( b2 ); b1 = all ( b3 ); b1 = all ( b4 ); + b1 = any ( b2 ); b1 = any ( b3 ); b1 = any ( b4 ); + + f1 = ceil( f1 ); f2 = ceil( f2 ); f3 = ceil( f3 ); f4 = ceil( f4 ); + + f1 = clamp(f1,f1,f1); f2 = clamp(f2,f2,f2); f3 = clamp(f3,f3,f3); f4 = clamp(f4,f4,f4); + i1 = clamp(i1,i1,i1); i2 = clamp(i2,i2,i2); i3 = clamp(i3,i3,i3); i4 = clamp(i4,i4,i4); + u1 = clamp(u1,u1,u1); u2 = clamp(u2,u2,u2); u3 = clamp(u3,u3,u3); u4 = clamp(u4,u4,u4); + + // Trigonometric functions + f1 = cos( f1 ); f2 = cos( f2 ); f3 = cos( f3 ); f4 = cos( f4 ); + f1 = sin( f1 ); f2 = sin( f2 ); f3 = sin( f3 ); f4 = sin( f4 ); + f1 = tan( f1 ); f2 = tan( f2 ); f3 = tan( f3 ); f4 = tan( f4 ); + f1 = cosh( f1 ); f2 = cosh( f2 ); f3 = cosh( f3 ); f4 = cosh( f4 ); + f1 = sinh( f1 ); f2 = sinh( f2 ); f3 = sinh( f3 ); f4 = sinh( f4 ); + f1 = tanh( f1 ); f2 = tanh( f2 ); f3 = tanh( f3 ); f4 = tanh( f4 ); + f1 = acos( f1 ); f2 = acos( f2 ); f3 = acos( f3 ); f4 = acos( f4 ); + f1 = asin( f1 ); f2 = asin( f2 ); f3 = asin( f3 ); f4 = asin( f4 ); + f1 = atan( f1 ); f2 = atan( f2 ); f3 = atan( f3 ); f4 = atan( f4 ); + f1 = atan2(f1,f1); f2 = atan2(f2,f2); f3 = atan2(f3,f3); f4 = atan2(f4,f4); + f1 = degrees( f1 ); f2 = degrees( f2 ); f3 = degrees( f3 ); f4 = degrees( f4 ); + f1 = radians( f1 ); f2 = radians( f2 ); f3 = radians( f3 ); f4 = radians( f4 ); + + // Exponential functions + f1 = pow( f1, f1 ); f2 = pow( f2,f2 ); f3 = pow( f3,f3 ); f4 = pow( f4,f4 ); + f1 = exp( f1 ); f2 = exp( f2 ); f3 = exp( f3 ); f4 = exp( f4 ); + f1 = log( f1 ); f2 = log( f2 ); f3 = log( f3 ); f4 = log( f4 ); + f1 = exp2( f1 ); f2 = exp2( f2 ); f3 = exp2( f3 ); f4 = exp2( f4 ); + f1 = log2( f1 ); f2 = log2( f2 ); f3 = log2( f3 ); f4 = log2( f4 ); + f1 = sqrt( f1 ); f2 = sqrt( f2 ); f3 = sqrt( f3 ); f4 = sqrt( f4 ); + f1 = rsqrt( f1 ); f2 = rsqrt( f2 ); f3 = rsqrt( f3 ); f4 = rsqrt( f4 ); + f1 = log10( f1 ); f2 = log10( f2 ); f3 = log10( f3 ); f4 = log10( f4 ); + + i1 = sign ( i1 ); i2 = sign ( i2 ); i3 = sign ( i3 ); i4 = sign ( i4 ); + f1 = sign ( f1 ); f2 = sign ( f2 ); f3 = sign ( f3 ); f4 = sign ( f4 ); + f1 = floor ( f1 ); f2 = floor( f2 ); f3 = floor( f3 ); f4 = floor( f4 ); + f1 = trunc ( f1 ); f2 = trunc( f2 ); f3 = trunc( f3 ); f4 = trunc( f4 ); + f1 = round ( f1 ); f2 = round( f2 ); f3 = round( f3 ); f4 = round( f4 ); + f1 = frac ( f1 ); f2 = frac ( f2 ); f3 = frac ( f3 ); f4 = frac ( f4 ); + + f1 = 1.0; + f2 = float2(1.0, 2.0); + f3 = float3(1.0, 2.0, 3.0); + f4 = float4(1.0,2.0,3.0,4.0); + f1 = fmod ( f1, f1 ); f2 = fmod ( f2, f2 ); f3 = fmod ( f3, f3 ); f4 = fmod ( f4, f4 ); + f1 = modf ( f1, f1 ); f2 = modf ( f2, f2 ); f3 = modf ( f3, f3 ); f4 = modf ( f4, f4 ); + + f1 = min(f1,f1); f2 = min(f2,f2); f3 = min(f3,f3); f4 = min(f4,f4); + i1 = min(i1,i1); i2 = min(i2,i2); i3 = min(i3,i3); i4 = min(i4,i4); + u1 = min(u1,u1); u2 = min(u2,u2); u3 = min(u3,u3); u4 = min(u4,u4); + + f1 = max(f1,f1); f2 = max(f2,f2); f3 = max(f3,f3); f4 = max(f4,f4); + i1 = max(i1,i1); i2 = max(i2,i2); i3 = max(i3,i3); i4 = max(i4,i4); + u1 = max(u1,u1); u2 = max(u2,u2); u3 = max(u3,u3); u4 = max(u4,u4); + + f1 = lerp(f1,f1,f1); f2 = lerp(f2,f2,f2); f3 = lerp(f3,f3,f3); f4 = lerp(f4,f4,f4); + f1 = step(f1,f1); f2 = step(f2,f2); f3 = step(f3,f3); f4 = step(f4,f4); + f1 = smoothstep(f1,f1_,f1); f2 = smoothstep(f2,f2_,f2); f3 = smoothstep(f3,f3_,f3); f4 = smoothstep(f4,f4_,f4); + + b1 = isnan ( f1/Pos.x ); b2 = isnan( f2/Pos.x ); b3 = isnan( f3/Pos.x ); b4 = isnan( f4/Pos.x ); + b1 = isinf ( f1/Pos.x ); b2 = isinf( f2/Pos.x ); b3 = isinf( f3/Pos.x ); b4 = isinf( f4/Pos.x ); + b1 = isfinite ( f1/Pos.x ); b2 = isfinite( f2/Pos.x ); b3 = isfinite( f3/Pos.x ); b4 = isfinite( f4/Pos.x ); + f1 = mad(f1,f1,f1); f2 = mad(f2,f2,f2); f3 = mad(f3,f3,f3); f4 = mad(f4,f4,f4); + + f1 = distance(f1,f1); f1 = distance(f2,f2); f1 = distance(f3,f3); f1 = distance(f4,f4); + f1 = length(f1); f1 = length(f2); f1 = length(f3); f1 = length(f4); + f1 = dot(f1,f1); f1 = dot(f2,f2); f1 = dot(f3,f3); f1 = dot(f4,f4); + f3 = cross( f3, f3 ); + + f1 = 1.0; + f2 = float2(1.0, 2.0); + f3 = float3(1.0, 2.0, 3.0); + f4 = float4(1.0,2.0,3.0,4.0); + f2 = normalize(f2); f3 = normalize(f3); f4 = normalize(f4); + f2 = reflect(f2,f2); f3 = reflect(f3,f3); f4 = reflect(f4,f4); + f2 = refract(f2,f2,1.0); f3 = refract(f3,f3,1.0); f4 = refract(f4,f4,1.0); + f2 = faceforward(f2,f2,f2); f3 = faceforward(f3,f3,f3); f4 = faceforward(f4,f4,f4); + + //f1 = dst(f1,f1); f1 = dst(f2,f2); f1 = dst(f3,f3); f1 = dst(f4,f4); + f1 = rcp(f1); f2 = rcp(f2); f3 = rcp(f3); f4 = rcp(f4); + + f1 = saturate(f1); f2 = saturate(f2); f3 = saturate(f3); f4 = saturate(f4); + sincos(f1,f1,f1_); sincos(f2,f2,f2_); sincos(f3,f3,f3_); sincos(f4,f4,f4_); + + // no bit operations in GLES3.0. SPIRV optimizer also fails to legalize these operations. +#if !GLES30 && !defined(VULKAN) + i1 = countbits(u1); i2 = countbits(u2); i3 = countbits(u3); i4 = countbits(u4); + i1 = countbits(i1); i2 = countbits(i2); i3 = countbits(i3); i4 = countbits(i4); + i1 = firstbithigh(u1); i2 = firstbithigh(u2); i3 = firstbithigh(u3); i4 = firstbithigh(u4); + i1 = firstbithigh(i1); i2 = firstbithigh(i2); i3 = firstbithigh(i3); i4 = firstbithigh(i4); + i1 = firstbitlow(u1); i2 = firstbitlow(u2); i3 = firstbitlow(u3); i4 = firstbitlow(u4); + i1 = firstbitlow(i1); i2 = firstbitlow(i2); i3 = firstbitlow(i3); i4 = firstbitlow(i4); + u1 = reversebits(u1); u2 = reversebits(u2); u3 = reversebits(u3); u4 = reversebits(u4); + i1 = reversebits(i1); i2 = reversebits(i2); i3 = reversebits(i3); i4 = reversebits(i4); + + f1 = frexp(f1_, f1); f2 = frexp(f2_, f2); f3 = frexp(f3_, f3); f4 = frexp(f4_, f4); + f1 = ldexp(f1, i1); f2 = ldexp(f2, i2); f3 = ldexp(f3, i3); f4 = ldexp(f4, i4); +#endif + + + float4x4 f4x4; + f4x4[0] = float4(0.0, 1.0/Pos.x, 2.0/Pos.y, 3.0); + f4x4[1] = float4(0.0, 1.0/Pos.x, 2.0/Pos.y, 3.0); + f4x4[2] = float4(0.0, 1.0/Pos.x, 2.0/Pos.y, 3.0); + f4x4[3] = float4(0.0, 1.0/Pos.x, 2.0/Pos.y, 3.0); + f4x4 = transpose(f4x4); + f1 = determinant( f4x4 ); + + float3x3 f3x3; + f3x3[0] = float3(0.0, 1.0/Pos.x, 2.0/Pos.y); + f3x3[1] = float3(0.0, 1.0/Pos.x, 2.0/Pos.y); + f3x3[2] = float3(0.0, 1.0/Pos.x, 2.0/Pos.y); + f3x3 = transpose(f3x3); + f1 = determinant( f3x3 ); + + float2x2 f2x2; + f2x2[0] = float2(0.0, 1.0/Pos.x); + f2x2[1] = float2(0.0, 1.0/Pos.x); + f2x2 = transpose(f2x2); + f1 = determinant( f2x2 ); + + f1 = ddx( Pos.x ); f2 = ddx( Pos.xy ); f3 = ddx( Pos.xyz ); f4 = ddx( Pos.xyzw ); + f1 = ddy( Pos.x ); f2 = ddy( Pos.xy ); f3 = ddy( Pos.xyz ); f4 = ddy( Pos.xyzw ); + f1 = ddx_coarse( Pos.x ); f2 = ddx_coarse( Pos.xy ); f3 = ddx_coarse( Pos.xyz ); f4 = ddx_coarse( Pos.xyzw ); + f1 = ddy_coarse( Pos.x ); f2 = ddy_coarse( Pos.xy ); f3 = ddy_coarse( Pos.xyz ); f4 = ddy_coarse( Pos.xyzw ); + f1 = ddx_fine( Pos.x ); f2 = ddx_fine( Pos.xy ); f3 = ddx_fine( Pos.xyz ); f4 = ddx_fine( Pos.xyzw ); + f1 = ddy_fine( Pos.x ); f2 = ddy_fine( Pos.xy ); f3 = ddy_fine( Pos.xyz ); f4 = ddy_fine( Pos.xyzw ); +#ifdef FRAGMENT_SHADER + f1 = fwidth( Pos.x ); f2 = fwidth( Pos.xy ); f3 = fwidth( Pos.xyz ); f4 = fwidth( Pos.xyzw ); +#endif + + f1 = asfloat( f1 ); f2 = asfloat( f2 ); f3 = asfloat( f3 ); f4 = asfloat( f4 ); + f1 = asfloat( i1 ); f2 = asfloat( i2 ); f3 = asfloat( i3 ); f4 = asfloat( i4 ); + f1 = asfloat( u1 ); f2 = asfloat( u2 ); f3 = asfloat( u3 ); f4 = asfloat( u4 ); + + i1 = asint( f1 ); i2 = asint( f2 ); i3 = asint( f3 ); i4 = asint( f4 ); + i1 = asint( i1 ); i2 = asint( i2 ); i3 = asint( i3 ); i4 = asint( i4 ); + i1 = asint( u1 ); i2 = asint( u2 ); i3 = asint( u3 ); i4 = asint( u4 ); + + u1 = asuint( f1 ); u2 = asuint( f2 ); u3 = asuint( f3 ); u4 = asuint( f4 ); + u1 = asuint( i1 ); u2 = asuint( i2 ); u3 = asuint( i3 ); u4 = asuint( i4 ); + u1 = asuint( u1 ); u2 = asuint( u2 ); u3 = asuint( u3 ); u4 = asuint( u4 ); + +#if defined(GL_ES) && (__VERSION__>=310) || !defined(GL_ES) && (__VERSION__>=420) + f1 = f16tof32( u1 ); f2 = f16tof32( u2 ); f3 = f16tof32( u3 ); f4 = f16tof32( u4 ); + f1 = f16tof32( i1 ); f2 = f16tof32( i2 ); f3 = f16tof32( i3 ); f4 = f16tof32( i4 ); + u1 = f32tof16( f1 ); u2 = f32tof16( f2 ); u3 = f32tof16( f3 ); u4 = f32tof16( f4 ); +#endif + +#ifndef GL_ES + double d = asdouble( u1, u1 ); +#endif + } +} diff --git a/Tests/DiligentCoreAPITest/assets/shaders/ShaderResourceArrayTest.psh b/Tests/DiligentCoreAPITest/assets/shaders/ShaderResourceArrayTest.psh new file mode 100644 index 00000000..51f570c1 --- /dev/null +++ b/Tests/DiligentCoreAPITest/assets/shaders/ShaderResourceArrayTest.psh @@ -0,0 +1,31 @@ + +Texture2D g_tex2DTest[4]; +Texture2D g_tex2DTest2[2]; +Texture2D g_tex2D[2]; +SamplerState g_tex2DTest_sampler[4]; +SamplerState g_tex2DTest2_sampler; +SamplerState g_tex2D_sampler[2]; + +struct VSOut +{ + float2 f2UV : UV; +}; + + +void main(in float4 f4Position : SV_Position, + in VSOut vsOut, + out float4 Color : SV_Target) +{ + float4 Color0 = (g_tex2DTest[0].SampleLevel(g_tex2DTest_sampler[0], vsOut.f2UV, 0) + g_tex2DTest2[0].SampleLevel(g_tex2DTest2_sampler, vsOut.f2UV, 0))/2.0; + float4 Color1 = (g_tex2DTest[0].SampleLevel(g_tex2DTest_sampler[0], vsOut.f2UV, 2) + g_tex2DTest2[1].SampleLevel(g_tex2DTest2_sampler, vsOut.f2UV, 0))/2.0; + float4 Color2 = (g_tex2DTest[2].SampleLevel(g_tex2DTest_sampler[2], vsOut.f2UV, 4) + g_tex2D[0].SampleLevel(g_tex2D_sampler[0], vsOut.f2UV, 0))/2.0; + float4 Color3 = (g_tex2DTest[3].SampleLevel(g_tex2DTest_sampler[3], vsOut.f2UV, 5) + g_tex2D[1].SampleLevel(g_tex2D_sampler[1], vsOut.f2UV, 0))/2.0; + if( vsOut.f2UV.x < 0.5 && vsOut.f2UV.y < 0.5 ) + Color = Color0; + else if( vsOut.f2UV.x > 0.5 && vsOut.f2UV.y < 0.5 ) + Color = Color1; + else if( vsOut.f2UV.x < 0.5 && vsOut.f2UV.y > 0.5 ) + Color = Color2; + else + Color = Color3; +} diff --git a/Tests/DiligentCoreAPITest/assets/shaders/ShaderResourceArrayTest.vsh b/Tests/DiligentCoreAPITest/assets/shaders/ShaderResourceArrayTest.vsh new file mode 100644 index 00000000..b244a512 --- /dev/null +++ b/Tests/DiligentCoreAPITest/assets/shaders/ShaderResourceArrayTest.vsh @@ -0,0 +1,15 @@ +struct VSOut +{ + float2 f2UV : UV; +}; + +void main(in float3 f3Position : ATTRIB0, + in float2 f2UV : ATTRIB1, + out float4 f4Position : SV_Position, + out VSOut vsOut) +{ + f4Position.xyz = f3Position; + //Out.f4Position.x += In.fOffset; + f4Position.w = 1.0; + vsOut.f2UV = f2UV; +} diff --git a/Tests/DiligentCoreAPITest/assets/shaders/ShaderResourceLayout/ConstantBuffers.hlsl b/Tests/DiligentCoreAPITest/assets/shaders/ShaderResourceLayout/ConstantBuffers.hlsl new file mode 100644 index 00000000..1a578bd6 --- /dev/null +++ b/Tests/DiligentCoreAPITest/assets/shaders/ShaderResourceLayout/ConstantBuffers.hlsl @@ -0,0 +1,67 @@ +cbuffer UniformBuff_Stat +{ + float4 g_Data_Stat; +} + +cbuffer UniformBuff_Mut +{ + float4 g_Data_Mut; +} + +cbuffer UniformBuff_Dyn +{ + float4 g_Data_Dyn; +} + +#if ARRAYS_SUPPORTED +struct CBData +{ + float4 Data; +}; +ConstantBuffer UniformBuffArr_Stat[STATIC_CB_ARRAY_SIZE]; // 2 +ConstantBuffer UniformBuffArr_Mut [MUTABLE_CB_ARRAY_SIZE]; // 4 +ConstantBuffer UniformBuffArr_Dyn [DYNAMIC_CB_ARRAY_SIZE]; // 3 +#endif + +float4 UseResources() +{ + float4 f4Color = float4(0.0, 0.0, 0.0, 0.0); + f4Color += g_Data_Stat; + f4Color += g_Data_Mut; + f4Color += g_Data_Dyn; + + // glslang is not smart enough to unroll the loops even when explicitly told to do so +#if ARRAYS_SUPPORTED + f4Color += UniformBuffArr_Stat[0].Data; + f4Color += UniformBuffArr_Stat[1].Data; + + f4Color += UniformBuffArr_Mut[0].Data; +#if MUTABLE_CB_ARRAY_SIZE == 4 + f4Color += UniformBuffArr_Mut[1].Data; + f4Color += UniformBuffArr_Mut[2].Data; + f4Color += UniformBuffArr_Mut[3].Data; +#endif + + f4Color += UniformBuffArr_Dyn[0].Data; +#if DYNAMIC_CB_ARRAY_SIZE == 3 + f4Color += UniformBuffArr_Dyn[1].Data; + f4Color += UniformBuffArr_Dyn[2].Data; +#endif + +#endif + + return f4Color; +} + +void VSMain(out float4 f4Color : COLOR, + out float4 f4Position : SV_Position) +{ + f4Color = UseResources(); + f4Position = float4(0.0, 0.0, 0.0, 1.0); +} + +float4 PSMain(in float4 in_f4Color : COLOR, + in float4 f4Position : SV_Position) : SV_Target +{ + return in_f4Color + UseResources(); +} diff --git a/Tests/DiligentCoreAPITest/assets/shaders/ShaderResourceLayout/FormattedBuffers.hlsl b/Tests/DiligentCoreAPITest/assets/shaders/ShaderResourceLayout/FormattedBuffers.hlsl new file mode 100644 index 00000000..a32ae31c --- /dev/null +++ b/Tests/DiligentCoreAPITest/assets/shaders/ShaderResourceLayout/FormattedBuffers.hlsl @@ -0,0 +1,44 @@ +Buffer g_Buff_Static; +Buffer g_Buff_Mut; +Buffer g_Buff_Dyn; + +Buffer g_BuffArr_Static[STATIC_BUFF_ARRAY_SIZE]; // 4 +Buffer g_BuffArr_Mut [MUTABLE_BUFF_ARRAY_SIZE]; // 3 +Buffer g_BuffArr_Dyn [DYNAMIC_BUFF_ARRAY_SIZE]; // 2 + +float4 UseResources() +{ + float4 f4Color = float4(0.0, 0.0, 0.0, 0.0); + f4Color += g_Buff_Static.Load(0); + f4Color += g_Buff_Mut. Load(0); + f4Color += g_Buff_Dyn. Load(0); + + // glslang is not smart enough to unroll the loops even when explicitly told to do so + + f4Color += g_BuffArr_Static[0].Load(0); + f4Color += g_BuffArr_Static[1].Load(0); + f4Color += g_BuffArr_Static[2].Load(0); + f4Color += g_BuffArr_Static[3].Load(0); + + f4Color += g_BuffArr_Mut[0].Load(0); + f4Color += g_BuffArr_Mut[1].Load(0); + f4Color += g_BuffArr_Mut[2].Load(0); + + f4Color += g_BuffArr_Dyn[0].Load(0); + f4Color += g_BuffArr_Dyn[1].Load(0); + + return f4Color; +} + +void VSMain(out float4 f4Color : COLOR, + out float4 f4Position : SV_Position) +{ + f4Color = UseResources(); + f4Position = float4(0.0, 0.0, 0.0, 1.0); +} + +float4 PSMain(in float4 in_f4Color : COLOR, + in float4 f4Position : SV_Position) : SV_Target +{ + return in_f4Color + UseResources(); +} diff --git a/Tests/DiligentCoreAPITest/assets/shaders/ShaderResourceLayout/RWFormattedBuffers.hlsl b/Tests/DiligentCoreAPITest/assets/shaders/ShaderResourceLayout/RWFormattedBuffers.hlsl new file mode 100644 index 00000000..30e3d321 --- /dev/null +++ b/Tests/DiligentCoreAPITest/assets/shaders/ShaderResourceLayout/RWFormattedBuffers.hlsl @@ -0,0 +1,39 @@ +RWBuffer g_RWBuff_Static; +RWBuffer g_RWBuff_Mut; +RWBuffer g_RWBuff_Dyn; + +RWBuffer g_RWBuffArr_Static[STATIC_BUFF_ARRAY_SIZE]; // 4 or 1 in D3D11 +RWBuffer g_RWBuffArr_Mut [MUTABLE_BUFF_ARRAY_SIZE]; // 3 or 2 in D3D11 +RWBuffer g_RWBuffArr_Dyn [DYNAMIC_BUFF_ARRAY_SIZE]; // 2 + +void UseResources() +{ + float4 f4Data = float4(1.0, 2.0, 3.0, 4.0); + g_RWBuff_Static[0] = f4Data; + g_RWBuff_Mut [0] = f4Data; + g_RWBuff_Dyn [0] = f4Data; + + // glslang is not smart enough to unroll the loops even when explicitly told to do so + + g_RWBuffArr_Static[0][0] = f4Data; +#if (STATIC_BUFF_ARRAY_SIZE == 4) + g_RWBuffArr_Static[1][0] = f4Data; + g_RWBuffArr_Static[2][0] = f4Data; + g_RWBuffArr_Static[3][0] = f4Data; +#endif + + g_RWBuffArr_Mut[0][0] = f4Data; + g_RWBuffArr_Mut[1][0] = f4Data; +#if (MUTABLE_BUFF_ARRAY_SIZE == 3) + g_RWBuffArr_Mut[2][0] = f4Data; +#endif + + g_RWBuffArr_Dyn[0][0] = f4Data; + g_RWBuffArr_Dyn[1][0] = f4Data; +} + +[numthreads(1,1,1)] +void main() +{ + UseResources(); +} diff --git a/Tests/DiligentCoreAPITest/assets/shaders/ShaderResourceLayout/RWStructuredBuffers.glsl b/Tests/DiligentCoreAPITest/assets/shaders/ShaderResourceLayout/RWStructuredBuffers.glsl new file mode 100644 index 00000000..a4a6c257 --- /dev/null +++ b/Tests/DiligentCoreAPITest/assets/shaders/ShaderResourceLayout/RWStructuredBuffers.glsl @@ -0,0 +1,62 @@ +layout(std140, binding = 0) writeonly buffer g_RWBuff_Static +{ + vec4 data; +}g_StorageBuff_Static; + +layout(std140, binding = 1) writeonly buffer g_RWBuff_Mut +{ + vec4 data; +}g_StorageBuff_Mut; + +layout(std140, binding = 2) writeonly buffer g_RWBuff_Dyn +{ + vec4 data; +}g_StorageBuff_Dyn; + + +layout(std140, binding = 3) writeonly buffer g_RWBuffArr_Static +{ + vec4 data; +}g_StorageBuffArr_Static[STATIC_BUFF_ARRAY_SIZE]; // 4 or 1 in OpenGL + +layout(std140, binding = 7) writeonly buffer g_RWBuffArr_Mut +{ + vec4 data; +}g_StorageBuffArr_Mut[MUTABLE_BUFF_ARRAY_SIZE]; // 3 or 2 in OpenGL + +layout(std140, binding = 10) writeonly buffer g_RWBuffArr_Dyn +{ + vec4 data; +}g_StorageBuffArr_Dyn[DYNAMIC_BUFF_ARRAY_SIZE]; // 2 + +void UseResources() +{ + vec4 Data = vec4(1.0, 2.0, 3.0, 4.0); + g_StorageBuff_Static.data = Data; + g_StorageBuff_Mut .data = Data; + g_StorageBuff_Dyn .data = Data; + + // glslang is not smart enough to unroll the loops even when explicitly told to do so + + g_StorageBuffArr_Static[0].data = Data; +#if (STATIC_BUFF_ARRAY_SIZE == 4) + g_StorageBuffArr_Static[1].data = Data; + g_StorageBuffArr_Static[2].data = Data; + g_StorageBuffArr_Static[3].data = Data; +#endif + + g_StorageBuffArr_Mut[0].data = Data; + g_StorageBuffArr_Mut[1].data = Data; +#if (MUTABLE_BUFF_ARRAY_SIZE == 3) + g_StorageBuffArr_Mut[2].data = Data; +#endif + + g_StorageBuffArr_Dyn[0].data = Data; + g_StorageBuffArr_Dyn[1].data = Data; +} + +layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in; +void main() +{ + UseResources(); +} diff --git a/Tests/DiligentCoreAPITest/assets/shaders/ShaderResourceLayout/RWStructuredBuffers.hlsl b/Tests/DiligentCoreAPITest/assets/shaders/ShaderResourceLayout/RWStructuredBuffers.hlsl new file mode 100644 index 00000000..99e68ca8 --- /dev/null +++ b/Tests/DiligentCoreAPITest/assets/shaders/ShaderResourceLayout/RWStructuredBuffers.hlsl @@ -0,0 +1,44 @@ +struct BufferData +{ + float4 data; +}; + +RWStructuredBuffer g_RWBuff_Static; +RWStructuredBuffer g_RWBuff_Mut; +RWStructuredBuffer g_RWBuff_Dyn; + +RWStructuredBuffer g_RWBuffArr_Static[STATIC_BUFF_ARRAY_SIZE]; // 4 or 1 in D3D11 +RWStructuredBuffer g_RWBuffArr_Mut [MUTABLE_BUFF_ARRAY_SIZE]; // 3 or 2 in D3D11 +RWStructuredBuffer g_RWBuffArr_Dyn [DYNAMIC_BUFF_ARRAY_SIZE]; // 2 + +void UseResources() +{ + float4 f4Data = float4(1.0, 2.0, 3.0, 4.0); + g_RWBuff_Static[0].data = f4Data; + g_RWBuff_Mut [0].data = f4Data; + g_RWBuff_Dyn [0].data = f4Data; + + // glslang is not smart enough to unroll the loops even when explicitly told to do so + + g_RWBuffArr_Static[0][0].data = f4Data; +#if (STATIC_BUFF_ARRAY_SIZE == 4) + g_RWBuffArr_Static[1][0].data = f4Data; + g_RWBuffArr_Static[2][0].data = f4Data; + g_RWBuffArr_Static[3][0].data = f4Data; +#endif + + g_RWBuffArr_Mut[0][0].data = f4Data; + g_RWBuffArr_Mut[1][0].data = f4Data; +#if (MUTABLE_BUFF_ARRAY_SIZE == 3) + g_RWBuffArr_Mut[2][0].data = f4Data; +#endif + + g_RWBuffArr_Dyn[0][0].data = f4Data; + g_RWBuffArr_Dyn[1][0].data = f4Data; +} + +[numthreads(1,1,1)] +void main() +{ + UseResources(); +} diff --git a/Tests/DiligentCoreAPITest/assets/shaders/ShaderResourceLayout/RWTextures.hlsl b/Tests/DiligentCoreAPITest/assets/shaders/ShaderResourceLayout/RWTextures.hlsl new file mode 100644 index 00000000..c11ce380 --- /dev/null +++ b/Tests/DiligentCoreAPITest/assets/shaders/ShaderResourceLayout/RWTextures.hlsl @@ -0,0 +1,39 @@ +RWTexture2D g_RWTex2D_Static; +RWTexture2D g_RWTex2D_Mut; +RWTexture2D g_RWTex2D_Dyn; + +RWTexture2D g_RWTex2DArr_Static[STATIC_TEX_ARRAY_SIZE]; // 2 +RWTexture2D g_RWTex2DArr_Mut [MUTABLE_TEX_ARRAY_SIZE]; // 4 or 2 in D3D11 +RWTexture2D g_RWTex2DArr_Dyn [DYNAMIC_TEX_ARRAY_SIZE]; // 3 or 1 in D3D11 + +void UseResources() +{ + float4 f4Color = float4(1.0, 2.0, 3.0, 4.0); + g_RWTex2D_Static[int2(0,0)] = f4Color; + g_RWTex2D_Mut [int2(0,0)] = f4Color; + g_RWTex2D_Dyn [int2(0,0)] = f4Color; + + // glslang is not smart enough to unroll the loops even when explicitly told to do so + + g_RWTex2DArr_Static[0][int2(0,0)] = f4Color; + g_RWTex2DArr_Static[1][int2(0,0)] = f4Color; + + g_RWTex2DArr_Mut[0][int2(0,0)] = f4Color; + g_RWTex2DArr_Mut[1][int2(0,0)] = f4Color; +#if (MUTABLE_TEX_ARRAY_SIZE == 4) + g_RWTex2DArr_Mut[2][int2(0,0)] = f4Color; + g_RWTex2DArr_Mut[3][int2(0,0)] = f4Color; +#endif + + g_RWTex2DArr_Dyn[0][int2(0,0)] = f4Color; +#if (DYNAMIC_TEX_ARRAY_SIZE == 3) + g_RWTex2DArr_Dyn[1][int2(0,0)] = f4Color; + g_RWTex2DArr_Dyn[2][int2(0,0)] = f4Color; +#endif +} + +[numthreads(1,1,1)] +void main() +{ + UseResources(); +} diff --git a/Tests/DiligentCoreAPITest/assets/shaders/ShaderResourceLayout/Samplers.hlsl b/Tests/DiligentCoreAPITest/assets/shaders/ShaderResourceLayout/Samplers.hlsl new file mode 100644 index 00000000..ad8cbe72 --- /dev/null +++ b/Tests/DiligentCoreAPITest/assets/shaders/ShaderResourceLayout/Samplers.hlsl @@ -0,0 +1,49 @@ +Texture2D g_Tex2D; + +SamplerState g_Sam_Static; +SamplerState g_Sam_Mut; +SamplerState g_Sam_Dyn; + +SamplerState g_SamArr_Static[STATIC_SAM_ARRAY_SIZE]; // 2 +SamplerState g_SamArr_Mut [MUTABLE_SAM_ARRAY_SIZE]; // 4 +SamplerState g_SamArr_Dyn [DYNAMIC_SAM_ARRAY_SIZE]; // 3 + +SamplerState g_Sampler; + +float4 UseResources() +{ + float2 UV = float2(0.0, 0.0); + float4 f4Color = float4(0.0, 0.0, 0.0, 0.0); + f4Color += g_Tex2D.SampleLevel(g_Sam_Static, UV.xy, 0.0); + f4Color += g_Tex2D.SampleLevel(g_Sam_Mut, UV.xy, 0.0); + f4Color += g_Tex2D.SampleLevel(g_Sam_Dyn, UV.xy, 0.0); + + // glslang is not smart enough to unroll the loops even when explicitly told to do so + + f4Color += g_Tex2D.SampleLevel(g_SamArr_Static[0], UV.xy, 0.0); + f4Color += g_Tex2D.SampleLevel(g_SamArr_Static[1], UV.xy, 0.0); + + f4Color += g_Tex2D.SampleLevel(g_SamArr_Mut[0], UV.xy, 0.0); + f4Color += g_Tex2D.SampleLevel(g_SamArr_Mut[1], UV.xy, 0.0); + f4Color += g_Tex2D.SampleLevel(g_SamArr_Mut[2], UV.xy, 0.0); + f4Color += g_Tex2D.SampleLevel(g_SamArr_Mut[3], UV.xy, 0.0); + + f4Color += g_Tex2D.SampleLevel(g_SamArr_Dyn[0], UV.xy, 0.0); + f4Color += g_Tex2D.SampleLevel(g_SamArr_Dyn[1], UV.xy, 0.0); + f4Color += g_Tex2D.SampleLevel(g_SamArr_Dyn[2], UV.xy, 0.0); + + return f4Color; +} + +void VSMain(out float4 f4Color : COLOR, + out float4 f4Position : SV_Position) +{ + f4Color = UseResources(); + f4Position = float4(0.0, 0.0, 0.0, 1.0); +} + +float4 PSMain(in float4 in_f4Color : COLOR, + in float4 f4Position : SV_Position) : SV_Target +{ + return in_f4Color + UseResources(); +} diff --git a/Tests/DiligentCoreAPITest/assets/shaders/ShaderResourceLayout/StaticSamplers.hlsl b/Tests/DiligentCoreAPITest/assets/shaders/ShaderResourceLayout/StaticSamplers.hlsl new file mode 100644 index 00000000..01418379 --- /dev/null +++ b/Tests/DiligentCoreAPITest/assets/shaders/ShaderResourceLayout/StaticSamplers.hlsl @@ -0,0 +1,54 @@ +Texture2D g_Tex2D_Static; +Texture2D g_Tex2D_Mut; +Texture2D g_Tex2D_Dyn; + +Texture2D g_Tex2DArr_Static[STATIC_TEX_ARRAY_SIZE]; // 2 +Texture2D g_Tex2DArr_Mut [MUTABLE_TEX_ARRAY_SIZE]; // 4 +Texture2D g_Tex2DArr_Dyn [DYNAMIC_TEX_ARRAY_SIZE]; // 3 + +SamplerState g_Tex2D_Static_sampler; +SamplerState g_Tex2D_Mut_sampler; +SamplerState g_Tex2D_Dyn_sampler; + +SamplerState g_Tex2DArr_Static_sampler; +SamplerState g_Tex2DArr_Mut_sampler [MUTABLE_TEX_ARRAY_SIZE]; +SamplerState g_Tex2DArr_Dyn_sampler [DYNAMIC_TEX_ARRAY_SIZE]; + + +float4 UseResources() +{ + float2 UV = float2(0.0, 0.0); + float4 f4Color = float4(0.0, 0.0, 0.0, 0.0); + f4Color += g_Tex2D_Static.SampleLevel(g_Tex2D_Static_sampler, UV.xy, 0.0); + f4Color += g_Tex2D_Mut. SampleLevel(g_Tex2D_Mut_sampler, UV.xy, 0.0); + f4Color += g_Tex2D_Dyn. SampleLevel(g_Tex2D_Dyn_sampler, UV.xy, 0.0); + + // glslang is not smart enough to unroll the loops even when explicitly told to do so + + f4Color += g_Tex2DArr_Static[0].SampleLevel(g_Tex2DArr_Static_sampler, UV.xy, 0.0); + f4Color += g_Tex2DArr_Static[1].SampleLevel(g_Tex2DArr_Static_sampler, UV.xy, 0.0); + + f4Color += g_Tex2DArr_Mut[0].SampleLevel(g_Tex2DArr_Mut_sampler[0], UV.xy, 0.0); + f4Color += g_Tex2DArr_Mut[1].SampleLevel(g_Tex2DArr_Mut_sampler[1], UV.xy, 0.0); + f4Color += g_Tex2DArr_Mut[2].SampleLevel(g_Tex2DArr_Mut_sampler[2], UV.xy, 0.0); + f4Color += g_Tex2DArr_Mut[3].SampleLevel(g_Tex2DArr_Mut_sampler[3], UV.xy, 0.0); + + f4Color += g_Tex2DArr_Dyn[0].SampleLevel(g_Tex2DArr_Dyn_sampler[0], UV.xy, 0.0); + f4Color += g_Tex2DArr_Dyn[1].SampleLevel(g_Tex2DArr_Dyn_sampler[1], UV.xy, 0.0); + f4Color += g_Tex2DArr_Dyn[2].SampleLevel(g_Tex2DArr_Dyn_sampler[2], UV.xy, 0.0); + + return f4Color; +} + +void VSMain(out float4 f4Color : COLOR, + out float4 f4Position : SV_Position) +{ + f4Color = UseResources(); + f4Position = float4(0.0, 0.0, 0.0, 1.0); +} + +float4 PSMain(in float4 in_f4Color : COLOR, + in float4 f4Position : SV_Position) : SV_Target +{ + return in_f4Color + UseResources(); +} diff --git a/Tests/DiligentCoreAPITest/assets/shaders/ShaderResourceLayout/StructuredBuffers.glsl b/Tests/DiligentCoreAPITest/assets/shaders/ShaderResourceLayout/StructuredBuffers.glsl new file mode 100644 index 00000000..91e74cca --- /dev/null +++ b/Tests/DiligentCoreAPITest/assets/shaders/ShaderResourceLayout/StructuredBuffers.glsl @@ -0,0 +1,89 @@ +layout(std140) readonly buffer g_Buff_Static +{ + vec4 data; +}g_StorageBuff_Static; + +layout(std140) readonly buffer g_Buff_Mut +{ + vec4 data; +}g_StorageBuff_Mut; + +layout(std140) readonly buffer g_Buff_Dyn +{ + vec4 data; +}g_StorageBuff_Dyn; + + +#ifdef FRAGMENT_SHADER +// Vulkan only allows 16 dynamic storage buffer bindings among all stages, so +// use arrays only in fragment shader +layout(std140) readonly buffer g_BuffArr_Static +{ + vec4 data; +}g_StorageBuffArr_Static[STATIC_BUFF_ARRAY_SIZE]; // 4 + +layout(std140) readonly buffer g_BuffArr_Mut +{ + vec4 data; +}g_StorageBuffArr_Mut[MUTABLE_BUFF_ARRAY_SIZE]; // 3 + +layout(std140) readonly buffer g_BuffArr_Dyn +{ + vec4 data; +}g_StorageBuffArr_Dyn[DYNAMIC_BUFF_ARRAY_SIZE]; // 2 +#endif + +vec4 UseResources() +{ + vec4 f4Color = vec4(0.0, 0.0, 0.0, 0.0); + f4Color += g_StorageBuff_Static.data; + f4Color += g_StorageBuff_Mut .data; + f4Color += g_StorageBuff_Dyn .data; + + // glslang is not smart enough to unroll the loops even when explicitly told to do so +#ifdef FRAGMENT_SHADER + f4Color += g_StorageBuffArr_Static[0].data; + f4Color += g_StorageBuffArr_Static[1].data; + f4Color += g_StorageBuffArr_Static[2].data; + f4Color += g_StorageBuffArr_Static[3].data; + + f4Color += g_StorageBuffArr_Mut[0].data; + f4Color += g_StorageBuffArr_Mut[1].data; + f4Color += g_StorageBuffArr_Mut[2].data; + + f4Color += g_StorageBuffArr_Dyn[0].data; + f4Color += g_StorageBuffArr_Dyn[1].data; +#endif + return f4Color; +} + +#ifdef VERTEX_SHADER + +//To use any built-in input or output in the gl_PerVertex and +//gl_PerFragment blocks in separable program objects, shader code must +//redeclare those blocks prior to use. +// +// Declaring this block causes compilation error on NVidia GLES +#ifndef GL_ES +out gl_PerVertex +{ + vec4 gl_Position; +}; +#endif + +layout(location = 0)out vec4 out_Color; +void main() +{ + out_Color = UseResources(); + gl_Position = vec4(0.0, 0.0, 0.0, 1.0); +} +#endif + +#ifdef FRAGMENT_SHADER +layout(location = 0)in vec4 in_Color; +layout(location = 0)out vec4 out_Color; +void main() +{ + out_Color = UseResources(); +} +#endif diff --git a/Tests/DiligentCoreAPITest/assets/shaders/ShaderResourceLayout/StructuredBuffers.hlsl b/Tests/DiligentCoreAPITest/assets/shaders/ShaderResourceLayout/StructuredBuffers.hlsl new file mode 100644 index 00000000..ad02a84c --- /dev/null +++ b/Tests/DiligentCoreAPITest/assets/shaders/ShaderResourceLayout/StructuredBuffers.hlsl @@ -0,0 +1,49 @@ +struct BufferData +{ + float4 data; +}; + +StructuredBuffer g_Buff_Static; +StructuredBuffer g_Buff_Mut; +StructuredBuffer g_Buff_Dyn; + +StructuredBuffer g_BuffArr_Static[STATIC_BUFF_ARRAY_SIZE]; // 4 +StructuredBuffer g_BuffArr_Mut [MUTABLE_BUFF_ARRAY_SIZE]; // 3 +StructuredBuffer g_BuffArr_Dyn [DYNAMIC_BUFF_ARRAY_SIZE]; // 2 + +float4 UseResources() +{ + float4 f4Color = float4(0.0, 0.0, 0.0, 0.0); + f4Color += g_Buff_Static[0].data; + f4Color += g_Buff_Mut [0].data; + f4Color += g_Buff_Dyn [0].data; + + // glslang is not smart enough to unroll the loops even when explicitly told to do so + + f4Color += g_BuffArr_Static[0][0].data; + f4Color += g_BuffArr_Static[1][0].data; + f4Color += g_BuffArr_Static[2][0].data; + f4Color += g_BuffArr_Static[3][0].data; + + f4Color += g_BuffArr_Mut[0][0].data; + f4Color += g_BuffArr_Mut[1][0].data; + f4Color += g_BuffArr_Mut[2][0].data; + + f4Color += g_BuffArr_Dyn[0][0].data; + f4Color += g_BuffArr_Dyn[1][0].data; + + return f4Color; +} + +void VSMain(out float4 f4Color : COLOR, + out float4 f4Position : SV_Position) +{ + f4Color = UseResources(); + f4Position = float4(0.0, 0.0, 0.0, 1.0); +} + +float4 PSMain(in float4 in_f4Color : COLOR, + in float4 f4Position : SV_Position) : SV_Target +{ + return in_f4Color + UseResources(); +} diff --git a/Tests/DiligentCoreAPITest/assets/shaders/ShaderResourceLayout/Textures.hlsl b/Tests/DiligentCoreAPITest/assets/shaders/ShaderResourceLayout/Textures.hlsl new file mode 100644 index 00000000..5f9ed026 --- /dev/null +++ b/Tests/DiligentCoreAPITest/assets/shaders/ShaderResourceLayout/Textures.hlsl @@ -0,0 +1,47 @@ +Texture2D g_Tex2D_Static; +Texture2D g_Tex2D_Mut; +Texture2D g_Tex2D_Dyn; + +Texture2D g_Tex2DArr_Static[STATIC_TEX_ARRAY_SIZE]; // 2 +Texture2D g_Tex2DArr_Mut [MUTABLE_TEX_ARRAY_SIZE]; // 4 +Texture2D g_Tex2DArr_Dyn [DYNAMIC_TEX_ARRAY_SIZE]; // 3 + +SamplerState g_Sampler; + +float4 UseResources() +{ + float2 UV = float2(0.0, 0.0); + float4 f4Color = float4(0.0, 0.0, 0.0, 0.0); + f4Color += g_Tex2D_Static.SampleLevel(g_Sampler, UV.xy, 0.0); + f4Color += g_Tex2D_Mut. SampleLevel(g_Sampler, UV.xy, 0.0); + f4Color += g_Tex2D_Dyn. SampleLevel(g_Sampler, UV.xy, 0.0); + + // glslang is not smart enough to unroll the loops even when explicitly told to do so + + f4Color += g_Tex2DArr_Static[0].SampleLevel(g_Sampler, UV.xy, 0.0); + f4Color += g_Tex2DArr_Static[1].SampleLevel(g_Sampler, UV.xy, 0.0); + + f4Color += g_Tex2DArr_Mut[0].SampleLevel(g_Sampler, UV.xy, 0.0); + f4Color += g_Tex2DArr_Mut[1].SampleLevel(g_Sampler, UV.xy, 0.0); + f4Color += g_Tex2DArr_Mut[2].SampleLevel(g_Sampler, UV.xy, 0.0); + f4Color += g_Tex2DArr_Mut[3].SampleLevel(g_Sampler, UV.xy, 0.0); + + f4Color += g_Tex2DArr_Dyn[0].SampleLevel(g_Sampler, UV.xy, 0.0); + f4Color += g_Tex2DArr_Dyn[1].SampleLevel(g_Sampler, UV.xy, 0.0); + f4Color += g_Tex2DArr_Dyn[2].SampleLevel(g_Sampler, UV.xy, 0.0); + + return f4Color; +} + +void VSMain(out float4 f4Color : COLOR, + out float4 f4Position : SV_Position) +{ + f4Color = UseResources(); + f4Position = float4(0.0, 0.0, 0.0, 1.0); +} + +float4 PSMain(in float4 in_f4Color : COLOR, + in float4 f4Position : SV_Position) : SV_Target +{ + return in_f4Color + UseResources(); +} diff --git a/Tests/DiligentCoreAPITest/assets/shaders/ShaderVariableAccessTestDX.psh b/Tests/DiligentCoreAPITest/assets/shaders/ShaderVariableAccessTestDX.psh new file mode 100644 index 00000000..fff038ed --- /dev/null +++ b/Tests/DiligentCoreAPITest/assets/shaders/ShaderVariableAccessTestDX.psh @@ -0,0 +1,79 @@ +Texture2D g_tex2D_Static; +Texture2D g_tex2D_Mut; +Texture2D g_tex2D_MutArr[2]; +Texture2D g_tex2D_Dyn; +Texture2D g_tex2D_DynArr[2]; +Texture2D g_tex2D_StaticArr[2]; + +SamplerState g_tex2D_Static_sampler; +SamplerState g_tex2D_Mut_sampler; +SamplerState g_tex2D_Dyn_sampler; +SamplerState g_tex2D_MutArr_sampler; +SamplerState g_tex2D_DynArr_sampler; +SamplerState g_tex2D_StaticArr_sampler; + +cbuffer UniformBuff_Stat +{ + float4 g_f4Color0; +} + +cbuffer UniformBuff_Stat2 +{ + float4 g_f4Color01; +} + +cbuffer UniformBuff_Mut +{ + float4 g_f4Color1; +} + +cbuffer UniformBuff_Dyn +{ + float4 g_f4Color2; +} + +RWTexture2D g_rwtex2D_Static; +RWTexture2D g_rwtex2D_Static2; +RWTexture2D g_rwtex2D_Mut; +RWTexture2D g_rwtex2D_Dyn; + +RWByteAddressBuffer g_rwBuff_Static; +RWBuffer g_rwBuff_Mut; +RWBuffer g_rwBuff_Dyn; + +Buffer g_Buffer_Static; +Buffer g_Buffer_StaticArr[2]; +ByteAddressBuffer g_Buffer_Mut; +Buffer g_Buffer_MutArr[2]; +Buffer g_Buffer_Dyn; +Buffer g_Buffer_DynArr[2]; + +struct VSOut +{ + float4 f4Position : SV_Position; + float4 f4Color : COLOR; +}; + + +float4 main(VSOut In) : SV_Target +{ + float4 Color = In.f4Color; + Color += g_tex2D_Static.SampleLevel(g_tex2D_Static_sampler, float2(0.5,0.5), 0.0); + Color += g_tex2D_StaticArr[0].SampleLevel(g_tex2D_StaticArr_sampler, float2(0.5,0.5), 0.0) + g_tex2D_StaticArr[1].SampleLevel(g_tex2D_StaticArr_sampler, float2(0.5,0.5), 0.0); + Color += g_tex2D_Mut.SampleLevel(g_tex2D_Mut_sampler, float2(0.5,0.5), 0.0); + Color += g_tex2D_MutArr[0].SampleLevel(g_tex2D_MutArr_sampler, float2(0.5,0.5), 0.0) + g_tex2D_MutArr[1].SampleLevel(g_tex2D_MutArr_sampler, float2(0.5,0.5), 0.0); + Color += g_tex2D_Dyn.SampleLevel(g_tex2D_Dyn_sampler, float2(0.5,0.5), 0.0); + Color += g_tex2D_DynArr[0].SampleLevel(g_tex2D_DynArr_sampler, float2(0.5,0.5), 0.0) + g_tex2D_DynArr[1].SampleLevel(g_tex2D_DynArr_sampler, float2(0.5,0.5), 0.0); + Color += g_f4Color0 + g_f4Color01 + g_f4Color1 + g_f4Color2; + Color += g_rwtex2D_Static.Load(int2(0,0)) + g_rwtex2D_Mut.Load(int2(0,0)) + g_rwtex2D_Dyn.Load(uint2(0,0)) + g_rwtex2D_Static2.Load(uint2(0,0)); + Color += asfloat(g_rwBuff_Static.Load(0)) + g_rwBuff_Mut.Load(0) + g_rwBuff_Dyn.Load(0); + + Color += g_Buffer_Static.Load(0); + Color += g_Buffer_StaticArr[0].Load(0) + g_Buffer_StaticArr[1].Load(0); + Color += asfloat(g_Buffer_Mut.Load(0)); + Color += g_Buffer_MutArr[0].Load(0) + g_Buffer_MutArr[1].Load(0); + Color += g_Buffer_Dyn.Load(0); + Color += g_Buffer_DynArr[0].Load(0) + g_Buffer_DynArr[1].Load(0); + + return Color; +} diff --git a/Tests/DiligentCoreAPITest/assets/shaders/ShaderVariableAccessTestDX.vsh b/Tests/DiligentCoreAPITest/assets/shaders/ShaderVariableAccessTestDX.vsh new file mode 100644 index 00000000..6da62ea5 --- /dev/null +++ b/Tests/DiligentCoreAPITest/assets/shaders/ShaderVariableAccessTestDX.vsh @@ -0,0 +1,69 @@ +Texture2D g_tex2D_Static; +Texture2D g_tex2D_StaticArr[2]; +Texture2D g_tex2D_Mut; +Texture2D g_tex2D_MutArr[2]; +Texture2D g_tex2D_Dyn; +Texture2D g_tex2D_DynArr[2]; + +SamplerState g_tex2D_Static_sampler; +SamplerState g_tex2D_StaticArr_sampler; +SamplerState g_tex2D_Mut_sampler; +SamplerState g_tex2D_MutArr_sampler; +SamplerState g_tex2D_Dyn_sampler; +SamplerState g_tex2D_DynArr_sampler; + +cbuffer UniformBuff_Stat +{ + float4 g_f4Color0; +} + +cbuffer UniformBuff_Stat2 +{ + float4 g_f4Color01; +} + +cbuffer UniformBuff_Mut +{ + float4 g_f4Color1; +} + +cbuffer UniformBuff_Dyn +{ + float4 g_f4Color2; +} + +Buffer g_Buffer_Static; +Buffer g_Buffer_StaticArr[2]; +Buffer g_Buffer_Mut; +Buffer g_Buffer_MutArr[2]; +Buffer g_Buffer_Dyn; +Buffer g_Buffer_DynArr[2]; + +struct VSOut +{ + float4 f4Position : SV_Position; + float4 f4Color : COLOR; +}; + + +VSOut main() +{ + VSOut Out; + Out.f4Position = float4(0.0, 0.0, 0.0, 0.0); + Out.f4Color = float4(0.0, 0.0, 0.0, 0.0); + Out.f4Color += g_tex2D_Static.SampleLevel(g_tex2D_Static_sampler, float2(0.5,0.5), 0.0); + Out.f4Color += g_tex2D_StaticArr[0].SampleLevel(g_tex2D_StaticArr_sampler, float2(0.5,0.5), 0.0) + g_tex2D_StaticArr[1].SampleLevel(g_tex2D_StaticArr_sampler, float2(0.5,0.5), 0.0); + Out.f4Color += g_tex2D_Mut.SampleLevel(g_tex2D_Mut_sampler, float2(0.5,0.5), 0.0); + Out.f4Color += g_tex2D_MutArr[0].SampleLevel(g_tex2D_MutArr_sampler, float2(0.5,0.5), 0.0) + g_tex2D_MutArr[1].SampleLevel(g_tex2D_MutArr_sampler, float2(0.5,0.5), 0.0); + Out.f4Color += g_tex2D_Dyn.SampleLevel(g_tex2D_Dyn_sampler, float2(0.5,0.5), 0.0); + Out.f4Color += g_tex2D_DynArr[0].SampleLevel(g_tex2D_DynArr_sampler, float2(0.5,0.5), 0.0) + g_tex2D_DynArr[1].SampleLevel(g_tex2D_DynArr_sampler, float2(0.5,0.5), 0.0); + Out.f4Color += g_f4Color0 + g_f4Color01 + g_f4Color1 + g_f4Color2; + Out.f4Color += g_Buffer_Static.Load(0); + Out.f4Color += g_Buffer_StaticArr[0].Load(0) + g_Buffer_StaticArr[1].Load(0); + Out.f4Color += g_Buffer_Mut.Load(0); + Out.f4Color += g_Buffer_MutArr[0].Load(0) + g_Buffer_MutArr[1].Load(0); + Out.f4Color += g_Buffer_Dyn.Load(0); + Out.f4Color += g_Buffer_DynArr[0].Load(0) + g_Buffer_DynArr[1].Load(0); + + return Out; +} diff --git a/Tests/DiligentCoreAPITest/assets/shaders/ShaderVariableAccessTestGL.psh b/Tests/DiligentCoreAPITest/assets/shaders/ShaderVariableAccessTestGL.psh new file mode 100644 index 00000000..52147e25 --- /dev/null +++ b/Tests/DiligentCoreAPITest/assets/shaders/ShaderVariableAccessTestGL.psh @@ -0,0 +1,78 @@ +uniform sampler2D g_tex2D_Static; +uniform sampler2D g_tex2D_Mut; +uniform sampler2D g_tex2D_MutArr[2]; +uniform sampler2D g_tex2D_Dyn; +uniform sampler2D g_tex2D_DynArr[2]; +uniform sampler2D g_tex2D_StaticArr[2]; + +uniform UniformBuff_Stat +{ + vec4 g_f4Color0; +}g_UniformBuff_Stat; + +uniform UniformBuff_Stat2 +{ + vec4 g_f4Color01; +}g_UniformBuff_Stat2; + +uniform UniformBuff_Mut +{ + vec4 g_f4Color1; +}g_UniformBuff_Mut; + +uniform UniformBuff_Dyn +{ + vec4 g_f4Color2; +}g_UniformBuff_Dyn; + +layout(rgba32f) uniform readonly image2D g_rwtex2D_Static; +layout(rgba32f) uniform readonly image2D g_rwtex2D_Static2; +layout(rgba32f) uniform readonly image2D g_rwtex2D_Mut; +layout(rgba32f) uniform readonly image2D g_rwtex2D_Dyn; + +layout(std140) buffer g_rwBuff_Static +{ + vec4 data[]; +}rwBuff_Static; + +layout(std140) buffer g_rwBuff_Mut +{ + vec4 data[]; +}rwBuff_Mut; + +layout(std140) buffer g_rwBuff_Dyn +{ + vec4 data[]; +}rwBuff_Dyn; + +uniform samplerBuffer g_Buffer_Static; +uniform samplerBuffer g_Buffer_StaticArr[2]; +uniform usamplerBuffer g_Buffer_Mut; +uniform samplerBuffer g_Buffer_MutArr[2]; +uniform samplerBuffer g_Buffer_Dyn; +uniform samplerBuffer g_Buffer_DynArr[2]; + +layout(location = 0) in vec4 f4Color; + +layout(location = 0) out vec4 out_Color; + +void main() +{ + out_Color = f4Color; + out_Color += textureLod(g_tex2D_Static, vec2(0.5,0.5), 0.0); + out_Color += textureLod(g_tex2D_StaticArr[0], vec2(0.5,0.5), 0.0) + textureLod(g_tex2D_StaticArr[1], vec2(0.5,0.5), 0.0); + out_Color += textureLod(g_tex2D_Mut, vec2(0.5,0.5), 0.0); + out_Color += textureLod(g_tex2D_MutArr[0], vec2(0.5,0.5), 0.0) + textureLod(g_tex2D_MutArr[1], vec2(0.5,0.5), 0.0); + out_Color += textureLod(g_tex2D_Dyn, vec2(0.5,0.5), 0.0); + out_Color += textureLod(g_tex2D_DynArr[0], vec2(0.5,0.5), 0.0) + textureLod(g_tex2D_DynArr[1], vec2(0.5,0.5), 0.0); + out_Color += g_UniformBuff_Stat.g_f4Color0 + g_UniformBuff_Stat2.g_f4Color01 + g_UniformBuff_Mut.g_f4Color1 + g_UniformBuff_Dyn.g_f4Color2; + out_Color += imageLoad(g_rwtex2D_Static, ivec2(0,0)) + imageLoad(g_rwtex2D_Mut, ivec2(0,0)) + imageLoad(g_rwtex2D_Dyn, ivec2(0,0)) + imageLoad(g_rwtex2D_Static2, ivec2(0,0)); + out_Color += rwBuff_Static.data[0] + rwBuff_Mut.data[0] + rwBuff_Dyn.data[0]; + + out_Color += texelFetch(g_Buffer_Static, 0); + out_Color += texelFetch(g_Buffer_StaticArr[0], 0) + texelFetch(g_Buffer_StaticArr[1],0); + out_Color += texelFetch(g_Buffer_Mut, 0); + out_Color += texelFetch(g_Buffer_MutArr[0], 0) + texelFetch(g_Buffer_MutArr[1], 0); + out_Color += texelFetch(g_Buffer_Dyn, 0); + out_Color += texelFetch(g_Buffer_DynArr[0], 0) + texelFetch(g_Buffer_DynArr[1], 0); +} diff --git a/Tests/DiligentCoreAPITest/assets/shaders/ShaderVariableAccessTestGL.vsh b/Tests/DiligentCoreAPITest/assets/shaders/ShaderVariableAccessTestGL.vsh new file mode 100644 index 00000000..83e38c2e --- /dev/null +++ b/Tests/DiligentCoreAPITest/assets/shaders/ShaderVariableAccessTestGL.vsh @@ -0,0 +1,61 @@ +uniform sampler2D g_tex2D_Static; +uniform sampler2D g_tex2D_StaticArr[2]; +uniform sampler2D g_tex2D_Mut; +uniform sampler2D g_tex2D_MutArr[2]; +uniform sampler2D g_tex2D_Dyn; +uniform sampler2D g_tex2D_DynArr[2]; + +uniform UniformBuff_Stat +{ + vec4 g_f4Color0; +}g_UniformBuff_Stat; + +uniform UniformBuff_Stat2 +{ + vec4 g_f4Color01; +}g_UniformBuff_Stat2; + +uniform UniformBuff_Mut +{ + vec4 g_f4Color1; +}g_UniformBuff_Mut; + +uniform UniformBuff_Dyn +{ + vec4 g_f4Color2; +}g_UniformBuff_Dyn; + +uniform samplerBuffer g_Buffer_Static; +uniform samplerBuffer g_Buffer_StaticArr[2]; +uniform samplerBuffer g_Buffer_Mut; +uniform samplerBuffer g_Buffer_MutArr[2]; +uniform samplerBuffer g_Buffer_Dyn; +uniform samplerBuffer g_Buffer_DynArr[2]; + +layout(location = 0) out vec4 f4Color; + +#ifndef GL_ES +out gl_PerVertex +{ + vec4 gl_Position; +}; +#endif + +void main() +{ + gl_Position = vec4(0.0, 0.0, 0.0, 0.0); + f4Color = vec4(0.0, 0.0, 0.0, 0.0); + f4Color += textureLod(g_tex2D_Static, vec2(0.5,0.5), 0.0); + f4Color += textureLod(g_tex2D_StaticArr[0], vec2(0.5,0.5), 0.0) + textureLod(g_tex2D_StaticArr[1], vec2(0.5,0.5), 0.0); + f4Color += textureLod(g_tex2D_Mut, vec2(0.5,0.5), 0.0); + f4Color += textureLod(g_tex2D_MutArr[0], vec2(0.5,0.5), 0.0) + textureLod(g_tex2D_MutArr[1], vec2(0.5,0.5), 0.0); + f4Color += textureLod(g_tex2D_Dyn, vec2(0.5,0.5), 0.0); + f4Color += textureLod(g_tex2D_DynArr[0], vec2(0.5,0.5), 0.0) + textureLod(g_tex2D_DynArr[1], vec2(0.5,0.5), 0.0); + f4Color += g_UniformBuff_Stat.g_f4Color0 + g_UniformBuff_Stat2.g_f4Color01 + g_UniformBuff_Mut.g_f4Color1 + g_UniformBuff_Dyn.g_f4Color2; + f4Color += texelFetch(g_Buffer_Static, 0); + f4Color += texelFetch(g_Buffer_StaticArr[0], 0) + texelFetch(g_Buffer_StaticArr[1],0); + f4Color += texelFetch(g_Buffer_Mut, 0); + f4Color += texelFetch(g_Buffer_MutArr[0], 0) + texelFetch(g_Buffer_MutArr[1], 0); + f4Color += texelFetch(g_Buffer_Dyn, 0); + f4Color += texelFetch(g_Buffer_DynArr[0], 0) + texelFetch(g_Buffer_DynArr[1], 0); +} diff --git a/Tests/DiligentCoreAPITest/include/CreateObjFromNativeResTestBase.h b/Tests/DiligentCoreAPITest/include/CreateObjFromNativeResTestBase.h new file mode 100644 index 00000000..4e6bfc25 --- /dev/null +++ b/Tests/DiligentCoreAPITest/include/CreateObjFromNativeResTestBase.h @@ -0,0 +1,55 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#pragma once + +#include "RenderDevice.h" +#include "Texture.h" +#include "Buffer.h" +#include "RefCntAutoPtr.h" + +namespace Diligent +{ + +namespace Testing +{ + +class CreateObjFromNativeResTestBase +{ +public: + CreateObjFromNativeResTestBase(IRenderDevice* pDevice) : + m_pDevice{pDevice} + {} + + virtual ~CreateObjFromNativeResTestBase() {} + + virtual void CreateTexture(ITexture* pTexture) = 0; + virtual void CreateBuffer(IBuffer* pBuffer) = 0; + +protected: + RefCntAutoPtr m_pDevice; +}; + +} // namespace Testing + +} // namespace Diligent diff --git a/Tests/DiligentCoreAPITest/include/D3D11/CreateObjFromNativeResD3D11.h b/Tests/DiligentCoreAPITest/include/D3D11/CreateObjFromNativeResD3D11.h new file mode 100644 index 00000000..579ed6aa --- /dev/null +++ b/Tests/DiligentCoreAPITest/include/D3D11/CreateObjFromNativeResD3D11.h @@ -0,0 +1,47 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#pragma once + +#include "CreateObjFromNativeResTestBase.h" + +namespace Diligent +{ + +namespace Testing +{ + +class TestCreateObjFromNativeResD3D11 : public CreateObjFromNativeResTestBase +{ +public: + TestCreateObjFromNativeResD3D11(IRenderDevice* pDevice) : + CreateObjFromNativeResTestBase(pDevice) + {} + + virtual void CreateTexture(ITexture* pTexture) override final; + virtual void CreateBuffer(IBuffer* pBuffer) override final; +}; + +} // namespace Testing + +} // namespace Diligent diff --git a/Tests/DiligentCoreAPITest/include/D3D11/TestingEnvironmentD3D11.h b/Tests/DiligentCoreAPITest/include/D3D11/TestingEnvironmentD3D11.h new file mode 100644 index 00000000..a42c387b --- /dev/null +++ b/Tests/DiligentCoreAPITest/include/D3D11/TestingEnvironmentD3D11.h @@ -0,0 +1,115 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#pragma once + +#include "TestingEnvironment.h" + +#ifndef NOMINMAX +# define NOMINMAX +#endif + +#include +#include + +namespace Diligent +{ + +namespace Testing +{ + +HRESULT CompileD3DShader(const char* Source, + LPCSTR strFunctionName, + const D3D_SHADER_MACRO* pDefines, + LPCSTR profile, + ID3DBlob** ppBlobOut); + +class TestingEnvironmentD3D11 final : public TestingEnvironment +{ +public: + TestingEnvironmentD3D11(DeviceType deviceType, ADAPTER_TYPE AdapterType, const SwapChainDesc& SCDesc); + + ID3D11Device* GetD3D11Device() + { + return m_pd3d11Device; + } + + ID3D11DeviceContext* GetD3D11Context() + { + return m_pd3d11Context; + } + + ID3D11RasterizerState* GetNoCullRS() + { + return m_pd3d11NoCullRS; + } + + ID3D11DepthStencilState* GetDisableDepthDSS() + { + return m_pd3d11DisableDepthDSS; + } + + ID3D11BlendState* GetDefaultBS() + { + return m_pd3d11DefaultBS; + } + + CComPtr CreateVertexShader(const char* Source, + LPCSTR strFunctionName = "main", + const D3D_SHADER_MACRO* pDefines = nullptr, + LPCSTR profile = "vs_5_0"); + + CComPtr CreatePixelShader(const char* Source, + LPCSTR strFunctionName = "main", + const D3D_SHADER_MACRO* pDefines = nullptr, + LPCSTR profile = "ps_5_0"); + + CComPtr CreateGeometryShader(const char* Source, + LPCSTR strFunctionName = "main", + const D3D_SHADER_MACRO* pDefines = nullptr, + LPCSTR profile = "gs_5_0"); + + CComPtr CreateDomainShader(const char* Source, + LPCSTR strFunctionName = "main", + const D3D_SHADER_MACRO* pDefines = nullptr, + LPCSTR profile = "ds_5_0"); + + CComPtr CreateHullShader(const char* Source, + LPCSTR strFunctionName = "main", + const D3D_SHADER_MACRO* pDefines = nullptr, + LPCSTR profile = "gs_5_0"); + + static TestingEnvironmentD3D11* GetInstance() { return ValidatedCast(TestingEnvironment::GetInstance()); } + +private: + CComPtr m_pd3d11Device; + CComPtr m_pd3d11Context; + + CComPtr m_pd3d11NoCullRS; + CComPtr m_pd3d11DisableDepthDSS; + CComPtr m_pd3d11DefaultBS; +}; + +} // namespace Testing + +} // namespace Diligent diff --git a/Tests/DiligentCoreAPITest/include/D3D11/TestingSwapChainD3D11.h b/Tests/DiligentCoreAPITest/include/D3D11/TestingSwapChainD3D11.h new file mode 100644 index 00000000..33815257 --- /dev/null +++ b/Tests/DiligentCoreAPITest/include/D3D11/TestingSwapChainD3D11.h @@ -0,0 +1,81 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "TestingSwapChainBase.h" + +#ifndef NOMINMAX +# define NOMINMAX +#endif + +#include +#include + +namespace Diligent +{ + +namespace Testing +{ + +class TestingSwapChainD3D11 final : public TestingSwapChainBase +{ +public: + using TBase = TestingSwapChainBase; + TestingSwapChainD3D11(IReferenceCounters* pRefCounters, + IRenderDevice* pDevice, + IDeviceContext* pContext, + const SwapChainDesc& SCDesc); + + virtual void TakeSnapshot() override final; + + ID3D11Texture2D* GetD3D11RenderTarget() + { + return m_pd3d11RenderTarget; + } + + ID3D11Texture2D* GetD3D11DepthBuffer() + { + return m_pd3d11DepthBuffer; + } + + ID3D11RenderTargetView* GetD3D11RTV() + { + return m_pd3d11RTV; + } + + ID3D11DepthStencilView* GetD3D11DSV() + { + return m_pd3d11DSV; + } + +private: + CComPtr m_pd3d11Context; + CComPtr m_pd3d11RenderTarget; + CComPtr m_pd3d11DepthBuffer; + CComPtr m_pd3d11RTV; + CComPtr m_pd3d11DSV; + CComPtr m_pd3d11StagingTex; +}; + +} // namespace Testing + +} // namespace Diligent diff --git a/Tests/DiligentCoreAPITest/include/D3D12/CreateObjFromNativeResD3D12.h b/Tests/DiligentCoreAPITest/include/D3D12/CreateObjFromNativeResD3D12.h new file mode 100644 index 00000000..b00c9676 --- /dev/null +++ b/Tests/DiligentCoreAPITest/include/D3D12/CreateObjFromNativeResD3D12.h @@ -0,0 +1,47 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#pragma once + +#include "CreateObjFromNativeResTestBase.h" + +namespace Diligent +{ + +namespace Testing +{ + +class TestCreateObjFromNativeResD3D12 : public CreateObjFromNativeResTestBase +{ +public: + TestCreateObjFromNativeResD3D12(IRenderDevice* pDevice) : + CreateObjFromNativeResTestBase(pDevice) + {} + + virtual void CreateTexture(ITexture* pTexture) override final; + virtual void CreateBuffer(IBuffer* pBuffer) override final; +}; + +} // namespace Testing + +} // namespace Diligent diff --git a/Tests/DiligentCoreAPITest/include/D3D12/D3D12DebugLayerSetNameBugWorkaround.h b/Tests/DiligentCoreAPITest/include/D3D12/D3D12DebugLayerSetNameBugWorkaround.h new file mode 100644 index 00000000..a2d06acb --- /dev/null +++ b/Tests/DiligentCoreAPITest/include/D3D12/D3D12DebugLayerSetNameBugWorkaround.h @@ -0,0 +1,57 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include + +#include "RenderDevice.h" + +namespace Diligent +{ + +namespace Testing +{ + +// There is a bug in D3D12 debug layer as of build version 10.0.18362: SetName() method +// is not protected by a mutex internally. This, in combination with the fact that root signatures are +// de-duplicated by D3D12 runtime, causes the following problem: +// when multiple threads attempt to create the same root signature, the run-time returns the same +// object. Calling SetName() results in a race condition because multiple threads attempt to resize/write +// to the buffer without a mutex. + +// As a workaround, we create the root signature ahead of time and reserve enough space for the name +// to avoid memory allocation. + +class D3D12DebugLayerSetNameBugWorkaround +{ +public: + explicit D3D12DebugLayerSetNameBugWorkaround(IRenderDevice* pDevice); + ~D3D12DebugLayerSetNameBugWorkaround(); + +private: + struct RootSignatureWrapper; + std::unique_ptr m_RootSignature; +}; + +} // namespace Testing + +} // namespace Diligent diff --git a/Tests/DiligentCoreAPITest/include/D3D12/TestingEnvironmentD3D12.h b/Tests/DiligentCoreAPITest/include/D3D12/TestingEnvironmentD3D12.h new file mode 100644 index 00000000..cdc9ca42 --- /dev/null +++ b/Tests/DiligentCoreAPITest/include/D3D12/TestingEnvironmentD3D12.h @@ -0,0 +1,79 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#pragma once + +#include "TestingEnvironment.h" + +#ifndef NOMINMAX +# define NOMINMAX +#endif + +#include +#include +#include + +namespace Diligent +{ + +namespace Testing +{ + +// Implemented in TestingEnvironmentD3D11.cpp +HRESULT CompileD3DShader(const char* Source, + LPCSTR strFunctionName, + const D3D_SHADER_MACRO* pDefines, + LPCSTR profile, + ID3DBlob** ppBlobOut); + +class TestingEnvironmentD3D12 final : public TestingEnvironment +{ +public: + TestingEnvironmentD3D12(DeviceType deviceType, ADAPTER_TYPE AdapterType, const SwapChainDesc& SCDesc); + ~TestingEnvironmentD3D12(); + + static TestingEnvironmentD3D12* GetInstance() { return ValidatedCast(TestingEnvironment::GetInstance()); } + + ID3D12Device* GetD3D12Device() + { + return m_pd3d12Device; + } + + // The allocator is currently never reset, which is not an issue in this testing system. + CComPtr CreateGraphicsCommandList(); + + void IdleCommandQueue(ID3D12CommandQueue* pd3d12Queue); + +private: + CComPtr m_pd3d12Device; + CComPtr m_pd3d12CmdAllocator; + CComPtr m_pd3d12Fence; + + UINT64 m_NextFenceValue = 1; + + HANDLE m_WaitForGPUEventHandle = {}; +}; + +} // namespace Testing + +} // namespace Diligent diff --git a/Tests/DiligentCoreAPITest/include/D3D12/TestingSwapChainD3D12.h b/Tests/DiligentCoreAPITest/include/D3D12/TestingSwapChainD3D12.h new file mode 100644 index 00000000..3eb1549e --- /dev/null +++ b/Tests/DiligentCoreAPITest/include/D3D12/TestingSwapChainD3D12.h @@ -0,0 +1,87 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "TestingSwapChainBase.h" + +#ifndef NOMINMAX +# define NOMINMAX +#endif + +#include +#include + +namespace Diligent +{ + +namespace Testing +{ + +class TestingSwapChainD3D12 : public TestingSwapChainBase +{ +public: + using TBase = TestingSwapChainBase; + TestingSwapChainD3D12(IReferenceCounters* pRefCounters, + IRenderDevice* pDevice, + IDeviceContext* pContext, + const SwapChainDesc& SCDesc); + + virtual void TakeSnapshot() override final; + + void TransitionRenderTarget(ID3D12GraphicsCommandList* pCmdList, + D3D12_RESOURCE_STATES RTVState); + + void TransitionBuffers(ID3D12GraphicsCommandList* pCmdList, + D3D12_RESOURCE_STATES RTVState, + D3D12_RESOURCE_STATES DSVState); + + D3D12_CPU_DESCRIPTOR_HANDLE GetRTVDescriptorHandle() + { + return m_RTVDescriptorHandle; + } + + D3D12_CPU_DESCRIPTOR_HANDLE GetDSVDescriptorHandle() + { + return m_DSVDescriptorHandle; + } + +private: + CComPtr m_pd3d12RenderTaget; + CComPtr m_pd3d12DepthBuffer; + CComPtr m_pd3d12StagingBuffer; + + CComPtr m_pd3d12RTVDescriptorHeap; + CComPtr m_pd3d12DSVDescriptorHeap; + + D3D12_RESOURCE_STATES m_RenderTargetState = D3D12_RESOURCE_STATE_RENDER_TARGET; + D3D12_RESOURCE_STATES m_DepthBufferState = D3D12_RESOURCE_STATE_DEPTH_WRITE; + + D3D12_CPU_DESCRIPTOR_HANDLE m_RTVDescriptorHandle = {}; + D3D12_CPU_DESCRIPTOR_HANDLE m_DSVDescriptorHandle = {}; + + D3D12_PLACED_SUBRESOURCE_FOOTPRINT m_StagingBufferFootprint = {}; + UINT64 m_StagingBufferSize = 0; +}; + +} // namespace Testing + +} // namespace Diligent diff --git a/Tests/DiligentCoreAPITest/include/GL/CreateObjFromNativeResGL.h b/Tests/DiligentCoreAPITest/include/GL/CreateObjFromNativeResGL.h new file mode 100644 index 00000000..2584e426 --- /dev/null +++ b/Tests/DiligentCoreAPITest/include/GL/CreateObjFromNativeResGL.h @@ -0,0 +1,47 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#pragma once + +#include "CreateObjFromNativeResTestBase.h" + +namespace Diligent +{ + +namespace Testing +{ + +class TestCreateObjFromNativeResGL : public CreateObjFromNativeResTestBase +{ +public: + TestCreateObjFromNativeResGL(IRenderDevice* pDevice) : + CreateObjFromNativeResTestBase(pDevice) + {} + + virtual void CreateTexture(ITexture* pTexture) override final; + virtual void CreateBuffer(IBuffer* pBuffer) override final; +}; + +} // namespace Testing + +} // namespace Diligent \ No newline at end of file diff --git a/Tests/DiligentCoreAPITest/include/GL/TestingEnvironmentGL.h b/Tests/DiligentCoreAPITest/include/GL/TestingEnvironmentGL.h new file mode 100644 index 00000000..306e1d8f --- /dev/null +++ b/Tests/DiligentCoreAPITest/include/GL/TestingEnvironmentGL.h @@ -0,0 +1,62 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#pragma once + +#ifndef GLEW_STATIC +# define GLEW_STATIC // Must be defined to use static version of glew +#endif +#ifndef GLEW_NO_GLU +# define GLEW_NO_GLU +#endif + +#include "GL/glew.h" + +#include "TestingEnvironment.h" + +namespace Diligent +{ + +namespace Testing +{ + +class TestingEnvironmentGL final : public TestingEnvironment +{ +public: + TestingEnvironmentGL(DeviceType deviceType, ADAPTER_TYPE AdapterType, const SwapChainDesc& SCDesc); + ~TestingEnvironmentGL(); + + static TestingEnvironmentGL* GetInstance() { return ValidatedCast(TestingEnvironment::GetInstance()); } + + GLuint CompileGLShader(const char* Source, GLenum ShaderType); + GLuint LinkProgram(GLuint Shaders[], GLuint NumShaders); + + GLuint GetDummyVAO() { return m_DummyVAO; } + +private: + GLuint m_DummyVAO = 0; +}; + +} // namespace Testing + +} // namespace Diligent diff --git a/Tests/DiligentCoreAPITest/include/GL/TestingSwapChainGL.h b/Tests/DiligentCoreAPITest/include/GL/TestingSwapChainGL.h new file mode 100644 index 00000000..fa6c3c37 --- /dev/null +++ b/Tests/DiligentCoreAPITest/include/GL/TestingSwapChainGL.h @@ -0,0 +1,54 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "TestingSwapChainBase.h" + +namespace Diligent +{ + +namespace Testing +{ + +class TestingSwapChainGL : public TestingSwapChainBase +{ +public: + using TBase = TestingSwapChainBase; + TestingSwapChainGL(IReferenceCounters* pRefCounters, + IRenderDevice* pDevice, + IDeviceContext* pContext, + const SwapChainDesc& SCDesc); + ~TestingSwapChainGL(); + + virtual void TakeSnapshot() override final; + + void BindFramebuffer(); + +private: + GLuint m_RenderTarget = 0; + GLuint m_DepthBuffer = 0; + GLuint m_FBO = 0; +}; + +} // namespace Testing + +} // namespace Diligent diff --git a/Tests/DiligentCoreAPITest/include/PSOTestBase.h b/Tests/DiligentCoreAPITest/include/PSOTestBase.h new file mode 100644 index 00000000..a66a5cf6 --- /dev/null +++ b/Tests/DiligentCoreAPITest/include/PSOTestBase.h @@ -0,0 +1,62 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "RenderDevice.h" +#include "DeviceContext.h" +#include "PipelineState.h" +#include "RefCntAutoPtr.h" + +namespace Diligent +{ + +namespace Testing +{ + +class PSOTestBase +{ +protected: + static void InitResources(); + static void ReleaseResources(); + + static RefCntAutoPtr CreateTestPSO(const PipelineStateDesc& PSODesc, bool BindPSO); + + static PipelineStateDesc& GetPSODesc() + { + return sm_Resources.PSODesc; + } + +private: + struct Resources + { + RefCntAutoPtr pTrivialVS; + RefCntAutoPtr pTrivialPS; + + PipelineStateDesc PSODesc; + }; + + static Resources sm_Resources; +}; + +} // namespace Testing + +} // namespace Diligent diff --git a/Tests/DiligentCoreAPITest/include/TestingEnvironment.h b/Tests/DiligentCoreAPITest/include/TestingEnvironment.h new file mode 100644 index 00000000..5d03e575 --- /dev/null +++ b/Tests/DiligentCoreAPITest/include/TestingEnvironment.h @@ -0,0 +1,120 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#pragma once + +#include + +#include "RenderDevice.h" +#include "DeviceContext.h" +#include "RefCntAutoPtr.h" +#include "SwapChain.h" +#include "GraphicsTypesOutputInserters.h" + +#include "gtest/gtest.h" + +namespace Diligent +{ + +namespace Testing +{ + +class TestingEnvironment : public ::testing::Environment +{ +public: + struct NativeWindow + { + void* NativeWindowHandle = nullptr; +#if PLATFORM_LINUX + void* Display = nullptr; +#endif + }; + + + TestingEnvironment(DeviceType deviceType, ADAPTER_TYPE AdapterType, const SwapChainDesc& SCDesc); + ~TestingEnvironment() override; + + // Override this to define how to set up the environment. + void SetUp() override final; + + // Override this to define how to tear down the environment. + void TearDown() override final; + + void Reset(); + void ReleaseResources(); + + class ScopedReset + { + public: + ScopedReset() = default; + ~ScopedReset() + { + if (m_pTheEnvironment) + m_pTheEnvironment->Reset(); + } + }; + + class ScopedReleaseResources + { + public: + ScopedReleaseResources() = default; + ~ScopedReleaseResources() + { + if (m_pTheEnvironment) + m_pTheEnvironment->ReleaseResources(); + } + }; + + IRenderDevice* GetDevice() { return m_pDevice; } + IDeviceContext* GetDeviceContext() { return m_pDeviceContext; } + ISwapChain* GetSwapChain() { return m_pSwapChain; } + + static TestingEnvironment* GetInstance() { return m_pTheEnvironment; } + + RefCntAutoPtr CreateTexture(const char* Name, TEXTURE_FORMAT Fmt, BIND_FLAGS BindFlags, Uint32 Width, Uint32 Height); + + static void SetErrorAllowance(int NumErrorsToAllow, const char* InfoMessage = nullptr); + +protected: + NativeWindow CreateNativeWindow(); + + static void MessageCallback(DebugMessageSeverity Severity, + const Char* Message, + const char* Function, + const char* File, + int Line); + + const DeviceType m_DeviceType; + + static TestingEnvironment* m_pTheEnvironment; + + RefCntAutoPtr m_pDevice; + RefCntAutoPtr m_pDeviceContext; + RefCntAutoPtr m_pSwapChain; + + static std::atomic_int m_NumAllowedErrors; +}; + +} // namespace Testing + +} // namespace Diligent diff --git a/Tests/DiligentCoreAPITest/include/TestingSwapChainBase.h b/Tests/DiligentCoreAPITest/include/TestingSwapChainBase.h new file mode 100644 index 00000000..1c976885 --- /dev/null +++ b/Tests/DiligentCoreAPITest/include/TestingSwapChainBase.h @@ -0,0 +1,209 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include + +#include "ObjectBase.h" +#include "RefCntAutoPtr.h" +#include "RenderDevice.h" +#include "DeviceContext.h" +#include "SwapChain.h" +#include "Texture.h" +#include "TextureView.h" +#include "TestingEnvironment.h" + +namespace Diligent +{ + +namespace Testing +{ + +void CompareTestImages(const Uint8* pReferencePixels, + Uint32 RefPixelsStride, + const Uint8* pPixels, + Uint32 PixelsStride, + Uint32 Width, + Uint32 Height, + TEXTURE_FORMAT Format); + +// {41BF4655-9B33-4E6C-9300-0CB45FBFE104} +static constexpr INTERFACE_ID IID_TestingSwapChain = + {0x41bf4655, 0x9b33, 0x4e6c, {0x93, 0x0, 0xc, 0xb4, 0x5f, 0xbf, 0xe1, 0x4}}; + +class ITestingSwapChain : public IObject +{ +public: + virtual void TakeSnapshot() = 0; +}; + +template +class SwapChainCombinedBaseInterface : public ITestingSwapChain, public SwapChainInterface +{}; + +template +class TestingSwapChainBase : public RefCountedObject> +{ +public: + using TObjectBase = RefCountedObject>; + + TestingSwapChainBase(IReferenceCounters* pRefCounters, + IRenderDevice* pDevice, + IDeviceContext* pContext, + const SwapChainDesc& SCDesc) : + TObjectBase{pRefCounters}, + m_pDevice{pDevice}, + m_pContext{pContext}, + m_SwapChainDesc{SCDesc} + { + VERIFY_EXPR(m_SwapChainDesc.ColorBufferFormat != TEX_FORMAT_UNKNOWN); + VERIFY_EXPR(m_SwapChainDesc.Width != 0); + VERIFY_EXPR(m_SwapChainDesc.Height != 0); + + { + TextureDesc RenderTargetDesc; + RenderTargetDesc.Name = "Testing color buffer"; + RenderTargetDesc.Type = RESOURCE_DIM_TEX_2D; + RenderTargetDesc.Width = m_SwapChainDesc.Width; + RenderTargetDesc.Height = m_SwapChainDesc.Height; + RenderTargetDesc.Format = m_SwapChainDesc.ColorBufferFormat; + RenderTargetDesc.SampleCount = 1; + RenderTargetDesc.Usage = USAGE_DEFAULT; + RenderTargetDesc.BindFlags = BIND_RENDER_TARGET; + m_pDevice->CreateTexture(RenderTargetDesc, nullptr, static_cast(&m_pRenderTarget)); + VERIFY_EXPR(m_pRenderTarget != nullptr); + m_pRTV = m_pRenderTarget->GetDefaultView(TEXTURE_VIEW_RENDER_TARGET); + VERIFY_EXPR(m_pRTV != nullptr); + + RenderTargetDesc.Name = "Staging color buffer copy"; + RenderTargetDesc.Usage = USAGE_STAGING; + RenderTargetDesc.CPUAccessFlags = CPU_ACCESS_READ; + RenderTargetDesc.BindFlags = BIND_NONE; + m_pDevice->CreateTexture(RenderTargetDesc, nullptr, static_cast(&m_pStagingTexture)); + } + + if (m_SwapChainDesc.DepthBufferFormat != TEX_FORMAT_UNKNOWN) + { + TextureDesc DepthBufferDesc; + DepthBufferDesc.Name = "Testing depth buffer"; + DepthBufferDesc.Type = RESOURCE_DIM_TEX_2D; + DepthBufferDesc.Width = m_SwapChainDesc.Width; + DepthBufferDesc.Height = m_SwapChainDesc.Height; + DepthBufferDesc.Format = m_SwapChainDesc.DepthBufferFormat; + DepthBufferDesc.SampleCount = 1; + DepthBufferDesc.Usage = USAGE_DEFAULT; + DepthBufferDesc.BindFlags = BIND_DEPTH_STENCIL; + + DepthBufferDesc.ClearValue.Format = DepthBufferDesc.Format; + DepthBufferDesc.ClearValue.DepthStencil.Depth = m_SwapChainDesc.DefaultDepthValue; + DepthBufferDesc.ClearValue.DepthStencil.Stencil = m_SwapChainDesc.DefaultStencilValue; + + m_pDevice->CreateTexture(DepthBufferDesc, nullptr, &m_pDepthBuffer); + VERIFY_EXPR(m_pDepthBuffer != nullptr); + m_pDSV = m_pDepthBuffer->GetDefaultView(TEXTURE_VIEW_DEPTH_STENCIL); + VERIFY_EXPR(m_pDSV != nullptr); + } + } + + void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) + { + if (ppInterface == nullptr) + return; + + if (IID == IID_SwapChain || IID == IID_Unknown) + { + *ppInterface = static_cast(this); + (*ppInterface)->AddRef(); + } + if (IID == IID_TestingSwapChain) + { + *ppInterface = static_cast(this); + (*ppInterface)->AddRef(); + } + } + + virtual void Present(Uint32 SyncInterval = 1) override + { + CopyTextureAttribs CopyInfo // + { + m_pRenderTarget, + RESOURCE_STATE_TRANSITION_MODE_TRANSITION, + m_pStagingTexture, + RESOURCE_STATE_TRANSITION_MODE_TRANSITION // + }; + m_pContext->CopyTexture(CopyInfo); + m_pContext->WaitForIdle(); + MappedTextureSubresource MapData; + m_pContext->MapTextureSubresource(m_pStagingTexture, 0, 0, MAP_READ, MAP_FLAG_DO_NOT_SYNCHRONIZE, nullptr, MapData); + CompareTestImages(m_ReferenceData.data(), m_ReferenceDataPitch, reinterpret_cast(MapData.pData), MapData.Stride, + m_SwapChainDesc.Width, m_SwapChainDesc.Height, m_SwapChainDesc.ColorBufferFormat); + + m_pContext->UnmapTextureSubresource(m_pStagingTexture, 0, 0); + } + + virtual void Resize(Uint32 NewWidth, Uint32 NewHeight) override final + { + UNEXPECTED("Resizing testing swap chains is not supported"); + } + + virtual void SetFullscreenMode(const DisplayModeAttribs& DisplayMode) override final + { + UNEXPECTED("Testing swap chain can't go into full screen mode"); + } + + virtual void SetWindowedMode() override final + { + UNEXPECTED("Testing swap chain can't switch between windowed and full screen modes"); + } + + virtual ITextureView* GetCurrentBackBufferRTV() override final + { + return m_pRTV; + } + + virtual ITextureView* GetDepthBufferDSV() override final + { + return m_pDSV; + } + + virtual const SwapChainDesc& GetDesc() const override final + { + return m_SwapChainDesc; + } + +protected: + const SwapChainDesc m_SwapChainDesc; + RefCntAutoPtr m_pDevice; + RefCntAutoPtr m_pContext; + RefCntAutoPtr m_pRenderTarget; + RefCntAutoPtr m_pDepthBuffer; + RefCntAutoPtr m_pRTV; + RefCntAutoPtr m_pDSV; + RefCntAutoPtr m_pStagingTexture; + + std::vector m_ReferenceData; + Uint32 m_ReferenceDataPitch = 0; +}; + +} // namespace Testing + +} // namespace Diligent diff --git a/Tests/DiligentCoreAPITest/include/Vulkan/CreateObjFromNativeResVK.h b/Tests/DiligentCoreAPITest/include/Vulkan/CreateObjFromNativeResVK.h new file mode 100644 index 00000000..f3b36403 --- /dev/null +++ b/Tests/DiligentCoreAPITest/include/Vulkan/CreateObjFromNativeResVK.h @@ -0,0 +1,47 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#pragma once + +#include "CreateObjFromNativeResTestBase.h" + +namespace Diligent +{ + +namespace Testing +{ + +class TestCreateObjFromNativeResVK : public CreateObjFromNativeResTestBase +{ +public: + TestCreateObjFromNativeResVK(IRenderDevice* pDevice) : + CreateObjFromNativeResTestBase(pDevice) + {} + + virtual void CreateTexture(ITexture* pTexture) override final; + virtual void CreateBuffer(IBuffer* pBuffer) override final; +}; + +} // namespace Testing + +} // namespace Diligent diff --git a/Tests/DiligentCoreAPITest/include/Vulkan/TestingEnvironmentVk.h b/Tests/DiligentCoreAPITest/include/Vulkan/TestingEnvironmentVk.h new file mode 100644 index 00000000..41c8dba7 --- /dev/null +++ b/Tests/DiligentCoreAPITest/include/Vulkan/TestingEnvironmentVk.h @@ -0,0 +1,102 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#pragma once + +#include + +#include "TestingEnvironment.h" + +#define VK_NO_PROTOTYPES +#include "vulkan/vulkan.h" + +namespace Diligent +{ + +namespace Testing +{ + +class TestingEnvironmentVk final : public TestingEnvironment +{ +public: + TestingEnvironmentVk(DeviceType deviceType, ADAPTER_TYPE AdapterType, const SwapChainDesc& SCDesc); + ~TestingEnvironmentVk(); + + static TestingEnvironmentVk* GetInstance() { return ValidatedCast(TestingEnvironment::GetInstance()); } + + void CreateImage2D(uint32_t Width, + uint32_t Height, + VkFormat vkFormat, + VkImageUsageFlags vkUsage, + VkImageLayout vkInitialLayout, + VkDeviceMemory& vkMemory, + VkImage& vkImage); + + void CreateBuffer(VkDeviceSize Size, + VkBufferUsageFlags vkUsage, + VkMemoryPropertyFlags MemoryFlags, + VkDeviceMemory& vkMemory, + VkBuffer& vkBuffer); + + uint32_t GetMemoryTypeIndex(uint32_t memoryTypeBitsRequirement, + VkMemoryPropertyFlags requiredProperties) const; + + VkDevice GetVkDevice() + { + return m_vkDevice; + } + + VkShaderModule CreateShaderModule(const SHADER_TYPE ShaderType, const char* ShaderSource, int SourceCodeLen); + + static VkRenderPassCreateInfo GetRenderPassCreateInfo( + Uint32 NumRenderTargets, + const VkFormat RTVFormats[], + VkFormat DSVFormat, + Uint32 SampleCount, + VkAttachmentLoadOp DepthAttachmentLoadOp, + VkAttachmentLoadOp ColorAttachmentLoadOp, + std::array& Attachments, + std::array& AttachmentReferences, + VkSubpassDescription& SubpassDesc); + + VkCommandBuffer AllocateCommandBuffer(); + + static void TransitionImageLayout(VkCommandBuffer CmdBuffer, + VkImage Image, + VkImageLayout& CurrentLayout, + VkImageLayout NewLayout, + const VkImageSubresourceRange& SubresRange, + VkPipelineStageFlags EnabledGraphicsShaderStages, + VkPipelineStageFlags SrcStages = 0, + VkPipelineStageFlags DestStages = 0); + +private: + VkDevice m_vkDevice = VK_NULL_HANDLE; + VkCommandPool m_vkCmdPool = VK_NULL_HANDLE; + + VkPhysicalDeviceMemoryProperties m_MemoryProperties = {}; +}; + +} // namespace Testing + +} // namespace Diligent diff --git a/Tests/DiligentCoreAPITest/include/Vulkan/TestingSwapChainVk.h b/Tests/DiligentCoreAPITest/include/Vulkan/TestingSwapChainVk.h new file mode 100644 index 00000000..10de2de9 --- /dev/null +++ b/Tests/DiligentCoreAPITest/include/Vulkan/TestingSwapChainVk.h @@ -0,0 +1,96 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "TestingSwapChainBase.h" + +#define VK_NO_PROTOTYPES +#include "vulkan/vulkan.h" + +namespace Diligent +{ + +namespace Testing +{ + +class TestingEnvironmentVk; + +class TestingSwapChainVk : public TestingSwapChainBase +{ +public: + using TBase = TestingSwapChainBase; + TestingSwapChainVk(IReferenceCounters* pRefCounters, + TestingEnvironmentVk* pEnv, + const SwapChainDesc& SCDesc); + ~TestingSwapChainVk(); + + virtual void TakeSnapshot() override final; + + VkImage GetVkRenderTargetImage() + { + return m_vkRenderTargetImage; + } + + VkImage GetVkDepthBufferImage() + { + return m_vkDepthBufferImage; + } + + VkRenderPass GetRenderPass() + { + return m_vkRenderPass; + } + + void TransitionRenderTarget(VkCommandBuffer vkCmdBuffer, VkImageLayout Layout, VkPipelineStageFlags GraphicsShaderStages); + void TransitionDepthBuffer(VkCommandBuffer vkCmdBuffer, VkImageLayout Layout, VkPipelineStageFlags GraphicsShaderStages); + + void BeginRenderPass(VkCommandBuffer vkCmdBuffer, VkPipelineStageFlags GraphicsShaderStages); + void EndRenderPass(VkCommandBuffer vkCmdBuffer); + +private: + void CreateFramebuffer(); + + VkDevice m_vkDevice = VK_NULL_HANDLE; + + VkDeviceMemory m_vkRenderTargetMemory = VK_NULL_HANDLE; + VkImage m_vkRenderTargetImage = VK_NULL_HANDLE; + VkImageLayout m_vkRenerTargetLayout = VK_IMAGE_LAYOUT_UNDEFINED; + VkImageView m_vkRenderTargetView = VK_NULL_HANDLE; + + VkDeviceMemory m_vkDepthBufferMemory = VK_NULL_HANDLE; + VkImage m_vkDepthBufferImage = VK_NULL_HANDLE; + VkImageLayout m_vkDepthBufferLayout = VK_IMAGE_LAYOUT_UNDEFINED; + VkImageView m_vkDepthBufferView = VK_NULL_HANDLE; + + VkDeviceSize m_StagingBufferSize = 0; + VkDeviceMemory m_vkStagingBufferMemory = VK_NULL_HANDLE; + VkBuffer m_vkStagingBuffer = VK_NULL_HANDLE; + + VkRenderPass m_vkRenderPass = VK_NULL_HANDLE; + VkFramebuffer m_vkFramebuffer = VK_NULL_HANDLE; + + VkPipelineStageFlags m_ActiveGraphicsShaderStages = 0; +}; + +} // namespace Testing + +} // namespace Diligent diff --git a/Tests/DiligentCoreAPITest/src/BlendStateTest.cpp b/Tests/DiligentCoreAPITest/src/BlendStateTest.cpp new file mode 100644 index 00000000..7a33f10f --- /dev/null +++ b/Tests/DiligentCoreAPITest/src/BlendStateTest.cpp @@ -0,0 +1,428 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include + +#include "TestingEnvironment.h" +#include "GraphicsAccessories.h" + +#include "gtest/gtest.h" + +using namespace Diligent; +using namespace Diligent::Testing; + +namespace +{ + +static const char g_TrivialVSSource[] = R"( +void VSMain(out float4 pos : SV_POSITION) +{ + pos = float4(0.0, 0.0, 0.0, 0.0); +} +)"; + +class BlendStateTestBase +{ +protected: + static void InitResources() + { + auto* pEnv = TestingEnvironment::GetInstance(); + auto* pDevice = pEnv->GetDevice(); + + ShaderCreateInfo Attrs; + Attrs.Source = g_TrivialVSSource; + Attrs.EntryPoint = "VSMain"; + Attrs.Desc.ShaderType = SHADER_TYPE_VERTEX; + Attrs.Desc.Name = "TrivialVS (TestPipelineStateBase)"; + Attrs.SourceLanguage = SHADER_SOURCE_LANGUAGE_HLSL; + Attrs.UseCombinedTextureSamplers = true; + pDevice->CreateShader(Attrs, &sm_Resources.pTrivialVS); + + Uint32 MaxTestRenderTargets = pDevice->GetDeviceCaps().DevType == DeviceType::OpenGLES ? 4 : 8; + for (Uint32 NumRTs = 1; NumRTs <= MaxTestRenderTargets; ++NumRTs) + { + std::stringstream source_ss; + source_ss << "void PSMain("; + for (Uint32 rt = 0; rt < NumRTs; ++rt) + { + if (rt > 0) + { + source_ss << ",\n" + << " "; + } + source_ss << "out float4 col" << rt << " : SV_TARGET" << rt; + } + source_ss << ")\n{"; + for (Uint32 rt = 0; rt < NumRTs; ++rt) + { + source_ss << "\n col" << rt << " = float4(0.0, 0.0, 0.0, 0.0);"; + } + source_ss << "\n}\n"; + + auto source = source_ss.str(); + Attrs.Source = source.c_str(); + Attrs.EntryPoint = "PSMain"; + Attrs.Desc.ShaderType = SHADER_TYPE_PIXEL; + Attrs.Desc.Name = "TrivialPS (TestPipelineStateBase)"; + pDevice->CreateShader(Attrs, &sm_Resources.pTrivialPS[NumRTs]); + } + + auto& PSODesc = sm_Resources.PSODesc; + + PSODesc.GraphicsPipeline.pVS = sm_Resources.pTrivialVS; + PSODesc.GraphicsPipeline.PrimitiveTopology = PRIMITIVE_TOPOLOGY_TRIANGLE_LIST; + PSODesc.GraphicsPipeline.NumRenderTargets = 1; + PSODesc.GraphicsPipeline.RTVFormats[0] = TEX_FORMAT_RGBA8_UNORM; + PSODesc.GraphicsPipeline.DSVFormat = TEX_FORMAT_D32_FLOAT; + } + + static void ReleaseResources() + { + sm_Resources = Resources{}; + TestingEnvironment::GetInstance()->Reset(); + } + + static RefCntAutoPtr CreateTestPSO(const PipelineStateDesc& PSODesc, bool BindPSO) + { + auto* pEnv = TestingEnvironment::GetInstance(); + auto* pDevice = pEnv->GetDevice(); + auto* pDeviceContext = pEnv->GetDeviceContext(); + + RefCntAutoPtr pPSO; + pDevice->CreatePipelineState(PSODesc, &pPSO); + EXPECT_TRUE(pPSO); + if (pPSO) + pDeviceContext->SetPipelineState(pPSO); + return pPSO; + } + + static PipelineStateDesc GetPSODesc(Uint32 NumRenderTargets) + { + auto PSODesc = sm_Resources.PSODesc; + PSODesc.GraphicsPipeline.NumRenderTargets = static_cast(NumRenderTargets); + PSODesc.GraphicsPipeline.pPS = sm_Resources.pTrivialPS[NumRenderTargets]; + for (Uint32 rt = 1; rt < NumRenderTargets; ++rt) + PSODesc.GraphicsPipeline.RTVFormats[rt] = PSODesc.GraphicsPipeline.RTVFormats[0]; + + return PSODesc; + } + +private: + struct Resources + { + RefCntAutoPtr pTrivialVS; + RefCntAutoPtr pTrivialPS[MaxRenderTargets + 1]; + + PipelineStateDesc PSODesc; + }; + + static Resources sm_Resources; +}; + +BlendStateTestBase::Resources BlendStateTestBase::sm_Resources; + +class BlendStateBasicTest : public BlendStateTestBase, public ::testing::Test +{ +protected: + static void SetUpTestSuite() + { + InitResources(); + } + + static void TearDownTestSuite() + { + ReleaseResources(); + TestingEnvironment::GetInstance()->ReleaseResources(); + } +}; + +TEST_F(BlendStateBasicTest, CreatePSO) +{ + auto PSODesc = GetPSODesc(1); + + PSODesc.Name = "BlendStateBasicTest"; + + BlendStateDesc& BSDesc = PSODesc.GraphicsPipeline.BlendDesc; + + auto& RT0 = BSDesc.RenderTargets[0]; + + RT0.BlendEnable = True; + EXPECT_TRUE(CreateTestPSO(PSODesc, true)); + + BSDesc.AlphaToCoverageEnable = !BSDesc.AlphaToCoverageEnable; + EXPECT_TRUE(CreateTestPSO(PSODesc, true)); + + RT0.RenderTargetWriteMask = COLOR_MASK_BLUE; + EXPECT_TRUE(CreateTestPSO(PSODesc, true)); + + RT0.RenderTargetWriteMask = COLOR_MASK_RED; + EXPECT_TRUE(CreateTestPSO(PSODesc, true)); + + RT0.RenderTargetWriteMask = COLOR_MASK_GREEN; + EXPECT_TRUE(CreateTestPSO(PSODesc, true)); + + RT0.RenderTargetWriteMask = COLOR_MASK_ALPHA; + EXPECT_TRUE(CreateTestPSO(PSODesc, true)); +} + +class BlendFactorTest : public BlendStateTestBase, public testing::TestWithParam> +{ +protected: + static void SetUpTestSuite() + { + InitResources(); + } + + static void TearDownTestSuite() + { + ReleaseResources(); + TestingEnvironment::GetInstance()->ReleaseResources(); + } +}; + +TEST_P(BlendFactorTest, CreatePSO) +{ + auto* pEnv = TestingEnvironment::GetInstance(); + auto* pDevice = pEnv->GetDevice(); + + const auto& Param = GetParam(); + + const auto BlendFactor = static_cast(std::get<0>(Param)); + const bool TestingAlpha = std::get<1>(Param); + + const auto& DevCaps = pDevice->GetDeviceCaps(); + Uint32 MaxTestRenderTargets = (DevCaps.DevType == DeviceType::OpenGLES) ? 4 : 8; + + const bool TestSRC1 = DevCaps.DevType != DeviceType::OpenGLES; // || DevCaps.Vendor == GPU_VENDOR::NVIDIA; + if (BlendFactor == BLEND_FACTOR_SRC1_COLOR || + BlendFactor == BLEND_FACTOR_INV_SRC1_COLOR || + BlendFactor == BLEND_FACTOR_SRC1_ALPHA || + BlendFactor == BLEND_FACTOR_INV_SRC1_ALPHA) + { + if (!TestSRC1) + { + GTEST_SKIP(); + } + else + { + MaxTestRenderTargets = 1; + } + } + + for (Uint32 NumRenderTarges = 1; NumRenderTarges < MaxTestRenderTargets; ++NumRenderTarges) + { + auto PSODesc = GetPSODesc(NumRenderTarges); + PSODesc.Name = "SrcBlendFactorTest"; + + BlendStateDesc& BSDesc = PSODesc.GraphicsPipeline.BlendDesc; + + BSDesc.IndependentBlendEnable = True; + for (Uint32 i = 0; i < NumRenderTarges; ++i) + { + auto& RT = BSDesc.RenderTargets[i]; + + RT.BlendEnable = True; + if (TestingAlpha) + RT.SrcBlendAlpha = BlendFactor; + else + RT.SrcBlend = BlendFactor; + } + + auto pPSO = CreateTestPSO(PSODesc, true); + ASSERT_TRUE(pPSO) << "Number of render targets: " << NumRenderTarges; + for (Uint32 i = 0; i < NumRenderTarges; ++i) + { + auto& RT = pPSO->GetDesc().GraphicsPipeline.BlendDesc.RenderTargets[i]; + + EXPECT_EQ(RT.BlendEnable, True) << "Render target: " << i; + if (TestingAlpha) + { + EXPECT_EQ(RT.SrcBlendAlpha, BlendFactor) << "Render target: " << i; + } + else + { + EXPECT_EQ(RT.SrcBlend, BlendFactor) << "Render target: " << i; + } + } + } + + for (Uint32 NumRenderTarges = 1; NumRenderTarges < MaxTestRenderTargets; ++NumRenderTarges) + { + auto PSODesc = GetPSODesc(NumRenderTarges); + PSODesc.Name = "DstBlendFactorTest"; + + BlendStateDesc& BSDesc = PSODesc.GraphicsPipeline.BlendDesc; + + BSDesc.IndependentBlendEnable = True; + for (Uint32 i = 0; i < NumRenderTarges; ++i) + { + auto& RT = BSDesc.RenderTargets[i]; + + RT.BlendEnable = True; + if (TestingAlpha) + RT.DestBlendAlpha = BlendFactor; + else + RT.DestBlend = BlendFactor; + } + + auto pPSO = CreateTestPSO(PSODesc, true); + ASSERT_TRUE(pPSO) << "Number of render targets: " << NumRenderTarges; + for (Uint32 i = 0; i < NumRenderTarges; ++i) + { + auto& RT = pPSO->GetDesc().GraphicsPipeline.BlendDesc.RenderTargets[i]; + + EXPECT_EQ(RT.BlendEnable, True) << "Render target: " << i; + if (TestingAlpha) + { + EXPECT_EQ(RT.DestBlendAlpha, BlendFactor) << "Render target: " << i; + } + else + { + EXPECT_EQ(RT.DestBlend, BlendFactor) << "Render target: " << i; + } + } + } +} + +std::string PrintBlendFactorTestName(const testing::TestParamInfo>& info) // +{ + auto BlendFactor = static_cast(std::get<0>(info.param)); + + std::stringstream name_ss; + name_ss << GetBlendFactorLiteralName(BlendFactor); + return name_ss.str(); +} + +INSTANTIATE_TEST_SUITE_P(ColorBlendFactors, + BlendFactorTest, + testing::Combine( + testing::Range(BLEND_FACTOR_UNDEFINED + 1, BLEND_FACTOR_NUM_FACTORS), + testing::Values(false)), + PrintBlendFactorTestName); + + +INSTANTIATE_TEST_SUITE_P(AlphaBlendFactors, + BlendFactorTest, + testing::Combine( + testing::Values(BLEND_FACTOR_ZERO, + BLEND_FACTOR_ONE, + BLEND_FACTOR_SRC_ALPHA, + BLEND_FACTOR_INV_SRC_ALPHA, + BLEND_FACTOR_DEST_ALPHA, + BLEND_FACTOR_INV_DEST_ALPHA, + BLEND_FACTOR_SRC_ALPHA_SAT, + BLEND_FACTOR_BLEND_FACTOR, + BLEND_FACTOR_INV_BLEND_FACTOR, + BLEND_FACTOR_SRC1_ALPHA, + BLEND_FACTOR_INV_SRC1_ALPHA), + testing::Values(true)), + PrintBlendFactorTestName); + + +class BlendOperationTest : public BlendStateTestBase, public testing::TestWithParam> +{ +protected: + static void SetUpTestSuite() + { + InitResources(); + } + + static void TearDownTestSuite() + { + ReleaseResources(); + TestingEnvironment::GetInstance()->ReleaseResources(); + } +}; + + +TEST_P(BlendOperationTest, CreatePSO) +{ + auto* pEnv = TestingEnvironment::GetInstance(); + auto* pDevice = pEnv->GetDevice(); + + const auto& Param = GetParam(); + + const auto BlendOp = static_cast(std::get<0>(Param)); + const auto TestingAlpha = std::get<1>(Param); + + const auto& DevCaps = pDevice->GetDeviceCaps(); + const Uint32 MaxTestRenderTargets = (DevCaps.DevType == DeviceType::OpenGLES) ? 4 : 8; + + for (Uint32 NumRenderTarges = 1; NumRenderTarges < MaxTestRenderTargets; ++NumRenderTarges) + { + auto PSODesc = GetPSODesc(NumRenderTarges); + PSODesc.Name = "BlendOperationTest"; + + BlendStateDesc& BSDesc = PSODesc.GraphicsPipeline.BlendDesc; + + BSDesc.IndependentBlendEnable = True; + for (Uint32 i = 0; i < NumRenderTarges; ++i) + { + auto& RT = BSDesc.RenderTargets[i]; + RT.BlendEnable = True; + RT.SrcBlend = BLEND_FACTOR_SRC_COLOR; + RT.DestBlend = BLEND_FACTOR_INV_SRC_COLOR; + RT.SrcBlendAlpha = BLEND_FACTOR_SRC_ALPHA; + RT.DestBlendAlpha = BLEND_FACTOR_INV_SRC_ALPHA; + if (TestingAlpha) + RT.BlendOpAlpha = BlendOp; + else + RT.BlendOp = BlendOp; + } + + auto pPSO = CreateTestPSO(PSODesc, true); + ASSERT_TRUE(pPSO) << "Number of render targets: " << NumRenderTarges; + for (Uint32 i = 0; i < NumRenderTarges; ++i) + { + auto& RT = pPSO->GetDesc().GraphicsPipeline.BlendDesc.RenderTargets[i]; + + EXPECT_EQ(RT.BlendEnable, True) << "Render target: " << i; + if (TestingAlpha) + { + EXPECT_EQ(RT.BlendOpAlpha, BlendOp) << "Render target: " << i; + } + else + { + EXPECT_EQ(RT.BlendOp, BlendOp) << "Render target: " << i; + } + } + } +} + +INSTANTIATE_TEST_SUITE_P(BlendOperations, + BlendOperationTest, + testing::Combine( + testing::Range(BLEND_OPERATION_UNDEFINED + 1, BLEND_OPERATION_NUM_OPERATIONS), + testing::Values(true, false)), + [](const testing::TestParamInfo>& info) // + { + auto BlendOp = static_cast(std::get<0>(info.param)); + auto IsTestingAlpha = std::get<1>(info.param); + + std::stringstream name_ss; + name_ss << (IsTestingAlpha ? "Alpha_" : "Color_") << GetBlendOperationLiteralName(BlendOp); + return name_ss.str(); + } // +); + +} // namespace diff --git a/Tests/DiligentCoreAPITest/src/BrokenShaderTest.cpp b/Tests/DiligentCoreAPITest/src/BrokenShaderTest.cpp new file mode 100644 index 00000000..d6eed1cd --- /dev/null +++ b/Tests/DiligentCoreAPITest/src/BrokenShaderTest.cpp @@ -0,0 +1,69 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "TestingEnvironment.h" + +#include "gtest/gtest.h" + +using namespace Diligent; +using namespace Diligent::Testing; + +namespace +{ + +static const char g_BrokenShaderSource[] = R"( +void VSMain(out float4 pos : SV_POSITION) +{ + pos = float3(0.0, 0.0, 0.0, 0.0); +} +)"; + +TEST(Shader, CompilationFailure) +{ + auto* pEnv = TestingEnvironment::GetInstance(); + auto* pDevice = pEnv->GetDevice(); + + TestingEnvironment::ScopedReset EnvironmentAutoReset; + + ShaderCreateInfo Attrs; + Attrs.Source = g_BrokenShaderSource; + Attrs.EntryPoint = "VSMain"; + Attrs.Desc.ShaderType = SHADER_TYPE_VERTEX; + Attrs.Desc.Name = "Broken shader test"; + Attrs.SourceLanguage = SHADER_SOURCE_LANGUAGE_HLSL; + Attrs.UseCombinedTextureSamplers = true; + + IDataBlob* pErrors = nullptr; + Attrs.ppCompilerOutput = &pErrors; + + pEnv->SetErrorAllowance(pDevice->GetDeviceCaps().IsVulkanDevice() ? 3 : 2, "\n\nNo worries, testing broken shader...\n\n"); + RefCntAutoPtr pBrokenShader; + pDevice->CreateShader(Attrs, &pBrokenShader); + EXPECT_FALSE(pBrokenShader); + EXPECT_TRUE(pErrors); + const char* Msg = reinterpret_cast(pErrors->GetDataPtr()); + LOG_INFO_MESSAGE("Compiler output:\n", Msg); + pErrors->Release(); +} + +} // namespace diff --git a/Tests/DiligentCoreAPITest/src/BufferCreationTest.cpp b/Tests/DiligentCoreAPITest/src/BufferCreationTest.cpp new file mode 100644 index 00000000..3af7125c --- /dev/null +++ b/Tests/DiligentCoreAPITest/src/BufferCreationTest.cpp @@ -0,0 +1,256 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#if D3D11_SUPPORTED +# include "D3D11/CreateObjFromNativeResD3D11.h" +#endif + +#if D3D12_SUPPORTED +# include "D3D12/CreateObjFromNativeResD3D12.h" +#endif + +#if GL_SUPPORTED || GLES_SUPPORTED +# include "GL/CreateObjFromNativeResGL.h" +#endif + +#if VULKAN_SUPPORTED +# include "Vulkan/CreateObjFromNativeResVK.h" +#endif + +#include "GraphicsAccessories.h" + +#include "TestingEnvironment.h" + +#include "gtest/gtest.h" + +using namespace Diligent; +using namespace Diligent::Testing; + +namespace +{ + +class BufferCreationTest : public ::testing::Test +{ +protected: + static void SetUpTestSuite() + { + auto* pEnv = TestingEnvironment::GetInstance(); + auto* pDevice = pEnv->GetDevice(); + + const auto DevCaps = pDevice->GetDeviceCaps(); + switch (DevCaps.DevType) + { +#if D3D11_SUPPORTED + case DeviceType::D3D11: + pCreateObjFromNativeRes.reset(new TestCreateObjFromNativeResD3D11(pDevice)); + break; + +#endif + +#if D3D12_SUPPORTED + case DeviceType::D3D12: + pCreateObjFromNativeRes.reset(new TestCreateObjFromNativeResD3D12(pDevice)); + break; +#endif + +#if GL_SUPPORTED || GLES_SUPPORTED + case DeviceType::OpenGL: + case DeviceType::OpenGLES: + pCreateObjFromNativeRes.reset(new TestCreateObjFromNativeResGL(pDevice)); + break; +#endif + +#if VULKAN_SUPPORTED + case DeviceType::Vulkan: + pCreateObjFromNativeRes.reset(new TestCreateObjFromNativeResVK(pDevice)); + break; +#endif + + default: UNEXPECTED("Unexpected device type"); + } + } + + static void TearDownTestSuite() + { + pCreateObjFromNativeRes.reset(); + TestingEnvironment::GetInstance()->Reset(); + } + + static std::unique_ptr pCreateObjFromNativeRes; +}; + +std::unique_ptr BufferCreationTest::pCreateObjFromNativeRes; + +TEST_F(BufferCreationTest, CreateVertexBuffer) +{ + auto* pEnv = TestingEnvironment::GetInstance(); + auto* pDevice = pEnv->GetDevice(); + + BufferDesc BuffDesc; + BuffDesc.Name = "Vertex buffer"; + BuffDesc.uiSizeInBytes = 256; + BuffDesc.BindFlags = BIND_VERTEX_BUFFER; + + BufferData InitData; + InitData.DataSize = BuffDesc.uiSizeInBytes; + std::vector DummyData(InitData.DataSize); + InitData.pData = DummyData.data(); + RefCntAutoPtr pBuffer; + pDevice->CreateBuffer(BuffDesc, &InitData, &pBuffer); + ASSERT_NE(pBuffer, nullptr) << GetObjectDescString(BuffDesc); + + pCreateObjFromNativeRes->CreateBuffer(pBuffer); +} + +TEST_F(BufferCreationTest, CreateIndexBuffer) +{ + auto* pEnv = TestingEnvironment::GetInstance(); + auto* pDevice = pEnv->GetDevice(); + + BufferDesc BuffDesc; + BuffDesc.Name = "Index"; + BuffDesc.uiSizeInBytes = 256; + BuffDesc.BindFlags = BIND_VERTEX_BUFFER; + + BufferData NullData; + + RefCntAutoPtr pBuffer; + pDevice->CreateBuffer(BuffDesc, &NullData, &pBuffer); + ASSERT_NE(pBuffer, nullptr) << GetObjectDescString(BuffDesc); + + pCreateObjFromNativeRes->CreateBuffer(pBuffer); +} + +TEST_F(BufferCreationTest, CreateFormattedBuffer) +{ + auto* pEnv = TestingEnvironment::GetInstance(); + auto* pDevice = pEnv->GetDevice(); + + const auto& DevCaps = pDevice->GetDeviceCaps(); + if (!(DevCaps.bComputeShadersSupported && DevCaps.bIndirectRenderingSupported)) + { + GTEST_SKIP(); + } + + BufferDesc BuffDesc; + BuffDesc.Name = "Formatted buffer"; + BuffDesc.uiSizeInBytes = 256; + BuffDesc.BindFlags = BIND_UNORDERED_ACCESS | BIND_SHADER_RESOURCE; + BuffDesc.Mode = BUFFER_MODE_FORMATTED; + BuffDesc.ElementByteStride = 16; + + RefCntAutoPtr pBuffer; + pDevice->CreateBuffer(BuffDesc, nullptr, &pBuffer); + ASSERT_NE(pBuffer, nullptr) << GetObjectDescString(BuffDesc); + + BufferViewDesc ViewDesc; + ViewDesc.ViewType = BUFFER_VIEW_SHADER_RESOURCE; + ViewDesc.ByteOffset = 32; + ViewDesc.Format.NumComponents = 4; + ViewDesc.Format.ValueType = VT_FLOAT32; + ViewDesc.Format.IsNormalized = false; + RefCntAutoPtr pBufferSRV; + pBuffer->CreateView(ViewDesc, &pBufferSRV); + EXPECT_NE(pBufferSRV, nullptr) << GetObjectDescString(BuffDesc); + + ViewDesc.ViewType = BUFFER_VIEW_UNORDERED_ACCESS; + RefCntAutoPtr pBufferUAV; + pBuffer->CreateView(ViewDesc, &pBufferUAV); + EXPECT_NE(pBufferUAV, nullptr) << GetObjectDescString(BuffDesc); + + pCreateObjFromNativeRes->CreateBuffer(pBuffer); +} + +TEST_F(BufferCreationTest, CreateStructuedBuffer) +{ + auto* pEnv = TestingEnvironment::GetInstance(); + auto* pDevice = pEnv->GetDevice(); + + const auto& DevCaps = pDevice->GetDeviceCaps(); + if (!DevCaps.bComputeShadersSupported) + { + GTEST_SKIP(); + } + + BufferDesc BuffDesc; + BuffDesc.Name = "Structured buffer"; + BuffDesc.uiSizeInBytes = 256; + BuffDesc.BindFlags = BIND_SHADER_RESOURCE | BIND_UNORDERED_ACCESS; + BuffDesc.Mode = BUFFER_MODE_STRUCTURED; + BuffDesc.ElementByteStride = 16; + RefCntAutoPtr pBuffer; + pDevice->CreateBuffer(BuffDesc, nullptr, &pBuffer); + ASSERT_NE(pBuffer, nullptr) << GetObjectDescString(BuffDesc); + + pCreateObjFromNativeRes->CreateBuffer(pBuffer); +} + +TEST_F(BufferCreationTest, CreateUniformBuffer) +{ + auto* pEnv = TestingEnvironment::GetInstance(); + auto* pDevice = pEnv->GetDevice(); + + BufferDesc BuffDesc; + BuffDesc.Name = "Uniform buffer"; + BuffDesc.uiSizeInBytes = 256; + BuffDesc.BindFlags = BIND_UNIFORM_BUFFER; + RefCntAutoPtr pBuffer; + pDevice->CreateBuffer(BuffDesc, nullptr, &pBuffer); + ASSERT_NE(pBuffer, nullptr) << GetObjectDescString(BuffDesc); + + pCreateObjFromNativeRes->CreateBuffer(pBuffer); +} + +TEST_F(BufferCreationTest, CreateRawBuffer) +{ + auto* pEnv = TestingEnvironment::GetInstance(); + auto* pDevice = pEnv->GetDevice(); + + BufferDesc BuffDesc; + BuffDesc.Name = "Raw buffer"; + BuffDesc.uiSizeInBytes = 256; + BuffDesc.BindFlags = BIND_VERTEX_BUFFER | BIND_INDEX_BUFFER | BIND_UNORDERED_ACCESS | BIND_SHADER_RESOURCE; + BuffDesc.Mode = BUFFER_MODE_RAW; + BuffDesc.ElementByteStride = 16; + RefCntAutoPtr pBuffer; + pDevice->CreateBuffer(BuffDesc, nullptr, &pBuffer); + ASSERT_NE(pBuffer, nullptr) << GetObjectDescString(BuffDesc); + + BufferViewDesc ViewDesc; + ViewDesc.ViewType = BUFFER_VIEW_UNORDERED_ACCESS; + ViewDesc.ByteOffset = 32; + ViewDesc.Format.NumComponents = 4; + ViewDesc.Format.ValueType = VT_FLOAT32; + RefCntAutoPtr pBufferUAV; + pBuffer->CreateView(ViewDesc, &pBufferUAV); + ASSERT_NE(pBufferUAV, nullptr) << GetObjectDescString(BuffDesc); + + ViewDesc.ViewType = BUFFER_VIEW_SHADER_RESOURCE; + RefCntAutoPtr pBufferSRV; + pBuffer->CreateView(ViewDesc, &pBufferSRV); + ASSERT_NE(pBufferSRV, nullptr) << GetObjectDescString(BuffDesc); + + pCreateObjFromNativeRes->CreateBuffer(pBuffer); +} + +} // namespace diff --git a/Tests/DiligentCoreAPITest/src/ClearRenderTargetTest.cpp b/Tests/DiligentCoreAPITest/src/ClearRenderTargetTest.cpp new file mode 100644 index 00000000..940d22e0 --- /dev/null +++ b/Tests/DiligentCoreAPITest/src/ClearRenderTargetTest.cpp @@ -0,0 +1,127 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "TestingEnvironment.h" +#include "TestingSwapChainBase.h" + +#include "gtest/gtest.h" + +namespace Diligent +{ + +namespace Testing +{ + +#if D3D11_SUPPORTED +void ClearRenderTargetReferenceD3D11(ISwapChain* pSwapChain); +#endif + +#if D3D12_SUPPORTED +void ClearRenderTargetReferenceD3D12(ISwapChain* pSwapChain); +#endif + +#if GL_SUPPORTED || GLES_SUPPORTED +void ClearRenderTargetReferenceGL(ISwapChain* pSwapChain); +#endif + +#if VULKAN_SUPPORTED +void ClearRenderTargetReferenceVk(ISwapChain* pSwapChain); +#endif + +#if METAL_SUPPORTED + +#endif + +} // namespace Testing + +} // namespace Diligent + +using namespace Diligent; +using namespace Diligent::Testing; + +namespace +{ + +TEST(ClearRenderTargetTest, Clear) +{ + auto* pEnv = TestingEnvironment::GetInstance(); + auto* pDevice = pEnv->GetDevice(); + auto* pSwapChain = pEnv->GetSwapChain(); + auto* pConext = pEnv->GetDeviceContext(); + + RefCntAutoPtr pTestingSwapChain(pSwapChain, IID_TestingSwapChain); + if (pTestingSwapChain) + { + pConext->Flush(); + pConext->InvalidateState(); + + auto deviceType = pDevice->GetDeviceCaps().DevType; + switch (deviceType) + { +#if D3D11_SUPPORTED + case DeviceType::D3D11: + ClearRenderTargetReferenceD3D11(pSwapChain); + break; +#endif + +#if D3D12_SUPPORTED + case DeviceType::D3D12: + ClearRenderTargetReferenceD3D12(pSwapChain); + break; +#endif + +#if GL_SUPPORTED || GLES_SUPPORTED + case DeviceType::OpenGL: + case DeviceType::OpenGLES: + ClearRenderTargetReferenceGL(pSwapChain); + break; + +#endif + +#if VULKAN_SUPPORTED + case DeviceType::Vulkan: + ClearRenderTargetReferenceVk(pSwapChain); + break; + +#endif + + default: + LOG_ERROR_AND_THROW("Unsupported device type"); + } + + pTestingSwapChain->TakeSnapshot(); + } + TestingEnvironment::ScopedReleaseResources EnvironmentAutoReset; + + auto* pContext = pEnv->GetDeviceContext(); + + ITextureView* pRTVs[] = {pSwapChain->GetCurrentBackBufferRTV()}; + pContext->SetRenderTargets(1, pRTVs, nullptr, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); + + float ClearColor[] = {0.25f, 0.5f, 0.75f, 1.0f}; + pContext->ClearRenderTarget(pRTVs[0], ClearColor, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); + + pSwapChain->Present(); +} + +} // namespace diff --git a/Tests/DiligentCoreAPITest/src/CopyTextureTest.cpp b/Tests/DiligentCoreAPITest/src/CopyTextureTest.cpp new file mode 100644 index 00000000..633cf167 --- /dev/null +++ b/Tests/DiligentCoreAPITest/src/CopyTextureTest.cpp @@ -0,0 +1,278 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "TestingEnvironment.h" + +#include "gtest/gtest.h" + +using namespace Diligent; +using namespace Diligent::Testing; + +namespace +{ + +// clang-format off +TEXTURE_FORMAT TestFormats[] = +{ + TEX_FORMAT_RGBA32_FLOAT, + TEX_FORMAT_RGBA32_UINT, + TEX_FORMAT_RGBA32_SINT, + TEX_FORMAT_RGBA16_FLOAT, + TEX_FORMAT_RGBA16_UINT, + TEX_FORMAT_RGBA16_SINT, + TEX_FORMAT_RGBA8_UNORM, + TEX_FORMAT_RGBA8_SNORM, + TEX_FORMAT_RGBA8_UINT, + TEX_FORMAT_RGBA8_SINT, + + TEX_FORMAT_RG32_FLOAT, + TEX_FORMAT_RG32_UINT, + TEX_FORMAT_RG32_SINT, + TEX_FORMAT_RG16_FLOAT, + TEX_FORMAT_RG16_UINT, + TEX_FORMAT_RG16_SINT, + TEX_FORMAT_RG8_UNORM, + TEX_FORMAT_RG8_SNORM, + TEX_FORMAT_RG8_UINT, + TEX_FORMAT_RG8_SINT, + + TEX_FORMAT_R32_FLOAT, + TEX_FORMAT_R32_UINT, + TEX_FORMAT_R32_SINT, + TEX_FORMAT_R16_FLOAT, + TEX_FORMAT_R16_UINT, + TEX_FORMAT_R16_SINT, + TEX_FORMAT_R8_UNORM, + TEX_FORMAT_R8_SNORM, + TEX_FORMAT_R8_UINT, + TEX_FORMAT_R8_SINT +}; +// clang-format on + +TEST(CopyTexture, Texture2D) +{ + auto* pEnv = TestingEnvironment::GetInstance(); + auto* pDevice = pEnv->GetDevice(); + auto* pContext = pEnv->GetDeviceContext(); + + TestingEnvironment::ScopedReleaseResources EnvironmentAutoReset; + + for (auto f = 0; f < _countof(TestFormats); ++f) + { + auto Format = TestFormats[f]; + + TextureDesc TexDesc; + TexDesc.Type = RESOURCE_DIM_TEX_2D; + TexDesc.Format = Format; + TexDesc.Width = 128; + TexDesc.Height = 128; + TexDesc.BindFlags = BIND_SHADER_RESOURCE; + TexDesc.MipLevels = 5; + TexDesc.Usage = USAGE_DEFAULT; + + Diligent::RefCntAutoPtr pSrcTex, pDstTex; + + auto FmtAttribs = pDevice->GetTextureFormatInfo(Format); + auto TexelSize = Uint32{FmtAttribs.ComponentSize} * Uint32{FmtAttribs.NumComponents}; + std::vector DummyData(size_t{TexDesc.Width} * size_t{TexDesc.Height} * size_t{TexelSize}); + TextureData InitData; + InitData.NumSubresources = TexDesc.MipLevels; + std::vector SubResData(InitData.NumSubresources); + for (Uint32 mip = 0; mip < TexDesc.MipLevels; ++mip) + { + SubResData[mip] = TextureSubResData{DummyData.data(), (TexDesc.Width >> mip) * TexelSize, 0}; + } + InitData.pSubResources = SubResData.data(); + pDevice->CreateTexture(TexDesc, &InitData, &pSrcTex); + pDevice->CreateTexture(TexDesc, nullptr, &pDstTex); + + CopyTextureAttribs CopyAttribs; + CopyAttribs.pSrcTexture = pSrcTex; + CopyAttribs.SrcMipLevel = 2; + CopyAttribs.pDstTexture = pDstTex; + CopyAttribs.DstMipLevel = 1; + CopyAttribs.DstX = 32; + CopyAttribs.DstY = 16; + CopyAttribs.DstZ = 0; + CopyAttribs.SrcTextureTransitionMode = RESOURCE_STATE_TRANSITION_MODE_TRANSITION; + CopyAttribs.DstTextureTransitionMode = RESOURCE_STATE_TRANSITION_MODE_TRANSITION; + pContext->CopyTexture(CopyAttribs); + + Box SrcBox; + SrcBox.MinX = 3; + SrcBox.MaxX = 19; + SrcBox.MinY = 1; + SrcBox.MaxY = 32; + + CopyAttribs.pSrcBox = &SrcBox; + CopyAttribs.SrcTextureTransitionMode = RESOURCE_STATE_TRANSITION_MODE_VERIFY; + CopyAttribs.DstTextureTransitionMode = RESOURCE_STATE_TRANSITION_MODE_VERIFY; + pContext->CopyTexture(CopyAttribs); + + pEnv->ReleaseResources(); + } +} + +TEST(CopyTexture, Texture2DArray) +{ + auto* pEnv = TestingEnvironment::GetInstance(); + auto* pDevice = pEnv->GetDevice(); + auto* pContext = pEnv->GetDeviceContext(); + + TestingEnvironment::ScopedReleaseResources EnvironmentAutoReset; + + for (auto f = 0; f < _countof(TestFormats); ++f) + { + auto Format = TestFormats[f]; + + TextureDesc TexDesc; + TexDesc.Type = RESOURCE_DIM_TEX_2D_ARRAY; + TexDesc.Format = Format; + TexDesc.Width = 128; + TexDesc.Height = 128; + TexDesc.BindFlags = BIND_SHADER_RESOURCE; + TexDesc.MipLevels = 5; + TexDesc.ArraySize = 8; + TexDesc.Usage = USAGE_DEFAULT; + + Diligent::RefCntAutoPtr pSrcTex, pDstTex; + auto FmtAttribs = pDevice->GetTextureFormatInfo(Format); + auto TexelSize = Uint32{FmtAttribs.ComponentSize} * Uint32{FmtAttribs.NumComponents}; + std::vector DummyData(size_t{TexDesc.Width} * size_t{TexDesc.Height} * size_t{TexelSize}); + TextureData InitData; + InitData.NumSubresources = TexDesc.MipLevels * TexDesc.ArraySize; + std::vector SubResData(InitData.NumSubresources); + Uint32 subres = 0; + for (Uint32 slice = 0; slice < TexDesc.ArraySize; ++slice) + { + for (Uint32 mip = 0; mip < TexDesc.MipLevels; ++mip) + { + SubResData[subres++] = TextureSubResData{DummyData.data(), (TexDesc.Width >> mip) * TexelSize, 0}; + } + } + VERIFY_EXPR(subres == InitData.NumSubresources); + InitData.pSubResources = SubResData.data(); + + pDevice->CreateTexture(TexDesc, &InitData, &pSrcTex); + pDevice->CreateTexture(TexDesc, nullptr, &pDstTex); + + CopyTextureAttribs CopyAttribs; + CopyAttribs.pSrcTexture = pSrcTex; + CopyAttribs.SrcMipLevel = 2; + CopyAttribs.SrcSlice = 3; + CopyAttribs.pDstTexture = pDstTex; + CopyAttribs.DstMipLevel = 1; + CopyAttribs.DstSlice = 6; + CopyAttribs.DstX = 32; + CopyAttribs.DstY = 16; + CopyAttribs.DstZ = 0; + CopyAttribs.SrcTextureTransitionMode = RESOURCE_STATE_TRANSITION_MODE_TRANSITION; + CopyAttribs.DstTextureTransitionMode = RESOURCE_STATE_TRANSITION_MODE_TRANSITION; + pContext->CopyTexture(CopyAttribs); + + Box SrcBox; + SrcBox.MinX = 3; + SrcBox.MaxX = 19; + SrcBox.MinY = 1; + SrcBox.MaxY = 32; + + CopyAttribs.DstSlice = 5; + CopyAttribs.pSrcBox = &SrcBox; + CopyAttribs.SrcTextureTransitionMode = RESOURCE_STATE_TRANSITION_MODE_VERIFY; + CopyAttribs.DstTextureTransitionMode = RESOURCE_STATE_TRANSITION_MODE_VERIFY; + pContext->CopyTexture(CopyAttribs); + + pEnv->ReleaseResources(); + } +} + +TEST(CopyTexture, Texture3D) +{ + auto* pEnv = TestingEnvironment::GetInstance(); + auto* pDevice = pEnv->GetDevice(); + auto* pContext = pEnv->GetDeviceContext(); + + TestingEnvironment::ScopedReleaseResources EnvironmentAutoReset; + + for (auto f = 0; f < _countof(TestFormats); ++f) + { + auto Format = TestFormats[f]; + + TextureDesc TexDesc; + TexDesc.Type = RESOURCE_DIM_TEX_3D; + TexDesc.Format = Format; + TexDesc.Width = 64; + TexDesc.Height = 64; + TexDesc.Depth = 16; + TexDesc.BindFlags = BIND_SHADER_RESOURCE; + TexDesc.MipLevels = 4; + TexDesc.Usage = USAGE_DEFAULT; + + Diligent::RefCntAutoPtr pSrcTex, pDstTex; + + auto FmtAttribs = pDevice->GetTextureFormatInfo(Format); + auto TexelSize = Uint32{FmtAttribs.ComponentSize} * Uint32{FmtAttribs.NumComponents}; + std::vector DummyData(size_t{TexDesc.Width} * size_t{TexDesc.Height} * size_t{TexDesc.Depth} * size_t{TexelSize}); + TextureData InitData; + InitData.NumSubresources = TexDesc.MipLevels; + std::vector SubResData(InitData.NumSubresources); + for (Uint32 mip = 0; mip < TexDesc.MipLevels; ++mip) + { + SubResData[mip] = TextureSubResData{DummyData.data(), (TexDesc.Width >> mip) * TexelSize, (TexDesc.Width >> mip) * (TexDesc.Height >> mip) * TexelSize}; + } + InitData.pSubResources = SubResData.data(); + pDevice->CreateTexture(TexDesc, &InitData, &pSrcTex); + pDevice->CreateTexture(TexDesc, nullptr, &pDstTex); + + CopyTextureAttribs CopyAttribs; + CopyAttribs.pSrcTexture = pSrcTex; + CopyAttribs.SrcMipLevel = 2; + CopyAttribs.pDstTexture = pDstTex; + CopyAttribs.DstMipLevel = 1; + CopyAttribs.DstX = 16; + CopyAttribs.DstY = 8; + CopyAttribs.DstZ = 0; + CopyAttribs.SrcTextureTransitionMode = RESOURCE_STATE_TRANSITION_MODE_TRANSITION; + CopyAttribs.DstTextureTransitionMode = RESOURCE_STATE_TRANSITION_MODE_TRANSITION; + + pContext->CopyTexture(CopyAttribs); + + Box SrcBox; + SrcBox.MinX = 3; + SrcBox.MaxX = 19; + SrcBox.MinY = 1; + SrcBox.MaxY = 32; + + CopyAttribs.pSrcBox = &SrcBox; + CopyAttribs.SrcMipLevel = 1; + CopyAttribs.DstMipLevel = 0; + CopyAttribs.DstX = 32; + CopyAttribs.DstY = 16; + CopyAttribs.DstZ = 0; + pContext->CopyTexture(CopyAttribs); + + pEnv->ReleaseResources(); + } +} + +} // namespace diff --git a/Tests/DiligentCoreAPITest/src/D3D11/ClearRenderTargetRefenceD3D11.cpp b/Tests/DiligentCoreAPITest/src/D3D11/ClearRenderTargetRefenceD3D11.cpp new file mode 100644 index 00000000..72eef2c0 --- /dev/null +++ b/Tests/DiligentCoreAPITest/src/D3D11/ClearRenderTargetRefenceD3D11.cpp @@ -0,0 +1,47 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "D3D11/TestingEnvironmentD3D11.h" +#include "D3D11/TestingSwapChainD3D11.h" + +namespace Diligent +{ + +namespace Testing +{ + +void ClearRenderTargetReferenceD3D11(ISwapChain* pSwapChain) +{ + auto* pEnvD3D11 = TestingEnvironmentD3D11::GetInstance(); + auto* pd3d11Context = pEnvD3D11->GetD3D11Context(); + auto* pTestingSwapChainD3D11 = ValidatedCast(pSwapChain); + + float ClearColor[] = {0.25, 0.5, 0.75, 1.0}; + pd3d11Context->ClearRenderTargetView(pTestingSwapChainD3D11->GetD3D11RTV(), ClearColor); + + pd3d11Context->ClearState(); +} + +} // namespace Testing + +} // namespace Diligent diff --git a/Tests/DiligentCoreAPITest/src/D3D11/CreateObjFromNativeResD3D11.cpp b/Tests/DiligentCoreAPITest/src/D3D11/CreateObjFromNativeResD3D11.cpp new file mode 100644 index 00000000..08b9b6fd --- /dev/null +++ b/Tests/DiligentCoreAPITest/src/D3D11/CreateObjFromNativeResD3D11.cpp @@ -0,0 +1,136 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "D3D11/CreateObjFromNativeResD3D11.h" + +#include +#include "RenderDeviceD3D11.h" +#include "TextureD3D11.h" +#include "BufferD3D11.h" +#include "GraphicsAccessories.h" + +#include "gtest/gtest.h" + +namespace Diligent +{ + +namespace Testing +{ + +void TestCreateObjFromNativeResD3D11::CreateTexture(ITexture* pTexture) +{ + RefCntAutoPtr pDeviceD3D11(m_pDevice, IID_RenderDeviceD3D11); + RefCntAutoPtr pTextureD3D11(pTexture, IID_TextureD3D11); + ASSERT_NE(pDeviceD3D11, nullptr); + ASSERT_NE(pTextureD3D11, nullptr); + + auto* pd3d11Texture = pTextureD3D11->GetD3D11Texture(); + ASSERT_NE(pd3d11Texture, nullptr); + + const auto& SrcTexDesc = pTexture->GetDesc(); + + RefCntAutoPtr pTextureFromNativeD3D11Handle; + if (SrcTexDesc.Type == RESOURCE_DIM_TEX_1D || + SrcTexDesc.Type == RESOURCE_DIM_TEX_1D_ARRAY) + { + pDeviceD3D11->CreateTextureFromD3DResource(static_cast(pd3d11Texture), RESOURCE_STATE_UNKNOWN, &pTextureFromNativeD3D11Handle); + } + else if (SrcTexDesc.Type == RESOURCE_DIM_TEX_2D || + SrcTexDesc.Type == RESOURCE_DIM_TEX_2D_ARRAY || + SrcTexDesc.Type == RESOURCE_DIM_TEX_CUBE || + SrcTexDesc.Type == RESOURCE_DIM_TEX_CUBE_ARRAY) + { + pDeviceD3D11->CreateTextureFromD3DResource(static_cast(pd3d11Texture), RESOURCE_STATE_UNKNOWN, &pTextureFromNativeD3D11Handle); + } + else if (SrcTexDesc.Type == RESOURCE_DIM_TEX_3D) + { + pDeviceD3D11->CreateTextureFromD3DResource(static_cast(pd3d11Texture), RESOURCE_STATE_UNKNOWN, &pTextureFromNativeD3D11Handle); + } + else + { + ADD_FAILURE(); + } + + ASSERT_NE(pTextureFromNativeD3D11Handle, nullptr); + + auto TestTexDesc = pTextureFromNativeD3D11Handle->GetDesc(); + if (SrcTexDesc.Type == RESOURCE_DIM_TEX_CUBE || SrcTexDesc.Type == RESOURCE_DIM_TEX_CUBE_ARRAY) + { + EXPECT_EQ(TestTexDesc.Type, RESOURCE_DIM_TEX_2D_ARRAY); + TestTexDesc.Type = SrcTexDesc.Type; + } + EXPECT_EQ(TestTexDesc, SrcTexDesc) << "Src tex desc: " << GetObjectDescString(SrcTexDesc) + << "\nTest tex desc: " << GetObjectDescString(TestTexDesc); + + RefCntAutoPtr pTestTextureD3D11(pTextureFromNativeD3D11Handle, IID_TextureD3D11); + ASSERT_NE(pTestTextureD3D11, nullptr); + EXPECT_EQ(pTestTextureD3D11->GetD3D11Texture(), pd3d11Texture); + EXPECT_EQ(pTestTextureD3D11->GetNativeHandle(), pd3d11Texture); +} + +void TestCreateObjFromNativeResD3D11::CreateBuffer(IBuffer* pBuffer) +{ + RefCntAutoPtr pDeviceD3D11(m_pDevice, IID_RenderDeviceD3D11); + RefCntAutoPtr pBufferD3D11(pBuffer, IID_BufferD3D11); + ASSERT_NE(pDeviceD3D11, nullptr); + ASSERT_NE(pBufferD3D11, nullptr); + + auto* pd3d11Buffer = pBufferD3D11->GetD3D11Buffer(); + ASSERT_NE(pd3d11Buffer, nullptr); + + const auto& SrcBuffDesc = pBuffer->GetDesc(); + { + RefCntAutoPtr pBufferFromNativeD3D11Handle; + pDeviceD3D11->CreateBufferFromD3DResource(pd3d11Buffer, SrcBuffDesc, RESOURCE_STATE_UNKNOWN, &pBufferFromNativeD3D11Handle); + ASSERT_NE(pBufferFromNativeD3D11Handle, nullptr); + + const auto& TestBufferDesc = pBufferFromNativeD3D11Handle->GetDesc(); + EXPECT_EQ(TestBufferDesc, SrcBuffDesc); + + RefCntAutoPtr pTestBufferD3D11(pBufferFromNativeD3D11Handle, IID_BufferD3D11); + EXPECT_EQ(pTestBufferD3D11->GetD3D11Buffer(), pd3d11Buffer); + EXPECT_EQ(pTestBufferD3D11->GetNativeHandle(), pd3d11Buffer); + } + + { + BufferDesc BuffDesc; + BuffDesc.Name = "Test buffer from D3D11 buffer"; + BuffDesc.ElementByteStride = SrcBuffDesc.ElementByteStride; + RefCntAutoPtr pBufferFromNativeD3D11Handle; + pDeviceD3D11->CreateBufferFromD3DResource(pd3d11Buffer, BuffDesc, RESOURCE_STATE_UNKNOWN, &pBufferFromNativeD3D11Handle); + ASSERT_NE(pBufferFromNativeD3D11Handle, nullptr); + + const auto& TestBufferDesc = pBufferFromNativeD3D11Handle->GetDesc(); + EXPECT_EQ(TestBufferDesc, SrcBuffDesc) << "Src buff desc: " << GetObjectDescString(SrcBuffDesc) + << "\nTest buff desc: " << GetObjectDescString(TestBufferDesc); + + RefCntAutoPtr pTestBufferD3D11(pBufferFromNativeD3D11Handle, IID_BufferD3D11); + ASSERT_NE(pTestBufferD3D11, nullptr); + EXPECT_EQ(pTestBufferD3D11->GetD3D11Buffer(), pd3d11Buffer); + EXPECT_EQ(pTestBufferD3D11->GetNativeHandle(), pd3d11Buffer); + } +} + +} // namespace Testing + +} // namespace Diligent diff --git a/Tests/DiligentCoreAPITest/src/D3D11/DrawCommandReferenceD3D11.cpp b/Tests/DiligentCoreAPITest/src/D3D11/DrawCommandReferenceD3D11.cpp new file mode 100644 index 00000000..01fa5c78 --- /dev/null +++ b/Tests/DiligentCoreAPITest/src/D3D11/DrawCommandReferenceD3D11.cpp @@ -0,0 +1,121 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "D3D11/TestingEnvironmentD3D11.h" +#include "D3D11/TestingSwapChainD3D11.h" + +namespace Diligent +{ + +namespace Testing +{ + +static const char* VSSource = R"( +struct PSInput +{ + float4 Pos : SV_POSITION; + float3 Color : COLOR; +}; + +void main(in uint VertId : SV_VertexID, + out PSInput PSIn) +{ + float4 Pos[6]; + Pos[0] = float4(-1.0, -0.5, 0.0, 1.0); + Pos[1] = float4(-0.5, +0.5, 0.0, 1.0); + Pos[2] = float4( 0.0, -0.5, 0.0, 1.0); + + Pos[3] = float4(+0.0, -0.5, 0.0, 1.0); + Pos[4] = float4(+0.5, +0.5, 0.0, 1.0); + Pos[5] = float4(+1.0, -0.5, 0.0, 1.0); + + float3 Col[6]; + Col[0] = float3(1.0, 0.0, 0.0); + Col[1] = float3(0.0, 1.0, 0.0); + Col[2] = float3(0.0, 0.0, 1.0); + + Col[3] = float3(1.0, 0.0, 0.0); + Col[4] = float3(0.0, 1.0, 0.0); + Col[5] = float3(0.0, 0.0, 1.0); + + PSIn.Pos = Pos[VertId]; + PSIn.Color = Col[VertId]; +} +)"; + +static const char* PSSource = R"( +struct PSInput +{ + float4 Pos : SV_POSITION; + float3 Color : COLOR; +}; + +float4 main(in PSInput PSIn) : SV_Target +{ + return float4(PSIn.Color.rgb, 1.0); +} +)"; + +void RenderDrawCommandReferenceD3D11(ISwapChain* pSwapChain) +{ + auto* pEnvD3D11 = TestingEnvironmentD3D11::GetInstance(); + auto* pd3d11Context = pEnvD3D11->GetD3D11Context(); + auto* pTestingSwapChainD3D11 = ValidatedCast(pSwapChain); + + pd3d11Context->ClearState(); + + auto pVS = pEnvD3D11->CreateVertexShader(VSSource); + ASSERT_NE(pVS, nullptr); + + auto pPS = pEnvD3D11->CreatePixelShader(PSSource); + ASSERT_NE(pPS, nullptr); + + pd3d11Context->VSSetShader(pVS, nullptr, 0); + pd3d11Context->PSSetShader(pPS, nullptr, 0); + pd3d11Context->RSSetState(pEnvD3D11->GetNoCullRS()); + pd3d11Context->OMSetBlendState(pEnvD3D11->GetDefaultBS(), nullptr, 0xFFFFFFFF); + pd3d11Context->OMSetDepthStencilState(pEnvD3D11->GetDisableDepthDSS(), 0); + pd3d11Context->IASetInputLayout(nullptr); + + ID3D11RenderTargetView* pd3d11RTVs[] = {pTestingSwapChainD3D11->GetD3D11RTV()}; + pd3d11Context->OMSetRenderTargets(1, pd3d11RTVs, nullptr); + float ClearColor[] = {0, 0, 0, 0}; + pd3d11Context->ClearRenderTargetView(pd3d11RTVs[0], ClearColor); + + D3D11_VIEWPORT d3dVP = {}; + + const auto& SCDesc = pTestingSwapChainD3D11->GetDesc(); + d3dVP.Width = static_cast(SCDesc.Width); + d3dVP.Height = static_cast(SCDesc.Height); + d3dVP.MaxDepth = 1; + pd3d11Context->RSSetViewports(1, &d3dVP); + + pd3d11Context->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST); + pd3d11Context->Draw(6, 0); + + pd3d11Context->ClearState(); +} + +} // namespace Testing + +} // namespace Diligent diff --git a/Tests/DiligentCoreAPITest/src/D3D11/TestingEnvironmentD3D11.cpp b/Tests/DiligentCoreAPITest/src/D3D11/TestingEnvironmentD3D11.cpp new file mode 100644 index 00000000..3f63218f --- /dev/null +++ b/Tests/DiligentCoreAPITest/src/D3D11/TestingEnvironmentD3D11.cpp @@ -0,0 +1,244 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "D3D11/TestingEnvironmentD3D11.h" + +#include "RenderDeviceD3D11.h" +#include "DeviceContextD3D11.h" + +#include + +namespace Diligent +{ + +namespace Testing +{ + +void CreateTestingSwapChainD3D11(IRenderDevice* pDevice, + IDeviceContext* pContext, + const SwapChainDesc& SCDesc, + ISwapChain** ppSwapChain); + + +TestingEnvironmentD3D11::TestingEnvironmentD3D11(DeviceType deviceType, ADAPTER_TYPE AdapterType, const SwapChainDesc& SCDesc) : + TestingEnvironment{deviceType, AdapterType, SCDesc} +{ + RefCntAutoPtr pRenderDeviceD3D11{m_pDevice, IID_RenderDeviceD3D11}; + RefCntAutoPtr pContextD3D11{m_pDeviceContext, IID_DeviceContextD3D11}; + + m_pd3d11Device = pRenderDeviceD3D11->GetD3D11Device(); + m_pd3d11Context = pContextD3D11->GetD3D11DeviceContext(); + + { + D3D11_RASTERIZER_DESC RSDesc = {}; + + RSDesc.CullMode = D3D11_CULL_NONE; + RSDesc.FillMode = D3D11_FILL_SOLID; + auto hr = m_pd3d11Device->CreateRasterizerState(&RSDesc, &m_pd3d11NoCullRS); + VERIFY_EXPR(SUCCEEDED(hr)); + } + + { + D3D11_DEPTH_STENCIL_DESC DSDesc = {}; + + DSDesc.DepthEnable = False; + auto hr = m_pd3d11Device->CreateDepthStencilState(&DSDesc, &m_pd3d11DisableDepthDSS); + VERIFY_EXPR(SUCCEEDED(hr)); + } + + { + D3D11_BLEND_DESC BSDesc = {}; + + BSDesc.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL; + + auto hr = m_pd3d11Device->CreateBlendState(&BSDesc, &m_pd3d11DefaultBS); + VERIFY_EXPR(SUCCEEDED(hr)); + } + + if (m_pSwapChain == nullptr) + { + CreateTestingSwapChainD3D11(m_pDevice, m_pDeviceContext, SCDesc, &m_pSwapChain); + } +} + +HRESULT CompileD3DShader(const char* Source, + LPCSTR strFunctionName, + const D3D_SHADER_MACRO* pDefines, + LPCSTR profile, + ID3DBlob** ppBlobOut) +{ + DWORD dwShaderFlags = D3DCOMPILE_ENABLE_STRICTNESS; +#if defined(DEBUG) || defined(_DEBUG) + // Set the D3D10_SHADER_DEBUG flag to embed debug information in the shaders. + // Setting this flag improves the shader debugging experience, but still allows + // the shaders to be optimized and to run exactly the way they will run in + // the release configuration of this program. + dwShaderFlags |= D3DCOMPILE_DEBUG; +#else + // Warning: do not use this flag as it causes shader compiler to fail the compilation and + // report strange errors: + // dwShaderFlags |= D3D10_SHADER_OPTIMIZATION_LEVEL3; +#endif + + CComPtr pCompilerOutput; + + auto SourceLen = strlen(Source); + + auto hr = D3DCompile(Source, SourceLen, NULL, pDefines, nullptr, strFunctionName, profile, dwShaderFlags, 0, ppBlobOut, &pCompilerOutput); + + const char* CompilerMsg = pCompilerOutput ? reinterpret_cast(pCompilerOutput->GetBufferPointer()) : nullptr; + if (FAILED(hr)) + { + LOG_ERROR_AND_THROW("Failed to compile D3D shader :\n", (CompilerMsg != nullptr ? CompilerMsg : "")); + } + else if (CompilerMsg != nullptr) + { + LOG_INFO_MESSAGE("Shader compiler output:\n", CompilerMsg); + } + + return hr; +} + +CComPtr TestingEnvironmentD3D11::CreateVertexShader(const char* Source, + LPCSTR strFunctionName, + const D3D_SHADER_MACRO* pDefines, + LPCSTR profile) +{ + CComPtr pByteCode; + CComPtr pVS; + + auto hr = CompileD3DShader(Source, strFunctionName, pDefines, profile, &pByteCode); + if (FAILED(hr)) + { + ADD_FAILURE() << "Failed to compile vertex shader"; + return pVS; + } + + hr = m_pd3d11Device->CreateVertexShader(pByteCode->GetBufferPointer(), pByteCode->GetBufferSize(), NULL, &pVS); + if (FAILED(hr)) + { + ADD_FAILURE() << "Failed to create vertex shader"; + } + return pVS; +} + +CComPtr TestingEnvironmentD3D11::CreatePixelShader(const char* Source, + LPCSTR strFunctionName, + const D3D_SHADER_MACRO* pDefines, + LPCSTR profile) +{ + CComPtr pByteCode; + CComPtr pPS; + + auto hr = CompileD3DShader(Source, strFunctionName, pDefines, profile, &pByteCode); + if (FAILED(hr)) + { + ADD_FAILURE() << "Failed to compile pixel shader"; + return pPS; + } + + hr = m_pd3d11Device->CreatePixelShader(pByteCode->GetBufferPointer(), pByteCode->GetBufferSize(), NULL, &pPS); + if (FAILED(hr)) + { + ADD_FAILURE() << "Failed to create pixel shader"; + } + return pPS; +} + +CComPtr TestingEnvironmentD3D11::CreateGeometryShader(const char* Source, + LPCSTR strFunctionName, + const D3D_SHADER_MACRO* pDefines, + LPCSTR profile) +{ + CComPtr pByteCode; + CComPtr pGS; + + auto hr = CompileD3DShader(Source, strFunctionName, pDefines, profile, &pByteCode); + if (FAILED(hr)) + { + ADD_FAILURE() << "Failed to compile geometry shader"; + return pGS; + } + + hr = m_pd3d11Device->CreateGeometryShader(pByteCode->GetBufferPointer(), pByteCode->GetBufferSize(), NULL, &pGS); + if (FAILED(hr)) + { + ADD_FAILURE() << "Failed to create geometry shader"; + } + return pGS; +} + +CComPtr TestingEnvironmentD3D11::CreateDomainShader(const char* Source, + LPCSTR strFunctionName, + const D3D_SHADER_MACRO* pDefines, + LPCSTR profile) +{ + CComPtr pByteCode; + CComPtr pDS; + + auto hr = CompileD3DShader(Source, strFunctionName, pDefines, profile, &pByteCode); + if (FAILED(hr)) + { + ADD_FAILURE() << "Failed to compile domain shader"; + return pDS; + } + + hr = m_pd3d11Device->CreateDomainShader(pByteCode->GetBufferPointer(), pByteCode->GetBufferSize(), NULL, &pDS); + if (FAILED(hr)) + { + ADD_FAILURE() << "Failed to create domain shader"; + } + return pDS; +} + +CComPtr TestingEnvironmentD3D11::CreateHullShader(const char* Source, + LPCSTR strFunctionName, + const D3D_SHADER_MACRO* pDefines, + LPCSTR profile) +{ + CComPtr pByteCode; + CComPtr pDS; + + auto hr = CompileD3DShader(Source, strFunctionName, pDefines, profile, &pByteCode); + if (FAILED(hr)) + { + ADD_FAILURE() << "Failed to compile hull shader"; + return pDS; + } + + hr = m_pd3d11Device->CreateHullShader(pByteCode->GetBufferPointer(), pByteCode->GetBufferSize(), NULL, &pDS); + if (FAILED(hr)) + { + ADD_FAILURE() << "Failed to create hull shader"; + } + return pDS; +} + +TestingEnvironment* CreateTestingEnvironmentD3D11(DeviceType deviceType, ADAPTER_TYPE AdapterType, const SwapChainDesc& SCDesc) +{ + return new TestingEnvironmentD3D11{deviceType, AdapterType, SCDesc}; +} + +} // namespace Testing + +} // namespace Diligent diff --git a/Tests/DiligentCoreAPITest/src/D3D11/TestingSwapChainD3D11.cpp b/Tests/DiligentCoreAPITest/src/D3D11/TestingSwapChainD3D11.cpp new file mode 100644 index 00000000..675dd134 --- /dev/null +++ b/Tests/DiligentCoreAPITest/src/D3D11/TestingSwapChainD3D11.cpp @@ -0,0 +1,134 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "../include/D3D11/TestingSwapChainD3D11.h" +#include "../include/DXGITypeConversions.h" + +#include "RenderDeviceD3D11.h" +#include "DeviceContextD3D11.h" + +namespace Diligent +{ + +namespace Testing +{ + +TestingSwapChainD3D11::TestingSwapChainD3D11(IReferenceCounters* pRefCounters, + IRenderDevice* pDevice, + IDeviceContext* pContext, + const SwapChainDesc& SCDesc) : + TBase // + { + pRefCounters, + pDevice, + pContext, + SCDesc // + } +{ + RefCntAutoPtr pRenderDeviceD3D11{pDevice, IID_RenderDeviceD3D11}; + RefCntAutoPtr pContextD3D11{pContext, IID_DeviceContextD3D11}; + + auto* pd3d11Device = pRenderDeviceD3D11->GetD3D11Device(); + m_pd3d11Context = pContextD3D11->GetD3D11DeviceContext(); + + D3D11_TEXTURE2D_DESC TexDesc = {}; + + TexDesc.Width = SCDesc.Width; + TexDesc.Height = SCDesc.Height; + TexDesc.MipLevels = 1; + TexDesc.ArraySize = 1; + TexDesc.Format = TexFormatToDXGI_Format(SCDesc.ColorBufferFormat); + TexDesc.SampleDesc.Count = 1; + TexDesc.SampleDesc.Quality = 0; + TexDesc.Usage = D3D11_USAGE_DEFAULT; + TexDesc.BindFlags = BIND_RENDER_TARGET; + TexDesc.CPUAccessFlags = 0; + TexDesc.MiscFlags = 0; + + auto hr = pd3d11Device->CreateTexture2D(&TexDesc, nullptr, &m_pd3d11RenderTarget); + VERIFY(SUCCEEDED(hr), "Failed to create D3D11 render target"); + + hr = pd3d11Device->CreateRenderTargetView(m_pd3d11RenderTarget, nullptr, &m_pd3d11RTV); + VERIFY(SUCCEEDED(hr), "Failed to create D3D11 render target view"); + + TexDesc.BindFlags = 0; + TexDesc.Usage = D3D11_USAGE_STAGING; + TexDesc.CPUAccessFlags = D3D11_CPU_ACCESS_READ; + + hr = pd3d11Device->CreateTexture2D(&TexDesc, nullptr, &m_pd3d11StagingTex); + VERIFY(SUCCEEDED(hr), "Failed to create staging D3D11 texture"); + + if (SCDesc.DepthBufferFormat != TEX_FORMAT_UNKNOWN) + { + TexDesc.Usage = D3D11_USAGE_DEFAULT; + TexDesc.Format = TexFormatToDXGI_Format(SCDesc.DepthBufferFormat); + TexDesc.BindFlags = BIND_DEPTH_STENCIL; + TexDesc.CPUAccessFlags = 0; + + hr = pd3d11Device->CreateTexture2D(&TexDesc, nullptr, &m_pd3d11DepthBuffer); + VERIFY(SUCCEEDED(hr), "Failed to create D3D11 depth buffer"); + + hr = pd3d11Device->CreateDepthStencilView(m_pd3d11DepthBuffer, nullptr, &m_pd3d11DSV); + VERIFY(SUCCEEDED(hr), "Failed to create D3D11 depth-stencil view"); + } +} + +void TestingSwapChainD3D11::TakeSnapshot() +{ + m_pd3d11Context->CopyResource(m_pd3d11StagingTex, m_pd3d11RenderTarget); + D3D11_MAPPED_SUBRESOURCE MappedData; + + auto hr = m_pd3d11Context->Map(m_pd3d11StagingTex, 0, D3D11_MAP_READ, 0, &MappedData); + if (SUCCEEDED(hr)) + { + m_ReferenceDataPitch = MappedData.RowPitch; + m_ReferenceData.resize(m_ReferenceDataPitch * m_SwapChainDesc.Height); + for (Uint32 row = 0; row < m_SwapChainDesc.Height; ++row) + { + memcpy(&m_ReferenceData[row * m_ReferenceDataPitch], + reinterpret_cast(MappedData.pData) + row * m_ReferenceDataPitch, + m_ReferenceDataPitch); + } + } + else + { + ADD_FAILURE() << "Failed to map stagin texture"; + return; + } + + m_pd3d11Context->Unmap(m_pd3d11StagingTex, 0); + m_pd3d11Context->ClearState(); +} + +void CreateTestingSwapChainD3D11(IRenderDevice* pDevice, + IDeviceContext* pContext, + const SwapChainDesc& SCDesc, + ISwapChain** ppSwapChain) +{ + TestingSwapChainD3D11* pTestingSC(MakeNewRCObj()(pDevice, pContext, SCDesc)); + pTestingSC->QueryInterface(IID_SwapChain, reinterpret_cast(ppSwapChain)); +} + +} // namespace Testing + +} // namespace Diligent diff --git a/Tests/DiligentCoreAPITest/src/D3D12/ClearRenderTargetRefenceD3D12.cpp b/Tests/DiligentCoreAPITest/src/D3D12/ClearRenderTargetRefenceD3D12.cpp new file mode 100644 index 00000000..0a2fe8ab --- /dev/null +++ b/Tests/DiligentCoreAPITest/src/D3D12/ClearRenderTargetRefenceD3D12.cpp @@ -0,0 +1,64 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "D3D12/TestingEnvironmentD3D12.h" +#include "D3D12/TestingSwapChainD3D12.h" + +#include "DeviceContextD3D12.h" + +namespace Diligent +{ + +namespace Testing +{ + +void ClearRenderTargetReferenceD3D12(ISwapChain* pSwapChain) +{ + auto* pEnv = TestingEnvironmentD3D12::GetInstance(); + auto* pContext = pEnv->GetDeviceContext(); + auto* pTestingSwapChainD3D12 = ValidatedCast(pSwapChain); + + auto pCmdList = pEnv->CreateGraphicsCommandList(); + pTestingSwapChainD3D12->TransitionRenderTarget(pCmdList, D3D12_RESOURCE_STATE_RENDER_TARGET); + + auto RTVDesriptorHandle = pTestingSwapChainD3D12->GetRTVDescriptorHandle(); + + float ClearColor[] = {0.25, 0.5, 0.75, 1.0}; + pCmdList->ClearRenderTargetView(RTVDesriptorHandle, ClearColor, 0, nullptr); + + pCmdList->Close(); + ID3D12CommandList* pCmdLits[] = {pCmdList}; + + RefCntAutoPtr pContextD3D12{pContext, IID_DeviceContextD3D12}; + + auto* pQeueD3D12 = pContextD3D12->LockCommandQueue(); + auto* pd3d12Queue = pQeueD3D12->GetD3D12CommandQueue(); + + pd3d12Queue->ExecuteCommandLists(_countof(pCmdLits), pCmdLits); + + pContextD3D12->UnlockCommandQueue(); +} + +} // namespace Testing + +} // namespace Diligent diff --git a/Tests/DiligentCoreAPITest/src/D3D12/CreateObjFromNativeResD3D12.cpp b/Tests/DiligentCoreAPITest/src/D3D12/CreateObjFromNativeResD3D12.cpp new file mode 100644 index 00000000..d76e084d --- /dev/null +++ b/Tests/DiligentCoreAPITest/src/D3D12/CreateObjFromNativeResD3D12.cpp @@ -0,0 +1,104 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "D3D12/CreateObjFromNativeResD3D12.h" +#include +#include "RenderDeviceD3D12.h" +#include "TextureD3D12.h" +#include "BufferD3D12.h" +#include "GraphicsAccessories.h" + +#include "gtest/gtest.h" + +namespace Diligent +{ + +namespace Testing +{ + +void TestCreateObjFromNativeResD3D12::CreateTexture(Diligent::ITexture* pTexture) +{ + RefCntAutoPtr pDeviceD3D12(m_pDevice, IID_RenderDeviceD3D12); + RefCntAutoPtr pTextureD3D12(pTexture, IID_TextureD3D12); + ASSERT_NE(pDeviceD3D12, nullptr); + ASSERT_NE(pTextureD3D12, nullptr); + + const auto& SrcTexDesc = pTexture->GetDesc(); + auto* pD3D12Texture = pTextureD3D12->GetD3D12Texture(); + ASSERT_NE(pD3D12Texture, nullptr); + + RefCntAutoPtr pTextureFromNativeD3D12Handle; + pDeviceD3D12->CreateTextureFromD3DResource(pD3D12Texture, RESOURCE_STATE_UNKNOWN, &pTextureFromNativeD3D12Handle); + ASSERT_NE(pTextureFromNativeD3D12Handle, nullptr); + + auto TestTexDesc = pTextureFromNativeD3D12Handle->GetDesc(); + if (SrcTexDesc.Type == RESOURCE_DIM_TEX_CUBE || SrcTexDesc.Type == RESOURCE_DIM_TEX_CUBE_ARRAY) + { + EXPECT_EQ(TestTexDesc.Type, RESOURCE_DIM_TEX_2D_ARRAY); + TestTexDesc.Type = SrcTexDesc.Type; + } + EXPECT_EQ(TestTexDesc, SrcTexDesc) << "Src tex desc: " << GetObjectDescString(SrcTexDesc) + << "\nTest tex desc: " << GetObjectDescString(TestTexDesc); + + RefCntAutoPtr pTestTextureD3D12(pTextureFromNativeD3D12Handle, IID_TextureD3D12); + ASSERT_NE(pTestTextureD3D12, nullptr); + EXPECT_EQ(pTestTextureD3D12->GetD3D12Texture(), pD3D12Texture); + EXPECT_EQ(pTestTextureD3D12->GetNativeHandle(), pD3D12Texture); +} + +void TestCreateObjFromNativeResD3D12::CreateBuffer(Diligent::IBuffer* pBuffer) +{ + RefCntAutoPtr pDeviceD3D12(m_pDevice, IID_RenderDeviceD3D12); + RefCntAutoPtr pBufferD3D12(pBuffer, IID_BufferD3D12); + ASSERT_NE(pDeviceD3D12, nullptr); + ASSERT_NE(pBufferD3D12, nullptr); + + + Uint64 DataStartByteOffset; + auto* pD3D12Buffer = pBufferD3D12->GetD3D12Buffer(DataStartByteOffset, nullptr); + ASSERT_NE(pD3D12Buffer, nullptr); + EXPECT_EQ(DataStartByteOffset, 0); + + const auto& SrcBuffDesc = pBuffer->GetDesc(); + { + RefCntAutoPtr pBufferFromNativeD3D12Handle; + pDeviceD3D12->CreateBufferFromD3DResource(pD3D12Buffer, SrcBuffDesc, RESOURCE_STATE_UNKNOWN, &pBufferFromNativeD3D12Handle); + ASSERT_NE(pBufferFromNativeD3D12Handle, nullptr); + + const auto& TestBufferDesc = pBufferFromNativeD3D12Handle->GetDesc(); + EXPECT_EQ(TestBufferDesc, SrcBuffDesc) << "Src buff desc: " << GetObjectDescString(SrcBuffDesc) + << "\nTest buff desc: " << GetObjectDescString(TestBufferDesc); + + RefCntAutoPtr pTestBufferD3D12(pBufferFromNativeD3D12Handle, IID_BufferD3D12); + ASSERT_NE(pTestBufferD3D12, nullptr); + + Uint64 TestBuffDataStartByteOffset; + EXPECT_EQ(pTestBufferD3D12->GetD3D12Buffer(TestBuffDataStartByteOffset, nullptr), pD3D12Buffer); + EXPECT_EQ(TestBuffDataStartByteOffset, 0); + EXPECT_EQ(pTestBufferD3D12->GetNativeHandle(), pD3D12Buffer); + } +} + +} // namespace Testing + +} // namespace Diligent diff --git a/Tests/DiligentCoreAPITest/src/D3D12/D3D12DebugLayerSetNameBugWorkaround.cpp b/Tests/DiligentCoreAPITest/src/D3D12/D3D12DebugLayerSetNameBugWorkaround.cpp new file mode 100644 index 00000000..e186dbfd --- /dev/null +++ b/Tests/DiligentCoreAPITest/src/D3D12/D3D12DebugLayerSetNameBugWorkaround.cpp @@ -0,0 +1,76 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "D3D12/D3D12DebugLayerSetNameBugWorkaround.h" + +#include "RefCntAutoPtr.h" + +#ifndef NOMINMAX +# define NOMINMAX +#endif + +#include +#include + +#include "RenderDeviceD3D12.h" + +namespace Diligent +{ + +namespace Testing +{ + +struct D3D12DebugLayerSetNameBugWorkaround::RootSignatureWrapper +{ + CComPtr pRootSignature; +}; + +D3D12DebugLayerSetNameBugWorkaround::D3D12DebugLayerSetNameBugWorkaround(IRenderDevice* pDevice) : + m_RootSignature(new RootSignatureWrapper) +{ + if (pDevice->GetDeviceCaps().DevType != DeviceType::D3D12) + return; + + RefCntAutoPtr pDeviceD3D12(pDevice, IID_RenderDeviceD3D12); + VERIFY_EXPR(pDeviceD3D12); + auto pd3d12Device = pDeviceD3D12->GetD3D12Device(); + + D3D12_ROOT_SIGNATURE_DESC RootSignatureDesc = {}; + + RootSignatureDesc.Flags = D3D12_ROOT_SIGNATURE_FLAG_ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT; + + CComPtr signature; + D3D12SerializeRootSignature(&RootSignatureDesc, D3D_ROOT_SIGNATURE_VERSION_1, &signature, nullptr); + auto& pRootSign = m_RootSignature->pRootSignature; + pd3d12Device->CreateRootSignature(0, signature->GetBufferPointer(), signature->GetBufferSize(), __uuidof(pRootSign), reinterpret_cast(static_cast(&pRootSign))); + pRootSign->SetName(L"A long string to make sure there is enough space reserved in the buffer to avoid resize when SetName is called " + "and it is accessed simultaneously from multiple threads without a mutex"); +} + +D3D12DebugLayerSetNameBugWorkaround::~D3D12DebugLayerSetNameBugWorkaround() +{ +} + +} // namespace Testing + +} // namespace Diligent diff --git a/Tests/DiligentCoreAPITest/src/D3D12/DrawCommandReferenceD3D12.cpp b/Tests/DiligentCoreAPITest/src/D3D12/DrawCommandReferenceD3D12.cpp new file mode 100644 index 00000000..b10da269 --- /dev/null +++ b/Tests/DiligentCoreAPITest/src/D3D12/DrawCommandReferenceD3D12.cpp @@ -0,0 +1,180 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "D3D12/TestingEnvironmentD3D12.h" +#include "D3D12/TestingSwapChainD3D12.h" +#include "../include/DXGITypeConversions.h" +#include "../include/d3dx12_win.h" + +#include "RenderDeviceD3D12.h" +#include "DeviceContextD3D12.h" + +namespace Diligent +{ + +namespace Testing +{ + +static const char* VSSource = R"( +struct PSInput +{ + float4 Pos : SV_POSITION; + float3 Color : COLOR; +}; + +void main(in uint VertId : SV_VertexID, + out PSInput PSIn) +{ + float4 Pos[6]; + Pos[0] = float4(-1.0, -0.5, 0.0, 1.0); + Pos[1] = float4(-0.5, +0.5, 0.0, 1.0); + Pos[2] = float4( 0.0, -0.5, 0.0, 1.0); + + Pos[3] = float4(+0.0, -0.5, 0.0, 1.0); + Pos[4] = float4(+0.5, +0.5, 0.0, 1.0); + Pos[5] = float4(+1.0, -0.5, 0.0, 1.0); + + float3 Col[6]; + Col[0] = float3(1.0, 0.0, 0.0); + Col[1] = float3(0.0, 1.0, 0.0); + Col[2] = float3(0.0, 0.0, 1.0); + + Col[3] = float3(1.0, 0.0, 0.0); + Col[4] = float3(0.0, 1.0, 0.0); + Col[5] = float3(0.0, 0.0, 1.0); + + PSIn.Pos = Pos[VertId]; + PSIn.Color = Col[VertId]; +} +)"; + +static const char* PSSource = R"( +struct PSInput +{ + float4 Pos : SV_POSITION; + float3 Color : COLOR; +}; + +float4 main(in PSInput PSIn) : SV_Target +{ + return float4(PSIn.Color.rgb, 1.0); +} +)"; + +void RenderDrawCommandReferenceD3D12(ISwapChain* pSwapChain) +{ + auto* pEnv = TestingEnvironmentD3D12::GetInstance(); + auto* pContext = pEnv->GetDeviceContext(); + auto* pd3d12Device = pEnv->GetD3D12Device(); + auto* pTestingSwapChainD3D12 = ValidatedCast(pSwapChain); + + const auto& SCDesc = pSwapChain->GetDesc(); + + CComPtr pVSByteCode, pPSByteCode; + + auto hr = CompileD3DShader(VSSource, "main", nullptr, "vs_5_0", &pVSByteCode); + ASSERT_HRESULT_SUCCEEDED(hr) << "Failed to compile vertex shader"; + + hr = CompileD3DShader(PSSource, "main", nullptr, "ps_5_0", &pPSByteCode); + ASSERT_HRESULT_SUCCEEDED(hr) << "Failed to compile pixel shader"; + + + D3D12_ROOT_SIGNATURE_DESC RootSignatureDesc = {}; + + RootSignatureDesc.Flags = D3D12_ROOT_SIGNATURE_FLAG_ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT; + + CComPtr signature; + CComPtr pd3d12RootSignature; + D3D12SerializeRootSignature(&RootSignatureDesc, D3D_ROOT_SIGNATURE_VERSION_1, &signature, nullptr); + pd3d12Device->CreateRootSignature(0, signature->GetBufferPointer(), signature->GetBufferSize(), __uuidof(pd3d12RootSignature), reinterpret_cast(static_cast(&pd3d12RootSignature))); + + D3D12_GRAPHICS_PIPELINE_STATE_DESC PSODesc = {}; + + PSODesc.pRootSignature = pd3d12RootSignature; + PSODesc.VS.pShaderBytecode = pVSByteCode->GetBufferPointer(); + PSODesc.VS.BytecodeLength = pVSByteCode->GetBufferSize(); + PSODesc.PS.pShaderBytecode = pPSByteCode->GetBufferPointer(); + PSODesc.PS.BytecodeLength = pPSByteCode->GetBufferSize(); + + PSODesc.BlendState = CD3DX12_BLEND_DESC{D3D12_DEFAULT}; + PSODesc.RasterizerState = CD3DX12_RASTERIZER_DESC{D3D12_DEFAULT}; + PSODesc.DepthStencilState = CD3DX12_DEPTH_STENCIL_DESC{D3D12_DEFAULT}; + + PSODesc.RasterizerState.CullMode = D3D12_CULL_MODE_NONE; + PSODesc.DepthStencilState.DepthEnable = FALSE; + PSODesc.DepthStencilState.DepthWriteMask = D3D12_DEPTH_WRITE_MASK_ZERO; + + PSODesc.SampleMask = 0xFFFFFFFF; + + PSODesc.PrimitiveTopologyType = D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE; + PSODesc.NumRenderTargets = 1; + PSODesc.RTVFormats[0] = TexFormatToDXGI_Format(SCDesc.ColorBufferFormat); + PSODesc.SampleDesc.Count = 1; + PSODesc.SampleDesc.Quality = 0; + PSODesc.NodeMask = 0; + PSODesc.Flags = D3D12_PIPELINE_STATE_FLAG_NONE; + + CComPtr pd3d12PSO; + hr = pd3d12Device->CreateGraphicsPipelineState(&PSODesc, __uuidof(pd3d12PSO), reinterpret_cast(static_cast(&pd3d12PSO))); + ASSERT_HRESULT_SUCCEEDED(hr) << "Failed to create pipeline state"; + + auto pCmdList = pEnv->CreateGraphicsCommandList(); + pTestingSwapChainD3D12->TransitionRenderTarget(pCmdList, D3D12_RESOURCE_STATE_RENDER_TARGET); + + D3D12_VIEWPORT d3d12VP = {}; + d3d12VP.Width = static_cast(SCDesc.Width); + d3d12VP.Height = static_cast(SCDesc.Height); + d3d12VP.MaxDepth = 1; + pCmdList->RSSetViewports(1, &d3d12VP); + D3D12_RECT Rect = {0, 0, static_cast(SCDesc.Width), static_cast(SCDesc.Height)}; + pCmdList->RSSetScissorRects(1, &Rect); + + auto RTVDesriptorHandle = pTestingSwapChainD3D12->GetRTVDescriptorHandle(); + + pCmdList->OMSetRenderTargets(1, &RTVDesriptorHandle, FALSE, nullptr); + + float ClearColor[] = {0, 0, 0, 0}; + pCmdList->ClearRenderTargetView(RTVDesriptorHandle, ClearColor, 0, nullptr); + + pCmdList->SetPipelineState(pd3d12PSO); + pCmdList->SetGraphicsRootSignature(pd3d12RootSignature); + pCmdList->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST); + pCmdList->DrawInstanced(6, 1, 0, 0); + + pCmdList->Close(); + ID3D12CommandList* pCmdLits[] = {pCmdList}; + + RefCntAutoPtr pContextD3D12{pContext, IID_DeviceContextD3D12}; + + auto* pQeueD3D12 = pContextD3D12->LockCommandQueue(); + auto* pd3d12Queue = pQeueD3D12->GetD3D12CommandQueue(); + + pd3d12Queue->ExecuteCommandLists(_countof(pCmdLits), pCmdLits); + pEnv->IdleCommandQueue(pd3d12Queue); + + pContextD3D12->UnlockCommandQueue(); +} + +} // namespace Testing + +} // namespace Diligent diff --git a/Tests/DiligentCoreAPITest/src/D3D12/TestingEnvironmentD3D12.cpp b/Tests/DiligentCoreAPITest/src/D3D12/TestingEnvironmentD3D12.cpp new file mode 100644 index 00000000..214f239a --- /dev/null +++ b/Tests/DiligentCoreAPITest/src/D3D12/TestingEnvironmentD3D12.cpp @@ -0,0 +1,94 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "D3D12/TestingEnvironmentD3D12.h" +#include "RenderDeviceD3D12.h" + +namespace Diligent +{ + +namespace Testing +{ + +void CreateTestingSwapChainD3D12(IRenderDevice* pDevice, + IDeviceContext* pContext, + const SwapChainDesc& SCDesc, + ISwapChain** ppSwapChain); + +TestingEnvironmentD3D12::TestingEnvironmentD3D12(DeviceType deviceType, ADAPTER_TYPE AdapterType, const SwapChainDesc& SCDesc) : + TestingEnvironment{deviceType, AdapterType, SCDesc}, + m_WaitForGPUEventHandle{CreateEvent(nullptr, false, false, nullptr)} +{ + RefCntAutoPtr pRenderDeviceD3D12{m_pDevice, IID_RenderDeviceD3D12}; + m_pd3d12Device = pRenderDeviceD3D12->GetD3D12Device(); + auto hr = + m_pd3d12Device->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT, __uuidof(m_pd3d12CmdAllocator), + reinterpret_cast(static_cast(&m_pd3d12CmdAllocator))); + VERIFY_EXPR(SUCCEEDED(hr)); + + hr = m_pd3d12Device->CreateFence(0, D3D12_FENCE_FLAG_NONE, __uuidof(m_pd3d12Fence), + reinterpret_cast(static_cast(&m_pd3d12Fence))); + VERIFY_EXPR(SUCCEEDED(hr)); + + if (m_pSwapChain == nullptr) + { + CreateTestingSwapChainD3D12(m_pDevice, m_pDeviceContext, SCDesc, &m_pSwapChain); + } +} + +TestingEnvironmentD3D12::~TestingEnvironmentD3D12() +{ + CloseHandle(m_WaitForGPUEventHandle); +} + +CComPtr TestingEnvironmentD3D12::CreateGraphicsCommandList() +{ + CComPtr pd3d12CmdList; + m_pd3d12Device->CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, m_pd3d12CmdAllocator, nullptr, __uuidof(pd3d12CmdList), + reinterpret_cast(static_cast(&pd3d12CmdList))); + return pd3d12CmdList; +} + +void TestingEnvironmentD3D12::IdleCommandQueue(ID3D12CommandQueue* pd3d12Queue) +{ + Uint64 LastSignaledFenceValue = m_NextFenceValue; + ++m_NextFenceValue; + + pd3d12Queue->Signal(m_pd3d12Fence, LastSignaledFenceValue); + + if (m_pd3d12Fence->GetCompletedValue() < LastSignaledFenceValue) + { + m_pd3d12Fence->SetEventOnCompletion(LastSignaledFenceValue, m_WaitForGPUEventHandle); + WaitForSingleObject(m_WaitForGPUEventHandle, INFINITE); + VERIFY(m_pd3d12Fence->GetCompletedValue() == LastSignaledFenceValue, "Unexpected signaled fence value"); + } +} + +TestingEnvironment* CreateTestingEnvironmentD3D12(DeviceType deviceType, ADAPTER_TYPE AdapterType, const SwapChainDesc& SCDesc) +{ + return new TestingEnvironmentD3D12{deviceType, AdapterType, SCDesc}; +} + +} // namespace Testing + +} // namespace Diligent diff --git a/Tests/DiligentCoreAPITest/src/D3D12/TestingSwapChainD3D12.cpp b/Tests/DiligentCoreAPITest/src/D3D12/TestingSwapChainD3D12.cpp new file mode 100644 index 00000000..e893a1c0 --- /dev/null +++ b/Tests/DiligentCoreAPITest/src/D3D12/TestingSwapChainD3D12.cpp @@ -0,0 +1,257 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include + +#include "D3D12/TestingEnvironmentD3D12.h" +#include "D3D12/TestingSwapChainD3D12.h" +#include "../include/DXGITypeConversions.h" + +#include "RenderDeviceD3D12.h" +#include "DeviceContextD3D12.h" + +namespace Diligent +{ + +namespace Testing +{ + +TestingSwapChainD3D12::TestingSwapChainD3D12(IReferenceCounters* pRefCounters, + IRenderDevice* pDevice, + IDeviceContext* pContext, + const SwapChainDesc& SCDesc) : + TBase // + { + pRefCounters, + pDevice, + pContext, + SCDesc // + } +{ + RefCntAutoPtr pRenderDeviceD3D12{pDevice, IID_RenderDeviceD3D12}; + + auto* pd3d12Device = pRenderDeviceD3D12->GetD3D12Device(); + + D3D12_HEAP_PROPERTIES HeapProps = {}; + HeapProps.Type = D3D12_HEAP_TYPE_DEFAULT; + HeapProps.CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_UNKNOWN; + HeapProps.MemoryPoolPreference = D3D12_MEMORY_POOL_UNKNOWN; + HeapProps.CreationNodeMask = 1; + HeapProps.VisibleNodeMask = 1; + + D3D12_RESOURCE_DESC TexDesc = {}; + TexDesc.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D; + TexDesc.Alignment = 0; + TexDesc.Width = m_SwapChainDesc.Width; + TexDesc.Height = m_SwapChainDesc.Height; + TexDesc.DepthOrArraySize = 1; + TexDesc.MipLevels = 1; + TexDesc.Format = TexFormatToDXGI_Format(SCDesc.ColorBufferFormat); + TexDesc.SampleDesc.Count = 1; + TexDesc.SampleDesc.Quality = 0; + TexDesc.Layout = D3D12_TEXTURE_LAYOUT_UNKNOWN; + TexDesc.Flags = D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET; + + D3D12_CLEAR_VALUE ClearColorValue = {}; + ClearColorValue.Format = TexDesc.Format; + auto hr = + pd3d12Device->CreateCommittedResource(&HeapProps, D3D12_HEAP_FLAG_NONE, &TexDesc, m_RenderTargetState, &ClearColorValue, + __uuidof(m_pd3d12RenderTaget), + reinterpret_cast(static_cast(&m_pd3d12RenderTaget))); + VERIFY(SUCCEEDED(hr), "Failed to create D3D12 render target"); + + { + pd3d12Device->GetCopyableFootprints(&TexDesc, 0, 1, 0, &m_StagingBufferFootprint, nullptr, nullptr, &m_StagingBufferSize); + + D3D12_HEAP_PROPERTIES DownloadHeapProps; + DownloadHeapProps.Type = D3D12_HEAP_TYPE_READBACK; + DownloadHeapProps.CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_UNKNOWN; + DownloadHeapProps.MemoryPoolPreference = D3D12_MEMORY_POOL_UNKNOWN; + DownloadHeapProps.CreationNodeMask = 1; + DownloadHeapProps.VisibleNodeMask = 1; + + D3D12_RESOURCE_DESC BufferDesc; + BufferDesc.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER; + BufferDesc.Alignment = 0; + BufferDesc.Width = m_StagingBufferSize; + BufferDesc.Height = 1; + BufferDesc.DepthOrArraySize = 1; + BufferDesc.MipLevels = 1; + BufferDesc.Format = DXGI_FORMAT_UNKNOWN; + BufferDesc.SampleDesc.Count = 1; + BufferDesc.SampleDesc.Quality = 0; + BufferDesc.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR; + BufferDesc.Flags = D3D12_RESOURCE_FLAG_NONE; + + hr = pd3d12Device->CreateCommittedResource(&DownloadHeapProps, D3D12_HEAP_FLAG_NONE, + &BufferDesc, D3D12_RESOURCE_STATE_COPY_DEST, + nullptr, __uuidof(m_pd3d12StagingBuffer), + reinterpret_cast(static_cast(&m_pd3d12StagingBuffer))); + if (FAILED(hr)) + LOG_ERROR_AND_THROW("Failed to create committed staging buffer in an upload heap"); + } + + if (SCDesc.DepthBufferFormat != TEX_FORMAT_UNKNOWN) + { + TexDesc.Flags = D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL; + TexDesc.Format = TexFormatToDXGI_Format(SCDesc.DepthBufferFormat); + + D3D12_CLEAR_VALUE ClearDepthValue = {}; + ClearDepthValue.Format = TexDesc.Format; + ClearDepthValue.DepthStencil.Depth = 1; + hr = + pd3d12Device->CreateCommittedResource(&HeapProps, D3D12_HEAP_FLAG_NONE, &TexDesc, m_DepthBufferState, &ClearDepthValue, + __uuidof(m_pd3d12DepthBuffer), + reinterpret_cast(static_cast(&m_pd3d12DepthBuffer))); + VERIFY(SUCCEEDED(hr), "Failed to create D3D12 depth buffer"); + } + + D3D12_DESCRIPTOR_HEAP_DESC DescriptorHeapDesc = {}; + DescriptorHeapDesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_RTV; + DescriptorHeapDesc.NumDescriptors = 1; + DescriptorHeapDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_NONE; + DescriptorHeapDesc.NodeMask = 0; + hr = + pd3d12Device->CreateDescriptorHeap(&DescriptorHeapDesc, + __uuidof(m_pd3d12RTVDescriptorHeap), + reinterpret_cast(static_cast(&m_pd3d12RTVDescriptorHeap))); + VERIFY(SUCCEEDED(hr), "Failed to create D3D12 RTV descriptor heap"); + m_RTVDescriptorHandle = m_pd3d12RTVDescriptorHeap->GetCPUDescriptorHandleForHeapStart(); + pd3d12Device->CreateRenderTargetView(m_pd3d12RenderTaget, nullptr, m_RTVDescriptorHandle); + + DescriptorHeapDesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_DSV; + hr = + pd3d12Device->CreateDescriptorHeap(&DescriptorHeapDesc, + __uuidof(m_pd3d12DSVDescriptorHeap), + reinterpret_cast(static_cast(&m_pd3d12DSVDescriptorHeap))); + VERIFY(SUCCEEDED(hr), "Failed to create D3D12 DSV descriptor heap"); + m_DSVDescriptorHandle = m_pd3d12DSVDescriptorHeap->GetCPUDescriptorHandleForHeapStart(); + pd3d12Device->CreateDepthStencilView(m_pd3d12DepthBuffer, nullptr, m_DSVDescriptorHandle); +} + +void TestingSwapChainD3D12::TransitionBuffers(ID3D12GraphicsCommandList* pCmdList, + D3D12_RESOURCE_STATES RTVState, + D3D12_RESOURCE_STATES DSVState) +{ + std::vector Barriers; + if (m_RenderTargetState != RTVState) + { + D3D12_RESOURCE_BARRIER Barrier = {}; + Barrier.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION; + Barrier.Transition.pResource = m_pd3d12RenderTaget; + Barrier.Transition.StateBefore = m_RenderTargetState; + Barrier.Transition.StateAfter = RTVState; + Barrier.Transition.Subresource = 0; + + m_RenderTargetState = RTVState; + + Barriers.emplace_back(Barrier); + } + + if (m_DepthBufferState != DSVState) + { + D3D12_RESOURCE_BARRIER Barrier = {}; + Barrier.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION; + Barrier.Transition.pResource = m_pd3d12DepthBuffer; + Barrier.Transition.StateBefore = m_DepthBufferState; + Barrier.Transition.StateAfter = DSVState; + Barrier.Transition.Subresource = 0; + + m_DepthBufferState = DSVState; + + Barriers.emplace_back(Barrier); + } + + if (!Barriers.empty()) + { + pCmdList->ResourceBarrier(static_cast(Barriers.size()), Barriers.data()); + } +} + +void TestingSwapChainD3D12::TransitionRenderTarget(ID3D12GraphicsCommandList* pCmdList, + D3D12_RESOURCE_STATES RTVState) +{ + TransitionBuffers(pCmdList, RTVState, m_DepthBufferState); +} + +void TestingSwapChainD3D12::TakeSnapshot() +{ + auto* pEnv = TestingEnvironmentD3D12::GetInstance(); + auto* pContext = pEnv->GetDeviceContext(); + auto pCmdList = pEnv->CreateGraphicsCommandList(); + + TransitionRenderTarget(pCmdList, D3D12_RESOURCE_STATE_COPY_SOURCE); + + D3D12_TEXTURE_COPY_LOCATION SrcLocation = {}; + + SrcLocation.Type = D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX; + SrcLocation.pResource = m_pd3d12RenderTaget; + SrcLocation.SubresourceIndex = 0; + + D3D12_TEXTURE_COPY_LOCATION DstLocation = {}; + + DstLocation.Type = D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT; + DstLocation.pResource = m_pd3d12StagingBuffer; + DstLocation.PlacedFootprint = m_StagingBufferFootprint; + + pCmdList->CopyTextureRegion(&DstLocation, 0, 0, 0, &SrcLocation, nullptr); + + pCmdList->Close(); + ID3D12CommandList* pCmdLits[] = {pCmdList}; + + RefCntAutoPtr pContextD3D12{pContext, IID_DeviceContextD3D12}; + + auto* pQeueD3D12 = pContextD3D12->LockCommandQueue(); + auto* pd3d12Queue = pQeueD3D12->GetD3D12CommandQueue(); + + pd3d12Queue->ExecuteCommandLists(1, pCmdLits); + pEnv->IdleCommandQueue(pd3d12Queue); + + D3D12_RANGE InvalidateRange = {0, m_StagingBufferSize}; + void* pStagingDataPtr = nullptr; + m_pd3d12StagingBuffer->Map(0, &InvalidateRange, &pStagingDataPtr); + m_ReferenceDataPitch = m_SwapChainDesc.Width * 4; + m_ReferenceData.resize(m_SwapChainDesc.Height * m_ReferenceDataPitch); + for (Uint32 row = 0; row < m_SwapChainDesc.Height; ++row) + { + memcpy(&m_ReferenceData[row * m_ReferenceDataPitch], + reinterpret_cast(pStagingDataPtr) + m_StagingBufferFootprint.Footprint.RowPitch * row, + m_ReferenceDataPitch); + } + m_pd3d12StagingBuffer->Unmap(0, nullptr); + + pContextD3D12->UnlockCommandQueue(); +} + +void CreateTestingSwapChainD3D12(IRenderDevice* pDevice, + IDeviceContext* pContext, + const SwapChainDesc& SCDesc, + ISwapChain** ppSwapChain) +{ + TestingSwapChainD3D12* pTestingSC(MakeNewRCObj()(pDevice, pContext, SCDesc)); + pTestingSC->QueryInterface(IID_SwapChain, reinterpret_cast(ppSwapChain)); +} + +} // namespace Testing + +} // namespace Diligent diff --git a/Tests/DiligentCoreAPITest/src/DepthStencilStateTest.cpp b/Tests/DiligentCoreAPITest/src/DepthStencilStateTest.cpp new file mode 100644 index 00000000..421c9872 --- /dev/null +++ b/Tests/DiligentCoreAPITest/src/DepthStencilStateTest.cpp @@ -0,0 +1,111 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "TestingEnvironment.h" +#include "PSOTestBase.h" +#include "GraphicsAccessories.h" + +#include "gtest/gtest.h" + +using namespace Diligent; +using namespace Diligent::Testing; + +namespace +{ + +class DepthStencilStateTest : public PSOTestBase, public ::testing::Test +{ +protected: + static void SetUpTestSuite() + { + InitResources(); + } + + static void TearDownTestSuite() + { + ReleaseResources(); + TestingEnvironment::GetInstance()->ReleaseResources(); + } +}; + +TEST_F(DepthStencilStateTest, CreatePSO) +{ + auto PSODesc = GetPSODesc(); + + DepthStencilStateDesc& DSSDesc = PSODesc.GraphicsPipeline.DepthStencilDesc; + + DSSDesc.DepthEnable = False; + DSSDesc.DepthWriteEnable = False; + ASSERT_TRUE(CreateTestPSO(PSODesc, true)); + + DSSDesc.DepthEnable = True; + ASSERT_TRUE(CreateTestPSO(PSODesc, true)); + + DSSDesc.DepthWriteEnable = True; + ASSERT_TRUE(CreateTestPSO(PSODesc, true)); + + for (auto CmpFunc = COMPARISON_FUNC_UNKNOWN + 1; CmpFunc < COMPARISON_FUNC_NUM_FUNCTIONS; ++CmpFunc) + { + DSSDesc.DepthFunc = static_cast(CmpFunc); + ASSERT_TRUE(CreateTestPSO(PSODesc, true)) << "Comparison func: " << GetComparisonFunctionLiteralName(DSSDesc.DepthFunc, true); + } + + DSSDesc.StencilEnable = True; + ASSERT_TRUE(CreateTestPSO(PSODesc, true)); + + DSSDesc.StencilReadMask = 0xA9; + ASSERT_TRUE(CreateTestPSO(PSODesc, true)); + + DSSDesc.StencilWriteMask = 0xB8; + ASSERT_TRUE(CreateTestPSO(PSODesc, true)); + + for (int Face = 0; Face < 2; ++Face) + { + auto& FaceOp = Face == 0 ? DSSDesc.FrontFace : DSSDesc.BackFace; + for (auto StOp = STENCIL_OP_UNDEFINED + 1; StOp < STENCIL_OP_NUM_OPS; ++StOp) + { + FaceOp.StencilFailOp = static_cast(StOp); + ASSERT_TRUE(CreateTestPSO(PSODesc, true)) << "Face: " << Face << "; Stencil fail op: " << GetStencilOpLiteralName(FaceOp.StencilFailOp); + } + + for (auto StOp = STENCIL_OP_UNDEFINED + 1; StOp < STENCIL_OP_NUM_OPS; ++StOp) + { + FaceOp.StencilDepthFailOp = static_cast(StOp); + ASSERT_TRUE(CreateTestPSO(PSODesc, true)) << "Face: " << Face << "; Stencil depth fail op: " << GetStencilOpLiteralName(FaceOp.StencilDepthFailOp); + } + + for (auto StOp = STENCIL_OP_UNDEFINED + 1; StOp < STENCIL_OP_NUM_OPS; ++StOp) + { + FaceOp.StencilPassOp = static_cast(StOp); + ASSERT_TRUE(CreateTestPSO(PSODesc, true)) << "Face: " << Face << "; Stencil pass op: " << GetStencilOpLiteralName(FaceOp.StencilPassOp); + } + + for (auto CmpFunc = COMPARISON_FUNC_UNKNOWN + 1; CmpFunc < COMPARISON_FUNC_NUM_FUNCTIONS; ++CmpFunc) + { + FaceOp.StencilFunc = static_cast(CmpFunc); + ASSERT_TRUE(CreateTestPSO(PSODesc, true)) << "Face: " << Face << "; Comparison func: " << GetComparisonFunctionLiteralName(FaceOp.StencilFunc, true); + } + } +} + +} // namespace diff --git a/Tests/DiligentCoreAPITest/src/DrawCommandTest.cpp b/Tests/DiligentCoreAPITest/src/DrawCommandTest.cpp new file mode 100644 index 00000000..4efce119 --- /dev/null +++ b/Tests/DiligentCoreAPITest/src/DrawCommandTest.cpp @@ -0,0 +1,1492 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "TestingEnvironment.h" +#include "TestingSwapChainBase.h" +#include "BasicMath.h" + +#include "gtest/gtest.h" + +namespace Diligent +{ + +namespace Testing +{ + +#if D3D11_SUPPORTED +void RenderDrawCommandReferenceD3D11(ISwapChain* pSwapChain); +#endif + +#if D3D12_SUPPORTED +void RenderDrawCommandReferenceD3D12(ISwapChain* pSwapChain); +#endif + +#if GL_SUPPORTED || GLES_SUPPORTED +void RenderDrawCommandReferenceGL(ISwapChain* pSwapChain); +#endif + +#if VULKAN_SUPPORTED +void RenderDrawCommandReferenceVk(ISwapChain* pSwapChain); +#endif + +#if METAL_SUPPORTED + +#endif + +} // namespace Testing + +} // namespace Diligent + +using namespace Diligent; +using namespace Diligent::Testing; + +namespace +{ + +const char* ProceduralVSSource = R"( +struct PSInput +{ + float4 Pos : SV_POSITION; + float3 Color : COLOR; +}; + +void main(in uint VertId : SV_VertexID, + out PSInput PSIn) +{ + float4 Pos[6]; + Pos[0] = float4(-1.0, -0.5, 0.0, 1.0); + Pos[1] = float4(-0.5, +0.5, 0.0, 1.0); + Pos[2] = float4( 0.0, -0.5, 0.0, 1.0); + + Pos[3] = float4(+0.0, -0.5, 0.0, 1.0); + Pos[4] = float4(+0.5, +0.5, 0.0, 1.0); + Pos[5] = float4(+1.0, -0.5, 0.0, 1.0); + + float3 Col[6]; + Col[0] = float3(1.0, 0.0, 0.0); + Col[1] = float3(0.0, 1.0, 0.0); + Col[2] = float3(0.0, 0.0, 1.0); + + Col[3] = float3(1.0, 0.0, 0.0); + Col[4] = float3(0.0, 1.0, 0.0); + Col[5] = float3(0.0, 0.0, 1.0); + + PSIn.Pos = Pos[VertId]; + PSIn.Color = Col[VertId]; +} +)"; + +const char* VSSource = R"( +struct PSInput +{ + float4 Pos : SV_POSITION; + float3 Color : COLOR; +}; + +struct VSInput +{ + float4 Pos : ATTRIB0; + float3 Color : ATTRIB1; +}; + +void main(in VSInput VSIn, + out PSInput PSIn) +{ + PSIn.Pos = VSIn.Pos; + PSIn.Color = VSIn.Color; +} +)"; + +const char* PSSource = R"( +struct PSInput +{ + float4 Pos : SV_POSITION; + float3 Color : COLOR; +}; + +struct PSOutput +{ + float4 Color : SV_TARGET; +}; + +void main(in PSInput PSIn, + out PSOutput PSOut) +{ + PSOut.Color = float4(PSIn.Color.rgb, 1.0); +} +)"; + +const char* VSInstancedSource = R"( +struct PSInput +{ + float4 Pos : SV_POSITION; + float3 Color : COLOR; +}; + +struct VSInput +{ + float4 Pos : ATTRIB0; + float3 Color : ATTRIB1; + float4 ScaleBias : ATTRIB2; +}; + +void main(in VSInput VSIn, + out PSInput PSIn) +{ + PSIn.Pos.xy = VSIn.Pos.xy * VSIn.ScaleBias.xy + VSIn.ScaleBias.zw; + PSIn.Pos.zw = VSIn.Pos.zw; + PSIn.Color = VSIn.Color; +} +)"; + + +struct Vertex +{ + float4 Pos; + float3 Color; +}; + +// clang-format off +float4 Pos[] = +{ + float4(-1.0f, -0.5f, 0.f, 1.f), + float4(-0.5f, +0.5f, 0.f, 1.f), + float4( 0.0f, -0.5f, 0.f, 1.f), + + float4(+0.0f, -0.5f, 0.f, 1.f), + float4(+0.5f, +0.5f, 0.f, 1.f), + float4(+1.0f, -0.5f, 0.f, 1.f) +}; + +float3 Color[] = +{ + float3(1.f, 0.f, 0.f), + float3(0.f, 1.f, 0.f), + float3(0.f, 0.f, 1.f), +}; + +Vertex Vert[] = +{ + {Pos[0], Color[0]}, + {Pos[1], Color[1]}, + {Pos[2], Color[2]}, + + {Pos[3], Color[0]}, + {Pos[4], Color[1]}, + {Pos[5], Color[2]} +}; + +Vertex VertInst[] = +{ + {float4(-1.0, 0.0, 0.0, 1.0), Color[0]}, + {float4( 0.0, +2.0, 0.0, 1.0), Color[1]}, + {float4(+1.0, 0.0, 0.0, 1.0), Color[2]} +}; +// clang-format on + +class DrawCommandTest : public ::testing::Test +{ +protected: + static void SetUpTestSuite() + { + auto* pEnv = TestingEnvironment::GetInstance(); + auto* pDevice = pEnv->GetDevice(); + auto* pSwapChain = pEnv->GetSwapChain(); + auto* pConext = pEnv->GetDeviceContext(); + + RefCntAutoPtr pTestingSwapChain(pSwapChain, IID_TestingSwapChain); + if (pTestingSwapChain) + { + pConext->Flush(); + pConext->InvalidateState(); + + auto deviceType = pDevice->GetDeviceCaps().DevType; + switch (deviceType) + { +#if D3D11_SUPPORTED + case DeviceType::D3D11: + RenderDrawCommandReferenceD3D11(pSwapChain); + break; +#endif + +#if D3D12_SUPPORTED + case DeviceType::D3D12: + RenderDrawCommandReferenceD3D12(pSwapChain); + break; +#endif + +#if GL_SUPPORTED || GLES_SUPPORTED + case DeviceType::OpenGL: + case DeviceType::OpenGLES: + RenderDrawCommandReferenceGL(pSwapChain); + break; + +#endif + +#if VULKAN_SUPPORTED + case DeviceType::Vulkan: + RenderDrawCommandReferenceVk(pSwapChain); + break; + +#endif + + default: + LOG_ERROR_AND_THROW("Unsupported device type"); + } + + pTestingSwapChain->TakeSnapshot(); + } + TestingEnvironment::ScopedReleaseResources EnvironmentAutoReset; + + PipelineStateDesc PSODesc; + PSODesc.Name = "Procedural triangle PSO"; + + PSODesc.IsComputePipeline = false; + PSODesc.GraphicsPipeline.NumRenderTargets = 1; + PSODesc.GraphicsPipeline.RTVFormats[0] = pSwapChain->GetDesc().ColorBufferFormat; + PSODesc.GraphicsPipeline.PrimitiveTopology = PRIMITIVE_TOPOLOGY_TRIANGLE_LIST; + PSODesc.GraphicsPipeline.RasterizerDesc.CullMode = CULL_MODE_NONE; + PSODesc.GraphicsPipeline.DepthStencilDesc.DepthEnable = False; + + ShaderCreateInfo ShaderCI; + ShaderCI.SourceLanguage = SHADER_SOURCE_LANGUAGE_HLSL; + ShaderCI.UseCombinedTextureSamplers = true; + + RefCntAutoPtr pProceduralVS; + { + ShaderCI.Desc.ShaderType = SHADER_TYPE_VERTEX; + ShaderCI.EntryPoint = "main"; + ShaderCI.Desc.Name = "Draw command test procedural vertex shader"; + ShaderCI.Source = ProceduralVSSource; + pDevice->CreateShader(ShaderCI, &pProceduralVS); + ASSERT_NE(pProceduralVS, nullptr); + } + + RefCntAutoPtr pVS; + { + ShaderCI.Desc.ShaderType = SHADER_TYPE_VERTEX; + ShaderCI.EntryPoint = "main"; + ShaderCI.Desc.Name = "Draw command test vertex shader"; + ShaderCI.Source = VSSource; + pDevice->CreateShader(ShaderCI, &pVS); + ASSERT_NE(pVS, nullptr); + } + + RefCntAutoPtr pInstancedVS; + { + ShaderCI.Desc.ShaderType = SHADER_TYPE_VERTEX; + ShaderCI.EntryPoint = "main"; + ShaderCI.Desc.Name = "Draw command test instanced vertex shader"; + ShaderCI.Source = VSInstancedSource; + pDevice->CreateShader(ShaderCI, &pInstancedVS); + ASSERT_NE(pInstancedVS, nullptr); + } + + RefCntAutoPtr pPS; + { + ShaderCI.Desc.ShaderType = SHADER_TYPE_PIXEL; + ShaderCI.EntryPoint = "main"; + ShaderCI.Desc.Name = "Draw command test pixel shader"; + ShaderCI.Source = PSSource; + pDevice->CreateShader(ShaderCI, &pPS); + ASSERT_NE(pPS, nullptr); + } + + PSODesc.GraphicsPipeline.pVS = pProceduralVS; + PSODesc.GraphicsPipeline.pPS = pPS; + pDevice->CreatePipelineState(PSODesc, &sm_pDrawProceduralPSO); + ASSERT_NE(sm_pDrawProceduralPSO, nullptr); + + InputLayoutDesc LayoutDesc; + // clang-format off + LayoutElement Elems[] = + { + LayoutElement{ 0, 0, 4, VT_FLOAT32}, + LayoutElement{ 1, 0, 3, VT_FLOAT32} + }; + // clang-format on + PSODesc.GraphicsPipeline.InputLayout.LayoutElements = Elems; + PSODesc.GraphicsPipeline.InputLayout.NumElements = _countof(Elems); + PSODesc.GraphicsPipeline.pVS = pVS; + PSODesc.GraphicsPipeline.pPS = pPS; + PSODesc.GraphicsPipeline.PrimitiveTopology = PRIMITIVE_TOPOLOGY_TRIANGLE_LIST; + pDevice->CreatePipelineState(PSODesc, &sm_pDrawPSO); + + Elems[0].Stride = sizeof(Vertex) * 2; + pDevice->CreatePipelineState(PSODesc, &sm_pDraw_2xStride_PSO); + + // clang-format off + LayoutElement InstancedElems[] = + { + LayoutElement{ 0, 0, 4, VT_FLOAT32}, + LayoutElement{ 1, 0, 3, VT_FLOAT32}, + LayoutElement{ 2, 1, 4, VT_FLOAT32, false, LayoutElement::FREQUENCY_PER_INSTANCE} + }; + // clang-format on + PSODesc.GraphicsPipeline.InputLayout.LayoutElements = InstancedElems; + PSODesc.GraphicsPipeline.InputLayout.NumElements = _countof(InstancedElems); + PSODesc.GraphicsPipeline.pVS = pInstancedVS; + pDevice->CreatePipelineState(PSODesc, &sm_pDrawInstancedPSO); + } + + static void TearDownTestSuite() + { + sm_pDrawProceduralPSO.Release(); + + auto* pEnv = TestingEnvironment::GetInstance(); + pEnv->Reset(); + } + + static void SetRenderTargets(IPipelineState* pPSO) + { + auto* pEnv = TestingEnvironment::GetInstance(); + auto* pContext = pEnv->GetDeviceContext(); + auto* pSwapChain = pEnv->GetSwapChain(); + + ITextureView* pRTVs[] = {pSwapChain->GetCurrentBackBufferRTV()}; + pContext->SetRenderTargets(1, pRTVs, nullptr, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); + + const float ClearColor[] = {0.f, 0.f, 0.f, 0.0f}; + pContext->ClearRenderTarget(pRTVs[0], ClearColor, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); + + pContext->SetPipelineState(pPSO); + // Commit shader resources. We don't really have any resources, but this call also sets the shaders in OpenGL backend. + pContext->CommitShaderResources(nullptr, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); + } + + static void Present() + { + auto* pEnv = TestingEnvironment::GetInstance(); + auto* pSwapChain = pEnv->GetSwapChain(); + auto* pContext = pEnv->GetDeviceContext(); + + pSwapChain->Present(); + + pContext->Flush(); + pContext->InvalidateState(); + } + + RefCntAutoPtr CreateVertexBuffer(const void* VertexData, Uint32 DataSize) + { + BufferDesc BuffDesc; + BuffDesc.Name = "Test vertex buffer"; + BuffDesc.BindFlags = BIND_VERTEX_BUFFER; + BuffDesc.uiSizeInBytes = DataSize; + + BufferData InitialData; + InitialData.pData = VertexData; + InitialData.DataSize = DataSize; + + auto* pDevice = TestingEnvironment::GetInstance()->GetDevice(); + + RefCntAutoPtr pBuffer; + pDevice->CreateBuffer(BuffDesc, &InitialData, &pBuffer); + VERIFY_EXPR(pBuffer); + return pBuffer; + } + + RefCntAutoPtr CreateIndexBuffer(const Uint32* Indices, Uint32 NumIndices) + { + BufferDesc BuffDesc; + BuffDesc.Name = "Test index buffer"; + BuffDesc.BindFlags = BIND_INDEX_BUFFER; + BuffDesc.uiSizeInBytes = sizeof(Uint32) * NumIndices; + + BufferData InitialData; + InitialData.pData = Indices; + InitialData.DataSize = BuffDesc.uiSizeInBytes; + + auto* pDevice = TestingEnvironment::GetInstance()->GetDevice(); + + RefCntAutoPtr pBuffer; + pDevice->CreateBuffer(BuffDesc, &InitialData, &pBuffer); + VERIFY_EXPR(pBuffer); + return pBuffer; + } + + RefCntAutoPtr CreateIndirectDrawArgsBuffer(const Uint32* Data, Uint32 DataSize) + { + BufferDesc BuffDesc; + BuffDesc.Name = "Test index buffer"; + BuffDesc.BindFlags = BIND_INDIRECT_DRAW_ARGS; + BuffDesc.uiSizeInBytes = DataSize; + + BufferData InitialData; + InitialData.pData = Data; + InitialData.DataSize = BuffDesc.uiSizeInBytes; + + auto* pDevice = TestingEnvironment::GetInstance()->GetDevice(); + + RefCntAutoPtr pBuffer; + pDevice->CreateBuffer(BuffDesc, &InitialData, &pBuffer); + VERIFY_EXPR(pBuffer); + return pBuffer; + } + + static RefCntAutoPtr sm_pDrawProceduralPSO; + static RefCntAutoPtr sm_pDrawPSO; + static RefCntAutoPtr sm_pDraw_2xStride_PSO; + static RefCntAutoPtr sm_pDrawInstancedPSO; +}; + +RefCntAutoPtr DrawCommandTest::sm_pDrawProceduralPSO; +RefCntAutoPtr DrawCommandTest::sm_pDrawPSO; +RefCntAutoPtr DrawCommandTest::sm_pDraw_2xStride_PSO; +RefCntAutoPtr DrawCommandTest::sm_pDrawInstancedPSO; + +TEST_F(DrawCommandTest, DrawProcedural) +{ + auto* pEnv = TestingEnvironment::GetInstance(); + auto* pContext = pEnv->GetDeviceContext(); + + SetRenderTargets(sm_pDrawProceduralPSO); + + DrawAttribs drawAttrs{6, DRAW_FLAG_VERIFY_ALL}; + pContext->Draw(drawAttrs); + + Present(); +} + + +// Non-indexed draw calls + + +TEST_F(DrawCommandTest, Draw) +{ + auto* pEnv = TestingEnvironment::GetInstance(); + auto* pContext = pEnv->GetDeviceContext(); + + SetRenderTargets(sm_pDrawPSO); + + // clang-format off + const Vertex Triangles[] = + { + Vert[0], Vert[1], Vert[2], + Vert[3], Vert[4], Vert[5] + }; + // clang-format on + + auto pVB = CreateVertexBuffer(Triangles, sizeof(Triangles)); + IBuffer* pVBs[] = {pVB}; + Uint32 Offsets[] = {0}; + pContext->SetVertexBuffers(0, 1, pVBs, Offsets, RESOURCE_STATE_TRANSITION_MODE_TRANSITION, SET_VERTEX_BUFFERS_FLAG_RESET); + + DrawAttribs drawAttrs{6, DRAW_FLAG_VERIFY_ALL}; + pContext->Draw(drawAttrs); + + Present(); +} + +TEST_F(DrawCommandTest, Draw_StartVertex) +{ + auto* pEnv = TestingEnvironment::GetInstance(); + auto* pContext = pEnv->GetDeviceContext(); + + SetRenderTargets(sm_pDrawPSO); + + // clang-format off + const Vertex Triangles[] = + { + {}, {}, // Skip 2 vertices using StartVertexLocation + Vert[0], Vert[1], Vert[2], + Vert[3], Vert[4], Vert[5] + }; + // clang-format on + + auto pVB = CreateVertexBuffer(Triangles, sizeof(Triangles)); + IBuffer* pVBs[] = {pVB}; + Uint32 Offsets[] = {0}; + pContext->SetVertexBuffers(0, 1, pVBs, Offsets, RESOURCE_STATE_TRANSITION_MODE_TRANSITION, SET_VERTEX_BUFFERS_FLAG_RESET); + + DrawAttribs drawAttrs{6, DRAW_FLAG_VERIFY_ALL}; + drawAttrs.StartVertexLocation = 2; + pContext->Draw(drawAttrs); + + Present(); +} + +TEST_F(DrawCommandTest, Draw_VBOffset) +{ + auto* pEnv = TestingEnvironment::GetInstance(); + auto* pContext = pEnv->GetDeviceContext(); + + SetRenderTargets(sm_pDrawPSO); + + // clang-format off + const Vertex Triangles[] = + { + {}, {}, {}, // Skip 3 vertices using buffer offset + Vert[0], Vert[1], Vert[2], + Vert[3], Vert[4], Vert[5] + }; + // clang-format on + + auto pVB = CreateVertexBuffer(Triangles, sizeof(Triangles)); + IBuffer* pVBs[] = {pVB}; + Uint32 Offsets[] = {3 * sizeof(Vertex)}; + pContext->SetVertexBuffers(0, 1, pVBs, Offsets, RESOURCE_STATE_TRANSITION_MODE_TRANSITION, SET_VERTEX_BUFFERS_FLAG_RESET); + + DrawAttribs drawAttrs{6, DRAW_FLAG_VERIFY_ALL}; + pContext->Draw(drawAttrs); + + Present(); +} + +TEST_F(DrawCommandTest, Draw_StartVertex_VBOffset) +{ + auto* pEnv = TestingEnvironment::GetInstance(); + auto* pContext = pEnv->GetDeviceContext(); + + SetRenderTargets(sm_pDrawPSO); + + // clang-format off + const Vertex Triangles[] = + { + {}, {}, {}, // Skip 3 vertices using buffer offset + {}, {}, // Skip 2 vertices using StartVertexLocation + Vert[0], Vert[1], Vert[2], + Vert[3], Vert[4], Vert[5] + }; + // clang-format on + + auto pVB = CreateVertexBuffer(Triangles, sizeof(Triangles)); + IBuffer* pVBs[] = {pVB}; + Uint32 Offsets[] = {3 * sizeof(Vertex)}; + pContext->SetVertexBuffers(0, 1, pVBs, Offsets, RESOURCE_STATE_TRANSITION_MODE_TRANSITION, SET_VERTEX_BUFFERS_FLAG_RESET); + + DrawAttribs drawAttrs{6, DRAW_FLAG_VERIFY_ALL}; + drawAttrs.StartVertexLocation = 2; + pContext->Draw(drawAttrs); + + Present(); +} + +TEST_F(DrawCommandTest, Draw_StartVertex_VBOffset_2xStride) +{ + auto* pEnv = TestingEnvironment::GetInstance(); + auto* pContext = pEnv->GetDeviceContext(); + + SetRenderTargets(sm_pDraw_2xStride_PSO); + + // clang-format off + const Vertex Triangles[] = + { + {}, {}, {}, // Skip 3 * sizeof(Vertex) using buffer offset + {}, {}, {}, {}, // Skip 2 vertices using StartVertexLocation + Vert[0], {}, Vert[1], {}, Vert[2], {}, + Vert[3], {}, Vert[4], {}, Vert[5], {} + }; + // clang-format on + + auto pVB = CreateVertexBuffer(Triangles, sizeof(Triangles)); + IBuffer* pVBs[] = {pVB}; + Uint32 Offsets[] = {3 * sizeof(Vertex)}; + pContext->SetVertexBuffers(0, 1, pVBs, Offsets, RESOURCE_STATE_TRANSITION_MODE_TRANSITION, SET_VERTEX_BUFFERS_FLAG_RESET); + + DrawAttribs drawAttrs{6, DRAW_FLAG_VERIFY_ALL}; + drawAttrs.StartVertexLocation = 2; + pContext->Draw(drawAttrs); + + Present(); +} + + + +// Indexed draw calls (glDrawElements/DrawIndexed) + +TEST_F(DrawCommandTest, DrawIndexed) +{ + auto* pEnv = TestingEnvironment::GetInstance(); + auto* pContext = pEnv->GetDeviceContext(); + + SetRenderTargets(sm_pDrawPSO); + + // clang-format off + const Vertex Triangles[] = + { + {}, {}, + Vert[0], {}, Vert[1], {}, {}, Vert[2], + Vert[3], {}, {}, Vert[5], Vert[4] + }; + Uint32 Indices[] = {2,4,7, 8,12,11}; + // clang-format on + + auto pVB = CreateVertexBuffer(Triangles, sizeof(Triangles)); + auto pIB = CreateIndexBuffer(Indices, _countof(Indices)); + + IBuffer* pVBs[] = {pVB}; + Uint32 Offsets[] = {0}; + pContext->SetVertexBuffers(0, 1, pVBs, Offsets, RESOURCE_STATE_TRANSITION_MODE_TRANSITION, SET_VERTEX_BUFFERS_FLAG_RESET); + pContext->SetIndexBuffer(pIB, 0, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); + + DrawIndexedAttribs drawAttrs{6, VT_UINT32, DRAW_FLAG_VERIFY_ALL}; + pContext->DrawIndexed(drawAttrs); + + Present(); +} + +TEST_F(DrawCommandTest, DrawIndexed_IBOffset) +{ + auto* pEnv = TestingEnvironment::GetInstance(); + auto* pContext = pEnv->GetDeviceContext(); + + SetRenderTargets(sm_pDrawPSO); + + // clang-format off + const Vertex Triangles[] = + { + {}, {}, + Vert[0], {}, Vert[1], {}, {}, Vert[2], + Vert[3], {}, {}, Vert[5], Vert[4] + }; + Uint32 Indices[] = {0,0,0,0, 2,4,7, 8,12,11}; // Skip 4 indices using index buffer offset + // clang-format on + + auto pVB = CreateVertexBuffer(Triangles, sizeof(Triangles)); + auto pIB = CreateIndexBuffer(Indices, _countof(Indices)); + + IBuffer* pVBs[] = {pVB}; + Uint32 Offsets[] = {0}; + pContext->SetVertexBuffers(0, 1, pVBs, Offsets, RESOURCE_STATE_TRANSITION_MODE_TRANSITION, SET_VERTEX_BUFFERS_FLAG_RESET); + pContext->SetIndexBuffer(pIB, sizeof(Uint32) * 4, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); + + DrawIndexedAttribs drawAttrs{6, VT_UINT32, DRAW_FLAG_VERIFY_ALL}; + pContext->DrawIndexed(drawAttrs); + + Present(); +} + +TEST_F(DrawCommandTest, DrawIndexed_IBOffset_BaseVertex) +{ + auto* pEnv = TestingEnvironment::GetInstance(); + auto* pContext = pEnv->GetDeviceContext(); + + SetRenderTargets(sm_pDrawPSO); + + Uint32 bv = 2; // Base vertex + // clang-format off + const Vertex Triangles[] = + { + {}, {}, + Vert[0], {}, Vert[1], {}, {}, Vert[2], + Vert[3], {}, {}, Vert[5], Vert[4] + }; + Uint32 Indices[] = {0,0,0,0, 2-bv,4-bv,7-bv, 8-bv,12-bv,11-bv}; + // clang-format on + + auto pVB = CreateVertexBuffer(Triangles, sizeof(Triangles)); + auto pIB = CreateIndexBuffer(Indices, _countof(Indices)); + + IBuffer* pVBs[] = {pVB}; + Uint32 Offsets[] = {0}; + pContext->SetVertexBuffers(0, 1, pVBs, Offsets, RESOURCE_STATE_TRANSITION_MODE_TRANSITION, SET_VERTEX_BUFFERS_FLAG_RESET); + pContext->SetIndexBuffer(pIB, sizeof(Uint32) * 4, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); + + DrawIndexedAttribs drawAttrs{6, VT_UINT32, DRAW_FLAG_VERIFY_ALL}; + drawAttrs.BaseVertex = bv; + pContext->DrawIndexed(drawAttrs); + + Present(); +} + + +// Instanced non-indexed draw calls (glDrawArraysInstanced/DrawInstanced) + +TEST_F(DrawCommandTest, DrawInstanced) +{ + auto* pEnv = TestingEnvironment::GetInstance(); + auto* pContext = pEnv->GetDeviceContext(); + + SetRenderTargets(sm_pDrawInstancedPSO); + + // clang-format off + const Vertex Triangles[] = + { + VertInst[0], VertInst[1], VertInst[2] + }; + const float4 InstancedData[] = + { + float4{0.5f, 0.5f, -0.5f, -0.5f}, + float4{0.5f, 0.5f, +0.5f, -0.5f} + }; + // clang-format on + + auto pVB = CreateVertexBuffer(Triangles, sizeof(Triangles)); + auto pInstVB = CreateVertexBuffer(InstancedData, sizeof(InstancedData)); + + IBuffer* pVBs[] = {pVB, pInstVB}; + Uint32 Offsets[] = {0, 0}; + pContext->SetVertexBuffers(0, _countof(pVBs), pVBs, Offsets, RESOURCE_STATE_TRANSITION_MODE_TRANSITION, SET_VERTEX_BUFFERS_FLAG_RESET); + + DrawAttribs drawAttrs{3, DRAW_FLAG_VERIFY_ALL}; + drawAttrs.NumInstances = 2; // Draw two instances of the same triangle + pContext->Draw(drawAttrs); + + Present(); +} + +TEST_F(DrawCommandTest, DrawInstanced_VBOffset) +{ + auto* pEnv = TestingEnvironment::GetInstance(); + auto* pContext = pEnv->GetDeviceContext(); + + SetRenderTargets(sm_pDrawInstancedPSO); + + // clang-format off + const Vertex Triangles[] = + { + {}, {}, // Skip 2 vertices with VB offset + VertInst[0], VertInst[1], VertInst[2] + }; + const float4 InstancedData[] = + { + {}, {}, {}, // Skip 3 instances with VB offset + float4{0.5f, 0.5f, -0.5f, -0.5f}, + float4{0.5f, 0.5f, +0.5f, -0.5f} + }; + // clang-format on + + auto pVB = CreateVertexBuffer(Triangles, sizeof(Triangles)); + auto pInstVB = CreateVertexBuffer(InstancedData, sizeof(InstancedData)); + + IBuffer* pVBs[] = {pVB, pInstVB}; + Uint32 Offsets[] = {2 * sizeof(Vertex), 3 * sizeof(float4)}; + pContext->SetVertexBuffers(0, _countof(pVBs), pVBs, Offsets, RESOURCE_STATE_TRANSITION_MODE_TRANSITION, SET_VERTEX_BUFFERS_FLAG_RESET); + + DrawAttribs drawAttrs{3, DRAW_FLAG_VERIFY_ALL}; + drawAttrs.NumInstances = 2; // Draw two instances of the same triangle + pContext->Draw(drawAttrs); + + Present(); +} + +TEST_F(DrawCommandTest, DrawInstanced_StartVertex) +{ + auto* pEnv = TestingEnvironment::GetInstance(); + auto* pContext = pEnv->GetDeviceContext(); + + SetRenderTargets(sm_pDrawInstancedPSO); + + // clang-format off + const Vertex Triangles[] = + { + {}, {}, {}, {}, // Skip 4 vertices with start vertex + VertInst[0], VertInst[1], VertInst[2] + }; + const float4 InstancedData[] = + { + float4{0.5f, 0.5f, -0.5f, -0.5f}, + float4{0.5f, 0.5f, +0.5f, -0.5f} + }; + // clang-format on + + auto pVB = CreateVertexBuffer(Triangles, sizeof(Triangles)); + auto pInstVB = CreateVertexBuffer(InstancedData, sizeof(InstancedData)); + + IBuffer* pVBs[] = {pVB, pInstVB}; + Uint32 Offsets[] = {0, 0}; + pContext->SetVertexBuffers(0, _countof(pVBs), pVBs, Offsets, RESOURCE_STATE_TRANSITION_MODE_TRANSITION, SET_VERTEX_BUFFERS_FLAG_RESET); + + DrawAttribs drawAttrs{3, DRAW_FLAG_VERIFY_ALL}; + drawAttrs.NumInstances = 2; // Draw two instances of the same triangle + drawAttrs.StartVertexLocation = 4; // Skip 4 vertices + pContext->Draw(drawAttrs); + + Present(); +} + + +// Instanced draw calls with first instance (glDrawArraysInstancedBaseInstance/DrawInstanced) + +TEST_F(DrawCommandTest, DrawInstanced_FirstInstance) +{ + auto* pEnv = TestingEnvironment::GetInstance(); + auto* pContext = pEnv->GetDeviceContext(); + + SetRenderTargets(sm_pDrawInstancedPSO); + + // clang-format off + const Vertex Triangles[] = + { + VertInst[0], VertInst[1], VertInst[2] + }; + const float4 InstancedData[] = + { + {}, {}, {}, {}, // Skip 4 instances with FirstInstanceLocation + float4{0.5f, 0.5f, -0.5f, -0.5f}, + float4{0.5f, 0.5f, +0.5f, -0.5f} + }; + // clang-format on + + auto pVB = CreateVertexBuffer(Triangles, sizeof(Triangles)); + auto pInstVB = CreateVertexBuffer(InstancedData, sizeof(InstancedData)); + + IBuffer* pVBs[] = {pVB, pInstVB}; + Uint32 Offsets[] = {0, 0}; + pContext->SetVertexBuffers(0, _countof(pVBs), pVBs, Offsets, RESOURCE_STATE_TRANSITION_MODE_TRANSITION, SET_VERTEX_BUFFERS_FLAG_RESET); + + DrawAttribs drawAttrs{3, DRAW_FLAG_VERIFY_ALL}; + drawAttrs.NumInstances = 2; + drawAttrs.FirstInstanceLocation = 4; // Skip 4 instances + pContext->Draw(drawAttrs); + + Present(); +} + +TEST_F(DrawCommandTest, DrawInstanced_FirstInstance_VBOffset) +{ + auto* pEnv = TestingEnvironment::GetInstance(); + auto* pContext = pEnv->GetDeviceContext(); + + SetRenderTargets(sm_pDrawInstancedPSO); + + // clang-format off + const Vertex Triangles[] = + { + {}, {}, {}, // Skip 3 vertices with buffer offset + VertInst[0], VertInst[1], VertInst[2] + }; + const float4 InstancedData[] = + { + {}, {}, // Skip 2 instances with buffer offset + {}, {}, {}, {}, // Skip 4 instances with FirstInstanceLocation + float4{0.5f, 0.5f, -0.5f, -0.5f}, + float4{0.5f, 0.5f, +0.5f, -0.5f} + }; + // clang-format on + + auto pVB = CreateVertexBuffer(Triangles, sizeof(Triangles)); + auto pInstVB = CreateVertexBuffer(InstancedData, sizeof(InstancedData)); + + IBuffer* pVBs[] = {pVB, pInstVB}; + Uint32 Offsets[] = {3 * sizeof(Vertex), 2 * sizeof(float4)}; + pContext->SetVertexBuffers(0, _countof(pVBs), pVBs, Offsets, RESOURCE_STATE_TRANSITION_MODE_TRANSITION, SET_VERTEX_BUFFERS_FLAG_RESET); + + DrawAttribs drawAttrs{3, DRAW_FLAG_VERIFY_ALL}; + drawAttrs.NumInstances = 2; + drawAttrs.FirstInstanceLocation = 4; // Skip 4 instances + pContext->Draw(drawAttrs); + + Present(); +} + + +TEST_F(DrawCommandTest, DrawInstanced_FirstInstance_BaseVertex_FirstIndex_VBOffset_IBOffset) +{ + auto* pEnv = TestingEnvironment::GetInstance(); + auto* pContext = pEnv->GetDeviceContext(); + + SetRenderTargets(sm_pDrawInstancedPSO); + + // clang-format off + const Vertex Triangles[] = + { + {}, {}, {}, {}, // Skip 4 vertices with VB offset + {}, {}, {}, // Skip 3 vertices with StartVertexLocation + VertInst[0], VertInst[1], VertInst[2] + }; + const float4 InstancedData[] = + { + {}, {}, {}, {}, {}, // Skip 5 instances with VB offset + {}, {}, {}, {}, // Skip 4 instances with FirstInstance + float4{0.5f, 0.5f, -0.5f, -0.5f}, + float4{0.5f, 0.5f, +0.5f, -0.5f} + }; + // clang-format on + + auto pVB = CreateVertexBuffer(Triangles, sizeof(Triangles)); + auto pInstVB = CreateVertexBuffer(InstancedData, sizeof(InstancedData)); + + IBuffer* pVBs[] = {pVB, pInstVB}; + Uint32 Offsets[] = {4 * sizeof(Vertex), 5 * sizeof(float4)}; + pContext->SetVertexBuffers(0, _countof(pVBs), pVBs, Offsets, RESOURCE_STATE_TRANSITION_MODE_TRANSITION, SET_VERTEX_BUFFERS_FLAG_RESET); + + DrawAttribs drawAttrs{6, DRAW_FLAG_VERIFY_ALL}; + drawAttrs.NumInstances = 2; + drawAttrs.FirstInstanceLocation = 4; + drawAttrs.StartVertexLocation = 3; + pContext->Draw(drawAttrs); + + Present(); +} + +// Instanced indexed draw calls (glDrawElementsInstanced/DrawIndexedInstanced) + +TEST_F(DrawCommandTest, DrawIndexedInstanced) +{ + auto* pEnv = TestingEnvironment::GetInstance(); + auto* pContext = pEnv->GetDeviceContext(); + + SetRenderTargets(sm_pDrawInstancedPSO); + + // clang-format off + const Vertex Triangles[] = + { + {}, {}, + VertInst[1], {}, VertInst[0], {}, {}, VertInst[2] + }; + Uint32 Indices[] = {4, 2, 7}; + const float4 InstancedData[] = + { + float4{0.5f, 0.5f, -0.5f, -0.5f}, + float4{0.5f, 0.5f, +0.5f, -0.5f} + }; + // clang-format on + + auto pVB = CreateVertexBuffer(Triangles, sizeof(Triangles)); + auto pInstVB = CreateVertexBuffer(InstancedData, sizeof(InstancedData)); + auto pIB = CreateIndexBuffer(Indices, _countof(Indices)); + + IBuffer* pVBs[] = {pVB, pInstVB}; + Uint32 Offsets[] = {0, 0}; + pContext->SetVertexBuffers(0, _countof(pVBs), pVBs, Offsets, RESOURCE_STATE_TRANSITION_MODE_TRANSITION, SET_VERTEX_BUFFERS_FLAG_RESET); + pContext->SetIndexBuffer(pIB, 0, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); + + DrawIndexedAttribs drawAttrs{3, VT_UINT32, DRAW_FLAG_VERIFY_ALL}; + drawAttrs.NumInstances = 2; + pContext->DrawIndexed(drawAttrs); + + Present(); +} + + +TEST_F(DrawCommandTest, DrawIndexedInstanced_IBOffset) +{ + auto* pEnv = TestingEnvironment::GetInstance(); + auto* pContext = pEnv->GetDeviceContext(); + + SetRenderTargets(sm_pDrawInstancedPSO); + + // clang-format off + const Vertex Triangles[] = + { + {}, {}, + VertInst[1], {}, VertInst[0], {}, {}, VertInst[2] + }; + Uint32 Indices[] = {0,0,0,0,0, 4, 2, 7}; + const float4 InstancedData[] = + { + float4{0.5f, 0.5f, -0.5f, -0.5f}, + float4{0.5f, 0.5f, +0.5f, -0.5f} + }; + // clang-format on + + auto pVB = CreateVertexBuffer(Triangles, sizeof(Triangles)); + auto pInstVB = CreateVertexBuffer(InstancedData, sizeof(InstancedData)); + auto pIB = CreateIndexBuffer(Indices, _countof(Indices)); + + IBuffer* pVBs[] = {pVB, pInstVB}; + Uint32 Offsets[] = {0, 0}; + pContext->SetVertexBuffers(0, _countof(pVBs), pVBs, Offsets, RESOURCE_STATE_TRANSITION_MODE_TRANSITION, SET_VERTEX_BUFFERS_FLAG_RESET); + pContext->SetIndexBuffer(pIB, 5 * sizeof(Uint32), RESOURCE_STATE_TRANSITION_MODE_TRANSITION); + + DrawIndexedAttribs drawAttrs{3, VT_UINT32, DRAW_FLAG_VERIFY_ALL}; + drawAttrs.NumInstances = 2; + pContext->DrawIndexed(drawAttrs); + + Present(); +} + + +TEST_F(DrawCommandTest, DrawIndexedInstanced_VBOffset) +{ + auto* pEnv = TestingEnvironment::GetInstance(); + auto* pContext = pEnv->GetDeviceContext(); + + SetRenderTargets(sm_pDrawInstancedPSO); + + // clang-format off + const Vertex Triangles[] = + { + {}, {}, // Skip 2 vertices with VBOffset + {}, {}, + VertInst[1], {}, VertInst[0], {}, {}, VertInst[2] + }; + Uint32 Indices[] = {4, 2, 7}; + const float4 InstancedData[] = + { + {}, {}, {}, {}, // Skip 4 instances with VB offset + float4{0.5f, 0.5f, -0.5f, -0.5f}, + float4{0.5f, 0.5f, +0.5f, -0.5f} + }; + // clang-format on + + auto pVB = CreateVertexBuffer(Triangles, sizeof(Triangles)); + auto pInstVB = CreateVertexBuffer(InstancedData, sizeof(InstancedData)); + auto pIB = CreateIndexBuffer(Indices, _countof(Indices)); + + IBuffer* pVBs[] = {pVB, pInstVB}; + Uint32 Offsets[] = {2 * sizeof(Vertex), 4 * sizeof(float4)}; + pContext->SetVertexBuffers(0, _countof(pVBs), pVBs, Offsets, RESOURCE_STATE_TRANSITION_MODE_TRANSITION, SET_VERTEX_BUFFERS_FLAG_RESET); + pContext->SetIndexBuffer(pIB, 0, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); + + DrawIndexedAttribs drawAttrs{3, VT_UINT32, DRAW_FLAG_VERIFY_ALL}; + drawAttrs.NumInstances = 2; + pContext->DrawIndexed(drawAttrs); + + Present(); +} + + +TEST_F(DrawCommandTest, DrawIndexedInstanced_FirstIndex) +{ + auto* pEnv = TestingEnvironment::GetInstance(); + auto* pContext = pEnv->GetDeviceContext(); + + SetRenderTargets(sm_pDrawInstancedPSO); + + // clang-format off + const Vertex Triangles[] = + { + {}, {}, + VertInst[1], {}, VertInst[0], {}, {}, VertInst[2] + }; + Uint32 Indices[] = {0,0,0,0,0, 4, 2, 7}; + const float4 InstancedData[] = + { + float4{0.5f, 0.5f, -0.5f, -0.5f}, + float4{0.5f, 0.5f, +0.5f, -0.5f} + }; + // clang-format on + + auto pVB = CreateVertexBuffer(Triangles, sizeof(Triangles)); + auto pInstVB = CreateVertexBuffer(InstancedData, sizeof(InstancedData)); + auto pIB = CreateIndexBuffer(Indices, _countof(Indices)); + + IBuffer* pVBs[] = {pVB, pInstVB}; + Uint32 Offsets[] = {0, 0}; + pContext->SetVertexBuffers(0, _countof(pVBs), pVBs, Offsets, RESOURCE_STATE_TRANSITION_MODE_TRANSITION, SET_VERTEX_BUFFERS_FLAG_RESET); + pContext->SetIndexBuffer(pIB, 0, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); + + DrawIndexedAttribs drawAttrs{3, VT_UINT32, DRAW_FLAG_VERIFY_ALL}; + drawAttrs.NumInstances = 2; + drawAttrs.FirstIndexLocation = 5; + pContext->DrawIndexed(drawAttrs); + + Present(); +} + + +// Instanced indexed draw calls with first instance (glDrawElementsInstancedBaseInstance/DrawInstanced) + + +TEST_F(DrawCommandTest, DrawIndexedInstanced_FirstInstance) +{ + auto* pEnv = TestingEnvironment::GetInstance(); + auto* pContext = pEnv->GetDeviceContext(); + + SetRenderTargets(sm_pDrawInstancedPSO); + + // clang-format off + const Vertex Triangles[] = + { + {}, {}, + VertInst[1], {}, VertInst[0], {}, {}, VertInst[2] + }; + Uint32 Indices[] = {4, 2, 7}; + const float4 InstancedData[] = + { + {}, {}, {}, {}, // Skip 4 instances with FirstInstance + float4{0.5f, 0.5f, -0.5f, -0.5f}, + float4{0.5f, 0.5f, +0.5f, -0.5f} + }; + // clang-format on + + auto pVB = CreateVertexBuffer(Triangles, sizeof(Triangles)); + auto pInstVB = CreateVertexBuffer(InstancedData, sizeof(InstancedData)); + auto pIB = CreateIndexBuffer(Indices, _countof(Indices)); + + IBuffer* pVBs[] = {pVB, pInstVB}; + Uint32 Offsets[] = {0, 0}; + pContext->SetVertexBuffers(0, _countof(pVBs), pVBs, Offsets, RESOURCE_STATE_TRANSITION_MODE_TRANSITION, SET_VERTEX_BUFFERS_FLAG_RESET); + pContext->SetIndexBuffer(pIB, 0, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); + + DrawIndexedAttribs drawAttrs{3, VT_UINT32, DRAW_FLAG_VERIFY_ALL}; + drawAttrs.NumInstances = 2; + drawAttrs.FirstInstanceLocation = 4; // Skip 4 instances + pContext->DrawIndexed(drawAttrs); + + Present(); +} + +TEST_F(DrawCommandTest, DrawIndexedInstanced_FirstInstance_IBOffset) +{ + auto* pEnv = TestingEnvironment::GetInstance(); + auto* pContext = pEnv->GetDeviceContext(); + + SetRenderTargets(sm_pDrawInstancedPSO); + + // clang-format off + const Vertex Triangles[] = + { + {}, {}, + VertInst[1], {}, VertInst[0], {}, {}, VertInst[2] + }; + Uint32 Indices[] = {0,0,0,0, 4, 2, 7}; + const float4 InstancedData[] = + { + {}, {}, {}, {}, // Skip 4 instances with FirstInstance + float4{0.5f, 0.5f, -0.5f, -0.5f}, + float4{0.5f, 0.5f, +0.5f, -0.5f} + }; + // clang-format on + + auto pVB = CreateVertexBuffer(Triangles, sizeof(Triangles)); + auto pInstVB = CreateVertexBuffer(InstancedData, sizeof(InstancedData)); + auto pIB = CreateIndexBuffer(Indices, _countof(Indices)); + + IBuffer* pVBs[] = {pVB, pInstVB}; + Uint32 Offsets[] = {0, 0}; + pContext->SetVertexBuffers(0, _countof(pVBs), pVBs, Offsets, RESOURCE_STATE_TRANSITION_MODE_TRANSITION, SET_VERTEX_BUFFERS_FLAG_RESET); + pContext->SetIndexBuffer(pIB, 4 * sizeof(Uint32), RESOURCE_STATE_TRANSITION_MODE_TRANSITION); + + DrawIndexedAttribs drawAttrs{3, VT_UINT32, DRAW_FLAG_VERIFY_ALL}; + drawAttrs.NumInstances = 2; + drawAttrs.FirstInstanceLocation = 4; // Skip 4 instances + pContext->DrawIndexed(drawAttrs); + + Present(); +} + +TEST_F(DrawCommandTest, DrawIndexedInstanced_FirstInstance_VBOffset) +{ + auto* pEnv = TestingEnvironment::GetInstance(); + auto* pContext = pEnv->GetDeviceContext(); + + SetRenderTargets(sm_pDrawInstancedPSO); + + // clang-format off + const Vertex Triangles[] = + { + {}, {}, {}, {}, // Skip 4 vertices with VB offset + {}, {}, + VertInst[1], {}, VertInst[0], {}, {}, VertInst[2] + }; + Uint32 Indices[] = {4, 2, 7}; + const float4 InstancedData[] = + { + {}, {}, {}, {}, {}, // Skip 5 instances with VB offset + {}, {}, {}, {}, // Skip 4 instances with FirstInstance + float4{0.5f, 0.5f, -0.5f, -0.5f}, + float4{0.5f, 0.5f, +0.5f, -0.5f} + }; + // clang-format on + + auto pVB = CreateVertexBuffer(Triangles, sizeof(Triangles)); + auto pInstVB = CreateVertexBuffer(InstancedData, sizeof(InstancedData)); + auto pIB = CreateIndexBuffer(Indices, _countof(Indices)); + + IBuffer* pVBs[] = {pVB, pInstVB}; + Uint32 Offsets[] = {4 * sizeof(Vertex), 5 * sizeof(float4)}; + pContext->SetVertexBuffers(0, _countof(pVBs), pVBs, Offsets, RESOURCE_STATE_TRANSITION_MODE_TRANSITION, SET_VERTEX_BUFFERS_FLAG_RESET); + pContext->SetIndexBuffer(pIB, 0, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); + + DrawIndexedAttribs drawAttrs{3, VT_UINT32, DRAW_FLAG_VERIFY_ALL}; + drawAttrs.NumInstances = 2; + drawAttrs.FirstInstanceLocation = 4; // Skip 4 instances + pContext->DrawIndexed(drawAttrs); + + Present(); +} + + +TEST_F(DrawCommandTest, DrawIndexedInstanced_FirstInstance_IBOffset_FirstIndex) +{ + auto* pEnv = TestingEnvironment::GetInstance(); + auto* pContext = pEnv->GetDeviceContext(); + + SetRenderTargets(sm_pDrawInstancedPSO); + + // clang-format off + const Vertex Triangles[] = + { + {}, {}, + VertInst[1], {}, VertInst[0], {}, {}, VertInst[2] + }; + Uint32 Indices[] = {0,0,0,0, 0,0,0, 4, 2, 7}; + const float4 InstancedData[] = + { + {}, {}, {}, {}, // Skip 4 instances with FirstInstance + float4{0.5f, 0.5f, -0.5f, -0.5f}, + float4{0.5f, 0.5f, +0.5f, -0.5f} + }; + // clang-format on + + auto pVB = CreateVertexBuffer(Triangles, sizeof(Triangles)); + auto pInstVB = CreateVertexBuffer(InstancedData, sizeof(InstancedData)); + auto pIB = CreateIndexBuffer(Indices, _countof(Indices)); + + IBuffer* pVBs[] = {pVB, pInstVB}; + Uint32 Offsets[] = {0, 0}; + pContext->SetVertexBuffers(0, _countof(pVBs), pVBs, Offsets, RESOURCE_STATE_TRANSITION_MODE_TRANSITION, SET_VERTEX_BUFFERS_FLAG_RESET); + pContext->SetIndexBuffer(pIB, 4 * sizeof(Uint32), RESOURCE_STATE_TRANSITION_MODE_TRANSITION); + + DrawIndexedAttribs drawAttrs{3, VT_UINT32, DRAW_FLAG_VERIFY_ALL}; + drawAttrs.NumInstances = 2; + drawAttrs.FirstInstanceLocation = 4; // Skip 4 instances + drawAttrs.FirstIndexLocation = 3; + pContext->DrawIndexed(drawAttrs); + + Present(); +} + + + +// Instanced draw commands with base vertex (glDrawElementsInstancedBaseVertex/DrawInstanced) + +TEST_F(DrawCommandTest, DrawIndexedInstanced_BaseVertex) +{ + auto* pEnv = TestingEnvironment::GetInstance(); + auto* pContext = pEnv->GetDeviceContext(); + + SetRenderTargets(sm_pDrawInstancedPSO); + + // clang-format off + const Vertex Triangles[] = + { + {}, {}, {}, // Skip 3 vertices with BaseVertex + {}, {}, + VertInst[1], {}, VertInst[0], {}, {}, VertInst[2] + }; + Uint32 Indices[] = {4, 2, 7}; + const float4 InstancedData[] = + { + float4{0.5f, 0.5f, -0.5f, -0.5f}, + float4{0.5f, 0.5f, +0.5f, -0.5f} + }; + // clang-format on + + auto pVB = CreateVertexBuffer(Triangles, sizeof(Triangles)); + auto pInstVB = CreateVertexBuffer(InstancedData, sizeof(InstancedData)); + auto pIB = CreateIndexBuffer(Indices, _countof(Indices)); + + IBuffer* pVBs[] = {pVB, pInstVB}; + Uint32 Offsets[] = {0, 0}; + pContext->SetVertexBuffers(0, _countof(pVBs), pVBs, Offsets, RESOURCE_STATE_TRANSITION_MODE_TRANSITION, SET_VERTEX_BUFFERS_FLAG_RESET); + pContext->SetIndexBuffer(pIB, 0, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); + + DrawIndexedAttribs drawAttrs{3, VT_UINT32, DRAW_FLAG_VERIFY_ALL}; + drawAttrs.NumInstances = 2; + drawAttrs.BaseVertex = 3; + pContext->DrawIndexed(drawAttrs); + + Present(); +} + +TEST_F(DrawCommandTest, DrawIndexedInstanced_FirstInstance_BaseVertex_VBOffset) +{ + auto* pEnv = TestingEnvironment::GetInstance(); + auto* pContext = pEnv->GetDeviceContext(); + + SetRenderTargets(sm_pDrawInstancedPSO); + + // clang-format off + const Vertex Triangles[] = + { + {}, {}, {}, {}, // Skip 4 vertices with VB offset + {}, {}, {}, // Skip 3 vertices with BaseVertex + {}, {}, + VertInst[1], {}, VertInst[0], {}, {}, VertInst[2] + }; + Uint32 Indices[] = {4, 2, 7}; + const float4 InstancedData[] = + { + {}, {}, {}, {}, {}, // Skip 5 instances with VB offset + {}, {}, {}, {}, // Skip 4 instances with FirstInstance + float4{0.5f, 0.5f, -0.5f, -0.5f}, + float4{0.5f, 0.5f, +0.5f, -0.5f} + }; + // clang-format on + + auto pVB = CreateVertexBuffer(Triangles, sizeof(Triangles)); + auto pInstVB = CreateVertexBuffer(InstancedData, sizeof(InstancedData)); + auto pIB = CreateIndexBuffer(Indices, _countof(Indices)); + + IBuffer* pVBs[] = {pVB, pInstVB}; + Uint32 Offsets[] = {4 * sizeof(Vertex), 5 * sizeof(float4)}; + pContext->SetVertexBuffers(0, _countof(pVBs), pVBs, Offsets, RESOURCE_STATE_TRANSITION_MODE_TRANSITION, SET_VERTEX_BUFFERS_FLAG_RESET); + pContext->SetIndexBuffer(pIB, 0, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); + + DrawIndexedAttribs drawAttrs{3, VT_UINT32, DRAW_FLAG_VERIFY_ALL}; + drawAttrs.NumInstances = 2; + drawAttrs.FirstInstanceLocation = 4; // Skip 4 instances + drawAttrs.BaseVertex = 3; + pContext->DrawIndexed(drawAttrs); + + Present(); +} + + +TEST_F(DrawCommandTest, DrawIndexedInstanced_FirstInstance_BaseVertex_FirstIndex_VBOffset_IBOffset) +{ + auto* pEnv = TestingEnvironment::GetInstance(); + auto* pContext = pEnv->GetDeviceContext(); + + SetRenderTargets(sm_pDrawInstancedPSO); + + // clang-format off + const Vertex Triangles[] = + { + {}, {}, {}, {}, // Skip 4 vertices with VB offset + {}, {}, {}, // Skip 3 vertices with BaseVertex + {}, {}, + VertInst[1], {}, VertInst[0], {}, {}, VertInst[2] + }; + Uint32 Indices[] = {0,0,0,0, 0,0,0, 4, 2, 7}; + const float4 InstancedData[] = + { + {}, {}, {}, {}, {}, // Skip 5 instances with VB offset + {}, {}, {}, {}, // Skip 4 instances with FirstInstance + float4{0.5f, 0.5f, -0.5f, -0.5f}, + float4{0.5f, 0.5f, +0.5f, -0.5f} + }; + // clang-format on + + auto pVB = CreateVertexBuffer(Triangles, sizeof(Triangles)); + auto pInstVB = CreateVertexBuffer(InstancedData, sizeof(InstancedData)); + auto pIB = CreateIndexBuffer(Indices, _countof(Indices)); + + IBuffer* pVBs[] = {pVB, pInstVB}; + Uint32 Offsets[] = {4 * sizeof(Vertex), 5 * sizeof(float4)}; + pContext->SetVertexBuffers(0, _countof(pVBs), pVBs, Offsets, RESOURCE_STATE_TRANSITION_MODE_TRANSITION, SET_VERTEX_BUFFERS_FLAG_RESET); + pContext->SetIndexBuffer(pIB, 4 * sizeof(Uint32), RESOURCE_STATE_TRANSITION_MODE_TRANSITION); + + DrawIndexedAttribs drawAttrs{3, VT_UINT32, DRAW_FLAG_VERIFY_ALL}; + drawAttrs.NumInstances = 2; + drawAttrs.FirstInstanceLocation = 4; // Skip 4 instances + drawAttrs.BaseVertex = 3; + drawAttrs.FirstIndexLocation = 3; + pContext->DrawIndexed(drawAttrs); + + Present(); +} + + +// Indirect draw calls + +TEST_F(DrawCommandTest, DrawInstancedIndirect_FirstInstance_BaseVertex_FirstIndex_VBOffset_IBOffset_InstOffset) +{ + auto* pEnv = TestingEnvironment::GetInstance(); + auto* pDevice = pEnv->GetDevice(); + if (!pDevice->GetDeviceCaps().bIndirectRenderingSupported) + GTEST_SKIP() << "Indirect rendering is not supported on this device"; + + auto* pContext = pEnv->GetDeviceContext(); + + SetRenderTargets(sm_pDrawInstancedPSO); + + // clang-format off + const Vertex Triangles[] = + { + {}, {}, {}, {}, // Skip 4 vertices with VB offset + {}, {}, {}, // Skip 3 vertices with StartVertexLocation + VertInst[0], VertInst[1], VertInst[2] + }; + const float4 InstancedData[] = + { + {}, {}, {}, {}, {}, // Skip 5 instances with VB offset + {}, {}, {}, {}, // Skip 4 instances with FirstInstance + float4{0.5f, 0.5f, -0.5f, -0.5f}, + float4{0.5f, 0.5f, +0.5f, -0.5f} + }; + // clang-format on + + auto pVB = CreateVertexBuffer(Triangles, sizeof(Triangles)); + auto pInstVB = CreateVertexBuffer(InstancedData, sizeof(InstancedData)); + + IBuffer* pVBs[] = {pVB, pInstVB}; + Uint32 Offsets[] = {4 * sizeof(Vertex), 5 * sizeof(float4)}; + pContext->SetVertexBuffers(0, _countof(pVBs), pVBs, Offsets, RESOURCE_STATE_TRANSITION_MODE_TRANSITION, SET_VERTEX_BUFFERS_FLAG_RESET); + + Uint32 IndirectDrawData[] = + { + 0, 0, 0, 0, 0, // Offset + + 6, // NumVertices + 2, // NumInstances + 3, // StartVertexLocation + 4 // FirstInstanceLocation + }; + auto pIndirectArgsBuff = CreateIndirectDrawArgsBuffer(IndirectDrawData, sizeof(IndirectDrawData)); + + DrawIndirectAttribs drawAttrs{DRAW_FLAG_VERIFY_ALL, RESOURCE_STATE_TRANSITION_MODE_TRANSITION}; + drawAttrs.IndirectDrawArgsOffset = 5 * sizeof(Uint32); + pContext->DrawIndirect(drawAttrs, pIndirectArgsBuff); + + Present(); +} + +TEST_F(DrawCommandTest, DrawIndexedInstancedIndirect_FirstInstance_BaseVertex_FirstIndex_VBOffset_IBOffset_InstOffset) +{ + auto* pEnv = TestingEnvironment::GetInstance(); + auto* pContext = pEnv->GetDeviceContext(); + + SetRenderTargets(sm_pDrawInstancedPSO); + + // clang-format off + const Vertex Triangles[] = + { + {}, {}, {}, {}, // Skip 4 vertices with VB offset + {}, {}, {}, // Skip 3 vertices with BaseVertex + {}, {}, + VertInst[1], {}, VertInst[0], {}, {}, VertInst[2] + }; + Uint32 Indices[] = {0,0,0, 0,0,0,0, 4, 2, 7}; + const float4 InstancedData[] = + { + {}, {}, {}, {}, // Skip 4 instances with VB offset + {}, {}, {}, {}, {}, // Skip 5 instances with FirstInstance + float4{0.5f, 0.5f, -0.5f, -0.5f}, + float4{0.5f, 0.5f, +0.5f, -0.5f} + }; + // clang-format on + + auto pVB = CreateVertexBuffer(Triangles, sizeof(Triangles)); + auto pInstVB = CreateVertexBuffer(InstancedData, sizeof(InstancedData)); + auto pIB = CreateIndexBuffer(Indices, _countof(Indices)); + + IBuffer* pVBs[] = {pVB, pInstVB}; + Uint32 Offsets[] = {4 * sizeof(Vertex), 4 * sizeof(float4)}; + pContext->SetVertexBuffers(0, _countof(pVBs), pVBs, Offsets, RESOURCE_STATE_TRANSITION_MODE_TRANSITION, SET_VERTEX_BUFFERS_FLAG_RESET); + pContext->SetIndexBuffer(pIB, 3 * sizeof(Uint32), RESOURCE_STATE_TRANSITION_MODE_TRANSITION); + + Uint32 IndirectDrawData[] = + { + 0, 0, 0, 0, 0, // Offset + + 6, // NumIndices + 2, // NumInstances + 4, // FirstIndexLocation + 3, // BaseVertex + 5, // FirstInstanceLocation + }; + auto pIndirectArgsBuff = CreateIndirectDrawArgsBuffer(IndirectDrawData, sizeof(IndirectDrawData)); + + DrawIndexedIndirectAttribs drawAttrs{VT_UINT32, DRAW_FLAG_VERIFY_ALL, RESOURCE_STATE_TRANSITION_MODE_TRANSITION}; + drawAttrs.IndirectDrawArgsOffset = 5 * sizeof(Uint32); + pContext->DrawIndexedIndirect(drawAttrs, pIndirectArgsBuff); + + Present(); +} + +} // namespace diff --git a/Tests/DiligentCoreAPITest/src/GL/ClearRenderTargetRefenceGL.cpp b/Tests/DiligentCoreAPITest/src/GL/ClearRenderTargetRefenceGL.cpp new file mode 100644 index 00000000..fa41d17f --- /dev/null +++ b/Tests/DiligentCoreAPITest/src/GL/ClearRenderTargetRefenceGL.cpp @@ -0,0 +1,53 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "GL/TestingEnvironmentGL.h" +#include "GL/TestingSwapChainGL.h" + +namespace Diligent +{ + +namespace Testing +{ + +void ClearRenderTargetReferenceGL(ISwapChain* pSwapChain) +{ + auto* pEnv = TestingEnvironmentGL::GetInstance(); + auto* pContext = pEnv->GetDeviceContext(); + auto* pTestingSwapChainGL = ValidatedCast(pSwapChain); + + const auto& SCDesc = pTestingSwapChainGL->GetDesc(); + + glDisable(GL_SCISSOR_TEST); + pTestingSwapChainGL->BindFramebuffer(); + glViewport(0, 0, SCDesc.Width, SCDesc.Height); + glClearColor(0.25, 0.5f, 0.75f, 1.0f); + glClear(GL_COLOR_BUFFER_BIT); + + // Make sure Diligent Engine will reset all GL states + pContext->InvalidateState(); +} + +} // namespace Testing + +} // namespace Diligent diff --git a/Tests/DiligentCoreAPITest/src/GL/CreateObjFromNativeResGL.cpp b/Tests/DiligentCoreAPITest/src/GL/CreateObjFromNativeResGL.cpp new file mode 100644 index 00000000..ad265eaf --- /dev/null +++ b/Tests/DiligentCoreAPITest/src/GL/CreateObjFromNativeResGL.cpp @@ -0,0 +1,167 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#if PLATFORM_WIN32 + +# ifndef GLEW_STATIC +# define GLEW_STATIC // Must be defined to use static version of glew +# endif +# include "GL/glew.h" +#elif PLATFORM_LINUX + +# ifndef GLEW_STATIC +# define GLEW_STATIC // Must be defined to use static version of glew +# endif +# ifndef GLEW_NO_GLU +# define GLEW_NO_GLU +# endif + +# include "GL/glew.h" + +// Undefine beautiful defines from GL/glx.h -> X11/Xlib.h +# ifdef Bool +# undef Bool +# endif +# ifdef True +# undef True +# endif +# ifdef False +# undef False +# endif +# ifdef Status +# undef Status +# endif +# ifdef Success +# undef Success +# endif + +#elif PLATFORM_MACOS + +# ifndef GLEW_STATIC +# define GLEW_STATIC // Must be defined to use static version of glew +# endif +# ifndef GLEW_NO_GLU +# define GLEW_NO_GLU +# endif + +# include "GL/glew.h" + +#elif PLATFORM_ANDROID + +# include +# include + +#elif PLATFORM_IOS + +# include + +#else +# error Unsupported platform +#endif + +#include "RenderDeviceGL.h" +#include "TextureGL.h" +#include "BufferGL.h" +#include "GraphicsAccessories.h" + +#include "GL/CreateObjFromNativeResGL.h" + +#include "gtest/gtest.h" + +namespace Diligent +{ + +namespace Testing +{ + +void TestCreateObjFromNativeResGL::CreateTexture(Diligent::ITexture* pTexture) +{ +#if PLATFORM_WIN32 || PLATFORM_LINUX || PLATFORM_ANDROID + RefCntAutoPtr pDeviceGL(m_pDevice, IID_RenderDeviceGL); + RefCntAutoPtr pTextureGL(pTexture, IID_TextureGL); + ASSERT_NE(pDeviceGL, nullptr); + ASSERT_NE(pTextureGL, nullptr); + + const auto& SrcTexDesc = pTexture->GetDesc(); + if (SrcTexDesc.Type == RESOURCE_DIM_TEX_CUBE_ARRAY) + return; + + auto GLHandle = pTextureGL->GetGLTextureHandle(); + ASSERT_NE(GLHandle, (GLuint)0); + + auto TmpTexDesc = SrcTexDesc; + + TmpTexDesc.Width = 0; + TmpTexDesc.Height = 0; + TmpTexDesc.MipLevels = 0; + TmpTexDesc.Format = TEX_FORMAT_UNKNOWN; + + RefCntAutoPtr pAttachedTexture; + pDeviceGL->CreateTextureFromGLHandle(GLHandle, TmpTexDesc, RESOURCE_STATE_UNKNOWN, &pAttachedTexture); + ASSERT_NE(pAttachedTexture, nullptr); + + auto TestTexDesc = pAttachedTexture->GetDesc(); + if (m_pDevice->GetTextureFormatInfo(SrcTexDesc.Format).IsTypeless) + TestTexDesc.Format = SrcTexDesc.Format; + + EXPECT_EQ(TestTexDesc, SrcTexDesc) << "Src tex desc: " << GetObjectDescString(SrcTexDesc) + << "\nTest tex desc: " << GetObjectDescString(TestTexDesc); + + RefCntAutoPtr pAttachedTextureGL(pAttachedTexture, IID_TextureGL); + ASSERT_NE(pAttachedTextureGL, nullptr); + EXPECT_EQ(pAttachedTextureGL->GetGLTextureHandle(), GLHandle); + EXPECT_EQ(pAttachedTextureGL->GetBindTarget(), pTextureGL->GetBindTarget()); + EXPECT_EQ(reinterpret_cast(pAttachedTextureGL->GetNativeHandle()), GLHandle); +#endif +} + +void TestCreateObjFromNativeResGL::CreateBuffer(Diligent::IBuffer* pBuffer) +{ +#if PLATFORM_WIN32 || PLATFORM_LINUX || PLATFORM_ANDROID + RefCntAutoPtr pDeviceGL(m_pDevice, IID_RenderDeviceGL); + RefCntAutoPtr pBufferGL(pBuffer, IID_BufferGL); + ASSERT_NE(pDeviceGL, nullptr); + ASSERT_NE(pBufferGL, nullptr); + + const auto& SrcBuffDesc = pBuffer->GetDesc(); + auto GLBufferHandle = pBufferGL->GetGLBufferHandle(); + ASSERT_NE(GLBufferHandle, (GLuint)0); + + RefCntAutoPtr pBufferFromNativeGLHandle; + pDeviceGL->CreateBufferFromGLHandle(GLBufferHandle, SrcBuffDesc, RESOURCE_STATE_UNKNOWN, &pBufferFromNativeGLHandle); + ASSERT_NE(pBufferFromNativeGLHandle, nullptr); + + const auto& TestBufferDesc = pBufferFromNativeGLHandle->GetDesc(); + EXPECT_EQ(TestBufferDesc, SrcBuffDesc) << "Src buff desc: " << GetObjectDescString(SrcBuffDesc) + << "\nTest buff desc: " << GetObjectDescString(TestBufferDesc); + + RefCntAutoPtr pTestBufferGL(pBufferFromNativeGLHandle, IID_BufferGL); + ASSERT_NE(pTestBufferGL, nullptr); + EXPECT_EQ(pTestBufferGL->GetGLBufferHandle(), GLBufferHandle); + EXPECT_EQ(reinterpret_cast(pTestBufferGL->GetNativeHandle()), GLBufferHandle); +#endif +} + +} // namespace Testing + +} // namespace Diligent diff --git a/Tests/DiligentCoreAPITest/src/GL/DrawCommandReferenceGL.cpp b/Tests/DiligentCoreAPITest/src/GL/DrawCommandReferenceGL.cpp new file mode 100644 index 00000000..2058fe12 --- /dev/null +++ b/Tests/DiligentCoreAPITest/src/GL/DrawCommandReferenceGL.cpp @@ -0,0 +1,131 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "GL/TestingEnvironmentGL.h" +#include "GL/TestingSwapChainGL.h" + +namespace Diligent +{ + +namespace Testing +{ + +static const char* VSSource = R"( +#version 420 core + +#ifndef GL_ES +out gl_PerVertex +{ + vec4 gl_Position; +}; +#endif + +layout(location = 0) out vec3 out_Color; + +void main() +{ + vec4 Pos[6]; + Pos[0] = vec4(-1.0, -0.5, 0.0, 1.0); + Pos[1] = vec4(-0.5, +0.5, 0.0, 1.0); + Pos[2] = vec4( 0.0, -0.5, 0.0, 1.0); + + Pos[3] = vec4(+0.0, -0.5, 0.0, 1.0); + Pos[4] = vec4(+0.5, +0.5, 0.0, 1.0); + Pos[5] = vec4(+1.0, -0.5, 0.0, 1.0); + + vec3 Col[6]; + Col[0] = vec3(1.0, 0.0, 0.0); + Col[1] = vec3(0.0, 1.0, 0.0); + Col[2] = vec3(0.0, 0.0, 1.0); + + Col[3] = vec3(1.0, 0.0, 0.0); + Col[4] = vec3(0.0, 1.0, 0.0); + Col[5] = vec3(0.0, 0.0, 1.0); + + gl_Position = Pos[gl_VertexID]; + out_Color = Col[gl_VertexID]; +} +)"; + +static const char* PSSource = R"( +#version 420 core + +layout(location = 0) in vec3 in_Color; +layout(location = 0) out vec4 out_Color; + +void main() +{ + out_Color = vec4(in_Color, 1.0); +} +)"; + +void RenderDrawCommandReferenceGL(ISwapChain* pSwapChain) +{ + auto* pEnv = TestingEnvironmentGL::GetInstance(); + auto* pContext = pEnv->GetDeviceContext(); + auto* pTestingSwapChainGL = ValidatedCast(pSwapChain); + + const auto& SCDesc = pTestingSwapChainGL->GetDesc(); + + GLuint glShaders[2] = {}; + + glShaders[0] = pEnv->CompileGLShader(VSSource, GL_VERTEX_SHADER); + ASSERT_NE(glShaders[0], 0u); + glShaders[1] = pEnv->CompileGLShader(PSSource, GL_FRAGMENT_SHADER); + ASSERT_NE(glShaders[1], 0u); + auto glProg = pEnv->LinkProgram(glShaders, 2); + ASSERT_NE(glProg, 0u); + + glDisable(GL_DEPTH_TEST); + glDisable(GL_SCISSOR_TEST); + glDisable(GL_BLEND); + glDisable(GL_CULL_FACE); + if (glPolygonMode != nullptr) + { + glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); + } + pTestingSwapChainGL->BindFramebuffer(); + glViewport(0, 0, SCDesc.Width, SCDesc.Height); + glClearColor(0.f, 0.f, 0.f, 0.f); + glClear(GL_COLOR_BUFFER_BIT); + glUseProgram(glProg); + glBindVertexArray(pEnv->GetDummyVAO()); + glDrawArrays(GL_TRIANGLES, 0, 6); + glBindVertexArray(0); + glUseProgram(0); + + for (int i = 0; i < _countof(glShaders); ++i) + { + if (glShaders[i] != 0) + glDeleteShader(glShaders[i]); + } + if (glProg != 0) + glDeleteProgram(glProg); + + // Make sure Diligent Engine will reset all GL states + pContext->InvalidateState(); +} + +} // namespace Testing + +} // namespace Diligent diff --git a/Tests/DiligentCoreAPITest/src/GL/TestingEnvironmentGL.cpp b/Tests/DiligentCoreAPITest/src/GL/TestingEnvironmentGL.cpp new file mode 100644 index 00000000..a78318cb --- /dev/null +++ b/Tests/DiligentCoreAPITest/src/GL/TestingEnvironmentGL.cpp @@ -0,0 +1,144 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "GL/TestingEnvironmentGL.h" + +namespace Diligent +{ + +namespace Testing +{ + +void CreateTestingSwapChainGL(IRenderDevice* pDevice, + IDeviceContext* pContext, + const SwapChainDesc& SCDesc, + ISwapChain** ppSwapChain); + +TestingEnvironmentGL::TestingEnvironmentGL(DeviceType deviceType, ADAPTER_TYPE AdapterType, const SwapChainDesc& SCDesc) : + TestingEnvironment{deviceType, AdapterType, SCDesc} +{ + // Initialize GLEW + auto err = glewInit(); + if (GLEW_OK != err) + LOG_ERROR_AND_THROW("Failed to initialize GLEW"); + + if (m_pSwapChain == nullptr) + { + CreateTestingSwapChainGL(m_pDevice, m_pDeviceContext, SCDesc, &m_pSwapChain); + } + + glGenVertexArrays(1, &m_DummyVAO); +} + +TestingEnvironmentGL::~TestingEnvironmentGL() +{ + glDeleteVertexArrays(1, &m_DummyVAO); +} + +GLuint TestingEnvironmentGL::CompileGLShader(const char* Source, GLenum ShaderType) +{ + GLuint glShader = glCreateShader(ShaderType); + + const char* ShaderStrings[] = {Source}; + GLint Lenghts[] = {static_cast(strlen(Source))}; + + // Provide source strings (the strings will be saved in internal OpenGL memory) + glShaderSource(glShader, _countof(ShaderStrings), ShaderStrings, Lenghts); + // When the shader is compiled, it will be compiled as if all of the given strings were concatenated end-to-end. + glCompileShader(glShader); + GLint compiled = GL_FALSE; + // Get compilation status + glGetShaderiv(glShader, GL_COMPILE_STATUS, &compiled); + if (!compiled) + { + int infoLogLen = 0; + // The function glGetShaderiv() tells how many bytes to allocate; the length includes the NULL terminator. + glGetShaderiv(glShader, GL_INFO_LOG_LENGTH, &infoLogLen); + + std::vector infoLog(infoLogLen); + if (infoLogLen > 0) + { + int charsWritten = 0; + // Get the log. infoLogLen is the size of infoLog. This tells OpenGL how many bytes at maximum it will write + // charsWritten is a return value, specifying how many bytes it actually wrote. One may pass NULL if he + // doesn't care + glGetShaderInfoLog(glShader, infoLogLen, &charsWritten, infoLog.data()); + VERIFY(charsWritten == infoLogLen - 1, "Unexpected info log length"); + LOG_ERROR("Failed to compile GL shader\n", infoLog.data()); + } + } + + return glShader; +} + +GLuint TestingEnvironmentGL::LinkProgram(GLuint Shaders[], GLuint NumShaders) +{ + auto glProg = glCreateProgram(); + + for (Uint32 i = 0; i < NumShaders; ++i) + { + glAttachShader(glProg, Shaders[i]); + VERIFY_EXPR(glGetError() == GL_NO_ERROR); + } + + glLinkProgram(glProg); + int IsLinked = GL_FALSE; + glGetProgramiv(glProg, GL_LINK_STATUS, &IsLinked); + if (!IsLinked) + { + int LengthWithNull = 0, Length = 0; + // Notice that glGetProgramiv is used to get the length for a shader program, not glGetShaderiv. + // The length of the info log includes a null terminator. + glGetProgramiv(glProg, GL_INFO_LOG_LENGTH, &LengthWithNull); + + // The maxLength includes the NULL character + std::vector shaderProgramInfoLog(LengthWithNull); + + // Notice that glGetProgramInfoLog is used, not glGetShaderInfoLog. + glGetProgramInfoLog(glProg, LengthWithNull, &Length, shaderProgramInfoLog.data()); + VERIFY(Length == LengthWithNull - 1, "Incorrect program info log len"); + LOG_ERROR_MESSAGE("Failed to link shader program:\n", shaderProgramInfoLog.data(), '\n'); + } + + for (Uint32 i = 0; i < NumShaders; ++i) + { + glDetachShader(glProg, Shaders[i]); + } + return glProg; +} + +TestingEnvironment* CreateTestingEnvironmentGL(DeviceType deviceType, ADAPTER_TYPE AdapterType, const SwapChainDesc& SCDesc) +{ + try + { + return new TestingEnvironmentGL{deviceType, AdapterType, SCDesc}; + } + catch (...) + { + return nullptr; + } +} + +} // namespace Testing + +} // namespace Diligent diff --git a/Tests/DiligentCoreAPITest/src/GL/TestingSwapChainGL.cpp b/Tests/DiligentCoreAPITest/src/GL/TestingSwapChainGL.cpp new file mode 100644 index 00000000..ece1572c --- /dev/null +++ b/Tests/DiligentCoreAPITest/src/GL/TestingSwapChainGL.cpp @@ -0,0 +1,158 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "GL/TestingEnvironmentGL.h" +#include "GL/TestingSwapChainGL.h" + +namespace Diligent +{ + +namespace Testing +{ + +TestingSwapChainGL::TestingSwapChainGL(IReferenceCounters* pRefCounters, + IRenderDevice* pDevice, + IDeviceContext* pContext, + const SwapChainDesc& SCDesc) : + TBase // + { + pRefCounters, + pDevice, + pContext, + SCDesc // + } +{ + { + glGenTextures(1, &m_RenderTarget); + if (glGetError() != GL_NO_ERROR) + LOG_ERROR_AND_THROW("Failed to create render target texture"); + + GLenum RenderTargetFmt = 0; + switch (m_SwapChainDesc.ColorBufferFormat) + { + case TEX_FORMAT_RGBA8_UNORM: + RenderTargetFmt = GL_RGBA8; + break; + + default: + UNSUPPORTED("Texture format ", GetTextureFormatAttribs(m_SwapChainDesc.ColorBufferFormat).Name, " is not a supported color buffer format"); + } + + glBindTexture(GL_TEXTURE_2D, m_RenderTarget); + // levels format width height + glTexStorage2D(GL_TEXTURE_2D, 1, RenderTargetFmt, m_SwapChainDesc.Width, m_SwapChainDesc.Height); + if (glGetError() != GL_NO_ERROR) + LOG_ERROR_AND_THROW("Failed to allocate render target texture"); + } + + + { + glGenTextures(1, &m_DepthBuffer); + if (glGetError() != GL_NO_ERROR) + LOG_ERROR_AND_THROW("Failed to create depth texture"); + + GLenum DepthBufferFmt = 0; + switch (m_SwapChainDesc.DepthBufferFormat) + { + case TEX_FORMAT_D32_FLOAT: + DepthBufferFmt = GL_DEPTH_COMPONENT32F; + break; + + default: + UNSUPPORTED("Texture format ", GetTextureFormatAttribs(m_SwapChainDesc.DepthBufferFormat).Name, " is not a supported depth buffer format"); + } + + glBindTexture(GL_TEXTURE_2D, m_DepthBuffer); + // levels format width height + glTexStorage2D(GL_TEXTURE_2D, 1, DepthBufferFmt, m_SwapChainDesc.Width, m_SwapChainDesc.Height); + if (glGetError() != GL_NO_ERROR) + LOG_ERROR_AND_THROW("Failed to allocate render target texture"); + } + + { + glGenFramebuffers(1, &m_FBO); + if (glGetError() != GL_NO_ERROR) + LOG_ERROR_AND_THROW("Failed to create FBO"); + + glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_FBO); + glBindFramebuffer(GL_READ_FRAMEBUFFER, m_FBO); + glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_RenderTarget, 0); + glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_RenderTarget, 0); + glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, m_DepthBuffer, 0); + glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, m_DepthBuffer, 0); + static const GLenum DrawBuffers[] = {GL_COLOR_ATTACHMENT0}; + glDrawBuffers(1, DrawBuffers); + GLenum Status = glCheckFramebufferStatus(GL_FRAMEBUFFER); + if (Status != GL_FRAMEBUFFER_COMPLETE) + LOG_ERROR_AND_THROW("FBO is incomplete"); + } + + // Make sure Diligent Engine will reset all GL states + pContext->InvalidateState(); +} + +void TestingSwapChainGL::BindFramebuffer() +{ + glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_FBO); + glBindFramebuffer(GL_READ_FRAMEBUFFER, m_FBO); +} + +TestingSwapChainGL::~TestingSwapChainGL() +{ + if (m_RenderTarget != 0) + glDeleteTextures(1, &m_RenderTarget); + if (m_DepthBuffer != 0) + glDeleteTextures(1, &m_DepthBuffer); + if (m_FBO != 0) + glDeleteFramebuffers(1, &m_FBO); +} + +void TestingSwapChainGL::TakeSnapshot() +{ + m_ReferenceDataPitch = m_SwapChainDesc.Width * 4; + m_ReferenceData.resize(m_SwapChainDesc.Height * m_ReferenceDataPitch); + glBindBuffer(GL_PIXEL_PACK_BUFFER, 0); + glBindFramebuffer(GL_READ_FRAMEBUFFER, m_FBO); + glReadPixels(0, 0, m_SwapChainDesc.Width, m_SwapChainDesc.Height, GL_RGBA, GL_UNSIGNED_BYTE, m_ReferenceData.data()); + VERIFY(glGetError() == GL_NO_ERROR, "Failed to read pixels from the framebuffer"); +} + +void CreateTestingSwapChainGL(IRenderDevice* pDevice, + IDeviceContext* pContext, + const SwapChainDesc& SCDesc, + ISwapChain** ppSwapChain) +{ + try + { + TestingSwapChainGL* pTestingSC(MakeNewRCObj()(pDevice, pContext, SCDesc)); + pTestingSC->QueryInterface(IID_SwapChain, reinterpret_cast(ppSwapChain)); + } + catch (...) + { + *ppSwapChain = nullptr; + } +} + +} // namespace Testing + +} // namespace Diligent diff --git a/Tests/DiligentCoreAPITest/src/GenerateMipsTest.cpp b/Tests/DiligentCoreAPITest/src/GenerateMipsTest.cpp new file mode 100644 index 00000000..5e3acc50 --- /dev/null +++ b/Tests/DiligentCoreAPITest/src/GenerateMipsTest.cpp @@ -0,0 +1,129 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "TestingEnvironment.h" + +#include "gtest/gtest.h" + +using namespace Diligent; +using namespace Diligent::Testing; + +namespace +{ + +TEST(GenerateMipsTest, GenerateMips) +{ + TestingEnvironment::ScopedReleaseResources AutoResetEnvironment; + + auto* pEnv = TestingEnvironment::GetInstance(); + auto* pDevice = pEnv->GetDevice(); + auto* pContext = pEnv->GetDeviceContext(); + + TEXTURE_FORMAT TestFormats[] = // + { + TEX_FORMAT_RGBA8_UNORM, + TEX_FORMAT_RGBA8_UNORM_SRGB, + TEX_FORMAT_RGBA32_FLOAT // + }; + + for (auto f = 0; f < _countof(TestFormats); ++f) + { + TextureDesc TexDesc; + TexDesc.Name = "Mips generation test texture"; + TexDesc.Type = RESOURCE_DIM_TEX_2D; + TexDesc.Format = TestFormats[f]; + TexDesc.Width = 128 + 6; + TexDesc.Height = 128 + 5; + TexDesc.BindFlags = BIND_SHADER_RESOURCE; + TexDesc.MipLevels = 6; + TexDesc.Usage = USAGE_DEFAULT; + TexDesc.MiscFlags = MISC_TEXTURE_FLAG_GENERATE_MIPS; + + std::vector ZeroData(TexDesc.Width * TexDesc.Height * 16); + + { + RefCntAutoPtr pTex; + std::vector SubresData(TexDesc.MipLevels); + for (auto& MipLevelData : SubresData) + { + MipLevelData.pData = ZeroData.data(); + MipLevelData.Stride = TexDesc.Width * 16; + } + TextureData InitData{SubresData.data(), TexDesc.MipLevels}; + + pDevice->CreateTexture(TexDesc, &InitData, &pTex); + ASSERT_NE(pTex, nullptr) << "Failed to create texture: " << TexDesc; + + pContext->GenerateMips(pTex->GetDefaultView(TEXTURE_VIEW_SHADER_RESOURCE)); + + TextureViewDesc ViewDesc(TEXTURE_VIEW_SHADER_RESOURCE, RESOURCE_DIM_TEX_2D_ARRAY); + ViewDesc.MostDetailedMip = 1; + ViewDesc.NumMipLevels = 3; + ViewDesc.Flags = TEXTURE_VIEW_FLAG_ALLOW_MIP_MAP_GENERATION; + RefCntAutoPtr pTexView; + pTex->CreateView(ViewDesc, &pTexView); + ASSERT_NE(pTexView, nullptr) << "Failed to create SRV for texture: " << TexDesc; + pContext->GenerateMips(pTexView); + } + + TexDesc.Name = "Mips generation test texture array"; + TexDesc.Type = RESOURCE_DIM_TEX_2D_ARRAY; + TexDesc.ArraySize = 16; + { + std::vector SubresData(TexDesc.MipLevels * TexDesc.ArraySize); + for (auto& MipLevelData : SubresData) + { + MipLevelData.pData = ZeroData.data(); + MipLevelData.Stride = TexDesc.Width * 16; + } + TextureData InitData{SubresData.data(), TexDesc.MipLevels * TexDesc.ArraySize}; + + RefCntAutoPtr pTex; + pDevice->CreateTexture(TexDesc, &InitData, &pTex); + ASSERT_NE(pTex, nullptr) << "Failed to create texture array: " << TexDesc; + + TextureViewDesc ViewDesc(TEXTURE_VIEW_SHADER_RESOURCE, RESOURCE_DIM_TEX_2D_ARRAY); + ViewDesc.FirstArraySlice = 2; + ViewDesc.NumArraySlices = 5; + ViewDesc.MostDetailedMip = 1; + ViewDesc.NumMipLevels = 5; + if (pDevice->GetDeviceCaps().DevType == DeviceType::D3D11) + { + // The appears to be a bug in D3D11 Warp: the warp crashes if + // the view addresses only a subset of mip levels + ViewDesc.MostDetailedMip = 0; + ViewDesc.NumMipLevels = TexDesc.MipLevels; + } + + ViewDesc.Flags = TEXTURE_VIEW_FLAG_ALLOW_MIP_MAP_GENERATION; + RefCntAutoPtr pTexView; + pTex->CreateView(ViewDesc, &pTexView); + ASSERT_NE(pTexView, nullptr) << "Failed to create SRV for texture array: " << TexDesc; + pContext->GenerateMips(pTexView); + + pContext->GenerateMips(pTex->GetDefaultView(TEXTURE_VIEW_SHADER_RESOURCE)); + } + } +} + +} // namespace diff --git a/Tests/DiligentCoreAPITest/src/HLSL2GLSLConverterTest.cpp b/Tests/DiligentCoreAPITest/src/HLSL2GLSLConverterTest.cpp new file mode 100644 index 00000000..50358d06 --- /dev/null +++ b/Tests/DiligentCoreAPITest/src/HLSL2GLSLConverterTest.cpp @@ -0,0 +1,131 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "TestingEnvironment.h" +#include "HLSL2GLSLConverter.h" + +#include "gtest/gtest.h" + +using namespace Diligent; +using namespace Diligent::Testing; + +namespace +{ + +RefCntAutoPtr CreateTestShader(const char* FileName, + const char* EntryPoint, + SHADER_TYPE ShaderType, + IHLSL2GLSLConversionStream** ppConversionStream = nullptr) +{ + auto* pEnv = TestingEnvironment::GetInstance(); + auto* pDevice = pEnv->GetDevice(); + + ShaderCreateInfo ShaderCI; + + RefCntAutoPtr pShaderSourceFactory; + pDevice->GetEngineFactory()->CreateDefaultShaderSourceStreamFactory("shaders/HLSL2GLSLConverter", &pShaderSourceFactory); + + ShaderCI.FilePath = FileName; + ShaderCI.EntryPoint = EntryPoint; + ShaderCI.pShaderSourceStreamFactory = pShaderSourceFactory; + ShaderCI.SourceLanguage = SHADER_SOURCE_LANGUAGE_HLSL; + ShaderCI.Desc.Name = "Test converted shader"; + ShaderCI.Desc.ShaderType = ShaderType; + ShaderCI.UseCombinedTextureSamplers = pDevice->GetDeviceCaps().IsGLDevice(); + ShaderCI.ppConversionStream = ppConversionStream; + + RefCntAutoPtr pShader; + pDevice->CreateShader(ShaderCI, &pShader); + + return pShader; +} + +TEST(HLSL2GLSLConverterTest, VS_PS) +{ + TestingEnvironment::ScopedReset EnvironmentAutoReset; + + RefCntAutoPtr pStream; + + auto pVS = CreateTestShader("VS_PS.hlsl", "TestVS", SHADER_TYPE_VERTEX, &pStream); + EXPECT_NE(pVS, nullptr); + auto pPS = CreateTestShader("VS_PS.hlsl", "TestPS", SHADER_TYPE_PIXEL, &pStream); + EXPECT_NE(pPS, nullptr); +} + +TEST(HLSL2GLSLConverterTest, CS_RWTex1D) +{ + TestingEnvironment::ScopedReset EnvironmentAutoReset; + + auto* pEnv = TestingEnvironment::GetInstance(); + if (!pEnv->GetDevice()->GetDeviceCaps().bComputeShadersSupported) + { + GTEST_SKIP() << "This device does not support compute shaders"; + } + + auto pCS = CreateTestShader("CS_RWTex1D.hlsl", "TestCS", SHADER_TYPE_COMPUTE); + EXPECT_NE(pCS, nullptr); +} + +TEST(HLSL2GLSLConverterTest, CS_RWTex2D_1) +{ + TestingEnvironment::ScopedReset EnvironmentAutoReset; + + auto* pEnv = TestingEnvironment::GetInstance(); + if (!pEnv->GetDevice()->GetDeviceCaps().bComputeShadersSupported) + { + GTEST_SKIP() << "This device does not support compute shaders"; + } + + auto pCS = CreateTestShader("CS_RWTex2D_1.hlsl", "TestCS", SHADER_TYPE_COMPUTE); + EXPECT_NE(pCS, nullptr); +} + +TEST(HLSL2GLSLConverterTest, CS_RWTex2D_2) +{ + TestingEnvironment::ScopedReset EnvironmentAutoReset; + + auto* pEnv = TestingEnvironment::GetInstance(); + if (!pEnv->GetDevice()->GetDeviceCaps().bComputeShadersSupported) + { + GTEST_SKIP() << "This device does not support compute shaders"; + } + + auto pCS = CreateTestShader("CS_RWTex2D_2.hlsl", "TestCS", SHADER_TYPE_COMPUTE); + EXPECT_NE(pCS, nullptr); +} + +TEST(HLSL2GLSLConverterTest, CS_RWBuff) +{ + TestingEnvironment::ScopedReset EnvironmentAutoReset; + + auto* pEnv = TestingEnvironment::GetInstance(); + if (!pEnv->GetDevice()->GetDeviceCaps().bComputeShadersSupported) + { + GTEST_SKIP() << "This device does not support compute shaders"; + } + + auto pCS = CreateTestShader("CS_RWBuff.hlsl", "TestCS", SHADER_TYPE_COMPUTE); + EXPECT_NE(pCS, nullptr); +} + +} // namespace diff --git a/Tests/DiligentCoreAPITest/src/MTResourceCreationTest.cpp b/Tests/DiligentCoreAPITest/src/MTResourceCreationTest.cpp new file mode 100644 index 00000000..1a7e4e5f --- /dev/null +++ b/Tests/DiligentCoreAPITest/src/MTResourceCreationTest.cpp @@ -0,0 +1,311 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include +#include +#include + +#include "TestingEnvironment.h" +#include "ThreadSignal.h" +#if D3D12_SUPPORTED +# include "D3D12/D3D12DebugLayerSetNameBugWorkaround.h" +#endif + +#include "gtest/gtest.h" + +using namespace Diligent; +using namespace Diligent::Testing; + +namespace +{ + +static const char g_ShaderSource[] = R"( +void VSMain(out float4 pos : SV_POSITION) +{ + pos = float4(0.0, 0.0, 0.0, 0.0); +} + +void PSMain(out float4 col : SV_TARGET) +{ + col = float4(0.0, 0.0, 0.0, 0.0); +} +)"; + + +class MultithreadedResourceCreationTest : public ::testing::Test +{ +protected: + ~MultithreadedResourceCreationTest(); + + static void WorkerThreadFunc(MultithreadedResourceCreationTest* This, size_t ThreadNum); + + void StartWorkerThreadsAndWait(int SignalIdx); + void WaitSiblingWorkerThreads(int SignalIdx); + + std::vector m_Threads; + + ThreadingTools::Signal m_WorkerThreadSignal[2]; + ThreadingTools::Signal m_MainThreadSignal; + + std::mutex m_NumThreadsCompletedMtx; + std::atomic_int m_NumThreadsCompleted[2]; + std::atomic_int m_NumThreadsReady; + + static const int NumBuffersToCreate = 10; + static const int NumTexturesToCreate = 5; + static const int NumPSOToCreate = 3; + +#ifdef _DEBUG + static const int NumIterations = 10; +#else + static const int NumIterations = 30; +#endif +}; + +MultithreadedResourceCreationTest::~MultithreadedResourceCreationTest() +{ + LOG_INFO_MESSAGE("Created ", NumBuffersToCreate, " buffers, ", NumTexturesToCreate, " textures, and ", + NumPSOToCreate, " PSO in ", NumIterations, " iterations by each of ", m_Threads.size(), " threads"); +} + +void MultithreadedResourceCreationTest::WaitSiblingWorkerThreads(int SignalIdx) +{ + auto NumThreads = static_cast(m_Threads.size()); + if (++m_NumThreadsCompleted[SignalIdx] == NumThreads) + { + ASSERT_FALSE(m_WorkerThreadSignal[1 - SignalIdx].IsTriggered()); + m_MainThreadSignal.Trigger(); + } + else + { + while (m_NumThreadsCompleted[SignalIdx] < NumThreads) + std::this_thread::yield(); + } +} + +void MultithreadedResourceCreationTest::StartWorkerThreadsAndWait(int SignalIdx) +{ + m_NumThreadsCompleted[SignalIdx] = 0; + m_WorkerThreadSignal[SignalIdx].Trigger(true); + + m_MainThreadSignal.Wait(true, 1); +} + +void MultithreadedResourceCreationTest::WorkerThreadFunc(MultithreadedResourceCreationTest* This, size_t ThreadNum) +{ + auto* pEnv = TestingEnvironment::GetInstance(); + auto* pDevice = pEnv->GetDevice(); + + const int NumThreads = static_cast(This->m_Threads.size()); + + constexpr Uint32 TexWidth = 512; + constexpr Uint32 TexHeight = 512; + + std::vector RawBufferData(1024); + std::vector RawTextureData(TexWidth * TexHeight * 4); + + int SignalIdx = 0; + while (true) + { + auto SignaledValue = This->m_WorkerThreadSignal[SignalIdx].Wait(true, NumThreads); + if (SignaledValue < 0) + { + return; + } + + for (Uint32 i = 0; i < NumBuffersToCreate; ++i) + { + BufferDesc BuffDesc; + BuffDesc.Usage = USAGE_DEFAULT; + BuffDesc.BindFlags = BIND_UNIFORM_BUFFER; + BuffDesc.Name = "MT creation test buffer"; + BuffDesc.uiSizeInBytes = static_cast(RawBufferData.size()); + + BufferData BuffData; + BuffData.DataSize = BuffDesc.uiSizeInBytes; + BuffData.pData = RawBufferData.data(); + + RefCntAutoPtr pBuffer1; + pDevice->CreateBuffer(BuffDesc, &BuffData, &pBuffer1); + EXPECT_NE(pBuffer1, nullptr) << "Failed to create the following buffer:\n" + << BuffDesc; + + BuffDesc.Mode = BUFFER_MODE_FORMATTED; + BuffDesc.ElementByteStride = 16; + BuffDesc.BindFlags = BIND_SHADER_RESOURCE | BIND_UNORDERED_ACCESS; + RefCntAutoPtr pBuffer2; + pDevice->CreateBuffer(BuffDesc, &BuffData, &pBuffer2); + EXPECT_NE(pBuffer2, nullptr) << "Failed to create the following buffer:\n" + << BuffDesc; + + BufferViewDesc ViewDesc; + ViewDesc.ViewType = BUFFER_VIEW_SHADER_RESOURCE; + ViewDesc.ByteOffset = 16; + ViewDesc.Format.NumComponents = 4; + ViewDesc.Format.IsNormalized = False; + ViewDesc.Format.ValueType = VT_FLOAT32; + RefCntAutoPtr pBufferSRV; + if (pBuffer2) + { + pBuffer2->CreateView(ViewDesc, &pBufferSRV); + EXPECT_NE(pBufferSRV, nullptr) << "Failed to create SRV for the following buffer:\n" + << BuffDesc; + } + + BuffDesc.BindFlags = BIND_VERTEX_BUFFER | BIND_UNORDERED_ACCESS; + RefCntAutoPtr pBuffer3; + pDevice->CreateBuffer(BuffDesc, &BuffData, &pBuffer3); + EXPECT_NE(pBuffer3, nullptr) << "Failed to create the following buffer:\n" + << BuffDesc; + ViewDesc.ViewType = BUFFER_VIEW_UNORDERED_ACCESS; + RefCntAutoPtr pBufferUAV; + if (pBuffer3) + { + pBuffer3->CreateView(ViewDesc, &pBufferUAV); + EXPECT_NE(pBufferUAV, nullptr) << "Failed to create UAV for the following buffer:\n" + << BuffDesc; + } + + BuffDesc.Mode = BUFFER_MODE_RAW; + BuffDesc.BindFlags = BIND_INDEX_BUFFER | BIND_UNORDERED_ACCESS; + RefCntAutoPtr pBuffer4; + pDevice->CreateBuffer(BuffDesc, &BuffData, &pBuffer4); + EXPECT_NE(pBuffer4, nullptr) << "Failed to create the following buffer:\n" + << BuffDesc; + } + + for (Uint32 i = 0; i < NumTexturesToCreate; ++i) + { + RefCntAutoPtr pTexture; + + TextureDesc TexDesc; + TexDesc.BindFlags = BIND_SHADER_RESOURCE | BIND_RENDER_TARGET | BIND_UNORDERED_ACCESS; + TexDesc.Type = RESOURCE_DIM_TEX_2D; + TexDesc.Width = TexWidth; + TexDesc.Height = TexHeight; + TexDesc.Format = TEX_FORMAT_RGBA8_UNORM; + TexDesc.MipLevels = 1; + + + TextureSubResData SubResData; + SubResData.pData = RawTextureData.data(); + SubResData.Stride = TexDesc.Width * 4; + + TextureData TexData; + TexData.NumSubresources = 1; + TexData.pSubResources = &SubResData; + + pDevice->CreateTexture(TexDesc, &TexData, &pTexture); + EXPECT_NE(pTexture, nullptr) << "Failed to create the following texture:\n" + << TexDesc; + } + + for (Uint32 i = 0; i < NumPSOToCreate; ++i) + { + RefCntAutoPtr pTrivialVS, pTrivialPS; + RefCntAutoPtr pPSO; + { + ShaderCreateInfo Attrs; + Attrs.Source = g_ShaderSource; + Attrs.EntryPoint = "VSMain"; + Attrs.Desc.ShaderType = SHADER_TYPE_VERTEX; + Attrs.Desc.Name = "TrivialVS (MTResourceCreationTest)"; + Attrs.SourceLanguage = SHADER_SOURCE_LANGUAGE_HLSL; + Attrs.UseCombinedTextureSamplers = true; + pDevice->CreateShader(Attrs, &pTrivialVS); + if (!pTrivialVS) + { + ADD_FAILURE() << "Failed to create trivial VS"; + continue; + } + + Attrs.EntryPoint = "PSMain"; + Attrs.Desc.ShaderType = SHADER_TYPE_PIXEL; + Attrs.Desc.Name = "TrivialPS (MTResourceCreationTest)"; + pDevice->CreateShader(Attrs, &pTrivialPS); + if (!pTrivialPS) + { + ADD_FAILURE() << "Failed to create trivial PS"; + continue; + } + + PipelineStateDesc PSODesc; + PSODesc.GraphicsPipeline.pVS = pTrivialVS; + PSODesc.GraphicsPipeline.pPS = pTrivialPS; + PSODesc.GraphicsPipeline.PrimitiveTopology = PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; + PSODesc.GraphicsPipeline.NumRenderTargets = 1; + PSODesc.GraphicsPipeline.RTVFormats[0] = TEX_FORMAT_RGBA8_UNORM; + PSODesc.GraphicsPipeline.DSVFormat = TEX_FORMAT_D32_FLOAT; + + pDevice->CreatePipelineState(PSODesc, &pPSO); + EXPECT_NE(pPSO, nullptr) << "Failed to create test PSO"; + } + } + + This->WaitSiblingWorkerThreads(SignalIdx); + SignalIdx = 1 - SignalIdx; + } +} + + +TEST_F(MultithreadedResourceCreationTest, CreateResources) +{ + auto* pEnv = TestingEnvironment::GetInstance(); + auto* pDevice = pEnv->GetDevice(); + if (pDevice->GetDeviceCaps().IsGLDevice()) + { + GTEST_SKIP() << "Multithreading resource creation is not supported in OpenGL"; + } + +#if D3D12_SUPPORTED + // There is a bug in D3D12 debug layer as of build version 10.0.18362: SetName() method + // is not protected by a mutex internally. This, in combination with the fact that root signatures are + // de-duplicated by D3D12 runtime results in a race condition when SetName is called and causes random crashes. + + // As a workaround, we create the root signature ahead of time and reserve enough space for the name + // to avoid memory allocation. + + D3D12DebugLayerSetNameBugWorkaround D3D12DebugLayerBugWorkaround(pDevice); +#endif + + TestingEnvironment::ScopedReleaseResources AutoResetEnvironment; + + auto numCores = std::thread::hardware_concurrency(); + m_Threads.resize(std::max(numCores, 4u)); + for (auto& t : m_Threads) + t = std::thread(WorkerThreadFunc, this, &t - m_Threads.data()); + + int SignalIdx = 0; + for (Uint32 iter = 0; iter < NumIterations; ++iter) + { + StartWorkerThreadsAndWait(SignalIdx); + pEnv->ReleaseResources(); + SignalIdx = 1 - SignalIdx; + } + + m_WorkerThreadSignal[SignalIdx].Trigger(true, -1); + for (auto& t : m_Threads) + t.join(); +} + +} // namespace diff --git a/Tests/DiligentCoreAPITest/src/PSOCompatibilityTest.cpp b/Tests/DiligentCoreAPITest/src/PSOCompatibilityTest.cpp new file mode 100644 index 00000000..8e8f261d --- /dev/null +++ b/Tests/DiligentCoreAPITest/src/PSOCompatibilityTest.cpp @@ -0,0 +1,325 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "TestingEnvironment.h" + +#include "gtest/gtest.h" + +using namespace Diligent; +using namespace Diligent::Testing; + +namespace +{ + +static const char* VS0 = R"( +float4 main() : SV_Position +{ + return float4(0.0, 0.0, 0.0, 0.0); +} +)"; + +static const char* PS0 = R"( +float4 main() : SV_Target +{ + return float4(0.0, 0.0, 0.0, 0.0); +} +)"; + +static const char* PS_Tex = R"( +Texture2D g_tex2D; +SamplerState g_tex2D_sampler; +float4 main() : SV_Target +{ + return g_tex2D.Sample(g_tex2D_sampler, float2(0.0, 0.0)); +} +)"; + +static const char* PS_Tex2 = R"( +Texture2D g_tex2D2; +SamplerState g_tex2D2_sampler; +float4 main() : SV_Target +{ + return g_tex2D2.Sample(g_tex2D2_sampler, float2(0.0, 0.0)); +} +)"; + +static const char* PS_ArrOfTex = R"( +Texture2D g_tex2D[2]; +SamplerState g_tex2D_sampler; +float4 main() : SV_Target +{ + return g_tex2D[0].Sample(g_tex2D_sampler, float2(0.0, 0.0)) + g_tex2D[1].Sample(g_tex2D_sampler, float2(0.0, 0.0)); +} +)"; + +static const char* PS_TexArr = R"( +Texture2DArray g_tex2D; +SamplerState g_tex2D_sampler; +float4 main() : SV_Target +{ + return g_tex2D.Sample(g_tex2D_sampler, float3(0.0, 0.0, 0.0)); +} +)"; + + +static const char* PS_CB = R"( +cbuffer Test +{ + float4 g_Test; +}; + +float4 main() : SV_Target +{ + return g_Test; +} +)"; + +static const char* PS1_CB = R"( +cbuffer Test +{ + float4 g_Test; + float4 g_Test2; +}; + +float4 main() : SV_Target +{ + return g_Test + g_Test2; +} +)"; + +static const char* PS_2CB = R"( +cbuffer Test +{ + float4 g_Test; +}; + +cbuffer Test2 +{ + float4 g_Test2; +}; + +float4 main() : SV_Target +{ + return g_Test + g_Test2; +} +)"; + +static const char* PS_TexCB = R"( +cbuffer Test +{ + float4 g_Test; +}; + +cbuffer Test2 +{ + float4 g_Test2; +}; + +Texture2D g_tex2D; +SamplerState g_tex2D_sampler; +float4 main() : SV_Target +{ + return g_Test + g_Test2 + g_tex2D.Sample(g_tex2D_sampler, float2(0.0, 0.0)); +} +)"; + +static const char* PS_TexCB2 = R"( +cbuffer TestA +{ + float4 g_Test; +}; + +cbuffer Test2A +{ + float4 g_Test2; +}; + +Texture2D g_tex2DA; +SamplerState g_tex2DA_sampler; +float4 main() : SV_Target +{ + return g_Test + g_Test2 + g_tex2DA.Sample(g_tex2DA_sampler, float2(0.0, 0.0)); +} +)"; + +static const char* CS_RwBuff = R"( +RWTexture2D g_RWTex; + +[numthreads(1,1,1)] +void main() +{ + g_RWTex[int2(0,0)] = 0.0; +} +)"; + +static const char* CS_RwBuff2 = R"( +RWTexture2D g_RWTex2; + +[numthreads(1,1,1)] +void main() +{ + g_RWTex2[int2(0,0)] = 0.0; +} +)"; + +static const char* CS_RwBuff3 = R"( +RWTexture2D g_RWTex; +RWTexture2D g_RWTex2; + +[numthreads(1,1,1)] +void main() +{ + g_RWTex[int2(0,0)] = 0.0; + g_RWTex2[int2(0,0)] = 0.0; +} +)"; + + +RefCntAutoPtr CreateGraphicsPSO(IRenderDevice* pDevice, const char* VSSource, const char* PSSource) +{ + PipelineStateDesc PSODesc; + PSODesc.IsComputePipeline = false; + PSODesc.GraphicsPipeline.NumRenderTargets = 1; + PSODesc.GraphicsPipeline.RTVFormats[0] = TEX_FORMAT_RGBA8_UNORM_SRGB; + PSODesc.GraphicsPipeline.DepthStencilDesc.DepthEnable = False; + + ShaderCreateInfo CreationAttrs; + CreationAttrs.SourceLanguage = SHADER_SOURCE_LANGUAGE_HLSL; + CreationAttrs.UseCombinedTextureSamplers = true; + RefCntAutoPtr pVS; + { + CreationAttrs.Desc.ShaderType = SHADER_TYPE_VERTEX; + CreationAttrs.EntryPoint = "main"; + CreationAttrs.Desc.Name = "PSO Compatibility test VS"; + CreationAttrs.Source = VSSource; + pDevice->CreateShader(CreationAttrs, &pVS); + VERIFY_EXPR(pVS != nullptr); + } + + RefCntAutoPtr pPS; + { + CreationAttrs.Desc.ShaderType = SHADER_TYPE_PIXEL; + CreationAttrs.EntryPoint = "main"; + CreationAttrs.Desc.Name = "PSO Compatibility test PS"; + CreationAttrs.Source = PSSource; + pDevice->CreateShader(CreationAttrs, &pPS); + VERIFY_EXPR(pPS != nullptr); + } + + PSODesc.GraphicsPipeline.pVS = pVS; + PSODesc.GraphicsPipeline.pPS = pPS; + + RefCntAutoPtr pPSO; + pDevice->CreatePipelineState(PSODesc, &pPSO); + VERIFY_EXPR(pPSO != nullptr); + + return pPSO; +} + +RefCntAutoPtr CreateComputePSO(IRenderDevice* pDevice, const char* CSSource) +{ + PipelineStateDesc PSODesc; + PSODesc.IsComputePipeline = true; + ShaderCreateInfo CreationAttrs; + CreationAttrs.SourceLanguage = SHADER_SOURCE_LANGUAGE_HLSL; + CreationAttrs.UseCombinedTextureSamplers = true; + RefCntAutoPtr pCS; + { + CreationAttrs.Desc.ShaderType = SHADER_TYPE_COMPUTE; + CreationAttrs.EntryPoint = "main"; + CreationAttrs.Desc.Name = "PSO Compatibility test CS"; + CreationAttrs.Source = CSSource; + pDevice->CreateShader(CreationAttrs, &pCS); + VERIFY_EXPR(pCS != nullptr); + } + PSODesc.ComputePipeline.pCS = pCS; + + RefCntAutoPtr pPSO; + pDevice->CreatePipelineState(PSODesc, &pPSO); + VERIFY_EXPR(pPSO != nullptr); + + return pPSO; +} + +TEST(PSOCompatibility, CompilationFailure) +{ + auto* pEnv = TestingEnvironment::GetInstance(); + auto* pDevice = pEnv->GetDevice(); + + TestingEnvironment::ScopedReset EnvironmentAutoReset; + + auto DevType = pDevice->GetDeviceCaps().DevType; + auto PSO0 = CreateGraphicsPSO(pDevice, VS0, PS0); + ASSERT_TRUE(PSO0); + EXPECT_TRUE(PSO0->IsCompatibleWith(PSO0)); + auto PSO0_1 = CreateGraphicsPSO(pDevice, VS0, PS0); + ASSERT_TRUE(PSO0_1); + EXPECT_TRUE(PSO0->IsCompatibleWith(PSO0_1)); + EXPECT_TRUE(PSO0_1->IsCompatibleWith(PSO0)); + + auto PSO_Tex = CreateGraphicsPSO(pDevice, VS0, PS_Tex); + auto PSO_Tex2 = CreateGraphicsPSO(pDevice, VS0, PS_Tex2); + auto PSO_TexArr = CreateGraphicsPSO(pDevice, VS0, PS_TexArr); + auto PSO_ArrOfTex = CreateGraphicsPSO(pDevice, VS0, PS_ArrOfTex); + ASSERT_TRUE(PSO_Tex); + ASSERT_TRUE(PSO_Tex2); + ASSERT_TRUE(PSO_TexArr); + ASSERT_TRUE(PSO_ArrOfTex); + EXPECT_TRUE(PSO_Tex->IsCompatibleWith(PSO_Tex2)); + if (DevType != DeviceType::D3D12 && DevType != DeviceType::Vulkan) + { + EXPECT_FALSE(PSO_Tex->IsCompatibleWith(PSO_TexArr)); + } + VERIFY_EXPR(!PSO_Tex->IsCompatibleWith(PSO_ArrOfTex)); + if (DevType != DeviceType::D3D12 && DevType != DeviceType::Vulkan) + { + EXPECT_FALSE(PSO_Tex2->IsCompatibleWith(PSO_TexArr)); + } + EXPECT_FALSE(PSO_Tex2->IsCompatibleWith(PSO_ArrOfTex)); + EXPECT_FALSE(PSO_TexArr->IsCompatibleWith(PSO_ArrOfTex)); + + auto PSO_CB = CreateGraphicsPSO(pDevice, VS0, PS_CB); + auto PSO1_CB = CreateGraphicsPSO(pDevice, VS0, PS1_CB); + auto PSO_2CB = CreateGraphicsPSO(pDevice, VS0, PS_2CB); + EXPECT_TRUE(PSO_CB->IsCompatibleWith(PSO1_CB)); + EXPECT_FALSE(PSO_CB->IsCompatibleWith(PSO_2CB)); + + auto PSO_TexCB = CreateGraphicsPSO(pDevice, VS0, PS_TexCB); + auto PSO_TexCB2 = CreateGraphicsPSO(pDevice, VS0, PS_TexCB2); + EXPECT_TRUE(PSO_TexCB->IsCompatibleWith(PSO_TexCB2)); + EXPECT_TRUE(PSO_TexCB2->IsCompatibleWith(PSO_TexCB)); + + if (pDevice->GetDeviceCaps().bComputeShadersSupported) + { + auto PSO_RWBuff = CreateComputePSO(pDevice, CS_RwBuff); + auto PSO_RWBuff2 = CreateComputePSO(pDevice, CS_RwBuff2); + auto PSO_RWBuff3 = CreateComputePSO(pDevice, CS_RwBuff3); + EXPECT_TRUE(PSO_RWBuff); + EXPECT_TRUE(PSO_RWBuff2); + EXPECT_TRUE(PSO_RWBuff3); + EXPECT_TRUE(PSO_RWBuff->IsCompatibleWith(PSO_RWBuff2)); + EXPECT_FALSE(PSO_RWBuff->IsCompatibleWith(PSO_RWBuff3)); + } +} + +} // namespace diff --git a/Tests/DiligentCoreAPITest/src/PSOTestBase.cpp b/Tests/DiligentCoreAPITest/src/PSOTestBase.cpp new file mode 100644 index 00000000..5b0bc8d0 --- /dev/null +++ b/Tests/DiligentCoreAPITest/src/PSOTestBase.cpp @@ -0,0 +1,99 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "PSOTestBase.h" +#include "TestingEnvironment.h" + +namespace Diligent +{ + +namespace Testing +{ + +PSOTestBase::Resources PSOTestBase::sm_Resources; + +static const char g_ShaderSource[] = R"( +void VSMain(out float4 pos : SV_POSITION) +{ + pos = float4(0.0, 0.0, 0.0, 0.0); +} + +void PSMain(out float4 col : SV_TARGET) +{ + col = float4(0.0, 0.0, 0.0, 0.0); +} +)"; + +void PSOTestBase::InitResources() +{ + auto* pEnv = TestingEnvironment::GetInstance(); + auto* pDevice = pEnv->GetDevice(); + + ShaderCreateInfo Attrs; + Attrs.Source = g_ShaderSource; + Attrs.EntryPoint = "VSMain"; + Attrs.Desc.ShaderType = SHADER_TYPE_VERTEX; + Attrs.Desc.Name = "TrivialVS (TestPipelineStateBase)"; + Attrs.SourceLanguage = SHADER_SOURCE_LANGUAGE_HLSL; + Attrs.UseCombinedTextureSamplers = true; + pDevice->CreateShader(Attrs, &sm_Resources.pTrivialVS); + + Attrs.EntryPoint = "PSMain"; + Attrs.Desc.ShaderType = SHADER_TYPE_PIXEL; + Attrs.Desc.Name = "TrivialPS (TestPipelineStateBase)"; + pDevice->CreateShader(Attrs, &sm_Resources.pTrivialPS); + + auto& PSODesc = sm_Resources.PSODesc; + + PSODesc.GraphicsPipeline.pVS = sm_Resources.pTrivialVS; + PSODesc.GraphicsPipeline.pPS = sm_Resources.pTrivialPS; + PSODesc.GraphicsPipeline.PrimitiveTopology = PRIMITIVE_TOPOLOGY_TRIANGLE_LIST; + PSODesc.GraphicsPipeline.NumRenderTargets = 1; + PSODesc.GraphicsPipeline.RTVFormats[0] = TEX_FORMAT_RGBA8_UNORM; + PSODesc.GraphicsPipeline.DSVFormat = TEX_FORMAT_D32_FLOAT; +} + +void PSOTestBase::ReleaseResources() +{ + sm_Resources = Resources{}; + TestingEnvironment::GetInstance()->Reset(); +} + +RefCntAutoPtr PSOTestBase::CreateTestPSO(const PipelineStateDesc& PSODesc, bool BindPSO) +{ + auto* pEnv = TestingEnvironment::GetInstance(); + auto* pDevice = pEnv->GetDevice(); + auto* pContext = pEnv->GetDeviceContext(); + + RefCntAutoPtr pPSO; + pDevice->CreatePipelineState(PSODesc, &pPSO); + if (BindPSO && pPSO) + { + pContext->SetPipelineState(pPSO); + } + return pPSO; +} + +} // namespace Testing + +} // namespace Diligent diff --git a/Tests/DiligentCoreAPITest/src/RasterizerStateTest.cpp b/Tests/DiligentCoreAPITest/src/RasterizerStateTest.cpp new file mode 100644 index 00000000..aea21319 --- /dev/null +++ b/Tests/DiligentCoreAPITest/src/RasterizerStateTest.cpp @@ -0,0 +1,109 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "TestingEnvironment.h" +#include "PSOTestBase.h" +#include "GraphicsAccessories.h" + +#include "gtest/gtest.h" + +using namespace Diligent; +using namespace Diligent::Testing; + +namespace +{ + +class RasterizerStateTest : public PSOTestBase, public ::testing::Test +{ +protected: + static void SetUpTestSuite() + { + InitResources(); + } + + static void TearDownTestSuite() + { + ReleaseResources(); + TestingEnvironment::GetInstance()->ReleaseResources(); + } +}; + +TEST_F(RasterizerStateTest, CreatePSO) +{ + auto PSODesc = GetPSODesc(); + + RasterizerStateDesc& RSDesc = PSODesc.GraphicsPipeline.RasterizerDesc; + + ASSERT_TRUE(CreateTestPSO(PSODesc, true)); + + for (auto FillMode = FILL_MODE_UNDEFINED + 1; FillMode < FILL_MODE_NUM_MODES; ++FillMode) + { + RSDesc.FillMode = static_cast(FillMode); + auto pPSO = CreateTestPSO(PSODesc, true); + ASSERT_TRUE(pPSO) << "Fill mode: " << GetFillModeLiteralName(RSDesc.FillMode); + EXPECT_EQ(pPSO->GetDesc().GraphicsPipeline.RasterizerDesc.FillMode, RSDesc.FillMode); + } + + for (auto CullMode = CULL_MODE_UNDEFINED + 1; CullMode < CULL_MODE_NUM_MODES; ++CullMode) + { + RSDesc.CullMode = static_cast(CullMode); + auto pPSO = CreateTestPSO(PSODesc, true); + ASSERT_TRUE(pPSO) << "Cull mode: " << GetCullModeLiteralName(RSDesc.CullMode); + EXPECT_EQ(pPSO->GetDesc().GraphicsPipeline.RasterizerDesc.CullMode, RSDesc.CullMode); + } + + { + RSDesc.FrontCounterClockwise = !RSDesc.FrontCounterClockwise; + auto pPSO = CreateTestPSO(PSODesc, true); + ASSERT_TRUE(pPSO); + EXPECT_EQ(pPSO->GetDesc().GraphicsPipeline.RasterizerDesc.FrontCounterClockwise, RSDesc.FrontCounterClockwise); + } + + RSDesc.DepthBias = 100; + ASSERT_TRUE(CreateTestPSO(PSODesc, true)); + + RSDesc.DepthBiasClamp = 1.f; + ASSERT_TRUE(CreateTestPSO(PSODesc, true)); + + RSDesc.SlopeScaledDepthBias = 2.f; + ASSERT_TRUE(CreateTestPSO(PSODesc, true)); + + { + RSDesc.DepthClipEnable = !RSDesc.DepthClipEnable; + auto pPSO = CreateTestPSO(PSODesc, true); + ASSERT_TRUE(pPSO); + EXPECT_EQ(pPSO->GetDesc().GraphicsPipeline.RasterizerDesc.DepthClipEnable, RSDesc.DepthClipEnable); + } + + { + RSDesc.ScissorEnable = !RSDesc.ScissorEnable; + auto pPSO = CreateTestPSO(PSODesc, true); + ASSERT_TRUE(pPSO); + EXPECT_EQ(pPSO->GetDesc().GraphicsPipeline.RasterizerDesc.ScissorEnable, RSDesc.ScissorEnable); + } + + RSDesc.AntialiasedLineEnable = !RSDesc.AntialiasedLineEnable; + ASSERT_TRUE(CreateTestPSO(PSODesc, true)); +} + +} // namespace diff --git a/Tests/DiligentCoreAPITest/src/SamplerCreationTest.cpp b/Tests/DiligentCoreAPITest/src/SamplerCreationTest.cpp new file mode 100644 index 00000000..59450ef1 --- /dev/null +++ b/Tests/DiligentCoreAPITest/src/SamplerCreationTest.cpp @@ -0,0 +1,218 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include +#include + +#include "TestingEnvironment.h" +#include "Sampler.h" +#include "GraphicsAccessories.h" + +#include "gtest/gtest.h" + +using namespace Diligent; +using namespace Diligent::Testing; + +namespace +{ + +class FilterTypeTest : public testing::TestWithParam> +{ +protected: + static void TearDownTestSuite() + { + TestingEnvironment::GetInstance()->ReleaseResources(); + } +}; + +TEST_P(FilterTypeTest, CreateSampler) +{ + auto* pEnv = TestingEnvironment::GetInstance(); + auto* pDevice = pEnv->GetDevice(); + + SamplerDesc SamplerDesc; + const auto& Param = GetParam(); + SamplerDesc.MinFilter = std::get<0>(Param); + SamplerDesc.MagFilter = std::get<1>(Param); + SamplerDesc.MipFilter = std::get<2>(Param); + RefCntAutoPtr pSampler; + pDevice->CreateSampler(SamplerDesc, &pSampler); + ASSERT_TRUE(pSampler); + EXPECT_EQ(pSampler->GetDesc(), SamplerDesc); +} + +std::string GetSamplerFilterTestName(const testing::TestParamInfo>& info) // +{ + std::string name = + std::string{GetFilterTypeLiteralName(std::get<0>(info.param), false)} + std::string{"__"} + + std::string{GetFilterTypeLiteralName(std::get<1>(info.param), false)} + std::string{"__"} + + std::string{GetFilterTypeLiteralName(std::get<2>(info.param), false)}; + for (size_t i = 0; i < name.length(); ++i) + { + if (!std::isalnum(name[i])) + name[i] = '_'; + } + return name; +} + + +INSTANTIATE_TEST_SUITE_P(RegularFitlers, + FilterTypeTest, + testing::Combine( + testing::Values(FILTER_TYPE_POINT, FILTER_TYPE_LINEAR), + testing::Values(FILTER_TYPE_POINT, FILTER_TYPE_LINEAR), + testing::Values(FILTER_TYPE_POINT, FILTER_TYPE_LINEAR)), + GetSamplerFilterTestName); + +INSTANTIATE_TEST_SUITE_P(ComparisonFilters, + FilterTypeTest, + testing::Combine( + testing::Values(FILTER_TYPE_COMPARISON_POINT, FILTER_TYPE_COMPARISON_LINEAR), + testing::Values(FILTER_TYPE_COMPARISON_POINT, FILTER_TYPE_COMPARISON_LINEAR), + testing::Values(FILTER_TYPE_COMPARISON_POINT, FILTER_TYPE_COMPARISON_LINEAR)), + GetSamplerFilterTestName); + +TEST(FilterTypeTest, AnisotropicFilter) +{ + auto* pEnv = TestingEnvironment::GetInstance(); + auto* pDevice = pEnv->GetDevice(); + + { + SamplerDesc SamplerDesc; + SamplerDesc.MinFilter = FILTER_TYPE_ANISOTROPIC; + SamplerDesc.MagFilter = FILTER_TYPE_ANISOTROPIC; + SamplerDesc.MipFilter = FILTER_TYPE_ANISOTROPIC; + + SamplerDesc.MaxAnisotropy = 4; + RefCntAutoPtr pSampler; + pDevice->CreateSampler(SamplerDesc, &pSampler); + ASSERT_TRUE(pSampler); + ASSERT_TRUE(pSampler); + EXPECT_EQ(pSampler->GetDesc(), SamplerDesc); + } + + { + SamplerDesc SamplerDesc; + SamplerDesc.MinFilter = FILTER_TYPE_COMPARISON_ANISOTROPIC; + SamplerDesc.MagFilter = FILTER_TYPE_COMPARISON_ANISOTROPIC; + SamplerDesc.MipFilter = FILTER_TYPE_COMPARISON_ANISOTROPIC; + + SamplerDesc.MaxAnisotropy = 4; + RefCntAutoPtr pSampler; + pDevice->CreateSampler(SamplerDesc, &pSampler); + ASSERT_TRUE(pSampler); + ASSERT_TRUE(pSampler); + EXPECT_EQ(pSampler->GetDesc(), SamplerDesc); + } +} + + +class AddressModeTest : public testing::TestWithParam +{ +protected: + static void TearDownTestSuite() + { + TestingEnvironment::GetInstance()->ReleaseResources(); + } +}; + +TEST_P(AddressModeTest, CreateSampler) +{ + auto* pEnv = TestingEnvironment::GetInstance(); + auto* pDevice = pEnv->GetDevice(); + + SamplerDesc SamplerDesc; + SamplerDesc.MinFilter = FILTER_TYPE_LINEAR; + SamplerDesc.MagFilter = FILTER_TYPE_LINEAR; + SamplerDesc.MipFilter = FILTER_TYPE_LINEAR; + SamplerDesc.AddressU = SamplerDesc.AddressV = SamplerDesc.AddressW = GetParam(); + RefCntAutoPtr pSampler; + pDevice->CreateSampler(SamplerDesc, &pSampler); + ASSERT_TRUE(pSampler); + EXPECT_EQ(pSampler->GetDesc(), SamplerDesc); + + pEnv->ReleaseResources(); +} + +INSTANTIATE_TEST_SUITE_P(AddressModes, + AddressModeTest, + testing::Values( + TEXTURE_ADDRESS_WRAP, + TEXTURE_ADDRESS_MIRROR, + TEXTURE_ADDRESS_CLAMP, + TEXTURE_ADDRESS_BORDER), + [](const testing::TestParamInfo& info) // + { + return std::string{GetTextureAddressModeLiteralName(info.param, true)}; + } // +); + + +class ComparisonFuncTest : public testing::TestWithParam +{ +protected: + static void TearDownTestSuite() + { + TestingEnvironment::GetInstance()->ReleaseResources(); + } +}; + +TEST_P(ComparisonFuncTest, CreateSampler) +{ + auto* pEnv = TestingEnvironment::GetInstance(); + auto* pDevice = pEnv->GetDevice(); + + SamplerDesc SamplerDesc; + SamplerDesc.MinFilter = FILTER_TYPE_LINEAR; + SamplerDesc.MagFilter = FILTER_TYPE_LINEAR; + SamplerDesc.MipFilter = FILTER_TYPE_LINEAR; + SamplerDesc.ComparisonFunc = GetParam(); + RefCntAutoPtr pSampler1, pSampler2; + SamplerDesc.Name = "Sam1"; + pDevice->CreateSampler(SamplerDesc, &pSampler1); + SamplerDesc.Name = "Sam2"; + pDevice->CreateSampler(SamplerDesc, &pSampler2); + ASSERT_TRUE(pSampler1); + ASSERT_TRUE(pSampler2); + EXPECT_EQ(pSampler1, pSampler2); + EXPECT_EQ(pSampler1->GetDesc(), SamplerDesc); +} + +INSTANTIATE_TEST_SUITE_P(ComparisonFunctions, + ComparisonFuncTest, + testing::Values( + COMPARISON_FUNC_NEVER, + COMPARISON_FUNC_LESS, + COMPARISON_FUNC_EQUAL, + COMPARISON_FUNC_LESS_EQUAL, + COMPARISON_FUNC_GREATER, + COMPARISON_FUNC_NOT_EQUAL, + COMPARISON_FUNC_GREATER_EQUAL, + COMPARISON_FUNC_ALWAYS), + [](const testing::TestParamInfo& info) // + { + return std::string{GetComparisonFunctionLiteralName(info.param, true)}; + } // +); + +} // namespace diff --git a/Tests/DiligentCoreAPITest/src/SeparateTextureSamplerTest.cpp b/Tests/DiligentCoreAPITest/src/SeparateTextureSamplerTest.cpp new file mode 100644 index 00000000..c842cf02 --- /dev/null +++ b/Tests/DiligentCoreAPITest/src/SeparateTextureSamplerTest.cpp @@ -0,0 +1,181 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "TestingEnvironment.h" + +#include "gtest/gtest.h" + +using namespace Diligent; +using namespace Diligent::Testing; + +namespace +{ + +static const char g_VSShaderSource[] = R"( +void VSMain(out float4 pos : SV_POSITION) +{ + pos = float4(0.0, 0.0, 0.0, 0.0); +} +)"; + +static const char g_PSShaderSource[] = R"( +Texture2D g_Tex; +SamplerState g_Sam; +Texture2D g_Tex2; +SamplerState g_Sam2; +SamplerState g_Sam3[2]; +SamplerState g_Sam4[2]; + +void PSMain(out float4 col : SV_TARGET) +{ + col = g_Tex.Sample(g_Sam, float2(0.5, 0.5)) + + g_Tex2.Sample(g_Sam2, float2(0.5, 0.5)) + + g_Tex2.Sample(g_Sam3[0], float2(0.5, 0.5)) + + g_Tex2.Sample(g_Sam3[1], float2(0.5, 0.5)) + + g_Tex2.Sample(g_Sam4[0], float2(0.5, 0.5)) + + g_Tex2.Sample(g_Sam4[1], float2(0.5, 0.5)); +} +)"; + +TEST(SeparateTextureSampler, CreateSampler) +{ + auto* pEnv = TestingEnvironment::GetInstance(); + auto* pDevice = pEnv->GetDevice(); + auto* pContext = pEnv->GetDeviceContext(); + + if (pDevice->GetDeviceCaps().IsGLDevice()) + { + GTEST_SKIP() << "Separate texture samplers are not supported in OpenGL"; + } + + TestingEnvironment::ScopedReset EnvironmentAutoReset; + + ShaderCreateInfo Attrs; + Attrs.Source = g_VSShaderSource; + Attrs.EntryPoint = "VSMain"; + Attrs.Desc.ShaderType = SHADER_TYPE_VERTEX; + Attrs.Desc.Name = "VSMain (TestSeparateTextureSampler)"; + Attrs.SourceLanguage = SHADER_SOURCE_LANGUAGE_HLSL; + RefCntAutoPtr pVS; + pDevice->CreateShader(Attrs, &pVS); + ASSERT_TRUE(pVS); + + Attrs.Source = g_PSShaderSource; + Attrs.EntryPoint = "PSMain"; + Attrs.Desc.ShaderType = SHADER_TYPE_PIXEL; + Attrs.Desc.Name = "PSMain (TestSeparateTextureSampler)"; + + RefCntAutoPtr pPS; + pDevice->CreateShader(Attrs, &pPS); + ASSERT_TRUE(pPS); + + PipelineStateDesc PSODesc; + PSODesc.GraphicsPipeline.pVS = pVS; + PSODesc.GraphicsPipeline.pPS = pPS; + PSODesc.GraphicsPipeline.PrimitiveTopology = PRIMITIVE_TOPOLOGY_TRIANGLE_LIST; + PSODesc.GraphicsPipeline.NumRenderTargets = 1; + PSODesc.GraphicsPipeline.RTVFormats[0] = TEX_FORMAT_RGBA8_UNORM; + PSODesc.GraphicsPipeline.DSVFormat = TEX_FORMAT_UNKNOWN; + PSODesc.GraphicsPipeline.DepthStencilDesc.DepthEnable = false; + + ShaderResourceVariableDesc Vars[] = + { + {SHADER_TYPE_PIXEL, "g_Tex", SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE}, + {SHADER_TYPE_PIXEL, "g_Sam", SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC}, + {SHADER_TYPE_PIXEL, "g_Tex2", SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC}, + {SHADER_TYPE_PIXEL, "g_Sam2", SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE}, + {SHADER_TYPE_PIXEL, "g_Sam4", SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE} // + }; + PSODesc.ResourceLayout.Variables = Vars; + PSODesc.ResourceLayout.NumVariables = _countof(Vars); + + StaticSamplerDesc StaticSamplers[] = + { + {SHADER_TYPE_PIXEL, "g_Sam2", SamplerDesc{}} // + }; + PSODesc.ResourceLayout.StaticSamplers = StaticSamplers; + PSODesc.ResourceLayout.NumStaticSamplers = _countof(StaticSamplers); + + RefCntAutoPtr pPSO; + pDevice->CreatePipelineState(PSODesc, &pPSO); + ASSERT_TRUE(pPSO); + + TextureDesc TexDesc; + TexDesc.Name = "Separate sampler texture test"; + TexDesc.Type = RESOURCE_DIM_TEX_2D; + TexDesc.Width = 256; + TexDesc.Height = 256; + TexDesc.Format = TEX_FORMAT_RGBA8_UNORM; + TexDesc.Usage = USAGE_DEFAULT; + TexDesc.BindFlags = BIND_SHADER_RESOURCE; + RefCntAutoPtr pTexture; + pDevice->CreateTexture(TexDesc, nullptr, &pTexture); + ASSERT_TRUE(pTexture); + + RefCntAutoPtr pSampler; + pDevice->CreateSampler(SamplerDesc{}, &pSampler); + IDeviceObject* ppSamplers[2] = {pSampler, pSampler}; + pPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, "g_Sam3")->SetArray(ppSamplers, 0, 2); + + RefCntAutoPtr pSRB; + pPSO->CreateShaderResourceBinding(&pSRB, true); + + pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_Tex")->Set(pTexture->GetDefaultView(TEXTURE_VIEW_SHADER_RESOURCE)); + pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_Sam")->Set(pSampler); + pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_Sam4")->SetArray(ppSamplers, 0, 2); + pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_Tex2")->Set(pTexture->GetDefaultView(TEXTURE_VIEW_SHADER_RESOURCE)); + ASSERT_TRUE(pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_Sam2") == nullptr); + + auto VarCount = pSRB->GetVariableCount(SHADER_TYPE_PIXEL); + EXPECT_EQ(VarCount, 4u); + for (Uint32 v = 0; v < VarCount; ++v) + { + auto* pVar = pSRB->GetVariableByIndex(SHADER_TYPE_PIXEL, v); + EXPECT_EQ(pVar->GetIndex(), v); + EXPECT_TRUE(pVar->GetType() == SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE || pVar->GetType() == SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC); + auto pVar2 = pSRB->GetVariableByName(SHADER_TYPE_PIXEL, pVar->GetResourceDesc().Name); + EXPECT_EQ(pVar, pVar2); + } + + TextureDesc RenderTargetDesc; + RenderTargetDesc.Type = RESOURCE_DIM_TEX_2D; + RenderTargetDesc.Width = 256; + RenderTargetDesc.Height = 256; + RenderTargetDesc.BindFlags = BIND_RENDER_TARGET | BIND_SHADER_RESOURCE; + RenderTargetDesc.Format = TEX_FORMAT_RGBA8_UNORM; + RenderTargetDesc.Name = "TestSeparateTextureSampler: test render target"; + RefCntAutoPtr pRenderTarget; + pDevice->CreateTexture(RenderTargetDesc, nullptr, &pRenderTarget); + ASSERT_TRUE(pRenderTarget); + + ITextureView* pRTV[] = {pRenderTarget->GetDefaultView(TEXTURE_VIEW_RENDER_TARGET)}; + pContext->SetRenderTargets(1, pRTV, nullptr, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); + float Zero[4] = {}; + pContext->ClearRenderTarget(pRTV[0], Zero, RESOURCE_STATE_TRANSITION_MODE_VERIFY); + pContext->SetPipelineState(pPSO); + pContext->CommitShaderResources(pSRB, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); + DrawAttribs DrawAttrs(3, DRAW_FLAG_VERIFY_ALL); + pContext->Draw(DrawAttrs); +} + +} // namespace diff --git a/Tests/DiligentCoreAPITest/src/ShaderResourceArrayTest.cpp b/Tests/DiligentCoreAPITest/src/ShaderResourceArrayTest.cpp new file mode 100644 index 00000000..515ecbbc --- /dev/null +++ b/Tests/DiligentCoreAPITest/src/ShaderResourceArrayTest.cpp @@ -0,0 +1,244 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "TestingEnvironment.h" + +#include "gtest/gtest.h" + +using namespace Diligent; +using namespace Diligent::Testing; + +namespace +{ + +TEST(ShaderResourceLayout, ResourceArray) +{ + auto* pEnv = TestingEnvironment::GetInstance(); + auto* pDevice = pEnv->GetDevice(); + auto* pContext = pEnv->GetDeviceContext(); + + TestingEnvironment::ScopedReset EnvironmentAutoReset; + + RefCntAutoPtr pShaderSourceFactory; + pDevice->GetEngineFactory()->CreateDefaultShaderSourceStreamFactory("shaders", &pShaderSourceFactory); + ShaderCreateInfo ShaderCI; + ShaderCI.pShaderSourceStreamFactory = pShaderSourceFactory; + ShaderCI.UseCombinedTextureSamplers = true; + ShaderCI.HLSLVersion = ShaderCreateInfo::ShaderVersion{5, 0}; + RefCntAutoPtr pVS, pPS; + { + ShaderCI.Desc.Name = "ShaderResourceArrayTest: VS"; + ShaderCI.FilePath = "ShaderResourceArrayTest.vsh"; + ShaderCI.Desc.ShaderType = SHADER_TYPE_VERTEX; + ShaderCI.SourceLanguage = SHADER_SOURCE_LANGUAGE_HLSL; + pDevice->CreateShader(ShaderCI, &pVS); + ASSERT_NE(pVS, nullptr); + } + + { + ShaderCI.Desc.Name = "ShaderResourceArrayTest: PS"; + ShaderCI.FilePath = "ShaderResourceArrayTest.psh"; + ShaderCI.Desc.ShaderType = SHADER_TYPE_PIXEL; + ShaderCI.SourceLanguage = SHADER_SOURCE_LANGUAGE_HLSL; + pDevice->CreateShader(ShaderCI, &pPS); + ASSERT_NE(pPS, nullptr); + } + + + PipelineStateDesc PSODesc; + StaticSamplerDesc StaticSampler; + StaticSampler.Desc.MinFilter = FILTER_TYPE_LINEAR; + StaticSampler.Desc.MagFilter = FILTER_TYPE_LINEAR; + StaticSampler.Desc.MipFilter = FILTER_TYPE_LINEAR; + StaticSampler.ShaderStages = SHADER_TYPE_PIXEL; + StaticSampler.SamplerOrTextureName = "g_tex2DTest"; + PSODesc.ResourceLayout.NumStaticSamplers = 1; + PSODesc.ResourceLayout.StaticSamplers = &StaticSampler; + // clang-format off + ShaderResourceVariableDesc Vars[] = + { + {SHADER_TYPE_PIXEL, "g_tex2DTest", SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE}, + {SHADER_TYPE_PIXEL, "g_tex2DTest2", SHADER_RESOURCE_VARIABLE_TYPE_STATIC}, + {SHADER_TYPE_PIXEL, "g_tex2D", SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC} + }; + // clang-format on + PSODesc.ResourceLayout.Variables = Vars; + PSODesc.ResourceLayout.NumVariables = _countof(Vars); + PSODesc.GraphicsPipeline.DepthStencilDesc.DepthEnable = False; + PSODesc.GraphicsPipeline.RasterizerDesc.CullMode = CULL_MODE_NONE; + PSODesc.GraphicsPipeline.BlendDesc.IndependentBlendEnable = False; + PSODesc.GraphicsPipeline.BlendDesc.RenderTargets[0].BlendEnable = False; + PSODesc.GraphicsPipeline.NumRenderTargets = 1; + + constexpr TEXTURE_FORMAT RTVFormat = TEX_FORMAT_RGBA8_UNORM; + constexpr TEXTURE_FORMAT DSVFormat = TEX_FORMAT_D32_FLOAT; + PSODesc.GraphicsPipeline.RTVFormats[0] = RTVFormat; + PSODesc.GraphicsPipeline.DSVFormat = DSVFormat; + PSODesc.GraphicsPipeline.pVS = pVS; + PSODesc.GraphicsPipeline.pPS = pPS; + + PSODesc.GraphicsPipeline.PrimitiveTopology = PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; + // clang-format off + LayoutElement Elems[] = + { + LayoutElement{ 0, 0, 3, VT_FLOAT32, false, 0 }, + LayoutElement{ 1, 0, 2, VT_FLOAT32, false, sizeof( float ) * 3 } + }; + // clang-format on + PSODesc.GraphicsPipeline.InputLayout.LayoutElements = Elems; + PSODesc.GraphicsPipeline.InputLayout.NumElements = _countof(Elems); + RefCntAutoPtr pPSO; + pDevice->CreatePipelineState(PSODesc, &pPSO); + ASSERT_NE(pPSO, nullptr); + + RefCntAutoPtr pSRB; + pPSO->CreateShaderResourceBinding(&pSRB); + ASSERT_NE(pSRB, nullptr); + + // clang-format off + float Vertices[] = + { + 0, 0, 0, 0,1, + 0, 1, 0, 0,0, + 1, 0, 0, 1,1, + 1, 1, 0, 1,0 + }; + // clang-format on + constexpr float fMinXCoord = 0.4f; + constexpr float fMinYCoord = -0.9f; + constexpr float fXExtent = 0.5f; + constexpr float fYExtent = 0.5f; + for (int v = 0; v < 4; ++v) + { + Vertices[v * 5 + 0] = Vertices[v * 5 + 0] * fXExtent + fMinXCoord; + Vertices[v * 5 + 1] = Vertices[v * 5 + 1] * fYExtent + fMinYCoord; + } + + RefCntAutoPtr pVertexBuff; + { + BufferDesc BuffDesc; + BuffDesc.uiSizeInBytes = sizeof(Vertices); + BuffDesc.BindFlags = BIND_VERTEX_BUFFER; + BuffDesc.Usage = USAGE_STATIC; + BufferData BuffData; + BuffData.pData = Vertices; + BuffData.DataSize = BuffDesc.uiSizeInBytes; + pDevice->CreateBuffer(BuffDesc, &BuffData, &pVertexBuff); + ASSERT_NE(pVertexBuff, nullptr); + } + + RefCntAutoPtr pRTV, pDSV; + { + auto pRenderTarget = pEnv->CreateTexture("ShaderResourceLayout: offscreen render target", TEX_FORMAT_RGBA8_UNORM, BIND_RENDER_TARGET, 256, 256); + ASSERT_NE(pRenderTarget, nullptr); + pRTV = pRenderTarget->GetDefaultView(TEXTURE_VIEW_RENDER_TARGET); + ASSERT_NE(pRTV, nullptr); + + auto pDepth = pEnv->CreateTexture("ShaderResourceLayout: offscreen depth", TEX_FORMAT_D32_FLOAT, BIND_DEPTH_STENCIL, 256, 256); + ASSERT_NE(pDepth, nullptr); + pDSV = pDepth->GetDefaultView(TEXTURE_VIEW_DEPTH_STENCIL); + ASSERT_NE(pDSV, nullptr); + } + + RefCntAutoPtr pSampler; + SamplerDesc SamDesc; + pDevice->CreateSampler(SamDesc, &pSampler); + RefCntAutoPtr pTextures[8]; + for (auto t = 0; t < _countof(pTextures); ++t) + { + TextureDesc TexDesc; + TexDesc.Type = RESOURCE_DIM_TEX_2D; + TexDesc.Width = 256; + TexDesc.Height = 256; + TexDesc.MipLevels = 8; + TexDesc.Usage = USAGE_STATIC; + TexDesc.Format = TEX_FORMAT_RGBA8_UNORM; + TexDesc.BindFlags = BIND_SHADER_RESOURCE; + TexDesc.Name = "Test Texture"; + + std::vector Data(TexDesc.Width * TexDesc.Height * 4, 128); + std::vector SubResouces(TexDesc.MipLevels); + for (Uint32 i = 0; i < TexDesc.MipLevels; ++i) + { + auto& SubResData = SubResouces[i]; + SubResData.pData = Data.data(); + SubResData.Stride = TexDesc.Width * 4; + } + + float ColorOffset[4] = {(float)t * 0.13f, (float)t * 0.21f, (float)t * 0.29f, 0}; + //TestTexturing::GenerateTextureData(pDevice, Data, SubResouces, TexDesc, ColorOffset); + TextureData TexData; + TexData.pSubResources = SubResouces.data(); + TexData.NumSubresources = (Uint32)SubResouces.size(); + + pDevice->CreateTexture(TexDesc, &TexData, &pTextures[t]); + ASSERT_NE(pTextures[t], nullptr); + pTextures[t]->GetDefaultView(TEXTURE_VIEW_SHADER_RESOURCE)->SetSampler(pSampler); + } + + // clang-format off + ResourceMappingEntry ResMpEntries [] = + { + ResourceMappingEntry("g_tex2DTest", pTextures[0]->GetDefaultView(TEXTURE_VIEW_SHADER_RESOURCE), 0), + ResourceMappingEntry("g_tex2DTest", pTextures[1]->GetDefaultView(TEXTURE_VIEW_SHADER_RESOURCE), 1), + ResourceMappingEntry("g_tex2DTest", pTextures[2]->GetDefaultView(TEXTURE_VIEW_SHADER_RESOURCE), 2), + ResourceMappingEntry("g_tex2DTest2", pTextures[5]->GetDefaultView(TEXTURE_VIEW_SHADER_RESOURCE), 0), + ResourceMappingEntry("g_tex2D", pTextures[6]->GetDefaultView(TEXTURE_VIEW_SHADER_RESOURCE), 0), + ResourceMappingEntry() + }; + // clang-format on + + ResourceMappingDesc ResMappingDesc; + ResMappingDesc.pEntries = ResMpEntries; + RefCntAutoPtr pResMapping; + pDevice->CreateResourceMapping(ResMappingDesc, &pResMapping); + + //pVS->BindResources(m_pResourceMapping, 0); + IDeviceObject* ppSRVs[] = {pTextures[3]->GetDefaultView(TEXTURE_VIEW_SHADER_RESOURCE)}; + pPSO->BindStaticResources(SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, pResMapping, BIND_SHADER_RESOURCES_KEEP_EXISTING); + pPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, "g_tex2DTest2")->SetArray(ppSRVs, 1, 1); + + pSRB->InitializeStaticResources(); + pSRB->BindResources(SHADER_TYPE_PIXEL, pResMapping, BIND_SHADER_RESOURCES_KEEP_EXISTING | BIND_SHADER_RESOURCES_UPDATE_MUTABLE | BIND_SHADER_RESOURCES_UPDATE_DYNAMIC); + ppSRVs[0] = pTextures[4]->GetDefaultView(TEXTURE_VIEW_SHADER_RESOURCE); + pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_tex2DTest")->SetArray(ppSRVs, 3, 1); + + ITextureView* pRTVs[] = {pRTV}; + pContext->SetRenderTargets(1, pRTVs, pDSV, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); + + pContext->SetPipelineState(pPSO); + ppSRVs[0] = {pTextures[7]->GetDefaultView(TEXTURE_VIEW_SHADER_RESOURCE)}; + pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_tex2D")->SetArray(ppSRVs, 1, 1); + + pContext->CommitShaderResources(pSRB, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); + + IBuffer* pBuffs[] = {pVertexBuff}; + Uint32 Offsets[] = {0}; + pContext->SetVertexBuffers(0, 1, pBuffs, Offsets, RESOURCE_STATE_TRANSITION_MODE_TRANSITION, SET_VERTEX_BUFFERS_FLAG_RESET); + + // Draw a quad + DrawAttribs DrawAttrs(4, DRAW_FLAG_VERIFY_ALL); + pContext->Draw(DrawAttrs); +} + +} // namespace diff --git a/Tests/DiligentCoreAPITest/src/ShaderResourceLayoutTest.cpp b/Tests/DiligentCoreAPITest/src/ShaderResourceLayoutTest.cpp new file mode 100644 index 00000000..76a6b71f --- /dev/null +++ b/Tests/DiligentCoreAPITest/src/ShaderResourceLayoutTest.cpp @@ -0,0 +1,1121 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ +#include +#include +#include +#include + +#include "TestingEnvironment.h" +#include "ShaderMacroHelper.h" +#include "GraphicsAccessories.h" + +#include "gtest/gtest.h" + +using namespace Diligent; +using namespace Diligent::Testing; + +namespace Diligent +{ +namespace Test +{ +void PrintShaderResources(IShader* pShader); +} +} // namespace Diligent + +namespace +{ + +class ShaderResourceLayoutTest : public ::testing::Test +{ +protected: + static void SetUpTestSuite() + { + auto* pEnv = TestingEnvironment::GetInstance(); + auto pRenderTarget = pEnv->CreateTexture("ShaderResourceLayoutTest: test RTV", TEX_FORMAT_RGBA8_UNORM, BIND_RENDER_TARGET, 512, 512); + ASSERT_NE(pRenderTarget, nullptr); + pRTV = pRenderTarget->GetDefaultView(TEXTURE_VIEW_RENDER_TARGET); + } + + static void TearDownTestSuite() + { + TestingEnvironment::GetInstance()->Reset(); + } + + static void VerifyShaderResources(IShader* pShader, + const ShaderResourceDesc ExpectedResources[], + Uint32 ExpectedResCount) + { + auto ResCount = pShader->GetResourceCount(); + EXPECT_EQ(ResCount, ExpectedResCount) << "Actual number of resources (" << ResCount << ") in shader '" + << pShader->GetDesc().Name << "' does not match the expected number of resources (" << ExpectedResCount << ')'; + std::unordered_map Resources; + for (Uint32 i = 0; i < ResCount; ++i) + { + const auto& ResDesc = pShader->GetResource(i); + Resources.emplace(ResDesc.Name, ResDesc); + } + + for (Uint32 i = 0; i < ExpectedResCount; ++i) + { + const auto& ExpectedRes = ExpectedResources[i]; + + auto it = Resources.find(ExpectedRes.Name); + if (it != Resources.end()) + { + EXPECT_EQ(it->second.Type, ExpectedRes.Type) << "Unexpected type of resource '" << ExpectedRes.Name << '\''; + EXPECT_EQ(it->second.ArraySize, ExpectedRes.ArraySize) << "Unexpected array size of resource '" << ExpectedRes.Name << '\''; + Resources.erase(it); + } + else + { + ADD_FAILURE() << "Unable to find resource '" << ExpectedRes.Name << "' in shader '" << pShader->GetDesc().Name << "'"; + } + } + + for (auto it : Resources) + { + ADD_FAILURE() << "Unexpected resource '" << it.second.Name << "' in shader '" << pShader->GetDesc().Name << "'"; + } + } + + template + static RefCntAutoPtr CreateShader(const char* ShaderName, + const char* FileName, + const char* EntryPoint, + SHADER_TYPE ShaderType, + SHADER_SOURCE_LANGUAGE SrcLang, + const ShaderMacro* Macros, + const ShaderResourceDesc* ExpectedResources, + Uint32 NumExpectedResources, + TModifyShaderCI ModifyShaderCI) + { + auto* pEnv = TestingEnvironment::GetInstance(); + auto* pDevice = pEnv->GetDevice(); + + RefCntAutoPtr pShaderSourceFactory; + pDevice->GetEngineFactory()->CreateDefaultShaderSourceStreamFactory("shaders/ShaderResourceLayout", &pShaderSourceFactory); + + ShaderCreateInfo ShaderCI; + ShaderCI.pShaderSourceStreamFactory = pShaderSourceFactory; + ShaderCI.UseCombinedTextureSamplers = pDevice->GetDeviceCaps().IsGLDevice(); + + ShaderCI.FilePath = FileName; + ShaderCI.Desc.Name = ShaderName; + ShaderCI.EntryPoint = EntryPoint; + ShaderCI.Desc.ShaderType = ShaderType; + ShaderCI.SourceLanguage = SrcLang; + ShaderCI.Macros = Macros; + + ModifyShaderCI(ShaderCI); + + RefCntAutoPtr pShader; + pDevice->CreateShader(ShaderCI, &pShader); + if (pShader) + { + VerifyShaderResources(pShader, ExpectedResources, NumExpectedResources); + Diligent::Test::PrintShaderResources(pShader); + } + + return pShader; + } + + static RefCntAutoPtr CreateShader(const char* ShaderName, + const char* FileName, + const char* EntryPoint, + SHADER_TYPE ShaderType, + SHADER_SOURCE_LANGUAGE SrcLang, + const ShaderMacro* Macros, + const ShaderResourceDesc* ExpectedResources, + Uint32 NumExpectedResources) + { + return CreateShader(ShaderName, + FileName, + EntryPoint, + ShaderType, + SrcLang, + Macros, + ExpectedResources, + NumExpectedResources, + [](const ShaderCreateInfo&) {}); + } + + + static void CreateGraphicsPSO(IShader* pVS, + IShader* pPS, + const PipelineResourceLayoutDesc& ResourceLayout, + RefCntAutoPtr& pPSO, + RefCntAutoPtr& pSRB) + { + PipelineStateDesc PSODesc; + + auto* pEnv = TestingEnvironment::GetInstance(); + auto* pDevice = pEnv->GetDevice(); + + PSODesc.ResourceLayout = ResourceLayout; + + PSODesc.Name = "Shader resource layout test"; + PSODesc.GraphicsPipeline.pVS = pVS; + PSODesc.GraphicsPipeline.pPS = pPS; + PSODesc.GraphicsPipeline.PrimitiveTopology = PRIMITIVE_TOPOLOGY_TRIANGLE_LIST; + PSODesc.GraphicsPipeline.NumRenderTargets = 1; + PSODesc.GraphicsPipeline.RTVFormats[0] = TEX_FORMAT_RGBA8_UNORM; + PSODesc.GraphicsPipeline.DSVFormat = TEX_FORMAT_UNKNOWN; + PSODesc.SRBAllocationGranularity = 16; + PSODesc.GraphicsPipeline.DepthStencilDesc.DepthEnable = False; + + pDevice->CreatePipelineState(PSODesc, &pPSO); + if (pPSO) + pPSO->CreateShaderResourceBinding(&pSRB, false); + } + + static RefCntAutoPtr CreateResourceBufferView(BUFFER_MODE BufferMode, BUFFER_VIEW_TYPE ViewType) + { + VERIFY_EXPR(ViewType == BUFFER_VIEW_SHADER_RESOURCE || ViewType == BUFFER_VIEW_UNORDERED_ACCESS); + + auto* pEnv = TestingEnvironment::GetInstance(); + auto* pDevice = pEnv->GetDevice(); + + BufferDesc BuffDesc; + BuffDesc.Name = "Formatted buffer"; + BuffDesc.uiSizeInBytes = 256; + BuffDesc.BindFlags = ViewType == BUFFER_VIEW_SHADER_RESOURCE ? BIND_SHADER_RESOURCE : BIND_UNORDERED_ACCESS; + BuffDesc.Usage = USAGE_DEFAULT; + BuffDesc.ElementByteStride = 16; + BuffDesc.Mode = BufferMode; + RefCntAutoPtr pBuffer; + RefCntAutoPtr pBufferView; + pDevice->CreateBuffer(BuffDesc, nullptr, &pBuffer); + if (!pBuffer) + { + ADD_FAILURE() << "Unable to create buffer " << BuffDesc; + return pBufferView; + } + + if (BufferMode == BUFFER_MODE_FORMATTED) + { + BufferViewDesc BuffViewDesc; + BuffViewDesc.Name = "Formatted buffer SRV"; + BuffViewDesc.ViewType = ViewType; + BuffViewDesc.Format.ValueType = VT_FLOAT32; + BuffViewDesc.Format.NumComponents = 4; + BuffViewDesc.Format.IsNormalized = false; + pBuffer->CreateView(BuffViewDesc, &pBufferView); + } + else + { + pBufferView = pBuffer->GetDefaultView(ViewType); + } + + return pBufferView; + } + + static void CreateComputePSO(IShader* pCS, + const PipelineResourceLayoutDesc& ResourceLayout, + RefCntAutoPtr& pPSO, + RefCntAutoPtr& pSRB) + { + PipelineStateDesc PSODesc; + + auto* pEnv = TestingEnvironment::GetInstance(); + auto* pDevice = pEnv->GetDevice(); + + PSODesc.Name = "Shader resource layout test"; + PSODesc.IsComputePipeline = true; + PSODesc.ResourceLayout = ResourceLayout; + PSODesc.ComputePipeline.pCS = pCS; + + pDevice->CreatePipelineState(PSODesc, &pPSO); + if (pPSO) + pPSO->CreateShaderResourceBinding(&pSRB, false); + } + + void TestTexturesAndStaticSamplers(bool TestStaticSamplers); + void TestStructuredOrFormattedBuffer(bool IsFormatted); + void TestRWStructuredOrFormattedBuffer(bool IsFormatted); + + static RefCntAutoPtr pRTV; +}; + +RefCntAutoPtr ShaderResourceLayoutTest::pRTV; + +#define SET_STATIC_VAR(PSO, ShaderFlags, VarName, SetMethod, ...) \ + do \ + { \ + auto pStaticVar = PSO->GetStaticVariableByName(ShaderFlags, VarName); \ + EXPECT_NE(pStaticVar, nullptr) << "Unable to find static variable '" << VarName << '\''; \ + if (pStaticVar != nullptr) \ + pStaticVar->SetMethod(__VA_ARGS__); \ + } while (false) + + +#define SET_SRB_VAR(SRB, ShaderFlags, VarName, SetMethod, ...) \ + do \ + { \ + auto pVar = SRB->GetVariableByName(ShaderFlags, VarName); \ + EXPECT_NE(pVar, nullptr) << "Unable to find SRB variable '" << VarName << '\''; \ + if (pVar != nullptr) \ + pVar->SetMethod(__VA_ARGS__); \ + } while (false) + + +void ShaderResourceLayoutTest::TestTexturesAndStaticSamplers(bool TestStaticSamplers) +{ + TestingEnvironment::ScopedReset AutoResetEnvironment; + + auto* pEnv = TestingEnvironment::GetInstance(); + auto* pDevice = pEnv->GetDevice(); + + static constexpr Uint32 StaticTexArraySize = 2; + static constexpr Uint32 MutableTexArraySize = 4; + static constexpr Uint32 DynamicTexArraySize = 3; + ShaderMacroHelper Macros; + Macros.AddShaderMacro("STATIC_TEX_ARRAY_SIZE", static_cast(StaticTexArraySize)); + Macros.AddShaderMacro("MUTABLE_TEX_ARRAY_SIZE", static_cast(MutableTexArraySize)); + Macros.AddShaderMacro("DYNAMIC_TEX_ARRAY_SIZE", static_cast(DynamicTexArraySize)); + + // clang-format off + std::vector Resources = + { + ShaderResourceDesc{"g_Tex2D_Static", SHADER_RESOURCE_TYPE_TEXTURE_SRV, 1}, + ShaderResourceDesc{"g_Tex2D_Mut", SHADER_RESOURCE_TYPE_TEXTURE_SRV, 1}, + ShaderResourceDesc{"g_Tex2D_Dyn", SHADER_RESOURCE_TYPE_TEXTURE_SRV, 1}, + ShaderResourceDesc{"g_Tex2DArr_Static", SHADER_RESOURCE_TYPE_TEXTURE_SRV, StaticTexArraySize}, + ShaderResourceDesc{"g_Tex2DArr_Mut", SHADER_RESOURCE_TYPE_TEXTURE_SRV, MutableTexArraySize}, + ShaderResourceDesc{"g_Tex2DArr_Dyn", SHADER_RESOURCE_TYPE_TEXTURE_SRV, DynamicTexArraySize} + }; + if (!pDevice->GetDeviceCaps().IsGLDevice()) + { + if (TestStaticSamplers) + { + Resources.emplace_back("g_Tex2D_Static_sampler", SHADER_RESOURCE_TYPE_SAMPLER, 1); + Resources.emplace_back("g_Tex2D_Mut_sampler", SHADER_RESOURCE_TYPE_SAMPLER, 1); + Resources.emplace_back("g_Tex2D_Dyn_sampler", SHADER_RESOURCE_TYPE_SAMPLER, 1); + Resources.emplace_back("g_Tex2DArr_Static_sampler", SHADER_RESOURCE_TYPE_SAMPLER, 1); + Resources.emplace_back("g_Tex2DArr_Mut_sampler", SHADER_RESOURCE_TYPE_SAMPLER, MutableTexArraySize); + Resources.emplace_back("g_Tex2DArr_Dyn_sampler", SHADER_RESOURCE_TYPE_SAMPLER, DynamicTexArraySize); + } + else + { + Resources.emplace_back("g_Sampler", SHADER_RESOURCE_TYPE_SAMPLER, 1); + } + } + // clang-format on + + auto ModifyShaderCI = [TestStaticSamplers](ShaderCreateInfo& ShaderCI) { + if (TestStaticSamplers) + { + ShaderCI.UseCombinedTextureSamplers = true; + ShaderCI.HLSLVersion = ShaderCreateInfo::ShaderVersion{5, 0}; + } + }; + auto pVS = CreateShader(TestStaticSamplers ? "ShaderResourceLayoutTest.StaticSamplers - VS" : "ShaderResourceLayoutTest.Textures - VS", + TestStaticSamplers ? "StaticSamplers.hlsl" : "Textures.hlsl", + "VSMain", + SHADER_TYPE_VERTEX, SHADER_SOURCE_LANGUAGE_HLSL, Macros, + Resources.data(), static_cast(Resources.size()), + ModifyShaderCI); + auto pPS = CreateShader(TestStaticSamplers ? "ShaderResourceLayoutTest.StaticSamplers - PS" : "ShaderResourceLayoutTest.Textures - PS", + TestStaticSamplers ? "StaticSamplers.hlsl" : "Textures.hlsl", + "PSMain", + SHADER_TYPE_PIXEL, SHADER_SOURCE_LANGUAGE_HLSL, Macros, + Resources.data(), static_cast(Resources.size()), + ModifyShaderCI); + ASSERT_NE(pVS, nullptr); + ASSERT_NE(pPS, nullptr); + + + // clang-format off + ShaderResourceVariableDesc Vars[] = + { + {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_Tex2D_Static", SHADER_RESOURCE_VARIABLE_TYPE_STATIC}, + {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_Tex2D_Mut", SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE}, + {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_Tex2D_Dyn", SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC}, + + {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_Tex2DArr_Static", SHADER_RESOURCE_VARIABLE_TYPE_STATIC}, + {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_Tex2DArr_Mut", SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE}, + {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_Tex2DArr_Dyn", SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC} + }; + std::vector StaticSamplers; + if (TestStaticSamplers) + { + StaticSamplers.emplace_back(SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_Tex2D_Static", SamplerDesc{}); + StaticSamplers.emplace_back(SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_Tex2D_Mut", SamplerDesc{}); + StaticSamplers.emplace_back(SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_Tex2D_Dyn", SamplerDesc{}); + StaticSamplers.emplace_back(SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_Tex2DArr_Static", SamplerDesc{}); + StaticSamplers.emplace_back(SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_Tex2DArr_Mut", SamplerDesc{}); + StaticSamplers.emplace_back(SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_Tex2DArr_Dyn", SamplerDesc{}); + } + else + { + StaticSamplers.emplace_back(SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_Sampler", SamplerDesc{}); + } + // clang-format on + + PipelineResourceLayoutDesc ResourceLayout; + ResourceLayout.Variables = Vars; + ResourceLayout.NumVariables = _countof(Vars); + ResourceLayout.StaticSamplers = StaticSamplers.data(); + ResourceLayout.NumStaticSamplers = static_cast(StaticSamplers.size()); + + RefCntAutoPtr pPSO; + RefCntAutoPtr pSRB; + CreateGraphicsPSO(pVS, pPS, ResourceLayout, pPSO, pSRB); + ASSERT_NE(pPSO, nullptr); + ASSERT_NE(pSRB, nullptr); + + constexpr auto MaxTextures = std::max(std::max(StaticTexArraySize, MutableTexArraySize), DynamicTexArraySize); + + std::array, MaxTextures> pTextures; + std::array pTexSRVs = {}; + + for (Uint32 i = 0; i < MaxTextures; ++i) + { + pTextures[i] = pEnv->CreateTexture("Test texture", TEX_FORMAT_RGBA8_UNORM, BIND_SHADER_RESOURCE, 256, 256); + pTexSRVs[i] = pTextures[i]->GetDefaultView(TEXTURE_VIEW_SHADER_RESOURCE); + } + + SET_STATIC_VAR(pPSO, SHADER_TYPE_VERTEX, "g_Tex2D_Static", Set, pTexSRVs[0]); + SET_STATIC_VAR(pPSO, SHADER_TYPE_VERTEX, "g_Tex2DArr_Static", SetArray, pTexSRVs.data(), 0, StaticTexArraySize); + + SET_STATIC_VAR(pPSO, SHADER_TYPE_PIXEL, "g_Tex2D_Static", Set, pTexSRVs[0]); + SET_STATIC_VAR(pPSO, SHADER_TYPE_PIXEL, "g_Tex2DArr_Static", SetArray, pTexSRVs.data(), 0, StaticTexArraySize); + + SET_SRB_VAR(pSRB, SHADER_TYPE_VERTEX, "g_Tex2D_Mut", Set, pTexSRVs[0]); + SET_SRB_VAR(pSRB, SHADER_TYPE_VERTEX, "g_Tex2D_Dyn", Set, pTexSRVs[0]); + SET_SRB_VAR(pSRB, SHADER_TYPE_VERTEX, "g_Tex2DArr_Mut", SetArray, pTexSRVs.data(), 0, MutableTexArraySize); + SET_SRB_VAR(pSRB, SHADER_TYPE_VERTEX, "g_Tex2DArr_Dyn", SetArray, pTexSRVs.data(), 0, DynamicTexArraySize); + + SET_SRB_VAR(pSRB, SHADER_TYPE_PIXEL, "g_Tex2D_Mut", Set, pTexSRVs[0]); + SET_SRB_VAR(pSRB, SHADER_TYPE_PIXEL, "g_Tex2D_Dyn", Set, pTexSRVs[0]); + SET_SRB_VAR(pSRB, SHADER_TYPE_PIXEL, "g_Tex2DArr_Mut", SetArray, pTexSRVs.data(), 0, MutableTexArraySize); + SET_SRB_VAR(pSRB, SHADER_TYPE_PIXEL, "g_Tex2DArr_Dyn", SetArray, pTexSRVs.data(), 0, DynamicTexArraySize); + + pSRB->InitializeStaticResources(pPSO); + + auto* pContext = pEnv->GetDeviceContext(); + + ITextureView* ppRTVs[] = {pRTV}; + pContext->SetRenderTargets(1, ppRTVs, nullptr, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); + + pContext->SetPipelineState(pPSO); + pContext->CommitShaderResources(pSRB, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); + + DrawAttribs DrawAttrs(3, DRAW_FLAG_VERIFY_ALL); + pContext->Draw(DrawAttrs); + + SET_SRB_VAR(pSRB, SHADER_TYPE_VERTEX, "g_Tex2D_Dyn", Set, pTexSRVs[1]); + SET_SRB_VAR(pSRB, SHADER_TYPE_VERTEX, "g_Tex2DArr_Dyn", SetArray, pTexSRVs.data(), 1, DynamicTexArraySize - 1); + + SET_SRB_VAR(pSRB, SHADER_TYPE_PIXEL, "g_Tex2D_Dyn", Set, pTexSRVs[1]); + SET_SRB_VAR(pSRB, SHADER_TYPE_PIXEL, "g_Tex2DArr_Dyn", SetArray, pTexSRVs.data(), 1, DynamicTexArraySize - 1); + + pContext->Draw(DrawAttrs); +} + +TEST_F(ShaderResourceLayoutTest, Textures) +{ + TestTexturesAndStaticSamplers(false); +} + +TEST_F(ShaderResourceLayoutTest, StaticSamplers) +{ + TestTexturesAndStaticSamplers(true); +} + + +void ShaderResourceLayoutTest::TestStructuredOrFormattedBuffer(bool IsFormatted) +{ + TestingEnvironment::ScopedReset AutoResetEnvironment; + + static constexpr int StaticBuffArraySize = 4; + static constexpr int MutableBuffArraySize = 3; + static constexpr int DynamicBuffArraySize = 2; + ShaderMacroHelper Macros; + Macros.AddShaderMacro("STATIC_BUFF_ARRAY_SIZE", StaticBuffArraySize); + Macros.AddShaderMacro("MUTABLE_BUFF_ARRAY_SIZE", MutableBuffArraySize); + Macros.AddShaderMacro("DYNAMIC_BUFF_ARRAY_SIZE", DynamicBuffArraySize); + + auto* pEnv = TestingEnvironment::GetInstance(); + auto* pDevice = pEnv->GetDevice(); + + // Vulkan only allows 16 dynamic storage buffer bindings among all stages, so + // use arrays only in fragment shader for structured buffer test. + const auto UseArraysInPSOnly = !IsFormatted && pDevice->GetDeviceCaps().IsVulkanDevice(); + + // clang-format off + std::vector Resources = + { + {"g_Buff_Static", SHADER_RESOURCE_TYPE_BUFFER_SRV, 1}, + {"g_Buff_Mut", SHADER_RESOURCE_TYPE_BUFFER_SRV, 1}, + {"g_Buff_Dyn", SHADER_RESOURCE_TYPE_BUFFER_SRV, 1} + }; + + auto AddArrayResources = [&Resources]() + { + Resources.emplace_back("g_BuffArr_Static", SHADER_RESOURCE_TYPE_BUFFER_SRV, StaticBuffArraySize); + Resources.emplace_back("g_BuffArr_Mut", SHADER_RESOURCE_TYPE_BUFFER_SRV, MutableBuffArraySize); + Resources.emplace_back("g_BuffArr_Dyn", SHADER_RESOURCE_TYPE_BUFFER_SRV, DynamicBuffArraySize); + }; + // clang-format on + if (!UseArraysInPSOnly) + { + AddArrayResources(); + } + + const char* ShaderFileName = nullptr; + SHADER_SOURCE_LANGUAGE SrcLang = SHADER_SOURCE_LANGUAGE_DEFAULT; + if (pDevice->GetDeviceCaps().IsD3DDevice()) + { + ShaderFileName = IsFormatted ? "FormattedBuffers.hlsl" : "StructuredBuffers.hlsl"; + SrcLang = SHADER_SOURCE_LANGUAGE_HLSL; + } + else if (pDevice->GetDeviceCaps().IsVulkanDevice() || pDevice->GetDeviceCaps().IsGLDevice()) + { + ShaderFileName = IsFormatted ? "FormattedBuffers.hlsl" : "StructuredBuffers.glsl"; + SrcLang = IsFormatted ? SHADER_SOURCE_LANGUAGE_HLSL : SHADER_SOURCE_LANGUAGE_GLSL; + } + else + { + GTEST_FAIL() << "Unexpected device type"; + } + auto pVS = CreateShader(IsFormatted ? "ShaderResourceLayoutTest.FormattedBuffers - VS" : "ShaderResourceLayoutTest.StructuredBuffers - VS", + ShaderFileName, "VSMain", + SHADER_TYPE_VERTEX, SrcLang, Macros, + Resources.data(), static_cast(Resources.size())); + if (UseArraysInPSOnly) + { + AddArrayResources(); + } + auto pPS = CreateShader(IsFormatted ? "ShaderResourceLayoutTest.FormattedBuffers - PS" : "ShaderResourceLayoutTest.StructuredBuffers - PS", + ShaderFileName, "PSMain", + SHADER_TYPE_PIXEL, SrcLang, Macros, + Resources.data(), static_cast(Resources.size())); + ASSERT_NE(pVS, nullptr); + ASSERT_NE(pPS, nullptr); + + + // clang-format off + ShaderResourceVariableDesc Vars[] = + { + {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_Buff_Static", SHADER_RESOURCE_VARIABLE_TYPE_STATIC}, + {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_Buff_Mut", SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE}, + {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_Buff_Dyn", SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC}, + + {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_BuffArr_Static", SHADER_RESOURCE_VARIABLE_TYPE_STATIC}, + {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_BuffArr_Mut", SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE}, + {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_BuffArr_Dyn", SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC} + }; + // clang-format on + + PipelineResourceLayoutDesc ResourceLayout; + ResourceLayout.Variables = Vars; + ResourceLayout.NumVariables = _countof(Vars); + + RefCntAutoPtr pPSO; + RefCntAutoPtr pSRB; + + CreateGraphicsPSO(pVS, pPS, ResourceLayout, pPSO, pSRB); + ASSERT_NE(pPSO, nullptr); + ASSERT_NE(pSRB, nullptr); + + constexpr auto MaxBuffers = std::max(std::max(StaticBuffArraySize, MutableBuffArraySize), DynamicBuffArraySize); + + std::array, MaxBuffers> pBufferViews; + std::array pBuffSRVs = {}; + + for (Uint32 i = 0; i < MaxBuffers; ++i) + { + pBufferViews[i] = CreateResourceBufferView(IsFormatted ? BUFFER_MODE_FORMATTED : BUFFER_MODE_STRUCTURED, BUFFER_VIEW_SHADER_RESOURCE); + ASSERT_NE(pBufferViews[i], nullptr) << "Unable to formatted buffer view "; + pBuffSRVs[i] = pBufferViews[i]; + } + + SET_STATIC_VAR(pPSO, SHADER_TYPE_VERTEX, "g_Buff_Static", Set, pBuffSRVs[0]); + if (!UseArraysInPSOnly) + { + SET_STATIC_VAR(pPSO, SHADER_TYPE_VERTEX, "g_BuffArr_Static", SetArray, pBuffSRVs.data(), 0, StaticBuffArraySize); + } + else + { + EXPECT_EQ(pPSO->GetStaticVariableByName(SHADER_TYPE_VERTEX, "g_BuffArr_Static"), nullptr); + } + SET_STATIC_VAR(pPSO, SHADER_TYPE_PIXEL, "g_Buff_Static", Set, pBuffSRVs[0]); + SET_STATIC_VAR(pPSO, SHADER_TYPE_PIXEL, "g_BuffArr_Static", SetArray, pBuffSRVs.data(), 0, StaticBuffArraySize); + + + SET_SRB_VAR(pSRB, SHADER_TYPE_VERTEX, "g_Buff_Mut", Set, pBuffSRVs[0]); + SET_SRB_VAR(pSRB, SHADER_TYPE_VERTEX, "g_Buff_Dyn", Set, pBuffSRVs[0]); + if (!UseArraysInPSOnly) + { + SET_SRB_VAR(pSRB, SHADER_TYPE_VERTEX, "g_BuffArr_Mut", SetArray, pBuffSRVs.data(), 0, MutableBuffArraySize); + SET_SRB_VAR(pSRB, SHADER_TYPE_VERTEX, "g_BuffArr_Dyn", SetArray, pBuffSRVs.data(), 0, DynamicBuffArraySize); + } + else + { + EXPECT_EQ(pSRB->GetVariableByName(SHADER_TYPE_VERTEX, "g_BuffArr_Mut"), nullptr); + EXPECT_EQ(pSRB->GetVariableByName(SHADER_TYPE_VERTEX, "g_BuffArr_Dyn"), nullptr); + } + + SET_SRB_VAR(pSRB, SHADER_TYPE_PIXEL, "g_Buff_Mut", Set, pBuffSRVs[0]); + SET_SRB_VAR(pSRB, SHADER_TYPE_PIXEL, "g_Buff_Dyn", Set, pBuffSRVs[0]); + SET_SRB_VAR(pSRB, SHADER_TYPE_PIXEL, "g_BuffArr_Mut", SetArray, pBuffSRVs.data(), 0, MutableBuffArraySize); + SET_SRB_VAR(pSRB, SHADER_TYPE_PIXEL, "g_BuffArr_Dyn", SetArray, pBuffSRVs.data(), 0, DynamicBuffArraySize); + + pSRB->InitializeStaticResources(pPSO); + + auto* pContext = pEnv->GetDeviceContext(); + + ITextureView* ppRTVs[] = {pRTV}; + pContext->SetRenderTargets(1, ppRTVs, nullptr, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); + + pContext->SetPipelineState(pPSO); + pContext->CommitShaderResources(pSRB, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); + + DrawAttribs DrawAttrs(3, DRAW_FLAG_VERIFY_ALL); + pContext->Draw(DrawAttrs); + + SET_SRB_VAR(pSRB, SHADER_TYPE_VERTEX, "g_Buff_Dyn", Set, pBuffSRVs[1]); + if (!UseArraysInPSOnly) + { + SET_SRB_VAR(pSRB, SHADER_TYPE_VERTEX, "g_BuffArr_Dyn", SetArray, pBuffSRVs.data(), 1, DynamicBuffArraySize - 1); + } + + SET_SRB_VAR(pSRB, SHADER_TYPE_PIXEL, "g_Buff_Dyn", Set, pBuffSRVs[1]); + SET_SRB_VAR(pSRB, SHADER_TYPE_PIXEL, "g_BuffArr_Dyn", SetArray, pBuffSRVs.data(), 1, DynamicBuffArraySize - 1); + + pContext->Draw(DrawAttrs); +} + +TEST_F(ShaderResourceLayoutTest, FormattedBuffers) +{ + TestStructuredOrFormattedBuffer(true /*IsFormatted*/); +} + +TEST_F(ShaderResourceLayoutTest, StructuredBuffers) +{ + auto* pEnv = TestingEnvironment::GetInstance(); + auto* pDevice = pEnv->GetDevice(); + if (pDevice->GetDeviceCaps().IsGLDevice()) + { + GTEST_SKIP() << "Read-only structured buffers in glsl are currently " + "identified as UAVs in OpenGL backend because " + "there seems to be no way to detect read-only property on the host"; + } + + TestStructuredOrFormattedBuffer(false /*IsFormatted*/); +} + + +void ShaderResourceLayoutTest::TestRWStructuredOrFormattedBuffer(bool IsFormatted) +{ + TestingEnvironment::ScopedReset AutoResetEnvironment; + + auto* pEnv = TestingEnvironment::GetInstance(); + auto* pDevice = pEnv->GetDevice(); + + const auto& deviceCaps = pDevice->GetDeviceCaps(); + auto deviceType = deviceCaps.DevType; + + const Uint32 StaticBuffArraySize = deviceType == DeviceType::D3D11 || deviceCaps.IsGLDevice() ? 1 : 4; + const Uint32 MutableBuffArraySize = deviceType == DeviceType::D3D11 || deviceCaps.IsGLDevice() ? 2 : 3; + const Uint32 DynamicBuffArraySize = 2; + + ShaderMacroHelper Macros; + Macros.AddShaderMacro("STATIC_BUFF_ARRAY_SIZE", static_cast(StaticBuffArraySize)); + Macros.AddShaderMacro("MUTABLE_BUFF_ARRAY_SIZE", static_cast(MutableBuffArraySize)); + Macros.AddShaderMacro("DYNAMIC_BUFF_ARRAY_SIZE", static_cast(DynamicBuffArraySize)); + + // clang-format off + ShaderResourceDesc Resources[] = + { + {"g_RWBuff_Static", SHADER_RESOURCE_TYPE_BUFFER_UAV, 1}, + {"g_RWBuff_Mut", SHADER_RESOURCE_TYPE_BUFFER_UAV, 1}, + {"g_RWBuff_Dyn", SHADER_RESOURCE_TYPE_BUFFER_UAV, 1}, + {"g_RWBuffArr_Static", SHADER_RESOURCE_TYPE_BUFFER_UAV, StaticBuffArraySize }, + {"g_RWBuffArr_Mut", SHADER_RESOURCE_TYPE_BUFFER_UAV, MutableBuffArraySize}, + {"g_RWBuffArr_Dyn", SHADER_RESOURCE_TYPE_BUFFER_UAV, DynamicBuffArraySize} + }; + + const char* ShaderFileName = nullptr; + SHADER_SOURCE_LANGUAGE SrcLang = SHADER_SOURCE_LANGUAGE_DEFAULT; + if (pDevice->GetDeviceCaps().IsD3DDevice()) + { + ShaderFileName = IsFormatted ? "RWFormattedBuffers.hlsl" : "RWStructuredBuffers.hlsl"; + SrcLang = SHADER_SOURCE_LANGUAGE_HLSL; + } + else if (pDevice->GetDeviceCaps().IsVulkanDevice() || pDevice->GetDeviceCaps().IsGLDevice()) + { + ShaderFileName = IsFormatted ? "RWFormattedBuffers.hlsl" : "RWStructuredBuffers.glsl"; + SrcLang = IsFormatted ? SHADER_SOURCE_LANGUAGE_HLSL : SHADER_SOURCE_LANGUAGE_GLSL; + } + else + { + GTEST_FAIL() << "Unexpected device type"; + } + auto pCS = CreateShader(IsFormatted ? "ShaderResourceLayoutTest.RWFormattedBuffers - CS" : "ShaderResourceLayoutTest.RWtructuredBuffers - CS", + ShaderFileName, "main", + SHADER_TYPE_COMPUTE, SrcLang, Macros, + Resources, _countof(Resources)); + ASSERT_NE(pCS, nullptr); + + // clang-format off + ShaderResourceVariableDesc Vars[] = + { + {SHADER_TYPE_COMPUTE, "g_RWBuff_Static", SHADER_RESOURCE_VARIABLE_TYPE_STATIC}, + {SHADER_TYPE_COMPUTE, "g_RWBuff_Mut", SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE}, + {SHADER_TYPE_COMPUTE, "g_RWBuff_Dyn", SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC}, + + {SHADER_TYPE_COMPUTE, "g_RWBuffArr_Static", SHADER_RESOURCE_VARIABLE_TYPE_STATIC}, + {SHADER_TYPE_COMPUTE, "g_RWBuffArr_Mut", SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE}, + {SHADER_TYPE_COMPUTE, "g_RWBuffArr_Dyn", SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC} + }; + // clang-format on + + PipelineResourceLayoutDesc ResourceLayout; + ResourceLayout.Variables = Vars; + ResourceLayout.NumVariables = _countof(Vars); + + RefCntAutoPtr pPSO; + RefCntAutoPtr pSRB; + + CreateComputePSO(pCS, ResourceLayout, pPSO, pSRB); + ASSERT_NE(pPSO, nullptr); + ASSERT_NE(pSRB, nullptr); + + const auto TotalBuffers = StaticBuffArraySize + MutableBuffArraySize + DynamicBuffArraySize + 3 + 2; + + std::vector> pBufferViews(TotalBuffers); + std::vector pBuffUAVs(TotalBuffers); + + for (Uint32 i = 0; i < TotalBuffers; ++i) + { + pBufferViews[i] = CreateResourceBufferView(IsFormatted ? BUFFER_MODE_FORMATTED : BUFFER_MODE_STRUCTURED, BUFFER_VIEW_UNORDERED_ACCESS); + ASSERT_NE(pBufferViews[i], nullptr) << "Unable to formatted buffer view "; + pBuffUAVs[i] = pBufferViews[i]; + } + + Uint32 uav = 0; + SET_STATIC_VAR(pPSO, SHADER_TYPE_COMPUTE, "g_RWBuff_Static", Set, pBuffUAVs[uav++]); + SET_STATIC_VAR(pPSO, SHADER_TYPE_COMPUTE, "g_RWBuffArr_Static", SetArray, &pBuffUAVs[uav], 0, StaticBuffArraySize); + uav += StaticBuffArraySize; + + SET_SRB_VAR(pSRB, SHADER_TYPE_COMPUTE, "g_RWBuff_Mut", Set, pBuffUAVs[uav++]); + SET_SRB_VAR(pSRB, SHADER_TYPE_COMPUTE, "g_RWBuff_Dyn", Set, pBuffUAVs[uav++]); + SET_SRB_VAR(pSRB, SHADER_TYPE_COMPUTE, "g_RWBuffArr_Mut", SetArray, &pBuffUAVs[uav], 0, MutableBuffArraySize); + uav += MutableBuffArraySize; + SET_SRB_VAR(pSRB, SHADER_TYPE_COMPUTE, "g_RWBuffArr_Dyn", SetArray, &pBuffUAVs[uav], 0, DynamicBuffArraySize); + uav += DynamicBuffArraySize; + VERIFY_EXPR(uav + 2 == pBuffUAVs.size()); + + pSRB->InitializeStaticResources(pPSO); + + auto* pContext = pEnv->GetDeviceContext(); + + pContext->SetPipelineState(pPSO); + pContext->CommitShaderResources(pSRB, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); + + DispatchComputeAttribs DispatchAttribs(1, 1, 1); + pContext->DispatchCompute(DispatchAttribs); + + SET_SRB_VAR(pSRB, SHADER_TYPE_COMPUTE, "g_RWBuff_Dyn", Set, pBuffUAVs[uav++]); + SET_SRB_VAR(pSRB, SHADER_TYPE_COMPUTE, "g_RWBuffArr_Dyn", SetArray, &pBuffUAVs[uav++], 1, 1); + pContext->DispatchCompute(DispatchAttribs); +} + +TEST_F(ShaderResourceLayoutTest, FormattedRWBuffers) +{ + TestRWStructuredOrFormattedBuffer(true /*IsFormatted*/); +} + +TEST_F(ShaderResourceLayoutTest, StructuredRWBuffers) +{ + TestRWStructuredOrFormattedBuffer(false /*IsFormatted*/); +} + +TEST_F(ShaderResourceLayoutTest, RWTextures) +{ + TestingEnvironment::ScopedReset AutoResetEnvironment; + + auto* pEnv = TestingEnvironment::GetInstance(); + auto* pDevice = pEnv->GetDevice(); + + const auto& deviceCaps = pDevice->GetDeviceCaps(); + auto deviceType = deviceCaps.DevType; + + const Uint32 StaticTexArraySize = 2; + const Uint32 MutableTexArraySize = deviceType == DeviceType::D3D11 || deviceCaps.IsGLDevice() ? 2 : 4; + const Uint32 DynamicTexArraySize = deviceType == DeviceType::D3D11 || deviceCaps.IsGLDevice() ? 1 : 3; + + ShaderMacroHelper Macros; + Macros.AddShaderMacro("STATIC_TEX_ARRAY_SIZE", static_cast(StaticTexArraySize)); + Macros.AddShaderMacro("MUTABLE_TEX_ARRAY_SIZE", static_cast(MutableTexArraySize)); + Macros.AddShaderMacro("DYNAMIC_TEX_ARRAY_SIZE", static_cast(DynamicTexArraySize)); + + // clang-format off + ShaderResourceDesc Resources[] = + { + {"g_RWTex2D_Static", SHADER_RESOURCE_TYPE_TEXTURE_UAV, 1}, + {"g_RWTex2D_Mut", SHADER_RESOURCE_TYPE_TEXTURE_UAV, 1}, + {"g_RWTex2D_Dyn", SHADER_RESOURCE_TYPE_TEXTURE_UAV, 1}, + {"g_RWTex2DArr_Static", SHADER_RESOURCE_TYPE_TEXTURE_UAV, StaticTexArraySize }, + {"g_RWTex2DArr_Mut", SHADER_RESOURCE_TYPE_TEXTURE_UAV, MutableTexArraySize}, + {"g_RWTex2DArr_Dyn", SHADER_RESOURCE_TYPE_TEXTURE_UAV, DynamicTexArraySize} + }; + + auto pCS = CreateShader("ShaderResourceLayoutTest.RWTextures - CS", + "RWTextures.hlsl", "main", + SHADER_TYPE_COMPUTE, SHADER_SOURCE_LANGUAGE_HLSL, Macros, + Resources, _countof(Resources)); + ASSERT_NE(pCS, nullptr); + + // clang-format off + ShaderResourceVariableDesc Vars[] = + { + {SHADER_TYPE_COMPUTE, "g_RWTex2D_Static", SHADER_RESOURCE_VARIABLE_TYPE_STATIC}, + {SHADER_TYPE_COMPUTE, "g_RWTex2D_Mut", SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE}, + {SHADER_TYPE_COMPUTE, "g_RWTex2D_Dyn", SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC}, + + {SHADER_TYPE_COMPUTE, "g_RWTex2DArr_Static", SHADER_RESOURCE_VARIABLE_TYPE_STATIC}, + {SHADER_TYPE_COMPUTE, "g_RWTex2DArr_Mut", SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE}, + {SHADER_TYPE_COMPUTE, "g_RWTex2DArr_Dyn", SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC} + }; + // clang-format on + + PipelineResourceLayoutDesc ResourceLayout; + ResourceLayout.Variables = Vars; + ResourceLayout.NumVariables = _countof(Vars); + + RefCntAutoPtr pPSO; + RefCntAutoPtr pSRB; + + CreateComputePSO(pCS, ResourceLayout, pPSO, pSRB); + ASSERT_NE(pPSO, nullptr); + ASSERT_NE(pSRB, nullptr); + + const auto TotalTextures = StaticTexArraySize + MutableTexArraySize + DynamicTexArraySize + 3 + 2; + + std::vector> pTextures(TotalTextures); + std::vector pUAVs(TotalTextures); + + for (Uint32 i = 0; i < TotalTextures; ++i) + { + pTextures[i] = pEnv->CreateTexture("Test RW texture", TEX_FORMAT_RGBA32_FLOAT, BIND_UNORDERED_ACCESS, 256, 256); + ASSERT_NE(pTextures[i], nullptr); + pUAVs[i] = pTextures[i]->GetDefaultView(TEXTURE_VIEW_UNORDERED_ACCESS); + ASSERT_NE(pUAVs[i], nullptr); + } + + Uint32 uav = 0; + SET_STATIC_VAR(pPSO, SHADER_TYPE_COMPUTE, "g_RWTex2D_Static", Set, pUAVs[uav++]); + SET_STATIC_VAR(pPSO, SHADER_TYPE_COMPUTE, "g_RWTex2DArr_Static", SetArray, &pUAVs[uav], 0, StaticTexArraySize); + uav += StaticTexArraySize; + + SET_SRB_VAR(pSRB, SHADER_TYPE_COMPUTE, "g_RWTex2D_Mut", Set, pUAVs[uav++]); + SET_SRB_VAR(pSRB, SHADER_TYPE_COMPUTE, "g_RWTex2D_Dyn", Set, pUAVs[uav++]); + SET_SRB_VAR(pSRB, SHADER_TYPE_COMPUTE, "g_RWTex2DArr_Mut", SetArray, &pUAVs[uav], 0, MutableTexArraySize); + uav += MutableTexArraySize; + SET_SRB_VAR(pSRB, SHADER_TYPE_COMPUTE, "g_RWTex2DArr_Dyn", SetArray, &pUAVs[uav], 0, DynamicTexArraySize); + uav += DynamicTexArraySize; + VERIFY_EXPR(uav + 2 == pUAVs.size()); + + pSRB->InitializeStaticResources(pPSO); + + auto* pContext = pEnv->GetDeviceContext(); + + pContext->SetPipelineState(pPSO); + pContext->CommitShaderResources(pSRB, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); + + DispatchComputeAttribs DispatchAttribs(1, 1, 1); + pContext->DispatchCompute(DispatchAttribs); + + SET_SRB_VAR(pSRB, SHADER_TYPE_COMPUTE, "g_RWTex2D_Dyn", Set, pUAVs[uav++]); + SET_SRB_VAR(pSRB, SHADER_TYPE_COMPUTE, "g_RWTex2DArr_Dyn", SetArray, &pUAVs[uav++], 0, 1); + pContext->DispatchCompute(DispatchAttribs); +} + +TEST_F(ShaderResourceLayoutTest, ConstantBuffers) +{ + TestingEnvironment::ScopedReset AutoResetEnvironment; + + auto* pEnv = TestingEnvironment::GetInstance(); + auto* pDevice = pEnv->GetDevice(); + + const auto deviceCaps = pDevice->GetDeviceCaps(); + // Vulkan allows 15 dynamic uniform buffer bindings among all stages + const Uint32 StaticCBArraySize = 2; + const Uint32 MutableCBArraySize = deviceCaps.IsVulkanDevice() ? 1 : 4; + const Uint32 DynamicCBArraySize = deviceCaps.IsVulkanDevice() ? 1 : 3; + + ShaderMacroHelper Macros; + Macros.AddShaderMacro("STATIC_CB_ARRAY_SIZE", static_cast(StaticCBArraySize)); + Macros.AddShaderMacro("MUTABLE_CB_ARRAY_SIZE", static_cast(MutableCBArraySize)); + Macros.AddShaderMacro("DYNAMIC_CB_ARRAY_SIZE", static_cast(DynamicCBArraySize)); + + const auto CBArraysSupported = deviceCaps.DevType == DeviceType::D3D12 || deviceCaps.IsVulkanDevice(); + Macros.AddShaderMacro("ARRAYS_SUPPORTED", CBArraysSupported); + + // clang-format off + std::vector Resources = + { + ShaderResourceDesc{"UniformBuff_Stat", SHADER_RESOURCE_TYPE_CONSTANT_BUFFER, 1}, + ShaderResourceDesc{"UniformBuff_Mut", SHADER_RESOURCE_TYPE_CONSTANT_BUFFER, 1}, + ShaderResourceDesc{"UniformBuff_Dyn", SHADER_RESOURCE_TYPE_CONSTANT_BUFFER, 1} + }; + + if (CBArraysSupported) + { + Resources.emplace_back("UniformBuffArr_Stat", SHADER_RESOURCE_TYPE_CONSTANT_BUFFER, StaticCBArraySize); + Resources.emplace_back("UniformBuffArr_Mut", SHADER_RESOURCE_TYPE_CONSTANT_BUFFER, MutableCBArraySize); + Resources.emplace_back("UniformBuffArr_Dyn", SHADER_RESOURCE_TYPE_CONSTANT_BUFFER, DynamicCBArraySize); + } + // clang-format on + + auto pVS = CreateShader("ShaderResourceLayoutTest.ConstantBuffers - VS", + "ConstantBuffers.hlsl", + "VSMain", + SHADER_TYPE_VERTEX, SHADER_SOURCE_LANGUAGE_HLSL, Macros, + Resources.data(), static_cast(Resources.size())); + auto pPS = CreateShader("ShaderResourceLayoutTest.ConstantBuffers - PS", + "ConstantBuffers.hlsl", + "PSMain", + SHADER_TYPE_PIXEL, SHADER_SOURCE_LANGUAGE_HLSL, Macros, + Resources.data(), static_cast(Resources.size())); + ASSERT_NE(pVS, nullptr); + ASSERT_NE(pPS, nullptr); + + + // clang-format off + std::vector Vars = + { + {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "UniformBuff_Stat", SHADER_RESOURCE_VARIABLE_TYPE_STATIC}, + {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "UniformBuff_Mut", SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE}, + {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "UniformBuff_Dyn", SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC} + }; + + if (CBArraysSupported) + { + Vars.emplace_back(SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "UniformBuffArr_Stat", SHADER_RESOURCE_VARIABLE_TYPE_STATIC); + Vars.emplace_back(SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "UniformBuffArr_Mut", SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE); + Vars.emplace_back(SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "UniformBuffArr_Dyn", SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC); + }; + // clang-format on + + PipelineResourceLayoutDesc ResourceLayout; + ResourceLayout.Variables = Vars.data(); + ResourceLayout.NumVariables = static_cast(Vars.size()); + + RefCntAutoPtr pPSO; + RefCntAutoPtr pSRB; + CreateGraphicsPSO(pVS, pPS, ResourceLayout, pPSO, pSRB); + ASSERT_NE(pPSO, nullptr); + ASSERT_NE(pSRB, nullptr); + + const auto MaxBuffers = std::max(std::max(StaticCBArraySize, MutableCBArraySize), DynamicCBArraySize); + + std::vector> pBuffers(MaxBuffers); + std::vector pCBObjs(MaxBuffers); + + for (Uint32 i = 0; i < MaxBuffers; ++i) + { + BufferDesc BuffDesc; + BuffDesc.Name = "Constant buffer"; + BuffDesc.uiSizeInBytes = 256; + BuffDesc.BindFlags = BIND_UNIFORM_BUFFER; + BuffDesc.Usage = USAGE_DEFAULT; + pDevice->CreateBuffer(BuffDesc, nullptr, &pBuffers[i]); + ASSERT_NE(pBuffers[i], nullptr); + pCBObjs[i] = pBuffers[i]; + } + + SET_STATIC_VAR(pPSO, SHADER_TYPE_VERTEX, "UniformBuff_Stat", Set, pCBObjs[0]); + SET_STATIC_VAR(pPSO, SHADER_TYPE_PIXEL, "UniformBuff_Stat", Set, pCBObjs[0]); + if (CBArraysSupported) + { + SET_STATIC_VAR(pPSO, SHADER_TYPE_VERTEX, "UniformBuffArr_Stat", SetArray, pCBObjs.data(), 0, StaticCBArraySize); + SET_STATIC_VAR(pPSO, SHADER_TYPE_PIXEL, "UniformBuffArr_Stat", SetArray, pCBObjs.data(), 0, StaticCBArraySize); + } + + SET_SRB_VAR(pSRB, SHADER_TYPE_VERTEX, "UniformBuff_Mut", Set, pCBObjs[0]); + SET_SRB_VAR(pSRB, SHADER_TYPE_VERTEX, "UniformBuff_Dyn", Set, pCBObjs[0]); + if (CBArraysSupported) + { + SET_SRB_VAR(pSRB, SHADER_TYPE_VERTEX, "UniformBuffArr_Mut", SetArray, pCBObjs.data(), 0, MutableCBArraySize); + SET_SRB_VAR(pSRB, SHADER_TYPE_VERTEX, "UniformBuffArr_Dyn", SetArray, pCBObjs.data(), 0, DynamicCBArraySize); + } + + SET_SRB_VAR(pSRB, SHADER_TYPE_PIXEL, "UniformBuff_Mut", Set, pCBObjs[0]); + SET_SRB_VAR(pSRB, SHADER_TYPE_PIXEL, "UniformBuff_Dyn", Set, pCBObjs[0]); + if (CBArraysSupported) + { + SET_SRB_VAR(pSRB, SHADER_TYPE_PIXEL, "UniformBuffArr_Mut", SetArray, pCBObjs.data(), 0, MutableCBArraySize); + SET_SRB_VAR(pSRB, SHADER_TYPE_PIXEL, "UniformBuffArr_Dyn", SetArray, pCBObjs.data(), 0, DynamicCBArraySize); + } + + pSRB->InitializeStaticResources(pPSO); + + auto* pContext = pEnv->GetDeviceContext(); + + ITextureView* ppRTVs[] = {pRTV}; + pContext->SetRenderTargets(1, ppRTVs, nullptr, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); + + pContext->SetPipelineState(pPSO); + pContext->CommitShaderResources(pSRB, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); + + DrawAttribs DrawAttrs(3, DRAW_FLAG_VERIFY_ALL); + pContext->Draw(DrawAttrs); + + SET_SRB_VAR(pSRB, SHADER_TYPE_VERTEX, "UniformBuff_Dyn", Set, pCBObjs[1]); + SET_SRB_VAR(pSRB, SHADER_TYPE_PIXEL, "UniformBuff_Dyn", Set, pCBObjs[1]); + if (CBArraysSupported) + { + SET_SRB_VAR(pSRB, SHADER_TYPE_VERTEX, "UniformBuffArr_Dyn", SetArray, &pCBObjs[1], 0, DynamicCBArraySize - 1); + SET_SRB_VAR(pSRB, SHADER_TYPE_PIXEL, "UniformBuffArr_Dyn", SetArray, &pCBObjs[1], 0, DynamicCBArraySize - 1); + } + + pContext->Draw(DrawAttrs); +} + +TEST_F(ShaderResourceLayoutTest, Samplers) +{ + auto* pEnv = TestingEnvironment::GetInstance(); + auto* pDevice = pEnv->GetDevice(); + if (pDevice->GetDeviceCaps().IsGLDevice()) + { + GTEST_SKIP() << "OpenGL does not support separate samplers"; + } + + TestingEnvironment::ScopedReset AutoResetEnvironment; + + static constexpr Uint32 StaticSamArraySize = 2; + static constexpr Uint32 MutableSamArraySize = 4; + static constexpr Uint32 DynamicSamArraySize = 3; + ShaderMacroHelper Macros; + Macros.AddShaderMacro("STATIC_SAM_ARRAY_SIZE", static_cast(StaticSamArraySize)); + Macros.AddShaderMacro("MUTABLE_SAM_ARRAY_SIZE", static_cast(MutableSamArraySize)); + Macros.AddShaderMacro("DYNAMIC_SAM_ARRAY_SIZE", static_cast(DynamicSamArraySize)); + + RefCntAutoPtr pPSO; + RefCntAutoPtr pSRB; + // clang-format off + ShaderResourceDesc Resources[] = + { + {"g_Sam_Static", SHADER_RESOURCE_TYPE_SAMPLER, 1}, + {"g_Sam_Mut", SHADER_RESOURCE_TYPE_SAMPLER, 1}, + {"g_Sam_Dyn", SHADER_RESOURCE_TYPE_SAMPLER, 1}, + {"g_SamArr_Static", SHADER_RESOURCE_TYPE_SAMPLER, StaticSamArraySize}, + {"g_SamArr_Mut", SHADER_RESOURCE_TYPE_SAMPLER, MutableSamArraySize}, + {"g_SamArr_Dyn", SHADER_RESOURCE_TYPE_SAMPLER, DynamicSamArraySize}, + {"g_Tex2D", SHADER_RESOURCE_TYPE_TEXTURE_SRV, 1}, + }; + // clang-format on + auto pVS = CreateShader("ShaderResourceLayoutTest.Samplers - VS", "Samplers.hlsl", "VSMain", + SHADER_TYPE_VERTEX, SHADER_SOURCE_LANGUAGE_HLSL, Macros, + Resources, _countof(Resources)); + auto pPS = CreateShader("ShaderResourceLayoutTest.Samplers - PS", "Samplers.hlsl", "PSMain", + SHADER_TYPE_PIXEL, SHADER_SOURCE_LANGUAGE_HLSL, Macros, + Resources, _countof(Resources)); + ASSERT_NE(pVS, nullptr); + ASSERT_NE(pPS, nullptr); + + + // clang-format off + ShaderResourceVariableDesc Vars[] = + { + {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_Tex2D", SHADER_RESOURCE_VARIABLE_TYPE_STATIC}, + + {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_Sam_Static", SHADER_RESOURCE_VARIABLE_TYPE_STATIC}, + {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_Sam_Mut", SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE}, + {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_Sam_Dyn", SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC}, + + {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_SamArr_Static", SHADER_RESOURCE_VARIABLE_TYPE_STATIC}, + {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_SamArr_Mut", SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE}, + {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_SamArr_Dyn", SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC} + }; + // clang-format on + + PipelineResourceLayoutDesc ResourceLayout; + ResourceLayout.Variables = Vars; + ResourceLayout.NumVariables = _countof(Vars); + + CreateGraphicsPSO(pVS, pPS, ResourceLayout, pPSO, pSRB); + ASSERT_NE(pPSO, nullptr); + ASSERT_NE(pSRB, nullptr); + + constexpr auto MaxSamplers = std::max(std::max(StaticSamArraySize, MutableSamArraySize), DynamicSamArraySize); + + std::array, MaxSamplers> pSamplers; + std::array pSamObjs = {}; + + for (Uint32 i = 0; i < MaxSamplers; ++i) + { + SamplerDesc SamDesc; + pDevice->CreateSampler(SamDesc, &pSamplers[i]); + ASSERT_NE(pSamplers[i], nullptr); + pSamObjs[i] = pSamplers[i]; + } + + auto pTex2D = pEnv->CreateTexture("ShaderResourceLayoutTest: test RTV", TEX_FORMAT_RGBA8_UNORM, BIND_SHADER_RESOURCE, 512, 512); + auto* pTex2DSRV = pTex2D->GetDefaultView(TEXTURE_VIEW_SHADER_RESOURCE); + SET_STATIC_VAR(pPSO, SHADER_TYPE_VERTEX, "g_Tex2D", Set, pTex2DSRV); + SET_STATIC_VAR(pPSO, SHADER_TYPE_PIXEL, "g_Tex2D", Set, pTex2DSRV); + + + SET_STATIC_VAR(pPSO, SHADER_TYPE_VERTEX, "g_Sam_Static", Set, pSamObjs[0]); + SET_STATIC_VAR(pPSO, SHADER_TYPE_VERTEX, "g_SamArr_Static", SetArray, pSamObjs.data(), 0, StaticSamArraySize); + + SET_STATIC_VAR(pPSO, SHADER_TYPE_PIXEL, "g_Sam_Static", Set, pSamObjs[0]); + SET_STATIC_VAR(pPSO, SHADER_TYPE_PIXEL, "g_SamArr_Static", SetArray, pSamObjs.data(), 0, StaticSamArraySize); + + SET_SRB_VAR(pSRB, SHADER_TYPE_VERTEX, "g_Sam_Mut", Set, pSamObjs[0]); + SET_SRB_VAR(pSRB, SHADER_TYPE_VERTEX, "g_Sam_Dyn", Set, pSamObjs[0]); + SET_SRB_VAR(pSRB, SHADER_TYPE_VERTEX, "g_SamArr_Mut", SetArray, pSamObjs.data(), 0, MutableSamArraySize); + SET_SRB_VAR(pSRB, SHADER_TYPE_VERTEX, "g_SamArr_Dyn", SetArray, pSamObjs.data(), 0, DynamicSamArraySize); + + SET_SRB_VAR(pSRB, SHADER_TYPE_PIXEL, "g_Sam_Mut", Set, pSamObjs[0]); + SET_SRB_VAR(pSRB, SHADER_TYPE_PIXEL, "g_Sam_Dyn", Set, pSamObjs[0]); + SET_SRB_VAR(pSRB, SHADER_TYPE_PIXEL, "g_SamArr_Mut", SetArray, pSamObjs.data(), 0, MutableSamArraySize); + SET_SRB_VAR(pSRB, SHADER_TYPE_PIXEL, "g_SamArr_Dyn", SetArray, pSamObjs.data(), 0, DynamicSamArraySize); + + pSRB->InitializeStaticResources(pPSO); + + auto* pContext = pEnv->GetDeviceContext(); + + ITextureView* ppRTVs[] = {pRTV}; + pContext->SetRenderTargets(1, ppRTVs, nullptr, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); + + pContext->SetPipelineState(pPSO); + pContext->CommitShaderResources(pSRB, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); + + DrawAttribs DrawAttrs(3, DRAW_FLAG_VERIFY_ALL); + pContext->Draw(DrawAttrs); + + SET_SRB_VAR(pSRB, SHADER_TYPE_VERTEX, "g_Sam_Dyn", Set, pSamObjs[1]); + SET_SRB_VAR(pSRB, SHADER_TYPE_VERTEX, "g_SamArr_Dyn", SetArray, pSamObjs.data(), 1, DynamicSamArraySize - 1); + + SET_SRB_VAR(pSRB, SHADER_TYPE_PIXEL, "g_Sam_Dyn", Set, pSamObjs[1]); + SET_SRB_VAR(pSRB, SHADER_TYPE_PIXEL, "g_SamArr_Dyn", SetArray, pSamObjs.data(), 1, DynamicSamArraySize - 1); + + pContext->Draw(DrawAttrs); +} + +} // namespace diff --git a/Tests/DiligentCoreAPITest/src/ShaderVariableAccessTest.cpp b/Tests/DiligentCoreAPITest/src/ShaderVariableAccessTest.cpp new file mode 100644 index 00000000..052d8371 --- /dev/null +++ b/Tests/DiligentCoreAPITest/src/ShaderVariableAccessTest.cpp @@ -0,0 +1,827 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "GraphicsAccessories.h" +#include "../../../Graphics/GraphicsEngineD3DBase/interface/ShaderD3D.h" + +#include "TestingEnvironment.h" + +#include "gtest/gtest.h" + +using namespace Diligent; +using namespace Diligent::Testing; + +namespace Diligent +{ + +namespace Test +{ + +void PrintShaderResources(IShader* pShader) +{ + RefCntAutoPtr pShaderD3D(pShader, IID_ShaderD3D); + + std::stringstream ss; + ss << "Resources of shader '" << pShader->GetDesc().Name << "':" << std::endl; + for (Uint32 res = 0; res < pShader->GetResourceCount(); ++res) + { + auto ResDec = pShader->GetResource(res); + + std::stringstream name_ss; + name_ss << ResDec.Name; + if (ResDec.ArraySize > 1) + name_ss << "[" << ResDec.ArraySize << "]"; + ss << std::setw(2) << std::right << res << ": " << std::setw(25) << std::left << name_ss.str(); + if (pShaderD3D) + { + auto HLSLResDesc = pShaderD3D->GetHLSLResource(res); + ss << " hlsl register " << std::setw(2) << HLSLResDesc.ShaderRegister; + } + ss << " " << GetShaderResourceTypeLiteralName(ResDec.Type) << std::endl; + } + LOG_INFO_MESSAGE(ss.str()); +} + +} // namespace Test + +} // namespace Diligent +namespace +{ + +TEST(ShaderResourceLayout, VariableAccess) +{ + auto* pEnv = TestingEnvironment::GetInstance(); + auto* pDevice = pEnv->GetDevice(); + auto* pContext = pEnv->GetDeviceContext(); + + if (pDevice->GetDeviceCaps().DevType == DeviceType::OpenGLES) + return; + + TestingEnvironment::ScopedReset EnvironmentAutoReset; + + ShaderCreateInfo ShaderCI; + + RefCntAutoPtr pShaderSourceFactory; + pDevice->GetEngineFactory()->CreateDefaultShaderSourceStreamFactory("shaders", &pShaderSourceFactory); + ShaderCI.pShaderSourceStreamFactory = pShaderSourceFactory; + ShaderCI.EntryPoint = "main"; + ShaderCI.UseCombinedTextureSamplers = true; + + RefCntAutoPtr pSamplers[2]; + IDeviceObject* pSams[2] = {}; + for (size_t i = 0; i < _countof(pSams); ++i) + { + SamplerDesc SamDesc; + pDevice->CreateSampler(SamDesc, &(pSamplers[i])); + pSams[i] = pSamplers[i]; + } + + RefCntAutoPtr pTex[2]; + TextureDesc TexDesc; + TexDesc.Type = RESOURCE_DIM_TEX_2D; + TexDesc.Width = 1024; + TexDesc.Height = 1024; + TexDesc.Format = TEX_FORMAT_RGBA8_UNORM_SRGB; + TexDesc.BindFlags = BIND_SHADER_RESOURCE; + IDeviceObject* pSRVs[2] = {}; + for (size_t i = 0; i < _countof(pSRVs); ++i) + { + pDevice->CreateTexture(TexDesc, nullptr, &(pTex[i])); + auto* pSRV = pTex[i]->GetDefaultView(TEXTURE_VIEW_SHADER_RESOURCE); + pSRV->SetSampler(pSamplers[i]); + pSRVs[i] = pSRV; + } + + RefCntAutoPtr pRWTex[8]; + IDeviceObject* pTexUAVs[_countof(pRWTex)] = {}; + IDeviceObject* pRWTexSRVs[_countof(pRWTex)] = {}; + TexDesc.BindFlags = BIND_SHADER_RESOURCE | BIND_UNORDERED_ACCESS; + TexDesc.Format = TEX_FORMAT_RGBA32_FLOAT; + for (size_t i = 0; i < _countof(pRWTex); ++i) + { + pDevice->CreateTexture(TexDesc, nullptr, &(pRWTex[i])); + pTexUAVs[i] = pRWTex[i]->GetDefaultView(TEXTURE_VIEW_UNORDERED_ACCESS); + pRWTexSRVs[i] = pRWTex[i]->GetDefaultView(TEXTURE_VIEW_SHADER_RESOURCE); + } + + + //RefCntAutoPtr pStorageTex[4]; + //IDeviceObject *pUAVs[4]; + //for (int i = 0; i < 4; ++i) + //{ + // pDevice->CreateTexture(TexDesc, TextureData{}, &(pStorageTex[i])); + // pUAVs[i] = pStorageTex[i]->GetDefaultView(TEXTURE_VIEW_UNORDERED_ACCESS); + //} + + constexpr auto RTVFormat = TEX_FORMAT_RGBA8_UNORM; + constexpr auto DSVFormat = TEX_FORMAT_D32_FLOAT; + + TexDesc.Format = RTVFormat; + TexDesc.BindFlags = BIND_RENDER_TARGET | BIND_SHADER_RESOURCE; + RefCntAutoPtr pRenderTarget; + pDevice->CreateTexture(TexDesc, nullptr, &pRenderTarget); + auto* pRTV = pRenderTarget->GetDefaultView(TEXTURE_VIEW_RENDER_TARGET); + + TexDesc.Format = DSVFormat; + TexDesc.BindFlags = BIND_DEPTH_STENCIL; + RefCntAutoPtr pDepthTex; + pDevice->CreateTexture(TexDesc, nullptr, &pDepthTex); + auto* pDSV = pDepthTex->GetDefaultView(TEXTURE_VIEW_DEPTH_STENCIL); + + BufferDesc BuffDesc; + BuffDesc.uiSizeInBytes = 1024; + BuffDesc.BindFlags = BIND_UNIFORM_BUFFER; + RefCntAutoPtr pUniformBuffs[2]; + IDeviceObject* pUBs[2]; + for (int i = 0; i < _countof(pUniformBuffs); ++i) + { + pDevice->CreateBuffer(BuffDesc, nullptr, &(pUniformBuffs[i])); + pUBs[i] = pUniformBuffs[i]; + } + + //BuffDesc.BindFlags = BIND_UNORDERED_ACCESS; + //BuffDesc.Mode = BUFFER_MODE_STRUCTURED; + //BuffDesc.ElementByteStride = 16; + //RefCntAutoPtr pStorgeBuffs[4]; + //IDeviceObject *pSBUAVs[4]; + //for (int i = 0; i < 4; ++i) + //{ + // pDevice->CreateBuffer(BuffDesc, BufferData{}, &(pStorgeBuffs[i])); + // pSBUAVs[i] = pStorgeBuffs[i]->GetDefaultView(BUFFER_VIEW_UNORDERED_ACCESS); + //} + + RefCntAutoPtr pFormattedBuff0, pFormattedBuff[4], pRawBuff[2]; + IDeviceObject * pFormattedBuffSRV = nullptr, *pFormattedBuffUAV[4] = {}, *pFormattedBuffSRVs[4] = {}; + RefCntAutoPtr spFormattedBuffSRV, spFormattedBuffUAV[4], spFormattedBuffSRVs[4]; + RefCntAutoPtr spRawBuffUAV[2], spRawBuffSRVs[2]; + { + BufferDesc TxlBuffDesc; + TxlBuffDesc.Name = "Uniform texel buffer test"; + TxlBuffDesc.uiSizeInBytes = 256; + TxlBuffDesc.BindFlags = BIND_SHADER_RESOURCE | BIND_UNORDERED_ACCESS; + TxlBuffDesc.Usage = USAGE_DEFAULT; + TxlBuffDesc.ElementByteStride = 16; + TxlBuffDesc.Mode = BUFFER_MODE_FORMATTED; + pDevice->CreateBuffer(TxlBuffDesc, nullptr, &pFormattedBuff0); + + BufferViewDesc ViewDesc; + ViewDesc.ViewType = BUFFER_VIEW_SHADER_RESOURCE; + ViewDesc.Format.ValueType = VT_FLOAT32; + ViewDesc.Format.NumComponents = 4; + ViewDesc.Format.IsNormalized = false; + pFormattedBuff0->CreateView(ViewDesc, &spFormattedBuffSRV); + pFormattedBuffSRV = spFormattedBuffSRV; + + for (size_t i = 0; i < _countof(pFormattedBuff); ++i) + { + TxlBuffDesc.Name = "UAV buffer test"; + TxlBuffDesc.BindFlags = BIND_SHADER_RESOURCE | BIND_UNORDERED_ACCESS; + pDevice->CreateBuffer(TxlBuffDesc, nullptr, &(pFormattedBuff[i])); + + ViewDesc.ViewType = BUFFER_VIEW_UNORDERED_ACCESS; + pFormattedBuff[i]->CreateView(ViewDesc, &(spFormattedBuffUAV[i])); + pFormattedBuffUAV[i] = spFormattedBuffUAV[i]; + + ViewDesc.ViewType = BUFFER_VIEW_SHADER_RESOURCE; + pFormattedBuff[i]->CreateView(ViewDesc, &(spFormattedBuffSRVs[i])); + pFormattedBuffSRVs[i] = spFormattedBuffSRVs[i]; + } + + TxlBuffDesc.Mode = BUFFER_MODE_RAW; + ViewDesc.Format.ValueType = VT_UNDEFINED; + for (size_t i = 0; i < _countof(pRawBuff); ++i) + { + TxlBuffDesc.Name = "Raw buffer test"; + pDevice->CreateBuffer(TxlBuffDesc, nullptr, &(pRawBuff[i])); + spRawBuffUAV[i] = pRawBuff[i]->GetDefaultView(BUFFER_VIEW_UNORDERED_ACCESS); + spRawBuffSRVs[i] = pRawBuff[i]->GetDefaultView(BUFFER_VIEW_SHADER_RESOURCE); + } + } + + RefCntAutoPtr pVS; + { + ShaderCI.Desc.Name = "Shader variable access test VS"; + ShaderCI.Desc.ShaderType = SHADER_TYPE_VERTEX; + ShaderCI.SourceLanguage = SHADER_SOURCE_LANGUAGE_DEFAULT; + ShaderCI.FilePath = pDevice->GetDeviceCaps().IsD3DDevice() ? "ShaderVariableAccessTestDX.vsh" : "ShaderVariableAccessTestGL.vsh"; + + pDevice->CreateShader(ShaderCI, &pVS); + ASSERT_NE(pVS, nullptr); + + Diligent::Test::PrintShaderResources(pVS); + } + + std::vector VarDesc = + { + {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_tex2D_Static", SHADER_RESOURCE_VARIABLE_TYPE_STATIC}, + {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_tex2D_StaticArr", SHADER_RESOURCE_VARIABLE_TYPE_STATIC}, + {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_tex2D_Mut", SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE}, + {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_tex2D_Dyn", SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC}, + {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_tex2D_MutArr", SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE}, + {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_tex2D_DynArr", SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC}, + {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "UniformBuff_Mut", SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE}, + {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "UniformBuff_Dyn", SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC}, + {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_Buffer_Mut", SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE}, + {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_Buffer_MutArr", SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE}, + {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_Buffer_Dyn", SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC}, + {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_Buffer_DynArr", SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC}, + {SHADER_TYPE_PIXEL, "g_rwtex2D_Mut", SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE}, + {SHADER_TYPE_PIXEL, "g_rwtex2D_Dyn", SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC}, + {SHADER_TYPE_PIXEL, "g_rwBuff_Mut", SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE}, + {SHADER_TYPE_PIXEL, "g_rwBuff_Dyn", SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC}, + }; + + StaticSamplerDesc StaticSamplers[] = + { + {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_tex2D_Static", SamplerDesc{}}, + {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_tex2D_StaticArr", SamplerDesc{}}, + {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_tex2D_Mut", SamplerDesc{}}, + {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_tex2D_MutArr", SamplerDesc{}}, + {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_tex2D_Dyn", SamplerDesc{}}, + {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_tex2D_DynArr", SamplerDesc{}}, + }; + + RefCntAutoPtr pPS; + { + ShaderCI.Desc.Name = "Shader variable access test PS"; + ShaderCI.Desc.ShaderType = SHADER_TYPE_PIXEL; + ShaderCI.SourceLanguage = SHADER_SOURCE_LANGUAGE_DEFAULT; + ShaderCI.FilePath = pDevice->GetDeviceCaps().IsD3DDevice() ? "ShaderVariableAccessTestDX.psh" : "ShaderVariableAccessTestGL.psh"; + pDevice->CreateShader(ShaderCI, &pPS); + ASSERT_NE(pPS, nullptr); + + Diligent::Test::PrintShaderResources(pPS); + } + + + PipelineStateDesc PSODesc; + + PSODesc.ResourceLayout.Variables = VarDesc.data(); + PSODesc.ResourceLayout.NumVariables = static_cast(VarDesc.size()); + PSODesc.ResourceLayout.NumStaticSamplers = _countof(StaticSamplers); + PSODesc.ResourceLayout.StaticSamplers = StaticSamplers; + + PSODesc.Name = "Shader variable access test PSO"; + PSODesc.GraphicsPipeline.pVS = pVS; + PSODesc.GraphicsPipeline.pPS = pPS; + PSODesc.GraphicsPipeline.PrimitiveTopology = PRIMITIVE_TOPOLOGY_TRIANGLE_LIST; + PSODesc.GraphicsPipeline.NumRenderTargets = 1; + PSODesc.GraphicsPipeline.RTVFormats[0] = RTVFormat; + PSODesc.GraphicsPipeline.DSVFormat = DSVFormat; + PSODesc.SRBAllocationGranularity = 16; + + RefCntAutoPtr pTestPSO; + pDevice->CreatePipelineState(PSODesc, &pTestPSO); + ASSERT_NE(pTestPSO, nullptr); + + { + EXPECT_EQ(pTestPSO->GetStaticVariableCount(SHADER_TYPE_VERTEX), 6u); + + { + auto tex2D_Static = pTestPSO->GetStaticVariableByName(SHADER_TYPE_VERTEX, "g_tex2D_Static"); + ASSERT_NE(tex2D_Static, nullptr); + EXPECT_EQ(tex2D_Static->GetResourceDesc().ArraySize, 1u); + EXPECT_EQ(tex2D_Static, pTestPSO->GetStaticVariableByName(SHADER_TYPE_VERTEX, tex2D_Static->GetResourceDesc().Name)); + tex2D_Static->Set(pSRVs[0]); + } + + { + auto tex2D_Static_sampler = pTestPSO->GetStaticVariableByName(SHADER_TYPE_VERTEX, "g_tex2D_Static_sampler"); + EXPECT_EQ(tex2D_Static_sampler, nullptr); + } + + { + auto tex2D_StaticArr = pTestPSO->GetStaticVariableByName(SHADER_TYPE_VERTEX, "g_tex2D_StaticArr"); + ASSERT_NE(tex2D_StaticArr, nullptr); + EXPECT_EQ(tex2D_StaticArr->GetResourceDesc().ArraySize, 2u); + EXPECT_EQ(tex2D_StaticArr, pTestPSO->GetStaticVariableByName(SHADER_TYPE_VERTEX, tex2D_StaticArr->GetResourceDesc().Name)); + tex2D_StaticArr->SetArray(pSRVs, 0, 2); + } + + { + auto tex2D_StaticArr_sampler = pTestPSO->GetStaticVariableByName(SHADER_TYPE_VERTEX, "g_tex2D_StaticArr_sampler"); + EXPECT_EQ(tex2D_StaticArr_sampler, nullptr); + } + + { + auto UniformBuff_Stat = pTestPSO->GetStaticVariableByName(SHADER_TYPE_VERTEX, "UniformBuff_Stat"); + ASSERT_NE(UniformBuff_Stat, nullptr); + EXPECT_EQ(UniformBuff_Stat->GetResourceDesc().ArraySize, 1u); + EXPECT_EQ(UniformBuff_Stat, pTestPSO->GetStaticVariableByName(SHADER_TYPE_VERTEX, UniformBuff_Stat->GetResourceDesc().Name)); + UniformBuff_Stat->Set(pUBs[0]); + } + + { + auto UniformBuff_Stat2 = pTestPSO->GetStaticVariableByName(SHADER_TYPE_VERTEX, "UniformBuff_Stat2"); + ASSERT_NE(UniformBuff_Stat2, nullptr); + EXPECT_EQ(UniformBuff_Stat2->GetResourceDesc().ArraySize, 1u); + EXPECT_EQ(UniformBuff_Stat2, pTestPSO->GetStaticVariableByName(SHADER_TYPE_VERTEX, UniformBuff_Stat2->GetResourceDesc().Name)); + UniformBuff_Stat2->Set(pUBs[0]); + } + + { + auto Buffer_Static = pTestPSO->GetStaticVariableByName(SHADER_TYPE_VERTEX, "g_Buffer_Static"); + ASSERT_NE(Buffer_Static, nullptr); + EXPECT_EQ(Buffer_Static->GetResourceDesc().ArraySize, 1u); + EXPECT_EQ(Buffer_Static, pTestPSO->GetStaticVariableByName(SHADER_TYPE_VERTEX, Buffer_Static->GetResourceDesc().Name)); + Buffer_Static->Set(pFormattedBuffSRV); + } + + { + auto Buffer_StaticArr = pTestPSO->GetStaticVariableByName(SHADER_TYPE_VERTEX, "g_Buffer_StaticArr"); + ASSERT_NE(Buffer_StaticArr, nullptr); + EXPECT_EQ(Buffer_StaticArr->GetResourceDesc().ArraySize, 2u); + EXPECT_EQ(Buffer_StaticArr, pTestPSO->GetStaticVariableByName(SHADER_TYPE_VERTEX, Buffer_StaticArr->GetResourceDesc().Name)); + Buffer_StaticArr->SetArray(&pFormattedBuffSRV, 0, 1); + Buffer_StaticArr->SetArray(&pFormattedBuffSRV, 1, 1); + } + + + { + auto tex2D_Mut = pTestPSO->GetStaticVariableByName(SHADER_TYPE_VERTEX, "g_tex2D_Mut"); + EXPECT_EQ(tex2D_Mut, nullptr); + } + { + auto tex2D_Dyn = pTestPSO->GetStaticVariableByName(SHADER_TYPE_VERTEX, "g_tex2D_Dyn"); + EXPECT_EQ(tex2D_Dyn, nullptr); + } + { + auto tex2D_Mut_sampler = pTestPSO->GetStaticVariableByName(SHADER_TYPE_VERTEX, "g_tex2D_Mut_sampler"); + EXPECT_EQ(tex2D_Mut_sampler, nullptr); + } + { + auto tex2D_Dyn_sampler = pTestPSO->GetStaticVariableByName(SHADER_TYPE_VERTEX, "g_tex2D_DynArr_sampler"); + EXPECT_EQ(tex2D_Dyn_sampler, nullptr); + } + + + + auto NumVSVars = pTestPSO->GetStaticVariableCount(SHADER_TYPE_VERTEX); + for (Uint32 v = 0; v < NumVSVars; ++v) + { + auto pVar = pTestPSO->GetStaticVariableByIndex(SHADER_TYPE_VERTEX, v); + EXPECT_EQ(pVar->GetIndex(), v); + EXPECT_EQ(pVar->GetType(), SHADER_RESOURCE_VARIABLE_TYPE_STATIC); + auto pVar2 = pTestPSO->GetStaticVariableByName(SHADER_TYPE_VERTEX, pVar->GetResourceDesc().Name); + EXPECT_EQ(pVar, pVar2); + } + } + + + { + EXPECT_EQ(pTestPSO->GetStaticVariableCount(SHADER_TYPE_PIXEL), 9u); + + { + auto tex2D_Static = pTestPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, "g_tex2D_Static"); + ASSERT_NE(tex2D_Static, nullptr); + EXPECT_EQ(tex2D_Static->GetResourceDesc().ArraySize, 1u); + EXPECT_EQ(tex2D_Static, pTestPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, tex2D_Static->GetResourceDesc().Name)); + tex2D_Static->Set(pSRVs[0]); + } + + { + auto tex2D_Static_sampler = pTestPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, "g_tex2D_Static_sampler"); + EXPECT_EQ(tex2D_Static_sampler, nullptr); + } + + { + auto tex2D_StaticArr = pTestPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, "g_tex2D_StaticArr"); + ASSERT_NE(tex2D_StaticArr, nullptr); + EXPECT_EQ(tex2D_StaticArr->GetResourceDesc().ArraySize, 2u); + EXPECT_EQ(tex2D_StaticArr, pTestPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, tex2D_StaticArr->GetResourceDesc().Name)); + tex2D_StaticArr->SetArray(pSRVs, 0, 2); + } + { + auto tex2D_StaticArr_sampler = pTestPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, "g_tex2D_StaticArr_sampler"); + EXPECT_EQ(tex2D_StaticArr_sampler, nullptr); + } + + { + auto UniformBuff_Stat = pTestPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, "UniformBuff_Stat"); + ASSERT_NE(UniformBuff_Stat, nullptr); + EXPECT_EQ(UniformBuff_Stat->GetResourceDesc().ArraySize, 1u); + EXPECT_EQ(UniformBuff_Stat, pTestPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, UniformBuff_Stat->GetResourceDesc().Name)); + UniformBuff_Stat->Set(pUBs[0]); + } + + { + auto UniformBuff_Stat2 = pTestPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, "UniformBuff_Stat2"); + ASSERT_NE(UniformBuff_Stat2, nullptr); + EXPECT_EQ(UniformBuff_Stat2->GetResourceDesc().ArraySize, 1u); + EXPECT_EQ(UniformBuff_Stat2, pTestPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, UniformBuff_Stat2->GetResourceDesc().Name)); + UniformBuff_Stat2->Set(pUBs[0]); + } + + { + auto Buffer_Static = pTestPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, "g_Buffer_Static"); + ASSERT_NE(Buffer_Static, nullptr); + EXPECT_EQ(Buffer_Static->GetResourceDesc().ArraySize, 1u); + EXPECT_EQ(Buffer_Static, pTestPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, Buffer_Static->GetResourceDesc().Name)); + Buffer_Static->Set(pFormattedBuffSRV); + } + + { + auto Buffer_StaticArr = pTestPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, "g_Buffer_StaticArr"); + ASSERT_NE(Buffer_StaticArr, nullptr); + EXPECT_EQ(Buffer_StaticArr->GetResourceDesc().ArraySize, 2u); + EXPECT_EQ(Buffer_StaticArr, pTestPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, Buffer_StaticArr->GetResourceDesc().Name)); + Buffer_StaticArr->SetArray(&pFormattedBuffSRV, 0, 1); + Buffer_StaticArr->SetArray(&pFormattedBuffSRV, 1, 1); + } + + + { + auto rwtex2D_Static = pTestPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, "g_rwtex2D_Static"); + ASSERT_NE(rwtex2D_Static, nullptr); + EXPECT_EQ(rwtex2D_Static->GetResourceDesc().ArraySize, 1u); + EXPECT_EQ(rwtex2D_Static, pTestPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, rwtex2D_Static->GetResourceDesc().Name)); + rwtex2D_Static->Set(pTexUAVs[0]); + } + + + { + auto rwtex2D_Static2 = pTestPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, "g_rwtex2D_Static2"); + ASSERT_NE(rwtex2D_Static2, nullptr); + EXPECT_EQ(rwtex2D_Static2->GetResourceDesc().ArraySize, 1u); + EXPECT_EQ(rwtex2D_Static2, pTestPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, rwtex2D_Static2->GetResourceDesc().Name)); + rwtex2D_Static2->Set(pTexUAVs[1]); + } + + { + auto rwBuff_Static = pTestPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, "g_rwBuff_Static"); + ASSERT_NE(rwBuff_Static, nullptr); + EXPECT_EQ(rwBuff_Static->GetResourceDesc().ArraySize, 1u); + EXPECT_EQ(rwBuff_Static, pTestPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, rwBuff_Static->GetResourceDesc().Name)); + rwBuff_Static->Set(spRawBuffUAV[0]); + } + + + { + auto tex2D_Mut = pTestPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, "g_tex2D_Mut"); + EXPECT_EQ(tex2D_Mut, nullptr); + } + { + auto tex2D_Dyn = pTestPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, "g_tex2D_Dyn"); + EXPECT_EQ(tex2D_Dyn, nullptr); + } + { + auto tex2D_Mut_sampler = pTestPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, "g_tex2D_Mut_sampler"); + EXPECT_EQ(tex2D_Mut_sampler, nullptr); + } + { + auto tex2D_Dyn_sampler = pTestPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, "g_tex2D_DynArr_sampler"); + EXPECT_EQ(tex2D_Dyn_sampler, nullptr); + } + + + auto NumPSVars = pTestPSO->GetStaticVariableCount(SHADER_TYPE_PIXEL); + for (Uint32 v = 0; v < NumPSVars; ++v) + { + auto pVar = pTestPSO->GetStaticVariableByIndex(SHADER_TYPE_PIXEL, v); + EXPECT_EQ(pVar->GetIndex(), v); + EXPECT_EQ(pVar->GetType(), SHADER_RESOURCE_VARIABLE_TYPE_STATIC); + auto pVar2 = pTestPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, pVar->GetResourceDesc().Name); + EXPECT_EQ(pVar, pVar2); + } + } + + RefCntAutoPtr pSRB; + pTestPSO->CreateShaderResourceBinding(&pSRB, true); + ASSERT_NE(pSRB, nullptr); + + { + { + auto tex2D_Mut = pSRB->GetVariableByName(SHADER_TYPE_VERTEX, "g_tex2D_Mut"); + ASSERT_NE(tex2D_Mut, nullptr); + EXPECT_EQ(tex2D_Mut->GetResourceDesc().ArraySize, 1u); + EXPECT_EQ(tex2D_Mut, pSRB->GetVariableByName(SHADER_TYPE_VERTEX, tex2D_Mut->GetResourceDesc().Name)); + tex2D_Mut->Set(pSRVs[0]); + } + + { + auto tex2D_Mut_sampler = pSRB->GetVariableByName(SHADER_TYPE_VERTEX, "g_tex2D_Mut_sampler"); + EXPECT_EQ(tex2D_Mut_sampler, nullptr); + } + + { + auto tex2D_MutArr = pSRB->GetVariableByName(SHADER_TYPE_VERTEX, "g_tex2D_MutArr"); + ASSERT_NE(tex2D_MutArr, nullptr); + EXPECT_EQ(tex2D_MutArr->GetResourceDesc().ArraySize, 2u); + EXPECT_EQ(tex2D_MutArr, pSRB->GetVariableByName(SHADER_TYPE_VERTEX, tex2D_MutArr->GetResourceDesc().Name)); + tex2D_MutArr->SetArray(pSRVs, 0, 2); + } + + { + auto tex2D_MutArr_sampler = pSRB->GetVariableByName(SHADER_TYPE_VERTEX, "g_tex2D_MutArr_sampler"); + EXPECT_EQ(tex2D_MutArr_sampler, nullptr); + } + + { + auto tex2D_Dyn = pSRB->GetVariableByName(SHADER_TYPE_VERTEX, "g_tex2D_Dyn"); + ASSERT_NE(tex2D_Dyn, nullptr); + EXPECT_EQ(tex2D_Dyn->GetResourceDesc().ArraySize, 1u); + EXPECT_EQ(tex2D_Dyn, pSRB->GetVariableByName(SHADER_TYPE_VERTEX, tex2D_Dyn->GetResourceDesc().Name)); + tex2D_Dyn->Set(pSRVs[0]); + } + + { + auto tex2D_Dyn_sampler = pSRB->GetVariableByName(SHADER_TYPE_VERTEX, "g_tex2D_Dyn_sampler"); + EXPECT_EQ(tex2D_Dyn_sampler, nullptr); + } + + { + auto tex2D_DynArr = pSRB->GetVariableByName(SHADER_TYPE_VERTEX, "g_tex2D_DynArr"); + ASSERT_NE(tex2D_DynArr, nullptr); + EXPECT_EQ(tex2D_DynArr->GetResourceDesc().ArraySize, 2u); + EXPECT_EQ(tex2D_DynArr, pSRB->GetVariableByName(SHADER_TYPE_VERTEX, tex2D_DynArr->GetResourceDesc().Name)); + tex2D_DynArr->SetArray(pSRVs, 0, 2); + } + + { + auto tex2D_DynArr_sampler = pSRB->GetVariableByName(SHADER_TYPE_VERTEX, "g_tex2D_DynArr_sampler"); + EXPECT_EQ(tex2D_DynArr_sampler, nullptr); + } + + { + auto UniformBuff_Mut = pSRB->GetVariableByName(SHADER_TYPE_VERTEX, "UniformBuff_Mut"); + ASSERT_NE(UniformBuff_Mut, nullptr); + EXPECT_EQ(UniformBuff_Mut->GetResourceDesc().ArraySize, 1u); + EXPECT_EQ(UniformBuff_Mut, pSRB->GetVariableByName(SHADER_TYPE_VERTEX, UniformBuff_Mut->GetResourceDesc().Name)); + UniformBuff_Mut->Set(pUBs[0]); + } + + { + auto UniformBuff_Dyn = pSRB->GetVariableByName(SHADER_TYPE_VERTEX, "UniformBuff_Dyn"); + ASSERT_NE(UniformBuff_Dyn, nullptr); + EXPECT_EQ(UniformBuff_Dyn->GetResourceDesc().ArraySize, 1u); + EXPECT_EQ(UniformBuff_Dyn, pSRB->GetVariableByName(SHADER_TYPE_VERTEX, UniformBuff_Dyn->GetResourceDesc().Name)); + UniformBuff_Dyn->Set(pUBs[0]); + } + + { + auto Buffer_Mut = pSRB->GetVariableByName(SHADER_TYPE_VERTEX, "g_Buffer_Mut"); + ASSERT_NE(Buffer_Mut, nullptr); + EXPECT_EQ(Buffer_Mut->GetResourceDesc().ArraySize, 1u); + EXPECT_EQ(Buffer_Mut, pSRB->GetVariableByName(SHADER_TYPE_VERTEX, Buffer_Mut->GetResourceDesc().Name)); + Buffer_Mut->Set(pFormattedBuffSRV); + } + + { + auto Buffer_MutArr = pSRB->GetVariableByName(SHADER_TYPE_VERTEX, "g_Buffer_MutArr"); + ASSERT_NE(Buffer_MutArr, nullptr); + EXPECT_EQ(Buffer_MutArr->GetResourceDesc().ArraySize, 2u); + EXPECT_EQ(Buffer_MutArr, pSRB->GetVariableByName(SHADER_TYPE_VERTEX, Buffer_MutArr->GetResourceDesc().Name)); + Buffer_MutArr->SetArray(&pFormattedBuffSRV, 0, 1); + Buffer_MutArr->SetArray(&pFormattedBuffSRV, 1, 1); + } + + { + auto Buffer_Dyn = pSRB->GetVariableByName(SHADER_TYPE_VERTEX, "g_Buffer_Dyn"); + ASSERT_NE(Buffer_Dyn, nullptr); + EXPECT_EQ(Buffer_Dyn->GetResourceDesc().ArraySize, 1u); + EXPECT_EQ(Buffer_Dyn, pSRB->GetVariableByName(SHADER_TYPE_VERTEX, Buffer_Dyn->GetResourceDesc().Name)); + Buffer_Dyn->Set(pFormattedBuffSRV); + } + + { + auto Buffer_DynArr = pSRB->GetVariableByName(SHADER_TYPE_VERTEX, "g_Buffer_DynArr"); + ASSERT_NE(Buffer_DynArr, nullptr); + EXPECT_EQ(Buffer_DynArr->GetResourceDesc().ArraySize, 2u); + EXPECT_EQ(Buffer_DynArr, pSRB->GetVariableByName(SHADER_TYPE_VERTEX, Buffer_DynArr->GetResourceDesc().Name)); + Buffer_DynArr->SetArray(&pFormattedBuffSRV, 0, 1); + Buffer_DynArr->SetArray(&pFormattedBuffSRV, 1, 1); + } + + { + auto tex2D_Static = pSRB->GetVariableByName(SHADER_TYPE_VERTEX, "g_tex2D_Static"); + EXPECT_EQ(tex2D_Static, nullptr); + } + + auto UniformBuff_Stat = pSRB->GetVariableByName(SHADER_TYPE_VERTEX, "UniformBuff_Stat"); + EXPECT_EQ(UniformBuff_Stat, nullptr); + } + + + + { + { + auto tex2D_Mut = pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_tex2D_Mut"); + ASSERT_NE(tex2D_Mut, nullptr); + EXPECT_EQ(tex2D_Mut->GetResourceDesc().ArraySize, 1u); + EXPECT_EQ(tex2D_Mut, pSRB->GetVariableByName(SHADER_TYPE_PIXEL, tex2D_Mut->GetResourceDesc().Name)); + tex2D_Mut->Set(pRWTexSRVs[4]); + } + + { + auto tex2D_Mut_sampler = pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_tex2D_Mut_sampler"); + EXPECT_EQ(tex2D_Mut_sampler, nullptr); + } + + { + auto tex2D_MutArr = pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_tex2D_MutArr"); + ASSERT_NE(tex2D_MutArr, nullptr); + EXPECT_EQ(tex2D_MutArr->GetResourceDesc().ArraySize, 2u); + EXPECT_EQ(tex2D_MutArr, pSRB->GetVariableByName(SHADER_TYPE_PIXEL, tex2D_MutArr->GetResourceDesc().Name)); + tex2D_MutArr->SetArray(pRWTexSRVs + 5, 0, 2); + } + + { + auto tex2D_MutArr_sampler = pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_tex2D_MutArr_sampler"); + EXPECT_EQ(tex2D_MutArr_sampler, nullptr); + } + + { + auto tex2D_Dyn = pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_tex2D_Dyn"); + ASSERT_NE(tex2D_Dyn, nullptr); + EXPECT_EQ(tex2D_Dyn->GetResourceDesc().ArraySize, 1u); + EXPECT_EQ(tex2D_Dyn, pSRB->GetVariableByName(SHADER_TYPE_PIXEL, tex2D_Dyn->GetResourceDesc().Name)); + tex2D_Dyn->Set(pRWTexSRVs[7]); + } + + { + auto tex2D_Dyn_sampler = pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_tex2D_Dyn_sampler"); + EXPECT_EQ(tex2D_Dyn_sampler, nullptr); + } + + { + auto tex2D_DynArr = pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_tex2D_DynArr"); + ASSERT_NE(tex2D_DynArr, nullptr); + EXPECT_EQ(tex2D_DynArr->GetResourceDesc().ArraySize, 2u); + EXPECT_EQ(tex2D_DynArr, pSRB->GetVariableByName(SHADER_TYPE_PIXEL, tex2D_DynArr->GetResourceDesc().Name)); + tex2D_DynArr->SetArray(pSRVs, 0, 2); + } + + { + auto tex2D_DynArr_sampler = pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_tex2D_DynArr_sampler"); + EXPECT_EQ(tex2D_DynArr_sampler, nullptr); + } + + + { + auto UniformBuff_Mut = pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "UniformBuff_Mut"); + ASSERT_NE(UniformBuff_Mut, nullptr); + EXPECT_EQ(UniformBuff_Mut->GetResourceDesc().ArraySize, 1u); + EXPECT_EQ(UniformBuff_Mut, pSRB->GetVariableByName(SHADER_TYPE_PIXEL, UniformBuff_Mut->GetResourceDesc().Name)); + UniformBuff_Mut->Set(pUBs[0]); + } + + { + auto UniformBuff_Dyn = pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "UniformBuff_Dyn"); + ASSERT_NE(UniformBuff_Dyn, nullptr); + EXPECT_EQ(UniformBuff_Dyn->GetResourceDesc().ArraySize, 1u); + EXPECT_EQ(UniformBuff_Dyn, pSRB->GetVariableByName(SHADER_TYPE_PIXEL, UniformBuff_Dyn->GetResourceDesc().Name)); + UniformBuff_Dyn->Set(pUBs[0]); + } + + { + auto Buffer_Mut = pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_Buffer_Mut"); + ASSERT_NE(Buffer_Mut, nullptr); + EXPECT_EQ(Buffer_Mut->GetResourceDesc().ArraySize, 1u); + EXPECT_EQ(Buffer_Mut, pSRB->GetVariableByName(SHADER_TYPE_PIXEL, Buffer_Mut->GetResourceDesc().Name)); + Buffer_Mut->Set(spRawBuffSRVs[1]); + } + + { + auto Buffer_MutArr = pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_Buffer_MutArr"); + ASSERT_NE(Buffer_MutArr, nullptr); + EXPECT_EQ(Buffer_MutArr->GetResourceDesc().ArraySize, 2u); + EXPECT_EQ(Buffer_MutArr, pSRB->GetVariableByName(SHADER_TYPE_PIXEL, Buffer_MutArr->GetResourceDesc().Name)); + Buffer_MutArr->SetArray(&pFormattedBuffSRV, 0, 1); + Buffer_MutArr->SetArray(&pFormattedBuffSRV, 1, 1); + } + + { + auto Buffer_Dyn = pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_Buffer_Dyn"); + ASSERT_NE(Buffer_Dyn, nullptr); + EXPECT_EQ(Buffer_Dyn->GetResourceDesc().ArraySize, 1u); + EXPECT_EQ(Buffer_Dyn, pSRB->GetVariableByName(SHADER_TYPE_PIXEL, Buffer_Dyn->GetResourceDesc().Name)); + Buffer_Dyn->Set(pFormattedBuffSRVs[3]); + } + + { + auto Buffer_DynArr = pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_Buffer_DynArr"); + ASSERT_NE(Buffer_DynArr, nullptr); + EXPECT_EQ(Buffer_DynArr->GetResourceDesc().ArraySize, 2u); + EXPECT_EQ(Buffer_DynArr, pSRB->GetVariableByName(SHADER_TYPE_PIXEL, Buffer_DynArr->GetResourceDesc().Name)); + Buffer_DynArr->SetArray(&pFormattedBuffSRV, 0, 1); + Buffer_DynArr->SetArray(&pFormattedBuffSRV, 1, 1); + } + + { + auto rwtex2D_Mut = pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_rwtex2D_Mut"); + ASSERT_NE(rwtex2D_Mut, nullptr); + EXPECT_EQ(rwtex2D_Mut->GetResourceDesc().ArraySize, 1u); + EXPECT_EQ(rwtex2D_Mut, pSRB->GetVariableByName(SHADER_TYPE_PIXEL, rwtex2D_Mut->GetResourceDesc().Name)); + rwtex2D_Mut->Set(pTexUAVs[2]); + } + + { + auto rwtex2D_Dyn = pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_rwtex2D_Dyn"); + ASSERT_NE(rwtex2D_Dyn, nullptr); + EXPECT_EQ(rwtex2D_Dyn->GetResourceDesc().ArraySize, 1u); + EXPECT_EQ(rwtex2D_Dyn, pSRB->GetVariableByName(SHADER_TYPE_PIXEL, rwtex2D_Dyn->GetResourceDesc().Name)); + rwtex2D_Dyn->Set(pTexUAVs[3]); + } + + { + auto rwBuff_Mut = pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_rwBuff_Mut"); + ASSERT_NE(rwBuff_Mut, nullptr); + EXPECT_EQ(rwBuff_Mut->GetResourceDesc().ArraySize, 1u); + EXPECT_EQ(rwBuff_Mut, pSRB->GetVariableByName(SHADER_TYPE_PIXEL, rwBuff_Mut->GetResourceDesc().Name)); + rwBuff_Mut->Set(pFormattedBuffUAV[1]); + } + + { + auto rwBuff_Dyn = pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_rwBuff_Dyn"); + ASSERT_NE(rwBuff_Dyn, nullptr); + EXPECT_EQ(rwBuff_Dyn->GetResourceDesc().ArraySize, 1u); + EXPECT_EQ(rwBuff_Dyn, pSRB->GetVariableByName(SHADER_TYPE_PIXEL, rwBuff_Dyn->GetResourceDesc().Name)); + rwBuff_Dyn->Set(pFormattedBuffUAV[2]); + } + + { + auto tex2D_Static = pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_tex2D_Static"); + EXPECT_EQ(tex2D_Static, nullptr); + } + + auto UniformBuff_Stat = pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "UniformBuff_Stat"); + EXPECT_EQ(UniformBuff_Stat, nullptr); + } + + + + { + auto NumVSVars = pSRB->GetVariableCount(SHADER_TYPE_VERTEX); + for (Uint32 v = 0; v < NumVSVars; ++v) + { + auto pVar = pSRB->GetVariableByIndex(SHADER_TYPE_VERTEX, v); + EXPECT_EQ(pVar->GetIndex(), v); + EXPECT_TRUE(pVar->GetType() == SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE || pVar->GetType() == SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC); + auto pVar2 = pSRB->GetVariableByName(SHADER_TYPE_VERTEX, pVar->GetResourceDesc().Name); + EXPECT_EQ(pVar, pVar2); + } + } + + { + auto NumPSVars = pSRB->GetVariableCount(SHADER_TYPE_PIXEL); + for (Uint32 v = 0; v < NumPSVars; ++v) + { + auto pVar = pSRB->GetVariableByIndex(SHADER_TYPE_PIXEL, v); + EXPECT_EQ(pVar->GetIndex(), v); + EXPECT_TRUE(pVar->GetType() == SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE || pVar->GetType() == SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC); + auto pVar2 = pSRB->GetVariableByName(SHADER_TYPE_PIXEL, pVar->GetResourceDesc().Name); + EXPECT_EQ(pVar, pVar2); + } + } + + pContext->SetRenderTargets(1, &pRTV, pDSV, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); + + pContext->SetPipelineState(pTestPSO); + pContext->CommitShaderResources(pSRB, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); + + DrawAttribs DrawAttrs(3, DRAW_FLAG_VERIFY_ALL); + pContext->Draw(DrawAttrs); + + pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_rwtex2D_Dyn")->Set(pTexUAVs[7]); + pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_tex2D_Dyn")->Set(pRWTexSRVs[3]); + pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_rwBuff_Dyn")->Set(pFormattedBuffUAV[3]); + pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_Buffer_Dyn")->Set(pFormattedBuffSRVs[2]); + + { + LOG_INFO_MESSAGE("No worries about 3 warnings below: testing accessing variables from inactive shader stage"); + auto pNonExistingVar = pSRB->GetVariableByName(SHADER_TYPE_GEOMETRY, "g_NonExistingVar"); + EXPECT_EQ(pNonExistingVar, nullptr); + pNonExistingVar = pSRB->GetVariableByIndex(SHADER_TYPE_GEOMETRY, 4); + EXPECT_EQ(pNonExistingVar, nullptr); + EXPECT_EQ(pSRB->GetVariableCount(SHADER_TYPE_GEOMETRY), 0u); + } + + float Zero[4] = {}; + pContext->ClearRenderTarget(pRTV, Zero, RESOURCE_STATE_TRANSITION_MODE_VERIFY); + pContext->ClearDepthStencil(pDSV, CLEAR_DEPTH_FLAG, 1, 0, RESOURCE_STATE_TRANSITION_MODE_VERIFY); + + pContext->CommitShaderResources(pSRB, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); + pContext->Draw(DrawAttrs); +} + +} // namespace diff --git a/Tests/DiligentCoreAPITest/src/TestingEnvironment.cpp b/Tests/DiligentCoreAPITest/src/TestingEnvironment.cpp new file mode 100644 index 00000000..dca742a8 --- /dev/null +++ b/Tests/DiligentCoreAPITest/src/TestingEnvironment.cpp @@ -0,0 +1,406 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "TestingEnvironment.h" +#include "PlatformDebug.h" +#include "TestingSwapChainBase.h" + +#if D3D11_SUPPORTED +# include "EngineFactoryD3D11.h" +#endif + +#if D3D12_SUPPORTED +# include "EngineFactoryD3D12.h" +#endif + +#if GL_SUPPORTED || GLES_SUPPORTED +# include "EngineFactoryOpenGL.h" +#endif + +#if VULKAN_SUPPORTED +# include "EngineFactoryVk.h" +#endif + +#if METAL_SUPPORTED +# include "EngineFactoryMtl.h" +#endif + +namespace Diligent +{ + +namespace Testing +{ + +TestingEnvironment* TestingEnvironment::m_pTheEnvironment = nullptr; +std::atomic_int TestingEnvironment::m_NumAllowedErrors; + +void TestingEnvironment::MessageCallback(DebugMessageSeverity Severity, + const Char* Message, + const char* Function, + const char* File, + int Line) +{ + if (Severity == DebugMessageSeverity::Error || Severity == DebugMessageSeverity::FatalError) + { + if (m_NumAllowedErrors == 0) + { + ADD_FAILURE() << "Unexpected error"; + } + else + { + m_NumAllowedErrors--; + } + } + + PlatformDebug::OutputDebugMessage(Severity, Message, Function, File, Line); +} + +void TestingEnvironment::SetErrorAllowance(int NumErrorsToAllow, const char* InfoMessage) +{ + m_NumAllowedErrors = NumErrorsToAllow; + if (InfoMessage != nullptr) + { + std::cout << InfoMessage; + } +} + + +TestingEnvironment::TestingEnvironment(DeviceType deviceType, ADAPTER_TYPE AdapterType, const SwapChainDesc& SCDesc) : + m_DeviceType{deviceType} +{ + VERIFY(m_pTheEnvironment == nullptr, "Testing environment object has already been initialized!"); + m_pTheEnvironment = this; + + Uint32 NumDeferredCtx = 0; + + std::vector ppContexts; + std::vector Adapters; + + auto PrintAdapterInfo = [](Uint32 AdapterId, const AdapterAttribs& AdapterInfo, const std::vector& DisplayModes) // + { + const char* AdapterTypeStr = nullptr; + switch (AdapterInfo.AdapterType) + { + case ADAPTER_TYPE_HARDWARE: AdapterTypeStr = "HW"; break; + case ADAPTER_TYPE_SOFTWARE: AdapterTypeStr = "SW"; break; + default: AdapterTypeStr = "Type unknown"; + } + LOG_INFO_MESSAGE("Adapter ", AdapterId, ": '", AdapterInfo.Description, "' (", + AdapterTypeStr, ", ", AdapterInfo.DedicatedVideoMemory / (1 << 20), " MB); ", + DisplayModes.size(), (DisplayModes.size() == 1 ? " display mode" : " display modes")); + }; + switch (m_DeviceType) + { +#if D3D11_SUPPORTED + case DeviceType::D3D11: + { +# if ENGINE_DLL + GetEngineFactoryD3D11Type GetEngineFactoryD3D11 = nullptr; + // Load the dll and import GetEngineFactoryD3D11() function + LoadGraphicsEngineD3D11(GetEngineFactoryD3D11); + if (GetEngineFactoryD3D11 == nullptr) + { + LOG_ERROR_AND_THROW("Failed to load the engine"); + } +# endif + + EngineD3D11CreateInfo CreateInfo; + CreateInfo.DebugMessageCallback = MessageCallback; + +# ifdef _DEBUG + CreateInfo.DebugFlags = + D3D11_DEBUG_FLAG_CREATE_DEBUG_DEVICE | + D3D11_DEBUG_FLAG_VERIFY_COMMITTED_RESOURCE_RELEVANCE | + D3D11_DEBUG_FLAG_VERIFY_COMMITTED_SHADER_RESOURCES; +# endif + auto* pFactoryD3D11 = GetEngineFactoryD3D11(); + Uint32 NumAdapters = 0; + pFactoryD3D11->EnumerateAdapters(DIRECT3D_FEATURE_LEVEL_11_0, NumAdapters, 0); + Adapters.resize(NumAdapters); + pFactoryD3D11->EnumerateAdapters(DIRECT3D_FEATURE_LEVEL_11_0, NumAdapters, Adapters.data()); + + LOG_INFO_MESSAGE("Found ", Adapters.size(), " compatible adapters"); + for (Uint32 i = 0; i < Adapters.size(); ++i) + { + const auto& AdapterInfo = Adapters[i]; + + std::vector DisplayModes; + if (AdapterInfo.NumOutputs > 0) + { + Uint32 NumDisplayModes = 0; + pFactoryD3D11->EnumerateDisplayModes(DIRECT3D_FEATURE_LEVEL_11_0, i, 0, TEX_FORMAT_RGBA8_UNORM, NumDisplayModes, nullptr); + DisplayModes.resize(NumDisplayModes); + pFactoryD3D11->EnumerateDisplayModes(DIRECT3D_FEATURE_LEVEL_11_0, i, 0, TEX_FORMAT_RGBA8_UNORM, NumDisplayModes, DisplayModes.data()); + } + + PrintAdapterInfo(i, AdapterInfo, DisplayModes); + } + if (AdapterType != ADAPTER_TYPE_UNKNOWN) + { + for (Uint32 i = 0; i < Adapters.size(); ++i) + { + if (Adapters[i].AdapterType == AdapterType && + CreateInfo.AdapterId == EngineD3D11CreateInfo::DefaultAdapterId) + { + CreateInfo.AdapterId = i; + LOG_INFO_MESSAGE("Using adapter ", i, ": '", Adapters[i].Description, "'"); + break; + } + } + } + + + CreateInfo.NumDeferredContexts = NumDeferredCtx; + ppContexts.resize(1 + NumDeferredCtx); + pFactoryD3D11->CreateDeviceAndContextsD3D11(CreateInfo, &m_pDevice, ppContexts.data()); + } + break; +#endif + +#if D3D12_SUPPORTED + case DeviceType::D3D12: + { +# if ENGINE_DLL + GetEngineFactoryD3D12Type GetEngineFactoryD3D12 = nullptr; + // Load the dll and import GetEngineFactoryD3D12() function + LoadGraphicsEngineD3D12(GetEngineFactoryD3D12); + if (GetEngineFactoryD3D12 == nullptr) + { + LOG_ERROR_AND_THROW("Failed to load the engine"); + } +# endif + auto* pFactoryD3D12 = GetEngineFactoryD3D12(); + + Uint32 NumAdapters = 0; + pFactoryD3D12->EnumerateAdapters(DIRECT3D_FEATURE_LEVEL_11_0, NumAdapters, 0); + Adapters.resize(NumAdapters); + pFactoryD3D12->EnumerateAdapters(DIRECT3D_FEATURE_LEVEL_11_0, NumAdapters, Adapters.data()); + + EngineD3D12CreateInfo CreateInfo; + CreateInfo.DebugMessageCallback = MessageCallback; + + LOG_INFO_MESSAGE("Found ", Adapters.size(), " compatible adapters"); + for (Uint32 i = 0; i < Adapters.size(); ++i) + { + const auto& AdapterInfo = Adapters[i]; + + std::vector DisplayModes; + if (AdapterInfo.NumOutputs > 0) + { + Uint32 NumDisplayModes = 0; + pFactoryD3D12->EnumerateDisplayModes(DIRECT3D_FEATURE_LEVEL_11_0, i, 0, TEX_FORMAT_RGBA8_UNORM, NumDisplayModes, nullptr); + DisplayModes.resize(NumDisplayModes); + pFactoryD3D12->EnumerateDisplayModes(DIRECT3D_FEATURE_LEVEL_11_0, i, 0, TEX_FORMAT_RGBA8_UNORM, NumDisplayModes, DisplayModes.data()); + } + + PrintAdapterInfo(i, AdapterInfo, DisplayModes); + } + if (AdapterType != ADAPTER_TYPE_UNKNOWN) + { + for (Uint32 i = 0; i < Adapters.size(); ++i) + { + if (Adapters[i].AdapterType == AdapterType && + CreateInfo.AdapterId == EngineD3D11CreateInfo::DefaultAdapterId) + { + CreateInfo.AdapterId = i; + LOG_INFO_MESSAGE("Using adapter ", i, ": '", Adapters[i].Description, "'"); + break; + } + } + } + CreateInfo.EnableDebugLayer = true; + //CreateInfo.EnableGPUBasedValidation = true; + CreateInfo.CPUDescriptorHeapAllocationSize[0] = 64; // D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV + CreateInfo.CPUDescriptorHeapAllocationSize[1] = 32; // D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER + CreateInfo.CPUDescriptorHeapAllocationSize[2] = 16; // D3D12_DESCRIPTOR_HEAP_TYPE_RTV + CreateInfo.CPUDescriptorHeapAllocationSize[3] = 16; // D3D12_DESCRIPTOR_HEAP_TYPE_DSV + CreateInfo.DynamicDescriptorAllocationChunkSize[0] = 8; // D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV + CreateInfo.DynamicDescriptorAllocationChunkSize[1] = 8; // D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER + ppContexts.resize(1 + NumDeferredCtx); + + CreateInfo.NumDeferredContexts = NumDeferredCtx; + pFactoryD3D12->CreateDeviceAndContextsD3D12(CreateInfo, &m_pDevice, ppContexts.data()); + } + break; +#endif + +#if GL_SUPPORTED || GLES_SUPPORTED + case DeviceType::OpenGL: + case DeviceType::OpenGLES: + { +# if EXPLICITLY_LOAD_ENGINE_GL_DLL + // Declare function pointer + GetEngineFactoryOpenGLType GetEngineFactoryOpenGL = nullptr; + // Load the dll and import GetEngineFactoryOpenGL() function + LoadGraphicsEngineOpenGL(GetEngineFactoryOpenGL); + if (GetEngineFactoryOpenGL == nullptr) + { + LOG_ERROR_AND_THROW("Failed to load the engine"); + } +# endif + auto* pFactoryOpenGL = GetEngineFactoryOpenGL(); + + auto NativeWnd = CreateNativeWindow(); + + EngineGLCreateInfo CreateInfo; + CreateInfo.DebugMessageCallback = MessageCallback; + CreateInfo.pNativeWndHandle = NativeWnd.NativeWindowHandle; +# if PLATFORM_LINUX + CreateInfo.pDisplay = NativeWnd.Display; +# endif + if (NumDeferredCtx != 0) + { + LOG_ERROR_MESSAGE("Deferred contexts are not supported in OpenGL mode"); + NumDeferredCtx = 0; + } + ppContexts.resize(1 + NumDeferredCtx); + RefCntAutoPtr pSwapChain; // We will use testing swap chain instead + pFactoryOpenGL->CreateDeviceAndSwapChainGL( + CreateInfo, &m_pDevice, ppContexts.data(), SCDesc, &pSwapChain); + } + break; +#endif + +#if VULKAN_SUPPORTED + case DeviceType::Vulkan: + { +# if EXPLICITLY_LOAD_ENGINE_VK_DLL + GetEngineFactoryVkType GetEngineFactoryVk = nullptr; + // Load the dll and import GetEngineFactoryVk() function + LoadGraphicsEngineVk(GetEngineFactoryVk); + if (GetEngineFactoryVk == nullptr) + { + LOG_ERROR_AND_THROW("Failed to load the engine"); + } +# endif + + EngineVkCreateInfo CreateInfo; + CreateInfo.DebugMessageCallback = MessageCallback; + CreateInfo.EnableValidation = true; + CreateInfo.MainDescriptorPoolSize = EngineVkCreateInfo::DescriptorPoolSize{64, 64, 256, 256, 64, 32, 32, 32, 32}; + CreateInfo.DynamicDescriptorPoolSize = EngineVkCreateInfo::DescriptorPoolSize{64, 64, 256, 256, 64, 32, 32, 32, 32}; + CreateInfo.UploadHeapPageSize = 32 * 1024; + //CreateInfo.DeviceLocalMemoryReserveSize = 32 << 20; + //CreateInfo.HostVisibleMemoryReserveSize = 48 << 20; + + auto& Features = CreateInfo.EnabledFeatures; + Features.depthBiasClamp = true; + Features.fillModeNonSolid = true; + Features.depthClamp = true; + Features.independentBlend = true; + Features.samplerAnisotropy = true; + Features.geometryShader = true; + Features.tessellationShader = true; + Features.dualSrcBlend = true; + Features.multiViewport = true; + Features.imageCubeArray = true; + Features.textureCompressionBC = true; + Features.vertexPipelineStoresAndAtomics = true; + Features.fragmentStoresAndAtomics = true; + + CreateInfo.NumDeferredContexts = NumDeferredCtx; + ppContexts.resize(1 + NumDeferredCtx); + auto* pFactoryVk = GetEngineFactoryVk(); + pFactoryVk->CreateDeviceAndContextsVk(CreateInfo, &m_pDevice, ppContexts.data()); + } + break; +#endif + +#if METAL_SUPPORTED + case DeviceType::Metal: + { + EngineMtlCreateInfo MtlAttribs; + + MtlAttribs.DebugMessageCallback = MessageCallback; + MtlAttribs.NumDeferredContexts = NumDeferredCtx; + ppContexts.resize(1 + NumDeferredCtx); + auto* pFactoryMtl = GetEngineFactoryMtl(); + pFactoryMtl->CreateDeviceAndContextsMtl(MtlAttribs, &m_pDevice, ppContexts.data()); + } + break; +#endif + + default: + LOG_ERROR_AND_THROW("Unknown device type"); + break; + } + m_pDeviceContext.Attach(ppContexts[0]); +} + +TestingEnvironment::~TestingEnvironment() +{ + m_pDeviceContext->Flush(); + m_pDeviceContext->FinishFrame(); +} + +// Override this to define how to set up the environment. +void TestingEnvironment::SetUp() +{ +} + +// Override this to define how to tear down the environment. +void TestingEnvironment::TearDown() +{ +} + +void TestingEnvironment::ReleaseResources() +{ + // It is necessary to call Flush() to force the driver to release resources. + // Without flushing the command buffer, the memory may not be released until sometimes + // later causing out-of-memory error. + m_pDeviceContext->Flush(); + m_pDeviceContext->FinishFrame(); + m_pDevice->ReleaseStaleResources(); +} + +void TestingEnvironment::Reset() +{ + m_pDeviceContext->Flush(); + m_pDeviceContext->FinishFrame(); + m_pDevice->IdleGPU(); + m_pDevice->ReleaseStaleResources(); + m_pDeviceContext->InvalidateState(); + m_NumAllowedErrors = 0; +} + +RefCntAutoPtr TestingEnvironment::CreateTexture(const char* Name, TEXTURE_FORMAT Fmt, BIND_FLAGS BindFlags, Uint32 Width, Uint32 Height) +{ + TextureDesc TexDesc; + + TexDesc.Name = Name; + TexDesc.Type = RESOURCE_DIM_TEX_2D; + TexDesc.Format = Fmt; + TexDesc.BindFlags = BindFlags; + TexDesc.Width = Width; + TexDesc.Height = Height; + + RefCntAutoPtr pTexture; + m_pDevice->CreateTexture(TexDesc, nullptr, &pTexture); + VERIFY_EXPR(pTexture != nullptr); + + return pTexture; +} + +} // namespace Testing + +} // namespace Diligent diff --git a/Tests/DiligentCoreAPITest/src/TestingSwapChainBase.cpp b/Tests/DiligentCoreAPITest/src/TestingSwapChainBase.cpp new file mode 100644 index 00000000..2307ed9a --- /dev/null +++ b/Tests/DiligentCoreAPITest/src/TestingSwapChainBase.cpp @@ -0,0 +1,111 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include +#include +#include + +#include "TestingSwapChainBase.h" +#include "GraphicsAccessories.h" + +#define STB_IMAGE_WRITE_IMPLEMENTATION +#include "../../../ThirdParty/stb/stb_image_write.h" + +namespace Diligent +{ + +namespace Testing +{ + +void CompareTestImages(const Uint8* pReferencePixels, + Uint32 RefPixelsStride, + const Uint8* pPixels, + Uint32 PixelsStride, + Uint32 Width, + Uint32 Height, + TEXTURE_FORMAT Format) +{ + VERIFY_EXPR(pReferencePixels != nullptr); + VERIFY_EXPR(pPixels != nullptr); + VERIFY_EXPR(Width != 0); + VERIFY_EXPR(Height != 0); + VERIFY_EXPR(PixelsStride != 0); + VERIFY_EXPR(RefPixelsStride != 0); + VERIFY(Format == TEX_FORMAT_RGBA8_UNORM, GetTextureFormatAttribs(Format).Name, " is not supported"); + + bool bIsIdentical = true; + + for (Uint32 row = 0; row < Height; ++row) + { + if (memcmp(pReferencePixels + row * RefPixelsStride, + pPixels + row * PixelsStride, + Width * 4) != 0) + { + bIsIdentical = false; + } + } + + if (bIsIdentical) + { + } + else + { + auto ReportImageStride = (Width * 2) * 3; + + std::vector ReportImage(ReportImageStride * (Height * 2)); + for (Uint32 row = 0; row < Height; ++row) + { + for (Uint32 col = 0; col < Width; ++col) + { + for (Uint32 c = 0; c < 3; ++c) + { + auto RefVal = pReferencePixels[row * RefPixelsStride + col * 4 + c]; + auto Val = pPixels[row * PixelsStride + col * 4 + c]; + auto diff = static_cast(std::min(std::abs(int{RefVal} - int{Val}), 255)); + + // clang-format off + ReportImage[row * ReportImageStride + col * 3 + c] = RefVal; + ReportImage[row * ReportImageStride + (Width + col) * 3 + c] = Val; + ReportImage[(row + Height) * ReportImageStride + col * 3 + c] = diff; + ReportImage[(row + Height) * ReportImageStride + (Width + col) * 3 + c] = static_cast(std::min(diff*16, 255)); + // clang-format on + } + } + } + const auto* const TestInfo = ::testing::UnitTest::GetInstance()->current_test_info(); + + std::string FileName = TestInfo->test_suite_name(); + FileName += '.'; + FileName += TestInfo->name(); + FileName += "_FAIL_.png"; + if (stbi_write_png(FileName.c_str(), Width * 2, Height * 2, 3, ReportImage.data(), (Width * 2) * 3) == 0) + { + LOG_ERROR_MESSAGE("Failed to write ", FileName); + } + ADD_FAILURE() << "Captured image is not identical to the reference image"; + } +} + +} // namespace Testing + +} // namespace Diligent diff --git a/Tests/DiligentCoreAPITest/src/TextureCreationTest.cpp b/Tests/DiligentCoreAPITest/src/TextureCreationTest.cpp new file mode 100644 index 00000000..7fe667a4 --- /dev/null +++ b/Tests/DiligentCoreAPITest/src/TextureCreationTest.cpp @@ -0,0 +1,747 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include + +#include "RenderDevice.h" +#include "GraphicsAccessories.h" + +#if D3D11_SUPPORTED +# include "D3D11/CreateObjFromNativeResD3D11.h" +#endif + +#if D3D12_SUPPORTED +# include "D3D12/CreateObjFromNativeResD3D12.h" +#endif + +#if GL_SUPPORTED || GLES_SUPPORTED +# include "GL/CreateObjFromNativeResGL.h" +#endif + +#if VULKAN_SUPPORTED +# include "Vulkan/CreateObjFromNativeResVK.h" +#endif + +#include "TestingEnvironment.h" + +#include "gtest/gtest.h" + +using namespace Diligent; +using namespace Diligent::Testing; + +namespace +{ + +struct TextureTestAttribs +{ + TEXTURE_FORMAT Fmt; + Uint32 PixelSize; + BIND_FLAGS BindFlags; + Bool TestDataUpload; +}; + +class TextureCreationTest : public testing::TestWithParam +{ +protected: + static void SetUpTestSuite() + { + auto* pEnv = TestingEnvironment::GetInstance(); + auto* pDevice = pEnv->GetDevice(); + + const auto DevCaps = pDevice->GetDeviceCaps(); + switch (DevCaps.DevType) + { +#if D3D11_SUPPORTED + case DeviceType::D3D11: + pCreateObjFromNativeRes.reset(new TestCreateObjFromNativeResD3D11(pDevice)); + break; + +#endif + +#if D3D12_SUPPORTED + case DeviceType::D3D12: + pCreateObjFromNativeRes.reset(new TestCreateObjFromNativeResD3D12(pDevice)); + break; +#endif + +#if GL_SUPPORTED || GLES_SUPPORTED + case DeviceType::OpenGL: + case DeviceType::OpenGLES: + pCreateObjFromNativeRes.reset(new TestCreateObjFromNativeResGL(pDevice)); + break; +#endif + +#if VULKAN_SUPPORTED + case DeviceType::Vulkan: + pCreateObjFromNativeRes.reset(new TestCreateObjFromNativeResVK(pDevice)); + break; +#endif + + default: UNEXPECTED("Unexpected device type"); + } + } + + static void TearDownTestSuite() + { + pCreateObjFromNativeRes.reset(); + TestingEnvironment::GetInstance()->Reset(); + } + + static void PrepareSubresourceData(const TextureDesc& TexDesc, + const TextureFormatInfo& FmtInfo, + std::vector>& Data, + std::vector& SubResources, + TextureData& InitData) + { + Uint32 ArrSize = (TexDesc.Type == RESOURCE_DIM_TEX_3D) ? 1 : TexDesc.ArraySize; + + VERIFY(FmtInfo.ComponentType != COMPONENT_TYPE_COMPRESSED, "Uploading data to compressed formats is not yet being tested"); + + InitData.NumSubresources = ArrSize * TexDesc.MipLevels; + Data.resize(InitData.NumSubresources); + SubResources.resize(InitData.NumSubresources); + Uint32 SubRes = 0; + for (Uint32 Slice = 0; Slice < ArrSize; ++Slice) + { + for (Uint32 Mip = 0; Mip < TexDesc.MipLevels; ++Mip) + { + auto MipLevelInfo = GetMipLevelProperties(TexDesc, Mip); + + auto& CurrSubResData = Data[SubRes]; + auto& SubResInfo = SubResources[SubRes]; + + SubResInfo.Stride = ((MipLevelInfo.RowSize + 3) & (-4)) + 192; + auto SubresDataSize = 0; + if (TexDesc.Type == RESOURCE_DIM_TEX_3D) + { + SubResInfo.DepthStride = (MipLevelInfo.StorageHeight + 32) * SubResInfo.Stride; + SubresDataSize = SubResInfo.DepthStride * MipLevelInfo.Depth; + } + else + SubresDataSize = SubResInfo.Stride * MipLevelInfo.StorageHeight; + + CurrSubResData.resize(SubresDataSize); + SubResInfo.pData = CurrSubResData.data(); + ++SubRes; + } + } + InitData.pSubResources = SubResources.data(); + } + + + static void CreateTestTexture(RESOURCE_DIMENSION Type, + TEXTURE_FORMAT TextureFormat, + BIND_FLAGS BindFlags, + Uint32 SampleCount, + bool UploadData) + { + auto* pEnv = TestingEnvironment::GetInstance(); + + auto* pDevice = pEnv->GetDevice(); + auto* pDeviceContext = pEnv->GetDeviceContext(); + const auto& deviceCaps = pDevice->GetDeviceCaps(); + const auto& TexCaps = deviceCaps.TexCaps; + + TextureDesc TexDesc; + TexDesc.Name = "Test Texture"; + TexDesc.Type = Type; + TexDesc.Width = 211; + if (TexDesc.Type == RESOURCE_DIM_TEX_1D || TexDesc.Type == RESOURCE_DIM_TEX_1D_ARRAY) + TexDesc.Height = 1; + else + TexDesc.Height = 243; + + if (TexDesc.Type == RESOURCE_DIM_TEX_3D) + TexDesc.Depth = 16; + + if (TexDesc.Type == RESOURCE_DIM_TEX_1D_ARRAY || TexDesc.Type == RESOURCE_DIM_TEX_2D_ARRAY) + TexDesc.ArraySize = 16; + + const auto& FmtInfo = pDevice->GetTextureFormatInfoExt(TextureFormat); + if (FmtInfo.ComponentType == COMPONENT_TYPE_COMPRESSED) + { + TexDesc.Width = (TexDesc.Width + 3) & (-4); + TexDesc.Height = (TexDesc.Height + 3) & (-4); + } + + TexDesc.MipLevels = SampleCount == 1 ? 0 : 1; + TexDesc.Format = TextureFormat; + TexDesc.Usage = USAGE_DEFAULT; + TexDesc.BindFlags = BindFlags; + if (SampleCount > 1) + TexDesc.BindFlags &= ~BIND_UNORDERED_ACCESS; + + TexDesc.SampleCount = SampleCount; + + RefCntAutoPtr pTestTex; + TextureData NullData; + pDevice->CreateTexture(TexDesc, &NullData, &pTestTex); + ASSERT_NE(pTestTex, nullptr) << GetObjectDescString(TexDesc); + + pCreateObjFromNativeRes->CreateTexture(pTestTex); + TexDesc.MipLevels = pTestTex->GetDesc().MipLevels; + if (SampleCount == 1 && UploadData) + { + std::vector> Data; + std::vector SubResources; + TextureData InitData; + + PrepareSubresourceData(TexDesc, FmtInfo, Data, SubResources, InitData); + + TexDesc.Name = "Test Texture 2"; + RefCntAutoPtr pTestTex2; + pDevice->CreateTexture(TexDesc, &InitData, &pTestTex2); + ASSERT_NE(pTestTex2, nullptr) << GetObjectDescString(TexDesc); + + pCreateObjFromNativeRes->CreateTexture(pTestTex2); + + if (deviceCaps.DevType == DeviceType::D3D11 && + ((TexDesc.BindFlags & BIND_DEPTH_STENCIL) != 0 || TexDesc.SampleCount > 1)) + { + // In D3D11 if CopySubresourceRegion is used with Multisampled or D3D11_BIND_DEPTH_STENCIL Resources, + // then the whole Subresource must be copied. + CopyTextureAttribs CopyAttribs(pTestTex2, RESOURCE_STATE_TRANSITION_MODE_TRANSITION, pTestTex, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); + pDeviceContext->CopyTexture(CopyAttribs); + } + else + { + Box SrcBox; + SrcBox.MinX = TexDesc.Width / 4; + SrcBox.MinY = TexDesc.Height / 4; + SrcBox.MinZ = (TexDesc.Type == RESOURCE_DIM_TEX_3D) ? TexDesc.Depth / 4 : 0; + SrcBox.MaxX = std::max(TexDesc.Width / 3, SrcBox.MinX + 1); + SrcBox.MaxY = std::max(TexDesc.Height / 3, SrcBox.MinY + 1); + SrcBox.MaxZ = (TexDesc.Type == RESOURCE_DIM_TEX_3D) ? std::max(TexDesc.Depth / 3, SrcBox.MinZ + 1) : 1; + //pTestTex2->UpdateData(m_pDeviceContext, 0, 0, DstBox, SubResources[0]); + CopyTextureAttribs CopyAttribs(pTestTex2, RESOURCE_STATE_TRANSITION_MODE_TRANSITION, pTestTex, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); + CopyAttribs.pSrcBox = &SrcBox; + pDeviceContext->CopyTexture(CopyAttribs); + } + } + + if (!TexCaps.bTextureViewSupported) + { + LOG_WARNING_MESSAGE_ONCE("Texture views are not supported!\n"); + } + + if (TexCaps.bTextureViewSupported && !FmtInfo.IsTypeless) + { + TextureViewDesc ViewDesc; + ViewDesc.TextureDim = TexDesc.Type; + + if (SampleCount > 1) + { + ViewDesc.MostDetailedMip = 0; + ViewDesc.NumMipLevels = 1; + } + else + { + ViewDesc.MostDetailedMip = 1; + ViewDesc.NumMipLevels = 2; + } + + if (TexDesc.Type == RESOURCE_DIM_TEX_1D_ARRAY || TexDesc.Type == RESOURCE_DIM_TEX_2D_ARRAY) + { + ViewDesc.FirstArraySlice = 3; + ViewDesc.NumArraySlices = (deviceCaps.DevType == DeviceType::D3D11 || deviceCaps.DevType == DeviceType::D3D12 || ViewDesc.ViewType == TEXTURE_VIEW_SHADER_RESOURCE) ? 4 : 1; + } + else if (TexDesc.Type == RESOURCE_DIM_TEX_3D) + { + if (deviceCaps.DevType == DeviceType::D3D11 || deviceCaps.DevType == DeviceType::D3D12) + { + ViewDesc.FirstDepthSlice = 3; + ViewDesc.NumDepthSlices = 4; + } + else if ((deviceCaps.DevType == DeviceType::Vulkan && ViewDesc.ViewType != TEXTURE_VIEW_RENDER_TARGET && ViewDesc.ViewType != TEXTURE_VIEW_DEPTH_STENCIL) || + deviceCaps.DevType != DeviceType::Vulkan) + { + // OpenGL cannot create views for separate depth slices + ViewDesc.FirstDepthSlice = 0; + ViewDesc.NumDepthSlices = TexDesc.Depth >> ViewDesc.MostDetailedMip; + } + } + else + { + ViewDesc.FirstArraySlice = 0; + ViewDesc.NumArraySlices = 1; + } + + if (TexDesc.BindFlags & BIND_SHADER_RESOURCE) + { + ViewDesc.ViewType = TEXTURE_VIEW_SHADER_RESOURCE; + RefCntAutoPtr pSRV; + pTestTex->CreateView(ViewDesc, &pSRV); + EXPECT_NE(pSRV, nullptr) << GetObjectDescString(TexDesc); + } + + // RTV, DSV & UAV can reference only one mip level + ViewDesc.NumMipLevels = 1; + + if (TexDesc.BindFlags & BIND_RENDER_TARGET) + { + ViewDesc.ViewType = TEXTURE_VIEW_RENDER_TARGET; + RefCntAutoPtr pRTV; + pTestTex->CreateView(ViewDesc, &pRTV); + EXPECT_NE(pRTV, nullptr) << GetObjectDescString(TexDesc); + } + + if (TexDesc.BindFlags & BIND_DEPTH_STENCIL) + { + ViewDesc.ViewType = TEXTURE_VIEW_DEPTH_STENCIL; + RefCntAutoPtr pDSV; + pTestTex->CreateView(ViewDesc, &pDSV); + EXPECT_NE(pDSV, nullptr) << GetObjectDescString(TexDesc); + } + + if (TexDesc.BindFlags & BIND_UNORDERED_ACCESS) + { + ViewDesc.ViewType = TEXTURE_VIEW_UNORDERED_ACCESS; + ViewDesc.AccessFlags = UAV_ACCESS_FLAG_READ | UAV_ACCESS_FLAG_WRITE; + RefCntAutoPtr pUAV; + pTestTex->CreateView(ViewDesc, &pUAV); + EXPECT_NE(pUAV, nullptr) << GetObjectDescString(TexDesc); + } + } + + // Flush, FinishFrame, and ReleaseStaleResources. + pEnv->ReleaseResources(); + } + + void CreateTestCubemap(TEXTURE_FORMAT TextureFormat, + BIND_FLAGS BindFlags, + bool UploadData) + { + auto* pEnv = TestingEnvironment::GetInstance(); + + auto* pDevice = pEnv->GetDevice(); + const auto& deviceCaps = pDevice->GetDeviceCaps(); + const auto& TexCaps = deviceCaps.TexCaps; + + TextureDesc TexDesc; + TexDesc.Name = "Test Cube MapTextureCreation"; + TexDesc.Type = RESOURCE_DIM_TEX_CUBE; + TexDesc.Width = 256; + TexDesc.Height = 256; + TexDesc.ArraySize = 6; + TexDesc.MipLevels = 0; + TexDesc.Format = TextureFormat; + TexDesc.Usage = USAGE_DEFAULT; + TexDesc.BindFlags = BindFlags; + TexDesc.SampleCount = 1; + + RefCntAutoPtr pTestCubemap, pTestCubemapArr; + pDevice->CreateTexture(TexDesc, nullptr, &pTestCubemap); + ASSERT_NE(pTestCubemap, nullptr) << GetObjectDescString(TexDesc); + pCreateObjFromNativeRes->CreateTexture(pTestCubemap); + TexDesc.MipLevels = pTestCubemap->GetDesc().MipLevels; + + const auto& FmtInfo = pDevice->GetTextureFormatInfoExt(TextureFormat); + if (UploadData) + { + std::vector> Data; + std::vector SubResources; + TextureData InitData; + + PrepareSubresourceData(TexDesc, FmtInfo, Data, SubResources, InitData); + + InitData.pSubResources = SubResources.data(); + TexDesc.Name = "TestCubemap2"; + pTestCubemap.Release(); + pDevice->CreateTexture(TexDesc, &InitData, &pTestCubemap); + ASSERT_NE(pTestCubemap, nullptr) << GetObjectDescString(TexDesc); + pCreateObjFromNativeRes->CreateTexture(pTestCubemap); + } + + if (TexCaps.bTextureViewSupported && !FmtInfo.IsTypeless) + { + TextureViewDesc ViewDesc; + if (TexDesc.BindFlags & BIND_SHADER_RESOURCE) + { + ViewDesc.TextureDim = RESOURCE_DIM_TEX_CUBE; + ViewDesc.ViewType = TEXTURE_VIEW_SHADER_RESOURCE; + ViewDesc.MostDetailedMip = 1; + ViewDesc.NumMipLevels = 6; + { + RefCntAutoPtr pSRV; + pTestCubemap->CreateView(ViewDesc, &pSRV); + EXPECT_NE(pSRV, nullptr) << GetObjectDescString(TexDesc); + } + + ViewDesc.TextureDim = RESOURCE_DIM_TEX_2D; + ViewDesc.FirstArraySlice = 0; + ViewDesc.NumArraySlices = 1; + ViewDesc.MostDetailedMip = 2; + ViewDesc.NumMipLevels = 4; + { + RefCntAutoPtr pSRV; + pTestCubemap->CreateView(ViewDesc, &pSRV); + EXPECT_NE(pSRV, nullptr) << GetObjectDescString(TexDesc); + } + + ViewDesc.TextureDim = RESOURCE_DIM_TEX_2D_ARRAY; + ViewDesc.FirstArraySlice = 2; + ViewDesc.NumArraySlices = 3; + { + RefCntAutoPtr pSRV; + pTestCubemap->CreateView(ViewDesc, &pSRV); + EXPECT_NE(pSRV, nullptr) << GetObjectDescString(TexDesc); + } + } + + // RTV, DSV & UAV can reference only one mip level + ViewDesc.NumMipLevels = 1; + + if (TexDesc.BindFlags & BIND_RENDER_TARGET) + { + ViewDesc.ViewType = TEXTURE_VIEW_RENDER_TARGET; + ViewDesc.TextureDim = RESOURCE_DIM_TEX_2D; + ViewDesc.FirstArraySlice = 0; + ViewDesc.NumArraySlices = 1; + { + RefCntAutoPtr pRTV; + pTestCubemap->CreateView(ViewDesc, &pRTV); + EXPECT_NE(pRTV, nullptr) << GetObjectDescString(TexDesc); + } + + ViewDesc.TextureDim = RESOURCE_DIM_TEX_2D_ARRAY; + ViewDesc.FirstArraySlice = 2; + ViewDesc.NumArraySlices = 3; + { + RefCntAutoPtr pRTV; + pTestCubemap->CreateView(ViewDesc, &pRTV); + EXPECT_NE(pRTV, nullptr) << GetObjectDescString(TexDesc); + } + } + + if (TexDesc.BindFlags & BIND_DEPTH_STENCIL) + { + ViewDesc.ViewType = TEXTURE_VIEW_DEPTH_STENCIL; + ViewDesc.TextureDim = RESOURCE_DIM_TEX_2D; + ViewDesc.NumArraySlices = 1; + ViewDesc.FirstArraySlice = 0; + ViewDesc.MostDetailedMip = 2; + { + RefCntAutoPtr pDSV; + pTestCubemap->CreateView(ViewDesc, &pDSV); + EXPECT_NE(pDSV, nullptr) << GetObjectDescString(TexDesc); + } + + ViewDesc.TextureDim = RESOURCE_DIM_TEX_2D_ARRAY; + ViewDesc.NumArraySlices = 3; + ViewDesc.FirstArraySlice = 2; + { + RefCntAutoPtr pDSV; + pTestCubemap->CreateView(ViewDesc, &pDSV); + EXPECT_NE(pDSV, nullptr) << GetObjectDescString(TexDesc); + } + } + + if (TexDesc.BindFlags & BIND_UNORDERED_ACCESS) + { + ViewDesc.ViewType = TEXTURE_VIEW_UNORDERED_ACCESS; + ViewDesc.AccessFlags = UAV_ACCESS_FLAG_READ | UAV_ACCESS_FLAG_WRITE; + ViewDesc.TextureDim = RESOURCE_DIM_TEX_2D; + ViewDesc.NumArraySlices = 1; + ViewDesc.FirstArraySlice = 0; + { + RefCntAutoPtr pUAV; + pTestCubemap->CreateView(ViewDesc, &pUAV); + EXPECT_NE(pUAV, nullptr) << GetObjectDescString(TexDesc); + } + + ViewDesc.TextureDim = RESOURCE_DIM_TEX_2D_ARRAY; + if (deviceCaps.DevType == DeviceType::OpenGL || deviceCaps.DevType == DeviceType::OpenGLES) + { + ViewDesc.NumArraySlices = 1; + ViewDesc.FirstArraySlice = 2; + } + else + { + ViewDesc.NumArraySlices = 3; + ViewDesc.FirstArraySlice = 2; + } + + { + RefCntAutoPtr pUAV; + pTestCubemap->CreateView(ViewDesc, &pUAV); + EXPECT_NE(pUAV, nullptr) << GetObjectDescString(TexDesc); + } + } + } + + if (deviceCaps.TexCaps.bCubemapArraysSupported) + { + TexDesc.ArraySize = 24; + TexDesc.Type = RESOURCE_DIM_TEX_CUBE_ARRAY; + + std::vector> Data; + std::vector SubResources; + TextureData InitData; + + if (UploadData) + { + PrepareSubresourceData(TexDesc, FmtInfo, Data, SubResources, InitData); + } + + TexDesc.Name = "TestCubemapArray"; + + pDevice->CreateTexture(TexDesc, &InitData, &pTestCubemapArr); + EXPECT_NE(pTestCubemapArr, nullptr) << GetObjectDescString(TexDesc); + pCreateObjFromNativeRes->CreateTexture(pTestCubemapArr); + } + + // Flush, FinishFrame, and ReleaseStaleResources. + pEnv->ReleaseResources(); + } + + static std::unique_ptr pCreateObjFromNativeRes; +}; + +std::unique_ptr TextureCreationTest::pCreateObjFromNativeRes; + +TEST_P(TextureCreationTest, CreateTexture) +{ + auto* pEnv = TestingEnvironment::GetInstance(); + auto* pDevice = pEnv->GetDevice(); + + const auto& TestInfo = GetParam(); + + const auto& FmtInfo = pDevice->GetTextureFormatInfoExt(TestInfo.Fmt); + + if (!FmtInfo.Supported) + { + GTEST_SKIP() << "Texture format " << FmtInfo.Name << " is not supported"; + } + + EXPECT_TRUE(TestInfo.PixelSize == Uint32{FmtInfo.ComponentSize} * Uint32{FmtInfo.NumComponents} || + FmtInfo.ComponentType == COMPONENT_TYPE_COMPRESSED); + + const auto& TexCaps = pDevice->GetDeviceCaps().TexCaps; + // Test texture 1D / texture 1D array + if (TexCaps.bTexture1DSupported) + { + if (FmtInfo.Tex1DFmt) + CreateTestTexture(RESOURCE_DIM_TEX_1D, TestInfo.Fmt, TestInfo.BindFlags, 1, TestInfo.TestDataUpload); + } + else + { + LOG_WARNING_MESSAGE_ONCE("Texture 1D is not supported\n"); + } + + if (TexCaps.bTexture1DArraySupported) + { + if (FmtInfo.Tex1DFmt) + CreateTestTexture(RESOURCE_DIM_TEX_1D_ARRAY, TestInfo.Fmt, TestInfo.BindFlags, 1, TestInfo.TestDataUpload); + } + else + { + LOG_WARNING_MESSAGE_ONCE("Texture 1D array is not supported\n"); + } + + // Test texture 2D / texture 2D array + CreateTestTexture(RESOURCE_DIM_TEX_2D, TestInfo.Fmt, TestInfo.BindFlags, 1, TestInfo.TestDataUpload); + CreateTestTexture(RESOURCE_DIM_TEX_2D, TestInfo.Fmt, TestInfo.BindFlags, 1, TestInfo.TestDataUpload); + CreateTestTexture(RESOURCE_DIM_TEX_2D_ARRAY, TestInfo.Fmt, TestInfo.BindFlags, 1, TestInfo.TestDataUpload); + CreateTestTexture(RESOURCE_DIM_TEX_2D_ARRAY, TestInfo.Fmt, TestInfo.BindFlags, 1, TestInfo.TestDataUpload); + CreateTestCubemap(TestInfo.Fmt, TestInfo.BindFlags, TestInfo.TestDataUpload); + + if (TestInfo.Fmt != TEX_FORMAT_RGB9E5_SHAREDEXP && + FmtInfo.ComponentType != COMPONENT_TYPE_COMPRESSED) + { + if (TexCaps.bTexture2DMSSupported) + { + if ((FmtInfo.SampleCounts & 0x04) != 0 && (TestInfo.BindFlags & (BIND_RENDER_TARGET | BIND_DEPTH_STENCIL)) != 0) + { + CreateTestTexture(RESOURCE_DIM_TEX_2D, TestInfo.Fmt, TestInfo.BindFlags, 4, TestInfo.TestDataUpload); + CreateTestTexture(RESOURCE_DIM_TEX_2D, TestInfo.Fmt, TestInfo.BindFlags, 4, TestInfo.TestDataUpload); + } + } + else + { + LOG_WARNING_MESSAGE_ONCE("Texture 2D MS is not supported\n"); + } + + if (TexCaps.bTexture2DMSArraySupported) + { + if ((FmtInfo.SampleCounts & 0x04) != 0 && (TestInfo.BindFlags & (BIND_RENDER_TARGET | BIND_DEPTH_STENCIL)) != 0) + { + CreateTestTexture(RESOURCE_DIM_TEX_2D_ARRAY, TestInfo.Fmt, TestInfo.BindFlags, 4, TestInfo.TestDataUpload); + CreateTestTexture(RESOURCE_DIM_TEX_2D_ARRAY, TestInfo.Fmt, TestInfo.BindFlags, 4, TestInfo.TestDataUpload); + } + } + else + { + LOG_WARNING_MESSAGE_ONCE("Texture 2D MS Array is not supported\n"); + } + } + + // Test texture 3D + if (FmtInfo.Tex3DFmt) + CreateTestTexture(RESOURCE_DIM_TEX_3D, TestInfo.Fmt, TestInfo.BindFlags, 1, TestInfo.TestDataUpload); +} + + + +constexpr BIND_FLAGS BindSRU = BIND_SHADER_RESOURCE | BIND_RENDER_TARGET | BIND_UNORDERED_ACCESS; +constexpr BIND_FLAGS BindSR = BIND_SHADER_RESOURCE | BIND_RENDER_TARGET; +//constexpr BIND_FLAGS BindSD = BIND_SHADER_RESOURCE | BIND_DEPTH_STENCIL; +constexpr BIND_FLAGS BindSU = BIND_SHADER_RESOURCE | BIND_UNORDERED_ACCESS; +constexpr BIND_FLAGS BindSD = BIND_SHADER_RESOURCE | BIND_DEPTH_STENCIL; +constexpr BIND_FLAGS BindD = BIND_DEPTH_STENCIL; +constexpr BIND_FLAGS BindS = BIND_SHADER_RESOURCE; + +// clang-format off +const TextureTestAttribs TestList[] = +{ + {TEX_FORMAT_RGBA32_TYPELESS, 16, BindSRU, true}, + {TEX_FORMAT_RGBA32_FLOAT, 16, BindSRU, true}, + {TEX_FORMAT_RGBA32_UINT, 16, BindSRU, true}, + {TEX_FORMAT_RGBA32_SINT, 16, BindSRU, true}, + //{TEX_FORMAT_RGB32_TYPELESS 12, BindS, true}, + + // These formats are ill-supported + //{TEX_FORMAT_RGB32_FLOAT, 12, BindS, true}, + //{TEX_FORMAT_RGB32_UINT, 12, BindS, true}, + //{TEX_FORMAT_RGB32_SINT, 12, BindS, true}, + + {TEX_FORMAT_RGBA16_TYPELESS, 8, BindSRU, true}, + {TEX_FORMAT_RGBA16_FLOAT, 8, BindSRU, true}, + {TEX_FORMAT_RGBA16_UNORM, 8, BindSRU, true}, + {TEX_FORMAT_RGBA16_UINT, 8, BindSRU, true}, + {TEX_FORMAT_RGBA16_SNORM, 8, BindSU, true}, + {TEX_FORMAT_RGBA16_SINT, 8, BindSRU, true}, + + {TEX_FORMAT_RG32_TYPELESS, 8, BindSRU, true}, + {TEX_FORMAT_RG32_FLOAT, 8, BindSRU, true}, + {TEX_FORMAT_RG32_UINT, 8, BindSRU, true}, + {TEX_FORMAT_RG32_SINT, 8, BindSRU, true}, + + {TEX_FORMAT_R32G8X24_TYPELESS, 8, BindD, false}, + {TEX_FORMAT_D32_FLOAT_S8X24_UINT, 8, BindD, false}, + //{TEX_FORMAT_R32_FLOAT_X8X24_TYPELESS, 8, BindD, false}, + //{TEX_FORMAT_X32_TYPELESS_G8X24_UINT, 8, BindD, false}, + + {TEX_FORMAT_RGB10A2_TYPELESS, 4, BindSR, true}, + {TEX_FORMAT_RGB10A2_UNORM, 4, BindSR, true}, + {TEX_FORMAT_RGB10A2_UINT, 4, BindS, true}, + {TEX_FORMAT_R11G11B10_FLOAT, 4, BindSRU, false}, + + {TEX_FORMAT_RGBA8_TYPELESS, 4, BindSRU, true}, + {TEX_FORMAT_RGBA8_UNORM, 4, BindSRU, true}, + {TEX_FORMAT_RGBA8_UNORM_SRGB, 4, BindSR, true}, + {TEX_FORMAT_RGBA8_UINT, 4, BindSRU, true}, + {TEX_FORMAT_RGBA8_SNORM, 4, BindSU, true}, + {TEX_FORMAT_RGBA8_SINT, 4, BindSRU, true}, + + {TEX_FORMAT_RG16_TYPELESS, 4, BindSRU, true}, + {TEX_FORMAT_RG16_FLOAT, 4, BindSRU, true}, + {TEX_FORMAT_RG16_UNORM, 4, BindSRU, true}, + {TEX_FORMAT_RG16_UINT, 4, BindSRU, true}, + {TEX_FORMAT_RG16_SNORM, 4, BindSU, true}, + {TEX_FORMAT_RG16_SINT, 4, BindSRU, true}, + + {TEX_FORMAT_R32_TYPELESS, 4, BindSRU, true}, + {TEX_FORMAT_D32_FLOAT, 4, BindD, false}, + {TEX_FORMAT_R32_FLOAT, 4, BindSRU, true}, + {TEX_FORMAT_R32_UINT, 4, BindSRU, true}, + {TEX_FORMAT_R32_SINT, 4, BindSRU, true}, + + {TEX_FORMAT_R24G8_TYPELESS, 4, BindSD, false}, + {TEX_FORMAT_D24_UNORM_S8_UINT, 4, BindD, false}, + //{TEX_FORMAT_R24_UNORM_X8_TYPELESS, 4, BindD, true}, + //{TEX_FORMAT_X24_TYPELESS_G8_UINT, 4, BindD, true}, + + {TEX_FORMAT_RG8_TYPELESS, 2, BindSRU, true}, + {TEX_FORMAT_RG8_UNORM, 2, BindSRU, true}, + {TEX_FORMAT_RG8_UINT, 2, BindSRU, true}, + {TEX_FORMAT_RG8_SNORM, 2, BindSU, true}, + {TEX_FORMAT_RG8_SINT, 2, BindSRU, true}, + + {TEX_FORMAT_R16_TYPELESS, 2, BindSRU, true}, + {TEX_FORMAT_R16_FLOAT, 2, BindSRU, true}, + {TEX_FORMAT_D16_UNORM, 2, BindD, false}, + {TEX_FORMAT_R16_UNORM, 2, BindSRU, true}, + {TEX_FORMAT_R16_UINT, 2, BindSRU, true}, + {TEX_FORMAT_R16_SNORM, 2, BindSU, true}, + {TEX_FORMAT_R16_SINT, 2, BindSRU, true}, + + {TEX_FORMAT_R8_TYPELESS, 1, BindSRU, true}, + {TEX_FORMAT_R8_UNORM, 1, BindSRU, true}, + {TEX_FORMAT_R8_UINT, 1, BindSRU, true}, + {TEX_FORMAT_R8_SNORM, 1, BindSU, true}, + {TEX_FORMAT_R8_SINT, 1, BindSRU, true}, + //{TEX_FORMAT_A8_UNORM, 1, BindSRU, true}, + //{TEX_FORMAT_R1_UNORM, 1, BindSRU, true}, + + {TEX_FORMAT_RGB9E5_SHAREDEXP, 4, BindS, false}, + //{TEX_FORMAT_RG8_B8G8_UNORM, 4, BindSRU, false}, + //{TEX_FORMAT_G8R8_G8B8_UNORM, 4, BindSRU, false}, + + //{TEX_FORMAT_BC1_TYPELESS, 16, BindS, false}, + {TEX_FORMAT_BC1_UNORM, 16, BindS, false}, + {TEX_FORMAT_BC1_UNORM_SRGB, 16, BindS, false}, + //{TEX_FORMAT_BC2_TYPELESS, 16, BindS, false}, + {TEX_FORMAT_BC2_UNORM, 16, BindS, false}, + {TEX_FORMAT_BC2_UNORM_SRGB, 16, BindS, false}, + //{TEX_FORMAT_BC3_TYPELESS, 16, BindS, false}, + {TEX_FORMAT_BC3_UNORM, 16, BindS, false}, + {TEX_FORMAT_BC3_UNORM_SRGB, 16, BindS, false}, + //{TEX_FORMAT_BC4_TYPELESS, 16, BindS, false}, + {TEX_FORMAT_BC4_UNORM, 16, BindS, false}, + {TEX_FORMAT_BC4_SNORM, 16, BindS, false}, + //{TEX_FORMAT_BC5_TYPELESS, 16, BindS, false}, + {TEX_FORMAT_BC5_UNORM, 16, BindS, false}, + {TEX_FORMAT_BC5_SNORM, 16, BindS, false}, + + //{TEX_FORMAT_B5G6R5_UNORM, 2, BindSRU, true}, + //{TEX_FORMAT_B5G5R5A1_UNORM, 2, BindSRU, true}, + //{TEX_FORMAT_BGRA8_UNORM, 4, BindSRU, true}, + //{TEX_FORMAT_BGRX8_UNORM, 4, BindSRU, true}, + //{TEX_FORMAT_R10G10B10_XR_BIAS_A2_UNORM, 4, BindS, false}, + + {TEX_FORMAT_BGRA8_TYPELESS, 4, BindSRU, true}, + {TEX_FORMAT_BGRA8_UNORM_SRGB, 4, BindSR, true}, + //{TEX_FORMAT_BGRX8_TYPELESS, 4, BindSRU, true}, + //{TEX_FORMAT_BGRX8_UNORM_SRGB, 4, BindSR, true}, + + //{TEX_FORMAT_BC6H_TYPELESS, 16, BindS, false}, + {TEX_FORMAT_BC6H_UF16, 16, BindS, false}, + {TEX_FORMAT_BC6H_SF16, 16, BindS, false}, + //{TEX_FORMAT_BC7_TYPELESS, 16, BindS, false}, + {TEX_FORMAT_BC7_UNORM, 16, BindS, false}, + {TEX_FORMAT_BC7_UNORM_SRGB, 16, BindS, false}, +}; +// clang-format on + + +INSTANTIATE_TEST_SUITE_P(TextureCreation, + TextureCreationTest, + testing::ValuesIn(std::begin(TestList), std::end(TestList)), + [](const testing::TestParamInfo& info) // + { + const auto& FmtAttribs = GetTextureFormatAttribs(info.param.Fmt); + return FmtAttribs.Name; + } // +); + +} // namespace diff --git a/Tests/DiligentCoreAPITest/src/Vulkan/ClearRenderTargetReferenceVk.cpp b/Tests/DiligentCoreAPITest/src/Vulkan/ClearRenderTargetReferenceVk.cpp new file mode 100644 index 00000000..55a5dd8e --- /dev/null +++ b/Tests/DiligentCoreAPITest/src/Vulkan/ClearRenderTargetReferenceVk.cpp @@ -0,0 +1,83 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "Vulkan/TestingEnvironmentVk.h" +#include "Vulkan/TestingSwapChainVk.h" + +#include "DeviceContextVk.h" + +#include "volk/volk.h" + +namespace Diligent +{ + +namespace Testing +{ + +void ClearRenderTargetReferenceVk(ISwapChain* pSwapChain) +{ + auto* pEnv = TestingEnvironmentVk::GetInstance(); + auto* pContext = pEnv->GetDeviceContext(); + + VkResult res = VK_SUCCESS; + (void)res; + + auto* pTestingSwapChainVk = ValidatedCast(pSwapChain); + + VkCommandBuffer vkCmdBuffer = pEnv->AllocateCommandBuffer(); + + pTestingSwapChainVk->TransitionRenderTarget(vkCmdBuffer, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_PIPELINE_STAGE_VERTEX_SHADER_BIT | VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT); + VkClearColorValue ClearColor = {}; + + ClearColor.float32[0] = 0.25f; + ClearColor.float32[1] = 0.5f; + ClearColor.float32[2] = 0.75f; + ClearColor.float32[3] = 1.0f; + + VkImageSubresourceRange SubResRange = {}; + + SubResRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; + SubResRange.layerCount = 1; + SubResRange.levelCount = 1; + vkCmdClearColorImage(vkCmdBuffer, pTestingSwapChainVk->GetVkRenderTargetImage(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, &ClearColor, 1, &SubResRange); + + res = vkEndCommandBuffer(vkCmdBuffer); + VERIFY(res >= 0, "Failed to end command buffer"); + + RefCntAutoPtr pContextVk{pContext, IID_DeviceContextVk}; + + auto* pQeueVk = pContextVk->LockCommandQueue(); + auto vkQueue = pQeueVk->GetVkQueue(); + + VkSubmitInfo SubmitInfo = {}; + SubmitInfo.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; + SubmitInfo.pCommandBuffers = &vkCmdBuffer; + SubmitInfo.commandBufferCount = 1; + vkQueueSubmit(vkQueue, 1, &SubmitInfo, VK_NULL_HANDLE); + + pContextVk->UnlockCommandQueue(); +} + +} // namespace Testing + +} // namespace Diligent diff --git a/Tests/DiligentCoreAPITest/src/Vulkan/CreateObjFromNativeResVK.cpp b/Tests/DiligentCoreAPITest/src/Vulkan/CreateObjFromNativeResVK.cpp new file mode 100644 index 00000000..b1d65e3a --- /dev/null +++ b/Tests/DiligentCoreAPITest/src/Vulkan/CreateObjFromNativeResVK.cpp @@ -0,0 +1,104 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * 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 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#if VULKAN_SUPPORTED +# define VK_NO_PROTOTYPES +# include "vulkan/vulkan.h" +#endif + +#include "RenderDeviceVk.h" +#include "TextureVk.h" +#include "BufferVk.h" +#include "GraphicsAccessories.h" + +#include "Vulkan/CreateObjFromNativeResVK.h" + +#include "gtest/gtest.h" + +namespace Diligent +{ + +namespace Testing +{ + +void TestCreateObjFromNativeResVK::CreateTexture(Diligent::ITexture* pTexture) +{ +#if VULKAN_SUPPORTED + RefCntAutoPtr pDeviceVk(m_pDevice, IID_RenderDeviceVk); + RefCntAutoPtr pTextureVk(pTexture, IID_TextureVk); + ASSERT_NE(pDeviceVk, nullptr); + ASSERT_NE(pTextureVk, nullptr); + + const auto& SrcTexDesc = pTexture->GetDesc(); + if (SrcTexDesc.Type == RESOURCE_DIM_TEX_CUBE_ARRAY) + return; + + auto VkHandle = pTextureVk->GetVkImage(); + ASSERT_NE(VkHandle, (VkImage)VK_NULL_HANDLE); + + RefCntAutoPtr pAttachedTexture; + pDeviceVk->CreateTextureFromVulkanImage(VkHandle, SrcTexDesc, RESOURCE_STATE_UNKNOWN, &pAttachedTexture); + ASSERT_NE(pAttachedTexture, nullptr); + + const auto& TestTexDesc = pAttachedTexture->GetDesc(); + EXPECT_EQ(TestTexDesc, SrcTexDesc) << "Src tex desc: " << GetObjectDescString(SrcTexDesc) + << "\nTest tex desc: " << GetObjectDescString(TestTexDesc); + + RefCntAutoPtr pAttachedTextureVk(pAttachedTexture, IID_TextureVk); + ASSERT_NE(pAttachedTextureVk, nullptr); + EXPECT_EQ(pAttachedTextureVk->GetVkImage(), VkHandle); + EXPECT_EQ(reinterpret_cast(pAttachedTextureVk->GetNativeHandle()), VkHandle); +#endif +} + +void TestCreateObjFromNativeResVK::CreateBuffer(Diligent::IBuffer* pBuffer) +{ +#if VULKAN_SUPPORTED + RefCntAutoPtr pDeviceVk(m_pDevice, IID_RenderDeviceVk); + RefCntAutoPtr pBufferVk(pBuffer, IID_BufferVk); + ASSERT_NE(pDeviceVk, nullptr); + ASSERT_NE(pBufferVk, nullptr); + + auto VkBufferHandle = pBufferVk->GetVkBuffer(); + ASSERT_NE(VkBufferHandle, (VkBuffer)VK_NULL_HANDLE); + + const auto& SrcBuffDesc = pBuffer->GetDesc(); + + RefCntAutoPtr pBufferFromNativeVkHandle; + pDeviceVk->CreateBufferFromVulkanResource(VkBufferHandle, SrcBuffDesc, RESOURCE_STATE_UNKNOWN, &pBufferFromNativeVkHandle); + ASSERT_NE(pBufferFromNativeVkHandle, nullptr); + + const auto& TestBufferDesc = pBufferFromNativeVkHandle->GetDesc(); + EXPECT_EQ(TestBufferDesc, SrcBuffDesc) << "Src buff desc: " << GetObjectDescString(SrcBuffDesc) + << "\nTest buff desc: " << GetObjectDescString(TestBufferDesc); + + RefCntAutoPtr pTestBufferVk(pBufferFromNativeVkHandle, IID_BufferVk); + ASSERT_NE(pTestBufferVk, nullptr); + EXPECT_EQ(pTestBufferVk->GetVkBuffer(), VkBufferHandle); + EXPECT_EQ(reinterpret_cast(pTestBufferVk->GetNativeHandle()), VkBufferHandle); +#endif +} + +} // namespace Testing + +} // namespace Diligent diff --git a/Tests/DiligentCoreAPITest/src/Vulkan/DrawCommandReferenceVk.cpp b/Tests/DiligentCoreAPITest/src/Vulkan/DrawCommandReferenceVk.cpp new file mode 100644 index 00000000..2f3e37bc --- /dev/null +++ b/Tests/DiligentCoreAPITest/src/Vulkan/DrawCommandReferenceVk.cpp @@ -0,0 +1,274 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "Vulkan/TestingEnvironmentVk.h" +#include "Vulkan/TestingSwapChainVk.h" + +#include "DeviceContextVk.h" + +#include "volk/volk.h" + +namespace Diligent +{ + +namespace Testing +{ + +static const char* VSSource = R"( +#version 430 core + +#ifndef GL_ES +out gl_PerVertex +{ + vec4 gl_Position; +}; +#endif + +layout(location = 0) out vec3 out_Color; + +void main() +{ + vec4 Pos[6]; + Pos[0] = vec4(-1.0, -0.5, 0.0, 1.0); + Pos[1] = vec4(-0.5, +0.5, 0.0, 1.0); + Pos[2] = vec4( 0.0, -0.5, 0.0, 1.0); + + Pos[3] = vec4(+0.0, -0.5, 0.0, 1.0); + Pos[4] = vec4(+0.5, +0.5, 0.0, 1.0); + Pos[5] = vec4(+1.0, -0.5, 0.0, 1.0); + + vec3 Col[6]; + Col[0] = vec3(1.0, 0.0, 0.0); + Col[1] = vec3(0.0, 1.0, 0.0); + Col[2] = vec3(0.0, 0.0, 1.0); + + Col[3] = vec3(1.0, 0.0, 0.0); + Col[4] = vec3(0.0, 1.0, 0.0); + Col[5] = vec3(0.0, 0.0, 1.0); + + gl_Position = Pos[gl_VertexIndex]; + out_Color = Col[gl_VertexIndex]; +} +)"; + +static const char* PSSource = R"( +#version 430 core + +layout(location = 0) in vec3 in_Color; +layout(location = 0) out vec4 out_Color; + +void main() +{ + out_Color = vec4(in_Color, 1.0); +} +)"; + +void RenderDrawCommandReferenceVk(ISwapChain* pSwapChain) +{ + auto* pEnv = TestingEnvironmentVk::GetInstance(); + auto vkDevice = pEnv->GetVkDevice(); + auto* pContext = pEnv->GetDeviceContext(); + + const auto& SCDesc = pSwapChain->GetDesc(); + + VkResult res = VK_SUCCESS; + (void)res; + + auto* pTestingSwapChainVk = ValidatedCast(pSwapChain); + + auto vkVSModule = pEnv->CreateShaderModule(SHADER_TYPE_VERTEX, VSSource, static_cast(strlen(VSSource))); + ASSERT_TRUE(vkVSModule != VK_NULL_HANDLE); + auto vkPSModule = pEnv->CreateShaderModule(SHADER_TYPE_PIXEL, PSSource, static_cast(strlen(PSSource))); + ASSERT_TRUE(vkPSModule != VK_NULL_HANDLE); + + VkGraphicsPipelineCreateInfo PipelineCI = {}; + + PipelineCI.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; + PipelineCI.pNext = nullptr; + + VkPipelineShaderStageCreateInfo ShaderStages[2] = {}; + + ShaderStages[0].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; + ShaderStages[0].stage = VK_SHADER_STAGE_VERTEX_BIT; + ShaderStages[0].module = vkVSModule; + ShaderStages[0].pName = "main"; + + ShaderStages[1].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; + ShaderStages[1].stage = VK_SHADER_STAGE_FRAGMENT_BIT; + ShaderStages[1].module = vkPSModule; + ShaderStages[1].pName = "main"; + + PipelineCI.pStages = ShaderStages; + PipelineCI.stageCount = _countof(ShaderStages); + + VkPipelineLayoutCreateInfo PipelineLayoutCI = {}; + + PipelineLayoutCI.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; + VkPipelineLayout vkLayout = VK_NULL_HANDLE; + vkCreatePipelineLayout(vkDevice, &PipelineLayoutCI, nullptr, &vkLayout); + ASSERT_TRUE(vkLayout != VK_NULL_HANDLE); + PipelineCI.layout = vkLayout; + + VkPipelineVertexInputStateCreateInfo VertexInputStateCI = {}; + + VertexInputStateCI.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; + PipelineCI.pVertexInputState = &VertexInputStateCI; + + + VkPipelineInputAssemblyStateCreateInfo InputAssemblyCI = {}; + + InputAssemblyCI.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; + InputAssemblyCI.pNext = nullptr; + InputAssemblyCI.flags = 0; // reserved for future use + InputAssemblyCI.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST; + InputAssemblyCI.primitiveRestartEnable = VK_FALSE; + PipelineCI.pInputAssemblyState = &InputAssemblyCI; + + + VkPipelineTessellationStateCreateInfo TessStateCI = {}; + + TessStateCI.sType = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO; + TessStateCI.pNext = nullptr; + TessStateCI.flags = 0; // reserved for future use + PipelineCI.pTessellationState = &TessStateCI; + + + VkPipelineViewportStateCreateInfo ViewPortStateCI = {}; + + ViewPortStateCI.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; + ViewPortStateCI.pNext = nullptr; + ViewPortStateCI.flags = 0; // reserved for future use + ViewPortStateCI.viewportCount = 1; + + VkViewport Viewport = {}; + Viewport.y = static_cast(SCDesc.Height); + Viewport.width = static_cast(SCDesc.Width); + Viewport.height = -static_cast(SCDesc.Height); + Viewport.maxDepth = 1; + + ViewPortStateCI.pViewports = &Viewport; + ViewPortStateCI.scissorCount = ViewPortStateCI.viewportCount; // the number of scissors must match the number of viewports (23.5) + // (why the hell it is in the struct then?) + + VkRect2D ScissorRect = {}; + ScissorRect.extent.width = SCDesc.Width; + ScissorRect.extent.height = SCDesc.Height; + ViewPortStateCI.pScissors = &ScissorRect; + + PipelineCI.pViewportState = &ViewPortStateCI; + + VkPipelineRasterizationStateCreateInfo RasterizerStateCI = {}; + + RasterizerStateCI.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; + RasterizerStateCI.polygonMode = VK_POLYGON_MODE_FILL; + RasterizerStateCI.cullMode = VK_CULL_MODE_NONE; + RasterizerStateCI.lineWidth = 1; + + PipelineCI.pRasterizationState = &RasterizerStateCI; + + // Multisample state (24) + VkPipelineMultisampleStateCreateInfo MSStateCI = {}; + + MSStateCI.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; + MSStateCI.pNext = nullptr; + MSStateCI.flags = 0; // reserved for future use + // If subpass uses color and/or depth/stencil attachments, then the rasterizationSamples member of + // pMultisampleState must be the same as the sample count for those subpass attachments + MSStateCI.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; + MSStateCI.sampleShadingEnable = VK_FALSE; + MSStateCI.minSampleShading = 0; // a minimum fraction of sample shading if sampleShadingEnable is set to VK_TRUE. + uint32_t SampleMask[] = {0xFFFFFFFF, 0}; // Vulkan spec allows up to 64 samples + MSStateCI.pSampleMask = SampleMask; // an array of static coverage information that is ANDed with + // the coverage information generated during rasterization (25.3) + MSStateCI.alphaToCoverageEnable = VK_FALSE; // whether a temporary coverage value is generated based on + // the alpha component of the fragment's first color output + MSStateCI.alphaToOneEnable = VK_FALSE; // whether the alpha component of the fragment's first color output is replaced with one + PipelineCI.pMultisampleState = &MSStateCI; + + + VkPipelineDepthStencilStateCreateInfo DepthStencilStateCI = {}; + + DepthStencilStateCI.sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO; + PipelineCI.pDepthStencilState = &DepthStencilStateCI; + + + VkPipelineColorBlendStateCreateInfo BlendStateCI = {}; + + VkPipelineColorBlendAttachmentState Attachment = {}; + + Attachment.colorWriteMask = VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT | VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT; + + BlendStateCI.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; + BlendStateCI.pAttachments = &Attachment; + BlendStateCI.attachmentCount = 1; // must equal the colorAttachmentCount for the subpass + // in which this pipeline is used. + PipelineCI.pColorBlendState = &BlendStateCI; + + + VkPipelineDynamicStateCreateInfo DynamicStateCI = {}; + + DynamicStateCI.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; + PipelineCI.pDynamicState = &DynamicStateCI; + + PipelineCI.renderPass = pTestingSwapChainVk->GetRenderPass(); + PipelineCI.subpass = 0; + PipelineCI.basePipelineHandle = VK_NULL_HANDLE; // a pipeline to derive from + PipelineCI.basePipelineIndex = 0; // an index into the pCreateInfos parameter to use as a pipeline to derive from + + VkPipeline vkPipeline = VK_NULL_HANDLE; + res = vkCreateGraphicsPipelines(vkDevice, VK_NULL_HANDLE, 1, &PipelineCI, nullptr, &vkPipeline); + ASSERT_GE(res, 0); + ASSERT_TRUE(vkPipeline != VK_NULL_HANDLE); + + VkCommandBuffer vkCmdBuffer = pEnv->AllocateCommandBuffer(); + + pTestingSwapChainVk->BeginRenderPass(vkCmdBuffer, VK_PIPELINE_STAGE_VERTEX_SHADER_BIT | VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT); + vkCmdBindPipeline(vkCmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, vkPipeline); + vkCmdDraw(vkCmdBuffer, 6, 1, 0, 0); + pTestingSwapChainVk->EndRenderPass(vkCmdBuffer); + res = vkEndCommandBuffer(vkCmdBuffer); + VERIFY(res >= 0, "Failed to end command buffer"); + + RefCntAutoPtr pContextVk{pContext, IID_DeviceContextVk}; + + auto* pQeueVk = pContextVk->LockCommandQueue(); + auto vkQueue = pQeueVk->GetVkQueue(); + + VkSubmitInfo SubmitInfo = {}; + SubmitInfo.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; + SubmitInfo.pCommandBuffers = &vkCmdBuffer; + SubmitInfo.commandBufferCount = 1; + vkQueueSubmit(vkQueue, 1, &SubmitInfo, VK_NULL_HANDLE); + vkQueueWaitIdle(vkQueue); + + pContextVk->UnlockCommandQueue(); + + vkDestroyPipeline(vkDevice, vkPipeline, nullptr); + vkDestroyPipelineLayout(vkDevice, vkLayout, nullptr); + vkDestroyShaderModule(vkDevice, vkVSModule, nullptr); + vkDestroyShaderModule(vkDevice, vkPSModule, nullptr); +} + +} // namespace Testing + +} // namespace Diligent diff --git a/Tests/DiligentCoreAPITest/src/Vulkan/TestingEnvironmentVk.cpp b/Tests/DiligentCoreAPITest/src/Vulkan/TestingEnvironmentVk.cpp new file mode 100644 index 00000000..fa242455 --- /dev/null +++ b/Tests/DiligentCoreAPITest/src/Vulkan/TestingEnvironmentVk.cpp @@ -0,0 +1,641 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "Vulkan/TestingEnvironmentVk.h" + +#include "RenderDeviceVk.h" +#include "DeviceContextVk.h" + +#include "SPIRVUtils.h" + +#define VOLK_IMPLEMENTATION +#include "volk/volk.h" + +namespace Diligent +{ + +namespace Testing +{ + +void CreateTestingSwapChainVk(TestingEnvironmentVk* pEnv, + const SwapChainDesc& SCDesc, + ISwapChain** ppSwapChain); + +TestingEnvironmentVk::TestingEnvironmentVk(DeviceType deviceType, ADAPTER_TYPE AdapterType, const SwapChainDesc& SCDesc) : + TestingEnvironment{deviceType, AdapterType, SCDesc} +{ + InitializeGlslang(); + + // We have to use dynamic Vulkan loader because if an application is statically linked with vulkan-1.lib + // and the Vulkan library is not present on the system, the app will instantly crash. + volkInitialize(); + + RefCntAutoPtr pRenderDeviceVk{m_pDevice, IID_RenderDeviceVk}; + m_vkDevice = pRenderDeviceVk->GetVkDevice(); + + volkLoadInstance(pRenderDeviceVk->GetVkInstance()); + + RefCntAutoPtr pContextVk{m_pDeviceContext, IID_DeviceContextVk}; + + auto* pQeueVk = pContextVk->LockCommandQueue(); + auto QueueFamilyIndex = pQeueVk->GetQueueFamilyIndex(); + pContextVk->UnlockCommandQueue(); + + auto vkPhysicalDevice = pRenderDeviceVk->GetVkPhysicalDevice(); + vkGetPhysicalDeviceMemoryProperties(vkPhysicalDevice, &m_MemoryProperties); + + VkCommandPoolCreateInfo CmdPoolCI = {}; + CmdPoolCI.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; + CmdPoolCI.queueFamilyIndex = QueueFamilyIndex; + vkCreateCommandPool(m_vkDevice, &CmdPoolCI, nullptr, &m_vkCmdPool); + VERIFY_EXPR(m_vkCmdPool != VK_NULL_HANDLE); + + if (m_pSwapChain == nullptr) + { + CreateTestingSwapChainVk(this, SCDesc, &m_pSwapChain); + } +} + +TestingEnvironmentVk::~TestingEnvironmentVk() +{ + if (m_vkCmdPool != VK_NULL_HANDLE) + { + vkDestroyCommandPool(m_vkDevice, m_vkCmdPool, nullptr); + } + + FinalizeGlslang(); +} + +uint32_t TestingEnvironmentVk::GetMemoryTypeIndex(uint32_t memoryTypeBitsRequirement, + VkMemoryPropertyFlags requiredProperties) const +{ + // Iterate over all memory types available for the device + // For each pair of elements X and Y returned in memoryTypes, X must be placed at a lower index position than Y if: + // * either the set of bit flags of X is a strict subset of the set of bit flags of Y. + // * or the propertyFlags members of X and Y are equal, and X belongs to a memory heap with greater performance + + for (uint32_t memoryIndex = 0; memoryIndex < m_MemoryProperties.memoryTypeCount; memoryIndex++) + { + // Each memory type returned by vkGetPhysicalDeviceMemoryProperties must have its propertyFlags set + // to one of the following values: + // * 0 + // * HOST_VISIBLE_BIT | HOST_COHERENT_BIT + // * HOST_VISIBLE_BIT | HOST_CACHED_BIT + // * HOST_VISIBLE_BIT | HOST_CACHED_BIT | HOST_COHERENT_BIT + // * DEVICE_LOCAL_BIT + // * DEVICE_LOCAL_BIT | HOST_VISIBLE_BIT | HOST_COHERENT_BIT + // * DEVICE_LOCAL_BIT | HOST_VISIBLE_BIT | HOST_CACHED_BIT + // * DEVICE_LOCAL_BIT | HOST_VISIBLE_BIT | HOST_CACHED_BIT | HOST_COHERENT_BIT + // * DEVICE_LOCAL_BIT | LAZILY_ALLOCATED_BIT + // + // There must be at least one memory type with both the HOST_VISIBLE_BIT and HOST_COHERENT_BIT bits set + // There must be at least one memory type with the DEVICE_LOCAL_BIT bit set + + const uint32_t memoryTypeBit = (1 << memoryIndex); + const bool isRequiredMemoryType = (memoryTypeBitsRequirement & memoryTypeBit) != 0; + if (isRequiredMemoryType) + { + const VkMemoryPropertyFlags properties = m_MemoryProperties.memoryTypes[memoryIndex].propertyFlags; + const bool hasRequiredProperties = (properties & requiredProperties) == requiredProperties; + + if (hasRequiredProperties) + return memoryIndex; + } + } + return static_cast(-1); +} + +void TestingEnvironmentVk::CreateImage2D(uint32_t Width, + uint32_t Height, + VkFormat vkFormat, + VkImageUsageFlags vkUsage, + VkImageLayout vkInitialLayout, + VkDeviceMemory& vkMemory, + VkImage& vkImage) +{ + VkImageCreateInfo ImageCI = {}; + + ImageCI.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; + ImageCI.pNext = nullptr; + ImageCI.flags = 0; + ImageCI.imageType = VK_IMAGE_TYPE_2D; + ImageCI.format = vkFormat; + ImageCI.extent = VkExtent3D{Width, Height, 1}; + ImageCI.mipLevels = 1; + ImageCI.arrayLayers = 1; + ImageCI.samples = VK_SAMPLE_COUNT_1_BIT; + ImageCI.tiling = VK_IMAGE_TILING_OPTIMAL; + ImageCI.usage = vkUsage; + ImageCI.sharingMode = VK_SHARING_MODE_EXCLUSIVE; + ImageCI.queueFamilyIndexCount = 0; + ImageCI.pQueueFamilyIndices = nullptr; + ImageCI.initialLayout = vkInitialLayout; + + auto res = vkCreateImage(m_vkDevice, &ImageCI, nullptr, &vkImage); + ASSERT_GE(res, 0); + + VkMemoryRequirements MemReqs = {}; + vkGetImageMemoryRequirements(m_vkDevice, vkImage, &MemReqs); + + VkMemoryPropertyFlags ImageMemoryFlags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT; + auto MemoryTypeIndex = GetMemoryTypeIndex(MemReqs.memoryTypeBits, ImageMemoryFlags); + + VkMemoryAllocateInfo AllocInfo = {}; + AllocInfo.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; + AllocInfo.pNext = nullptr; + AllocInfo.allocationSize = MemReqs.size; + AllocInfo.memoryTypeIndex = MemoryTypeIndex; + + res = vkAllocateMemory(m_vkDevice, &AllocInfo, nullptr, &vkMemory); + ASSERT_GE(res, 0); + + res = vkBindImageMemory(m_vkDevice, vkImage, vkMemory, 0); + ASSERT_GE(res, 0); +} + +void TestingEnvironmentVk::CreateBuffer(VkDeviceSize Size, + VkBufferUsageFlags vkUsage, + VkMemoryPropertyFlags MemoryFlags, + VkDeviceMemory& vkMemory, + VkBuffer& vkBuffer) +{ + VkBufferCreateInfo BufferCI = {}; + + BufferCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; + BufferCI.pNext = nullptr; + BufferCI.flags = 0; + BufferCI.size = Size; + BufferCI.usage = vkUsage; + BufferCI.sharingMode = VK_SHARING_MODE_EXCLUSIVE; + BufferCI.queueFamilyIndexCount = 0; + BufferCI.pQueueFamilyIndices = nullptr; + + auto res = vkCreateBuffer(m_vkDevice, &BufferCI, nullptr, &vkBuffer); + ASSERT_GE(res, 0); + + VkMemoryRequirements MemReqs = {}; + vkGetBufferMemoryRequirements(m_vkDevice, vkBuffer, &MemReqs); + + auto MemoryTypeIndex = GetMemoryTypeIndex(MemReqs.memoryTypeBits, MemoryFlags); + + VkMemoryAllocateInfo AllocInfo = {}; + AllocInfo.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; + AllocInfo.pNext = nullptr; + AllocInfo.allocationSize = MemReqs.size; + AllocInfo.memoryTypeIndex = MemoryTypeIndex; + + res = vkAllocateMemory(m_vkDevice, &AllocInfo, nullptr, &vkMemory); + ASSERT_GE(res, 0); + + res = vkBindBufferMemory(m_vkDevice, vkBuffer, vkMemory, 0); + ASSERT_GE(res, 0); +} + + +VkRenderPassCreateInfo TestingEnvironmentVk::GetRenderPassCreateInfo( + Uint32 NumRenderTargets, + const VkFormat RTVFormats[], + VkFormat DSVFormat, + Uint32 SampleCount, + VkAttachmentLoadOp DepthAttachmentLoadOp, + VkAttachmentLoadOp ColorAttachmentLoadOp, + std::array& Attachments, + std::array& AttachmentReferences, + VkSubpassDescription& SubpassDesc) +{ + VERIFY_EXPR(NumRenderTargets <= MaxRenderTargets); + + // Prepare render pass create info (7.1) + VkRenderPassCreateInfo RenderPassCI = {}; + + RenderPassCI.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO; + RenderPassCI.pNext = nullptr; + RenderPassCI.flags = 0; // reserved for future use + RenderPassCI.attachmentCount = (DSVFormat != TEX_FORMAT_UNKNOWN ? 1 : 0) + NumRenderTargets; + + uint32_t AttachmentInd = 0; + VkSampleCountFlagBits SampleCountFlags = static_cast(SampleCount); + VkAttachmentReference* pDepthAttachmentReference = nullptr; + if (DSVFormat != TEX_FORMAT_UNKNOWN) + { + auto& DepthAttachment = Attachments[AttachmentInd]; + + DepthAttachment.flags = 0; // Allowed value VK_ATTACHMENT_DESCRIPTION_MAY_ALIAS_BIT + DepthAttachment.format = DSVFormat; + DepthAttachment.samples = SampleCountFlags; + DepthAttachment.loadOp = DepthAttachmentLoadOp; + DepthAttachment.storeOp = VK_ATTACHMENT_STORE_OP_STORE; // the contents generated during the render pass and within the render + // area are written to memory. For attachments with a depth/stencil format, + // this uses the access type VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT. + DepthAttachment.stencilLoadOp = DepthAttachmentLoadOp; + DepthAttachment.stencilStoreOp = VK_ATTACHMENT_STORE_OP_STORE; + DepthAttachment.initialLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; + DepthAttachment.finalLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; + + pDepthAttachmentReference = &AttachmentReferences[AttachmentInd]; + pDepthAttachmentReference->attachment = AttachmentInd; + pDepthAttachmentReference->layout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; + + ++AttachmentInd; + } + + VkAttachmentReference* pColorAttachmentsReference = NumRenderTargets > 0 ? &AttachmentReferences[AttachmentInd] : nullptr; + for (Uint32 rt = 0; rt < NumRenderTargets; ++rt, ++AttachmentInd) + { + auto& ColorAttachment = Attachments[AttachmentInd]; + + ColorAttachment.flags = 0; // Allowed value VK_ATTACHMENT_DESCRIPTION_MAY_ALIAS_BIT + ColorAttachment.format = RTVFormats[rt]; + ColorAttachment.samples = SampleCountFlags; + ColorAttachment.loadOp = ColorAttachmentLoadOp; + ColorAttachment.storeOp = VK_ATTACHMENT_STORE_OP_STORE; // the contents generated during the render pass and within the render + // area are written to memory. For attachments with a color format, + // this uses the access type VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT. + ColorAttachment.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; + ColorAttachment.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; + ColorAttachment.initialLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; + ColorAttachment.finalLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; + + auto& ColorAttachmentRef = AttachmentReferences[AttachmentInd]; + ColorAttachmentRef.attachment = AttachmentInd; + ColorAttachmentRef.layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; + } + + RenderPassCI.pAttachments = Attachments.data(); + RenderPassCI.subpassCount = 1; + RenderPassCI.pSubpasses = &SubpassDesc; + RenderPassCI.dependencyCount = 0; // the number of dependencies between pairs of subpasses, or zero indicating no dependencies. + RenderPassCI.pDependencies = nullptr; // an array of dependencyCount number of VkSubpassDependency structures describing + // dependencies between pairs of subpasses, or NULL if dependencyCount is zero. + + + SubpassDesc.flags = 0; // All bits for this type are defined by extensions + SubpassDesc.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS; // Currently, only graphics subpasses are supported. + SubpassDesc.inputAttachmentCount = 0; + SubpassDesc.pInputAttachments = nullptr; + SubpassDesc.colorAttachmentCount = NumRenderTargets; + SubpassDesc.pColorAttachments = pColorAttachmentsReference; + SubpassDesc.pResolveAttachments = nullptr; + SubpassDesc.pDepthStencilAttachment = pDepthAttachmentReference; + SubpassDesc.preserveAttachmentCount = 0; + SubpassDesc.pPreserveAttachments = nullptr; + + return RenderPassCI; +} + +VkShaderModule TestingEnvironmentVk::CreateShaderModule(const SHADER_TYPE ShaderType, const char* ShaderSource, int SourceCodeLen) +{ + auto Bytecode = GLSLtoSPIRV(ShaderType, ShaderSource, SourceCodeLen, nullptr); + VERIFY_EXPR(!Bytecode.empty()); + if (Bytecode.empty()) + return VK_NULL_HANDLE; + + VkShaderModuleCreateInfo ShaderModuleCI = {}; + + ShaderModuleCI.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; + ShaderModuleCI.pNext = nullptr; + ShaderModuleCI.flags = 0; + ShaderModuleCI.codeSize = Bytecode.size() * sizeof(uint32_t); + ShaderModuleCI.pCode = Bytecode.data(); + + VkShaderModule vkShaderModule = VK_NULL_HANDLE; + vkCreateShaderModule(m_vkDevice, &ShaderModuleCI, nullptr, &vkShaderModule); + VERIFY_EXPR(vkShaderModule != VK_NULL_HANDLE); + + return vkShaderModule; +} + +VkCommandBuffer TestingEnvironmentVk::AllocateCommandBuffer() +{ + VkCommandBufferAllocateInfo AllocInfo = {}; + + AllocInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; + AllocInfo.commandPool = m_vkCmdPool; + AllocInfo.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; + AllocInfo.commandBufferCount = 1; + + VkCommandBuffer vkCmdBuff = VK_NULL_HANDLE; + vkAllocateCommandBuffers(m_vkDevice, &AllocInfo, &vkCmdBuff); + VERIFY_EXPR(vkCmdBuff != VK_NULL_HANDLE); + + VkCommandBufferBeginInfo BeginInfo = {}; + + BeginInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; + BeginInfo.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; + auto res = vkBeginCommandBuffer(vkCmdBuff, &BeginInfo); + VERIFY(res >= 0, "Failed to begin command buffer"); + + return vkCmdBuff; +} + + +static VkPipelineStageFlags PipelineStageFromAccessFlags(VkAccessFlags AccessFlags, + const VkPipelineStageFlags EnabledGraphicsShaderStages) +{ + // 6.1.3 + VkPipelineStageFlags Stages = 0; + + while (AccessFlags != 0) + { + VkAccessFlagBits AccessFlag = static_cast(AccessFlags & (~(AccessFlags - 1))); + VERIFY_EXPR(AccessFlag != 0 && (AccessFlag & (AccessFlag - 1)) == 0); + AccessFlags &= ~AccessFlag; + + // An application MUST NOT specify an access flag in a synchronization command if it does not include a + // pipeline stage in the corresponding stage mask that is able to perform accesses of that type. + // A table that lists, for each access flag, which pipeline stages can perform that type of access is given in 6.1.3. + switch (AccessFlag) + { + // Read access to an indirect command structure read as part of an indirect drawing or dispatch command + case VK_ACCESS_INDIRECT_COMMAND_READ_BIT: + Stages |= VK_PIPELINE_STAGE_DRAW_INDIRECT_BIT; + break; + + // Read access to an index buffer as part of an indexed drawing command, bound by vkCmdBindIndexBuffer + case VK_ACCESS_INDEX_READ_BIT: + Stages |= VK_PIPELINE_STAGE_VERTEX_INPUT_BIT; + break; + + // Read access to a vertex buffer as part of a drawing command, bound by vkCmdBindVertexBuffers + case VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT: + Stages |= VK_PIPELINE_STAGE_VERTEX_INPUT_BIT; + break; + + // Read access to a uniform buffer + case VK_ACCESS_UNIFORM_READ_BIT: + Stages |= EnabledGraphicsShaderStages | VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT; + break; + + // Read access to an input attachment within a render pass during fragment shading + case VK_ACCESS_INPUT_ATTACHMENT_READ_BIT: + Stages |= VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT; + break; + + // Read access to a storage buffer, uniform texel buffer, storage texel buffer, sampled image, or storage image + case VK_ACCESS_SHADER_READ_BIT: + Stages |= EnabledGraphicsShaderStages | VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT; + break; + + // Write access to a storage buffer, storage texel buffer, or storage image + case VK_ACCESS_SHADER_WRITE_BIT: + Stages |= EnabledGraphicsShaderStages | VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT; + break; + + // Read access to a color attachment, such as via blending, logic operations, or via certain subpass load operations + case VK_ACCESS_COLOR_ATTACHMENT_READ_BIT: + Stages |= VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT; + break; + + // Write access to a color or resolve attachment during a render pass or via certain subpass load and store operations + case VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT: + Stages |= VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT; + break; + + // Read access to a depth/stencil attachment, via depth or stencil operations or via certain subpass load operations + case VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT: + Stages |= VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT; + break; + + // Write access to a depth/stencil attachment, via depth or stencil operations or via certain subpass load and store operations + case VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT: + Stages |= VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT; + break; + + // Read access to an image or buffer in a copy operation + case VK_ACCESS_TRANSFER_READ_BIT: + Stages |= VK_PIPELINE_STAGE_TRANSFER_BIT; + break; + + // Write access to an image or buffer in a clear or copy operation + case VK_ACCESS_TRANSFER_WRITE_BIT: + Stages |= VK_PIPELINE_STAGE_TRANSFER_BIT; + break; + + // Read access by a host operation. Accesses of this type are not performed through a resource, but directly on memory + case VK_ACCESS_HOST_READ_BIT: + Stages |= VK_PIPELINE_STAGE_HOST_BIT; + break; + + // Write access by a host operation. Accesses of this type are not performed through a resource, but directly on memory + case VK_ACCESS_HOST_WRITE_BIT: + Stages |= VK_PIPELINE_STAGE_HOST_BIT; + break; + + // Read access via non-specific entities. When included in a destination access mask, makes all available writes + // visible to all future read accesses on entities known to the Vulkan device + case VK_ACCESS_MEMORY_READ_BIT: + break; + + // Write access via non-specific entities. hen included in a source access mask, all writes that are performed + // by entities known to the Vulkan device are made available. When included in a destination access mask, makes + // all available writes visible to all future write accesses on entities known to the Vulkan device. + case VK_ACCESS_MEMORY_WRITE_BIT: + break; + + default: + UNEXPECTED("Unknown memory access flag"); + } + } + return Stages; +} + + +static VkPipelineStageFlags AccessMaskFromImageLayout(VkImageLayout Layout, + bool IsDstMask // false - source mask + // true - destination mask +) +{ + VkPipelineStageFlags AccessMask = 0; + switch (Layout) + { + // does not support device access. This layout must only be used as the initialLayout member + // of VkImageCreateInfo or VkAttachmentDescription, or as the oldLayout in an image transition. + // When transitioning out of this layout, the contents of the memory are not guaranteed to be preserved (11.4) + case VK_IMAGE_LAYOUT_UNDEFINED: + if (IsDstMask) + { + UNEXPECTED("The new layout used in a transition must not be VK_IMAGE_LAYOUT_UNDEFINED. " + "This layout must only be used as the initialLayout member of VkImageCreateInfo " + "or VkAttachmentDescription, or as the oldLayout in an image transition. (11.4)"); + } + break; + + // supports all types of device access + case VK_IMAGE_LAYOUT_GENERAL: + // VK_IMAGE_LAYOUT_GENERAL must be used for image load/store operations (13.1.1, 13.2.4) + AccessMask = VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT; + break; + + // must only be used as a color or resolve attachment in a VkFramebuffer (11.4) + case VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL: + AccessMask = VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT; + break; + + // must only be used as a depth/stencil attachment in a VkFramebuffer (11.4) + case VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL: + AccessMask = VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT; + break; + + // must only be used as a read-only depth/stencil attachment in a VkFramebuffer and/or as a read-only image in a shader (11.4) + case VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL: + AccessMask = VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT; + break; + + // must only be used as a read-only image in a shader (which can be read as a sampled image, + // combined image/sampler and/or input attachment) (11.4) + case VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL: + AccessMask = VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_INPUT_ATTACHMENT_READ_BIT; + break; + + // must only be used as a source image of a transfer command (11.4) + case VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL: + AccessMask = VK_ACCESS_TRANSFER_READ_BIT; + break; + + // must only be used as a destination image of a transfer command (11.4) + case VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL: + AccessMask = VK_ACCESS_TRANSFER_WRITE_BIT; + break; + + // does not support device access. This layout must only be used as the initialLayout member + // of VkImageCreateInfo or VkAttachmentDescription, or as the oldLayout in an image transition. + // When transitioning out of this layout, the contents of the memory are preserved. (11.4) + case VK_IMAGE_LAYOUT_PREINITIALIZED: + if (!IsDstMask) + { + AccessMask = VK_ACCESS_HOST_WRITE_BIT; + } + else + { + UNEXPECTED("The new layout used in a transition must not be VK_IMAGE_LAYOUT_PREINITIALIZED. " + "This layout must only be used as the initialLayout member of VkImageCreateInfo " + "or VkAttachmentDescription, or as the oldLayout in an image transition. (11.4)"); + } + break; + + case VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL: + AccessMask = VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT; + break; + + case VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL: + AccessMask = VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT; + break; + + case VK_IMAGE_LAYOUT_PRESENT_SRC_KHR: + AccessMask = VK_ACCESS_MEMORY_READ_BIT; + break; + + default: + UNEXPECTED("Unexpected image layout"); + break; + } + + return AccessMask; +} + +void TestingEnvironmentVk::TransitionImageLayout(VkCommandBuffer CmdBuffer, + VkImage Image, + VkImageLayout& CurrentLayout, + VkImageLayout NewLayout, + const VkImageSubresourceRange& SubresRange, + VkPipelineStageFlags EnabledGraphicsShaderStages, + VkPipelineStageFlags SrcStages, + VkPipelineStageFlags DestStages) +{ + if (CurrentLayout == NewLayout) + return; + + VkImageMemoryBarrier ImgBarrier = {}; + ImgBarrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; + ImgBarrier.pNext = nullptr; + ImgBarrier.srcAccessMask = 0; + ImgBarrier.dstAccessMask = 0; + ImgBarrier.oldLayout = CurrentLayout; + ImgBarrier.newLayout = NewLayout; + ImgBarrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; // source queue family for a queue family ownership transfer. + ImgBarrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; // destination queue family for a queue family ownership transfer. + ImgBarrier.image = Image; + ImgBarrier.subresourceRange = SubresRange; + ImgBarrier.srcAccessMask = AccessMaskFromImageLayout(CurrentLayout, false); + ImgBarrier.dstAccessMask = AccessMaskFromImageLayout(NewLayout, true); + + if (SrcStages == 0) + { + if (CurrentLayout == VK_IMAGE_LAYOUT_PRESENT_SRC_KHR) + { + SrcStages = VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT; + } + else if (ImgBarrier.srcAccessMask != 0) + { + SrcStages = PipelineStageFromAccessFlags(ImgBarrier.srcAccessMask, EnabledGraphicsShaderStages); + } + else + { + // An execution dependency with only VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT in the source stage + // mask will effectively not wait for any prior commands to complete. (6.1.2) + SrcStages = VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT; + } + } + + if (DestStages == 0) + { + if (NewLayout == VK_IMAGE_LAYOUT_PRESENT_SRC_KHR) + { + DestStages = VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT; + } + else if (ImgBarrier.dstAccessMask != 0) + { + DestStages = PipelineStageFromAccessFlags(ImgBarrier.dstAccessMask, EnabledGraphicsShaderStages); + } + else + { + // An execution dependency with only VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT in the destination + // stage mask will only prevent that stage from executing in subsequently submitted commands. + // As this stage does not perform any actual execution, this is not observable - in effect, + // it does not delay processing of subsequent commands. (6.1.2) + DestStages = VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT; + } + } + + vkCmdPipelineBarrier(CmdBuffer, + SrcStages, // must not be 0 + DestStages, // must not be 0 + 0, // a bitmask specifying how execution and memory dependencies are formed + 0, // memoryBarrierCount + nullptr, // pMemoryBarriers + 0, // bufferMemoryBarrierCount + nullptr, // pBufferMemoryBarriers + 1, + &ImgBarrier); + + CurrentLayout = NewLayout; +} + +TestingEnvironment* CreateTestingEnvironmentVk(DeviceType deviceType, ADAPTER_TYPE AdapterType, const SwapChainDesc& SCDesc) +{ + return new TestingEnvironmentVk{deviceType, AdapterType, SCDesc}; +} + +} // namespace Testing + +} // namespace Diligent diff --git a/Tests/DiligentCoreAPITest/src/Vulkan/TestingSwapChainVk.cpp b/Tests/DiligentCoreAPITest/src/Vulkan/TestingSwapChainVk.cpp new file mode 100644 index 00000000..b89c91fc --- /dev/null +++ b/Tests/DiligentCoreAPITest/src/Vulkan/TestingSwapChainVk.cpp @@ -0,0 +1,297 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "Vulkan/TestingSwapChainVk.h" +#include "Vulkan/TestingEnvironmentVk.h" + +#include "RenderDeviceVk.h" +#include "DeviceContextVk.h" + +#include "volk/volk.h" + +namespace Diligent +{ + +namespace Testing +{ + +TestingSwapChainVk::TestingSwapChainVk(IReferenceCounters* pRefCounters, + TestingEnvironmentVk* pEnv, + const SwapChainDesc& SCDesc) : + TBase // + { + pRefCounters, + pEnv->GetDevice(), + pEnv->GetDeviceContext(), + SCDesc // + } +{ + m_vkDevice = pEnv->GetVkDevice(); + + VkFormat ColorFormat = VK_FORMAT_UNDEFINED; + switch (m_SwapChainDesc.ColorBufferFormat) + { + case TEX_FORMAT_RGBA8_UNORM: + ColorFormat = VK_FORMAT_R8G8B8A8_UNORM; + break; + + default: + UNSUPPORTED("Texture format ", GetTextureFormatAttribs(m_SwapChainDesc.ColorBufferFormat).Name, " is not a supported color buffer format"); + } + pEnv->CreateImage2D(m_SwapChainDesc.Width, m_SwapChainDesc.Height, ColorFormat, + VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT, + m_vkRenerTargetLayout, + m_vkRenderTargetMemory, m_vkRenderTargetImage); + + + VkFormat DepthFormat = VK_FORMAT_UNDEFINED; + switch (m_SwapChainDesc.DepthBufferFormat) + { + case TEX_FORMAT_D32_FLOAT: + DepthFormat = VK_FORMAT_D32_SFLOAT; + break; + + default: + UNSUPPORTED("Texture format ", GetTextureFormatAttribs(m_SwapChainDesc.DepthBufferFormat).Name, " is not a supported depth buffer format"); + } + pEnv->CreateImage2D(m_SwapChainDesc.Width, m_SwapChainDesc.Height, DepthFormat, + VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT, + m_vkDepthBufferLayout, + m_vkDepthBufferMemory, m_vkDepthBufferImage); + + { + VERIFY(m_SwapChainDesc.ColorBufferFormat == TEX_FORMAT_RGBA8_UNORM, "Unexpected color buffer format"); + m_StagingBufferSize = m_SwapChainDesc.Width * m_SwapChainDesc.Height * 4; + pEnv->CreateBuffer(m_StagingBufferSize, VK_IMAGE_USAGE_TRANSFER_DST_BIT, + VK_MEMORY_PROPERTY_HOST_COHERENT_BIT | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_CACHED_BIT, + m_vkStagingBufferMemory, m_vkStagingBuffer); + } + + VkImageViewCreateInfo ImageViewCI = {}; + + ImageViewCI.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; + ImageViewCI.pNext = nullptr; + ImageViewCI.flags = 0; // reserved for future use. + ImageViewCI.image = m_vkRenderTargetImage; + ImageViewCI.format = ColorFormat; + ImageViewCI.viewType = VK_IMAGE_VIEW_TYPE_2D; + ImageViewCI.components.r = VK_COMPONENT_SWIZZLE_IDENTITY; + ImageViewCI.components.g = VK_COMPONENT_SWIZZLE_IDENTITY; + ImageViewCI.components.b = VK_COMPONENT_SWIZZLE_IDENTITY; + ImageViewCI.components.a = VK_COMPONENT_SWIZZLE_IDENTITY; + + ImageViewCI.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; + ImageViewCI.subresourceRange.levelCount = 1; + ImageViewCI.subresourceRange.layerCount = 1; + + auto res = vkCreateImageView(m_vkDevice, &ImageViewCI, nullptr, &m_vkRenderTargetView); + VERIFY_EXPR(res >= 0); + + ImageViewCI.image = m_vkDepthBufferImage; + ImageViewCI.format = DepthFormat; + ImageViewCI.subresourceRange.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT; + + res = vkCreateImageView(m_vkDevice, &ImageViewCI, nullptr, &m_vkDepthBufferView); + VERIFY_EXPR(res >= 0); + + + std::array Attachments; + std::array AttachmentReferences; + + VkSubpassDescription Subpass; + + auto RenderPassCI = + TestingEnvironmentVk::GetRenderPassCreateInfo(1, &ColorFormat, DepthFormat, 1, + VK_ATTACHMENT_LOAD_OP_CLEAR, VK_ATTACHMENT_LOAD_OP_CLEAR, + Attachments, AttachmentReferences, Subpass); + res = vkCreateRenderPass(m_vkDevice, &RenderPassCI, nullptr, &m_vkRenderPass); + VERIFY_EXPR(res >= 0); + + CreateFramebuffer(); +} + +void TestingSwapChainVk::CreateFramebuffer() +{ + VkFramebufferCreateInfo FramebufferCI = {}; + + FramebufferCI.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO; + FramebufferCI.pNext = nullptr; + FramebufferCI.flags = 0; // reserved for future use + FramebufferCI.renderPass = m_vkRenderPass; + FramebufferCI.attachmentCount = 2; + VkImageView Attachments[2] = {m_vkDepthBufferView, m_vkRenderTargetView}; + FramebufferCI.pAttachments = Attachments; + FramebufferCI.width = m_SwapChainDesc.Width; + FramebufferCI.height = m_SwapChainDesc.Height; + FramebufferCI.layers = 1; + + auto res = vkCreateFramebuffer(m_vkDevice, &FramebufferCI, nullptr, &m_vkFramebuffer); + VERIFY_EXPR(res >= 0); +} + +TestingSwapChainVk::~TestingSwapChainVk() +{ + if (m_vkRenderTargetImage != VK_NULL_HANDLE) + vkDestroyImage(m_vkDevice, m_vkRenderTargetImage, nullptr); + if (m_vkRenderTargetMemory != VK_NULL_HANDLE) + vkFreeMemory(m_vkDevice, m_vkRenderTargetMemory, nullptr); + + if (m_vkDepthBufferImage != VK_NULL_HANDLE) + vkDestroyImage(m_vkDevice, m_vkDepthBufferImage, nullptr); + if (m_vkDepthBufferMemory != VK_NULL_HANDLE) + vkFreeMemory(m_vkDevice, m_vkDepthBufferMemory, nullptr); + + if (m_vkStagingBuffer != VK_NULL_HANDLE) + vkDestroyBuffer(m_vkDevice, m_vkStagingBuffer, nullptr); + if (m_vkStagingBufferMemory != VK_NULL_HANDLE) + vkFreeMemory(m_vkDevice, m_vkStagingBufferMemory, nullptr); + + if (m_vkRenderPass != VK_NULL_HANDLE) + vkDestroyRenderPass(m_vkDevice, m_vkRenderPass, nullptr); + if (m_vkFramebuffer != VK_NULL_HANDLE) + vkDestroyFramebuffer(m_vkDevice, m_vkFramebuffer, nullptr); + + if (m_vkRenderTargetView != VK_NULL_HANDLE) + vkDestroyImageView(m_vkDevice, m_vkRenderTargetView, nullptr); + if (m_vkDepthBufferView != VK_NULL_HANDLE) + vkDestroyImageView(m_vkDevice, m_vkDepthBufferView, nullptr); +} + +void TestingSwapChainVk::TransitionRenderTarget(VkCommandBuffer vkCmdBuffer, VkImageLayout Layout, VkPipelineStageFlags GraphicsShaderStages) +{ + m_ActiveGraphicsShaderStages = GraphicsShaderStages; + VkImageSubresourceRange SubresRange = {}; + + SubresRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; + SubresRange.layerCount = 1; + SubresRange.levelCount = 1; + TestingEnvironmentVk::TransitionImageLayout(vkCmdBuffer, m_vkRenderTargetImage, m_vkRenerTargetLayout, + Layout, SubresRange, GraphicsShaderStages); +} + +void TestingSwapChainVk::TransitionDepthBuffer(VkCommandBuffer vkCmdBuffer, VkImageLayout Layout, VkPipelineStageFlags GraphicsShaderStages) +{ + m_ActiveGraphicsShaderStages = GraphicsShaderStages; + VkImageSubresourceRange SubresRange = {}; + + SubresRange.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT; + SubresRange.layerCount = 1; + SubresRange.levelCount = 1; + TestingEnvironmentVk::TransitionImageLayout(vkCmdBuffer, m_vkDepthBufferImage, m_vkDepthBufferLayout, + Layout, SubresRange, GraphicsShaderStages); +} + +void TestingSwapChainVk::BeginRenderPass(VkCommandBuffer vkCmdBuffer, VkPipelineStageFlags GraphicsShaderStages) +{ + TransitionRenderTarget(vkCmdBuffer, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, GraphicsShaderStages); + TransitionDepthBuffer(vkCmdBuffer, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, GraphicsShaderStages); + + VkRenderPassBeginInfo BeginInfo = {}; + + BeginInfo.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO; + BeginInfo.renderPass = m_vkRenderPass; + BeginInfo.framebuffer = m_vkFramebuffer; + BeginInfo.renderArea.extent = VkExtent2D{m_SwapChainDesc.Width, m_SwapChainDesc.Height}; + + VkClearValue ClearValues[2] = {}; + + ClearValues[0].depthStencil.depth = 1; + ClearValues[1].color.float32[0] = 0; + ClearValues[1].color.float32[1] = 0; + ClearValues[1].color.float32[2] = 0; + ClearValues[1].color.float32[3] = 0; + + BeginInfo.clearValueCount = 2; + BeginInfo.pClearValues = ClearValues; + + vkCmdBeginRenderPass(vkCmdBuffer, &BeginInfo, VK_SUBPASS_CONTENTS_INLINE); +} + +void TestingSwapChainVk::EndRenderPass(VkCommandBuffer vkCmdBuffer) +{ + vkCmdEndRenderPass(vkCmdBuffer); +} + + +void TestingSwapChainVk::TakeSnapshot() +{ + auto* pEnv = TestingEnvironmentVk::GetInstance(); + auto* pContext = pEnv->GetDeviceContext(); + + VkCommandBuffer vkCmdBuffer = pEnv->AllocateCommandBuffer(); + + TransitionRenderTarget(vkCmdBuffer, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, m_ActiveGraphicsShaderStages); + + VkBufferImageCopy BuffImgCopy = {}; + + BuffImgCopy.imageExtent = VkExtent3D{m_SwapChainDesc.Width, m_SwapChainDesc.Height, 1}; + BuffImgCopy.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; + BuffImgCopy.imageSubresource.layerCount = 1; + VERIFY(m_SwapChainDesc.ColorBufferFormat == TEX_FORMAT_RGBA8_UNORM, "Unexpected color buffer format"); + BuffImgCopy.bufferRowLength = m_SwapChainDesc.Width; // In texels + + vkCmdCopyImageToBuffer(vkCmdBuffer, m_vkRenderTargetImage, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, + m_vkStagingBuffer, 1, &BuffImgCopy); + vkEndCommandBuffer(vkCmdBuffer); + + + RefCntAutoPtr pContextVk{pContext, IID_DeviceContextVk}; + + auto* pQeueVk = pContextVk->LockCommandQueue(); + auto vkQueue = pQeueVk->GetVkQueue(); + + VkSubmitInfo SubmitInfo = {}; + SubmitInfo.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; + SubmitInfo.pCommandBuffers = &vkCmdBuffer; + SubmitInfo.commandBufferCount = 1; + vkQueueSubmit(vkQueue, 1, &SubmitInfo, VK_NULL_HANDLE); + vkQueueWaitIdle(vkQueue); + + VERIFY_EXPR(m_StagingBufferSize == m_SwapChainDesc.Width * m_SwapChainDesc.Height * 4); + void* pStagingDataPtr = nullptr; + vkMapMemory(m_vkDevice, m_vkStagingBufferMemory, 0, m_StagingBufferSize, 0, &pStagingDataPtr); + + m_ReferenceDataPitch = m_SwapChainDesc.Width * 4; + m_ReferenceData.resize(m_SwapChainDesc.Height * m_ReferenceDataPitch); + for (Uint32 row = 0; row < m_SwapChainDesc.Height; ++row) + { + memcpy(&m_ReferenceData[row * m_ReferenceDataPitch], + reinterpret_cast(pStagingDataPtr) + m_SwapChainDesc.Width * 4 * row, + m_ReferenceDataPitch); + } + + vkUnmapMemory(m_vkDevice, m_vkStagingBufferMemory); + pContextVk->UnlockCommandQueue(); +} + +void CreateTestingSwapChainVk(TestingEnvironmentVk* pEnv, + const SwapChainDesc& SCDesc, + ISwapChain** ppSwapChain) +{ + TestingSwapChainVk* pTestingSC(MakeNewRCObj()(pEnv, SCDesc)); + pTestingSC->QueryInterface(IID_SwapChain, reinterpret_cast(ppSwapChain)); +} + +} // namespace Testing + +} // namespace Diligent diff --git a/Tests/DiligentCoreAPITest/src/Win32/TestingEnvironmentWin32.cpp b/Tests/DiligentCoreAPITest/src/Win32/TestingEnvironmentWin32.cpp new file mode 100644 index 00000000..bc241ffc --- /dev/null +++ b/Tests/DiligentCoreAPITest/src/Win32/TestingEnvironmentWin32.cpp @@ -0,0 +1,69 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "TestingEnvironment.h" + +#ifndef NOMINMAX +# define NOMINMAX +#endif +#include + +namespace Diligent +{ + +namespace Testing +{ + +TestingEnvironment::NativeWindow TestingEnvironment::CreateNativeWindow() +{ +#ifdef UNICODE + const auto* const WindowClassName = L"SampleApp"; +#else + const auto* const WindowClassName = "SampleApp"; +#endif + // Register window class + HINSTANCE instance = NULL; + + WNDCLASSEX wcex = {sizeof(WNDCLASSEX), CS_HREDRAW | CS_VREDRAW, DefWindowProc, + 0L, 0L, instance, NULL, NULL, NULL, NULL, WindowClassName, NULL}; + RegisterClassEx(&wcex); + + LONG WindowWidth = 512; + LONG WindowHeight = 512; + RECT rc = {0, 0, WindowWidth, WindowHeight}; + AdjustWindowRect(&rc, WS_OVERLAPPEDWINDOW, FALSE); + HWND wnd = CreateWindowA("SampleApp", "Dummy Window", + WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, + rc.right - rc.left, rc.bottom - rc.top, NULL, NULL, instance, NULL); + if (wnd == NULL) + LOG_ERROR_AND_THROW("Unable to create a window"); + + NativeWindow NativeWnd; + NativeWnd.NativeWindowHandle = wnd; + + return NativeWnd; +} + +} // namespace Testing + +} // namespace Diligent diff --git a/Tests/DiligentCoreAPITest/src/main.cpp b/Tests/DiligentCoreAPITest/src/main.cpp new file mode 100644 index 00000000..bacaca9f --- /dev/null +++ b/Tests/DiligentCoreAPITest/src/main.cpp @@ -0,0 +1,176 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include + +#include "gtest/gtest.h" +#include "TestingEnvironment.h" + +#if PLATFORM_WIN32 +# include +#endif + + +namespace Diligent +{ + +namespace Testing +{ + +#if D3D11_SUPPORTED +TestingEnvironment* CreateTestingEnvironmentD3D11(DeviceType deviceType, ADAPTER_TYPE AdapterType, const SwapChainDesc& SCDesc); +#endif + +#if D3D12_SUPPORTED +TestingEnvironment* CreateTestingEnvironmentD3D12(DeviceType deviceType, ADAPTER_TYPE AdapterType, const SwapChainDesc& SCDesc); +#endif + +#if GL_SUPPORTED || GLES_SUPPORTED +TestingEnvironment* CreateTestingEnvironmentGL(DeviceType deviceType, ADAPTER_TYPE AdapterType, const SwapChainDesc& SCDesc); +#endif + +#if VULKAN_SUPPORTED +TestingEnvironment* CreateTestingEnvironmentVk(DeviceType deviceType, ADAPTER_TYPE AdapterType, const SwapChainDesc& SCDesc); +#endif + +#if METAL_SUPPORTED + +#endif + +} // namespace Testing + +} // namespace Diligent + + +using namespace Diligent; +using namespace Diligent::Testing; + +int main(int argc, char** argv) +{ +#if PLATFORM_WIN32 + _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); +#endif + + ::testing::InitGoogleTest(&argc, argv); + + DeviceType deviceType = DeviceType::Undefined; + ADAPTER_TYPE AdapterType = ADAPTER_TYPE_UNKNOWN; + for (int i = 1; i < argc; ++i) + { + const auto* arg = argv[i]; + if (strcmp(arg, "--mode=d3d11") == 0) + { + deviceType = DeviceType::D3D11; + } + else if (strcmp(arg, "--mode=d3d11_sw") == 0) + { + deviceType = DeviceType::D3D11; + AdapterType = ADAPTER_TYPE_SOFTWARE; + } + else if (strcmp(arg, "--mode=d3d12") == 0) + { + deviceType = DeviceType::D3D12; + } + else if (strcmp(arg, "--mode=d3d12_sw") == 0) + { + deviceType = DeviceType::D3D12; + AdapterType = ADAPTER_TYPE_SOFTWARE; + } + else if (strcmp(arg, "--mode=vk") == 0) + { + deviceType = DeviceType::Vulkan; + } + else if (strcmp(arg, "--mode=gl") == 0) + { + deviceType = DeviceType::OpenGL; + } + } + + if (deviceType == DeviceType::Undefined) + { + LOG_ERROR_MESSAGE("Device type is not specified"); + return -1; + } + + SwapChainDesc SCDesc; + SCDesc.Width = 512; + SCDesc.Height = 512; + SCDesc.ColorBufferFormat = TEX_FORMAT_RGBA8_UNORM; + SCDesc.DepthBufferFormat = TEX_FORMAT_D32_FLOAT; + + Diligent::Testing::TestingEnvironment* pEnv = nullptr; + try + { + switch (deviceType) + { +#if D3D11_SUPPORTED + case DeviceType::D3D11: + pEnv = CreateTestingEnvironmentD3D11(deviceType, AdapterType, SCDesc); + if (AdapterType == ADAPTER_TYPE_SOFTWARE) + std::cout << "\n\n\n================ Testing Diligent Core API in Direct3D11-SW mode =================\n\n"; + else + std::cout << "\n\n\n================== Testing Diligent Core API in Direct3D11 mode ==================\n\n"; + break; +#endif + +#if D3D12_SUPPORTED + case DeviceType::D3D12: + pEnv = CreateTestingEnvironmentD3D12(deviceType, AdapterType, SCDesc); + if (AdapterType == ADAPTER_TYPE_SOFTWARE) + std::cout << "\n\n\n================ Testing Diligent Core API in Direct3D12-SW mode =================\n\n"; + else + std::cout << "\n\n\n================== Testing Diligent Core API in Direct3D12 mode ==================\n\n"; + break; +#endif + +#if GL_SUPPORTED || GLES_SUPPORTED + case DeviceType::OpenGL: + case DeviceType::OpenGLES: + pEnv = CreateTestingEnvironmentGL(deviceType, AdapterType, SCDesc); + std::cout << "\n\n\n==================== Testing Diligent Core API in OpenGL mode ====================\n\n"; + break; + +#endif + +#if VULKAN_SUPPORTED + case DeviceType::Vulkan: + pEnv = CreateTestingEnvironmentVk(deviceType, AdapterType, SCDesc); + std::cout << "\n\n\n==================== Testing Diligent Core API in Vulkan mode ====================\n\n"; + break; + +#endif + + default: + LOG_ERROR_AND_THROW("Unsupported device type"); + } + } + catch (...) + { + return -1; + } + ::testing::AddGlobalTestEnvironment(pEnv); + + auto ret_val = RUN_ALL_TESTS(); + std::cout << "\n\n\n"; + return ret_val; +} diff --git a/Tests/DiligentCoreTest/CMakeLists.txt b/Tests/DiligentCoreTest/CMakeLists.txt new file mode 100644 index 00000000..780a9cc2 --- /dev/null +++ b/Tests/DiligentCoreTest/CMakeLists.txt @@ -0,0 +1,28 @@ +cmake_minimum_required (VERSION 3.6) + +project(DiligentCoreTest) + +file(GLOB COMMON_SOURCE src/Common/*) +file(GLOB GRAPHICS_ACCESSORIES_SOURCE src/GraphicsAccessories/*) +file(GLOB PLATFORMS_SOURCE src/Platforms/*) + +set(SOURCE ${COMMON_SOURCE} ${GRAPHICS_ACCESSORIES_SOURCE} ${PLATFORMS_SOURCE}) +set(INCLUDE) + +add_executable(DiligentCoreTest ${SOURCE} ${INCLUDE}) +set_common_target_properties(DiligentCoreTest) + +target_link_libraries(DiligentCoreTest +PRIVATE + gtest_main + Diligent-BuildSettings + Diligent-TargetPlatform + Diligent-GraphicsAccessories + Diligent-Common +) + +source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${SOURCE} ${INCLUDE}) + +set_target_properties(DiligentCoreTest PROPERTIES + FOLDER "DiligentCore/Tests" +) diff --git a/Tests/DiligentCoreTest/src/Common/AllocatorTest.cpp b/Tests/DiligentCoreTest/src/Common/AllocatorTest.cpp new file mode 100644 index 00000000..6bf30956 --- /dev/null +++ b/Tests/DiligentCoreTest/src/Common/AllocatorTest.cpp @@ -0,0 +1,79 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "DefaultRawMemoryAllocator.h" +#include "FixedBlockMemoryAllocator.h" + +#include "gtest/gtest.h" + +using namespace Diligent; + +namespace +{ + +TEST(Common_FixedBlockMemoryAllocator, AllocDealloc) +{ + constexpr Uint32 AllocSize = 32; + constexpr Uint32 NumAllocationsPerPage = 16; + + FixedBlockMemoryAllocator TestAllocator(DefaultRawMemoryAllocator::GetAllocator(), AllocSize, NumAllocationsPerPage); + + void* Allocations[NumAllocationsPerPage][2] = {}; + for (int p = 0; p < 2; ++p) + { + for (int a = 1; a < NumAllocationsPerPage; ++a) + { + for (int i = 0; i < a; ++i) + Allocations[i][p] = TestAllocator.Allocate(AllocSize, "Fixed block allocator test", __FILE__, __LINE__); + + for (int i = a - 1; i >= 0; --i) + TestAllocator.Free(Allocations[i][p]); + + for (int i = 0; i < a; ++i) + { + auto* NewAlloc = TestAllocator.Allocate(AllocSize, "Fixed block allocator test", __FILE__, __LINE__); + EXPECT_EQ(Allocations[i][p], NewAlloc); + } + + for (int i = a - 1; i >= 0; --i) + TestAllocator.Free(Allocations[i][p]); + } + for (int i = 0; i < NumAllocationsPerPage; ++i) + Allocations[i][p] = TestAllocator.Allocate(AllocSize, "Fixed block allocator test", __FILE__, __LINE__); + } + + for (int p = 0; p < 2; ++p) + for (int i = 0; i < NumAllocationsPerPage; ++i) + TestAllocator.Free(Allocations[i][p]); + + for (int p = 0; p < 2; ++p) + for (int i = 0; i < NumAllocationsPerPage; ++i) + Allocations[i][p] = TestAllocator.Allocate(AllocSize, "Fixed block allocator test", __FILE__, __LINE__); + + for (int p = 0; p < 2; ++p) + for (int s = 0; s < 5; ++s) + for (int i = s; i < NumAllocationsPerPage; i += 5) + TestAllocator.Free(Allocations[i][p]); +} + +} // namespace diff --git a/Tests/DiligentCoreTest/src/Common/MathLibTest.cpp b/Tests/DiligentCoreTest/src/Common/MathLibTest.cpp new file mode 100644 index 00000000..63040de2 --- /dev/null +++ b/Tests/DiligentCoreTest/src/Common/MathLibTest.cpp @@ -0,0 +1,929 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "BasicMath.h" +#include "AdvancedMath.h" + +#include "gtest/gtest.h" + +using namespace Diligent; + +namespace +{ + +// Constructors +TEST(Common_BasicMath, VectorConstructors) +{ + { + float2 f2{1, 2}; + + EXPECT_EQ(f2.x, 1); + EXPECT_EQ(f2.y, 2); + + EXPECT_EQ(f2.x, f2[0]); + EXPECT_EQ(f2.y, f2[1]); + } + + { + float3 f3{1, 2, 3}; + + EXPECT_EQ(f3.x, 1); + EXPECT_EQ(f3.y, 2); + EXPECT_EQ(f3.z, 3); + + EXPECT_EQ(f3.x, f3[0]); + EXPECT_EQ(f3.y, f3[1]); + EXPECT_EQ(f3.z, f3[2]); + } + + { + float4 f4{1, 2, 3, 4}; + + EXPECT_EQ(f4.x, 1); + EXPECT_EQ(f4.y, 2); + EXPECT_EQ(f4.z, 3); + EXPECT_EQ(f4.w, 4); + + EXPECT_EQ(f4.x, f4[0]); + EXPECT_EQ(f4.y, f4[1]); + EXPECT_EQ(f4.z, f4[2]); + EXPECT_EQ(f4.w, f4[3]); + } +} + +// a - b +TEST(Common_BasicMath, OpeartorMinus) +{ + { + auto v = float2{5, 3} - float2{1, 2}; + EXPECT_EQ(v.x, 4); + EXPECT_EQ(v.y, 1); + } + + { + auto v = float3{5, 3, 20} - float3{1, 2, 10}; + EXPECT_EQ(v.x, 4); + EXPECT_EQ(v.y, 1); + EXPECT_EQ(v.z, 10); + } + + { + auto v = float4{5, 3, 20, 200} - float4{1, 2, 10, 100}; + EXPECT_EQ(v.x, 4); + EXPECT_EQ(v.y, 1); + EXPECT_EQ(v.z, 10); + EXPECT_EQ(v.w, 100); + } +} + +// a -= b +TEST(Common_BasicMath, OpeartorMinusEqual) +{ + { + auto v = float2{5, 3}; + v -= float2{1, 2}; + EXPECT_EQ(v.x, 4); + EXPECT_EQ(v.y, 1); + } + + { + auto v = float3{5, 3, 20}; + v -= float3{1, 2, 10}; + EXPECT_EQ(v.x, 4); + EXPECT_EQ(v.y, 1); + EXPECT_EQ(v.z, 10); + } + + { + auto v = float4{5, 3, 20, 200}; + v -= float4{1, 2, 10, 100}; + EXPECT_EQ(v.x, 4); + EXPECT_EQ(v.y, 1); + EXPECT_EQ(v.z, 10); + EXPECT_EQ(v.w, 100); + } +} + +// -a +TEST(Common_BasicMath, UnaryMinus) +{ + { + auto v = -float2{1, 2}; + EXPECT_EQ(v.x, -1); + EXPECT_EQ(v.y, -2); + } + + { + auto v = -float3{1, 2, 3}; + EXPECT_EQ(v.x, -1); + EXPECT_EQ(v.y, -2); + EXPECT_EQ(v.z, -3); + } + + { + auto v = -float4{1, 2, 3, 4}; + EXPECT_EQ(v.x, -1); + EXPECT_EQ(v.y, -2); + EXPECT_EQ(v.z, -3); + EXPECT_EQ(v.w, -4); + } +} + +// a + b +TEST(Common_BasicMath, OperatorPlus) +{ + // a + b + { + auto v = float2{5, 3} + float2{1, 2}; + EXPECT_EQ(v.x, 6); + EXPECT_EQ(v.y, 5); + } + + { + auto v = float3{5, 3, 20} + float3{1, 2, 10}; + EXPECT_EQ(v.x, 6); + EXPECT_EQ(v.y, 5); + EXPECT_EQ(v.z, 30); + } + + { + auto v = float4{5, 3, 20, 200} + float4{1, 2, 10, 100}; + EXPECT_EQ(v.x, 6); + EXPECT_EQ(v.y, 5); + EXPECT_EQ(v.z, 30); + EXPECT_EQ(v.w, 300); + } +} + +// a += b +TEST(Common_BasicMath, OpeartorPlusEqual) +{ + { + auto v = float2{5, 3}; + v += float2{1, 2}; + EXPECT_EQ(v.x, 6); + EXPECT_EQ(v.y, 5); + } + + { + auto v = float3{5, 3, 20}; + v += float3{1, 2, 10}; + EXPECT_EQ(v.x, 6); + EXPECT_EQ(v.y, 5); + EXPECT_EQ(v.z, 30); + } + + { + auto v = float4{5, 3, 20, 200}; + v += float4{1, 2, 10, 100}; + EXPECT_EQ(v.x, 6); + EXPECT_EQ(v.y, 5); + EXPECT_EQ(v.z, 30); + EXPECT_EQ(v.w, 300); + } +} + +// a * b +TEST(Common_BasicMath, VectorVectorMultiply) +{ + { + auto v = float2{5, 3} * float2{1, 2}; + EXPECT_EQ(v.x, 5); + EXPECT_EQ(v.y, 6); + } + + { + auto v = float3{5, 3, 20} * float3{1, 2, 3}; + EXPECT_EQ(v.x, 5); + EXPECT_EQ(v.y, 6); + EXPECT_EQ(v.z, 60); + } + + { + auto v = float4{5, 3, 20, 200} * float4{1, 2, 3, 4}; + EXPECT_EQ(v.x, 5); + EXPECT_EQ(v.y, 6); + EXPECT_EQ(v.z, 60); + EXPECT_EQ(v.w, 800); + } +} + +// a *= b +TEST(Common_BasicMath, VectorVectorMultiplyEqual) +{ + { + auto v = float2{5, 3}; + v *= float2{1, 2}; + EXPECT_EQ(v.x, 5); + EXPECT_EQ(v.y, 6); + } + + { + auto v = float3{5, 3, 20}; + v *= float3{1, 2, 3}; + EXPECT_EQ(v.x, 5); + EXPECT_EQ(v.y, 6); + EXPECT_EQ(v.z, 60); + } + + { + auto v = float4{5, 3, 20, 200}; + v *= float4{1, 2, 3, 4}; + EXPECT_EQ(v.x, 5); + EXPECT_EQ(v.y, 6); + EXPECT_EQ(v.z, 60); + EXPECT_EQ(v.w, 800); + } +} + + +// a * s +TEST(Common_BasicMath, VectorScalarMultiply) +{ + { + auto v = float2{5, 3} * 2; + EXPECT_EQ(v.x, 10); + EXPECT_EQ(v.y, 6); + } + + { + auto v = float3{5, 3, 20} * 2; + EXPECT_EQ(v.x, 10); + EXPECT_EQ(v.y, 6); + EXPECT_EQ(v.z, 40); + } + + { + auto v = float4{5, 3, 20, 200} * 2; + EXPECT_EQ(v.x, 10); + EXPECT_EQ(v.y, 6); + EXPECT_EQ(v.z, 40); + EXPECT_EQ(v.w, 400); + } +} + +// a *= s +TEST(Common_BasicMath, VectorScalarMultiplyEqual) +{ + { + auto v = float2{5, 3}; + v *= 2; + EXPECT_EQ(v.x, 10); + EXPECT_EQ(v.y, 6); + } + + { + auto v = float3{5, 3, 20}; + v *= 2; + EXPECT_EQ(v.x, 10); + EXPECT_EQ(v.y, 6); + EXPECT_EQ(v.z, 40); + } + + { + auto v = float4{5, 3, 20, 200}; + v *= 2; + EXPECT_EQ(v.x, 10); + EXPECT_EQ(v.y, 6); + EXPECT_EQ(v.z, 40); + EXPECT_EQ(v.w, 400); + } +} + +// s * a +TEST(Common_BasicMath, ScalarVectorMultiply) +{ + { + auto v = 2.f * float2{5, 3}; + EXPECT_EQ(v.x, 10); + EXPECT_EQ(v.y, 6); + } + + { + auto v = 2.f * float3{5, 3, 20}; + EXPECT_EQ(v.x, 10); + EXPECT_EQ(v.y, 6); + EXPECT_EQ(v.z, 40); + } + + { + auto v = 2.f * float4{5, 3, 20, 200}; + EXPECT_EQ(v.x, 10); + EXPECT_EQ(v.y, 6); + EXPECT_EQ(v.z, 40); + EXPECT_EQ(v.w, 400); + } +} + +// a / s +TEST(Common_BasicMath, VectorScalarDivision) +{ + { + auto v = float2{10, 6} / 2; + EXPECT_EQ(v.x, 5); + EXPECT_EQ(v.y, 3); + } + + { + auto v = float3{10, 6, 40} / 2; + EXPECT_EQ(v.x, 5); + EXPECT_EQ(v.y, 3); + EXPECT_EQ(v.z, 20); + } + + { + auto v = float4{10, 6, 40, 400} / 2; + EXPECT_EQ(v.x, 5); + EXPECT_EQ(v.y, 3); + EXPECT_EQ(v.z, 20); + EXPECT_EQ(v.w, 200); + } +} + +// a / b +TEST(Common_BasicMath, VectorVectorDivision) +{ + { + auto v = float2{6, 4} / float2{1, 2}; + EXPECT_EQ(v.x, 6); + EXPECT_EQ(v.y, 2); + } + + { + auto v = float3{6, 3, 20} / float3{3, 1, 5}; + EXPECT_EQ(v.x, 2); + EXPECT_EQ(v.y, 3); + EXPECT_EQ(v.z, 4); + } + + { + auto v = float4{6, 3, 20, 200} / float4{3, 1, 5, 40}; + EXPECT_EQ(v.x, 2); + EXPECT_EQ(v.y, 3); + EXPECT_EQ(v.z, 4); + EXPECT_EQ(v.w, 5); + } +} + +// a /= b +TEST(Common_BasicMath, VectorVectorDivideEqual) +{ + { + auto v = float2{6, 4}; + v /= float2{1, 2}; + EXPECT_EQ(v.x, 6); + EXPECT_EQ(v.y, 2); + } + + { + auto v = float3{6, 3, 20}; + v /= float3{3, 1, 5}; + EXPECT_EQ(v.x, 2); + EXPECT_EQ(v.y, 3); + EXPECT_EQ(v.z, 4); + } + + { + auto v = float4{6, 3, 20, 200}; + v /= float4{3, 1, 5, 40}; + EXPECT_EQ(v.x, 2); + EXPECT_EQ(v.y, 3); + EXPECT_EQ(v.z, 4); + EXPECT_EQ(v.w, 5); + } +} + + +// a /= s +TEST(Common_BasicMath, VectorScalarDivideEqual) +{ + { + auto v = float2{6, 4}; + v /= 2; + EXPECT_EQ(v.x, 3); + EXPECT_EQ(v.y, 2); + } + + { + auto v = float3{4, 6, 20}; + v /= 2; + EXPECT_EQ(v.x, 2); + EXPECT_EQ(v.y, 3); + EXPECT_EQ(v.z, 10); + } + + { + auto v = float4{4, 6, 20, 200}; + v /= 2; + EXPECT_EQ(v.x, 2); + EXPECT_EQ(v.y, 3); + EXPECT_EQ(v.z, 10); + EXPECT_EQ(v.w, 100); + } +} + + +// max +TEST(Common_BasicMath, StdMax) +{ + { + auto v = std::max(float2{6, 4}, float2{1, 40}); + EXPECT_EQ(v.x, 6); + EXPECT_EQ(v.y, 40); + } + + { + auto v = std::max(float3{4, 6, 20}, float3{40, 3, 23}); + EXPECT_EQ(v.x, 40); + EXPECT_EQ(v.y, 6); + EXPECT_EQ(v.z, 23); + } + + { + auto v = std::max(float4{4, 6, 20, 100}, float4{40, 3, 23, 50}); + EXPECT_EQ(v.x, 40); + EXPECT_EQ(v.y, 6); + EXPECT_EQ(v.z, 23); + EXPECT_EQ(v.w, 100); + } +} + +// min +TEST(Common_BasicMath, StdMin) +{ + { + auto v = std::min(float2{6, 4}, float2{1, 40}); + EXPECT_EQ(v.x, 1); + EXPECT_EQ(v.y, 4); + } + + { + auto v = std::min(float3{4, 6, 20}, float3{40, 3, 23}); + EXPECT_EQ(v.x, 4); + EXPECT_EQ(v.y, 3); + EXPECT_EQ(v.z, 20); + } + + { + auto v = std::min(float4{4, 6, 20, 100}, float4{40, 3, 23, 50}); + EXPECT_EQ(v.x, 4); + EXPECT_EQ(v.y, 3); + EXPECT_EQ(v.z, 20); + EXPECT_EQ(v.w, 50); + } +} + +// a == b +TEST(Common_BasicMath, ComparisonOperators) +{ + { + EXPECT_TRUE(float2(1, 2) == float2(1, 2)); + EXPECT_TRUE(float3(1, 2, 3) == float3(1, 2, 3)); + EXPECT_TRUE(float4(1, 2, 3, 4) == float4(1, 2, 3, 4)); + } + + { + float4 vec4(1, 2, 3, 4); + float3 vec3 = vec4; + EXPECT_TRUE(vec3 == float3(1, 2, 3)); + } + + // a != b + { + EXPECT_TRUE(float2(1, 2) != float2(1, 9)); + EXPECT_TRUE(float2(9, 2) != float2(1, 2)); + EXPECT_TRUE(float3(1, 2, 3) != float3(9, 2, 3)); + EXPECT_TRUE(float3(1, 2, 3) != float3(1, 9, 3)); + EXPECT_TRUE(float3(1, 2, 3) != float3(1, 2, 9)); + EXPECT_TRUE(float4(1, 2, 3, 4) != float4(9, 2, 3, 4)); + EXPECT_TRUE(float4(1, 2, 3, 4) != float4(1, 9, 3, 4)); + EXPECT_TRUE(float4(1, 2, 3, 4) != float4(1, 2, 9, 4)); + EXPECT_TRUE(float4(1, 2, 3, 4) != float4(1, 2, 3, 9)); + } + + // a < b + { + // clang-format off + EXPECT_TRUE((float2(1, 5) < float2(3, 5)) == float2(1, 0)); + EXPECT_TRUE((float2(3, 1) < float2(3, 4)) == float2(0, 1)); + EXPECT_TRUE((float3(1, 5, 10) < float3(3, 5, 20)) == float3(1, 0, 1)); + EXPECT_TRUE((float3(3, 1, 2) < float3(3, 4, 2)) == float3(0, 1, 0)); + EXPECT_TRUE((float4(1, 4, 10, 50) < float4(3, 4, 20, 50)) == float4(1, 0, 1, 0)); + EXPECT_TRUE((float4(3, 1, 2, 30) < float4(3, 4, 2, 70)) == float4(0, 1, 0, 1)); + // clang-format on + } + + // a <= b + { + // clang-format off + EXPECT_TRUE((float2(1, 5) <= float2(1, 4)) == float2(1, 0)); + EXPECT_TRUE((float2(5, 2) <= float2(3, 2)) == float2(0, 1)); + EXPECT_TRUE((float3(3, 5, 10) <= float3(3, 4, 10)) == float3(1, 0, 1)); + EXPECT_TRUE((float3(5, 4, 2) <= float3(3, 4, 0)) == float3(0, 1, 0)); + EXPECT_TRUE((float4(3, 5, 20, 100) <= float4(3, 4, 20, 50)) == float4(1, 0, 1, 0)); + EXPECT_TRUE((float4(5, 4, 2, 70) <= float4(3, 4, 0, 70)) == float4(0, 1, 0, 1)); + // clang-format on + } + + // a >= b + { + // clang-format off + EXPECT_TRUE((float2(1, 5) >= float2(3, 5)) == float2(0, 1)); + EXPECT_TRUE((float2(3, 1) >= float2(3, 4)) == float2(1, 0)); + EXPECT_TRUE((float3(1, 5, 10) >= float3(3, 5, 20)) == float3(0, 1, 0)); + EXPECT_TRUE((float3(3, 1, 2) >= float3(3, 4, 2)) == float3(1, 0, 1)); + EXPECT_TRUE((float4(1, 4, 10, 50) >= float4(3, 4, 20, 50)) == float4(0, 1, 0, 1)); + EXPECT_TRUE((float4(3, 1, 2, 30) >= float4(3, 4, 2, 70)) == float4(1, 0, 1, 0)); + // clang-format on + } + + // a > b + { + // clang-format off + EXPECT_TRUE((float2(1, 5) > float2(1, 4)) == float2(0, 1)); + EXPECT_TRUE((float2(5, 2) > float2(3, 2)) == float2(1, 0)); + EXPECT_TRUE((float3(3, 5, 10) > float3(3, 4, 10)) == float3(0, 1, 0)); + EXPECT_TRUE((float3(5, 4, 2) > float3(3, 4, 0)) == float3(1, 0, 1)); + EXPECT_TRUE((float4(3, 5, 20, 100) > float4(3, 4, 20, 50)) == float4(0, 1, 0, 1)); + EXPECT_TRUE((float4(5, 4, 2, 70) > float4(3, 4, 0, 70)) == float4(1, 0, 1, 0)); + // clang-format on + } +} + +// Functions +TEST(Common_BasicMath, Abs) +{ + { + // clang-format off + EXPECT_EQ(abs(float2(-1, -5)), float2(1, 5)); + EXPECT_EQ(abs(float2( 1, 5)), float2(1, 5)); + + EXPECT_EQ(abs(float3(-1, -5, -10)), float3(1, 5, 10)); + EXPECT_EQ(abs(float3( 1, 5, 10)), float3(1, 5, 10)); + + EXPECT_EQ(abs(float4(-1, -5, -10, -100)), float4(1, 5, 10, 100)); + EXPECT_EQ(abs(float4( 1, 5, 10, 100)), float4(1, 5, 10, 100)); + // clang-format on + } + + // clamp + { + // clang-format off + EXPECT_EQ(clamp(-1, 1, 10), 1); + EXPECT_EQ(clamp(11, 1, 10), 10); + EXPECT_EQ(clamp( 9, 1, 10), 9); + + EXPECT_EQ(clamp(float2(-10, -11), float2(1, 2), float2(10, 11)), float2(1, 2)); + EXPECT_EQ(clamp(float2( 11, 12), float2(1, 2), float2(10, 11)), float2(10, 11)); + EXPECT_EQ(clamp(float2( 9, 8), float2(1, 2), float2(10, 11)), float2(9, 8)); + + EXPECT_EQ(clamp(float3(-10, -11, -12), float3(1, 2, 3), float3(10, 11, 12)), float3( 1, 2, 3)); + EXPECT_EQ(clamp(float3( 11, 12, 13), float3(1, 2, 3), float3(10, 11, 12)), float3(10, 11, 12)); + EXPECT_EQ(clamp(float3( 9, 8, 7), float3(1, 2, 3), float3(10, 11, 12)), float3( 9, 8, 7)); + + EXPECT_EQ(clamp(float4(-10, -11, -12, -13), float4(1, 2, 3, 4), float4(10, 11, 12, 13)), float4( 1, 2, 3, 4)); + EXPECT_EQ(clamp(float4( 11, 12, 13, 14), float4(1, 2, 3, 4), float4(10, 11, 12, 13)), float4(10, 11, 12, 13)); + EXPECT_EQ(clamp(float4( 9, 8, 7, 6), float4(1, 2, 3, 4), float4(10, 11, 12, 13)), float4( 9, 8, 7, 6)); + // clang-format on + } + + // dot + { + EXPECT_EQ(dot(float2(1, 2), float2(1, 2)), 5); + EXPECT_EQ(dot(float3(1, 2, 3), float3(1, 2, 3)), 14); + EXPECT_EQ(dot(float4(1, 2, 3, 4), float4(1, 2, 3, 4)), 30); + } + + // length + { + auto l = length(float2(3, 4)); + EXPECT_NEAR(l, 5.f, 1e-6); + } +} + + +TEST(Common_BasicMath, MatrixConstructors) +{ + // Matrix 2x2 + { + // clang-format off + float2x2 m1 + { + 1, 2, + 5, 6 + }; + float2x2 m2 + { + 1, 2, + 5, 6 + }; + // clang-format on + EXPECT_TRUE(m1._11 == 1 && m1._12 == 2 && + m1._21 == 5 && m1._22 == 6); + EXPECT_TRUE(m1[0][0] == 1 && m1[0][1] == 2 && + m1[1][0] == 5 && m1[1][1] == 6); + + EXPECT_TRUE(m1 == m2); + auto t = m1.Transpose().Transpose(); + EXPECT_TRUE(t == m1); + } + + // Matrix 3x3 + { + // clang-format off + float3x3 m1 + { + 1, 2, 3, + 5, 6, 7, + 9, 10, 11 + }; + float3x3 m2 + { + 1, 2, 3, + 5, 6, 7, + 9, 10, 11 + }; + + EXPECT_TRUE(m1._11 == 1 && m1._12 == 2 && m1._13 == 3 && + m1._21 == 5 && m1._22 == 6 && m1._23 == 7 && + m1._31 == 9 && m1._32 == 10 && m1._33 == 11); + EXPECT_TRUE(m1[0][0] == 1 && m1[0][1] == 2 && m1[0][2] == 3 && + m1[1][0] == 5 && m1[1][1] == 6 && m1[1][2] == 7 && + m1[2][0] == 9 && m1[2][1] == 10 && m1[2][2] == 11); + + // clang-format on + + EXPECT_TRUE(m1 == m2); + auto t = m1.Transpose().Transpose(); + EXPECT_TRUE(t == m1); + } + + // Matrix 4x4 + { + // clang-format off + float4x4 m1 + { + 1, 2, 3, 4, + 5, 6, 7, 8, + 9, 10, 11, 12, + 13, 14, 15, 16 + }; + + float4x4 m2 + { + 1, 2, 3, 4, + 5, 6, 7, 8, + 9, 10, 11, 12, + 13, 14, 15, 16 + }; + + EXPECT_TRUE(m1._11 == 1 && m1._12 == 2 && m1._13 == 3 && m1._14 == 4 && + m1._21 == 5 && m1._22 == 6 && m1._23 == 7 && m1._24 == 8 && + m1._31 == 9 && m1._32 == 10 && m1._33 == 11 && m1._34 == 12 && + m1._41 == 13 && m1._42 == 14 && m1._43 == 15 && m1._44 == 16); + EXPECT_TRUE(m1[0][0] == 1 && m1[0][1] == 2 && m1[0][2] == 3 && m1[0][3] == 4 && + m1[1][0] == 5 && m1[1][1] == 6 && m1[1][2] == 7 && m1[1][3] == 8 && + m1[2][0] == 9 && m1[2][1] == 10 && m1[2][2] == 11 && m1[2][3] == 12 && + m1[3][0] == 13 && m1[3][1] == 14 && m1[3][2] == 15 && m1[3][3] == 16); + // clang-format on + + EXPECT_TRUE(m1 == m2); + auto t = m1.Transpose().Transpose(); + EXPECT_TRUE(t == m1); + } +} + +TEST(Common_BasicMath, MatrixInverse) +{ + { + // clang-format off + float4x4 m + { + 7, 8, 3, 6, + 5, 1, 4, 9, + 5, 11, 7, 2, + 13, 4, 19, 8 + }; + // clang-format on + + auto inv = m.Inverse(); + auto identity = m * inv; + + for (int j = 0; j < 4; ++j) + { + for (int i = 0; i < 4; ++i) + { + float ref = i == j ? 1.f : 0.f; + auto val = identity[i][j]; + EXPECT_NEAR(val, ref, 1e-6f); + } + } + } + + // Determinant + { + // clang-format off + float4x4 m1 + { + 1, 2, 3, 4, + 5, 6, 7, 8, + 9, 10, 11, 12, + 13, 14, 15, 16 + }; + // clang-format on + auto det = m1.Determinant(); + EXPECT_EQ(det, 0); + } +} + + +TEST(Common_BasicMath, Hash) +{ + { + EXPECT_NE(std::hash{}(float2{1, 2}), 0); + EXPECT_NE(std::hash{}(float3{1, 2, 3}), 0); + EXPECT_NE(std::hash{}(float4{1, 2, 3, 5}), 0); + // clang-format off + float4x4 m1 + { + 1, 2, 3, 4, + 5, 6, 7, 8, + 9, 10, 11, 12, + 13, 14, 15, 16 + }; + // clang-format on + EXPECT_NE(std::hash{}(m1), 0); + + // clang-format off + float3x3 m2 + { + 1, 2, 3, + 5, 6, 7, + 9, 10, 11 + }; + // clang-format on + EXPECT_NE(std::hash{}(m2), 0); + + // clang-format off + float2x2 m3 + { + 1, 2, + 5, 6 + }; + // clang-format on + EXPECT_NE(std::hash{}(m3), 0); + } +} + +TEST(Common_BasicMath, OrthoProjection) +{ + { + float4x4 OrthoProj = float4x4::Ortho(2.f, 4.f, -4.f, 12.f, false); + + auto c0 = float3{-1.f, -2.f, -4.f} * OrthoProj; + auto c1 = float3{+1.f, +2.f, +12.f} * OrthoProj; + EXPECT_EQ(c0, float3(-1, -1, 0)); + EXPECT_EQ(c1, float3(+1, +1, +1)); + } + + { + float4x4 OrthoProj = float4x4::Ortho(2.f, 4.f, -4.f, 12.f, true); + + auto c0 = float3(-1.f, -2.f, -4.f) * OrthoProj; + auto c1 = float3(+1.f, +2.f, +12.f) * OrthoProj; + EXPECT_EQ(c0, float3(-1, -1, -1)); + EXPECT_EQ(c1, float3(+1, +1, +1)); + } + + { + float4x4 OrthoProj = float4x4::OrthoOffCenter(-2.f, 6.f, -4.f, +12.f, -6.f, 10.f, false); + + auto c0 = float3{-2.f, -4.f, -6.f} * OrthoProj; + auto c1 = float3{+6.f, +12.f, +10.f} * OrthoProj; + EXPECT_EQ(c0, float3(-1, -1, 0)); + EXPECT_EQ(c1, float3(+1, +1, +1)); + } + + { + float4x4 OrthoProj = float4x4::OrthoOffCenter(-2.f, 6.f, -4.f, +12.f, -6.f, 10.f, true); + + auto c0 = float3{-2.f, -4.f, -6.f} * OrthoProj; + auto c1 = float3{+6.f, +12.f, +10.f} * OrthoProj; + EXPECT_EQ(c0, float3(-1, -1, -1)); + EXPECT_EQ(c1, float3(+1, +1, +1)); + } +} + +TEST(Common_BasicMath, MakeObject) +{ + double data[] = {1, 2, 3, 4, + 5, 6, 7, 8, + 9, 10, 11, 12, + 13, 14, 15, 16}; + EXPECT_EQ(float2::MakeVector(data), float2(1, 2)); + EXPECT_EQ(float3::MakeVector(data), float3(1, 2, 3)); + EXPECT_EQ(float4::MakeVector(data), float4(1, 2, 3, 4)); + EXPECT_EQ(Quaternion::MakeQuaternion(data), Quaternion(1, 2, 3, 4)); + EXPECT_EQ(float4x4::MakeMatrix(data), float4x4(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)); + EXPECT_EQ(float3x3::MakeMatrix(data), float3x3(1, 2, 3, 4, 5, 6, 7, 8, 9)); + EXPECT_EQ(float2x2::MakeMatrix(data), float2x2(1, 2, 3, 4)); +} + +TEST(Common_BasicMath, MatrixMultiply) +{ + { + float2x2 m1(1, 2, 3, 4); + float2x2 m2(5, 6, 7, 8); + + auto m = m1; + m *= m2; + EXPECT_EQ(m, m1 * m2); + } + { + float3x3 m1(1, 2, 3, + 4, 5, 6, + 7, 8, 9); + float3x3 m2(10, 11, 12, + 13, 14, 15, + 16, 17, 18); + + auto m = m1; + m *= m2; + EXPECT_EQ(m, m1 * m2); + } + { + float4x4 m1(1, 2, 3, 4, + 5, 6, 7, 8, + 9, 10, 11, 12, + 13, 14, 15, 16); + float4x4 m2(17, 18, 19, 20, + 21, 22, 23, 24, + 25, 26, 27, 28, + 29, 30, 31, 32); + + auto m = m1; + m *= m2; + EXPECT_EQ(m, m1 * m2); + } +} + +TEST(Common_BasicMath, VectorRecast) +{ + { + EXPECT_EQ(float2(1, 2).Recast(), Vector2(1, 2)); + EXPECT_EQ(float3(1, 2, 3).Recast(), Vector3(1, 2, 3)); + EXPECT_EQ(float4(1, 2, 3, 4).Recast(), Vector4(1, 2, 3, 4)); + } +} + +TEST(Common_BasicMath, StdFloorCeil) +{ + { + EXPECT_EQ(std::floor(float2(0.1f, 1.2f)), float2(0, 1)); + EXPECT_EQ(std::floor(float3(0.1f, 1.2f, 2.3f)), float3(0, 1, 2)); + EXPECT_EQ(std::floor(float4(0.1f, 1.2f, 2.3f, 3.4f)), float4(0, 1, 2, 3)); + EXPECT_EQ(std::ceil(float2(0.1f, 1.2f)), float2(1, 2)); + EXPECT_EQ(std::ceil(float3(0.1f, 1.2f, 2.3f)), float3(1, 2, 3)); + EXPECT_EQ(std::ceil(float4(0.1f, 1.2f, 2.3f, 3.4f)), float4(1, 2, 3, 4)); + } +} + +TEST(Common_AdvancedMath, Planes) +{ + Plane3D plane = {}; + EXPECT_NE(std::hash{}(plane), 0); + + ViewFrustum frustum = {}; + EXPECT_NE(std::hash{}(frustum), 0); + + ViewFrustumExt frustm_ext = {}; + EXPECT_NE(std::hash{}(frustm_ext), 0); +} + +TEST(Common_AdvancedMath, HermiteSpline) +{ + EXPECT_NE(HermiteSpline(float3(1, 2, 3), float3(4, 5, 6), float3(7, 8, 9), float3(10, 11, 12), 0.1f), float3(0, 0, 0)); + EXPECT_NE(HermiteSpline(double3(1, 2, 3), double3(4, 5, 6), double3(7, 8, 9), double3(10, 11, 12), 0.1), double3(0, 0, 0)); +} + +} // namespace diff --git a/Tests/DiligentCoreTest/src/Common/RefCntAutoPtrTest.cpp b/Tests/DiligentCoreTest/src/Common/RefCntAutoPtrTest.cpp new file mode 100644 index 00000000..11d3e381 --- /dev/null +++ b/Tests/DiligentCoreTest/src/Common/RefCntAutoPtrTest.cpp @@ -0,0 +1,903 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include +#include +#include +#include +#include + +#include "DefaultRawMemoryAllocator.h" +#include "RefCntAutoPtr.h" +#include "RefCountedObjectImpl.h" +#include "ThreadSignal.h" + +#include "gtest/gtest.h" + +using namespace Diligent; + +template +Type* MakeNewObj() +{ + return MakeNewRCObj{}(); +} + +namespace +{ + +class Object : public Diligent::RefCountedObject +{ +public: + static void Create(Object** ppObj) + { + *ppObj = MakeNewObj(); + (*ppObj)->AddRef(); + } + + virtual void QueryInterface(const Diligent::INTERFACE_ID& IID, Diligent::IObject** ppInterface) + { + *ppInterface = nullptr; + if (IID == Diligent::IID_Unknown) + { + *ppInterface = this; + (*ppInterface)->AddRef(); + } + } + + Object(Diligent::IReferenceCounters* pRefCounters) : + RefCountedObject{pRefCounters}, + m_Value(0) + { + } + + ~Object() {} + std::atomic_int m_Value; +}; + + +class DerivedObject : public Object +{ +public: + DerivedObject(Diligent::IReferenceCounters* pRefCounters) : + Object{pRefCounters}, + m_Value2{1} + {} + int m_Value2; +}; + +using SmartPtr = Diligent::RefCntAutoPtr; +using WeakPtr = Diligent::RefCntWeakPtr; + +TEST(Common_RefCntAutoPtr, Constructors) +{ + { + SmartPtr SP0; + SmartPtr SP1(nullptr); + auto* pRawPtr = MakeNewObj(); + SmartPtr SP2(pRawPtr); + SmartPtr SP2_1(pRawPtr); + EXPECT_EQ(SP2, SP2_1); + + SmartPtr SP3(SP0); + SmartPtr SP4(SP2); + SmartPtr SP5(std::move(SP3)); + EXPECT_TRUE(!SP3); + SmartPtr SP6(std::move(SP4)); + EXPECT_TRUE(!SP4); + + RefCntAutoPtr DerivedSP(MakeNewObj()); + + SmartPtr SP7(DerivedSP); + SmartPtr SP8(std::move(DerivedSP)); + EXPECT_EQ(SP7, SP8); + EXPECT_TRUE(!DerivedSP); + } +} + +TEST(Common_RefCntAutoPtr, AttachDetach) +{ + { + auto* pRawPtr = MakeNewObj(); + + SmartPtr SP0; + SP0.Attach(nullptr); + EXPECT_TRUE(!SP0); + SP0.Attach(pRawPtr); + EXPECT_TRUE(SP0); + pRawPtr->AddRef(); + } + + { + auto* pRawPtr = MakeNewObj(); + + SmartPtr SP0; + pRawPtr->AddRef(); + SP0.Attach(pRawPtr); + EXPECT_TRUE(SP0); + SP0.Attach(nullptr); + EXPECT_TRUE(!SP0); + } + + { + auto* pRawPtr = MakeNewObj(); + + SmartPtr SP0(MakeNewObj()); + SP0.Attach(pRawPtr); + EXPECT_TRUE(SP0); + pRawPtr->AddRef(); + } + + { + SmartPtr SP0(MakeNewObj()); + EXPECT_TRUE(SP0); + + auto* pRawPtr = MakeNewObj(); + pRawPtr->AddRef(); + SP0.Attach(pRawPtr); + auto* pRawPtr2 = SP0.Detach(); + pRawPtr2->Release(); + + auto* pRawPtr3 = SmartPtr().Detach(); + EXPECT_TRUE(pRawPtr3 == nullptr); + auto* pRawPtr4 = SmartPtr(MakeNewObj()).Detach(); + EXPECT_TRUE(pRawPtr4 != nullptr); + pRawPtr4->Release(); + } +} + +TEST(Common_RefCntAutoPtr, OperatorEqual) +{ + { + SmartPtr SP0; + auto pRawPtr1 = MakeNewObj(); + SmartPtr SP1(pRawPtr1); + SmartPtr SP2(pRawPtr1); + SP0 = SP0; + SP0 = std::move(SP0); + SP0 = nullptr; + EXPECT_EQ(SP0, nullptr); + + SP1 = pRawPtr1; + SP1 = SP1; + SP1 = std::move(SP1); + EXPECT_EQ(SP1, pRawPtr1); + + SP1 = SP2; + SP1 = std::move(SP2); + EXPECT_EQ(SP1, pRawPtr1); + + auto pRawPtr2 = MakeNewObj(); + SmartPtr SP3(pRawPtr2); + + SP0 = pRawPtr2; + SmartPtr SP4; + SP4 = SP3; + SmartPtr SP5; + SP5 = std::move(SP4); + EXPECT_TRUE(!SP4); + + SP1 = pRawPtr2; + SP1 = nullptr; + SP1 = std::move(SP5); + EXPECT_TRUE(!SP5); + + RefCntAutoPtr DerivedSP(MakeNewObj()); + SP1 = DerivedSP; + SP2 = std::move(DerivedSP); + EXPECT_TRUE(!DerivedSP); + } +} + +TEST(Common_RefCntAutoPtr, LogicalOperators) +{ + { + auto pRawPtr1 = MakeNewObj(); + auto pRawPtr2 = MakeNewObj(); + SmartPtr SP0, SP1(pRawPtr1), SP2(pRawPtr1), SP3(pRawPtr2); + EXPECT_TRUE(!SP0); + bool b1 = SP0.operator bool(); + EXPECT_TRUE(!b1); + + + EXPECT_TRUE(!(!SP1)); + EXPECT_TRUE(SP1); + EXPECT_TRUE(SP0 != SP1); + EXPECT_TRUE(SP0 == SP0); + EXPECT_TRUE(SP1 == SP1); + EXPECT_TRUE(SP1 == SP2); + EXPECT_TRUE(SP1 != SP3); + EXPECT_TRUE(SP0 < SP3); + EXPECT_TRUE((SP1 < SP3) == (pRawPtr1 < pRawPtr2)); + } +} + +TEST(Common_RefCntAutoPtr, OperatorAmpersand) +{ + { + SmartPtr SP0, SP1(MakeNewObj()), SP2, SP3, SP4(MakeNewObj()); + auto* pRawPtr = MakeNewObj(); + pRawPtr->AddRef(); + + *static_cast(&SP0) = pRawPtr; + SP0.Detach(); + *&SP2 = pRawPtr; + SP2.Detach(); + + Object::Create(&SP3); + + Object::Create(&SP1); + *static_cast(&SP4) = pRawPtr; + + { + SmartPtr SP5(MakeNewObj()); + auto pDblPtr = &SP5; + *pDblPtr = MakeNewObj(); + (*pDblPtr)->AddRef(); + auto pDblPtr2 = &SP5; + Object::Create(pDblPtr2); + } + + SmartPtr SP6(MakeNewObj()); + // This will not work: + // Object **pDblPtr3 = &SP6; + // *pDblPtr3 = new Object; + } +} + +TEST(Common_RefCntWeakPtr, Constructors) +{ + { + SmartPtr SP0, SP1(MakeNewObj()); + WeakPtr WP0; + WeakPtr WP1(WP0); + WeakPtr WP2(SP0); + WeakPtr WP3(SP1); + WeakPtr WP4(WP3); + WeakPtr WP5(std::move(WP0)); + WeakPtr WP6(std::move(WP4)); + + auto* pRawPtr = MakeNewObj(); + pRawPtr->AddRef(); + WeakPtr WP7(pRawPtr); + pRawPtr->Release(); + } +} + + +TEST(Common_RefCntWeakPtr, OperatorEqual) +{ + { + auto* pRawPtr = MakeNewObj(); + SmartPtr SP0, SP1(pRawPtr); + WeakPtr WP0, WP1(SP1), WP2(SP1); + WP0 = WP0; + WP0 = std::move(WP0); + WP1 = WP1; + WP1 = std::move(WP1); + WP1 = WP2; + WP1 = std::move(WP2); + WP1 = pRawPtr; + WP0 = pRawPtr; + WP0.Release(); + WP0 = WP2; + + WP1 = WP0; + WP0 = SP1; + WP2 = std::move(WP1); + } +} + +TEST(Common_RefCntWeakPtr, Lock) +{ + { + SmartPtr SP0, SP1(MakeNewObj()); + WeakPtr WP0, WP1(SP0), WP2(SP1), WP3(SP1); + assert(WP0 == WP1); + assert(WP0 != WP2); + assert(WP2 == WP3); + SP1.Release(); + assert(WP2 == WP3); + } + + // Test Lock() + { + SmartPtr SP0, SP1(MakeNewObj()); + WeakPtr WP0, WP1(SP0), WP2(SP1); + WeakPtr WP3(WP2); + auto L1 = WP0.Lock(); + assert(!L1); + L1 = WP1.Lock(); + assert(!L1); + L1 = WP2.Lock(); + assert(L1); + L1 = WP3.Lock(); + assert(L1); + auto pRawPtr = SP1.Detach(); + L1.Release(); + + L1 = WP3.Lock(); + assert(L1); + L1.Release(); + + pRawPtr->Release(); + + L1 = WP3.Lock(); + assert(!L1); + } +} + +TEST(Common_RefCntAutoPtr, Misc) +{ + { + class OwnerTest : public RefCountedObject + { + public: + OwnerTest(IReferenceCounters* pRefCounters) : + RefCountedObject(pRefCounters), + Obj(NEW_RC_OBJ(DefaultRawMemoryAllocator::GetAllocator(), "Test object", Object, this)()) + { + } + + virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) {} + ~OwnerTest() + { + Obj->~Object(); + DefaultRawMemoryAllocator::GetAllocator().Free(Obj); + } + + private: + Object* Obj; + }; + + OwnerTest* pOwnerObject = MakeNewObj(); + pOwnerObject->AddRef(); + pOwnerObject->Release(); + } + + { + class SelfRefTest : public RefCountedObject + { + public: + SelfRefTest(IReferenceCounters* pRefCounters) : + RefCountedObject(pRefCounters), + wpSelf(this) + {} + + virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) {} + + private: + RefCntWeakPtr wpSelf; + }; + + SelfRefTest* pSelfRefTest = MakeNewObj(); + pSelfRefTest->AddRef(); + pSelfRefTest->Release(); + } + + { + class ExceptionTest1 : public RefCountedObject + { + public: + ExceptionTest1(IReferenceCounters* pRefCounters) : + RefCountedObject(pRefCounters), + wpSelf(this) + { + throw std::runtime_error("test exception"); + } + + virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) {} + + private: + RefCntWeakPtr wpSelf; + }; + + try + { + auto* pExceptionTest = MakeNewObj(); + (void)pExceptionTest; + } + catch (std::runtime_error&) + { + } + } + + { + class ExceptionTest2 : public RefCountedObject + { + public: + ExceptionTest2(IReferenceCounters* pRefCounters) : + RefCountedObject(pRefCounters), + wpSelf(this) + { + throw std::runtime_error("test exception"); + } + + virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) {} + + private: + RefCntWeakPtr wpSelf; + }; + + try + { + auto* pExceptionTest = NEW_RC_OBJ(DefaultRawMemoryAllocator::GetAllocator(), "Test object", ExceptionTest2)(); + (void)pExceptionTest; + } + catch (std::runtime_error&) + { + } + } + + { + class ExceptionTest3 : public RefCountedObject + { + public: + ExceptionTest3(IReferenceCounters* pRefCounters) : + RefCountedObject(pRefCounters), + m_Member(*this) + { + } + + class Subclass + { + public: + Subclass(ExceptionTest3& parent) : + wpSelf(&parent) + { + throw std::runtime_error("test exception"); + } + + private: + RefCntWeakPtr wpSelf; + }; + virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) {} + + private: + Subclass m_Member; + }; + + try + { + auto* pExceptionTest = NEW_RC_OBJ(DefaultRawMemoryAllocator::GetAllocator(), "Test object", ExceptionTest3)(); + (void)pExceptionTest; + } + catch (std::runtime_error&) + { + } + } + + { + class OwnerObject : public RefCountedObject + { + public: + OwnerObject(IReferenceCounters* pRefCounters) : + RefCountedObject(pRefCounters) + {} + + void CreateMember() + { + try + { + m_pMember = NEW_RC_OBJ(DefaultRawMemoryAllocator::GetAllocator(), "Test object", ExceptionTest4, this)(*this); + } + catch (...) + { + } + } + virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) {} + + class ExceptionTest4 : public RefCountedObject + { + public: + ExceptionTest4(IReferenceCounters* pRefCounters, OwnerObject& owner) : + RefCountedObject(pRefCounters), + m_Member(owner, *this) + { + } + + class Subclass + { + public: + Subclass(OwnerObject& owner, ExceptionTest4& parent) : + wpParent(&parent), + wpOwner(&owner) + { + throw std::runtime_error("test exception"); + } + + private: + RefCntWeakPtr wpParent; + RefCntWeakPtr wpOwner; + }; + virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) {} + + private: + Subclass m_Member; + }; + + RefCntAutoPtr m_pMember; + }; + + RefCntAutoPtr pOwner(NEW_RC_OBJ(DefaultRawMemoryAllocator::GetAllocator(), "Test object", OwnerObject)()); + pOwner->CreateMember(); + } + + + { + class OwnerObject : public RefCountedObject + { + public: + OwnerObject(IReferenceCounters* pRefCounters) : + RefCountedObject(pRefCounters) + { + m_pMember = NEW_RC_OBJ(DefaultRawMemoryAllocator::GetAllocator(), "Test object", ExceptionTest4, this)(*this); + } + + virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) {} + + class ExceptionTest4 : public RefCountedObject + { + public: + ExceptionTest4(IReferenceCounters* pRefCounters, OwnerObject& owner) : + RefCountedObject(pRefCounters), + m_Member(owner, *this) + { + } + + class Subclass + { + public: + Subclass(OwnerObject& owner, ExceptionTest4& parent) : + wpParent(&parent), + wpOwner(&owner) + { + throw std::runtime_error("test exception"); + } + + private: + RefCntWeakPtr wpParent; + RefCntWeakPtr wpOwner; + }; + virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) {} + + private: + Subclass m_Member; + }; + + RefCntAutoPtr m_pMember; + }; + + try + { + RefCntAutoPtr pOwner(NEW_RC_OBJ(DefaultRawMemoryAllocator::GetAllocator(), "Test object", OwnerObject)()); + } + catch (...) + { + } + } + + { + class TestObject : public RefCountedObject + { + public: + TestObject(IReferenceCounters* pRefCounters) : + RefCountedObject(pRefCounters) + { + } + + virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) override final {} + + inline virtual Atomics::Long Release() override final + { + return RefCountedObject::Release( + [&]() // + { + ppWeakPtr->Release(); + } // + ); + } + RefCntWeakPtr* ppWeakPtr = nullptr; + }; + + RefCntAutoPtr pObj(NEW_RC_OBJ(DefaultRawMemoryAllocator::GetAllocator(), "Test object", TestObject)()); + RefCntWeakPtr pWeakPtr(pObj); + + pObj->ppWeakPtr = &pWeakPtr; + pObj.Release(); + } +} + +class RefCntAutoPtrThreadingTest +{ +public: + ~RefCntAutoPtrThreadingTest(); + + void StartConcurrencyTest(); + void RunConcurrencyTest(); + + static void WorkerThreadFunc(RefCntAutoPtrThreadingTest* This, size_t ThreadNum); + + void StartWorkerThreadsAndWait(int SignalIdx); + void WaitSiblingWorkerThreads(int SignalIdx); + + std::vector m_Threads; + + Object* m_pSharedObject = nullptr; +#ifdef _DEBUG + static const int NumThreadInterations = 10000; +#else + static const int NumThreadInterations = 50000; +#endif + ThreadingTools::Signal m_WorkerThreadSignal[2]; + ThreadingTools::Signal m_MainThreadSignal; + + std::mutex m_NumThreadsCompletedMtx; + std::atomic_int m_NumThreadsCompleted[2]; + std::atomic_int m_NumThreadsReady; +}; + + +RefCntAutoPtrThreadingTest::~RefCntAutoPtrThreadingTest() +{ + m_WorkerThreadSignal[0].Trigger(true, -1); + + for (auto& t : m_Threads) + t.join(); + + LOG_INFO_MESSAGE("Performed ", NumThreadInterations, " iterations on ", m_Threads.size(), " threads"); +} + +void RefCntAutoPtrThreadingTest::WaitSiblingWorkerThreads(int SignalIdx) +{ + auto NumThreads = static_cast(m_Threads.size()); + if (++m_NumThreadsCompleted[SignalIdx] == NumThreads) + { + ASSERT_FALSE(m_WorkerThreadSignal[1 - SignalIdx].IsTriggered()); + m_MainThreadSignal.Trigger(); + } + else + { + while (m_NumThreadsCompleted[SignalIdx] < NumThreads) + std::this_thread::yield(); + } +} + +void RefCntAutoPtrThreadingTest::StartWorkerThreadsAndWait(int SignalIdx) +{ + m_NumThreadsCompleted[SignalIdx] = 0; + m_WorkerThreadSignal[SignalIdx].Trigger(true); + + m_MainThreadSignal.Wait(true, 1); +} + +void RefCntAutoPtrThreadingTest::WorkerThreadFunc(RefCntAutoPtrThreadingTest* This, size_t ThreadNum) +{ + const int NumThreads = static_cast(This->m_Threads.size()); + while (true) + { + for (int i = 0; i < NumThreadInterations; ++i) + { + // Wait until main() sends data + auto SignaledValue = This->m_WorkerThreadSignal[0].Wait(true, NumThreads); + if (SignaledValue < 0) + { + return; + } + + { + auto* pObject = This->m_pSharedObject; + for (int j = 0; j < 100; ++j) + { + //LOG_INFO_MESSAGE("t",std::this_thread::get_id(), ": AddRef" ); + pObject->m_Value++; + pObject->AddRef(); + } + This->WaitSiblingWorkerThreads(0); + + This->m_WorkerThreadSignal[1].Wait(true, NumThreads); + for (int j = 0; j < 100; ++j) + { + //LOG_INFO_MESSAGE("t",std::this_thread::get_id(), ": Release" ); + pObject->m_Value--; + pObject->Release(); + } + This->WaitSiblingWorkerThreads(1); + } + + { + This->m_WorkerThreadSignal[0].Wait(true, NumThreads); + auto* pObject = This->m_pSharedObject; + auto* pRefCounters = pObject->GetReferenceCounters(); + if (ThreadNum % 3 == 0) + { + pObject->m_Value++; + pObject->AddRef(); + } + else + pRefCounters->AddWeakRef(); + This->WaitSiblingWorkerThreads(0); + + This->m_WorkerThreadSignal[1].Wait(true, NumThreads); + if (ThreadNum % 3 == 0) + { + pObject->m_Value--; + pObject->Release(); + } + else + pRefCounters->ReleaseWeakRef(); + This->WaitSiblingWorkerThreads(1); + } + + { + // Test interferences of ReleaseStrongRef() and GetObject() + + // Goal: catch scenario when GetObject() runs between + // AtomicDecrement() and acquiring the lock in ReleaseStrongRef(): + + // m_lNumStrongReferences == 1 + // + + // Scenario I + // + // Thread 1 | Thread 2 | Thread 3 + // | | + // | | + // | | + // | 1. Acquire the lock | + // | 2. Increment m_lNumStrongReferences | + // 1. Decrement m_lNumStrongReferences | 3. Read StrongRefCnt > 1 | + // 2. Test RefCount!=0 | 4. Return the reference to object | + // 3. DO NOT destroy the object | | + // 4. Wait for the lock | | + + + // Scenario I + // + // Thread 1 | Thread 2 | Thread 3 + // | | + // | | + // 1. Decrement m_lNumStrongReferences | | + // | 1. Acquire the lock | + // 2. Test RefCount==0 | 2. Increment m_lNumStrongReferences | + // 3. Start destroying the object | 3. Read StrongRefCnt == 1 | + // 4. Wait for the lock | 4. DO NOT create the object | + // | 5. Decrement m_lNumStrongReferences | + // | | 1. Acquire the lock + // | | 2. Increment m_lNumStrongReferences + // | | 3. Read StrongRefCnt == 1 + // | | 4. DO NOT create the object + // | | 5. Decrement m_lNumStrongReferences + // 5. Acquire the lock | + // 6. DESTROY the object | + + This->m_WorkerThreadSignal[0].Wait(true, NumThreads); + auto* pObject = This->m_pSharedObject; + + RefCntWeakPtr weakPtr(pObject); + RefCntAutoPtr strongPtr, strongPtr2; + if (ThreadNum < 2) + { + strongPtr = pObject; + strongPtr->m_Value++; + } + else + weakPtr = WeakPtr(pObject); + This->WaitSiblingWorkerThreads(0); + + This->m_WorkerThreadSignal[1].Wait(true, NumThreads); + if (ThreadNum == 0) + { + strongPtr->m_Value--; + strongPtr.Release(); + } + else + { + strongPtr2 = weakPtr.Lock(); + if (strongPtr2) + strongPtr2->m_Value++; + weakPtr.Release(); + } + This->WaitSiblingWorkerThreads(1); + } + + + { + This->m_WorkerThreadSignal[0].Wait(true, NumThreads); + auto* pObject = This->m_pSharedObject; + + RefCntWeakPtr weakPtr; + RefCntAutoPtr strongPtr; + if (ThreadNum % 4 == 0) + { + strongPtr = pObject; + strongPtr->m_Value++; + } + else + weakPtr = WeakPtr(pObject); + This->WaitSiblingWorkerThreads(0); + + This->m_WorkerThreadSignal[1].Wait(true, NumThreads); + if (ThreadNum % 4 == 0) + { + strongPtr->m_Value--; + strongPtr.Release(); + } + else + { + auto Ptr = weakPtr.Lock(); + if (Ptr) + Ptr->m_Value++; + Ptr.Release(); + } + This->WaitSiblingWorkerThreads(1); + } + } + } +} + +void RefCntAutoPtrThreadingTest::StartConcurrencyTest() +{ + auto numCores = std::thread::hardware_concurrency(); + m_Threads.resize(std::max(numCores, 4u)); + for (auto& t : m_Threads) + t = std::thread(WorkerThreadFunc, this, &t - m_Threads.data()); +} + +void RefCntAutoPtrThreadingTest::RunConcurrencyTest() +{ + for (int i = 0; i < NumThreadInterations; ++i) + { + m_pSharedObject = MakeNewObj(); + + StartWorkerThreadsAndWait(0); + + StartWorkerThreadsAndWait(1); + + m_pSharedObject = MakeNewObj(); + + StartWorkerThreadsAndWait(0); + + StartWorkerThreadsAndWait(1); + + m_pSharedObject = MakeNewObj(); + + StartWorkerThreadsAndWait(0); + + StartWorkerThreadsAndWait(1); + + m_pSharedObject = MakeNewObj(); + + StartWorkerThreadsAndWait(0); + + StartWorkerThreadsAndWait(1); + } +} + +TEST(Common_RefCntAutoPtr, Threading) +{ + RefCntAutoPtrThreadingTest ThreadingTest; + ThreadingTest.StartConcurrencyTest(); + ThreadingTest.RunConcurrencyTest(); +} + +} // namespace diff --git a/Tests/DiligentCoreTest/src/Common/StringToolsTest.cpp b/Tests/DiligentCoreTest/src/Common/StringToolsTest.cpp new file mode 100644 index 00000000..37be477e --- /dev/null +++ b/Tests/DiligentCoreTest/src/Common/StringToolsTest.cpp @@ -0,0 +1,55 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "StringTools.h" + +#include "gtest/gtest.h" + +using namespace Diligent; + +namespace +{ + +TEST(Common_StringTools, StreqSuff) +{ + EXPECT_TRUE(StreqSuff("abc_def", "abc", "_def")); + EXPECT_TRUE(!StreqSuff("abc", "abc", "_def")); + EXPECT_TRUE(!StreqSuff("ab", "abc", "_def")); + EXPECT_TRUE(!StreqSuff("abc_de", "abc", "_def")); + EXPECT_TRUE(!StreqSuff("abc_def", "ab", "_def")); + EXPECT_TRUE(!StreqSuff("abc_def", "abd", "_def")); + EXPECT_TRUE(!StreqSuff("abc_def", "abc", "_de")); + EXPECT_TRUE(!StreqSuff("abc", "abc", "_def")); + EXPECT_TRUE(!StreqSuff("abc_def", "", "_def")); + EXPECT_TRUE(!StreqSuff("abc_def", "", "")); + + EXPECT_TRUE(StreqSuff("abc", "abc", "_def", true)); + EXPECT_TRUE(!StreqSuff("abc", "abc_", "_def", true)); + EXPECT_TRUE(!StreqSuff("abc_", "abc", "_def", true)); + EXPECT_TRUE(StreqSuff("abc", "abc", nullptr, true)); + EXPECT_TRUE(StreqSuff("abc", "abc", nullptr, false)); + EXPECT_TRUE(!StreqSuff("ab", "abc", nullptr, true)); + EXPECT_TRUE(!StreqSuff("abc", "ab", nullptr, false)); +} + +} // namespace diff --git a/Tests/DiligentCoreTest/src/GraphicsAccessories/GraphicsAccessoriesTest.cpp b/Tests/DiligentCoreTest/src/GraphicsAccessories/GraphicsAccessoriesTest.cpp new file mode 100644 index 00000000..89f23ac0 --- /dev/null +++ b/Tests/DiligentCoreTest/src/GraphicsAccessories/GraphicsAccessoriesTest.cpp @@ -0,0 +1,450 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "GraphicsAccessories.h" + +#include "gtest/gtest.h" + +using namespace Diligent; + +namespace +{ + +TEST(GraphicsAccessories_GraphicsAccessories, GetFilterTypeLiteralName) +{ +#define TEST_FILTER_TYPE_ENUM(ENUM_VAL, ShortName) \ + { \ + EXPECT_STREQ(GetFilterTypeLiteralName(ENUM_VAL, true), #ENUM_VAL); \ + EXPECT_STREQ(GetFilterTypeLiteralName(ENUM_VAL, false), ShortName); \ + } + + // clang-format off + TEST_FILTER_TYPE_ENUM(FILTER_TYPE_UNKNOWN, "unknown"); + TEST_FILTER_TYPE_ENUM(FILTER_TYPE_POINT, "point"); + TEST_FILTER_TYPE_ENUM(FILTER_TYPE_LINEAR, "linear"); + TEST_FILTER_TYPE_ENUM(FILTER_TYPE_ANISOTROPIC, "anisotropic"); + TEST_FILTER_TYPE_ENUM(FILTER_TYPE_COMPARISON_POINT, "comparison point"); + TEST_FILTER_TYPE_ENUM(FILTER_TYPE_COMPARISON_LINEAR, "comparison linear"); + TEST_FILTER_TYPE_ENUM(FILTER_TYPE_COMPARISON_ANISOTROPIC, "comparison anisotropic"); + TEST_FILTER_TYPE_ENUM(FILTER_TYPE_MINIMUM_POINT, "minimum point"); + TEST_FILTER_TYPE_ENUM(FILTER_TYPE_MINIMUM_LINEAR, "minimum linear"); + TEST_FILTER_TYPE_ENUM(FILTER_TYPE_MINIMUM_ANISOTROPIC, "minimum anisotropic"); + TEST_FILTER_TYPE_ENUM(FILTER_TYPE_MAXIMUM_POINT, "maximum point"); + TEST_FILTER_TYPE_ENUM(FILTER_TYPE_MAXIMUM_LINEAR, "maximum linear"); + TEST_FILTER_TYPE_ENUM(FILTER_TYPE_MAXIMUM_ANISOTROPIC, "maximum anisotropic"); + // clang-format on +#undef TEST_FILTER_TYPE_ENUM +} + +TEST(GraphicsAccessories_GraphicsAccessories, GetTextureAddressModeLiteralName) +{ +#define TEST_TEX_ADDRESS_MODE_ENUM(ENUM_VAL, ShortName) \ + { \ + EXPECT_STREQ(GetTextureAddressModeLiteralName(ENUM_VAL, true), #ENUM_VAL); \ + EXPECT_STREQ(GetTextureAddressModeLiteralName(ENUM_VAL, false), ShortName); \ + } + + // clang-format off + TEST_TEX_ADDRESS_MODE_ENUM(TEXTURE_ADDRESS_UNKNOWN, "unknown"); + TEST_TEX_ADDRESS_MODE_ENUM(TEXTURE_ADDRESS_WRAP, "wrap"); + TEST_TEX_ADDRESS_MODE_ENUM(TEXTURE_ADDRESS_MIRROR, "mirror"); + TEST_TEX_ADDRESS_MODE_ENUM(TEXTURE_ADDRESS_CLAMP, "clamp"); + TEST_TEX_ADDRESS_MODE_ENUM(TEXTURE_ADDRESS_BORDER, "border"); + TEST_TEX_ADDRESS_MODE_ENUM(TEXTURE_ADDRESS_MIRROR_ONCE, "mirror once"); + // clang-format on +#undef TEST_TEX_ADDRESS_MODE_ENUM +} + +TEST(GraphicsAccessories_GraphicsAccessories, GetComparisonFunctionLiteralName) +{ +#define TEST_COMPARISON_FUNC_ENUM(ENUM_VAL, ShortName) \ + { \ + EXPECT_STREQ(GetComparisonFunctionLiteralName(ENUM_VAL, true), #ENUM_VAL); \ + EXPECT_STREQ(GetComparisonFunctionLiteralName(ENUM_VAL, false), ShortName); \ + } + + // clang-format off + TEST_COMPARISON_FUNC_ENUM(COMPARISON_FUNC_UNKNOWN, "unknown"); + TEST_COMPARISON_FUNC_ENUM(COMPARISON_FUNC_NEVER, "never"); + TEST_COMPARISON_FUNC_ENUM(COMPARISON_FUNC_LESS, "less"); + TEST_COMPARISON_FUNC_ENUM(COMPARISON_FUNC_EQUAL, "equal"); + TEST_COMPARISON_FUNC_ENUM(COMPARISON_FUNC_LESS_EQUAL, "less equal"); + TEST_COMPARISON_FUNC_ENUM(COMPARISON_FUNC_GREATER, "greater"); + TEST_COMPARISON_FUNC_ENUM(COMPARISON_FUNC_NOT_EQUAL, "not equal"); + TEST_COMPARISON_FUNC_ENUM(COMPARISON_FUNC_GREATER_EQUAL, "greater equal"); + TEST_COMPARISON_FUNC_ENUM(COMPARISON_FUNC_ALWAYS, "always"); + // clang-format on +#undef TEST_TEX_ADDRESS_MODE_ENUM +} + +TEST(GraphicsAccessories_GraphicsAccessories, GetBlendFactorLiteralName) +{ +#define TEST_BLEND_FACTOR_ENUM(ENUM_VAL) \ + { \ + EXPECT_STREQ(GetBlendFactorLiteralName(ENUM_VAL), #ENUM_VAL); \ + } + + TEST_BLEND_FACTOR_ENUM(BLEND_FACTOR_UNDEFINED); + TEST_BLEND_FACTOR_ENUM(BLEND_FACTOR_ZERO); + TEST_BLEND_FACTOR_ENUM(BLEND_FACTOR_ONE); + TEST_BLEND_FACTOR_ENUM(BLEND_FACTOR_SRC_COLOR); + TEST_BLEND_FACTOR_ENUM(BLEND_FACTOR_INV_SRC_COLOR); + TEST_BLEND_FACTOR_ENUM(BLEND_FACTOR_SRC_ALPHA); + TEST_BLEND_FACTOR_ENUM(BLEND_FACTOR_INV_SRC_ALPHA); + TEST_BLEND_FACTOR_ENUM(BLEND_FACTOR_DEST_ALPHA); + TEST_BLEND_FACTOR_ENUM(BLEND_FACTOR_INV_DEST_ALPHA); + TEST_BLEND_FACTOR_ENUM(BLEND_FACTOR_DEST_COLOR); + TEST_BLEND_FACTOR_ENUM(BLEND_FACTOR_INV_DEST_COLOR); + TEST_BLEND_FACTOR_ENUM(BLEND_FACTOR_SRC_ALPHA_SAT); + TEST_BLEND_FACTOR_ENUM(BLEND_FACTOR_BLEND_FACTOR); + TEST_BLEND_FACTOR_ENUM(BLEND_FACTOR_INV_BLEND_FACTOR); + TEST_BLEND_FACTOR_ENUM(BLEND_FACTOR_SRC1_COLOR); + TEST_BLEND_FACTOR_ENUM(BLEND_FACTOR_INV_SRC1_COLOR); + TEST_BLEND_FACTOR_ENUM(BLEND_FACTOR_SRC1_ALPHA); + TEST_BLEND_FACTOR_ENUM(BLEND_FACTOR_INV_SRC1_ALPHA); +#undef TEST_TEX_ADDRESS_MODE_ENUM +} + +TEST(GraphicsAccessories_GraphicsAccessories, GetBlendOperationLiteralName) +{ +#define TEST_BLEND_OP_ENUM(ENUM_VAL) \ + { \ + EXPECT_STREQ(GetBlendOperationLiteralName(ENUM_VAL), #ENUM_VAL); \ + } + + TEST_BLEND_OP_ENUM(BLEND_OPERATION_UNDEFINED); + TEST_BLEND_OP_ENUM(BLEND_OPERATION_ADD); + TEST_BLEND_OP_ENUM(BLEND_OPERATION_SUBTRACT); + TEST_BLEND_OP_ENUM(BLEND_OPERATION_REV_SUBTRACT); + TEST_BLEND_OP_ENUM(BLEND_OPERATION_MIN); + TEST_BLEND_OP_ENUM(BLEND_OPERATION_MAX); +#undef TEST_BLEND_OP_ENUM +} + +TEST(GraphicsAccessories_GraphicsAccessories, GetFillModeLiteralName) +{ +#define TEST_FILL_MODE_ENUM(ENUM_VAL) \ + { \ + EXPECT_STREQ(GetFillModeLiteralName(ENUM_VAL), #ENUM_VAL); \ + } + TEST_FILL_MODE_ENUM(FILL_MODE_UNDEFINED); + TEST_FILL_MODE_ENUM(FILL_MODE_WIREFRAME); + TEST_FILL_MODE_ENUM(FILL_MODE_SOLID); +#undef TEST_FILL_MODE_ENUM +} + +TEST(GraphicsAccessories_GraphicsAccessories, GetCullModeLiteralName) +{ +#define TEST_CULL_MODE_ENUM(ENUM_VAL) \ + { \ + EXPECT_STREQ(GetCullModeLiteralName(ENUM_VAL), #ENUM_VAL); \ + } + TEST_CULL_MODE_ENUM(CULL_MODE_UNDEFINED); + TEST_CULL_MODE_ENUM(CULL_MODE_NONE); + TEST_CULL_MODE_ENUM(CULL_MODE_FRONT); + TEST_CULL_MODE_ENUM(CULL_MODE_BACK); +#undef TEST_CULL_MODE_ENUM +} + +TEST(GraphicsAccessories_GraphicsAccessories, GetStencilOpLiteralName) +{ +#define TEST_STENCIL_OP_ENUM(ENUM_VAL) \ + { \ + EXPECT_STREQ(GetStencilOpLiteralName(ENUM_VAL), #ENUM_VAL); \ + } + + TEST_STENCIL_OP_ENUM(STENCIL_OP_UNDEFINED); + TEST_STENCIL_OP_ENUM(STENCIL_OP_KEEP); + TEST_STENCIL_OP_ENUM(STENCIL_OP_ZERO); + TEST_STENCIL_OP_ENUM(STENCIL_OP_REPLACE); + TEST_STENCIL_OP_ENUM(STENCIL_OP_INCR_SAT); + TEST_STENCIL_OP_ENUM(STENCIL_OP_DECR_SAT); + TEST_STENCIL_OP_ENUM(STENCIL_OP_INVERT); + TEST_STENCIL_OP_ENUM(STENCIL_OP_INCR_WRAP); + TEST_STENCIL_OP_ENUM(STENCIL_OP_DECR_WRAP); +#undef TEST_STENCIL_OP_ENUM +} + + + +TEST(GraphicsAccessories_GraphicsAccessories, GetTextureFormatAttribs) +{ + auto CheckFormatSize = [](TEXTURE_FORMAT* begin, TEXTURE_FORMAT* end, Uint32 RefSize) // + { + for (auto fmt = begin; fmt != end; ++fmt) + { + auto FmtAttrs = GetTextureFormatAttribs(*fmt); + EXPECT_EQ(Uint32{FmtAttrs.ComponentSize} * Uint32{FmtAttrs.NumComponents}, RefSize); + } + }; + + auto CheckNumComponents = [](TEXTURE_FORMAT* begin, TEXTURE_FORMAT* end, Uint32 RefComponents) // + { + for (auto fmt = begin; fmt != end; ++fmt) + { + auto FmtAttrs = GetTextureFormatAttribs(*fmt); + EXPECT_EQ(FmtAttrs.NumComponents, RefComponents); + } + }; + + auto CheckComponentType = [](TEXTURE_FORMAT* begin, TEXTURE_FORMAT* end, COMPONENT_TYPE RefType) // + { + for (auto fmt = begin; fmt != end; ++fmt) + { + auto FmtAttrs = GetTextureFormatAttribs(*fmt); + EXPECT_EQ(FmtAttrs.ComponentType, RefType); + } + }; + + TEXTURE_FORMAT _16ByteFormats[] = + { + TEX_FORMAT_RGBA32_TYPELESS, TEX_FORMAT_RGBA32_FLOAT, TEX_FORMAT_RGBA32_UINT, TEX_FORMAT_RGBA32_SINT // + }; + CheckFormatSize(std::begin(_16ByteFormats), std::end(_16ByteFormats), 16); + + TEXTURE_FORMAT _12ByteFormats[] = + { + TEX_FORMAT_RGB32_TYPELESS, TEX_FORMAT_RGB32_FLOAT, TEX_FORMAT_RGB32_UINT, TEX_FORMAT_RGB32_SINT // + }; + CheckFormatSize(std::begin(_12ByteFormats), std::end(_12ByteFormats), 12); + + TEXTURE_FORMAT _8ByteFormats[] = + { + TEX_FORMAT_RGBA16_TYPELESS, TEX_FORMAT_RGBA16_FLOAT, TEX_FORMAT_RGBA16_UNORM, TEX_FORMAT_RGBA16_UINT, TEX_FORMAT_RGBA16_SNORM, TEX_FORMAT_RGBA16_SINT, + TEX_FORMAT_RG32_TYPELESS, TEX_FORMAT_RG32_FLOAT, TEX_FORMAT_RG32_UINT, TEX_FORMAT_RG32_SINT, + TEX_FORMAT_R32G8X24_TYPELESS, TEX_FORMAT_D32_FLOAT_S8X24_UINT, TEX_FORMAT_R32_FLOAT_X8X24_TYPELESS, TEX_FORMAT_X32_TYPELESS_G8X24_UINT // + }; + CheckFormatSize(std::begin(_8ByteFormats), std::end(_8ByteFormats), 8); + + TEXTURE_FORMAT _4ByteFormats[] = + { + TEX_FORMAT_RGB10A2_TYPELESS, TEX_FORMAT_RGB10A2_UNORM, TEX_FORMAT_RGB10A2_UINT, TEX_FORMAT_R11G11B10_FLOAT, + TEX_FORMAT_RGBA8_TYPELESS, TEX_FORMAT_RGBA8_UNORM, TEX_FORMAT_RGBA8_UNORM_SRGB, TEX_FORMAT_RGBA8_UINT, TEX_FORMAT_RGBA8_SNORM, TEX_FORMAT_RGBA8_SINT, + TEX_FORMAT_RG16_TYPELESS, TEX_FORMAT_RG16_FLOAT, TEX_FORMAT_RG16_UNORM, TEX_FORMAT_RG16_UINT, TEX_FORMAT_RG16_SNORM, TEX_FORMAT_RG16_SINT, + TEX_FORMAT_R32_TYPELESS, TEX_FORMAT_D32_FLOAT, TEX_FORMAT_R32_FLOAT, TEX_FORMAT_R32_UINT, TEX_FORMAT_R32_SINT, + TEX_FORMAT_R24G8_TYPELESS, TEX_FORMAT_D24_UNORM_S8_UINT, TEX_FORMAT_R24_UNORM_X8_TYPELESS, TEX_FORMAT_X24_TYPELESS_G8_UINT, + TEX_FORMAT_RGB9E5_SHAREDEXP, TEX_FORMAT_RG8_B8G8_UNORM, TEX_FORMAT_G8R8_G8B8_UNORM, + TEX_FORMAT_BGRA8_UNORM, TEX_FORMAT_BGRX8_UNORM, TEX_FORMAT_R10G10B10_XR_BIAS_A2_UNORM, + TEX_FORMAT_BGRA8_TYPELESS, TEX_FORMAT_BGRA8_UNORM_SRGB, TEX_FORMAT_BGRX8_TYPELESS, TEX_FORMAT_BGRX8_UNORM_SRGB // + }; + CheckFormatSize(std::begin(_4ByteFormats), std::end(_4ByteFormats), 4); + + TEXTURE_FORMAT _2ByteFormats[] = + { + TEX_FORMAT_RG8_TYPELESS, TEX_FORMAT_RG8_UNORM, TEX_FORMAT_RG8_UINT, TEX_FORMAT_RG8_SNORM, TEX_FORMAT_RG8_SINT, + TEX_FORMAT_R16_TYPELESS, TEX_FORMAT_R16_FLOAT, TEX_FORMAT_D16_UNORM, TEX_FORMAT_R16_UNORM, TEX_FORMAT_R16_UINT, TEX_FORMAT_R16_SNORM, TEX_FORMAT_R16_SINT, + TEX_FORMAT_B5G6R5_UNORM, TEX_FORMAT_B5G5R5A1_UNORM // + }; + CheckFormatSize(std::begin(_2ByteFormats), std::end(_2ByteFormats), 2); + + TEXTURE_FORMAT _1ByteFormats[] = + { + TEX_FORMAT_R8_TYPELESS, TEX_FORMAT_R8_UNORM, TEX_FORMAT_R8_UINT, TEX_FORMAT_R8_SNORM, TEX_FORMAT_R8_SINT, TEX_FORMAT_A8_UNORM, //TEX_FORMAT_R1_UNORM + }; + CheckFormatSize(std::begin(_1ByteFormats), std::end(_1ByteFormats), 1); + + TEXTURE_FORMAT _4ComponentFormats[] = + { + TEX_FORMAT_RGBA32_TYPELESS, TEX_FORMAT_RGBA32_FLOAT, TEX_FORMAT_RGBA32_UINT, TEX_FORMAT_RGBA32_SINT, + TEX_FORMAT_RGBA16_TYPELESS, TEX_FORMAT_RGBA16_FLOAT, TEX_FORMAT_RGBA16_UNORM, TEX_FORMAT_RGBA16_UINT, TEX_FORMAT_RGBA16_SNORM, TEX_FORMAT_RGBA16_SINT, + TEX_FORMAT_RGBA8_TYPELESS, TEX_FORMAT_RGBA8_UNORM, TEX_FORMAT_RGBA8_UNORM_SRGB, TEX_FORMAT_RGBA8_UINT, TEX_FORMAT_RGBA8_SNORM, TEX_FORMAT_RGBA8_SINT, + TEX_FORMAT_RG8_B8G8_UNORM, TEX_FORMAT_G8R8_G8B8_UNORM, + TEX_FORMAT_BGRA8_UNORM, TEX_FORMAT_BGRX8_UNORM, TEX_FORMAT_BGRA8_TYPELESS, TEX_FORMAT_BGRA8_UNORM_SRGB, TEX_FORMAT_BGRX8_TYPELESS, TEX_FORMAT_BGRX8_UNORM_SRGB // + }; + CheckNumComponents(std::begin(_4ComponentFormats), std::end(_4ComponentFormats), 4); + + TEXTURE_FORMAT _3ComponentFormats[] = + { + TEX_FORMAT_RGB32_TYPELESS, + TEX_FORMAT_RGB32_FLOAT, + TEX_FORMAT_RGB32_UINT, + TEX_FORMAT_RGB32_SINT // + }; + CheckNumComponents(std::begin(_3ComponentFormats), std::end(_3ComponentFormats), 3); + + TEXTURE_FORMAT _2ComponentFormats[] = + { + TEX_FORMAT_RG32_TYPELESS, TEX_FORMAT_RG32_FLOAT, TEX_FORMAT_RG32_UINT, TEX_FORMAT_RG32_SINT, + TEX_FORMAT_R32G8X24_TYPELESS, TEX_FORMAT_D32_FLOAT_S8X24_UINT, TEX_FORMAT_R32_FLOAT_X8X24_TYPELESS, TEX_FORMAT_X32_TYPELESS_G8X24_UINT, + TEX_FORMAT_RG16_TYPELESS, TEX_FORMAT_RG16_FLOAT, TEX_FORMAT_RG16_UNORM, TEX_FORMAT_RG16_UINT, TEX_FORMAT_RG16_SNORM, TEX_FORMAT_RG16_SINT, + TEX_FORMAT_RG8_TYPELESS, TEX_FORMAT_RG8_UNORM, TEX_FORMAT_RG8_UINT, TEX_FORMAT_RG8_SNORM, TEX_FORMAT_RG8_SINT // + }; + CheckNumComponents(std::begin(_2ComponentFormats), std::end(_2ComponentFormats), 2); + + TEXTURE_FORMAT _1ComponentFormats[] = + { + TEX_FORMAT_RGB10A2_TYPELESS, TEX_FORMAT_RGB10A2_UNORM, TEX_FORMAT_RGB10A2_UINT, TEX_FORMAT_R11G11B10_FLOAT, + TEX_FORMAT_R32_TYPELESS, TEX_FORMAT_D32_FLOAT, TEX_FORMAT_R32_FLOAT, TEX_FORMAT_R32_UINT, TEX_FORMAT_R32_SINT, + TEX_FORMAT_R24G8_TYPELESS, TEX_FORMAT_D24_UNORM_S8_UINT, TEX_FORMAT_R24_UNORM_X8_TYPELESS, TEX_FORMAT_X24_TYPELESS_G8_UINT, + TEX_FORMAT_R16_TYPELESS, TEX_FORMAT_R16_FLOAT, TEX_FORMAT_D16_UNORM, TEX_FORMAT_R16_UNORM, TEX_FORMAT_R16_UINT, TEX_FORMAT_R16_SNORM, TEX_FORMAT_R16_SINT, + TEX_FORMAT_R8_TYPELESS, TEX_FORMAT_R8_UNORM, TEX_FORMAT_R8_UINT, TEX_FORMAT_R8_SNORM, TEX_FORMAT_R8_SINT, TEX_FORMAT_A8_UNORM, //TEX_FORMAT_R1_UNORM + TEX_FORMAT_RGB9E5_SHAREDEXP, + TEX_FORMAT_R10G10B10_XR_BIAS_A2_UNORM, TEX_FORMAT_B5G6R5_UNORM, TEX_FORMAT_B5G5R5A1_UNORM // + }; + CheckNumComponents(std::begin(_1ComponentFormats), std::end(_1ComponentFormats), 1); + + + TEXTURE_FORMAT FloatFormats[] = + { + TEX_FORMAT_RGBA32_FLOAT, + TEX_FORMAT_RGB32_FLOAT, + TEX_FORMAT_RGBA16_FLOAT, + TEX_FORMAT_RG32_FLOAT, + TEX_FORMAT_RG16_FLOAT, + TEX_FORMAT_R32_FLOAT, + TEX_FORMAT_R16_FLOAT // + }; + CheckComponentType(std::begin(FloatFormats), std::end(FloatFormats), COMPONENT_TYPE_FLOAT); + + TEXTURE_FORMAT SintFormats[] = + { + TEX_FORMAT_RGBA32_SINT, + TEX_FORMAT_RGB32_SINT, + TEX_FORMAT_RGBA16_SINT, + TEX_FORMAT_RG32_SINT, + TEX_FORMAT_RGBA8_SINT, + TEX_FORMAT_RG16_SINT, + TEX_FORMAT_R32_SINT, + TEX_FORMAT_RG8_SINT, + TEX_FORMAT_R16_SINT, + TEX_FORMAT_R8_SINT // + }; + CheckComponentType(std::begin(SintFormats), std::end(SintFormats), COMPONENT_TYPE_SINT); + + TEXTURE_FORMAT UintFormats[] = + { + TEX_FORMAT_RGBA32_UINT, + TEX_FORMAT_RGB32_UINT, + TEX_FORMAT_RGBA16_UINT, + TEX_FORMAT_RG32_UINT, + TEX_FORMAT_RGBA8_UINT, + TEX_FORMAT_RG16_UINT, + TEX_FORMAT_R32_UINT, + TEX_FORMAT_RG8_UINT, + TEX_FORMAT_R16_UINT, + TEX_FORMAT_R8_UINT // + }; + CheckComponentType(std::begin(UintFormats), std::end(UintFormats), COMPONENT_TYPE_UINT); + + TEXTURE_FORMAT UnormFormats[] = + { + TEX_FORMAT_RGBA16_UNORM, + TEX_FORMAT_RGBA8_UNORM, + TEX_FORMAT_RG16_UNORM, + TEX_FORMAT_RG8_UNORM, + TEX_FORMAT_R16_UNORM, + TEX_FORMAT_R8_UNORM, + TEX_FORMAT_A8_UNORM, + TEX_FORMAT_R1_UNORM, + TEX_FORMAT_RG8_B8G8_UNORM, + TEX_FORMAT_G8R8_G8B8_UNORM, + TEX_FORMAT_BGRA8_UNORM, + TEX_FORMAT_BGRX8_UNORM // + }; + CheckComponentType(std::begin(UnormFormats), std::end(UnormFormats), COMPONENT_TYPE_UNORM); + + TEXTURE_FORMAT UnormSRGBFormats[] = + { + TEX_FORMAT_RGBA8_UNORM_SRGB, + TEX_FORMAT_BGRA8_UNORM_SRGB, + TEX_FORMAT_BGRX8_UNORM_SRGB // + }; + CheckComponentType(std::begin(UnormSRGBFormats), std::end(UnormSRGBFormats), COMPONENT_TYPE_UNORM_SRGB); + + TEXTURE_FORMAT SnormFormats[] = + { + TEX_FORMAT_RGBA16_SNORM, + TEX_FORMAT_RGBA8_SNORM, + TEX_FORMAT_RG16_SNORM, + TEX_FORMAT_RG8_SNORM, + TEX_FORMAT_R16_SNORM, + TEX_FORMAT_R8_SNORM // + }; + CheckComponentType(std::begin(SnormFormats), std::end(SnormFormats), COMPONENT_TYPE_SNORM); + + TEXTURE_FORMAT UndefinedFormats[] = + { + TEX_FORMAT_RGBA32_TYPELESS, + TEX_FORMAT_RGB32_TYPELESS, + TEX_FORMAT_RGBA16_TYPELESS, + TEX_FORMAT_RG32_TYPELESS, + TEX_FORMAT_RGBA8_TYPELESS, + TEX_FORMAT_RG16_TYPELESS, + TEX_FORMAT_R32_TYPELESS, + TEX_FORMAT_RG8_TYPELESS, + TEX_FORMAT_R16_TYPELESS, + TEX_FORMAT_R8_TYPELESS, + TEX_FORMAT_BGRA8_TYPELESS, + TEX_FORMAT_BGRX8_TYPELESS // + }; + CheckComponentType(std::begin(UndefinedFormats), std::end(UndefinedFormats), COMPONENT_TYPE_UNDEFINED); + + TEXTURE_FORMAT DepthFormats[] = + { + TEX_FORMAT_D32_FLOAT, + TEX_FORMAT_D16_UNORM // + }; + CheckComponentType(std::begin(DepthFormats), std::end(DepthFormats), COMPONENT_TYPE_DEPTH); + + TEXTURE_FORMAT DepthStencilFormats[] = + { + TEX_FORMAT_R32G8X24_TYPELESS, + TEX_FORMAT_D32_FLOAT_S8X24_UINT, + TEX_FORMAT_R32_FLOAT_X8X24_TYPELESS, + TEX_FORMAT_X32_TYPELESS_G8X24_UINT, + TEX_FORMAT_R24G8_TYPELESS, + TEX_FORMAT_D24_UNORM_S8_UINT, + TEX_FORMAT_R24_UNORM_X8_TYPELESS, + TEX_FORMAT_X24_TYPELESS_G8_UINT // + }; + CheckComponentType(std::begin(DepthStencilFormats), std::end(DepthStencilFormats), COMPONENT_TYPE_DEPTH_STENCIL); + + TEXTURE_FORMAT CompoundFormats[] = + { + TEX_FORMAT_RGB10A2_TYPELESS, + TEX_FORMAT_RGB10A2_UNORM, + TEX_FORMAT_RGB10A2_UINT, + TEX_FORMAT_RGB9E5_SHAREDEXP, + TEX_FORMAT_R11G11B10_FLOAT, + TEX_FORMAT_R10G10B10_XR_BIAS_A2_UNORM, + TEX_FORMAT_B5G6R5_UNORM, + TEX_FORMAT_B5G5R5A1_UNORM // + }; + CheckComponentType(std::begin(CompoundFormats), std::end(CompoundFormats), COMPONENT_TYPE_COMPOUND); + + + TEXTURE_FORMAT CompressedFormats[] = + { + TEX_FORMAT_BC1_TYPELESS, TEX_FORMAT_BC1_UNORM, TEX_FORMAT_BC1_UNORM_SRGB, + TEX_FORMAT_BC2_TYPELESS, TEX_FORMAT_BC2_UNORM, TEX_FORMAT_BC2_UNORM_SRGB, + TEX_FORMAT_BC3_TYPELESS, TEX_FORMAT_BC3_UNORM, TEX_FORMAT_BC3_UNORM_SRGB, + TEX_FORMAT_BC4_TYPELESS, TEX_FORMAT_BC4_UNORM, TEX_FORMAT_BC4_SNORM, + TEX_FORMAT_BC5_TYPELESS, TEX_FORMAT_BC5_UNORM, TEX_FORMAT_BC5_SNORM, + TEX_FORMAT_BC6H_TYPELESS, TEX_FORMAT_BC6H_UF16, TEX_FORMAT_BC6H_SF16, + TEX_FORMAT_BC7_TYPELESS, TEX_FORMAT_BC7_UNORM, TEX_FORMAT_BC7_UNORM_SRGB // + }; + CheckComponentType(std::begin(CompressedFormats), std::end(CompressedFormats), COMPONENT_TYPE_COMPRESSED); +} + + +} // namespace diff --git a/Tests/DiligentCoreTest/src/GraphicsAccessories/ResourceReleaseQueueTest.cpp b/Tests/DiligentCoreTest/src/GraphicsAccessories/ResourceReleaseQueueTest.cpp new file mode 100644 index 00000000..740f0fb5 --- /dev/null +++ b/Tests/DiligentCoreTest/src/GraphicsAccessories/ResourceReleaseQueueTest.cpp @@ -0,0 +1,127 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include + +#include "ResourceReleaseQueue.h" +#include "DefaultRawMemoryAllocator.h" + +#include "gtest/gtest.h" + +using namespace Diligent; + +namespace +{ + +TEST(GraphicsAccessories_ResourceReleaseQueue, GetFilterTypeLiteralName) +{ + struct ResourceA + { + int Data = 1; + }; + struct ResourceB + { + float Data = 2; + }; + struct ResourceC + { + float Data[2] = {3, 4}; + }; + + { + ResourceReleaseQueue Queue(DefaultRawMemoryAllocator::GetAllocator()); + + std::unique_ptr res0(new ResourceA); + std::unique_ptr res1(new ResourceB); + + Queue.SafeReleaseResource(std::move(res0), 0); + Queue.SafeReleaseResource(std::move(res1), 0); + + std::unique_ptr res2(new ResourceC); + + auto Wrapper2 = Queue.CreateWrapper(std::move(res2), 1); + //auto WrapperX = Queue.CreateWrapper(res2, 1);// - error + //auto WrapperY = Queue.CreateWrapper(static_cast&>(res2), 1);// - error + Queue.SafeReleaseResource(std::move(Wrapper2), 0); + + Queue.DiscardStaleResources(0, 1); + + std::unique_ptr res4(new ResourceA); + Queue.DiscardResource(std::move(res4), 1); + + std::unique_ptr res5(new ResourceB); + + auto Wrapper5 = Queue.CreateWrapper(std::move(res5), 1); + Queue.DiscardResource(std::move(Wrapper5), 1); + + Queue.Purge(1); + } + + { + ResourceReleaseQueue Queue0(DefaultRawMemoryAllocator::GetAllocator()); + ResourceReleaseQueue Queue1(DefaultRawMemoryAllocator::GetAllocator()); + ResourceReleaseQueue Queue2(DefaultRawMemoryAllocator::GetAllocator()); + + std::unique_ptr res0(new ResourceA); + std::unique_ptr res1(new ResourceB); + std::unique_ptr res2(new ResourceC); + + auto Wrapper0 = ResourceReleaseQueue::CreateWrapper(std::move(res0), 3); + auto Wrapper1 = ResourceReleaseQueue::CreateWrapper(std::move(res1), 3); + auto Wrapper2 = ResourceReleaseQueue::CreateWrapper(std::move(res2), 1); + + Queue0.SafeReleaseResource(Wrapper0, 0); + Queue0.SafeReleaseResource(Wrapper1, 0); + Queue0.SafeReleaseResource(Wrapper2, 0); + Wrapper2.GiveUpOwnership(); + + Queue1.SafeReleaseResource(Wrapper0, 0); + Queue1.SafeReleaseResource(Wrapper1, 0); + + Queue2.SafeReleaseResource(std::move(Wrapper0), 0); + Queue2.SafeReleaseResource(Wrapper1, 0); + Wrapper1.GiveUpOwnership(); + + Queue0.DiscardStaleResources(0, 1); + Queue1.DiscardStaleResources(0, 1); + Queue2.DiscardStaleResources(0, 1); + + std::unique_ptr res3(new ResourceC); + + auto Wrapper3 = ResourceReleaseQueue::CreateWrapper(std::move(res3), 2); + Queue0.DiscardResource(Wrapper3, 1); + Queue1.DiscardResource(std::move(Wrapper3), 1); + + std::unique_ptr res4(new ResourceA); + + auto Wrapper4 = ResourceReleaseQueue::CreateWrapper(std::move(res4), 1); + Queue2.DiscardResource(Wrapper4, 1); + Wrapper4.GiveUpOwnership(); + + Queue0.Purge(1); + Queue1.Purge(1); + Queue2.Purge(1); + } +} + +} // namespace diff --git a/Tests/DiligentCoreTest/src/GraphicsAccessories/RingBufferTest.cpp b/Tests/DiligentCoreTest/src/GraphicsAccessories/RingBufferTest.cpp new file mode 100644 index 00000000..11fd0cf6 --- /dev/null +++ b/Tests/DiligentCoreTest/src/GraphicsAccessories/RingBufferTest.cpp @@ -0,0 +1,288 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "RingBuffer.h" +#include "DefaultRawMemoryAllocator.h" + +#include "gtest/gtest.h" + +using namespace Diligent; + +namespace +{ + +TEST(GraphicsAccessories_RingBuffer, AllocDealloc) +{ + auto& Allocator = DefaultRawMemoryAllocator::GetAllocator(); + { + RingBuffer RB(1023, Allocator); + + auto Offset = RB.Allocate(120, 16); + // + // O h + // | | | + // 0 128 + EXPECT_EQ(Offset, 0); + + + Offset = RB.Allocate(10, 1); + // + // t O h + // | | | | + // 0 128 138 + EXPECT_EQ(Offset, 128); + + Offset = RB.Allocate(10, 32); + // + // t O h + // | | | | + // 0 128 138 160 192 + EXPECT_EQ(Offset, 160); + + Offset = RB.Allocate(17, 1); + // + // t O h + // | | | | + // 0 128 138 160 192 209 + EXPECT_EQ(Offset, 192); + + Offset = RB.Allocate(65, 64); + // + // t O h + // | | | | + // 0 128 138 160 192 209 256 384 + EXPECT_EQ(Offset, 256); + + RB.FinishCurrentFrame(1); + // + // t h1 + // | | | + // 0 384 + + + Offset = RB.Allocate(100, 256); + // + // t h1 O h + // | | | | | + // 0 384 512 768 + EXPECT_EQ(Offset, 512); + + + Offset = RB.Allocate(127, 1); + // + // t h1 O h + // | | | | | + // 0 384 512 768 895 = 1023-128 + EXPECT_EQ(Offset, 768); + + Offset = RB.Allocate(128, 2); + EXPECT_EQ(Offset, RingBuffer::InvalidOffset); + + Offset = RB.Allocate(128, 1); + // + // t h1 O h + // | | | | + // 0 384 512 768 895 1023 + EXPECT_EQ(Offset, 895); + + RB.FinishCurrentFrame(2); + // + // t h1 h2,h + // | | | + // 0 384 1023 + EXPECT_TRUE(RB.IsFull()); + + Offset = RB.Allocate(1, 1); + EXPECT_EQ(Offset, RingBuffer::InvalidOffset); + + RingBuffer RB1(std::move(RB)); + EXPECT_TRUE(RB.IsEmpty()); + RB1.ReleaseCompletedFrames(1); + // + // t h2 + // | | | + // 0 384 1023 + + RB1.ReleaseCompletedFrames(2); + // + // h,t + // | | + // 0 1023 + EXPECT_TRUE(RB1.IsEmpty()); + EXPECT_EQ(RB1.GetUsedSize(), 0); + + Offset = RB1.Allocate(256, 1); + // + // O h t + // | | | + // 0 256 1023 + EXPECT_EQ(Offset, 0); + + + Offset = RB1.Allocate(256, 16); + RB1.ReleaseCompletedFrames(0); + // + // O h t + // | | | | + // 0 256 512 1023 + EXPECT_EQ(Offset, 256); + RB1.FinishCurrentFrame(2); + RB1.FinishCurrentFrame(3); // ignored + // + // h2 t + // | | | + // 0 512 1023 + RB1.ReleaseCompletedFrames(2); + // + // h,t + // | | + // 0 1023 + + RB1.ReleaseCompletedFrames(3); + + EXPECT_EQ(RB1.GetUsedSize(), 0); + EXPECT_TRUE(RB1.IsEmpty()); + + Offset = RB1.Allocate(512, 1); + // + // O h + // | | | + // 0 512 1023 + EXPECT_EQ(Offset, 0); + + RB1.FinishCurrentFrame(4); + RB1.FinishCurrentFrame(5); + // + // t h4 + // | | | + // 0 512 1023 + + Offset = RB1.Allocate(129, 1); + // + // t h4,O h + // | | | | + // 0 512 641 1023 + EXPECT_EQ(Offset, 512); + + RB1.ReleaseCompletedFrames(4); + // + // t h + // | | | | + // 0 512 641 1023 + + + Offset = RB1.Allocate(128, 128); + // + // t O h + // | | | | | + // 0 512 641 768 896 1023 + EXPECT_EQ(Offset, 768); + + Offset = RB1.Allocate(513, 64); + EXPECT_EQ(Offset, RingBuffer::InvalidOffset); + + Offset = RB1.Allocate(513, 1); + EXPECT_EQ(Offset, RingBuffer::InvalidOffset); + + Offset = RB1.Allocate(255, 1); + // + // O h t + // | | | | + // 0 255 512 1023 + EXPECT_EQ(Offset, 0); + + RB1.FinishCurrentFrame(6); + // + // O h,h6 t + // | | | | + // 0 255 512 1023 + + + Offset = RB1.Allocate(256, 2); + // + // h6 O t,h + // | | | | | + // 0 255 256 512 1023 + EXPECT_EQ(Offset, 256); + + EXPECT_TRUE(RB1.IsFull()); + Offset = RB1.Allocate(1, 1); + EXPECT_EQ(Offset, RingBuffer::InvalidOffset); + RB1.ReleaseCompletedFrames(6); + // + // t h + // | | | | + // 0 255 512 1023 + + Offset = RB1.Allocate(511, 1); + // + // t O h + // | | | | + // 0 255 512 1023 + EXPECT_EQ(Offset, 512); + + Offset = RB1.Allocate(191, 1); + // + // O h t + // | | | | + // 0 191 255 1023 + EXPECT_EQ(Offset, 0); + + Offset = RB1.Allocate(64, 2); + EXPECT_EQ(Offset, RingBuffer::InvalidOffset); + + Offset = RB1.Allocate(64, 1); + // + // O t,h + // | | | | + // 0 191 255 1023 + EXPECT_EQ(Offset, 191); + + Offset = RB1.Allocate(1, 1); + EXPECT_EQ(Offset, RingBuffer::InvalidOffset); + + RB1.FinishCurrentFrame(7); + RB1.ReleaseCompletedFrames(7); + } + + { + RingBuffer RB(1024, Allocator); + + auto offset = RB.Allocate(512, 1); + RB.FinishCurrentFrame(0); + RB.FinishCurrentFrame(1); + RB.ReleaseCompletedFrames(1); + RB.FinishCurrentFrame(2); + RB.FinishCurrentFrame(3); + offset = RB.Allocate(512, 1); + RB.FinishCurrentFrame(4); + RB.ReleaseCompletedFrames(2); + RB.ReleaseCompletedFrames(3); + RB.ReleaseCompletedFrames(4); + offset = RB.Allocate(512, 1); + RB.FinishCurrentFrame(5); + RB.ReleaseCompletedFrames(5); + } +} + +} // namespace diff --git a/Tests/DiligentCoreTest/src/GraphicsAccessories/VariableSizeGPUAllocationsManagerTest.cpp b/Tests/DiligentCoreTest/src/GraphicsAccessories/VariableSizeGPUAllocationsManagerTest.cpp new file mode 100644 index 00000000..cc1c0e6f --- /dev/null +++ b/Tests/DiligentCoreTest/src/GraphicsAccessories/VariableSizeGPUAllocationsManagerTest.cpp @@ -0,0 +1,195 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "VariableSizeGPUAllocationsManager.h" +#include "DefaultRawMemoryAllocator.h" + +#include "gtest/gtest.h" + +using namespace Diligent; + +namespace +{ + +TEST(GraphicsAccessories_VariableSizeGPUAllocationsManager, AllocateFree) +{ + auto& Allocator = DefaultRawMemoryAllocator::GetAllocator(); + + { + VariableSizeAllocationsManager ListMgr(128, Allocator); + EXPECT_EQ(ListMgr.GetNumFreeBlocks(), 1); + + auto a1 = ListMgr.Allocate(17, 4); + EXPECT_EQ(a1.UnalignedOffset, 0); + EXPECT_EQ(a1.Size, 20); + EXPECT_EQ(ListMgr.GetNumFreeBlocks(), 1); + + auto a2 = ListMgr.Allocate(17, 8); + EXPECT_EQ(a2.UnalignedOffset, 20); + EXPECT_EQ(a2.Size, 28); + + auto a3 = ListMgr.Allocate(8, 1); + EXPECT_EQ(a3.UnalignedOffset, 48); + EXPECT_EQ(a3.Size, 8); + + auto a4 = ListMgr.Allocate(11, 8); + EXPECT_EQ(a4.UnalignedOffset, 56); + EXPECT_EQ(a4.Size, 16); + + auto a5 = ListMgr.Allocate(64, 1); + EXPECT_FALSE(a5.IsValid()); + EXPECT_EQ(a5.Size, 0); + + a5 = ListMgr.Allocate(16, 1); + EXPECT_EQ(a5.UnalignedOffset, 72); + EXPECT_EQ(a5.Size, 16); + + auto a6 = ListMgr.Allocate(8, 1); + EXPECT_EQ(a6.UnalignedOffset, 88); + EXPECT_EQ(a6.Size, 8); + + auto a7 = ListMgr.Allocate(16, 1); + EXPECT_EQ(a7.UnalignedOffset, 96); + EXPECT_EQ(a7.Size, 16); + + auto a8 = ListMgr.Allocate(8, 1); + EXPECT_EQ(a8.UnalignedOffset, 112); + EXPECT_EQ(a8.Size, 8); + EXPECT_EQ(ListMgr.GetNumFreeBlocks(), 1); + + auto a9 = ListMgr.Allocate(8, 1); + EXPECT_EQ(a9.UnalignedOffset, 120); + EXPECT_EQ(a9.Size, 8); + EXPECT_EQ(ListMgr.GetNumFreeBlocks(), 0); + + EXPECT_TRUE(ListMgr.IsFull()); + + ListMgr.Free(std::move(a6)); + EXPECT_EQ(ListMgr.GetNumFreeBlocks(), 1); + + ListMgr.Free(a8.UnalignedOffset, a8.Size); + EXPECT_EQ(ListMgr.GetNumFreeBlocks(), 2); + + ListMgr.Free(std::move(a9)); + EXPECT_EQ(ListMgr.GetNumFreeBlocks(), 2); + + auto a10 = ListMgr.Allocate(16, 1); + EXPECT_EQ(a10.UnalignedOffset, 112); + EXPECT_EQ(a10.Size, 16); + EXPECT_EQ(ListMgr.GetNumFreeBlocks(), 1); + + ListMgr.Free(a10.UnalignedOffset, a10.Size); + EXPECT_EQ(ListMgr.GetNumFreeBlocks(), 2); + + ListMgr.Free(std::move(a7)); + EXPECT_EQ(ListMgr.GetNumFreeBlocks(), 1); + + ListMgr.Free(std::move(a4)); + EXPECT_EQ(ListMgr.GetNumFreeBlocks(), 2); + + ListMgr.Free(a2.UnalignedOffset, a2.Size); + EXPECT_EQ(ListMgr.GetNumFreeBlocks(), 3); + + ListMgr.Free(std::move(a1)); + EXPECT_EQ(ListMgr.GetNumFreeBlocks(), 3); + + ListMgr.Free(std::move(a3)); + EXPECT_EQ(ListMgr.GetNumFreeBlocks(), 2); + + ListMgr.Free(std::move(a5)); + EXPECT_EQ(ListMgr.GetNumFreeBlocks(), 1); + + EXPECT_TRUE(ListMgr.IsEmpty()); + } +} + +TEST(GraphicsAccessories_VariableSizeGPUAllocationsManager, FreeOrder) +{ + auto& Allocator = DefaultRawMemoryAllocator::GetAllocator(); + { + const auto NumAllocs = 6; + int NumPerms = 0; + size_t ReleaseOrder[NumAllocs]; + for (size_t a = 0; a < NumAllocs; ++a) + ReleaseOrder[a] = a; + do + { + ++NumPerms; + VariableSizeAllocationsManager ListMgr(NumAllocs * 4, Allocator); + + VariableSizeAllocationsManager::Allocation allocs[NumAllocs]; + for (size_t a = 0; a < NumAllocs; ++a) + { + allocs[a] = ListMgr.Allocate(4, 1); + EXPECT_EQ(allocs[a].UnalignedOffset, a * 4); + EXPECT_EQ(allocs[a].Size, 4); + } + for (size_t a = 0; a < NumAllocs; ++a) + { + ListMgr.Free(std::move(allocs[ReleaseOrder[a]])); + } + } while (std::next_permutation(std::begin(ReleaseOrder), std::end(ReleaseOrder))); + EXPECT_EQ(NumPerms, 720); + } +} + +TEST(GraphicsAccessories_VariableSizeGPUAllocationsManager, Free) +{ + auto& Allocator = DefaultRawMemoryAllocator::GetAllocator(); + { + VariableSizeGPUAllocationsManager ListMgr(128, Allocator); + + VariableSizeGPUAllocationsManager::Allocation al[16]; + for (size_t o = 0; o < _countof(al); ++o) + al[o] = ListMgr.Allocate(8, 4); + EXPECT_TRUE(ListMgr.IsFull()); + + ListMgr.Free(std::move(al[1]), 0); + ListMgr.Free(std::move(al[5]), 0); + ListMgr.Free(std::move(al[4]), 0); + ListMgr.Free(std::move(al[3]), 0); + + ListMgr.Free(al[10].UnalignedOffset, al[10].Size, 1); + ListMgr.Free(al[13].UnalignedOffset, al[13].Size, 1); + ListMgr.Free(al[2].UnalignedOffset, al[2].Size, 1); + ListMgr.Free(al[8].UnalignedOffset, al[8].Size, 1); + + ListMgr.ReleaseStaleAllocations(1); + + ListMgr.Free(std::move(al[14]), 2); + ListMgr.Free(std::move(al[7]), 2); + ListMgr.Free(std::move(al[0]), 2); + ListMgr.Free(std::move(al[9]), 2); + + ListMgr.ReleaseStaleAllocations(2); + + ListMgr.Free(std::move(al[12]), 1); + ListMgr.Free(std::move(al[15]), 1); + ListMgr.Free(std::move(al[6]), 1); + ListMgr.Free(std::move(al[11]), 1); + + ListMgr.ReleaseStaleAllocations(3); + } +} + +} // namespace diff --git a/Tests/DiligentCoreTest/src/Platforms/PlatformMiscTest.cpp b/Tests/DiligentCoreTest/src/Platforms/PlatformMiscTest.cpp new file mode 100644 index 00000000..78543d53 --- /dev/null +++ b/Tests/DiligentCoreTest/src/Platforms/PlatformMiscTest.cpp @@ -0,0 +1,78 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "PlatformMisc.h" + +#include "gtest/gtest.h" + +using namespace Diligent; + +namespace +{ + +TEST(Platforms_PlatformMisc, GetMsbLsb) +{ + EXPECT_EQ(PlatformMisc::GetMSB(Uint32{0}), Uint32{32}); + for (Uint32 i = 0; i < 32; ++i) + { + auto MSB = PlatformMisc::GetMSB((Uint32{1} << i) | 1); + EXPECT_EQ(MSB, i); + } + + EXPECT_EQ(PlatformMisc::GetMSB(Uint64{0}), Uint64{64}); + for (Uint32 i = 0; i < 64; ++i) + { + auto MSB = PlatformMisc::GetMSB((Uint64{1} << i) | 1); + EXPECT_EQ(MSB, i); + } + + EXPECT_EQ(PlatformMisc::GetLSB(Uint32{0}), Uint32{32}); + for (Uint32 i = 0; i < 32; ++i) + { + auto LSB = PlatformMisc::GetLSB((Uint32{1} << i) | (Uint32{1} << 31)); + EXPECT_EQ(LSB, i); + } + + EXPECT_EQ(PlatformMisc::GetLSB(Uint64{0}), Uint64{64}); + for (Uint32 i = 0; i < 64; ++i) + { + auto LSB = PlatformMisc::GetLSB((Uint64{1} << i) | (Uint64{1} << 63)); + EXPECT_EQ(LSB, i); + } +} + +TEST(Platforms_PlatformMisc, CountOneBits) +{ + EXPECT_EQ(PlatformMisc::CountOneBits(Uint32{0}), Uint32{0}); + EXPECT_EQ(PlatformMisc::CountOneBits(Uint64{0}), Uint64{0}); + EXPECT_EQ(PlatformMisc::CountOneBits(Uint32{1}), Uint32{1}); + EXPECT_EQ(PlatformMisc::CountOneBits(Uint64{1}), Uint64{1}); + EXPECT_EQ(PlatformMisc::CountOneBits(Uint32{7}), Uint32{3}); + EXPECT_EQ(PlatformMisc::CountOneBits(Uint64{7}), Uint64{3}); + EXPECT_EQ(PlatformMisc::CountOneBits((Uint32{1} << 31) | (Uint32{1} << 15)), Uint32{2}); + EXPECT_EQ(PlatformMisc::CountOneBits((Uint64{1} << 63) | (Uint32{1} << 31)), Uint64{2}); + EXPECT_EQ(PlatformMisc::CountOneBits((Uint32{1} << 31) - 1), Uint32{31}); + EXPECT_EQ(PlatformMisc::CountOneBits((Uint64{1} << 63) - 1), Uint64{63}); +} + +} // namespace diff --git a/Tests/IncludeTest/CMakeLists.txt b/Tests/IncludeTest/CMakeLists.txt new file mode 100644 index 00000000..3208c23f --- /dev/null +++ b/Tests/IncludeTest/CMakeLists.txt @@ -0,0 +1,48 @@ +cmake_minimum_required (VERSION 3.6) + +project(DiligentCore-IncludeTest) + +file(GLOB_RECURSE SOURCE LIST_DIRECTORIES false *.cpp) + +if(NOT D3D11_SUPPORTED) + file(GLOB GRAPHICS_ENGINE_D3D11_INC_TEST LIST_DIRECTORIES false GraphicsEngineD3D11/*.cpp) + list(REMOVE_ITEM SOURCE ${GRAPHICS_ENGINE_D3D11_INC_TEST}) +endif() + +if(NOT D3D12_SUPPORTED) + file(GLOB GRAPHICS_ENGINE_D3D12_INC_TEST LIST_DIRECTORIES false GraphicsEngineD3D12/*.cpp) + list(REMOVE_ITEM SOURCE ${GRAPHICS_ENGINE_D3D12_INC_TEST}) +endif() + +if(NOT D3D11_SUPPORTED AND NOT D3D12_SUPPORTED) + file(GLOB GRAPHICS_ENGINE_D3DBASE_INC_TEST LIST_DIRECTORIES false GraphicsEngineD3DBase/*.cpp) + list(REMOVE_ITEM SOURCE ${GRAPHICS_ENGINE_D3DBASE_INC_TEST}) +endif() + +if(NOT GL_SUPPORTED AND NOT GLES_SUPPORTED) + file(GLOB GRAPHICS_ENGINE_GL_INC_TEST LIST_DIRECTORIES false GraphicsEngineOpenGL/*.cpp) + list(REMOVE_ITEM SOURCE ${GRAPHICS_ENGINE_GL_INC_TEST}) +endif() + +if(NOT VULKAN_SUPPORTED) + file(GLOB GRAPHICS_ENGINE_VK_INC_TEST LIST_DIRECTORIES false GraphicsEngineVk/*.cpp) + list(REMOVE_ITEM SOURCE ${GRAPHICS_ENGINE_VK_INC_TEST}) +endif() + +add_library(DiligentCore-IncludeTest ${SOURCE}) + +target_include_directories(DiligentCore-IncludeTest PRIVATE ../../..) +target_link_libraries(DiligentCore-IncludeTest PRIVATE Diligent-BuildSettings) +set_common_target_properties(DiligentCore-IncludeTest) + +if(MSVC) + set_target_properties(DiligentCore-IncludeTest PROPERTIES + STATIC_LIBRARY_FLAGS "/IGNORE:4221" + ) +endif() + +source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${SOURCE}) + +set_target_properties(DiligentCore-IncludeTest PROPERTIES + FOLDER "DiligentCore/Tests" +) diff --git a/Tests/IncludeTest/Common/AdvancedMathH_test.cpp b/Tests/IncludeTest/Common/AdvancedMathH_test.cpp new file mode 100644 index 00000000..df8cc14f --- /dev/null +++ b/Tests/IncludeTest/Common/AdvancedMathH_test.cpp @@ -0,0 +1,24 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "DiligentCore/Common/interface/AdvancedMath.h" diff --git a/Tests/IncludeTest/Common/BasicFileStreamH_test.cpp b/Tests/IncludeTest/Common/BasicFileStreamH_test.cpp new file mode 100644 index 00000000..aa08514c --- /dev/null +++ b/Tests/IncludeTest/Common/BasicFileStreamH_test.cpp @@ -0,0 +1,24 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "DiligentCore/Common/interface/BasicFileStream.h" diff --git a/Tests/IncludeTest/Common/BasicMathH_test.cpp b/Tests/IncludeTest/Common/BasicMathH_test.cpp new file mode 100644 index 00000000..09576d34 --- /dev/null +++ b/Tests/IncludeTest/Common/BasicMathH_test.cpp @@ -0,0 +1,24 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "DiligentCore/Common/interface/BasicMath.h" diff --git a/Tests/IncludeTest/Common/DataBlobImplH_test.cpp b/Tests/IncludeTest/Common/DataBlobImplH_test.cpp new file mode 100644 index 00000000..f72994d6 --- /dev/null +++ b/Tests/IncludeTest/Common/DataBlobImplH_test.cpp @@ -0,0 +1,24 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "DiligentCore/Common/interface/DataBlobImpl.h" diff --git a/Tests/IncludeTest/Common/DefaultRawMemoryAllocatorH_test.cpp b/Tests/IncludeTest/Common/DefaultRawMemoryAllocatorH_test.cpp new file mode 100644 index 00000000..fa3990d4 --- /dev/null +++ b/Tests/IncludeTest/Common/DefaultRawMemoryAllocatorH_test.cpp @@ -0,0 +1,24 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "DiligentCore/Common/interface/DefaultRawMemoryAllocator.h" diff --git a/Tests/IncludeTest/Common/FileWrapperH_test.cpp b/Tests/IncludeTest/Common/FileWrapperH_test.cpp new file mode 100644 index 00000000..ac8375b3 --- /dev/null +++ b/Tests/IncludeTest/Common/FileWrapperH_test.cpp @@ -0,0 +1,24 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "DiligentCore/Common/interface/FileWrapper.h" diff --git a/Tests/IncludeTest/Common/FixedBlockMemoryAllocatorH_test.cpp b/Tests/IncludeTest/Common/FixedBlockMemoryAllocatorH_test.cpp new file mode 100644 index 00000000..0d719caa --- /dev/null +++ b/Tests/IncludeTest/Common/FixedBlockMemoryAllocatorH_test.cpp @@ -0,0 +1,24 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "DiligentCore/Common/interface/FixedBlockMemoryAllocator.h" diff --git a/Tests/IncludeTest/Common/HashUtilsH_test.cpp b/Tests/IncludeTest/Common/HashUtilsH_test.cpp new file mode 100644 index 00000000..79bfaeed --- /dev/null +++ b/Tests/IncludeTest/Common/HashUtilsH_test.cpp @@ -0,0 +1,24 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "DiligentCore/Common/interface/HashUtils.h" diff --git a/Tests/IncludeTest/Common/LockHelperH_test.cpp b/Tests/IncludeTest/Common/LockHelperH_test.cpp new file mode 100644 index 00000000..19cb7ef9 --- /dev/null +++ b/Tests/IncludeTest/Common/LockHelperH_test.cpp @@ -0,0 +1,24 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "DiligentCore/Common/interface/LockHelper.h" diff --git a/Tests/IncludeTest/Common/ObjectBaseH_test.cpp b/Tests/IncludeTest/Common/ObjectBaseH_test.cpp new file mode 100644 index 00000000..7b1e26dc --- /dev/null +++ b/Tests/IncludeTest/Common/ObjectBaseH_test.cpp @@ -0,0 +1,24 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "DiligentCore/Common/interface/ObjectBase.h" diff --git a/Tests/IncludeTest/Common/RefCntAutoPtrH_test.cpp b/Tests/IncludeTest/Common/RefCntAutoPtrH_test.cpp new file mode 100644 index 00000000..79c52c90 --- /dev/null +++ b/Tests/IncludeTest/Common/RefCntAutoPtrH_test.cpp @@ -0,0 +1,24 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "DiligentCore/Common/interface/RefCntAutoPtr.h" diff --git a/Tests/IncludeTest/Common/RefCountedObjectImplH_test.cpp b/Tests/IncludeTest/Common/RefCountedObjectImplH_test.cpp new file mode 100644 index 00000000..33df39c0 --- /dev/null +++ b/Tests/IncludeTest/Common/RefCountedObjectImplH_test.cpp @@ -0,0 +1,24 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "DiligentCore/Common/interface/RefCountedObjectImpl.h" diff --git a/Tests/IncludeTest/Common/STDAllocatorH_test.cpp b/Tests/IncludeTest/Common/STDAllocatorH_test.cpp new file mode 100644 index 00000000..c2ca54f3 --- /dev/null +++ b/Tests/IncludeTest/Common/STDAllocatorH_test.cpp @@ -0,0 +1,24 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "DiligentCore/Common/interface/STDAllocator.h" diff --git a/Tests/IncludeTest/Common/StringDataBlobImplH_test.cpp b/Tests/IncludeTest/Common/StringDataBlobImplH_test.cpp new file mode 100644 index 00000000..889cca6d --- /dev/null +++ b/Tests/IncludeTest/Common/StringDataBlobImplH_test.cpp @@ -0,0 +1,24 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "DiligentCore/Common/interface/StringDataBlobImpl.h" diff --git a/Tests/IncludeTest/Common/StringPool_test.cpp b/Tests/IncludeTest/Common/StringPool_test.cpp new file mode 100644 index 00000000..0fe38252 --- /dev/null +++ b/Tests/IncludeTest/Common/StringPool_test.cpp @@ -0,0 +1,24 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "DiligentCore/Common/interface/StringPool.h" diff --git a/Tests/IncludeTest/Common/StringToolsH_test.cpp b/Tests/IncludeTest/Common/StringToolsH_test.cpp new file mode 100644 index 00000000..f4ea9c43 --- /dev/null +++ b/Tests/IncludeTest/Common/StringToolsH_test.cpp @@ -0,0 +1,24 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "DiligentCore/Common/interface/StringTools.h" diff --git a/Tests/IncludeTest/Common/ThreadSignalH_test.cpp b/Tests/IncludeTest/Common/ThreadSignalH_test.cpp new file mode 100644 index 00000000..d3e9803b --- /dev/null +++ b/Tests/IncludeTest/Common/ThreadSignalH_test.cpp @@ -0,0 +1,24 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "DiligentCore/Common/interface/ThreadSignal.h" diff --git a/Tests/IncludeTest/Common/TimerH_test.cpp b/Tests/IncludeTest/Common/TimerH_test.cpp new file mode 100644 index 00000000..9884c09b --- /dev/null +++ b/Tests/IncludeTest/Common/TimerH_test.cpp @@ -0,0 +1,24 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "DiligentCore/Common/interface/Timer.h" diff --git a/Tests/IncludeTest/Common/UniqueIdentifierH_test.cpp b/Tests/IncludeTest/Common/UniqueIdentifierH_test.cpp new file mode 100644 index 00000000..2c3bb79e --- /dev/null +++ b/Tests/IncludeTest/Common/UniqueIdentifierH_test.cpp @@ -0,0 +1,24 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "DiligentCore/Common/interface/UniqueIdentifier.h" diff --git a/Tests/IncludeTest/Common/ValidatedCastH_test.cpp b/Tests/IncludeTest/Common/ValidatedCastH_test.cpp new file mode 100644 index 00000000..66aa9ce3 --- /dev/null +++ b/Tests/IncludeTest/Common/ValidatedCastH_test.cpp @@ -0,0 +1,24 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "DiligentCore/Common/interface/ValidatedCast.h" diff --git a/Tests/IncludeTest/GraphicsAccessories/ColorConversionH_test.cpp b/Tests/IncludeTest/GraphicsAccessories/ColorConversionH_test.cpp new file mode 100644 index 00000000..cf160a97 --- /dev/null +++ b/Tests/IncludeTest/GraphicsAccessories/ColorConversionH_test.cpp @@ -0,0 +1,24 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "DiligentCore/Graphics/GraphicsAccessories/interface/ColorConversion.h" diff --git a/Tests/IncludeTest/GraphicsAccessories/GraphicsAccessoriesH_test.cpp b/Tests/IncludeTest/GraphicsAccessories/GraphicsAccessoriesH_test.cpp new file mode 100644 index 00000000..dc95f655 --- /dev/null +++ b/Tests/IncludeTest/GraphicsAccessories/GraphicsAccessoriesH_test.cpp @@ -0,0 +1,24 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "DiligentCore/Graphics/GraphicsAccessories/interface/GraphicsAccessories.h" diff --git a/Tests/IncludeTest/GraphicsAccessories/ResourceReleaseQueueH_test.cpp b/Tests/IncludeTest/GraphicsAccessories/ResourceReleaseQueueH_test.cpp new file mode 100644 index 00000000..459711c7 --- /dev/null +++ b/Tests/IncludeTest/GraphicsAccessories/ResourceReleaseQueueH_test.cpp @@ -0,0 +1,24 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "DiligentCore/Graphics/GraphicsAccessories/interface/ResourceReleaseQueue.h" diff --git a/Tests/IncludeTest/GraphicsAccessories/RingBufferH_test.cpp b/Tests/IncludeTest/GraphicsAccessories/RingBufferH_test.cpp new file mode 100644 index 00000000..ebe47e97 --- /dev/null +++ b/Tests/IncludeTest/GraphicsAccessories/RingBufferH_test.cpp @@ -0,0 +1,24 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "DiligentCore/Graphics/GraphicsAccessories/interface/RingBuffer.h" diff --git a/Tests/IncludeTest/GraphicsAccessories/SRBMemortAllocatorH_test.cpp b/Tests/IncludeTest/GraphicsAccessories/SRBMemortAllocatorH_test.cpp new file mode 100644 index 00000000..94317363 --- /dev/null +++ b/Tests/IncludeTest/GraphicsAccessories/SRBMemortAllocatorH_test.cpp @@ -0,0 +1,24 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "DiligentCore/Graphics/GraphicsAccessories/interface/SRBMemoryAllocator.h" diff --git a/Tests/IncludeTest/GraphicsAccessories/VariableSizeAllocationsManagerH_test.cpp b/Tests/IncludeTest/GraphicsAccessories/VariableSizeAllocationsManagerH_test.cpp new file mode 100644 index 00000000..d0cfefe6 --- /dev/null +++ b/Tests/IncludeTest/GraphicsAccessories/VariableSizeAllocationsManagerH_test.cpp @@ -0,0 +1,24 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "DiligentCore/Graphics/GraphicsAccessories/interface/VariableSizeAllocationsManager.h" diff --git a/Tests/IncludeTest/GraphicsAccessories/VariableSizeGPUAllocationsManagerH_test.cpp b/Tests/IncludeTest/GraphicsAccessories/VariableSizeGPUAllocationsManagerH_test.cpp new file mode 100644 index 00000000..324f1914 --- /dev/null +++ b/Tests/IncludeTest/GraphicsAccessories/VariableSizeGPUAllocationsManagerH_test.cpp @@ -0,0 +1,24 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "DiligentCore/Graphics/GraphicsAccessories/interface/VariableSizeGPUAllocationsManager.h" diff --git a/Tests/IncludeTest/GraphicsEngine/BlendStateH_test.cpp b/Tests/IncludeTest/GraphicsEngine/BlendStateH_test.cpp new file mode 100644 index 00000000..8fe22738 --- /dev/null +++ b/Tests/IncludeTest/GraphicsEngine/BlendStateH_test.cpp @@ -0,0 +1,24 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "DiligentCore/Graphics/GraphicsEngine/interface/BlendState.h" diff --git a/Tests/IncludeTest/GraphicsEngine/BufferH_test.cpp b/Tests/IncludeTest/GraphicsEngine/BufferH_test.cpp new file mode 100644 index 00000000..175494a7 --- /dev/null +++ b/Tests/IncludeTest/GraphicsEngine/BufferH_test.cpp @@ -0,0 +1,24 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "DiligentCore/Graphics/GraphicsEngine/interface/Buffer.h" \ No newline at end of file diff --git a/Tests/IncludeTest/GraphicsEngine/BufferViewH_test.cpp b/Tests/IncludeTest/GraphicsEngine/BufferViewH_test.cpp new file mode 100644 index 00000000..3cc88c4e --- /dev/null +++ b/Tests/IncludeTest/GraphicsEngine/BufferViewH_test.cpp @@ -0,0 +1,24 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "DiligentCore/Graphics/GraphicsEngine/interface/BufferView.h" \ No newline at end of file diff --git a/Tests/IncludeTest/GraphicsEngine/CommandListH_test.cpp b/Tests/IncludeTest/GraphicsEngine/CommandListH_test.cpp new file mode 100644 index 00000000..abe39f27 --- /dev/null +++ b/Tests/IncludeTest/GraphicsEngine/CommandListH_test.cpp @@ -0,0 +1,24 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "DiligentCore/Graphics/GraphicsEngine/interface/CommandList.h" \ No newline at end of file diff --git a/Tests/IncludeTest/GraphicsEngine/ConstantsH_test.cpp b/Tests/IncludeTest/GraphicsEngine/ConstantsH_test.cpp new file mode 100644 index 00000000..d5312411 --- /dev/null +++ b/Tests/IncludeTest/GraphicsEngine/ConstantsH_test.cpp @@ -0,0 +1,24 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "DiligentCore/Graphics/GraphicsEngine/interface/Constants.h" diff --git a/Tests/IncludeTest/GraphicsEngine/DefaultShaderSourceStreamFactoryH_test.cpp b/Tests/IncludeTest/GraphicsEngine/DefaultShaderSourceStreamFactoryH_test.cpp new file mode 100644 index 00000000..5cdbc81d --- /dev/null +++ b/Tests/IncludeTest/GraphicsEngine/DefaultShaderSourceStreamFactoryH_test.cpp @@ -0,0 +1,24 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "DiligentCore/Graphics/GraphicsEngine/include/DefaultShaderSourceStreamFactory.h" diff --git a/Tests/IncludeTest/GraphicsEngine/DepthStencilStateH_test.cpp b/Tests/IncludeTest/GraphicsEngine/DepthStencilStateH_test.cpp new file mode 100644 index 00000000..12502b60 --- /dev/null +++ b/Tests/IncludeTest/GraphicsEngine/DepthStencilStateH_test.cpp @@ -0,0 +1,24 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "DiligentCore/Graphics/GraphicsEngine/interface/DepthStencilState.h" diff --git a/Tests/IncludeTest/GraphicsEngine/DeviceCapsH_test.cpp b/Tests/IncludeTest/GraphicsEngine/DeviceCapsH_test.cpp new file mode 100644 index 00000000..1a2c324c --- /dev/null +++ b/Tests/IncludeTest/GraphicsEngine/DeviceCapsH_test.cpp @@ -0,0 +1,24 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "DiligentCore/Graphics/GraphicsEngine/interface/DeviceCaps.h" diff --git a/Tests/IncludeTest/GraphicsEngine/DeviceContextH_test.cpp b/Tests/IncludeTest/GraphicsEngine/DeviceContextH_test.cpp new file mode 100644 index 00000000..1161f611 --- /dev/null +++ b/Tests/IncludeTest/GraphicsEngine/DeviceContextH_test.cpp @@ -0,0 +1,24 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "DiligentCore/Graphics/GraphicsEngine/interface/DeviceContext.h" diff --git a/Tests/IncludeTest/GraphicsEngine/DeviceObjectH_test.cpp b/Tests/IncludeTest/GraphicsEngine/DeviceObjectH_test.cpp new file mode 100644 index 00000000..30f3c828 --- /dev/null +++ b/Tests/IncludeTest/GraphicsEngine/DeviceObjectH_test.cpp @@ -0,0 +1,24 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "DiligentCore/Graphics/GraphicsEngine/interface/DeviceObject.h" diff --git a/Tests/IncludeTest/GraphicsEngine/EngineFactoryH_test.cpp b/Tests/IncludeTest/GraphicsEngine/EngineFactoryH_test.cpp new file mode 100644 index 00000000..66a6d061 --- /dev/null +++ b/Tests/IncludeTest/GraphicsEngine/EngineFactoryH_test.cpp @@ -0,0 +1,24 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "DiligentCore/Graphics/GraphicsEngine/interface/EngineFactory.h" \ No newline at end of file diff --git a/Tests/IncludeTest/GraphicsEngine/FenceH_test.cpp b/Tests/IncludeTest/GraphicsEngine/FenceH_test.cpp new file mode 100644 index 00000000..ec683990 --- /dev/null +++ b/Tests/IncludeTest/GraphicsEngine/FenceH_test.cpp @@ -0,0 +1,24 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "DiligentCore/Graphics/GraphicsEngine/interface/Fence.h" \ No newline at end of file diff --git a/Tests/IncludeTest/GraphicsEngine/GraphicsTypesH_test.cpp b/Tests/IncludeTest/GraphicsEngine/GraphicsTypesH_test.cpp new file mode 100644 index 00000000..480e4a16 --- /dev/null +++ b/Tests/IncludeTest/GraphicsEngine/GraphicsTypesH_test.cpp @@ -0,0 +1,24 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "DiligentCore/Graphics/GraphicsEngine/interface/GraphicsTypes.h" diff --git a/Tests/IncludeTest/GraphicsEngine/InputLayoutH_test.cpp b/Tests/IncludeTest/GraphicsEngine/InputLayoutH_test.cpp new file mode 100644 index 00000000..9b3581fa --- /dev/null +++ b/Tests/IncludeTest/GraphicsEngine/InputLayoutH_test.cpp @@ -0,0 +1,24 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "DiligentCore/Graphics/GraphicsEngine/interface/InputLayout.h" diff --git a/Tests/IncludeTest/GraphicsEngine/MapHelperH_test.cpp b/Tests/IncludeTest/GraphicsEngine/MapHelperH_test.cpp new file mode 100644 index 00000000..b3b7a6d0 --- /dev/null +++ b/Tests/IncludeTest/GraphicsEngine/MapHelperH_test.cpp @@ -0,0 +1,24 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "DiligentCore/Graphics/GraphicsEngine/interface/MapHelper.h" diff --git a/Tests/IncludeTest/GraphicsEngine/PipelineStateH_test.cpp b/Tests/IncludeTest/GraphicsEngine/PipelineStateH_test.cpp new file mode 100644 index 00000000..b3b19163 --- /dev/null +++ b/Tests/IncludeTest/GraphicsEngine/PipelineStateH_test.cpp @@ -0,0 +1,24 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "DiligentCore/Graphics/GraphicsEngine/interface/PipelineState.h" diff --git a/Tests/IncludeTest/GraphicsEngine/RasterizerStateH_test.cpp b/Tests/IncludeTest/GraphicsEngine/RasterizerStateH_test.cpp new file mode 100644 index 00000000..598e2f5e --- /dev/null +++ b/Tests/IncludeTest/GraphicsEngine/RasterizerStateH_test.cpp @@ -0,0 +1,24 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "DiligentCore/Graphics/GraphicsEngine/interface/RasterizerState.h" diff --git a/Tests/IncludeTest/GraphicsEngine/RenderDeviceH_test.cpp b/Tests/IncludeTest/GraphicsEngine/RenderDeviceH_test.cpp new file mode 100644 index 00000000..2eaf3641 --- /dev/null +++ b/Tests/IncludeTest/GraphicsEngine/RenderDeviceH_test.cpp @@ -0,0 +1,24 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "DiligentCore/Graphics/GraphicsEngine/interface/RenderDevice.h" diff --git a/Tests/IncludeTest/GraphicsEngine/ResourceMappingH_test.cpp b/Tests/IncludeTest/GraphicsEngine/ResourceMappingH_test.cpp new file mode 100644 index 00000000..db76165c --- /dev/null +++ b/Tests/IncludeTest/GraphicsEngine/ResourceMappingH_test.cpp @@ -0,0 +1,24 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "DiligentCore/Graphics/GraphicsEngine/interface/ResourceMapping.h" diff --git a/Tests/IncludeTest/GraphicsEngine/SamplerH_test.cpp b/Tests/IncludeTest/GraphicsEngine/SamplerH_test.cpp new file mode 100644 index 00000000..aa02c1f9 --- /dev/null +++ b/Tests/IncludeTest/GraphicsEngine/SamplerH_test.cpp @@ -0,0 +1,24 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "DiligentCore/Graphics/GraphicsEngine/interface/Sampler.h" diff --git a/Tests/IncludeTest/GraphicsEngine/ShaderH_test.cpp b/Tests/IncludeTest/GraphicsEngine/ShaderH_test.cpp new file mode 100644 index 00000000..0e68007c --- /dev/null +++ b/Tests/IncludeTest/GraphicsEngine/ShaderH_test.cpp @@ -0,0 +1,24 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "DiligentCore/Graphics/GraphicsEngine/interface/Shader.h" diff --git a/Tests/IncludeTest/GraphicsEngine/ShaderResourceBindingH_test.cpp b/Tests/IncludeTest/GraphicsEngine/ShaderResourceBindingH_test.cpp new file mode 100644 index 00000000..d91f48bf --- /dev/null +++ b/Tests/IncludeTest/GraphicsEngine/ShaderResourceBindingH_test.cpp @@ -0,0 +1,24 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "DiligentCore/Graphics/GraphicsEngine/interface/ShaderResourceBinding.h" diff --git a/Tests/IncludeTest/GraphicsEngine/ShaderResourceVaraibleH_test.cpp b/Tests/IncludeTest/GraphicsEngine/ShaderResourceVaraibleH_test.cpp new file mode 100644 index 00000000..3e0ad249 --- /dev/null +++ b/Tests/IncludeTest/GraphicsEngine/ShaderResourceVaraibleH_test.cpp @@ -0,0 +1,24 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "DiligentCore/Graphics/GraphicsEngine/interface/ShaderResourceVariable.h" diff --git a/Tests/IncludeTest/GraphicsEngine/SwapChainH_test.cpp b/Tests/IncludeTest/GraphicsEngine/SwapChainH_test.cpp new file mode 100644 index 00000000..67be654c --- /dev/null +++ b/Tests/IncludeTest/GraphicsEngine/SwapChainH_test.cpp @@ -0,0 +1,24 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "DiligentCore/Graphics/GraphicsEngine/interface/SwapChain.h" \ No newline at end of file diff --git a/Tests/IncludeTest/GraphicsEngine/TextureH_test.cpp b/Tests/IncludeTest/GraphicsEngine/TextureH_test.cpp new file mode 100644 index 00000000..0252cb1c --- /dev/null +++ b/Tests/IncludeTest/GraphicsEngine/TextureH_test.cpp @@ -0,0 +1,24 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "DiligentCore/Graphics/GraphicsEngine/interface/Texture.h" diff --git a/Tests/IncludeTest/GraphicsEngine/TextureViewH_test.cpp b/Tests/IncludeTest/GraphicsEngine/TextureViewH_test.cpp new file mode 100644 index 00000000..acafd3c7 --- /dev/null +++ b/Tests/IncludeTest/GraphicsEngine/TextureViewH_test.cpp @@ -0,0 +1,24 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "DiligentCore/Graphics/GraphicsEngine/interface/TextureView.h" diff --git a/Tests/IncludeTest/GraphicsEngineD3D11/BufferD3D11H_test.cpp b/Tests/IncludeTest/GraphicsEngineD3D11/BufferD3D11H_test.cpp new file mode 100644 index 00000000..30ecdc00 --- /dev/null +++ b/Tests/IncludeTest/GraphicsEngineD3D11/BufferD3D11H_test.cpp @@ -0,0 +1,25 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include +#include "DiligentCore/Graphics/GraphicsEngineD3D11/interface/BufferD3D11.h" diff --git a/Tests/IncludeTest/GraphicsEngineD3D11/BufferViewD3D11H_test.cpp b/Tests/IncludeTest/GraphicsEngineD3D11/BufferViewD3D11H_test.cpp new file mode 100644 index 00000000..23a5aa37 --- /dev/null +++ b/Tests/IncludeTest/GraphicsEngineD3D11/BufferViewD3D11H_test.cpp @@ -0,0 +1,25 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include +#include "DiligentCore/Graphics/GraphicsEngineD3D11/interface/BufferViewD3D11.h" diff --git a/Tests/IncludeTest/GraphicsEngineD3D11/DeviceContextD3D11H_test.cpp b/Tests/IncludeTest/GraphicsEngineD3D11/DeviceContextD3D11H_test.cpp new file mode 100644 index 00000000..4b654bc2 --- /dev/null +++ b/Tests/IncludeTest/GraphicsEngineD3D11/DeviceContextD3D11H_test.cpp @@ -0,0 +1,25 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include +#include "DiligentCore/Graphics/GraphicsEngineD3D11/interface/DeviceContextD3D11.h" diff --git a/Tests/IncludeTest/GraphicsEngineD3D11/EngineFactoryD3D11H_test.cpp b/Tests/IncludeTest/GraphicsEngineD3D11/EngineFactoryD3D11H_test.cpp new file mode 100644 index 00000000..f7a1c6f1 --- /dev/null +++ b/Tests/IncludeTest/GraphicsEngineD3D11/EngineFactoryD3D11H_test.cpp @@ -0,0 +1,33 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#ifndef NOMINMAX +# define NOMINMAX +#endif +#include + +#ifndef ENGINE_DLL +# define ENGINE_DLL 1 +#endif + +#include "DiligentCore/Graphics/GraphicsEngineD3D11/interface/EngineFactoryD3D11.h" diff --git a/Tests/IncludeTest/GraphicsEngineD3D11/FenceD3D11H_test.cpp b/Tests/IncludeTest/GraphicsEngineD3D11/FenceD3D11H_test.cpp new file mode 100644 index 00000000..e568e924 --- /dev/null +++ b/Tests/IncludeTest/GraphicsEngineD3D11/FenceD3D11H_test.cpp @@ -0,0 +1,25 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include +#include "DiligentCore/Graphics/GraphicsEngineD3D11/interface/FenceD3D11.h" diff --git a/Tests/IncludeTest/GraphicsEngineD3D11/PipelineStateD3D11H_test.cpp b/Tests/IncludeTest/GraphicsEngineD3D11/PipelineStateD3D11H_test.cpp new file mode 100644 index 00000000..8fb95d90 --- /dev/null +++ b/Tests/IncludeTest/GraphicsEngineD3D11/PipelineStateD3D11H_test.cpp @@ -0,0 +1,25 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include +#include "DiligentCore/Graphics/GraphicsEngineD3D11/interface/PipelineStateD3D11.h" diff --git a/Tests/IncludeTest/GraphicsEngineD3D11/RenderDeviceD3D11H_test.cpp b/Tests/IncludeTest/GraphicsEngineD3D11/RenderDeviceD3D11H_test.cpp new file mode 100644 index 00000000..abf6da80 --- /dev/null +++ b/Tests/IncludeTest/GraphicsEngineD3D11/RenderDeviceD3D11H_test.cpp @@ -0,0 +1,25 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include +#include "DiligentCore/Graphics/GraphicsEngineD3D11/interface/RenderDeviceD3D11.h" diff --git a/Tests/IncludeTest/GraphicsEngineD3D11/SamplerD3D11H_test.cpp b/Tests/IncludeTest/GraphicsEngineD3D11/SamplerD3D11H_test.cpp new file mode 100644 index 00000000..00961e95 --- /dev/null +++ b/Tests/IncludeTest/GraphicsEngineD3D11/SamplerD3D11H_test.cpp @@ -0,0 +1,25 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include +#include "DiligentCore/Graphics/GraphicsEngineD3D11/interface/SamplerD3D11.h" diff --git a/Tests/IncludeTest/GraphicsEngineD3D11/ShaderD3D11H_test.cpp b/Tests/IncludeTest/GraphicsEngineD3D11/ShaderD3D11H_test.cpp new file mode 100644 index 00000000..77ca1a69 --- /dev/null +++ b/Tests/IncludeTest/GraphicsEngineD3D11/ShaderD3D11H_test.cpp @@ -0,0 +1,25 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ +#include + +#include "DiligentCore/Graphics/GraphicsEngineD3D11/interface/ShaderD3D11.h" diff --git a/Tests/IncludeTest/GraphicsEngineD3D11/ShaderResourceBindingD3D11H_test.cpp b/Tests/IncludeTest/GraphicsEngineD3D11/ShaderResourceBindingD3D11H_test.cpp new file mode 100644 index 00000000..9409f3f6 --- /dev/null +++ b/Tests/IncludeTest/GraphicsEngineD3D11/ShaderResourceBindingD3D11H_test.cpp @@ -0,0 +1,25 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ +#include + +#include "DiligentCore/Graphics/GraphicsEngineD3D11/interface/ShaderResourceBindingD3D11.h" diff --git a/Tests/IncludeTest/GraphicsEngineD3D11/SwapChainD3D11H_test.cpp b/Tests/IncludeTest/GraphicsEngineD3D11/SwapChainD3D11H_test.cpp new file mode 100644 index 00000000..59f23387 --- /dev/null +++ b/Tests/IncludeTest/GraphicsEngineD3D11/SwapChainD3D11H_test.cpp @@ -0,0 +1,24 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ +#include +#include "DiligentCore/Graphics/GraphicsEngineD3D11/interface/SwapChainD3D11.h" \ No newline at end of file diff --git a/Tests/IncludeTest/GraphicsEngineD3D11/TextureD3D11H_test.cpp b/Tests/IncludeTest/GraphicsEngineD3D11/TextureD3D11H_test.cpp new file mode 100644 index 00000000..4cd32017 --- /dev/null +++ b/Tests/IncludeTest/GraphicsEngineD3D11/TextureD3D11H_test.cpp @@ -0,0 +1,25 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ +#include + +#include "DiligentCore/Graphics/GraphicsEngineD3D11/interface/TextureD3D11.h" diff --git a/Tests/IncludeTest/GraphicsEngineD3D11/TextureViewD3D11H_test.cpp b/Tests/IncludeTest/GraphicsEngineD3D11/TextureViewD3D11H_test.cpp new file mode 100644 index 00000000..144b72da --- /dev/null +++ b/Tests/IncludeTest/GraphicsEngineD3D11/TextureViewD3D11H_test.cpp @@ -0,0 +1,25 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ +#include + +#include "DiligentCore/Graphics/GraphicsEngineD3D11/interface/TextureViewD3D11.h" diff --git a/Tests/IncludeTest/GraphicsEngineD3D12/BufferD3D12H_test.cpp b/Tests/IncludeTest/GraphicsEngineD3D12/BufferD3D12H_test.cpp new file mode 100644 index 00000000..13945d1c --- /dev/null +++ b/Tests/IncludeTest/GraphicsEngineD3D12/BufferD3D12H_test.cpp @@ -0,0 +1,25 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include +#include "DiligentCore/Graphics/GraphicsEngineD3D12/interface/BufferD3D12.h" diff --git a/Tests/IncludeTest/GraphicsEngineD3D12/BufferViewD3D12H_test.cpp b/Tests/IncludeTest/GraphicsEngineD3D12/BufferViewD3D12H_test.cpp new file mode 100644 index 00000000..f341419c --- /dev/null +++ b/Tests/IncludeTest/GraphicsEngineD3D12/BufferViewD3D12H_test.cpp @@ -0,0 +1,25 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include +#include "DiligentCore/Graphics/GraphicsEngineD3D12/interface/BufferViewD3D12.h" diff --git a/Tests/IncludeTest/GraphicsEngineD3D12/CommandQueueD3D12H_test.cpp b/Tests/IncludeTest/GraphicsEngineD3D12/CommandQueueD3D12H_test.cpp new file mode 100644 index 00000000..f341419c --- /dev/null +++ b/Tests/IncludeTest/GraphicsEngineD3D12/CommandQueueD3D12H_test.cpp @@ -0,0 +1,25 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include +#include "DiligentCore/Graphics/GraphicsEngineD3D12/interface/BufferViewD3D12.h" diff --git a/Tests/IncludeTest/GraphicsEngineD3D12/DeviceContextD3D12H_test.cpp b/Tests/IncludeTest/GraphicsEngineD3D12/DeviceContextD3D12H_test.cpp new file mode 100644 index 00000000..eafb4881 --- /dev/null +++ b/Tests/IncludeTest/GraphicsEngineD3D12/DeviceContextD3D12H_test.cpp @@ -0,0 +1,25 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include +#include "DiligentCore/Graphics/GraphicsEngineD3D12/interface/DeviceContextD3D12.h" diff --git a/Tests/IncludeTest/GraphicsEngineD3D12/EngineFactoryD3D12H_test.cpp b/Tests/IncludeTest/GraphicsEngineD3D12/EngineFactoryD3D12H_test.cpp new file mode 100644 index 00000000..a0351d94 --- /dev/null +++ b/Tests/IncludeTest/GraphicsEngineD3D12/EngineFactoryD3D12H_test.cpp @@ -0,0 +1,33 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#ifndef NOMINMAX +# define NOMINMAX +#endif +#include + +#ifndef ENGINE_DLL +# define ENGINE_DLL 1 +#endif + +#include "DiligentCore/Graphics/GraphicsEngineD3D12/interface/EngineFactoryD3D12.h" diff --git a/Tests/IncludeTest/GraphicsEngineD3D12/FenceD3D12H_test.cpp b/Tests/IncludeTest/GraphicsEngineD3D12/FenceD3D12H_test.cpp new file mode 100644 index 00000000..12e265ba --- /dev/null +++ b/Tests/IncludeTest/GraphicsEngineD3D12/FenceD3D12H_test.cpp @@ -0,0 +1,25 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include +#include "DiligentCore/Graphics/GraphicsEngineD3D12/interface/FenceD3D12.h" diff --git a/Tests/IncludeTest/GraphicsEngineD3D12/PipelineStateD3D12H_test.cpp b/Tests/IncludeTest/GraphicsEngineD3D12/PipelineStateD3D12H_test.cpp new file mode 100644 index 00000000..05aead58 --- /dev/null +++ b/Tests/IncludeTest/GraphicsEngineD3D12/PipelineStateD3D12H_test.cpp @@ -0,0 +1,25 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include +#include "DiligentCore/Graphics/GraphicsEngineD3D12/interface/PipelineStateD3D12.h" diff --git a/Tests/IncludeTest/GraphicsEngineD3D12/RenderDeviceD3D12H_test.cpp b/Tests/IncludeTest/GraphicsEngineD3D12/RenderDeviceD3D12H_test.cpp new file mode 100644 index 00000000..e8d2d2f6 --- /dev/null +++ b/Tests/IncludeTest/GraphicsEngineD3D12/RenderDeviceD3D12H_test.cpp @@ -0,0 +1,25 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include +#include "DiligentCore/Graphics/GraphicsEngineD3D12/interface/RenderDeviceD3D12.h" diff --git a/Tests/IncludeTest/GraphicsEngineD3D12/SamplerD3D12H_test.cpp b/Tests/IncludeTest/GraphicsEngineD3D12/SamplerD3D12H_test.cpp new file mode 100644 index 00000000..3694cd74 --- /dev/null +++ b/Tests/IncludeTest/GraphicsEngineD3D12/SamplerD3D12H_test.cpp @@ -0,0 +1,25 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include +#include "DiligentCore/Graphics/GraphicsEngineD3D12/interface/SamplerD3D12.h" diff --git a/Tests/IncludeTest/GraphicsEngineD3D12/ShaderD3D12H_test.cpp b/Tests/IncludeTest/GraphicsEngineD3D12/ShaderD3D12H_test.cpp new file mode 100644 index 00000000..206058ff --- /dev/null +++ b/Tests/IncludeTest/GraphicsEngineD3D12/ShaderD3D12H_test.cpp @@ -0,0 +1,24 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ +#include +#include "DiligentCore/Graphics/GraphicsEngineD3D12/interface/ShaderD3D12.h" diff --git a/Tests/IncludeTest/GraphicsEngineD3D12/ShaderResourceBindingD3D12H_test.cpp b/Tests/IncludeTest/GraphicsEngineD3D12/ShaderResourceBindingD3D12H_test.cpp new file mode 100644 index 00000000..5ffcafe3 --- /dev/null +++ b/Tests/IncludeTest/GraphicsEngineD3D12/ShaderResourceBindingD3D12H_test.cpp @@ -0,0 +1,24 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ +#include +#include "DiligentCore/Graphics/GraphicsEngineD3D12/interface/ShaderResourceBindingD3D12.h" diff --git a/Tests/IncludeTest/GraphicsEngineD3D12/SwapChainD3D12H_test.cpp b/Tests/IncludeTest/GraphicsEngineD3D12/SwapChainD3D12H_test.cpp new file mode 100644 index 00000000..9ca8bdb5 --- /dev/null +++ b/Tests/IncludeTest/GraphicsEngineD3D12/SwapChainD3D12H_test.cpp @@ -0,0 +1,24 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ +#include +#include "DiligentCore/Graphics/GraphicsEngineD3D12/interface/SwapChainD3D12.h" \ No newline at end of file diff --git a/Tests/IncludeTest/GraphicsEngineD3D12/TextureD3D12H_test.cpp b/Tests/IncludeTest/GraphicsEngineD3D12/TextureD3D12H_test.cpp new file mode 100644 index 00000000..fa9b50ea --- /dev/null +++ b/Tests/IncludeTest/GraphicsEngineD3D12/TextureD3D12H_test.cpp @@ -0,0 +1,24 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ +#include +#include "DiligentCore/Graphics/GraphicsEngineD3D12/interface/TextureD3D12.h" diff --git a/Tests/IncludeTest/GraphicsEngineD3D12/TextureViewD3D12H_test.cpp b/Tests/IncludeTest/GraphicsEngineD3D12/TextureViewD3D12H_test.cpp new file mode 100644 index 00000000..bda08196 --- /dev/null +++ b/Tests/IncludeTest/GraphicsEngineD3D12/TextureViewD3D12H_test.cpp @@ -0,0 +1,25 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include +#include "DiligentCore/Graphics/GraphicsEngineD3D12/interface/TextureViewD3D12.h" diff --git a/Tests/IncludeTest/GraphicsEngineD3DBase/ShaderD3DH_test.cpp b/Tests/IncludeTest/GraphicsEngineD3DBase/ShaderD3DH_test.cpp new file mode 100644 index 00000000..d8deb96c --- /dev/null +++ b/Tests/IncludeTest/GraphicsEngineD3DBase/ShaderD3DH_test.cpp @@ -0,0 +1,24 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "DiligentCore/Graphics/GraphicsEngineD3DBase/interface/ShaderD3D.h" \ No newline at end of file diff --git a/Tests/IncludeTest/GraphicsEngineD3DBase/ShaderResourceVariableD3DH_test.cpp b/Tests/IncludeTest/GraphicsEngineD3DBase/ShaderResourceVariableD3DH_test.cpp new file mode 100644 index 00000000..32c06851 --- /dev/null +++ b/Tests/IncludeTest/GraphicsEngineD3DBase/ShaderResourceVariableD3DH_test.cpp @@ -0,0 +1,23 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ +#include "DiligentCore/Graphics/GraphicsEngineD3DBase/interface/ShaderResourceVariableD3D.h" diff --git a/Tests/IncludeTest/GraphicsEngineOpenGL/BaseInterfacesGLH_test.cpp b/Tests/IncludeTest/GraphicsEngineOpenGL/BaseInterfacesGLH_test.cpp new file mode 100644 index 00000000..b7213875 --- /dev/null +++ b/Tests/IncludeTest/GraphicsEngineOpenGL/BaseInterfacesGLH_test.cpp @@ -0,0 +1,24 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "DiligentCore/Graphics/GraphicsEngineOpenGL/interface/BaseInterfacesGL.h" diff --git a/Tests/IncludeTest/GraphicsEngineOpenGL/BufferGLH_test.cpp b/Tests/IncludeTest/GraphicsEngineOpenGL/BufferGLH_test.cpp new file mode 100644 index 00000000..f91a96e4 --- /dev/null +++ b/Tests/IncludeTest/GraphicsEngineOpenGL/BufferGLH_test.cpp @@ -0,0 +1,25 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +typedef unsigned int GLuint; +#include "DiligentCore/Graphics/GraphicsEngineOpenGL/interface/BufferGL.h" diff --git a/Tests/IncludeTest/GraphicsEngineOpenGL/BufferViewGLH_test.cpp b/Tests/IncludeTest/GraphicsEngineOpenGL/BufferViewGLH_test.cpp new file mode 100644 index 00000000..5d7e5ebf --- /dev/null +++ b/Tests/IncludeTest/GraphicsEngineOpenGL/BufferViewGLH_test.cpp @@ -0,0 +1,24 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "DiligentCore/Graphics/GraphicsEngineOpenGL/interface/BufferViewGL.h" diff --git a/Tests/IncludeTest/GraphicsEngineOpenGL/DeviceContextGLH_test.cpp b/Tests/IncludeTest/GraphicsEngineOpenGL/DeviceContextGLH_test.cpp new file mode 100644 index 00000000..59204d79 --- /dev/null +++ b/Tests/IncludeTest/GraphicsEngineOpenGL/DeviceContextGLH_test.cpp @@ -0,0 +1,24 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "DiligentCore/Graphics/GraphicsEngineOpenGL/interface/DeviceContextGL.h" diff --git a/Tests/IncludeTest/GraphicsEngineOpenGL/EngineFactoryOpenGLH_test.cpp b/Tests/IncludeTest/GraphicsEngineOpenGL/EngineFactoryOpenGLH_test.cpp new file mode 100644 index 00000000..671fe4fe --- /dev/null +++ b/Tests/IncludeTest/GraphicsEngineOpenGL/EngineFactoryOpenGLH_test.cpp @@ -0,0 +1,35 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * 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 + +#include "DiligentCore/Graphics/GraphicsEngineOpenGL/interface/EngineFactoryOpenGL.h" diff --git a/Tests/IncludeTest/GraphicsEngineOpenGL/FenceGLH_test .cpp b/Tests/IncludeTest/GraphicsEngineOpenGL/FenceGLH_test .cpp new file mode 100644 index 00000000..5c412e64 --- /dev/null +++ b/Tests/IncludeTest/GraphicsEngineOpenGL/FenceGLH_test .cpp @@ -0,0 +1,25 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +typedef unsigned int GLuint; +#include "DiligentCore/Graphics/GraphicsEngineOpenGL/interface/FenceGL.h" diff --git a/Tests/IncludeTest/GraphicsEngineOpenGL/PipelineStateGLH_test.cpp b/Tests/IncludeTest/GraphicsEngineOpenGL/PipelineStateGLH_test.cpp new file mode 100644 index 00000000..6a49ef62 --- /dev/null +++ b/Tests/IncludeTest/GraphicsEngineOpenGL/PipelineStateGLH_test.cpp @@ -0,0 +1,24 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "DiligentCore/Graphics/GraphicsEngineOpenGL/interface/PipelineStateGL.h" diff --git a/Tests/IncludeTest/GraphicsEngineOpenGL/RenderDeviceGL_test.cpp b/Tests/IncludeTest/GraphicsEngineOpenGL/RenderDeviceGL_test.cpp new file mode 100644 index 00000000..2c7388b0 --- /dev/null +++ b/Tests/IncludeTest/GraphicsEngineOpenGL/RenderDeviceGL_test.cpp @@ -0,0 +1,24 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "DiligentCore/Graphics/GraphicsEngineOpenGL/interface/RenderDeviceGL.h" diff --git a/Tests/IncludeTest/GraphicsEngineOpenGL/SamplerGLH_test.cpp b/Tests/IncludeTest/GraphicsEngineOpenGL/SamplerGLH_test.cpp new file mode 100644 index 00000000..18aa01fc --- /dev/null +++ b/Tests/IncludeTest/GraphicsEngineOpenGL/SamplerGLH_test.cpp @@ -0,0 +1,24 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "DiligentCore/Graphics/GraphicsEngineOpenGL/interface/SamplerGL.h" diff --git a/Tests/IncludeTest/GraphicsEngineOpenGL/ShaderGLH_test.cpp b/Tests/IncludeTest/GraphicsEngineOpenGL/ShaderGLH_test.cpp new file mode 100644 index 00000000..108d261b --- /dev/null +++ b/Tests/IncludeTest/GraphicsEngineOpenGL/ShaderGLH_test.cpp @@ -0,0 +1,24 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "DiligentCore/Graphics/GraphicsEngineOpenGL/interface/ShaderGL.h" diff --git a/Tests/IncludeTest/GraphicsEngineOpenGL/ShaderResourceBindingGLH_test.cpp b/Tests/IncludeTest/GraphicsEngineOpenGL/ShaderResourceBindingGLH_test.cpp new file mode 100644 index 00000000..6bc1f230 --- /dev/null +++ b/Tests/IncludeTest/GraphicsEngineOpenGL/ShaderResourceBindingGLH_test.cpp @@ -0,0 +1,23 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ +#include "DiligentCore/Graphics/GraphicsEngineOpenGL/interface/ShaderResourceBindingGL.h" diff --git a/Tests/IncludeTest/GraphicsEngineOpenGL/SwapChainGLH_test.cpp b/Tests/IncludeTest/GraphicsEngineOpenGL/SwapChainGLH_test.cpp new file mode 100644 index 00000000..b8d338b0 --- /dev/null +++ b/Tests/IncludeTest/GraphicsEngineOpenGL/SwapChainGLH_test.cpp @@ -0,0 +1,24 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ +typedef unsigned int GLuint; +#include "DiligentCore/Graphics/GraphicsEngineOpenGL/interface/SwapChainGL.h" \ No newline at end of file diff --git a/Tests/IncludeTest/GraphicsEngineOpenGL/TextureGLH_test.cpp b/Tests/IncludeTest/GraphicsEngineOpenGL/TextureGLH_test.cpp new file mode 100644 index 00000000..2c4670bc --- /dev/null +++ b/Tests/IncludeTest/GraphicsEngineOpenGL/TextureGLH_test.cpp @@ -0,0 +1,25 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ +typedef unsigned int GLuint; +typedef unsigned int GLenum; +#include "DiligentCore/Graphics/GraphicsEngineOpenGL/interface/TextureGL.h" diff --git a/Tests/IncludeTest/GraphicsEngineOpenGL/TextureViewGLH_test.cpp b/Tests/IncludeTest/GraphicsEngineOpenGL/TextureViewGLH_test.cpp new file mode 100644 index 00000000..dc7bcd2c --- /dev/null +++ b/Tests/IncludeTest/GraphicsEngineOpenGL/TextureViewGLH_test.cpp @@ -0,0 +1,24 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "DiligentCore/Graphics/GraphicsEngineOpenGL/interface/TextureViewGL.h" diff --git a/Tests/IncludeTest/GraphicsEngineVk/BufferViewVkH_test.cpp b/Tests/IncludeTest/GraphicsEngineVk/BufferViewVkH_test.cpp new file mode 100644 index 00000000..1e419e60 --- /dev/null +++ b/Tests/IncludeTest/GraphicsEngineVk/BufferViewVkH_test.cpp @@ -0,0 +1,25 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "DiligentCore/ThirdParty/vulkan/vulkan.h" +#include "DiligentCore/Graphics/GraphicsEngineVulkan/interface/BufferViewVk.h" diff --git a/Tests/IncludeTest/GraphicsEngineVk/BufferVkH_test.cpp b/Tests/IncludeTest/GraphicsEngineVk/BufferVkH_test.cpp new file mode 100644 index 00000000..cc0668a2 --- /dev/null +++ b/Tests/IncludeTest/GraphicsEngineVk/BufferVkH_test.cpp @@ -0,0 +1,25 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "DiligentCore/ThirdParty/vulkan/vulkan.h" +#include "DiligentCore/Graphics/GraphicsEngineVulkan/interface/BufferVk.h" diff --git a/Tests/IncludeTest/GraphicsEngineVk/CommandQueueVkH_test.cpp b/Tests/IncludeTest/GraphicsEngineVk/CommandQueueVkH_test.cpp new file mode 100644 index 00000000..092d564a --- /dev/null +++ b/Tests/IncludeTest/GraphicsEngineVk/CommandQueueVkH_test.cpp @@ -0,0 +1,25 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "DiligentCore/ThirdParty/vulkan/vulkan.h" +#include "DiligentCore/Graphics/GraphicsEngineVulkan/interface/CommandQueueVk.h" diff --git a/Tests/IncludeTest/GraphicsEngineVk/DeviceContextVkH_test.cpp b/Tests/IncludeTest/GraphicsEngineVk/DeviceContextVkH_test.cpp new file mode 100644 index 00000000..b1f66961 --- /dev/null +++ b/Tests/IncludeTest/GraphicsEngineVk/DeviceContextVkH_test.cpp @@ -0,0 +1,25 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "DiligentCore/ThirdParty/vulkan/vulkan.h" +#include "DiligentCore/Graphics/GraphicsEngineVulkan/interface/DeviceContextVk.h" diff --git a/Tests/IncludeTest/GraphicsEngineVk/EngineFactoryVkH_test.cpp b/Tests/IncludeTest/GraphicsEngineVk/EngineFactoryVkH_test.cpp new file mode 100644 index 00000000..9d34cb47 --- /dev/null +++ b/Tests/IncludeTest/GraphicsEngineVk/EngineFactoryVkH_test.cpp @@ -0,0 +1,35 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * 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" diff --git a/Tests/IncludeTest/GraphicsEngineVk/FenceVkH_test.cpp b/Tests/IncludeTest/GraphicsEngineVk/FenceVkH_test.cpp new file mode 100644 index 00000000..7b943c2a --- /dev/null +++ b/Tests/IncludeTest/GraphicsEngineVk/FenceVkH_test.cpp @@ -0,0 +1,25 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "DiligentCore/ThirdParty/vulkan/vulkan.h" +#include "DiligentCore/Graphics/GraphicsEngineVulkan/interface/FenceVk.h" diff --git a/Tests/IncludeTest/GraphicsEngineVk/PipelineStateVkH_test.cpp b/Tests/IncludeTest/GraphicsEngineVk/PipelineStateVkH_test.cpp new file mode 100644 index 00000000..19d45e6e --- /dev/null +++ b/Tests/IncludeTest/GraphicsEngineVk/PipelineStateVkH_test.cpp @@ -0,0 +1,25 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "DiligentCore/ThirdParty/vulkan/vulkan.h" +#include "DiligentCore/Graphics/GraphicsEngineVulkan/interface/PipelineStateVk.h" diff --git a/Tests/IncludeTest/GraphicsEngineVk/RenderDeviceVkH_test.cpp b/Tests/IncludeTest/GraphicsEngineVk/RenderDeviceVkH_test.cpp new file mode 100644 index 00000000..c4faac67 --- /dev/null +++ b/Tests/IncludeTest/GraphicsEngineVk/RenderDeviceVkH_test.cpp @@ -0,0 +1,25 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "DiligentCore/ThirdParty/vulkan/vulkan.h" +#include "DiligentCore/Graphics/GraphicsEngineVulkan/interface/RenderDeviceVk.h" diff --git a/Tests/IncludeTest/GraphicsEngineVk/SamplerVkH_test.cpp b/Tests/IncludeTest/GraphicsEngineVk/SamplerVkH_test.cpp new file mode 100644 index 00000000..60640a34 --- /dev/null +++ b/Tests/IncludeTest/GraphicsEngineVk/SamplerVkH_test.cpp @@ -0,0 +1,25 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "DiligentCore/ThirdParty/vulkan/vulkan.h" +#include "DiligentCore/Graphics/GraphicsEngineVulkan/interface/SamplerVk.h" diff --git a/Tests/IncludeTest/GraphicsEngineVk/ShaderResourceBindingVkH_test.cpp b/Tests/IncludeTest/GraphicsEngineVk/ShaderResourceBindingVkH_test.cpp new file mode 100644 index 00000000..0d38447c --- /dev/null +++ b/Tests/IncludeTest/GraphicsEngineVk/ShaderResourceBindingVkH_test.cpp @@ -0,0 +1,24 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ +#include "DiligentCore/ThirdParty/vulkan/vulkan.h" +#include "DiligentCore/Graphics/GraphicsEngineVulkan/interface/ShaderResourceBindingVk.h" diff --git a/Tests/IncludeTest/GraphicsEngineVk/ShaderVkH_test.cpp b/Tests/IncludeTest/GraphicsEngineVk/ShaderVkH_test.cpp new file mode 100644 index 00000000..10a06cb0 --- /dev/null +++ b/Tests/IncludeTest/GraphicsEngineVk/ShaderVkH_test.cpp @@ -0,0 +1,24 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ +#include "DiligentCore/ThirdParty/vulkan/vulkan.h" +#include "DiligentCore/Graphics/GraphicsEngineVulkan/interface/ShaderVk.h" diff --git a/Tests/IncludeTest/GraphicsEngineVk/SwapChainVkH_test.cpp b/Tests/IncludeTest/GraphicsEngineVk/SwapChainVkH_test.cpp new file mode 100644 index 00000000..b42adc73 --- /dev/null +++ b/Tests/IncludeTest/GraphicsEngineVk/SwapChainVkH_test.cpp @@ -0,0 +1,24 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * 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 diff --git a/Tests/IncludeTest/GraphicsEngineVk/TextureViewVkH_test.cpp b/Tests/IncludeTest/GraphicsEngineVk/TextureViewVkH_test.cpp new file mode 100644 index 00000000..cf611200 --- /dev/null +++ b/Tests/IncludeTest/GraphicsEngineVk/TextureViewVkH_test.cpp @@ -0,0 +1,25 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "DiligentCore/ThirdParty/vulkan/vulkan.h" +#include "DiligentCore/Graphics/GraphicsEngineVulkan/interface/TextureViewVk.h" diff --git a/Tests/IncludeTest/GraphicsEngineVk/TextureVkH_test.cpp b/Tests/IncludeTest/GraphicsEngineVk/TextureVkH_test.cpp new file mode 100644 index 00000000..2ac5dffc --- /dev/null +++ b/Tests/IncludeTest/GraphicsEngineVk/TextureVkH_test.cpp @@ -0,0 +1,25 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "DiligentCore/ThirdParty/vulkan/vulkan.h" +#include "DiligentCore/Graphics/GraphicsEngineVulkan/interface/TextureVk.h" diff --git a/Tests/IncludeTest/GraphicsTools/CommonlyUsedStatesH_test.cpp b/Tests/IncludeTest/GraphicsTools/CommonlyUsedStatesH_test.cpp new file mode 100644 index 00000000..da1ecbd5 --- /dev/null +++ b/Tests/IncludeTest/GraphicsTools/CommonlyUsedStatesH_test.cpp @@ -0,0 +1,24 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "DiligentCore/Graphics/GraphicsTools/include/CommonlyUsedStates.h" diff --git a/Tests/IncludeTest/GraphicsTools/GraphicsUtilitiesH_test.cpp b/Tests/IncludeTest/GraphicsTools/GraphicsUtilitiesH_test.cpp new file mode 100644 index 00000000..de3396e2 --- /dev/null +++ b/Tests/IncludeTest/GraphicsTools/GraphicsUtilitiesH_test.cpp @@ -0,0 +1,24 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "DiligentCore/Graphics/GraphicsTools/include/GraphicsUtilities.h" diff --git a/Tests/IncludeTest/GraphicsTools/ShaderMacroHelperH_test.cpp b/Tests/IncludeTest/GraphicsTools/ShaderMacroHelperH_test.cpp new file mode 100644 index 00000000..acfeed8d --- /dev/null +++ b/Tests/IncludeTest/GraphicsTools/ShaderMacroHelperH_test.cpp @@ -0,0 +1,24 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "DiligentCore/Graphics/GraphicsTools/include/ShaderMacroHelper.h" diff --git a/Tests/IncludeTest/GraphicsTools/TextureUploaderBaseH_test.cpp b/Tests/IncludeTest/GraphicsTools/TextureUploaderBaseH_test.cpp new file mode 100644 index 00000000..82e1df06 --- /dev/null +++ b/Tests/IncludeTest/GraphicsTools/TextureUploaderBaseH_test.cpp @@ -0,0 +1,24 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "DiligentCore/Graphics/GraphicsTools/include/TextureUploaderBase.h" diff --git a/Tests/IncludeTest/GraphicsTools/TextureUploaderD3D11H_test.cpp b/Tests/IncludeTest/GraphicsTools/TextureUploaderD3D11H_test.cpp new file mode 100644 index 00000000..b2b8e97b --- /dev/null +++ b/Tests/IncludeTest/GraphicsTools/TextureUploaderD3D11H_test.cpp @@ -0,0 +1,26 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#if D3D11_SUPPORTED +# include "DiligentCore/Graphics/GraphicsTools/include/TextureUploaderD3D11.h" +#endif diff --git a/Tests/IncludeTest/GraphicsTools/TextureUploaderD3D12_VkH_test.cpp b/Tests/IncludeTest/GraphicsTools/TextureUploaderD3D12_VkH_test.cpp new file mode 100644 index 00000000..b218d340 --- /dev/null +++ b/Tests/IncludeTest/GraphicsTools/TextureUploaderD3D12_VkH_test.cpp @@ -0,0 +1,26 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#if D3D12_SUPPORTED +# include "DiligentCore/Graphics/GraphicsTools/include/TextureUploaderD3D12_Vk.h" +#endif \ No newline at end of file diff --git a/Tests/IncludeTest/GraphicsTools/TextureUploaderGLH_test.cpp b/Tests/IncludeTest/GraphicsTools/TextureUploaderGLH_test.cpp new file mode 100644 index 00000000..943609ca --- /dev/null +++ b/Tests/IncludeTest/GraphicsTools/TextureUploaderGLH_test.cpp @@ -0,0 +1,26 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#if GL_SUPPORTED || GLES_SUPPORTED +# include "DiligentCore/Graphics/GraphicsTools/include/TextureUploaderGL.h" +#endif \ No newline at end of file diff --git a/Tests/IncludeTest/GraphicsTools/TextureUploaderH_test.cpp b/Tests/IncludeTest/GraphicsTools/TextureUploaderH_test.cpp new file mode 100644 index 00000000..dfc192be --- /dev/null +++ b/Tests/IncludeTest/GraphicsTools/TextureUploaderH_test.cpp @@ -0,0 +1,24 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "DiligentCore/Graphics/GraphicsTools/include/TextureUploader.h" diff --git a/Tests/IncludeTest/Platforms/AtomicsH_test.cpp b/Tests/IncludeTest/Platforms/AtomicsH_test.cpp new file mode 100644 index 00000000..03493fce --- /dev/null +++ b/Tests/IncludeTest/Platforms/AtomicsH_test.cpp @@ -0,0 +1,24 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "DiligentCore/Platforms/interface/Atomics.h" diff --git a/Tests/IncludeTest/Platforms/FileSystemH_test.cpp b/Tests/IncludeTest/Platforms/FileSystemH_test.cpp new file mode 100644 index 00000000..4c615712 --- /dev/null +++ b/Tests/IncludeTest/Platforms/FileSystemH_test.cpp @@ -0,0 +1,24 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "DiligentCore/Platforms/interface/FileSystem.h" diff --git a/Tests/IncludeTest/Platforms/PlatformDebugH_test.cpp b/Tests/IncludeTest/Platforms/PlatformDebugH_test.cpp new file mode 100644 index 00000000..6a561070 --- /dev/null +++ b/Tests/IncludeTest/Platforms/PlatformDebugH_test.cpp @@ -0,0 +1,24 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "DiligentCore/Platforms/interface/PlatformDebug.h" diff --git a/Tests/IncludeTest/Platforms/PlatformDefinitionsH_test.cpp b/Tests/IncludeTest/Platforms/PlatformDefinitionsH_test.cpp new file mode 100644 index 00000000..148fa5e3 --- /dev/null +++ b/Tests/IncludeTest/Platforms/PlatformDefinitionsH_test.cpp @@ -0,0 +1,24 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "DiligentCore/Platforms/interface/PlatformDefinitions.h" diff --git a/Tests/IncludeTest/Platforms/PlatformMiscH_test.cpp b/Tests/IncludeTest/Platforms/PlatformMiscH_test.cpp new file mode 100644 index 00000000..654b5e88 --- /dev/null +++ b/Tests/IncludeTest/Platforms/PlatformMiscH_test.cpp @@ -0,0 +1,24 @@ +/* Copyright 2019 Diligent Graphics LLC + * + * 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 + * + * 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 OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent 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 + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "DiligentCore/Platforms/interface/PlatformMisc.h" diff --git a/UnitTests/CMakeLists.txt b/UnitTests/CMakeLists.txt deleted file mode 100644 index 4a867e45..00000000 --- a/UnitTests/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required (VERSION 3.6) - -if(TARGET gtest) - add_subdirectory(DiligentCoreTest) - add_subdirectory(DiligentCoreAPITest) -endif() -add_subdirectory(IncludeTest) diff --git a/UnitTests/DiligentCoreAPITest/CMakeLists.txt b/UnitTests/DiligentCoreAPITest/CMakeLists.txt deleted file mode 100644 index f0c2673c..00000000 --- a/UnitTests/DiligentCoreAPITest/CMakeLists.txt +++ /dev/null @@ -1,130 +0,0 @@ -cmake_minimum_required (VERSION 3.6) - -project(DiligentCoreAPITest) - -file(GLOB COMMON_SOURCE LIST_DIRECTORIES false src/*) -file(GLOB COMMON_INCLUDE LIST_DIRECTORIES false include/*) -file(GLOB_RECURSE SHADERS LIST_DIRECTORIES false assets/shaders/*.*) - -set_source_files_properties(${SHADERS} PROPERTIES VS_TOOL_OVERRIDE "None") - -set(SOURCE ${COMMON_SOURCE}) -set(INCLUDE ${COMMON_INCLUDE}) - -if(NOT GL_SUPPORTED AND NOT GLES_SUPPORTED) - list(REMOVE_ITEM SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/src/HLSL2GLSLConverterTest.cpp) - list(REMOVE_ITEM SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/src/CreateObjFromNativeResGL.cpp) - - list(REMOVE_ITEM INCLUDE ${CMAKE_CURRENT_SOURCE_DIR}/include/CreateObjFromNativeResGL.h) -endif() - -if(NOT D3D11_SUPPORTED) - list(REMOVE_ITEM SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/src/CreateObjFromNativeResD3D11.cpp) - list(REMOVE_ITEM INCLUDE ${CMAKE_CURRENT_SOURCE_DIR}/include/CreateObjFromNativeResD3D11.h) -endif() - -if(NOT D3D12_SUPPORTED) - list(REMOVE_ITEM SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/src/CreateObjFromNativeResD3D12.cpp) - list(REMOVE_ITEM INCLUDE ${CMAKE_CURRENT_SOURCE_DIR}/include/CreateObjFromNativeResD3D12.h) -endif() - -if(NOT VULKAN_SUPPORTED) - list(REMOVE_ITEM SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/src/CreateObjFromNativeResVK.cpp) - list(REMOVE_ITEM INCLUDE ${CMAKE_CURRENT_SOURCE_DIR}/include/CreateObjFromNativeResVK.h) -endif() - -if(PLATFORM_WIN32) - file(GLOB SOURCE_WIN32 LIST_DIRECTORIES false src/Win32/*) - list(APPEND SOURCE ${SOURCE_WIN32}) -endif() - -if(D3D11_SUPPORTED) - file(GLOB D3D11_SOURCE LIST_DIRECTORIES false src/D3D11/*) - file(GLOB D3D11_INCLUDE LIST_DIRECTORIES false include/D3D11/*) - list(APPEND INCLUDE ${D3D11_INCLUDE}) - list(APPEND SOURCE ${D3D11_SOURCE}) -endif() - -if(D3D12_SUPPORTED) - file(GLOB D3D12_SOURCE LIST_DIRECTORIES false src/D3D12/*) - file(GLOB D3D12_INCLUDE LIST_DIRECTORIES false include/D3D12/*) - list(APPEND INCLUDE ${D3D12_INCLUDE}) - list(APPEND SOURCE ${D3D12_SOURCE}) -endif() - -if(VULKAN_SUPPORTED) - file(GLOB VK_SOURCE LIST_DIRECTORIES false src/Vulkan/*) - file(GLOB VK_INCLUDE LIST_DIRECTORIES false include/Vulkan/*) - list(APPEND INCLUDE ${VK_INCLUDE}) - list(APPEND SOURCE ${VK_SOURCE}) -endif() - -if(GL_SUPPORTED OR GLES_SUPPORTED) - file(GLOB GL_SOURCE LIST_DIRECTORIES false src/GL/*) - file(GLOB GL_INCLUDE LIST_DIRECTORIES false include/GL/*) - list(APPEND INCLUDE ${GL_INCLUDE}) - list(APPEND SOURCE ${GL_SOURCE}) -endif() - -add_executable(DiligentCoreAPITest ${SOURCE} ${INCLUDE} ${SHADERS}) -set_common_target_properties(DiligentCoreAPITest) - -get_supported_backends(ENGINE_LIBRARIES) - -target_link_libraries(DiligentCoreAPITest -PRIVATE - gtest - Diligent-BuildSettings - Diligent-TargetPlatform - Diligent-GraphicsAccessories - Diligent-Common - Diligent-GraphicsTools - ${ENGINE_LIBRARIES} -) - -if(D3D11_SUPPORTED OR D3D12_SUPPORTED) - target_link_libraries(DiligentCoreAPITest PRIVATE d3dcompiler.lib) -endif() - -if(GL_SUPPORTED OR GLES_SUPPORTED) - target_link_libraries(DiligentCoreAPITest PRIVATE Diligent-HLSL2GLSLConverterLib) - - if(PLATFORM_WIN32) - target_link_libraries(DiligentCoreAPITest PRIVATE glew-static opengl32.lib) - elseif(PLATFORM_LINUX) - target_link_libraries(DiligentCoreAPITest PRIVATE glew-static) - elseif(PLATFORM_MACOS) - find_package(OpenGL REQUIRED) - target_link_libraries(DiligentCoreAPITest PRIVATE glew-static ${OPENGL_LIBRARY}) - else() - message(FATAL_ERROR "Unsupported platform") - endif() - -endif() - -if(VULKAN_SUPPORTED) - target_link_libraries(DiligentCoreAPITest PRIVATE Diligent-GLSLTools) - target_include_directories(DiligentCoreAPITest PRIVATE ../../ThirdParty) -endif() - -target_include_directories(DiligentCoreAPITest -PRIVATE - include -) - - -set_target_properties(DiligentCoreAPITest -PROPERTIES - VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/assets" -) - -if(PLATFORM_WIN32) - copy_required_dlls(DiligentCoreAPITest) -endif() - - -source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${SOURCE} ${INCLUDE} ${SHADERS}) - -set_target_properties(DiligentCoreAPITest PROPERTIES - FOLDER "DiligentCore/Tests" -) diff --git a/UnitTests/DiligentCoreAPITest/assets/shaders/HLSL2GLSLConverter/CS_RWBuff.hlsl b/UnitTests/DiligentCoreAPITest/assets/shaders/HLSL2GLSLConverter/CS_RWBuff.hlsl deleted file mode 100644 index fdfdb2ec..00000000 --- a/UnitTests/DiligentCoreAPITest/assets/shaders/HLSL2GLSLConverter/CS_RWBuff.hlsl +++ /dev/null @@ -1,81 +0,0 @@ -RWBuffer TexBuff_F; -RWBuffer TexBuff_I; -RWBuffer TexBuff_U; - -struct StorageBufferStruct -{ - float4 Data; -}; - -RWStructuredBuffer RWStructBuff0; -RWStructuredBuffer RWStructBuff1; -RWStructuredBuffer RWStructBuff2; - -void TestGetDimensions() -{ - //RWBuffer - { - uint uWidth; - int iWidth; - float fWidth; - TexBuff_F.GetDimensions(uWidth); - //TexBuff_I.GetDimensions(iWidth); - //TexBuff_U.GetDimensions(fWidth); - } -} - - -void TestLoad() -{ - int4 Location = int4(2, 5, 1, 10); - - //Buffer - { - TexBuff_F.Load(Location.x); - TexBuff_I.Load(Location.x); - TexBuff_U.Load(Location.x); - } - StorageBufferStruct Data0 = RWStructBuff0[Location.x]; - StorageBufferStruct Data1 = RWStructBuff1[Location.y]; - StorageBufferStruct Data3 = RWStructBuff2[Location.w]; -} - - - -void TestStore() -{ - int4 Location = int4(2, 5, 1, 10); - - //Buffer - { - TexBuff_F[Location.x] = 1.0; - TexBuff_I[Location.x] = int2(1,2); - TexBuff_U[Location.x] = uint4(1,2,3,4); - } - StorageBufferStruct Data0; - Data0.Data = float4(0.0, 1.0, 2.0, 3.0); - RWStructBuff0[Location.x] = Data0; - RWStructBuff1[Location.z] = Data0; - RWStructBuff2[Location.w] = Data0; - -} - -struct CSInputSubstr -{ - uint3 DTid : SV_DispatchThreadID; -}; -struct CSInput -{ - uint GroupInd : SV_GroupIndex; - CSInputSubstr substr; -}; - -[numthreads(2,4,8)] -void TestCS(CSInput In, - uint3 Gid : SV_GroupID, - uint3 GTid : SV_GroupThreadID) -{ - TestGetDimensions(); - TestLoad(); - TestStore(); -} diff --git a/UnitTests/DiligentCoreAPITest/assets/shaders/HLSL2GLSLConverter/CS_RWTex1D.hlsl b/UnitTests/DiligentCoreAPITest/assets/shaders/HLSL2GLSLConverter/CS_RWTex1D.hlsl deleted file mode 100644 index 306ec599..00000000 --- a/UnitTests/DiligentCoreAPITest/assets/shaders/HLSL2GLSLConverter/CS_RWTex1D.hlsl +++ /dev/null @@ -1,134 +0,0 @@ -#include "IncludeTest.h" -// # include <- fix commented include - - -//#define TEXTURE2D Texture2D <- Macros do not work currently -//TEXTURE2D MacroTex2D; - -/******//* /* /**** / */ -void EmptyFunc(){}cbuffer cbTest1{int a;}cbuffer cbTest2{int b;}/*comment -test - -*/cbuffer cbTest3{int c;}//Single line comment -cbuffer cbTest4{int d;} - -cbuffer cbTest5 -{ - float4 e; -} - -cbuffer cbTest6 -{ - float4 f; -}; - -int cbuffer_fake; -int fakecbuffer; - -RWTexture1DTex1D_F1; -RWTexture1DTex1D_I; -RWTexture1DTex1D_U; - -RWTexture1DArray Tex1D_F_A; -RWTexture1DArray Tex1D_I_A; -RWTexture1DArray Tex1D_U_A; - -void TestGetDimensions() -{ - // RWTexture1D - { - uint uWidth; - float fWidth; - int iWidth; - Tex1D_F1.GetDimensions(uWidth); - Tex1D_I.GetDimensions( uWidth); - Tex1D_U.GetDimensions( uWidth ); - - Tex1D_F1.GetDimensions(fWidth); - Tex1D_I.GetDimensions( fWidth); - Tex1D_U.GetDimensions( fWidth ); - - Tex1D_F1.GetDimensions(iWidth); - Tex1D_I.GetDimensions( iWidth); - Tex1D_U.GetDimensions( iWidth ); - } - - // RWTexture1DArray - { - uint uWidth, uElems; - int iWidth, iElems; - float fWidth, fElems; - Tex1D_F_A.GetDimensions(uWidth, uElems); - Tex1D_U_A.GetDimensions( uWidth, uElems); - Tex1D_I_A.GetDimensions( uWidth , uElems ); - - Tex1D_F_A.GetDimensions(iWidth, iElems); - Tex1D_U_A.GetDimensions( iWidth, iElems); - Tex1D_I_A.GetDimensions( iWidth , iElems ); - - Tex1D_F_A.GetDimensions(fWidth, fElems); - Tex1D_U_A.GetDimensions( fWidth, fElems); - Tex1D_I_A.GetDimensions( fWidth , fElems ); - } -} - -void TestLoad() -{ - int4 Location = int4(2, 5, 1, 10); - - // Texture1D - { - float f = Tex1D_F1.Load(Location.x); - int2 i2 = Tex1D_I.Load(Location.x).xy; - uint4 u4 = Tex1D_U.Load(Location.x); - } - - // Texture1DArray - { - float f = Tex1D_F_A.Load(Location.xy); - uint4 u4 = Tex1D_U_A.Load(Location.xy); - int2 i2 = Tex1D_I_A.Load(Location.xy); - } -} - - - -void TestStore() -{ - int4 Location = int4(2, 5, 1, 10); - - // Texture1D - { - Tex1D_F1[Location.x] = 1.0; - Tex1D_I[ Location.x] = int2(3,6); - Tex1D_U[ Location.x ] = uint4(0,4,7,8); - } - - // Texture1DArray - { - Tex1D_F_A[Location.xy] = 3.5; - Tex1D_U_A[ Location.xy] = uint4(2,4,2,5); - Tex1D_I_A[Location.xy ] = int2( 13, 19); - } -} - -struct CSInputSubstr -{ - uint3 DTid : SV_DispatchThreadID; -}; - -struct CSInput -{ - uint GroupInd : SV_GroupIndex; - CSInputSubstr substr; -}; - -[numthreads(2,4,8)] -void TestCS(CSInput In, - uint3 Gid : SV_GroupID, - uint3 GTid : SV_GroupThreadID) -{ - TestGetDimensions(); - TestLoad(); - TestStore(); -} diff --git a/UnitTests/DiligentCoreAPITest/assets/shaders/HLSL2GLSLConverter/CS_RWTex2D_1.hlsl b/UnitTests/DiligentCoreAPITest/assets/shaders/HLSL2GLSLConverter/CS_RWTex2D_1.hlsl deleted file mode 100644 index a60f8413..00000000 --- a/UnitTests/DiligentCoreAPITest/assets/shaders/HLSL2GLSLConverter/CS_RWTex2D_1.hlsl +++ /dev/null @@ -1,216 +0,0 @@ -#include "IncludeTest.h" -// # include <- fix commented include - - -//#define TEXTURE2D Texture2D <- Macros do not work currently -//TEXTURE2D MacroTex2D; - -/******//* /* /**** / */ -void EmptyFunc(){}cbuffer cbTest1{int a;}cbuffer cbTest2{int b;}/*comment -test - -*/cbuffer cbTest3{int c;}//Single line comment -cbuffer cbTest4{int d;} - -cbuffer cbTest5 -{ - float4 e; -} - -cbuffer cbTest6 -{ - float4 f; -}; - -int cbuffer_fake; -int fakecbuffer; - -RWTexture2DTex2D_F1; -RWTexture2DTex2D_F2[2],Tex2D_F3,/*cmt*/Tex2D_F4, Tex2D_F5; -RWTexture2DTex2D_I; -RWTexture2DTex2D_U; - - -int GlobalIntVar;Texture2D Tex2D_Test1;Texture2D Tex2D_Test2;/*Comment* / *//* /** Comment2*/Texture2D Tex2D_Test3 /*Cmnt*/, -// Comment -Tex2D_Test4 -; - -Texture2D Tex2D_M1, Tex2D_M2; - -groupshared float4 g_f4TestSharedArr[10]; -groupshared int4 g_i4TestSharedArr[10]; -groupshared uint4 g_u4TestSharedArr[10]; -groupshared float4 g_f4TestSharedVar; -groupshared int4 g_i4TestSharedVar; -groupshared uint4 g_u4TestSharedVar; - - -void TestGetDimensions() -{ - //RWTexture2D - { - uint uWidth, uHeight; - int iWidth, iHeight; - float fWidth, fHeight; - Tex2D_F1.GetDimensions(uWidth, uHeight); - Tex2D_F3.GetDimensions(uWidth, uHeight); - Tex2D_F4.GetDimensions(uWidth, uHeight); - Tex2D_F2[0].GetDimensions( uWidth, uHeight); - Tex2D_I.GetDimensions (uWidth, uHeight ); - Tex2D_U.GetDimensions ( uWidth, uHeight ); - - Tex2D_F1.GetDimensions(iWidth, iHeight); - Tex2D_F2[0].GetDimensions( iWidth, iHeight); - Tex2D_I.GetDimensions (iWidth, iHeight ); - Tex2D_U.GetDimensions ( iWidth, iHeight ); - - Tex2D_F1.GetDimensions(fWidth, fHeight); - Tex2D_F2[0].GetDimensions( fWidth, fHeight); - Tex2D_I.GetDimensions (fWidth, fHeight ); - Tex2D_U.GetDimensions ( fWidth, fHeight ); - } -} - - -void TestLoad() -{ - int4 Location = int4(2, 5, 1, 10); - - //Texture2D - { - float f = Tex2D_F1.Load(Location.xy); - f = Tex2D_F1.Load(Tex2D_I.Load(Location.xy) + Tex2D_I.Load(Location.xy).yx); - int2 i2 = Tex2D_I.Load(Location.xy); - uint4 u4= Tex2D_U.Load(Location.xy).xyzw; - } - -} - - - -void TestStore() -{ - int4 Location = int4(2, 5, 1, 10); - - //Texture2D - { - Tex2D_F1[Location.xy] = 10.0; - Tex2D_F1[Tex2D_I.Load(Location.xy).xy + Tex2D_I.Load(Location.xy).xy] = 20.0; - Tex2D_I[Location.xy] = int2( 43, 23); - Tex2D_U[Location.xy] = uint4( 3,7,1,7); - } -} - - -/* -void TestImageArgs1(RWTexture2D in_RWTex, int2 Location) -{ - int Width, Height; - in_RWTex.GetDimensions (Width, Height ); - in_RWTex[Location] = Width; - InterlockedAdd(in_RWTex[Location], 3); - int i = in_RWTex.Load(Location.xy); -} - -void TestImageArgs2(RWTexture3D in_RWTex) -{ - int Width, Height, Depth; - in_RWTex.GetDimensions (Width, Height, Depth ); - float f = in_RWTex.Load(int3(10,11,23)); - in_RWTex[int3(1,2,3)] = float4(10.0, 25.0, 26.0, 27.0); -} -*/ - - - -int2 GetCoords( uint x, uint y ) -{ - return int2(x, y); -} - -struct CSInputSubstr -{ - uint3 DTid : SV_DispatchThreadID; -}; -struct CSInput -{ - uint GroupInd : SV_GroupIndex; - CSInputSubstr substr; -}; - -[numthreads(2,4,8)] -void TestCS(CSInput In, - uint3 Gid : SV_GroupID, - uint3 GTid : SV_GroupThreadID) -{ - TestGetDimensions(); - TestLoad(); - TestStore(); - - uint uOldVal; - int iOldVal; - - if( GTid.y == 0u ) - { - g_i4TestSharedVar = int4(0, 0, 0, 0); - g_u4TestSharedVar = uint4(0u, 0u, 0u, 0u); - } - g_i4TestSharedArr[In.GroupInd] = int4(0, 0, 0, 0); - g_u4TestSharedArr[In.GroupInd] = uint4(0u, 0u, 0u, 0u); - - InterlockedAdd(g_i4TestSharedVar.x, 1); - InterlockedAdd(g_u4TestSharedVar.x, 1u); - InterlockedAdd(g_i4TestSharedArr[GTid.x].x, 1, iOldVal); - InterlockedAdd(g_u4TestSharedArr[Gid.x].x, 1u, uOldVal); - - InterlockedAnd(g_i4TestSharedVar.x, 1); - InterlockedAnd(g_u4TestSharedVar.x, 1u); - InterlockedAnd(g_i4TestSharedArr[GTid.x].x, 1, iOldVal); - InterlockedAnd(g_u4TestSharedArr[Gid.x].x, 1u, uOldVal); - - InterlockedOr(g_i4TestSharedVar.x, 1); - InterlockedOr(g_u4TestSharedVar.x, 1u); - InterlockedOr(g_i4TestSharedArr[GTid.x].x, 1, iOldVal); - InterlockedOr(g_u4TestSharedArr[Gid.x].x, 1u, uOldVal); - - InterlockedXor(g_i4TestSharedVar.x, 1); - InterlockedXor(g_u4TestSharedVar.x, 1u); - InterlockedXor(g_i4TestSharedArr[GTid.x].x, 1, iOldVal); - InterlockedXor(g_u4TestSharedArr[Gid.x].x, 1u, uOldVal); - - InterlockedMax(g_i4TestSharedVar.x, 1); - InterlockedMax(g_u4TestSharedVar.x, 1u); - InterlockedMax(g_i4TestSharedArr[GTid.x].x, 1, iOldVal); - InterlockedMax(g_u4TestSharedArr[Gid.x].x, 1u, uOldVal); - - InterlockedMin(g_i4TestSharedVar.x, 1); - InterlockedMin(g_u4TestSharedVar.x, 1u); - InterlockedMin(g_i4TestSharedArr[GTid.x].x, 1, iOldVal); - InterlockedMin(g_u4TestSharedArr[Gid.x].x, 1u, uOldVal); - - // There is actually no InterlockedExchange() with 2 arguments - //InterlockedExchange(g_i4TestSharedVar.x, 1); - //InterlockedExchange(g_u4TestSharedVar.x, 1u); - InterlockedExchange(g_i4TestSharedArr[GTid.x].x, 1, iOldVal); - InterlockedExchange(g_u4TestSharedArr[Gid.x].x, 1u, uOldVal); - - InterlockedCompareStore(g_i4TestSharedVar.x, 1, 10); - InterlockedCompareStore(g_u4TestSharedVar.x, 1u, 10u); - InterlockedCompareExchange(g_i4TestSharedArr[GTid.x].x, 1, 10, iOldVal); - InterlockedCompareExchange(g_u4TestSharedArr[Gid.x].x, 1u, 10u, uOldVal); - - //uint2 ui2Dim; - //g_tex2DTestUAV.GetDimensions(ui2Dim.x, ui2Dim.y); - //if( DTid.x >= ui2Dim.x || DTid.y >= ui2Dim.y )return; - - //float2 f2UV = float2(DTid.xy) / float2(ui2Dim); - //float DistFromCenter = length(f2UV - float2(0.5,0.5)); - //g_tex2DTestUAV[DTid.xy] = float4((1-DistFromCenter), abs(f2UV.x-0.5), abs(0.5-f2UV.y), 0); - GroupMemoryBarrier(); - GroupMemoryBarrierWithGroupSync(); - DeviceMemoryBarrier(); - DeviceMemoryBarrierWithGroupSync(); - AllMemoryBarrier(); - //AllMemoryBarrierWithGroupSync(); -} diff --git a/UnitTests/DiligentCoreAPITest/assets/shaders/HLSL2GLSLConverter/CS_RWTex2D_2.hlsl b/UnitTests/DiligentCoreAPITest/assets/shaders/HLSL2GLSLConverter/CS_RWTex2D_2.hlsl deleted file mode 100644 index bfaa4050..00000000 --- a/UnitTests/DiligentCoreAPITest/assets/shaders/HLSL2GLSLConverter/CS_RWTex2D_2.hlsl +++ /dev/null @@ -1,123 +0,0 @@ -RWTexture2DTex2D_I1; -RWTexture2DTex2D_U1; - -RWTexture2DArray Tex2D_F_A; -RWTexture2DArray Tex2D_I_A; -RWTexture2DArray Tex2D_U_A; - -RWTexture3D< float4/* -format -= -rgba32f -*/> Tex3D_F; -RWTexture3D< int /* format = r8i */> Tex3D_I; -RWTexture3D< uint2 /* format = rg8ui */> Tex3D_U; - -void TestGetDimensions() -{ - //RWTexture2DArray - { - uint uWidth, uHeight, uElems; - float fWidth, fHeight, fElems; - int iWidth, iHeight, iElems; - Tex2D_F_A.GetDimensions(uWidth,uHeight,uElems); - Tex2D_U_A.GetDimensions( uWidth, uHeight, uElems ); - Tex2D_I_A.GetDimensions (uWidth , uHeight , uElems ) ; - - Tex2D_F_A.GetDimensions(iWidth,iHeight,iElems); - Tex2D_U_A.GetDimensions( iWidth, iHeight, iElems ); - Tex2D_I_A.GetDimensions (iWidth , iHeight , iElems ) ; - - Tex2D_F_A.GetDimensions(fWidth,fHeight,fElems); - Tex2D_U_A.GetDimensions( fWidth, fHeight, fElems ); - Tex2D_I_A.GetDimensions (fWidth , fHeight , fElems ) ; - } - - //RWTexture3D - { - uint uWidth, uHeight, uDepth; - int iWidth, iHeight, iDepth; - float fWidth, fHeight, fDepth; - Tex3D_F.GetDimensions ( uWidth, uHeight, uDepth ); - Tex3D_U.GetDimensions(uWidth,uHeight,uDepth); - Tex3D_I.GetDimensions ( uWidth , uHeight , uDepth ); - - Tex3D_F.GetDimensions ( iWidth, iHeight, iDepth ); - Tex3D_U.GetDimensions(iWidth,iHeight,iDepth); - Tex3D_I.GetDimensions ( iWidth , iHeight , iDepth ); - - Tex3D_F.GetDimensions ( fWidth, fHeight, fDepth ); - Tex3D_U.GetDimensions(fWidth,fHeight,fDepth); - Tex3D_I.GetDimensions ( fWidth , fHeight , fDepth ); - } -} - - -void TestLoad() -{ - int4 Location = int4(2, 5, 1, 10); - - //Texture2DArray - { - float f = Tex2D_F_A.Load(Location.xyz); - uint4 u4 = Tex2D_U_A.Load(Location.xyz); - int2 i2 = Tex2D_I_A.Load(Location.xyz); - } - - //Texture3D - { - float4 f4 = Tex3D_F.Load(Location.xyz).xyzw; - uint2 u2 = Tex3D_U.Load(Location.xyz).xy; - int i = Tex3D_I.Load(Location.xyz); - } -} - - - -void TestStore() -{ - int4 Location = int4(2, 5, 1, 10); - - //Texture2DArray - { - Tex2D_F_A[Location.xyz] = 30.0; - Tex2D_U_A[Location.xyz] = uint4(0,5,7,87); - Tex2D_I_A[Location.xyz] = int2(-3, 5); - } - - //Texture3D - { - Tex3D_F[Location.xyz] = float4(10.0, 25.0, 26.0, 27.0); - Tex3D_U[Location.xyz] = uint2(0,6); - Tex3D_I[Location.xyz] = -5; - } -} - - -int2 GetCoords( uint x, uint y ) -{ - return int2(x, y); -} - -struct CSInputSubstr -{ - uint3 DTid : SV_DispatchThreadID; -}; -struct CSInput -{ - uint GroupInd : SV_GroupIndex; - CSInputSubstr substr; -}; - -[numthreads(2,4,8)] -void TestCS(CSInput In, - uint3 Gid : SV_GroupID, - uint3 GTid : SV_GroupThreadID) -{ - TestGetDimensions(); - TestLoad(); - TestStore(); -} diff --git a/UnitTests/DiligentCoreAPITest/assets/shaders/HLSL2GLSLConverter/IncludeTest.h b/UnitTests/DiligentCoreAPITest/assets/shaders/HLSL2GLSLConverter/IncludeTest.h deleted file mode 100644 index dd6128d5..00000000 --- a/UnitTests/DiligentCoreAPITest/assets/shaders/HLSL2GLSLConverter/IncludeTest.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef _INCLUDE_TEST_FXH_ -#define _INCLUDE_TEST_FXH_ - -#define PI (3.1415928f) - -struct SomeStruct -{ - float a; - int b; -}; - -#endif //_INCLUDE_TEST_FXH_ diff --git a/UnitTests/DiligentCoreAPITest/assets/shaders/HLSL2GLSLConverter/VS_PS.hlsl b/UnitTests/DiligentCoreAPITest/assets/shaders/HLSL2GLSLConverter/VS_PS.hlsl deleted file mode 100644 index 7560231d..00000000 --- a/UnitTests/DiligentCoreAPITest/assets/shaders/HLSL2GLSLConverter/VS_PS.hlsl +++ /dev/null @@ -1,1283 +0,0 @@ -#if defined(GL_ES) && (__VERSION__<=300) -# define GLES30 1 -#else -# define GLES30 0 -#endif - -/***//* Some comment * ** * * * / ** //// */ //Another comment -// -// Comment - -/* More *//*com*///ments/**/ -// -// - - -# include /*Comment*/ -// #include "NonExistingFile.h" - - -//#define TEXTURE2D Texture2D <- Macros do not work currently -//TEXTURE2D MacroTex2D; - -/******//* /* /**** / */ -void EmptyFunc(){}cbuffer cbTest1{int a;}cbuffer cbTest2{int b;}/*comment -test - -**/cbuffer cbTest3{int c;}//Single line comment -cbuffer cbTest4{int d;} - -cbuffer cbTest5 -{ - float4 e; -} - -cbuffer cbTest6 -{ - float4 f; -}; - -int cbuffer_fake; -int fakecbuffer; - -int GlobalIntVar;Texture2D Tex2D_Test1;Texture2D Tex2D_Test2;/*Comment* / *//* /** Comment2**/Texture2D Tex2D_Test3; - -Texture2D Tex2D_M1, Tex2D_M2; - -// Test texture declaration - -#ifndef GL_ES - -Texture1D Tex1D_F1; -Texture1DTex1D_F2; -Texture1DTex1D_I; -Texture1DTex1D_U; - -SamplerState Tex1D_F1_sampler; - -Texture1DArray Tex1D_F_A1; -Texture1DArray Tex1D_F_A2; -Texture1DArray Tex1D_I_A; -Texture1DArray Tex1D_U_A; - -SamplerState Tex1D_F_A1_sampler; - -Texture1D Tex1DS1; -Texture1DTex1DS2,Tex1DS3; -SamplerComparisonState Tex1DS1_sampler, Tex1DS2_sampler, TestCmpSamplerArr[2], Tex1DS3_sampler; - -Texture1DArray Tex1DAS1; -SamplerComparisonState Tex1DAS1_sampler, Tex1DAS2_sampler; -Texture1DArrayTex1DAS2; - -#endif - -Texture2D Tex2D_F1; -Texture2DTex2D_F3[2],Tex2D_F2,Tex2DS_F4,Tex2DS_F5; -Texture2DTex2D_F6; -Texture2DTex2D_I; -Texture2DTex2D_U; - -SamplerState Tex2D_F1_sampler,Tex2D_F6_sampler; -SamplerComparisonState DummySampler, Tex2DS_F4_sampler,Tex2DS_F5_sampler; - -Texture2DArray Tex2D_F_A1; -Texture2DArray Tex2D_F_A2; -Texture2DArray Tex2D_F_A3; -Texture2DArray Tex2D_I_A; -Texture2DArray Tex2D_U_A; - -SamplerState Tex2D_F_A1_sampler,Tex2D_F_A3_sampler; - -#if !GLES30 -Texture2DMS < float2 > Tex2DMS_F1; -Texture2DMS < float, 4 > Tex2DMS_F2; -Texture2DMS < int > Tex2DMS_I; -Texture2DMS < uint > Tex2DMS_U; -#endif - -#ifndef GL_ES -Texture2DMSArray < float3 > Tex2DMS_F_A1; -Texture2DMSArray < float, 4> Tex2DMS_F_A2; -Texture2DMSArray < int2 > Tex2DMS_I_A; -Texture2DMSArray < uint4 > Tex2DMS_U_A; -#endif - -Texture3D Tex3D_F1; -Texture3D< float4 > Tex3D_F2; -Texture3D< float > Tex3D_F3; -Texture3D< int > Tex3D_I; -Texture3D< uint2 > Tex3D_U; - -SamplerState Tex3D_F1_sampler; - -TextureCube TexC_F1; -TextureCube TexC_F2; -TextureCube TexC_I; -TextureCube TexC_U; - -SamplerState TexC_F1_sampler; - -#ifndef GL_ES -TextureCubeArray TexC_F_A1; -TextureCubeArray TexC_F_A2; -TextureCubeArray TexC_I_A; -TextureCubeArray TexC_U_A; - -SamplerState TexC_F_A1_sampler; -#endif - -Texture2D Tex2DS1; -SamplerComparisonState Tex2DS1_sampler; -Texture2DTex2DS2; -SamplerComparisonState Tex2DS2_sampler; - -Texture2DArray Tex2DAS1; -SamplerComparisonState Tex2DAS1_sampler; -Texture2DArrayTex2DAS2; -SamplerComparisonState Tex2DAS2_sampler; - -TextureCube TexCS1; -SamplerComparisonState TexCS1_sampler; -TextureCube< float > TexCS2; -SamplerComparisonState TexCS2_sampler; - -#ifndef GL_ES -TextureCubeArray TexCAS1; -SamplerComparisonState TexCAS1_sampler; -TextureCubeArray TexCAS2; -SamplerComparisonState TexCAS2_sampler; -#endif - -Buffer TexBuffer_F1; -BufferTexBuffer_F4; -BufferTexBuffer_I; -BufferTexBuffer_U; - -int intvar1;SamplerState Dummy;int intvar2; - -int Texture2D_fake, Texture2DArray_fake, fakeTexture2D, fakeTexture2DArray; -int Texture2DMS_fake; -int fakeTexture2DMS; -int Texture2DMSArray_fake; -int fakeTexture2DMSArray; -int Texture3D_fake; -int fakeTexture3D; -int TextureCube_fake, TextureCubeArray_fake; -int fakeTextureCube, fakeTextureCubeArray; -int SamplerState_fake; -int SamplerComparisonState_fake; -int fakeSamplerState; -int fakeSamplerComparisonState; -int Texture4D; -int Texture2d; -int TextureCub; -int Texture2DArr; -int Texture2DM; -int Texture2DMSArr; - -void TestGetDimensions() -{ -#ifndef GL_ES - // Texture1D - { - uint uWidth, uMipLevels; - int iWidth, iMipLevels; - float fWidth, fMipLevels; - Tex1D_F1.GetDimensions(uWidth); - Tex1D_F1.GetDimensions(0, uWidth, uMipLevels); - Tex1D_I.GetDimensions(uWidth); - Tex1D_I.GetDimensions(0, uWidth, uMipLevels); - Tex1D_U.GetDimensions(uWidth); - Tex1D_U.GetDimensions(0, uWidth, uMipLevels); - Tex1DS1.GetDimensions(uWidth); - Tex1DS1.GetDimensions(0, uWidth, uMipLevels); - - Tex1D_F1.GetDimensions(fWidth); - Tex1D_F1.GetDimensions(0, fWidth, fMipLevels); - Tex1D_I.GetDimensions(fWidth); - Tex1D_I.GetDimensions(0, fWidth, fMipLevels); - Tex1D_U.GetDimensions(fWidth); - Tex1D_U.GetDimensions(0, fWidth, fMipLevels); - Tex1DS1.GetDimensions(fWidth); - Tex1DS1.GetDimensions(0, fWidth, fMipLevels); - - Tex1D_F1.GetDimensions(iWidth); - Tex1D_F1.GetDimensions(0, iWidth, iMipLevels); - Tex1D_I.GetDimensions(iWidth); - Tex1D_I.GetDimensions(0, iWidth, iMipLevels); - Tex1D_U.GetDimensions(iWidth); - Tex1D_U.GetDimensions(0, iWidth, iMipLevels); - Tex1DS1.GetDimensions(iWidth); - Tex1DS1.GetDimensions(0, iWidth, iMipLevels); - } - - // Texture1DArray - { - uint uWidth, uMipLevels, uElems; - float fWidth, fMipLevels, fElems; - int iWidth, iMipLevels, iElems; - - Tex1D_F_A1.GetDimensions(0, uWidth, uElems, uMipLevels); - Tex1D_F_A1.GetDimensions(uWidth, uElems); - Tex1D_U_A.GetDimensions(0, uWidth, uElems, uMipLevels); - Tex1D_U_A.GetDimensions(uWidth, uElems); - Tex1D_I_A.GetDimensions(0, uWidth, uElems, uMipLevels); - Tex1D_I_A.GetDimensions(uWidth, uElems); - Tex1DAS1.GetDimensions(0, uWidth, uElems, uMipLevels); - Tex1DAS1.GetDimensions(uWidth, uElems); - - Tex1D_F_A1.GetDimensions(0, iWidth, iElems, iMipLevels); - Tex1D_F_A1.GetDimensions(iWidth, iElems); - Tex1D_U_A.GetDimensions(0, iWidth, iElems, iMipLevels); - Tex1D_U_A.GetDimensions(iWidth, iElems); - Tex1D_I_A.GetDimensions(0, iWidth, iElems, iMipLevels); - Tex1D_I_A.GetDimensions(iWidth, iElems); - Tex1DAS1.GetDimensions(0, iWidth, iElems, iMipLevels); - Tex1DAS1.GetDimensions(iWidth, iElems); - - Tex1D_F_A1.GetDimensions(0, fWidth, fElems, fMipLevels); - Tex1D_F_A1.GetDimensions(fWidth, fElems); - Tex1D_U_A.GetDimensions(0, fWidth, fElems, fMipLevels); - Tex1D_U_A.GetDimensions(fWidth, fElems); - Tex1D_I_A.GetDimensions(0, fWidth, fElems, fMipLevels); - Tex1D_I_A.GetDimensions(fWidth, fElems); - Tex1DAS1.GetDimensions(0, fWidth, fElems, fMipLevels); - Tex1DAS1.GetDimensions(fWidth, fElems); - } -#endif - - //Texture2D - { - uint uWidth, uHeight, uMipLevels; - int iWidth, iHeight, iMipLevels; - float fWidth, fHeight, fMipLevels; - - Tex2D_F1.GetDimensions(uWidth, uHeight); - Tex2D_F1.GetDimensions(0, uWidth, uHeight, uMipLevels); - Tex2D_F3[0].GetDimensions( 0, uWidth, uHeight, uMipLevels ); - Tex2D_I.GetDimensions(uWidth, uHeight); - Tex2D_I.GetDimensions(0, uWidth, uHeight, uMipLevels); - Tex2D_U.GetDimensions(uWidth, uHeight); - Tex2D_U.GetDimensions(0, uWidth, uHeight, uMipLevels); - Tex2DS1.GetDimensions(uWidth, uHeight); - Tex2DS1.GetDimensions(0, uWidth, uHeight, uMipLevels); - - Tex2D_F1.GetDimensions(iWidth, iHeight); - Tex2D_F1.GetDimensions(0, iWidth, iHeight, iMipLevels); - Tex2D_F3[0].GetDimensions( 0, iWidth, iHeight, iMipLevels ); - Tex2D_I.GetDimensions(iWidth, iHeight); - Tex2D_I.GetDimensions(0, iWidth, iHeight, iMipLevels); - Tex2D_U.GetDimensions(iWidth, iHeight); - Tex2D_U.GetDimensions(0, iWidth, iHeight, iMipLevels); - Tex2DS1.GetDimensions(iWidth, iHeight); - Tex2DS1.GetDimensions(0, iWidth, iHeight, iMipLevels); - - - Tex2D_F1.GetDimensions(fWidth, fHeight); - Tex2D_F1.GetDimensions(0, fWidth, fHeight, fMipLevels); - Tex2D_F3[0].GetDimensions( 0, fWidth, fHeight, fMipLevels ); - Tex2D_I.GetDimensions(fWidth, fHeight); - Tex2D_I.GetDimensions(0, fWidth, fHeight, fMipLevels); - Tex2D_U.GetDimensions(fWidth, fHeight); - Tex2D_U.GetDimensions(0, fWidth, fHeight, fMipLevels); - Tex2DS1.GetDimensions(fWidth, fHeight); - Tex2DS1.GetDimensions(0, fWidth, fHeight, fMipLevels); - } - - //Texture2DArray - { - uint uWidth, uHeight, uMipLevels, uElems; - int iWidth, iHeight, iMipLevels, iElems; - float fWidth, fHeight, fMipLevels, fElems; - - Tex2D_F_A1.GetDimensions(0, uWidth, uHeight, uElems, uMipLevels); - Tex2D_F_A1.GetDimensions(uWidth, uHeight, uElems); - Tex2D_U_A.GetDimensions(0, uWidth, uHeight, uElems, uMipLevels); - Tex2D_U_A.GetDimensions(uWidth, uHeight, uElems); - Tex2D_I_A.GetDimensions(0, uWidth, uHeight, uElems, uMipLevels); - Tex2D_I_A.GetDimensions(uWidth, uHeight, uElems); - Tex2DAS1.GetDimensions(0, uWidth, uHeight, uElems, uMipLevels); - Tex2DAS1.GetDimensions(uWidth, uHeight, uElems); - - Tex2D_F_A1.GetDimensions(0, iWidth, iHeight, iElems, iMipLevels); - Tex2D_F_A1.GetDimensions(iWidth, iHeight, iElems); - Tex2D_U_A.GetDimensions(0, iWidth, iHeight, iElems, iMipLevels); - Tex2D_U_A.GetDimensions(iWidth, iHeight, iElems); - Tex2D_I_A.GetDimensions(0, iWidth, iHeight, iElems, iMipLevels); - Tex2D_I_A.GetDimensions(iWidth, iHeight, iElems); - Tex2DAS1.GetDimensions(0, iWidth, iHeight, iElems, iMipLevels); - Tex2DAS1.GetDimensions(iWidth, iHeight, iElems); - - Tex2D_F_A1.GetDimensions(0, fWidth, fHeight, fElems, fMipLevels); - Tex2D_F_A1.GetDimensions(fWidth, fHeight, fElems); - Tex2D_U_A.GetDimensions(0, fWidth, fHeight, fElems, fMipLevels); - Tex2D_U_A.GetDimensions(fWidth, fHeight, fElems); - Tex2D_I_A.GetDimensions(0, fWidth, fHeight, fElems, fMipLevels); - Tex2D_I_A.GetDimensions(fWidth, fHeight, fElems); - Tex2DAS1.GetDimensions(0, fWidth, fHeight, fElems, fMipLevels); - Tex2DAS1.GetDimensions(fWidth, fHeight, fElems); - } - - //Texture3D - { - uint uWidth, uHeight, uDepth, uMipLevels; - int iWidth, iHeight, iDepth, iMipLevels; - float fWidth, fHeight, fDepth, fMipLevels; - Tex3D_F1.GetDimensions(0, uWidth, uHeight, uDepth, uMipLevels); - Tex3D_F1.GetDimensions(uWidth, uHeight, uDepth); - Tex3D_U.GetDimensions(0, uWidth, uHeight, uDepth, uMipLevels); - Tex3D_U.GetDimensions(uWidth, uHeight, uDepth); - Tex3D_I.GetDimensions(0, uWidth, uHeight, uDepth, uMipLevels); - Tex3D_I.GetDimensions(uWidth, uHeight, uDepth); - - Tex3D_F1.GetDimensions(0, iWidth, iHeight, iDepth, iMipLevels); - Tex3D_F1.GetDimensions(iWidth, iHeight, iDepth); - Tex3D_U.GetDimensions(0, iWidth, iHeight, iDepth, iMipLevels); - Tex3D_U.GetDimensions(iWidth, iHeight, iDepth); - Tex3D_I.GetDimensions(0, iWidth, iHeight, iDepth, iMipLevels); - Tex3D_I.GetDimensions(iWidth, iHeight, iDepth); - - Tex3D_F1.GetDimensions(0, fWidth, fHeight, fDepth, fMipLevels); - Tex3D_F1.GetDimensions(fWidth, fHeight, fDepth); - Tex3D_U.GetDimensions(0, fWidth, fHeight, fDepth, fMipLevels); - Tex3D_U.GetDimensions(fWidth, fHeight, fDepth); - Tex3D_I.GetDimensions(0, fWidth, fHeight, fDepth, fMipLevels); - Tex3D_I.GetDimensions(fWidth, fHeight, fDepth); - } - - //TextureCube ~ Texture2D - { - uint uWidth, uHeight, uMipLevels; - int iWidth, iHeight, iMipLevels; - float fWidth, fHeight, fMipLevels; - - TexC_F1.GetDimensions(0, uWidth, uHeight, uMipLevels); - TexC_F1.GetDimensions(uWidth, uHeight); - TexC_I.GetDimensions(0, uWidth, uHeight, uMipLevels); - TexC_I.GetDimensions(uWidth, uHeight); - TexC_U.GetDimensions(0, uWidth, uHeight, uMipLevels); - TexC_U.GetDimensions(uWidth, uHeight); - TexCS1.GetDimensions(0, uWidth, uHeight, uMipLevels); - TexCS1.GetDimensions(uWidth, uHeight); - - TexC_F1.GetDimensions(0, iWidth, iHeight, iMipLevels); - TexC_F1.GetDimensions(iWidth, iHeight); - TexC_I.GetDimensions(0, iWidth, iHeight, iMipLevels); - TexC_I.GetDimensions(iWidth, iHeight); - TexC_U.GetDimensions(0, iWidth, iHeight, iMipLevels); - TexC_U.GetDimensions(iWidth, iHeight); - TexCS1.GetDimensions(0, iWidth, iHeight, iMipLevels); - TexCS1.GetDimensions(iWidth, iHeight); - - TexC_F1.GetDimensions(0, fWidth, fHeight, fMipLevels); - TexC_F1.GetDimensions(fWidth, fHeight); - TexC_I.GetDimensions(0, fWidth, fHeight, fMipLevels); - TexC_I.GetDimensions(fWidth, fHeight); - TexC_U.GetDimensions(0, fWidth, fHeight, fMipLevels); - TexC_U.GetDimensions(fWidth, fHeight); - TexCS1.GetDimensions(0, fWidth, fHeight, fMipLevels); - TexCS1.GetDimensions(fWidth, fHeight); - } - -#ifndef GL_ES - //TextureCubeArray ~ Texture2DArray - { - uint uWidth, uHeight, uMipLevels, uElems; - float fWidth, fHeight, fMipLevels, fElems; - int iWidth, iHeight, iMipLevels, iElems; - - TexC_F_A1.GetDimensions(0, uWidth, uHeight, uElems, uMipLevels); - TexC_F_A1.GetDimensions(uWidth, uHeight, uElems); - TexC_I_A.GetDimensions(0, uWidth, uHeight, uElems, uMipLevels); - TexC_I_A.GetDimensions(uWidth, uHeight, uElems); - TexC_U_A.GetDimensions(0, uWidth, uHeight, uElems, uMipLevels); - TexC_U_A.GetDimensions(uWidth, uHeight, uElems); - TexCAS1.GetDimensions(0, uWidth, uHeight, uElems, uMipLevels); - TexCAS1.GetDimensions(uWidth, uHeight, uElems); - - TexC_F_A1.GetDimensions(0, iWidth, iHeight, iElems, iMipLevels); - TexC_F_A1.GetDimensions(iWidth, iHeight, iElems); - TexC_I_A.GetDimensions(0, iWidth, iHeight, iElems, iMipLevels); - TexC_I_A.GetDimensions(iWidth, iHeight, iElems); - TexC_U_A.GetDimensions(0, iWidth, iHeight, iElems, iMipLevels); - TexC_U_A.GetDimensions(iWidth, iHeight, iElems); - TexCAS1.GetDimensions(0, iWidth, iHeight, iElems, iMipLevels); - TexCAS1.GetDimensions(iWidth, iHeight, iElems); - - TexC_F_A1.GetDimensions(0, fWidth, fHeight, fElems, fMipLevels); - TexC_F_A1.GetDimensions(fWidth, fHeight, fElems); - TexC_I_A.GetDimensions(0, fWidth, fHeight, fElems, fMipLevels); - TexC_I_A.GetDimensions(fWidth, fHeight, fElems); - TexC_U_A.GetDimensions(0, fWidth, fHeight, fElems, fMipLevels); - TexC_U_A.GetDimensions(fWidth, fHeight, fElems); - TexCAS1.GetDimensions(0, fWidth, fHeight, fElems, fMipLevels); - TexCAS1.GetDimensions(fWidth, fHeight, fElems); - } -#endif - - -#ifndef GL_ES // This should work on ES3.1, but compiler fails for no reason - // Texture2DMS - { - uint uWidth, uHeight, uNumSamples; - float fWidth, fHeight, fNumSamples; - int iWidth, iHeight, iNumSamples; - Tex2DMS_F1.GetDimensions(uWidth, uHeight, uNumSamples); - Tex2DMS_I.GetDimensions(uWidth, uHeight, uNumSamples); - Tex2DMS_U.GetDimensions(uWidth, uHeight, uNumSamples); - - Tex2DMS_F1.GetDimensions(fWidth, fHeight, fNumSamples); - Tex2DMS_I.GetDimensions(fWidth, fHeight, fNumSamples); - Tex2DMS_U.GetDimensions(fWidth, fHeight, fNumSamples); - - Tex2DMS_F1.GetDimensions(iWidth, iHeight, iNumSamples); - Tex2DMS_I.GetDimensions(iWidth, iHeight, iNumSamples); - Tex2DMS_U.GetDimensions(iWidth, iHeight, iNumSamples); - } -#endif - -#ifndef GL_ES - // Texture2DMSArray - { - uint uWidth, uHeight, uElems, uNumSamples; - int iWidth, iHeight, iElems, iNumSamples; - float fWidth, fHeight, fElems, fNumSamples; - Tex2DMS_F_A1.GetDimensions(uWidth, uHeight, uElems, uNumSamples); - Tex2DMS_I_A.GetDimensions(uWidth, uHeight, uElems, uNumSamples); - // OpenGL4.2 only supports 32 texture units and this one is 33rd: - // Tex2DMS_U_A.GetDimensions(Width, Height, Elems, NumSamples); - - Tex2DMS_F_A1.GetDimensions(fWidth, fHeight, fElems, fNumSamples); - Tex2DMS_I_A.GetDimensions(fWidth, fHeight, fElems, fNumSamples); - - Tex2DMS_F_A1.GetDimensions(iWidth, iHeight, iElems, iNumSamples); - Tex2DMS_I_A.GetDimensions(iWidth, iHeight, iElems, iNumSamples); - } -#endif - - // Buffer - { - uint uWidth; - //int iWidth; - //float fWidth; - TexBuffer_F1.GetDimensions(uWidth); - //TexBuffer_F4.GetDimensions(iWidth); - //TexBuffer_I.GetDimensions(fWidth); - } -} - - - -void TestSample() -{ - float2 f2UV = float2(0.2, 0.3); - float3 f3UVW = float3(0.2, 0.3, 0.5); - const int3 Offset = int3(3, 6, 2); - float4 f4UVWQ = float4(0.2, 0.3, 0.5, 10.0); - -#ifndef GL_ES - // Texture1D - Tex1D_F1.Sample(Tex1D_F1_sampler, f3UVW.x); - Tex1D_F1.Sample(Tex1D_F1_sampler, f3UVW.x, Offset.x); - - // Texture1DArray - Tex1D_F_A1.Sample(Tex1D_F_A1_sampler, f3UVW.xy); - Tex1D_F_A1.Sample(Tex1D_F_A1_sampler, f3UVW.xy, Offset.x); -#endif - - //Texture2D - Tex2D_F1.Sample( Tex2D_F1_sampler, f3UVW.xy ).xyzw.xyzw; - Tex2D_F1.Sample( Tex2D_F1_sampler, f3UVW.xy, Offset.xy ); - Tex2D_F1.Sample( Tex2D_F1_sampler, float2(0.1, 0.3) ); - Tex2D_F1.Sample( Tex2D_F1_sampler, float2(0.1, (0.3+0.1) ), int2( (3-1) ,5) ); - - //Texture2DArray - Tex2D_F_A1.Sample( Tex2D_F_A1_sampler, f3UVW.xyz ); - Tex2D_F_A1.Sample( Tex2D_F_A1_sampler, f3UVW.xyz, Offset.xy ); - - //Texture3D - Tex3D_F1.Sample(Tex3D_F1_sampler, f3UVW.xyz ); - Tex3D_F1.Sample(Tex3D_F1_sampler, f3UVW.xyz, Offset.xyz ); - - //TextureCube - TexC_F1.Sample(TexC_F1_sampler, f3UVW.xyz ); - // Offset not supported - -#ifndef GL_ES - // TextureCubeArray - TexC_F_A1.Sample( TexC_F_A1_sampler, f4UVWQ.xyzw ); - TexC_F_A1.Sample( TexC_F_A1_sampler, float4(0.5, (0.2+(0.01+0.02)), 0.4, 7.0) ); - // Offset not supported -#endif -} - - - -void TestSampleBias() -{ - float2 f2UV = float2(0.2, 0.3); - float3 f3UVW = float3(0.2, 0.3, 0.5); - const int3 Offset = int3(3, 6, 2); - float4 f4UVWQ = float4(0.2, 0.3, 0.5, 10.0); - -#ifndef GL_ES - // Texture1D - Tex1D_F1.SampleBias(Tex1D_F1_sampler, f3UVW.x, 1.5); - Tex1D_F1.SampleBias(Tex1D_F1_sampler, f3UVW.x, 1.5, Offset.x); - - // Texture1DArray - Tex1D_F_A1.SampleBias(Tex1D_F_A1_sampler, f3UVW.xy, 1.5); - Tex1D_F_A1.SampleBias(Tex1D_F_A1_sampler, f3UVW.xy, 1.5, Offset.x); -#endif - - //Texture2D - Tex2D_F1.SampleBias( Tex2D_F1_sampler, f3UVW.xy, 1.5 ); - Tex2D_F1.SampleBias( Tex2D_F1_sampler, f3UVW.xy, 1.5, Offset.xy ); - Tex2D_F1.SampleBias( Tex2D_F1_sampler, float2(0.1, 0.3), 1.5 ); - Tex2D_F1.SampleBias( Tex2D_F1_sampler, float2(0.1, (0.3+0.1) ), 1.5, int2( (3-1) ,5) ); - - //Texture2DArray - Tex2D_F_A1.SampleBias( Tex2D_F_A1_sampler, f3UVW.xyz, 1.5 ); - Tex2D_F_A1.SampleBias( Tex2D_F_A1_sampler, f3UVW.xyz, 1.5, Offset.xy ); - - //Texture3D - Tex3D_F1.SampleBias(Tex3D_F1_sampler, f3UVW.xyz, 1.5 ); - Tex3D_F1.SampleBias(Tex3D_F1_sampler, f3UVW.xyz, 1.5, Offset.xyz ); - - //TextureCube - TexC_F1.SampleBias(TexC_F1_sampler, f3UVW.xyz, 1.5 ); - // Offset not supported - -#ifndef GL_ES - // TextureCubeArray - TexC_F_A1.SampleBias( TexC_F_A1_sampler, f4UVWQ.xyzw, 1.5 ); - TexC_F_A1.SampleBias( TexC_F_A1_sampler, float4(0.5, (0.2+(0.01+0.02)), 0.4, 7.0), 1.6 ); - // Offset not supported -#endif -} - -void TestSampleLevel() -{ - float2 f2UV = float2(0.2, 0.3); - float3 f3UVW = float3(0.2, 0.3, 0.5); - float Level = 1.8; - const int3 Offset = int3(3, 6, 2); - float4 f4UVWQ = float4(0.2, 0.3, 0.5, 10.0); - -#ifndef GL_ES - // Texture1D - Tex1D_F1.SampleLevel(Tex1D_F1_sampler, f3UVW.x, Level); - Tex1D_F1.SampleLevel(Tex1D_F1_sampler, f3UVW.x, Level, Offset.x); - - // Texture1DArray - Tex1D_F_A1.SampleLevel(Tex1D_F_A1_sampler, f3UVW.xy, Level); - Tex1D_F_A1.SampleLevel(Tex1D_F_A1_sampler, f3UVW.xy, Level, Offset.x); -#endif - - //Texture2D - Tex2D_F1.SampleLevel( Tex2D_F1_sampler, f3UVW.xy, Level ); - Tex2D_F1.SampleLevel( Tex2D_F1_sampler, Tex2D_F1.SampleLevel( Tex2D_F1_sampler, f3UVW.xy, Level ).xy + Tex2D_F1.SampleLevel( Tex2D_F1_sampler, f3UVW.xy, Level ).xy, Level ); - Tex2D_F1.SampleLevel( Tex2D_F1_sampler, f3UVW.xy, Level, Offset.xy ); - Tex2D_F1.SampleLevel( Tex2D_F1_sampler, float2(0.1, 0.3), 4.0 ); - Tex2D_F1.SampleLevel( Tex2D_F1_sampler, float2(0.1, (0.3+0.1) ), 4.0, int2( (3-1) ,5) ); - - //Texture2DArray - Tex2D_F_A1.SampleLevel( Tex2D_F_A1_sampler, f3UVW.xyz, Level ); - Tex2D_F_A1.SampleLevel( Tex2D_F_A1_sampler, f3UVW.xyz, Level, Offset.xy ); - - //Texture3D - Tex3D_F1.SampleLevel(Tex3D_F1_sampler, f3UVW.xyz, Level ); - Tex3D_F1.SampleLevel(Tex3D_F1_sampler, f3UVW.xyz, Level, Offset.xyz ); - - //TextureCube - TexC_F1.SampleLevel(TexC_F1_sampler, f3UVW.xyz, Level ); - // Offset not supported - -#ifndef GL_ES - // TextureCubeArray - TexC_F_A1.SampleLevel( TexC_F_A1_sampler, f4UVWQ.xyzw, Level ); - TexC_F_A1.SampleLevel( TexC_F_A1_sampler, float4(0.5, (0.2+(0.01+0.02)), 0.4, 7.0), 5 ); - // Offset not supported -#endif -} - - -void TestSampleGrad() -{ - float2 f2UV = float2(0.2, 0.3); - float2 f2ddxUV = float2(0.01, -0.02); - float2 f2ddyUV = float2(-0.01, 0.01); - float3 f3UVW = float3(0.2, 0.3, 0.5); - float3 f3ddxUVW = float3(-0.02, 0.03, 0.05); - float3 f3ddyUVW = float3( 0.01, -0.02, 0.02); - const int3 Offset = int3(3, 6, 2); - float4 f4UVWQ = float4(0.2, 0.3, 0.5, 10.0); - -#ifndef GL_ES - // Texture1D - Tex1D_F1.SampleGrad(Tex1D_F1_sampler, f3UVW.x, f2ddxUV.x, f2ddyUV.x); - Tex1D_F1.SampleGrad(Tex1D_F1_sampler, f3UVW.x, f2ddxUV.x, f2ddyUV.x, Offset.x); - - // Texture1DArray - Tex1D_F_A1.SampleGrad(Tex1D_F_A1_sampler, f3UVW.xy, f2ddxUV.x, f2ddyUV.x); - Tex1D_F_A1.SampleGrad(Tex1D_F_A1_sampler, f3UVW.xy, f2ddxUV.x, f2ddyUV.x, Offset.x); -#endif - - //Texture2D - Tex2D_F1.SampleGrad( Tex2D_F1_sampler, f3UVW.xy, f2ddxUV.xy, f2ddyUV.xy ); - Tex2D_F1.SampleGrad( Tex2D_F1_sampler, f3UVW.xy, f2ddxUV.xy, f2ddyUV.xy, Offset.xy ); - Tex2D_F1.SampleGrad( Tex2D_F1_sampler, float2(0.1, 0.3), float2(0.01, 0.02), float2(-0.02, 0.01) ); - Tex2D_F1.SampleGrad( Tex2D_F1_sampler, float2(0.1, (0.3+0.1) ), float2(0.01, 0.02), float2(-0.02, 0.01), int2( (3-1) ,5) ); - - //Texture2DArray - Tex2D_F_A1.SampleGrad( Tex2D_F_A1_sampler, f3UVW.xyz, f2ddxUV.xy, f2ddyUV.xy ); - Tex2D_F_A1.SampleGrad( Tex2D_F_A1_sampler, f3UVW.xyz, f2ddxUV.xy, f2ddyUV.xy, Offset.xy ); - - //Texture3D - Tex3D_F1.SampleGrad(Tex3D_F1_sampler, f3UVW.xyz, f3ddxUVW.xyz, f3ddyUVW.xyz ); - Tex3D_F1.SampleGrad(Tex3D_F1_sampler, f3UVW.xyz, f3ddxUVW.xyz, f3ddyUVW.xyz, Offset.xyz ); - - //TextureCube - TexC_F1.SampleGrad(TexC_F1_sampler, f3UVW.xyz, f3ddxUVW.xyz, f3ddyUVW.xyz ); - // Offset not supported - -#ifndef GL_ES - // TextureCubeArray - TexC_F_A1.SampleGrad( TexC_F_A1_sampler, f4UVWQ.xyzw, f3ddxUVW.xyz, f3ddyUVW.xyz ); - TexC_F_A1.SampleGrad( TexC_F_A1_sampler, float4(0.5, (0.2+(0.01+0.02)), 0.4, 7.0), float3(0.01,0.02,0.03), float3(-0.01,-0.02,-0.03) ); - // Offset not supported -#endif -} - - - -void TestSampleCmp() -{ - float3 f3UVW = float3(0.2, 0.3, 0.5); - const int3 Offset = int3(3, 6, 2); - float4 f4UVWQ = float4(0.2, 0.3, 0.5, 10.0); - float CompareVal = 0.7; - -#ifndef GL_ES - // Texture1D - Tex1DS1.SampleCmp(Tex1DS1_sampler, f3UVW.x, CompareVal); - Tex1DS1.SampleCmp(Tex1DS1_sampler, f3UVW.x, CompareVal, Offset.x); - - // Texture1DArray - Tex1DAS1.SampleCmp(Tex1DAS1_sampler, f3UVW.xy, CompareVal); - Tex1DAS1.SampleCmp(Tex1DAS1_sampler, f3UVW.xy, CompareVal, Offset.x); -#endif - - //Texture2D - Tex2DS1.SampleCmp( Tex2DS1_sampler, f3UVW.xy, CompareVal ); - Tex2DS1.SampleCmp( Tex2DS1_sampler, f3UVW.xy, CompareVal, Offset.xy ); - Tex2DS1.SampleCmp( Tex2DS1_sampler, float2(0.1, 0.3), 4.0 ); - Tex2DS1.SampleCmp( Tex2DS1_sampler, float2(0.1, (0.3+0.1) ), 4.0, int2( (3-1) ,5) ); - Tex2DS_F5.SampleCmp( Tex2DS_F5_sampler, f3UVW.xy, CompareVal ); - - //Texture2DArray - Tex2DAS1.SampleCmp( Tex2DAS1_sampler, f3UVW.xyz, CompareVal ); - // This seems to be another bug on Intel driver: the following line does not compile: - // Tex2DAS1.SampleCmp( Tex2DAS1_sampler, f3UVW.xyz, CompareVal, Offset.xy ); - - //TextureCube - TexCS1.SampleCmp(TexCS1_sampler, f3UVW.xyz, CompareVal ); - // Offset not supported - -#ifndef GL_ES - // TextureCubeArray - TexCAS1.SampleCmp( TexCAS1_sampler, f4UVWQ.xyzw, CompareVal ); - TexCAS1.SampleCmp( TexCAS1_sampler, float4(0.5, (0.2+(0.01+0.02)), 0.4, 7.0), 0.5 ); - // Offset not supported -#endif -} - - - -void TestSampleCmpLevelZero() -{ - float3 f3UVW = float3(0.2, 0.3, 0.5); - const int3 Offset = int3(3, 6, 2); - float4 f4UVWQ = float4(0.2, 0.3, 0.5, 10.0); - float CompareVal = 0.7; - -#ifndef GL_ES - // Texture1D - Tex1DS1.SampleCmpLevelZero(Tex1DS1_sampler, f3UVW.x, CompareVal); - Tex1DS1.SampleCmpLevelZero(Tex1DS1_sampler, f3UVW.x, CompareVal, Offset.x); - - // Texture1DArray - Tex1DAS1.SampleCmpLevelZero(Tex1DAS1_sampler, f3UVW.xy, CompareVal); - Tex1DAS1.SampleCmpLevelZero(Tex1DAS1_sampler, f3UVW.xy, CompareVal, Offset.x); -#endif - - //Texture2D - Tex2DS1.SampleCmpLevelZero( Tex2DS1_sampler, f3UVW.xy, CompareVal ); - Tex2DS1.SampleCmpLevelZero( Tex2DS1_sampler, f3UVW.xy, CompareVal, Offset.xy ); - Tex2DS1.SampleCmpLevelZero( Tex2DS1_sampler, float2(0.1, 0.3), 4.0 ); - Tex2DS1.SampleCmpLevelZero( Tex2DS1_sampler, float2(0.1, (0.3+0.1) ), 4.0, int2( (3-1) ,5) ); - - //Texture2DArray - Tex2DAS1.SampleCmpLevelZero( Tex2DAS1_sampler, f3UVW.xyz, CompareVal ); - // This seems to be another bug on Intel driver: the following line does not compile: - // Tex2DAS1.SampleCmpLevelZero( Tex2DAS1_sampler, f3UVW.xyz, CompareVal, Offset.xy ); - - //TextureCube - TexCS1.SampleCmpLevelZero(TexCS1_sampler, f3UVW.xyz, CompareVal ); - // Offset not supported - -#ifndef GL_ES - // TextureCubeArray - TexCAS1.SampleCmpLevelZero( TexCAS1_sampler, f4UVWQ.xyzw, CompareVal ); - TexCAS1.SampleCmpLevelZero( TexCAS1_sampler, float4(0.5, (0.2+(0.01+0.02)), 0.4, 7.0), 0.5 ); - // Offset not supported -#endif -} - - - -void TestLoad() -{ - int4 Location = int4(2, 5, 1, 10); - const int3 Offset = int3(5, 7, -6); - -#ifndef GL_ES - // Texture1D - { - Tex1D_F1.Load(Location.xy); - Tex1D_F1.Load(Location.xy, Offset.x); - Tex1D_I.Load(Location.xy); - Tex1D_I.Load(Location.xy, Offset.x); - Tex1D_U.Load(Location.xy); - Tex1D_U.Load(Location.xy, Offset.x); - } - - // Texture1DArray - { - Tex1D_F_A1.Load(Location.xyz); - Tex1D_F_A1.Load(Location.xyz, Offset.x); - Tex1D_U_A.Load(Location.xyz); - Tex1D_U_A.Load(Location.xyz, Offset.x); - Tex1D_I_A.Load(Location.xyz); - Tex1D_I_A.Load(Location.xyz, Offset.x); - } -#endif - - //Texture2D - { - Tex2D_F1.Load(Location.xyz); - Tex2D_F1.Load(Location.xyz, Offset.xy); - Tex2D_F1.Load(Tex2D_I.Load(Location.xyz).xyz + Tex2D_I.Load(Location.xyz).xyz); - Tex2D_I.Load(Location.xyz); - Tex2D_I.Load(Location.xyz, Offset.xy); - Tex2D_U.Load(Location.xyz); - Tex2D_U.Load(Location.xyz, Offset.xy); - } - - //Texture2DArray - { - Tex2D_F_A1.Load(Location.xyzw); - Tex2D_F_A1.Load(Location.xyzw, Offset.xy); - Tex2D_U_A.Load(Location.xyzw); - Tex2D_U_A.Load(Location.xyzw, Offset.xy); - Tex2D_I_A.Load(Location.xyzw); - Tex2D_I_A.Load(Location.xyzw, Offset.xy); - } - - //Texture3D - { - Tex3D_F1.Load(Location.xyzw); - Tex3D_F1.Load(Location.xyzw, Offset.xyz); - Tex3D_U.Load(Location.xyzw); - Tex3D_U.Load(Location.xyzw, Offset.xyz); - Tex3D_I.Load(Location.xyzw); - Tex3D_I.Load(Location.xyzw, Offset.xyz); - } - -#ifndef GL_ES // This should work on ES3.1, but compiler fails for no reason - // Texture2DMS - { - Tex2DMS_F1.Load(Location.xy, 1); - Tex2DMS_F1.Load(Location.xy, 1, Offset.xy); - Tex2DMS_I.Load(Location.xy, 1); - Tex2DMS_I.Load(Location.xy, 1, Offset.xy); - Tex2DMS_U.Load(Location.xy, 1); - Tex2DMS_U.Load(Location.xy, 1, Offset.xy); - } -#endif - -#ifndef GL_ES - // Texture2DMSArray - { - Tex2DMS_F_A1.Load(Location.xyz, 1); - Tex2DMS_F_A1.Load(Location.xyz, 1, Offset.xy); - Tex2DMS_I_A.Load(Location.xyz, 1); - Tex2DMS_I_A.Load(Location.xyz, 1, Offset.xy); - Tex2DMS_U_A.Load(Location.xyz, 1); - Tex2DMS_U_A.Load(Location.xyz, 1, Offset.xy); - } -#endif - - // Buffer - { - TexBuffer_F1.Load(Location.x); - TexBuffer_F4.Load(Location.x); - TexBuffer_I.Load(Location.x); - TexBuffer_U.Load(Location.x); - } -} - - - - -void TestGather() -{ -#if !GLES30 // no textureGather in GLES3.0 - float4 Location = float4(0.2, 0.5, 0.1, 0.7); - const int3 Offset = int3(5, 10, 20); - - //Texture2D - { - Tex2D_F1.Gather(Tex2D_F1_sampler, Location.xy); - Tex2D_F1.Gather(Tex2D_F1_sampler, Location.xy, Offset.xy); - //Tex2D_I.Gather(Location.xyz); - //Tex2D_I.Gather(Location.xyz, Offset.xy); - //Tex2D_U.Gather(Location.xyz); - //Tex2D_U.Gather(Location.xyz, Offset.xy); - } - - //Texture2DArray - { - Tex2D_F_A1.Gather(Tex2D_F_A1_sampler, Location.xyz); - Tex2D_F_A1.Gather(Tex2D_F_A1_sampler, Location.xyz, Offset.xy); - //Tex2D_U_A.Gather(Location.xyzw); - //Tex2D_U_A.Gather(Location.xyzw, Offset.xy); - //Tex2D_I_A.Gather(Location.xyzw); - //Tex2D_I_A.Gather(Location.xyzw, Offset.xy); - } - - // TextureCube - { - TexC_F1.Gather(TexC_F1_sampler, Location.xyz); - //TexC_I.Gather(Location.xyz); - //TexC_U.Gather(Location.xyz); - } -#ifndef GL_ES - // TextureCubeArray - { - TexC_F_A1.Gather(TexC_F_A1_sampler, Location.xyzw); - //TexC_I_A.Gather(Location.xyzw); - //TexC_U_A.Gather(Location.xyzw); - } -#endif - -#endif -} - - - -void TestGatherCmp() -{ -#if !GLES30 // no textureGather in GLES3.0 - float4 Location = float4(0.2, 0.5, 0.1, 0.7); - const int3 Offset = int3(5, 10, 20); - float CompareVal = 0.01; - - //Texture2D - { - Tex2DS1.GatherCmp(Tex2DS1_sampler, Location.xy, CompareVal); - Tex2DS1.GatherCmp(Tex2DS1_sampler, Location.xy, CompareVal, Offset.xy); - } - - //Texture2DArray - { - Tex2DAS1.GatherCmp(Tex2DAS1_sampler, Location.xyz, CompareVal); - Tex2DAS1.GatherCmp(Tex2DAS1_sampler, Location.xyz, CompareVal, Offset.xy); - } - - // TextureCube - { - TexCS1.GatherCmp(TexCS1_sampler, Location.xyz, CompareVal); - } -#ifndef GL_ES - // TextureCubeArray - { - TexCAS1.GatherCmp(TexCAS1_sampler, Location.xyzw, CompareVal); - } -#endif - -#endif -} - -struct InnerStruct -{ - float f[4]; - int i; - uint u; - bool b; -}; - -struct OuterStruct -{ - InnerStruct inner; - float f; - int i; - uint u; - bool b; -}; - -struct VSInputSubStruct -{ - float3 f3Normal : ATTRIB2; - uint VertexId : SV_VertexId; -}; - -struct VSInput -{ - float3 f3PosWS : ATTRIB0; - float2 f2UV : ATTRIB1; - VSInputSubStruct SubStruct; -}; - -struct VSOutputSubStruct -{ - float4 f4Attrib : F4_ATTRIB2; - int iAttrib : I_ATTRIB2; -}; -struct VSOutput -{ - float2 f2Attrib : F2_ATTRIB; - float3 f3Attrib : F3_ATTRIB; - float4 f4Attrib : F4_ATTRIB; - uint uiAttrib : UI_ATTRIB; - uint3 ui3Attrib : UI3_ATTRIB; - int iAttrib : I_ATTRIB; - float4 f4PosPS : SV_Position; - VSOutputSubStruct SubStruct; -}; - -void TestVS ( VSInput In, - in float3 f3UV : ATTRIB3, - in uint InstID : SV_InstanceID, - out VSOutput Out, - out float fAttrib : F_ATTRIB, - out int4 i4Attrib : I4_ATTRIB) -{ - Out.f4PosPS = float4(1.0, 2.0, 3.0, 4.0); - fAttrib = 1.0; - Out.f2Attrib = float2(5.0, 6.0) + In.f2UV; - Out.f3Attrib = float3(7.0, 8.0, 9.0) + In.f3PosWS + f3UV + In.SubStruct.f3Normal; - Out.f4Attrib = float4(10.0, 11.0, 12.0, 13.0); - - Out.SubStruct.f4Attrib = float4(10.0, 11.0, 12.0, 13.0); - Out.uiAttrib = 1u; - Out.ui3Attrib = uint3(2u, 3u, 4u); - Out.iAttrib = 5; - Out.SubStruct.iAttrib = 20; - i4Attrib = int4(5, 6, 7, 8); - - if( In.f2UV.x < 0.5 ) - return; - - Out.f4Attrib.z = 0.1; - Out.SubStruct.f4Attrib.zw = float2(12.0, 31.0); - Out.ui3Attrib.y = 2u; - i4Attrib.yzw = int3(15, 16, 17); -} - - -void TestFuncArgs1( Texture2D Arg1, - SamplerState Arg1_sampler, - Texture2D Arg2, - SamplerComparisonState Arg2_sampler, - Texture3D Arg3) -{ - uint uWidth, uHeight, uMipLevels; - Arg1.GetDimensions(uWidth, uHeight); - - Arg2.SampleCmp( Arg2_sampler, float2(0.5,0.5), 0.1 ); - - Arg3.Load( int4(1, 2, 3, 0) ); -} - -void TestFuncArgs2( Texture3D Arg1, - Texture2DArray Arg2, - SamplerState Arg2_sampler, - Texture2D Arg3) -{ - Arg1.Load( int4(1, 2, 3, 0) ); - - uint uWidth, uHeight, uElems; - Arg2.GetDimensions(uWidth, uHeight, uElems); - - Arg3.Load(int3(10,15,3) ); -} - -struct PSOutputSubStruct -{ - float4 Color4 : SV_Target1; -}; -struct PSOutput -{ - float4 Color3 : SV_Target3; - PSOutputSubStruct substr; -}; - -void TestPS ( in VSOutput In, - out float4 Color : SV_Target, - out float3 Color2 : SV_Target2, - out PSOutput Out) -{ - float4 Pos = In.f4PosPS; - - Out.Color3 = float4(0.0 + a, 1.0 + b, 2.0 + c, 3.0 + d); - Out.substr.Color4 = float4(0.0, 1.0, 2.0, 3.0); - - TestFuncArgs1( Tex2D_F6, - Tex2D_F6_sampler, - Tex2DS_F5, - Tex2DS_F5_sampler, - Tex3D_F3); - TestFuncArgs2( Tex3D_I, - Tex2D_F_A3, - Tex2D_F_A3_sampler, - Tex2D_F2); - { - float2 a = float2(0.0, 0.0); - float2 b = float2(1.0, 1.0); - float2 c = float2(2.0, 2.0); - a += b; - a-=b; - a *=c; - a/= c; - float2 d = a; - - int2 x = int2(1, 2); - int2 y = int2(2, 1); - x %= y; - x &= y; - x |= y; - x ^= y; - x >>= y; - x <<= y; - x = x | y; - x = x & y; - x = x % y; - x = x ^ y; - x = ~y; - x = x >> y; - x = x << y; - x++; - ++x; - y--; - --y; - if( x.x>= y.x || y.y >=x.y && x.y == y.x && y.y==x.y && !(x.x==y.y) ) - x += y; - - [flatten] - if(x.x==y.x) - x.x=y.x; - - [branch] - if(x.x==y.x) - x.x+=y.x; - { - [loop] - for(int i=0;i<10;++i) - x.x+=1; - } - - { - [unroll] - for(int i=0;i<10;++i) - y.x+=1; - } - - Color = In.f4Attrib; - Color2 = In.f3Attrib; - if( Pos.x < 0.2 ) return; - } - - { - int i1 = 1; - int2 i2 = int2(1, 2); - int3 i3 = int3(1, 2, 3); - int4 i4 = int4(1,2,3,4); - - float f1 = 1.0; - float2 f2 = float2(1.0, 2.0); - float3 f3 = float3(1.0, 2.0, 3.0); - float4 f4 = float4(1.0,2.0,3.0,4.0); - float f1_ = 2.0; - float2 f2_ = float2(11.0, 12.0); - float3 f3_ = float3(11.0, 12.0, 13.0); - float4 f4_ = float4(11.0,12.0,13.0,14.0); - - uint u1 = 1u; - uint2 u2 = uint2(1u, 2u); - uint3 u3 = uint3(1u, 2u, 3u); - uint4 u4 = uint4(1u, 2u,3u,4u); - - bool b1 = true; - bool2 b2 = bool2(true, false); - bool3 b3 = bool3(true, false, true); - bool4 b4 = bool4(true, false, true, false); - - i1 = abs ( i1 ); i2 = abs ( i2 ); i3 = abs ( i3 ); i4 = abs ( i4 ); - f1 = abs ( f1 ); f2 = abs ( f2 ); f3 = abs ( f3 ); f4 = abs ( f4 ); - - b1 = all ( b2 ); b1 = all ( b3 ); b1 = all ( b4 ); - b1 = any ( b2 ); b1 = any ( b3 ); b1 = any ( b4 ); - - f1 = ceil( f1 ); f2 = ceil( f2 ); f3 = ceil( f3 ); f4 = ceil( f4 ); - - f1 = clamp(f1,f1,f1); f2 = clamp(f2,f2,f2); f3 = clamp(f3,f3,f3); f4 = clamp(f4,f4,f4); - i1 = clamp(i1,i1,i1); i2 = clamp(i2,i2,i2); i3 = clamp(i3,i3,i3); i4 = clamp(i4,i4,i4); - u1 = clamp(u1,u1,u1); u2 = clamp(u2,u2,u2); u3 = clamp(u3,u3,u3); u4 = clamp(u4,u4,u4); - - // Trigonometric functions - f1 = cos( f1 ); f2 = cos( f2 ); f3 = cos( f3 ); f4 = cos( f4 ); - f1 = sin( f1 ); f2 = sin( f2 ); f3 = sin( f3 ); f4 = sin( f4 ); - f1 = tan( f1 ); f2 = tan( f2 ); f3 = tan( f3 ); f4 = tan( f4 ); - f1 = cosh( f1 ); f2 = cosh( f2 ); f3 = cosh( f3 ); f4 = cosh( f4 ); - f1 = sinh( f1 ); f2 = sinh( f2 ); f3 = sinh( f3 ); f4 = sinh( f4 ); - f1 = tanh( f1 ); f2 = tanh( f2 ); f3 = tanh( f3 ); f4 = tanh( f4 ); - f1 = acos( f1 ); f2 = acos( f2 ); f3 = acos( f3 ); f4 = acos( f4 ); - f1 = asin( f1 ); f2 = asin( f2 ); f3 = asin( f3 ); f4 = asin( f4 ); - f1 = atan( f1 ); f2 = atan( f2 ); f3 = atan( f3 ); f4 = atan( f4 ); - f1 = atan2(f1,f1); f2 = atan2(f2,f2); f3 = atan2(f3,f3); f4 = atan2(f4,f4); - f1 = degrees( f1 ); f2 = degrees( f2 ); f3 = degrees( f3 ); f4 = degrees( f4 ); - f1 = radians( f1 ); f2 = radians( f2 ); f3 = radians( f3 ); f4 = radians( f4 ); - - // Exponential functions - f1 = pow( f1, f1 ); f2 = pow( f2,f2 ); f3 = pow( f3,f3 ); f4 = pow( f4,f4 ); - f1 = exp( f1 ); f2 = exp( f2 ); f3 = exp( f3 ); f4 = exp( f4 ); - f1 = log( f1 ); f2 = log( f2 ); f3 = log( f3 ); f4 = log( f4 ); - f1 = exp2( f1 ); f2 = exp2( f2 ); f3 = exp2( f3 ); f4 = exp2( f4 ); - f1 = log2( f1 ); f2 = log2( f2 ); f3 = log2( f3 ); f4 = log2( f4 ); - f1 = sqrt( f1 ); f2 = sqrt( f2 ); f3 = sqrt( f3 ); f4 = sqrt( f4 ); - f1 = rsqrt( f1 ); f2 = rsqrt( f2 ); f3 = rsqrt( f3 ); f4 = rsqrt( f4 ); - f1 = log10( f1 ); f2 = log10( f2 ); f3 = log10( f3 ); f4 = log10( f4 ); - - i1 = sign ( i1 ); i2 = sign ( i2 ); i3 = sign ( i3 ); i4 = sign ( i4 ); - f1 = sign ( f1 ); f2 = sign ( f2 ); f3 = sign ( f3 ); f4 = sign ( f4 ); - f1 = floor ( f1 ); f2 = floor( f2 ); f3 = floor( f3 ); f4 = floor( f4 ); - f1 = trunc ( f1 ); f2 = trunc( f2 ); f3 = trunc( f3 ); f4 = trunc( f4 ); - f1 = round ( f1 ); f2 = round( f2 ); f3 = round( f3 ); f4 = round( f4 ); - f1 = frac ( f1 ); f2 = frac ( f2 ); f3 = frac ( f3 ); f4 = frac ( f4 ); - - f1 = 1.0; - f2 = float2(1.0, 2.0); - f3 = float3(1.0, 2.0, 3.0); - f4 = float4(1.0,2.0,3.0,4.0); - f1 = fmod ( f1, f1 ); f2 = fmod ( f2, f2 ); f3 = fmod ( f3, f3 ); f4 = fmod ( f4, f4 ); - f1 = modf ( f1, f1 ); f2 = modf ( f2, f2 ); f3 = modf ( f3, f3 ); f4 = modf ( f4, f4 ); - - f1 = min(f1,f1); f2 = min(f2,f2); f3 = min(f3,f3); f4 = min(f4,f4); - i1 = min(i1,i1); i2 = min(i2,i2); i3 = min(i3,i3); i4 = min(i4,i4); - u1 = min(u1,u1); u2 = min(u2,u2); u3 = min(u3,u3); u4 = min(u4,u4); - - f1 = max(f1,f1); f2 = max(f2,f2); f3 = max(f3,f3); f4 = max(f4,f4); - i1 = max(i1,i1); i2 = max(i2,i2); i3 = max(i3,i3); i4 = max(i4,i4); - u1 = max(u1,u1); u2 = max(u2,u2); u3 = max(u3,u3); u4 = max(u4,u4); - - f1 = lerp(f1,f1,f1); f2 = lerp(f2,f2,f2); f3 = lerp(f3,f3,f3); f4 = lerp(f4,f4,f4); - f1 = step(f1,f1); f2 = step(f2,f2); f3 = step(f3,f3); f4 = step(f4,f4); - f1 = smoothstep(f1,f1_,f1); f2 = smoothstep(f2,f2_,f2); f3 = smoothstep(f3,f3_,f3); f4 = smoothstep(f4,f4_,f4); - - b1 = isnan ( f1/Pos.x ); b2 = isnan( f2/Pos.x ); b3 = isnan( f3/Pos.x ); b4 = isnan( f4/Pos.x ); - b1 = isinf ( f1/Pos.x ); b2 = isinf( f2/Pos.x ); b3 = isinf( f3/Pos.x ); b4 = isinf( f4/Pos.x ); - b1 = isfinite ( f1/Pos.x ); b2 = isfinite( f2/Pos.x ); b3 = isfinite( f3/Pos.x ); b4 = isfinite( f4/Pos.x ); - f1 = mad(f1,f1,f1); f2 = mad(f2,f2,f2); f3 = mad(f3,f3,f3); f4 = mad(f4,f4,f4); - - f1 = distance(f1,f1); f1 = distance(f2,f2); f1 = distance(f3,f3); f1 = distance(f4,f4); - f1 = length(f1); f1 = length(f2); f1 = length(f3); f1 = length(f4); - f1 = dot(f1,f1); f1 = dot(f2,f2); f1 = dot(f3,f3); f1 = dot(f4,f4); - f3 = cross( f3, f3 ); - - f1 = 1.0; - f2 = float2(1.0, 2.0); - f3 = float3(1.0, 2.0, 3.0); - f4 = float4(1.0,2.0,3.0,4.0); - f2 = normalize(f2); f3 = normalize(f3); f4 = normalize(f4); - f2 = reflect(f2,f2); f3 = reflect(f3,f3); f4 = reflect(f4,f4); - f2 = refract(f2,f2,1.0); f3 = refract(f3,f3,1.0); f4 = refract(f4,f4,1.0); - f2 = faceforward(f2,f2,f2); f3 = faceforward(f3,f3,f3); f4 = faceforward(f4,f4,f4); - - //f1 = dst(f1,f1); f1 = dst(f2,f2); f1 = dst(f3,f3); f1 = dst(f4,f4); - f1 = rcp(f1); f2 = rcp(f2); f3 = rcp(f3); f4 = rcp(f4); - - f1 = saturate(f1); f2 = saturate(f2); f3 = saturate(f3); f4 = saturate(f4); - sincos(f1,f1,f1_); sincos(f2,f2,f2_); sincos(f3,f3,f3_); sincos(f4,f4,f4_); - - // no bit operations in GLES3.0. SPIRV optimizer also fails to legalize these operations. -#if !GLES30 && !defined(VULKAN) - i1 = countbits(u1); i2 = countbits(u2); i3 = countbits(u3); i4 = countbits(u4); - i1 = countbits(i1); i2 = countbits(i2); i3 = countbits(i3); i4 = countbits(i4); - i1 = firstbithigh(u1); i2 = firstbithigh(u2); i3 = firstbithigh(u3); i4 = firstbithigh(u4); - i1 = firstbithigh(i1); i2 = firstbithigh(i2); i3 = firstbithigh(i3); i4 = firstbithigh(i4); - i1 = firstbitlow(u1); i2 = firstbitlow(u2); i3 = firstbitlow(u3); i4 = firstbitlow(u4); - i1 = firstbitlow(i1); i2 = firstbitlow(i2); i3 = firstbitlow(i3); i4 = firstbitlow(i4); - u1 = reversebits(u1); u2 = reversebits(u2); u3 = reversebits(u3); u4 = reversebits(u4); - i1 = reversebits(i1); i2 = reversebits(i2); i3 = reversebits(i3); i4 = reversebits(i4); - - f1 = frexp(f1_, f1); f2 = frexp(f2_, f2); f3 = frexp(f3_, f3); f4 = frexp(f4_, f4); - f1 = ldexp(f1, i1); f2 = ldexp(f2, i2); f3 = ldexp(f3, i3); f4 = ldexp(f4, i4); -#endif - - - float4x4 f4x4; - f4x4[0] = float4(0.0, 1.0/Pos.x, 2.0/Pos.y, 3.0); - f4x4[1] = float4(0.0, 1.0/Pos.x, 2.0/Pos.y, 3.0); - f4x4[2] = float4(0.0, 1.0/Pos.x, 2.0/Pos.y, 3.0); - f4x4[3] = float4(0.0, 1.0/Pos.x, 2.0/Pos.y, 3.0); - f4x4 = transpose(f4x4); - f1 = determinant( f4x4 ); - - float3x3 f3x3; - f3x3[0] = float3(0.0, 1.0/Pos.x, 2.0/Pos.y); - f3x3[1] = float3(0.0, 1.0/Pos.x, 2.0/Pos.y); - f3x3[2] = float3(0.0, 1.0/Pos.x, 2.0/Pos.y); - f3x3 = transpose(f3x3); - f1 = determinant( f3x3 ); - - float2x2 f2x2; - f2x2[0] = float2(0.0, 1.0/Pos.x); - f2x2[1] = float2(0.0, 1.0/Pos.x); - f2x2 = transpose(f2x2); - f1 = determinant( f2x2 ); - - f1 = ddx( Pos.x ); f2 = ddx( Pos.xy ); f3 = ddx( Pos.xyz ); f4 = ddx( Pos.xyzw ); - f1 = ddy( Pos.x ); f2 = ddy( Pos.xy ); f3 = ddy( Pos.xyz ); f4 = ddy( Pos.xyzw ); - f1 = ddx_coarse( Pos.x ); f2 = ddx_coarse( Pos.xy ); f3 = ddx_coarse( Pos.xyz ); f4 = ddx_coarse( Pos.xyzw ); - f1 = ddy_coarse( Pos.x ); f2 = ddy_coarse( Pos.xy ); f3 = ddy_coarse( Pos.xyz ); f4 = ddy_coarse( Pos.xyzw ); - f1 = ddx_fine( Pos.x ); f2 = ddx_fine( Pos.xy ); f3 = ddx_fine( Pos.xyz ); f4 = ddx_fine( Pos.xyzw ); - f1 = ddy_fine( Pos.x ); f2 = ddy_fine( Pos.xy ); f3 = ddy_fine( Pos.xyz ); f4 = ddy_fine( Pos.xyzw ); -#ifdef FRAGMENT_SHADER - f1 = fwidth( Pos.x ); f2 = fwidth( Pos.xy ); f3 = fwidth( Pos.xyz ); f4 = fwidth( Pos.xyzw ); -#endif - - f1 = asfloat( f1 ); f2 = asfloat( f2 ); f3 = asfloat( f3 ); f4 = asfloat( f4 ); - f1 = asfloat( i1 ); f2 = asfloat( i2 ); f3 = asfloat( i3 ); f4 = asfloat( i4 ); - f1 = asfloat( u1 ); f2 = asfloat( u2 ); f3 = asfloat( u3 ); f4 = asfloat( u4 ); - - i1 = asint( f1 ); i2 = asint( f2 ); i3 = asint( f3 ); i4 = asint( f4 ); - i1 = asint( i1 ); i2 = asint( i2 ); i3 = asint( i3 ); i4 = asint( i4 ); - i1 = asint( u1 ); i2 = asint( u2 ); i3 = asint( u3 ); i4 = asint( u4 ); - - u1 = asuint( f1 ); u2 = asuint( f2 ); u3 = asuint( f3 ); u4 = asuint( f4 ); - u1 = asuint( i1 ); u2 = asuint( i2 ); u3 = asuint( i3 ); u4 = asuint( i4 ); - u1 = asuint( u1 ); u2 = asuint( u2 ); u3 = asuint( u3 ); u4 = asuint( u4 ); - -#if defined(GL_ES) && (__VERSION__>=310) || !defined(GL_ES) && (__VERSION__>=420) - f1 = f16tof32( u1 ); f2 = f16tof32( u2 ); f3 = f16tof32( u3 ); f4 = f16tof32( u4 ); - f1 = f16tof32( i1 ); f2 = f16tof32( i2 ); f3 = f16tof32( i3 ); f4 = f16tof32( i4 ); - u1 = f32tof16( f1 ); u2 = f32tof16( f2 ); u3 = f32tof16( f3 ); u4 = f32tof16( f4 ); -#endif - -#ifndef GL_ES - double d = asdouble( u1, u1 ); -#endif - } -} diff --git a/UnitTests/DiligentCoreAPITest/assets/shaders/ShaderResourceArrayTest.psh b/UnitTests/DiligentCoreAPITest/assets/shaders/ShaderResourceArrayTest.psh deleted file mode 100644 index 51f570c1..00000000 --- a/UnitTests/DiligentCoreAPITest/assets/shaders/ShaderResourceArrayTest.psh +++ /dev/null @@ -1,31 +0,0 @@ - -Texture2D g_tex2DTest[4]; -Texture2D g_tex2DTest2[2]; -Texture2D g_tex2D[2]; -SamplerState g_tex2DTest_sampler[4]; -SamplerState g_tex2DTest2_sampler; -SamplerState g_tex2D_sampler[2]; - -struct VSOut -{ - float2 f2UV : UV; -}; - - -void main(in float4 f4Position : SV_Position, - in VSOut vsOut, - out float4 Color : SV_Target) -{ - float4 Color0 = (g_tex2DTest[0].SampleLevel(g_tex2DTest_sampler[0], vsOut.f2UV, 0) + g_tex2DTest2[0].SampleLevel(g_tex2DTest2_sampler, vsOut.f2UV, 0))/2.0; - float4 Color1 = (g_tex2DTest[0].SampleLevel(g_tex2DTest_sampler[0], vsOut.f2UV, 2) + g_tex2DTest2[1].SampleLevel(g_tex2DTest2_sampler, vsOut.f2UV, 0))/2.0; - float4 Color2 = (g_tex2DTest[2].SampleLevel(g_tex2DTest_sampler[2], vsOut.f2UV, 4) + g_tex2D[0].SampleLevel(g_tex2D_sampler[0], vsOut.f2UV, 0))/2.0; - float4 Color3 = (g_tex2DTest[3].SampleLevel(g_tex2DTest_sampler[3], vsOut.f2UV, 5) + g_tex2D[1].SampleLevel(g_tex2D_sampler[1], vsOut.f2UV, 0))/2.0; - if( vsOut.f2UV.x < 0.5 && vsOut.f2UV.y < 0.5 ) - Color = Color0; - else if( vsOut.f2UV.x > 0.5 && vsOut.f2UV.y < 0.5 ) - Color = Color1; - else if( vsOut.f2UV.x < 0.5 && vsOut.f2UV.y > 0.5 ) - Color = Color2; - else - Color = Color3; -} diff --git a/UnitTests/DiligentCoreAPITest/assets/shaders/ShaderResourceArrayTest.vsh b/UnitTests/DiligentCoreAPITest/assets/shaders/ShaderResourceArrayTest.vsh deleted file mode 100644 index b244a512..00000000 --- a/UnitTests/DiligentCoreAPITest/assets/shaders/ShaderResourceArrayTest.vsh +++ /dev/null @@ -1,15 +0,0 @@ -struct VSOut -{ - float2 f2UV : UV; -}; - -void main(in float3 f3Position : ATTRIB0, - in float2 f2UV : ATTRIB1, - out float4 f4Position : SV_Position, - out VSOut vsOut) -{ - f4Position.xyz = f3Position; - //Out.f4Position.x += In.fOffset; - f4Position.w = 1.0; - vsOut.f2UV = f2UV; -} diff --git a/UnitTests/DiligentCoreAPITest/assets/shaders/ShaderResourceLayout/ConstantBuffers.hlsl b/UnitTests/DiligentCoreAPITest/assets/shaders/ShaderResourceLayout/ConstantBuffers.hlsl deleted file mode 100644 index 1a578bd6..00000000 --- a/UnitTests/DiligentCoreAPITest/assets/shaders/ShaderResourceLayout/ConstantBuffers.hlsl +++ /dev/null @@ -1,67 +0,0 @@ -cbuffer UniformBuff_Stat -{ - float4 g_Data_Stat; -} - -cbuffer UniformBuff_Mut -{ - float4 g_Data_Mut; -} - -cbuffer UniformBuff_Dyn -{ - float4 g_Data_Dyn; -} - -#if ARRAYS_SUPPORTED -struct CBData -{ - float4 Data; -}; -ConstantBuffer UniformBuffArr_Stat[STATIC_CB_ARRAY_SIZE]; // 2 -ConstantBuffer UniformBuffArr_Mut [MUTABLE_CB_ARRAY_SIZE]; // 4 -ConstantBuffer UniformBuffArr_Dyn [DYNAMIC_CB_ARRAY_SIZE]; // 3 -#endif - -float4 UseResources() -{ - float4 f4Color = float4(0.0, 0.0, 0.0, 0.0); - f4Color += g_Data_Stat; - f4Color += g_Data_Mut; - f4Color += g_Data_Dyn; - - // glslang is not smart enough to unroll the loops even when explicitly told to do so -#if ARRAYS_SUPPORTED - f4Color += UniformBuffArr_Stat[0].Data; - f4Color += UniformBuffArr_Stat[1].Data; - - f4Color += UniformBuffArr_Mut[0].Data; -#if MUTABLE_CB_ARRAY_SIZE == 4 - f4Color += UniformBuffArr_Mut[1].Data; - f4Color += UniformBuffArr_Mut[2].Data; - f4Color += UniformBuffArr_Mut[3].Data; -#endif - - f4Color += UniformBuffArr_Dyn[0].Data; -#if DYNAMIC_CB_ARRAY_SIZE == 3 - f4Color += UniformBuffArr_Dyn[1].Data; - f4Color += UniformBuffArr_Dyn[2].Data; -#endif - -#endif - - return f4Color; -} - -void VSMain(out float4 f4Color : COLOR, - out float4 f4Position : SV_Position) -{ - f4Color = UseResources(); - f4Position = float4(0.0, 0.0, 0.0, 1.0); -} - -float4 PSMain(in float4 in_f4Color : COLOR, - in float4 f4Position : SV_Position) : SV_Target -{ - return in_f4Color + UseResources(); -} diff --git a/UnitTests/DiligentCoreAPITest/assets/shaders/ShaderResourceLayout/FormattedBuffers.hlsl b/UnitTests/DiligentCoreAPITest/assets/shaders/ShaderResourceLayout/FormattedBuffers.hlsl deleted file mode 100644 index a32ae31c..00000000 --- a/UnitTests/DiligentCoreAPITest/assets/shaders/ShaderResourceLayout/FormattedBuffers.hlsl +++ /dev/null @@ -1,44 +0,0 @@ -Buffer g_Buff_Static; -Buffer g_Buff_Mut; -Buffer g_Buff_Dyn; - -Buffer g_BuffArr_Static[STATIC_BUFF_ARRAY_SIZE]; // 4 -Buffer g_BuffArr_Mut [MUTABLE_BUFF_ARRAY_SIZE]; // 3 -Buffer g_BuffArr_Dyn [DYNAMIC_BUFF_ARRAY_SIZE]; // 2 - -float4 UseResources() -{ - float4 f4Color = float4(0.0, 0.0, 0.0, 0.0); - f4Color += g_Buff_Static.Load(0); - f4Color += g_Buff_Mut. Load(0); - f4Color += g_Buff_Dyn. Load(0); - - // glslang is not smart enough to unroll the loops even when explicitly told to do so - - f4Color += g_BuffArr_Static[0].Load(0); - f4Color += g_BuffArr_Static[1].Load(0); - f4Color += g_BuffArr_Static[2].Load(0); - f4Color += g_BuffArr_Static[3].Load(0); - - f4Color += g_BuffArr_Mut[0].Load(0); - f4Color += g_BuffArr_Mut[1].Load(0); - f4Color += g_BuffArr_Mut[2].Load(0); - - f4Color += g_BuffArr_Dyn[0].Load(0); - f4Color += g_BuffArr_Dyn[1].Load(0); - - return f4Color; -} - -void VSMain(out float4 f4Color : COLOR, - out float4 f4Position : SV_Position) -{ - f4Color = UseResources(); - f4Position = float4(0.0, 0.0, 0.0, 1.0); -} - -float4 PSMain(in float4 in_f4Color : COLOR, - in float4 f4Position : SV_Position) : SV_Target -{ - return in_f4Color + UseResources(); -} diff --git a/UnitTests/DiligentCoreAPITest/assets/shaders/ShaderResourceLayout/RWFormattedBuffers.hlsl b/UnitTests/DiligentCoreAPITest/assets/shaders/ShaderResourceLayout/RWFormattedBuffers.hlsl deleted file mode 100644 index 30e3d321..00000000 --- a/UnitTests/DiligentCoreAPITest/assets/shaders/ShaderResourceLayout/RWFormattedBuffers.hlsl +++ /dev/null @@ -1,39 +0,0 @@ -RWBuffer g_RWBuff_Static; -RWBuffer g_RWBuff_Mut; -RWBuffer g_RWBuff_Dyn; - -RWBuffer g_RWBuffArr_Static[STATIC_BUFF_ARRAY_SIZE]; // 4 or 1 in D3D11 -RWBuffer g_RWBuffArr_Mut [MUTABLE_BUFF_ARRAY_SIZE]; // 3 or 2 in D3D11 -RWBuffer g_RWBuffArr_Dyn [DYNAMIC_BUFF_ARRAY_SIZE]; // 2 - -void UseResources() -{ - float4 f4Data = float4(1.0, 2.0, 3.0, 4.0); - g_RWBuff_Static[0] = f4Data; - g_RWBuff_Mut [0] = f4Data; - g_RWBuff_Dyn [0] = f4Data; - - // glslang is not smart enough to unroll the loops even when explicitly told to do so - - g_RWBuffArr_Static[0][0] = f4Data; -#if (STATIC_BUFF_ARRAY_SIZE == 4) - g_RWBuffArr_Static[1][0] = f4Data; - g_RWBuffArr_Static[2][0] = f4Data; - g_RWBuffArr_Static[3][0] = f4Data; -#endif - - g_RWBuffArr_Mut[0][0] = f4Data; - g_RWBuffArr_Mut[1][0] = f4Data; -#if (MUTABLE_BUFF_ARRAY_SIZE == 3) - g_RWBuffArr_Mut[2][0] = f4Data; -#endif - - g_RWBuffArr_Dyn[0][0] = f4Data; - g_RWBuffArr_Dyn[1][0] = f4Data; -} - -[numthreads(1,1,1)] -void main() -{ - UseResources(); -} diff --git a/UnitTests/DiligentCoreAPITest/assets/shaders/ShaderResourceLayout/RWStructuredBuffers.glsl b/UnitTests/DiligentCoreAPITest/assets/shaders/ShaderResourceLayout/RWStructuredBuffers.glsl deleted file mode 100644 index a4a6c257..00000000 --- a/UnitTests/DiligentCoreAPITest/assets/shaders/ShaderResourceLayout/RWStructuredBuffers.glsl +++ /dev/null @@ -1,62 +0,0 @@ -layout(std140, binding = 0) writeonly buffer g_RWBuff_Static -{ - vec4 data; -}g_StorageBuff_Static; - -layout(std140, binding = 1) writeonly buffer g_RWBuff_Mut -{ - vec4 data; -}g_StorageBuff_Mut; - -layout(std140, binding = 2) writeonly buffer g_RWBuff_Dyn -{ - vec4 data; -}g_StorageBuff_Dyn; - - -layout(std140, binding = 3) writeonly buffer g_RWBuffArr_Static -{ - vec4 data; -}g_StorageBuffArr_Static[STATIC_BUFF_ARRAY_SIZE]; // 4 or 1 in OpenGL - -layout(std140, binding = 7) writeonly buffer g_RWBuffArr_Mut -{ - vec4 data; -}g_StorageBuffArr_Mut[MUTABLE_BUFF_ARRAY_SIZE]; // 3 or 2 in OpenGL - -layout(std140, binding = 10) writeonly buffer g_RWBuffArr_Dyn -{ - vec4 data; -}g_StorageBuffArr_Dyn[DYNAMIC_BUFF_ARRAY_SIZE]; // 2 - -void UseResources() -{ - vec4 Data = vec4(1.0, 2.0, 3.0, 4.0); - g_StorageBuff_Static.data = Data; - g_StorageBuff_Mut .data = Data; - g_StorageBuff_Dyn .data = Data; - - // glslang is not smart enough to unroll the loops even when explicitly told to do so - - g_StorageBuffArr_Static[0].data = Data; -#if (STATIC_BUFF_ARRAY_SIZE == 4) - g_StorageBuffArr_Static[1].data = Data; - g_StorageBuffArr_Static[2].data = Data; - g_StorageBuffArr_Static[3].data = Data; -#endif - - g_StorageBuffArr_Mut[0].data = Data; - g_StorageBuffArr_Mut[1].data = Data; -#if (MUTABLE_BUFF_ARRAY_SIZE == 3) - g_StorageBuffArr_Mut[2].data = Data; -#endif - - g_StorageBuffArr_Dyn[0].data = Data; - g_StorageBuffArr_Dyn[1].data = Data; -} - -layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in; -void main() -{ - UseResources(); -} diff --git a/UnitTests/DiligentCoreAPITest/assets/shaders/ShaderResourceLayout/RWStructuredBuffers.hlsl b/UnitTests/DiligentCoreAPITest/assets/shaders/ShaderResourceLayout/RWStructuredBuffers.hlsl deleted file mode 100644 index 99e68ca8..00000000 --- a/UnitTests/DiligentCoreAPITest/assets/shaders/ShaderResourceLayout/RWStructuredBuffers.hlsl +++ /dev/null @@ -1,44 +0,0 @@ -struct BufferData -{ - float4 data; -}; - -RWStructuredBuffer g_RWBuff_Static; -RWStructuredBuffer g_RWBuff_Mut; -RWStructuredBuffer g_RWBuff_Dyn; - -RWStructuredBuffer g_RWBuffArr_Static[STATIC_BUFF_ARRAY_SIZE]; // 4 or 1 in D3D11 -RWStructuredBuffer g_RWBuffArr_Mut [MUTABLE_BUFF_ARRAY_SIZE]; // 3 or 2 in D3D11 -RWStructuredBuffer g_RWBuffArr_Dyn [DYNAMIC_BUFF_ARRAY_SIZE]; // 2 - -void UseResources() -{ - float4 f4Data = float4(1.0, 2.0, 3.0, 4.0); - g_RWBuff_Static[0].data = f4Data; - g_RWBuff_Mut [0].data = f4Data; - g_RWBuff_Dyn [0].data = f4Data; - - // glslang is not smart enough to unroll the loops even when explicitly told to do so - - g_RWBuffArr_Static[0][0].data = f4Data; -#if (STATIC_BUFF_ARRAY_SIZE == 4) - g_RWBuffArr_Static[1][0].data = f4Data; - g_RWBuffArr_Static[2][0].data = f4Data; - g_RWBuffArr_Static[3][0].data = f4Data; -#endif - - g_RWBuffArr_Mut[0][0].data = f4Data; - g_RWBuffArr_Mut[1][0].data = f4Data; -#if (MUTABLE_BUFF_ARRAY_SIZE == 3) - g_RWBuffArr_Mut[2][0].data = f4Data; -#endif - - g_RWBuffArr_Dyn[0][0].data = f4Data; - g_RWBuffArr_Dyn[1][0].data = f4Data; -} - -[numthreads(1,1,1)] -void main() -{ - UseResources(); -} diff --git a/UnitTests/DiligentCoreAPITest/assets/shaders/ShaderResourceLayout/RWTextures.hlsl b/UnitTests/DiligentCoreAPITest/assets/shaders/ShaderResourceLayout/RWTextures.hlsl deleted file mode 100644 index c11ce380..00000000 --- a/UnitTests/DiligentCoreAPITest/assets/shaders/ShaderResourceLayout/RWTextures.hlsl +++ /dev/null @@ -1,39 +0,0 @@ -RWTexture2D g_RWTex2D_Static; -RWTexture2D g_RWTex2D_Mut; -RWTexture2D g_RWTex2D_Dyn; - -RWTexture2D g_RWTex2DArr_Static[STATIC_TEX_ARRAY_SIZE]; // 2 -RWTexture2D g_RWTex2DArr_Mut [MUTABLE_TEX_ARRAY_SIZE]; // 4 or 2 in D3D11 -RWTexture2D g_RWTex2DArr_Dyn [DYNAMIC_TEX_ARRAY_SIZE]; // 3 or 1 in D3D11 - -void UseResources() -{ - float4 f4Color = float4(1.0, 2.0, 3.0, 4.0); - g_RWTex2D_Static[int2(0,0)] = f4Color; - g_RWTex2D_Mut [int2(0,0)] = f4Color; - g_RWTex2D_Dyn [int2(0,0)] = f4Color; - - // glslang is not smart enough to unroll the loops even when explicitly told to do so - - g_RWTex2DArr_Static[0][int2(0,0)] = f4Color; - g_RWTex2DArr_Static[1][int2(0,0)] = f4Color; - - g_RWTex2DArr_Mut[0][int2(0,0)] = f4Color; - g_RWTex2DArr_Mut[1][int2(0,0)] = f4Color; -#if (MUTABLE_TEX_ARRAY_SIZE == 4) - g_RWTex2DArr_Mut[2][int2(0,0)] = f4Color; - g_RWTex2DArr_Mut[3][int2(0,0)] = f4Color; -#endif - - g_RWTex2DArr_Dyn[0][int2(0,0)] = f4Color; -#if (DYNAMIC_TEX_ARRAY_SIZE == 3) - g_RWTex2DArr_Dyn[1][int2(0,0)] = f4Color; - g_RWTex2DArr_Dyn[2][int2(0,0)] = f4Color; -#endif -} - -[numthreads(1,1,1)] -void main() -{ - UseResources(); -} diff --git a/UnitTests/DiligentCoreAPITest/assets/shaders/ShaderResourceLayout/Samplers.hlsl b/UnitTests/DiligentCoreAPITest/assets/shaders/ShaderResourceLayout/Samplers.hlsl deleted file mode 100644 index ad8cbe72..00000000 --- a/UnitTests/DiligentCoreAPITest/assets/shaders/ShaderResourceLayout/Samplers.hlsl +++ /dev/null @@ -1,49 +0,0 @@ -Texture2D g_Tex2D; - -SamplerState g_Sam_Static; -SamplerState g_Sam_Mut; -SamplerState g_Sam_Dyn; - -SamplerState g_SamArr_Static[STATIC_SAM_ARRAY_SIZE]; // 2 -SamplerState g_SamArr_Mut [MUTABLE_SAM_ARRAY_SIZE]; // 4 -SamplerState g_SamArr_Dyn [DYNAMIC_SAM_ARRAY_SIZE]; // 3 - -SamplerState g_Sampler; - -float4 UseResources() -{ - float2 UV = float2(0.0, 0.0); - float4 f4Color = float4(0.0, 0.0, 0.0, 0.0); - f4Color += g_Tex2D.SampleLevel(g_Sam_Static, UV.xy, 0.0); - f4Color += g_Tex2D.SampleLevel(g_Sam_Mut, UV.xy, 0.0); - f4Color += g_Tex2D.SampleLevel(g_Sam_Dyn, UV.xy, 0.0); - - // glslang is not smart enough to unroll the loops even when explicitly told to do so - - f4Color += g_Tex2D.SampleLevel(g_SamArr_Static[0], UV.xy, 0.0); - f4Color += g_Tex2D.SampleLevel(g_SamArr_Static[1], UV.xy, 0.0); - - f4Color += g_Tex2D.SampleLevel(g_SamArr_Mut[0], UV.xy, 0.0); - f4Color += g_Tex2D.SampleLevel(g_SamArr_Mut[1], UV.xy, 0.0); - f4Color += g_Tex2D.SampleLevel(g_SamArr_Mut[2], UV.xy, 0.0); - f4Color += g_Tex2D.SampleLevel(g_SamArr_Mut[3], UV.xy, 0.0); - - f4Color += g_Tex2D.SampleLevel(g_SamArr_Dyn[0], UV.xy, 0.0); - f4Color += g_Tex2D.SampleLevel(g_SamArr_Dyn[1], UV.xy, 0.0); - f4Color += g_Tex2D.SampleLevel(g_SamArr_Dyn[2], UV.xy, 0.0); - - return f4Color; -} - -void VSMain(out float4 f4Color : COLOR, - out float4 f4Position : SV_Position) -{ - f4Color = UseResources(); - f4Position = float4(0.0, 0.0, 0.0, 1.0); -} - -float4 PSMain(in float4 in_f4Color : COLOR, - in float4 f4Position : SV_Position) : SV_Target -{ - return in_f4Color + UseResources(); -} diff --git a/UnitTests/DiligentCoreAPITest/assets/shaders/ShaderResourceLayout/StaticSamplers.hlsl b/UnitTests/DiligentCoreAPITest/assets/shaders/ShaderResourceLayout/StaticSamplers.hlsl deleted file mode 100644 index 01418379..00000000 --- a/UnitTests/DiligentCoreAPITest/assets/shaders/ShaderResourceLayout/StaticSamplers.hlsl +++ /dev/null @@ -1,54 +0,0 @@ -Texture2D g_Tex2D_Static; -Texture2D g_Tex2D_Mut; -Texture2D g_Tex2D_Dyn; - -Texture2D g_Tex2DArr_Static[STATIC_TEX_ARRAY_SIZE]; // 2 -Texture2D g_Tex2DArr_Mut [MUTABLE_TEX_ARRAY_SIZE]; // 4 -Texture2D g_Tex2DArr_Dyn [DYNAMIC_TEX_ARRAY_SIZE]; // 3 - -SamplerState g_Tex2D_Static_sampler; -SamplerState g_Tex2D_Mut_sampler; -SamplerState g_Tex2D_Dyn_sampler; - -SamplerState g_Tex2DArr_Static_sampler; -SamplerState g_Tex2DArr_Mut_sampler [MUTABLE_TEX_ARRAY_SIZE]; -SamplerState g_Tex2DArr_Dyn_sampler [DYNAMIC_TEX_ARRAY_SIZE]; - - -float4 UseResources() -{ - float2 UV = float2(0.0, 0.0); - float4 f4Color = float4(0.0, 0.0, 0.0, 0.0); - f4Color += g_Tex2D_Static.SampleLevel(g_Tex2D_Static_sampler, UV.xy, 0.0); - f4Color += g_Tex2D_Mut. SampleLevel(g_Tex2D_Mut_sampler, UV.xy, 0.0); - f4Color += g_Tex2D_Dyn. SampleLevel(g_Tex2D_Dyn_sampler, UV.xy, 0.0); - - // glslang is not smart enough to unroll the loops even when explicitly told to do so - - f4Color += g_Tex2DArr_Static[0].SampleLevel(g_Tex2DArr_Static_sampler, UV.xy, 0.0); - f4Color += g_Tex2DArr_Static[1].SampleLevel(g_Tex2DArr_Static_sampler, UV.xy, 0.0); - - f4Color += g_Tex2DArr_Mut[0].SampleLevel(g_Tex2DArr_Mut_sampler[0], UV.xy, 0.0); - f4Color += g_Tex2DArr_Mut[1].SampleLevel(g_Tex2DArr_Mut_sampler[1], UV.xy, 0.0); - f4Color += g_Tex2DArr_Mut[2].SampleLevel(g_Tex2DArr_Mut_sampler[2], UV.xy, 0.0); - f4Color += g_Tex2DArr_Mut[3].SampleLevel(g_Tex2DArr_Mut_sampler[3], UV.xy, 0.0); - - f4Color += g_Tex2DArr_Dyn[0].SampleLevel(g_Tex2DArr_Dyn_sampler[0], UV.xy, 0.0); - f4Color += g_Tex2DArr_Dyn[1].SampleLevel(g_Tex2DArr_Dyn_sampler[1], UV.xy, 0.0); - f4Color += g_Tex2DArr_Dyn[2].SampleLevel(g_Tex2DArr_Dyn_sampler[2], UV.xy, 0.0); - - return f4Color; -} - -void VSMain(out float4 f4Color : COLOR, - out float4 f4Position : SV_Position) -{ - f4Color = UseResources(); - f4Position = float4(0.0, 0.0, 0.0, 1.0); -} - -float4 PSMain(in float4 in_f4Color : COLOR, - in float4 f4Position : SV_Position) : SV_Target -{ - return in_f4Color + UseResources(); -} diff --git a/UnitTests/DiligentCoreAPITest/assets/shaders/ShaderResourceLayout/StructuredBuffers.glsl b/UnitTests/DiligentCoreAPITest/assets/shaders/ShaderResourceLayout/StructuredBuffers.glsl deleted file mode 100644 index 91e74cca..00000000 --- a/UnitTests/DiligentCoreAPITest/assets/shaders/ShaderResourceLayout/StructuredBuffers.glsl +++ /dev/null @@ -1,89 +0,0 @@ -layout(std140) readonly buffer g_Buff_Static -{ - vec4 data; -}g_StorageBuff_Static; - -layout(std140) readonly buffer g_Buff_Mut -{ - vec4 data; -}g_StorageBuff_Mut; - -layout(std140) readonly buffer g_Buff_Dyn -{ - vec4 data; -}g_StorageBuff_Dyn; - - -#ifdef FRAGMENT_SHADER -// Vulkan only allows 16 dynamic storage buffer bindings among all stages, so -// use arrays only in fragment shader -layout(std140) readonly buffer g_BuffArr_Static -{ - vec4 data; -}g_StorageBuffArr_Static[STATIC_BUFF_ARRAY_SIZE]; // 4 - -layout(std140) readonly buffer g_BuffArr_Mut -{ - vec4 data; -}g_StorageBuffArr_Mut[MUTABLE_BUFF_ARRAY_SIZE]; // 3 - -layout(std140) readonly buffer g_BuffArr_Dyn -{ - vec4 data; -}g_StorageBuffArr_Dyn[DYNAMIC_BUFF_ARRAY_SIZE]; // 2 -#endif - -vec4 UseResources() -{ - vec4 f4Color = vec4(0.0, 0.0, 0.0, 0.0); - f4Color += g_StorageBuff_Static.data; - f4Color += g_StorageBuff_Mut .data; - f4Color += g_StorageBuff_Dyn .data; - - // glslang is not smart enough to unroll the loops even when explicitly told to do so -#ifdef FRAGMENT_SHADER - f4Color += g_StorageBuffArr_Static[0].data; - f4Color += g_StorageBuffArr_Static[1].data; - f4Color += g_StorageBuffArr_Static[2].data; - f4Color += g_StorageBuffArr_Static[3].data; - - f4Color += g_StorageBuffArr_Mut[0].data; - f4Color += g_StorageBuffArr_Mut[1].data; - f4Color += g_StorageBuffArr_Mut[2].data; - - f4Color += g_StorageBuffArr_Dyn[0].data; - f4Color += g_StorageBuffArr_Dyn[1].data; -#endif - return f4Color; -} - -#ifdef VERTEX_SHADER - -//To use any built-in input or output in the gl_PerVertex and -//gl_PerFragment blocks in separable program objects, shader code must -//redeclare those blocks prior to use. -// -// Declaring this block causes compilation error on NVidia GLES -#ifndef GL_ES -out gl_PerVertex -{ - vec4 gl_Position; -}; -#endif - -layout(location = 0)out vec4 out_Color; -void main() -{ - out_Color = UseResources(); - gl_Position = vec4(0.0, 0.0, 0.0, 1.0); -} -#endif - -#ifdef FRAGMENT_SHADER -layout(location = 0)in vec4 in_Color; -layout(location = 0)out vec4 out_Color; -void main() -{ - out_Color = UseResources(); -} -#endif diff --git a/UnitTests/DiligentCoreAPITest/assets/shaders/ShaderResourceLayout/StructuredBuffers.hlsl b/UnitTests/DiligentCoreAPITest/assets/shaders/ShaderResourceLayout/StructuredBuffers.hlsl deleted file mode 100644 index ad02a84c..00000000 --- a/UnitTests/DiligentCoreAPITest/assets/shaders/ShaderResourceLayout/StructuredBuffers.hlsl +++ /dev/null @@ -1,49 +0,0 @@ -struct BufferData -{ - float4 data; -}; - -StructuredBuffer g_Buff_Static; -StructuredBuffer g_Buff_Mut; -StructuredBuffer g_Buff_Dyn; - -StructuredBuffer g_BuffArr_Static[STATIC_BUFF_ARRAY_SIZE]; // 4 -StructuredBuffer g_BuffArr_Mut [MUTABLE_BUFF_ARRAY_SIZE]; // 3 -StructuredBuffer g_BuffArr_Dyn [DYNAMIC_BUFF_ARRAY_SIZE]; // 2 - -float4 UseResources() -{ - float4 f4Color = float4(0.0, 0.0, 0.0, 0.0); - f4Color += g_Buff_Static[0].data; - f4Color += g_Buff_Mut [0].data; - f4Color += g_Buff_Dyn [0].data; - - // glslang is not smart enough to unroll the loops even when explicitly told to do so - - f4Color += g_BuffArr_Static[0][0].data; - f4Color += g_BuffArr_Static[1][0].data; - f4Color += g_BuffArr_Static[2][0].data; - f4Color += g_BuffArr_Static[3][0].data; - - f4Color += g_BuffArr_Mut[0][0].data; - f4Color += g_BuffArr_Mut[1][0].data; - f4Color += g_BuffArr_Mut[2][0].data; - - f4Color += g_BuffArr_Dyn[0][0].data; - f4Color += g_BuffArr_Dyn[1][0].data; - - return f4Color; -} - -void VSMain(out float4 f4Color : COLOR, - out float4 f4Position : SV_Position) -{ - f4Color = UseResources(); - f4Position = float4(0.0, 0.0, 0.0, 1.0); -} - -float4 PSMain(in float4 in_f4Color : COLOR, - in float4 f4Position : SV_Position) : SV_Target -{ - return in_f4Color + UseResources(); -} diff --git a/UnitTests/DiligentCoreAPITest/assets/shaders/ShaderResourceLayout/Textures.hlsl b/UnitTests/DiligentCoreAPITest/assets/shaders/ShaderResourceLayout/Textures.hlsl deleted file mode 100644 index 5f9ed026..00000000 --- a/UnitTests/DiligentCoreAPITest/assets/shaders/ShaderResourceLayout/Textures.hlsl +++ /dev/null @@ -1,47 +0,0 @@ -Texture2D g_Tex2D_Static; -Texture2D g_Tex2D_Mut; -Texture2D g_Tex2D_Dyn; - -Texture2D g_Tex2DArr_Static[STATIC_TEX_ARRAY_SIZE]; // 2 -Texture2D g_Tex2DArr_Mut [MUTABLE_TEX_ARRAY_SIZE]; // 4 -Texture2D g_Tex2DArr_Dyn [DYNAMIC_TEX_ARRAY_SIZE]; // 3 - -SamplerState g_Sampler; - -float4 UseResources() -{ - float2 UV = float2(0.0, 0.0); - float4 f4Color = float4(0.0, 0.0, 0.0, 0.0); - f4Color += g_Tex2D_Static.SampleLevel(g_Sampler, UV.xy, 0.0); - f4Color += g_Tex2D_Mut. SampleLevel(g_Sampler, UV.xy, 0.0); - f4Color += g_Tex2D_Dyn. SampleLevel(g_Sampler, UV.xy, 0.0); - - // glslang is not smart enough to unroll the loops even when explicitly told to do so - - f4Color += g_Tex2DArr_Static[0].SampleLevel(g_Sampler, UV.xy, 0.0); - f4Color += g_Tex2DArr_Static[1].SampleLevel(g_Sampler, UV.xy, 0.0); - - f4Color += g_Tex2DArr_Mut[0].SampleLevel(g_Sampler, UV.xy, 0.0); - f4Color += g_Tex2DArr_Mut[1].SampleLevel(g_Sampler, UV.xy, 0.0); - f4Color += g_Tex2DArr_Mut[2].SampleLevel(g_Sampler, UV.xy, 0.0); - f4Color += g_Tex2DArr_Mut[3].SampleLevel(g_Sampler, UV.xy, 0.0); - - f4Color += g_Tex2DArr_Dyn[0].SampleLevel(g_Sampler, UV.xy, 0.0); - f4Color += g_Tex2DArr_Dyn[1].SampleLevel(g_Sampler, UV.xy, 0.0); - f4Color += g_Tex2DArr_Dyn[2].SampleLevel(g_Sampler, UV.xy, 0.0); - - return f4Color; -} - -void VSMain(out float4 f4Color : COLOR, - out float4 f4Position : SV_Position) -{ - f4Color = UseResources(); - f4Position = float4(0.0, 0.0, 0.0, 1.0); -} - -float4 PSMain(in float4 in_f4Color : COLOR, - in float4 f4Position : SV_Position) : SV_Target -{ - return in_f4Color + UseResources(); -} diff --git a/UnitTests/DiligentCoreAPITest/assets/shaders/ShaderVariableAccessTestDX.psh b/UnitTests/DiligentCoreAPITest/assets/shaders/ShaderVariableAccessTestDX.psh deleted file mode 100644 index fff038ed..00000000 --- a/UnitTests/DiligentCoreAPITest/assets/shaders/ShaderVariableAccessTestDX.psh +++ /dev/null @@ -1,79 +0,0 @@ -Texture2D g_tex2D_Static; -Texture2D g_tex2D_Mut; -Texture2D g_tex2D_MutArr[2]; -Texture2D g_tex2D_Dyn; -Texture2D g_tex2D_DynArr[2]; -Texture2D g_tex2D_StaticArr[2]; - -SamplerState g_tex2D_Static_sampler; -SamplerState g_tex2D_Mut_sampler; -SamplerState g_tex2D_Dyn_sampler; -SamplerState g_tex2D_MutArr_sampler; -SamplerState g_tex2D_DynArr_sampler; -SamplerState g_tex2D_StaticArr_sampler; - -cbuffer UniformBuff_Stat -{ - float4 g_f4Color0; -} - -cbuffer UniformBuff_Stat2 -{ - float4 g_f4Color01; -} - -cbuffer UniformBuff_Mut -{ - float4 g_f4Color1; -} - -cbuffer UniformBuff_Dyn -{ - float4 g_f4Color2; -} - -RWTexture2D g_rwtex2D_Static; -RWTexture2D g_rwtex2D_Static2; -RWTexture2D g_rwtex2D_Mut; -RWTexture2D g_rwtex2D_Dyn; - -RWByteAddressBuffer g_rwBuff_Static; -RWBuffer g_rwBuff_Mut; -RWBuffer g_rwBuff_Dyn; - -Buffer g_Buffer_Static; -Buffer g_Buffer_StaticArr[2]; -ByteAddressBuffer g_Buffer_Mut; -Buffer g_Buffer_MutArr[2]; -Buffer g_Buffer_Dyn; -Buffer g_Buffer_DynArr[2]; - -struct VSOut -{ - float4 f4Position : SV_Position; - float4 f4Color : COLOR; -}; - - -float4 main(VSOut In) : SV_Target -{ - float4 Color = In.f4Color; - Color += g_tex2D_Static.SampleLevel(g_tex2D_Static_sampler, float2(0.5,0.5), 0.0); - Color += g_tex2D_StaticArr[0].SampleLevel(g_tex2D_StaticArr_sampler, float2(0.5,0.5), 0.0) + g_tex2D_StaticArr[1].SampleLevel(g_tex2D_StaticArr_sampler, float2(0.5,0.5), 0.0); - Color += g_tex2D_Mut.SampleLevel(g_tex2D_Mut_sampler, float2(0.5,0.5), 0.0); - Color += g_tex2D_MutArr[0].SampleLevel(g_tex2D_MutArr_sampler, float2(0.5,0.5), 0.0) + g_tex2D_MutArr[1].SampleLevel(g_tex2D_MutArr_sampler, float2(0.5,0.5), 0.0); - Color += g_tex2D_Dyn.SampleLevel(g_tex2D_Dyn_sampler, float2(0.5,0.5), 0.0); - Color += g_tex2D_DynArr[0].SampleLevel(g_tex2D_DynArr_sampler, float2(0.5,0.5), 0.0) + g_tex2D_DynArr[1].SampleLevel(g_tex2D_DynArr_sampler, float2(0.5,0.5), 0.0); - Color += g_f4Color0 + g_f4Color01 + g_f4Color1 + g_f4Color2; - Color += g_rwtex2D_Static.Load(int2(0,0)) + g_rwtex2D_Mut.Load(int2(0,0)) + g_rwtex2D_Dyn.Load(uint2(0,0)) + g_rwtex2D_Static2.Load(uint2(0,0)); - Color += asfloat(g_rwBuff_Static.Load(0)) + g_rwBuff_Mut.Load(0) + g_rwBuff_Dyn.Load(0); - - Color += g_Buffer_Static.Load(0); - Color += g_Buffer_StaticArr[0].Load(0) + g_Buffer_StaticArr[1].Load(0); - Color += asfloat(g_Buffer_Mut.Load(0)); - Color += g_Buffer_MutArr[0].Load(0) + g_Buffer_MutArr[1].Load(0); - Color += g_Buffer_Dyn.Load(0); - Color += g_Buffer_DynArr[0].Load(0) + g_Buffer_DynArr[1].Load(0); - - return Color; -} diff --git a/UnitTests/DiligentCoreAPITest/assets/shaders/ShaderVariableAccessTestDX.vsh b/UnitTests/DiligentCoreAPITest/assets/shaders/ShaderVariableAccessTestDX.vsh deleted file mode 100644 index 6da62ea5..00000000 --- a/UnitTests/DiligentCoreAPITest/assets/shaders/ShaderVariableAccessTestDX.vsh +++ /dev/null @@ -1,69 +0,0 @@ -Texture2D g_tex2D_Static; -Texture2D g_tex2D_StaticArr[2]; -Texture2D g_tex2D_Mut; -Texture2D g_tex2D_MutArr[2]; -Texture2D g_tex2D_Dyn; -Texture2D g_tex2D_DynArr[2]; - -SamplerState g_tex2D_Static_sampler; -SamplerState g_tex2D_StaticArr_sampler; -SamplerState g_tex2D_Mut_sampler; -SamplerState g_tex2D_MutArr_sampler; -SamplerState g_tex2D_Dyn_sampler; -SamplerState g_tex2D_DynArr_sampler; - -cbuffer UniformBuff_Stat -{ - float4 g_f4Color0; -} - -cbuffer UniformBuff_Stat2 -{ - float4 g_f4Color01; -} - -cbuffer UniformBuff_Mut -{ - float4 g_f4Color1; -} - -cbuffer UniformBuff_Dyn -{ - float4 g_f4Color2; -} - -Buffer g_Buffer_Static; -Buffer g_Buffer_StaticArr[2]; -Buffer g_Buffer_Mut; -Buffer g_Buffer_MutArr[2]; -Buffer g_Buffer_Dyn; -Buffer g_Buffer_DynArr[2]; - -struct VSOut -{ - float4 f4Position : SV_Position; - float4 f4Color : COLOR; -}; - - -VSOut main() -{ - VSOut Out; - Out.f4Position = float4(0.0, 0.0, 0.0, 0.0); - Out.f4Color = float4(0.0, 0.0, 0.0, 0.0); - Out.f4Color += g_tex2D_Static.SampleLevel(g_tex2D_Static_sampler, float2(0.5,0.5), 0.0); - Out.f4Color += g_tex2D_StaticArr[0].SampleLevel(g_tex2D_StaticArr_sampler, float2(0.5,0.5), 0.0) + g_tex2D_StaticArr[1].SampleLevel(g_tex2D_StaticArr_sampler, float2(0.5,0.5), 0.0); - Out.f4Color += g_tex2D_Mut.SampleLevel(g_tex2D_Mut_sampler, float2(0.5,0.5), 0.0); - Out.f4Color += g_tex2D_MutArr[0].SampleLevel(g_tex2D_MutArr_sampler, float2(0.5,0.5), 0.0) + g_tex2D_MutArr[1].SampleLevel(g_tex2D_MutArr_sampler, float2(0.5,0.5), 0.0); - Out.f4Color += g_tex2D_Dyn.SampleLevel(g_tex2D_Dyn_sampler, float2(0.5,0.5), 0.0); - Out.f4Color += g_tex2D_DynArr[0].SampleLevel(g_tex2D_DynArr_sampler, float2(0.5,0.5), 0.0) + g_tex2D_DynArr[1].SampleLevel(g_tex2D_DynArr_sampler, float2(0.5,0.5), 0.0); - Out.f4Color += g_f4Color0 + g_f4Color01 + g_f4Color1 + g_f4Color2; - Out.f4Color += g_Buffer_Static.Load(0); - Out.f4Color += g_Buffer_StaticArr[0].Load(0) + g_Buffer_StaticArr[1].Load(0); - Out.f4Color += g_Buffer_Mut.Load(0); - Out.f4Color += g_Buffer_MutArr[0].Load(0) + g_Buffer_MutArr[1].Load(0); - Out.f4Color += g_Buffer_Dyn.Load(0); - Out.f4Color += g_Buffer_DynArr[0].Load(0) + g_Buffer_DynArr[1].Load(0); - - return Out; -} diff --git a/UnitTests/DiligentCoreAPITest/assets/shaders/ShaderVariableAccessTestGL.psh b/UnitTests/DiligentCoreAPITest/assets/shaders/ShaderVariableAccessTestGL.psh deleted file mode 100644 index 52147e25..00000000 --- a/UnitTests/DiligentCoreAPITest/assets/shaders/ShaderVariableAccessTestGL.psh +++ /dev/null @@ -1,78 +0,0 @@ -uniform sampler2D g_tex2D_Static; -uniform sampler2D g_tex2D_Mut; -uniform sampler2D g_tex2D_MutArr[2]; -uniform sampler2D g_tex2D_Dyn; -uniform sampler2D g_tex2D_DynArr[2]; -uniform sampler2D g_tex2D_StaticArr[2]; - -uniform UniformBuff_Stat -{ - vec4 g_f4Color0; -}g_UniformBuff_Stat; - -uniform UniformBuff_Stat2 -{ - vec4 g_f4Color01; -}g_UniformBuff_Stat2; - -uniform UniformBuff_Mut -{ - vec4 g_f4Color1; -}g_UniformBuff_Mut; - -uniform UniformBuff_Dyn -{ - vec4 g_f4Color2; -}g_UniformBuff_Dyn; - -layout(rgba32f) uniform readonly image2D g_rwtex2D_Static; -layout(rgba32f) uniform readonly image2D g_rwtex2D_Static2; -layout(rgba32f) uniform readonly image2D g_rwtex2D_Mut; -layout(rgba32f) uniform readonly image2D g_rwtex2D_Dyn; - -layout(std140) buffer g_rwBuff_Static -{ - vec4 data[]; -}rwBuff_Static; - -layout(std140) buffer g_rwBuff_Mut -{ - vec4 data[]; -}rwBuff_Mut; - -layout(std140) buffer g_rwBuff_Dyn -{ - vec4 data[]; -}rwBuff_Dyn; - -uniform samplerBuffer g_Buffer_Static; -uniform samplerBuffer g_Buffer_StaticArr[2]; -uniform usamplerBuffer g_Buffer_Mut; -uniform samplerBuffer g_Buffer_MutArr[2]; -uniform samplerBuffer g_Buffer_Dyn; -uniform samplerBuffer g_Buffer_DynArr[2]; - -layout(location = 0) in vec4 f4Color; - -layout(location = 0) out vec4 out_Color; - -void main() -{ - out_Color = f4Color; - out_Color += textureLod(g_tex2D_Static, vec2(0.5,0.5), 0.0); - out_Color += textureLod(g_tex2D_StaticArr[0], vec2(0.5,0.5), 0.0) + textureLod(g_tex2D_StaticArr[1], vec2(0.5,0.5), 0.0); - out_Color += textureLod(g_tex2D_Mut, vec2(0.5,0.5), 0.0); - out_Color += textureLod(g_tex2D_MutArr[0], vec2(0.5,0.5), 0.0) + textureLod(g_tex2D_MutArr[1], vec2(0.5,0.5), 0.0); - out_Color += textureLod(g_tex2D_Dyn, vec2(0.5,0.5), 0.0); - out_Color += textureLod(g_tex2D_DynArr[0], vec2(0.5,0.5), 0.0) + textureLod(g_tex2D_DynArr[1], vec2(0.5,0.5), 0.0); - out_Color += g_UniformBuff_Stat.g_f4Color0 + g_UniformBuff_Stat2.g_f4Color01 + g_UniformBuff_Mut.g_f4Color1 + g_UniformBuff_Dyn.g_f4Color2; - out_Color += imageLoad(g_rwtex2D_Static, ivec2(0,0)) + imageLoad(g_rwtex2D_Mut, ivec2(0,0)) + imageLoad(g_rwtex2D_Dyn, ivec2(0,0)) + imageLoad(g_rwtex2D_Static2, ivec2(0,0)); - out_Color += rwBuff_Static.data[0] + rwBuff_Mut.data[0] + rwBuff_Dyn.data[0]; - - out_Color += texelFetch(g_Buffer_Static, 0); - out_Color += texelFetch(g_Buffer_StaticArr[0], 0) + texelFetch(g_Buffer_StaticArr[1],0); - out_Color += texelFetch(g_Buffer_Mut, 0); - out_Color += texelFetch(g_Buffer_MutArr[0], 0) + texelFetch(g_Buffer_MutArr[1], 0); - out_Color += texelFetch(g_Buffer_Dyn, 0); - out_Color += texelFetch(g_Buffer_DynArr[0], 0) + texelFetch(g_Buffer_DynArr[1], 0); -} diff --git a/UnitTests/DiligentCoreAPITest/assets/shaders/ShaderVariableAccessTestGL.vsh b/UnitTests/DiligentCoreAPITest/assets/shaders/ShaderVariableAccessTestGL.vsh deleted file mode 100644 index 83e38c2e..00000000 --- a/UnitTests/DiligentCoreAPITest/assets/shaders/ShaderVariableAccessTestGL.vsh +++ /dev/null @@ -1,61 +0,0 @@ -uniform sampler2D g_tex2D_Static; -uniform sampler2D g_tex2D_StaticArr[2]; -uniform sampler2D g_tex2D_Mut; -uniform sampler2D g_tex2D_MutArr[2]; -uniform sampler2D g_tex2D_Dyn; -uniform sampler2D g_tex2D_DynArr[2]; - -uniform UniformBuff_Stat -{ - vec4 g_f4Color0; -}g_UniformBuff_Stat; - -uniform UniformBuff_Stat2 -{ - vec4 g_f4Color01; -}g_UniformBuff_Stat2; - -uniform UniformBuff_Mut -{ - vec4 g_f4Color1; -}g_UniformBuff_Mut; - -uniform UniformBuff_Dyn -{ - vec4 g_f4Color2; -}g_UniformBuff_Dyn; - -uniform samplerBuffer g_Buffer_Static; -uniform samplerBuffer g_Buffer_StaticArr[2]; -uniform samplerBuffer g_Buffer_Mut; -uniform samplerBuffer g_Buffer_MutArr[2]; -uniform samplerBuffer g_Buffer_Dyn; -uniform samplerBuffer g_Buffer_DynArr[2]; - -layout(location = 0) out vec4 f4Color; - -#ifndef GL_ES -out gl_PerVertex -{ - vec4 gl_Position; -}; -#endif - -void main() -{ - gl_Position = vec4(0.0, 0.0, 0.0, 0.0); - f4Color = vec4(0.0, 0.0, 0.0, 0.0); - f4Color += textureLod(g_tex2D_Static, vec2(0.5,0.5), 0.0); - f4Color += textureLod(g_tex2D_StaticArr[0], vec2(0.5,0.5), 0.0) + textureLod(g_tex2D_StaticArr[1], vec2(0.5,0.5), 0.0); - f4Color += textureLod(g_tex2D_Mut, vec2(0.5,0.5), 0.0); - f4Color += textureLod(g_tex2D_MutArr[0], vec2(0.5,0.5), 0.0) + textureLod(g_tex2D_MutArr[1], vec2(0.5,0.5), 0.0); - f4Color += textureLod(g_tex2D_Dyn, vec2(0.5,0.5), 0.0); - f4Color += textureLod(g_tex2D_DynArr[0], vec2(0.5,0.5), 0.0) + textureLod(g_tex2D_DynArr[1], vec2(0.5,0.5), 0.0); - f4Color += g_UniformBuff_Stat.g_f4Color0 + g_UniformBuff_Stat2.g_f4Color01 + g_UniformBuff_Mut.g_f4Color1 + g_UniformBuff_Dyn.g_f4Color2; - f4Color += texelFetch(g_Buffer_Static, 0); - f4Color += texelFetch(g_Buffer_StaticArr[0], 0) + texelFetch(g_Buffer_StaticArr[1],0); - f4Color += texelFetch(g_Buffer_Mut, 0); - f4Color += texelFetch(g_Buffer_MutArr[0], 0) + texelFetch(g_Buffer_MutArr[1], 0); - f4Color += texelFetch(g_Buffer_Dyn, 0); - f4Color += texelFetch(g_Buffer_DynArr[0], 0) + texelFetch(g_Buffer_DynArr[1], 0); -} diff --git a/UnitTests/DiligentCoreAPITest/include/CreateObjFromNativeResTestBase.h b/UnitTests/DiligentCoreAPITest/include/CreateObjFromNativeResTestBase.h deleted file mode 100644 index 4e6bfc25..00000000 --- a/UnitTests/DiligentCoreAPITest/include/CreateObjFromNativeResTestBase.h +++ /dev/null @@ -1,55 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#pragma once - -#include "RenderDevice.h" -#include "Texture.h" -#include "Buffer.h" -#include "RefCntAutoPtr.h" - -namespace Diligent -{ - -namespace Testing -{ - -class CreateObjFromNativeResTestBase -{ -public: - CreateObjFromNativeResTestBase(IRenderDevice* pDevice) : - m_pDevice{pDevice} - {} - - virtual ~CreateObjFromNativeResTestBase() {} - - virtual void CreateTexture(ITexture* pTexture) = 0; - virtual void CreateBuffer(IBuffer* pBuffer) = 0; - -protected: - RefCntAutoPtr m_pDevice; -}; - -} // namespace Testing - -} // namespace Diligent diff --git a/UnitTests/DiligentCoreAPITest/include/D3D11/CreateObjFromNativeResD3D11.h b/UnitTests/DiligentCoreAPITest/include/D3D11/CreateObjFromNativeResD3D11.h deleted file mode 100644 index 579ed6aa..00000000 --- a/UnitTests/DiligentCoreAPITest/include/D3D11/CreateObjFromNativeResD3D11.h +++ /dev/null @@ -1,47 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#pragma once - -#include "CreateObjFromNativeResTestBase.h" - -namespace Diligent -{ - -namespace Testing -{ - -class TestCreateObjFromNativeResD3D11 : public CreateObjFromNativeResTestBase -{ -public: - TestCreateObjFromNativeResD3D11(IRenderDevice* pDevice) : - CreateObjFromNativeResTestBase(pDevice) - {} - - virtual void CreateTexture(ITexture* pTexture) override final; - virtual void CreateBuffer(IBuffer* pBuffer) override final; -}; - -} // namespace Testing - -} // namespace Diligent diff --git a/UnitTests/DiligentCoreAPITest/include/D3D11/TestingEnvironmentD3D11.h b/UnitTests/DiligentCoreAPITest/include/D3D11/TestingEnvironmentD3D11.h deleted file mode 100644 index a42c387b..00000000 --- a/UnitTests/DiligentCoreAPITest/include/D3D11/TestingEnvironmentD3D11.h +++ /dev/null @@ -1,115 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#pragma once - -#include "TestingEnvironment.h" - -#ifndef NOMINMAX -# define NOMINMAX -#endif - -#include -#include - -namespace Diligent -{ - -namespace Testing -{ - -HRESULT CompileD3DShader(const char* Source, - LPCSTR strFunctionName, - const D3D_SHADER_MACRO* pDefines, - LPCSTR profile, - ID3DBlob** ppBlobOut); - -class TestingEnvironmentD3D11 final : public TestingEnvironment -{ -public: - TestingEnvironmentD3D11(DeviceType deviceType, ADAPTER_TYPE AdapterType, const SwapChainDesc& SCDesc); - - ID3D11Device* GetD3D11Device() - { - return m_pd3d11Device; - } - - ID3D11DeviceContext* GetD3D11Context() - { - return m_pd3d11Context; - } - - ID3D11RasterizerState* GetNoCullRS() - { - return m_pd3d11NoCullRS; - } - - ID3D11DepthStencilState* GetDisableDepthDSS() - { - return m_pd3d11DisableDepthDSS; - } - - ID3D11BlendState* GetDefaultBS() - { - return m_pd3d11DefaultBS; - } - - CComPtr CreateVertexShader(const char* Source, - LPCSTR strFunctionName = "main", - const D3D_SHADER_MACRO* pDefines = nullptr, - LPCSTR profile = "vs_5_0"); - - CComPtr CreatePixelShader(const char* Source, - LPCSTR strFunctionName = "main", - const D3D_SHADER_MACRO* pDefines = nullptr, - LPCSTR profile = "ps_5_0"); - - CComPtr CreateGeometryShader(const char* Source, - LPCSTR strFunctionName = "main", - const D3D_SHADER_MACRO* pDefines = nullptr, - LPCSTR profile = "gs_5_0"); - - CComPtr CreateDomainShader(const char* Source, - LPCSTR strFunctionName = "main", - const D3D_SHADER_MACRO* pDefines = nullptr, - LPCSTR profile = "ds_5_0"); - - CComPtr CreateHullShader(const char* Source, - LPCSTR strFunctionName = "main", - const D3D_SHADER_MACRO* pDefines = nullptr, - LPCSTR profile = "gs_5_0"); - - static TestingEnvironmentD3D11* GetInstance() { return ValidatedCast(TestingEnvironment::GetInstance()); } - -private: - CComPtr m_pd3d11Device; - CComPtr m_pd3d11Context; - - CComPtr m_pd3d11NoCullRS; - CComPtr m_pd3d11DisableDepthDSS; - CComPtr m_pd3d11DefaultBS; -}; - -} // namespace Testing - -} // namespace Diligent diff --git a/UnitTests/DiligentCoreAPITest/include/D3D11/TestingSwapChainD3D11.h b/UnitTests/DiligentCoreAPITest/include/D3D11/TestingSwapChainD3D11.h deleted file mode 100644 index 33815257..00000000 --- a/UnitTests/DiligentCoreAPITest/include/D3D11/TestingSwapChainD3D11.h +++ /dev/null @@ -1,81 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "TestingSwapChainBase.h" - -#ifndef NOMINMAX -# define NOMINMAX -#endif - -#include -#include - -namespace Diligent -{ - -namespace Testing -{ - -class TestingSwapChainD3D11 final : public TestingSwapChainBase -{ -public: - using TBase = TestingSwapChainBase; - TestingSwapChainD3D11(IReferenceCounters* pRefCounters, - IRenderDevice* pDevice, - IDeviceContext* pContext, - const SwapChainDesc& SCDesc); - - virtual void TakeSnapshot() override final; - - ID3D11Texture2D* GetD3D11RenderTarget() - { - return m_pd3d11RenderTarget; - } - - ID3D11Texture2D* GetD3D11DepthBuffer() - { - return m_pd3d11DepthBuffer; - } - - ID3D11RenderTargetView* GetD3D11RTV() - { - return m_pd3d11RTV; - } - - ID3D11DepthStencilView* GetD3D11DSV() - { - return m_pd3d11DSV; - } - -private: - CComPtr m_pd3d11Context; - CComPtr m_pd3d11RenderTarget; - CComPtr m_pd3d11DepthBuffer; - CComPtr m_pd3d11RTV; - CComPtr m_pd3d11DSV; - CComPtr m_pd3d11StagingTex; -}; - -} // namespace Testing - -} // namespace Diligent diff --git a/UnitTests/DiligentCoreAPITest/include/D3D12/CreateObjFromNativeResD3D12.h b/UnitTests/DiligentCoreAPITest/include/D3D12/CreateObjFromNativeResD3D12.h deleted file mode 100644 index b00c9676..00000000 --- a/UnitTests/DiligentCoreAPITest/include/D3D12/CreateObjFromNativeResD3D12.h +++ /dev/null @@ -1,47 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#pragma once - -#include "CreateObjFromNativeResTestBase.h" - -namespace Diligent -{ - -namespace Testing -{ - -class TestCreateObjFromNativeResD3D12 : public CreateObjFromNativeResTestBase -{ -public: - TestCreateObjFromNativeResD3D12(IRenderDevice* pDevice) : - CreateObjFromNativeResTestBase(pDevice) - {} - - virtual void CreateTexture(ITexture* pTexture) override final; - virtual void CreateBuffer(IBuffer* pBuffer) override final; -}; - -} // namespace Testing - -} // namespace Diligent diff --git a/UnitTests/DiligentCoreAPITest/include/D3D12/D3D12DebugLayerSetNameBugWorkaround.h b/UnitTests/DiligentCoreAPITest/include/D3D12/D3D12DebugLayerSetNameBugWorkaround.h deleted file mode 100644 index a2d06acb..00000000 --- a/UnitTests/DiligentCoreAPITest/include/D3D12/D3D12DebugLayerSetNameBugWorkaround.h +++ /dev/null @@ -1,57 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include - -#include "RenderDevice.h" - -namespace Diligent -{ - -namespace Testing -{ - -// There is a bug in D3D12 debug layer as of build version 10.0.18362: SetName() method -// is not protected by a mutex internally. This, in combination with the fact that root signatures are -// de-duplicated by D3D12 runtime, causes the following problem: -// when multiple threads attempt to create the same root signature, the run-time returns the same -// object. Calling SetName() results in a race condition because multiple threads attempt to resize/write -// to the buffer without a mutex. - -// As a workaround, we create the root signature ahead of time and reserve enough space for the name -// to avoid memory allocation. - -class D3D12DebugLayerSetNameBugWorkaround -{ -public: - explicit D3D12DebugLayerSetNameBugWorkaround(IRenderDevice* pDevice); - ~D3D12DebugLayerSetNameBugWorkaround(); - -private: - struct RootSignatureWrapper; - std::unique_ptr m_RootSignature; -}; - -} // namespace Testing - -} // namespace Diligent diff --git a/UnitTests/DiligentCoreAPITest/include/D3D12/TestingEnvironmentD3D12.h b/UnitTests/DiligentCoreAPITest/include/D3D12/TestingEnvironmentD3D12.h deleted file mode 100644 index cdc9ca42..00000000 --- a/UnitTests/DiligentCoreAPITest/include/D3D12/TestingEnvironmentD3D12.h +++ /dev/null @@ -1,79 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#pragma once - -#include "TestingEnvironment.h" - -#ifndef NOMINMAX -# define NOMINMAX -#endif - -#include -#include -#include - -namespace Diligent -{ - -namespace Testing -{ - -// Implemented in TestingEnvironmentD3D11.cpp -HRESULT CompileD3DShader(const char* Source, - LPCSTR strFunctionName, - const D3D_SHADER_MACRO* pDefines, - LPCSTR profile, - ID3DBlob** ppBlobOut); - -class TestingEnvironmentD3D12 final : public TestingEnvironment -{ -public: - TestingEnvironmentD3D12(DeviceType deviceType, ADAPTER_TYPE AdapterType, const SwapChainDesc& SCDesc); - ~TestingEnvironmentD3D12(); - - static TestingEnvironmentD3D12* GetInstance() { return ValidatedCast(TestingEnvironment::GetInstance()); } - - ID3D12Device* GetD3D12Device() - { - return m_pd3d12Device; - } - - // The allocator is currently never reset, which is not an issue in this testing system. - CComPtr CreateGraphicsCommandList(); - - void IdleCommandQueue(ID3D12CommandQueue* pd3d12Queue); - -private: - CComPtr m_pd3d12Device; - CComPtr m_pd3d12CmdAllocator; - CComPtr m_pd3d12Fence; - - UINT64 m_NextFenceValue = 1; - - HANDLE m_WaitForGPUEventHandle = {}; -}; - -} // namespace Testing - -} // namespace Diligent diff --git a/UnitTests/DiligentCoreAPITest/include/D3D12/TestingSwapChainD3D12.h b/UnitTests/DiligentCoreAPITest/include/D3D12/TestingSwapChainD3D12.h deleted file mode 100644 index 3eb1549e..00000000 --- a/UnitTests/DiligentCoreAPITest/include/D3D12/TestingSwapChainD3D12.h +++ /dev/null @@ -1,87 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "TestingSwapChainBase.h" - -#ifndef NOMINMAX -# define NOMINMAX -#endif - -#include -#include - -namespace Diligent -{ - -namespace Testing -{ - -class TestingSwapChainD3D12 : public TestingSwapChainBase -{ -public: - using TBase = TestingSwapChainBase; - TestingSwapChainD3D12(IReferenceCounters* pRefCounters, - IRenderDevice* pDevice, - IDeviceContext* pContext, - const SwapChainDesc& SCDesc); - - virtual void TakeSnapshot() override final; - - void TransitionRenderTarget(ID3D12GraphicsCommandList* pCmdList, - D3D12_RESOURCE_STATES RTVState); - - void TransitionBuffers(ID3D12GraphicsCommandList* pCmdList, - D3D12_RESOURCE_STATES RTVState, - D3D12_RESOURCE_STATES DSVState); - - D3D12_CPU_DESCRIPTOR_HANDLE GetRTVDescriptorHandle() - { - return m_RTVDescriptorHandle; - } - - D3D12_CPU_DESCRIPTOR_HANDLE GetDSVDescriptorHandle() - { - return m_DSVDescriptorHandle; - } - -private: - CComPtr m_pd3d12RenderTaget; - CComPtr m_pd3d12DepthBuffer; - CComPtr m_pd3d12StagingBuffer; - - CComPtr m_pd3d12RTVDescriptorHeap; - CComPtr m_pd3d12DSVDescriptorHeap; - - D3D12_RESOURCE_STATES m_RenderTargetState = D3D12_RESOURCE_STATE_RENDER_TARGET; - D3D12_RESOURCE_STATES m_DepthBufferState = D3D12_RESOURCE_STATE_DEPTH_WRITE; - - D3D12_CPU_DESCRIPTOR_HANDLE m_RTVDescriptorHandle = {}; - D3D12_CPU_DESCRIPTOR_HANDLE m_DSVDescriptorHandle = {}; - - D3D12_PLACED_SUBRESOURCE_FOOTPRINT m_StagingBufferFootprint = {}; - UINT64 m_StagingBufferSize = 0; -}; - -} // namespace Testing - -} // namespace Diligent diff --git a/UnitTests/DiligentCoreAPITest/include/GL/CreateObjFromNativeResGL.h b/UnitTests/DiligentCoreAPITest/include/GL/CreateObjFromNativeResGL.h deleted file mode 100644 index 2584e426..00000000 --- a/UnitTests/DiligentCoreAPITest/include/GL/CreateObjFromNativeResGL.h +++ /dev/null @@ -1,47 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#pragma once - -#include "CreateObjFromNativeResTestBase.h" - -namespace Diligent -{ - -namespace Testing -{ - -class TestCreateObjFromNativeResGL : public CreateObjFromNativeResTestBase -{ -public: - TestCreateObjFromNativeResGL(IRenderDevice* pDevice) : - CreateObjFromNativeResTestBase(pDevice) - {} - - virtual void CreateTexture(ITexture* pTexture) override final; - virtual void CreateBuffer(IBuffer* pBuffer) override final; -}; - -} // namespace Testing - -} // namespace Diligent \ No newline at end of file diff --git a/UnitTests/DiligentCoreAPITest/include/GL/TestingEnvironmentGL.h b/UnitTests/DiligentCoreAPITest/include/GL/TestingEnvironmentGL.h deleted file mode 100644 index 306e1d8f..00000000 --- a/UnitTests/DiligentCoreAPITest/include/GL/TestingEnvironmentGL.h +++ /dev/null @@ -1,62 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#pragma once - -#ifndef GLEW_STATIC -# define GLEW_STATIC // Must be defined to use static version of glew -#endif -#ifndef GLEW_NO_GLU -# define GLEW_NO_GLU -#endif - -#include "GL/glew.h" - -#include "TestingEnvironment.h" - -namespace Diligent -{ - -namespace Testing -{ - -class TestingEnvironmentGL final : public TestingEnvironment -{ -public: - TestingEnvironmentGL(DeviceType deviceType, ADAPTER_TYPE AdapterType, const SwapChainDesc& SCDesc); - ~TestingEnvironmentGL(); - - static TestingEnvironmentGL* GetInstance() { return ValidatedCast(TestingEnvironment::GetInstance()); } - - GLuint CompileGLShader(const char* Source, GLenum ShaderType); - GLuint LinkProgram(GLuint Shaders[], GLuint NumShaders); - - GLuint GetDummyVAO() { return m_DummyVAO; } - -private: - GLuint m_DummyVAO = 0; -}; - -} // namespace Testing - -} // namespace Diligent diff --git a/UnitTests/DiligentCoreAPITest/include/GL/TestingSwapChainGL.h b/UnitTests/DiligentCoreAPITest/include/GL/TestingSwapChainGL.h deleted file mode 100644 index fa6c3c37..00000000 --- a/UnitTests/DiligentCoreAPITest/include/GL/TestingSwapChainGL.h +++ /dev/null @@ -1,54 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "TestingSwapChainBase.h" - -namespace Diligent -{ - -namespace Testing -{ - -class TestingSwapChainGL : public TestingSwapChainBase -{ -public: - using TBase = TestingSwapChainBase; - TestingSwapChainGL(IReferenceCounters* pRefCounters, - IRenderDevice* pDevice, - IDeviceContext* pContext, - const SwapChainDesc& SCDesc); - ~TestingSwapChainGL(); - - virtual void TakeSnapshot() override final; - - void BindFramebuffer(); - -private: - GLuint m_RenderTarget = 0; - GLuint m_DepthBuffer = 0; - GLuint m_FBO = 0; -}; - -} // namespace Testing - -} // namespace Diligent diff --git a/UnitTests/DiligentCoreAPITest/include/PSOTestBase.h b/UnitTests/DiligentCoreAPITest/include/PSOTestBase.h deleted file mode 100644 index a66a5cf6..00000000 --- a/UnitTests/DiligentCoreAPITest/include/PSOTestBase.h +++ /dev/null @@ -1,62 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "RenderDevice.h" -#include "DeviceContext.h" -#include "PipelineState.h" -#include "RefCntAutoPtr.h" - -namespace Diligent -{ - -namespace Testing -{ - -class PSOTestBase -{ -protected: - static void InitResources(); - static void ReleaseResources(); - - static RefCntAutoPtr CreateTestPSO(const PipelineStateDesc& PSODesc, bool BindPSO); - - static PipelineStateDesc& GetPSODesc() - { - return sm_Resources.PSODesc; - } - -private: - struct Resources - { - RefCntAutoPtr pTrivialVS; - RefCntAutoPtr pTrivialPS; - - PipelineStateDesc PSODesc; - }; - - static Resources sm_Resources; -}; - -} // namespace Testing - -} // namespace Diligent diff --git a/UnitTests/DiligentCoreAPITest/include/TestingEnvironment.h b/UnitTests/DiligentCoreAPITest/include/TestingEnvironment.h deleted file mode 100644 index 5d03e575..00000000 --- a/UnitTests/DiligentCoreAPITest/include/TestingEnvironment.h +++ /dev/null @@ -1,120 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#pragma once - -#include - -#include "RenderDevice.h" -#include "DeviceContext.h" -#include "RefCntAutoPtr.h" -#include "SwapChain.h" -#include "GraphicsTypesOutputInserters.h" - -#include "gtest/gtest.h" - -namespace Diligent -{ - -namespace Testing -{ - -class TestingEnvironment : public ::testing::Environment -{ -public: - struct NativeWindow - { - void* NativeWindowHandle = nullptr; -#if PLATFORM_LINUX - void* Display = nullptr; -#endif - }; - - - TestingEnvironment(DeviceType deviceType, ADAPTER_TYPE AdapterType, const SwapChainDesc& SCDesc); - ~TestingEnvironment() override; - - // Override this to define how to set up the environment. - void SetUp() override final; - - // Override this to define how to tear down the environment. - void TearDown() override final; - - void Reset(); - void ReleaseResources(); - - class ScopedReset - { - public: - ScopedReset() = default; - ~ScopedReset() - { - if (m_pTheEnvironment) - m_pTheEnvironment->Reset(); - } - }; - - class ScopedReleaseResources - { - public: - ScopedReleaseResources() = default; - ~ScopedReleaseResources() - { - if (m_pTheEnvironment) - m_pTheEnvironment->ReleaseResources(); - } - }; - - IRenderDevice* GetDevice() { return m_pDevice; } - IDeviceContext* GetDeviceContext() { return m_pDeviceContext; } - ISwapChain* GetSwapChain() { return m_pSwapChain; } - - static TestingEnvironment* GetInstance() { return m_pTheEnvironment; } - - RefCntAutoPtr CreateTexture(const char* Name, TEXTURE_FORMAT Fmt, BIND_FLAGS BindFlags, Uint32 Width, Uint32 Height); - - static void SetErrorAllowance(int NumErrorsToAllow, const char* InfoMessage = nullptr); - -protected: - NativeWindow CreateNativeWindow(); - - static void MessageCallback(DebugMessageSeverity Severity, - const Char* Message, - const char* Function, - const char* File, - int Line); - - const DeviceType m_DeviceType; - - static TestingEnvironment* m_pTheEnvironment; - - RefCntAutoPtr m_pDevice; - RefCntAutoPtr m_pDeviceContext; - RefCntAutoPtr m_pSwapChain; - - static std::atomic_int m_NumAllowedErrors; -}; - -} // namespace Testing - -} // namespace Diligent diff --git a/UnitTests/DiligentCoreAPITest/include/TestingSwapChainBase.h b/UnitTests/DiligentCoreAPITest/include/TestingSwapChainBase.h deleted file mode 100644 index 1c976885..00000000 --- a/UnitTests/DiligentCoreAPITest/include/TestingSwapChainBase.h +++ /dev/null @@ -1,209 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include - -#include "ObjectBase.h" -#include "RefCntAutoPtr.h" -#include "RenderDevice.h" -#include "DeviceContext.h" -#include "SwapChain.h" -#include "Texture.h" -#include "TextureView.h" -#include "TestingEnvironment.h" - -namespace Diligent -{ - -namespace Testing -{ - -void CompareTestImages(const Uint8* pReferencePixels, - Uint32 RefPixelsStride, - const Uint8* pPixels, - Uint32 PixelsStride, - Uint32 Width, - Uint32 Height, - TEXTURE_FORMAT Format); - -// {41BF4655-9B33-4E6C-9300-0CB45FBFE104} -static constexpr INTERFACE_ID IID_TestingSwapChain = - {0x41bf4655, 0x9b33, 0x4e6c, {0x93, 0x0, 0xc, 0xb4, 0x5f, 0xbf, 0xe1, 0x4}}; - -class ITestingSwapChain : public IObject -{ -public: - virtual void TakeSnapshot() = 0; -}; - -template -class SwapChainCombinedBaseInterface : public ITestingSwapChain, public SwapChainInterface -{}; - -template -class TestingSwapChainBase : public RefCountedObject> -{ -public: - using TObjectBase = RefCountedObject>; - - TestingSwapChainBase(IReferenceCounters* pRefCounters, - IRenderDevice* pDevice, - IDeviceContext* pContext, - const SwapChainDesc& SCDesc) : - TObjectBase{pRefCounters}, - m_pDevice{pDevice}, - m_pContext{pContext}, - m_SwapChainDesc{SCDesc} - { - VERIFY_EXPR(m_SwapChainDesc.ColorBufferFormat != TEX_FORMAT_UNKNOWN); - VERIFY_EXPR(m_SwapChainDesc.Width != 0); - VERIFY_EXPR(m_SwapChainDesc.Height != 0); - - { - TextureDesc RenderTargetDesc; - RenderTargetDesc.Name = "Testing color buffer"; - RenderTargetDesc.Type = RESOURCE_DIM_TEX_2D; - RenderTargetDesc.Width = m_SwapChainDesc.Width; - RenderTargetDesc.Height = m_SwapChainDesc.Height; - RenderTargetDesc.Format = m_SwapChainDesc.ColorBufferFormat; - RenderTargetDesc.SampleCount = 1; - RenderTargetDesc.Usage = USAGE_DEFAULT; - RenderTargetDesc.BindFlags = BIND_RENDER_TARGET; - m_pDevice->CreateTexture(RenderTargetDesc, nullptr, static_cast(&m_pRenderTarget)); - VERIFY_EXPR(m_pRenderTarget != nullptr); - m_pRTV = m_pRenderTarget->GetDefaultView(TEXTURE_VIEW_RENDER_TARGET); - VERIFY_EXPR(m_pRTV != nullptr); - - RenderTargetDesc.Name = "Staging color buffer copy"; - RenderTargetDesc.Usage = USAGE_STAGING; - RenderTargetDesc.CPUAccessFlags = CPU_ACCESS_READ; - RenderTargetDesc.BindFlags = BIND_NONE; - m_pDevice->CreateTexture(RenderTargetDesc, nullptr, static_cast(&m_pStagingTexture)); - } - - if (m_SwapChainDesc.DepthBufferFormat != TEX_FORMAT_UNKNOWN) - { - TextureDesc DepthBufferDesc; - DepthBufferDesc.Name = "Testing depth buffer"; - DepthBufferDesc.Type = RESOURCE_DIM_TEX_2D; - DepthBufferDesc.Width = m_SwapChainDesc.Width; - DepthBufferDesc.Height = m_SwapChainDesc.Height; - DepthBufferDesc.Format = m_SwapChainDesc.DepthBufferFormat; - DepthBufferDesc.SampleCount = 1; - DepthBufferDesc.Usage = USAGE_DEFAULT; - DepthBufferDesc.BindFlags = BIND_DEPTH_STENCIL; - - DepthBufferDesc.ClearValue.Format = DepthBufferDesc.Format; - DepthBufferDesc.ClearValue.DepthStencil.Depth = m_SwapChainDesc.DefaultDepthValue; - DepthBufferDesc.ClearValue.DepthStencil.Stencil = m_SwapChainDesc.DefaultStencilValue; - - m_pDevice->CreateTexture(DepthBufferDesc, nullptr, &m_pDepthBuffer); - VERIFY_EXPR(m_pDepthBuffer != nullptr); - m_pDSV = m_pDepthBuffer->GetDefaultView(TEXTURE_VIEW_DEPTH_STENCIL); - VERIFY_EXPR(m_pDSV != nullptr); - } - } - - void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) - { - if (ppInterface == nullptr) - return; - - if (IID == IID_SwapChain || IID == IID_Unknown) - { - *ppInterface = static_cast(this); - (*ppInterface)->AddRef(); - } - if (IID == IID_TestingSwapChain) - { - *ppInterface = static_cast(this); - (*ppInterface)->AddRef(); - } - } - - virtual void Present(Uint32 SyncInterval = 1) override - { - CopyTextureAttribs CopyInfo // - { - m_pRenderTarget, - RESOURCE_STATE_TRANSITION_MODE_TRANSITION, - m_pStagingTexture, - RESOURCE_STATE_TRANSITION_MODE_TRANSITION // - }; - m_pContext->CopyTexture(CopyInfo); - m_pContext->WaitForIdle(); - MappedTextureSubresource MapData; - m_pContext->MapTextureSubresource(m_pStagingTexture, 0, 0, MAP_READ, MAP_FLAG_DO_NOT_SYNCHRONIZE, nullptr, MapData); - CompareTestImages(m_ReferenceData.data(), m_ReferenceDataPitch, reinterpret_cast(MapData.pData), MapData.Stride, - m_SwapChainDesc.Width, m_SwapChainDesc.Height, m_SwapChainDesc.ColorBufferFormat); - - m_pContext->UnmapTextureSubresource(m_pStagingTexture, 0, 0); - } - - virtual void Resize(Uint32 NewWidth, Uint32 NewHeight) override final - { - UNEXPECTED("Resizing testing swap chains is not supported"); - } - - virtual void SetFullscreenMode(const DisplayModeAttribs& DisplayMode) override final - { - UNEXPECTED("Testing swap chain can't go into full screen mode"); - } - - virtual void SetWindowedMode() override final - { - UNEXPECTED("Testing swap chain can't switch between windowed and full screen modes"); - } - - virtual ITextureView* GetCurrentBackBufferRTV() override final - { - return m_pRTV; - } - - virtual ITextureView* GetDepthBufferDSV() override final - { - return m_pDSV; - } - - virtual const SwapChainDesc& GetDesc() const override final - { - return m_SwapChainDesc; - } - -protected: - const SwapChainDesc m_SwapChainDesc; - RefCntAutoPtr m_pDevice; - RefCntAutoPtr m_pContext; - RefCntAutoPtr m_pRenderTarget; - RefCntAutoPtr m_pDepthBuffer; - RefCntAutoPtr m_pRTV; - RefCntAutoPtr m_pDSV; - RefCntAutoPtr m_pStagingTexture; - - std::vector m_ReferenceData; - Uint32 m_ReferenceDataPitch = 0; -}; - -} // namespace Testing - -} // namespace Diligent diff --git a/UnitTests/DiligentCoreAPITest/include/Vulkan/CreateObjFromNativeResVK.h b/UnitTests/DiligentCoreAPITest/include/Vulkan/CreateObjFromNativeResVK.h deleted file mode 100644 index f3b36403..00000000 --- a/UnitTests/DiligentCoreAPITest/include/Vulkan/CreateObjFromNativeResVK.h +++ /dev/null @@ -1,47 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#pragma once - -#include "CreateObjFromNativeResTestBase.h" - -namespace Diligent -{ - -namespace Testing -{ - -class TestCreateObjFromNativeResVK : public CreateObjFromNativeResTestBase -{ -public: - TestCreateObjFromNativeResVK(IRenderDevice* pDevice) : - CreateObjFromNativeResTestBase(pDevice) - {} - - virtual void CreateTexture(ITexture* pTexture) override final; - virtual void CreateBuffer(IBuffer* pBuffer) override final; -}; - -} // namespace Testing - -} // namespace Diligent diff --git a/UnitTests/DiligentCoreAPITest/include/Vulkan/TestingEnvironmentVk.h b/UnitTests/DiligentCoreAPITest/include/Vulkan/TestingEnvironmentVk.h deleted file mode 100644 index 41c8dba7..00000000 --- a/UnitTests/DiligentCoreAPITest/include/Vulkan/TestingEnvironmentVk.h +++ /dev/null @@ -1,102 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#pragma once - -#include - -#include "TestingEnvironment.h" - -#define VK_NO_PROTOTYPES -#include "vulkan/vulkan.h" - -namespace Diligent -{ - -namespace Testing -{ - -class TestingEnvironmentVk final : public TestingEnvironment -{ -public: - TestingEnvironmentVk(DeviceType deviceType, ADAPTER_TYPE AdapterType, const SwapChainDesc& SCDesc); - ~TestingEnvironmentVk(); - - static TestingEnvironmentVk* GetInstance() { return ValidatedCast(TestingEnvironment::GetInstance()); } - - void CreateImage2D(uint32_t Width, - uint32_t Height, - VkFormat vkFormat, - VkImageUsageFlags vkUsage, - VkImageLayout vkInitialLayout, - VkDeviceMemory& vkMemory, - VkImage& vkImage); - - void CreateBuffer(VkDeviceSize Size, - VkBufferUsageFlags vkUsage, - VkMemoryPropertyFlags MemoryFlags, - VkDeviceMemory& vkMemory, - VkBuffer& vkBuffer); - - uint32_t GetMemoryTypeIndex(uint32_t memoryTypeBitsRequirement, - VkMemoryPropertyFlags requiredProperties) const; - - VkDevice GetVkDevice() - { - return m_vkDevice; - } - - VkShaderModule CreateShaderModule(const SHADER_TYPE ShaderType, const char* ShaderSource, int SourceCodeLen); - - static VkRenderPassCreateInfo GetRenderPassCreateInfo( - Uint32 NumRenderTargets, - const VkFormat RTVFormats[], - VkFormat DSVFormat, - Uint32 SampleCount, - VkAttachmentLoadOp DepthAttachmentLoadOp, - VkAttachmentLoadOp ColorAttachmentLoadOp, - std::array& Attachments, - std::array& AttachmentReferences, - VkSubpassDescription& SubpassDesc); - - VkCommandBuffer AllocateCommandBuffer(); - - static void TransitionImageLayout(VkCommandBuffer CmdBuffer, - VkImage Image, - VkImageLayout& CurrentLayout, - VkImageLayout NewLayout, - const VkImageSubresourceRange& SubresRange, - VkPipelineStageFlags EnabledGraphicsShaderStages, - VkPipelineStageFlags SrcStages = 0, - VkPipelineStageFlags DestStages = 0); - -private: - VkDevice m_vkDevice = VK_NULL_HANDLE; - VkCommandPool m_vkCmdPool = VK_NULL_HANDLE; - - VkPhysicalDeviceMemoryProperties m_MemoryProperties = {}; -}; - -} // namespace Testing - -} // namespace Diligent diff --git a/UnitTests/DiligentCoreAPITest/include/Vulkan/TestingSwapChainVk.h b/UnitTests/DiligentCoreAPITest/include/Vulkan/TestingSwapChainVk.h deleted file mode 100644 index 10de2de9..00000000 --- a/UnitTests/DiligentCoreAPITest/include/Vulkan/TestingSwapChainVk.h +++ /dev/null @@ -1,96 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "TestingSwapChainBase.h" - -#define VK_NO_PROTOTYPES -#include "vulkan/vulkan.h" - -namespace Diligent -{ - -namespace Testing -{ - -class TestingEnvironmentVk; - -class TestingSwapChainVk : public TestingSwapChainBase -{ -public: - using TBase = TestingSwapChainBase; - TestingSwapChainVk(IReferenceCounters* pRefCounters, - TestingEnvironmentVk* pEnv, - const SwapChainDesc& SCDesc); - ~TestingSwapChainVk(); - - virtual void TakeSnapshot() override final; - - VkImage GetVkRenderTargetImage() - { - return m_vkRenderTargetImage; - } - - VkImage GetVkDepthBufferImage() - { - return m_vkDepthBufferImage; - } - - VkRenderPass GetRenderPass() - { - return m_vkRenderPass; - } - - void TransitionRenderTarget(VkCommandBuffer vkCmdBuffer, VkImageLayout Layout, VkPipelineStageFlags GraphicsShaderStages); - void TransitionDepthBuffer(VkCommandBuffer vkCmdBuffer, VkImageLayout Layout, VkPipelineStageFlags GraphicsShaderStages); - - void BeginRenderPass(VkCommandBuffer vkCmdBuffer, VkPipelineStageFlags GraphicsShaderStages); - void EndRenderPass(VkCommandBuffer vkCmdBuffer); - -private: - void CreateFramebuffer(); - - VkDevice m_vkDevice = VK_NULL_HANDLE; - - VkDeviceMemory m_vkRenderTargetMemory = VK_NULL_HANDLE; - VkImage m_vkRenderTargetImage = VK_NULL_HANDLE; - VkImageLayout m_vkRenerTargetLayout = VK_IMAGE_LAYOUT_UNDEFINED; - VkImageView m_vkRenderTargetView = VK_NULL_HANDLE; - - VkDeviceMemory m_vkDepthBufferMemory = VK_NULL_HANDLE; - VkImage m_vkDepthBufferImage = VK_NULL_HANDLE; - VkImageLayout m_vkDepthBufferLayout = VK_IMAGE_LAYOUT_UNDEFINED; - VkImageView m_vkDepthBufferView = VK_NULL_HANDLE; - - VkDeviceSize m_StagingBufferSize = 0; - VkDeviceMemory m_vkStagingBufferMemory = VK_NULL_HANDLE; - VkBuffer m_vkStagingBuffer = VK_NULL_HANDLE; - - VkRenderPass m_vkRenderPass = VK_NULL_HANDLE; - VkFramebuffer m_vkFramebuffer = VK_NULL_HANDLE; - - VkPipelineStageFlags m_ActiveGraphicsShaderStages = 0; -}; - -} // namespace Testing - -} // namespace Diligent diff --git a/UnitTests/DiligentCoreAPITest/src/BlendStateTest.cpp b/UnitTests/DiligentCoreAPITest/src/BlendStateTest.cpp deleted file mode 100644 index 7a33f10f..00000000 --- a/UnitTests/DiligentCoreAPITest/src/BlendStateTest.cpp +++ /dev/null @@ -1,428 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include - -#include "TestingEnvironment.h" -#include "GraphicsAccessories.h" - -#include "gtest/gtest.h" - -using namespace Diligent; -using namespace Diligent::Testing; - -namespace -{ - -static const char g_TrivialVSSource[] = R"( -void VSMain(out float4 pos : SV_POSITION) -{ - pos = float4(0.0, 0.0, 0.0, 0.0); -} -)"; - -class BlendStateTestBase -{ -protected: - static void InitResources() - { - auto* pEnv = TestingEnvironment::GetInstance(); - auto* pDevice = pEnv->GetDevice(); - - ShaderCreateInfo Attrs; - Attrs.Source = g_TrivialVSSource; - Attrs.EntryPoint = "VSMain"; - Attrs.Desc.ShaderType = SHADER_TYPE_VERTEX; - Attrs.Desc.Name = "TrivialVS (TestPipelineStateBase)"; - Attrs.SourceLanguage = SHADER_SOURCE_LANGUAGE_HLSL; - Attrs.UseCombinedTextureSamplers = true; - pDevice->CreateShader(Attrs, &sm_Resources.pTrivialVS); - - Uint32 MaxTestRenderTargets = pDevice->GetDeviceCaps().DevType == DeviceType::OpenGLES ? 4 : 8; - for (Uint32 NumRTs = 1; NumRTs <= MaxTestRenderTargets; ++NumRTs) - { - std::stringstream source_ss; - source_ss << "void PSMain("; - for (Uint32 rt = 0; rt < NumRTs; ++rt) - { - if (rt > 0) - { - source_ss << ",\n" - << " "; - } - source_ss << "out float4 col" << rt << " : SV_TARGET" << rt; - } - source_ss << ")\n{"; - for (Uint32 rt = 0; rt < NumRTs; ++rt) - { - source_ss << "\n col" << rt << " = float4(0.0, 0.0, 0.0, 0.0);"; - } - source_ss << "\n}\n"; - - auto source = source_ss.str(); - Attrs.Source = source.c_str(); - Attrs.EntryPoint = "PSMain"; - Attrs.Desc.ShaderType = SHADER_TYPE_PIXEL; - Attrs.Desc.Name = "TrivialPS (TestPipelineStateBase)"; - pDevice->CreateShader(Attrs, &sm_Resources.pTrivialPS[NumRTs]); - } - - auto& PSODesc = sm_Resources.PSODesc; - - PSODesc.GraphicsPipeline.pVS = sm_Resources.pTrivialVS; - PSODesc.GraphicsPipeline.PrimitiveTopology = PRIMITIVE_TOPOLOGY_TRIANGLE_LIST; - PSODesc.GraphicsPipeline.NumRenderTargets = 1; - PSODesc.GraphicsPipeline.RTVFormats[0] = TEX_FORMAT_RGBA8_UNORM; - PSODesc.GraphicsPipeline.DSVFormat = TEX_FORMAT_D32_FLOAT; - } - - static void ReleaseResources() - { - sm_Resources = Resources{}; - TestingEnvironment::GetInstance()->Reset(); - } - - static RefCntAutoPtr CreateTestPSO(const PipelineStateDesc& PSODesc, bool BindPSO) - { - auto* pEnv = TestingEnvironment::GetInstance(); - auto* pDevice = pEnv->GetDevice(); - auto* pDeviceContext = pEnv->GetDeviceContext(); - - RefCntAutoPtr pPSO; - pDevice->CreatePipelineState(PSODesc, &pPSO); - EXPECT_TRUE(pPSO); - if (pPSO) - pDeviceContext->SetPipelineState(pPSO); - return pPSO; - } - - static PipelineStateDesc GetPSODesc(Uint32 NumRenderTargets) - { - auto PSODesc = sm_Resources.PSODesc; - PSODesc.GraphicsPipeline.NumRenderTargets = static_cast(NumRenderTargets); - PSODesc.GraphicsPipeline.pPS = sm_Resources.pTrivialPS[NumRenderTargets]; - for (Uint32 rt = 1; rt < NumRenderTargets; ++rt) - PSODesc.GraphicsPipeline.RTVFormats[rt] = PSODesc.GraphicsPipeline.RTVFormats[0]; - - return PSODesc; - } - -private: - struct Resources - { - RefCntAutoPtr pTrivialVS; - RefCntAutoPtr pTrivialPS[MaxRenderTargets + 1]; - - PipelineStateDesc PSODesc; - }; - - static Resources sm_Resources; -}; - -BlendStateTestBase::Resources BlendStateTestBase::sm_Resources; - -class BlendStateBasicTest : public BlendStateTestBase, public ::testing::Test -{ -protected: - static void SetUpTestSuite() - { - InitResources(); - } - - static void TearDownTestSuite() - { - ReleaseResources(); - TestingEnvironment::GetInstance()->ReleaseResources(); - } -}; - -TEST_F(BlendStateBasicTest, CreatePSO) -{ - auto PSODesc = GetPSODesc(1); - - PSODesc.Name = "BlendStateBasicTest"; - - BlendStateDesc& BSDesc = PSODesc.GraphicsPipeline.BlendDesc; - - auto& RT0 = BSDesc.RenderTargets[0]; - - RT0.BlendEnable = True; - EXPECT_TRUE(CreateTestPSO(PSODesc, true)); - - BSDesc.AlphaToCoverageEnable = !BSDesc.AlphaToCoverageEnable; - EXPECT_TRUE(CreateTestPSO(PSODesc, true)); - - RT0.RenderTargetWriteMask = COLOR_MASK_BLUE; - EXPECT_TRUE(CreateTestPSO(PSODesc, true)); - - RT0.RenderTargetWriteMask = COLOR_MASK_RED; - EXPECT_TRUE(CreateTestPSO(PSODesc, true)); - - RT0.RenderTargetWriteMask = COLOR_MASK_GREEN; - EXPECT_TRUE(CreateTestPSO(PSODesc, true)); - - RT0.RenderTargetWriteMask = COLOR_MASK_ALPHA; - EXPECT_TRUE(CreateTestPSO(PSODesc, true)); -} - -class BlendFactorTest : public BlendStateTestBase, public testing::TestWithParam> -{ -protected: - static void SetUpTestSuite() - { - InitResources(); - } - - static void TearDownTestSuite() - { - ReleaseResources(); - TestingEnvironment::GetInstance()->ReleaseResources(); - } -}; - -TEST_P(BlendFactorTest, CreatePSO) -{ - auto* pEnv = TestingEnvironment::GetInstance(); - auto* pDevice = pEnv->GetDevice(); - - const auto& Param = GetParam(); - - const auto BlendFactor = static_cast(std::get<0>(Param)); - const bool TestingAlpha = std::get<1>(Param); - - const auto& DevCaps = pDevice->GetDeviceCaps(); - Uint32 MaxTestRenderTargets = (DevCaps.DevType == DeviceType::OpenGLES) ? 4 : 8; - - const bool TestSRC1 = DevCaps.DevType != DeviceType::OpenGLES; // || DevCaps.Vendor == GPU_VENDOR::NVIDIA; - if (BlendFactor == BLEND_FACTOR_SRC1_COLOR || - BlendFactor == BLEND_FACTOR_INV_SRC1_COLOR || - BlendFactor == BLEND_FACTOR_SRC1_ALPHA || - BlendFactor == BLEND_FACTOR_INV_SRC1_ALPHA) - { - if (!TestSRC1) - { - GTEST_SKIP(); - } - else - { - MaxTestRenderTargets = 1; - } - } - - for (Uint32 NumRenderTarges = 1; NumRenderTarges < MaxTestRenderTargets; ++NumRenderTarges) - { - auto PSODesc = GetPSODesc(NumRenderTarges); - PSODesc.Name = "SrcBlendFactorTest"; - - BlendStateDesc& BSDesc = PSODesc.GraphicsPipeline.BlendDesc; - - BSDesc.IndependentBlendEnable = True; - for (Uint32 i = 0; i < NumRenderTarges; ++i) - { - auto& RT = BSDesc.RenderTargets[i]; - - RT.BlendEnable = True; - if (TestingAlpha) - RT.SrcBlendAlpha = BlendFactor; - else - RT.SrcBlend = BlendFactor; - } - - auto pPSO = CreateTestPSO(PSODesc, true); - ASSERT_TRUE(pPSO) << "Number of render targets: " << NumRenderTarges; - for (Uint32 i = 0; i < NumRenderTarges; ++i) - { - auto& RT = pPSO->GetDesc().GraphicsPipeline.BlendDesc.RenderTargets[i]; - - EXPECT_EQ(RT.BlendEnable, True) << "Render target: " << i; - if (TestingAlpha) - { - EXPECT_EQ(RT.SrcBlendAlpha, BlendFactor) << "Render target: " << i; - } - else - { - EXPECT_EQ(RT.SrcBlend, BlendFactor) << "Render target: " << i; - } - } - } - - for (Uint32 NumRenderTarges = 1; NumRenderTarges < MaxTestRenderTargets; ++NumRenderTarges) - { - auto PSODesc = GetPSODesc(NumRenderTarges); - PSODesc.Name = "DstBlendFactorTest"; - - BlendStateDesc& BSDesc = PSODesc.GraphicsPipeline.BlendDesc; - - BSDesc.IndependentBlendEnable = True; - for (Uint32 i = 0; i < NumRenderTarges; ++i) - { - auto& RT = BSDesc.RenderTargets[i]; - - RT.BlendEnable = True; - if (TestingAlpha) - RT.DestBlendAlpha = BlendFactor; - else - RT.DestBlend = BlendFactor; - } - - auto pPSO = CreateTestPSO(PSODesc, true); - ASSERT_TRUE(pPSO) << "Number of render targets: " << NumRenderTarges; - for (Uint32 i = 0; i < NumRenderTarges; ++i) - { - auto& RT = pPSO->GetDesc().GraphicsPipeline.BlendDesc.RenderTargets[i]; - - EXPECT_EQ(RT.BlendEnable, True) << "Render target: " << i; - if (TestingAlpha) - { - EXPECT_EQ(RT.DestBlendAlpha, BlendFactor) << "Render target: " << i; - } - else - { - EXPECT_EQ(RT.DestBlend, BlendFactor) << "Render target: " << i; - } - } - } -} - -std::string PrintBlendFactorTestName(const testing::TestParamInfo>& info) // -{ - auto BlendFactor = static_cast(std::get<0>(info.param)); - - std::stringstream name_ss; - name_ss << GetBlendFactorLiteralName(BlendFactor); - return name_ss.str(); -} - -INSTANTIATE_TEST_SUITE_P(ColorBlendFactors, - BlendFactorTest, - testing::Combine( - testing::Range(BLEND_FACTOR_UNDEFINED + 1, BLEND_FACTOR_NUM_FACTORS), - testing::Values(false)), - PrintBlendFactorTestName); - - -INSTANTIATE_TEST_SUITE_P(AlphaBlendFactors, - BlendFactorTest, - testing::Combine( - testing::Values(BLEND_FACTOR_ZERO, - BLEND_FACTOR_ONE, - BLEND_FACTOR_SRC_ALPHA, - BLEND_FACTOR_INV_SRC_ALPHA, - BLEND_FACTOR_DEST_ALPHA, - BLEND_FACTOR_INV_DEST_ALPHA, - BLEND_FACTOR_SRC_ALPHA_SAT, - BLEND_FACTOR_BLEND_FACTOR, - BLEND_FACTOR_INV_BLEND_FACTOR, - BLEND_FACTOR_SRC1_ALPHA, - BLEND_FACTOR_INV_SRC1_ALPHA), - testing::Values(true)), - PrintBlendFactorTestName); - - -class BlendOperationTest : public BlendStateTestBase, public testing::TestWithParam> -{ -protected: - static void SetUpTestSuite() - { - InitResources(); - } - - static void TearDownTestSuite() - { - ReleaseResources(); - TestingEnvironment::GetInstance()->ReleaseResources(); - } -}; - - -TEST_P(BlendOperationTest, CreatePSO) -{ - auto* pEnv = TestingEnvironment::GetInstance(); - auto* pDevice = pEnv->GetDevice(); - - const auto& Param = GetParam(); - - const auto BlendOp = static_cast(std::get<0>(Param)); - const auto TestingAlpha = std::get<1>(Param); - - const auto& DevCaps = pDevice->GetDeviceCaps(); - const Uint32 MaxTestRenderTargets = (DevCaps.DevType == DeviceType::OpenGLES) ? 4 : 8; - - for (Uint32 NumRenderTarges = 1; NumRenderTarges < MaxTestRenderTargets; ++NumRenderTarges) - { - auto PSODesc = GetPSODesc(NumRenderTarges); - PSODesc.Name = "BlendOperationTest"; - - BlendStateDesc& BSDesc = PSODesc.GraphicsPipeline.BlendDesc; - - BSDesc.IndependentBlendEnable = True; - for (Uint32 i = 0; i < NumRenderTarges; ++i) - { - auto& RT = BSDesc.RenderTargets[i]; - RT.BlendEnable = True; - RT.SrcBlend = BLEND_FACTOR_SRC_COLOR; - RT.DestBlend = BLEND_FACTOR_INV_SRC_COLOR; - RT.SrcBlendAlpha = BLEND_FACTOR_SRC_ALPHA; - RT.DestBlendAlpha = BLEND_FACTOR_INV_SRC_ALPHA; - if (TestingAlpha) - RT.BlendOpAlpha = BlendOp; - else - RT.BlendOp = BlendOp; - } - - auto pPSO = CreateTestPSO(PSODesc, true); - ASSERT_TRUE(pPSO) << "Number of render targets: " << NumRenderTarges; - for (Uint32 i = 0; i < NumRenderTarges; ++i) - { - auto& RT = pPSO->GetDesc().GraphicsPipeline.BlendDesc.RenderTargets[i]; - - EXPECT_EQ(RT.BlendEnable, True) << "Render target: " << i; - if (TestingAlpha) - { - EXPECT_EQ(RT.BlendOpAlpha, BlendOp) << "Render target: " << i; - } - else - { - EXPECT_EQ(RT.BlendOp, BlendOp) << "Render target: " << i; - } - } - } -} - -INSTANTIATE_TEST_SUITE_P(BlendOperations, - BlendOperationTest, - testing::Combine( - testing::Range(BLEND_OPERATION_UNDEFINED + 1, BLEND_OPERATION_NUM_OPERATIONS), - testing::Values(true, false)), - [](const testing::TestParamInfo>& info) // - { - auto BlendOp = static_cast(std::get<0>(info.param)); - auto IsTestingAlpha = std::get<1>(info.param); - - std::stringstream name_ss; - name_ss << (IsTestingAlpha ? "Alpha_" : "Color_") << GetBlendOperationLiteralName(BlendOp); - return name_ss.str(); - } // -); - -} // namespace diff --git a/UnitTests/DiligentCoreAPITest/src/BrokenShaderTest.cpp b/UnitTests/DiligentCoreAPITest/src/BrokenShaderTest.cpp deleted file mode 100644 index d6eed1cd..00000000 --- a/UnitTests/DiligentCoreAPITest/src/BrokenShaderTest.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "TestingEnvironment.h" - -#include "gtest/gtest.h" - -using namespace Diligent; -using namespace Diligent::Testing; - -namespace -{ - -static const char g_BrokenShaderSource[] = R"( -void VSMain(out float4 pos : SV_POSITION) -{ - pos = float3(0.0, 0.0, 0.0, 0.0); -} -)"; - -TEST(Shader, CompilationFailure) -{ - auto* pEnv = TestingEnvironment::GetInstance(); - auto* pDevice = pEnv->GetDevice(); - - TestingEnvironment::ScopedReset EnvironmentAutoReset; - - ShaderCreateInfo Attrs; - Attrs.Source = g_BrokenShaderSource; - Attrs.EntryPoint = "VSMain"; - Attrs.Desc.ShaderType = SHADER_TYPE_VERTEX; - Attrs.Desc.Name = "Broken shader test"; - Attrs.SourceLanguage = SHADER_SOURCE_LANGUAGE_HLSL; - Attrs.UseCombinedTextureSamplers = true; - - IDataBlob* pErrors = nullptr; - Attrs.ppCompilerOutput = &pErrors; - - pEnv->SetErrorAllowance(pDevice->GetDeviceCaps().IsVulkanDevice() ? 3 : 2, "\n\nNo worries, testing broken shader...\n\n"); - RefCntAutoPtr pBrokenShader; - pDevice->CreateShader(Attrs, &pBrokenShader); - EXPECT_FALSE(pBrokenShader); - EXPECT_TRUE(pErrors); - const char* Msg = reinterpret_cast(pErrors->GetDataPtr()); - LOG_INFO_MESSAGE("Compiler output:\n", Msg); - pErrors->Release(); -} - -} // namespace diff --git a/UnitTests/DiligentCoreAPITest/src/BufferCreationTest.cpp b/UnitTests/DiligentCoreAPITest/src/BufferCreationTest.cpp deleted file mode 100644 index 3af7125c..00000000 --- a/UnitTests/DiligentCoreAPITest/src/BufferCreationTest.cpp +++ /dev/null @@ -1,256 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#if D3D11_SUPPORTED -# include "D3D11/CreateObjFromNativeResD3D11.h" -#endif - -#if D3D12_SUPPORTED -# include "D3D12/CreateObjFromNativeResD3D12.h" -#endif - -#if GL_SUPPORTED || GLES_SUPPORTED -# include "GL/CreateObjFromNativeResGL.h" -#endif - -#if VULKAN_SUPPORTED -# include "Vulkan/CreateObjFromNativeResVK.h" -#endif - -#include "GraphicsAccessories.h" - -#include "TestingEnvironment.h" - -#include "gtest/gtest.h" - -using namespace Diligent; -using namespace Diligent::Testing; - -namespace -{ - -class BufferCreationTest : public ::testing::Test -{ -protected: - static void SetUpTestSuite() - { - auto* pEnv = TestingEnvironment::GetInstance(); - auto* pDevice = pEnv->GetDevice(); - - const auto DevCaps = pDevice->GetDeviceCaps(); - switch (DevCaps.DevType) - { -#if D3D11_SUPPORTED - case DeviceType::D3D11: - pCreateObjFromNativeRes.reset(new TestCreateObjFromNativeResD3D11(pDevice)); - break; - -#endif - -#if D3D12_SUPPORTED - case DeviceType::D3D12: - pCreateObjFromNativeRes.reset(new TestCreateObjFromNativeResD3D12(pDevice)); - break; -#endif - -#if GL_SUPPORTED || GLES_SUPPORTED - case DeviceType::OpenGL: - case DeviceType::OpenGLES: - pCreateObjFromNativeRes.reset(new TestCreateObjFromNativeResGL(pDevice)); - break; -#endif - -#if VULKAN_SUPPORTED - case DeviceType::Vulkan: - pCreateObjFromNativeRes.reset(new TestCreateObjFromNativeResVK(pDevice)); - break; -#endif - - default: UNEXPECTED("Unexpected device type"); - } - } - - static void TearDownTestSuite() - { - pCreateObjFromNativeRes.reset(); - TestingEnvironment::GetInstance()->Reset(); - } - - static std::unique_ptr pCreateObjFromNativeRes; -}; - -std::unique_ptr BufferCreationTest::pCreateObjFromNativeRes; - -TEST_F(BufferCreationTest, CreateVertexBuffer) -{ - auto* pEnv = TestingEnvironment::GetInstance(); - auto* pDevice = pEnv->GetDevice(); - - BufferDesc BuffDesc; - BuffDesc.Name = "Vertex buffer"; - BuffDesc.uiSizeInBytes = 256; - BuffDesc.BindFlags = BIND_VERTEX_BUFFER; - - BufferData InitData; - InitData.DataSize = BuffDesc.uiSizeInBytes; - std::vector DummyData(InitData.DataSize); - InitData.pData = DummyData.data(); - RefCntAutoPtr pBuffer; - pDevice->CreateBuffer(BuffDesc, &InitData, &pBuffer); - ASSERT_NE(pBuffer, nullptr) << GetObjectDescString(BuffDesc); - - pCreateObjFromNativeRes->CreateBuffer(pBuffer); -} - -TEST_F(BufferCreationTest, CreateIndexBuffer) -{ - auto* pEnv = TestingEnvironment::GetInstance(); - auto* pDevice = pEnv->GetDevice(); - - BufferDesc BuffDesc; - BuffDesc.Name = "Index"; - BuffDesc.uiSizeInBytes = 256; - BuffDesc.BindFlags = BIND_VERTEX_BUFFER; - - BufferData NullData; - - RefCntAutoPtr pBuffer; - pDevice->CreateBuffer(BuffDesc, &NullData, &pBuffer); - ASSERT_NE(pBuffer, nullptr) << GetObjectDescString(BuffDesc); - - pCreateObjFromNativeRes->CreateBuffer(pBuffer); -} - -TEST_F(BufferCreationTest, CreateFormattedBuffer) -{ - auto* pEnv = TestingEnvironment::GetInstance(); - auto* pDevice = pEnv->GetDevice(); - - const auto& DevCaps = pDevice->GetDeviceCaps(); - if (!(DevCaps.bComputeShadersSupported && DevCaps.bIndirectRenderingSupported)) - { - GTEST_SKIP(); - } - - BufferDesc BuffDesc; - BuffDesc.Name = "Formatted buffer"; - BuffDesc.uiSizeInBytes = 256; - BuffDesc.BindFlags = BIND_UNORDERED_ACCESS | BIND_SHADER_RESOURCE; - BuffDesc.Mode = BUFFER_MODE_FORMATTED; - BuffDesc.ElementByteStride = 16; - - RefCntAutoPtr pBuffer; - pDevice->CreateBuffer(BuffDesc, nullptr, &pBuffer); - ASSERT_NE(pBuffer, nullptr) << GetObjectDescString(BuffDesc); - - BufferViewDesc ViewDesc; - ViewDesc.ViewType = BUFFER_VIEW_SHADER_RESOURCE; - ViewDesc.ByteOffset = 32; - ViewDesc.Format.NumComponents = 4; - ViewDesc.Format.ValueType = VT_FLOAT32; - ViewDesc.Format.IsNormalized = false; - RefCntAutoPtr pBufferSRV; - pBuffer->CreateView(ViewDesc, &pBufferSRV); - EXPECT_NE(pBufferSRV, nullptr) << GetObjectDescString(BuffDesc); - - ViewDesc.ViewType = BUFFER_VIEW_UNORDERED_ACCESS; - RefCntAutoPtr pBufferUAV; - pBuffer->CreateView(ViewDesc, &pBufferUAV); - EXPECT_NE(pBufferUAV, nullptr) << GetObjectDescString(BuffDesc); - - pCreateObjFromNativeRes->CreateBuffer(pBuffer); -} - -TEST_F(BufferCreationTest, CreateStructuedBuffer) -{ - auto* pEnv = TestingEnvironment::GetInstance(); - auto* pDevice = pEnv->GetDevice(); - - const auto& DevCaps = pDevice->GetDeviceCaps(); - if (!DevCaps.bComputeShadersSupported) - { - GTEST_SKIP(); - } - - BufferDesc BuffDesc; - BuffDesc.Name = "Structured buffer"; - BuffDesc.uiSizeInBytes = 256; - BuffDesc.BindFlags = BIND_SHADER_RESOURCE | BIND_UNORDERED_ACCESS; - BuffDesc.Mode = BUFFER_MODE_STRUCTURED; - BuffDesc.ElementByteStride = 16; - RefCntAutoPtr pBuffer; - pDevice->CreateBuffer(BuffDesc, nullptr, &pBuffer); - ASSERT_NE(pBuffer, nullptr) << GetObjectDescString(BuffDesc); - - pCreateObjFromNativeRes->CreateBuffer(pBuffer); -} - -TEST_F(BufferCreationTest, CreateUniformBuffer) -{ - auto* pEnv = TestingEnvironment::GetInstance(); - auto* pDevice = pEnv->GetDevice(); - - BufferDesc BuffDesc; - BuffDesc.Name = "Uniform buffer"; - BuffDesc.uiSizeInBytes = 256; - BuffDesc.BindFlags = BIND_UNIFORM_BUFFER; - RefCntAutoPtr pBuffer; - pDevice->CreateBuffer(BuffDesc, nullptr, &pBuffer); - ASSERT_NE(pBuffer, nullptr) << GetObjectDescString(BuffDesc); - - pCreateObjFromNativeRes->CreateBuffer(pBuffer); -} - -TEST_F(BufferCreationTest, CreateRawBuffer) -{ - auto* pEnv = TestingEnvironment::GetInstance(); - auto* pDevice = pEnv->GetDevice(); - - BufferDesc BuffDesc; - BuffDesc.Name = "Raw buffer"; - BuffDesc.uiSizeInBytes = 256; - BuffDesc.BindFlags = BIND_VERTEX_BUFFER | BIND_INDEX_BUFFER | BIND_UNORDERED_ACCESS | BIND_SHADER_RESOURCE; - BuffDesc.Mode = BUFFER_MODE_RAW; - BuffDesc.ElementByteStride = 16; - RefCntAutoPtr pBuffer; - pDevice->CreateBuffer(BuffDesc, nullptr, &pBuffer); - ASSERT_NE(pBuffer, nullptr) << GetObjectDescString(BuffDesc); - - BufferViewDesc ViewDesc; - ViewDesc.ViewType = BUFFER_VIEW_UNORDERED_ACCESS; - ViewDesc.ByteOffset = 32; - ViewDesc.Format.NumComponents = 4; - ViewDesc.Format.ValueType = VT_FLOAT32; - RefCntAutoPtr pBufferUAV; - pBuffer->CreateView(ViewDesc, &pBufferUAV); - ASSERT_NE(pBufferUAV, nullptr) << GetObjectDescString(BuffDesc); - - ViewDesc.ViewType = BUFFER_VIEW_SHADER_RESOURCE; - RefCntAutoPtr pBufferSRV; - pBuffer->CreateView(ViewDesc, &pBufferSRV); - ASSERT_NE(pBufferSRV, nullptr) << GetObjectDescString(BuffDesc); - - pCreateObjFromNativeRes->CreateBuffer(pBuffer); -} - -} // namespace diff --git a/UnitTests/DiligentCoreAPITest/src/ClearRenderTargetTest.cpp b/UnitTests/DiligentCoreAPITest/src/ClearRenderTargetTest.cpp deleted file mode 100644 index 940d22e0..00000000 --- a/UnitTests/DiligentCoreAPITest/src/ClearRenderTargetTest.cpp +++ /dev/null @@ -1,127 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "TestingEnvironment.h" -#include "TestingSwapChainBase.h" - -#include "gtest/gtest.h" - -namespace Diligent -{ - -namespace Testing -{ - -#if D3D11_SUPPORTED -void ClearRenderTargetReferenceD3D11(ISwapChain* pSwapChain); -#endif - -#if D3D12_SUPPORTED -void ClearRenderTargetReferenceD3D12(ISwapChain* pSwapChain); -#endif - -#if GL_SUPPORTED || GLES_SUPPORTED -void ClearRenderTargetReferenceGL(ISwapChain* pSwapChain); -#endif - -#if VULKAN_SUPPORTED -void ClearRenderTargetReferenceVk(ISwapChain* pSwapChain); -#endif - -#if METAL_SUPPORTED - -#endif - -} // namespace Testing - -} // namespace Diligent - -using namespace Diligent; -using namespace Diligent::Testing; - -namespace -{ - -TEST(ClearRenderTargetTest, Clear) -{ - auto* pEnv = TestingEnvironment::GetInstance(); - auto* pDevice = pEnv->GetDevice(); - auto* pSwapChain = pEnv->GetSwapChain(); - auto* pConext = pEnv->GetDeviceContext(); - - RefCntAutoPtr pTestingSwapChain(pSwapChain, IID_TestingSwapChain); - if (pTestingSwapChain) - { - pConext->Flush(); - pConext->InvalidateState(); - - auto deviceType = pDevice->GetDeviceCaps().DevType; - switch (deviceType) - { -#if D3D11_SUPPORTED - case DeviceType::D3D11: - ClearRenderTargetReferenceD3D11(pSwapChain); - break; -#endif - -#if D3D12_SUPPORTED - case DeviceType::D3D12: - ClearRenderTargetReferenceD3D12(pSwapChain); - break; -#endif - -#if GL_SUPPORTED || GLES_SUPPORTED - case DeviceType::OpenGL: - case DeviceType::OpenGLES: - ClearRenderTargetReferenceGL(pSwapChain); - break; - -#endif - -#if VULKAN_SUPPORTED - case DeviceType::Vulkan: - ClearRenderTargetReferenceVk(pSwapChain); - break; - -#endif - - default: - LOG_ERROR_AND_THROW("Unsupported device type"); - } - - pTestingSwapChain->TakeSnapshot(); - } - TestingEnvironment::ScopedReleaseResources EnvironmentAutoReset; - - auto* pContext = pEnv->GetDeviceContext(); - - ITextureView* pRTVs[] = {pSwapChain->GetCurrentBackBufferRTV()}; - pContext->SetRenderTargets(1, pRTVs, nullptr, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); - - float ClearColor[] = {0.25f, 0.5f, 0.75f, 1.0f}; - pContext->ClearRenderTarget(pRTVs[0], ClearColor, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); - - pSwapChain->Present(); -} - -} // namespace diff --git a/UnitTests/DiligentCoreAPITest/src/CopyTextureTest.cpp b/UnitTests/DiligentCoreAPITest/src/CopyTextureTest.cpp deleted file mode 100644 index 633cf167..00000000 --- a/UnitTests/DiligentCoreAPITest/src/CopyTextureTest.cpp +++ /dev/null @@ -1,278 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "TestingEnvironment.h" - -#include "gtest/gtest.h" - -using namespace Diligent; -using namespace Diligent::Testing; - -namespace -{ - -// clang-format off -TEXTURE_FORMAT TestFormats[] = -{ - TEX_FORMAT_RGBA32_FLOAT, - TEX_FORMAT_RGBA32_UINT, - TEX_FORMAT_RGBA32_SINT, - TEX_FORMAT_RGBA16_FLOAT, - TEX_FORMAT_RGBA16_UINT, - TEX_FORMAT_RGBA16_SINT, - TEX_FORMAT_RGBA8_UNORM, - TEX_FORMAT_RGBA8_SNORM, - TEX_FORMAT_RGBA8_UINT, - TEX_FORMAT_RGBA8_SINT, - - TEX_FORMAT_RG32_FLOAT, - TEX_FORMAT_RG32_UINT, - TEX_FORMAT_RG32_SINT, - TEX_FORMAT_RG16_FLOAT, - TEX_FORMAT_RG16_UINT, - TEX_FORMAT_RG16_SINT, - TEX_FORMAT_RG8_UNORM, - TEX_FORMAT_RG8_SNORM, - TEX_FORMAT_RG8_UINT, - TEX_FORMAT_RG8_SINT, - - TEX_FORMAT_R32_FLOAT, - TEX_FORMAT_R32_UINT, - TEX_FORMAT_R32_SINT, - TEX_FORMAT_R16_FLOAT, - TEX_FORMAT_R16_UINT, - TEX_FORMAT_R16_SINT, - TEX_FORMAT_R8_UNORM, - TEX_FORMAT_R8_SNORM, - TEX_FORMAT_R8_UINT, - TEX_FORMAT_R8_SINT -}; -// clang-format on - -TEST(CopyTexture, Texture2D) -{ - auto* pEnv = TestingEnvironment::GetInstance(); - auto* pDevice = pEnv->GetDevice(); - auto* pContext = pEnv->GetDeviceContext(); - - TestingEnvironment::ScopedReleaseResources EnvironmentAutoReset; - - for (auto f = 0; f < _countof(TestFormats); ++f) - { - auto Format = TestFormats[f]; - - TextureDesc TexDesc; - TexDesc.Type = RESOURCE_DIM_TEX_2D; - TexDesc.Format = Format; - TexDesc.Width = 128; - TexDesc.Height = 128; - TexDesc.BindFlags = BIND_SHADER_RESOURCE; - TexDesc.MipLevels = 5; - TexDesc.Usage = USAGE_DEFAULT; - - Diligent::RefCntAutoPtr pSrcTex, pDstTex; - - auto FmtAttribs = pDevice->GetTextureFormatInfo(Format); - auto TexelSize = Uint32{FmtAttribs.ComponentSize} * Uint32{FmtAttribs.NumComponents}; - std::vector DummyData(size_t{TexDesc.Width} * size_t{TexDesc.Height} * size_t{TexelSize}); - TextureData InitData; - InitData.NumSubresources = TexDesc.MipLevels; - std::vector SubResData(InitData.NumSubresources); - for (Uint32 mip = 0; mip < TexDesc.MipLevels; ++mip) - { - SubResData[mip] = TextureSubResData{DummyData.data(), (TexDesc.Width >> mip) * TexelSize, 0}; - } - InitData.pSubResources = SubResData.data(); - pDevice->CreateTexture(TexDesc, &InitData, &pSrcTex); - pDevice->CreateTexture(TexDesc, nullptr, &pDstTex); - - CopyTextureAttribs CopyAttribs; - CopyAttribs.pSrcTexture = pSrcTex; - CopyAttribs.SrcMipLevel = 2; - CopyAttribs.pDstTexture = pDstTex; - CopyAttribs.DstMipLevel = 1; - CopyAttribs.DstX = 32; - CopyAttribs.DstY = 16; - CopyAttribs.DstZ = 0; - CopyAttribs.SrcTextureTransitionMode = RESOURCE_STATE_TRANSITION_MODE_TRANSITION; - CopyAttribs.DstTextureTransitionMode = RESOURCE_STATE_TRANSITION_MODE_TRANSITION; - pContext->CopyTexture(CopyAttribs); - - Box SrcBox; - SrcBox.MinX = 3; - SrcBox.MaxX = 19; - SrcBox.MinY = 1; - SrcBox.MaxY = 32; - - CopyAttribs.pSrcBox = &SrcBox; - CopyAttribs.SrcTextureTransitionMode = RESOURCE_STATE_TRANSITION_MODE_VERIFY; - CopyAttribs.DstTextureTransitionMode = RESOURCE_STATE_TRANSITION_MODE_VERIFY; - pContext->CopyTexture(CopyAttribs); - - pEnv->ReleaseResources(); - } -} - -TEST(CopyTexture, Texture2DArray) -{ - auto* pEnv = TestingEnvironment::GetInstance(); - auto* pDevice = pEnv->GetDevice(); - auto* pContext = pEnv->GetDeviceContext(); - - TestingEnvironment::ScopedReleaseResources EnvironmentAutoReset; - - for (auto f = 0; f < _countof(TestFormats); ++f) - { - auto Format = TestFormats[f]; - - TextureDesc TexDesc; - TexDesc.Type = RESOURCE_DIM_TEX_2D_ARRAY; - TexDesc.Format = Format; - TexDesc.Width = 128; - TexDesc.Height = 128; - TexDesc.BindFlags = BIND_SHADER_RESOURCE; - TexDesc.MipLevels = 5; - TexDesc.ArraySize = 8; - TexDesc.Usage = USAGE_DEFAULT; - - Diligent::RefCntAutoPtr pSrcTex, pDstTex; - auto FmtAttribs = pDevice->GetTextureFormatInfo(Format); - auto TexelSize = Uint32{FmtAttribs.ComponentSize} * Uint32{FmtAttribs.NumComponents}; - std::vector DummyData(size_t{TexDesc.Width} * size_t{TexDesc.Height} * size_t{TexelSize}); - TextureData InitData; - InitData.NumSubresources = TexDesc.MipLevels * TexDesc.ArraySize; - std::vector SubResData(InitData.NumSubresources); - Uint32 subres = 0; - for (Uint32 slice = 0; slice < TexDesc.ArraySize; ++slice) - { - for (Uint32 mip = 0; mip < TexDesc.MipLevels; ++mip) - { - SubResData[subres++] = TextureSubResData{DummyData.data(), (TexDesc.Width >> mip) * TexelSize, 0}; - } - } - VERIFY_EXPR(subres == InitData.NumSubresources); - InitData.pSubResources = SubResData.data(); - - pDevice->CreateTexture(TexDesc, &InitData, &pSrcTex); - pDevice->CreateTexture(TexDesc, nullptr, &pDstTex); - - CopyTextureAttribs CopyAttribs; - CopyAttribs.pSrcTexture = pSrcTex; - CopyAttribs.SrcMipLevel = 2; - CopyAttribs.SrcSlice = 3; - CopyAttribs.pDstTexture = pDstTex; - CopyAttribs.DstMipLevel = 1; - CopyAttribs.DstSlice = 6; - CopyAttribs.DstX = 32; - CopyAttribs.DstY = 16; - CopyAttribs.DstZ = 0; - CopyAttribs.SrcTextureTransitionMode = RESOURCE_STATE_TRANSITION_MODE_TRANSITION; - CopyAttribs.DstTextureTransitionMode = RESOURCE_STATE_TRANSITION_MODE_TRANSITION; - pContext->CopyTexture(CopyAttribs); - - Box SrcBox; - SrcBox.MinX = 3; - SrcBox.MaxX = 19; - SrcBox.MinY = 1; - SrcBox.MaxY = 32; - - CopyAttribs.DstSlice = 5; - CopyAttribs.pSrcBox = &SrcBox; - CopyAttribs.SrcTextureTransitionMode = RESOURCE_STATE_TRANSITION_MODE_VERIFY; - CopyAttribs.DstTextureTransitionMode = RESOURCE_STATE_TRANSITION_MODE_VERIFY; - pContext->CopyTexture(CopyAttribs); - - pEnv->ReleaseResources(); - } -} - -TEST(CopyTexture, Texture3D) -{ - auto* pEnv = TestingEnvironment::GetInstance(); - auto* pDevice = pEnv->GetDevice(); - auto* pContext = pEnv->GetDeviceContext(); - - TestingEnvironment::ScopedReleaseResources EnvironmentAutoReset; - - for (auto f = 0; f < _countof(TestFormats); ++f) - { - auto Format = TestFormats[f]; - - TextureDesc TexDesc; - TexDesc.Type = RESOURCE_DIM_TEX_3D; - TexDesc.Format = Format; - TexDesc.Width = 64; - TexDesc.Height = 64; - TexDesc.Depth = 16; - TexDesc.BindFlags = BIND_SHADER_RESOURCE; - TexDesc.MipLevels = 4; - TexDesc.Usage = USAGE_DEFAULT; - - Diligent::RefCntAutoPtr pSrcTex, pDstTex; - - auto FmtAttribs = pDevice->GetTextureFormatInfo(Format); - auto TexelSize = Uint32{FmtAttribs.ComponentSize} * Uint32{FmtAttribs.NumComponents}; - std::vector DummyData(size_t{TexDesc.Width} * size_t{TexDesc.Height} * size_t{TexDesc.Depth} * size_t{TexelSize}); - TextureData InitData; - InitData.NumSubresources = TexDesc.MipLevels; - std::vector SubResData(InitData.NumSubresources); - for (Uint32 mip = 0; mip < TexDesc.MipLevels; ++mip) - { - SubResData[mip] = TextureSubResData{DummyData.data(), (TexDesc.Width >> mip) * TexelSize, (TexDesc.Width >> mip) * (TexDesc.Height >> mip) * TexelSize}; - } - InitData.pSubResources = SubResData.data(); - pDevice->CreateTexture(TexDesc, &InitData, &pSrcTex); - pDevice->CreateTexture(TexDesc, nullptr, &pDstTex); - - CopyTextureAttribs CopyAttribs; - CopyAttribs.pSrcTexture = pSrcTex; - CopyAttribs.SrcMipLevel = 2; - CopyAttribs.pDstTexture = pDstTex; - CopyAttribs.DstMipLevel = 1; - CopyAttribs.DstX = 16; - CopyAttribs.DstY = 8; - CopyAttribs.DstZ = 0; - CopyAttribs.SrcTextureTransitionMode = RESOURCE_STATE_TRANSITION_MODE_TRANSITION; - CopyAttribs.DstTextureTransitionMode = RESOURCE_STATE_TRANSITION_MODE_TRANSITION; - - pContext->CopyTexture(CopyAttribs); - - Box SrcBox; - SrcBox.MinX = 3; - SrcBox.MaxX = 19; - SrcBox.MinY = 1; - SrcBox.MaxY = 32; - - CopyAttribs.pSrcBox = &SrcBox; - CopyAttribs.SrcMipLevel = 1; - CopyAttribs.DstMipLevel = 0; - CopyAttribs.DstX = 32; - CopyAttribs.DstY = 16; - CopyAttribs.DstZ = 0; - pContext->CopyTexture(CopyAttribs); - - pEnv->ReleaseResources(); - } -} - -} // namespace diff --git a/UnitTests/DiligentCoreAPITest/src/D3D11/ClearRenderTargetRefenceD3D11.cpp b/UnitTests/DiligentCoreAPITest/src/D3D11/ClearRenderTargetRefenceD3D11.cpp deleted file mode 100644 index 72eef2c0..00000000 --- a/UnitTests/DiligentCoreAPITest/src/D3D11/ClearRenderTargetRefenceD3D11.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "D3D11/TestingEnvironmentD3D11.h" -#include "D3D11/TestingSwapChainD3D11.h" - -namespace Diligent -{ - -namespace Testing -{ - -void ClearRenderTargetReferenceD3D11(ISwapChain* pSwapChain) -{ - auto* pEnvD3D11 = TestingEnvironmentD3D11::GetInstance(); - auto* pd3d11Context = pEnvD3D11->GetD3D11Context(); - auto* pTestingSwapChainD3D11 = ValidatedCast(pSwapChain); - - float ClearColor[] = {0.25, 0.5, 0.75, 1.0}; - pd3d11Context->ClearRenderTargetView(pTestingSwapChainD3D11->GetD3D11RTV(), ClearColor); - - pd3d11Context->ClearState(); -} - -} // namespace Testing - -} // namespace Diligent diff --git a/UnitTests/DiligentCoreAPITest/src/D3D11/CreateObjFromNativeResD3D11.cpp b/UnitTests/DiligentCoreAPITest/src/D3D11/CreateObjFromNativeResD3D11.cpp deleted file mode 100644 index 08b9b6fd..00000000 --- a/UnitTests/DiligentCoreAPITest/src/D3D11/CreateObjFromNativeResD3D11.cpp +++ /dev/null @@ -1,136 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "D3D11/CreateObjFromNativeResD3D11.h" - -#include -#include "RenderDeviceD3D11.h" -#include "TextureD3D11.h" -#include "BufferD3D11.h" -#include "GraphicsAccessories.h" - -#include "gtest/gtest.h" - -namespace Diligent -{ - -namespace Testing -{ - -void TestCreateObjFromNativeResD3D11::CreateTexture(ITexture* pTexture) -{ - RefCntAutoPtr pDeviceD3D11(m_pDevice, IID_RenderDeviceD3D11); - RefCntAutoPtr pTextureD3D11(pTexture, IID_TextureD3D11); - ASSERT_NE(pDeviceD3D11, nullptr); - ASSERT_NE(pTextureD3D11, nullptr); - - auto* pd3d11Texture = pTextureD3D11->GetD3D11Texture(); - ASSERT_NE(pd3d11Texture, nullptr); - - const auto& SrcTexDesc = pTexture->GetDesc(); - - RefCntAutoPtr pTextureFromNativeD3D11Handle; - if (SrcTexDesc.Type == RESOURCE_DIM_TEX_1D || - SrcTexDesc.Type == RESOURCE_DIM_TEX_1D_ARRAY) - { - pDeviceD3D11->CreateTextureFromD3DResource(static_cast(pd3d11Texture), RESOURCE_STATE_UNKNOWN, &pTextureFromNativeD3D11Handle); - } - else if (SrcTexDesc.Type == RESOURCE_DIM_TEX_2D || - SrcTexDesc.Type == RESOURCE_DIM_TEX_2D_ARRAY || - SrcTexDesc.Type == RESOURCE_DIM_TEX_CUBE || - SrcTexDesc.Type == RESOURCE_DIM_TEX_CUBE_ARRAY) - { - pDeviceD3D11->CreateTextureFromD3DResource(static_cast(pd3d11Texture), RESOURCE_STATE_UNKNOWN, &pTextureFromNativeD3D11Handle); - } - else if (SrcTexDesc.Type == RESOURCE_DIM_TEX_3D) - { - pDeviceD3D11->CreateTextureFromD3DResource(static_cast(pd3d11Texture), RESOURCE_STATE_UNKNOWN, &pTextureFromNativeD3D11Handle); - } - else - { - ADD_FAILURE(); - } - - ASSERT_NE(pTextureFromNativeD3D11Handle, nullptr); - - auto TestTexDesc = pTextureFromNativeD3D11Handle->GetDesc(); - if (SrcTexDesc.Type == RESOURCE_DIM_TEX_CUBE || SrcTexDesc.Type == RESOURCE_DIM_TEX_CUBE_ARRAY) - { - EXPECT_EQ(TestTexDesc.Type, RESOURCE_DIM_TEX_2D_ARRAY); - TestTexDesc.Type = SrcTexDesc.Type; - } - EXPECT_EQ(TestTexDesc, SrcTexDesc) << "Src tex desc: " << GetObjectDescString(SrcTexDesc) - << "\nTest tex desc: " << GetObjectDescString(TestTexDesc); - - RefCntAutoPtr pTestTextureD3D11(pTextureFromNativeD3D11Handle, IID_TextureD3D11); - ASSERT_NE(pTestTextureD3D11, nullptr); - EXPECT_EQ(pTestTextureD3D11->GetD3D11Texture(), pd3d11Texture); - EXPECT_EQ(pTestTextureD3D11->GetNativeHandle(), pd3d11Texture); -} - -void TestCreateObjFromNativeResD3D11::CreateBuffer(IBuffer* pBuffer) -{ - RefCntAutoPtr pDeviceD3D11(m_pDevice, IID_RenderDeviceD3D11); - RefCntAutoPtr pBufferD3D11(pBuffer, IID_BufferD3D11); - ASSERT_NE(pDeviceD3D11, nullptr); - ASSERT_NE(pBufferD3D11, nullptr); - - auto* pd3d11Buffer = pBufferD3D11->GetD3D11Buffer(); - ASSERT_NE(pd3d11Buffer, nullptr); - - const auto& SrcBuffDesc = pBuffer->GetDesc(); - { - RefCntAutoPtr pBufferFromNativeD3D11Handle; - pDeviceD3D11->CreateBufferFromD3DResource(pd3d11Buffer, SrcBuffDesc, RESOURCE_STATE_UNKNOWN, &pBufferFromNativeD3D11Handle); - ASSERT_NE(pBufferFromNativeD3D11Handle, nullptr); - - const auto& TestBufferDesc = pBufferFromNativeD3D11Handle->GetDesc(); - EXPECT_EQ(TestBufferDesc, SrcBuffDesc); - - RefCntAutoPtr pTestBufferD3D11(pBufferFromNativeD3D11Handle, IID_BufferD3D11); - EXPECT_EQ(pTestBufferD3D11->GetD3D11Buffer(), pd3d11Buffer); - EXPECT_EQ(pTestBufferD3D11->GetNativeHandle(), pd3d11Buffer); - } - - { - BufferDesc BuffDesc; - BuffDesc.Name = "Test buffer from D3D11 buffer"; - BuffDesc.ElementByteStride = SrcBuffDesc.ElementByteStride; - RefCntAutoPtr pBufferFromNativeD3D11Handle; - pDeviceD3D11->CreateBufferFromD3DResource(pd3d11Buffer, BuffDesc, RESOURCE_STATE_UNKNOWN, &pBufferFromNativeD3D11Handle); - ASSERT_NE(pBufferFromNativeD3D11Handle, nullptr); - - const auto& TestBufferDesc = pBufferFromNativeD3D11Handle->GetDesc(); - EXPECT_EQ(TestBufferDesc, SrcBuffDesc) << "Src buff desc: " << GetObjectDescString(SrcBuffDesc) - << "\nTest buff desc: " << GetObjectDescString(TestBufferDesc); - - RefCntAutoPtr pTestBufferD3D11(pBufferFromNativeD3D11Handle, IID_BufferD3D11); - ASSERT_NE(pTestBufferD3D11, nullptr); - EXPECT_EQ(pTestBufferD3D11->GetD3D11Buffer(), pd3d11Buffer); - EXPECT_EQ(pTestBufferD3D11->GetNativeHandle(), pd3d11Buffer); - } -} - -} // namespace Testing - -} // namespace Diligent diff --git a/UnitTests/DiligentCoreAPITest/src/D3D11/DrawCommandRefenceD3D11.cpp b/UnitTests/DiligentCoreAPITest/src/D3D11/DrawCommandRefenceD3D11.cpp deleted file mode 100644 index 376221d1..00000000 --- a/UnitTests/DiligentCoreAPITest/src/D3D11/DrawCommandRefenceD3D11.cpp +++ /dev/null @@ -1,121 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "D3D11/TestingEnvironmentD3D11.h" -#include "D3D11/TestingSwapChainD3D11.h" - -namespace Diligent -{ - -namespace Testing -{ - -static const char* VSSource = R"( -struct PSInput -{ - float4 Pos : SV_POSITION; - float3 Color : COLOR; -}; - -void main(in uint VertId : SV_VertexID, - out PSInput PSIn) -{ - float4 Pos[6]; - Pos[0] = float4(-1.0, -0.5, 0.0, 1.0); - Pos[1] = float4(-0.5, +0.5, 0.0, 1.0); - Pos[2] = float4( 0.0, -0.5, 0.0, 1.0); - - Pos[3] = float4(+0.0, -0.5, 0.0, 1.0); - Pos[4] = float4(+0.5, +0.5, 0.0, 1.0); - Pos[5] = float4(+1.0, -0.5, 0.0, 1.0); - - float3 Col[6]; - Col[0] = float3(1.0, 0.0, 0.0); - Col[1] = float3(0.0, 1.0, 0.0); - Col[2] = float3(0.0, 0.0, 1.0); - - Col[3] = float3(1.0, 0.0, 0.0); - Col[4] = float3(0.0, 1.0, 0.0); - Col[5] = float3(0.0, 0.0, 1.0); - - PSIn.Pos = Pos[VertId]; - PSIn.Color = Col[VertId]; -} -)"; - -static const char* PSSource = R"( -struct PSInput -{ - float4 Pos : SV_POSITION; - float3 Color : COLOR; -}; - -float4 main(in PSInput PSIn) : SV_Target -{ - return float4(PSIn.Color.rgb, 1.0); -} -)"; - -void RenderDrawCommandRefenceD3D11(ISwapChain* pSwapChain) -{ - auto* pEnvD3D11 = TestingEnvironmentD3D11::GetInstance(); - auto* pd3d11Context = pEnvD3D11->GetD3D11Context(); - auto* pTestingSwapChainD3D11 = ValidatedCast(pSwapChain); - - pd3d11Context->ClearState(); - - auto pVS = pEnvD3D11->CreateVertexShader(VSSource); - ASSERT_NE(pVS, nullptr); - - auto pPS = pEnvD3D11->CreatePixelShader(PSSource); - ASSERT_NE(pPS, nullptr); - - pd3d11Context->VSSetShader(pVS, nullptr, 0); - pd3d11Context->PSSetShader(pPS, nullptr, 0); - pd3d11Context->RSSetState(pEnvD3D11->GetNoCullRS()); - pd3d11Context->OMSetBlendState(pEnvD3D11->GetDefaultBS(), nullptr, 0xFFFFFFFF); - pd3d11Context->OMSetDepthStencilState(pEnvD3D11->GetDisableDepthDSS(), 0); - pd3d11Context->IASetInputLayout(nullptr); - - ID3D11RenderTargetView* pd3d11RTVs[] = {pTestingSwapChainD3D11->GetD3D11RTV()}; - pd3d11Context->OMSetRenderTargets(1, pd3d11RTVs, nullptr); - float ClearColor[] = {0, 0, 0, 0}; - pd3d11Context->ClearRenderTargetView(pd3d11RTVs[0], ClearColor); - - D3D11_VIEWPORT d3dVP = {}; - - const auto& SCDesc = pTestingSwapChainD3D11->GetDesc(); - d3dVP.Width = static_cast(SCDesc.Width); - d3dVP.Height = static_cast(SCDesc.Height); - d3dVP.MaxDepth = 1; - pd3d11Context->RSSetViewports(1, &d3dVP); - - pd3d11Context->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST); - pd3d11Context->Draw(6, 0); - - pd3d11Context->ClearState(); -} - -} // namespace Testing - -} // namespace Diligent diff --git a/UnitTests/DiligentCoreAPITest/src/D3D11/TestingEnvironmentD3D11.cpp b/UnitTests/DiligentCoreAPITest/src/D3D11/TestingEnvironmentD3D11.cpp deleted file mode 100644 index 3f63218f..00000000 --- a/UnitTests/DiligentCoreAPITest/src/D3D11/TestingEnvironmentD3D11.cpp +++ /dev/null @@ -1,244 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "D3D11/TestingEnvironmentD3D11.h" - -#include "RenderDeviceD3D11.h" -#include "DeviceContextD3D11.h" - -#include - -namespace Diligent -{ - -namespace Testing -{ - -void CreateTestingSwapChainD3D11(IRenderDevice* pDevice, - IDeviceContext* pContext, - const SwapChainDesc& SCDesc, - ISwapChain** ppSwapChain); - - -TestingEnvironmentD3D11::TestingEnvironmentD3D11(DeviceType deviceType, ADAPTER_TYPE AdapterType, const SwapChainDesc& SCDesc) : - TestingEnvironment{deviceType, AdapterType, SCDesc} -{ - RefCntAutoPtr pRenderDeviceD3D11{m_pDevice, IID_RenderDeviceD3D11}; - RefCntAutoPtr pContextD3D11{m_pDeviceContext, IID_DeviceContextD3D11}; - - m_pd3d11Device = pRenderDeviceD3D11->GetD3D11Device(); - m_pd3d11Context = pContextD3D11->GetD3D11DeviceContext(); - - { - D3D11_RASTERIZER_DESC RSDesc = {}; - - RSDesc.CullMode = D3D11_CULL_NONE; - RSDesc.FillMode = D3D11_FILL_SOLID; - auto hr = m_pd3d11Device->CreateRasterizerState(&RSDesc, &m_pd3d11NoCullRS); - VERIFY_EXPR(SUCCEEDED(hr)); - } - - { - D3D11_DEPTH_STENCIL_DESC DSDesc = {}; - - DSDesc.DepthEnable = False; - auto hr = m_pd3d11Device->CreateDepthStencilState(&DSDesc, &m_pd3d11DisableDepthDSS); - VERIFY_EXPR(SUCCEEDED(hr)); - } - - { - D3D11_BLEND_DESC BSDesc = {}; - - BSDesc.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL; - - auto hr = m_pd3d11Device->CreateBlendState(&BSDesc, &m_pd3d11DefaultBS); - VERIFY_EXPR(SUCCEEDED(hr)); - } - - if (m_pSwapChain == nullptr) - { - CreateTestingSwapChainD3D11(m_pDevice, m_pDeviceContext, SCDesc, &m_pSwapChain); - } -} - -HRESULT CompileD3DShader(const char* Source, - LPCSTR strFunctionName, - const D3D_SHADER_MACRO* pDefines, - LPCSTR profile, - ID3DBlob** ppBlobOut) -{ - DWORD dwShaderFlags = D3DCOMPILE_ENABLE_STRICTNESS; -#if defined(DEBUG) || defined(_DEBUG) - // Set the D3D10_SHADER_DEBUG flag to embed debug information in the shaders. - // Setting this flag improves the shader debugging experience, but still allows - // the shaders to be optimized and to run exactly the way they will run in - // the release configuration of this program. - dwShaderFlags |= D3DCOMPILE_DEBUG; -#else - // Warning: do not use this flag as it causes shader compiler to fail the compilation and - // report strange errors: - // dwShaderFlags |= D3D10_SHADER_OPTIMIZATION_LEVEL3; -#endif - - CComPtr pCompilerOutput; - - auto SourceLen = strlen(Source); - - auto hr = D3DCompile(Source, SourceLen, NULL, pDefines, nullptr, strFunctionName, profile, dwShaderFlags, 0, ppBlobOut, &pCompilerOutput); - - const char* CompilerMsg = pCompilerOutput ? reinterpret_cast(pCompilerOutput->GetBufferPointer()) : nullptr; - if (FAILED(hr)) - { - LOG_ERROR_AND_THROW("Failed to compile D3D shader :\n", (CompilerMsg != nullptr ? CompilerMsg : "")); - } - else if (CompilerMsg != nullptr) - { - LOG_INFO_MESSAGE("Shader compiler output:\n", CompilerMsg); - } - - return hr; -} - -CComPtr TestingEnvironmentD3D11::CreateVertexShader(const char* Source, - LPCSTR strFunctionName, - const D3D_SHADER_MACRO* pDefines, - LPCSTR profile) -{ - CComPtr pByteCode; - CComPtr pVS; - - auto hr = CompileD3DShader(Source, strFunctionName, pDefines, profile, &pByteCode); - if (FAILED(hr)) - { - ADD_FAILURE() << "Failed to compile vertex shader"; - return pVS; - } - - hr = m_pd3d11Device->CreateVertexShader(pByteCode->GetBufferPointer(), pByteCode->GetBufferSize(), NULL, &pVS); - if (FAILED(hr)) - { - ADD_FAILURE() << "Failed to create vertex shader"; - } - return pVS; -} - -CComPtr TestingEnvironmentD3D11::CreatePixelShader(const char* Source, - LPCSTR strFunctionName, - const D3D_SHADER_MACRO* pDefines, - LPCSTR profile) -{ - CComPtr pByteCode; - CComPtr pPS; - - auto hr = CompileD3DShader(Source, strFunctionName, pDefines, profile, &pByteCode); - if (FAILED(hr)) - { - ADD_FAILURE() << "Failed to compile pixel shader"; - return pPS; - } - - hr = m_pd3d11Device->CreatePixelShader(pByteCode->GetBufferPointer(), pByteCode->GetBufferSize(), NULL, &pPS); - if (FAILED(hr)) - { - ADD_FAILURE() << "Failed to create pixel shader"; - } - return pPS; -} - -CComPtr TestingEnvironmentD3D11::CreateGeometryShader(const char* Source, - LPCSTR strFunctionName, - const D3D_SHADER_MACRO* pDefines, - LPCSTR profile) -{ - CComPtr pByteCode; - CComPtr pGS; - - auto hr = CompileD3DShader(Source, strFunctionName, pDefines, profile, &pByteCode); - if (FAILED(hr)) - { - ADD_FAILURE() << "Failed to compile geometry shader"; - return pGS; - } - - hr = m_pd3d11Device->CreateGeometryShader(pByteCode->GetBufferPointer(), pByteCode->GetBufferSize(), NULL, &pGS); - if (FAILED(hr)) - { - ADD_FAILURE() << "Failed to create geometry shader"; - } - return pGS; -} - -CComPtr TestingEnvironmentD3D11::CreateDomainShader(const char* Source, - LPCSTR strFunctionName, - const D3D_SHADER_MACRO* pDefines, - LPCSTR profile) -{ - CComPtr pByteCode; - CComPtr pDS; - - auto hr = CompileD3DShader(Source, strFunctionName, pDefines, profile, &pByteCode); - if (FAILED(hr)) - { - ADD_FAILURE() << "Failed to compile domain shader"; - return pDS; - } - - hr = m_pd3d11Device->CreateDomainShader(pByteCode->GetBufferPointer(), pByteCode->GetBufferSize(), NULL, &pDS); - if (FAILED(hr)) - { - ADD_FAILURE() << "Failed to create domain shader"; - } - return pDS; -} - -CComPtr TestingEnvironmentD3D11::CreateHullShader(const char* Source, - LPCSTR strFunctionName, - const D3D_SHADER_MACRO* pDefines, - LPCSTR profile) -{ - CComPtr pByteCode; - CComPtr pDS; - - auto hr = CompileD3DShader(Source, strFunctionName, pDefines, profile, &pByteCode); - if (FAILED(hr)) - { - ADD_FAILURE() << "Failed to compile hull shader"; - return pDS; - } - - hr = m_pd3d11Device->CreateHullShader(pByteCode->GetBufferPointer(), pByteCode->GetBufferSize(), NULL, &pDS); - if (FAILED(hr)) - { - ADD_FAILURE() << "Failed to create hull shader"; - } - return pDS; -} - -TestingEnvironment* CreateTestingEnvironmentD3D11(DeviceType deviceType, ADAPTER_TYPE AdapterType, const SwapChainDesc& SCDesc) -{ - return new TestingEnvironmentD3D11{deviceType, AdapterType, SCDesc}; -} - -} // namespace Testing - -} // namespace Diligent diff --git a/UnitTests/DiligentCoreAPITest/src/D3D11/TestingSwapChainD3D11.cpp b/UnitTests/DiligentCoreAPITest/src/D3D11/TestingSwapChainD3D11.cpp deleted file mode 100644 index 675dd134..00000000 --- a/UnitTests/DiligentCoreAPITest/src/D3D11/TestingSwapChainD3D11.cpp +++ /dev/null @@ -1,134 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "../include/D3D11/TestingSwapChainD3D11.h" -#include "../include/DXGITypeConversions.h" - -#include "RenderDeviceD3D11.h" -#include "DeviceContextD3D11.h" - -namespace Diligent -{ - -namespace Testing -{ - -TestingSwapChainD3D11::TestingSwapChainD3D11(IReferenceCounters* pRefCounters, - IRenderDevice* pDevice, - IDeviceContext* pContext, - const SwapChainDesc& SCDesc) : - TBase // - { - pRefCounters, - pDevice, - pContext, - SCDesc // - } -{ - RefCntAutoPtr pRenderDeviceD3D11{pDevice, IID_RenderDeviceD3D11}; - RefCntAutoPtr pContextD3D11{pContext, IID_DeviceContextD3D11}; - - auto* pd3d11Device = pRenderDeviceD3D11->GetD3D11Device(); - m_pd3d11Context = pContextD3D11->GetD3D11DeviceContext(); - - D3D11_TEXTURE2D_DESC TexDesc = {}; - - TexDesc.Width = SCDesc.Width; - TexDesc.Height = SCDesc.Height; - TexDesc.MipLevels = 1; - TexDesc.ArraySize = 1; - TexDesc.Format = TexFormatToDXGI_Format(SCDesc.ColorBufferFormat); - TexDesc.SampleDesc.Count = 1; - TexDesc.SampleDesc.Quality = 0; - TexDesc.Usage = D3D11_USAGE_DEFAULT; - TexDesc.BindFlags = BIND_RENDER_TARGET; - TexDesc.CPUAccessFlags = 0; - TexDesc.MiscFlags = 0; - - auto hr = pd3d11Device->CreateTexture2D(&TexDesc, nullptr, &m_pd3d11RenderTarget); - VERIFY(SUCCEEDED(hr), "Failed to create D3D11 render target"); - - hr = pd3d11Device->CreateRenderTargetView(m_pd3d11RenderTarget, nullptr, &m_pd3d11RTV); - VERIFY(SUCCEEDED(hr), "Failed to create D3D11 render target view"); - - TexDesc.BindFlags = 0; - TexDesc.Usage = D3D11_USAGE_STAGING; - TexDesc.CPUAccessFlags = D3D11_CPU_ACCESS_READ; - - hr = pd3d11Device->CreateTexture2D(&TexDesc, nullptr, &m_pd3d11StagingTex); - VERIFY(SUCCEEDED(hr), "Failed to create staging D3D11 texture"); - - if (SCDesc.DepthBufferFormat != TEX_FORMAT_UNKNOWN) - { - TexDesc.Usage = D3D11_USAGE_DEFAULT; - TexDesc.Format = TexFormatToDXGI_Format(SCDesc.DepthBufferFormat); - TexDesc.BindFlags = BIND_DEPTH_STENCIL; - TexDesc.CPUAccessFlags = 0; - - hr = pd3d11Device->CreateTexture2D(&TexDesc, nullptr, &m_pd3d11DepthBuffer); - VERIFY(SUCCEEDED(hr), "Failed to create D3D11 depth buffer"); - - hr = pd3d11Device->CreateDepthStencilView(m_pd3d11DepthBuffer, nullptr, &m_pd3d11DSV); - VERIFY(SUCCEEDED(hr), "Failed to create D3D11 depth-stencil view"); - } -} - -void TestingSwapChainD3D11::TakeSnapshot() -{ - m_pd3d11Context->CopyResource(m_pd3d11StagingTex, m_pd3d11RenderTarget); - D3D11_MAPPED_SUBRESOURCE MappedData; - - auto hr = m_pd3d11Context->Map(m_pd3d11StagingTex, 0, D3D11_MAP_READ, 0, &MappedData); - if (SUCCEEDED(hr)) - { - m_ReferenceDataPitch = MappedData.RowPitch; - m_ReferenceData.resize(m_ReferenceDataPitch * m_SwapChainDesc.Height); - for (Uint32 row = 0; row < m_SwapChainDesc.Height; ++row) - { - memcpy(&m_ReferenceData[row * m_ReferenceDataPitch], - reinterpret_cast(MappedData.pData) + row * m_ReferenceDataPitch, - m_ReferenceDataPitch); - } - } - else - { - ADD_FAILURE() << "Failed to map stagin texture"; - return; - } - - m_pd3d11Context->Unmap(m_pd3d11StagingTex, 0); - m_pd3d11Context->ClearState(); -} - -void CreateTestingSwapChainD3D11(IRenderDevice* pDevice, - IDeviceContext* pContext, - const SwapChainDesc& SCDesc, - ISwapChain** ppSwapChain) -{ - TestingSwapChainD3D11* pTestingSC(MakeNewRCObj()(pDevice, pContext, SCDesc)); - pTestingSC->QueryInterface(IID_SwapChain, reinterpret_cast(ppSwapChain)); -} - -} // namespace Testing - -} // namespace Diligent diff --git a/UnitTests/DiligentCoreAPITest/src/D3D12/ClearRenderTargetRefenceD3D12.cpp b/UnitTests/DiligentCoreAPITest/src/D3D12/ClearRenderTargetRefenceD3D12.cpp deleted file mode 100644 index 0a2fe8ab..00000000 --- a/UnitTests/DiligentCoreAPITest/src/D3D12/ClearRenderTargetRefenceD3D12.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "D3D12/TestingEnvironmentD3D12.h" -#include "D3D12/TestingSwapChainD3D12.h" - -#include "DeviceContextD3D12.h" - -namespace Diligent -{ - -namespace Testing -{ - -void ClearRenderTargetReferenceD3D12(ISwapChain* pSwapChain) -{ - auto* pEnv = TestingEnvironmentD3D12::GetInstance(); - auto* pContext = pEnv->GetDeviceContext(); - auto* pTestingSwapChainD3D12 = ValidatedCast(pSwapChain); - - auto pCmdList = pEnv->CreateGraphicsCommandList(); - pTestingSwapChainD3D12->TransitionRenderTarget(pCmdList, D3D12_RESOURCE_STATE_RENDER_TARGET); - - auto RTVDesriptorHandle = pTestingSwapChainD3D12->GetRTVDescriptorHandle(); - - float ClearColor[] = {0.25, 0.5, 0.75, 1.0}; - pCmdList->ClearRenderTargetView(RTVDesriptorHandle, ClearColor, 0, nullptr); - - pCmdList->Close(); - ID3D12CommandList* pCmdLits[] = {pCmdList}; - - RefCntAutoPtr pContextD3D12{pContext, IID_DeviceContextD3D12}; - - auto* pQeueD3D12 = pContextD3D12->LockCommandQueue(); - auto* pd3d12Queue = pQeueD3D12->GetD3D12CommandQueue(); - - pd3d12Queue->ExecuteCommandLists(_countof(pCmdLits), pCmdLits); - - pContextD3D12->UnlockCommandQueue(); -} - -} // namespace Testing - -} // namespace Diligent diff --git a/UnitTests/DiligentCoreAPITest/src/D3D12/CreateObjFromNativeResD3D12.cpp b/UnitTests/DiligentCoreAPITest/src/D3D12/CreateObjFromNativeResD3D12.cpp deleted file mode 100644 index d76e084d..00000000 --- a/UnitTests/DiligentCoreAPITest/src/D3D12/CreateObjFromNativeResD3D12.cpp +++ /dev/null @@ -1,104 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "D3D12/CreateObjFromNativeResD3D12.h" -#include -#include "RenderDeviceD3D12.h" -#include "TextureD3D12.h" -#include "BufferD3D12.h" -#include "GraphicsAccessories.h" - -#include "gtest/gtest.h" - -namespace Diligent -{ - -namespace Testing -{ - -void TestCreateObjFromNativeResD3D12::CreateTexture(Diligent::ITexture* pTexture) -{ - RefCntAutoPtr pDeviceD3D12(m_pDevice, IID_RenderDeviceD3D12); - RefCntAutoPtr pTextureD3D12(pTexture, IID_TextureD3D12); - ASSERT_NE(pDeviceD3D12, nullptr); - ASSERT_NE(pTextureD3D12, nullptr); - - const auto& SrcTexDesc = pTexture->GetDesc(); - auto* pD3D12Texture = pTextureD3D12->GetD3D12Texture(); - ASSERT_NE(pD3D12Texture, nullptr); - - RefCntAutoPtr pTextureFromNativeD3D12Handle; - pDeviceD3D12->CreateTextureFromD3DResource(pD3D12Texture, RESOURCE_STATE_UNKNOWN, &pTextureFromNativeD3D12Handle); - ASSERT_NE(pTextureFromNativeD3D12Handle, nullptr); - - auto TestTexDesc = pTextureFromNativeD3D12Handle->GetDesc(); - if (SrcTexDesc.Type == RESOURCE_DIM_TEX_CUBE || SrcTexDesc.Type == RESOURCE_DIM_TEX_CUBE_ARRAY) - { - EXPECT_EQ(TestTexDesc.Type, RESOURCE_DIM_TEX_2D_ARRAY); - TestTexDesc.Type = SrcTexDesc.Type; - } - EXPECT_EQ(TestTexDesc, SrcTexDesc) << "Src tex desc: " << GetObjectDescString(SrcTexDesc) - << "\nTest tex desc: " << GetObjectDescString(TestTexDesc); - - RefCntAutoPtr pTestTextureD3D12(pTextureFromNativeD3D12Handle, IID_TextureD3D12); - ASSERT_NE(pTestTextureD3D12, nullptr); - EXPECT_EQ(pTestTextureD3D12->GetD3D12Texture(), pD3D12Texture); - EXPECT_EQ(pTestTextureD3D12->GetNativeHandle(), pD3D12Texture); -} - -void TestCreateObjFromNativeResD3D12::CreateBuffer(Diligent::IBuffer* pBuffer) -{ - RefCntAutoPtr pDeviceD3D12(m_pDevice, IID_RenderDeviceD3D12); - RefCntAutoPtr pBufferD3D12(pBuffer, IID_BufferD3D12); - ASSERT_NE(pDeviceD3D12, nullptr); - ASSERT_NE(pBufferD3D12, nullptr); - - - Uint64 DataStartByteOffset; - auto* pD3D12Buffer = pBufferD3D12->GetD3D12Buffer(DataStartByteOffset, nullptr); - ASSERT_NE(pD3D12Buffer, nullptr); - EXPECT_EQ(DataStartByteOffset, 0); - - const auto& SrcBuffDesc = pBuffer->GetDesc(); - { - RefCntAutoPtr pBufferFromNativeD3D12Handle; - pDeviceD3D12->CreateBufferFromD3DResource(pD3D12Buffer, SrcBuffDesc, RESOURCE_STATE_UNKNOWN, &pBufferFromNativeD3D12Handle); - ASSERT_NE(pBufferFromNativeD3D12Handle, nullptr); - - const auto& TestBufferDesc = pBufferFromNativeD3D12Handle->GetDesc(); - EXPECT_EQ(TestBufferDesc, SrcBuffDesc) << "Src buff desc: " << GetObjectDescString(SrcBuffDesc) - << "\nTest buff desc: " << GetObjectDescString(TestBufferDesc); - - RefCntAutoPtr pTestBufferD3D12(pBufferFromNativeD3D12Handle, IID_BufferD3D12); - ASSERT_NE(pTestBufferD3D12, nullptr); - - Uint64 TestBuffDataStartByteOffset; - EXPECT_EQ(pTestBufferD3D12->GetD3D12Buffer(TestBuffDataStartByteOffset, nullptr), pD3D12Buffer); - EXPECT_EQ(TestBuffDataStartByteOffset, 0); - EXPECT_EQ(pTestBufferD3D12->GetNativeHandle(), pD3D12Buffer); - } -} - -} // namespace Testing - -} // namespace Diligent diff --git a/UnitTests/DiligentCoreAPITest/src/D3D12/D3D12DebugLayerSetNameBugWorkaround.cpp b/UnitTests/DiligentCoreAPITest/src/D3D12/D3D12DebugLayerSetNameBugWorkaround.cpp deleted file mode 100644 index e186dbfd..00000000 --- a/UnitTests/DiligentCoreAPITest/src/D3D12/D3D12DebugLayerSetNameBugWorkaround.cpp +++ /dev/null @@ -1,76 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "D3D12/D3D12DebugLayerSetNameBugWorkaround.h" - -#include "RefCntAutoPtr.h" - -#ifndef NOMINMAX -# define NOMINMAX -#endif - -#include -#include - -#include "RenderDeviceD3D12.h" - -namespace Diligent -{ - -namespace Testing -{ - -struct D3D12DebugLayerSetNameBugWorkaround::RootSignatureWrapper -{ - CComPtr pRootSignature; -}; - -D3D12DebugLayerSetNameBugWorkaround::D3D12DebugLayerSetNameBugWorkaround(IRenderDevice* pDevice) : - m_RootSignature(new RootSignatureWrapper) -{ - if (pDevice->GetDeviceCaps().DevType != DeviceType::D3D12) - return; - - RefCntAutoPtr pDeviceD3D12(pDevice, IID_RenderDeviceD3D12); - VERIFY_EXPR(pDeviceD3D12); - auto pd3d12Device = pDeviceD3D12->GetD3D12Device(); - - D3D12_ROOT_SIGNATURE_DESC RootSignatureDesc = {}; - - RootSignatureDesc.Flags = D3D12_ROOT_SIGNATURE_FLAG_ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT; - - CComPtr signature; - D3D12SerializeRootSignature(&RootSignatureDesc, D3D_ROOT_SIGNATURE_VERSION_1, &signature, nullptr); - auto& pRootSign = m_RootSignature->pRootSignature; - pd3d12Device->CreateRootSignature(0, signature->GetBufferPointer(), signature->GetBufferSize(), __uuidof(pRootSign), reinterpret_cast(static_cast(&pRootSign))); - pRootSign->SetName(L"A long string to make sure there is enough space reserved in the buffer to avoid resize when SetName is called " - "and it is accessed simultaneously from multiple threads without a mutex"); -} - -D3D12DebugLayerSetNameBugWorkaround::~D3D12DebugLayerSetNameBugWorkaround() -{ -} - -} // namespace Testing - -} // namespace Diligent diff --git a/UnitTests/DiligentCoreAPITest/src/D3D12/DrawCommandRefenceD3D12.cpp b/UnitTests/DiligentCoreAPITest/src/D3D12/DrawCommandRefenceD3D12.cpp deleted file mode 100644 index 6d873547..00000000 --- a/UnitTests/DiligentCoreAPITest/src/D3D12/DrawCommandRefenceD3D12.cpp +++ /dev/null @@ -1,180 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "D3D12/TestingEnvironmentD3D12.h" -#include "D3D12/TestingSwapChainD3D12.h" -#include "../include/DXGITypeConversions.h" -#include "../include/d3dx12_win.h" - -#include "RenderDeviceD3D12.h" -#include "DeviceContextD3D12.h" - -namespace Diligent -{ - -namespace Testing -{ - -static const char* VSSource = R"( -struct PSInput -{ - float4 Pos : SV_POSITION; - float3 Color : COLOR; -}; - -void main(in uint VertId : SV_VertexID, - out PSInput PSIn) -{ - float4 Pos[6]; - Pos[0] = float4(-1.0, -0.5, 0.0, 1.0); - Pos[1] = float4(-0.5, +0.5, 0.0, 1.0); - Pos[2] = float4( 0.0, -0.5, 0.0, 1.0); - - Pos[3] = float4(+0.0, -0.5, 0.0, 1.0); - Pos[4] = float4(+0.5, +0.5, 0.0, 1.0); - Pos[5] = float4(+1.0, -0.5, 0.0, 1.0); - - float3 Col[6]; - Col[0] = float3(1.0, 0.0, 0.0); - Col[1] = float3(0.0, 1.0, 0.0); - Col[2] = float3(0.0, 0.0, 1.0); - - Col[3] = float3(1.0, 0.0, 0.0); - Col[4] = float3(0.0, 1.0, 0.0); - Col[5] = float3(0.0, 0.0, 1.0); - - PSIn.Pos = Pos[VertId]; - PSIn.Color = Col[VertId]; -} -)"; - -static const char* PSSource = R"( -struct PSInput -{ - float4 Pos : SV_POSITION; - float3 Color : COLOR; -}; - -float4 main(in PSInput PSIn) : SV_Target -{ - return float4(PSIn.Color.rgb, 1.0); -} -)"; - -void RenderDrawCommandRefenceD3D12(ISwapChain* pSwapChain) -{ - auto* pEnv = TestingEnvironmentD3D12::GetInstance(); - auto* pContext = pEnv->GetDeviceContext(); - auto* pd3d12Device = pEnv->GetD3D12Device(); - auto* pTestingSwapChainD3D12 = ValidatedCast(pSwapChain); - - const auto& SCDesc = pSwapChain->GetDesc(); - - CComPtr pVSByteCode, pPSByteCode; - - auto hr = CompileD3DShader(VSSource, "main", nullptr, "vs_5_0", &pVSByteCode); - ASSERT_HRESULT_SUCCEEDED(hr) << "Failed to compile vertex shader"; - - hr = CompileD3DShader(PSSource, "main", nullptr, "ps_5_0", &pPSByteCode); - ASSERT_HRESULT_SUCCEEDED(hr) << "Failed to compile pixel shader"; - - - D3D12_ROOT_SIGNATURE_DESC RootSignatureDesc = {}; - - RootSignatureDesc.Flags = D3D12_ROOT_SIGNATURE_FLAG_ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT; - - CComPtr signature; - CComPtr pd3d12RootSignature; - D3D12SerializeRootSignature(&RootSignatureDesc, D3D_ROOT_SIGNATURE_VERSION_1, &signature, nullptr); - pd3d12Device->CreateRootSignature(0, signature->GetBufferPointer(), signature->GetBufferSize(), __uuidof(pd3d12RootSignature), reinterpret_cast(static_cast(&pd3d12RootSignature))); - - D3D12_GRAPHICS_PIPELINE_STATE_DESC PSODesc = {}; - - PSODesc.pRootSignature = pd3d12RootSignature; - PSODesc.VS.pShaderBytecode = pVSByteCode->GetBufferPointer(); - PSODesc.VS.BytecodeLength = pVSByteCode->GetBufferSize(); - PSODesc.PS.pShaderBytecode = pPSByteCode->GetBufferPointer(); - PSODesc.PS.BytecodeLength = pPSByteCode->GetBufferSize(); - - PSODesc.BlendState = CD3DX12_BLEND_DESC{D3D12_DEFAULT}; - PSODesc.RasterizerState = CD3DX12_RASTERIZER_DESC{D3D12_DEFAULT}; - PSODesc.DepthStencilState = CD3DX12_DEPTH_STENCIL_DESC{D3D12_DEFAULT}; - - PSODesc.RasterizerState.CullMode = D3D12_CULL_MODE_NONE; - PSODesc.DepthStencilState.DepthEnable = FALSE; - PSODesc.DepthStencilState.DepthWriteMask = D3D12_DEPTH_WRITE_MASK_ZERO; - - PSODesc.SampleMask = 0xFFFFFFFF; - - PSODesc.PrimitiveTopologyType = D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE; - PSODesc.NumRenderTargets = 1; - PSODesc.RTVFormats[0] = TexFormatToDXGI_Format(SCDesc.ColorBufferFormat); - PSODesc.SampleDesc.Count = 1; - PSODesc.SampleDesc.Quality = 0; - PSODesc.NodeMask = 0; - PSODesc.Flags = D3D12_PIPELINE_STATE_FLAG_NONE; - - CComPtr pd3d12PSO; - hr = pd3d12Device->CreateGraphicsPipelineState(&PSODesc, __uuidof(pd3d12PSO), reinterpret_cast(static_cast(&pd3d12PSO))); - ASSERT_HRESULT_SUCCEEDED(hr) << "Failed to create pipeline state"; - - auto pCmdList = pEnv->CreateGraphicsCommandList(); - pTestingSwapChainD3D12->TransitionRenderTarget(pCmdList, D3D12_RESOURCE_STATE_RENDER_TARGET); - - D3D12_VIEWPORT d3d12VP = {}; - d3d12VP.Width = static_cast(SCDesc.Width); - d3d12VP.Height = static_cast(SCDesc.Height); - d3d12VP.MaxDepth = 1; - pCmdList->RSSetViewports(1, &d3d12VP); - D3D12_RECT Rect = {0, 0, static_cast(SCDesc.Width), static_cast(SCDesc.Height)}; - pCmdList->RSSetScissorRects(1, &Rect); - - auto RTVDesriptorHandle = pTestingSwapChainD3D12->GetRTVDescriptorHandle(); - - pCmdList->OMSetRenderTargets(1, &RTVDesriptorHandle, FALSE, nullptr); - - float ClearColor[] = {0, 0, 0, 0}; - pCmdList->ClearRenderTargetView(RTVDesriptorHandle, ClearColor, 0, nullptr); - - pCmdList->SetPipelineState(pd3d12PSO); - pCmdList->SetGraphicsRootSignature(pd3d12RootSignature); - pCmdList->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST); - pCmdList->DrawInstanced(6, 1, 0, 0); - - pCmdList->Close(); - ID3D12CommandList* pCmdLits[] = {pCmdList}; - - RefCntAutoPtr pContextD3D12{pContext, IID_DeviceContextD3D12}; - - auto* pQeueD3D12 = pContextD3D12->LockCommandQueue(); - auto* pd3d12Queue = pQeueD3D12->GetD3D12CommandQueue(); - - pd3d12Queue->ExecuteCommandLists(_countof(pCmdLits), pCmdLits); - pEnv->IdleCommandQueue(pd3d12Queue); - - pContextD3D12->UnlockCommandQueue(); -} - -} // namespace Testing - -} // namespace Diligent diff --git a/UnitTests/DiligentCoreAPITest/src/D3D12/TestingEnvironmentD3D12.cpp b/UnitTests/DiligentCoreAPITest/src/D3D12/TestingEnvironmentD3D12.cpp deleted file mode 100644 index 214f239a..00000000 --- a/UnitTests/DiligentCoreAPITest/src/D3D12/TestingEnvironmentD3D12.cpp +++ /dev/null @@ -1,94 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "D3D12/TestingEnvironmentD3D12.h" -#include "RenderDeviceD3D12.h" - -namespace Diligent -{ - -namespace Testing -{ - -void CreateTestingSwapChainD3D12(IRenderDevice* pDevice, - IDeviceContext* pContext, - const SwapChainDesc& SCDesc, - ISwapChain** ppSwapChain); - -TestingEnvironmentD3D12::TestingEnvironmentD3D12(DeviceType deviceType, ADAPTER_TYPE AdapterType, const SwapChainDesc& SCDesc) : - TestingEnvironment{deviceType, AdapterType, SCDesc}, - m_WaitForGPUEventHandle{CreateEvent(nullptr, false, false, nullptr)} -{ - RefCntAutoPtr pRenderDeviceD3D12{m_pDevice, IID_RenderDeviceD3D12}; - m_pd3d12Device = pRenderDeviceD3D12->GetD3D12Device(); - auto hr = - m_pd3d12Device->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT, __uuidof(m_pd3d12CmdAllocator), - reinterpret_cast(static_cast(&m_pd3d12CmdAllocator))); - VERIFY_EXPR(SUCCEEDED(hr)); - - hr = m_pd3d12Device->CreateFence(0, D3D12_FENCE_FLAG_NONE, __uuidof(m_pd3d12Fence), - reinterpret_cast(static_cast(&m_pd3d12Fence))); - VERIFY_EXPR(SUCCEEDED(hr)); - - if (m_pSwapChain == nullptr) - { - CreateTestingSwapChainD3D12(m_pDevice, m_pDeviceContext, SCDesc, &m_pSwapChain); - } -} - -TestingEnvironmentD3D12::~TestingEnvironmentD3D12() -{ - CloseHandle(m_WaitForGPUEventHandle); -} - -CComPtr TestingEnvironmentD3D12::CreateGraphicsCommandList() -{ - CComPtr pd3d12CmdList; - m_pd3d12Device->CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, m_pd3d12CmdAllocator, nullptr, __uuidof(pd3d12CmdList), - reinterpret_cast(static_cast(&pd3d12CmdList))); - return pd3d12CmdList; -} - -void TestingEnvironmentD3D12::IdleCommandQueue(ID3D12CommandQueue* pd3d12Queue) -{ - Uint64 LastSignaledFenceValue = m_NextFenceValue; - ++m_NextFenceValue; - - pd3d12Queue->Signal(m_pd3d12Fence, LastSignaledFenceValue); - - if (m_pd3d12Fence->GetCompletedValue() < LastSignaledFenceValue) - { - m_pd3d12Fence->SetEventOnCompletion(LastSignaledFenceValue, m_WaitForGPUEventHandle); - WaitForSingleObject(m_WaitForGPUEventHandle, INFINITE); - VERIFY(m_pd3d12Fence->GetCompletedValue() == LastSignaledFenceValue, "Unexpected signaled fence value"); - } -} - -TestingEnvironment* CreateTestingEnvironmentD3D12(DeviceType deviceType, ADAPTER_TYPE AdapterType, const SwapChainDesc& SCDesc) -{ - return new TestingEnvironmentD3D12{deviceType, AdapterType, SCDesc}; -} - -} // namespace Testing - -} // namespace Diligent diff --git a/UnitTests/DiligentCoreAPITest/src/D3D12/TestingSwapChainD3D12.cpp b/UnitTests/DiligentCoreAPITest/src/D3D12/TestingSwapChainD3D12.cpp deleted file mode 100644 index e893a1c0..00000000 --- a/UnitTests/DiligentCoreAPITest/src/D3D12/TestingSwapChainD3D12.cpp +++ /dev/null @@ -1,257 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include - -#include "D3D12/TestingEnvironmentD3D12.h" -#include "D3D12/TestingSwapChainD3D12.h" -#include "../include/DXGITypeConversions.h" - -#include "RenderDeviceD3D12.h" -#include "DeviceContextD3D12.h" - -namespace Diligent -{ - -namespace Testing -{ - -TestingSwapChainD3D12::TestingSwapChainD3D12(IReferenceCounters* pRefCounters, - IRenderDevice* pDevice, - IDeviceContext* pContext, - const SwapChainDesc& SCDesc) : - TBase // - { - pRefCounters, - pDevice, - pContext, - SCDesc // - } -{ - RefCntAutoPtr pRenderDeviceD3D12{pDevice, IID_RenderDeviceD3D12}; - - auto* pd3d12Device = pRenderDeviceD3D12->GetD3D12Device(); - - D3D12_HEAP_PROPERTIES HeapProps = {}; - HeapProps.Type = D3D12_HEAP_TYPE_DEFAULT; - HeapProps.CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_UNKNOWN; - HeapProps.MemoryPoolPreference = D3D12_MEMORY_POOL_UNKNOWN; - HeapProps.CreationNodeMask = 1; - HeapProps.VisibleNodeMask = 1; - - D3D12_RESOURCE_DESC TexDesc = {}; - TexDesc.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D; - TexDesc.Alignment = 0; - TexDesc.Width = m_SwapChainDesc.Width; - TexDesc.Height = m_SwapChainDesc.Height; - TexDesc.DepthOrArraySize = 1; - TexDesc.MipLevels = 1; - TexDesc.Format = TexFormatToDXGI_Format(SCDesc.ColorBufferFormat); - TexDesc.SampleDesc.Count = 1; - TexDesc.SampleDesc.Quality = 0; - TexDesc.Layout = D3D12_TEXTURE_LAYOUT_UNKNOWN; - TexDesc.Flags = D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET; - - D3D12_CLEAR_VALUE ClearColorValue = {}; - ClearColorValue.Format = TexDesc.Format; - auto hr = - pd3d12Device->CreateCommittedResource(&HeapProps, D3D12_HEAP_FLAG_NONE, &TexDesc, m_RenderTargetState, &ClearColorValue, - __uuidof(m_pd3d12RenderTaget), - reinterpret_cast(static_cast(&m_pd3d12RenderTaget))); - VERIFY(SUCCEEDED(hr), "Failed to create D3D12 render target"); - - { - pd3d12Device->GetCopyableFootprints(&TexDesc, 0, 1, 0, &m_StagingBufferFootprint, nullptr, nullptr, &m_StagingBufferSize); - - D3D12_HEAP_PROPERTIES DownloadHeapProps; - DownloadHeapProps.Type = D3D12_HEAP_TYPE_READBACK; - DownloadHeapProps.CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_UNKNOWN; - DownloadHeapProps.MemoryPoolPreference = D3D12_MEMORY_POOL_UNKNOWN; - DownloadHeapProps.CreationNodeMask = 1; - DownloadHeapProps.VisibleNodeMask = 1; - - D3D12_RESOURCE_DESC BufferDesc; - BufferDesc.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER; - BufferDesc.Alignment = 0; - BufferDesc.Width = m_StagingBufferSize; - BufferDesc.Height = 1; - BufferDesc.DepthOrArraySize = 1; - BufferDesc.MipLevels = 1; - BufferDesc.Format = DXGI_FORMAT_UNKNOWN; - BufferDesc.SampleDesc.Count = 1; - BufferDesc.SampleDesc.Quality = 0; - BufferDesc.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR; - BufferDesc.Flags = D3D12_RESOURCE_FLAG_NONE; - - hr = pd3d12Device->CreateCommittedResource(&DownloadHeapProps, D3D12_HEAP_FLAG_NONE, - &BufferDesc, D3D12_RESOURCE_STATE_COPY_DEST, - nullptr, __uuidof(m_pd3d12StagingBuffer), - reinterpret_cast(static_cast(&m_pd3d12StagingBuffer))); - if (FAILED(hr)) - LOG_ERROR_AND_THROW("Failed to create committed staging buffer in an upload heap"); - } - - if (SCDesc.DepthBufferFormat != TEX_FORMAT_UNKNOWN) - { - TexDesc.Flags = D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL; - TexDesc.Format = TexFormatToDXGI_Format(SCDesc.DepthBufferFormat); - - D3D12_CLEAR_VALUE ClearDepthValue = {}; - ClearDepthValue.Format = TexDesc.Format; - ClearDepthValue.DepthStencil.Depth = 1; - hr = - pd3d12Device->CreateCommittedResource(&HeapProps, D3D12_HEAP_FLAG_NONE, &TexDesc, m_DepthBufferState, &ClearDepthValue, - __uuidof(m_pd3d12DepthBuffer), - reinterpret_cast(static_cast(&m_pd3d12DepthBuffer))); - VERIFY(SUCCEEDED(hr), "Failed to create D3D12 depth buffer"); - } - - D3D12_DESCRIPTOR_HEAP_DESC DescriptorHeapDesc = {}; - DescriptorHeapDesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_RTV; - DescriptorHeapDesc.NumDescriptors = 1; - DescriptorHeapDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_NONE; - DescriptorHeapDesc.NodeMask = 0; - hr = - pd3d12Device->CreateDescriptorHeap(&DescriptorHeapDesc, - __uuidof(m_pd3d12RTVDescriptorHeap), - reinterpret_cast(static_cast(&m_pd3d12RTVDescriptorHeap))); - VERIFY(SUCCEEDED(hr), "Failed to create D3D12 RTV descriptor heap"); - m_RTVDescriptorHandle = m_pd3d12RTVDescriptorHeap->GetCPUDescriptorHandleForHeapStart(); - pd3d12Device->CreateRenderTargetView(m_pd3d12RenderTaget, nullptr, m_RTVDescriptorHandle); - - DescriptorHeapDesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_DSV; - hr = - pd3d12Device->CreateDescriptorHeap(&DescriptorHeapDesc, - __uuidof(m_pd3d12DSVDescriptorHeap), - reinterpret_cast(static_cast(&m_pd3d12DSVDescriptorHeap))); - VERIFY(SUCCEEDED(hr), "Failed to create D3D12 DSV descriptor heap"); - m_DSVDescriptorHandle = m_pd3d12DSVDescriptorHeap->GetCPUDescriptorHandleForHeapStart(); - pd3d12Device->CreateDepthStencilView(m_pd3d12DepthBuffer, nullptr, m_DSVDescriptorHandle); -} - -void TestingSwapChainD3D12::TransitionBuffers(ID3D12GraphicsCommandList* pCmdList, - D3D12_RESOURCE_STATES RTVState, - D3D12_RESOURCE_STATES DSVState) -{ - std::vector Barriers; - if (m_RenderTargetState != RTVState) - { - D3D12_RESOURCE_BARRIER Barrier = {}; - Barrier.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION; - Barrier.Transition.pResource = m_pd3d12RenderTaget; - Barrier.Transition.StateBefore = m_RenderTargetState; - Barrier.Transition.StateAfter = RTVState; - Barrier.Transition.Subresource = 0; - - m_RenderTargetState = RTVState; - - Barriers.emplace_back(Barrier); - } - - if (m_DepthBufferState != DSVState) - { - D3D12_RESOURCE_BARRIER Barrier = {}; - Barrier.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION; - Barrier.Transition.pResource = m_pd3d12DepthBuffer; - Barrier.Transition.StateBefore = m_DepthBufferState; - Barrier.Transition.StateAfter = DSVState; - Barrier.Transition.Subresource = 0; - - m_DepthBufferState = DSVState; - - Barriers.emplace_back(Barrier); - } - - if (!Barriers.empty()) - { - pCmdList->ResourceBarrier(static_cast(Barriers.size()), Barriers.data()); - } -} - -void TestingSwapChainD3D12::TransitionRenderTarget(ID3D12GraphicsCommandList* pCmdList, - D3D12_RESOURCE_STATES RTVState) -{ - TransitionBuffers(pCmdList, RTVState, m_DepthBufferState); -} - -void TestingSwapChainD3D12::TakeSnapshot() -{ - auto* pEnv = TestingEnvironmentD3D12::GetInstance(); - auto* pContext = pEnv->GetDeviceContext(); - auto pCmdList = pEnv->CreateGraphicsCommandList(); - - TransitionRenderTarget(pCmdList, D3D12_RESOURCE_STATE_COPY_SOURCE); - - D3D12_TEXTURE_COPY_LOCATION SrcLocation = {}; - - SrcLocation.Type = D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX; - SrcLocation.pResource = m_pd3d12RenderTaget; - SrcLocation.SubresourceIndex = 0; - - D3D12_TEXTURE_COPY_LOCATION DstLocation = {}; - - DstLocation.Type = D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT; - DstLocation.pResource = m_pd3d12StagingBuffer; - DstLocation.PlacedFootprint = m_StagingBufferFootprint; - - pCmdList->CopyTextureRegion(&DstLocation, 0, 0, 0, &SrcLocation, nullptr); - - pCmdList->Close(); - ID3D12CommandList* pCmdLits[] = {pCmdList}; - - RefCntAutoPtr pContextD3D12{pContext, IID_DeviceContextD3D12}; - - auto* pQeueD3D12 = pContextD3D12->LockCommandQueue(); - auto* pd3d12Queue = pQeueD3D12->GetD3D12CommandQueue(); - - pd3d12Queue->ExecuteCommandLists(1, pCmdLits); - pEnv->IdleCommandQueue(pd3d12Queue); - - D3D12_RANGE InvalidateRange = {0, m_StagingBufferSize}; - void* pStagingDataPtr = nullptr; - m_pd3d12StagingBuffer->Map(0, &InvalidateRange, &pStagingDataPtr); - m_ReferenceDataPitch = m_SwapChainDesc.Width * 4; - m_ReferenceData.resize(m_SwapChainDesc.Height * m_ReferenceDataPitch); - for (Uint32 row = 0; row < m_SwapChainDesc.Height; ++row) - { - memcpy(&m_ReferenceData[row * m_ReferenceDataPitch], - reinterpret_cast(pStagingDataPtr) + m_StagingBufferFootprint.Footprint.RowPitch * row, - m_ReferenceDataPitch); - } - m_pd3d12StagingBuffer->Unmap(0, nullptr); - - pContextD3D12->UnlockCommandQueue(); -} - -void CreateTestingSwapChainD3D12(IRenderDevice* pDevice, - IDeviceContext* pContext, - const SwapChainDesc& SCDesc, - ISwapChain** ppSwapChain) -{ - TestingSwapChainD3D12* pTestingSC(MakeNewRCObj()(pDevice, pContext, SCDesc)); - pTestingSC->QueryInterface(IID_SwapChain, reinterpret_cast(ppSwapChain)); -} - -} // namespace Testing - -} // namespace Diligent diff --git a/UnitTests/DiligentCoreAPITest/src/DepthStencilStateTest.cpp b/UnitTests/DiligentCoreAPITest/src/DepthStencilStateTest.cpp deleted file mode 100644 index 421c9872..00000000 --- a/UnitTests/DiligentCoreAPITest/src/DepthStencilStateTest.cpp +++ /dev/null @@ -1,111 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "TestingEnvironment.h" -#include "PSOTestBase.h" -#include "GraphicsAccessories.h" - -#include "gtest/gtest.h" - -using namespace Diligent; -using namespace Diligent::Testing; - -namespace -{ - -class DepthStencilStateTest : public PSOTestBase, public ::testing::Test -{ -protected: - static void SetUpTestSuite() - { - InitResources(); - } - - static void TearDownTestSuite() - { - ReleaseResources(); - TestingEnvironment::GetInstance()->ReleaseResources(); - } -}; - -TEST_F(DepthStencilStateTest, CreatePSO) -{ - auto PSODesc = GetPSODesc(); - - DepthStencilStateDesc& DSSDesc = PSODesc.GraphicsPipeline.DepthStencilDesc; - - DSSDesc.DepthEnable = False; - DSSDesc.DepthWriteEnable = False; - ASSERT_TRUE(CreateTestPSO(PSODesc, true)); - - DSSDesc.DepthEnable = True; - ASSERT_TRUE(CreateTestPSO(PSODesc, true)); - - DSSDesc.DepthWriteEnable = True; - ASSERT_TRUE(CreateTestPSO(PSODesc, true)); - - for (auto CmpFunc = COMPARISON_FUNC_UNKNOWN + 1; CmpFunc < COMPARISON_FUNC_NUM_FUNCTIONS; ++CmpFunc) - { - DSSDesc.DepthFunc = static_cast(CmpFunc); - ASSERT_TRUE(CreateTestPSO(PSODesc, true)) << "Comparison func: " << GetComparisonFunctionLiteralName(DSSDesc.DepthFunc, true); - } - - DSSDesc.StencilEnable = True; - ASSERT_TRUE(CreateTestPSO(PSODesc, true)); - - DSSDesc.StencilReadMask = 0xA9; - ASSERT_TRUE(CreateTestPSO(PSODesc, true)); - - DSSDesc.StencilWriteMask = 0xB8; - ASSERT_TRUE(CreateTestPSO(PSODesc, true)); - - for (int Face = 0; Face < 2; ++Face) - { - auto& FaceOp = Face == 0 ? DSSDesc.FrontFace : DSSDesc.BackFace; - for (auto StOp = STENCIL_OP_UNDEFINED + 1; StOp < STENCIL_OP_NUM_OPS; ++StOp) - { - FaceOp.StencilFailOp = static_cast(StOp); - ASSERT_TRUE(CreateTestPSO(PSODesc, true)) << "Face: " << Face << "; Stencil fail op: " << GetStencilOpLiteralName(FaceOp.StencilFailOp); - } - - for (auto StOp = STENCIL_OP_UNDEFINED + 1; StOp < STENCIL_OP_NUM_OPS; ++StOp) - { - FaceOp.StencilDepthFailOp = static_cast(StOp); - ASSERT_TRUE(CreateTestPSO(PSODesc, true)) << "Face: " << Face << "; Stencil depth fail op: " << GetStencilOpLiteralName(FaceOp.StencilDepthFailOp); - } - - for (auto StOp = STENCIL_OP_UNDEFINED + 1; StOp < STENCIL_OP_NUM_OPS; ++StOp) - { - FaceOp.StencilPassOp = static_cast(StOp); - ASSERT_TRUE(CreateTestPSO(PSODesc, true)) << "Face: " << Face << "; Stencil pass op: " << GetStencilOpLiteralName(FaceOp.StencilPassOp); - } - - for (auto CmpFunc = COMPARISON_FUNC_UNKNOWN + 1; CmpFunc < COMPARISON_FUNC_NUM_FUNCTIONS; ++CmpFunc) - { - FaceOp.StencilFunc = static_cast(CmpFunc); - ASSERT_TRUE(CreateTestPSO(PSODesc, true)) << "Face: " << Face << "; Comparison func: " << GetComparisonFunctionLiteralName(FaceOp.StencilFunc, true); - } - } -} - -} // namespace diff --git a/UnitTests/DiligentCoreAPITest/src/DrawCommandTest.cpp b/UnitTests/DiligentCoreAPITest/src/DrawCommandTest.cpp deleted file mode 100644 index 71822b77..00000000 --- a/UnitTests/DiligentCoreAPITest/src/DrawCommandTest.cpp +++ /dev/null @@ -1,1492 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "TestingEnvironment.h" -#include "TestingSwapChainBase.h" -#include "BasicMath.h" - -#include "gtest/gtest.h" - -namespace Diligent -{ - -namespace Testing -{ - -#if D3D11_SUPPORTED -void RenderDrawCommandRefenceD3D11(ISwapChain* pSwapChain); -#endif - -#if D3D12_SUPPORTED -void RenderDrawCommandRefenceD3D12(ISwapChain* pSwapChain); -#endif - -#if GL_SUPPORTED || GLES_SUPPORTED -void RenderDrawCommandRefenceGL(ISwapChain* pSwapChain); -#endif - -#if VULKAN_SUPPORTED -void RenderDrawCommandRefenceVk(ISwapChain* pSwapChain); -#endif - -#if METAL_SUPPORTED - -#endif - -} // namespace Testing - -} // namespace Diligent - -using namespace Diligent; -using namespace Diligent::Testing; - -namespace -{ - -const char* ProceduralVSSource = R"( -struct PSInput -{ - float4 Pos : SV_POSITION; - float3 Color : COLOR; -}; - -void main(in uint VertId : SV_VertexID, - out PSInput PSIn) -{ - float4 Pos[6]; - Pos[0] = float4(-1.0, -0.5, 0.0, 1.0); - Pos[1] = float4(-0.5, +0.5, 0.0, 1.0); - Pos[2] = float4( 0.0, -0.5, 0.0, 1.0); - - Pos[3] = float4(+0.0, -0.5, 0.0, 1.0); - Pos[4] = float4(+0.5, +0.5, 0.0, 1.0); - Pos[5] = float4(+1.0, -0.5, 0.0, 1.0); - - float3 Col[6]; - Col[0] = float3(1.0, 0.0, 0.0); - Col[1] = float3(0.0, 1.0, 0.0); - Col[2] = float3(0.0, 0.0, 1.0); - - Col[3] = float3(1.0, 0.0, 0.0); - Col[4] = float3(0.0, 1.0, 0.0); - Col[5] = float3(0.0, 0.0, 1.0); - - PSIn.Pos = Pos[VertId]; - PSIn.Color = Col[VertId]; -} -)"; - -const char* VSSource = R"( -struct PSInput -{ - float4 Pos : SV_POSITION; - float3 Color : COLOR; -}; - -struct VSInput -{ - float4 Pos : ATTRIB0; - float3 Color : ATTRIB1; -}; - -void main(in VSInput VSIn, - out PSInput PSIn) -{ - PSIn.Pos = VSIn.Pos; - PSIn.Color = VSIn.Color; -} -)"; - -const char* PSSource = R"( -struct PSInput -{ - float4 Pos : SV_POSITION; - float3 Color : COLOR; -}; - -struct PSOutput -{ - float4 Color : SV_TARGET; -}; - -void main(in PSInput PSIn, - out PSOutput PSOut) -{ - PSOut.Color = float4(PSIn.Color.rgb, 1.0); -} -)"; - -const char* VSInstancedSource = R"( -struct PSInput -{ - float4 Pos : SV_POSITION; - float3 Color : COLOR; -}; - -struct VSInput -{ - float4 Pos : ATTRIB0; - float3 Color : ATTRIB1; - float4 ScaleBias : ATTRIB2; -}; - -void main(in VSInput VSIn, - out PSInput PSIn) -{ - PSIn.Pos.xy = VSIn.Pos.xy * VSIn.ScaleBias.xy + VSIn.ScaleBias.zw; - PSIn.Pos.zw = VSIn.Pos.zw; - PSIn.Color = VSIn.Color; -} -)"; - - -struct Vertex -{ - float4 Pos; - float3 Color; -}; - -// clang-format off -float4 Pos[] = -{ - float4(-1.0f, -0.5f, 0.f, 1.f), - float4(-0.5f, +0.5f, 0.f, 1.f), - float4( 0.0f, -0.5f, 0.f, 1.f), - - float4(+0.0f, -0.5f, 0.f, 1.f), - float4(+0.5f, +0.5f, 0.f, 1.f), - float4(+1.0f, -0.5f, 0.f, 1.f) -}; - -float3 Color[] = -{ - float3(1.f, 0.f, 0.f), - float3(0.f, 1.f, 0.f), - float3(0.f, 0.f, 1.f), -}; - -Vertex Vert[] = -{ - {Pos[0], Color[0]}, - {Pos[1], Color[1]}, - {Pos[2], Color[2]}, - - {Pos[3], Color[0]}, - {Pos[4], Color[1]}, - {Pos[5], Color[2]} -}; - -Vertex VertInst[] = -{ - {float4(-1.0, 0.0, 0.0, 1.0), Color[0]}, - {float4( 0.0, +2.0, 0.0, 1.0), Color[1]}, - {float4(+1.0, 0.0, 0.0, 1.0), Color[2]} -}; -// clang-format on - -class DrawCommandTest : public ::testing::Test -{ -protected: - static void SetUpTestSuite() - { - auto* pEnv = TestingEnvironment::GetInstance(); - auto* pDevice = pEnv->GetDevice(); - auto* pSwapChain = pEnv->GetSwapChain(); - auto* pConext = pEnv->GetDeviceContext(); - - RefCntAutoPtr pTestingSwapChain(pSwapChain, IID_TestingSwapChain); - if (pTestingSwapChain) - { - pConext->Flush(); - pConext->InvalidateState(); - - auto deviceType = pDevice->GetDeviceCaps().DevType; - switch (deviceType) - { -#if D3D11_SUPPORTED - case DeviceType::D3D11: - RenderDrawCommandRefenceD3D11(pSwapChain); - break; -#endif - -#if D3D12_SUPPORTED - case DeviceType::D3D12: - RenderDrawCommandRefenceD3D12(pSwapChain); - break; -#endif - -#if GL_SUPPORTED || GLES_SUPPORTED - case DeviceType::OpenGL: - case DeviceType::OpenGLES: - RenderDrawCommandRefenceGL(pSwapChain); - break; - -#endif - -#if VULKAN_SUPPORTED - case DeviceType::Vulkan: - RenderDrawCommandRefenceVk(pSwapChain); - break; - -#endif - - default: - LOG_ERROR_AND_THROW("Unsupported device type"); - } - - pTestingSwapChain->TakeSnapshot(); - } - TestingEnvironment::ScopedReleaseResources EnvironmentAutoReset; - - PipelineStateDesc PSODesc; - PSODesc.Name = "Procedural triangle PSO"; - - PSODesc.IsComputePipeline = false; - PSODesc.GraphicsPipeline.NumRenderTargets = 1; - PSODesc.GraphicsPipeline.RTVFormats[0] = pSwapChain->GetDesc().ColorBufferFormat; - PSODesc.GraphicsPipeline.PrimitiveTopology = PRIMITIVE_TOPOLOGY_TRIANGLE_LIST; - PSODesc.GraphicsPipeline.RasterizerDesc.CullMode = CULL_MODE_NONE; - PSODesc.GraphicsPipeline.DepthStencilDesc.DepthEnable = False; - - ShaderCreateInfo ShaderCI; - ShaderCI.SourceLanguage = SHADER_SOURCE_LANGUAGE_HLSL; - ShaderCI.UseCombinedTextureSamplers = true; - - RefCntAutoPtr pProceduralVS; - { - ShaderCI.Desc.ShaderType = SHADER_TYPE_VERTEX; - ShaderCI.EntryPoint = "main"; - ShaderCI.Desc.Name = "Draw command test procedural vertex shader"; - ShaderCI.Source = ProceduralVSSource; - pDevice->CreateShader(ShaderCI, &pProceduralVS); - ASSERT_NE(pProceduralVS, nullptr); - } - - RefCntAutoPtr pVS; - { - ShaderCI.Desc.ShaderType = SHADER_TYPE_VERTEX; - ShaderCI.EntryPoint = "main"; - ShaderCI.Desc.Name = "Draw command test vertex shader"; - ShaderCI.Source = VSSource; - pDevice->CreateShader(ShaderCI, &pVS); - ASSERT_NE(pVS, nullptr); - } - - RefCntAutoPtr pInstancedVS; - { - ShaderCI.Desc.ShaderType = SHADER_TYPE_VERTEX; - ShaderCI.EntryPoint = "main"; - ShaderCI.Desc.Name = "Draw command test instanced vertex shader"; - ShaderCI.Source = VSInstancedSource; - pDevice->CreateShader(ShaderCI, &pInstancedVS); - ASSERT_NE(pInstancedVS, nullptr); - } - - RefCntAutoPtr pPS; - { - ShaderCI.Desc.ShaderType = SHADER_TYPE_PIXEL; - ShaderCI.EntryPoint = "main"; - ShaderCI.Desc.Name = "Draw command test pixel shader"; - ShaderCI.Source = PSSource; - pDevice->CreateShader(ShaderCI, &pPS); - ASSERT_NE(pPS, nullptr); - } - - PSODesc.GraphicsPipeline.pVS = pProceduralVS; - PSODesc.GraphicsPipeline.pPS = pPS; - pDevice->CreatePipelineState(PSODesc, &sm_pDrawProceduralPSO); - ASSERT_NE(sm_pDrawProceduralPSO, nullptr); - - InputLayoutDesc LayoutDesc; - // clang-format off - LayoutElement Elems[] = - { - LayoutElement{ 0, 0, 4, VT_FLOAT32}, - LayoutElement{ 1, 0, 3, VT_FLOAT32} - }; - // clang-format on - PSODesc.GraphicsPipeline.InputLayout.LayoutElements = Elems; - PSODesc.GraphicsPipeline.InputLayout.NumElements = _countof(Elems); - PSODesc.GraphicsPipeline.pVS = pVS; - PSODesc.GraphicsPipeline.pPS = pPS; - PSODesc.GraphicsPipeline.PrimitiveTopology = PRIMITIVE_TOPOLOGY_TRIANGLE_LIST; - pDevice->CreatePipelineState(PSODesc, &sm_pDrawPSO); - - Elems[0].Stride = sizeof(Vertex) * 2; - pDevice->CreatePipelineState(PSODesc, &sm_pDraw_2xStride_PSO); - - // clang-format off - LayoutElement InstancedElems[] = - { - LayoutElement{ 0, 0, 4, VT_FLOAT32}, - LayoutElement{ 1, 0, 3, VT_FLOAT32}, - LayoutElement{ 2, 1, 4, VT_FLOAT32, false, LayoutElement::FREQUENCY_PER_INSTANCE} - }; - // clang-format on - PSODesc.GraphicsPipeline.InputLayout.LayoutElements = InstancedElems; - PSODesc.GraphicsPipeline.InputLayout.NumElements = _countof(InstancedElems); - PSODesc.GraphicsPipeline.pVS = pInstancedVS; - pDevice->CreatePipelineState(PSODesc, &sm_pDrawInstancedPSO); - } - - static void TearDownTestSuite() - { - sm_pDrawProceduralPSO.Release(); - - auto* pEnv = TestingEnvironment::GetInstance(); - pEnv->Reset(); - } - - static void SetRenderTargets(IPipelineState* pPSO) - { - auto* pEnv = TestingEnvironment::GetInstance(); - auto* pContext = pEnv->GetDeviceContext(); - auto* pSwapChain = pEnv->GetSwapChain(); - - ITextureView* pRTVs[] = {pSwapChain->GetCurrentBackBufferRTV()}; - pContext->SetRenderTargets(1, pRTVs, nullptr, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); - - const float ClearColor[] = {0.f, 0.f, 0.f, 0.0f}; - pContext->ClearRenderTarget(pRTVs[0], ClearColor, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); - - pContext->SetPipelineState(pPSO); - // Commit shader resources. We don't really have any resources, but this call also sets the shaders in OpenGL backend. - pContext->CommitShaderResources(nullptr, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); - } - - static void Present() - { - auto* pEnv = TestingEnvironment::GetInstance(); - auto* pSwapChain = pEnv->GetSwapChain(); - auto* pContext = pEnv->GetDeviceContext(); - - pSwapChain->Present(); - - pContext->Flush(); - pContext->InvalidateState(); - } - - RefCntAutoPtr CreateVertexBuffer(const void* VertexData, Uint32 DataSize) - { - BufferDesc BuffDesc; - BuffDesc.Name = "Test vertex buffer"; - BuffDesc.BindFlags = BIND_VERTEX_BUFFER; - BuffDesc.uiSizeInBytes = DataSize; - - BufferData InitialData; - InitialData.pData = VertexData; - InitialData.DataSize = DataSize; - - auto* pDevice = TestingEnvironment::GetInstance()->GetDevice(); - - RefCntAutoPtr pBuffer; - pDevice->CreateBuffer(BuffDesc, &InitialData, &pBuffer); - VERIFY_EXPR(pBuffer); - return pBuffer; - } - - RefCntAutoPtr CreateIndexBuffer(const Uint32* Indices, Uint32 NumIndices) - { - BufferDesc BuffDesc; - BuffDesc.Name = "Test index buffer"; - BuffDesc.BindFlags = BIND_INDEX_BUFFER; - BuffDesc.uiSizeInBytes = sizeof(Uint32) * NumIndices; - - BufferData InitialData; - InitialData.pData = Indices; - InitialData.DataSize = BuffDesc.uiSizeInBytes; - - auto* pDevice = TestingEnvironment::GetInstance()->GetDevice(); - - RefCntAutoPtr pBuffer; - pDevice->CreateBuffer(BuffDesc, &InitialData, &pBuffer); - VERIFY_EXPR(pBuffer); - return pBuffer; - } - - RefCntAutoPtr CreateIndirectDrawArgsBuffer(const Uint32* Data, Uint32 DataSize) - { - BufferDesc BuffDesc; - BuffDesc.Name = "Test index buffer"; - BuffDesc.BindFlags = BIND_INDIRECT_DRAW_ARGS; - BuffDesc.uiSizeInBytes = DataSize; - - BufferData InitialData; - InitialData.pData = Data; - InitialData.DataSize = BuffDesc.uiSizeInBytes; - - auto* pDevice = TestingEnvironment::GetInstance()->GetDevice(); - - RefCntAutoPtr pBuffer; - pDevice->CreateBuffer(BuffDesc, &InitialData, &pBuffer); - VERIFY_EXPR(pBuffer); - return pBuffer; - } - - static RefCntAutoPtr sm_pDrawProceduralPSO; - static RefCntAutoPtr sm_pDrawPSO; - static RefCntAutoPtr sm_pDraw_2xStride_PSO; - static RefCntAutoPtr sm_pDrawInstancedPSO; -}; - -RefCntAutoPtr DrawCommandTest::sm_pDrawProceduralPSO; -RefCntAutoPtr DrawCommandTest::sm_pDrawPSO; -RefCntAutoPtr DrawCommandTest::sm_pDraw_2xStride_PSO; -RefCntAutoPtr DrawCommandTest::sm_pDrawInstancedPSO; - -TEST_F(DrawCommandTest, DrawProcedural) -{ - auto* pEnv = TestingEnvironment::GetInstance(); - auto* pContext = pEnv->GetDeviceContext(); - - SetRenderTargets(sm_pDrawProceduralPSO); - - DrawAttribs drawAttrs{6, DRAW_FLAG_VERIFY_ALL}; - pContext->Draw(drawAttrs); - - Present(); -} - - -// Non-indexed draw calls - - -TEST_F(DrawCommandTest, Draw) -{ - auto* pEnv = TestingEnvironment::GetInstance(); - auto* pContext = pEnv->GetDeviceContext(); - - SetRenderTargets(sm_pDrawPSO); - - // clang-format off - const Vertex Triangles[] = - { - Vert[0], Vert[1], Vert[2], - Vert[3], Vert[4], Vert[5] - }; - // clang-format on - - auto pVB = CreateVertexBuffer(Triangles, sizeof(Triangles)); - IBuffer* pVBs[] = {pVB}; - Uint32 Offsets[] = {0}; - pContext->SetVertexBuffers(0, 1, pVBs, Offsets, RESOURCE_STATE_TRANSITION_MODE_TRANSITION, SET_VERTEX_BUFFERS_FLAG_RESET); - - DrawAttribs drawAttrs{6, DRAW_FLAG_VERIFY_ALL}; - pContext->Draw(drawAttrs); - - Present(); -} - -TEST_F(DrawCommandTest, Draw_StartVertex) -{ - auto* pEnv = TestingEnvironment::GetInstance(); - auto* pContext = pEnv->GetDeviceContext(); - - SetRenderTargets(sm_pDrawPSO); - - // clang-format off - const Vertex Triangles[] = - { - {}, {}, // Skip 2 vertices using StartVertexLocation - Vert[0], Vert[1], Vert[2], - Vert[3], Vert[4], Vert[5] - }; - // clang-format on - - auto pVB = CreateVertexBuffer(Triangles, sizeof(Triangles)); - IBuffer* pVBs[] = {pVB}; - Uint32 Offsets[] = {0}; - pContext->SetVertexBuffers(0, 1, pVBs, Offsets, RESOURCE_STATE_TRANSITION_MODE_TRANSITION, SET_VERTEX_BUFFERS_FLAG_RESET); - - DrawAttribs drawAttrs{6, DRAW_FLAG_VERIFY_ALL}; - drawAttrs.StartVertexLocation = 2; - pContext->Draw(drawAttrs); - - Present(); -} - -TEST_F(DrawCommandTest, Draw_VBOffset) -{ - auto* pEnv = TestingEnvironment::GetInstance(); - auto* pContext = pEnv->GetDeviceContext(); - - SetRenderTargets(sm_pDrawPSO); - - // clang-format off - const Vertex Triangles[] = - { - {}, {}, {}, // Skip 3 vertices using buffer offset - Vert[0], Vert[1], Vert[2], - Vert[3], Vert[4], Vert[5] - }; - // clang-format on - - auto pVB = CreateVertexBuffer(Triangles, sizeof(Triangles)); - IBuffer* pVBs[] = {pVB}; - Uint32 Offsets[] = {3 * sizeof(Vertex)}; - pContext->SetVertexBuffers(0, 1, pVBs, Offsets, RESOURCE_STATE_TRANSITION_MODE_TRANSITION, SET_VERTEX_BUFFERS_FLAG_RESET); - - DrawAttribs drawAttrs{6, DRAW_FLAG_VERIFY_ALL}; - pContext->Draw(drawAttrs); - - Present(); -} - -TEST_F(DrawCommandTest, Draw_StartVertex_VBOffset) -{ - auto* pEnv = TestingEnvironment::GetInstance(); - auto* pContext = pEnv->GetDeviceContext(); - - SetRenderTargets(sm_pDrawPSO); - - // clang-format off - const Vertex Triangles[] = - { - {}, {}, {}, // Skip 3 vertices using buffer offset - {}, {}, // Skip 2 vertices using StartVertexLocation - Vert[0], Vert[1], Vert[2], - Vert[3], Vert[4], Vert[5] - }; - // clang-format on - - auto pVB = CreateVertexBuffer(Triangles, sizeof(Triangles)); - IBuffer* pVBs[] = {pVB}; - Uint32 Offsets[] = {3 * sizeof(Vertex)}; - pContext->SetVertexBuffers(0, 1, pVBs, Offsets, RESOURCE_STATE_TRANSITION_MODE_TRANSITION, SET_VERTEX_BUFFERS_FLAG_RESET); - - DrawAttribs drawAttrs{6, DRAW_FLAG_VERIFY_ALL}; - drawAttrs.StartVertexLocation = 2; - pContext->Draw(drawAttrs); - - Present(); -} - -TEST_F(DrawCommandTest, Draw_StartVertex_VBOffset_2xStride) -{ - auto* pEnv = TestingEnvironment::GetInstance(); - auto* pContext = pEnv->GetDeviceContext(); - - SetRenderTargets(sm_pDraw_2xStride_PSO); - - // clang-format off - const Vertex Triangles[] = - { - {}, {}, {}, // Skip 3 * sizeof(Vertex) using buffer offset - {}, {}, {}, {}, // Skip 2 vertices using StartVertexLocation - Vert[0], {}, Vert[1], {}, Vert[2], {}, - Vert[3], {}, Vert[4], {}, Vert[5], {} - }; - // clang-format on - - auto pVB = CreateVertexBuffer(Triangles, sizeof(Triangles)); - IBuffer* pVBs[] = {pVB}; - Uint32 Offsets[] = {3 * sizeof(Vertex)}; - pContext->SetVertexBuffers(0, 1, pVBs, Offsets, RESOURCE_STATE_TRANSITION_MODE_TRANSITION, SET_VERTEX_BUFFERS_FLAG_RESET); - - DrawAttribs drawAttrs{6, DRAW_FLAG_VERIFY_ALL}; - drawAttrs.StartVertexLocation = 2; - pContext->Draw(drawAttrs); - - Present(); -} - - - -// Indexed draw calls (glDrawElements/DrawIndexed) - -TEST_F(DrawCommandTest, DrawIndexed) -{ - auto* pEnv = TestingEnvironment::GetInstance(); - auto* pContext = pEnv->GetDeviceContext(); - - SetRenderTargets(sm_pDrawPSO); - - // clang-format off - const Vertex Triangles[] = - { - {}, {}, - Vert[0], {}, Vert[1], {}, {}, Vert[2], - Vert[3], {}, {}, Vert[5], Vert[4] - }; - Uint32 Indices[] = {2,4,7, 8,12,11}; - // clang-format on - - auto pVB = CreateVertexBuffer(Triangles, sizeof(Triangles)); - auto pIB = CreateIndexBuffer(Indices, _countof(Indices)); - - IBuffer* pVBs[] = {pVB}; - Uint32 Offsets[] = {0}; - pContext->SetVertexBuffers(0, 1, pVBs, Offsets, RESOURCE_STATE_TRANSITION_MODE_TRANSITION, SET_VERTEX_BUFFERS_FLAG_RESET); - pContext->SetIndexBuffer(pIB, 0, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); - - DrawIndexedAttribs drawAttrs{6, VT_UINT32, DRAW_FLAG_VERIFY_ALL}; - pContext->DrawIndexed(drawAttrs); - - Present(); -} - -TEST_F(DrawCommandTest, DrawIndexed_IBOffset) -{ - auto* pEnv = TestingEnvironment::GetInstance(); - auto* pContext = pEnv->GetDeviceContext(); - - SetRenderTargets(sm_pDrawPSO); - - // clang-format off - const Vertex Triangles[] = - { - {}, {}, - Vert[0], {}, Vert[1], {}, {}, Vert[2], - Vert[3], {}, {}, Vert[5], Vert[4] - }; - Uint32 Indices[] = {0,0,0,0, 2,4,7, 8,12,11}; // Skip 4 indices using index buffer offset - // clang-format on - - auto pVB = CreateVertexBuffer(Triangles, sizeof(Triangles)); - auto pIB = CreateIndexBuffer(Indices, _countof(Indices)); - - IBuffer* pVBs[] = {pVB}; - Uint32 Offsets[] = {0}; - pContext->SetVertexBuffers(0, 1, pVBs, Offsets, RESOURCE_STATE_TRANSITION_MODE_TRANSITION, SET_VERTEX_BUFFERS_FLAG_RESET); - pContext->SetIndexBuffer(pIB, sizeof(Uint32) * 4, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); - - DrawIndexedAttribs drawAttrs{6, VT_UINT32, DRAW_FLAG_VERIFY_ALL}; - pContext->DrawIndexed(drawAttrs); - - Present(); -} - -TEST_F(DrawCommandTest, DrawIndexed_IBOffset_BaseVertex) -{ - auto* pEnv = TestingEnvironment::GetInstance(); - auto* pContext = pEnv->GetDeviceContext(); - - SetRenderTargets(sm_pDrawPSO); - - Uint32 bv = 2; // Base vertex - // clang-format off - const Vertex Triangles[] = - { - {}, {}, - Vert[0], {}, Vert[1], {}, {}, Vert[2], - Vert[3], {}, {}, Vert[5], Vert[4] - }; - Uint32 Indices[] = {0,0,0,0, 2-bv,4-bv,7-bv, 8-bv,12-bv,11-bv}; - // clang-format on - - auto pVB = CreateVertexBuffer(Triangles, sizeof(Triangles)); - auto pIB = CreateIndexBuffer(Indices, _countof(Indices)); - - IBuffer* pVBs[] = {pVB}; - Uint32 Offsets[] = {0}; - pContext->SetVertexBuffers(0, 1, pVBs, Offsets, RESOURCE_STATE_TRANSITION_MODE_TRANSITION, SET_VERTEX_BUFFERS_FLAG_RESET); - pContext->SetIndexBuffer(pIB, sizeof(Uint32) * 4, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); - - DrawIndexedAttribs drawAttrs{6, VT_UINT32, DRAW_FLAG_VERIFY_ALL}; - drawAttrs.BaseVertex = bv; - pContext->DrawIndexed(drawAttrs); - - Present(); -} - - -// Instanced non-indexed draw calls (glDrawArraysInstanced/DrawInstanced) - -TEST_F(DrawCommandTest, DrawInstanced) -{ - auto* pEnv = TestingEnvironment::GetInstance(); - auto* pContext = pEnv->GetDeviceContext(); - - SetRenderTargets(sm_pDrawInstancedPSO); - - // clang-format off - const Vertex Triangles[] = - { - VertInst[0], VertInst[1], VertInst[2] - }; - const float4 InstancedData[] = - { - float4{0.5f, 0.5f, -0.5f, -0.5f}, - float4{0.5f, 0.5f, +0.5f, -0.5f} - }; - // clang-format on - - auto pVB = CreateVertexBuffer(Triangles, sizeof(Triangles)); - auto pInstVB = CreateVertexBuffer(InstancedData, sizeof(InstancedData)); - - IBuffer* pVBs[] = {pVB, pInstVB}; - Uint32 Offsets[] = {0, 0}; - pContext->SetVertexBuffers(0, _countof(pVBs), pVBs, Offsets, RESOURCE_STATE_TRANSITION_MODE_TRANSITION, SET_VERTEX_BUFFERS_FLAG_RESET); - - DrawAttribs drawAttrs{3, DRAW_FLAG_VERIFY_ALL}; - drawAttrs.NumInstances = 2; // Draw two instances of the same triangle - pContext->Draw(drawAttrs); - - Present(); -} - -TEST_F(DrawCommandTest, DrawInstanced_VBOffset) -{ - auto* pEnv = TestingEnvironment::GetInstance(); - auto* pContext = pEnv->GetDeviceContext(); - - SetRenderTargets(sm_pDrawInstancedPSO); - - // clang-format off - const Vertex Triangles[] = - { - {}, {}, // Skip 2 vertices with VB offset - VertInst[0], VertInst[1], VertInst[2] - }; - const float4 InstancedData[] = - { - {}, {}, {}, // Skip 3 instances with VB offset - float4{0.5f, 0.5f, -0.5f, -0.5f}, - float4{0.5f, 0.5f, +0.5f, -0.5f} - }; - // clang-format on - - auto pVB = CreateVertexBuffer(Triangles, sizeof(Triangles)); - auto pInstVB = CreateVertexBuffer(InstancedData, sizeof(InstancedData)); - - IBuffer* pVBs[] = {pVB, pInstVB}; - Uint32 Offsets[] = {2 * sizeof(Vertex), 3 * sizeof(float4)}; - pContext->SetVertexBuffers(0, _countof(pVBs), pVBs, Offsets, RESOURCE_STATE_TRANSITION_MODE_TRANSITION, SET_VERTEX_BUFFERS_FLAG_RESET); - - DrawAttribs drawAttrs{3, DRAW_FLAG_VERIFY_ALL}; - drawAttrs.NumInstances = 2; // Draw two instances of the same triangle - pContext->Draw(drawAttrs); - - Present(); -} - -TEST_F(DrawCommandTest, DrawInstanced_StartVertex) -{ - auto* pEnv = TestingEnvironment::GetInstance(); - auto* pContext = pEnv->GetDeviceContext(); - - SetRenderTargets(sm_pDrawInstancedPSO); - - // clang-format off - const Vertex Triangles[] = - { - {}, {}, {}, {}, // Skip 4 vertices with start vertex - VertInst[0], VertInst[1], VertInst[2] - }; - const float4 InstancedData[] = - { - float4{0.5f, 0.5f, -0.5f, -0.5f}, - float4{0.5f, 0.5f, +0.5f, -0.5f} - }; - // clang-format on - - auto pVB = CreateVertexBuffer(Triangles, sizeof(Triangles)); - auto pInstVB = CreateVertexBuffer(InstancedData, sizeof(InstancedData)); - - IBuffer* pVBs[] = {pVB, pInstVB}; - Uint32 Offsets[] = {0, 0}; - pContext->SetVertexBuffers(0, _countof(pVBs), pVBs, Offsets, RESOURCE_STATE_TRANSITION_MODE_TRANSITION, SET_VERTEX_BUFFERS_FLAG_RESET); - - DrawAttribs drawAttrs{3, DRAW_FLAG_VERIFY_ALL}; - drawAttrs.NumInstances = 2; // Draw two instances of the same triangle - drawAttrs.StartVertexLocation = 4; // Skip 4 vertices - pContext->Draw(drawAttrs); - - Present(); -} - - -// Instanced draw calls with first instance (glDrawArraysInstancedBaseInstance/DrawInstanced) - -TEST_F(DrawCommandTest, DrawInstanced_FirstInstance) -{ - auto* pEnv = TestingEnvironment::GetInstance(); - auto* pContext = pEnv->GetDeviceContext(); - - SetRenderTargets(sm_pDrawInstancedPSO); - - // clang-format off - const Vertex Triangles[] = - { - VertInst[0], VertInst[1], VertInst[2] - }; - const float4 InstancedData[] = - { - {}, {}, {}, {}, // Skip 4 instances with FirstInstanceLocation - float4{0.5f, 0.5f, -0.5f, -0.5f}, - float4{0.5f, 0.5f, +0.5f, -0.5f} - }; - // clang-format on - - auto pVB = CreateVertexBuffer(Triangles, sizeof(Triangles)); - auto pInstVB = CreateVertexBuffer(InstancedData, sizeof(InstancedData)); - - IBuffer* pVBs[] = {pVB, pInstVB}; - Uint32 Offsets[] = {0, 0}; - pContext->SetVertexBuffers(0, _countof(pVBs), pVBs, Offsets, RESOURCE_STATE_TRANSITION_MODE_TRANSITION, SET_VERTEX_BUFFERS_FLAG_RESET); - - DrawAttribs drawAttrs{3, DRAW_FLAG_VERIFY_ALL}; - drawAttrs.NumInstances = 2; - drawAttrs.FirstInstanceLocation = 4; // Skip 4 instances - pContext->Draw(drawAttrs); - - Present(); -} - -TEST_F(DrawCommandTest, DrawInstanced_FirstInstance_VBOffset) -{ - auto* pEnv = TestingEnvironment::GetInstance(); - auto* pContext = pEnv->GetDeviceContext(); - - SetRenderTargets(sm_pDrawInstancedPSO); - - // clang-format off - const Vertex Triangles[] = - { - {}, {}, {}, // Skip 3 vertices with buffer offset - VertInst[0], VertInst[1], VertInst[2] - }; - const float4 InstancedData[] = - { - {}, {}, // Skip 2 instances with buffer offset - {}, {}, {}, {}, // Skip 4 instances with FirstInstanceLocation - float4{0.5f, 0.5f, -0.5f, -0.5f}, - float4{0.5f, 0.5f, +0.5f, -0.5f} - }; - // clang-format on - - auto pVB = CreateVertexBuffer(Triangles, sizeof(Triangles)); - auto pInstVB = CreateVertexBuffer(InstancedData, sizeof(InstancedData)); - - IBuffer* pVBs[] = {pVB, pInstVB}; - Uint32 Offsets[] = {3 * sizeof(Vertex), 2 * sizeof(float4)}; - pContext->SetVertexBuffers(0, _countof(pVBs), pVBs, Offsets, RESOURCE_STATE_TRANSITION_MODE_TRANSITION, SET_VERTEX_BUFFERS_FLAG_RESET); - - DrawAttribs drawAttrs{3, DRAW_FLAG_VERIFY_ALL}; - drawAttrs.NumInstances = 2; - drawAttrs.FirstInstanceLocation = 4; // Skip 4 instances - pContext->Draw(drawAttrs); - - Present(); -} - - -TEST_F(DrawCommandTest, DrawInstanced_FirstInstance_BaseVertex_FirstIndex_VBOffset_IBOffset) -{ - auto* pEnv = TestingEnvironment::GetInstance(); - auto* pContext = pEnv->GetDeviceContext(); - - SetRenderTargets(sm_pDrawInstancedPSO); - - // clang-format off - const Vertex Triangles[] = - { - {}, {}, {}, {}, // Skip 4 vertices with VB offset - {}, {}, {}, // Skip 3 vertices with StartVertexLocation - VertInst[0], VertInst[1], VertInst[2] - }; - const float4 InstancedData[] = - { - {}, {}, {}, {}, {}, // Skip 5 instances with VB offset - {}, {}, {}, {}, // Skip 4 instances with FirstInstance - float4{0.5f, 0.5f, -0.5f, -0.5f}, - float4{0.5f, 0.5f, +0.5f, -0.5f} - }; - // clang-format on - - auto pVB = CreateVertexBuffer(Triangles, sizeof(Triangles)); - auto pInstVB = CreateVertexBuffer(InstancedData, sizeof(InstancedData)); - - IBuffer* pVBs[] = {pVB, pInstVB}; - Uint32 Offsets[] = {4 * sizeof(Vertex), 5 * sizeof(float4)}; - pContext->SetVertexBuffers(0, _countof(pVBs), pVBs, Offsets, RESOURCE_STATE_TRANSITION_MODE_TRANSITION, SET_VERTEX_BUFFERS_FLAG_RESET); - - DrawAttribs drawAttrs{6, DRAW_FLAG_VERIFY_ALL}; - drawAttrs.NumInstances = 2; - drawAttrs.FirstInstanceLocation = 4; - drawAttrs.StartVertexLocation = 3; - pContext->Draw(drawAttrs); - - Present(); -} - -// Instanced indexed draw calls (glDrawElementsInstanced/DrawIndexedInstanced) - -TEST_F(DrawCommandTest, DrawIndexedInstanced) -{ - auto* pEnv = TestingEnvironment::GetInstance(); - auto* pContext = pEnv->GetDeviceContext(); - - SetRenderTargets(sm_pDrawInstancedPSO); - - // clang-format off - const Vertex Triangles[] = - { - {}, {}, - VertInst[1], {}, VertInst[0], {}, {}, VertInst[2] - }; - Uint32 Indices[] = {4, 2, 7}; - const float4 InstancedData[] = - { - float4{0.5f, 0.5f, -0.5f, -0.5f}, - float4{0.5f, 0.5f, +0.5f, -0.5f} - }; - // clang-format on - - auto pVB = CreateVertexBuffer(Triangles, sizeof(Triangles)); - auto pInstVB = CreateVertexBuffer(InstancedData, sizeof(InstancedData)); - auto pIB = CreateIndexBuffer(Indices, _countof(Indices)); - - IBuffer* pVBs[] = {pVB, pInstVB}; - Uint32 Offsets[] = {0, 0}; - pContext->SetVertexBuffers(0, _countof(pVBs), pVBs, Offsets, RESOURCE_STATE_TRANSITION_MODE_TRANSITION, SET_VERTEX_BUFFERS_FLAG_RESET); - pContext->SetIndexBuffer(pIB, 0, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); - - DrawIndexedAttribs drawAttrs{3, VT_UINT32, DRAW_FLAG_VERIFY_ALL}; - drawAttrs.NumInstances = 2; - pContext->DrawIndexed(drawAttrs); - - Present(); -} - - -TEST_F(DrawCommandTest, DrawIndexedInstanced_IBOffset) -{ - auto* pEnv = TestingEnvironment::GetInstance(); - auto* pContext = pEnv->GetDeviceContext(); - - SetRenderTargets(sm_pDrawInstancedPSO); - - // clang-format off - const Vertex Triangles[] = - { - {}, {}, - VertInst[1], {}, VertInst[0], {}, {}, VertInst[2] - }; - Uint32 Indices[] = {0,0,0,0,0, 4, 2, 7}; - const float4 InstancedData[] = - { - float4{0.5f, 0.5f, -0.5f, -0.5f}, - float4{0.5f, 0.5f, +0.5f, -0.5f} - }; - // clang-format on - - auto pVB = CreateVertexBuffer(Triangles, sizeof(Triangles)); - auto pInstVB = CreateVertexBuffer(InstancedData, sizeof(InstancedData)); - auto pIB = CreateIndexBuffer(Indices, _countof(Indices)); - - IBuffer* pVBs[] = {pVB, pInstVB}; - Uint32 Offsets[] = {0, 0}; - pContext->SetVertexBuffers(0, _countof(pVBs), pVBs, Offsets, RESOURCE_STATE_TRANSITION_MODE_TRANSITION, SET_VERTEX_BUFFERS_FLAG_RESET); - pContext->SetIndexBuffer(pIB, 5 * sizeof(Uint32), RESOURCE_STATE_TRANSITION_MODE_TRANSITION); - - DrawIndexedAttribs drawAttrs{3, VT_UINT32, DRAW_FLAG_VERIFY_ALL}; - drawAttrs.NumInstances = 2; - pContext->DrawIndexed(drawAttrs); - - Present(); -} - - -TEST_F(DrawCommandTest, DrawIndexedInstanced_VBOffset) -{ - auto* pEnv = TestingEnvironment::GetInstance(); - auto* pContext = pEnv->GetDeviceContext(); - - SetRenderTargets(sm_pDrawInstancedPSO); - - // clang-format off - const Vertex Triangles[] = - { - {}, {}, // Skip 2 vertices with VBOffset - {}, {}, - VertInst[1], {}, VertInst[0], {}, {}, VertInst[2] - }; - Uint32 Indices[] = {4, 2, 7}; - const float4 InstancedData[] = - { - {}, {}, {}, {}, // Skip 4 instances with VB offset - float4{0.5f, 0.5f, -0.5f, -0.5f}, - float4{0.5f, 0.5f, +0.5f, -0.5f} - }; - // clang-format on - - auto pVB = CreateVertexBuffer(Triangles, sizeof(Triangles)); - auto pInstVB = CreateVertexBuffer(InstancedData, sizeof(InstancedData)); - auto pIB = CreateIndexBuffer(Indices, _countof(Indices)); - - IBuffer* pVBs[] = {pVB, pInstVB}; - Uint32 Offsets[] = {2 * sizeof(Vertex), 4 * sizeof(float4)}; - pContext->SetVertexBuffers(0, _countof(pVBs), pVBs, Offsets, RESOURCE_STATE_TRANSITION_MODE_TRANSITION, SET_VERTEX_BUFFERS_FLAG_RESET); - pContext->SetIndexBuffer(pIB, 0, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); - - DrawIndexedAttribs drawAttrs{3, VT_UINT32, DRAW_FLAG_VERIFY_ALL}; - drawAttrs.NumInstances = 2; - pContext->DrawIndexed(drawAttrs); - - Present(); -} - - -TEST_F(DrawCommandTest, DrawIndexedInstanced_FirstIndex) -{ - auto* pEnv = TestingEnvironment::GetInstance(); - auto* pContext = pEnv->GetDeviceContext(); - - SetRenderTargets(sm_pDrawInstancedPSO); - - // clang-format off - const Vertex Triangles[] = - { - {}, {}, - VertInst[1], {}, VertInst[0], {}, {}, VertInst[2] - }; - Uint32 Indices[] = {0,0,0,0,0, 4, 2, 7}; - const float4 InstancedData[] = - { - float4{0.5f, 0.5f, -0.5f, -0.5f}, - float4{0.5f, 0.5f, +0.5f, -0.5f} - }; - // clang-format on - - auto pVB = CreateVertexBuffer(Triangles, sizeof(Triangles)); - auto pInstVB = CreateVertexBuffer(InstancedData, sizeof(InstancedData)); - auto pIB = CreateIndexBuffer(Indices, _countof(Indices)); - - IBuffer* pVBs[] = {pVB, pInstVB}; - Uint32 Offsets[] = {0, 0}; - pContext->SetVertexBuffers(0, _countof(pVBs), pVBs, Offsets, RESOURCE_STATE_TRANSITION_MODE_TRANSITION, SET_VERTEX_BUFFERS_FLAG_RESET); - pContext->SetIndexBuffer(pIB, 0, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); - - DrawIndexedAttribs drawAttrs{3, VT_UINT32, DRAW_FLAG_VERIFY_ALL}; - drawAttrs.NumInstances = 2; - drawAttrs.FirstIndexLocation = 5; - pContext->DrawIndexed(drawAttrs); - - Present(); -} - - -// Instanced indexed draw calls with first instance (glDrawElementsInstancedBaseInstance/DrawInstanced) - - -TEST_F(DrawCommandTest, DrawIndexedInstanced_FirstInstance) -{ - auto* pEnv = TestingEnvironment::GetInstance(); - auto* pContext = pEnv->GetDeviceContext(); - - SetRenderTargets(sm_pDrawInstancedPSO); - - // clang-format off - const Vertex Triangles[] = - { - {}, {}, - VertInst[1], {}, VertInst[0], {}, {}, VertInst[2] - }; - Uint32 Indices[] = {4, 2, 7}; - const float4 InstancedData[] = - { - {}, {}, {}, {}, // Skip 4 instances with FirstInstance - float4{0.5f, 0.5f, -0.5f, -0.5f}, - float4{0.5f, 0.5f, +0.5f, -0.5f} - }; - // clang-format on - - auto pVB = CreateVertexBuffer(Triangles, sizeof(Triangles)); - auto pInstVB = CreateVertexBuffer(InstancedData, sizeof(InstancedData)); - auto pIB = CreateIndexBuffer(Indices, _countof(Indices)); - - IBuffer* pVBs[] = {pVB, pInstVB}; - Uint32 Offsets[] = {0, 0}; - pContext->SetVertexBuffers(0, _countof(pVBs), pVBs, Offsets, RESOURCE_STATE_TRANSITION_MODE_TRANSITION, SET_VERTEX_BUFFERS_FLAG_RESET); - pContext->SetIndexBuffer(pIB, 0, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); - - DrawIndexedAttribs drawAttrs{3, VT_UINT32, DRAW_FLAG_VERIFY_ALL}; - drawAttrs.NumInstances = 2; - drawAttrs.FirstInstanceLocation = 4; // Skip 4 instances - pContext->DrawIndexed(drawAttrs); - - Present(); -} - -TEST_F(DrawCommandTest, DrawIndexedInstanced_FirstInstance_IBOffset) -{ - auto* pEnv = TestingEnvironment::GetInstance(); - auto* pContext = pEnv->GetDeviceContext(); - - SetRenderTargets(sm_pDrawInstancedPSO); - - // clang-format off - const Vertex Triangles[] = - { - {}, {}, - VertInst[1], {}, VertInst[0], {}, {}, VertInst[2] - }; - Uint32 Indices[] = {0,0,0,0, 4, 2, 7}; - const float4 InstancedData[] = - { - {}, {}, {}, {}, // Skip 4 instances with FirstInstance - float4{0.5f, 0.5f, -0.5f, -0.5f}, - float4{0.5f, 0.5f, +0.5f, -0.5f} - }; - // clang-format on - - auto pVB = CreateVertexBuffer(Triangles, sizeof(Triangles)); - auto pInstVB = CreateVertexBuffer(InstancedData, sizeof(InstancedData)); - auto pIB = CreateIndexBuffer(Indices, _countof(Indices)); - - IBuffer* pVBs[] = {pVB, pInstVB}; - Uint32 Offsets[] = {0, 0}; - pContext->SetVertexBuffers(0, _countof(pVBs), pVBs, Offsets, RESOURCE_STATE_TRANSITION_MODE_TRANSITION, SET_VERTEX_BUFFERS_FLAG_RESET); - pContext->SetIndexBuffer(pIB, 4 * sizeof(Uint32), RESOURCE_STATE_TRANSITION_MODE_TRANSITION); - - DrawIndexedAttribs drawAttrs{3, VT_UINT32, DRAW_FLAG_VERIFY_ALL}; - drawAttrs.NumInstances = 2; - drawAttrs.FirstInstanceLocation = 4; // Skip 4 instances - pContext->DrawIndexed(drawAttrs); - - Present(); -} - -TEST_F(DrawCommandTest, DrawIndexedInstanced_FirstInstance_VBOffset) -{ - auto* pEnv = TestingEnvironment::GetInstance(); - auto* pContext = pEnv->GetDeviceContext(); - - SetRenderTargets(sm_pDrawInstancedPSO); - - // clang-format off - const Vertex Triangles[] = - { - {}, {}, {}, {}, // Skip 4 vertices with VB offset - {}, {}, - VertInst[1], {}, VertInst[0], {}, {}, VertInst[2] - }; - Uint32 Indices[] = {4, 2, 7}; - const float4 InstancedData[] = - { - {}, {}, {}, {}, {}, // Skip 5 instances with VB offset - {}, {}, {}, {}, // Skip 4 instances with FirstInstance - float4{0.5f, 0.5f, -0.5f, -0.5f}, - float4{0.5f, 0.5f, +0.5f, -0.5f} - }; - // clang-format on - - auto pVB = CreateVertexBuffer(Triangles, sizeof(Triangles)); - auto pInstVB = CreateVertexBuffer(InstancedData, sizeof(InstancedData)); - auto pIB = CreateIndexBuffer(Indices, _countof(Indices)); - - IBuffer* pVBs[] = {pVB, pInstVB}; - Uint32 Offsets[] = {4 * sizeof(Vertex), 5 * sizeof(float4)}; - pContext->SetVertexBuffers(0, _countof(pVBs), pVBs, Offsets, RESOURCE_STATE_TRANSITION_MODE_TRANSITION, SET_VERTEX_BUFFERS_FLAG_RESET); - pContext->SetIndexBuffer(pIB, 0, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); - - DrawIndexedAttribs drawAttrs{3, VT_UINT32, DRAW_FLAG_VERIFY_ALL}; - drawAttrs.NumInstances = 2; - drawAttrs.FirstInstanceLocation = 4; // Skip 4 instances - pContext->DrawIndexed(drawAttrs); - - Present(); -} - - -TEST_F(DrawCommandTest, DrawIndexedInstanced_FirstInstance_IBOffset_FirstIndex) -{ - auto* pEnv = TestingEnvironment::GetInstance(); - auto* pContext = pEnv->GetDeviceContext(); - - SetRenderTargets(sm_pDrawInstancedPSO); - - // clang-format off - const Vertex Triangles[] = - { - {}, {}, - VertInst[1], {}, VertInst[0], {}, {}, VertInst[2] - }; - Uint32 Indices[] = {0,0,0,0, 0,0,0, 4, 2, 7}; - const float4 InstancedData[] = - { - {}, {}, {}, {}, // Skip 4 instances with FirstInstance - float4{0.5f, 0.5f, -0.5f, -0.5f}, - float4{0.5f, 0.5f, +0.5f, -0.5f} - }; - // clang-format on - - auto pVB = CreateVertexBuffer(Triangles, sizeof(Triangles)); - auto pInstVB = CreateVertexBuffer(InstancedData, sizeof(InstancedData)); - auto pIB = CreateIndexBuffer(Indices, _countof(Indices)); - - IBuffer* pVBs[] = {pVB, pInstVB}; - Uint32 Offsets[] = {0, 0}; - pContext->SetVertexBuffers(0, _countof(pVBs), pVBs, Offsets, RESOURCE_STATE_TRANSITION_MODE_TRANSITION, SET_VERTEX_BUFFERS_FLAG_RESET); - pContext->SetIndexBuffer(pIB, 4 * sizeof(Uint32), RESOURCE_STATE_TRANSITION_MODE_TRANSITION); - - DrawIndexedAttribs drawAttrs{3, VT_UINT32, DRAW_FLAG_VERIFY_ALL}; - drawAttrs.NumInstances = 2; - drawAttrs.FirstInstanceLocation = 4; // Skip 4 instances - drawAttrs.FirstIndexLocation = 3; - pContext->DrawIndexed(drawAttrs); - - Present(); -} - - - -// Instanced draw commands with base vertex (glDrawElementsInstancedBaseVertex/DrawInstanced) - -TEST_F(DrawCommandTest, DrawIndexedInstanced_BaseVertex) -{ - auto* pEnv = TestingEnvironment::GetInstance(); - auto* pContext = pEnv->GetDeviceContext(); - - SetRenderTargets(sm_pDrawInstancedPSO); - - // clang-format off - const Vertex Triangles[] = - { - {}, {}, {}, // Skip 3 vertices with BaseVertex - {}, {}, - VertInst[1], {}, VertInst[0], {}, {}, VertInst[2] - }; - Uint32 Indices[] = {4, 2, 7}; - const float4 InstancedData[] = - { - float4{0.5f, 0.5f, -0.5f, -0.5f}, - float4{0.5f, 0.5f, +0.5f, -0.5f} - }; - // clang-format on - - auto pVB = CreateVertexBuffer(Triangles, sizeof(Triangles)); - auto pInstVB = CreateVertexBuffer(InstancedData, sizeof(InstancedData)); - auto pIB = CreateIndexBuffer(Indices, _countof(Indices)); - - IBuffer* pVBs[] = {pVB, pInstVB}; - Uint32 Offsets[] = {0, 0}; - pContext->SetVertexBuffers(0, _countof(pVBs), pVBs, Offsets, RESOURCE_STATE_TRANSITION_MODE_TRANSITION, SET_VERTEX_BUFFERS_FLAG_RESET); - pContext->SetIndexBuffer(pIB, 0, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); - - DrawIndexedAttribs drawAttrs{3, VT_UINT32, DRAW_FLAG_VERIFY_ALL}; - drawAttrs.NumInstances = 2; - drawAttrs.BaseVertex = 3; - pContext->DrawIndexed(drawAttrs); - - Present(); -} - -TEST_F(DrawCommandTest, DrawIndexedInstanced_FirstInstance_BaseVertex_VBOffset) -{ - auto* pEnv = TestingEnvironment::GetInstance(); - auto* pContext = pEnv->GetDeviceContext(); - - SetRenderTargets(sm_pDrawInstancedPSO); - - // clang-format off - const Vertex Triangles[] = - { - {}, {}, {}, {}, // Skip 4 vertices with VB offset - {}, {}, {}, // Skip 3 vertices with BaseVertex - {}, {}, - VertInst[1], {}, VertInst[0], {}, {}, VertInst[2] - }; - Uint32 Indices[] = {4, 2, 7}; - const float4 InstancedData[] = - { - {}, {}, {}, {}, {}, // Skip 5 instances with VB offset - {}, {}, {}, {}, // Skip 4 instances with FirstInstance - float4{0.5f, 0.5f, -0.5f, -0.5f}, - float4{0.5f, 0.5f, +0.5f, -0.5f} - }; - // clang-format on - - auto pVB = CreateVertexBuffer(Triangles, sizeof(Triangles)); - auto pInstVB = CreateVertexBuffer(InstancedData, sizeof(InstancedData)); - auto pIB = CreateIndexBuffer(Indices, _countof(Indices)); - - IBuffer* pVBs[] = {pVB, pInstVB}; - Uint32 Offsets[] = {4 * sizeof(Vertex), 5 * sizeof(float4)}; - pContext->SetVertexBuffers(0, _countof(pVBs), pVBs, Offsets, RESOURCE_STATE_TRANSITION_MODE_TRANSITION, SET_VERTEX_BUFFERS_FLAG_RESET); - pContext->SetIndexBuffer(pIB, 0, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); - - DrawIndexedAttribs drawAttrs{3, VT_UINT32, DRAW_FLAG_VERIFY_ALL}; - drawAttrs.NumInstances = 2; - drawAttrs.FirstInstanceLocation = 4; // Skip 4 instances - drawAttrs.BaseVertex = 3; - pContext->DrawIndexed(drawAttrs); - - Present(); -} - - -TEST_F(DrawCommandTest, DrawIndexedInstanced_FirstInstance_BaseVertex_FirstIndex_VBOffset_IBOffset) -{ - auto* pEnv = TestingEnvironment::GetInstance(); - auto* pContext = pEnv->GetDeviceContext(); - - SetRenderTargets(sm_pDrawInstancedPSO); - - // clang-format off - const Vertex Triangles[] = - { - {}, {}, {}, {}, // Skip 4 vertices with VB offset - {}, {}, {}, // Skip 3 vertices with BaseVertex - {}, {}, - VertInst[1], {}, VertInst[0], {}, {}, VertInst[2] - }; - Uint32 Indices[] = {0,0,0,0, 0,0,0, 4, 2, 7}; - const float4 InstancedData[] = - { - {}, {}, {}, {}, {}, // Skip 5 instances with VB offset - {}, {}, {}, {}, // Skip 4 instances with FirstInstance - float4{0.5f, 0.5f, -0.5f, -0.5f}, - float4{0.5f, 0.5f, +0.5f, -0.5f} - }; - // clang-format on - - auto pVB = CreateVertexBuffer(Triangles, sizeof(Triangles)); - auto pInstVB = CreateVertexBuffer(InstancedData, sizeof(InstancedData)); - auto pIB = CreateIndexBuffer(Indices, _countof(Indices)); - - IBuffer* pVBs[] = {pVB, pInstVB}; - Uint32 Offsets[] = {4 * sizeof(Vertex), 5 * sizeof(float4)}; - pContext->SetVertexBuffers(0, _countof(pVBs), pVBs, Offsets, RESOURCE_STATE_TRANSITION_MODE_TRANSITION, SET_VERTEX_BUFFERS_FLAG_RESET); - pContext->SetIndexBuffer(pIB, 4 * sizeof(Uint32), RESOURCE_STATE_TRANSITION_MODE_TRANSITION); - - DrawIndexedAttribs drawAttrs{3, VT_UINT32, DRAW_FLAG_VERIFY_ALL}; - drawAttrs.NumInstances = 2; - drawAttrs.FirstInstanceLocation = 4; // Skip 4 instances - drawAttrs.BaseVertex = 3; - drawAttrs.FirstIndexLocation = 3; - pContext->DrawIndexed(drawAttrs); - - Present(); -} - - -// Indirect draw calls - -TEST_F(DrawCommandTest, DrawInstancedIndirect_FirstInstance_BaseVertex_FirstIndex_VBOffset_IBOffset_InstOffset) -{ - auto* pEnv = TestingEnvironment::GetInstance(); - auto* pDevice = pEnv->GetDevice(); - if (!pDevice->GetDeviceCaps().bIndirectRenderingSupported) - GTEST_SKIP() << "Indirect rendering is not supported on this device"; - - auto* pContext = pEnv->GetDeviceContext(); - - SetRenderTargets(sm_pDrawInstancedPSO); - - // clang-format off - const Vertex Triangles[] = - { - {}, {}, {}, {}, // Skip 4 vertices with VB offset - {}, {}, {}, // Skip 3 vertices with StartVertexLocation - VertInst[0], VertInst[1], VertInst[2] - }; - const float4 InstancedData[] = - { - {}, {}, {}, {}, {}, // Skip 5 instances with VB offset - {}, {}, {}, {}, // Skip 4 instances with FirstInstance - float4{0.5f, 0.5f, -0.5f, -0.5f}, - float4{0.5f, 0.5f, +0.5f, -0.5f} - }; - // clang-format on - - auto pVB = CreateVertexBuffer(Triangles, sizeof(Triangles)); - auto pInstVB = CreateVertexBuffer(InstancedData, sizeof(InstancedData)); - - IBuffer* pVBs[] = {pVB, pInstVB}; - Uint32 Offsets[] = {4 * sizeof(Vertex), 5 * sizeof(float4)}; - pContext->SetVertexBuffers(0, _countof(pVBs), pVBs, Offsets, RESOURCE_STATE_TRANSITION_MODE_TRANSITION, SET_VERTEX_BUFFERS_FLAG_RESET); - - Uint32 IndirectDrawData[] = - { - 0, 0, 0, 0, 0, // Offset - - 6, // NumVertices - 2, // NumInstances - 3, // StartVertexLocation - 4 // FirstInstanceLocation - }; - auto pIndirectArgsBuff = CreateIndirectDrawArgsBuffer(IndirectDrawData, sizeof(IndirectDrawData)); - - DrawIndirectAttribs drawAttrs{DRAW_FLAG_VERIFY_ALL, RESOURCE_STATE_TRANSITION_MODE_TRANSITION}; - drawAttrs.IndirectDrawArgsOffset = 5 * sizeof(Uint32); - pContext->DrawIndirect(drawAttrs, pIndirectArgsBuff); - - Present(); -} - -TEST_F(DrawCommandTest, DrawIndexedInstancedIndirect_FirstInstance_BaseVertex_FirstIndex_VBOffset_IBOffset_InstOffset) -{ - auto* pEnv = TestingEnvironment::GetInstance(); - auto* pContext = pEnv->GetDeviceContext(); - - SetRenderTargets(sm_pDrawInstancedPSO); - - // clang-format off - const Vertex Triangles[] = - { - {}, {}, {}, {}, // Skip 4 vertices with VB offset - {}, {}, {}, // Skip 3 vertices with BaseVertex - {}, {}, - VertInst[1], {}, VertInst[0], {}, {}, VertInst[2] - }; - Uint32 Indices[] = {0,0,0, 0,0,0,0, 4, 2, 7}; - const float4 InstancedData[] = - { - {}, {}, {}, {}, // Skip 4 instances with VB offset - {}, {}, {}, {}, {}, // Skip 5 instances with FirstInstance - float4{0.5f, 0.5f, -0.5f, -0.5f}, - float4{0.5f, 0.5f, +0.5f, -0.5f} - }; - // clang-format on - - auto pVB = CreateVertexBuffer(Triangles, sizeof(Triangles)); - auto pInstVB = CreateVertexBuffer(InstancedData, sizeof(InstancedData)); - auto pIB = CreateIndexBuffer(Indices, _countof(Indices)); - - IBuffer* pVBs[] = {pVB, pInstVB}; - Uint32 Offsets[] = {4 * sizeof(Vertex), 4 * sizeof(float4)}; - pContext->SetVertexBuffers(0, _countof(pVBs), pVBs, Offsets, RESOURCE_STATE_TRANSITION_MODE_TRANSITION, SET_VERTEX_BUFFERS_FLAG_RESET); - pContext->SetIndexBuffer(pIB, 3 * sizeof(Uint32), RESOURCE_STATE_TRANSITION_MODE_TRANSITION); - - Uint32 IndirectDrawData[] = - { - 0, 0, 0, 0, 0, // Offset - - 6, // NumIndices - 2, // NumInstances - 4, // FirstIndexLocation - 3, // BaseVertex - 5, // FirstInstanceLocation - }; - auto pIndirectArgsBuff = CreateIndirectDrawArgsBuffer(IndirectDrawData, sizeof(IndirectDrawData)); - - DrawIndexedIndirectAttribs drawAttrs{VT_UINT32, DRAW_FLAG_VERIFY_ALL, RESOURCE_STATE_TRANSITION_MODE_TRANSITION}; - drawAttrs.IndirectDrawArgsOffset = 5 * sizeof(Uint32); - pContext->DrawIndexedIndirect(drawAttrs, pIndirectArgsBuff); - - Present(); -} - -} // namespace diff --git a/UnitTests/DiligentCoreAPITest/src/GL/ClearRenderTargetRefenceGL.cpp b/UnitTests/DiligentCoreAPITest/src/GL/ClearRenderTargetRefenceGL.cpp deleted file mode 100644 index fa41d17f..00000000 --- a/UnitTests/DiligentCoreAPITest/src/GL/ClearRenderTargetRefenceGL.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "GL/TestingEnvironmentGL.h" -#include "GL/TestingSwapChainGL.h" - -namespace Diligent -{ - -namespace Testing -{ - -void ClearRenderTargetReferenceGL(ISwapChain* pSwapChain) -{ - auto* pEnv = TestingEnvironmentGL::GetInstance(); - auto* pContext = pEnv->GetDeviceContext(); - auto* pTestingSwapChainGL = ValidatedCast(pSwapChain); - - const auto& SCDesc = pTestingSwapChainGL->GetDesc(); - - glDisable(GL_SCISSOR_TEST); - pTestingSwapChainGL->BindFramebuffer(); - glViewport(0, 0, SCDesc.Width, SCDesc.Height); - glClearColor(0.25, 0.5f, 0.75f, 1.0f); - glClear(GL_COLOR_BUFFER_BIT); - - // Make sure Diligent Engine will reset all GL states - pContext->InvalidateState(); -} - -} // namespace Testing - -} // namespace Diligent diff --git a/UnitTests/DiligentCoreAPITest/src/GL/CreateObjFromNativeResGL.cpp b/UnitTests/DiligentCoreAPITest/src/GL/CreateObjFromNativeResGL.cpp deleted file mode 100644 index ad265eaf..00000000 --- a/UnitTests/DiligentCoreAPITest/src/GL/CreateObjFromNativeResGL.cpp +++ /dev/null @@ -1,167 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#if PLATFORM_WIN32 - -# ifndef GLEW_STATIC -# define GLEW_STATIC // Must be defined to use static version of glew -# endif -# include "GL/glew.h" -#elif PLATFORM_LINUX - -# ifndef GLEW_STATIC -# define GLEW_STATIC // Must be defined to use static version of glew -# endif -# ifndef GLEW_NO_GLU -# define GLEW_NO_GLU -# endif - -# include "GL/glew.h" - -// Undefine beautiful defines from GL/glx.h -> X11/Xlib.h -# ifdef Bool -# undef Bool -# endif -# ifdef True -# undef True -# endif -# ifdef False -# undef False -# endif -# ifdef Status -# undef Status -# endif -# ifdef Success -# undef Success -# endif - -#elif PLATFORM_MACOS - -# ifndef GLEW_STATIC -# define GLEW_STATIC // Must be defined to use static version of glew -# endif -# ifndef GLEW_NO_GLU -# define GLEW_NO_GLU -# endif - -# include "GL/glew.h" - -#elif PLATFORM_ANDROID - -# include -# include - -#elif PLATFORM_IOS - -# include - -#else -# error Unsupported platform -#endif - -#include "RenderDeviceGL.h" -#include "TextureGL.h" -#include "BufferGL.h" -#include "GraphicsAccessories.h" - -#include "GL/CreateObjFromNativeResGL.h" - -#include "gtest/gtest.h" - -namespace Diligent -{ - -namespace Testing -{ - -void TestCreateObjFromNativeResGL::CreateTexture(Diligent::ITexture* pTexture) -{ -#if PLATFORM_WIN32 || PLATFORM_LINUX || PLATFORM_ANDROID - RefCntAutoPtr pDeviceGL(m_pDevice, IID_RenderDeviceGL); - RefCntAutoPtr pTextureGL(pTexture, IID_TextureGL); - ASSERT_NE(pDeviceGL, nullptr); - ASSERT_NE(pTextureGL, nullptr); - - const auto& SrcTexDesc = pTexture->GetDesc(); - if (SrcTexDesc.Type == RESOURCE_DIM_TEX_CUBE_ARRAY) - return; - - auto GLHandle = pTextureGL->GetGLTextureHandle(); - ASSERT_NE(GLHandle, (GLuint)0); - - auto TmpTexDesc = SrcTexDesc; - - TmpTexDesc.Width = 0; - TmpTexDesc.Height = 0; - TmpTexDesc.MipLevels = 0; - TmpTexDesc.Format = TEX_FORMAT_UNKNOWN; - - RefCntAutoPtr pAttachedTexture; - pDeviceGL->CreateTextureFromGLHandle(GLHandle, TmpTexDesc, RESOURCE_STATE_UNKNOWN, &pAttachedTexture); - ASSERT_NE(pAttachedTexture, nullptr); - - auto TestTexDesc = pAttachedTexture->GetDesc(); - if (m_pDevice->GetTextureFormatInfo(SrcTexDesc.Format).IsTypeless) - TestTexDesc.Format = SrcTexDesc.Format; - - EXPECT_EQ(TestTexDesc, SrcTexDesc) << "Src tex desc: " << GetObjectDescString(SrcTexDesc) - << "\nTest tex desc: " << GetObjectDescString(TestTexDesc); - - RefCntAutoPtr pAttachedTextureGL(pAttachedTexture, IID_TextureGL); - ASSERT_NE(pAttachedTextureGL, nullptr); - EXPECT_EQ(pAttachedTextureGL->GetGLTextureHandle(), GLHandle); - EXPECT_EQ(pAttachedTextureGL->GetBindTarget(), pTextureGL->GetBindTarget()); - EXPECT_EQ(reinterpret_cast(pAttachedTextureGL->GetNativeHandle()), GLHandle); -#endif -} - -void TestCreateObjFromNativeResGL::CreateBuffer(Diligent::IBuffer* pBuffer) -{ -#if PLATFORM_WIN32 || PLATFORM_LINUX || PLATFORM_ANDROID - RefCntAutoPtr pDeviceGL(m_pDevice, IID_RenderDeviceGL); - RefCntAutoPtr pBufferGL(pBuffer, IID_BufferGL); - ASSERT_NE(pDeviceGL, nullptr); - ASSERT_NE(pBufferGL, nullptr); - - const auto& SrcBuffDesc = pBuffer->GetDesc(); - auto GLBufferHandle = pBufferGL->GetGLBufferHandle(); - ASSERT_NE(GLBufferHandle, (GLuint)0); - - RefCntAutoPtr pBufferFromNativeGLHandle; - pDeviceGL->CreateBufferFromGLHandle(GLBufferHandle, SrcBuffDesc, RESOURCE_STATE_UNKNOWN, &pBufferFromNativeGLHandle); - ASSERT_NE(pBufferFromNativeGLHandle, nullptr); - - const auto& TestBufferDesc = pBufferFromNativeGLHandle->GetDesc(); - EXPECT_EQ(TestBufferDesc, SrcBuffDesc) << "Src buff desc: " << GetObjectDescString(SrcBuffDesc) - << "\nTest buff desc: " << GetObjectDescString(TestBufferDesc); - - RefCntAutoPtr pTestBufferGL(pBufferFromNativeGLHandle, IID_BufferGL); - ASSERT_NE(pTestBufferGL, nullptr); - EXPECT_EQ(pTestBufferGL->GetGLBufferHandle(), GLBufferHandle); - EXPECT_EQ(reinterpret_cast(pTestBufferGL->GetNativeHandle()), GLBufferHandle); -#endif -} - -} // namespace Testing - -} // namespace Diligent diff --git a/UnitTests/DiligentCoreAPITest/src/GL/DrawCommandRefenceGL.cpp b/UnitTests/DiligentCoreAPITest/src/GL/DrawCommandRefenceGL.cpp deleted file mode 100644 index 0f6ca830..00000000 --- a/UnitTests/DiligentCoreAPITest/src/GL/DrawCommandRefenceGL.cpp +++ /dev/null @@ -1,131 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "GL/TestingEnvironmentGL.h" -#include "GL/TestingSwapChainGL.h" - -namespace Diligent -{ - -namespace Testing -{ - -static const char* VSSource = R"( -#version 420 core - -#ifndef GL_ES -out gl_PerVertex -{ - vec4 gl_Position; -}; -#endif - -layout(location = 0) out vec3 out_Color; - -void main() -{ - vec4 Pos[6]; - Pos[0] = vec4(-1.0, -0.5, 0.0, 1.0); - Pos[1] = vec4(-0.5, +0.5, 0.0, 1.0); - Pos[2] = vec4( 0.0, -0.5, 0.0, 1.0); - - Pos[3] = vec4(+0.0, -0.5, 0.0, 1.0); - Pos[4] = vec4(+0.5, +0.5, 0.0, 1.0); - Pos[5] = vec4(+1.0, -0.5, 0.0, 1.0); - - vec3 Col[6]; - Col[0] = vec3(1.0, 0.0, 0.0); - Col[1] = vec3(0.0, 1.0, 0.0); - Col[2] = vec3(0.0, 0.0, 1.0); - - Col[3] = vec3(1.0, 0.0, 0.0); - Col[4] = vec3(0.0, 1.0, 0.0); - Col[5] = vec3(0.0, 0.0, 1.0); - - gl_Position = Pos[gl_VertexID]; - out_Color = Col[gl_VertexID]; -} -)"; - -static const char* PSSource = R"( -#version 420 core - -layout(location = 0) in vec3 in_Color; -layout(location = 0) out vec4 out_Color; - -void main() -{ - out_Color = vec4(in_Color, 1.0); -} -)"; - -void RenderDrawCommandRefenceGL(ISwapChain* pSwapChain) -{ - auto* pEnv = TestingEnvironmentGL::GetInstance(); - auto* pContext = pEnv->GetDeviceContext(); - auto* pTestingSwapChainGL = ValidatedCast(pSwapChain); - - const auto& SCDesc = pTestingSwapChainGL->GetDesc(); - - GLuint glShaders[2] = {}; - - glShaders[0] = pEnv->CompileGLShader(VSSource, GL_VERTEX_SHADER); - ASSERT_NE(glShaders[0], 0u); - glShaders[1] = pEnv->CompileGLShader(PSSource, GL_FRAGMENT_SHADER); - ASSERT_NE(glShaders[1], 0u); - auto glProg = pEnv->LinkProgram(glShaders, 2); - ASSERT_NE(glProg, 0u); - - glDisable(GL_DEPTH_TEST); - glDisable(GL_SCISSOR_TEST); - glDisable(GL_BLEND); - glDisable(GL_CULL_FACE); - if (glPolygonMode != nullptr) - { - glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); - } - pTestingSwapChainGL->BindFramebuffer(); - glViewport(0, 0, SCDesc.Width, SCDesc.Height); - glClearColor(0.f, 0.f, 0.f, 0.f); - glClear(GL_COLOR_BUFFER_BIT); - glUseProgram(glProg); - glBindVertexArray(pEnv->GetDummyVAO()); - glDrawArrays(GL_TRIANGLES, 0, 6); - glBindVertexArray(0); - glUseProgram(0); - - for (int i = 0; i < _countof(glShaders); ++i) - { - if (glShaders[i] != 0) - glDeleteShader(glShaders[i]); - } - if (glProg != 0) - glDeleteProgram(glProg); - - // Make sure Diligent Engine will reset all GL states - pContext->InvalidateState(); -} - -} // namespace Testing - -} // namespace Diligent diff --git a/UnitTests/DiligentCoreAPITest/src/GL/TestingEnvironmentGL.cpp b/UnitTests/DiligentCoreAPITest/src/GL/TestingEnvironmentGL.cpp deleted file mode 100644 index a78318cb..00000000 --- a/UnitTests/DiligentCoreAPITest/src/GL/TestingEnvironmentGL.cpp +++ /dev/null @@ -1,144 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "GL/TestingEnvironmentGL.h" - -namespace Diligent -{ - -namespace Testing -{ - -void CreateTestingSwapChainGL(IRenderDevice* pDevice, - IDeviceContext* pContext, - const SwapChainDesc& SCDesc, - ISwapChain** ppSwapChain); - -TestingEnvironmentGL::TestingEnvironmentGL(DeviceType deviceType, ADAPTER_TYPE AdapterType, const SwapChainDesc& SCDesc) : - TestingEnvironment{deviceType, AdapterType, SCDesc} -{ - // Initialize GLEW - auto err = glewInit(); - if (GLEW_OK != err) - LOG_ERROR_AND_THROW("Failed to initialize GLEW"); - - if (m_pSwapChain == nullptr) - { - CreateTestingSwapChainGL(m_pDevice, m_pDeviceContext, SCDesc, &m_pSwapChain); - } - - glGenVertexArrays(1, &m_DummyVAO); -} - -TestingEnvironmentGL::~TestingEnvironmentGL() -{ - glDeleteVertexArrays(1, &m_DummyVAO); -} - -GLuint TestingEnvironmentGL::CompileGLShader(const char* Source, GLenum ShaderType) -{ - GLuint glShader = glCreateShader(ShaderType); - - const char* ShaderStrings[] = {Source}; - GLint Lenghts[] = {static_cast(strlen(Source))}; - - // Provide source strings (the strings will be saved in internal OpenGL memory) - glShaderSource(glShader, _countof(ShaderStrings), ShaderStrings, Lenghts); - // When the shader is compiled, it will be compiled as if all of the given strings were concatenated end-to-end. - glCompileShader(glShader); - GLint compiled = GL_FALSE; - // Get compilation status - glGetShaderiv(glShader, GL_COMPILE_STATUS, &compiled); - if (!compiled) - { - int infoLogLen = 0; - // The function glGetShaderiv() tells how many bytes to allocate; the length includes the NULL terminator. - glGetShaderiv(glShader, GL_INFO_LOG_LENGTH, &infoLogLen); - - std::vector infoLog(infoLogLen); - if (infoLogLen > 0) - { - int charsWritten = 0; - // Get the log. infoLogLen is the size of infoLog. This tells OpenGL how many bytes at maximum it will write - // charsWritten is a return value, specifying how many bytes it actually wrote. One may pass NULL if he - // doesn't care - glGetShaderInfoLog(glShader, infoLogLen, &charsWritten, infoLog.data()); - VERIFY(charsWritten == infoLogLen - 1, "Unexpected info log length"); - LOG_ERROR("Failed to compile GL shader\n", infoLog.data()); - } - } - - return glShader; -} - -GLuint TestingEnvironmentGL::LinkProgram(GLuint Shaders[], GLuint NumShaders) -{ - auto glProg = glCreateProgram(); - - for (Uint32 i = 0; i < NumShaders; ++i) - { - glAttachShader(glProg, Shaders[i]); - VERIFY_EXPR(glGetError() == GL_NO_ERROR); - } - - glLinkProgram(glProg); - int IsLinked = GL_FALSE; - glGetProgramiv(glProg, GL_LINK_STATUS, &IsLinked); - if (!IsLinked) - { - int LengthWithNull = 0, Length = 0; - // Notice that glGetProgramiv is used to get the length for a shader program, not glGetShaderiv. - // The length of the info log includes a null terminator. - glGetProgramiv(glProg, GL_INFO_LOG_LENGTH, &LengthWithNull); - - // The maxLength includes the NULL character - std::vector shaderProgramInfoLog(LengthWithNull); - - // Notice that glGetProgramInfoLog is used, not glGetShaderInfoLog. - glGetProgramInfoLog(glProg, LengthWithNull, &Length, shaderProgramInfoLog.data()); - VERIFY(Length == LengthWithNull - 1, "Incorrect program info log len"); - LOG_ERROR_MESSAGE("Failed to link shader program:\n", shaderProgramInfoLog.data(), '\n'); - } - - for (Uint32 i = 0; i < NumShaders; ++i) - { - glDetachShader(glProg, Shaders[i]); - } - return glProg; -} - -TestingEnvironment* CreateTestingEnvironmentGL(DeviceType deviceType, ADAPTER_TYPE AdapterType, const SwapChainDesc& SCDesc) -{ - try - { - return new TestingEnvironmentGL{deviceType, AdapterType, SCDesc}; - } - catch (...) - { - return nullptr; - } -} - -} // namespace Testing - -} // namespace Diligent diff --git a/UnitTests/DiligentCoreAPITest/src/GL/TestingSwapChainGL.cpp b/UnitTests/DiligentCoreAPITest/src/GL/TestingSwapChainGL.cpp deleted file mode 100644 index ece1572c..00000000 --- a/UnitTests/DiligentCoreAPITest/src/GL/TestingSwapChainGL.cpp +++ /dev/null @@ -1,158 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "GL/TestingEnvironmentGL.h" -#include "GL/TestingSwapChainGL.h" - -namespace Diligent -{ - -namespace Testing -{ - -TestingSwapChainGL::TestingSwapChainGL(IReferenceCounters* pRefCounters, - IRenderDevice* pDevice, - IDeviceContext* pContext, - const SwapChainDesc& SCDesc) : - TBase // - { - pRefCounters, - pDevice, - pContext, - SCDesc // - } -{ - { - glGenTextures(1, &m_RenderTarget); - if (glGetError() != GL_NO_ERROR) - LOG_ERROR_AND_THROW("Failed to create render target texture"); - - GLenum RenderTargetFmt = 0; - switch (m_SwapChainDesc.ColorBufferFormat) - { - case TEX_FORMAT_RGBA8_UNORM: - RenderTargetFmt = GL_RGBA8; - break; - - default: - UNSUPPORTED("Texture format ", GetTextureFormatAttribs(m_SwapChainDesc.ColorBufferFormat).Name, " is not a supported color buffer format"); - } - - glBindTexture(GL_TEXTURE_2D, m_RenderTarget); - // levels format width height - glTexStorage2D(GL_TEXTURE_2D, 1, RenderTargetFmt, m_SwapChainDesc.Width, m_SwapChainDesc.Height); - if (glGetError() != GL_NO_ERROR) - LOG_ERROR_AND_THROW("Failed to allocate render target texture"); - } - - - { - glGenTextures(1, &m_DepthBuffer); - if (glGetError() != GL_NO_ERROR) - LOG_ERROR_AND_THROW("Failed to create depth texture"); - - GLenum DepthBufferFmt = 0; - switch (m_SwapChainDesc.DepthBufferFormat) - { - case TEX_FORMAT_D32_FLOAT: - DepthBufferFmt = GL_DEPTH_COMPONENT32F; - break; - - default: - UNSUPPORTED("Texture format ", GetTextureFormatAttribs(m_SwapChainDesc.DepthBufferFormat).Name, " is not a supported depth buffer format"); - } - - glBindTexture(GL_TEXTURE_2D, m_DepthBuffer); - // levels format width height - glTexStorage2D(GL_TEXTURE_2D, 1, DepthBufferFmt, m_SwapChainDesc.Width, m_SwapChainDesc.Height); - if (glGetError() != GL_NO_ERROR) - LOG_ERROR_AND_THROW("Failed to allocate render target texture"); - } - - { - glGenFramebuffers(1, &m_FBO); - if (glGetError() != GL_NO_ERROR) - LOG_ERROR_AND_THROW("Failed to create FBO"); - - glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_FBO); - glBindFramebuffer(GL_READ_FRAMEBUFFER, m_FBO); - glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_RenderTarget, 0); - glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_RenderTarget, 0); - glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, m_DepthBuffer, 0); - glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, m_DepthBuffer, 0); - static const GLenum DrawBuffers[] = {GL_COLOR_ATTACHMENT0}; - glDrawBuffers(1, DrawBuffers); - GLenum Status = glCheckFramebufferStatus(GL_FRAMEBUFFER); - if (Status != GL_FRAMEBUFFER_COMPLETE) - LOG_ERROR_AND_THROW("FBO is incomplete"); - } - - // Make sure Diligent Engine will reset all GL states - pContext->InvalidateState(); -} - -void TestingSwapChainGL::BindFramebuffer() -{ - glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_FBO); - glBindFramebuffer(GL_READ_FRAMEBUFFER, m_FBO); -} - -TestingSwapChainGL::~TestingSwapChainGL() -{ - if (m_RenderTarget != 0) - glDeleteTextures(1, &m_RenderTarget); - if (m_DepthBuffer != 0) - glDeleteTextures(1, &m_DepthBuffer); - if (m_FBO != 0) - glDeleteFramebuffers(1, &m_FBO); -} - -void TestingSwapChainGL::TakeSnapshot() -{ - m_ReferenceDataPitch = m_SwapChainDesc.Width * 4; - m_ReferenceData.resize(m_SwapChainDesc.Height * m_ReferenceDataPitch); - glBindBuffer(GL_PIXEL_PACK_BUFFER, 0); - glBindFramebuffer(GL_READ_FRAMEBUFFER, m_FBO); - glReadPixels(0, 0, m_SwapChainDesc.Width, m_SwapChainDesc.Height, GL_RGBA, GL_UNSIGNED_BYTE, m_ReferenceData.data()); - VERIFY(glGetError() == GL_NO_ERROR, "Failed to read pixels from the framebuffer"); -} - -void CreateTestingSwapChainGL(IRenderDevice* pDevice, - IDeviceContext* pContext, - const SwapChainDesc& SCDesc, - ISwapChain** ppSwapChain) -{ - try - { - TestingSwapChainGL* pTestingSC(MakeNewRCObj()(pDevice, pContext, SCDesc)); - pTestingSC->QueryInterface(IID_SwapChain, reinterpret_cast(ppSwapChain)); - } - catch (...) - { - *ppSwapChain = nullptr; - } -} - -} // namespace Testing - -} // namespace Diligent diff --git a/UnitTests/DiligentCoreAPITest/src/GenerateMipsTest.cpp b/UnitTests/DiligentCoreAPITest/src/GenerateMipsTest.cpp deleted file mode 100644 index 5e3acc50..00000000 --- a/UnitTests/DiligentCoreAPITest/src/GenerateMipsTest.cpp +++ /dev/null @@ -1,129 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "TestingEnvironment.h" - -#include "gtest/gtest.h" - -using namespace Diligent; -using namespace Diligent::Testing; - -namespace -{ - -TEST(GenerateMipsTest, GenerateMips) -{ - TestingEnvironment::ScopedReleaseResources AutoResetEnvironment; - - auto* pEnv = TestingEnvironment::GetInstance(); - auto* pDevice = pEnv->GetDevice(); - auto* pContext = pEnv->GetDeviceContext(); - - TEXTURE_FORMAT TestFormats[] = // - { - TEX_FORMAT_RGBA8_UNORM, - TEX_FORMAT_RGBA8_UNORM_SRGB, - TEX_FORMAT_RGBA32_FLOAT // - }; - - for (auto f = 0; f < _countof(TestFormats); ++f) - { - TextureDesc TexDesc; - TexDesc.Name = "Mips generation test texture"; - TexDesc.Type = RESOURCE_DIM_TEX_2D; - TexDesc.Format = TestFormats[f]; - TexDesc.Width = 128 + 6; - TexDesc.Height = 128 + 5; - TexDesc.BindFlags = BIND_SHADER_RESOURCE; - TexDesc.MipLevels = 6; - TexDesc.Usage = USAGE_DEFAULT; - TexDesc.MiscFlags = MISC_TEXTURE_FLAG_GENERATE_MIPS; - - std::vector ZeroData(TexDesc.Width * TexDesc.Height * 16); - - { - RefCntAutoPtr pTex; - std::vector SubresData(TexDesc.MipLevels); - for (auto& MipLevelData : SubresData) - { - MipLevelData.pData = ZeroData.data(); - MipLevelData.Stride = TexDesc.Width * 16; - } - TextureData InitData{SubresData.data(), TexDesc.MipLevels}; - - pDevice->CreateTexture(TexDesc, &InitData, &pTex); - ASSERT_NE(pTex, nullptr) << "Failed to create texture: " << TexDesc; - - pContext->GenerateMips(pTex->GetDefaultView(TEXTURE_VIEW_SHADER_RESOURCE)); - - TextureViewDesc ViewDesc(TEXTURE_VIEW_SHADER_RESOURCE, RESOURCE_DIM_TEX_2D_ARRAY); - ViewDesc.MostDetailedMip = 1; - ViewDesc.NumMipLevels = 3; - ViewDesc.Flags = TEXTURE_VIEW_FLAG_ALLOW_MIP_MAP_GENERATION; - RefCntAutoPtr pTexView; - pTex->CreateView(ViewDesc, &pTexView); - ASSERT_NE(pTexView, nullptr) << "Failed to create SRV for texture: " << TexDesc; - pContext->GenerateMips(pTexView); - } - - TexDesc.Name = "Mips generation test texture array"; - TexDesc.Type = RESOURCE_DIM_TEX_2D_ARRAY; - TexDesc.ArraySize = 16; - { - std::vector SubresData(TexDesc.MipLevels * TexDesc.ArraySize); - for (auto& MipLevelData : SubresData) - { - MipLevelData.pData = ZeroData.data(); - MipLevelData.Stride = TexDesc.Width * 16; - } - TextureData InitData{SubresData.data(), TexDesc.MipLevels * TexDesc.ArraySize}; - - RefCntAutoPtr pTex; - pDevice->CreateTexture(TexDesc, &InitData, &pTex); - ASSERT_NE(pTex, nullptr) << "Failed to create texture array: " << TexDesc; - - TextureViewDesc ViewDesc(TEXTURE_VIEW_SHADER_RESOURCE, RESOURCE_DIM_TEX_2D_ARRAY); - ViewDesc.FirstArraySlice = 2; - ViewDesc.NumArraySlices = 5; - ViewDesc.MostDetailedMip = 1; - ViewDesc.NumMipLevels = 5; - if (pDevice->GetDeviceCaps().DevType == DeviceType::D3D11) - { - // The appears to be a bug in D3D11 Warp: the warp crashes if - // the view addresses only a subset of mip levels - ViewDesc.MostDetailedMip = 0; - ViewDesc.NumMipLevels = TexDesc.MipLevels; - } - - ViewDesc.Flags = TEXTURE_VIEW_FLAG_ALLOW_MIP_MAP_GENERATION; - RefCntAutoPtr pTexView; - pTex->CreateView(ViewDesc, &pTexView); - ASSERT_NE(pTexView, nullptr) << "Failed to create SRV for texture array: " << TexDesc; - pContext->GenerateMips(pTexView); - - pContext->GenerateMips(pTex->GetDefaultView(TEXTURE_VIEW_SHADER_RESOURCE)); - } - } -} - -} // namespace diff --git a/UnitTests/DiligentCoreAPITest/src/HLSL2GLSLConverterTest.cpp b/UnitTests/DiligentCoreAPITest/src/HLSL2GLSLConverterTest.cpp deleted file mode 100644 index 50358d06..00000000 --- a/UnitTests/DiligentCoreAPITest/src/HLSL2GLSLConverterTest.cpp +++ /dev/null @@ -1,131 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "TestingEnvironment.h" -#include "HLSL2GLSLConverter.h" - -#include "gtest/gtest.h" - -using namespace Diligent; -using namespace Diligent::Testing; - -namespace -{ - -RefCntAutoPtr CreateTestShader(const char* FileName, - const char* EntryPoint, - SHADER_TYPE ShaderType, - IHLSL2GLSLConversionStream** ppConversionStream = nullptr) -{ - auto* pEnv = TestingEnvironment::GetInstance(); - auto* pDevice = pEnv->GetDevice(); - - ShaderCreateInfo ShaderCI; - - RefCntAutoPtr pShaderSourceFactory; - pDevice->GetEngineFactory()->CreateDefaultShaderSourceStreamFactory("shaders/HLSL2GLSLConverter", &pShaderSourceFactory); - - ShaderCI.FilePath = FileName; - ShaderCI.EntryPoint = EntryPoint; - ShaderCI.pShaderSourceStreamFactory = pShaderSourceFactory; - ShaderCI.SourceLanguage = SHADER_SOURCE_LANGUAGE_HLSL; - ShaderCI.Desc.Name = "Test converted shader"; - ShaderCI.Desc.ShaderType = ShaderType; - ShaderCI.UseCombinedTextureSamplers = pDevice->GetDeviceCaps().IsGLDevice(); - ShaderCI.ppConversionStream = ppConversionStream; - - RefCntAutoPtr pShader; - pDevice->CreateShader(ShaderCI, &pShader); - - return pShader; -} - -TEST(HLSL2GLSLConverterTest, VS_PS) -{ - TestingEnvironment::ScopedReset EnvironmentAutoReset; - - RefCntAutoPtr pStream; - - auto pVS = CreateTestShader("VS_PS.hlsl", "TestVS", SHADER_TYPE_VERTEX, &pStream); - EXPECT_NE(pVS, nullptr); - auto pPS = CreateTestShader("VS_PS.hlsl", "TestPS", SHADER_TYPE_PIXEL, &pStream); - EXPECT_NE(pPS, nullptr); -} - -TEST(HLSL2GLSLConverterTest, CS_RWTex1D) -{ - TestingEnvironment::ScopedReset EnvironmentAutoReset; - - auto* pEnv = TestingEnvironment::GetInstance(); - if (!pEnv->GetDevice()->GetDeviceCaps().bComputeShadersSupported) - { - GTEST_SKIP() << "This device does not support compute shaders"; - } - - auto pCS = CreateTestShader("CS_RWTex1D.hlsl", "TestCS", SHADER_TYPE_COMPUTE); - EXPECT_NE(pCS, nullptr); -} - -TEST(HLSL2GLSLConverterTest, CS_RWTex2D_1) -{ - TestingEnvironment::ScopedReset EnvironmentAutoReset; - - auto* pEnv = TestingEnvironment::GetInstance(); - if (!pEnv->GetDevice()->GetDeviceCaps().bComputeShadersSupported) - { - GTEST_SKIP() << "This device does not support compute shaders"; - } - - auto pCS = CreateTestShader("CS_RWTex2D_1.hlsl", "TestCS", SHADER_TYPE_COMPUTE); - EXPECT_NE(pCS, nullptr); -} - -TEST(HLSL2GLSLConverterTest, CS_RWTex2D_2) -{ - TestingEnvironment::ScopedReset EnvironmentAutoReset; - - auto* pEnv = TestingEnvironment::GetInstance(); - if (!pEnv->GetDevice()->GetDeviceCaps().bComputeShadersSupported) - { - GTEST_SKIP() << "This device does not support compute shaders"; - } - - auto pCS = CreateTestShader("CS_RWTex2D_2.hlsl", "TestCS", SHADER_TYPE_COMPUTE); - EXPECT_NE(pCS, nullptr); -} - -TEST(HLSL2GLSLConverterTest, CS_RWBuff) -{ - TestingEnvironment::ScopedReset EnvironmentAutoReset; - - auto* pEnv = TestingEnvironment::GetInstance(); - if (!pEnv->GetDevice()->GetDeviceCaps().bComputeShadersSupported) - { - GTEST_SKIP() << "This device does not support compute shaders"; - } - - auto pCS = CreateTestShader("CS_RWBuff.hlsl", "TestCS", SHADER_TYPE_COMPUTE); - EXPECT_NE(pCS, nullptr); -} - -} // namespace diff --git a/UnitTests/DiligentCoreAPITest/src/MTResourceCreationTest.cpp b/UnitTests/DiligentCoreAPITest/src/MTResourceCreationTest.cpp deleted file mode 100644 index 1a7e4e5f..00000000 --- a/UnitTests/DiligentCoreAPITest/src/MTResourceCreationTest.cpp +++ /dev/null @@ -1,311 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include -#include -#include - -#include "TestingEnvironment.h" -#include "ThreadSignal.h" -#if D3D12_SUPPORTED -# include "D3D12/D3D12DebugLayerSetNameBugWorkaround.h" -#endif - -#include "gtest/gtest.h" - -using namespace Diligent; -using namespace Diligent::Testing; - -namespace -{ - -static const char g_ShaderSource[] = R"( -void VSMain(out float4 pos : SV_POSITION) -{ - pos = float4(0.0, 0.0, 0.0, 0.0); -} - -void PSMain(out float4 col : SV_TARGET) -{ - col = float4(0.0, 0.0, 0.0, 0.0); -} -)"; - - -class MultithreadedResourceCreationTest : public ::testing::Test -{ -protected: - ~MultithreadedResourceCreationTest(); - - static void WorkerThreadFunc(MultithreadedResourceCreationTest* This, size_t ThreadNum); - - void StartWorkerThreadsAndWait(int SignalIdx); - void WaitSiblingWorkerThreads(int SignalIdx); - - std::vector m_Threads; - - ThreadingTools::Signal m_WorkerThreadSignal[2]; - ThreadingTools::Signal m_MainThreadSignal; - - std::mutex m_NumThreadsCompletedMtx; - std::atomic_int m_NumThreadsCompleted[2]; - std::atomic_int m_NumThreadsReady; - - static const int NumBuffersToCreate = 10; - static const int NumTexturesToCreate = 5; - static const int NumPSOToCreate = 3; - -#ifdef _DEBUG - static const int NumIterations = 10; -#else - static const int NumIterations = 30; -#endif -}; - -MultithreadedResourceCreationTest::~MultithreadedResourceCreationTest() -{ - LOG_INFO_MESSAGE("Created ", NumBuffersToCreate, " buffers, ", NumTexturesToCreate, " textures, and ", - NumPSOToCreate, " PSO in ", NumIterations, " iterations by each of ", m_Threads.size(), " threads"); -} - -void MultithreadedResourceCreationTest::WaitSiblingWorkerThreads(int SignalIdx) -{ - auto NumThreads = static_cast(m_Threads.size()); - if (++m_NumThreadsCompleted[SignalIdx] == NumThreads) - { - ASSERT_FALSE(m_WorkerThreadSignal[1 - SignalIdx].IsTriggered()); - m_MainThreadSignal.Trigger(); - } - else - { - while (m_NumThreadsCompleted[SignalIdx] < NumThreads) - std::this_thread::yield(); - } -} - -void MultithreadedResourceCreationTest::StartWorkerThreadsAndWait(int SignalIdx) -{ - m_NumThreadsCompleted[SignalIdx] = 0; - m_WorkerThreadSignal[SignalIdx].Trigger(true); - - m_MainThreadSignal.Wait(true, 1); -} - -void MultithreadedResourceCreationTest::WorkerThreadFunc(MultithreadedResourceCreationTest* This, size_t ThreadNum) -{ - auto* pEnv = TestingEnvironment::GetInstance(); - auto* pDevice = pEnv->GetDevice(); - - const int NumThreads = static_cast(This->m_Threads.size()); - - constexpr Uint32 TexWidth = 512; - constexpr Uint32 TexHeight = 512; - - std::vector RawBufferData(1024); - std::vector RawTextureData(TexWidth * TexHeight * 4); - - int SignalIdx = 0; - while (true) - { - auto SignaledValue = This->m_WorkerThreadSignal[SignalIdx].Wait(true, NumThreads); - if (SignaledValue < 0) - { - return; - } - - for (Uint32 i = 0; i < NumBuffersToCreate; ++i) - { - BufferDesc BuffDesc; - BuffDesc.Usage = USAGE_DEFAULT; - BuffDesc.BindFlags = BIND_UNIFORM_BUFFER; - BuffDesc.Name = "MT creation test buffer"; - BuffDesc.uiSizeInBytes = static_cast(RawBufferData.size()); - - BufferData BuffData; - BuffData.DataSize = BuffDesc.uiSizeInBytes; - BuffData.pData = RawBufferData.data(); - - RefCntAutoPtr pBuffer1; - pDevice->CreateBuffer(BuffDesc, &BuffData, &pBuffer1); - EXPECT_NE(pBuffer1, nullptr) << "Failed to create the following buffer:\n" - << BuffDesc; - - BuffDesc.Mode = BUFFER_MODE_FORMATTED; - BuffDesc.ElementByteStride = 16; - BuffDesc.BindFlags = BIND_SHADER_RESOURCE | BIND_UNORDERED_ACCESS; - RefCntAutoPtr pBuffer2; - pDevice->CreateBuffer(BuffDesc, &BuffData, &pBuffer2); - EXPECT_NE(pBuffer2, nullptr) << "Failed to create the following buffer:\n" - << BuffDesc; - - BufferViewDesc ViewDesc; - ViewDesc.ViewType = BUFFER_VIEW_SHADER_RESOURCE; - ViewDesc.ByteOffset = 16; - ViewDesc.Format.NumComponents = 4; - ViewDesc.Format.IsNormalized = False; - ViewDesc.Format.ValueType = VT_FLOAT32; - RefCntAutoPtr pBufferSRV; - if (pBuffer2) - { - pBuffer2->CreateView(ViewDesc, &pBufferSRV); - EXPECT_NE(pBufferSRV, nullptr) << "Failed to create SRV for the following buffer:\n" - << BuffDesc; - } - - BuffDesc.BindFlags = BIND_VERTEX_BUFFER | BIND_UNORDERED_ACCESS; - RefCntAutoPtr pBuffer3; - pDevice->CreateBuffer(BuffDesc, &BuffData, &pBuffer3); - EXPECT_NE(pBuffer3, nullptr) << "Failed to create the following buffer:\n" - << BuffDesc; - ViewDesc.ViewType = BUFFER_VIEW_UNORDERED_ACCESS; - RefCntAutoPtr pBufferUAV; - if (pBuffer3) - { - pBuffer3->CreateView(ViewDesc, &pBufferUAV); - EXPECT_NE(pBufferUAV, nullptr) << "Failed to create UAV for the following buffer:\n" - << BuffDesc; - } - - BuffDesc.Mode = BUFFER_MODE_RAW; - BuffDesc.BindFlags = BIND_INDEX_BUFFER | BIND_UNORDERED_ACCESS; - RefCntAutoPtr pBuffer4; - pDevice->CreateBuffer(BuffDesc, &BuffData, &pBuffer4); - EXPECT_NE(pBuffer4, nullptr) << "Failed to create the following buffer:\n" - << BuffDesc; - } - - for (Uint32 i = 0; i < NumTexturesToCreate; ++i) - { - RefCntAutoPtr pTexture; - - TextureDesc TexDesc; - TexDesc.BindFlags = BIND_SHADER_RESOURCE | BIND_RENDER_TARGET | BIND_UNORDERED_ACCESS; - TexDesc.Type = RESOURCE_DIM_TEX_2D; - TexDesc.Width = TexWidth; - TexDesc.Height = TexHeight; - TexDesc.Format = TEX_FORMAT_RGBA8_UNORM; - TexDesc.MipLevels = 1; - - - TextureSubResData SubResData; - SubResData.pData = RawTextureData.data(); - SubResData.Stride = TexDesc.Width * 4; - - TextureData TexData; - TexData.NumSubresources = 1; - TexData.pSubResources = &SubResData; - - pDevice->CreateTexture(TexDesc, &TexData, &pTexture); - EXPECT_NE(pTexture, nullptr) << "Failed to create the following texture:\n" - << TexDesc; - } - - for (Uint32 i = 0; i < NumPSOToCreate; ++i) - { - RefCntAutoPtr pTrivialVS, pTrivialPS; - RefCntAutoPtr pPSO; - { - ShaderCreateInfo Attrs; - Attrs.Source = g_ShaderSource; - Attrs.EntryPoint = "VSMain"; - Attrs.Desc.ShaderType = SHADER_TYPE_VERTEX; - Attrs.Desc.Name = "TrivialVS (MTResourceCreationTest)"; - Attrs.SourceLanguage = SHADER_SOURCE_LANGUAGE_HLSL; - Attrs.UseCombinedTextureSamplers = true; - pDevice->CreateShader(Attrs, &pTrivialVS); - if (!pTrivialVS) - { - ADD_FAILURE() << "Failed to create trivial VS"; - continue; - } - - Attrs.EntryPoint = "PSMain"; - Attrs.Desc.ShaderType = SHADER_TYPE_PIXEL; - Attrs.Desc.Name = "TrivialPS (MTResourceCreationTest)"; - pDevice->CreateShader(Attrs, &pTrivialPS); - if (!pTrivialPS) - { - ADD_FAILURE() << "Failed to create trivial PS"; - continue; - } - - PipelineStateDesc PSODesc; - PSODesc.GraphicsPipeline.pVS = pTrivialVS; - PSODesc.GraphicsPipeline.pPS = pTrivialPS; - PSODesc.GraphicsPipeline.PrimitiveTopology = PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; - PSODesc.GraphicsPipeline.NumRenderTargets = 1; - PSODesc.GraphicsPipeline.RTVFormats[0] = TEX_FORMAT_RGBA8_UNORM; - PSODesc.GraphicsPipeline.DSVFormat = TEX_FORMAT_D32_FLOAT; - - pDevice->CreatePipelineState(PSODesc, &pPSO); - EXPECT_NE(pPSO, nullptr) << "Failed to create test PSO"; - } - } - - This->WaitSiblingWorkerThreads(SignalIdx); - SignalIdx = 1 - SignalIdx; - } -} - - -TEST_F(MultithreadedResourceCreationTest, CreateResources) -{ - auto* pEnv = TestingEnvironment::GetInstance(); - auto* pDevice = pEnv->GetDevice(); - if (pDevice->GetDeviceCaps().IsGLDevice()) - { - GTEST_SKIP() << "Multithreading resource creation is not supported in OpenGL"; - } - -#if D3D12_SUPPORTED - // There is a bug in D3D12 debug layer as of build version 10.0.18362: SetName() method - // is not protected by a mutex internally. This, in combination with the fact that root signatures are - // de-duplicated by D3D12 runtime results in a race condition when SetName is called and causes random crashes. - - // As a workaround, we create the root signature ahead of time and reserve enough space for the name - // to avoid memory allocation. - - D3D12DebugLayerSetNameBugWorkaround D3D12DebugLayerBugWorkaround(pDevice); -#endif - - TestingEnvironment::ScopedReleaseResources AutoResetEnvironment; - - auto numCores = std::thread::hardware_concurrency(); - m_Threads.resize(std::max(numCores, 4u)); - for (auto& t : m_Threads) - t = std::thread(WorkerThreadFunc, this, &t - m_Threads.data()); - - int SignalIdx = 0; - for (Uint32 iter = 0; iter < NumIterations; ++iter) - { - StartWorkerThreadsAndWait(SignalIdx); - pEnv->ReleaseResources(); - SignalIdx = 1 - SignalIdx; - } - - m_WorkerThreadSignal[SignalIdx].Trigger(true, -1); - for (auto& t : m_Threads) - t.join(); -} - -} // namespace diff --git a/UnitTests/DiligentCoreAPITest/src/PSOCompatibilityTest.cpp b/UnitTests/DiligentCoreAPITest/src/PSOCompatibilityTest.cpp deleted file mode 100644 index 8e8f261d..00000000 --- a/UnitTests/DiligentCoreAPITest/src/PSOCompatibilityTest.cpp +++ /dev/null @@ -1,325 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "TestingEnvironment.h" - -#include "gtest/gtest.h" - -using namespace Diligent; -using namespace Diligent::Testing; - -namespace -{ - -static const char* VS0 = R"( -float4 main() : SV_Position -{ - return float4(0.0, 0.0, 0.0, 0.0); -} -)"; - -static const char* PS0 = R"( -float4 main() : SV_Target -{ - return float4(0.0, 0.0, 0.0, 0.0); -} -)"; - -static const char* PS_Tex = R"( -Texture2D g_tex2D; -SamplerState g_tex2D_sampler; -float4 main() : SV_Target -{ - return g_tex2D.Sample(g_tex2D_sampler, float2(0.0, 0.0)); -} -)"; - -static const char* PS_Tex2 = R"( -Texture2D g_tex2D2; -SamplerState g_tex2D2_sampler; -float4 main() : SV_Target -{ - return g_tex2D2.Sample(g_tex2D2_sampler, float2(0.0, 0.0)); -} -)"; - -static const char* PS_ArrOfTex = R"( -Texture2D g_tex2D[2]; -SamplerState g_tex2D_sampler; -float4 main() : SV_Target -{ - return g_tex2D[0].Sample(g_tex2D_sampler, float2(0.0, 0.0)) + g_tex2D[1].Sample(g_tex2D_sampler, float2(0.0, 0.0)); -} -)"; - -static const char* PS_TexArr = R"( -Texture2DArray g_tex2D; -SamplerState g_tex2D_sampler; -float4 main() : SV_Target -{ - return g_tex2D.Sample(g_tex2D_sampler, float3(0.0, 0.0, 0.0)); -} -)"; - - -static const char* PS_CB = R"( -cbuffer Test -{ - float4 g_Test; -}; - -float4 main() : SV_Target -{ - return g_Test; -} -)"; - -static const char* PS1_CB = R"( -cbuffer Test -{ - float4 g_Test; - float4 g_Test2; -}; - -float4 main() : SV_Target -{ - return g_Test + g_Test2; -} -)"; - -static const char* PS_2CB = R"( -cbuffer Test -{ - float4 g_Test; -}; - -cbuffer Test2 -{ - float4 g_Test2; -}; - -float4 main() : SV_Target -{ - return g_Test + g_Test2; -} -)"; - -static const char* PS_TexCB = R"( -cbuffer Test -{ - float4 g_Test; -}; - -cbuffer Test2 -{ - float4 g_Test2; -}; - -Texture2D g_tex2D; -SamplerState g_tex2D_sampler; -float4 main() : SV_Target -{ - return g_Test + g_Test2 + g_tex2D.Sample(g_tex2D_sampler, float2(0.0, 0.0)); -} -)"; - -static const char* PS_TexCB2 = R"( -cbuffer TestA -{ - float4 g_Test; -}; - -cbuffer Test2A -{ - float4 g_Test2; -}; - -Texture2D g_tex2DA; -SamplerState g_tex2DA_sampler; -float4 main() : SV_Target -{ - return g_Test + g_Test2 + g_tex2DA.Sample(g_tex2DA_sampler, float2(0.0, 0.0)); -} -)"; - -static const char* CS_RwBuff = R"( -RWTexture2D g_RWTex; - -[numthreads(1,1,1)] -void main() -{ - g_RWTex[int2(0,0)] = 0.0; -} -)"; - -static const char* CS_RwBuff2 = R"( -RWTexture2D g_RWTex2; - -[numthreads(1,1,1)] -void main() -{ - g_RWTex2[int2(0,0)] = 0.0; -} -)"; - -static const char* CS_RwBuff3 = R"( -RWTexture2D g_RWTex; -RWTexture2D g_RWTex2; - -[numthreads(1,1,1)] -void main() -{ - g_RWTex[int2(0,0)] = 0.0; - g_RWTex2[int2(0,0)] = 0.0; -} -)"; - - -RefCntAutoPtr CreateGraphicsPSO(IRenderDevice* pDevice, const char* VSSource, const char* PSSource) -{ - PipelineStateDesc PSODesc; - PSODesc.IsComputePipeline = false; - PSODesc.GraphicsPipeline.NumRenderTargets = 1; - PSODesc.GraphicsPipeline.RTVFormats[0] = TEX_FORMAT_RGBA8_UNORM_SRGB; - PSODesc.GraphicsPipeline.DepthStencilDesc.DepthEnable = False; - - ShaderCreateInfo CreationAttrs; - CreationAttrs.SourceLanguage = SHADER_SOURCE_LANGUAGE_HLSL; - CreationAttrs.UseCombinedTextureSamplers = true; - RefCntAutoPtr pVS; - { - CreationAttrs.Desc.ShaderType = SHADER_TYPE_VERTEX; - CreationAttrs.EntryPoint = "main"; - CreationAttrs.Desc.Name = "PSO Compatibility test VS"; - CreationAttrs.Source = VSSource; - pDevice->CreateShader(CreationAttrs, &pVS); - VERIFY_EXPR(pVS != nullptr); - } - - RefCntAutoPtr pPS; - { - CreationAttrs.Desc.ShaderType = SHADER_TYPE_PIXEL; - CreationAttrs.EntryPoint = "main"; - CreationAttrs.Desc.Name = "PSO Compatibility test PS"; - CreationAttrs.Source = PSSource; - pDevice->CreateShader(CreationAttrs, &pPS); - VERIFY_EXPR(pPS != nullptr); - } - - PSODesc.GraphicsPipeline.pVS = pVS; - PSODesc.GraphicsPipeline.pPS = pPS; - - RefCntAutoPtr pPSO; - pDevice->CreatePipelineState(PSODesc, &pPSO); - VERIFY_EXPR(pPSO != nullptr); - - return pPSO; -} - -RefCntAutoPtr CreateComputePSO(IRenderDevice* pDevice, const char* CSSource) -{ - PipelineStateDesc PSODesc; - PSODesc.IsComputePipeline = true; - ShaderCreateInfo CreationAttrs; - CreationAttrs.SourceLanguage = SHADER_SOURCE_LANGUAGE_HLSL; - CreationAttrs.UseCombinedTextureSamplers = true; - RefCntAutoPtr pCS; - { - CreationAttrs.Desc.ShaderType = SHADER_TYPE_COMPUTE; - CreationAttrs.EntryPoint = "main"; - CreationAttrs.Desc.Name = "PSO Compatibility test CS"; - CreationAttrs.Source = CSSource; - pDevice->CreateShader(CreationAttrs, &pCS); - VERIFY_EXPR(pCS != nullptr); - } - PSODesc.ComputePipeline.pCS = pCS; - - RefCntAutoPtr pPSO; - pDevice->CreatePipelineState(PSODesc, &pPSO); - VERIFY_EXPR(pPSO != nullptr); - - return pPSO; -} - -TEST(PSOCompatibility, CompilationFailure) -{ - auto* pEnv = TestingEnvironment::GetInstance(); - auto* pDevice = pEnv->GetDevice(); - - TestingEnvironment::ScopedReset EnvironmentAutoReset; - - auto DevType = pDevice->GetDeviceCaps().DevType; - auto PSO0 = CreateGraphicsPSO(pDevice, VS0, PS0); - ASSERT_TRUE(PSO0); - EXPECT_TRUE(PSO0->IsCompatibleWith(PSO0)); - auto PSO0_1 = CreateGraphicsPSO(pDevice, VS0, PS0); - ASSERT_TRUE(PSO0_1); - EXPECT_TRUE(PSO0->IsCompatibleWith(PSO0_1)); - EXPECT_TRUE(PSO0_1->IsCompatibleWith(PSO0)); - - auto PSO_Tex = CreateGraphicsPSO(pDevice, VS0, PS_Tex); - auto PSO_Tex2 = CreateGraphicsPSO(pDevice, VS0, PS_Tex2); - auto PSO_TexArr = CreateGraphicsPSO(pDevice, VS0, PS_TexArr); - auto PSO_ArrOfTex = CreateGraphicsPSO(pDevice, VS0, PS_ArrOfTex); - ASSERT_TRUE(PSO_Tex); - ASSERT_TRUE(PSO_Tex2); - ASSERT_TRUE(PSO_TexArr); - ASSERT_TRUE(PSO_ArrOfTex); - EXPECT_TRUE(PSO_Tex->IsCompatibleWith(PSO_Tex2)); - if (DevType != DeviceType::D3D12 && DevType != DeviceType::Vulkan) - { - EXPECT_FALSE(PSO_Tex->IsCompatibleWith(PSO_TexArr)); - } - VERIFY_EXPR(!PSO_Tex->IsCompatibleWith(PSO_ArrOfTex)); - if (DevType != DeviceType::D3D12 && DevType != DeviceType::Vulkan) - { - EXPECT_FALSE(PSO_Tex2->IsCompatibleWith(PSO_TexArr)); - } - EXPECT_FALSE(PSO_Tex2->IsCompatibleWith(PSO_ArrOfTex)); - EXPECT_FALSE(PSO_TexArr->IsCompatibleWith(PSO_ArrOfTex)); - - auto PSO_CB = CreateGraphicsPSO(pDevice, VS0, PS_CB); - auto PSO1_CB = CreateGraphicsPSO(pDevice, VS0, PS1_CB); - auto PSO_2CB = CreateGraphicsPSO(pDevice, VS0, PS_2CB); - EXPECT_TRUE(PSO_CB->IsCompatibleWith(PSO1_CB)); - EXPECT_FALSE(PSO_CB->IsCompatibleWith(PSO_2CB)); - - auto PSO_TexCB = CreateGraphicsPSO(pDevice, VS0, PS_TexCB); - auto PSO_TexCB2 = CreateGraphicsPSO(pDevice, VS0, PS_TexCB2); - EXPECT_TRUE(PSO_TexCB->IsCompatibleWith(PSO_TexCB2)); - EXPECT_TRUE(PSO_TexCB2->IsCompatibleWith(PSO_TexCB)); - - if (pDevice->GetDeviceCaps().bComputeShadersSupported) - { - auto PSO_RWBuff = CreateComputePSO(pDevice, CS_RwBuff); - auto PSO_RWBuff2 = CreateComputePSO(pDevice, CS_RwBuff2); - auto PSO_RWBuff3 = CreateComputePSO(pDevice, CS_RwBuff3); - EXPECT_TRUE(PSO_RWBuff); - EXPECT_TRUE(PSO_RWBuff2); - EXPECT_TRUE(PSO_RWBuff3); - EXPECT_TRUE(PSO_RWBuff->IsCompatibleWith(PSO_RWBuff2)); - EXPECT_FALSE(PSO_RWBuff->IsCompatibleWith(PSO_RWBuff3)); - } -} - -} // namespace diff --git a/UnitTests/DiligentCoreAPITest/src/PSOTestBase.cpp b/UnitTests/DiligentCoreAPITest/src/PSOTestBase.cpp deleted file mode 100644 index 5b0bc8d0..00000000 --- a/UnitTests/DiligentCoreAPITest/src/PSOTestBase.cpp +++ /dev/null @@ -1,99 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "PSOTestBase.h" -#include "TestingEnvironment.h" - -namespace Diligent -{ - -namespace Testing -{ - -PSOTestBase::Resources PSOTestBase::sm_Resources; - -static const char g_ShaderSource[] = R"( -void VSMain(out float4 pos : SV_POSITION) -{ - pos = float4(0.0, 0.0, 0.0, 0.0); -} - -void PSMain(out float4 col : SV_TARGET) -{ - col = float4(0.0, 0.0, 0.0, 0.0); -} -)"; - -void PSOTestBase::InitResources() -{ - auto* pEnv = TestingEnvironment::GetInstance(); - auto* pDevice = pEnv->GetDevice(); - - ShaderCreateInfo Attrs; - Attrs.Source = g_ShaderSource; - Attrs.EntryPoint = "VSMain"; - Attrs.Desc.ShaderType = SHADER_TYPE_VERTEX; - Attrs.Desc.Name = "TrivialVS (TestPipelineStateBase)"; - Attrs.SourceLanguage = SHADER_SOURCE_LANGUAGE_HLSL; - Attrs.UseCombinedTextureSamplers = true; - pDevice->CreateShader(Attrs, &sm_Resources.pTrivialVS); - - Attrs.EntryPoint = "PSMain"; - Attrs.Desc.ShaderType = SHADER_TYPE_PIXEL; - Attrs.Desc.Name = "TrivialPS (TestPipelineStateBase)"; - pDevice->CreateShader(Attrs, &sm_Resources.pTrivialPS); - - auto& PSODesc = sm_Resources.PSODesc; - - PSODesc.GraphicsPipeline.pVS = sm_Resources.pTrivialVS; - PSODesc.GraphicsPipeline.pPS = sm_Resources.pTrivialPS; - PSODesc.GraphicsPipeline.PrimitiveTopology = PRIMITIVE_TOPOLOGY_TRIANGLE_LIST; - PSODesc.GraphicsPipeline.NumRenderTargets = 1; - PSODesc.GraphicsPipeline.RTVFormats[0] = TEX_FORMAT_RGBA8_UNORM; - PSODesc.GraphicsPipeline.DSVFormat = TEX_FORMAT_D32_FLOAT; -} - -void PSOTestBase::ReleaseResources() -{ - sm_Resources = Resources{}; - TestingEnvironment::GetInstance()->Reset(); -} - -RefCntAutoPtr PSOTestBase::CreateTestPSO(const PipelineStateDesc& PSODesc, bool BindPSO) -{ - auto* pEnv = TestingEnvironment::GetInstance(); - auto* pDevice = pEnv->GetDevice(); - auto* pContext = pEnv->GetDeviceContext(); - - RefCntAutoPtr pPSO; - pDevice->CreatePipelineState(PSODesc, &pPSO); - if (BindPSO && pPSO) - { - pContext->SetPipelineState(pPSO); - } - return pPSO; -} - -} // namespace Testing - -} // namespace Diligent diff --git a/UnitTests/DiligentCoreAPITest/src/RasterizerStateTest.cpp b/UnitTests/DiligentCoreAPITest/src/RasterizerStateTest.cpp deleted file mode 100644 index aea21319..00000000 --- a/UnitTests/DiligentCoreAPITest/src/RasterizerStateTest.cpp +++ /dev/null @@ -1,109 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "TestingEnvironment.h" -#include "PSOTestBase.h" -#include "GraphicsAccessories.h" - -#include "gtest/gtest.h" - -using namespace Diligent; -using namespace Diligent::Testing; - -namespace -{ - -class RasterizerStateTest : public PSOTestBase, public ::testing::Test -{ -protected: - static void SetUpTestSuite() - { - InitResources(); - } - - static void TearDownTestSuite() - { - ReleaseResources(); - TestingEnvironment::GetInstance()->ReleaseResources(); - } -}; - -TEST_F(RasterizerStateTest, CreatePSO) -{ - auto PSODesc = GetPSODesc(); - - RasterizerStateDesc& RSDesc = PSODesc.GraphicsPipeline.RasterizerDesc; - - ASSERT_TRUE(CreateTestPSO(PSODesc, true)); - - for (auto FillMode = FILL_MODE_UNDEFINED + 1; FillMode < FILL_MODE_NUM_MODES; ++FillMode) - { - RSDesc.FillMode = static_cast(FillMode); - auto pPSO = CreateTestPSO(PSODesc, true); - ASSERT_TRUE(pPSO) << "Fill mode: " << GetFillModeLiteralName(RSDesc.FillMode); - EXPECT_EQ(pPSO->GetDesc().GraphicsPipeline.RasterizerDesc.FillMode, RSDesc.FillMode); - } - - for (auto CullMode = CULL_MODE_UNDEFINED + 1; CullMode < CULL_MODE_NUM_MODES; ++CullMode) - { - RSDesc.CullMode = static_cast(CullMode); - auto pPSO = CreateTestPSO(PSODesc, true); - ASSERT_TRUE(pPSO) << "Cull mode: " << GetCullModeLiteralName(RSDesc.CullMode); - EXPECT_EQ(pPSO->GetDesc().GraphicsPipeline.RasterizerDesc.CullMode, RSDesc.CullMode); - } - - { - RSDesc.FrontCounterClockwise = !RSDesc.FrontCounterClockwise; - auto pPSO = CreateTestPSO(PSODesc, true); - ASSERT_TRUE(pPSO); - EXPECT_EQ(pPSO->GetDesc().GraphicsPipeline.RasterizerDesc.FrontCounterClockwise, RSDesc.FrontCounterClockwise); - } - - RSDesc.DepthBias = 100; - ASSERT_TRUE(CreateTestPSO(PSODesc, true)); - - RSDesc.DepthBiasClamp = 1.f; - ASSERT_TRUE(CreateTestPSO(PSODesc, true)); - - RSDesc.SlopeScaledDepthBias = 2.f; - ASSERT_TRUE(CreateTestPSO(PSODesc, true)); - - { - RSDesc.DepthClipEnable = !RSDesc.DepthClipEnable; - auto pPSO = CreateTestPSO(PSODesc, true); - ASSERT_TRUE(pPSO); - EXPECT_EQ(pPSO->GetDesc().GraphicsPipeline.RasterizerDesc.DepthClipEnable, RSDesc.DepthClipEnable); - } - - { - RSDesc.ScissorEnable = !RSDesc.ScissorEnable; - auto pPSO = CreateTestPSO(PSODesc, true); - ASSERT_TRUE(pPSO); - EXPECT_EQ(pPSO->GetDesc().GraphicsPipeline.RasterizerDesc.ScissorEnable, RSDesc.ScissorEnable); - } - - RSDesc.AntialiasedLineEnable = !RSDesc.AntialiasedLineEnable; - ASSERT_TRUE(CreateTestPSO(PSODesc, true)); -} - -} // namespace diff --git a/UnitTests/DiligentCoreAPITest/src/SamplerCreationTest.cpp b/UnitTests/DiligentCoreAPITest/src/SamplerCreationTest.cpp deleted file mode 100644 index 59450ef1..00000000 --- a/UnitTests/DiligentCoreAPITest/src/SamplerCreationTest.cpp +++ /dev/null @@ -1,218 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include -#include - -#include "TestingEnvironment.h" -#include "Sampler.h" -#include "GraphicsAccessories.h" - -#include "gtest/gtest.h" - -using namespace Diligent; -using namespace Diligent::Testing; - -namespace -{ - -class FilterTypeTest : public testing::TestWithParam> -{ -protected: - static void TearDownTestSuite() - { - TestingEnvironment::GetInstance()->ReleaseResources(); - } -}; - -TEST_P(FilterTypeTest, CreateSampler) -{ - auto* pEnv = TestingEnvironment::GetInstance(); - auto* pDevice = pEnv->GetDevice(); - - SamplerDesc SamplerDesc; - const auto& Param = GetParam(); - SamplerDesc.MinFilter = std::get<0>(Param); - SamplerDesc.MagFilter = std::get<1>(Param); - SamplerDesc.MipFilter = std::get<2>(Param); - RefCntAutoPtr pSampler; - pDevice->CreateSampler(SamplerDesc, &pSampler); - ASSERT_TRUE(pSampler); - EXPECT_EQ(pSampler->GetDesc(), SamplerDesc); -} - -std::string GetSamplerFilterTestName(const testing::TestParamInfo>& info) // -{ - std::string name = - std::string{GetFilterTypeLiteralName(std::get<0>(info.param), false)} + std::string{"__"} + - std::string{GetFilterTypeLiteralName(std::get<1>(info.param), false)} + std::string{"__"} + - std::string{GetFilterTypeLiteralName(std::get<2>(info.param), false)}; - for (size_t i = 0; i < name.length(); ++i) - { - if (!std::isalnum(name[i])) - name[i] = '_'; - } - return name; -} - - -INSTANTIATE_TEST_SUITE_P(RegularFitlers, - FilterTypeTest, - testing::Combine( - testing::Values(FILTER_TYPE_POINT, FILTER_TYPE_LINEAR), - testing::Values(FILTER_TYPE_POINT, FILTER_TYPE_LINEAR), - testing::Values(FILTER_TYPE_POINT, FILTER_TYPE_LINEAR)), - GetSamplerFilterTestName); - -INSTANTIATE_TEST_SUITE_P(ComparisonFilters, - FilterTypeTest, - testing::Combine( - testing::Values(FILTER_TYPE_COMPARISON_POINT, FILTER_TYPE_COMPARISON_LINEAR), - testing::Values(FILTER_TYPE_COMPARISON_POINT, FILTER_TYPE_COMPARISON_LINEAR), - testing::Values(FILTER_TYPE_COMPARISON_POINT, FILTER_TYPE_COMPARISON_LINEAR)), - GetSamplerFilterTestName); - -TEST(FilterTypeTest, AnisotropicFilter) -{ - auto* pEnv = TestingEnvironment::GetInstance(); - auto* pDevice = pEnv->GetDevice(); - - { - SamplerDesc SamplerDesc; - SamplerDesc.MinFilter = FILTER_TYPE_ANISOTROPIC; - SamplerDesc.MagFilter = FILTER_TYPE_ANISOTROPIC; - SamplerDesc.MipFilter = FILTER_TYPE_ANISOTROPIC; - - SamplerDesc.MaxAnisotropy = 4; - RefCntAutoPtr pSampler; - pDevice->CreateSampler(SamplerDesc, &pSampler); - ASSERT_TRUE(pSampler); - ASSERT_TRUE(pSampler); - EXPECT_EQ(pSampler->GetDesc(), SamplerDesc); - } - - { - SamplerDesc SamplerDesc; - SamplerDesc.MinFilter = FILTER_TYPE_COMPARISON_ANISOTROPIC; - SamplerDesc.MagFilter = FILTER_TYPE_COMPARISON_ANISOTROPIC; - SamplerDesc.MipFilter = FILTER_TYPE_COMPARISON_ANISOTROPIC; - - SamplerDesc.MaxAnisotropy = 4; - RefCntAutoPtr pSampler; - pDevice->CreateSampler(SamplerDesc, &pSampler); - ASSERT_TRUE(pSampler); - ASSERT_TRUE(pSampler); - EXPECT_EQ(pSampler->GetDesc(), SamplerDesc); - } -} - - -class AddressModeTest : public testing::TestWithParam -{ -protected: - static void TearDownTestSuite() - { - TestingEnvironment::GetInstance()->ReleaseResources(); - } -}; - -TEST_P(AddressModeTest, CreateSampler) -{ - auto* pEnv = TestingEnvironment::GetInstance(); - auto* pDevice = pEnv->GetDevice(); - - SamplerDesc SamplerDesc; - SamplerDesc.MinFilter = FILTER_TYPE_LINEAR; - SamplerDesc.MagFilter = FILTER_TYPE_LINEAR; - SamplerDesc.MipFilter = FILTER_TYPE_LINEAR; - SamplerDesc.AddressU = SamplerDesc.AddressV = SamplerDesc.AddressW = GetParam(); - RefCntAutoPtr pSampler; - pDevice->CreateSampler(SamplerDesc, &pSampler); - ASSERT_TRUE(pSampler); - EXPECT_EQ(pSampler->GetDesc(), SamplerDesc); - - pEnv->ReleaseResources(); -} - -INSTANTIATE_TEST_SUITE_P(AddressModes, - AddressModeTest, - testing::Values( - TEXTURE_ADDRESS_WRAP, - TEXTURE_ADDRESS_MIRROR, - TEXTURE_ADDRESS_CLAMP, - TEXTURE_ADDRESS_BORDER), - [](const testing::TestParamInfo& info) // - { - return std::string{GetTextureAddressModeLiteralName(info.param, true)}; - } // -); - - -class ComparisonFuncTest : public testing::TestWithParam -{ -protected: - static void TearDownTestSuite() - { - TestingEnvironment::GetInstance()->ReleaseResources(); - } -}; - -TEST_P(ComparisonFuncTest, CreateSampler) -{ - auto* pEnv = TestingEnvironment::GetInstance(); - auto* pDevice = pEnv->GetDevice(); - - SamplerDesc SamplerDesc; - SamplerDesc.MinFilter = FILTER_TYPE_LINEAR; - SamplerDesc.MagFilter = FILTER_TYPE_LINEAR; - SamplerDesc.MipFilter = FILTER_TYPE_LINEAR; - SamplerDesc.ComparisonFunc = GetParam(); - RefCntAutoPtr pSampler1, pSampler2; - SamplerDesc.Name = "Sam1"; - pDevice->CreateSampler(SamplerDesc, &pSampler1); - SamplerDesc.Name = "Sam2"; - pDevice->CreateSampler(SamplerDesc, &pSampler2); - ASSERT_TRUE(pSampler1); - ASSERT_TRUE(pSampler2); - EXPECT_EQ(pSampler1, pSampler2); - EXPECT_EQ(pSampler1->GetDesc(), SamplerDesc); -} - -INSTANTIATE_TEST_SUITE_P(ComparisonFunctions, - ComparisonFuncTest, - testing::Values( - COMPARISON_FUNC_NEVER, - COMPARISON_FUNC_LESS, - COMPARISON_FUNC_EQUAL, - COMPARISON_FUNC_LESS_EQUAL, - COMPARISON_FUNC_GREATER, - COMPARISON_FUNC_NOT_EQUAL, - COMPARISON_FUNC_GREATER_EQUAL, - COMPARISON_FUNC_ALWAYS), - [](const testing::TestParamInfo& info) // - { - return std::string{GetComparisonFunctionLiteralName(info.param, true)}; - } // -); - -} // namespace diff --git a/UnitTests/DiligentCoreAPITest/src/SeparateTextureSamplerTest.cpp b/UnitTests/DiligentCoreAPITest/src/SeparateTextureSamplerTest.cpp deleted file mode 100644 index c842cf02..00000000 --- a/UnitTests/DiligentCoreAPITest/src/SeparateTextureSamplerTest.cpp +++ /dev/null @@ -1,181 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "TestingEnvironment.h" - -#include "gtest/gtest.h" - -using namespace Diligent; -using namespace Diligent::Testing; - -namespace -{ - -static const char g_VSShaderSource[] = R"( -void VSMain(out float4 pos : SV_POSITION) -{ - pos = float4(0.0, 0.0, 0.0, 0.0); -} -)"; - -static const char g_PSShaderSource[] = R"( -Texture2D g_Tex; -SamplerState g_Sam; -Texture2D g_Tex2; -SamplerState g_Sam2; -SamplerState g_Sam3[2]; -SamplerState g_Sam4[2]; - -void PSMain(out float4 col : SV_TARGET) -{ - col = g_Tex.Sample(g_Sam, float2(0.5, 0.5)) + - g_Tex2.Sample(g_Sam2, float2(0.5, 0.5)) + - g_Tex2.Sample(g_Sam3[0], float2(0.5, 0.5)) + - g_Tex2.Sample(g_Sam3[1], float2(0.5, 0.5)) + - g_Tex2.Sample(g_Sam4[0], float2(0.5, 0.5)) + - g_Tex2.Sample(g_Sam4[1], float2(0.5, 0.5)); -} -)"; - -TEST(SeparateTextureSampler, CreateSampler) -{ - auto* pEnv = TestingEnvironment::GetInstance(); - auto* pDevice = pEnv->GetDevice(); - auto* pContext = pEnv->GetDeviceContext(); - - if (pDevice->GetDeviceCaps().IsGLDevice()) - { - GTEST_SKIP() << "Separate texture samplers are not supported in OpenGL"; - } - - TestingEnvironment::ScopedReset EnvironmentAutoReset; - - ShaderCreateInfo Attrs; - Attrs.Source = g_VSShaderSource; - Attrs.EntryPoint = "VSMain"; - Attrs.Desc.ShaderType = SHADER_TYPE_VERTEX; - Attrs.Desc.Name = "VSMain (TestSeparateTextureSampler)"; - Attrs.SourceLanguage = SHADER_SOURCE_LANGUAGE_HLSL; - RefCntAutoPtr pVS; - pDevice->CreateShader(Attrs, &pVS); - ASSERT_TRUE(pVS); - - Attrs.Source = g_PSShaderSource; - Attrs.EntryPoint = "PSMain"; - Attrs.Desc.ShaderType = SHADER_TYPE_PIXEL; - Attrs.Desc.Name = "PSMain (TestSeparateTextureSampler)"; - - RefCntAutoPtr pPS; - pDevice->CreateShader(Attrs, &pPS); - ASSERT_TRUE(pPS); - - PipelineStateDesc PSODesc; - PSODesc.GraphicsPipeline.pVS = pVS; - PSODesc.GraphicsPipeline.pPS = pPS; - PSODesc.GraphicsPipeline.PrimitiveTopology = PRIMITIVE_TOPOLOGY_TRIANGLE_LIST; - PSODesc.GraphicsPipeline.NumRenderTargets = 1; - PSODesc.GraphicsPipeline.RTVFormats[0] = TEX_FORMAT_RGBA8_UNORM; - PSODesc.GraphicsPipeline.DSVFormat = TEX_FORMAT_UNKNOWN; - PSODesc.GraphicsPipeline.DepthStencilDesc.DepthEnable = false; - - ShaderResourceVariableDesc Vars[] = - { - {SHADER_TYPE_PIXEL, "g_Tex", SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE}, - {SHADER_TYPE_PIXEL, "g_Sam", SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC}, - {SHADER_TYPE_PIXEL, "g_Tex2", SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC}, - {SHADER_TYPE_PIXEL, "g_Sam2", SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE}, - {SHADER_TYPE_PIXEL, "g_Sam4", SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE} // - }; - PSODesc.ResourceLayout.Variables = Vars; - PSODesc.ResourceLayout.NumVariables = _countof(Vars); - - StaticSamplerDesc StaticSamplers[] = - { - {SHADER_TYPE_PIXEL, "g_Sam2", SamplerDesc{}} // - }; - PSODesc.ResourceLayout.StaticSamplers = StaticSamplers; - PSODesc.ResourceLayout.NumStaticSamplers = _countof(StaticSamplers); - - RefCntAutoPtr pPSO; - pDevice->CreatePipelineState(PSODesc, &pPSO); - ASSERT_TRUE(pPSO); - - TextureDesc TexDesc; - TexDesc.Name = "Separate sampler texture test"; - TexDesc.Type = RESOURCE_DIM_TEX_2D; - TexDesc.Width = 256; - TexDesc.Height = 256; - TexDesc.Format = TEX_FORMAT_RGBA8_UNORM; - TexDesc.Usage = USAGE_DEFAULT; - TexDesc.BindFlags = BIND_SHADER_RESOURCE; - RefCntAutoPtr pTexture; - pDevice->CreateTexture(TexDesc, nullptr, &pTexture); - ASSERT_TRUE(pTexture); - - RefCntAutoPtr pSampler; - pDevice->CreateSampler(SamplerDesc{}, &pSampler); - IDeviceObject* ppSamplers[2] = {pSampler, pSampler}; - pPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, "g_Sam3")->SetArray(ppSamplers, 0, 2); - - RefCntAutoPtr pSRB; - pPSO->CreateShaderResourceBinding(&pSRB, true); - - pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_Tex")->Set(pTexture->GetDefaultView(TEXTURE_VIEW_SHADER_RESOURCE)); - pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_Sam")->Set(pSampler); - pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_Sam4")->SetArray(ppSamplers, 0, 2); - pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_Tex2")->Set(pTexture->GetDefaultView(TEXTURE_VIEW_SHADER_RESOURCE)); - ASSERT_TRUE(pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_Sam2") == nullptr); - - auto VarCount = pSRB->GetVariableCount(SHADER_TYPE_PIXEL); - EXPECT_EQ(VarCount, 4u); - for (Uint32 v = 0; v < VarCount; ++v) - { - auto* pVar = pSRB->GetVariableByIndex(SHADER_TYPE_PIXEL, v); - EXPECT_EQ(pVar->GetIndex(), v); - EXPECT_TRUE(pVar->GetType() == SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE || pVar->GetType() == SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC); - auto pVar2 = pSRB->GetVariableByName(SHADER_TYPE_PIXEL, pVar->GetResourceDesc().Name); - EXPECT_EQ(pVar, pVar2); - } - - TextureDesc RenderTargetDesc; - RenderTargetDesc.Type = RESOURCE_DIM_TEX_2D; - RenderTargetDesc.Width = 256; - RenderTargetDesc.Height = 256; - RenderTargetDesc.BindFlags = BIND_RENDER_TARGET | BIND_SHADER_RESOURCE; - RenderTargetDesc.Format = TEX_FORMAT_RGBA8_UNORM; - RenderTargetDesc.Name = "TestSeparateTextureSampler: test render target"; - RefCntAutoPtr pRenderTarget; - pDevice->CreateTexture(RenderTargetDesc, nullptr, &pRenderTarget); - ASSERT_TRUE(pRenderTarget); - - ITextureView* pRTV[] = {pRenderTarget->GetDefaultView(TEXTURE_VIEW_RENDER_TARGET)}; - pContext->SetRenderTargets(1, pRTV, nullptr, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); - float Zero[4] = {}; - pContext->ClearRenderTarget(pRTV[0], Zero, RESOURCE_STATE_TRANSITION_MODE_VERIFY); - pContext->SetPipelineState(pPSO); - pContext->CommitShaderResources(pSRB, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); - DrawAttribs DrawAttrs(3, DRAW_FLAG_VERIFY_ALL); - pContext->Draw(DrawAttrs); -} - -} // namespace diff --git a/UnitTests/DiligentCoreAPITest/src/ShaderResourceArrayTest.cpp b/UnitTests/DiligentCoreAPITest/src/ShaderResourceArrayTest.cpp deleted file mode 100644 index 515ecbbc..00000000 --- a/UnitTests/DiligentCoreAPITest/src/ShaderResourceArrayTest.cpp +++ /dev/null @@ -1,244 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "TestingEnvironment.h" - -#include "gtest/gtest.h" - -using namespace Diligent; -using namespace Diligent::Testing; - -namespace -{ - -TEST(ShaderResourceLayout, ResourceArray) -{ - auto* pEnv = TestingEnvironment::GetInstance(); - auto* pDevice = pEnv->GetDevice(); - auto* pContext = pEnv->GetDeviceContext(); - - TestingEnvironment::ScopedReset EnvironmentAutoReset; - - RefCntAutoPtr pShaderSourceFactory; - pDevice->GetEngineFactory()->CreateDefaultShaderSourceStreamFactory("shaders", &pShaderSourceFactory); - ShaderCreateInfo ShaderCI; - ShaderCI.pShaderSourceStreamFactory = pShaderSourceFactory; - ShaderCI.UseCombinedTextureSamplers = true; - ShaderCI.HLSLVersion = ShaderCreateInfo::ShaderVersion{5, 0}; - RefCntAutoPtr pVS, pPS; - { - ShaderCI.Desc.Name = "ShaderResourceArrayTest: VS"; - ShaderCI.FilePath = "ShaderResourceArrayTest.vsh"; - ShaderCI.Desc.ShaderType = SHADER_TYPE_VERTEX; - ShaderCI.SourceLanguage = SHADER_SOURCE_LANGUAGE_HLSL; - pDevice->CreateShader(ShaderCI, &pVS); - ASSERT_NE(pVS, nullptr); - } - - { - ShaderCI.Desc.Name = "ShaderResourceArrayTest: PS"; - ShaderCI.FilePath = "ShaderResourceArrayTest.psh"; - ShaderCI.Desc.ShaderType = SHADER_TYPE_PIXEL; - ShaderCI.SourceLanguage = SHADER_SOURCE_LANGUAGE_HLSL; - pDevice->CreateShader(ShaderCI, &pPS); - ASSERT_NE(pPS, nullptr); - } - - - PipelineStateDesc PSODesc; - StaticSamplerDesc StaticSampler; - StaticSampler.Desc.MinFilter = FILTER_TYPE_LINEAR; - StaticSampler.Desc.MagFilter = FILTER_TYPE_LINEAR; - StaticSampler.Desc.MipFilter = FILTER_TYPE_LINEAR; - StaticSampler.ShaderStages = SHADER_TYPE_PIXEL; - StaticSampler.SamplerOrTextureName = "g_tex2DTest"; - PSODesc.ResourceLayout.NumStaticSamplers = 1; - PSODesc.ResourceLayout.StaticSamplers = &StaticSampler; - // clang-format off - ShaderResourceVariableDesc Vars[] = - { - {SHADER_TYPE_PIXEL, "g_tex2DTest", SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE}, - {SHADER_TYPE_PIXEL, "g_tex2DTest2", SHADER_RESOURCE_VARIABLE_TYPE_STATIC}, - {SHADER_TYPE_PIXEL, "g_tex2D", SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC} - }; - // clang-format on - PSODesc.ResourceLayout.Variables = Vars; - PSODesc.ResourceLayout.NumVariables = _countof(Vars); - PSODesc.GraphicsPipeline.DepthStencilDesc.DepthEnable = False; - PSODesc.GraphicsPipeline.RasterizerDesc.CullMode = CULL_MODE_NONE; - PSODesc.GraphicsPipeline.BlendDesc.IndependentBlendEnable = False; - PSODesc.GraphicsPipeline.BlendDesc.RenderTargets[0].BlendEnable = False; - PSODesc.GraphicsPipeline.NumRenderTargets = 1; - - constexpr TEXTURE_FORMAT RTVFormat = TEX_FORMAT_RGBA8_UNORM; - constexpr TEXTURE_FORMAT DSVFormat = TEX_FORMAT_D32_FLOAT; - PSODesc.GraphicsPipeline.RTVFormats[0] = RTVFormat; - PSODesc.GraphicsPipeline.DSVFormat = DSVFormat; - PSODesc.GraphicsPipeline.pVS = pVS; - PSODesc.GraphicsPipeline.pPS = pPS; - - PSODesc.GraphicsPipeline.PrimitiveTopology = PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; - // clang-format off - LayoutElement Elems[] = - { - LayoutElement{ 0, 0, 3, VT_FLOAT32, false, 0 }, - LayoutElement{ 1, 0, 2, VT_FLOAT32, false, sizeof( float ) * 3 } - }; - // clang-format on - PSODesc.GraphicsPipeline.InputLayout.LayoutElements = Elems; - PSODesc.GraphicsPipeline.InputLayout.NumElements = _countof(Elems); - RefCntAutoPtr pPSO; - pDevice->CreatePipelineState(PSODesc, &pPSO); - ASSERT_NE(pPSO, nullptr); - - RefCntAutoPtr pSRB; - pPSO->CreateShaderResourceBinding(&pSRB); - ASSERT_NE(pSRB, nullptr); - - // clang-format off - float Vertices[] = - { - 0, 0, 0, 0,1, - 0, 1, 0, 0,0, - 1, 0, 0, 1,1, - 1, 1, 0, 1,0 - }; - // clang-format on - constexpr float fMinXCoord = 0.4f; - constexpr float fMinYCoord = -0.9f; - constexpr float fXExtent = 0.5f; - constexpr float fYExtent = 0.5f; - for (int v = 0; v < 4; ++v) - { - Vertices[v * 5 + 0] = Vertices[v * 5 + 0] * fXExtent + fMinXCoord; - Vertices[v * 5 + 1] = Vertices[v * 5 + 1] * fYExtent + fMinYCoord; - } - - RefCntAutoPtr pVertexBuff; - { - BufferDesc BuffDesc; - BuffDesc.uiSizeInBytes = sizeof(Vertices); - BuffDesc.BindFlags = BIND_VERTEX_BUFFER; - BuffDesc.Usage = USAGE_STATIC; - BufferData BuffData; - BuffData.pData = Vertices; - BuffData.DataSize = BuffDesc.uiSizeInBytes; - pDevice->CreateBuffer(BuffDesc, &BuffData, &pVertexBuff); - ASSERT_NE(pVertexBuff, nullptr); - } - - RefCntAutoPtr pRTV, pDSV; - { - auto pRenderTarget = pEnv->CreateTexture("ShaderResourceLayout: offscreen render target", TEX_FORMAT_RGBA8_UNORM, BIND_RENDER_TARGET, 256, 256); - ASSERT_NE(pRenderTarget, nullptr); - pRTV = pRenderTarget->GetDefaultView(TEXTURE_VIEW_RENDER_TARGET); - ASSERT_NE(pRTV, nullptr); - - auto pDepth = pEnv->CreateTexture("ShaderResourceLayout: offscreen depth", TEX_FORMAT_D32_FLOAT, BIND_DEPTH_STENCIL, 256, 256); - ASSERT_NE(pDepth, nullptr); - pDSV = pDepth->GetDefaultView(TEXTURE_VIEW_DEPTH_STENCIL); - ASSERT_NE(pDSV, nullptr); - } - - RefCntAutoPtr pSampler; - SamplerDesc SamDesc; - pDevice->CreateSampler(SamDesc, &pSampler); - RefCntAutoPtr pTextures[8]; - for (auto t = 0; t < _countof(pTextures); ++t) - { - TextureDesc TexDesc; - TexDesc.Type = RESOURCE_DIM_TEX_2D; - TexDesc.Width = 256; - TexDesc.Height = 256; - TexDesc.MipLevels = 8; - TexDesc.Usage = USAGE_STATIC; - TexDesc.Format = TEX_FORMAT_RGBA8_UNORM; - TexDesc.BindFlags = BIND_SHADER_RESOURCE; - TexDesc.Name = "Test Texture"; - - std::vector Data(TexDesc.Width * TexDesc.Height * 4, 128); - std::vector SubResouces(TexDesc.MipLevels); - for (Uint32 i = 0; i < TexDesc.MipLevels; ++i) - { - auto& SubResData = SubResouces[i]; - SubResData.pData = Data.data(); - SubResData.Stride = TexDesc.Width * 4; - } - - float ColorOffset[4] = {(float)t * 0.13f, (float)t * 0.21f, (float)t * 0.29f, 0}; - //TestTexturing::GenerateTextureData(pDevice, Data, SubResouces, TexDesc, ColorOffset); - TextureData TexData; - TexData.pSubResources = SubResouces.data(); - TexData.NumSubresources = (Uint32)SubResouces.size(); - - pDevice->CreateTexture(TexDesc, &TexData, &pTextures[t]); - ASSERT_NE(pTextures[t], nullptr); - pTextures[t]->GetDefaultView(TEXTURE_VIEW_SHADER_RESOURCE)->SetSampler(pSampler); - } - - // clang-format off - ResourceMappingEntry ResMpEntries [] = - { - ResourceMappingEntry("g_tex2DTest", pTextures[0]->GetDefaultView(TEXTURE_VIEW_SHADER_RESOURCE), 0), - ResourceMappingEntry("g_tex2DTest", pTextures[1]->GetDefaultView(TEXTURE_VIEW_SHADER_RESOURCE), 1), - ResourceMappingEntry("g_tex2DTest", pTextures[2]->GetDefaultView(TEXTURE_VIEW_SHADER_RESOURCE), 2), - ResourceMappingEntry("g_tex2DTest2", pTextures[5]->GetDefaultView(TEXTURE_VIEW_SHADER_RESOURCE), 0), - ResourceMappingEntry("g_tex2D", pTextures[6]->GetDefaultView(TEXTURE_VIEW_SHADER_RESOURCE), 0), - ResourceMappingEntry() - }; - // clang-format on - - ResourceMappingDesc ResMappingDesc; - ResMappingDesc.pEntries = ResMpEntries; - RefCntAutoPtr pResMapping; - pDevice->CreateResourceMapping(ResMappingDesc, &pResMapping); - - //pVS->BindResources(m_pResourceMapping, 0); - IDeviceObject* ppSRVs[] = {pTextures[3]->GetDefaultView(TEXTURE_VIEW_SHADER_RESOURCE)}; - pPSO->BindStaticResources(SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, pResMapping, BIND_SHADER_RESOURCES_KEEP_EXISTING); - pPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, "g_tex2DTest2")->SetArray(ppSRVs, 1, 1); - - pSRB->InitializeStaticResources(); - pSRB->BindResources(SHADER_TYPE_PIXEL, pResMapping, BIND_SHADER_RESOURCES_KEEP_EXISTING | BIND_SHADER_RESOURCES_UPDATE_MUTABLE | BIND_SHADER_RESOURCES_UPDATE_DYNAMIC); - ppSRVs[0] = pTextures[4]->GetDefaultView(TEXTURE_VIEW_SHADER_RESOURCE); - pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_tex2DTest")->SetArray(ppSRVs, 3, 1); - - ITextureView* pRTVs[] = {pRTV}; - pContext->SetRenderTargets(1, pRTVs, pDSV, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); - - pContext->SetPipelineState(pPSO); - ppSRVs[0] = {pTextures[7]->GetDefaultView(TEXTURE_VIEW_SHADER_RESOURCE)}; - pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_tex2D")->SetArray(ppSRVs, 1, 1); - - pContext->CommitShaderResources(pSRB, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); - - IBuffer* pBuffs[] = {pVertexBuff}; - Uint32 Offsets[] = {0}; - pContext->SetVertexBuffers(0, 1, pBuffs, Offsets, RESOURCE_STATE_TRANSITION_MODE_TRANSITION, SET_VERTEX_BUFFERS_FLAG_RESET); - - // Draw a quad - DrawAttribs DrawAttrs(4, DRAW_FLAG_VERIFY_ALL); - pContext->Draw(DrawAttrs); -} - -} // namespace diff --git a/UnitTests/DiligentCoreAPITest/src/ShaderResourceLayoutTest.cpp b/UnitTests/DiligentCoreAPITest/src/ShaderResourceLayoutTest.cpp deleted file mode 100644 index 76a6b71f..00000000 --- a/UnitTests/DiligentCoreAPITest/src/ShaderResourceLayoutTest.cpp +++ /dev/null @@ -1,1121 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ -#include -#include -#include -#include - -#include "TestingEnvironment.h" -#include "ShaderMacroHelper.h" -#include "GraphicsAccessories.h" - -#include "gtest/gtest.h" - -using namespace Diligent; -using namespace Diligent::Testing; - -namespace Diligent -{ -namespace Test -{ -void PrintShaderResources(IShader* pShader); -} -} // namespace Diligent - -namespace -{ - -class ShaderResourceLayoutTest : public ::testing::Test -{ -protected: - static void SetUpTestSuite() - { - auto* pEnv = TestingEnvironment::GetInstance(); - auto pRenderTarget = pEnv->CreateTexture("ShaderResourceLayoutTest: test RTV", TEX_FORMAT_RGBA8_UNORM, BIND_RENDER_TARGET, 512, 512); - ASSERT_NE(pRenderTarget, nullptr); - pRTV = pRenderTarget->GetDefaultView(TEXTURE_VIEW_RENDER_TARGET); - } - - static void TearDownTestSuite() - { - TestingEnvironment::GetInstance()->Reset(); - } - - static void VerifyShaderResources(IShader* pShader, - const ShaderResourceDesc ExpectedResources[], - Uint32 ExpectedResCount) - { - auto ResCount = pShader->GetResourceCount(); - EXPECT_EQ(ResCount, ExpectedResCount) << "Actual number of resources (" << ResCount << ") in shader '" - << pShader->GetDesc().Name << "' does not match the expected number of resources (" << ExpectedResCount << ')'; - std::unordered_map Resources; - for (Uint32 i = 0; i < ResCount; ++i) - { - const auto& ResDesc = pShader->GetResource(i); - Resources.emplace(ResDesc.Name, ResDesc); - } - - for (Uint32 i = 0; i < ExpectedResCount; ++i) - { - const auto& ExpectedRes = ExpectedResources[i]; - - auto it = Resources.find(ExpectedRes.Name); - if (it != Resources.end()) - { - EXPECT_EQ(it->second.Type, ExpectedRes.Type) << "Unexpected type of resource '" << ExpectedRes.Name << '\''; - EXPECT_EQ(it->second.ArraySize, ExpectedRes.ArraySize) << "Unexpected array size of resource '" << ExpectedRes.Name << '\''; - Resources.erase(it); - } - else - { - ADD_FAILURE() << "Unable to find resource '" << ExpectedRes.Name << "' in shader '" << pShader->GetDesc().Name << "'"; - } - } - - for (auto it : Resources) - { - ADD_FAILURE() << "Unexpected resource '" << it.second.Name << "' in shader '" << pShader->GetDesc().Name << "'"; - } - } - - template - static RefCntAutoPtr CreateShader(const char* ShaderName, - const char* FileName, - const char* EntryPoint, - SHADER_TYPE ShaderType, - SHADER_SOURCE_LANGUAGE SrcLang, - const ShaderMacro* Macros, - const ShaderResourceDesc* ExpectedResources, - Uint32 NumExpectedResources, - TModifyShaderCI ModifyShaderCI) - { - auto* pEnv = TestingEnvironment::GetInstance(); - auto* pDevice = pEnv->GetDevice(); - - RefCntAutoPtr pShaderSourceFactory; - pDevice->GetEngineFactory()->CreateDefaultShaderSourceStreamFactory("shaders/ShaderResourceLayout", &pShaderSourceFactory); - - ShaderCreateInfo ShaderCI; - ShaderCI.pShaderSourceStreamFactory = pShaderSourceFactory; - ShaderCI.UseCombinedTextureSamplers = pDevice->GetDeviceCaps().IsGLDevice(); - - ShaderCI.FilePath = FileName; - ShaderCI.Desc.Name = ShaderName; - ShaderCI.EntryPoint = EntryPoint; - ShaderCI.Desc.ShaderType = ShaderType; - ShaderCI.SourceLanguage = SrcLang; - ShaderCI.Macros = Macros; - - ModifyShaderCI(ShaderCI); - - RefCntAutoPtr pShader; - pDevice->CreateShader(ShaderCI, &pShader); - if (pShader) - { - VerifyShaderResources(pShader, ExpectedResources, NumExpectedResources); - Diligent::Test::PrintShaderResources(pShader); - } - - return pShader; - } - - static RefCntAutoPtr CreateShader(const char* ShaderName, - const char* FileName, - const char* EntryPoint, - SHADER_TYPE ShaderType, - SHADER_SOURCE_LANGUAGE SrcLang, - const ShaderMacro* Macros, - const ShaderResourceDesc* ExpectedResources, - Uint32 NumExpectedResources) - { - return CreateShader(ShaderName, - FileName, - EntryPoint, - ShaderType, - SrcLang, - Macros, - ExpectedResources, - NumExpectedResources, - [](const ShaderCreateInfo&) {}); - } - - - static void CreateGraphicsPSO(IShader* pVS, - IShader* pPS, - const PipelineResourceLayoutDesc& ResourceLayout, - RefCntAutoPtr& pPSO, - RefCntAutoPtr& pSRB) - { - PipelineStateDesc PSODesc; - - auto* pEnv = TestingEnvironment::GetInstance(); - auto* pDevice = pEnv->GetDevice(); - - PSODesc.ResourceLayout = ResourceLayout; - - PSODesc.Name = "Shader resource layout test"; - PSODesc.GraphicsPipeline.pVS = pVS; - PSODesc.GraphicsPipeline.pPS = pPS; - PSODesc.GraphicsPipeline.PrimitiveTopology = PRIMITIVE_TOPOLOGY_TRIANGLE_LIST; - PSODesc.GraphicsPipeline.NumRenderTargets = 1; - PSODesc.GraphicsPipeline.RTVFormats[0] = TEX_FORMAT_RGBA8_UNORM; - PSODesc.GraphicsPipeline.DSVFormat = TEX_FORMAT_UNKNOWN; - PSODesc.SRBAllocationGranularity = 16; - PSODesc.GraphicsPipeline.DepthStencilDesc.DepthEnable = False; - - pDevice->CreatePipelineState(PSODesc, &pPSO); - if (pPSO) - pPSO->CreateShaderResourceBinding(&pSRB, false); - } - - static RefCntAutoPtr CreateResourceBufferView(BUFFER_MODE BufferMode, BUFFER_VIEW_TYPE ViewType) - { - VERIFY_EXPR(ViewType == BUFFER_VIEW_SHADER_RESOURCE || ViewType == BUFFER_VIEW_UNORDERED_ACCESS); - - auto* pEnv = TestingEnvironment::GetInstance(); - auto* pDevice = pEnv->GetDevice(); - - BufferDesc BuffDesc; - BuffDesc.Name = "Formatted buffer"; - BuffDesc.uiSizeInBytes = 256; - BuffDesc.BindFlags = ViewType == BUFFER_VIEW_SHADER_RESOURCE ? BIND_SHADER_RESOURCE : BIND_UNORDERED_ACCESS; - BuffDesc.Usage = USAGE_DEFAULT; - BuffDesc.ElementByteStride = 16; - BuffDesc.Mode = BufferMode; - RefCntAutoPtr pBuffer; - RefCntAutoPtr pBufferView; - pDevice->CreateBuffer(BuffDesc, nullptr, &pBuffer); - if (!pBuffer) - { - ADD_FAILURE() << "Unable to create buffer " << BuffDesc; - return pBufferView; - } - - if (BufferMode == BUFFER_MODE_FORMATTED) - { - BufferViewDesc BuffViewDesc; - BuffViewDesc.Name = "Formatted buffer SRV"; - BuffViewDesc.ViewType = ViewType; - BuffViewDesc.Format.ValueType = VT_FLOAT32; - BuffViewDesc.Format.NumComponents = 4; - BuffViewDesc.Format.IsNormalized = false; - pBuffer->CreateView(BuffViewDesc, &pBufferView); - } - else - { - pBufferView = pBuffer->GetDefaultView(ViewType); - } - - return pBufferView; - } - - static void CreateComputePSO(IShader* pCS, - const PipelineResourceLayoutDesc& ResourceLayout, - RefCntAutoPtr& pPSO, - RefCntAutoPtr& pSRB) - { - PipelineStateDesc PSODesc; - - auto* pEnv = TestingEnvironment::GetInstance(); - auto* pDevice = pEnv->GetDevice(); - - PSODesc.Name = "Shader resource layout test"; - PSODesc.IsComputePipeline = true; - PSODesc.ResourceLayout = ResourceLayout; - PSODesc.ComputePipeline.pCS = pCS; - - pDevice->CreatePipelineState(PSODesc, &pPSO); - if (pPSO) - pPSO->CreateShaderResourceBinding(&pSRB, false); - } - - void TestTexturesAndStaticSamplers(bool TestStaticSamplers); - void TestStructuredOrFormattedBuffer(bool IsFormatted); - void TestRWStructuredOrFormattedBuffer(bool IsFormatted); - - static RefCntAutoPtr pRTV; -}; - -RefCntAutoPtr ShaderResourceLayoutTest::pRTV; - -#define SET_STATIC_VAR(PSO, ShaderFlags, VarName, SetMethod, ...) \ - do \ - { \ - auto pStaticVar = PSO->GetStaticVariableByName(ShaderFlags, VarName); \ - EXPECT_NE(pStaticVar, nullptr) << "Unable to find static variable '" << VarName << '\''; \ - if (pStaticVar != nullptr) \ - pStaticVar->SetMethod(__VA_ARGS__); \ - } while (false) - - -#define SET_SRB_VAR(SRB, ShaderFlags, VarName, SetMethod, ...) \ - do \ - { \ - auto pVar = SRB->GetVariableByName(ShaderFlags, VarName); \ - EXPECT_NE(pVar, nullptr) << "Unable to find SRB variable '" << VarName << '\''; \ - if (pVar != nullptr) \ - pVar->SetMethod(__VA_ARGS__); \ - } while (false) - - -void ShaderResourceLayoutTest::TestTexturesAndStaticSamplers(bool TestStaticSamplers) -{ - TestingEnvironment::ScopedReset AutoResetEnvironment; - - auto* pEnv = TestingEnvironment::GetInstance(); - auto* pDevice = pEnv->GetDevice(); - - static constexpr Uint32 StaticTexArraySize = 2; - static constexpr Uint32 MutableTexArraySize = 4; - static constexpr Uint32 DynamicTexArraySize = 3; - ShaderMacroHelper Macros; - Macros.AddShaderMacro("STATIC_TEX_ARRAY_SIZE", static_cast(StaticTexArraySize)); - Macros.AddShaderMacro("MUTABLE_TEX_ARRAY_SIZE", static_cast(MutableTexArraySize)); - Macros.AddShaderMacro("DYNAMIC_TEX_ARRAY_SIZE", static_cast(DynamicTexArraySize)); - - // clang-format off - std::vector Resources = - { - ShaderResourceDesc{"g_Tex2D_Static", SHADER_RESOURCE_TYPE_TEXTURE_SRV, 1}, - ShaderResourceDesc{"g_Tex2D_Mut", SHADER_RESOURCE_TYPE_TEXTURE_SRV, 1}, - ShaderResourceDesc{"g_Tex2D_Dyn", SHADER_RESOURCE_TYPE_TEXTURE_SRV, 1}, - ShaderResourceDesc{"g_Tex2DArr_Static", SHADER_RESOURCE_TYPE_TEXTURE_SRV, StaticTexArraySize}, - ShaderResourceDesc{"g_Tex2DArr_Mut", SHADER_RESOURCE_TYPE_TEXTURE_SRV, MutableTexArraySize}, - ShaderResourceDesc{"g_Tex2DArr_Dyn", SHADER_RESOURCE_TYPE_TEXTURE_SRV, DynamicTexArraySize} - }; - if (!pDevice->GetDeviceCaps().IsGLDevice()) - { - if (TestStaticSamplers) - { - Resources.emplace_back("g_Tex2D_Static_sampler", SHADER_RESOURCE_TYPE_SAMPLER, 1); - Resources.emplace_back("g_Tex2D_Mut_sampler", SHADER_RESOURCE_TYPE_SAMPLER, 1); - Resources.emplace_back("g_Tex2D_Dyn_sampler", SHADER_RESOURCE_TYPE_SAMPLER, 1); - Resources.emplace_back("g_Tex2DArr_Static_sampler", SHADER_RESOURCE_TYPE_SAMPLER, 1); - Resources.emplace_back("g_Tex2DArr_Mut_sampler", SHADER_RESOURCE_TYPE_SAMPLER, MutableTexArraySize); - Resources.emplace_back("g_Tex2DArr_Dyn_sampler", SHADER_RESOURCE_TYPE_SAMPLER, DynamicTexArraySize); - } - else - { - Resources.emplace_back("g_Sampler", SHADER_RESOURCE_TYPE_SAMPLER, 1); - } - } - // clang-format on - - auto ModifyShaderCI = [TestStaticSamplers](ShaderCreateInfo& ShaderCI) { - if (TestStaticSamplers) - { - ShaderCI.UseCombinedTextureSamplers = true; - ShaderCI.HLSLVersion = ShaderCreateInfo::ShaderVersion{5, 0}; - } - }; - auto pVS = CreateShader(TestStaticSamplers ? "ShaderResourceLayoutTest.StaticSamplers - VS" : "ShaderResourceLayoutTest.Textures - VS", - TestStaticSamplers ? "StaticSamplers.hlsl" : "Textures.hlsl", - "VSMain", - SHADER_TYPE_VERTEX, SHADER_SOURCE_LANGUAGE_HLSL, Macros, - Resources.data(), static_cast(Resources.size()), - ModifyShaderCI); - auto pPS = CreateShader(TestStaticSamplers ? "ShaderResourceLayoutTest.StaticSamplers - PS" : "ShaderResourceLayoutTest.Textures - PS", - TestStaticSamplers ? "StaticSamplers.hlsl" : "Textures.hlsl", - "PSMain", - SHADER_TYPE_PIXEL, SHADER_SOURCE_LANGUAGE_HLSL, Macros, - Resources.data(), static_cast(Resources.size()), - ModifyShaderCI); - ASSERT_NE(pVS, nullptr); - ASSERT_NE(pPS, nullptr); - - - // clang-format off - ShaderResourceVariableDesc Vars[] = - { - {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_Tex2D_Static", SHADER_RESOURCE_VARIABLE_TYPE_STATIC}, - {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_Tex2D_Mut", SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE}, - {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_Tex2D_Dyn", SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC}, - - {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_Tex2DArr_Static", SHADER_RESOURCE_VARIABLE_TYPE_STATIC}, - {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_Tex2DArr_Mut", SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE}, - {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_Tex2DArr_Dyn", SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC} - }; - std::vector StaticSamplers; - if (TestStaticSamplers) - { - StaticSamplers.emplace_back(SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_Tex2D_Static", SamplerDesc{}); - StaticSamplers.emplace_back(SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_Tex2D_Mut", SamplerDesc{}); - StaticSamplers.emplace_back(SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_Tex2D_Dyn", SamplerDesc{}); - StaticSamplers.emplace_back(SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_Tex2DArr_Static", SamplerDesc{}); - StaticSamplers.emplace_back(SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_Tex2DArr_Mut", SamplerDesc{}); - StaticSamplers.emplace_back(SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_Tex2DArr_Dyn", SamplerDesc{}); - } - else - { - StaticSamplers.emplace_back(SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_Sampler", SamplerDesc{}); - } - // clang-format on - - PipelineResourceLayoutDesc ResourceLayout; - ResourceLayout.Variables = Vars; - ResourceLayout.NumVariables = _countof(Vars); - ResourceLayout.StaticSamplers = StaticSamplers.data(); - ResourceLayout.NumStaticSamplers = static_cast(StaticSamplers.size()); - - RefCntAutoPtr pPSO; - RefCntAutoPtr pSRB; - CreateGraphicsPSO(pVS, pPS, ResourceLayout, pPSO, pSRB); - ASSERT_NE(pPSO, nullptr); - ASSERT_NE(pSRB, nullptr); - - constexpr auto MaxTextures = std::max(std::max(StaticTexArraySize, MutableTexArraySize), DynamicTexArraySize); - - std::array, MaxTextures> pTextures; - std::array pTexSRVs = {}; - - for (Uint32 i = 0; i < MaxTextures; ++i) - { - pTextures[i] = pEnv->CreateTexture("Test texture", TEX_FORMAT_RGBA8_UNORM, BIND_SHADER_RESOURCE, 256, 256); - pTexSRVs[i] = pTextures[i]->GetDefaultView(TEXTURE_VIEW_SHADER_RESOURCE); - } - - SET_STATIC_VAR(pPSO, SHADER_TYPE_VERTEX, "g_Tex2D_Static", Set, pTexSRVs[0]); - SET_STATIC_VAR(pPSO, SHADER_TYPE_VERTEX, "g_Tex2DArr_Static", SetArray, pTexSRVs.data(), 0, StaticTexArraySize); - - SET_STATIC_VAR(pPSO, SHADER_TYPE_PIXEL, "g_Tex2D_Static", Set, pTexSRVs[0]); - SET_STATIC_VAR(pPSO, SHADER_TYPE_PIXEL, "g_Tex2DArr_Static", SetArray, pTexSRVs.data(), 0, StaticTexArraySize); - - SET_SRB_VAR(pSRB, SHADER_TYPE_VERTEX, "g_Tex2D_Mut", Set, pTexSRVs[0]); - SET_SRB_VAR(pSRB, SHADER_TYPE_VERTEX, "g_Tex2D_Dyn", Set, pTexSRVs[0]); - SET_SRB_VAR(pSRB, SHADER_TYPE_VERTEX, "g_Tex2DArr_Mut", SetArray, pTexSRVs.data(), 0, MutableTexArraySize); - SET_SRB_VAR(pSRB, SHADER_TYPE_VERTEX, "g_Tex2DArr_Dyn", SetArray, pTexSRVs.data(), 0, DynamicTexArraySize); - - SET_SRB_VAR(pSRB, SHADER_TYPE_PIXEL, "g_Tex2D_Mut", Set, pTexSRVs[0]); - SET_SRB_VAR(pSRB, SHADER_TYPE_PIXEL, "g_Tex2D_Dyn", Set, pTexSRVs[0]); - SET_SRB_VAR(pSRB, SHADER_TYPE_PIXEL, "g_Tex2DArr_Mut", SetArray, pTexSRVs.data(), 0, MutableTexArraySize); - SET_SRB_VAR(pSRB, SHADER_TYPE_PIXEL, "g_Tex2DArr_Dyn", SetArray, pTexSRVs.data(), 0, DynamicTexArraySize); - - pSRB->InitializeStaticResources(pPSO); - - auto* pContext = pEnv->GetDeviceContext(); - - ITextureView* ppRTVs[] = {pRTV}; - pContext->SetRenderTargets(1, ppRTVs, nullptr, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); - - pContext->SetPipelineState(pPSO); - pContext->CommitShaderResources(pSRB, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); - - DrawAttribs DrawAttrs(3, DRAW_FLAG_VERIFY_ALL); - pContext->Draw(DrawAttrs); - - SET_SRB_VAR(pSRB, SHADER_TYPE_VERTEX, "g_Tex2D_Dyn", Set, pTexSRVs[1]); - SET_SRB_VAR(pSRB, SHADER_TYPE_VERTEX, "g_Tex2DArr_Dyn", SetArray, pTexSRVs.data(), 1, DynamicTexArraySize - 1); - - SET_SRB_VAR(pSRB, SHADER_TYPE_PIXEL, "g_Tex2D_Dyn", Set, pTexSRVs[1]); - SET_SRB_VAR(pSRB, SHADER_TYPE_PIXEL, "g_Tex2DArr_Dyn", SetArray, pTexSRVs.data(), 1, DynamicTexArraySize - 1); - - pContext->Draw(DrawAttrs); -} - -TEST_F(ShaderResourceLayoutTest, Textures) -{ - TestTexturesAndStaticSamplers(false); -} - -TEST_F(ShaderResourceLayoutTest, StaticSamplers) -{ - TestTexturesAndStaticSamplers(true); -} - - -void ShaderResourceLayoutTest::TestStructuredOrFormattedBuffer(bool IsFormatted) -{ - TestingEnvironment::ScopedReset AutoResetEnvironment; - - static constexpr int StaticBuffArraySize = 4; - static constexpr int MutableBuffArraySize = 3; - static constexpr int DynamicBuffArraySize = 2; - ShaderMacroHelper Macros; - Macros.AddShaderMacro("STATIC_BUFF_ARRAY_SIZE", StaticBuffArraySize); - Macros.AddShaderMacro("MUTABLE_BUFF_ARRAY_SIZE", MutableBuffArraySize); - Macros.AddShaderMacro("DYNAMIC_BUFF_ARRAY_SIZE", DynamicBuffArraySize); - - auto* pEnv = TestingEnvironment::GetInstance(); - auto* pDevice = pEnv->GetDevice(); - - // Vulkan only allows 16 dynamic storage buffer bindings among all stages, so - // use arrays only in fragment shader for structured buffer test. - const auto UseArraysInPSOnly = !IsFormatted && pDevice->GetDeviceCaps().IsVulkanDevice(); - - // clang-format off - std::vector Resources = - { - {"g_Buff_Static", SHADER_RESOURCE_TYPE_BUFFER_SRV, 1}, - {"g_Buff_Mut", SHADER_RESOURCE_TYPE_BUFFER_SRV, 1}, - {"g_Buff_Dyn", SHADER_RESOURCE_TYPE_BUFFER_SRV, 1} - }; - - auto AddArrayResources = [&Resources]() - { - Resources.emplace_back("g_BuffArr_Static", SHADER_RESOURCE_TYPE_BUFFER_SRV, StaticBuffArraySize); - Resources.emplace_back("g_BuffArr_Mut", SHADER_RESOURCE_TYPE_BUFFER_SRV, MutableBuffArraySize); - Resources.emplace_back("g_BuffArr_Dyn", SHADER_RESOURCE_TYPE_BUFFER_SRV, DynamicBuffArraySize); - }; - // clang-format on - if (!UseArraysInPSOnly) - { - AddArrayResources(); - } - - const char* ShaderFileName = nullptr; - SHADER_SOURCE_LANGUAGE SrcLang = SHADER_SOURCE_LANGUAGE_DEFAULT; - if (pDevice->GetDeviceCaps().IsD3DDevice()) - { - ShaderFileName = IsFormatted ? "FormattedBuffers.hlsl" : "StructuredBuffers.hlsl"; - SrcLang = SHADER_SOURCE_LANGUAGE_HLSL; - } - else if (pDevice->GetDeviceCaps().IsVulkanDevice() || pDevice->GetDeviceCaps().IsGLDevice()) - { - ShaderFileName = IsFormatted ? "FormattedBuffers.hlsl" : "StructuredBuffers.glsl"; - SrcLang = IsFormatted ? SHADER_SOURCE_LANGUAGE_HLSL : SHADER_SOURCE_LANGUAGE_GLSL; - } - else - { - GTEST_FAIL() << "Unexpected device type"; - } - auto pVS = CreateShader(IsFormatted ? "ShaderResourceLayoutTest.FormattedBuffers - VS" : "ShaderResourceLayoutTest.StructuredBuffers - VS", - ShaderFileName, "VSMain", - SHADER_TYPE_VERTEX, SrcLang, Macros, - Resources.data(), static_cast(Resources.size())); - if (UseArraysInPSOnly) - { - AddArrayResources(); - } - auto pPS = CreateShader(IsFormatted ? "ShaderResourceLayoutTest.FormattedBuffers - PS" : "ShaderResourceLayoutTest.StructuredBuffers - PS", - ShaderFileName, "PSMain", - SHADER_TYPE_PIXEL, SrcLang, Macros, - Resources.data(), static_cast(Resources.size())); - ASSERT_NE(pVS, nullptr); - ASSERT_NE(pPS, nullptr); - - - // clang-format off - ShaderResourceVariableDesc Vars[] = - { - {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_Buff_Static", SHADER_RESOURCE_VARIABLE_TYPE_STATIC}, - {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_Buff_Mut", SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE}, - {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_Buff_Dyn", SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC}, - - {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_BuffArr_Static", SHADER_RESOURCE_VARIABLE_TYPE_STATIC}, - {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_BuffArr_Mut", SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE}, - {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_BuffArr_Dyn", SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC} - }; - // clang-format on - - PipelineResourceLayoutDesc ResourceLayout; - ResourceLayout.Variables = Vars; - ResourceLayout.NumVariables = _countof(Vars); - - RefCntAutoPtr pPSO; - RefCntAutoPtr pSRB; - - CreateGraphicsPSO(pVS, pPS, ResourceLayout, pPSO, pSRB); - ASSERT_NE(pPSO, nullptr); - ASSERT_NE(pSRB, nullptr); - - constexpr auto MaxBuffers = std::max(std::max(StaticBuffArraySize, MutableBuffArraySize), DynamicBuffArraySize); - - std::array, MaxBuffers> pBufferViews; - std::array pBuffSRVs = {}; - - for (Uint32 i = 0; i < MaxBuffers; ++i) - { - pBufferViews[i] = CreateResourceBufferView(IsFormatted ? BUFFER_MODE_FORMATTED : BUFFER_MODE_STRUCTURED, BUFFER_VIEW_SHADER_RESOURCE); - ASSERT_NE(pBufferViews[i], nullptr) << "Unable to formatted buffer view "; - pBuffSRVs[i] = pBufferViews[i]; - } - - SET_STATIC_VAR(pPSO, SHADER_TYPE_VERTEX, "g_Buff_Static", Set, pBuffSRVs[0]); - if (!UseArraysInPSOnly) - { - SET_STATIC_VAR(pPSO, SHADER_TYPE_VERTEX, "g_BuffArr_Static", SetArray, pBuffSRVs.data(), 0, StaticBuffArraySize); - } - else - { - EXPECT_EQ(pPSO->GetStaticVariableByName(SHADER_TYPE_VERTEX, "g_BuffArr_Static"), nullptr); - } - SET_STATIC_VAR(pPSO, SHADER_TYPE_PIXEL, "g_Buff_Static", Set, pBuffSRVs[0]); - SET_STATIC_VAR(pPSO, SHADER_TYPE_PIXEL, "g_BuffArr_Static", SetArray, pBuffSRVs.data(), 0, StaticBuffArraySize); - - - SET_SRB_VAR(pSRB, SHADER_TYPE_VERTEX, "g_Buff_Mut", Set, pBuffSRVs[0]); - SET_SRB_VAR(pSRB, SHADER_TYPE_VERTEX, "g_Buff_Dyn", Set, pBuffSRVs[0]); - if (!UseArraysInPSOnly) - { - SET_SRB_VAR(pSRB, SHADER_TYPE_VERTEX, "g_BuffArr_Mut", SetArray, pBuffSRVs.data(), 0, MutableBuffArraySize); - SET_SRB_VAR(pSRB, SHADER_TYPE_VERTEX, "g_BuffArr_Dyn", SetArray, pBuffSRVs.data(), 0, DynamicBuffArraySize); - } - else - { - EXPECT_EQ(pSRB->GetVariableByName(SHADER_TYPE_VERTEX, "g_BuffArr_Mut"), nullptr); - EXPECT_EQ(pSRB->GetVariableByName(SHADER_TYPE_VERTEX, "g_BuffArr_Dyn"), nullptr); - } - - SET_SRB_VAR(pSRB, SHADER_TYPE_PIXEL, "g_Buff_Mut", Set, pBuffSRVs[0]); - SET_SRB_VAR(pSRB, SHADER_TYPE_PIXEL, "g_Buff_Dyn", Set, pBuffSRVs[0]); - SET_SRB_VAR(pSRB, SHADER_TYPE_PIXEL, "g_BuffArr_Mut", SetArray, pBuffSRVs.data(), 0, MutableBuffArraySize); - SET_SRB_VAR(pSRB, SHADER_TYPE_PIXEL, "g_BuffArr_Dyn", SetArray, pBuffSRVs.data(), 0, DynamicBuffArraySize); - - pSRB->InitializeStaticResources(pPSO); - - auto* pContext = pEnv->GetDeviceContext(); - - ITextureView* ppRTVs[] = {pRTV}; - pContext->SetRenderTargets(1, ppRTVs, nullptr, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); - - pContext->SetPipelineState(pPSO); - pContext->CommitShaderResources(pSRB, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); - - DrawAttribs DrawAttrs(3, DRAW_FLAG_VERIFY_ALL); - pContext->Draw(DrawAttrs); - - SET_SRB_VAR(pSRB, SHADER_TYPE_VERTEX, "g_Buff_Dyn", Set, pBuffSRVs[1]); - if (!UseArraysInPSOnly) - { - SET_SRB_VAR(pSRB, SHADER_TYPE_VERTEX, "g_BuffArr_Dyn", SetArray, pBuffSRVs.data(), 1, DynamicBuffArraySize - 1); - } - - SET_SRB_VAR(pSRB, SHADER_TYPE_PIXEL, "g_Buff_Dyn", Set, pBuffSRVs[1]); - SET_SRB_VAR(pSRB, SHADER_TYPE_PIXEL, "g_BuffArr_Dyn", SetArray, pBuffSRVs.data(), 1, DynamicBuffArraySize - 1); - - pContext->Draw(DrawAttrs); -} - -TEST_F(ShaderResourceLayoutTest, FormattedBuffers) -{ - TestStructuredOrFormattedBuffer(true /*IsFormatted*/); -} - -TEST_F(ShaderResourceLayoutTest, StructuredBuffers) -{ - auto* pEnv = TestingEnvironment::GetInstance(); - auto* pDevice = pEnv->GetDevice(); - if (pDevice->GetDeviceCaps().IsGLDevice()) - { - GTEST_SKIP() << "Read-only structured buffers in glsl are currently " - "identified as UAVs in OpenGL backend because " - "there seems to be no way to detect read-only property on the host"; - } - - TestStructuredOrFormattedBuffer(false /*IsFormatted*/); -} - - -void ShaderResourceLayoutTest::TestRWStructuredOrFormattedBuffer(bool IsFormatted) -{ - TestingEnvironment::ScopedReset AutoResetEnvironment; - - auto* pEnv = TestingEnvironment::GetInstance(); - auto* pDevice = pEnv->GetDevice(); - - const auto& deviceCaps = pDevice->GetDeviceCaps(); - auto deviceType = deviceCaps.DevType; - - const Uint32 StaticBuffArraySize = deviceType == DeviceType::D3D11 || deviceCaps.IsGLDevice() ? 1 : 4; - const Uint32 MutableBuffArraySize = deviceType == DeviceType::D3D11 || deviceCaps.IsGLDevice() ? 2 : 3; - const Uint32 DynamicBuffArraySize = 2; - - ShaderMacroHelper Macros; - Macros.AddShaderMacro("STATIC_BUFF_ARRAY_SIZE", static_cast(StaticBuffArraySize)); - Macros.AddShaderMacro("MUTABLE_BUFF_ARRAY_SIZE", static_cast(MutableBuffArraySize)); - Macros.AddShaderMacro("DYNAMIC_BUFF_ARRAY_SIZE", static_cast(DynamicBuffArraySize)); - - // clang-format off - ShaderResourceDesc Resources[] = - { - {"g_RWBuff_Static", SHADER_RESOURCE_TYPE_BUFFER_UAV, 1}, - {"g_RWBuff_Mut", SHADER_RESOURCE_TYPE_BUFFER_UAV, 1}, - {"g_RWBuff_Dyn", SHADER_RESOURCE_TYPE_BUFFER_UAV, 1}, - {"g_RWBuffArr_Static", SHADER_RESOURCE_TYPE_BUFFER_UAV, StaticBuffArraySize }, - {"g_RWBuffArr_Mut", SHADER_RESOURCE_TYPE_BUFFER_UAV, MutableBuffArraySize}, - {"g_RWBuffArr_Dyn", SHADER_RESOURCE_TYPE_BUFFER_UAV, DynamicBuffArraySize} - }; - - const char* ShaderFileName = nullptr; - SHADER_SOURCE_LANGUAGE SrcLang = SHADER_SOURCE_LANGUAGE_DEFAULT; - if (pDevice->GetDeviceCaps().IsD3DDevice()) - { - ShaderFileName = IsFormatted ? "RWFormattedBuffers.hlsl" : "RWStructuredBuffers.hlsl"; - SrcLang = SHADER_SOURCE_LANGUAGE_HLSL; - } - else if (pDevice->GetDeviceCaps().IsVulkanDevice() || pDevice->GetDeviceCaps().IsGLDevice()) - { - ShaderFileName = IsFormatted ? "RWFormattedBuffers.hlsl" : "RWStructuredBuffers.glsl"; - SrcLang = IsFormatted ? SHADER_SOURCE_LANGUAGE_HLSL : SHADER_SOURCE_LANGUAGE_GLSL; - } - else - { - GTEST_FAIL() << "Unexpected device type"; - } - auto pCS = CreateShader(IsFormatted ? "ShaderResourceLayoutTest.RWFormattedBuffers - CS" : "ShaderResourceLayoutTest.RWtructuredBuffers - CS", - ShaderFileName, "main", - SHADER_TYPE_COMPUTE, SrcLang, Macros, - Resources, _countof(Resources)); - ASSERT_NE(pCS, nullptr); - - // clang-format off - ShaderResourceVariableDesc Vars[] = - { - {SHADER_TYPE_COMPUTE, "g_RWBuff_Static", SHADER_RESOURCE_VARIABLE_TYPE_STATIC}, - {SHADER_TYPE_COMPUTE, "g_RWBuff_Mut", SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE}, - {SHADER_TYPE_COMPUTE, "g_RWBuff_Dyn", SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC}, - - {SHADER_TYPE_COMPUTE, "g_RWBuffArr_Static", SHADER_RESOURCE_VARIABLE_TYPE_STATIC}, - {SHADER_TYPE_COMPUTE, "g_RWBuffArr_Mut", SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE}, - {SHADER_TYPE_COMPUTE, "g_RWBuffArr_Dyn", SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC} - }; - // clang-format on - - PipelineResourceLayoutDesc ResourceLayout; - ResourceLayout.Variables = Vars; - ResourceLayout.NumVariables = _countof(Vars); - - RefCntAutoPtr pPSO; - RefCntAutoPtr pSRB; - - CreateComputePSO(pCS, ResourceLayout, pPSO, pSRB); - ASSERT_NE(pPSO, nullptr); - ASSERT_NE(pSRB, nullptr); - - const auto TotalBuffers = StaticBuffArraySize + MutableBuffArraySize + DynamicBuffArraySize + 3 + 2; - - std::vector> pBufferViews(TotalBuffers); - std::vector pBuffUAVs(TotalBuffers); - - for (Uint32 i = 0; i < TotalBuffers; ++i) - { - pBufferViews[i] = CreateResourceBufferView(IsFormatted ? BUFFER_MODE_FORMATTED : BUFFER_MODE_STRUCTURED, BUFFER_VIEW_UNORDERED_ACCESS); - ASSERT_NE(pBufferViews[i], nullptr) << "Unable to formatted buffer view "; - pBuffUAVs[i] = pBufferViews[i]; - } - - Uint32 uav = 0; - SET_STATIC_VAR(pPSO, SHADER_TYPE_COMPUTE, "g_RWBuff_Static", Set, pBuffUAVs[uav++]); - SET_STATIC_VAR(pPSO, SHADER_TYPE_COMPUTE, "g_RWBuffArr_Static", SetArray, &pBuffUAVs[uav], 0, StaticBuffArraySize); - uav += StaticBuffArraySize; - - SET_SRB_VAR(pSRB, SHADER_TYPE_COMPUTE, "g_RWBuff_Mut", Set, pBuffUAVs[uav++]); - SET_SRB_VAR(pSRB, SHADER_TYPE_COMPUTE, "g_RWBuff_Dyn", Set, pBuffUAVs[uav++]); - SET_SRB_VAR(pSRB, SHADER_TYPE_COMPUTE, "g_RWBuffArr_Mut", SetArray, &pBuffUAVs[uav], 0, MutableBuffArraySize); - uav += MutableBuffArraySize; - SET_SRB_VAR(pSRB, SHADER_TYPE_COMPUTE, "g_RWBuffArr_Dyn", SetArray, &pBuffUAVs[uav], 0, DynamicBuffArraySize); - uav += DynamicBuffArraySize; - VERIFY_EXPR(uav + 2 == pBuffUAVs.size()); - - pSRB->InitializeStaticResources(pPSO); - - auto* pContext = pEnv->GetDeviceContext(); - - pContext->SetPipelineState(pPSO); - pContext->CommitShaderResources(pSRB, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); - - DispatchComputeAttribs DispatchAttribs(1, 1, 1); - pContext->DispatchCompute(DispatchAttribs); - - SET_SRB_VAR(pSRB, SHADER_TYPE_COMPUTE, "g_RWBuff_Dyn", Set, pBuffUAVs[uav++]); - SET_SRB_VAR(pSRB, SHADER_TYPE_COMPUTE, "g_RWBuffArr_Dyn", SetArray, &pBuffUAVs[uav++], 1, 1); - pContext->DispatchCompute(DispatchAttribs); -} - -TEST_F(ShaderResourceLayoutTest, FormattedRWBuffers) -{ - TestRWStructuredOrFormattedBuffer(true /*IsFormatted*/); -} - -TEST_F(ShaderResourceLayoutTest, StructuredRWBuffers) -{ - TestRWStructuredOrFormattedBuffer(false /*IsFormatted*/); -} - -TEST_F(ShaderResourceLayoutTest, RWTextures) -{ - TestingEnvironment::ScopedReset AutoResetEnvironment; - - auto* pEnv = TestingEnvironment::GetInstance(); - auto* pDevice = pEnv->GetDevice(); - - const auto& deviceCaps = pDevice->GetDeviceCaps(); - auto deviceType = deviceCaps.DevType; - - const Uint32 StaticTexArraySize = 2; - const Uint32 MutableTexArraySize = deviceType == DeviceType::D3D11 || deviceCaps.IsGLDevice() ? 2 : 4; - const Uint32 DynamicTexArraySize = deviceType == DeviceType::D3D11 || deviceCaps.IsGLDevice() ? 1 : 3; - - ShaderMacroHelper Macros; - Macros.AddShaderMacro("STATIC_TEX_ARRAY_SIZE", static_cast(StaticTexArraySize)); - Macros.AddShaderMacro("MUTABLE_TEX_ARRAY_SIZE", static_cast(MutableTexArraySize)); - Macros.AddShaderMacro("DYNAMIC_TEX_ARRAY_SIZE", static_cast(DynamicTexArraySize)); - - // clang-format off - ShaderResourceDesc Resources[] = - { - {"g_RWTex2D_Static", SHADER_RESOURCE_TYPE_TEXTURE_UAV, 1}, - {"g_RWTex2D_Mut", SHADER_RESOURCE_TYPE_TEXTURE_UAV, 1}, - {"g_RWTex2D_Dyn", SHADER_RESOURCE_TYPE_TEXTURE_UAV, 1}, - {"g_RWTex2DArr_Static", SHADER_RESOURCE_TYPE_TEXTURE_UAV, StaticTexArraySize }, - {"g_RWTex2DArr_Mut", SHADER_RESOURCE_TYPE_TEXTURE_UAV, MutableTexArraySize}, - {"g_RWTex2DArr_Dyn", SHADER_RESOURCE_TYPE_TEXTURE_UAV, DynamicTexArraySize} - }; - - auto pCS = CreateShader("ShaderResourceLayoutTest.RWTextures - CS", - "RWTextures.hlsl", "main", - SHADER_TYPE_COMPUTE, SHADER_SOURCE_LANGUAGE_HLSL, Macros, - Resources, _countof(Resources)); - ASSERT_NE(pCS, nullptr); - - // clang-format off - ShaderResourceVariableDesc Vars[] = - { - {SHADER_TYPE_COMPUTE, "g_RWTex2D_Static", SHADER_RESOURCE_VARIABLE_TYPE_STATIC}, - {SHADER_TYPE_COMPUTE, "g_RWTex2D_Mut", SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE}, - {SHADER_TYPE_COMPUTE, "g_RWTex2D_Dyn", SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC}, - - {SHADER_TYPE_COMPUTE, "g_RWTex2DArr_Static", SHADER_RESOURCE_VARIABLE_TYPE_STATIC}, - {SHADER_TYPE_COMPUTE, "g_RWTex2DArr_Mut", SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE}, - {SHADER_TYPE_COMPUTE, "g_RWTex2DArr_Dyn", SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC} - }; - // clang-format on - - PipelineResourceLayoutDesc ResourceLayout; - ResourceLayout.Variables = Vars; - ResourceLayout.NumVariables = _countof(Vars); - - RefCntAutoPtr pPSO; - RefCntAutoPtr pSRB; - - CreateComputePSO(pCS, ResourceLayout, pPSO, pSRB); - ASSERT_NE(pPSO, nullptr); - ASSERT_NE(pSRB, nullptr); - - const auto TotalTextures = StaticTexArraySize + MutableTexArraySize + DynamicTexArraySize + 3 + 2; - - std::vector> pTextures(TotalTextures); - std::vector pUAVs(TotalTextures); - - for (Uint32 i = 0; i < TotalTextures; ++i) - { - pTextures[i] = pEnv->CreateTexture("Test RW texture", TEX_FORMAT_RGBA32_FLOAT, BIND_UNORDERED_ACCESS, 256, 256); - ASSERT_NE(pTextures[i], nullptr); - pUAVs[i] = pTextures[i]->GetDefaultView(TEXTURE_VIEW_UNORDERED_ACCESS); - ASSERT_NE(pUAVs[i], nullptr); - } - - Uint32 uav = 0; - SET_STATIC_VAR(pPSO, SHADER_TYPE_COMPUTE, "g_RWTex2D_Static", Set, pUAVs[uav++]); - SET_STATIC_VAR(pPSO, SHADER_TYPE_COMPUTE, "g_RWTex2DArr_Static", SetArray, &pUAVs[uav], 0, StaticTexArraySize); - uav += StaticTexArraySize; - - SET_SRB_VAR(pSRB, SHADER_TYPE_COMPUTE, "g_RWTex2D_Mut", Set, pUAVs[uav++]); - SET_SRB_VAR(pSRB, SHADER_TYPE_COMPUTE, "g_RWTex2D_Dyn", Set, pUAVs[uav++]); - SET_SRB_VAR(pSRB, SHADER_TYPE_COMPUTE, "g_RWTex2DArr_Mut", SetArray, &pUAVs[uav], 0, MutableTexArraySize); - uav += MutableTexArraySize; - SET_SRB_VAR(pSRB, SHADER_TYPE_COMPUTE, "g_RWTex2DArr_Dyn", SetArray, &pUAVs[uav], 0, DynamicTexArraySize); - uav += DynamicTexArraySize; - VERIFY_EXPR(uav + 2 == pUAVs.size()); - - pSRB->InitializeStaticResources(pPSO); - - auto* pContext = pEnv->GetDeviceContext(); - - pContext->SetPipelineState(pPSO); - pContext->CommitShaderResources(pSRB, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); - - DispatchComputeAttribs DispatchAttribs(1, 1, 1); - pContext->DispatchCompute(DispatchAttribs); - - SET_SRB_VAR(pSRB, SHADER_TYPE_COMPUTE, "g_RWTex2D_Dyn", Set, pUAVs[uav++]); - SET_SRB_VAR(pSRB, SHADER_TYPE_COMPUTE, "g_RWTex2DArr_Dyn", SetArray, &pUAVs[uav++], 0, 1); - pContext->DispatchCompute(DispatchAttribs); -} - -TEST_F(ShaderResourceLayoutTest, ConstantBuffers) -{ - TestingEnvironment::ScopedReset AutoResetEnvironment; - - auto* pEnv = TestingEnvironment::GetInstance(); - auto* pDevice = pEnv->GetDevice(); - - const auto deviceCaps = pDevice->GetDeviceCaps(); - // Vulkan allows 15 dynamic uniform buffer bindings among all stages - const Uint32 StaticCBArraySize = 2; - const Uint32 MutableCBArraySize = deviceCaps.IsVulkanDevice() ? 1 : 4; - const Uint32 DynamicCBArraySize = deviceCaps.IsVulkanDevice() ? 1 : 3; - - ShaderMacroHelper Macros; - Macros.AddShaderMacro("STATIC_CB_ARRAY_SIZE", static_cast(StaticCBArraySize)); - Macros.AddShaderMacro("MUTABLE_CB_ARRAY_SIZE", static_cast(MutableCBArraySize)); - Macros.AddShaderMacro("DYNAMIC_CB_ARRAY_SIZE", static_cast(DynamicCBArraySize)); - - const auto CBArraysSupported = deviceCaps.DevType == DeviceType::D3D12 || deviceCaps.IsVulkanDevice(); - Macros.AddShaderMacro("ARRAYS_SUPPORTED", CBArraysSupported); - - // clang-format off - std::vector Resources = - { - ShaderResourceDesc{"UniformBuff_Stat", SHADER_RESOURCE_TYPE_CONSTANT_BUFFER, 1}, - ShaderResourceDesc{"UniformBuff_Mut", SHADER_RESOURCE_TYPE_CONSTANT_BUFFER, 1}, - ShaderResourceDesc{"UniformBuff_Dyn", SHADER_RESOURCE_TYPE_CONSTANT_BUFFER, 1} - }; - - if (CBArraysSupported) - { - Resources.emplace_back("UniformBuffArr_Stat", SHADER_RESOURCE_TYPE_CONSTANT_BUFFER, StaticCBArraySize); - Resources.emplace_back("UniformBuffArr_Mut", SHADER_RESOURCE_TYPE_CONSTANT_BUFFER, MutableCBArraySize); - Resources.emplace_back("UniformBuffArr_Dyn", SHADER_RESOURCE_TYPE_CONSTANT_BUFFER, DynamicCBArraySize); - } - // clang-format on - - auto pVS = CreateShader("ShaderResourceLayoutTest.ConstantBuffers - VS", - "ConstantBuffers.hlsl", - "VSMain", - SHADER_TYPE_VERTEX, SHADER_SOURCE_LANGUAGE_HLSL, Macros, - Resources.data(), static_cast(Resources.size())); - auto pPS = CreateShader("ShaderResourceLayoutTest.ConstantBuffers - PS", - "ConstantBuffers.hlsl", - "PSMain", - SHADER_TYPE_PIXEL, SHADER_SOURCE_LANGUAGE_HLSL, Macros, - Resources.data(), static_cast(Resources.size())); - ASSERT_NE(pVS, nullptr); - ASSERT_NE(pPS, nullptr); - - - // clang-format off - std::vector Vars = - { - {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "UniformBuff_Stat", SHADER_RESOURCE_VARIABLE_TYPE_STATIC}, - {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "UniformBuff_Mut", SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE}, - {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "UniformBuff_Dyn", SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC} - }; - - if (CBArraysSupported) - { - Vars.emplace_back(SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "UniformBuffArr_Stat", SHADER_RESOURCE_VARIABLE_TYPE_STATIC); - Vars.emplace_back(SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "UniformBuffArr_Mut", SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE); - Vars.emplace_back(SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "UniformBuffArr_Dyn", SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC); - }; - // clang-format on - - PipelineResourceLayoutDesc ResourceLayout; - ResourceLayout.Variables = Vars.data(); - ResourceLayout.NumVariables = static_cast(Vars.size()); - - RefCntAutoPtr pPSO; - RefCntAutoPtr pSRB; - CreateGraphicsPSO(pVS, pPS, ResourceLayout, pPSO, pSRB); - ASSERT_NE(pPSO, nullptr); - ASSERT_NE(pSRB, nullptr); - - const auto MaxBuffers = std::max(std::max(StaticCBArraySize, MutableCBArraySize), DynamicCBArraySize); - - std::vector> pBuffers(MaxBuffers); - std::vector pCBObjs(MaxBuffers); - - for (Uint32 i = 0; i < MaxBuffers; ++i) - { - BufferDesc BuffDesc; - BuffDesc.Name = "Constant buffer"; - BuffDesc.uiSizeInBytes = 256; - BuffDesc.BindFlags = BIND_UNIFORM_BUFFER; - BuffDesc.Usage = USAGE_DEFAULT; - pDevice->CreateBuffer(BuffDesc, nullptr, &pBuffers[i]); - ASSERT_NE(pBuffers[i], nullptr); - pCBObjs[i] = pBuffers[i]; - } - - SET_STATIC_VAR(pPSO, SHADER_TYPE_VERTEX, "UniformBuff_Stat", Set, pCBObjs[0]); - SET_STATIC_VAR(pPSO, SHADER_TYPE_PIXEL, "UniformBuff_Stat", Set, pCBObjs[0]); - if (CBArraysSupported) - { - SET_STATIC_VAR(pPSO, SHADER_TYPE_VERTEX, "UniformBuffArr_Stat", SetArray, pCBObjs.data(), 0, StaticCBArraySize); - SET_STATIC_VAR(pPSO, SHADER_TYPE_PIXEL, "UniformBuffArr_Stat", SetArray, pCBObjs.data(), 0, StaticCBArraySize); - } - - SET_SRB_VAR(pSRB, SHADER_TYPE_VERTEX, "UniformBuff_Mut", Set, pCBObjs[0]); - SET_SRB_VAR(pSRB, SHADER_TYPE_VERTEX, "UniformBuff_Dyn", Set, pCBObjs[0]); - if (CBArraysSupported) - { - SET_SRB_VAR(pSRB, SHADER_TYPE_VERTEX, "UniformBuffArr_Mut", SetArray, pCBObjs.data(), 0, MutableCBArraySize); - SET_SRB_VAR(pSRB, SHADER_TYPE_VERTEX, "UniformBuffArr_Dyn", SetArray, pCBObjs.data(), 0, DynamicCBArraySize); - } - - SET_SRB_VAR(pSRB, SHADER_TYPE_PIXEL, "UniformBuff_Mut", Set, pCBObjs[0]); - SET_SRB_VAR(pSRB, SHADER_TYPE_PIXEL, "UniformBuff_Dyn", Set, pCBObjs[0]); - if (CBArraysSupported) - { - SET_SRB_VAR(pSRB, SHADER_TYPE_PIXEL, "UniformBuffArr_Mut", SetArray, pCBObjs.data(), 0, MutableCBArraySize); - SET_SRB_VAR(pSRB, SHADER_TYPE_PIXEL, "UniformBuffArr_Dyn", SetArray, pCBObjs.data(), 0, DynamicCBArraySize); - } - - pSRB->InitializeStaticResources(pPSO); - - auto* pContext = pEnv->GetDeviceContext(); - - ITextureView* ppRTVs[] = {pRTV}; - pContext->SetRenderTargets(1, ppRTVs, nullptr, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); - - pContext->SetPipelineState(pPSO); - pContext->CommitShaderResources(pSRB, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); - - DrawAttribs DrawAttrs(3, DRAW_FLAG_VERIFY_ALL); - pContext->Draw(DrawAttrs); - - SET_SRB_VAR(pSRB, SHADER_TYPE_VERTEX, "UniformBuff_Dyn", Set, pCBObjs[1]); - SET_SRB_VAR(pSRB, SHADER_TYPE_PIXEL, "UniformBuff_Dyn", Set, pCBObjs[1]); - if (CBArraysSupported) - { - SET_SRB_VAR(pSRB, SHADER_TYPE_VERTEX, "UniformBuffArr_Dyn", SetArray, &pCBObjs[1], 0, DynamicCBArraySize - 1); - SET_SRB_VAR(pSRB, SHADER_TYPE_PIXEL, "UniformBuffArr_Dyn", SetArray, &pCBObjs[1], 0, DynamicCBArraySize - 1); - } - - pContext->Draw(DrawAttrs); -} - -TEST_F(ShaderResourceLayoutTest, Samplers) -{ - auto* pEnv = TestingEnvironment::GetInstance(); - auto* pDevice = pEnv->GetDevice(); - if (pDevice->GetDeviceCaps().IsGLDevice()) - { - GTEST_SKIP() << "OpenGL does not support separate samplers"; - } - - TestingEnvironment::ScopedReset AutoResetEnvironment; - - static constexpr Uint32 StaticSamArraySize = 2; - static constexpr Uint32 MutableSamArraySize = 4; - static constexpr Uint32 DynamicSamArraySize = 3; - ShaderMacroHelper Macros; - Macros.AddShaderMacro("STATIC_SAM_ARRAY_SIZE", static_cast(StaticSamArraySize)); - Macros.AddShaderMacro("MUTABLE_SAM_ARRAY_SIZE", static_cast(MutableSamArraySize)); - Macros.AddShaderMacro("DYNAMIC_SAM_ARRAY_SIZE", static_cast(DynamicSamArraySize)); - - RefCntAutoPtr pPSO; - RefCntAutoPtr pSRB; - // clang-format off - ShaderResourceDesc Resources[] = - { - {"g_Sam_Static", SHADER_RESOURCE_TYPE_SAMPLER, 1}, - {"g_Sam_Mut", SHADER_RESOURCE_TYPE_SAMPLER, 1}, - {"g_Sam_Dyn", SHADER_RESOURCE_TYPE_SAMPLER, 1}, - {"g_SamArr_Static", SHADER_RESOURCE_TYPE_SAMPLER, StaticSamArraySize}, - {"g_SamArr_Mut", SHADER_RESOURCE_TYPE_SAMPLER, MutableSamArraySize}, - {"g_SamArr_Dyn", SHADER_RESOURCE_TYPE_SAMPLER, DynamicSamArraySize}, - {"g_Tex2D", SHADER_RESOURCE_TYPE_TEXTURE_SRV, 1}, - }; - // clang-format on - auto pVS = CreateShader("ShaderResourceLayoutTest.Samplers - VS", "Samplers.hlsl", "VSMain", - SHADER_TYPE_VERTEX, SHADER_SOURCE_LANGUAGE_HLSL, Macros, - Resources, _countof(Resources)); - auto pPS = CreateShader("ShaderResourceLayoutTest.Samplers - PS", "Samplers.hlsl", "PSMain", - SHADER_TYPE_PIXEL, SHADER_SOURCE_LANGUAGE_HLSL, Macros, - Resources, _countof(Resources)); - ASSERT_NE(pVS, nullptr); - ASSERT_NE(pPS, nullptr); - - - // clang-format off - ShaderResourceVariableDesc Vars[] = - { - {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_Tex2D", SHADER_RESOURCE_VARIABLE_TYPE_STATIC}, - - {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_Sam_Static", SHADER_RESOURCE_VARIABLE_TYPE_STATIC}, - {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_Sam_Mut", SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE}, - {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_Sam_Dyn", SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC}, - - {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_SamArr_Static", SHADER_RESOURCE_VARIABLE_TYPE_STATIC}, - {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_SamArr_Mut", SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE}, - {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_SamArr_Dyn", SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC} - }; - // clang-format on - - PipelineResourceLayoutDesc ResourceLayout; - ResourceLayout.Variables = Vars; - ResourceLayout.NumVariables = _countof(Vars); - - CreateGraphicsPSO(pVS, pPS, ResourceLayout, pPSO, pSRB); - ASSERT_NE(pPSO, nullptr); - ASSERT_NE(pSRB, nullptr); - - constexpr auto MaxSamplers = std::max(std::max(StaticSamArraySize, MutableSamArraySize), DynamicSamArraySize); - - std::array, MaxSamplers> pSamplers; - std::array pSamObjs = {}; - - for (Uint32 i = 0; i < MaxSamplers; ++i) - { - SamplerDesc SamDesc; - pDevice->CreateSampler(SamDesc, &pSamplers[i]); - ASSERT_NE(pSamplers[i], nullptr); - pSamObjs[i] = pSamplers[i]; - } - - auto pTex2D = pEnv->CreateTexture("ShaderResourceLayoutTest: test RTV", TEX_FORMAT_RGBA8_UNORM, BIND_SHADER_RESOURCE, 512, 512); - auto* pTex2DSRV = pTex2D->GetDefaultView(TEXTURE_VIEW_SHADER_RESOURCE); - SET_STATIC_VAR(pPSO, SHADER_TYPE_VERTEX, "g_Tex2D", Set, pTex2DSRV); - SET_STATIC_VAR(pPSO, SHADER_TYPE_PIXEL, "g_Tex2D", Set, pTex2DSRV); - - - SET_STATIC_VAR(pPSO, SHADER_TYPE_VERTEX, "g_Sam_Static", Set, pSamObjs[0]); - SET_STATIC_VAR(pPSO, SHADER_TYPE_VERTEX, "g_SamArr_Static", SetArray, pSamObjs.data(), 0, StaticSamArraySize); - - SET_STATIC_VAR(pPSO, SHADER_TYPE_PIXEL, "g_Sam_Static", Set, pSamObjs[0]); - SET_STATIC_VAR(pPSO, SHADER_TYPE_PIXEL, "g_SamArr_Static", SetArray, pSamObjs.data(), 0, StaticSamArraySize); - - SET_SRB_VAR(pSRB, SHADER_TYPE_VERTEX, "g_Sam_Mut", Set, pSamObjs[0]); - SET_SRB_VAR(pSRB, SHADER_TYPE_VERTEX, "g_Sam_Dyn", Set, pSamObjs[0]); - SET_SRB_VAR(pSRB, SHADER_TYPE_VERTEX, "g_SamArr_Mut", SetArray, pSamObjs.data(), 0, MutableSamArraySize); - SET_SRB_VAR(pSRB, SHADER_TYPE_VERTEX, "g_SamArr_Dyn", SetArray, pSamObjs.data(), 0, DynamicSamArraySize); - - SET_SRB_VAR(pSRB, SHADER_TYPE_PIXEL, "g_Sam_Mut", Set, pSamObjs[0]); - SET_SRB_VAR(pSRB, SHADER_TYPE_PIXEL, "g_Sam_Dyn", Set, pSamObjs[0]); - SET_SRB_VAR(pSRB, SHADER_TYPE_PIXEL, "g_SamArr_Mut", SetArray, pSamObjs.data(), 0, MutableSamArraySize); - SET_SRB_VAR(pSRB, SHADER_TYPE_PIXEL, "g_SamArr_Dyn", SetArray, pSamObjs.data(), 0, DynamicSamArraySize); - - pSRB->InitializeStaticResources(pPSO); - - auto* pContext = pEnv->GetDeviceContext(); - - ITextureView* ppRTVs[] = {pRTV}; - pContext->SetRenderTargets(1, ppRTVs, nullptr, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); - - pContext->SetPipelineState(pPSO); - pContext->CommitShaderResources(pSRB, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); - - DrawAttribs DrawAttrs(3, DRAW_FLAG_VERIFY_ALL); - pContext->Draw(DrawAttrs); - - SET_SRB_VAR(pSRB, SHADER_TYPE_VERTEX, "g_Sam_Dyn", Set, pSamObjs[1]); - SET_SRB_VAR(pSRB, SHADER_TYPE_VERTEX, "g_SamArr_Dyn", SetArray, pSamObjs.data(), 1, DynamicSamArraySize - 1); - - SET_SRB_VAR(pSRB, SHADER_TYPE_PIXEL, "g_Sam_Dyn", Set, pSamObjs[1]); - SET_SRB_VAR(pSRB, SHADER_TYPE_PIXEL, "g_SamArr_Dyn", SetArray, pSamObjs.data(), 1, DynamicSamArraySize - 1); - - pContext->Draw(DrawAttrs); -} - -} // namespace diff --git a/UnitTests/DiligentCoreAPITest/src/ShaderVariableAccessTest.cpp b/UnitTests/DiligentCoreAPITest/src/ShaderVariableAccessTest.cpp deleted file mode 100644 index 052d8371..00000000 --- a/UnitTests/DiligentCoreAPITest/src/ShaderVariableAccessTest.cpp +++ /dev/null @@ -1,827 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "GraphicsAccessories.h" -#include "../../../Graphics/GraphicsEngineD3DBase/interface/ShaderD3D.h" - -#include "TestingEnvironment.h" - -#include "gtest/gtest.h" - -using namespace Diligent; -using namespace Diligent::Testing; - -namespace Diligent -{ - -namespace Test -{ - -void PrintShaderResources(IShader* pShader) -{ - RefCntAutoPtr pShaderD3D(pShader, IID_ShaderD3D); - - std::stringstream ss; - ss << "Resources of shader '" << pShader->GetDesc().Name << "':" << std::endl; - for (Uint32 res = 0; res < pShader->GetResourceCount(); ++res) - { - auto ResDec = pShader->GetResource(res); - - std::stringstream name_ss; - name_ss << ResDec.Name; - if (ResDec.ArraySize > 1) - name_ss << "[" << ResDec.ArraySize << "]"; - ss << std::setw(2) << std::right << res << ": " << std::setw(25) << std::left << name_ss.str(); - if (pShaderD3D) - { - auto HLSLResDesc = pShaderD3D->GetHLSLResource(res); - ss << " hlsl register " << std::setw(2) << HLSLResDesc.ShaderRegister; - } - ss << " " << GetShaderResourceTypeLiteralName(ResDec.Type) << std::endl; - } - LOG_INFO_MESSAGE(ss.str()); -} - -} // namespace Test - -} // namespace Diligent -namespace -{ - -TEST(ShaderResourceLayout, VariableAccess) -{ - auto* pEnv = TestingEnvironment::GetInstance(); - auto* pDevice = pEnv->GetDevice(); - auto* pContext = pEnv->GetDeviceContext(); - - if (pDevice->GetDeviceCaps().DevType == DeviceType::OpenGLES) - return; - - TestingEnvironment::ScopedReset EnvironmentAutoReset; - - ShaderCreateInfo ShaderCI; - - RefCntAutoPtr pShaderSourceFactory; - pDevice->GetEngineFactory()->CreateDefaultShaderSourceStreamFactory("shaders", &pShaderSourceFactory); - ShaderCI.pShaderSourceStreamFactory = pShaderSourceFactory; - ShaderCI.EntryPoint = "main"; - ShaderCI.UseCombinedTextureSamplers = true; - - RefCntAutoPtr pSamplers[2]; - IDeviceObject* pSams[2] = {}; - for (size_t i = 0; i < _countof(pSams); ++i) - { - SamplerDesc SamDesc; - pDevice->CreateSampler(SamDesc, &(pSamplers[i])); - pSams[i] = pSamplers[i]; - } - - RefCntAutoPtr pTex[2]; - TextureDesc TexDesc; - TexDesc.Type = RESOURCE_DIM_TEX_2D; - TexDesc.Width = 1024; - TexDesc.Height = 1024; - TexDesc.Format = TEX_FORMAT_RGBA8_UNORM_SRGB; - TexDesc.BindFlags = BIND_SHADER_RESOURCE; - IDeviceObject* pSRVs[2] = {}; - for (size_t i = 0; i < _countof(pSRVs); ++i) - { - pDevice->CreateTexture(TexDesc, nullptr, &(pTex[i])); - auto* pSRV = pTex[i]->GetDefaultView(TEXTURE_VIEW_SHADER_RESOURCE); - pSRV->SetSampler(pSamplers[i]); - pSRVs[i] = pSRV; - } - - RefCntAutoPtr pRWTex[8]; - IDeviceObject* pTexUAVs[_countof(pRWTex)] = {}; - IDeviceObject* pRWTexSRVs[_countof(pRWTex)] = {}; - TexDesc.BindFlags = BIND_SHADER_RESOURCE | BIND_UNORDERED_ACCESS; - TexDesc.Format = TEX_FORMAT_RGBA32_FLOAT; - for (size_t i = 0; i < _countof(pRWTex); ++i) - { - pDevice->CreateTexture(TexDesc, nullptr, &(pRWTex[i])); - pTexUAVs[i] = pRWTex[i]->GetDefaultView(TEXTURE_VIEW_UNORDERED_ACCESS); - pRWTexSRVs[i] = pRWTex[i]->GetDefaultView(TEXTURE_VIEW_SHADER_RESOURCE); - } - - - //RefCntAutoPtr pStorageTex[4]; - //IDeviceObject *pUAVs[4]; - //for (int i = 0; i < 4; ++i) - //{ - // pDevice->CreateTexture(TexDesc, TextureData{}, &(pStorageTex[i])); - // pUAVs[i] = pStorageTex[i]->GetDefaultView(TEXTURE_VIEW_UNORDERED_ACCESS); - //} - - constexpr auto RTVFormat = TEX_FORMAT_RGBA8_UNORM; - constexpr auto DSVFormat = TEX_FORMAT_D32_FLOAT; - - TexDesc.Format = RTVFormat; - TexDesc.BindFlags = BIND_RENDER_TARGET | BIND_SHADER_RESOURCE; - RefCntAutoPtr pRenderTarget; - pDevice->CreateTexture(TexDesc, nullptr, &pRenderTarget); - auto* pRTV = pRenderTarget->GetDefaultView(TEXTURE_VIEW_RENDER_TARGET); - - TexDesc.Format = DSVFormat; - TexDesc.BindFlags = BIND_DEPTH_STENCIL; - RefCntAutoPtr pDepthTex; - pDevice->CreateTexture(TexDesc, nullptr, &pDepthTex); - auto* pDSV = pDepthTex->GetDefaultView(TEXTURE_VIEW_DEPTH_STENCIL); - - BufferDesc BuffDesc; - BuffDesc.uiSizeInBytes = 1024; - BuffDesc.BindFlags = BIND_UNIFORM_BUFFER; - RefCntAutoPtr pUniformBuffs[2]; - IDeviceObject* pUBs[2]; - for (int i = 0; i < _countof(pUniformBuffs); ++i) - { - pDevice->CreateBuffer(BuffDesc, nullptr, &(pUniformBuffs[i])); - pUBs[i] = pUniformBuffs[i]; - } - - //BuffDesc.BindFlags = BIND_UNORDERED_ACCESS; - //BuffDesc.Mode = BUFFER_MODE_STRUCTURED; - //BuffDesc.ElementByteStride = 16; - //RefCntAutoPtr pStorgeBuffs[4]; - //IDeviceObject *pSBUAVs[4]; - //for (int i = 0; i < 4; ++i) - //{ - // pDevice->CreateBuffer(BuffDesc, BufferData{}, &(pStorgeBuffs[i])); - // pSBUAVs[i] = pStorgeBuffs[i]->GetDefaultView(BUFFER_VIEW_UNORDERED_ACCESS); - //} - - RefCntAutoPtr pFormattedBuff0, pFormattedBuff[4], pRawBuff[2]; - IDeviceObject * pFormattedBuffSRV = nullptr, *pFormattedBuffUAV[4] = {}, *pFormattedBuffSRVs[4] = {}; - RefCntAutoPtr spFormattedBuffSRV, spFormattedBuffUAV[4], spFormattedBuffSRVs[4]; - RefCntAutoPtr spRawBuffUAV[2], spRawBuffSRVs[2]; - { - BufferDesc TxlBuffDesc; - TxlBuffDesc.Name = "Uniform texel buffer test"; - TxlBuffDesc.uiSizeInBytes = 256; - TxlBuffDesc.BindFlags = BIND_SHADER_RESOURCE | BIND_UNORDERED_ACCESS; - TxlBuffDesc.Usage = USAGE_DEFAULT; - TxlBuffDesc.ElementByteStride = 16; - TxlBuffDesc.Mode = BUFFER_MODE_FORMATTED; - pDevice->CreateBuffer(TxlBuffDesc, nullptr, &pFormattedBuff0); - - BufferViewDesc ViewDesc; - ViewDesc.ViewType = BUFFER_VIEW_SHADER_RESOURCE; - ViewDesc.Format.ValueType = VT_FLOAT32; - ViewDesc.Format.NumComponents = 4; - ViewDesc.Format.IsNormalized = false; - pFormattedBuff0->CreateView(ViewDesc, &spFormattedBuffSRV); - pFormattedBuffSRV = spFormattedBuffSRV; - - for (size_t i = 0; i < _countof(pFormattedBuff); ++i) - { - TxlBuffDesc.Name = "UAV buffer test"; - TxlBuffDesc.BindFlags = BIND_SHADER_RESOURCE | BIND_UNORDERED_ACCESS; - pDevice->CreateBuffer(TxlBuffDesc, nullptr, &(pFormattedBuff[i])); - - ViewDesc.ViewType = BUFFER_VIEW_UNORDERED_ACCESS; - pFormattedBuff[i]->CreateView(ViewDesc, &(spFormattedBuffUAV[i])); - pFormattedBuffUAV[i] = spFormattedBuffUAV[i]; - - ViewDesc.ViewType = BUFFER_VIEW_SHADER_RESOURCE; - pFormattedBuff[i]->CreateView(ViewDesc, &(spFormattedBuffSRVs[i])); - pFormattedBuffSRVs[i] = spFormattedBuffSRVs[i]; - } - - TxlBuffDesc.Mode = BUFFER_MODE_RAW; - ViewDesc.Format.ValueType = VT_UNDEFINED; - for (size_t i = 0; i < _countof(pRawBuff); ++i) - { - TxlBuffDesc.Name = "Raw buffer test"; - pDevice->CreateBuffer(TxlBuffDesc, nullptr, &(pRawBuff[i])); - spRawBuffUAV[i] = pRawBuff[i]->GetDefaultView(BUFFER_VIEW_UNORDERED_ACCESS); - spRawBuffSRVs[i] = pRawBuff[i]->GetDefaultView(BUFFER_VIEW_SHADER_RESOURCE); - } - } - - RefCntAutoPtr pVS; - { - ShaderCI.Desc.Name = "Shader variable access test VS"; - ShaderCI.Desc.ShaderType = SHADER_TYPE_VERTEX; - ShaderCI.SourceLanguage = SHADER_SOURCE_LANGUAGE_DEFAULT; - ShaderCI.FilePath = pDevice->GetDeviceCaps().IsD3DDevice() ? "ShaderVariableAccessTestDX.vsh" : "ShaderVariableAccessTestGL.vsh"; - - pDevice->CreateShader(ShaderCI, &pVS); - ASSERT_NE(pVS, nullptr); - - Diligent::Test::PrintShaderResources(pVS); - } - - std::vector VarDesc = - { - {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_tex2D_Static", SHADER_RESOURCE_VARIABLE_TYPE_STATIC}, - {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_tex2D_StaticArr", SHADER_RESOURCE_VARIABLE_TYPE_STATIC}, - {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_tex2D_Mut", SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE}, - {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_tex2D_Dyn", SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC}, - {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_tex2D_MutArr", SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE}, - {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_tex2D_DynArr", SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC}, - {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "UniformBuff_Mut", SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE}, - {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "UniformBuff_Dyn", SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC}, - {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_Buffer_Mut", SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE}, - {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_Buffer_MutArr", SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE}, - {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_Buffer_Dyn", SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC}, - {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_Buffer_DynArr", SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC}, - {SHADER_TYPE_PIXEL, "g_rwtex2D_Mut", SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE}, - {SHADER_TYPE_PIXEL, "g_rwtex2D_Dyn", SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC}, - {SHADER_TYPE_PIXEL, "g_rwBuff_Mut", SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE}, - {SHADER_TYPE_PIXEL, "g_rwBuff_Dyn", SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC}, - }; - - StaticSamplerDesc StaticSamplers[] = - { - {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_tex2D_Static", SamplerDesc{}}, - {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_tex2D_StaticArr", SamplerDesc{}}, - {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_tex2D_Mut", SamplerDesc{}}, - {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_tex2D_MutArr", SamplerDesc{}}, - {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_tex2D_Dyn", SamplerDesc{}}, - {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_tex2D_DynArr", SamplerDesc{}}, - }; - - RefCntAutoPtr pPS; - { - ShaderCI.Desc.Name = "Shader variable access test PS"; - ShaderCI.Desc.ShaderType = SHADER_TYPE_PIXEL; - ShaderCI.SourceLanguage = SHADER_SOURCE_LANGUAGE_DEFAULT; - ShaderCI.FilePath = pDevice->GetDeviceCaps().IsD3DDevice() ? "ShaderVariableAccessTestDX.psh" : "ShaderVariableAccessTestGL.psh"; - pDevice->CreateShader(ShaderCI, &pPS); - ASSERT_NE(pPS, nullptr); - - Diligent::Test::PrintShaderResources(pPS); - } - - - PipelineStateDesc PSODesc; - - PSODesc.ResourceLayout.Variables = VarDesc.data(); - PSODesc.ResourceLayout.NumVariables = static_cast(VarDesc.size()); - PSODesc.ResourceLayout.NumStaticSamplers = _countof(StaticSamplers); - PSODesc.ResourceLayout.StaticSamplers = StaticSamplers; - - PSODesc.Name = "Shader variable access test PSO"; - PSODesc.GraphicsPipeline.pVS = pVS; - PSODesc.GraphicsPipeline.pPS = pPS; - PSODesc.GraphicsPipeline.PrimitiveTopology = PRIMITIVE_TOPOLOGY_TRIANGLE_LIST; - PSODesc.GraphicsPipeline.NumRenderTargets = 1; - PSODesc.GraphicsPipeline.RTVFormats[0] = RTVFormat; - PSODesc.GraphicsPipeline.DSVFormat = DSVFormat; - PSODesc.SRBAllocationGranularity = 16; - - RefCntAutoPtr pTestPSO; - pDevice->CreatePipelineState(PSODesc, &pTestPSO); - ASSERT_NE(pTestPSO, nullptr); - - { - EXPECT_EQ(pTestPSO->GetStaticVariableCount(SHADER_TYPE_VERTEX), 6u); - - { - auto tex2D_Static = pTestPSO->GetStaticVariableByName(SHADER_TYPE_VERTEX, "g_tex2D_Static"); - ASSERT_NE(tex2D_Static, nullptr); - EXPECT_EQ(tex2D_Static->GetResourceDesc().ArraySize, 1u); - EXPECT_EQ(tex2D_Static, pTestPSO->GetStaticVariableByName(SHADER_TYPE_VERTEX, tex2D_Static->GetResourceDesc().Name)); - tex2D_Static->Set(pSRVs[0]); - } - - { - auto tex2D_Static_sampler = pTestPSO->GetStaticVariableByName(SHADER_TYPE_VERTEX, "g_tex2D_Static_sampler"); - EXPECT_EQ(tex2D_Static_sampler, nullptr); - } - - { - auto tex2D_StaticArr = pTestPSO->GetStaticVariableByName(SHADER_TYPE_VERTEX, "g_tex2D_StaticArr"); - ASSERT_NE(tex2D_StaticArr, nullptr); - EXPECT_EQ(tex2D_StaticArr->GetResourceDesc().ArraySize, 2u); - EXPECT_EQ(tex2D_StaticArr, pTestPSO->GetStaticVariableByName(SHADER_TYPE_VERTEX, tex2D_StaticArr->GetResourceDesc().Name)); - tex2D_StaticArr->SetArray(pSRVs, 0, 2); - } - - { - auto tex2D_StaticArr_sampler = pTestPSO->GetStaticVariableByName(SHADER_TYPE_VERTEX, "g_tex2D_StaticArr_sampler"); - EXPECT_EQ(tex2D_StaticArr_sampler, nullptr); - } - - { - auto UniformBuff_Stat = pTestPSO->GetStaticVariableByName(SHADER_TYPE_VERTEX, "UniformBuff_Stat"); - ASSERT_NE(UniformBuff_Stat, nullptr); - EXPECT_EQ(UniformBuff_Stat->GetResourceDesc().ArraySize, 1u); - EXPECT_EQ(UniformBuff_Stat, pTestPSO->GetStaticVariableByName(SHADER_TYPE_VERTEX, UniformBuff_Stat->GetResourceDesc().Name)); - UniformBuff_Stat->Set(pUBs[0]); - } - - { - auto UniformBuff_Stat2 = pTestPSO->GetStaticVariableByName(SHADER_TYPE_VERTEX, "UniformBuff_Stat2"); - ASSERT_NE(UniformBuff_Stat2, nullptr); - EXPECT_EQ(UniformBuff_Stat2->GetResourceDesc().ArraySize, 1u); - EXPECT_EQ(UniformBuff_Stat2, pTestPSO->GetStaticVariableByName(SHADER_TYPE_VERTEX, UniformBuff_Stat2->GetResourceDesc().Name)); - UniformBuff_Stat2->Set(pUBs[0]); - } - - { - auto Buffer_Static = pTestPSO->GetStaticVariableByName(SHADER_TYPE_VERTEX, "g_Buffer_Static"); - ASSERT_NE(Buffer_Static, nullptr); - EXPECT_EQ(Buffer_Static->GetResourceDesc().ArraySize, 1u); - EXPECT_EQ(Buffer_Static, pTestPSO->GetStaticVariableByName(SHADER_TYPE_VERTEX, Buffer_Static->GetResourceDesc().Name)); - Buffer_Static->Set(pFormattedBuffSRV); - } - - { - auto Buffer_StaticArr = pTestPSO->GetStaticVariableByName(SHADER_TYPE_VERTEX, "g_Buffer_StaticArr"); - ASSERT_NE(Buffer_StaticArr, nullptr); - EXPECT_EQ(Buffer_StaticArr->GetResourceDesc().ArraySize, 2u); - EXPECT_EQ(Buffer_StaticArr, pTestPSO->GetStaticVariableByName(SHADER_TYPE_VERTEX, Buffer_StaticArr->GetResourceDesc().Name)); - Buffer_StaticArr->SetArray(&pFormattedBuffSRV, 0, 1); - Buffer_StaticArr->SetArray(&pFormattedBuffSRV, 1, 1); - } - - - { - auto tex2D_Mut = pTestPSO->GetStaticVariableByName(SHADER_TYPE_VERTEX, "g_tex2D_Mut"); - EXPECT_EQ(tex2D_Mut, nullptr); - } - { - auto tex2D_Dyn = pTestPSO->GetStaticVariableByName(SHADER_TYPE_VERTEX, "g_tex2D_Dyn"); - EXPECT_EQ(tex2D_Dyn, nullptr); - } - { - auto tex2D_Mut_sampler = pTestPSO->GetStaticVariableByName(SHADER_TYPE_VERTEX, "g_tex2D_Mut_sampler"); - EXPECT_EQ(tex2D_Mut_sampler, nullptr); - } - { - auto tex2D_Dyn_sampler = pTestPSO->GetStaticVariableByName(SHADER_TYPE_VERTEX, "g_tex2D_DynArr_sampler"); - EXPECT_EQ(tex2D_Dyn_sampler, nullptr); - } - - - - auto NumVSVars = pTestPSO->GetStaticVariableCount(SHADER_TYPE_VERTEX); - for (Uint32 v = 0; v < NumVSVars; ++v) - { - auto pVar = pTestPSO->GetStaticVariableByIndex(SHADER_TYPE_VERTEX, v); - EXPECT_EQ(pVar->GetIndex(), v); - EXPECT_EQ(pVar->GetType(), SHADER_RESOURCE_VARIABLE_TYPE_STATIC); - auto pVar2 = pTestPSO->GetStaticVariableByName(SHADER_TYPE_VERTEX, pVar->GetResourceDesc().Name); - EXPECT_EQ(pVar, pVar2); - } - } - - - { - EXPECT_EQ(pTestPSO->GetStaticVariableCount(SHADER_TYPE_PIXEL), 9u); - - { - auto tex2D_Static = pTestPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, "g_tex2D_Static"); - ASSERT_NE(tex2D_Static, nullptr); - EXPECT_EQ(tex2D_Static->GetResourceDesc().ArraySize, 1u); - EXPECT_EQ(tex2D_Static, pTestPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, tex2D_Static->GetResourceDesc().Name)); - tex2D_Static->Set(pSRVs[0]); - } - - { - auto tex2D_Static_sampler = pTestPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, "g_tex2D_Static_sampler"); - EXPECT_EQ(tex2D_Static_sampler, nullptr); - } - - { - auto tex2D_StaticArr = pTestPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, "g_tex2D_StaticArr"); - ASSERT_NE(tex2D_StaticArr, nullptr); - EXPECT_EQ(tex2D_StaticArr->GetResourceDesc().ArraySize, 2u); - EXPECT_EQ(tex2D_StaticArr, pTestPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, tex2D_StaticArr->GetResourceDesc().Name)); - tex2D_StaticArr->SetArray(pSRVs, 0, 2); - } - { - auto tex2D_StaticArr_sampler = pTestPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, "g_tex2D_StaticArr_sampler"); - EXPECT_EQ(tex2D_StaticArr_sampler, nullptr); - } - - { - auto UniformBuff_Stat = pTestPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, "UniformBuff_Stat"); - ASSERT_NE(UniformBuff_Stat, nullptr); - EXPECT_EQ(UniformBuff_Stat->GetResourceDesc().ArraySize, 1u); - EXPECT_EQ(UniformBuff_Stat, pTestPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, UniformBuff_Stat->GetResourceDesc().Name)); - UniformBuff_Stat->Set(pUBs[0]); - } - - { - auto UniformBuff_Stat2 = pTestPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, "UniformBuff_Stat2"); - ASSERT_NE(UniformBuff_Stat2, nullptr); - EXPECT_EQ(UniformBuff_Stat2->GetResourceDesc().ArraySize, 1u); - EXPECT_EQ(UniformBuff_Stat2, pTestPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, UniformBuff_Stat2->GetResourceDesc().Name)); - UniformBuff_Stat2->Set(pUBs[0]); - } - - { - auto Buffer_Static = pTestPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, "g_Buffer_Static"); - ASSERT_NE(Buffer_Static, nullptr); - EXPECT_EQ(Buffer_Static->GetResourceDesc().ArraySize, 1u); - EXPECT_EQ(Buffer_Static, pTestPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, Buffer_Static->GetResourceDesc().Name)); - Buffer_Static->Set(pFormattedBuffSRV); - } - - { - auto Buffer_StaticArr = pTestPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, "g_Buffer_StaticArr"); - ASSERT_NE(Buffer_StaticArr, nullptr); - EXPECT_EQ(Buffer_StaticArr->GetResourceDesc().ArraySize, 2u); - EXPECT_EQ(Buffer_StaticArr, pTestPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, Buffer_StaticArr->GetResourceDesc().Name)); - Buffer_StaticArr->SetArray(&pFormattedBuffSRV, 0, 1); - Buffer_StaticArr->SetArray(&pFormattedBuffSRV, 1, 1); - } - - - { - auto rwtex2D_Static = pTestPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, "g_rwtex2D_Static"); - ASSERT_NE(rwtex2D_Static, nullptr); - EXPECT_EQ(rwtex2D_Static->GetResourceDesc().ArraySize, 1u); - EXPECT_EQ(rwtex2D_Static, pTestPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, rwtex2D_Static->GetResourceDesc().Name)); - rwtex2D_Static->Set(pTexUAVs[0]); - } - - - { - auto rwtex2D_Static2 = pTestPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, "g_rwtex2D_Static2"); - ASSERT_NE(rwtex2D_Static2, nullptr); - EXPECT_EQ(rwtex2D_Static2->GetResourceDesc().ArraySize, 1u); - EXPECT_EQ(rwtex2D_Static2, pTestPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, rwtex2D_Static2->GetResourceDesc().Name)); - rwtex2D_Static2->Set(pTexUAVs[1]); - } - - { - auto rwBuff_Static = pTestPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, "g_rwBuff_Static"); - ASSERT_NE(rwBuff_Static, nullptr); - EXPECT_EQ(rwBuff_Static->GetResourceDesc().ArraySize, 1u); - EXPECT_EQ(rwBuff_Static, pTestPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, rwBuff_Static->GetResourceDesc().Name)); - rwBuff_Static->Set(spRawBuffUAV[0]); - } - - - { - auto tex2D_Mut = pTestPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, "g_tex2D_Mut"); - EXPECT_EQ(tex2D_Mut, nullptr); - } - { - auto tex2D_Dyn = pTestPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, "g_tex2D_Dyn"); - EXPECT_EQ(tex2D_Dyn, nullptr); - } - { - auto tex2D_Mut_sampler = pTestPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, "g_tex2D_Mut_sampler"); - EXPECT_EQ(tex2D_Mut_sampler, nullptr); - } - { - auto tex2D_Dyn_sampler = pTestPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, "g_tex2D_DynArr_sampler"); - EXPECT_EQ(tex2D_Dyn_sampler, nullptr); - } - - - auto NumPSVars = pTestPSO->GetStaticVariableCount(SHADER_TYPE_PIXEL); - for (Uint32 v = 0; v < NumPSVars; ++v) - { - auto pVar = pTestPSO->GetStaticVariableByIndex(SHADER_TYPE_PIXEL, v); - EXPECT_EQ(pVar->GetIndex(), v); - EXPECT_EQ(pVar->GetType(), SHADER_RESOURCE_VARIABLE_TYPE_STATIC); - auto pVar2 = pTestPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, pVar->GetResourceDesc().Name); - EXPECT_EQ(pVar, pVar2); - } - } - - RefCntAutoPtr pSRB; - pTestPSO->CreateShaderResourceBinding(&pSRB, true); - ASSERT_NE(pSRB, nullptr); - - { - { - auto tex2D_Mut = pSRB->GetVariableByName(SHADER_TYPE_VERTEX, "g_tex2D_Mut"); - ASSERT_NE(tex2D_Mut, nullptr); - EXPECT_EQ(tex2D_Mut->GetResourceDesc().ArraySize, 1u); - EXPECT_EQ(tex2D_Mut, pSRB->GetVariableByName(SHADER_TYPE_VERTEX, tex2D_Mut->GetResourceDesc().Name)); - tex2D_Mut->Set(pSRVs[0]); - } - - { - auto tex2D_Mut_sampler = pSRB->GetVariableByName(SHADER_TYPE_VERTEX, "g_tex2D_Mut_sampler"); - EXPECT_EQ(tex2D_Mut_sampler, nullptr); - } - - { - auto tex2D_MutArr = pSRB->GetVariableByName(SHADER_TYPE_VERTEX, "g_tex2D_MutArr"); - ASSERT_NE(tex2D_MutArr, nullptr); - EXPECT_EQ(tex2D_MutArr->GetResourceDesc().ArraySize, 2u); - EXPECT_EQ(tex2D_MutArr, pSRB->GetVariableByName(SHADER_TYPE_VERTEX, tex2D_MutArr->GetResourceDesc().Name)); - tex2D_MutArr->SetArray(pSRVs, 0, 2); - } - - { - auto tex2D_MutArr_sampler = pSRB->GetVariableByName(SHADER_TYPE_VERTEX, "g_tex2D_MutArr_sampler"); - EXPECT_EQ(tex2D_MutArr_sampler, nullptr); - } - - { - auto tex2D_Dyn = pSRB->GetVariableByName(SHADER_TYPE_VERTEX, "g_tex2D_Dyn"); - ASSERT_NE(tex2D_Dyn, nullptr); - EXPECT_EQ(tex2D_Dyn->GetResourceDesc().ArraySize, 1u); - EXPECT_EQ(tex2D_Dyn, pSRB->GetVariableByName(SHADER_TYPE_VERTEX, tex2D_Dyn->GetResourceDesc().Name)); - tex2D_Dyn->Set(pSRVs[0]); - } - - { - auto tex2D_Dyn_sampler = pSRB->GetVariableByName(SHADER_TYPE_VERTEX, "g_tex2D_Dyn_sampler"); - EXPECT_EQ(tex2D_Dyn_sampler, nullptr); - } - - { - auto tex2D_DynArr = pSRB->GetVariableByName(SHADER_TYPE_VERTEX, "g_tex2D_DynArr"); - ASSERT_NE(tex2D_DynArr, nullptr); - EXPECT_EQ(tex2D_DynArr->GetResourceDesc().ArraySize, 2u); - EXPECT_EQ(tex2D_DynArr, pSRB->GetVariableByName(SHADER_TYPE_VERTEX, tex2D_DynArr->GetResourceDesc().Name)); - tex2D_DynArr->SetArray(pSRVs, 0, 2); - } - - { - auto tex2D_DynArr_sampler = pSRB->GetVariableByName(SHADER_TYPE_VERTEX, "g_tex2D_DynArr_sampler"); - EXPECT_EQ(tex2D_DynArr_sampler, nullptr); - } - - { - auto UniformBuff_Mut = pSRB->GetVariableByName(SHADER_TYPE_VERTEX, "UniformBuff_Mut"); - ASSERT_NE(UniformBuff_Mut, nullptr); - EXPECT_EQ(UniformBuff_Mut->GetResourceDesc().ArraySize, 1u); - EXPECT_EQ(UniformBuff_Mut, pSRB->GetVariableByName(SHADER_TYPE_VERTEX, UniformBuff_Mut->GetResourceDesc().Name)); - UniformBuff_Mut->Set(pUBs[0]); - } - - { - auto UniformBuff_Dyn = pSRB->GetVariableByName(SHADER_TYPE_VERTEX, "UniformBuff_Dyn"); - ASSERT_NE(UniformBuff_Dyn, nullptr); - EXPECT_EQ(UniformBuff_Dyn->GetResourceDesc().ArraySize, 1u); - EXPECT_EQ(UniformBuff_Dyn, pSRB->GetVariableByName(SHADER_TYPE_VERTEX, UniformBuff_Dyn->GetResourceDesc().Name)); - UniformBuff_Dyn->Set(pUBs[0]); - } - - { - auto Buffer_Mut = pSRB->GetVariableByName(SHADER_TYPE_VERTEX, "g_Buffer_Mut"); - ASSERT_NE(Buffer_Mut, nullptr); - EXPECT_EQ(Buffer_Mut->GetResourceDesc().ArraySize, 1u); - EXPECT_EQ(Buffer_Mut, pSRB->GetVariableByName(SHADER_TYPE_VERTEX, Buffer_Mut->GetResourceDesc().Name)); - Buffer_Mut->Set(pFormattedBuffSRV); - } - - { - auto Buffer_MutArr = pSRB->GetVariableByName(SHADER_TYPE_VERTEX, "g_Buffer_MutArr"); - ASSERT_NE(Buffer_MutArr, nullptr); - EXPECT_EQ(Buffer_MutArr->GetResourceDesc().ArraySize, 2u); - EXPECT_EQ(Buffer_MutArr, pSRB->GetVariableByName(SHADER_TYPE_VERTEX, Buffer_MutArr->GetResourceDesc().Name)); - Buffer_MutArr->SetArray(&pFormattedBuffSRV, 0, 1); - Buffer_MutArr->SetArray(&pFormattedBuffSRV, 1, 1); - } - - { - auto Buffer_Dyn = pSRB->GetVariableByName(SHADER_TYPE_VERTEX, "g_Buffer_Dyn"); - ASSERT_NE(Buffer_Dyn, nullptr); - EXPECT_EQ(Buffer_Dyn->GetResourceDesc().ArraySize, 1u); - EXPECT_EQ(Buffer_Dyn, pSRB->GetVariableByName(SHADER_TYPE_VERTEX, Buffer_Dyn->GetResourceDesc().Name)); - Buffer_Dyn->Set(pFormattedBuffSRV); - } - - { - auto Buffer_DynArr = pSRB->GetVariableByName(SHADER_TYPE_VERTEX, "g_Buffer_DynArr"); - ASSERT_NE(Buffer_DynArr, nullptr); - EXPECT_EQ(Buffer_DynArr->GetResourceDesc().ArraySize, 2u); - EXPECT_EQ(Buffer_DynArr, pSRB->GetVariableByName(SHADER_TYPE_VERTEX, Buffer_DynArr->GetResourceDesc().Name)); - Buffer_DynArr->SetArray(&pFormattedBuffSRV, 0, 1); - Buffer_DynArr->SetArray(&pFormattedBuffSRV, 1, 1); - } - - { - auto tex2D_Static = pSRB->GetVariableByName(SHADER_TYPE_VERTEX, "g_tex2D_Static"); - EXPECT_EQ(tex2D_Static, nullptr); - } - - auto UniformBuff_Stat = pSRB->GetVariableByName(SHADER_TYPE_VERTEX, "UniformBuff_Stat"); - EXPECT_EQ(UniformBuff_Stat, nullptr); - } - - - - { - { - auto tex2D_Mut = pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_tex2D_Mut"); - ASSERT_NE(tex2D_Mut, nullptr); - EXPECT_EQ(tex2D_Mut->GetResourceDesc().ArraySize, 1u); - EXPECT_EQ(tex2D_Mut, pSRB->GetVariableByName(SHADER_TYPE_PIXEL, tex2D_Mut->GetResourceDesc().Name)); - tex2D_Mut->Set(pRWTexSRVs[4]); - } - - { - auto tex2D_Mut_sampler = pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_tex2D_Mut_sampler"); - EXPECT_EQ(tex2D_Mut_sampler, nullptr); - } - - { - auto tex2D_MutArr = pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_tex2D_MutArr"); - ASSERT_NE(tex2D_MutArr, nullptr); - EXPECT_EQ(tex2D_MutArr->GetResourceDesc().ArraySize, 2u); - EXPECT_EQ(tex2D_MutArr, pSRB->GetVariableByName(SHADER_TYPE_PIXEL, tex2D_MutArr->GetResourceDesc().Name)); - tex2D_MutArr->SetArray(pRWTexSRVs + 5, 0, 2); - } - - { - auto tex2D_MutArr_sampler = pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_tex2D_MutArr_sampler"); - EXPECT_EQ(tex2D_MutArr_sampler, nullptr); - } - - { - auto tex2D_Dyn = pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_tex2D_Dyn"); - ASSERT_NE(tex2D_Dyn, nullptr); - EXPECT_EQ(tex2D_Dyn->GetResourceDesc().ArraySize, 1u); - EXPECT_EQ(tex2D_Dyn, pSRB->GetVariableByName(SHADER_TYPE_PIXEL, tex2D_Dyn->GetResourceDesc().Name)); - tex2D_Dyn->Set(pRWTexSRVs[7]); - } - - { - auto tex2D_Dyn_sampler = pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_tex2D_Dyn_sampler"); - EXPECT_EQ(tex2D_Dyn_sampler, nullptr); - } - - { - auto tex2D_DynArr = pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_tex2D_DynArr"); - ASSERT_NE(tex2D_DynArr, nullptr); - EXPECT_EQ(tex2D_DynArr->GetResourceDesc().ArraySize, 2u); - EXPECT_EQ(tex2D_DynArr, pSRB->GetVariableByName(SHADER_TYPE_PIXEL, tex2D_DynArr->GetResourceDesc().Name)); - tex2D_DynArr->SetArray(pSRVs, 0, 2); - } - - { - auto tex2D_DynArr_sampler = pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_tex2D_DynArr_sampler"); - EXPECT_EQ(tex2D_DynArr_sampler, nullptr); - } - - - { - auto UniformBuff_Mut = pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "UniformBuff_Mut"); - ASSERT_NE(UniformBuff_Mut, nullptr); - EXPECT_EQ(UniformBuff_Mut->GetResourceDesc().ArraySize, 1u); - EXPECT_EQ(UniformBuff_Mut, pSRB->GetVariableByName(SHADER_TYPE_PIXEL, UniformBuff_Mut->GetResourceDesc().Name)); - UniformBuff_Mut->Set(pUBs[0]); - } - - { - auto UniformBuff_Dyn = pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "UniformBuff_Dyn"); - ASSERT_NE(UniformBuff_Dyn, nullptr); - EXPECT_EQ(UniformBuff_Dyn->GetResourceDesc().ArraySize, 1u); - EXPECT_EQ(UniformBuff_Dyn, pSRB->GetVariableByName(SHADER_TYPE_PIXEL, UniformBuff_Dyn->GetResourceDesc().Name)); - UniformBuff_Dyn->Set(pUBs[0]); - } - - { - auto Buffer_Mut = pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_Buffer_Mut"); - ASSERT_NE(Buffer_Mut, nullptr); - EXPECT_EQ(Buffer_Mut->GetResourceDesc().ArraySize, 1u); - EXPECT_EQ(Buffer_Mut, pSRB->GetVariableByName(SHADER_TYPE_PIXEL, Buffer_Mut->GetResourceDesc().Name)); - Buffer_Mut->Set(spRawBuffSRVs[1]); - } - - { - auto Buffer_MutArr = pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_Buffer_MutArr"); - ASSERT_NE(Buffer_MutArr, nullptr); - EXPECT_EQ(Buffer_MutArr->GetResourceDesc().ArraySize, 2u); - EXPECT_EQ(Buffer_MutArr, pSRB->GetVariableByName(SHADER_TYPE_PIXEL, Buffer_MutArr->GetResourceDesc().Name)); - Buffer_MutArr->SetArray(&pFormattedBuffSRV, 0, 1); - Buffer_MutArr->SetArray(&pFormattedBuffSRV, 1, 1); - } - - { - auto Buffer_Dyn = pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_Buffer_Dyn"); - ASSERT_NE(Buffer_Dyn, nullptr); - EXPECT_EQ(Buffer_Dyn->GetResourceDesc().ArraySize, 1u); - EXPECT_EQ(Buffer_Dyn, pSRB->GetVariableByName(SHADER_TYPE_PIXEL, Buffer_Dyn->GetResourceDesc().Name)); - Buffer_Dyn->Set(pFormattedBuffSRVs[3]); - } - - { - auto Buffer_DynArr = pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_Buffer_DynArr"); - ASSERT_NE(Buffer_DynArr, nullptr); - EXPECT_EQ(Buffer_DynArr->GetResourceDesc().ArraySize, 2u); - EXPECT_EQ(Buffer_DynArr, pSRB->GetVariableByName(SHADER_TYPE_PIXEL, Buffer_DynArr->GetResourceDesc().Name)); - Buffer_DynArr->SetArray(&pFormattedBuffSRV, 0, 1); - Buffer_DynArr->SetArray(&pFormattedBuffSRV, 1, 1); - } - - { - auto rwtex2D_Mut = pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_rwtex2D_Mut"); - ASSERT_NE(rwtex2D_Mut, nullptr); - EXPECT_EQ(rwtex2D_Mut->GetResourceDesc().ArraySize, 1u); - EXPECT_EQ(rwtex2D_Mut, pSRB->GetVariableByName(SHADER_TYPE_PIXEL, rwtex2D_Mut->GetResourceDesc().Name)); - rwtex2D_Mut->Set(pTexUAVs[2]); - } - - { - auto rwtex2D_Dyn = pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_rwtex2D_Dyn"); - ASSERT_NE(rwtex2D_Dyn, nullptr); - EXPECT_EQ(rwtex2D_Dyn->GetResourceDesc().ArraySize, 1u); - EXPECT_EQ(rwtex2D_Dyn, pSRB->GetVariableByName(SHADER_TYPE_PIXEL, rwtex2D_Dyn->GetResourceDesc().Name)); - rwtex2D_Dyn->Set(pTexUAVs[3]); - } - - { - auto rwBuff_Mut = pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_rwBuff_Mut"); - ASSERT_NE(rwBuff_Mut, nullptr); - EXPECT_EQ(rwBuff_Mut->GetResourceDesc().ArraySize, 1u); - EXPECT_EQ(rwBuff_Mut, pSRB->GetVariableByName(SHADER_TYPE_PIXEL, rwBuff_Mut->GetResourceDesc().Name)); - rwBuff_Mut->Set(pFormattedBuffUAV[1]); - } - - { - auto rwBuff_Dyn = pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_rwBuff_Dyn"); - ASSERT_NE(rwBuff_Dyn, nullptr); - EXPECT_EQ(rwBuff_Dyn->GetResourceDesc().ArraySize, 1u); - EXPECT_EQ(rwBuff_Dyn, pSRB->GetVariableByName(SHADER_TYPE_PIXEL, rwBuff_Dyn->GetResourceDesc().Name)); - rwBuff_Dyn->Set(pFormattedBuffUAV[2]); - } - - { - auto tex2D_Static = pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_tex2D_Static"); - EXPECT_EQ(tex2D_Static, nullptr); - } - - auto UniformBuff_Stat = pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "UniformBuff_Stat"); - EXPECT_EQ(UniformBuff_Stat, nullptr); - } - - - - { - auto NumVSVars = pSRB->GetVariableCount(SHADER_TYPE_VERTEX); - for (Uint32 v = 0; v < NumVSVars; ++v) - { - auto pVar = pSRB->GetVariableByIndex(SHADER_TYPE_VERTEX, v); - EXPECT_EQ(pVar->GetIndex(), v); - EXPECT_TRUE(pVar->GetType() == SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE || pVar->GetType() == SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC); - auto pVar2 = pSRB->GetVariableByName(SHADER_TYPE_VERTEX, pVar->GetResourceDesc().Name); - EXPECT_EQ(pVar, pVar2); - } - } - - { - auto NumPSVars = pSRB->GetVariableCount(SHADER_TYPE_PIXEL); - for (Uint32 v = 0; v < NumPSVars; ++v) - { - auto pVar = pSRB->GetVariableByIndex(SHADER_TYPE_PIXEL, v); - EXPECT_EQ(pVar->GetIndex(), v); - EXPECT_TRUE(pVar->GetType() == SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE || pVar->GetType() == SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC); - auto pVar2 = pSRB->GetVariableByName(SHADER_TYPE_PIXEL, pVar->GetResourceDesc().Name); - EXPECT_EQ(pVar, pVar2); - } - } - - pContext->SetRenderTargets(1, &pRTV, pDSV, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); - - pContext->SetPipelineState(pTestPSO); - pContext->CommitShaderResources(pSRB, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); - - DrawAttribs DrawAttrs(3, DRAW_FLAG_VERIFY_ALL); - pContext->Draw(DrawAttrs); - - pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_rwtex2D_Dyn")->Set(pTexUAVs[7]); - pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_tex2D_Dyn")->Set(pRWTexSRVs[3]); - pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_rwBuff_Dyn")->Set(pFormattedBuffUAV[3]); - pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_Buffer_Dyn")->Set(pFormattedBuffSRVs[2]); - - { - LOG_INFO_MESSAGE("No worries about 3 warnings below: testing accessing variables from inactive shader stage"); - auto pNonExistingVar = pSRB->GetVariableByName(SHADER_TYPE_GEOMETRY, "g_NonExistingVar"); - EXPECT_EQ(pNonExistingVar, nullptr); - pNonExistingVar = pSRB->GetVariableByIndex(SHADER_TYPE_GEOMETRY, 4); - EXPECT_EQ(pNonExistingVar, nullptr); - EXPECT_EQ(pSRB->GetVariableCount(SHADER_TYPE_GEOMETRY), 0u); - } - - float Zero[4] = {}; - pContext->ClearRenderTarget(pRTV, Zero, RESOURCE_STATE_TRANSITION_MODE_VERIFY); - pContext->ClearDepthStencil(pDSV, CLEAR_DEPTH_FLAG, 1, 0, RESOURCE_STATE_TRANSITION_MODE_VERIFY); - - pContext->CommitShaderResources(pSRB, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); - pContext->Draw(DrawAttrs); -} - -} // namespace diff --git a/UnitTests/DiligentCoreAPITest/src/TestingEnvironment.cpp b/UnitTests/DiligentCoreAPITest/src/TestingEnvironment.cpp deleted file mode 100644 index dca742a8..00000000 --- a/UnitTests/DiligentCoreAPITest/src/TestingEnvironment.cpp +++ /dev/null @@ -1,406 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "TestingEnvironment.h" -#include "PlatformDebug.h" -#include "TestingSwapChainBase.h" - -#if D3D11_SUPPORTED -# include "EngineFactoryD3D11.h" -#endif - -#if D3D12_SUPPORTED -# include "EngineFactoryD3D12.h" -#endif - -#if GL_SUPPORTED || GLES_SUPPORTED -# include "EngineFactoryOpenGL.h" -#endif - -#if VULKAN_SUPPORTED -# include "EngineFactoryVk.h" -#endif - -#if METAL_SUPPORTED -# include "EngineFactoryMtl.h" -#endif - -namespace Diligent -{ - -namespace Testing -{ - -TestingEnvironment* TestingEnvironment::m_pTheEnvironment = nullptr; -std::atomic_int TestingEnvironment::m_NumAllowedErrors; - -void TestingEnvironment::MessageCallback(DebugMessageSeverity Severity, - const Char* Message, - const char* Function, - const char* File, - int Line) -{ - if (Severity == DebugMessageSeverity::Error || Severity == DebugMessageSeverity::FatalError) - { - if (m_NumAllowedErrors == 0) - { - ADD_FAILURE() << "Unexpected error"; - } - else - { - m_NumAllowedErrors--; - } - } - - PlatformDebug::OutputDebugMessage(Severity, Message, Function, File, Line); -} - -void TestingEnvironment::SetErrorAllowance(int NumErrorsToAllow, const char* InfoMessage) -{ - m_NumAllowedErrors = NumErrorsToAllow; - if (InfoMessage != nullptr) - { - std::cout << InfoMessage; - } -} - - -TestingEnvironment::TestingEnvironment(DeviceType deviceType, ADAPTER_TYPE AdapterType, const SwapChainDesc& SCDesc) : - m_DeviceType{deviceType} -{ - VERIFY(m_pTheEnvironment == nullptr, "Testing environment object has already been initialized!"); - m_pTheEnvironment = this; - - Uint32 NumDeferredCtx = 0; - - std::vector ppContexts; - std::vector Adapters; - - auto PrintAdapterInfo = [](Uint32 AdapterId, const AdapterAttribs& AdapterInfo, const std::vector& DisplayModes) // - { - const char* AdapterTypeStr = nullptr; - switch (AdapterInfo.AdapterType) - { - case ADAPTER_TYPE_HARDWARE: AdapterTypeStr = "HW"; break; - case ADAPTER_TYPE_SOFTWARE: AdapterTypeStr = "SW"; break; - default: AdapterTypeStr = "Type unknown"; - } - LOG_INFO_MESSAGE("Adapter ", AdapterId, ": '", AdapterInfo.Description, "' (", - AdapterTypeStr, ", ", AdapterInfo.DedicatedVideoMemory / (1 << 20), " MB); ", - DisplayModes.size(), (DisplayModes.size() == 1 ? " display mode" : " display modes")); - }; - switch (m_DeviceType) - { -#if D3D11_SUPPORTED - case DeviceType::D3D11: - { -# if ENGINE_DLL - GetEngineFactoryD3D11Type GetEngineFactoryD3D11 = nullptr; - // Load the dll and import GetEngineFactoryD3D11() function - LoadGraphicsEngineD3D11(GetEngineFactoryD3D11); - if (GetEngineFactoryD3D11 == nullptr) - { - LOG_ERROR_AND_THROW("Failed to load the engine"); - } -# endif - - EngineD3D11CreateInfo CreateInfo; - CreateInfo.DebugMessageCallback = MessageCallback; - -# ifdef _DEBUG - CreateInfo.DebugFlags = - D3D11_DEBUG_FLAG_CREATE_DEBUG_DEVICE | - D3D11_DEBUG_FLAG_VERIFY_COMMITTED_RESOURCE_RELEVANCE | - D3D11_DEBUG_FLAG_VERIFY_COMMITTED_SHADER_RESOURCES; -# endif - auto* pFactoryD3D11 = GetEngineFactoryD3D11(); - Uint32 NumAdapters = 0; - pFactoryD3D11->EnumerateAdapters(DIRECT3D_FEATURE_LEVEL_11_0, NumAdapters, 0); - Adapters.resize(NumAdapters); - pFactoryD3D11->EnumerateAdapters(DIRECT3D_FEATURE_LEVEL_11_0, NumAdapters, Adapters.data()); - - LOG_INFO_MESSAGE("Found ", Adapters.size(), " compatible adapters"); - for (Uint32 i = 0; i < Adapters.size(); ++i) - { - const auto& AdapterInfo = Adapters[i]; - - std::vector DisplayModes; - if (AdapterInfo.NumOutputs > 0) - { - Uint32 NumDisplayModes = 0; - pFactoryD3D11->EnumerateDisplayModes(DIRECT3D_FEATURE_LEVEL_11_0, i, 0, TEX_FORMAT_RGBA8_UNORM, NumDisplayModes, nullptr); - DisplayModes.resize(NumDisplayModes); - pFactoryD3D11->EnumerateDisplayModes(DIRECT3D_FEATURE_LEVEL_11_0, i, 0, TEX_FORMAT_RGBA8_UNORM, NumDisplayModes, DisplayModes.data()); - } - - PrintAdapterInfo(i, AdapterInfo, DisplayModes); - } - if (AdapterType != ADAPTER_TYPE_UNKNOWN) - { - for (Uint32 i = 0; i < Adapters.size(); ++i) - { - if (Adapters[i].AdapterType == AdapterType && - CreateInfo.AdapterId == EngineD3D11CreateInfo::DefaultAdapterId) - { - CreateInfo.AdapterId = i; - LOG_INFO_MESSAGE("Using adapter ", i, ": '", Adapters[i].Description, "'"); - break; - } - } - } - - - CreateInfo.NumDeferredContexts = NumDeferredCtx; - ppContexts.resize(1 + NumDeferredCtx); - pFactoryD3D11->CreateDeviceAndContextsD3D11(CreateInfo, &m_pDevice, ppContexts.data()); - } - break; -#endif - -#if D3D12_SUPPORTED - case DeviceType::D3D12: - { -# if ENGINE_DLL - GetEngineFactoryD3D12Type GetEngineFactoryD3D12 = nullptr; - // Load the dll and import GetEngineFactoryD3D12() function - LoadGraphicsEngineD3D12(GetEngineFactoryD3D12); - if (GetEngineFactoryD3D12 == nullptr) - { - LOG_ERROR_AND_THROW("Failed to load the engine"); - } -# endif - auto* pFactoryD3D12 = GetEngineFactoryD3D12(); - - Uint32 NumAdapters = 0; - pFactoryD3D12->EnumerateAdapters(DIRECT3D_FEATURE_LEVEL_11_0, NumAdapters, 0); - Adapters.resize(NumAdapters); - pFactoryD3D12->EnumerateAdapters(DIRECT3D_FEATURE_LEVEL_11_0, NumAdapters, Adapters.data()); - - EngineD3D12CreateInfo CreateInfo; - CreateInfo.DebugMessageCallback = MessageCallback; - - LOG_INFO_MESSAGE("Found ", Adapters.size(), " compatible adapters"); - for (Uint32 i = 0; i < Adapters.size(); ++i) - { - const auto& AdapterInfo = Adapters[i]; - - std::vector DisplayModes; - if (AdapterInfo.NumOutputs > 0) - { - Uint32 NumDisplayModes = 0; - pFactoryD3D12->EnumerateDisplayModes(DIRECT3D_FEATURE_LEVEL_11_0, i, 0, TEX_FORMAT_RGBA8_UNORM, NumDisplayModes, nullptr); - DisplayModes.resize(NumDisplayModes); - pFactoryD3D12->EnumerateDisplayModes(DIRECT3D_FEATURE_LEVEL_11_0, i, 0, TEX_FORMAT_RGBA8_UNORM, NumDisplayModes, DisplayModes.data()); - } - - PrintAdapterInfo(i, AdapterInfo, DisplayModes); - } - if (AdapterType != ADAPTER_TYPE_UNKNOWN) - { - for (Uint32 i = 0; i < Adapters.size(); ++i) - { - if (Adapters[i].AdapterType == AdapterType && - CreateInfo.AdapterId == EngineD3D11CreateInfo::DefaultAdapterId) - { - CreateInfo.AdapterId = i; - LOG_INFO_MESSAGE("Using adapter ", i, ": '", Adapters[i].Description, "'"); - break; - } - } - } - CreateInfo.EnableDebugLayer = true; - //CreateInfo.EnableGPUBasedValidation = true; - CreateInfo.CPUDescriptorHeapAllocationSize[0] = 64; // D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV - CreateInfo.CPUDescriptorHeapAllocationSize[1] = 32; // D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER - CreateInfo.CPUDescriptorHeapAllocationSize[2] = 16; // D3D12_DESCRIPTOR_HEAP_TYPE_RTV - CreateInfo.CPUDescriptorHeapAllocationSize[3] = 16; // D3D12_DESCRIPTOR_HEAP_TYPE_DSV - CreateInfo.DynamicDescriptorAllocationChunkSize[0] = 8; // D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV - CreateInfo.DynamicDescriptorAllocationChunkSize[1] = 8; // D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER - ppContexts.resize(1 + NumDeferredCtx); - - CreateInfo.NumDeferredContexts = NumDeferredCtx; - pFactoryD3D12->CreateDeviceAndContextsD3D12(CreateInfo, &m_pDevice, ppContexts.data()); - } - break; -#endif - -#if GL_SUPPORTED || GLES_SUPPORTED - case DeviceType::OpenGL: - case DeviceType::OpenGLES: - { -# if EXPLICITLY_LOAD_ENGINE_GL_DLL - // Declare function pointer - GetEngineFactoryOpenGLType GetEngineFactoryOpenGL = nullptr; - // Load the dll and import GetEngineFactoryOpenGL() function - LoadGraphicsEngineOpenGL(GetEngineFactoryOpenGL); - if (GetEngineFactoryOpenGL == nullptr) - { - LOG_ERROR_AND_THROW("Failed to load the engine"); - } -# endif - auto* pFactoryOpenGL = GetEngineFactoryOpenGL(); - - auto NativeWnd = CreateNativeWindow(); - - EngineGLCreateInfo CreateInfo; - CreateInfo.DebugMessageCallback = MessageCallback; - CreateInfo.pNativeWndHandle = NativeWnd.NativeWindowHandle; -# if PLATFORM_LINUX - CreateInfo.pDisplay = NativeWnd.Display; -# endif - if (NumDeferredCtx != 0) - { - LOG_ERROR_MESSAGE("Deferred contexts are not supported in OpenGL mode"); - NumDeferredCtx = 0; - } - ppContexts.resize(1 + NumDeferredCtx); - RefCntAutoPtr pSwapChain; // We will use testing swap chain instead - pFactoryOpenGL->CreateDeviceAndSwapChainGL( - CreateInfo, &m_pDevice, ppContexts.data(), SCDesc, &pSwapChain); - } - break; -#endif - -#if VULKAN_SUPPORTED - case DeviceType::Vulkan: - { -# if EXPLICITLY_LOAD_ENGINE_VK_DLL - GetEngineFactoryVkType GetEngineFactoryVk = nullptr; - // Load the dll and import GetEngineFactoryVk() function - LoadGraphicsEngineVk(GetEngineFactoryVk); - if (GetEngineFactoryVk == nullptr) - { - LOG_ERROR_AND_THROW("Failed to load the engine"); - } -# endif - - EngineVkCreateInfo CreateInfo; - CreateInfo.DebugMessageCallback = MessageCallback; - CreateInfo.EnableValidation = true; - CreateInfo.MainDescriptorPoolSize = EngineVkCreateInfo::DescriptorPoolSize{64, 64, 256, 256, 64, 32, 32, 32, 32}; - CreateInfo.DynamicDescriptorPoolSize = EngineVkCreateInfo::DescriptorPoolSize{64, 64, 256, 256, 64, 32, 32, 32, 32}; - CreateInfo.UploadHeapPageSize = 32 * 1024; - //CreateInfo.DeviceLocalMemoryReserveSize = 32 << 20; - //CreateInfo.HostVisibleMemoryReserveSize = 48 << 20; - - auto& Features = CreateInfo.EnabledFeatures; - Features.depthBiasClamp = true; - Features.fillModeNonSolid = true; - Features.depthClamp = true; - Features.independentBlend = true; - Features.samplerAnisotropy = true; - Features.geometryShader = true; - Features.tessellationShader = true; - Features.dualSrcBlend = true; - Features.multiViewport = true; - Features.imageCubeArray = true; - Features.textureCompressionBC = true; - Features.vertexPipelineStoresAndAtomics = true; - Features.fragmentStoresAndAtomics = true; - - CreateInfo.NumDeferredContexts = NumDeferredCtx; - ppContexts.resize(1 + NumDeferredCtx); - auto* pFactoryVk = GetEngineFactoryVk(); - pFactoryVk->CreateDeviceAndContextsVk(CreateInfo, &m_pDevice, ppContexts.data()); - } - break; -#endif - -#if METAL_SUPPORTED - case DeviceType::Metal: - { - EngineMtlCreateInfo MtlAttribs; - - MtlAttribs.DebugMessageCallback = MessageCallback; - MtlAttribs.NumDeferredContexts = NumDeferredCtx; - ppContexts.resize(1 + NumDeferredCtx); - auto* pFactoryMtl = GetEngineFactoryMtl(); - pFactoryMtl->CreateDeviceAndContextsMtl(MtlAttribs, &m_pDevice, ppContexts.data()); - } - break; -#endif - - default: - LOG_ERROR_AND_THROW("Unknown device type"); - break; - } - m_pDeviceContext.Attach(ppContexts[0]); -} - -TestingEnvironment::~TestingEnvironment() -{ - m_pDeviceContext->Flush(); - m_pDeviceContext->FinishFrame(); -} - -// Override this to define how to set up the environment. -void TestingEnvironment::SetUp() -{ -} - -// Override this to define how to tear down the environment. -void TestingEnvironment::TearDown() -{ -} - -void TestingEnvironment::ReleaseResources() -{ - // It is necessary to call Flush() to force the driver to release resources. - // Without flushing the command buffer, the memory may not be released until sometimes - // later causing out-of-memory error. - m_pDeviceContext->Flush(); - m_pDeviceContext->FinishFrame(); - m_pDevice->ReleaseStaleResources(); -} - -void TestingEnvironment::Reset() -{ - m_pDeviceContext->Flush(); - m_pDeviceContext->FinishFrame(); - m_pDevice->IdleGPU(); - m_pDevice->ReleaseStaleResources(); - m_pDeviceContext->InvalidateState(); - m_NumAllowedErrors = 0; -} - -RefCntAutoPtr TestingEnvironment::CreateTexture(const char* Name, TEXTURE_FORMAT Fmt, BIND_FLAGS BindFlags, Uint32 Width, Uint32 Height) -{ - TextureDesc TexDesc; - - TexDesc.Name = Name; - TexDesc.Type = RESOURCE_DIM_TEX_2D; - TexDesc.Format = Fmt; - TexDesc.BindFlags = BindFlags; - TexDesc.Width = Width; - TexDesc.Height = Height; - - RefCntAutoPtr pTexture; - m_pDevice->CreateTexture(TexDesc, nullptr, &pTexture); - VERIFY_EXPR(pTexture != nullptr); - - return pTexture; -} - -} // namespace Testing - -} // namespace Diligent diff --git a/UnitTests/DiligentCoreAPITest/src/TestingSwapChainBase.cpp b/UnitTests/DiligentCoreAPITest/src/TestingSwapChainBase.cpp deleted file mode 100644 index 2307ed9a..00000000 --- a/UnitTests/DiligentCoreAPITest/src/TestingSwapChainBase.cpp +++ /dev/null @@ -1,111 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include -#include -#include - -#include "TestingSwapChainBase.h" -#include "GraphicsAccessories.h" - -#define STB_IMAGE_WRITE_IMPLEMENTATION -#include "../../../ThirdParty/stb/stb_image_write.h" - -namespace Diligent -{ - -namespace Testing -{ - -void CompareTestImages(const Uint8* pReferencePixels, - Uint32 RefPixelsStride, - const Uint8* pPixels, - Uint32 PixelsStride, - Uint32 Width, - Uint32 Height, - TEXTURE_FORMAT Format) -{ - VERIFY_EXPR(pReferencePixels != nullptr); - VERIFY_EXPR(pPixels != nullptr); - VERIFY_EXPR(Width != 0); - VERIFY_EXPR(Height != 0); - VERIFY_EXPR(PixelsStride != 0); - VERIFY_EXPR(RefPixelsStride != 0); - VERIFY(Format == TEX_FORMAT_RGBA8_UNORM, GetTextureFormatAttribs(Format).Name, " is not supported"); - - bool bIsIdentical = true; - - for (Uint32 row = 0; row < Height; ++row) - { - if (memcmp(pReferencePixels + row * RefPixelsStride, - pPixels + row * PixelsStride, - Width * 4) != 0) - { - bIsIdentical = false; - } - } - - if (bIsIdentical) - { - } - else - { - auto ReportImageStride = (Width * 2) * 3; - - std::vector ReportImage(ReportImageStride * (Height * 2)); - for (Uint32 row = 0; row < Height; ++row) - { - for (Uint32 col = 0; col < Width; ++col) - { - for (Uint32 c = 0; c < 3; ++c) - { - auto RefVal = pReferencePixels[row * RefPixelsStride + col * 4 + c]; - auto Val = pPixels[row * PixelsStride + col * 4 + c]; - auto diff = static_cast(std::min(std::abs(int{RefVal} - int{Val}), 255)); - - // clang-format off - ReportImage[row * ReportImageStride + col * 3 + c] = RefVal; - ReportImage[row * ReportImageStride + (Width + col) * 3 + c] = Val; - ReportImage[(row + Height) * ReportImageStride + col * 3 + c] = diff; - ReportImage[(row + Height) * ReportImageStride + (Width + col) * 3 + c] = static_cast(std::min(diff*16, 255)); - // clang-format on - } - } - } - const auto* const TestInfo = ::testing::UnitTest::GetInstance()->current_test_info(); - - std::string FileName = TestInfo->test_suite_name(); - FileName += '.'; - FileName += TestInfo->name(); - FileName += "_FAIL_.png"; - if (stbi_write_png(FileName.c_str(), Width * 2, Height * 2, 3, ReportImage.data(), (Width * 2) * 3) == 0) - { - LOG_ERROR_MESSAGE("Failed to write ", FileName); - } - ADD_FAILURE() << "Captured image is not identical to the reference image"; - } -} - -} // namespace Testing - -} // namespace Diligent diff --git a/UnitTests/DiligentCoreAPITest/src/TextureCreationTest.cpp b/UnitTests/DiligentCoreAPITest/src/TextureCreationTest.cpp deleted file mode 100644 index 7fe667a4..00000000 --- a/UnitTests/DiligentCoreAPITest/src/TextureCreationTest.cpp +++ /dev/null @@ -1,747 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include - -#include "RenderDevice.h" -#include "GraphicsAccessories.h" - -#if D3D11_SUPPORTED -# include "D3D11/CreateObjFromNativeResD3D11.h" -#endif - -#if D3D12_SUPPORTED -# include "D3D12/CreateObjFromNativeResD3D12.h" -#endif - -#if GL_SUPPORTED || GLES_SUPPORTED -# include "GL/CreateObjFromNativeResGL.h" -#endif - -#if VULKAN_SUPPORTED -# include "Vulkan/CreateObjFromNativeResVK.h" -#endif - -#include "TestingEnvironment.h" - -#include "gtest/gtest.h" - -using namespace Diligent; -using namespace Diligent::Testing; - -namespace -{ - -struct TextureTestAttribs -{ - TEXTURE_FORMAT Fmt; - Uint32 PixelSize; - BIND_FLAGS BindFlags; - Bool TestDataUpload; -}; - -class TextureCreationTest : public testing::TestWithParam -{ -protected: - static void SetUpTestSuite() - { - auto* pEnv = TestingEnvironment::GetInstance(); - auto* pDevice = pEnv->GetDevice(); - - const auto DevCaps = pDevice->GetDeviceCaps(); - switch (DevCaps.DevType) - { -#if D3D11_SUPPORTED - case DeviceType::D3D11: - pCreateObjFromNativeRes.reset(new TestCreateObjFromNativeResD3D11(pDevice)); - break; - -#endif - -#if D3D12_SUPPORTED - case DeviceType::D3D12: - pCreateObjFromNativeRes.reset(new TestCreateObjFromNativeResD3D12(pDevice)); - break; -#endif - -#if GL_SUPPORTED || GLES_SUPPORTED - case DeviceType::OpenGL: - case DeviceType::OpenGLES: - pCreateObjFromNativeRes.reset(new TestCreateObjFromNativeResGL(pDevice)); - break; -#endif - -#if VULKAN_SUPPORTED - case DeviceType::Vulkan: - pCreateObjFromNativeRes.reset(new TestCreateObjFromNativeResVK(pDevice)); - break; -#endif - - default: UNEXPECTED("Unexpected device type"); - } - } - - static void TearDownTestSuite() - { - pCreateObjFromNativeRes.reset(); - TestingEnvironment::GetInstance()->Reset(); - } - - static void PrepareSubresourceData(const TextureDesc& TexDesc, - const TextureFormatInfo& FmtInfo, - std::vector>& Data, - std::vector& SubResources, - TextureData& InitData) - { - Uint32 ArrSize = (TexDesc.Type == RESOURCE_DIM_TEX_3D) ? 1 : TexDesc.ArraySize; - - VERIFY(FmtInfo.ComponentType != COMPONENT_TYPE_COMPRESSED, "Uploading data to compressed formats is not yet being tested"); - - InitData.NumSubresources = ArrSize * TexDesc.MipLevels; - Data.resize(InitData.NumSubresources); - SubResources.resize(InitData.NumSubresources); - Uint32 SubRes = 0; - for (Uint32 Slice = 0; Slice < ArrSize; ++Slice) - { - for (Uint32 Mip = 0; Mip < TexDesc.MipLevels; ++Mip) - { - auto MipLevelInfo = GetMipLevelProperties(TexDesc, Mip); - - auto& CurrSubResData = Data[SubRes]; - auto& SubResInfo = SubResources[SubRes]; - - SubResInfo.Stride = ((MipLevelInfo.RowSize + 3) & (-4)) + 192; - auto SubresDataSize = 0; - if (TexDesc.Type == RESOURCE_DIM_TEX_3D) - { - SubResInfo.DepthStride = (MipLevelInfo.StorageHeight + 32) * SubResInfo.Stride; - SubresDataSize = SubResInfo.DepthStride * MipLevelInfo.Depth; - } - else - SubresDataSize = SubResInfo.Stride * MipLevelInfo.StorageHeight; - - CurrSubResData.resize(SubresDataSize); - SubResInfo.pData = CurrSubResData.data(); - ++SubRes; - } - } - InitData.pSubResources = SubResources.data(); - } - - - static void CreateTestTexture(RESOURCE_DIMENSION Type, - TEXTURE_FORMAT TextureFormat, - BIND_FLAGS BindFlags, - Uint32 SampleCount, - bool UploadData) - { - auto* pEnv = TestingEnvironment::GetInstance(); - - auto* pDevice = pEnv->GetDevice(); - auto* pDeviceContext = pEnv->GetDeviceContext(); - const auto& deviceCaps = pDevice->GetDeviceCaps(); - const auto& TexCaps = deviceCaps.TexCaps; - - TextureDesc TexDesc; - TexDesc.Name = "Test Texture"; - TexDesc.Type = Type; - TexDesc.Width = 211; - if (TexDesc.Type == RESOURCE_DIM_TEX_1D || TexDesc.Type == RESOURCE_DIM_TEX_1D_ARRAY) - TexDesc.Height = 1; - else - TexDesc.Height = 243; - - if (TexDesc.Type == RESOURCE_DIM_TEX_3D) - TexDesc.Depth = 16; - - if (TexDesc.Type == RESOURCE_DIM_TEX_1D_ARRAY || TexDesc.Type == RESOURCE_DIM_TEX_2D_ARRAY) - TexDesc.ArraySize = 16; - - const auto& FmtInfo = pDevice->GetTextureFormatInfoExt(TextureFormat); - if (FmtInfo.ComponentType == COMPONENT_TYPE_COMPRESSED) - { - TexDesc.Width = (TexDesc.Width + 3) & (-4); - TexDesc.Height = (TexDesc.Height + 3) & (-4); - } - - TexDesc.MipLevels = SampleCount == 1 ? 0 : 1; - TexDesc.Format = TextureFormat; - TexDesc.Usage = USAGE_DEFAULT; - TexDesc.BindFlags = BindFlags; - if (SampleCount > 1) - TexDesc.BindFlags &= ~BIND_UNORDERED_ACCESS; - - TexDesc.SampleCount = SampleCount; - - RefCntAutoPtr pTestTex; - TextureData NullData; - pDevice->CreateTexture(TexDesc, &NullData, &pTestTex); - ASSERT_NE(pTestTex, nullptr) << GetObjectDescString(TexDesc); - - pCreateObjFromNativeRes->CreateTexture(pTestTex); - TexDesc.MipLevels = pTestTex->GetDesc().MipLevels; - if (SampleCount == 1 && UploadData) - { - std::vector> Data; - std::vector SubResources; - TextureData InitData; - - PrepareSubresourceData(TexDesc, FmtInfo, Data, SubResources, InitData); - - TexDesc.Name = "Test Texture 2"; - RefCntAutoPtr pTestTex2; - pDevice->CreateTexture(TexDesc, &InitData, &pTestTex2); - ASSERT_NE(pTestTex2, nullptr) << GetObjectDescString(TexDesc); - - pCreateObjFromNativeRes->CreateTexture(pTestTex2); - - if (deviceCaps.DevType == DeviceType::D3D11 && - ((TexDesc.BindFlags & BIND_DEPTH_STENCIL) != 0 || TexDesc.SampleCount > 1)) - { - // In D3D11 if CopySubresourceRegion is used with Multisampled or D3D11_BIND_DEPTH_STENCIL Resources, - // then the whole Subresource must be copied. - CopyTextureAttribs CopyAttribs(pTestTex2, RESOURCE_STATE_TRANSITION_MODE_TRANSITION, pTestTex, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); - pDeviceContext->CopyTexture(CopyAttribs); - } - else - { - Box SrcBox; - SrcBox.MinX = TexDesc.Width / 4; - SrcBox.MinY = TexDesc.Height / 4; - SrcBox.MinZ = (TexDesc.Type == RESOURCE_DIM_TEX_3D) ? TexDesc.Depth / 4 : 0; - SrcBox.MaxX = std::max(TexDesc.Width / 3, SrcBox.MinX + 1); - SrcBox.MaxY = std::max(TexDesc.Height / 3, SrcBox.MinY + 1); - SrcBox.MaxZ = (TexDesc.Type == RESOURCE_DIM_TEX_3D) ? std::max(TexDesc.Depth / 3, SrcBox.MinZ + 1) : 1; - //pTestTex2->UpdateData(m_pDeviceContext, 0, 0, DstBox, SubResources[0]); - CopyTextureAttribs CopyAttribs(pTestTex2, RESOURCE_STATE_TRANSITION_MODE_TRANSITION, pTestTex, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); - CopyAttribs.pSrcBox = &SrcBox; - pDeviceContext->CopyTexture(CopyAttribs); - } - } - - if (!TexCaps.bTextureViewSupported) - { - LOG_WARNING_MESSAGE_ONCE("Texture views are not supported!\n"); - } - - if (TexCaps.bTextureViewSupported && !FmtInfo.IsTypeless) - { - TextureViewDesc ViewDesc; - ViewDesc.TextureDim = TexDesc.Type; - - if (SampleCount > 1) - { - ViewDesc.MostDetailedMip = 0; - ViewDesc.NumMipLevels = 1; - } - else - { - ViewDesc.MostDetailedMip = 1; - ViewDesc.NumMipLevels = 2; - } - - if (TexDesc.Type == RESOURCE_DIM_TEX_1D_ARRAY || TexDesc.Type == RESOURCE_DIM_TEX_2D_ARRAY) - { - ViewDesc.FirstArraySlice = 3; - ViewDesc.NumArraySlices = (deviceCaps.DevType == DeviceType::D3D11 || deviceCaps.DevType == DeviceType::D3D12 || ViewDesc.ViewType == TEXTURE_VIEW_SHADER_RESOURCE) ? 4 : 1; - } - else if (TexDesc.Type == RESOURCE_DIM_TEX_3D) - { - if (deviceCaps.DevType == DeviceType::D3D11 || deviceCaps.DevType == DeviceType::D3D12) - { - ViewDesc.FirstDepthSlice = 3; - ViewDesc.NumDepthSlices = 4; - } - else if ((deviceCaps.DevType == DeviceType::Vulkan && ViewDesc.ViewType != TEXTURE_VIEW_RENDER_TARGET && ViewDesc.ViewType != TEXTURE_VIEW_DEPTH_STENCIL) || - deviceCaps.DevType != DeviceType::Vulkan) - { - // OpenGL cannot create views for separate depth slices - ViewDesc.FirstDepthSlice = 0; - ViewDesc.NumDepthSlices = TexDesc.Depth >> ViewDesc.MostDetailedMip; - } - } - else - { - ViewDesc.FirstArraySlice = 0; - ViewDesc.NumArraySlices = 1; - } - - if (TexDesc.BindFlags & BIND_SHADER_RESOURCE) - { - ViewDesc.ViewType = TEXTURE_VIEW_SHADER_RESOURCE; - RefCntAutoPtr pSRV; - pTestTex->CreateView(ViewDesc, &pSRV); - EXPECT_NE(pSRV, nullptr) << GetObjectDescString(TexDesc); - } - - // RTV, DSV & UAV can reference only one mip level - ViewDesc.NumMipLevels = 1; - - if (TexDesc.BindFlags & BIND_RENDER_TARGET) - { - ViewDesc.ViewType = TEXTURE_VIEW_RENDER_TARGET; - RefCntAutoPtr pRTV; - pTestTex->CreateView(ViewDesc, &pRTV); - EXPECT_NE(pRTV, nullptr) << GetObjectDescString(TexDesc); - } - - if (TexDesc.BindFlags & BIND_DEPTH_STENCIL) - { - ViewDesc.ViewType = TEXTURE_VIEW_DEPTH_STENCIL; - RefCntAutoPtr pDSV; - pTestTex->CreateView(ViewDesc, &pDSV); - EXPECT_NE(pDSV, nullptr) << GetObjectDescString(TexDesc); - } - - if (TexDesc.BindFlags & BIND_UNORDERED_ACCESS) - { - ViewDesc.ViewType = TEXTURE_VIEW_UNORDERED_ACCESS; - ViewDesc.AccessFlags = UAV_ACCESS_FLAG_READ | UAV_ACCESS_FLAG_WRITE; - RefCntAutoPtr pUAV; - pTestTex->CreateView(ViewDesc, &pUAV); - EXPECT_NE(pUAV, nullptr) << GetObjectDescString(TexDesc); - } - } - - // Flush, FinishFrame, and ReleaseStaleResources. - pEnv->ReleaseResources(); - } - - void CreateTestCubemap(TEXTURE_FORMAT TextureFormat, - BIND_FLAGS BindFlags, - bool UploadData) - { - auto* pEnv = TestingEnvironment::GetInstance(); - - auto* pDevice = pEnv->GetDevice(); - const auto& deviceCaps = pDevice->GetDeviceCaps(); - const auto& TexCaps = deviceCaps.TexCaps; - - TextureDesc TexDesc; - TexDesc.Name = "Test Cube MapTextureCreation"; - TexDesc.Type = RESOURCE_DIM_TEX_CUBE; - TexDesc.Width = 256; - TexDesc.Height = 256; - TexDesc.ArraySize = 6; - TexDesc.MipLevels = 0; - TexDesc.Format = TextureFormat; - TexDesc.Usage = USAGE_DEFAULT; - TexDesc.BindFlags = BindFlags; - TexDesc.SampleCount = 1; - - RefCntAutoPtr pTestCubemap, pTestCubemapArr; - pDevice->CreateTexture(TexDesc, nullptr, &pTestCubemap); - ASSERT_NE(pTestCubemap, nullptr) << GetObjectDescString(TexDesc); - pCreateObjFromNativeRes->CreateTexture(pTestCubemap); - TexDesc.MipLevels = pTestCubemap->GetDesc().MipLevels; - - const auto& FmtInfo = pDevice->GetTextureFormatInfoExt(TextureFormat); - if (UploadData) - { - std::vector> Data; - std::vector SubResources; - TextureData InitData; - - PrepareSubresourceData(TexDesc, FmtInfo, Data, SubResources, InitData); - - InitData.pSubResources = SubResources.data(); - TexDesc.Name = "TestCubemap2"; - pTestCubemap.Release(); - pDevice->CreateTexture(TexDesc, &InitData, &pTestCubemap); - ASSERT_NE(pTestCubemap, nullptr) << GetObjectDescString(TexDesc); - pCreateObjFromNativeRes->CreateTexture(pTestCubemap); - } - - if (TexCaps.bTextureViewSupported && !FmtInfo.IsTypeless) - { - TextureViewDesc ViewDesc; - if (TexDesc.BindFlags & BIND_SHADER_RESOURCE) - { - ViewDesc.TextureDim = RESOURCE_DIM_TEX_CUBE; - ViewDesc.ViewType = TEXTURE_VIEW_SHADER_RESOURCE; - ViewDesc.MostDetailedMip = 1; - ViewDesc.NumMipLevels = 6; - { - RefCntAutoPtr pSRV; - pTestCubemap->CreateView(ViewDesc, &pSRV); - EXPECT_NE(pSRV, nullptr) << GetObjectDescString(TexDesc); - } - - ViewDesc.TextureDim = RESOURCE_DIM_TEX_2D; - ViewDesc.FirstArraySlice = 0; - ViewDesc.NumArraySlices = 1; - ViewDesc.MostDetailedMip = 2; - ViewDesc.NumMipLevels = 4; - { - RefCntAutoPtr pSRV; - pTestCubemap->CreateView(ViewDesc, &pSRV); - EXPECT_NE(pSRV, nullptr) << GetObjectDescString(TexDesc); - } - - ViewDesc.TextureDim = RESOURCE_DIM_TEX_2D_ARRAY; - ViewDesc.FirstArraySlice = 2; - ViewDesc.NumArraySlices = 3; - { - RefCntAutoPtr pSRV; - pTestCubemap->CreateView(ViewDesc, &pSRV); - EXPECT_NE(pSRV, nullptr) << GetObjectDescString(TexDesc); - } - } - - // RTV, DSV & UAV can reference only one mip level - ViewDesc.NumMipLevels = 1; - - if (TexDesc.BindFlags & BIND_RENDER_TARGET) - { - ViewDesc.ViewType = TEXTURE_VIEW_RENDER_TARGET; - ViewDesc.TextureDim = RESOURCE_DIM_TEX_2D; - ViewDesc.FirstArraySlice = 0; - ViewDesc.NumArraySlices = 1; - { - RefCntAutoPtr pRTV; - pTestCubemap->CreateView(ViewDesc, &pRTV); - EXPECT_NE(pRTV, nullptr) << GetObjectDescString(TexDesc); - } - - ViewDesc.TextureDim = RESOURCE_DIM_TEX_2D_ARRAY; - ViewDesc.FirstArraySlice = 2; - ViewDesc.NumArraySlices = 3; - { - RefCntAutoPtr pRTV; - pTestCubemap->CreateView(ViewDesc, &pRTV); - EXPECT_NE(pRTV, nullptr) << GetObjectDescString(TexDesc); - } - } - - if (TexDesc.BindFlags & BIND_DEPTH_STENCIL) - { - ViewDesc.ViewType = TEXTURE_VIEW_DEPTH_STENCIL; - ViewDesc.TextureDim = RESOURCE_DIM_TEX_2D; - ViewDesc.NumArraySlices = 1; - ViewDesc.FirstArraySlice = 0; - ViewDesc.MostDetailedMip = 2; - { - RefCntAutoPtr pDSV; - pTestCubemap->CreateView(ViewDesc, &pDSV); - EXPECT_NE(pDSV, nullptr) << GetObjectDescString(TexDesc); - } - - ViewDesc.TextureDim = RESOURCE_DIM_TEX_2D_ARRAY; - ViewDesc.NumArraySlices = 3; - ViewDesc.FirstArraySlice = 2; - { - RefCntAutoPtr pDSV; - pTestCubemap->CreateView(ViewDesc, &pDSV); - EXPECT_NE(pDSV, nullptr) << GetObjectDescString(TexDesc); - } - } - - if (TexDesc.BindFlags & BIND_UNORDERED_ACCESS) - { - ViewDesc.ViewType = TEXTURE_VIEW_UNORDERED_ACCESS; - ViewDesc.AccessFlags = UAV_ACCESS_FLAG_READ | UAV_ACCESS_FLAG_WRITE; - ViewDesc.TextureDim = RESOURCE_DIM_TEX_2D; - ViewDesc.NumArraySlices = 1; - ViewDesc.FirstArraySlice = 0; - { - RefCntAutoPtr pUAV; - pTestCubemap->CreateView(ViewDesc, &pUAV); - EXPECT_NE(pUAV, nullptr) << GetObjectDescString(TexDesc); - } - - ViewDesc.TextureDim = RESOURCE_DIM_TEX_2D_ARRAY; - if (deviceCaps.DevType == DeviceType::OpenGL || deviceCaps.DevType == DeviceType::OpenGLES) - { - ViewDesc.NumArraySlices = 1; - ViewDesc.FirstArraySlice = 2; - } - else - { - ViewDesc.NumArraySlices = 3; - ViewDesc.FirstArraySlice = 2; - } - - { - RefCntAutoPtr pUAV; - pTestCubemap->CreateView(ViewDesc, &pUAV); - EXPECT_NE(pUAV, nullptr) << GetObjectDescString(TexDesc); - } - } - } - - if (deviceCaps.TexCaps.bCubemapArraysSupported) - { - TexDesc.ArraySize = 24; - TexDesc.Type = RESOURCE_DIM_TEX_CUBE_ARRAY; - - std::vector> Data; - std::vector SubResources; - TextureData InitData; - - if (UploadData) - { - PrepareSubresourceData(TexDesc, FmtInfo, Data, SubResources, InitData); - } - - TexDesc.Name = "TestCubemapArray"; - - pDevice->CreateTexture(TexDesc, &InitData, &pTestCubemapArr); - EXPECT_NE(pTestCubemapArr, nullptr) << GetObjectDescString(TexDesc); - pCreateObjFromNativeRes->CreateTexture(pTestCubemapArr); - } - - // Flush, FinishFrame, and ReleaseStaleResources. - pEnv->ReleaseResources(); - } - - static std::unique_ptr pCreateObjFromNativeRes; -}; - -std::unique_ptr TextureCreationTest::pCreateObjFromNativeRes; - -TEST_P(TextureCreationTest, CreateTexture) -{ - auto* pEnv = TestingEnvironment::GetInstance(); - auto* pDevice = pEnv->GetDevice(); - - const auto& TestInfo = GetParam(); - - const auto& FmtInfo = pDevice->GetTextureFormatInfoExt(TestInfo.Fmt); - - if (!FmtInfo.Supported) - { - GTEST_SKIP() << "Texture format " << FmtInfo.Name << " is not supported"; - } - - EXPECT_TRUE(TestInfo.PixelSize == Uint32{FmtInfo.ComponentSize} * Uint32{FmtInfo.NumComponents} || - FmtInfo.ComponentType == COMPONENT_TYPE_COMPRESSED); - - const auto& TexCaps = pDevice->GetDeviceCaps().TexCaps; - // Test texture 1D / texture 1D array - if (TexCaps.bTexture1DSupported) - { - if (FmtInfo.Tex1DFmt) - CreateTestTexture(RESOURCE_DIM_TEX_1D, TestInfo.Fmt, TestInfo.BindFlags, 1, TestInfo.TestDataUpload); - } - else - { - LOG_WARNING_MESSAGE_ONCE("Texture 1D is not supported\n"); - } - - if (TexCaps.bTexture1DArraySupported) - { - if (FmtInfo.Tex1DFmt) - CreateTestTexture(RESOURCE_DIM_TEX_1D_ARRAY, TestInfo.Fmt, TestInfo.BindFlags, 1, TestInfo.TestDataUpload); - } - else - { - LOG_WARNING_MESSAGE_ONCE("Texture 1D array is not supported\n"); - } - - // Test texture 2D / texture 2D array - CreateTestTexture(RESOURCE_DIM_TEX_2D, TestInfo.Fmt, TestInfo.BindFlags, 1, TestInfo.TestDataUpload); - CreateTestTexture(RESOURCE_DIM_TEX_2D, TestInfo.Fmt, TestInfo.BindFlags, 1, TestInfo.TestDataUpload); - CreateTestTexture(RESOURCE_DIM_TEX_2D_ARRAY, TestInfo.Fmt, TestInfo.BindFlags, 1, TestInfo.TestDataUpload); - CreateTestTexture(RESOURCE_DIM_TEX_2D_ARRAY, TestInfo.Fmt, TestInfo.BindFlags, 1, TestInfo.TestDataUpload); - CreateTestCubemap(TestInfo.Fmt, TestInfo.BindFlags, TestInfo.TestDataUpload); - - if (TestInfo.Fmt != TEX_FORMAT_RGB9E5_SHAREDEXP && - FmtInfo.ComponentType != COMPONENT_TYPE_COMPRESSED) - { - if (TexCaps.bTexture2DMSSupported) - { - if ((FmtInfo.SampleCounts & 0x04) != 0 && (TestInfo.BindFlags & (BIND_RENDER_TARGET | BIND_DEPTH_STENCIL)) != 0) - { - CreateTestTexture(RESOURCE_DIM_TEX_2D, TestInfo.Fmt, TestInfo.BindFlags, 4, TestInfo.TestDataUpload); - CreateTestTexture(RESOURCE_DIM_TEX_2D, TestInfo.Fmt, TestInfo.BindFlags, 4, TestInfo.TestDataUpload); - } - } - else - { - LOG_WARNING_MESSAGE_ONCE("Texture 2D MS is not supported\n"); - } - - if (TexCaps.bTexture2DMSArraySupported) - { - if ((FmtInfo.SampleCounts & 0x04) != 0 && (TestInfo.BindFlags & (BIND_RENDER_TARGET | BIND_DEPTH_STENCIL)) != 0) - { - CreateTestTexture(RESOURCE_DIM_TEX_2D_ARRAY, TestInfo.Fmt, TestInfo.BindFlags, 4, TestInfo.TestDataUpload); - CreateTestTexture(RESOURCE_DIM_TEX_2D_ARRAY, TestInfo.Fmt, TestInfo.BindFlags, 4, TestInfo.TestDataUpload); - } - } - else - { - LOG_WARNING_MESSAGE_ONCE("Texture 2D MS Array is not supported\n"); - } - } - - // Test texture 3D - if (FmtInfo.Tex3DFmt) - CreateTestTexture(RESOURCE_DIM_TEX_3D, TestInfo.Fmt, TestInfo.BindFlags, 1, TestInfo.TestDataUpload); -} - - - -constexpr BIND_FLAGS BindSRU = BIND_SHADER_RESOURCE | BIND_RENDER_TARGET | BIND_UNORDERED_ACCESS; -constexpr BIND_FLAGS BindSR = BIND_SHADER_RESOURCE | BIND_RENDER_TARGET; -//constexpr BIND_FLAGS BindSD = BIND_SHADER_RESOURCE | BIND_DEPTH_STENCIL; -constexpr BIND_FLAGS BindSU = BIND_SHADER_RESOURCE | BIND_UNORDERED_ACCESS; -constexpr BIND_FLAGS BindSD = BIND_SHADER_RESOURCE | BIND_DEPTH_STENCIL; -constexpr BIND_FLAGS BindD = BIND_DEPTH_STENCIL; -constexpr BIND_FLAGS BindS = BIND_SHADER_RESOURCE; - -// clang-format off -const TextureTestAttribs TestList[] = -{ - {TEX_FORMAT_RGBA32_TYPELESS, 16, BindSRU, true}, - {TEX_FORMAT_RGBA32_FLOAT, 16, BindSRU, true}, - {TEX_FORMAT_RGBA32_UINT, 16, BindSRU, true}, - {TEX_FORMAT_RGBA32_SINT, 16, BindSRU, true}, - //{TEX_FORMAT_RGB32_TYPELESS 12, BindS, true}, - - // These formats are ill-supported - //{TEX_FORMAT_RGB32_FLOAT, 12, BindS, true}, - //{TEX_FORMAT_RGB32_UINT, 12, BindS, true}, - //{TEX_FORMAT_RGB32_SINT, 12, BindS, true}, - - {TEX_FORMAT_RGBA16_TYPELESS, 8, BindSRU, true}, - {TEX_FORMAT_RGBA16_FLOAT, 8, BindSRU, true}, - {TEX_FORMAT_RGBA16_UNORM, 8, BindSRU, true}, - {TEX_FORMAT_RGBA16_UINT, 8, BindSRU, true}, - {TEX_FORMAT_RGBA16_SNORM, 8, BindSU, true}, - {TEX_FORMAT_RGBA16_SINT, 8, BindSRU, true}, - - {TEX_FORMAT_RG32_TYPELESS, 8, BindSRU, true}, - {TEX_FORMAT_RG32_FLOAT, 8, BindSRU, true}, - {TEX_FORMAT_RG32_UINT, 8, BindSRU, true}, - {TEX_FORMAT_RG32_SINT, 8, BindSRU, true}, - - {TEX_FORMAT_R32G8X24_TYPELESS, 8, BindD, false}, - {TEX_FORMAT_D32_FLOAT_S8X24_UINT, 8, BindD, false}, - //{TEX_FORMAT_R32_FLOAT_X8X24_TYPELESS, 8, BindD, false}, - //{TEX_FORMAT_X32_TYPELESS_G8X24_UINT, 8, BindD, false}, - - {TEX_FORMAT_RGB10A2_TYPELESS, 4, BindSR, true}, - {TEX_FORMAT_RGB10A2_UNORM, 4, BindSR, true}, - {TEX_FORMAT_RGB10A2_UINT, 4, BindS, true}, - {TEX_FORMAT_R11G11B10_FLOAT, 4, BindSRU, false}, - - {TEX_FORMAT_RGBA8_TYPELESS, 4, BindSRU, true}, - {TEX_FORMAT_RGBA8_UNORM, 4, BindSRU, true}, - {TEX_FORMAT_RGBA8_UNORM_SRGB, 4, BindSR, true}, - {TEX_FORMAT_RGBA8_UINT, 4, BindSRU, true}, - {TEX_FORMAT_RGBA8_SNORM, 4, BindSU, true}, - {TEX_FORMAT_RGBA8_SINT, 4, BindSRU, true}, - - {TEX_FORMAT_RG16_TYPELESS, 4, BindSRU, true}, - {TEX_FORMAT_RG16_FLOAT, 4, BindSRU, true}, - {TEX_FORMAT_RG16_UNORM, 4, BindSRU, true}, - {TEX_FORMAT_RG16_UINT, 4, BindSRU, true}, - {TEX_FORMAT_RG16_SNORM, 4, BindSU, true}, - {TEX_FORMAT_RG16_SINT, 4, BindSRU, true}, - - {TEX_FORMAT_R32_TYPELESS, 4, BindSRU, true}, - {TEX_FORMAT_D32_FLOAT, 4, BindD, false}, - {TEX_FORMAT_R32_FLOAT, 4, BindSRU, true}, - {TEX_FORMAT_R32_UINT, 4, BindSRU, true}, - {TEX_FORMAT_R32_SINT, 4, BindSRU, true}, - - {TEX_FORMAT_R24G8_TYPELESS, 4, BindSD, false}, - {TEX_FORMAT_D24_UNORM_S8_UINT, 4, BindD, false}, - //{TEX_FORMAT_R24_UNORM_X8_TYPELESS, 4, BindD, true}, - //{TEX_FORMAT_X24_TYPELESS_G8_UINT, 4, BindD, true}, - - {TEX_FORMAT_RG8_TYPELESS, 2, BindSRU, true}, - {TEX_FORMAT_RG8_UNORM, 2, BindSRU, true}, - {TEX_FORMAT_RG8_UINT, 2, BindSRU, true}, - {TEX_FORMAT_RG8_SNORM, 2, BindSU, true}, - {TEX_FORMAT_RG8_SINT, 2, BindSRU, true}, - - {TEX_FORMAT_R16_TYPELESS, 2, BindSRU, true}, - {TEX_FORMAT_R16_FLOAT, 2, BindSRU, true}, - {TEX_FORMAT_D16_UNORM, 2, BindD, false}, - {TEX_FORMAT_R16_UNORM, 2, BindSRU, true}, - {TEX_FORMAT_R16_UINT, 2, BindSRU, true}, - {TEX_FORMAT_R16_SNORM, 2, BindSU, true}, - {TEX_FORMAT_R16_SINT, 2, BindSRU, true}, - - {TEX_FORMAT_R8_TYPELESS, 1, BindSRU, true}, - {TEX_FORMAT_R8_UNORM, 1, BindSRU, true}, - {TEX_FORMAT_R8_UINT, 1, BindSRU, true}, - {TEX_FORMAT_R8_SNORM, 1, BindSU, true}, - {TEX_FORMAT_R8_SINT, 1, BindSRU, true}, - //{TEX_FORMAT_A8_UNORM, 1, BindSRU, true}, - //{TEX_FORMAT_R1_UNORM, 1, BindSRU, true}, - - {TEX_FORMAT_RGB9E5_SHAREDEXP, 4, BindS, false}, - //{TEX_FORMAT_RG8_B8G8_UNORM, 4, BindSRU, false}, - //{TEX_FORMAT_G8R8_G8B8_UNORM, 4, BindSRU, false}, - - //{TEX_FORMAT_BC1_TYPELESS, 16, BindS, false}, - {TEX_FORMAT_BC1_UNORM, 16, BindS, false}, - {TEX_FORMAT_BC1_UNORM_SRGB, 16, BindS, false}, - //{TEX_FORMAT_BC2_TYPELESS, 16, BindS, false}, - {TEX_FORMAT_BC2_UNORM, 16, BindS, false}, - {TEX_FORMAT_BC2_UNORM_SRGB, 16, BindS, false}, - //{TEX_FORMAT_BC3_TYPELESS, 16, BindS, false}, - {TEX_FORMAT_BC3_UNORM, 16, BindS, false}, - {TEX_FORMAT_BC3_UNORM_SRGB, 16, BindS, false}, - //{TEX_FORMAT_BC4_TYPELESS, 16, BindS, false}, - {TEX_FORMAT_BC4_UNORM, 16, BindS, false}, - {TEX_FORMAT_BC4_SNORM, 16, BindS, false}, - //{TEX_FORMAT_BC5_TYPELESS, 16, BindS, false}, - {TEX_FORMAT_BC5_UNORM, 16, BindS, false}, - {TEX_FORMAT_BC5_SNORM, 16, BindS, false}, - - //{TEX_FORMAT_B5G6R5_UNORM, 2, BindSRU, true}, - //{TEX_FORMAT_B5G5R5A1_UNORM, 2, BindSRU, true}, - //{TEX_FORMAT_BGRA8_UNORM, 4, BindSRU, true}, - //{TEX_FORMAT_BGRX8_UNORM, 4, BindSRU, true}, - //{TEX_FORMAT_R10G10B10_XR_BIAS_A2_UNORM, 4, BindS, false}, - - {TEX_FORMAT_BGRA8_TYPELESS, 4, BindSRU, true}, - {TEX_FORMAT_BGRA8_UNORM_SRGB, 4, BindSR, true}, - //{TEX_FORMAT_BGRX8_TYPELESS, 4, BindSRU, true}, - //{TEX_FORMAT_BGRX8_UNORM_SRGB, 4, BindSR, true}, - - //{TEX_FORMAT_BC6H_TYPELESS, 16, BindS, false}, - {TEX_FORMAT_BC6H_UF16, 16, BindS, false}, - {TEX_FORMAT_BC6H_SF16, 16, BindS, false}, - //{TEX_FORMAT_BC7_TYPELESS, 16, BindS, false}, - {TEX_FORMAT_BC7_UNORM, 16, BindS, false}, - {TEX_FORMAT_BC7_UNORM_SRGB, 16, BindS, false}, -}; -// clang-format on - - -INSTANTIATE_TEST_SUITE_P(TextureCreation, - TextureCreationTest, - testing::ValuesIn(std::begin(TestList), std::end(TestList)), - [](const testing::TestParamInfo& info) // - { - const auto& FmtAttribs = GetTextureFormatAttribs(info.param.Fmt); - return FmtAttribs.Name; - } // -); - -} // namespace diff --git a/UnitTests/DiligentCoreAPITest/src/Vulkan/ClearRenderTargetReferenceVk.cpp b/UnitTests/DiligentCoreAPITest/src/Vulkan/ClearRenderTargetReferenceVk.cpp deleted file mode 100644 index 55a5dd8e..00000000 --- a/UnitTests/DiligentCoreAPITest/src/Vulkan/ClearRenderTargetReferenceVk.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "Vulkan/TestingEnvironmentVk.h" -#include "Vulkan/TestingSwapChainVk.h" - -#include "DeviceContextVk.h" - -#include "volk/volk.h" - -namespace Diligent -{ - -namespace Testing -{ - -void ClearRenderTargetReferenceVk(ISwapChain* pSwapChain) -{ - auto* pEnv = TestingEnvironmentVk::GetInstance(); - auto* pContext = pEnv->GetDeviceContext(); - - VkResult res = VK_SUCCESS; - (void)res; - - auto* pTestingSwapChainVk = ValidatedCast(pSwapChain); - - VkCommandBuffer vkCmdBuffer = pEnv->AllocateCommandBuffer(); - - pTestingSwapChainVk->TransitionRenderTarget(vkCmdBuffer, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_PIPELINE_STAGE_VERTEX_SHADER_BIT | VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT); - VkClearColorValue ClearColor = {}; - - ClearColor.float32[0] = 0.25f; - ClearColor.float32[1] = 0.5f; - ClearColor.float32[2] = 0.75f; - ClearColor.float32[3] = 1.0f; - - VkImageSubresourceRange SubResRange = {}; - - SubResRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; - SubResRange.layerCount = 1; - SubResRange.levelCount = 1; - vkCmdClearColorImage(vkCmdBuffer, pTestingSwapChainVk->GetVkRenderTargetImage(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, &ClearColor, 1, &SubResRange); - - res = vkEndCommandBuffer(vkCmdBuffer); - VERIFY(res >= 0, "Failed to end command buffer"); - - RefCntAutoPtr pContextVk{pContext, IID_DeviceContextVk}; - - auto* pQeueVk = pContextVk->LockCommandQueue(); - auto vkQueue = pQeueVk->GetVkQueue(); - - VkSubmitInfo SubmitInfo = {}; - SubmitInfo.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; - SubmitInfo.pCommandBuffers = &vkCmdBuffer; - SubmitInfo.commandBufferCount = 1; - vkQueueSubmit(vkQueue, 1, &SubmitInfo, VK_NULL_HANDLE); - - pContextVk->UnlockCommandQueue(); -} - -} // namespace Testing - -} // namespace Diligent diff --git a/UnitTests/DiligentCoreAPITest/src/Vulkan/CreateObjFromNativeResVK.cpp b/UnitTests/DiligentCoreAPITest/src/Vulkan/CreateObjFromNativeResVK.cpp deleted file mode 100644 index b1d65e3a..00000000 --- a/UnitTests/DiligentCoreAPITest/src/Vulkan/CreateObjFromNativeResVK.cpp +++ /dev/null @@ -1,104 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * 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 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#if VULKAN_SUPPORTED -# define VK_NO_PROTOTYPES -# include "vulkan/vulkan.h" -#endif - -#include "RenderDeviceVk.h" -#include "TextureVk.h" -#include "BufferVk.h" -#include "GraphicsAccessories.h" - -#include "Vulkan/CreateObjFromNativeResVK.h" - -#include "gtest/gtest.h" - -namespace Diligent -{ - -namespace Testing -{ - -void TestCreateObjFromNativeResVK::CreateTexture(Diligent::ITexture* pTexture) -{ -#if VULKAN_SUPPORTED - RefCntAutoPtr pDeviceVk(m_pDevice, IID_RenderDeviceVk); - RefCntAutoPtr pTextureVk(pTexture, IID_TextureVk); - ASSERT_NE(pDeviceVk, nullptr); - ASSERT_NE(pTextureVk, nullptr); - - const auto& SrcTexDesc = pTexture->GetDesc(); - if (SrcTexDesc.Type == RESOURCE_DIM_TEX_CUBE_ARRAY) - return; - - auto VkHandle = pTextureVk->GetVkImage(); - ASSERT_NE(VkHandle, (VkImage)VK_NULL_HANDLE); - - RefCntAutoPtr pAttachedTexture; - pDeviceVk->CreateTextureFromVulkanImage(VkHandle, SrcTexDesc, RESOURCE_STATE_UNKNOWN, &pAttachedTexture); - ASSERT_NE(pAttachedTexture, nullptr); - - const auto& TestTexDesc = pAttachedTexture->GetDesc(); - EXPECT_EQ(TestTexDesc, SrcTexDesc) << "Src tex desc: " << GetObjectDescString(SrcTexDesc) - << "\nTest tex desc: " << GetObjectDescString(TestTexDesc); - - RefCntAutoPtr pAttachedTextureVk(pAttachedTexture, IID_TextureVk); - ASSERT_NE(pAttachedTextureVk, nullptr); - EXPECT_EQ(pAttachedTextureVk->GetVkImage(), VkHandle); - EXPECT_EQ(reinterpret_cast(pAttachedTextureVk->GetNativeHandle()), VkHandle); -#endif -} - -void TestCreateObjFromNativeResVK::CreateBuffer(Diligent::IBuffer* pBuffer) -{ -#if VULKAN_SUPPORTED - RefCntAutoPtr pDeviceVk(m_pDevice, IID_RenderDeviceVk); - RefCntAutoPtr pBufferVk(pBuffer, IID_BufferVk); - ASSERT_NE(pDeviceVk, nullptr); - ASSERT_NE(pBufferVk, nullptr); - - auto VkBufferHandle = pBufferVk->GetVkBuffer(); - ASSERT_NE(VkBufferHandle, (VkBuffer)VK_NULL_HANDLE); - - const auto& SrcBuffDesc = pBuffer->GetDesc(); - - RefCntAutoPtr pBufferFromNativeVkHandle; - pDeviceVk->CreateBufferFromVulkanResource(VkBufferHandle, SrcBuffDesc, RESOURCE_STATE_UNKNOWN, &pBufferFromNativeVkHandle); - ASSERT_NE(pBufferFromNativeVkHandle, nullptr); - - const auto& TestBufferDesc = pBufferFromNativeVkHandle->GetDesc(); - EXPECT_EQ(TestBufferDesc, SrcBuffDesc) << "Src buff desc: " << GetObjectDescString(SrcBuffDesc) - << "\nTest buff desc: " << GetObjectDescString(TestBufferDesc); - - RefCntAutoPtr pTestBufferVk(pBufferFromNativeVkHandle, IID_BufferVk); - ASSERT_NE(pTestBufferVk, nullptr); - EXPECT_EQ(pTestBufferVk->GetVkBuffer(), VkBufferHandle); - EXPECT_EQ(reinterpret_cast(pTestBufferVk->GetNativeHandle()), VkBufferHandle); -#endif -} - -} // namespace Testing - -} // namespace Diligent diff --git a/UnitTests/DiligentCoreAPITest/src/Vulkan/DrawCommandRefenceVk.cpp b/UnitTests/DiligentCoreAPITest/src/Vulkan/DrawCommandRefenceVk.cpp deleted file mode 100644 index 8122923c..00000000 --- a/UnitTests/DiligentCoreAPITest/src/Vulkan/DrawCommandRefenceVk.cpp +++ /dev/null @@ -1,274 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "Vulkan/TestingEnvironmentVk.h" -#include "Vulkan/TestingSwapChainVk.h" - -#include "DeviceContextVk.h" - -#include "volk/volk.h" - -namespace Diligent -{ - -namespace Testing -{ - -static const char* VSSource = R"( -#version 430 core - -#ifndef GL_ES -out gl_PerVertex -{ - vec4 gl_Position; -}; -#endif - -layout(location = 0) out vec3 out_Color; - -void main() -{ - vec4 Pos[6]; - Pos[0] = vec4(-1.0, -0.5, 0.0, 1.0); - Pos[1] = vec4(-0.5, +0.5, 0.0, 1.0); - Pos[2] = vec4( 0.0, -0.5, 0.0, 1.0); - - Pos[3] = vec4(+0.0, -0.5, 0.0, 1.0); - Pos[4] = vec4(+0.5, +0.5, 0.0, 1.0); - Pos[5] = vec4(+1.0, -0.5, 0.0, 1.0); - - vec3 Col[6]; - Col[0] = vec3(1.0, 0.0, 0.0); - Col[1] = vec3(0.0, 1.0, 0.0); - Col[2] = vec3(0.0, 0.0, 1.0); - - Col[3] = vec3(1.0, 0.0, 0.0); - Col[4] = vec3(0.0, 1.0, 0.0); - Col[5] = vec3(0.0, 0.0, 1.0); - - gl_Position = Pos[gl_VertexIndex]; - out_Color = Col[gl_VertexIndex]; -} -)"; - -static const char* PSSource = R"( -#version 430 core - -layout(location = 0) in vec3 in_Color; -layout(location = 0) out vec4 out_Color; - -void main() -{ - out_Color = vec4(in_Color, 1.0); -} -)"; - -void RenderDrawCommandRefenceVk(ISwapChain* pSwapChain) -{ - auto* pEnv = TestingEnvironmentVk::GetInstance(); - auto vkDevice = pEnv->GetVkDevice(); - auto* pContext = pEnv->GetDeviceContext(); - - const auto& SCDesc = pSwapChain->GetDesc(); - - VkResult res = VK_SUCCESS; - (void)res; - - auto* pTestingSwapChainVk = ValidatedCast(pSwapChain); - - auto vkVSModule = pEnv->CreateShaderModule(SHADER_TYPE_VERTEX, VSSource, static_cast(strlen(VSSource))); - ASSERT_TRUE(vkVSModule != VK_NULL_HANDLE); - auto vkPSModule = pEnv->CreateShaderModule(SHADER_TYPE_PIXEL, PSSource, static_cast(strlen(PSSource))); - ASSERT_TRUE(vkPSModule != VK_NULL_HANDLE); - - VkGraphicsPipelineCreateInfo PipelineCI = {}; - - PipelineCI.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; - PipelineCI.pNext = nullptr; - - VkPipelineShaderStageCreateInfo ShaderStages[2] = {}; - - ShaderStages[0].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; - ShaderStages[0].stage = VK_SHADER_STAGE_VERTEX_BIT; - ShaderStages[0].module = vkVSModule; - ShaderStages[0].pName = "main"; - - ShaderStages[1].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; - ShaderStages[1].stage = VK_SHADER_STAGE_FRAGMENT_BIT; - ShaderStages[1].module = vkPSModule; - ShaderStages[1].pName = "main"; - - PipelineCI.pStages = ShaderStages; - PipelineCI.stageCount = _countof(ShaderStages); - - VkPipelineLayoutCreateInfo PipelineLayoutCI = {}; - - PipelineLayoutCI.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; - VkPipelineLayout vkLayout = VK_NULL_HANDLE; - vkCreatePipelineLayout(vkDevice, &PipelineLayoutCI, nullptr, &vkLayout); - ASSERT_TRUE(vkLayout != VK_NULL_HANDLE); - PipelineCI.layout = vkLayout; - - VkPipelineVertexInputStateCreateInfo VertexInputStateCI = {}; - - VertexInputStateCI.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; - PipelineCI.pVertexInputState = &VertexInputStateCI; - - - VkPipelineInputAssemblyStateCreateInfo InputAssemblyCI = {}; - - InputAssemblyCI.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; - InputAssemblyCI.pNext = nullptr; - InputAssemblyCI.flags = 0; // reserved for future use - InputAssemblyCI.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST; - InputAssemblyCI.primitiveRestartEnable = VK_FALSE; - PipelineCI.pInputAssemblyState = &InputAssemblyCI; - - - VkPipelineTessellationStateCreateInfo TessStateCI = {}; - - TessStateCI.sType = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO; - TessStateCI.pNext = nullptr; - TessStateCI.flags = 0; // reserved for future use - PipelineCI.pTessellationState = &TessStateCI; - - - VkPipelineViewportStateCreateInfo ViewPortStateCI = {}; - - ViewPortStateCI.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; - ViewPortStateCI.pNext = nullptr; - ViewPortStateCI.flags = 0; // reserved for future use - ViewPortStateCI.viewportCount = 1; - - VkViewport Viewport = {}; - Viewport.y = static_cast(SCDesc.Height); - Viewport.width = static_cast(SCDesc.Width); - Viewport.height = -static_cast(SCDesc.Height); - Viewport.maxDepth = 1; - - ViewPortStateCI.pViewports = &Viewport; - ViewPortStateCI.scissorCount = ViewPortStateCI.viewportCount; // the number of scissors must match the number of viewports (23.5) - // (why the hell it is in the struct then?) - - VkRect2D ScissorRect = {}; - ScissorRect.extent.width = SCDesc.Width; - ScissorRect.extent.height = SCDesc.Height; - ViewPortStateCI.pScissors = &ScissorRect; - - PipelineCI.pViewportState = &ViewPortStateCI; - - VkPipelineRasterizationStateCreateInfo RasterizerStateCI = {}; - - RasterizerStateCI.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; - RasterizerStateCI.polygonMode = VK_POLYGON_MODE_FILL; - RasterizerStateCI.cullMode = VK_CULL_MODE_NONE; - RasterizerStateCI.lineWidth = 1; - - PipelineCI.pRasterizationState = &RasterizerStateCI; - - // Multisample state (24) - VkPipelineMultisampleStateCreateInfo MSStateCI = {}; - - MSStateCI.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; - MSStateCI.pNext = nullptr; - MSStateCI.flags = 0; // reserved for future use - // If subpass uses color and/or depth/stencil attachments, then the rasterizationSamples member of - // pMultisampleState must be the same as the sample count for those subpass attachments - MSStateCI.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; - MSStateCI.sampleShadingEnable = VK_FALSE; - MSStateCI.minSampleShading = 0; // a minimum fraction of sample shading if sampleShadingEnable is set to VK_TRUE. - uint32_t SampleMask[] = {0xFFFFFFFF, 0}; // Vulkan spec allows up to 64 samples - MSStateCI.pSampleMask = SampleMask; // an array of static coverage information that is ANDed with - // the coverage information generated during rasterization (25.3) - MSStateCI.alphaToCoverageEnable = VK_FALSE; // whether a temporary coverage value is generated based on - // the alpha component of the fragment's first color output - MSStateCI.alphaToOneEnable = VK_FALSE; // whether the alpha component of the fragment's first color output is replaced with one - PipelineCI.pMultisampleState = &MSStateCI; - - - VkPipelineDepthStencilStateCreateInfo DepthStencilStateCI = {}; - - DepthStencilStateCI.sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO; - PipelineCI.pDepthStencilState = &DepthStencilStateCI; - - - VkPipelineColorBlendStateCreateInfo BlendStateCI = {}; - - VkPipelineColorBlendAttachmentState Attachment = {}; - - Attachment.colorWriteMask = VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT | VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT; - - BlendStateCI.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; - BlendStateCI.pAttachments = &Attachment; - BlendStateCI.attachmentCount = 1; // must equal the colorAttachmentCount for the subpass - // in which this pipeline is used. - PipelineCI.pColorBlendState = &BlendStateCI; - - - VkPipelineDynamicStateCreateInfo DynamicStateCI = {}; - - DynamicStateCI.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; - PipelineCI.pDynamicState = &DynamicStateCI; - - PipelineCI.renderPass = pTestingSwapChainVk->GetRenderPass(); - PipelineCI.subpass = 0; - PipelineCI.basePipelineHandle = VK_NULL_HANDLE; // a pipeline to derive from - PipelineCI.basePipelineIndex = 0; // an index into the pCreateInfos parameter to use as a pipeline to derive from - - VkPipeline vkPipeline = VK_NULL_HANDLE; - res = vkCreateGraphicsPipelines(vkDevice, VK_NULL_HANDLE, 1, &PipelineCI, nullptr, &vkPipeline); - ASSERT_GE(res, 0); - ASSERT_TRUE(vkPipeline != VK_NULL_HANDLE); - - VkCommandBuffer vkCmdBuffer = pEnv->AllocateCommandBuffer(); - - pTestingSwapChainVk->BeginRenderPass(vkCmdBuffer, VK_PIPELINE_STAGE_VERTEX_SHADER_BIT | VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT); - vkCmdBindPipeline(vkCmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, vkPipeline); - vkCmdDraw(vkCmdBuffer, 6, 1, 0, 0); - pTestingSwapChainVk->EndRenderPass(vkCmdBuffer); - res = vkEndCommandBuffer(vkCmdBuffer); - VERIFY(res >= 0, "Failed to end command buffer"); - - RefCntAutoPtr pContextVk{pContext, IID_DeviceContextVk}; - - auto* pQeueVk = pContextVk->LockCommandQueue(); - auto vkQueue = pQeueVk->GetVkQueue(); - - VkSubmitInfo SubmitInfo = {}; - SubmitInfo.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; - SubmitInfo.pCommandBuffers = &vkCmdBuffer; - SubmitInfo.commandBufferCount = 1; - vkQueueSubmit(vkQueue, 1, &SubmitInfo, VK_NULL_HANDLE); - vkQueueWaitIdle(vkQueue); - - pContextVk->UnlockCommandQueue(); - - vkDestroyPipeline(vkDevice, vkPipeline, nullptr); - vkDestroyPipelineLayout(vkDevice, vkLayout, nullptr); - vkDestroyShaderModule(vkDevice, vkVSModule, nullptr); - vkDestroyShaderModule(vkDevice, vkPSModule, nullptr); -} - -} // namespace Testing - -} // namespace Diligent diff --git a/UnitTests/DiligentCoreAPITest/src/Vulkan/TestingEnvironmentVk.cpp b/UnitTests/DiligentCoreAPITest/src/Vulkan/TestingEnvironmentVk.cpp deleted file mode 100644 index fa242455..00000000 --- a/UnitTests/DiligentCoreAPITest/src/Vulkan/TestingEnvironmentVk.cpp +++ /dev/null @@ -1,641 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "Vulkan/TestingEnvironmentVk.h" - -#include "RenderDeviceVk.h" -#include "DeviceContextVk.h" - -#include "SPIRVUtils.h" - -#define VOLK_IMPLEMENTATION -#include "volk/volk.h" - -namespace Diligent -{ - -namespace Testing -{ - -void CreateTestingSwapChainVk(TestingEnvironmentVk* pEnv, - const SwapChainDesc& SCDesc, - ISwapChain** ppSwapChain); - -TestingEnvironmentVk::TestingEnvironmentVk(DeviceType deviceType, ADAPTER_TYPE AdapterType, const SwapChainDesc& SCDesc) : - TestingEnvironment{deviceType, AdapterType, SCDesc} -{ - InitializeGlslang(); - - // We have to use dynamic Vulkan loader because if an application is statically linked with vulkan-1.lib - // and the Vulkan library is not present on the system, the app will instantly crash. - volkInitialize(); - - RefCntAutoPtr pRenderDeviceVk{m_pDevice, IID_RenderDeviceVk}; - m_vkDevice = pRenderDeviceVk->GetVkDevice(); - - volkLoadInstance(pRenderDeviceVk->GetVkInstance()); - - RefCntAutoPtr pContextVk{m_pDeviceContext, IID_DeviceContextVk}; - - auto* pQeueVk = pContextVk->LockCommandQueue(); - auto QueueFamilyIndex = pQeueVk->GetQueueFamilyIndex(); - pContextVk->UnlockCommandQueue(); - - auto vkPhysicalDevice = pRenderDeviceVk->GetVkPhysicalDevice(); - vkGetPhysicalDeviceMemoryProperties(vkPhysicalDevice, &m_MemoryProperties); - - VkCommandPoolCreateInfo CmdPoolCI = {}; - CmdPoolCI.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; - CmdPoolCI.queueFamilyIndex = QueueFamilyIndex; - vkCreateCommandPool(m_vkDevice, &CmdPoolCI, nullptr, &m_vkCmdPool); - VERIFY_EXPR(m_vkCmdPool != VK_NULL_HANDLE); - - if (m_pSwapChain == nullptr) - { - CreateTestingSwapChainVk(this, SCDesc, &m_pSwapChain); - } -} - -TestingEnvironmentVk::~TestingEnvironmentVk() -{ - if (m_vkCmdPool != VK_NULL_HANDLE) - { - vkDestroyCommandPool(m_vkDevice, m_vkCmdPool, nullptr); - } - - FinalizeGlslang(); -} - -uint32_t TestingEnvironmentVk::GetMemoryTypeIndex(uint32_t memoryTypeBitsRequirement, - VkMemoryPropertyFlags requiredProperties) const -{ - // Iterate over all memory types available for the device - // For each pair of elements X and Y returned in memoryTypes, X must be placed at a lower index position than Y if: - // * either the set of bit flags of X is a strict subset of the set of bit flags of Y. - // * or the propertyFlags members of X and Y are equal, and X belongs to a memory heap with greater performance - - for (uint32_t memoryIndex = 0; memoryIndex < m_MemoryProperties.memoryTypeCount; memoryIndex++) - { - // Each memory type returned by vkGetPhysicalDeviceMemoryProperties must have its propertyFlags set - // to one of the following values: - // * 0 - // * HOST_VISIBLE_BIT | HOST_COHERENT_BIT - // * HOST_VISIBLE_BIT | HOST_CACHED_BIT - // * HOST_VISIBLE_BIT | HOST_CACHED_BIT | HOST_COHERENT_BIT - // * DEVICE_LOCAL_BIT - // * DEVICE_LOCAL_BIT | HOST_VISIBLE_BIT | HOST_COHERENT_BIT - // * DEVICE_LOCAL_BIT | HOST_VISIBLE_BIT | HOST_CACHED_BIT - // * DEVICE_LOCAL_BIT | HOST_VISIBLE_BIT | HOST_CACHED_BIT | HOST_COHERENT_BIT - // * DEVICE_LOCAL_BIT | LAZILY_ALLOCATED_BIT - // - // There must be at least one memory type with both the HOST_VISIBLE_BIT and HOST_COHERENT_BIT bits set - // There must be at least one memory type with the DEVICE_LOCAL_BIT bit set - - const uint32_t memoryTypeBit = (1 << memoryIndex); - const bool isRequiredMemoryType = (memoryTypeBitsRequirement & memoryTypeBit) != 0; - if (isRequiredMemoryType) - { - const VkMemoryPropertyFlags properties = m_MemoryProperties.memoryTypes[memoryIndex].propertyFlags; - const bool hasRequiredProperties = (properties & requiredProperties) == requiredProperties; - - if (hasRequiredProperties) - return memoryIndex; - } - } - return static_cast(-1); -} - -void TestingEnvironmentVk::CreateImage2D(uint32_t Width, - uint32_t Height, - VkFormat vkFormat, - VkImageUsageFlags vkUsage, - VkImageLayout vkInitialLayout, - VkDeviceMemory& vkMemory, - VkImage& vkImage) -{ - VkImageCreateInfo ImageCI = {}; - - ImageCI.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; - ImageCI.pNext = nullptr; - ImageCI.flags = 0; - ImageCI.imageType = VK_IMAGE_TYPE_2D; - ImageCI.format = vkFormat; - ImageCI.extent = VkExtent3D{Width, Height, 1}; - ImageCI.mipLevels = 1; - ImageCI.arrayLayers = 1; - ImageCI.samples = VK_SAMPLE_COUNT_1_BIT; - ImageCI.tiling = VK_IMAGE_TILING_OPTIMAL; - ImageCI.usage = vkUsage; - ImageCI.sharingMode = VK_SHARING_MODE_EXCLUSIVE; - ImageCI.queueFamilyIndexCount = 0; - ImageCI.pQueueFamilyIndices = nullptr; - ImageCI.initialLayout = vkInitialLayout; - - auto res = vkCreateImage(m_vkDevice, &ImageCI, nullptr, &vkImage); - ASSERT_GE(res, 0); - - VkMemoryRequirements MemReqs = {}; - vkGetImageMemoryRequirements(m_vkDevice, vkImage, &MemReqs); - - VkMemoryPropertyFlags ImageMemoryFlags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT; - auto MemoryTypeIndex = GetMemoryTypeIndex(MemReqs.memoryTypeBits, ImageMemoryFlags); - - VkMemoryAllocateInfo AllocInfo = {}; - AllocInfo.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; - AllocInfo.pNext = nullptr; - AllocInfo.allocationSize = MemReqs.size; - AllocInfo.memoryTypeIndex = MemoryTypeIndex; - - res = vkAllocateMemory(m_vkDevice, &AllocInfo, nullptr, &vkMemory); - ASSERT_GE(res, 0); - - res = vkBindImageMemory(m_vkDevice, vkImage, vkMemory, 0); - ASSERT_GE(res, 0); -} - -void TestingEnvironmentVk::CreateBuffer(VkDeviceSize Size, - VkBufferUsageFlags vkUsage, - VkMemoryPropertyFlags MemoryFlags, - VkDeviceMemory& vkMemory, - VkBuffer& vkBuffer) -{ - VkBufferCreateInfo BufferCI = {}; - - BufferCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; - BufferCI.pNext = nullptr; - BufferCI.flags = 0; - BufferCI.size = Size; - BufferCI.usage = vkUsage; - BufferCI.sharingMode = VK_SHARING_MODE_EXCLUSIVE; - BufferCI.queueFamilyIndexCount = 0; - BufferCI.pQueueFamilyIndices = nullptr; - - auto res = vkCreateBuffer(m_vkDevice, &BufferCI, nullptr, &vkBuffer); - ASSERT_GE(res, 0); - - VkMemoryRequirements MemReqs = {}; - vkGetBufferMemoryRequirements(m_vkDevice, vkBuffer, &MemReqs); - - auto MemoryTypeIndex = GetMemoryTypeIndex(MemReqs.memoryTypeBits, MemoryFlags); - - VkMemoryAllocateInfo AllocInfo = {}; - AllocInfo.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; - AllocInfo.pNext = nullptr; - AllocInfo.allocationSize = MemReqs.size; - AllocInfo.memoryTypeIndex = MemoryTypeIndex; - - res = vkAllocateMemory(m_vkDevice, &AllocInfo, nullptr, &vkMemory); - ASSERT_GE(res, 0); - - res = vkBindBufferMemory(m_vkDevice, vkBuffer, vkMemory, 0); - ASSERT_GE(res, 0); -} - - -VkRenderPassCreateInfo TestingEnvironmentVk::GetRenderPassCreateInfo( - Uint32 NumRenderTargets, - const VkFormat RTVFormats[], - VkFormat DSVFormat, - Uint32 SampleCount, - VkAttachmentLoadOp DepthAttachmentLoadOp, - VkAttachmentLoadOp ColorAttachmentLoadOp, - std::array& Attachments, - std::array& AttachmentReferences, - VkSubpassDescription& SubpassDesc) -{ - VERIFY_EXPR(NumRenderTargets <= MaxRenderTargets); - - // Prepare render pass create info (7.1) - VkRenderPassCreateInfo RenderPassCI = {}; - - RenderPassCI.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO; - RenderPassCI.pNext = nullptr; - RenderPassCI.flags = 0; // reserved for future use - RenderPassCI.attachmentCount = (DSVFormat != TEX_FORMAT_UNKNOWN ? 1 : 0) + NumRenderTargets; - - uint32_t AttachmentInd = 0; - VkSampleCountFlagBits SampleCountFlags = static_cast(SampleCount); - VkAttachmentReference* pDepthAttachmentReference = nullptr; - if (DSVFormat != TEX_FORMAT_UNKNOWN) - { - auto& DepthAttachment = Attachments[AttachmentInd]; - - DepthAttachment.flags = 0; // Allowed value VK_ATTACHMENT_DESCRIPTION_MAY_ALIAS_BIT - DepthAttachment.format = DSVFormat; - DepthAttachment.samples = SampleCountFlags; - DepthAttachment.loadOp = DepthAttachmentLoadOp; - DepthAttachment.storeOp = VK_ATTACHMENT_STORE_OP_STORE; // the contents generated during the render pass and within the render - // area are written to memory. For attachments with a depth/stencil format, - // this uses the access type VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT. - DepthAttachment.stencilLoadOp = DepthAttachmentLoadOp; - DepthAttachment.stencilStoreOp = VK_ATTACHMENT_STORE_OP_STORE; - DepthAttachment.initialLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; - DepthAttachment.finalLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; - - pDepthAttachmentReference = &AttachmentReferences[AttachmentInd]; - pDepthAttachmentReference->attachment = AttachmentInd; - pDepthAttachmentReference->layout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; - - ++AttachmentInd; - } - - VkAttachmentReference* pColorAttachmentsReference = NumRenderTargets > 0 ? &AttachmentReferences[AttachmentInd] : nullptr; - for (Uint32 rt = 0; rt < NumRenderTargets; ++rt, ++AttachmentInd) - { - auto& ColorAttachment = Attachments[AttachmentInd]; - - ColorAttachment.flags = 0; // Allowed value VK_ATTACHMENT_DESCRIPTION_MAY_ALIAS_BIT - ColorAttachment.format = RTVFormats[rt]; - ColorAttachment.samples = SampleCountFlags; - ColorAttachment.loadOp = ColorAttachmentLoadOp; - ColorAttachment.storeOp = VK_ATTACHMENT_STORE_OP_STORE; // the contents generated during the render pass and within the render - // area are written to memory. For attachments with a color format, - // this uses the access type VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT. - ColorAttachment.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; - ColorAttachment.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; - ColorAttachment.initialLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; - ColorAttachment.finalLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; - - auto& ColorAttachmentRef = AttachmentReferences[AttachmentInd]; - ColorAttachmentRef.attachment = AttachmentInd; - ColorAttachmentRef.layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; - } - - RenderPassCI.pAttachments = Attachments.data(); - RenderPassCI.subpassCount = 1; - RenderPassCI.pSubpasses = &SubpassDesc; - RenderPassCI.dependencyCount = 0; // the number of dependencies between pairs of subpasses, or zero indicating no dependencies. - RenderPassCI.pDependencies = nullptr; // an array of dependencyCount number of VkSubpassDependency structures describing - // dependencies between pairs of subpasses, or NULL if dependencyCount is zero. - - - SubpassDesc.flags = 0; // All bits for this type are defined by extensions - SubpassDesc.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS; // Currently, only graphics subpasses are supported. - SubpassDesc.inputAttachmentCount = 0; - SubpassDesc.pInputAttachments = nullptr; - SubpassDesc.colorAttachmentCount = NumRenderTargets; - SubpassDesc.pColorAttachments = pColorAttachmentsReference; - SubpassDesc.pResolveAttachments = nullptr; - SubpassDesc.pDepthStencilAttachment = pDepthAttachmentReference; - SubpassDesc.preserveAttachmentCount = 0; - SubpassDesc.pPreserveAttachments = nullptr; - - return RenderPassCI; -} - -VkShaderModule TestingEnvironmentVk::CreateShaderModule(const SHADER_TYPE ShaderType, const char* ShaderSource, int SourceCodeLen) -{ - auto Bytecode = GLSLtoSPIRV(ShaderType, ShaderSource, SourceCodeLen, nullptr); - VERIFY_EXPR(!Bytecode.empty()); - if (Bytecode.empty()) - return VK_NULL_HANDLE; - - VkShaderModuleCreateInfo ShaderModuleCI = {}; - - ShaderModuleCI.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; - ShaderModuleCI.pNext = nullptr; - ShaderModuleCI.flags = 0; - ShaderModuleCI.codeSize = Bytecode.size() * sizeof(uint32_t); - ShaderModuleCI.pCode = Bytecode.data(); - - VkShaderModule vkShaderModule = VK_NULL_HANDLE; - vkCreateShaderModule(m_vkDevice, &ShaderModuleCI, nullptr, &vkShaderModule); - VERIFY_EXPR(vkShaderModule != VK_NULL_HANDLE); - - return vkShaderModule; -} - -VkCommandBuffer TestingEnvironmentVk::AllocateCommandBuffer() -{ - VkCommandBufferAllocateInfo AllocInfo = {}; - - AllocInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; - AllocInfo.commandPool = m_vkCmdPool; - AllocInfo.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; - AllocInfo.commandBufferCount = 1; - - VkCommandBuffer vkCmdBuff = VK_NULL_HANDLE; - vkAllocateCommandBuffers(m_vkDevice, &AllocInfo, &vkCmdBuff); - VERIFY_EXPR(vkCmdBuff != VK_NULL_HANDLE); - - VkCommandBufferBeginInfo BeginInfo = {}; - - BeginInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; - BeginInfo.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; - auto res = vkBeginCommandBuffer(vkCmdBuff, &BeginInfo); - VERIFY(res >= 0, "Failed to begin command buffer"); - - return vkCmdBuff; -} - - -static VkPipelineStageFlags PipelineStageFromAccessFlags(VkAccessFlags AccessFlags, - const VkPipelineStageFlags EnabledGraphicsShaderStages) -{ - // 6.1.3 - VkPipelineStageFlags Stages = 0; - - while (AccessFlags != 0) - { - VkAccessFlagBits AccessFlag = static_cast(AccessFlags & (~(AccessFlags - 1))); - VERIFY_EXPR(AccessFlag != 0 && (AccessFlag & (AccessFlag - 1)) == 0); - AccessFlags &= ~AccessFlag; - - // An application MUST NOT specify an access flag in a synchronization command if it does not include a - // pipeline stage in the corresponding stage mask that is able to perform accesses of that type. - // A table that lists, for each access flag, which pipeline stages can perform that type of access is given in 6.1.3. - switch (AccessFlag) - { - // Read access to an indirect command structure read as part of an indirect drawing or dispatch command - case VK_ACCESS_INDIRECT_COMMAND_READ_BIT: - Stages |= VK_PIPELINE_STAGE_DRAW_INDIRECT_BIT; - break; - - // Read access to an index buffer as part of an indexed drawing command, bound by vkCmdBindIndexBuffer - case VK_ACCESS_INDEX_READ_BIT: - Stages |= VK_PIPELINE_STAGE_VERTEX_INPUT_BIT; - break; - - // Read access to a vertex buffer as part of a drawing command, bound by vkCmdBindVertexBuffers - case VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT: - Stages |= VK_PIPELINE_STAGE_VERTEX_INPUT_BIT; - break; - - // Read access to a uniform buffer - case VK_ACCESS_UNIFORM_READ_BIT: - Stages |= EnabledGraphicsShaderStages | VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT; - break; - - // Read access to an input attachment within a render pass during fragment shading - case VK_ACCESS_INPUT_ATTACHMENT_READ_BIT: - Stages |= VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT; - break; - - // Read access to a storage buffer, uniform texel buffer, storage texel buffer, sampled image, or storage image - case VK_ACCESS_SHADER_READ_BIT: - Stages |= EnabledGraphicsShaderStages | VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT; - break; - - // Write access to a storage buffer, storage texel buffer, or storage image - case VK_ACCESS_SHADER_WRITE_BIT: - Stages |= EnabledGraphicsShaderStages | VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT; - break; - - // Read access to a color attachment, such as via blending, logic operations, or via certain subpass load operations - case VK_ACCESS_COLOR_ATTACHMENT_READ_BIT: - Stages |= VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT; - break; - - // Write access to a color or resolve attachment during a render pass or via certain subpass load and store operations - case VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT: - Stages |= VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT; - break; - - // Read access to a depth/stencil attachment, via depth or stencil operations or via certain subpass load operations - case VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT: - Stages |= VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT; - break; - - // Write access to a depth/stencil attachment, via depth or stencil operations or via certain subpass load and store operations - case VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT: - Stages |= VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT; - break; - - // Read access to an image or buffer in a copy operation - case VK_ACCESS_TRANSFER_READ_BIT: - Stages |= VK_PIPELINE_STAGE_TRANSFER_BIT; - break; - - // Write access to an image or buffer in a clear or copy operation - case VK_ACCESS_TRANSFER_WRITE_BIT: - Stages |= VK_PIPELINE_STAGE_TRANSFER_BIT; - break; - - // Read access by a host operation. Accesses of this type are not performed through a resource, but directly on memory - case VK_ACCESS_HOST_READ_BIT: - Stages |= VK_PIPELINE_STAGE_HOST_BIT; - break; - - // Write access by a host operation. Accesses of this type are not performed through a resource, but directly on memory - case VK_ACCESS_HOST_WRITE_BIT: - Stages |= VK_PIPELINE_STAGE_HOST_BIT; - break; - - // Read access via non-specific entities. When included in a destination access mask, makes all available writes - // visible to all future read accesses on entities known to the Vulkan device - case VK_ACCESS_MEMORY_READ_BIT: - break; - - // Write access via non-specific entities. hen included in a source access mask, all writes that are performed - // by entities known to the Vulkan device are made available. When included in a destination access mask, makes - // all available writes visible to all future write accesses on entities known to the Vulkan device. - case VK_ACCESS_MEMORY_WRITE_BIT: - break; - - default: - UNEXPECTED("Unknown memory access flag"); - } - } - return Stages; -} - - -static VkPipelineStageFlags AccessMaskFromImageLayout(VkImageLayout Layout, - bool IsDstMask // false - source mask - // true - destination mask -) -{ - VkPipelineStageFlags AccessMask = 0; - switch (Layout) - { - // does not support device access. This layout must only be used as the initialLayout member - // of VkImageCreateInfo or VkAttachmentDescription, or as the oldLayout in an image transition. - // When transitioning out of this layout, the contents of the memory are not guaranteed to be preserved (11.4) - case VK_IMAGE_LAYOUT_UNDEFINED: - if (IsDstMask) - { - UNEXPECTED("The new layout used in a transition must not be VK_IMAGE_LAYOUT_UNDEFINED. " - "This layout must only be used as the initialLayout member of VkImageCreateInfo " - "or VkAttachmentDescription, or as the oldLayout in an image transition. (11.4)"); - } - break; - - // supports all types of device access - case VK_IMAGE_LAYOUT_GENERAL: - // VK_IMAGE_LAYOUT_GENERAL must be used for image load/store operations (13.1.1, 13.2.4) - AccessMask = VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT; - break; - - // must only be used as a color or resolve attachment in a VkFramebuffer (11.4) - case VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL: - AccessMask = VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT; - break; - - // must only be used as a depth/stencil attachment in a VkFramebuffer (11.4) - case VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL: - AccessMask = VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT; - break; - - // must only be used as a read-only depth/stencil attachment in a VkFramebuffer and/or as a read-only image in a shader (11.4) - case VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL: - AccessMask = VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT; - break; - - // must only be used as a read-only image in a shader (which can be read as a sampled image, - // combined image/sampler and/or input attachment) (11.4) - case VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL: - AccessMask = VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_INPUT_ATTACHMENT_READ_BIT; - break; - - // must only be used as a source image of a transfer command (11.4) - case VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL: - AccessMask = VK_ACCESS_TRANSFER_READ_BIT; - break; - - // must only be used as a destination image of a transfer command (11.4) - case VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL: - AccessMask = VK_ACCESS_TRANSFER_WRITE_BIT; - break; - - // does not support device access. This layout must only be used as the initialLayout member - // of VkImageCreateInfo or VkAttachmentDescription, or as the oldLayout in an image transition. - // When transitioning out of this layout, the contents of the memory are preserved. (11.4) - case VK_IMAGE_LAYOUT_PREINITIALIZED: - if (!IsDstMask) - { - AccessMask = VK_ACCESS_HOST_WRITE_BIT; - } - else - { - UNEXPECTED("The new layout used in a transition must not be VK_IMAGE_LAYOUT_PREINITIALIZED. " - "This layout must only be used as the initialLayout member of VkImageCreateInfo " - "or VkAttachmentDescription, or as the oldLayout in an image transition. (11.4)"); - } - break; - - case VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL: - AccessMask = VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT; - break; - - case VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL: - AccessMask = VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT; - break; - - case VK_IMAGE_LAYOUT_PRESENT_SRC_KHR: - AccessMask = VK_ACCESS_MEMORY_READ_BIT; - break; - - default: - UNEXPECTED("Unexpected image layout"); - break; - } - - return AccessMask; -} - -void TestingEnvironmentVk::TransitionImageLayout(VkCommandBuffer CmdBuffer, - VkImage Image, - VkImageLayout& CurrentLayout, - VkImageLayout NewLayout, - const VkImageSubresourceRange& SubresRange, - VkPipelineStageFlags EnabledGraphicsShaderStages, - VkPipelineStageFlags SrcStages, - VkPipelineStageFlags DestStages) -{ - if (CurrentLayout == NewLayout) - return; - - VkImageMemoryBarrier ImgBarrier = {}; - ImgBarrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; - ImgBarrier.pNext = nullptr; - ImgBarrier.srcAccessMask = 0; - ImgBarrier.dstAccessMask = 0; - ImgBarrier.oldLayout = CurrentLayout; - ImgBarrier.newLayout = NewLayout; - ImgBarrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; // source queue family for a queue family ownership transfer. - ImgBarrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; // destination queue family for a queue family ownership transfer. - ImgBarrier.image = Image; - ImgBarrier.subresourceRange = SubresRange; - ImgBarrier.srcAccessMask = AccessMaskFromImageLayout(CurrentLayout, false); - ImgBarrier.dstAccessMask = AccessMaskFromImageLayout(NewLayout, true); - - if (SrcStages == 0) - { - if (CurrentLayout == VK_IMAGE_LAYOUT_PRESENT_SRC_KHR) - { - SrcStages = VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT; - } - else if (ImgBarrier.srcAccessMask != 0) - { - SrcStages = PipelineStageFromAccessFlags(ImgBarrier.srcAccessMask, EnabledGraphicsShaderStages); - } - else - { - // An execution dependency with only VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT in the source stage - // mask will effectively not wait for any prior commands to complete. (6.1.2) - SrcStages = VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT; - } - } - - if (DestStages == 0) - { - if (NewLayout == VK_IMAGE_LAYOUT_PRESENT_SRC_KHR) - { - DestStages = VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT; - } - else if (ImgBarrier.dstAccessMask != 0) - { - DestStages = PipelineStageFromAccessFlags(ImgBarrier.dstAccessMask, EnabledGraphicsShaderStages); - } - else - { - // An execution dependency with only VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT in the destination - // stage mask will only prevent that stage from executing in subsequently submitted commands. - // As this stage does not perform any actual execution, this is not observable - in effect, - // it does not delay processing of subsequent commands. (6.1.2) - DestStages = VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT; - } - } - - vkCmdPipelineBarrier(CmdBuffer, - SrcStages, // must not be 0 - DestStages, // must not be 0 - 0, // a bitmask specifying how execution and memory dependencies are formed - 0, // memoryBarrierCount - nullptr, // pMemoryBarriers - 0, // bufferMemoryBarrierCount - nullptr, // pBufferMemoryBarriers - 1, - &ImgBarrier); - - CurrentLayout = NewLayout; -} - -TestingEnvironment* CreateTestingEnvironmentVk(DeviceType deviceType, ADAPTER_TYPE AdapterType, const SwapChainDesc& SCDesc) -{ - return new TestingEnvironmentVk{deviceType, AdapterType, SCDesc}; -} - -} // namespace Testing - -} // namespace Diligent diff --git a/UnitTests/DiligentCoreAPITest/src/Vulkan/TestingSwapChainVk.cpp b/UnitTests/DiligentCoreAPITest/src/Vulkan/TestingSwapChainVk.cpp deleted file mode 100644 index b89c91fc..00000000 --- a/UnitTests/DiligentCoreAPITest/src/Vulkan/TestingSwapChainVk.cpp +++ /dev/null @@ -1,297 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "Vulkan/TestingSwapChainVk.h" -#include "Vulkan/TestingEnvironmentVk.h" - -#include "RenderDeviceVk.h" -#include "DeviceContextVk.h" - -#include "volk/volk.h" - -namespace Diligent -{ - -namespace Testing -{ - -TestingSwapChainVk::TestingSwapChainVk(IReferenceCounters* pRefCounters, - TestingEnvironmentVk* pEnv, - const SwapChainDesc& SCDesc) : - TBase // - { - pRefCounters, - pEnv->GetDevice(), - pEnv->GetDeviceContext(), - SCDesc // - } -{ - m_vkDevice = pEnv->GetVkDevice(); - - VkFormat ColorFormat = VK_FORMAT_UNDEFINED; - switch (m_SwapChainDesc.ColorBufferFormat) - { - case TEX_FORMAT_RGBA8_UNORM: - ColorFormat = VK_FORMAT_R8G8B8A8_UNORM; - break; - - default: - UNSUPPORTED("Texture format ", GetTextureFormatAttribs(m_SwapChainDesc.ColorBufferFormat).Name, " is not a supported color buffer format"); - } - pEnv->CreateImage2D(m_SwapChainDesc.Width, m_SwapChainDesc.Height, ColorFormat, - VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT, - m_vkRenerTargetLayout, - m_vkRenderTargetMemory, m_vkRenderTargetImage); - - - VkFormat DepthFormat = VK_FORMAT_UNDEFINED; - switch (m_SwapChainDesc.DepthBufferFormat) - { - case TEX_FORMAT_D32_FLOAT: - DepthFormat = VK_FORMAT_D32_SFLOAT; - break; - - default: - UNSUPPORTED("Texture format ", GetTextureFormatAttribs(m_SwapChainDesc.DepthBufferFormat).Name, " is not a supported depth buffer format"); - } - pEnv->CreateImage2D(m_SwapChainDesc.Width, m_SwapChainDesc.Height, DepthFormat, - VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT, - m_vkDepthBufferLayout, - m_vkDepthBufferMemory, m_vkDepthBufferImage); - - { - VERIFY(m_SwapChainDesc.ColorBufferFormat == TEX_FORMAT_RGBA8_UNORM, "Unexpected color buffer format"); - m_StagingBufferSize = m_SwapChainDesc.Width * m_SwapChainDesc.Height * 4; - pEnv->CreateBuffer(m_StagingBufferSize, VK_IMAGE_USAGE_TRANSFER_DST_BIT, - VK_MEMORY_PROPERTY_HOST_COHERENT_BIT | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_CACHED_BIT, - m_vkStagingBufferMemory, m_vkStagingBuffer); - } - - VkImageViewCreateInfo ImageViewCI = {}; - - ImageViewCI.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; - ImageViewCI.pNext = nullptr; - ImageViewCI.flags = 0; // reserved for future use. - ImageViewCI.image = m_vkRenderTargetImage; - ImageViewCI.format = ColorFormat; - ImageViewCI.viewType = VK_IMAGE_VIEW_TYPE_2D; - ImageViewCI.components.r = VK_COMPONENT_SWIZZLE_IDENTITY; - ImageViewCI.components.g = VK_COMPONENT_SWIZZLE_IDENTITY; - ImageViewCI.components.b = VK_COMPONENT_SWIZZLE_IDENTITY; - ImageViewCI.components.a = VK_COMPONENT_SWIZZLE_IDENTITY; - - ImageViewCI.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; - ImageViewCI.subresourceRange.levelCount = 1; - ImageViewCI.subresourceRange.layerCount = 1; - - auto res = vkCreateImageView(m_vkDevice, &ImageViewCI, nullptr, &m_vkRenderTargetView); - VERIFY_EXPR(res >= 0); - - ImageViewCI.image = m_vkDepthBufferImage; - ImageViewCI.format = DepthFormat; - ImageViewCI.subresourceRange.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT; - - res = vkCreateImageView(m_vkDevice, &ImageViewCI, nullptr, &m_vkDepthBufferView); - VERIFY_EXPR(res >= 0); - - - std::array Attachments; - std::array AttachmentReferences; - - VkSubpassDescription Subpass; - - auto RenderPassCI = - TestingEnvironmentVk::GetRenderPassCreateInfo(1, &ColorFormat, DepthFormat, 1, - VK_ATTACHMENT_LOAD_OP_CLEAR, VK_ATTACHMENT_LOAD_OP_CLEAR, - Attachments, AttachmentReferences, Subpass); - res = vkCreateRenderPass(m_vkDevice, &RenderPassCI, nullptr, &m_vkRenderPass); - VERIFY_EXPR(res >= 0); - - CreateFramebuffer(); -} - -void TestingSwapChainVk::CreateFramebuffer() -{ - VkFramebufferCreateInfo FramebufferCI = {}; - - FramebufferCI.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO; - FramebufferCI.pNext = nullptr; - FramebufferCI.flags = 0; // reserved for future use - FramebufferCI.renderPass = m_vkRenderPass; - FramebufferCI.attachmentCount = 2; - VkImageView Attachments[2] = {m_vkDepthBufferView, m_vkRenderTargetView}; - FramebufferCI.pAttachments = Attachments; - FramebufferCI.width = m_SwapChainDesc.Width; - FramebufferCI.height = m_SwapChainDesc.Height; - FramebufferCI.layers = 1; - - auto res = vkCreateFramebuffer(m_vkDevice, &FramebufferCI, nullptr, &m_vkFramebuffer); - VERIFY_EXPR(res >= 0); -} - -TestingSwapChainVk::~TestingSwapChainVk() -{ - if (m_vkRenderTargetImage != VK_NULL_HANDLE) - vkDestroyImage(m_vkDevice, m_vkRenderTargetImage, nullptr); - if (m_vkRenderTargetMemory != VK_NULL_HANDLE) - vkFreeMemory(m_vkDevice, m_vkRenderTargetMemory, nullptr); - - if (m_vkDepthBufferImage != VK_NULL_HANDLE) - vkDestroyImage(m_vkDevice, m_vkDepthBufferImage, nullptr); - if (m_vkDepthBufferMemory != VK_NULL_HANDLE) - vkFreeMemory(m_vkDevice, m_vkDepthBufferMemory, nullptr); - - if (m_vkStagingBuffer != VK_NULL_HANDLE) - vkDestroyBuffer(m_vkDevice, m_vkStagingBuffer, nullptr); - if (m_vkStagingBufferMemory != VK_NULL_HANDLE) - vkFreeMemory(m_vkDevice, m_vkStagingBufferMemory, nullptr); - - if (m_vkRenderPass != VK_NULL_HANDLE) - vkDestroyRenderPass(m_vkDevice, m_vkRenderPass, nullptr); - if (m_vkFramebuffer != VK_NULL_HANDLE) - vkDestroyFramebuffer(m_vkDevice, m_vkFramebuffer, nullptr); - - if (m_vkRenderTargetView != VK_NULL_HANDLE) - vkDestroyImageView(m_vkDevice, m_vkRenderTargetView, nullptr); - if (m_vkDepthBufferView != VK_NULL_HANDLE) - vkDestroyImageView(m_vkDevice, m_vkDepthBufferView, nullptr); -} - -void TestingSwapChainVk::TransitionRenderTarget(VkCommandBuffer vkCmdBuffer, VkImageLayout Layout, VkPipelineStageFlags GraphicsShaderStages) -{ - m_ActiveGraphicsShaderStages = GraphicsShaderStages; - VkImageSubresourceRange SubresRange = {}; - - SubresRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; - SubresRange.layerCount = 1; - SubresRange.levelCount = 1; - TestingEnvironmentVk::TransitionImageLayout(vkCmdBuffer, m_vkRenderTargetImage, m_vkRenerTargetLayout, - Layout, SubresRange, GraphicsShaderStages); -} - -void TestingSwapChainVk::TransitionDepthBuffer(VkCommandBuffer vkCmdBuffer, VkImageLayout Layout, VkPipelineStageFlags GraphicsShaderStages) -{ - m_ActiveGraphicsShaderStages = GraphicsShaderStages; - VkImageSubresourceRange SubresRange = {}; - - SubresRange.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT; - SubresRange.layerCount = 1; - SubresRange.levelCount = 1; - TestingEnvironmentVk::TransitionImageLayout(vkCmdBuffer, m_vkDepthBufferImage, m_vkDepthBufferLayout, - Layout, SubresRange, GraphicsShaderStages); -} - -void TestingSwapChainVk::BeginRenderPass(VkCommandBuffer vkCmdBuffer, VkPipelineStageFlags GraphicsShaderStages) -{ - TransitionRenderTarget(vkCmdBuffer, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, GraphicsShaderStages); - TransitionDepthBuffer(vkCmdBuffer, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, GraphicsShaderStages); - - VkRenderPassBeginInfo BeginInfo = {}; - - BeginInfo.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO; - BeginInfo.renderPass = m_vkRenderPass; - BeginInfo.framebuffer = m_vkFramebuffer; - BeginInfo.renderArea.extent = VkExtent2D{m_SwapChainDesc.Width, m_SwapChainDesc.Height}; - - VkClearValue ClearValues[2] = {}; - - ClearValues[0].depthStencil.depth = 1; - ClearValues[1].color.float32[0] = 0; - ClearValues[1].color.float32[1] = 0; - ClearValues[1].color.float32[2] = 0; - ClearValues[1].color.float32[3] = 0; - - BeginInfo.clearValueCount = 2; - BeginInfo.pClearValues = ClearValues; - - vkCmdBeginRenderPass(vkCmdBuffer, &BeginInfo, VK_SUBPASS_CONTENTS_INLINE); -} - -void TestingSwapChainVk::EndRenderPass(VkCommandBuffer vkCmdBuffer) -{ - vkCmdEndRenderPass(vkCmdBuffer); -} - - -void TestingSwapChainVk::TakeSnapshot() -{ - auto* pEnv = TestingEnvironmentVk::GetInstance(); - auto* pContext = pEnv->GetDeviceContext(); - - VkCommandBuffer vkCmdBuffer = pEnv->AllocateCommandBuffer(); - - TransitionRenderTarget(vkCmdBuffer, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, m_ActiveGraphicsShaderStages); - - VkBufferImageCopy BuffImgCopy = {}; - - BuffImgCopy.imageExtent = VkExtent3D{m_SwapChainDesc.Width, m_SwapChainDesc.Height, 1}; - BuffImgCopy.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; - BuffImgCopy.imageSubresource.layerCount = 1; - VERIFY(m_SwapChainDesc.ColorBufferFormat == TEX_FORMAT_RGBA8_UNORM, "Unexpected color buffer format"); - BuffImgCopy.bufferRowLength = m_SwapChainDesc.Width; // In texels - - vkCmdCopyImageToBuffer(vkCmdBuffer, m_vkRenderTargetImage, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, - m_vkStagingBuffer, 1, &BuffImgCopy); - vkEndCommandBuffer(vkCmdBuffer); - - - RefCntAutoPtr pContextVk{pContext, IID_DeviceContextVk}; - - auto* pQeueVk = pContextVk->LockCommandQueue(); - auto vkQueue = pQeueVk->GetVkQueue(); - - VkSubmitInfo SubmitInfo = {}; - SubmitInfo.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; - SubmitInfo.pCommandBuffers = &vkCmdBuffer; - SubmitInfo.commandBufferCount = 1; - vkQueueSubmit(vkQueue, 1, &SubmitInfo, VK_NULL_HANDLE); - vkQueueWaitIdle(vkQueue); - - VERIFY_EXPR(m_StagingBufferSize == m_SwapChainDesc.Width * m_SwapChainDesc.Height * 4); - void* pStagingDataPtr = nullptr; - vkMapMemory(m_vkDevice, m_vkStagingBufferMemory, 0, m_StagingBufferSize, 0, &pStagingDataPtr); - - m_ReferenceDataPitch = m_SwapChainDesc.Width * 4; - m_ReferenceData.resize(m_SwapChainDesc.Height * m_ReferenceDataPitch); - for (Uint32 row = 0; row < m_SwapChainDesc.Height; ++row) - { - memcpy(&m_ReferenceData[row * m_ReferenceDataPitch], - reinterpret_cast(pStagingDataPtr) + m_SwapChainDesc.Width * 4 * row, - m_ReferenceDataPitch); - } - - vkUnmapMemory(m_vkDevice, m_vkStagingBufferMemory); - pContextVk->UnlockCommandQueue(); -} - -void CreateTestingSwapChainVk(TestingEnvironmentVk* pEnv, - const SwapChainDesc& SCDesc, - ISwapChain** ppSwapChain) -{ - TestingSwapChainVk* pTestingSC(MakeNewRCObj()(pEnv, SCDesc)); - pTestingSC->QueryInterface(IID_SwapChain, reinterpret_cast(ppSwapChain)); -} - -} // namespace Testing - -} // namespace Diligent diff --git a/UnitTests/DiligentCoreAPITest/src/Win32/TestingEnvironmentWin32.cpp b/UnitTests/DiligentCoreAPITest/src/Win32/TestingEnvironmentWin32.cpp deleted file mode 100644 index bc241ffc..00000000 --- a/UnitTests/DiligentCoreAPITest/src/Win32/TestingEnvironmentWin32.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "TestingEnvironment.h" - -#ifndef NOMINMAX -# define NOMINMAX -#endif -#include - -namespace Diligent -{ - -namespace Testing -{ - -TestingEnvironment::NativeWindow TestingEnvironment::CreateNativeWindow() -{ -#ifdef UNICODE - const auto* const WindowClassName = L"SampleApp"; -#else - const auto* const WindowClassName = "SampleApp"; -#endif - // Register window class - HINSTANCE instance = NULL; - - WNDCLASSEX wcex = {sizeof(WNDCLASSEX), CS_HREDRAW | CS_VREDRAW, DefWindowProc, - 0L, 0L, instance, NULL, NULL, NULL, NULL, WindowClassName, NULL}; - RegisterClassEx(&wcex); - - LONG WindowWidth = 512; - LONG WindowHeight = 512; - RECT rc = {0, 0, WindowWidth, WindowHeight}; - AdjustWindowRect(&rc, WS_OVERLAPPEDWINDOW, FALSE); - HWND wnd = CreateWindowA("SampleApp", "Dummy Window", - WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, - rc.right - rc.left, rc.bottom - rc.top, NULL, NULL, instance, NULL); - if (wnd == NULL) - LOG_ERROR_AND_THROW("Unable to create a window"); - - NativeWindow NativeWnd; - NativeWnd.NativeWindowHandle = wnd; - - return NativeWnd; -} - -} // namespace Testing - -} // namespace Diligent diff --git a/UnitTests/DiligentCoreAPITest/src/main.cpp b/UnitTests/DiligentCoreAPITest/src/main.cpp deleted file mode 100644 index bacaca9f..00000000 --- a/UnitTests/DiligentCoreAPITest/src/main.cpp +++ /dev/null @@ -1,176 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include - -#include "gtest/gtest.h" -#include "TestingEnvironment.h" - -#if PLATFORM_WIN32 -# include -#endif - - -namespace Diligent -{ - -namespace Testing -{ - -#if D3D11_SUPPORTED -TestingEnvironment* CreateTestingEnvironmentD3D11(DeviceType deviceType, ADAPTER_TYPE AdapterType, const SwapChainDesc& SCDesc); -#endif - -#if D3D12_SUPPORTED -TestingEnvironment* CreateTestingEnvironmentD3D12(DeviceType deviceType, ADAPTER_TYPE AdapterType, const SwapChainDesc& SCDesc); -#endif - -#if GL_SUPPORTED || GLES_SUPPORTED -TestingEnvironment* CreateTestingEnvironmentGL(DeviceType deviceType, ADAPTER_TYPE AdapterType, const SwapChainDesc& SCDesc); -#endif - -#if VULKAN_SUPPORTED -TestingEnvironment* CreateTestingEnvironmentVk(DeviceType deviceType, ADAPTER_TYPE AdapterType, const SwapChainDesc& SCDesc); -#endif - -#if METAL_SUPPORTED - -#endif - -} // namespace Testing - -} // namespace Diligent - - -using namespace Diligent; -using namespace Diligent::Testing; - -int main(int argc, char** argv) -{ -#if PLATFORM_WIN32 - _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); -#endif - - ::testing::InitGoogleTest(&argc, argv); - - DeviceType deviceType = DeviceType::Undefined; - ADAPTER_TYPE AdapterType = ADAPTER_TYPE_UNKNOWN; - for (int i = 1; i < argc; ++i) - { - const auto* arg = argv[i]; - if (strcmp(arg, "--mode=d3d11") == 0) - { - deviceType = DeviceType::D3D11; - } - else if (strcmp(arg, "--mode=d3d11_sw") == 0) - { - deviceType = DeviceType::D3D11; - AdapterType = ADAPTER_TYPE_SOFTWARE; - } - else if (strcmp(arg, "--mode=d3d12") == 0) - { - deviceType = DeviceType::D3D12; - } - else if (strcmp(arg, "--mode=d3d12_sw") == 0) - { - deviceType = DeviceType::D3D12; - AdapterType = ADAPTER_TYPE_SOFTWARE; - } - else if (strcmp(arg, "--mode=vk") == 0) - { - deviceType = DeviceType::Vulkan; - } - else if (strcmp(arg, "--mode=gl") == 0) - { - deviceType = DeviceType::OpenGL; - } - } - - if (deviceType == DeviceType::Undefined) - { - LOG_ERROR_MESSAGE("Device type is not specified"); - return -1; - } - - SwapChainDesc SCDesc; - SCDesc.Width = 512; - SCDesc.Height = 512; - SCDesc.ColorBufferFormat = TEX_FORMAT_RGBA8_UNORM; - SCDesc.DepthBufferFormat = TEX_FORMAT_D32_FLOAT; - - Diligent::Testing::TestingEnvironment* pEnv = nullptr; - try - { - switch (deviceType) - { -#if D3D11_SUPPORTED - case DeviceType::D3D11: - pEnv = CreateTestingEnvironmentD3D11(deviceType, AdapterType, SCDesc); - if (AdapterType == ADAPTER_TYPE_SOFTWARE) - std::cout << "\n\n\n================ Testing Diligent Core API in Direct3D11-SW mode =================\n\n"; - else - std::cout << "\n\n\n================== Testing Diligent Core API in Direct3D11 mode ==================\n\n"; - break; -#endif - -#if D3D12_SUPPORTED - case DeviceType::D3D12: - pEnv = CreateTestingEnvironmentD3D12(deviceType, AdapterType, SCDesc); - if (AdapterType == ADAPTER_TYPE_SOFTWARE) - std::cout << "\n\n\n================ Testing Diligent Core API in Direct3D12-SW mode =================\n\n"; - else - std::cout << "\n\n\n================== Testing Diligent Core API in Direct3D12 mode ==================\n\n"; - break; -#endif - -#if GL_SUPPORTED || GLES_SUPPORTED - case DeviceType::OpenGL: - case DeviceType::OpenGLES: - pEnv = CreateTestingEnvironmentGL(deviceType, AdapterType, SCDesc); - std::cout << "\n\n\n==================== Testing Diligent Core API in OpenGL mode ====================\n\n"; - break; - -#endif - -#if VULKAN_SUPPORTED - case DeviceType::Vulkan: - pEnv = CreateTestingEnvironmentVk(deviceType, AdapterType, SCDesc); - std::cout << "\n\n\n==================== Testing Diligent Core API in Vulkan mode ====================\n\n"; - break; - -#endif - - default: - LOG_ERROR_AND_THROW("Unsupported device type"); - } - } - catch (...) - { - return -1; - } - ::testing::AddGlobalTestEnvironment(pEnv); - - auto ret_val = RUN_ALL_TESTS(); - std::cout << "\n\n\n"; - return ret_val; -} diff --git a/UnitTests/DiligentCoreTest/CMakeLists.txt b/UnitTests/DiligentCoreTest/CMakeLists.txt deleted file mode 100644 index 780a9cc2..00000000 --- a/UnitTests/DiligentCoreTest/CMakeLists.txt +++ /dev/null @@ -1,28 +0,0 @@ -cmake_minimum_required (VERSION 3.6) - -project(DiligentCoreTest) - -file(GLOB COMMON_SOURCE src/Common/*) -file(GLOB GRAPHICS_ACCESSORIES_SOURCE src/GraphicsAccessories/*) -file(GLOB PLATFORMS_SOURCE src/Platforms/*) - -set(SOURCE ${COMMON_SOURCE} ${GRAPHICS_ACCESSORIES_SOURCE} ${PLATFORMS_SOURCE}) -set(INCLUDE) - -add_executable(DiligentCoreTest ${SOURCE} ${INCLUDE}) -set_common_target_properties(DiligentCoreTest) - -target_link_libraries(DiligentCoreTest -PRIVATE - gtest_main - Diligent-BuildSettings - Diligent-TargetPlatform - Diligent-GraphicsAccessories - Diligent-Common -) - -source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${SOURCE} ${INCLUDE}) - -set_target_properties(DiligentCoreTest PROPERTIES - FOLDER "DiligentCore/Tests" -) diff --git a/UnitTests/DiligentCoreTest/src/Common/AllocatorTest.cpp b/UnitTests/DiligentCoreTest/src/Common/AllocatorTest.cpp deleted file mode 100644 index 6bf30956..00000000 --- a/UnitTests/DiligentCoreTest/src/Common/AllocatorTest.cpp +++ /dev/null @@ -1,79 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "DefaultRawMemoryAllocator.h" -#include "FixedBlockMemoryAllocator.h" - -#include "gtest/gtest.h" - -using namespace Diligent; - -namespace -{ - -TEST(Common_FixedBlockMemoryAllocator, AllocDealloc) -{ - constexpr Uint32 AllocSize = 32; - constexpr Uint32 NumAllocationsPerPage = 16; - - FixedBlockMemoryAllocator TestAllocator(DefaultRawMemoryAllocator::GetAllocator(), AllocSize, NumAllocationsPerPage); - - void* Allocations[NumAllocationsPerPage][2] = {}; - for (int p = 0; p < 2; ++p) - { - for (int a = 1; a < NumAllocationsPerPage; ++a) - { - for (int i = 0; i < a; ++i) - Allocations[i][p] = TestAllocator.Allocate(AllocSize, "Fixed block allocator test", __FILE__, __LINE__); - - for (int i = a - 1; i >= 0; --i) - TestAllocator.Free(Allocations[i][p]); - - for (int i = 0; i < a; ++i) - { - auto* NewAlloc = TestAllocator.Allocate(AllocSize, "Fixed block allocator test", __FILE__, __LINE__); - EXPECT_EQ(Allocations[i][p], NewAlloc); - } - - for (int i = a - 1; i >= 0; --i) - TestAllocator.Free(Allocations[i][p]); - } - for (int i = 0; i < NumAllocationsPerPage; ++i) - Allocations[i][p] = TestAllocator.Allocate(AllocSize, "Fixed block allocator test", __FILE__, __LINE__); - } - - for (int p = 0; p < 2; ++p) - for (int i = 0; i < NumAllocationsPerPage; ++i) - TestAllocator.Free(Allocations[i][p]); - - for (int p = 0; p < 2; ++p) - for (int i = 0; i < NumAllocationsPerPage; ++i) - Allocations[i][p] = TestAllocator.Allocate(AllocSize, "Fixed block allocator test", __FILE__, __LINE__); - - for (int p = 0; p < 2; ++p) - for (int s = 0; s < 5; ++s) - for (int i = s; i < NumAllocationsPerPage; i += 5) - TestAllocator.Free(Allocations[i][p]); -} - -} // namespace diff --git a/UnitTests/DiligentCoreTest/src/Common/MathLibTest.cpp b/UnitTests/DiligentCoreTest/src/Common/MathLibTest.cpp deleted file mode 100644 index 63040de2..00000000 --- a/UnitTests/DiligentCoreTest/src/Common/MathLibTest.cpp +++ /dev/null @@ -1,929 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "BasicMath.h" -#include "AdvancedMath.h" - -#include "gtest/gtest.h" - -using namespace Diligent; - -namespace -{ - -// Constructors -TEST(Common_BasicMath, VectorConstructors) -{ - { - float2 f2{1, 2}; - - EXPECT_EQ(f2.x, 1); - EXPECT_EQ(f2.y, 2); - - EXPECT_EQ(f2.x, f2[0]); - EXPECT_EQ(f2.y, f2[1]); - } - - { - float3 f3{1, 2, 3}; - - EXPECT_EQ(f3.x, 1); - EXPECT_EQ(f3.y, 2); - EXPECT_EQ(f3.z, 3); - - EXPECT_EQ(f3.x, f3[0]); - EXPECT_EQ(f3.y, f3[1]); - EXPECT_EQ(f3.z, f3[2]); - } - - { - float4 f4{1, 2, 3, 4}; - - EXPECT_EQ(f4.x, 1); - EXPECT_EQ(f4.y, 2); - EXPECT_EQ(f4.z, 3); - EXPECT_EQ(f4.w, 4); - - EXPECT_EQ(f4.x, f4[0]); - EXPECT_EQ(f4.y, f4[1]); - EXPECT_EQ(f4.z, f4[2]); - EXPECT_EQ(f4.w, f4[3]); - } -} - -// a - b -TEST(Common_BasicMath, OpeartorMinus) -{ - { - auto v = float2{5, 3} - float2{1, 2}; - EXPECT_EQ(v.x, 4); - EXPECT_EQ(v.y, 1); - } - - { - auto v = float3{5, 3, 20} - float3{1, 2, 10}; - EXPECT_EQ(v.x, 4); - EXPECT_EQ(v.y, 1); - EXPECT_EQ(v.z, 10); - } - - { - auto v = float4{5, 3, 20, 200} - float4{1, 2, 10, 100}; - EXPECT_EQ(v.x, 4); - EXPECT_EQ(v.y, 1); - EXPECT_EQ(v.z, 10); - EXPECT_EQ(v.w, 100); - } -} - -// a -= b -TEST(Common_BasicMath, OpeartorMinusEqual) -{ - { - auto v = float2{5, 3}; - v -= float2{1, 2}; - EXPECT_EQ(v.x, 4); - EXPECT_EQ(v.y, 1); - } - - { - auto v = float3{5, 3, 20}; - v -= float3{1, 2, 10}; - EXPECT_EQ(v.x, 4); - EXPECT_EQ(v.y, 1); - EXPECT_EQ(v.z, 10); - } - - { - auto v = float4{5, 3, 20, 200}; - v -= float4{1, 2, 10, 100}; - EXPECT_EQ(v.x, 4); - EXPECT_EQ(v.y, 1); - EXPECT_EQ(v.z, 10); - EXPECT_EQ(v.w, 100); - } -} - -// -a -TEST(Common_BasicMath, UnaryMinus) -{ - { - auto v = -float2{1, 2}; - EXPECT_EQ(v.x, -1); - EXPECT_EQ(v.y, -2); - } - - { - auto v = -float3{1, 2, 3}; - EXPECT_EQ(v.x, -1); - EXPECT_EQ(v.y, -2); - EXPECT_EQ(v.z, -3); - } - - { - auto v = -float4{1, 2, 3, 4}; - EXPECT_EQ(v.x, -1); - EXPECT_EQ(v.y, -2); - EXPECT_EQ(v.z, -3); - EXPECT_EQ(v.w, -4); - } -} - -// a + b -TEST(Common_BasicMath, OperatorPlus) -{ - // a + b - { - auto v = float2{5, 3} + float2{1, 2}; - EXPECT_EQ(v.x, 6); - EXPECT_EQ(v.y, 5); - } - - { - auto v = float3{5, 3, 20} + float3{1, 2, 10}; - EXPECT_EQ(v.x, 6); - EXPECT_EQ(v.y, 5); - EXPECT_EQ(v.z, 30); - } - - { - auto v = float4{5, 3, 20, 200} + float4{1, 2, 10, 100}; - EXPECT_EQ(v.x, 6); - EXPECT_EQ(v.y, 5); - EXPECT_EQ(v.z, 30); - EXPECT_EQ(v.w, 300); - } -} - -// a += b -TEST(Common_BasicMath, OpeartorPlusEqual) -{ - { - auto v = float2{5, 3}; - v += float2{1, 2}; - EXPECT_EQ(v.x, 6); - EXPECT_EQ(v.y, 5); - } - - { - auto v = float3{5, 3, 20}; - v += float3{1, 2, 10}; - EXPECT_EQ(v.x, 6); - EXPECT_EQ(v.y, 5); - EXPECT_EQ(v.z, 30); - } - - { - auto v = float4{5, 3, 20, 200}; - v += float4{1, 2, 10, 100}; - EXPECT_EQ(v.x, 6); - EXPECT_EQ(v.y, 5); - EXPECT_EQ(v.z, 30); - EXPECT_EQ(v.w, 300); - } -} - -// a * b -TEST(Common_BasicMath, VectorVectorMultiply) -{ - { - auto v = float2{5, 3} * float2{1, 2}; - EXPECT_EQ(v.x, 5); - EXPECT_EQ(v.y, 6); - } - - { - auto v = float3{5, 3, 20} * float3{1, 2, 3}; - EXPECT_EQ(v.x, 5); - EXPECT_EQ(v.y, 6); - EXPECT_EQ(v.z, 60); - } - - { - auto v = float4{5, 3, 20, 200} * float4{1, 2, 3, 4}; - EXPECT_EQ(v.x, 5); - EXPECT_EQ(v.y, 6); - EXPECT_EQ(v.z, 60); - EXPECT_EQ(v.w, 800); - } -} - -// a *= b -TEST(Common_BasicMath, VectorVectorMultiplyEqual) -{ - { - auto v = float2{5, 3}; - v *= float2{1, 2}; - EXPECT_EQ(v.x, 5); - EXPECT_EQ(v.y, 6); - } - - { - auto v = float3{5, 3, 20}; - v *= float3{1, 2, 3}; - EXPECT_EQ(v.x, 5); - EXPECT_EQ(v.y, 6); - EXPECT_EQ(v.z, 60); - } - - { - auto v = float4{5, 3, 20, 200}; - v *= float4{1, 2, 3, 4}; - EXPECT_EQ(v.x, 5); - EXPECT_EQ(v.y, 6); - EXPECT_EQ(v.z, 60); - EXPECT_EQ(v.w, 800); - } -} - - -// a * s -TEST(Common_BasicMath, VectorScalarMultiply) -{ - { - auto v = float2{5, 3} * 2; - EXPECT_EQ(v.x, 10); - EXPECT_EQ(v.y, 6); - } - - { - auto v = float3{5, 3, 20} * 2; - EXPECT_EQ(v.x, 10); - EXPECT_EQ(v.y, 6); - EXPECT_EQ(v.z, 40); - } - - { - auto v = float4{5, 3, 20, 200} * 2; - EXPECT_EQ(v.x, 10); - EXPECT_EQ(v.y, 6); - EXPECT_EQ(v.z, 40); - EXPECT_EQ(v.w, 400); - } -} - -// a *= s -TEST(Common_BasicMath, VectorScalarMultiplyEqual) -{ - { - auto v = float2{5, 3}; - v *= 2; - EXPECT_EQ(v.x, 10); - EXPECT_EQ(v.y, 6); - } - - { - auto v = float3{5, 3, 20}; - v *= 2; - EXPECT_EQ(v.x, 10); - EXPECT_EQ(v.y, 6); - EXPECT_EQ(v.z, 40); - } - - { - auto v = float4{5, 3, 20, 200}; - v *= 2; - EXPECT_EQ(v.x, 10); - EXPECT_EQ(v.y, 6); - EXPECT_EQ(v.z, 40); - EXPECT_EQ(v.w, 400); - } -} - -// s * a -TEST(Common_BasicMath, ScalarVectorMultiply) -{ - { - auto v = 2.f * float2{5, 3}; - EXPECT_EQ(v.x, 10); - EXPECT_EQ(v.y, 6); - } - - { - auto v = 2.f * float3{5, 3, 20}; - EXPECT_EQ(v.x, 10); - EXPECT_EQ(v.y, 6); - EXPECT_EQ(v.z, 40); - } - - { - auto v = 2.f * float4{5, 3, 20, 200}; - EXPECT_EQ(v.x, 10); - EXPECT_EQ(v.y, 6); - EXPECT_EQ(v.z, 40); - EXPECT_EQ(v.w, 400); - } -} - -// a / s -TEST(Common_BasicMath, VectorScalarDivision) -{ - { - auto v = float2{10, 6} / 2; - EXPECT_EQ(v.x, 5); - EXPECT_EQ(v.y, 3); - } - - { - auto v = float3{10, 6, 40} / 2; - EXPECT_EQ(v.x, 5); - EXPECT_EQ(v.y, 3); - EXPECT_EQ(v.z, 20); - } - - { - auto v = float4{10, 6, 40, 400} / 2; - EXPECT_EQ(v.x, 5); - EXPECT_EQ(v.y, 3); - EXPECT_EQ(v.z, 20); - EXPECT_EQ(v.w, 200); - } -} - -// a / b -TEST(Common_BasicMath, VectorVectorDivision) -{ - { - auto v = float2{6, 4} / float2{1, 2}; - EXPECT_EQ(v.x, 6); - EXPECT_EQ(v.y, 2); - } - - { - auto v = float3{6, 3, 20} / float3{3, 1, 5}; - EXPECT_EQ(v.x, 2); - EXPECT_EQ(v.y, 3); - EXPECT_EQ(v.z, 4); - } - - { - auto v = float4{6, 3, 20, 200} / float4{3, 1, 5, 40}; - EXPECT_EQ(v.x, 2); - EXPECT_EQ(v.y, 3); - EXPECT_EQ(v.z, 4); - EXPECT_EQ(v.w, 5); - } -} - -// a /= b -TEST(Common_BasicMath, VectorVectorDivideEqual) -{ - { - auto v = float2{6, 4}; - v /= float2{1, 2}; - EXPECT_EQ(v.x, 6); - EXPECT_EQ(v.y, 2); - } - - { - auto v = float3{6, 3, 20}; - v /= float3{3, 1, 5}; - EXPECT_EQ(v.x, 2); - EXPECT_EQ(v.y, 3); - EXPECT_EQ(v.z, 4); - } - - { - auto v = float4{6, 3, 20, 200}; - v /= float4{3, 1, 5, 40}; - EXPECT_EQ(v.x, 2); - EXPECT_EQ(v.y, 3); - EXPECT_EQ(v.z, 4); - EXPECT_EQ(v.w, 5); - } -} - - -// a /= s -TEST(Common_BasicMath, VectorScalarDivideEqual) -{ - { - auto v = float2{6, 4}; - v /= 2; - EXPECT_EQ(v.x, 3); - EXPECT_EQ(v.y, 2); - } - - { - auto v = float3{4, 6, 20}; - v /= 2; - EXPECT_EQ(v.x, 2); - EXPECT_EQ(v.y, 3); - EXPECT_EQ(v.z, 10); - } - - { - auto v = float4{4, 6, 20, 200}; - v /= 2; - EXPECT_EQ(v.x, 2); - EXPECT_EQ(v.y, 3); - EXPECT_EQ(v.z, 10); - EXPECT_EQ(v.w, 100); - } -} - - -// max -TEST(Common_BasicMath, StdMax) -{ - { - auto v = std::max(float2{6, 4}, float2{1, 40}); - EXPECT_EQ(v.x, 6); - EXPECT_EQ(v.y, 40); - } - - { - auto v = std::max(float3{4, 6, 20}, float3{40, 3, 23}); - EXPECT_EQ(v.x, 40); - EXPECT_EQ(v.y, 6); - EXPECT_EQ(v.z, 23); - } - - { - auto v = std::max(float4{4, 6, 20, 100}, float4{40, 3, 23, 50}); - EXPECT_EQ(v.x, 40); - EXPECT_EQ(v.y, 6); - EXPECT_EQ(v.z, 23); - EXPECT_EQ(v.w, 100); - } -} - -// min -TEST(Common_BasicMath, StdMin) -{ - { - auto v = std::min(float2{6, 4}, float2{1, 40}); - EXPECT_EQ(v.x, 1); - EXPECT_EQ(v.y, 4); - } - - { - auto v = std::min(float3{4, 6, 20}, float3{40, 3, 23}); - EXPECT_EQ(v.x, 4); - EXPECT_EQ(v.y, 3); - EXPECT_EQ(v.z, 20); - } - - { - auto v = std::min(float4{4, 6, 20, 100}, float4{40, 3, 23, 50}); - EXPECT_EQ(v.x, 4); - EXPECT_EQ(v.y, 3); - EXPECT_EQ(v.z, 20); - EXPECT_EQ(v.w, 50); - } -} - -// a == b -TEST(Common_BasicMath, ComparisonOperators) -{ - { - EXPECT_TRUE(float2(1, 2) == float2(1, 2)); - EXPECT_TRUE(float3(1, 2, 3) == float3(1, 2, 3)); - EXPECT_TRUE(float4(1, 2, 3, 4) == float4(1, 2, 3, 4)); - } - - { - float4 vec4(1, 2, 3, 4); - float3 vec3 = vec4; - EXPECT_TRUE(vec3 == float3(1, 2, 3)); - } - - // a != b - { - EXPECT_TRUE(float2(1, 2) != float2(1, 9)); - EXPECT_TRUE(float2(9, 2) != float2(1, 2)); - EXPECT_TRUE(float3(1, 2, 3) != float3(9, 2, 3)); - EXPECT_TRUE(float3(1, 2, 3) != float3(1, 9, 3)); - EXPECT_TRUE(float3(1, 2, 3) != float3(1, 2, 9)); - EXPECT_TRUE(float4(1, 2, 3, 4) != float4(9, 2, 3, 4)); - EXPECT_TRUE(float4(1, 2, 3, 4) != float4(1, 9, 3, 4)); - EXPECT_TRUE(float4(1, 2, 3, 4) != float4(1, 2, 9, 4)); - EXPECT_TRUE(float4(1, 2, 3, 4) != float4(1, 2, 3, 9)); - } - - // a < b - { - // clang-format off - EXPECT_TRUE((float2(1, 5) < float2(3, 5)) == float2(1, 0)); - EXPECT_TRUE((float2(3, 1) < float2(3, 4)) == float2(0, 1)); - EXPECT_TRUE((float3(1, 5, 10) < float3(3, 5, 20)) == float3(1, 0, 1)); - EXPECT_TRUE((float3(3, 1, 2) < float3(3, 4, 2)) == float3(0, 1, 0)); - EXPECT_TRUE((float4(1, 4, 10, 50) < float4(3, 4, 20, 50)) == float4(1, 0, 1, 0)); - EXPECT_TRUE((float4(3, 1, 2, 30) < float4(3, 4, 2, 70)) == float4(0, 1, 0, 1)); - // clang-format on - } - - // a <= b - { - // clang-format off - EXPECT_TRUE((float2(1, 5) <= float2(1, 4)) == float2(1, 0)); - EXPECT_TRUE((float2(5, 2) <= float2(3, 2)) == float2(0, 1)); - EXPECT_TRUE((float3(3, 5, 10) <= float3(3, 4, 10)) == float3(1, 0, 1)); - EXPECT_TRUE((float3(5, 4, 2) <= float3(3, 4, 0)) == float3(0, 1, 0)); - EXPECT_TRUE((float4(3, 5, 20, 100) <= float4(3, 4, 20, 50)) == float4(1, 0, 1, 0)); - EXPECT_TRUE((float4(5, 4, 2, 70) <= float4(3, 4, 0, 70)) == float4(0, 1, 0, 1)); - // clang-format on - } - - // a >= b - { - // clang-format off - EXPECT_TRUE((float2(1, 5) >= float2(3, 5)) == float2(0, 1)); - EXPECT_TRUE((float2(3, 1) >= float2(3, 4)) == float2(1, 0)); - EXPECT_TRUE((float3(1, 5, 10) >= float3(3, 5, 20)) == float3(0, 1, 0)); - EXPECT_TRUE((float3(3, 1, 2) >= float3(3, 4, 2)) == float3(1, 0, 1)); - EXPECT_TRUE((float4(1, 4, 10, 50) >= float4(3, 4, 20, 50)) == float4(0, 1, 0, 1)); - EXPECT_TRUE((float4(3, 1, 2, 30) >= float4(3, 4, 2, 70)) == float4(1, 0, 1, 0)); - // clang-format on - } - - // a > b - { - // clang-format off - EXPECT_TRUE((float2(1, 5) > float2(1, 4)) == float2(0, 1)); - EXPECT_TRUE((float2(5, 2) > float2(3, 2)) == float2(1, 0)); - EXPECT_TRUE((float3(3, 5, 10) > float3(3, 4, 10)) == float3(0, 1, 0)); - EXPECT_TRUE((float3(5, 4, 2) > float3(3, 4, 0)) == float3(1, 0, 1)); - EXPECT_TRUE((float4(3, 5, 20, 100) > float4(3, 4, 20, 50)) == float4(0, 1, 0, 1)); - EXPECT_TRUE((float4(5, 4, 2, 70) > float4(3, 4, 0, 70)) == float4(1, 0, 1, 0)); - // clang-format on - } -} - -// Functions -TEST(Common_BasicMath, Abs) -{ - { - // clang-format off - EXPECT_EQ(abs(float2(-1, -5)), float2(1, 5)); - EXPECT_EQ(abs(float2( 1, 5)), float2(1, 5)); - - EXPECT_EQ(abs(float3(-1, -5, -10)), float3(1, 5, 10)); - EXPECT_EQ(abs(float3( 1, 5, 10)), float3(1, 5, 10)); - - EXPECT_EQ(abs(float4(-1, -5, -10, -100)), float4(1, 5, 10, 100)); - EXPECT_EQ(abs(float4( 1, 5, 10, 100)), float4(1, 5, 10, 100)); - // clang-format on - } - - // clamp - { - // clang-format off - EXPECT_EQ(clamp(-1, 1, 10), 1); - EXPECT_EQ(clamp(11, 1, 10), 10); - EXPECT_EQ(clamp( 9, 1, 10), 9); - - EXPECT_EQ(clamp(float2(-10, -11), float2(1, 2), float2(10, 11)), float2(1, 2)); - EXPECT_EQ(clamp(float2( 11, 12), float2(1, 2), float2(10, 11)), float2(10, 11)); - EXPECT_EQ(clamp(float2( 9, 8), float2(1, 2), float2(10, 11)), float2(9, 8)); - - EXPECT_EQ(clamp(float3(-10, -11, -12), float3(1, 2, 3), float3(10, 11, 12)), float3( 1, 2, 3)); - EXPECT_EQ(clamp(float3( 11, 12, 13), float3(1, 2, 3), float3(10, 11, 12)), float3(10, 11, 12)); - EXPECT_EQ(clamp(float3( 9, 8, 7), float3(1, 2, 3), float3(10, 11, 12)), float3( 9, 8, 7)); - - EXPECT_EQ(clamp(float4(-10, -11, -12, -13), float4(1, 2, 3, 4), float4(10, 11, 12, 13)), float4( 1, 2, 3, 4)); - EXPECT_EQ(clamp(float4( 11, 12, 13, 14), float4(1, 2, 3, 4), float4(10, 11, 12, 13)), float4(10, 11, 12, 13)); - EXPECT_EQ(clamp(float4( 9, 8, 7, 6), float4(1, 2, 3, 4), float4(10, 11, 12, 13)), float4( 9, 8, 7, 6)); - // clang-format on - } - - // dot - { - EXPECT_EQ(dot(float2(1, 2), float2(1, 2)), 5); - EXPECT_EQ(dot(float3(1, 2, 3), float3(1, 2, 3)), 14); - EXPECT_EQ(dot(float4(1, 2, 3, 4), float4(1, 2, 3, 4)), 30); - } - - // length - { - auto l = length(float2(3, 4)); - EXPECT_NEAR(l, 5.f, 1e-6); - } -} - - -TEST(Common_BasicMath, MatrixConstructors) -{ - // Matrix 2x2 - { - // clang-format off - float2x2 m1 - { - 1, 2, - 5, 6 - }; - float2x2 m2 - { - 1, 2, - 5, 6 - }; - // clang-format on - EXPECT_TRUE(m1._11 == 1 && m1._12 == 2 && - m1._21 == 5 && m1._22 == 6); - EXPECT_TRUE(m1[0][0] == 1 && m1[0][1] == 2 && - m1[1][0] == 5 && m1[1][1] == 6); - - EXPECT_TRUE(m1 == m2); - auto t = m1.Transpose().Transpose(); - EXPECT_TRUE(t == m1); - } - - // Matrix 3x3 - { - // clang-format off - float3x3 m1 - { - 1, 2, 3, - 5, 6, 7, - 9, 10, 11 - }; - float3x3 m2 - { - 1, 2, 3, - 5, 6, 7, - 9, 10, 11 - }; - - EXPECT_TRUE(m1._11 == 1 && m1._12 == 2 && m1._13 == 3 && - m1._21 == 5 && m1._22 == 6 && m1._23 == 7 && - m1._31 == 9 && m1._32 == 10 && m1._33 == 11); - EXPECT_TRUE(m1[0][0] == 1 && m1[0][1] == 2 && m1[0][2] == 3 && - m1[1][0] == 5 && m1[1][1] == 6 && m1[1][2] == 7 && - m1[2][0] == 9 && m1[2][1] == 10 && m1[2][2] == 11); - - // clang-format on - - EXPECT_TRUE(m1 == m2); - auto t = m1.Transpose().Transpose(); - EXPECT_TRUE(t == m1); - } - - // Matrix 4x4 - { - // clang-format off - float4x4 m1 - { - 1, 2, 3, 4, - 5, 6, 7, 8, - 9, 10, 11, 12, - 13, 14, 15, 16 - }; - - float4x4 m2 - { - 1, 2, 3, 4, - 5, 6, 7, 8, - 9, 10, 11, 12, - 13, 14, 15, 16 - }; - - EXPECT_TRUE(m1._11 == 1 && m1._12 == 2 && m1._13 == 3 && m1._14 == 4 && - m1._21 == 5 && m1._22 == 6 && m1._23 == 7 && m1._24 == 8 && - m1._31 == 9 && m1._32 == 10 && m1._33 == 11 && m1._34 == 12 && - m1._41 == 13 && m1._42 == 14 && m1._43 == 15 && m1._44 == 16); - EXPECT_TRUE(m1[0][0] == 1 && m1[0][1] == 2 && m1[0][2] == 3 && m1[0][3] == 4 && - m1[1][0] == 5 && m1[1][1] == 6 && m1[1][2] == 7 && m1[1][3] == 8 && - m1[2][0] == 9 && m1[2][1] == 10 && m1[2][2] == 11 && m1[2][3] == 12 && - m1[3][0] == 13 && m1[3][1] == 14 && m1[3][2] == 15 && m1[3][3] == 16); - // clang-format on - - EXPECT_TRUE(m1 == m2); - auto t = m1.Transpose().Transpose(); - EXPECT_TRUE(t == m1); - } -} - -TEST(Common_BasicMath, MatrixInverse) -{ - { - // clang-format off - float4x4 m - { - 7, 8, 3, 6, - 5, 1, 4, 9, - 5, 11, 7, 2, - 13, 4, 19, 8 - }; - // clang-format on - - auto inv = m.Inverse(); - auto identity = m * inv; - - for (int j = 0; j < 4; ++j) - { - for (int i = 0; i < 4; ++i) - { - float ref = i == j ? 1.f : 0.f; - auto val = identity[i][j]; - EXPECT_NEAR(val, ref, 1e-6f); - } - } - } - - // Determinant - { - // clang-format off - float4x4 m1 - { - 1, 2, 3, 4, - 5, 6, 7, 8, - 9, 10, 11, 12, - 13, 14, 15, 16 - }; - // clang-format on - auto det = m1.Determinant(); - EXPECT_EQ(det, 0); - } -} - - -TEST(Common_BasicMath, Hash) -{ - { - EXPECT_NE(std::hash{}(float2{1, 2}), 0); - EXPECT_NE(std::hash{}(float3{1, 2, 3}), 0); - EXPECT_NE(std::hash{}(float4{1, 2, 3, 5}), 0); - // clang-format off - float4x4 m1 - { - 1, 2, 3, 4, - 5, 6, 7, 8, - 9, 10, 11, 12, - 13, 14, 15, 16 - }; - // clang-format on - EXPECT_NE(std::hash{}(m1), 0); - - // clang-format off - float3x3 m2 - { - 1, 2, 3, - 5, 6, 7, - 9, 10, 11 - }; - // clang-format on - EXPECT_NE(std::hash{}(m2), 0); - - // clang-format off - float2x2 m3 - { - 1, 2, - 5, 6 - }; - // clang-format on - EXPECT_NE(std::hash{}(m3), 0); - } -} - -TEST(Common_BasicMath, OrthoProjection) -{ - { - float4x4 OrthoProj = float4x4::Ortho(2.f, 4.f, -4.f, 12.f, false); - - auto c0 = float3{-1.f, -2.f, -4.f} * OrthoProj; - auto c1 = float3{+1.f, +2.f, +12.f} * OrthoProj; - EXPECT_EQ(c0, float3(-1, -1, 0)); - EXPECT_EQ(c1, float3(+1, +1, +1)); - } - - { - float4x4 OrthoProj = float4x4::Ortho(2.f, 4.f, -4.f, 12.f, true); - - auto c0 = float3(-1.f, -2.f, -4.f) * OrthoProj; - auto c1 = float3(+1.f, +2.f, +12.f) * OrthoProj; - EXPECT_EQ(c0, float3(-1, -1, -1)); - EXPECT_EQ(c1, float3(+1, +1, +1)); - } - - { - float4x4 OrthoProj = float4x4::OrthoOffCenter(-2.f, 6.f, -4.f, +12.f, -6.f, 10.f, false); - - auto c0 = float3{-2.f, -4.f, -6.f} * OrthoProj; - auto c1 = float3{+6.f, +12.f, +10.f} * OrthoProj; - EXPECT_EQ(c0, float3(-1, -1, 0)); - EXPECT_EQ(c1, float3(+1, +1, +1)); - } - - { - float4x4 OrthoProj = float4x4::OrthoOffCenter(-2.f, 6.f, -4.f, +12.f, -6.f, 10.f, true); - - auto c0 = float3{-2.f, -4.f, -6.f} * OrthoProj; - auto c1 = float3{+6.f, +12.f, +10.f} * OrthoProj; - EXPECT_EQ(c0, float3(-1, -1, -1)); - EXPECT_EQ(c1, float3(+1, +1, +1)); - } -} - -TEST(Common_BasicMath, MakeObject) -{ - double data[] = {1, 2, 3, 4, - 5, 6, 7, 8, - 9, 10, 11, 12, - 13, 14, 15, 16}; - EXPECT_EQ(float2::MakeVector(data), float2(1, 2)); - EXPECT_EQ(float3::MakeVector(data), float3(1, 2, 3)); - EXPECT_EQ(float4::MakeVector(data), float4(1, 2, 3, 4)); - EXPECT_EQ(Quaternion::MakeQuaternion(data), Quaternion(1, 2, 3, 4)); - EXPECT_EQ(float4x4::MakeMatrix(data), float4x4(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)); - EXPECT_EQ(float3x3::MakeMatrix(data), float3x3(1, 2, 3, 4, 5, 6, 7, 8, 9)); - EXPECT_EQ(float2x2::MakeMatrix(data), float2x2(1, 2, 3, 4)); -} - -TEST(Common_BasicMath, MatrixMultiply) -{ - { - float2x2 m1(1, 2, 3, 4); - float2x2 m2(5, 6, 7, 8); - - auto m = m1; - m *= m2; - EXPECT_EQ(m, m1 * m2); - } - { - float3x3 m1(1, 2, 3, - 4, 5, 6, - 7, 8, 9); - float3x3 m2(10, 11, 12, - 13, 14, 15, - 16, 17, 18); - - auto m = m1; - m *= m2; - EXPECT_EQ(m, m1 * m2); - } - { - float4x4 m1(1, 2, 3, 4, - 5, 6, 7, 8, - 9, 10, 11, 12, - 13, 14, 15, 16); - float4x4 m2(17, 18, 19, 20, - 21, 22, 23, 24, - 25, 26, 27, 28, - 29, 30, 31, 32); - - auto m = m1; - m *= m2; - EXPECT_EQ(m, m1 * m2); - } -} - -TEST(Common_BasicMath, VectorRecast) -{ - { - EXPECT_EQ(float2(1, 2).Recast(), Vector2(1, 2)); - EXPECT_EQ(float3(1, 2, 3).Recast(), Vector3(1, 2, 3)); - EXPECT_EQ(float4(1, 2, 3, 4).Recast(), Vector4(1, 2, 3, 4)); - } -} - -TEST(Common_BasicMath, StdFloorCeil) -{ - { - EXPECT_EQ(std::floor(float2(0.1f, 1.2f)), float2(0, 1)); - EXPECT_EQ(std::floor(float3(0.1f, 1.2f, 2.3f)), float3(0, 1, 2)); - EXPECT_EQ(std::floor(float4(0.1f, 1.2f, 2.3f, 3.4f)), float4(0, 1, 2, 3)); - EXPECT_EQ(std::ceil(float2(0.1f, 1.2f)), float2(1, 2)); - EXPECT_EQ(std::ceil(float3(0.1f, 1.2f, 2.3f)), float3(1, 2, 3)); - EXPECT_EQ(std::ceil(float4(0.1f, 1.2f, 2.3f, 3.4f)), float4(1, 2, 3, 4)); - } -} - -TEST(Common_AdvancedMath, Planes) -{ - Plane3D plane = {}; - EXPECT_NE(std::hash{}(plane), 0); - - ViewFrustum frustum = {}; - EXPECT_NE(std::hash{}(frustum), 0); - - ViewFrustumExt frustm_ext = {}; - EXPECT_NE(std::hash{}(frustm_ext), 0); -} - -TEST(Common_AdvancedMath, HermiteSpline) -{ - EXPECT_NE(HermiteSpline(float3(1, 2, 3), float3(4, 5, 6), float3(7, 8, 9), float3(10, 11, 12), 0.1f), float3(0, 0, 0)); - EXPECT_NE(HermiteSpline(double3(1, 2, 3), double3(4, 5, 6), double3(7, 8, 9), double3(10, 11, 12), 0.1), double3(0, 0, 0)); -} - -} // namespace diff --git a/UnitTests/DiligentCoreTest/src/Common/RefCntAutoPtrTest.cpp b/UnitTests/DiligentCoreTest/src/Common/RefCntAutoPtrTest.cpp deleted file mode 100644 index 11d3e381..00000000 --- a/UnitTests/DiligentCoreTest/src/Common/RefCntAutoPtrTest.cpp +++ /dev/null @@ -1,903 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include -#include -#include -#include -#include - -#include "DefaultRawMemoryAllocator.h" -#include "RefCntAutoPtr.h" -#include "RefCountedObjectImpl.h" -#include "ThreadSignal.h" - -#include "gtest/gtest.h" - -using namespace Diligent; - -template -Type* MakeNewObj() -{ - return MakeNewRCObj{}(); -} - -namespace -{ - -class Object : public Diligent::RefCountedObject -{ -public: - static void Create(Object** ppObj) - { - *ppObj = MakeNewObj(); - (*ppObj)->AddRef(); - } - - virtual void QueryInterface(const Diligent::INTERFACE_ID& IID, Diligent::IObject** ppInterface) - { - *ppInterface = nullptr; - if (IID == Diligent::IID_Unknown) - { - *ppInterface = this; - (*ppInterface)->AddRef(); - } - } - - Object(Diligent::IReferenceCounters* pRefCounters) : - RefCountedObject{pRefCounters}, - m_Value(0) - { - } - - ~Object() {} - std::atomic_int m_Value; -}; - - -class DerivedObject : public Object -{ -public: - DerivedObject(Diligent::IReferenceCounters* pRefCounters) : - Object{pRefCounters}, - m_Value2{1} - {} - int m_Value2; -}; - -using SmartPtr = Diligent::RefCntAutoPtr; -using WeakPtr = Diligent::RefCntWeakPtr; - -TEST(Common_RefCntAutoPtr, Constructors) -{ - { - SmartPtr SP0; - SmartPtr SP1(nullptr); - auto* pRawPtr = MakeNewObj(); - SmartPtr SP2(pRawPtr); - SmartPtr SP2_1(pRawPtr); - EXPECT_EQ(SP2, SP2_1); - - SmartPtr SP3(SP0); - SmartPtr SP4(SP2); - SmartPtr SP5(std::move(SP3)); - EXPECT_TRUE(!SP3); - SmartPtr SP6(std::move(SP4)); - EXPECT_TRUE(!SP4); - - RefCntAutoPtr DerivedSP(MakeNewObj()); - - SmartPtr SP7(DerivedSP); - SmartPtr SP8(std::move(DerivedSP)); - EXPECT_EQ(SP7, SP8); - EXPECT_TRUE(!DerivedSP); - } -} - -TEST(Common_RefCntAutoPtr, AttachDetach) -{ - { - auto* pRawPtr = MakeNewObj(); - - SmartPtr SP0; - SP0.Attach(nullptr); - EXPECT_TRUE(!SP0); - SP0.Attach(pRawPtr); - EXPECT_TRUE(SP0); - pRawPtr->AddRef(); - } - - { - auto* pRawPtr = MakeNewObj(); - - SmartPtr SP0; - pRawPtr->AddRef(); - SP0.Attach(pRawPtr); - EXPECT_TRUE(SP0); - SP0.Attach(nullptr); - EXPECT_TRUE(!SP0); - } - - { - auto* pRawPtr = MakeNewObj(); - - SmartPtr SP0(MakeNewObj()); - SP0.Attach(pRawPtr); - EXPECT_TRUE(SP0); - pRawPtr->AddRef(); - } - - { - SmartPtr SP0(MakeNewObj()); - EXPECT_TRUE(SP0); - - auto* pRawPtr = MakeNewObj(); - pRawPtr->AddRef(); - SP0.Attach(pRawPtr); - auto* pRawPtr2 = SP0.Detach(); - pRawPtr2->Release(); - - auto* pRawPtr3 = SmartPtr().Detach(); - EXPECT_TRUE(pRawPtr3 == nullptr); - auto* pRawPtr4 = SmartPtr(MakeNewObj()).Detach(); - EXPECT_TRUE(pRawPtr4 != nullptr); - pRawPtr4->Release(); - } -} - -TEST(Common_RefCntAutoPtr, OperatorEqual) -{ - { - SmartPtr SP0; - auto pRawPtr1 = MakeNewObj(); - SmartPtr SP1(pRawPtr1); - SmartPtr SP2(pRawPtr1); - SP0 = SP0; - SP0 = std::move(SP0); - SP0 = nullptr; - EXPECT_EQ(SP0, nullptr); - - SP1 = pRawPtr1; - SP1 = SP1; - SP1 = std::move(SP1); - EXPECT_EQ(SP1, pRawPtr1); - - SP1 = SP2; - SP1 = std::move(SP2); - EXPECT_EQ(SP1, pRawPtr1); - - auto pRawPtr2 = MakeNewObj(); - SmartPtr SP3(pRawPtr2); - - SP0 = pRawPtr2; - SmartPtr SP4; - SP4 = SP3; - SmartPtr SP5; - SP5 = std::move(SP4); - EXPECT_TRUE(!SP4); - - SP1 = pRawPtr2; - SP1 = nullptr; - SP1 = std::move(SP5); - EXPECT_TRUE(!SP5); - - RefCntAutoPtr DerivedSP(MakeNewObj()); - SP1 = DerivedSP; - SP2 = std::move(DerivedSP); - EXPECT_TRUE(!DerivedSP); - } -} - -TEST(Common_RefCntAutoPtr, LogicalOperators) -{ - { - auto pRawPtr1 = MakeNewObj(); - auto pRawPtr2 = MakeNewObj(); - SmartPtr SP0, SP1(pRawPtr1), SP2(pRawPtr1), SP3(pRawPtr2); - EXPECT_TRUE(!SP0); - bool b1 = SP0.operator bool(); - EXPECT_TRUE(!b1); - - - EXPECT_TRUE(!(!SP1)); - EXPECT_TRUE(SP1); - EXPECT_TRUE(SP0 != SP1); - EXPECT_TRUE(SP0 == SP0); - EXPECT_TRUE(SP1 == SP1); - EXPECT_TRUE(SP1 == SP2); - EXPECT_TRUE(SP1 != SP3); - EXPECT_TRUE(SP0 < SP3); - EXPECT_TRUE((SP1 < SP3) == (pRawPtr1 < pRawPtr2)); - } -} - -TEST(Common_RefCntAutoPtr, OperatorAmpersand) -{ - { - SmartPtr SP0, SP1(MakeNewObj()), SP2, SP3, SP4(MakeNewObj()); - auto* pRawPtr = MakeNewObj(); - pRawPtr->AddRef(); - - *static_cast(&SP0) = pRawPtr; - SP0.Detach(); - *&SP2 = pRawPtr; - SP2.Detach(); - - Object::Create(&SP3); - - Object::Create(&SP1); - *static_cast(&SP4) = pRawPtr; - - { - SmartPtr SP5(MakeNewObj()); - auto pDblPtr = &SP5; - *pDblPtr = MakeNewObj(); - (*pDblPtr)->AddRef(); - auto pDblPtr2 = &SP5; - Object::Create(pDblPtr2); - } - - SmartPtr SP6(MakeNewObj()); - // This will not work: - // Object **pDblPtr3 = &SP6; - // *pDblPtr3 = new Object; - } -} - -TEST(Common_RefCntWeakPtr, Constructors) -{ - { - SmartPtr SP0, SP1(MakeNewObj()); - WeakPtr WP0; - WeakPtr WP1(WP0); - WeakPtr WP2(SP0); - WeakPtr WP3(SP1); - WeakPtr WP4(WP3); - WeakPtr WP5(std::move(WP0)); - WeakPtr WP6(std::move(WP4)); - - auto* pRawPtr = MakeNewObj(); - pRawPtr->AddRef(); - WeakPtr WP7(pRawPtr); - pRawPtr->Release(); - } -} - - -TEST(Common_RefCntWeakPtr, OperatorEqual) -{ - { - auto* pRawPtr = MakeNewObj(); - SmartPtr SP0, SP1(pRawPtr); - WeakPtr WP0, WP1(SP1), WP2(SP1); - WP0 = WP0; - WP0 = std::move(WP0); - WP1 = WP1; - WP1 = std::move(WP1); - WP1 = WP2; - WP1 = std::move(WP2); - WP1 = pRawPtr; - WP0 = pRawPtr; - WP0.Release(); - WP0 = WP2; - - WP1 = WP0; - WP0 = SP1; - WP2 = std::move(WP1); - } -} - -TEST(Common_RefCntWeakPtr, Lock) -{ - { - SmartPtr SP0, SP1(MakeNewObj()); - WeakPtr WP0, WP1(SP0), WP2(SP1), WP3(SP1); - assert(WP0 == WP1); - assert(WP0 != WP2); - assert(WP2 == WP3); - SP1.Release(); - assert(WP2 == WP3); - } - - // Test Lock() - { - SmartPtr SP0, SP1(MakeNewObj()); - WeakPtr WP0, WP1(SP0), WP2(SP1); - WeakPtr WP3(WP2); - auto L1 = WP0.Lock(); - assert(!L1); - L1 = WP1.Lock(); - assert(!L1); - L1 = WP2.Lock(); - assert(L1); - L1 = WP3.Lock(); - assert(L1); - auto pRawPtr = SP1.Detach(); - L1.Release(); - - L1 = WP3.Lock(); - assert(L1); - L1.Release(); - - pRawPtr->Release(); - - L1 = WP3.Lock(); - assert(!L1); - } -} - -TEST(Common_RefCntAutoPtr, Misc) -{ - { - class OwnerTest : public RefCountedObject - { - public: - OwnerTest(IReferenceCounters* pRefCounters) : - RefCountedObject(pRefCounters), - Obj(NEW_RC_OBJ(DefaultRawMemoryAllocator::GetAllocator(), "Test object", Object, this)()) - { - } - - virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) {} - ~OwnerTest() - { - Obj->~Object(); - DefaultRawMemoryAllocator::GetAllocator().Free(Obj); - } - - private: - Object* Obj; - }; - - OwnerTest* pOwnerObject = MakeNewObj(); - pOwnerObject->AddRef(); - pOwnerObject->Release(); - } - - { - class SelfRefTest : public RefCountedObject - { - public: - SelfRefTest(IReferenceCounters* pRefCounters) : - RefCountedObject(pRefCounters), - wpSelf(this) - {} - - virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) {} - - private: - RefCntWeakPtr wpSelf; - }; - - SelfRefTest* pSelfRefTest = MakeNewObj(); - pSelfRefTest->AddRef(); - pSelfRefTest->Release(); - } - - { - class ExceptionTest1 : public RefCountedObject - { - public: - ExceptionTest1(IReferenceCounters* pRefCounters) : - RefCountedObject(pRefCounters), - wpSelf(this) - { - throw std::runtime_error("test exception"); - } - - virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) {} - - private: - RefCntWeakPtr wpSelf; - }; - - try - { - auto* pExceptionTest = MakeNewObj(); - (void)pExceptionTest; - } - catch (std::runtime_error&) - { - } - } - - { - class ExceptionTest2 : public RefCountedObject - { - public: - ExceptionTest2(IReferenceCounters* pRefCounters) : - RefCountedObject(pRefCounters), - wpSelf(this) - { - throw std::runtime_error("test exception"); - } - - virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) {} - - private: - RefCntWeakPtr wpSelf; - }; - - try - { - auto* pExceptionTest = NEW_RC_OBJ(DefaultRawMemoryAllocator::GetAllocator(), "Test object", ExceptionTest2)(); - (void)pExceptionTest; - } - catch (std::runtime_error&) - { - } - } - - { - class ExceptionTest3 : public RefCountedObject - { - public: - ExceptionTest3(IReferenceCounters* pRefCounters) : - RefCountedObject(pRefCounters), - m_Member(*this) - { - } - - class Subclass - { - public: - Subclass(ExceptionTest3& parent) : - wpSelf(&parent) - { - throw std::runtime_error("test exception"); - } - - private: - RefCntWeakPtr wpSelf; - }; - virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) {} - - private: - Subclass m_Member; - }; - - try - { - auto* pExceptionTest = NEW_RC_OBJ(DefaultRawMemoryAllocator::GetAllocator(), "Test object", ExceptionTest3)(); - (void)pExceptionTest; - } - catch (std::runtime_error&) - { - } - } - - { - class OwnerObject : public RefCountedObject - { - public: - OwnerObject(IReferenceCounters* pRefCounters) : - RefCountedObject(pRefCounters) - {} - - void CreateMember() - { - try - { - m_pMember = NEW_RC_OBJ(DefaultRawMemoryAllocator::GetAllocator(), "Test object", ExceptionTest4, this)(*this); - } - catch (...) - { - } - } - virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) {} - - class ExceptionTest4 : public RefCountedObject - { - public: - ExceptionTest4(IReferenceCounters* pRefCounters, OwnerObject& owner) : - RefCountedObject(pRefCounters), - m_Member(owner, *this) - { - } - - class Subclass - { - public: - Subclass(OwnerObject& owner, ExceptionTest4& parent) : - wpParent(&parent), - wpOwner(&owner) - { - throw std::runtime_error("test exception"); - } - - private: - RefCntWeakPtr wpParent; - RefCntWeakPtr wpOwner; - }; - virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) {} - - private: - Subclass m_Member; - }; - - RefCntAutoPtr m_pMember; - }; - - RefCntAutoPtr pOwner(NEW_RC_OBJ(DefaultRawMemoryAllocator::GetAllocator(), "Test object", OwnerObject)()); - pOwner->CreateMember(); - } - - - { - class OwnerObject : public RefCountedObject - { - public: - OwnerObject(IReferenceCounters* pRefCounters) : - RefCountedObject(pRefCounters) - { - m_pMember = NEW_RC_OBJ(DefaultRawMemoryAllocator::GetAllocator(), "Test object", ExceptionTest4, this)(*this); - } - - virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) {} - - class ExceptionTest4 : public RefCountedObject - { - public: - ExceptionTest4(IReferenceCounters* pRefCounters, OwnerObject& owner) : - RefCountedObject(pRefCounters), - m_Member(owner, *this) - { - } - - class Subclass - { - public: - Subclass(OwnerObject& owner, ExceptionTest4& parent) : - wpParent(&parent), - wpOwner(&owner) - { - throw std::runtime_error("test exception"); - } - - private: - RefCntWeakPtr wpParent; - RefCntWeakPtr wpOwner; - }; - virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) {} - - private: - Subclass m_Member; - }; - - RefCntAutoPtr m_pMember; - }; - - try - { - RefCntAutoPtr pOwner(NEW_RC_OBJ(DefaultRawMemoryAllocator::GetAllocator(), "Test object", OwnerObject)()); - } - catch (...) - { - } - } - - { - class TestObject : public RefCountedObject - { - public: - TestObject(IReferenceCounters* pRefCounters) : - RefCountedObject(pRefCounters) - { - } - - virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) override final {} - - inline virtual Atomics::Long Release() override final - { - return RefCountedObject::Release( - [&]() // - { - ppWeakPtr->Release(); - } // - ); - } - RefCntWeakPtr* ppWeakPtr = nullptr; - }; - - RefCntAutoPtr pObj(NEW_RC_OBJ(DefaultRawMemoryAllocator::GetAllocator(), "Test object", TestObject)()); - RefCntWeakPtr pWeakPtr(pObj); - - pObj->ppWeakPtr = &pWeakPtr; - pObj.Release(); - } -} - -class RefCntAutoPtrThreadingTest -{ -public: - ~RefCntAutoPtrThreadingTest(); - - void StartConcurrencyTest(); - void RunConcurrencyTest(); - - static void WorkerThreadFunc(RefCntAutoPtrThreadingTest* This, size_t ThreadNum); - - void StartWorkerThreadsAndWait(int SignalIdx); - void WaitSiblingWorkerThreads(int SignalIdx); - - std::vector m_Threads; - - Object* m_pSharedObject = nullptr; -#ifdef _DEBUG - static const int NumThreadInterations = 10000; -#else - static const int NumThreadInterations = 50000; -#endif - ThreadingTools::Signal m_WorkerThreadSignal[2]; - ThreadingTools::Signal m_MainThreadSignal; - - std::mutex m_NumThreadsCompletedMtx; - std::atomic_int m_NumThreadsCompleted[2]; - std::atomic_int m_NumThreadsReady; -}; - - -RefCntAutoPtrThreadingTest::~RefCntAutoPtrThreadingTest() -{ - m_WorkerThreadSignal[0].Trigger(true, -1); - - for (auto& t : m_Threads) - t.join(); - - LOG_INFO_MESSAGE("Performed ", NumThreadInterations, " iterations on ", m_Threads.size(), " threads"); -} - -void RefCntAutoPtrThreadingTest::WaitSiblingWorkerThreads(int SignalIdx) -{ - auto NumThreads = static_cast(m_Threads.size()); - if (++m_NumThreadsCompleted[SignalIdx] == NumThreads) - { - ASSERT_FALSE(m_WorkerThreadSignal[1 - SignalIdx].IsTriggered()); - m_MainThreadSignal.Trigger(); - } - else - { - while (m_NumThreadsCompleted[SignalIdx] < NumThreads) - std::this_thread::yield(); - } -} - -void RefCntAutoPtrThreadingTest::StartWorkerThreadsAndWait(int SignalIdx) -{ - m_NumThreadsCompleted[SignalIdx] = 0; - m_WorkerThreadSignal[SignalIdx].Trigger(true); - - m_MainThreadSignal.Wait(true, 1); -} - -void RefCntAutoPtrThreadingTest::WorkerThreadFunc(RefCntAutoPtrThreadingTest* This, size_t ThreadNum) -{ - const int NumThreads = static_cast(This->m_Threads.size()); - while (true) - { - for (int i = 0; i < NumThreadInterations; ++i) - { - // Wait until main() sends data - auto SignaledValue = This->m_WorkerThreadSignal[0].Wait(true, NumThreads); - if (SignaledValue < 0) - { - return; - } - - { - auto* pObject = This->m_pSharedObject; - for (int j = 0; j < 100; ++j) - { - //LOG_INFO_MESSAGE("t",std::this_thread::get_id(), ": AddRef" ); - pObject->m_Value++; - pObject->AddRef(); - } - This->WaitSiblingWorkerThreads(0); - - This->m_WorkerThreadSignal[1].Wait(true, NumThreads); - for (int j = 0; j < 100; ++j) - { - //LOG_INFO_MESSAGE("t",std::this_thread::get_id(), ": Release" ); - pObject->m_Value--; - pObject->Release(); - } - This->WaitSiblingWorkerThreads(1); - } - - { - This->m_WorkerThreadSignal[0].Wait(true, NumThreads); - auto* pObject = This->m_pSharedObject; - auto* pRefCounters = pObject->GetReferenceCounters(); - if (ThreadNum % 3 == 0) - { - pObject->m_Value++; - pObject->AddRef(); - } - else - pRefCounters->AddWeakRef(); - This->WaitSiblingWorkerThreads(0); - - This->m_WorkerThreadSignal[1].Wait(true, NumThreads); - if (ThreadNum % 3 == 0) - { - pObject->m_Value--; - pObject->Release(); - } - else - pRefCounters->ReleaseWeakRef(); - This->WaitSiblingWorkerThreads(1); - } - - { - // Test interferences of ReleaseStrongRef() and GetObject() - - // Goal: catch scenario when GetObject() runs between - // AtomicDecrement() and acquiring the lock in ReleaseStrongRef(): - - // m_lNumStrongReferences == 1 - // - - // Scenario I - // - // Thread 1 | Thread 2 | Thread 3 - // | | - // | | - // | | - // | 1. Acquire the lock | - // | 2. Increment m_lNumStrongReferences | - // 1. Decrement m_lNumStrongReferences | 3. Read StrongRefCnt > 1 | - // 2. Test RefCount!=0 | 4. Return the reference to object | - // 3. DO NOT destroy the object | | - // 4. Wait for the lock | | - - - // Scenario I - // - // Thread 1 | Thread 2 | Thread 3 - // | | - // | | - // 1. Decrement m_lNumStrongReferences | | - // | 1. Acquire the lock | - // 2. Test RefCount==0 | 2. Increment m_lNumStrongReferences | - // 3. Start destroying the object | 3. Read StrongRefCnt == 1 | - // 4. Wait for the lock | 4. DO NOT create the object | - // | 5. Decrement m_lNumStrongReferences | - // | | 1. Acquire the lock - // | | 2. Increment m_lNumStrongReferences - // | | 3. Read StrongRefCnt == 1 - // | | 4. DO NOT create the object - // | | 5. Decrement m_lNumStrongReferences - // 5. Acquire the lock | - // 6. DESTROY the object | - - This->m_WorkerThreadSignal[0].Wait(true, NumThreads); - auto* pObject = This->m_pSharedObject; - - RefCntWeakPtr weakPtr(pObject); - RefCntAutoPtr strongPtr, strongPtr2; - if (ThreadNum < 2) - { - strongPtr = pObject; - strongPtr->m_Value++; - } - else - weakPtr = WeakPtr(pObject); - This->WaitSiblingWorkerThreads(0); - - This->m_WorkerThreadSignal[1].Wait(true, NumThreads); - if (ThreadNum == 0) - { - strongPtr->m_Value--; - strongPtr.Release(); - } - else - { - strongPtr2 = weakPtr.Lock(); - if (strongPtr2) - strongPtr2->m_Value++; - weakPtr.Release(); - } - This->WaitSiblingWorkerThreads(1); - } - - - { - This->m_WorkerThreadSignal[0].Wait(true, NumThreads); - auto* pObject = This->m_pSharedObject; - - RefCntWeakPtr weakPtr; - RefCntAutoPtr strongPtr; - if (ThreadNum % 4 == 0) - { - strongPtr = pObject; - strongPtr->m_Value++; - } - else - weakPtr = WeakPtr(pObject); - This->WaitSiblingWorkerThreads(0); - - This->m_WorkerThreadSignal[1].Wait(true, NumThreads); - if (ThreadNum % 4 == 0) - { - strongPtr->m_Value--; - strongPtr.Release(); - } - else - { - auto Ptr = weakPtr.Lock(); - if (Ptr) - Ptr->m_Value++; - Ptr.Release(); - } - This->WaitSiblingWorkerThreads(1); - } - } - } -} - -void RefCntAutoPtrThreadingTest::StartConcurrencyTest() -{ - auto numCores = std::thread::hardware_concurrency(); - m_Threads.resize(std::max(numCores, 4u)); - for (auto& t : m_Threads) - t = std::thread(WorkerThreadFunc, this, &t - m_Threads.data()); -} - -void RefCntAutoPtrThreadingTest::RunConcurrencyTest() -{ - for (int i = 0; i < NumThreadInterations; ++i) - { - m_pSharedObject = MakeNewObj(); - - StartWorkerThreadsAndWait(0); - - StartWorkerThreadsAndWait(1); - - m_pSharedObject = MakeNewObj(); - - StartWorkerThreadsAndWait(0); - - StartWorkerThreadsAndWait(1); - - m_pSharedObject = MakeNewObj(); - - StartWorkerThreadsAndWait(0); - - StartWorkerThreadsAndWait(1); - - m_pSharedObject = MakeNewObj(); - - StartWorkerThreadsAndWait(0); - - StartWorkerThreadsAndWait(1); - } -} - -TEST(Common_RefCntAutoPtr, Threading) -{ - RefCntAutoPtrThreadingTest ThreadingTest; - ThreadingTest.StartConcurrencyTest(); - ThreadingTest.RunConcurrencyTest(); -} - -} // namespace diff --git a/UnitTests/DiligentCoreTest/src/Common/StringToolsTest.cpp b/UnitTests/DiligentCoreTest/src/Common/StringToolsTest.cpp deleted file mode 100644 index 37be477e..00000000 --- a/UnitTests/DiligentCoreTest/src/Common/StringToolsTest.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "StringTools.h" - -#include "gtest/gtest.h" - -using namespace Diligent; - -namespace -{ - -TEST(Common_StringTools, StreqSuff) -{ - EXPECT_TRUE(StreqSuff("abc_def", "abc", "_def")); - EXPECT_TRUE(!StreqSuff("abc", "abc", "_def")); - EXPECT_TRUE(!StreqSuff("ab", "abc", "_def")); - EXPECT_TRUE(!StreqSuff("abc_de", "abc", "_def")); - EXPECT_TRUE(!StreqSuff("abc_def", "ab", "_def")); - EXPECT_TRUE(!StreqSuff("abc_def", "abd", "_def")); - EXPECT_TRUE(!StreqSuff("abc_def", "abc", "_de")); - EXPECT_TRUE(!StreqSuff("abc", "abc", "_def")); - EXPECT_TRUE(!StreqSuff("abc_def", "", "_def")); - EXPECT_TRUE(!StreqSuff("abc_def", "", "")); - - EXPECT_TRUE(StreqSuff("abc", "abc", "_def", true)); - EXPECT_TRUE(!StreqSuff("abc", "abc_", "_def", true)); - EXPECT_TRUE(!StreqSuff("abc_", "abc", "_def", true)); - EXPECT_TRUE(StreqSuff("abc", "abc", nullptr, true)); - EXPECT_TRUE(StreqSuff("abc", "abc", nullptr, false)); - EXPECT_TRUE(!StreqSuff("ab", "abc", nullptr, true)); - EXPECT_TRUE(!StreqSuff("abc", "ab", nullptr, false)); -} - -} // namespace diff --git a/UnitTests/DiligentCoreTest/src/GraphicsAccessories/GraphicsAccessoriesTest.cpp b/UnitTests/DiligentCoreTest/src/GraphicsAccessories/GraphicsAccessoriesTest.cpp deleted file mode 100644 index 89f23ac0..00000000 --- a/UnitTests/DiligentCoreTest/src/GraphicsAccessories/GraphicsAccessoriesTest.cpp +++ /dev/null @@ -1,450 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "GraphicsAccessories.h" - -#include "gtest/gtest.h" - -using namespace Diligent; - -namespace -{ - -TEST(GraphicsAccessories_GraphicsAccessories, GetFilterTypeLiteralName) -{ -#define TEST_FILTER_TYPE_ENUM(ENUM_VAL, ShortName) \ - { \ - EXPECT_STREQ(GetFilterTypeLiteralName(ENUM_VAL, true), #ENUM_VAL); \ - EXPECT_STREQ(GetFilterTypeLiteralName(ENUM_VAL, false), ShortName); \ - } - - // clang-format off - TEST_FILTER_TYPE_ENUM(FILTER_TYPE_UNKNOWN, "unknown"); - TEST_FILTER_TYPE_ENUM(FILTER_TYPE_POINT, "point"); - TEST_FILTER_TYPE_ENUM(FILTER_TYPE_LINEAR, "linear"); - TEST_FILTER_TYPE_ENUM(FILTER_TYPE_ANISOTROPIC, "anisotropic"); - TEST_FILTER_TYPE_ENUM(FILTER_TYPE_COMPARISON_POINT, "comparison point"); - TEST_FILTER_TYPE_ENUM(FILTER_TYPE_COMPARISON_LINEAR, "comparison linear"); - TEST_FILTER_TYPE_ENUM(FILTER_TYPE_COMPARISON_ANISOTROPIC, "comparison anisotropic"); - TEST_FILTER_TYPE_ENUM(FILTER_TYPE_MINIMUM_POINT, "minimum point"); - TEST_FILTER_TYPE_ENUM(FILTER_TYPE_MINIMUM_LINEAR, "minimum linear"); - TEST_FILTER_TYPE_ENUM(FILTER_TYPE_MINIMUM_ANISOTROPIC, "minimum anisotropic"); - TEST_FILTER_TYPE_ENUM(FILTER_TYPE_MAXIMUM_POINT, "maximum point"); - TEST_FILTER_TYPE_ENUM(FILTER_TYPE_MAXIMUM_LINEAR, "maximum linear"); - TEST_FILTER_TYPE_ENUM(FILTER_TYPE_MAXIMUM_ANISOTROPIC, "maximum anisotropic"); - // clang-format on -#undef TEST_FILTER_TYPE_ENUM -} - -TEST(GraphicsAccessories_GraphicsAccessories, GetTextureAddressModeLiteralName) -{ -#define TEST_TEX_ADDRESS_MODE_ENUM(ENUM_VAL, ShortName) \ - { \ - EXPECT_STREQ(GetTextureAddressModeLiteralName(ENUM_VAL, true), #ENUM_VAL); \ - EXPECT_STREQ(GetTextureAddressModeLiteralName(ENUM_VAL, false), ShortName); \ - } - - // clang-format off - TEST_TEX_ADDRESS_MODE_ENUM(TEXTURE_ADDRESS_UNKNOWN, "unknown"); - TEST_TEX_ADDRESS_MODE_ENUM(TEXTURE_ADDRESS_WRAP, "wrap"); - TEST_TEX_ADDRESS_MODE_ENUM(TEXTURE_ADDRESS_MIRROR, "mirror"); - TEST_TEX_ADDRESS_MODE_ENUM(TEXTURE_ADDRESS_CLAMP, "clamp"); - TEST_TEX_ADDRESS_MODE_ENUM(TEXTURE_ADDRESS_BORDER, "border"); - TEST_TEX_ADDRESS_MODE_ENUM(TEXTURE_ADDRESS_MIRROR_ONCE, "mirror once"); - // clang-format on -#undef TEST_TEX_ADDRESS_MODE_ENUM -} - -TEST(GraphicsAccessories_GraphicsAccessories, GetComparisonFunctionLiteralName) -{ -#define TEST_COMPARISON_FUNC_ENUM(ENUM_VAL, ShortName) \ - { \ - EXPECT_STREQ(GetComparisonFunctionLiteralName(ENUM_VAL, true), #ENUM_VAL); \ - EXPECT_STREQ(GetComparisonFunctionLiteralName(ENUM_VAL, false), ShortName); \ - } - - // clang-format off - TEST_COMPARISON_FUNC_ENUM(COMPARISON_FUNC_UNKNOWN, "unknown"); - TEST_COMPARISON_FUNC_ENUM(COMPARISON_FUNC_NEVER, "never"); - TEST_COMPARISON_FUNC_ENUM(COMPARISON_FUNC_LESS, "less"); - TEST_COMPARISON_FUNC_ENUM(COMPARISON_FUNC_EQUAL, "equal"); - TEST_COMPARISON_FUNC_ENUM(COMPARISON_FUNC_LESS_EQUAL, "less equal"); - TEST_COMPARISON_FUNC_ENUM(COMPARISON_FUNC_GREATER, "greater"); - TEST_COMPARISON_FUNC_ENUM(COMPARISON_FUNC_NOT_EQUAL, "not equal"); - TEST_COMPARISON_FUNC_ENUM(COMPARISON_FUNC_GREATER_EQUAL, "greater equal"); - TEST_COMPARISON_FUNC_ENUM(COMPARISON_FUNC_ALWAYS, "always"); - // clang-format on -#undef TEST_TEX_ADDRESS_MODE_ENUM -} - -TEST(GraphicsAccessories_GraphicsAccessories, GetBlendFactorLiteralName) -{ -#define TEST_BLEND_FACTOR_ENUM(ENUM_VAL) \ - { \ - EXPECT_STREQ(GetBlendFactorLiteralName(ENUM_VAL), #ENUM_VAL); \ - } - - TEST_BLEND_FACTOR_ENUM(BLEND_FACTOR_UNDEFINED); - TEST_BLEND_FACTOR_ENUM(BLEND_FACTOR_ZERO); - TEST_BLEND_FACTOR_ENUM(BLEND_FACTOR_ONE); - TEST_BLEND_FACTOR_ENUM(BLEND_FACTOR_SRC_COLOR); - TEST_BLEND_FACTOR_ENUM(BLEND_FACTOR_INV_SRC_COLOR); - TEST_BLEND_FACTOR_ENUM(BLEND_FACTOR_SRC_ALPHA); - TEST_BLEND_FACTOR_ENUM(BLEND_FACTOR_INV_SRC_ALPHA); - TEST_BLEND_FACTOR_ENUM(BLEND_FACTOR_DEST_ALPHA); - TEST_BLEND_FACTOR_ENUM(BLEND_FACTOR_INV_DEST_ALPHA); - TEST_BLEND_FACTOR_ENUM(BLEND_FACTOR_DEST_COLOR); - TEST_BLEND_FACTOR_ENUM(BLEND_FACTOR_INV_DEST_COLOR); - TEST_BLEND_FACTOR_ENUM(BLEND_FACTOR_SRC_ALPHA_SAT); - TEST_BLEND_FACTOR_ENUM(BLEND_FACTOR_BLEND_FACTOR); - TEST_BLEND_FACTOR_ENUM(BLEND_FACTOR_INV_BLEND_FACTOR); - TEST_BLEND_FACTOR_ENUM(BLEND_FACTOR_SRC1_COLOR); - TEST_BLEND_FACTOR_ENUM(BLEND_FACTOR_INV_SRC1_COLOR); - TEST_BLEND_FACTOR_ENUM(BLEND_FACTOR_SRC1_ALPHA); - TEST_BLEND_FACTOR_ENUM(BLEND_FACTOR_INV_SRC1_ALPHA); -#undef TEST_TEX_ADDRESS_MODE_ENUM -} - -TEST(GraphicsAccessories_GraphicsAccessories, GetBlendOperationLiteralName) -{ -#define TEST_BLEND_OP_ENUM(ENUM_VAL) \ - { \ - EXPECT_STREQ(GetBlendOperationLiteralName(ENUM_VAL), #ENUM_VAL); \ - } - - TEST_BLEND_OP_ENUM(BLEND_OPERATION_UNDEFINED); - TEST_BLEND_OP_ENUM(BLEND_OPERATION_ADD); - TEST_BLEND_OP_ENUM(BLEND_OPERATION_SUBTRACT); - TEST_BLEND_OP_ENUM(BLEND_OPERATION_REV_SUBTRACT); - TEST_BLEND_OP_ENUM(BLEND_OPERATION_MIN); - TEST_BLEND_OP_ENUM(BLEND_OPERATION_MAX); -#undef TEST_BLEND_OP_ENUM -} - -TEST(GraphicsAccessories_GraphicsAccessories, GetFillModeLiteralName) -{ -#define TEST_FILL_MODE_ENUM(ENUM_VAL) \ - { \ - EXPECT_STREQ(GetFillModeLiteralName(ENUM_VAL), #ENUM_VAL); \ - } - TEST_FILL_MODE_ENUM(FILL_MODE_UNDEFINED); - TEST_FILL_MODE_ENUM(FILL_MODE_WIREFRAME); - TEST_FILL_MODE_ENUM(FILL_MODE_SOLID); -#undef TEST_FILL_MODE_ENUM -} - -TEST(GraphicsAccessories_GraphicsAccessories, GetCullModeLiteralName) -{ -#define TEST_CULL_MODE_ENUM(ENUM_VAL) \ - { \ - EXPECT_STREQ(GetCullModeLiteralName(ENUM_VAL), #ENUM_VAL); \ - } - TEST_CULL_MODE_ENUM(CULL_MODE_UNDEFINED); - TEST_CULL_MODE_ENUM(CULL_MODE_NONE); - TEST_CULL_MODE_ENUM(CULL_MODE_FRONT); - TEST_CULL_MODE_ENUM(CULL_MODE_BACK); -#undef TEST_CULL_MODE_ENUM -} - -TEST(GraphicsAccessories_GraphicsAccessories, GetStencilOpLiteralName) -{ -#define TEST_STENCIL_OP_ENUM(ENUM_VAL) \ - { \ - EXPECT_STREQ(GetStencilOpLiteralName(ENUM_VAL), #ENUM_VAL); \ - } - - TEST_STENCIL_OP_ENUM(STENCIL_OP_UNDEFINED); - TEST_STENCIL_OP_ENUM(STENCIL_OP_KEEP); - TEST_STENCIL_OP_ENUM(STENCIL_OP_ZERO); - TEST_STENCIL_OP_ENUM(STENCIL_OP_REPLACE); - TEST_STENCIL_OP_ENUM(STENCIL_OP_INCR_SAT); - TEST_STENCIL_OP_ENUM(STENCIL_OP_DECR_SAT); - TEST_STENCIL_OP_ENUM(STENCIL_OP_INVERT); - TEST_STENCIL_OP_ENUM(STENCIL_OP_INCR_WRAP); - TEST_STENCIL_OP_ENUM(STENCIL_OP_DECR_WRAP); -#undef TEST_STENCIL_OP_ENUM -} - - - -TEST(GraphicsAccessories_GraphicsAccessories, GetTextureFormatAttribs) -{ - auto CheckFormatSize = [](TEXTURE_FORMAT* begin, TEXTURE_FORMAT* end, Uint32 RefSize) // - { - for (auto fmt = begin; fmt != end; ++fmt) - { - auto FmtAttrs = GetTextureFormatAttribs(*fmt); - EXPECT_EQ(Uint32{FmtAttrs.ComponentSize} * Uint32{FmtAttrs.NumComponents}, RefSize); - } - }; - - auto CheckNumComponents = [](TEXTURE_FORMAT* begin, TEXTURE_FORMAT* end, Uint32 RefComponents) // - { - for (auto fmt = begin; fmt != end; ++fmt) - { - auto FmtAttrs = GetTextureFormatAttribs(*fmt); - EXPECT_EQ(FmtAttrs.NumComponents, RefComponents); - } - }; - - auto CheckComponentType = [](TEXTURE_FORMAT* begin, TEXTURE_FORMAT* end, COMPONENT_TYPE RefType) // - { - for (auto fmt = begin; fmt != end; ++fmt) - { - auto FmtAttrs = GetTextureFormatAttribs(*fmt); - EXPECT_EQ(FmtAttrs.ComponentType, RefType); - } - }; - - TEXTURE_FORMAT _16ByteFormats[] = - { - TEX_FORMAT_RGBA32_TYPELESS, TEX_FORMAT_RGBA32_FLOAT, TEX_FORMAT_RGBA32_UINT, TEX_FORMAT_RGBA32_SINT // - }; - CheckFormatSize(std::begin(_16ByteFormats), std::end(_16ByteFormats), 16); - - TEXTURE_FORMAT _12ByteFormats[] = - { - TEX_FORMAT_RGB32_TYPELESS, TEX_FORMAT_RGB32_FLOAT, TEX_FORMAT_RGB32_UINT, TEX_FORMAT_RGB32_SINT // - }; - CheckFormatSize(std::begin(_12ByteFormats), std::end(_12ByteFormats), 12); - - TEXTURE_FORMAT _8ByteFormats[] = - { - TEX_FORMAT_RGBA16_TYPELESS, TEX_FORMAT_RGBA16_FLOAT, TEX_FORMAT_RGBA16_UNORM, TEX_FORMAT_RGBA16_UINT, TEX_FORMAT_RGBA16_SNORM, TEX_FORMAT_RGBA16_SINT, - TEX_FORMAT_RG32_TYPELESS, TEX_FORMAT_RG32_FLOAT, TEX_FORMAT_RG32_UINT, TEX_FORMAT_RG32_SINT, - TEX_FORMAT_R32G8X24_TYPELESS, TEX_FORMAT_D32_FLOAT_S8X24_UINT, TEX_FORMAT_R32_FLOAT_X8X24_TYPELESS, TEX_FORMAT_X32_TYPELESS_G8X24_UINT // - }; - CheckFormatSize(std::begin(_8ByteFormats), std::end(_8ByteFormats), 8); - - TEXTURE_FORMAT _4ByteFormats[] = - { - TEX_FORMAT_RGB10A2_TYPELESS, TEX_FORMAT_RGB10A2_UNORM, TEX_FORMAT_RGB10A2_UINT, TEX_FORMAT_R11G11B10_FLOAT, - TEX_FORMAT_RGBA8_TYPELESS, TEX_FORMAT_RGBA8_UNORM, TEX_FORMAT_RGBA8_UNORM_SRGB, TEX_FORMAT_RGBA8_UINT, TEX_FORMAT_RGBA8_SNORM, TEX_FORMAT_RGBA8_SINT, - TEX_FORMAT_RG16_TYPELESS, TEX_FORMAT_RG16_FLOAT, TEX_FORMAT_RG16_UNORM, TEX_FORMAT_RG16_UINT, TEX_FORMAT_RG16_SNORM, TEX_FORMAT_RG16_SINT, - TEX_FORMAT_R32_TYPELESS, TEX_FORMAT_D32_FLOAT, TEX_FORMAT_R32_FLOAT, TEX_FORMAT_R32_UINT, TEX_FORMAT_R32_SINT, - TEX_FORMAT_R24G8_TYPELESS, TEX_FORMAT_D24_UNORM_S8_UINT, TEX_FORMAT_R24_UNORM_X8_TYPELESS, TEX_FORMAT_X24_TYPELESS_G8_UINT, - TEX_FORMAT_RGB9E5_SHAREDEXP, TEX_FORMAT_RG8_B8G8_UNORM, TEX_FORMAT_G8R8_G8B8_UNORM, - TEX_FORMAT_BGRA8_UNORM, TEX_FORMAT_BGRX8_UNORM, TEX_FORMAT_R10G10B10_XR_BIAS_A2_UNORM, - TEX_FORMAT_BGRA8_TYPELESS, TEX_FORMAT_BGRA8_UNORM_SRGB, TEX_FORMAT_BGRX8_TYPELESS, TEX_FORMAT_BGRX8_UNORM_SRGB // - }; - CheckFormatSize(std::begin(_4ByteFormats), std::end(_4ByteFormats), 4); - - TEXTURE_FORMAT _2ByteFormats[] = - { - TEX_FORMAT_RG8_TYPELESS, TEX_FORMAT_RG8_UNORM, TEX_FORMAT_RG8_UINT, TEX_FORMAT_RG8_SNORM, TEX_FORMAT_RG8_SINT, - TEX_FORMAT_R16_TYPELESS, TEX_FORMAT_R16_FLOAT, TEX_FORMAT_D16_UNORM, TEX_FORMAT_R16_UNORM, TEX_FORMAT_R16_UINT, TEX_FORMAT_R16_SNORM, TEX_FORMAT_R16_SINT, - TEX_FORMAT_B5G6R5_UNORM, TEX_FORMAT_B5G5R5A1_UNORM // - }; - CheckFormatSize(std::begin(_2ByteFormats), std::end(_2ByteFormats), 2); - - TEXTURE_FORMAT _1ByteFormats[] = - { - TEX_FORMAT_R8_TYPELESS, TEX_FORMAT_R8_UNORM, TEX_FORMAT_R8_UINT, TEX_FORMAT_R8_SNORM, TEX_FORMAT_R8_SINT, TEX_FORMAT_A8_UNORM, //TEX_FORMAT_R1_UNORM - }; - CheckFormatSize(std::begin(_1ByteFormats), std::end(_1ByteFormats), 1); - - TEXTURE_FORMAT _4ComponentFormats[] = - { - TEX_FORMAT_RGBA32_TYPELESS, TEX_FORMAT_RGBA32_FLOAT, TEX_FORMAT_RGBA32_UINT, TEX_FORMAT_RGBA32_SINT, - TEX_FORMAT_RGBA16_TYPELESS, TEX_FORMAT_RGBA16_FLOAT, TEX_FORMAT_RGBA16_UNORM, TEX_FORMAT_RGBA16_UINT, TEX_FORMAT_RGBA16_SNORM, TEX_FORMAT_RGBA16_SINT, - TEX_FORMAT_RGBA8_TYPELESS, TEX_FORMAT_RGBA8_UNORM, TEX_FORMAT_RGBA8_UNORM_SRGB, TEX_FORMAT_RGBA8_UINT, TEX_FORMAT_RGBA8_SNORM, TEX_FORMAT_RGBA8_SINT, - TEX_FORMAT_RG8_B8G8_UNORM, TEX_FORMAT_G8R8_G8B8_UNORM, - TEX_FORMAT_BGRA8_UNORM, TEX_FORMAT_BGRX8_UNORM, TEX_FORMAT_BGRA8_TYPELESS, TEX_FORMAT_BGRA8_UNORM_SRGB, TEX_FORMAT_BGRX8_TYPELESS, TEX_FORMAT_BGRX8_UNORM_SRGB // - }; - CheckNumComponents(std::begin(_4ComponentFormats), std::end(_4ComponentFormats), 4); - - TEXTURE_FORMAT _3ComponentFormats[] = - { - TEX_FORMAT_RGB32_TYPELESS, - TEX_FORMAT_RGB32_FLOAT, - TEX_FORMAT_RGB32_UINT, - TEX_FORMAT_RGB32_SINT // - }; - CheckNumComponents(std::begin(_3ComponentFormats), std::end(_3ComponentFormats), 3); - - TEXTURE_FORMAT _2ComponentFormats[] = - { - TEX_FORMAT_RG32_TYPELESS, TEX_FORMAT_RG32_FLOAT, TEX_FORMAT_RG32_UINT, TEX_FORMAT_RG32_SINT, - TEX_FORMAT_R32G8X24_TYPELESS, TEX_FORMAT_D32_FLOAT_S8X24_UINT, TEX_FORMAT_R32_FLOAT_X8X24_TYPELESS, TEX_FORMAT_X32_TYPELESS_G8X24_UINT, - TEX_FORMAT_RG16_TYPELESS, TEX_FORMAT_RG16_FLOAT, TEX_FORMAT_RG16_UNORM, TEX_FORMAT_RG16_UINT, TEX_FORMAT_RG16_SNORM, TEX_FORMAT_RG16_SINT, - TEX_FORMAT_RG8_TYPELESS, TEX_FORMAT_RG8_UNORM, TEX_FORMAT_RG8_UINT, TEX_FORMAT_RG8_SNORM, TEX_FORMAT_RG8_SINT // - }; - CheckNumComponents(std::begin(_2ComponentFormats), std::end(_2ComponentFormats), 2); - - TEXTURE_FORMAT _1ComponentFormats[] = - { - TEX_FORMAT_RGB10A2_TYPELESS, TEX_FORMAT_RGB10A2_UNORM, TEX_FORMAT_RGB10A2_UINT, TEX_FORMAT_R11G11B10_FLOAT, - TEX_FORMAT_R32_TYPELESS, TEX_FORMAT_D32_FLOAT, TEX_FORMAT_R32_FLOAT, TEX_FORMAT_R32_UINT, TEX_FORMAT_R32_SINT, - TEX_FORMAT_R24G8_TYPELESS, TEX_FORMAT_D24_UNORM_S8_UINT, TEX_FORMAT_R24_UNORM_X8_TYPELESS, TEX_FORMAT_X24_TYPELESS_G8_UINT, - TEX_FORMAT_R16_TYPELESS, TEX_FORMAT_R16_FLOAT, TEX_FORMAT_D16_UNORM, TEX_FORMAT_R16_UNORM, TEX_FORMAT_R16_UINT, TEX_FORMAT_R16_SNORM, TEX_FORMAT_R16_SINT, - TEX_FORMAT_R8_TYPELESS, TEX_FORMAT_R8_UNORM, TEX_FORMAT_R8_UINT, TEX_FORMAT_R8_SNORM, TEX_FORMAT_R8_SINT, TEX_FORMAT_A8_UNORM, //TEX_FORMAT_R1_UNORM - TEX_FORMAT_RGB9E5_SHAREDEXP, - TEX_FORMAT_R10G10B10_XR_BIAS_A2_UNORM, TEX_FORMAT_B5G6R5_UNORM, TEX_FORMAT_B5G5R5A1_UNORM // - }; - CheckNumComponents(std::begin(_1ComponentFormats), std::end(_1ComponentFormats), 1); - - - TEXTURE_FORMAT FloatFormats[] = - { - TEX_FORMAT_RGBA32_FLOAT, - TEX_FORMAT_RGB32_FLOAT, - TEX_FORMAT_RGBA16_FLOAT, - TEX_FORMAT_RG32_FLOAT, - TEX_FORMAT_RG16_FLOAT, - TEX_FORMAT_R32_FLOAT, - TEX_FORMAT_R16_FLOAT // - }; - CheckComponentType(std::begin(FloatFormats), std::end(FloatFormats), COMPONENT_TYPE_FLOAT); - - TEXTURE_FORMAT SintFormats[] = - { - TEX_FORMAT_RGBA32_SINT, - TEX_FORMAT_RGB32_SINT, - TEX_FORMAT_RGBA16_SINT, - TEX_FORMAT_RG32_SINT, - TEX_FORMAT_RGBA8_SINT, - TEX_FORMAT_RG16_SINT, - TEX_FORMAT_R32_SINT, - TEX_FORMAT_RG8_SINT, - TEX_FORMAT_R16_SINT, - TEX_FORMAT_R8_SINT // - }; - CheckComponentType(std::begin(SintFormats), std::end(SintFormats), COMPONENT_TYPE_SINT); - - TEXTURE_FORMAT UintFormats[] = - { - TEX_FORMAT_RGBA32_UINT, - TEX_FORMAT_RGB32_UINT, - TEX_FORMAT_RGBA16_UINT, - TEX_FORMAT_RG32_UINT, - TEX_FORMAT_RGBA8_UINT, - TEX_FORMAT_RG16_UINT, - TEX_FORMAT_R32_UINT, - TEX_FORMAT_RG8_UINT, - TEX_FORMAT_R16_UINT, - TEX_FORMAT_R8_UINT // - }; - CheckComponentType(std::begin(UintFormats), std::end(UintFormats), COMPONENT_TYPE_UINT); - - TEXTURE_FORMAT UnormFormats[] = - { - TEX_FORMAT_RGBA16_UNORM, - TEX_FORMAT_RGBA8_UNORM, - TEX_FORMAT_RG16_UNORM, - TEX_FORMAT_RG8_UNORM, - TEX_FORMAT_R16_UNORM, - TEX_FORMAT_R8_UNORM, - TEX_FORMAT_A8_UNORM, - TEX_FORMAT_R1_UNORM, - TEX_FORMAT_RG8_B8G8_UNORM, - TEX_FORMAT_G8R8_G8B8_UNORM, - TEX_FORMAT_BGRA8_UNORM, - TEX_FORMAT_BGRX8_UNORM // - }; - CheckComponentType(std::begin(UnormFormats), std::end(UnormFormats), COMPONENT_TYPE_UNORM); - - TEXTURE_FORMAT UnormSRGBFormats[] = - { - TEX_FORMAT_RGBA8_UNORM_SRGB, - TEX_FORMAT_BGRA8_UNORM_SRGB, - TEX_FORMAT_BGRX8_UNORM_SRGB // - }; - CheckComponentType(std::begin(UnormSRGBFormats), std::end(UnormSRGBFormats), COMPONENT_TYPE_UNORM_SRGB); - - TEXTURE_FORMAT SnormFormats[] = - { - TEX_FORMAT_RGBA16_SNORM, - TEX_FORMAT_RGBA8_SNORM, - TEX_FORMAT_RG16_SNORM, - TEX_FORMAT_RG8_SNORM, - TEX_FORMAT_R16_SNORM, - TEX_FORMAT_R8_SNORM // - }; - CheckComponentType(std::begin(SnormFormats), std::end(SnormFormats), COMPONENT_TYPE_SNORM); - - TEXTURE_FORMAT UndefinedFormats[] = - { - TEX_FORMAT_RGBA32_TYPELESS, - TEX_FORMAT_RGB32_TYPELESS, - TEX_FORMAT_RGBA16_TYPELESS, - TEX_FORMAT_RG32_TYPELESS, - TEX_FORMAT_RGBA8_TYPELESS, - TEX_FORMAT_RG16_TYPELESS, - TEX_FORMAT_R32_TYPELESS, - TEX_FORMAT_RG8_TYPELESS, - TEX_FORMAT_R16_TYPELESS, - TEX_FORMAT_R8_TYPELESS, - TEX_FORMAT_BGRA8_TYPELESS, - TEX_FORMAT_BGRX8_TYPELESS // - }; - CheckComponentType(std::begin(UndefinedFormats), std::end(UndefinedFormats), COMPONENT_TYPE_UNDEFINED); - - TEXTURE_FORMAT DepthFormats[] = - { - TEX_FORMAT_D32_FLOAT, - TEX_FORMAT_D16_UNORM // - }; - CheckComponentType(std::begin(DepthFormats), std::end(DepthFormats), COMPONENT_TYPE_DEPTH); - - TEXTURE_FORMAT DepthStencilFormats[] = - { - TEX_FORMAT_R32G8X24_TYPELESS, - TEX_FORMAT_D32_FLOAT_S8X24_UINT, - TEX_FORMAT_R32_FLOAT_X8X24_TYPELESS, - TEX_FORMAT_X32_TYPELESS_G8X24_UINT, - TEX_FORMAT_R24G8_TYPELESS, - TEX_FORMAT_D24_UNORM_S8_UINT, - TEX_FORMAT_R24_UNORM_X8_TYPELESS, - TEX_FORMAT_X24_TYPELESS_G8_UINT // - }; - CheckComponentType(std::begin(DepthStencilFormats), std::end(DepthStencilFormats), COMPONENT_TYPE_DEPTH_STENCIL); - - TEXTURE_FORMAT CompoundFormats[] = - { - TEX_FORMAT_RGB10A2_TYPELESS, - TEX_FORMAT_RGB10A2_UNORM, - TEX_FORMAT_RGB10A2_UINT, - TEX_FORMAT_RGB9E5_SHAREDEXP, - TEX_FORMAT_R11G11B10_FLOAT, - TEX_FORMAT_R10G10B10_XR_BIAS_A2_UNORM, - TEX_FORMAT_B5G6R5_UNORM, - TEX_FORMAT_B5G5R5A1_UNORM // - }; - CheckComponentType(std::begin(CompoundFormats), std::end(CompoundFormats), COMPONENT_TYPE_COMPOUND); - - - TEXTURE_FORMAT CompressedFormats[] = - { - TEX_FORMAT_BC1_TYPELESS, TEX_FORMAT_BC1_UNORM, TEX_FORMAT_BC1_UNORM_SRGB, - TEX_FORMAT_BC2_TYPELESS, TEX_FORMAT_BC2_UNORM, TEX_FORMAT_BC2_UNORM_SRGB, - TEX_FORMAT_BC3_TYPELESS, TEX_FORMAT_BC3_UNORM, TEX_FORMAT_BC3_UNORM_SRGB, - TEX_FORMAT_BC4_TYPELESS, TEX_FORMAT_BC4_UNORM, TEX_FORMAT_BC4_SNORM, - TEX_FORMAT_BC5_TYPELESS, TEX_FORMAT_BC5_UNORM, TEX_FORMAT_BC5_SNORM, - TEX_FORMAT_BC6H_TYPELESS, TEX_FORMAT_BC6H_UF16, TEX_FORMAT_BC6H_SF16, - TEX_FORMAT_BC7_TYPELESS, TEX_FORMAT_BC7_UNORM, TEX_FORMAT_BC7_UNORM_SRGB // - }; - CheckComponentType(std::begin(CompressedFormats), std::end(CompressedFormats), COMPONENT_TYPE_COMPRESSED); -} - - -} // namespace diff --git a/UnitTests/DiligentCoreTest/src/GraphicsAccessories/ResourceReleaseQueueTest.cpp b/UnitTests/DiligentCoreTest/src/GraphicsAccessories/ResourceReleaseQueueTest.cpp deleted file mode 100644 index 740f0fb5..00000000 --- a/UnitTests/DiligentCoreTest/src/GraphicsAccessories/ResourceReleaseQueueTest.cpp +++ /dev/null @@ -1,127 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include - -#include "ResourceReleaseQueue.h" -#include "DefaultRawMemoryAllocator.h" - -#include "gtest/gtest.h" - -using namespace Diligent; - -namespace -{ - -TEST(GraphicsAccessories_ResourceReleaseQueue, GetFilterTypeLiteralName) -{ - struct ResourceA - { - int Data = 1; - }; - struct ResourceB - { - float Data = 2; - }; - struct ResourceC - { - float Data[2] = {3, 4}; - }; - - { - ResourceReleaseQueue Queue(DefaultRawMemoryAllocator::GetAllocator()); - - std::unique_ptr res0(new ResourceA); - std::unique_ptr res1(new ResourceB); - - Queue.SafeReleaseResource(std::move(res0), 0); - Queue.SafeReleaseResource(std::move(res1), 0); - - std::unique_ptr res2(new ResourceC); - - auto Wrapper2 = Queue.CreateWrapper(std::move(res2), 1); - //auto WrapperX = Queue.CreateWrapper(res2, 1);// - error - //auto WrapperY = Queue.CreateWrapper(static_cast&>(res2), 1);// - error - Queue.SafeReleaseResource(std::move(Wrapper2), 0); - - Queue.DiscardStaleResources(0, 1); - - std::unique_ptr res4(new ResourceA); - Queue.DiscardResource(std::move(res4), 1); - - std::unique_ptr res5(new ResourceB); - - auto Wrapper5 = Queue.CreateWrapper(std::move(res5), 1); - Queue.DiscardResource(std::move(Wrapper5), 1); - - Queue.Purge(1); - } - - { - ResourceReleaseQueue Queue0(DefaultRawMemoryAllocator::GetAllocator()); - ResourceReleaseQueue Queue1(DefaultRawMemoryAllocator::GetAllocator()); - ResourceReleaseQueue Queue2(DefaultRawMemoryAllocator::GetAllocator()); - - std::unique_ptr res0(new ResourceA); - std::unique_ptr res1(new ResourceB); - std::unique_ptr res2(new ResourceC); - - auto Wrapper0 = ResourceReleaseQueue::CreateWrapper(std::move(res0), 3); - auto Wrapper1 = ResourceReleaseQueue::CreateWrapper(std::move(res1), 3); - auto Wrapper2 = ResourceReleaseQueue::CreateWrapper(std::move(res2), 1); - - Queue0.SafeReleaseResource(Wrapper0, 0); - Queue0.SafeReleaseResource(Wrapper1, 0); - Queue0.SafeReleaseResource(Wrapper2, 0); - Wrapper2.GiveUpOwnership(); - - Queue1.SafeReleaseResource(Wrapper0, 0); - Queue1.SafeReleaseResource(Wrapper1, 0); - - Queue2.SafeReleaseResource(std::move(Wrapper0), 0); - Queue2.SafeReleaseResource(Wrapper1, 0); - Wrapper1.GiveUpOwnership(); - - Queue0.DiscardStaleResources(0, 1); - Queue1.DiscardStaleResources(0, 1); - Queue2.DiscardStaleResources(0, 1); - - std::unique_ptr res3(new ResourceC); - - auto Wrapper3 = ResourceReleaseQueue::CreateWrapper(std::move(res3), 2); - Queue0.DiscardResource(Wrapper3, 1); - Queue1.DiscardResource(std::move(Wrapper3), 1); - - std::unique_ptr res4(new ResourceA); - - auto Wrapper4 = ResourceReleaseQueue::CreateWrapper(std::move(res4), 1); - Queue2.DiscardResource(Wrapper4, 1); - Wrapper4.GiveUpOwnership(); - - Queue0.Purge(1); - Queue1.Purge(1); - Queue2.Purge(1); - } -} - -} // namespace diff --git a/UnitTests/DiligentCoreTest/src/GraphicsAccessories/RingBufferTest.cpp b/UnitTests/DiligentCoreTest/src/GraphicsAccessories/RingBufferTest.cpp deleted file mode 100644 index 11fd0cf6..00000000 --- a/UnitTests/DiligentCoreTest/src/GraphicsAccessories/RingBufferTest.cpp +++ /dev/null @@ -1,288 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "RingBuffer.h" -#include "DefaultRawMemoryAllocator.h" - -#include "gtest/gtest.h" - -using namespace Diligent; - -namespace -{ - -TEST(GraphicsAccessories_RingBuffer, AllocDealloc) -{ - auto& Allocator = DefaultRawMemoryAllocator::GetAllocator(); - { - RingBuffer RB(1023, Allocator); - - auto Offset = RB.Allocate(120, 16); - // - // O h - // | | | - // 0 128 - EXPECT_EQ(Offset, 0); - - - Offset = RB.Allocate(10, 1); - // - // t O h - // | | | | - // 0 128 138 - EXPECT_EQ(Offset, 128); - - Offset = RB.Allocate(10, 32); - // - // t O h - // | | | | - // 0 128 138 160 192 - EXPECT_EQ(Offset, 160); - - Offset = RB.Allocate(17, 1); - // - // t O h - // | | | | - // 0 128 138 160 192 209 - EXPECT_EQ(Offset, 192); - - Offset = RB.Allocate(65, 64); - // - // t O h - // | | | | - // 0 128 138 160 192 209 256 384 - EXPECT_EQ(Offset, 256); - - RB.FinishCurrentFrame(1); - // - // t h1 - // | | | - // 0 384 - - - Offset = RB.Allocate(100, 256); - // - // t h1 O h - // | | | | | - // 0 384 512 768 - EXPECT_EQ(Offset, 512); - - - Offset = RB.Allocate(127, 1); - // - // t h1 O h - // | | | | | - // 0 384 512 768 895 = 1023-128 - EXPECT_EQ(Offset, 768); - - Offset = RB.Allocate(128, 2); - EXPECT_EQ(Offset, RingBuffer::InvalidOffset); - - Offset = RB.Allocate(128, 1); - // - // t h1 O h - // | | | | - // 0 384 512 768 895 1023 - EXPECT_EQ(Offset, 895); - - RB.FinishCurrentFrame(2); - // - // t h1 h2,h - // | | | - // 0 384 1023 - EXPECT_TRUE(RB.IsFull()); - - Offset = RB.Allocate(1, 1); - EXPECT_EQ(Offset, RingBuffer::InvalidOffset); - - RingBuffer RB1(std::move(RB)); - EXPECT_TRUE(RB.IsEmpty()); - RB1.ReleaseCompletedFrames(1); - // - // t h2 - // | | | - // 0 384 1023 - - RB1.ReleaseCompletedFrames(2); - // - // h,t - // | | - // 0 1023 - EXPECT_TRUE(RB1.IsEmpty()); - EXPECT_EQ(RB1.GetUsedSize(), 0); - - Offset = RB1.Allocate(256, 1); - // - // O h t - // | | | - // 0 256 1023 - EXPECT_EQ(Offset, 0); - - - Offset = RB1.Allocate(256, 16); - RB1.ReleaseCompletedFrames(0); - // - // O h t - // | | | | - // 0 256 512 1023 - EXPECT_EQ(Offset, 256); - RB1.FinishCurrentFrame(2); - RB1.FinishCurrentFrame(3); // ignored - // - // h2 t - // | | | - // 0 512 1023 - RB1.ReleaseCompletedFrames(2); - // - // h,t - // | | - // 0 1023 - - RB1.ReleaseCompletedFrames(3); - - EXPECT_EQ(RB1.GetUsedSize(), 0); - EXPECT_TRUE(RB1.IsEmpty()); - - Offset = RB1.Allocate(512, 1); - // - // O h - // | | | - // 0 512 1023 - EXPECT_EQ(Offset, 0); - - RB1.FinishCurrentFrame(4); - RB1.FinishCurrentFrame(5); - // - // t h4 - // | | | - // 0 512 1023 - - Offset = RB1.Allocate(129, 1); - // - // t h4,O h - // | | | | - // 0 512 641 1023 - EXPECT_EQ(Offset, 512); - - RB1.ReleaseCompletedFrames(4); - // - // t h - // | | | | - // 0 512 641 1023 - - - Offset = RB1.Allocate(128, 128); - // - // t O h - // | | | | | - // 0 512 641 768 896 1023 - EXPECT_EQ(Offset, 768); - - Offset = RB1.Allocate(513, 64); - EXPECT_EQ(Offset, RingBuffer::InvalidOffset); - - Offset = RB1.Allocate(513, 1); - EXPECT_EQ(Offset, RingBuffer::InvalidOffset); - - Offset = RB1.Allocate(255, 1); - // - // O h t - // | | | | - // 0 255 512 1023 - EXPECT_EQ(Offset, 0); - - RB1.FinishCurrentFrame(6); - // - // O h,h6 t - // | | | | - // 0 255 512 1023 - - - Offset = RB1.Allocate(256, 2); - // - // h6 O t,h - // | | | | | - // 0 255 256 512 1023 - EXPECT_EQ(Offset, 256); - - EXPECT_TRUE(RB1.IsFull()); - Offset = RB1.Allocate(1, 1); - EXPECT_EQ(Offset, RingBuffer::InvalidOffset); - RB1.ReleaseCompletedFrames(6); - // - // t h - // | | | | - // 0 255 512 1023 - - Offset = RB1.Allocate(511, 1); - // - // t O h - // | | | | - // 0 255 512 1023 - EXPECT_EQ(Offset, 512); - - Offset = RB1.Allocate(191, 1); - // - // O h t - // | | | | - // 0 191 255 1023 - EXPECT_EQ(Offset, 0); - - Offset = RB1.Allocate(64, 2); - EXPECT_EQ(Offset, RingBuffer::InvalidOffset); - - Offset = RB1.Allocate(64, 1); - // - // O t,h - // | | | | - // 0 191 255 1023 - EXPECT_EQ(Offset, 191); - - Offset = RB1.Allocate(1, 1); - EXPECT_EQ(Offset, RingBuffer::InvalidOffset); - - RB1.FinishCurrentFrame(7); - RB1.ReleaseCompletedFrames(7); - } - - { - RingBuffer RB(1024, Allocator); - - auto offset = RB.Allocate(512, 1); - RB.FinishCurrentFrame(0); - RB.FinishCurrentFrame(1); - RB.ReleaseCompletedFrames(1); - RB.FinishCurrentFrame(2); - RB.FinishCurrentFrame(3); - offset = RB.Allocate(512, 1); - RB.FinishCurrentFrame(4); - RB.ReleaseCompletedFrames(2); - RB.ReleaseCompletedFrames(3); - RB.ReleaseCompletedFrames(4); - offset = RB.Allocate(512, 1); - RB.FinishCurrentFrame(5); - RB.ReleaseCompletedFrames(5); - } -} - -} // namespace diff --git a/UnitTests/DiligentCoreTest/src/GraphicsAccessories/VariableSizeGPUAllocationsManagerTest.cpp b/UnitTests/DiligentCoreTest/src/GraphicsAccessories/VariableSizeGPUAllocationsManagerTest.cpp deleted file mode 100644 index cc1c0e6f..00000000 --- a/UnitTests/DiligentCoreTest/src/GraphicsAccessories/VariableSizeGPUAllocationsManagerTest.cpp +++ /dev/null @@ -1,195 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "VariableSizeGPUAllocationsManager.h" -#include "DefaultRawMemoryAllocator.h" - -#include "gtest/gtest.h" - -using namespace Diligent; - -namespace -{ - -TEST(GraphicsAccessories_VariableSizeGPUAllocationsManager, AllocateFree) -{ - auto& Allocator = DefaultRawMemoryAllocator::GetAllocator(); - - { - VariableSizeAllocationsManager ListMgr(128, Allocator); - EXPECT_EQ(ListMgr.GetNumFreeBlocks(), 1); - - auto a1 = ListMgr.Allocate(17, 4); - EXPECT_EQ(a1.UnalignedOffset, 0); - EXPECT_EQ(a1.Size, 20); - EXPECT_EQ(ListMgr.GetNumFreeBlocks(), 1); - - auto a2 = ListMgr.Allocate(17, 8); - EXPECT_EQ(a2.UnalignedOffset, 20); - EXPECT_EQ(a2.Size, 28); - - auto a3 = ListMgr.Allocate(8, 1); - EXPECT_EQ(a3.UnalignedOffset, 48); - EXPECT_EQ(a3.Size, 8); - - auto a4 = ListMgr.Allocate(11, 8); - EXPECT_EQ(a4.UnalignedOffset, 56); - EXPECT_EQ(a4.Size, 16); - - auto a5 = ListMgr.Allocate(64, 1); - EXPECT_FALSE(a5.IsValid()); - EXPECT_EQ(a5.Size, 0); - - a5 = ListMgr.Allocate(16, 1); - EXPECT_EQ(a5.UnalignedOffset, 72); - EXPECT_EQ(a5.Size, 16); - - auto a6 = ListMgr.Allocate(8, 1); - EXPECT_EQ(a6.UnalignedOffset, 88); - EXPECT_EQ(a6.Size, 8); - - auto a7 = ListMgr.Allocate(16, 1); - EXPECT_EQ(a7.UnalignedOffset, 96); - EXPECT_EQ(a7.Size, 16); - - auto a8 = ListMgr.Allocate(8, 1); - EXPECT_EQ(a8.UnalignedOffset, 112); - EXPECT_EQ(a8.Size, 8); - EXPECT_EQ(ListMgr.GetNumFreeBlocks(), 1); - - auto a9 = ListMgr.Allocate(8, 1); - EXPECT_EQ(a9.UnalignedOffset, 120); - EXPECT_EQ(a9.Size, 8); - EXPECT_EQ(ListMgr.GetNumFreeBlocks(), 0); - - EXPECT_TRUE(ListMgr.IsFull()); - - ListMgr.Free(std::move(a6)); - EXPECT_EQ(ListMgr.GetNumFreeBlocks(), 1); - - ListMgr.Free(a8.UnalignedOffset, a8.Size); - EXPECT_EQ(ListMgr.GetNumFreeBlocks(), 2); - - ListMgr.Free(std::move(a9)); - EXPECT_EQ(ListMgr.GetNumFreeBlocks(), 2); - - auto a10 = ListMgr.Allocate(16, 1); - EXPECT_EQ(a10.UnalignedOffset, 112); - EXPECT_EQ(a10.Size, 16); - EXPECT_EQ(ListMgr.GetNumFreeBlocks(), 1); - - ListMgr.Free(a10.UnalignedOffset, a10.Size); - EXPECT_EQ(ListMgr.GetNumFreeBlocks(), 2); - - ListMgr.Free(std::move(a7)); - EXPECT_EQ(ListMgr.GetNumFreeBlocks(), 1); - - ListMgr.Free(std::move(a4)); - EXPECT_EQ(ListMgr.GetNumFreeBlocks(), 2); - - ListMgr.Free(a2.UnalignedOffset, a2.Size); - EXPECT_EQ(ListMgr.GetNumFreeBlocks(), 3); - - ListMgr.Free(std::move(a1)); - EXPECT_EQ(ListMgr.GetNumFreeBlocks(), 3); - - ListMgr.Free(std::move(a3)); - EXPECT_EQ(ListMgr.GetNumFreeBlocks(), 2); - - ListMgr.Free(std::move(a5)); - EXPECT_EQ(ListMgr.GetNumFreeBlocks(), 1); - - EXPECT_TRUE(ListMgr.IsEmpty()); - } -} - -TEST(GraphicsAccessories_VariableSizeGPUAllocationsManager, FreeOrder) -{ - auto& Allocator = DefaultRawMemoryAllocator::GetAllocator(); - { - const auto NumAllocs = 6; - int NumPerms = 0; - size_t ReleaseOrder[NumAllocs]; - for (size_t a = 0; a < NumAllocs; ++a) - ReleaseOrder[a] = a; - do - { - ++NumPerms; - VariableSizeAllocationsManager ListMgr(NumAllocs * 4, Allocator); - - VariableSizeAllocationsManager::Allocation allocs[NumAllocs]; - for (size_t a = 0; a < NumAllocs; ++a) - { - allocs[a] = ListMgr.Allocate(4, 1); - EXPECT_EQ(allocs[a].UnalignedOffset, a * 4); - EXPECT_EQ(allocs[a].Size, 4); - } - for (size_t a = 0; a < NumAllocs; ++a) - { - ListMgr.Free(std::move(allocs[ReleaseOrder[a]])); - } - } while (std::next_permutation(std::begin(ReleaseOrder), std::end(ReleaseOrder))); - EXPECT_EQ(NumPerms, 720); - } -} - -TEST(GraphicsAccessories_VariableSizeGPUAllocationsManager, Free) -{ - auto& Allocator = DefaultRawMemoryAllocator::GetAllocator(); - { - VariableSizeGPUAllocationsManager ListMgr(128, Allocator); - - VariableSizeGPUAllocationsManager::Allocation al[16]; - for (size_t o = 0; o < _countof(al); ++o) - al[o] = ListMgr.Allocate(8, 4); - EXPECT_TRUE(ListMgr.IsFull()); - - ListMgr.Free(std::move(al[1]), 0); - ListMgr.Free(std::move(al[5]), 0); - ListMgr.Free(std::move(al[4]), 0); - ListMgr.Free(std::move(al[3]), 0); - - ListMgr.Free(al[10].UnalignedOffset, al[10].Size, 1); - ListMgr.Free(al[13].UnalignedOffset, al[13].Size, 1); - ListMgr.Free(al[2].UnalignedOffset, al[2].Size, 1); - ListMgr.Free(al[8].UnalignedOffset, al[8].Size, 1); - - ListMgr.ReleaseStaleAllocations(1); - - ListMgr.Free(std::move(al[14]), 2); - ListMgr.Free(std::move(al[7]), 2); - ListMgr.Free(std::move(al[0]), 2); - ListMgr.Free(std::move(al[9]), 2); - - ListMgr.ReleaseStaleAllocations(2); - - ListMgr.Free(std::move(al[12]), 1); - ListMgr.Free(std::move(al[15]), 1); - ListMgr.Free(std::move(al[6]), 1); - ListMgr.Free(std::move(al[11]), 1); - - ListMgr.ReleaseStaleAllocations(3); - } -} - -} // namespace diff --git a/UnitTests/DiligentCoreTest/src/Platforms/PlatformMiscTest.cpp b/UnitTests/DiligentCoreTest/src/Platforms/PlatformMiscTest.cpp deleted file mode 100644 index 78543d53..00000000 --- a/UnitTests/DiligentCoreTest/src/Platforms/PlatformMiscTest.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "PlatformMisc.h" - -#include "gtest/gtest.h" - -using namespace Diligent; - -namespace -{ - -TEST(Platforms_PlatformMisc, GetMsbLsb) -{ - EXPECT_EQ(PlatformMisc::GetMSB(Uint32{0}), Uint32{32}); - for (Uint32 i = 0; i < 32; ++i) - { - auto MSB = PlatformMisc::GetMSB((Uint32{1} << i) | 1); - EXPECT_EQ(MSB, i); - } - - EXPECT_EQ(PlatformMisc::GetMSB(Uint64{0}), Uint64{64}); - for (Uint32 i = 0; i < 64; ++i) - { - auto MSB = PlatformMisc::GetMSB((Uint64{1} << i) | 1); - EXPECT_EQ(MSB, i); - } - - EXPECT_EQ(PlatformMisc::GetLSB(Uint32{0}), Uint32{32}); - for (Uint32 i = 0; i < 32; ++i) - { - auto LSB = PlatformMisc::GetLSB((Uint32{1} << i) | (Uint32{1} << 31)); - EXPECT_EQ(LSB, i); - } - - EXPECT_EQ(PlatformMisc::GetLSB(Uint64{0}), Uint64{64}); - for (Uint32 i = 0; i < 64; ++i) - { - auto LSB = PlatformMisc::GetLSB((Uint64{1} << i) | (Uint64{1} << 63)); - EXPECT_EQ(LSB, i); - } -} - -TEST(Platforms_PlatformMisc, CountOneBits) -{ - EXPECT_EQ(PlatformMisc::CountOneBits(Uint32{0}), Uint32{0}); - EXPECT_EQ(PlatformMisc::CountOneBits(Uint64{0}), Uint64{0}); - EXPECT_EQ(PlatformMisc::CountOneBits(Uint32{1}), Uint32{1}); - EXPECT_EQ(PlatformMisc::CountOneBits(Uint64{1}), Uint64{1}); - EXPECT_EQ(PlatformMisc::CountOneBits(Uint32{7}), Uint32{3}); - EXPECT_EQ(PlatformMisc::CountOneBits(Uint64{7}), Uint64{3}); - EXPECT_EQ(PlatformMisc::CountOneBits((Uint32{1} << 31) | (Uint32{1} << 15)), Uint32{2}); - EXPECT_EQ(PlatformMisc::CountOneBits((Uint64{1} << 63) | (Uint32{1} << 31)), Uint64{2}); - EXPECT_EQ(PlatformMisc::CountOneBits((Uint32{1} << 31) - 1), Uint32{31}); - EXPECT_EQ(PlatformMisc::CountOneBits((Uint64{1} << 63) - 1), Uint64{63}); -} - -} // namespace diff --git a/UnitTests/IncludeTest/CMakeLists.txt b/UnitTests/IncludeTest/CMakeLists.txt deleted file mode 100644 index 3208c23f..00000000 --- a/UnitTests/IncludeTest/CMakeLists.txt +++ /dev/null @@ -1,48 +0,0 @@ -cmake_minimum_required (VERSION 3.6) - -project(DiligentCore-IncludeTest) - -file(GLOB_RECURSE SOURCE LIST_DIRECTORIES false *.cpp) - -if(NOT D3D11_SUPPORTED) - file(GLOB GRAPHICS_ENGINE_D3D11_INC_TEST LIST_DIRECTORIES false GraphicsEngineD3D11/*.cpp) - list(REMOVE_ITEM SOURCE ${GRAPHICS_ENGINE_D3D11_INC_TEST}) -endif() - -if(NOT D3D12_SUPPORTED) - file(GLOB GRAPHICS_ENGINE_D3D12_INC_TEST LIST_DIRECTORIES false GraphicsEngineD3D12/*.cpp) - list(REMOVE_ITEM SOURCE ${GRAPHICS_ENGINE_D3D12_INC_TEST}) -endif() - -if(NOT D3D11_SUPPORTED AND NOT D3D12_SUPPORTED) - file(GLOB GRAPHICS_ENGINE_D3DBASE_INC_TEST LIST_DIRECTORIES false GraphicsEngineD3DBase/*.cpp) - list(REMOVE_ITEM SOURCE ${GRAPHICS_ENGINE_D3DBASE_INC_TEST}) -endif() - -if(NOT GL_SUPPORTED AND NOT GLES_SUPPORTED) - file(GLOB GRAPHICS_ENGINE_GL_INC_TEST LIST_DIRECTORIES false GraphicsEngineOpenGL/*.cpp) - list(REMOVE_ITEM SOURCE ${GRAPHICS_ENGINE_GL_INC_TEST}) -endif() - -if(NOT VULKAN_SUPPORTED) - file(GLOB GRAPHICS_ENGINE_VK_INC_TEST LIST_DIRECTORIES false GraphicsEngineVk/*.cpp) - list(REMOVE_ITEM SOURCE ${GRAPHICS_ENGINE_VK_INC_TEST}) -endif() - -add_library(DiligentCore-IncludeTest ${SOURCE}) - -target_include_directories(DiligentCore-IncludeTest PRIVATE ../../..) -target_link_libraries(DiligentCore-IncludeTest PRIVATE Diligent-BuildSettings) -set_common_target_properties(DiligentCore-IncludeTest) - -if(MSVC) - set_target_properties(DiligentCore-IncludeTest PROPERTIES - STATIC_LIBRARY_FLAGS "/IGNORE:4221" - ) -endif() - -source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${SOURCE}) - -set_target_properties(DiligentCore-IncludeTest PROPERTIES - FOLDER "DiligentCore/Tests" -) diff --git a/UnitTests/IncludeTest/Common/AdvancedMathH_test.cpp b/UnitTests/IncludeTest/Common/AdvancedMathH_test.cpp deleted file mode 100644 index df8cc14f..00000000 --- a/UnitTests/IncludeTest/Common/AdvancedMathH_test.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "DiligentCore/Common/interface/AdvancedMath.h" diff --git a/UnitTests/IncludeTest/Common/BasicFileStreamH_test.cpp b/UnitTests/IncludeTest/Common/BasicFileStreamH_test.cpp deleted file mode 100644 index aa08514c..00000000 --- a/UnitTests/IncludeTest/Common/BasicFileStreamH_test.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "DiligentCore/Common/interface/BasicFileStream.h" diff --git a/UnitTests/IncludeTest/Common/BasicMathH_test.cpp b/UnitTests/IncludeTest/Common/BasicMathH_test.cpp deleted file mode 100644 index 09576d34..00000000 --- a/UnitTests/IncludeTest/Common/BasicMathH_test.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "DiligentCore/Common/interface/BasicMath.h" diff --git a/UnitTests/IncludeTest/Common/DataBlobImplH_test.cpp b/UnitTests/IncludeTest/Common/DataBlobImplH_test.cpp deleted file mode 100644 index f72994d6..00000000 --- a/UnitTests/IncludeTest/Common/DataBlobImplH_test.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "DiligentCore/Common/interface/DataBlobImpl.h" diff --git a/UnitTests/IncludeTest/Common/DefaultRawMemoryAllocatorH_test.cpp b/UnitTests/IncludeTest/Common/DefaultRawMemoryAllocatorH_test.cpp deleted file mode 100644 index fa3990d4..00000000 --- a/UnitTests/IncludeTest/Common/DefaultRawMemoryAllocatorH_test.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "DiligentCore/Common/interface/DefaultRawMemoryAllocator.h" diff --git a/UnitTests/IncludeTest/Common/FileWrapperH_test.cpp b/UnitTests/IncludeTest/Common/FileWrapperH_test.cpp deleted file mode 100644 index ac8375b3..00000000 --- a/UnitTests/IncludeTest/Common/FileWrapperH_test.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "DiligentCore/Common/interface/FileWrapper.h" diff --git a/UnitTests/IncludeTest/Common/FixedBlockMemoryAllocatorH_test.cpp b/UnitTests/IncludeTest/Common/FixedBlockMemoryAllocatorH_test.cpp deleted file mode 100644 index 0d719caa..00000000 --- a/UnitTests/IncludeTest/Common/FixedBlockMemoryAllocatorH_test.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "DiligentCore/Common/interface/FixedBlockMemoryAllocator.h" diff --git a/UnitTests/IncludeTest/Common/HashUtilsH_test.cpp b/UnitTests/IncludeTest/Common/HashUtilsH_test.cpp deleted file mode 100644 index 79bfaeed..00000000 --- a/UnitTests/IncludeTest/Common/HashUtilsH_test.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "DiligentCore/Common/interface/HashUtils.h" diff --git a/UnitTests/IncludeTest/Common/LockHelperH_test.cpp b/UnitTests/IncludeTest/Common/LockHelperH_test.cpp deleted file mode 100644 index 19cb7ef9..00000000 --- a/UnitTests/IncludeTest/Common/LockHelperH_test.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "DiligentCore/Common/interface/LockHelper.h" diff --git a/UnitTests/IncludeTest/Common/ObjectBaseH_test.cpp b/UnitTests/IncludeTest/Common/ObjectBaseH_test.cpp deleted file mode 100644 index 7b1e26dc..00000000 --- a/UnitTests/IncludeTest/Common/ObjectBaseH_test.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "DiligentCore/Common/interface/ObjectBase.h" diff --git a/UnitTests/IncludeTest/Common/RefCntAutoPtrH_test.cpp b/UnitTests/IncludeTest/Common/RefCntAutoPtrH_test.cpp deleted file mode 100644 index 79c52c90..00000000 --- a/UnitTests/IncludeTest/Common/RefCntAutoPtrH_test.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "DiligentCore/Common/interface/RefCntAutoPtr.h" diff --git a/UnitTests/IncludeTest/Common/RefCountedObjectImplH_test.cpp b/UnitTests/IncludeTest/Common/RefCountedObjectImplH_test.cpp deleted file mode 100644 index 33df39c0..00000000 --- a/UnitTests/IncludeTest/Common/RefCountedObjectImplH_test.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "DiligentCore/Common/interface/RefCountedObjectImpl.h" diff --git a/UnitTests/IncludeTest/Common/STDAllocatorH_test.cpp b/UnitTests/IncludeTest/Common/STDAllocatorH_test.cpp deleted file mode 100644 index c2ca54f3..00000000 --- a/UnitTests/IncludeTest/Common/STDAllocatorH_test.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "DiligentCore/Common/interface/STDAllocator.h" diff --git a/UnitTests/IncludeTest/Common/StringDataBlobImplH_test.cpp b/UnitTests/IncludeTest/Common/StringDataBlobImplH_test.cpp deleted file mode 100644 index 889cca6d..00000000 --- a/UnitTests/IncludeTest/Common/StringDataBlobImplH_test.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "DiligentCore/Common/interface/StringDataBlobImpl.h" diff --git a/UnitTests/IncludeTest/Common/StringPool_test.cpp b/UnitTests/IncludeTest/Common/StringPool_test.cpp deleted file mode 100644 index 0fe38252..00000000 --- a/UnitTests/IncludeTest/Common/StringPool_test.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "DiligentCore/Common/interface/StringPool.h" diff --git a/UnitTests/IncludeTest/Common/StringToolsH_test.cpp b/UnitTests/IncludeTest/Common/StringToolsH_test.cpp deleted file mode 100644 index f4ea9c43..00000000 --- a/UnitTests/IncludeTest/Common/StringToolsH_test.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "DiligentCore/Common/interface/StringTools.h" diff --git a/UnitTests/IncludeTest/Common/ThreadSignalH_test.cpp b/UnitTests/IncludeTest/Common/ThreadSignalH_test.cpp deleted file mode 100644 index d3e9803b..00000000 --- a/UnitTests/IncludeTest/Common/ThreadSignalH_test.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "DiligentCore/Common/interface/ThreadSignal.h" diff --git a/UnitTests/IncludeTest/Common/TimerH_test.cpp b/UnitTests/IncludeTest/Common/TimerH_test.cpp deleted file mode 100644 index 9884c09b..00000000 --- a/UnitTests/IncludeTest/Common/TimerH_test.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "DiligentCore/Common/interface/Timer.h" diff --git a/UnitTests/IncludeTest/Common/UniqueIdentifierH_test.cpp b/UnitTests/IncludeTest/Common/UniqueIdentifierH_test.cpp deleted file mode 100644 index 2c3bb79e..00000000 --- a/UnitTests/IncludeTest/Common/UniqueIdentifierH_test.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "DiligentCore/Common/interface/UniqueIdentifier.h" diff --git a/UnitTests/IncludeTest/Common/ValidatedCastH_test.cpp b/UnitTests/IncludeTest/Common/ValidatedCastH_test.cpp deleted file mode 100644 index 66aa9ce3..00000000 --- a/UnitTests/IncludeTest/Common/ValidatedCastH_test.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "DiligentCore/Common/interface/ValidatedCast.h" diff --git a/UnitTests/IncludeTest/GraphicsAccessories/ColorConversionH_test.cpp b/UnitTests/IncludeTest/GraphicsAccessories/ColorConversionH_test.cpp deleted file mode 100644 index cf160a97..00000000 --- a/UnitTests/IncludeTest/GraphicsAccessories/ColorConversionH_test.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "DiligentCore/Graphics/GraphicsAccessories/interface/ColorConversion.h" diff --git a/UnitTests/IncludeTest/GraphicsAccessories/GraphicsAccessoriesH_test.cpp b/UnitTests/IncludeTest/GraphicsAccessories/GraphicsAccessoriesH_test.cpp deleted file mode 100644 index dc95f655..00000000 --- a/UnitTests/IncludeTest/GraphicsAccessories/GraphicsAccessoriesH_test.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "DiligentCore/Graphics/GraphicsAccessories/interface/GraphicsAccessories.h" diff --git a/UnitTests/IncludeTest/GraphicsAccessories/ResourceReleaseQueueH_test.cpp b/UnitTests/IncludeTest/GraphicsAccessories/ResourceReleaseQueueH_test.cpp deleted file mode 100644 index 459711c7..00000000 --- a/UnitTests/IncludeTest/GraphicsAccessories/ResourceReleaseQueueH_test.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "DiligentCore/Graphics/GraphicsAccessories/interface/ResourceReleaseQueue.h" diff --git a/UnitTests/IncludeTest/GraphicsAccessories/RingBufferH_test.cpp b/UnitTests/IncludeTest/GraphicsAccessories/RingBufferH_test.cpp deleted file mode 100644 index ebe47e97..00000000 --- a/UnitTests/IncludeTest/GraphicsAccessories/RingBufferH_test.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "DiligentCore/Graphics/GraphicsAccessories/interface/RingBuffer.h" diff --git a/UnitTests/IncludeTest/GraphicsAccessories/SRBMemortAllocatorH_test.cpp b/UnitTests/IncludeTest/GraphicsAccessories/SRBMemortAllocatorH_test.cpp deleted file mode 100644 index 94317363..00000000 --- a/UnitTests/IncludeTest/GraphicsAccessories/SRBMemortAllocatorH_test.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "DiligentCore/Graphics/GraphicsAccessories/interface/SRBMemoryAllocator.h" diff --git a/UnitTests/IncludeTest/GraphicsAccessories/VariableSizeAllocationsManagerH_test.cpp b/UnitTests/IncludeTest/GraphicsAccessories/VariableSizeAllocationsManagerH_test.cpp deleted file mode 100644 index d0cfefe6..00000000 --- a/UnitTests/IncludeTest/GraphicsAccessories/VariableSizeAllocationsManagerH_test.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "DiligentCore/Graphics/GraphicsAccessories/interface/VariableSizeAllocationsManager.h" diff --git a/UnitTests/IncludeTest/GraphicsAccessories/VariableSizeGPUAllocationsManagerH_test.cpp b/UnitTests/IncludeTest/GraphicsAccessories/VariableSizeGPUAllocationsManagerH_test.cpp deleted file mode 100644 index 324f1914..00000000 --- a/UnitTests/IncludeTest/GraphicsAccessories/VariableSizeGPUAllocationsManagerH_test.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "DiligentCore/Graphics/GraphicsAccessories/interface/VariableSizeGPUAllocationsManager.h" diff --git a/UnitTests/IncludeTest/GraphicsEngine/BlendStateH_test.cpp b/UnitTests/IncludeTest/GraphicsEngine/BlendStateH_test.cpp deleted file mode 100644 index 8fe22738..00000000 --- a/UnitTests/IncludeTest/GraphicsEngine/BlendStateH_test.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "DiligentCore/Graphics/GraphicsEngine/interface/BlendState.h" diff --git a/UnitTests/IncludeTest/GraphicsEngine/BufferH_test.cpp b/UnitTests/IncludeTest/GraphicsEngine/BufferH_test.cpp deleted file mode 100644 index 175494a7..00000000 --- a/UnitTests/IncludeTest/GraphicsEngine/BufferH_test.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "DiligentCore/Graphics/GraphicsEngine/interface/Buffer.h" \ No newline at end of file diff --git a/UnitTests/IncludeTest/GraphicsEngine/BufferViewH_test.cpp b/UnitTests/IncludeTest/GraphicsEngine/BufferViewH_test.cpp deleted file mode 100644 index 3cc88c4e..00000000 --- a/UnitTests/IncludeTest/GraphicsEngine/BufferViewH_test.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "DiligentCore/Graphics/GraphicsEngine/interface/BufferView.h" \ No newline at end of file diff --git a/UnitTests/IncludeTest/GraphicsEngine/CommandListH_test.cpp b/UnitTests/IncludeTest/GraphicsEngine/CommandListH_test.cpp deleted file mode 100644 index abe39f27..00000000 --- a/UnitTests/IncludeTest/GraphicsEngine/CommandListH_test.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "DiligentCore/Graphics/GraphicsEngine/interface/CommandList.h" \ No newline at end of file diff --git a/UnitTests/IncludeTest/GraphicsEngine/ConstantsH_test.cpp b/UnitTests/IncludeTest/GraphicsEngine/ConstantsH_test.cpp deleted file mode 100644 index d5312411..00000000 --- a/UnitTests/IncludeTest/GraphicsEngine/ConstantsH_test.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "DiligentCore/Graphics/GraphicsEngine/interface/Constants.h" diff --git a/UnitTests/IncludeTest/GraphicsEngine/DefaultShaderSourceStreamFactoryH_test.cpp b/UnitTests/IncludeTest/GraphicsEngine/DefaultShaderSourceStreamFactoryH_test.cpp deleted file mode 100644 index 5cdbc81d..00000000 --- a/UnitTests/IncludeTest/GraphicsEngine/DefaultShaderSourceStreamFactoryH_test.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "DiligentCore/Graphics/GraphicsEngine/include/DefaultShaderSourceStreamFactory.h" diff --git a/UnitTests/IncludeTest/GraphicsEngine/DepthStencilStateH_test.cpp b/UnitTests/IncludeTest/GraphicsEngine/DepthStencilStateH_test.cpp deleted file mode 100644 index 12502b60..00000000 --- a/UnitTests/IncludeTest/GraphicsEngine/DepthStencilStateH_test.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "DiligentCore/Graphics/GraphicsEngine/interface/DepthStencilState.h" diff --git a/UnitTests/IncludeTest/GraphicsEngine/DeviceCapsH_test.cpp b/UnitTests/IncludeTest/GraphicsEngine/DeviceCapsH_test.cpp deleted file mode 100644 index 1a2c324c..00000000 --- a/UnitTests/IncludeTest/GraphicsEngine/DeviceCapsH_test.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "DiligentCore/Graphics/GraphicsEngine/interface/DeviceCaps.h" diff --git a/UnitTests/IncludeTest/GraphicsEngine/DeviceContextH_test.cpp b/UnitTests/IncludeTest/GraphicsEngine/DeviceContextH_test.cpp deleted file mode 100644 index 1161f611..00000000 --- a/UnitTests/IncludeTest/GraphicsEngine/DeviceContextH_test.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "DiligentCore/Graphics/GraphicsEngine/interface/DeviceContext.h" diff --git a/UnitTests/IncludeTest/GraphicsEngine/DeviceObjectH_test.cpp b/UnitTests/IncludeTest/GraphicsEngine/DeviceObjectH_test.cpp deleted file mode 100644 index 30f3c828..00000000 --- a/UnitTests/IncludeTest/GraphicsEngine/DeviceObjectH_test.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "DiligentCore/Graphics/GraphicsEngine/interface/DeviceObject.h" diff --git a/UnitTests/IncludeTest/GraphicsEngine/EngineFactoryH_test.cpp b/UnitTests/IncludeTest/GraphicsEngine/EngineFactoryH_test.cpp deleted file mode 100644 index 66a6d061..00000000 --- a/UnitTests/IncludeTest/GraphicsEngine/EngineFactoryH_test.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "DiligentCore/Graphics/GraphicsEngine/interface/EngineFactory.h" \ No newline at end of file diff --git a/UnitTests/IncludeTest/GraphicsEngine/FenceH_test.cpp b/UnitTests/IncludeTest/GraphicsEngine/FenceH_test.cpp deleted file mode 100644 index ec683990..00000000 --- a/UnitTests/IncludeTest/GraphicsEngine/FenceH_test.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "DiligentCore/Graphics/GraphicsEngine/interface/Fence.h" \ No newline at end of file diff --git a/UnitTests/IncludeTest/GraphicsEngine/GraphicsTypesH_test.cpp b/UnitTests/IncludeTest/GraphicsEngine/GraphicsTypesH_test.cpp deleted file mode 100644 index 480e4a16..00000000 --- a/UnitTests/IncludeTest/GraphicsEngine/GraphicsTypesH_test.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "DiligentCore/Graphics/GraphicsEngine/interface/GraphicsTypes.h" diff --git a/UnitTests/IncludeTest/GraphicsEngine/InputLayoutH_test.cpp b/UnitTests/IncludeTest/GraphicsEngine/InputLayoutH_test.cpp deleted file mode 100644 index 9b3581fa..00000000 --- a/UnitTests/IncludeTest/GraphicsEngine/InputLayoutH_test.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "DiligentCore/Graphics/GraphicsEngine/interface/InputLayout.h" diff --git a/UnitTests/IncludeTest/GraphicsEngine/MapHelperH_test.cpp b/UnitTests/IncludeTest/GraphicsEngine/MapHelperH_test.cpp deleted file mode 100644 index b3b7a6d0..00000000 --- a/UnitTests/IncludeTest/GraphicsEngine/MapHelperH_test.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "DiligentCore/Graphics/GraphicsEngine/interface/MapHelper.h" diff --git a/UnitTests/IncludeTest/GraphicsEngine/PipelineStateH_test.cpp b/UnitTests/IncludeTest/GraphicsEngine/PipelineStateH_test.cpp deleted file mode 100644 index b3b19163..00000000 --- a/UnitTests/IncludeTest/GraphicsEngine/PipelineStateH_test.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "DiligentCore/Graphics/GraphicsEngine/interface/PipelineState.h" diff --git a/UnitTests/IncludeTest/GraphicsEngine/RasterizerStateH_test.cpp b/UnitTests/IncludeTest/GraphicsEngine/RasterizerStateH_test.cpp deleted file mode 100644 index 598e2f5e..00000000 --- a/UnitTests/IncludeTest/GraphicsEngine/RasterizerStateH_test.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "DiligentCore/Graphics/GraphicsEngine/interface/RasterizerState.h" diff --git a/UnitTests/IncludeTest/GraphicsEngine/RenderDeviceH_test.cpp b/UnitTests/IncludeTest/GraphicsEngine/RenderDeviceH_test.cpp deleted file mode 100644 index 2eaf3641..00000000 --- a/UnitTests/IncludeTest/GraphicsEngine/RenderDeviceH_test.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "DiligentCore/Graphics/GraphicsEngine/interface/RenderDevice.h" diff --git a/UnitTests/IncludeTest/GraphicsEngine/ResourceMappingH_test.cpp b/UnitTests/IncludeTest/GraphicsEngine/ResourceMappingH_test.cpp deleted file mode 100644 index db76165c..00000000 --- a/UnitTests/IncludeTest/GraphicsEngine/ResourceMappingH_test.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "DiligentCore/Graphics/GraphicsEngine/interface/ResourceMapping.h" diff --git a/UnitTests/IncludeTest/GraphicsEngine/SamplerH_test.cpp b/UnitTests/IncludeTest/GraphicsEngine/SamplerH_test.cpp deleted file mode 100644 index aa02c1f9..00000000 --- a/UnitTests/IncludeTest/GraphicsEngine/SamplerH_test.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "DiligentCore/Graphics/GraphicsEngine/interface/Sampler.h" diff --git a/UnitTests/IncludeTest/GraphicsEngine/ShaderH_test.cpp b/UnitTests/IncludeTest/GraphicsEngine/ShaderH_test.cpp deleted file mode 100644 index 0e68007c..00000000 --- a/UnitTests/IncludeTest/GraphicsEngine/ShaderH_test.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "DiligentCore/Graphics/GraphicsEngine/interface/Shader.h" diff --git a/UnitTests/IncludeTest/GraphicsEngine/ShaderResourceBindingH_test.cpp b/UnitTests/IncludeTest/GraphicsEngine/ShaderResourceBindingH_test.cpp deleted file mode 100644 index d91f48bf..00000000 --- a/UnitTests/IncludeTest/GraphicsEngine/ShaderResourceBindingH_test.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "DiligentCore/Graphics/GraphicsEngine/interface/ShaderResourceBinding.h" diff --git a/UnitTests/IncludeTest/GraphicsEngine/ShaderResourceVaraibleH_test.cpp b/UnitTests/IncludeTest/GraphicsEngine/ShaderResourceVaraibleH_test.cpp deleted file mode 100644 index 3e0ad249..00000000 --- a/UnitTests/IncludeTest/GraphicsEngine/ShaderResourceVaraibleH_test.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "DiligentCore/Graphics/GraphicsEngine/interface/ShaderResourceVariable.h" diff --git a/UnitTests/IncludeTest/GraphicsEngine/SwapChainH_test.cpp b/UnitTests/IncludeTest/GraphicsEngine/SwapChainH_test.cpp deleted file mode 100644 index 67be654c..00000000 --- a/UnitTests/IncludeTest/GraphicsEngine/SwapChainH_test.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "DiligentCore/Graphics/GraphicsEngine/interface/SwapChain.h" \ No newline at end of file diff --git a/UnitTests/IncludeTest/GraphicsEngine/TextureH_test.cpp b/UnitTests/IncludeTest/GraphicsEngine/TextureH_test.cpp deleted file mode 100644 index 0252cb1c..00000000 --- a/UnitTests/IncludeTest/GraphicsEngine/TextureH_test.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "DiligentCore/Graphics/GraphicsEngine/interface/Texture.h" diff --git a/UnitTests/IncludeTest/GraphicsEngine/TextureViewH_test.cpp b/UnitTests/IncludeTest/GraphicsEngine/TextureViewH_test.cpp deleted file mode 100644 index acafd3c7..00000000 --- a/UnitTests/IncludeTest/GraphicsEngine/TextureViewH_test.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "DiligentCore/Graphics/GraphicsEngine/interface/TextureView.h" diff --git a/UnitTests/IncludeTest/GraphicsEngineD3D11/BufferD3D11H_test.cpp b/UnitTests/IncludeTest/GraphicsEngineD3D11/BufferD3D11H_test.cpp deleted file mode 100644 index 30ecdc00..00000000 --- a/UnitTests/IncludeTest/GraphicsEngineD3D11/BufferD3D11H_test.cpp +++ /dev/null @@ -1,25 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include -#include "DiligentCore/Graphics/GraphicsEngineD3D11/interface/BufferD3D11.h" diff --git a/UnitTests/IncludeTest/GraphicsEngineD3D11/BufferViewD3D11H_test.cpp b/UnitTests/IncludeTest/GraphicsEngineD3D11/BufferViewD3D11H_test.cpp deleted file mode 100644 index 23a5aa37..00000000 --- a/UnitTests/IncludeTest/GraphicsEngineD3D11/BufferViewD3D11H_test.cpp +++ /dev/null @@ -1,25 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include -#include "DiligentCore/Graphics/GraphicsEngineD3D11/interface/BufferViewD3D11.h" diff --git a/UnitTests/IncludeTest/GraphicsEngineD3D11/DeviceContextD3D11H_test.cpp b/UnitTests/IncludeTest/GraphicsEngineD3D11/DeviceContextD3D11H_test.cpp deleted file mode 100644 index 4b654bc2..00000000 --- a/UnitTests/IncludeTest/GraphicsEngineD3D11/DeviceContextD3D11H_test.cpp +++ /dev/null @@ -1,25 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include -#include "DiligentCore/Graphics/GraphicsEngineD3D11/interface/DeviceContextD3D11.h" diff --git a/UnitTests/IncludeTest/GraphicsEngineD3D11/EngineFactoryD3D11H_test.cpp b/UnitTests/IncludeTest/GraphicsEngineD3D11/EngineFactoryD3D11H_test.cpp deleted file mode 100644 index f7a1c6f1..00000000 --- a/UnitTests/IncludeTest/GraphicsEngineD3D11/EngineFactoryD3D11H_test.cpp +++ /dev/null @@ -1,33 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#ifndef NOMINMAX -# define NOMINMAX -#endif -#include - -#ifndef ENGINE_DLL -# define ENGINE_DLL 1 -#endif - -#include "DiligentCore/Graphics/GraphicsEngineD3D11/interface/EngineFactoryD3D11.h" diff --git a/UnitTests/IncludeTest/GraphicsEngineD3D11/FenceD3D11H_test.cpp b/UnitTests/IncludeTest/GraphicsEngineD3D11/FenceD3D11H_test.cpp deleted file mode 100644 index e568e924..00000000 --- a/UnitTests/IncludeTest/GraphicsEngineD3D11/FenceD3D11H_test.cpp +++ /dev/null @@ -1,25 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include -#include "DiligentCore/Graphics/GraphicsEngineD3D11/interface/FenceD3D11.h" diff --git a/UnitTests/IncludeTest/GraphicsEngineD3D11/PipelineStateD3D11H_test.cpp b/UnitTests/IncludeTest/GraphicsEngineD3D11/PipelineStateD3D11H_test.cpp deleted file mode 100644 index 8fb95d90..00000000 --- a/UnitTests/IncludeTest/GraphicsEngineD3D11/PipelineStateD3D11H_test.cpp +++ /dev/null @@ -1,25 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include -#include "DiligentCore/Graphics/GraphicsEngineD3D11/interface/PipelineStateD3D11.h" diff --git a/UnitTests/IncludeTest/GraphicsEngineD3D11/RenderDeviceD3D11H_test.cpp b/UnitTests/IncludeTest/GraphicsEngineD3D11/RenderDeviceD3D11H_test.cpp deleted file mode 100644 index abf6da80..00000000 --- a/UnitTests/IncludeTest/GraphicsEngineD3D11/RenderDeviceD3D11H_test.cpp +++ /dev/null @@ -1,25 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include -#include "DiligentCore/Graphics/GraphicsEngineD3D11/interface/RenderDeviceD3D11.h" diff --git a/UnitTests/IncludeTest/GraphicsEngineD3D11/SamplerD3D11H_test.cpp b/UnitTests/IncludeTest/GraphicsEngineD3D11/SamplerD3D11H_test.cpp deleted file mode 100644 index 00961e95..00000000 --- a/UnitTests/IncludeTest/GraphicsEngineD3D11/SamplerD3D11H_test.cpp +++ /dev/null @@ -1,25 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include -#include "DiligentCore/Graphics/GraphicsEngineD3D11/interface/SamplerD3D11.h" diff --git a/UnitTests/IncludeTest/GraphicsEngineD3D11/ShaderD3D11H_test.cpp b/UnitTests/IncludeTest/GraphicsEngineD3D11/ShaderD3D11H_test.cpp deleted file mode 100644 index 77ca1a69..00000000 --- a/UnitTests/IncludeTest/GraphicsEngineD3D11/ShaderD3D11H_test.cpp +++ /dev/null @@ -1,25 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ -#include - -#include "DiligentCore/Graphics/GraphicsEngineD3D11/interface/ShaderD3D11.h" diff --git a/UnitTests/IncludeTest/GraphicsEngineD3D11/ShaderResourceBindingD3D11H_test.cpp b/UnitTests/IncludeTest/GraphicsEngineD3D11/ShaderResourceBindingD3D11H_test.cpp deleted file mode 100644 index 9409f3f6..00000000 --- a/UnitTests/IncludeTest/GraphicsEngineD3D11/ShaderResourceBindingD3D11H_test.cpp +++ /dev/null @@ -1,25 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ -#include - -#include "DiligentCore/Graphics/GraphicsEngineD3D11/interface/ShaderResourceBindingD3D11.h" diff --git a/UnitTests/IncludeTest/GraphicsEngineD3D11/SwapChainD3D11H_test.cpp b/UnitTests/IncludeTest/GraphicsEngineD3D11/SwapChainD3D11H_test.cpp deleted file mode 100644 index 59f23387..00000000 --- a/UnitTests/IncludeTest/GraphicsEngineD3D11/SwapChainD3D11H_test.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ -#include -#include "DiligentCore/Graphics/GraphicsEngineD3D11/interface/SwapChainD3D11.h" \ No newline at end of file diff --git a/UnitTests/IncludeTest/GraphicsEngineD3D11/TextureD3D11H_test.cpp b/UnitTests/IncludeTest/GraphicsEngineD3D11/TextureD3D11H_test.cpp deleted file mode 100644 index 4cd32017..00000000 --- a/UnitTests/IncludeTest/GraphicsEngineD3D11/TextureD3D11H_test.cpp +++ /dev/null @@ -1,25 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ -#include - -#include "DiligentCore/Graphics/GraphicsEngineD3D11/interface/TextureD3D11.h" diff --git a/UnitTests/IncludeTest/GraphicsEngineD3D11/TextureViewD3D11H_test.cpp b/UnitTests/IncludeTest/GraphicsEngineD3D11/TextureViewD3D11H_test.cpp deleted file mode 100644 index 144b72da..00000000 --- a/UnitTests/IncludeTest/GraphicsEngineD3D11/TextureViewD3D11H_test.cpp +++ /dev/null @@ -1,25 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ -#include - -#include "DiligentCore/Graphics/GraphicsEngineD3D11/interface/TextureViewD3D11.h" diff --git a/UnitTests/IncludeTest/GraphicsEngineD3D12/BufferD3D12H_test.cpp b/UnitTests/IncludeTest/GraphicsEngineD3D12/BufferD3D12H_test.cpp deleted file mode 100644 index 13945d1c..00000000 --- a/UnitTests/IncludeTest/GraphicsEngineD3D12/BufferD3D12H_test.cpp +++ /dev/null @@ -1,25 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include -#include "DiligentCore/Graphics/GraphicsEngineD3D12/interface/BufferD3D12.h" diff --git a/UnitTests/IncludeTest/GraphicsEngineD3D12/BufferViewD3D12H_test.cpp b/UnitTests/IncludeTest/GraphicsEngineD3D12/BufferViewD3D12H_test.cpp deleted file mode 100644 index f341419c..00000000 --- a/UnitTests/IncludeTest/GraphicsEngineD3D12/BufferViewD3D12H_test.cpp +++ /dev/null @@ -1,25 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include -#include "DiligentCore/Graphics/GraphicsEngineD3D12/interface/BufferViewD3D12.h" diff --git a/UnitTests/IncludeTest/GraphicsEngineD3D12/CommandQueueD3D12H_test.cpp b/UnitTests/IncludeTest/GraphicsEngineD3D12/CommandQueueD3D12H_test.cpp deleted file mode 100644 index f341419c..00000000 --- a/UnitTests/IncludeTest/GraphicsEngineD3D12/CommandQueueD3D12H_test.cpp +++ /dev/null @@ -1,25 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include -#include "DiligentCore/Graphics/GraphicsEngineD3D12/interface/BufferViewD3D12.h" diff --git a/UnitTests/IncludeTest/GraphicsEngineD3D12/DeviceContextD3D12H_test.cpp b/UnitTests/IncludeTest/GraphicsEngineD3D12/DeviceContextD3D12H_test.cpp deleted file mode 100644 index eafb4881..00000000 --- a/UnitTests/IncludeTest/GraphicsEngineD3D12/DeviceContextD3D12H_test.cpp +++ /dev/null @@ -1,25 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include -#include "DiligentCore/Graphics/GraphicsEngineD3D12/interface/DeviceContextD3D12.h" diff --git a/UnitTests/IncludeTest/GraphicsEngineD3D12/EngineFactoryD3D12H_test.cpp b/UnitTests/IncludeTest/GraphicsEngineD3D12/EngineFactoryD3D12H_test.cpp deleted file mode 100644 index a0351d94..00000000 --- a/UnitTests/IncludeTest/GraphicsEngineD3D12/EngineFactoryD3D12H_test.cpp +++ /dev/null @@ -1,33 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#ifndef NOMINMAX -# define NOMINMAX -#endif -#include - -#ifndef ENGINE_DLL -# define ENGINE_DLL 1 -#endif - -#include "DiligentCore/Graphics/GraphicsEngineD3D12/interface/EngineFactoryD3D12.h" diff --git a/UnitTests/IncludeTest/GraphicsEngineD3D12/FenceD3D12H_test.cpp b/UnitTests/IncludeTest/GraphicsEngineD3D12/FenceD3D12H_test.cpp deleted file mode 100644 index 12e265ba..00000000 --- a/UnitTests/IncludeTest/GraphicsEngineD3D12/FenceD3D12H_test.cpp +++ /dev/null @@ -1,25 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include -#include "DiligentCore/Graphics/GraphicsEngineD3D12/interface/FenceD3D12.h" diff --git a/UnitTests/IncludeTest/GraphicsEngineD3D12/PipelineStateD3D12H_test.cpp b/UnitTests/IncludeTest/GraphicsEngineD3D12/PipelineStateD3D12H_test.cpp deleted file mode 100644 index 05aead58..00000000 --- a/UnitTests/IncludeTest/GraphicsEngineD3D12/PipelineStateD3D12H_test.cpp +++ /dev/null @@ -1,25 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include -#include "DiligentCore/Graphics/GraphicsEngineD3D12/interface/PipelineStateD3D12.h" diff --git a/UnitTests/IncludeTest/GraphicsEngineD3D12/RenderDeviceD3D12H_test.cpp b/UnitTests/IncludeTest/GraphicsEngineD3D12/RenderDeviceD3D12H_test.cpp deleted file mode 100644 index e8d2d2f6..00000000 --- a/UnitTests/IncludeTest/GraphicsEngineD3D12/RenderDeviceD3D12H_test.cpp +++ /dev/null @@ -1,25 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include -#include "DiligentCore/Graphics/GraphicsEngineD3D12/interface/RenderDeviceD3D12.h" diff --git a/UnitTests/IncludeTest/GraphicsEngineD3D12/SamplerD3D12H_test.cpp b/UnitTests/IncludeTest/GraphicsEngineD3D12/SamplerD3D12H_test.cpp deleted file mode 100644 index 3694cd74..00000000 --- a/UnitTests/IncludeTest/GraphicsEngineD3D12/SamplerD3D12H_test.cpp +++ /dev/null @@ -1,25 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include -#include "DiligentCore/Graphics/GraphicsEngineD3D12/interface/SamplerD3D12.h" diff --git a/UnitTests/IncludeTest/GraphicsEngineD3D12/ShaderD3D12H_test.cpp b/UnitTests/IncludeTest/GraphicsEngineD3D12/ShaderD3D12H_test.cpp deleted file mode 100644 index 206058ff..00000000 --- a/UnitTests/IncludeTest/GraphicsEngineD3D12/ShaderD3D12H_test.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ -#include -#include "DiligentCore/Graphics/GraphicsEngineD3D12/interface/ShaderD3D12.h" diff --git a/UnitTests/IncludeTest/GraphicsEngineD3D12/ShaderResourceBindingD3D12H_test.cpp b/UnitTests/IncludeTest/GraphicsEngineD3D12/ShaderResourceBindingD3D12H_test.cpp deleted file mode 100644 index 5ffcafe3..00000000 --- a/UnitTests/IncludeTest/GraphicsEngineD3D12/ShaderResourceBindingD3D12H_test.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ -#include -#include "DiligentCore/Graphics/GraphicsEngineD3D12/interface/ShaderResourceBindingD3D12.h" diff --git a/UnitTests/IncludeTest/GraphicsEngineD3D12/SwapChainD3D12H_test.cpp b/UnitTests/IncludeTest/GraphicsEngineD3D12/SwapChainD3D12H_test.cpp deleted file mode 100644 index 9ca8bdb5..00000000 --- a/UnitTests/IncludeTest/GraphicsEngineD3D12/SwapChainD3D12H_test.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ -#include -#include "DiligentCore/Graphics/GraphicsEngineD3D12/interface/SwapChainD3D12.h" \ No newline at end of file diff --git a/UnitTests/IncludeTest/GraphicsEngineD3D12/TextureD3D12H_test.cpp b/UnitTests/IncludeTest/GraphicsEngineD3D12/TextureD3D12H_test.cpp deleted file mode 100644 index fa9b50ea..00000000 --- a/UnitTests/IncludeTest/GraphicsEngineD3D12/TextureD3D12H_test.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ -#include -#include "DiligentCore/Graphics/GraphicsEngineD3D12/interface/TextureD3D12.h" diff --git a/UnitTests/IncludeTest/GraphicsEngineD3D12/TextureViewD3D12H_test.cpp b/UnitTests/IncludeTest/GraphicsEngineD3D12/TextureViewD3D12H_test.cpp deleted file mode 100644 index bda08196..00000000 --- a/UnitTests/IncludeTest/GraphicsEngineD3D12/TextureViewD3D12H_test.cpp +++ /dev/null @@ -1,25 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include -#include "DiligentCore/Graphics/GraphicsEngineD3D12/interface/TextureViewD3D12.h" diff --git a/UnitTests/IncludeTest/GraphicsEngineD3DBase/ShaderD3DH_test.cpp b/UnitTests/IncludeTest/GraphicsEngineD3DBase/ShaderD3DH_test.cpp deleted file mode 100644 index d8deb96c..00000000 --- a/UnitTests/IncludeTest/GraphicsEngineD3DBase/ShaderD3DH_test.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "DiligentCore/Graphics/GraphicsEngineD3DBase/interface/ShaderD3D.h" \ No newline at end of file diff --git a/UnitTests/IncludeTest/GraphicsEngineD3DBase/ShaderResourceVariableD3DH_test.cpp b/UnitTests/IncludeTest/GraphicsEngineD3DBase/ShaderResourceVariableD3DH_test.cpp deleted file mode 100644 index 32c06851..00000000 --- a/UnitTests/IncludeTest/GraphicsEngineD3DBase/ShaderResourceVariableD3DH_test.cpp +++ /dev/null @@ -1,23 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ -#include "DiligentCore/Graphics/GraphicsEngineD3DBase/interface/ShaderResourceVariableD3D.h" diff --git a/UnitTests/IncludeTest/GraphicsEngineOpenGL/BaseInterfacesGLH_test.cpp b/UnitTests/IncludeTest/GraphicsEngineOpenGL/BaseInterfacesGLH_test.cpp deleted file mode 100644 index b7213875..00000000 --- a/UnitTests/IncludeTest/GraphicsEngineOpenGL/BaseInterfacesGLH_test.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "DiligentCore/Graphics/GraphicsEngineOpenGL/interface/BaseInterfacesGL.h" diff --git a/UnitTests/IncludeTest/GraphicsEngineOpenGL/BufferGLH_test.cpp b/UnitTests/IncludeTest/GraphicsEngineOpenGL/BufferGLH_test.cpp deleted file mode 100644 index f91a96e4..00000000 --- a/UnitTests/IncludeTest/GraphicsEngineOpenGL/BufferGLH_test.cpp +++ /dev/null @@ -1,25 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -typedef unsigned int GLuint; -#include "DiligentCore/Graphics/GraphicsEngineOpenGL/interface/BufferGL.h" diff --git a/UnitTests/IncludeTest/GraphicsEngineOpenGL/BufferViewGLH_test.cpp b/UnitTests/IncludeTest/GraphicsEngineOpenGL/BufferViewGLH_test.cpp deleted file mode 100644 index 5d7e5ebf..00000000 --- a/UnitTests/IncludeTest/GraphicsEngineOpenGL/BufferViewGLH_test.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "DiligentCore/Graphics/GraphicsEngineOpenGL/interface/BufferViewGL.h" diff --git a/UnitTests/IncludeTest/GraphicsEngineOpenGL/DeviceContextGLH_test.cpp b/UnitTests/IncludeTest/GraphicsEngineOpenGL/DeviceContextGLH_test.cpp deleted file mode 100644 index 59204d79..00000000 --- a/UnitTests/IncludeTest/GraphicsEngineOpenGL/DeviceContextGLH_test.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "DiligentCore/Graphics/GraphicsEngineOpenGL/interface/DeviceContextGL.h" diff --git a/UnitTests/IncludeTest/GraphicsEngineOpenGL/EngineFactoryOpenGLH_test.cpp b/UnitTests/IncludeTest/GraphicsEngineOpenGL/EngineFactoryOpenGLH_test.cpp deleted file mode 100644 index 671fe4fe..00000000 --- a/UnitTests/IncludeTest/GraphicsEngineOpenGL/EngineFactoryOpenGLH_test.cpp +++ /dev/null @@ -1,35 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * 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 - -#include "DiligentCore/Graphics/GraphicsEngineOpenGL/interface/EngineFactoryOpenGL.h" diff --git a/UnitTests/IncludeTest/GraphicsEngineOpenGL/FenceGLH_test .cpp b/UnitTests/IncludeTest/GraphicsEngineOpenGL/FenceGLH_test .cpp deleted file mode 100644 index 5c412e64..00000000 --- a/UnitTests/IncludeTest/GraphicsEngineOpenGL/FenceGLH_test .cpp +++ /dev/null @@ -1,25 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -typedef unsigned int GLuint; -#include "DiligentCore/Graphics/GraphicsEngineOpenGL/interface/FenceGL.h" diff --git a/UnitTests/IncludeTest/GraphicsEngineOpenGL/PipelineStateGLH_test.cpp b/UnitTests/IncludeTest/GraphicsEngineOpenGL/PipelineStateGLH_test.cpp deleted file mode 100644 index 6a49ef62..00000000 --- a/UnitTests/IncludeTest/GraphicsEngineOpenGL/PipelineStateGLH_test.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "DiligentCore/Graphics/GraphicsEngineOpenGL/interface/PipelineStateGL.h" diff --git a/UnitTests/IncludeTest/GraphicsEngineOpenGL/RenderDeviceGL_test.cpp b/UnitTests/IncludeTest/GraphicsEngineOpenGL/RenderDeviceGL_test.cpp deleted file mode 100644 index 2c7388b0..00000000 --- a/UnitTests/IncludeTest/GraphicsEngineOpenGL/RenderDeviceGL_test.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "DiligentCore/Graphics/GraphicsEngineOpenGL/interface/RenderDeviceGL.h" diff --git a/UnitTests/IncludeTest/GraphicsEngineOpenGL/SamplerGLH_test.cpp b/UnitTests/IncludeTest/GraphicsEngineOpenGL/SamplerGLH_test.cpp deleted file mode 100644 index 18aa01fc..00000000 --- a/UnitTests/IncludeTest/GraphicsEngineOpenGL/SamplerGLH_test.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "DiligentCore/Graphics/GraphicsEngineOpenGL/interface/SamplerGL.h" diff --git a/UnitTests/IncludeTest/GraphicsEngineOpenGL/ShaderGLH_test.cpp b/UnitTests/IncludeTest/GraphicsEngineOpenGL/ShaderGLH_test.cpp deleted file mode 100644 index 108d261b..00000000 --- a/UnitTests/IncludeTest/GraphicsEngineOpenGL/ShaderGLH_test.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "DiligentCore/Graphics/GraphicsEngineOpenGL/interface/ShaderGL.h" diff --git a/UnitTests/IncludeTest/GraphicsEngineOpenGL/ShaderResourceBindingGLH_test.cpp b/UnitTests/IncludeTest/GraphicsEngineOpenGL/ShaderResourceBindingGLH_test.cpp deleted file mode 100644 index 6bc1f230..00000000 --- a/UnitTests/IncludeTest/GraphicsEngineOpenGL/ShaderResourceBindingGLH_test.cpp +++ /dev/null @@ -1,23 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ -#include "DiligentCore/Graphics/GraphicsEngineOpenGL/interface/ShaderResourceBindingGL.h" diff --git a/UnitTests/IncludeTest/GraphicsEngineOpenGL/SwapChainGLH_test.cpp b/UnitTests/IncludeTest/GraphicsEngineOpenGL/SwapChainGLH_test.cpp deleted file mode 100644 index b8d338b0..00000000 --- a/UnitTests/IncludeTest/GraphicsEngineOpenGL/SwapChainGLH_test.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ -typedef unsigned int GLuint; -#include "DiligentCore/Graphics/GraphicsEngineOpenGL/interface/SwapChainGL.h" \ No newline at end of file diff --git a/UnitTests/IncludeTest/GraphicsEngineOpenGL/TextureGLH_test.cpp b/UnitTests/IncludeTest/GraphicsEngineOpenGL/TextureGLH_test.cpp deleted file mode 100644 index 2c4670bc..00000000 --- a/UnitTests/IncludeTest/GraphicsEngineOpenGL/TextureGLH_test.cpp +++ /dev/null @@ -1,25 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ -typedef unsigned int GLuint; -typedef unsigned int GLenum; -#include "DiligentCore/Graphics/GraphicsEngineOpenGL/interface/TextureGL.h" diff --git a/UnitTests/IncludeTest/GraphicsEngineOpenGL/TextureViewGLH_test.cpp b/UnitTests/IncludeTest/GraphicsEngineOpenGL/TextureViewGLH_test.cpp deleted file mode 100644 index dc7bcd2c..00000000 --- a/UnitTests/IncludeTest/GraphicsEngineOpenGL/TextureViewGLH_test.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "DiligentCore/Graphics/GraphicsEngineOpenGL/interface/TextureViewGL.h" diff --git a/UnitTests/IncludeTest/GraphicsEngineVk/BufferViewVkH_test.cpp b/UnitTests/IncludeTest/GraphicsEngineVk/BufferViewVkH_test.cpp deleted file mode 100644 index 1e419e60..00000000 --- a/UnitTests/IncludeTest/GraphicsEngineVk/BufferViewVkH_test.cpp +++ /dev/null @@ -1,25 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "DiligentCore/ThirdParty/vulkan/vulkan.h" -#include "DiligentCore/Graphics/GraphicsEngineVulkan/interface/BufferViewVk.h" diff --git a/UnitTests/IncludeTest/GraphicsEngineVk/BufferVkH_test.cpp b/UnitTests/IncludeTest/GraphicsEngineVk/BufferVkH_test.cpp deleted file mode 100644 index cc0668a2..00000000 --- a/UnitTests/IncludeTest/GraphicsEngineVk/BufferVkH_test.cpp +++ /dev/null @@ -1,25 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "DiligentCore/ThirdParty/vulkan/vulkan.h" -#include "DiligentCore/Graphics/GraphicsEngineVulkan/interface/BufferVk.h" diff --git a/UnitTests/IncludeTest/GraphicsEngineVk/CommandQueueVkH_test.cpp b/UnitTests/IncludeTest/GraphicsEngineVk/CommandQueueVkH_test.cpp deleted file mode 100644 index 092d564a..00000000 --- a/UnitTests/IncludeTest/GraphicsEngineVk/CommandQueueVkH_test.cpp +++ /dev/null @@ -1,25 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "DiligentCore/ThirdParty/vulkan/vulkan.h" -#include "DiligentCore/Graphics/GraphicsEngineVulkan/interface/CommandQueueVk.h" diff --git a/UnitTests/IncludeTest/GraphicsEngineVk/DeviceContextVkH_test.cpp b/UnitTests/IncludeTest/GraphicsEngineVk/DeviceContextVkH_test.cpp deleted file mode 100644 index b1f66961..00000000 --- a/UnitTests/IncludeTest/GraphicsEngineVk/DeviceContextVkH_test.cpp +++ /dev/null @@ -1,25 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "DiligentCore/ThirdParty/vulkan/vulkan.h" -#include "DiligentCore/Graphics/GraphicsEngineVulkan/interface/DeviceContextVk.h" diff --git a/UnitTests/IncludeTest/GraphicsEngineVk/EngineFactoryVkH_test.cpp b/UnitTests/IncludeTest/GraphicsEngineVk/EngineFactoryVkH_test.cpp deleted file mode 100644 index 9d34cb47..00000000 --- a/UnitTests/IncludeTest/GraphicsEngineVk/EngineFactoryVkH_test.cpp +++ /dev/null @@ -1,35 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * 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" diff --git a/UnitTests/IncludeTest/GraphicsEngineVk/FenceVkH_test.cpp b/UnitTests/IncludeTest/GraphicsEngineVk/FenceVkH_test.cpp deleted file mode 100644 index 7b943c2a..00000000 --- a/UnitTests/IncludeTest/GraphicsEngineVk/FenceVkH_test.cpp +++ /dev/null @@ -1,25 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "DiligentCore/ThirdParty/vulkan/vulkan.h" -#include "DiligentCore/Graphics/GraphicsEngineVulkan/interface/FenceVk.h" diff --git a/UnitTests/IncludeTest/GraphicsEngineVk/PipelineStateVkH_test.cpp b/UnitTests/IncludeTest/GraphicsEngineVk/PipelineStateVkH_test.cpp deleted file mode 100644 index 19d45e6e..00000000 --- a/UnitTests/IncludeTest/GraphicsEngineVk/PipelineStateVkH_test.cpp +++ /dev/null @@ -1,25 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "DiligentCore/ThirdParty/vulkan/vulkan.h" -#include "DiligentCore/Graphics/GraphicsEngineVulkan/interface/PipelineStateVk.h" diff --git a/UnitTests/IncludeTest/GraphicsEngineVk/RenderDeviceVkH_test.cpp b/UnitTests/IncludeTest/GraphicsEngineVk/RenderDeviceVkH_test.cpp deleted file mode 100644 index c4faac67..00000000 --- a/UnitTests/IncludeTest/GraphicsEngineVk/RenderDeviceVkH_test.cpp +++ /dev/null @@ -1,25 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "DiligentCore/ThirdParty/vulkan/vulkan.h" -#include "DiligentCore/Graphics/GraphicsEngineVulkan/interface/RenderDeviceVk.h" diff --git a/UnitTests/IncludeTest/GraphicsEngineVk/SamplerVkH_test.cpp b/UnitTests/IncludeTest/GraphicsEngineVk/SamplerVkH_test.cpp deleted file mode 100644 index 60640a34..00000000 --- a/UnitTests/IncludeTest/GraphicsEngineVk/SamplerVkH_test.cpp +++ /dev/null @@ -1,25 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "DiligentCore/ThirdParty/vulkan/vulkan.h" -#include "DiligentCore/Graphics/GraphicsEngineVulkan/interface/SamplerVk.h" diff --git a/UnitTests/IncludeTest/GraphicsEngineVk/ShaderResourceBindingVkH_test.cpp b/UnitTests/IncludeTest/GraphicsEngineVk/ShaderResourceBindingVkH_test.cpp deleted file mode 100644 index 0d38447c..00000000 --- a/UnitTests/IncludeTest/GraphicsEngineVk/ShaderResourceBindingVkH_test.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ -#include "DiligentCore/ThirdParty/vulkan/vulkan.h" -#include "DiligentCore/Graphics/GraphicsEngineVulkan/interface/ShaderResourceBindingVk.h" diff --git a/UnitTests/IncludeTest/GraphicsEngineVk/ShaderVkH_test.cpp b/UnitTests/IncludeTest/GraphicsEngineVk/ShaderVkH_test.cpp deleted file mode 100644 index 10a06cb0..00000000 --- a/UnitTests/IncludeTest/GraphicsEngineVk/ShaderVkH_test.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ -#include "DiligentCore/ThirdParty/vulkan/vulkan.h" -#include "DiligentCore/Graphics/GraphicsEngineVulkan/interface/ShaderVk.h" diff --git a/UnitTests/IncludeTest/GraphicsEngineVk/SwapChainVkH_test.cpp b/UnitTests/IncludeTest/GraphicsEngineVk/SwapChainVkH_test.cpp deleted file mode 100644 index b42adc73..00000000 --- a/UnitTests/IncludeTest/GraphicsEngineVk/SwapChainVkH_test.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * 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 diff --git a/UnitTests/IncludeTest/GraphicsEngineVk/TextureViewVkH_test.cpp b/UnitTests/IncludeTest/GraphicsEngineVk/TextureViewVkH_test.cpp deleted file mode 100644 index cf611200..00000000 --- a/UnitTests/IncludeTest/GraphicsEngineVk/TextureViewVkH_test.cpp +++ /dev/null @@ -1,25 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "DiligentCore/ThirdParty/vulkan/vulkan.h" -#include "DiligentCore/Graphics/GraphicsEngineVulkan/interface/TextureViewVk.h" diff --git a/UnitTests/IncludeTest/GraphicsEngineVk/TextureVkH_test.cpp b/UnitTests/IncludeTest/GraphicsEngineVk/TextureVkH_test.cpp deleted file mode 100644 index 2ac5dffc..00000000 --- a/UnitTests/IncludeTest/GraphicsEngineVk/TextureVkH_test.cpp +++ /dev/null @@ -1,25 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "DiligentCore/ThirdParty/vulkan/vulkan.h" -#include "DiligentCore/Graphics/GraphicsEngineVulkan/interface/TextureVk.h" diff --git a/UnitTests/IncludeTest/GraphicsTools/CommonlyUsedStatesH_test.cpp b/UnitTests/IncludeTest/GraphicsTools/CommonlyUsedStatesH_test.cpp deleted file mode 100644 index da1ecbd5..00000000 --- a/UnitTests/IncludeTest/GraphicsTools/CommonlyUsedStatesH_test.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "DiligentCore/Graphics/GraphicsTools/include/CommonlyUsedStates.h" diff --git a/UnitTests/IncludeTest/GraphicsTools/GraphicsUtilitiesH_test.cpp b/UnitTests/IncludeTest/GraphicsTools/GraphicsUtilitiesH_test.cpp deleted file mode 100644 index de3396e2..00000000 --- a/UnitTests/IncludeTest/GraphicsTools/GraphicsUtilitiesH_test.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "DiligentCore/Graphics/GraphicsTools/include/GraphicsUtilities.h" diff --git a/UnitTests/IncludeTest/GraphicsTools/ShaderMacroHelperH_test.cpp b/UnitTests/IncludeTest/GraphicsTools/ShaderMacroHelperH_test.cpp deleted file mode 100644 index acfeed8d..00000000 --- a/UnitTests/IncludeTest/GraphicsTools/ShaderMacroHelperH_test.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "DiligentCore/Graphics/GraphicsTools/include/ShaderMacroHelper.h" diff --git a/UnitTests/IncludeTest/GraphicsTools/TextureUploaderBaseH_test.cpp b/UnitTests/IncludeTest/GraphicsTools/TextureUploaderBaseH_test.cpp deleted file mode 100644 index 82e1df06..00000000 --- a/UnitTests/IncludeTest/GraphicsTools/TextureUploaderBaseH_test.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "DiligentCore/Graphics/GraphicsTools/include/TextureUploaderBase.h" diff --git a/UnitTests/IncludeTest/GraphicsTools/TextureUploaderD3D11H_test.cpp b/UnitTests/IncludeTest/GraphicsTools/TextureUploaderD3D11H_test.cpp deleted file mode 100644 index b2b8e97b..00000000 --- a/UnitTests/IncludeTest/GraphicsTools/TextureUploaderD3D11H_test.cpp +++ /dev/null @@ -1,26 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#if D3D11_SUPPORTED -# include "DiligentCore/Graphics/GraphicsTools/include/TextureUploaderD3D11.h" -#endif diff --git a/UnitTests/IncludeTest/GraphicsTools/TextureUploaderD3D12_VkH_test.cpp b/UnitTests/IncludeTest/GraphicsTools/TextureUploaderD3D12_VkH_test.cpp deleted file mode 100644 index b218d340..00000000 --- a/UnitTests/IncludeTest/GraphicsTools/TextureUploaderD3D12_VkH_test.cpp +++ /dev/null @@ -1,26 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#if D3D12_SUPPORTED -# include "DiligentCore/Graphics/GraphicsTools/include/TextureUploaderD3D12_Vk.h" -#endif \ No newline at end of file diff --git a/UnitTests/IncludeTest/GraphicsTools/TextureUploaderGLH_test.cpp b/UnitTests/IncludeTest/GraphicsTools/TextureUploaderGLH_test.cpp deleted file mode 100644 index 943609ca..00000000 --- a/UnitTests/IncludeTest/GraphicsTools/TextureUploaderGLH_test.cpp +++ /dev/null @@ -1,26 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#if GL_SUPPORTED || GLES_SUPPORTED -# include "DiligentCore/Graphics/GraphicsTools/include/TextureUploaderGL.h" -#endif \ No newline at end of file diff --git a/UnitTests/IncludeTest/GraphicsTools/TextureUploaderH_test.cpp b/UnitTests/IncludeTest/GraphicsTools/TextureUploaderH_test.cpp deleted file mode 100644 index dfc192be..00000000 --- a/UnitTests/IncludeTest/GraphicsTools/TextureUploaderH_test.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "DiligentCore/Graphics/GraphicsTools/include/TextureUploader.h" diff --git a/UnitTests/IncludeTest/Platforms/AtomicsH_test.cpp b/UnitTests/IncludeTest/Platforms/AtomicsH_test.cpp deleted file mode 100644 index 03493fce..00000000 --- a/UnitTests/IncludeTest/Platforms/AtomicsH_test.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "DiligentCore/Platforms/interface/Atomics.h" diff --git a/UnitTests/IncludeTest/Platforms/FileSystemH_test.cpp b/UnitTests/IncludeTest/Platforms/FileSystemH_test.cpp deleted file mode 100644 index 4c615712..00000000 --- a/UnitTests/IncludeTest/Platforms/FileSystemH_test.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "DiligentCore/Platforms/interface/FileSystem.h" diff --git a/UnitTests/IncludeTest/Platforms/PlatformDebugH_test.cpp b/UnitTests/IncludeTest/Platforms/PlatformDebugH_test.cpp deleted file mode 100644 index 6a561070..00000000 --- a/UnitTests/IncludeTest/Platforms/PlatformDebugH_test.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "DiligentCore/Platforms/interface/PlatformDebug.h" diff --git a/UnitTests/IncludeTest/Platforms/PlatformDefinitionsH_test.cpp b/UnitTests/IncludeTest/Platforms/PlatformDefinitionsH_test.cpp deleted file mode 100644 index 148fa5e3..00000000 --- a/UnitTests/IncludeTest/Platforms/PlatformDefinitionsH_test.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "DiligentCore/Platforms/interface/PlatformDefinitions.h" diff --git a/UnitTests/IncludeTest/Platforms/PlatformMiscH_test.cpp b/UnitTests/IncludeTest/Platforms/PlatformMiscH_test.cpp deleted file mode 100644 index 654b5e88..00000000 --- a/UnitTests/IncludeTest/Platforms/PlatformMiscH_test.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2019 Diligent Graphics LLC - * - * 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 - * - * 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 OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent 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 - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#include "DiligentCore/Platforms/interface/PlatformMisc.h" -- cgit v1.2.3