اعتبارًا من 27 آذار (مارس) 2025، ننصحك باستخدام android-latest-release
بدلاً من aosp-main
لإنشاء AOSP والمساهمة فيه. لمزيد من المعلومات، يُرجى الاطّلاع على التغييرات في AOSP.
تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
مرجع بنية vr_module
#include <
vr.h
>
يمكنك تنفيذ HAL هذا لتلقّي عمليات استدعاء عند استخدام تطبيق الواقع الافتراضي. تفرض تطبيقات الواقع الافتراضي عادةً عددًا من متطلبات العرض والأداء الخاصة، بما في ذلك:
-
وقت استجابة منخفض لأجهزة الاستشعار: يجب أن يكون إجمالي وقت الاستجابة من البداية إلى النهاية من وحدة IMU ومقياس التسارع ووحدة التحكّم في الانحراف إلى طلب إعادة الاتصال المرئي للتطبيق منخفضًا جدًا (عادةً أقل من 5 مللي ثانية). هذا الإجراء مطلوب لتفعيل ميزة "الاستماع بجودة عالية".
-
وقت استجابة منخفض للعرض: يجب أن يكون إجمالي وقت الاستجابة من البداية إلى النهاية من طلبات رسم وحدة معالجة الرسومات إلى التحديث الفعلي للعرض منخفضًا قدر الإمكان. ويتم تحقيق ذلك باستخدام SurfaceFlinger في وضع التخزين المؤقت الفردي، والتأكّد من تزامن طلبات الرسم مع عملية مسح الشاشة بشكل صحيح. ويتم عرض هذا السلوك من خلال إضافة EGL للتطبيقات. اطّلِع أدناه على إضافات EGL المطلوبة لإجراء ذلك.
-
شاشة ذات مدة عرض منخفضة: يجب ضبط إعدادات مدة عرض الشاشة على أدنى مستوى ممكن مع الحفاظ على سطوع معقول. بالنسبة إلى الشاشة العادية التي تعمل بمعدّل 60 هرتز، يجب أن تبقى وحدات البكسل مضاءة لمدة 3.5 ملي ثانية كحدّ أدنى كي تُعتبر منخفضة الثبات. ويؤدي ذلك إلى تجنُّب ظهور مؤثر "المشاهدة المزدوجة" أثناء الحركات في وضع الواقع الافتراضي، ويجب تفعيله من ملف
lights.h
HAL عند ضبط BRIGHTNESS_MODE_LOW_PERSISTENCE.
-
الأداء المتسق لوحدة معالجة الرسومات ووحدة المعالجة المركزية: عند تقديم حمولة عمل مختلطة لوحدة معالجة الرسومات/وحدة المعالجة المركزية لتطبيق الواقع الافتراضي مع نوبات عمل على فترات منتظمة عدة مرات في اللقطة، يجب أن تضمن جدولة وحدة المعالجة المركزية تنفيذ عمل سلسلة المهام لعرض التطبيق بشكلٍ متسق خلال 1 ملي ثانية من وقت تحديد الموعد، وأن تكتمل قبل نهاية نافذة الرسم. لتحقيق هذا الهدف، يجب حجز نواة وحدة معالجة مركزية واحدة فقط لسلسلة عمليات عرض تطبيق الواقع الافتراضي الذي يتم تشغيله حاليًا أثناء تفعيل وضع الواقع الافتراضي، ويجب إتاحتها في مجموعة المعالجة المركزية "top-app". وبالمثل، يجب الحفاظ على معدّل ساعة مناسب لوحدة المعالجة المركزية ووحدة معالجة الرسومات ووحدة الحافلة لضمان انتهاء حمولة عرض اللقطات في غضون الوقت المخصّص لعرض كل لقطة عند ضبط العلامة POWER_HINT_SUSTAINED_PERFORMANCE فيملف برمجة التطبيقات
power.h
HAL أثناء استخدام وضع الواقع الافتراضي عندما لا يتم فرض قيود حرارية على الجهاز.
-
يجب توفُّر إضافات EGL المطلوبة: يجب توفُّر أي إعدادات مطلوبة لوحدة معالجة الرسومات للسماح بالإمكانات المذكورة أعلاه، بما في ذلك إضافات 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.
-
إعداد تقارير دقيقة عن الحرارة: يجب الإبلاغ عن درجات الحرارة والحدّ الأقصى لها بدقة فيملف برمجي
thermal.h
HAL. على وجه التحديد، يجب الإبلاغ بدقة عن درجة حرارة السطح الحالية لـ DEVICE_TEMPERATURE_SKIN، ويجب أن يُبلغ vr_throttling_threshold الذي تم الإبلاغ عنه لهذا الجهاز بدقة عن الحد الأقصى لدرجة الحرارة التي يحدّد عندها نظام التحكّم الحراري في الجهاز من معدّلات ساعة وحدة المعالجة المركزية و/أو وحدة معالجة الرسومات و/أو الناقل إلى ما دون الحد الأدنى اللازم لتحقيق أداء ثابت (راجِع النقطة النقطية السابقة).
بشكل عام، من المتوقّع أن يستخدم المورّدون الذين ينفّذون HAL هذا دالة set_vr_mode كإشارة لتفعيل ضبط الأداء الخاص بتقنية الواقع الافتراضي المطلوب لأي من المتطلبات المذكورة أعلاه، وتفعيل أي ميزات للجهاز تكون مثالية لأوضاع عرض الواقع الافتراضي. قد لا يؤدي طلب 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)
|
اضبط حالة وضع الواقع الافتراضي. الحالات المحتمَلة للمَعلمة enabled هي: false - وضع الواقع الافتراضي غير مفعَّل، أوقِف جميع الإعدادات المتعلّقة بالواقع الافتراضي. true - وضع الواقع الافتراضي مفعَّل، فعِّل جميع الإعدادات المتعلّقة بالواقع الافتراضي.
يتمّ تشغيل هذا الإجراء كلّما دخل نظام Android في وضع الواقع الافتراضي أو خرج منه. ويحدث ذلك عادةً عندما ينتقل المستخدم إلى تطبيق واقع افتراضي يُجري عرضًا مجسمًا أو يغادره.
التعريف في السطر
107
من الملف
vr.h
.
تم إنشاء مستندات هذه البنية من الملف التالي:
-
hardware/libhardware/include/hardware/
vr.h
يخضع كل من المحتوى وعيّنات التعليمات البرمجية في هذه الصفحة للتراخيص الموضحّة في ترخيص استخدام المحتوى. إنّ Java وOpenJDK هما علامتان تجاريتان مسجَّلتان لشركة Oracle و/أو الشركات التابعة لها.
تاريخ التعديل الأخير: 2025-07-26 (حسب التوقيت العالمي المتفَّق عليه)
[[["يسهُل فهم المحتوى.","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 (حسب التوقيت العالمي المتفَّق عليه)"],[],[],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)"]]