View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0002312 | NoesisGUI | Unreal | public | 2022-03-22 23:14 | 2022-03-25 15:27 |
Reporter | vogelLightword | Assigned To | hcpizzi | ||
Priority | normal | Severity | crash | Reproducibility | always |
Status | resolved | Resolution | fixed | ||
Product Version | 3.1.4 | ||||
Target Version | 3.1.5 | Fixed in Version | 3.1.5 | ||
Summary | 0002312: Crash when using MPC-collections in a material | ||||
Description | Good evening, We have a Material-Parameter-Collection that manages the currently selected input device inside a Material. We want an instance of that material to be visible in our UI. From our Noesis frontend we implement a Material-Instance (MI) as a ShaderBrush. The master-material of that MI uses the mentioned MPC. If the MPC is connected whilst the MI is being used in a Noesis-View/xaml, the engine crashes. Breakpoint is attached, | ||||
Steps To Reproduce | 1: Bind a Noesis-Image (or in our case ImageBrush in an inline-Container) to a Material-Instance 1.1: The parent of the Material-Instance uses a Material-Parameter-Collection to give output 2: Implement the Noesis-View and thus try to show the Material-Instance 3: See a crash happening | ||||
Additional Information | Our noesis-sample-code: (M_InputButton_Inst is the mentioned Material-Instance, of which the parent uses a Material-Parameter-Collection). The currentID-binding is the current ID of the image to select (not directly related to the Material-Parameter-Collection, no problem/crash occurs whilst the MPC is disconnected) <TextBlock> <Run Text="{Binding Text1}"></Run> <InlineUIContainer> <Rectangle Width="32" Height="32"> <Rectangle.Fill> <ImageBrush> <noesis:Brush.Shader> <assets:M_InputButton_Inst KeyboardID="{Binding currentID}"/> </noesis:Brush.Shader> </ImageBrush> </Rectangle.Fill> </Rectangle> </InlineUIContainer> <Run Text="{Binding Text2}"></Run> </TextBlock> | ||||
Tags | crash, Materials, MPC, Unreal | ||||
Platform | Any | ||||
Changed mentions of Material-Instances-Dynamic to Material-Instances (since in our case we only use Material-Instances as Noesis can already modify its bindings at runtime, so no Dynamic instantiation is needed) | |
Hi, I think I fixed this correctly. Besides fixing the crash, now parameter overrides (using Set[Scalar|Vector]ParameterValue) seem to work correctly too. Could you give the attached patch a try to confirm it solves your problem? Thanks. 2312.patch (6,663 bytes)
Index: Classes/NoesisInstance.h =================================================================== --- Classes/NoesisInstance.h (revision 11259) +++ Classes/NoesisInstance.h (working copy) @@ -8,6 +8,9 @@ // Core includes #include "CoreMinimal.h" +// Launch includes +#include "Runtime/Launch/Resources/Version.h" + // CoreUObject includes #include "Blueprint/UserWidget.h" @@ -126,6 +129,7 @@ float Width; float Height; float CurrentTime; + FSceneInterface* Scene; FGameTime WorldTime; bool FlipYAxis; Index: Private/NoesisInstance.cpp =================================================================== --- Private/NoesisInstance.cpp (revision 11259) +++ Private/NoesisInstance.cpp (working copy) @@ -69,6 +69,7 @@ float Top; float Right; float Bottom; + FSceneInterface* Scene; FGameTime WorldTime; bool FlipYAxis; }; @@ -111,6 +112,7 @@ RHICmdList.SetViewport((int32)Left, (int32)Top, 0.0f, (int32)Right, (int32)Bottom, 1.0f); FNoesisRenderDevice* RenderDevice = FNoesisRenderDevice::Get(); RenderDevice->SetWorldTime(WorldTime); + RenderDevice->SetScene(Scene); RenderDevice->SetRHICmdList(&RHICmdList); RenderDevice->CreateView(Left, Top, Right, Bottom); Renderer->Render(FlipYAxis); @@ -266,7 +268,7 @@ } UNoesisInstance::UNoesisInstance(const FObjectInitializer& ObjectInitializer) - : Super(ObjectInitializer) + : Super(ObjectInitializer), Scene(nullptr) { Visibility = ESlateVisibility::Visible; } @@ -365,6 +367,7 @@ #else WorldTime = World->GetTime(); #endif + Scene = World->Scene; } else if (GWorld) { @@ -373,6 +376,7 @@ #else WorldTime = GWorld->GetTime(); #endif + Scene = GWorld->Scene; } } @@ -633,7 +637,7 @@ ENQUEUE_RENDER_COMMAND(FNoesisXamlThumbnailRendererDrawCommand) ( [Renderer, FlipYAxis = FlipYAxis, BackBuffer, - WorldTime = WorldTime](FRHICommandListImmediate& RHICmdList) + WorldTime = WorldTime, Scene = Scene](FRHICommandListImmediate& RHICmdList) { // Make sure dynamic material cached uniform expressions are up to date before doing any rendering FMaterialRenderProxy::UpdateDeferredCachedUniformExpressions(); @@ -640,6 +644,7 @@ FNoesisRenderDevice* RenderDevice = FNoesisRenderDevice::Get(); RenderDevice->SetWorldTime(WorldTime); + RenderDevice->SetScene(Scene); RenderDevice->SetRHICmdList(&RHICmdList); Renderer->UpdateRenderTree(); Renderer->RenderOffscreen(); @@ -696,7 +701,7 @@ ENQUEUE_RENDER_COMMAND(FNoesisInstance_DrawOffscreen) ( [Renderer, - WorldTime = WorldTime](FRHICommandListImmediate& RHICmdList) + WorldTime = WorldTime, Scene = Scene](FRHICommandListImmediate& RHICmdList) { // Make sure dynamic material cached uniform expressions are up to date before doing any rendering FMaterialRenderProxy::UpdateDeferredCachedUniformExpressions(); @@ -711,6 +716,7 @@ SCOPED_GPU_STAT(RHICmdList, NoesisDraw); FNoesisRenderDevice* RenderDevice = FNoesisRenderDevice::Get(); RenderDevice->SetWorldTime(WorldTime); + RenderDevice->SetScene(Scene); RenderDevice->SetRHICmdList(&RHICmdList); Renderer->RenderOffscreen(); RenderDevice->SetRHICmdList(nullptr); @@ -724,6 +730,7 @@ NoesisSlateElement->Top = MyClippingRect.Top; NoesisSlateElement->Right = MyClippingRect.Right; NoesisSlateElement->Bottom = MyClippingRect.Bottom; + NoesisSlateElement->Scene = Scene; NoesisSlateElement->WorldTime = WorldTime; NoesisSlateElement->FlipYAxis = FlipYAxis; FSlateDrawElement::MakeCustom(OutDrawElements, LayerId, NoesisSlateElement); Index: Private/Render/NoesisRenderDevice.cpp =================================================================== --- Private/Render/NoesisRenderDevice.cpp (revision 11271) +++ Private/Render/NoesisRenderDevice.cpp (working copy) @@ -283,7 +283,7 @@ }; FNoesisRenderDevice::FNoesisRenderDevice() - : VSConstantsHash(0), TextureSizeHash(0), PSConstantsHash(0), EffectsHash(0) + : VSConstantsHash(0), TextureSizeHash(0), PSConstantsHash(0), EffectsHash(0), ViewFamily(nullptr), View(nullptr) { FRHIResourceCreateInfo CreateInfo(TEXT("Noesis.VertexIndexBuffer")); DynamicVertexBuffer = RHICreateVertexBuffer(DYNAMIC_VB_SIZE, BUF_Volatile, CreateInfo); @@ -765,6 +765,11 @@ WorldTime = InWorldTime; } +void FNoesisRenderDevice::SetScene(FSceneInterface* InScene) +{ + Scene = InScene; +} + void FNoesisRenderDevice::CreateView(uint32 Left, uint32 Top, uint32 Right, uint32 Bottom) { ViewLeft = Left; @@ -788,7 +793,7 @@ FSceneViewFamily::ConstructionValues ViewFamilyConstruction ( nullptr, - nullptr, + Scene, FEngineShowFlags(ESFIM_Game) ); @@ -797,12 +802,10 @@ #else ViewFamilyConstruction.SetTime(WorldTime); #endif - /*.SetGammaCorrection(DisplayGamma) - .SetRealtimeUpdate(true)*/ - FSceneViewFamilyContext Family(ViewFamilyConstruction); + ViewFamily = new FSceneViewFamily(ViewFamilyConstruction); FSceneViewInitOptions ViewInitOptions; memset(&ViewInitOptions, 0, sizeof(ViewInitOptions)); - ViewInitOptions.ViewFamily = &Family; + ViewInitOptions.ViewFamily = ViewFamily; ViewInitOptions.SetViewRectangle(FIntRect(Left, Top, Right, Bottom)); ViewInitOptions.ViewOrigin = FVector::ZeroVector; ViewInitOptions.ViewRotationMatrix = FMatrix::Identity; @@ -871,8 +874,17 @@ void FNoesisRenderDevice::DestroyView() { - delete View; - View = nullptr; + if (View != nullptr) + { + delete View; + View = nullptr; + } + + if (ViewFamily != nullptr) + { + delete ViewFamily; + ViewFamily = nullptr; + } } static void SetTextureFormat(FNoesisTexture* Texture, EPixelFormat Format) Index: Private/Render/NoesisRenderDevice.h =================================================================== --- Private/Render/NoesisRenderDevice.h (revision 11259) +++ Private/Render/NoesisRenderDevice.h (working copy) @@ -53,7 +53,9 @@ public: FGameTime WorldTime; FRHICommandList* RHICmdList; + FSceneViewFamily* ViewFamily; FSceneView* View; + FSceneInterface* Scene; uint32 ViewLeft, ViewTop, ViewRight, ViewBottom; FVertexDeclarationRHIRef VertexDeclarations[Noesis::Shader::Count]; TShaderRef<FNoesisVSBase> VertexShaders[Noesis::Shader::Count]; @@ -75,6 +77,7 @@ void SetRHICmdList(class FRHICommandList* RHICmdList); void SetWorldTime(FGameTime InWorldTime); + void SetScene(FSceneInterface* InScene); void CreateView(uint32 Left, uint32 Top, uint32 Right, uint32 Bottom); void DestroyView(); |
|
Thanks a lot hcpizzi, that works just fine now! Also many thanks for the fast fix! | |
Glad it solved your issue. Marking as resolved. | |
Date Modified | Username | Field | Change |
---|---|---|---|
2022-03-22 23:14 | vogelLightword | New Issue | |
2022-03-22 23:14 | vogelLightword | Tag Attached: crash | |
2022-03-22 23:14 | vogelLightword | Tag Attached: Materials | |
2022-03-22 23:14 | vogelLightword | Tag Attached: MPC | |
2022-03-22 23:14 | vogelLightword | Tag Attached: Unreal | |
2022-03-22 23:14 | vogelLightword | File Added: image.png | |
2022-03-22 23:17 | vogelLightword | Additional Information Updated | |
2022-03-22 23:17 | vogelLightword | Note Added: 0007874 | |
2022-03-23 04:44 | jsantos | Assigned To | => hcpizzi |
2022-03-23 04:44 | jsantos | Status | new => assigned |
2022-03-23 04:44 | jsantos | Target Version | => 3.1.5 |
2022-03-23 09:27 | vogelLightword | Description Updated | |
2022-03-23 09:27 | vogelLightword | Steps to Reproduce Updated | |
2022-03-23 09:27 | vogelLightword | Additional Information Updated | |
2022-03-23 09:27 | vogelLightword | Note Added: 0007875 | |
2022-03-23 15:56 | hcpizzi | Status | assigned => confirmed |
2022-03-25 13:50 | hcpizzi | Note Added: 0007879 | |
2022-03-25 13:50 | hcpizzi | File Added: 2312.patch | |
2022-03-25 13:50 | hcpizzi | Status | confirmed => feedback |
2022-03-25 14:19 | vogelLightword | Note Added: 0007880 | |
2022-03-25 14:19 | vogelLightword | Status | feedback => assigned |
2022-03-25 15:27 | hcpizzi | Status | assigned => resolved |
2022-03-25 15:27 | hcpizzi | Resolution | open => fixed |
2022-03-25 15:27 | hcpizzi | Fixed in Version | => 3.1.5 |
2022-03-25 15:27 | hcpizzi | Note Added: 0007881 |