ReXGlue SDK
Loading...
Searching...
No Matches
state.h File Reference

Xenos pipeline state, shader and EDRAM enums. More...

#include <utility>
#include <rex/assert.h>
#include <rex/types.h>

Go to the source code of this file.

Classes

struct  rex::xenos::DepthSampleCounts

Namespaces

namespace  rex

Enumerations

enum class  ShaderType : u32 { kVertex = 0 , kPixel = 1 }
enum class  rex::xenos::PrimitiveType : u32 {
  kNone = 0x00 , kPointList = 0x01 , kLineList = 0x02 , kLineStrip = 0x03 ,
  kTriangleList = 0x04 , kTriangleFan = 0x05 , kTriangleStrip = 0x06 , kTriangleWithWFlags = 0x07 ,
  kRectangleList = 0x08 , kLineLoop = 0x0C , kQuadList = 0x0D , kQuadStrip = 0x0E ,
  kPolygon = 0x0F , kExplicitMajorModeForceStart = 0x10 , k2DCopyRectListV0 = 0x10 , k2DCopyRectListV1 = 0x11 ,
  k2DCopyRectListV2 = 0x12 , k2DCopyRectListV3 = 0x13 , k2DFillRectList = 0x14 , k2DLineStrip = 0x15 ,
  k2DTriStrip = 0x16 , kLinePatch = 0x10 , kTrianglePatch = 0x11 , kQuadPatch = 0x12
}
enum class  SampleLocation : u32 { kCentroid = 0 , kCenter = 1 }
enum class  rex::xenos::MSAASamples : u32 { k1X = 0 , k2X = 1 , k4X = 2 }
enum class  CompareFunction : u32 {
  kNever = 0b000 , kLess = 0b001 , kEqual = 0b010 , kLessEqual = 0b011 ,
  kGreater = 0b100 , kNotEqual = 0b101 , kGreaterEqual = 0b110 , kAlways = 0b111
}
enum class  StencilOp : u32 {
  kKeep = 0 , kZero = 1 , kReplace = 2 , kIncrementClamp = 3 ,
  kDecrementClamp = 4 , kInvert = 5 , kIncrementWrap = 6 , kDecrementWrap = 7
}
enum class  rex::xenos::BlendFactor : u32 {
  kZero = 0 , kOne = 1 , kSrcColor = 4 , kOneMinusSrcColor = 5 ,
  kSrcAlpha = 6 , kOneMinusSrcAlpha = 7 , kDstColor = 8 , kOneMinusDstColor = 9 ,
  kDstAlpha = 10 , kOneMinusDstAlpha = 11 , kConstantColor = 12 , kOneMinusConstantColor = 13 ,
  kConstantAlpha = 14 , kOneMinusConstantAlpha = 15 , kSrcAlphaSaturate = 16
}
enum class  rex::xenos::BlendOp : u32 {
  kAdd = 0 , kSubtract = 1 , kMin = 2 , kMax = 3 ,
  kRevSubtract = 4
}
enum class  InvalidateMask : u16 { kVertexShader = 1 << 8 , kPixelShader = 1 << 9 , kAll = 0x7FFF }
enum class  rex::xenos::SourceSelect : u32 { kDMA , kImmediate , kAutoIndex }
enum class  rex::xenos::MajorMode : u32 { kImplicit , kExplicit }
enum class  rex::xenos::SignedRepeatingFractionMode : u32 { kZeroClampMinusOne , kNoZero }
enum class  rex::xenos::ArbitraryFilter : u32 {
  k2x4Sym = 0 , k2x4Asym = 1 , k4x2Sym = 2 , k4x2Asym = 3 ,
  k4x4Sym = 4 , k4x4Asym = 5 , kUseFetchConst = 7
}
enum class  rex::xenos::VertexShaderExportMode : u32 {
  kPosition1Vector = 0 , kPosition2VectorsSprite = 2 , kPosition2VectorsEdge = 3 , kPosition2VectorsKill = 4 ,
  kPosition2VectorsSpriteKill = 5 , kPosition2VectorsEdgeKill = 6 , kMultipass = 7
}
enum class  rex::xenos::SampleControl : u32 { kCentroidsOnly = 0 , kCentersOnly = 1 , kCentroidsAndCenters = 2 }
enum class  rex::xenos::VGTOutputPath : u32 { kVertexReuse = 0 , kTessellationEnable = 1 , kPassthru = 2 }
enum class  TessellationMode : u32 { kDiscrete = 0 , kContinuous = 1 , kAdaptive = 2 }
enum class  rex::xenos::PolygonModeEnable : u32 { kDisabled = 0 , kDualMode = 1 }
enum class  PolygonType : u32 { kPoints = 0 , kLines = 1 , kTriangles = 2 }
enum class  rex::xenos::PixelCenter : u32 { kD3DZero = 0 , kOGLHalf = 1 }
enum class  rex::xenos::VertexRounding : u32 { kTruncate = 0 , kRound = 1 , kRoundToEven = 2 , kRoundToOdd = 3 }
enum class  VertexQuantization : u32 {
  k_1_16th = 0 , k_1_8th = 1 , k_1_4th = 2 , k_1_2 = 3 ,
  k_1 = 4
}
enum class  rex::xenos::EDRAMMode : u32 { kNoOperation = 0 , kColorDepth = 4 , kDepthOnly = 5 , kCopy = 6 }
enum class  CopyCommand : u32 { kRaw = 0 , kConvert = 1 , kConstantOne = 2 , kNull = 3 }
enum class  rex::xenos::CopySampleSelect : u32 {
  k0 , k1 , k2 , k3 ,
  k01 , k23 , k0123
}

Functions

constexpr u32 rex::xenos::GetSurfacePitchTiles (u32 pitch_pixels, MSAASamples msaa_samples, bool is_64bpp)
bool rex::xenos::IsMajorModeExplicit (MajorMode major_mode, PrimitiveType primitive_type)
u32 rex::xenos::GetInterpolatorSamplingPattern (MSAASamples msaa_samples, SampleControl sample_control, u32 interpolator_control_sampling_pattern)
constexpr bool rex::xenos::IsSingleCopySampleSelected (CopySampleSelect copy_sample_select)

Variables

constexpr u32 rex::xenos::kVertexIndexBits = 24
constexpr u32 rex::xenos::kVertexIndexMask = (static_cast<u32>(1) << kVertexIndexBits) - 1
constexpr u32 rex::xenos::kMSAASamplesBits = 2
constexpr u32 rex::xenos::kColorRenderTargetIndexBits = 2
constexpr u32 rex::xenos::kMaxColorRenderTargets = 4
constexpr f32 rex::xenos::kPolygonOffsetScaleSubpixelUnit = 1.0f / 16.0f
constexpr u32 rex::xenos::kEDRAMTileWidthSamples = 80
constexpr u32 rex::xenos::kEDRAMTileHeightSamples = 16
constexpr u32 rex::xenos::kEDRAMTileCount = 2048
constexpr u32 rex::xenos::kEDRAMSizeBytes
constexpr u32 rex::xenos::kEDRAMPitchPixelsBits = 14
constexpr u32 rex::xenos::kEDRAMBaseTilesBits = 11
constexpr u32 rex::xenos::kEDRAMPitchTilesBits = 10
constexpr u32 rex::xenos::kMaxShaderTempRegistersLog2 = 6
constexpr u32 rex::xenos::kMaxShaderTempRegisters = UINT32_C(1) << kMaxShaderTempRegistersLog2
constexpr u32 rex::xenos::kMaxInterpolators = 16
constexpr u32 rex::xenos::kResolveAlignmentPixelsLog2 = 3
constexpr u32 rex::xenos::kResolveAlignmentPixels = 1 << kResolveAlignmentPixelsLog2
constexpr u32 rex::xenos::kResolveSizeBits = 14
constexpr u32 rex::xenos::kMaxResolveSize = (1 << kResolveSizeBits) - kResolveAlignmentPixels

Detailed Description

Xenos pipeline state, shader and EDRAM enums.

License
BSD 3-Clause License See LICENSE file in the project root for full license text.
Remarks
Derived from Xenia's xenia/gpu/xenos.h (Ben Vanik, 2020).

Enumeration Type Documentation

◆ ArbitraryFilter

enum class rex::xenos::ArbitraryFilter : u32
strong

Arbitrary texture filter kernel. Deprecated in the R400 documentation.

Enumerator
kUseFetchConst 

Use the kernel from the fetch constant.

◆ BlendFactor

enum class rex::xenos::BlendFactor : u32
strong

Blend factor (adreno_rb_blend_factor).

◆ BlendOp

enum class rex::xenos::BlendOp : u32
strong
Enumerator
kRevSubtract 

Destination minus source.

◆ CopySampleSelect

enum class rex::xenos::CopySampleSelect : u32
strong

Samples a resolve reads (a2xx_rb_copy_sample_select).

Enumerator
k01 

Average of samples 0 and 1.

k23 

Average of samples 2 and 3.

k0123 

Average of samples 0 to 3.

◆ EDRAMMode

enum class rex::xenos::EDRAMMode : u32
strong
Enumerator
kDepthOnly 

The pixel shader is treated as unused.

◆ MajorMode

enum class rex::xenos::MajorMode : u32
strong

Major mode of a draw (VGT_DRAW_INITIATOR::DI_MAJOR_MODE).

◆ MSAASamples

enum class rex::xenos::MSAASamples : u32
strong
Enumerator
k2X 

1x2 samples per pixel.

k4X 

2x2 samples per pixel.

◆ PixelCenter

enum class rex::xenos::PixelCenter : u32
strong

Pixel center convention (PA_SU_VTX_CNTL::pix_center).

Enumerator
kD3DZero 

Center at .0, as in Direct3D 9.

kOGLHalf 

Center at .5, as in OpenGL.

◆ PolygonModeEnable

enum class rex::xenos::PolygonModeEnable : u32
strong

Polygon mode enable. Only kDualMode applies the front and back polygon types.

Enumerator
kDisabled 

Renders filled triangles.

◆ PrimitiveType

enum class rex::xenos::PrimitiveType : u32
strong

Primitive type of a draw. Types from kExplicitMajorModeForceStart force explicit major mode.

Enumerator
kRectangleList 

Three vertices per rectangle.

kLinePatch 

Used with tessellation enabled.

kTrianglePatch 

Used with tessellation enabled.

kQuadPatch 

Used with tessellation enabled.

◆ SampleControl

enum class rex::xenos::SampleControl : u32
strong

Interpolation sample location control (SQ_CONTEXT_MISC::sc_sample_cntl).

Enumerator
kCentroidsAndCenters 

Per interpolator, from the sampling pattern.

◆ SignedRepeatingFractionMode

enum class rex::xenos::SignedRepeatingFractionMode : u32
strong

Signed normalized value mapping.

Enumerator
kZeroClampMinusOne 

Two representations of -1, one of them clamped.

kNoZero 

Alternate mapping with no representation for 0.

◆ SourceSelect

enum class rex::xenos::SourceSelect : u32
strong

Index source of a draw (VGT_DRAW_INITIATOR::DI_SRC_SEL).

Enumerator
kDMA 

Indices fetched from memory.

kAutoIndex 

Indices generated by the GPU.

◆ VertexRounding

enum class rex::xenos::VertexRounding : u32
strong
Enumerator
kTruncate 

Truncate, as in OpenGL.

kRoundToEven 

Round to even, as in Direct3D.

◆ VertexShaderExportMode

enum class rex::xenos::VertexShaderExportMode : u32
strong

Vertex shader export mode (a2xx_sq_ps_vtx_mode).

Enumerator
kMultipass 

Outputs ignored and all primitives killed.

◆ VGTOutputPath

enum class rex::xenos::VGTOutputPath : u32
strong

VGT output path (VGT_OUTPUT_PATH_CNTL::path_select).

Function Documentation

◆ GetInterpolatorSamplingPattern()

u32 rex::xenos::GetInterpolatorSamplingPattern ( MSAASamples msaa_samples,
SampleControl sample_control,
u32 interpolator_control_sampling_pattern )
inline

Returns one SampleLocation bit per interpolator, set for kCenter.

Parameters
msaa_samplesRB_SURFACE_INFO::msaa_samples.
sample_controlSQ_CONTEXT_MISC::sc_sample_cntl.
interpolator_control_sampling_patternSQ_INTERPOLATOR_CNTL::sampling_pattern.

◆ GetSurfacePitchTiles()

u32 rex::xenos::GetSurfacePitchTiles ( u32 pitch_pixels,
MSAASamples msaa_samples,
bool is_64bpp )
constexpr

Returns the EDRAM row pitch of a surface in tiles.

Parameters
pitch_pixelsSurface pitch in pixels.
msaa_samplesSample count of the surface.
is_64bppTrue for 64 bits per sample.

◆ IsMajorModeExplicit()

bool rex::xenos::IsMajorModeExplicit ( MajorMode major_mode,
PrimitiveType primitive_type )
inline

Reports whether a draw uses explicit major mode.

Returns
True when the mode is explicit or the primitive type forces it.

◆ IsSingleCopySampleSelected()

bool rex::xenos::IsSingleCopySampleSelected ( CopySampleSelect copy_sample_select)
constexpr

Reports whether a resolve reads a single sample.

Returns
True when the selection is k0, k1, k2 or k3.

Variable Documentation

◆ kEDRAMBaseTilesBits

u32 rex::xenos::kEDRAMBaseTilesBits = 11
constexpr

Usable width of RB_COLOR_INFO::color_base and RB_DEPTH_INFO::depth_base.

◆ kEDRAMPitchPixelsBits

u32 rex::xenos::kEDRAMPitchPixelsBits = 14
constexpr

Width of RB_SURFACE_INFO::surface_pitch.

◆ kEDRAMPitchTilesBits

u32 rex::xenos::kEDRAMPitchTilesBits = 10
constexpr

Bits needed for the largest GetSurfacePitchTiles result with a 16383 pixel pitch.

◆ kEDRAMSizeBytes

u32 rex::xenos::kEDRAMSizeBytes
constexpr
Initial value:
= static_cast<u32>(u64{kEDRAMTileCount} * kEDRAMTileHeightSamples *
kEDRAMTileWidthSamples * sizeof(u32))
constexpr u32 kEDRAMTileHeightSamples
Definition state.h:86
constexpr u32 kEDRAMTileCount
Definition state.h:88
constexpr u32 kEDRAMTileWidthSamples
Definition state.h:84

◆ kEDRAMTileCount

u32 rex::xenos::kEDRAMTileCount = 2048
constexpr

Tile addressing wraps around at this count.

◆ kEDRAMTileHeightSamples

u32 rex::xenos::kEDRAMTileHeightSamples = 16
constexpr

EDRAM tile height in 32bpp samples.

◆ kEDRAMTileWidthSamples

u32 rex::xenos::kEDRAMTileWidthSamples = 80
constexpr

EDRAM tile width in 32bpp samples.

◆ kPolygonOffsetScaleSubpixelUnit

f32 rex::xenos::kPolygonOffsetScaleSubpixelUnit = 1.0f / 16.0f
constexpr

Scale from PA_SU_POLY_OFFSET_FRONT/BACK_SCALE subpixel units to pixel units.

◆ kResolveSizeBits

u32 rex::xenos::kResolveSizeBits = 14
constexpr

Width of RB_SURFACE_INFO::surface_pitch and the RB_COPY_DEST_PITCH fields.

◆ kVertexIndexBits

u32 rex::xenos::kVertexIndexBits = 24
constexpr

Number of low vertex index bits the GPU uses.