@@ -56,9 +56,11 @@ public void onInitialize() {
5656 String optionString = System .getProperty ("debugger" );
5757 if (optionString != null ) {
5858 if (optionString .equalsIgnoreCase ("renderdoc" )) {
59- option = JOptionPane .NO_OPTION ;
60- } else if (optionString .equalsIgnoreCase ("nsight" )) {
59+ option = JOptionPane .CANCEL_OPTION ;
60+ } else if (optionString .equalsIgnoreCase ("nsight-gpu " )) {
6161 option = JOptionPane .YES_OPTION ;
62+ } else if (optionString .equalsIgnoreCase ("nsight-frame" )) {
63+ option = JOptionPane .NO_OPTION ;
6264 }
6365 }
6466
@@ -70,16 +72,16 @@ public void onInitialize() {
7072 } catch (ReflectiveOperationException | UnsupportedLookAndFeelException ignored ) {
7173 }
7274
73- String [] options = {"NSight" , "Renderdoc" };
75+ String [] options = {"NSight GPU Trace" , "NSight Frame Profiler " , "Renderdoc" };
7476
75- JFrame frame = new JFrame ("Shader debugging " );
77+ JFrame frame = new JFrame ("Choose a debugger to be loaded " );
7678
7779 frame .setUndecorated ( true );
7880 frame .setVisible ( true );
7981 frame .setLocationRelativeTo ( null );
8082 frame .requestFocus ();
8183
82- option = JOptionPane .showOptionDialog (frame , "Pick the debugger to be loaded " , "Shader debugging" , JOptionPane .YES_NO_OPTION , JOptionPane .QUESTION_MESSAGE , null ,
84+ option = JOptionPane .showOptionDialog (frame , "Closing the dialog will skip injection. \n \n NSight or Renderdoc must be installed for this to work properly. " , "Shader debugging" , JOptionPane .YES_NO_CANCEL_OPTION , JOptionPane .QUESTION_MESSAGE , null ,
8385 options , null );
8486
8587 frame .dispose ();
@@ -88,29 +90,31 @@ public void onInitialize() {
8890 }
8991
9092 if (option == JOptionPane .CLOSED_OPTION ) {
91- LOGGER .info ("Skipping injection..." );
93+ LOGGER .info ("Modal closed, skipping injection..." );
9294 return ;
9395 }
9496
95- if (option != JOptionPane .OK_OPTION ) {
96- LOGGER .info ("Loading Renderdoc injector ..." );
97+ if (option == JOptionPane .CANCEL_OPTION ) {
98+ LOGGER .info ("Injecting Renderdoc..." );
9799 String RENDERDOC_DLL = unpackResource ("renderdoc.dll" );
98100 try {
99101 System .load (RENDERDOC_DLL );
100- LOGGER .info ("Renderdoc loaded successfully" );
102+ LOGGER .info ("Renderdoc loaded successfully. " );
101103 } catch (UnsatisfiedLinkError e ) {
102104 LOGGER .error ("Failed to load Renderdoc: " , e );
103105 }
104106 return ;
105107 }
106108
107- LOGGER .info ("Loading NSight..." );
109+ LOGGER .info ("Injecting NSight..." );
108110
109111 String NGFX_DLL = unpackResource ("NGFX_Injection.dll" );
110112
113+ int activityType = option == JOptionPane .YES_OPTION ? Activity .ActivityType .NGFX_INJECTION_ACTIVITY_GPU_TRACE : Activity .ActivityType .NGFX_INJECTION_ACTIVITY_FRAME_DEBUGGER ;
114+
111115 try {
112116 NGFX ngfx = new NGFX (NGFX_DLL );
113- LOGGER .info ("NGFX loaded successfully " );
117+ LOGGER .info ("NGFX Injection API loaded. Searching for NSight... " );
114118
115119 List <Installation > installations = ngfx .EnumerateInstallations ();
116120 // Find newest installation
@@ -127,18 +131,17 @@ public void onInitialize() {
127131 LOGGER .error ("No installations found" );
128132 return ;
129133 }
130- LOGGER .info ("Found installation on " + newestInstallation .installationPath + ": drive" );
134+ LOGGER .info ("Found NSight on " + newestInstallation .installationPath + ": drive" );
131135
132136 List <Activity > activities = ngfx .EnumerateActivities (newestInstallation );
133- Activity activity = activities .stream ().filter (a -> a .type == Activity . ActivityType . NGFX_INJECTION_ACTIVITY_FRAME_DEBUGGER ).findFirst ().orElse (null );
137+ Activity activity = activities .stream ().filter (a -> a .type == activityType ).findFirst ().orElse (null );
134138
135139 if (activity == null ) {
136- LOGGER .error ("Frame debugger is not available for this installation" );
140+ LOGGER .error ("The requested activity is not available for this installation. Skipping injection... " );
137141 return ;
138142 }
139- LOGGER .info ("Found activity " + activity .getType () + ": " + activity .description );
140143 Result result = ngfx .Inject (newestInstallation , activity );
141- LOGGER .info ("Injection result: " + result );
144+ LOGGER .info ("NGFX Injection result: " + result );
142145 } catch (Exception e ) {
143146 LOGGER .error ("Failed to load NGFX" , e );
144147 }
0 commit comments