이 인터페이스를 사용하면 그래픽스 기기가 생성되기 전에 설정 작업을 수행할 수 있습니다. 일반적인 사용 사례에는 멀티 GPU 시나리오에서 특정 GPU를 선택하고, 그래픽스 확장을 활성화하고, 버퍼 생성을 수정하는 작업이 포함됩니다.
공급자는 그래픽스 기기가 생성되기 전에 네이티브 심볼 XRSDKPreInit
(런타임 초기화의 초기에 호출됨)를 익스포트할 수 있습니다. 초기 초기화 중에 필요할 수 있는 정보를 엔진에 제공하기 위해 관련 엔트리 포인트로 UnityXRPreInitProvider
구조를 채워야 합니다. 공급자가 초기화할 수 있기 전에 그래픽스 기기가 생성되기 때문에 일부 공급자의 경우 이러한 작업이 필요합니다.
Unity 프로젝트 빌드 프로세스는 엔진 시작 시 XRSDKPreInit()
를 호출하기 위해 공급자 라이브러리의 이름을 필요로 합니다. 이렇게 하려면 XRLoader
에 IXRLoaderPreInit.GetPreInitLibraryName
인터페이스를 구현하십시오.
public string GetPreInitLibraryName(BuildTarget buildTarget, BuildTargetGroup buildTargetGroup)
{
return "XRSDKMyProviderLibraryName";
}
Unity를 시작하면 위의 코드를 실행하여 라이브러리를 로드합니다. 그런 다음에는 해당 라이브러리를 열고 XRSDKPreInit
익스포트를 찾아 호출합니다. 이 시점에서 XRSDKPreInit
는 UnityXRPreInitProvider
를 등록해야 합니다.
다음은 초기 엔진 초기화에 사용할 수 있는 모든 콜백을 등록하는 간단한 예제입니다.
XRSDKPreInit(IUnityInterfaces * interfaces)
{
IUnityXRPreInit* preInit = (IUnityXRPreInit*)interfaces->GetInterface(GetUnityInterfaceGUID<IUnityXRPreInit>());
UnityXRPreInitProvider provider = { 0 };
provider.userData = nullptr;
provider.GetPreInitFlags = GetPreInitFlags;
provider.GetGraphicsAdapterId = GetGraphicsAdapterId;
provider.GetVulkanInstanceExtensions = GetVulkanInstanceExtensions;
provider.GetVulkanDeviceExtensions = GetVulkanDeviceExtensions;
preInit->RegisterPreInitProvider(&provider);
}
필요하지 않은 모든 콜백은 nullptr
로 설정하십시오.
GetPreInitFlags
는 플래그의 64비트 비트필드를 반환합니다. 현재 다음의 플래그가 표시됩니다.
kUnityXRPreInitFlagsEGLUsePBuffer
- EGL 플랫폼(Android, 스탠드얼론 Meta/Oculus 기기 등)에서는 Pbuffer를 사용하여 EGL을 초기화해야 합니다.kUnityXRPreInitFlagsEGLUseNoErrorContext
- EGL 플랫폼에서 EGL은 NO_ERROR 컨텍스트를 사용하여 초기화해야 합니다.공급자는 정의되지 않은 비트를 설정해서는 안 됩니다. 이러한 비트는 향후 확장에서 사용될 수 있습니다.
GetGraphicsAdapterId
는 Unity 런타임 그래픽스 기기가 그래픽스 API 초기화에 사용하는 그래픽스 어댑터를 설정합니다. 예를 들어 사용자가 사용자의 기본 디스플레이 기기가 아닌 다른 GPU에 헤드셋을 연결하는 경우 Unity는 보조 GPU를 명시적으로 타게팅하는 그래픽스 API를 초기화해야 할 수 있습니다.
GetVulkanDeviceExtensions
및 GetVulkanInstanceExtensions
는 공급자가 Unity에서 기기 및 인스턴스에 대한 특정 확장으로 Vulkan을 초기화해야 하는 경우에 사용됩니다. 또한 컴포지터 표면 공유에도 자주 사용됩니다. 둘 다 공백으로 구분된 확장 문자열을 반환합니다.
GetPreInitLibraryName
은 XRManager 프리팹의 첫 번째 XRLoader에서만 호출되므로, 리스트의 첫 번째 공급자만 런타임 시점에 PreInit 엔트리 포인트를 제공할 수 있습니다.Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.