Add a GN build option for the startup dialog

Settting the 'swiftshader_startup_dialog' GN argument to true causes
SwiftShader to show a startup dialog, for Debug builds on Windows. This
makes it easy to attach a debugger at launch.

Bug: debugging utility
Change-Id: I9a116402ac15f951207e0464a9dcfcd3beeb4281
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/60088
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Kokoro-Result: kokoro <noreply+kokoro@google.com>
Commit-Queue: Nicolas Capens <nicolascapens@google.com>
diff --git a/BUILD.gn b/BUILD.gn
index f6d86c9..7d84b99 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -23,7 +23,11 @@
     cflags += [ "-Wno-shadow" ]
   }
 
-  if (!is_debug) {
+  if (is_debug) {
+    if (swiftshader_startup_dialog) {
+      defines += [ "DEBUGGER_WAIT_DIALOG" ]
+    }
+  } else {
     defines += [ "ANGLE_DISABLE_TRACE" ]
   }
 
diff --git a/src/swiftshader.gni b/src/swiftshader.gni
index 0225f7d..68909f2 100644
--- a/src/swiftshader.gni
+++ b/src/swiftshader.gni
@@ -21,6 +21,10 @@
   # By default, build SwiftShader with optimizations enabled in debug
   # for performance reasons. Set to false to build as unoptimized.
   swiftshader_optimized_debug_build = true
+
+  # If enabled, debug builds on Windows will pop up a dialog when the
+  # SwiftShader DLL gets loaded, to facilitate attaching a debugger.
+  swiftshader_startup_dialog = false
 }
 
 configs_to_add = []