@@ -56,9 +56,11 @@ public void onInitialize() {
56
56
String optionString = System .getProperty ("debugger" );
57
57
if (optionString != null ) {
58
58
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 " )) {
61
61
option = JOptionPane .YES_OPTION ;
62
+ } else if (optionString .equalsIgnoreCase ("nsight-frame" )) {
63
+ option = JOptionPane .NO_OPTION ;
62
64
}
63
65
}
64
66
@@ -70,16 +72,16 @@ public void onInitialize() {
70
72
} catch (ReflectiveOperationException | UnsupportedLookAndFeelException ignored ) {
71
73
}
72
74
73
- String [] options = {"NSight" , "Renderdoc" };
75
+ String [] options = {"NSight GPU Trace" , "NSight Frame Profiler " , "Renderdoc" };
74
76
75
- JFrame frame = new JFrame ("Shader debugging " );
77
+ JFrame frame = new JFrame ("Choose a debugger to be loaded " );
76
78
77
79
frame .setUndecorated ( true );
78
80
frame .setVisible ( true );
79
81
frame .setLocationRelativeTo ( null );
80
82
frame .requestFocus ();
81
83
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 ,
83
85
options , null );
84
86
85
87
frame .dispose ();
@@ -88,29 +90,31 @@ public void onInitialize() {
88
90
}
89
91
90
92
if (option == JOptionPane .CLOSED_OPTION ) {
91
- LOGGER .info ("Skipping injection..." );
93
+ LOGGER .info ("Modal closed, skipping injection..." );
92
94
return ;
93
95
}
94
96
95
- if (option != JOptionPane .OK_OPTION ) {
96
- LOGGER .info ("Loading Renderdoc injector ..." );
97
+ if (option == JOptionPane .CANCEL_OPTION ) {
98
+ LOGGER .info ("Injecting Renderdoc..." );
97
99
String RENDERDOC_DLL = unpackResource ("renderdoc.dll" );
98
100
try {
99
101
System .load (RENDERDOC_DLL );
100
- LOGGER .info ("Renderdoc loaded successfully" );
102
+ LOGGER .info ("Renderdoc loaded successfully. " );
101
103
} catch (UnsatisfiedLinkError e ) {
102
104
LOGGER .error ("Failed to load Renderdoc: " , e );
103
105
}
104
106
return ;
105
107
}
106
108
107
- LOGGER .info ("Loading NSight..." );
109
+ LOGGER .info ("Injecting NSight..." );
108
110
109
111
String NGFX_DLL = unpackResource ("NGFX_Injection.dll" );
110
112
113
+ int activityType = option == JOptionPane .YES_OPTION ? Activity .ActivityType .NGFX_INJECTION_ACTIVITY_GPU_TRACE : Activity .ActivityType .NGFX_INJECTION_ACTIVITY_FRAME_DEBUGGER ;
114
+
111
115
try {
112
116
NGFX ngfx = new NGFX (NGFX_DLL );
113
- LOGGER .info ("NGFX loaded successfully " );
117
+ LOGGER .info ("NGFX Injection API loaded. Searching for NSight... " );
114
118
115
119
List <Installation > installations = ngfx .EnumerateInstallations ();
116
120
// Find newest installation
@@ -127,18 +131,17 @@ public void onInitialize() {
127
131
LOGGER .error ("No installations found" );
128
132
return ;
129
133
}
130
- LOGGER .info ("Found installation on " + newestInstallation .installationPath + ": drive" );
134
+ LOGGER .info ("Found NSight on " + newestInstallation .installationPath + ": drive" );
131
135
132
136
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 );
134
138
135
139
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... " );
137
141
return ;
138
142
}
139
- LOGGER .info ("Found activity " + activity .getType () + ": " + activity .description );
140
143
Result result = ngfx .Inject (newestInstallation , activity );
141
- LOGGER .info ("Injection result: " + result );
144
+ LOGGER .info ("NGFX Injection result: " + result );
142
145
} catch (Exception e ) {
143
146
LOGGER .error ("Failed to load NGFX" , e );
144
147
}
0 commit comments