using Ryujinx.Graphics.Shader.CodeGen; using System; namespace Ryujinx.Graphics.Shader { /// /// GPU state access interface. /// public interface IGpuAccessor : ILogger { /// /// 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 binding number of a constant buffer. /// /// Constant buffer index /// Binding number int CreateConstantBufferBinding(int index); /// /// Queries the binding number of an image. /// /// For array of images, the number of elements of the array, otherwise it should be 1 /// Indicates if the image is a buffer image /// Binding number int CreateImageBinding(int count, bool isBuffer); /// /// Queries the binding number of a storage buffer. /// /// Storage buffer index /// Binding number int CreateStorageBufferBinding(int index); /// /// Queries the binding number of a texture. /// /// For array of textures, the number of elements of the array, otherwise it should be 1 /// Indicates if the texture is a buffer texture /// Binding number int CreateTextureBinding(int count, bool isBuffer); /// /// 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 specialized GPU graphics state that the shader depends on. /// /// GPU graphics state GpuGraphicsState QueryGraphicsState() { return new GpuGraphicsState( false, InputTopology.Points, false, TessPatchType.Triangles, TessSpacing.EqualSpacing, false, false, false, false, false, 1f, AlphaTestOp.Always, 0f, default, true, default, false, false, false, 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 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 shader subgroup size. /// /// Host shader subgroup size in invocations int QueryHostSubgroupSize() { return 32; } /// /// 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 support scaled vertex formats, where a integer value is converted to floating-point. /// /// True if the host support scaled vertex formats, false otherwise bool QueryHostSupportsScaledVertexFormats() { return true; } /// /// Queries host API support for separate textures and samplers. /// /// True if the API supports samplers and textures to be combined on the shader, false otherwise bool QueryHostSupportsSeparateSampler() { 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 gather with multiple offsets support. /// /// True if the GPU and driver supports texture gather offsets, false otherwise bool QueryHostSupportsTextureGatherOffsets() { 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; } /// /// Gets the maximum number of samplers that the bound texture pool may have. /// /// Maximum amount of samplers that the pool may have int QuerySamplerArrayLengthFromPool(); /// /// 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; } /// /// Gets the size in bytes of a bound constant buffer for the current shader stage. /// /// The number of the constant buffer to get the size from /// Size in bytes int QueryTextureArrayLengthFromBuffer(int slot); /// /// Gets the maximum number of textures that the bound texture pool may have. /// /// Maximum amount of textures that the pool may have int QueryTextureArrayLengthFromPool(); /// /// 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 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 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; } /// /// 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. } } }