Common nn::gfx

From EPD Wiki
Jump to navigation Jump to search

Structures and enums from nn::gfx appearing across nn::gfx file formats and nn::g3d file formats. Notably the nn::gfx formats Bnsh and Bntx, as well as nn::g3d Bfres.

nn::gfx::MemoryPoolFlags

Flags denoting how a memory pool can be accessed.

Name (Unofficial) Value Description
CpuNoAccess 0x1 (1 << 0) Memory is unable to be mapped to CPU
CpuUncached 0x2 (1 << 1) Memory is coherent on CPU
CpuCached 0x4 (1 << 2) Memory is cached on CPU
GpuNoAccess 0x8 (1 << 3) Memory is unable to be read by the GPU
GpuUncached 0x10 (1 << 4) Memory is coherent on GPU
GpuCached 0x20 (1 << 5) Memory is cached on GPU
ShaderCode 0x40 (1 << 6) Memory is shader code for the GPU
Compressible 0x80 (1 << 7) ???
Physical 0x100 (1 << 8) ???
Virtual 0x200 (1 << 9) ???

nn::gfx::MemoryPoolInfo

Offset Size Type Description
0x0 0x4 u32 (nn::gfx::MemoryPoolFlags) MemoryPool flags
0x4 0x4 u32 Memory size
0x8 0x8 void * Memory pointer (must be 0x1000 aka page aligned)

nn::gfx::GpuAccessFlags

Flags denoting how a buffer or texture will be accessed.

Name (Unofficial) Value Description
VertexBuffer 0x4 (1 << 2) Vertex buffer
IndexBuffer 0x8 (1 << 3) Index buffer
UniformBuffer 0x10 (1 << 4) Uniform/Storage buffer
Texture 0x20 (1 << 5) Texture
TransferDestination 0x40 (1 << 6) Transfer destination
RenderTargetColor 0x80 (1 << 7) For render target colors
RenderTargetDepth 0x100 (1 << 8) For render target depths
IndirectDraw 0x200 (1 << 9) For indirect draw commands
DisplayTexture 0x400 (1 << 10) For present
Counter 0x800 (1 << 11) ???

nn::gfx::BufferInfo

Offset Size Type Description
0x0 0x4 u32 Buffer size
0x4 0x4 u32 (nn::gfx::GpuAccessFlags) GPU access flags
0x8 0x4 u32 Reserved
0xc 0x4 u32 Reserved

nn::gfx:::ImageStorageDimension

Name (Unofficial) Value Description
Type1D 0x1
Type2D 0x2
Type3D 0x3

nn::gfx::TileMode (Unofficial)

Name (Unofficial) Value Description
Optimal 0x0
Linear 0x1

nn::gfx::ChannelFormat

Name (Unofficial) Value Description
None 0x1
R8 0x2
R4G4B4A4 0x3
R5G5B5A1 0x5
A1B5G5R5 0x6
R5G6B5 0x7
B5G6R5 0x8
R8G8 0x9
R16 0xa
R8G8B8A8 0xb
B8G8R8A8 0xc
R9G9B9E5F 0xd
R10G10B10A2 0xe
R11G11B10F 0xf
R16G16 0x12
D24S8 0x13
R32 0x14
R16G16B16A16 0x15
D32FS8 0x16
R32G32 0x17
R32G32B32 0x18
R32G32B32A32 0x19
BC1 0x1a
BC2 0x1b
BC3 0x1c
BC4 0x1d
BC5 0x1e
BC6H 0x1f
BC7U 0x20
ASTC_4x4 0x2d
ASTC_5x4 0x2e
ASTC_5x5 0x2f
ASTC_6x5 0x30
ASTC_6x6 0x31
ASTC_8x5 0x32
ASTC_8x6 0x33
ASTC_8x8 0x34
ASTC_10x5 0x35
ASTC_10x6 0x26
ASTC_10x8 0x37
ASTC_10x10 0x38
ASTC_12x10 0x39
ASTC_12x12 0x3a
B5G5R5A1 0x3b

nn::gfx::TypeFormat

Name (Unofficial) Value Description
Unorm 0x1
Snorm 0x2
UInt 0x3
SInt 0x4
Float 0x5
SRGB 0x6
Depth 0x7
UScaled 0x8
SScaled 0x9
UFloat 0xa

nn::gfx::ImageFormat

Image formats are formed by a ChannelFormat and a TypeFormat. ImageFormat = (ChannelFormat << 8) | TypeFormat

Name (Unofficial) Value Description
R8_Unorm
R8_Snorm
R8_UInt
R8_SInt
R4G4B4A4_Unorm
R5G5B5A1_Unorm
A1B5G5R5_Unorm
R5G6B5_Unorm
B5G6R5_Unorm
R8G8_Unorm
R8G8_Snorm
R8G8_UInt
R8G8_SInt
R16_Unorm
R16_Snorm
R16_UInt
R16_SInt
R16_Float
Z16_Depth
R8G8B8A8_Unorm
R8G8B8A8_Snorm
R8G8B8A8_UInt
R8G8B8A8_SInt
R8G8B8A8_SRGB
B8G8R8A8_Unorm
B8G8R8A8_SRGB
R9G9B9E5F_SharedFloat
R10G10B10A2_Unorm
R10G10B10A2_UInt
R11G11B10F_Float
R16G16_Unorm
R16G16_Snorm
R16G16_UInt
R16G16_SInt
R16G16_Float
D24S8_Depth
R32_UInt
R32_SInt
R32_Float
D32F_Depth
R16G16B16A16_Unorm
R16G16B16A16_Snorm
R16G16B16A16_UInt
R16G16B16A16_SInt
R16G16B16A16_Float
D32FS8_Depth
R32G32_UInt
R32G32_SInt
R32G32_Float
R32G32B32_UInt
R32G32B32_SInt
R32G32B32_Float
R32G32B32A32_UInt
R32G32B32A32_SInt
R32G32B32A32_Float
BC1_Unorm
BC1_SRGB
BC2_Unorm
BC2_SRGB
BC3_Unorm
BC3_SRGB
BC4_Unorm
BC4_Snorm
BC5_Unorm
BC5_Snorm
BC6H_SF16
BC6H_UF16
BC7U_Unorm
BC7U_SRGB
ASTC_4X4_Unorm
ASTC_4X4_SRGB
ASTC_5X4_Unorm
ASTC_5X4_SRGB
ASTC_5X5_Unorm
ASTC_5X5_SRGB
ASTC_6X5_Unorm
ASTC_6X5_SRGB
ASTC_6X6_Unorm
ASTC_6X6_SRGB
ASTC_8X5_Unorm
ASTC_8X5_SRGB
ASTC_8X6_Unorm
ASTC_8X6_SRGB
ASTC_8X8_Unorm
ASTC_8X8_SRGB
ASTC_10X5_Unorm
ASTC_10X5_SRGB
ASTC_10X6_Unorm
ASTC_10X6_SRGB
ASTC_10X8_Unorm
ASTC_10X8_SRGB
ASTC_10X10_Unorm
ASTC_10X10_SRGB
ASTC_12X10_Unorm
ASTC_12X10_SRGB
ASTC_12X12_Unorm
ASTC_12X12_SRGB
B5G5R5A1_Unorm

nn::gfx::TextureInfo

Offset Size Type Description
0x0:0 1 bit u8 Is Packaged Texture
0x0:1 1 bit u8 Is Sparse Binding
0x0:2 1 bit u8 Is Sparse
0x0:3 1 bit u8 Is ResTexture
0x0:4 4 bit u8 Reserved
0x1 0x1 u8 Storage dimension (nn::gfx::ImageStorageDimension)
0x2 0x2 u16 Tile mode (nn::gfx::TileMode)
0x4 0x2 u16 Swizzle (???)
0x6 0x2 u16 Mip levels
0x8 0x2 u16 Sample count
0xa 0x2 u16 Reserved
0xc 0x4 u32 Image format (nn::gfx::ImageFormat)
0x10 0x4 u32 Gpu access flags (nn::gfx::GpuAccessFlags)
0x14 0x4 u32 Width
0x18 0x4 u32 Height
0x1c 0x4 u32 Depth
0x20 0x4 u32 Array layers
0x24 0x4 u32 Packaged texture layout (???)

nn::gfx::TextureAddressMode

Name (Unofficial) Value Description
Repeat 0x0
MirrorRepeat 0x1
ClampToEdge 0x2
ClampToBorder 0x3
MirrorClampToBorder 0x4

nn::gfx::ComparisonFunction

Name (Unofficial) Value Description
Never 0x0
LessThan 0x1
Equal 0x2
LessThanEqual 0x3
GreateThan 0x4
NotEqual 0x5
GreaterThanEqual 0x6
Always 0x7

nn::gfx::BorderColor (Unofficial)

Name (Unofficial) Value Description
White 0x0
TransparentBlack 0x1
Black 0x2

nn::gfx::MipMapFilter (Unofficial)

Name (Unofficial) Value Description
None 0x0
Nearest 0x1
Linear 0x2

nn::gfx::MagFilter (Unofficial)

Name (Unofficial) Value Description
Invalid 0x0
Nearest 0x1
Linear 0x2

nn::gfx::MinFilter (Unofficial)

Name (Unofficial) Value Description
Invalid 0x0
Nearest 0x1
Linear 0x2

nn::gfx::ReductionFilter (Unofficial)

Name (Unofficial) Value Description
Average 0x0
Min 0x1
Max 0x2

nn::gfx::SamplerInfo

Offset Size Type Description
0x0 0x1 u8 Wrap Mode U (nn::gfx::TextureAddressMode)
0x1 0x1 u8 Wrap Mode V (nn::gfx::TextureAddressMode)
0x2 0x1 u8 Wrap Mode W (nn::gfx::TextureAddressMode)
0x3 0x1 u8 CompareOp (nn::gfx::ComparisonFunction)
0x4 0x1 u8 Border color (nn::gfx::BorderColor)
0x5 0x1 u8 Max anisotropy
0x6:0 2 bit u16 MipMap filter (nn::gfx::MipMapFilter)
0x6:2 2 bit u16 Mag filter (nn::gfx::MagFilter)
0x6:4 2 bit u16 Min filter (nn::gfx::MinFilter)
0x6:6 1 bit u16 Enable anisotropy
0x6:7 1 bit u16 Enable CompareOp
0x6:8 2 bit u16 Reduction filter (nn::gfx::ReductionFilter)
0x6:a 6 bit u16 Reserved
0x8 0x4 Float Lod clamp min
0xc 0x4 Float Lod clamp max
0x10 0x4 Float Lod bias
0x14 0x4 u32 Reserved
0x18 0x4 u32 Reserved
0x1c 0x4 u32 Reserved

Gfx Embed File

Offset Size Type Description
0x0 0x8 void * Offset to file
0x8 0x4 u32 Size of file
0xc 0x4 u32 ???

Gfx User Data Type

Name (Unofficial) Value Description
S32 0x0
Float 0x1
String 0x2
Byte 0x3 Used for arbitrary binary data (other files)

Gfx User Data

Offset Size Type Description
0x0 0x8 const char * User data name
0x8 0x8 void * User data (can be nullptr)
0x10 0x4 s32 User data entries
0x14 0x1 u8 User Data Type
0x15 0x2b u8[0x2b] Reserved