diff --git a/unittests/autotestscripts/check_debug_dlls.pl b/unittests/autotestscripts/check_debug_dlls.pl deleted file mode 100644 index 7f1e16c2..00000000 --- a/unittests/autotestscripts/check_debug_dlls.pl +++ /dev/null @@ -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 ); - } - } diff --git a/unittests/autotestscripts/check_dynamic_shader_compile.pl b/unittests/autotestscripts/check_dynamic_shader_compile.pl deleted file mode 100644 index 39e8e3a7..00000000 --- a/unittests/autotestscripts/check_dynamic_shader_compile.pl +++ /dev/null @@ -1,15 +0,0 @@ -#!perl - -open(DLL,"../../../game/bin/shaderapidx9.dll" ) || die "can't open shaderapi"; - -binmode DLL; -my $dllcode = do { local( $/ ) ; } ; # 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; - } - diff --git a/unittests/autotestscripts/datafiles/gwolf.tga b/unittests/autotestscripts/datafiles/gwolf.tga deleted file mode 100644 index c813d8a1..00000000 Binary files a/unittests/autotestscripts/datafiles/gwolf.tga and /dev/null differ diff --git a/unittests/autotestscripts/filecompare_tests.cfg b/unittests/autotestscripts/filecompare_tests.cfg deleted file mode 100644 index 4f4cda63..00000000 --- a/unittests/autotestscripts/filecompare_tests.cfg +++ /dev/null @@ -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 - - - - - diff --git a/unittests/autotestscripts/reference_output/file_size_monitor.txt b/unittests/autotestscripts/reference_output/file_size_monitor.txt deleted file mode 100644 index 1f3ef708..00000000 --- a/unittests/autotestscripts/reference_output/file_size_monitor.txt +++ /dev/null @@ -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 diff --git a/unittests/autotestscripts/reference_output/mathlib_test.txt b/unittests/autotestscripts/reference_output/mathlib_test.txt deleted file mode 100644 index e5815616..00000000 --- a/unittests/autotestscripts/reference_output/mathlib_test.txt +++ /dev/null @@ -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 diff --git a/unittests/autotestscripts/reference_output/rt_test.txt b/unittests/autotestscripts/reference_output/rt_test.txt deleted file mode 100644 index 1cee230d..00000000 --- a/unittests/autotestscripts/reference_output/rt_test.txt +++ /dev/null @@ -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 diff --git a/unittests/autotestscripts/reference_output/testprocess.txt b/unittests/autotestscripts/reference_output/testprocess.txt deleted file mode 100644 index 63b55cd5..00000000 --- a/unittests/autotestscripts/reference_output/testprocess.txt +++ /dev/null @@ -1 +0,0 @@ -testprocess autotest1 \ No newline at end of file diff --git a/unittests/autotestscripts/reference_output/vtex.vtf b/unittests/autotestscripts/reference_output/vtex.vtf deleted file mode 100644 index f36a0305..00000000 Binary files a/unittests/autotestscripts/reference_output/vtex.vtf and /dev/null differ diff --git a/unittests/autotestscripts/run_file_comparison_tests.pl b/unittests/autotestscripts/run_file_comparison_tests.pl deleted file mode 100644 index 7408a561..00000000 --- a/unittests/autotestscripts/run_file_comparison_tests.pl +++ /dev/null @@ -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() - { - 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( $/ ) ; } ; # slurp comparison output in - close REF; - - if ( length( $testfile ) ) - { - print STDERR $output; - # file case - if ( open(TESTFILE, $testfile )) - { - binmode TESTFILE; - $new_output= do { local( $/ ) ; } ; # 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; - } - - } - } - - } diff --git a/unittests/autotestscripts/subtests/file_size_monitor.pl b/unittests/autotestscripts/subtests/file_size_monitor.pl deleted file mode 100644 index fa834d34..00000000 --- a/unittests/autotestscripts/subtests/file_size_monitor.pl +++ /dev/null @@ -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; - } diff --git a/unittests/autotestscripts/test_error_reporting.pl b/unittests/autotestscripts/test_error_reporting.pl deleted file mode 100644 index f705f9cd..00000000 --- a/unittests/autotestscripts/test_error_reporting.pl +++ /dev/null @@ -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; - } - - } diff --git a/unittests/autotestscripts/test_shader_crcs.pl b/unittests/autotestscripts/test_shader_crcs.pl deleted file mode 100644 index 517aa026..00000000 --- a/unittests/autotestscripts/test_shader_crcs.pl +++ /dev/null @@ -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; -} diff --git a/unittests/autotestscripts/verify_compiled_sheet_files_match_src.pl b/unittests/autotestscripts/verify_compiled_sheet_files_match_src.pl deleted file mode 100644 index bce70bae..00000000 --- a/unittests/autotestscripts/verify_compiled_sheet_files_match_src.pl +++ /dev/null @@ -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=; - $new_data=; - 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, $_; - } - } diff --git a/unittests/autotestscripts_graphics/keyimages/abovewater.tga b/unittests/autotestscripts_graphics/keyimages/abovewater.tga deleted file mode 100644 index 9700ce3b..00000000 Binary files a/unittests/autotestscripts_graphics/keyimages/abovewater.tga and /dev/null differ diff --git a/unittests/autotestscripts_graphics/keyimages/belowwater.tga b/unittests/autotestscripts_graphics/keyimages/belowwater.tga deleted file mode 100644 index 5641376d..00000000 Binary files a/unittests/autotestscripts_graphics/keyimages/belowwater.tga and /dev/null differ diff --git a/unittests/autotestscripts_graphics/keyimages/mat_fullbright_1.tga b/unittests/autotestscripts_graphics/keyimages/mat_fullbright_1.tga deleted file mode 100644 index ce60746b..00000000 Binary files a/unittests/autotestscripts_graphics/keyimages/mat_fullbright_1.tga and /dev/null differ diff --git a/unittests/autotestscripts_graphics/keyimages/mat_fullbright_2.tga b/unittests/autotestscripts_graphics/keyimages/mat_fullbright_2.tga deleted file mode 100644 index ef516c50..00000000 Binary files a/unittests/autotestscripts_graphics/keyimages/mat_fullbright_2.tga and /dev/null differ diff --git a/unittests/autotestscripts_graphics/keyimages/mat_luxels_1.tga b/unittests/autotestscripts_graphics/keyimages/mat_luxels_1.tga deleted file mode 100644 index 80e5bd16..00000000 Binary files a/unittests/autotestscripts_graphics/keyimages/mat_luxels_1.tga and /dev/null differ diff --git a/unittests/autotestscripts_graphics/keyimages/mat_showmiplevels_1.tga b/unittests/autotestscripts_graphics/keyimages/mat_showmiplevels_1.tga deleted file mode 100644 index ac2b726c..00000000 Binary files a/unittests/autotestscripts_graphics/keyimages/mat_showmiplevels_1.tga and /dev/null differ diff --git a/unittests/autotestscripts_graphics/keyimages/mat_showmiplevels_2.tga b/unittests/autotestscripts_graphics/keyimages/mat_showmiplevels_2.tga deleted file mode 100644 index 04af7cbc..00000000 Binary files a/unittests/autotestscripts_graphics/keyimages/mat_showmiplevels_2.tga and /dev/null differ diff --git a/unittests/autotestscripts_graphics/keyimages/mat_wireframe_1.tga b/unittests/autotestscripts_graphics/keyimages/mat_wireframe_1.tga deleted file mode 100644 index 862b2419..00000000 Binary files a/unittests/autotestscripts_graphics/keyimages/mat_wireframe_1.tga and /dev/null differ diff --git a/unittests/autotestscripts_graphics/rendering_regression_test.pl b/unittests/autotestscripts_graphics/rendering_regression_test.pl deleted file mode 100644 index a29bd575..00000000 --- a/unittests/autotestscripts_graphics/rendering_regression_test.pl +++ /dev/null @@ -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, ") -{ - $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; - } -} diff --git a/unittests/avitest/avitest.cpp b/unittests/avitest/avitest.cpp deleted file mode 100644 index 00029303..00000000 --- a/unittests/avitest/avitest.cpp +++ /dev/null @@ -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 -#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; -} - - - diff --git a/unittests/avitest/avitest.vpc b/unittests/avitest/avitest.vpc deleted file mode 100644 index cb6e1525..00000000 --- a/unittests/avitest/avitest.vpc +++ /dev/null @@ -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" - } -} diff --git a/unittests/inputtest/inputtest.cpp b/unittests/inputtest/inputtest.cpp deleted file mode 100644 index 5b9781b3..00000000 --- a/unittests/inputtest/inputtest.cpp +++ /dev/null @@ -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 -#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; -} - - - diff --git a/unittests/inputtest/inputtest.vpc b/unittests/inputtest/inputtest.vpc deleted file mode 100644 index 6ab8216e..00000000 --- a/unittests/inputtest/inputtest.vpc +++ /dev/null @@ -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 - } -} diff --git a/unittests/materialsystemtest/materialsystemtest.cpp b/unittests/materialsystemtest/materialsystemtest.cpp deleted file mode 100644 index 9a193bfc..00000000 --- a/unittests/materialsystemtest/materialsystemtest.cpp +++ /dev/null @@ -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 -#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; -} \ No newline at end of file diff --git a/unittests/materialsystemtest/materialsystemtest.vpc b/unittests/materialsystemtest/materialsystemtest.vpc deleted file mode 100644 index 740908dc..00000000 --- a/unittests/materialsystemtest/materialsystemtest.vpc +++ /dev/null @@ -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 - } -} diff --git a/unittests/mathlib_test/mathlib_test.cpp b/unittests/mathlib_test/mathlib_test.cpp deleted file mode 100644 index c3c1191a..00000000 --- a/unittests/mathlib_test/mathlib_test.cpp +++ /dev/null @@ -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 - -} - diff --git a/unittests/mathlib_test/mathlib_test.vpc b/unittests/mathlib_test/mathlib_test.vpc deleted file mode 100644 index 32dd5f34..00000000 --- a/unittests/mathlib_test/mathlib_test.vpc +++ /dev/null @@ -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 - } -} diff --git a/unittests/shaderapitest/shaderapitest.cpp b/unittests/shaderapitest/shaderapitest.cpp deleted file mode 100644 index 2f94b2f9..00000000 --- a/unittests/shaderapitest/shaderapitest.cpp +++ /dev/null @@ -1,1056 +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 -#include "appframework/tier2app.h" -#include "shaderapi/ishaderdevice.h" -#include "shaderapi/ishaderutil.h" -#include "shaderapi/ishaderapi.h" -#include "materialsystem/materialsystem_config.h" -#include "materialsystem/imaterialsystemhardwareconfig.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 "tier1/lzmadecoder.h" -#include "materialsystem/imesh.h" -#include "materialsystem/shader_vcs_version.h" -#include "../utils/bzip2/bzlib.h" - - -class CShaderUtilTemp : public CBaseAppSystem< IShaderUtil > -{ -public: - // Method to allow clients access to the MaterialSystem_Config - virtual MaterialSystem_Config_t& GetConfig() - { - static MaterialSystem_Config_t config; - return config; - } - - // Allows us to convert image formats - virtual bool ConvertImageFormat( unsigned char *src, enum ImageFormat srcImageFormat, - unsigned char *dst, enum ImageFormat dstImageFormat, - int width, int height, int srcStride = 0, int dstStride = 0 ) - { - return true; - } - - // Figures out the amount of memory needed by a bitmap - virtual int GetMemRequired( int width, int height, int depth, ImageFormat format, bool mipmap ) - { - return 0; - } - - // Gets image format info - virtual const ImageFormatInfo_t& ImageFormatInfo( ImageFormat fmt ) const - { - static ImageFormatInfo_t info; - return info; - } - - // Allows us to set the default shadow state - virtual void SetDefaultShadowState() { } - - // Allows us to set the default shader state - virtual void SetDefaultState( ) { } - - // Bind standard textures - virtual void BindStandardTexture( Sampler_t stage, StandardTextureId_t id ) { } - virtual void BindStandardVertexTexture( VertexTextureSampler_t stage, StandardTextureId_t id ) { } - virtual void GetStandardTextureDimensions( int *pWidth, int *pHeight, StandardTextureId_t id ) { *pWidth = *pHeight = 0; } - - // What are the lightmap dimensions? - virtual void GetLightmapDimensions( int *w, int *h ) { *w = *h = 0; } - - // These methods are called when the shader must eject + restore HW memory - virtual void ReleaseShaderObjects() {} - virtual void RestoreShaderObjects( CreateInterfaceFn shaderFactory, int nChangeFlags = 0 ) {} - - // Used to prevent meshes from drawing. - virtual bool IsInStubMode() { return false; } - virtual bool InFlashlightMode() const { return false; } - - // For the shader API to shove the current version of aniso level into the - // "definitive" place (g_config) when the shader API decides to change it. - // Eventually, we should have a better system of who owns the definitive - // versions of config vars. - virtual void NoteAnisotropicLevel( int currentLevel ) {} - - // NOTE: Stuff after this is added after shipping HL2. - - // Are we rendering through the editor? - virtual bool InEditorMode() const { return false; } - - // Gets the bound morph's vertex format; returns 0 if no morph is bound - virtual MorphFormat_t GetBoundMorphFormat() { return 0; } - - virtual ITexture *GetRenderTargetEx( int nRenderTargetID ) { return 0; } - - // Tells the material system to draw a buffer clearing quad - virtual void DrawClearBufferQuad( unsigned char r, unsigned char g, unsigned char b, unsigned char a, bool bClearColor, bool bClearAlpha, bool bClearDepth ) OVERRIDE {} - -#if defined( _X360 ) - virtual void ReadBackBuffer( Rect_t *pSrcRect, Rect_t *pDstRect, unsigned char *pData, ImageFormat dstFormat, int nDstStride ) {} -#endif - - // Calls from meshes to material system to handle queing/threading - virtual bool OnDrawMesh( IMesh *pMesh, int firstIndex, int numIndices ) { return false; } - virtual bool OnDrawMesh( IMesh *pMesh, CPrimList *pLists, int nLists ) { return false; } - virtual bool OnSetFlexMesh( IMesh *pStaticMesh, IMesh *pMesh, int nVertexOffsetInBytes ) { return false; } - virtual bool OnSetColorMesh( IMesh *pStaticMesh, IMesh *pMesh, int nVertexOffsetInBytes ) { return false; } - virtual bool OnSetPrimitiveType( IMesh *pMesh, MaterialPrimitiveType_t type ) { return false; } - virtual bool OnFlushBufferedPrimitives() { return false; } - - - virtual void SyncMatrices() {} - virtual void SyncMatrix( MaterialMatrixMode_t ) {} - virtual int MaxHWMorphBatchCount() const { return 0; } - - virtual void GetCurrentColorCorrection( ShaderColorCorrectionInfo_t* pInfo ) - { - pInfo->m_bIsEnabled = false; - pInfo->m_nLookupCount = 0; - pInfo->m_flDefaultWeight = 0.0f; - } - virtual void OnThreadEvent( uint32 threadEvent ) {} - - ShaderAPITextureHandle_t GetShaderAPITextureBindHandle( ITexture *pTexture, int nFrame, int nTextureChannel ) { return 0; } - - // Remove any materials from memory that aren't in use as determined - // by the IMaterial's reference count. - virtual void UncacheUnusedMaterials( bool bRecomputeStateSnapshots = false ) {} - - virtual MaterialThreadMode_t GetThreadMode( ) { return MATERIAL_SINGLE_THREADED; } - virtual bool IsRenderThreadSafe( ) { return true; } -}; - - -static CShaderUtilTemp g_pTemp; - -static IShaderDeviceMgr *g_pShaderDeviceMgr; - -EXPOSE_SINGLE_INTERFACE_GLOBALVAR( CShaderUtilTemp, IShaderUtil, - SHADER_UTIL_INTERFACE_VERSION, g_pTemp ) - -//----------------------------------------------------------------------------- -// 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 CShaderAPITestApp : 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( const char *pTitle, bool bWindowed, int w, int h ); - - // Sets up the game path - bool SetupSearchPaths(); - - // Waits for a keypress - bool WaitForKeypress(); - - // Displays information about all adapters - void DisplayAdapterInfo(); - - // Sets the video mode - bool SetMode(); - - // Creates really simple vertex + index buffers - void CreateSimpleBuffers( ShaderBufferType_t nVBType, ShaderBufferType_t nIBType, bool bBuffered ); - - // Destroys the buffers - void DestroyBuffers(); - - // Creates shaders - void CreateShaders( const char *pVShader, int nVBufLen, const char *pGShader, int nGBufLen, const char *pPShader, int nPBufLen ); - - // Destroys the buffers - void DestroyShaders(); - - // DrawUsingShaders - void TestColoredQuad( ShaderBufferType_t nVBType, ShaderBufferType_t nIBType, bool bBuffered ); - - // Tests dynamic buffers - void TestDynamicBuffers(); - - bool CreateDynamicCombos_Ver5( uint8 *pComboBuffer, bool bVertexShader ); - void LoadShaderFile( const char *pName, bool bVertexShader ); - - HWND m_HWnd; - IShaderAPI *m_pShaderAPI; - IShaderDevice *m_pShaderDevice; - - IIndexBuffer *m_pIndexBuffer; - IVertexBuffer *m_pVertexBuffer; - - VertexShaderHandle_t m_hVertexShader; - GeometryShaderHandle_t m_hGeometryShader; - PixelShaderHandle_t m_hPixelShader; -}; - -DEFINE_WINDOWED_STEAM_APPLICATION_OBJECT( CShaderAPITestApp ); - - -//----------------------------------------------------------------------------- -// Create all singleton systems -//----------------------------------------------------------------------------- -bool CShaderAPITestApp::Create() -{ - SpewOutputFunc( SpewFunc ); - - 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"; - } - - AppModule_t module = LoadModule( pShaderDLL ); - if ( module == APP_MODULE_INVALID ) - { - if ( module == APP_MODULE_INVALID ) - { - pShaderDLL = "shaderapidx9.dll"; - module = LoadModule( pShaderDLL ); - if ( module == APP_MODULE_INVALID ) - { - pShaderDLL = "shaderapiempty.dll"; - module = LoadModule( pShaderDLL ); - if ( module == APP_MODULE_INVALID ) - return false; - } - } - } - - g_pShaderDeviceMgr = (IShaderDeviceMgr*)AddSystem( module, SHADER_DEVICE_MGR_INTERFACE_VERSION ); - - // So that shaderapi can get ahold of our bogus IShaderUtil - module = LoadModule( Sys_GetFactoryThis() ); - AddSystem( module, SHADER_UTIL_INTERFACE_VERSION ); - - return ( g_pShaderDeviceMgr != NULL ); -} - -void CShaderAPITestApp::Destroy() -{ -} - - -//----------------------------------------------------------------------------- -// Window callback -//----------------------------------------------------------------------------- -static LRESULT CALLBACK ShaderAPITestWndProc( 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 CShaderAPITestApp::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 = ShaderAPITestWndProc; - 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 CShaderAPITestApp::SetupSearchPaths() -{ - if ( !BaseClass::SetupSearchPaths( NULL, false, true ) ) - return false; - - g_pFullFileSystem->AddSearchPath( GetGameInfoPath(), "SKIN", PATH_ADD_TO_HEAD ); - return true; -} - - -//----------------------------------------------------------------------------- -// PreInit, PostShutdown -//----------------------------------------------------------------------------- -bool CShaderAPITestApp::PreInit( ) -{ - if ( !BaseClass::PreInit() ) - return false; - - if (!g_pFullFileSystem || !g_pShaderDeviceMgr ) - 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; - - return true; -} - -void CShaderAPITestApp::PostShutdown( ) -{ - BaseClass::PostShutdown(); -} - - -//----------------------------------------------------------------------------- -// Waits for a keypress -//----------------------------------------------------------------------------- -bool CShaderAPITestApp::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; -} - - -//----------------------------------------------------------------------------- -// Displays adapter information -//----------------------------------------------------------------------------- -void CShaderAPITestApp::DisplayAdapterInfo() -{ - int nAdapterCount = g_pShaderDeviceMgr->GetAdapterCount(); - for ( int i = 0; i < nAdapterCount; ++i ) - { - MaterialAdapterInfo_t info; - g_pShaderDeviceMgr->GetAdapterInfo( i, info ); - - Msg( "Adapter %d\n", i ); - Msg( "\tName: %s\n\tVendor: 0x%X\n\tDevice: 0x%X\n\tSubSystem: 0x%X\n\tRevision: 0x%X\n\tRecommended DX Level: %d\n\tMax DX Level: %d\n", - info.m_pDriverName, info.m_VendorID, info.m_DeviceID, info.m_SubSysID, info.m_Revision, info.m_nDXSupportLevel, info.m_nMaxDXSupportLevel ); - - CUtlBuffer buf( 0, 0, CUtlBuffer::TEXT_BUFFER ); - KeyValues *pConfiguration = new KeyValues( "Config" ); - g_pShaderDeviceMgr->GetRecommendedConfigurationInfo( i, info.m_nDXSupportLevel, pConfiguration ); - pConfiguration->RecursiveSaveToFile( buf, 1 ); - Msg( "\tConfiguration:\n%s", ( const char * )buf.Base() ); - Msg( "\n" ); - - int nModeCount = g_pShaderDeviceMgr->GetModeCount( i ); - Msg( "\tMode Count : %d\n", nModeCount ); - for ( int j = 0; j < nModeCount; ++j ) - { - ShaderDisplayMode_t mode; - g_pShaderDeviceMgr->GetModeInfo( &mode, i, j ); - Msg( "\t\tH: %5d W: %5d Format: %3d Refresh %3d/%3d\n", - mode.m_nWidth, mode.m_nHeight, mode.m_Format, mode.m_nRefreshRateNumerator, mode.m_nRefreshRateDenominator ); - } - } -} - - -//----------------------------------------------------------------------------- -// Sets the video mode -//----------------------------------------------------------------------------- -bool CShaderAPITestApp::SetMode() -{ - int nAdapterCount = g_pShaderDeviceMgr->GetAdapterCount(); - int nAdapter = CommandLine()->ParmValue( "-adapter", 0 ); - if ( nAdapter >= nAdapterCount ) - { - Warning( "Specified too high an adapter number on the command-line (%d/%d)!\n", nAdapter, nAdapterCount ); - return false; - } - - ShaderDeviceInfo_t mode; - mode.m_DisplayMode.m_nWidth = 1024; - mode.m_DisplayMode.m_nHeight = 768; - mode.m_DisplayMode.m_Format = IMAGE_FORMAT_BGRA8888; - mode.m_DisplayMode.m_nRefreshRateNumerator = 60; - mode.m_DisplayMode.m_nRefreshRateDenominator = 1; - mode.m_bWindowed = true; - mode.m_nBackBufferCount = 1; - - CreateInterfaceFn shaderFactory = g_pShaderDeviceMgr->SetMode( m_HWnd, nAdapter, mode ); - if ( !shaderFactory ) - { - Warning( "Unable to set mode!\n" ); - return false; - } - - m_pShaderAPI = (IShaderAPI*)shaderFactory( SHADERAPI_INTERFACE_VERSION, NULL ); - m_pShaderDevice = (IShaderDevice*)shaderFactory( SHADER_DEVICE_INTERFACE_VERSION, NULL ); - if ( !m_pShaderAPI || !m_pShaderDevice ) - { - Warning( "Unable to get IShaderAPI or IShaderDevice interface!\n" ); - return false; - } - - return true; -} - - -//----------------------------------------------------------------------------- -// Creates really simple vertex + index buffers -//----------------------------------------------------------------------------- -void CShaderAPITestApp::CreateSimpleBuffers( ShaderBufferType_t nVBType, ShaderBufferType_t nIBType, bool bBuffered ) -{ - VertexFormat_t fmt = VERTEX_POSITION | VERTEX_NORMAL | VERTEX_COLOR; - if ( IsDynamicBufferType( nVBType ) ) - { - m_pVertexBuffer = m_pShaderDevice->CreateVertexBuffer( - nVBType, VERTEX_FORMAT_UNKNOWN, 1024, "test" ); - } - else - { - m_pVertexBuffer = m_pShaderDevice->CreateVertexBuffer( - nVBType, fmt, 4, "test" ); - } - - 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; - - CVertexBuilder vb( m_pVertexBuffer, fmt ); - vb.Lock( 4 ); - - vb.Position3f( -1.0f, -1.0f, 0.5f ); - vb.Normal3f( 0.0f, 0.0f, 1.0f ); - vb.Color4ubv( s_pColors[nCount++ % 4] ); - vb.AdvanceVertex(); - - vb.Position3f( 1.0f, -1.0f, 0.5f ); - vb.Normal3f( 0.0f, 0.0f, 1.0f ); - vb.Color4ubv( s_pColors[nCount++ % 4] ); - vb.AdvanceVertex(); - - vb.Position3f( 1.0f, 1.0f, 0.5f ); - vb.Normal3f( 0.0f, 0.0f, 1.0f ); - vb.Color4ubv( s_pColors[nCount++ % 4] ); - vb.AdvanceVertex(); - - vb.Position3f( -1.0f, 1.0f, 0.5f ); - vb.Normal3f( 0.0f, 0.0f, 1.0f ); - vb.Color4ubv( s_pColors[nCount++ % 4] ); - vb.AdvanceVertex(); - - vb.SpewData( ); - vb.Unlock( ); - - ++nCount; - - if ( IsDynamicBufferType( nIBType ) ) - { - m_pIndexBuffer = m_pShaderDevice->CreateIndexBuffer( nIBType, MATERIAL_INDEX_FORMAT_UNKNOWN, 64, "test" ); - } - else - { - m_pIndexBuffer = m_pShaderDevice->CreateIndexBuffer( nIBType, MATERIAL_INDEX_FORMAT_16BIT, 6, "test" ); - } - CIndexBuilder ib( m_pIndexBuffer, MATERIAL_INDEX_FORMAT_16BIT ); - - ib.Lock( 6, 0 ); - ib.FastIndex( 0 ); - ib.FastIndex( 2 ); - ib.FastIndex( 1 ); - ib.FastIndex( 0 ); - ib.FastIndex( 3 ); - ib.FastIndex( 2 ); - ib.SpewData(); - ib.Unlock( ); - - m_pShaderAPI->BindVertexBuffer( 0, m_pVertexBuffer, vb.Offset(), 0, vb.TotalVertexCount(), fmt ); - m_pShaderAPI->BindIndexBuffer( m_pIndexBuffer, ib.Offset() ); -} - - -//----------------------------------------------------------------------------- -// Destroys the buffers -//----------------------------------------------------------------------------- -void CShaderAPITestApp::DestroyBuffers() -{ - if ( m_pVertexBuffer ) - { - m_pShaderDevice->DestroyVertexBuffer( m_pVertexBuffer ); - m_pVertexBuffer = NULL; - } - - if ( m_pIndexBuffer ) - { - m_pShaderDevice->DestroyIndexBuffer( m_pIndexBuffer ); - m_pIndexBuffer = NULL; - } -} - - -//----------------------------------------------------------------------------- -// shader programs -//----------------------------------------------------------------------------- -static const char s_pSimpleVertexShader[] = - "struct VS_INPUT " - "{ " - " float3 vPos : POSITION0; " - " float4 vColor : COLOR0; " - "}; " - " " - "struct VS_OUTPUT " - "{ " - " float4 projPos : POSITION0; " - " float4 vertexColor : COLOR0; " - "}; " - " " - "VS_OUTPUT main( const VS_INPUT v ) " - "{ " - " VS_OUTPUT o = ( VS_OUTPUT )0; " - " " - " o.projPos.xyz = v.vPos; " - " o.projPos.w = 1.0f; " - " o.vertexColor = v.vColor; " - " return o; " - "} " - ""; - -static const char s_pSimplePixelShader[] = - "struct PS_INPUT " - "{ " - " float4 projPos : POSITION0; " - " float4 vColor : COLOR0; " - "}; " - " " - "float4 main( const PS_INPUT i ) : COLOR " - "{ " - " return i.vColor; " - "} " - ""; - - -//----------------------------------------------------------------------------- -// Create, destroy shaders -//----------------------------------------------------------------------------- -void CShaderAPITestApp::CreateShaders( const char *pVShader, int nVBufLen, const char *pGShader, int nGBufLen, const char *pPShader, int nPBufLen ) -{ - const char *pVertexShaderVersion = g_pMaterialSystemHardwareConfig->GetDXSupportLevel() == 100 ? "vs_4_0" : "vs_2_0"; - const char *pPixelShaderVersion = g_pMaterialSystemHardwareConfig->GetDXSupportLevel() == 100 ? "ps_4_0" : "ps_2_0"; - - // Compile shaders - m_hVertexShader = m_pShaderDevice->CreateVertexShader( pVShader, nVBufLen, pVertexShaderVersion ); - Assert( m_hVertexShader != VERTEX_SHADER_HANDLE_INVALID ); - - m_hGeometryShader = GEOMETRY_SHADER_HANDLE_INVALID; - if ( g_pMaterialSystemHardwareConfig->GetDXSupportLevel() >= 100 ) - { - // m_hGeometryShader = m_pShaderDevice->CreateGeometryShader( pGShader, nGBufLen, "gs_4_0" ); - // Assert( m_hGeometryShader != GEOMETRY_SHADER_HANDLE_INVALID ); - } - - m_hPixelShader = m_pShaderDevice->CreatePixelShader( pPShader, nPBufLen, pPixelShaderVersion ); - Assert( m_hPixelShader != PIXEL_SHADER_HANDLE_INVALID ); - - m_pShaderAPI->BindVertexShader( m_hVertexShader ); - m_pShaderAPI->BindGeometryShader( m_hGeometryShader ); - m_pShaderAPI->BindPixelShader( m_hPixelShader ); -} - -void CShaderAPITestApp::DestroyShaders() -{ - m_pShaderDevice->DestroyVertexShader( m_hVertexShader ); - m_pShaderDevice->DestroyGeometryShader( m_hGeometryShader ); - m_pShaderDevice->DestroyPixelShader( m_hPixelShader ); - - m_hVertexShader = VERTEX_SHADER_HANDLE_INVALID; - m_hGeometryShader = GEOMETRY_SHADER_HANDLE_INVALID; - m_hPixelShader = PIXEL_SHADER_HANDLE_INVALID; -} - - -//----------------------------------------------------------------------------- -// DrawQuad -//----------------------------------------------------------------------------- -void CShaderAPITestApp::TestColoredQuad( ShaderBufferType_t nVBType, ShaderBufferType_t nIBType, bool bBuffered ) -{ - // clear (so that we can make sure that we aren't getting results from the previous quad) - m_pShaderAPI->ClearColor3ub( RandomInt( 0, 100 ), RandomInt( 0, 100 ), RandomInt( 190, 255 ) ); - m_pShaderAPI->ClearBuffers( true, false, false, -1, -1 ); - - CreateSimpleBuffers( nVBType, nIBType, bBuffered ); - - // Draw a quad! - CreateShaders( s_pSimpleVertexShader, sizeof(s_pSimpleVertexShader), - NULL, 0, s_pSimplePixelShader, sizeof(s_pSimplePixelShader) ); - - m_pShaderAPI->Draw( MATERIAL_TRIANGLES, 0, 6 ); - m_pShaderDevice->Present(); - - DestroyShaders(); - - DestroyBuffers(); -} - - -//----------------------------------------------------------------------------- -// Tests dynamic buffers -//----------------------------------------------------------------------------- -void CShaderAPITestApp::TestDynamicBuffers() -{ - m_pVertexBuffer = m_pShaderDevice->CreateVertexBuffer( - SHADER_BUFFER_TYPE_DYNAMIC, VERTEX_FORMAT_UNKNOWN, 0x100, "test" ); - m_pIndexBuffer = m_pShaderDevice->CreateIndexBuffer( - SHADER_BUFFER_TYPE_DYNAMIC, MATERIAL_INDEX_FORMAT_UNKNOWN, 30, "test" ); - - CreateShaders( s_pSimpleVertexShader, sizeof(s_pSimpleVertexShader), - NULL, 0, s_pSimplePixelShader, sizeof(s_pSimplePixelShader) ); - - // clear (so that we can make sure that we aren't getting results from the previous quad) - m_pShaderAPI->ClearColor3ub( RandomInt( 0, 100 ), RandomInt( 0, 100 ), RandomInt( 190, 255 ) ); - m_pShaderAPI->ClearBuffers( true, false, false, -1, -1 ); - - 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; - - VertexFormat_t fmt = VERTEX_POSITION | VERTEX_NORMAL | VERTEX_COLOR; - const int nLoopCount = 8; - float flWidth = 2.0f / nLoopCount; - for ( int i = 0; i < nLoopCount; ++i ) - { - CVertexBuilder vb( m_pVertexBuffer, fmt ); - vb.Lock( 4 ); - - vb.Position3f( -1.0f + i * flWidth, -1.0f, 0.5f ); - vb.Normal3f( 0.0f, 0.0f, 1.0f ); - vb.Color4ubv( s_pColors[nCount++ % 4] ); - vb.AdvanceVertex(); - - vb.Position3f( -1.0f + i * flWidth + flWidth, -1.0f, 0.5f ); - vb.Normal3f( 0.0f, 0.0f, 1.0f ); - vb.Color4ubv( s_pColors[nCount++ % 4] ); - vb.AdvanceVertex(); - - vb.Position3f( -1.0f + i * flWidth + flWidth, 1.0f, 0.5f ); - vb.Normal3f( 0.0f, 0.0f, 1.0f ); - vb.Color4ubv( s_pColors[nCount++ % 4] ); - vb.AdvanceVertex(); - - vb.Position3f( -1.0f + i * flWidth, 1.0f, 0.5f ); - vb.Normal3f( 0.0f, 0.0f, 1.0f ); - vb.Color4ubv( s_pColors[nCount++ % 4] ); - vb.AdvanceVertex(); - vb.SpewData(); - vb.Unlock( ); - - ++nCount; - - CIndexBuilder ib( m_pIndexBuffer, MATERIAL_INDEX_FORMAT_16BIT ); - - ib.Lock( 6, vb.GetFirstVertex() ); - ib.FastIndex( 0 ); - ib.FastIndex( 2 ); - ib.FastIndex( 1 ); - ib.FastIndex( 0 ); - ib.FastIndex( 3 ); - ib.FastIndex( 2 ); - ib.SpewData(); - ib.Unlock( ); - - m_pShaderAPI->BindVertexBuffer( 0, m_pVertexBuffer, vb.Offset(), vb.GetFirstVertex(), vb.TotalVertexCount(), fmt ); - m_pShaderAPI->BindIndexBuffer( m_pIndexBuffer, ib.Offset() ); - m_pShaderAPI->Draw( MATERIAL_TRIANGLES, ib.GetFirstIndex(), ib.TotalIndexCount() ); - } - - m_pShaderDevice->Present(); - - ++nCount; - - DestroyShaders(); - DestroyBuffers(); -} - - -//----------------------------------------------------------------------------- -// Create dynamic combos -//----------------------------------------------------------------------------- -static uint32 NextULONG( uint8 * &pData ) -{ - // handle unaligned read - uint32 nRet; - memcpy( &nRet, pData, sizeof( nRet ) ); - pData += sizeof( nRet ); - return nRet; -} - -bool CShaderAPITestApp::CreateDynamicCombos_Ver5( uint8 *pComboBuffer, bool bVertexShader ) -{ - uint8 *pCompressedShaders = pComboBuffer; - uint8 *pUnpackBuffer = new uint8[MAX_SHADER_UNPACKED_BLOCK_SIZE]; - - // now, loop through all blocks - bool bOK = true; - while ( bOK ) - { - uint32 nBlockSize = NextULONG( pCompressedShaders ); - if ( nBlockSize == 0xffffffff ) - { - // any more blocks? - break; - } - - switch( nBlockSize & 0xc0000000 ) - { - case 0: // bzip2 - { - // uncompress - uint32 nOutsize = MAX_SHADER_UNPACKED_BLOCK_SIZE; - int nRslt = BZ2_bzBuffToBuffDecompress( - reinterpret_cast( pUnpackBuffer ), - &nOutsize, - reinterpret_cast( pCompressedShaders ), - nBlockSize, 1, 0 ); - if ( nRslt < 0 ) - { - // errors are negative for bzip - Assert( 0 ); - Warning( "BZIP Error (%d) decompressing shader", nRslt ); - bOK = false; - } - - pCompressedShaders += nBlockSize; - nBlockSize = nOutsize; // how much data there is - } - break; - - case 0x80000000: // uncompressed - { - // not compressed, as is - nBlockSize &= 0x3fffffff; - memcpy( pUnpackBuffer, pCompressedShaders, nBlockSize ); - pCompressedShaders += nBlockSize; - } - break; - - case 0x40000000: // lzma compressed - { - nBlockSize &= 0x3fffffff; - - size_t nOutsize = CLZMA::Uncompress( - reinterpret_cast( pCompressedShaders ), - pUnpackBuffer ); - pCompressedShaders += nBlockSize; - nBlockSize = nOutsize; // how much data there is - } - break; - - default: - { - Assert( 0 ); - Error(" unrecognized shader compression type = file corrupt?"); - bOK = false; - } - } - - uint8 *pReadPtr = pUnpackBuffer; - while ( pReadPtr < pUnpackBuffer+nBlockSize ) - { - uint32 nCombo_ID = NextULONG( pReadPtr ); - (void)nCombo_ID; // Suppress local variable is initialized but not referenced warning - uint32 nShaderSize = NextULONG( pReadPtr ); - - CUtlBuffer buf( pReadPtr, nShaderSize ); - if ( bVertexShader ) - { - m_pShaderDevice->CreateVertexShader( buf, "vs_2_0" ); - } - else - { - m_pShaderDevice->CreatePixelShader( buf, "ps_2_b" ); - } - - pReadPtr += nShaderSize; - } - } - - delete[] pUnpackBuffer; - - return bOK; -} - - -//----------------------------------------------------------------------------- -// Load shader -//----------------------------------------------------------------------------- -void CShaderAPITestApp::LoadShaderFile( const char *pName, bool bVertexShader ) -{ - // next, try the fxc dir - char pFileName[MAX_PATH]; - Q_snprintf( pFileName, MAX_PATH, "..\\hl2\\shaders\\fxc\\%s.vcs", pName ); - - FileHandle_t hFile = g_pFullFileSystem->Open( pFileName, "rb", "EXECUTABLE_PATH" ); - if ( hFile == FILESYSTEM_INVALID_HANDLE ) - { - Warning( "Couldn't load %s shader %s\n", bVertexShader ? "vertex" : "pixel", pName ); - return; - } - - ShaderHeader_t header; - g_pFullFileSystem->Read( &header, sizeof( ShaderHeader_t ), hFile ); - - // cache the dictionary - int nComboSize = header.m_nNumStaticCombos * sizeof( StaticComboRecord_t ); - StaticComboRecord_t *pRecords = (StaticComboRecord_t *)malloc( nComboSize ); - g_pFullFileSystem->Read( pRecords, nComboSize, hFile ); - - for ( unsigned int i = 0; i < header.m_nNumStaticCombos - 1; ++i ) - { - int nStartingOffset = pRecords[i].m_nFileOffset; - int nEndingOffset = pRecords[i+1].m_nFileOffset; - int nShaderSize = nEndingOffset - nStartingOffset; - - uint8 *pBuf = (uint8*)malloc( nShaderSize ); - g_pFullFileSystem->Seek( hFile, nStartingOffset, FILESYSTEM_SEEK_HEAD ); - g_pFullFileSystem->Read( pBuf, nShaderSize, hFile ); - - CreateDynamicCombos_Ver5( pBuf, bVertexShader ); - free( pBuf ); - - } - - free( pRecords ); - g_pFullFileSystem->Close( hFile ); - -} - - -//----------------------------------------------------------------------------- -// main application -//----------------------------------------------------------------------------- -int CShaderAPITestApp::Main() -{ - DisplayAdapterInfo(); - if ( !SetMode() ) - return 0; - - // Test buffer clearing - m_pShaderAPI->ClearColor3ub( RandomInt( 0, 100 ), RandomInt( 0, 100 ), RandomInt( 190, 255 ) ); - m_pShaderAPI->ClearBuffers( true, false, false, -1, -1 ); - m_pShaderDevice->Present(); - - SetWindowText( m_HWnd, "ClearBuffers test results . . hit a key" ); - - if ( !WaitForKeypress() ) - return 1; - - // Test viewport - int nMaxViewports = g_pMaterialSystemHardwareConfig->MaxViewports(); - ShaderViewport_t* pViewports = ( ShaderViewport_t* )_alloca( nMaxViewports * sizeof(ShaderViewport_t) ); - for ( int i = 0; i < nMaxViewports; ++i ) - { - int x = RandomInt( 0, 100 ); - int y = RandomInt( 0, 100 ); - int w = RandomInt( 100, 200 ); - int h = RandomInt( 100, 200 ); - pViewports[i].Init( x, y, w, h ); - - m_pShaderAPI->SetViewports( i+1, pViewports ); - } - - SetWindowText( m_HWnd, "SetViewports test results . . hit a key" ); - - if ( !WaitForKeypress() ) - return 1; - - // Sets up a full-screen viewport - int w, h; - m_pShaderDevice->GetWindowSize( w, h ); - - ShaderViewport_t viewport; - viewport.Init( 0, 0, w, h ); - m_pShaderAPI->SetViewports( 1, &viewport ); - - // Test drawing a full-screen quad with interpolated vertex colors for every combo of static/dynamic VB, static dynamic IB, buffered/non-buffered. - char buf[1024]; - for ( int nVBType = 0; nVBType < SHADER_BUFFER_TYPE_COUNT; ++nVBType ) - { - // FIXME: Remove - if ( nVBType > SHADER_BUFFER_TYPE_DYNAMIC ) - continue; - - for( int nIBType = 0; nIBType < SHADER_BUFFER_TYPE_COUNT; ++nIBType ) - { - // FIXME: Remove - if ( nIBType > SHADER_BUFFER_TYPE_DYNAMIC ) - continue; - - // MESHFIXME: make buffered vertex buffers/index buffers work. - int nBuffered = 0; -// for( nBuffered = 0; nBuffered < 2; nBuffered++ ) - { - TestColoredQuad( (ShaderBufferType_t)nVBType, (ShaderBufferType_t)nIBType, nBuffered != 0 ); - - sprintf( buf, "TestColoredQuad results VB: %d IB: %d Buffered: %d HIT A KEY!", - nVBType, nIBType, nBuffered != 0 ); - SetWindowText( m_HWnd, buf ); - - if ( !WaitForKeypress() ) - return 1; - } - } - } - - SetWindowText( m_HWnd, "Dynamic Buffer Test: HIT A KEY!" ); - TestDynamicBuffers(); - if ( !WaitForKeypress() ) - return 1; - - g_pMaterialSystemHardwareConfig->OverrideStreamOffsetSupport( true, false ); - - SetWindowText( m_HWnd, "Dynamic Buffer Test (no stream offset): HIT A KEY!" ); - TestDynamicBuffers(); - if ( !WaitForKeypress() ) - return 1; - - g_pMaterialSystemHardwareConfig->OverrideStreamOffsetSupport( false, false ); - - return 1; -} diff --git a/unittests/shaderapitest/shaderapitest.vpc b/unittests/shaderapitest/shaderapitest.vpc deleted file mode 100644 index 4bb31405..00000000 --- a/unittests/shaderapitest/shaderapitest.vpc +++ /dev/null @@ -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 - } -} diff --git a/unittests/soundtest/soundtest.cpp b/unittests/soundtest/soundtest.cpp deleted file mode 100644 index e43b3c5c..00000000 --- a/unittests/soundtest/soundtest.cpp +++ /dev/null @@ -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 -#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 -{ -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; -} - - - diff --git a/unittests/soundtest/soundtest.vpc b/unittests/soundtest/soundtest.vpc deleted file mode 100644 index 3e5ab430..00000000 --- a/unittests/soundtest/soundtest.vpc +++ /dev/null @@ -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" - } -} diff --git a/unittests/testprocess/testprocess.cpp b/unittests/testprocess/testprocess.cpp deleted file mode 100644 index 23fbde82..00000000 --- a/unittests/testprocess/testprocess.cpp +++ /dev/null @@ -1,191 +0,0 @@ -//========= Copyright Valve Corporation, All rights reserved. ============// -// -// Purpose: -// -// $NoKeywords: $ -// -//===========================================================================// - -#include -#include "tier0/icommandline.h" -#include -#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; -} - - - - diff --git a/unittests/testprocess/testprocess.exe b/unittests/testprocess/testprocess.exe deleted file mode 100644 index eee66a31..00000000 Binary files a/unittests/testprocess/testprocess.exe and /dev/null differ diff --git a/unittests/testprocess/testprocess.pdb b/unittests/testprocess/testprocess.pdb deleted file mode 100644 index d40bd3c8..00000000 Binary files a/unittests/testprocess/testprocess.pdb and /dev/null differ diff --git a/unittests/testprocess/testprocess.vpc b/unittests/testprocess/testprocess.vpc deleted file mode 100644 index 44cc7469..00000000 --- a/unittests/testprocess/testprocess.vpc +++ /dev/null @@ -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 - } -}