Od 27 marca 2025 r. zalecamy używanie android-latest-release
zamiast aosp-main
do kompilowania i wspołtworzenia AOSP. Więcej informacji znajdziesz w artykule o zmianach w AOSP.
Zadbaj o dobrą organizację dzięki kolekcji
Zapisuj i kategoryzuj treści zgodnie ze swoimi preferencjami.
Struktura vr_module
#include <
vr.h
>
Zaimplementuj ten interfejs HAL, aby otrzymywać wywołania zwrotne podczas korzystania z aplikacji rzeczywistości wirtualnej (VR). Aplikacje VR mają zazwyczaj specjalne wymagania dotyczące wyświetlania i wydajności, w tym:
-
Niski czas reakcji czujników – łączny czas reakcji od czujnika IMU, akcelerometru i żyroskopu do wywołania widocznego dla aplikacji musi być bardzo krótki (zwykle poniżej 5 ms). Jest to wymagane do obsługi czujnika HIFI.
-
Niska latencja wyświetlania – łączna latencja od wywołania funkcji rysowania na procesorze graficznym do faktycznej aktualizacji wyświetlania musi być jak najniższa. Aby to osiągnąć, należy użyć SurfaceFlingera w trybie pojedynczego buforowania i zadbać o to, aby wywołania funkcji rysowania były prawidłowo zsynchronizowane z wyświetlaniem. To zachowanie jest udostępniane aplikacjom za pomocą rozszerzenia EGL. Poniżej znajdziesz potrzebne w tym celu rozszerzenia EGL.
-
Wyświetlacz o niskiej perzystancji – ustawienia wyświetlacza o niskiej perzystancji muszą być ustawione tak nisko, jak to możliwe, przy zachowaniu rozsądnej jasności. W przypadku typowego wyświetlacza pracującego z częstotliwością 60 Hz piksele powinny być podświetlane przez czas nie dłuższy niż 3,5 ms, aby można je było uznać za oświetlenie o niskiej trwałości. Pozwala to uniknąć efektu ghostingu podczas poruszania się w ustawieniach VR. Należy włączyć tę opcję w
lights.h
HAL, gdy ustawiona jest opcja BRIGHTNESS_MODE_LOW_PERSISTENCE.
-
Stałe osiąganie wydajności przez GPU i CPU – w przypadku aplikacji VR z mieszanym obciążeniem GPU/CPU, która wykonuje zadania w regularnych odstępach czasu (kilka razy na klatkę), harmonogram procesora powinien zapewnić, aby zadania wątku renderowania aplikacji były wykonywane w ciągu 1 ms od momentu zaplanowania i były ukończone przed końcem okna rysowania. W tym celu jedno jądro procesora musi być zarezerwowane tylko dla wątku renderowania aktualnie uruchomionej aplikacji VR w trybie VR i udostępnione w ramach zestawu procesora „aplikacja na wierzchu”. Należy też zachować odpowiednią częstotliwość zegara procesora, procesora graficznego i szyny, aby mieć pewność, że renderowanie zostanie ukończone w czasie przeznaczonym na renderowanie każdej klatki, gdy w pliku
HAL power.h
w trybie VR, gdy urządzenie nie jest ograniczane termicznie.
-
Wymagane rozszerzenia EGL: wymagane są wszystkie ustawienia GPU umożliwiające korzystanie z wymienionych powyżej funkcji, w tym rozszerzenia 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 i EGL_KHR_wait_sync.
-
Dokładne raportowanie danych termicznych – dokładne temperatury i limity termiczne muszą być raportowane w pliku
thermal.h
HAL. W szczególności aktualna temperatura skóry musi być prawidłowo raportowana w przypadku DEVICE_TEMPERATURE_SKIN, a wartość vr_throttling_threshold zgłaszana przez to urządzenie musi prawidłowo raportować limit temperatury, powyżej którego regulator termiczny urządzenia ogranicza częstotliwość zegara procesora, GPU lub magistrali poniżej wartości minimalnej wymaganej do zapewnienia stabilnej wydajności (patrz poprzedni punkt).
Ogólnie rzecz biorąc, producenci wdrażający ten interfejs HAL powinni używać polecenia set_vr_mode jako wskazówki, aby włączyć optymalizację wydajności w trybie VR, która jest potrzebna do spełnienia któregokolwiek z wymienionych powyżej wymagań, oraz włączyć funkcje urządzenia, które są optymalne dla trybów wyświetlania VR. Jeśli nie ma żadnych optymalizacji lub nie są one potrzebne do spełnienia powyższych wymagań, wywołanie set_vr_mode może po prostu nic nie robić.
Żadna metoda w tym interfejsie HAL nie będzie wywoływana równolegle w ramach frameworka Androida.
Definicja w wierszu
82
pliku
vr.h
.
Metoda ułatwiająca implementację HAL do konfigurowania stanu potrzebnego podczas uruchamiania w czasie wykonywania. Ta metoda jest wywoływana raz przez VrManagerService podczas fazy uruchamiania. Przed zainicjowaniem nie zostanie wywołana żadna metoda tego interfejsu HAL.
Definicja w wierszu
96
w pliku
vr.h
.
Definicja w wierszu
110
w pliku
vr.h
.
void(* set_vr_mode)(struct
vr_module
*module, bool enabled)
|
Ustaw stan trybu VR. Możliwe stany parametru włączonego: false – tryb VR jest wyłączony, wyłącz wszystkie ustawienia dotyczące VR. true – tryb VR jest włączony, włącz wszystkie ustawienia dotyczące VR.
Jest on wywoływany za każdym razem, gdy system Android wchodzi w tryb VR lub z niego wychodzi. Zwykle dzieje się tak, gdy użytkownik przełącza się na aplikację VR, która wykonuje renderowanie stereoskopowe.
Definicja w wierszu
107
pliku
vr.h
.
Dokumentacja tego typu danych została wygenerowana z tego pliku:
-
hardware/libhardware/include/hardware/
vr.h
Treść strony i umieszczone na niej fragmenty kodu podlegają licencjom opisanym w Licencji na treści. Java i OpenJDK są znakami towarowymi lub zastrzeżonymi znakami towarowymi należącymi do firmy Oracle lub jej podmiotów stowarzyszonych.
Ostatnia aktualizacja: 2025-07-26 UTC.
[[["Łatwo zrozumieć","easyToUnderstand","thumb-up"],["Rozwiązało to mój problem","solvedMyProblem","thumb-up"],["Inne","otherUp","thumb-up"]],[["Brak potrzebnych mi informacji","missingTheInformationINeed","thumb-down"],["Zbyt skomplikowane / zbyt wiele czynności do wykonania","tooComplicatedTooManySteps","thumb-down"],["Nieaktualne treści","outOfDate","thumb-down"],["Problem z tłumaczeniem","translationIssue","thumb-down"],["Problem z przykładami/kodem","samplesCodeIssue","thumb-down"],["Inne","otherDown","thumb-down"]],["Ostatnia aktualizacja: 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)"]]