This repository has been archived by the owner on Nov 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 114
/
Copy pathnvidia.h
785 lines (631 loc) · 30.2 KB
/
nvidia.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
/*
* Process Hacker Extra Plugins -
* Nvidia GPU Plugin
*
* Copyright (C) 2015 dmex
*
* This file is part of Process Hacker.
*
* Process Hacker is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Process Hacker is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Process Hacker. If not, see <http://www.gnu.org/licenses/>.
*/
#include "main.h"
#include <pshpack8.h>
// rev
#define NVAPI_MAX_USAGES_PER_GPU 33
#define NVAPI_MAX_CLOCKS_PER_GPU 0x120
#define NVAPI_MAX_COOLERS_PER_GPU 3
#define NVAPI_MIN_COOLER_LEVEL 0
#define NVAPI_MAX_COOLER_LEVEL 100
#define NVAPI_MAX_COOLER_LEVELS 24
#define NVAPI_MAX_PROCESSES 128
// rev
typedef PVOID (WINAPIV *_NvAPI_QueryInterface)(NvU32 FunctionOffset);
_NvAPI_QueryInterface NvAPI_QueryInterface;
// rev
typedef NvAPI_Status (WINAPIV *_NvAPI_GPU_GetShaderPipeCount)(_In_ NvPhysicalGpuHandle hPhysicalGPU, NvU32* pShaderPipeCount);
_NvAPI_GPU_GetShaderPipeCount NvAPI_GPU_GetShaderPipeCount;
// rev
typedef NvAPI_Status (WINAPIV *_NvAPI_GPU_GetShaderSubPipeCount)(_In_ NvPhysicalGpuHandle hPhysicalGPU, NvU32* pShaderSubPipeCount);
_NvAPI_GPU_GetShaderSubPipeCount NvAPI_GPU_GetShaderSubPipeCount;
// rev
typedef enum _NV_RAM_TYPE
{
NV_RAM_TYPE_NONE,
NV_RAM_TYPE_SDRAM,
NV_RAM_TYPE_DDR1,
NV_RAM_TYPE_DDR2,
NV_RAM_TYPE_GDDR2,
NV_RAM_TYPE_GDDR3,
NV_RAM_TYPE_GDDR4,
NV_RAM_TYPE_DDR3,
NV_RAM_TYPE_GDDR5,
NV_RAM_TYPE_LPDDR2
} NV_RAM_TYPE;
// rev
typedef NvAPI_Status (WINAPIV *_NvAPI_GPU_GetRamType)(_In_ NvPhysicalGpuHandle hPhysicalGPU, NV_RAM_TYPE* pRamType);
_NvAPI_GPU_GetRamType NvAPI_GPU_GetRamType;
// rev
typedef enum _NV_RAM_MAKER
{
NV_RAM_MAKER_NONE,
NV_RAM_MAKER_SAMSUNG,
NV_RAM_MAKER_QIMONDA,
NV_RAM_MAKER_ELPIDA,
NV_RAM_MAKER_ETRON,
NV_RAM_MAKER_NANYA,
NV_RAM_MAKER_HYNIX,
NV_RAM_MAKER_MOSEL,
NV_RAM_MAKER_WINBOND,
NV_RAM_MAKER_ELITE,
NV_RAM_MAKER_MICRON
} NV_RAM_MAKER;
// rev
typedef NvAPI_Status (WINAPIV *_NvAPI_GPU_GetRamMaker)(_In_ NvPhysicalGpuHandle hPhysicalGPU, NV_RAM_MAKER* pRamMaker);
_NvAPI_GPU_GetRamMaker NvAPI_GPU_GetRamMaker;
// rev
typedef NvAPI_Status(WINAPIV *_NvAPI_GPU_GetRamBusWidth)(_In_ NvPhysicalGpuHandle hPhysicalGPU, NvU32* pRamBusWidth);
_NvAPI_GPU_GetRamBusWidth NvAPI_GPU_GetRamBusWidth;
// rev
typedef NvAPI_Status(WINAPIV *_NvAPI_GPU_GetRamBankCount)(_In_ NvPhysicalGpuHandle hPhysicalGPU, NvU32* pRamBankCount);
_NvAPI_GPU_GetRamBankCount NvAPI_GPU_GetRamBankCount;
typedef enum _NV_FOUNDRY
{
NV_FOUNDRY_NONE,
NV_FOUNDRY_TSMC,
NV_FOUNDRY_UMC,
NV_FOUNDRY_IBM,
NV_FOUNDRY_SMIC,
NV_FOUNDRY_CSM,
NV_FOUNDRY_TOSHIBA
} NV_FOUNDRY;
// rev
typedef NvAPI_Status (WINAPIV *_NvAPI_GPU_GetFoundry)(_In_ NvPhysicalGpuHandle hPhysicalGPU, NV_FOUNDRY* pFoundry);
_NvAPI_GPU_GetFoundry NvAPI_GPU_GetFoundry;
// rev
typedef NvAPI_Status (WINAPIV *_NvAPI_GPU_GetFBWidthAndLocation)(_In_ NvPhysicalGpuHandle hPhysicalGPU, NvU32* pWidth, NvU32* pLocation);
_NvAPI_GPU_GetFBWidthAndLocation NvAPI_GPU_GetFBWidthAndLocation;
// rev (This has a different offset than the NvAPI_GPU_GetMemoryInfo function despite both returning the same struct).
typedef NvAPI_Status (WINAPIV *_NvAPI_GetDisplayDriverMemoryInfo)(_In_ NvDisplayHandle NvDispHandle, _Inout_ NV_DISPLAY_DRIVER_MEMORY_INFO* pMemoryInfo);
_NvAPI_GetDisplayDriverMemoryInfo NvAPI_GetDisplayDriverMemoryInfo;
// rev
typedef enum _NV_COOLER_TYPE
{
NVAPI_COOLER_TYPE_NONE = 0,
NVAPI_COOLER_TYPE_FAN,
NVAPI_COOLER_TYPE_WATER,
NVAPI_COOLER_TYPE_LIQUID_NO2,
} NV_COOLER_TYPE;
// rev
typedef enum _NV_COOLER_CONTROLLER
{
NVAPI_COOLER_CONTROLLER_NONE = 0,
NVAPI_COOLER_CONTROLLER_ADI,
NVAPI_COOLER_CONTROLLER_INTERNAL,
} NV_COOLER_CONTROLLER;
// rev
typedef enum _NV_COOLER_POLICY
{
NVAPI_COOLER_POLICY_NONE = 0,
NVAPI_COOLER_POLICY_MANUAL, // Manual adjustment of cooler level. Gets applied right away independent of temperature or performance level.
NVAPI_COOLER_POLICY_PERF, // GPU performance controls the cooler level.
NVAPI_COOLER_POLICY_TEMPERATURE_DISCRETE = 4, // Discrete thermal levels control the cooler level.
NVAPI_COOLER_POLICY_TEMPERATURE_CONTINUOUS = 8, // Cooler level adjusted at continuous thermal levels.
NVAPI_COOLER_POLICY_HYBRID, // Hybrid of performance and temperature levels.
} NV_COOLER_POLICY;
// rev
typedef enum _NV_COOLER_TARGET
{
NVAPI_COOLER_TARGET_NONE = 0,
NVAPI_COOLER_TARGET_GPU,
NVAPI_COOLER_TARGET_MEMORY,
NVAPI_COOLER_TARGET_POWER_SUPPLY = 4,
NVAPI_COOLER_TARGET_ALL = 7 // This cooler cools all of the components related to its target gpu.
} NV_COOLER_TARGET;
// rev
typedef enum _NV_COOLER_CONTROL
{
NVAPI_COOLER_CONTROL_NONE = 0,
NVAPI_COOLER_CONTROL_TOGGLE, // ON/OFF
NVAPI_COOLER_CONTROL_VARIABLE, // Suppports variable control.
} NV_COOLER_CONTROL;
// rev
typedef enum _NV_COOLER_ACTIVITY_LEVEL
{
NVAPI_INACTIVE = 0, // inactive or unsupported
NVAPI_ACTIVE = 1, // active and spinning in case of fan
} NV_COOLER_ACTIVITY_LEVEL;
// rev
typedef struct _NV_GPU_COOLER_SETTINGS
{
NvU32 version; // structure version
NvU32 count; // number of associated coolers with the selected GPU
struct
{
NV_COOLER_TYPE type; // type of cooler - FAN, WATER, LIQUID_NO2...
NV_COOLER_CONTROLLER controller; // internal, ADI...
NvU32 defaultMinLevel; // the min default value % of the cooler
NvU32 defaultMaxLevel; // the max default value % of the cooler
NvU32 currentMinLevel; // the current allowed min value % of the cooler
NvU32 currentMaxLevel; // the current allowed max value % of the cooler
NvU32 currentLevel; // the current value % of the cooler
NV_COOLER_POLICY defaultPolicy; // cooler control policy - auto-perf, auto-thermal, manual, hybrid...
NV_COOLER_POLICY currentPolicy; // cooler control policy - auto-perf, auto-thermal, manual, hybrid...
NV_COOLER_TARGET target; // cooling target - GPU, memory, chipset, powersupply, canoas...
NV_COOLER_CONTROL controlType; // toggle or variable
NV_COOLER_ACTIVITY_LEVEL active; // is the cooler active - fan spinning...
} cooler[NVAPI_MAX_COOLERS_PER_GPU];
} NV_GPU_COOLER_SETTINGS, *PNV_GPU_COOLER_SETTINGS;
#define NV_GPU_COOLER_SETTINGS_VER MAKE_NVAPI_VERSION(NV_GPU_COOLER_SETTINGS, 1)
// rev
typedef struct _NV_GPU_SETCOOLER_LEVEL
{
NvU32 version; //structure version
struct
{
NvU32 currentLevel; // the new value % of the cooler
NV_COOLER_POLICY currentPolicy; // the new cooler control policy - auto-perf, auto-thermal, manual, hybrid...
} cooler[NVAPI_MAX_COOLERS_PER_GPU];
} NV_GPU_SETCOOLER_LEVEL;
#define NV_GPU_SETCOOLER_LEVEL_VER MAKE_NVAPI_VERSION(NV_GPU_SETCOOLER_LEVEL, 1)
// rev
typedef struct _NV_GPU_COOLER_POLICY_TABLE
{
NvU32 version; //structure version
NV_COOLER_POLICY policy; //selected policy to update the cooler levels for, example NVAPI_COOLER_POLICY_PERF
struct
{
NvU32 levelId; // level indicator for a policy
NvU32 currentLevel; // new cooler level for the selected policy level indicator.
NvU32 defaultLevel; // default cooler level for the selected policy level indicator.
} policyCoolerLevel[NVAPI_MAX_COOLER_LEVELS];
} NV_GPU_COOLER_POLICY_TABLE;
#define NV_GPU_COOLER_POLICY_TABLE_VER MAKE_NVAPI_VERSION(NV_GPU_COOLER_POLICY_TABLE, 1)
///////////////////////////////////////////////////////////////////////////////
//
// FUNCTION NAME: NvAPI_GPU_GetCoolerSettings
//
// DESCRIPTION: Retrieves the cooler information of all coolers or a specific cooler associated with the selected GPU.
// Coolers are indexed 0 to NVAPI_MAX_COOLERS_PER_GPU-1.
// To retrieve specific cooler info set the coolerIndex to the appropriate cooler index.
// To retrieve info for all cooler set coolerIndex to NVAPI_COOLER_TARGET_ALL.
//
// PARAMETERS : hPhysicalGPU(IN) - GPU selection.
// coolerIndex(IN) - Explict cooler index selection.
// pCoolerInfo(OUT) - Array of cooler settings.
//
///////////////////////////////////////////////////////////////////////////////
typedef NvAPI_Status (WINAPIV *_NvAPI_GPU_GetCoolerSettings)(_In_ NvPhysicalGpuHandle hPhysicalGpu, NvU32 coolerIndex, NV_GPU_COOLER_SETTINGS* pCoolerInfo);
_NvAPI_GPU_GetCoolerSettings NvAPI_GPU_GetCoolerSettings;
///////////////////////////////////////////////////////////////////////////////
//
// FUNCTION NAME: NvAPI_GPU_SetCoolerLevels
//
// DESCRIPTION: Set the cooler levels for all coolers or a specific cooler associated with the selected GPU.
// Coolers are indexed 0 to NVAPI_MAX_COOLERS_PER_GPU-1. Every cooler level with non-zero currentpolicy gets applied.
// The new level should be in the range of minlevel and maxlevel retrieved from GetCoolerSettings API or between
// and NVAPI_MIN_COOLER_LEVEL to MAX_COOLER_LEVEL.
// To set level for a specific cooler set the coolerIndex to the appropriate cooler index.
// To set level for all coolers set coolerIndex to NVAPI_COOLER_TARGET_ALL.
// NOTE: To lock the fan speed independent of the temperature or performance changes set the cooler currentPolicy to
// NVAPI_COOLER_POLICY_MANUAL else set it to the current policy retrieved from the GetCoolerSettings API.
// PARAMETERS: hPhysicalGPU(IN) - GPU selection.
// coolerIndex(IN) - Explict cooler index selection.
// pCoolerLevels(IN) - Updated cooler level and cooler policy.
//
///////////////////////////////////////////////////////////////////////////////
typedef NvAPI_Status (WINAPIV *_NvAPI_GPU_SetCoolerLevels)(_In_ NvPhysicalGpuHandle hPhysicalGpu, NvU32 coolerIndex, NV_GPU_SETCOOLER_LEVEL *pCoolerLevels);
///////////////////////////////////////////////////////////////////////////////
//
// FUNCTION NAME: NvAPI_GPU_RestoreCoolerSettings
//
// DESCRIPTION: Restore the modified cooler settings to NVIDIA defaults.
//
// PARAMETERS: hPhysicalGPU(IN) - GPU selection.
// pCoolerIndex(IN) - Array containing absolute cooler indexes to restore. Pass NULL restore all coolers.
// CoolerCount - Number of coolers to restore.
//
///////////////////////////////////////////////////////////////////////////////
typedef NvAPI_Status (WINAPIV *_NvAPI_GPU_RestoreCoolerSettings)(_In_ NvPhysicalGpuHandle hPhysicalGpu, NvU32 *pCoolerIndex, NvU32 coolerCount);
///////////////////////////////////////////////////////////////////////////////
//
// FUNCTION NAME: NvAPI_GPU_GetCoolerPolicyTable
//
// DESCRIPTION: Retrieves the table of cooler and policy levels for the selected policy. Supported only for NVAPI_COOLER_POLICY_PERF.
//
// PARAMETERS: hPhysicalGPU(IN) - GPU selection.
// coolerIndex(IN) - cooler index selection.
// pCoolerTable(OUT) - Table of policy levels and associated cooler levels.
// count(OUT) - Count of the number of valid levels for the selected policy.
//
///////////////////////////////////////////////////////////////////////////////
typedef NvAPI_Status (WINAPIV *_NvAPI_GPU_GetCoolerPolicyTable)(_In_ NvPhysicalGpuHandle hPhysicalGpu, NvU32 coolerIndex, NV_GPU_COOLER_POLICY_TABLE *pCoolerTable, NvU32 *count);
///////////////////////////////////////////////////////////////////////////////
//
// FUNCTION NAME: NvAPI_GPU_SetCoolerPolicyTable
//
// DESCRIPTION: Restore the modified cooler settings to NVIDIA defaults. Supported only for NVAPI_COOLER_POLICY_PERF.
//
// PARAMETERS: hPhysicalGPU(IN) - GPU selection.
// coolerIndex(IN) - cooler index selection.
// pCoolerTable(IN) - Updated table of policy levels and associated cooler levels. Every non-zero policy level gets updated.
// count(IN) - Number of valid levels in the policy table.
//
///////////////////////////////////////////////////////////////////////////////
typedef NvAPI_Status (WINAPIV *_NvAPI_GPU_SetCoolerPolicyTable)(_In_ NvPhysicalGpuHandle hPhysicalGpu, NvU32 coolerIndex, NV_GPU_COOLER_POLICY_TABLE *pCoolerTable, NvU32 count);
///////////////////////////////////////////////////////////////////////////////
//
// FUNCTION NAME: NvAPI_GPU_RestoreCoolerPolicyTable
//
// DESCRIPTION: Restores the perf table policy levels to the defaults.
//
// PARAMETERS: hPhysicalGPU(IN) - GPU selection.
// coolerIndex(IN) - cooler index selection.
// pCoolerIndex(IN) - Array containing absolute cooler indexes to restore. Pass NULL restore all coolers.
// coolerCount - Number of coolers to restore.
// policy - restore for the selected policy
//
///////////////////////////////////////////////////////////////////////////////
typedef NvAPI_Status (WINAPIV *_NvAPI_GPU_RestoreCoolerPolicyTable)(_In_ NvPhysicalGpuHandle hPhysicalGpu, NvU32 *pCoolerIndex, NvU32 coolerCount, NV_COOLER_POLICY policy);
// rev - NvAPI_GPU_GetUsages
typedef struct _NV_USAGES_INFO
{
NvU32 version; //!< Structure version
NvU32 usages[NVAPI_MAX_USAGES_PER_GPU];
} NV_USAGES_INFO;
#define NV_USAGES_INFO_VER MAKE_NVAPI_VERSION(NV_USAGES_INFO, 1)
// rev
typedef NvAPI_Status (WINAPIV *_NvAPI_GPU_GetUsages)(_In_ NvPhysicalGpuHandle hPhysicalGpu, _Inout_ NV_USAGES_INFO* pUsagesInfo);
_NvAPI_GPU_GetUsages NvAPI_GPU_GetUsages;
// rev - NvAPI_GPU_GetAllClocks
typedef struct _NV_CLOCKS_INFO
{
NvU32 version; //!< Structure version
NvU32 clocks[NVAPI_MAX_CLOCKS_PER_GPU];
} NV_CLOCKS_INFO;
#define NV_CLOCKS_INFO_VER MAKE_NVAPI_VERSION(NV_CLOCKS_INFO, 2)
// rev
typedef NvAPI_Status (WINAPIV *_NvAPI_GPU_GetAllClocks)(_In_ NvPhysicalGpuHandle hPhysicalGpu, _Inout_ NV_CLOCKS_INFO* pClocksInfo);
_NvAPI_GPU_GetAllClocks NvAPI_GPU_GetAllClocks;
// rev - NvAPI_GPU_GetVoltageDomainsStatus
typedef struct _NV_VOLTAGE_DOMAINS
{
NvU32 version; //!< Structure version
NvU32 flags; //!< Reserved for future use. Must be set to 0
NvU32 max;
struct
{
NV_GPU_PERF_VOLTAGE_INFO_DOMAIN_ID domainId; //!< ID of the voltage domain
NvU32 mvolt; //!< Voltage in mV
} domain[NVAPI_MAX_GPU_PERF_VOLTAGES];
} NV_VOLTAGE_DOMAINS;
#define NV_VOLTAGE_DOMAIN_INFO_VER MAKE_NVAPI_VERSION(NV_VOLTAGE_DOMAINS, 1)
// rev
typedef NvAPI_Status (WINAPIV *_NvAPI_GPU_GetVoltageDomainsStatus)(_In_ NvPhysicalGpuHandle hPhysicalGPU, _Inout_ NV_VOLTAGE_DOMAINS* pVoltageDomainsStatus);
_NvAPI_GPU_GetVoltageDomainsStatus NvAPI_GPU_GetVoltageDomainsStatus;
//internal enum \ue098
//{
// \ue000,
// \ue001
//}
typedef struct
{
NvU32 version;
NvU32 flags;
BYTE unknown[32];
NvU32 mvolt;
BYTE unknown1[32];
} NVAPI_RAIL_STATUS;
#define NV_RAIL_STATUS_INFO_VER MAKE_NVAPI_VERSION(NVAPI_RAIL_STATUS, 1)
// rev
typedef NvAPI_Status (__cdecl* _NvAPI_GPU_GetCurrentVoltage)(_In_ NvPhysicalGpuHandle hPhysicalGPU, NVAPI_RAIL_STATUS* pClientRailsStatus);
_NvAPI_GPU_GetCurrentVoltage NvAPI_GetCurrentVoltage;
// rev - NvAPI_GPU_GetVoltages
typedef struct _NV_VOLTAGES_INFO
{
NV_GPU_PERF_VOLTAGE_INFO_DOMAIN_ID domainId; //!< ID of the voltage domain
NvU32 unknown1;
NvU32 max;
struct
{
NvU32 unknown2;
NvU32 mvolt; //!< Voltage in mV
} info[128];
} NV_VOLTAGES_INFO;
// rev
typedef struct _NV_VOLTAGES
{
NvU32 version; //!< Structure version
NvU32 flags; //!< Reserved for future use. Must be set to 0
NvU32 max;
NV_VOLTAGES_INFO voltages[NVAPI_MAX_GPU_PERF_VOLTAGES];
} NV_VOLTAGES;
#define NV_VOLTAGES_INFO_VER MAKE_NVAPI_VERSION(NV_VOLTAGES, 1)
// rev
typedef NvAPI_Status (WINAPIV *_NvAPI_GPU_GetVoltages)(_In_ NvPhysicalGpuHandle hPhysicalGPU, _Inout_ NV_VOLTAGES* pPerfVoltages);
_NvAPI_GPU_GetVoltages NvAPI_GPU_GetVoltages;
// rev - NvAPI_GPU_GetPerfClocks
typedef struct _NV_PERF_CLOCKS_UNKNOWN_2
{
NvU32 unknown1;
NvU32 unknown2;
NvU32 unknown3;
NvU32 unknown4;
NvU32 unknown5;
NvU32 unknown6;
NvU32 unknown7;
} NV_PERF_CLOCKS_UNKNOWN_2;
// rev
typedef struct _NV_PERF_CLOCKS_UNKNOWN_1
{
NvU32 unknown1;
NvU32 unknown2;
NV_PERF_CLOCKS_UNKNOWN_2 unknown3[32];
} NV_PERF_CLOCKS_UNKNOWN_1;
// rev
typedef struct _NV_PERF_CLOCKS
{
NvU32 version; //!< Structure version
NvU32 unknown1;
NvU32 unknown2;
NvU32 unknown3;
NvU32 unknown4;
NV_PERF_CLOCKS_UNKNOWN_1 unknown5[12];
} NV_PERF_CLOCKS;
#define NV_PERF_CLOCKS_INFO_VER MAKE_NVAPI_VERSION(NV_PERF_CLOCKS, 1)
// rev
typedef NvAPI_Status(WINAPIV *_NvAPI_GPU_GetPerfClocks)(_In_ NvPhysicalGpuHandle hPhysicalGPU, INT i, _Inout_ NV_PERF_CLOCKS* pPerfClocks);
_NvAPI_GPU_GetPerfClocks NvAPI_GPU_GetPerfClocks;
// rev - NvAPI_GPU_QueryActiveApps
typedef struct _NV_ACTIVE_APP
{
NvU32 version; //!< Structure version
NvU32 processPID;
NvAPI_LongString processName;
} NV_ACTIVE_APP;
#define NV_ACTIVE_APPS_INFO_VER MAKE_NVAPI_VERSION(NV_ACTIVE_APP, 2)
// rev
typedef NvAPI_Status (WINAPIV *_NvAPI_GPU_QueryActiveApps)(_In_ NvPhysicalGpuHandle hPhysicalGPU, _Inout_ NV_ACTIVE_APP pActiveApps[NVAPI_MAX_PROCESSES], _Inout_ NvU32* pTotal);
_NvAPI_GPU_QueryActiveApps NvAPI_GPU_QueryActiveApps;
// rev - NvAPI_GPU_GetPowerMizerInfo
typedef enum _PowerSourceInfo
{
PowerSourceInfo_Unknown1 = 1,
PowerSourceInfo_Unknown2,
PowerSourceInfo_Unknown3 = 8738
} PowerSourceInfo;
// rev
typedef enum _SelectSource
{
SelectSource_Unknown1 = 1,
SelectSource_Unknown2,
SelectSource_Unknown3
} SelectSource;
// rev
typedef enum _LevelInfo
{
LevelInfo_Unknown1 = 1,
LevelInfo_Unknown2,
LevelInfo_Unknown3,
LevelInfo_Unknown4,
LevelInfo_Unknown5,
LevelInfo_Unknown6,
LevelInfo_Unknown7
} LevelInfo;
// rev
typedef NvAPI_Status (WINAPIV *_NvAPI_GPU_GetPowerMizerInfo)(_In_ NvPhysicalGpuHandle hPhysicalGPU, PowerSourceInfo powerSourceInfo, SelectSource select, LevelInfo* pLevelInfo);
_NvAPI_GPU_GetPowerMizerInfo NvAPI_GPU_GetPowerMizerInfo;
// rev
typedef NvAPI_Status (WINAPIV *_NvAPI_GetDisplayDriverRegistryPath)(_In_ NvDisplayHandle hNvDisplay, _Inout_ NvAPI_LongString szDriverRegistryPath);
_NvAPI_GetDisplayDriverRegistryPath NvAPI_GetDisplayDriverRegistryPath;
// rev
//typedef NvAPI_Status (WINAPIV *_NvAPI_RestartDisplayDriver)(_In_ NvU32 NvDriverIndex);
//_NvAPI_RestartDisplayDriver NvAPI_RestartDisplayDriver;
typedef enum _NV_POWER_TOPOLOGY_FLAGS
{
NV_POWER_TOPOLOGY_FLAG_UNKNOWN1,
NV_POWER_TOPOLOGY_FLAG_UNKNOWN2
} NV_POWER_TOPOLOGY_FLAGS;
typedef struct _NV_POWER_TOPOLOGY_1
{
NvU32 unknown1;
NvU32 unknown2;
NvU32 unknown3;
//public uint UInt32_0
//{
// return this.unknown1 & 1u;
//}
//public uint UInt32_1
//{
// return (this.unknown1 & 4294967294u) / 2u;
//}
} NV_POWER_TOPOLOGY_1;
typedef struct _NV_POWER_TOPOLOGY_2
{
NV_POWER_TOPOLOGY_FLAGS flags;
NV_POWER_TOPOLOGY_1 unknown;
} NV_POWER_TOPOLOGY_2;
typedef struct _NV_POWER_TOPOLOGY_STATUS
{
NvU32 version; //!< Structure version
NvU32 count;
NV_POWER_TOPOLOGY_2 unknown[4];
} NV_POWER_TOPOLOGY_STATUS;
#define NV_POWER_TOPOLOGY_STATUS_VER MAKE_NVAPI_VERSION(NV_POWER_TOPOLOGY_STATUS, 1)
typedef NvAPI_Status (WINAPIV *_NvAPI_GPU_ClientPowerTopologyGetStatus)(_In_ NvPhysicalGpuHandle hPhysicalGPU, _Inout_ NV_POWER_TOPOLOGY_STATUS* pClientPowerTopologyStatus);
_NvAPI_GPU_ClientPowerTopologyGetStatus NvAPI_GPU_ClientPowerTopologyGetStatus;
// rev
typedef NvAPI_Status (WINAPIV *_NvAPI_GPU_GetShortName)(_In_ NvPhysicalGpuHandle hPhysicalGPU, _Inout_ NvAPI_ShortString szName);
_NvAPI_GPU_GetShortName NvAPI_GPU_GetShortName;
// rev
typedef struct _NV_ARCH_INFO
{
NvU32 version; //!< Structure version
NvU32 unknown[3];
} NV_ARCH_INFO;
#define NV_ARCH_INFO_VER MAKE_NVAPI_VERSION(NV_ARCH_INFO, 2)
// rev
typedef NvAPI_Status (WINAPIV *_NvAPI_GPU_GetArchInfo)(_In_ NvPhysicalGpuHandle hPhysicalGPU, _Inout_ NV_ARCH_INFO* pArchInfo);
_NvAPI_GPU_GetArchInfo NvAPI_GPU_GetArchInfo;
// rev
typedef NvAPI_Status (WINAPIV *_NvAPI_GPU_GetPartitionCount)(_In_ NvPhysicalGpuHandle hPhysicalGPU, _Out_ NvU32* pCount);
_NvAPI_GPU_GetPartitionCount NvAPI_GPU_GetPartitionCount;
typedef struct _NV_PCIE_INFO_UNKNOWN
{
NvU32 unknown0;
NvU32 unknown1;
NvU32 unknown2;
NvU32 unknown3;
NvU32 unknown4;
NvU32 unknown5;
NvU32 unknown6;
NvU32 unknown7;
} NV_PCIE_INFO_UNKNOWN;
typedef struct _NV_PCIE_INFO
{
NvU32 version; //!< Structure version
NV_PCIE_INFO_UNKNOWN info[5];
} NV_PCIE_INFO;
#define NV_PCIE_INFO_VER MAKE_NVAPI_VERSION(NV_PCIE_INFO, 2)
typedef NvAPI_Status (WINAPIV *_NvAPI_GPU_GetPCIEInfo)(_In_ NvPhysicalGpuHandle hPhysicalGPU, _Inout_ NV_PCIE_INFO* pPciInfo);
_NvAPI_GPU_GetPCIEInfo NvAPI_GPU_GetPCIEInfo;
NV_DECLARE_HANDLE(NvmlDeviceHandle);
typedef enum _nvmlReturn_t
{
NVML_SUCCESS = 0, //!< The operation was successful
NVML_ERROR_UNINITIALIZED = 1, //!< NVML was not first initialized with nvmlInit()
NVML_ERROR_INVALID_ARGUMENT = 2, //!< A supplied argument is invalid
NVML_ERROR_NOT_SUPPORTED = 3, //!< The requested operation is not available on target device
NVML_ERROR_NO_PERMISSION = 4, //!< The current user does not have permission for operation
NVML_ERROR_ALREADY_INITIALIZED = 5, //!< Deprecated: Multiple initializations are now allowed through ref counting
NVML_ERROR_NOT_FOUND = 6, //!< A query to find an object was unsuccessful
NVML_ERROR_INSUFFICIENT_SIZE = 7, //!< An input argument is not large enough
NVML_ERROR_INSUFFICIENT_POWER = 8, //!< A device's external power cables are not properly attached
NVML_ERROR_DRIVER_NOT_LOADED = 9, //!< NVIDIA driver is not loaded
NVML_ERROR_TIMEOUT = 10, //!< User provided timeout passed
NVML_ERROR_UNKNOWN = 999 //!< An internal driver error occurred
} nvmlReturn_t;
typedef enum _NvmlPcieUtilCounter
{
NVML_PCIE_UTIL_TX_BYTES = 0,
NVML_PCIE_UTIL_RX_BYTES = 1,
NVML_PCIE_UTIL_COUNT
} NvmlPcieUtilCounter;
typedef enum _nvmlClockType_t
{
NVML_CLOCK_GRAPHICS = 0,
NVML_CLOCK_SM = 1,
NVML_CLOCK_MEM = 2,
NVML_CLOCK_VIDEO = 3,
NVML_CLOCK_COUNT
} nvmlClockType_t;
typedef enum _nvmlClockId_t
{
NVML_CLOCK_ID_CURRENT = 0,
NVML_CLOCK_ID_APP_CLOCK_TARGET = 1,
NVML_CLOCK_ID_APP_CLOCK_DEFAULT = 2,
NVML_CLOCK_ID_CUSTOMER_BOOST_MAX = 3,
NVML_CLOCK_ID_COUNT
} nvmlClockId_t;
typedef nvmlReturn_t (WINAPIV* _nvmlInit)(VOID);
_nvmlInit NvmlInit;
typedef nvmlReturn_t (WINAPIV* _nvmlInit_v2)(VOID);
_nvmlInit_v2 NvmlInit_v2;
#define NVML_INIT_FLAG_NO_GPUS 1 //!< Don't fail nvmlInit() when no GPUs are found
#define NVML_INIT_FLAG_NO_ATTACH 2 //!< Don't attach GPUs
typedef nvmlReturn_t (WINAPIV* _nvmlInitWithFlags)(_In_ UINT32 Flags);
_nvmlInitWithFlags nvmlInitWithFlags;
typedef nvmlReturn_t (WINAPIV* _nvmlShutdown)(VOID);
_nvmlShutdown NvmlShutdown;
typedef PSTR (WINAPIV* _nvmlErrorString)(VOID);
_nvmlErrorString NvmlErrorString;
// Retrieves the globally unique immutable UUID associated with this device, as a 5 part hexadecimal string, that augments the immutable, board serial identifier.
typedef nvmlReturn_t (WINAPIV* _nvmlDeviceGetUUID)(_In_ NvmlDeviceHandle DeviceHandle, _Inout_ PSTR uuid, _In_ UINT32 length);
_nvmlDeviceGetUUID NvmlDeviceGetUUID;
// Retrieves the globally unique board serial number associated with this device's board.
typedef nvmlReturn_t (WINAPIV* _nvmlDeviceGetSerial)(_In_ NvmlDeviceHandle DeviceHandle, _Inout_ PSTR serial, _In_ UINT32 length);
_nvmlDeviceGetSerial NvmlDeviceGetSerial;
typedef nvmlReturn_t (WINAPIV* _nvmlDeviceGetHandleByIndex_v2)(_In_ UINT32 index, _Out_ NvmlDeviceHandle* DeviceHandle);
_nvmlDeviceGetHandleByIndex_v2 NvmlDeviceGetHandleByIndex_v2;
// Acquire the handle for a particular device, based on its PCI bus id.
typedef nvmlReturn_t (WINAPIV* _nvmlDeviceGetHandleByPciBusId)(_In_ PSTR PciBusId, _Out_ NvmlDeviceHandle* DeviceHandle);
_nvmlDeviceGetHandleByPciBusId NvmlDeviceGetHandleByPciBusId;
// Acquire the handle for a particular device, based on its PCI bus id.
typedef nvmlReturn_t (WINAPIV* _nvmlDeviceGetHandleByPciBusId_v2)(_In_ PSTR PciBusId, _Out_ NvmlDeviceHandle* DeviceHandle);
_nvmlDeviceGetHandleByPciBusId_v2 NvmlDeviceGetHandleByPciBusId_v2;
// Retrieves power usage for this GPU in milliwatts and its associated circuitry (e.g. memory)
typedef nvmlReturn_t (WINAPIV* _nvmlDeviceGetPowerUsage)(_In_ NvmlDeviceHandle DeviceHandle, _Out_ PULONG Usage);
_nvmlDeviceGetPowerUsage NvmlDeviceGetPowerUsage;
// Retrieves the current temperature readings for the device, in degrees C.
typedef nvmlReturn_t (WINAPIV* _nvmlDeviceGetTemperature)(_In_ NvmlDeviceHandle DeviceHandle, _Out_ PULONG Temperature);
_nvmlDeviceGetTemperature NvmlDeviceGetTemperature;
// Retrieves the intended operating speed of the device's fan.
typedef nvmlReturn_t (WINAPIV* _nvmlDeviceGetFanSpeed)(_In_ NvmlDeviceHandle DeviceHandle, _Out_ PULONG Temperature);
_nvmlDeviceGetFanSpeed NvmlDeviceGetFanSpeed;
typedef enum nvmlSamplingType_enum
{
NVML_TOTAL_POWER_SAMPLES = 0, //!< To represent total power drawn by GPU
NVML_GPU_UTILIZATION_SAMPLES = 1, //!< To represent percent of time during which one or more kernels was executing on the GPU
NVML_MEMORY_UTILIZATION_SAMPLES = 2, //!< To represent percent of time during which global (device) memory was being read or written
NVML_ENC_UTILIZATION_SAMPLES = 3, //!< To represent percent of time during which NVENC remains busy
NVML_DEC_UTILIZATION_SAMPLES = 4, //!< To represent percent of time during which NVDEC remains busy
NVML_PROCESSOR_CLK_SAMPLES = 5, //!< To represent processor clock samples
NVML_MEMORY_CLK_SAMPLES = 6, //!< To represent memory clock samples
NVML_SAMPLINGTYPE_COUNT
} nvmlSamplingType_t;
typedef enum nvmlValueType_enum
{
NVML_VALUE_TYPE_DOUBLE = 0,
NVML_VALUE_TYPE_UNSIGNED_INT = 1,
NVML_VALUE_TYPE_UNSIGNED_LONG = 2,
NVML_VALUE_TYPE_UNSIGNED_LONG_LONG = 3,
NVML_VALUE_TYPE_SIGNED_LONG_LONG = 4,
NVML_VALUE_TYPE_COUNT
} nvmlValueType_t;
typedef union nvmlValue_st
{
double dVal; //!< If the value is double
unsigned int uiVal; //!< If the value is unsigned int
unsigned long ulVal; //!< If the value is unsigned long
unsigned long long ullVal; //!< If the value is unsigned long long
signed long long sllVal; //!< If the value is signed long long
} nvmlValue_t;
typedef struct nvmlSample_st
{
unsigned long long timeStamp; //!< CPU Timestamp in microseconds
nvmlValue_t sampleValue; //!< Sample Value
} nvmlSample_t;
typedef nvmlReturn_t(WINAPIV* _nvmlDeviceGetSamples)(_In_ NvmlDeviceHandle device, _In_ nvmlSamplingType_t type, unsigned long long lastSeenTimeStamp, nvmlValueType_t* sampleValType, unsigned int* sampleCount, nvmlSample_t* samples);
_nvmlDeviceGetSamples NvmlDeviceGetSamples;
// Retrieves the current PCIe link width
typedef nvmlReturn_t (WINAPIV* _nvmlDeviceGetCurrPcieLinkGeneration)(_In_ NvmlDeviceHandle DeviceHandle, _Out_ PULONG Generation);
_nvmlDeviceGetCurrPcieLinkGeneration NvmlDeviceGetCurrPcieLinkGeneration;
// Retrieves the maximum PCIe link generation possible with this device and system
typedef nvmlReturn_t (WINAPIV* _nvmlDeviceGetMaxPcieLinkGeneration)(_In_ NvmlDeviceHandle DeviceHandle, _Out_ PULONG Generation);
_nvmlDeviceGetMaxPcieLinkGeneration NvmlDeviceGetMaxPcieLinkGeneration;
// Retrieves the current PCIe link width
typedef nvmlReturn_t (WINAPIV* _nvmlDeviceGetCurrPcieLinkWidth)(_In_ NvmlDeviceHandle DeviceHandle, _Out_ PULONG Width);
_nvmlDeviceGetCurrPcieLinkWidth NvmlDeviceGetCurrPcieLinkWidth;
// Retrieves the maximum PCIe link width possible with this device and system
typedef nvmlReturn_t (WINAPIV* _nvmlDeviceGetMaxPcieLinkWidth)(_In_ NvmlDeviceHandle DeviceHandle, _Out_ PULONG Width);
_nvmlDeviceGetMaxPcieLinkWidth NvmlDeviceGetMaxPcieLinkWidth;
// Retrieve PCIe utilization information. This function is querying a byte counter over a 20ms interval and thus is the PCIe throughput over that interval.
typedef nvmlReturn_t (WINAPIV* _nvmlDeviceGetPcieThroughput)(_In_ NvmlDeviceHandle DeviceHandle, _In_ NvmlPcieUtilCounter counter, _Out_ PULONG Usage);
_nvmlDeviceGetPcieThroughput NvmlDeviceGetPcieThroughput;
// Retrieves the clock speed for the clock specified by the clock type and clock ID.
typedef nvmlReturn_t (WINAPIV* _nvmlDeviceGetClock)(_In_ NvmlDeviceHandle DeviceHandle, _In_ nvmlClockType_t clockType, _In_ nvmlClockId_t clockId, _Out_ PULONG clockMHz);
_nvmlDeviceGetClock NvmlDeviceGetClock;
// Retrieves total energy consumption for this GPU in millijoules (mJ) since the driver was last reloaded
typedef nvmlReturn_t (WINAPIV* _nvmlDeviceGetTotalEnergyConsumption)(_In_ NvmlDeviceHandle DeviceHandle, _Out_ PULONG64 energ);
_nvmlDeviceGetTotalEnergyConsumption NvmlDeviceGetTotalEnergyConsumption;
#include <poppack.h>