using System; namespace Ryujinx.Graphics.Shader { /// /// GPU state access interface. /// public interface IGpuAccessor { /// /// Prints a log message. /// /// Message to print void Log(string message) { // No default log output. } /// /// Reads data from the constant buffer 1. /// /// Offset in bytes to read from /// Value at the given offset uint ConstantBuffer1Read(int offset) { return 0; } /// /// Gets a span of the specified memory location, containing shader code. /// /// GPU virtual address of the data /// Minimum size that the returned span may have /// Span of the memory location ReadOnlySpan GetCode(ulong address, int minimumSize); /// /// Queries the alpha test comparison operator that is being used currently. /// If alpha test is disabled, it should be set to . /// /// Current alpha test comparison AlphaTestOp QueryAlphaTestCompare() { return AlphaTestOp.Always; } /// /// Queries the current alpha test reference value used by the comparison. /// /// Current alpha test reference value float QueryAlphaTestReference() { return 0f; } /// /// Queries the type of the vertex shader input attribute at the specified . /// /// Location of the input attribute /// Input type AttributeType QueryAttributeType(int location) { return AttributeType.Float; } /// /// Queries whenever the alpha-to-coverage dithering feature is enabled. /// /// True if the feature is enabled, false otherwise bool QueryAlphaToCoverageDitherEnable() { return false; } /// /// Queries the binding number of a constant buffer. /// /// Constant buffer index /// Binding number int QueryBindingConstantBuffer(int index) { return index + 1; } /// /// Queries the binding number of a storage buffer. /// /// Storage buffer index /// Binding number int QueryBindingStorageBuffer(int index) { return index; } /// /// Queries the binding number of a texture. /// /// Texture index /// Indicates if the texture is a buffer texture /// Binding number int QueryBindingTexture(int index, bool isBuffer) { return index; } /// /// Queries the binding number of an image. /// /// Image index /// Indicates if the image is a buffer image /// Binding number int QueryBindingImage(int index, bool isBuffer) { return index; } /// /// Queries output type for fragment shaders. /// /// Location of the framgent output /// Output location AttributeType QueryFragmentOutputType(int location) { return AttributeType.Float; } /// /// Queries Local Size X for compute shaders. /// /// Local Size X int QueryComputeLocalSizeX() { return 1; } /// /// Queries Local Size Y for compute shaders. /// /// Local Size Y int QueryComputeLocalSizeY() { return 1; } /// /// Queries Local Size Z for compute shaders. /// /// Local Size Z int QueryComputeLocalSizeZ() { return 1; } /// /// Queries Local Memory size in bytes for compute shaders. /// /// Local Memory size in bytes int QueryComputeLocalMemorySize() { return 0x1000; } /// /// Queries Shared Memory size in bytes for compute shaders. /// /// Shared Memory size in bytes int QueryComputeSharedMemorySize() { return 0xc000; } /// /// Queries Constant Buffer usage information. /// /// A mask where each bit set indicates a bound constant buffer uint QueryConstantBufferUse() { return 0; } /// /// Queries if host state forces early depth testing. /// /// True if early depth testing is forced bool QueryEarlyZForce() { return false; } /// /// Queries whenever the current draw has written the base vertex and base instance into Constant Buffer 0. /// /// True if the shader translator can assume that the constant buffer contains the base IDs, false otherwise bool QueryHasConstantBufferDrawParameters() { return false; } /// /// Queries whenever the current draw uses unaligned storage buffer addresses. /// /// True if any storage buffer address is not aligned to 16 bytes, false otherwise bool QueryHasUnalignedStorageBuffer() { return false; } /// /// Queries host's gather operation precision bits for biasing their coordinates. Zero means no bias. /// /// Bits of gather operation precision to use for coordinate bias int QueryHostGatherBiasPrecision() { return 0; } /// /// Queries host about whether to reduce precision to improve performance. /// /// True if precision is limited to vertex position, false otherwise bool QueryHostReducedPrecision() { return false; } /// /// Queries dual source blend state. /// /// True if blending is enabled with a dual source blend equation, false otherwise bool QueryDualSourceBlendEnable() { return false; } /// /// Queries host about the presence of the FrontFacing built-in variable bug. /// /// True if the bug is present on the host device used, false otherwise bool QueryHostHasFrontFacingBug() { return false; } /// /// Queries host about the presence of the vector indexing bug. /// /// True if the bug is present on the host device used, false otherwise bool QueryHostHasVectorIndexingBug() { return false; } /// /// Queries host storage buffer alignment required. /// /// Host storage buffer alignment in bytes int QueryHostStorageBufferOffsetAlignment() { return 16; } /// /// Queries host support for texture formats with BGRA component order (such as BGRA8). /// /// True if BGRA formats are supported, false otherwise bool QueryHostSupportsBgraFormat() { return true; } /// /// Queries host support for fragment shader ordering critical sections on the shader code. /// /// True if fragment shader interlock is supported, false otherwise bool QueryHostSupportsFragmentShaderInterlock() { return true; } /// /// Queries host support for fragment shader ordering scoped critical sections on the shader code. /// /// True if fragment shader ordering is supported, false otherwise bool QueryHostSupportsFragmentShaderOrderingIntel() { return false; } /// /// Queries host GPU geometry shader support. /// /// True if the GPU and driver supports geometry shaders, false otherwise bool QueryHostSupportsGeometryShader() { return true; } /// /// Queries host GPU geometry shader passthrough support. /// /// True if the GPU and driver supports geometry shader passthrough, false otherwise bool QueryHostSupportsGeometryShaderPassthrough() { return true; } /// /// Queries host support for readable images without a explicit format declaration on the shader. /// /// True if formatted image load is supported, false otherwise bool QueryHostSupportsImageLoadFormatted() { return true; } /// /// Queries host support for writes to the layer from vertex or tessellation shader stages. /// /// True if writes to the layer from vertex or tessellation are supported, false otherwise bool QueryHostSupportsLayerVertexTessellation() { return true; } /// /// Queries host GPU non-constant texture offset support. /// /// True if the GPU and driver supports non-constant texture offsets, false otherwise bool QueryHostSupportsNonConstantTextureOffset() { return true; } /// /// Queries host GPU shader ballot support. /// /// True if the GPU and driver supports shader ballot, false otherwise bool QueryHostSupportsShaderBallot() { return true; } /// /// Queries host GPU shader support for barrier instructions on divergent control flow paths. /// /// True if the GPU supports barriers on divergent control flow paths, false otherwise bool QueryHostSupportsShaderBarrierDivergence() { return true; } /// /// Queries host GPU support for 64-bit floating point (double precision) operations on the shader. /// /// True if the GPU and driver supports double operations, false otherwise bool QueryHostSupportsShaderFloat64() { return true; } /// /// Queries host GPU support for signed normalized buffer texture formats. /// /// True if the GPU and driver supports the formats, false otherwise bool QueryHostSupportsSnormBufferTextureFormat() { return true; } /// /// Queries host GPU texture shadow LOD support. /// /// True if the GPU and driver supports texture shadow LOD, false otherwise bool QueryHostSupportsTextureShadowLod() { return true; } /// /// Queries host GPU transform feedback support. /// /// True if the GPU and driver supports transform feedback, false otherwise bool QueryHostSupportsTransformFeedback() { return true; } /// /// Queries host support for writes to the viewport index from vertex or tessellation shader stages. /// /// True if writes to the viewport index from vertex or tessellation are supported, false otherwise bool QueryHostSupportsViewportIndexVertexTessellation() { return true; } /// /// Queries host GPU shader viewport mask output support. /// /// True if the GPU and driver supports shader viewport mask output, false otherwise bool QueryHostSupportsViewportMask() { return true; } /// /// Queries whether the host supports depth clip control. /// /// True if the GPU and driver supports depth clip control, false otherwise bool QueryHostSupportsDepthClipControl() { return true; } /// /// Queries the point size from the GPU state, used when it is not explicitly set on the shader. /// /// Current point size float QueryPointSize() { return 1f; } /// /// Queries the state that indicates if the program point size should be explicitly set on the shader /// or read from the GPU state. /// /// True if the shader is expected to set the point size explicitly, false otherwise bool QueryProgramPointSize() { return true; } /// /// Queries sampler type information. /// /// Texture handle /// Constant buffer slot for the texture handle /// The sampler type value for the given handle SamplerType QuerySamplerType(int handle, int cbufSlot = -1) { return SamplerType.Texture2D; } /// /// Queries texture coordinate normalization information. /// /// Texture handle /// Constant buffer slot for the texture handle /// True if the coordinates are normalized, false otherwise bool QueryTextureCoordNormalized(int handle, int cbufSlot = -1) { return true; } /// /// Queries current primitive topology for geometry shaders. /// /// Current primitive topology InputTopology QueryPrimitiveTopology() { return InputTopology.Points; } /// /// Queries the tessellation evaluation shader primitive winding order. /// /// True if the primitive winding order is clockwise, false if counter-clockwise bool QueryTessCw() { return false; } /// /// Queries the tessellation evaluation shader abstract patch type. /// /// Abstract patch type TessPatchType QueryTessPatchType() { return TessPatchType.Triangles; } /// /// Queries the tessellation evaluation shader spacing between tessellated vertices of the patch. /// /// Spacing between tessellated vertices of the patch TessSpacing QueryTessSpacing() { return TessSpacing.EqualSpacing; } /// /// Queries texture format information, for shaders using image load or store. /// /// /// This only returns non-compressed color formats. /// If the format of the texture is a compressed, depth or unsupported format, then a default value is returned. /// /// Texture handle /// Constant buffer slot for the texture handle /// Color format of the non-compressed texture TextureFormat QueryTextureFormat(int handle, int cbufSlot = -1) { return TextureFormat.R8G8B8A8Unorm; } /// /// Queries depth mode information from the GPU state. /// /// True if current depth mode is -1 to 1, false if 0 to 1 bool QueryTransformDepthMinusOneToOne() { return false; } /// /// Queries transform feedback enable state. /// /// True if the shader uses transform feedback, false otherwise bool QueryTransformFeedbackEnabled() { return false; } /// /// Queries the varying locations that should be written to the transform feedback buffer. /// /// Index of the transform feedback buffer /// Varying locations for the specified buffer ReadOnlySpan QueryTransformFeedbackVaryingLocations(int bufferIndex) { return ReadOnlySpan.Empty; } /// /// Queries the stride (in bytes) of the per vertex data written into the transform feedback buffer. /// /// Index of the transform feedback buffer /// Stride for the specified buffer int QueryTransformFeedbackStride(int bufferIndex) { return 0; } /// /// Queries if host state disables the viewport transform. /// /// True if the viewport transform is disabled bool QueryViewportTransformDisable() { return false; } /// /// Queries Y negate enable state. /// /// True if Y negate of the fragment coordinates is enabled, false otherwise bool QueryYNegateEnabled() { return false; } /// /// Registers a texture used by the shader. /// /// Texture handle word offset /// Constant buffer slot where the texture handle is located void RegisterTexture(int handle, int cbufSlot) { // Only useful when recording information for a disk shader cache. } } }