Debian Codegraph @

thirdparty/amd-fsr2/ffx_fsr2.h

raw symbols SCIP
1 // This file is part of the FidelityFX SDK.
2 //
3 // Copyright (c) 2022-2023 Advanced Micro Devices, Inc. All rights reserved.
4 //
5 // Permission is hereby granted, free of charge, to any person obtaining a copy
6 // of this software and associated documentation files (the "Software"), to deal
7 // in the Software without restriction, including without limitation the rights
8 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 // copies of the Software, and to permit persons to whom the Software is
10 // furnished to do so, subject to the following conditions:
11 // The above copyright notice and this permission notice shall be included in
12 // all copies or substantial portions of the Software.
13 //
14 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 // THE SOFTWARE.
21
22
23 // @defgroup FSR2
24
25 #pragma once
26
27 // Include the interface for the backend of the FSR2 API.
28 #include "ffx_fsr2_interface.h"
29
30 /// FidelityFX Super Resolution 2 major version.
31 ///
32 /// @ingroup FSR2
33 #define FFX_FSR2_VERSION_MAJOR (2)
34
35 /// FidelityFX Super Resolution 2 minor version.
36 ///
37 /// @ingroup FSR2
38 #define FFX_FSR2_VERSION_MINOR (2)
39
40 /// FidelityFX Super Resolution 2 patch version.
41 ///
42 /// @ingroup FSR2
43 #define FFX_FSR2_VERSION_PATCH (1)
44
45 /// The size of the context specified in 32bit values.
46 ///
47 /// @ingroup FSR2
48 #define FFX_FSR2_CONTEXT_SIZE (16536)
49
50 #if defined(__cplusplus)
51 extern "C" {
52 #endif // #if defined(__cplusplus)
53
54 /// An enumeration of all the quality modes supported by FidelityFX Super
55 /// Resolution 2 upscaling.
56 ///
57 /// In order to provide a consistent user experience across multiple
58 /// applications which implement FSR2. It is strongly recommended that the
59 /// following preset scaling factors are made available through your
60 /// application's user interface.
61 ///
62 /// If your application does not expose the notion of preset scaling factors
63 /// for upscaling algorithms (perhaps instead implementing a fixed ratio which
64 /// is immutable) or implementing a more dynamic scaling scheme (such as
65 /// dynamic resolution scaling), then there is no need to use these presets.
66 ///
67 /// Please note that <c><i>FFX_FSR2_QUALITY_MODE_ULTRA_PERFORMANCE</i></c> is
68 /// an optional mode which may introduce significant quality degradation in the
69 /// final image. As such it is recommended that you evaluate the final results
70 /// of using this scaling mode before deciding if you should include it in your
71 /// application.
72 ///
73 /// @ingroup FSR2
74 typedef enum FfxFsr2QualityMode {
75
76 FFX_FSR2_QUALITY_MODE_QUALITY = 1, ///< Perform upscaling with a per-dimension upscaling ratio of 1.5x.
77 FFX_FSR2_QUALITY_MODE_BALANCED = 2, ///< Perform upscaling with a per-dimension upscaling ratio of 1.7x.
78 FFX_FSR2_QUALITY_MODE_PERFORMANCE = 3, ///< Perform upscaling with a per-dimension upscaling ratio of 2.0x.
79 FFX_FSR2_QUALITY_MODE_ULTRA_PERFORMANCE = 4 ///< Perform upscaling with a per-dimension upscaling ratio of 3.0x.
80 } FfxFsr2QualityMode;
81
82 /// An enumeration of bit flags used when creating a
83 /// <c><i>FfxFsr2Context</i></c>. See <c><i>FfxFsr2ContextDescription</i></c>.
84 ///
85 /// @ingroup FSR2
86 typedef enum FfxFsr2InitializationFlagBits {
87
88 FFX_FSR2_ENABLE_HIGH_DYNAMIC_RANGE = (1<<0), ///< A bit indicating if the input color data provided is using a high-dynamic range.
89 FFX_FSR2_ENABLE_DISPLAY_RESOLUTION_MOTION_VECTORS = (1<<1), ///< A bit indicating if the motion vectors are rendered at display resolution.
90 FFX_FSR2_ENABLE_MOTION_VECTORS_JITTER_CANCELLATION = (1<<2), ///< A bit indicating that the motion vectors have the jittering pattern applied to them.
91 FFX_FSR2_ENABLE_DEPTH_INVERTED = (1<<3), ///< A bit indicating that the input depth buffer data provided is inverted [1..0].
92 FFX_FSR2_ENABLE_DEPTH_INFINITE = (1<<4), ///< A bit indicating that the input depth buffer data provided is using an infinite far plane.
93 FFX_FSR2_ENABLE_AUTO_EXPOSURE = (1<<5), ///< A bit indicating if automatic exposure should be applied to input color data.
94 FFX_FSR2_ENABLE_DYNAMIC_RESOLUTION = (1<<6), ///< A bit indicating that the application uses dynamic resolution scaling.
95 FFX_FSR2_ENABLE_TEXTURE1D_USAGE = (1<<7), ///< A bit indicating that the backend should use 1D textures.
96 FFX_FSR2_ENABLE_DEBUG_CHECKING = (1<<8), ///< A bit indicating that the runtime should check some API values and report issues.
97 } FfxFsr2InitializationFlagBits;
98
99 /// A structure encapsulating the parameters required to initialize FidelityFX
100 /// Super Resolution 2 upscaling.
101 ///
102 /// @ingroup FSR2
103 typedef struct FfxFsr2ContextDescription {
104
105 uint32_t flags; ///< A collection of <c><i>FfxFsr2InitializationFlagBits</i></c>.
106 FfxDimensions2D maxRenderSize; ///< The maximum size that rendering will be performed at.
107 FfxDimensions2D displaySize; ///< The size of the presentation resolution targeted by the upscaling process.
108 FfxFsr2Interface callbacks; ///< A set of pointers to the backend implementation for FSR 2.0.
109 FfxDevice device; ///< The abstracted device which is passed to some callback functions.
110
111 FfxFsr2Message fpMessage; ///< A pointer to a function that can recieve messages from the runtime.
112 } FfxFsr2ContextDescription;
113
114 /// A structure encapsulating the parameters for dispatching the various passes
115 /// of FidelityFX Super Resolution 2.
116 ///
117 /// @ingroup FSR2
118 typedef struct FfxFsr2DispatchDescription {
119
120 FfxCommandList commandList; ///< The <c><i>FfxCommandList</i></c> to record FSR2 rendering commands into.
121 FfxResource color; ///< A <c><i>FfxResource</i></c> containing the color buffer for the current frame (at render resolution).
122 FfxResource depth; ///< A <c><i>FfxResource</i></c> containing 32bit depth values for the current frame (at render resolution).
123 FfxResource motionVectors; ///< A <c><i>FfxResource</i></c> containing 2-dimensional motion vectors (at render resolution if <c><i>FFX_FSR2_ENABLE_DISPLAY_RESOLUTION_MOTION_VECTORS</i></c> is not set).
124 FfxResource exposure; ///< A optional <c><i>FfxResource</i></c> containing a 1x1 exposure value.
125 FfxResource reactive; ///< A optional <c><i>FfxResource</i></c> containing alpha value of reactive objects in the scene.
126 FfxResource transparencyAndComposition; ///< A optional <c><i>FfxResource</i></c> containing alpha value of special objects in the scene.
127 FfxResource output; ///< A <c><i>FfxResource</i></c> containing the output color buffer for the current frame (at presentation resolution).
128 FfxFloatCoords2D jitterOffset; ///< The subpixel jitter offset applied to the camera.
129 FfxFloatCoords2D motionVectorScale; ///< The scale factor to apply to motion vectors.
130 FfxDimensions2D renderSize; ///< The resolution that was used for rendering the input resources.
131 bool enableSharpening; ///< Enable an additional sharpening pass.
132 float sharpness; ///< The sharpness value between 0 and 1, where 0 is no additional sharpness and 1 is maximum additional sharpness.
133 float frameTimeDelta; ///< The time elapsed since the last frame (expressed in milliseconds).
134 float preExposure; ///< The pre exposure value (must be > 0.0f)
135 bool reset; ///< A boolean value which when set to true, indicates the camera has moved discontinuously.
136 float cameraNear; ///< The distance to the near plane of the camera.
137 float cameraFar; ///< The distance to the far plane of the camera.
138 float cameraFovAngleVertical; ///< The camera angle field of view in the vertical direction (expressed in radians).
139 float viewSpaceToMetersFactor; ///< The scale factor to convert view space units to meters
140
141 // EXPERIMENTAL reactive mask generation parameters
142 bool enableAutoReactive; ///< A boolean value to indicate internal reactive autogeneration should be used
143 FfxResource colorOpaqueOnly; ///< A <c><i>FfxResource</i></c> containing the opaque only color buffer for the current frame (at render resolution).
144 float autoTcThreshold; ///< Cutoff value for TC
145 float autoTcScale; ///< A value to scale the transparency and composition mask
146 float autoReactiveScale; ///< A value to scale the reactive mask
147 float autoReactiveMax; ///< A value to clamp the reactive mask
148
149 float reprojectionMatrix[16]; ///< The matrix used for reprojecting pixels with invalid motion vectors by using the depth.
150 } FfxFsr2DispatchDescription;
151
152 /// A structure encapsulating the parameters for automatic generation of a reactive mask
153 ///
154 /// @ingroup FSR2
155 typedef struct FfxFsr2GenerateReactiveDescription {
156
157 FfxCommandList commandList; ///< The <c><i>FfxCommandList</i></c> to record FSR2 rendering commands into.
158 FfxResource colorOpaqueOnly; ///< A <c><i>FfxResource</i></c> containing the opaque only color buffer for the current frame (at render resolution).
159 FfxResource colorPreUpscale; ///< A <c><i>FfxResource</i></c> containing the opaque+translucent color buffer for the current frame (at render resolution).
160 FfxResource outReactive; ///< A <c><i>FfxResource</i></c> containing the surface to generate the reactive mask into.
161 FfxDimensions2D renderSize; ///< The resolution that was used for rendering the input resources.
162 float scale; ///< A value to scale the output
163 float cutoffThreshold; ///< A threshold value to generate a binary reactive mask
164 float binaryValue; ///< A value to set for the binary reactive mask
165 uint32_t flags; ///< Flags to determine how to generate the reactive mask
166 } FfxFsr2GenerateReactiveDescription;
167
168 /// A structure encapsulating the FidelityFX Super Resolution 2 context.
169 ///
170 /// This sets up an object which contains all persistent internal data and
171 /// resources that are required by FSR2.
172 ///
173 /// The <c><i>FfxFsr2Context</i></c> object should have a lifetime matching
174 /// your use of FSR2. Before destroying the FSR2 context care should be taken
175 /// to ensure the GPU is not accessing the resources created or used by FSR2.
176 /// It is therefore recommended that the GPU is idle before destroying the
177 /// FSR2 context.
178 ///
179 /// @ingroup FSR2
180 typedef struct FfxFsr2Context {
181
182 uint32_t data[FFX_FSR2_CONTEXT_SIZE]; ///< An opaque set of <c>uint32_t</c> which contain the data for the context.
183 } FfxFsr2Context;
184
185 /// Create a FidelityFX Super Resolution 2 context from the parameters
186 /// programmed to the <c><i>FfxFsr2CreateParams</i></c> structure.
187 ///
188 /// The context structure is the main object used to interact with the FSR2
189 /// API, and is responsible for the management of the internal resources used
190 /// by the FSR2 algorithm. When this API is called, multiple calls will be
191 /// made via the pointers contained in the <c><i>callbacks</i></c> structure.
192 /// These callbacks will attempt to retreive the device capabilities, and
193 /// create the internal resources, and pipelines required by FSR2's
194 /// frame-to-frame function. Depending on the precise configuration used when
195 /// creating the <c><i>FfxFsr2Context</i></c> a different set of resources and
196 /// pipelines might be requested via the callback functions.
197 ///
198 /// The flags included in the <c><i>flags</i></c> field of
199 /// <c><i>FfxFsr2Context</i></c> how match the configuration of your
200 /// application as well as the intended use of FSR2. It is important that these
201 /// flags are set correctly (as well as a correct programmed
202 /// <c><i>FfxFsr2DispatchDescription</i></c>) to ensure correct operation. It is
203 /// recommended to consult the overview documentation for further details on
204 /// how FSR2 should be integerated into an application.
205 ///
206 /// When the <c><i>FfxFsr2Context</i></c> is created, you should use the
207 /// <c><i>ffxFsr2ContextDispatch</i></c> function each frame where FSR2
208 /// upscaling should be applied. See the documentation of
209 /// <c><i>ffxFsr2ContextDispatch</i></c> for more details.
210 ///
211 /// The <c><i>FfxFsr2Context</i></c> should be destroyed when use of it is
212 /// completed, typically when an application is unloaded or FSR2 upscaling is
213 /// disabled by a user. To destroy the FSR2 context you should call
214 /// <c><i>ffxFsr2ContextDestroy</i></c>.
215 ///
216 /// @param [out] context A pointer to a <c><i>FfxFsr2Context</i></c> structure to populate.
217 /// @param [in] contextDescription A pointer to a <c><i>FfxFsr2ContextDescription</i></c> structure.
218 ///
219 /// @retval
220 /// FFX_OK The operation completed successfully.
221 /// @retval
222 /// FFX_ERROR_CODE_NULL_POINTER The operation failed because either <c><i>context</i></c> or <c><i>contextDescription</i></c> was <c><i>NULL</i></c>.
223 /// @retval
224 /// FFX_ERROR_INCOMPLETE_INTERFACE The operation failed because the <c><i>FfxFsr2ContextDescription.callbacks</i></c> was not fully specified.
225 /// @retval
226 /// FFX_ERROR_BACKEND_API_ERROR The operation failed because of an error returned from the backend.
227 ///
228 /// @ingroup FSR2
229 FFX_API FfxErrorCode ffxFsr2ContextCreate(FfxFsr2Context* context, const FfxFsr2ContextDescription* contextDescription);
230
231 /// Dispatch the various passes that constitute FidelityFX Super Resolution 2.
232 ///
233 /// FSR2 is a composite effect, meaning that it is compromised of multiple
234 /// constituent passes (implemented as one or more clears, copies and compute
235 /// dispatches). The <c><i>ffxFsr2ContextDispatch</i></c> function is the
236 /// function which (via the use of the functions contained in the
237 /// <c><i>callbacks</i></c> field of the <c><i>FfxFsr2Context</i></c>
238 /// structure) utlimately generates the sequence of graphics API calls required
239 /// each frame.
240 ///
241 /// As with the creation of the <c><i>FfxFsr2Context</i></c> correctly
242 /// programming the <c><i>FfxFsr2DispatchDescription</i></c> is key to ensuring
243 /// the correct operation of FSR2. It is particularly important to ensure that
244 /// camera jitter is correctly applied to your application's projection matrix
245 /// (or camera origin for raytraced applications). FSR2 provides the
246 /// <c><i>ffxFsr2GetJitterPhaseCount</i></c> and
247 /// <c><i>ffxFsr2GetJitterOffset</i></c> entry points to help applications
248 /// correctly compute the camera jitter. Whatever jitter pattern is used by the
249 /// application it should be correctly programmed to the
250 /// <c><i>jitterOffset</i></c> field of the <c><i>dispatchDescription</i></c>
251 /// structure. For more guidance on camera jitter please consult the
252 /// documentation for <c><i>ffxFsr2GetJitterOffset</i></c> as well as the
253 /// accompanying overview documentation for FSR2.
254 ///
255 /// @param [in] context A pointer to a <c><i>FfxFsr2Context</i></c> structure.
256 /// @param [in] dispatchDescription A pointer to a <c><i>FfxFsr2DispatchDescription</i></c> structure.
257 ///
258 /// @retval
259 /// FFX_OK The operation completed successfully.
260 /// @retval
261 /// FFX_ERROR_CODE_NULL_POINTER The operation failed because either <c><i>context</i></c> or <c><i>dispatchDescription</i></c> was <c><i>NULL</i></c>.
262 /// @retval
263 /// FFX_ERROR_OUT_OF_RANGE The operation failed because <c><i>dispatchDescription.renderSize</i></c> was larger than the maximum render resolution.
264 /// @retval
265 /// FFX_ERROR_NULL_DEVICE The operation failed because the device inside the context was <c><i>NULL</i></c>.
266 /// @retval
267 /// FFX_ERROR_BACKEND_API_ERROR The operation failed because of an error returned from the backend.
268 ///
269 /// @ingroup FSR2
270 FFX_API FfxErrorCode ffxFsr2ContextDispatch(FfxFsr2Context* context, const FfxFsr2DispatchDescription* dispatchDescription);
271
272 /// A helper function generate a Reactive mask from an opaque only texure and one containing translucent objects.
273 ///
274 /// @param [in] context A pointer to a <c><i>FfxFsr2Context</i></c> structure.
275 /// @param [in] params A pointer to a <c><i>FfxFsr2GenerateReactiveDescription</i></c> structure
276 ///
277 /// @retval
278 /// FFX_OK The operation completed successfully.
279 ///
280 /// @ingroup FSR2
281 FFX_API FfxErrorCode ffxFsr2ContextGenerateReactiveMask(FfxFsr2Context* context, const FfxFsr2GenerateReactiveDescription* params);
282
283 /// Destroy the FidelityFX Super Resolution context.
284 ///
285 /// @param [out] context A pointer to a <c><i>FfxFsr2Context</i></c> structure to destroy.
286 ///
287 /// @retval
288 /// FFX_OK The operation completed successfully.
289 /// @retval
290 /// FFX_ERROR_CODE_NULL_POINTER The operation failed because either <c><i>context</i></c> was <c><i>NULL</i></c>.
291 ///
292 /// @ingroup FSR2
293 FFX_API FfxErrorCode ffxFsr2ContextDestroy(FfxFsr2Context* context);
294
295 /// Get the upscale ratio from the quality mode.
296 ///
297 /// The following table enumerates the mapping of the quality modes to
298 /// per-dimension scaling ratios.
299 ///
300 /// Quality preset | Scale factor
301 /// ----------------------------------------------------- | -------------
302 /// <c><i>FFX_FSR2_QUALITY_MODE_QUALITY</i></c> | 1.5x
303 /// <c><i>FFX_FSR2_QUALITY_MODE_BALANCED</i></c> | 1.7x
304 /// <c><i>FFX_FSR2_QUALITY_MODE_PERFORMANCE</i></c> | 2.0x
305 /// <c><i>FFX_FSR2_QUALITY_MODE_ULTRA_PERFORMANCE</i></c> | 3.0x
306 ///
307 /// Passing an invalid <c><i>qualityMode</i></c> will return 0.0f.
308 ///
309 /// @param [in] qualityMode The quality mode preset.
310 ///
311 /// @returns
312 /// The upscaling the per-dimension upscaling ratio for
313 /// <c><i>qualityMode</i></c> according to the table above.
314 ///
315 /// @ingroup FSR2
316 FFX_API float ffxFsr2GetUpscaleRatioFromQualityMode(FfxFsr2QualityMode qualityMode);
317
318 /// A helper function to calculate the rendering resolution from a target
319 /// resolution and desired quality level.
320 ///
321 /// This function applies the scaling factor returned by
322 /// <c><i>ffxFsr2GetUpscaleRatioFromQualityMode</i></c> to each dimension.
323 ///
324 /// @param [out] renderWidth A pointer to a <c>uint32_t</c> which will hold the calculated render resolution width.
325 /// @param [out] renderHeight A pointer to a <c>uint32_t</c> which will hold the calculated render resolution height.
326 /// @param [in] displayWidth The target display resolution width.
327 /// @param [in] displayHeight The target display resolution height.
328 /// @param [in] qualityMode The desired quality mode for FSR 2 upscaling.
329 ///
330 /// @retval
331 /// FFX_OK The operation completed successfully.
332 /// @retval
333 /// FFX_ERROR_INVALID_POINTER Either <c><i>renderWidth</i></c> or <c><i>renderHeight</i></c> was <c>NULL</c>.
334 /// @retval
335 /// FFX_ERROR_INVALID_ENUM An invalid quality mode was specified.
336 ///
337 /// @ingroup FSR2
338 FFX_API FfxErrorCode ffxFsr2GetRenderResolutionFromQualityMode(
339 uint32_t* renderWidth,
340 uint32_t* renderHeight,
341 uint32_t displayWidth,
342 uint32_t displayHeight,
343 FfxFsr2QualityMode qualityMode);
344
345 /// A helper function to calculate the jitter phase count from display
346 /// resolution.
347 ///
348 /// For more detailed information about the application of camera jitter to
349 /// your application's rendering please refer to the
350 /// <c><i>ffxFsr2GetJitterOffset</i></c> function.
351 ///
352 /// The table below shows the jitter phase count which this function
353 /// would return for each of the quality presets.
354 ///
355 /// Quality preset | Scale factor | Phase count
356 /// ----------------------------------------------------- | ------------- | ---------------
357 /// <c><i>FFX_FSR2_QUALITY_MODE_QUALITY</i></c> | 1.5x | 18
358 /// <c><i>FFX_FSR2_QUALITY_MODE_BALANCED</i></c> | 1.7x | 23
359 /// <c><i>FFX_FSR2_QUALITY_MODE_PERFORMANCE</i></c> | 2.0x | 32
360 /// <c><i>FFX_FSR2_QUALITY_MODE_ULTRA_PERFORMANCE</i></c> | 3.0x | 72
361 /// Custom | [1..n]x | ceil(8*n^2)
362 ///
363 /// @param [in] renderWidth The render resolution width.
364 /// @param [in] displayWidth The display resolution width.
365 ///
366 /// @returns
367 /// The jitter phase count for the scaling factor between <c><i>renderWidth</i></c> and <c><i>displayWidth</i></c>.
368 ///
369 /// @ingroup FSR2
370 FFX_API int32_t ffxFsr2GetJitterPhaseCount(int32_t renderWidth, int32_t displayWidth);
371
372 /// A helper function to calculate the subpixel jitter offset.
373 ///
374 /// FSR2 relies on the application to apply sub-pixel jittering while rendering.
375 /// This is typically included in the projection matrix of the camera. To make
376 /// the application of camera jitter simple, the FSR2 API provides a small set
377 /// of utility function which computes the sub-pixel jitter offset for a
378 /// particular frame within a sequence of separate jitter offsets. To begin, the
379 /// index within the jitter phase must be computed. To calculate the
380 /// sequence's length, you can call the <c><i>ffxFsr2GetJitterPhaseCount</i></c>
381 /// function. The index should be a value which is incremented each frame modulo
382 /// the length of the sequence computed by <c><i>ffxFsr2GetJitterPhaseCount</i></c>.
383 /// The index within the jitter phase is passed to
384 /// <c><i>ffxFsr2GetJitterOffset</i></c> via the <c><i>index</i></c> parameter.
385 ///
386 /// This function uses a Halton(2,3) sequence to compute the jitter offset.
387 /// The ultimate index used for the sequence is <c><i>index</i></c> %
388 /// <c><i>phaseCount</i></c>.
389 ///
390 /// It is important to understand that the values returned from the
391 /// <c><i>ffxFsr2GetJitterOffset</i></c> function are in unit pixel space, and
392 /// in order to composite this correctly into a projection matrix we must
393 /// convert them into projection offsets. This is done as per the pseudo code
394 /// listing which is shown below.
395 ///
396 /// const int32_t jitterPhaseCount = ffxFsr2GetJitterPhaseCount(renderWidth, displayWidth);
397 ///
398 /// float jitterX = 0;
399 /// float jitterY = 0;
400 /// ffxFsr2GetJitterOffset(&jitterX, &jitterY, index, jitterPhaseCount);
401 ///
402 /// const float jitterX = 2.0f * jitterX / (float)renderWidth;
403 /// const float jitterY = -2.0f * jitterY / (float)renderHeight;
404 /// const Matrix4 jitterTranslationMatrix = translateMatrix(Matrix3::identity, Vector3(jitterX, jitterY, 0));
405 /// const Matrix4 jitteredProjectionMatrix = jitterTranslationMatrix * projectionMatrix;
406 ///
407 /// Jitter should be applied to all rendering. This includes opaque, alpha
408 /// transparent, and raytraced objects. For rasterized objects, the sub-pixel
409 /// jittering values calculated by the <c><i>iffxFsr2GetJitterOffset</i></c>
410 /// function can be applied to the camera projection matrix which is ultimately
411 /// used to perform transformations during vertex shading. For raytraced
412 /// rendering, the sub-pixel jitter should be applied to the ray's origin,
413 /// often the camera's position.
414 ///
415 /// Whether you elect to use the <c><i>ffxFsr2GetJitterOffset</i></c> function
416 /// or your own sequence generator, you must program the
417 /// <c><i>jitterOffset</i></c> field of the
418 /// <c><i>FfxFsr2DispatchParameters</i></c> structure in order to inform FSR2
419 /// of the jitter offset that has been applied in order to render each frame.
420 ///
421 /// If not using the recommended <c><i>ffxFsr2GetJitterOffset</i></c> function,
422 /// care should be taken that your jitter sequence never generates a null vector;
423 /// that is value of 0 in both the X and Y dimensions.
424 ///
425 /// @param [out] outX A pointer to a <c>float</c> which will contain the subpixel jitter offset for the x dimension.
426 /// @param [out] outY A pointer to a <c>float</c> which will contain the subpixel jitter offset for the y dimension.
427 /// @param [in] index The index within the jitter sequence.
428 /// @param [in] phaseCount The length of jitter phase. See <c><i>ffxFsr2GetJitterPhaseCount</i></c>.
429 ///
430 /// @retval
431 /// FFX_OK The operation completed successfully.
432 /// @retval
433 /// FFX_ERROR_INVALID_POINTER Either <c><i>outX</i></c> or <c><i>outY</i></c> was <c>NULL</c>.
434 /// @retval
435 /// FFX_ERROR_INVALID_ARGUMENT Argument <c><i>phaseCount</i></c> must be greater than 0.
436 ///
437 /// @ingroup FSR2
438 FFX_API FfxErrorCode ffxFsr2GetJitterOffset(float* outX, float* outY, int32_t index, int32_t phaseCount);
439
440 /// A helper function to check if a resource is
441 /// <c><i>FFX_FSR2_RESOURCE_IDENTIFIER_NULL</i></c>.
442 ///
443 /// @param [in] resource A <c><i>FfxResource</i></c>.
444 ///
445 /// @returns
446 /// true The <c><i>resource</i></c> was not <c><i>FFX_FSR2_RESOURCE_IDENTIFIER_NULL</i></c>.
447 /// @returns
448 /// false The <c><i>resource</i></c> was <c><i>FFX_FSR2_RESOURCE_IDENTIFIER_NULL</i></c>.
449 ///
450 /// @ingroup FSR2
451 FFX_API bool ffxFsr2ResourceIsNull(FfxResource resource);
452
453 #if defined(__cplusplus)
454 }
455 #endif // #if defined(__cplusplus)