Stringa del nome
XR_ANDROID_composition_layer_passthrough_mesh
Tipo di estensione
Estensione dell'istanza
Numero di estensione registrato
463
Revisione
1
Dipendenze di estensioni e versioni
Data ultima modifica
2024-09-18
Stato IP
Nessuna rivendicazione IP nota.
Collaboratori
Grant Yoshida, Google
Kevin Moule, Google
Vasiliy Baranov, Google
Peter Chen, Google
Levana Chen, Google
Panoramica
Per i dispositivi che supportano più modalità di sfumatura dell'ambiente, il sistema può fornire configurazioni passthrough per mostrare all'utente il suo ambiente fisico da una visualizzazione immersiva.
Questa estensione consente alle applicazioni di proiettare texture passthrough su geometrie arbitrarie tramite un livello di composizione aggiuntivo XrCompositionLayerPassthroughANDROID.
Le caratteristiche del livello di transizione vengono specificate dai seguenti parametri, in cui la proiezione è rappresentata da XrPassthroughLayerANDROID.
XrPosef pose;
XrVector3f scale;
float opacity;
XrPassthroughLayerANDROID layer;
Per il passthrough a schermo intero, le applicazioni possono utilizzare la modalità di miscela dell'ambiente.
Controlla la funzionalità del sistema
Un'applicazione può verificare se il sistema è in grado di comporre un mesh di passaggio del livello collegando una struttura XrSystemPassthroughLayerPropertiesANDROID a XrSystemProperties quando chiama xrGetSystemProperties.
typedef struct XrSystemPassthroughLayerPropertiesANDROID {
XrStructureType type;
void* next;
XrBool32 supportsPassthroughLayer;
uint32_t maxMeshIndexCount;
uint32_t maxMeshVertexCount;
} XrSystemPassthroughLayerPropertiesANDROID;
Descrizioni dei membri
typeè il XrStructureType di questa struttura.nextèNULLo un puntatore alla struttura successiva in una catena di strutture. Queste strutture non sono definite in OpenXR di base o in questa estensione.supportsPassthroughLayerè unXrBool32che indica se il sistema corrente supporta il mesh di passaggio del livello di composizione.maxMeshIndexCountè unuint32_tche restituisce il numero massimo di indici che verranno accettati per una mesh passthrough.maxMeshVertexCountè unuint32_tche restituisce il numero massimo di vertici che verranno accettati per una mesh di passaggio.
Se supportsPassthroughLayer restituisce XR_FALSE, il sistema non supporta il mesh passthrough del livello di composizione e, di conseguenza, riceverà XR_ERROR_FEATURE_UNSUPPORTED da xrCreatePassthroughLayerANDROID. L'applicazione deve evitare di utilizzare la mesh di trasmissione del livello di composizione quando supportsPassthroughLayer è XR_FALSE.
Se supportsPassthroughLayer restituisce XR_TRUE, il sistema supporta il mesh passthrough del livello di composizione. In questo caso,
maxMeshIndexCount e maxMeshVertexCount restituiranno un numero diverso da zero. Un'applicazione deve utilizzare maxMeshIndexCount e maxMeshVertexCount come valori massimi per impostare i mesh di transizione quando chiama xrCreatePassthroughLayerANDROID e xrSetPassthroughLayerMeshANDROID, altrimenti potrebbe essere restituito XR_ERROR_MESH_DATA_LIMIT_EXCEEDED_ANDROID per indicare che i dati del mesh superano il limite supportato.
Utilizzo valido (implicito)
- L'estensione
XR_ANDROID_composition_layer_passthrough_meshdeve essere attivata prima di utilizzare XrSystemPassthroughLayerPropertiesANDROID typedeve essereXR_TYPE_SYSTEM_PASSTHROUGH_LAYER_PROPERTIES_ANDROIDnextdeve essereNULLo un puntatore valido alla struttura successiva in una catena di strutture
Composizione livello passthrough
XrCompositionLayerPassthroughANDROID contiene le informazioni necessarie per eseguire il rendering di una texture passthrough su una mesh triangolare quando viene chiamata xrEndFrame. XrCompositionLayerPassthroughANDROID è un tipo di alias per la struttura di base XrCompositionLayerBaseHeader utilizzata in XrFrameEndInfo.
typedef struct XrCompositionLayerPassthroughANDROID {
XrStructureType type;
const void* next;
XrCompositionLayerFlags layerFlags;
XrSpace space;
XrPosef pose;
XrVector3f scale;
float opacity;
XrPassthroughLayerANDROID layer;
} XrCompositionLayerPassthroughANDROID;
Descrizioni dei membri
typeè il XrStructureType di questa struttura.nextèNULLo un puntatore alla struttura successiva in una catena di strutture. Queste strutture non sono definite in OpenXR di base o in questa estensione.layerFlagsè una maschera di bit di XrCompositionLayerFlags che descrive i flag da applicare al livello.spaceè lo spazio Xr in cui ilposedella mesh del livello viene valutato nel tempo.poseè unXrPosefche definisce la posizione e l'orientamento della maglia del livello nel sistema di riferimento delspace.scaleè unXrVector3fche definisce la scala della mesh del livello.opacityè unfloatche definisce l'opacità della texture di translucenza nell'intervallo [0, 1].layerè l'XrPassthroughLayerANDROID creato in precedenza da xrCreatePassthroughLayerANDROID.
L'applicazione può creare una struttura XrCompositionLayerPassthroughANDROID con il layer creato e i mesh corrispondenti forniti da XrPassthroughLayerMeshANDROID.
Un puntatore a XrCompositionLayerPassthroughANDROID può essere inviato in xrEndFrame come puntatore alla struttura di base XrCompositionLayerBaseHeader, nell'ordine del livello scelto, per richiedere al runtime di comporre un livello passthrough nell'output del frame finale.
Utilizzo valido (implicito)
- L'estensione
XR_ANDROID_composition_layer_passthrough_meshdeve essere attivata prima di utilizzare XrCompositionLayerPassthroughANDROID typedeve essereXR_TYPE_COMPOSITION_LAYER_PASSTHROUGH_ANDROIDnextdeve essereNULLo un puntatore valido alla struttura successiva in una catena di strutturelayerFlagsdeve essere0o una combinazione valida di valori XrCompositionLayerFlagBitsspacedeve essere un handle XrSpace validolayerdeve essere un handle XrPassthroughLayerANDROID valido- Sia
layerchespacedevono essere stati creati, allocati o recuperati dalla stessa XrSession
Creare un handle del livello passthrough
Il handle XrPassthroughLayerANDROID rappresenta un livello passthrough che definisce il comportamento di XrCompositionLayerPassthroughANDROID.
XR_DEFINE_HANDLE(XrPassthroughLayerANDROID)
Un'applicazione può creare un handle XrPassthroughLayerANDROID chiamando xrCreatePassthroughLayerANDROID. L'handle XrPassthroughLayerANDROID restituito può essere utilizzato successivamente nelle chiamate API.
XrResult xrCreatePassthroughLayerANDROID(
XrSession session,
const XrPassthroughLayerCreateInfoANDROID* createInfo,
XrPassthroughLayerANDROID* layer);
Descrizioni dei parametri
sessionè un'XrSession per la quale verrà creato il livello di passthrough.createInfoè un puntatore a una struttura XrPassthroughLayerCreateInfoANDROID che specifica i parametri iniziali del livello di passthrough. Questo campo può anche essere collegato a una struttura XrPassthroughLayerMeshANDROID per impostare contemporaneamente la mesh.layerè un puntatore a un handle in cui viene restituito il XrPassthroughLayerANDROID creato.
L'applicazione deve specificare il numero di indici del mesh passthrough in
XrPassthroughLayerCreateInfoANDROID::vertexCapacity e
XrPassthroughLayerCreateInfoANDROID::indexCapacity inferiore o uguale ai
valori massimi restituiti da
XrSystemPassthroughLayerPropertiesANDROID::maxMeshIndexCount e
XrSystemPassthroughLayerPropertiesANDROID::maxMeshVertexCount quando viene chiamata
xrGetSystemProperties. xrCreatePassthroughLayerANDROID restituirà un
errore XR_ERROR_MESH_DATA_LIMIT_EXCEEDED_ANDROID se il conteggio degli indici del mesh
definito dacreateInfo è maggiore dei valori massimi.
L'handle XrPassthroughLayerANDROID deve essere eventualmente liberato utilizzando la funzione
xrDestroyPassthroughLayerANDROID.
Utilizzo valido (implicito)
- L'estensione
XR_ANDROID_composition_layer_passthrough_meshdeve essere attivata prima di chiamare xrCreatePassthroughLayerANDROID sessiondeve essere un handle XrSession validocreateInfodeve essere un puntatore a una struttura XrPassthroughLayerCreateInfoANDROID validalayerdeve essere un puntatore a un handle XrPassthroughLayerANDROID
Codici di ritorno
XR_SUCCESSXR_SESSION_LOSS_PENDING
XR_ERROR_FUNCTION_UNSUPPORTEDXR_ERROR_VALIDATION_FAILUREXR_ERROR_RUNTIME_FAILUREXR_ERROR_HANDLE_INVALIDXR_ERROR_INSTANCE_LOSTXR_ERROR_SESSION_LOSTXR_ERROR_OUT_OF_MEMORYXR_ERROR_LIMIT_REACHEDXR_ERROR_SIZE_INSUFFICIENTXR_ERROR_MESH_DATA_LIMIT_EXCEEDED_ANDROID
La struttura XrPassthroughLayerCreateInfoANDROID è definita come:
typedef struct XrPassthroughLayerCreateInfoANDROID {
XrStructureType type;
const void* next;
uint32_t vertexCapacity;
uint32_t indexCapacity;
} XrPassthroughLayerCreateInfoANDROID;
Descrizioni dei membri
typeè il XrStructureType di questa struttura.nextè NULL o un puntatore alla struttura successiva in una catena di strutture. XrPassthroughLayerMeshANDROID può essere fornito nella catena successiva per specificare un mesh iniziale per il livello di trasparenza quando viene chiamata la funzione xrCreatePassthroughLayerANDROID.vertexCapacityè unuint32_tche rappresenta la capacità massima del buffer di vertici per la mesh di questo livello oppure0se non specificato. Se specificato, XrPassthroughLayerMeshANDROID::vertexCount di qualsiasi mesh impostato per questo livello deve essere inferiore o uguale avertexCapacity.indexCapacityè unuint32_tche rappresenta la capacità massima del buffer di indice per la mesh di questo livello o0se non specificato. Se specificato, il valore XrPassthroughLayerMeshANDROID::indexCount di qualsiasi mesh impostato per questo livello deve essere inferiore o uguale aindexCapacity.
Utilizzo valido (implicito)
- L'estensione
XR_ANDROID_composition_layer_passthrough_meshdeve essere attivata prima di utilizzare XrPassthroughLayerCreateInfoANDROID typedeve essereXR_TYPE_PASSTHROUGH_LAYER_CREATE_INFO_ANDROIDnextdeve essereNULLo un puntatore valido alla struttura successiva in una catena di strutture. Vedi anche: XrPassthroughLayerMeshANDROID
Un'applicazione può utilizzare la funzione xrDestroyPassthroughLayerANDROID per liberare il livello passthrough e le risorse sottostanti.
XrResult xrDestroyPassthroughLayerANDROID(
XrPassthroughLayerANDROID layer);
Descrizioni dei parametri
layerè l'XrPassthroughLayerANDROID da distruggere.
Utilizzo valido (implicito)
- L'estensione
XR_ANDROID_composition_layer_passthrough_meshdeve essere attivata prima di chiamarexrDestroyPassthroughLayerANDROID layerdeve essere un handle XrPassthroughLayerANDROID valido
Coerenza di thread
- L'accesso a
layere a eventuali handle secondari deve essere sincronizzato esternamente
Codici di ritorno
XR_SUCCESS
XR_ERROR_FUNCTION_UNSUPPORTEDXR_ERROR_RUNTIME_FAILUREXR_ERROR_HANDLE_INVALID
Imposta il mesh del livello di passthrough
Un'applicazione può utilizzare la funzione xrSetPassthroughLayerMeshANDROID per impostare la mesh per un livello di trasmissione.
XrResult xrSetPassthroughLayerMeshANDROID(
XrPassthroughLayerANDROID layer,
const XrPassthroughLayerMeshANDROID* mesh);
Descrizioni dei parametri
layerè un handle XrPassthroughLayerANDROID in cui eseguire l'aggiornamento con ilmeshspecificato.meshè un puntatore a una struttura XrPassthroughLayerMeshANDROID che specifica le informazioni della mesh.
L'applicazione deve specificare il numero di indici del mesh di transizione in
XrPassthroughLayerMeshANDROID::vertexCount e
XrPassthroughLayerMeshANDROID::indexCount inferiore o uguale ai
valori massimi restituiti da
XrSystemPassthroughLayerPropertiesANDROID::maxMeshIndexCount e
XrSystemPassthroughLayerPropertiesANDROID::maxMeshVertexCount quando viene chiamata
xrGetSystemProperties. Se il numero di indici del mesh specificato da mesh in
xrSetPassthroughLayerMeshANDROID è maggiore dei valori massimi, verrà restituito
XR_ERROR_MESH_DATA_LIMIT_EXCEEDED_ANDROID.
Se la capacità del buffer del mesh è specificata da
XrPassthroughLayerCreateInfoANDROID::vertexCapacity e
XrPassthroughLayerCreateInfoANDROID::indexCapacity durante la creazione del
layer utilizzando xrCreatePassthroughLayerANDROID, verrà restituito l'errore
XR_ERROR_SIZE_INSUFFICIENT su
xrSetPassthroughLayerMeshANDROID se
il numero di indici del mesh definiti da mesh è maggiore della capacità.
Utilizzo valido (implicito)
- L'estensione
XR_ANDROID_composition_layer_passthrough_meshdeve essere attivata prima di chiamare xrSetPassthroughLayerMeshANDROID layerdeve essere un handle XrPassthroughLayerANDROID validomeshdeve essere un puntatore a una struttura XrPassthroughLayerMeshANDROID valida
Codici di ritorno
XR_SUCCESSXR_SESSION_LOSS_PENDING
XR_ERROR_FUNCTION_UNSUPPORTEDXR_ERROR_VALIDATION_FAILUREXR_ERROR_RUNTIME_FAILUREXR_ERROR_HANDLE_INVALIDXR_ERROR_INSTANCE_LOSTXR_ERROR_SESSION_LOSTXR_ERROR_OUT_OF_MEMORYXR_ERROR_LIMIT_REACHEDXR_ERROR_SIZE_INSUFFICIENTXR_ERROR_MESH_DATA_LIMIT_EXCEEDED_ANDROID
La struttura XrPassthroughLayerMeshANDROID è definita come:
typedef struct XrPassthroughLayerMeshANDROID {
XrStructureType type;
const void* next;
XrWindingOrderANDROID windingOrder;
uint32_t vertexCount;
const XrVector3f* vertices;
uint32_t indexCount;
const uint16_t* indices;
} XrPassthroughLayerMeshANDROID;
Descrizioni dei membri
typeè il XrStructureType di questa struttura.nextèNULLo un puntatore alla struttura successiva in una catena di strutture.windingOrderè l'attributo XrWindingOrderANDROID dei triangoli della mesh, che verrà utilizzato per il culling della faccia posteriore durante il rendering della mesh.vertexCountè unuint32_tche rappresenta il numero di vertici nel mesh. Quando viene specificato XrPassthroughLayerCreateInfoANDROID::vertexCapacity,vertexCountdeve essere inferiore o uguale avertexCapacity.verticesè un puntatore a un array diXrVector3fche contiene le posizioni dei vertici della mesh triangolare.
indexCountè unuint32_tche rappresenta il numero di indici nel mesh di triangoli. Gli ultimiindexCount % 3indici, se presenti, non verranno disegnati. Quando viene specificato XrPassthroughLayerCreateInfoANDROID::indexCapacity,indexCountdeve essere inferiore o uguale aindexCapacity.indicesè un puntatore a un array diuint16_tche contiene gli indici della mesh triangolare.
Utilizzo valido (implicito)
- L'estensione
XR_ANDROID_composition_layer_passthrough_meshdeve essere attivata prima di utilizzare XrPassthroughLayerMeshANDROID typedeve essereXR_TYPE_PASSTHROUGH_LAYER_MESH_ANDROIDnextdeve essereNULLo un puntatore valido alla struttura successiva in una catena di strutturewindingOrderdeve essere un valore XrWindingOrderANDROID valido- Se
vertexCountnon è0, verticesdeve essere un puntatore a un array di strutturevertexCountXrVector3f - Se
indexCountnon è0, indicesdeve essere un puntatore a un array di valoriindexCount uint16_t
L'enumerazione XrWindingOrderANDROID identifica l'ordine di orientamento dei triangoli di un mesh, utilizzato dal runtime per il culling della faccia posteriore durante il rendering del mesh del livello di passaggio.
typedef enum XrWindingOrderANDROID {
XR_WINDING_ORDER_UNKNOWN_ANDROID = 0,
XR_WINDING_ORDER_CW_ANDROID = 1,
XR_WINDING_ORDER_CCW_ANDROID = 2
} XrWindingOrderANDROID;
Descrizioni degli enumeranti
XR_WINDING_ORDER_UNKNOWN_ANDROID— L'ordine di chiusura dei triangoli della maglia non è conosciuto.XR_WINDING_ORDER_CW_ANDROID— L'ordine di orientamento dei triangoli della mesh è in senso orario.XR_WINDING_ORDER_CCW_ANDROID— L'ordine di orientamento dei triangoli della maglia è antiorario.
Codice di esempio per la composizione del livello passthrough
Il seguente codice di esempio mostra come creare un livello passthrough e usarlo nel compositing.
XrInstance instance; // previously initialized
XrSystemId systemId; // previously initialized
XrSession session; // previously initialized
XrSpace space; // previously initialized
// The function pointers are previously initialized using xrGetInstanceProcAddr.
PFN_xrCreatePassthroughLayerANDROID xrCreatePassthroughLayerANDROID; // previously initialized
PFN_xrDestroyPassthroughLayerANDROID xrDestroyPassthroughLayerANDROID; // previously initialized
PFN_xrSetPassthroughLayerMeshANDROID xrSetPassthroughLayerMeshANDROID; // previously initialized
// Inspect passthrough mesh system properties
XrSystemPassthroughLayerPropertiesANDROID passthroughLayerSystemProperties{
XR_TYPE_SYSTEM_PASSTHROUGH_LAYER_PROPERTIES_ANDROID};
XrSystemProperties systemProperties{
XR_TYPE_SYSTEM_PROPERTIES, &passthroughLayerSystemProperties};
CHK_XR(xrGetSystemProperties(instance, systemId, &systemProperties));
if (!passthroughLayerSystemProperties.supportsPassthroughLayer) {
// the system does not support composite layer passthrough mesh.
return;
}
// The initial mesh for the layer.
XrPassthroughLayerMeshANDROID mesh = {
.type = XR_TYPE_PASSTHROUGH_LAYER_MESH_ANDROID,
.windingOrder = XR_WINDING_ORDER_CW_ANDROID,
.vertexCount = 4,
.vertices = {
{ 0, 0, 0 }, { 0, 1, 0 }, { 1, 1, 0 }, { 1, 0, 0 }
},
.indexCount = 6,
.indices = {
0, 1, 2,
0, 2, 3
},
};
// Create the layer. Layers are expected to persist across frames.
XrPassthroughLayerCreateInfoANDROID create_info = {
.type = XR_TYPE_PASSTHROUGH_LAYER_CREATE_INFO_ANDROID,
.next = &mesh,
.vertexCapacity = 0,
.indexCapacity = 0,
};
XrPassthroughLayerANDROID layer;
CHK_XR(xrCreatePassthroughLayerANDROID(session, &create_info, &layer));
// Create a composition layer. Composition layers are submitted per frame.
XrCompositionLayerPassthroughANDROID passthrough_layer = {
.type = XR_TYPE_COMPOSITION_LAYER_PASSTHROUGH_ANDROID,
.next = nullptr,
.layerFlags = 0,
.space = space,
.pose = {
.orientation = { 0.0f, 0.0f, 0.0f, 1.0f }
.position = { 0.0f, 0.0f, 0.0f }
},
.scale = { 1.0f, 1.0f, 1.0f },
.opacity = 1.0f,
.layer = layer
};
while (1) {
// ...
// For every frame in frame loop
// ...
// Submit composition layer in xrEndFrame.
std::vector<XrCompositionLayerBaseHeader*> layers = {
...,
&passthrough_layer,
...,
};
XrFrameEndInfo end_frame_info = { XR_TYPE_FRAME_END_INFO, nullptr };
end_frame_info.layerCount = (uint32_t)layers.size();
end_frame_info.layers = layers.data();
CHK_XR(xrEndFrame(session, &end_frame_info));
// Update the layer. Results can be seen the next time a passthrough composition
// layer is submitted.
mesh.indexCount = 9;
const uint16_t new_index_buffer[] = {
0, 1, 2,
0, 2, 3,
0, 1, 2
};
mesh.indexBuffer = &new_index_buffer[0];
CHK_XR(xrSetPassthroughLayerMeshANDROID(&layer, &mesh));
// ...
// Finish frame loop
// ...
}
// Clean up.
CHK_XR(xrDestroyPassthroughLayerANDROID(layer));
Nuovi tipi di oggetti
Nuove costanti enum
L'enumerazione XrObjectType è estesa con:
XR_OBJECT_TYPE_PASSTHROUGH_LAYER_ANDROID
L'enumerazione XrStructureType è stata estesa con:
XR_TYPE_PASSTHROUGH_LAYER_CREATE_INFO_ANDROIDXR_TYPE_PASSTHROUGH_LAYER_MESH_ANDROIDXR_TYPE_COMPOSITION_LAYER_PASSTHROUGH_ANDROIDXR_TYPE_SYSTEM_PASSTHROUGH_LAYER_PROPERTIES_ANDROID
L'enumerazione XrResult è stata estesa con:
XR_ERROR_MESH_DATA_LIMIT_EXCEEDED_ANDROID
Nuovi enum
Nuove strutture
- XrPassthroughLayerCreateInfoANDROID
- XrPassthroughLayerMeshANDROID
- XrCompositionLayerPassthroughANDROID
- XrSystemPassthroughLayerPropertiesANDROID
Nuove funzioni
- xrCreatePassthroughLayerANDROID
xrDestroyPassthroughLayerANDROID- xrSetPassthroughLayerMeshANDROID
Problemi
Cronologia delle versioni
- Revisione 1, 11-09-2024 (Levana Chen)
- Descrizione iniziale dell'estensione
OpenXR™ e il logo OpenXR sono marchi di proprietà di The Khronos Group Inc. e sono registrati come marchi in Cina, nell'Unione Europea, in Giappone e nel Regno Unito.