Skip to content

Commit c3e38ac

Browse files
Update SuperResolution API
1 parent 4ee0c7f commit c3e38ac

File tree

3 files changed

+41
-9
lines changed

3 files changed

+41
-9
lines changed

Graphics/GraphicsEngine/interface/GraphicsTypes.h

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3347,10 +3347,28 @@ DILIGENT_TYPED_ENUM(SUPER_RESOLUTION_TEMPORAL_CAP_FLAGS, Uint32)
33473347
DEFINE_FLAG_ENUM_OPERATORS(SUPER_RESOLUTION_TEMPORAL_CAP_FLAGS)
33483348

33493349

3350+
/// Super resolution creation flags.
3351+
DILIGENT_TYPED_ENUM(SUPER_RESOLUTION_CREATE_FLAGS, Uint32)
3352+
{
3353+
SUPER_RESOLUTION_CREATE_FLAG_NONE = 0u,
3354+
3355+
/// When set, the upscaler automatically calculates exposure for each frame.
3356+
/// The exposure texture in ExecuteSuperResolutionAttribs is ignored.
3357+
SUPER_RESOLUTION_CREATE_FLAG_AUTO_EXPOSURE = 1u << 0,
3358+
3359+
/// When set, enables the sharpening pass in the upscaler.
3360+
/// The Sharpness field in ExecuteSuperResolutionAttribs controls the amount.
3361+
SUPER_RESOLUTION_CREATE_FLAG_ENABLE_SHARPENING = 1u << 1,
3362+
3363+
SUPER_RESOLUTION_CREATE_FLAG_LAST = SUPER_RESOLUTION_CREATE_FLAG_ENABLE_SHARPENING
3364+
};
3365+
DEFINE_FLAG_ENUM_OPERATORS(SUPER_RESOLUTION_CREATE_FLAGS)
3366+
3367+
33503368
/// Information about a supported super resolution upscaler variant
33513369
struct SuperResolutionInfo
33523370
{
3353-
/// Human-readable name of the upscaler variant (e.g. "MetalFX Spatial", "MetalFX Temporal").
3371+
/// Human-readable name of the upscaler variant (e.g. "DLSS", "FSR", "MetalFX Spatial", "MetalFX Temporal").
33543372
Char Name[128] DEFAULT_INITIALIZER({});
33553373

33563374
/// Unique identifier for this upscaler variant.

Graphics/GraphicsEngine/interface/SuperResolution.h

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,14 @@ struct SuperResolutionDesc DILIGENT_DERIVE(DeviceObjectAttribs)
8989
/// Unlike the reactive mask which provides proportional control, this is a binary decision.
9090
TEXTURE_FORMAT IgnoreHistoryMaskFormat DEFAULT_INITIALIZER(TEX_FORMAT_UNKNOWN);
9191

92-
/// When True, the upscaler automatically calculates exposure for each frame.
93-
/// When auto exposure is enabled, the exposure texture in
94-
/// ExecuteSuperResolutionAttribs is ignored.
95-
Bool AutoExposureEnabled DEFAULT_INITIALIZER(True);
92+
/// Exposure scale texture format.
93+
/// Optional. When auto-exposure is disabled, specifies the format of the 1x1 exposure
94+
/// texture provided in ExecuteSuperResolutionAttribs::pExposureTextureSRV.
95+
TEXTURE_FORMAT ExposureFormat DEFAULT_INITIALIZER(TEX_FORMAT_UNKNOWN);
96+
97+
/// Engine creation flags controlling the super resolution upscaler behavior.
98+
/// See SUPER_RESOLUTION_CREATE_FLAGS.
99+
SUPER_RESOLUTION_CREATE_FLAGS Flags DEFAULT_INITIALIZER(SUPER_RESOLUTION_CREATE_FLAG_NONE);
96100
};
97101
typedef struct SuperResolutionDesc SuperResolutionDesc;
98102

@@ -112,6 +116,16 @@ struct SuperResolutionSourceSettingsAttribs
112116
/// Target (output) texture height. Must be greater than zero.
113117
Uint32 OutputHeight DEFAULT_INITIALIZER(0);
114118

119+
/// Output texture format.
120+
/// Some backends (e.g. DirectSR) may return different optimal input resolutions
121+
/// depending on the output format. When set to TEX_FORMAT_UNKNOWN, the backend will use a reasonable default.
122+
TEXTURE_FORMAT OutputFormat DEFAULT_INITIALIZER(TEX_FORMAT_UNKNOWN);
123+
124+
/// Engine creation flags controlling the super resolution upscaler behavior.
125+
/// These flags affect the optimal source resolution returned by the backend.
126+
/// Must match the flags that will be used when creating the upscaler.
127+
SUPER_RESOLUTION_CREATE_FLAGS Flags DEFAULT_INITIALIZER(SUPER_RESOLUTION_CREATE_FLAG_NONE);
128+
115129
/// Optimization type controlling the quality/performance trade-off.
116130
SUPER_RESOLUTION_OPTIMIZATION_TYPE OptimizationType DEFAULT_INITIALIZER(SUPER_RESOLUTION_OPTIMIZATION_TYPE_BALANCED);
117131
};
@@ -150,12 +164,12 @@ struct ExecuteSuperResolutionAttribs
150164

151165
/// Output (upscaled) texture (unordered access view or render target view).
152166
/// Must match SuperResolutionDesc::OutputWidth x OutputHeight.
153-
ITextureView* pOutputTextureRTV DEFAULT_INITIALIZER(nullptr);
167+
ITextureView* pOutputTextureView DEFAULT_INITIALIZER(nullptr);
154168

155169
/// Exposure texture (shader resource view).
156170
/// Optional. A 1x1 R16_FLOAT texture containing the exposure value.
157171
/// The upscaler reads the R channel and uses it to multiply the input color.
158-
/// Ignored when SuperResolutionDesc::AutoExposureEnabled is True.
172+
/// Ignored when SuperResolutionDesc::Flags includes SUPER_RESOLUTION_CREATE_FLAG_AUTO_EXPOSURE.
159173
ITextureView* pExposureTextureSRV DEFAULT_INITIALIZER(nullptr);
160174

161175
/// Reactive mask texture (shader resource view).

Tests/DiligentCoreAPITest/src/SuperResolutionTest.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ TEST(SuperResolutionTest, ExecuteSpatialUpscaler)
329329

330330
ExecuteSuperResolutionAttribs Attribs;
331331
Attribs.pColorTextureSRV = pColorTex->GetDefaultView(TEXTURE_VIEW_SHADER_RESOURCE);
332-
Attribs.pOutputTextureRTV = pOutputTex->GetDefaultView(TEXTURE_VIEW_RENDER_TARGET);
332+
Attribs.pOutputTextureView = pOutputTex->GetDefaultView(TEXTURE_VIEW_RENDER_TARGET);
333333

334334
pContext->ExecuteSuperResolution(Attribs, pUpscaler);
335335
pContext->Flush();
@@ -452,7 +452,7 @@ TEST(SuperResolutionTest, ExecuteTemporalUpscaler)
452452
Attribs.pColorTextureSRV = pColorTex->GetDefaultView(TEXTURE_VIEW_SHADER_RESOURCE);
453453
Attribs.pDepthTextureSRV = pDepthTex->GetDefaultView(TEXTURE_VIEW_SHADER_RESOURCE);
454454
Attribs.pMotionVectorsSRV = pMotionTex->GetDefaultView(TEXTURE_VIEW_SHADER_RESOURCE);
455-
Attribs.pOutputTextureRTV = pOutputTex->GetDefaultView(TEXTURE_VIEW_RENDER_TARGET);
455+
Attribs.pOutputTextureView = pOutputTex->GetDefaultView(TEXTURE_VIEW_RENDER_TARGET);
456456
Attribs.JitterX = 0.5f;
457457
Attribs.JitterY = -0.5f;
458458
Attribs.MotionVectorScaleX = 1.0f;

0 commit comments

Comments
 (0)