From b423197619dd8d9dda1c255a76105bf30e255dae Mon Sep 17 00:00:00 2001 From: gdkchan Date: Sun, 13 Aug 2023 22:26:42 -0300 Subject: Delete ShaderConfig and organize shader resources/definitions better (#5509) * Move some properties out of ShaderConfig * Stop using ShaderConfig on backends * Replace ShaderConfig usages on Translator and passes * Move remaining properties out of ShaderConfig and delete ShaderConfig * Remove ResourceManager property from TranslatorContext * Move Rewriter passes to separate transform pass files * Fix TransformPasses.RunPass on cases where a node is removed * Move remaining ClipDistancePrimitivesWritten and UsedFeatures updates to decode stage * Reduce excessive parameter passing a bit by using structs more * Remove binding parameter from ShaderProperties methods since it is redundant * Replace decoder instruction checks with switch statement * Put GLSL on the same plan as SPIR-V for input/output declaration * Stop mutating TranslatorContext state when Translate is called * Pass most of the graphics state using a struct instead of individual query methods * Auto-format * Auto-format * Add backend logging interface * Auto-format * Remove unnecessary use of interpolated strings * Remove more modifications of AttributeUsage after decode * PR feedback * gl_Layer is not supported on compute --- src/Ryujinx.Graphics.Shader/GpuGraphicsState.cs | 169 ++++++++++++++++++++++++ 1 file changed, 169 insertions(+) create mode 100644 src/Ryujinx.Graphics.Shader/GpuGraphicsState.cs (limited to 'src/Ryujinx.Graphics.Shader/GpuGraphicsState.cs') diff --git a/src/Ryujinx.Graphics.Shader/GpuGraphicsState.cs b/src/Ryujinx.Graphics.Shader/GpuGraphicsState.cs new file mode 100644 index 00000000..f16c71d5 --- /dev/null +++ b/src/Ryujinx.Graphics.Shader/GpuGraphicsState.cs @@ -0,0 +1,169 @@ +using Ryujinx.Common.Memory; + +namespace Ryujinx.Graphics.Shader +{ + /// + /// GPU graphics state that the shader depends on. + /// + public readonly struct GpuGraphicsState + { + /// + /// Early Z force enable. + /// + public readonly bool EarlyZForce; + + /// + /// Primitive topology of current draw. + /// + public readonly InputTopology Topology; + + /// + /// Tessellation winding order. + /// + public readonly bool TessCw; + + /// + /// Tessellation patch type. + /// + public readonly TessPatchType TessPatchType; + + /// + /// Tessellation spacing. + /// + public readonly TessSpacing TessSpacing; + + /// + /// Indicates whether alpha-to-coverage is enabled. + /// + public readonly bool AlphaToCoverageEnable; + + /// + /// Indicates whether alpha-to-coverage dithering is enabled. + /// + public readonly bool AlphaToCoverageDitherEnable; + + /// + /// Indicates whether the viewport transform is disabled. + /// + public readonly bool ViewportTransformDisable; + + /// + /// Depth mode zero to one or minus one to one. + /// + public readonly bool DepthMode; + + /// + /// Indicates if the point size is set on the shader or is fixed. + /// + public readonly bool ProgramPointSizeEnable; + + /// + /// Point size used if is false. + /// + public readonly float PointSize; + + /// + /// When alpha test is enabled, indicates the comparison that decides if the fragment should be discarded. + /// + public readonly AlphaTestOp AlphaTestCompare; + + /// + /// When alpha test is enabled, indicates the value to compare with the fragment output alpha. + /// + public readonly float AlphaTestReference; + + /// + /// Type of the vertex attributes consumed by the shader. + /// + public readonly Array32 AttributeTypes; + + /// + /// Indicates that the draw is writing the base vertex, base instance and draw index to Constant Buffer 0. + /// + public readonly bool HasConstantBufferDrawParameters; + + /// + /// Type of the fragment shader outputs. + /// + public readonly Array8 FragmentOutputTypes; + + /// + /// Indicates whether dual source blend is enabled. + /// + public readonly bool DualSourceBlendEnable; + + /// + /// Indicates if negation of the viewport Y axis is enabled. + /// + public readonly bool YNegateEnabled; + + /// + /// If true, indicates that the fragment origin is the upper left corner of the viewport, otherwise it is the lower left corner. + /// + public readonly bool OriginUpperLeft; + + /// + /// Creates a new GPU graphics state. + /// + /// Early Z force enable + /// Primitive topology + /// Tessellation winding order (clockwise or counter-clockwise) + /// Tessellation patch type + /// Tessellation spacing + /// Indicates whether alpha-to-coverage is enabled + /// Indicates whether alpha-to-coverage dithering is enabled + /// Indicates whether the viewport transform is disabled + /// Depth mode zero to one or minus one to one + /// Indicates if the point size is set on the shader or is fixed + /// Point size if not set from shader + /// When alpha test is enabled, indicates the comparison that decides if the fragment should be discarded + /// When alpha test is enabled, indicates the value to compare with the fragment output alpha + /// Type of the vertex attributes consumed by the shader + /// Indicates that the draw is writing the base vertex, base instance and draw index to Constant Buffer 0 + /// Type of the fragment shader outputs + /// Indicates whether dual source blend is enabled + /// Indicates if negation of the viewport Y axis is enabled + /// If true, indicates that the fragment origin is the upper left corner of the viewport, otherwise it is the lower left corner + public GpuGraphicsState( + bool earlyZForce, + InputTopology topology, + bool tessCw, + TessPatchType tessPatchType, + TessSpacing tessSpacing, + bool alphaToCoverageEnable, + bool alphaToCoverageDitherEnable, + bool viewportTransformDisable, + bool depthMode, + bool programPointSizeEnable, + float pointSize, + AlphaTestOp alphaTestCompare, + float alphaTestReference, + in Array32 attributeTypes, + bool hasConstantBufferDrawParameters, + in Array8 fragmentOutputTypes, + bool dualSourceBlendEnable, + bool yNegateEnabled, + bool originUpperLeft) + { + EarlyZForce = earlyZForce; + Topology = topology; + TessCw = tessCw; + TessPatchType = tessPatchType; + TessSpacing = tessSpacing; + AlphaToCoverageEnable = alphaToCoverageEnable; + AlphaToCoverageDitherEnable = alphaToCoverageDitherEnable; + ViewportTransformDisable = viewportTransformDisable; + DepthMode = depthMode; + ProgramPointSizeEnable = programPointSizeEnable; + PointSize = pointSize; + AlphaTestCompare = alphaTestCompare; + AlphaTestReference = alphaTestReference; + AttributeTypes = attributeTypes; + HasConstantBufferDrawParameters = hasConstantBufferDrawParameters; + FragmentOutputTypes = fragmentOutputTypes; + DualSourceBlendEnable = dualSourceBlendEnable; + YNegateEnabled = yNegateEnabled; + OriginUpperLeft = originUpperLeft; + } + } +} -- cgit v1.2.3