18 #if defined(__i386) || defined(__x86_64__) || defined(_M_IX86) || defined(_M_X64) 21 #elif defined(__GNUC__) && !defined(__clang__) 22 #include <x86intrin.h> 31 return (width == other.width && height == other.height &&
32 bits_per_pixel == other.bits_per_pixel &&
33 refresh_rate == other.refresh_rate &&
34 fullscreen_only == other.fullscreen_only);
49 output(std::ostream &out)
const {
50 out << width <<
'x' << height;
51 if (bits_per_pixel > 0) {
52 out <<
' ' << bits_per_pixel <<
"bpp";
54 if (refresh_rate > 0) {
55 out <<
' ' << refresh_rate <<
"Hz";
57 if (fullscreen_only > 0) {
58 out <<
" (fullscreen only)";
66 ~DisplayInformation() {
67 if (_display_mode_array !=
nullptr) {
68 delete[] _display_mode_array;
76 DisplayInformation() {
77 DisplayInformation::DetectionState state;
78 int get_adapter_display_mode_state;
79 int get_device_caps_state;
82 int window_bits_per_pixel;
83 int total_display_modes;
87 uint64_t physical_memory;
88 uint64_t available_physical_memory;
90 state = DisplayInformation::DS_unknown;
91 get_adapter_display_mode_state =
false;
92 get_device_caps_state =
false;
95 window_bits_per_pixel = 0;
96 total_display_modes = 0;
97 display_mode_array =
nullptr;
101 available_physical_memory = 0;
104 _get_adapter_display_mode_state = get_adapter_display_mode_state;
105 _get_device_caps_state = get_device_caps_state;
106 _maximum_window_width = window_width;
107 _maximum_window_height = window_height;
108 _window_bits_per_pixel = window_bits_per_pixel;
109 _total_display_modes = total_display_modes;
110 _display_mode_array = display_mode_array;
111 _shader_model = GraphicsStateGuardian::SM_00;
112 _video_memory = video_memory;
113 _texture_memory = texture_memory;
115 _physical_memory = physical_memory;
116 _available_physical_memory = available_physical_memory;
118 _available_page_file_size = 0;
119 _process_virtual_memory = 0;
120 _available_process_virtual_memory = 0;
122 _page_fault_count = 0;
124 _peak_process_memory = 0;
125 _page_file_usage = 0;
126 _peak_page_file_usage = 0;
133 _driver_sub_version = 0;
136 _driver_date_month = 0;
137 _driver_date_day = 0;
138 _driver_date_year = 0;
140 _cpu_version_information = 0;
141 _cpu_brand_index = 0;
145 _maximum_cpu_frequency = 0;
146 _current_cpu_frequency = 0;
149 _num_logical_cpus = 0;
151 _get_memory_information_function =
nullptr;
152 _update_cpu_frequency_function =
nullptr;
154 _os_version_major = -1;
155 _os_version_minor = -1;
156 _os_version_build = -1;
157 _os_platform_id = -1;
163 int DisplayInformation::get_display_state() {
170 int DisplayInformation::
171 get_maximum_window_width() {
172 return _maximum_window_width;
178 int DisplayInformation::
179 get_maximum_window_height() {
180 return _maximum_window_height;
186 int DisplayInformation::
187 get_window_bits_per_pixel() {
188 return _window_bits_per_pixel;
194 int DisplayInformation::
195 get_total_display_modes() {
196 return _total_display_modes;
203 get_display_mode(
int display_index) {
206 nassertr(display_index >= 0 && display_index < _total_display_modes, err_mode);
209 return _display_mode_array[display_index];
215 int DisplayInformation::
216 get_display_mode_width (
int display_index) {
220 if (display_index >= 0 && display_index < _total_display_modes) {
221 value = _display_mode_array [display_index].width;
230 int DisplayInformation::
231 get_display_mode_height (
int display_index) {
235 if (display_index >= 0 && display_index < _total_display_modes) {
236 value = _display_mode_array [display_index].height;
245 int DisplayInformation::
246 get_display_mode_bits_per_pixel (
int display_index) {
250 if (display_index >= 0 && display_index < _total_display_modes) {
251 value = _display_mode_array [display_index].bits_per_pixel;
260 int DisplayInformation::
261 get_display_mode_refresh_rate (
int display_index) {
265 if (display_index >= 0 && display_index < _total_display_modes) {
266 value = _display_mode_array [display_index].refresh_rate;
275 int DisplayInformation::
276 get_display_mode_fullscreen_only (
int display_index) {
280 if (display_index >= 0 && display_index < _total_display_modes) {
281 value = _display_mode_array [display_index].fullscreen_only;
290 GraphicsStateGuardian::ShaderModel DisplayInformation::
292 return _shader_model;
298 int DisplayInformation::
299 get_video_memory ( ) {
300 return _video_memory;
306 int DisplayInformation::
307 get_texture_memory() {
308 return _texture_memory;
314 void DisplayInformation::
315 update_memory_information() {
316 if (_get_memory_information_function) {
317 _get_memory_information_function (
this);
324 uint64_t DisplayInformation::
325 get_physical_memory() {
326 return _physical_memory;
332 uint64_t DisplayInformation::
333 get_available_physical_memory() {
334 return _available_physical_memory;
340 uint64_t DisplayInformation::
341 get_page_file_size() {
342 return _page_file_size;
348 uint64_t DisplayInformation::
349 get_available_page_file_size() {
350 return _available_page_file_size;
356 uint64_t DisplayInformation::
357 get_process_virtual_memory() {
358 return _process_virtual_memory;
364 uint64_t DisplayInformation::
365 get_available_process_virtual_memory() {
366 return _available_process_virtual_memory;
372 int DisplayInformation::
380 uint64_t DisplayInformation::
381 get_page_fault_count() {
382 return _page_fault_count;
388 uint64_t DisplayInformation::
389 get_process_memory() {
390 return _process_memory;
396 uint64_t DisplayInformation::
397 get_peak_process_memory() {
398 return _peak_process_memory;
404 uint64_t DisplayInformation::
405 get_page_file_usage() {
406 return _page_file_usage;
412 uint64_t DisplayInformation::
413 get_peak_page_file_usage() {
414 return _peak_page_file_usage;
420 int DisplayInformation::
428 int DisplayInformation::
436 int DisplayInformation::
437 get_driver_product() {
438 return _driver_product;
444 int DisplayInformation::
445 get_driver_version() {
446 return _driver_version;
452 int DisplayInformation::
453 get_driver_sub_version() {
454 return _driver_sub_version;
460 int DisplayInformation::
462 return _driver_build;
468 int DisplayInformation::
469 get_driver_date_month() {
470 return _driver_date_month;
476 int DisplayInformation::
477 get_driver_date_day() {
478 return _driver_date_day;
484 int DisplayInformation::
485 get_driver_date_year() {
486 return _driver_date_year;
492 const std::string &DisplayInformation::
493 get_cpu_vendor_string()
const {
494 return _cpu_vendor_string;
500 const std::string &DisplayInformation::
501 get_cpu_brand_string()
const {
502 return _cpu_brand_string;
508 unsigned int DisplayInformation::
509 get_cpu_version_information() {
510 return _cpu_version_information;
516 unsigned int DisplayInformation::
517 get_cpu_brand_index() {
518 return _cpu_brand_index;
524 uint64_t DisplayInformation::
525 get_cpu_frequency() {
526 return _cpu_frequency;
534 #if defined(__i386) || defined(__x86_64__) || defined(_M_IX86) || defined(_M_X64) 535 #if defined(_MSC_VER) || (defined(__GNUC__) && !defined(__clang__)) 538 unsigned int lo, hi = 0;
539 __asm__ __volatile__ (
"rdtsc" :
"=a" (lo),
"=d" (hi));
540 return ((uint64_t)hi << 32) | lo;
550 uint64_t DisplayInformation::
551 get_maximum_cpu_frequency() {
552 return _maximum_cpu_frequency;
558 uint64_t DisplayInformation::
559 get_current_cpu_frequency() {
560 return _current_cpu_frequency;
566 void DisplayInformation::
567 update_cpu_frequency(
int processor_number) {
568 if (_update_cpu_frequency_function) {
569 _update_cpu_frequency_function (processor_number,
this);
579 return _num_cpu_cores;
588 return _num_logical_cpus;
596 return _os_version_major;
604 return _os_version_minor;
612 return _os_version_build;
620 return _os_platform_id;
bool operator==(const DisplayMode &other) const
Returns true if these two DisplayModes are identical.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
bool operator !=(const DisplayMode &other) const
Returns false if these two DisplayModes are identical.