Compare commits
10 Commits
Author | SHA1 | Date | |
---|---|---|---|
f3835dc78b | |||
51bb8707ef | |||
5ff5fe47ba | |||
38275f9056 | |||
67cbdc3a6a | |||
131b43170e | |||
730d2f4b9b | |||
f6a7309b14 | |||
472a621589 | |||
311c2661b8 |
2
.github/ISSUE_TEMPLATE/bug_report.md
vendored
2
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@ -1,6 +1,6 @@
|
||||
---
|
||||
name: Bug Report
|
||||
about: Something doesn't work correctly in Ryujinx.
|
||||
about: Something doesn't work correctly in Ryujinx. Note that game-specific issues should be instead posted on the Game Compatibility List at https://github.com/Ryujinx/Ryujinx-Games-List, unless it is a provable regression.
|
||||
#assignees:
|
||||
---
|
||||
|
||||
|
@ -8,195 +8,542 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||
/// </summary>
|
||||
static class FormatTable
|
||||
{
|
||||
private static Dictionary<uint, FormatInfo> _textureFormats = new Dictionary<uint, FormatInfo>()
|
||||
private enum TextureFormat : uint
|
||||
{
|
||||
{ 0x2491d, new FormatInfo(Format.R8Unorm, 1, 1, 1, 1) },
|
||||
{ 0x1249d, new FormatInfo(Format.R8Snorm, 1, 1, 1, 1) },
|
||||
{ 0x4921d, new FormatInfo(Format.R8Uint, 1, 1, 1, 1) },
|
||||
{ 0x36d9d, new FormatInfo(Format.R8Sint, 1, 1, 1, 1) },
|
||||
{ 0x7ff9b, new FormatInfo(Format.R16Float, 1, 1, 2, 1) },
|
||||
{ 0x2491b, new FormatInfo(Format.R16Unorm, 1, 1, 2, 1) },
|
||||
{ 0x1249b, new FormatInfo(Format.R16Snorm, 1, 1, 2, 1) },
|
||||
{ 0x4921b, new FormatInfo(Format.R16Uint, 1, 1, 2, 1) },
|
||||
{ 0x36d9b, new FormatInfo(Format.R16Sint, 1, 1, 2, 1) },
|
||||
{ 0x7ff8f, new FormatInfo(Format.R32Float, 1, 1, 4, 1) },
|
||||
{ 0x4920f, new FormatInfo(Format.R32Uint, 1, 1, 4, 1) },
|
||||
{ 0x36d8f, new FormatInfo(Format.R32Sint, 1, 1, 4, 1) },
|
||||
{ 0x24918, new FormatInfo(Format.R8G8Unorm, 1, 1, 2, 2) },
|
||||
{ 0x12498, new FormatInfo(Format.R8G8Snorm, 1, 1, 2, 2) },
|
||||
{ 0x49218, new FormatInfo(Format.R8G8Uint, 1, 1, 2, 2) },
|
||||
{ 0x36d98, new FormatInfo(Format.R8G8Sint, 1, 1, 2, 2) },
|
||||
{ 0x7ff8c, new FormatInfo(Format.R16G16Float, 1, 1, 4, 2) },
|
||||
{ 0x2490c, new FormatInfo(Format.R16G16Unorm, 1, 1, 4, 2) },
|
||||
{ 0x1248c, new FormatInfo(Format.R16G16Snorm, 1, 1, 4, 2) },
|
||||
{ 0x4920c, new FormatInfo(Format.R16G16Uint, 1, 1, 4, 2) },
|
||||
{ 0x36d8c, new FormatInfo(Format.R16G16Sint, 1, 1, 4, 2) },
|
||||
{ 0x7ff84, new FormatInfo(Format.R32G32Float, 1, 1, 8, 2) },
|
||||
{ 0x49204, new FormatInfo(Format.R32G32Uint, 1, 1, 8, 2) },
|
||||
{ 0x36d84, new FormatInfo(Format.R32G32Sint, 1, 1, 8, 2) },
|
||||
{ 0x7ff82, new FormatInfo(Format.R32G32B32Float, 1, 1, 12, 3) },
|
||||
{ 0x49202, new FormatInfo(Format.R32G32B32Uint, 1, 1, 12, 3) },
|
||||
{ 0x36d82, new FormatInfo(Format.R32G32B32Sint, 1, 1, 12, 3) },
|
||||
{ 0x24908, new FormatInfo(Format.R8G8B8A8Unorm, 1, 1, 4, 4) },
|
||||
{ 0x12488, new FormatInfo(Format.R8G8B8A8Snorm, 1, 1, 4, 4) },
|
||||
{ 0x49208, new FormatInfo(Format.R8G8B8A8Uint, 1, 1, 4, 4) },
|
||||
{ 0x36d88, new FormatInfo(Format.R8G8B8A8Sint, 1, 1, 4, 4) },
|
||||
{ 0x7ff83, new FormatInfo(Format.R16G16B16A16Float, 1, 1, 8, 4) },
|
||||
{ 0x24903, new FormatInfo(Format.R16G16B16A16Unorm, 1, 1, 8, 4) },
|
||||
{ 0x12483, new FormatInfo(Format.R16G16B16A16Snorm, 1, 1, 8, 4) },
|
||||
{ 0x49203, new FormatInfo(Format.R16G16B16A16Uint, 1, 1, 8, 4) },
|
||||
{ 0x36d83, new FormatInfo(Format.R16G16B16A16Sint, 1, 1, 8, 4) },
|
||||
{ 0x7ff81, new FormatInfo(Format.R32G32B32A32Float, 1, 1, 16, 4) },
|
||||
{ 0x49201, new FormatInfo(Format.R32G32B32A32Uint, 1, 1, 16, 4) },
|
||||
{ 0x36d81, new FormatInfo(Format.R32G32B32A32Sint, 1, 1, 16, 4) },
|
||||
{ 0x2493a, new FormatInfo(Format.D16Unorm, 1, 1, 2, 1) },
|
||||
{ 0x493af, new FormatInfo(Format.D32Float, 1, 1, 4, 1) },
|
||||
{ 0x7ffaf, new FormatInfo(Format.D32Float, 1, 1, 4, 1) },
|
||||
{ 0x24a0e, new FormatInfo(Format.D24UnormS8Uint, 1, 1, 4, 2) },
|
||||
{ 0x24a29, new FormatInfo(Format.D24UnormS8Uint, 1, 1, 4, 2) },
|
||||
{ 0x48a29, new FormatInfo(Format.D24UnormS8Uint, 1, 1, 4, 2) },
|
||||
{ 0x4912b, new FormatInfo(Format.S8UintD24Unorm, 1, 1, 4, 2) },
|
||||
{ 0x25385, new FormatInfo(Format.D32FloatS8Uint, 1, 1, 8, 2) },
|
||||
{ 0x253b0, new FormatInfo(Format.D32FloatS8Uint, 1, 1, 8, 2) },
|
||||
{ 0xa4908, new FormatInfo(Format.R8G8B8A8Srgb, 1, 1, 4, 4) },
|
||||
{ 0x2491e, new FormatInfo(Format.R4G4Unorm, 1, 1, 1, 2) },
|
||||
{ 0x24912, new FormatInfo(Format.R4G4B4A4Unorm, 1, 1, 2, 4) },
|
||||
{ 0x24914, new FormatInfo(Format.R5G5B5A1Unorm, 1, 1, 2, 4) },
|
||||
{ 0x24915, new FormatInfo(Format.R5G6B5Unorm, 1, 1, 2, 3) },
|
||||
{ 0x24909, new FormatInfo(Format.R10G10B10A2Unorm, 1, 1, 4, 4) },
|
||||
{ 0x49209, new FormatInfo(Format.R10G10B10A2Uint, 1, 1, 4, 4) },
|
||||
{ 0x7ffa1, new FormatInfo(Format.R11G11B10Float, 1, 1, 4, 3) },
|
||||
{ 0x7ffa0, new FormatInfo(Format.R9G9B9E5Float, 1, 1, 4, 4) },
|
||||
{ 0x24924, new FormatInfo(Format.Bc1RgbaUnorm, 4, 4, 8, 4) },
|
||||
{ 0x24925, new FormatInfo(Format.Bc2Unorm, 4, 4, 16, 4) },
|
||||
{ 0x24926, new FormatInfo(Format.Bc3Unorm, 4, 4, 16, 4) },
|
||||
{ 0xa4924, new FormatInfo(Format.Bc1RgbaSrgb, 4, 4, 8, 4) },
|
||||
{ 0xa4925, new FormatInfo(Format.Bc2Srgb, 4, 4, 16, 4) },
|
||||
{ 0xa4926, new FormatInfo(Format.Bc3Srgb, 4, 4, 16, 4) },
|
||||
{ 0x24927, new FormatInfo(Format.Bc4Unorm, 4, 4, 8, 1) },
|
||||
{ 0x124a7, new FormatInfo(Format.Bc4Snorm, 4, 4, 8, 1) },
|
||||
{ 0x24928, new FormatInfo(Format.Bc5Unorm, 4, 4, 16, 2) },
|
||||
{ 0x124a8, new FormatInfo(Format.Bc5Snorm, 4, 4, 16, 2) },
|
||||
{ 0x24917, new FormatInfo(Format.Bc7Unorm, 4, 4, 16, 4) },
|
||||
{ 0xa4917, new FormatInfo(Format.Bc7Srgb, 4, 4, 16, 4) },
|
||||
{ 0x7ff90, new FormatInfo(Format.Bc6HSfloat, 4, 4, 16, 4) },
|
||||
{ 0x7ff91, new FormatInfo(Format.Bc6HUfloat, 4, 4, 16, 4) },
|
||||
{ 0x24906, new FormatInfo(Format.Etc2RgbUnorm, 4, 4, 8, 3) },
|
||||
{ 0x2490b, new FormatInfo(Format.Etc2RgbaUnorm, 4, 4, 16, 4) },
|
||||
{ 0xa4906, new FormatInfo(Format.Etc2RgbSrgb, 4, 4, 8, 3) },
|
||||
{ 0xa490b, new FormatInfo(Format.Etc2RgbaSrgb, 4, 4, 16, 4) },
|
||||
{ 0x24940, new FormatInfo(Format.Astc4x4Unorm, 4, 4, 16, 4) },
|
||||
{ 0x24950, new FormatInfo(Format.Astc5x4Unorm, 5, 4, 16, 4) },
|
||||
{ 0x24941, new FormatInfo(Format.Astc5x5Unorm, 5, 5, 16, 4) },
|
||||
{ 0x24951, new FormatInfo(Format.Astc6x5Unorm, 6, 5, 16, 4) },
|
||||
{ 0x24942, new FormatInfo(Format.Astc6x6Unorm, 6, 6, 16, 4) },
|
||||
{ 0x24955, new FormatInfo(Format.Astc8x5Unorm, 8, 5, 16, 4) },
|
||||
{ 0x24952, new FormatInfo(Format.Astc8x6Unorm, 8, 6, 16, 4) },
|
||||
{ 0x24944, new FormatInfo(Format.Astc8x8Unorm, 8, 8, 16, 4) },
|
||||
{ 0x24956, new FormatInfo(Format.Astc10x5Unorm, 10, 5, 16, 4) },
|
||||
{ 0x24957, new FormatInfo(Format.Astc10x6Unorm, 10, 6, 16, 4) },
|
||||
{ 0x24953, new FormatInfo(Format.Astc10x8Unorm, 10, 8, 16, 4) },
|
||||
{ 0x24945, new FormatInfo(Format.Astc10x10Unorm, 10, 10, 16, 4) },
|
||||
{ 0x24954, new FormatInfo(Format.Astc12x10Unorm, 12, 10, 16, 4) },
|
||||
{ 0x24946, new FormatInfo(Format.Astc12x12Unorm, 12, 12, 16, 4) },
|
||||
{ 0xa4940, new FormatInfo(Format.Astc4x4Srgb, 4, 4, 16, 4) },
|
||||
{ 0xa4950, new FormatInfo(Format.Astc5x4Srgb, 5, 4, 16, 4) },
|
||||
{ 0xa4941, new FormatInfo(Format.Astc5x5Srgb, 5, 5, 16, 4) },
|
||||
{ 0xa4951, new FormatInfo(Format.Astc6x5Srgb, 6, 5, 16, 4) },
|
||||
{ 0xa4942, new FormatInfo(Format.Astc6x6Srgb, 6, 6, 16, 4) },
|
||||
{ 0xa4955, new FormatInfo(Format.Astc8x5Srgb, 8, 5, 16, 4) },
|
||||
{ 0xa4952, new FormatInfo(Format.Astc8x6Srgb, 8, 6, 16, 4) },
|
||||
{ 0xa4944, new FormatInfo(Format.Astc8x8Srgb, 8, 8, 16, 4) },
|
||||
{ 0xa4956, new FormatInfo(Format.Astc10x5Srgb, 10, 5, 16, 4) },
|
||||
{ 0xa4957, new FormatInfo(Format.Astc10x6Srgb, 10, 6, 16, 4) },
|
||||
{ 0xa4953, new FormatInfo(Format.Astc10x8Srgb, 10, 8, 16, 4) },
|
||||
{ 0xa4945, new FormatInfo(Format.Astc10x10Srgb, 10, 10, 16, 4) },
|
||||
{ 0xa4954, new FormatInfo(Format.Astc12x10Srgb, 12, 10, 16, 4) },
|
||||
{ 0xa4946, new FormatInfo(Format.Astc12x12Srgb, 12, 12, 16, 4) },
|
||||
{ 0x24913, new FormatInfo(Format.A1B5G5R5Unorm, 1, 1, 2, 4) }
|
||||
// Formats
|
||||
R32G32B32A32 = 0x01,
|
||||
R32G32B32 = 0x02,
|
||||
R16G16B16A16 = 0x03,
|
||||
R32G32 = 0x04,
|
||||
R32B24G8 = 0x05,
|
||||
X8B8G8R8 = 0x07,
|
||||
A8B8G8R8 = 0x08,
|
||||
A2B10G10R10 = 0x09,
|
||||
R16G16 = 0x0c,
|
||||
G8R24 = 0x0d,
|
||||
G24R8 = 0x0e,
|
||||
R32 = 0x0f,
|
||||
A4B4G4R4 = 0x12,
|
||||
A5B5G5R1 = 0x13,
|
||||
A1B5G5R5 = 0x14,
|
||||
B5G6R5 = 0x15,
|
||||
B6G5R5 = 0x16,
|
||||
G8R8 = 0x18,
|
||||
R16 = 0x1b,
|
||||
Y8Video = 0x1c,
|
||||
R8 = 0x1d,
|
||||
G4R4 = 0x1e,
|
||||
R1 = 0x1f,
|
||||
E5B9G9R9SharedExp = 0x20,
|
||||
Bf10Gf11Rf11 = 0x21,
|
||||
G8B8G8R8 = 0x22,
|
||||
B8G8R8G8 = 0x23,
|
||||
Bc1 = 0x24,
|
||||
Bc2 = 0x25,
|
||||
Bc3 = 0x26,
|
||||
Bc4 = 0x27,
|
||||
Bc5 = 0x28,
|
||||
Bc6HSf16 = 0x10,
|
||||
Bc6HUf16 = 0x11,
|
||||
Bc7U = 0x17,
|
||||
Etc2Rgb = 0x06,
|
||||
Etc2RgbPta = 0x0a,
|
||||
Etc2Rgba = 0x0b,
|
||||
Eac = 0x19,
|
||||
Eacx2 = 0x1a,
|
||||
Z24S8 = 0x29,
|
||||
X8Z24 = 0x2a,
|
||||
S8Z24 = 0x2b,
|
||||
X4V4Z24Cov4R4V = 0x2c,
|
||||
X4V4Z24Cov8R8V = 0x2d,
|
||||
V8Z24Cov4R12V = 0x2e,
|
||||
Zf32 = 0x2f,
|
||||
Zf32X24S8 = 0x30,
|
||||
X8Z24X20V4S8Cov4R4V = 0x31,
|
||||
X8Z24X20V4S8Cov8R8V = 0x32,
|
||||
Zf32X20V4X8Cov4R4V = 0x33,
|
||||
Zf32X20V4X8Cov8R8V = 0x34,
|
||||
Zf32X20V4S8Cov4R4V = 0x35,
|
||||
Zf32X20V4S8Cov8R8V = 0x36,
|
||||
X8Z24X16V8S8Cov4R12V = 0x37,
|
||||
Zf32X16V8X8Cov4R12V = 0x38,
|
||||
Zf32X16V8S8Cov4R12V = 0x39,
|
||||
Z16 = 0x3a,
|
||||
V8Z24Cov8R24V = 0x3b,
|
||||
X8Z24X16V8S8Cov8R24V = 0x3c,
|
||||
Zf32X16V8X8Cov8R24V = 0x3d,
|
||||
Zf32X16V8S8Cov8R24V = 0x3e,
|
||||
Astc2D4x4 = 0x40,
|
||||
Astc2D5x4 = 0x50,
|
||||
Astc2D5x5 = 0x41,
|
||||
Astc2D6x5 = 0x51,
|
||||
Astc2D6x6 = 0x42,
|
||||
Astc2D8x5 = 0x55,
|
||||
Astc2D8x6 = 0x52,
|
||||
Astc2D8x8 = 0x44,
|
||||
Astc2D10x5 = 0x56,
|
||||
Astc2D10x6 = 0x57,
|
||||
Astc2D10x8 = 0x53,
|
||||
Astc2D10x10 = 0x45,
|
||||
Astc2D12x10 = 0x54,
|
||||
Astc2D12x12 = 0x46,
|
||||
|
||||
// Types
|
||||
Snorm = 0x1,
|
||||
Unorm = 0x2,
|
||||
Sint = 0x3,
|
||||
Uint = 0x4,
|
||||
SnormForceFp16 = 0x5,
|
||||
UnormForceFp16 = 0x6,
|
||||
Float = 0x7,
|
||||
|
||||
// Component Types
|
||||
RSnorm = Snorm << 7,
|
||||
GSnorm = Snorm << 10,
|
||||
BSnorm = Snorm << 13,
|
||||
ASnorm = Snorm << 16,
|
||||
|
||||
RUnorm = Unorm << 7,
|
||||
GUnorm = Unorm << 10,
|
||||
BUnorm = Unorm << 13,
|
||||
AUnorm = Unorm << 16,
|
||||
|
||||
RSint = Sint << 7,
|
||||
GSint = Sint << 10,
|
||||
BSint = Sint << 13,
|
||||
ASint = Sint << 16,
|
||||
|
||||
RUint = Uint << 7,
|
||||
GUint = Uint << 10,
|
||||
BUint = Uint << 13,
|
||||
AUint = Uint << 16,
|
||||
|
||||
RSnormForceFp16 = SnormForceFp16 << 7,
|
||||
GSnormForceFp16 = SnormForceFp16 << 10,
|
||||
BSnormForceFp16 = SnormForceFp16 << 13,
|
||||
ASnormForceFp16 = SnormForceFp16 << 16,
|
||||
|
||||
RUnormForceFp16 = UnormForceFp16 << 7,
|
||||
GUnormForceFp16 = UnormForceFp16 << 10,
|
||||
BUnormForceFp16 = UnormForceFp16 << 13,
|
||||
AUnormForceFp16 = UnormForceFp16 << 16,
|
||||
|
||||
RFloat = Float << 7,
|
||||
GFloat = Float << 10,
|
||||
BFloat = Float << 13,
|
||||
AFloat = Float << 16,
|
||||
|
||||
Srgb = 0x1 << 19, // Custom encoding
|
||||
|
||||
// Combinations
|
||||
R8Unorm = R8 | RUnorm | GUnorm | BUnorm | AUnorm, // 0x2491d
|
||||
R8Snorm = R8 | RSnorm | GSnorm | BSnorm | ASnorm, // 0x1249d
|
||||
R8Uint = R8 | RUint | GUint | BUint | AUint, // 0x4921d
|
||||
R8Sint = R8 | RSint | GSint | BSint | ASint, // 0x36d9d
|
||||
R16Float = R16 | RFloat | GFloat | BFloat | AFloat, // 0x7ff9b
|
||||
R16Unorm = R16 | RUnorm | GUnorm | BUnorm | AUnorm, // 0x2491b
|
||||
R16Snorm = R16 | RSnorm | GSnorm | BSnorm | ASnorm, // 0x1249b
|
||||
R16Uint = R16 | RUint | GUint | BUint | AUint, // 0x4921b
|
||||
R16Sint = R16 | RSint | GSint | BSint | ASint, // 0x36d9b
|
||||
R32Float = R32 | RFloat | GFloat | BFloat | AFloat, // 0x7ff8f
|
||||
R32Uint = R32 | RUint | GUint | BUint | AUint, // 0x4920f
|
||||
R32Sint = R32 | RSint | GSint | BSint | ASint, // 0x36d8f
|
||||
G8R8Unorm = G8R8 | RUnorm | GUnorm | BUnorm | AUnorm, // 0x24918
|
||||
G8R8Snorm = G8R8 | RSnorm | GSnorm | BSnorm | ASnorm, // 0x12498
|
||||
G8R8Uint = G8R8 | RUint | GUint | BUint | AUint, // 0x49218
|
||||
G8R8Sint = G8R8 | RSint | GSint | BSint | ASint, // 0x36d98
|
||||
R16G16Float = R16G16 | RFloat | GFloat | BFloat | AFloat, // 0x7ff8c
|
||||
R16G16Unorm = R16G16 | RUnorm | GUnorm | BUnorm | AUnorm, // 0x2490c
|
||||
R16G16Snorm = R16G16 | RSnorm | GSnorm | BSnorm | ASnorm, // 0x1248c
|
||||
R16G16Uint = R16G16 | RUint | GUint | BUint | AUint, // 0x4920c
|
||||
R16G16Sint = R16G16 | RSint | GSint | BSint | ASint, // 0x36d8c
|
||||
R32G32Float = R32G32 | RFloat | GFloat | BFloat | AFloat, // 0x7ff84
|
||||
R32G32Uint = R32G32 | RUint | GUint | BUint | AUint, // 0x49204
|
||||
R32G32Sint = R32G32 | RSint | GSint | BSint | ASint, // 0x36d84
|
||||
R32G32B32Float = R32G32B32 | RFloat | GFloat | BFloat | AFloat, // 0x7ff82
|
||||
R32G32B32Uint = R32G32B32 | RUint | GUint | BUint | AUint, // 0x49202
|
||||
R32G32B32Sint = R32G32B32 | RSint | GSint | BSint | ASint, // 0x36d82
|
||||
A8B8G8R8Unorm = A8B8G8R8 | RUnorm | GUnorm | BUnorm | AUnorm, // 0x24908
|
||||
A8B8G8R8Snorm = A8B8G8R8 | RSnorm | GSnorm | BSnorm | ASnorm, // 0x12488
|
||||
A8B8G8R8Uint = A8B8G8R8 | RUint | GUint | BUint | AUint, // 0x49208
|
||||
A8B8G8R8Sint = A8B8G8R8 | RSint | GSint | BSint | ASint, // 0x36d88
|
||||
R16G16B16A16Float = R16G16B16A16 | RFloat | GFloat | BFloat | AFloat, // 0x7ff83
|
||||
R16G16B16A16Unorm = R16G16B16A16 | RUnorm | GUnorm | BUnorm | AUnorm, // 0x24903
|
||||
R16G16B16A16Snorm = R16G16B16A16 | RSnorm | GSnorm | BSnorm | ASnorm, // 0x12483
|
||||
R16G16B16A16Uint = R16G16B16A16 | RUint | GUint | BUint | AUint, // 0x49203
|
||||
R16G16B16A16Sint = R16G16B16A16 | RSint | GSint | BSint | ASint, // 0x36d83
|
||||
R32G32B32A32Float = R32G32B32A32 | RFloat | GFloat | BFloat | AFloat, // 0x7ff81
|
||||
R32G32B32A32Uint = R32G32B32A32 | RUint | GUint | BUint | AUint, // 0x49201
|
||||
R32G32B32A32Sint = R32G32B32A32 | RSint | GSint | BSint | ASint, // 0x36d81
|
||||
Z16Unorm = Z16 | RUnorm | GUnorm | BUnorm | AUnorm, // 0x2493a
|
||||
Zf32RFloatGUintBUintAUint = Zf32 | RFloat | GUint | BUint | AUint, // 0x493af
|
||||
Zf32Float = Zf32 | RFloat | GFloat | BFloat | AFloat, // 0x7ffaf
|
||||
G24R8RUintGUnormBUnormAUnorm = G24R8 | RUint | GUnorm | BUnorm | AUnorm, // 0x24a0e
|
||||
Z24S8RUintGUnormBUnormAUnorm = Z24S8 | RUint | GUnorm | BUnorm | AUnorm, // 0x24a29
|
||||
Z24S8RUintGUnormBUintAUint = Z24S8 | RUint | GUnorm | BUint | AUint, // 0x48a29
|
||||
S8Z24RUnormGUintBUintAUint = S8Z24 | RUnorm | GUint | BUint | AUint, // 0x4912b
|
||||
R32B24G8RFloatGUintBUnormAUnorm = R32B24G8 | RFloat | GUint | BUnorm | AUnorm, // 0x25385
|
||||
Zf32X24S8RFloatGUintBUnormAUnorm = Zf32X24S8 | RFloat | GUint | BUnorm | AUnorm, // 0x253b0
|
||||
A8B8G8R8UnormSrgb = A8B8G8R8 | RUnorm | GUnorm | BUnorm | AUnorm | Srgb, // 0xa4908
|
||||
G4R4Unorm = G4R4 | RUnorm | GUnorm | BUnorm | AUnorm, // 0x2491e
|
||||
A4B4G4R4Unorm = A4B4G4R4 | RUnorm | GUnorm | BUnorm | AUnorm, // 0x24912
|
||||
A1B5G5R5Unorm = A1B5G5R5 | RUnorm | GUnorm | BUnorm | AUnorm, // 0x24914
|
||||
B5G6R5Unorm = B5G6R5 | RUnorm | GUnorm | BUnorm | AUnorm, // 0x24915
|
||||
A2B10G10R10Unorm = A2B10G10R10 | RUnorm | GUnorm | BUnorm | AUnorm, // 0x24909
|
||||
A2B10G10R10Uint = A2B10G10R10 | RUint | GUint | BUint | AUint, // 0x49209
|
||||
Bf10Gf11Rf11Float = Bf10Gf11Rf11 | RFloat | GFloat | BFloat | AFloat, // 0x7ffa1
|
||||
E5B9G9R9SharedExpFloat = E5B9G9R9SharedExp | RFloat | GFloat | BFloat | AFloat, // 0x7ffa0
|
||||
Bc1Unorm = Bc1 | RUnorm | GUnorm | BUnorm | AUnorm, // 0x24924
|
||||
Bc2Unorm = Bc2 | RUnorm | GUnorm | BUnorm | AUnorm, // 0x24925
|
||||
Bc3Unorm = Bc3 | RUnorm | GUnorm | BUnorm | AUnorm, // 0x24926
|
||||
Bc1UnormSrgb = Bc1 | RUnorm | GUnorm | BUnorm | AUnorm | Srgb, // 0xa4924
|
||||
Bc2UnormSrgb = Bc2 | RUnorm | GUnorm | BUnorm | AUnorm | Srgb, // 0xa4925
|
||||
Bc3UnormSrgb = Bc3 | RUnorm | GUnorm | BUnorm | AUnorm | Srgb, // 0xa4926
|
||||
Bc4Unorm = Bc4 | RUnorm | GUnorm | BUnorm | AUnorm, // 0x24927
|
||||
Bc4Snorm = Bc4 | RSnorm | GSnorm | BSnorm | ASnorm, // 0x124a7
|
||||
Bc5Unorm = Bc5 | RUnorm | GUnorm | BUnorm | AUnorm, // 0x24928
|
||||
Bc5Snorm = Bc5 | RSnorm | GSnorm | BSnorm | ASnorm, // 0x124a8
|
||||
Bc7UUnorm = Bc7U | RUnorm | GUnorm | BUnorm | AUnorm, // 0x24917
|
||||
Bc7UUnormSrgb = Bc7U | RUnorm | GUnorm | BUnorm | AUnorm | Srgb, // 0xa4917
|
||||
Bc6HSf16Float = Bc6HSf16 | RFloat | GFloat | BFloat | AFloat, // 0x7ff90
|
||||
Bc6HUf16Float = Bc6HUf16 | RFloat | GFloat | BFloat | AFloat, // 0x7ff91
|
||||
Etc2RgbUnorm = Etc2Rgb | RUnorm | GUnorm | BUnorm | AUnorm, // 0x24906
|
||||
Etc2RgbaUnorm = Etc2Rgba | RUnorm | GUnorm | BUnorm | AUnorm, // 0x2490b
|
||||
Etc2RgbUnormSrgb = Etc2Rgb | RUnorm | GUnorm | BUnorm | AUnorm | Srgb, // 0xa4906
|
||||
Etc2RgbaUnormSrgb = Etc2Rgba | RUnorm | GUnorm | BUnorm | AUnorm | Srgb, // 0xa490b
|
||||
Astc2D4x4Unorm = Astc2D4x4 | RUnorm | GUnorm | BUnorm | AUnorm, // 0x24940
|
||||
Astc2D5x4Unorm = Astc2D5x4 | RUnorm | GUnorm | BUnorm | AUnorm, // 0x24950
|
||||
Astc2D5x5Unorm = Astc2D5x5 | RUnorm | GUnorm | BUnorm | AUnorm, // 0x24941
|
||||
Astc2D6x5Unorm = Astc2D6x5 | RUnorm | GUnorm | BUnorm | AUnorm, // 0x24951
|
||||
Astc2D6x6Unorm = Astc2D6x6 | RUnorm | GUnorm | BUnorm | AUnorm, // 0x24942
|
||||
Astc2D8x5Unorm = Astc2D8x5 | RUnorm | GUnorm | BUnorm | AUnorm, // 0x24955
|
||||
Astc2D8x6Unorm = Astc2D8x6 | RUnorm | GUnorm | BUnorm | AUnorm, // 0x24952
|
||||
Astc2D8x8Unorm = Astc2D8x8 | RUnorm | GUnorm | BUnorm | AUnorm, // 0x24944
|
||||
Astc2D10x5Unorm = Astc2D10x5 | RUnorm | GUnorm | BUnorm | AUnorm, // 0x24956
|
||||
Astc2D10x6Unorm = Astc2D10x6 | RUnorm | GUnorm | BUnorm | AUnorm, // 0x24957
|
||||
Astc2D10x8Unorm = Astc2D10x8 | RUnorm | GUnorm | BUnorm | AUnorm, // 0x24953
|
||||
Astc2D10x10Unorm = Astc2D10x10 | RUnorm | GUnorm | BUnorm | AUnorm, // 0x24945
|
||||
Astc2D12x10Unorm = Astc2D12x10 | RUnorm | GUnorm | BUnorm | AUnorm, // 0x24954
|
||||
Astc2D12x12Unorm = Astc2D12x12 | RUnorm | GUnorm | BUnorm | AUnorm, // 0x24946
|
||||
Astc2D4x4UnormSrgb = Astc2D4x4 | RUnorm | GUnorm | BUnorm | AUnorm | Srgb, // 0xa4940
|
||||
Astc2D5x4UnormSrgb = Astc2D5x4 | RUnorm | GUnorm | BUnorm | AUnorm | Srgb, // 0xa4950
|
||||
Astc2D5x5UnormSrgb = Astc2D5x5 | RUnorm | GUnorm | BUnorm | AUnorm | Srgb, // 0xa4941
|
||||
Astc2D6x5UnormSrgb = Astc2D6x5 | RUnorm | GUnorm | BUnorm | AUnorm | Srgb, // 0xa4951
|
||||
Astc2D6x6UnormSrgb = Astc2D6x6 | RUnorm | GUnorm | BUnorm | AUnorm | Srgb, // 0xa4942
|
||||
Astc2D8x5UnormSrgb = Astc2D8x5 | RUnorm | GUnorm | BUnorm | AUnorm | Srgb, // 0xa4955
|
||||
Astc2D8x6UnormSrgb = Astc2D8x6 | RUnorm | GUnorm | BUnorm | AUnorm | Srgb, // 0xa4952
|
||||
Astc2D8x8UnormSrgb = Astc2D8x8 | RUnorm | GUnorm | BUnorm | AUnorm | Srgb, // 0xa4944
|
||||
Astc2D10x5UnormSrgb = Astc2D10x5 | RUnorm | GUnorm | BUnorm | AUnorm | Srgb, // 0xa4956
|
||||
Astc2D10x6UnormSrgb = Astc2D10x6 | RUnorm | GUnorm | BUnorm | AUnorm | Srgb, // 0xa4957
|
||||
Astc2D10x8UnormSrgb = Astc2D10x8 | RUnorm | GUnorm | BUnorm | AUnorm | Srgb, // 0xa4953
|
||||
Astc2D10x10UnormSrgb = Astc2D10x10 | RUnorm | GUnorm | BUnorm | AUnorm | Srgb, // 0xa4945
|
||||
Astc2D12x10UnormSrgb = Astc2D12x10 | RUnorm | GUnorm | BUnorm | AUnorm | Srgb, // 0xa4954
|
||||
Astc2D12x12UnormSrgb = Astc2D12x12 | RUnorm | GUnorm | BUnorm | AUnorm | Srgb, // 0xa4946
|
||||
A5B5G5R1Unorm = A5B5G5R1 | RUnorm | GUnorm | BUnorm | AUnorm, // 0x24913
|
||||
}
|
||||
|
||||
private enum VertexAttributeFormat : uint
|
||||
{
|
||||
// Width
|
||||
R32G32B32A32 = 0x01,
|
||||
R32G32B32 = 0x02,
|
||||
R16G16B16A16 = 0x03,
|
||||
R32G32 = 0x04,
|
||||
R16G16B16 = 0x05,
|
||||
A8B8G8R8 = 0x2f,
|
||||
R8G8B8A8 = 0x0a,
|
||||
X8B8G8R8 = 0x33,
|
||||
A2B10G10R10 = 0x30,
|
||||
B10G11R11 = 0x31,
|
||||
R16G16 = 0x0f,
|
||||
R32 = 0x12,
|
||||
R8G8B8 = 0x13,
|
||||
G8R8 = 0x32,
|
||||
R8G8 = 0x18,
|
||||
R16 = 0x1b,
|
||||
R8 = 0x1d,
|
||||
A8 = 0x34,
|
||||
|
||||
// Type
|
||||
Snorm = 0x01,
|
||||
Unorm = 0x02,
|
||||
Sint = 0x03,
|
||||
Uint = 0x04,
|
||||
Uscaled = 0x05,
|
||||
Sscaled = 0x06,
|
||||
Float = 0x07,
|
||||
|
||||
// Combinations
|
||||
R8Unorm = (R8 << 21) | (Unorm << 27), // 0x13a00000
|
||||
R8Snorm = (R8 << 21) | (Snorm << 27), // 0x0ba00000
|
||||
R8Uint = (R8 << 21) | (Uint << 27), // 0x23a00000
|
||||
R8Sint = (R8 << 21) | (Sint << 27), // 0x1ba00000
|
||||
R16Float = (R16 << 21) | (Float << 27), // 0x3b600000
|
||||
R16Unorm = (R16 << 21) | (Unorm << 27), // 0x13600000
|
||||
R16Snorm = (R16 << 21) | (Snorm << 27), // 0x0b600000
|
||||
R16Uint = (R16 << 21) | (Uint << 27), // 0x23600000
|
||||
R16Sint = (R16 << 21) | (Sint << 27), // 0x1b600000
|
||||
R32Float = (R32 << 21) | (Float << 27), // 0x3a400000
|
||||
R32Uint = (R32 << 21) | (Uint << 27), // 0x22400000
|
||||
R32Sint = (R32 << 21) | (Sint << 27), // 0x1a400000
|
||||
R8G8Unorm = (R8G8 << 21) | (Unorm << 27), // 0x13000000
|
||||
R8G8Snorm = (R8G8 << 21) | (Snorm << 27), // 0x0b000000
|
||||
R8G8Uint = (R8G8 << 21) | (Uint << 27), // 0x23000000
|
||||
R8G8Sint = (R8G8 << 21) | (Sint << 27), // 0x1b000000
|
||||
R16G16Float = (R16G16 << 21) | (Float << 27), // 0x39e00000
|
||||
R16G16Unorm = (R16G16 << 21) | (Unorm << 27), // 0x11e00000
|
||||
R16G16Snorm = (R16G16 << 21) | (Snorm << 27), // 0x09e00000
|
||||
R16G16Uint = (R16G16 << 21) | (Uint << 27), // 0x21e00000
|
||||
R16G16Sint = (R16G16 << 21) | (Sint << 27), // 0x19e00000
|
||||
R32G32Float = (R32G32 << 21) | (Float << 27), // 0x38800000
|
||||
R32G32Uint = (R32G32 << 21) | (Uint << 27), // 0x20800000
|
||||
R32G32Sint = (R32G32 << 21) | (Sint << 27), // 0x18800000
|
||||
R8G8B8Unorm = (R8G8B8 << 21) | (Unorm << 27), // 0x12600000
|
||||
R8G8B8Snorm = (R8G8B8 << 21) | (Snorm << 27), // 0x0a600000
|
||||
R8G8B8Uint = (R8G8B8 << 21) | (Uint << 27), // 0x22600000
|
||||
R8G8B8Sint = (R8G8B8 << 21) | (Sint << 27), // 0x1a600000
|
||||
R16G16B16Float = (R16G16B16 << 21) | (Float << 27), // 0x38a00000
|
||||
R16G16B16Unorm = (R16G16B16 << 21) | (Unorm << 27), // 0x10a00000
|
||||
R16G16B16Snorm = (R16G16B16 << 21) | (Snorm << 27), // 0x08a00000
|
||||
R16G16B16Uint = (R16G16B16 << 21) | (Uint << 27), // 0x20a00000
|
||||
R16G16B16Sint = (R16G16B16 << 21) | (Sint << 27), // 0x18a00000
|
||||
R32G32B32Float = (R32G32B32 << 21) | (Float << 27), // 0x38400000
|
||||
R32G32B32Uint = (R32G32B32 << 21) | (Uint << 27), // 0x20400000
|
||||
R32G32B32Sint = (R32G32B32 << 21) | (Sint << 27), // 0x18400000
|
||||
R8G8B8A8Unorm = (R8G8B8A8 << 21) | (Unorm << 27), // 0x11400000
|
||||
R8G8B8A8Snorm = (R8G8B8A8 << 21) | (Snorm << 27), // 0x09400000
|
||||
R8G8B8A8Uint = (R8G8B8A8 << 21) | (Uint << 27), // 0x21400000
|
||||
R8G8B8A8Sint = (R8G8B8A8 << 21) | (Sint << 27), // 0x19400000
|
||||
R16G16B16A16Float = (R16G16B16A16 << 21) | (Float << 27), // 0x38600000
|
||||
R16G16B16A16Unorm = (R16G16B16A16 << 21) | (Unorm << 27), // 0x10600000
|
||||
R16G16B16A16Snorm = (R16G16B16A16 << 21) | (Snorm << 27), // 0x08600000
|
||||
R16G16B16A16Uint = (R16G16B16A16 << 21) | (Uint << 27), // 0x20600000
|
||||
R16G16B16A16Sint = (R16G16B16A16 << 21) | (Sint << 27), // 0x18600000
|
||||
R32G32B32A32Float = (R32G32B32A32 << 21) | (Float << 27), // 0x38200000
|
||||
R32G32B32A32Uint = (R32G32B32A32 << 21) | (Uint << 27), // 0x20200000
|
||||
R32G32B32A32Sint = (R32G32B32A32 << 21) | (Sint << 27), // 0x18200000
|
||||
A2B10G10R10Unorm = (A2B10G10R10 << 21) | (Unorm << 27), // 0x16000000
|
||||
A2B10G10R10Uint = (A2B10G10R10 << 21) | (Uint << 27), // 0x26000000
|
||||
B10G11R11Float = (B10G11R11 << 21) | (Float << 27), // 0x3e200000
|
||||
R8Uscaled = (R8 << 21) | (Uscaled << 27), // 0x2ba00000
|
||||
R8Sscaled = (R8 << 21) | (Sscaled << 27), // 0x33a00000
|
||||
R16Uscaled = (R16 << 21) | (Uscaled << 27), // 0x2b600000
|
||||
R16Sscaled = (R16 << 21) | (Sscaled << 27), // 0x33600000
|
||||
R32Uscaled = (R32 << 21) | (Uscaled << 27), // 0x2a400000
|
||||
R32Sscaled = (R32 << 21) | (Sscaled << 27), // 0x32400000
|
||||
R8G8Uscaled = (R8G8 << 21) | (Uscaled << 27), // 0x2b000000
|
||||
R8G8Sscaled = (R8G8 << 21) | (Sscaled << 27), // 0x33000000
|
||||
R16G16Uscaled = (R16G16 << 21) | (Uscaled << 27), // 0x29e00000
|
||||
R16G16Sscaled = (R16G16 << 21) | (Sscaled << 27), // 0x31e00000
|
||||
R32G32Uscaled = (R32G32 << 21) | (Uscaled << 27), // 0x28800000
|
||||
R32G32Sscaled = (R32G32 << 21) | (Sscaled << 27), // 0x30800000
|
||||
R8G8B8Uscaled = (R8G8B8 << 21) | (Uscaled << 27), // 0x2a600000
|
||||
R8G8B8Sscaled = (R8G8B8 << 21) | (Sscaled << 27), // 0x32600000
|
||||
R16G16B16Uscaled = (R16G16B16 << 21) | (Uscaled << 27), // 0x28a00000
|
||||
R16G16B16Sscaled = (R16G16B16 << 21) | (Sscaled << 27), // 0x30a00000
|
||||
R32G32B32Uscaled = (R32G32B32 << 21) | (Uscaled << 27), // 0x28400000
|
||||
R32G32B32Sscaled = (R32G32B32 << 21) | (Sscaled << 27), // 0x30400000
|
||||
R8G8B8A8Uscaled = (R8G8B8A8 << 21) | (Uscaled << 27), // 0x29400000
|
||||
R8G8B8A8Sscaled = (R8G8B8A8 << 21) | (Sscaled << 27), // 0x31400000
|
||||
R16G16B16A16Uscaled = (R16G16B16A16 << 21) | (Uscaled << 27), // 0x28600000
|
||||
R16G16B16A16Sscaled = (R16G16B16A16 << 21) | (Sscaled << 27), // 0x30600000
|
||||
R32G32B32A32Uscaled = (R32G32B32A32 << 21) | (Uscaled << 27), // 0x28200000
|
||||
R32G32B32A32Sscaled = (R32G32B32A32 << 21) | (Sscaled << 27), // 0x30200000
|
||||
A2B10G10R10Snorm = (A2B10G10R10 << 21) | (Snorm << 27), // 0x0e000000
|
||||
A2B10G10R10Sint = (A2B10G10R10 << 21) | (Sint << 27), // 0x1e000000
|
||||
A2B10G10R10Uscaled = (A2B10G10R10 << 21) | (Uscaled << 27), // 0x2e000000
|
||||
A2B10G10R10Sscaled = (A2B10G10R10 << 21) | (Sscaled << 27), // 0x36000000
|
||||
}
|
||||
|
||||
private static readonly Dictionary<TextureFormat, FormatInfo> _textureFormats = new Dictionary<TextureFormat, FormatInfo>()
|
||||
{
|
||||
{ TextureFormat.R8Unorm, new FormatInfo(Format.R8Unorm, 1, 1, 1, 1) },
|
||||
{ TextureFormat.R8Snorm, new FormatInfo(Format.R8Snorm, 1, 1, 1, 1) },
|
||||
{ TextureFormat.R8Uint, new FormatInfo(Format.R8Uint, 1, 1, 1, 1) },
|
||||
{ TextureFormat.R8Sint, new FormatInfo(Format.R8Sint, 1, 1, 1, 1) },
|
||||
{ TextureFormat.R16Float, new FormatInfo(Format.R16Float, 1, 1, 2, 1) },
|
||||
{ TextureFormat.R16Unorm, new FormatInfo(Format.R16Unorm, 1, 1, 2, 1) },
|
||||
{ TextureFormat.R16Snorm, new FormatInfo(Format.R16Snorm, 1, 1, 2, 1) },
|
||||
{ TextureFormat.R16Uint, new FormatInfo(Format.R16Uint, 1, 1, 2, 1) },
|
||||
{ TextureFormat.R16Sint, new FormatInfo(Format.R16Sint, 1, 1, 2, 1) },
|
||||
{ TextureFormat.R32Float, new FormatInfo(Format.R32Float, 1, 1, 4, 1) },
|
||||
{ TextureFormat.R32Uint, new FormatInfo(Format.R32Uint, 1, 1, 4, 1) },
|
||||
{ TextureFormat.R32Sint, new FormatInfo(Format.R32Sint, 1, 1, 4, 1) },
|
||||
{ TextureFormat.G8R8Unorm, new FormatInfo(Format.R8G8Unorm, 1, 1, 2, 2) },
|
||||
{ TextureFormat.G8R8Snorm, new FormatInfo(Format.R8G8Snorm, 1, 1, 2, 2) },
|
||||
{ TextureFormat.G8R8Uint, new FormatInfo(Format.R8G8Uint, 1, 1, 2, 2) },
|
||||
{ TextureFormat.G8R8Sint, new FormatInfo(Format.R8G8Sint, 1, 1, 2, 2) },
|
||||
{ TextureFormat.R16G16Float, new FormatInfo(Format.R16G16Float, 1, 1, 4, 2) },
|
||||
{ TextureFormat.R16G16Unorm, new FormatInfo(Format.R16G16Unorm, 1, 1, 4, 2) },
|
||||
{ TextureFormat.R16G16Snorm, new FormatInfo(Format.R16G16Snorm, 1, 1, 4, 2) },
|
||||
{ TextureFormat.R16G16Uint, new FormatInfo(Format.R16G16Uint, 1, 1, 4, 2) },
|
||||
{ TextureFormat.R16G16Sint, new FormatInfo(Format.R16G16Sint, 1, 1, 4, 2) },
|
||||
{ TextureFormat.R32G32Float, new FormatInfo(Format.R32G32Float, 1, 1, 8, 2) },
|
||||
{ TextureFormat.R32G32Uint, new FormatInfo(Format.R32G32Uint, 1, 1, 8, 2) },
|
||||
{ TextureFormat.R32G32Sint, new FormatInfo(Format.R32G32Sint, 1, 1, 8, 2) },
|
||||
{ TextureFormat.R32G32B32Float, new FormatInfo(Format.R32G32B32Float, 1, 1, 12, 3) },
|
||||
{ TextureFormat.R32G32B32Uint, new FormatInfo(Format.R32G32B32Uint, 1, 1, 12, 3) },
|
||||
{ TextureFormat.R32G32B32Sint, new FormatInfo(Format.R32G32B32Sint, 1, 1, 12, 3) },
|
||||
{ TextureFormat.A8B8G8R8Unorm, new FormatInfo(Format.R8G8B8A8Unorm, 1, 1, 4, 4) },
|
||||
{ TextureFormat.A8B8G8R8Snorm, new FormatInfo(Format.R8G8B8A8Snorm, 1, 1, 4, 4) },
|
||||
{ TextureFormat.A8B8G8R8Uint, new FormatInfo(Format.R8G8B8A8Uint, 1, 1, 4, 4) },
|
||||
{ TextureFormat.A8B8G8R8Sint, new FormatInfo(Format.R8G8B8A8Sint, 1, 1, 4, 4) },
|
||||
{ TextureFormat.R16G16B16A16Float, new FormatInfo(Format.R16G16B16A16Float, 1, 1, 8, 4) },
|
||||
{ TextureFormat.R16G16B16A16Unorm, new FormatInfo(Format.R16G16B16A16Unorm, 1, 1, 8, 4) },
|
||||
{ TextureFormat.R16G16B16A16Snorm, new FormatInfo(Format.R16G16B16A16Snorm, 1, 1, 8, 4) },
|
||||
{ TextureFormat.R16G16B16A16Uint, new FormatInfo(Format.R16G16B16A16Uint, 1, 1, 8, 4) },
|
||||
{ TextureFormat.R16G16B16A16Sint, new FormatInfo(Format.R16G16B16A16Sint, 1, 1, 8, 4) },
|
||||
{ TextureFormat.R32G32B32A32Float, new FormatInfo(Format.R32G32B32A32Float, 1, 1, 16, 4) },
|
||||
{ TextureFormat.R32G32B32A32Uint, new FormatInfo(Format.R32G32B32A32Uint, 1, 1, 16, 4) },
|
||||
{ TextureFormat.R32G32B32A32Sint, new FormatInfo(Format.R32G32B32A32Sint, 1, 1, 16, 4) },
|
||||
{ TextureFormat.Z16Unorm, new FormatInfo(Format.D16Unorm, 1, 1, 2, 1) },
|
||||
{ TextureFormat.Zf32RFloatGUintBUintAUint, new FormatInfo(Format.D32Float, 1, 1, 4, 1) },
|
||||
{ TextureFormat.Zf32Float, new FormatInfo(Format.D32Float, 1, 1, 4, 1) },
|
||||
{ TextureFormat.G24R8RUintGUnormBUnormAUnorm, new FormatInfo(Format.D24UnormS8Uint, 1, 1, 4, 2) },
|
||||
{ TextureFormat.Z24S8RUintGUnormBUnormAUnorm, new FormatInfo(Format.D24UnormS8Uint, 1, 1, 4, 2) },
|
||||
{ TextureFormat.Z24S8RUintGUnormBUintAUint, new FormatInfo(Format.D24UnormS8Uint, 1, 1, 4, 2) },
|
||||
{ TextureFormat.S8Z24RUnormGUintBUintAUint, new FormatInfo(Format.S8UintD24Unorm, 1, 1, 4, 2) },
|
||||
{ TextureFormat.R32B24G8RFloatGUintBUnormAUnorm, new FormatInfo(Format.D32FloatS8Uint, 1, 1, 8, 2) },
|
||||
{ TextureFormat.Zf32X24S8RFloatGUintBUnormAUnorm, new FormatInfo(Format.D32FloatS8Uint, 1, 1, 8, 2) },
|
||||
{ TextureFormat.A8B8G8R8UnormSrgb, new FormatInfo(Format.R8G8B8A8Srgb, 1, 1, 4, 4) },
|
||||
{ TextureFormat.G4R4Unorm, new FormatInfo(Format.R4G4Unorm, 1, 1, 1, 2) },
|
||||
{ TextureFormat.A4B4G4R4Unorm, new FormatInfo(Format.R4G4B4A4Unorm, 1, 1, 2, 4) },
|
||||
{ TextureFormat.A1B5G5R5Unorm, new FormatInfo(Format.R5G5B5A1Unorm, 1, 1, 2, 4) },
|
||||
{ TextureFormat.B5G6R5Unorm, new FormatInfo(Format.R5G6B5Unorm, 1, 1, 2, 3) },
|
||||
{ TextureFormat.A2B10G10R10Unorm, new FormatInfo(Format.R10G10B10A2Unorm, 1, 1, 4, 4) },
|
||||
{ TextureFormat.A2B10G10R10Uint, new FormatInfo(Format.R10G10B10A2Uint, 1, 1, 4, 4) },
|
||||
{ TextureFormat.Bf10Gf11Rf11Float, new FormatInfo(Format.R11G11B10Float, 1, 1, 4, 3) },
|
||||
{ TextureFormat.E5B9G9R9SharedExpFloat, new FormatInfo(Format.R9G9B9E5Float, 1, 1, 4, 4) },
|
||||
{ TextureFormat.Bc1Unorm, new FormatInfo(Format.Bc1RgbaUnorm, 4, 4, 8, 4) },
|
||||
{ TextureFormat.Bc2Unorm, new FormatInfo(Format.Bc2Unorm, 4, 4, 16, 4) },
|
||||
{ TextureFormat.Bc3Unorm, new FormatInfo(Format.Bc3Unorm, 4, 4, 16, 4) },
|
||||
{ TextureFormat.Bc1UnormSrgb, new FormatInfo(Format.Bc1RgbaSrgb, 4, 4, 8, 4) },
|
||||
{ TextureFormat.Bc2UnormSrgb, new FormatInfo(Format.Bc2Srgb, 4, 4, 16, 4) },
|
||||
{ TextureFormat.Bc3UnormSrgb, new FormatInfo(Format.Bc3Srgb, 4, 4, 16, 4) },
|
||||
{ TextureFormat.Bc4Unorm, new FormatInfo(Format.Bc4Unorm, 4, 4, 8, 1) },
|
||||
{ TextureFormat.Bc4Snorm, new FormatInfo(Format.Bc4Snorm, 4, 4, 8, 1) },
|
||||
{ TextureFormat.Bc5Unorm, new FormatInfo(Format.Bc5Unorm, 4, 4, 16, 2) },
|
||||
{ TextureFormat.Bc5Snorm, new FormatInfo(Format.Bc5Snorm, 4, 4, 16, 2) },
|
||||
{ TextureFormat.Bc7UUnorm, new FormatInfo(Format.Bc7Unorm, 4, 4, 16, 4) },
|
||||
{ TextureFormat.Bc7UUnormSrgb, new FormatInfo(Format.Bc7Srgb, 4, 4, 16, 4) },
|
||||
{ TextureFormat.Bc6HSf16Float, new FormatInfo(Format.Bc6HSfloat, 4, 4, 16, 4) },
|
||||
{ TextureFormat.Bc6HUf16Float, new FormatInfo(Format.Bc6HUfloat, 4, 4, 16, 4) },
|
||||
{ TextureFormat.Etc2RgbUnorm, new FormatInfo(Format.Etc2RgbUnorm, 4, 4, 8, 3) },
|
||||
{ TextureFormat.Etc2RgbaUnorm, new FormatInfo(Format.Etc2RgbaUnorm, 4, 4, 16, 4) },
|
||||
{ TextureFormat.Etc2RgbUnormSrgb, new FormatInfo(Format.Etc2RgbSrgb, 4, 4, 8, 3) },
|
||||
{ TextureFormat.Etc2RgbaUnormSrgb, new FormatInfo(Format.Etc2RgbaSrgb, 4, 4, 16, 4) },
|
||||
{ TextureFormat.Astc2D4x4Unorm, new FormatInfo(Format.Astc4x4Unorm, 4, 4, 16, 4) },
|
||||
{ TextureFormat.Astc2D5x4Unorm, new FormatInfo(Format.Astc5x4Unorm, 5, 4, 16, 4) },
|
||||
{ TextureFormat.Astc2D5x5Unorm, new FormatInfo(Format.Astc5x5Unorm, 5, 5, 16, 4) },
|
||||
{ TextureFormat.Astc2D6x5Unorm, new FormatInfo(Format.Astc6x5Unorm, 6, 5, 16, 4) },
|
||||
{ TextureFormat.Astc2D6x6Unorm, new FormatInfo(Format.Astc6x6Unorm, 6, 6, 16, 4) },
|
||||
{ TextureFormat.Astc2D8x5Unorm, new FormatInfo(Format.Astc8x5Unorm, 8, 5, 16, 4) },
|
||||
{ TextureFormat.Astc2D8x6Unorm, new FormatInfo(Format.Astc8x6Unorm, 8, 6, 16, 4) },
|
||||
{ TextureFormat.Astc2D8x8Unorm, new FormatInfo(Format.Astc8x8Unorm, 8, 8, 16, 4) },
|
||||
{ TextureFormat.Astc2D10x5Unorm, new FormatInfo(Format.Astc10x5Unorm, 10, 5, 16, 4) },
|
||||
{ TextureFormat.Astc2D10x6Unorm, new FormatInfo(Format.Astc10x6Unorm, 10, 6, 16, 4) },
|
||||
{ TextureFormat.Astc2D10x8Unorm, new FormatInfo(Format.Astc10x8Unorm, 10, 8, 16, 4) },
|
||||
{ TextureFormat.Astc2D10x10Unorm, new FormatInfo(Format.Astc10x10Unorm, 10, 10, 16, 4) },
|
||||
{ TextureFormat.Astc2D12x10Unorm, new FormatInfo(Format.Astc12x10Unorm, 12, 10, 16, 4) },
|
||||
{ TextureFormat.Astc2D12x12Unorm, new FormatInfo(Format.Astc12x12Unorm, 12, 12, 16, 4) },
|
||||
{ TextureFormat.Astc2D4x4UnormSrgb, new FormatInfo(Format.Astc4x4Srgb, 4, 4, 16, 4) },
|
||||
{ TextureFormat.Astc2D5x4UnormSrgb, new FormatInfo(Format.Astc5x4Srgb, 5, 4, 16, 4) },
|
||||
{ TextureFormat.Astc2D5x5UnormSrgb, new FormatInfo(Format.Astc5x5Srgb, 5, 5, 16, 4) },
|
||||
{ TextureFormat.Astc2D6x5UnormSrgb, new FormatInfo(Format.Astc6x5Srgb, 6, 5, 16, 4) },
|
||||
{ TextureFormat.Astc2D6x6UnormSrgb, new FormatInfo(Format.Astc6x6Srgb, 6, 6, 16, 4) },
|
||||
{ TextureFormat.Astc2D8x5UnormSrgb, new FormatInfo(Format.Astc8x5Srgb, 8, 5, 16, 4) },
|
||||
{ TextureFormat.Astc2D8x6UnormSrgb, new FormatInfo(Format.Astc8x6Srgb, 8, 6, 16, 4) },
|
||||
{ TextureFormat.Astc2D8x8UnormSrgb, new FormatInfo(Format.Astc8x8Srgb, 8, 8, 16, 4) },
|
||||
{ TextureFormat.Astc2D10x5UnormSrgb, new FormatInfo(Format.Astc10x5Srgb, 10, 5, 16, 4) },
|
||||
{ TextureFormat.Astc2D10x6UnormSrgb, new FormatInfo(Format.Astc10x6Srgb, 10, 6, 16, 4) },
|
||||
{ TextureFormat.Astc2D10x8UnormSrgb, new FormatInfo(Format.Astc10x8Srgb, 10, 8, 16, 4) },
|
||||
{ TextureFormat.Astc2D10x10UnormSrgb, new FormatInfo(Format.Astc10x10Srgb, 10, 10, 16, 4) },
|
||||
{ TextureFormat.Astc2D12x10UnormSrgb, new FormatInfo(Format.Astc12x10Srgb, 12, 10, 16, 4) },
|
||||
{ TextureFormat.Astc2D12x12UnormSrgb, new FormatInfo(Format.Astc12x12Srgb, 12, 12, 16, 4) },
|
||||
{ TextureFormat.A5B5G5R1Unorm, new FormatInfo(Format.A1B5G5R5Unorm, 1, 1, 2, 4) }
|
||||
};
|
||||
|
||||
private static Dictionary<ulong, Format> _attribFormats = new Dictionary<ulong, Format>()
|
||||
private static readonly Dictionary<VertexAttributeFormat, Format> _attribFormats = new Dictionary<VertexAttributeFormat, Format>()
|
||||
{
|
||||
{ 0x13a00000, Format.R8Unorm },
|
||||
{ 0x0ba00000, Format.R8Snorm },
|
||||
{ 0x23a00000, Format.R8Uint },
|
||||
{ 0x1ba00000, Format.R8Sint },
|
||||
{ 0x3b600000, Format.R16Float },
|
||||
{ 0x13600000, Format.R16Unorm },
|
||||
{ 0x0b600000, Format.R16Snorm },
|
||||
{ 0x23600000, Format.R16Uint },
|
||||
{ 0x1b600000, Format.R16Sint },
|
||||
{ 0x3a400000, Format.R32Float },
|
||||
{ 0x22400000, Format.R32Uint },
|
||||
{ 0x1a400000, Format.R32Sint },
|
||||
{ 0x13000000, Format.R8G8Unorm },
|
||||
{ 0x0b000000, Format.R8G8Snorm },
|
||||
{ 0x23000000, Format.R8G8Uint },
|
||||
{ 0x1b000000, Format.R8G8Sint },
|
||||
{ 0x39e00000, Format.R16G16Float },
|
||||
{ 0x11e00000, Format.R16G16Unorm },
|
||||
{ 0x09e00000, Format.R16G16Snorm },
|
||||
{ 0x21e00000, Format.R16G16Uint },
|
||||
{ 0x19e00000, Format.R16G16Sint },
|
||||
{ 0x38800000, Format.R32G32Float },
|
||||
{ 0x20800000, Format.R32G32Uint },
|
||||
{ 0x18800000, Format.R32G32Sint },
|
||||
{ 0x12600000, Format.R8G8B8Unorm },
|
||||
{ 0x0a600000, Format.R8G8B8Snorm },
|
||||
{ 0x22600000, Format.R8G8B8Uint },
|
||||
{ 0x1a600000, Format.R8G8B8Sint },
|
||||
{ 0x38a00000, Format.R16G16B16Float },
|
||||
{ 0x10a00000, Format.R16G16B16Unorm },
|
||||
{ 0x08a00000, Format.R16G16B16Snorm },
|
||||
{ 0x20a00000, Format.R16G16B16Uint },
|
||||
{ 0x18a00000, Format.R16G16B16Sint },
|
||||
{ 0x38400000, Format.R32G32B32Float },
|
||||
{ 0x20400000, Format.R32G32B32Uint },
|
||||
{ 0x18400000, Format.R32G32B32Sint },
|
||||
{ 0x11400000, Format.R8G8B8A8Unorm },
|
||||
{ 0x09400000, Format.R8G8B8A8Snorm },
|
||||
{ 0x21400000, Format.R8G8B8A8Uint },
|
||||
{ 0x19400000, Format.R8G8B8A8Sint },
|
||||
{ 0x38600000, Format.R16G16B16A16Float },
|
||||
{ 0x10600000, Format.R16G16B16A16Unorm },
|
||||
{ 0x08600000, Format.R16G16B16A16Snorm },
|
||||
{ 0x20600000, Format.R16G16B16A16Uint },
|
||||
{ 0x18600000, Format.R16G16B16A16Sint },
|
||||
{ 0x38200000, Format.R32G32B32A32Float },
|
||||
{ 0x20200000, Format.R32G32B32A32Uint },
|
||||
{ 0x18200000, Format.R32G32B32A32Sint },
|
||||
{ 0x16000000, Format.R10G10B10A2Unorm },
|
||||
{ 0x26000000, Format.R10G10B10A2Uint },
|
||||
{ 0x3e200000, Format.R11G11B10Float },
|
||||
{ 0x2ba00000, Format.R8Uscaled },
|
||||
{ 0x33a00000, Format.R8Sscaled },
|
||||
{ 0x2b600000, Format.R16Uscaled },
|
||||
{ 0x33600000, Format.R16Sscaled },
|
||||
{ 0x2a400000, Format.R32Uscaled },
|
||||
{ 0x32400000, Format.R32Sscaled },
|
||||
{ 0x2b000000, Format.R8G8Uscaled },
|
||||
{ 0x33000000, Format.R8G8Sscaled },
|
||||
{ 0x29e00000, Format.R16G16Uscaled },
|
||||
{ 0x31e00000, Format.R16G16Sscaled },
|
||||
{ 0x28800000, Format.R32G32Uscaled },
|
||||
{ 0x30800000, Format.R32G32Sscaled },
|
||||
{ 0x2a600000, Format.R8G8B8Uscaled },
|
||||
{ 0x32600000, Format.R8G8B8Sscaled },
|
||||
{ 0x28a00000, Format.R16G16B16Uscaled },
|
||||
{ 0x30a00000, Format.R16G16B16Sscaled },
|
||||
{ 0x28400000, Format.R32G32B32Uscaled },
|
||||
{ 0x30400000, Format.R32G32B32Sscaled },
|
||||
{ 0x29400000, Format.R8G8B8A8Uscaled },
|
||||
{ 0x31400000, Format.R8G8B8A8Sscaled },
|
||||
{ 0x28600000, Format.R16G16B16A16Uscaled },
|
||||
{ 0x30600000, Format.R16G16B16A16Sscaled },
|
||||
{ 0x28200000, Format.R32G32B32A32Uscaled },
|
||||
{ 0x30200000, Format.R32G32B32A32Sscaled },
|
||||
{ 0x0e000000, Format.R10G10B10A2Snorm },
|
||||
{ 0x1e000000, Format.R10G10B10A2Sint },
|
||||
{ 0x2e000000, Format.R10G10B10A2Uscaled },
|
||||
{ 0x36000000, Format.R10G10B10A2Sscaled }
|
||||
{ VertexAttributeFormat.R8Unorm, Format.R8Unorm },
|
||||
{ VertexAttributeFormat.R8Snorm, Format.R8Snorm },
|
||||
{ VertexAttributeFormat.R8Uint, Format.R8Uint },
|
||||
{ VertexAttributeFormat.R8Sint, Format.R8Sint },
|
||||
{ VertexAttributeFormat.R16Float, Format.R16Float },
|
||||
{ VertexAttributeFormat.R16Unorm, Format.R16Unorm },
|
||||
{ VertexAttributeFormat.R16Snorm, Format.R16Snorm },
|
||||
{ VertexAttributeFormat.R16Uint, Format.R16Uint },
|
||||
{ VertexAttributeFormat.R16Sint, Format.R16Sint },
|
||||
{ VertexAttributeFormat.R32Float, Format.R32Float },
|
||||
{ VertexAttributeFormat.R32Uint, Format.R32Uint },
|
||||
{ VertexAttributeFormat.R32Sint, Format.R32Sint },
|
||||
{ VertexAttributeFormat.R8G8Unorm, Format.R8G8Unorm },
|
||||
{ VertexAttributeFormat.R8G8Snorm, Format.R8G8Snorm },
|
||||
{ VertexAttributeFormat.R8G8Uint, Format.R8G8Uint },
|
||||
{ VertexAttributeFormat.R8G8Sint, Format.R8G8Sint },
|
||||
{ VertexAttributeFormat.R16G16Float, Format.R16G16Float },
|
||||
{ VertexAttributeFormat.R16G16Unorm, Format.R16G16Unorm },
|
||||
{ VertexAttributeFormat.R16G16Snorm, Format.R16G16Snorm },
|
||||
{ VertexAttributeFormat.R16G16Uint, Format.R16G16Uint },
|
||||
{ VertexAttributeFormat.R16G16Sint, Format.R16G16Sint },
|
||||
{ VertexAttributeFormat.R32G32Float, Format.R32G32Float },
|
||||
{ VertexAttributeFormat.R32G32Uint, Format.R32G32Uint },
|
||||
{ VertexAttributeFormat.R32G32Sint, Format.R32G32Sint },
|
||||
{ VertexAttributeFormat.R8G8B8Unorm, Format.R8G8B8Unorm },
|
||||
{ VertexAttributeFormat.R8G8B8Snorm, Format.R8G8B8Snorm },
|
||||
{ VertexAttributeFormat.R8G8B8Uint, Format.R8G8B8Uint },
|
||||
{ VertexAttributeFormat.R8G8B8Sint, Format.R8G8B8Sint },
|
||||
{ VertexAttributeFormat.R16G16B16Float, Format.R16G16B16Float },
|
||||
{ VertexAttributeFormat.R16G16B16Unorm, Format.R16G16B16Unorm },
|
||||
{ VertexAttributeFormat.R16G16B16Snorm, Format.R16G16B16Snorm },
|
||||
{ VertexAttributeFormat.R16G16B16Uint, Format.R16G16B16Uint },
|
||||
{ VertexAttributeFormat.R16G16B16Sint, Format.R16G16B16Sint },
|
||||
{ VertexAttributeFormat.R32G32B32Float, Format.R32G32B32Float },
|
||||
{ VertexAttributeFormat.R32G32B32Uint, Format.R32G32B32Uint },
|
||||
{ VertexAttributeFormat.R32G32B32Sint, Format.R32G32B32Sint },
|
||||
{ VertexAttributeFormat.R8G8B8A8Unorm, Format.R8G8B8A8Unorm },
|
||||
{ VertexAttributeFormat.R8G8B8A8Snorm, Format.R8G8B8A8Snorm },
|
||||
{ VertexAttributeFormat.R8G8B8A8Uint, Format.R8G8B8A8Uint },
|
||||
{ VertexAttributeFormat.R8G8B8A8Sint, Format.R8G8B8A8Sint },
|
||||
{ VertexAttributeFormat.R16G16B16A16Float, Format.R16G16B16A16Float },
|
||||
{ VertexAttributeFormat.R16G16B16A16Unorm, Format.R16G16B16A16Unorm },
|
||||
{ VertexAttributeFormat.R16G16B16A16Snorm, Format.R16G16B16A16Snorm },
|
||||
{ VertexAttributeFormat.R16G16B16A16Uint, Format.R16G16B16A16Uint },
|
||||
{ VertexAttributeFormat.R16G16B16A16Sint, Format.R16G16B16A16Sint },
|
||||
{ VertexAttributeFormat.R32G32B32A32Float, Format.R32G32B32A32Float },
|
||||
{ VertexAttributeFormat.R32G32B32A32Uint, Format.R32G32B32A32Uint },
|
||||
{ VertexAttributeFormat.R32G32B32A32Sint, Format.R32G32B32A32Sint },
|
||||
{ VertexAttributeFormat.A2B10G10R10Unorm, Format.R10G10B10A2Unorm },
|
||||
{ VertexAttributeFormat.A2B10G10R10Uint, Format.R10G10B10A2Uint },
|
||||
{ VertexAttributeFormat.B10G11R11Float, Format.R11G11B10Float },
|
||||
{ VertexAttributeFormat.R8Uscaled, Format.R8Uscaled },
|
||||
{ VertexAttributeFormat.R8Sscaled, Format.R8Sscaled },
|
||||
{ VertexAttributeFormat.R16Uscaled, Format.R16Uscaled },
|
||||
{ VertexAttributeFormat.R16Sscaled, Format.R16Sscaled },
|
||||
{ VertexAttributeFormat.R32Uscaled, Format.R32Uscaled },
|
||||
{ VertexAttributeFormat.R32Sscaled, Format.R32Sscaled },
|
||||
{ VertexAttributeFormat.R8G8Uscaled, Format.R8G8Uscaled },
|
||||
{ VertexAttributeFormat.R8G8Sscaled, Format.R8G8Sscaled },
|
||||
{ VertexAttributeFormat.R16G16Uscaled, Format.R16G16Uscaled },
|
||||
{ VertexAttributeFormat.R16G16Sscaled, Format.R16G16Sscaled },
|
||||
{ VertexAttributeFormat.R32G32Uscaled, Format.R32G32Uscaled },
|
||||
{ VertexAttributeFormat.R32G32Sscaled, Format.R32G32Sscaled },
|
||||
{ VertexAttributeFormat.R8G8B8Uscaled, Format.R8G8B8Uscaled },
|
||||
{ VertexAttributeFormat.R8G8B8Sscaled, Format.R8G8B8Sscaled },
|
||||
{ VertexAttributeFormat.R16G16B16Uscaled, Format.R16G16B16Uscaled },
|
||||
{ VertexAttributeFormat.R16G16B16Sscaled, Format.R16G16B16Sscaled },
|
||||
{ VertexAttributeFormat.R32G32B32Uscaled, Format.R32G32B32Uscaled },
|
||||
{ VertexAttributeFormat.R32G32B32Sscaled, Format.R32G32B32Sscaled },
|
||||
{ VertexAttributeFormat.R8G8B8A8Uscaled, Format.R8G8B8A8Uscaled },
|
||||
{ VertexAttributeFormat.R8G8B8A8Sscaled, Format.R8G8B8A8Sscaled },
|
||||
{ VertexAttributeFormat.R16G16B16A16Uscaled, Format.R16G16B16A16Uscaled },
|
||||
{ VertexAttributeFormat.R16G16B16A16Sscaled, Format.R16G16B16A16Sscaled },
|
||||
{ VertexAttributeFormat.R32G32B32A32Uscaled, Format.R32G32B32A32Uscaled },
|
||||
{ VertexAttributeFormat.R32G32B32A32Sscaled, Format.R32G32B32A32Sscaled },
|
||||
{ VertexAttributeFormat.A2B10G10R10Snorm, Format.R10G10B10A2Snorm },
|
||||
{ VertexAttributeFormat.A2B10G10R10Sint, Format.R10G10B10A2Sint },
|
||||
{ VertexAttributeFormat.A2B10G10R10Uscaled, Format.R10G10B10A2Uscaled },
|
||||
{ VertexAttributeFormat.A2B10G10R10Sscaled, Format.R10G10B10A2Sscaled }
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
@ -210,7 +557,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||
{
|
||||
encoded |= (isSrgb ? 1u << 19 : 0u);
|
||||
|
||||
return _textureFormats.TryGetValue(encoded, out format);
|
||||
return _textureFormats.TryGetValue((TextureFormat)encoded, out format);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -221,7 +568,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||
/// <returns>True if the format is valid, false otherwise</returns>
|
||||
public static bool TryGetAttribFormat(uint encoded, out Format format)
|
||||
{
|
||||
return _attribFormats.TryGetValue(encoded, out format);
|
||||
return _attribFormats.TryGetValue((VertexAttributeFormat)encoded, out format);
|
||||
}
|
||||
}
|
||||
}
|
@ -57,5 +57,19 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc.AccountService
|
||||
{
|
||||
return _managerServer.StoreOpenContext(context);
|
||||
}
|
||||
|
||||
[CommandHipc(170)] // 6.0.0+
|
||||
// LoadNetworkServiceLicenseKindAsync() -> object<nn::account::detail::IAsyncNetworkServiceLicenseKindContext>
|
||||
public ResultCode LoadNetworkServiceLicenseKindAsync(ServiceCtx context)
|
||||
{
|
||||
ResultCode resultCode = _managerServer.LoadNetworkServiceLicenseKindAsync(context, out IAsyncNetworkServiceLicenseKindContext asyncContext);
|
||||
|
||||
if (resultCode == ResultCode.Success)
|
||||
{
|
||||
MakeObject(context, asyncContext);
|
||||
}
|
||||
|
||||
return resultCode;
|
||||
}
|
||||
}
|
||||
}
|
@ -166,5 +166,22 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc.AccountService
|
||||
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
public ResultCode LoadNetworkServiceLicenseKindAsync(ServiceCtx context, out IAsyncNetworkServiceLicenseKindContext asyncContext)
|
||||
{
|
||||
KEvent asyncEvent = new KEvent(context.Device.System.KernelContext);
|
||||
AsyncExecution asyncExecution = new AsyncExecution(asyncEvent);
|
||||
|
||||
Logger.Stub?.PrintStub(LogClass.ServiceAcc);
|
||||
|
||||
// NOTE: This is an extension of the data retrieved from the id token cache.
|
||||
asyncExecution.Initialize(1000, EnsureIdTokenCacheAsyncImpl);
|
||||
|
||||
asyncContext = new IAsyncNetworkServiceLicenseKindContext(asyncExecution, NetworkServiceLicenseKind.Subscribed);
|
||||
|
||||
// return ResultCode.NullObject if the IAsyncNetworkServiceLicenseKindContext pointer is null. Doesn't occur in our case.
|
||||
|
||||
return ResultCode.Success;
|
||||
}
|
||||
}
|
||||
}
|
@ -7,18 +7,18 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc
|
||||
{
|
||||
class IAsyncContext : IpcService
|
||||
{
|
||||
AsyncExecution _asyncExecution;
|
||||
protected AsyncExecution AsyncExecution;
|
||||
|
||||
public IAsyncContext(AsyncExecution asyncExecution)
|
||||
{
|
||||
_asyncExecution = asyncExecution;
|
||||
AsyncExecution = asyncExecution;
|
||||
}
|
||||
|
||||
[CommandHipc(0)]
|
||||
// GetSystemEvent() -> handle<copy>
|
||||
public ResultCode GetSystemEvent(ServiceCtx context)
|
||||
{
|
||||
if (context.Process.HandleTable.GenerateHandle(_asyncExecution.SystemEvent.ReadableEvent, out int _systemEventHandle) != KernelResult.Success)
|
||||
if (context.Process.HandleTable.GenerateHandle(AsyncExecution.SystemEvent.ReadableEvent, out int _systemEventHandle) != KernelResult.Success)
|
||||
{
|
||||
throw new InvalidOperationException("Out of handles!");
|
||||
}
|
||||
@ -32,14 +32,14 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc
|
||||
// Cancel()
|
||||
public ResultCode Cancel(ServiceCtx context)
|
||||
{
|
||||
if (!_asyncExecution.IsInitialized)
|
||||
if (!AsyncExecution.IsInitialized)
|
||||
{
|
||||
return ResultCode.AsyncExecutionNotInitialized;
|
||||
}
|
||||
|
||||
if (_asyncExecution.IsRunning)
|
||||
if (AsyncExecution.IsRunning)
|
||||
{
|
||||
_asyncExecution.Cancel();
|
||||
AsyncExecution.Cancel();
|
||||
}
|
||||
|
||||
return ResultCode.Success;
|
||||
@ -49,12 +49,12 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc
|
||||
// HasDone() -> b8
|
||||
public ResultCode HasDone(ServiceCtx context)
|
||||
{
|
||||
if (!_asyncExecution.IsInitialized)
|
||||
if (!AsyncExecution.IsInitialized)
|
||||
{
|
||||
return ResultCode.AsyncExecutionNotInitialized;
|
||||
}
|
||||
|
||||
context.ResponseData.Write(_asyncExecution.SystemEvent.ReadableEvent.IsSignaled());
|
||||
context.ResponseData.Write(AsyncExecution.SystemEvent.ReadableEvent.IsSignaled());
|
||||
|
||||
return ResultCode.Success;
|
||||
}
|
||||
@ -63,12 +63,12 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc
|
||||
// GetResult()
|
||||
public ResultCode GetResult(ServiceCtx context)
|
||||
{
|
||||
if (!_asyncExecution.IsInitialized)
|
||||
if (!AsyncExecution.IsInitialized)
|
||||
{
|
||||
return ResultCode.AsyncExecutionNotInitialized;
|
||||
}
|
||||
|
||||
if (!_asyncExecution.SystemEvent.ReadableEvent.IsSignaled())
|
||||
if (!AsyncExecution.SystemEvent.ReadableEvent.IsSignaled())
|
||||
{
|
||||
return ResultCode.Unknown41;
|
||||
}
|
||||
|
@ -0,0 +1,38 @@
|
||||
using Ryujinx.HLE.HOS.Services.Account.Acc.AsyncContext;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.Account.Acc
|
||||
{
|
||||
class IAsyncNetworkServiceLicenseKindContext : IAsyncContext
|
||||
{
|
||||
private NetworkServiceLicenseKind? _serviceLicenseKind;
|
||||
|
||||
public IAsyncNetworkServiceLicenseKindContext(AsyncExecution asyncExecution, NetworkServiceLicenseKind? serviceLicenseKind) : base(asyncExecution)
|
||||
{
|
||||
_serviceLicenseKind = serviceLicenseKind;
|
||||
}
|
||||
|
||||
[CommandHipc(100)]
|
||||
// GetNetworkServiceLicenseKind() -> nn::account::NetworkServiceLicenseKind
|
||||
public ResultCode GetNetworkServiceLicenseKind(ServiceCtx context)
|
||||
{
|
||||
if (!AsyncExecution.IsInitialized)
|
||||
{
|
||||
return ResultCode.AsyncExecutionNotInitialized;
|
||||
}
|
||||
|
||||
if (!AsyncExecution.SystemEvent.ReadableEvent.IsSignaled())
|
||||
{
|
||||
return ResultCode.Unknown41;
|
||||
}
|
||||
|
||||
if (!_serviceLicenseKind.HasValue)
|
||||
{
|
||||
return ResultCode.MissingNetworkServiceLicenseKind;
|
||||
}
|
||||
|
||||
context.ResponseData.Write((uint)_serviceLicenseKind.Value);
|
||||
|
||||
return ResultCode.Success;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
namespace Ryujinx.HLE.HOS.Services.Account.Acc
|
||||
{
|
||||
enum NetworkServiceLicenseKind : uint
|
||||
{
|
||||
NoSubscription,
|
||||
Subscribed
|
||||
}
|
||||
}
|
@ -7,17 +7,18 @@ namespace Ryujinx.HLE.HOS.Services.Account
|
||||
|
||||
Success = 0,
|
||||
|
||||
NullArgument = (20 << ErrorCodeShift) | ModuleId,
|
||||
InvalidArgument = (22 << ErrorCodeShift) | ModuleId,
|
||||
NullInputBuffer = (30 << ErrorCodeShift) | ModuleId,
|
||||
InvalidBufferSize = (31 << ErrorCodeShift) | ModuleId,
|
||||
InvalidBuffer = (32 << ErrorCodeShift) | ModuleId,
|
||||
AsyncExecutionNotInitialized = (40 << ErrorCodeShift) | ModuleId,
|
||||
Unknown41 = (41 << ErrorCodeShift) | ModuleId,
|
||||
InternetRequestDenied = (59 << ErrorCodeShift) | ModuleId,
|
||||
UserNotFound = (100 << ErrorCodeShift) | ModuleId,
|
||||
NullObject = (302 << ErrorCodeShift) | ModuleId,
|
||||
Unknown341 = (341 << ErrorCodeShift) | ModuleId,
|
||||
InvalidIdTokenCacheBufferSize = (451 << ErrorCodeShift) | ModuleId
|
||||
NullArgument = (20 << ErrorCodeShift) | ModuleId,
|
||||
InvalidArgument = (22 << ErrorCodeShift) | ModuleId,
|
||||
NullInputBuffer = (30 << ErrorCodeShift) | ModuleId,
|
||||
InvalidBufferSize = (31 << ErrorCodeShift) | ModuleId,
|
||||
InvalidBuffer = (32 << ErrorCodeShift) | ModuleId,
|
||||
AsyncExecutionNotInitialized = (40 << ErrorCodeShift) | ModuleId,
|
||||
Unknown41 = (41 << ErrorCodeShift) | ModuleId,
|
||||
InternetRequestDenied = (59 << ErrorCodeShift) | ModuleId,
|
||||
UserNotFound = (100 << ErrorCodeShift) | ModuleId,
|
||||
NullObject = (302 << ErrorCodeShift) | ModuleId,
|
||||
Unknown341 = (341 << ErrorCodeShift) | ModuleId,
|
||||
MissingNetworkServiceLicenseKind = (400 << ErrorCodeShift) | ModuleId,
|
||||
InvalidIdTokenCacheBufferSize = (451 << ErrorCodeShift) | ModuleId
|
||||
}
|
||||
}
|
||||
|
@ -336,6 +336,12 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
|
||||
context.Memory.Write(outputBufferPosition + (ulong)(i * Unsafe.SizeOf<PollEventData>()), events[i].Data);
|
||||
}
|
||||
|
||||
// In case of non blocking call timeout should not be returned.
|
||||
if (timeout == 0 && errno == LinuxError.ETIMEDOUT)
|
||||
{
|
||||
errno = LinuxError.SUCCESS;
|
||||
}
|
||||
|
||||
return WriteBsdResult(context, updateCount, errno);
|
||||
}
|
||||
|
||||
@ -567,14 +573,18 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
|
||||
|
||||
LinuxError errno = LinuxError.EBADF;
|
||||
ISocket socket = _context.RetrieveSocket(socketFd);
|
||||
|
||||
if (socket != null)
|
||||
{
|
||||
errno = LinuxError.SUCCESS;
|
||||
errno = LinuxError.ENOTCONN;
|
||||
|
||||
WriteSockAddr(context, bufferPosition, socket, true);
|
||||
WriteBsdResult(context, 0, errno);
|
||||
context.ResponseData.Write(Unsafe.SizeOf<BsdSockAddr>());
|
||||
if (socket.RemoteEndPoint != null)
|
||||
{
|
||||
errno = LinuxError.SUCCESS;
|
||||
|
||||
WriteSockAddr(context, bufferPosition, socket, true);
|
||||
WriteBsdResult(context, 0, errno);
|
||||
context.ResponseData.Write(Unsafe.SizeOf<BsdSockAddr>());
|
||||
}
|
||||
}
|
||||
|
||||
return WriteBsdResult(context, 0, errno);
|
||||
@ -876,6 +886,91 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
|
||||
return WriteBsdResult(context, newSockFd, errno);
|
||||
}
|
||||
|
||||
|
||||
[CommandHipc(29)] // 7.0.0+
|
||||
// RecvMMsg(u32 fd, u32 vlen, u32 flags, u32 reserved, nn::socket::TimeVal timeout) -> (i32 ret, u32 bsd_errno, buffer<bytes, 6> message);
|
||||
public ResultCode RecvMMsg(ServiceCtx context)
|
||||
{
|
||||
int socketFd = context.RequestData.ReadInt32();
|
||||
int vlen = context.RequestData.ReadInt32();
|
||||
BsdSocketFlags socketFlags = (BsdSocketFlags)context.RequestData.ReadInt32();
|
||||
uint reserved = context.RequestData.ReadUInt32();
|
||||
TimeVal timeout = context.RequestData.ReadStruct<TimeVal>();
|
||||
|
||||
ulong receivePosition = context.Request.ReceiveBuff[0].Position;
|
||||
ulong receiveLength = context.Request.ReceiveBuff[0].Size;
|
||||
|
||||
WritableRegion receiveRegion = context.Memory.GetWritableRegion(receivePosition, (int)receiveLength);
|
||||
|
||||
LinuxError errno = LinuxError.EBADF;
|
||||
ISocket socket = _context.RetrieveSocket(socketFd);
|
||||
int result = -1;
|
||||
|
||||
if (socket != null)
|
||||
{
|
||||
errno = BsdMMsgHdr.Deserialize(out BsdMMsgHdr message, receiveRegion.Memory.Span, vlen);
|
||||
|
||||
if (errno == LinuxError.SUCCESS)
|
||||
{
|
||||
errno = socket.RecvMMsg(out result, message, socketFlags, timeout);
|
||||
|
||||
if (errno == LinuxError.SUCCESS)
|
||||
{
|
||||
errno = BsdMMsgHdr.Serialize(receiveRegion.Memory.Span, message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (errno == LinuxError.SUCCESS)
|
||||
{
|
||||
SetResultErrno(socket, result);
|
||||
receiveRegion.Dispose();
|
||||
}
|
||||
|
||||
return WriteBsdResult(context, result, errno);
|
||||
}
|
||||
|
||||
[CommandHipc(30)] // 7.0.0+
|
||||
// SendMMsg(u32 fd, u32 vlen, u32 flags) -> (i32 ret, u32 bsd_errno, buffer<bytes, 6> message);
|
||||
public ResultCode SendMMsg(ServiceCtx context)
|
||||
{
|
||||
int socketFd = context.RequestData.ReadInt32();
|
||||
int vlen = context.RequestData.ReadInt32();
|
||||
BsdSocketFlags socketFlags = (BsdSocketFlags)context.RequestData.ReadInt32();
|
||||
|
||||
ulong receivePosition = context.Request.ReceiveBuff[0].Position;
|
||||
ulong receiveLength = context.Request.ReceiveBuff[0].Size;
|
||||
|
||||
WritableRegion receiveRegion = context.Memory.GetWritableRegion(receivePosition, (int)receiveLength);
|
||||
|
||||
LinuxError errno = LinuxError.EBADF;
|
||||
ISocket socket = _context.RetrieveSocket(socketFd);
|
||||
int result = -1;
|
||||
|
||||
if (socket != null)
|
||||
{
|
||||
errno = BsdMMsgHdr.Deserialize(out BsdMMsgHdr message, receiveRegion.Memory.Span, vlen);
|
||||
|
||||
if (errno == LinuxError.SUCCESS)
|
||||
{
|
||||
errno = socket.SendMMsg(out result, message, socketFlags);
|
||||
|
||||
if (errno == LinuxError.SUCCESS)
|
||||
{
|
||||
errno = BsdMMsgHdr.Serialize(receiveRegion.Memory.Span, message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (errno == LinuxError.SUCCESS)
|
||||
{
|
||||
SetResultErrno(socket, result);
|
||||
receiveRegion.Dispose();
|
||||
}
|
||||
|
||||
return WriteBsdResult(context, result, errno);
|
||||
}
|
||||
|
||||
[CommandHipc(31)] // 7.0.0+
|
||||
// EventFd(u64 initval, nn::socket::EventFdFlags flags) -> (i32 ret, u32 bsd_errno)
|
||||
public ResultCode EventFd(ServiceCtx context)
|
||||
@ -897,4 +992,4 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
|
||||
return WriteBsdResult(context, newSockFd, errno);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,12 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
|
||||
|
||||
LinuxError SendTo(out int sendSize, ReadOnlySpan<byte> buffer, int size, BsdSocketFlags flags, IPEndPoint remoteEndPoint);
|
||||
|
||||
LinuxError RecvMMsg(out int vlen, BsdMMsgHdr message, BsdSocketFlags flags, TimeVal timeout);
|
||||
|
||||
LinuxError SendMMsg(out int vlen, BsdMMsgHdr message, BsdSocketFlags flags);
|
||||
|
||||
LinuxError GetSocketOption(BsdSocketOption option, SocketOptionLevel level, Span<byte> optionValue);
|
||||
|
||||
LinuxError SetSocketOption(BsdSocketOption option, SocketOptionLevel level, ReadOnlySpan<byte> optionValue);
|
||||
|
||||
bool Poll(int microSeconds, SelectMode mode);
|
||||
|
@ -1,5 +1,7 @@
|
||||
using Ryujinx.Common.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Runtime.InteropServices;
|
||||
@ -323,9 +325,14 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
|
||||
|
||||
int value = optionValue.Length >= 4 ? MemoryMarshal.Read<int>(optionValue) : MemoryMarshal.Read<byte>(optionValue);
|
||||
|
||||
if (option == BsdSocketOption.SoLinger)
|
||||
if (level == SocketOptionLevel.Socket && option == BsdSocketOption.SoLinger)
|
||||
{
|
||||
int value2 = MemoryMarshal.Read<int>(optionValue[4..]);
|
||||
int value2 = 0;
|
||||
|
||||
if (optionValue.Length >= 8)
|
||||
{
|
||||
value2 = MemoryMarshal.Read<int>(optionValue[4..]);
|
||||
}
|
||||
|
||||
Socket.SetSocketOption(level, SocketOptionName.Linger, new LingerOption(value != 0, value2));
|
||||
}
|
||||
@ -351,5 +358,165 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
|
||||
{
|
||||
return Send(out writeSize, buffer, BsdSocketFlags.None);
|
||||
}
|
||||
|
||||
private bool CanSupportMMsgHdr(BsdMMsgHdr message)
|
||||
{
|
||||
for (int i = 0; i < message.Messages.Length; i++)
|
||||
{
|
||||
if (message.Messages[i].Name != null ||
|
||||
message.Messages[i].Control != null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static IList<ArraySegment<byte>> ConvertMessagesToBuffer(BsdMMsgHdr message)
|
||||
{
|
||||
int segmentCount = 0;
|
||||
int index = 0;
|
||||
|
||||
foreach (BsdMsgHdr msgHeader in message.Messages)
|
||||
{
|
||||
segmentCount += msgHeader.Iov.Length;
|
||||
}
|
||||
|
||||
ArraySegment<byte>[] buffers = new ArraySegment<byte>[segmentCount];
|
||||
|
||||
foreach (BsdMsgHdr msgHeader in message.Messages)
|
||||
{
|
||||
foreach (byte[] iov in msgHeader.Iov)
|
||||
{
|
||||
buffers[index++] = new ArraySegment<byte>(iov);
|
||||
}
|
||||
|
||||
// Clear the length
|
||||
msgHeader.Length = 0;
|
||||
}
|
||||
|
||||
return buffers;
|
||||
}
|
||||
|
||||
private static void UpdateMessages(out int vlen, BsdMMsgHdr message, int transferedSize)
|
||||
{
|
||||
int bytesLeft = transferedSize;
|
||||
int index = 0;
|
||||
|
||||
while (bytesLeft > 0)
|
||||
{
|
||||
// First ensure we haven't finished all buffers
|
||||
if (index >= message.Messages.Length)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
BsdMsgHdr msgHeader = message.Messages[index];
|
||||
|
||||
int possiblyTransferedBytes = 0;
|
||||
|
||||
foreach (byte[] iov in msgHeader.Iov)
|
||||
{
|
||||
possiblyTransferedBytes += iov.Length;
|
||||
}
|
||||
|
||||
int storedBytes;
|
||||
|
||||
if (bytesLeft > possiblyTransferedBytes)
|
||||
{
|
||||
storedBytes = possiblyTransferedBytes;
|
||||
index++;
|
||||
}
|
||||
else
|
||||
{
|
||||
storedBytes = bytesLeft;
|
||||
}
|
||||
|
||||
msgHeader.Length = (uint)storedBytes;
|
||||
bytesLeft -= storedBytes;
|
||||
}
|
||||
|
||||
Debug.Assert(bytesLeft == 0);
|
||||
|
||||
vlen = index + 1;
|
||||
}
|
||||
|
||||
// TODO: Find a way to support passing the timeout somehow without changing the socket ReceiveTimeout.
|
||||
public LinuxError RecvMMsg(out int vlen, BsdMMsgHdr message, BsdSocketFlags flags, TimeVal timeout)
|
||||
{
|
||||
vlen = 0;
|
||||
|
||||
if (message.Messages.Length == 0)
|
||||
{
|
||||
return LinuxError.SUCCESS;
|
||||
}
|
||||
|
||||
if (!CanSupportMMsgHdr(message))
|
||||
{
|
||||
Logger.Warning?.Print(LogClass.ServiceBsd, $"Unsupported BsdMMsgHdr");
|
||||
|
||||
return LinuxError.EOPNOTSUPP;
|
||||
}
|
||||
|
||||
if (message.Messages.Length == 0)
|
||||
{
|
||||
return LinuxError.SUCCESS;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
int receiveSize = Socket.Receive(ConvertMessagesToBuffer(message), ConvertBsdSocketFlags(flags), out SocketError socketError);
|
||||
|
||||
if (receiveSize > 0)
|
||||
{
|
||||
UpdateMessages(out vlen, message, receiveSize);
|
||||
}
|
||||
|
||||
return WinSockHelper.ConvertError((WsaError)socketError);
|
||||
}
|
||||
catch (SocketException exception)
|
||||
{
|
||||
return WinSockHelper.ConvertError((WsaError)exception.ErrorCode);
|
||||
}
|
||||
}
|
||||
|
||||
public LinuxError SendMMsg(out int vlen, BsdMMsgHdr message, BsdSocketFlags flags)
|
||||
{
|
||||
vlen = 0;
|
||||
|
||||
if (message.Messages.Length == 0)
|
||||
{
|
||||
return LinuxError.SUCCESS;
|
||||
}
|
||||
|
||||
if (!CanSupportMMsgHdr(message))
|
||||
{
|
||||
Logger.Warning?.Print(LogClass.ServiceBsd, $"Unsupported BsdMMsgHdr");
|
||||
|
||||
return LinuxError.EOPNOTSUPP;
|
||||
}
|
||||
|
||||
if (message.Messages.Length == 0)
|
||||
{
|
||||
return LinuxError.SUCCESS;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
int sendSize = Socket.Send(ConvertMessagesToBuffer(message), ConvertBsdSocketFlags(flags), out SocketError socketError);
|
||||
|
||||
if (sendSize > 0)
|
||||
{
|
||||
UpdateMessages(out vlen, message, sendSize);
|
||||
}
|
||||
|
||||
return WinSockHelper.ConvertError((WsaError)socketError);
|
||||
}
|
||||
catch (SocketException exception)
|
||||
{
|
||||
return WinSockHelper.ConvertError((WsaError)exception.ErrorCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
56
Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdMMsgHdr.cs
Normal file
56
Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdMMsgHdr.cs
Normal file
@ -0,0 +1,56 @@
|
||||
using System;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
|
||||
{
|
||||
class BsdMMsgHdr
|
||||
{
|
||||
public BsdMsgHdr[] Messages { get; }
|
||||
|
||||
private BsdMMsgHdr(BsdMsgHdr[] messages)
|
||||
{
|
||||
Messages = messages;
|
||||
}
|
||||
|
||||
public static LinuxError Serialize(Span<byte> rawData, BsdMMsgHdr message)
|
||||
{
|
||||
rawData[0] = 0x8;
|
||||
rawData = rawData[1..];
|
||||
|
||||
for (int index = 0; index < message.Messages.Length; index++)
|
||||
{
|
||||
LinuxError res = BsdMsgHdr.Serialize(ref rawData, message.Messages[index]);
|
||||
|
||||
if (res != LinuxError.SUCCESS)
|
||||
{
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
return LinuxError.SUCCESS;
|
||||
}
|
||||
|
||||
public static LinuxError Deserialize(out BsdMMsgHdr message, ReadOnlySpan<byte> rawData, int vlen)
|
||||
{
|
||||
message = null;
|
||||
|
||||
BsdMsgHdr[] messages = new BsdMsgHdr[vlen];
|
||||
|
||||
// Skip "header" byte (Nintendo also ignore it)
|
||||
rawData = rawData[1..];
|
||||
|
||||
for (int index = 0; index < messages.Length; index++)
|
||||
{
|
||||
LinuxError res = BsdMsgHdr.Deserialize(out messages[index], ref rawData);
|
||||
|
||||
if (res != LinuxError.SUCCESS)
|
||||
{
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
message = new BsdMMsgHdr(messages);
|
||||
|
||||
return LinuxError.SUCCESS;
|
||||
}
|
||||
}
|
||||
}
|
212
Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdMsgHdr.cs
Normal file
212
Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/BsdMsgHdr.cs
Normal file
@ -0,0 +1,212 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
|
||||
{
|
||||
class BsdMsgHdr
|
||||
{
|
||||
public byte[] Name { get; }
|
||||
public byte[][] Iov { get; }
|
||||
public byte[] Control { get; }
|
||||
public BsdSocketFlags Flags { get; }
|
||||
public uint Length;
|
||||
|
||||
private BsdMsgHdr(byte[] name, byte[][] iov, byte[] control, BsdSocketFlags flags, uint length)
|
||||
{
|
||||
Name = name;
|
||||
Iov = iov;
|
||||
Control = control;
|
||||
Flags = flags;
|
||||
Length = length;
|
||||
}
|
||||
|
||||
public static LinuxError Serialize(ref Span<byte> rawData, BsdMsgHdr message)
|
||||
{
|
||||
int msgNameLength = message.Name == null ? 0 : message.Name.Length;
|
||||
int iovCount = message.Iov == null ? 0 : message.Iov.Length;
|
||||
int controlLength = message.Control == null ? 0 : message.Control.Length;
|
||||
BsdSocketFlags flags = message.Flags;
|
||||
|
||||
if (!MemoryMarshal.TryWrite(rawData, ref msgNameLength))
|
||||
{
|
||||
return LinuxError.EFAULT;
|
||||
}
|
||||
|
||||
rawData = rawData[sizeof(uint)..];
|
||||
|
||||
if (msgNameLength > 0)
|
||||
{
|
||||
if (rawData.Length < msgNameLength)
|
||||
{
|
||||
return LinuxError.EFAULT;
|
||||
}
|
||||
|
||||
message.Name.CopyTo(rawData);
|
||||
rawData = rawData[msgNameLength..];
|
||||
}
|
||||
|
||||
if (!MemoryMarshal.TryWrite(rawData, ref iovCount))
|
||||
{
|
||||
return LinuxError.EFAULT;
|
||||
}
|
||||
|
||||
rawData = rawData[sizeof(uint)..];
|
||||
|
||||
if (iovCount > 0)
|
||||
{
|
||||
for (int index = 0; index < iovCount; index++)
|
||||
{
|
||||
ulong iovLength = (ulong)message.Iov[index].Length;
|
||||
|
||||
if (!MemoryMarshal.TryWrite(rawData, ref iovLength))
|
||||
{
|
||||
return LinuxError.EFAULT;
|
||||
}
|
||||
|
||||
rawData = rawData[sizeof(ulong)..];
|
||||
|
||||
if (iovLength > 0)
|
||||
{
|
||||
if ((ulong)rawData.Length < iovLength)
|
||||
{
|
||||
return LinuxError.EFAULT;
|
||||
}
|
||||
|
||||
message.Iov[index].CopyTo(rawData);
|
||||
rawData = rawData[(int)iovLength..];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!MemoryMarshal.TryWrite(rawData, ref controlLength))
|
||||
{
|
||||
return LinuxError.EFAULT;
|
||||
}
|
||||
|
||||
rawData = rawData[sizeof(uint)..];
|
||||
|
||||
if (controlLength > 0)
|
||||
{
|
||||
if (rawData.Length < controlLength)
|
||||
{
|
||||
return LinuxError.EFAULT;
|
||||
}
|
||||
|
||||
message.Control.CopyTo(rawData);
|
||||
rawData = rawData[controlLength..];
|
||||
}
|
||||
|
||||
if (!MemoryMarshal.TryWrite(rawData, ref flags))
|
||||
{
|
||||
return LinuxError.EFAULT;
|
||||
}
|
||||
|
||||
rawData = rawData[sizeof(BsdSocketFlags)..];
|
||||
|
||||
if (!MemoryMarshal.TryWrite(rawData, ref message.Length))
|
||||
{
|
||||
return LinuxError.EFAULT;
|
||||
}
|
||||
|
||||
rawData = rawData[sizeof(uint)..];
|
||||
|
||||
return LinuxError.SUCCESS;
|
||||
}
|
||||
|
||||
public static LinuxError Deserialize(out BsdMsgHdr message, ref ReadOnlySpan<byte> rawData)
|
||||
{
|
||||
byte[] name = null;
|
||||
byte[][] iov = null;
|
||||
byte[] control = null;
|
||||
|
||||
message = null;
|
||||
|
||||
if (!MemoryMarshal.TryRead(rawData, out uint msgNameLength))
|
||||
{
|
||||
return LinuxError.EFAULT;
|
||||
}
|
||||
|
||||
rawData = rawData[sizeof(uint)..];
|
||||
|
||||
if (msgNameLength > 0)
|
||||
{
|
||||
if (rawData.Length < msgNameLength)
|
||||
{
|
||||
return LinuxError.EFAULT;
|
||||
}
|
||||
|
||||
name = rawData[..(int)msgNameLength].ToArray();
|
||||
rawData = rawData[(int)msgNameLength..];
|
||||
}
|
||||
|
||||
if (!MemoryMarshal.TryRead(rawData, out uint iovCount))
|
||||
{
|
||||
return LinuxError.EFAULT;
|
||||
}
|
||||
|
||||
rawData = rawData[sizeof(uint)..];
|
||||
|
||||
if (iovCount > 0)
|
||||
{
|
||||
iov = new byte[iovCount][];
|
||||
|
||||
for (int index = 0; index < iov.Length; index++)
|
||||
{
|
||||
if (!MemoryMarshal.TryRead(rawData, out ulong iovLength))
|
||||
{
|
||||
return LinuxError.EFAULT;
|
||||
}
|
||||
|
||||
rawData = rawData[sizeof(ulong)..];
|
||||
|
||||
if (iovLength > 0)
|
||||
{
|
||||
if ((ulong)rawData.Length < iovLength)
|
||||
{
|
||||
return LinuxError.EFAULT;
|
||||
}
|
||||
|
||||
iov[index] = rawData[..(int)iovLength].ToArray();
|
||||
rawData = rawData[(int)iovLength..];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!MemoryMarshal.TryRead(rawData, out uint controlLength))
|
||||
{
|
||||
return LinuxError.EFAULT;
|
||||
}
|
||||
|
||||
rawData = rawData[sizeof(uint)..];
|
||||
|
||||
if (controlLength > 0)
|
||||
{
|
||||
if (rawData.Length < controlLength)
|
||||
{
|
||||
return LinuxError.EFAULT;
|
||||
}
|
||||
|
||||
control = rawData[..(int)controlLength].ToArray();
|
||||
rawData = rawData[(int)controlLength..];
|
||||
}
|
||||
|
||||
if (!MemoryMarshal.TryRead(rawData, out BsdSocketFlags flags))
|
||||
{
|
||||
return LinuxError.EFAULT;
|
||||
}
|
||||
|
||||
rawData = rawData[sizeof(BsdSocketFlags)..];
|
||||
|
||||
if (!MemoryMarshal.TryRead(rawData, out uint length))
|
||||
{
|
||||
return LinuxError.EFAULT;
|
||||
}
|
||||
|
||||
rawData = rawData[sizeof(uint)..];
|
||||
|
||||
message = new BsdMsgHdr(name, iov, control, flags, length);
|
||||
|
||||
return LinuxError.SUCCESS;
|
||||
}
|
||||
}
|
||||
}
|
8
Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/TimeVal.cs
Normal file
8
Ryujinx.HLE/HOS/Services/Sockets/Bsd/Types/TimeVal.cs
Normal file
@ -0,0 +1,8 @@
|
||||
namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
|
||||
{
|
||||
public struct TimeVal
|
||||
{
|
||||
public ulong TvSec;
|
||||
public ulong TvUsec;
|
||||
}
|
||||
}
|
@ -19,7 +19,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres.Types
|
||||
{
|
||||
Length = (byte)Unsafe.SizeOf<Array4<byte>>();
|
||||
Family = (byte)AddressFamily.InterNetwork;
|
||||
Port = port;
|
||||
Port = IPAddress.HostToNetworkOrder(port);
|
||||
Address = new Array4<byte>();
|
||||
|
||||
address.TryWriteBytes(Address.AsSpan(), out _);
|
||||
|
@ -35,6 +35,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger
|
||||
private long _1msTicks;
|
||||
|
||||
private int _swapInterval;
|
||||
private int _swapIntervalDelay;
|
||||
|
||||
private readonly object Lock = new object();
|
||||
|
||||
@ -91,7 +92,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger
|
||||
}
|
||||
else
|
||||
{
|
||||
_ticksPerFrame = Stopwatch.Frequency / (TargetFps / _swapInterval);
|
||||
_ticksPerFrame = Stopwatch.Frequency / TargetFps;
|
||||
}
|
||||
}
|
||||
|
||||
@ -322,7 +323,13 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger
|
||||
|
||||
if (_ticks >= _ticksPerFrame)
|
||||
{
|
||||
Compose();
|
||||
if (_swapIntervalDelay-- == 0)
|
||||
{
|
||||
Compose();
|
||||
|
||||
// When a frame is presented, delay the next one by its swap interval value.
|
||||
_swapIntervalDelay = Math.Max(0, _swapInterval - 1);
|
||||
}
|
||||
|
||||
_device.System?.SignalVsync();
|
||||
|
||||
|
Reference in New Issue
Block a user