mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2025-06-28 20:30:47 -07:00
Move solution and projects to src
This commit is contained in:
14
src/Ryujinx.Graphics.GAL/AddressMode.cs
Normal file
14
src/Ryujinx.Graphics.GAL/AddressMode.cs
Normal file
@ -0,0 +1,14 @@
|
||||
namespace Ryujinx.Graphics.GAL
|
||||
{
|
||||
public enum AddressMode
|
||||
{
|
||||
Repeat,
|
||||
MirroredRepeat,
|
||||
ClampToEdge,
|
||||
ClampToBorder,
|
||||
Clamp,
|
||||
MirrorClampToEdge,
|
||||
MirrorClampToBorder,
|
||||
MirrorClamp
|
||||
}
|
||||
}
|
16
src/Ryujinx.Graphics.GAL/AdvancedBlendDescriptor.cs
Normal file
16
src/Ryujinx.Graphics.GAL/AdvancedBlendDescriptor.cs
Normal file
@ -0,0 +1,16 @@
|
||||
namespace Ryujinx.Graphics.GAL
|
||||
{
|
||||
public struct AdvancedBlendDescriptor
|
||||
{
|
||||
public AdvancedBlendOp Op { get; }
|
||||
public AdvancedBlendOverlap Overlap { get; }
|
||||
public bool SrcPreMultiplied { get; }
|
||||
|
||||
public AdvancedBlendDescriptor(AdvancedBlendOp op, AdvancedBlendOverlap overlap, bool srcPreMultiplied)
|
||||
{
|
||||
Op = op;
|
||||
Overlap = overlap;
|
||||
SrcPreMultiplied = srcPreMultiplied;
|
||||
}
|
||||
}
|
||||
}
|
52
src/Ryujinx.Graphics.GAL/AdvancedBlendOp.cs
Normal file
52
src/Ryujinx.Graphics.GAL/AdvancedBlendOp.cs
Normal file
@ -0,0 +1,52 @@
|
||||
namespace Ryujinx.Graphics.GAL
|
||||
{
|
||||
public enum AdvancedBlendOp
|
||||
{
|
||||
Zero,
|
||||
Src,
|
||||
Dst,
|
||||
SrcOver,
|
||||
DstOver,
|
||||
SrcIn,
|
||||
DstIn,
|
||||
SrcOut,
|
||||
DstOut,
|
||||
SrcAtop,
|
||||
DstAtop,
|
||||
Xor,
|
||||
Plus,
|
||||
PlusClamped,
|
||||
PlusClampedAlpha,
|
||||
PlusDarker,
|
||||
Multiply,
|
||||
Screen,
|
||||
Overlay,
|
||||
Darken,
|
||||
Lighten,
|
||||
ColorDodge,
|
||||
ColorBurn,
|
||||
HardLight,
|
||||
SoftLight,
|
||||
Difference,
|
||||
Minus,
|
||||
MinusClamped,
|
||||
Exclusion,
|
||||
Contrast,
|
||||
Invert,
|
||||
InvertRGB,
|
||||
InvertOvg,
|
||||
LinearDodge,
|
||||
LinearBurn,
|
||||
VividLight,
|
||||
LinearLight,
|
||||
PinLight,
|
||||
HardMix,
|
||||
Red,
|
||||
Green,
|
||||
Blue,
|
||||
HslHue,
|
||||
HslSaturation,
|
||||
HslColor,
|
||||
HslLuminosity
|
||||
}
|
||||
}
|
9
src/Ryujinx.Graphics.GAL/AdvancedBlendOverlap.cs
Normal file
9
src/Ryujinx.Graphics.GAL/AdvancedBlendOverlap.cs
Normal file
@ -0,0 +1,9 @@
|
||||
namespace Ryujinx.Graphics.GAL
|
||||
{
|
||||
public enum AdvancedBlendOverlap
|
||||
{
|
||||
Uncorrelated,
|
||||
Disjoint,
|
||||
Conjoint
|
||||
}
|
||||
}
|
12
src/Ryujinx.Graphics.GAL/AntiAliasing.cs
Normal file
12
src/Ryujinx.Graphics.GAL/AntiAliasing.cs
Normal file
@ -0,0 +1,12 @@
|
||||
namespace Ryujinx.Graphics.GAL
|
||||
{
|
||||
public enum AntiAliasing
|
||||
{
|
||||
None,
|
||||
Fxaa,
|
||||
SmaaLow,
|
||||
SmaaMedium,
|
||||
SmaaHigh,
|
||||
SmaaUltra
|
||||
}
|
||||
}
|
35
src/Ryujinx.Graphics.GAL/BlendDescriptor.cs
Normal file
35
src/Ryujinx.Graphics.GAL/BlendDescriptor.cs
Normal file
@ -0,0 +1,35 @@
|
||||
namespace Ryujinx.Graphics.GAL
|
||||
{
|
||||
public readonly struct BlendDescriptor
|
||||
{
|
||||
public bool Enable { get; }
|
||||
|
||||
public ColorF BlendConstant { 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,
|
||||
ColorF blendConstant,
|
||||
BlendOp colorOp,
|
||||
BlendFactor colorSrcFactor,
|
||||
BlendFactor colorDstFactor,
|
||||
BlendOp alphaOp,
|
||||
BlendFactor alphaSrcFactor,
|
||||
BlendFactor alphaDstFactor)
|
||||
{
|
||||
Enable = enable;
|
||||
BlendConstant = blendConstant;
|
||||
ColorOp = colorOp;
|
||||
ColorSrcFactor = colorSrcFactor;
|
||||
ColorDstFactor = colorDstFactor;
|
||||
AlphaOp = alphaOp;
|
||||
AlphaSrcFactor = alphaSrcFactor;
|
||||
AlphaDstFactor = alphaDstFactor;
|
||||
}
|
||||
}
|
||||
}
|
62
src/Ryujinx.Graphics.GAL/BlendFactor.cs
Normal file
62
src/Ryujinx.Graphics.GAL/BlendFactor.cs
Normal file
@ -0,0 +1,62 @@
|
||||
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
|
||||
}
|
||||
|
||||
public static class BlendFactorExtensions
|
||||
{
|
||||
public static bool IsDualSource(this BlendFactor factor)
|
||||
{
|
||||
switch (factor)
|
||||
{
|
||||
case BlendFactor.Src1Color:
|
||||
case BlendFactor.Src1ColorGl:
|
||||
case BlendFactor.Src1Alpha:
|
||||
case BlendFactor.Src1AlphaGl:
|
||||
case BlendFactor.OneMinusSrc1Color:
|
||||
case BlendFactor.OneMinusSrc1ColorGl:
|
||||
case BlendFactor.OneMinusSrc1Alpha:
|
||||
case BlendFactor.OneMinusSrc1AlphaGl:
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
17
src/Ryujinx.Graphics.GAL/BlendOp.cs
Normal file
17
src/Ryujinx.Graphics.GAL/BlendOp.cs
Normal file
@ -0,0 +1,17 @@
|
||||
namespace Ryujinx.Graphics.GAL
|
||||
{
|
||||
public enum BlendOp
|
||||
{
|
||||
Add = 1,
|
||||
Subtract,
|
||||
ReverseSubtract,
|
||||
Minimum,
|
||||
Maximum,
|
||||
|
||||
AddGl = 0x8006,
|
||||
MinimumGl = 0x8007,
|
||||
MaximumGl = 0x8008,
|
||||
SubtractGl = 0x800a,
|
||||
ReverseSubtractGl = 0x800b
|
||||
}
|
||||
}
|
14
src/Ryujinx.Graphics.GAL/BufferAssignment.cs
Normal file
14
src/Ryujinx.Graphics.GAL/BufferAssignment.cs
Normal file
@ -0,0 +1,14 @@
|
||||
namespace Ryujinx.Graphics.GAL
|
||||
{
|
||||
public readonly struct BufferAssignment
|
||||
{
|
||||
public readonly int Binding;
|
||||
public readonly BufferRange Range;
|
||||
|
||||
public BufferAssignment(int binding, BufferRange range)
|
||||
{
|
||||
Binding = binding;
|
||||
Range = range;
|
||||
}
|
||||
}
|
||||
}
|
14
src/Ryujinx.Graphics.GAL/BufferHandle.cs
Normal file
14
src/Ryujinx.Graphics.GAL/BufferHandle.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Ryujinx.Graphics.GAL
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential, Size = 8)]
|
||||
public readonly record struct BufferHandle
|
||||
{
|
||||
private readonly ulong _value;
|
||||
|
||||
public static BufferHandle Null => new BufferHandle(0);
|
||||
|
||||
private BufferHandle(ulong value) => _value = value;
|
||||
}
|
||||
}
|
21
src/Ryujinx.Graphics.GAL/BufferRange.cs
Normal file
21
src/Ryujinx.Graphics.GAL/BufferRange.cs
Normal file
@ -0,0 +1,21 @@
|
||||
namespace Ryujinx.Graphics.GAL
|
||||
{
|
||||
public readonly struct BufferRange
|
||||
{
|
||||
private static readonly BufferRange _empty = new BufferRange(BufferHandle.Null, 0, 0);
|
||||
|
||||
public static BufferRange Empty => _empty;
|
||||
|
||||
public BufferHandle Handle { get; }
|
||||
|
||||
public int Offset { get; }
|
||||
public int Size { get; }
|
||||
|
||||
public BufferRange(BufferHandle handle, int offset, int size)
|
||||
{
|
||||
Handle = handle;
|
||||
Offset = offset;
|
||||
Size = size;
|
||||
}
|
||||
}
|
||||
}
|
140
src/Ryujinx.Graphics.GAL/Capabilities.cs
Normal file
140
src/Ryujinx.Graphics.GAL/Capabilities.cs
Normal file
@ -0,0 +1,140 @@
|
||||
using Ryujinx.Graphics.Shader.Translation;
|
||||
|
||||
namespace Ryujinx.Graphics.GAL
|
||||
{
|
||||
public readonly struct Capabilities
|
||||
{
|
||||
public readonly TargetApi Api;
|
||||
public readonly string VendorName;
|
||||
|
||||
public readonly bool HasFrontFacingBug;
|
||||
public readonly bool HasVectorIndexingBug;
|
||||
public readonly bool NeedsFragmentOutputSpecialization;
|
||||
public readonly bool ReduceShaderPrecision;
|
||||
|
||||
public readonly bool SupportsAstcCompression;
|
||||
public readonly bool SupportsBc123Compression;
|
||||
public readonly bool SupportsBc45Compression;
|
||||
public readonly bool SupportsBc67Compression;
|
||||
public readonly bool SupportsEtc2Compression;
|
||||
public readonly bool Supports3DTextureCompression;
|
||||
public readonly bool SupportsBgraFormat;
|
||||
public readonly bool SupportsR4G4Format;
|
||||
public readonly bool SupportsR4G4B4A4Format;
|
||||
public readonly bool SupportsSnormBufferTextureFormat;
|
||||
public readonly bool Supports5BitComponentFormat;
|
||||
public readonly bool SupportsBlendEquationAdvanced;
|
||||
public readonly bool SupportsFragmentShaderInterlock;
|
||||
public readonly bool SupportsFragmentShaderOrderingIntel;
|
||||
public readonly bool SupportsGeometryShader;
|
||||
public readonly bool SupportsGeometryShaderPassthrough;
|
||||
public readonly bool SupportsImageLoadFormatted;
|
||||
public readonly bool SupportsLayerVertexTessellation;
|
||||
public readonly bool SupportsMismatchingViewFormat;
|
||||
public readonly bool SupportsCubemapView;
|
||||
public readonly bool SupportsNonConstantTextureOffset;
|
||||
public readonly bool SupportsShaderBallot;
|
||||
public readonly bool SupportsTextureShadowLod;
|
||||
public readonly bool SupportsViewportIndexVertexTessellation;
|
||||
public readonly bool SupportsViewportMask;
|
||||
public readonly bool SupportsViewportSwizzle;
|
||||
public readonly bool SupportsIndirectParameters;
|
||||
|
||||
public readonly uint MaximumUniformBuffersPerStage;
|
||||
public readonly uint MaximumStorageBuffersPerStage;
|
||||
public readonly uint MaximumTexturesPerStage;
|
||||
public readonly uint MaximumImagesPerStage;
|
||||
|
||||
public readonly int MaximumComputeSharedMemorySize;
|
||||
public readonly float MaximumSupportedAnisotropy;
|
||||
public readonly int StorageBufferOffsetAlignment;
|
||||
|
||||
public readonly int GatherBiasPrecision;
|
||||
|
||||
public Capabilities(
|
||||
TargetApi api,
|
||||
string vendorName,
|
||||
bool hasFrontFacingBug,
|
||||
bool hasVectorIndexingBug,
|
||||
bool needsFragmentOutputSpecialization,
|
||||
bool reduceShaderPrecision,
|
||||
bool supportsAstcCompression,
|
||||
bool supportsBc123Compression,
|
||||
bool supportsBc45Compression,
|
||||
bool supportsBc67Compression,
|
||||
bool supportsEtc2Compression,
|
||||
bool supports3DTextureCompression,
|
||||
bool supportsBgraFormat,
|
||||
bool supportsR4G4Format,
|
||||
bool supportsR4G4B4A4Format,
|
||||
bool supportsSnormBufferTextureFormat,
|
||||
bool supports5BitComponentFormat,
|
||||
bool supportsBlendEquationAdvanced,
|
||||
bool supportsFragmentShaderInterlock,
|
||||
bool supportsFragmentShaderOrderingIntel,
|
||||
bool supportsGeometryShader,
|
||||
bool supportsGeometryShaderPassthrough,
|
||||
bool supportsImageLoadFormatted,
|
||||
bool supportsLayerVertexTessellation,
|
||||
bool supportsMismatchingViewFormat,
|
||||
bool supportsCubemapView,
|
||||
bool supportsNonConstantTextureOffset,
|
||||
bool supportsShaderBallot,
|
||||
bool supportsTextureShadowLod,
|
||||
bool supportsViewportIndexVertexTessellation,
|
||||
bool supportsViewportMask,
|
||||
bool supportsViewportSwizzle,
|
||||
bool supportsIndirectParameters,
|
||||
uint maximumUniformBuffersPerStage,
|
||||
uint maximumStorageBuffersPerStage,
|
||||
uint maximumTexturesPerStage,
|
||||
uint maximumImagesPerStage,
|
||||
int maximumComputeSharedMemorySize,
|
||||
float maximumSupportedAnisotropy,
|
||||
int storageBufferOffsetAlignment,
|
||||
int gatherBiasPrecision)
|
||||
{
|
||||
Api = api;
|
||||
VendorName = vendorName;
|
||||
HasFrontFacingBug = hasFrontFacingBug;
|
||||
HasVectorIndexingBug = hasVectorIndexingBug;
|
||||
NeedsFragmentOutputSpecialization = needsFragmentOutputSpecialization;
|
||||
ReduceShaderPrecision = reduceShaderPrecision;
|
||||
SupportsAstcCompression = supportsAstcCompression;
|
||||
SupportsBc123Compression = supportsBc123Compression;
|
||||
SupportsBc45Compression = supportsBc45Compression;
|
||||
SupportsBc67Compression = supportsBc67Compression;
|
||||
SupportsEtc2Compression = supportsEtc2Compression;
|
||||
Supports3DTextureCompression = supports3DTextureCompression;
|
||||
SupportsBgraFormat = supportsBgraFormat;
|
||||
SupportsR4G4Format = supportsR4G4Format;
|
||||
SupportsR4G4B4A4Format = supportsR4G4B4A4Format;
|
||||
SupportsSnormBufferTextureFormat = supportsSnormBufferTextureFormat;
|
||||
Supports5BitComponentFormat = supports5BitComponentFormat;
|
||||
SupportsBlendEquationAdvanced = supportsBlendEquationAdvanced;
|
||||
SupportsFragmentShaderInterlock = supportsFragmentShaderInterlock;
|
||||
SupportsFragmentShaderOrderingIntel = supportsFragmentShaderOrderingIntel;
|
||||
SupportsGeometryShader = supportsGeometryShader;
|
||||
SupportsGeometryShaderPassthrough = supportsGeometryShaderPassthrough;
|
||||
SupportsImageLoadFormatted = supportsImageLoadFormatted;
|
||||
SupportsLayerVertexTessellation = supportsLayerVertexTessellation;
|
||||
SupportsMismatchingViewFormat = supportsMismatchingViewFormat;
|
||||
SupportsCubemapView = supportsCubemapView;
|
||||
SupportsNonConstantTextureOffset = supportsNonConstantTextureOffset;
|
||||
SupportsShaderBallot = supportsShaderBallot;
|
||||
SupportsTextureShadowLod = supportsTextureShadowLod;
|
||||
SupportsViewportIndexVertexTessellation = supportsViewportIndexVertexTessellation;
|
||||
SupportsViewportMask = supportsViewportMask;
|
||||
SupportsViewportSwizzle = supportsViewportSwizzle;
|
||||
SupportsIndirectParameters = supportsIndirectParameters;
|
||||
MaximumUniformBuffersPerStage = maximumUniformBuffersPerStage;
|
||||
MaximumStorageBuffersPerStage = maximumStorageBuffersPerStage;
|
||||
MaximumTexturesPerStage = maximumTexturesPerStage;
|
||||
MaximumImagesPerStage = maximumImagesPerStage;
|
||||
MaximumComputeSharedMemorySize = maximumComputeSharedMemorySize;
|
||||
MaximumSupportedAnisotropy = maximumSupportedAnisotropy;
|
||||
StorageBufferOffsetAlignment = storageBufferOffsetAlignment;
|
||||
GatherBiasPrecision = gatherBiasPrecision;
|
||||
}
|
||||
}
|
||||
}
|
4
src/Ryujinx.Graphics.GAL/ColorF.cs
Normal file
4
src/Ryujinx.Graphics.GAL/ColorF.cs
Normal file
@ -0,0 +1,4 @@
|
||||
namespace Ryujinx.Graphics.GAL
|
||||
{
|
||||
public readonly record struct ColorF(float Red, float Green, float Blue, float Alpha);
|
||||
}
|
8
src/Ryujinx.Graphics.GAL/CompareMode.cs
Normal file
8
src/Ryujinx.Graphics.GAL/CompareMode.cs
Normal file
@ -0,0 +1,8 @@
|
||||
namespace Ryujinx.Graphics.GAL
|
||||
{
|
||||
public enum CompareMode
|
||||
{
|
||||
None,
|
||||
CompareRToTexture
|
||||
}
|
||||
}
|
23
src/Ryujinx.Graphics.GAL/CompareOp.cs
Normal file
23
src/Ryujinx.Graphics.GAL/CompareOp.cs
Normal file
@ -0,0 +1,23 @@
|
||||
namespace Ryujinx.Graphics.GAL
|
||||
{
|
||||
public enum CompareOp
|
||||
{
|
||||
Never = 1,
|
||||
Less,
|
||||
Equal,
|
||||
LessOrEqual,
|
||||
Greater,
|
||||
NotEqual,
|
||||
GreaterOrEqual,
|
||||
Always,
|
||||
|
||||
NeverGl = 0x200,
|
||||
LessGl = 0x201,
|
||||
EqualGl = 0x202,
|
||||
LessOrEqualGl = 0x203,
|
||||
GreaterGl = 0x204,
|
||||
NotEqualGl = 0x205,
|
||||
GreaterOrEqualGl = 0x206,
|
||||
AlwaysGl = 0x207,
|
||||
}
|
||||
}
|
9
src/Ryujinx.Graphics.GAL/CounterType.cs
Normal file
9
src/Ryujinx.Graphics.GAL/CounterType.cs
Normal file
@ -0,0 +1,9 @@
|
||||
namespace Ryujinx.Graphics.GAL
|
||||
{
|
||||
public enum CounterType
|
||||
{
|
||||
SamplesPassed,
|
||||
PrimitivesGenerated,
|
||||
TransformFeedbackPrimitivesWritten
|
||||
}
|
||||
}
|
8
src/Ryujinx.Graphics.GAL/DepthMode.cs
Normal file
8
src/Ryujinx.Graphics.GAL/DepthMode.cs
Normal file
@ -0,0 +1,8 @@
|
||||
namespace Ryujinx.Graphics.GAL
|
||||
{
|
||||
public enum DepthMode
|
||||
{
|
||||
MinusOneToOne,
|
||||
ZeroToOne
|
||||
}
|
||||
}
|
8
src/Ryujinx.Graphics.GAL/DepthStencilMode.cs
Normal file
8
src/Ryujinx.Graphics.GAL/DepthStencilMode.cs
Normal file
@ -0,0 +1,8 @@
|
||||
namespace Ryujinx.Graphics.GAL
|
||||
{
|
||||
public enum DepthStencilMode
|
||||
{
|
||||
Depth,
|
||||
Stencil
|
||||
}
|
||||
}
|
20
src/Ryujinx.Graphics.GAL/DepthTestDescriptor.cs
Normal file
20
src/Ryujinx.Graphics.GAL/DepthTestDescriptor.cs
Normal file
@ -0,0 +1,20 @@
|
||||
namespace Ryujinx.Graphics.GAL
|
||||
{
|
||||
public readonly 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;
|
||||
}
|
||||
}
|
||||
}
|
18
src/Ryujinx.Graphics.GAL/DeviceInfo.cs
Normal file
18
src/Ryujinx.Graphics.GAL/DeviceInfo.cs
Normal file
@ -0,0 +1,18 @@
|
||||
namespace Ryujinx.Graphics.GAL
|
||||
{
|
||||
public readonly struct DeviceInfo
|
||||
{
|
||||
public readonly string Id;
|
||||
public readonly string Vendor;
|
||||
public readonly string Name;
|
||||
public readonly bool IsDiscrete;
|
||||
|
||||
public DeviceInfo(string id, string vendor, string name, bool isDiscrete)
|
||||
{
|
||||
Id = id;
|
||||
Vendor = vendor;
|
||||
Name = name;
|
||||
IsDiscrete = isDiscrete;
|
||||
}
|
||||
}
|
||||
}
|
31
src/Ryujinx.Graphics.GAL/Extents2D.cs
Normal file
31
src/Ryujinx.Graphics.GAL/Extents2D.cs
Normal file
@ -0,0 +1,31 @@
|
||||
using Ryujinx.Common;
|
||||
|
||||
namespace Ryujinx.Graphics.GAL
|
||||
{
|
||||
public readonly 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;
|
||||
}
|
||||
|
||||
public Extents2D Reduce(int level)
|
||||
{
|
||||
int div = 1 << level;
|
||||
|
||||
return new Extents2D(
|
||||
X1 >> level,
|
||||
Y1 >> level,
|
||||
BitUtils.DivRoundUp(X2, div),
|
||||
BitUtils.DivRoundUp(Y2, div));
|
||||
}
|
||||
}
|
||||
}
|
18
src/Ryujinx.Graphics.GAL/Extents2DF.cs
Normal file
18
src/Ryujinx.Graphics.GAL/Extents2DF.cs
Normal file
@ -0,0 +1,18 @@
|
||||
namespace Ryujinx.Graphics.GAL
|
||||
{
|
||||
public readonly struct Extents2DF
|
||||
{
|
||||
public float X1 { get; }
|
||||
public float Y1 { get; }
|
||||
public float X2 { get; }
|
||||
public float Y2 { get; }
|
||||
|
||||
public Extents2DF(float x1, float y1, float x2, float y2)
|
||||
{
|
||||
X1 = x1;
|
||||
Y1 = y1;
|
||||
X2 = x2;
|
||||
Y2 = y2;
|
||||
}
|
||||
}
|
||||
}
|
9
src/Ryujinx.Graphics.GAL/Face.cs
Normal file
9
src/Ryujinx.Graphics.GAL/Face.cs
Normal file
@ -0,0 +1,9 @@
|
||||
namespace Ryujinx.Graphics.GAL
|
||||
{
|
||||
public enum Face
|
||||
{
|
||||
Front = 0x404,
|
||||
Back = 0x405,
|
||||
FrontAndBack = 0x408
|
||||
}
|
||||
}
|
667
src/Ryujinx.Graphics.GAL/Format.cs
Normal file
667
src/Ryujinx.Graphics.GAL/Format.cs
Normal file
@ -0,0 +1,667 @@
|
||||
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,
|
||||
S8UintD24Unorm,
|
||||
D32Float,
|
||||
D24UnormS8Uint,
|
||||
D32FloatS8Uint,
|
||||
R8G8B8A8Srgb,
|
||||
R4G4Unorm,
|
||||
R4G4B4A4Unorm,
|
||||
R5G5B5X1Unorm,
|
||||
R5G5B5A1Unorm,
|
||||
R5G6B5Unorm,
|
||||
R10G10B10A2Unorm,
|
||||
R10G10B10A2Uint,
|
||||
R11G11B10Float,
|
||||
R9G9B9E5Float,
|
||||
Bc1RgbaUnorm,
|
||||
Bc2Unorm,
|
||||
Bc3Unorm,
|
||||
Bc1RgbaSrgb,
|
||||
Bc2Srgb,
|
||||
Bc3Srgb,
|
||||
Bc4Unorm,
|
||||
Bc4Snorm,
|
||||
Bc5Unorm,
|
||||
Bc5Snorm,
|
||||
Bc7Unorm,
|
||||
Bc7Srgb,
|
||||
Bc6HSfloat,
|
||||
Bc6HUfloat,
|
||||
Etc2RgbUnorm,
|
||||
Etc2RgbaUnorm,
|
||||
Etc2RgbPtaUnorm,
|
||||
Etc2RgbSrgb,
|
||||
Etc2RgbaSrgb,
|
||||
Etc2RgbPtaSrgb,
|
||||
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,
|
||||
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,
|
||||
B5G5R5A1Unorm,
|
||||
A1B5G5R5Unorm,
|
||||
B8G8R8A8Unorm,
|
||||
B8G8R8A8Srgb
|
||||
}
|
||||
|
||||
public static class FormatExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// The largest scalar size for a buffer format.
|
||||
/// </summary>
|
||||
public const int MaxBufferFormatScalarSize = 4;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the byte size for a single component of this format, or its packed size.
|
||||
/// </summary>
|
||||
/// <param name="format">Texture format</param>
|
||||
/// <returns>Byte size for a single component, or packed size</returns>
|
||||
public static int GetScalarSize(this Format format)
|
||||
{
|
||||
switch (format)
|
||||
{
|
||||
case Format.R8Unorm:
|
||||
case Format.R8Snorm:
|
||||
case Format.R8Uint:
|
||||
case Format.R8Sint:
|
||||
case Format.R8G8Unorm:
|
||||
case Format.R8G8Snorm:
|
||||
case Format.R8G8Uint:
|
||||
case Format.R8G8Sint:
|
||||
case Format.R8G8B8Unorm:
|
||||
case Format.R8G8B8Snorm:
|
||||
case Format.R8G8B8Uint:
|
||||
case Format.R8G8B8Sint:
|
||||
case Format.R8G8B8A8Unorm:
|
||||
case Format.R8G8B8A8Snorm:
|
||||
case Format.R8G8B8A8Uint:
|
||||
case Format.R8G8B8A8Sint:
|
||||
case Format.R8G8B8A8Srgb:
|
||||
case Format.R4G4Unorm:
|
||||
case Format.R8Uscaled:
|
||||
case Format.R8Sscaled:
|
||||
case Format.R8G8Uscaled:
|
||||
case Format.R8G8Sscaled:
|
||||
case Format.R8G8B8Uscaled:
|
||||
case Format.R8G8B8Sscaled:
|
||||
case Format.R8G8B8A8Uscaled:
|
||||
case Format.R8G8B8A8Sscaled:
|
||||
case Format.B8G8R8A8Unorm:
|
||||
case Format.B8G8R8A8Srgb:
|
||||
return 1;
|
||||
|
||||
case Format.R16Float:
|
||||
case Format.R16Unorm:
|
||||
case Format.R16Snorm:
|
||||
case Format.R16Uint:
|
||||
case Format.R16Sint:
|
||||
case Format.R16G16Float:
|
||||
case Format.R16G16Unorm:
|
||||
case Format.R16G16Snorm:
|
||||
case Format.R16G16Uint:
|
||||
case Format.R16G16Sint:
|
||||
case Format.R16G16B16Float:
|
||||
case Format.R16G16B16Unorm:
|
||||
case Format.R16G16B16Snorm:
|
||||
case Format.R16G16B16Uint:
|
||||
case Format.R16G16B16Sint:
|
||||
case Format.R16G16B16A16Float:
|
||||
case Format.R16G16B16A16Unorm:
|
||||
case Format.R16G16B16A16Snorm:
|
||||
case Format.R16G16B16A16Uint:
|
||||
case Format.R16G16B16A16Sint:
|
||||
case Format.R4G4B4A4Unorm:
|
||||
case Format.R5G5B5X1Unorm:
|
||||
case Format.R5G5B5A1Unorm:
|
||||
case Format.R5G6B5Unorm:
|
||||
case Format.R16Uscaled:
|
||||
case Format.R16Sscaled:
|
||||
case Format.R16G16Uscaled:
|
||||
case Format.R16G16Sscaled:
|
||||
case Format.R16G16B16Uscaled:
|
||||
case Format.R16G16B16Sscaled:
|
||||
case Format.R16G16B16A16Uscaled:
|
||||
case Format.R16G16B16A16Sscaled:
|
||||
case Format.B5G6R5Unorm:
|
||||
case Format.B5G5R5A1Unorm:
|
||||
case Format.A1B5G5R5Unorm:
|
||||
return 2;
|
||||
|
||||
case Format.R32Float:
|
||||
case Format.R32Uint:
|
||||
case Format.R32Sint:
|
||||
case Format.R32G32Float:
|
||||
case Format.R32G32Uint:
|
||||
case Format.R32G32Sint:
|
||||
case Format.R32G32B32Float:
|
||||
case Format.R32G32B32Uint:
|
||||
case Format.R32G32B32Sint:
|
||||
case Format.R32G32B32A32Float:
|
||||
case Format.R32G32B32A32Uint:
|
||||
case Format.R32G32B32A32Sint:
|
||||
case Format.R10G10B10A2Unorm:
|
||||
case Format.R10G10B10A2Uint:
|
||||
case Format.R11G11B10Float:
|
||||
case Format.R9G9B9E5Float:
|
||||
case Format.R32Uscaled:
|
||||
case Format.R32Sscaled:
|
||||
case Format.R32G32Uscaled:
|
||||
case Format.R32G32Sscaled:
|
||||
case Format.R32G32B32Uscaled:
|
||||
case Format.R32G32B32Sscaled:
|
||||
case Format.R32G32B32A32Uscaled:
|
||||
case Format.R32G32B32A32Sscaled:
|
||||
case Format.R10G10B10A2Snorm:
|
||||
case Format.R10G10B10A2Sint:
|
||||
case Format.R10G10B10A2Uscaled:
|
||||
case Format.R10G10B10A2Sscaled:
|
||||
return 4;
|
||||
|
||||
case Format.S8Uint:
|
||||
return 1;
|
||||
case Format.D16Unorm:
|
||||
return 2;
|
||||
case Format.S8UintD24Unorm:
|
||||
case Format.D32Float:
|
||||
case Format.D24UnormS8Uint:
|
||||
return 4;
|
||||
case Format.D32FloatS8Uint:
|
||||
return 8;
|
||||
|
||||
case Format.Bc1RgbaUnorm:
|
||||
case Format.Bc1RgbaSrgb:
|
||||
return 8;
|
||||
|
||||
case Format.Bc2Unorm:
|
||||
case Format.Bc3Unorm:
|
||||
case Format.Bc2Srgb:
|
||||
case Format.Bc3Srgb:
|
||||
case Format.Bc4Unorm:
|
||||
case Format.Bc4Snorm:
|
||||
case Format.Bc5Unorm:
|
||||
case Format.Bc5Snorm:
|
||||
case Format.Bc7Unorm:
|
||||
case Format.Bc7Srgb:
|
||||
case Format.Bc6HSfloat:
|
||||
case Format.Bc6HUfloat:
|
||||
return 16;
|
||||
|
||||
case Format.Etc2RgbUnorm:
|
||||
case Format.Etc2RgbPtaUnorm:
|
||||
case Format.Etc2RgbSrgb:
|
||||
case Format.Etc2RgbPtaSrgb:
|
||||
return 8;
|
||||
|
||||
case Format.Etc2RgbaUnorm:
|
||||
case Format.Etc2RgbaSrgb:
|
||||
return 16;
|
||||
|
||||
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:
|
||||
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 16;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the texture format is valid to use as image format.
|
||||
/// </summary>
|
||||
/// <param name="format">Texture format</param>
|
||||
/// <returns>True if the texture can be used as image, false otherwise</returns>
|
||||
public static bool IsImageCompatible(this Format format)
|
||||
{
|
||||
switch (format)
|
||||
{
|
||||
case Format.R8Unorm:
|
||||
case Format.R8Snorm:
|
||||
case Format.R8Uint:
|
||||
case Format.R8Sint:
|
||||
case Format.R16Float:
|
||||
case Format.R16Unorm:
|
||||
case Format.R16Snorm:
|
||||
case Format.R16Uint:
|
||||
case Format.R16Sint:
|
||||
case Format.R32Float:
|
||||
case Format.R32Uint:
|
||||
case Format.R32Sint:
|
||||
case Format.R8G8Unorm:
|
||||
case Format.R8G8Snorm:
|
||||
case Format.R8G8Uint:
|
||||
case Format.R8G8Sint:
|
||||
case Format.R16G16Float:
|
||||
case Format.R16G16Unorm:
|
||||
case Format.R16G16Snorm:
|
||||
case Format.R16G16Uint:
|
||||
case Format.R16G16Sint:
|
||||
case Format.R32G32Float:
|
||||
case Format.R32G32Uint:
|
||||
case Format.R32G32Sint:
|
||||
case Format.R8G8B8A8Unorm:
|
||||
case Format.R8G8B8A8Snorm:
|
||||
case Format.R8G8B8A8Uint:
|
||||
case Format.R8G8B8A8Sint:
|
||||
case Format.R16G16B16A16Float:
|
||||
case Format.R16G16B16A16Unorm:
|
||||
case Format.R16G16B16A16Snorm:
|
||||
case Format.R16G16B16A16Uint:
|
||||
case Format.R16G16B16A16Sint:
|
||||
case Format.R32G32B32A32Float:
|
||||
case Format.R32G32B32A32Uint:
|
||||
case Format.R32G32B32A32Sint:
|
||||
case Format.R10G10B10A2Unorm:
|
||||
case Format.R10G10B10A2Uint:
|
||||
case Format.R11G11B10Float:
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the texture format is valid to use as render target color format.
|
||||
/// </summary>
|
||||
/// <param name="format">Texture format</param>
|
||||
/// <returns>True if the texture can be used as render target, false otherwise</returns>
|
||||
public static bool IsRtColorCompatible(this Format format)
|
||||
{
|
||||
switch (format)
|
||||
{
|
||||
case Format.R32G32B32A32Float:
|
||||
case Format.R32G32B32A32Sint:
|
||||
case Format.R32G32B32A32Uint:
|
||||
case Format.R16G16B16A16Unorm:
|
||||
case Format.R16G16B16A16Snorm:
|
||||
case Format.R16G16B16A16Sint:
|
||||
case Format.R16G16B16A16Uint:
|
||||
case Format.R16G16B16A16Float:
|
||||
case Format.R32G32Float:
|
||||
case Format.R32G32Sint:
|
||||
case Format.R32G32Uint:
|
||||
case Format.B8G8R8A8Unorm:
|
||||
case Format.B8G8R8A8Srgb:
|
||||
case Format.R10G10B10A2Unorm:
|
||||
case Format.R10G10B10A2Uint:
|
||||
case Format.R8G8B8A8Unorm:
|
||||
case Format.R8G8B8A8Srgb:
|
||||
case Format.R8G8B8A8Snorm:
|
||||
case Format.R8G8B8A8Sint:
|
||||
case Format.R8G8B8A8Uint:
|
||||
case Format.R16G16Unorm:
|
||||
case Format.R16G16Snorm:
|
||||
case Format.R16G16Sint:
|
||||
case Format.R16G16Uint:
|
||||
case Format.R16G16Float:
|
||||
case Format.R11G11B10Float:
|
||||
case Format.R32Sint:
|
||||
case Format.R32Uint:
|
||||
case Format.R32Float:
|
||||
case Format.B5G6R5Unorm:
|
||||
case Format.B5G5R5A1Unorm:
|
||||
case Format.R8G8Unorm:
|
||||
case Format.R8G8Snorm:
|
||||
case Format.R8G8Sint:
|
||||
case Format.R8G8Uint:
|
||||
case Format.R16Unorm:
|
||||
case Format.R16Snorm:
|
||||
case Format.R16Sint:
|
||||
case Format.R16Uint:
|
||||
case Format.R16Float:
|
||||
case Format.R8Unorm:
|
||||
case Format.R8Snorm:
|
||||
case Format.R8Sint:
|
||||
case Format.R8Uint:
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the texture format is 16 bit packed.
|
||||
/// </summary>
|
||||
/// <param name="format">Texture format</param>
|
||||
/// <returns>True if the texture format is 16 bit packed, false otherwise</returns>
|
||||
public static bool Is16BitPacked(this Format format)
|
||||
{
|
||||
switch (format)
|
||||
{
|
||||
case Format.B5G6R5Unorm:
|
||||
case Format.B5G5R5A1Unorm:
|
||||
case Format.R5G5B5X1Unorm:
|
||||
case Format.R5G5B5A1Unorm:
|
||||
case Format.R5G6B5Unorm:
|
||||
case Format.R4G4B4A4Unorm:
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the texture format is an ASTC format.
|
||||
/// </summary>
|
||||
/// <param name="format">Texture format</param>
|
||||
/// <returns>True if the texture format is an ASTC format, false otherwise</returns>
|
||||
public static bool IsAstc(this Format format)
|
||||
{
|
||||
return format.IsAstcUnorm() || format.IsAstcSrgb();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the texture format is an ASTC Unorm format.
|
||||
/// </summary>
|
||||
/// <param name="format">Texture format</param>
|
||||
/// <returns>True if the texture format is an ASTC Unorm format, false otherwise</returns>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the texture format is an ASTC SRGB format.
|
||||
/// </summary>
|
||||
/// <param name="format">Texture format</param>
|
||||
/// <returns>True if the texture format is an ASTC SRGB format, false otherwise</returns>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the texture format is an ETC2 format.
|
||||
/// </summary>
|
||||
/// <param name="format">Texture format</param>
|
||||
/// <returns>True if the texture format is an ETC2 format, false otherwise</returns>
|
||||
public static bool IsEtc2(this Format format)
|
||||
{
|
||||
switch (format)
|
||||
{
|
||||
case Format.Etc2RgbaSrgb:
|
||||
case Format.Etc2RgbaUnorm:
|
||||
case Format.Etc2RgbPtaSrgb:
|
||||
case Format.Etc2RgbPtaUnorm:
|
||||
case Format.Etc2RgbSrgb:
|
||||
case Format.Etc2RgbUnorm:
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the texture format is a BGR format.
|
||||
/// </summary>
|
||||
/// <param name="format">Texture format</param>
|
||||
/// <returns>True if the texture format is a BGR format, false otherwise</returns>
|
||||
public static bool IsBgr(this Format format)
|
||||
{
|
||||
switch (format)
|
||||
{
|
||||
case Format.B5G6R5Unorm:
|
||||
case Format.B5G5R5A1Unorm:
|
||||
case Format.B8G8R8A8Unorm:
|
||||
case Format.B8G8R8A8Srgb:
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the texture format is a depth, stencil or depth-stencil format.
|
||||
/// </summary>
|
||||
/// <param name="format">Texture format</param>
|
||||
/// <returns>True if the format is a depth, stencil or depth-stencil format, false otherwise</returns>
|
||||
public static bool IsDepthOrStencil(this Format format)
|
||||
{
|
||||
switch (format)
|
||||
{
|
||||
case Format.D16Unorm:
|
||||
case Format.D24UnormS8Uint:
|
||||
case Format.S8UintD24Unorm:
|
||||
case Format.D32Float:
|
||||
case Format.D32FloatS8Uint:
|
||||
case Format.S8Uint:
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the texture format is an unsigned integer color format.
|
||||
/// </summary>
|
||||
/// <param name="format">Texture format</param>
|
||||
/// <returns>True if the texture format is an unsigned integer color format, false otherwise</returns>
|
||||
public static bool IsUint(this Format format)
|
||||
{
|
||||
switch (format)
|
||||
{
|
||||
case Format.R8Uint:
|
||||
case Format.R16Uint:
|
||||
case Format.R32Uint:
|
||||
case Format.R8G8Uint:
|
||||
case Format.R16G16Uint:
|
||||
case Format.R32G32Uint:
|
||||
case Format.R8G8B8Uint:
|
||||
case Format.R16G16B16Uint:
|
||||
case Format.R32G32B32Uint:
|
||||
case Format.R8G8B8A8Uint:
|
||||
case Format.R16G16B16A16Uint:
|
||||
case Format.R32G32B32A32Uint:
|
||||
case Format.R10G10B10A2Uint:
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the texture format is a signed integer color format.
|
||||
/// </summary>
|
||||
/// <param name="format">Texture format</param>
|
||||
/// <returns>True if the texture format is a signed integer color format, false otherwise</returns>
|
||||
public static bool IsSint(this Format format)
|
||||
{
|
||||
switch (format)
|
||||
{
|
||||
case Format.R8Sint:
|
||||
case Format.R16Sint:
|
||||
case Format.R32Sint:
|
||||
case Format.R8G8Sint:
|
||||
case Format.R16G16Sint:
|
||||
case Format.R32G32Sint:
|
||||
case Format.R8G8B8Sint:
|
||||
case Format.R16G16B16Sint:
|
||||
case Format.R32G32B32Sint:
|
||||
case Format.R8G8B8A8Sint:
|
||||
case Format.R16G16B16A16Sint:
|
||||
case Format.R32G32B32A32Sint:
|
||||
case Format.R10G10B10A2Sint:
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the texture format is an integer color format.
|
||||
/// </summary>
|
||||
/// <param name="format">Texture format</param>
|
||||
/// <returns>True if the texture format is an integer color format, false otherwise</returns>
|
||||
public static bool IsInteger(this Format format)
|
||||
{
|
||||
return format.IsUint() || format.IsSint();
|
||||
}
|
||||
}
|
||||
}
|
8
src/Ryujinx.Graphics.GAL/FrontFace.cs
Normal file
8
src/Ryujinx.Graphics.GAL/FrontFace.cs
Normal file
@ -0,0 +1,8 @@
|
||||
namespace Ryujinx.Graphics.GAL
|
||||
{
|
||||
public enum FrontFace
|
||||
{
|
||||
Clockwise = 0x900,
|
||||
CounterClockwise = 0x901
|
||||
}
|
||||
}
|
14
src/Ryujinx.Graphics.GAL/HardwareInfo.cs
Normal file
14
src/Ryujinx.Graphics.GAL/HardwareInfo.cs
Normal file
@ -0,0 +1,14 @@
|
||||
namespace Ryujinx.Graphics.GAL
|
||||
{
|
||||
public readonly struct HardwareInfo
|
||||
{
|
||||
public string GpuVendor { get; }
|
||||
public string GpuModel { get; }
|
||||
|
||||
public HardwareInfo(string gpuVendor, string gpuModel)
|
||||
{
|
||||
GpuVendor = gpuVendor;
|
||||
GpuModel = gpuModel;
|
||||
}
|
||||
}
|
||||
}
|
13
src/Ryujinx.Graphics.GAL/ICounterEvent.cs
Normal file
13
src/Ryujinx.Graphics.GAL/ICounterEvent.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
|
||||
namespace Ryujinx.Graphics.GAL
|
||||
{
|
||||
public interface ICounterEvent : IDisposable
|
||||
{
|
||||
bool Invalid { get; set; }
|
||||
|
||||
bool ReserveForHostAccess();
|
||||
|
||||
void Flush();
|
||||
}
|
||||
}
|
113
src/Ryujinx.Graphics.GAL/IPipeline.cs
Normal file
113
src/Ryujinx.Graphics.GAL/IPipeline.cs
Normal file
@ -0,0 +1,113 @@
|
||||
using Ryujinx.Graphics.Shader;
|
||||
using System;
|
||||
|
||||
namespace Ryujinx.Graphics.GAL
|
||||
{
|
||||
public interface IPipeline
|
||||
{
|
||||
void Barrier();
|
||||
|
||||
void BeginTransformFeedback(PrimitiveTopology topology);
|
||||
|
||||
void ClearBuffer(BufferHandle destination, int offset, int size, uint value);
|
||||
|
||||
void ClearRenderTargetColor(int index, int layer, int layerCount, uint componentMask, ColorF color);
|
||||
|
||||
void ClearRenderTargetDepthStencil(
|
||||
int layer,
|
||||
int layerCount,
|
||||
float depthValue,
|
||||
bool depthMask,
|
||||
int stencilValue,
|
||||
int stencilMask);
|
||||
|
||||
void CommandBufferBarrier();
|
||||
|
||||
void CopyBuffer(BufferHandle source, BufferHandle destination, int srcOffset, int dstOffset, int size);
|
||||
|
||||
void DispatchCompute(int groupsX, int groupsY, int groupsZ);
|
||||
|
||||
void Draw(int vertexCount, int instanceCount, int firstVertex, int firstInstance);
|
||||
void DrawIndexed(
|
||||
int indexCount,
|
||||
int instanceCount,
|
||||
int firstIndex,
|
||||
int firstVertex,
|
||||
int firstInstance);
|
||||
void DrawIndexedIndirect(BufferRange indirectBuffer);
|
||||
void DrawIndexedIndirectCount(BufferRange indirectBuffer, BufferRange parameterBuffer, int maxDrawCount, int stride);
|
||||
void DrawIndirect(BufferRange indirectBuffer);
|
||||
void DrawIndirectCount(BufferRange indirectBuffer, BufferRange parameterBuffer, int maxDrawCount, int stride);
|
||||
void DrawTexture(ITexture texture, ISampler sampler, Extents2DF srcRegion, Extents2DF dstRegion);
|
||||
|
||||
void EndTransformFeedback();
|
||||
|
||||
void SetAlphaTest(bool enable, float reference, CompareOp op);
|
||||
|
||||
void SetBlendState(AdvancedBlendDescriptor blend);
|
||||
void SetBlendState(int index, BlendDescriptor blend);
|
||||
|
||||
void SetDepthBias(PolygonModeMask enables, float factor, float units, float clamp);
|
||||
void SetDepthClamp(bool clamp);
|
||||
void SetDepthMode(DepthMode mode);
|
||||
void SetDepthTest(DepthTestDescriptor depthTest);
|
||||
|
||||
void SetFaceCulling(bool enable, Face face);
|
||||
|
||||
void SetFrontFace(FrontFace frontFace);
|
||||
|
||||
void SetIndexBuffer(BufferRange buffer, IndexType type);
|
||||
|
||||
void SetImage(int binding, ITexture texture, Format imageFormat);
|
||||
|
||||
void SetLineParameters(float width, bool smooth);
|
||||
|
||||
void SetLogicOpState(bool enable, LogicalOp op);
|
||||
|
||||
void SetMultisampleState(MultisampleDescriptor multisample);
|
||||
|
||||
void SetPatchParameters(int vertices, ReadOnlySpan<float> defaultOuterLevel, ReadOnlySpan<float> defaultInnerLevel);
|
||||
void SetPointParameters(float size, bool isProgramPointSize, bool enablePointSprite, Origin origin);
|
||||
|
||||
void SetPolygonMode(PolygonMode frontMode, PolygonMode backMode);
|
||||
|
||||
void SetPrimitiveRestart(bool enable, int index);
|
||||
|
||||
void SetPrimitiveTopology(PrimitiveTopology topology);
|
||||
|
||||
void SetProgram(IProgram program);
|
||||
|
||||
void SetRasterizerDiscard(bool discard);
|
||||
|
||||
void SetRenderTargetScale(float scale);
|
||||
void SetRenderTargetColorMasks(ReadOnlySpan<uint> componentMask);
|
||||
void SetRenderTargets(ITexture[] colors, ITexture depthStencil);
|
||||
|
||||
void SetScissors(ReadOnlySpan<Rectangle<int>> regions);
|
||||
|
||||
void SetStencilTest(StencilTestDescriptor stencilTest);
|
||||
|
||||
void SetStorageBuffers(ReadOnlySpan<BufferAssignment> buffers);
|
||||
|
||||
void SetTextureAndSampler(ShaderStage stage, int binding, ITexture texture, ISampler sampler);
|
||||
|
||||
void SetTransformFeedbackBuffers(ReadOnlySpan<BufferRange> buffers);
|
||||
void SetUniformBuffers(ReadOnlySpan<BufferAssignment> buffers);
|
||||
|
||||
void SetUserClipDistance(int index, bool enableClip);
|
||||
|
||||
void SetVertexAttribs(ReadOnlySpan<VertexAttribDescriptor> vertexAttribs);
|
||||
void SetVertexBuffers(ReadOnlySpan<VertexBufferDescriptor> vertexBuffers);
|
||||
|
||||
void SetViewports(ReadOnlySpan<Viewport> viewports, bool disableTransform);
|
||||
|
||||
void TextureBarrier();
|
||||
void TextureBarrierTiled();
|
||||
|
||||
bool TryHostConditionalRendering(ICounterEvent value, ulong compare, bool isEqual);
|
||||
bool TryHostConditionalRendering(ICounterEvent value, ICounterEvent compare, bool isEqual);
|
||||
void EndHostConditionalRendering();
|
||||
|
||||
void UpdateRenderScale(ReadOnlySpan<float> scales, int totalCount, int fragmentCount);
|
||||
}
|
||||
}
|
11
src/Ryujinx.Graphics.GAL/IProgram.cs
Normal file
11
src/Ryujinx.Graphics.GAL/IProgram.cs
Normal file
@ -0,0 +1,11 @@
|
||||
using System;
|
||||
|
||||
namespace Ryujinx.Graphics.GAL
|
||||
{
|
||||
public interface IProgram : IDisposable
|
||||
{
|
||||
ProgramLinkStatus CheckProgramLink(bool blocking);
|
||||
|
||||
byte[] GetBinary();
|
||||
}
|
||||
}
|
65
src/Ryujinx.Graphics.GAL/IRenderer.cs
Normal file
65
src/Ryujinx.Graphics.GAL/IRenderer.cs
Normal file
@ -0,0 +1,65 @@
|
||||
using Ryujinx.Common.Configuration;
|
||||
using System;
|
||||
|
||||
namespace Ryujinx.Graphics.GAL
|
||||
{
|
||||
public interface IRenderer : IDisposable
|
||||
{
|
||||
event EventHandler<ScreenCaptureImageInfo> ScreenCaptured;
|
||||
|
||||
bool PreferThreading { get; }
|
||||
|
||||
IPipeline Pipeline { get; }
|
||||
|
||||
IWindow Window { get; }
|
||||
|
||||
void BackgroundContextAction(Action action, bool alwaysBackground = false);
|
||||
|
||||
BufferHandle CreateBuffer(int size, BufferHandle storageHint);
|
||||
|
||||
BufferHandle CreateBuffer(int size)
|
||||
{
|
||||
return CreateBuffer(size, BufferHandle.Null);
|
||||
}
|
||||
|
||||
IProgram CreateProgram(ShaderSource[] shaders, ShaderInfo info);
|
||||
|
||||
ISampler CreateSampler(SamplerCreateInfo info);
|
||||
ITexture CreateTexture(TextureCreateInfo info, float scale);
|
||||
|
||||
void CreateSync(ulong id, bool strict);
|
||||
|
||||
void DeleteBuffer(BufferHandle buffer);
|
||||
|
||||
PinnedSpan<byte> GetBufferData(BufferHandle buffer, int offset, int size);
|
||||
|
||||
Capabilities GetCapabilities();
|
||||
ulong GetCurrentSync();
|
||||
HardwareInfo GetHardwareInfo();
|
||||
|
||||
IProgram LoadProgramBinary(byte[] programBinary, bool hasFragmentShader, ShaderInfo info);
|
||||
|
||||
void SetBufferData(BufferHandle buffer, int offset, ReadOnlySpan<byte> data);
|
||||
|
||||
void UpdateCounters();
|
||||
|
||||
void PreFrame();
|
||||
|
||||
ICounterEvent ReportCounter(CounterType type, EventHandler<ulong> resultHandler, bool hostReserved);
|
||||
|
||||
void ResetCounter(CounterType type);
|
||||
|
||||
void RunLoop(Action gpuLoop)
|
||||
{
|
||||
gpuLoop();
|
||||
}
|
||||
|
||||
void WaitSync(ulong id);
|
||||
|
||||
void Initialize(GraphicsDebugLevel logLevel);
|
||||
|
||||
void SetInterruptAction(Action<Action> interruptAction);
|
||||
|
||||
void Screenshot();
|
||||
}
|
||||
}
|
6
src/Ryujinx.Graphics.GAL/ISampler.cs
Normal file
6
src/Ryujinx.Graphics.GAL/ISampler.cs
Normal file
@ -0,0 +1,6 @@
|
||||
using System;
|
||||
|
||||
namespace Ryujinx.Graphics.GAL
|
||||
{
|
||||
public interface ISampler : IDisposable { }
|
||||
}
|
27
src/Ryujinx.Graphics.GAL/ITexture.cs
Normal file
27
src/Ryujinx.Graphics.GAL/ITexture.cs
Normal file
@ -0,0 +1,27 @@
|
||||
using Ryujinx.Common.Memory;
|
||||
using System;
|
||||
|
||||
namespace Ryujinx.Graphics.GAL
|
||||
{
|
||||
public interface ITexture
|
||||
{
|
||||
int Width { get; }
|
||||
int Height { get; }
|
||||
float ScaleFactor { get; }
|
||||
|
||||
void CopyTo(ITexture destination, int firstLayer, int firstLevel);
|
||||
void CopyTo(ITexture destination, int srcLayer, int dstLayer, int srcLevel, int dstLevel);
|
||||
void CopyTo(ITexture destination, Extents2D srcRegion, Extents2D dstRegion, bool linearFilter);
|
||||
|
||||
ITexture CreateView(TextureCreateInfo info, int firstLayer, int firstLevel);
|
||||
|
||||
PinnedSpan<byte> GetData();
|
||||
PinnedSpan<byte> GetData(int layer, int level);
|
||||
|
||||
void SetData(SpanOrArray<byte> data);
|
||||
void SetData(SpanOrArray<byte> data, int layer, int level);
|
||||
void SetData(SpanOrArray<byte> data, int layer, int level, Rectangle<int> region);
|
||||
void SetStorage(BufferRange buffer);
|
||||
void Release();
|
||||
}
|
||||
}
|
17
src/Ryujinx.Graphics.GAL/IWindow.cs
Normal file
17
src/Ryujinx.Graphics.GAL/IWindow.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
|
||||
namespace Ryujinx.Graphics.GAL
|
||||
{
|
||||
public interface IWindow
|
||||
{
|
||||
void Present(ITexture texture, ImageCrop crop, Action swapBuffersCallback);
|
||||
|
||||
void SetSize(int width, int height);
|
||||
|
||||
void ChangeVSyncMode(bool vsyncEnabled);
|
||||
|
||||
void SetAntiAliasing(AntiAliasing antialiasing);
|
||||
void SetScalingFilter(ScalingFilter type);
|
||||
void SetScalingFilterLevel(float level);
|
||||
}
|
||||
}
|
37
src/Ryujinx.Graphics.GAL/ImageCrop.cs
Normal file
37
src/Ryujinx.Graphics.GAL/ImageCrop.cs
Normal file
@ -0,0 +1,37 @@
|
||||
namespace Ryujinx.Graphics.GAL
|
||||
{
|
||||
public readonly 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 bool IsStretched { get; }
|
||||
public float AspectRatioX { get; }
|
||||
public float AspectRatioY { get; }
|
||||
|
||||
public ImageCrop(
|
||||
int left,
|
||||
int right,
|
||||
int top,
|
||||
int bottom,
|
||||
bool flipX,
|
||||
bool flipY,
|
||||
bool isStretched,
|
||||
float aspectRatioX,
|
||||
float aspectRatioY)
|
||||
{
|
||||
Left = left;
|
||||
Right = right;
|
||||
Top = top;
|
||||
Bottom = bottom;
|
||||
FlipX = flipX;
|
||||
FlipY = flipY;
|
||||
IsStretched = isStretched;
|
||||
AspectRatioX = aspectRatioX;
|
||||
AspectRatioY = aspectRatioY;
|
||||
}
|
||||
}
|
||||
}
|
9
src/Ryujinx.Graphics.GAL/IndexType.cs
Normal file
9
src/Ryujinx.Graphics.GAL/IndexType.cs
Normal file
@ -0,0 +1,9 @@
|
||||
namespace Ryujinx.Graphics.GAL
|
||||
{
|
||||
public enum IndexType
|
||||
{
|
||||
UByte,
|
||||
UShort,
|
||||
UInt
|
||||
}
|
||||
}
|
22
src/Ryujinx.Graphics.GAL/LogicalOp.cs
Normal file
22
src/Ryujinx.Graphics.GAL/LogicalOp.cs
Normal file
@ -0,0 +1,22 @@
|
||||
namespace Ryujinx.Graphics.GAL
|
||||
{
|
||||
public enum LogicalOp
|
||||
{
|
||||
Clear = 0x1500,
|
||||
And = 0x1501,
|
||||
AndReverse = 0x1502,
|
||||
Copy = 0x1503,
|
||||
AndInverted = 0x1504,
|
||||
Noop = 0x1505,
|
||||
Xor = 0x1506,
|
||||
Or = 0x1507,
|
||||
Nor = 0x1508,
|
||||
Equiv = 0x1509,
|
||||
Invert = 0x150A,
|
||||
OrReverse = 0x150B,
|
||||
CopyInverted = 0x150C,
|
||||
OrInverted = 0x150D,
|
||||
Nand = 0x150E,
|
||||
Set = 0x150F
|
||||
}
|
||||
}
|
8
src/Ryujinx.Graphics.GAL/MagFilter.cs
Normal file
8
src/Ryujinx.Graphics.GAL/MagFilter.cs
Normal file
@ -0,0 +1,8 @@
|
||||
namespace Ryujinx.Graphics.GAL
|
||||
{
|
||||
public enum MagFilter
|
||||
{
|
||||
Nearest = 1,
|
||||
Linear
|
||||
}
|
||||
}
|
12
src/Ryujinx.Graphics.GAL/MinFilter.cs
Normal file
12
src/Ryujinx.Graphics.GAL/MinFilter.cs
Normal file
@ -0,0 +1,12 @@
|
||||
namespace Ryujinx.Graphics.GAL
|
||||
{
|
||||
public enum MinFilter
|
||||
{
|
||||
Nearest = 1,
|
||||
Linear,
|
||||
NearestMipmapNearest,
|
||||
LinearMipmapNearest,
|
||||
NearestMipmapLinear,
|
||||
LinearMipmapLinear
|
||||
}
|
||||
}
|
19
src/Ryujinx.Graphics.GAL/MultisampleDescriptor.cs
Normal file
19
src/Ryujinx.Graphics.GAL/MultisampleDescriptor.cs
Normal file
@ -0,0 +1,19 @@
|
||||
namespace Ryujinx.Graphics.GAL
|
||||
{
|
||||
public readonly struct MultisampleDescriptor
|
||||
{
|
||||
public bool AlphaToCoverageEnable { get; }
|
||||
public bool AlphaToCoverageDitherEnable { get; }
|
||||
public bool AlphaToOneEnable { get; }
|
||||
|
||||
public MultisampleDescriptor(
|
||||
bool alphaToCoverageEnable,
|
||||
bool alphaToCoverageDitherEnable,
|
||||
bool alphaToOneEnable)
|
||||
{
|
||||
AlphaToCoverageEnable = alphaToCoverageEnable;
|
||||
AlphaToCoverageDitherEnable = alphaToCoverageDitherEnable;
|
||||
AlphaToOneEnable = alphaToOneEnable;
|
||||
}
|
||||
}
|
||||
}
|
194
src/Ryujinx.Graphics.GAL/Multithreading/BufferMap.cs
Normal file
194
src/Ryujinx.Graphics.GAL/Multithreading/BufferMap.cs
Normal file
@ -0,0 +1,194 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Threading;
|
||||
|
||||
namespace Ryujinx.Graphics.GAL.Multithreading
|
||||
{
|
||||
/// <summary>
|
||||
/// Buffer handles given to the client are not the same as those provided by the backend,
|
||||
/// as their handle is created at a later point on the queue.
|
||||
/// The handle returned is a unique identifier that will map to the real buffer when it is available.
|
||||
/// Note that any uses within the queue should be safe, but outside you must use MapBufferBlocking.
|
||||
/// </summary>
|
||||
class BufferMap
|
||||
{
|
||||
private ulong _bufferHandle = 0;
|
||||
|
||||
private Dictionary<BufferHandle, BufferHandle> _bufferMap = new Dictionary<BufferHandle, BufferHandle>();
|
||||
private HashSet<BufferHandle> _inFlight = new HashSet<BufferHandle>();
|
||||
private AutoResetEvent _inFlightChanged = new AutoResetEvent(false);
|
||||
|
||||
internal BufferHandle CreateBufferHandle()
|
||||
{
|
||||
ulong handle64 = Interlocked.Increment(ref _bufferHandle);
|
||||
|
||||
BufferHandle threadedHandle = Unsafe.As<ulong, BufferHandle>(ref handle64);
|
||||
|
||||
lock (_inFlight)
|
||||
{
|
||||
_inFlight.Add(threadedHandle);
|
||||
}
|
||||
|
||||
return threadedHandle;
|
||||
}
|
||||
|
||||
internal void AssignBuffer(BufferHandle threadedHandle, BufferHandle realHandle)
|
||||
{
|
||||
lock (_bufferMap)
|
||||
{
|
||||
_bufferMap[threadedHandle] = realHandle;
|
||||
}
|
||||
|
||||
lock (_inFlight)
|
||||
{
|
||||
_inFlight.Remove(threadedHandle);
|
||||
}
|
||||
|
||||
_inFlightChanged.Set();
|
||||
}
|
||||
|
||||
internal void UnassignBuffer(BufferHandle threadedHandle)
|
||||
{
|
||||
lock (_bufferMap)
|
||||
{
|
||||
_bufferMap.Remove(threadedHandle);
|
||||
}
|
||||
}
|
||||
|
||||
internal BufferHandle MapBuffer(BufferHandle handle)
|
||||
{
|
||||
// Maps a threaded buffer to a backend one.
|
||||
// Threaded buffers are returned on creation as the buffer
|
||||
// isn't actually created until the queue runs the command.
|
||||
|
||||
BufferHandle result;
|
||||
|
||||
lock (_bufferMap)
|
||||
{
|
||||
if (!_bufferMap.TryGetValue(handle, out result))
|
||||
{
|
||||
result = BufferHandle.Null;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
internal BufferHandle MapBufferBlocking(BufferHandle handle)
|
||||
{
|
||||
// Blocks until the handle is available.
|
||||
|
||||
BufferHandle result;
|
||||
|
||||
lock (_bufferMap)
|
||||
{
|
||||
if (_bufferMap.TryGetValue(handle, out result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
bool signal = false;
|
||||
|
||||
while (true)
|
||||
{
|
||||
lock (_inFlight)
|
||||
{
|
||||
if (!_inFlight.Contains(handle))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
_inFlightChanged.WaitOne();
|
||||
signal = true;
|
||||
}
|
||||
|
||||
if (signal)
|
||||
{
|
||||
// Signal other threads which might still be waiting.
|
||||
_inFlightChanged.Set();
|
||||
}
|
||||
|
||||
return MapBuffer(handle);
|
||||
}
|
||||
|
||||
internal BufferRange MapBufferRange(BufferRange range)
|
||||
{
|
||||
return new BufferRange(MapBuffer(range.Handle), range.Offset, range.Size);
|
||||
}
|
||||
|
||||
internal Span<BufferRange> MapBufferRanges(Span<BufferRange> ranges)
|
||||
{
|
||||
// Rewrite the buffer ranges to point to the mapped handles.
|
||||
|
||||
lock (_bufferMap)
|
||||
{
|
||||
for (int i = 0; i < ranges.Length; i++)
|
||||
{
|
||||
ref BufferRange range = ref ranges[i];
|
||||
BufferHandle result;
|
||||
|
||||
if (!_bufferMap.TryGetValue(range.Handle, out result))
|
||||
{
|
||||
result = BufferHandle.Null;
|
||||
}
|
||||
|
||||
range = new BufferRange(result, range.Offset, range.Size);
|
||||
}
|
||||
}
|
||||
|
||||
return ranges;
|
||||
}
|
||||
|
||||
internal Span<BufferAssignment> MapBufferRanges(Span<BufferAssignment> ranges)
|
||||
{
|
||||
// Rewrite the buffer ranges to point to the mapped handles.
|
||||
|
||||
lock (_bufferMap)
|
||||
{
|
||||
for (int i = 0; i < ranges.Length; i++)
|
||||
{
|
||||
ref BufferAssignment assignment = ref ranges[i];
|
||||
BufferRange range = assignment.Range;
|
||||
BufferHandle result;
|
||||
|
||||
if (!_bufferMap.TryGetValue(range.Handle, out result))
|
||||
{
|
||||
result = BufferHandle.Null;
|
||||
}
|
||||
|
||||
assignment = new BufferAssignment(ranges[i].Binding, new BufferRange(result, range.Offset, range.Size));
|
||||
}
|
||||
}
|
||||
|
||||
return ranges;
|
||||
}
|
||||
|
||||
internal Span<VertexBufferDescriptor> MapBufferRanges(Span<VertexBufferDescriptor> ranges)
|
||||
{
|
||||
// Rewrite the buffer ranges to point to the mapped handles.
|
||||
|
||||
lock (_bufferMap)
|
||||
{
|
||||
for (int i = 0; i < ranges.Length; i++)
|
||||
{
|
||||
BufferRange range = ranges[i].Buffer;
|
||||
BufferHandle result;
|
||||
|
||||
if (!_bufferMap.TryGetValue(range.Handle, out result))
|
||||
{
|
||||
result = BufferHandle.Null;
|
||||
}
|
||||
|
||||
range = new BufferRange(result, range.Offset, range.Size);
|
||||
|
||||
ranges[i] = new VertexBufferDescriptor(range, ranges[i].Stride, ranges[i].Divisor);
|
||||
}
|
||||
}
|
||||
|
||||
return ranges;
|
||||
}
|
||||
}
|
||||
}
|
149
src/Ryujinx.Graphics.GAL/Multithreading/CommandHelper.cs
Normal file
149
src/Ryujinx.Graphics.GAL/Multithreading/CommandHelper.cs
Normal file
@ -0,0 +1,149 @@
|
||||
using Ryujinx.Graphics.GAL.Multithreading.Commands;
|
||||
using Ryujinx.Graphics.GAL.Multithreading.Commands.Buffer;
|
||||
using Ryujinx.Graphics.GAL.Multithreading.Commands.CounterEvent;
|
||||
using Ryujinx.Graphics.GAL.Multithreading.Commands.Program;
|
||||
using Ryujinx.Graphics.GAL.Multithreading.Commands.Renderer;
|
||||
using Ryujinx.Graphics.GAL.Multithreading.Commands.Sampler;
|
||||
using Ryujinx.Graphics.GAL.Multithreading.Commands.Texture;
|
||||
using Ryujinx.Graphics.GAL.Multithreading.Commands.Window;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Ryujinx.Graphics.GAL.Multithreading
|
||||
{
|
||||
static class CommandHelper
|
||||
{
|
||||
private delegate void CommandDelegate(Span<byte> memory, ThreadedRenderer threaded, IRenderer renderer);
|
||||
|
||||
private static int _totalCommands = (int)Enum.GetValues<CommandType>().Max() + 1;
|
||||
private static CommandDelegate[] _lookup = new CommandDelegate[_totalCommands];
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private static ref T GetCommand<T>(Span<byte> memory)
|
||||
{
|
||||
return ref Unsafe.As<byte, T>(ref MemoryMarshal.GetReference(memory));
|
||||
}
|
||||
|
||||
public static int GetMaxCommandSize()
|
||||
{
|
||||
return InitLookup() + 1; // 1 byte reserved for command size.
|
||||
}
|
||||
|
||||
private static int InitLookup()
|
||||
{
|
||||
int maxCommandSize = 0;
|
||||
|
||||
void Register<T>(CommandType commandType) where T : unmanaged, IGALCommand, IGALCommand<T>
|
||||
{
|
||||
maxCommandSize = Math.Max(maxCommandSize, Unsafe.SizeOf<T>());
|
||||
_lookup[(int)commandType] = (memory, threaded, renderer) => T.Run(ref GetCommand<T>(memory), threaded, renderer);
|
||||
}
|
||||
|
||||
Register<ActionCommand>(CommandType.Action);
|
||||
Register<CreateBufferCommand>(CommandType.CreateBuffer);
|
||||
Register<CreateProgramCommand>(CommandType.CreateProgram);
|
||||
Register<CreateSamplerCommand>(CommandType.CreateSampler);
|
||||
Register<CreateSyncCommand>(CommandType.CreateSync);
|
||||
Register<CreateTextureCommand>(CommandType.CreateTexture);
|
||||
Register<GetCapabilitiesCommand>(CommandType.GetCapabilities);
|
||||
Register<PreFrameCommand>(CommandType.PreFrame);
|
||||
Register<ReportCounterCommand>(CommandType.ReportCounter);
|
||||
Register<ResetCounterCommand>(CommandType.ResetCounter);
|
||||
Register<UpdateCountersCommand>(CommandType.UpdateCounters);
|
||||
|
||||
Register<BufferDisposeCommand>(CommandType.BufferDispose);
|
||||
Register<BufferGetDataCommand>(CommandType.BufferGetData);
|
||||
Register<BufferSetDataCommand>(CommandType.BufferSetData);
|
||||
|
||||
Register<CounterEventDisposeCommand>(CommandType.CounterEventDispose);
|
||||
Register<CounterEventFlushCommand>(CommandType.CounterEventFlush);
|
||||
|
||||
Register<ProgramDisposeCommand>(CommandType.ProgramDispose);
|
||||
Register<ProgramGetBinaryCommand>(CommandType.ProgramGetBinary);
|
||||
Register<ProgramCheckLinkCommand>(CommandType.ProgramCheckLink);
|
||||
|
||||
Register<SamplerDisposeCommand>(CommandType.SamplerDispose);
|
||||
|
||||
Register<TextureCopyToCommand>(CommandType.TextureCopyTo);
|
||||
Register<TextureCopyToScaledCommand>(CommandType.TextureCopyToScaled);
|
||||
Register<TextureCopyToSliceCommand>(CommandType.TextureCopyToSlice);
|
||||
Register<TextureCreateViewCommand>(CommandType.TextureCreateView);
|
||||
Register<TextureGetDataCommand>(CommandType.TextureGetData);
|
||||
Register<TextureGetDataSliceCommand>(CommandType.TextureGetDataSlice);
|
||||
Register<TextureReleaseCommand>(CommandType.TextureRelease);
|
||||
Register<TextureSetDataCommand>(CommandType.TextureSetData);
|
||||
Register<TextureSetDataSliceCommand>(CommandType.TextureSetDataSlice);
|
||||
Register<TextureSetDataSliceRegionCommand>(CommandType.TextureSetDataSliceRegion);
|
||||
Register<TextureSetStorageCommand>(CommandType.TextureSetStorage);
|
||||
|
||||
Register<WindowPresentCommand>(CommandType.WindowPresent);
|
||||
|
||||
Register<BarrierCommand>(CommandType.Barrier);
|
||||
Register<BeginTransformFeedbackCommand>(CommandType.BeginTransformFeedback);
|
||||
Register<ClearBufferCommand>(CommandType.ClearBuffer);
|
||||
Register<ClearRenderTargetColorCommand>(CommandType.ClearRenderTargetColor);
|
||||
Register<ClearRenderTargetDepthStencilCommand>(CommandType.ClearRenderTargetDepthStencil);
|
||||
Register<CommandBufferBarrierCommand>(CommandType.CommandBufferBarrier);
|
||||
Register<CopyBufferCommand>(CommandType.CopyBuffer);
|
||||
Register<DispatchComputeCommand>(CommandType.DispatchCompute);
|
||||
Register<DrawCommand>(CommandType.Draw);
|
||||
Register<DrawIndexedCommand>(CommandType.DrawIndexed);
|
||||
Register<DrawIndexedIndirectCommand>(CommandType.DrawIndexedIndirect);
|
||||
Register<DrawIndexedIndirectCountCommand>(CommandType.DrawIndexedIndirectCount);
|
||||
Register<DrawIndirectCommand>(CommandType.DrawIndirect);
|
||||
Register<DrawIndirectCountCommand>(CommandType.DrawIndirectCount);
|
||||
Register<DrawTextureCommand>(CommandType.DrawTexture);
|
||||
Register<EndHostConditionalRenderingCommand>(CommandType.EndHostConditionalRendering);
|
||||
Register<EndTransformFeedbackCommand>(CommandType.EndTransformFeedback);
|
||||
Register<SetAlphaTestCommand>(CommandType.SetAlphaTest);
|
||||
Register<SetBlendStateAdvancedCommand>(CommandType.SetBlendStateAdvanced);
|
||||
Register<SetBlendStateCommand>(CommandType.SetBlendState);
|
||||
Register<SetDepthBiasCommand>(CommandType.SetDepthBias);
|
||||
Register<SetDepthClampCommand>(CommandType.SetDepthClamp);
|
||||
Register<SetDepthModeCommand>(CommandType.SetDepthMode);
|
||||
Register<SetDepthTestCommand>(CommandType.SetDepthTest);
|
||||
Register<SetFaceCullingCommand>(CommandType.SetFaceCulling);
|
||||
Register<SetFrontFaceCommand>(CommandType.SetFrontFace);
|
||||
Register<SetStorageBuffersCommand>(CommandType.SetStorageBuffers);
|
||||
Register<SetTransformFeedbackBuffersCommand>(CommandType.SetTransformFeedbackBuffers);
|
||||
Register<SetUniformBuffersCommand>(CommandType.SetUniformBuffers);
|
||||
Register<SetImageCommand>(CommandType.SetImage);
|
||||
Register<SetIndexBufferCommand>(CommandType.SetIndexBuffer);
|
||||
Register<SetLineParametersCommand>(CommandType.SetLineParameters);
|
||||
Register<SetLogicOpStateCommand>(CommandType.SetLogicOpState);
|
||||
Register<SetMultisampleStateCommand>(CommandType.SetMultisampleState);
|
||||
Register<SetPatchParametersCommand>(CommandType.SetPatchParameters);
|
||||
Register<SetPointParametersCommand>(CommandType.SetPointParameters);
|
||||
Register<SetPolygonModeCommand>(CommandType.SetPolygonMode);
|
||||
Register<SetPrimitiveRestartCommand>(CommandType.SetPrimitiveRestart);
|
||||
Register<SetPrimitiveTopologyCommand>(CommandType.SetPrimitiveTopology);
|
||||
Register<SetProgramCommand>(CommandType.SetProgram);
|
||||
Register<SetRasterizerDiscardCommand>(CommandType.SetRasterizerDiscard);
|
||||
Register<SetRenderTargetColorMasksCommand>(CommandType.SetRenderTargetColorMasks);
|
||||
Register<SetRenderTargetScaleCommand>(CommandType.SetRenderTargetScale);
|
||||
Register<SetRenderTargetsCommand>(CommandType.SetRenderTargets);
|
||||
Register<SetScissorsCommand>(CommandType.SetScissor);
|
||||
Register<SetStencilTestCommand>(CommandType.SetStencilTest);
|
||||
Register<SetTextureAndSamplerCommand>(CommandType.SetTextureAndSampler);
|
||||
Register<SetUserClipDistanceCommand>(CommandType.SetUserClipDistance);
|
||||
Register<SetVertexAttribsCommand>(CommandType.SetVertexAttribs);
|
||||
Register<SetVertexBuffersCommand>(CommandType.SetVertexBuffers);
|
||||
Register<SetViewportsCommand>(CommandType.SetViewports);
|
||||
Register<TextureBarrierCommand>(CommandType.TextureBarrier);
|
||||
Register<TextureBarrierTiledCommand>(CommandType.TextureBarrierTiled);
|
||||
Register<TryHostConditionalRenderingCommand>(CommandType.TryHostConditionalRendering);
|
||||
Register<TryHostConditionalRenderingFlushCommand>(CommandType.TryHostConditionalRenderingFlush);
|
||||
Register<UpdateRenderScaleCommand>(CommandType.UpdateRenderScale);
|
||||
|
||||
return maxCommandSize;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void RunCommand(Span<byte> memory, ThreadedRenderer threaded, IRenderer renderer)
|
||||
{
|
||||
_lookup[memory[memory.Length - 1]](memory, threaded, renderer);
|
||||
}
|
||||
}
|
||||
}
|
102
src/Ryujinx.Graphics.GAL/Multithreading/CommandType.cs
Normal file
102
src/Ryujinx.Graphics.GAL/Multithreading/CommandType.cs
Normal file
@ -0,0 +1,102 @@
|
||||
namespace Ryujinx.Graphics.GAL.Multithreading
|
||||
{
|
||||
enum CommandType : byte
|
||||
{
|
||||
Action,
|
||||
CreateBuffer,
|
||||
CreateProgram,
|
||||
CreateSampler,
|
||||
CreateSync,
|
||||
CreateTexture,
|
||||
GetCapabilities,
|
||||
Unused,
|
||||
PreFrame,
|
||||
ReportCounter,
|
||||
ResetCounter,
|
||||
UpdateCounters,
|
||||
|
||||
BufferDispose,
|
||||
BufferGetData,
|
||||
BufferSetData,
|
||||
|
||||
CounterEventDispose,
|
||||
CounterEventFlush,
|
||||
|
||||
ProgramDispose,
|
||||
ProgramGetBinary,
|
||||
ProgramCheckLink,
|
||||
|
||||
SamplerDispose,
|
||||
|
||||
TextureCopyTo,
|
||||
TextureCopyToScaled,
|
||||
TextureCopyToSlice,
|
||||
TextureCreateView,
|
||||
TextureGetData,
|
||||
TextureGetDataSlice,
|
||||
TextureRelease,
|
||||
TextureSetData,
|
||||
TextureSetDataSlice,
|
||||
TextureSetDataSliceRegion,
|
||||
TextureSetStorage,
|
||||
|
||||
WindowPresent,
|
||||
|
||||
Barrier,
|
||||
BeginTransformFeedback,
|
||||
ClearBuffer,
|
||||
ClearRenderTargetColor,
|
||||
ClearRenderTargetDepthStencil,
|
||||
CommandBufferBarrier,
|
||||
CopyBuffer,
|
||||
DispatchCompute,
|
||||
Draw,
|
||||
DrawIndexed,
|
||||
DrawIndexedIndirect,
|
||||
DrawIndexedIndirectCount,
|
||||
DrawIndirect,
|
||||
DrawIndirectCount,
|
||||
DrawTexture,
|
||||
EndHostConditionalRendering,
|
||||
EndTransformFeedback,
|
||||
SetAlphaTest,
|
||||
SetBlendStateAdvanced,
|
||||
SetBlendState,
|
||||
SetDepthBias,
|
||||
SetDepthClamp,
|
||||
SetDepthMode,
|
||||
SetDepthTest,
|
||||
SetFaceCulling,
|
||||
SetFrontFace,
|
||||
SetStorageBuffers,
|
||||
SetTransformFeedbackBuffers,
|
||||
SetUniformBuffers,
|
||||
SetImage,
|
||||
SetIndexBuffer,
|
||||
SetLineParameters,
|
||||
SetLogicOpState,
|
||||
SetMultisampleState,
|
||||
SetPatchParameters,
|
||||
SetPointParameters,
|
||||
SetPolygonMode,
|
||||
SetPrimitiveRestart,
|
||||
SetPrimitiveTopology,
|
||||
SetProgram,
|
||||
SetRasterizerDiscard,
|
||||
SetRenderTargetColorMasks,
|
||||
SetRenderTargetScale,
|
||||
SetRenderTargets,
|
||||
SetScissor,
|
||||
SetStencilTest,
|
||||
SetTextureAndSampler,
|
||||
SetUserClipDistance,
|
||||
SetVertexAttribs,
|
||||
SetVertexBuffers,
|
||||
SetViewports,
|
||||
TextureBarrier,
|
||||
TextureBarrierTiled,
|
||||
TryHostConditionalRendering,
|
||||
TryHostConditionalRenderingFlush,
|
||||
UpdateRenderScale
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
namespace Ryujinx.Graphics.GAL.Multithreading.Commands
|
||||
{
|
||||
struct BarrierCommand : IGALCommand, IGALCommand<BarrierCommand>
|
||||
{
|
||||
public CommandType CommandType => CommandType.Barrier;
|
||||
|
||||
public static void Run(ref BarrierCommand command, ThreadedRenderer threaded, IRenderer renderer)
|
||||
{
|
||||
renderer.Pipeline.Barrier();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
namespace Ryujinx.Graphics.GAL.Multithreading.Commands
|
||||
{
|
||||
struct BeginTransformFeedbackCommand : IGALCommand, IGALCommand<BeginTransformFeedbackCommand>
|
||||
{
|
||||
public CommandType CommandType => CommandType.BeginTransformFeedback;
|
||||
private PrimitiveTopology _topology;
|
||||
|
||||
public void Set(PrimitiveTopology topology)
|
||||
{
|
||||
_topology = topology;
|
||||
}
|
||||
|
||||
public static void Run(ref BeginTransformFeedbackCommand command, ThreadedRenderer threaded, IRenderer renderer)
|
||||
{
|
||||
renderer.Pipeline.BeginTransformFeedback(command._topology);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
namespace Ryujinx.Graphics.GAL.Multithreading.Commands.Buffer
|
||||
{
|
||||
struct BufferDisposeCommand : IGALCommand, IGALCommand<BufferDisposeCommand>
|
||||
{
|
||||
public CommandType CommandType => CommandType.BufferDispose;
|
||||
private BufferHandle _buffer;
|
||||
|
||||
public void Set(BufferHandle buffer)
|
||||
{
|
||||
_buffer = buffer;
|
||||
}
|
||||
|
||||
public static void Run(ref BufferDisposeCommand command, ThreadedRenderer threaded, IRenderer renderer)
|
||||
{
|
||||
renderer.DeleteBuffer(threaded.Buffers.MapBuffer(command._buffer));
|
||||
threaded.Buffers.UnassignBuffer(command._buffer);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
using Ryujinx.Graphics.GAL.Multithreading.Model;
|
||||
using System;
|
||||
|
||||
namespace Ryujinx.Graphics.GAL.Multithreading.Commands.Buffer
|
||||
{
|
||||
struct BufferGetDataCommand : IGALCommand, IGALCommand<BufferGetDataCommand>
|
||||
{
|
||||
public CommandType CommandType => CommandType.BufferGetData;
|
||||
private BufferHandle _buffer;
|
||||
private int _offset;
|
||||
private int _size;
|
||||
private TableRef<ResultBox<PinnedSpan<byte>>> _result;
|
||||
|
||||
public void Set(BufferHandle buffer, int offset, int size, TableRef<ResultBox<PinnedSpan<byte>>> result)
|
||||
{
|
||||
_buffer = buffer;
|
||||
_offset = offset;
|
||||
_size = size;
|
||||
_result = result;
|
||||
}
|
||||
|
||||
public static void Run(ref BufferGetDataCommand command, ThreadedRenderer threaded, IRenderer renderer)
|
||||
{
|
||||
PinnedSpan<byte> result = renderer.GetBufferData(threaded.Buffers.MapBuffer(command._buffer), command._offset, command._size);
|
||||
|
||||
command._result.Get(threaded).Result = result;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
using Ryujinx.Graphics.GAL.Multithreading.Model;
|
||||
using System;
|
||||
|
||||
namespace Ryujinx.Graphics.GAL.Multithreading.Commands.Buffer
|
||||
{
|
||||
struct BufferSetDataCommand : IGALCommand, IGALCommand<BufferSetDataCommand>
|
||||
{
|
||||
public CommandType CommandType => CommandType.BufferSetData;
|
||||
private BufferHandle _buffer;
|
||||
private int _offset;
|
||||
private SpanRef<byte> _data;
|
||||
|
||||
public void Set(BufferHandle buffer, int offset, SpanRef<byte> data)
|
||||
{
|
||||
_buffer = buffer;
|
||||
_offset = offset;
|
||||
_data = data;
|
||||
}
|
||||
|
||||
public static void Run(ref BufferSetDataCommand command, ThreadedRenderer threaded, IRenderer renderer)
|
||||
{
|
||||
ReadOnlySpan<byte> data = command._data.Get(threaded);
|
||||
renderer.SetBufferData(threaded.Buffers.MapBuffer(command._buffer), command._offset, data);
|
||||
command._data.Dispose(threaded);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
namespace Ryujinx.Graphics.GAL.Multithreading.Commands
|
||||
{
|
||||
struct ClearBufferCommand : IGALCommand, IGALCommand<ClearBufferCommand>
|
||||
{
|
||||
public CommandType CommandType => CommandType.ClearBuffer;
|
||||
private BufferHandle _destination;
|
||||
private int _offset;
|
||||
private int _size;
|
||||
private uint _value;
|
||||
|
||||
public void Set(BufferHandle destination, int offset, int size, uint value)
|
||||
{
|
||||
_destination = destination;
|
||||
_offset = offset;
|
||||
_size = size;
|
||||
_value = value;
|
||||
}
|
||||
|
||||
public static void Run(ref ClearBufferCommand command, ThreadedRenderer threaded, IRenderer renderer)
|
||||
{
|
||||
renderer.Pipeline.ClearBuffer(threaded.Buffers.MapBuffer(command._destination), command._offset, command._size, command._value);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
namespace Ryujinx.Graphics.GAL.Multithreading.Commands
|
||||
{
|
||||
struct ClearRenderTargetColorCommand : IGALCommand, IGALCommand<ClearRenderTargetColorCommand>
|
||||
{
|
||||
public CommandType CommandType => CommandType.ClearRenderTargetColor;
|
||||
private int _index;
|
||||
private int _layer;
|
||||
private int _layerCount;
|
||||
private uint _componentMask;
|
||||
private ColorF _color;
|
||||
|
||||
public void Set(int index, int layer, int layerCount, uint componentMask, ColorF color)
|
||||
{
|
||||
_index = index;
|
||||
_layer = layer;
|
||||
_layerCount = layerCount;
|
||||
_componentMask = componentMask;
|
||||
_color = color;
|
||||
}
|
||||
|
||||
public static void Run(ref ClearRenderTargetColorCommand command, ThreadedRenderer threaded, IRenderer renderer)
|
||||
{
|
||||
renderer.Pipeline.ClearRenderTargetColor(command._index, command._layer, command._layerCount, command._componentMask, command._color);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
namespace Ryujinx.Graphics.GAL.Multithreading.Commands
|
||||
{
|
||||
struct ClearRenderTargetDepthStencilCommand : IGALCommand, IGALCommand<ClearRenderTargetDepthStencilCommand>
|
||||
{
|
||||
public CommandType CommandType => CommandType.ClearRenderTargetDepthStencil;
|
||||
private int _layer;
|
||||
private int _layerCount;
|
||||
private float _depthValue;
|
||||
private bool _depthMask;
|
||||
private int _stencilValue;
|
||||
private int _stencilMask;
|
||||
|
||||
public void Set(int layer, int layerCount, float depthValue, bool depthMask, int stencilValue, int stencilMask)
|
||||
{
|
||||
_layer = layer;
|
||||
_layerCount = layerCount;
|
||||
_depthValue = depthValue;
|
||||
_depthMask = depthMask;
|
||||
_stencilValue = stencilValue;
|
||||
_stencilMask = stencilMask;
|
||||
}
|
||||
|
||||
public static void Run(ref ClearRenderTargetDepthStencilCommand command, ThreadedRenderer threaded, IRenderer renderer)
|
||||
{
|
||||
renderer.Pipeline.ClearRenderTargetDepthStencil(command._layer, command._layerCount, command._depthValue, command._depthMask, command._stencilValue, command._stencilMask);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
namespace Ryujinx.Graphics.GAL.Multithreading.Commands
|
||||
{
|
||||
struct CommandBufferBarrierCommand : IGALCommand, IGALCommand<CommandBufferBarrierCommand>
|
||||
{
|
||||
public CommandType CommandType => CommandType.CommandBufferBarrier;
|
||||
|
||||
public static void Run(ref CommandBufferBarrierCommand command, ThreadedRenderer threaded, IRenderer renderer)
|
||||
{
|
||||
renderer.Pipeline.CommandBufferBarrier();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
namespace Ryujinx.Graphics.GAL.Multithreading.Commands
|
||||
{
|
||||
struct CopyBufferCommand : IGALCommand, IGALCommand<CopyBufferCommand>
|
||||
{
|
||||
public CommandType CommandType => CommandType.CopyBuffer;
|
||||
private BufferHandle _source;
|
||||
private BufferHandle _destination;
|
||||
private int _srcOffset;
|
||||
private int _dstOffset;
|
||||
private int _size;
|
||||
|
||||
public void Set(BufferHandle source, BufferHandle destination, int srcOffset, int dstOffset, int size)
|
||||
{
|
||||
_source = source;
|
||||
_destination = destination;
|
||||
_srcOffset = srcOffset;
|
||||
_dstOffset = dstOffset;
|
||||
_size = size;
|
||||
}
|
||||
|
||||
public static void Run(ref CopyBufferCommand command, ThreadedRenderer threaded, IRenderer renderer)
|
||||
{
|
||||
renderer.Pipeline.CopyBuffer(threaded.Buffers.MapBuffer(command._source), threaded.Buffers.MapBuffer(command._destination), command._srcOffset, command._dstOffset, command._size);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
using Ryujinx.Graphics.GAL.Multithreading.Model;
|
||||
using Ryujinx.Graphics.GAL.Multithreading.Resources;
|
||||
|
||||
namespace Ryujinx.Graphics.GAL.Multithreading.Commands.CounterEvent
|
||||
{
|
||||
struct CounterEventDisposeCommand : IGALCommand, IGALCommand<CounterEventDisposeCommand>
|
||||
{
|
||||
public CommandType CommandType => CommandType.CounterEventDispose;
|
||||
private TableRef<ThreadedCounterEvent> _event;
|
||||
|
||||
public void Set(TableRef<ThreadedCounterEvent> evt)
|
||||
{
|
||||
_event = evt;
|
||||
}
|
||||
|
||||
public static void Run(ref CounterEventDisposeCommand command, ThreadedRenderer threaded, IRenderer renderer)
|
||||
{
|
||||
command._event.Get(threaded).Base.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
using Ryujinx.Graphics.GAL.Multithreading.Model;
|
||||
using Ryujinx.Graphics.GAL.Multithreading.Resources;
|
||||
|
||||
namespace Ryujinx.Graphics.GAL.Multithreading.Commands.CounterEvent
|
||||
{
|
||||
struct CounterEventFlushCommand : IGALCommand, IGALCommand<CounterEventFlushCommand>
|
||||
{
|
||||
public CommandType CommandType => CommandType.CounterEventFlush;
|
||||
private TableRef<ThreadedCounterEvent> _event;
|
||||
|
||||
public void Set(TableRef<ThreadedCounterEvent> evt)
|
||||
{
|
||||
_event = evt;
|
||||
}
|
||||
|
||||
public static void Run(ref CounterEventFlushCommand command, ThreadedRenderer threaded, IRenderer renderer)
|
||||
{
|
||||
command._event.Get(threaded).Base.Flush();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
namespace Ryujinx.Graphics.GAL.Multithreading.Commands
|
||||
{
|
||||
struct DispatchComputeCommand : IGALCommand, IGALCommand<DispatchComputeCommand>
|
||||
{
|
||||
public CommandType CommandType => CommandType.DispatchCompute;
|
||||
private int _groupsX;
|
||||
private int _groupsY;
|
||||
private int _groupsZ;
|
||||
|
||||
public void Set(int groupsX, int groupsY, int groupsZ)
|
||||
{
|
||||
_groupsX = groupsX;
|
||||
_groupsY = groupsY;
|
||||
_groupsZ = groupsZ;
|
||||
}
|
||||
|
||||
public static void Run(ref DispatchComputeCommand command, ThreadedRenderer threaded, IRenderer renderer)
|
||||
{
|
||||
renderer.Pipeline.DispatchCompute(command._groupsX, command._groupsY, command._groupsZ);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
namespace Ryujinx.Graphics.GAL.Multithreading.Commands
|
||||
{
|
||||
struct DrawIndexedCommand : IGALCommand, IGALCommand<DrawIndexedCommand>
|
||||
{
|
||||
public CommandType CommandType => CommandType.DrawIndexed;
|
||||
private int _indexCount;
|
||||
private int _instanceCount;
|
||||
private int _firstIndex;
|
||||
private int _firstVertex;
|
||||
private int _firstInstance;
|
||||
|
||||
public void Set(int indexCount, int instanceCount, int firstIndex, int firstVertex, int firstInstance)
|
||||
{
|
||||
_indexCount = indexCount;
|
||||
_instanceCount = instanceCount;
|
||||
_firstIndex = firstIndex;
|
||||
_firstVertex = firstVertex;
|
||||
_firstInstance = firstInstance;
|
||||
}
|
||||
|
||||
public static void Run(ref DrawIndexedCommand command, ThreadedRenderer threaded, IRenderer renderer)
|
||||
{
|
||||
renderer.Pipeline.DrawIndexed(command._indexCount, command._instanceCount, command._firstIndex, command._firstVertex, command._firstInstance);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
namespace Ryujinx.Graphics.GAL.Multithreading.Commands
|
||||
{
|
||||
struct DrawCommand : IGALCommand, IGALCommand<DrawCommand>
|
||||
{
|
||||
public CommandType CommandType => CommandType.Draw;
|
||||
private int _vertexCount;
|
||||
private int _instanceCount;
|
||||
private int _firstVertex;
|
||||
private int _firstInstance;
|
||||
|
||||
public void Set(int vertexCount, int instanceCount, int firstVertex, int firstInstance)
|
||||
{
|
||||
_vertexCount = vertexCount;
|
||||
_instanceCount = instanceCount;
|
||||
_firstVertex = firstVertex;
|
||||
_firstInstance = firstInstance;
|
||||
}
|
||||
|
||||
public static void Run(ref DrawCommand command, ThreadedRenderer threaded, IRenderer renderer)
|
||||
{
|
||||
renderer.Pipeline.Draw(command._vertexCount, command._instanceCount, command._firstVertex, command._firstInstance);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
namespace Ryujinx.Graphics.GAL.Multithreading.Commands
|
||||
{
|
||||
struct DrawIndexedIndirectCommand : IGALCommand, IGALCommand<DrawIndexedIndirectCommand>
|
||||
{
|
||||
public CommandType CommandType => CommandType.DrawIndexedIndirect;
|
||||
private BufferRange _indirectBuffer;
|
||||
|
||||
public void Set(BufferRange indirectBuffer)
|
||||
{
|
||||
_indirectBuffer = indirectBuffer;
|
||||
}
|
||||
|
||||
public static void Run(ref DrawIndexedIndirectCommand command, ThreadedRenderer threaded, IRenderer renderer)
|
||||
{
|
||||
renderer.Pipeline.DrawIndexedIndirect(threaded.Buffers.MapBufferRange(command._indirectBuffer));
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
namespace Ryujinx.Graphics.GAL.Multithreading.Commands
|
||||
{
|
||||
struct DrawIndexedIndirectCountCommand : IGALCommand, IGALCommand<DrawIndexedIndirectCountCommand>
|
||||
{
|
||||
public CommandType CommandType => CommandType.DrawIndexedIndirectCount;
|
||||
private BufferRange _indirectBuffer;
|
||||
private BufferRange _parameterBuffer;
|
||||
private int _maxDrawCount;
|
||||
private int _stride;
|
||||
|
||||
public void Set(BufferRange indirectBuffer, BufferRange parameterBuffer, int maxDrawCount, int stride)
|
||||
{
|
||||
_indirectBuffer = indirectBuffer;
|
||||
_parameterBuffer = parameterBuffer;
|
||||
_maxDrawCount = maxDrawCount;
|
||||
_stride = stride;
|
||||
}
|
||||
|
||||
public static void Run(ref DrawIndexedIndirectCountCommand command, ThreadedRenderer threaded, IRenderer renderer)
|
||||
{
|
||||
renderer.Pipeline.DrawIndexedIndirectCount(
|
||||
threaded.Buffers.MapBufferRange(command._indirectBuffer),
|
||||
threaded.Buffers.MapBufferRange(command._parameterBuffer),
|
||||
command._maxDrawCount,
|
||||
command._stride
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
namespace Ryujinx.Graphics.GAL.Multithreading.Commands
|
||||
{
|
||||
struct DrawIndirectCommand : IGALCommand, IGALCommand<DrawIndirectCommand>
|
||||
{
|
||||
public CommandType CommandType => CommandType.DrawIndirect;
|
||||
private BufferRange _indirectBuffer;
|
||||
|
||||
public void Set(BufferRange indirectBuffer)
|
||||
{
|
||||
_indirectBuffer = indirectBuffer;
|
||||
}
|
||||
|
||||
public static void Run(ref DrawIndirectCommand command, ThreadedRenderer threaded, IRenderer renderer)
|
||||
{
|
||||
renderer.Pipeline.DrawIndirect(threaded.Buffers.MapBufferRange(command._indirectBuffer));
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
namespace Ryujinx.Graphics.GAL.Multithreading.Commands
|
||||
{
|
||||
struct DrawIndirectCountCommand : IGALCommand, IGALCommand<DrawIndirectCountCommand>
|
||||
{
|
||||
public CommandType CommandType => CommandType.DrawIndirectCount;
|
||||
private BufferRange _indirectBuffer;
|
||||
private BufferRange _parameterBuffer;
|
||||
private int _maxDrawCount;
|
||||
private int _stride;
|
||||
|
||||
public void Set(BufferRange indirectBuffer, BufferRange parameterBuffer, int maxDrawCount, int stride)
|
||||
{
|
||||
_indirectBuffer = indirectBuffer;
|
||||
_parameterBuffer = parameterBuffer;
|
||||
_maxDrawCount = maxDrawCount;
|
||||
_stride = stride;
|
||||
}
|
||||
|
||||
public static void Run(ref DrawIndirectCountCommand command, ThreadedRenderer threaded, IRenderer renderer)
|
||||
{
|
||||
renderer.Pipeline.DrawIndirectCount(
|
||||
threaded.Buffers.MapBufferRange(command._indirectBuffer),
|
||||
threaded.Buffers.MapBufferRange(command._parameterBuffer),
|
||||
command._maxDrawCount,
|
||||
command._stride
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
using Ryujinx.Graphics.GAL.Multithreading.Model;
|
||||
using Ryujinx.Graphics.GAL.Multithreading.Resources;
|
||||
|
||||
namespace Ryujinx.Graphics.GAL.Multithreading.Commands
|
||||
{
|
||||
struct DrawTextureCommand : IGALCommand, IGALCommand<DrawTextureCommand>
|
||||
{
|
||||
public CommandType CommandType => CommandType.DrawTexture;
|
||||
private TableRef<ITexture> _texture;
|
||||
private TableRef<ISampler> _sampler;
|
||||
private Extents2DF _srcRegion;
|
||||
private Extents2DF _dstRegion;
|
||||
|
||||
public void Set(TableRef<ITexture> texture, TableRef<ISampler> sampler, Extents2DF srcRegion, Extents2DF dstRegion)
|
||||
{
|
||||
_texture = texture;
|
||||
_sampler = sampler;
|
||||
_srcRegion = srcRegion;
|
||||
_dstRegion = dstRegion;
|
||||
}
|
||||
|
||||
public static void Run(ref DrawTextureCommand command, ThreadedRenderer threaded, IRenderer renderer)
|
||||
{
|
||||
renderer.Pipeline.DrawTexture(
|
||||
command._texture.GetAs<ThreadedTexture>(threaded)?.Base,
|
||||
command._sampler.GetAs<ThreadedSampler>(threaded)?.Base,
|
||||
command._srcRegion,
|
||||
command._dstRegion);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
namespace Ryujinx.Graphics.GAL.Multithreading.Commands
|
||||
{
|
||||
struct EndHostConditionalRenderingCommand : IGALCommand, IGALCommand<EndHostConditionalRenderingCommand>
|
||||
{
|
||||
public CommandType CommandType => CommandType.EndHostConditionalRendering;
|
||||
|
||||
public static void Run(ref EndHostConditionalRenderingCommand command, ThreadedRenderer threaded, IRenderer renderer)
|
||||
{
|
||||
renderer.Pipeline.EndHostConditionalRendering();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
namespace Ryujinx.Graphics.GAL.Multithreading.Commands
|
||||
{
|
||||
struct EndTransformFeedbackCommand : IGALCommand, IGALCommand<EndTransformFeedbackCommand>
|
||||
{
|
||||
public CommandType CommandType => CommandType.EndTransformFeedback;
|
||||
|
||||
public static void Run(ref EndTransformFeedbackCommand command, ThreadedRenderer threaded, IRenderer renderer)
|
||||
{
|
||||
renderer.Pipeline.EndTransformFeedback();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
namespace Ryujinx.Graphics.GAL.Multithreading.Commands
|
||||
{
|
||||
interface IGALCommand
|
||||
{
|
||||
CommandType CommandType { get; }
|
||||
}
|
||||
|
||||
interface IGALCommand<T> where T : IGALCommand
|
||||
{
|
||||
abstract static void Run(ref T command, ThreadedRenderer threaded, IRenderer renderer);
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
using Ryujinx.Graphics.GAL.Multithreading.Model;
|
||||
using Ryujinx.Graphics.GAL.Multithreading.Resources;
|
||||
|
||||
namespace Ryujinx.Graphics.GAL.Multithreading.Commands.Program
|
||||
{
|
||||
struct ProgramCheckLinkCommand : IGALCommand, IGALCommand<ProgramCheckLinkCommand>
|
||||
{
|
||||
public CommandType CommandType => CommandType.ProgramCheckLink;
|
||||
private TableRef<ThreadedProgram> _program;
|
||||
private bool _blocking;
|
||||
private TableRef<ResultBox<ProgramLinkStatus>> _result;
|
||||
|
||||
public void Set(TableRef<ThreadedProgram> program, bool blocking, TableRef<ResultBox<ProgramLinkStatus>> result)
|
||||
{
|
||||
_program = program;
|
||||
_blocking = blocking;
|
||||
_result = result;
|
||||
}
|
||||
|
||||
public static void Run(ref ProgramCheckLinkCommand command, ThreadedRenderer threaded, IRenderer renderer)
|
||||
{
|
||||
ProgramLinkStatus result = command._program.Get(threaded).Base.CheckProgramLink(command._blocking);
|
||||
|
||||
command._result.Get(threaded).Result = result;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
using Ryujinx.Graphics.GAL.Multithreading.Model;
|
||||
using Ryujinx.Graphics.GAL.Multithreading.Resources;
|
||||
|
||||
namespace Ryujinx.Graphics.GAL.Multithreading.Commands.Program
|
||||
{
|
||||
struct ProgramDisposeCommand : IGALCommand, IGALCommand<ProgramDisposeCommand>
|
||||
{
|
||||
public CommandType CommandType => CommandType.ProgramDispose;
|
||||
private TableRef<ThreadedProgram> _program;
|
||||
|
||||
public void Set(TableRef<ThreadedProgram> program)
|
||||
{
|
||||
_program = program;
|
||||
}
|
||||
|
||||
public static void Run(ref ProgramDisposeCommand command, ThreadedRenderer threaded, IRenderer renderer)
|
||||
{
|
||||
command._program.Get(threaded).Base.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
using Ryujinx.Graphics.GAL.Multithreading.Model;
|
||||
using Ryujinx.Graphics.GAL.Multithreading.Resources;
|
||||
|
||||
namespace Ryujinx.Graphics.GAL.Multithreading.Commands.Program
|
||||
{
|
||||
struct ProgramGetBinaryCommand : IGALCommand, IGALCommand<ProgramGetBinaryCommand>
|
||||
{
|
||||
public CommandType CommandType => CommandType.ProgramGetBinary;
|
||||
private TableRef<ThreadedProgram> _program;
|
||||
private TableRef<ResultBox<byte[]>> _result;
|
||||
|
||||
public void Set(TableRef<ThreadedProgram> program, TableRef<ResultBox<byte[]>> result)
|
||||
{
|
||||
_program = program;
|
||||
_result = result;
|
||||
}
|
||||
|
||||
public static void Run(ref ProgramGetBinaryCommand command, ThreadedRenderer threaded, IRenderer renderer)
|
||||
{
|
||||
byte[] result = command._program.Get(threaded).Base.GetBinary();
|
||||
|
||||
command._result.Get(threaded).Result = result;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
using Ryujinx.Graphics.GAL.Multithreading.Model;
|
||||
using System;
|
||||
|
||||
namespace Ryujinx.Graphics.GAL.Multithreading.Commands.Renderer
|
||||
{
|
||||
struct ActionCommand : IGALCommand, IGALCommand<ActionCommand>
|
||||
{
|
||||
public CommandType CommandType => CommandType.Action;
|
||||
private TableRef<Action> _action;
|
||||
|
||||
public void Set(TableRef<Action> action)
|
||||
{
|
||||
_action = action;
|
||||
}
|
||||
|
||||
public static void Run(ref ActionCommand command, ThreadedRenderer threaded, IRenderer renderer)
|
||||
{
|
||||
command._action.Get(threaded)();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
namespace Ryujinx.Graphics.GAL.Multithreading.Commands.Renderer
|
||||
{
|
||||
struct CreateBufferCommand : IGALCommand, IGALCommand<CreateBufferCommand>
|
||||
{
|
||||
public CommandType CommandType => CommandType.CreateBuffer;
|
||||
private BufferHandle _threadedHandle;
|
||||
private int _size;
|
||||
private BufferHandle _storageHint;
|
||||
|
||||
public void Set(BufferHandle threadedHandle, int size, BufferHandle storageHint)
|
||||
{
|
||||
_threadedHandle = threadedHandle;
|
||||
_size = size;
|
||||
_storageHint = storageHint;
|
||||
}
|
||||
|
||||
public static void Run(ref CreateBufferCommand command, ThreadedRenderer threaded, IRenderer renderer)
|
||||
{
|
||||
BufferHandle hint = BufferHandle.Null;
|
||||
|
||||
if (command._storageHint != BufferHandle.Null)
|
||||
{
|
||||
hint = threaded.Buffers.MapBuffer(command._storageHint);
|
||||
}
|
||||
|
||||
threaded.Buffers.AssignBuffer(command._threadedHandle, renderer.CreateBuffer(command._size, hint));
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
using Ryujinx.Graphics.GAL.Multithreading.Model;
|
||||
using Ryujinx.Graphics.GAL.Multithreading.Resources.Programs;
|
||||
|
||||
namespace Ryujinx.Graphics.GAL.Multithreading.Commands.Renderer
|
||||
{
|
||||
struct CreateProgramCommand : IGALCommand, IGALCommand<CreateProgramCommand>
|
||||
{
|
||||
public CommandType CommandType => CommandType.CreateProgram;
|
||||
private TableRef<IProgramRequest> _request;
|
||||
|
||||
public void Set(TableRef<IProgramRequest> request)
|
||||
{
|
||||
_request = request;
|
||||
}
|
||||
|
||||
public static void Run(ref CreateProgramCommand command, ThreadedRenderer threaded, IRenderer renderer)
|
||||
{
|
||||
IProgramRequest request = command._request.Get(threaded);
|
||||
|
||||
if (request.Threaded.Base == null)
|
||||
{
|
||||
request.Threaded.Base = request.Create(renderer);
|
||||
}
|
||||
|
||||
threaded.Programs.ProcessQueue();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
using Ryujinx.Graphics.GAL.Multithreading.Model;
|
||||
using Ryujinx.Graphics.GAL.Multithreading.Resources;
|
||||
|
||||
namespace Ryujinx.Graphics.GAL.Multithreading.Commands.Renderer
|
||||
{
|
||||
struct CreateSamplerCommand : IGALCommand, IGALCommand<CreateSamplerCommand>
|
||||
{
|
||||
public CommandType CommandType => CommandType.CreateSampler;
|
||||
private TableRef<ThreadedSampler> _sampler;
|
||||
private SamplerCreateInfo _info;
|
||||
|
||||
public void Set(TableRef<ThreadedSampler> sampler, SamplerCreateInfo info)
|
||||
{
|
||||
_sampler = sampler;
|
||||
_info = info;
|
||||
}
|
||||
|
||||
public static void Run(ref CreateSamplerCommand command, ThreadedRenderer threaded, IRenderer renderer)
|
||||
{
|
||||
command._sampler.Get(threaded).Base = renderer.CreateSampler(command._info);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
namespace Ryujinx.Graphics.GAL.Multithreading.Commands.Renderer
|
||||
{
|
||||
struct CreateSyncCommand : IGALCommand, IGALCommand<CreateSyncCommand>
|
||||
{
|
||||
public CommandType CommandType => CommandType.CreateSync;
|
||||
private ulong _id;
|
||||
private bool _strict;
|
||||
|
||||
public void Set(ulong id, bool strict)
|
||||
{
|
||||
_id = id;
|
||||
_strict = strict;
|
||||
}
|
||||
|
||||
public static void Run(ref CreateSyncCommand command, ThreadedRenderer threaded, IRenderer renderer)
|
||||
{
|
||||
renderer.CreateSync(command._id, command._strict);
|
||||
|
||||
threaded.Sync.AssignSync(command._id);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
using Ryujinx.Graphics.GAL.Multithreading.Model;
|
||||
using Ryujinx.Graphics.GAL.Multithreading.Resources;
|
||||
|
||||
namespace Ryujinx.Graphics.GAL.Multithreading.Commands.Renderer
|
||||
{
|
||||
struct CreateTextureCommand : IGALCommand, IGALCommand<CreateTextureCommand>
|
||||
{
|
||||
public CommandType CommandType => CommandType.CreateTexture;
|
||||
private TableRef<ThreadedTexture> _texture;
|
||||
private TextureCreateInfo _info;
|
||||
private float _scale;
|
||||
|
||||
public void Set(TableRef<ThreadedTexture> texture, TextureCreateInfo info, float scale)
|
||||
{
|
||||
_texture = texture;
|
||||
_info = info;
|
||||
_scale = scale;
|
||||
}
|
||||
|
||||
public static void Run(ref CreateTextureCommand command, ThreadedRenderer threaded, IRenderer renderer)
|
||||
{
|
||||
command._texture.Get(threaded).Base = renderer.CreateTexture(command._info, command._scale);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
using Ryujinx.Graphics.GAL.Multithreading.Model;
|
||||
|
||||
namespace Ryujinx.Graphics.GAL.Multithreading.Commands.Renderer
|
||||
{
|
||||
struct GetCapabilitiesCommand : IGALCommand, IGALCommand<GetCapabilitiesCommand>
|
||||
{
|
||||
public CommandType CommandType => CommandType.GetCapabilities;
|
||||
private TableRef<ResultBox<Capabilities>> _result;
|
||||
|
||||
public void Set(TableRef<ResultBox<Capabilities>> result)
|
||||
{
|
||||
_result = result;
|
||||
}
|
||||
|
||||
public static void Run(ref GetCapabilitiesCommand command, ThreadedRenderer threaded, IRenderer renderer)
|
||||
{
|
||||
command._result.Get(threaded).Result = renderer.GetCapabilities();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
namespace Ryujinx.Graphics.GAL.Multithreading.Commands.Renderer
|
||||
{
|
||||
struct PreFrameCommand : IGALCommand, IGALCommand<PreFrameCommand>
|
||||
{
|
||||
public CommandType CommandType => CommandType.PreFrame;
|
||||
|
||||
public static void Run(ref PreFrameCommand command, ThreadedRenderer threaded, IRenderer renderer)
|
||||
{
|
||||
renderer.PreFrame();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
using Ryujinx.Graphics.GAL.Multithreading.Model;
|
||||
using Ryujinx.Graphics.GAL.Multithreading.Resources;
|
||||
using System;
|
||||
|
||||
namespace Ryujinx.Graphics.GAL.Multithreading.Commands.Renderer
|
||||
{
|
||||
struct ReportCounterCommand : IGALCommand, IGALCommand<ReportCounterCommand>
|
||||
{
|
||||
public CommandType CommandType => CommandType.ReportCounter;
|
||||
private TableRef<ThreadedCounterEvent> _event;
|
||||
private CounterType _type;
|
||||
private TableRef<EventHandler<ulong>> _resultHandler;
|
||||
private bool _hostReserved;
|
||||
|
||||
public void Set(TableRef<ThreadedCounterEvent> evt, CounterType type, TableRef<EventHandler<ulong>> resultHandler, bool hostReserved)
|
||||
{
|
||||
_event = evt;
|
||||
_type = type;
|
||||
_resultHandler = resultHandler;
|
||||
_hostReserved = hostReserved;
|
||||
}
|
||||
|
||||
public static void Run(ref ReportCounterCommand command, ThreadedRenderer threaded, IRenderer renderer)
|
||||
{
|
||||
ThreadedCounterEvent evt = command._event.Get(threaded);
|
||||
|
||||
evt.Create(renderer, command._type, command._resultHandler.Get(threaded), command._hostReserved);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
namespace Ryujinx.Graphics.GAL.Multithreading.Commands.Renderer
|
||||
{
|
||||
struct ResetCounterCommand : IGALCommand, IGALCommand<ResetCounterCommand>
|
||||
{
|
||||
public CommandType CommandType => CommandType.ResetCounter;
|
||||
private CounterType _type;
|
||||
|
||||
public void Set(CounterType type)
|
||||
{
|
||||
_type = type;
|
||||
}
|
||||
|
||||
public static void Run(ref ResetCounterCommand command, ThreadedRenderer threaded, IRenderer renderer)
|
||||
{
|
||||
renderer.ResetCounter(command._type);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
namespace Ryujinx.Graphics.GAL.Multithreading.Commands.Renderer
|
||||
{
|
||||
struct UpdateCountersCommand : IGALCommand, IGALCommand<UpdateCountersCommand>
|
||||
{
|
||||
public CommandType CommandType => CommandType.UpdateCounters;
|
||||
|
||||
public static void Run(ref UpdateCountersCommand command, ThreadedRenderer threaded, IRenderer renderer)
|
||||
{
|
||||
renderer.UpdateCounters();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
using Ryujinx.Graphics.GAL.Multithreading.Model;
|
||||
using Ryujinx.Graphics.GAL.Multithreading.Resources;
|
||||
|
||||
namespace Ryujinx.Graphics.GAL.Multithreading.Commands.Sampler
|
||||
{
|
||||
struct SamplerDisposeCommand : IGALCommand, IGALCommand<SamplerDisposeCommand>
|
||||
{
|
||||
public CommandType CommandType => CommandType.SamplerDispose;
|
||||
private TableRef<ThreadedSampler> _sampler;
|
||||
|
||||
public void Set(TableRef<ThreadedSampler> sampler)
|
||||
{
|
||||
_sampler = sampler;
|
||||
}
|
||||
|
||||
public static void Run(ref SamplerDisposeCommand command, ThreadedRenderer threaded, IRenderer renderer)
|
||||
{
|
||||
command._sampler.Get(threaded).Base.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
namespace Ryujinx.Graphics.GAL.Multithreading.Commands
|
||||
{
|
||||
struct SetAlphaTestCommand : IGALCommand, IGALCommand<SetAlphaTestCommand>
|
||||
{
|
||||
public CommandType CommandType => CommandType.SetAlphaTest;
|
||||
private bool _enable;
|
||||
private float _reference;
|
||||
private CompareOp _op;
|
||||
|
||||
public void Set(bool enable, float reference, CompareOp op)
|
||||
{
|
||||
_enable = enable;
|
||||
_reference = reference;
|
||||
_op = op;
|
||||
}
|
||||
|
||||
public static void Run(ref SetAlphaTestCommand command, ThreadedRenderer threaded, IRenderer renderer)
|
||||
{
|
||||
renderer.Pipeline.SetAlphaTest(command._enable, command._reference, command._op);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
namespace Ryujinx.Graphics.GAL.Multithreading.Commands
|
||||
{
|
||||
struct SetBlendStateAdvancedCommand : IGALCommand, IGALCommand<SetBlendStateAdvancedCommand>
|
||||
{
|
||||
public CommandType CommandType => CommandType.SetBlendStateAdvanced;
|
||||
private AdvancedBlendDescriptor _blend;
|
||||
|
||||
public void Set(AdvancedBlendDescriptor blend)
|
||||
{
|
||||
_blend = blend;
|
||||
}
|
||||
|
||||
public static void Run(ref SetBlendStateAdvancedCommand command, ThreadedRenderer threaded, IRenderer renderer)
|
||||
{
|
||||
renderer.Pipeline.SetBlendState(command._blend);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
namespace Ryujinx.Graphics.GAL.Multithreading.Commands
|
||||
{
|
||||
struct SetBlendStateCommand : IGALCommand, IGALCommand<SetBlendStateCommand>
|
||||
{
|
||||
public CommandType CommandType => CommandType.SetBlendState;
|
||||
private int _index;
|
||||
private BlendDescriptor _blend;
|
||||
|
||||
public void Set(int index, BlendDescriptor blend)
|
||||
{
|
||||
_index = index;
|
||||
_blend = blend;
|
||||
}
|
||||
|
||||
public static void Run(ref SetBlendStateCommand command, ThreadedRenderer threaded, IRenderer renderer)
|
||||
{
|
||||
renderer.Pipeline.SetBlendState(command._index, command._blend);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
namespace Ryujinx.Graphics.GAL.Multithreading.Commands
|
||||
{
|
||||
struct SetDepthBiasCommand : IGALCommand, IGALCommand<SetDepthBiasCommand>
|
||||
{
|
||||
public CommandType CommandType => CommandType.SetDepthBias;
|
||||
private PolygonModeMask _enables;
|
||||
private float _factor;
|
||||
private float _units;
|
||||
private float _clamp;
|
||||
|
||||
public void Set(PolygonModeMask enables, float factor, float units, float clamp)
|
||||
{
|
||||
_enables = enables;
|
||||
_factor = factor;
|
||||
_units = units;
|
||||
_clamp = clamp;
|
||||
}
|
||||
|
||||
public static void Run(ref SetDepthBiasCommand command, ThreadedRenderer threaded, IRenderer renderer)
|
||||
{
|
||||
renderer.Pipeline.SetDepthBias(command._enables, command._factor, command._units, command._clamp);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
namespace Ryujinx.Graphics.GAL.Multithreading.Commands
|
||||
{
|
||||
struct SetDepthClampCommand : IGALCommand, IGALCommand<SetDepthClampCommand>
|
||||
{
|
||||
public CommandType CommandType => CommandType.SetDepthClamp;
|
||||
private bool _clamp;
|
||||
|
||||
public void Set(bool clamp)
|
||||
{
|
||||
_clamp = clamp;
|
||||
}
|
||||
|
||||
public static void Run(ref SetDepthClampCommand command, ThreadedRenderer threaded, IRenderer renderer)
|
||||
{
|
||||
renderer.Pipeline.SetDepthClamp(command._clamp);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
namespace Ryujinx.Graphics.GAL.Multithreading.Commands
|
||||
{
|
||||
struct SetDepthModeCommand : IGALCommand, IGALCommand<SetDepthModeCommand>
|
||||
{
|
||||
public CommandType CommandType => CommandType.SetDepthMode;
|
||||
private DepthMode _mode;
|
||||
|
||||
public void Set(DepthMode mode)
|
||||
{
|
||||
_mode = mode;
|
||||
}
|
||||
|
||||
public static void Run(ref SetDepthModeCommand command, ThreadedRenderer threaded, IRenderer renderer)
|
||||
{
|
||||
renderer.Pipeline.SetDepthMode(command._mode);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
namespace Ryujinx.Graphics.GAL.Multithreading.Commands
|
||||
{
|
||||
struct SetDepthTestCommand : IGALCommand, IGALCommand<SetDepthTestCommand>
|
||||
{
|
||||
public CommandType CommandType => CommandType.SetDepthTest;
|
||||
private DepthTestDescriptor _depthTest;
|
||||
|
||||
public void Set(DepthTestDescriptor depthTest)
|
||||
{
|
||||
_depthTest = depthTest;
|
||||
}
|
||||
|
||||
public static void Run(ref SetDepthTestCommand command, ThreadedRenderer threaded, IRenderer renderer)
|
||||
{
|
||||
renderer.Pipeline.SetDepthTest(command._depthTest);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
namespace Ryujinx.Graphics.GAL.Multithreading.Commands
|
||||
{
|
||||
struct SetFaceCullingCommand : IGALCommand, IGALCommand<SetFaceCullingCommand>
|
||||
{
|
||||
public CommandType CommandType => CommandType.SetFaceCulling;
|
||||
private bool _enable;
|
||||
private Face _face;
|
||||
|
||||
public void Set(bool enable, Face face)
|
||||
{
|
||||
_enable = enable;
|
||||
_face = face;
|
||||
}
|
||||
|
||||
public static void Run(ref SetFaceCullingCommand command, ThreadedRenderer threaded, IRenderer renderer)
|
||||
{
|
||||
renderer.Pipeline.SetFaceCulling(command._enable, command._face);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
namespace Ryujinx.Graphics.GAL.Multithreading.Commands
|
||||
{
|
||||
struct SetFrontFaceCommand : IGALCommand, IGALCommand<SetFrontFaceCommand>
|
||||
{
|
||||
public CommandType CommandType => CommandType.SetFrontFace;
|
||||
private FrontFace _frontFace;
|
||||
|
||||
public void Set(FrontFace frontFace)
|
||||
{
|
||||
_frontFace = frontFace;
|
||||
}
|
||||
|
||||
public static void Run(ref SetFrontFaceCommand command, ThreadedRenderer threaded, IRenderer renderer)
|
||||
{
|
||||
renderer.Pipeline.SetFrontFace(command._frontFace);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
using Ryujinx.Graphics.GAL.Multithreading.Model;
|
||||
using Ryujinx.Graphics.GAL.Multithreading.Resources;
|
||||
|
||||
namespace Ryujinx.Graphics.GAL.Multithreading.Commands
|
||||
{
|
||||
struct SetImageCommand : IGALCommand, IGALCommand<SetImageCommand>
|
||||
{
|
||||
public CommandType CommandType => CommandType.SetImage;
|
||||
private int _binding;
|
||||
private TableRef<ITexture> _texture;
|
||||
private Format _imageFormat;
|
||||
|
||||
public void Set(int binding, TableRef<ITexture> texture, Format imageFormat)
|
||||
{
|
||||
_binding = binding;
|
||||
_texture = texture;
|
||||
_imageFormat = imageFormat;
|
||||
}
|
||||
|
||||
public static void Run(ref SetImageCommand command, ThreadedRenderer threaded, IRenderer renderer)
|
||||
{
|
||||
renderer.Pipeline.SetImage(command._binding, command._texture.GetAs<ThreadedTexture>(threaded)?.Base, command._imageFormat);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
namespace Ryujinx.Graphics.GAL.Multithreading.Commands
|
||||
{
|
||||
struct SetIndexBufferCommand : IGALCommand, IGALCommand<SetIndexBufferCommand>
|
||||
{
|
||||
public CommandType CommandType => CommandType.SetIndexBuffer;
|
||||
private BufferRange _buffer;
|
||||
private IndexType _type;
|
||||
|
||||
public void Set(BufferRange buffer, IndexType type)
|
||||
{
|
||||
_buffer = buffer;
|
||||
_type = type;
|
||||
}
|
||||
|
||||
public static void Run(ref SetIndexBufferCommand command, ThreadedRenderer threaded, IRenderer renderer)
|
||||
{
|
||||
BufferRange range = threaded.Buffers.MapBufferRange(command._buffer);
|
||||
renderer.Pipeline.SetIndexBuffer(range, command._type);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
namespace Ryujinx.Graphics.GAL.Multithreading.Commands
|
||||
{
|
||||
struct SetLineParametersCommand : IGALCommand, IGALCommand<SetLineParametersCommand>
|
||||
{
|
||||
public CommandType CommandType => CommandType.SetLineParameters;
|
||||
private float _width;
|
||||
private bool _smooth;
|
||||
|
||||
public void Set(float width, bool smooth)
|
||||
{
|
||||
_width = width;
|
||||
_smooth = smooth;
|
||||
}
|
||||
|
||||
public static void Run(ref SetLineParametersCommand command, ThreadedRenderer threaded, IRenderer renderer)
|
||||
{
|
||||
renderer.Pipeline.SetLineParameters(command._width, command._smooth);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
namespace Ryujinx.Graphics.GAL.Multithreading.Commands
|
||||
{
|
||||
struct SetLogicOpStateCommand : IGALCommand, IGALCommand<SetLogicOpStateCommand>
|
||||
{
|
||||
public CommandType CommandType => CommandType.SetLogicOpState;
|
||||
private bool _enable;
|
||||
private LogicalOp _op;
|
||||
|
||||
public void Set(bool enable, LogicalOp op)
|
||||
{
|
||||
_enable = enable;
|
||||
_op = op;
|
||||
}
|
||||
|
||||
public static void Run(ref SetLogicOpStateCommand command, ThreadedRenderer threaded, IRenderer renderer)
|
||||
{
|
||||
renderer.Pipeline.SetLogicOpState(command._enable, command._op);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
namespace Ryujinx.Graphics.GAL.Multithreading.Commands
|
||||
{
|
||||
struct SetMultisampleStateCommand : IGALCommand, IGALCommand<SetMultisampleStateCommand>
|
||||
{
|
||||
public CommandType CommandType => CommandType.SetMultisampleState;
|
||||
private MultisampleDescriptor _multisample;
|
||||
|
||||
public void Set(MultisampleDescriptor multisample)
|
||||
{
|
||||
_multisample = multisample;
|
||||
}
|
||||
|
||||
public static void Run(ref SetMultisampleStateCommand command, ThreadedRenderer threaded, IRenderer renderer)
|
||||
{
|
||||
renderer.Pipeline.SetMultisampleState(command._multisample);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
using Ryujinx.Common.Memory;
|
||||
using System;
|
||||
|
||||
namespace Ryujinx.Graphics.GAL.Multithreading.Commands
|
||||
{
|
||||
struct SetPatchParametersCommand : IGALCommand, IGALCommand<SetPatchParametersCommand>
|
||||
{
|
||||
public CommandType CommandType => CommandType.SetPatchParameters;
|
||||
private int _vertices;
|
||||
private Array4<float> _defaultOuterLevel;
|
||||
private Array2<float> _defaultInnerLevel;
|
||||
|
||||
public void Set(int vertices, ReadOnlySpan<float> defaultOuterLevel, ReadOnlySpan<float> defaultInnerLevel)
|
||||
{
|
||||
_vertices = vertices;
|
||||
defaultOuterLevel.CopyTo(_defaultOuterLevel.AsSpan());
|
||||
defaultInnerLevel.CopyTo(_defaultInnerLevel.AsSpan());
|
||||
}
|
||||
|
||||
public static void Run(ref SetPatchParametersCommand command, ThreadedRenderer threaded, IRenderer renderer)
|
||||
{
|
||||
renderer.Pipeline.SetPatchParameters(command._vertices, command._defaultOuterLevel.AsSpan(), command._defaultInnerLevel.AsSpan());
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
namespace Ryujinx.Graphics.GAL.Multithreading.Commands
|
||||
{
|
||||
struct SetPointParametersCommand : IGALCommand, IGALCommand<SetPointParametersCommand>
|
||||
{
|
||||
public CommandType CommandType => CommandType.SetPointParameters;
|
||||
private float _size;
|
||||
private bool _isProgramPointSize;
|
||||
private bool _enablePointSprite;
|
||||
private Origin _origin;
|
||||
|
||||
public void Set(float size, bool isProgramPointSize, bool enablePointSprite, Origin origin)
|
||||
{
|
||||
_size = size;
|
||||
_isProgramPointSize = isProgramPointSize;
|
||||
_enablePointSprite = enablePointSprite;
|
||||
_origin = origin;
|
||||
}
|
||||
|
||||
public static void Run(ref SetPointParametersCommand command, ThreadedRenderer threaded, IRenderer renderer)
|
||||
{
|
||||
renderer.Pipeline.SetPointParameters(command._size, command._isProgramPointSize, command._enablePointSprite, command._origin);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
namespace Ryujinx.Graphics.GAL.Multithreading.Commands
|
||||
{
|
||||
struct SetPolygonModeCommand : IGALCommand, IGALCommand<SetPolygonModeCommand>
|
||||
{
|
||||
public CommandType CommandType => CommandType.SetPolygonMode;
|
||||
private PolygonMode _frontMode;
|
||||
private PolygonMode _backMode;
|
||||
|
||||
public void Set(PolygonMode frontMode, PolygonMode backMode)
|
||||
{
|
||||
_frontMode = frontMode;
|
||||
_backMode = backMode;
|
||||
}
|
||||
|
||||
public static void Run(ref SetPolygonModeCommand command, ThreadedRenderer threaded, IRenderer renderer)
|
||||
{
|
||||
renderer.Pipeline.SetPolygonMode(command._frontMode, command._backMode);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
namespace Ryujinx.Graphics.GAL.Multithreading.Commands
|
||||
{
|
||||
struct SetPrimitiveRestartCommand : IGALCommand, IGALCommand<SetPrimitiveRestartCommand>
|
||||
{
|
||||
public CommandType CommandType => CommandType.SetPrimitiveRestart;
|
||||
private bool _enable;
|
||||
private int _index;
|
||||
|
||||
public void Set(bool enable, int index)
|
||||
{
|
||||
_enable = enable;
|
||||
_index = index;
|
||||
}
|
||||
|
||||
public static void Run(ref SetPrimitiveRestartCommand command, ThreadedRenderer threaded, IRenderer renderer)
|
||||
{
|
||||
renderer.Pipeline.SetPrimitiveRestart(command._enable, command._index);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
namespace Ryujinx.Graphics.GAL.Multithreading.Commands
|
||||
{
|
||||
struct SetPrimitiveTopologyCommand : IGALCommand, IGALCommand<SetPrimitiveTopologyCommand>
|
||||
{
|
||||
public CommandType CommandType => CommandType.SetPrimitiveTopology;
|
||||
private PrimitiveTopology _topology;
|
||||
|
||||
public void Set(PrimitiveTopology topology)
|
||||
{
|
||||
_topology = topology;
|
||||
}
|
||||
|
||||
public static void Run(ref SetPrimitiveTopologyCommand command, ThreadedRenderer threaded, IRenderer renderer)
|
||||
{
|
||||
renderer.Pipeline.SetPrimitiveTopology(command._topology);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
using Ryujinx.Graphics.GAL.Multithreading.Model;
|
||||
using Ryujinx.Graphics.GAL.Multithreading.Resources;
|
||||
|
||||
namespace Ryujinx.Graphics.GAL.Multithreading.Commands
|
||||
{
|
||||
struct SetProgramCommand : IGALCommand, IGALCommand<SetProgramCommand>
|
||||
{
|
||||
public CommandType CommandType => CommandType.SetProgram;
|
||||
private TableRef<IProgram> _program;
|
||||
|
||||
public void Set(TableRef<IProgram> program)
|
||||
{
|
||||
_program = program;
|
||||
}
|
||||
|
||||
public static void Run(ref SetProgramCommand command, ThreadedRenderer threaded, IRenderer renderer)
|
||||
{
|
||||
ThreadedProgram program = command._program.GetAs<ThreadedProgram>(threaded);
|
||||
|
||||
threaded.Programs.WaitForProgram(program);
|
||||
|
||||
renderer.Pipeline.SetProgram(program.Base);
|
||||
}
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user