Browse Source

Delete needless unittests

pull/112/head
nillerusr 2 years ago
parent
commit
d8f5cdfd3c
  1. 25
      unittests/autotestscripts/check_debug_dlls.pl
  2. 15
      unittests/autotestscripts/check_dynamic_shader_compile.pl
  3. BIN
      unittests/autotestscripts/datafiles/gwolf.tga
  4. 16
      unittests/autotestscripts/filecompare_tests.cfg
  5. 6
      unittests/autotestscripts/reference_output/file_size_monitor.txt
  6. 3
      unittests/autotestscripts/reference_output/mathlib_test.txt
  7. 6
      unittests/autotestscripts/reference_output/rt_test.txt
  8. 1
      unittests/autotestscripts/reference_output/testprocess.txt
  9. BIN
      unittests/autotestscripts/reference_output/vtex.vtf
  10. 181
      unittests/autotestscripts/run_file_comparison_tests.pl
  11. 40
      unittests/autotestscripts/subtests/file_size_monitor.pl
  12. 13
      unittests/autotestscripts/test_error_reporting.pl
  13. 36
      unittests/autotestscripts/test_shader_crcs.pl
  14. 69
      unittests/autotestscripts/verify_compiled_sheet_files_match_src.pl
  15. BIN
      unittests/autotestscripts_graphics/keyimages/abovewater.tga
  16. BIN
      unittests/autotestscripts_graphics/keyimages/belowwater.tga
  17. BIN
      unittests/autotestscripts_graphics/keyimages/mat_fullbright_1.tga
  18. BIN
      unittests/autotestscripts_graphics/keyimages/mat_fullbright_2.tga
  19. BIN
      unittests/autotestscripts_graphics/keyimages/mat_luxels_1.tga
  20. BIN
      unittests/autotestscripts_graphics/keyimages/mat_showmiplevels_1.tga
  21. BIN
      unittests/autotestscripts_graphics/keyimages/mat_showmiplevels_2.tga
  22. BIN
      unittests/autotestscripts_graphics/keyimages/mat_wireframe_1.tga
  23. 36
      unittests/autotestscripts_graphics/rendering_regression_test.pl
  24. 233
      unittests/avitest/avitest.cpp
  25. 27
      unittests/avitest/avitest.vpc
  26. 250
      unittests/inputtest/inputtest.cpp
  27. 24
      unittests/inputtest/inputtest.vpc
  28. 492
      unittests/materialsystemtest/materialsystemtest.cpp
  29. 24
      unittests/materialsystemtest/materialsystemtest.vpc
  30. 79
      unittests/mathlib_test/mathlib_test.cpp
  31. 38
      unittests/mathlib_test/mathlib_test.vpc
  32. 1056
      unittests/shaderapitest/shaderapitest.cpp
  33. 25
      unittests/shaderapitest/shaderapitest.vpc
  34. 306
      unittests/soundtest/soundtest.cpp
  35. 24
      unittests/soundtest/soundtest.vpc
  36. 191
      unittests/testprocess/testprocess.cpp
  37. BIN
      unittests/testprocess/testprocess.exe
  38. BIN
      unittests/testprocess/testprocess.pdb
  39. 38
      unittests/testprocess/testprocess.vpc

25
unittests/autotestscripts/check_debug_dlls.pl

@ -1,25 +0,0 @@ @@ -1,25 +0,0 @@
#!perl
use File::Find;
use Win32::API;
find(\&ProcessFile, "../../../game/bin/" );
sub ProcessFile
{
return if (/360/);
return unless( /\.dll$/i );
my $LoadLibrary = Win32::API->new( "kernel32", "LoadLibrary","P","L" );
my $GetProcAddress = Win32::API->new( "kernel32", "GetProcAddress","LP","L" );
my $FreeLibrary = Win32::API->new( "kernel32", "FreeLibrary", "P", "V" );
my $handle=$LoadLibrary->Call($_);
if ( $handle )
{
my $proc = $GetProcAddress->Call($handle, "BuiltDebug\0");
if ( $proc )
{
print "Error $_ is built debug\n";
}
$FreeLibrary->Call( $handle );
}
}

15
unittests/autotestscripts/check_dynamic_shader_compile.pl

@ -1,15 +0,0 @@ @@ -1,15 +0,0 @@
#!perl
open(DLL,"../../../game/bin/shaderapidx9.dll" ) || die "can't open shaderapi";
binmode DLL;
my $dllcode = do { local( $/ ) ; <DLL> } ; # slurp comparison output in
close DLL;
if ( $dllcode =~ /dynamic_shader_compile_is_on/s )
{
open(ERRORS,">errors.txt") || die "huh - can't write";
print ERRORS "stdshader_dx9.dll was built with dynamic shader compile!\n";
close ERRORS;
}

BIN
unittests/autotestscripts/datafiles/gwolf.tga

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.0 MiB

16
unittests/autotestscripts/filecompare_tests.cfg

@ -1,16 +0,0 @@ @@ -1,16 +0,0 @@
// this config file defines all unit tests which are run by running a program and comparing its output to reference output
// which is checked in in the directory src/unittests/autotestscripts/reference_output
// the format of entries is TESTNAME,OUTPUTFILE,COMMAND-LINE-TO-EXECUTE
// if the OUTPUTFILE part is blank, it assumes the test is meant to compare the output of stdio
file_size_monitor,,perl subtests/file_size_monitor.pl
testprocess,,..\testprocess\testprocess -message "testprocess autotest1"
vtex,gwolf.vtf,vtex -outdir . -nopause -nop4 -crcforce datafiles\gwolf.tga
rt_test,,..\rt_test\rt_test ..\rt_test\gwolf.tga test 1024 1024
// mathlib_test,,..\mathlib_test\mathlib_test

6
unittests/autotestscripts/reference_output/file_size_monitor.txt

@ -1,6 +0,0 @@ @@ -1,6 +0,0 @@
Running file size monitor
PC shader size := 291934326
PC Game Bin DLL size := 108442741
360 shader size := 0
360 Game Bin DLL size := 0
tf texture size := 1396651036

3
unittests/autotestscripts/reference_output/mathlib_test.txt

@ -1,3 +0,0 @@ @@ -1,3 +0,0 @@
right spherical triangle projected percentage=0.1250
small spherical triangle projected percentage=0.00156
sum of areas of cubemap cells = 1.00

6
unittests/autotestscripts/reference_output/rt_test.txt

@ -1,6 +0,0 @@ @@ -1,6 +0,0 @@
reading src texture
n triangles 1567238
Creating kd-tree
kd built time := 79
Rendering
pixels traced and lit per second := 1559694.998968

1
unittests/autotestscripts/reference_output/testprocess.txt

@ -1 +0,0 @@ @@ -1 +0,0 @@
testprocess autotest1

BIN
unittests/autotestscripts/reference_output/vtex.vtf

Binary file not shown.

181
unittests/autotestscripts/run_file_comparison_tests.pl

@ -1,181 +0,0 @@ @@ -1,181 +0,0 @@
#!perl
# read stdio_test_list.cfg and perform all tests
$create_refs=0;
$subset_string=shift;
@months = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec);
@weekDays = qw(Sun Mon Tue Wed Thu Fri Sat Sun);
($second, $minute, $hour, $dayOfMonth, $month, $yearOffset, $dayOfWeek, $dayOfYear, $daylightSavings) = localtime();
$year = 1900 + $yearOffset;
$dstamp = "$weekDays[$dayOfWeek] $months[$month] $dayOfMonth $year".sprintf(" %02d:%02d:%02d", $hour,$minute,$second);
$changelist_counter=`p4 counter main_changelist`; # grab value of p4 counter
$dstamp.=" $changelist_counter";
$dstamp=~ s/[\n\r]//g;
$computername=$ENV{'COMPUTERNAME'};
# first, set our priority to high and affinity to 1 to try to get more repeatable benchmark results
#my $pid = $$;
#my $cmd="datafiles\\process.exe -p $pid High";
#print STDERR `$cmd`;
#$cmd="datafiles\\process.exe -a $pid 01";
#print STDERR `$cmd`;
if ( open(CFGFILE, "filecompare_tests.cfg") )
{
while(<CFGFILE>)
{
s/[\n\r]//g;
s@//.*$@@; # kill comments
if (/^([^,]*),([^,]*),(.*$)/)
{
$testname=$1;
$testfile=$2;
$testcommand=$3;
next if ( length($subset_string) && ( ! ( $testname=~/$subset_string/i) ) );
$ext=".txt";
if ( length($testfile ) )
{
$ext="";
$ext = $1 if ( $testfile=~/(\..*)$/ ); # copy extension
unlink $testfile if ( -e $testfile); # kill it if it exists
}
print STDOUT "running $testname : $testcommand ($testfile)\n";
# suck the reference output in. use binary mode unless stdio
$refname="reference_output/$testname$ext";
# run the test
my $stime=time;
$output=`$testcommand`;
$stime=time-$stime;
if ( open(REF,$refname))
{
if ( length($testfile ))
{
binmode REF;
}
$ref_output= do { local( $/ ) ; <REF> } ; # slurp comparison output in
close REF;
if ( length( $testfile ) )
{
print STDERR $output;
# file case
if ( open(TESTFILE, $testfile ))
{
binmode TESTFILE;
$new_output= do { local( $/ ) ; <TESTFILE> } ; # slurp comparison output in
close TESTFILE;
if ($new_output ne $ref_output )
{
$errout.="ERROR: test $testname ($testcommand) : test produced file $testfile (length=".
length($new_output).") but it doesn't match the reference (length=".length($ref_output).")\n";
}
else
{
&UpdateMetrics( $testname, $output, $stime );
}
}
else
{
$errout.="ERROR: test $testname ($testcommand) : test was supposed to create $testfile, but didn't.\n";
}
}
else
{
# strip metrics (like timing) for comparison
my $massaged_ref = $ref_output;
my $massaged_output = $output;
$massaged_ref =~ s/:=\s*[0-9\.]+//g;
$massaged_output =~ s/:=\s*[0-9\.]+//g;
if ($massaged_output ne $massaged_ref )
{
# print STDERR "o=$massaged_output r=$massaged_ref\n";
$errout.="ERROR: test $testname ($testcommand) : output does not match reference output.\n";
}
else
{
&UpdateMetrics( $testname, $output, $stime );
}
}
}
else
{
$errout.="ERROR: Can't open reference $refname for $testname\n";
if ($create_refs)
{
if ( length($testfile ) )
{
if ( -e $testfile )
{
$oname=$refname;
$oname=~s@/@\\@g;
print STDERR "copy $testfile $oname";
print STDERR `copy $testfile $oname`;
print STDERR `p4 add $oname`;
}
}
else
{
if ( open(REFOUT,">$refname") )
{
print REFOUT $output;
}
close REFOUT;
print STDERR `p4 add $refname`;
}
}
}
}
}
}
else
{
$errout.="Can't open stdio_test_list.cfg\n";
}
if (length($errout))
{
print STDERR "There were errors: $errout";
open(ERRORS,">errors.txt") || die "huh - can't write";
print ERRORS $errout;
close ERRORS;
}
sub UpdateMetrics
{
return unless length($computername);
local( $tname, $output, $runtime) = @_;
$output .= "\ntest runtime := $runtime\n";
foreach $_ ( split(/\n/,$output))
{
if (/^(.+):=(.*$)/)
{
my $varname=$1;
my $etime=$2;
$varname=~s@^\s*@@g;
$varname=~s@\s*$@@g;
mkdir "\\\\fileserver\\user\\perf\\$computername";
mkdir "\\\\fileserver\\user\\perf\\$computername\\$tname";
if ( open(COUT,">>\\\\fileserver\\user\\perf\\$computername\\$tname\\$varname.csv") )
{
print COUT "\"$dstamp\",$etime\n";
close COUT;
}
}
}
}

40
unittests/autotestscripts/subtests/file_size_monitor.pl

@ -1,40 +0,0 @@ @@ -1,40 +0,0 @@
#!perl
use File::Find;
# customize here
print "Running file size monitor\n";
LogDirectorySize("PC shader size", "../../../game/hl2/shaders","\.vcs","\.360\.vcs");
LogDirectorySize("PC Game Bin DLL size", "../../../game/bin/","\.dll","_360\.dll");
LogDirectorySize("360 shader size", "../../../game/hl2/shaders","\.360\.vcs");
LogDirectorySize("360 Game Bin DLL size", "../../../game/bin/","_360\.dll");
LogDirectorySize("tf texture size","../../../game/tf/materials/","\.vtf");
sub LogDirectorySize
{
my ($label, $basedir, $filepattern, $excludepattern ) = @_;
undef @FileList;
find(\&ProcessFile, $basedir);
my $total_size = 0;
foreach $_ (@FileList)
{
next if ( length($excludepattern) && ( /$excludepattern/i ) );
if (/$filepattern/i)
{
$total_size += (-s $_ );
}
}
print "$label := $total_size\n";
}
sub ProcessFile
{
push @FileList, $File::Find::name;
}

13
unittests/autotestscripts/test_error_reporting.pl

@ -1,13 +0,0 @@ @@ -1,13 +0,0 @@
#! perl
$errfname="//fileserver/user/cgreen/force_an_error.txt";
if (-e $errfname )
{
unlink $errfname;
open(ERROUT,">errors.txt") || die "huh - can't write";
{
print ERROUT "This is not an error - its just a test of the error script system.\n";
close ERROUT;
}
}

36
unittests/autotestscripts/test_shader_crcs.pl

@ -1,36 +0,0 @@ @@ -1,36 +0,0 @@
use Cwd;
my $dir = getcwd;
chdir "../../materialsystem/stdshaders";
@output = `perl ..\\..\\devtools\\bin\\checkshaderchecksums.pl stdshader_dx9_20b.txt`;
foreach $_ (@output)
{
$output.=$_ unless(/appchooser360/i);
}
@output = `perl ..\\..\\devtools\\bin\\checkshaderchecksums.pl stdshader_dx9_30.txt`;
foreach $_ (@output)
{
$output.=$_ unless(/appchooser360/i);
}
my $errors;
foreach $_ (@output )
{
$errors.=$_ unless (/appchooser360movie/);
}
chdir $dir;
print $errors;
if( length( $errors ) > 0 )
{
print "writing errors.txt\n";
open FP, ">errors.txt";
print FP "$errors";
close FP;
}

69
unittests/autotestscripts/verify_compiled_sheet_files_match_src.pl

@ -1,69 +0,0 @@ @@ -1,69 +0,0 @@
#! perl
use File::Find;
use Cwd;
use File::Basename;
# find(\&Visitfile,"../../../content/tf");
foreach $_ ( @sheetfiles )
{
$dest_sheet_name=$_;
$dest_sheet_name =~ s/\.mks/.sht/i;
$dest_sheet_name =~ s@/content/([^/]+)/materialsrc/@/game/\1/materials/@gi;
print "**Checking $_\n";
if (! -e $dest_sheet_name )
{
push @errors,"sheet $_ exists but not $dest_sheet_name";
}
else
{
# buid it and make sure they match
$cmd="cd ".dirname($_)." & mksheet ".basename($_)." test.sht";
$cmd=~tr/\//\\/;
$cmdout=`$cmd`;
if ( open(NEWFILE, dirname($_)."/test.sht") )
{
binmode NEWFILE;
open(OLDFILE, $dest_sheet_name ) || die "strange error - cant find $dest_sheet_name";
binmode OLDFILE;
{
local( $/, *FH ) ;
$old_data=<OLDFILE>;
$new_data=<NEWFILE>;
if ( $new_data ne $old_data )
{
push @errors,"Sheet source file $_ does not compile to the same output as the checked in $dest_sheet_name";
}
close OLDFILE;
close NEWFILE;
unlink dirname($_)."/test.sht";
}
}
else
{
push @errors, "Couldn't compile sheet $_ by running $cmd : \n$cmdout";
}
}
}
$errout=join("\n", @errors);
print $errout;
if (length($errout))
{
open(ERRFILE,">errors.txt") || die "can't write errors.txt";
print ERRFILE $errout;
close ERRFILE;
}
sub Visitfile
{
local($_)= $File::Find::name;
s@\\@\/@g;
if (m@content/(\S+)/.*\.mks$@i)
{
push @sheetfiles, $_;
}
}

BIN
unittests/autotestscripts_graphics/keyimages/abovewater.tga

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 MiB

BIN
unittests/autotestscripts_graphics/keyimages/belowwater.tga

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 MiB

BIN
unittests/autotestscripts_graphics/keyimages/mat_fullbright_1.tga

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 MiB

BIN
unittests/autotestscripts_graphics/keyimages/mat_fullbright_2.tga

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 MiB

BIN
unittests/autotestscripts_graphics/keyimages/mat_luxels_1.tga

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 MiB

BIN
unittests/autotestscripts_graphics/keyimages/mat_showmiplevels_1.tga

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 MiB

BIN
unittests/autotestscripts_graphics/keyimages/mat_showmiplevels_2.tga

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 MiB

BIN
unittests/autotestscripts_graphics/keyimages/mat_wireframe_1.tga

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 MiB

36
unittests/autotestscripts_graphics/rendering_regression_test.pl

@ -1,36 +0,0 @@ @@ -1,36 +0,0 @@
use Cwd;
my $dir = getcwd;
chdir "../../../game";
if( 1 )
{
system "rd /s /q ep2\\screenshots";
system "mkdir ep2\\screenshots";
@output = `hl2.exe -allowdebug -autoconfig -console -toconsole -dev -sw -width 1024 -game ep2 -testscript rendering_regression_test.vtest`;
}
$keydir = "\\\\fileserver\\user\\rendering_regression_test";
open TESTSCRIPT, "<ep2/testscripts/rendering_regression_test.vtest" || die;
foreach $line (<TESTSCRIPT>)
{
$line =~ s,//.*,,g; # remove comments
if( $line =~ m/\s*screenshot\s+(.*)$/i )
{
push @screenshots, $1;
}
}
close TESTSCRIPT;
foreach $screenshot (@screenshots)
{
$cmd = "tgamse $keydir\\$screenshot.tga ep2\\screenshots\\$screenshot.tga 0";
$output = `$cmd`;
if( $output =~ m/FAIL/ )
{
$cmd = "tgadiff $keydir\\$screenshot.tga ep2\\screenshots\\$screenshot.tga ep2\\screenshots\\$screenshot" . "_diff.tga";
system $cmd;
}
}

233
unittests/avitest/avitest.cpp

@ -1,233 +0,0 @@ @@ -1,233 +0,0 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// The copyright to the contents herein is the property of Valve, L.L.C.
// The contents may be used and/or copied only with the written permission of
// Valve, L.L.C., or in accordance with the terms and conditions stipulated in
// the agreement/contract under which the contents have been supplied.
//
// $Header: $
// $NoKeywords: $
//
// Material editor
//=============================================================================
#include <windows.h>
#include "appframework/vguimatsysapp.h"
#include "filesystem.h"
#include "materialsystem/imaterialsystem.h"
#include "materialsystem/imesh.h"
#include "vgui/ISurface.h"
#include "vgui/IVGui.h"
#include "vgui_controls/controls.h"
#include "VGuiMatSurface/IMatSystemSurface.h"
#include "vgui/ILocalize.h"
#include "vgui/IScheme.h"
#include "avi/iavi.h"
#include "avi/ibik.h"
#include "tier3/tier3.h"
//-----------------------------------------------------------------------------
// The application object
//-----------------------------------------------------------------------------
class CAVITestApp : public CVguiMatSysApp
{
typedef CVguiMatSysApp BaseClass;
public:
// Methods of IApplication
virtual bool Create();
virtual bool PreInit( );
virtual int Main();
virtual void PostShutdown( );
virtual const char *GetAppName() { return "AVITest"; }
virtual bool AppUsesReadPixels() { return true; }
private:
// Draws a quad
void DrawStuff( AVIMaterial_t hMaterial );
IMaterial *m_pMaterial;
float m_flStartTime;
};
DEFINE_WINDOWED_STEAM_APPLICATION_OBJECT( CAVITestApp );
//-----------------------------------------------------------------------------
// Create all singleton systems
//-----------------------------------------------------------------------------
bool CAVITestApp::Create()
{
if ( !BaseClass::Create() )
return false;
AppSystemInfo_t appSystems[] =
{
{ "valve_avi.dll", AVI_INTERFACE_VERSION },
{ "valve_avi.dll", BIK_INTERFACE_VERSION },
{ "", "" } // Required to terminate the list
};
return AddSystems( appSystems );
}
//-----------------------------------------------------------------------------
// PreInit, PostShutdown
//-----------------------------------------------------------------------------
bool CAVITestApp::PreInit( )
{
if ( !BaseClass::PreInit() )
return false;
if ( !g_pFullFileSystem || !g_pMaterialSystem || !g_pVGui || !g_pVGuiSurface || !g_pAVI || !g_pBIK )
return false;
g_pAVI->SetMainWindow( GetAppWindow() );
return true;
}
void CAVITestApp::PostShutdown( )
{
g_pAVI->SetMainWindow( NULL );
BaseClass::PostShutdown();
}
//-----------------------------------------------------------------------------
// Draws a quad
//-----------------------------------------------------------------------------
void CAVITestApp::DrawStuff( AVIMaterial_t hMaterial )
{
int iViewableWidth = GetWindowWidth();
int iViewableHeight = GetWindowHeight();
g_pAVI->SetTime( hMaterial, Sys_FloatTime() - m_flStartTime );
float flMaxU, flMaxV;
g_pAVI->GetTexCoordRange( hMaterial, &flMaxU, &flMaxV );
IMaterial *pMaterial = g_pAVI->GetMaterial( hMaterial );
CMatRenderContextPtr pRenderContext( g_pMaterialSystem );
pRenderContext->MatrixMode( MATERIAL_PROJECTION );
pRenderContext->LoadIdentity();
pRenderContext->Ortho( 0, 0, iViewableWidth, iViewableHeight, 0, 1 );
pRenderContext->Bind( pMaterial );
IMesh *pMesh = pRenderContext->GetDynamicMesh();
CMeshBuilder meshBuilder;
meshBuilder.Begin( pMesh, MATERIAL_QUADS, 1 );
// Draw a polygon the size of the panel
meshBuilder.Color4ub( 255, 255, 255, 255 );
meshBuilder.Position3f( -0.5, iViewableHeight + 0.5, 0 );
meshBuilder.TexCoord2f( 0, 0, 0 );
meshBuilder.AdvanceVertex();
meshBuilder.Color4ub( 255, 255, 255, 255 );
meshBuilder.Position3f( -0.5, 0.5, 0 );
meshBuilder.TexCoord2f( 0, 0, flMaxV );
meshBuilder.AdvanceVertex();
meshBuilder.Color4ub( 255, 255, 255, 255 );
meshBuilder.Position3f( iViewableWidth - 0.5, 0.5, 0 );
meshBuilder.TexCoord2f( 0, flMaxU, flMaxV );
meshBuilder.AdvanceVertex();
meshBuilder.Color4ub( 255, 255, 255, 255 );
meshBuilder.Position3f( iViewableWidth - 0.5, iViewableHeight + 0.5, 0 );
meshBuilder.TexCoord2f( 0, flMaxU, 0 );
meshBuilder.AdvanceVertex();
meshBuilder.End();
pMesh->Draw();
}
//-----------------------------------------------------------------------------
// main application
//-----------------------------------------------------------------------------
int CAVITestApp::Main()
{
if (!SetVideoMode())
return 0;
// load scheme
if (!vgui::scheme()->LoadSchemeFromFile("resource/BoxRocket.res", "ElementViewer" ))
{
Assert( 0 );
}
// load the boxrocket localization file
g_pVGuiLocalize->AddFile( "resource/boxrocket_%language%.txt" );
// load the base localization file
g_pVGuiLocalize->AddFile( "Resource/valve_%language%.txt" );
g_pFullFileSystem->AddSearchPath("platform", "PLATFORM");
g_pVGuiLocalize->AddFile( "Resource/vgui_%language%.txt");
// start vgui
g_pVGui->Start();
// add our main window
// vgui::Panel *mainPanel = CreateElementViewerPanel();
CMatRenderContextPtr pRenderContext( g_pMaterialSystem );
AVIParams_t params;
Q_strcpy( params.m_pFileName, "c:\\temp\\out.avi" );
Q_strcpy( params.m_pPathID, "MOD" );
pRenderContext->GetWindowSize( params.m_nWidth, params.m_nHeight );
params.m_nFrameRate = 24;
params.m_nFrameScale = 1;
params.m_nNumChannels = 0;
AVIHandle_t h = g_pAVI->StartAVI( params );
AVIMaterial_t hAVIMaterial = g_pAVI->CreateAVIMaterial( "avitest", "c:\\temp\\test.avi", "MOD" );
// run app frame loop
vgui::VPANEL root = g_pVGuiSurface->GetEmbeddedPanel();
g_pVGuiSurface->Invalidate( root );
int imagesize = params.m_nWidth * params.m_nHeight;
BGR888_t *hp = new BGR888_t[ imagesize ];
m_flStartTime = Sys_FloatTime();
m_pMaterial = g_pMaterialSystem->FindMaterial( "debug/debugempty", "app" );
while ( g_pVGui->IsRunning() )
{
AppPumpMessages();
pRenderContext->ClearColor4ub( 76, 88, 68, 255 );
pRenderContext->ClearBuffers( true, true );
DrawStuff( hAVIMaterial );
g_pVGui->RunFrame();
g_pVGuiSurface->PaintTraverse( root );
// Get Bits from material system
Rect_t rect;
rect.x = rect.y = 0;
rect.width = params.m_nWidth;
rect.height = params.m_nHeight;
pRenderContext->ReadPixelsAndStretch( &rect, &rect, (unsigned char*)hp,
IMAGE_FORMAT_BGR888, rect.width * sizeof( BGR888_t ) );
g_pAVI->AppendMovieFrame( h, hp );
g_pMaterialSystem->SwapBuffers();
}
delete[] hp;
g_pAVI->FinishAVI( h );
g_pAVI->DestroyAVIMaterial( hAVIMaterial );
// delete mainPanel;
return 1;
}

27
unittests/avitest/avitest.vpc

@ -1,27 +0,0 @@ @@ -1,27 +0,0 @@
//-----------------------------------------------------------------------------
// AVITEST.VPC
//
// Project Script
//-----------------------------------------------------------------------------
$Macro SRCDIR "..\.."
$Macro OUTBINDIR "$LIBPUBLIC"
$Include "$SRCDIR\vpc_scripts\source_exe_win_win32_base.vpc"
$Project "Avitest"
{
$Folder "Source Files"
{
$File "avitest.cpp"
$File "$SRCDIR\public\vgui_controls\vgui_controls.cpp"
}
$Folder "Link Libraries"
{
$DynamicFile "$SRCDIR\lib\public\appframework.lib"
$DynamicFile "$SRCDIR\lib\public\tier2.lib"
$DynamicFile "$SRCDIR\lib\public\tier3.lib"
$DynamicFile "$SRCDIR\lib\public\vgui_controls.lib"
}
}

250
unittests/inputtest/inputtest.cpp

@ -1,250 +0,0 @@ @@ -1,250 +0,0 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// The copyright to the contents herein is the property of Valve, L.L.C.
// The contents may be used and/or copied only with the written permission of
// Valve, L.L.C., or in accordance with the terms and conditions stipulated in
// the agreement/contract under which the contents have been supplied.
//
// $Header: $
// $NoKeywords: $
//
// Material editor
//=============================================================================
#include <windows.h>
#include "appframework/tier2app.h"
#include "inputsystem/iinputsystem.h"
#include "filesystem.h"
#include "filesystem_init.h"
#include "tier0/icommandline.h"
//-----------------------------------------------------------------------------
// Purpose: Warning/Msg call back through this API
// Input : type -
// *pMsg -
// Output : SpewRetval_t
//-----------------------------------------------------------------------------
SpewRetval_t SpewFunc( SpewType_t type, char const *pMsg )
{
OutputDebugString( pMsg );
return SPEW_CONTINUE;
}
//-----------------------------------------------------------------------------
// The application object
//-----------------------------------------------------------------------------
class CInputTestApp : public CTier2SteamApp
{
typedef CTier2SteamApp BaseClass;
public:
// Methods of IApplication
virtual bool Create();
virtual bool PreInit( );
virtual int Main();
virtual void PostShutdown( );
virtual void Destroy();
virtual const char *GetAppName() { return "InputTest"; }
virtual bool AppUsesReadPixels() { return false; }
private:
// Window management
bool CreateAppWindow( char const *pTitle, bool bWindowed, int w, int h );
// Sets up the game path
bool SetupSearchPaths();
HWND m_HWnd;
};
DEFINE_WINDOWED_STEAM_APPLICATION_OBJECT( CInputTestApp );
//-----------------------------------------------------------------------------
// Create all singleton systems
//-----------------------------------------------------------------------------
bool CInputTestApp::Create()
{
SpewOutputFunc( SpewFunc );
AppSystemInfo_t appSystems[] =
{
{ "inputsystem.dll", INPUTSYSTEM_INTERFACE_VERSION },
{ "", "" } // Required to terminate the list
};
if ( !AddSystems( appSystems ) )
return false;
return true;
}
void CInputTestApp::Destroy()
{
}
//-----------------------------------------------------------------------------
// Window management
//-----------------------------------------------------------------------------
bool CInputTestApp::CreateAppWindow( char const *pTitle, bool bWindowed, int w, int h )
{
WNDCLASSEX wc;
memset( &wc, 0, sizeof( wc ) );
wc.cbSize = sizeof( wc );
wc.style = CS_OWNDC | CS_DBLCLKS;
wc.lpfnWndProc = DefWindowProc;
wc.hInstance = (HINSTANCE)GetAppInstance();
wc.lpszClassName = "Valve001";
wc.hIcon = NULL; //LoadIcon( s_HInstance, MAKEINTRESOURCE( IDI_LAUNCHER ) );
wc.hIconSm = wc.hIcon;
RegisterClassEx( &wc );
// Note, it's hidden
DWORD style = WS_POPUP | WS_CLIPSIBLINGS;
if ( bWindowed )
{
// Give it a frame
style |= WS_OVERLAPPEDWINDOW;
style &= ~WS_THICKFRAME;
}
// Never a max box
style &= ~WS_MAXIMIZEBOX;
RECT windowRect;
windowRect.top = 0;
windowRect.left = 0;
windowRect.right = w;
windowRect.bottom = h;
// Compute rect needed for that size client area based on window style
AdjustWindowRectEx(&windowRect, style, FALSE, 0);
// Create the window
m_HWnd = CreateWindow( wc.lpszClassName, pTitle, style, 0, 0,
windowRect.right - windowRect.left, windowRect.bottom - windowRect.top,
NULL, NULL, (HINSTANCE)GetAppInstance(), NULL );
if (!m_HWnd)
return false;
int CenterX, CenterY;
CenterX = (GetSystemMetrics(SM_CXSCREEN) - w) / 2;
CenterY = (GetSystemMetrics(SM_CYSCREEN) - h) / 2;
CenterX = (CenterX < 0) ? 0: CenterX;
CenterY = (CenterY < 0) ? 0: CenterY;
// In VCR modes, keep it in the upper left so mouse coordinates are always relative to the window.
SetWindowPos (m_HWnd, NULL, CenterX, CenterY, 0, 0,
SWP_NOSIZE | SWP_NOZORDER | SWP_SHOWWINDOW | SWP_DRAWFRAME);
return true;
}
//-----------------------------------------------------------------------------
// Sets up the game path
//-----------------------------------------------------------------------------
bool CInputTestApp::SetupSearchPaths()
{
if ( !BaseClass::SetupSearchPaths( NULL, false, true ) )
return false;
g_pFullFileSystem->AddSearchPath( GetGameInfoPath(), "SKIN", PATH_ADD_TO_HEAD );
return true;
}
//-----------------------------------------------------------------------------
// PreInit, PostShutdown
//-----------------------------------------------------------------------------
bool CInputTestApp::PreInit( )
{
if ( !BaseClass::PreInit() )
return false;
if (!g_pFullFileSystem || !g_pInputSystem )
return false;
// Add paths...
if ( !SetupSearchPaths() )
return false;
const char *pArg;
int iWidth = 1024;
int iHeight = 768;
bool bWindowed = (CommandLine()->CheckParm( "-fullscreen" ) == NULL);
if (CommandLine()->CheckParm( "-width", &pArg ))
{
iWidth = atoi( pArg );
}
if (CommandLine()->CheckParm( "-height", &pArg ))
{
iHeight = atoi( pArg );
}
if (!CreateAppWindow( "InputTest", bWindowed, iWidth, iHeight ))
return false;
g_pInputSystem->AttachToWindow( m_HWnd );
return true;
}
void CInputTestApp::PostShutdown( )
{
g_pInputSystem->DetachFromWindow( );
BaseClass::PostShutdown();
}
//-----------------------------------------------------------------------------
// main application
//-----------------------------------------------------------------------------
int CInputTestApp::Main()
{
while( true )
{
g_pInputSystem->PollInputState();
int nEventCount = g_pInputSystem->GetEventCount();
const InputEvent_t* pEvents = g_pInputSystem->GetEventData( );
for ( int i = 0; i < nEventCount; ++i )
{
const InputEvent_t* pEvent = &pEvents[i];
switch( pEvent->m_nType )
{
case IE_ButtonPressed:
Msg("Button Pressed Event %d : Start tick %d\n", pEvent->m_nData, pEvent->m_nTick );
break;
case IE_ButtonReleased:
Msg("Button Released Event %d : End tick %d Start tick %d\n", pEvent->m_nData, pEvent->m_nTick, g_pInputSystem->GetButtonPressedTick( (ButtonCode_t)pEvent->m_nData ) );
break;
case IE_ButtonDoubleClicked:
Msg("Button Double clicked Event %d : Start tick %d\n", pEvent->m_nData, pEvent->m_nTick );
break;
case IE_AnalogValueChanged:
Msg("Analog Value Changed %d : Start tick %d Value %d\n", pEvent->m_nData, pEvent->m_nTick, pEvent->m_nData2 );
break;
case IE_Quit:
Msg("Quit");
return 1;
}
}
}
return 1;
}

24
unittests/inputtest/inputtest.vpc

@ -1,24 +0,0 @@ @@ -1,24 +0,0 @@
//-----------------------------------------------------------------------------
// INPUTTEST.VPC
//
// Project Script
//-----------------------------------------------------------------------------
$Macro SRCDIR "..\.."
$Macro OUTBINDIR "$LIBPUBLIC"
$Include "$SRCDIR\vpc_scripts\source_exe_base.vpc"
$Project "Inputtest"
{
$Folder "Source Files"
{
$File "inputtest.cpp"
}
$Folder "Link Libraries"
{
$Lib appframework
$Lib tier2
}
}

492
unittests/materialsystemtest/materialsystemtest.cpp

@ -1,492 +0,0 @@ @@ -1,492 +0,0 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// The copyright to the contents herein is the property of Valve, L.L.C.
// The contents may be used and/or copied only with the written permission of
// Valve, L.L.C., or in accordance with the terms and conditions stipulated in
// the agreement/contract under which the contents have been supplied.
//
// $Header: $
// $NoKeywords: $
//
// Material editor
//=============================================================================
#include <windows.h>
#include "appframework/tier2app.h"
#include "materialsystem/materialsystem_config.h"
#include "materialsystem/imaterialsystemhardwareconfig.h"
#include "materialsystem/imaterialsystem.h"
#include "materialsystem/MaterialSystemUtil.h"
#include "vstdlib/random.h"
#include "filesystem.h"
#include "filesystem_init.h"
#include "tier0/icommandline.h"
#include "tier1/KeyValues.h"
#include "tier1/utlbuffer.h"
#include "materialsystem/imesh.h"
//-----------------------------------------------------------------------------
// Purpose: Warning/Msg call back through this API
// Input : type -
// *pMsg -
// Output : SpewRetval_t
//-----------------------------------------------------------------------------
SpewRetval_t SpewFunc( SpewType_t type, const char *pMsg )
{
if ( Plat_IsInDebugSession() )
{
OutputDebugString( pMsg );
if ( type == SPEW_ASSERT )
return SPEW_DEBUGGER;
}
return SPEW_CONTINUE;
}
//-----------------------------------------------------------------------------
// The application object
//-----------------------------------------------------------------------------
class CMaterialSystemTestApp : public CTier2SteamApp
{
typedef CTier2SteamApp BaseClass;
public:
// Methods of IApplication
virtual bool Create();
virtual bool PreInit( );
virtual int Main();
virtual void PostShutdown( );
virtual void Destroy();
virtual const char *GetAppName() { return "MaterialSystemTest"; }
virtual bool AppUsesReadPixels() { return false; }
private:
// Window management
bool CreateAppWindow( const char *pTitle, bool bWindowed, int w, int h );
// Sets up the game path
bool SetupSearchPaths();
// Waits for a keypress
bool WaitForKeypress();
// Sets the video mode
bool SetMode();
// Tests dynamic buffers
void TestDynamicBuffers( IMatRenderContext *pRenderContext, bool bBuffered );
// Creates, destroys a test material
void CreateWireframeMaterial();
void DestroyMaterial();
CMaterialReference m_pMaterial;
HWND m_HWnd;
};
DEFINE_WINDOWED_STEAM_APPLICATION_OBJECT( CMaterialSystemTestApp );
//-----------------------------------------------------------------------------
// Create all singleton systems
//-----------------------------------------------------------------------------
bool CMaterialSystemTestApp::Create()
{
SpewOutputFunc( SpewFunc );
AppSystemInfo_t appSystems[] =
{
{ "materialsystem.dll", MATERIAL_SYSTEM_INTERFACE_VERSION },
// Required to terminate the list
{ "", "" }
};
if ( !AddSystems( appSystems ) )
return false;
IMaterialSystem *pMaterialSystem = (IMaterialSystem*)FindSystem( MATERIAL_SYSTEM_INTERFACE_VERSION );
if ( !pMaterialSystem )
{
Warning( "CMaterialSystemTestApp::Create: Unable to connect to necessary interface!\n" );
return false;
}
bool bIsVistaOrHigher = false;
OSVERSIONINFO info;
info.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
if ( GetVersionEx( &info ) )
{
bIsVistaOrHigher = info.dwMajorVersion >= 6;
}
const char *pShaderDLL = CommandLine()->ParmValue( "-shaderdll" );
if ( !pShaderDLL )
{
pShaderDLL = "shaderapidx10.dll";
}
if ( !bIsVistaOrHigher && !Q_stricmp( pShaderDLL, "shaderapidx10.dll" ) )
{
pShaderDLL = "shaderapidx9.dll";
}
pMaterialSystem->SetShaderAPI( pShaderDLL );
return true;
}
void CMaterialSystemTestApp::Destroy()
{
}
//-----------------------------------------------------------------------------
// Window callback
//-----------------------------------------------------------------------------
static LRESULT CALLBACK MaterialSystemTestWndProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )
{
switch( message )
{
case WM_DESTROY:
PostQuitMessage( 0 );
break;
default:
return DefWindowProc( hWnd, message, wParam, lParam );
}
return 0;
}
//-----------------------------------------------------------------------------
// Window management
//-----------------------------------------------------------------------------
bool CMaterialSystemTestApp::CreateAppWindow( const char *pTitle, bool bWindowed, int w, int h )
{
WNDCLASSEX wc;
memset( &wc, 0, sizeof( wc ) );
wc.cbSize = sizeof( wc );
wc.style = CS_OWNDC | CS_DBLCLKS;
wc.lpfnWndProc = MaterialSystemTestWndProc;
wc.hInstance = (HINSTANCE)GetAppInstance();
wc.lpszClassName = "Valve001";
wc.hIcon = NULL; //LoadIcon( s_HInstance, MAKEINTRESOURCE( IDI_LAUNCHER ) );
wc.hIconSm = wc.hIcon;
RegisterClassEx( &wc );
// Note, it's hidden
DWORD style = WS_POPUP | WS_CLIPSIBLINGS;
if ( bWindowed )
{
// Give it a frame
style |= WS_OVERLAPPEDWINDOW;
style &= ~WS_THICKFRAME;
}
// Never a max box
style &= ~WS_MAXIMIZEBOX;
RECT windowRect;
windowRect.top = 0;
windowRect.left = 0;
windowRect.right = w;
windowRect.bottom = h;
// Compute rect needed for that size client area based on window style
AdjustWindowRectEx(&windowRect, style, FALSE, 0);
// Create the window
m_HWnd = CreateWindow( wc.lpszClassName, pTitle, style, 0, 0,
windowRect.right - windowRect.left, windowRect.bottom - windowRect.top,
NULL, NULL, (HINSTANCE)GetAppInstance(), NULL );
if (!m_HWnd)
return false;
int CenterX, CenterY;
CenterX = (GetSystemMetrics(SM_CXSCREEN) - w) / 2;
CenterY = (GetSystemMetrics(SM_CYSCREEN) - h) / 2;
CenterX = (CenterX < 0) ? 0: CenterX;
CenterY = (CenterY < 0) ? 0: CenterY;
// In VCR modes, keep it in the upper left so mouse coordinates are always relative to the window.
SetWindowPos (m_HWnd, NULL, CenterX, CenterY, 0, 0,
SWP_NOSIZE | SWP_NOZORDER | SWP_SHOWWINDOW | SWP_DRAWFRAME);
return true;
}
//-----------------------------------------------------------------------------
// Sets up the game path
//-----------------------------------------------------------------------------
bool CMaterialSystemTestApp::SetupSearchPaths()
{
if ( !BaseClass::SetupSearchPaths( NULL, false, true ) )
return false;
g_pFullFileSystem->AddSearchPath( GetGameInfoPath(), "SKIN", PATH_ADD_TO_HEAD );
return true;
}
//-----------------------------------------------------------------------------
// PreInit, PostShutdown
//-----------------------------------------------------------------------------
bool CMaterialSystemTestApp::PreInit( )
{
if ( !BaseClass::PreInit() )
return false;
if ( !g_pFullFileSystem || !g_pMaterialSystem )
return false;
// Add paths...
if ( !SetupSearchPaths() )
return false;
const char *pArg;
int iWidth = 1024;
int iHeight = 768;
bool bWindowed = (CommandLine()->CheckParm( "-fullscreen" ) == NULL);
if (CommandLine()->CheckParm( "-width", &pArg ))
{
iWidth = atoi( pArg );
}
if (CommandLine()->CheckParm( "-height", &pArg ))
{
iHeight = atoi( pArg );
}
if (!CreateAppWindow( "Press a Key To Continue", bWindowed, iWidth, iHeight ))
return false;
// Get the adapter from the command line....
const char *pAdapterString;
int nAdapter = 0;
if ( CommandLine()->CheckParm( "-adapter", &pAdapterString ) )
{
nAdapter = atoi( pAdapterString );
}
int nAdapterFlags = 0;
if ( AppUsesReadPixels() )
{
nAdapterFlags |= MATERIAL_INIT_ALLOCATE_FULLSCREEN_TEXTURE;
}
g_pMaterialSystem->SetAdapter( nAdapter, nAdapterFlags );
return true;
}
void CMaterialSystemTestApp::PostShutdown( )
{
BaseClass::PostShutdown();
}
//-----------------------------------------------------------------------------
// Waits for a keypress
//-----------------------------------------------------------------------------
bool CMaterialSystemTestApp::WaitForKeypress()
{
MSG msg = {0};
while( WM_QUIT != msg.message )
{
if( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) )
{
TranslateMessage( &msg );
DispatchMessage( &msg );
}
if ( msg.message == WM_KEYDOWN )
return true;
}
return false;
}
//-----------------------------------------------------------------------------
// Sets the video mode
//-----------------------------------------------------------------------------
bool CMaterialSystemTestApp::SetMode()
{
MaterialSystem_Config_t config;
if ( CommandLine()->CheckParm( "-fullscreen" ) )
{
config.SetFlag( MATSYS_VIDCFG_FLAGS_WINDOWED, false );
}
else
{
config.SetFlag( MATSYS_VIDCFG_FLAGS_WINDOWED, true );
}
if ( CommandLine()->CheckParm( "-resizing" ) )
{
config.SetFlag( MATSYS_VIDCFG_FLAGS_RESIZING, true );
}
if ( CommandLine()->CheckParm( "-mat_vsync" ) )
{
config.SetFlag( MATSYS_VIDCFG_FLAGS_NO_WAIT_FOR_VSYNC, false );
}
config.m_nAASamples = CommandLine()->ParmValue( "-mat_antialias", 1 );
config.m_nAAQuality = CommandLine()->ParmValue( "-mat_aaquality", 0 );
config.m_VideoMode.m_Width = config.m_VideoMode.m_Height = 0;
config.m_VideoMode.m_Format = IMAGE_FORMAT_BGRX8888;
config.m_VideoMode.m_RefreshRate = 0;
bool modeSet = g_pMaterialSystem->SetMode( m_HWnd, config );
if (!modeSet)
{
Error( "Unable to set mode\n" );
return false;
}
g_pMaterialSystem->OverrideConfig( config, false );
return true;
}
//-----------------------------------------------------------------------------
// Creates, destroys a test material
//-----------------------------------------------------------------------------
void CMaterialSystemTestApp::CreateWireframeMaterial()
{
KeyValues *pVMTKeyValues = new KeyValues( "Wireframe" );
pVMTKeyValues->SetInt( "$vertexcolor", 1 );
pVMTKeyValues->SetInt( "$nocull", 1 );
pVMTKeyValues->SetInt( "$ignorez", 1 );
m_pMaterial.Init( "__test", pVMTKeyValues );
}
void CMaterialSystemTestApp::DestroyMaterial()
{
m_pMaterial.Shutdown();
}
//-----------------------------------------------------------------------------
// Tests dynamic buffers
//-----------------------------------------------------------------------------
void CMaterialSystemTestApp::TestDynamicBuffers( IMatRenderContext *pMatRenderContext, bool bBuffered )
{
CreateWireframeMaterial();
g_pMaterialSystem->BeginFrame( 0 );
pMatRenderContext->Bind( m_pMaterial );
IMesh *pMesh = pMatRenderContext->GetDynamicMesh( bBuffered );
// clear (so that we can make sure that we aren't getting results from the previous quad)
pMatRenderContext->ClearColor3ub( RandomInt( 0, 100 ), RandomInt( 0, 100 ), RandomInt( 190, 255 ) );
pMatRenderContext->ClearBuffers( true, true );
static unsigned char s_pColors[4][4] =
{
{ 255, 0, 0, 255 },
{ 0, 255, 0, 255 },
{ 0, 0, 255, 255 },
{ 255, 255, 255, 255 },
};
static int nCount = 0;
const int nLoopCount = 8;
float flWidth = 2.0f / nLoopCount;
for ( int i = 0; i < nLoopCount; ++i )
{
CMeshBuilder mb;
mb.Begin( pMesh, MATERIAL_TRIANGLES, 4, 6 );
mb.Position3f( -1.0f + i * flWidth, -1.0f, 0.5f );
mb.Normal3f( 0.0f, 0.0f, 1.0f );
mb.Color4ubv( s_pColors[nCount++ % 4] );
mb.AdvanceVertex();
mb.Position3f( -1.0f + i * flWidth + flWidth, -1.0f, 0.5f );
mb.Normal3f( 0.0f, 0.0f, 1.0f );
mb.Color4ubv( s_pColors[nCount++ % 4] );
mb.AdvanceVertex();
mb.Position3f( -1.0f + i * flWidth + flWidth, 1.0f, 0.5f );
mb.Normal3f( 0.0f, 0.0f, 1.0f );
mb.Color4ubv( s_pColors[nCount++ % 4] );
mb.AdvanceVertex();
mb.Position3f( -1.0f + i * flWidth, 1.0f, 0.5f );
mb.Normal3f( 0.0f, 0.0f, 1.0f );
mb.Color4ubv( s_pColors[nCount++ % 4] );
mb.AdvanceVertex();
++nCount;
mb.FastIndex( 0 );
mb.FastIndex( 2 );
mb.FastIndex( 1 );
mb.FastIndex( 0 );
mb.FastIndex( 3 );
mb.FastIndex( 2 );
mb.End( true );
pMesh->Draw( );
}
++nCount;
g_pMaterialSystem->EndFrame();
g_pMaterialSystem->SwapBuffers();
DestroyMaterial();
}
//-----------------------------------------------------------------------------
// main application
//-----------------------------------------------------------------------------
int CMaterialSystemTestApp::Main()
{
if ( !SetMode() )
return 0;
CMatRenderContextPtr pRenderContext( g_pMaterialSystem );
// Sets up a full-screen viewport
int w, h;
pRenderContext->GetWindowSize( w, h );
pRenderContext->Viewport( 0, 0, w, h );
pRenderContext->DepthRange( 0.0f, 1.0f );
// Clears the screen
g_pMaterialSystem->BeginFrame( 0 );
pRenderContext->ClearColor4ub( 76, 88, 68, 255 );
pRenderContext->ClearBuffers( true, true );
g_pMaterialSystem->EndFrame();
g_pMaterialSystem->SwapBuffers();
SetWindowText( m_HWnd, "Buffer clearing . . hit a key" );
if ( !WaitForKeypress() )
return 1;
SetWindowText( m_HWnd, "Dynamic buffer test.. hit a key" );
TestDynamicBuffers( pRenderContext, false );
if ( !WaitForKeypress() )
return 1;
SetWindowText( m_HWnd, "Buffered dynamic buffer test.. hit a key" );
TestDynamicBuffers( pRenderContext, true );
if ( !WaitForKeypress() )
return 1;
return 1;
}

24
unittests/materialsystemtest/materialsystemtest.vpc

@ -1,24 +0,0 @@ @@ -1,24 +0,0 @@
//-----------------------------------------------------------------------------
// MATERIALSYSTEMTEST.VPC
//
// Project Script
//-----------------------------------------------------------------------------
$Macro SRCDIR "..\.."
$Macro OUTBINDIR "$LIBPUBLIC"
$Include "$SRCDIR\vpc_scripts\source_exe_base.vpc"
$Project "MaterialSystemTest"
{
$Folder "Source Files"
{
$File "materialsystemtest.cpp"
}
$Folder "Link Libraries"
{
$Lib appframework
$Lib tier2
}
}

79
unittests/mathlib_test/mathlib_test.cpp

@ -1,79 +0,0 @@ @@ -1,79 +0,0 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
#include "tier0/platform.h"
#include "mathlib/mathlib.h"
#include "mathlib/spherical_geometry.h"
#include "tier2/tier2.h"
#include "mathlib/halton.h"
#include "bitmap/float_bm.h"
#include "tier0/memdbgon.h"
void main(int argc,char **argv)
{
InitCommandLineProgram( argc, argv );
// 1/8th of the sphere
float a1=UnitSphereTriangleArea( Vector( 1, 0, 0 ), Vector( 0, 0, -1 ), Vector( 0, 1, 0 ) );
printf( "right spherical triangle projected percentage=%2.4f\n", a1 / ( 4 * M_PI ));
// a small one
Vector v1 = Vector( 1, 0, 0 );
Vector v2 = v1 + Vector( 0, 0.2, 0 );
Vector v3 = v1 + Vector( 0, 0, 0.2 );
v2.NormalizeInPlace();
v3.NormalizeInPlace();
float a2=UnitSphereTriangleArea( v1, v2, v3 );
printf( "small spherical triangle projected percentage=%2.5f\n", a2 / ( 4* M_PI ) );
// now, create a cubemap and sum the area of each of its cells
FloatCubeMap_t envMap( 10, 10 );
float flAreaSum = 0.;
for( int nFace = 0 ; nFace < 6; nFace ++ )
{
for( int nY = 0 ; nY < 9; nY++ )
for( int nX = 0 ; nX < 9; nX++ )
{
Vector v00 = envMap.PixelDirection( nFace, nX, nY );
Vector v01 = envMap.PixelDirection( nFace, nX, nY + 1 );
Vector v10 = envMap.PixelDirection( nFace, nX + 1, nY );
Vector v11 = envMap.PixelDirection( nFace, nX + 1 , nY + 1 );
v00.NormalizeInPlace();
v01.NormalizeInPlace();
v10.NormalizeInPlace();
v11.NormalizeInPlace();
flAreaSum += UnitSphereTriangleArea( v00, v01, v10 );
flAreaSum += UnitSphereTriangleArea( v10, v11, v01 );
}
}
printf( "sum of areas of cubemap cells = %2.2f\n", flAreaSum / ( 4.0 * M_PI ) );
#if 0 // visual spherical harmonics as (confusing) point sets
// spherical harmonics
DirectionalSampler_t sampler;
for(int i = 0 ; i < 50000; i++ )
{
Vector dir=sampler.NextValue();
float SH = SphericalHarmonic( 4, 3, dir );
float r=0;
float g=1; //0.5+0.5*DotProduct( dir, Vector( 0, 0, 1 ) );
float b=0;
if ( SH < 0 )
{
SH = -SH;
r=g;
g=0;
}
r *= SH;
g *= SH;
b *= SH;
float rad= SH * 4.0; //4.0; //SH *= 8.0;
printf( "2\n" );
printf( "%f %f %f %f %f %f\n",
dir.x * rad, dir.y * rad, dir.z * rad, r, g, b );
rad += 0.03;
printf( "%f %f %f %f %f %f\n",
dir.x * rad, dir.y * rad, dir.z * rad, r, g, b );
}
#endif
}

38
unittests/mathlib_test/mathlib_test.vpc

@ -1,38 +0,0 @@ @@ -1,38 +0,0 @@
//-----------------------------------------------------------------------------
// mathlib_test.VPC
//
// Project Script
//-----------------------------------------------------------------------------
$Macro SRCDIR "..\.."
$Macro OUTBINDIR "$SRCDIR\unittests\mathlib_test"
$Include "$SRCDIR\vpc_scripts\source_exe_con_base.vpc"
$Configuration "Debug"
{
$Compiler
{
$PreprocessorDefinitions "$BASE;PROTECTED_THINGS_DISABLE"
}
$Linker
{
$AdditionalDependencies "$BASE winmm.lib"
}
}
$Project "mathlib_test"
{
$Folder "Source Files"
{
$File "mathlib_test.cpp"
}
$Folder "Link Libraries"
{
$Lib bitmap
$Lib mathlib
$Lib tier2
}
}

1056
unittests/shaderapitest/shaderapitest.cpp

File diff suppressed because it is too large Load Diff

25
unittests/shaderapitest/shaderapitest.vpc

@ -1,25 +0,0 @@ @@ -1,25 +0,0 @@
//-----------------------------------------------------------------------------
// SHADERAPITEST.VPC
//
// Project Script
//-----------------------------------------------------------------------------
$Macro SRCDIR "..\.."
$Macro OUTBINDIR "$LIBPUBLIC"
$Include "$SRCDIR\vpc_scripts\source_exe_base.vpc"
$Project "ShaderAPITest"
{
$Folder "Source Files"
{
$File "shaderapitest.cpp"
}
$Folder "Link Libraries"
{
$Lib appframework
$Lib tier2
$Lib $LIBCOMMON\bzip2
}
}

306
unittests/soundtest/soundtest.cpp

@ -1,306 +0,0 @@ @@ -1,306 +0,0 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// The copyright to the contents herein is the property of Valve, L.L.C.
// The contents may be used and/or copied only with the written permission of
// Valve, L.L.C., or in accordance with the terms and conditions stipulated in
// the agreement/contract under which the contents have been supplied.
//
// $Header: $
// $NoKeywords: $
//
// Sound unit test application
//
//=============================================================================
#include <windows.h>
#include "tier0/dbg.h"
#include "tier0/icommandline.h"
#include "filesystem.h"
#include "datacache/idatacache.h"
#include "appframework/appframework.h"
#include "soundsystem/isoundsystem.h"
#include "vstdlib/cvar.h"
#include "filesystem_init.h"
//-----------------------------------------------------------------------------
// Main system interfaces
//-----------------------------------------------------------------------------
IFileSystem *g_pFileSystem;
ISoundSystem *g_pSoundSystem;
//-----------------------------------------------------------------------------
// Standard spew functions
//-----------------------------------------------------------------------------
static SpewRetval_t SoundTestOutputFunc( SpewType_t spewType, char const *pMsg )
{
printf( pMsg );
fflush( stdout );
if (spewType == SPEW_ERROR)
return SPEW_ABORT;
return (spewType == SPEW_ASSERT) ? SPEW_DEBUGGER : SPEW_CONTINUE;
}
//-----------------------------------------------------------------------------
// The application object
//-----------------------------------------------------------------------------
class CSoundTestApp : public CDefaultAppSystemGroup<CSteamAppSystemGroup>
{
public:
// Methods of IApplication
virtual bool Create();
virtual bool PreInit();
virtual int Main();
virtual void PostShutdown();
virtual void Destroy();
private:
bool CreateAppWindow( char const *pTitle, bool bWindowed, int w, int h );
bool SetupSearchPaths();
void AppPumpMessages();
// Windproc
static LONG WINAPI WinAppWindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
LONG WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
HWND m_hWnd;
bool m_bExitMainLoop;
};
static CSoundTestApp s_SoundTestApp;
DEFINE_WINDOWED_STEAM_APPLICATION_OBJECT_GLOBALVAR( CSoundTestApp, s_SoundTestApp );
//-----------------------------------------------------------------------------
// The application object
//-----------------------------------------------------------------------------
bool CSoundTestApp::Create()
{
SpewOutputFunc( SoundTestOutputFunc );
// Add in the cvar factory
AppModule_t cvarModule = LoadModule( VStdLib_GetICVarFactory() );
AddSystem( cvarModule, CVAR_INTERFACE_VERSION );
AppSystemInfo_t appSystems[] =
{
{ "datacache.dll", DATACACHE_INTERFACE_VERSION },
{ "soundsystem.dll", SOUNDSYSTEM_INTERFACE_VERSION },
{ "", "" } // Required to terminate the list
};
if ( !AddSystems( appSystems ) )
return false;
g_pFileSystem = (IFileSystem*)FindSystem( FILESYSTEM_INTERFACE_VERSION );
g_pSoundSystem = (ISoundSystem*)FindSystem( SOUNDSYSTEM_INTERFACE_VERSION );
return ( g_pFileSystem && g_pSoundSystem );
}
void CSoundTestApp::Destroy()
{
g_pFileSystem = NULL;
g_pSoundSystem = NULL;
}
//-----------------------------------------------------------------------------
// Window management
//-----------------------------------------------------------------------------
bool CSoundTestApp::CreateAppWindow( char const *pTitle, bool bWindowed, int w, int h )
{
WNDCLASSEX wc;
memset( &wc, 0, sizeof( wc ) );
wc.cbSize = sizeof( wc );
wc.style = CS_OWNDC | CS_DBLCLKS;
wc.lpfnWndProc = WinAppWindowProc;
wc.hInstance = (HINSTANCE)GetAppInstance();
wc.lpszClassName = "Valve001";
wc.hIcon = NULL; //LoadIcon( s_HInstance, MAKEINTRESOURCE( IDI_LAUNCHER ) );
wc.hIconSm = wc.hIcon;
RegisterClassEx( &wc );
// Note, it's hidden
DWORD style = WS_POPUP | WS_CLIPSIBLINGS;
if ( bWindowed )
{
// Give it a frame
style |= WS_OVERLAPPEDWINDOW;
style &= ~WS_THICKFRAME;
}
// Never a max box
style &= ~WS_MAXIMIZEBOX;
RECT windowRect;
windowRect.top = 0;
windowRect.left = 0;
windowRect.right = w;
windowRect.bottom = h;
// Compute rect needed for that size client area based on window style
AdjustWindowRectEx(&windowRect, style, FALSE, 0);
// Create the window
m_hWnd = CreateWindow( wc.lpszClassName, pTitle, style, 0, 0,
windowRect.right - windowRect.left, windowRect.bottom - windowRect.top,
NULL, NULL, (HINSTANCE)GetAppInstance(), NULL );
if ( m_hWnd == INVALID_HANDLE_VALUE )
return false;
int CenterX, CenterY;
CenterX = (GetSystemMetrics(SM_CXSCREEN) - w) / 2;
CenterY = (GetSystemMetrics(SM_CYSCREEN) - h) / 2;
CenterX = (CenterX < 0) ? 0: CenterX;
CenterY = (CenterY < 0) ? 0: CenterY;
// In VCR modes, keep it in the upper left so mouse coordinates are always relative to the window.
SetWindowPos (m_hWnd, NULL, CenterX, CenterY, 0, 0,
SWP_NOSIZE | SWP_NOZORDER | SWP_SHOWWINDOW | SWP_DRAWFRAME);
return true;
}
//-----------------------------------------------------------------------------
// Message handler
//-----------------------------------------------------------------------------
LONG CSoundTestApp::WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
if ( uMsg == WM_CLOSE )
{
m_bExitMainLoop = true;
}
return DefWindowProc( hWnd, uMsg, wParam, lParam );
}
LONG WINAPI CSoundTestApp::WinAppWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
return s_SoundTestApp.WindowProc( hWnd, uMsg, wParam, lParam );
}
//-----------------------------------------------------------------------------
// Sets up the game path
//-----------------------------------------------------------------------------
bool CSoundTestApp::SetupSearchPaths()
{
CFSSteamSetupInfo steamInfo;
steamInfo.m_pDirectoryName = NULL;
steamInfo.m_bOnlyUseDirectoryName = false;
steamInfo.m_bToolsMode = true;
steamInfo.m_bSetSteamDLLPath = true;
steamInfo.m_bSteam = g_pFileSystem->IsSteam();
if ( FileSystem_SetupSteamEnvironment( steamInfo ) != FS_OK )
return false;
CFSMountContentInfo fsInfo;
fsInfo.m_pFileSystem = g_pFileSystem;
fsInfo.m_bToolsMode = true;
fsInfo.m_pDirectoryName = steamInfo.m_GameInfoPath;
if ( FileSystem_MountContent( fsInfo ) != FS_OK )
return false;
// Finally, load the search paths for the "GAME" path.
CFSSearchPathsInit searchPathsInit;
searchPathsInit.m_pDirectoryName = steamInfo.m_GameInfoPath;
searchPathsInit.m_pFileSystem = g_pFileSystem;
if ( FileSystem_LoadSearchPaths( searchPathsInit ) != FS_OK )
return false;
g_pFileSystem->AddSearchPath( steamInfo.m_GameInfoPath, "SKIN", PATH_ADD_TO_HEAD );
FileSystem_AddSearchPath_Platform( g_pFileSystem, steamInfo.m_GameInfoPath );
// and now add episodic to the GAME searchpath
char shorts[MAX_PATH];
Q_strncpy( shorts, steamInfo.m_GameInfoPath, MAX_PATH );
Q_StripTrailingSlash( shorts );
Q_strncat( shorts, "/../episodic", MAX_PATH, MAX_PATH );
g_pFileSystem->AddSearchPath( shorts, "GAME", PATH_ADD_TO_HEAD );
return true;
}
//-----------------------------------------------------------------------------
// PreInit, PostShutdown
//-----------------------------------------------------------------------------
bool CSoundTestApp::PreInit( )
{
// Add paths...
if ( !SetupSearchPaths() )
return false;
const char *pArg;
int iWidth = 1024;
int iHeight = 768;
bool bWindowed = (CommandLine()->CheckParm( "-fullscreen" ) == NULL);
if (CommandLine()->CheckParm( "-width", &pArg ))
{
iWidth = atoi( pArg );
}
if (CommandLine()->CheckParm( "-height", &pArg ))
{
iHeight = atoi( pArg );
}
if ( !CreateAppWindow( "SoundTest", bWindowed, iWidth, iHeight ) )
return false;
return true;
}
void CSoundTestApp::PostShutdown()
{
}
//-----------------------------------------------------------------------------
// Pump messages
//-----------------------------------------------------------------------------
void CSoundTestApp::AppPumpMessages()
{
MSG msg;
while ( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) )
{
TranslateMessage( &msg );
DispatchMessage( &msg );
}
}
//-----------------------------------------------------------------------------
// The application object
//-----------------------------------------------------------------------------
int CSoundTestApp::Main()
{
CAudioSource *pSource = g_pSoundSystem->LoadSound( "sound/ambient/alarms/alarm1.wav" );
CAudioMixer *pMixer;
g_pSoundSystem->PlaySound( pSource, 1.0f, &pMixer );
m_bExitMainLoop = false;
while ( !m_bExitMainLoop )
{
AppPumpMessages();
g_pSoundSystem->Update( Plat_FloatTime() );
}
return 1;
}

24
unittests/soundtest/soundtest.vpc

@ -1,24 +0,0 @@ @@ -1,24 +0,0 @@
//-----------------------------------------------------------------------------
// SOUNDTEST.VPC
//
// Project Script
//-----------------------------------------------------------------------------
$Macro SRCDIR "..\.."
$Macro OUTBINDIR "$LIBPUBLIC"
$Include "$SRCDIR\vpc_scripts\source_exe_win_win32_base.vpc"
$Project "Soundtest"
{
$Folder "Source Files"
{
$File "$SRCDIR\public\filesystem_init.cpp"
$File "soundtest.cpp"
}
$Folder "Link Libraries"
{
$DynamicFile "$SRCDIR\lib\public\appframework.lib"
}
}

191
unittests/testprocess/testprocess.cpp

@ -1,191 +0,0 @@ @@ -1,191 +0,0 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//
//===========================================================================//
#include <windows.h>
#include "tier0/icommandline.h"
#include <stdio.h>
#include "tier0/dbg.h"
static unsigned short g_InitialColor = 0xFFFF;
static unsigned short g_LastColor = 0xFFFF;
static unsigned short g_BadColor = 0xFFFF;
static WORD g_BackgroundFlags = 0xFFFF;
static void GetInitialColors( )
{
// Get the old background attributes.
CONSOLE_SCREEN_BUFFER_INFO oldInfo;
GetConsoleScreenBufferInfo( GetStdHandle( STD_OUTPUT_HANDLE ), &oldInfo );
g_InitialColor = g_LastColor = oldInfo.wAttributes & (FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE|FOREGROUND_INTENSITY);
g_BackgroundFlags = oldInfo.wAttributes & (BACKGROUND_RED|BACKGROUND_GREEN|BACKGROUND_BLUE|BACKGROUND_INTENSITY);
g_BadColor = 0;
if (g_BackgroundFlags & BACKGROUND_RED)
g_BadColor |= FOREGROUND_RED;
if (g_BackgroundFlags & BACKGROUND_GREEN)
g_BadColor |= FOREGROUND_GREEN;
if (g_BackgroundFlags & BACKGROUND_BLUE)
g_BadColor |= FOREGROUND_BLUE;
if (g_BackgroundFlags & BACKGROUND_INTENSITY)
g_BadColor |= FOREGROUND_INTENSITY;
}
static WORD SetConsoleTextColor( int red, int green, int blue, int intensity )
{
WORD ret = g_LastColor;
g_LastColor = 0;
if( red ) g_LastColor |= FOREGROUND_RED;
if( green ) g_LastColor |= FOREGROUND_GREEN;
if( blue ) g_LastColor |= FOREGROUND_BLUE;
if( intensity ) g_LastColor |= FOREGROUND_INTENSITY;
// Just use the initial color if there's a match...
if (g_LastColor == g_BadColor)
g_LastColor = g_InitialColor;
SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), g_LastColor | g_BackgroundFlags );
return ret;
}
static void RestoreConsoleTextColor( WORD color )
{
SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), color | g_BackgroundFlags );
g_LastColor = color;
}
void CmdLib_Exit( int exitCode )
{
TerminateProcess( GetCurrentProcess(), 1 );
}
CRITICAL_SECTION g_SpewCS;
bool g_bSpewCSInitted = false;
bool g_bSuppressPrintfOutput = false;
SpewRetval_t CmdLib_SpewOutputFunc( SpewType_t type, char const *pMsg )
{
// Hopefully two threads won't call this simultaneously right at the start!
if ( !g_bSpewCSInitted )
{
InitializeCriticalSection( &g_SpewCS );
g_bSpewCSInitted = true;
}
WORD old;
SpewRetval_t retVal;
EnterCriticalSection( &g_SpewCS );
{
if (( type == SPEW_MESSAGE ) || (type == SPEW_LOG ))
{
old = SetConsoleTextColor( 1, 1, 1, 0 );
retVal = SPEW_CONTINUE;
}
else if( type == SPEW_WARNING )
{
old = SetConsoleTextColor( 1, 1, 0, 1 );
retVal = SPEW_CONTINUE;
}
else if( type == SPEW_ASSERT )
{
old = SetConsoleTextColor( 1, 0, 0, 1 );
retVal = SPEW_DEBUGGER;
#ifdef MPI
// VMPI workers don't want to bring up dialogs and suchlike.
if ( g_bUseMPI && !g_bMPIMaster )
{
VMPI_HandleCrash( pMsg, true );
exit( 0 );
}
#endif
}
else if( type == SPEW_ERROR )
{
old = SetConsoleTextColor( 1, 0, 0, 1 );
retVal = SPEW_ABORT; // doesn't matter.. we exit below so we can return an errorlevel (which dbg.dll doesn't do).
}
else
{
old = SetConsoleTextColor( 1, 1, 1, 1 );
retVal = SPEW_CONTINUE;
}
if ( !g_bSuppressPrintfOutput || type == SPEW_ERROR )
printf( "%s", pMsg );
OutputDebugString( pMsg );
if ( type == SPEW_ERROR )
{
printf( "\n" );
OutputDebugString( "\n" );
}
RestoreConsoleTextColor( old );
}
LeaveCriticalSection( &g_SpewCS );
if ( type == SPEW_ERROR )
{
CmdLib_Exit( 1 );
}
return retVal;
}
void InstallSpewFunction()
{
setvbuf( stdout, NULL, _IONBF, 0 );
setvbuf( stderr, NULL, _IONBF, 0 );
SpewOutputFunc( CmdLib_SpewOutputFunc );
GetInitialColors();
}
//-----------------------------------------------------------------------------
// Tests the process.cpp stuff
//-----------------------------------------------------------------------------
int main( int argc, char **argv )
{
CommandLine()->CreateCmdLine( argc, argv );
InstallSpewFunction();
float flDelay = CommandLine()->ParmValue( "-delay", 0.0f );
const char *pEndMessage = CommandLine()->ParmValue( "-message", "Test Finished!\n" );
int nEndExtraBytes = CommandLine()->ParmValue( "-extrabytes", 0 );
if ( flDelay > 0.0f )
{
float t = Plat_FloatTime();
while ( Plat_FloatTime() - t < flDelay )
{
}
}
Msg( pEndMessage );
if ( nEndExtraBytes )
{
while( --nEndExtraBytes >= 0 )
{
Msg( "%c", ( nEndExtraBytes % 10 ) + '0' );
}
}
return 0;
}

BIN
unittests/testprocess/testprocess.exe

Binary file not shown.

BIN
unittests/testprocess/testprocess.pdb

Binary file not shown.

38
unittests/testprocess/testprocess.vpc

@ -1,38 +0,0 @@ @@ -1,38 +0,0 @@
//-----------------------------------------------------------------------------
// TESTPROCESS.VPC
//
// Project Script
//-----------------------------------------------------------------------------
$MacroRequired "PLATSUBDIR"
$Macro SRCDIR "..\.."
$Macro OUTBINDIR "$SRCDIR\unittests\testprocess"
$Include "$SRCDIR\vpc_scripts\source_exe_con_base.vpc"
$Configuration "Debug"
{
$Compiler
{
$PreprocessorDefinitions "$BASE;PROTECTED_THINGS_DISABLE"
}
$Linker
{
$AdditionalDependencies "$BASE winmm.lib"
}
}
$Project "Testprocess"
{
$Folder "Source Files"
{
$File "testprocess.cpp"
}
$Folder "Link Libraries"
{
$Lib tier2
}
}
Loading…
Cancel
Save