summaryrefslogtreecommitdiffstats
path: root/Tests/TestApp/src
diff options
context:
space:
mode:
authorassiduous <assiduous@diligentgraphics.com>2019-12-12 22:41:17 +0000
committerassiduous <assiduous@diligentgraphics.com>2019-12-12 22:41:17 +0000
commit80bfa52139976bd51b43c58e9576d379fe9f8a14 (patch)
tree3d7663ef18296eb5cc6de7fedeb8a1fc1e4d372f /Tests/TestApp/src
parentUpdated core & tools. Fixed https://github.com/DiligentGraphics/DiligentEngin... (diff)
downloadDiligentEngine-80bfa52139976bd51b43c58e9576d379fe9f8a14.tar.gz
DiligentEngine-80bfa52139976bd51b43c58e9576d379fe9f8a14.zip
Updated submodules (added unit tests). Reworked TestApp
Diffstat (limited to 'Tests/TestApp/src')
-rw-r--r--Tests/TestApp/src/MTResourceCreationTest.cpp261
-rw-r--r--Tests/TestApp/src/RenderScriptTest.cpp3
-rw-r--r--Tests/TestApp/src/ResourceReleaseQueueTest.cpp129
-rw-r--r--Tests/TestApp/src/ShaderConverterTest.cpp107
-rw-r--r--Tests/TestApp/src/TestApp.cpp108
-rw-r--r--Tests/TestApp/src/TestBlendState.cpp261
-rw-r--r--Tests/TestApp/src/TestBrokenShader.cpp63
-rw-r--r--Tests/TestApp/src/TestBufferAccess.cpp3
-rw-r--r--Tests/TestApp/src/TestBufferCreation.cpp201
-rw-r--r--Tests/TestApp/src/TestComputeShaders.cpp3
-rw-r--r--Tests/TestApp/src/TestCreateObjFromNativeResD3D11.cpp109
-rw-r--r--Tests/TestApp/src/TestCreateObjFromNativeResD3D12.cpp79
-rw-r--r--Tests/TestApp/src/TestCreateObjFromNativeResGL.cpp143
-rw-r--r--Tests/TestApp/src/TestCreateObjFromNativeResVK.cpp82
-rw-r--r--Tests/TestApp/src/TestDepthStencilState.cpp172
-rw-r--r--Tests/TestApp/src/TestDrawCommands.cpp3
-rw-r--r--Tests/TestApp/src/TestGeometryShader.cpp3
-rw-r--r--Tests/TestApp/src/TestMipMapsGeneration.cpp101
-rw-r--r--Tests/TestApp/src/TestPSOCompatibility.cpp302
-rw-r--r--Tests/TestApp/src/TestPipelineStateBase.cpp67
-rw-r--r--Tests/TestApp/src/TestRasterizerState.cpp135
-rw-r--r--Tests/TestApp/src/TestRenderTarget.cpp3
-rw-r--r--Tests/TestApp/src/TestSamplerCreation.cpp129
-rw-r--r--Tests/TestApp/src/TestSeparateTextureSampler.cpp177
-rw-r--r--Tests/TestApp/src/TestShaderResArrays.cpp195
-rw-r--r--Tests/TestApp/src/TestShaderResourceLayout.cpp447
-rw-r--r--Tests/TestApp/src/TestShaderVarAccess.cpp649
-rw-r--r--Tests/TestApp/src/TestTessellation.cpp3
-rw-r--r--Tests/TestApp/src/TestTextureCreation.cpp987
-rw-r--r--Tests/TestApp/src/TestTexturing.cpp3
-rw-r--r--Tests/TestApp/src/TestVPAndSR.cpp3
-rw-r--r--Tests/TestApp/src/UnitTestBase.cpp3
-rw-r--r--Tests/TestApp/src/VarSizeAllocationsManagerTest.cpp183
33 files changed, 5 insertions, 5112 deletions
diff --git a/Tests/TestApp/src/MTResourceCreationTest.cpp b/Tests/TestApp/src/MTResourceCreationTest.cpp
deleted file mode 100644
index 519a712..0000000
--- a/Tests/TestApp/src/MTResourceCreationTest.cpp
+++ /dev/null
@@ -1,261 +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.
- */
-
-// EngineSandbox.cpp : Defines the entry point for the application.
-//
-
-#include "pch.h"
-#include "MTResourceCreationTest.h"
-#include "Errors.h"
-
-using namespace Diligent;
-
-static const char g_ShaderSource[] =
-"void VSMain(out float4 pos : SV_POSITION) \n"
-"{ \n"
-" pos = float4(0.0, 0.0, 0.0, 0.0); \n"
-"} \n"
-" \n"
-"void PSMain(out float4 col : SV_TARGET)\n"
-"{ \n"
-" col = float4(0.0, 0.0, 0.0, 0.0); \n"
-"} \n"
-;
-
-MTResourceCreationTest::MTResourceCreationTest(IRenderDevice *pDevice, IDeviceContext *pContext, Uint32 NumThreads) :
- UnitTestBase("Multithreaded resource creation"),
- m_pDevice(pDevice),
- m_pContext(pContext)
-{
- m_NumThreadsCompleted = 0;
- m_NumBuffersCreated = 0;
- m_NumTexturesCreated = 0;
- m_NumPSOCreated = 0;
-
- auto &DevCaps = m_pDevice->GetDeviceCaps();
- if (DevCaps.bMultithreadedResourceCreationSupported)
- {
- m_Threads.resize(NumThreads);
- }
- else
- {
- LOG_WARNING_MESSAGE("Multithreaded resource creation is not supported on this device");
- }
-}
-
-void MTResourceCreationTest::WaitForThreadStart(int VarId)
-{
- std::unique_lock<std::mutex> lk(m_Mtx);
- m_CondVar.wait(lk, [&]{return m_bReleaseThread[VarId];});
-}
-
-void MTResourceCreationTest::WaitThreads(int VarId)
-{
- while((size_t)m_NumThreadsCompleted < m_Threads.size())
- std::this_thread::yield();
- m_bReleaseThread[VarId] = false;
- VERIFY_EXPR(m_NumThreadsCompleted == m_Threads.size());
-}
-
-void MTResourceCreationTest::StartThreads(int VarId)
-{
- {
- std::unique_lock<std::mutex> lk(m_Mtx);
- m_bReleaseThread[VarId] = true;
- m_NumThreadsCompleted = 0;
- }
- m_CondVar.notify_all();
-}
-
-static Uint8 RawBufferData[1024];
-static Uint8 RawTextureData[1024*1024*4];
-
-void MTResourceCreationTest::ThreadWorkerFunc(bool bIsMasterThread)
-{
- while (!m_bStopThreadsFlagInternal)
- {
- if (bIsMasterThread)
- StartThreads(0);
- else
- WaitForThreadStart(0);
-
- RefCntAutoPtr<IBuffer> pBuffer1, pBuffer2,pBuffer3,pBuffer4;
- RefCntAutoPtr<IBufferView> pBufferSRV, pBufferUAV;
- {
- BufferDesc BuffDesc;
- BuffDesc.Usage = USAGE_DEFAULT;
- BuffDesc.BindFlags = BIND_UNIFORM_BUFFER;
- BuffDesc.Name = "MT test buffer";
- BuffDesc.uiSizeInBytes = sizeof(RawBufferData);
-
- BufferData BuffData;
- BuffData.DataSize = BuffDesc.uiSizeInBytes;
- BuffData.pData = RawBufferData;
-
- m_pDevice->CreateBuffer(BuffDesc, &BuffData, &pBuffer1);
-
- BuffDesc.Mode = BUFFER_MODE_FORMATTED;
- BuffDesc.ElementByteStride = 16;
- BuffDesc.BindFlags = BIND_SHADER_RESOURCE|BIND_UNORDERED_ACCESS;
- m_pDevice->CreateBuffer(BuffDesc, &BuffData, &pBuffer2);
-
- BufferViewDesc ViewDesc;
- ViewDesc.ViewType = BUFFER_VIEW_SHADER_RESOURCE;
- ViewDesc.ByteOffset = 16;
- ViewDesc.Format.NumComponents = 4;
- ViewDesc.Format.IsNormalized = False;
- ViewDesc.Format.ValueType = VT_FLOAT32;
- pBuffer2->CreateView(ViewDesc, &pBufferSRV);
-
- BuffDesc.BindFlags = BIND_VERTEX_BUFFER | BIND_UNORDERED_ACCESS;
- m_pDevice->CreateBuffer(BuffDesc, &BuffData, &pBuffer3);
- ViewDesc.ViewType = BUFFER_VIEW_UNORDERED_ACCESS;
- pBuffer3->CreateView(ViewDesc, &pBufferUAV);
-
- BuffDesc.Mode = BUFFER_MODE_RAW;
- BuffDesc.BindFlags = BIND_INDEX_BUFFER|BIND_UNORDERED_ACCESS;
- m_pDevice->CreateBuffer(BuffDesc, &BuffData, &pBuffer4);
-
- m_NumBuffersCreated += 4;
-
- ++m_NumThreadsCompleted;
- }
-
- if (bIsMasterThread)
- {
- WaitThreads(0);
-
- // This is the sync point. All threads must reach this point before
- // master thread can proceed. Othre threads are now waiting for StartThreads(1);
- // When we set m_bStopThreadsFlagInternal here,
- // we make sure all threads will exit simultaneously
- m_bStopThreadsFlagInternal = m_bStopThreadsFlag;
-
- StartThreads(1);
- }
- else
- WaitForThreadStart(1);
-
- RefCntAutoPtr<ITexture> pTexture;
- {
- TextureDesc TexDesc;
- TexDesc.BindFlags = BIND_SHADER_RESOURCE | BIND_RENDER_TARGET | BIND_UNORDERED_ACCESS;
- TexDesc.Type = RESOURCE_DIM_TEX_2D;
- TexDesc.Width = 1024;
- TexDesc.Height = 1024;
- TexDesc.Format = TEX_FORMAT_RGBA8_UNORM;
- TexDesc.MipLevels = 1;
-
-
- TextureSubResData SubResData;
- SubResData.pData = RawTextureData;
- SubResData.Stride = TexDesc.Width*4;
-
- TextureData TexData;
- TexData.NumSubresources = 1;
- TexData.pSubResources = &SubResData;
-
- m_pDevice->CreateTexture(TexDesc, &TexData, &pTexture);
- ++m_NumTexturesCreated;
-
- ++m_NumThreadsCompleted;
- }
-
-
- if (bIsMasterThread)
- {
- WaitThreads(1);
- StartThreads(0);
- }
- else
- WaitForThreadStart(0);
-
-
- RefCntAutoPtr<IShader> pTrivialVS, pTrivialPS;
- RefCntAutoPtr<IPipelineState> pPSO;
- {
- ShaderCreateInfo Attrs;
- Attrs.Source = g_ShaderSource;
- Attrs.EntryPoint = "VSMain";
- Attrs.Desc.ShaderType = SHADER_TYPE_VERTEX;
- Attrs.Desc.Name = "TrivialVS (MTResourceCreationTest)";
- Attrs.SourceLanguage = SHADER_SOURCE_LANGUAGE_HLSL;
- Attrs.UseCombinedTextureSamplers = true;
- m_pDevice->CreateShader(Attrs, &pTrivialVS);
-
- Attrs.EntryPoint = "PSMain";
- Attrs.Desc.ShaderType = SHADER_TYPE_PIXEL;
- Attrs.Desc.Name = "TrivialPS (MTResourceCreationTest)";
- m_pDevice->CreateShader(Attrs, &pTrivialPS);
-
- PipelineStateDesc PSODesc;
- PSODesc.GraphicsPipeline.pVS = pTrivialVS;
- PSODesc.GraphicsPipeline.pPS = pTrivialPS;
- PSODesc.GraphicsPipeline.PrimitiveTopology = PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP;
- PSODesc.GraphicsPipeline.NumRenderTargets = 1;
- PSODesc.GraphicsPipeline.RTVFormats[0] = TEX_FORMAT_RGBA8_UNORM;
- PSODesc.GraphicsPipeline.DSVFormat = TEX_FORMAT_D32_FLOAT;
-
- m_pDevice->CreatePipelineState(PSODesc, &pPSO);
- ++m_NumPSOCreated;
-
- ++m_NumThreadsCompleted;
- }
-
- if (bIsMasterThread)
- {
- WaitThreads(0);
- StartThreads(1);
- }
- else
- WaitForThreadStart(1);
-
-
- {
-
- ++m_NumThreadsCompleted;
- }
-
- std::this_thread::sleep_for(std::chrono::milliseconds(1));
-
- if (bIsMasterThread)
- WaitThreads(1);
- }
-}
-
-void MTResourceCreationTest::StartThreads()
-{
- for(size_t t=0; t < m_Threads.size(); ++t)
- m_Threads[t] = std::thread(&MTResourceCreationTest::ThreadWorkerFunc, this, t == 0);
-}
-
-void MTResourceCreationTest::StopThreads()
-{
- m_bStopThreadsFlag = true;
- for(auto &t : m_Threads)
- t.join();
-
- std::stringstream infoss;
- infoss << "Buffers created: " << m_NumBuffersCreated << " Textures created: " << m_NumTexturesCreated << " PSO Created: " << m_NumPSOCreated;
- SetStatus(m_Threads.empty() ? TestResult::Skipped : TestResult::Succeeded, infoss.str().c_str());
-}
diff --git a/Tests/TestApp/src/RenderScriptTest.cpp b/Tests/TestApp/src/RenderScriptTest.cpp
index e847d26..ff8d1d4 100644
--- a/Tests/TestApp/src/RenderScriptTest.cpp
+++ b/Tests/TestApp/src/RenderScriptTest.cpp
@@ -21,9 +21,6 @@
* of the possibility of such damages.
*/
-// EngineSandbox.cpp : Defines the entry point for the application.
-//
-
#include "pch.h"
#include "RenderScriptTest.h"
#include "FileSystem.h"
diff --git a/Tests/TestApp/src/ResourceReleaseQueueTest.cpp b/Tests/TestApp/src/ResourceReleaseQueueTest.cpp
deleted file mode 100644
index 500b5a7..0000000
--- a/Tests/TestApp/src/ResourceReleaseQueueTest.cpp
+++ /dev/null
@@ -1,129 +0,0 @@
-/* Copyright 2019 Diligent Graphics LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS.
- *
- * In no event and under no legal theory, whether in tort (including negligence),
- * contract, or otherwise, unless required by applicable law (such as deliberate
- * and grossly negligent acts) or agreed to in writing, shall any Contributor be
- * liable for any damages, including any direct, indirect, special, incidental,
- * or consequential damages of any character arising as a result of this License or
- * out of the use or inability to use the software (including but not limited to damages
- * for loss of goodwill, work stoppage, computer failure or malfunction, or any and
- * all other commercial damages or losses), even if such Contributor has been advised
- * of the possibility of such damages.
- */
-
-// EngineSandbox.cpp : Defines the entry point for the application.
-//
-
-#include "pch.h"
-#include "Errors.h"
-#include "ResourceReleaseQueue.h"
-#include "DefaultRawMemoryAllocator.h"
-#include "UnitTestBase.h"
-#include <memory>
-
-using namespace Diligent;
-
-class ResourceReleaseQueueTest : public UnitTestBase
-{
-public:
- ResourceReleaseQueueTest() :
- UnitTestBase("Resource release queue test")
- {
- struct ResourceA
- {
- int Data = 1;
- };
- struct ResourceB
- {
- float Data = 2;
- };
- struct ResourceC
- {
- float Data[2] = {3, 4};
- };
-
- {
- ResourceReleaseQueue<DynamicStaleResourceWrapper> Queue(DefaultRawMemoryAllocator::GetAllocator());
- std::unique_ptr<ResourceA> res0(new ResourceA);
- std::unique_ptr<ResourceB> res1(new ResourceB);
-
- Queue.SafeReleaseResource(std::move(res0), 0);
- Queue.SafeReleaseResource(std::move(res1), 0);
-
- std::unique_ptr<ResourceC> res2(new ResourceC);
- auto Wrapper2 = Queue.CreateWrapper(std::move(res2), 1);
- //auto WrapperX = Queue.CreateWrapper(res2, 1);// - error
- //auto WrapperY = Queue.CreateWrapper(static_cast<std::unique_ptr<ResourceC>&>(res2), 1);// - error
- Queue.SafeReleaseResource(std::move(Wrapper2), 0);
-
- Queue.DiscardStaleResources(0, 1);
-
- std::unique_ptr<ResourceA> res4(new ResourceA);
- Queue.DiscardResource(std::move(res4), 1);
-
- std::unique_ptr<ResourceB> res5(new ResourceB);
- auto Wrapper5 = Queue.CreateWrapper(std::move(res5), 1);
- Queue.DiscardResource(std::move(Wrapper5), 1);
-
- Queue.Purge(1);
- }
-
- {
- ResourceReleaseQueue<DynamicStaleResourceWrapper> Queue0(DefaultRawMemoryAllocator::GetAllocator());
- ResourceReleaseQueue<DynamicStaleResourceWrapper> Queue1(DefaultRawMemoryAllocator::GetAllocator());
- ResourceReleaseQueue<DynamicStaleResourceWrapper> Queue2(DefaultRawMemoryAllocator::GetAllocator());
-
- std::unique_ptr<ResourceA> res0(new ResourceA);
- std::unique_ptr<ResourceB> res1(new ResourceB);
- std::unique_ptr<ResourceC> res2(new ResourceC);
-
- auto Wrapper0 = ResourceReleaseQueue<DynamicStaleResourceWrapper>::CreateWrapper(std::move(res0), 3);
- auto Wrapper1 = ResourceReleaseQueue<DynamicStaleResourceWrapper>::CreateWrapper(std::move(res1), 3);
- auto Wrapper2 = ResourceReleaseQueue<DynamicStaleResourceWrapper>::CreateWrapper(std::move(res2), 1);
-
- Queue0.SafeReleaseResource(Wrapper0, 0);
- Queue0.SafeReleaseResource(Wrapper1, 0);
- Queue0.SafeReleaseResource(Wrapper2, 0);
- Wrapper2.GiveUpOwnership();
-
- Queue1.SafeReleaseResource(Wrapper0, 0);
- Queue1.SafeReleaseResource(Wrapper1, 0);
-
- Queue2.SafeReleaseResource(std::move(Wrapper0), 0);
- Queue2.SafeReleaseResource(Wrapper1, 0);
- Wrapper1.GiveUpOwnership();
-
- Queue0.DiscardStaleResources(0, 1);
- Queue1.DiscardStaleResources(0, 1);
- Queue2.DiscardStaleResources(0, 1);
-
- std::unique_ptr<ResourceC> res3(new ResourceC);
- auto Wrapper3 = ResourceReleaseQueue<DynamicStaleResourceWrapper>::CreateWrapper(std::move(res3), 2);
- Queue0.DiscardResource(Wrapper3, 1);
- Queue1.DiscardResource(std::move(Wrapper3), 1);
-
- std::unique_ptr<ResourceA> res4(new ResourceA);
- auto Wrapper4 = ResourceReleaseQueue<DynamicStaleResourceWrapper>::CreateWrapper(std::move(res4), 1);
- Queue2.DiscardResource(Wrapper4, 1);
- Wrapper4.GiveUpOwnership();
-
- Queue0.Purge(1);
- Queue1.Purge(1);
- Queue2.Purge(1);
- }
-
- SetStatus(TestResult::Succeeded);
- }
-};
-
-static ResourceReleaseQueueTest TheTest; \ No newline at end of file
diff --git a/Tests/TestApp/src/ShaderConverterTest.cpp b/Tests/TestApp/src/ShaderConverterTest.cpp
deleted file mode 100644
index 15378bb..0000000
--- a/Tests/TestApp/src/ShaderConverterTest.cpp
+++ /dev/null
@@ -1,107 +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.
- */
-
-// EngineSandbox.cpp : Defines the entry point for the application.
-//
-
-#include "pch.h"
-#include "ShaderConverterTest.h"
-#include "FileSystem.h"
-#include "Errors.h"
-#include "ScriptParser.h"
-#include "ConvenienceFunctions.h"
-#include "HLSL2GLSLConverter.h"
-
-using namespace Diligent;
-
-ShaderConverterTest::ShaderConverterTest( IRenderDevice *pRenderDevice, IDeviceContext *pContext ) :
- UnitTestBase("Shader Converter Test")
-{
- ShaderCreateInfo ShaderCI;
- ShaderCI.FilePath = "Shaders\\ConverterTest.fx";
- RefCntAutoPtr<IShaderSourceInputStreamFactory> pShaderSourceFactory;
- pRenderDevice->GetEngineFactory()->CreateDefaultShaderSourceStreamFactory("Shaders", &pShaderSourceFactory);
- ShaderCI.pShaderSourceStreamFactory = pShaderSourceFactory;
- ShaderCI.SourceLanguage = SHADER_SOURCE_LANGUAGE_HLSL;
- ShaderCI.Desc.Name = "Test converted shader";
- ShaderCI.UseCombinedTextureSamplers = pRenderDevice->GetDeviceCaps().IsGLDevice();
- RefCntAutoPtr<IHLSL2GLSLConversionStream> pStream;
- ShaderCI.ppConversionStream = pStream.GetRawDblPtr();
-
- {
- ShaderCI.Desc.ShaderType = SHADER_TYPE_PIXEL;
- ShaderCI.EntryPoint = "TestPS";
- RefCntAutoPtr<IShader> pShader;
- pRenderDevice->CreateShader( ShaderCI, &pShader );
- VERIFY_EXPR( pShader );
- }
-
- {
- ShaderCI.EntryPoint = "TestVS";
- ShaderCI.Desc.ShaderType = SHADER_TYPE_VERTEX;
- RefCntAutoPtr<IShader> pShader;
- pRenderDevice->CreateShader( ShaderCI, &pShader );
- VERIFY_EXPR( pShader );
- }
-
- std::string status;
- if(pRenderDevice->GetDeviceCaps().bComputeShadersSupported)
- {
-#if PLATFORM_WIN32 || PLATFORM_LINUX
- ShaderCI.EntryPoint = "TestCS";
- ShaderCI.Desc.ShaderType = SHADER_TYPE_COMPUTE;
- ShaderCI.ppConversionStream = nullptr;
- if (pRenderDevice->GetDeviceCaps().DevType != DeviceType::OpenGLES)
- {
- ShaderCI.FilePath = "Shaders\\CSConversionTest_RWTex1D.fx";
- RefCntAutoPtr<IShader> pShader;
- pRenderDevice->CreateShader( ShaderCI, &pShader );
- VERIFY_EXPR( pShader );
- }
- {
- ShaderCI.FilePath = "Shaders\\CSConversionTest_RWTex2D_1.fx";
- RefCntAutoPtr<IShader> pShader;
- pRenderDevice->CreateShader( ShaderCI, &pShader );
- VERIFY_EXPR( pShader );
- }
- {
- ShaderCI.FilePath = "Shaders\\CSConversionTest_RWTex2D_2.fx";
- RefCntAutoPtr<IShader> pShader;
- pRenderDevice->CreateShader( ShaderCI, &pShader );
- VERIFY_EXPR( pShader );
- }
- {
- ShaderCI.FilePath = "Shaders\\CSConversionTest_RWBuff.fx";
- RefCntAutoPtr<IShader> pShader;
- pRenderDevice->CreateShader( ShaderCI, &pShader );
- VERIFY_EXPR( pShader );
- }
-#else
- status = "Skipped compute shader conversion test";
-#endif
- }
- else
- status = "Skipped compute shader conversion test";
-
- SetStatus(TestResult::Succeeded, status.c_str());
-}
diff --git a/Tests/TestApp/src/TestApp.cpp b/Tests/TestApp/src/TestApp.cpp
index f01ba31..b588590 100644
--- a/Tests/TestApp/src/TestApp.cpp
+++ b/Tests/TestApp/src/TestApp.cpp
@@ -58,22 +58,9 @@
#include "ScriptParser.h"
#include "Errors.h"
#include "ConvenienceFunctions.h"
-#include "TestDepthStencilState.h"
-#include "TestRasterizerState.h"
-#include "TestBlendState.h"
#include "TestVPAndSR.h"
-#include "TestPSOCompatibility.h"
-#if GL_SUPPORTED || GLES_SUPPORTED
- #include "ShaderConverterTest.h"
-#endif
#include "TestCopyTexData.h"
-#include "TestMipMapsGeneration.h"
#include "PlatformMisc.h"
-#include "TestBufferCreation.h"
-#include "TestBrokenShader.h"
-#include "TestShaderResourceLayout.h"
-#include "TestShaderVarAccess.h"
-#include "TestSeparateTextureSampler.h"
#include "StringTools.h"
namespace Diligent
@@ -82,70 +69,10 @@ namespace Diligent
TestApp::TestApp() :
m_AppTitle("Test app")
{
- VERIFY_EXPR(PlatformMisc::GetMSB(Uint32{0}) == 32);
- for (Uint32 i = 0; i < 32; ++i)
- {
- auto MSB = PlatformMisc::GetMSB((Uint32{1} << i) | 1);
- VERIFY_EXPR(MSB == i); (void)MSB;
- }
-
- VERIFY_EXPR(PlatformMisc::GetMSB(Uint64{0}) == 64);
- for (Uint32 i = 0; i < 64; ++i)
- {
- auto MSB = PlatformMisc::GetMSB((Uint64{1} << i) | 1);
- VERIFY_EXPR(MSB == i); (void)MSB;
- }
-
- VERIFY_EXPR(PlatformMisc::GetLSB(Uint32{0}) == 32);
- for (Uint32 i = 0; i < 32; ++i)
- {
- auto LSB = PlatformMisc::GetLSB((Uint32{1} << i) | (Uint32{1}<<31));
- VERIFY_EXPR(LSB == i); (void)LSB;
- }
-
- VERIFY_EXPR(PlatformMisc::GetLSB(Uint64{0}) == 64);
- for (Uint32 i = 0; i < 64; ++i)
- {
- auto LSB = PlatformMisc::GetLSB((Uint64{1} << i) | (Uint64{1}<<63));
- VERIFY_EXPR(LSB == i); (void)LSB;
- }
-
- VERIFY_EXPR(PlatformMisc::CountOneBits(Uint32{0}) == 0);
- VERIFY_EXPR(PlatformMisc::CountOneBits(Uint64{0}) == 0);
- VERIFY_EXPR(PlatformMisc::CountOneBits(Uint32{1}) == 1);
- VERIFY_EXPR(PlatformMisc::CountOneBits(Uint64{1}) == 1);
- VERIFY_EXPR(PlatformMisc::CountOneBits(Uint32{7}) == 3);
- VERIFY_EXPR(PlatformMisc::CountOneBits(Uint64{7}) == 3);
- VERIFY_EXPR(PlatformMisc::CountOneBits( (Uint32{1}<<31) | (Uint32{1} << 15)) == 2);
- VERIFY_EXPR(PlatformMisc::CountOneBits( (Uint64{1}<<63) | (Uint32{1} << 31)) == 2);
- VERIFY_EXPR(PlatformMisc::CountOneBits( (Uint32{1}<<31) - 1) == 31);
- VERIFY_EXPR(PlatformMisc::CountOneBits( (Uint64{1}<<63) - 1) == 63);
-
-
- VERIFY_EXPR(StreqSuff("abc_def","abc", "_def"));
- VERIFY_EXPR(!StreqSuff("abc","abc", "_def"));
- VERIFY_EXPR(!StreqSuff("ab","abc", "_def"));
- VERIFY_EXPR(!StreqSuff("abc_de","abc", "_def"));
- VERIFY_EXPR(!StreqSuff("abc_def","ab", "_def"));
- VERIFY_EXPR(!StreqSuff("abc_def","abd", "_def"));
- VERIFY_EXPR(!StreqSuff("abc_def","abc", "_de"));
- VERIFY_EXPR(!StreqSuff("abc","abc", "_def"));
- VERIFY_EXPR(!StreqSuff("abc_def", "", "_def"));
- VERIFY_EXPR(!StreqSuff("abc_def", "", ""));
-
- VERIFY_EXPR(StreqSuff("abc","abc", "_def", true));
- VERIFY_EXPR(!StreqSuff("abc","abc_", "_def", true));
- VERIFY_EXPR(!StreqSuff("abc_","abc", "_def", true));
- VERIFY_EXPR(StreqSuff("abc","abc", nullptr, true));
- VERIFY_EXPR(StreqSuff("abc","abc", nullptr, false));
- VERIFY_EXPR(!StreqSuff("ab","abc", nullptr, true));
- VERIFY_EXPR(!StreqSuff("abc","ab", nullptr, false));
}
TestApp::~TestApp()
{
- if(m_pMTResCreationTest)
- m_pMTResCreationTest->StopThreads();
}
@@ -159,7 +86,7 @@ void TestApp::InitializeDiligentEngine(
SwapChainDesc SCDesc;
Uint32 NumDeferredCtx = 0;
std::vector<IDeviceContext*> ppContexts;
- std::vector<HardwareAdapterAttribs> Adapters;
+ std::vector<AdapterAttribs> Adapters;
std::vector<std::vector<DisplayModeAttribs>> AdapterDisplayModes;
switch (m_DeviceType)
{
@@ -179,9 +106,9 @@ void TestApp::InitializeDiligentEngine(
#endif
auto *pFactoryD3D11 = GetEngineFactoryD3D11();
Uint32 NumAdapters = 0;
- pFactoryD3D11->EnumerateHardwareAdapters(DIRECT3D_FEATURE_LEVEL_11_0, NumAdapters, 0);
+ pFactoryD3D11->EnumerateAdapters(DIRECT3D_FEATURE_LEVEL_11_0, NumAdapters, 0);
Adapters.resize(NumAdapters);
- pFactoryD3D11->EnumerateHardwareAdapters(DIRECT3D_FEATURE_LEVEL_11_0, NumAdapters, Adapters.data());
+ pFactoryD3D11->EnumerateAdapters(DIRECT3D_FEATURE_LEVEL_11_0, NumAdapters, Adapters.data());
for(Uint32 i=0; i < Adapters.size(); ++i)
{
@@ -213,9 +140,9 @@ void TestApp::InitializeDiligentEngine(
#endif
auto *pFactoryD3D12 = GetEngineFactoryD3D12();
Uint32 NumAdapters = 0;
- pFactoryD3D12->EnumerateHardwareAdapters(DIRECT3D_FEATURE_LEVEL_11_0, NumAdapters, 0);
+ pFactoryD3D12->EnumerateAdapters(DIRECT3D_FEATURE_LEVEL_11_0, NumAdapters, 0);
Adapters.resize(NumAdapters);
- pFactoryD3D12->EnumerateHardwareAdapters(DIRECT3D_FEATURE_LEVEL_11_0, NumAdapters, Adapters.data());
+ pFactoryD3D12->EnumerateAdapters(DIRECT3D_FEATURE_LEVEL_11_0, NumAdapters, Adapters.data());
for (Uint32 i = 0; i < Adapters.size(); ++i)
{
@@ -367,30 +294,9 @@ void TestApp::InitializeDiligentEngine(
void TestApp::InitializeRenderers()
{
- m_pMTResCreationTest.reset(new MTResourceCreationTest(m_pDevice, m_pImmediateContext, 7));
-
- TestSeparateTextureSampler TestSeparateTexSampler{m_pDevice, m_pImmediateContext};
- TestRasterizerState TestRS{m_pDevice, m_pImmediateContext};
- TestBlendState TestBS{m_pDevice, m_pImmediateContext};
- TestDepthStencilState TestDSS{m_pDevice, m_pImmediateContext};
- TestBufferCreation TestBuffCreation{m_pDevice, m_pImmediateContext};
- TestTextureCreation TestTexCreation{m_pDevice, m_pImmediateContext};
- TestPSOCompatibility TestPSOCompat{m_pDevice};
- TestBrokenShader TestBrknShdr{m_pDevice};
-
m_TestGS.Init(m_pDevice, m_pImmediateContext, m_pSwapChain);
m_TestTessellation.Init(m_pDevice, m_pImmediateContext, m_pSwapChain);
- m_pTestShaderResArrays.reset(new TestShaderResArrays(m_pDevice, m_pImmediateContext, m_pSwapChain, 0.4f, -0.9f, 0.5f, 0.5f));
- TestShaderVarAccess TestShaderVarAccess{m_pDevice, m_pImmediateContext, m_pSwapChain};
- TestShaderResourceLayout TestShaderResLayout{m_pDevice, m_pImmediateContext};
-
-#if GL_SUPPORTED || GLES_SUPPORTED
- ShaderConverterTest ConverterTest{m_pDevice, m_pImmediateContext};
-#endif
-
- TestSamplerCreation TestSamplers{m_pDevice};
-
RenderScriptTest LuaTest{m_pDevice, m_pImmediateContext};
const auto* BackBufferFmt = m_pDevice->GetTextureFormatInfo(m_pSwapChain->GetDesc().ColorBufferFormat).Name;
@@ -425,7 +331,6 @@ void TestApp::InitializeRenderers()
}
TestCopyTexData TestCopyData(m_pDevice, m_pImmediateContext);
- TestMipMapsGeneration TestMipsGen(m_pDevice, m_pImmediateContext);
TestVPAndSR TestVPAndSR(m_pDevice, m_pImmediateContext);
@@ -435,8 +340,6 @@ void TestApp::InitializeRenderers()
m_pTestRT.reset(new TestRenderTarget);
m_pTestRT->Init(m_pDevice, m_pImmediateContext, m_pSwapChain, -0.4f, 0.55f, 0.4f, 0.4f);
- m_pMTResCreationTest->StartThreads();
-
float instance_offsets[] = { -0.3f, 0.0f, 0.0f, 0.0f, +0.3f, -0.3f };
{
@@ -717,7 +620,6 @@ void TestApp::Render()
}
m_pTestCS->Draw();
m_pTestRT->Draw();
- m_pTestShaderResArrays->Draw();
m_TestGS.Draw();
auto CompletedFenceValue = m_pFence->GetCompletedValue();
diff --git a/Tests/TestApp/src/TestBlendState.cpp b/Tests/TestApp/src/TestBlendState.cpp
deleted file mode 100644
index 91035f2..0000000
--- a/Tests/TestApp/src/TestBlendState.cpp
+++ /dev/null
@@ -1,261 +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.
- */
-
-// EngineSandbox.cpp : Defines the entry point for the application.
-//
-
-#include "pch.h"
-#include "TestBlendState.h"
-#include "ConvenienceFunctions.h"
-
-using namespace Diligent;
-
-void TestBlendState::CreateTestBS( BlendStateDesc &BSDesc )
-{
- RefCntAutoPtr<IPipelineState> pPS0;
- m_pDevice->CreatePipelineState( m_PSODesc, &pPS0 );
- m_pDeviceContext->SetPipelineState(pPS0);
-#if 0
- BSDesc.Name = "TestBS2";
- m_pDevice->CreateBlendState( BSDesc, &pBS2 );
- assert( pBS == pBS2 );
- float BlendFactors[4] = { 0.8f, 0.2f, 0.3f, 0.6f };
- m_pDeviceContext->SetBlendState( pBS );
- m_pDeviceContext->SetBlendState( pBS2, BlendFactors );
- m_pDeviceContext->SetBlendState( pBS2, BlendFactors, 0x12F5BA3D );
- m_pDeviceContext->SetBlendState( pBS2, BlendFactors, 0x12F5BA3D );
-#endif
-}
-
-TestBlendState::TestBlendState( IRenderDevice *pDevice, IDeviceContext *pContext ) :
- TestPipelineStateBase(pDevice, "Blend state initialization test"),
- m_pDeviceContext(pContext)
-{
- // Dual-source color blending is not supported in GLES3.2, but NVidia's GPUs do support it
- const auto& DevCaps = pDevice->GetDeviceCaps();
- bool TestSRC1 = DevCaps.DevType != DeviceType::OpenGLES;// || DevCaps.Vendor == GPU_VENDOR::NVIDIA;
- std::stringstream statusss;
- statusss << "Dual-source color blending " << (TestSRC1 ? "tested." : "NOT tested.");
-
- m_PSODesc.Name = "PSO-TestBlendStates";
- BlendStateDesc &BSDesc = m_PSODesc.GraphicsPipeline.BlendDesc;
- BSDesc.RenderTargets[0].BlendEnable = True;
- CreateTestBS( BSDesc );
-
- BSDesc.AlphaToCoverageEnable = !BSDesc.AlphaToCoverageEnable;
- CreateTestBS( BSDesc );
-
- BSDesc.IndependentBlendEnable = !BSDesc.IndependentBlendEnable;
- CreateTestBS( BSDesc );
-
- BSDesc.AlphaToCoverageEnable = False;
- BSDesc.IndependentBlendEnable = True;
-
- const BLEND_FACTOR AlphaBlendFactors[] =
- {
- BLEND_FACTOR_ZERO,
- BLEND_FACTOR_ONE,
- BLEND_FACTOR_SRC_ALPHA,
- BLEND_FACTOR_INV_SRC_ALPHA,
- BLEND_FACTOR_DEST_ALPHA,
- BLEND_FACTOR_INV_DEST_ALPHA,
- BLEND_FACTOR_SRC_ALPHA_SAT,
- BLEND_FACTOR_BLEND_FACTOR,
- BLEND_FACTOR_INV_BLEND_FACTOR,
- BLEND_FACTOR_SRC1_ALPHA,
- BLEND_FACTOR_INV_SRC1_ALPHA,
- };
-
- // GLES is required to support 4 render targets
- int NumRenderTargetsToTest = DevCaps.DevType == DeviceType::OpenGLES ? 4 : 8;
- statusss << " Num render targets tested: " << NumRenderTargetsToTest;
- for( int i = 0; i < NumRenderTargetsToTest; ++i )
- {
- auto &RT = BSDesc.RenderTargets[i];
- RT.BlendEnable = True;
- for( auto bf = BLEND_FACTOR_UNDEFINED + 1; bf < BLEND_FACTOR_NUM_FACTORS; ++bf )
- {
- if( (!TestSRC1 || i > 0) &&
- (bf == BLEND_FACTOR_SRC1_COLOR ||
- bf == BLEND_FACTOR_INV_SRC1_COLOR ||
- bf == BLEND_FACTOR_SRC1_ALPHA ||
- bf == BLEND_FACTOR_INV_SRC1_ALPHA) )
- continue;
- RT.SrcBlend = static_cast<BLEND_FACTOR>( bf );
- CreateTestBS( BSDesc );
- }
-
- for( auto bf = BLEND_FACTOR_UNDEFINED + 1; bf < BLEND_FACTOR_NUM_FACTORS; ++bf )
- {
- if( (!TestSRC1 || i > 0) &&
- (bf == BLEND_FACTOR_SRC1_COLOR ||
- bf == BLEND_FACTOR_INV_SRC1_COLOR ||
- bf == BLEND_FACTOR_SRC1_ALPHA ||
- bf == BLEND_FACTOR_INV_SRC1_ALPHA) )
- continue;
-
- RT.DestBlend = static_cast<BLEND_FACTOR>( bf );
- CreateTestBS( BSDesc );
- }
-
- RT.SrcBlend = BLEND_FACTOR_SRC_COLOR;
- RT.DestBlend = BLEND_FACTOR_INV_SRC_COLOR;
- RT.SrcBlendAlpha = BLEND_FACTOR_SRC_ALPHA;
- RT.DestBlendAlpha = BLEND_FACTOR_INV_SRC_ALPHA;
- for( auto bo = BLEND_OPERATION_UNDEFINED + 1; bo < BLEND_OPERATION_NUM_OPERATIONS; ++bo )
- {
- RT.BlendOp = static_cast<BLEND_OPERATION>( bo );
- CreateTestBS( BSDesc );
- }
-
- for( auto bf = 0; bf < _countof(AlphaBlendFactors); ++bf )
- {
- auto AlphaBlend = AlphaBlendFactors[bf];
- if( (!TestSRC1 || i > 0) && (AlphaBlend == BLEND_FACTOR_SRC1_ALPHA || AlphaBlend == BLEND_FACTOR_INV_SRC1_ALPHA) )
- continue;
-
- RT.SrcBlendAlpha = AlphaBlend;
- CreateTestBS( BSDesc );
- }
-
- for( auto bf = 0; bf < _countof(AlphaBlendFactors); ++bf )
- {
- auto AlphaBlend = AlphaBlendFactors[bf];
- if( (!TestSRC1 || i > 0) && (AlphaBlend == BLEND_FACTOR_SRC1_ALPHA || AlphaBlend == BLEND_FACTOR_INV_SRC1_ALPHA) )
- continue;
-
- RT.DestBlendAlpha = AlphaBlend;
- CreateTestBS( BSDesc );
- }
-
- RT.SrcBlend = BLEND_FACTOR_SRC_COLOR;
- RT.DestBlend = BLEND_FACTOR_INV_SRC_COLOR;
- RT.SrcBlendAlpha = BLEND_FACTOR_SRC_ALPHA;
- RT.DestBlendAlpha = BLEND_FACTOR_INV_SRC_ALPHA;
- for( auto bo = BLEND_OPERATION_UNDEFINED + 1; bo < BLEND_OPERATION_NUM_OPERATIONS; ++bo )
- {
- RT.BlendOpAlpha = static_cast<BLEND_OPERATION>( bo );
- CreateTestBS( BSDesc );
- }
-
- RT.RenderTargetWriteMask = COLOR_MASK_BLUE;
- CreateTestBS( BSDesc );
-
- RT.RenderTargetWriteMask |= COLOR_MASK_RED;
- CreateTestBS( BSDesc );
-
- RT.RenderTargetWriteMask |= COLOR_MASK_GREEN;
- CreateTestBS( BSDesc );
-
- RT.RenderTargetWriteMask |= COLOR_MASK_ALPHA;
- CreateTestBS( BSDesc );
- }
-
- auto pScript = CreateRenderScriptFromFile( "BlendStateTest.lua", pDevice, pContext, [&]( Diligent::ScriptParser *pScriptParser )
- {
- BSDesc = BlendStateDesc();
- BSDesc.IndependentBlendEnable = True;
- BSDesc.AlphaToCoverageEnable = False;
- BSDesc.RenderTargets[0].BlendEnable = True;
- BSDesc.RenderTargets[0].SrcBlend = BLEND_FACTOR_ZERO;
- BSDesc.RenderTargets[0].DestBlend = BLEND_FACTOR_ONE;
- BSDesc.RenderTargets[0].BlendOp = BLEND_OPERATION_ADD;
- BSDesc.RenderTargets[0].SrcBlendAlpha = BLEND_FACTOR_SRC_ALPHA;
- BSDesc.RenderTargets[0].DestBlendAlpha = BLEND_FACTOR_INV_SRC_ALPHA;
- BSDesc.RenderTargets[0].BlendOpAlpha = BLEND_OPERATION_SUBTRACT;
- BSDesc.RenderTargets[0].RenderTargetWriteMask = COLOR_MASK_RED;
-
- BSDesc.RenderTargets[1].BlendEnable = True;
- BSDesc.RenderTargets[1].SrcBlend = BLEND_FACTOR_SRC_ALPHA;
- BSDesc.RenderTargets[1].DestBlend = BLEND_FACTOR_INV_SRC_ALPHA;
- BSDesc.RenderTargets[1].BlendOp = BLEND_OPERATION_REV_SUBTRACT;
- BSDesc.RenderTargets[1].SrcBlendAlpha = BLEND_FACTOR_DEST_ALPHA;
- BSDesc.RenderTargets[1].DestBlendAlpha = BLEND_FACTOR_INV_DEST_ALPHA;
- BSDesc.RenderTargets[1].BlendOpAlpha = BLEND_OPERATION_MIN;
- BSDesc.RenderTargets[1].RenderTargetWriteMask = COLOR_MASK_GREEN;
-
- BSDesc.RenderTargets[2].BlendEnable = True;
- BSDesc.RenderTargets[2].SrcBlend = BLEND_FACTOR_DEST_COLOR;
- BSDesc.RenderTargets[2].DestBlend = BLEND_FACTOR_INV_DEST_COLOR;
- BSDesc.RenderTargets[2].BlendOp = BLEND_OPERATION_MAX;
- BSDesc.RenderTargets[2].SrcBlendAlpha = BLEND_FACTOR_SRC_ALPHA_SAT;
- BSDesc.RenderTargets[2].DestBlendAlpha = BLEND_FACTOR_BLEND_FACTOR;
- BSDesc.RenderTargets[2].BlendOpAlpha = BLEND_OPERATION_ADD;
- BSDesc.RenderTargets[2].RenderTargetWriteMask = COLOR_MASK_BLUE;
-
- BSDesc.RenderTargets[3].BlendEnable = True;
- BSDesc.RenderTargets[3].SrcBlend = BLEND_FACTOR_INV_BLEND_FACTOR;
- BSDesc.RenderTargets[3].DestBlend = BLEND_FACTOR_SRC_COLOR;
- BSDesc.RenderTargets[3].BlendOp = BLEND_OPERATION_MAX;
- BSDesc.RenderTargets[3].SrcBlendAlpha = BLEND_FACTOR_INV_SRC_ALPHA;
- BSDesc.RenderTargets[3].DestBlendAlpha = BLEND_FACTOR_SRC_ALPHA;
- BSDesc.RenderTargets[3].BlendOpAlpha = BLEND_OPERATION_ADD;
- BSDesc.RenderTargets[3].RenderTargetWriteMask = COLOR_MASK_ALPHA;
-
- RefCntAutoPtr<IPipelineState> pPSO;
- pDevice->CreatePipelineState( m_PSODesc, &pPSO);
- pScriptParser->SetGlobalVariable( "TestGlobalPSO", pPSO );
- }
- );
- {
- RefCntAutoPtr<IPipelineState> pPSOFromScript, pPSOFromScript2;
- pScript->GetPipelineStateByName( "PSO_TestBlendState", &pPSOFromScript );
- //pScript->GetPipelineStateByName( "TestPSO2", &pPSOFromScript2 );
- //assert( pPSOFromScript == pBSFromScript2 );
- const auto &PSODesc = pPSOFromScript->GetDesc();
- const auto &BSDesc2 = PSODesc.GraphicsPipeline.BlendDesc;
-
- assert( strcmp(PSODesc.Name, "TestPSO_FromScript") == 0 );
- assert( BSDesc2.IndependentBlendEnable == true );
- assert( BSDesc2.AlphaToCoverageEnable == false );
- const auto &RT1 = BSDesc2.RenderTargets[0];
- assert( RT1.BlendEnable == true);
- assert( RT1.SrcBlend == BLEND_FACTOR_ZERO);
- assert( RT1.DestBlend == BLEND_FACTOR_SRC_COLOR);
- assert( RT1.BlendOp == BLEND_OPERATION_ADD);
- assert( RT1.SrcBlendAlpha == BLEND_FACTOR_SRC_ALPHA);
- assert( RT1.DestBlendAlpha == BLEND_FACTOR_INV_SRC_ALPHA);
- assert( RT1.BlendOpAlpha == BLEND_OPERATION_SUBTRACT);
- assert( RT1.RenderTargetWriteMask == (COLOR_MASK_GREEN | COLOR_MASK_RED) );
- (void)RT1;
-
- const auto& RT3 = BSDesc2.RenderTargets[2];
- assert(RT3.BlendEnable == true);
- assert(RT3.SrcBlend == BLEND_FACTOR_INV_DEST_ALPHA);
- assert(RT3.DestBlend == BLEND_FACTOR_INV_DEST_COLOR);
- assert(RT3.BlendOp == BLEND_OPERATION_ADD);
- assert(RT3.SrcBlendAlpha == BLEND_FACTOR_BLEND_FACTOR);
- assert(RT3.DestBlendAlpha == BLEND_FACTOR_INV_SRC_ALPHA);
- assert(RT3.BlendOpAlpha == BLEND_OPERATION_SUBTRACT);
- assert(RT3.RenderTargetWriteMask == (COLOR_MASK_BLUE | COLOR_MASK_ALPHA) );
- (void)RT3;
- }
-
- {
- BSDesc = BlendStateDesc();
- RefCntAutoPtr<IPipelineState> pPSO;
- m_pDevice->CreatePipelineState(m_PSODesc, &pPSO );
- pScript->Run( m_pDeviceContext, "TestPSOArg", pPSO );
- }
- SetStatus(TestResult::Succeeded, statusss.str().c_str());
-}
diff --git a/Tests/TestApp/src/TestBrokenShader.cpp b/Tests/TestApp/src/TestBrokenShader.cpp
deleted file mode 100644
index 68a6787..0000000
--- a/Tests/TestApp/src/TestBrokenShader.cpp
+++ /dev/null
@@ -1,63 +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.
- */
-
-// EngineSandbox.cpp : Defines the entry point for the application.
-//
-
-#include "pch.h"
-#include "TestBrokenShader.h"
-
-using namespace Diligent;
-
-static const char g_BrokenShaderSource[] =
-R"(
-void VSMain(out float4 pos : SV_POSITION)
-{
- pos = float3(0.0, 0.0, 0.0, 0.0);
-}
-)";
-
-TestBrokenShader::TestBrokenShader(IRenderDevice *pDevice) :
- UnitTestBase("Broken shader test")
-{
- ShaderCreateInfo Attrs;
- Attrs.Source = g_BrokenShaderSource;
- Attrs.EntryPoint = "VSMain";
- Attrs.Desc.ShaderType = SHADER_TYPE_VERTEX;
- Attrs.Desc.Name = "Broken shader test";
- Attrs.SourceLanguage = SHADER_SOURCE_LANGUAGE_HLSL;
- Attrs.UseCombinedTextureSamplers = true;
- RefCntAutoPtr<IShader> pBrokenShader;
- IDataBlob *pErrors = nullptr;
- Attrs.ppCompilerOutput = &pErrors;
- LOG_INFO_MESSAGE("\n\nNo worries, testing broken shader...");
- pDevice->CreateShader(Attrs, &pBrokenShader);
- VERIFY_EXPR(!pBrokenShader);
- VERIFY_EXPR(pErrors != nullptr);
- const char* Msg = reinterpret_cast<const char*>(pErrors->GetDataPtr());
- LOG_INFO_MESSAGE("Compiler output:\n", Msg);
- pErrors->Release();
- LOG_INFO_MESSAGE("No worries, errors above are result of the broken shader test.\n");
-
- SetStatus(TestResult::Succeeded);
-}
diff --git a/Tests/TestApp/src/TestBufferAccess.cpp b/Tests/TestApp/src/TestBufferAccess.cpp
index 7d119dc..6e139f9 100644
--- a/Tests/TestApp/src/TestBufferAccess.cpp
+++ b/Tests/TestApp/src/TestBufferAccess.cpp
@@ -21,9 +21,6 @@
* of the possibility of such damages.
*/
-// EngineSandbox.cpp : Defines the entry point for the application.
-//
-
#include "pch.h"
#include <math.h>
#include "TestBufferAccess.h"
diff --git a/Tests/TestApp/src/TestBufferCreation.cpp b/Tests/TestApp/src/TestBufferCreation.cpp
deleted file mode 100644
index c9ffcfb..0000000
--- a/Tests/TestApp/src/TestBufferCreation.cpp
+++ /dev/null
@@ -1,201 +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 "TestBufferCreation.h"
-
-#if D3D11_SUPPORTED
-#include "TestCreateObjFromNativeResD3D11.h"
-#endif
-
-#if D3D12_SUPPORTED
-#include "TestCreateObjFromNativeResD3D12.h"
-#endif
-
-#if GL_SUPPORTED || GLES_SUPPORTED
-#include "TestCreateObjFromNativeResGL.h"
-#endif
-
-#if VULKAN_SUPPORTED
-#include "TestCreateObjFromNativeResVK.h"
-#endif
-
-using namespace Diligent;
-
-TestBufferCreation::TestBufferCreation(Diligent::IRenderDevice *pDevice, Diligent::IDeviceContext *pContext) :
- UnitTestBase("Buffer creation test")
-{
- std::unique_ptr<TestCreateObjFromNativeRes> pTestCreateObjFromNativeRes;
- const auto DevCaps = pDevice->GetDeviceCaps();
- switch (DevCaps.DevType)
- {
-#if D3D11_SUPPORTED
- case DeviceType::D3D11:
- pTestCreateObjFromNativeRes.reset(new TestCreateObjFromNativeResD3D11(pDevice));
- break;
-
-#endif
-
-#if D3D12_SUPPORTED
- case DeviceType::D3D12:
- pTestCreateObjFromNativeRes.reset(new TestCreateObjFromNativeResD3D12(pDevice));
- break;
-#endif
-
-#if GL_SUPPORTED || GLES_SUPPORTED
- case DeviceType::OpenGL:
- case DeviceType::OpenGLES:
- pTestCreateObjFromNativeRes.reset(new TestCreateObjFromNativeResGL(pDevice));
- break;
-#endif
-
-#if VULKAN_SUPPORTED
- case DeviceType::Vulkan:
- pTestCreateObjFromNativeRes.reset(new TestCreateObjFromNativeResVK(pDevice));
- break;
-#endif
-
- default: UNEXPECTED("Unexpected device type");
- }
-
- int BuffersCreated = 0;
- {
- Diligent::BufferDesc BuffDesc;
- BuffDesc.Name = "Buffer creation test 0";
- BuffDesc.uiSizeInBytes = 256;
- BuffDesc.BindFlags = BIND_VERTEX_BUFFER;
- RefCntAutoPtr<IBuffer> pBuffer;
- BufferData InitData;
- InitData.DataSize = BuffDesc.uiSizeInBytes;
- std::vector<Uint8> DummyData(InitData.DataSize);
- InitData.pData = DummyData.data();
- pDevice->CreateBuffer(BuffDesc, &InitData, &pBuffer);
- VERIFY_EXPR(pBuffer);
-
- pTestCreateObjFromNativeRes->CreateBuffer(pBuffer);
- ++BuffersCreated;
- }
-
- {
- Diligent::BufferDesc BuffDesc;
- BuffDesc.Name = "Buffer creation test 1";
- BuffDesc.uiSizeInBytes = 256;
- BuffDesc.BindFlags = BIND_VERTEX_BUFFER;
- RefCntAutoPtr<IBuffer> pBuffer;
- BufferData NullData;
- pDevice->CreateBuffer(BuffDesc, &NullData, &pBuffer);
- VERIFY_EXPR(pBuffer);
-
- pTestCreateObjFromNativeRes->CreateBuffer(pBuffer);
- ++BuffersCreated;
- }
-
- if(DevCaps.bComputeShadersSupported && DevCaps.bIndirectRenderingSupported)
- {
- Diligent::BufferDesc BuffDesc;
- BuffDesc.Name = "Buffer creation test 2";
- BuffDesc.uiSizeInBytes = 256;
- BuffDesc.BindFlags = BIND_UNORDERED_ACCESS | BIND_SHADER_RESOURCE;
- BuffDesc.Mode = BUFFER_MODE_FORMATTED;
- BuffDesc.ElementByteStride = 16;
- RefCntAutoPtr<IBuffer> pBuffer;
- pDevice->CreateBuffer(BuffDesc, nullptr, &pBuffer);
- VERIFY_EXPR(pBuffer);
-
- BufferViewDesc ViewDesc;
- ViewDesc.ViewType = BUFFER_VIEW_SHADER_RESOURCE;
- ViewDesc.ByteOffset = 32;
- ViewDesc.Format.NumComponents = 4;
- ViewDesc.Format.ValueType = VT_FLOAT32;
- ViewDesc.Format.IsNormalized = false;
- RefCntAutoPtr<IBufferView> pBufferSRV;
- pBuffer->CreateView(ViewDesc, &pBufferSRV);
-
- ViewDesc.ViewType = BUFFER_VIEW_UNORDERED_ACCESS;
- RefCntAutoPtr<IBufferView> pBufferUAV;
- pBuffer->CreateView(ViewDesc, &pBufferUAV);
-
- pTestCreateObjFromNativeRes->CreateBuffer(pBuffer);
- ++BuffersCreated;
- }
-
- if(DevCaps.bComputeShadersSupported)
- {
- Diligent::BufferDesc BuffDesc;
- BuffDesc.Name = "Buffer creation test 3";
- BuffDesc.uiSizeInBytes = 256;
- BuffDesc.BindFlags = BIND_SHADER_RESOURCE | BIND_UNORDERED_ACCESS;
- BuffDesc.Mode = BUFFER_MODE_STRUCTURED;
- BuffDesc.ElementByteStride = 16;
- RefCntAutoPtr<IBuffer> pBuffer;
- pDevice->CreateBuffer(BuffDesc, nullptr, &pBuffer);
- VERIFY_EXPR(pBuffer);
-
- pTestCreateObjFromNativeRes->CreateBuffer(pBuffer);
- ++BuffersCreated;
- }
-
- {
- Diligent::BufferDesc BuffDesc;
- BuffDesc.Name = "Buffer creation test 4";
- BuffDesc.uiSizeInBytes = 256;
- BuffDesc.BindFlags = BIND_UNIFORM_BUFFER;
- RefCntAutoPtr<IBuffer> pBuffer;
- pDevice->CreateBuffer(BuffDesc, nullptr, &pBuffer);
- VERIFY_EXPR(pBuffer);
-
- pTestCreateObjFromNativeRes->CreateBuffer(pBuffer);
- ++BuffersCreated;
- }
-
- {
- Diligent::BufferDesc BuffDesc;
- BuffDesc.Name = "Buffer creation test 5";
- BuffDesc.uiSizeInBytes = 256;
- BuffDesc.BindFlags = BIND_VERTEX_BUFFER | BIND_INDEX_BUFFER | BIND_UNORDERED_ACCESS | BIND_SHADER_RESOURCE;
- BuffDesc.Mode = BUFFER_MODE_RAW;
- BuffDesc.ElementByteStride = 16;
- RefCntAutoPtr<IBuffer> pBuffer;
- pDevice->CreateBuffer(BuffDesc, nullptr, &pBuffer);
- VERIFY_EXPR(pBuffer);
-
- BufferViewDesc ViewDesc;
- ViewDesc.ViewType = BUFFER_VIEW_UNORDERED_ACCESS;
- ViewDesc.ByteOffset = 32;
- ViewDesc.Format.NumComponents = 4;
- ViewDesc.Format.ValueType = VT_FLOAT32;
- RefCntAutoPtr<IBufferView> pBufferUAV;
- pBuffer->CreateView(ViewDesc, &pBufferUAV);
-
- ViewDesc.ViewType = BUFFER_VIEW_SHADER_RESOURCE;
- RefCntAutoPtr<IBufferView> pBufferSRV;
- pBuffer->CreateView(ViewDesc, &pBufferSRV);
-
- pTestCreateObjFromNativeRes->CreateBuffer(pBuffer);
- ++BuffersCreated;
- }
-
- std::stringstream infoss;
- infoss << "Created " << BuffersCreated << " test buffers.";
- SetStatus(TestResult::Succeeded, infoss.str().c_str());
-}
diff --git a/Tests/TestApp/src/TestComputeShaders.cpp b/Tests/TestApp/src/TestComputeShaders.cpp
index 67c0c5f..9d6116c 100644
--- a/Tests/TestApp/src/TestComputeShaders.cpp
+++ b/Tests/TestApp/src/TestComputeShaders.cpp
@@ -21,9 +21,6 @@
* of the possibility of such damages.
*/
-// EngineSandbox.cpp : Defines the entry point for the application.
-//
-
#include "pch.h"
#include "TestComputeShaders.h"
#include "GraphicsUtilities.h"
diff --git a/Tests/TestApp/src/TestCreateObjFromNativeResD3D11.cpp b/Tests/TestApp/src/TestCreateObjFromNativeResD3D11.cpp
deleted file mode 100644
index 4d913a6..0000000
--- a/Tests/TestApp/src/TestCreateObjFromNativeResD3D11.cpp
+++ /dev/null
@@ -1,109 +0,0 @@
-/* Copyright 2019 Diligent Graphics LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS.
- *
- * In no event and under no legal theory, whether in tort (including negligence),
- * contract, or otherwise, unless required by applicable law (such as deliberate
- * and grossly negligent acts) or agreed to in writing, shall any Contributor be
- * liable for any damages, including any direct, indirect, special, incidental,
- * or consequential damages of any character arising as a result of this License or
- * out of the use or inability to use the software (including but not limited to damages
- * for loss of goodwill, work stoppage, computer failure or malfunction, or any and
- * all other commercial damages or losses), even if such Contributor has been advised
- * of the possibility of such damages.
- */
-
-#include "pch.h"
-#include "TestCreateObjFromNativeResD3D11.h"
-
-#include <d3d11.h>
-#include "RenderDeviceD3D11.h"
-#include "TextureD3D11.h"
-#include "BufferD3D11.h"
-
-using namespace Diligent;
-
-void TestCreateObjFromNativeResD3D11::CreateTexture(Diligent::ITexture *pTexture)
-{
- RefCntAutoPtr<IRenderDeviceD3D11> pDeviceD3D11(m_pDevice, IID_RenderDeviceD3D11);
- const auto &SrcTexDesc = pTexture->GetDesc();
- RefCntAutoPtr<ITextureD3D11> pTextureD3D11(pTexture, IID_TextureD3D11);
- auto *pd3d11Texture = pTextureD3D11->GetD3D11Texture();
- RefCntAutoPtr<ITexture> pTextureFromNativeD3D11Handle;
- if (SrcTexDesc.Type == RESOURCE_DIM_TEX_1D || SrcTexDesc.Type == RESOURCE_DIM_TEX_1D_ARRAY)
- {
- pDeviceD3D11->CreateTextureFromD3DResource(static_cast<ID3D11Texture1D*>(pd3d11Texture), RESOURCE_STATE_UNKNOWN, &pTextureFromNativeD3D11Handle);
- ++m_NumTexturesCreated;
- }
- else if (SrcTexDesc.Type == RESOURCE_DIM_TEX_2D || SrcTexDesc.Type == RESOURCE_DIM_TEX_2D_ARRAY ||
- SrcTexDesc.Type == RESOURCE_DIM_TEX_CUBE || SrcTexDesc.Type == RESOURCE_DIM_TEX_CUBE_ARRAY)
- {
- pDeviceD3D11->CreateTextureFromD3DResource(static_cast<ID3D11Texture2D*>(pd3d11Texture), RESOURCE_STATE_UNKNOWN, &pTextureFromNativeD3D11Handle);
- ++m_NumTexturesCreated;
- }
- else if (SrcTexDesc.Type == RESOURCE_DIM_TEX_3D)
- {
- pDeviceD3D11->CreateTextureFromD3DResource(static_cast<ID3D11Texture3D*>(pd3d11Texture), RESOURCE_STATE_UNKNOWN, &pTextureFromNativeD3D11Handle);
- ++m_NumTexturesCreated;
- }
- else
- {
- UNEXPECTED("Unexpected texture dimensions");
- }
-
- auto TestTexDesc = pTextureFromNativeD3D11Handle->GetDesc();
- if (SrcTexDesc.Type == RESOURCE_DIM_TEX_CUBE || SrcTexDesc.Type == RESOURCE_DIM_TEX_CUBE_ARRAY)
- {
- VERIFY_EXPR(TestTexDesc.Type == RESOURCE_DIM_TEX_2D_ARRAY);
- TestTexDesc.Type = SrcTexDesc.Type;
- }
- VERIFY_EXPR(TestTexDesc == SrcTexDesc);
- RefCntAutoPtr<ITextureD3D11> pTestTextureD3D11(pTextureFromNativeD3D11Handle, IID_TextureD3D11);
- VERIFY_EXPR(pTestTextureD3D11->GetD3D11Texture() == pd3d11Texture);
- VERIFY_EXPR(pTestTextureD3D11->GetNativeHandle() == pd3d11Texture);
-}
-
-void TestCreateObjFromNativeResD3D11::CreateBuffer(Diligent::IBuffer *pBuffer)
-{
- RefCntAutoPtr<IRenderDeviceD3D11> pDeviceD3D11(m_pDevice, IID_RenderDeviceD3D11);
- const auto &SrcBuffDesc = pBuffer->GetDesc();
- RefCntAutoPtr<IBufferD3D11> pBufferD3D11(pBuffer, IID_BufferD3D11);
- auto *pd3d11Buffer = pBufferD3D11->GetD3D11Buffer();
-
- {
- RefCntAutoPtr<IBuffer> pBufferFromNativeD3D11Handle;
- pDeviceD3D11->CreateBufferFromD3DResource(pd3d11Buffer, SrcBuffDesc, RESOURCE_STATE_UNKNOWN, &pBufferFromNativeD3D11Handle);
- ++m_NumBuffersCreated;
-
- const auto &TestBufferDesc = pBufferFromNativeD3D11Handle->GetDesc();
- VERIFY_EXPR(TestBufferDesc == SrcBuffDesc);
-
- RefCntAutoPtr<IBufferD3D11> pTestBufferD3D11(pBufferFromNativeD3D11Handle, IID_BufferD3D11);
- VERIFY_EXPR(pTestBufferD3D11->GetD3D11Buffer() == pd3d11Buffer);
- VERIFY_EXPR(pTestBufferD3D11->GetNativeHandle() == pd3d11Buffer);
- }
-
- {
- BufferDesc BuffDesc;
- BuffDesc.Name = "Test buffer from D3D11 buffer";
- BuffDesc.ElementByteStride = SrcBuffDesc.ElementByteStride;
- RefCntAutoPtr<IBuffer> pBufferFromNativeD3D11Handle;
- pDeviceD3D11->CreateBufferFromD3DResource(pd3d11Buffer, BuffDesc, RESOURCE_STATE_UNKNOWN, &pBufferFromNativeD3D11Handle);
- ++m_NumBuffersCreated;
-
- const auto &TestBufferDesc = pBufferFromNativeD3D11Handle->GetDesc();
- VERIFY_EXPR(TestBufferDesc == SrcBuffDesc);
-
- RefCntAutoPtr<IBufferD3D11> pTestBufferD3D11(pBufferFromNativeD3D11Handle, IID_BufferD3D11);
- VERIFY_EXPR(pTestBufferD3D11->GetD3D11Buffer() == pd3d11Buffer);
- VERIFY_EXPR(pTestBufferD3D11->GetNativeHandle() == pd3d11Buffer);
- }
-}
diff --git a/Tests/TestApp/src/TestCreateObjFromNativeResD3D12.cpp b/Tests/TestApp/src/TestCreateObjFromNativeResD3D12.cpp
deleted file mode 100644
index 1d995d2..0000000
--- a/Tests/TestApp/src/TestCreateObjFromNativeResD3D12.cpp
+++ /dev/null
@@ -1,79 +0,0 @@
-/* Copyright 2019 Diligent Graphics LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS.
- *
- * In no event and under no legal theory, whether in tort (including negligence),
- * contract, or otherwise, unless required by applicable law (such as deliberate
- * and grossly negligent acts) or agreed to in writing, shall any Contributor be
- * liable for any damages, including any direct, indirect, special, incidental,
- * or consequential damages of any character arising as a result of this License or
- * out of the use or inability to use the software (including but not limited to damages
- * for loss of goodwill, work stoppage, computer failure or malfunction, or any and
- * all other commercial damages or losses), even if such Contributor has been advised
- * of the possibility of such damages.
- */
-
-#include "pch.h"
-#include "TestCreateObjFromNativeResD3D12.h"
-#include <d3d12.h>
-#include "RenderDeviceD3D12.h"
-#include "TextureD3D12.h"
-#include "BufferD3D12.h"
-
-using namespace Diligent;
-
-void TestCreateObjFromNativeResD3D12::CreateTexture(Diligent::ITexture *pTexture)
-{
- RefCntAutoPtr<IRenderDeviceD3D12> pDeviceD3D12(m_pDevice, IID_RenderDeviceD3D12);
- const auto &SrcTexDesc = pTexture->GetDesc();
- RefCntAutoPtr<ITextureD3D12> pTextureD3D12(pTexture, IID_TextureD3D12);
- auto *pD3D12Texture = pTextureD3D12->GetD3D12Texture();
- RefCntAutoPtr<ITexture> pTextureFromNativeD3D12Handle;
- pDeviceD3D12->CreateTextureFromD3DResource(pD3D12Texture, RESOURCE_STATE_UNKNOWN, &pTextureFromNativeD3D12Handle);
- ++m_NumTexturesCreated;
-
- auto TestTexDesc = pTextureFromNativeD3D12Handle->GetDesc();
- if (SrcTexDesc.Type == RESOURCE_DIM_TEX_CUBE || SrcTexDesc.Type == RESOURCE_DIM_TEX_CUBE_ARRAY)
- {
- VERIFY_EXPR(TestTexDesc.Type == RESOURCE_DIM_TEX_2D_ARRAY);
- TestTexDesc.Type = SrcTexDesc.Type;
- }
- VERIFY_EXPR(TestTexDesc == SrcTexDesc);
-
- RefCntAutoPtr<ITextureD3D12> pTestTextureD3D12(pTextureFromNativeD3D12Handle, IID_TextureD3D12);
- VERIFY_EXPR(pTestTextureD3D12->GetD3D12Texture() == pD3D12Texture);
- VERIFY_EXPR(pTestTextureD3D12->GetNativeHandle() == pD3D12Texture);
-}
-
-void TestCreateObjFromNativeResD3D12::CreateBuffer(Diligent::IBuffer *pBuffer)
-{
- RefCntAutoPtr<IRenderDeviceD3D12> pDeviceD3D12(m_pDevice, IID_RenderDeviceD3D12);
- const auto &SrcBuffDesc = pBuffer->GetDesc();
- RefCntAutoPtr<IBufferD3D12> pBufferD3D12(pBuffer, IID_BufferD3D12);
- Uint64 DataStartByteOffset;
- auto *pD3D12Buffer = pBufferD3D12->GetD3D12Buffer(DataStartByteOffset, 0);
- VERIFY_EXPR(DataStartByteOffset == 0);
-
- {
- RefCntAutoPtr<IBuffer> pBufferFromNativeD3D12Handle;
- pDeviceD3D12->CreateBufferFromD3DResource(pD3D12Buffer, SrcBuffDesc, RESOURCE_STATE_UNKNOWN, &pBufferFromNativeD3D12Handle);
- ++m_NumBuffersCreated;
-
- const auto &TestBufferDesc = pBufferFromNativeD3D12Handle->GetDesc();
- VERIFY_EXPR(TestBufferDesc == SrcBuffDesc);
-
- RefCntAutoPtr<IBufferD3D12> pTestBufferD3D12(pBufferFromNativeD3D12Handle, IID_BufferD3D12);
- Uint64 TestBuffDataStartByteOffset;
- VERIFY_EXPR(pTestBufferD3D12->GetD3D12Buffer(TestBuffDataStartByteOffset, 0) == pD3D12Buffer);
- VERIFY_EXPR(TestBuffDataStartByteOffset == 0);
- VERIFY_EXPR(pTestBufferD3D12->GetNativeHandle() == pD3D12Buffer);
- }
-}
diff --git a/Tests/TestApp/src/TestCreateObjFromNativeResGL.cpp b/Tests/TestApp/src/TestCreateObjFromNativeResGL.cpp
deleted file mode 100644
index 1d22ee1..0000000
--- a/Tests/TestApp/src/TestCreateObjFromNativeResGL.cpp
+++ /dev/null
@@ -1,143 +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"
-
-#if PLATFORM_WIN32
-
-# ifndef GLEW_STATIC
-# define GLEW_STATIC // Must be defined to use static version of glew
-# endif
-# include "GL/glew.h"
- #elif PLATFORM_LINUX
-
-# ifndef GLEW_STATIC
-# define GLEW_STATIC // Must be defined to use static version of glew
-# endif
-# ifndef GLEW_NO_GLU
-# define GLEW_NO_GLU
-# endif
-
-# include "GL/glew.h"
-
- // Undefine beautiful defines from GL/glx.h -> X11/Xlib.h
-# ifdef Bool
-# undef Bool
-# endif
-# ifdef True
-# undef True
-# endif
-# ifdef False
-# undef False
-# endif
-# ifdef Status
-# undef Status
-# endif
-# ifdef Success
-# undef Success
-# endif
-
-#elif PLATFORM_MACOS
-
-# ifndef GLEW_STATIC
-# define GLEW_STATIC // Must be defined to use static version of glew
-# endif
-# ifndef GLEW_NO_GLU
-# define GLEW_NO_GLU
-# endif
-
-# include "GL/glew.h"
-
-#elif PLATFORM_ANDROID
-
-# include <GLES3/gl3.h>
-# include <GLES3/gl3ext.h>
-
-#elif PLATFORM_IOS
-
-# include <OpenGLES/ES3/gl.h>
-
-#else
-# error Unsupported platform
-#endif
-
-#include "RenderDeviceGL.h"
-#include "TextureGL.h"
-#include "BufferGL.h"
-
-#include "Errors.h"
-#include "TestCreateObjFromNativeResGL.h"
-
-using namespace Diligent;
-
-void TestCreateObjFromNativeResGL::CreateTexture(Diligent::ITexture *pTexture)
-{
-#if PLATFORM_WIN32 || PLATFORM_LINUX || PLATFORM_ANDROID
- RefCntAutoPtr<IRenderDeviceGL> pDeviceGL(m_pDevice, IID_RenderDeviceGL);
- const auto &SrcTexDesc = pTexture->GetDesc();
- if (SrcTexDesc.Type == RESOURCE_DIM_TEX_CUBE_ARRAY)
- return;
-
- RefCntAutoPtr<ITextureGL> pTextureGL(pTexture, IID_TextureGL);
- auto GLHandle = pTextureGL->GetGLTextureHandle();
- RefCntAutoPtr<ITexture> pAttachedTexture;
- auto TmpTexDesc = SrcTexDesc;
- TmpTexDesc.Width = 0;
- TmpTexDesc.Height = 0;
- TmpTexDesc.MipLevels = 0;
- TmpTexDesc.Format = TEX_FORMAT_UNKNOWN;
- pDeviceGL->CreateTextureFromGLHandle(GLHandle, TmpTexDesc, RESOURCE_STATE_UNKNOWN, &pAttachedTexture);
- ++m_NumTexturesCreated;
-
- auto TestTexDesc = pAttachedTexture->GetDesc();
- if (m_pDevice->GetTextureFormatInfo(SrcTexDesc.Format).IsTypeless)
- TestTexDesc.Format = SrcTexDesc.Format;
-
- VERIFY_EXPR(TestTexDesc == SrcTexDesc);
- RefCntAutoPtr<ITextureGL> pAttachedTextureGL(pAttachedTexture, IID_TextureGL);
- VERIFY_EXPR(pAttachedTextureGL->GetGLTextureHandle() == GLHandle);
- VERIFY_EXPR(pAttachedTextureGL->GetBindTarget() == pTextureGL->GetBindTarget());
- VERIFY_EXPR( reinterpret_cast<size_t>(pAttachedTextureGL->GetNativeHandle()) == GLHandle);
-#endif
-}
-
-void TestCreateObjFromNativeResGL::CreateBuffer(Diligent::IBuffer *pBuffer)
-{
-#if PLATFORM_WIN32 || PLATFORM_LINUX || PLATFORM_ANDROID
- RefCntAutoPtr<IRenderDeviceGL> pDeviceGL(m_pDevice, IID_RenderDeviceGL);
- const auto &SrcBuffDesc = pBuffer->GetDesc();
- RefCntAutoPtr<IBufferGL> pBufferGL(pBuffer, IID_BufferGL);
- auto GLBufferHandle = pBufferGL->GetGLBufferHandle();
-
- RefCntAutoPtr<IBuffer> pBufferFromNativeGLHandle;
- pDeviceGL->CreateBufferFromGLHandle(GLBufferHandle, SrcBuffDesc, RESOURCE_STATE_UNKNOWN, &pBufferFromNativeGLHandle);
- ++m_NumBuffersCreated;
-
- const auto &TestBufferDesc = pBufferFromNativeGLHandle->GetDesc();
- VERIFY_EXPR(TestBufferDesc == SrcBuffDesc);
-
- RefCntAutoPtr<IBufferGL> pTestBufferGL(pBufferFromNativeGLHandle, IID_BufferGL);
- VERIFY_EXPR(pTestBufferGL->GetGLBufferHandle() == GLBufferHandle);
- VERIFY_EXPR( reinterpret_cast<size_t>(pTestBufferGL->GetNativeHandle()) == GLBufferHandle);
-#endif
-}
diff --git a/Tests/TestApp/src/TestCreateObjFromNativeResVK.cpp b/Tests/TestApp/src/TestCreateObjFromNativeResVK.cpp
deleted file mode 100644
index 3bb662a..0000000
--- a/Tests/TestApp/src/TestCreateObjFromNativeResVK.cpp
+++ /dev/null
@@ -1,82 +0,0 @@
-/* Copyright 2019 Diligent Graphics LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS.
- *
- * In no event and under no legal theory, whether in tort (including neVkigence),
- * contract, or otherwise, unless required by applicable law (such as deliberate
- * and grossly neVkigent acts) or agreed to in writing, shall any Contributor be
- * liable for any damages, including any direct, indirect, special, incidental,
- * or consequential damages of any character arising as a result of this License or
- * out of the use or inability to use the software (including but not limited to damages
- * for loss of goodwill, work stoppage, computer failure or malfunction, or any and
- * all other commercial damages or losses), even if such Contributor has been advised
- * of the possibility of such damages.
- */
-
-#include "pch.h"
-
-#if VULKAN_SUPPORTED
-#include "vulkan.h"
-#endif
-
-#include "RenderDeviceVk.h"
-#include "TextureVk.h"
-#include "BufferVk.h"
-
-#include "Errors.h"
-#include "TestCreateObjFromNativeResVK.h"
-
-using namespace Diligent;
-
-void TestCreateObjFromNativeResVK::CreateTexture(Diligent::ITexture *pTexture)
-{
-#if VULKAN_SUPPORTED
- RefCntAutoPtr<IRenderDeviceVk> pDeviceVk(m_pDevice, IID_RenderDeviceVk);
- const auto& SrcTexDesc = pTexture->GetDesc();
- if (SrcTexDesc.Type == RESOURCE_DIM_TEX_CUBE_ARRAY)
- return;
-
- RefCntAutoPtr<ITextureVk> pTextureVk(pTexture, IID_TextureVk);
- auto VkHandle = pTextureVk->GetVkImage();
- RefCntAutoPtr<ITexture> pAttachedTexture;
- pDeviceVk->CreateTextureFromVulkanImage(VkHandle, SrcTexDesc, RESOURCE_STATE_UNKNOWN, &pAttachedTexture);
- ++m_NumTexturesCreated;
-
- const auto& TestTexDesc = pAttachedTexture->GetDesc();
- VERIFY_EXPR(TestTexDesc == SrcTexDesc);
- RefCntAutoPtr<ITextureVk> pAttachedTextureVk(pAttachedTexture, IID_TextureVk);
- VERIFY_EXPR(pAttachedTextureVk->GetVkImage() == VkHandle);
- VERIFY_EXPR( reinterpret_cast<VkImage>(pAttachedTextureVk->GetNativeHandle()) == VkHandle);
- (void)TestTexDesc;
-#endif
-}
-
-void TestCreateObjFromNativeResVK::CreateBuffer(Diligent::IBuffer *pBuffer)
-{
-#if VULKAN_SUPPORTED
- RefCntAutoPtr<IRenderDeviceVk> pDeviceVk(m_pDevice, IID_RenderDeviceVk);
- const auto &SrcBuffDesc = pBuffer->GetDesc();
- RefCntAutoPtr<IBufferVk> pBufferVk(pBuffer, IID_BufferVk);
- auto VkBufferHandle = pBufferVk->GetVkBuffer();
-
- RefCntAutoPtr<IBuffer> pBufferFromNativeVkHandle;
- pDeviceVk->CreateBufferFromVulkanResource(VkBufferHandle, SrcBuffDesc, RESOURCE_STATE_UNKNOWN, &pBufferFromNativeVkHandle);
- ++m_NumBuffersCreated;
-
- const auto &TestBufferDesc = pBufferFromNativeVkHandle->GetDesc();
- VERIFY_EXPR(TestBufferDesc == SrcBuffDesc);
- (void)TestBufferDesc;
-
- RefCntAutoPtr<IBufferVk> pTestBufferVk(pBufferFromNativeVkHandle, IID_BufferVk);
- VERIFY_EXPR(pTestBufferVk->GetVkBuffer() == VkBufferHandle);
- VERIFY_EXPR( reinterpret_cast<VkBuffer>(pTestBufferVk->GetNativeHandle()) == VkBufferHandle);
-#endif
-}
diff --git a/Tests/TestApp/src/TestDepthStencilState.cpp b/Tests/TestApp/src/TestDepthStencilState.cpp
deleted file mode 100644
index 5730cc3..0000000
--- a/Tests/TestApp/src/TestDepthStencilState.cpp
+++ /dev/null
@@ -1,172 +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.
- */
-
-// EngineSandbox.cpp : Defines the entry point for the application.
-//
-
-#include "pch.h"
-#include "TestDepthStencilState.h"
-#include "ConvenienceFunctions.h"
-
-using namespace Diligent;
-
-void TestDepthStencilState::CreateTestDSS( DepthStencilStateDesc &DSSDesc )
-{
- RefCntAutoPtr<IPipelineState> pPSO;
- m_pDevice->CreatePipelineState( m_PSODesc, &pPSO );
- m_pDeviceContext->SetPipelineState( pPSO );
-
- RefCntAutoPtr<IShaderResourceBinding> pSRB;
- pPSO->CreateShaderResourceBinding(&pSRB);
- auto PSVarCount = pSRB->GetVariableCount(SHADER_TYPE_PIXEL);
- auto VSVarCount = pSRB->GetVariableCount(SHADER_TYPE_VERTEX);
- (void)PSVarCount;
- (void)VSVarCount;
-
-#if 0
- DSSDesc.Name = "TestDSS2";
- m_pDevice->CreateDepthStencilState( DSSDesc, &pDSState2 );
- assert( pDSState == pDSState2 );
- m_pDeviceContext->SetDepthStencilState( pDSState );
- m_pDeviceContext->SetDepthStencilState( pDSState2 );
- m_pDeviceContext->SetDepthStencilState( pDSState2, 2 );
-#endif
-}
-
-TestDepthStencilState::TestDepthStencilState( IRenderDevice *pDevice, IDeviceContext *pContext ) :
- TestPipelineStateBase(pDevice, "Depth-stencil state initialization test"),
- m_pDeviceContext(pContext)
-{
- DepthStencilStateDesc &DSSDesc = m_PSODesc.GraphicsPipeline.DepthStencilDesc;
-
- DSSDesc.DepthEnable = False;
- DSSDesc.DepthWriteEnable = False;
- CreateTestDSS( DSSDesc );
-
- DSSDesc.DepthEnable = True;
- CreateTestDSS( DSSDesc );
-
- DSSDesc.DepthWriteEnable = True;
- CreateTestDSS( DSSDesc );
-
- for( auto CmpFunc = COMPARISON_FUNC_UNKNOWN + 1; CmpFunc < COMPARISON_FUNC_NUM_FUNCTIONS; ++CmpFunc )
- {
- DSSDesc.DepthFunc = static_cast<COMPARISON_FUNCTION>(CmpFunc);
- CreateTestDSS( DSSDesc );
- }
-
- DSSDesc.StencilEnable = True;
- CreateTestDSS( DSSDesc );
-
- DSSDesc.StencilReadMask = 0xA9;
- CreateTestDSS( DSSDesc );
-
- DSSDesc.StencilWriteMask = 0xB8;
- CreateTestDSS( DSSDesc );
-
- for( int Face = 0; Face < 2; ++Face )
- {
- auto &FaceOp = Face == 0 ? DSSDesc.FrontFace : DSSDesc.BackFace;
- for( auto StOp = STENCIL_OP_UNDEFINED + 1; StOp < STENCIL_OP_NUM_OPS; ++StOp )
- {
- FaceOp.StencilFailOp = static_cast<STENCIL_OP>(StOp);
- CreateTestDSS( DSSDesc );
- }
-
- for( auto StOp = STENCIL_OP_UNDEFINED + 1; StOp < STENCIL_OP_NUM_OPS; ++StOp )
- {
- FaceOp.StencilDepthFailOp = static_cast<STENCIL_OP>(StOp);
- CreateTestDSS( DSSDesc );
- }
-
- for( auto StOp = STENCIL_OP_UNDEFINED + 1; StOp < STENCIL_OP_NUM_OPS; ++StOp )
- {
- FaceOp.StencilPassOp = static_cast<STENCIL_OP>(StOp);
- CreateTestDSS( DSSDesc );
- }
-
- for( auto CmpFunc = COMPARISON_FUNC_UNKNOWN + 1; CmpFunc < COMPARISON_FUNC_NUM_FUNCTIONS; ++CmpFunc )
- {
- FaceOp.StencilFunc = static_cast<COMPARISON_FUNCTION>(CmpFunc);
- CreateTestDSS( DSSDesc );
- }
- }
-
- auto pScript = CreateRenderScriptFromFile( "DepthStencilStateTest.lua", pDevice, pContext, [&]( Diligent::ScriptParser *pScriptParser )
- {
- DSSDesc = DepthStencilStateDesc();
- DSSDesc.DepthEnable = True;
- DSSDesc.DepthWriteEnable = True;
- DSSDesc.DepthFunc = COMPARISON_FUNC_NEVER;
- DSSDesc.StencilEnable = True;
- DSSDesc.StencilReadMask = 0xFA;
- DSSDesc.StencilWriteMask = 0xFF;
-
- DSSDesc.FrontFace.StencilFailOp = STENCIL_OP_DECR_SAT;
- DSSDesc.FrontFace.StencilDepthFailOp = STENCIL_OP_DECR_WRAP;
- DSSDesc.FrontFace.StencilPassOp = STENCIL_OP_INCR_WRAP;
- DSSDesc.FrontFace.StencilFunc = COMPARISON_FUNC_NOT_EQUAL;
-
- DSSDesc.BackFace.StencilFailOp = STENCIL_OP_INVERT;
- DSSDesc.BackFace.StencilDepthFailOp = STENCIL_OP_REPLACE;
- DSSDesc.BackFace.StencilPassOp = STENCIL_OP_INCR_SAT;
- DSSDesc.BackFace.StencilFunc = COMPARISON_FUNC_EQUAL;
- RefCntAutoPtr<IPipelineState> pPSO;
- pDevice->CreatePipelineState( m_PSODesc, &pPSO );
- pScriptParser->SetGlobalVariable( "TestGlobalPSO", pPSO );
- }
- );
-
- {
- RefCntAutoPtr<IPipelineState> pPSOFromScript, pDSStateFromScript2;
- pScript->GetPipelineStateByName( "TestPSO", &pPSOFromScript);
- //pScript->GetDepthStencilStateByName( "TestDSS2", &pDSStateFromScript2 );
- //assert( pDSStateFromScript == pDSStateFromScript2 );
- const auto &DSSDesc2 = pPSOFromScript->GetDesc().GraphicsPipeline.DepthStencilDesc;
-
- assert( DSSDesc2.DepthEnable == True );
- assert( DSSDesc2.DepthWriteEnable == True );
- assert( DSSDesc2.DepthFunc == COMPARISON_FUNC_LESS );
- assert( DSSDesc2.StencilEnable == True );
- assert( DSSDesc2.StencilReadMask == 0xF8 );
- assert( DSSDesc2.StencilWriteMask == 0xF1 );
- assert( DSSDesc2.FrontFace.StencilFailOp == STENCIL_OP_KEEP );
- assert( DSSDesc2.FrontFace.StencilDepthFailOp == STENCIL_OP_ZERO );
- assert( DSSDesc2.FrontFace.StencilPassOp == STENCIL_OP_REPLACE );
- assert( DSSDesc2.FrontFace.StencilFunc == COMPARISON_FUNC_EQUAL );
- assert( DSSDesc2.BackFace.StencilFailOp == STENCIL_OP_INCR_SAT );
- assert( DSSDesc2.BackFace.StencilDepthFailOp == STENCIL_OP_DECR_SAT );
- assert( DSSDesc2.BackFace.StencilPassOp == STENCIL_OP_INVERT );
- assert( DSSDesc2.BackFace.StencilFunc == COMPARISON_FUNC_NOT_EQUAL );
- (void)DSSDesc2;
- }
-
- {
- m_PSODesc.GraphicsPipeline.DepthStencilDesc = DepthStencilStateDesc();
- RefCntAutoPtr<IPipelineState> pPSO;
- m_pDevice->CreatePipelineState( m_PSODesc, &pPSO );
- pScript->Run( m_pDeviceContext, "TestDSSDesc", pPSO );
- }
-
- SetStatus(TestResult::Succeeded);
-}
diff --git a/Tests/TestApp/src/TestDrawCommands.cpp b/Tests/TestApp/src/TestDrawCommands.cpp
index a4641a6..2fdbd76 100644
--- a/Tests/TestApp/src/TestDrawCommands.cpp
+++ b/Tests/TestApp/src/TestDrawCommands.cpp
@@ -21,9 +21,6 @@
* of the possibility of such damages.
*/
-// EngineSandbox.cpp : Defines the entry point for the application.
-//
-
#include "pch.h"
#include "TestDrawCommands.h"
#include "MapHelper.h"
diff --git a/Tests/TestApp/src/TestGeometryShader.cpp b/Tests/TestApp/src/TestGeometryShader.cpp
index d72b323..b3dc8df 100644
--- a/Tests/TestApp/src/TestGeometryShader.cpp
+++ b/Tests/TestApp/src/TestGeometryShader.cpp
@@ -21,9 +21,6 @@
* of the possibility of such damages.
*/
-// EngineSandbox.cpp : Defines the entry point for the application.
-//
-
#include "pch.h"
#include "TestGeometryShader.h"
#include "MapHelper.h"
diff --git a/Tests/TestApp/src/TestMipMapsGeneration.cpp b/Tests/TestApp/src/TestMipMapsGeneration.cpp
deleted file mode 100644
index 5dcecc4..0000000
--- a/Tests/TestApp/src/TestMipMapsGeneration.cpp
+++ /dev/null
@@ -1,101 +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 "TestMipMapsGeneration.h"
-#include "RenderDevice.h"
-#include "GraphicsUtilities.h"
-#include "Errors.h"
-
-using namespace Diligent;
-
-TestMipMapsGeneration::TestMipMapsGeneration( IRenderDevice *pDevice, IDeviceContext *pContext ) :
- UnitTestBase("Texture mipmap generation")
-{
- TEXTURE_FORMAT TestFormats[] =
- {
- TEX_FORMAT_RGBA8_UNORM,
- TEX_FORMAT_RGBA8_UNORM_SRGB,
- TEX_FORMAT_RGBA32_FLOAT
- };
-
- int NumFormatsTested = 0;
- for( auto f = 0; f < _countof( TestFormats ); ++f )
- {
- TextureDesc TexDesc;
- TexDesc.Type = RESOURCE_DIM_TEX_2D;
- TexDesc.Format = TestFormats[f];
- TexDesc.Width = 128 + 6;
- TexDesc.Height = 128 + 5;
- TexDesc.BindFlags = BIND_SHADER_RESOURCE;
- TexDesc.MipLevels = 6;
- TexDesc.Usage = USAGE_DEFAULT;
- TexDesc.MiscFlags = MISC_TEXTURE_FLAG_GENERATE_MIPS;
-
- std::vector<Uint8> NullData(TexDesc.Width * TexDesc.Height * 16);
-
- {
- RefCntAutoPtr<ITexture> pTex;
- std::vector<TextureSubResData> SubresData(TexDesc.MipLevels);
- for(auto& MipLevelData : SubresData)
- {
- MipLevelData.pData = NullData.data();
- MipLevelData.Stride = TexDesc.Width * 16;
- }
- TextureData InitData{SubresData.data(), TexDesc.MipLevels};
-
- pDevice->CreateTexture(TexDesc, &InitData, &pTex);
- pContext->GenerateMips(pTex->GetDefaultView(TEXTURE_VIEW_SHADER_RESOURCE));
-
- TextureViewDesc ViewDesc(TEXTURE_VIEW_SHADER_RESOURCE, RESOURCE_DIM_TEX_2D_ARRAY);
- ViewDesc.MostDetailedMip = 1;
- ViewDesc.NumMipLevels = 3;
- ViewDesc.Flags = TEXTURE_VIEW_FLAG_ALLOW_MIP_MAP_GENERATION;
- RefCntAutoPtr<ITextureView> pTexView;
- pTex->CreateView(ViewDesc, &pTexView);
- pContext->GenerateMips(pTexView);
- }
-
- TexDesc.Type = RESOURCE_DIM_TEX_2D_ARRAY;
- TexDesc.ArraySize = 16;
- {
- RefCntAutoPtr<ITexture> pTex;
- pDevice->CreateTexture(TexDesc, nullptr, &pTex);
-
- TextureViewDesc ViewDesc(TEXTURE_VIEW_SHADER_RESOURCE, RESOURCE_DIM_TEX_2D_ARRAY);
- ViewDesc.FirstArraySlice = 2;
- ViewDesc.NumArraySlices = 5;
- ViewDesc.MostDetailedMip = 1;
- ViewDesc.NumMipLevels = 5;
- ViewDesc.Flags = TEXTURE_VIEW_FLAG_ALLOW_MIP_MAP_GENERATION;
- RefCntAutoPtr<ITextureView> pTexView;
- pTex->CreateView(ViewDesc, &pTexView);
- pContext->GenerateMips(pTexView);
-
- pContext->GenerateMips(pTex->GetDefaultView(TEXTURE_VIEW_SHADER_RESOURCE));
- }
- }
- std::stringstream infoss;
- infoss << "Formats tested: " << NumFormatsTested;
- SetStatus(TestResult::Succeeded, infoss.str().c_str());
-}
diff --git a/Tests/TestApp/src/TestPSOCompatibility.cpp b/Tests/TestApp/src/TestPSOCompatibility.cpp
deleted file mode 100644
index f9add52..0000000
--- a/Tests/TestApp/src/TestPSOCompatibility.cpp
+++ /dev/null
@@ -1,302 +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.
- */
-
-// EngineSandbox.cpp : Defines the entry point for the application.
-//
-
-#include "pch.h"
-#include "TestPSOCompatibility.h"
-
-using namespace Diligent;
-
-static const char* VS0 = R"(
-float4 main() : SV_Position
-{
- return float4(0.0, 0.0, 0.0, 0.0);
-}
-)";
-
-static const char* PS0 = R"(
-float4 main() : SV_Target
-{
- return float4(0.0, 0.0, 0.0, 0.0);
-}
-)";
-
-static const char* PS_Tex = R"(
-Texture2D<float4> g_tex2D;
-SamplerState g_tex2D_sampler;
-float4 main() : SV_Target
-{
- return g_tex2D.Sample(g_tex2D_sampler, float2(0.0, 0.0));
-}
-)";
-
-static const char* PS_Tex2 = R"(
-Texture2D<float4> g_tex2D2;
-SamplerState g_tex2D2_sampler;
-float4 main() : SV_Target
-{
- return g_tex2D2.Sample(g_tex2D2_sampler, float2(0.0, 0.0));
-}
-)";
-
-static const char* PS_ArrOfTex = R"(
-Texture2D<float4> g_tex2D[2];
-SamplerState g_tex2D_sampler;
-float4 main() : SV_Target
-{
- return g_tex2D[0].Sample(g_tex2D_sampler, float2(0.0, 0.0)) + g_tex2D[1].Sample(g_tex2D_sampler, float2(0.0, 0.0));
-}
-)";
-
-static const char* PS_TexArr = R"(
-Texture2DArray<float4> g_tex2D;
-SamplerState g_tex2D_sampler;
-float4 main() : SV_Target
-{
- return g_tex2D.Sample(g_tex2D_sampler, float3(0.0, 0.0, 0.0));
-}
-)";
-
-
-static const char* PS_CB = R"(
-cbuffer Test
-{
- float4 g_Test;
-};
-
-float4 main() : SV_Target
-{
- return g_Test;
-}
-)";
-
-static const char* PS1_CB = R"(
-cbuffer Test
-{
- float4 g_Test;
- float4 g_Test2;
-};
-
-float4 main() : SV_Target
-{
- return g_Test + g_Test2;
-}
-)";
-
-static const char* PS_2CB = R"(
-cbuffer Test
-{
- float4 g_Test;
-};
-
-cbuffer Test2
-{
- float4 g_Test2;
-};
-
-float4 main() : SV_Target
-{
- return g_Test + g_Test2;
-}
-)";
-
-static const char* PS_TexCB = R"(
-cbuffer Test
-{
- float4 g_Test;
-};
-
-cbuffer Test2
-{
- float4 g_Test2;
-};
-
-Texture2D<float4> g_tex2D;
-SamplerState g_tex2D_sampler;
-float4 main() : SV_Target
-{
- return g_Test + g_Test2 + g_tex2D.Sample(g_tex2D_sampler, float2(0.0, 0.0));
-}
-)";
-
-static const char* PS_TexCB2 = R"(
-cbuffer TestA
-{
- float4 g_Test;
-};
-
-cbuffer Test2A
-{
- float4 g_Test2;
-};
-
-Texture2D<float4> g_tex2DA;
-SamplerState g_tex2DA_sampler;
-float4 main() : SV_Target
-{
- return g_Test + g_Test2 + g_tex2DA.Sample(g_tex2DA_sampler, float2(0.0, 0.0));
-}
-)";
-
-static const char* CS_RwBuff = R"(
-RWTexture2D<float/* format=r32f */> g_RWTex;
-
-[numthreads(1,1,1)]
-void main()
-{
- g_RWTex[int2(0,0)] = 0.0;
-}
-)";
-
-static const char* CS_RwBuff2 = R"(
-RWTexture2D<float/* format=r32f */> g_RWTex2;
-
-[numthreads(1,1,1)]
-void main()
-{
- g_RWTex2[int2(0,0)] = 0.0;
-}
-)";
-
-static const char* CS_RwBuff3 = R"(
-RWTexture2D<float/* format=r32f */> g_RWTex;
-RWTexture2D<float/* format=r32f */> g_RWTex2;
-
-[numthreads(1,1,1)]
-void main()
-{
- g_RWTex[int2(0,0)] = 0.0;
- g_RWTex2[int2(0,0)] = 0.0;
-}
-)";
-
-
-RefCntAutoPtr<IPipelineState> TestPSOCompatibility::CreateTestPSO(const char *VSSource, const char *PSSource)
-{
- PipelineStateDesc PSODesc;
- PSODesc.IsComputePipeline = false;
- PSODesc.GraphicsPipeline.NumRenderTargets = 1;
- PSODesc.GraphicsPipeline.RTVFormats[0] = TEX_FORMAT_RGBA8_UNORM_SRGB;
- PSODesc.GraphicsPipeline.DepthStencilDesc.DepthEnable = False;
-
- ShaderCreateInfo CreationAttrs;
- CreationAttrs.SourceLanguage = SHADER_SOURCE_LANGUAGE_HLSL;
- CreationAttrs.UseCombinedTextureSamplers = true;
- RefCntAutoPtr<IShader> pVS;
- {
- CreationAttrs.Desc.ShaderType = SHADER_TYPE_VERTEX;
- CreationAttrs.EntryPoint = "main";
- CreationAttrs.Desc.Name = "PSO Compatibility test VS";
- CreationAttrs.Source = VSSource;
- m_pDevice->CreateShader(CreationAttrs, &pVS);
- }
-
- RefCntAutoPtr<IShader> pPS;
- {
- CreationAttrs.Desc.ShaderType = SHADER_TYPE_PIXEL;
- CreationAttrs.EntryPoint = "main";
- CreationAttrs.Desc.Name = "PSO Compatibility test PS";
- CreationAttrs.Source = PSSource;
- m_pDevice->CreateShader(CreationAttrs, &pPS);
- }
-
- PSODesc.GraphicsPipeline.pVS = pVS;
- PSODesc.GraphicsPipeline.pPS = pPS;
-
- RefCntAutoPtr<IPipelineState> pPSO;
- m_pDevice->CreatePipelineState(PSODesc, &pPSO);
-
- return pPSO;
-}
-
-RefCntAutoPtr<IPipelineState> TestPSOCompatibility::CreateTestPSO(const char *CSSource)
-{
- PipelineStateDesc PSODesc;
- PSODesc.IsComputePipeline = true;
- ShaderCreateInfo CreationAttrs;
- CreationAttrs.SourceLanguage = SHADER_SOURCE_LANGUAGE_HLSL;
- CreationAttrs.UseCombinedTextureSamplers = true;
- RefCntAutoPtr<IShader> pCS;
- {
- CreationAttrs.Desc.ShaderType = SHADER_TYPE_COMPUTE;
- CreationAttrs.EntryPoint = "main";
- CreationAttrs.Desc.Name = "PSO Compatibility test CS";
- CreationAttrs.Source = CSSource;
- m_pDevice->CreateShader(CreationAttrs, &pCS);
- }
- PSODesc.ComputePipeline.pCS = pCS;
-
- RefCntAutoPtr<IPipelineState> pPSO;
- m_pDevice->CreatePipelineState(PSODesc, &pPSO);
-
- return pPSO;
-}
-
-TestPSOCompatibility::TestPSOCompatibility(IRenderDevice *pDevice ) :
- UnitTestBase("PSO Compatibility test"),
- m_pDevice(pDevice)
-{
- auto DevType = pDevice->GetDeviceCaps().DevType;
- auto PSO0 = CreateTestPSO(VS0, PS0);
- VERIFY_EXPR(PSO0->IsCompatibleWith(PSO0));
- auto PSO0_1 = CreateTestPSO(VS0, PS0);
- VERIFY_EXPR(PSO0->IsCompatibleWith(PSO0_1));
- VERIFY_EXPR(PSO0_1->IsCompatibleWith(PSO0));
-
- auto PSO_Tex = CreateTestPSO(VS0, PS_Tex);
- auto PSO_Tex2 = CreateTestPSO(VS0, PS_Tex2);
- auto PSO_TexArr = CreateTestPSO(VS0, PS_TexArr);
- auto PSO_ArrOfTex = CreateTestPSO(VS0, PS_ArrOfTex);
- VERIFY_EXPR(PSO_Tex->IsCompatibleWith(PSO_Tex2));
- if(DevType!=DeviceType::D3D12 && DevType != DeviceType::Vulkan)
- VERIFY_EXPR(!PSO_Tex->IsCompatibleWith(PSO_TexArr));
- VERIFY_EXPR(!PSO_Tex->IsCompatibleWith(PSO_ArrOfTex));
- if (DevType != DeviceType::D3D12 && DevType != DeviceType::Vulkan)
- VERIFY_EXPR(!PSO_Tex2->IsCompatibleWith(PSO_TexArr));
- VERIFY_EXPR(!PSO_Tex2->IsCompatibleWith(PSO_ArrOfTex));
- VERIFY_EXPR(!PSO_TexArr->IsCompatibleWith(PSO_ArrOfTex));
-
- auto PSO_CB = CreateTestPSO(VS0, PS_CB);
- auto PSO1_CB = CreateTestPSO(VS0, PS1_CB);
- auto PSO_2CB = CreateTestPSO(VS0, PS_2CB);
- VERIFY_EXPR(PSO_CB->IsCompatibleWith(PSO1_CB));
- VERIFY_EXPR(!PSO_CB->IsCompatibleWith(PSO_2CB));
-
- auto PSO_TexCB = CreateTestPSO(VS0, PS_TexCB);
- auto PSO_TexCB2 = CreateTestPSO(VS0, PS_TexCB2);
- VERIFY_EXPR(PSO_TexCB->IsCompatibleWith(PSO_TexCB2));
- VERIFY_EXPR(PSO_TexCB2->IsCompatibleWith(PSO_TexCB));
-
- if(pDevice->GetDeviceCaps().bComputeShadersSupported)
- {
- auto PSO_RWBuff = CreateTestPSO(CS_RwBuff);
- auto PSO_RWBuff2 = CreateTestPSO(CS_RwBuff2);
- auto PSO_RWBuff3 = CreateTestPSO(CS_RwBuff3);
- VERIFY_EXPR(PSO_RWBuff->IsCompatibleWith(PSO_RWBuff2));
- VERIFY_EXPR(!PSO_RWBuff->IsCompatibleWith(PSO_RWBuff3));
- }
-
- SetStatus(TestResult::Succeeded);
-}
diff --git a/Tests/TestApp/src/TestPipelineStateBase.cpp b/Tests/TestApp/src/TestPipelineStateBase.cpp
deleted file mode 100644
index 53aa7bd..0000000
--- a/Tests/TestApp/src/TestPipelineStateBase.cpp
+++ /dev/null
@@ -1,67 +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.
- */
-
-// EngineSandbox.cpp : Defines the entry point for the application.
-//
-#include "pch.h"
-#include "TestPipelineStateBase.h"
-
-using namespace Diligent;
-
-static const char g_ShaderSource[] =
-"void VSMain(out float4 pos : SV_POSITION) \n"
-"{ \n"
-" pos = float4(0.0, 0.0, 0.0, 0.0); \n"
-"} \n"
-" \n"
-"void PSMain(out float4 col : SV_TARGET) \n"
-"{ \n"
-" col = float4(0.0, 0.0, 0.0, 0.0); \n"
-"} \n"
-;
-
-TestPipelineStateBase::TestPipelineStateBase(Diligent::IRenderDevice *pDevice, const char *Name) :
- UnitTestBase(Name),
- m_pDevice(pDevice)
-{
- ShaderCreateInfo Attrs;
- Attrs.Source = g_ShaderSource;
- Attrs.EntryPoint = "VSMain";
- Attrs.Desc.ShaderType = SHADER_TYPE_VERTEX;
- Attrs.Desc.Name = "TrivialVS (TestPipelineStateBase)";
- Attrs.SourceLanguage = SHADER_SOURCE_LANGUAGE_HLSL;
- Attrs.UseCombinedTextureSamplers = true;
- m_pDevice->CreateShader(Attrs, &m_pTrivialVS);
-
- Attrs.EntryPoint = "PSMain";
- Attrs.Desc.ShaderType = SHADER_TYPE_PIXEL;
- Attrs.Desc.Name = "TrivialPS (TestPipelineStateBase)";
- m_pDevice->CreateShader(Attrs, &m_pTrivialPS);
-
- m_PSODesc.GraphicsPipeline.pVS = m_pTrivialVS;
- m_PSODesc.GraphicsPipeline.pPS = m_pTrivialPS;
- m_PSODesc.GraphicsPipeline.PrimitiveTopology = PRIMITIVE_TOPOLOGY_TRIANGLE_LIST;
- m_PSODesc.GraphicsPipeline.NumRenderTargets = 1;
- m_PSODesc.GraphicsPipeline.RTVFormats[0] = TEX_FORMAT_RGBA8_UNORM;
- m_PSODesc.GraphicsPipeline.DSVFormat = TEX_FORMAT_D32_FLOAT;
-}
diff --git a/Tests/TestApp/src/TestRasterizerState.cpp b/Tests/TestApp/src/TestRasterizerState.cpp
deleted file mode 100644
index 2fc9c53..0000000
--- a/Tests/TestApp/src/TestRasterizerState.cpp
+++ /dev/null
@@ -1,135 +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.
- */
-
-// EngineSandbox.cpp : Defines the entry point for the application.
-//
-
-#include "pch.h"
-#include "TestRasterizerState.h"
-#include "ConvenienceFunctions.h"
-
-using namespace Diligent;
-
-void TestRasterizerState::CreateTestRS()
-{
- RefCntAutoPtr<IPipelineState> pPSO;
- m_PSODesc.Name = "TestRS1";
- m_pDevice->CreatePipelineState( m_PSODesc, &pPSO );
- //RSDesc.Name = "TestRS2";
- //m_pDevice->CreateRasterizerState( RSDesc, &pRS2 );
- //assert( pRS == pRS2 );
- m_pDeviceContext->SetPipelineState( pPSO );
- //m_pDeviceContext->SetRasterizerState( pRS2 );
-}
-
-TestRasterizerState::TestRasterizerState( IRenderDevice *pDevice, IDeviceContext *pContext ) :
- TestPipelineStateBase(pDevice, "Rasterizer state initialization test"),
- m_pDeviceContext(pContext)
-{
- RasterizerStateDesc &RSDesc = m_PSODesc.GraphicsPipeline.RasterizerDesc;
- CreateTestRS( );
-
- for( auto FillMode = FILL_MODE_UNDEFINED + 1; FillMode < FILL_MODE_NUM_MODES; ++FillMode )
- {
- RSDesc.FillMode = static_cast<FILL_MODE>(FillMode);
- CreateTestRS();
- }
-
- for( auto CullMode = CULL_MODE_UNDEFINED + 1; CullMode < CULL_MODE_NUM_MODES; ++CullMode )
- {
- RSDesc.CullMode = static_cast<CULL_MODE>(CullMode);
- CreateTestRS();
- }
-
- RSDesc.FrontCounterClockwise = !RSDesc.FrontCounterClockwise;
- CreateTestRS();
-
- RSDesc.DepthBias = 100;
- CreateTestRS();
-
- RSDesc.DepthBiasClamp = 1.f;
- CreateTestRS();
-
- RSDesc.SlopeScaledDepthBias = 2.f;
- CreateTestRS();
-
- RSDesc.DepthClipEnable = !RSDesc.DepthClipEnable;
- CreateTestRS();
-
-#if 0
- RSDesc.ScissorEnable = !RSDesc.ScissorEnable;
- CreateTestRS( RSDesc );
-#endif
-
- RSDesc.AntialiasedLineEnable = !RSDesc.AntialiasedLineEnable;
- CreateTestRS();
-
- auto pScript = CreateRenderScriptFromFile( "RasterizerStateTest.lua", pDevice, pContext, [&]( Diligent::ScriptParser *pScriptParser )
- {
- m_PSODesc.Name = "PSO-TestRS";
- RSDesc = RasterizerStateDesc();
- RSDesc.FillMode = FILL_MODE_WIREFRAME;
- RSDesc.CullMode = CULL_MODE_FRONT;
- RSDesc.FrontCounterClockwise = True;
- RSDesc.DepthBias = 64;
- RSDesc.DepthBiasClamp = 98.f;
- RSDesc.SlopeScaledDepthBias = 12.5f;
- RSDesc.DepthClipEnable = False;
- RSDesc.ScissorEnable = False;
- RSDesc.AntialiasedLineEnable = True;
-
- RefCntAutoPtr<IPipelineState> pPSO;
- pDevice->CreatePipelineState( m_PSODesc, &pPSO);
- pScriptParser->SetGlobalVariable( "TestGlobalPSO", pPSO );
- }
- );
-
- {
- RefCntAutoPtr<IPipelineState> pPSOFromScript, pRSFromScript2;
- pScript->GetPipelineStateByName( "TestRS_PSO", &pPSOFromScript);
- //pScript->GetRasterizerStateByName( "TestRS2", &pRSFromScript2 );
- const auto &PSODesc = pPSOFromScript->GetDesc();
-
- const auto &RSDesc2 = PSODesc.GraphicsPipeline.RasterizerDesc;
-
- assert( RSDesc2.FillMode == FILL_MODE_WIREFRAME );
- assert( RSDesc2.CullMode == CULL_MODE_BACK );
- assert( RSDesc2.FrontCounterClockwise == True );
- assert( RSDesc2.DepthBias == 32 );
- assert( RSDesc2.DepthBiasClamp == 63.0 );
- assert( RSDesc2.SlopeScaledDepthBias == 31.25 );
- assert( RSDesc2.DepthClipEnable == True );
- assert( RSDesc2.ScissorEnable == False );
- assert( RSDesc2.AntialiasedLineEnable == True );
- (void)RSDesc2;
- }
-
- {
- m_PSODesc.GraphicsPipeline.RasterizerDesc = RasterizerStateDesc();
- RefCntAutoPtr<IPipelineState> pPSO;
- m_pDevice->CreatePipelineState(m_PSODesc, &pPSO );
- pScript->Run( m_pDeviceContext, "TestRSDescFunc", pPSO );
- }
-
- SetStatus(TestResult::Succeeded);
-}
diff --git a/Tests/TestApp/src/TestRenderTarget.cpp b/Tests/TestApp/src/TestRenderTarget.cpp
index c74af76..7a18990 100644
--- a/Tests/TestApp/src/TestRenderTarget.cpp
+++ b/Tests/TestApp/src/TestRenderTarget.cpp
@@ -21,9 +21,6 @@
* of the possibility of such damages.
*/
-// EngineSandbox.cpp : Defines the entry point for the application.
-//
-
#include "pch.h"
#include "TestRenderTarget.h"
#include "GraphicsUtilities.h"
diff --git a/Tests/TestApp/src/TestSamplerCreation.cpp b/Tests/TestApp/src/TestSamplerCreation.cpp
deleted file mode 100644
index c020433..0000000
--- a/Tests/TestApp/src/TestSamplerCreation.cpp
+++ /dev/null
@@ -1,129 +0,0 @@
-/* Copyright 2019 Diligent Graphics LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS.
- *
- * In no event and under no legal theory, whether in tort (including negligence),
- * contract, or otherwise, unless required by applicable law (such as deliberate
- * and grossly negligent acts) or agreed to in writing, shall any Contributor be
- * liable for any damages, including any direct, indirect, special, incidental,
- * or consequential damages of any character arising as a result of this License or
- * out of the use or inability to use the software (including but not limited to damages
- * for loss of goodwill, work stoppage, computer failure or malfunction, or any and
- * all other commercial damages or losses), even if such Contributor has been advised
- * of the possibility of such damages.
- */
-
-#include "pch.h"
-#include "TestSamplerCreation.h"
-#include "RenderDevice.h"
-
-using namespace Diligent;
-
-TestSamplerCreation::TestSamplerCreation(IRenderDevice *pDevice) :
- UnitTestBase("Test sampler creation"),
- m_pDevice(pDevice)
-{
- // Test different filters
- for(int Min = 0; Min < 2; ++Min)
- for(int Mag = 0; Mag < 2; ++Mag)
- for(int Mip = 0; Mip < 2; ++Mip)
- {
- SamplerDesc SamplerDesc;
- SamplerDesc.MinFilter = Min ? FILTER_TYPE_LINEAR : FILTER_TYPE_POINT;
- SamplerDesc.MagFilter = Mag ? FILTER_TYPE_LINEAR : FILTER_TYPE_POINT;
- SamplerDesc.MipFilter = Mip ? FILTER_TYPE_LINEAR : FILTER_TYPE_POINT;
- RefCntAutoPtr<ISampler> pSampler;
- m_pDevice->CreateSampler(SamplerDesc, &pSampler);
- }
-
- {
- SamplerDesc SamplerDesc;
- SamplerDesc.MinFilter = FILTER_TYPE_ANISOTROPIC;
- SamplerDesc.MagFilter = FILTER_TYPE_ANISOTROPIC;
- SamplerDesc.MipFilter = FILTER_TYPE_ANISOTROPIC;
- SamplerDesc.MaxAnisotropy = 4;
- RefCntAutoPtr<ISampler> pSampler;
- m_pDevice->CreateSampler(SamplerDesc, &pSampler);
- }
-
- for(int Min = 0; Min < 2; ++Min)
- for(int Mag = 0; Mag < 2; ++Mag)
- for(int Mip = 0; Mip < 2; ++Mip)
- {
- SamplerDesc SamplerDesc;
- SamplerDesc.MinFilter = Min ? FILTER_TYPE_COMPARISON_LINEAR : FILTER_TYPE_COMPARISON_POINT;
- SamplerDesc.MagFilter = Mag ? FILTER_TYPE_COMPARISON_LINEAR : FILTER_TYPE_COMPARISON_POINT;
- SamplerDesc.MipFilter = Mip ? FILTER_TYPE_COMPARISON_LINEAR : FILTER_TYPE_COMPARISON_POINT;
- RefCntAutoPtr<ISampler> pSampler;
- m_pDevice->CreateSampler(SamplerDesc, &pSampler);
- }
-
- {
- SamplerDesc SamplerDesc;
- SamplerDesc.MinFilter = FILTER_TYPE_COMPARISON_ANISOTROPIC;
- SamplerDesc.MagFilter = FILTER_TYPE_COMPARISON_ANISOTROPIC;
- SamplerDesc.MipFilter = FILTER_TYPE_COMPARISON_ANISOTROPIC;
- SamplerDesc.MaxAnisotropy = 4;
- RefCntAutoPtr<ISampler> pSampler;
- m_pDevice->CreateSampler(SamplerDesc, &pSampler);
- }
-
- // Test address modes
- TEXTURE_ADDRESS_MODE AddrModes[] =
- {
- TEXTURE_ADDRESS_WRAP,
- TEXTURE_ADDRESS_MIRROR,
- TEXTURE_ADDRESS_CLAMP,
- TEXTURE_ADDRESS_BORDER
- //TEXTURE_ADDRESS_MIRROR_ONCE // This mode is not supported on Intel HW
- };
-
- for(int AddrMode = 0; AddrMode < _countof(AddrModes); ++AddrMode)
- {
- SamplerDesc SamplerDesc;
- SamplerDesc.MinFilter = FILTER_TYPE_LINEAR;
- SamplerDesc.MagFilter = FILTER_TYPE_LINEAR;
- SamplerDesc.MipFilter = FILTER_TYPE_LINEAR;
- SamplerDesc.AddressU = SamplerDesc.AddressV = SamplerDesc.AddressW = AddrModes[AddrMode];
- RefCntAutoPtr<ISampler> pSampler;
- m_pDevice->CreateSampler(SamplerDesc, &pSampler);
- }
-
- // Test comparison funcs
- COMPARISON_FUNCTION CmpFuncs[] =
- {
- COMPARISON_FUNC_NEVER,
- COMPARISON_FUNC_LESS,
- COMPARISON_FUNC_EQUAL,
- COMPARISON_FUNC_LESS_EQUAL,
- COMPARISON_FUNC_GREATER,
- COMPARISON_FUNC_NOT_EQUAL,
- COMPARISON_FUNC_GREATER_EQUAL,
- COMPARISON_FUNC_ALWAYS
- };
-
- for(int CmpFunc=0; CmpFunc < _countof(CmpFuncs); ++CmpFunc)
- {
- SamplerDesc SamplerDesc;
- SamplerDesc.MinFilter = FILTER_TYPE_LINEAR;
- SamplerDesc.MagFilter = FILTER_TYPE_LINEAR;
- SamplerDesc.MipFilter = FILTER_TYPE_LINEAR;
- SamplerDesc.ComparisonFunc = CmpFuncs[CmpFunc];
- RefCntAutoPtr<ISampler> pSampler1, pSampler2;
- SamplerDesc.Name = "Sam1";
- m_pDevice->CreateSampler(SamplerDesc, &pSampler1);
- SamplerDesc.Name = "Sam2";
- m_pDevice->CreateSampler(SamplerDesc, &pSampler2);
- assert(pSampler1 == pSampler2);
- }
-
- SetStatus(TestResult::Succeeded);
-}
diff --git a/Tests/TestApp/src/TestSeparateTextureSampler.cpp b/Tests/TestApp/src/TestSeparateTextureSampler.cpp
deleted file mode 100644
index 3977023..0000000
--- a/Tests/TestApp/src/TestSeparateTextureSampler.cpp
+++ /dev/null
@@ -1,177 +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.
- */
-
-// EngineSandbox.cpp : Defines the entry point for the application.
-//
-
-#include "pch.h"
-#include "TestSeparateTextureSampler.h"
-
-static const char g_VSShaderSource[] =
-R"(
-void VSMain(out float4 pos : SV_POSITION)
-{
- pos = float4(0.0, 0.0, 0.0, 0.0);
-}
-)";
-
-static const char g_PSShaderSource[] =
-R"(
-
-Texture2D g_Tex;
-SamplerState g_Sam;
-Texture2D g_Tex2;
-SamplerState g_Sam2;
-SamplerState g_Sam3[2];
-SamplerState g_Sam4[2];
-
-void PSMain(out float4 col : SV_TARGET)
-{
- col = g_Tex.Sample(g_Sam, float2(0.5, 0.5)) +
- g_Tex2.Sample(g_Sam2, float2(0.5, 0.5)) +
- g_Tex2.Sample(g_Sam3[0], float2(0.5, 0.5)) +
- g_Tex2.Sample(g_Sam3[1], float2(0.5, 0.5)) +
- g_Tex2.Sample(g_Sam4[0], float2(0.5, 0.5)) +
- g_Tex2.Sample(g_Sam4[1], float2(0.5, 0.5));
-}
-)";
-
-using namespace Diligent;
-
-TestSeparateTextureSampler::TestSeparateTextureSampler(IRenderDevice *pDevice, IDeviceContext *pContext) :
- UnitTestBase("Test separate texture sampler")
-{
- if (pDevice->GetDeviceCaps().IsD3DDevice() || pDevice->GetDeviceCaps().IsVulkanDevice())
- {
- ShaderCreateInfo Attrs;
- Attrs.Source = g_VSShaderSource;
- Attrs.EntryPoint = "VSMain";
- Attrs.Desc.ShaderType = SHADER_TYPE_VERTEX;
- Attrs.Desc.Name = "VSMain (TestSeparateTextureSampler)";
- Attrs.SourceLanguage = SHADER_SOURCE_LANGUAGE_HLSL;
- RefCntAutoPtr<IShader> pVS;
- pDevice->CreateShader(Attrs, &pVS);
-
- Attrs.Source = g_PSShaderSource;
- Attrs.EntryPoint = "PSMain";
- Attrs.Desc.ShaderType = SHADER_TYPE_PIXEL;
- Attrs.Desc.Name = "PSMain (TestSeparateTextureSampler)";
-
- RefCntAutoPtr<IShader> pPS;
- pDevice->CreateShader(Attrs, &pPS);
-
- PipelineStateDesc PSODesc;
- PSODesc.GraphicsPipeline.pVS = pVS;
- PSODesc.GraphicsPipeline.pPS = pPS;
- PSODesc.GraphicsPipeline.PrimitiveTopology = PRIMITIVE_TOPOLOGY_TRIANGLE_LIST;
- PSODesc.GraphicsPipeline.NumRenderTargets = 1;
- PSODesc.GraphicsPipeline.RTVFormats[0] = TEX_FORMAT_RGBA8_UNORM;
- PSODesc.GraphicsPipeline.DSVFormat = TEX_FORMAT_UNKNOWN;
- PSODesc.GraphicsPipeline.DepthStencilDesc.DepthEnable = false;
-
- ShaderResourceVariableDesc Vars[] =
- {
- {SHADER_TYPE_PIXEL, "g_Tex", SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE},
- {SHADER_TYPE_PIXEL, "g_Sam", SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC},
- {SHADER_TYPE_PIXEL, "g_Tex2", SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC},
- {SHADER_TYPE_PIXEL, "g_Sam2", SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE},
- {SHADER_TYPE_PIXEL, "g_Sam4", SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE}
- };
- PSODesc.ResourceLayout.Variables = Vars;
- PSODesc.ResourceLayout.NumVariables = _countof(Vars);
-
- StaticSamplerDesc StaticSamplers[] =
- {
- {SHADER_TYPE_PIXEL, "g_Sam2", SamplerDesc{}}
- };
- PSODesc.ResourceLayout.StaticSamplers = StaticSamplers;
- PSODesc.ResourceLayout.NumStaticSamplers = _countof(StaticSamplers);
-
- RefCntAutoPtr<IPipelineState> pPSO;
- pDevice->CreatePipelineState(PSODesc, &pPSO);
-
- TextureDesc TexDesc;
- TexDesc.Name = "Separate sampler texture test";
- TexDesc.Type = RESOURCE_DIM_TEX_2D;
- TexDesc.Width = 256;
- TexDesc.Height = 256;
- TexDesc.Format = TEX_FORMAT_RGBA8_UNORM;
- TexDesc.Usage = USAGE_DEFAULT;
- TexDesc.BindFlags = BIND_SHADER_RESOURCE;
- RefCntAutoPtr<ITexture> pTexture;
- pDevice->CreateTexture( TexDesc, nullptr, &pTexture );
-
- RefCntAutoPtr<ISampler> pSampler;
- pDevice->CreateSampler( SamplerDesc{}, &pSampler );
- IDeviceObject* ppSamplers[2] = {pSampler, pSampler};
- pPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, "g_Sam3")->SetArray(ppSamplers, 0, 2);
-
- RefCntAutoPtr<IShaderResourceBinding> pSRB;
- pPSO->CreateShaderResourceBinding(&pSRB, true);
-
- pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_Tex")->Set(pTexture->GetDefaultView(TEXTURE_VIEW_SHADER_RESOURCE));
- pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_Sam")->Set(pSampler);
- pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_Sam4")->SetArray(ppSamplers, 0, 2);
- pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_Tex2")->Set(pTexture->GetDefaultView(TEXTURE_VIEW_SHADER_RESOURCE));
- VERIFY_EXPR(pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_Sam2") == nullptr);
-
- auto VarCount = pSRB->GetVariableCount(SHADER_TYPE_PIXEL);
- VERIFY_EXPR(VarCount == 4);
- for(Uint32 v=0; v < VarCount; ++v)
- {
- auto* pVar = pSRB->GetVariableByIndex(SHADER_TYPE_PIXEL, v);
- VERIFY_EXPR(pVar->GetIndex() == v);
- VERIFY_EXPR(pVar->GetType() == SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE || pVar->GetType() == SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC);
- auto pVar2 = pSRB->GetVariableByName(SHADER_TYPE_PIXEL, pVar->GetResourceDesc().Name);
- VERIFY_EXPR(pVar == pVar2);
- (void)pVar2;
- }
-
- TextureDesc RenderTargetDesc;
- RenderTargetDesc.Type = RESOURCE_DIM_TEX_2D;
- RenderTargetDesc.Width = 256;
- RenderTargetDesc.Height = 256;
- RenderTargetDesc.BindFlags = BIND_RENDER_TARGET | BIND_SHADER_RESOURCE;
- RenderTargetDesc.Format = TEX_FORMAT_RGBA8_UNORM;
- RenderTargetDesc.Name = "TestSeparateTextureSampler: test render target";
- RefCntAutoPtr<ITexture> pRenderTarget;
- pDevice->CreateTexture(RenderTargetDesc, nullptr, &pRenderTarget);
-
- ITextureView* pRTV[] = {pRenderTarget->GetDefaultView(TEXTURE_VIEW_RENDER_TARGET)};
- pContext->SetRenderTargets(1, pRTV, nullptr, RESOURCE_STATE_TRANSITION_MODE_TRANSITION);
- float Zero[4] = {};
- pContext->ClearRenderTarget(pRTV[0], Zero, RESOURCE_STATE_TRANSITION_MODE_VERIFY);
- pContext->SetPipelineState(pPSO);
- pContext->CommitShaderResources(pSRB, RESOURCE_STATE_TRANSITION_MODE_TRANSITION);
- DrawAttribs DrawAttrs(3, DRAW_FLAG_VERIFY_ALL);
- pContext->Draw(DrawAttrs);
-
- pContext->SetRenderTargets(0, nullptr, nullptr, RESOURCE_STATE_TRANSITION_MODE_TRANSITION);
-
- SetStatus(TestResult::Succeeded);
- }
- else
- {
- SetStatus(TestResult::Skipped);
- }
-}
diff --git a/Tests/TestApp/src/TestShaderResArrays.cpp b/Tests/TestApp/src/TestShaderResArrays.cpp
deleted file mode 100644
index 79029c3..0000000
--- a/Tests/TestApp/src/TestShaderResArrays.cpp
+++ /dev/null
@@ -1,195 +0,0 @@
-/* Copyright 2019 Diligent Graphics LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS.
- *
- * In no event and under no legal theory, whether in tort (including negligence),
- * contract, or otherwise, unless required by applicable law (such as deliberate
- * and grossly negligent acts) or agreed to in writing, shall any Contributor be
- * liable for any damages, including any direct, indirect, special, incidental,
- * or consequential damages of any character arising as a result of this License or
- * out of the use or inability to use the software (including but not limited to damages
- * for loss of goodwill, work stoppage, computer failure or malfunction, or any and
- * all other commercial damages or losses), even if such Contributor has been advised
- * of the possibility of such damages.
- */
-
-// EngineSandbox.cpp : Defines the entry point for the application.
-//
-
-#include "pch.h"
-#include "TestShaderResArrays.h"
-#include "GraphicsUtilities.h"
-#include "TestTexturing.h"
-
-using namespace Diligent;
-
-TestShaderResArrays::TestShaderResArrays(IRenderDevice *pDevice, IDeviceContext *pDeviceContext, ISwapChain *pSwapChain, float fMinXCoord, float fMinYCoord, float fXExtent, float fYExtent) :
- UnitTestBase("Shader resource array test")
-{
- m_pRenderDevice = pDevice;
- m_pDeviceContext = pDeviceContext;
-
- ShaderCreateInfo CreationAttrs;
- RefCntAutoPtr<IShaderSourceInputStreamFactory> pShaderSourceFactory;
- pDevice->GetEngineFactory()->CreateDefaultShaderSourceStreamFactory(nullptr, &pShaderSourceFactory);
- CreationAttrs.pShaderSourceStreamFactory = pShaderSourceFactory;
- CreationAttrs.UseCombinedTextureSamplers = true;
- CreationAttrs.HLSLVersion = ShaderCreateInfo::ShaderVersion{5, 0};
- RefCntAutoPtr<Diligent::IShader> pVS, pPS;
- {
- CreationAttrs.Desc.Name = "TestShaderResArrays: VS";
- CreationAttrs.FilePath = "Shaders\\ShaderResArrayTest.vsh";
- CreationAttrs.Desc.ShaderType = SHADER_TYPE_VERTEX;
- CreationAttrs.SourceLanguage = SHADER_SOURCE_LANGUAGE_HLSL;
- m_pRenderDevice->CreateShader( CreationAttrs, &pVS );
- }
-
- {
- CreationAttrs.Desc.Name = "TestShaderResArrays: PS";
- CreationAttrs.FilePath = "Shaders\\ShaderResArrayTest.psh";
- CreationAttrs.Desc.ShaderType = SHADER_TYPE_PIXEL;
- CreationAttrs.SourceLanguage = SHADER_SOURCE_LANGUAGE_HLSL;
- m_pRenderDevice->CreateShader( CreationAttrs, &pPS );
- }
-
- PipelineStateDesc PSODesc;
- StaticSamplerDesc StaticSampler;
- StaticSampler.Desc.MinFilter = FILTER_TYPE_LINEAR;
- StaticSampler.Desc.MagFilter = FILTER_TYPE_LINEAR;
- StaticSampler.Desc.MipFilter = FILTER_TYPE_LINEAR;
- StaticSampler.ShaderStages = SHADER_TYPE_PIXEL;
- StaticSampler.SamplerOrTextureName = "g_tex2DTest";
- PSODesc.ResourceLayout.NumStaticSamplers = 1;
- PSODesc.ResourceLayout.StaticSamplers = &StaticSampler;
- ShaderResourceVariableDesc Vars[] =
- {
- {SHADER_TYPE_PIXEL, "g_tex2DTest", SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE},
- {SHADER_TYPE_PIXEL, "g_tex2DTest2", SHADER_RESOURCE_VARIABLE_TYPE_STATIC},
- {SHADER_TYPE_PIXEL, "g_tex2D", SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC}
- };
- PSODesc.ResourceLayout.Variables = Vars;
- PSODesc.ResourceLayout.NumVariables = _countof(Vars);
- PSODesc.GraphicsPipeline.DepthStencilDesc.DepthEnable = False;
- PSODesc.GraphicsPipeline.RasterizerDesc.CullMode = CULL_MODE_NONE;
- PSODesc.GraphicsPipeline.BlendDesc.IndependentBlendEnable = False;
- PSODesc.GraphicsPipeline.BlendDesc.RenderTargets[0].BlendEnable = False;
- PSODesc.GraphicsPipeline.NumRenderTargets = 1;
- PSODesc.GraphicsPipeline.RTVFormats[0] = pSwapChain->GetDesc().ColorBufferFormat;
- PSODesc.GraphicsPipeline.DSVFormat = pSwapChain->GetDesc().DepthBufferFormat;
- 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 );
- pDevice->CreatePipelineState(PSODesc, &m_pPSO);
- m_pPSO->CreateShaderResourceBinding(&m_pSRB);
-
- 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);
- }
-
- RefCntAutoPtr<ISampler> pSampler;
- SamplerDesc SamDesc;
- pDevice->CreateSampler(SamDesc, &pSampler);
- for(auto t=0; t < _countof(m_pTextures); ++t)
- {
- TextureDesc TexDesc;
- TexDesc.Type = RESOURCE_DIM_TEX_2D;
- TexDesc.Width = 256;
- TexDesc.Height = 256;
- TexDesc.MipLevels = 8;
- TexDesc.Usage = USAGE_STATIC;
- TexDesc.Format = TEX_FORMAT_RGBA8_UNORM;
- TexDesc.BindFlags = BIND_SHADER_RESOURCE;
- TexDesc.Name = "Test Texture";
-
- std::vector<Uint8> Data;
- std::vector<TextureSubResData> SubResouces;
- float ColorOffset[4] = {(float)t*0.13f, (float)t*0.21f, (float)t*0.29f, 0};
- TestTexturing::GenerateTextureData(m_pRenderDevice, Data, SubResouces, TexDesc, ColorOffset);
- TextureData TexData;
- TexData.pSubResources = SubResouces.data();
- TexData.NumSubresources = (Uint32)SubResouces.size();
-
- m_pRenderDevice->CreateTexture( TexDesc, &TexData, &m_pTextures[t] );
- m_pTextures[t]->GetDefaultView(TEXTURE_VIEW_SHADER_RESOURCE)->SetSampler(pSampler);
- }
-
- ResourceMappingEntry ResMpEntries [] =
- {
- ResourceMappingEntry("g_tex2DTest", m_pTextures[0]->GetDefaultView(TEXTURE_VIEW_SHADER_RESOURCE), 0),
- ResourceMappingEntry("g_tex2DTest", m_pTextures[1]->GetDefaultView(TEXTURE_VIEW_SHADER_RESOURCE), 1),
- ResourceMappingEntry("g_tex2DTest", m_pTextures[2]->GetDefaultView(TEXTURE_VIEW_SHADER_RESOURCE), 2),
- ResourceMappingEntry("g_tex2DTest2", m_pTextures[5]->GetDefaultView(TEXTURE_VIEW_SHADER_RESOURCE), 0),
- ResourceMappingEntry("g_tex2D", m_pTextures[6]->GetDefaultView(TEXTURE_VIEW_SHADER_RESOURCE), 0),
- ResourceMappingEntry()
- };
-
- ResourceMappingDesc ResMappingDesc;
- ResMappingDesc.pEntries = ResMpEntries;
- RefCntAutoPtr<IResourceMapping> pResMapping;
- m_pRenderDevice->CreateResourceMapping(ResMappingDesc, &pResMapping);
-
- //pVS->BindResources(m_pResourceMapping, 0);
- IDeviceObject *ppSRVs[] = {m_pTextures[3]->GetDefaultView(TEXTURE_VIEW_SHADER_RESOURCE)};
- m_pPSO->BindStaticResources(SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, pResMapping, BIND_SHADER_RESOURCES_KEEP_EXISTING);
- m_pPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, "g_tex2DTest2")->SetArray( ppSRVs, 1, 1);
-
- m_pSRB->InitializeStaticResources();
- m_pSRB->BindResources(SHADER_TYPE_PIXEL, pResMapping, BIND_SHADER_RESOURCES_KEEP_EXISTING | BIND_SHADER_RESOURCES_UPDATE_MUTABLE | BIND_SHADER_RESOURCES_UPDATE_DYNAMIC);
- ppSRVs[0] = m_pTextures[4]->GetDefaultView(TEXTURE_VIEW_SHADER_RESOURCE);
- m_pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_tex2DTest")->SetArray(ppSRVs, 3, 1);
-}
-
-void TestShaderResArrays::Draw()
-{
- m_pDeviceContext->SetPipelineState(m_pPSO);
- IDeviceObject *ppSRVs[] = {m_pTextures[7]->GetDefaultView(TEXTURE_VIEW_SHADER_RESOURCE)};
- m_pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_tex2D")->SetArray(ppSRVs, 1, 1);
-
- m_pDeviceContext->CommitShaderResources(m_pSRB, RESOURCE_STATE_TRANSITION_MODE_TRANSITION);
-
- 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 a quad
- Diligent::DrawAttribs DrawAttrs(4, DRAW_FLAG_VERIFY_ALL);
- m_pDeviceContext->Draw( DrawAttrs );
-
- SetStatus(TestResult::Succeeded);
-}
diff --git a/Tests/TestApp/src/TestShaderResourceLayout.cpp b/Tests/TestApp/src/TestShaderResourceLayout.cpp
deleted file mode 100644
index c827683..0000000
--- a/Tests/TestApp/src/TestShaderResourceLayout.cpp
+++ /dev/null
@@ -1,447 +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.
- */
-
-// EngineSandbox.cpp : Defines the entry point for the application.
-//
-
-#include "pch.h"
-#include "TestShaderResourceLayout.h"
-
-using namespace Diligent;
-
-void PrintShaderResources(IShader* pShader);
-
-TestShaderResourceLayout::TestShaderResourceLayout( IRenderDevice *pDevice, IDeviceContext *pContext ) :
- UnitTestBase("Shader resource layout initialization test"),
- m_pDeviceContext(pContext)
-{
- if (pDevice->GetDeviceCaps().DevType != DeviceType::Vulkan)
- {
- SetStatus(TestResult::Skipped);
- return;
- }
-
- ShaderCreateInfo CreationAttrs;
- RefCntAutoPtr<IShaderSourceInputStreamFactory> pShaderSourceFactory;
- pDevice->GetEngineFactory()->CreateDefaultShaderSourceStreamFactory("Shaders", &pShaderSourceFactory);
- CreationAttrs.pShaderSourceStreamFactory = pShaderSourceFactory;
- CreationAttrs.EntryPoint = "main";
- CreationAttrs.UseCombinedTextureSamplers = false;
-
- RefCntAutoPtr<ISampler> pSamplers[4];
- IDeviceObject *pSams[4];
- for (int i = 0; i < 4; ++i)
- {
- SamplerDesc SamDesc;
- pDevice->CreateSampler(SamDesc, &(pSamplers[i]));
- pSams[i] = pSamplers[i];
- }
-
- RefCntAutoPtr<ITexture> pTex[4];
- TextureDesc TexDesc;
- TexDesc.Type = RESOURCE_DIM_TEX_2D;
- TexDesc.Width = 1024;
- TexDesc.Height = 1024;
- TexDesc.Format = TEX_FORMAT_RGBA8_UNORM_SRGB;
- TexDesc.BindFlags = BIND_SHADER_RESOURCE;
- IDeviceObject *pSRVs[4];
- for(int i=0; i < 4; ++i)
- {
- pDevice->CreateTexture(TexDesc, nullptr, &(pTex[i]));
- auto *pSRV = pTex[i]->GetDefaultView(TEXTURE_VIEW_SHADER_RESOURCE);
- pSRV->SetSampler(pSamplers[i]);
- pSRVs[i] = pSRV;
- }
-
- TexDesc.BindFlags = BIND_SHADER_RESOURCE | BIND_UNORDERED_ACCESS;
- TexDesc.Format = TEX_FORMAT_RGBA8_UNORM;
- RefCntAutoPtr<ITexture> pStorageTex[4];
- IDeviceObject *pUAVs[4];
- for (int i = 0; i < 4; ++i)
- {
- pDevice->CreateTexture(TexDesc, nullptr, &(pStorageTex[i]));
- pUAVs[i] = pStorageTex[i]->GetDefaultView(TEXTURE_VIEW_UNORDERED_ACCESS);
- }
-
- TexDesc.BindFlags = BIND_RENDER_TARGET;
- RefCntAutoPtr<ITexture> pRenderTarget;
- pDevice->CreateTexture(TexDesc, nullptr, &pRenderTarget);
- auto *pRTV = pRenderTarget->GetDefaultView(TEXTURE_VIEW_RENDER_TARGET);
- m_pDeviceContext->SetRenderTargets(1, &pRTV, nullptr, RESOURCE_STATE_TRANSITION_MODE_TRANSITION);
- float Zero[4] = {};
- m_pDeviceContext->ClearRenderTarget(pRTV, Zero, RESOURCE_STATE_TRANSITION_MODE_VERIFY);
-
- BufferDesc BuffDesc;
- BuffDesc.uiSizeInBytes = 1024;
- BuffDesc.BindFlags = BIND_UNIFORM_BUFFER;
- RefCntAutoPtr<IBuffer> pUniformBuffs[4];
- IDeviceObject *pUBs[4];
- for (int i = 0; i < 4; ++i)
- {
- pDevice->CreateBuffer(BuffDesc, nullptr, &(pUniformBuffs[i]));
- pUBs[i] = pUniformBuffs[i];
- }
-
- BuffDesc.BindFlags = BIND_UNORDERED_ACCESS;
- BuffDesc.Mode = BUFFER_MODE_STRUCTURED;
- BuffDesc.ElementByteStride = 16;
- RefCntAutoPtr<IBuffer> pStorgeBuffs[4];
- IDeviceObject *pSBUAVs[4];
- for (int i = 0; i < 4; ++i)
- {
- pDevice->CreateBuffer(BuffDesc, nullptr, &(pStorgeBuffs[i]));
- pSBUAVs[i] = pStorgeBuffs[i]->GetDefaultView(BUFFER_VIEW_UNORDERED_ACCESS);
- }
-
- RefCntAutoPtr<IBuffer> pUniformTexelBuff, pStorageTexelBuff;
- RefCntAutoPtr<IBufferView> pUniformTexelBuffSRV , pStorageTexelBuffUAV;
- {
- BufferDesc TxlBuffDesc;
- TxlBuffDesc.Name = "Uniform texel buffer test";
- TxlBuffDesc.uiSizeInBytes = 256;
- TxlBuffDesc.BindFlags = BIND_SHADER_RESOURCE | BIND_UNORDERED_ACCESS;
- TxlBuffDesc.Usage = USAGE_DEFAULT;
- TxlBuffDesc.ElementByteStride = 16;
- TxlBuffDesc.Mode = BUFFER_MODE_FORMATTED;
- pDevice->CreateBuffer(TxlBuffDesc, nullptr, &pUniformTexelBuff);
-
- BufferViewDesc TxlBuffViewDesc;
- TxlBuffViewDesc.Name = "Uniform texel buffer SRV";
- TxlBuffViewDesc.ViewType = BUFFER_VIEW_SHADER_RESOURCE;
- TxlBuffViewDesc.Format.ValueType = VT_FLOAT32;
- TxlBuffViewDesc.Format.NumComponents = 4;
- TxlBuffViewDesc.Format.IsNormalized = false;
- pUniformTexelBuff->CreateView(TxlBuffViewDesc, &pUniformTexelBuffSRV);
-
- TxlBuffDesc.Name = "Storage texel buffer test";
- TxlBuffDesc.BindFlags = BIND_UNORDERED_ACCESS;
- pDevice->CreateBuffer(TxlBuffDesc, nullptr, &pStorageTexelBuff);
-
- TxlBuffViewDesc.Name = "Storage texel buffer UAV";
- TxlBuffViewDesc.ViewType = BUFFER_VIEW_UNORDERED_ACCESS;
- pUniformTexelBuff->CreateView(TxlBuffViewDesc, &pStorageTexelBuffUAV);
- }
-
- ResourceMappingDesc ResMappingDesc;
- ResourceMappingEntry MappingEntries[] =
- {
- {"g_tex2D_Static", pSRVs[0]},
- {"g_tex2DArr_Static", pSRVs[0], 0},
- {"g_tex2DArr_Static", pSRVs[1], 1},
- {"g_sepTex2D_static", pSRVs[0]},
- {"g_sepTex2DArr_static", pSRVs[0], 0},
- {"g_sepTex2DArr_static", pSRVs[1], 1},
- {"g_tex2D_Mut", pSRVs[0]},
- {"g_tex2DArr_Mut", pSRVs[0], 0},
- {"g_tex2DArr_Mut", pSRVs[1], 1},
- {"g_tex2DArr_Mut", pSRVs[2], 2},
- {"g_tex2D_Dyn", pSRVs[0]},
- {"g_tex2DArr_Dyn", pSRVs[0], 0},
- {"g_tex2DArr_Dyn", pSRVs[1], 1},
- {"g_tex2DArr_Dyn", pSRVs[2], 2},
- {"g_tex2DArr_Dyn", pSRVs[3], 3},
- {"g_tex2DArr_Dyn", pSRVs[0], 4},
- {"g_tex2DArr_Dyn", pSRVs[1], 5},
- {"g_tex2DArr_Dyn", pSRVs[2], 6},
- {"g_tex2DArr_Dyn", pSRVs[3], 7},
- {"g_sepTex2D_mut", pSRVs[0]},
- {"g_sepTex2DArr_mut", pSRVs[0], 0},
- {"g_sepTex2DArr_mut", pSRVs[1], 1},
- {"g_sepTex2DArr_mut", pSRVs[2], 2},
- {"g_sepTex2D_dyn", pSRVs[0]},
- {"g_sepTex2DArr_dyn", pSRVs[0], 0},
- {"g_sepTex2DArr_dyn", pSRVs[1], 1},
- {"g_sepTex2DArr_dyn", pSRVs[2], 2},
- {"g_sepTex2DArr_dyn", pSRVs[3], 3},
- {"g_sepTex2DArr_dyn", pSRVs[0], 4},
- {"g_sepTex2DArr_dyn", pSRVs[1], 5},
- {"g_sepTex2DArr_dyn", pSRVs[2], 6},
- {"g_sepTex2DArr_dyn", pSRVs[3], 7},
- {}
- };
- ResMappingDesc.pEntries = MappingEntries;
- RefCntAutoPtr<IResourceMapping> pResMapping;
- pDevice->CreateResourceMapping(ResMappingDesc, &pResMapping);
-
- RefCntAutoPtr<IShader> pVS;
- {
- CreationAttrs.Desc.Name = "Shader resource layout test VS";
- CreationAttrs.Desc.ShaderType = SHADER_TYPE_VERTEX;
- CreationAttrs.SourceLanguage = SHADER_SOURCE_LANGUAGE_GLSL;
- CreationAttrs.FilePath = "Shaders\\ShaderResLayoutTestGL.vsh";
-
- pDevice->CreateShader(CreationAttrs, &pVS);
- VERIFY_EXPR(pVS);
- }
-
- RefCntAutoPtr<IShader> pPS;
- {
- CreationAttrs.Desc.Name = "Shader resource layout test FS";
- CreationAttrs.Desc.ShaderType = SHADER_TYPE_PIXEL;
- CreationAttrs.SourceLanguage = SHADER_SOURCE_LANGUAGE_GLSL;
- CreationAttrs.FilePath = "Shaders\\ShaderResLayoutTestGL.psh";
-
- pDevice->CreateShader(CreationAttrs, &pPS);
- VERIFY_EXPR(pPS);
-
- PrintShaderResources(pPS);
- }
-
- PipelineStateDesc PSODesc;
-
- ShaderResourceVariableDesc VarDesc[] =
- {
- { SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_tex2D_Static", SHADER_RESOURCE_VARIABLE_TYPE_STATIC },
- { SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_tex2D_Mut", SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE },
- { SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_tex2D_Dyn", SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC },
- { SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_tex2DArr_Static", SHADER_RESOURCE_VARIABLE_TYPE_STATIC },
- { SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_tex2DArr_Mut", SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE },
- { SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_tex2DArr_Dyn", SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC },
- { SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_sepTex2DArr_static", SHADER_RESOURCE_VARIABLE_TYPE_STATIC },
- { SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_sepTex2D_mut", SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE },
- { SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_sepTex2DArr_mut", SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE },
- { SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_sepTex2D_dyn", SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC },
- { SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_sepTex2DArr_dyn", SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC },
- { SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_SamArr_static", SHADER_RESOURCE_VARIABLE_TYPE_STATIC},
- { SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_Sam_mut", SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE },
- { SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_SamArr_mut", SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE },
- { SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_Sam_dyn", SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC },
- { SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_SamArr_dyn", SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC },
- { SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "UniformBuff_Mut", SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE },
- { SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "UniformBuff_Dyn", SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC },
- { SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "UniformBuffArr_Mut", SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE },
- { SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "UniformBuffArr_Dyn", SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC },
- { SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "storageBuff_Mut", SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE },
- { SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "storageBuff_Dyn", SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC },
- { SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "storageBuffArr_Mut", SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE },
- { SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "storageBuffArr_Dyn", SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC },
- { SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_tex2DStorageImgArr_Mut", SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE },
- { SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_tex2DStorageImgArr_Dyn", SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC },
- { SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_tex2DNoResourceTest", SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC },
- { SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_UniformTexelBuff_mut", SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC },
- { SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_StorageTexelBuff_mut", SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC }
- };
- StaticSamplerDesc StaticSamplers[] =
- {
- {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_tex2D_Static", SamplerDesc{}},
- {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_tex2DArr_Mut", SamplerDesc{}},
- {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_Sam_static", SamplerDesc{}},
- {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_SamArr_mut", SamplerDesc{} },
- {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_Sam_dyn", SamplerDesc{} },
- {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_tex2DNoStaticSamplerTest", SamplerDesc{} }
- };
- PSODesc.ResourceLayout.Variables = VarDesc;
- PSODesc.ResourceLayout.NumVariables = _countof(VarDesc);
- PSODesc.ResourceLayout.StaticSamplers = StaticSamplers;
- PSODesc.ResourceLayout.NumStaticSamplers = _countof(StaticSamplers);
-
- PSODesc.Name = "Shader resource layout test";
- PSODesc.GraphicsPipeline.pVS = pVS;
- PSODesc.GraphicsPipeline.pPS = pPS;
- PSODesc.GraphicsPipeline.PrimitiveTopology = PRIMITIVE_TOPOLOGY_TRIANGLE_LIST;
- PSODesc.GraphicsPipeline.NumRenderTargets = 1;
- PSODesc.GraphicsPipeline.RTVFormats[0] = TEX_FORMAT_RGBA8_UNORM;
- PSODesc.GraphicsPipeline.DSVFormat = TEX_FORMAT_UNKNOWN;
- PSODesc.SRBAllocationGranularity = 16;
-
- RefCntAutoPtr<IPipelineState> pTestPSO;
- LOG_INFO_MESSAGE("The 2 warnings below about missing shader resources are part of the test");
- pDevice->CreatePipelineState(PSODesc, &pTestPSO);
-
-
- VERIFY_EXPR(pTestPSO);
-
- {
- //pTestPSO->GetStaticVariableByName(SHADER_TYPE_VERTEX, "g_tex2D_Static")->Set(pSRVs[0]);
- //pTestPSO->GetStaticVariableByName(SHADER_TYPE_VERTEX, "g_tex2DArr_Static")->SetArray(pSRVs, 0, 2);
- pTestPSO->GetStaticVariableByName(SHADER_TYPE_VERTEX, "g_sepTex2D_static")->Set(pSRVs[0]);
- pTestPSO->GetStaticVariableByName(SHADER_TYPE_VERTEX, "g_sepTex2DArr_static")->SetArray(pSRVs, 0, 2);
- pTestPSO->GetStaticVariableByName(SHADER_TYPE_VERTEX, "g_SamArr_static")->SetArray(pSams, 0, 2);
- pTestPSO->GetStaticVariableByName(SHADER_TYPE_VERTEX, "UniformBuff_Stat")->Set(pUBs[0]);
- pTestPSO->GetStaticVariableByName(SHADER_TYPE_VERTEX, "UniformBuffArr_Stat")->SetArray(pUBs, 0, 2);
- pTestPSO->GetStaticVariableByName(SHADER_TYPE_VERTEX, "storageBuff_Static")->Set(pSBUAVs[0]);
- pTestPSO->GetStaticVariableByName(SHADER_TYPE_VERTEX, "storageBuffArr_Static")->SetArray(pSBUAVs, 0, 2);
- pTestPSO->GetStaticVariableByName(SHADER_TYPE_VERTEX, "g_tex2DStorageImg_Stat")->Set(pUAVs[0]);
- pTestPSO->GetStaticVariableByName(SHADER_TYPE_VERTEX, "g_UniformTexelBuff")->Set(pUniformTexelBuffSRV);
- pTestPSO->GetStaticVariableByName(SHADER_TYPE_VERTEX, "g_StorageTexelBuff")->Set(pStorageTexelBuffUAV);
- pTestPSO->GetStaticVariableByName(SHADER_TYPE_VERTEX, "g_tex2D_Mut");
- auto* pStaticSam = pTestPSO->GetStaticVariableByName(SHADER_TYPE_VERTEX, "g_Sam_static");
- VERIFY_EXPR(pStaticSam == nullptr); (void)pStaticSam;
-
-
- auto NumVSVars = pTestPSO->GetStaticVariableCount(SHADER_TYPE_VERTEX);
- for(Uint32 v=0; v < NumVSVars; ++v)
- {
- auto pVar = pTestPSO->GetStaticVariableByIndex(SHADER_TYPE_VERTEX, v);
- VERIFY_EXPR(pVar->GetIndex() == v);
- VERIFY_EXPR(pVar->GetType() == SHADER_RESOURCE_VARIABLE_TYPE_STATIC);
- auto pVar2 = pTestPSO->GetStaticVariableByName(SHADER_TYPE_VERTEX, pVar->GetResourceDesc().Name);
- VERIFY_EXPR(pVar == pVar2);
- (void)pVar2;
- }
- }
-
- {
- pTestPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, "g_tex2D_Static")->Set(pSRVs[0]);
- pTestPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, "g_tex2DArr_Static")->SetArray(pSRVs, 0, 2);
- //pTestPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, "g_sepTex2D_static")->Set(pSRVs[0]);
- //pTestPSO->GetStaticVariableByNames(SHADER_TYPE_PIXEL, "g_sepTex2DArr_static")->SetArray(pSRVs, 0, 2);
- pTestPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, "g_SamArr_static")->SetArray(pSams, 0, 2);
- pTestPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, "UniformBuff_Stat")->Set(pUBs[0]);
- pTestPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, "UniformBuffArr_Stat")->SetArray(pUBs, 0, 2);
- pTestPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, "storageBuff_Static")->Set(pSBUAVs[0]);
- pTestPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, "storageBuffArr_Static")->SetArray(pSBUAVs, 0, 2);
- pTestPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, "g_tex2DStorageImg_Stat")->Set(pUAVs[0]);
- pTestPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, "g_UniformTexelBuff")->Set(pUniformTexelBuffSRV);
- pTestPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, "g_StorageTexelBuff")->Set(pStorageTexelBuffUAV);
- pTestPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, "storageBuff_Dyn");
- auto* pStaticSam = pTestPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, "g_Sam_static");
- VERIFY_EXPR(pStaticSam == nullptr);
- (void)pStaticSam;
-
- auto NumPSVars = pTestPSO->GetStaticVariableCount(SHADER_TYPE_PIXEL);
- for(Uint32 v=0; v < NumPSVars; ++v)
- {
- auto pVar = pTestPSO->GetStaticVariableByIndex(SHADER_TYPE_PIXEL, v);
- VERIFY_EXPR(pVar->GetIndex() == v);
- VERIFY_EXPR(pVar->GetType() == SHADER_RESOURCE_VARIABLE_TYPE_STATIC);
- auto pVar2 = pTestPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, pVar->GetResourceDesc().Name);
- VERIFY_EXPR(pVar == pVar2);
- (void)pVar2;
- }
- }
-
- pTestPSO->BindStaticResources(SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, pResMapping, BIND_SHADER_RESOURCES_KEEP_EXISTING | BIND_SHADER_RESOURCES_VERIFY_ALL_RESOLVED | BIND_SHADER_RESOURCES_UPDATE_STATIC);
-
- RefCntAutoPtr<IShaderResourceBinding> pSRB;
- pTestPSO->CreateShaderResourceBinding(&pSRB, true);
-
- pSRB->GetVariableByName(SHADER_TYPE_VERTEX, "UniformBuff_Stat");
- pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_sepTex2DArr_static");
- LOG_INFO_MESSAGE("The above 2 errors about missing shader resources are part of the test");
-
- //pSRB->GetVariableByName(SHADER_TYPE_VERTEX, "g_tex2D_Mut")->Set(pSRVs[0]);
- //pSRB->GetVariableByName(SHADER_TYPE_VERTEX, "g_tex2DArr_Mut")->SetArray(pSRVs, 0, 3);
- //pSRB->GetVariableByName(SHADER_TYPE_VERTEX, "g_tex2D_Dyn")->Set(pSRVs[0]);
- //pSRB->GetVariableByName(SHADER_TYPE_VERTEX, "g_tex2DArr_Dyn")->SetArray(pSRVs, 0, 4);
-
- pSRB->GetVariableByName(SHADER_TYPE_VERTEX, "g_sepTex2D_mut")->Set(pSRVs[0]);
- pSRB->GetVariableByName(SHADER_TYPE_VERTEX, "g_sepTex2DArr_mut")->SetArray(pSRVs, 0, 3);
- pSRB->GetVariableByName(SHADER_TYPE_VERTEX, "g_sepTex2D_dyn")->Set(pSRVs[0]);
- pSRB->GetVariableByName(SHADER_TYPE_VERTEX, "g_sepTex2DArr_dyn")->SetArray(pSRVs, 0, 4);
-
- pSRB->GetVariableByName(SHADER_TYPE_VERTEX, "g_Sam_mut")->Set(pSams[0]);
- pSRB->GetVariableByName(SHADER_TYPE_VERTEX, "g_SamArr_dyn")->SetArray(pSams, 0, 4);
-
- pSRB->GetVariableByName(SHADER_TYPE_VERTEX, "UniformBuff_Mut")->Set(pUBs[0]);
- pSRB->GetVariableByName(SHADER_TYPE_VERTEX, "UniformBuffArr_Mut")->SetArray(pUBs, 0, 3);
- pSRB->GetVariableByName(SHADER_TYPE_VERTEX, "UniformBuff_Dyn")->Set(pUBs[0]);
- pSRB->GetVariableByName(SHADER_TYPE_VERTEX, "UniformBuffArr_Dyn")->SetArray(pUBs, 0, 4);
-
- pSRB->GetVariableByName(SHADER_TYPE_VERTEX, "storageBuff_Mut")->Set(pSBUAVs[0]);
- pSRB->GetVariableByName(SHADER_TYPE_VERTEX, "storageBuffArr_Mut")->SetArray(pSBUAVs, 0, 3);
- pSRB->GetVariableByName(SHADER_TYPE_VERTEX, "storageBuff_Dyn")->Set(pSBUAVs[0]);
- pSRB->GetVariableByName(SHADER_TYPE_VERTEX, "storageBuffArr_Dyn")->SetArray(pSBUAVs, 0, 4);
-
- pSRB->GetVariableByName(SHADER_TYPE_VERTEX, "g_tex2DStorageImgArr_Mut")->SetArray(pUAVs, 0, 2);
- pSRB->GetVariableByName(SHADER_TYPE_VERTEX, "g_tex2DStorageImgArr_Dyn")->SetArray(pUAVs, 0, 2);
-
- pSRB->GetVariableByName(SHADER_TYPE_VERTEX, "g_UniformTexelBuff_mut")->Set(pUniformTexelBuffSRV);
- pSRB->GetVariableByName(SHADER_TYPE_VERTEX, "g_StorageTexelBuff_mut")->Set(pStorageTexelBuffUAV);
-
-
-
- pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_tex2D_Mut")->Set(pSRVs[0]);
- pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_tex2DArr_Mut")->SetArray(pSRVs, 0, 3);
- pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_tex2D_Dyn")->Set(pSRVs[0]);
- pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_tex2DArr_Dyn")->SetArray(pSRVs, 0, 4);
-
- //pSRB->GetVariable(SHADER_TYPE_PIXEL, "g_sepTex2D_mut")->Set(pSRVs[0]);
- //pSRB->GetVariable(SHADER_TYPE_PIXEL, "g_sepTex2DArr_mut")->SetArray(pSRVs, 0, 3);
- //pSRB->GetVariable(SHADER_TYPE_PIXEL, "g_sepTex2D_dyn")->Set(pSRVs[0]);
- //pSRB->GetVariable(SHADER_TYPE_PIXEL, "g_sepTex2DArr_dyn")->SetArray(pSRVs, 0, 4);
-
- pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_Sam_mut")->Set(pSams[0]);
- pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_SamArr_dyn")->SetArray(pSams, 0, 4);
-
- pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "UniformBuff_Mut")->Set(pUBs[0]);
- pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "UniformBuffArr_Mut")->SetArray(pUBs, 0, 3);
- pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "UniformBuff_Dyn")->Set(pUBs[0]);
- pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "UniformBuffArr_Dyn")->SetArray(pUBs, 0, 4);
-
- pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "storageBuff_Mut")->Set(pSBUAVs[0]);
- pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "storageBuffArr_Mut")->SetArray(pSBUAVs, 0, 3);
- pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "storageBuff_Dyn")->Set(pSBUAVs[0]);
- pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "storageBuffArr_Dyn")->SetArray(pSBUAVs, 0, 4);
-
- pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_tex2DStorageImgArr_Mut")->SetArray(pUAVs, 0, 2);
- pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_tex2DStorageImgArr_Dyn")->SetArray(pUAVs, 0, 2);
-
- pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_UniformTexelBuff_mut")->Set(pUniformTexelBuffSRV);
- pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_StorageTexelBuff_mut")->Set(pStorageTexelBuffUAV);
-
- pSRB->BindResources(SHADER_TYPE_PIXEL | SHADER_TYPE_VERTEX, pResMapping, BIND_SHADER_RESOURCES_KEEP_EXISTING | BIND_SHADER_RESOURCES_VERIFY_ALL_RESOLVED | BIND_SHADER_RESOURCES_UPDATE_MUTABLE | BIND_SHADER_RESOURCES_UPDATE_DYNAMIC);
-
- pContext->SetPipelineState(pTestPSO);
- pContext->CommitShaderResources(pSRB, RESOURCE_STATE_TRANSITION_MODE_TRANSITION);
-
- DrawAttribs DrawAttrs(3, DRAW_FLAG_VERIFY_ALL);
- pContext->Draw(DrawAttrs);
-
- pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "storageBuff_Dyn")->Set(pSBUAVs[1]);
- pSRB->GetVariableByName(SHADER_TYPE_VERTEX, "g_tex2D_Dyn")->Set(pSRVs[1]);
- pSRB->GetVariableByName(SHADER_TYPE_VERTEX, "g_sepTex2D_dyn")->Set(pSRVs[1]);
- pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_SamArr_dyn")->SetArray(pSams+1, 1, 3);
- pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "UniformBuff_Dyn")->Set(pUBs[1]);
- pSRB->GetVariableByName(SHADER_TYPE_VERTEX, "g_tex2DStorageImgArr_Dyn")->SetArray(pUAVs+1, 1, 1);
- pContext->CommitShaderResources(pSRB, RESOURCE_STATE_TRANSITION_MODE_TRANSITION);
- pContext->Draw(DrawAttrs);
-
- {
- auto NumVSVars = pSRB->GetVariableCount(SHADER_TYPE_VERTEX);
- for(Uint32 v=0; v < NumVSVars; ++v)
- {
- auto pVar = pSRB->GetVariableByIndex(SHADER_TYPE_VERTEX, v);
- VERIFY_EXPR(pVar->GetIndex() == v);
- VERIFY_EXPR(pVar->GetType() == SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE || pVar->GetType() == SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC);
- auto pVar2 = pSRB->GetVariableByName(SHADER_TYPE_VERTEX, pVar->GetResourceDesc().Name);
- VERIFY_EXPR(pVar == pVar2);
- (void)pVar2;
- }
- }
-
- {
- auto NumPSVars = pSRB->GetVariableCount(SHADER_TYPE_PIXEL);
- for(Uint32 v=0; v < NumPSVars; ++v)
- {
- auto pVar = pSRB->GetVariableByIndex(SHADER_TYPE_PIXEL, v);
- VERIFY_EXPR(pVar->GetIndex() == v);
- VERIFY_EXPR(pVar->GetType() == SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE || pVar->GetType() == SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC);
- auto pVar2 = pSRB->GetVariableByName(SHADER_TYPE_PIXEL, pVar->GetResourceDesc().Name);
- VERIFY_EXPR(pVar == pVar2);
- (void)pVar2;
- }
- }
-
- SetStatus(TestResult::Succeeded);
-}
diff --git a/Tests/TestApp/src/TestShaderVarAccess.cpp b/Tests/TestApp/src/TestShaderVarAccess.cpp
deleted file mode 100644
index 5be5169..0000000
--- a/Tests/TestApp/src/TestShaderVarAccess.cpp
+++ /dev/null
@@ -1,649 +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.
- */
-
-// EngineSandbox.cpp : Defines the entry point for the application.
-//
-
-#include "pch.h"
-#include "TestShaderVarAccess.h"
-#include "GraphicsAccessories.h"
-#include "../../../DiligentCore/Graphics/GraphicsEngineD3DBase/interface/ShaderD3D.h"
-
-using namespace Diligent;
-
-void PrintShaderResources(IShader* pShader)
-{
- RefCntAutoPtr<IShaderD3D> pShaderD3D(pShader, IID_ShaderD3D);
-
- std::stringstream ss;
- ss << "Resources of shader '" << pShader->GetDesc().Name << "':" << std::endl;
- for (Uint32 res=0; res < pShader->GetResourceCount(); ++res)
- {
- auto ResDec = pShader->GetResource(res);
- std::stringstream name_ss;
- name_ss << ResDec.Name;
- if(ResDec.ArraySize > 1)
- name_ss << "[" << ResDec.ArraySize << "]";
- ss << std::setw(2) << std::right << res << ": " << std::setw(25) << std::left << name_ss.str();
- if (pShaderD3D)
- {
- auto HLSLResDesc = pShaderD3D->GetHLSLResource(res);
- ss << " hlsl register " << std::setw(2) << HLSLResDesc.ShaderRegister;
- }
- ss << " " << GetShaderResourceTypeLiteralName(ResDec.Type) << std::endl;
- }
- LOG_INFO_MESSAGE(ss.str());
-}
-
-TestShaderVarAccess::TestShaderVarAccess( IRenderDevice *pDevice, IDeviceContext *pContext, Diligent::ISwapChain* pSwapChain ) :
- UnitTestBase("Shader variable access test"),
- m_pDeviceContext(pContext)
-{
- if( pDevice->GetDeviceCaps().DevType == DeviceType::OpenGLES )
- return;
-
- ShaderCreateInfo CreationAttrs;
- RefCntAutoPtr<IShaderSourceInputStreamFactory> pShaderSourceFactory;
- pDevice->GetEngineFactory()->CreateDefaultShaderSourceStreamFactory("Shaders", &pShaderSourceFactory);
- CreationAttrs.pShaderSourceStreamFactory = pShaderSourceFactory;
- CreationAttrs.EntryPoint = "main";
- CreationAttrs.UseCombinedTextureSamplers = true;
-
- RefCntAutoPtr<ISampler> pSamplers[2];
- IDeviceObject *pSams[2];
- for (size_t i = 0; i < _countof(pSams); ++i)
- {
- SamplerDesc SamDesc;
- pDevice->CreateSampler(SamDesc, &(pSamplers[i]));
- pSams[i] = pSamplers[i];
- }
-
- RefCntAutoPtr<ITexture> pTex[2];
- TextureDesc TexDesc;
- TexDesc.Type = RESOURCE_DIM_TEX_2D;
- TexDesc.Width = 1024;
- TexDesc.Height = 1024;
- TexDesc.Format = TEX_FORMAT_RGBA8_UNORM_SRGB;
- TexDesc.BindFlags = BIND_SHADER_RESOURCE;
- IDeviceObject *pSRVs[2];
- for(size_t i=0; i < _countof(pSRVs); ++i)
- {
- pDevice->CreateTexture(TexDesc, nullptr, &(pTex[i]));
- auto *pSRV = pTex[i]->GetDefaultView(TEXTURE_VIEW_SHADER_RESOURCE);
- pSRV->SetSampler(pSamplers[i]);
- pSRVs[i] = pSRV;
- }
-
- RefCntAutoPtr<ITexture> pRWTex[8];
- IDeviceObject *pTexUAVs[_countof(pRWTex)];
- IDeviceObject *pRWTexSRVs[_countof(pRWTex)];
- TexDesc.BindFlags = BIND_SHADER_RESOURCE | BIND_UNORDERED_ACCESS;
- TexDesc.Format = TEX_FORMAT_RGBA32_FLOAT;
- for(size_t i=0; i < _countof(pRWTex); ++i)
- {
- pDevice->CreateTexture(TexDesc, nullptr, &(pRWTex[i]));
- pTexUAVs[i] = pRWTex[i]->GetDefaultView(TEXTURE_VIEW_UNORDERED_ACCESS);
- pRWTexSRVs[i] = pRWTex[i]->GetDefaultView(TEXTURE_VIEW_SHADER_RESOURCE);
- }
-
-
- //RefCntAutoPtr<ITexture> pStorageTex[4];
- //IDeviceObject *pUAVs[4];
- //for (int i = 0; i < 4; ++i)
- //{
- // pDevice->CreateTexture(TexDesc, TextureData{}, &(pStorageTex[i]));
- // pUAVs[i] = pStorageTex[i]->GetDefaultView(TEXTURE_VIEW_UNORDERED_ACCESS);
- //}
-
- TexDesc.Format = pSwapChain->GetDesc().ColorBufferFormat;
- TexDesc.BindFlags = BIND_RENDER_TARGET | BIND_SHADER_RESOURCE;
- RefCntAutoPtr<ITexture> pRenderTarget;
- pDevice->CreateTexture(TexDesc, nullptr, &pRenderTarget);
- auto *pRTV = pRenderTarget->GetDefaultView(TEXTURE_VIEW_RENDER_TARGET);
-
- TexDesc.Format = pSwapChain->GetDesc().DepthBufferFormat;
- TexDesc.BindFlags = BIND_DEPTH_STENCIL;
- RefCntAutoPtr<ITexture> pDepthTex;
- pDevice->CreateTexture(TexDesc, nullptr, &pDepthTex);
- auto *pDSV = pDepthTex->GetDefaultView(TEXTURE_VIEW_DEPTH_STENCIL);
-
- BufferDesc BuffDesc;
- BuffDesc.uiSizeInBytes = 1024;
- BuffDesc.BindFlags = BIND_UNIFORM_BUFFER;
- RefCntAutoPtr<IBuffer> pUniformBuffs[2];
- IDeviceObject *pUBs[2];
- for (int i = 0; i < _countof(pUniformBuffs); ++i)
- {
- pDevice->CreateBuffer(BuffDesc, nullptr, &(pUniformBuffs[i]));
- pUBs[i] = pUniformBuffs[i];
- }
-
- //BuffDesc.BindFlags = BIND_UNORDERED_ACCESS;
- //BuffDesc.Mode = BUFFER_MODE_STRUCTURED;
- //BuffDesc.ElementByteStride = 16;
- //RefCntAutoPtr<IBuffer> pStorgeBuffs[4];
- //IDeviceObject *pSBUAVs[4];
- //for (int i = 0; i < 4; ++i)
- //{
- // pDevice->CreateBuffer(BuffDesc, BufferData{}, &(pStorgeBuffs[i]));
- // pSBUAVs[i] = pStorgeBuffs[i]->GetDefaultView(BUFFER_VIEW_UNORDERED_ACCESS);
- //}
-
- RefCntAutoPtr<IBuffer> pFormattedBuff0, pFormattedBuff[4], pRawBuff[2];
- IDeviceObject *pFormattedBuffSRV = nullptr, *pFormattedBuffUAV[4] = {}, *pFormattedBuffSRVs[4] = {};
- RefCntAutoPtr<IBufferView> spFormattedBuffSRV, spFormattedBuffUAV[4], spFormattedBuffSRVs[4];
- RefCntAutoPtr<IBufferView> spRawBuffUAV[2], spRawBuffSRVs[2];
- {
- Diligent::BufferDesc TxlBuffDesc;
- TxlBuffDesc.Name = "Uniform texel buffer test";
- TxlBuffDesc.uiSizeInBytes = 256;
- TxlBuffDesc.BindFlags = BIND_SHADER_RESOURCE | BIND_UNORDERED_ACCESS;
- TxlBuffDesc.Usage = USAGE_DEFAULT;
- TxlBuffDesc.ElementByteStride = 16;
- TxlBuffDesc.Mode = BUFFER_MODE_FORMATTED;
- pDevice->CreateBuffer(TxlBuffDesc, nullptr, &pFormattedBuff0);
-
- Diligent::BufferViewDesc ViewDesc;
- ViewDesc.ViewType = BUFFER_VIEW_SHADER_RESOURCE;
- ViewDesc.Format.ValueType = VT_FLOAT32;
- ViewDesc.Format.NumComponents = 4;
- ViewDesc.Format.IsNormalized = false;
- pFormattedBuff0->CreateView(ViewDesc, &spFormattedBuffSRV);
- pFormattedBuffSRV = spFormattedBuffSRV;
-
- for(size_t i=0; i < _countof(pFormattedBuff); ++i)
- {
- TxlBuffDesc.Name = "UAV buffer test";
- TxlBuffDesc.BindFlags = BIND_SHADER_RESOURCE | BIND_UNORDERED_ACCESS;
- pDevice->CreateBuffer(TxlBuffDesc, nullptr, &(pFormattedBuff[i]));
-
- ViewDesc.ViewType = BUFFER_VIEW_UNORDERED_ACCESS;
- pFormattedBuff[i]->CreateView(ViewDesc, &(spFormattedBuffUAV[i]));
- pFormattedBuffUAV[i] = spFormattedBuffUAV[i];
-
- ViewDesc.ViewType = BUFFER_VIEW_SHADER_RESOURCE;
- pFormattedBuff[i]->CreateView(ViewDesc, &(spFormattedBuffSRVs[i]));
- pFormattedBuffSRVs[i] = spFormattedBuffSRVs[i];
- }
-
- TxlBuffDesc.Mode = BUFFER_MODE_RAW;
- ViewDesc.Format.ValueType = VT_UNDEFINED;
- for(size_t i=0; i < _countof(pRawBuff); ++i)
- {
- TxlBuffDesc.Name = "Raw buffer test";
- pDevice->CreateBuffer(TxlBuffDesc, nullptr, &(pRawBuff[i]));
- spRawBuffUAV[i] = pRawBuff[i]->GetDefaultView(BUFFER_VIEW_UNORDERED_ACCESS);
- spRawBuffSRVs[i] = pRawBuff[i]->GetDefaultView(BUFFER_VIEW_SHADER_RESOURCE);
- }
- }
-
- RefCntAutoPtr<IShader> pVS;
- {
- CreationAttrs.Desc.Name = "Shader variable access test VS";
- CreationAttrs.Desc.ShaderType = SHADER_TYPE_VERTEX;
- CreationAttrs.SourceLanguage = SHADER_SOURCE_LANGUAGE_DEFAULT;
- CreationAttrs.FilePath = pDevice->GetDeviceCaps().IsD3DDevice() ? "Shaders\\ShaderVarAccessTestDX.vsh" : "Shaders\\ShaderVarAccessTestGL.vsh";
-
- pDevice->CreateShader(CreationAttrs, &pVS);
- VERIFY_EXPR(pVS);
-
- PrintShaderResources(pVS);
- }
-
- std::vector<ShaderResourceVariableDesc> VarDesc =
- {
- { SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_tex2D_Static", SHADER_RESOURCE_VARIABLE_TYPE_STATIC },
- { SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_tex2D_StaticArr", SHADER_RESOURCE_VARIABLE_TYPE_STATIC },
- { SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_tex2D_Mut", SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE },
- { SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_tex2D_Dyn", SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC },
- { SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_tex2D_MutArr", SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE },
- { SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_tex2D_DynArr", SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC },
- { SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "UniformBuff_Mut", SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE },
- { SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "UniformBuff_Dyn", SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC },
- { SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_Buffer_Mut", SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE },
- { SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_Buffer_MutArr", SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE },
- { SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_Buffer_Dyn", SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC },
- { SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_Buffer_DynArr", SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC },
- {SHADER_TYPE_PIXEL, "g_rwtex2D_Mut", SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE},
- {SHADER_TYPE_PIXEL, "g_rwtex2D_Dyn", SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC},
- {SHADER_TYPE_PIXEL, "g_rwBuff_Mut", SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE},
- {SHADER_TYPE_PIXEL, "g_rwBuff_Dyn", SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC},
- };
-
- StaticSamplerDesc StaticSamplers[] =
- {
- {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_tex2D_Static", SamplerDesc{}},
- {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_tex2D_StaticArr", SamplerDesc{}},
- {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_tex2D_Mut", SamplerDesc{}},
- {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_tex2D_MutArr", SamplerDesc{}},
- {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_tex2D_Dyn", SamplerDesc{}},
- {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "g_tex2D_DynArr", SamplerDesc{}}
- };
-
- RefCntAutoPtr<IShader> pPS;
- {
- CreationAttrs.Desc.Name = "Shader variable access test PS";
- CreationAttrs.Desc.ShaderType = SHADER_TYPE_PIXEL;
- CreationAttrs.SourceLanguage = SHADER_SOURCE_LANGUAGE_DEFAULT;
- CreationAttrs.FilePath = pDevice->GetDeviceCaps().IsD3DDevice() ? "Shaders\\ShaderVarAccessTestDX.psh" : "Shaders\\ShaderVarAccessTestGL.psh";
- pDevice->CreateShader(CreationAttrs, &pPS);
- VERIFY_EXPR(pPS);
-
- PrintShaderResources(pPS);
- }
-
-
- PipelineStateDesc PSODesc;
-
- PSODesc.ResourceLayout.Variables = VarDesc.data();
- PSODesc.ResourceLayout.NumVariables = static_cast<Uint32>(VarDesc.size());
- PSODesc.ResourceLayout.NumStaticSamplers = _countof(StaticSamplers);
- PSODesc.ResourceLayout.StaticSamplers = StaticSamplers;
-
- PSODesc.Name = "Shader variable access test PSO";
- PSODesc.GraphicsPipeline.pVS = pVS;
- PSODesc.GraphicsPipeline.pPS = pPS;
- PSODesc.GraphicsPipeline.PrimitiveTopology = PRIMITIVE_TOPOLOGY_TRIANGLE_LIST;
- PSODesc.GraphicsPipeline.NumRenderTargets = 1;
- PSODesc.GraphicsPipeline.RTVFormats[0] = pSwapChain->GetDesc().ColorBufferFormat;
- PSODesc.GraphicsPipeline.DSVFormat = pSwapChain->GetDesc().DepthBufferFormat;
- PSODesc.SRBAllocationGranularity = 16;
-
- RefCntAutoPtr<IPipelineState> pTestPSO;
- pDevice->CreatePipelineState(PSODesc, &pTestPSO);
- VERIFY_EXPR(pTestPSO);
-
- {
- VERIFY_EXPR(pTestPSO->GetStaticVariableCount(SHADER_TYPE_VERTEX) == 6);
-
- auto tex2D_Static = pTestPSO->GetStaticVariableByName(SHADER_TYPE_VERTEX, "g_tex2D_Static");
- VERIFY_EXPR(tex2D_Static->GetResourceDesc().ArraySize == 1);
- VERIFY_EXPR(tex2D_Static == pTestPSO->GetStaticVariableByName(SHADER_TYPE_VERTEX, tex2D_Static->GetResourceDesc().Name));
- tex2D_Static->Set(pSRVs[0]);
-
- auto tex2D_Static_sampler = pTestPSO->GetStaticVariableByName(SHADER_TYPE_VERTEX, "g_tex2D_Static_sampler");
- VERIFY_EXPR(tex2D_Static_sampler == nullptr);
- (void)tex2D_Static_sampler;
-
- auto tex2D_StaticArr = pTestPSO->GetStaticVariableByName(SHADER_TYPE_VERTEX, "g_tex2D_StaticArr");
- VERIFY_EXPR(tex2D_StaticArr->GetResourceDesc().ArraySize == 2);
- VERIFY_EXPR(tex2D_StaticArr == pTestPSO->GetStaticVariableByName(SHADER_TYPE_VERTEX, tex2D_StaticArr->GetResourceDesc().Name));
- tex2D_StaticArr->SetArray(pSRVs, 0, 2);
-
- auto tex2D_StaticArr_sampler = pTestPSO->GetStaticVariableByName(SHADER_TYPE_VERTEX, "g_tex2D_StaticArr_sampler");
- VERIFY_EXPR(tex2D_StaticArr_sampler == nullptr);
- (void)tex2D_StaticArr_sampler;
-
- auto UniformBuff_Stat = pTestPSO->GetStaticVariableByName(SHADER_TYPE_VERTEX, "UniformBuff_Stat");
- VERIFY_EXPR(UniformBuff_Stat->GetResourceDesc().ArraySize == 1);
- VERIFY_EXPR(UniformBuff_Stat == pTestPSO->GetStaticVariableByName(SHADER_TYPE_VERTEX, UniformBuff_Stat->GetResourceDesc().Name));
- UniformBuff_Stat->Set(pUBs[0]);
-
- auto UniformBuff_Stat2 = pTestPSO->GetStaticVariableByName(SHADER_TYPE_VERTEX, "UniformBuff_Stat2");
- VERIFY_EXPR(UniformBuff_Stat2->GetResourceDesc().ArraySize == 1);
- VERIFY_EXPR(UniformBuff_Stat2 == pTestPSO->GetStaticVariableByName(SHADER_TYPE_VERTEX, UniformBuff_Stat2->GetResourceDesc().Name));
- UniformBuff_Stat2->Set(pUBs[0]);
-
- auto Buffer_Static = pTestPSO->GetStaticVariableByName(SHADER_TYPE_VERTEX, "g_Buffer_Static");
- VERIFY_EXPR(Buffer_Static->GetResourceDesc().ArraySize == 1);
- VERIFY_EXPR(Buffer_Static == pTestPSO->GetStaticVariableByName(SHADER_TYPE_VERTEX, Buffer_Static->GetResourceDesc().Name));
- Buffer_Static->Set(pFormattedBuffSRV);
-
- auto Buffer_StaticArr = pTestPSO->GetStaticVariableByName(SHADER_TYPE_VERTEX, "g_Buffer_StaticArr");
- VERIFY_EXPR(Buffer_StaticArr->GetResourceDesc().ArraySize == 2);
- VERIFY_EXPR(Buffer_StaticArr == pTestPSO->GetStaticVariableByName(SHADER_TYPE_VERTEX, Buffer_StaticArr->GetResourceDesc().Name));
- Buffer_StaticArr->SetArray(&pFormattedBuffSRV,0,1);
- Buffer_StaticArr->SetArray(&pFormattedBuffSRV,1,1);
-
-
- auto tex2D_Mut = pTestPSO->GetStaticVariableByName(SHADER_TYPE_VERTEX, "g_tex2D_Mut");
- VERIFY_EXPR(tex2D_Mut == nullptr); (void)tex2D_Mut;
- auto tex2D_Dyn = pTestPSO->GetStaticVariableByName(SHADER_TYPE_VERTEX, "g_tex2D_Dyn");
- VERIFY_EXPR(tex2D_Dyn == nullptr); (void)tex2D_Dyn;
- auto tex2D_Mut_sampler = pTestPSO->GetStaticVariableByName(SHADER_TYPE_VERTEX, "g_tex2D_Mut_sampler");
- VERIFY_EXPR(tex2D_Mut_sampler == nullptr); (void)tex2D_Mut_sampler;
- auto tex2D_Dyn_sampler = pTestPSO->GetStaticVariableByName(SHADER_TYPE_VERTEX, "g_tex2D_DynArr_sampler");
- VERIFY_EXPR(tex2D_Dyn_sampler == nullptr); (void)tex2D_Dyn_sampler;
-
-
- auto NumVSVars = pTestPSO->GetStaticVariableCount(SHADER_TYPE_VERTEX);
- for(Uint32 v=0; v < NumVSVars; ++v)
- {
- auto pVar = pTestPSO->GetStaticVariableByIndex(SHADER_TYPE_VERTEX, v);
- VERIFY_EXPR(pVar->GetIndex() == v);
- VERIFY_EXPR(pVar->GetType() == SHADER_RESOURCE_VARIABLE_TYPE_STATIC);
- auto pVar2 = pTestPSO->GetStaticVariableByName(SHADER_TYPE_VERTEX, pVar->GetResourceDesc().Name);
- VERIFY_EXPR(pVar == pVar2);
- (void)pVar2;
- }
- }
-
-
- {
- VERIFY_EXPR(pTestPSO->GetStaticVariableCount(SHADER_TYPE_PIXEL) == 9);
-
- auto tex2D_Static = pTestPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, "g_tex2D_Static");
- VERIFY_EXPR(tex2D_Static->GetResourceDesc().ArraySize == 1);
- VERIFY_EXPR(tex2D_Static == pTestPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, tex2D_Static->GetResourceDesc().Name));
- tex2D_Static->Set(pSRVs[0]);
-
- auto tex2D_Static_sampler = pTestPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, "g_tex2D_Static_sampler");
- VERIFY_EXPR(tex2D_Static_sampler == nullptr);
- (void)tex2D_Static_sampler;
-
- auto tex2D_StaticArr = pTestPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, "g_tex2D_StaticArr");
- VERIFY_EXPR(tex2D_StaticArr->GetResourceDesc().ArraySize == 2);
- VERIFY_EXPR(tex2D_StaticArr == pTestPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, tex2D_StaticArr->GetResourceDesc().Name));
- tex2D_StaticArr->SetArray(pSRVs, 0, 2);
- auto tex2D_StaticArr_sampler = pTestPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, "g_tex2D_StaticArr_sampler");
- VERIFY_EXPR(tex2D_StaticArr_sampler == nullptr); (void)tex2D_StaticArr_sampler;
-
- auto UniformBuff_Stat = pTestPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, "UniformBuff_Stat");
- VERIFY_EXPR(UniformBuff_Stat->GetResourceDesc().ArraySize == 1);
- VERIFY_EXPR(UniformBuff_Stat == pTestPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, UniformBuff_Stat->GetResourceDesc().Name));
- UniformBuff_Stat->Set(pUBs[0]);
-
- auto UniformBuff_Stat2 = pTestPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, "UniformBuff_Stat2");
- VERIFY_EXPR(UniformBuff_Stat2->GetResourceDesc().ArraySize == 1);
- VERIFY_EXPR(UniformBuff_Stat2 == pTestPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, UniformBuff_Stat2->GetResourceDesc().Name));
- UniformBuff_Stat2->Set(pUBs[0]);
-
- auto Buffer_Static = pTestPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, "g_Buffer_Static");
- VERIFY_EXPR(Buffer_Static->GetResourceDesc().ArraySize == 1);
- VERIFY_EXPR(Buffer_Static == pTestPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, Buffer_Static->GetResourceDesc().Name));
- Buffer_Static->Set(pFormattedBuffSRV);
-
- auto Buffer_StaticArr = pTestPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, "g_Buffer_StaticArr");
- VERIFY_EXPR(Buffer_StaticArr->GetResourceDesc().ArraySize == 2);
- VERIFY_EXPR(Buffer_StaticArr == pTestPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, Buffer_StaticArr->GetResourceDesc().Name));
- Buffer_StaticArr->SetArray(&pFormattedBuffSRV,0,1);
- Buffer_StaticArr->SetArray(&pFormattedBuffSRV,1,1);
-
-
- auto rwtex2D_Static = pTestPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, "g_rwtex2D_Static");
- VERIFY_EXPR(rwtex2D_Static->GetResourceDesc().ArraySize == 1);
- VERIFY_EXPR(rwtex2D_Static == pTestPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, rwtex2D_Static->GetResourceDesc().Name));
- rwtex2D_Static->Set(pTexUAVs[0]);
-
- auto rwtex2D_Static2 = pTestPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, "g_rwtex2D_Static2");
- VERIFY_EXPR(rwtex2D_Static2->GetResourceDesc().ArraySize == 1);
- VERIFY_EXPR(rwtex2D_Static2 == pTestPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, rwtex2D_Static2->GetResourceDesc().Name));
- rwtex2D_Static2->Set(pTexUAVs[1]);
-
- auto rwBuff_Static = pTestPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, "g_rwBuff_Static");
- VERIFY_EXPR(rwBuff_Static->GetResourceDesc().ArraySize == 1);
- VERIFY_EXPR(rwBuff_Static == pTestPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, rwBuff_Static->GetResourceDesc().Name));
- rwBuff_Static->Set(spRawBuffUAV[0]);
-
-
- auto tex2D_Mut = pTestPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, "g_tex2D_Mut");
- VERIFY_EXPR(tex2D_Mut == nullptr); (void)tex2D_Mut;
- auto tex2D_Dyn = pTestPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, "g_tex2D_Dyn");
- VERIFY_EXPR(tex2D_Dyn == nullptr); (void)tex2D_Dyn;
- auto tex2D_Mut_sampler = pTestPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, "g_tex2D_Mut_sampler");
- VERIFY_EXPR(tex2D_Mut_sampler == nullptr); (void)tex2D_Mut_sampler;
- auto tex2D_Dyn_sampler = pTestPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, "g_tex2D_DynArr_sampler");
- VERIFY_EXPR(tex2D_Dyn_sampler == nullptr); (void)tex2D_Dyn_sampler;
-
-
- auto NumPSVars = pTestPSO->GetStaticVariableCount(SHADER_TYPE_PIXEL);
- for(Uint32 v=0; v < NumPSVars; ++v)
- {
- auto pVar = pTestPSO->GetStaticVariableByIndex(SHADER_TYPE_PIXEL, v);
- VERIFY_EXPR(pVar->GetIndex() == v);
- VERIFY_EXPR(pVar->GetType() == SHADER_RESOURCE_VARIABLE_TYPE_STATIC);
- auto pVar2 = pTestPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, pVar->GetResourceDesc().Name);
- VERIFY_EXPR(pVar == pVar2);
- (void)pVar2;
- }
- }
-
- RefCntAutoPtr<IShaderResourceBinding> pSRB;
- pTestPSO->CreateShaderResourceBinding(&pSRB, true);
-
- {
- auto tex2D_Mut = pSRB->GetVariableByName(SHADER_TYPE_VERTEX, "g_tex2D_Mut");
- VERIFY_EXPR(tex2D_Mut->GetResourceDesc().ArraySize == 1);
- VERIFY_EXPR(tex2D_Mut == pSRB->GetVariableByName(SHADER_TYPE_VERTEX, tex2D_Mut->GetResourceDesc().Name));
- tex2D_Mut->Set(pSRVs[0]);
-
- auto tex2D_Mut_sampler = pSRB->GetVariableByName(SHADER_TYPE_VERTEX, "g_tex2D_Mut_sampler");
- VERIFY_EXPR(tex2D_Mut_sampler == nullptr);
- (void)tex2D_Mut_sampler;
-
- auto tex2D_MutArr = pSRB->GetVariableByName(SHADER_TYPE_VERTEX, "g_tex2D_MutArr");
- VERIFY_EXPR(tex2D_MutArr->GetResourceDesc().ArraySize == 2);
- VERIFY_EXPR(tex2D_MutArr == pSRB->GetVariableByName(SHADER_TYPE_VERTEX, tex2D_MutArr->GetResourceDesc().Name));
- tex2D_MutArr->SetArray(pSRVs, 0, 2);
-
- auto tex2D_MutArr_sampler = pSRB->GetVariableByName(SHADER_TYPE_VERTEX, "g_tex2D_MutArr_sampler");
- VERIFY_EXPR(tex2D_MutArr_sampler == nullptr);
- (void)tex2D_MutArr_sampler;
-
- auto tex2D_Dyn = pSRB->GetVariableByName(SHADER_TYPE_VERTEX, "g_tex2D_Dyn");
- VERIFY_EXPR(tex2D_Dyn->GetResourceDesc().ArraySize == 1);
- VERIFY_EXPR(tex2D_Dyn == pSRB->GetVariableByName(SHADER_TYPE_VERTEX, tex2D_Dyn->GetResourceDesc().Name));
- tex2D_Dyn->Set(pSRVs[0]);
-
- auto tex2D_Dyn_sampler = pSRB->GetVariableByName(SHADER_TYPE_VERTEX, "g_tex2D_Dyn_sampler");
- VERIFY_EXPR(tex2D_Dyn_sampler == nullptr);
- (void)tex2D_Dyn_sampler;
-
- auto tex2D_DynArr = pSRB->GetVariableByName(SHADER_TYPE_VERTEX, "g_tex2D_DynArr");
- VERIFY_EXPR(tex2D_DynArr->GetResourceDesc().ArraySize == 2);
- VERIFY_EXPR(tex2D_DynArr == pSRB->GetVariableByName(SHADER_TYPE_VERTEX, tex2D_DynArr->GetResourceDesc().Name));
- tex2D_DynArr->SetArray(pSRVs, 0, 2);
-
- auto tex2D_DynArr_sampler = pSRB->GetVariableByName(SHADER_TYPE_VERTEX, "g_tex2D_DynArr_sampler");
- VERIFY_EXPR(tex2D_DynArr_sampler == nullptr);
- (void)tex2D_DynArr_sampler;
-
- auto UniformBuff_Mut = pSRB->GetVariableByName(SHADER_TYPE_VERTEX, "UniformBuff_Mut");
- VERIFY_EXPR(UniformBuff_Mut->GetResourceDesc().ArraySize == 1);
- VERIFY_EXPR(UniformBuff_Mut == pSRB->GetVariableByName(SHADER_TYPE_VERTEX, UniformBuff_Mut->GetResourceDesc().Name));
- UniformBuff_Mut->Set(pUBs[0]);
-
- auto UniformBuff_Dyn = pSRB->GetVariableByName(SHADER_TYPE_VERTEX, "UniformBuff_Dyn");
- VERIFY_EXPR(UniformBuff_Dyn->GetResourceDesc().ArraySize == 1);
- VERIFY_EXPR(UniformBuff_Dyn == pSRB->GetVariableByName(SHADER_TYPE_VERTEX, UniformBuff_Dyn->GetResourceDesc().Name));
- UniformBuff_Dyn->Set(pUBs[0]);
-
- auto Buffer_Mut = pSRB->GetVariableByName(SHADER_TYPE_VERTEX, "g_Buffer_Mut");
- VERIFY_EXPR(Buffer_Mut->GetResourceDesc().ArraySize == 1);
- VERIFY_EXPR(Buffer_Mut == pSRB->GetVariableByName(SHADER_TYPE_VERTEX, Buffer_Mut->GetResourceDesc().Name));
- Buffer_Mut->Set(pFormattedBuffSRV);
-
- auto Buffer_MutArr = pSRB->GetVariableByName(SHADER_TYPE_VERTEX, "g_Buffer_MutArr");
- VERIFY_EXPR(Buffer_MutArr->GetResourceDesc().ArraySize == 2);
- VERIFY_EXPR(Buffer_MutArr == pSRB->GetVariableByName(SHADER_TYPE_VERTEX, Buffer_MutArr->GetResourceDesc().Name));
- Buffer_MutArr->SetArray(&pFormattedBuffSRV, 0, 1);
- Buffer_MutArr->SetArray(&pFormattedBuffSRV, 1, 1);
-
- auto Buffer_Dyn = pSRB->GetVariableByName(SHADER_TYPE_VERTEX, "g_Buffer_Dyn");
- VERIFY_EXPR(Buffer_Dyn->GetResourceDesc().ArraySize == 1);
- VERIFY_EXPR(Buffer_Dyn == pSRB->GetVariableByName(SHADER_TYPE_VERTEX, Buffer_Dyn->GetResourceDesc().Name));
- Buffer_Dyn->Set(pFormattedBuffSRV);
-
- auto Buffer_DynArr = pSRB->GetVariableByName(SHADER_TYPE_VERTEX, "g_Buffer_DynArr");
- VERIFY_EXPR(Buffer_DynArr->GetResourceDesc().ArraySize == 2);
- VERIFY_EXPR(Buffer_DynArr == pSRB->GetVariableByName(SHADER_TYPE_VERTEX, Buffer_DynArr->GetResourceDesc().Name));
- Buffer_DynArr->SetArray(&pFormattedBuffSRV, 0, 1);
- Buffer_DynArr->SetArray(&pFormattedBuffSRV, 1, 1);
-
- auto tex2D_Static = pSRB->GetVariableByName(SHADER_TYPE_VERTEX, "g_tex2D_Static");
- VERIFY_EXPR(tex2D_Static == nullptr); (void)tex2D_Static;
- auto UniformBuff_Stat = pSRB->GetVariableByName(SHADER_TYPE_VERTEX, "UniformBuff_Stat");
- VERIFY_EXPR(UniformBuff_Stat == nullptr); (void)UniformBuff_Stat;
- }
-
-
-
- {
- auto tex2D_Mut = pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_tex2D_Mut");
- VERIFY_EXPR(tex2D_Mut->GetResourceDesc().ArraySize == 1);
- VERIFY_EXPR(tex2D_Mut == pSRB->GetVariableByName(SHADER_TYPE_PIXEL, tex2D_Mut->GetResourceDesc().Name));
- tex2D_Mut->Set(pRWTexSRVs[4]);
-
- auto tex2D_Mut_sampler = pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_tex2D_Mut_sampler");
- VERIFY_EXPR(tex2D_Mut_sampler == nullptr); (void)tex2D_Mut_sampler;
-
- auto tex2D_MutArr = pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_tex2D_MutArr");
- VERIFY_EXPR(tex2D_MutArr->GetResourceDesc().ArraySize == 2);
- VERIFY_EXPR(tex2D_MutArr == pSRB->GetVariableByName(SHADER_TYPE_PIXEL, tex2D_MutArr->GetResourceDesc().Name));
- tex2D_MutArr->SetArray(pRWTexSRVs+5, 0, 2);
-
- auto tex2D_MutArr_sampler = pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_tex2D_MutArr_sampler");
- VERIFY_EXPR(tex2D_MutArr_sampler == nullptr); (void)tex2D_MutArr_sampler;
-
- auto tex2D_Dyn = pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_tex2D_Dyn");
- VERIFY_EXPR(tex2D_Dyn->GetResourceDesc().ArraySize == 1);
- VERIFY_EXPR(tex2D_Dyn == pSRB->GetVariableByName(SHADER_TYPE_PIXEL, tex2D_Dyn->GetResourceDesc().Name));
- tex2D_Dyn->Set(pRWTexSRVs[7]);
-
- auto tex2D_Dyn_sampler = pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_tex2D_Dyn_sampler");
- VERIFY_EXPR(tex2D_Dyn_sampler == nullptr); (void)tex2D_Dyn_sampler;
-
- auto tex2D_DynArr = pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_tex2D_DynArr");
- VERIFY_EXPR(tex2D_DynArr->GetResourceDesc().ArraySize == 2);
- VERIFY_EXPR(tex2D_DynArr == pSRB->GetVariableByName(SHADER_TYPE_PIXEL, tex2D_DynArr->GetResourceDesc().Name));
- tex2D_DynArr->SetArray(pSRVs, 0, 2);
-
- auto tex2D_DynArr_sampler = pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_tex2D_DynArr_sampler");
- VERIFY_EXPR(tex2D_DynArr_sampler == nullptr); (void)tex2D_DynArr_sampler;
-
-
- auto UniformBuff_Mut = pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "UniformBuff_Mut");
- VERIFY_EXPR(UniformBuff_Mut->GetResourceDesc().ArraySize == 1);
- VERIFY_EXPR(UniformBuff_Mut == pSRB->GetVariableByName(SHADER_TYPE_PIXEL, UniformBuff_Mut->GetResourceDesc().Name));
- UniformBuff_Mut->Set(pUBs[0]);
-
- auto UniformBuff_Dyn = pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "UniformBuff_Dyn");
- VERIFY_EXPR(UniformBuff_Dyn->GetResourceDesc().ArraySize == 1);
- VERIFY_EXPR(UniformBuff_Dyn == pSRB->GetVariableByName(SHADER_TYPE_PIXEL, UniformBuff_Dyn->GetResourceDesc().Name));
- UniformBuff_Dyn->Set(pUBs[0]);
-
- auto Buffer_Mut = pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_Buffer_Mut");
- VERIFY_EXPR(Buffer_Mut->GetResourceDesc().ArraySize == 1);
- VERIFY_EXPR(Buffer_Mut == pSRB->GetVariableByName(SHADER_TYPE_PIXEL, Buffer_Mut->GetResourceDesc().Name));
- Buffer_Mut->Set(spRawBuffSRVs[1]);
-
- auto Buffer_MutArr = pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_Buffer_MutArr");
- VERIFY_EXPR(Buffer_MutArr->GetResourceDesc().ArraySize == 2);
- VERIFY_EXPR(Buffer_MutArr == pSRB->GetVariableByName(SHADER_TYPE_PIXEL, Buffer_MutArr->GetResourceDesc().Name));
- Buffer_MutArr->SetArray(&pFormattedBuffSRV, 0, 1);
- Buffer_MutArr->SetArray(&pFormattedBuffSRV, 1, 1);
-
- auto Buffer_Dyn = pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_Buffer_Dyn");
- VERIFY_EXPR(Buffer_Dyn->GetResourceDesc().ArraySize == 1);
- VERIFY_EXPR(Buffer_Dyn == pSRB->GetVariableByName(SHADER_TYPE_PIXEL, Buffer_Dyn->GetResourceDesc().Name));
- Buffer_Dyn->Set(pFormattedBuffSRVs[3]);
-
- auto Buffer_DynArr = pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_Buffer_DynArr");
- VERIFY_EXPR(Buffer_DynArr->GetResourceDesc().ArraySize == 2);
- VERIFY_EXPR(Buffer_DynArr == pSRB->GetVariableByName(SHADER_TYPE_PIXEL, Buffer_DynArr->GetResourceDesc().Name));
- Buffer_DynArr->SetArray(&pFormattedBuffSRV, 0, 1);
- Buffer_DynArr->SetArray(&pFormattedBuffSRV, 1, 1);
-
- auto rwtex2D_Mut = pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_rwtex2D_Mut");
- VERIFY_EXPR(rwtex2D_Mut->GetResourceDesc().ArraySize == 1);
- VERIFY_EXPR(rwtex2D_Mut == pSRB->GetVariableByName(SHADER_TYPE_PIXEL, rwtex2D_Mut->GetResourceDesc().Name));
- rwtex2D_Mut->Set(pTexUAVs[2]);
-
- auto rwtex2D_Dyn = pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_rwtex2D_Dyn");
- VERIFY_EXPR(rwtex2D_Dyn->GetResourceDesc().ArraySize == 1);
- VERIFY_EXPR(rwtex2D_Dyn == pSRB->GetVariableByName(SHADER_TYPE_PIXEL, rwtex2D_Dyn->GetResourceDesc().Name));
- rwtex2D_Dyn->Set(pTexUAVs[3]);
-
- auto rwBuff_Mut = pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_rwBuff_Mut");
- VERIFY_EXPR(rwBuff_Mut->GetResourceDesc().ArraySize == 1);
- VERIFY_EXPR(rwBuff_Mut == pSRB->GetVariableByName(SHADER_TYPE_PIXEL, rwBuff_Mut->GetResourceDesc().Name));
- rwBuff_Mut->Set(pFormattedBuffUAV[1]);
-
- auto rwBuff_Dyn = pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_rwBuff_Dyn");
- VERIFY_EXPR(rwBuff_Dyn->GetResourceDesc().ArraySize == 1);
- VERIFY_EXPR(rwBuff_Dyn == pSRB->GetVariableByName(SHADER_TYPE_PIXEL, rwBuff_Dyn->GetResourceDesc().Name));
- rwBuff_Dyn->Set(pFormattedBuffUAV[2]);
-
- auto tex2D_Static = pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_tex2D_Static");
- VERIFY_EXPR(tex2D_Static == nullptr); (void)tex2D_Static;
- auto UniformBuff_Stat = pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "UniformBuff_Stat");
- VERIFY_EXPR(UniformBuff_Stat == nullptr); (void)UniformBuff_Stat;
- }
-
-
-
- {
- auto NumVSVars = pSRB->GetVariableCount(SHADER_TYPE_VERTEX);
- for(Uint32 v=0; v < NumVSVars; ++v)
- {
- auto pVar = pSRB->GetVariableByIndex(SHADER_TYPE_VERTEX, v);
- VERIFY_EXPR(pVar->GetIndex() == v);
- VERIFY_EXPR(pVar->GetType() == SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE || pVar->GetType() == SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC);
- auto pVar2 = pSRB->GetVariableByName(SHADER_TYPE_VERTEX, pVar->GetResourceDesc().Name);
- VERIFY_EXPR(pVar == pVar2); (void)pVar2; (void)pVar;
- }
- }
-
- {
- auto NumPSVars = pSRB->GetVariableCount(SHADER_TYPE_PIXEL);
- for(Uint32 v=0; v < NumPSVars; ++v)
- {
- auto pVar = pSRB->GetVariableByIndex(SHADER_TYPE_PIXEL, v);
- VERIFY_EXPR(pVar->GetIndex() == v);
- VERIFY_EXPR(pVar->GetType() == SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE || pVar->GetType() == SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC);
- auto pVar2 = pSRB->GetVariableByName(SHADER_TYPE_PIXEL, pVar->GetResourceDesc().Name);
- VERIFY_EXPR(pVar == pVar2); (void)pVar2; (void)pVar;
- }
- }
-
-
- pContext->SetPipelineState(pTestPSO);
- pContext->CommitShaderResources(pSRB, RESOURCE_STATE_TRANSITION_MODE_TRANSITION);
-
- DrawAttribs DrawAttrs(3, DRAW_FLAG_VERIFY_ALL);
- pContext->Draw(DrawAttrs);
-
- pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_rwtex2D_Dyn")->Set(pTexUAVs[7]);
- pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_tex2D_Dyn")->Set(pRWTexSRVs[3]);
- pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_rwBuff_Dyn")->Set(pFormattedBuffUAV[3]);
- pSRB->GetVariableByName(SHADER_TYPE_PIXEL, "g_Buffer_Dyn")->Set(pFormattedBuffSRVs[2]);
-
- LOG_INFO_MESSAGE("No worries about 3 errors below: attempting to access variables from inactive shader stage");
- auto pNonExistingVar = pSRB->GetVariableByName(SHADER_TYPE_GEOMETRY, "g_NonExistingVar");
- VERIFY_EXPR(pNonExistingVar == nullptr);
- pNonExistingVar = pSRB->GetVariableByIndex(SHADER_TYPE_GEOMETRY, 4);
- VERIFY_EXPR(pNonExistingVar == nullptr);
- VERIFY_EXPR(pSRB->GetVariableCount(SHADER_TYPE_GEOMETRY) == 0);
-
- m_pDeviceContext->SetRenderTargets(1, &pRTV, pDSV, RESOURCE_STATE_TRANSITION_MODE_TRANSITION);
- float Zero[4] = {};
- m_pDeviceContext->ClearRenderTarget(pRTV, Zero, RESOURCE_STATE_TRANSITION_MODE_VERIFY);
- m_pDeviceContext->ClearDepthStencil(pDSV, CLEAR_DEPTH_FLAG, 1, 0, RESOURCE_STATE_TRANSITION_MODE_VERIFY);
-
- pContext->CommitShaderResources(pSRB, RESOURCE_STATE_TRANSITION_MODE_TRANSITION);
- pContext->Draw(DrawAttrs);
-
- m_pDeviceContext->SetRenderTargets(0, nullptr, nullptr, RESOURCE_STATE_TRANSITION_MODE_TRANSITION);
-
- SetStatus(TestResult::Succeeded);
-}
diff --git a/Tests/TestApp/src/TestTessellation.cpp b/Tests/TestApp/src/TestTessellation.cpp
index bec50cc..6d9f001 100644
--- a/Tests/TestApp/src/TestTessellation.cpp
+++ b/Tests/TestApp/src/TestTessellation.cpp
@@ -21,9 +21,6 @@
* of the possibility of such damages.
*/
-// EngineSandbox.cpp : Defines the entry point for the application.
-//
-
#include "pch.h"
#include "TestTessellation.h"
#include "MapHelper.h"
diff --git a/Tests/TestApp/src/TestTextureCreation.cpp b/Tests/TestApp/src/TestTextureCreation.cpp
deleted file mode 100644
index b687121..0000000
--- a/Tests/TestApp/src/TestTextureCreation.cpp
+++ /dev/null
@@ -1,987 +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 "TestTextureCreation.h"
-#include "RenderDevice.h"
-#include "GraphicsUtilities.h"
-#include "Errors.h"
-#include "TestCreateObjFromNativeRes.h"
-
-#if D3D11_SUPPORTED
-#include "TestCreateObjFromNativeResD3D11.h"
-#endif
-
-#if D3D12_SUPPORTED
-#include "TestCreateObjFromNativeResD3D12.h"
-#endif
-
-#if GL_SUPPORTED || GLES_SUPPORTED
-#include "TestCreateObjFromNativeResGL.h"
-#endif
-
-#if VULKAN_SUPPORTED
-#include "TestCreateObjFromNativeResVK.h"
-#endif
-
-using namespace Diligent;
-
-class TextureCreationVerifier
-{
-public:
- TextureCreationVerifier( IRenderDevice *pDevice, IDeviceContext *pContext ) :
- m_pDevice(pDevice),
- m_pDeviceContext(pContext),
- m_BindFlags(BIND_NONE),
- m_TextureFormat(TEX_FORMAT_UNKNOWN),
- m_PixelSize(0),
- m_bTestDataUpload(False)
- {
- auto DevType = m_pDevice->GetDeviceCaps().DevType;
- switch (DevType)
- {
-#if D3D11_SUPPORTED
- case DeviceType::D3D11:
- m_pTestCreateObjFromNativeRes.reset(new TestCreateObjFromNativeResD3D11(pDevice));
- break;
-#endif
-
-#if D3D12_SUPPORTED
- case DeviceType::D3D12:
- m_pTestCreateObjFromNativeRes.reset(new TestCreateObjFromNativeResD3D12(pDevice));
- break;
-#endif
-
-#if GL_SUPPORTED || GLES_SUPPORTED
- case DeviceType::OpenGL:
- case DeviceType::OpenGLES:
- m_pTestCreateObjFromNativeRes.reset(new TestCreateObjFromNativeResGL(pDevice));
- break;
-#endif
-
-#if VULKAN_SUPPORTED
- case DeviceType::Vulkan:
- m_pTestCreateObjFromNativeRes.reset(new TestCreateObjFromNativeResVK(pDevice));
- break;
-#endif
-
- default: UNEXPECTED("Unexpected device type");
- }
- }
-
- void Test(TEXTURE_FORMAT TextureFormat,
- Uint32 PixelSize,
- BIND_FLAGS BindFlags,
- Bool TestDataUpload)
- {
- m_TextureFormat = TextureFormat;
- m_BindFlags = BindFlags;
- m_PixelSize = PixelSize;
- m_bTestDataUpload = TestDataUpload;
-
- auto PixelFormatAttribs = m_pDevice->GetTextureFormatInfoExt(TextureFormat);
-
- const auto &TexCaps = m_pDevice->GetDeviceCaps().TexCaps;
- // Test texture 1D / texture 1D array
- if( TexCaps.bTexture1DSupported )
- {
- if( PixelFormatAttribs.Tex1DFmt )
- CreateTestTexture( RESOURCE_DIM_TEX_1D, 1 );
- }
- else
- {
- static bool FirstTime = true;
- if( FirstTime )
- {
- LOG_WARNING_MESSAGE( "Texture 1D is not supported\n" );
- FirstTime = false;
- }
- }
-
- if( TexCaps.bTexture1DArraySupported )
- {
- if( PixelFormatAttribs.Tex1DFmt )
- CreateTestTexture( RESOURCE_DIM_TEX_1D_ARRAY, 1 );
- }
- else
- {
- static bool FirstTime = true;
- if( FirstTime )
- {
- LOG_WARNING_MESSAGE( "Texture 1D array is not supported\n" );
- FirstTime = false;
- }
- }
-
- // Test texture 2D / texture 2D array
- CreateTestTexture(RESOURCE_DIM_TEX_2D, 1);
- CreateTestTexture(RESOURCE_DIM_TEX_2D, 1);
- CreateTestTexture(RESOURCE_DIM_TEX_2D_ARRAY, 1);
- CreateTestTexture(RESOURCE_DIM_TEX_2D_ARRAY, 1);
- CreateTestCubemap();
-
- if( m_TextureFormat != TEX_FORMAT_RGB9E5_SHAREDEXP &&
- PixelFormatAttribs.ComponentType != COMPONENT_TYPE_COMPRESSED )
- {
- if (TexCaps.bTexture2DMSSupported)
- {
- if( (PixelFormatAttribs.SampleCounts & 0x04) != 0 && (BindFlags & (BIND_RENDER_TARGET|BIND_DEPTH_STENCIL)) != 0 )
- {
- CreateTestTexture( RESOURCE_DIM_TEX_2D, 4 );
- CreateTestTexture( RESOURCE_DIM_TEX_2D, 4 );
- }
- }
- else
- {
- LOG_WARNING_MESSAGE_ONCE("Texture 2D MS is not supported\n");
- }
-
- if (TexCaps.bTexture2DMSArraySupported)
- {
- if( (PixelFormatAttribs.SampleCounts & 0x04) != 0 && (BindFlags & (BIND_RENDER_TARGET|BIND_DEPTH_STENCIL)) != 0)
- {
- CreateTestTexture( RESOURCE_DIM_TEX_2D_ARRAY, 4 );
- CreateTestTexture( RESOURCE_DIM_TEX_2D_ARRAY, 4 );
- }
- }
- else
- {
- LOG_WARNING_MESSAGE_ONCE( "Texture 2D MS Array is not supported\n" );
- }
- }
-
- // Test texture 3D
- if( PixelFormatAttribs.Tex3DFmt )
- CreateTestTexture(RESOURCE_DIM_TEX_3D, 1);
- }
-
-private:
- void PrepareSubresourceData(TextureDesc &TexDesc,
- TextureFormatInfo &PixelFormatAttribs,
- std::vector< std::vector<Uint8> > &Data,
- std::vector<TextureSubResData> &SubResources,
- TextureData &InitData)
- {
-
- Uint32 PixelSize = Uint32{PixelFormatAttribs.ComponentSize} * Uint32{PixelFormatAttribs.NumComponents};
- assert( PixelSize == m_PixelSize );
-
- Uint32 ArrSize = (TexDesc.Type == RESOURCE_DIM_TEX_3D) ? 1 : TexDesc.ArraySize;
- InitData.NumSubresources = ArrSize * TexDesc.MipLevels;
- Data.resize(InitData.NumSubresources);
- SubResources.resize(InitData.NumSubresources);
- Uint32 SubRes = 0;
- for(Uint32 Slice = 0; Slice < ArrSize; ++Slice)
- {
- for(Uint32 Mip = 0; Mip < TexDesc.MipLevels; ++Mip)
- {
- Uint32 MipWidth = std::max(TexDesc.Width >> Mip, 1U);
- Uint32 MipHeight = std::max(TexDesc.Height >> Mip, 1U);
- auto &CurrSubResData = Data[SubRes];
- auto &SubResInfo = SubResources[SubRes];
- SubResInfo.Stride = (MipWidth + 128) * PixelSize;
- SubResInfo.Stride = (SubResInfo.Stride + 3) & (-4);
- auto SubresDataSize = 0;
- if(TexDesc.Type == RESOURCE_DIM_TEX_3D)
- {
- SubResInfo.DepthStride = SubResInfo.Stride * (MipHeight + 32);
- Uint32 MipDeth = std::max(TexDesc.Depth >> Mip, 1U);
- SubresDataSize = SubResInfo.DepthStride * MipDeth;
- }
- else
- SubresDataSize = SubResInfo.Stride * MipHeight;
-
- CurrSubResData.resize(SubresDataSize);
- SubResInfo.pData = CurrSubResData.data();
- ++SubRes;
- }
- }
- InitData.pSubResources = SubResources.data();
- }
- void CreateTestTexture(RESOURCE_DIMENSION Type, Uint32 SampleCount)
- {
- TextureDesc TexDesc;
- TexDesc.Name = "TestTextureCreation";
- TexDesc.Type = Type;
- TexDesc.Width = 211;
- if( TexDesc.Type == RESOURCE_DIM_TEX_1D || TexDesc.Type == RESOURCE_DIM_TEX_1D_ARRAY )
- TexDesc.Height = 1;
- else
- TexDesc.Height = 243;
-
- if( TexDesc.Type == RESOURCE_DIM_TEX_3D )
- TexDesc.Depth = 16;
-
- if( TexDesc.Type == RESOURCE_DIM_TEX_1D_ARRAY || TexDesc.Type == RESOURCE_DIM_TEX_2D_ARRAY )
- TexDesc.ArraySize = 16;
-
- auto PixelFormatAttribs = m_pDevice->GetTextureFormatInfoExt(m_TextureFormat);
- if( PixelFormatAttribs.ComponentType == COMPONENT_TYPE_COMPRESSED )
- {
- TexDesc.Width = (TexDesc.Width+3) & (-4);
- TexDesc.Height = (TexDesc.Height+3) & (-4);
- }
-
- TexDesc.MipLevels = SampleCount == 1 ? 0 : 1;
- TexDesc.Format = m_TextureFormat;
- TexDesc.Usage = USAGE_DEFAULT;
- TexDesc.BindFlags = m_BindFlags;
- if( SampleCount > 1 )
- TexDesc.BindFlags &= ~BIND_UNORDERED_ACCESS;
-
- TexDesc.SampleCount = SampleCount;
-
- RefCntAutoPtr<Diligent::ITexture> pTestTex;
- TextureData NullData;
- m_pDevice->CreateTexture( TexDesc, &NullData, &pTestTex );
- m_pTestCreateObjFromNativeRes->CreateTexture(pTestTex);
- TexDesc.MipLevels = pTestTex->GetDesc().MipLevels;
- if( SampleCount == 1 && m_bTestDataUpload )
- {
- std::vector< std::vector<Uint8> > Data;
- std::vector<TextureSubResData> SubResources;
- TextureData InitData;
-
- PrepareSubresourceData(TexDesc, PixelFormatAttribs, Data, SubResources, InitData);
-
- TexDesc.Name = "TestTexture2";
- RefCntAutoPtr<Diligent::ITexture> pTestTex2;
- m_pDevice->CreateTexture( TexDesc, &InitData, &pTestTex2 );
- m_pTestCreateObjFromNativeRes->CreateTexture(pTestTex2);
-
- if(m_pDevice->GetDeviceCaps().DevType == DeviceType::D3D11 &&
- ((TexDesc.BindFlags & BIND_DEPTH_STENCIL) != 0 || TexDesc.SampleCount > 1) )
- {
- // In D3D11 if CopySubresourceRegion is used with Multisampled or D3D11_BIND_DEPTH_STENCIL Resources,
- // then the whole Subresource must be copied.
- CopyTextureAttribs CopyAttribs(pTestTex2, RESOURCE_STATE_TRANSITION_MODE_TRANSITION, pTestTex, RESOURCE_STATE_TRANSITION_MODE_TRANSITION);
- m_pDeviceContext->CopyTexture(CopyAttribs);
- }
- else
- {
- Box SrcBox;
- SrcBox.MinX = TexDesc.Width/4;
- SrcBox.MinY = TexDesc.Height/4;
- SrcBox.MinZ = ( TexDesc.Type == RESOURCE_DIM_TEX_3D ) ? TexDesc.Depth/4 : 0;
- SrcBox.MaxX = std::max(TexDesc.Width/3, SrcBox.MinX+1);
- SrcBox.MaxY = std::max(TexDesc.Height/3, SrcBox.MinY+1);
- SrcBox.MaxZ = ( TexDesc.Type == RESOURCE_DIM_TEX_3D ) ? std::max(TexDesc.Depth/3, SrcBox.MinZ+1) : 1;
- //pTestTex2->UpdateData(m_pDeviceContext, 0, 0, DstBox, SubResources[0]);
- CopyTextureAttribs CopyAttribs(pTestTex2, RESOURCE_STATE_TRANSITION_MODE_TRANSITION, pTestTex, RESOURCE_STATE_TRANSITION_MODE_TRANSITION);
- CopyAttribs.pSrcBox = &SrcBox;
- m_pDeviceContext->CopyTexture(CopyAttribs);
- }
- }
-
- const auto &DeviceCaps = m_pDevice->GetDeviceCaps();
- const auto &TextureCaps = DeviceCaps.TexCaps;
-
- if (!TextureCaps.bTextureViewSupported)
- {
- LOG_WARNING_MESSAGE_ONCE("Texture views are not supported!\n");
- }
-
- if (TextureCaps.bTextureViewSupported && !m_pDevice->GetTextureFormatInfo(TexDesc.Format).IsTypeless)
- {
- TextureViewDesc ViewDesc;
- ViewDesc.TextureDim = TexDesc.Type;
-
- if( SampleCount > 1 )
- {
- ViewDesc.MostDetailedMip = 0;
- ViewDesc.NumMipLevels = 1;
- }
- else
- {
- ViewDesc.MostDetailedMip = 1;
- ViewDesc.NumMipLevels = 2;
- }
-
- if( TexDesc.Type == RESOURCE_DIM_TEX_1D_ARRAY || TexDesc.Type == RESOURCE_DIM_TEX_2D_ARRAY )
- {
- ViewDesc.FirstArraySlice = 3;
- ViewDesc.NumArraySlices = (DeviceCaps.DevType == DeviceType::D3D11 || DeviceCaps.DevType == DeviceType::D3D12 || ViewDesc.ViewType == TEXTURE_VIEW_SHADER_RESOURCE) ? 4 : 1;
- }
- else if(TexDesc.Type == RESOURCE_DIM_TEX_3D)
- {
- if( DeviceCaps.DevType == DeviceType::D3D11 || DeviceCaps.DevType == DeviceType::D3D12 )
- {
- ViewDesc.FirstDepthSlice = 3;
- ViewDesc.NumDepthSlices = 4;
- }
- else if( (DeviceCaps.DevType == DeviceType::Vulkan && ViewDesc.ViewType != TEXTURE_VIEW_RENDER_TARGET && ViewDesc.ViewType != TEXTURE_VIEW_DEPTH_STENCIL) ||
- DeviceCaps.DevType != DeviceType::Vulkan)
- {
- // OpenGL cannot create views for separate depth slices
- ViewDesc.FirstDepthSlice = 0;
- ViewDesc.NumDepthSlices = TexDesc.Depth >> ViewDesc.MostDetailedMip;
- }
- }
- else
- {
- ViewDesc.FirstArraySlice = 0;
- ViewDesc.NumArraySlices = 1;
- }
-
- if( TexDesc.BindFlags & BIND_SHADER_RESOURCE )
- {
- ViewDesc.ViewType = TEXTURE_VIEW_SHADER_RESOURCE;
- RefCntAutoPtr<ITextureView> pSRV;
- pTestTex->CreateView( ViewDesc, &pSRV );
- }
-
- // RTV, DSV & UAV can reference only one mip level
- ViewDesc.NumMipLevels = 1;
-
- if( TexDesc.BindFlags & BIND_RENDER_TARGET )
- {
- ViewDesc.ViewType = TEXTURE_VIEW_RENDER_TARGET;
- RefCntAutoPtr<ITextureView> pRTV;
- pTestTex->CreateView( ViewDesc, &pRTV );
- }
-
- if( TexDesc.BindFlags & BIND_DEPTH_STENCIL )
- {
- ViewDesc.ViewType = TEXTURE_VIEW_DEPTH_STENCIL;
- RefCntAutoPtr<ITextureView> pDSV;
- pTestTex->CreateView( ViewDesc, &pDSV );
- }
-
- if( TexDesc.BindFlags & BIND_UNORDERED_ACCESS )
- {
- ViewDesc.ViewType = TEXTURE_VIEW_UNORDERED_ACCESS;
- ViewDesc.AccessFlags = UAV_ACCESS_FLAG_READ | UAV_ACCESS_FLAG_WRITE;
- RefCntAutoPtr<ITextureView> pUAV;
- pTestTex->CreateView( ViewDesc, &pUAV );
- }
- }
-
- // It is necessary to call Flush() to force the driver to release the resources.
- // Without flushing the command buffer, the memory is not released until sometimes
- // later causing out-of-memory error
- m_pDeviceContext->Flush();
- // Also call FinishFrame() because otherwise resources will not be released
- m_pDeviceContext->FinishFrame();
-
- m_pDevice->ReleaseStaleResources();
- }
-
-
- void CreateTestCubemap()
- {
- TextureDesc TexDesc;
- TexDesc.Name = "Test Cube MapTextureCreation";
- TexDesc.Type = RESOURCE_DIM_TEX_CUBE;
- TexDesc.Width = 256;
- TexDesc.Height = 256;
- TexDesc.ArraySize = 6;
- TexDesc.MipLevels = 0;
- TexDesc.Format = m_TextureFormat;
- TexDesc.Usage = USAGE_DEFAULT;
- TexDesc.BindFlags = m_BindFlags;
- TexDesc.SampleCount = 1;
-
- RefCntAutoPtr<Diligent::ITexture> pTestCubemap, pTestCubemapArr;
- m_pDevice->CreateTexture( TexDesc, nullptr, &pTestCubemap );
- m_pTestCreateObjFromNativeRes->CreateTexture(pTestCubemap);
- TexDesc.MipLevels = pTestCubemap->GetDesc().MipLevels;
-
- auto PixelFormatAttribs = m_pDevice->GetTextureFormatInfoExt(m_TextureFormat);
- if( m_bTestDataUpload )
- {
- std::vector< std::vector<Uint8> > Data;
- std::vector<TextureSubResData> SubResources;
- TextureData InitData;
-
- PrepareSubresourceData(TexDesc, PixelFormatAttribs, Data, SubResources, InitData);
-
- InitData.pSubResources = SubResources.data();
- TexDesc.Name = "TestCubemap2";
- pTestCubemap.Release();
- m_pDevice->CreateTexture( TexDesc, &InitData, &pTestCubemap );
- m_pTestCreateObjFromNativeRes->CreateTexture(pTestCubemap);
- }
-
- const auto &DeviceCaps = m_pDevice->GetDeviceCaps();
- const auto &TextureCaps = DeviceCaps.TexCaps;
- if( TextureCaps.bTextureViewSupported && !m_pDevice->GetTextureFormatInfo(TexDesc.Format).IsTypeless )
- {
- TextureViewDesc ViewDesc;
- if( TexDesc.BindFlags & BIND_SHADER_RESOURCE )
- {
- ViewDesc.TextureDim = RESOURCE_DIM_TEX_CUBE;
- ViewDesc.ViewType = TEXTURE_VIEW_SHADER_RESOURCE;
- ViewDesc.MostDetailedMip = 1;
- ViewDesc.NumMipLevels = 6;
- {
- RefCntAutoPtr<ITextureView> pSRV;
- pTestCubemap->CreateView( ViewDesc, &pSRV );
- }
-
- ViewDesc.TextureDim = RESOURCE_DIM_TEX_2D;
- ViewDesc.FirstArraySlice = 0;
- ViewDesc.NumArraySlices = 1;
- ViewDesc.MostDetailedMip = 2;
- ViewDesc.NumMipLevels = 4;
- {
- RefCntAutoPtr<ITextureView> pSRV;
- pTestCubemap->CreateView( ViewDesc, &pSRV );
- }
-
- ViewDesc.TextureDim = RESOURCE_DIM_TEX_2D_ARRAY;
- ViewDesc.FirstArraySlice = 2;
- ViewDesc.NumArraySlices = 3;
- {
- RefCntAutoPtr<ITextureView> pSRV;
- pTestCubemap->CreateView( ViewDesc, &pSRV );
- }
- }
-
- // RTV, DSV & UAV can reference only one mip level
- ViewDesc.NumMipLevels = 1;
-
- if( TexDesc.BindFlags & BIND_RENDER_TARGET )
- {
- ViewDesc.ViewType = TEXTURE_VIEW_RENDER_TARGET;
- ViewDesc.TextureDim = RESOURCE_DIM_TEX_2D;
- ViewDesc.FirstArraySlice = 0;
- ViewDesc.NumArraySlices = 1;
- {
- RefCntAutoPtr<ITextureView> pRTV;
- pTestCubemap->CreateView( ViewDesc, &pRTV );
- }
-
- ViewDesc.TextureDim = RESOURCE_DIM_TEX_2D_ARRAY;
- ViewDesc.FirstArraySlice = 2;
- ViewDesc.NumArraySlices = 3;
- {
- RefCntAutoPtr<ITextureView> pRTV;
- pTestCubemap->CreateView( ViewDesc, &pRTV );
- }
- }
-
- if( TexDesc.BindFlags & BIND_DEPTH_STENCIL )
- {
- ViewDesc.ViewType = TEXTURE_VIEW_DEPTH_STENCIL;
- ViewDesc.TextureDim = RESOURCE_DIM_TEX_2D;
- ViewDesc.NumArraySlices = 1;
- ViewDesc.FirstArraySlice = 0;
- ViewDesc.MostDetailedMip = 2;
- {
- RefCntAutoPtr<ITextureView> pDSV;
- pTestCubemap->CreateView( ViewDesc, &pDSV );
- }
-
- ViewDesc.TextureDim = RESOURCE_DIM_TEX_2D_ARRAY;
- ViewDesc.NumArraySlices = 3;
- ViewDesc.FirstArraySlice = 2;
- {
- RefCntAutoPtr<ITextureView> pDSV;
- pTestCubemap->CreateView( ViewDesc, &pDSV );
- }
- }
-
- if( TexDesc.BindFlags & BIND_UNORDERED_ACCESS )
- {
- ViewDesc.ViewType = TEXTURE_VIEW_UNORDERED_ACCESS;
- ViewDesc.AccessFlags = UAV_ACCESS_FLAG_READ | UAV_ACCESS_FLAG_WRITE;
- ViewDesc.TextureDim = RESOURCE_DIM_TEX_2D;
- ViewDesc.NumArraySlices = 1;
- ViewDesc.FirstArraySlice = 0;
- {
- RefCntAutoPtr<ITextureView> pUAV;
- pTestCubemap->CreateView( ViewDesc, &pUAV );
- }
-
- ViewDesc.TextureDim = RESOURCE_DIM_TEX_2D_ARRAY;
- if( DeviceCaps.DevType == DeviceType::OpenGL || DeviceCaps.DevType == DeviceType::OpenGLES )
- {
- ViewDesc.NumArraySlices = 1;
- ViewDesc.FirstArraySlice = 2;
- }
- else
- {
- ViewDesc.NumArraySlices = 3;
- ViewDesc.FirstArraySlice = 2;
- }
-
- {
- RefCntAutoPtr<ITextureView> pUAV;
- pTestCubemap->CreateView( ViewDesc, &pUAV );
- }
- }
- }
-
- if(DeviceCaps.TexCaps.bCubemapArraysSupported)
- {
- TexDesc.ArraySize = 24;
- TexDesc.Type = RESOURCE_DIM_TEX_CUBE_ARRAY;
-
- std::vector< std::vector<Uint8> > Data;
- std::vector<TextureSubResData> SubResources;
- TextureData InitData;
-
- if( m_bTestDataUpload )
- {
- PrepareSubresourceData(TexDesc, PixelFormatAttribs, Data, SubResources, InitData);
- }
-
- TexDesc.Name = "TestCubemapArray";
-
- m_pDevice->CreateTexture( TexDesc, &InitData, &pTestCubemapArr );
- m_pTestCreateObjFromNativeRes->CreateTexture(pTestCubemapArr);
- }
-
- // It is necessary to call Flush() to force the driver to release the resources.
- // Without flushing the command buffer, the memory is not released until sometimes
- // later causing out-of-memory error
- m_pDeviceContext->Flush();
- }
- IRenderDevice *m_pDevice;
- IDeviceContext *m_pDeviceContext;
- BIND_FLAGS m_BindFlags;
- TEXTURE_FORMAT m_TextureFormat;
- Uint32 m_PixelSize;
- Bool m_bTestDataUpload;
- std::unique_ptr<TestCreateObjFromNativeRes> m_pTestCreateObjFromNativeRes;
-};
-
-TestTextureCreation::TestTextureCreation( IRenderDevice *pDevice, IDeviceContext *pContext ) :
- UnitTestBase("Texture creation test"),
- m_pDevice(pDevice)
-{
- TestTextureFormatAttribs();
-
- TextureCreationVerifier Verifier(pDevice, pContext);
- const BIND_FLAGS BindSRU = BIND_SHADER_RESOURCE | BIND_RENDER_TARGET | BIND_UNORDERED_ACCESS;
- const BIND_FLAGS BindSR = BIND_SHADER_RESOURCE | BIND_RENDER_TARGET;
- //const BIND_FLAGS BindSD = BIND_SHADER_RESOURCE | BIND_DEPTH_STENCIL;
- const BIND_FLAGS BindSU = BIND_SHADER_RESOURCE | BIND_UNORDERED_ACCESS;
- const BIND_FLAGS BindSD = BIND_SHADER_RESOURCE | BIND_DEPTH_STENCIL;
- const BIND_FLAGS BindD = BIND_DEPTH_STENCIL;
- const BIND_FLAGS BindS = BIND_SHADER_RESOURCE;
-
- struct TextureTestAttribs
- {
- TEXTURE_FORMAT Fmt;
- Uint32 PixelSize;
- BIND_FLAGS BindFlags;
- Bool TestDataUpload;
- const char* Name;
- };
-
- const TextureTestAttribs TestAttribs[] =
- {
- {TEX_FORMAT_RGBA32_TYPELESS, 16, BindSRU, true, "RGBA32_TYPELESS"},
- {TEX_FORMAT_RGBA32_FLOAT, 16, BindSRU, true, "RGBA32_FLOAT"},
- {TEX_FORMAT_RGBA32_UINT, 16, BindSRU, true, "RGBA32_UINT"},
- {TEX_FORMAT_RGBA32_SINT, 16, BindSRU, true, "RGBA32_SINT"},
- //{TEX_FORMAT_RGB32_TYPELESS, , 5, "RGB32_TYPELESS"},
-
- // These formats are ill-supported
- //{TEX_FORMAT_RGB32_FLOAT, 12, BindS, true, "RGB32_FLOAT"},
- //{TEX_FORMAT_RGB32_UINT, 12, BindS, true, "RGB32_UINT"},
- //{TEX_FORMAT_RGB32_SINT, 12, BindS, true, "RGB32_SINT"},
-
- {TEX_FORMAT_RGBA16_TYPELESS, 8, BindSRU, true, "RGBA16_TYPELESS"},
- {TEX_FORMAT_RGBA16_FLOAT, 8, BindSRU, true, "RGBA16_FLOAT"},
- {TEX_FORMAT_RGBA16_UNORM, 8, BindSRU, true, "RGBA16_UNORM"},
- {TEX_FORMAT_RGBA16_UINT, 8, BindSRU, true, "RGBA16_UINT"},
- {TEX_FORMAT_RGBA16_SNORM, 8, BindSU, true, "RGBA16_SNORM"},
- {TEX_FORMAT_RGBA16_SINT, 8, BindSRU, true, "RGBA16_SINT"},
-
- {TEX_FORMAT_RG32_TYPELESS, 8, BindSRU, true, "RG32_TYPELESS"},
- {TEX_FORMAT_RG32_FLOAT, 8, BindSRU, true, "RG32_FLOAT"},
- {TEX_FORMAT_RG32_UINT, 8, BindSRU, true, "RG32_UINT"},
- {TEX_FORMAT_RG32_SINT, 8, BindSRU, true, "RG32_SINT"},
-
- {TEX_FORMAT_R32G8X24_TYPELESS, 8, BindD, false, "R32G8X24_TYPELESS"},
- {TEX_FORMAT_D32_FLOAT_S8X24_UINT, 8, BindD, false, "D32_FLOAT_S8X24_UINT"},
- //{TEX_FORMAT_R32_FLOAT_X8X24_TYPELESS, 8, BindD, false, "R32_FLOAT_X8X24_TYPELESS"},
- //{TEX_FORMAT_X32_TYPELESS_G8X24_UINT, 8, BindD, false, "X32_TYPELESS_G8X24_UINT"},
-
- {TEX_FORMAT_RGB10A2_TYPELESS, 4, BindSR, true, "RGB10A2_TYPELESS"},
- {TEX_FORMAT_RGB10A2_UNORM, 4, BindSR, true, "RGB10A2_UNORM"},
- {TEX_FORMAT_RGB10A2_UINT, 4, BindS, true, "RGB10A2_UINT"},
- {TEX_FORMAT_R11G11B10_FLOAT, 4, BindSRU, false, "R11G11B10_FLOAT"},
-
- {TEX_FORMAT_RGBA8_TYPELESS, 4, BindSRU, true, "RGBA8_TYPELESS"},
- {TEX_FORMAT_RGBA8_UNORM, 4, BindSRU, true, "RGBA8_UNORM"},
- {TEX_FORMAT_RGBA8_UNORM_SRGB, 4, BindSR, true, "RGBA8_UNORM_SRGB"},
- {TEX_FORMAT_RGBA8_UINT, 4, BindSRU, true, "RGBA8_UINT"},
- {TEX_FORMAT_RGBA8_SNORM, 4, BindSU, true, "RGBA8_SNORM"},
- {TEX_FORMAT_RGBA8_SINT, 4, BindSRU, true, "RGBA8_SINT"},
-
- {TEX_FORMAT_RG16_TYPELESS, 4, BindSRU, true, "RG16_TYPELESS"},
- {TEX_FORMAT_RG16_FLOAT, 4, BindSRU, true, "RG16_FLOAT"},
- {TEX_FORMAT_RG16_UNORM, 4, BindSRU, true, "RG16_UNORM"},
- {TEX_FORMAT_RG16_UINT, 4, BindSRU, true, "RG16_UINT"},
- {TEX_FORMAT_RG16_SNORM, 4, BindSU, true, "RG16_SNORM"},
- {TEX_FORMAT_RG16_SINT, 4, BindSRU, true, "RG16_SINT"},
-
- {TEX_FORMAT_R32_TYPELESS, 4, BindSRU, true, "R32_TYPELESS"},
- {TEX_FORMAT_D32_FLOAT, 4, BindD, true, "D32_FLOAT"},
- {TEX_FORMAT_R32_FLOAT, 4, BindSRU, true, "R32_FLOAT"},
- {TEX_FORMAT_R32_UINT, 4, BindSRU, true, "R32_UINT"},
- {TEX_FORMAT_R32_SINT, 4, BindSRU, true, "R32_SINT"},
-
- {TEX_FORMAT_R24G8_TYPELESS, 4, BindSD, false, "R24G8_TYPELESS"},
- {TEX_FORMAT_D24_UNORM_S8_UINT, 4, BindD, false, "D24_UNORM_S8_UINT"},
- //{TEX_FORMAT_R24_UNORM_X8_TYPELESS, 4, BindD, true, "R24_UNORM_X8_TYPELESS"},
- //{TEX_FORMAT_X24_TYPELESS_G8_UINT, 4, BindD, true, "X24_TYPELESS_G8_UINT"},
-
- {TEX_FORMAT_RG8_TYPELESS, 2, BindSRU, true, "RG8_TYPELESS"},
- {TEX_FORMAT_RG8_UNORM, 2, BindSRU, true, "RG8_UNORM"},
- {TEX_FORMAT_RG8_UINT, 2, BindSRU, true, "RG8_UINT"},
- {TEX_FORMAT_RG8_SNORM, 2, BindSU, true, "RG8_SNORM"},
- {TEX_FORMAT_RG8_SINT, 2, BindSRU, true, "RG8_SINT"},
-
- {TEX_FORMAT_R16_TYPELESS, 2, BindSRU, true, "R16_TYPELESS"},
- {TEX_FORMAT_R16_FLOAT, 2, BindSRU, true, "R16_FLOAT"},
- {TEX_FORMAT_D16_UNORM, 2, BindD, true, "D16_UNORM"},
- {TEX_FORMAT_R16_UNORM, 2, BindSRU, true, "R16_UNORM"},
- {TEX_FORMAT_R16_UINT, 2, BindSRU, true, "R16_UINT"},
- {TEX_FORMAT_R16_SNORM, 2, BindSU, true, "R16_SNORM"},
- {TEX_FORMAT_R16_SINT, 2, BindSRU, true, "R16_SINT"},
-
- {TEX_FORMAT_R8_TYPELESS, 1, BindSRU, true, "R8_TYPELESS"},
- {TEX_FORMAT_R8_UNORM, 1, BindSRU, true, "R8_UNORM"},
- {TEX_FORMAT_R8_UINT, 1, BindSRU, true, "R8_UINT"},
- {TEX_FORMAT_R8_SNORM, 1, BindSU, true, "R8_SNORM"},
- {TEX_FORMAT_R8_SINT, 1, BindSRU, true, "R8_SINT"},
- //{TEX_FORMAT_A8_UNORM, 1, BindSRU, true, "A8_UNORM"},
- //{TEX_FORMAT_R1_UNORM, 1, BindSRU, true, "R1_UNORM"},
-
- {TEX_FORMAT_RGB9E5_SHAREDEXP, 4, BindS, false, "RGB9E5_SHAREDEXP"},
- //{TEX_FORMAT_RG8_B8G8_UNORM, 4, BindSRU, false, "RG8_B8G8_UNORM"},
- //{TEX_FORMAT_G8R8_G8B8_UNORM, 4, BindSRU, false, "G8R8_G8B8_UNORM"},
-
- //{TEX_FORMAT_BC1_TYPELESS, 16, BindS, false, "BC1_TYPELESS"},
- {TEX_FORMAT_BC1_UNORM, 16, BindS, false, "BC1_UNORM"},
- {TEX_FORMAT_BC1_UNORM_SRGB, 16, BindS, false, "BC1_UNORM_SRGB"},
- //{TEX_FORMAT_BC2_TYPELESS, 16, BindS, false, "BC2_TYPELESS"},
- {TEX_FORMAT_BC2_UNORM, 16, BindS, false, "BC2_UNORM"},
- {TEX_FORMAT_BC2_UNORM_SRGB, 16, BindS, false, "BC2_UNORM_SRGB"},
- //{TEX_FORMAT_BC3_TYPELESS, 16, BindS, false, "BC3_TYPELESS"},
- {TEX_FORMAT_BC3_UNORM, 16, BindS, false, "BC3_UNORM"},
- {TEX_FORMAT_BC3_UNORM_SRGB, 16, BindS, false, "BC3_UNORM_SRGB"},
- //{TEX_FORMAT_BC4_TYPELESS, 16, BindS, false, "BC4_TYPELESS"},
- {TEX_FORMAT_BC4_UNORM, 16, BindS, false, "BC4_UNORM"},
- {TEX_FORMAT_BC4_SNORM, 16, BindS, false, "BC4_SNORM"},
- //{TEX_FORMAT_BC5_TYPELESS, 16, BindS, false, "BC5_TYPELESS"},
- {TEX_FORMAT_BC5_UNORM, 16, BindS, false, "BC5_UNORM"},
- {TEX_FORMAT_BC5_SNORM, 16, BindS, false, "BC5_SNORM"},
-
- //{TEX_FORMAT_B5G6R5_UNORM, 2, BindSRU, true, "B5G6R5_UNORM"},
- //{TEX_FORMAT_B5G5R5A1_UNORM, 2, BindSRU, true, "B5G5R5A1_UNORM"},
- //{TEX_FORMAT_BGRA8_UNORM, 4, BindSRU, true, "BGRA8_UNORM"},
- //{TEX_FORMAT_BGRX8_UNORM, 4, BindSRU, true, "BGRX8_UNORM"},
- //{TEX_FORMAT_R10G10B10_XR_BIAS_A2_UNORM, 4, BindS, false, "R10G10B10_XR_BIAS_A2_UNORM"},
-
- {TEX_FORMAT_BGRA8_TYPELESS, 4, BindSRU, true, "BGRA8_TYPELESS"},
- {TEX_FORMAT_BGRA8_UNORM_SRGB, 4, BindSR, true, "BGRA8_UNORM_SRGB",},
- //{TEX_FORMAT_BGRX8_TYPELESS, 4, BindSRU, true, "BGRX8_TYPELESS"},
- //{TEX_FORMAT_BGRX8_UNORM_SRGB, 4, BindSR, true, "BGRX8_UNORM_SRGB",},
-
- //{TEX_FORMAT_BC6H_TYPELESS, 16, BindS, false, "BC6H_TYPELESS"},
- {TEX_FORMAT_BC6H_UF16, 16, BindS, false, "BC6H_UF16"},
- {TEX_FORMAT_BC6H_SF16, 16, BindS, false, "BC6H_SF16"},
- //{TEX_FORMAT_BC7_TYPELESS, 16, BindS, false, "BC7_TYPELESS"},
- {TEX_FORMAT_BC7_UNORM, 16, BindS, false, "BC7_UNORM"},
- {TEX_FORMAT_BC7_UNORM_SRGB, 16, BindS, false, "BC7_UNORM_SRGB"},
- };
- for(int Test = 0; Test < _countof(TestAttribs); ++Test)
- {
- const auto &CurrAttrs = TestAttribs[Test];
- const auto PixelFormatAttribs = pDevice->GetTextureFormatInfoExt(CurrAttrs.Fmt);
- if( !PixelFormatAttribs.Supported )
- {
- LOG_WARNING_MESSAGE( "Texture format ", CurrAttrs.Name, " is not supported!\n" );
- continue;
- }
- ++m_NumFormatsTested;
- assert(CurrAttrs.PixelSize == Uint32{PixelFormatAttribs.ComponentSize} * Uint32{PixelFormatAttribs.NumComponents} ||
- PixelFormatAttribs.ComponentType == COMPONENT_TYPE_COMPRESSED);
- Verifier.Test(CurrAttrs.Fmt, CurrAttrs.PixelSize, CurrAttrs.BindFlags, CurrAttrs.TestDataUpload);
- }
- std::stringstream infoss;
- infoss << "Formats tested: " << m_NumFormatsTested;
- SetStatus(TestResult::Succeeded, infoss.str().c_str());
-}
-
-void TestTextureCreation::CheckFormatSize(TEXTURE_FORMAT *begin, TEXTURE_FORMAT *end, Uint32 RefSize)
-{
- for(auto fmt = begin; fmt != end; ++fmt)
- {
- auto FmtAttrs = m_pDevice->GetTextureFormatInfo(*fmt);
- assert(Uint32{FmtAttrs.ComponentSize} * Uint32{FmtAttrs.NumComponents} == RefSize); (void)FmtAttrs;
- }
-}
-
-void TestTextureCreation::CheckNumComponents(TEXTURE_FORMAT *begin, TEXTURE_FORMAT *end, Uint32 RefComponents)
-{
- for(auto fmt = begin; fmt != end; ++fmt)
- {
- auto FmtAttrs = m_pDevice->GetTextureFormatInfo(*fmt);
- assert(FmtAttrs.NumComponents == RefComponents); (void)FmtAttrs;
- }
-}
-
-void TestTextureCreation::CheckComponentType(TEXTURE_FORMAT *begin, TEXTURE_FORMAT *end, COMPONENT_TYPE RefType)
-{
- for(auto fmt = begin; fmt != end; ++fmt)
- {
- auto FmtAttrs = m_pDevice->GetTextureFormatInfo(*fmt);
- assert(FmtAttrs.ComponentType == RefType); (void)FmtAttrs;
- }
-}
-
-void TestTextureCreation::TestTextureFormatAttribs()
-{
- TEXTURE_FORMAT _16ByteFormats[] =
- {
- TEX_FORMAT_RGBA32_TYPELESS, TEX_FORMAT_RGBA32_FLOAT, TEX_FORMAT_RGBA32_UINT, TEX_FORMAT_RGBA32_SINT
- };
- CheckFormatSize(std::begin(_16ByteFormats), std::end(_16ByteFormats), 16);
-
- TEXTURE_FORMAT _12ByteFormats[] =
- {
- TEX_FORMAT_RGB32_TYPELESS, TEX_FORMAT_RGB32_FLOAT, TEX_FORMAT_RGB32_UINT, TEX_FORMAT_RGB32_SINT
- };
- CheckFormatSize(std::begin(_12ByteFormats), std::end(_12ByteFormats), 12);
-
- TEXTURE_FORMAT _8ByteFormats[] =
- {
- TEX_FORMAT_RGBA16_TYPELESS, TEX_FORMAT_RGBA16_FLOAT, TEX_FORMAT_RGBA16_UNORM, TEX_FORMAT_RGBA16_UINT, TEX_FORMAT_RGBA16_SNORM, TEX_FORMAT_RGBA16_SINT,
- TEX_FORMAT_RG32_TYPELESS, TEX_FORMAT_RG32_FLOAT, TEX_FORMAT_RG32_UINT, TEX_FORMAT_RG32_SINT,
- TEX_FORMAT_R32G8X24_TYPELESS, TEX_FORMAT_D32_FLOAT_S8X24_UINT, TEX_FORMAT_R32_FLOAT_X8X24_TYPELESS, TEX_FORMAT_X32_TYPELESS_G8X24_UINT
- };
- CheckFormatSize(std::begin(_8ByteFormats), std::end(_8ByteFormats), 8);
-
- TEXTURE_FORMAT _4ByteFormats[] =
- {
- TEX_FORMAT_RGB10A2_TYPELESS, TEX_FORMAT_RGB10A2_UNORM, TEX_FORMAT_RGB10A2_UINT, TEX_FORMAT_R11G11B10_FLOAT,
- TEX_FORMAT_RGBA8_TYPELESS, TEX_FORMAT_RGBA8_UNORM, TEX_FORMAT_RGBA8_UNORM_SRGB, TEX_FORMAT_RGBA8_UINT, TEX_FORMAT_RGBA8_SNORM, TEX_FORMAT_RGBA8_SINT,
- TEX_FORMAT_RG16_TYPELESS, TEX_FORMAT_RG16_FLOAT, TEX_FORMAT_RG16_UNORM, TEX_FORMAT_RG16_UINT, TEX_FORMAT_RG16_SNORM, TEX_FORMAT_RG16_SINT,
- TEX_FORMAT_R32_TYPELESS, TEX_FORMAT_D32_FLOAT, TEX_FORMAT_R32_FLOAT, TEX_FORMAT_R32_UINT, TEX_FORMAT_R32_SINT,
- TEX_FORMAT_R24G8_TYPELESS, TEX_FORMAT_D24_UNORM_S8_UINT, TEX_FORMAT_R24_UNORM_X8_TYPELESS, TEX_FORMAT_X24_TYPELESS_G8_UINT,
- TEX_FORMAT_RGB9E5_SHAREDEXP, TEX_FORMAT_RG8_B8G8_UNORM, TEX_FORMAT_G8R8_G8B8_UNORM,
- TEX_FORMAT_BGRA8_UNORM, TEX_FORMAT_BGRX8_UNORM, TEX_FORMAT_R10G10B10_XR_BIAS_A2_UNORM,
- TEX_FORMAT_BGRA8_TYPELESS, TEX_FORMAT_BGRA8_UNORM_SRGB, TEX_FORMAT_BGRX8_TYPELESS, TEX_FORMAT_BGRX8_UNORM_SRGB
- };
- CheckFormatSize(std::begin(_4ByteFormats), std::end(_4ByteFormats), 4);
-
- TEXTURE_FORMAT _2ByteFormats[] =
- {
- TEX_FORMAT_RG8_TYPELESS, TEX_FORMAT_RG8_UNORM, TEX_FORMAT_RG8_UINT, TEX_FORMAT_RG8_SNORM, TEX_FORMAT_RG8_SINT,
- TEX_FORMAT_R16_TYPELESS, TEX_FORMAT_R16_FLOAT, TEX_FORMAT_D16_UNORM, TEX_FORMAT_R16_UNORM, TEX_FORMAT_R16_UINT, TEX_FORMAT_R16_SNORM, TEX_FORMAT_R16_SINT,
- TEX_FORMAT_B5G6R5_UNORM, TEX_FORMAT_B5G5R5A1_UNORM
- };
- CheckFormatSize(std::begin(_2ByteFormats), std::end(_2ByteFormats), 2);
-
- TEXTURE_FORMAT _1ByteFormats[] =
- {
- TEX_FORMAT_R8_TYPELESS, TEX_FORMAT_R8_UNORM, TEX_FORMAT_R8_UINT, TEX_FORMAT_R8_SNORM, TEX_FORMAT_R8_SINT, TEX_FORMAT_A8_UNORM, //TEX_FORMAT_R1_UNORM
- };
- CheckFormatSize(std::begin(_1ByteFormats), std::end(_1ByteFormats), 1);
-
- TEXTURE_FORMAT _4ComponentFormats[] =
- {
- TEX_FORMAT_RGBA32_TYPELESS, TEX_FORMAT_RGBA32_FLOAT, TEX_FORMAT_RGBA32_UINT, TEX_FORMAT_RGBA32_SINT,
- TEX_FORMAT_RGBA16_TYPELESS, TEX_FORMAT_RGBA16_FLOAT, TEX_FORMAT_RGBA16_UNORM, TEX_FORMAT_RGBA16_UINT, TEX_FORMAT_RGBA16_SNORM, TEX_FORMAT_RGBA16_SINT,
- TEX_FORMAT_RGBA8_TYPELESS, TEX_FORMAT_RGBA8_UNORM, TEX_FORMAT_RGBA8_UNORM_SRGB, TEX_FORMAT_RGBA8_UINT, TEX_FORMAT_RGBA8_SNORM, TEX_FORMAT_RGBA8_SINT,
- TEX_FORMAT_RG8_B8G8_UNORM, TEX_FORMAT_G8R8_G8B8_UNORM,
- TEX_FORMAT_BGRA8_UNORM, TEX_FORMAT_BGRX8_UNORM, TEX_FORMAT_BGRA8_TYPELESS, TEX_FORMAT_BGRA8_UNORM_SRGB, TEX_FORMAT_BGRX8_TYPELESS, TEX_FORMAT_BGRX8_UNORM_SRGB
- };
- CheckNumComponents(std::begin(_4ComponentFormats), std::end(_4ComponentFormats), 4);
-
- TEXTURE_FORMAT _3ComponentFormats[] =
- {
- TEX_FORMAT_RGB32_TYPELESS, TEX_FORMAT_RGB32_FLOAT, TEX_FORMAT_RGB32_UINT, TEX_FORMAT_RGB32_SINT,
-
- };
- CheckNumComponents(std::begin(_3ComponentFormats), std::end(_3ComponentFormats), 3);
-
- TEXTURE_FORMAT _2ComponentFormats[] =
- {
- TEX_FORMAT_RG32_TYPELESS, TEX_FORMAT_RG32_FLOAT, TEX_FORMAT_RG32_UINT, TEX_FORMAT_RG32_SINT,
- TEX_FORMAT_R32G8X24_TYPELESS, TEX_FORMAT_D32_FLOAT_S8X24_UINT, TEX_FORMAT_R32_FLOAT_X8X24_TYPELESS, TEX_FORMAT_X32_TYPELESS_G8X24_UINT,
- TEX_FORMAT_RG16_TYPELESS, TEX_FORMAT_RG16_FLOAT, TEX_FORMAT_RG16_UNORM, TEX_FORMAT_RG16_UINT, TEX_FORMAT_RG16_SNORM, TEX_FORMAT_RG16_SINT,
- TEX_FORMAT_RG8_TYPELESS, TEX_FORMAT_RG8_UNORM, TEX_FORMAT_RG8_UINT, TEX_FORMAT_RG8_SNORM, TEX_FORMAT_RG8_SINT
- };
- CheckNumComponents(std::begin(_2ComponentFormats), std::end(_2ComponentFormats), 2);
-
- TEXTURE_FORMAT _1ComponentFormats[] =
- {
- TEX_FORMAT_RGB10A2_TYPELESS, TEX_FORMAT_RGB10A2_UNORM, TEX_FORMAT_RGB10A2_UINT, TEX_FORMAT_R11G11B10_FLOAT,
- TEX_FORMAT_R32_TYPELESS, TEX_FORMAT_D32_FLOAT, TEX_FORMAT_R32_FLOAT, TEX_FORMAT_R32_UINT, TEX_FORMAT_R32_SINT,
- TEX_FORMAT_R24G8_TYPELESS, TEX_FORMAT_D24_UNORM_S8_UINT, TEX_FORMAT_R24_UNORM_X8_TYPELESS, TEX_FORMAT_X24_TYPELESS_G8_UINT,
- TEX_FORMAT_R16_TYPELESS, TEX_FORMAT_R16_FLOAT, TEX_FORMAT_D16_UNORM, TEX_FORMAT_R16_UNORM, TEX_FORMAT_R16_UINT, TEX_FORMAT_R16_SNORM, TEX_FORMAT_R16_SINT,
- TEX_FORMAT_R8_TYPELESS, TEX_FORMAT_R8_UNORM, TEX_FORMAT_R8_UINT, TEX_FORMAT_R8_SNORM, TEX_FORMAT_R8_SINT, TEX_FORMAT_A8_UNORM, //TEX_FORMAT_R1_UNORM
- TEX_FORMAT_RGB9E5_SHAREDEXP,
- TEX_FORMAT_R10G10B10_XR_BIAS_A2_UNORM, TEX_FORMAT_B5G6R5_UNORM, TEX_FORMAT_B5G5R5A1_UNORM
- };
- CheckNumComponents(std::begin(_1ComponentFormats), std::end(_1ComponentFormats), 1);
-
-
- TEXTURE_FORMAT FloatFormats[] =
- {
- TEX_FORMAT_RGBA32_FLOAT,
- TEX_FORMAT_RGB32_FLOAT,
- TEX_FORMAT_RGBA16_FLOAT,
- TEX_FORMAT_RG32_FLOAT,
- TEX_FORMAT_RG16_FLOAT,
- TEX_FORMAT_R32_FLOAT,
- TEX_FORMAT_R16_FLOAT
- };
- CheckComponentType(std::begin(FloatFormats), std::end(FloatFormats), COMPONENT_TYPE_FLOAT);
-
- TEXTURE_FORMAT SintFormats[] =
- {
- TEX_FORMAT_RGBA32_SINT,
- TEX_FORMAT_RGB32_SINT,
- TEX_FORMAT_RGBA16_SINT,
- TEX_FORMAT_RG32_SINT,
- TEX_FORMAT_RGBA8_SINT,
- TEX_FORMAT_RG16_SINT,
- TEX_FORMAT_R32_SINT,
- TEX_FORMAT_RG8_SINT,
- TEX_FORMAT_R16_SINT,
- TEX_FORMAT_R8_SINT
- };
- CheckComponentType(std::begin(SintFormats), std::end(SintFormats), COMPONENT_TYPE_SINT);
-
- TEXTURE_FORMAT UintFormats[] =
- {
- TEX_FORMAT_RGBA32_UINT,
- TEX_FORMAT_RGB32_UINT,
- TEX_FORMAT_RGBA16_UINT,
- TEX_FORMAT_RG32_UINT,
- TEX_FORMAT_RGBA8_UINT,
- TEX_FORMAT_RG16_UINT,
- TEX_FORMAT_R32_UINT,
- TEX_FORMAT_RG8_UINT,
- TEX_FORMAT_R16_UINT,
- TEX_FORMAT_R8_UINT
- };
- CheckComponentType(std::begin(UintFormats), std::end(UintFormats), COMPONENT_TYPE_UINT);
-
- TEXTURE_FORMAT UnormFormats[] =
- {
- TEX_FORMAT_RGBA16_UNORM,
- TEX_FORMAT_RGBA8_UNORM,
- TEX_FORMAT_RG16_UNORM,
- TEX_FORMAT_RG8_UNORM,
- TEX_FORMAT_R16_UNORM,
- TEX_FORMAT_R8_UNORM,
- TEX_FORMAT_A8_UNORM,
- TEX_FORMAT_R1_UNORM,
- TEX_FORMAT_RG8_B8G8_UNORM,
- TEX_FORMAT_G8R8_G8B8_UNORM,
- TEX_FORMAT_BGRA8_UNORM,
- TEX_FORMAT_BGRX8_UNORM
- };
- CheckComponentType(std::begin(UnormFormats), std::end(UnormFormats), COMPONENT_TYPE_UNORM);
-
- TEXTURE_FORMAT UnormSRGBFormats[] =
- {
- TEX_FORMAT_RGBA8_UNORM_SRGB,
- TEX_FORMAT_BGRA8_UNORM_SRGB,
- TEX_FORMAT_BGRX8_UNORM_SRGB
- };
- CheckComponentType(std::begin(UnormSRGBFormats), std::end(UnormSRGBFormats), COMPONENT_TYPE_UNORM_SRGB);
-
- TEXTURE_FORMAT SnormFormats[] =
- {
- TEX_FORMAT_RGBA16_SNORM,
- TEX_FORMAT_RGBA8_SNORM,
- TEX_FORMAT_RG16_SNORM,
- TEX_FORMAT_RG8_SNORM,
- TEX_FORMAT_R16_SNORM,
- TEX_FORMAT_R8_SNORM
- };
- CheckComponentType(std::begin(SnormFormats), std::end(SnormFormats), COMPONENT_TYPE_SNORM);
-
- TEXTURE_FORMAT UndefinedFormats[] =
- {
- TEX_FORMAT_RGBA32_TYPELESS,
- TEX_FORMAT_RGB32_TYPELESS,
- TEX_FORMAT_RGBA16_TYPELESS,
- TEX_FORMAT_RG32_TYPELESS,
- TEX_FORMAT_RGBA8_TYPELESS,
- TEX_FORMAT_RG16_TYPELESS,
- TEX_FORMAT_R32_TYPELESS,
- TEX_FORMAT_RG8_TYPELESS,
- TEX_FORMAT_R16_TYPELESS,
- TEX_FORMAT_R8_TYPELESS,
- TEX_FORMAT_BGRA8_TYPELESS,
- TEX_FORMAT_BGRX8_TYPELESS
- };
- CheckComponentType(std::begin(UndefinedFormats), std::end(UndefinedFormats), COMPONENT_TYPE_UNDEFINED);
-
- TEXTURE_FORMAT DepthFormats[] =
- {
- TEX_FORMAT_D32_FLOAT,
- TEX_FORMAT_D16_UNORM
- };
- CheckComponentType(std::begin(DepthFormats), std::end(DepthFormats), COMPONENT_TYPE_DEPTH);
-
- TEXTURE_FORMAT DepthStencilFormats[] =
- {
- TEX_FORMAT_R32G8X24_TYPELESS,
- TEX_FORMAT_D32_FLOAT_S8X24_UINT,
- TEX_FORMAT_R32_FLOAT_X8X24_TYPELESS,
- TEX_FORMAT_X32_TYPELESS_G8X24_UINT,
- TEX_FORMAT_R24G8_TYPELESS,
- TEX_FORMAT_D24_UNORM_S8_UINT,
- TEX_FORMAT_R24_UNORM_X8_TYPELESS,
- TEX_FORMAT_X24_TYPELESS_G8_UINT
- };
- CheckComponentType(std::begin(DepthStencilFormats), std::end(DepthStencilFormats), COMPONENT_TYPE_DEPTH_STENCIL);
-
- TEXTURE_FORMAT CompoundFormats[] =
- {
- TEX_FORMAT_RGB10A2_TYPELESS,
- TEX_FORMAT_RGB10A2_UNORM,
- TEX_FORMAT_RGB10A2_UINT,
- TEX_FORMAT_RGB9E5_SHAREDEXP,
- TEX_FORMAT_R11G11B10_FLOAT,
- TEX_FORMAT_R10G10B10_XR_BIAS_A2_UNORM,
- TEX_FORMAT_B5G6R5_UNORM,
- TEX_FORMAT_B5G5R5A1_UNORM
- };
- CheckComponentType(std::begin(CompoundFormats), std::end(CompoundFormats), COMPONENT_TYPE_COMPOUND);
-
-
- TEXTURE_FORMAT CompressedFormats[] =
- {
- TEX_FORMAT_BC1_TYPELESS, TEX_FORMAT_BC1_UNORM, TEX_FORMAT_BC1_UNORM_SRGB,
- TEX_FORMAT_BC2_TYPELESS, TEX_FORMAT_BC2_UNORM, TEX_FORMAT_BC2_UNORM_SRGB,
- TEX_FORMAT_BC3_TYPELESS, TEX_FORMAT_BC3_UNORM, TEX_FORMAT_BC3_UNORM_SRGB,
- TEX_FORMAT_BC4_TYPELESS, TEX_FORMAT_BC4_UNORM, TEX_FORMAT_BC4_SNORM,
- TEX_FORMAT_BC5_TYPELESS, TEX_FORMAT_BC5_UNORM, TEX_FORMAT_BC5_SNORM,
- TEX_FORMAT_BC6H_TYPELESS, TEX_FORMAT_BC6H_UF16, TEX_FORMAT_BC6H_SF16,
- TEX_FORMAT_BC7_TYPELESS, TEX_FORMAT_BC7_UNORM, TEX_FORMAT_BC7_UNORM_SRGB
- };
- CheckComponentType(std::begin(CompressedFormats), std::end(CompressedFormats), COMPONENT_TYPE_COMPRESSED);
-}
diff --git a/Tests/TestApp/src/TestTexturing.cpp b/Tests/TestApp/src/TestTexturing.cpp
index df6adce..2c1d0a1 100644
--- a/Tests/TestApp/src/TestTexturing.cpp
+++ b/Tests/TestApp/src/TestTexturing.cpp
@@ -21,9 +21,6 @@
* of the possibility of such damages.
*/
-// EngineSandbox.cpp : Defines the entry point for the application.
-//
-
#include "pch.h"
#include <math.h>
#include "TestTexturing.h"
diff --git a/Tests/TestApp/src/TestVPAndSR.cpp b/Tests/TestApp/src/TestVPAndSR.cpp
index 8014b0b..8eac85f 100644
--- a/Tests/TestApp/src/TestVPAndSR.cpp
+++ b/Tests/TestApp/src/TestVPAndSR.cpp
@@ -21,9 +21,6 @@
* of the possibility of such damages.
*/
-// EngineSandbox.cpp : Defines the entry point for the application.
-//
-
#include "pch.h"
#include "TestVPAndSR.h"
#include "GraphicsUtilities.h"
diff --git a/Tests/TestApp/src/UnitTestBase.cpp b/Tests/TestApp/src/UnitTestBase.cpp
index 069aa10..5421c7a 100644
--- a/Tests/TestApp/src/UnitTestBase.cpp
+++ b/Tests/TestApp/src/UnitTestBase.cpp
@@ -21,9 +21,6 @@
* of the possibility of such damages.
*/
-// EngineSandbox.cpp : Defines the entry point for the application.
-//
-
#include <iomanip>
#include <ios>
diff --git a/Tests/TestApp/src/VarSizeAllocationsManagerTest.cpp b/Tests/TestApp/src/VarSizeAllocationsManagerTest.cpp
deleted file mode 100644
index 9d90ce4..0000000
--- a/Tests/TestApp/src/VarSizeAllocationsManagerTest.cpp
+++ /dev/null
@@ -1,183 +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.
- */
-
-// EngineSandbox.cpp : Defines the entry point for the application.
-//
-
-#include "pch.h"
-#include "VariableSizeGPUAllocationsManager.h"
-#include "DefaultRawMemoryAllocator.h"
-#include "DebugUtilities.h"
-#include "UnitTestBase.h"
-
-using namespace Diligent;
-
-class VariableSizeAllocationsManagerTest : public UnitTestBase
-{
-public:
- VariableSizeAllocationsManagerTest();
-};
-
-static VariableSizeAllocationsManagerTest TheVariableSizeAllocationsManagerTest;
-
-VariableSizeAllocationsManagerTest::VariableSizeAllocationsManagerTest() :
- UnitTestBase("Variable size allocation manager test")
-{
- auto &Allocator = DefaultRawMemoryAllocator::GetAllocator();
-
- {
- VariableSizeAllocationsManager ListMgr(128, Allocator);
- VERIFY_EXPR(ListMgr.DbgGetNumFreeBlocks() == 1);
-
- auto a1 = ListMgr.Allocate(17, 4);
- VERIFY_EXPR(a1.UnalignedOffset == 0 && a1.Size == 20);
- VERIFY_EXPR(ListMgr.DbgGetNumFreeBlocks() == 1);
-
- auto a2 = ListMgr.Allocate(17, 8);
- VERIFY_EXPR(a2.UnalignedOffset == 20 && a2.Size == 28);
-
- auto a3 = ListMgr.Allocate(8, 1);
- VERIFY_EXPR(a3.UnalignedOffset == 48 && a3.Size == 8);
-
- auto a4 = ListMgr.Allocate(11, 8);
- VERIFY_EXPR(a4.UnalignedOffset == 56 && a4.Size == 16);
-
- auto a5 = ListMgr.Allocate(64, 1);
- VERIFY_EXPR(!a5.IsValid() && a5.Size == 0);
-
- a5 = ListMgr.Allocate(16, 1);
- VERIFY_EXPR(a5.UnalignedOffset == 72 && a5.Size == 16);
-
- auto a6 = ListMgr.Allocate(8, 1);
- VERIFY_EXPR(a6.UnalignedOffset == 88 && a6.Size == 8);
-
- auto a7 = ListMgr.Allocate(16, 1);
- VERIFY_EXPR(a7.UnalignedOffset == 96 && a7.Size == 16);
-
- auto a8 = ListMgr.Allocate(8, 1);
- VERIFY_EXPR(a8.UnalignedOffset == 112 && a8.Size == 8);
- VERIFY_EXPR(ListMgr.DbgGetNumFreeBlocks() == 1);
-
- auto a9 = ListMgr.Allocate(8, 1);
- VERIFY_EXPR(a9.UnalignedOffset == 120 && a9.Size == 8);
- VERIFY_EXPR(ListMgr.DbgGetNumFreeBlocks() == 0);
-
- VERIFY_EXPR(ListMgr.IsFull());
-
- ListMgr.Free(std::move(a6));
- VERIFY_EXPR(ListMgr.DbgGetNumFreeBlocks() == 1);
-
- ListMgr.Free(a8.UnalignedOffset, a8.Size);
- VERIFY_EXPR(ListMgr.DbgGetNumFreeBlocks() == 2);
-
- ListMgr.Free(std::move(a9));
- VERIFY_EXPR(ListMgr.DbgGetNumFreeBlocks() == 2);
-
- auto a10 = ListMgr.Allocate(16, 1);
- VERIFY_EXPR(a10.UnalignedOffset == 112 && a10.Size == 16);
- VERIFY_EXPR(ListMgr.DbgGetNumFreeBlocks() == 1);
-
- ListMgr.Free(a10.UnalignedOffset, a10.Size);
- VERIFY_EXPR(ListMgr.DbgGetNumFreeBlocks() == 2);
-
- ListMgr.Free(std::move(a7));
- VERIFY_EXPR(ListMgr.DbgGetNumFreeBlocks() == 1);
-
- ListMgr.Free(std::move(a4));
- VERIFY_EXPR(ListMgr.DbgGetNumFreeBlocks() == 2);
-
- ListMgr.Free(a2.UnalignedOffset, a2.Size);
- VERIFY_EXPR(ListMgr.DbgGetNumFreeBlocks() == 3);
-
- ListMgr.Free(std::move(a1));
- VERIFY_EXPR(ListMgr.DbgGetNumFreeBlocks() == 3);
-
- ListMgr.Free(std::move(a3));
- VERIFY_EXPR(ListMgr.DbgGetNumFreeBlocks() == 2);
-
- ListMgr.Free(std::move(a5));
- VERIFY_EXPR(ListMgr.DbgGetNumFreeBlocks() == 1);
-
- VERIFY_EXPR(ListMgr.IsEmpty());
- }
-
- {
- const auto NumAllocs = 6;
- int NumPerms = 0;
- size_t ReleaseOrder[NumAllocs];
- for(size_t a=0; a < NumAllocs; ++a)
- ReleaseOrder[a] = a;
- do
- {
- ++NumPerms;
- VariableSizeAllocationsManager ListMgr(NumAllocs*4, Allocator);
- VariableSizeAllocationsManager::Allocation allocs[NumAllocs];
- for(size_t a=0; a < NumAllocs; ++a)
- {
- allocs[a] = ListMgr.Allocate(4, 1);
- VERIFY_EXPR(allocs[a].UnalignedOffset == a*4 && allocs[a].Size == 4);
- }
- for(size_t a=0; a < NumAllocs; ++a)
- {
- ListMgr.Free(std::move(allocs[ReleaseOrder[a]]));
- }
- } while(std::next_permutation(std::begin(ReleaseOrder), std::end(ReleaseOrder)));
- VERIFY_EXPR(NumPerms == 720);
- }
-
- {
- VariableSizeGPUAllocationsManager ListMgr(128, Allocator);
- VariableSizeGPUAllocationsManager::Allocation al[16];
- for(size_t o=0; o < _countof(al); ++o)
- al[o] = ListMgr.Allocate(8, 4);
- VERIFY_EXPR(ListMgr.IsFull());
-
- ListMgr.Free(std::move(al[1]), 0);
- ListMgr.Free(std::move(al[5]), 0);
- ListMgr.Free(std::move(al[4]), 0);
- ListMgr.Free(std::move(al[3]), 0);
-
- ListMgr.Free(al[10].UnalignedOffset, al[10].Size, 1);
- ListMgr.Free(al[13].UnalignedOffset, al[13].Size, 1);
- ListMgr.Free(al[2].UnalignedOffset, al[2].Size, 1);
- ListMgr.Free(al[8].UnalignedOffset, al[8].Size, 1);
-
- ListMgr.ReleaseStaleAllocations(1);
-
- ListMgr.Free(std::move(al[14]), 2);
- ListMgr.Free(std::move(al[7]), 2);
- ListMgr.Free(std::move(al[0]), 2);
- ListMgr.Free(std::move(al[9]), 2);
-
- ListMgr.ReleaseStaleAllocations(2);
-
- ListMgr.Free(std::move(al[12]), 1);
- ListMgr.Free(std::move(al[15]), 1);
- ListMgr.Free(std::move(al[6]), 1);
- ListMgr.Free(std::move(al[11]), 1);
-
- ListMgr.ReleaseStaleAllocations(3);
- }
-
- SetStatus(TestResult::Succeeded);
-}