diff options
| author | Konstantin <const@const.me> | 2023-01-18 21:10:40 +0100 |
|---|---|---|
| committer | Konstantin <const@const.me> | 2023-01-18 21:10:40 +0100 |
| commit | 670f889b7e3af360fbd66ae34bc74e7e393edbfe (patch) | |
| tree | 268707bf77309527d2e9cac02b8adf93c01d4d30 /Examples/WhisperDesktop | |
| parent | 11c399b70c7ad5664b6060b39632e6b9fa815350 (diff) | |
GUI to force specific version of the compute shaders
Diffstat (limited to 'Examples/WhisperDesktop')
| -rw-r--r-- | Examples/WhisperDesktop/AppState.cpp | 14 | ||||
| -rw-r--r-- | Examples/WhisperDesktop/AppState.h | 3 | ||||
| -rw-r--r-- | Examples/WhisperDesktop/LoadModelDlg.cpp | 14 | ||||
| -rw-r--r-- | Examples/WhisperDesktop/LoadModelDlg.h | 3 | ||||
| -rw-r--r-- | Examples/WhisperDesktop/ModelAdvancedDlg.cpp | 63 | ||||
| -rw-r--r-- | Examples/WhisperDesktop/ModelAdvancedDlg.h | 35 | ||||
| -rw-r--r-- | Examples/WhisperDesktop/Resource.h | 7 | ||||
| -rw-r--r-- | Examples/WhisperDesktop/WhisperDesktop.rc | bin | 18438 -> 20076 bytes | |||
| -rw-r--r-- | Examples/WhisperDesktop/WhisperDesktop.vcxproj | 2 | ||||
| -rw-r--r-- | Examples/WhisperDesktop/WhisperDesktop.vcxproj.filters | 6 |
10 files changed, 143 insertions, 4 deletions
diff --git a/Examples/WhisperDesktop/AppState.cpp b/Examples/WhisperDesktop/AppState.cpp index 6697e6a..651e8ae 100644 --- a/Examples/WhisperDesktop/AppState.cpp +++ b/Examples/WhisperDesktop/AppState.cpp @@ -14,6 +14,7 @@ namespace const LPCTSTR regValImpl = L"modelImpl"; const LPCTSTR regValLang = L"language"; const LPCTSTR regValLastScreen = L"screen"; + const LPCTSTR regValGpuFlags = L"gpuFlags"; static HRESULT readString( CRegKey& k, LPCTSTR name, CString& rdi ) { @@ -189,4 +190,17 @@ void AppState::setupIcon( CWindow* wnd ) wnd->SendMessage( WM_SETICON, ICON_SMALL, (LPARAM)ic ); wnd->SendMessage( WM_SETICON, ICON_BIG, (LPARAM)ic ); } +} + +uint32_t AppState::gpuFlagsLoad() +{ + return dwordLoad( regValGpuFlags, 0 ); +} + +void AppState::gpuFlagsStore( uint32_t flags ) +{ + if( 0 == flags ) + registryKey.DeleteValue( regValGpuFlags ); + else + dwordStore( regValGpuFlags, flags ); }
\ No newline at end of file diff --git a/Examples/WhisperDesktop/AppState.h b/Examples/WhisperDesktop/AppState.h index 0a45a21..9824b42 100644 --- a/Examples/WhisperDesktop/AppState.h +++ b/Examples/WhisperDesktop/AppState.h @@ -44,6 +44,9 @@ public: HRESULT lastScreenLoad(); void setupIcon( CWindow* wnd ); + + uint32_t gpuFlagsLoad(); + void gpuFlagsStore( uint32_t flags ); }; constexpr HRESULT SCREEN_MODEL = 1; diff --git a/Examples/WhisperDesktop/LoadModelDlg.cpp b/Examples/WhisperDesktop/LoadModelDlg.cpp index 3aa84e7..ad41397 100644 --- a/Examples/WhisperDesktop/LoadModelDlg.cpp +++ b/Examples/WhisperDesktop/LoadModelDlg.cpp @@ -2,6 +2,7 @@ #include "LoadModelDlg.h" #include "Utils/miscUtils.h" #include "Utils/logger.h" +#include "ModelAdvancedDlg.h" constexpr int progressMaxInteger = 1024 * 8; @@ -43,8 +44,8 @@ LRESULT LoadModelDlg::OnInitDialog( UINT nMessage, WPARAM wParam, LPARAM lParam, return TRUE; } - editorsWindows.reserve( 5 ); - editorsWindows = { modelPath, cbModelType, GetDlgItem( IDC_BROWSE ), GetDlgItem( IDOK ), GetDlgItem( IDCANCEL ) }; + editorsWindows.reserve( 6 ); + editorsWindows = { modelPath, cbModelType, GetDlgItem( IDC_BROWSE ), GetDlgItem( IDC_MODEL_ADV ), GetDlgItem( IDOK ), GetDlgItem( IDCANCEL ) }; pendingWindows.reserve( 2 ); pendingWindows = { GetDlgItem( IDC_PENDING_TEXT ), progressBar }; @@ -140,7 +141,8 @@ void __stdcall LoadModelDlg::poolCallback() noexcept lmcb.cancel = nullptr; lmcb.progress = &LoadModelDlg::progressCallback; lmcb.pv = this; - HRESULT hr = Whisper::loadModel( path, impl, 0, &lmcb, &model ); + const uint32_t flags = appState.gpuFlagsLoad(); + HRESULT hr = Whisper::loadModel( path, impl, flags, &lmcb, &model ); if( SUCCEEDED( hr ) ) appState.model = model; else @@ -203,4 +205,10 @@ LRESULT LoadModelDlg::OnHyperlink( int idCtrl, LPNMHDR pnmh, BOOL& bHandled ) ShellExecute( NULL, L"open", url, NULL, NULL, SW_SHOW ); bHandled = TRUE; return 0; +} + +void LoadModelDlg::onModelAdvanced() +{ + ModelAdvancedDlg dlg{ appState }; + dlg.show( m_hWnd ); }
\ No newline at end of file diff --git a/Examples/WhisperDesktop/LoadModelDlg.h b/Examples/WhisperDesktop/LoadModelDlg.h index a8d7aea..f11c0df 100644 --- a/Examples/WhisperDesktop/LoadModelDlg.h +++ b/Examples/WhisperDesktop/LoadModelDlg.h @@ -25,6 +25,7 @@ public: COMMAND_ID_HANDLER( IDC_BROWSE, OnBrowse ) MESSAGE_HANDLER( WM_CALLBACK_STATUS, OnCallbackStatus ) NOTIFY_ID_HANDLER( IDC_HYPERLINKS, OnHyperlink ) + ON_BUTTON_CLICK( IDC_MODEL_ADV, onModelAdvanced ) END_MSG_MAP() BEGIN_DDX_MAP( LoadModelDlg ) @@ -66,4 +67,6 @@ private: LRESULT OnHyperlink( int idCtrl, LPNMHDR pnmh, BOOL& bHandled ); static HRESULT __stdcall progressCallback( double val, void* pv ) noexcept; + + void onModelAdvanced(); };
\ No newline at end of file diff --git a/Examples/WhisperDesktop/ModelAdvancedDlg.cpp b/Examples/WhisperDesktop/ModelAdvancedDlg.cpp new file mode 100644 index 0000000..c72a838 --- /dev/null +++ b/Examples/WhisperDesktop/ModelAdvancedDlg.cpp @@ -0,0 +1,63 @@ +#include "stdafx.h" +#include "ModelAdvancedDlg.h" +using Whisper::eGpuModelFlags; + +LRESULT ModelAdvancedDlg::onInitDialog( UINT nMessage, WPARAM wParam, LPARAM lParam, BOOL& bHandled ) +{ + cbWave = GetDlgItem( IDC_WAVE ); + cbReshapedMatMul = GetDlgItem( IDC_RESHAPED_MAT_MUL ); + const uint32_t flags = appState.gpuFlagsLoad(); + + // Setup the "Compute shaders" combobox + cbWave.AddString( L"Wave64 shaders on AMD" ); + cbWave.AddString( L"Always use Wave32" ); + cbWave.AddString( L"Always use Wave64" ); + int i = 0; + if( 0 != ( flags & (uint32_t)eGpuModelFlags::Wave32 ) ) + i = 1; + else if( 0 != ( flags & (uint32_t)eGpuModelFlags::Wave64 ) ) + i = 2; + cbWave.SetCurSel( i ); + + // Setup the "reshaped multiply" combobox + cbReshapedMatMul.AddString( L"Reshape on AMD" ); + cbReshapedMatMul.AddString( L"Don’t reshape tensors" ); + cbReshapedMatMul.AddString( L"Reshape tensors" ); + i = 0; + if( 0 != ( flags & (uint32_t)eGpuModelFlags::NoReshapedMatMul ) ) + i = 1; + else if( 0 != ( flags & (uint32_t)eGpuModelFlags::UseReshapedMatMul ) ) + i = 2; + cbReshapedMatMul.SetCurSel( i ); + + return 0; +} + +bool ModelAdvancedDlg::show( HWND owner ) +{ + auto res = DoModal( owner ); + return res == IDOK; +} + +void ModelAdvancedDlg::onOk() +{ + // Gather values from these comboboxes + uint32_t flags = 0; + + int i = cbWave.GetCurSel(); + if( 1 == i ) + flags |= (uint32_t)eGpuModelFlags::Wave32; + else if( 2 == i ) + flags |= (uint32_t)eGpuModelFlags::Wave64; + + i = cbReshapedMatMul.GetCurSel(); + if( 1 == i ) + flags |= (uint32_t)eGpuModelFlags::NoReshapedMatMul; + else if( 2 == i ) + flags |= (uint32_t)eGpuModelFlags::UseReshapedMatMul; + + // Save to registry + appState.gpuFlagsStore( flags ); + + EndDialog( IDOK ); +}
\ No newline at end of file diff --git a/Examples/WhisperDesktop/ModelAdvancedDlg.h b/Examples/WhisperDesktop/ModelAdvancedDlg.h new file mode 100644 index 0000000..aebbda5 --- /dev/null +++ b/Examples/WhisperDesktop/ModelAdvancedDlg.h @@ -0,0 +1,35 @@ +#pragma once +#include "AppState.h" +#include "Utils/WTL/atlddx.h" +#include "Utils/miscUtils.h" + +class ModelAdvancedDlg : + public CDialogImpl<ModelAdvancedDlg> +{ + CComboBox cbWave, cbReshapedMatMul; + AppState& appState; + +public: + static constexpr UINT IDD = IDD_MODEL_ADV; + + ModelAdvancedDlg( AppState& app ) : appState( app ) { } + + BEGIN_MSG_MAP( ModelAdvancedDlg ) + MESSAGE_HANDLER( WM_INITDIALOG, onInitDialog ) + ON_BUTTON_CLICK( IDOK, onOk ) + ON_BUTTON_CLICK( IDCANCEL, onCancel ) + END_MSG_MAP() + + bool show( HWND owner ); + +private: + + LRESULT onInitDialog( UINT nMessage, WPARAM wParam, LPARAM lParam, BOOL& bHandled ); + + void onOk(); + + void onCancel() + { + EndDialog( IDCANCEL ); + } +};
\ No newline at end of file diff --git a/Examples/WhisperDesktop/Resource.h b/Examples/WhisperDesktop/Resource.h index f4a9af5..a4ccf94 100644 --- a/Examples/WhisperDesktop/Resource.h +++ b/Examples/WhisperDesktop/Resource.h @@ -13,6 +13,7 @@ #define IDD_MAIN_DIALOG 130 #define IDD_TRANSCRIBE_DIALOG 130 #define IDD_CAPTURE_DIALOG 131 +#define IDD_MODEL_ADV 132 #define IDC_PATH 1000 #define IDC_BROWSE 1001 #define IDC_MODEL_TYPE 1002 @@ -46,6 +47,10 @@ #define IDC_STALL_STATUS 1024 #define IDC_STALL_LBL 1025 #define IDC_TRANSLATE 1026 +#define IDC_MODEL_ADV 1027 +#define IDC_WAVE 1028 +#define IDC_WAVE2 1029 +#define IDC_RESHAPED_MAT_MUL 1029 #define IDC_STATIC -1 // Next default values for new objects @@ -55,7 +60,7 @@ #define _APS_NO_MFC 1 #define _APS_NEXT_RESOURCE_VALUE 131 #define _APS_NEXT_COMMAND_VALUE 32771 -#define _APS_NEXT_CONTROL_VALUE 1027 +#define _APS_NEXT_CONTROL_VALUE 1029 #define _APS_NEXT_SYMED_VALUE 110 #endif #endif diff --git a/Examples/WhisperDesktop/WhisperDesktop.rc b/Examples/WhisperDesktop/WhisperDesktop.rc Binary files differindex 8516921..a9bb696 100644 --- a/Examples/WhisperDesktop/WhisperDesktop.rc +++ b/Examples/WhisperDesktop/WhisperDesktop.rc diff --git a/Examples/WhisperDesktop/WhisperDesktop.vcxproj b/Examples/WhisperDesktop/WhisperDesktop.vcxproj index db6d529..7f5bce8 100644 --- a/Examples/WhisperDesktop/WhisperDesktop.vcxproj +++ b/Examples/WhisperDesktop/WhisperDesktop.vcxproj @@ -92,6 +92,7 @@ <ClInclude Include="CircleIndicator.h" /> <ClInclude Include="AppState.h" /> <ClInclude Include="CaptureDlg.h" /> + <ClInclude Include="ModelAdvancedDlg.h" /> <ClInclude Include="Utils\TranslateCheckbox.h" /> <ClInclude Include="Utils\DebugConsole.h" /> <ClInclude Include="framework.h" /> @@ -117,6 +118,7 @@ <ClCompile Include="CircleIndicator.cpp" /> <ClCompile Include="AppState.cpp" /> <ClCompile Include="CaptureDlg.cpp" /> + <ClCompile Include="ModelAdvancedDlg.cpp" /> <ClCompile Include="Utils\TranslateCheckbox.cpp" /> <ClCompile Include="Utils\DebugConsole.cpp" /> <ClCompile Include="Utils\logger.cpp" /> diff --git a/Examples/WhisperDesktop/WhisperDesktop.vcxproj.filters b/Examples/WhisperDesktop/WhisperDesktop.vcxproj.filters index 09bb5f1..7d12f22 100644 --- a/Examples/WhisperDesktop/WhisperDesktop.vcxproj.filters +++ b/Examples/WhisperDesktop/WhisperDesktop.vcxproj.filters @@ -84,6 +84,9 @@ <ClInclude Include="Utils\TranslateCheckbox.h"> <Filter>Header Files</Filter> </ClInclude> + <ClInclude Include="ModelAdvancedDlg.h"> + <Filter>Header Files</Filter> + </ClInclude> </ItemGroup> <ItemGroup> <ClCompile Include="WhisperDesktop.cpp"> @@ -125,6 +128,9 @@ <ClCompile Include="Utils\TranslateCheckbox.cpp"> <Filter>Source Files</Filter> </ClCompile> + <ClCompile Include="ModelAdvancedDlg.cpp"> + <Filter>Source Files</Filter> + </ClCompile> </ItemGroup> <ItemGroup> <ResourceCompile Include="WhisperDesktop.rc"> |
