From 654e617fe78b0f5cc86d0bcf0625301abff168f5 Mon Sep 17 00:00:00 2001 From: gdkchan Date: Sun, 29 Dec 2019 14:41:50 -0300 Subject: Some code cleanup --- Ryujinx.Graphics.GAL/AddressMode.cs | 14 +++ Ryujinx.Graphics.GAL/Blend/BlendDescriptor.cs | 32 ------ Ryujinx.Graphics.GAL/Blend/BlendFactor.cs | 41 ------- Ryujinx.Graphics.GAL/Blend/BlendOp.cs | 17 --- Ryujinx.Graphics.GAL/BlendDescriptor.cs | 32 ++++++ Ryujinx.Graphics.GAL/BlendFactor.cs | 41 +++++++ Ryujinx.Graphics.GAL/BlendOp.cs | 17 +++ Ryujinx.Graphics.GAL/Color/ColorF.cs | 18 ---- Ryujinx.Graphics.GAL/Color/ColorSI.cs | 18 ---- Ryujinx.Graphics.GAL/Color/ColorUI.cs | 18 ---- Ryujinx.Graphics.GAL/ColorF.cs | 18 ++++ Ryujinx.Graphics.GAL/CompareMode.cs | 8 ++ .../DepthStencil/DepthStencilState.cs | 47 -------- .../DepthStencil/DepthTestDescriptor.cs | 20 ---- Ryujinx.Graphics.GAL/DepthStencil/StencilOp.cs | 14 --- .../DepthStencil/StencilTestDescriptor.cs | 56 ---------- Ryujinx.Graphics.GAL/DepthStencilMode.cs | 8 ++ Ryujinx.Graphics.GAL/DepthStencilState.cs | 47 ++++++++ Ryujinx.Graphics.GAL/DepthTestDescriptor.cs | 20 ++++ Ryujinx.Graphics.GAL/IPipeline.cs | 44 ++++---- Ryujinx.Graphics.GAL/IRenderer.cs | 2 - Ryujinx.Graphics.GAL/ITexture.cs | 1 - .../InputAssembler/VertexAttribDescriptor.cs | 17 --- .../InputAssembler/VertexBufferDescriptor.cs | 17 --- Ryujinx.Graphics.GAL/MagFilter.cs | 8 ++ Ryujinx.Graphics.GAL/MinFilter.cs | 12 +++ Ryujinx.Graphics.GAL/Sampler/AddressMode.cs | 14 --- Ryujinx.Graphics.GAL/Sampler/CompareMode.cs | 8 -- Ryujinx.Graphics.GAL/Sampler/MagFilter.cs | 8 -- Ryujinx.Graphics.GAL/Sampler/MinFilter.cs | 12 --- Ryujinx.Graphics.GAL/Sampler/SamplerCreateInfo.cs | 52 --------- Ryujinx.Graphics.GAL/SamplerCreateInfo.cs | 50 +++++++++ Ryujinx.Graphics.GAL/StencilOp.cs | 14 +++ Ryujinx.Graphics.GAL/StencilTestDescriptor.cs | 56 ++++++++++ Ryujinx.Graphics.GAL/SwizzleComponent.cs | 12 +++ Ryujinx.Graphics.GAL/Target.cs | 17 +++ Ryujinx.Graphics.GAL/Texture/DepthStencilMode.cs | 8 -- Ryujinx.Graphics.GAL/Texture/SwizzleComponent.cs | 12 --- Ryujinx.Graphics.GAL/Texture/Target.cs | 17 --- Ryujinx.Graphics.GAL/Texture/TextureCreateInfo.cs | 120 --------------------- Ryujinx.Graphics.GAL/TextureCreateInfo.cs | 120 +++++++++++++++++++++ Ryujinx.Graphics.GAL/VertexAttribDescriptor.cs | 17 +++ Ryujinx.Graphics.GAL/VertexBufferDescriptor.cs | 17 +++ 43 files changed, 548 insertions(+), 593 deletions(-) create mode 100644 Ryujinx.Graphics.GAL/AddressMode.cs delete mode 100644 Ryujinx.Graphics.GAL/Blend/BlendDescriptor.cs delete mode 100644 Ryujinx.Graphics.GAL/Blend/BlendFactor.cs delete mode 100644 Ryujinx.Graphics.GAL/Blend/BlendOp.cs create mode 100644 Ryujinx.Graphics.GAL/BlendDescriptor.cs create mode 100644 Ryujinx.Graphics.GAL/BlendFactor.cs create mode 100644 Ryujinx.Graphics.GAL/BlendOp.cs delete mode 100644 Ryujinx.Graphics.GAL/Color/ColorF.cs delete mode 100644 Ryujinx.Graphics.GAL/Color/ColorSI.cs delete mode 100644 Ryujinx.Graphics.GAL/Color/ColorUI.cs create mode 100644 Ryujinx.Graphics.GAL/ColorF.cs create mode 100644 Ryujinx.Graphics.GAL/CompareMode.cs delete mode 100644 Ryujinx.Graphics.GAL/DepthStencil/DepthStencilState.cs delete mode 100644 Ryujinx.Graphics.GAL/DepthStencil/DepthTestDescriptor.cs delete mode 100644 Ryujinx.Graphics.GAL/DepthStencil/StencilOp.cs delete mode 100644 Ryujinx.Graphics.GAL/DepthStencil/StencilTestDescriptor.cs create mode 100644 Ryujinx.Graphics.GAL/DepthStencilMode.cs create mode 100644 Ryujinx.Graphics.GAL/DepthStencilState.cs create mode 100644 Ryujinx.Graphics.GAL/DepthTestDescriptor.cs delete mode 100644 Ryujinx.Graphics.GAL/InputAssembler/VertexAttribDescriptor.cs delete mode 100644 Ryujinx.Graphics.GAL/InputAssembler/VertexBufferDescriptor.cs create mode 100644 Ryujinx.Graphics.GAL/MagFilter.cs create mode 100644 Ryujinx.Graphics.GAL/MinFilter.cs delete mode 100644 Ryujinx.Graphics.GAL/Sampler/AddressMode.cs delete mode 100644 Ryujinx.Graphics.GAL/Sampler/CompareMode.cs delete mode 100644 Ryujinx.Graphics.GAL/Sampler/MagFilter.cs delete mode 100644 Ryujinx.Graphics.GAL/Sampler/MinFilter.cs delete mode 100644 Ryujinx.Graphics.GAL/Sampler/SamplerCreateInfo.cs create mode 100644 Ryujinx.Graphics.GAL/SamplerCreateInfo.cs create mode 100644 Ryujinx.Graphics.GAL/StencilOp.cs create mode 100644 Ryujinx.Graphics.GAL/StencilTestDescriptor.cs create mode 100644 Ryujinx.Graphics.GAL/SwizzleComponent.cs create mode 100644 Ryujinx.Graphics.GAL/Target.cs delete mode 100644 Ryujinx.Graphics.GAL/Texture/DepthStencilMode.cs delete mode 100644 Ryujinx.Graphics.GAL/Texture/SwizzleComponent.cs delete mode 100644 Ryujinx.Graphics.GAL/Texture/Target.cs delete mode 100644 Ryujinx.Graphics.GAL/Texture/TextureCreateInfo.cs create mode 100644 Ryujinx.Graphics.GAL/TextureCreateInfo.cs create mode 100644 Ryujinx.Graphics.GAL/VertexAttribDescriptor.cs create mode 100644 Ryujinx.Graphics.GAL/VertexBufferDescriptor.cs (limited to 'Ryujinx.Graphics.GAL') diff --git a/Ryujinx.Graphics.GAL/AddressMode.cs b/Ryujinx.Graphics.GAL/AddressMode.cs new file mode 100644 index 00000000..153925b1 --- /dev/null +++ b/Ryujinx.Graphics.GAL/AddressMode.cs @@ -0,0 +1,14 @@ +namespace Ryujinx.Graphics.GAL +{ + public enum AddressMode + { + Repeat, + MirroredRepeat, + ClampToEdge, + ClampToBorder, + Clamp, + MirrorClampToEdge, + MirrorClampToBorder, + MirrorClamp + } +} \ No newline at end of file diff --git a/Ryujinx.Graphics.GAL/Blend/BlendDescriptor.cs b/Ryujinx.Graphics.GAL/Blend/BlendDescriptor.cs deleted file mode 100644 index d7ef8004..00000000 --- a/Ryujinx.Graphics.GAL/Blend/BlendDescriptor.cs +++ /dev/null @@ -1,32 +0,0 @@ -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 deleted file mode 100644 index f92e5b3a..00000000 --- a/Ryujinx.Graphics.GAL/Blend/BlendFactor.cs +++ /dev/null @@ -1,41 +0,0 @@ -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, - - ZeroGl = 0x4000, - OneGl = 0x4001, - SrcColorGl = 0x4300, - OneMinusSrcColorGl = 0x4301, - SrcAlphaGl = 0x4302, - OneMinusSrcAlphaGl = 0x4303, - DstAlphaGl = 0x4304, - OneMinusDstAlphaGl = 0x4305, - DstColorGl = 0x4306, - OneMinusDstColorGl = 0x4307, - SrcAlphaSaturateGl = 0x4308, - Src1ColorGl = 0xc900, - OneMinusSrc1ColorGl = 0xc901, - Src1AlphaGl = 0xc902, - OneMinusSrc1AlphaGl = 0xc903 - } -} \ No newline at end of file diff --git a/Ryujinx.Graphics.GAL/Blend/BlendOp.cs b/Ryujinx.Graphics.GAL/Blend/BlendOp.cs deleted file mode 100644 index 566dafd9..00000000 --- a/Ryujinx.Graphics.GAL/Blend/BlendOp.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace Ryujinx.Graphics.GAL.Blend -{ - public enum BlendOp - { - Add = 1, - Subtract, - ReverseSubtract, - Minimum, - Maximum, - - AddGl = 0x8006, - SubtractGl = 0x8007, - ReverseSubtractGl = 0x8008, - MinimumGl = 0x800a, - MaximumGl = 0x800b - } -} diff --git a/Ryujinx.Graphics.GAL/BlendDescriptor.cs b/Ryujinx.Graphics.GAL/BlendDescriptor.cs new file mode 100644 index 00000000..b35a0169 --- /dev/null +++ b/Ryujinx.Graphics.GAL/BlendDescriptor.cs @@ -0,0 +1,32 @@ +namespace Ryujinx.Graphics.GAL +{ + 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/BlendFactor.cs b/Ryujinx.Graphics.GAL/BlendFactor.cs new file mode 100644 index 00000000..135873e9 --- /dev/null +++ b/Ryujinx.Graphics.GAL/BlendFactor.cs @@ -0,0 +1,41 @@ +namespace Ryujinx.Graphics.GAL +{ + 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, + + ZeroGl = 0x4000, + OneGl = 0x4001, + SrcColorGl = 0x4300, + OneMinusSrcColorGl = 0x4301, + SrcAlphaGl = 0x4302, + OneMinusSrcAlphaGl = 0x4303, + DstAlphaGl = 0x4304, + OneMinusDstAlphaGl = 0x4305, + DstColorGl = 0x4306, + OneMinusDstColorGl = 0x4307, + SrcAlphaSaturateGl = 0x4308, + Src1ColorGl = 0xc900, + OneMinusSrc1ColorGl = 0xc901, + Src1AlphaGl = 0xc902, + OneMinusSrc1AlphaGl = 0xc903 + } +} \ No newline at end of file diff --git a/Ryujinx.Graphics.GAL/BlendOp.cs b/Ryujinx.Graphics.GAL/BlendOp.cs new file mode 100644 index 00000000..de1ab67d --- /dev/null +++ b/Ryujinx.Graphics.GAL/BlendOp.cs @@ -0,0 +1,17 @@ +namespace Ryujinx.Graphics.GAL +{ + public enum BlendOp + { + Add = 1, + Subtract, + ReverseSubtract, + Minimum, + Maximum, + + AddGl = 0x8006, + SubtractGl = 0x8007, + ReverseSubtractGl = 0x8008, + MinimumGl = 0x800a, + MaximumGl = 0x800b + } +} diff --git a/Ryujinx.Graphics.GAL/Color/ColorF.cs b/Ryujinx.Graphics.GAL/Color/ColorF.cs deleted file mode 100644 index bc4b32b8..00000000 --- a/Ryujinx.Graphics.GAL/Color/ColorF.cs +++ /dev/null @@ -1,18 +0,0 @@ -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 deleted file mode 100644 index 9cde0406..00000000 --- a/Ryujinx.Graphics.GAL/Color/ColorSI.cs +++ /dev/null @@ -1,18 +0,0 @@ -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 deleted file mode 100644 index 3bac84ef..00000000 --- a/Ryujinx.Graphics.GAL/Color/ColorUI.cs +++ /dev/null @@ -1,18 +0,0 @@ -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/ColorF.cs b/Ryujinx.Graphics.GAL/ColorF.cs new file mode 100644 index 00000000..2e971a62 --- /dev/null +++ b/Ryujinx.Graphics.GAL/ColorF.cs @@ -0,0 +1,18 @@ +namespace Ryujinx.Graphics.GAL +{ + 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/CompareMode.cs b/Ryujinx.Graphics.GAL/CompareMode.cs new file mode 100644 index 00000000..7a64d9bb --- /dev/null +++ b/Ryujinx.Graphics.GAL/CompareMode.cs @@ -0,0 +1,8 @@ +namespace Ryujinx.Graphics.GAL +{ + public enum CompareMode + { + None, + CompareRToTexture + } +} \ No newline at end of file diff --git a/Ryujinx.Graphics.GAL/DepthStencil/DepthStencilState.cs b/Ryujinx.Graphics.GAL/DepthStencil/DepthStencilState.cs deleted file mode 100644 index 93b8d50e..00000000 --- a/Ryujinx.Graphics.GAL/DepthStencil/DepthStencilState.cs +++ /dev/null @@ -1,47 +0,0 @@ -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 deleted file mode 100644 index 98b1429b..00000000 --- a/Ryujinx.Graphics.GAL/DepthStencil/DepthTestDescriptor.cs +++ /dev/null @@ -1,20 +0,0 @@ -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 deleted file mode 100644 index 3818c6a5..00000000 --- a/Ryujinx.Graphics.GAL/DepthStencil/StencilOp.cs +++ /dev/null @@ -1,14 +0,0 @@ -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 deleted file mode 100644 index 2db53172..00000000 --- a/Ryujinx.Graphics.GAL/DepthStencil/StencilTestDescriptor.cs +++ /dev/null @@ -1,56 +0,0 @@ -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/DepthStencilMode.cs b/Ryujinx.Graphics.GAL/DepthStencilMode.cs new file mode 100644 index 00000000..e80d0d4b --- /dev/null +++ b/Ryujinx.Graphics.GAL/DepthStencilMode.cs @@ -0,0 +1,8 @@ +namespace Ryujinx.Graphics.GAL +{ + public enum DepthStencilMode + { + Depth, + Stencil + } +} \ No newline at end of file diff --git a/Ryujinx.Graphics.GAL/DepthStencilState.cs b/Ryujinx.Graphics.GAL/DepthStencilState.cs new file mode 100644 index 00000000..d81e8436 --- /dev/null +++ b/Ryujinx.Graphics.GAL/DepthStencilState.cs @@ -0,0 +1,47 @@ +namespace Ryujinx.Graphics.GAL +{ + 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/DepthTestDescriptor.cs b/Ryujinx.Graphics.GAL/DepthTestDescriptor.cs new file mode 100644 index 00000000..c835e941 --- /dev/null +++ b/Ryujinx.Graphics.GAL/DepthTestDescriptor.cs @@ -0,0 +1,20 @@ +namespace Ryujinx.Graphics.GAL +{ + 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/IPipeline.cs b/Ryujinx.Graphics.GAL/IPipeline.cs index 7211fbe0..1a502913 100644 --- a/Ryujinx.Graphics.GAL/IPipeline.cs +++ b/Ryujinx.Graphics.GAL/IPipeline.cs @@ -1,33 +1,10 @@ -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 IPipeline { - void BindBlendState(int index, BlendDescriptor blend); - - void BindIndexBuffer(BufferRange buffer, IndexType type); - - void BindImage(int index, ShaderStage stage, ITexture texture); - - void BindProgram(IProgram program); - - void BindSampler(int index, ShaderStage stage, ISampler sampler); - void BindTexture(int index, ShaderStage stage, ITexture texture); - - void BindStorageBuffer(int index, ShaderStage stage, BufferRange buffer); - void BindUniformBuffer(int index, ShaderStage stage, BufferRange buffer); - - 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, @@ -35,7 +12,7 @@ namespace Ryujinx.Graphics.GAL int stencilValue, int stencilMask); - void Dispatch(int groupsX, int groupsY, int groupsZ); + void DispatchCompute(int groupsX, int groupsY, int groupsZ); void Draw(int vertexCount, int instanceCount, int firstVertex, int firstInstance); void DrawIndexed( @@ -45,6 +22,8 @@ namespace Ryujinx.Graphics.GAL int firstVertex, int firstInstance); + void SetBlendState(int index, BlendDescriptor blend); + void SetBlendColor(ColorF color); void SetDepthBias(PolygonModeMask enables, float factor, float units, float clamp); @@ -57,16 +36,33 @@ namespace Ryujinx.Graphics.GAL void SetFrontFace(FrontFace frontFace); + void SetIndexBuffer(BufferRange buffer, IndexType type); + + void SetImage(int index, ShaderStage stage, ITexture texture); + void SetPrimitiveRestart(bool enable, int index); void SetPrimitiveTopology(PrimitiveTopology topology); + void SetProgram(IProgram program); + void SetRenderTargetColorMasks(uint[] componentMask); void SetRenderTargets(ITexture[] colors, ITexture depthStencil); + void SetSampler(int index, ShaderStage stage, ISampler sampler); + void SetStencilTest(StencilTestDescriptor stencilTest); + void SetStorageBuffer(int index, ShaderStage stage, BufferRange buffer); + + void SetTexture(int index, ShaderStage stage, ITexture texture); + + void SetUniformBuffer(int index, ShaderStage stage, BufferRange buffer); + + void SetVertexAttribs(VertexAttribDescriptor[] vertexAttribs); + void SetVertexBuffers(VertexBufferDescriptor[] vertexBuffers); + void SetViewports(int first, Viewport[] viewports); void TextureBarrier(); diff --git a/Ryujinx.Graphics.GAL/IRenderer.cs b/Ryujinx.Graphics.GAL/IRenderer.cs index ebe6785c..4f9e5bc9 100644 --- a/Ryujinx.Graphics.GAL/IRenderer.cs +++ b/Ryujinx.Graphics.GAL/IRenderer.cs @@ -1,5 +1,3 @@ -using Ryujinx.Graphics.GAL.Sampler; -using Ryujinx.Graphics.GAL.Texture; using Ryujinx.Graphics.Shader; namespace Ryujinx.Graphics.GAL diff --git a/Ryujinx.Graphics.GAL/ITexture.cs b/Ryujinx.Graphics.GAL/ITexture.cs index 592c0482..7664f89c 100644 --- a/Ryujinx.Graphics.GAL/ITexture.cs +++ b/Ryujinx.Graphics.GAL/ITexture.cs @@ -1,4 +1,3 @@ -using Ryujinx.Graphics.GAL.Texture; using System; namespace Ryujinx.Graphics.GAL diff --git a/Ryujinx.Graphics.GAL/InputAssembler/VertexAttribDescriptor.cs b/Ryujinx.Graphics.GAL/InputAssembler/VertexAttribDescriptor.cs deleted file mode 100644 index cba3a9a4..00000000 --- a/Ryujinx.Graphics.GAL/InputAssembler/VertexAttribDescriptor.cs +++ /dev/null @@ -1,17 +0,0 @@ -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 deleted file mode 100644 index eb428f8e..00000000 --- a/Ryujinx.Graphics.GAL/InputAssembler/VertexBufferDescriptor.cs +++ /dev/null @@ -1,17 +0,0 @@ -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/MagFilter.cs b/Ryujinx.Graphics.GAL/MagFilter.cs new file mode 100644 index 00000000..f20d095e --- /dev/null +++ b/Ryujinx.Graphics.GAL/MagFilter.cs @@ -0,0 +1,8 @@ +namespace Ryujinx.Graphics.GAL +{ + public enum MagFilter + { + Nearest = 1, + Linear + } +} \ No newline at end of file diff --git a/Ryujinx.Graphics.GAL/MinFilter.cs b/Ryujinx.Graphics.GAL/MinFilter.cs new file mode 100644 index 00000000..b7a0740b --- /dev/null +++ b/Ryujinx.Graphics.GAL/MinFilter.cs @@ -0,0 +1,12 @@ +namespace Ryujinx.Graphics.GAL +{ + public enum MinFilter + { + Nearest = 1, + Linear, + NearestMipmapNearest, + LinearMipmapNearest, + NearestMipmapLinear, + LinearMipmapLinear + } +} \ No newline at end of file diff --git a/Ryujinx.Graphics.GAL/Sampler/AddressMode.cs b/Ryujinx.Graphics.GAL/Sampler/AddressMode.cs deleted file mode 100644 index 4f56d892..00000000 --- a/Ryujinx.Graphics.GAL/Sampler/AddressMode.cs +++ /dev/null @@ -1,14 +0,0 @@ -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 deleted file mode 100644 index ca4b09a0..00000000 --- a/Ryujinx.Graphics.GAL/Sampler/CompareMode.cs +++ /dev/null @@ -1,8 +0,0 @@ -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 deleted file mode 100644 index 3c9c9de6..00000000 --- a/Ryujinx.Graphics.GAL/Sampler/MagFilter.cs +++ /dev/null @@ -1,8 +0,0 @@ -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 deleted file mode 100644 index d012f695..00000000 --- a/Ryujinx.Graphics.GAL/Sampler/MinFilter.cs +++ /dev/null @@ -1,12 +0,0 @@ -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 deleted file mode 100644 index 3f42742b..00000000 --- a/Ryujinx.Graphics.GAL/Sampler/SamplerCreateInfo.cs +++ /dev/null @@ -1,52 +0,0 @@ -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/SamplerCreateInfo.cs b/Ryujinx.Graphics.GAL/SamplerCreateInfo.cs new file mode 100644 index 00000000..33d80af5 --- /dev/null +++ b/Ryujinx.Graphics.GAL/SamplerCreateInfo.cs @@ -0,0 +1,50 @@ +namespace Ryujinx.Graphics.GAL +{ + 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/StencilOp.cs b/Ryujinx.Graphics.GAL/StencilOp.cs new file mode 100644 index 00000000..f0ac829e --- /dev/null +++ b/Ryujinx.Graphics.GAL/StencilOp.cs @@ -0,0 +1,14 @@ +namespace Ryujinx.Graphics.GAL +{ + public enum StencilOp + { + Keep = 1, + Zero, + Replace, + IncrementAndClamp, + DecrementAndClamp, + Invert, + IncrementAndWrap, + DecrementAndWrap + } +} \ No newline at end of file diff --git a/Ryujinx.Graphics.GAL/StencilTestDescriptor.cs b/Ryujinx.Graphics.GAL/StencilTestDescriptor.cs new file mode 100644 index 00000000..8c9d1644 --- /dev/null +++ b/Ryujinx.Graphics.GAL/StencilTestDescriptor.cs @@ -0,0 +1,56 @@ +namespace Ryujinx.Graphics.GAL +{ + 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/SwizzleComponent.cs b/Ryujinx.Graphics.GAL/SwizzleComponent.cs new file mode 100644 index 00000000..a405bd13 --- /dev/null +++ b/Ryujinx.Graphics.GAL/SwizzleComponent.cs @@ -0,0 +1,12 @@ +namespace Ryujinx.Graphics.GAL +{ + public enum SwizzleComponent + { + Zero, + One, + Red, + Green, + Blue, + Alpha + } +} \ No newline at end of file diff --git a/Ryujinx.Graphics.GAL/Target.cs b/Ryujinx.Graphics.GAL/Target.cs new file mode 100644 index 00000000..73f77f43 --- /dev/null +++ b/Ryujinx.Graphics.GAL/Target.cs @@ -0,0 +1,17 @@ +namespace Ryujinx.Graphics.GAL +{ + 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/DepthStencilMode.cs b/Ryujinx.Graphics.GAL/Texture/DepthStencilMode.cs deleted file mode 100644 index d7a379d8..00000000 --- a/Ryujinx.Graphics.GAL/Texture/DepthStencilMode.cs +++ /dev/null @@ -1,8 +0,0 @@ -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 deleted file mode 100644 index fd7d50e3..00000000 --- a/Ryujinx.Graphics.GAL/Texture/SwizzleComponent.cs +++ /dev/null @@ -1,12 +0,0 @@ -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 deleted file mode 100644 index b9cc1105..00000000 --- a/Ryujinx.Graphics.GAL/Texture/Target.cs +++ /dev/null @@ -1,17 +0,0 @@ -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 deleted file mode 100644 index c6a73d91..00000000 --- a/Ryujinx.Graphics.GAL/Texture/TextureCreateInfo.cs +++ /dev/null @@ -1,120 +0,0 @@ -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 GetMipSize2D(int level) - { - return GetMipStride(level) * GetLevelHeight(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/TextureCreateInfo.cs b/Ryujinx.Graphics.GAL/TextureCreateInfo.cs new file mode 100644 index 00000000..8e8c5ff7 --- /dev/null +++ b/Ryujinx.Graphics.GAL/TextureCreateInfo.cs @@ -0,0 +1,120 @@ +using Ryujinx.Common; +using System; + +namespace Ryujinx.Graphics.GAL +{ + 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 GetMipSize2D(int level) + { + return GetMipStride(level) * GetLevelHeight(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/VertexAttribDescriptor.cs b/Ryujinx.Graphics.GAL/VertexAttribDescriptor.cs new file mode 100644 index 00000000..18774aae --- /dev/null +++ b/Ryujinx.Graphics.GAL/VertexAttribDescriptor.cs @@ -0,0 +1,17 @@ +namespace Ryujinx.Graphics.GAL +{ + 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/VertexBufferDescriptor.cs b/Ryujinx.Graphics.GAL/VertexBufferDescriptor.cs new file mode 100644 index 00000000..bcd3b28f --- /dev/null +++ b/Ryujinx.Graphics.GAL/VertexBufferDescriptor.cs @@ -0,0 +1,17 @@ +namespace Ryujinx.Graphics.GAL +{ + 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; + } + } +} -- cgit v1.2.3