diff options
| author | assiduous <assiduous@diligentgraphics.com> | 2019-12-25 03:23:32 +0000 |
|---|---|---|
| committer | assiduous <assiduous@diligentgraphics.com> | 2019-12-25 03:23:32 +0000 |
| commit | 040e4cb7e454d532d249d2a5de6f2aba0c902baa (patch) | |
| tree | c89a3a009e2d145c3c3cfdb053ad7392eedf6d98 /Tests/TestApp/src | |
| parent | Added codacy bages (diff) | |
| download | DiligentEngine-040e4cb7e454d532d249d2a5de6f2aba0c902baa.tar.gz DiligentEngine-040e4cb7e454d532d249d2a5de6f2aba0c902baa.zip | |
Updated submodules; removed tests folder (tests are now part of every submodule)
Diffstat (limited to 'Tests/TestApp/src')
| -rw-r--r-- | Tests/TestApp/src/Android/TestAppAndroid.cpp | 76 | ||||
| -rw-r--r-- | Tests/TestApp/src/CMakeLists.txt | 143 | ||||
| -rw-r--r-- | Tests/TestApp/src/IOS/TestAppIOS.cpp | 53 | ||||
| -rw-r--r-- | Tests/TestApp/src/Linux/TestAppLinux.cpp | 64 | ||||
| -rw-r--r-- | Tests/TestApp/src/MacOS/TestAppMacOS.cpp | 51 | ||||
| -rw-r--r-- | Tests/TestApp/src/TestApp.cpp | 588 | ||||
| -rw-r--r-- | Tests/TestApp/src/TestBufferAccess.cpp | 277 | ||||
| -rw-r--r-- | Tests/TestApp/src/TestComputeShaders.cpp | 64 | ||||
| -rw-r--r-- | Tests/TestApp/src/TestCopyTexData.cpp | 245 | ||||
| -rw-r--r-- | Tests/TestApp/src/TestDrawCommands.cpp | 918 | ||||
| -rw-r--r-- | Tests/TestApp/src/TestGeometryShader.cpp | 95 | ||||
| -rw-r--r-- | Tests/TestApp/src/TestRenderTarget.cpp | 68 | ||||
| -rw-r--r-- | Tests/TestApp/src/TestTessellation.cpp | 144 | ||||
| -rw-r--r-- | Tests/TestApp/src/TestTexturing.cpp | 316 | ||||
| -rw-r--r-- | Tests/TestApp/src/TestVPAndSR.cpp | 49 | ||||
| -rw-r--r-- | Tests/TestApp/src/UWP/TestAppUWP.cpp | 212 | ||||
| -rw-r--r-- | Tests/TestApp/src/UnitTestBase.cpp | 55 | ||||
| -rw-r--r-- | Tests/TestApp/src/Win32/TestAppWin32.cpp | 44 | ||||
| -rw-r--r-- | Tests/TestApp/src/pch.cpp | 31 |
19 files changed, 0 insertions, 3493 deletions
diff --git a/Tests/TestApp/src/Android/TestAppAndroid.cpp b/Tests/TestApp/src/Android/TestAppAndroid.cpp deleted file mode 100644 index 0563cab..0000000 --- a/Tests/TestApp/src/Android/TestAppAndroid.cpp +++ /dev/null @@ -1,76 +0,0 @@ -/* Copyright 2015-2018 Egor Yusov -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. -* -* In no event and under no legal theory, whether in tort (including negligence), -* contract, or otherwise, unless required by applicable law (such as deliberate -* and grossly negligent acts) or agreed to in writing, shall any Contributor be -* liable for any damages, including any direct, indirect, special, incidental, -* or consequential damages of any character arising as a result of this License or -* out of the use or inability to use the software (including but not limited to damages -* for loss of goodwill, work stoppage, computer failure or malfunction, or any and -* all other commercial damages or losses), even if such Contributor has been advised -* of the possibility of such damages. -*/ - -#include "AndroidFileSystem.h" -#include "EngineFactoryOpenGL.h" -#include "TestApp.h" -#include "RenderDeviceGLES.h" - -namespace Diligent -{ - -class TestAppAndroid final : public TestApp -{ -public: - TestAppAndroid() - { - m_DeviceType = DeviceType::OpenGLES; - } - - virtual void Initialize()override final - { - GetEngineFactoryOpenGL()->InitAndroidFileSystem(app_->activity, native_activity_class_name_.c_str()); - AndroidFileSystem::Init(app_->activity, native_activity_class_name_.c_str()); - TestApp::Initialize(); - InitializeDiligentEngine(app_->window); - m_RenderDeviceGLES = RefCntAutoPtr<IRenderDeviceGLES>(m_pDevice, IID_RenderDeviceGLES); - InitializeRenderers(); - } - - virtual int Resume(ANativeWindow* window)override final - { - return m_RenderDeviceGLES->Resume(window); - } - - virtual void TermDisplay()override final - { - // Tear down the EGL context currently associated with the display. - m_RenderDeviceGLES->Suspend(); - } - - virtual void TrimMemory()override final - { - LOGI( "Trimming memory" ); - m_RenderDeviceGLES->Invalidate(); - } - -private: - RefCntAutoPtr<IRenderDeviceGLES> m_RenderDeviceGLES; -}; - -NativeAppBase* CreateApplication() -{ - return new TestAppAndroid; -} - -} diff --git a/Tests/TestApp/src/CMakeLists.txt b/Tests/TestApp/src/CMakeLists.txt deleted file mode 100644 index 20fb0d0..0000000 --- a/Tests/TestApp/src/CMakeLists.txt +++ /dev/null @@ -1,143 +0,0 @@ -cmake_minimum_required (VERSION 3.6) - -project(TestApp) - -file(GLOB SOURCE LIST_DIRECTORIES false Src/*.cpp) -#set(SOURCE -# src/TestApp.cpp -#) - -set(INCLUDE - include/TestApp.h -) - -set(SHADERS) - -set(ASSETS) - -set(ALL_ASSETS ${ASSETS} ${SHADERS}) -add_target_platform_app(TestApp "${SOURCE}" "${INCLUDE}" "${ALL_ASSETS}") - -if(PLATFORM_WIN32) - set(WIN32_SOURCE src/Win32/TestAppWin32.cpp) - target_sources(TestApp PRIVATE ${WIN32_SOURCE}) - source_group("src\\Win32" FILES ${WIN32_SOURCE}) - - set_target_properties(TestApp PROPERTIES - VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/assets" - ) - copy_required_dlls(TestApp) - -elseif(PLATFORM_UNIVERSAL_WINDOWS) - - set(UWP_SOURCE - src/UWP/TestAppUWP.cpp - ) - target_sources(TestApp PRIVATE ${UWP_SOURCE}) - source_group("src\\UWP" FILES ${UWP_SOURCE}) - target_include_directories(${TestApp} PRIVATE src/UWP) - -elseif(PLATFORM_ANDROID) - set(ANDROID_SOURCE - src/Android/TestAppAndroid.cpp - ) - target_sources(TestApp PRIVATE ${ANDROID_SOURCE}) - source_group("src\\Android" FILES ${ANDROID_SOURCE}) -elseif(PLATFORM_LINUX) - set(LINUX_SOURCE - src/Linux/TestAppLinux.cpp - ) - target_sources(TestApp PRIVATE ${LINUX_SOURCE}) - source_group("src\\Linux" FILES ${LINUX_SOURCE}) -elseif(PLATFORM_MACOS) - - set(MAC_SOURCE - src/MacOS/TestAppMacOS.cpp - ) - target_sources(TestApp PRIVATE ${MAC_SOURCE}) - source_group("src\\McOS" FILES ${MAC_SOURCE}) - -elseif(PLATFORM_IOS) - set(IOS_SOURCE - src/IOS/TestAppIOS.cpp - ) - target_sources(TestApp PRIVATE ${IOS_SOURCE}) - source_group("src\\McOS" FILES ${IOS_SOURCE}) -endif() - -set_common_target_properties(TestApp) -target_include_directories(TestApp -PUBLIC - include -) - - -if(MSVC) - target_compile_options(TestApp PRIVATE -DUNICODE) - - if(PLATFORM_UNIVERSAL_WINDOWS) - # Disable w4189: local variable is initialized but not referenced - # Disable w4063: case is not a valid value for switch of enum - # Consume the windows runtime extensions (/ZW) - target_compile_options(TestApp INTERFACE /wd4189 /wd4063 /ZW) - endif() -endif() - -if(PLATFORM_WIN32) - SET(ENGINE_LIBRARIES - Diligent-GraphicsEngineD3D11-shared - Diligent-GraphicsEngineD3D12-shared - Diligent-GraphicsEngineOpenGL-shared - ) -elseif(PLATFORM_ANDROID) - SET(ENGINE_LIBRARIES - Diligent-GraphicsEngineOpenGL-shared - ) -elseif(PLATFORM_UNIVERSAL_WINDOWS) - SET(ENGINE_LIBRARIES - Diligent-GraphicsEngineD3D11-static - Diligent-GraphicsEngineD3D12-static - ) -elseif(PLATFORM_LINUX) - SET(ENGINE_LIBRARIES - Diligent-GraphicsEngineOpenGL-shared - ) -elseif(PLATFORM_MACOS) - SET(ENGINE_LIBRARIES - Diligent-GraphicsEngineOpenGL-shared - ) -elseif(PLATFORM_IOS) - SET(ENGINE_LIBRARIES - Diligent-GraphicsEngineOpenGL-static - ) -else() - message(FATAL_ERROR "Undefined platform") -endif() - -target_link_libraries(TestApp -PRIVATE - Diligent-BuildSettings -PUBLIC - NativeAppBase - Diligent-Common - Diligent-GraphicsTools - Diligent-TargetPlatform - ${ENGINE_LIBRARIES} -) - -if(PLATFORM_UNIVERSAL_WINDOWS) - target_link_libraries(TestApp PRIVATE dxguid.lib) -elseif(PLATFORM_ANDROID) - target_link_libraries(TestApp PRIVATE GLESv3 PUBLIC native_app_glue) -elseif(PLATFORM_LINUX) - target_link_libraries(TestApp PRIVATE GL X11) -elseif(PLATFORM_MACOS OR PLATFORM_IOS) - -endif() - -source_group("src" FILES ${SOURCE}) -source_group("include" FILES ${INCLUDE}) - -set_target_properties(TestApp PROPERTIES - FOLDER Tests -) diff --git a/Tests/TestApp/src/IOS/TestAppIOS.cpp b/Tests/TestApp/src/IOS/TestAppIOS.cpp deleted file mode 100644 index 2f1c44c..0000000 --- a/Tests/TestApp/src/IOS/TestAppIOS.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/* Copyright 2015-2018 Egor Yusov -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. -* -* In no event and under no legal theory, whether in tort (including negligence), -* contract, or otherwise, unless required by applicable law (such as deliberate -* and grossly negligent acts) or agreed to in writing, shall any Contributor be -* liable for any damages, including any direct, indirect, special, incidental, -* or consequential damages of any character arising as a result of this License or -* out of the use or inability to use the software (including but not limited to damages -* for loss of goodwill, work stoppage, computer failure or malfunction, or any and -* all other commercial damages or losses), even if such Contributor has been advised -* of the possibility of such damages. -*/ - -#include <queue> -#include "TestApp.h" - -namespace Diligent -{ - -class TestAppIOS final : public TestApp -{ -public: - TestAppIOS() - { - m_DeviceType = DeviceType::OpenGLES; - } - - virtual void Initialize(int deviceType, void* layer)override final - { - m_DeviceType = static_cast<Diligent::DeviceType>(deviceType); - InitializeDiligentEngine(layer); - InitializeRenderers(); - } - -private: -}; - -NativeAppBase* CreateApplication() -{ - return new TestAppIOS; -} - -} diff --git a/Tests/TestApp/src/Linux/TestAppLinux.cpp b/Tests/TestApp/src/Linux/TestAppLinux.cpp deleted file mode 100644 index 54abfa8..0000000 --- a/Tests/TestApp/src/Linux/TestAppLinux.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/* Copyright 2015-2018 Egor Yusov -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. -* -* In no event and under no legal theory, whether in tort (including negligence), -* contract, or otherwise, unless required by applicable law (such as deliberate -* and grossly negligent acts) or agreed to in writing, shall any Contributor be -* liable for any damages, including any direct, indirect, special, incidental, -* or consequential damages of any character arising as a result of this License or -* out of the use or inability to use the software (including but not limited to damages -* for loss of goodwill, work stoppage, computer failure or malfunction, or any and -* all other commercial damages or losses), even if such Contributor has been advised -* of the possibility of such damages. -*/ - -#include "TestApp.h" - -namespace Diligent -{ - -class TestAppLinux final : public TestApp -{ -public: - TestAppLinux() - { - m_DeviceType = DeviceType::OpenGL; - } - - virtual void OnGLContextCreated(Display* display, Window window)override final - { - InitializeDiligentEngine(display, reinterpret_cast<void*>(static_cast<size_t>(window))); - InitializeRenderers(); - } - -#if VULKAN_SUPPORTED - virtual bool InitVulkan(xcb_connection_t* connection, uint32_t window)override final - { - m_DeviceType = DeviceType::Vulkan; - struct XCBInfo - { - xcb_connection_t* connection; - uint32_t window; - }xcbInfo = {connection, window}; - InitializeDiligentEngine(nullptr, &xcbInfo); - InitializeRenderers(); - return true; - } -#endif -}; - -NativeAppBase* CreateApplication() -{ - return new TestAppLinux; -} - -} diff --git a/Tests/TestApp/src/MacOS/TestAppMacOS.cpp b/Tests/TestApp/src/MacOS/TestAppMacOS.cpp deleted file mode 100644 index 3542251..0000000 --- a/Tests/TestApp/src/MacOS/TestAppMacOS.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/* Copyright 2015-2019 Egor Yusov -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. -* -* In no event and under no legal theory, whether in tort (including negligence), -* contract, or otherwise, unless required by applicable law (such as deliberate -* and grossly negligent acts) or agreed to in writing, shall any Contributor be -* liable for any damages, including any direct, indirect, special, incidental, -* or consequential damages of any character arising as a result of this License or -* out of the use or inability to use the software (including but not limited to damages -* for loss of goodwill, work stoppage, computer failure or malfunction, or any and -* all other commercial damages or losses), even if such Contributor has been advised -* of the possibility of such damages. -*/ - -#include <queue> -#include "TestApp.h" - -namespace Diligent -{ - -class TestAppMacOS final : public TestApp -{ -public: - TestAppMacOS() - { - m_DeviceType = DeviceType::OpenGL; - } - - virtual void Initialize(void* view)override final - { - m_DeviceType = view == nullptr ? DeviceType::OpenGL : DeviceType::Vulkan; - InitializeDiligentEngine(view); - InitializeRenderers(); - } -}; - -NativeAppBase* CreateApplication() -{ - return new TestAppMacOS; -} - -} diff --git a/Tests/TestApp/src/TestApp.cpp b/Tests/TestApp/src/TestApp.cpp deleted file mode 100644 index 36d42e4..0000000 --- a/Tests/TestApp/src/TestApp.cpp +++ /dev/null @@ -1,588 +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 <sstream> -#include <math.h> -#include <iomanip> - -#include <cstdlib> - -#include "PlatformDefinitions.h" -#include "TestApp.h" -#include "Errors.h" -#include "StringTools.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 - -#include "FileSystem.h" -#include "MapHelper.h" -#include "Errors.h" -#include "TestVPAndSR.h" -#include "TestCopyTexData.h" -#include "PlatformMisc.h" -#include "StringTools.h" - -namespace Diligent -{ - -TestApp::TestApp() : - m_AppTitle("Test app") -{ -} - -TestApp::~TestApp() -{ -} - - -void TestApp::InitializeDiligentEngine( -#if PLATFORM_LINUX - void *display, -#endif - void *NativeWindowHandle - ) -{ - SwapChainDesc SCDesc; - Uint32 NumDeferredCtx = 0; - std::vector<IDeviceContext*> ppContexts; - std::vector<AdapterAttribs> Adapters; - std::vector<std::vector<DisplayModeAttribs>> AdapterDisplayModes; - switch (m_DeviceType) - { -#if D3D11_SUPPORTED - case DeviceType::D3D11: - { - EngineD3D11CreateInfo DeviceAttribs; -#if ENGINE_DLL - GetEngineFactoryD3D11Type GetEngineFactoryD3D11 = nullptr; - // Load the dll and import GetEngineFactoryD3D11() function - LoadGraphicsEngineD3D11(GetEngineFactoryD3D11); -#endif -#ifdef _DEBUG - DeviceAttribs.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()); - - for(Uint32 i=0; i < Adapters.size(); ++i) - { - Uint32 NumDisplayModes = 0; - std::vector<DisplayModeAttribs> DisplayModes; - 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()); - AdapterDisplayModes.emplace_back(std::move(DisplayModes)); - } - - DeviceAttribs.NumDeferredContexts = NumDeferredCtx; - ppContexts.resize(1 + NumDeferredCtx); - pFactoryD3D11->CreateDeviceAndContextsD3D11(DeviceAttribs, &m_pDevice, ppContexts.data()); - - if(NativeWindowHandle != nullptr) - pFactoryD3D11->CreateSwapChainD3D11(m_pDevice, ppContexts[0], SCDesc, FullScreenModeDesc{}, NativeWindowHandle, &m_pSwapChain); - } - break; -#endif - -#if D3D12_SUPPORTED - case DeviceType::D3D12: - { -#if ENGINE_DLL - GetEngineFactoryD3D12Type GetEngineFactoryD3D12 = nullptr; - // Load the dll and import GetEngineFactoryD3D12() function - LoadGraphicsEngineD3D12(GetEngineFactoryD3D12); -#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()); - - for (Uint32 i = 0; i < Adapters.size(); ++i) - { - Uint32 NumDisplayModes = 0; - std::vector<DisplayModeAttribs> DisplayModes; - 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()); - AdapterDisplayModes.emplace_back(std::move(DisplayModes)); - } - - EngineD3D12CreateInfo EngD3D12Attribs; - EngD3D12Attribs.EnableDebugLayer = true; - //EngD3D12Attribs.EnableGPUBasedValidation = true; - EngD3D12Attribs.CPUDescriptorHeapAllocationSize[0] = 64; // D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV - EngD3D12Attribs.CPUDescriptorHeapAllocationSize[1] = 32; // D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER - EngD3D12Attribs.CPUDescriptorHeapAllocationSize[2] = 16; // D3D12_DESCRIPTOR_HEAP_TYPE_RTV - EngD3D12Attribs.CPUDescriptorHeapAllocationSize[3] = 16; // D3D12_DESCRIPTOR_HEAP_TYPE_DSV - EngD3D12Attribs.DynamicDescriptorAllocationChunkSize[0] = 8; // D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV - EngD3D12Attribs.DynamicDescriptorAllocationChunkSize[1] = 8; // D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER - ppContexts.resize(1 + NumDeferredCtx); - - EngD3D12Attribs.NumDeferredContexts = NumDeferredCtx; - pFactoryD3D12->CreateDeviceAndContextsD3D12(EngD3D12Attribs, &m_pDevice, ppContexts.data()); - - if (!m_pSwapChain && NativeWindowHandle != nullptr) - pFactoryD3D12->CreateSwapChainD3D12(m_pDevice, ppContexts[0], SCDesc, FullScreenModeDesc{}, NativeWindowHandle, &m_pSwapChain); - } - break; -#endif - -#if GL_SUPPORTED || GLES_SUPPORTED - case DeviceType::OpenGL: - case DeviceType::OpenGLES: - { -#if !PLATFORM_MACOS - VERIFY_EXPR(NativeWindowHandle != nullptr); -#endif -#if EXPLICITLY_LOAD_ENGINE_GL_DLL - // Declare function pointer - GetEngineFactoryOpenGLType GetEngineFactoryOpenGL = nullptr; - // Load the dll and import GetEngineFactoryOpenGL() function - LoadGraphicsEngineOpenGL(GetEngineFactoryOpenGL); -#endif - auto* pFactoryOpenGL = GetEngineFactoryOpenGL(); - EngineGLCreateInfo CreationAttribs; - CreationAttribs.pNativeWndHandle = NativeWindowHandle; -#if PLATFORM_LINUX - CreationAttribs.pDisplay = display; -#endif - if (NumDeferredCtx != 0) - { - LOG_ERROR_MESSAGE("Deferred contexts are not supported in OpenGL mode"); - NumDeferredCtx = 0; - } - ppContexts.resize(1 + NumDeferredCtx); - pFactoryOpenGL->CreateDeviceAndSwapChainGL( - CreationAttribs, &m_pDevice, ppContexts.data(), SCDesc, &m_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); -#endif - EngineVkCreateInfo EngVkAttribs; - - EngVkAttribs.EnableValidation = true; - EngVkAttribs.MainDescriptorPoolSize = EngineVkCreateInfo::DescriptorPoolSize{ 64, 64, 256, 256, 64, 32, 32, 32, 32 }; - EngVkAttribs.DynamicDescriptorPoolSize = EngineVkCreateInfo::DescriptorPoolSize{ 64, 64, 256, 256, 64, 32, 32, 32, 32 }; - EngVkAttribs.UploadHeapPageSize = 32*1024; - //EngVkAttribs.DeviceLocalMemoryReserveSize = 32 << 20; - //EngVkAttribs.HostVisibleMemoryReserveSize = 48 << 20; - - auto& Features = EngVkAttribs.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; - - EngVkAttribs.NumDeferredContexts = NumDeferredCtx; - ppContexts.resize(1 + NumDeferredCtx); - auto* pFactoryVk = GetEngineFactoryVk(); - pFactoryVk->CreateDeviceAndContextsVk(EngVkAttribs, &m_pDevice, ppContexts.data()); - - if (!m_pSwapChain && NativeWindowHandle != nullptr) - pFactoryVk->CreateSwapChainVk(m_pDevice, ppContexts[0], SCDesc, NativeWindowHandle, &m_pSwapChain); - } - break; -#endif - -#if METAL_SUPPORTED - case DeviceType::Metal: - { - EngineMtlCreateInfo MtlAttribs; - - MtlAttribs.NumDeferredContexts = NumDeferredCtx; - ppContexts.resize(1 + NumDeferredCtx); - auto *pFactoryMtl = GetEngineFactoryMtl(); - pFactoryMtl->CreateDeviceAndContextsMtl(MtlAttribs, &m_pDevice, ppContexts.data()); - - if (!m_pSwapChain && NativeWindowHandle != nullptr) - pFactoryMtl->CreateSwapChainMtl(m_pDevice, ppContexts[0], SCDesc, NativeWindowHandle, &m_pSwapChain); - } - break; -#endif - - default: - LOG_ERROR_AND_THROW("Unknown device type"); - break; - } - - - std::stringstream ss; - ss << "Found " << Adapters.size() << " adapters:\n"; - for (Uint32 i = 0; i < Adapters.size(); ++i) - { - ss << Adapters[i].Description << " (" << (Adapters[i].DedicatedVideoMemory >> 20) << " MB). Num outputs: " << Adapters[i].NumOutputs << ". Display modes:\n"; - const auto &DisplayModes = AdapterDisplayModes[i]; - for(Uint32 m=0; m < DisplayModes.size(); ++m) - { - const auto &Mode = DisplayModes[m]; - float RefreshRate = (float)Mode.RefreshRateNumerator / (float)Mode.RefreshRateDenominator; - ss << " " << Mode.Width << 'x' << Mode.Height << " " << std::fixed << std::setprecision(2) << RefreshRate << " Hz\n"; - } - } - auto str = ss.str(); - LOG_INFO_MESSAGE(str); - - m_pImmediateContext.Attach(ppContexts[0]); - m_pDeferredContexts.resize(NumDeferredCtx); - for (Diligent::Uint32 ctx = 0; ctx < NumDeferredCtx; ++ctx) - m_pDeferredContexts[ctx].Attach(ppContexts[1 + ctx]); -} - -void TestApp::InitializeRenderers() -{ - m_TestGS.Init(m_pDevice, m_pImmediateContext, m_pSwapChain); - m_TestTessellation.Init(m_pDevice, m_pImmediateContext, m_pSwapChain); - - const auto* BackBufferFmt = m_pDevice->GetTextureFormatInfo(m_pSwapChain->GetDesc().ColorBufferFormat).Name; - const auto* DepthBufferFmt = m_pDevice->GetTextureFormatInfo(m_pSwapChain->GetDesc().DepthBufferFormat).Name; - - m_pTestDrawCommands.reset(new TestDrawCommands); - m_pTestDrawCommands->Init(m_pDevice, m_pImmediateContext, m_pSwapChain, 0, 0, 1, 1); - - m_pTestBufferAccess.reset(new TestBufferAccess); - m_pTestBufferAccess->Init(m_pDevice, m_pImmediateContext, m_pSwapChain, -1, 0, 0.5, 0.5); - - - TEXTURE_FORMAT TestFormats[16] = - { - TEX_FORMAT_RGBA8_UNORM, TEX_FORMAT_RGBA8_UNORM_SRGB, TEX_FORMAT_RGBA32_FLOAT, TEX_FORMAT_RGBA16_UINT, - TEX_FORMAT_RGBA8_SNORM, TEX_FORMAT_RGBA8_UINT, TEX_FORMAT_RG8_UNORM, TEX_FORMAT_RG8_UINT, - TEX_FORMAT_RG32_FLOAT, TEX_FORMAT_RG16_UINT, TEX_FORMAT_RG8_SNORM, TEX_FORMAT_R8_UNORM, - TEX_FORMAT_R32_FLOAT, TEX_FORMAT_R8_SNORM, TEX_FORMAT_R8_UINT, TEX_FORMAT_R16_UINT - }; - - for (int j = 0; j < 4; ++j) - for (int i = 0; i < 4; ++i) - { - auto Ind = i + j * 4; - m_pTestTexturing[Ind].reset(new TestTexturing); - m_pTestTexturing[Ind]->Init(m_pDevice, m_pImmediateContext, m_pSwapChain, TestFormats[Ind], -1 + (float)i*1.f / 4.f, -1 + (float)j*1.f / 4.f, 0.9f / 4.f, 0.9f / 4.f); - } - - TestCopyTexData TestCopyData(m_pDevice, m_pImmediateContext); - - TestVPAndSR TestVPAndSR(m_pDevice, m_pImmediateContext); - - m_pTestCS.reset(new TestComputeShaders); - m_pTestCS->Init(m_pDevice, m_pImmediateContext, m_pSwapChain); - - m_pTestRT.reset(new TestRenderTarget); - m_pTestRT->Init(m_pDevice, m_pImmediateContext, m_pSwapChain, -0.4f, 0.55f, 0.4f, 0.4f); - - float instance_offsets[] = { -0.3f, 0.0f, 0.0f, 0.0f, +0.3f, -0.3f }; - - { - Diligent::BufferDesc BuffDesc; - BuffDesc.Name = "cbTestBlock2"; - float UniformData[16] = { 1,1,1,1 }; - BuffDesc.uiSizeInBytes = sizeof(UniformData); - BuffDesc.BindFlags = BIND_UNIFORM_BUFFER; - BuffDesc.Usage = USAGE_DYNAMIC; - BuffDesc.CPUAccessFlags = CPU_ACCESS_WRITE; - m_pDevice->CreateBuffer(BuffDesc, nullptr, &m_pUniformBuff2); - } - - { - Diligent::BufferDesc BuffDesc; - BuffDesc.Name = "Test Constant Buffer 3"; - float UniformData[16] = { 1, 1, 1, 1 }; - BuffDesc.uiSizeInBytes = sizeof(UniformData); - BuffDesc.BindFlags = BIND_UNIFORM_BUFFER; - BuffDesc.Usage = USAGE_DEFAULT; - BuffDesc.CPUAccessFlags = CPU_ACCESS_NONE; - Diligent::BufferData BuffData; - BuffData.pData = UniformData; - BuffData.DataSize = sizeof(UniformData); - m_pDevice->CreateBuffer(BuffDesc, &BuffData, &m_pUniformBuff3); - } - - { - Diligent::BufferDesc BuffDesc; - BuffDesc.Name = "Test Constant Buffer 4"; - float UniformData[16] = { 1, 1, 1, 1 }; - BuffDesc.uiSizeInBytes = sizeof(UniformData); - BuffDesc.BindFlags = BIND_UNIFORM_BUFFER; - BuffDesc.Usage = USAGE_DEFAULT; - BuffDesc.CPUAccessFlags = CPU_ACCESS_NONE; - Diligent::BufferData BuffData; - BuffData.pData = UniformData; - BuffData.DataSize = sizeof(UniformData); - m_pDevice->CreateBuffer(BuffDesc, &BuffData, &m_pUniformBuff4); - } - - { - TextureDesc TexDesc; - TexDesc.Type = RESOURCE_DIM_TEX_2D; - TexDesc.Width = 1024; - TexDesc.Height = 1024; - TexDesc.Format = TEX_FORMAT_RGBA8_UNORM; - TexDesc.Usage = USAGE_DEFAULT; - TexDesc.BindFlags = BIND_SHADER_RESOURCE | BIND_RENDER_TARGET | BIND_UNORDERED_ACCESS; - TexDesc.Name = "UniqueTexture"; - - m_pDevice->CreateTexture(TexDesc, nullptr, &m_pTestTex); - - m_pTestTex.Release(); - m_pDevice->CreateTexture(TexDesc, nullptr, &m_pTestTex); - } - - { - m_pImmediateContext->Flush(); - // This is a test for possible bug in D3D12 - TextureDesc TexDesc; - TexDesc.Type = RESOURCE_DIM_TEX_2D; - TexDesc.Width = 512; - TexDesc.Height = 512; - TexDesc.Format = m_pSwapChain->GetDesc().ColorBufferFormat; - TexDesc.Usage = USAGE_DEFAULT; - TexDesc.BindFlags = BIND_SHADER_RESOURCE | BIND_RENDER_TARGET; - TexDesc.Name = "UniqueTexture"; - RefCntAutoPtr<ITexture> pTex; - m_pDevice->CreateTexture(TexDesc, nullptr, &pTex); - ITextureView *pRTVs[] = { pTex->GetDefaultView(TEXTURE_VIEW_RENDER_TARGET) }; - - TexDesc.Format = m_pSwapChain->GetDesc().DepthBufferFormat; - RefCntAutoPtr<ITexture> pDepthTex; - TexDesc.BindFlags = BIND_DEPTH_STENCIL; - m_pDevice->CreateTexture(TexDesc, nullptr, &pDepthTex); - auto* pDSV = pDepthTex->GetDefaultView(TEXTURE_VIEW_DEPTH_STENCIL); - - { - MapHelper<float> UniformData(m_pImmediateContext, m_pUniformBuff2, MAP_WRITE, MAP_FLAG_DISCARD); - UniformData[0] = (float)sin(0)*0.1f; - UniformData[1] = (float)cos(0)*0.1f; - UniformData[2] = (float)sin(0)*0.1f; - UniformData[3] = 0; - } - - m_pImmediateContext->SetRenderTargets(0, nullptr, nullptr, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); - float ClearColor[] = {0.1f, 0.2f, 0.4f, 1.0f}; - m_pImmediateContext->ClearRenderTarget(nullptr, ClearColor, RESOURCE_STATE_TRANSITION_MODE_VERIFY); - - // This adds transition barrier for pTex1 - m_pImmediateContext->SetRenderTargets(1, pRTVs, pDSV, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); - m_pImmediateContext->ClearRenderTarget(pRTVs[0], ClearColor, RESOURCE_STATE_TRANSITION_MODE_VERIFY); - m_pImmediateContext->ClearDepthStencil(pDSV, CLEAR_DEPTH_FLAG, 1, 0, RESOURCE_STATE_TRANSITION_MODE_VERIFY); - // Generate draw command to the bound render target - m_pImmediateContext->SetRenderTargets(0, nullptr, nullptr, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); - // This will destroy texture and put D3D12 resource into release queue - pTex.Release(); - - - Diligent::BufferDesc BuffDesc; - BuffDesc.Name = "cbTestBlock2"; - float Data[16] = { 1,1,1,1 }; - BuffDesc.uiSizeInBytes = sizeof(Data); - BuffDesc.BindFlags = BIND_UNIFORM_BUFFER; - BuffDesc.Usage = USAGE_DEFAULT; - BuffDesc.CPUAccessFlags = CPU_ACCESS_NONE; - Diligent::BufferData BuffData; - BuffData.pData = Data; - BuffData.DataSize = sizeof(Data); - // This will result in creating and executing another command list - RefCntAutoPtr<IBuffer> pBuff; - m_pDevice->CreateBuffer(BuffDesc, &BuffData, &pBuff); - - // This may cause D3D12 error - m_pImmediateContext->Flush(); - } - - { - FenceDesc fenceDesc; - fenceDesc.Name = "Test fence"; - m_pDevice->CreateFence(fenceDesc, &m_pFence); - } -} - -void TestApp::ProcessCommandLine(const char *CmdLine) -{ - const auto* Key = "-mode "; - const auto *pos = strstr(CmdLine, Key); - if (pos != nullptr) - { - pos += strlen(Key); - if (_stricmp(pos, "D3D11") == 0) - { - m_DeviceType = DeviceType::D3D11; - } - else if (_stricmp(pos, "D3D12") == 0) - { - m_DeviceType = DeviceType::D3D12; - } - else if (_stricmp(pos, "GL") == 0) - { - m_DeviceType = DeviceType::OpenGL; - } - else if (_stricmp(pos, "VK") == 0) - { - m_DeviceType = DeviceType::Vulkan; - } - else - { - LOG_ERROR_AND_THROW("Unknown device type. Only the following types are supported: D3D11, D3D12, GL, VK"); - } - } - else - { -#if D3D12_SUPPORTED - m_DeviceType = DeviceType::D3D12; -#elif VULKAN_SUPPORTED - m_DeviceType = DeviceType::Vulkan; -#elif D3D11_SUPPORTED - m_DeviceType = DeviceType::D3D11; -#elif GL_SUPPORTED || GLES_SUPPORTED - m_DeviceType = DeviceType::OpenGL; -#endif - } - - switch (m_DeviceType) - { - case DeviceType::D3D11: m_AppTitle.append(" (D3D11)"); break; - case DeviceType::D3D12: m_AppTitle.append(" (D3D12)"); break; - case DeviceType::OpenGL: m_AppTitle.append(" (OpenGL)"); break; - case DeviceType::Vulkan: m_AppTitle.append(" (Vulkan)"); break; - default: UNEXPECTED("Unknown device type"); - } -} - -void TestApp::WindowResize(int width, int height) -{ - if (m_pSwapChain) - { - m_pSwapChain->Resize(width, height); - //auto SCWidth = m_pSwapChain->GetDesc().Width; - //auto SCHeight = m_pSwapChain->GetDesc().Height; - - - } -} - -void TestApp::Update(double CurrTime, double ElapsedTime) -{ - m_CurrTime = CurrTime; -} - -void TestApp::Render() -{ - m_pImmediateContext->SetRenderTargets(0, nullptr, nullptr, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); - float ClearColor[] = {0.1f, 0.2f, 0.4f, 1.0f}; - m_pImmediateContext->ClearRenderTarget(nullptr, ClearColor, RESOURCE_STATE_TRANSITION_MODE_VERIFY); - m_pImmediateContext->ClearDepthStencil(nullptr, CLEAR_DEPTH_FLAG, 1.f, 0, RESOURCE_STATE_TRANSITION_MODE_VERIFY); - - double dCurrTime = m_CurrTime; - - - m_pTestDrawCommands->Draw(); - m_pTestBufferAccess->Draw((float)dCurrTime); - - for (int i = 0; i<_countof(m_pTestTexturing); ++i) - { - m_pTestTexturing[i]->Draw(); - } - m_pTestCS->Draw(); - m_pTestRT->Draw(); - m_TestGS.Draw(); - - auto CompletedFenceValue = m_pFence->GetCompletedValue(); - VERIFY_EXPR(CompletedFenceValue < m_NextFenceValue); - m_pImmediateContext->SignalFence(m_pFence, m_NextFenceValue++); - - CompletedFenceValue = m_pFence->GetCompletedValue(); - VERIFY_EXPR(CompletedFenceValue < m_NextFenceValue); - - if (rand() % 10 == 0) - { - if (rand() % 2 == 0) - { - m_pImmediateContext->Flush(); - m_pImmediateContext->SignalFence(m_pFence, m_NextFenceValue++); - } - - m_pImmediateContext->WaitForFence(m_pFence, m_NextFenceValue-1, true); - CompletedFenceValue = m_pFence->GetCompletedValue(); - VERIFY_EXPR(CompletedFenceValue >= m_NextFenceValue-1); - } - - if (rand() % 30 == 0) - { - m_pImmediateContext->WaitForIdle(); - } - - if (rand() % 60 == 0) - { - m_pDevice->IdleGPU(); - } - - m_TestTessellation.Draw(); - - m_pImmediateContext->Flush(); - m_pImmediateContext->InvalidateState(); -} - -void TestApp::Present() -{ - m_pSwapChain->Present(0); -} - -} diff --git a/Tests/TestApp/src/TestBufferAccess.cpp b/Tests/TestApp/src/TestBufferAccess.cpp deleted file mode 100644 index 6e139f9..0000000 --- a/Tests/TestApp/src/TestBufferAccess.cpp +++ /dev/null @@ -1,277 +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 "pch.h" -#include <math.h> -#include "TestBufferAccess.h" -#include "MapHelper.h" - -using namespace Diligent; - -TestBufferAccess::TestBufferAccess() : - UnitTestBase("Buffer access test"), - m_fXExtent(0), - m_fYExtent(0) -{} - -void TestBufferAccess::Init( IRenderDevice *pDevice, IDeviceContext *pContext, ISwapChain *pSwapChain, float fMinXCoord, float fMinYCoord, float fXExtent, float fYExtent ) -{ - m_pRenderDevice = pDevice; - m_pDeviceContext = pContext; - auto DevType = m_pRenderDevice->GetDeviceCaps().DevType; - bool bUseGLSL = DevType == DeviceType::OpenGL || DevType == DeviceType::OpenGLES || DevType == DeviceType::Vulkan; - - m_fXExtent = fXExtent; - m_fYExtent = fYExtent; - - float vertices[] = { 0.0f,0.0f,0.0f, 0.5f, 0.9f, 0.1f, - 0.5f,1.f,0.0f, 0.9f, 0.3f, 0.7f, - 1.f,0.0f,0.0f, 0.2f, 0.4f, 0.9f }; - for(int iVert=0; iVert < 3; ++iVert) - { - vertices[iVert*6] = (vertices[iVert*6]) / (float)(NumRows+1) * fXExtent + fMinXCoord; - vertices[iVert*6+1] = (vertices[iVert*6+1]) / (float)(NumRows+1) * fYExtent + fMinYCoord; - } - - { - Diligent::BufferDesc BuffDesc; - BuffDesc.uiSizeInBytes = sizeof(vertices); - BuffDesc.BindFlags = BIND_VERTEX_BUFFER; - Diligent::BufferData BuffData; - BuffData.pData = vertices; - BuffData.DataSize = BuffDesc.uiSizeInBytes; - m_pRenderDevice->CreateBuffer(BuffDesc, &BuffData, &m_pVertexBuff); - } - - for(int InstBuff = 0; InstBuff < _countof(m_pInstBuff); ++InstBuff) - { - float instance_offsets[NumInstances*2] = - { - 1.f * fXExtent / (float)(NumRows+1), InstBuff*fYExtent / (float)(NumRows+1), - 2.f * fXExtent / (float)(NumRows+1), InstBuff*fYExtent / (float)(NumRows+1), - 3.f * fXExtent / (float)(NumRows+1), InstBuff*fYExtent / (float)(NumRows+1), - }; - - Diligent::BufferDesc BuffDesc; - BuffDesc.uiSizeInBytes = sizeof(instance_offsets); - BuffDesc.BindFlags = BIND_VERTEX_BUFFER; - if( InstBuff == 3 ) - { - BuffDesc.Usage = USAGE_DYNAMIC; - BuffDesc.CPUAccessFlags = CPU_ACCESS_WRITE; - } - else if( InstBuff == 4 ) - { - BuffDesc.Usage = USAGE_STAGING; - BuffDesc.BindFlags = BIND_NONE; - BuffDesc.CPUAccessFlags = CPU_ACCESS_READ; - } - else if( InstBuff == 5 ) - { - BuffDesc.Usage = USAGE_STAGING; - BuffDesc.BindFlags = BIND_NONE; - BuffDesc.CPUAccessFlags = CPU_ACCESS_WRITE; - } - else if( InstBuff == 6 ) - { - BuffDesc.Usage = USAGE_STAGING; - BuffDesc.BindFlags = BIND_NONE; - BuffDesc.CPUAccessFlags = CPU_ACCESS_READ; - } - - Diligent::BufferData BuffData; - if(BuffDesc.Usage != USAGE_DYNAMIC && !(BuffDesc.Usage == USAGE_STAGING && (BuffDesc.CPUAccessFlags & CPU_ACCESS_WRITE) != 0)) - { - BuffData.pData = instance_offsets; - BuffData.DataSize = sizeof(instance_offsets); - } - m_pRenderDevice->CreateBuffer(BuffDesc, &BuffData, &m_pInstBuff[InstBuff]); - } - - ShaderCreateInfo CreationAttrs; - RefCntAutoPtr<IShaderSourceInputStreamFactory> pShaderSourceFactory; - pDevice->GetEngineFactory()->CreateDefaultShaderSourceStreamFactory(nullptr, &pShaderSourceFactory); - CreationAttrs.pShaderSourceStreamFactory = pShaderSourceFactory; - CreationAttrs.UseCombinedTextureSamplers = true; - - RefCntAutoPtr<Diligent::IShader> pVSInst, pPS; - - { - CreationAttrs.FilePath = bUseGLSL ? "Shaders\\minimalInstGL.vsh" : "Shaders\\minimalInstDX.vsh"; - CreationAttrs.Desc.ShaderType = SHADER_TYPE_VERTEX; - m_pRenderDevice->CreateShader( CreationAttrs, &pVSInst ); - } - - { - CreationAttrs.FilePath = bUseGLSL ? "Shaders\\minimalGL.psh" : "Shaders\\minimalDX.psh"; - CreationAttrs.Desc.ShaderType = SHADER_TYPE_PIXEL; - m_pRenderDevice->CreateShader( CreationAttrs, &pPS ); - } - - - PipelineStateDesc PSODesc; - PSODesc.Name = "Test buffer access PSO"; - 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; - PSODesc.GraphicsPipeline.RTVFormats[0] = pSwapChain->GetDesc().ColorBufferFormat; - PSODesc.GraphicsPipeline.DSVFormat = pSwapChain->GetDesc().DepthBufferFormat; - PSODesc.GraphicsPipeline.pVS = pVSInst; - PSODesc.GraphicsPipeline.pPS = pPS; - - LayoutElement Elems[] = - { - LayoutElement{ 1, 1, 3, Diligent::VT_FLOAT32, false, sizeof(float) * 3, sizeof(float) * 6 }, - LayoutElement{ 0, 1, 3, Diligent::VT_FLOAT32, false, 0, sizeof(float) * 6 }, - LayoutElement{ 2, 3, 2, Diligent::VT_FLOAT32, false, LayoutElement::AutoOffset, LayoutElement::AutoStride, LayoutElement::FREQUENCY_PER_INSTANCE } - }; - PSODesc.GraphicsPipeline.InputLayout.LayoutElements = Elems; - PSODesc.GraphicsPipeline.InputLayout.NumElements = _countof( Elems ); - PSODesc.GraphicsPipeline.PrimitiveTopology = PRIMITIVE_TOPOLOGY_TRIANGLE_LIST; - pDevice->CreatePipelineState(PSODesc, &m_pPSO); -} - -void TestBufferAccess::Draw(float fTime) -{ - m_pDeviceContext->SetPipelineState(m_pPSO); - // No shader resources needed - //m_pDeviceContext->TransitionShaderResources(m_pPSO, nullptr); - //m_pDeviceContext->CommitShaderResources(nullptr); - - IBuffer *pBuffs[] = {nullptr, m_pVertexBuff, nullptr, m_pInstBuff[0], nullptr}; - Uint32 Offsets[_countof( pBuffs )] = {0, 0, 0, 0, 0}; - m_pDeviceContext->SetVertexBuffers( 0, _countof( pBuffs ), pBuffs, Offsets, RESOURCE_STATE_TRANSITION_MODE_TRANSITION, SET_VERTEX_BUFFERS_FLAG_RESET ); - - DrawAttribs DrawAttrs(3, DRAW_FLAG_VERIFY_ALL); - DrawAttrs.NumVertices = 3; - DrawAttrs.NumInstances = NumInstances; - m_pDeviceContext->Draw(DrawAttrs); - - - float fDX = m_fXExtent / (float)(NumRows+1); - float fDY = m_fYExtent / (float)(NumRows+1); - - float instance_offsets[NumInstances*2]; - for(int Inst = 0; Inst < NumInstances; ++Inst) - { - instance_offsets[Inst*2] = (1+Inst) * fDX; - instance_offsets[Inst*2+1] = 1.f * fDY + sin(fTime) * fDY * 0.3f; - } - m_pDeviceContext->UpdateBuffer(m_pInstBuff[1], sizeof( float ) * 2, sizeof( float ) * 4, &instance_offsets[2], RESOURCE_STATE_TRANSITION_MODE_TRANSITION ); - - pBuffs[3] = m_pInstBuff[1]; - m_pDeviceContext->SetVertexBuffers( 0, _countof( pBuffs ), pBuffs, Offsets, RESOURCE_STATE_TRANSITION_MODE_TRANSITION, SET_VERTEX_BUFFERS_FLAG_RESET ); - - m_pDeviceContext->Draw(DrawAttrs); - - - for(int Inst = 0; Inst < NumInstances; ++Inst) - { - instance_offsets[Inst*2] = (1+Inst) * fDX; - instance_offsets[Inst*2+1] = 2.f * fDY + sin(fTime*0.8f) * fDY * 0.3f; - } - m_pDeviceContext->UpdateBuffer(m_pInstBuff[2], sizeof( float ) * 2, sizeof( float ) * 4, &instance_offsets[2], RESOURCE_STATE_TRANSITION_MODE_TRANSITION ); - m_pDeviceContext->CopyBuffer(m_pInstBuff[2], sizeof( float ) * 2, RESOURCE_STATE_TRANSITION_MODE_TRANSITION, m_pInstBuff[1], sizeof( float ) * 2, sizeof( float ) * 4, RESOURCE_STATE_TRANSITION_MODE_TRANSITION ); - StateTransitionDesc Barrier(m_pInstBuff[1], RESOURCE_STATE_UNKNOWN, RESOURCE_STATE_VERTEX_BUFFER, true); - m_pDeviceContext->TransitionResourceStates(1, &Barrier); - m_pDeviceContext->Draw(DrawAttrs); - - for(int Inst = 0; Inst < NumInstances; ++Inst) - { - instance_offsets[Inst*2] = (1+Inst) * fDX; - instance_offsets[Inst*2+1] = 3.f * fDY + sin(fTime*1.2f) * fDY * 0.3f; - } - - // Test updating dynamic buffer - { - MapHelper<float> pInstData( m_pDeviceContext, m_pInstBuff[3], MAP_WRITE, MAP_FLAG_DISCARD ); - memcpy(pInstData, instance_offsets, sizeof(instance_offsets)); - } - - pBuffs[3] = m_pInstBuff[3]; - m_pDeviceContext->SetVertexBuffers( 0, _countof( pBuffs ), pBuffs, Offsets, RESOURCE_STATE_TRANSITION_MODE_TRANSITION, SET_VERTEX_BUFFERS_FLAG_RESET ); - - m_pDeviceContext->Draw(DrawAttrs); - - bool TestStagingBuffers = false; - if(TestStagingBuffers) - { - MapHelper<float> pStagingData; - // Test reading data from staging resource - { - m_pDeviceContext->CopyBuffer(m_pInstBuff[3], 0, RESOURCE_STATE_TRANSITION_MODE_TRANSITION, m_pInstBuff[4], 0, sizeof( instance_offsets ), RESOURCE_STATE_TRANSITION_MODE_TRANSITION ); - pStagingData.Map( m_pDeviceContext, m_pInstBuff[4], MAP_READ, MAP_FLAG_NONE ); - for(int i = 0; i < _countof(instance_offsets); ++i) - assert(pStagingData[i] == instance_offsets[i]); - pStagingData.Unmap(); - } - - // D3D12 does not allow writing to the CPU-readable buffers - if(m_pRenderDevice->GetDeviceCaps().DevType != DeviceType::D3D12) - { - // Test writing data to staging resource - { - pStagingData.Map( m_pDeviceContext, m_pInstBuff[5], MAP_WRITE, MAP_FLAG_NONE ); - for(int Inst = 0; Inst < NumInstances; ++Inst) - { - pStagingData[Inst*2] = (1+Inst) * fDX; - pStagingData[Inst*2+1] = 4.f * fDY + sin(fTime*1.3f) * fDY * 0.3f; - } - pStagingData.Unmap(); - } - - StateTransitionDesc Barriers[2] = - { - StateTransitionDesc{m_pInstBuff[5], RESOURCE_STATE_UNKNOWN, RESOURCE_STATE_COPY_SOURCE, true}, - StateTransitionDesc{m_pInstBuff[2], RESOURCE_STATE_UNKNOWN, RESOURCE_STATE_COPY_DEST, true}, - }; - m_pDeviceContext->TransitionResourceStates(2, Barriers); - m_pDeviceContext->CopyBuffer(m_pInstBuff[5], 0, RESOURCE_STATE_TRANSITION_MODE_VERIFY, m_pInstBuff[2], 0, sizeof( instance_offsets ), RESOURCE_STATE_TRANSITION_MODE_VERIFY ); - pBuffs[3] = m_pInstBuff[2]; - m_pDeviceContext->SetVertexBuffers( 0, _countof( pBuffs ), pBuffs, Offsets, RESOURCE_STATE_TRANSITION_MODE_TRANSITION, SET_VERTEX_BUFFERS_FLAG_RESET ); - m_pDeviceContext->Draw(DrawAttrs); - - - // Test reading & writing data to the staging resource - /*{ - MapHelper<float> pInstData2( m_pDeviceContext, m_pInstBuff[6], MAP_READ_WRITE, 0 ); - MapHelper<float> pInstData3( std::move(pInstData2) ); - MapHelper<float> pInstData; - pInstData = std::move(pInstData3); - static float fPrevTime = fTime; - for(int Inst = 0; Inst < NumInstances; ++Inst) - { - pInstData[Inst*2] += (fTime-fPrevTime) * sin(fTime)*0.1f * m_fXExtent; - } - fPrevTime = fTime; - }*/ - - m_pDeviceContext->CopyBuffer(m_pInstBuff[6], 0, RESOURCE_STATE_TRANSITION_MODE_TRANSITION, m_pInstBuff[2], 0, sizeof( instance_offsets ), RESOURCE_STATE_TRANSITION_MODE_TRANSITION ); - m_pDeviceContext->Draw(DrawAttrs); - } - } - - SetStatus(TestResult::Succeeded); -} diff --git a/Tests/TestApp/src/TestComputeShaders.cpp b/Tests/TestApp/src/TestComputeShaders.cpp deleted file mode 100644 index 30a3023..0000000 --- a/Tests/TestApp/src/TestComputeShaders.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 "pch.h" -#include "TestComputeShaders.h" -#include "GraphicsUtilities.h" - -using namespace Diligent; - -TestComputeShaders::TestComputeShaders() : - UnitTestBase("Compute shader test") -{ -} - -void TestComputeShaders::Init( IRenderDevice *pDevice, IDeviceContext *pContext, ISwapChain *pSwapChain ) -{ - if(!pDevice->GetDeviceCaps().bComputeShadersSupported) - { - SetStatus(TestResult::Skipped, "Compute shaders are not supported"); - return; - } -#if 0 - m_pRenderDevice = pDevice; - m_pDeviceContext = pContext; - const auto* BackBufferFmt = pDevice->GetTextureFormatInfo(pSwapChain->GetDesc().ColorBufferFormat).Name; - const auto* DepthBufferFmt = pDevice->GetTextureFormatInfo(pSwapChain->GetDesc().DepthBufferFormat).Name; - m_pRenderScript = CreateRenderScriptFromFile( "TestComputeShaders.lua", pDevice, pContext, [BackBufferFmt, DepthBufferFmt]( ScriptParser *pScriptParser ) - { - pScriptParser->SetGlobalVariable( "extBackBufferFormat", BackBufferFmt ); - pScriptParser->SetGlobalVariable( "extDepthBufferFormat", DepthBufferFmt ); - } ); -#endif -} - -void TestComputeShaders::Draw() -{ -#if 0 - if(!m_pDeviceContext) - return; - - m_pRenderScript->Run( m_pDeviceContext, "Render" ); - SetStatus(TestResult::Succeeded); -#endif -} diff --git a/Tests/TestApp/src/TestCopyTexData.cpp b/Tests/TestApp/src/TestCopyTexData.cpp deleted file mode 100644 index ffe3748..0000000 --- a/Tests/TestApp/src/TestCopyTexData.cpp +++ /dev/null @@ -1,245 +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 "pch.h" -#include "TestCopyTexData.h" -#include "RenderDevice.h" -#include "GraphicsUtilities.h" -#include "Errors.h" - -using namespace Diligent; - -TestCopyTexData::TestCopyTexData( IRenderDevice *pDevice, IDeviceContext *pContext ) : - UnitTestBase("Texture data copy test"), - m_pDevice(pDevice), - m_pContext(pContext) -{ - 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 - }; - int NumFormatsTested = 0; - for( auto f = 0; f < _countof( TestFormats ); ++f ) - { - Test2DTexture(TestFormats[f]); - Test2DTexArray(TestFormats[f]); - Test3DTexture(TestFormats[f]); - ++NumFormatsTested; - } - std::stringstream infoss; - infoss << "Formats tested: " << NumFormatsTested; - SetStatus(TestResult::Succeeded, infoss.str().c_str()); -} - -void TestCopyTexData::Test2DTexture( TEXTURE_FORMAT Format ) -{ - 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<ITexture> pSrcTex, pDstTex; - auto FmtAttribs = m_pDevice->GetTextureFormatInfo(Format); - auto TexelSize = Uint32{FmtAttribs.ComponentSize} * Uint32{FmtAttribs.NumComponents}; - std::vector<uint8_t> DummyData(size_t{TexDesc.Width} * size_t{TexDesc.Height} * size_t{TexelSize}); - TextureData InitData; - InitData.NumSubresources = TexDesc.MipLevels; - std::vector<TextureSubResData> 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(); - m_pDevice->CreateTexture( TexDesc, &InitData, &pSrcTex ); - m_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; - m_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; - m_pContext->CopyTexture(CopyAttribs); -} - -void TestCopyTexData::Test2DTexArray( TEXTURE_FORMAT Format ) -{ - 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<ITexture> pSrcTex, pDstTex; - auto FmtAttribs = m_pDevice->GetTextureFormatInfo(Format); - auto TexelSize = Uint32{FmtAttribs.ComponentSize} * Uint32{FmtAttribs.NumComponents}; - std::vector<uint8_t> DummyData(size_t{TexDesc.Width} * size_t{TexDesc.Height} * size_t{TexelSize}); - TextureData InitData; - InitData.NumSubresources = TexDesc.MipLevels * TexDesc.ArraySize; - std::vector<TextureSubResData> 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(); - - m_pDevice->CreateTexture( TexDesc, &InitData, &pSrcTex ); - m_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; - m_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; - m_pContext->CopyTexture(CopyAttribs); -} - -void TestCopyTexData::Test3DTexture( TEXTURE_FORMAT Format ) -{ - 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<ITexture> pSrcTex, pDstTex; - auto FmtAttribs = m_pDevice->GetTextureFormatInfo(Format); - auto TexelSize = Uint32{FmtAttribs.ComponentSize} * Uint32{FmtAttribs.NumComponents}; - std::vector<uint8_t> DummyData(size_t{TexDesc.Width} * size_t{TexDesc.Height} * size_t{TexDesc.Depth} * size_t{TexelSize}); - TextureData InitData; - InitData.NumSubresources = TexDesc.MipLevels; - std::vector<TextureSubResData> 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(); - m_pDevice->CreateTexture( TexDesc, &InitData, &pSrcTex ); - m_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; - - m_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; - m_pContext->CopyTexture(CopyAttribs); -} diff --git a/Tests/TestApp/src/TestDrawCommands.cpp b/Tests/TestApp/src/TestDrawCommands.cpp deleted file mode 100644 index 2fdbd76..0000000 --- a/Tests/TestApp/src/TestDrawCommands.cpp +++ /dev/null @@ -1,918 +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 "pch.h" -#include "TestDrawCommands.h" -#include "MapHelper.h" - -using namespace Diligent; - -void TestDrawCommands::Init(IRenderDevice *pDevice, IDeviceContext *pDeviceContext, ISwapChain *pSwapChain, float fMinXCoord, float fMinYCoord, float fXExtent, float fYExtent ) -{ - m_pRenderDevice = pDevice; - m_pDeviceContext = pDeviceContext; - - auto DevType = m_pRenderDevice->GetDeviceCaps().DevType; - bool bUseGLSL = DevType == DeviceType::OpenGL || DevType == DeviceType::OpenGLES || DevType == DeviceType::Vulkan; - - std::vector<float> VertexData; - std::vector<float> VertexData2; - std::vector<Uint32> IndexData; - std::vector<float> InstanceData; - Uint32 Ind = 0; - for( int iRow = 0; iRow < TriGridSize; ++iRow ) - for( int iCol = 0; iCol < TriGridSize; ++iCol ) - { - float fTriCenterX = (((float)iCol + 0.5f) / (float)TriGridSize) * fXExtent + fMinXCoord; - float fTriCenterY = (((float)iRow + 0.5f) / (float)TriGridSize) * fYExtent + fMinYCoord; - float fTriSizeX = fXExtent / (float)TriGridSize * 0.9f; - float fTriSizeY = fYExtent / (float)TriGridSize * 0.9f; - Define2DVertex( VertexData, fTriCenterX - 0.5f*fTriSizeX, fTriCenterY - 0.5f*fTriSizeY, 1, 0, 0 ); - Define2DVertex( VertexData, fTriCenterX + 0.5f*fTriSizeX, fTriCenterY - 0.5f*fTriSizeY, 0, 1, 0 ); - Define2DVertex( VertexData, fTriCenterX + 0.0f*fTriSizeX, fTriCenterY + 0.5f*fTriSizeY, 0, 0, 1 ); - - Define2DVertex( VertexData2, fTriCenterX - 0.5f*fTriSizeX, fTriCenterY - 0.5f*fTriSizeY, 1, 1, 0 ); - Define2DVertex( VertexData2, fTriCenterX + 0.5f*fTriSizeX, fTriCenterY - 0.5f*fTriSizeY, 0, 1, 1 ); - Define2DVertex( VertexData2, fTriCenterX + 0.0f*fTriSizeX, fTriCenterY + 0.5f*fTriSizeY, 1, 0, 1 ); - - InstanceData.push_back( (float)iCol / (float)TriGridSize * fXExtent ); - InstanceData.push_back( (float)iRow / (float)TriGridSize * fYExtent ); - - IndexData.push_back( Ind++ ); - IndexData.push_back( Ind++ ); - IndexData.push_back( Ind++ ); - } - - { - BufferDesc BuffDesc; - BuffDesc.Name = "Test Draw Commands: VertexBuff"; - BuffDesc.uiSizeInBytes = (Uint32)VertexData.size()*sizeof( float ); - BuffDesc.BindFlags = BIND_VERTEX_BUFFER; - BuffDesc.Usage = USAGE_STATIC; - BufferData BuffData; - BuffData.pData = VertexData.data(); - BuffData.DataSize = (Uint32)VertexData.size()*sizeof( float ); - m_pRenderDevice->CreateBuffer( BuffDesc, &BuffData, &m_pVertexBuff ); - } - - { - BufferDesc BuffDesc; - BuffDesc.Name = "Test Draw Commands: VertexBuff2"; - BuffDesc.uiSizeInBytes = (Uint32)VertexData2.size()*sizeof( float ); - BuffDesc.BindFlags = BIND_VERTEX_BUFFER; - BuffDesc.Usage = USAGE_STATIC; - BufferData BuffData; - BuffData.pData = VertexData2.data(); - BuffData.DataSize = (Uint32)VertexData2.size()*sizeof( float ); - m_pRenderDevice->CreateBuffer( BuffDesc, &BuffData, &m_pVertexBuff2 ); - } - - { - BufferDesc BuffDesc; - BuffDesc.Name = "Test Draw Commands: IndexBuff"; - BuffDesc.uiSizeInBytes = (Uint32)IndexData.size() * sizeof( Uint32 ); - BuffDesc.BindFlags = BIND_INDEX_BUFFER; - BuffDesc.Usage = USAGE_STATIC; - BufferData BuffData; - BuffData.pData = IndexData.data(); - BuffData.DataSize = BuffDesc.uiSizeInBytes; - m_pRenderDevice->CreateBuffer( BuffDesc, &BuffData, &m_pIndexBuff ); - } - - { - BufferDesc BuffDesc; - BuffDesc.Name = "Test Draw Commands: InstanceData"; - BuffDesc.uiSizeInBytes = (Uint32)InstanceData.size() * sizeof( float ); - BuffDesc.BindFlags = BIND_VERTEX_BUFFER; - BuffDesc.Usage = USAGE_STATIC; - BufferData BuffData; - BuffData.pData = InstanceData.data(); - BuffData.DataSize = BuffDesc.uiSizeInBytes; - m_pRenderDevice->CreateBuffer( BuffDesc, &BuffData, &m_pInstanceData ); - } - - if( m_pRenderDevice->GetDeviceCaps().bIndirectRenderingSupported ) - { - //typedef struct { - // GLuint count; - // GLuint instanceCount; - // GLuint first; - // GLuint baseInstance; - //} DrawArraysIndirectCommand; - - Uint32 IndirectDrawArgs[] = { 3, 2, 0, 0 }; - BufferDesc BuffDesc; - BuffDesc.uiSizeInBytes = sizeof( IndirectDrawArgs ); - // A buffer cannot be created if no bind flags set. We thus have to set this dummy BIND_VERTEX_BUFFER flag - // to be able to create the buffer - BuffDesc.BindFlags = BIND_INDIRECT_DRAW_ARGS | BIND_VERTEX_BUFFER; - BuffDesc.Usage = USAGE_DYNAMIC; - BuffDesc.CPUAccessFlags = CPU_ACCESS_WRITE; - m_pRenderDevice->CreateBuffer( BuffDesc, nullptr, &m_pIndirectDrawArgs ); - } - - { - //typedef struct { - // GLuint count; - // GLuint instanceCount; - // GLuint firstIndex; - // GLuint baseVertex; - // GLuint baseInstance; - //} DrawElementsIndirectCommand; - - Uint32 IndirectDrawArgs[] = { 3, 2, 0, 0, 0 }; - BufferDesc BuffDesc; - BuffDesc.uiSizeInBytes = sizeof( IndirectDrawArgs ); - // A buffer cannot be created if no bind flags set. We thus have to set this dummy flag - // to be able to create the buffer - BuffDesc.BindFlags = BIND_INDIRECT_DRAW_ARGS | BIND_VERTEX_BUFFER; - BuffDesc.Usage = USAGE_DYNAMIC; - BuffDesc.CPUAccessFlags = CPU_ACCESS_WRITE; - m_pRenderDevice->CreateBuffer( BuffDesc, nullptr, &m_pIndexedIndirectDrawArgs ); - } - - - ShaderCreateInfo CreationAttrs; - RefCntAutoPtr<IShaderSourceInputStreamFactory> pShaderSourceFactory; - pDevice->GetEngineFactory()->CreateDefaultShaderSourceStreamFactory(nullptr, &pShaderSourceFactory); - CreationAttrs.pShaderSourceStreamFactory = pShaderSourceFactory; - CreationAttrs.UseCombinedTextureSamplers = true; - - RefCntAutoPtr<IShader> pVS, pVSInst, pPS; - { - CreationAttrs.FilePath = bUseGLSL ? "Shaders\\minimalGL.vsh" : "Shaders\\minimalDX.vsh"; - CreationAttrs.Desc.ShaderType = SHADER_TYPE_VERTEX; - m_pRenderDevice->CreateShader( CreationAttrs, &pVS ); - } - - { - CreationAttrs.FilePath = bUseGLSL ? "Shaders\\minimalInstGL.vsh" : "Shaders\\minimalInstDX.vsh"; - CreationAttrs.Desc.ShaderType = SHADER_TYPE_VERTEX; - m_pRenderDevice->CreateShader( CreationAttrs, &pVSInst ); - } - - { - CreationAttrs.FilePath = bUseGLSL ? "Shaders\\minimalGL.psh" : "Shaders\\minimalDX.psh"; - CreationAttrs.Desc.ShaderType = SHADER_TYPE_PIXEL; - m_pRenderDevice->CreateShader( CreationAttrs, &pPS ); - } - - PipelineStateDesc PSODesc; - 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; - PSODesc.GraphicsPipeline.RTVFormats[0] = pSwapChain->GetDesc().ColorBufferFormat; - PSODesc.GraphicsPipeline.DSVFormat = pSwapChain->GetDesc().DepthBufferFormat; - PSODesc.GraphicsPipeline.pPS = pPS; - - BlendStateDesc &BSDesc = PSODesc.GraphicsPipeline.BlendDesc; - BSDesc.IndependentBlendEnable = False; - BSDesc.RenderTargets[0].BlendEnable = True; - BSDesc.RenderTargets[0].SrcBlend = BLEND_FACTOR_ONE; - BSDesc.RenderTargets[0].DestBlend = BLEND_FACTOR_ONE; - BSDesc.RenderTargets[0].BlendOp = BLEND_OPERATION_ADD; - BSDesc.RenderTargets[0].SrcBlendAlpha = BLEND_FACTOR_ONE; - BSDesc.RenderTargets[0].DestBlendAlpha = BLEND_FACTOR_ZERO; - BSDesc.RenderTargets[0].BlendOpAlpha = BLEND_OPERATION_ADD; - - PSODesc.GraphicsPipeline.PrimitiveTopology = PRIMITIVE_TOPOLOGY_TRIANGLE_LIST; - { - PSODesc.GraphicsPipeline.pVS = pVS; - - InputLayoutDesc LayoutDesc; - LayoutElement Elems[] = - { - LayoutElement{ 0, 0, 3, VT_FLOAT32, false, 0 }, - LayoutElement{ 1, 0, 3, VT_FLOAT32, false, sizeof( float ) * 3 } - }; - PSODesc.GraphicsPipeline.InputLayout.LayoutElements = Elems; - PSODesc.GraphicsPipeline.InputLayout.NumElements = _countof( Elems ); - m_pRenderDevice->CreatePipelineState( PSODesc, &m_pPSO ); - - Elems[0].Stride = sizeof(float)*6 * 2; - m_pRenderDevice->CreatePipelineState( PSODesc, &m_pPSO_2xStride ); - } - - { - PSODesc.GraphicsPipeline.pVS = pVSInst; - - InputLayoutDesc LayoutDesc; - LayoutElement Elems[] = - { - LayoutElement{ 0, 0, 3, VT_FLOAT32, false, 0 }, - LayoutElement{ 1, 0, 3, VT_FLOAT32, false, sizeof( float ) * 3 }, - LayoutElement{ 2, 1, 2, VT_FLOAT32, false, LayoutElement::AutoOffset, LayoutElement::AutoStride, LayoutElement::FREQUENCY_PER_INSTANCE } - }; - PSODesc.GraphicsPipeline.InputLayout.LayoutElements = Elems; - PSODesc.GraphicsPipeline.InputLayout.NumElements = _countof( Elems ); - m_pRenderDevice->CreatePipelineState( PSODesc, &m_pPSOInst ); - } - - { - BufferDesc BuffDesc; - float UniformData[16] = { 1, 1, 1, 1 }; - BuffDesc.uiSizeInBytes = sizeof( UniformData ); - BuffDesc.BindFlags = BIND_UNIFORM_BUFFER; - BuffDesc.Usage = USAGE_DEFAULT; - BuffDesc.CPUAccessFlags = CPU_ACCESS_NONE; - BufferData BuffData; - BuffData.pData = UniformData; - BuffData.DataSize = sizeof( UniformData ); - RefCntAutoPtr<IBuffer> pUniformBuff3, pUniformBuff4; - BuffDesc.Name = "Test Constant Buffer 3"; - m_pRenderDevice->CreateBuffer( BuffDesc, &BuffData, &pUniformBuff3 ); - BuffDesc.Name = "Test Constant Buffer 4"; - m_pRenderDevice->CreateBuffer( BuffDesc, &BuffData, &pUniformBuff4 ); - - ResourceMappingDesc ResMappingDesc; - ResourceMappingEntry pEtries[] = { { "cbTestBlock3", pUniformBuff3 }, { "cbTestBlock4", pUniformBuff4 }, { nullptr, nullptr } }; - ResMappingDesc.pEntries = pEtries; - m_pRenderDevice->CreateResourceMapping( ResMappingDesc, &m_pResMapping ); - } - - m_pPSO->BindStaticResources(SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, m_pResMapping, BIND_SHADER_RESOURCES_VERIFY_ALL_RESOLVED); - m_pPSOInst->BindStaticResources(SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, m_pResMapping, BIND_SHADER_RESOURCES_VERIFY_ALL_RESOLVED | BIND_SHADER_RESOURCES_UPDATE_STATIC); - m_pPSO_2xStride->BindStaticResources(SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, m_pResMapping, BIND_SHADER_RESOURCES_VERIFY_ALL_RESOLVED | BIND_SHADER_RESOURCES_UPDATE_STATIC); - m_pPSO->CreateShaderResourceBinding(&m_pSRB, true); - m_pPSOInst->CreateShaderResourceBinding(&m_pSRBInst, true); -} - -void TestDrawCommands::Draw() -{ - m_pDeviceContext->SetPipelineState(m_pPSO); - m_pDeviceContext->CommitShaderResources(m_pSRB, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); - - IBuffer *pBuffs[2] = {m_pVertexBuff, m_pInstanceData}; - Uint32 Strides[] = {sizeof(float)*6, sizeof(float)*2}; - Uint32 Offsets[] = {0, 0}; - m_pDeviceContext->SetVertexBuffers( 0, 1, pBuffs, Offsets, RESOURCE_STATE_TRANSITION_MODE_TRANSITION, SET_VERTEX_BUFFERS_FLAG_RESET); - - StateTransitionDesc Barriers[] = - { - {m_pIndirectDrawArgs, m_pIndirectDrawArgs->GetState(), RESOURCE_STATE_INDIRECT_ARGUMENT, false}, - {m_pIndexedIndirectDrawArgs, m_pIndexedIndirectDrawArgs->GetState(), RESOURCE_STATE_INDIRECT_ARGUMENT, false}, - {m_pVertexBuff, m_pVertexBuff->GetState(), RESOURCE_STATE_VERTEX_BUFFER, true}, - {m_pVertexBuff2, m_pVertexBuff2->GetState(), RESOURCE_STATE_VERTEX_BUFFER, true}, - {m_pInstanceData, RESOURCE_STATE_UNKNOWN, RESOURCE_STATE_VERTEX_BUFFER, true}, - {m_pIndexBuff, RESOURCE_STATE_UNKNOWN, RESOURCE_STATE_INDEX_BUFFER, true} - }; - Barriers[0].TransitionType = STATE_TRANSITION_TYPE_BEGIN; - Barriers[1].TransitionType = STATE_TRANSITION_TYPE_BEGIN; - m_pDeviceContext->TransitionResourceStates(_countof(Barriers), Barriers); - - Uint32 NumTestTrianglesInRow[TriGridSize] = { 0 }; - - - // 1ST ROW: simple non-indexed drawing (glDrawArrays/Draw) - - // 0,1: basic drawing - { - // Draw 2 triangles - DrawAttribs DrawAttrs(2*3, DRAW_FLAG_VERIFY_ALL); - m_pDeviceContext->Draw(DrawAttrs); - } - - // 2,3: test StartVertex - { - // Draw 2 triangles - DrawAttribs DrawAttrs(2*3, DRAW_FLAG_VERIFY_ALL); - DrawAttrs.StartVertexLocation = 2*3; - m_pDeviceContext->Draw(DrawAttrs); - } - - // 4,5: test buffer offset - Offsets[0] = 4*3*6*sizeof(float); - m_pDeviceContext->SetVertexBuffers(0, 1, pBuffs, Offsets, RESOURCE_STATE_TRANSITION_MODE_VERIFY, SET_VERTEX_BUFFERS_FLAG_RESET); - { - // Draw 2 triangles - DrawAttribs DrawAttrs(2*3, DRAW_FLAG_VERIFY_ALL); - m_pDeviceContext->Draw(DrawAttrs); - } - - // 6,7: test buffer offset & StartVertex - { - DrawAttribs DrawAttrs(2*3, DRAW_FLAG_VERIFY_ALL); - DrawAttrs.StartVertexLocation = 2*3; - m_pDeviceContext->Draw(DrawAttrs); - } - - // 8,9: test strides - Strides[0] *= 2; - m_pDeviceContext->SetPipelineState(m_pPSO_2xStride); - m_pDeviceContext->CommitShaderResources(m_pSRB, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); - m_pDeviceContext->SetVertexBuffers(0, 1, pBuffs, Offsets, RESOURCE_STATE_TRANSITION_MODE_VERIFY, SET_VERTEX_BUFFERS_FLAG_RESET); - { - DrawAttribs DrawAttrs(2*3, DRAW_FLAG_VERIFY_ALL);// Draw 2 triangles - DrawAttrs.StartVertexLocation = 4*3/2; // Stride is 2x - m_pDeviceContext->Draw(DrawAttrs); - } - Strides[0] /= 2; - m_pDeviceContext->SetPipelineState(m_pPSO); - m_pDeviceContext->CommitShaderResources(m_pSRB, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); - - NumTestTrianglesInRow[0] = 12; - - - - - // 2ND ROW: simple indexed rendering (glDrawElements/DrawIndexed) - - Offsets[0] = 1*16*3 * 6*sizeof(float); - m_pDeviceContext->SetVertexBuffers(0, 1, pBuffs, Offsets, RESOURCE_STATE_TRANSITION_MODE_VERIFY, SET_VERTEX_BUFFERS_FLAG_RESET); - m_pDeviceContext->SetIndexBuffer(m_pIndexBuff, 0, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); - - // 0,1 - { - DrawIndexedAttribs DrawAttrs(2*3, VT_UINT32, DRAW_FLAG_VERIFY_ALL);// Draw 2 triangles - m_pDeviceContext->DrawIndexed(DrawAttrs); - } - - // 2,3: test index buffer offset - m_pDeviceContext->SetIndexBuffer( m_pIndexBuff, 2 * 3 * sizeof( Uint32 ), RESOURCE_STATE_TRANSITION_MODE_VERIFY ); - - { - DrawIndexedAttribs DrawAttrs(2*3, VT_UINT32, DRAW_FLAG_VERIFY_ALL);// Draw 2 triangles - m_pDeviceContext->DrawIndexed(DrawAttrs); - } - - NumTestTrianglesInRow[1] = 4; - - - - // 3RD ROW: indexed rendering with BaseVertex (glDrawElementsBaseVertex/DrawIndexed) - Offsets[0] = (2*16*3 - 10) * 6*sizeof(float); - m_pDeviceContext->SetVertexBuffers(0, 1, pBuffs, Offsets, RESOURCE_STATE_TRANSITION_MODE_VERIFY, SET_VERTEX_BUFFERS_FLAG_RESET); - m_pDeviceContext->SetIndexBuffer(m_pIndexBuff, 0, RESOURCE_STATE_TRANSITION_MODE_VERIFY); - - // 0,1 - { - DrawIndexedAttribs DrawAttrs(2*3, VT_UINT32, DRAW_FLAG_VERIFY_ALL);// Draw 2 triangles - DrawAttrs.BaseVertex = 10; - m_pDeviceContext->DrawIndexed(DrawAttrs); - } - - // 2,3: index buffer offset & Base Vertex - m_pDeviceContext->SetIndexBuffer( m_pIndexBuff, 2 * 3 * sizeof( Uint32 ), RESOURCE_STATE_TRANSITION_MODE_VERIFY ); - - { - DrawIndexedAttribs DrawAttrs(2*3, VT_UINT32, DRAW_FLAG_VERIFY_ALL);// Draw 2 triangles - DrawAttrs.BaseVertex = 10; - m_pDeviceContext->DrawIndexed(DrawAttrs); - } - NumTestTrianglesInRow[2] = 4; - - - // 4TH ROW: Instanced non-indexed rendering (glDrawArraysInstanced/DrawInstanced) - - Barriers[0].TransitionType = STATE_TRANSITION_TYPE_END; - Barriers[1].TransitionType = STATE_TRANSITION_TYPE_END; - Barriers[0].UpdateResourceState = true; - Barriers[1].UpdateResourceState = true; - m_pDeviceContext->TransitionResourceStates(2, Barriers); - - m_pDeviceContext->SetPipelineState(m_pPSOInst); - m_pDeviceContext->TransitionShaderResources(m_pPSOInst, m_pSRBInst); - m_pDeviceContext->CommitShaderResources(m_pSRBInst, RESOURCE_STATE_TRANSITION_MODE_VERIFY); - - Offsets[0] = 3*16*3 * 6*sizeof(float); - m_pDeviceContext->SetVertexBuffers(0, 2, pBuffs, Offsets, RESOURCE_STATE_TRANSITION_MODE_VERIFY, SET_VERTEX_BUFFERS_FLAG_RESET); - - // 0,1 - { - DrawAttribs DrawAttrs; - DrawAttrs.NumVertices = 3; // Draw 1 triangle - DrawAttrs.NumInstances = 2; // Draw 2 instances - DrawAttrs.Flags = DRAW_FLAG_VERIFY_ALL; - m_pDeviceContext->Draw(DrawAttrs); - } - - // 2,3: Test offset in instance buffer - Offsets[1] = 2* Strides[1]; - m_pDeviceContext->SetVertexBuffers(0, 2, pBuffs, Offsets, RESOURCE_STATE_TRANSITION_MODE_VERIFY, SET_VERTEX_BUFFERS_FLAG_RESET); - { - DrawAttribs DrawAttrs; - DrawAttrs.NumVertices = 3; // Draw 1 triangle - DrawAttrs.NumInstances = 2; // Draw 2 instances - DrawAttrs.Flags = DRAW_FLAG_VERIFY_ALL; - m_pDeviceContext->Draw(DrawAttrs); - } - - // 4,5: test start vertex index - { - DrawAttribs DrawAttrs; - DrawAttrs.NumVertices = 3; // Draw 1 triangle - DrawAttrs.NumInstances = 2; // Draw 2 instances - DrawAttrs.StartVertexLocation = 2*3; - DrawAttrs.Flags = DRAW_FLAG_VERIFY_ALL; - m_pDeviceContext->Draw(DrawAttrs); - } - NumTestTrianglesInRow[3] = 6; - - - - - // 5TH ROW: instanced rendering with base instance (glDrawArraysInstancedBaseInstance/DrawInstanced) - Offsets[0] = 4*16*3 * 6*sizeof(float); - Offsets[1] = 0; - m_pDeviceContext->SetVertexBuffers(0, 2, pBuffs, Offsets, RESOURCE_STATE_TRANSITION_MODE_VERIFY, SET_VERTEX_BUFFERS_FLAG_RESET); - m_pDeviceContext->SetIndexBuffer(m_pIndexBuff, 0, RESOURCE_STATE_TRANSITION_MODE_VERIFY); - // 0,1 - { - DrawAttribs DrawAttrs; - DrawAttrs.NumVertices = 3; // Draw 1 triangle - DrawAttrs.NumInstances = 2; // Draw 2 instances - DrawAttrs.FirstInstanceLocation = 0; - DrawAttrs.Flags = DRAW_FLAG_VERIFY_ALL; - m_pDeviceContext->Draw(DrawAttrs); - } - - // 2,3 - { - DrawAttribs DrawAttrs; - DrawAttrs.NumVertices = 3; // Draw 1 triangle - DrawAttrs.NumInstances = 2; // Draw 2 instances - DrawAttrs.FirstInstanceLocation = 2; - DrawAttrs.Flags = DRAW_FLAG_VERIFY_ALL; - m_pDeviceContext->Draw(DrawAttrs); - } - - // 4,5: test vertex buffer offset - Offsets[0] += 2*3 * Strides[0]; - m_pDeviceContext->SetVertexBuffers(0, 2, pBuffs, Offsets, RESOURCE_STATE_TRANSITION_MODE_VERIFY, SET_VERTEX_BUFFERS_FLAG_RESET); - { - DrawAttribs DrawAttrs; - DrawAttrs.NumVertices = 3; // Draw 1 triangle - DrawAttrs.NumInstances = 2; // Draw 2 instances - DrawAttrs.FirstInstanceLocation = 2; - DrawAttrs.Flags = DRAW_FLAG_VERIFY_ALL; - m_pDeviceContext->Draw(DrawAttrs); - } - - // 6,7: test instance buffer offset - Offsets[1] += 2 * Strides[1]; - m_pDeviceContext->SetVertexBuffers(0, 2, pBuffs, Offsets, RESOURCE_STATE_TRANSITION_MODE_VERIFY, SET_VERTEX_BUFFERS_FLAG_RESET); - { - DrawAttribs DrawAttrs; - DrawAttrs.NumVertices = 3; // Draw 1 triangle - DrawAttrs.NumInstances = 2; // Draw 2 instances - DrawAttrs.FirstInstanceLocation = 2; - DrawAttrs.Flags = DRAW_FLAG_VERIFY_ALL; - m_pDeviceContext->Draw(DrawAttrs); - } - NumTestTrianglesInRow[4] = 8; - - - - // 6TH ROW: instanced indexed rendering (glDrawElementsInstanced/DrawIndexedInstanced) - - Offsets[0] = 5*16*3 * 6*sizeof(float); - Offsets[1] = 0; - m_pDeviceContext->SetVertexBuffers(0, 2, pBuffs, Offsets, RESOURCE_STATE_TRANSITION_MODE_VERIFY, SET_VERTEX_BUFFERS_FLAG_RESET); - m_pDeviceContext->SetIndexBuffer(m_pIndexBuff, 0, RESOURCE_STATE_TRANSITION_MODE_VERIFY); - // 0,1 - { - DrawIndexedAttribs DrawAttrs; - DrawAttrs.NumIndices = 3; // Draw 1 triangle - DrawAttrs.NumInstances = 2; // Draw 2 instances - DrawAttrs.IndexType = VT_UINT32; - DrawAttrs.Flags = DRAW_FLAG_VERIFY_ALL; - m_pDeviceContext->DrawIndexed(DrawAttrs); - } - - // 2,3: test index buffer offset - m_pDeviceContext->SetIndexBuffer( m_pIndexBuff, 2 * 3 * sizeof( Uint32 ), RESOURCE_STATE_TRANSITION_MODE_VERIFY ); - { - DrawIndexedAttribs DrawAttrs; - DrawAttrs.NumIndices = 3; // Draw 1 triangle - DrawAttrs.NumInstances = 2; // Draw 2 instances - DrawAttrs.IndexType = VT_UINT32; - DrawAttrs.Flags = DRAW_FLAG_VERIFY_ALL; - m_pDeviceContext->DrawIndexed(DrawAttrs); - } - - // 4,5: test vertex buffer offset - Offsets[0] += 2*3 * Strides[0]; - m_pDeviceContext->SetVertexBuffers(0, 2, pBuffs, Offsets, RESOURCE_STATE_TRANSITION_MODE_VERIFY, SET_VERTEX_BUFFERS_FLAG_RESET); - { - DrawIndexedAttribs DrawAttrs; - DrawAttrs.NumIndices = 3; // Draw 1 triangle - DrawAttrs.NumInstances = 2; // Draw 2 instances - DrawAttrs.IndexType = VT_UINT32; - DrawAttrs.Flags = DRAW_FLAG_VERIFY_ALL; - m_pDeviceContext->DrawIndexed(DrawAttrs); - } - - // 6,7: test instance buffer offset - Offsets[1] += 2 * Strides[1]; - m_pDeviceContext->SetVertexBuffers(0, 2, pBuffs, Offsets, RESOURCE_STATE_TRANSITION_MODE_VERIFY, SET_VERTEX_BUFFERS_FLAG_RESET); - { - DrawIndexedAttribs DrawAttrs; - DrawAttrs.NumIndices = 3; // Draw 1 triangle - DrawAttrs.NumInstances = 2; // Draw 2 instances - DrawAttrs.IndexType = VT_UINT32; - DrawAttrs.Flags = DRAW_FLAG_VERIFY_ALL; - m_pDeviceContext->DrawIndexed(DrawAttrs); - } - - // 8,9: test first index location - { - DrawIndexedAttribs DrawAttrs; - DrawAttrs.NumIndices = 3; // Draw 1 triangle - DrawAttrs.NumInstances = 2; // Draw 2 instances - DrawAttrs.FirstIndexLocation = 2*3; - DrawAttrs.IndexType = VT_UINT32; - DrawAttrs.Flags = DRAW_FLAG_VERIFY_ALL; - m_pDeviceContext->DrawIndexed(DrawAttrs); - } - NumTestTrianglesInRow[5] = 10; - - - - - // 7TH ROW: instanced indexed rendering with base instance (glDrawElementsInstancedBaseInstance/DrawInstanced) - - Offsets[0] = 6*16*3 * 6*sizeof(float); - Offsets[1] = 0; - m_pDeviceContext->SetVertexBuffers(0, 2, pBuffs, Offsets, RESOURCE_STATE_TRANSITION_MODE_VERIFY, SET_VERTEX_BUFFERS_FLAG_RESET); - m_pDeviceContext->SetIndexBuffer(m_pIndexBuff, 0, RESOURCE_STATE_TRANSITION_MODE_VERIFY); - // 0,1 - { - DrawIndexedAttribs DrawAttrs; - DrawAttrs.NumIndices = 3; // Draw 1 triangle - DrawAttrs.NumInstances = 2; // Draw 2 instances - DrawAttrs.IndexType = VT_UINT32; - DrawAttrs.Flags = DRAW_FLAG_VERIFY_ALL; - m_pDeviceContext->DrawIndexed(DrawAttrs); - } - // 2,3 - { - DrawIndexedAttribs DrawAttrs; - DrawAttrs.NumIndices = 3; // Draw 1 triangle - DrawAttrs.NumInstances = 2; // Draw 2 instances - DrawAttrs.IndexType = VT_UINT32; - DrawAttrs.FirstInstanceLocation = 2; - DrawAttrs.Flags = DRAW_FLAG_VERIFY_ALL; - m_pDeviceContext->DrawIndexed(DrawAttrs); - } - - // 4,5: test index buffer offset - m_pDeviceContext->SetIndexBuffer( m_pIndexBuff, 2 * 3 * sizeof( Uint32 ), RESOURCE_STATE_TRANSITION_MODE_VERIFY ); - { - DrawIndexedAttribs DrawAttrs; - DrawAttrs.NumIndices = 3; // Draw 1 triangle - DrawAttrs.NumInstances = 2; // Draw 2 instances - DrawAttrs.IndexType = VT_UINT32; - DrawAttrs.FirstInstanceLocation = 2; - DrawAttrs.Flags = DRAW_FLAG_VERIFY_ALL; - m_pDeviceContext->DrawIndexed(DrawAttrs); - } - - // 6,7: test instance buffer offset - Offsets[1] += Strides[1] * 2; - m_pDeviceContext->SetVertexBuffers(0, 2, pBuffs, Offsets, RESOURCE_STATE_TRANSITION_MODE_VERIFY, SET_VERTEX_BUFFERS_FLAG_RESET); - { - DrawIndexedAttribs DrawAttrs; - DrawAttrs.NumIndices = 3; // Draw 1 triangle - DrawAttrs.NumInstances = 2; // Draw 2 instances - DrawAttrs.IndexType = VT_UINT32; - DrawAttrs.FirstInstanceLocation = 2; - DrawAttrs.Flags = DRAW_FLAG_VERIFY_ALL; - m_pDeviceContext->DrawIndexed(DrawAttrs); - } - - // 8,9: test first index location - { - DrawIndexedAttribs DrawAttrs; - DrawAttrs.NumIndices = 3; // Draw 1 triangle - DrawAttrs.NumInstances = 2; // Draw 2 instances - DrawAttrs.IndexType = VT_UINT32; - DrawAttrs.FirstInstanceLocation = 2; - DrawAttrs.FirstIndexLocation = 2*3; - DrawAttrs.Flags = DRAW_FLAG_VERIFY_ALL; - m_pDeviceContext->DrawIndexed(DrawAttrs); - } - NumTestTrianglesInRow[6] = 10; - - - - // 8TH ROW: instanced indexed rendering with base vertex (glDrawElementsInstancedBaseVertex/DrawInstanced) - - Offsets[0] = 7*16*3 * 6*sizeof(float); - Offsets[1] = 0; - m_pDeviceContext->SetVertexBuffers(0, 2, pBuffs, Offsets, RESOURCE_STATE_TRANSITION_MODE_VERIFY, SET_VERTEX_BUFFERS_FLAG_RESET); - m_pDeviceContext->SetIndexBuffer(m_pIndexBuff, 0, RESOURCE_STATE_TRANSITION_MODE_VERIFY); - // 0,1 - { - DrawIndexedAttribs DrawAttrs; - DrawAttrs.NumIndices = 3; // Draw 1 triangle - DrawAttrs.NumInstances = 2; // Draw 2 instances - DrawAttrs.IndexType = VT_UINT32; - DrawAttrs.Flags = DRAW_FLAG_VERIFY_ALL; - m_pDeviceContext->DrawIndexed(DrawAttrs); - } - - // 2,3 - { - DrawIndexedAttribs DrawAttrs; - DrawAttrs.NumIndices = 3; // Draw 1 triangle - DrawAttrs.NumInstances = 2; // Draw 2 instances - DrawAttrs.BaseVertex = 2*3; - DrawAttrs.IndexType = VT_UINT32; - DrawAttrs.Flags = DRAW_FLAG_VERIFY_ALL; - m_pDeviceContext->DrawIndexed(DrawAttrs); - } - - // 4,5: test index buffer offset - m_pDeviceContext->SetIndexBuffer( m_pIndexBuff, 2 * 3 * sizeof( Uint32 ), RESOURCE_STATE_TRANSITION_MODE_VERIFY ); - { - DrawIndexedAttribs DrawAttrs; - DrawAttrs.NumIndices = 3; // Draw 1 triangle - DrawAttrs.NumInstances = 2; // Draw 2 instances - DrawAttrs.BaseVertex = 2*3; - DrawAttrs.IndexType = VT_UINT32; - DrawAttrs.Flags = DRAW_FLAG_VERIFY_ALL; - m_pDeviceContext->DrawIndexed(DrawAttrs); - } - - // 6,7: test instance buffer offset - Offsets[1] += Strides[1] * 2; - m_pDeviceContext->SetVertexBuffers(0, 2, pBuffs, Offsets, RESOURCE_STATE_TRANSITION_MODE_VERIFY, SET_VERTEX_BUFFERS_FLAG_RESET); - { - DrawIndexedAttribs DrawAttrs; - DrawAttrs.NumIndices = 3; // Draw 1 triangle - DrawAttrs.NumInstances = 2; // Draw 2 instances - DrawAttrs.BaseVertex = 2*3; - DrawAttrs.IndexType = VT_UINT32; - DrawAttrs.Flags = DRAW_FLAG_VERIFY_ALL; - m_pDeviceContext->DrawIndexed(DrawAttrs); - } - - // 8,9: Test first index location - { - DrawIndexedAttribs DrawAttrs; - DrawAttrs.NumIndices = 3; // Draw 1 triangle - DrawAttrs.NumInstances = 2; // Draw 2 instances - DrawAttrs.BaseVertex = 2*3; - DrawAttrs.IndexType = VT_UINT32; - DrawAttrs.FirstIndexLocation = 2*3; - DrawAttrs.Flags = DRAW_FLAG_VERIFY_ALL; - m_pDeviceContext->DrawIndexed(DrawAttrs); - } - NumTestTrianglesInRow[7] = 10; - - - - // 9TH ROW: instanced indexed rendering with base vertex & base instance (glDrawElementsInstancedBaseVertexBaseInstance/DrawInstanced) - - Offsets[0] = 8*16*3 * 6*sizeof(float); - Offsets[1] = 0; - m_pDeviceContext->SetVertexBuffers(0, 2, pBuffs, Offsets, RESOURCE_STATE_TRANSITION_MODE_VERIFY, SET_VERTEX_BUFFERS_FLAG_RESET); - m_pDeviceContext->SetIndexBuffer(m_pIndexBuff, 0, RESOURCE_STATE_TRANSITION_MODE_VERIFY); - // 0,1 - { - DrawIndexedAttribs DrawAttrs; - DrawAttrs.NumIndices = 3; // Draw 1 triangle - DrawAttrs.NumInstances = 2; // Draw 2 instances - DrawAttrs.IndexType = VT_UINT32; - DrawAttrs.Flags = DRAW_FLAG_VERIFY_ALL; - m_pDeviceContext->DrawIndexed(DrawAttrs); - } - - // 2,3 - { - DrawIndexedAttribs DrawAttrs; - DrawAttrs.NumIndices = 3; // Draw 1 triangle - DrawAttrs.NumInstances = 2; // Draw 2 instances - DrawAttrs.BaseVertex = 3; - DrawAttrs.FirstInstanceLocation = 1; - DrawAttrs.IndexType = VT_UINT32; - DrawAttrs.Flags = DRAW_FLAG_VERIFY_ALL; - m_pDeviceContext->DrawIndexed(DrawAttrs); - } - - // 4,5: test index buffer offset - m_pDeviceContext->SetIndexBuffer( m_pIndexBuff, 2 * 3 * sizeof( Uint32 ), RESOURCE_STATE_TRANSITION_MODE_VERIFY ); - { - DrawIndexedAttribs DrawAttrs; - DrawAttrs.NumIndices = 3; // Draw 1 triangle - DrawAttrs.NumInstances = 2; // Draw 2 instances - DrawAttrs.BaseVertex = 3; - DrawAttrs.FirstInstanceLocation = 1; - DrawAttrs.IndexType = VT_UINT32; - DrawAttrs.Flags = DRAW_FLAG_VERIFY_ALL; - m_pDeviceContext->DrawIndexed(DrawAttrs); - } - - // 6,7: test instance buffer offset - Offsets[1] += Strides[1] * 2; - m_pDeviceContext->SetVertexBuffers(0, 2, pBuffs, Offsets, RESOURCE_STATE_TRANSITION_MODE_VERIFY, SET_VERTEX_BUFFERS_FLAG_RESET); - { - DrawIndexedAttribs DrawAttrs; - DrawAttrs.NumIndices = 3; // Draw 1 triangle - DrawAttrs.NumInstances = 2; // Draw 2 instances - DrawAttrs.BaseVertex = 3; - DrawAttrs.FirstInstanceLocation = 1; - DrawAttrs.IndexType = VT_UINT32; - DrawAttrs.Flags = DRAW_FLAG_VERIFY_ALL; - m_pDeviceContext->DrawIndexed(DrawAttrs); - } - - // 8,9: test first index location - { - DrawIndexedAttribs DrawAttrs; - DrawAttrs.NumIndices = 3; // Draw 1 triangle - DrawAttrs.NumInstances = 2; // Draw 2 instances - DrawAttrs.BaseVertex = 3; - DrawAttrs.FirstInstanceLocation = 1; - DrawAttrs.IndexType = VT_UINT32; - DrawAttrs.FirstIndexLocation = 2*3; - DrawAttrs.Flags = DRAW_FLAG_VERIFY_ALL; - m_pDeviceContext->DrawIndexed(DrawAttrs); - } - NumTestTrianglesInRow[8] = 10; - - - - if( m_pRenderDevice->GetDeviceCaps().bIndirectRenderingSupported ) - { - // 10TH ROW: instanced non-indexed indirect rendering (glDrawArraysIndirect/DrawInstancedIndirect) - - // Test indirect non-indexed drawing - Offsets[0] = 9*16*3 * 6*sizeof(float); - Offsets[1] = 0; - m_pDeviceContext->SetVertexBuffers(0, 2, pBuffs, Offsets, RESOURCE_STATE_TRANSITION_MODE_VERIFY, SET_VERTEX_BUFFERS_FLAG_RESET); - - // 0,1 - { - MapHelper<Uint32, true> MappedData(m_pDeviceContext, m_pIndirectDrawArgs, MAP_WRITE, MAP_FLAG_DISCARD); - MappedData[0] = 3; // Vertex count - MappedData[1] = 2; // Num instances - MappedData[2] = 0; // Start vertex - MappedData[3] = 0; // Start instance - MappedData.Unmap(); - - DrawIndirectAttribs DrawAttrs(DRAW_FLAG_VERIFY_ALL, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); - m_pDeviceContext->DrawIndirect(DrawAttrs, m_pIndirectDrawArgs); - } - - // 2,3: test first vertex location - { - MapHelper<Uint32, true> MappedData( m_pDeviceContext, m_pIndirectDrawArgs, MAP_WRITE, MAP_FLAG_DISCARD ); - MappedData[0] = 3; // Vertex count - MappedData[1] = 2; // Num instances - MappedData[2] = 3*2; // Start vertex - MappedData[3] = 0; // Start instance - MappedData.Unmap(); - DrawIndirectAttribs DrawAttrs(DRAW_FLAG_VERIFY_ALL, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); - m_pDeviceContext->DrawIndirect(DrawAttrs, m_pIndirectDrawArgs); - } - - // 4,5: test first instance location - { - MapHelper<Uint32, true> MappedData( m_pDeviceContext, m_pIndirectDrawArgs, MAP_WRITE, MAP_FLAG_DISCARD ); - MappedData[0] = 3; // Vertex count - MappedData[1] = 2; // Num instances - MappedData[2] = 3*2; // Start vertex - MappedData[3] = 2; // Start instance - MappedData.Unmap(); - DrawIndirectAttribs DrawAttrs; - DrawAttrs.IndirectAttribsBufferStateTransitionMode = RESOURCE_STATE_TRANSITION_MODE_VERIFY; - DrawAttrs.Flags = DRAW_FLAG_VERIFY_ALL; - m_pDeviceContext->DrawIndirect(DrawAttrs, m_pIndirectDrawArgs); - } - - NumTestTrianglesInRow[9] = 6; - - - - - // 11TH ROW: instanced indexed indirect rendering (glDrawElementsIndirect/DrawIndexedInstancedIndirect) - - Offsets[0] = 10*16*3 * 6*sizeof(float); - Offsets[1] = 0; - m_pDeviceContext->SetVertexBuffers(0, 2, pBuffs, Offsets, RESOURCE_STATE_TRANSITION_MODE_VERIFY, SET_VERTEX_BUFFERS_FLAG_RESET); - m_pDeviceContext->SetIndexBuffer(m_pIndexBuff, 0, RESOURCE_STATE_TRANSITION_MODE_VERIFY); - - // 0,1 - { - MapHelper<Uint32> MappedData( m_pDeviceContext, m_pIndexedIndirectDrawArgs, MAP_WRITE, MAP_FLAG_DISCARD ); - MappedData[0] = 3; // Num indices - MappedData[1] = 2; // Num instances - MappedData[2] = 0; // Start index - MappedData[3] = 0; // Base vertex - MappedData[4] = 0; // Start instance - MappedData.Unmap(); - - DrawIndexedIndirectAttribs DrawAttrs(VT_UINT32, DRAW_FLAG_VERIFY_ALL, RESOURCE_STATE_TRANSITION_MODE_VERIFY); - m_pDeviceContext->DrawIndexedIndirect(DrawAttrs, m_pIndexedIndirectDrawArgs); - } - - // 2,3: test start index location - { - MapHelper<Uint32> MappedData( m_pDeviceContext, m_pIndexedIndirectDrawArgs, MAP_WRITE, MAP_FLAG_DISCARD ); - MappedData[0] = 3; // Num indices - MappedData[1] = 2; // Num instances - MappedData[2] = 6; // Start index - MappedData[3] = 0; // Base vertex - MappedData[4] = 0; // Start instance - MappedData.Unmap(); - - DrawIndexedIndirectAttribs DrawAttrs; - DrawAttrs.IndexType = VT_UINT32; - DrawAttrs.IndirectAttribsBufferStateTransitionMode = RESOURCE_STATE_TRANSITION_MODE_VERIFY; - DrawAttrs.Flags = DRAW_FLAG_VERIFY_ALL; - m_pDeviceContext->DrawIndexedIndirect(DrawAttrs, m_pIndexedIndirectDrawArgs); - } - - // 4,5: test base vertex - { - MapHelper<Uint32> MappedData( m_pDeviceContext, m_pIndexedIndirectDrawArgs, MAP_WRITE, MAP_FLAG_DISCARD ); - MappedData[0] = 3; // Num indices - MappedData[1] = 2; // Num instances - MappedData[2] = 6; // Start index - MappedData[3] = 2*3;// Base vertex - MappedData[4] = 0; // Start instance - MappedData.Unmap(); - - DrawIndexedIndirectAttribs DrawAttrs; - DrawAttrs.IndexType = VT_UINT32; - DrawAttrs.IndirectAttribsBufferStateTransitionMode = RESOURCE_STATE_TRANSITION_MODE_VERIFY; - DrawAttrs.Flags = DRAW_FLAG_VERIFY_ALL; - m_pDeviceContext->DrawIndexedIndirect(DrawAttrs, m_pIndexedIndirectDrawArgs); - } - - // 6,7: test start instance - { - MapHelper<Uint32> MappedData( m_pDeviceContext, m_pIndexedIndirectDrawArgs, MAP_WRITE, MAP_FLAG_DISCARD ); - MappedData[0] = 3; // Num indices - MappedData[1] = 2; // Num instances - MappedData[2] = 6; // Start index - MappedData[3] = 2*3;// Base vertex - MappedData[4] = 2; // Start instance - MappedData.Unmap(); - - DrawIndexedIndirectAttribs DrawAttrs; - DrawAttrs.IndexType = VT_UINT32; - DrawAttrs.IndirectAttribsBufferStateTransitionMode = RESOURCE_STATE_TRANSITION_MODE_VERIFY; - DrawAttrs.Flags = DRAW_FLAG_VERIFY_ALL; - m_pDeviceContext->DrawIndexedIndirect(DrawAttrs, m_pIndexedIndirectDrawArgs); - } - NumTestTrianglesInRow[10] = 8; - } - - // Draw end triangles - Offsets[0] = 0; - pBuffs[0] = m_pVertexBuff2; - m_pDeviceContext->SetVertexBuffers(0, 1, pBuffs, Offsets, RESOURCE_STATE_TRANSITION_MODE_VERIFY, SET_VERTEX_BUFFERS_FLAG_RESET); - - m_pDeviceContext->SetPipelineState(m_pPSO); - m_pDeviceContext->CommitShaderResources(m_pSRB, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); - - { - // Draw 1 triangle - DrawAttribs DrawAttrs(3, DRAW_FLAG_VERIFY_ALL); - - for(int iRow=0; iRow < TriGridSize; ++iRow) - { - DrawAttrs.StartVertexLocation = 16*3*iRow + 3*(1+NumTestTrianglesInRow[iRow]); - m_pDeviceContext->Draw(DrawAttrs); - } - } - - m_pDeviceContext->SetVertexBuffers( 0, 0, nullptr, nullptr, RESOURCE_STATE_TRANSITION_MODE_VERIFY, SET_VERTEX_BUFFERS_FLAG_RESET ); - - SetStatus(TestResult::Succeeded); -} - - -void TestDrawCommands::Define2DVertex(std::vector<float> &VertexData, float fX, float fY, float fR, float fG, float fB) -{ - VertexData.push_back(fX); - VertexData.push_back(fY); - VertexData.push_back(0.5f); - VertexData.push_back(fR); - VertexData.push_back(fG); - VertexData.push_back(fB); -} diff --git a/Tests/TestApp/src/TestGeometryShader.cpp b/Tests/TestApp/src/TestGeometryShader.cpp deleted file mode 100644 index b3dc8df..0000000 --- a/Tests/TestApp/src/TestGeometryShader.cpp +++ /dev/null @@ -1,95 +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 "pch.h" -#include "TestGeometryShader.h" -#include "MapHelper.h" - -using namespace Diligent; - -void TestGeometryShader::Init( IRenderDevice *pDevice, IDeviceContext *pDeviceContext, ISwapChain *pSwapChain) -{ - if(!pDevice->GetDeviceCaps().bGeometryShadersSupported) - { - SetStatus(TestResult::Skipped, "Geometry shaders are not supported"); - return; - } - - m_pDeviceContext = pDeviceContext; - - ShaderCreateInfo CreationAttrs; - RefCntAutoPtr<IShaderSourceInputStreamFactory> pShaderSourceFactory; - pDevice->GetEngineFactory()->CreateDefaultShaderSourceStreamFactory(nullptr, &pShaderSourceFactory); - CreationAttrs.pShaderSourceStreamFactory = pShaderSourceFactory; - CreationAttrs.SourceLanguage = SHADER_SOURCE_LANGUAGE_HLSL; - CreationAttrs.UseCombinedTextureSamplers = true; - - RefCntAutoPtr<Diligent::IShader> pVS, pGS, pPS; - { - CreationAttrs.FilePath = "Shaders\\GSTestDX.vsh"; - CreationAttrs.Desc.ShaderType = SHADER_TYPE_VERTEX; - pDevice->CreateShader( CreationAttrs, &pVS ); - } - - { - CreationAttrs.FilePath = "Shaders\\GSTestDX.gsh"; - CreationAttrs.Desc.ShaderType = SHADER_TYPE_GEOMETRY; - pDevice->CreateShader( CreationAttrs, &pGS ); - } - - { - CreationAttrs.FilePath = "Shaders\\GSTestDX.psh"; - CreationAttrs.Desc.ShaderType = SHADER_TYPE_PIXEL; - pDevice->CreateShader( CreationAttrs, &pPS ); - } - - PipelineStateDesc PSODesc; - 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; - PSODesc.GraphicsPipeline.RTVFormats[0] = pSwapChain->GetDesc().ColorBufferFormat; - PSODesc.GraphicsPipeline.DSVFormat = pSwapChain->GetDesc().DepthBufferFormat; - PSODesc.GraphicsPipeline.pPS = pPS; - PSODesc.GraphicsPipeline.pVS = pVS; - PSODesc.GraphicsPipeline.pGS = pGS; - PSODesc.GraphicsPipeline.PrimitiveTopology = PRIMITIVE_TOPOLOGY_POINT_LIST; - - pDevice->CreatePipelineState( PSODesc, &m_pPSO ); -} - -void TestGeometryShader::Draw() -{ - if(!m_pDeviceContext) - return; - - m_pDeviceContext->SetPipelineState(m_pPSO); - m_pDeviceContext->CommitShaderResources(nullptr, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); - - // Draw 2 triangles - Diligent::DrawAttribs DrawAttrs(2, DRAW_FLAG_VERIFY_ALL); - m_pDeviceContext->Draw(DrawAttrs); - - SetStatus(TestResult::Succeeded); -} diff --git a/Tests/TestApp/src/TestRenderTarget.cpp b/Tests/TestApp/src/TestRenderTarget.cpp deleted file mode 100644 index 033dffc..0000000 --- a/Tests/TestApp/src/TestRenderTarget.cpp +++ /dev/null @@ -1,68 +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 "pch.h" -#include "TestRenderTarget.h" -#include "GraphicsUtilities.h" - -using namespace Diligent; - -TestRenderTarget::TestRenderTarget() : - UnitTestBase("Render target test") -{ -} - -void TestRenderTarget::Init( IRenderDevice *pDevice, IDeviceContext *pDeviceContext, ISwapChain* pSwapChain, float fMinXCoord, float fMinYCoord, float fXExtent, float fYExtent ) -{ -#if PLATFORM_IOS - SetStatus(TestResult::Skipped); - return; -#endif - -#if 0 - m_pRenderDevice = pDevice; - m_pDeviceContext = pDeviceContext; - m_pRenderScript = CreateRenderScriptFromFile( "TestRenderTargets.lua", pDevice, pDeviceContext, [&]( ScriptParser *pScriptParser ) - { - const auto* BackBufferFmt = pDevice->GetTextureFormatInfo(pSwapChain->GetDesc().ColorBufferFormat).Name; - const auto* DepthBufferFmt = pDevice->GetTextureFormatInfo(pSwapChain->GetDesc().DepthBufferFormat).Name; - pScriptParser->SetGlobalVariable( "extBackBufferFormat", BackBufferFmt ); - pScriptParser->SetGlobalVariable( "extDepthBufferFormat", DepthBufferFmt ); - - pScriptParser->SetGlobalVariable( "MinX", fMinXCoord ); - pScriptParser->SetGlobalVariable( "MinY", fMinYCoord ); - pScriptParser->SetGlobalVariable( "XExt", fXExtent ); - pScriptParser->SetGlobalVariable( "YExt", fYExtent ); - } ); -#endif -} - -void TestRenderTarget::Draw() -{ - if(!m_pDeviceContext) - return; -#if 0 - m_pRenderScript->Run( m_pDeviceContext, "Render" ); - SetStatus(TestResult::Succeeded); -#endif -} diff --git a/Tests/TestApp/src/TestTessellation.cpp b/Tests/TestApp/src/TestTessellation.cpp deleted file mode 100644 index 6d9f001..0000000 --- a/Tests/TestApp/src/TestTessellation.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 "pch.h" -#include "TestTessellation.h" -#include "MapHelper.h" - -using namespace Diligent; - -void TestTessellation::Init( IRenderDevice *pDevice, IDeviceContext *pDeviceContext, ISwapChain *pSwapChain) -{ - if(!pDevice->GetDeviceCaps().bTessellationSupported) - { - SetStatus(TestResult::Skipped, "Tessellation is not supported"); - return; - } - - m_pDeviceContext = pDeviceContext; - - ShaderCreateInfo CreationAttrs; - RefCntAutoPtr<IShaderSourceInputStreamFactory> pShaderSourceFactory; - pDevice->GetEngineFactory()->CreateDefaultShaderSourceStreamFactory("Shaders", &pShaderSourceFactory); - CreationAttrs.pShaderSourceStreamFactory = pShaderSourceFactory; - CreationAttrs.SourceLanguage = SHADER_SOURCE_LANGUAGE_HLSL; - CreationAttrs.UseCombinedTextureSamplers = true; - - RefCntAutoPtr<Diligent::IShader> pVS, pHS, pDS, pPS; - { - CreationAttrs.FilePath = "Shaders\\TessTestQuadDX.vsh"; - CreationAttrs.Desc.ShaderType = SHADER_TYPE_VERTEX; - pDevice->CreateShader( CreationAttrs, &pVS ); - VERIFY_EXPR(pVS); - } - - { - CreationAttrs.FilePath = "Shaders\\TessTestQuadDX.hsh"; - CreationAttrs.Desc.ShaderType = SHADER_TYPE_HULL; - pDevice->CreateShader( CreationAttrs, &pHS ); - VERIFY_EXPR(pHS); - } - - { - CreationAttrs.FilePath = "Shaders\\TessTestQuadDX.dsh"; - CreationAttrs.Desc.ShaderType = SHADER_TYPE_DOMAIN; - pDevice->CreateShader( CreationAttrs, &pDS ); - VERIFY_EXPR(pDS); - } - - { - CreationAttrs.FilePath = "Shaders\\GSTestDX.psh"; - CreationAttrs.Desc.ShaderType = SHADER_TYPE_PIXEL; - pDevice->CreateShader( CreationAttrs, &pPS ); - VERIFY_EXPR(pPS); - } - - PipelineStateDesc PSODesc; - PSODesc.GraphicsPipeline.DepthStencilDesc.DepthEnable = False; - PSODesc.GraphicsPipeline.RasterizerDesc.CullMode = CULL_MODE_NONE; - PSODesc.GraphicsPipeline.RasterizerDesc.FillMode = FILL_MODE_WIREFRAME; - PSODesc.GraphicsPipeline.BlendDesc.IndependentBlendEnable = False; - PSODesc.GraphicsPipeline.BlendDesc.RenderTargets[0].BlendEnable = False; - PSODesc.GraphicsPipeline.NumRenderTargets = 1; - PSODesc.GraphicsPipeline.RTVFormats[0] = pSwapChain->GetDesc().ColorBufferFormat; - PSODesc.GraphicsPipeline.DSVFormat = pSwapChain->GetDesc().DepthBufferFormat; - PSODesc.GraphicsPipeline.pPS = pPS; - PSODesc.GraphicsPipeline.pVS = pVS; - PSODesc.GraphicsPipeline.pHS = pHS; - PSODesc.GraphicsPipeline.pDS = pDS; - PSODesc.GraphicsPipeline.PrimitiveTopology = PRIMITIVE_TOPOLOGY_1_CONTROL_POINT_PATCHLIST; - - pDevice->CreatePipelineState( PSODesc, &m_pQuadPSO ); - - - { - pVS.Release(); - CreationAttrs.FilePath = "Shaders\\TessTestTriDX.vsh"; - CreationAttrs.Desc.ShaderType = SHADER_TYPE_VERTEX; - pDevice->CreateShader( CreationAttrs, &pVS ); - VERIFY_EXPR(pVS); - } - - { - pHS.Release(); - CreationAttrs.FilePath = "Shaders\\TessTestTriDX.hsh"; - CreationAttrs.Desc.ShaderType = SHADER_TYPE_HULL; - pDevice->CreateShader( CreationAttrs, &pHS ); - VERIFY_EXPR(pHS); - } - - { - pDS.Release(); - CreationAttrs.FilePath = "Shaders\\TessTestTriDX.dsh"; - CreationAttrs.Desc.ShaderType = SHADER_TYPE_DOMAIN; - pDevice->CreateShader( CreationAttrs, &pDS ); - VERIFY_EXPR(pDS); - } - - PSODesc.GraphicsPipeline.pPS = pPS; - PSODesc.GraphicsPipeline.pVS = pVS; - PSODesc.GraphicsPipeline.pHS = pHS; - PSODesc.GraphicsPipeline.pDS = pDS; - - pDevice->CreatePipelineState( PSODesc, &m_pTriPSO ); -} - -void TestTessellation::Draw() -{ - if(!m_pDeviceContext) - return; - - m_pDeviceContext->SetPipelineState(m_pQuadPSO); - m_pDeviceContext->CommitShaderResources(nullptr, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); - - // Draw 2 quad patches - Diligent::DrawAttribs DrawAttrs(2, DRAW_FLAG_VERIFY_ALL); - m_pDeviceContext->Draw(DrawAttrs); - - m_pDeviceContext->SetPipelineState(m_pTriPSO); - m_pDeviceContext->CommitShaderResources(nullptr, RESOURCE_STATE_TRANSITION_MODE_TRANSITION); - DrawAttrs.NumVertices = 1; // Draw 1 tri patch - m_pDeviceContext->Draw(DrawAttrs); - - SetStatus(TestResult::Succeeded); -} diff --git a/Tests/TestApp/src/TestTexturing.cpp b/Tests/TestApp/src/TestTexturing.cpp deleted file mode 100644 index 2c1d0a1..0000000 --- a/Tests/TestApp/src/TestTexturing.cpp +++ /dev/null @@ -1,316 +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 "pch.h" -#include <math.h> -#include "TestTexturing.h" -#include "GraphicsUtilities.h" -#include "ShaderMacroHelper.h" - -using namespace Diligent; - -TestTexturing::TestTexturing() : - UnitTestBase("Texturing test"), - m_iTestTexWidth(512), - m_iTestTexHeight(512), - m_iMipLevels(8), - m_TextureFormat(TEX_FORMAT_UNKNOWN) -{ -} - -void TestTexturing::GenerateTextureData(IRenderDevice *pRenderDevice, std::vector<Uint8> &Data, std::vector<TextureSubResData> &SubResouces, const TextureDesc &TexDesc, const float *ColorOffset) -{ - Data.clear(); - Uint32 CurrLevelOffset = 0; - std::vector<Uint32> LevelDataOffsets(TexDesc.MipLevels); - SubResouces.resize(TexDesc.MipLevels); - - auto PixelFormatAttribs = pRenderDevice->GetTextureFormatInfoExt(TexDesc.Format); - auto PixelSize = Uint32{PixelFormatAttribs.ComponentSize} * Uint32{PixelFormatAttribs.NumComponents}; - - for(Uint32 Level = 0; Level < TexDesc.MipLevels; ++Level) - { - Uint32 MipWidth = TexDesc.Width >> Level; - Uint32 MipHeight = TexDesc.Height >> Level; - auto Stride = (MipWidth + 64) * PixelSize; - - Data.resize(Data.size() + size_t{Stride} * size_t{MipHeight}); - auto *pCurrLevelPtr = &Data[CurrLevelOffset]; - LevelDataOffsets[Level] = CurrLevelOffset; - SubResouces[Level].Stride = Stride; - for(Uint32 j=0; j<MipHeight; ++j) - for(Uint32 i=0; i<MipWidth; ++i) - { - float Color[4] = - { - (float)i/(float)MipWidth * 1.5f + (ColorOffset ? ColorOffset[0] : 0.f), - (float)j/(float)MipHeight * 1.7f+ (ColorOffset ? ColorOffset[1] : 0.f), - (float)j/(float)MipHeight / 1.3f + (float)i/(float)MipWidth/1.1f + (ColorOffset ? ColorOffset[2] : 0.f), - 1.f + (ColorOffset ? ColorOffset[3] : 0.f) - }; - for(Uint32 iCmp = 0; iCmp < PixelFormatAttribs.NumComponents; ++iCmp) - { - float fCurrCmpCol = Color[iCmp]; - fCurrCmpCol = fCurrCmpCol - floor(fCurrCmpCol); - void *pDstCmp = pCurrLevelPtr + (i*size_t{PixelSize} + iCmp * size_t{PixelFormatAttribs.ComponentSize} + j*size_t{Stride}); - switch(PixelFormatAttribs.ComponentType) - { - case COMPONENT_TYPE_FLOAT: - *((float*)pDstCmp) = fCurrCmpCol; - break; - - case COMPONENT_TYPE_SNORM: - if( PixelFormatAttribs.ComponentSize == 1 ) - *((Int8*)pDstCmp) = (Int8) std::min( std::max(fCurrCmpCol*127.f, -127.f), 127.f ); - else if( PixelFormatAttribs.ComponentSize == 2 ) - *((Int16*)pDstCmp) = (Int16) std::min( std::max(fCurrCmpCol*32767.f, -32767.f), 32767.f ); - else - assert(false); - break; - - case COMPONENT_TYPE_UNORM_SRGB: - case COMPONENT_TYPE_UNORM: - if( PixelFormatAttribs.ComponentSize == 1 ) - *((Uint8*)pDstCmp) = (Uint8) std::min( std::max(fCurrCmpCol*255,0.f), 255.f ); - else if( PixelFormatAttribs.ComponentSize == 2 ) - *((Uint16*)pDstCmp) = (Uint16) std::min( std::max(fCurrCmpCol*65535.f,0.f), 65535.f ); - else - assert(false); - break; - - case COMPONENT_TYPE_SINT: - if( PixelFormatAttribs.ComponentSize == 1 ) - *((Int8*)pDstCmp) = (Int8) std::min( std::max(fCurrCmpCol*127.f, -127.f), 127.f ); - else if( PixelFormatAttribs.ComponentSize == 2 ) - *((Int16*)pDstCmp) = (Int16) std::min( std::max(fCurrCmpCol*127.f, -127.f), 127.f ); - else - assert(false); - break; - - case COMPONENT_TYPE_UINT: - if( PixelFormatAttribs.ComponentSize == 1 ) - *((Uint8*)pDstCmp) = (Uint8) std::min( std::max(fCurrCmpCol*255,0.f), 255.f ); - else if( PixelFormatAttribs.ComponentSize == 2 ) - *((Uint16*)pDstCmp) = (Uint16) std::min( std::max(fCurrCmpCol*255,0.f), 255.f ); - else - assert(false); - break; - - default: assert("Unsupport component type" && false); - } - } - } - CurrLevelOffset += Stride * MipHeight; - } - for(Uint32 Level = 0; Level < TexDesc.MipLevels; ++Level) - { - SubResouces[Level].pData = Data.data() + LevelDataOffsets[Level]; - } -} - - -void TestTexturing::Init( IRenderDevice *pDevice, IDeviceContext *pDeviceContext, ISwapChain *pSwapChain, TEXTURE_FORMAT TexFormat, float fMinXCoord, float fMinYCoord, float fXExtent, float fYExtent ) -{ - m_pRenderDevice = pDevice; - m_TextureFormat = TexFormat; - m_pDeviceContext = pDeviceContext; - auto DevType = m_pRenderDevice->GetDeviceCaps().DevType; - bool bUseGLSL = DevType == DeviceType::OpenGL || DevType == DeviceType::OpenGLES || DevType == DeviceType::Vulkan; - - float Vertices[] = - { - 0, 0, 0, 0,1, - 0, 1, 0, 0,0, - 1, 0, 0, 1,1, - 1, 1, 0, 1,0 - }; - 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; - } - - { - Diligent::BufferDesc BuffDesc; - BuffDesc.uiSizeInBytes = sizeof(Vertices); - BuffDesc.BindFlags = BIND_VERTEX_BUFFER; - BuffDesc.Usage = USAGE_STATIC; - Diligent::BufferData BuffData; - BuffData.pData = Vertices; - BuffData.DataSize = BuffDesc.uiSizeInBytes; - m_pRenderDevice->CreateBuffer(BuffDesc, &BuffData, &m_pVertexBuff); - } - - auto PixelFormatAttribs = m_pRenderDevice->GetTextureFormatInfoExt(m_TextureFormat); - - ShaderCreateInfo CreationAttrs; - RefCntAutoPtr<IShaderSourceInputStreamFactory> pShaderSourceFactory; - pDevice->GetEngineFactory()->CreateDefaultShaderSourceStreamFactory("Shaders", &pShaderSourceFactory); - CreationAttrs.pShaderSourceStreamFactory = pShaderSourceFactory; - CreationAttrs.UseCombinedTextureSamplers = true; - - RefCntAutoPtr<Diligent::IShader> pVS, pPS; - { - CreationAttrs.FilePath = bUseGLSL ? "Shaders\\TextureTestGL.vsh" : "Shaders\\TextureTestDX.vsh"; - CreationAttrs.Desc.ShaderType = SHADER_TYPE_VERTEX; - m_pRenderDevice->CreateShader( CreationAttrs, &pVS ); - } - - bool bIsIntTexture = false; - { - ShaderMacroHelper Macros; - if (PixelFormatAttribs.ComponentType == COMPONENT_TYPE_UINT || - PixelFormatAttribs.ComponentType == COMPONENT_TYPE_SINT) - { - if (bUseGLSL) - { - CreationAttrs.FilePath = "Shaders\\TextureIntTestGL.psh"; - Macros.AddShaderMacro("SAMPLER_TYPE", PixelFormatAttribs.ComponentType == COMPONENT_TYPE_UINT ? "usampler2D" : "isampler2D"); - } - else - { - CreationAttrs.FilePath = "Shaders\\TextureIntTestDX.psh"; - Macros.AddShaderMacro("DATA_TYPE", PixelFormatAttribs.ComponentType == COMPONENT_TYPE_UINT ? "uint4" : "int4"); - } - - bIsIntTexture = true; - } - else - { - CreationAttrs.FilePath = bUseGLSL ? "Shaders\\TextureTestGL.psh" : "Shaders\\TextureTestDX.psh"; - bIsIntTexture = false; - } - CreationAttrs.Desc.ShaderType = SHADER_TYPE_PIXEL; - CreationAttrs.Macros = Macros; - m_pRenderDevice->CreateShader( CreationAttrs, &pPS ); - } - - { - SamplerDesc SamplerDesc; - // On Intel HW, only point filtering sampler correctly works with an integer texture. - // If the sampler defines linear filtering, the texture is not properly bound to the - // sampler unit and zero is always returned. - // Note that on NVidia HW this works fine. - auto FilterType = bIsIntTexture ? FILTER_TYPE_POINT : FILTER_TYPE_LINEAR; - SamplerDesc.MinFilter = FilterType; - SamplerDesc.MagFilter = FilterType; - SamplerDesc.MipFilter = FilterType; - m_pRenderDevice->CreateSampler( SamplerDesc, &m_pSampler ); - } - - { - TextureDesc TexDesc; - TexDesc.Type = RESOURCE_DIM_TEX_2D; - TexDesc.Width = m_iTestTexWidth; - TexDesc.Height = m_iTestTexHeight; - TexDesc.MipLevels = m_iMipLevels; - TexDesc.Usage = USAGE_STATIC; - TexDesc.Format = m_TextureFormat; - TexDesc.BindFlags = BIND_SHADER_RESOURCE; - TexDesc.Name = "Test Texture"; - - std::vector<Uint8> Data; - std::vector<TextureSubResData> SubResouces; - GenerateTextureData(m_pRenderDevice, Data, SubResouces, TexDesc); - TextureData TexData; - TexData.pSubResources = SubResouces.data(); - TexData.NumSubresources = (Uint32)SubResouces.size(); - - m_pRenderDevice->CreateTexture( TexDesc, &TexData, &m_pTexture ); - } - - { - RefCntAutoPtr<ITextureView> pDefaultSRV; - TextureViewDesc ViewDesc; - ViewDesc.ViewType = TEXTURE_VIEW_SHADER_RESOURCE; - ViewDesc.NumMipLevels = TextureViewDesc::RemainingMipLevels; - ViewDesc.NumArraySlices = TextureViewDesc::RemainingArraySlices; - m_pTexture->CreateView( ViewDesc, &pDefaultSRV ); - pDefaultSRV->SetSampler( m_pSampler ); - ResourceMappingEntry Entries[] = { { "g_tex2DTest", pDefaultSRV }, {nullptr, nullptr} }; - ResourceMappingDesc ResourceMapping; - ResourceMapping.pEntries = Entries; - m_pRenderDevice->CreateResourceMapping( ResourceMapping, &m_pResourceMapping ); - } - PipelineStateDesc PSODesc; - 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.RTVFormats[0] = pSwapChain->GetDesc().ColorBufferFormat; - PSODesc.GraphicsPipeline.DSVFormat = pSwapChain->GetDesc().DepthBufferFormat; - PSODesc.GraphicsPipeline.NumRenderTargets = 1; - PSODesc.GraphicsPipeline.pVS = pVS; - PSODesc.GraphicsPipeline.pPS = pPS; - PSODesc.GraphicsPipeline.PrimitiveTopology = PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; - - LayoutElement Elems[] = - { - LayoutElement{ 0, 0, 3, Diligent::VT_FLOAT32, false, 0 }, - LayoutElement{ 1, 0, 2, Diligent::VT_FLOAT32, false, sizeof( float ) * 3 } - }; - PSODesc.GraphicsPipeline.InputLayout.LayoutElements = Elems; - PSODesc.GraphicsPipeline.InputLayout.NumElements = _countof( Elems ); - - StaticSamplerDesc StaticSampler; - // On Intel HW, only point filtering sampler correctly works with an integer texture. - // If the sampler defines linear filtering, the texture is not properly bound to the - // sampler unit and zero is always returned. - // Note that on NVidia HW this works fine. - auto FilterType = bIsIntTexture ? FILTER_TYPE_POINT : FILTER_TYPE_LINEAR; - StaticSampler.Desc.MinFilter = FilterType; - StaticSampler.Desc.MagFilter = FilterType; - StaticSampler.Desc.MipFilter = FilterType; - StaticSampler.ShaderStages = SHADER_TYPE_PIXEL; - StaticSampler.SamplerOrTextureName = "g_tex2DTest"; - PSODesc.ResourceLayout.NumStaticSamplers = !(bIsIntTexture && pDevice->GetDeviceCaps().IsD3DDevice()) ? 1 : 0; - PSODesc.ResourceLayout.StaticSamplers = &StaticSampler; - - pDevice->CreatePipelineState(PSODesc, &m_pPSO); - - m_pPSO->BindStaticResources(SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, m_pResourceMapping, 0); - - m_pPSO->CreateShaderResourceBinding(&m_pSRB, true); - - auto *FmtName = pDevice->GetTextureFormatInfo(TexFormat).Name; - m_TestName.append(" ("); - m_TestName.append(FmtName); - m_TestName.append(")"); -} - -void TestTexturing::Draw() -{ - m_pDeviceContext->SetPipelineState(m_pPSO); - m_pDeviceContext->TransitionShaderResources(m_pPSO, m_pSRB); - m_pDeviceContext->CommitShaderResources(m_pSRB, RESOURCE_STATE_TRANSITION_MODE_VERIFY); - - IBuffer *pBuffs[] = {m_pVertexBuff}; - Uint32 Offsets[] = {0}; - m_pDeviceContext->SetVertexBuffers( 0, 1, pBuffs, Offsets, RESOURCE_STATE_TRANSITION_MODE_TRANSITION, SET_VERTEX_BUFFERS_FLAG_RESET ); - - // Draw quad - Diligent::DrawAttribs DrawAttrs(4, DRAW_FLAG_VERIFY_ALL); - m_pDeviceContext->Draw( DrawAttrs ); - - SetStatus(TestResult::Succeeded); -} diff --git a/Tests/TestApp/src/TestVPAndSR.cpp b/Tests/TestApp/src/TestVPAndSR.cpp deleted file mode 100644 index 8cd9f86..0000000 --- a/Tests/TestApp/src/TestVPAndSR.cpp +++ /dev/null @@ -1,49 +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 "pch.h" -#include "TestVPAndSR.h" -#include "GraphicsUtilities.h" - -using namespace Diligent; - -TestVPAndSR::TestVPAndSR(IRenderDevice *pDevice, IDeviceContext *pContext ) : - UnitTestBase("Viewport and scissor rect test") -{ - m_pRenderDevice = pDevice; - m_pDeviceContext = pContext; -#if 0 - m_pRenderScript = CreateRenderScriptFromFile( "VPAndSRTest.lua", pDevice, pContext, []( ScriptParser *pScriptParser ) - { - Viewport VP(16.5, 24.25, 156.125, 381.625, 0.25, 0.75); - pScriptParser->SetGlobalVariable( "TestGlobalVP", VP ); - - Rect SR(10, 30, 200, 300); - pScriptParser->SetGlobalVariable( "TestGlobalSR", SR ); - } ); - - m_pRenderScript->Run( m_pDeviceContext, "SetViewports" ); - m_pRenderScript->Run( m_pDeviceContext, "SetScissorRects" ); -#endif - SetStatus(TestResult::Succeeded); -} diff --git a/Tests/TestApp/src/UWP/TestAppUWP.cpp b/Tests/TestApp/src/UWP/TestAppUWP.cpp deleted file mode 100644 index 3c8fa2e..0000000 --- a/Tests/TestApp/src/UWP/TestAppUWP.cpp +++ /dev/null @@ -1,212 +0,0 @@ -/* Copyright 2015-2018 Egor Yusov -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. -* -* In no event and under no legal theory, whether in tort (including negligence), -* contract, or otherwise, unless required by applicable law (such as deliberate -* and grossly negligent acts) or agreed to in writing, shall any Contributor be -* liable for any damages, including any direct, indirect, special, incidental, -* or consequential damages of any character arising as a result of this License or -* out of the use or inability to use the software (including but not limited to damages -* for loss of goodwill, work stoppage, computer failure or malfunction, or any and -* all other commercial damages or losses), even if such Contributor has been advised -* of the possibility of such damages. -*/ - -#include "TestApp.h" -#include "RenderDeviceD3D12.h" -#include "RenderDeviceD3D11.h" -#include "SwapChainD3D12.h" -#include "SwapChainD3D11.h" -#include "EngineFactoryD3D11.h" -#include "EngineFactoryD3D12.h" - -namespace Diligent -{ - -class TestAppUWP final : public TestApp -{ -public: - TestAppUWP() - { - m_DeviceType = DeviceType::D3D12; - } - - virtual void OnWindowSizeChanged()override final - { - InitWindowSizeDependentResources(); - } - - virtual void Render()override - { - // Don't try to render anything before the first Update. - if (m_timer.GetFrameCount() == 0) - { - return; - } - TestApp::Render(); - m_bFrameReady = true; - } - - // Notifies the app that it is being suspended. - virtual void OnSuspending()override final - { - // TODO: Replace this with your app's suspending logic. - - // Process lifetime management may terminate suspended apps at any time, so it is - // good practice to save any state that will allow the app to restart where it left off. - - //m_sceneRenderer->SaveState(); - - // If your application uses video memory allocations that are easy to re-create, - // consider releasing that memory to make it available to other applications. - } - - // Notifes the app that it is no longer suspended. - virtual void OnResuming()override final - { - // TODO: Replace this with your app's resuming logic. - } - - // Notifies renderers that device resources need to be released. - virtual void OnDeviceRemoved()override final - { - // TODO: Save any necessary application or renderer state and release the renderer - // and its resources which are no longer valid. - //m_sceneRenderer->SaveState(); - } - - virtual void Present()override - { - m_pSwapChain->Present(); - - //// If the device was removed either by a disconnection or a driver upgrade, we - //// must recreate all device resources. - //if (hr == DXGI_ERROR_DEVICE_REMOVED || hr == DXGI_ERROR_DEVICE_RESET) - //{ - // m_deviceRemoved = true; - //} - //else - //{ - // DX::ThrowIfFailed(hr); - //} - } - - virtual std::shared_ptr<DX::DeviceResources> InitDeviceResources()override - { - InitializeDiligentEngine(nullptr); - - ID3D12Device *pd3d12Device = nullptr; - ID3D11Device *pd3d11Device = nullptr; - if (m_DeviceType == DeviceType::D3D12) - { - // Store pointers to the Direct3D 11.1 API device and immediate context. - RefCntAutoPtr<IRenderDeviceD3D12> pRenderDeviceD3D12(m_pDevice, IID_RenderDeviceD3D12); - pd3d12Device = pRenderDeviceD3D12->GetD3D12Device(); - } - else if (m_DeviceType == DeviceType::D3D11) - { - RefCntAutoPtr<IRenderDeviceD3D11> pRenderDeviceD3D11(m_pDevice, IID_RenderDeviceD3D11); - pd3d11Device = pRenderDeviceD3D11->GetD3D11Device(); - } - else - { - UNEXPECTED("Unexpected device type"); - } - m_DeviceResources = std::make_shared<DX::DeviceResources>(pd3d11Device, pd3d12Device); - - return m_DeviceResources; - } - - virtual void InitWindowSizeDependentResources()override - { - m_DeviceResources->UpdateRenderTargetSize(); - auto backBufferWidth = m_DeviceResources->GetBackBufferWidth(); - auto backBufferHeight = m_DeviceResources->GetBackBufferHeight(); - - if (m_swapChain != nullptr) - { - m_swapChain.Reset(); - - // If the swap chain already exists, resize it. - m_pSwapChain->Resize(backBufferWidth, backBufferHeight); - - #if 0 - if (hr == DXGI_ERROR_DEVICE_REMOVED || hr == DXGI_ERROR_DEVICE_RESET) - { - // If the device was removed for any reason, a new device and swap chain will need to be created. - m_deviceRemoved = true; - - // Do not continue execution of this method. DeviceResources will be destroyed and re-created. - return; - } - else - { - DX::ThrowIfFailed(hr); - } - #endif - } - else - { - //DXGI_SCALING scaling = DisplayMetrics::SupportHighResolutions ? DXGI_SCALING_NONE : DXGI_SCALING_STRETCH; - SwapChainDesc SCDesc; - SCDesc.Width = backBufferWidth; - SCDesc.Height = backBufferHeight; - SCDesc.ColorBufferFormat = TEX_FORMAT_RGBA8_UNORM_SRGB; - SCDesc.DepthBufferFormat = TEX_FORMAT_D32_FLOAT; - auto window = m_DeviceResources->GetWindow(); - IDXGISwapChain3 *pDXGISwapChain3 = nullptr; - if (m_DeviceType == DeviceType::D3D12) - { - GetEngineFactoryD3D12()->CreateSwapChainD3D12(m_pDevice, m_pImmediateContext, SCDesc, FullScreenModeDesc{}, reinterpret_cast<IUnknown*>(window), &m_pSwapChain); - } - else if (m_DeviceType == DeviceType::D3D11) - { - GetEngineFactoryD3D11()->CreateSwapChainD3D11(m_pDevice, m_pImmediateContext, SCDesc, FullScreenModeDesc{}, reinterpret_cast<IUnknown*>(window), &m_pSwapChain); - } - else - UNEXPECTED("Unexpected device type"); - } - - IDXGISwapChain3 *pDXGISwapChain3 = nullptr; - if (m_DeviceType == DeviceType::D3D12) - { - RefCntAutoPtr<ISwapChainD3D12> pSwapChainD3D12(m_pSwapChain, IID_SwapChainD3D12); - pSwapChainD3D12->GetDXGISwapChain()->QueryInterface(__uuidof(pDXGISwapChain3), reinterpret_cast<void**>(&pDXGISwapChain3)); - } - else if (m_DeviceType == DeviceType::D3D11) - { - RefCntAutoPtr<ISwapChainD3D11> pSwapChainD3D11(m_pSwapChain, IID_SwapChainD3D11); - pSwapChainD3D11->GetDXGISwapChain()->QueryInterface(__uuidof(pDXGISwapChain3), reinterpret_cast<void**>(&pDXGISwapChain3)); - } - else - UNEXPECTED("Unexpected device type"); - m_swapChain.Attach(pDXGISwapChain3); - - m_DeviceResources->SetSwapChainRotation(m_swapChain.Get()); - } - - virtual void CreateRenderers()override - { - InitializeRenderers(); - } - -private: - Microsoft::WRL::ComPtr<IDXGISwapChain3> m_swapChain; -}; - - -NativeAppBase* CreateApplication() -{ - return new TestAppUWP; -} - -} diff --git a/Tests/TestApp/src/UnitTestBase.cpp b/Tests/TestApp/src/UnitTestBase.cpp deleted file mode 100644 index 5421c7a..0000000 --- a/Tests/TestApp/src/UnitTestBase.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 <iomanip> -#include <ios> - -#include "pch.h" -#include "UnitTestBase.h" -#include "Errors.h" - -using namespace Diligent; - -int UnitTestBase::m_TotalTests = 0; -size_t UnitTestBase::m_MaxNameLen = 0; - -UnitTestBase::UnitTestBase(const char *Name) : - m_TestName(Name) -{ - m_MaxNameLen = std::max(m_MaxNameLen, m_TestName.length()); - m_TestNum = ++m_TotalTests; - LOG_INFO_MESSAGE("Created test ", m_TestNum, ": ", Name); -} - -UnitTestBase::~UnitTestBase() -{ - const char* TestResltStr[] = - { - "UNKNOWN", - "SKIPPED", - "FAILED", - "SUCCEEDED" - }; - LOG_INFO_MESSAGE("Test ", std::setw(2), m_TestNum, "/", m_TotalTests, " - ", std::setw(m_MaxNameLen), std::left, m_TestName, " : ", - TestResltStr[static_cast<int>(m_TestResult)], ". ", m_TestResultInfo); -} diff --git a/Tests/TestApp/src/Win32/TestAppWin32.cpp b/Tests/TestApp/src/Win32/TestAppWin32.cpp deleted file mode 100644 index 5365123..0000000 --- a/Tests/TestApp/src/Win32/TestAppWin32.cpp +++ /dev/null @@ -1,44 +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 "TestApp.h" - -namespace Diligent -{ - -class TestAppWin32 final : public TestApp -{ -public: - virtual void OnWindowCreated(HWND hWnd, LONG WindowWidth, LONG WindowHeight)override final - { - InitializeDiligentEngine(hWnd); - InitializeRenderers(); - } -}; - -NativeAppBase* CreateApplication() -{ - return new TestAppWin32; -} - -} diff --git a/Tests/TestApp/src/pch.cpp b/Tests/TestApp/src/pch.cpp deleted file mode 100644 index ee46a4a..0000000 --- a/Tests/TestApp/src/pch.cpp +++ /dev/null @@ -1,31 +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. - */ - -// stdafx.cpp : source file that includes just the standard includes -// EngineSandbox.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "pch.h" - -// TODO: reference any additional headers you need in STDAFX.H -// and not in this file |
