secondvoice/force_nvidia_gpu.ps1
StillHammer 7dec7a6eed fix: Résolution complète du problème OpenGL/ImGui avec threading
PROBLÈME RÉSOLU: Les shaders ImGui compilent maintenant avec succès!

Changements majeurs:
- Remplacé vcpkg ImGui par FetchContent (compilation from source)
- Créé wrapper GLAD pour ImGui (imgui_opengl3_glad.cpp)
- Ajout de makeContextCurrent() pour gérer le contexte OpenGL multi-thread
- Release du contexte dans initialize(), puis rendu current dans uiThread()

Root Cause Analysis:
1. Rendering s'exécute dans uiThread() (thread séparé)
2. Contexte OpenGL créé dans thread principal n'était pas accessible
3. glCreateShader retournait 0 avec GL_INVALID_OPERATION (erreur 1282)
4. Solution: Transfer du contexte OpenGL du thread principal vers uiThread

Debugging profond:
- Ajout de logs debug dans ImGui pour tracer glCreateShader
- Découvert que handle=0 indiquait échec de création (pas compilation)
- Identifié erreur WGL \"ressource en cours d'utilisation\" = contexte locked

Fichiers modifiés:
- vcpkg.json: Supprimé imgui
- CMakeLists.txt: FetchContent pour ImGui + imgui_backends library
- src/imgui_opengl3_glad.cpp: Nouveau wrapper GLAD
- src/ui/TranslationUI.{h,cpp}: Ajout makeContextCurrent()
- src/core/Pipeline.cpp: Appel makeContextCurrent() dans uiThread()
- build/.../imgui_impl_opengl3.cpp: Debug logs (temporaire)

Résultat: UI fonctionne! NVIDIA RTX 4060 GPU, OpenGL 3.3.0, shaders compilent

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-21 16:37:47 +08:00

76 lines
3.3 KiB
PowerShell

# Force SecondVoice to use NVIDIA GPU
# Run as Administrator
Write-Host "========================================" -ForegroundColor Cyan
Write-Host "Force NVIDIA GPU for SecondVoice" -ForegroundColor Cyan
Write-Host "========================================" -ForegroundColor Cyan
Write-Host ""
# Check if running as admin
$isAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
if (-not $isAdmin) {
Write-Host "WARNING: Not running as Administrator" -ForegroundColor Yellow
Write-Host "Some settings may not apply properly" -ForegroundColor Yellow
Write-Host ""
}
# Get the executable path
$exePath = Join-Path $PSScriptRoot "build\mingw-Release\SecondVoice.exe"
$exeFullPath = (Resolve-Path $exePath -ErrorAction SilentlyContinue).Path
if (-not $exeFullPath) {
Write-Host "ERROR: SecondVoice.exe not found at:" -ForegroundColor Red
Write-Host " $exePath" -ForegroundColor Red
Write-Host ""
Write-Host "Please build the project first:" -ForegroundColor Yellow
Write-Host " .\build_mingw.bat" -ForegroundColor Yellow
exit 1
}
Write-Host "Found executable:" -ForegroundColor Green
Write-Host " $exeFullPath" -ForegroundColor White
Write-Host ""
# Method 1: Registry settings for NVIDIA Optimus
Write-Host "Setting NVIDIA Optimus preference..." -ForegroundColor Cyan
$regPath = "HKCU:\Software\Microsoft\DirectX\UserGpuPreferences"
if (-not (Test-Path $regPath)) {
New-Item -Path $regPath -Force | Out-Null
}
# Set to use high performance GPU (NVIDIA)
Set-ItemProperty -Path $regPath -Name $exeFullPath -Value "GpuPreference=2;" -Type String
Write-Host "✓ Registry setting applied" -ForegroundColor Green
Write-Host ""
# Instructions for manual configuration
Write-Host "========================================" -ForegroundColor Cyan
Write-Host "Manual Configuration (if needed)" -ForegroundColor Cyan
Write-Host "========================================" -ForegroundColor Cyan
Write-Host ""
Write-Host "If the automatic setting does not work, configure manually:" -ForegroundColor Yellow
Write-Host ""
Write-Host "Method 1 - Windows Graphics Settings:" -ForegroundColor White
Write-Host " 1. Open Windows Settings (Win + I)" -ForegroundColor Gray
Write-Host " 2. System > Display > Graphics" -ForegroundColor Gray
Write-Host " 3. Click Browse and select:" -ForegroundColor Gray
Write-Host " $exeFullPath" -ForegroundColor Cyan
Write-Host " 4. Click Options > High performance" -ForegroundColor Gray
Write-Host " 5. Save" -ForegroundColor Gray
Write-Host ""
Write-Host "Method 2 - NVIDIA Control Panel:" -ForegroundColor White
Write-Host " 1. Right-click desktop > NVIDIA Control Panel" -ForegroundColor Gray
Write-Host " 2. Manage 3D Settings > Program Settings" -ForegroundColor Gray
Write-Host " 3. Add SecondVoice.exe" -ForegroundColor Gray
Write-Host " 4. Select High-performance NVIDIA processor" -ForegroundColor Gray
Write-Host ""
Write-Host "========================================" -ForegroundColor Cyan
Write-Host "✓ Configuration complete!" -ForegroundColor Green
Write-Host "========================================" -ForegroundColor Cyan
Write-Host ""
Write-Host "Please restart SecondVoice for changes to take effect" -ForegroundColor Yellow