PlusLib  2.9.0
Software library for tracked ultrasound image acquisition, calibration, and processing.
nvSDIutil.cpp
Go to the documentation of this file.
1 /***************************************************************************\
2 |* *|
3 |* Copyright 2007 NVIDIA Corporation. All rights reserved. *|
4 |* *|
5 |* NOTICE TO USER: *|
6 |* *|
7 |* This source code is subject to NVIDIA ownership rights under U.S. *|
8 |* and international Copyright laws. Users and possessors of this *|
9 |* source code are hereby granted a nonexclusive, royalty-free *|
10 |* license to use this code in individual and commercial software. *|
11 |* *|
12 |* NVIDIA MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS SOURCE *|
13 |* CODE FOR ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR *|
14 |* IMPLIED WARRANTY OF ANY KIND. NVIDIA DISCLAIMS ALL WARRANTIES WITH *|
15 |* REGARD TO THIS SOURCE CODE, INCLUDING ALL IMPLIED WARRANTIES OF *|
16 |* MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR *|
17 |* PURPOSE. IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, *|
18 |* INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES *|
19 |* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN *|
20 |* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING *|
21 |* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOURCE *|
22 |* CODE. *|
23 |* *|
24 |* U.S. Government End Users. This source code is a "commercial item" *|
25 |* as that term is defined at 48 C.F.R. 2.101 (OCT 1995), consisting *|
26 |* of "commercial computer software" and "commercial computer software *|
27 |* documentation" as such terms are used in 48 C.F.R. 12.212 (SEPT 1995) *|
28 |* and is provided to the U.S. Government only as a commercial end item. *|
29 |* Consistent with 48 C.F.R.12.212 and 48 C.F.R. 227.7202-1 through *|
30 |* 227.7202-4 (JUNE 1995), all U.S. Government End Users acquire the *|
31 |* source code with only those rights set forth herein. *|
32 |* *|
33 |* Any use of this source code in individual and commercial software must *|
34 |* include, in the user documentation and internal comments to the code, *|
35 |* the above Disclaimer and U.S. Government End Users Notice. *|
36 |* *|
37 |* *|
38 \***************************************************************************/
39 
40 #include "nvSDIutil.h"
41 
42 std::string SignalFormatToString( NVVIOSIGNALFORMAT format )
43 {
44  std::string str;
45 
46  switch( format )
47  {
48  case NVVIOSIGNALFORMAT_NONE:
49  str = "None";
50  break;
51 
52  case NVVIOSIGNALFORMAT_487I_59_94_SMPTE259_NTSC:
53  str = "487i 59.95 (SMPTE 259)";
54  break;
55 
56  case NVVIOSIGNALFORMAT_576I_50_00_SMPTE259_PAL:
57  str = "576i 50.00 (SMPTE 259)";
58  break;
59 
60  case NVVIOSIGNALFORMAT_720P_59_94_SMPTE296:
61  str = "720p 59.94 (SMPTE 296)";
62  break;
63 
64  case NVVIOSIGNALFORMAT_720P_60_00_SMPTE296:
65  str = "720p 60.00 (SMPTE 296)";
66  break;
67 
68  case NVVIOSIGNALFORMAT_1035I_59_94_SMPTE260:
69  str = "1035i 59.94 (SMPTE 260)";
70  break;
71 
72  case NVVIOSIGNALFORMAT_1035I_60_00_SMPTE260:
73  str = "1035i 60.00 (SMPTE 260)";
74  break;
75 
76  case NVVIOSIGNALFORMAT_1080I_50_00_SMPTE295:
77  str = "1080i 50.00 (SMPTE 295)";
78  break;
79 
80  case NVVIOSIGNALFORMAT_1080I_50_00_SMPTE274:
81  str = "1080i 50.00 (SMPTE 274)";
82  break;
83 
84  case NVVIOSIGNALFORMAT_1080I_59_94_SMPTE274:
85  str = "1080i 59.94 (SMPTE 274)";
86  break;
87 
88  case NVVIOSIGNALFORMAT_1080I_60_00_SMPTE274:
89  str = "1080i 60.00 (SMPTE 274)";
90  break;
91 
92  case NVVIOSIGNALFORMAT_1080P_23_976_SMPTE274:
93  str = "1080p 23.976 (SMPTE 274)";
94  break;
95 
96  case NVVIOSIGNALFORMAT_1080P_24_00_SMPTE274:
97  str = "1080p 24.00 (SMPTE 274)";
98  break;
99 
100  case NVVIOSIGNALFORMAT_1080P_25_00_SMPTE274:
101  str = "1080p 25.00 (SMPTE 274)";
102  break;
103 
104  case NVVIOSIGNALFORMAT_1080P_29_97_SMPTE274:
105  str = "1080p 29.97 (SMPTE 274)";
106  break;
107 
108  case NVVIOSIGNALFORMAT_1080P_30_00_SMPTE274:
109  str = "1080p 30.00 (SMPTE 274)";
110  break;
111 
112  case NVVIOSIGNALFORMAT_720P_50_00_SMPTE296:
113  str = "720p 50.00 (SMPTE 296)";
114  break;
115 
116  case NVVIOSIGNALFORMAT_1080I_48_00_SMPTE274:
117  str = "1080i 48.00 (SMPTE 274)";
118  break;
119 
120  case NVVIOSIGNALFORMAT_1080I_47_96_SMPTE274:
121  str = "1080i 47.96 (SMPTE 274)";
122  break;
123 
124  case NVVIOSIGNALFORMAT_720P_30_00_SMPTE296:
125  str = "720p 30.00 (SMPTE 296)";
126  break;
127 
128  case NVVIOSIGNALFORMAT_720P_29_97_SMPTE296:
129  str = "720p 29.97 (SMPTE 296)";
130  break;
131 
132  case NVVIOSIGNALFORMAT_720P_25_00_SMPTE296:
133  str = "720p 25.00 (SMPTE 296)";
134  break;
135 
136  case NVVIOSIGNALFORMAT_720P_24_00_SMPTE296:
137  str = "720p 24.00 (SMPTE 296)";
138  break;
139 
140  case NVVIOSIGNALFORMAT_720P_23_98_SMPTE296:
141  str = "720p 23.98 (SMPTE 296)";
142  break;
143 
144  case NVVIOSIGNALFORMAT_1080PSF_25_00_SMPTE274:
145  str = "1080PsF 25.00 (SMPTE 274)";
146  break;
147 
148  case NVVIOSIGNALFORMAT_1080PSF_29_97_SMPTE274:
149  str = "1080PsF 29.97 (SMPTE 274)";
150  break;
151 
152  case NVVIOSIGNALFORMAT_1080PSF_30_00_SMPTE274:
153  str = "1080PsF 30.00 (SMPTE 274)";
154  break;
155 
156  case NVVIOSIGNALFORMAT_1080PSF_24_00_SMPTE274:
157  str = "1080PsF 24.00 (SMPTE 274)";
158  break;
159 
160  case NVVIOSIGNALFORMAT_1080PSF_23_98_SMPTE274:
161  str = "1080PsF 23.98 (SMPTE 274)";
162  break;
163 
164  case NVVIOSIGNALFORMAT_2048P_30_00_SMPTE372:
165  str = "2048p 30.00 (SMPTE 372)";
166  break;
167 
168  case NVVIOSIGNALFORMAT_2048P_29_97_SMPTE372:
169  str = "2048p 29.97 (SMPTE 372)";
170  break;
171 
172  case NVVIOSIGNALFORMAT_2048I_60_00_SMPTE372:
173  str = "2048i 60.00 (SMPTE 372)";
174  break;
175 
176  case NVVIOSIGNALFORMAT_2048I_59_94_SMPTE372:
177  str = "2048i 59.94 (SMPTE 372)";
178  break;
179 
180  case NVVIOSIGNALFORMAT_2048P_25_00_SMPTE372:
181  str = "2048p 25.00 (SMPTE 372)";
182  break;
183 
184  case NVVIOSIGNALFORMAT_2048I_50_00_SMPTE372:
185  str = "2048i 50.00 (SMPTE 372)";
186  break;
187 
188  case NVVIOSIGNALFORMAT_2048P_24_00_SMPTE372:
189  str = "2048p 24.00 (SMPTE 372)";
190  break;
191 
192  case NVVIOSIGNALFORMAT_2048P_23_98_SMPTE372:
193  str = "2048p 23.98 (SMPTE 372)";
194  break;
195 
196  case NVVIOSIGNALFORMAT_2048I_48_00_SMPTE372:
197  str = "2048i 48.00 (SMPTE 372)";
198  break;
199 
200  case NVVIOSIGNALFORMAT_2048I_47_96_SMPTE372:
201  str = "2048i 47.97 (SMPTE 372)";
202  break;
203 
204  case NVVIOSIGNALFORMAT_1080P_50_00_SMPTE274_3G_LEVEL_A:
205  str = "1080p 50.00Hz (SMPTE274) 3G Level A";
206  break;
207 
208  case NVVIOSIGNALFORMAT_1080P_59_94_SMPTE274_3G_LEVEL_A:
209  str = "1080p 59.94Hz (SMPTE274) 3G Level A";
210  break;
211 
212  case NVVIOSIGNALFORMAT_1080P_60_00_SMPTE274_3G_LEVEL_A:
213  str = "1080p 60.00Hz (SMPTE274) 3G Level A";
214  break;
215 
216  case NVVIOSIGNALFORMAT_1080P_60_00_SMPTE274_3G_LEVEL_B:
217  str = "1080p 60.00Hz (SMPTE274) 3G Level B";
218  break;
219 
220  case NVVIOSIGNALFORMAT_1080I_60_00_SMPTE274_3G_LEVEL_B:
221  str = "1080i 60.00Hz (SMPTE274) 3G Level B";
222  break;
223 
224  case NVVIOSIGNALFORMAT_2048I_60_00_SMPTE372_3G_LEVEL_B:
225  str = "2048i 60.00Hz (SMPTE372) 3G Level B";
226  break;
227 
228  case NVVIOSIGNALFORMAT_1080P_50_00_SMPTE274_3G_LEVEL_B:
229  str = "1080p 50.00Hz (SMPTE274) 3G Level B";
230  break;
231 
232  case NVVIOSIGNALFORMAT_1080I_50_00_SMPTE274_3G_LEVEL_B:
233  str = "1080i 50.00Hz (SMPTE274) 3G Level B";
234  break;
235 
236  case NVVIOSIGNALFORMAT_2048I_50_00_SMPTE372_3G_LEVEL_B:
237  str = "2048i 50.00Hz (SMPTE372) 3G Level B";
238  break;
239 
240  case NVVIOSIGNALFORMAT_1080P_30_00_SMPTE274_3G_LEVEL_B:
241  str = "1080p 30.00Hz (SMPTE274) 3G Level B";
242  break;
243 
244  case NVVIOSIGNALFORMAT_2048P_30_00_SMPTE372_3G_LEVEL_B:
245  str = "2048p 30.00Hz (SMPTE372) 3G Level B";
246  break;
247 
248  case NVVIOSIGNALFORMAT_1080P_25_00_SMPTE274_3G_LEVEL_B:
249  str = "1080p 25.00Hz (SMPTE274) 3G Level B";
250  break;
251 
252  case NVVIOSIGNALFORMAT_2048P_25_00_SMPTE372_3G_LEVEL_B:
253  str = "2048p 25.00Hz (SMPTE372) 3G Level B";
254  break;
255 
256  case NVVIOSIGNALFORMAT_1080P_24_00_SMPTE274_3G_LEVEL_B:
257  str = "1080p 24.00Hz (SMPTE274) 3G Level B";
258  break;
259 
260  case NVVIOSIGNALFORMAT_2048P_24_00_SMPTE372_3G_LEVEL_B:
261  str = "2048p 24.00Hz (SMPTE372) 3G Level B";
262  break;
263 
264  case NVVIOSIGNALFORMAT_1080I_48_00_SMPTE274_3G_LEVEL_B:
265  str = "1080i 48.00Hz (SMPTE274) 3G Level B";
266  break;
267 
268  case NVVIOSIGNALFORMAT_2048I_48_00_SMPTE372_3G_LEVEL_B:
269  str = "2048i 48.00Hz (SMPTE372) 3G Level B";
270  break;
271 
272  case NVVIOSIGNALFORMAT_1080P_59_94_SMPTE274_3G_LEVEL_B:
273  str = "1080p 59.94Hz (SMPTE274) 3G Level B";
274  break;
275 
276  case NVVIOSIGNALFORMAT_1080I_59_94_SMPTE274_3G_LEVEL_B:
277  str = "1080i 59.94Hz (SMPTE274) 3G Level B";
278  break;
279 
280  case NVVIOSIGNALFORMAT_2048I_59_94_SMPTE372_3G_LEVEL_B:
281  str = "2048i 59.94Hz (SMPTE372) 3G Level B";
282  break;
283 
284  case NVVIOSIGNALFORMAT_1080P_29_97_SMPTE274_3G_LEVEL_B:
285  str = "1080p 29.97Hz (SMPTE274) 3G Level B";
286  break;
287 
288  case NVVIOSIGNALFORMAT_2048P_29_97_SMPTE372_3G_LEVEL_B:
289  str = "2048p 29.97Hz (SMPTE372) 3G Level B";
290  break;
291 
292  case NVVIOSIGNALFORMAT_1080P_23_98_SMPTE274_3G_LEVEL_B:
293  str = "1080p 29.98Hz (SMPTE274) 3G Level B";
294  break;
295 
296  case NVVIOSIGNALFORMAT_2048P_23_98_SMPTE372_3G_LEVEL_B:
297  str = "2048p 29.98Hz (SMPTE372) 3G Level B";
298  break;
299 
300  case NVVIOSIGNALFORMAT_1080I_47_96_SMPTE274_3G_LEVEL_B:
301  str = "1080i 47.96Hz (SMPTE274) 3G Level B";
302  break;
303 
304  case NVVIOSIGNALFORMAT_2048I_47_96_SMPTE372_3G_LEVEL_B:
305  str = "2048i 47.96Hz (SMPTE372) 3G Level B";
306  break;
307 
308  default:
309  str = "Undefined";
310  break;
311  }
312 
313  return str;
314 }
315 
316 std::string DataFormatToString( NVVIODATAFORMAT format )
317 {
318  std::string str;
319 
320  switch ( format )
321  {
322  case NVVIODATAFORMAT_UNKNOWN:
323  str = "Unknown";
324  break;
325 
326  case NVVIODATAFORMAT_R8G8B8_TO_YCRCB444:
327  str = "R8G8B8 to YCrCb 4:4:4";
328  break;
329 
330  case NVVIODATAFORMAT_R8G8B8A8_TO_YCRCBA4444:
331  str = "R8G8B8 to YCrCbA 4:4:4:4";
332  break;
333 
334  case NVVIODATAFORMAT_R8G8B8Z10_TO_YCRCBZ4444:
335  str = "R8G8B8Z10 to YCrCbZ 4:4:4:4";
336  break;
337 
338  case NVVIODATAFORMAT_R8G8B8_TO_YCRCB422:
339  str = "R8G8B8 to YCrCb 4:2:2";
340  break;
341 
342  case NVVIODATAFORMAT_R8G8B8A8_TO_YCRCBA4224:
343  str = "R8G8B8A8 to YCrCbA 4:2:2:4";
344  break;
345 
346  case NVVIODATAFORMAT_R8G8B8Z10_TO_YCRCBZ4224:
347  str = "R8G8B8Z10 to YCrCbZ 4:2:2:4";
348  break;
349 
350  case NVVIODATAFORMAT_X8X8X8_444_PASSTHRU:
351  str = "X8X8X8 to XXX 4:4:4 Pass Thru";
352  break;
353 
354  case NVVIODATAFORMAT_X8X8X8A8_4444_PASSTHRU:
355  str = "X8X8X8X8 to XXXX 4:4:4:4 Pass Thru";
356  break;
357 
358  case NVVIODATAFORMAT_X8X8X8Z10_4444_PASSTHRU:
359  str = "X8X8X8Z10 to XXXZ 4:4:4:4 Pass Thru";
360  break;
361 
362  case NVVIODATAFORMAT_X10X10X10_444_PASSTHRU:
363  str = "X10X10X10 to XXX 4:4:4 Pass Thru";
364  break;
365 
366  case NVVIODATAFORMAT_X10X8X8_444_PASSTHRU:
367  str = "X10X8X8 to XXX 4:4:4 Pass Thru";
368  break;
369 
370  case NVVIODATAFORMAT_X10X8X8A10_4444_PASSTHRU:
371  str = "X10X8X8A10 to XXXA 4:4:4:4 Pass Thru";
372  break;
373 
374  case NVVIODATAFORMAT_X10X8X8Z10_4444_PASSTHRU:
375  str = "X10X8X8Z10 to XXXZ 4:4:4:4 Pass Thru";
376  break;
377 
378  case NVVIODATAFORMAT_DUAL_R8G8B8_TO_DUAL_YCRCB422:
379  str = "Dual R8G8B8 to Dual YCrCb 4:2:2";
380  break;
381 
382  case NVVIODATAFORMAT_DUAL_X8X8X8_TO_DUAL_422_PASSTHRU:
383  str = "Dual X8X8X8 to Dual XXX 4:2:2 Pass Thru";
384  break;
385 
386  case NVVIODATAFORMAT_R10G10B10_TO_YCRCB422:
387  str = "R10G10B10 to YCrCb 4:2:2";
388  break;
389 
390  case NVVIODATAFORMAT_X12X12X12_444_PASSTHRU:
391  str = "X12X12X12 to XXX 4:4:4 Pass Thru";
392  break;
393 
394  case NVVIODATAFORMAT_Y10CR10CB10_TO_YCRCB422:
395  str = "Y10Cr10Cb10 to YCrCb 4:2:2";
396  break;
397 
398  case NVVIODATAFORMAT_Y8CR8CB8_TO_YCRCB422:
399  str = "Y8Cr8Cb8 to YCrCb 4:2:2";
400  break;
401 
402  case NVVIODATAFORMAT_Y10CR8CB8A10_TO_YCRCBA4224:
403  str = "Y10Cr8Cb8A10 to YCrCb 4:2:2:4";
404  break;
405 
406  case NVVIODATAFORMAT_R10G10B10_TO_RGB444:
407  str = "R10G10B10 to RGB 4:4:4";
408  break;
409 
410  case NVVIODATAFORMAT_R12G12B12_TO_YCRCB444:
411  str = "R12G12B12 to YCrCb 4:4:4";
412  break;
413 
414  case NVVIODATAFORMAT_R12G12B12_TO_YCRCB422:
415  str = "R12G12B12 to YCrCb 4:2:2";
416  break;
417 
418  case NVVIODATAFORMAT_X12X12X12_422_PASSTHRU:
419  str = "X12X12X12 to XXX 4:4:4 Pass Thru";
420  break;
421 
422  default:
423  str = "Unknown";
424  break;
425  }
426 
427  return str;
428 }
429 
430 std::string SyncStatusToString( NVVIOSYNCSTATUS status )
431 {
432  switch ( status )
433  {
434  case NVVIOSYNCSTATUS_OFF:
435  return( "NVVIOSYNCSTATUS_OFF" );
436  break;
437  case NVVIOSYNCSTATUS_ERROR:
438  return( "NVVIOSYNCSTATUS_ERROR" );
439  break;
440  case NVVIOSYNCSTATUS_SYNCLOSS:
441  return( "NVVIOSYNCSTATUS_SYNCLOSS" );
442  break;
443  case NVVIOSYNCSTATUS_COMPOSITE:
444  return( "NVVIOSYNCSTATUS_COMPOSITE" );
445  break;
446  case NVVIOSYNCSTATUS_SDI_SD:
447  return( "NVVIOSYNCSTATUS_SDI_SD" );
448  break;
449  case NVVIOSYNCSTATUS_SDI_HD:
450  return( "NVVIOSYNCSTATUS_SDI_HD" );
451  break;
452  default:
453  return( "NVVIOSYNCSTATUS_ERROR" );
454  }
455 }
456 
457 std::string SyncSourceToString( NVVIOSYNCSOURCE source )
458 {
459  switch ( source )
460  {
461  case NVVIOSYNCSOURCE_SDISYNC:
462  return( "NVVIOSYNCSOURCE_SDISYNC" );
463  break;
464 
465  case NVVIOSYNCSOURCE_COMPSYNC:
466  return( "NVVIOSYNCSOURCE_COMPSYNC" );
467  break;
468  default:
469  return( "NVVIOSYNCSOURCE_NONE" );
470  }
471 }
472 
473 std::string ComponentSamplingFormatToString( NVVIOCOMPONENTSAMPLING sampling )
474 {
475  switch( sampling )
476  {
477  case NVVIOCOMPONENTSAMPLING_4444:
478  return( "NVVIOCOMPONENTSAMPLING_4444" );
479  break;
480  case NVVIOCOMPONENTSAMPLING_4224:
481  return( "NVVIOCOMPONENTSAMPLING_4224" );
482  break;
483  case NVVIOCOMPONENTSAMPLING_444:
484  return( "NVVIOCOMPONENTSAMPLING_444" );
485  break;
486  case NVVIOCOMPONENTSAMPLING_422:
487  return( "NVVIOCOMPONENTSAMPLING_422" );
488  break;
489  default:
490  return( "Unknown" );
491  break;
492  }
493 }
494 
495 std::string ColorSpaceToString( NVVIOCOLORSPACE space )
496 {
497  switch( space )
498  {
499  case NVVIOCOLORSPACE_YCBCR:
500  return( "NVVIOCOLORSPACE_YCBCR" );
501  break;
502  case NVVIOCOLORSPACE_YCBCRA:
503  return( "NVVIOCOLORSPACE_YCBCRA" );
504  break;
505  case NVVIOCOLORSPACE_YCBCRD:
506  return( "NVVIOCOLORSPACE_YCBCRD" );
507  break;
508  case NVVIOCOLORSPACE_GBR:
509  return( "NVVIOCOLORSPACE_GBR" );
510  break;
511  case NVVIOCOLORSPACE_GBRA:
512  return( "NVVIOCOLORSPACE_GBRA" );
513  break;
514  case NVVIOCOLORSPACE_GBRD:
515  return( "NVVIOCOLORSPACE_GBRD" );
516  break;
517  case NVVIOCOLORSPACE_UNKNOWN:
518  default:
519  return( "NVVIOCOLORSPACE_UNKNOWN" );
520  break;
521  }
522 }
523 
524 std::string LinkIDToString( NVVIOLINKID id )
525 {
526  switch( id )
527  {
528  case NVVIOLINKID_A:
529  return( "NVVIOLINKID_A" );
530  break;
531  case NVVIOLINKID_B:
532  return( "NVVIOLINKID_B" );
533  break;
534  case NVVIOLINKID_C:
535  return( "NVVIOLINKID_C" );
536  break;
537  case NVVIOLINKID_D:
538  return( "NVVIOLINKID_D" );
539  break;
540  default:
541  return( "Unknown" );
542  break;
543  }
544 }
545 
546 /*
547 //This function scans current HW topology
548 int ScanHW(HNVGPUVIO * gpuList, int * PrimaryIdx)
549 {
550  // First we need to create a dummy invisible window, otherwise none of the wgl functions will
551  // be available and we can't set up GLAffinity Contexts. This is 'hacky' but it's the only way
552  HWND hWnd;
553  HGLRC hGLRC;
554  CreateDummyGLWindow(&hWnd,&hGLRC);
555  if(!loadExtensionFunctions())
556  {
557  printf("Could not load OpenGL extensions\n");
558  return 0;
559  }
560 
561  // Query available VIO topologies.
562  // Initialize NVAPI
563  if (NvAPI_Initialize() != NVAPI_OK) {
564  return -1;
565  }
566  // Fail if there are no VIO topologies or devices available.
567  NVVIOTOPOLOGY l_vioTopologies;
568  memset(&l_vioTopologies, 0, sizeof(l_vioTopologies));
569  l_vioTopologies.version = NVVIOTOPOLOGY_VER;
570 
571  if (NvAPI_VIO_QueryTopology(&l_vioTopologies) != NVAPI_OK) {
572  return -1;
573  }
574 
575  if (l_vioTopologies.vioTotalDeviceCount == 0) {
576  return -1;
577  }
578 
579  //if(!loadExtensionFunctions())
580  // return 0;
581  printf("\n\nListing GPUs available for OpenGL GPU Affinity\n");
582  int numGPUs = 0;
583  unsigned int GPUIdx = 0;
584  GPU_DEVICE gpuDevice;
585  gpuDevice.cb = sizeof(gpuDevice);
586  HGPUNV hGPU;
587  HNVGPUVIO gpu_vio;
588  while(wglEnumGpusNV(GPUIdx,&hGPU)) // First call this function to get a handle to the gpu
589  { // wglEnumPGUsNV will fails if DeviceIdx > the available devices
590  printf("GPU# %d:\n",GPUIdx);
591  gpu_vio.hGpu = hGPU;
592  gpu_vio.hasSDIOutput = false;
593  gpu_vio.vioHandle = NULL;
594  gpu_vio.hasDisplay = false;
595  gpu_vio.isPrimary = false;
596  // Now get the detailed information about this device
597  int DisplayDeviceIdx = 0;
598  while(wglEnumGpuDevicesNV(hGPU,DisplayDeviceIdx,&gpuDevice))
599  {
600 
601  printf(" Display# %d\n",DisplayDeviceIdx);
602  printf(" Name: %s\n",gpuDevice.DeviceName);
603  printf(" String: %s\n",gpuDevice.DeviceString);
604 
605  NvDisplayHandle hNvDisplay;
606  NvAPI_Status status;
607  status = NvAPI_GetAssociatedNvidiaDisplayHandle(gpuDevice.DeviceName,&hNvDisplay);
608  if(status != NVAPI_OK)
609  break;
610 
611  gpu_vio.gpuDevice = gpuDevice;
612  gpu_vio.hasDisplay = true;
613 
614  NvU32 count = 0;
615  NvPhysicalGpuHandle hNvPhysicalGPU;
616  status = NvAPI_GetPhysicalGPUsFromDisplay(hNvDisplay,&hNvPhysicalGPU,&count);
617  if(status != NVAPI_OK)
618  break;
619 
620  // Cycle through all SDI topologies looking for the first
621  // available SDI output device topology.
622  BOOL l_bFound = FALSE;
623  unsigned int i = 0;
624  NVVIOCAPS l_vioCaps;
625  while ((i < l_vioTopologies.vioTotalDeviceCount) && (!l_bFound)) {
626 
627  if(l_vioTopologies.vioTarget[i].hPhysicalGpu == hNvPhysicalGPU){
628  // Get video I/O capabilities for current video I/O target.
629  memset(&l_vioCaps, 0, sizeof(l_vioCaps));
630  l_vioCaps.version = NVVIOCAPS_VER;
631  if (NvAPI_VIO_GetCapabilities(l_vioTopologies.vioTarget[i].hVioHandle,
632  &l_vioCaps) != NVAPI_OK) {
633  continue;
634  }
635  //MessageBox(NULL, "Video I/O Unsupported.", "Error", MB_OK);
636  //return E_FAIL;
637  // If video output device found, save VIO handle and set flag.
638  if (l_vioCaps.adapterCaps & NVVIOCAPS_VIDOUT_SDI) {
639  gpu_vio.hasSDIOutput = true;
640  gpu_vio.vioHandle = l_vioTopologies.vioTarget[i].hVioHandle;
641  l_bFound = TRUE;
642  } else {
643  i++;
644  }
645  }
646  else
647  {
648  i++;
649 
650  }
651  } // while i < vioTotalDeviceCount
652 
653  if(l_bFound)
654  printf(" SDI out: yes\n");
655  else
656  {
657  printf(" SDI out: no\n");
658  }
659  if(gpuDevice.Flags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP)
660  {
661  printf(" Attached to the desktop: LEFT=%d, RIGHT=%d, TOP=%d, BOTTOM=%d\n",
662  gpuDevice.rcVirtualScreen.left, gpuDevice.rcVirtualScreen.right, gpuDevice.rcVirtualScreen.top, gpuDevice.rcVirtualScreen.bottom);
663  }
664  else
665  {
666  printf(" Not attached to the desktop\n");
667  }
668 
669  // See if it's the primary GPU
670  if(gpuDevice.Flags & DISPLAY_DEVICE_PRIMARY_DEVICE)
671  {
672  printf(" This is the PRIMARY Display Device\n");
673  *PrimaryIdx = GPUIdx;
674  gpu_vio.isPrimary = true;
675  }
676  DisplayDeviceIdx++;
677 
678  }
679  gpuList[numGPUs].hasDisplay = gpu_vio.hasDisplay;
680  gpuList[numGPUs].hasSDIOutput = gpu_vio.hasSDIOutput;
681  gpuList[numGPUs].hGpu = gpu_vio.hGpu;
682  gpuList[numGPUs].vioHandle = gpu_vio.vioHandle;
683  gpuList[numGPUs].gpuDevice.cb = gpuDevice.cb;
684  gpuList[numGPUs].gpuDevice.rcVirtualScreen = gpuDevice.rcVirtualScreen;
685  gpuList[numGPUs].gpuDevice.Flags = gpuDevice.Flags;
686  memcpy(gpuList[numGPUs].gpuDevice.DeviceName,gpuDevice.DeviceName,32);
687  memcpy(gpuList[numGPUs].gpuDevice.DeviceString,gpuDevice.DeviceString,128);
688 
689  gpuList[numGPUs] = gpu_vio;
690 
691  numGPUs++;
692  GPUIdx++;
693  }
694  // We can kill the dummy window now
695  HDC hDC=GetDC(hWnd);
696  wglMakeCurrent(NULL,NULL);
697  wglDeleteContext(hGLRC);
698  ReleaseDC(hWnd,hDC);
699  DestroyWindow(hWnd);
700 
701  //if(glerr != GL_NO_ERROR)
702  // return 0;
703 
704  return(numGPUs);
705 }
706 */
const char * source
Definition: phidget22.h:2461
std::string DataFormatToString(NVVIODATAFORMAT format)
Definition: nvSDIutil.cpp:316
std::string LinkIDToString(NVVIOLINKID id)
Definition: nvSDIutil.cpp:524
std::string SyncStatusToString(NVVIOSYNCSTATUS status)
Definition: nvSDIutil.cpp:430
std::string SyncSourceToString(NVVIOSYNCSOURCE source)
Definition: nvSDIutil.cpp:457
std::string ColorSpaceToString(NVVIOCOLORSPACE space)
Definition: nvSDIutil.cpp:495
std::string SignalFormatToString(NVVIOSIGNALFORMAT format)
Definition: nvSDIutil.cpp:42
std::string ComponentSamplingFormatToString(NVVIOCOMPONENTSAMPLING sampling)
Definition: nvSDIutil.cpp:473