Skip to content

Commit ce3bad8

Browse files
Integrated tests
1 parent aa0d5d2 commit ce3bad8

5 files changed

Lines changed: 642 additions & 1 deletion

File tree

Tests/DiligentCoreAPITest/src/CInterfaceTest.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ extern "C"
3939
int TestRenderDeviceCInterface_CreateResourceMapping(void* pRenderDevice);
4040
int TestRenderDeviceCInterface_CreateFence(void* pRenderDevice);
4141
int TestRenderDeviceCInterface_CreateQuery(void* pRenderDevice);
42+
int TestRenderDeviceCInterface_CreateSuperResolutionUpscaler(void* pRenderDevice);
4243
}
4344

4445
using namespace Diligent;
@@ -53,7 +54,6 @@ TEST(RenderDevice_CInterface, Misc)
5354
EXPECT_EQ(TestRenderDeviceCInterface_Misc(pDevice), 0);
5455
}
5556

56-
5757
TEST(RenderDevice_CInterface, CreateBuffer)
5858
{
5959
auto* pDevice = GPUTestingEnvironment::GetInstance()->GetDevice();
@@ -96,4 +96,10 @@ TEST(RenderDevice_CInterface, CreateQuery)
9696
EXPECT_EQ(TestRenderDeviceCInterface_CreateQuery(pDevice), 0);
9797
}
9898

99+
TEST(RenderDevice_CInterface, CreateSuperResolutionUpscaler)
100+
{
101+
auto* pDevice = GPUTestingEnvironment::GetInstance()->GetDevice();
102+
EXPECT_EQ(TestRenderDeviceCInterface_CreateSuperResolutionUpscaler(pDevice), 0);
103+
}
104+
99105
} // namespace
Lines changed: 340 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,340 @@
1+
/*
2+
* Copyright 2026 Diligent Graphics LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
* In no event and under no legal theory, whether in tort (including negligence),
17+
* contract, or otherwise, unless required by applicable law (such as deliberate
18+
* and grossly negligent acts) or agreed to in writing, shall any Contributor be
19+
* liable for any damages, including any direct, indirect, special, incidental,
20+
* or consequential damages of any character arising as a result of this License or
21+
* out of the use or inability to use the software (including but not limited to damages
22+
* for loss of goodwill, work stoppage, computer failure or malfunction, or any and
23+
* all other commercial damages or losses), even if such Contributor has been advised
24+
* of the possibility of such damages.
25+
*/
26+
27+
#include "GPUTestingEnvironment.hpp"
28+
#include "GraphicsAccessories.hpp"
29+
30+
#include "gtest/gtest.h"
31+
32+
using namespace Diligent;
33+
using namespace Diligent::Testing;
34+
35+
namespace
36+
{
37+
38+
TEST(SuperResolutionTest, CheckProperties)
39+
{
40+
auto* pEnv = GPUTestingEnvironment::GetInstance();
41+
auto* pDevice = pEnv->GetDevice();
42+
if (!pDevice->GetDeviceInfo().Features.SuperResolution)
43+
{
44+
GTEST_SKIP() << "Super resolution is not supported by this device";
45+
}
46+
47+
const auto& SRProps = pDevice->GetAdapterInfo().SuperResolution;
48+
EXPECT_NE(SRProps.Flags, SUPER_RESOLUTION_FLAG_NONE);
49+
}
50+
51+
TEST(SuperResolutionTest, CreateSpatialUpscaler)
52+
{
53+
auto* pEnv = GPUTestingEnvironment::GetInstance();
54+
auto* pDevice = pEnv->GetDevice();
55+
if (!pDevice->GetDeviceInfo().Features.SuperResolution)
56+
{
57+
GTEST_SKIP() << "Super resolution is not supported by this device";
58+
}
59+
60+
const auto& SRProps = pDevice->GetAdapterInfo().SuperResolution;
61+
if (!(SRProps.Flags & SUPER_RESOLUTION_FLAG_SPATIAL))
62+
{
63+
GTEST_SKIP() << "Spatial super resolution is not supported by this device";
64+
}
65+
66+
GPUTestingEnvironment::ScopedReset EnvironmentAutoReset;
67+
68+
SuperResolutionUpscalerDesc Desc;
69+
Desc.Name = "Test Spatial Upscaler";
70+
Desc.Type = SUPER_RESOLUTION_UPSCALER_TYPE_SPATIAL;
71+
Desc.OutputWidth = 1920;
72+
Desc.OutputHeight = 1080;
73+
Desc.OutputFormat = TEX_FORMAT_RGBA16_FLOAT;
74+
Desc.ColorFormat = TEX_FORMAT_RGBA16_FLOAT;
75+
76+
RefCntAutoPtr<ISuperResolutionUpscaler> pUpscaler;
77+
pDevice->CreateSuperResolutionUpscaler(Desc, &pUpscaler);
78+
ASSERT_NE(pUpscaler, nullptr) << "Failed to create spatial super resolution upscaler";
79+
80+
const auto& RetDesc = pUpscaler->GetDesc();
81+
EXPECT_EQ(RetDesc.Type, SUPER_RESOLUTION_UPSCALER_TYPE_SPATIAL);
82+
EXPECT_EQ(RetDesc.OutputWidth, 1920u);
83+
EXPECT_EQ(RetDesc.OutputHeight, 1080u);
84+
85+
Uint32 RenderWidth = 0;
86+
Uint32 RenderHeight = 0;
87+
pUpscaler->GetRenderResolution(&RenderWidth, &RenderHeight);
88+
EXPECT_GT(RenderWidth, 0u);
89+
EXPECT_GT(RenderHeight, 0u);
90+
EXPECT_LE(RenderWidth, 1920u);
91+
EXPECT_LE(RenderHeight, 1080u);
92+
}
93+
94+
TEST(SuperResolutionTest, CreateTemporalUpscaler)
95+
{
96+
auto* pEnv = GPUTestingEnvironment::GetInstance();
97+
auto* pDevice = pEnv->GetDevice();
98+
if (!pDevice->GetDeviceInfo().Features.SuperResolution)
99+
{
100+
GTEST_SKIP() << "Super resolution is not supported by this device";
101+
}
102+
103+
const auto& SRProps = pDevice->GetAdapterInfo().SuperResolution;
104+
if (!(SRProps.Flags & SUPER_RESOLUTION_FLAG_TEMPORAL))
105+
{
106+
GTEST_SKIP() << "Temporal super resolution is not supported by this device";
107+
}
108+
109+
GPUTestingEnvironment::ScopedReset EnvironmentAutoReset;
110+
111+
SuperResolutionUpscalerDesc Desc;
112+
Desc.Name = "Test Temporal Upscaler";
113+
Desc.Type = SUPER_RESOLUTION_UPSCALER_TYPE_TEMPORAL;
114+
Desc.OutputWidth = 1920;
115+
Desc.OutputHeight = 1080;
116+
Desc.OutputFormat = TEX_FORMAT_RGBA16_FLOAT;
117+
Desc.ColorFormat = TEX_FORMAT_RGBA16_FLOAT;
118+
Desc.DepthFormat = TEX_FORMAT_D32_FLOAT;
119+
Desc.MotionFormat = TEX_FORMAT_RG16_FLOAT;
120+
121+
RefCntAutoPtr<ISuperResolutionUpscaler> pUpscaler;
122+
pDevice->CreateSuperResolutionUpscaler(Desc, &pUpscaler);
123+
ASSERT_NE(pUpscaler, nullptr) << "Failed to create temporal super resolution upscaler";
124+
125+
const auto& RetDesc = pUpscaler->GetDesc();
126+
EXPECT_EQ(RetDesc.Type, SUPER_RESOLUTION_UPSCALER_TYPE_TEMPORAL);
127+
EXPECT_EQ(RetDesc.OutputWidth, 1920u);
128+
EXPECT_EQ(RetDesc.OutputHeight, 1080u);
129+
130+
Uint32 RenderWidth = 0;
131+
Uint32 RenderHeight = 0;
132+
pUpscaler->GetRenderResolution(&RenderWidth, &RenderHeight);
133+
EXPECT_GT(RenderWidth, 0u);
134+
EXPECT_GT(RenderHeight, 0u);
135+
EXPECT_LE(RenderWidth, 1920u);
136+
EXPECT_LE(RenderHeight, 1080u);
137+
}
138+
139+
TEST(SuperResolutionTest, ExecuteSpatialUpscaler)
140+
{
141+
auto* pEnv = GPUTestingEnvironment::GetInstance();
142+
auto* pDevice = pEnv->GetDevice();
143+
if (!pDevice->GetDeviceInfo().Features.SuperResolution)
144+
{
145+
GTEST_SKIP() << "Super resolution is not supported by this device";
146+
}
147+
148+
const auto& SRProps = pDevice->GetAdapterInfo().SuperResolution;
149+
if (!(SRProps.Flags & SUPER_RESOLUTION_FLAG_SPATIAL))
150+
{
151+
GTEST_SKIP() << "Spatial super resolution is not supported by this device";
152+
}
153+
154+
GPUTestingEnvironment::ScopedReset EnvironmentAutoReset;
155+
156+
constexpr Uint32 OutputWidth = 256;
157+
constexpr Uint32 OutputHeight = 256;
158+
159+
// Create upscaler
160+
SuperResolutionUpscalerDesc UpscalerDesc;
161+
UpscalerDesc.Name = "Test Spatial Execute Upscaler";
162+
UpscalerDesc.Type = SUPER_RESOLUTION_UPSCALER_TYPE_SPATIAL;
163+
UpscalerDesc.OutputWidth = OutputWidth;
164+
UpscalerDesc.OutputHeight = OutputHeight;
165+
UpscalerDesc.OutputFormat = TEX_FORMAT_RGBA16_FLOAT;
166+
UpscalerDesc.ColorFormat = TEX_FORMAT_RGBA16_FLOAT;
167+
168+
RefCntAutoPtr<ISuperResolutionUpscaler> pUpscaler;
169+
pDevice->CreateSuperResolutionUpscaler(UpscalerDesc, &pUpscaler);
170+
ASSERT_NE(pUpscaler, nullptr);
171+
172+
Uint32 RenderWidth = 0;
173+
Uint32 RenderHeight = 0;
174+
pUpscaler->GetRenderResolution(&RenderWidth, &RenderHeight);
175+
ASSERT_GT(RenderWidth, 0u);
176+
ASSERT_GT(RenderHeight, 0u);
177+
178+
// Create input color texture
179+
TextureDesc ColorTexDesc;
180+
ColorTexDesc.Name = "SR Color Input";
181+
ColorTexDesc.Type = RESOURCE_DIM_TEX_2D;
182+
ColorTexDesc.Width = RenderWidth;
183+
ColorTexDesc.Height = RenderHeight;
184+
ColorTexDesc.Format = TEX_FORMAT_RGBA16_FLOAT;
185+
ColorTexDesc.BindFlags = BIND_SHADER_RESOURCE | BIND_RENDER_TARGET;
186+
ColorTexDesc.Usage = USAGE_DEFAULT;
187+
188+
RefCntAutoPtr<ITexture> pColorTex;
189+
pDevice->CreateTexture(ColorTexDesc, nullptr, &pColorTex);
190+
ASSERT_NE(pColorTex, nullptr);
191+
192+
// Create output texture
193+
TextureDesc OutputTexDesc;
194+
OutputTexDesc.Name = "SR Output";
195+
OutputTexDesc.Type = RESOURCE_DIM_TEX_2D;
196+
OutputTexDesc.Width = OutputWidth;
197+
OutputTexDesc.Height = OutputHeight;
198+
OutputTexDesc.Format = TEX_FORMAT_RGBA16_FLOAT;
199+
OutputTexDesc.BindFlags = BIND_RENDER_TARGET | BIND_UNORDERED_ACCESS;
200+
OutputTexDesc.Usage = USAGE_DEFAULT;
201+
202+
RefCntAutoPtr<ITexture> pOutputTex;
203+
pDevice->CreateTexture(OutputTexDesc, nullptr, &pOutputTex);
204+
ASSERT_NE(pOutputTex, nullptr);
205+
206+
// Execute spatial upscaling
207+
auto* pContext = pEnv->GetDeviceContext();
208+
209+
ExecuteSuperResolutionAttribs Attribs;
210+
Attribs.pColorTextureSRV = pColorTex->GetDefaultView(TEXTURE_VIEW_SHADER_RESOURCE);
211+
Attribs.pOutputTextureRTV = pOutputTex->GetDefaultView(TEXTURE_VIEW_RENDER_TARGET);
212+
213+
pContext->ExecuteSuperResolution(Attribs, pUpscaler);
214+
pContext->Flush();
215+
pContext->WaitForIdle();
216+
}
217+
218+
TEST(SuperResolutionTest, ExecuteTemporalUpscaler)
219+
{
220+
auto* pEnv = GPUTestingEnvironment::GetInstance();
221+
auto* pDevice = pEnv->GetDevice();
222+
if (!pDevice->GetDeviceInfo().Features.SuperResolution)
223+
{
224+
GTEST_SKIP() << "Super resolution is not supported by this device";
225+
}
226+
227+
const auto& SRProps = pDevice->GetAdapterInfo().SuperResolution;
228+
if (!(SRProps.Flags & SUPER_RESOLUTION_FLAG_TEMPORAL))
229+
{
230+
GTEST_SKIP() << "Temporal super resolution is not supported by this device";
231+
}
232+
233+
GPUTestingEnvironment::ScopedReset EnvironmentAutoReset;
234+
235+
constexpr Uint32 OutputWidth = 256;
236+
constexpr Uint32 OutputHeight = 256;
237+
238+
// Create upscaler
239+
SuperResolutionUpscalerDesc UpscalerDesc;
240+
UpscalerDesc.Name = "Test Temporal Execute Upscaler";
241+
UpscalerDesc.Type = SUPER_RESOLUTION_UPSCALER_TYPE_TEMPORAL;
242+
UpscalerDesc.OutputWidth = OutputWidth;
243+
UpscalerDesc.OutputHeight = OutputHeight;
244+
UpscalerDesc.OutputFormat = TEX_FORMAT_RGBA16_FLOAT;
245+
UpscalerDesc.ColorFormat = TEX_FORMAT_RGBA16_FLOAT;
246+
UpscalerDesc.DepthFormat = TEX_FORMAT_D32_FLOAT;
247+
UpscalerDesc.MotionFormat = TEX_FORMAT_RG16_FLOAT;
248+
249+
RefCntAutoPtr<ISuperResolutionUpscaler> pUpscaler;
250+
pDevice->CreateSuperResolutionUpscaler(UpscalerDesc, &pUpscaler);
251+
ASSERT_NE(pUpscaler, nullptr);
252+
253+
Uint32 RenderWidth = 0;
254+
Uint32 RenderHeight = 0;
255+
pUpscaler->GetRenderResolution(&RenderWidth, &RenderHeight);
256+
ASSERT_GT(RenderWidth, 0u);
257+
ASSERT_GT(RenderHeight, 0u);
258+
259+
// Create input color texture
260+
TextureDesc ColorTexDesc;
261+
ColorTexDesc.Name = "SR Color Input";
262+
ColorTexDesc.Type = RESOURCE_DIM_TEX_2D;
263+
ColorTexDesc.Width = RenderWidth;
264+
ColorTexDesc.Height = RenderHeight;
265+
ColorTexDesc.Format = TEX_FORMAT_RGBA16_FLOAT;
266+
ColorTexDesc.BindFlags = BIND_SHADER_RESOURCE | BIND_RENDER_TARGET;
267+
ColorTexDesc.Usage = USAGE_DEFAULT;
268+
269+
RefCntAutoPtr<ITexture> pColorTex;
270+
pDevice->CreateTexture(ColorTexDesc, nullptr, &pColorTex);
271+
ASSERT_NE(pColorTex, nullptr);
272+
273+
// Create depth texture
274+
TextureDesc DepthTexDesc;
275+
DepthTexDesc.Name = "SR Depth Input";
276+
DepthTexDesc.Type = RESOURCE_DIM_TEX_2D;
277+
DepthTexDesc.Width = RenderWidth;
278+
DepthTexDesc.Height = RenderHeight;
279+
DepthTexDesc.Format = TEX_FORMAT_D32_FLOAT;
280+
DepthTexDesc.BindFlags = BIND_SHADER_RESOURCE | BIND_DEPTH_STENCIL;
281+
DepthTexDesc.Usage = USAGE_DEFAULT;
282+
283+
RefCntAutoPtr<ITexture> pDepthTex;
284+
pDevice->CreateTexture(DepthTexDesc, nullptr, &pDepthTex);
285+
ASSERT_NE(pDepthTex, nullptr);
286+
287+
// Create motion vectors texture
288+
TextureDesc MotionTexDesc;
289+
MotionTexDesc.Name = "SR Motion Vectors";
290+
MotionTexDesc.Type = RESOURCE_DIM_TEX_2D;
291+
MotionTexDesc.Width = RenderWidth;
292+
MotionTexDesc.Height = RenderHeight;
293+
MotionTexDesc.Format = TEX_FORMAT_RG16_FLOAT;
294+
MotionTexDesc.BindFlags = BIND_SHADER_RESOURCE | BIND_RENDER_TARGET;
295+
MotionTexDesc.Usage = USAGE_DEFAULT;
296+
297+
RefCntAutoPtr<ITexture> pMotionTex;
298+
pDevice->CreateTexture(MotionTexDesc, nullptr, &pMotionTex);
299+
ASSERT_NE(pMotionTex, nullptr);
300+
301+
// Create output texture
302+
TextureDesc OutputTexDesc;
303+
OutputTexDesc.Name = "SR Output";
304+
OutputTexDesc.Type = RESOURCE_DIM_TEX_2D;
305+
OutputTexDesc.Width = OutputWidth;
306+
OutputTexDesc.Height = OutputHeight;
307+
OutputTexDesc.Format = TEX_FORMAT_RGBA16_FLOAT;
308+
OutputTexDesc.BindFlags = BIND_RENDER_TARGET | BIND_UNORDERED_ACCESS;
309+
OutputTexDesc.Usage = USAGE_DEFAULT;
310+
311+
RefCntAutoPtr<ITexture> pOutputTex;
312+
pDevice->CreateTexture(OutputTexDesc, nullptr, &pOutputTex);
313+
ASSERT_NE(pOutputTex, nullptr);
314+
315+
// Execute temporal upscaling with reset
316+
auto* pContext = pEnv->GetDeviceContext();
317+
318+
ExecuteSuperResolutionAttribs Attribs;
319+
Attribs.pColorTextureSRV = pColorTex->GetDefaultView(TEXTURE_VIEW_SHADER_RESOURCE);
320+
Attribs.pDepthTextureSRV = pDepthTex->GetDefaultView(TEXTURE_VIEW_SHADER_RESOURCE);
321+
Attribs.pMotionVectorsSRV = pMotionTex->GetDefaultView(TEXTURE_VIEW_SHADER_RESOURCE);
322+
Attribs.pOutputTextureRTV = pOutputTex->GetDefaultView(TEXTURE_VIEW_RENDER_TARGET);
323+
Attribs.JitterX = 0.5f;
324+
Attribs.JitterY = -0.5f;
325+
Attribs.Reset = True;
326+
327+
pContext->ExecuteSuperResolution(Attribs, pUpscaler);
328+
329+
// Execute a second frame without reset
330+
Attribs.JitterX = -0.25f;
331+
Attribs.JitterY = 0.25f;
332+
Attribs.Reset = False;
333+
334+
pContext->ExecuteSuperResolution(Attribs, pUpscaler);
335+
336+
pContext->Flush();
337+
pContext->WaitForIdle();
338+
}
339+
340+
} // namespace

0 commit comments

Comments
 (0)