החל מ-27 במרץ 2025, מומלץ להשתמש ב-android-latest-release
במקום ב-aosp-main
כדי ליצור תרומות ל-AOSP. מידע נוסף זמין במאמר שינויים ב-AOSP.
קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
VR_module Struct Reference
#include <
vr.h
>
מטמיעים את ה-HAL הזה כדי לקבל קריאות חזרה (callbacks) כשמשתמשים באפליקציית מציאות מדומה (VR). לאפליקציות VR יש בדרך כלל מספר דרישות מיוחדות לגבי תצוגה וביצועים, כולל:
-
זמן אחזור נמוך של חיישנים – זמן האחזור הכולל מקצה לקצה, מה-IMU, מהתאוצה ומהג'ירו לקריאה חוזרת (callback) גלויה לאפליקציה, צריך להיות נמוך מאוד (בדרך כלל פחות מ-5ms). הדבר נדרש לתמיכה בחיישני HIFI.
-
זמן אחזור קצר לתצוגה – זמן האחזור הכולל מקצה לקצה, מקריאות ה-draw של ה-GPU ועד לעדכון התצוגה בפועל, צריך להיות קצר ככל האפשר. כדי לעשות זאת, משתמשים ב-SurfaceFlinger במצב עם מאגר אחד, ומוודאים שהקריאות לציור מסונכרנות בצורה נכונה עם הסריקה של המסך. ההתנהגות הזו חשופה לאפליקציות באמצעות תוסף EGL. בהמשך מפורטות התוספים של EGL הנדרשים לכך.
-
מסך עם עמידות נמוכה – צריך להגדיר את ההגדרות של עמידות המסך לערך הנמוך ביותר האפשרי תוך שמירה על בהירות סבירה. במסך טיפוסי שפועל ב-60Hz, הפיקסלים צריכים להאיר למשך פחות מ-3.5ms כדי להיחשב כמסך עם עמידות נמוכה. כך אפשר למנוע צללי תנועה במהלך תנועות בסביבת VR, וצריכים להפעיל את התכונה מ-HAL של
lights.h
כשמגדירים את BRIGHTNESS_MODE_LOW_PERSISTENCE.
-
ביצועים עקביים של ה-GPU וה-CPU – כשמתקבל עומס עבודה מעורב של GPU/CPU לאפליקציית VR עם התפרצויות של עבודה במרווחי זמן קבועים כמה פעמים בפרמטר, תזמון ה-CPU אמור להבטיח שהעבודה של חוט הרינדור של האפליקציה תפעל באופן עקבי תוך אלפית שנייה מהמועד שבו היא תוזמנה, ותושלם לפני סיום חלון הציור. לשם כך, צריך להקצות ליבה אחת של מעבד רק לשרשור הרינדור של אפליקציית ה-VR שפועלת כרגע במצב VR, ולהפוך אותה לזמינה ב-cpuset 'top-app'. באופן דומה, צריך לשמור על קצב שעון מתאים של המעבד, המעבד הגרפי והאוטובוס כדי להבטיח שעומס העבודה של העיבוד יסתיים במסגרת הזמן שהוקצה לעיבוד כל פריים, כשהדגל POWER_HINT_SUSTAINED_PERFORMANCE מוגדר ב-HAL של
power.h
במצב VR כשאין הגבלת מהירות תרמית במכשיר.
-
צריכות להיות תוספות EGL נדרשות – כל הגדרות ה-GPU הנדרשות כדי לאפשר את היכולות שלמעלה נדרשות, כולל תוספות ה-EGL: EGL_ANDROID_create_native_client_buffer, EGL_ANDROID_front_buffer_auto_refresh, EGL_EXT_protected_content, EGL_KHR_mutable_render_buffer, EGL_KHR_reusable_sync ו-EGL_KHR_wait_sync.
-
דיווח מדויק על נתונים תרמו-אלקטרוניים – צריך לדווח על טמפרטורות ומגבלות מדויקות של נתונים תרמו-אלקטרוניים ב-HAL
thermal.h
. באופן ספציפי, צריך לדווח בצורה מדויקת על טמפרטורת העור הנוכחית עבור DEVICE_TEMPERATURE_SKIN, ועל סף ה-vr_throttling_threshold שמדווח על המכשיר הזה צריך לדווח בצורה מדויקת על מגבלת הטמפרטורה שמעליה הרגולטור התרמי של המכשיר מגביל את מהירויות השעון של המעבד, המעבד הגרפי או האוטובוס מתחת לערך המינימלי הנדרש לביצועים עקביים (ראו הנקודה הקודמת ברשימה).
באופן כללי, ספקים שמטמיעים את ה-HAL הזה צפויים להשתמש ב-set_vr_mode כרמז להפעלת אופטימיזציה של ביצועים ספציפית ל-VR שנדרשת לכל אחת מהדרישות שלמעלה, ולהפעלת כל תכונות המכשיר שמתאימות למצבי התצוגה של VR. יכול להיות שהקריאה ל-set_vr_mode לא תבצע שום פעולה אם אין אופטימיזציות זמינות או נדרשות כדי לעמוד בדרישות שלמעלה.
לא יתבצע קריאה בו-זמנית לשיטות ב-HAL הזה מהמסגרת של Android.
ההגדרה מופיעה בשורה
82
בקובץ
vr.h
.
שיטה נוחה להטמעת HAL להגדרת כל מצב שנחוץ בזמן ההפעלה בסביבת זמן הריצה. הקריאה הזו מתבצעת פעם אחת מ-VrManagerService במהלך שלב האתחול שלו. לא יתבצעו קריאות לשיטות של ה-HAL הזה לפני init.
ההגדרה מופיעה בשורה
96
בקובץ
vr.h
.
ההגדרה מופיעה בשורה
110
בקובץ
vr.h
.
void(* set_vr_mode)(struct
vr_module
*module, bool enabled)
|
מגדירים את מצב VR. המצבים האפשריים של הפרמטר המופעל הם: false – מצב VR מושבת, צריך להשבית את כל ההגדרות הספציפיות ל-VR. true – מצב VR מופעל, צריך להפעיל את כל ההגדרות הספציפיות ל-VR.
הפונקציה הזו נקראת בכל פעם שמערכת Android נכנסת למצב VR או יוצאת ממנו. המצב הזה מתרחש בדרך כלל כשהמשתמש עובר מאפליקציית VR שמבצעת עיבוד סטראוסקופי או אליה.
ההגדרה מופיעה בשורה
107
בקובץ
vr.h
.
התיעוד של המבנה הזה נוצר מהקובץ הבא:
-
hardware/libhardware/include/hardware/
vr.h
דוגמאות התוכן והקוד שבדף הזה כפופות לרישיונות המפורטים בקטע רישיון לתוכן. Java ו-OpenJDK הם סימנים מסחריים או סימנים מסחריים רשומים של חברת Oracle ו/או של השותפים העצמאיים שלה.
עדכון אחרון: 2025-07-26 (שעון UTC).
[[["התוכן קל להבנה","easyToUnderstand","thumb-up"],["התוכן עזר לי לפתור בעיה","solvedMyProblem","thumb-up"],["סיבה אחרת","otherUp","thumb-up"]],[["חסרים לי מידע או פרטים","missingTheInformationINeed","thumb-down"],["התוכן מורכב מדי או עם יותר מדי שלבים","tooComplicatedTooManySteps","thumb-down"],["התוכן לא עדכני","outOfDate","thumb-down"],["בעיה בתרגום","translationIssue","thumb-down"],["בעיה בדוגמאות/בקוד","samplesCodeIssue","thumb-down"],["סיבה אחרת","otherDown","thumb-down"]],["עדכון אחרון: 2025-07-26 (שעון UTC)."],[],[],null,["# Android Hardware Abstraction Layer: vr_module Struct Reference\n\nvr_module Struct Reference\n==========================\n\n[Data Fields](#pub-attribs) \nvr_module Struct Reference \n\n`\n#include \u003c\n`[vr.h](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/vr.h)`\n\u003e\n`\n\n|----------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| Data Fields ----------- ||\n| struct [hw_module_t](/reference/hal/structhw__module__t) | [common](/reference/hal/structvr__module#a71ea01183b3998cad6a2301a37a42fc7) |\n| ||\n| void(\\* | [init](/reference/hal/structvr__module#a1621887a15b003a1ba7be81d52b0abb0) )(struct [vr_module](/reference/hal/structvr__module) \\*module) |\n| ||\n| void(\\* | [set_vr_mode](/reference/hal/structvr__module#a8c9e8990b6b65b068703cd615be68fb5) )(struct [vr_module](/reference/hal/structvr__module) \\*module, bool enabled) |\n| ||\n| void \\* | [reserved](/reference/hal/structvr__module#aa1a42885ba14c2168dc14d3f219b5e99) \\[8-2\\] |\n| ||\n\n\nDetailed Description\n--------------------\n\n\nImplement this HAL to receive callbacks when a virtual reality (VR) application is being used. VR applications characteristically have a number of special display and performance requirements, including:\n\n- Low sensor latency - Total end-to-end latency from the IMU, accelerometer, and gyro to an application-visible callback must be extremely low (\\\u003c5ms typically). This is required for HIFI sensor support.\n- Low display latency - Total end-to-end latency from the GPU draw calls to the actual display update must be as low as possible. This is achieved by using SurfaceFlinger in a single-buffered mode, and assuring that draw calls are synchronized with the display scanout correctly. This behavior is exposed via an EGL extension to applications. See below for the EGL extensions needed for this.\n- Low-persistence display - Display persistence settings must be set as low as possible while still maintaining a reasonable brightness. For a typical display running at 60Hz, pixels should be illuminated for \\\u003c=3.5ms to be considered low-persistence. This avoids ghosting during movements in a VR setting, and should be enabled from the [lights.h](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/lights.h) HAL when BRIGHTNESS_MODE_LOW_PERSISTENCE is set.\n- Consistent performance of the GPU and CPU - When given a mixed GPU/CPU workload for a VR application with bursts of work at regular intervals several times a frame, the CPU scheduling should ensure that the application render thread work is run consistently within 1ms of when scheduled, and completed before the end of the draw window. To this end, a single CPU core must be reserved for solely for the currently running VR application's render thread while in VR mode, and made available in the \"top-app\" cpuset. Likewise, an appropriate CPU, GPU, and bus clockrate must be maintained to ensure that the rendering workload finishes within the time allotted to render each frame when the POWER_HINT_SUSTAINED_PERFORMANCE flag has been set in the [power.h](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/power.h) HAL while in VR mode when the device is not being thermally throttled.\n- Required EGL extensions must be present - Any GPU settings required to allow the above capabilities are required, including the EGL extensions: EGL_ANDROID_create_native_client_buffer, EGL_ANDROID_front_buffer_auto_refresh, EGL_EXT_protected_content, EGL_KHR_mutable_render_buffer, EGL_KHR_reusable_sync, and EGL_KHR_wait_sync.\n- Accurate thermal reporting - Accurate thermal temperatures and limits must be reported in the [thermal.h](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/thermal.h) HAL. Specifically, the current skin temperature must accurately be reported for DEVICE_TEMPERATURE_SKIN and the vr_throttling_threshold reported for this device must accurately report the temperature limit above which the device's thermal governor throttles the CPU, GPU, and/or bus clockrates below the minimum necessary for consistent performance (see previous bullet point).\n\n\nIn general, vendors implementing this HAL are expected to use set_vr_mode as a hint to enable VR-specific performance tuning needed for any of the above requirements, and to turn on any device features optimal for VR display modes. The set_vr_mode call may simply do nothing if no optimizations are available or necessary to meet the above requirements.\n\n\nNo methods in this HAL will be called concurrently from the Android framework.\n\n\nDefinition at line\n[82](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/vr.h)\nof file\n[vr.h](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/vr.h)\n.\n\nField Documentation\n-------------------\n\n\n|-----------------------------------------------------------------|\n| struct [hw_module_t](/reference/hal/structhw__module__t) common |\n\n\nCommon methods of the module. This\n*must*\nbe the first member of\n[vr_module](/reference/hal/structvr__module)\nas users of this structure may cast a\n[hw_module_t](/reference/hal/structhw__module__t)\nto a\n[vr_module](/reference/hal/structvr__module)\npointer in contexts where it's known that the\n[hw_module_t](/reference/hal/structhw__module__t)\nreferences a\n[vr_module](/reference/hal/structvr__module)\n.\n\n\nDefinition at line\n[89](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/vr.h)\nof file\n[vr.h](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/vr.h)\n.\n\n|-----------------------------------------------------------------------------|\n| void(\\* init)(struct [vr_module](/reference/hal/structvr__module) \\*module) |\n\n\nConvenience method for the HAL implementation to set up any state needed at runtime startup. This is called once from the VrManagerService during its boot phase. No methods from this HAL will be called before init.\n\n\nDefinition at line\n[96](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/vr.h)\nof file\n[vr.h](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/vr.h)\n.\n\n|------------------------|\n| void\\* reserved\\[8-2\\] |\n\n\nDefinition at line\n[110](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/vr.h)\nof file\n[vr.h](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/vr.h)\n.\n\n|--------------------------------------------------------------------------------------------------|\n| void(\\* set_vr_mode)(struct [vr_module](/reference/hal/structvr__module) \\*module, bool enabled) |\n\n\nSet the VR mode state. Possible states of the enabled parameter are: false - VR mode is disabled, turn off all VR-specific settings. true - VR mode is enabled, turn on all VR-specific settings.\n\n\nThis is called whenever the the Android system enters or leaves VR mode. This will typically occur when the user switches to or from a VR application that is doing stereoscopic rendering.\n\n\nDefinition at line\n[107](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/vr.h)\nof file\n[vr.h](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/vr.h)\n.\n\n*** ** * ** ***\n\nThe documentation for this struct was generated from the following file:\n\n- hardware/libhardware/include/hardware/ [vr.h](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/vr.h)"]]