update Unreal build script docs: add launch command
This commit is contained in:
@@ -23,7 +23,32 @@ MosisService provides a virtual phone that game engines can display and interact
|
|||||||
|
|
||||||
**Location**: `D:\Dev\Mosis\MosisUnreal\Plugins\MosisSDK\`
|
**Location**: `D:\Dev\Mosis\MosisUnreal\Plugins\MosisSDK\`
|
||||||
|
|
||||||
### Build Commands
|
### Build Script (Recommended)
|
||||||
|
|
||||||
|
Use the build script for one-command builds and deployment:
|
||||||
|
|
||||||
|
```batch
|
||||||
|
cd D:\Dev\Mosis\MosisUnreal
|
||||||
|
|
||||||
|
:: Build, install, and launch (default)
|
||||||
|
build-unreal.bat
|
||||||
|
|
||||||
|
:: Build APK only
|
||||||
|
build-unreal.bat build
|
||||||
|
|
||||||
|
:: Install to device only (requires prior build)
|
||||||
|
build-unreal.bat install
|
||||||
|
|
||||||
|
:: Launch app (starts MosisService first, then MosisUnreal)
|
||||||
|
build-unreal.bat launch
|
||||||
|
|
||||||
|
:: Clean build artifacts
|
||||||
|
build-unreal.bat clean
|
||||||
|
```
|
||||||
|
|
||||||
|
The script auto-detects connected Android devices, handles APK and OBB installation, and properly sequences app launches (MosisService must start before MosisUnreal).
|
||||||
|
|
||||||
|
### Manual Build Commands
|
||||||
|
|
||||||
```batch
|
```batch
|
||||||
:: Windows Editor Build
|
:: Windows Editor Build
|
||||||
@@ -272,15 +297,50 @@ adb logcat -s MosisSDK MosisTest RMLUI Vulkan
|
|||||||
|
|
||||||
Both game engines use Vulkan to import AHardwareBuffer from MosisService.
|
Both game engines use Vulkan to import AHardwareBuffer from MosisService.
|
||||||
|
|
||||||
|
### UE5 Implementation
|
||||||
|
|
||||||
|
MosisUnreal uses UE5's built-in Vulkan RHI API for hardware buffer import:
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
#include "IVulkanDynamicRHI.h"
|
||||||
|
|
||||||
|
// Import AHardwareBuffer as Vulkan texture (zero-copy)
|
||||||
|
IVulkanDynamicRHI* VulkanRHI = GetIVulkanDynamicRHI();
|
||||||
|
FTextureRHIRef ImportedTexture = VulkanRHI->RHICreateTexture2DFromAndroidHardwareBuffer(Buffer);
|
||||||
|
|
||||||
|
// GPU-to-GPU copy to destination texture each frame
|
||||||
|
ENQUEUE_RENDER_COMMAND(CopyMosisTexture)(
|
||||||
|
[SrcTexture, DstTexture, Width, Height](FRHICommandListImmediate& RHICmdList)
|
||||||
|
{
|
||||||
|
RHICmdList.Transition(FRHITransitionInfo(SrcTexture, ERHIAccess::Unknown, ERHIAccess::CopySrc));
|
||||||
|
RHICmdList.Transition(FRHITransitionInfo(DstTexture, ERHIAccess::Unknown, ERHIAccess::CopyDest));
|
||||||
|
|
||||||
|
FRHICopyTextureInfo CopyInfo;
|
||||||
|
CopyInfo.Size = FIntVector(Width, Height, 1);
|
||||||
|
RHICmdList.CopyTexture(SrcTexture, DstTexture, CopyInfo);
|
||||||
|
|
||||||
|
RHICmdList.Transition(FRHITransitionInfo(DstTexture, ERHIAccess::CopyDest, ERHIAccess::SRVMask));
|
||||||
|
}
|
||||||
|
);
|
||||||
|
```
|
||||||
|
|
||||||
|
**Key files:**
|
||||||
|
- `MosisPhoneTexture.cpp` - Vulkan import and GPU copy
|
||||||
|
- `MosisPhoneComponent.cpp` - Frame update coordination
|
||||||
|
|
||||||
### Required Vulkan Extensions
|
### Required Vulkan Extensions
|
||||||
|
|
||||||
|
UE5's VulkanRHI enables these automatically on Android:
|
||||||
|
|
||||||
```
|
```
|
||||||
VK_ANDROID_external_memory_android_hardware_buffer
|
VK_ANDROID_external_memory_android_hardware_buffer
|
||||||
VK_KHR_external_memory
|
VK_KHR_external_memory
|
||||||
VK_KHR_dedicated_allocation
|
VK_KHR_dedicated_allocation
|
||||||
```
|
```
|
||||||
|
|
||||||
### Import Pattern
|
### Raw Vulkan Import Pattern (Reference)
|
||||||
|
|
||||||
|
For custom implementations outside UE5:
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
// 1. Query buffer properties
|
// 1. Query buffer properties
|
||||||
@@ -299,9 +359,6 @@ VkExternalMemoryImageCreateInfo extInfo = {
|
|||||||
.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID
|
.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID
|
||||||
};
|
};
|
||||||
|
|
||||||
AHardwareBuffer_Desc desc;
|
|
||||||
AHardwareBuffer_describe(buffer, &desc);
|
|
||||||
|
|
||||||
VkImageCreateInfo imageInfo = {
|
VkImageCreateInfo imageInfo = {
|
||||||
.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,
|
.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,
|
||||||
.pNext = &extInfo,
|
.pNext = &extInfo,
|
||||||
@@ -339,10 +396,6 @@ vkAllocateMemory(device, &allocInfo, nullptr, &memory);
|
|||||||
vkBindImageMemory(device, image, memory, 0);
|
vkBindImageMemory(device, image, memory, 0);
|
||||||
```
|
```
|
||||||
|
|
||||||
### Synchronization
|
|
||||||
|
|
||||||
Currently using CPU synchronization (`vkQueueWaitIdle` / `glFinish`). Future improvement: use Vulkan semaphores for GPU-GPU sync.
|
|
||||||
|
|
||||||
### Double Buffering
|
### Double Buffering
|
||||||
|
|
||||||
The imported image is copied to a local texture each frame to prevent data races with MosisService rendering.
|
The imported image is copied to a local texture each frame via GPU copy to prevent data races with MosisService rendering. This is a fast GPU-to-GPU blit operation.
|
||||||
|
|||||||
Reference in New Issue
Block a user