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 binding number of a constant buffer.
///
/// Constant buffer index
/// Binding number
int QueryBindingConstantBuffer(int index)
{
return index;
}
///
/// 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
/// Binding number
int QueryBindingTexture(int index)
{
return index;
}
///
/// Queries the binding number of an image.
///
/// Image index
/// Binding number
int QueryBindingImage(int index)
{
return index;
}
///
/// 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 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 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 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 texture shadow LOD support.
///
/// True if the GPU and driver supports texture shadow LOD, false otherwise
bool QueryHostSupportsTextureShadowLod()
{
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 false;
}
///
/// 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 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 forces early depth testing.
///
/// True if early depth testing is forced
bool QueryEarlyZForce()
{
return false;
}
///
/// Queries if host state disables the viewport transform.
///
/// True if the viewport transform is disabled
bool QueryViewportTransformDisable()
{
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.
}
}
}