fix phone texture rendering using UTexture2DDynamic

This commit is contained in:
2026-01-17 18:20:08 +01:00
parent 554a946e60
commit dc1bd14ff0
7 changed files with 155 additions and 319 deletions

View File

@@ -16,17 +16,17 @@ The MosisSDK plugin connects to the MosisService Android application via AIDL (A
│ Unreal Engine Game │
│ │
│ ┌─────────────────┐ ┌──────────────────────────────────────────┐ │
│ │ AMosisPhoneActor│ │ UMosisPhoneTexture │ │
│ │ (Plane Mesh) │ │ │ │
│ │ (Material) │ │ │ │
│ └────────┬────────┘ │ ┌────────────────────────────────────┐ │ │
│ │ │ FMosisPhoneTextureResource │ │
│ ▼ │ │ │
│ ┌─────────────────────┐ │ENQUEUE_RENDER_CMD │ │ │
│ │ UMosisPhoneComponent│──┼──► IVulkanDynamicRHI:: │ │
│ │ (Touch Input) │ │ RHICreateTexture2DFromAndroid │ │ │
│ │ (Callbacks) │ │ HardwareBuffer() │ │
│ └──────────┬──────────┘ │ └────────────────────────────────────┘ │ │
│ │ AMosisPhoneActor│ │ UMosisPhoneTexture │ │
│ │ (Plane Mesh) │ │ (extends UTexture2DDynamic) │ │
│ │ (Material) │ │ │ │
│ └────────┬────────┘ │ ▼ CPU lock/copy │ │
│ │ │ AHardwareBuffer_lock() │ │
│ ▼ │ │ │ │
│ ┌─────────────────────┐ │ ▼ RHIUpdateTexture2D │ │
│ │ UMosisPhoneComponent│──┼──► FTexture2DDynamicResource │ │
│ │ (Touch Input) │ │ │ │
│ │ (Callbacks) │ │ │ │
│ └──────────┬──────────┘ │ UMaterialInstanceDynamic │ │
│ │ └──────────────────────────────────────────┘ │
│ ▼ │
│ ┌──────────────────────────────────────────────────────────────────┐ │
@@ -87,8 +87,7 @@ Plugins/MosisSDK/
│ └── Private/
│ ├── MosisSDK.cpp # Module + JNI callbacks
│ ├── MosisClient.h/cpp # AIDL client implementation
│ ├── MosisPhoneTexture.h/cpp # UTexture for phone screen
│ ├── MosisPhoneTextureResource.h/cpp # Render thread resource
│ ├── MosisPhoneTexture.h/cpp # UTexture2DDynamic subclass for phone screen
│ ├── MosisPhoneComponent.cpp
│ ├── MosisPhoneActor.cpp
│ └── Android/
@@ -364,6 +363,12 @@ HandTrackingVersion=V2
## Version History
- **v1.2** - UTexture2DDynamic integration
- Switched `UMosisPhoneTexture` to extend `UTexture2DDynamic` for proper material system integration
- Removed custom `FMosisPhoneTextureResource` - using UE5's built-in `FTexture2DDynamicResource`
- CPU-based texture upload via `AHardwareBuffer_lock()` and `RHIUpdateTexture2D()`
- Fixed stride conversion (AHardwareBuffer stride is in pixels, RHI expects bytes)
- **v1.1** - UE5 RHI texture integration
- New `UMosisPhoneTexture` using UE5's `IVulkanDynamicRHI::RHICreateTexture2DFromAndroidHardwareBuffer()`
- `FMosisPhoneTextureResource` for render thread HardwareBuffer import