xash3d-fwgs/ref/vk/NOTES.md

2.9 KiB

Frame structure wrt calls from the engine

  • (eng) SCR_UpdateScreen()
    • (eng) V_PreRender()
      • (ref) R_BeginFrame()
    • (eng) V_RenderView()
      • (ref) GL_BackendStartFrame() -- ref_gl only sets speeds string to empty here
        • (eng) loop over ref_params_t views
          • (ref) GL_RenderFrame()
        • (eng) ??? SV_DrawDebugTriangles()
      • (ref) GL_BackendEndFrame() -- ref_gl only produces speeds string here
    • (eng) V_PostRender()
      • (ref) R_AllowFog(), R_Set2DMode(true)
      • (ref) R_DrawTileClear() x N
      • (vgui) Paint() -> ???
      • (eng) SCR_RSpeeds()
        • (ref) R_SpeedsMessage()
        • (eng) CL_DrawString() ...
          • (ref) GL_SetRenderMode()
            • (ref) RefGetParm() for texture resolution
            • (ref) Color4ub()
            • (ref) R_DrawStretchPic()
      • (eng) SRC_DrawNetGraph()
        • (ref) many TriApi calls -- 2D usage of triapi. we were not ready for this (maybe track R_Set2DMode()?)
      • (ref) R_ShowTextures() kekw
      • (ref) VID_ScreenShot()
      • (ref) R_AllowFog(true)
      • (ref) R_EndFrame()

Staging and multiple command buffers

We want to get rid of extra command buffers used for staging (and building blases). That would mean tying any command-buffer related things in there to framectl. However, there are several staging cmdbuf usages which are technically out-of-band wrt framectl: 0. Staging data can get full, which requires sync flush: filling cmdbuf outside of frame (or while still building a frame), submitting it and waiting on it.

  1. Texture uploading. There's an explicit usage of staging cmdbuf in vk_texture to do layout transfer. This layout transfer can be moved to staging itself.
  2. BLAS building. Creating a ray model uploads its geometry via staging and then immediately builds its BLAS on the same staging cmdbuf. Ideally(?), we'd like to split BLAS building to some later stage to do it in bulk.

OpenGL-like immediate mode rendering, ~TriApi

Functions:

R_Set2DMode(bool) -- switches between 3D scene and 2D overlay modes; used in engine
R_DrawStretchRaw,
R_DrawStretchPic,
R_DrawTileClear,
CL_FillRGBA,
CL_FillRGBABlend,

R_AllowFog,
GL_SetRenderMode,

void		(*GL_Bind)( int tmu, unsigned int texnum );
void		(*GL_SelectTexture)( int tmu );

void		(*GL_LoadTextureMatrix)( const float *glmatrix ); -- exported to the game, not used in engine
void		(*GL_TexMatrixIdentity)( void ); -- exported to the game, not used in engine

void		(*GL_CleanUpTextureUnits)( int last );	// pass 0 for clear all the texture units
void		(*GL_TexGen)( unsigned int coord, unsigned int mode );
void		(*GL_TextureTarget)( unsigned int target ); // change texture unit mode without bind texture
void		(*GL_TexCoordArrayMode)( unsigned int texmode );
void		(*GL_UpdateTexSize)( int texnum, int width, int height, int depth ); // recalc statistics

TriRenderMode,
TriBegin,
TriEnd,
TriColor4f,
TriColor4ub,
TriTexCoord2f,
TriVertex3fv,
TriVertex3f,
TriFog,
TriGetMatrix,
TriFogParams,
TriCullFace,