successfully creating D3D texture with D3D11_RESOURCE_MISC_SHARED_NTHANDLE;

successfully allocating with VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT

working copying vulkan texture

successfully passing D3D texture back to Flutter

chore: Dart/Windows sample project: remove unnnecessary InvalidateRect from update()

chore: Dart/Windows sample project: add generated bindings

successfully blitting from Vulkan swapchain to D3D texture

working Vulkan texture integration with Flutter

refactor to allow disposal of resources in destructors

handle destroyTexture correctly

correctly implement surface resizing/destruction

move Windows engine to Vulkan backend and flush after creating swapchain

add vulkan + vkshaders to Windows libs

update materials with Vulkan

move Vulkan implementation to thermion_Dart

remove extras folder

thermion_flutter plugin updates

update build hook to copy .lib file to output directory and use -vulkan lib zip file

thermion_flutter cleanup

reinstate stereoscopic on Windows

add dxgi and d3d11.lib to windows header pragma

update cli_windows sample project

copy filament/vulkan headers to output directory. This was originally added to facilitate linking on Windows (where thermion_flutter_plugin.cpp needs the Vulkan-related headers), but this doesn't actually solve the problem because there's no way that I've found to get the directory structure correct in the Dart native_assets build directory unless you explicitly address each inidivual file. The current approach is therefore to just keep a permanent copy of the headers in the thermion_filament directory (meaning these will need to be updated manually if the Filament version changes). However, I decided to keep the changes to build.dart because it doesn't have much negative impact and may be helpful in future.

disable stereoscopic on Windows and disable handle use after free checks

use filament headers for thermion_flutter

throw Exception for MSAA on Windows (note that passing msaa:true for setAntiAliasing doesn't actually set MSAA on other platforms, but at least it won't cause the engine to crash)

change header include path for Windows/Vulkan

change header include path for Windows/Vulkan

add filament/vulkan headers for flutter (Windows)

ensure destroyTexture platform methods accept an integer rather than a list

handle Android/Windows swapchain creation separately
This commit is contained in:
Nick Fisher
2024-11-05 10:17:27 +08:00
parent b59cadc061
commit 436873a455
343 changed files with 135936 additions and 2449 deletions

View File

@@ -16,13 +16,10 @@ import 'package:thermion_flutter_platform_interface/thermion_flutter_window.dart
/// Flutter platform channels to create a rendering context,
/// resource loaders, and surface/render target(s).
///
class ThermionFlutterMethodChannelPlatform
extends ThermionFlutterPlatform {
class ThermionFlutterMethodChannelPlatform extends ThermionFlutterPlatform {
final channel = const MethodChannel("dev.thermion.flutter/event");
final _logger = Logger("ThermionFlutterMethodChannelPlatform");
static SwapChain? _swapChain;
ThermionFlutterMethodChannelPlatform._();
@@ -72,21 +69,22 @@ class ThermionFlutterMethodChannelPlatform
this.viewer = null;
});
if (_swapChain != null) {
if (_swapChain != null) {
throw Exception("Only a single swapchain can be created");
}
// this implementation renders directly into a texture/render target
// we still need to create a (headless) swapchain, but the actual dimensions
// don't matter
if (Platform.isMacOS || Platform.isIOS || Platform.isWindows) {
if (Platform.isMacOS || Platform.isIOS) {
_swapChain = await viewer!.createHeadlessSwapChain(1, 1);
}
return viewer!;
}
Future<ThermionFlutterTexture?> createTexture(int width, int height) async {
Future<ThermionFlutterTexture?> createTexture(
t.View view, int width, int height) async {
var result =
await channel.invokeMethod("createTexture", [width, height, 0, 0]);
if (result == null || (result[0] == -1)) {
@@ -94,39 +92,69 @@ class ThermionFlutterMethodChannelPlatform
}
final flutterId = result[0] as int;
final hardwareId = result[1] as int;
var window = result[2] as int; // usually 0 for nullptr
var window = result[2] as int?; // usually 0 for nullptr
return ThermionFlutterTexture(flutterId:flutterId, hardwareId:hardwareId, height:height, width:width, window:window);
var texture = ThermionFlutterTexture(
flutterId: flutterId,
hardwareId: hardwareId,
height: height,
width: width,
window: window ?? 0);
if (Platform.isWindows) {
if (_swapChain != null) {
await view!.setRenderable(false, _swapChain!);
await viewer!.destroySwapChain(_swapChain!);
}
_swapChain = await viewer!
.createHeadlessSwapChain(texture.width, texture.height);
} else if(Platform.isAndroid) {
if (_swapChain != null) {
await view!.setRenderable(false, _swapChain!);
await viewer!.destroySwapChain(_swapChain!);
}
_swapChain = await viewer!
.createSwapChain(texture.window);
} else {
var renderTarget = await viewer!.createRenderTarget(
texture.width, texture.height, texture.hardwareId);
await view.setRenderTarget(renderTarget!);
}
await view.setRenderable(true, _swapChain!);
return texture;
}
@override
Future bind(view, ThermionFlutterTexture texture) {
// TODO: implement bind
throw UnimplementedError();
}
@override
Future<ThermionFlutterWindow> createWindow(int width, int height, int offsetLeft, int offsetTop) {
Future<ThermionFlutterWindow> createWindow(
int width, int height, int offsetLeft, int offsetTop) {
// TODO: implement createWindow
throw UnimplementedError();
}
@override
Future destroyTexture(ThermionFlutterTexture texture) {
// TODO: implement destroyTexture
throw UnimplementedError();
Future destroyTexture(ThermionFlutterTexture texture) async {
await channel.invokeMethod("destroyTexture", texture.flutterId);
}
@override
Future markTextureFrameAvailable(ThermionFlutterTexture texture) async {
await channel.invokeMethod("markTextureFrameAvailable", texture.flutterId);
await channel.invokeMethod("markTextureFrameAvailable", texture.flutterId);
}
@override
Future<ThermionFlutterTexture> resizeTexture(ThermionFlutterTexture texture, int width, int height) async {
return texture;
Future<ThermionFlutterTexture> resizeTexture(ThermionFlutterTexture texture,
t.View view, int width, int height) async {
var newTexture = await createTexture(view, width, height);
if (newTexture == null) {
throw Exception();
}
await destroyTexture(texture);
return newTexture;
}
}