nxdk_pgraph_tests
A collection of tests for the Xbox nv2a graphics processor
 
Loading...
Searching...
No Matches
TestHost Class Reference

#include <test_host.h>

Classes

struct  AlphaInput
 
struct  ColorInput
 
struct  CombinerInput
 
struct  NegativeOneInput
 
struct  OneInput
 
struct  ZeroInput
 

Public Types

enum  VertexAttribute {
  POSITION = 1 << NV2A_VERTEX_ATTR_POSITION , WEIGHT = 1 << NV2A_VERTEX_ATTR_WEIGHT , NORMAL = 1 << NV2A_VERTEX_ATTR_NORMAL , DIFFUSE = 1 << NV2A_VERTEX_ATTR_DIFFUSE ,
  SPECULAR = 1 << NV2A_VERTEX_ATTR_SPECULAR , FOG_COORD = 1 << NV2A_VERTEX_ATTR_FOG_COORD , POINT_SIZE = 1 << NV2A_VERTEX_ATTR_POINT_SIZE , BACK_DIFFUSE = 1 << NV2A_VERTEX_ATTR_BACK_DIFFUSE ,
  BACK_SPECULAR = 1 << NV2A_VERTEX_ATTR_BACK_SPECULAR , TEXCOORD0 = 1 << NV2A_VERTEX_ATTR_TEXTURE0 , TEXCOORD1 = 1 << NV2A_VERTEX_ATTR_TEXTURE1 , TEXCOORD2 = 1 << NV2A_VERTEX_ATTR_TEXTURE2 ,
  TEXCOORD3 = 1 << NV2A_VERTEX_ATTR_TEXTURE3 , V13 = 1 << NV2A_VERTEX_ATTR_13 , V14 = 1 << NV2A_VERTEX_ATTR_14 , V15 = 1 << NV2A_VERTEX_ATTR_15
}
 
enum  DrawPrimitive {
  PRIMITIVE_POINTS = NV097_SET_BEGIN_END_OP_POINTS , PRIMITIVE_LINES = NV097_SET_BEGIN_END_OP_LINES , PRIMITIVE_LINE_LOOP = NV097_SET_BEGIN_END_OP_LINE_LOOP , PRIMITIVE_LINE_STRIP = NV097_SET_BEGIN_END_OP_LINE_STRIP ,
  PRIMITIVE_TRIANGLES = NV097_SET_BEGIN_END_OP_TRIANGLES , PRIMITIVE_TRIANGLE_STRIP = NV097_SET_BEGIN_END_OP_TRIANGLE_STRIP , PRIMITIVE_TRIANGLE_FAN = NV097_SET_BEGIN_END_OP_TRIANGLE_FAN , PRIMITIVE_QUADS = NV097_SET_BEGIN_END_OP_QUADS ,
  PRIMITIVE_QUAD_STRIP = NV097_SET_BEGIN_END_OP_QUAD_STRIP , PRIMITIVE_POLYGON = NV097_SET_BEGIN_END_OP_POLYGON
}
 Enumerates the rendering primitives supported by the NV2A.
 
enum  CombinerSource {
  SRC_ZERO = 0 , SRC_C0 , SRC_C1 , SRC_FOG ,
  SRC_DIFFUSE , SRC_SPECULAR , SRC_6 , SRC_7 ,
  SRC_TEX0 , SRC_TEX1 , SRC_TEX2 , SRC_TEX3 ,
  SRC_R0 , SRC_R1 , SRC_SPEC_R0_SUM , SRC_EF_PROD
}
 
enum  CombinerDest {
  DST_DISCARD = 0 , DST_C0 , DST_C1 , DST_FOG ,
  DST_DIFFUSE , DST_SPECULAR , DST_6 , DST_7 ,
  DST_TEX0 , DST_TEX1 , DST_TEX2 , DST_TEX3 ,
  DST_R0 , DST_R1 , DST_SPEC_R0_SUM , DST_EF_PROD
}
 
enum  CombinerSumMuxMode { SM_SUM = 0 , SM_MUX = 1 }
 
enum  CombinerOutOp {
  OP_IDENTITY = 0 , OP_BIAS = 1 , OP_SHIFT_LEFT_1 = 2 , OP_SHIFT_LEFT_1_BIAS = 3 ,
  OP_SHIFT_LEFT_2 = 4 , OP_SHIFT_RIGHT_1 = 6
}
 
enum  CombinerMapping {
  MAP_UNSIGNED_IDENTITY , MAP_UNSIGNED_INVERT , MAP_EXPAND_NORMAL , MAP_EXPAND_NEGATE ,
  MAP_HALFBIAS_NORMAL , MAP_HALFBIAS_NEGATE , MAP_SIGNED_IDENTITY , MAP_SIGNED_NEGATE
}
 
enum  PaletteSize { PALETTE_32 = 32 , PALETTE_64 = 64 , PALETTE_128 = 128 , PALETTE_256 = 256 }
 Palette size for palettized surfaces.
 
enum  ShaderStageProgram {
  STAGE_NONE = 0 , STAGE_2D_PROJECTIVE , STAGE_3D_PROJECTIVE , STAGE_CUBE_MAP ,
  STAGE_PASS_THROUGH , STAGE_CLIP_PLANE , STAGE_BUMPENVMAP , STAGE_BUMPENVMAP_LUMINANCE ,
  STAGE_BRDF , STAGE_DOT_ST , STAGE_DOT_ZW , STAGE_DOT_REFLECT_DIFFUSE ,
  STAGE_DOT_REFLECT_SPECULAR , STAGE_DOT_STR_3D , STAGE_DOT_STR_CUBE , STAGE_DEPENDENT_AR ,
  STAGE_DEPENDENT_GB , STAGE_DOT_PRODUCT , STAGE_DOT_REFLECT_SPECULAR_CONST
}
 Texture unit modes.
 
enum  AntiAliasingSetting { AA_CENTER_1 = NV097_SET_SURFACE_FORMAT_ANTI_ALIASING_CENTER_1 , AA_CENTER_CORNER_2 = NV097_SET_SURFACE_FORMAT_ANTI_ALIASING_CENTER_CORNER_2 , AA_SQUARE_OFFSET_4 = NV097_SET_SURFACE_FORMAT_ANTI_ALIASING_SQUARE_OFFSET_4 }
 Antialiasing settings for surfaces.
 
enum  SurfaceColorFormat {
  SCF_X1R5G5B5_Z1R5G5B5 = NV097_SET_SURFACE_FORMAT_COLOR_LE_X1R5G5B5_Z1R5G5B5 , SCF_X1R5G5B5_O1R5G5B5 = NV097_SET_SURFACE_FORMAT_COLOR_LE_X1R5G5B5_O1R5G5B5 , SCF_R5G6B5 = NV097_SET_SURFACE_FORMAT_COLOR_LE_R5G6B5 , SCF_X8R8G8B8_Z8R8G8B8 = NV097_SET_SURFACE_FORMAT_COLOR_LE_X8R8G8B8_Z8R8G8B8 ,
  SCF_X8R8G8B8_O8R8G8B8 = NV097_SET_SURFACE_FORMAT_COLOR_LE_X8R8G8B8_O8R8G8B8 , SCF_X1A7R8G8B8_Z1A7R8G8B8 = NV097_SET_SURFACE_FORMAT_COLOR_LE_X1A7R8G8B8_Z1A7R8G8B8 , SCF_X1A7R8G8B8_O1A7R8G8B8 = NV097_SET_SURFACE_FORMAT_COLOR_LE_X1A7R8G8B8_O1A7R8G8B8 , SCF_A8R8G8B8 = NV097_SET_SURFACE_FORMAT_COLOR_LE_A8R8G8B8 ,
  SCF_B8 = NV097_SET_SURFACE_FORMAT_COLOR_LE_B8 , SCF_G8B8 = NV097_SET_SURFACE_FORMAT_COLOR_LE_G8B8
}
 Color formats for surfaces.
 
enum  SurfaceZetaFormat { SZF_Z16 = NV097_SET_SURFACE_FORMAT_ZETA_Z16 , SZF_Z24S8 = NV097_SET_SURFACE_FORMAT_ZETA_Z24S8 }
 Depth buffer formats for surfaces.
 

Public Member Functions

 TestHost (std::shared_ptr< FTPLogger > ftp_logger, uint32_t framebuffer_width, uint32_t framebuffer_height, uint32_t max_texture_width, uint32_t max_texture_height, uint32_t max_texture_depth=4)
 
TextureStageGetTextureStage (uint32_t stage)
 
void SetTextureFormat (const TextureFormatInfo &fmt, uint32_t stage=0)
 
void SetDefaultTextureParams (uint32_t stage=0)
 
int SetTexture (SDL_Surface *surface, uint32_t stage=0)
 
int SetVolumetricTexture (const SDL_Surface **surface, uint32_t depth, uint32_t stage=0)
 
int SetRawTexture (const uint8_t *source, uint32_t width, uint32_t height, uint32_t depth, uint32_t pitch, uint32_t bytes_per_pixel, bool swizzle, uint32_t stage=0)
 
int SetPalette (const uint32_t *palette, PaletteSize size, uint32_t stage=0)
 
void SetPaletteSize (PaletteSize size, uint32_t stage=0)
 
void SetTextureStageEnabled (uint32_t stage, bool enabled=true)
 
void SetSurfaceFormat (SurfaceColorFormat color_format, SurfaceZetaFormat depth_format, uint32_t width, uint32_t height, bool swizzle=false, uint32_t clip_x=0, uint32_t clip_y=0, uint32_t clip_width=0, uint32_t clip_height=0, AntiAliasingSetting aa=AA_CENTER_1)
 
void SetSurfaceFormatImmediate (SurfaceColorFormat color_format, SurfaceZetaFormat depth_format, uint32_t width, uint32_t height, bool swizzle=false, uint32_t clip_x=0, uint32_t clip_y=0, uint32_t clip_width=0, uint32_t clip_height=0, AntiAliasingSetting aa=AA_CENTER_1)
 
SurfaceColorFormat GetColorBufferFormat () const
 Returns the current surface color format.
 
SurfaceZetaFormat GetDepthBufferFormat () const
 Returns the current depth buffer format.
 
void SetDepthBufferFloatMode (bool enabled)
 Changes the current depth buffer mode into float (true) or fixed integer (false).
 
bool GetDepthBufferFloatMode () const
 Returns true if the current depth buffer mode is floating point.
 
void CommitSurfaceFormat () const
 
uint32_t GetMaxTextureWidth () const
 Returns the maximum width for a texture.
 
uint32_t GetMaxTextureHeight () const
 Returns the maximum height for a texture.
 
uint32_t GetMaxTextureDepth () const
 Returns the maximum depth for a texture.
 
uint32_t GetMaxSingleTextureSize () const
 Returns the maximum size in bytes that any single texture can be.
 
uint8_t * GetTextureMemory () const
 Returns the base of texture memory.
 
uint32_t GetTextureMemorySize () const
 Returns the allocated size of the entire texture memory region.
 
uint8_t * GetTextureMemoryForStage (uint32_t stage) const
 Returns the base of texture memory used by the given texture unit (stage).
 
uint32_t * GetPaletteMemoryForStage (uint32_t stage) const
 Returns the base of the palette memory for an indexed texture used by the given texture unit.
 
uint32_t GetFramebufferWidth () const
 Returns the width of the screen, in pixels.
 
uint32_t GetFramebufferHeight () const
 Returns the height of the screen, in pixels.
 
float GetFramebufferWidthF () const
 Returns the width of the screen in pixels as a float.
 
float GetFramebufferHeightF () const
 Returns the height of the screen in pixels as a float.
 
std::shared_ptr< VertexBufferAllocateVertexBuffer (uint32_t num_vertices)
 Allocates a VertexBuffer large enough to hold the given number of vertices.
 
void SetVertexBuffer (std::shared_ptr< VertexBuffer > buffer)
 Sets the active vertex buffer.
 
std::shared_ptr< VertexBufferGetVertexBuffer ()
 Returns the active vertex buffer.
 
void ClearVertexBuffer ()
 Removes the active vertex buffer.
 
void Clear (uint32_t argb=0xFF000000, uint32_t depth_value=0xFFFFFFFF, uint8_t stencil_value=0x00) const
 Clears the active surface and pb_text overlay.
 
void ClearDepthStencilRegion (uint32_t depth_value, uint8_t stencil_value, uint32_t left=0, uint32_t top=0, uint32_t width=0, uint32_t height=0) const
 Sets the contents of a rect within the depth/stencil buffer.
 
void ClearColorRegion (uint32_t argb, uint32_t left=0, uint32_t top=0, uint32_t width=0, uint32_t height=0) const
 Sets the color of a rect within the active surface.
 
void PrepareDraw (uint32_t argb=0xFF000000, uint32_t depth_value=0xFFFFFFFF, uint8_t stencil_value=0x00)
 
void DrawArrays (uint32_t enabled_vertex_fields=kDefaultVertexFields, DrawPrimitive primitive=PRIMITIVE_TRIANGLES)
 
void DrawInlineBuffer (uint32_t enabled_vertex_fields=kDefaultVertexFields, DrawPrimitive primitive=PRIMITIVE_TRIANGLES)
 
void DrawInlineArray (uint32_t enabled_vertex_fields=kDefaultVertexFields, DrawPrimitive primitive=PRIMITIVE_TRIANGLES)
 Sends vertices as an interleaved array of vertex fields. E.g., [POS_0,DIFFUSE_0,POS_1,DIFFUSE_1,...].
 
void DrawInlineElements16 (const std::vector< uint32_t > &indices, uint32_t enabled_vertex_fields=kDefaultVertexFields, DrawPrimitive primitive=PRIMITIVE_TRIANGLES)
 Sends vertices via an index array. Index values must be < 0xFFFF and are sent two per command.
 
void DrawInlineElements32 (const std::vector< uint32_t > &indices, uint32_t enabled_vertex_fields=kDefaultVertexFields, DrawPrimitive primitive=PRIMITIVE_TRIANGLES)
 Sends vertices via an index array. Index values are unsigned integers.
 
void FinishDraw (bool allow_saving, const std::string &output_directory, const std::string &suite_name, const std::string &name, bool save_zbuffer=false)
 Marks drawing as completed, potentially causing artifacts (framebuffer, z/stencil-buffer) to be saved to disk.
 
void SetDepthClip (float min, float max) const
 Sets the z clipping range.
 
void SetVertexShaderProgram (std::shared_ptr< VertexShaderProgram > program)
 Sets the active vertex shader. Pass nullptr to use the fixed function pipeline.
 
std::shared_ptr< VertexShaderProgramGetShaderProgram () const
 Returns the active vertex shader.
 
void BuildD3DProjectionViewportMatrix (matrix4_t &result, float fov, float z_near, float z_far) const
 Gets a Direct3D-style matrix suitable for a projection + viewport transform.
 
void BuildDefaultXDKProjectionMatrix (matrix4_t &matrix) const
 Gets a reasonable default projection matrix (fov = PI/4, near = 1, far = 200) similar to the one used by the XDK.
 
const matrix4_t & GetFixedFunctionInverseCompositeMatrix () const
 Returns the inverse composite matrix for the fixed function pipeline.
 
void SetXDKDefaultViewportAndFixedFunctionMatrices ()
 Set up the viewport and fixed function pipeline matrices to match a default XDK project.
 
void SetDefaultViewportAndFixedFunctionMatrices ()
 Set up the viewport and fixed function pipeline matrices to match the nxdk settings.
 
void ProjectPoint (vector_t &result, const vector_t &world_point) const
 Projects the given point (on the CPU), placing the resulting screen coordinates into result.
 
void UnprojectPoint (vector_t &result, const vector_t &screen_point) const
 Unprojects a point in screenspace into 3D worldspace.
 
void UnprojectPoint (vector_t &result, const vector_t &screen_point, float world_z) const
 Unprojects a point in screenspace into 3D worldspace, setting Z to the given value.
 
void SetFixedFunctionModelViewMatrix (const matrix4_t &model_matrix)
 
void SetFixedFunctionProjectionMatrix (const matrix4_t &projection_matrix)
 
const matrix4_t & GetFixedFunctionModelViewMatrix () const
 
const matrix4_t & GetFixedFunctionProjectionMatrix () const
 
float GetWNear () const
 
float GetWFar () const
 
void Begin (DrawPrimitive primitive) const
 
void End () const
 Triggers the rendering of the primitive specified by the previous call to Begin.
 
void SetVertex (float x, float y, float z) const
 Trigger creation of a vertex, applying the last set attributes.
 
void SetVertex (float x, float y, float z, float w) const
 Trigger creation of a vertex, applying the last set attributes.
 
void SetVertex (const vector_t pt) const
 Trigger creation of a vertex, applying the last set attributes.
 
void SetScreenVertex (float x, float y, float screen_z) const
 Unprojects the given coordinates and calls SetVertex.
 
void SetScreenVertex (float x, float y) const
 Unprojects the given coordinates and calls SetVertex.
 
void SetWeight (float w) const
 
void SetWeight (float w1, float w2) const
 
void SetWeight (float w1, float w2, float w3) const
 
void SetWeight (float w1, float w2, float w3, float w4) const
 
void SetNormal (float x, float y, float z) const
 
void SetNormal (const float *vals) const
 
void SetNormal3S (int x, int y, int z) const
 
void SetDiffuse (const vector_t &color) const
 
void SetDiffuse (float r, float g, float b, float a) const
 
void SetDiffuse (float r, float g, float b) const
 
void SetDiffuse (uint32_t rgba) const
 
void SetSpecular (const vector_t &color) const
 
void SetSpecular (float r, float g, float b, float a) const
 
void SetSpecular (float r, float g, float b) const
 
void SetSpecular (uint32_t rgba) const
 
void SetFogCoord (float fc) const
 
void SetPointSize (float ps) const
 
void SetTexCoord0 (float u, float v) const
 
void SetTexCoord0S (int u, int v) const
 
void SetTexCoord0 (float s, float t, float p, float q) const
 
void SetTexCoord0S (int s, int t, int p, int q) const
 
void SetTexCoord1 (float u, float v) const
 
void SetTexCoord1S (int u, int v) const
 
void SetTexCoord1 (float s, float t, float p, float q) const
 
void SetTexCoord1S (int s, int t, int p, int q) const
 
void SetTexCoord2 (float u, float v) const
 
void SetTexCoord2S (int u, int v) const
 
void SetTexCoord2 (float s, float t, float p, float q) const
 
void SetTexCoord2S (int s, int t, int p, int q) const
 
void SetTexCoord3 (float u, float v) const
 
void SetTexCoord3S (int u, int v) const
 
void SetTexCoord3 (float s, float t, float p, float q) const
 
void SetTexCoord3S (int s, int t, int p, int q) const
 
void SetBackDiffuse (uint32_t rgba) const
 
void SetBackDiffuse (const float *vals) const
 
void SetBackDiffuse (float r, float g, float b, float a=1.f) const
 
void SetBackSpecular (uint32_t rgba) const
 
void SetBackSpecular (const float *vals) const
 
void SetBackSpecular (float r, float g, float b, float a=1.f) const
 
bool GetSaveResults () const
 Returns the current override flag to allow/prevent artifact saving.
 
void SetSaveResults (bool enable=true)
 Sets the override flag to prevent artifact saving during FinishDraw.
 
void SetColorMask (uint32_t mask=NV097_SET_COLOR_MASK_BLUE_WRITE_ENABLE|NV097_SET_COLOR_MASK_GREEN_WRITE_ENABLE|NV097_SET_COLOR_MASK_RED_WRITE_ENABLE|NV097_SET_COLOR_MASK_ALPHA_WRITE_ENABLE) const
 Sets the mask used to enable modification of various color channels during rendering.
 
void SetBlend (bool enable=true, uint32_t func=NV097_SET_BLEND_EQUATION_V_FUNC_ADD, uint32_t sfactor=NV097_SET_BLEND_FUNC_SFACTOR_V_SRC_ALPHA, uint32_t dfactor=NV097_SET_BLEND_FUNC_DFACTOR_V_ONE_MINUS_SRC_ALPHA) const
 Determines how pixels should be blended with existing pixels during rendering operations.
 
void SetBlendColorConstant (uint32_t color) const
 Sets the blend color (and alpha) used by the V_CONSTANT_COLOR and V_CONSTANT_ALPHA blend factors.
 
void SetAlphaReference (uint32_t color) const
 Sets the alpha reference value (NV097_SET_ALPHA_REF) used by NV097_SET_ALPHA_FUNC.
 
void SetAlphaFunc (bool enable=true, uint32_t func=NV097_SET_ALPHA_FUNC_V_ALWAYS) const
 Sets the alpha function used to mask writes based on alpha values.
 
void SetCombinerControl (int num_combiners=1, bool same_factor0=false, bool same_factor1=false, bool mux_msb=false) const
 
void SetInputColorCombiner (int combiner, CombinerInput a, CombinerInput b=ZeroInput(), CombinerInput c=ZeroInput(), CombinerInput d=ZeroInput()) const
 See https://github.com/abaire/nxdk_pgraph_tests/wiki/nv2a-pixel-shaders-(combiner-stages)
 
void SetInputColorCombiner (int combiner, CombinerSource a_source=SRC_ZERO, bool a_alpha=false, CombinerMapping a_mapping=MAP_UNSIGNED_IDENTITY, CombinerSource b_source=SRC_ZERO, bool b_alpha=false, CombinerMapping b_mapping=MAP_UNSIGNED_IDENTITY, CombinerSource c_source=SRC_ZERO, bool c_alpha=false, CombinerMapping c_mapping=MAP_UNSIGNED_IDENTITY, CombinerSource d_source=SRC_ZERO, bool d_alpha=false, CombinerMapping d_mapping=MAP_UNSIGNED_IDENTITY) const
 See https://github.com/abaire/nxdk_pgraph_tests/wiki/nv2a-pixel-shaders-(combiner-stages)
 
void ClearInputColorCombiner (int combiner) const
 
void ClearInputColorCombiners () const
 
void SetInputAlphaCombiner (int combiner, CombinerInput a, CombinerInput b=ZeroInput(), CombinerInput c=ZeroInput(), CombinerInput d=ZeroInput()) const
 See https://github.com/abaire/nxdk_pgraph_tests/wiki/nv2a-pixel-shaders-(combiner-stages)
 
void SetInputAlphaCombiner (int combiner, CombinerSource a_source=SRC_ZERO, bool a_alpha=false, CombinerMapping a_mapping=MAP_UNSIGNED_IDENTITY, CombinerSource b_source=SRC_ZERO, bool b_alpha=false, CombinerMapping b_mapping=MAP_UNSIGNED_IDENTITY, CombinerSource c_source=SRC_ZERO, bool c_alpha=false, CombinerMapping c_mapping=MAP_UNSIGNED_IDENTITY, CombinerSource d_source=SRC_ZERO, bool d_alpha=false, CombinerMapping d_mapping=MAP_UNSIGNED_IDENTITY) const
 See https://github.com/abaire/nxdk_pgraph_tests/wiki/nv2a-pixel-shaders-(combiner-stages)
 
void ClearInputAlphaColorCombiner (int combiner) const
 
void ClearInputAlphaCombiners () const
 
void SetOutputColorCombiner (int combiner, CombinerDest ab_dst=DST_DISCARD, CombinerDest cd_dst=DST_DISCARD, CombinerDest sum_dst=DST_DISCARD, bool ab_dot_product=false, bool cd_dot_product=false, CombinerSumMuxMode sum_or_mux=SM_SUM, CombinerOutOp op=OP_IDENTITY, bool alpha_from_ab_blue=false, bool alpha_from_cd_blue=false) const
 See https://github.com/abaire/nxdk_pgraph_tests/wiki/nv2a-pixel-shaders-(combiner-stages)
 
void ClearOutputColorCombiner (int combiner) const
 
void ClearOutputColorCombiners () const
 
void SetOutputAlphaCombiner (int combiner, CombinerDest ab_dst=DST_DISCARD, CombinerDest cd_dst=DST_DISCARD, CombinerDest sum_dst=DST_DISCARD, bool ab_dot_product=false, bool cd_dot_product=false, CombinerSumMuxMode sum_or_mux=SM_SUM, CombinerOutOp op=OP_IDENTITY) const
 See https://github.com/abaire/nxdk_pgraph_tests/wiki/nv2a-pixel-shaders-(combiner-stages)
 
void ClearOutputAlphaColorCombiner (int combiner) const
 
void ClearOutputAlphaCombiners () const
 
void SetFinalCombiner0Just (CombinerSource d_source, bool d_alpha=false, bool d_invert=false)
 
void SetFinalCombiner0 (CombinerSource a_source=SRC_ZERO, bool a_alpha=false, bool a_invert=false, CombinerSource b_source=SRC_ZERO, bool b_alpha=false, bool b_invert=false, CombinerSource c_source=SRC_ZERO, bool c_alpha=false, bool c_invert=false, CombinerSource d_source=SRC_ZERO, bool d_alpha=false, bool d_invert=false)
 See https://github.com/abaire/nxdk_pgraph_tests/wiki/nv2a-pixel-shaders-(combiner-stages)
 
void SetFinalCombiner1Just (CombinerSource g_source, bool g_alpha=false, bool g_invert=false)
 
void SetFinalCombiner1 (CombinerSource e_source=SRC_ZERO, bool e_alpha=false, bool e_invert=false, CombinerSource f_source=SRC_ZERO, bool f_alpha=false, bool f_invert=false, CombinerSource g_source=SRC_ZERO, bool g_alpha=false, bool g_invert=false, bool specular_add_invert_r0=false, bool specular_add_invert_v1=false, bool specular_clamp=false)
 See https://github.com/abaire/nxdk_pgraph_tests/wiki/nv2a-pixel-shaders-(combiner-stages)
 
void SetCombinerFactorC0 (int combiner, uint32_t value) const
 
void SetCombinerFactorC0 (int combiner, float red, float green, float blue, float alpha) const
 
void SetCombinerFactorC1 (int combiner, uint32_t value) const
 
void SetCombinerFactorC1 (int combiner, float red, float green, float blue, float alpha) const
 
void SetFinalCombinerFactorC0 (uint32_t value) const
 
void SetFinalCombinerFactorC0 (float red, float green, float blue, float alpha) const
 
void SetFinalCombinerFactorC1 (uint32_t value) const
 
void SetFinalCombinerFactorC1 (float red, float green, float blue, float alpha) const
 
std::pair< uint32_t, uint32_t > GetFinalCombinerState () const
 
void RestoreFinalCombinerState (const std::pair< uint32_t, uint32_t > &state)
 
void SetShaderStageProgram (ShaderStageProgram stage_0, ShaderStageProgram stage_1=STAGE_NONE, ShaderStageProgram stage_2=STAGE_NONE, ShaderStageProgram stage_3=STAGE_NONE) const
 
void SetShaderStageInput (uint32_t stage_2_input=0, uint32_t stage_3_input=0) const
 
void SetVertexBufferAttributes (uint32_t enabled_fields)
 
void OverrideVertexAttributeStride (VertexAttribute attribute, uint32_t stride)
 
void ClearVertexAttributeStrideOverride (VertexAttribute attribute)
 Clears any previously set vertex attribute stride override for the given attribute.
 
void ClearAllVertexAttributeStrideOverrides ()
 Clears all vertex attribute stride overrides.
 
void SetupControl0 (bool enable_stencil_write=true, bool w_buffered=false, bool texture_perspective_enable=true) const
 Set up the control0 register, controlling stencil writing and depth buffer mode.
 
void SetupTextureStages () const
 
std::string SaveZBuffer (const std::string &output_directory, const std::string &name) const
 Saves the Z/Stencil buffer to the filesystem/.
 
float GetMaxDepthBufferValue () const
 Returns the maximum value for the current depth buffer format.
 
void DrawCheckerboardUnproject (uint32_t first_color=0xFF00FFFF, uint32_t second_color=0xFF000000, uint32_t checker_size=8)
 

Static Public Member Functions

static bool SurfaceSupportsAlpha (SurfaceColorFormat fmt)
 
static uint32_t GetSurfaceColorPitch (SurfaceColorFormat fmt, uint32_t width)
 Returns the pitch (bytes per row) for the given format and width in pixels.
 
static void EraseText ()
 Erases the pb_text overlay.
 
static void BuildD3DModelViewMatrix (matrix4_t &matrix, const vector_t &eye, const vector_t &at, const vector_t &up)
 Generates a Direct3D-style model view matrix.
 
static void BuildD3DOrthographicProjectionMatrix (matrix4_t &result, float left, float right, float top, float bottom, float z_near, float z_far)
 Builds an orthographic projection matrix.
 
static void BuildDefaultXDKModelViewMatrix (matrix4_t &matrix)
 
static void SetWindowClipExclusive (bool exclusive)
 Toggles whether window clipping considers the rect as inclusive or exclusive.
 
static void SetWindowClip (uint32_t right, uint32_t bottom, uint32_t left=0, uint32_t top=0, uint32_t region=0)
 Sets the window clipping region.
 
static void SetViewportOffset (float x, float y, float z, float w)
 
static void SetViewportScale (float x, float y, float z, float w)
 
static std::string GetPrimitiveName (DrawPrimitive primitive)
 Returns a human-friendly name for the given DrawPrimitive.
 
static std::string SaveTexture (const std::string &output_directory, const std::string &name, const uint8_t *texture, uint32_t width, uint32_t height, uint32_t pitch, uint32_t bits_per_pixel, SDL_PixelFormatEnum format)
 Saves the given texture to the filesystem as a PNG file.
 
static std::string SaveRawTexture (const std::string &output_directory, const std::string &name, const uint8_t *texture, uint32_t width, uint32_t height, uint32_t pitch, uint32_t bits_per_pixel)
 Saves the given region of memory as a flat binary file.
 
static float MaxDepthBufferValue (uint32_t depth_buffer_format, bool float_mode)
 Returns the maximum possible value that can be stored in the depth surface for the given mode.
 
static float NV2ARound (float input)
 Rounds the given integer in the same way as nv2a hardware (only remainders >= 9/16th are rounded up).
 
static void EnsureFolderExists (const std::string &folder_path)
 Creates the given directory if it does not already exist.
 
static void WaitForGPU ()
 Inserts a pushbuffer command to await idle.
 
static void PBKitBusyWait ()
 Does a busywait.
 
static void PBKitFlushPushbufer ()
 

Static Public Attributes

static constexpr uint32_t kDefaultVertexFields = POSITION | DIFFUSE | TEXCOORD0
 

Detailed Description

Provides utility methods for use by TestSuite subclasses.

Member Function Documentation

◆ Begin()

void TestHost::Begin ( DrawPrimitive  primitive) const

Start the process of rendering an inline-defined primitive (specified via SetXXXX methods below). Note that End() must be called to trigger rendering, and that SetVertex() triggers the creation of a vertex.

◆ BuildDefaultXDKModelViewMatrix()

void TestHost::BuildDefaultXDKModelViewMatrix ( matrix4_t &  matrix)
static

Gets a reasonable default model view matrix (camera at z=-7.0f looking at the origin) similar to the one used by the XDK.

◆ DrawCheckerboardUnproject()

void TestHost::DrawCheckerboardUnproject ( uint32_t  first_color = 0xFF00FFFF,
uint32_t  second_color = 0xFF000000,
uint32_t  checker_size = 8 
)

Renders a 256x256 checkerboard pattern that is stretched and unprojected to fill the framebuffer.

Note: this leaves the tex0 stage disabled, disables all shader stage programs, and sets the final combiner to SRC_R0

◆ OverrideVertexAttributeStride()

void TestHost::OverrideVertexAttributeStride ( TestHost::VertexAttribute  attribute,
uint32_t  stride 
)

Overrides the default calculation of stride for a vertex attribute. "0" is special cased by the hardware to cause all reads for the attribute to be serviced by the first value in the buffer.

◆ PBKitFlushPushbufer()

static void TestHost::PBKitFlushPushbufer ( )
inlinestatic

Waits for the pushbuffer to empty then resets it to head.

It is illegal to call this within a pb_begin/pb_end block, doing so may crash or lead to undefined behavior.

◆ PrepareDraw()

void TestHost::PrepareDraw ( uint32_t  argb = 0xFF000000,
uint32_t  depth_value = 0xFFFFFFFF,
uint8_t  stencil_value = 0x00 
)

Note: A number of states are expected to be set before this method is called. E.g., texture stages, shader states This is not an exhaustive list and is not necessarily up to date. Prefer to call this just before initiating draw and be suspect of order dependence if you see results that seem to indicate that settings are being ignored.

◆ SetBackDiffuse()

void TestHost::SetBackDiffuse ( uint32_t  rgba) const

Sets the back diffuse color for the current vertex. NOTE: unlike most vertex attributes, there does not appear to be an explicit command to set this value, so it is set via NV097_SET_VERTEX_DATA4UB.

◆ SetBackSpecular()

void TestHost::SetBackSpecular ( uint32_t  rgba) const

Sets the back specular color for the current vertex. NOTE: unlike most vertex attributes, there does not appear to be an explicit command to set this value, so it is set via NV097_SET_VERTEX_DATA4UB.

◆ SetCombinerControl()

void TestHost::SetCombinerControl ( int  num_combiners = 1,
bool  same_factor0 = false,
bool  same_factor1 = false,
bool  mux_msb = false 
) const

Sets up the number of enabled color combiners and behavior flags.

same_factor0 == true will reuse the C0 constant across all enabled stages. same_factor1 == true will reuse the C1 constant across all enabled stages.

◆ SetShaderStageInput()

void TestHost::SetShaderStageInput ( uint32_t  stage_2_input = 0,
uint32_t  stage_3_input = 0 
) const

Sets the input for shader stage 2 and 3. The value is the 0 based index of the stage whose output should be linked. E.g., to have stage2 use stage1's input and stage3 use stage2's the params would be (1, 2).

◆ SetShaderStageProgram()

void TestHost::SetShaderStageProgram ( ShaderStageProgram  stage_0,
ShaderStageProgram  stage_1 = STAGE_NONE,
ShaderStageProgram  stage_2 = STAGE_NONE,
ShaderStageProgram  stage_3 = STAGE_NONE 
) const

Sets the type of texture sampling for each texture.

If you have a totally blank texture, double check that this is set to something other than STAGE_NONE.

◆ SetupTextureStages()

void TestHost::SetupTextureStages ( ) const

Commit any changes to texture stages (called automatically in PrepareDraw but may be useful to call more frequently in scenes with multiple draws per clear)


The documentation for this class was generated from the following files: