blob: b3712e6bf2dcf65f0e0fd7c20c8d1d83bfb52876 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
using System.Runtime.CompilerServices;
namespace Ryujinx.Graphics.Shader
{
public enum TextureHandleType
{
CombinedSampler = 0, // Must be 0.
SeparateSamplerHandle = 1,
SeparateSamplerId = 2
}
public static class TextureHandle
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static int PackSlots(int cbufSlot0, int cbufSlot1)
{
return cbufSlot0 | ((cbufSlot1 + 1) << 16);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static (int, int) UnpackSlots(int slots, int defaultTextureBufferIndex)
{
int textureBufferIndex;
int samplerBufferIndex;
if (slots < 0)
{
textureBufferIndex = defaultTextureBufferIndex;
samplerBufferIndex = textureBufferIndex;
}
else
{
uint high = (uint)slots >> 16;
textureBufferIndex = (ushort)slots;
samplerBufferIndex = high != 0 ? (int)high - 1 : textureBufferIndex;
}
return (textureBufferIndex, samplerBufferIndex);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static int PackOffsets(int cbufOffset0, int cbufOffset1, TextureHandleType type)
{
return cbufOffset0 | (cbufOffset1 << 14) | ((int)type << 28);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static (int, int, TextureHandleType) UnpackOffsets(int handle)
{
return (handle & 0x3fff, (handle >> 14) & 0x3fff, (TextureHandleType)((uint)handle >> 28));
}
}
}
|