1 /*---------------------------------------------------------------------------*
2 
3   Copyright (C) Nintendo.  All rights reserved.
4 
5   These coded instructions, statements, and computer programs contain
6   proprietary information of Nintendo of America Inc. and/or Nintendo
7   Company Ltd., and are protected by Federal copyright law.  They may
8   not be disclosed to third parties or copied or duplicated in any form,
9   in whole or in part, without the prior written consent of Nintendo.
10 
11  *---------------------------------------------------------------------------*/
12 
13 // gx2Texture.h
14 //
15 // Declares texture-related types & functions for gx2 library.
16 
17 #ifndef _CAFE_GX2_TEXTURE_H_
18 #define _CAFE_GX2_TEXTURE_H_
19 
20 #ifdef __cplusplus
21 extern "C"
22 {
23 #endif // __cplusplus
24 
25 /// @addtogroup GX2TextureGroup
26 /// @{
27 
28 /// @addtogroup GX2TextureSurfaceGroup
29 /// @{
30 
31 // -----------------
32 // GX2Texture.h
33 
34 // !!!Note!!! - The GX2Texture structure is burned into .gtx file.
35 // Altering parameters or changing their order may invalidate all existing content.
36 
37 /// \brief Completely describes a texture.
38 ///
39 /// In addition to GX2Surface, includes user fields to describe a texture.
40 /// Also includes hardware register settings for the same purpose.
41 /// It allows mip levels & array slices to be limited from what the surface
42 /// specifies.  This may be handy when not all images have been loaded yet.
43 ///
44 typedef struct _GX2Texture {
45 
46     /// main surface description
47     GX2Surface surface;
48 
49     /// (user) first mip level that's available (usually 0)
50     /// This value should be between 0 (the largest level) and surface.numMips-1.
51     u32 viewFirstMip;
52     /// (user) number of mip levels available (usually same as surface value).
53     /// 0 implies 1. This value should be between 1 and (surface.numMips - viewFirstMip).
54     u32 viewNumMips;
55     /// (user) start slice in the array or 3D surface (usually 0)
56     /// This value should be between 0 and surface.depth-1.
57     u32 viewFirstSlice;
58     /// (user) number of slices available (usually same as surface depth)
59     /// 0 implies 1. This value should be between 1 and (surface.depth - viewFirstSlice).
60     u32 viewNumSlices;
61 
62     /// (user) used to set the component swap (routing) selection
63     GX2CompSel compSel;
64 
65     /// (calc) private, calculated by driver
66     u32 _regs[GX2_NUM_TEXTURE_REGISTERS];
67 
68 } GX2Texture;
69 
70 /// \brief Given a texture structure with user fields set, fill in register values.
71 ///
72 /// \param texture Ptr to texture structure to update.
73 ///
74 /// \donotcall \threadsafe \devonly \enddonotcall
75 ///
76 void GX2API GX2InitTextureRegs(GX2Texture *texture);
77 
78 /// \brief Set the given texture to be used in a vertex shader.
79 ///
80 /// \param texture Ptr to texture structure to use; all fields & registers should already be initialized.
81 /// \param textureUnitNumber Which texture unit to configure (from shader sampler var location).
82 ///
83 /// \donotcall \gx2_typical \enddonotcall
84 ///
85 /// \writesgpu
86 /// \alwayswritesgpu
87 ///
88 void GX2API GX2SetVertexTexture(const GX2Texture *texture, u32 textureUnitNumber);
89 
90 /// \brief Set the given texture to be used in a geometry shader.
91 ///
92 /// \param texture Ptr to texture structure to use; all fields & registers should already be initialized.
93 /// \param textureUnitNumber Which texture unit to configure (from shader sampler var location).
94 ///
95 /// \donotcall \gx2_typical \enddonotcall
96 ///
97 /// \writesgpu
98 /// \alwayswritesgpu
99 ///
100 void GX2API GX2SetGeometryTexture(const GX2Texture *texture, u32 textureUnitNumber);
101 
102 /// \brief Set the given texture to be used in a pixel shader.
103 ///
104 /// \param texture Ptr to texture structure to use; all fields & registers should already be initialized.
105 /// \param textureUnitNumber Which texture unit to configure (from shader sampler var location).
106 ///
107 /// \donotcall \gx2_typical \enddonotcall
108 ///
109 /// \writesgpu
110 /// \alwayswritesgpu
111 ///
112 void GX2API GX2SetPixelTexture(const GX2Texture *texture, u32 textureUnitNumber);
113 
114 /// \brief Set the given texture to be used in a compute shader.
115 ///
116 /// \ingroup GX2ShaderComputeGroup
117 ///
118 /// For more information about Compute Shaders see \ref GX2ComputePage "GX2 Compute Shaders"
119 ///
120 /// \param texture Ptr to texture structure to use; all fields & registers should already be initialized.
121 /// \param textureUnitNumber Which texture unit to configure (from shader sampler var location).
122 ///
123 /// \donotcall \gx2_typical \enddonotcall
124 ///
125 /// \writesgpu
126 /// \alwayswritesgpu
127 ///
128 void GX2API GX2SetComputeTexture(const GX2Texture *texture, u32 textureUnitNumber);
129 
130 /// \brief Helper function to set up texture structure in a convenient way.
131 ///
132 /// \note   The image pointers are set using \ref GX2InitTexturePtrs.
133 ///
134 /// \note   Certain advanced options are set to defaults.  You must
135 ///         be very careful if you wish to use non-default values
136 ///         for aa, use, tileMode, or swizzle.  Please refer to
137 ///         \ref GX2TexturePage for more details.
138 ///
139 /// \param texture Ptr to texture structure to initialize.
140 /// \param width   Desired width for texture.
141 /// \param height  Desired height for texture.
142 /// \param depth   Desired depth for texture (use 1 for 2D).
143 /// \param numMips Desired number of mipmap levels for texture (use 1 for base level only).
144 /// \param format  Desired surface format for texture.
145 /// \param dim     Desired dimensionality for texture.
146 ///
147 /// \donotcall \threadsafe \devonly \enddonotcall
148 ///
GX2InitTexture(GX2Texture * texture,u32 width,u32 height,u32 depth,u32 numMips,GX2SurfaceFormat format,GX2SurfaceDim dim)149 GX2_INLINE void GX2InitTexture(GX2Texture *texture, u32 width, u32 height,
150                            u32 depth, u32 numMips,
151                            GX2SurfaceFormat format, GX2SurfaceDim dim)
152 {
153     const GX2CompSel dstSel[54] = {
154         GX2_COMP_SEL_NONE, GX2_COMP_SEL_X001, GX2_COMP_SEL_XY01, GX2_COMP_SEL_NONE, // 00-03
155         GX2_COMP_SEL_NONE, GX2_COMP_SEL_X001, GX2_COMP_SEL_X001, GX2_COMP_SEL_XY01, // 04-07
156         GX2_COMP_SEL_XYZ1, GX2_COMP_SEL_XYZ1, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_XYZW, // 08-0b
157         GX2_COMP_SEL_WZYX, GX2_COMP_SEL_X001, GX2_COMP_SEL_X001, GX2_COMP_SEL_XY01, // 0c-0f
158         GX2_COMP_SEL_XY01, GX2_COMP_SEL_NONE, GX2_COMP_SEL_NONE, GX2_COMP_SEL_NONE, // 10-13
159         GX2_COMP_SEL_NONE, GX2_COMP_SEL_NONE, GX2_COMP_SEL_XYZ1, GX2_COMP_SEL_NONE, // 14-17
160         GX2_COMP_SEL_NONE, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_WZYX, // 18-1b
161         GX2_COMP_SEL_XY01, GX2_COMP_SEL_XY01, GX2_COMP_SEL_XY01, GX2_COMP_SEL_XYZW, // 1c-1f
162         GX2_COMP_SEL_XYZW, GX2_COMP_SEL_NONE, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_XYZW, // 20-23
163         GX2_COMP_SEL_NONE, GX2_COMP_SEL_NONE, GX2_COMP_SEL_NONE, GX2_COMP_SEL_XYZ1, // 24-27
164         GX2_COMP_SEL_XYZ1, GX2_COMP_SEL_X001, GX2_COMP_SEL_XY01, GX2_COMP_SEL_XYZ1, // 28-2b
165         GX2_COMP_SEL_NONE, GX2_COMP_SEL_NONE, GX2_COMP_SEL_NONE, GX2_COMP_SEL_XYZ1, // 2c-2f
166         GX2_COMP_SEL_XYZ1, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_XYZW, // 30-33
167         GX2_COMP_SEL_X001, GX2_COMP_SEL_XY01 };                                     // 34-35
168 
169     GX2_CHECK_ENUM_RANGE(format, GX2_SURFACE_FORMAT);
170     GX2_CHECK_ENUM_RANGE(dim, GX2_SURFACE_DIM);
171 
172     // Set user surface values
173     texture->surface.dim     = dim;
174     texture->surface.width   = width;
175     texture->surface.height  = height;
176     texture->surface.depth   = depth;
177     texture->surface.numMips = numMips;
178     texture->surface.format  = format;
179 
180     // Set most common default surface values
181     texture->surface.aa         = GX2_AA_MODE_1X; // if not 1X, must change dim field
182     texture->surface.use        = GX2_SURFACE_USE_TEXTURE;
183 #ifdef GX2_ENABLE_FIX2197
184     texture->surface.tileMode = GX2_TILE_MODE_DEFAULT_FIX2197;
185 #else
186     texture->surface.tileMode = GX2_TILE_MODE_DEFAULT;
187 #endif
188     texture->surface.swizzle    = 0;
189 
190     // Set typical view values
191     texture->viewFirstMip   = 0;
192     texture->viewNumMips    = numMips;
193     texture->viewFirstSlice = 0;
194     texture->viewNumSlices  = depth;
195 
196     // Set default component selector
197     texture->compSel = dstSel[(format) & 0x3f];
198 
199     // Calculate the size, alignment, pitch, and mipOffset values
200     GX2CalcSurfaceSizeAndAlignment(&texture->surface);
201 
202     // Now set up the registers based on those values
203     GX2InitTextureRegs(texture);
204 }
205 
206 /// \brief Function set up custom component selection.
207 /// Requires calling GX2InitTextureRegs() afterwards.
208 ///
209 /// \param texture Ptr to texture structure to update.
210 /// \param compSel New component swap selection value (see \ref GX2UTGroup).
211 ///
212 /// \donotcall \threadsafe \devonly \enddonotcall
213 ///
GX2InitTextureCompSel(GX2Texture * texture,GX2CompSel compSel)214 GX2_INLINE void GX2InitTextureCompSel(GX2Texture *texture, GX2CompSel compSel)
215 {
216     texture->compSel = compSel;
217 }
218 
219 /// \brief Helper function to set up texture image pointers.
220 /// Does not require calling GX2InitTextureRegs() afterwards.
221 ///
222 /// \param texture  Ptr to texture structure to update.
223 /// \param imagePtr New image pointer value; points to level 0 image.
224 /// \param mipPtr   New mip pointer value; points to level 1+ image(s).
225 ///
226 /// \donotcall \threadsafe \devonly \enddonotcall
227 ///
GX2InitTexturePtrs(GX2Texture * texture,void * imagePtr,void * mipPtr)228 GX2_INLINE void GX2InitTexturePtrs(GX2Texture *texture, void *imagePtr, void *mipPtr)
229 {
230     texture->surface.imagePtr = imagePtr;
231     if (texture->surface.numMips > 1) {
232         if (mipPtr) {
233             texture->surface.mipPtr = mipPtr;
234         } else {
235             texture->surface.mipPtr = (void *) ( (u32) imagePtr + texture->surface.mipOffset[0]);
236         }
237     } else {
238         texture->surface.mipPtr = mipPtr;
239     }
240 }
241 
242 /// \brief Convert a linear format image into a tiled format texture.
243 ///
244 /// The present implementation uses CPU only (it is slow).
245 /// The given texture structure should already be initialized,
246 /// and it should have its imagePtr properly aligned & allocated as well.
247 /// See also notes at \ref GX2CopySurface.
248 ///
249 /// \param dstTexture  Ptr to texture structure to update.
250 /// \param srcImagePtr Ptr to source linear image data.
251 ///
252 /// \donotcall \gx2_typical \enddonotcall
253 ///
254 /// \writesgpu
255 /// \alwayswritesgpu
256 ///
GX2TileTexture(GX2Texture * dstTexture,void * srcImagePtr)257 GX2_INLINE void GX2TileTexture(GX2Texture* dstTexture, void *srcImagePtr)
258 {
259     GX2Surface srcSurf;
260     ASSERT(dstTexture && srcImagePtr);
261     srcSurf = dstTexture->surface;
262     srcSurf.tileMode = GX2_TILE_MODE_LINEAR_SPECIAL;
263     srcSurf.imagePtr = srcImagePtr;
264     GX2CalcSurfaceSizeAndAlignment(&srcSurf);
265     // Make sure the source texture data is in memory
266     GX2Invalidate(GX2_INVALIDATE_CPU_TEXTURE, srcImagePtr, srcSurf.imageSize);
267     GX2CopySurface(&srcSurf, 0, 0, &dstTexture->surface, 0, 0);
268 }
269 
270 /// @}
271 /// @addtogroup GX2TextureSamplerGroup
272 /// @{
273 
274 //----------------------------------------------------------------------
275 // Texture Samplers
276 
277 /// \brief Structure to contain all sampler (register) settings.
278 ///
279 typedef struct _GX2Sampler {
280     u32 samplerReg[3];  // sampler (filtering) related settings
281 } GX2Sampler;
282 
283 /// \brief Initialize a texture sampler with some basic settings and common defaults
284 ///
285 /// By default, Z and Mip filters are set to point sampling, max aniso is set to 1,
286 /// border type is set to transparent black, LOD is unrestricted/unchanged, high
287 /// precision filter is off, and perf options are default.  Use the other sampler APIs
288 /// to change these values.
289 ///
290 /// \param sampler Ptr to texture sampler structure to initialize.
291 /// \param clampAll Clamping mode for X/Y/Z dimensions.
292 /// \param minMagFilter Minification and magnification filters to use for X & Y dimensions.
293 ///
294 /// \donotcall \threadsafe \devonly \enddonotcall
295 ///
296 void GX2API GX2InitSampler(GX2Sampler *sampler,
297                            GX2TexClamp clampAll,
298                            GX2TexXYFilterType minMagFilter);
299 
300 /// \brief Function to change sampler clamp settings.
301 ///
302 /// \param sampler Ptr to texture sampler structure to update.
303 /// \param clampX  Texture coordinate clamp option for X dimension.
304 /// \param clampY  Texture coordinate clamp option for Y dimension.
305 /// \param clampZ  Texture coordinate clamp option for Z dimension.
306 ///
307 /// \donotcall \threadsafe \devonly \enddonotcall
308 ///
309 void GX2API GX2InitSamplerClamping(GX2Sampler *sampler,
310                                    GX2TexClamp clampX,
311                                    GX2TexClamp clampY,
312                                    GX2TexClamp clampZ);
313 
314 /// \brief Function to change sampler XY filter settings.
315 ///
316 /// \param sampler   Ptr to texture sampler structure to update.
317 /// \param magFilter Sampling to perform when images are magnified.
318 /// \param minFilter Sampling to perform when images are minified.
319 /// \param maxAniso  Maximum level of anisotropic filtering to apply.  Use 1:1 to disable aniso filtering.
320 ///
321 /// \donotcall \threadsafe \devonly \enddonotcall
322 ///
323 void GX2API GX2InitSamplerXYFilter(GX2Sampler *sampler,
324                                    GX2TexXYFilterType magFilter,
325                                    GX2TexXYFilterType minFilter,
326                                    GX2TexAnisoRatio maxAniso);
327 
328 /// \brief Function to change sampler Z & mip filter settings.
329 ///
330 /// \param sampler   Ptr to texture sampler structure to update.
331 /// \param zFilter   Sampling to perform across image Z planes.
332 /// \param mipFilter Sampling to perform across mip levels.
333 ///
334 /// \donotcall \threadsafe \devonly \enddonotcall
335 ///
336 void GX2API GX2InitSamplerZMFilter(GX2Sampler *sampler,
337                                    GX2TexZFilterType zFilter,
338                                    GX2TexMipFilterType mipFilter);
339 
340 /// \brief Function to change sampler LOD settings.
341 ///
342 /// LOD is calculated as a fractional number based on the texel:pixel ratio.
343 /// The whole part of the value determines which mip level or levels are
344 /// accessed, and the fraction determines the interpolation between them
345 /// (for trilinear filtering) or the transition point (for bilinear).
346 ///
347 /// \note This function allows additional restrictions on access to mip levels
348 ///       beyond what the texture itself specifies.  It is okay to leave these
349 ///       values at their maximum extents.
350 ///
351 /// \note The valid LOD range is 0 ... 15.999.
352 /// \note The valid bias range is -32 ... 31.999.
353 ///
354 /// \note The sampler's LOD is relative to the texture's view, defined by viewFirstMip
355 ///       and viewNumMips. LOD 0 is the largest and most detailed mip level allowed
356 ///       by the view.  maxLOD should be greater than or equal to minLOD.
357 ///       To limit the LOD to a single mipmap both minLOD and maxLOD should be set
358 ///       to the same value.
359 ///
360 /// \param sampler   Ptr to texture sampler structure to update.
361 /// \param minLOD    Lower bound for mip LOD level calculation. The is relative to the texture's view.
362 /// \param maxLOD    Upper bound for mip LOD level calculation. This should be >= minLOD.
363 ///                  This is relative to the texture's view.
364 /// \param LODBias   A bias value for LOD applied prior to applying min/max constraints.
365 ///
366 /// \donotcall \threadsafe \devonly \enddonotcall
367 ///
368 void GX2API GX2InitSamplerLOD(GX2Sampler *sampler,
369                               f32 minLOD,
370                               f32 maxLOD,
371                               f32 LODBias);
372 
373 /// \brief Sets the type of border used by sampler
374 /// \note It's better to avoid using the register color type, as setting
375 ///       those registers requires a pipeline stall.
376 ///
377 /// \param sampler   Ptr to texture sampler structure to update.
378 /// \param border    Type of border color to use.
379 ///
380 /// \donotcall \threadsafe \devonly \enddonotcall
381 ///
382 void GX2API GX2InitSamplerBorderType(GX2Sampler *sampler,
383                                      GX2TexBorderType border);
384 
385 /// \brief Function to change sampler rounding modes.
386 ///
387 /// \param sampler Ptr to texture sampler structure to update.
388 /// \param roundingMode  Texture coordinate rounding mode.
389 ///
390 /// Setting the rounding mode effects how texture coordinates are truncated.
391 /// The default GX2 behavior is \ref GX2_ROUNDING_MODE_ROUND_TO_EVEN.
392 ///
393 /// This is provided to work around an issue where point-sampled textures
394 /// may unexpectedly wrap when a given mipmap level is magnified more than
395 /// 64 times its original size. In this case, \ref GX2_ROUNDING_MODE_TRUNCATE
396 /// should be used.
397 ///
398 /// \warning Setting \ref GX2_ROUNDING_MODE_TRUNCATE should only be set when
399 ///          the following are true. See \ref GX2TextureCoordinateRoundingSect
400 ///          for more details.
401 ///          -# \c minFilter and \c magFilter are \ref GX2_TEX_XY_FILTER_POINT
402 ///          -# \c clampX, \c clampY or \c clampZ are \ref GX2_TEX_CLAMP_WRAP
403 ///
404 /// \warning Changing the rounding mode to \ref GX2_ROUNDING_MODE_TRUNCATE will
405 ///          affect bilinear interpolation. It is recommended that a separate
406 ///          sampler is allocated for this purpose to avoid unintended sampling
407 ///          differences.
408 ///
409 /// \donotcall \threadsafe \devonly \enddonotcall
410 ///
411 void GX2API GX2InitSamplerRoundingMode(GX2Sampler *sampler,
412                                        GX2RoundingModeType roundingMode);
413 
414 /// \brief Set the border color to be used by vertex-shader texture sampler.
415 ///
416 /// \note Calling this function will result in a graphics pipeline stall.
417 /// Calling it too frequently will result in a loss of performance.
418 ///
419 /// \param samplerUnitNumber Which sampler unit to configure (from shader sampler var location).
420 /// \param red               Red color component value for border color (0.0 - 1.0).
421 /// \param green             Green color component value for border color (0.0 - 1.0).
422 /// \param blue              Blue color component value for border color (0.0 - 1.0).
423 /// \param alpha             Alpha color component value for border color (0.0 - 1.0).
424 ///
425 /// \donotcall \gx2_typical \enddonotcall
426 ///
427 /// \writesgpu
428 /// \alwayswritesgpu
429 ///
430 void GX2API GX2SetVertexSamplerBorderColor(u32 samplerUnitNumber,
431           f32 red, f32 green, f32 blue, f32 alpha);
432 
433 /// \brief Set the border color to be used by geometry-shader texture sampler.
434 ///
435 /// \note Calling this function will result in a graphics pipeline stall.
436 /// Calling it too frequently will result in a loss of performance.
437 ///
438 /// \param samplerUnitNumber Which sampler unit to configure (from shader sampler var location).
439 /// \param red               Red color component value for border color (0.0 - 1.0).
440 /// \param green             Green color component value for border color (0.0 - 1.0).
441 /// \param blue              Blue color component value for border color (0.0 - 1.0).
442 /// \param alpha             Alpha color component value for border color (0.0 - 1.0).
443 ///
444 /// \donotcall \gx2_typical \enddonotcall
445 ///
446 /// \writesgpu
447 /// \alwayswritesgpu
448 ///
449 void GX2API GX2SetGeometrySamplerBorderColor(u32 samplerUnitNumber,
450           f32 red, f32 green, f32 blue, f32 alpha);
451 
452 /// \brief Set the border color to be used by pixel-shader texture sampler.
453 ///
454 /// \note Calling this function will result in a graphics pipeline stall.
455 /// Calling it too frequently will result in a loss of performance.
456 ///
457 /// \param samplerUnitNumber Which sampler unit to configure (from shader sampler var location).
458 /// \param red               Red color component value for border color (0.0 - 1.0).
459 /// \param green             Green color component value for border color (0.0 - 1.0).
460 /// \param blue              Blue color component value for border color (0.0 - 1.0).
461 /// \param alpha             Alpha color component value for border color (0.0 - 1.0).
462 ///
463 /// \donotcall \gx2_typical \enddonotcall
464 ///
465 /// \writesgpu
466 /// \alwayswritesgpu
467 ///
468 void GX2API GX2SetPixelSamplerBorderColor(u32 samplerUnitNumber,
469           f32 red, f32 green, f32 blue, f32 alpha);
470 
471 /// \brief Set the border color to be used by compute-shader texture sampler.
472 /// \ingroup GX2ShaderComputeGroup
473 ///
474 /// \note Calling this function will result in a graphics pipeline stall.
475 /// Calling it too frequently will result in a loss of performance.
476 ///
477 /// For more information about Compute Shaders see \ref GX2ComputePage "GX2 Compute Shaders"
478 ///
479 /// \param samplerUnitNumber Which sampler unit to configure (from shader sampler var location).
480 /// \param red               Red color component value for border color (0.0 - 1.0).
481 /// \param green             Green color component value for border color (0.0 - 1.0).
482 /// \param blue              Blue color component value for border color (0.0 - 1.0).
483 /// \param alpha             Alpha color component value for border color (0.0 - 1.0).
484 ///
485 /// \donotcall \gx2_typical \enddonotcall
486 ///
487 /// \writesgpu
488 /// \alwayswritesgpu
489 ///
490 void GX2API GX2SetComputeSamplerBorderColor(u32 samplerUnitNumber,
491           f32 red, f32 green, f32 blue, f32 alpha);
492 
493 /// \brief Sets the depth compare function when a shadow-type sampler is applied
494 ///
495 /// \note This does not make the sampler into a shadow type; that is
496 /// decided by how the sampler is declared in the shader.
497 ///
498 /// \param sampler   Ptr to texture sampler structure to update.
499 /// \param depthCompare Which depth comparison function to use.
500 ///
501 /// \donotcall \threadsafe \devonly \enddonotcall
502 ///
503 void GX2API GX2InitSamplerDepthCompare(GX2Sampler *sampler,
504                                        GX2CompareFunction depthCompare);
505 
506 /// \brief Used to tweak various advanced filtering performance options
507 ///
508 /// \param sampler   Ptr to texture sampler structure to update.
509 /// \param highPrecision If true, forces all formats to be converted to 32 bit float components, 2 channels/clock.
510 /// \param perfMip       Selects one of 8 lookup tables to adjust the linear mipmap transition performance/quality tradeoff.
511 /// \param perfZ         Selects one of 4 lookup tables to adjust the linear Z filter performance/quality tradeoff.
512 ///
513 /// \donotcall \threadsafe \devonly \enddonotcall
514 ///
515 void GX2API GX2InitSamplerFilterAdjust(GX2Sampler *sampler,
516                                        GX2Boolean highPrecision,
517                                        GX2TexMipPerfType perfMip,
518                                        GX2TexZPerfType perfZ);
519 
520 /// \brief Used to tweak various advanced filtering aniso/LOD options
521 ///
522 /// The valid bias range is 0 ... 1.999.
523 ///
524 /// \param sampler   Ptr to texture sampler structure to update.
525 /// \param anisoBias A number that is subtracted from the computed aniso ratio, reducing the number of samples taken.
526 /// \param lodUsesMinorAxis Forces the hardware to use minor axis for LOD calculation (for special shadow buffer path).
527 ///
528 /// \donotcall \threadsafe \devonly \enddonotcall
529 ///
530 void GX2API GX2InitSamplerLODAdjust(GX2Sampler *sampler,
531                                     f32 anisoBias,
532                                     GX2Boolean lodUsesMinorAxis);
533 
534 
535 /// \brief Set the sampler to be used by vertex shader.
536 ///
537 /// \param sampler   Ptr to texture sampler structure to use.
538 /// \param samplerUnitNumber Which sampler unit to configure (from shader sampler var location).
539 ///
540 /// \donotcall \gx2_typical \enddonotcall
541 ///
542 /// \writesgpu
543 /// \alwayswritesgpu
544 ///
545 void GX2API GX2SetVertexSampler(const GX2Sampler *sampler, u32 samplerUnitNumber);
546 
547 /// \brief Set the sampler to be used by geometry shader.
548 ///
549 /// \param sampler   Ptr to texture sampler structure to use.
550 /// \param samplerUnitNumber Which sampler unit to configure (from shader sampler var location).
551 ///
552 /// \donotcall \gx2_typical \enddonotcall
553 ///
554 /// \writesgpu
555 /// \alwayswritesgpu
556 ///
557 void GX2API GX2SetGeometrySampler(const GX2Sampler *sampler, u32 samplerUnitNumber);
558 
559 /// \brief Set the sampler to be used by pixel shader.
560 ///
561 /// \param sampler   Ptr to texture sampler structure to use.
562 /// \param samplerUnitNumber Which sampler unit to configure (from shader sampler var location).
563 ///
564 /// \donotcall \gx2_typical \enddonotcall
565 ///
566 /// \writesgpu
567 /// \alwayswritesgpu
568 ///
569 void GX2API GX2SetPixelSampler(const GX2Sampler *sampler, u32 samplerUnitNumber);
570 
571 /// \brief Set the sampler to be used by compute shader.
572 /// \ingroup GX2ShaderComputeGroup
573 ///
574 /// For more information about Compute Shaders see \ref GX2ComputePage "GX2 Compute Shaders"
575 ///
576 /// \param sampler   Ptr to texture sampler structure to use.
577 /// \param samplerUnitNumber Which sampler unit to configure (from shader sampler var location).
578 ///
579 /// \donotcall \gx2_typical \enddonotcall
580 ///
581 /// \writesgpu
582 /// \alwayswritesgpu
583 ///
584 void GX2API GX2SetComputeSampler(const GX2Sampler *sampler, u32 samplerUnitNumber);
585 
586 /// @}
587 
588 /// @}
589 
590 #ifdef __cplusplus
591 }
592 #endif // __cplusplus
593 
594 #endif // _CAFE_GX2_TEXTURE_H_
595