L3DT users' wiki
Large 3D terrain generator

Scripts > Sapphire debug v2

Description A script to test the different rendering modules in Sapphire and log the frame render times.
Author Aaron
Created 2014/09/10
Requires L3DT v11.11 or later
Download sapphire_debug_v2.zs

About

This script is included with L3DT v14.09 or later. Prior releases of L3DT included an older version of this script, which did not include frame render time logging.

Script contents

//
// Declare variables
//

bool TempBool
hvar pHF pWM pTX
int cnt
int cntmax
set cntmax 10
int Start End difftime

//
// Test maps
//

set pHF <GetMap "HF">
set pWM <GetMap "WM">
set pTX <GetMap "TX">

assert <cast bool <map.GetWidth pHF>> "Heightfield is not initialised!"

echo "Sapphire debug v2"
echo <strcat " - HF is " <strcat <map.GetWidth pHF> <strcat " x " <map.GetHeight pHF>>>>
echo <strcat " - HF horiz scale is " <strcat <map.GetHorizScale pHF> "m">>
float minalt maxalt
assert <map.GetMinMaxAlt pHF minalt maxalt> "Cannot get heightfield min/max altitude!"
echo <strcat " - HF vert range is " <strcat minalt <strcat " ... " <strcat maxalt "m">>>>
if <map.GetWidth pTX>
  echo <strcat " - TX is " <strcat <map.GetWidth pTX> <strcat " x " <map.GetHeight pTX>>>>
endif


//
// disable all modules (e.g. textures, lighting, fog)
// 

set TempBool false
Sapphire.SetParam "Skybox.IsShown" TempBool
Sapphire.SetParam "Terrain.DetailMap.IsShown" TempBool
Sapphire.SetParam "Terrain.ElevLUT.EnableFlag" TempBool
Sapphire.SetParam "WaterMap.IsShown" TempBool
Sapphire.SetParam "Atmosphere.FogEnabled" TempBool
Sapphire.SetParam "Lighting.EnableFlag" TempBool
Sapphire.SetParam "UI.CursorMesh.IsShown" TempBool

//
// Test with all options disabled
//
MessageBox "Starting test 1: all disabled" 64
echo "Starting test 1: all disabled"
Sapphire.SetPause true
Sapphire.ShowWndEx pHF pWM pTX 8
set cnt 0
do
  set Start <system.time.GetTickCount>
  Sapphire.RenderFrame 0
  set End <system.time.GetTickCount>
    set difftime <sub End Start>
  echo <strcat "Frame " <strcat cnt <strcat " rendered in " <strcat difftime "ms">>>>
while <islt <incr cnt> cntmax>
Sapphire.SetPause false
MessageBox "Closing test 1: all disabled" 64
Sapphire.HideWnd

//
// Test elev LUT
//
MessageBox "Starting test 2: ElevLUT" 64
echo "Starting test 2: ElevLUT"
Sapphire.SetPause true
set TempBool true
Sapphire.SetParam "Terrain.ElevLUT.EnableFlag" TempBool
Sapphire.ShowWndEx pHF pWM pTX 8
set cnt 0
do
  set Start <system.time.GetTickCount>
  Sapphire.RenderFrame 0
  set End <system.time.GetTickCount>
    set difftime <sub End Start>
  echo <strcat "Frame " <strcat cnt <strcat " rendered in " <strcat difftime "ms">>>>
while <islt <incr cnt> cntmax>
Sapphire.SetPause false
MessageBox "Closing test 2: ElevLUT" 64
Sapphire.HideWnd
//set TempBool false
//Sapphire.SetParam "Terrain.ElevLUT.EnableFlag" TempBool

//
// Test lighting map
//
MessageBox "Starting test 3: lighting" 64
echo "Starting test 3: lighting"
Sapphire.SetPause true
set TempBool true
Sapphire.SetParam "Lighting.EnableFlag" TempBool
Sapphire.ShowWndEx pHF pWM pTX 8
set cnt 0
do
  set Start <system.time.GetTickCount>
  Sapphire.RenderFrame 0
  set End <system.time.GetTickCount>
    set difftime <sub End Start>
  echo <strcat "Frame " <strcat cnt <strcat " rendered in " <strcat difftime "ms">>>>
while <islt <incr cnt> cntmax>
Sapphire.SetPause false
MessageBox "Closing test 3: lighting" 64
Sapphire.HideWnd
//set TempBool false
//Sapphire.SetParam "Lighting.EnableFlag" TempBool

//
// Test fog
//
MessageBox "Starting test 4: fog" 64
echo "Starting test 4: fog"
Sapphire.SetPause true
set TempBool true
Sapphire.SetParam "Atmosphere.FogEnabled" TempBool
Sapphire.ShowWndEx pHF pWM pTX 8
set cnt 0
do
  set Start <system.time.GetTickCount>
  Sapphire.RenderFrame 0
  set End <system.time.GetTickCount>
    set difftime <sub End Start>
  echo <strcat "Frame " <strcat cnt <strcat " rendered in " <strcat difftime "ms">>>>
while <islt <incr cnt> cntmax>
Sapphire.SetPause false
MessageBox "Closing test 4: fog" 64
Sapphire.HideWnd
//set TempBool false
//Sapphire.SetParam "Atmosphere.FogEnabled" TempBool

//
// Test skybox
//
MessageBox "Starting test 5: skybox" 64
echo "Starting test 5: skybox"
Sapphire.SetPause true
set TempBool true
Sapphire.SetParam "Skybox.IsShown" TempBool
Sapphire.ShowWndEx pHF pWM pTX 8
set cnt 0
do
  set Start <system.time.GetTickCount>
  Sapphire.RenderFrame 0
  set End <system.time.GetTickCount>
    set difftime <sub End Start>
  echo <strcat "Frame " <strcat cnt <strcat " rendered in " <strcat difftime "ms">>>>
while <islt <incr cnt> cntmax>
Sapphire.SetPause false
MessageBox "Closing test 5: skybox" 64
Sapphire.HideWnd
//set TempBool false
//Sapphire.SetParam "Skybox.IsShown" TempBool

//
// Test terrain texture
//
if <cast bool <map.GetWidth pTX>>
  MessageBox "Starting test 6: terrain texture" 64
  echo "Starting test 6: terrain texture"
  Sapphire.SetPause true
  Sapphire.ShowWndEx pHF pWM pTX 16
  set cnt 0
	do
	  set Start <system.time.GetTickCount>
	  Sapphire.RenderFrame 0
	  set End <system.time.GetTickCount>
		set difftime <sub End Start>
	  echo <strcat "Frame " <strcat cnt <strcat " rendered in " <strcat difftime "ms">>>>
	while <islt <incr cnt> cntmax>
	Sapphire.SetPause false
  MessageBox "Closing test 6: terrain texture" 64
  Sapphire.HideWnd
else
  MessageBox "Skipping test 6: terrain texture (no texture map)" 64
endif

//
// Test detail map
//
MessageBox "Starting test 7: detail map" 64
echo "Starting test 7: detail map"
Sapphire.SetPause true
set TempBool true
Sapphire.SetParam "Terrain.DetailMap.IsShown" TempBool
Sapphire.ShowWndEx pHF pWM pTX 16
set cnt 0
do
  set Start <system.time.GetTickCount>
  Sapphire.RenderFrame 0
  set End <system.time.GetTickCount>
    set difftime <sub End Start>
  echo <strcat "Frame " <strcat cnt <strcat " rendered in " <strcat difftime "ms">>>>
while <islt <incr cnt> cntmax>
Sapphire.SetPause false
MessageBox "Closing test 7: detail map" 64
Sapphire.HideWnd
//set TempBool false
//Sapphire.SetParam "Terrain.DetailMap.IsShown" TempBool

//
// Test water map
//
if <cast bool <map.GetWidth pWM>>
  MessageBox "Starting test 8: water texture" 64
  echo "Starting test 8: water texture"
  Sapphire.SetPause true
  set TempBool true
  Sapphire.SetParam "WaterMap.IsShown" TempBool
  Sapphire.ShowWndEx pHF pWM pTX 16
  set cnt 0
	do
	  set Start <system.time.GetTickCount>
	  Sapphire.RenderFrame 0
	  set End <system.time.GetTickCount>
		set difftime <sub End Start>
	  echo <strcat "Frame " <strcat cnt <strcat " rendered in " <strcat difftime "ms">>>>
	while <islt <incr cnt> cntmax>
	Sapphire.SetPause false
  MessageBox "Closing test 8: water texture" 64
  Sapphire.HideWnd
//  set TempBool false
//  Sapphire.SetParam "WaterMap.IsShown" TempBool
else
  MessageBox "Skipping test 8: water texture (no water map)" 64
endif

//
// Test mesh object
//
MessageBox "Starting test 9: cursor mesh" 64
echo "Starting test 9: cursor mesh"
Sapphire.SetPause true
set TempBool true
Sapphire.SetParam "UI.CursorMesh.IsShown" TempBool
Sapphire.ShowWndEx pHF pWM pTX 16
set cnt 0
do
  set Start <system.time.GetTickCount>
  Sapphire.RenderFrame 0
  set End <system.time.GetTickCount>
    set difftime <sub End Start>
  echo <strcat "Frame " <strcat cnt <strcat " rendered in " <strcat difftime "ms">>>>
while <islt <incr cnt> cntmax>
Sapphire.SetPause false
MessageBox "Closing test 9: cursor mesh" 64
Sapphire.HideWnd
//set TempBool false
//Sapphire.SetParam "UI.CursorMesh.IsShown" TempBool

//
// all together now
//
MessageBox "Starting test 10: all modules" 64
echo "Starting test 10: all modules"
Sapphire.SetPause true
set TempBool true
Sapphire.SetParam "Skybox.IsShown" TempBool
Sapphire.SetParam "Terrain.DetailMap.IsShown" TempBool
Sapphire.SetParam "Terrain.ElevLUT.EnableFlag" TempBool
Sapphire.SetParam "WaterMap.IsShown" TempBool
Sapphire.SetParam "Atmosphere.FogEnabled" TempBool
Sapphire.SetParam "Lighting.EnableFlag" TempBool
Sapphire.SetParam "UI.CursorMesh.IsShown" TempBool
Sapphire.ShowWndEx pHF pWM pTX 16
set cnt 0
do
  set Start <system.time.GetTickCount>
  Sapphire.RenderFrame 0
  set End <system.time.GetTickCount>
    set difftime <sub End Start>
  echo <strcat "Frame " <strcat cnt <strcat " rendered in " <strcat difftime "ms">>>>
while <islt <incr cnt> 20>
Sapphire.SetPause false
MessageBox "Closing test 10: all modules" 64
Sapphire.HideWnd

MessageBox "All modules OK!" 64

return true
 
scripts/sapphire_debug_v2.txt · Last modified: 2017/08/31 06:30 (external edit)
 
Except where otherwise noted, content on this wiki is licensed under the following license:CC Attribution-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki