mirror of
https://github.com/Ed94/HandmadeHero.git
synced 2024-12-22 06:14:45 -08:00
Fixed bugs with optimized builds
Symbol table for engine module was out of order.
This commit is contained in:
parent
0746cbd504
commit
d76163ae84
6
.vscode/bookmarks.json
vendored
6
.vscode/bookmarks.json
vendored
@ -19,17 +19,17 @@
|
|||||||
"label": "Timing"
|
"label": "Timing"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"line": 1477,
|
"line": 1478,
|
||||||
"column": 4,
|
"column": 4,
|
||||||
"label": "Main Loop : Audio Processing"
|
"label": "Main Loop : Audio Processing"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"line": 1596,
|
"line": 1597,
|
||||||
"column": 2,
|
"column": 2,
|
||||||
"label": "Main Loop : Timing Update"
|
"label": "Main Loop : Timing Update"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"line": 1680,
|
"line": 1681,
|
||||||
"column": 0,
|
"column": 0,
|
||||||
"label": "Main Loop : End"
|
"label": "Main Loop : End"
|
||||||
}
|
}
|
||||||
|
Binary file not shown.
@ -299,7 +299,6 @@ void play_input( EngineState* state, InputState* input, platform::ModuleAPI* pla
|
|||||||
if ( controller->Keyboard )
|
if ( controller->Keyboard )
|
||||||
{
|
{
|
||||||
*controller->Keyboard = new_input.Controllers[idx].Keyboard;
|
*controller->Keyboard = new_input.Controllers[idx].Keyboard;
|
||||||
printf("keyboard D key: %d\n", controller->Keyboard->D.EndedDown );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( controller->Mouse )
|
if ( controller->Mouse )
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
// Casting
|
// Casting
|
||||||
|
|
||||||
#define ccast( Type, Value ) ( * const_cast< Type* >( & (Value) ) )
|
#define ccast( Type, Value ) ( const_cast< Type >( (Value) ) )
|
||||||
#define pcast( Type, Value ) ( * reinterpret_cast< Type* >( & ( Value ) ) )
|
#define pcast( Type, Value ) ( * reinterpret_cast< Type* >( & ( Value ) ) )
|
||||||
#define rcast( Type, Value ) reinterpret_cast< Type >( Value )
|
#define rcast( Type, Value ) reinterpret_cast< Type >( Value )
|
||||||
#define scast( Type, Value ) static_cast< Type >( Value )
|
#define scast( Type, Value ) static_cast< Type >( Value )
|
||||||
|
@ -18,6 +18,8 @@
|
|||||||
#pragma warning( disable: 5045 ) // Compiler will insert Spectre mitigation for memory load if /Qspectre switch specified
|
#pragma warning( disable: 5045 ) // Compiler will insert Spectre mitigation for memory load if /Qspectre switch specified
|
||||||
#pragma warning( disable: 5264 ) // Support for 'const' variables unused
|
#pragma warning( disable: 5264 ) // Support for 'const' variables unused
|
||||||
#pragma warning( disable: 4820 ) // Support auto-adding padding to structs
|
#pragma warning( disable: 4820 ) // Support auto-adding padding to structs
|
||||||
|
#pragma warning( disable: 4711 ) // Support automatic inline expansion
|
||||||
|
#pragma warning( disable: 4710 ) // Support automatic inline expansion
|
||||||
|
|
||||||
// TODO(Ed) : REMOVE THESE WHEN HE GETS TO THEM
|
// TODO(Ed) : REMOVE THESE WHEN HE GETS TO THEM
|
||||||
#include <math.h> // TODO : Implement math ourselves
|
#include <math.h> // TODO : Implement math ourselves
|
||||||
|
@ -7,7 +7,7 @@ void str_concat( u32 dest_size, char* dest
|
|||||||
, u32 str_b_len, char const* str_b );
|
, u32 str_b_len, char const* str_b );
|
||||||
u32 str_length( char const* str );
|
u32 str_length( char const* str );
|
||||||
|
|
||||||
#define str_ascii( str ) { sizeof( str ) - 1, str }
|
#define str_ascii( str ) { sizeof( str ) - 1, ccast( char*, str) }
|
||||||
|
|
||||||
// Length tracked raw strings.
|
// Length tracked raw strings.
|
||||||
struct Str
|
struct Str
|
||||||
@ -118,7 +118,7 @@ void str_concat( u32 dest_size, char* dest
|
|||||||
char* dest_b = dest + str_a_len;
|
char* dest_b = dest + str_a_len;
|
||||||
if ( str_a_len > str_b_len )
|
if ( str_a_len > str_b_len )
|
||||||
{
|
{
|
||||||
u32 left = str_a_len;
|
u32 left = str_b_len;
|
||||||
while ( left-- )
|
while ( left-- )
|
||||||
{
|
{
|
||||||
*dest_a = *str_a;
|
*dest_a = *str_a;
|
||||||
@ -133,14 +133,14 @@ void str_concat( u32 dest_size, char* dest
|
|||||||
left = str_a_len - str_b_len;
|
left = str_a_len - str_b_len;
|
||||||
while ( left-- )
|
while ( left-- )
|
||||||
{
|
{
|
||||||
*dest_b = *str_b;
|
*dest_a = *str_a;
|
||||||
++ dest_b;
|
++ dest_a;
|
||||||
++ str_b;
|
++ str_a;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( str_a_len < str_b_len )
|
else if ( str_a_len < str_b_len )
|
||||||
{
|
{
|
||||||
u32 left = str_b_len;
|
u32 left = str_a_len;
|
||||||
while ( left-- )
|
while ( left-- )
|
||||||
{
|
{
|
||||||
*dest_a = *str_a;
|
*dest_a = *str_a;
|
||||||
@ -154,9 +154,9 @@ void str_concat( u32 dest_size, char* dest
|
|||||||
left = str_b_len - str_a_len;
|
left = str_b_len - str_a_len;
|
||||||
while ( left-- )
|
while ( left-- )
|
||||||
{
|
{
|
||||||
*dest_a = *str_a;
|
*dest_b = *str_b;
|
||||||
++ dest_a;
|
++ dest_b;
|
||||||
++ str_a;
|
++ str_b;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1064,9 +1064,9 @@ void* get_binary_module_symbol( BinaryModule module, char const* symbol_name )
|
|||||||
|
|
||||||
#pragma region Engine Module API
|
#pragma region Engine Module API
|
||||||
|
|
||||||
constexpr Str FName_Engine_DLL = str_ascii("handmade_engine.dll");
|
constexpr const Str FName_Engine_DLL = str_ascii("handmade_engine.dll");
|
||||||
constexpr Str FName_Engine_DLL_InUse = str_ascii("handmade_engine_in_use.dll");
|
constexpr const Str FName_Engine_DLL_InUse = str_ascii("handmade_engine_in_use.dll");
|
||||||
constexpr Str FName_Engine_PDB_Lock = str_ascii("handmade_engine.pdb.lock");
|
constexpr const Str FName_Engine_PDB_Lock = str_ascii("handmade_engine.pdb.lock");
|
||||||
|
|
||||||
global HMODULE Lib_Handmade_Engine = nullptr;
|
global HMODULE Lib_Handmade_Engine = nullptr;
|
||||||
global StrFixed< S16_MAX > Path_Engine_DLL;
|
global StrFixed< S16_MAX > Path_Engine_DLL;
|
||||||
@ -1093,7 +1093,7 @@ engine::ModuleAPI load_engine_module_api()
|
|||||||
|
|
||||||
File symbol_table {};
|
File symbol_table {};
|
||||||
symbol_table.Path = path_handmade_engine_symbols;
|
symbol_table.Path = path_handmade_engine_symbols;
|
||||||
if ( ! file_read_content( & symbol_table ) )
|
if ( file_read_content( & symbol_table ), symbol_table.Size == 0 )
|
||||||
{
|
{
|
||||||
fatal( "Failed to load symbol table for handmade engine module!" );
|
fatal( "Failed to load symbol table for handmade engine module!" );
|
||||||
return {};
|
return {};
|
||||||
@ -1218,7 +1218,8 @@ WinMain( HINSTANCE instance, HINSTANCE prev_instance, LPSTR commandline, int sho
|
|||||||
}
|
}
|
||||||
|
|
||||||
window_handle = CreateWindowExW(
|
window_handle = CreateWindowExW(
|
||||||
WS_EX_LAYERED | WS_EX_TOPMOST,
|
// WS_EX_LAYERED | WS_EX_TOPMOST,
|
||||||
|
WS_EX_LAYERED,
|
||||||
window_class.lpszClassName,
|
window_class.lpszClassName,
|
||||||
L"Handmade Hero",
|
L"Handmade Hero",
|
||||||
WS_Overlapped_Window | WS_Initially_Visible,
|
WS_Overlapped_Window | WS_Initially_Visible,
|
||||||
|
@ -10,7 +10,7 @@ Push-Location $path_root
|
|||||||
|
|
||||||
#region Arguments
|
#region Arguments
|
||||||
$vendor = $null
|
$vendor = $null
|
||||||
$optimized = $null
|
$optimize = $null
|
||||||
$debug = $null
|
$debug = $null
|
||||||
$analysis = $false
|
$analysis = $false
|
||||||
$dev = $false
|
$dev = $false
|
||||||
@ -25,7 +25,7 @@ Push-Location $path_root
|
|||||||
if ( $args ) { $args | ForEach-Object {
|
if ( $args ) { $args | ForEach-Object {
|
||||||
switch ($_){
|
switch ($_){
|
||||||
{ $_ -in $vendors } { $vendor = $_; break }
|
{ $_ -in $vendors } { $vendor = $_; break }
|
||||||
"optimized" { $optimized = $true }
|
"optimize" { $optimize = $true }
|
||||||
"debug" { $debug = $true }
|
"debug" { $debug = $true }
|
||||||
"analysis" { $analysis = $true }
|
"analysis" { $analysis = $true }
|
||||||
"dev" { $dev = $true }
|
"dev" { $dev = $true }
|
||||||
@ -211,7 +211,7 @@ if ( $vendor -match "clang" )
|
|||||||
$flag_section_functions,
|
$flag_section_functions,
|
||||||
( $flag_path_output + $object )
|
( $flag_path_output + $object )
|
||||||
)
|
)
|
||||||
if ( $optimized ) {
|
if ( $optimize ) {
|
||||||
$compiler_args += $flag_optimize_fast
|
$compiler_args += $flag_optimize_fast
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -348,7 +348,7 @@ if ( $vendor -match "msvc" )
|
|||||||
$compiler_args += ( $flag_path_debug + $path_build + '\' )
|
$compiler_args += ( $flag_path_debug + $path_build + '\' )
|
||||||
$compiler_args += $flag_link_win_rt_static_debug
|
$compiler_args += $flag_link_win_rt_static_debug
|
||||||
|
|
||||||
if ( $optimized ) {
|
if ( $optimize ) {
|
||||||
$compiler_args += $flag_optimized_debug
|
$compiler_args += $flag_optimized_debug
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -524,48 +524,60 @@ if ( $engine )
|
|||||||
# This is done by sifting through the emitter.map file from the linker for the base symbol names
|
# This is done by sifting through the emitter.map file from the linker for the base symbol names
|
||||||
# and mapping them to their found decorated name
|
# and mapping them to their found decorated name
|
||||||
|
|
||||||
$engine_symbols = @(
|
# Initialize the hashtable with the desired order of symbols
|
||||||
'on_module_reload',
|
$engine_symbols = [ordered]@{
|
||||||
'startup',
|
'on_module_reload' = $null
|
||||||
'shutdown',
|
'startup' = $null
|
||||||
'update_and_render',
|
'shutdown' = $null
|
||||||
'update_audio'
|
'update_and_render' = $null
|
||||||
)
|
'update_audio' = $null
|
||||||
|
}
|
||||||
|
|
||||||
|
$path_engine_obj = Join-Path $path_build 'handmade_engine.obj'
|
||||||
$path_engine_map = Join-Path $path_build 'handmade_engine.map'
|
$path_engine_map = Join-Path $path_build 'handmade_engine.map'
|
||||||
|
$maxNameLength = ($engine_symbols.Keys | Measure-Object -Property Length -Maximum).Maximum
|
||||||
|
|
||||||
$maxNameLength = ($engine_symbols | Measure-Object -Property Length -Maximum).Maximum
|
|
||||||
|
|
||||||
$engine_symbol_table = @()
|
|
||||||
$engine_symbol_list = @()
|
|
||||||
Get-Content -Path $path_engine_map | ForEach-Object {
|
Get-Content -Path $path_engine_map | ForEach-Object {
|
||||||
# Split each line by whitespace
|
# If all symbols are found, exit the loop
|
||||||
$tokens = $_ -split '\s+', 3
|
if ($engine_symbols.Values -notcontains $null) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
# Split the line into tokens
|
||||||
|
$tokens = $_ -split '\s+', 4
|
||||||
# Extract only the decorated name using regex for both MSVC and Clang conventions
|
# Extract only the decorated name using regex for both MSVC and Clang conventions
|
||||||
$decoratedName = ($tokens[2] -match '(\?[\w@]+|_Z[\w@]+)' ) ? $matches[1] : $null
|
$decoratedName = ($tokens[2] -match '(\?[\w@]+|_Z[\w@]+)') ? $matches[1] : $null
|
||||||
|
|
||||||
|
# Check the origin of the symbol
|
||||||
|
# If the origin matches 'handmade_engine.obj', then process the symbol
|
||||||
|
$originParts = $tokens[3] -split '\s+'
|
||||||
|
$origin = if ($originParts.Count -eq 3) { $originParts[2] } else { $originParts[1] }
|
||||||
|
|
||||||
|
# Diagnostic output
|
||||||
|
if ( $false -and $decoratedName) {
|
||||||
|
write-host "Found decorated name: $decoratedName" -ForegroundColor Yellow
|
||||||
|
write-host "Origin : $origin" -ForegroundColor Yellow
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($origin -like 'handmade_engine.obj') {
|
||||||
# Check each regular name against the current line
|
# Check each regular name against the current line
|
||||||
foreach ($name in $engine_symbols) {
|
$engine_symbols.Keys | Where-Object { $engine_symbols[$_] -eq $null } | ForEach-Object {
|
||||||
if ($decoratedName -like "*$name*") {
|
if ($decoratedName -like "*$_*") {
|
||||||
$engine_symbol_table += $name + ', ' + $decoratedName
|
$engine_symbols[$_] = $decoratedName
|
||||||
$engine_symbol_list += $decoratedName
|
}
|
||||||
$engine_symbols = $engine_symbols -ne $name # Remove the found symbol from the array
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
write-host "Engine Symbol Table:" -ForegroundColor Green
|
write-host "Engine Symbol Table:" -ForegroundColor Green
|
||||||
$engine_symbol_table | ForEach-Object {
|
$engine_symbols.GetEnumerator() | ForEach-Object {
|
||||||
$split = $_ -split ', ', 2
|
$paddedName = $_.Key.PadRight($maxNameLength)
|
||||||
$paddedName = $split[0].PadRight($maxNameLength)
|
$decoratedName = $_.Value
|
||||||
$decoratedName = $split[1]
|
|
||||||
write-host "`t$paddedName, $decoratedName" -ForegroundColor Green
|
write-host "`t$paddedName, $decoratedName" -ForegroundColor Green
|
||||||
}
|
}
|
||||||
|
|
||||||
# Write the symbol table to a file
|
# Write the symbol table to a file
|
||||||
$path_engine_symbols = Join-Path $path_binaries 'handmade_engine.symbols'
|
$path_engine_symbols = Join-Path $path_binaries 'handmade_engine.symbols'
|
||||||
$engine_symbol_list | Out-File -Path $path_engine_symbols
|
$engine_symbols.Values | Out-File -Path $path_engine_symbols
|
||||||
}
|
}
|
||||||
|
|
||||||
Remove-Item $path_pdb_lock -Force -Verbose
|
Remove-Item $path_pdb_lock -Force -Verbose
|
||||||
@ -592,7 +604,7 @@ if ( $platform )
|
|||||||
$lib_jsl,
|
$lib_jsl,
|
||||||
|
|
||||||
$flag_link_win_subsystem_windows
|
$flag_link_win_subsystem_windows
|
||||||
$flag_link_optimize_references
|
# $flag_link_optimize_references
|
||||||
)
|
)
|
||||||
|
|
||||||
$unit = Join-Path $path_project 'handmade_win32.cpp'
|
$unit = Join-Path $path_project 'handmade_win32.cpp'
|
||||||
|
@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<NatStepFiltering xmlns="http://schemas.microsoft.com/vstudio/debugger/natstepfilter/2010">
|
||||||
|
<Function>
|
||||||
|
<Name>StrFixed<*>::concat</Name>
|
||||||
|
<Action>NoStepInto</Action>
|
||||||
|
</Function>
|
||||||
|
</NatStepFiltering>
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user