aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics.GAL
diff options
context:
space:
mode:
Diffstat (limited to 'Ryujinx.Graphics.GAL')
-rw-r--r--Ryujinx.Graphics.GAL/Blend/BlendDescriptor.cs32
-rw-r--r--Ryujinx.Graphics.GAL/Blend/BlendFactor.cs25
-rw-r--r--Ryujinx.Graphics.GAL/Blend/BlendOp.cs11
-rw-r--r--Ryujinx.Graphics.GAL/BufferRange.cs21
-rw-r--r--Ryujinx.Graphics.GAL/Capabilities.cs12
-rw-r--r--Ryujinx.Graphics.GAL/Color/ColorF.cs18
-rw-r--r--Ryujinx.Graphics.GAL/Color/ColorSI.cs18
-rw-r--r--Ryujinx.Graphics.GAL/Color/ColorUI.cs18
-rw-r--r--Ryujinx.Graphics.GAL/CompareOp.cs14
-rw-r--r--Ryujinx.Graphics.GAL/CounterType.cs9
-rw-r--r--Ryujinx.Graphics.GAL/DepthStencil/DepthStencilState.cs47
-rw-r--r--Ryujinx.Graphics.GAL/DepthStencil/DepthTestDescriptor.cs20
-rw-r--r--Ryujinx.Graphics.GAL/DepthStencil/StencilOp.cs14
-rw-r--r--Ryujinx.Graphics.GAL/DepthStencil/StencilTestDescriptor.cs56
-rw-r--r--Ryujinx.Graphics.GAL/Extents2D.cs18
-rw-r--r--Ryujinx.Graphics.GAL/Face.cs9
-rw-r--r--Ryujinx.Graphics.GAL/Format.cs218
-rw-r--r--Ryujinx.Graphics.GAL/FrontFace.cs8
-rw-r--r--Ryujinx.Graphics.GAL/IBuffer.cs15
-rw-r--r--Ryujinx.Graphics.GAL/IComputePipeline.cs12
-rw-r--r--Ryujinx.Graphics.GAL/IGraphicsPipeline.cs69
-rw-r--r--Ryujinx.Graphics.GAL/IProgram.cs6
-rw-r--r--Ryujinx.Graphics.GAL/IRenderer.cs33
-rw-r--r--Ryujinx.Graphics.GAL/ISampler.cs6
-rw-r--r--Ryujinx.Graphics.GAL/IShader.cs6
-rw-r--r--Ryujinx.Graphics.GAL/ITexture.cs21
-rw-r--r--Ryujinx.Graphics.GAL/IWindow.cs13
-rw-r--r--Ryujinx.Graphics.GAL/ImageCrop.cs28
-rw-r--r--Ryujinx.Graphics.GAL/IndexType.cs9
-rw-r--r--Ryujinx.Graphics.GAL/InputAssembler/VertexAttribDescriptor.cs17
-rw-r--r--Ryujinx.Graphics.GAL/InputAssembler/VertexBufferDescriptor.cs17
-rw-r--r--Ryujinx.Graphics.GAL/PolygonModeMask.cs12
-rw-r--r--Ryujinx.Graphics.GAL/PrimitiveTopology.cs21
-rw-r--r--Ryujinx.Graphics.GAL/RectangleF.cs18
-rw-r--r--Ryujinx.Graphics.GAL/Ryujinx.Graphics.GAL.csproj12
-rw-r--r--Ryujinx.Graphics.GAL/Sampler/AddressMode.cs14
-rw-r--r--Ryujinx.Graphics.GAL/Sampler/CompareMode.cs8
-rw-r--r--Ryujinx.Graphics.GAL/Sampler/MagFilter.cs8
-rw-r--r--Ryujinx.Graphics.GAL/Sampler/MinFilter.cs12
-rw-r--r--Ryujinx.Graphics.GAL/Sampler/SamplerCreateInfo.cs52
-rw-r--r--Ryujinx.Graphics.GAL/Texture/DepthStencilMode.cs8
-rw-r--r--Ryujinx.Graphics.GAL/Texture/SwizzleComponent.cs12
-rw-r--r--Ryujinx.Graphics.GAL/Texture/Target.cs17
-rw-r--r--Ryujinx.Graphics.GAL/Texture/TextureCreateInfo.cs115
-rw-r--r--Ryujinx.Graphics.GAL/TextureReleaseCallback.cs4
-rw-r--r--Ryujinx.Graphics.GAL/Viewport.cs33
-rw-r--r--Ryujinx.Graphics.GAL/ViewportSwizzle.cs14
47 files changed, 1180 insertions, 0 deletions
diff --git a/Ryujinx.Graphics.GAL/Blend/BlendDescriptor.cs b/Ryujinx.Graphics.GAL/Blend/BlendDescriptor.cs
new file mode 100644
index 00000000..d7ef8004
--- /dev/null
+++ b/Ryujinx.Graphics.GAL/Blend/BlendDescriptor.cs
@@ -0,0 +1,32 @@
+namespace Ryujinx.Graphics.GAL.Blend
+{
+ public struct BlendDescriptor
+ {
+ public bool Enable { get; }
+
+ public BlendOp ColorOp { get; }
+ public BlendFactor ColorSrcFactor { get; }
+ public BlendFactor ColorDstFactor { get; }
+ public BlendOp AlphaOp { get; }
+ public BlendFactor AlphaSrcFactor { get; }
+ public BlendFactor AlphaDstFactor { get; }
+
+ public BlendDescriptor(
+ bool enable,
+ BlendOp colorOp,
+ BlendFactor colorSrcFactor,
+ BlendFactor colorDstFactor,
+ BlendOp alphaOp,
+ BlendFactor alphaSrcFactor,
+ BlendFactor alphaDstFactor)
+ {
+ Enable = enable;
+ ColorOp = colorOp;
+ ColorSrcFactor = colorSrcFactor;
+ ColorDstFactor = colorDstFactor;
+ AlphaOp = alphaOp;
+ AlphaSrcFactor = alphaSrcFactor;
+ AlphaDstFactor = alphaDstFactor;
+ }
+ }
+}
diff --git a/Ryujinx.Graphics.GAL/Blend/BlendFactor.cs b/Ryujinx.Graphics.GAL/Blend/BlendFactor.cs
new file mode 100644
index 00000000..0eda08a7
--- /dev/null
+++ b/Ryujinx.Graphics.GAL/Blend/BlendFactor.cs
@@ -0,0 +1,25 @@
+namespace Ryujinx.Graphics.GAL.Blend
+{
+ public enum BlendFactor
+ {
+ Zero = 1,
+ One,
+ SrcColor,
+ OneMinusSrcColor,
+ SrcAlpha,
+ OneMinusSrcAlpha,
+ DstAlpha,
+ OneMinusDstAlpha,
+ DstColor,
+ OneMinusDstColor,
+ SrcAlphaSaturate,
+ Src1Color = 0x10,
+ OneMinusSrc1Color,
+ Src1Alpha,
+ OneMinusSrc1Alpha,
+ ConstantColor = 0xc001,
+ OneMinusConstantColor,
+ ConstantAlpha,
+ OneMinusConstantAlpha
+ }
+} \ No newline at end of file
diff --git a/Ryujinx.Graphics.GAL/Blend/BlendOp.cs b/Ryujinx.Graphics.GAL/Blend/BlendOp.cs
new file mode 100644
index 00000000..51a0062d
--- /dev/null
+++ b/Ryujinx.Graphics.GAL/Blend/BlendOp.cs
@@ -0,0 +1,11 @@
+namespace Ryujinx.Graphics.GAL.Blend
+{
+ public enum BlendOp
+ {
+ Add = 1,
+ Subtract,
+ ReverseSubtract,
+ Minimum,
+ Maximum
+ }
+}
diff --git a/Ryujinx.Graphics.GAL/BufferRange.cs b/Ryujinx.Graphics.GAL/BufferRange.cs
new file mode 100644
index 00000000..a35636aa
--- /dev/null
+++ b/Ryujinx.Graphics.GAL/BufferRange.cs
@@ -0,0 +1,21 @@
+namespace Ryujinx.Graphics.GAL
+{
+ public struct BufferRange
+ {
+ private static BufferRange _empty = new BufferRange(null, 0, 0);
+
+ public BufferRange Empty => _empty;
+
+ public IBuffer Buffer { get; }
+
+ public int Offset { get; }
+ public int Size { get; }
+
+ public BufferRange(IBuffer buffer, int offset, int size)
+ {
+ Buffer = buffer;
+ Offset = offset;
+ Size = size;
+ }
+ }
+} \ No newline at end of file
diff --git a/Ryujinx.Graphics.GAL/Capabilities.cs b/Ryujinx.Graphics.GAL/Capabilities.cs
new file mode 100644
index 00000000..9640447b
--- /dev/null
+++ b/Ryujinx.Graphics.GAL/Capabilities.cs
@@ -0,0 +1,12 @@
+namespace Ryujinx.Graphics.GAL
+{
+ public struct Capabilities
+ {
+ public bool SupportsAstcCompression { get; }
+
+ public Capabilities(bool supportsAstcCompression)
+ {
+ SupportsAstcCompression = supportsAstcCompression;
+ }
+ }
+} \ No newline at end of file
diff --git a/Ryujinx.Graphics.GAL/Color/ColorF.cs b/Ryujinx.Graphics.GAL/Color/ColorF.cs
new file mode 100644
index 00000000..bc4b32b8
--- /dev/null
+++ b/Ryujinx.Graphics.GAL/Color/ColorF.cs
@@ -0,0 +1,18 @@
+namespace Ryujinx.Graphics.GAL.Color
+{
+ public struct ColorF
+ {
+ public float Red { get; }
+ public float Green { get; }
+ public float Blue { get; }
+ public float Alpha { get; }
+
+ public ColorF(float red, float green, float blue, float alpha)
+ {
+ Red = red;
+ Green = green;
+ Blue = blue;
+ Alpha = alpha;
+ }
+ }
+}
diff --git a/Ryujinx.Graphics.GAL/Color/ColorSI.cs b/Ryujinx.Graphics.GAL/Color/ColorSI.cs
new file mode 100644
index 00000000..9cde0406
--- /dev/null
+++ b/Ryujinx.Graphics.GAL/Color/ColorSI.cs
@@ -0,0 +1,18 @@
+namespace Ryujinx.Graphics.GAL.Color
+{
+ public struct ColorSI
+ {
+ public int Red { get; }
+ public int Green { get; }
+ public int Blue { get; }
+ public int Alpha { get; }
+
+ public ColorSI(int red, int green, int blue, int alpha)
+ {
+ Red = red;
+ Green = green;
+ Blue = blue;
+ Alpha = alpha;
+ }
+ }
+}
diff --git a/Ryujinx.Graphics.GAL/Color/ColorUI.cs b/Ryujinx.Graphics.GAL/Color/ColorUI.cs
new file mode 100644
index 00000000..3bac84ef
--- /dev/null
+++ b/Ryujinx.Graphics.GAL/Color/ColorUI.cs
@@ -0,0 +1,18 @@
+namespace Ryujinx.Graphics.GAL.Color
+{
+ public struct ColorUI
+ {
+ public uint Red { get; }
+ public uint Green { get; }
+ public uint Blue { get; }
+ public uint Alpha { get; }
+
+ public ColorUI(uint red, uint green, uint blue, uint alpha)
+ {
+ Red = red;
+ Green = green;
+ Blue = blue;
+ Alpha = alpha;
+ }
+ }
+}
diff --git a/Ryujinx.Graphics.GAL/CompareOp.cs b/Ryujinx.Graphics.GAL/CompareOp.cs
new file mode 100644
index 00000000..da5d5067
--- /dev/null
+++ b/Ryujinx.Graphics.GAL/CompareOp.cs
@@ -0,0 +1,14 @@
+namespace Ryujinx.Graphics.GAL
+{
+ public enum CompareOp
+ {
+ Never = 1,
+ Less,
+ Equal,
+ LessOrEqual,
+ Greater,
+ NotEqual,
+ GreaterOrEqual,
+ Always
+ }
+} \ No newline at end of file
diff --git a/Ryujinx.Graphics.GAL/CounterType.cs b/Ryujinx.Graphics.GAL/CounterType.cs
new file mode 100644
index 00000000..9d7b3b98
--- /dev/null
+++ b/Ryujinx.Graphics.GAL/CounterType.cs
@@ -0,0 +1,9 @@
+namespace Ryujinx.Graphics.GAL
+{
+ public enum CounterType
+ {
+ SamplesPassed,
+ PrimitivesGenerated,
+ TransformFeedbackPrimitivesWritten
+ }
+} \ No newline at end of file
diff --git a/Ryujinx.Graphics.GAL/DepthStencil/DepthStencilState.cs b/Ryujinx.Graphics.GAL/DepthStencil/DepthStencilState.cs
new file mode 100644
index 00000000..93b8d50e
--- /dev/null
+++ b/Ryujinx.Graphics.GAL/DepthStencil/DepthStencilState.cs
@@ -0,0 +1,47 @@
+namespace Ryujinx.Graphics.GAL.DepthStencil
+{
+ public struct DepthStencilState
+ {
+ public bool DepthTestEnable { get; }
+ public bool DepthWriteEnable { get; }
+ public bool StencilTestEnable { get; }
+
+ public CompareOp DepthFunc { get; }
+ public CompareOp StencilFrontFunc { get; }
+ public StencilOp StencilFrontSFail { get; }
+ public StencilOp StencilFrontDpPass { get; }
+ public StencilOp StencilFrontDpFail { get; }
+ public CompareOp StencilBackFunc { get; }
+ public StencilOp StencilBackSFail { get; }
+ public StencilOp StencilBackDpPass { get; }
+ public StencilOp StencilBackDpFail { get; }
+
+ public DepthStencilState(
+ bool depthTestEnable,
+ bool depthWriteEnable,
+ bool stencilTestEnable,
+ CompareOp depthFunc,
+ CompareOp stencilFrontFunc,
+ StencilOp stencilFrontSFail,
+ StencilOp stencilFrontDpPass,
+ StencilOp stencilFrontDpFail,
+ CompareOp stencilBackFunc,
+ StencilOp stencilBackSFail,
+ StencilOp stencilBackDpPass,
+ StencilOp stencilBackDpFail)
+ {
+ DepthTestEnable = depthTestEnable;
+ DepthWriteEnable = depthWriteEnable;
+ StencilTestEnable = stencilTestEnable;
+ DepthFunc = depthFunc;
+ StencilFrontFunc = stencilFrontFunc;
+ StencilFrontSFail = stencilFrontSFail;
+ StencilFrontDpPass = stencilFrontDpPass;
+ StencilFrontDpFail = stencilFrontDpFail;
+ StencilBackFunc = stencilBackFunc;
+ StencilBackSFail = stencilBackSFail;
+ StencilBackDpPass = stencilBackDpPass;
+ StencilBackDpFail = stencilBackDpFail;
+ }
+ }
+}
diff --git a/Ryujinx.Graphics.GAL/DepthStencil/DepthTestDescriptor.cs b/Ryujinx.Graphics.GAL/DepthStencil/DepthTestDescriptor.cs
new file mode 100644
index 00000000..98b1429b
--- /dev/null
+++ b/Ryujinx.Graphics.GAL/DepthStencil/DepthTestDescriptor.cs
@@ -0,0 +1,20 @@
+namespace Ryujinx.Graphics.GAL.DepthStencil
+{
+ public struct DepthTestDescriptor
+ {
+ public bool TestEnable { get; }
+ public bool WriteEnable { get; }
+
+ public CompareOp Func { get; }
+
+ public DepthTestDescriptor(
+ bool testEnable,
+ bool writeEnable,
+ CompareOp func)
+ {
+ TestEnable = testEnable;
+ WriteEnable = writeEnable;
+ Func = func;
+ }
+ }
+}
diff --git a/Ryujinx.Graphics.GAL/DepthStencil/StencilOp.cs b/Ryujinx.Graphics.GAL/DepthStencil/StencilOp.cs
new file mode 100644
index 00000000..3818c6a5
--- /dev/null
+++ b/Ryujinx.Graphics.GAL/DepthStencil/StencilOp.cs
@@ -0,0 +1,14 @@
+namespace Ryujinx.Graphics.GAL.DepthStencil
+{
+ public enum StencilOp
+ {
+ Keep = 1,
+ Zero,
+ Replace,
+ IncrementAndClamp,
+ DecrementAndClamp,
+ Invert,
+ IncrementAndWrap,
+ DecrementAndWrap
+ }
+} \ No newline at end of file
diff --git a/Ryujinx.Graphics.GAL/DepthStencil/StencilTestDescriptor.cs b/Ryujinx.Graphics.GAL/DepthStencil/StencilTestDescriptor.cs
new file mode 100644
index 00000000..2db53172
--- /dev/null
+++ b/Ryujinx.Graphics.GAL/DepthStencil/StencilTestDescriptor.cs
@@ -0,0 +1,56 @@
+namespace Ryujinx.Graphics.GAL.DepthStencil
+{
+ public struct StencilTestDescriptor
+ {
+ public bool TestEnable { get; }
+
+ public CompareOp FrontFunc { get; }
+ public StencilOp FrontSFail { get; }
+ public StencilOp FrontDpPass { get; }
+ public StencilOp FrontDpFail { get; }
+ public int FrontFuncRef { get; }
+ public int FrontFuncMask { get; }
+ public int FrontMask { get; }
+ public CompareOp BackFunc { get; }
+ public StencilOp BackSFail { get; }
+ public StencilOp BackDpPass { get; }
+ public StencilOp BackDpFail { get; }
+ public int BackFuncRef { get; }
+ public int BackFuncMask { get; }
+ public int BackMask { get; }
+
+ public StencilTestDescriptor(
+ bool testEnable,
+ CompareOp frontFunc,
+ StencilOp frontSFail,
+ StencilOp frontDpPass,
+ StencilOp frontDpFail,
+ int frontFuncRef,
+ int frontFuncMask,
+ int frontMask,
+ CompareOp backFunc,
+ StencilOp backSFail,
+ StencilOp backDpPass,
+ StencilOp backDpFail,
+ int backFuncRef,
+ int backFuncMask,
+ int backMask)
+ {
+ TestEnable = testEnable;
+ FrontFunc = frontFunc;
+ FrontSFail = frontSFail;
+ FrontDpPass = frontDpPass;
+ FrontDpFail = frontDpFail;
+ FrontFuncRef = frontFuncRef;
+ FrontFuncMask = frontFuncMask;
+ FrontMask = frontMask;
+ BackFunc = backFunc;
+ BackSFail = backSFail;
+ BackDpPass = backDpPass;
+ BackDpFail = backDpFail;
+ BackFuncRef = backFuncRef;
+ BackFuncMask = backFuncMask;
+ BackMask = backMask;
+ }
+ }
+}
diff --git a/Ryujinx.Graphics.GAL/Extents2D.cs b/Ryujinx.Graphics.GAL/Extents2D.cs
new file mode 100644
index 00000000..e9e26af4
--- /dev/null
+++ b/Ryujinx.Graphics.GAL/Extents2D.cs
@@ -0,0 +1,18 @@
+namespace Ryujinx.Graphics.GAL
+{
+ public struct Extents2D
+ {
+ public int X1 { get; }
+ public int Y1 { get; }
+ public int X2 { get; }
+ public int Y2 { get; }
+
+ public Extents2D(int x1, int y1, int x2, int y2)
+ {
+ X1 = x1;
+ Y1 = y1;
+ X2 = x2;
+ Y2 = y2;
+ }
+ }
+} \ No newline at end of file
diff --git a/Ryujinx.Graphics.GAL/Face.cs b/Ryujinx.Graphics.GAL/Face.cs
new file mode 100644
index 00000000..0587641f
--- /dev/null
+++ b/Ryujinx.Graphics.GAL/Face.cs
@@ -0,0 +1,9 @@
+namespace Ryujinx.Graphics.GAL
+{
+ public enum Face
+ {
+ Front = 0x404,
+ Back = 0x405,
+ FrontAndBack = 0x408
+ }
+} \ No newline at end of file
diff --git a/Ryujinx.Graphics.GAL/Format.cs b/Ryujinx.Graphics.GAL/Format.cs
new file mode 100644
index 00000000..9f28cdfb
--- /dev/null
+++ b/Ryujinx.Graphics.GAL/Format.cs
@@ -0,0 +1,218 @@
+namespace Ryujinx.Graphics.GAL
+{
+ public enum Format
+ {
+ R8Unorm,
+ R8Snorm,
+ R8Uint,
+ R8Sint,
+ R16Float,
+ R16Unorm,
+ R16Snorm,
+ R16Uint,
+ R16Sint,
+ R32Float,
+ R32Uint,
+ R32Sint,
+ R8G8Unorm,
+ R8G8Snorm,
+ R8G8Uint,
+ R8G8Sint,
+ R16G16Float,
+ R16G16Unorm,
+ R16G16Snorm,
+ R16G16Uint,
+ R16G16Sint,
+ R32G32Float,
+ R32G32Uint,
+ R32G32Sint,
+ R8G8B8Unorm,
+ R8G8B8Snorm,
+ R8G8B8Uint,
+ R8G8B8Sint,
+ R16G16B16Float,
+ R16G16B16Unorm,
+ R16G16B16Snorm,
+ R16G16B16Uint,
+ R16G16B16Sint,
+ R32G32B32Float,
+ R32G32B32Uint,
+ R32G32B32Sint,
+ R8G8B8A8Unorm,
+ R8G8B8A8Snorm,
+ R8G8B8A8Uint,
+ R8G8B8A8Sint,
+ R16G16B16A16Float,
+ R16G16B16A16Unorm,
+ R16G16B16A16Snorm,
+ R16G16B16A16Uint,
+ R16G16B16A16Sint,
+ R32G32B32A32Float,
+ R32G32B32A32Uint,
+ R32G32B32A32Sint,
+ S8Uint,
+ D16Unorm,
+ D24X8Unorm,
+ D32Float,
+ D24UnormS8Uint,
+ D32FloatS8Uint,
+ R8G8B8X8Srgb,
+ R8G8B8A8Srgb,
+ R4G4B4A4Unorm,
+ R5G5B5X1Unorm,
+ R5G5B5A1Unorm,
+ R5G6B5Unorm,
+ R10G10B10A2Unorm,
+ R10G10B10A2Uint,
+ R11G11B10Float,
+ R9G9B9E5Float,
+ Bc1RgbUnorm,
+ Bc1RgbaUnorm,
+ Bc2Unorm,
+ Bc3Unorm,
+ Bc1RgbSrgb,
+ Bc1RgbaSrgb,
+ Bc2Srgb,
+ Bc3Srgb,
+ Bc4Unorm,
+ Bc4Snorm,
+ Bc5Unorm,
+ Bc5Snorm,
+ Bc7Unorm,
+ Bc7Srgb,
+ Bc6HUfloat,
+ Bc6HSfloat,
+ R8Uscaled,
+ R8Sscaled,
+ R16Uscaled,
+ R16Sscaled,
+ R32Uscaled,
+ R32Sscaled,
+ R8G8Uscaled,
+ R8G8Sscaled,
+ R16G16Uscaled,
+ R16G16Sscaled,
+ R32G32Uscaled,
+ R32G32Sscaled,
+ R8G8B8Uscaled,
+ R8G8B8Sscaled,
+ R16G16B16Uscaled,
+ R16G16B16Sscaled,
+ R32G32B32Uscaled,
+ R32G32B32Sscaled,
+ R8G8B8A8Uscaled,
+ R8G8B8A8Sscaled,
+ R16G16B16A16Uscaled,
+ R16G16B16A16Sscaled,
+ R32G32B32A32Uscaled,
+ R32G32B32A32Sscaled,
+ R10G10B10A2Snorm,
+ R10G10B10A2Sint,
+ R10G10B10A2Uscaled,
+ R10G10B10A2Sscaled,
+ R8G8B8X8Unorm,
+ R8G8B8X8Snorm,
+ R8G8B8X8Uint,
+ R8G8B8X8Sint,
+ R16G16B16X16Float,
+ R16G16B16X16Unorm,
+ R16G16B16X16Snorm,
+ R16G16B16X16Uint,
+ R16G16B16X16Sint,
+ R32G32B32X32Float,
+ R32G32B32X32Uint,
+ R32G32B32X32Sint,
+ Astc4x4Unorm,
+ Astc5x4Unorm,
+ Astc5x5Unorm,
+ Astc6x5Unorm,
+ Astc6x6Unorm,
+ Astc8x5Unorm,
+ Astc8x6Unorm,
+ Astc8x8Unorm,
+ Astc10x5Unorm,
+ Astc10x6Unorm,
+ Astc10x8Unorm,
+ Astc10x10Unorm,
+ Astc12x10Unorm,
+ Astc12x12Unorm,
+ Astc4x4Srgb,
+ Astc5x4Srgb,
+ Astc5x5Srgb,
+ Astc6x5Srgb,
+ Astc6x6Srgb,
+ Astc8x5Srgb,
+ Astc8x6Srgb,
+ Astc8x8Srgb,
+ Astc10x5Srgb,
+ Astc10x6Srgb,
+ Astc10x8Srgb,
+ Astc10x10Srgb,
+ Astc12x10Srgb,
+ Astc12x12Srgb,
+ B5G6R5Unorm,
+ B5G5R5X1Unorm,
+ B5G5R5A1Unorm,
+ A1B5G5R5Unorm,
+ B8G8R8X8Unorm,
+ B8G8R8A8Unorm,
+ B8G8R8X8Srgb,
+ B8G8R8A8Srgb
+ }
+
+ public static class FormatExtensions
+ {
+ public static bool IsAstc(this Format format)
+ {
+ return format.IsAstcUnorm() || format.IsAstcSrgb();
+ }
+
+ public static bool IsAstcUnorm(this Format format)
+ {
+ switch (format)
+ {
+ case Format.Astc4x4Unorm:
+ case Format.Astc5x4Unorm:
+ case Format.Astc5x5Unorm:
+ case Format.Astc6x5Unorm:
+ case Format.Astc6x6Unorm:
+ case Format.Astc8x5Unorm:
+ case Format.Astc8x6Unorm:
+ case Format.Astc8x8Unorm:
+ case Format.Astc10x5Unorm:
+ case Format.Astc10x6Unorm:
+ case Format.Astc10x8Unorm:
+ case Format.Astc10x10Unorm:
+ case Format.Astc12x10Unorm:
+ case Format.Astc12x12Unorm:
+ return true;
+ }
+
+ return false;
+ }
+
+ public static bool IsAstcSrgb(this Format format)
+ {
+ switch (format)
+ {
+ case Format.Astc4x4Srgb:
+ case Format.Astc5x4Srgb:
+ case Format.Astc5x5Srgb:
+ case Format.Astc6x5Srgb:
+ case Format.Astc6x6Srgb:
+ case Format.Astc8x5Srgb:
+ case Format.Astc8x6Srgb:
+ case Format.Astc8x8Srgb:
+ case Format.Astc10x5Srgb:
+ case Format.Astc10x6Srgb:
+ case Format.Astc10x8Srgb:
+ case Format.Astc10x10Srgb:
+ case Format.Astc12x10Srgb:
+ case Format.Astc12x12Srgb:
+ return true;
+ }
+
+ return false;
+ }
+ }
+} \ No newline at end of file
diff --git a/Ryujinx.Graphics.GAL/FrontFace.cs b/Ryujinx.Graphics.GAL/FrontFace.cs
new file mode 100644
index 00000000..aa6bfdc5
--- /dev/null
+++ b/Ryujinx.Graphics.GAL/FrontFace.cs
@@ -0,0 +1,8 @@
+namespace Ryujinx.Graphics.GAL
+{
+ public enum FrontFace
+ {
+ Clockwise = 0x900,
+ CounterClockwise = 0x901
+ }
+} \ No newline at end of file
diff --git a/Ryujinx.Graphics.GAL/IBuffer.cs b/Ryujinx.Graphics.GAL/IBuffer.cs
new file mode 100644
index 00000000..000efd67
--- /dev/null
+++ b/Ryujinx.Graphics.GAL/IBuffer.cs
@@ -0,0 +1,15 @@
+using System;
+
+namespace Ryujinx.Graphics.GAL
+{
+ public interface IBuffer : IDisposable
+ {
+ void CopyTo(IBuffer destination, int srcOffset, int dstOffset, int size);
+
+ byte[] GetData(int offset, int size);
+
+ void SetData(Span<byte> data);
+
+ void SetData(int offset, Span<byte> data);
+ }
+} \ No newline at end of file
diff --git a/Ryujinx.Graphics.GAL/IComputePipeline.cs b/Ryujinx.Graphics.GAL/IComputePipeline.cs
new file mode 100644
index 00000000..e2d0b06e
--- /dev/null
+++ b/Ryujinx.Graphics.GAL/IComputePipeline.cs
@@ -0,0 +1,12 @@
+namespace Ryujinx.Graphics.GAL
+{
+ public interface IComputePipeline
+ {
+ void Dispatch(int groupsX, int groupsY, int groupsZ);
+
+ void SetProgram(IProgram program);
+
+ void SetStorageBuffer(int index, BufferRange buffer);
+ void SetUniformBuffer(int index, BufferRange buffer);
+ }
+}
diff --git a/Ryujinx.Graphics.GAL/IGraphicsPipeline.cs b/Ryujinx.Graphics.GAL/IGraphicsPipeline.cs
new file mode 100644
index 00000000..13e6ab1a
--- /dev/null
+++ b/Ryujinx.Graphics.GAL/IGraphicsPipeline.cs
@@ -0,0 +1,69 @@
+using Ryujinx.Graphics.GAL.Blend;
+using Ryujinx.Graphics.GAL.Color;
+using Ryujinx.Graphics.GAL.DepthStencil;
+using Ryujinx.Graphics.GAL.InputAssembler;
+using Ryujinx.Graphics.Shader;
+
+namespace Ryujinx.Graphics.GAL
+{
+ public interface IGraphicsPipeline
+ {
+ void BindBlendState(int index, BlendDescriptor blend);
+
+ void BindIndexBuffer(BufferRange buffer, IndexType type);
+
+ void BindProgram(IProgram program);
+
+ void BindSampler(int index, ShaderStage stage, ISampler sampler);
+ void BindTexture(int index, ShaderStage stage, ITexture texture);
+
+ void BindStorageBuffers(int index, ShaderStage stage, BufferRange[] buffers);
+ void BindUniformBuffers(int index, ShaderStage stage, BufferRange[] buffers);
+
+ void BindVertexAttribs(VertexAttribDescriptor[] vertexAttribs);
+ void BindVertexBuffers(VertexBufferDescriptor[] vertexBuffers);
+
+ void ClearRenderTargetColor(int index, uint componentMask, ColorF color);
+ void ClearRenderTargetColor(int index, uint componentMask, ColorSI color);
+ void ClearRenderTargetColor(int index, uint componentMask, ColorUI color);
+
+ void ClearRenderTargetDepthStencil(
+ float depthValue,
+ bool depthMask,
+ int stencilValue,
+ int stencilMask);
+
+ void Draw(int vertexCount, int instanceCount, int firstVertex, int firstInstance);
+ void DrawIndexed(
+ int indexCount,
+ int instanceCount,
+ int firstIndex,
+ int firstVertex,
+ int firstInstance);
+ void DrawIndirect (BufferRange buffer, ulong offset, int drawCount, int stride);
+ void DrawIndexedIndirect(BufferRange buffer, ulong offset, int drawCount, int stride);
+
+ void SetBlendColor(ColorF color);
+
+ void SetDepthBias(PolygonModeMask enables, float factor, float units, float clamp);
+
+ void SetDepthTest(DepthTestDescriptor depthTest);
+
+ void SetFaceCulling(bool enable, Face face);
+
+ void SetFrontFace(FrontFace frontFace);
+
+ void SetPrimitiveRestart(bool enable, int index);
+
+ void SetPrimitiveTopology(PrimitiveTopology topology);
+
+ void SetRenderTargetColorMasks(uint[] componentMask);
+
+ void SetRenderTargets(ITexture color3D, ITexture depthStencil);
+ void SetRenderTargets(ITexture[] colors, ITexture depthStencil);
+
+ void SetStencilTest(StencilTestDescriptor stencilTest);
+
+ void SetViewports(int first, Viewport[] viewports);
+ }
+}
diff --git a/Ryujinx.Graphics.GAL/IProgram.cs b/Ryujinx.Graphics.GAL/IProgram.cs
new file mode 100644
index 00000000..ef44fc47
--- /dev/null
+++ b/Ryujinx.Graphics.GAL/IProgram.cs
@@ -0,0 +1,6 @@
+using System;
+
+namespace Ryujinx.Graphics.GAL
+{
+ public interface IProgram : IDisposable { }
+}
diff --git a/Ryujinx.Graphics.GAL/IRenderer.cs b/Ryujinx.Graphics.GAL/IRenderer.cs
new file mode 100644
index 00000000..609f05f5
--- /dev/null
+++ b/Ryujinx.Graphics.GAL/IRenderer.cs
@@ -0,0 +1,33 @@
+using Ryujinx.Graphics.GAL.Sampler;
+using Ryujinx.Graphics.GAL.Texture;
+using Ryujinx.Graphics.Shader;
+
+namespace Ryujinx.Graphics.GAL
+{
+ public interface IRenderer
+ {
+ IComputePipeline ComputePipeline { get; }
+ IGraphicsPipeline GraphicsPipeline { get; }
+
+ IWindow Window { get; }
+
+ IShader CompileShader(ShaderProgram shader);
+
+ IBuffer CreateBuffer(int size);
+
+ IProgram CreateProgram(IShader[] shaders);
+
+ ISampler CreateSampler(SamplerCreateInfo info);
+ ITexture CreateTexture(TextureCreateInfo info);
+
+ void FlushPipelines();
+
+ Capabilities GetCapabilities();
+
+ ulong GetCounter(CounterType type);
+
+ void InitializeCounters();
+
+ void ResetCounter(CounterType type);
+ }
+}
diff --git a/Ryujinx.Graphics.GAL/ISampler.cs b/Ryujinx.Graphics.GAL/ISampler.cs
new file mode 100644
index 00000000..3aefc6a7
--- /dev/null
+++ b/Ryujinx.Graphics.GAL/ISampler.cs
@@ -0,0 +1,6 @@
+using System;
+
+namespace Ryujinx.Graphics.GAL
+{
+ public interface ISampler : IDisposable { }
+} \ No newline at end of file
diff --git a/Ryujinx.Graphics.GAL/IShader.cs b/Ryujinx.Graphics.GAL/IShader.cs
new file mode 100644
index 00000000..be24adcd
--- /dev/null
+++ b/Ryujinx.Graphics.GAL/IShader.cs
@@ -0,0 +1,6 @@
+using System;
+
+namespace Ryujinx.Graphics.GAL
+{
+ public interface IShader : IDisposable { }
+}
diff --git a/Ryujinx.Graphics.GAL/ITexture.cs b/Ryujinx.Graphics.GAL/ITexture.cs
new file mode 100644
index 00000000..6b3f5c59
--- /dev/null
+++ b/Ryujinx.Graphics.GAL/ITexture.cs
@@ -0,0 +1,21 @@
+using Ryujinx.Graphics.GAL.Texture;
+using System;
+
+namespace Ryujinx.Graphics.GAL
+{
+ public interface ITexture : IDisposable
+ {
+ int Handle { get; }
+
+ void CopyTo(ITexture destination);
+ void CopyTo(ITexture destination, Extents2D srcRegion, Extents2D dstRegion, bool linearFilter);
+
+ ITexture CreateView(TextureCreateInfo info, int firstLayer, int firstLevel);
+
+ int GetStorageDebugId();
+
+ byte[] GetData(int face);
+
+ void SetData(Span<byte> data);
+ }
+} \ No newline at end of file
diff --git a/Ryujinx.Graphics.GAL/IWindow.cs b/Ryujinx.Graphics.GAL/IWindow.cs
new file mode 100644
index 00000000..a0e5f196
--- /dev/null
+++ b/Ryujinx.Graphics.GAL/IWindow.cs
@@ -0,0 +1,13 @@
+using System;
+
+namespace Ryujinx.Graphics.GAL
+{
+ public interface IWindow
+ {
+ void Present();
+
+ void QueueTexture(ITexture texture, ImageCrop crop, object context);
+
+ void RegisterTextureReleaseCallback(TextureReleaseCallback callback);
+ }
+}
diff --git a/Ryujinx.Graphics.GAL/ImageCrop.cs b/Ryujinx.Graphics.GAL/ImageCrop.cs
new file mode 100644
index 00000000..4428eee9
--- /dev/null
+++ b/Ryujinx.Graphics.GAL/ImageCrop.cs
@@ -0,0 +1,28 @@
+namespace Ryujinx.Graphics.GAL
+{
+ public struct ImageCrop
+ {
+ public int Left { get; }
+ public int Right { get; }
+ public int Top { get; }
+ public int Bottom { get; }
+ public bool FlipX { get; }
+ public bool FlipY { get; }
+
+ public ImageCrop(
+ int left,
+ int right,
+ int top,
+ int bottom,
+ bool flipX,
+ bool flipY)
+ {
+ Left = left;
+ Right = right;
+ Top = top;
+ Bottom = bottom;
+ FlipX = flipX;
+ FlipY = flipY;
+ }
+ }
+} \ No newline at end of file
diff --git a/Ryujinx.Graphics.GAL/IndexType.cs b/Ryujinx.Graphics.GAL/IndexType.cs
new file mode 100644
index 00000000..4abf28d9
--- /dev/null
+++ b/Ryujinx.Graphics.GAL/IndexType.cs
@@ -0,0 +1,9 @@
+namespace Ryujinx.Graphics.GAL
+{
+ public enum IndexType
+ {
+ UByte,
+ UShort,
+ UInt
+ }
+} \ No newline at end of file
diff --git a/Ryujinx.Graphics.GAL/InputAssembler/VertexAttribDescriptor.cs b/Ryujinx.Graphics.GAL/InputAssembler/VertexAttribDescriptor.cs
new file mode 100644
index 00000000..cba3a9a4
--- /dev/null
+++ b/Ryujinx.Graphics.GAL/InputAssembler/VertexAttribDescriptor.cs
@@ -0,0 +1,17 @@
+namespace Ryujinx.Graphics.GAL.InputAssembler
+{
+ public struct VertexAttribDescriptor
+ {
+ public int BufferIndex { get; }
+ public int Offset { get; }
+
+ public Format Format { get; }
+
+ public VertexAttribDescriptor(int bufferIndex, int offset, Format format)
+ {
+ BufferIndex = bufferIndex;
+ Offset = offset;
+ Format = format;
+ }
+ }
+}
diff --git a/Ryujinx.Graphics.GAL/InputAssembler/VertexBufferDescriptor.cs b/Ryujinx.Graphics.GAL/InputAssembler/VertexBufferDescriptor.cs
new file mode 100644
index 00000000..eb428f8e
--- /dev/null
+++ b/Ryujinx.Graphics.GAL/InputAssembler/VertexBufferDescriptor.cs
@@ -0,0 +1,17 @@
+namespace Ryujinx.Graphics.GAL.InputAssembler
+{
+ public struct VertexBufferDescriptor
+ {
+ public BufferRange Buffer { get; }
+
+ public int Stride { get; }
+ public int Divisor { get; }
+
+ public VertexBufferDescriptor(BufferRange buffer, int stride, int divisor)
+ {
+ Buffer = buffer;
+ Stride = stride;
+ Divisor = divisor;
+ }
+ }
+}
diff --git a/Ryujinx.Graphics.GAL/PolygonModeMask.cs b/Ryujinx.Graphics.GAL/PolygonModeMask.cs
new file mode 100644
index 00000000..514b4231
--- /dev/null
+++ b/Ryujinx.Graphics.GAL/PolygonModeMask.cs
@@ -0,0 +1,12 @@
+using System;
+
+namespace Ryujinx.Graphics.GAL
+{
+ [Flags]
+ public enum PolygonModeMask
+ {
+ Point = 1 << 0,
+ Line = 1 << 1,
+ Fill = 1 << 2
+ }
+}
diff --git a/Ryujinx.Graphics.GAL/PrimitiveTopology.cs b/Ryujinx.Graphics.GAL/PrimitiveTopology.cs
new file mode 100644
index 00000000..ed567a68
--- /dev/null
+++ b/Ryujinx.Graphics.GAL/PrimitiveTopology.cs
@@ -0,0 +1,21 @@
+namespace Ryujinx.Graphics.GAL
+{
+ public enum PrimitiveTopology
+ {
+ Points,
+ Lines,
+ LineLoop,
+ LineStrip,
+ Triangles,
+ TriangleStrip,
+ TriangleFan,
+ Quads,
+ QuadStrip,
+ Polygon,
+ LinesAdjacency,
+ LineStripAdjacency,
+ TrianglesAdjacency,
+ TriangleStripAdjacency,
+ Patches
+ }
+}
diff --git a/Ryujinx.Graphics.GAL/RectangleF.cs b/Ryujinx.Graphics.GAL/RectangleF.cs
new file mode 100644
index 00000000..c58aabf0
--- /dev/null
+++ b/Ryujinx.Graphics.GAL/RectangleF.cs
@@ -0,0 +1,18 @@
+namespace Ryujinx.Graphics.GAL
+{
+ public struct RectangleF
+ {
+ public float X { get; }
+ public float Y { get; }
+ public float Width { get; }
+ public float Height { get; }
+
+ public RectangleF(float x, float y, float width, float height)
+ {
+ X = x;
+ Y = y;
+ Width = width;
+ Height = height;
+ }
+ }
+}
diff --git a/Ryujinx.Graphics.GAL/Ryujinx.Graphics.GAL.csproj b/Ryujinx.Graphics.GAL/Ryujinx.Graphics.GAL.csproj
new file mode 100644
index 00000000..584ebe97
--- /dev/null
+++ b/Ryujinx.Graphics.GAL/Ryujinx.Graphics.GAL.csproj
@@ -0,0 +1,12 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+ <ItemGroup>
+ <ProjectReference Include="..\Ryujinx.Graphics.Shader\Ryujinx.Graphics.Shader.csproj" />
+ <ProjectReference Include="..\Ryujinx.Common\Ryujinx.Common.csproj" />
+ </ItemGroup>
+
+ <PropertyGroup>
+ <TargetFramework>netcoreapp3.0</TargetFramework>
+ </PropertyGroup>
+
+</Project>
diff --git a/Ryujinx.Graphics.GAL/Sampler/AddressMode.cs b/Ryujinx.Graphics.GAL/Sampler/AddressMode.cs
new file mode 100644
index 00000000..4f56d892
--- /dev/null
+++ b/Ryujinx.Graphics.GAL/Sampler/AddressMode.cs
@@ -0,0 +1,14 @@
+namespace Ryujinx.Graphics.GAL.Sampler
+{
+ public enum AddressMode
+ {
+ Repeat,
+ MirroredRepeat,
+ ClampToEdge,
+ ClampToBorder,
+ Clamp,
+ MirrorClampToEdge,
+ MirrorClampToBorder,
+ MirrorClamp
+ }
+} \ No newline at end of file
diff --git a/Ryujinx.Graphics.GAL/Sampler/CompareMode.cs b/Ryujinx.Graphics.GAL/Sampler/CompareMode.cs
new file mode 100644
index 00000000..ca4b09a0
--- /dev/null
+++ b/Ryujinx.Graphics.GAL/Sampler/CompareMode.cs
@@ -0,0 +1,8 @@
+namespace Ryujinx.Graphics.GAL.Sampler
+{
+ public enum CompareMode
+ {
+ None,
+ CompareRToTexture
+ }
+} \ No newline at end of file
diff --git a/Ryujinx.Graphics.GAL/Sampler/MagFilter.cs b/Ryujinx.Graphics.GAL/Sampler/MagFilter.cs
new file mode 100644
index 00000000..3c9c9de6
--- /dev/null
+++ b/Ryujinx.Graphics.GAL/Sampler/MagFilter.cs
@@ -0,0 +1,8 @@
+namespace Ryujinx.Graphics.GAL.Sampler
+{
+ public enum MagFilter
+ {
+ Nearest = 1,
+ Linear
+ }
+} \ No newline at end of file
diff --git a/Ryujinx.Graphics.GAL/Sampler/MinFilter.cs b/Ryujinx.Graphics.GAL/Sampler/MinFilter.cs
new file mode 100644
index 00000000..d012f695
--- /dev/null
+++ b/Ryujinx.Graphics.GAL/Sampler/MinFilter.cs
@@ -0,0 +1,12 @@
+namespace Ryujinx.Graphics.GAL.Sampler
+{
+ public enum MinFilter
+ {
+ Nearest = 1,
+ Linear,
+ NearestMipmapNearest,
+ LinearMipmapNearest,
+ NearestMipmapLinear,
+ LinearMipmapLinear
+ }
+} \ No newline at end of file
diff --git a/Ryujinx.Graphics.GAL/Sampler/SamplerCreateInfo.cs b/Ryujinx.Graphics.GAL/Sampler/SamplerCreateInfo.cs
new file mode 100644
index 00000000..3f42742b
--- /dev/null
+++ b/Ryujinx.Graphics.GAL/Sampler/SamplerCreateInfo.cs
@@ -0,0 +1,52 @@
+using Ryujinx.Graphics.GAL.Color;
+
+namespace Ryujinx.Graphics.GAL.Sampler
+{
+ public struct SamplerCreateInfo
+ {
+ public MinFilter MinFilter { get; }
+ public MagFilter MagFilter { get; }
+
+ public AddressMode AddressU { get; }
+ public AddressMode AddressV { get; }
+ public AddressMode AddressP { get; }
+
+ public CompareMode CompareMode { get; }
+ public CompareOp CompareOp { get; }
+
+ public ColorF BorderColor { get; }
+
+ public float MinLod { get; }
+ public float MaxLod { get; }
+ public float MipLodBias { get; }
+ public float MaxAnisotropy { get; }
+
+ public SamplerCreateInfo(
+ MinFilter minFilter,
+ MagFilter magFilter,
+ AddressMode addressU,
+ AddressMode addressV,
+ AddressMode addressP,
+ CompareMode compareMode,
+ CompareOp compareOp,
+ ColorF borderColor,
+ float minLod,
+ float maxLod,
+ float mipLodBias,
+ float maxAnisotropy)
+ {
+ MinFilter = minFilter;
+ MagFilter = magFilter;
+ AddressU = addressU;
+ AddressV = addressV;
+ AddressP = addressP;
+ CompareMode = compareMode;
+ CompareOp = compareOp;
+ BorderColor = borderColor;
+ MinLod = minLod;
+ MaxLod = maxLod;
+ MipLodBias = mipLodBias;
+ MaxAnisotropy = maxAnisotropy;
+ }
+ }
+} \ No newline at end of file
diff --git a/Ryujinx.Graphics.GAL/Texture/DepthStencilMode.cs b/Ryujinx.Graphics.GAL/Texture/DepthStencilMode.cs
new file mode 100644
index 00000000..d7a379d8
--- /dev/null
+++ b/Ryujinx.Graphics.GAL/Texture/DepthStencilMode.cs
@@ -0,0 +1,8 @@
+namespace Ryujinx.Graphics.GAL.Texture
+{
+ public enum DepthStencilMode
+ {
+ Depth,
+ Stencil
+ }
+} \ No newline at end of file
diff --git a/Ryujinx.Graphics.GAL/Texture/SwizzleComponent.cs b/Ryujinx.Graphics.GAL/Texture/SwizzleComponent.cs
new file mode 100644
index 00000000..fd7d50e3
--- /dev/null
+++ b/Ryujinx.Graphics.GAL/Texture/SwizzleComponent.cs
@@ -0,0 +1,12 @@
+namespace Ryujinx.Graphics.GAL.Texture
+{
+ public enum SwizzleComponent
+ {
+ Zero,
+ One,
+ Red,
+ Green,
+ Blue,
+ Alpha
+ }
+} \ No newline at end of file
diff --git a/Ryujinx.Graphics.GAL/Texture/Target.cs b/Ryujinx.Graphics.GAL/Texture/Target.cs
new file mode 100644
index 00000000..b9cc1105
--- /dev/null
+++ b/Ryujinx.Graphics.GAL/Texture/Target.cs
@@ -0,0 +1,17 @@
+namespace Ryujinx.Graphics.GAL.Texture
+{
+ public enum Target
+ {
+ Texture1D,
+ Texture2D,
+ Texture3D,
+ Texture1DArray,
+ Texture2DArray,
+ Texture2DMultisample,
+ Texture2DMultisampleArray,
+ Rectangle,
+ Cubemap,
+ CubemapArray,
+ TextureBuffer
+ }
+} \ No newline at end of file
diff --git a/Ryujinx.Graphics.GAL/Texture/TextureCreateInfo.cs b/Ryujinx.Graphics.GAL/Texture/TextureCreateInfo.cs
new file mode 100644
index 00000000..ad365f6b
--- /dev/null
+++ b/Ryujinx.Graphics.GAL/Texture/TextureCreateInfo.cs
@@ -0,0 +1,115 @@
+using Ryujinx.Common;
+using System;
+
+namespace Ryujinx.Graphics.GAL.Texture
+{
+ public struct TextureCreateInfo
+ {
+ public int Width { get; }
+ public int Height { get; }
+ public int Depth { get; }
+ public int Levels { get; }
+ public int Samples { get; }
+ public int BlockWidth { get; }
+ public int BlockHeight { get; }
+ public int BytesPerPixel { get; }
+
+ public bool IsCompressed => (BlockWidth | BlockHeight) != 1;
+
+ public Format Format { get; }
+
+ public DepthStencilMode DepthStencilMode { get; }
+
+ public Target Target { get; }
+
+ public SwizzleComponent SwizzleR { get; }
+ public SwizzleComponent SwizzleG { get; }
+ public SwizzleComponent SwizzleB { get; }
+ public SwizzleComponent SwizzleA { get; }
+
+ public TextureCreateInfo(
+ int width,
+ int height,
+ int depth,
+ int levels,
+ int samples,
+ int blockWidth,
+ int blockHeight,
+ int bytesPerPixel,
+ Format format,
+ DepthStencilMode depthStencilMode,
+ Target target,
+ SwizzleComponent swizzleR,
+ SwizzleComponent swizzleG,
+ SwizzleComponent swizzleB,
+ SwizzleComponent swizzleA)
+ {
+ Width = width;
+ Height = height;
+ Depth = depth;
+ Levels = levels;
+ Samples = samples;
+ BlockWidth = blockWidth;
+ BlockHeight = blockHeight;
+ BytesPerPixel = bytesPerPixel;
+ Format = format;
+ DepthStencilMode = depthStencilMode;
+ Target = target;
+ SwizzleR = swizzleR;
+ SwizzleG = swizzleG;
+ SwizzleB = swizzleB;
+ SwizzleA = swizzleA;
+ }
+
+ public int GetMipSize(int level)
+ {
+ return GetMipStride(level) * GetLevelHeight(level) * GetLevelDepth(level);
+ }
+
+ public int GetMipStride(int level)
+ {
+ return BitUtils.AlignUp(GetLevelWidth(level) * BytesPerPixel, 4);
+ }
+
+ private int GetLevelWidth(int level)
+ {
+ return BitUtils.DivRoundUp(GetLevelSize(Width, level), BlockWidth);
+ }
+
+ private int GetLevelHeight(int level)
+ {
+ return BitUtils.DivRoundUp(GetLevelSize(Height, level), BlockHeight);
+ }
+
+ private int GetLevelDepth(int level)
+ {
+ return Target == Target.Texture3D ? GetLevelSize(Depth, level) : GetLayers();
+ }
+
+ public int GetDepthOrLayers()
+ {
+ return Target == Target.Texture3D ? Depth : GetLayers();
+ }
+
+ public int GetLayers()
+ {
+ if (Target == Target.Texture2DArray ||
+ Target == Target.Texture2DMultisampleArray ||
+ Target == Target.CubemapArray)
+ {
+ return Depth;
+ }
+ else if (Target == Target.Cubemap)
+ {
+ return 6;
+ }
+
+ return 1;
+ }
+
+ private static int GetLevelSize(int size, int level)
+ {
+ return Math.Max(1, size >> level);
+ }
+ }
+}
diff --git a/Ryujinx.Graphics.GAL/TextureReleaseCallback.cs b/Ryujinx.Graphics.GAL/TextureReleaseCallback.cs
new file mode 100644
index 00000000..c058df2b
--- /dev/null
+++ b/Ryujinx.Graphics.GAL/TextureReleaseCallback.cs
@@ -0,0 +1,4 @@
+namespace Ryujinx.Graphics.GAL
+{
+ public delegate void TextureReleaseCallback(object context);
+}
diff --git a/Ryujinx.Graphics.GAL/Viewport.cs b/Ryujinx.Graphics.GAL/Viewport.cs
new file mode 100644
index 00000000..d9d6e20a
--- /dev/null
+++ b/Ryujinx.Graphics.GAL/Viewport.cs
@@ -0,0 +1,33 @@
+namespace Ryujinx.Graphics.GAL
+{
+ public struct Viewport
+ {
+ public RectangleF Region { get; }
+
+ public ViewportSwizzle SwizzleX { get; }
+ public ViewportSwizzle SwizzleY { get; }
+ public ViewportSwizzle SwizzleZ { get; }
+ public ViewportSwizzle SwizzleW { get; }
+
+ public float DepthNear { get; }
+ public float DepthFar { get; }
+
+ public Viewport(
+ RectangleF region,
+ ViewportSwizzle swizzleX,
+ ViewportSwizzle swizzleY,
+ ViewportSwizzle swizzleZ,
+ ViewportSwizzle swizzleW,
+ float depthNear,
+ float depthFar)
+ {
+ Region = region;
+ SwizzleX = swizzleX;
+ SwizzleY = swizzleY;
+ SwizzleZ = swizzleZ;
+ SwizzleW = swizzleW;
+ DepthNear = depthNear;
+ DepthFar = depthFar;
+ }
+ }
+}
diff --git a/Ryujinx.Graphics.GAL/ViewportSwizzle.cs b/Ryujinx.Graphics.GAL/ViewportSwizzle.cs
new file mode 100644
index 00000000..5f04bf87
--- /dev/null
+++ b/Ryujinx.Graphics.GAL/ViewportSwizzle.cs
@@ -0,0 +1,14 @@
+namespace Ryujinx.Graphics.GAL
+{
+ public enum ViewportSwizzle
+ {
+ PositiveX,
+ NegativeX,
+ PositiveY,
+ NegativeY,
+ PositiveZ,
+ NegativeZ,
+ PositiveW,
+ NegativeW
+ }
+}