From 16247fb8792f4ac938825361ea6bfdd484b2e5a8 Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Thu, 11 Apr 2019 20:07:24 -0700 Subject: Added mip generation tests; updated submodules --- DiligentCore | 2 +- DiligentFX | 2 +- DiligentSamples | 2 +- Tests/TestApp/include/TestMipMapsGeneration.h | 32 ++++++++++ Tests/TestApp/src/TestApp.cpp | 2 + Tests/TestApp/src/TestMipMapsGeneration.cpp | 91 +++++++++++++++++++++++++++ 6 files changed, 128 insertions(+), 3 deletions(-) create mode 100644 Tests/TestApp/include/TestMipMapsGeneration.h create mode 100644 Tests/TestApp/src/TestMipMapsGeneration.cpp diff --git a/DiligentCore b/DiligentCore index 3c506af..f6f030d 160000 --- a/DiligentCore +++ b/DiligentCore @@ -1 +1 @@ -Subproject commit 3c506af939ed15ebcebdbbefb42231b8b153f946 +Subproject commit f6f030dbdc1b8cd636f1e340e506ae776b57999c diff --git a/DiligentFX b/DiligentFX index c895d75..fa24949 160000 --- a/DiligentFX +++ b/DiligentFX @@ -1 +1 @@ -Subproject commit c895d7548d7cda8f58a53812f513103e25c4d57e +Subproject commit fa2494936c032b7221b8264b240c9305596bb442 diff --git a/DiligentSamples b/DiligentSamples index dd12d12..a1c4f6f 160000 --- a/DiligentSamples +++ b/DiligentSamples @@ -1 +1 @@ -Subproject commit dd12d123dbc2a56c87c64a238b4b45af9b78d1b4 +Subproject commit a1c4f6f4d47509604784f7ca0854b75c0aad8a81 diff --git a/Tests/TestApp/include/TestMipMapsGeneration.h b/Tests/TestApp/include/TestMipMapsGeneration.h new file mode 100644 index 0000000..c9e9e19 --- /dev/null +++ b/Tests/TestApp/include/TestMipMapsGeneration.h @@ -0,0 +1,32 @@ +/* Copyright 2015-2019 Egor Yusov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent acts) or agreed to in writing, shall any Contributor be + * liable for any damages, including any direct, indirect, special, incidental, + * or consequential damages of any character arising as a result of this License or + * out of the use or inability to use the software (including but not limited to damages + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#pragma once + +#include "UnitTestBase.h" + +class TestMipMapsGeneration : public UnitTestBase +{ +public: + TestMipMapsGeneration(Diligent::IRenderDevice *pDevice, Diligent::IDeviceContext *pContext); +}; diff --git a/Tests/TestApp/src/TestApp.cpp b/Tests/TestApp/src/TestApp.cpp index a252e8d..514519c 100644 --- a/Tests/TestApp/src/TestApp.cpp +++ b/Tests/TestApp/src/TestApp.cpp @@ -65,6 +65,7 @@ #include "ShaderConverterTest.h" #endif #include "TestCopyTexData.h" +#include "TestMipMapsGeneration.h" #include "PlatformMisc.h" #include "TestBufferCreation.h" #include "TestBrokenShader.h" @@ -416,6 +417,7 @@ void TestApp::InitializeRenderers() } TestCopyTexData TestCopyData(m_pDevice, m_pImmediateContext); + TestMipMapsGeneration TestMipsGen(m_pDevice, m_pImmediateContext); TestVPAndSR TestVPAndSR(m_pDevice, m_pImmediateContext); diff --git a/Tests/TestApp/src/TestMipMapsGeneration.cpp b/Tests/TestApp/src/TestMipMapsGeneration.cpp new file mode 100644 index 0000000..d2a80d4 --- /dev/null +++ b/Tests/TestApp/src/TestMipMapsGeneration.cpp @@ -0,0 +1,91 @@ +/* Copyright 2015-2019 Egor Yusov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent acts) or agreed to in writing, shall any Contributor be + * liable for any damages, including any direct, indirect, special, incidental, + * or consequential damages of any character arising as a result of this License or + * out of the use or inability to use the software (including but not limited to damages + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "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; + TexDesc.Height = 128; + TexDesc.BindFlags = BIND_SHADER_RESOURCE; + TexDesc.MipLevels = 6; + TexDesc.Usage = USAGE_DEFAULT; + TexDesc.MiscFlags = MISC_TEXTURE_FLAG_GENERATE_MIPS; + + { + RefCntAutoPtr pTex; + pDevice->CreateTexture(TexDesc, nullptr, &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 pTexView; + pTex->CreateView(ViewDesc, &pTexView); + pContext->GenerateMips(pTexView); + } + + TexDesc.Type = RESOURCE_DIM_TEX_2D_ARRAY; + TexDesc.ArraySize = 16; + { + RefCntAutoPtr 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 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()); +} -- cgit v1.2.3