From 9efadda536338968267dba376efbfee1c197e404 Mon Sep 17 00:00:00 2001 From: PopcornFX Bot Date: Thu, 28 Sep 2023 12:24:02 +0200 Subject: [PATCH] PopcornFX Plugin v2.15.14 --- .github/workflows/draft-release.yml | 2 +- .../M_PK_Default_Mesh_AlphaBlend.uasset | 3 + Download_SDK_Desktop.bat | 2 +- Download_SDK_Mobile.bat | 2 +- PopcornFX.uplugin | 4 +- README.md | 4 +- .../Private/Assets/PopcornFXAssetDep.cpp | 1 + .../Assets/PopcornFXRendererMaterial.cpp | 4 ++ .../Attributes/PopcornFXAttributeSamplers.cpp | 3 + .../Private/GPUSim/PopcornFXGPUSim.cpp | 62 +++---------------- .../Private/GPUSim/PopcornFXGPUSim.h | 35 ++++------- .../Private/GPUSim/PopcornFXGPUSim_D3D11.cpp | 27 ++++---- .../Private/GPUSim/PopcornFXGPUSim_D3D11.h | 6 +- .../Private/GPUSim/PopcornFXGPUSim_D3D12.cpp | 36 +++++++++-- .../GPUSim/PopcornFXSortComputeShader.cpp | 3 +- .../Private/HUD/PopcornFXHUDProfiler.cpp | 1 + .../Internal/FileSystemController_UE.cpp | 10 +++ .../Private/Internal/ParticleScene.cpp | 7 +++ .../Private/Internal/ParticleScene.h | 2 + Source/PopcornFX/Private/Internal/Startup.cpp | 2 + .../Private/Platforms/PopcornFXPlatform.h | 6 ++ .../Platforms/PopcornFXPlatformCommon.cpp | 25 +++++++- Source/PopcornFX/Private/PopcornFXPlugin.cpp | 2 + .../Render/BatchDrawer_Billboard_CPU.cpp | 2 + .../Render/BatchDrawer_Billboard_GPU.cpp | 62 +++++++++++++++---- .../Render/BatchDrawer_Billboard_GPU.h | 34 +++++++++- .../Private/Render/BatchDrawer_Ribbon_CPU.cpp | 2 + .../Render/BatchDrawer_SkeletalMesh_CPU.cpp | 5 ++ .../Render/BatchDrawer_Triangle_CPU.cpp | 2 + .../PopcornFX/Private/Render/MaterialDesc.cpp | 4 ++ .../PopcornFX/Private/Render/MaterialDesc.h | 6 ++ .../Render/PopcornFXGPUVertexFactory.cpp | 5 ++ .../Render/PopcornFXMeshVertexFactory.cpp | 4 ++ .../PopcornFXSkeletalMeshVertexFactory.cpp | 4 ++ .../Private/Render/PopcornFXVertexFactory.cpp | 5 ++ ...PopcornFXVertexFactoryShaderParameters.cpp | 1 + .../Private/Render/RenderBatchManager.cpp | 5 ++ .../Private/World/PopcornFXSceneComponent.cpp | 2 + .../Public/PopcornFXVersionGenerated.h | 2 +- 39 files changed, 272 insertions(+), 122 deletions(-) create mode 100644 Content/Materials/M_PK_Default_Mesh_AlphaBlend.uasset diff --git a/.github/workflows/draft-release.yml b/.github/workflows/draft-release.yml index b69523a..77199de 100644 --- a/.github/workflows/draft-release.yml +++ b/.github/workflows/draft-release.yml @@ -25,6 +25,6 @@ jobs: with: draft: true name: "Unreal Engine Plugin: ${{ github.ref_name }}" - body: "PopcornFX Plugin v${{ github.ref_name }} for Unreal Engine\n + body: "PopcornFX Plugin ${{ github.ref_name }} for Unreal Engine\n\n You can download the PopcornFX Editor and find the full changelog here:\n https://wiki.popcornfx.com/index.php?title=PK-Editor_${{ env.MINOR_VERSION }}#Changelog_${{ env.VERSION }}" \ No newline at end of file diff --git a/Content/Materials/M_PK_Default_Mesh_AlphaBlend.uasset b/Content/Materials/M_PK_Default_Mesh_AlphaBlend.uasset new file mode 100644 index 0000000..0efa80f --- /dev/null +++ b/Content/Materials/M_PK_Default_Mesh_AlphaBlend.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2d9e9424bd336ee779c1c689b113855bf8348571d6e4b1ba05460ee1fa29bdda +size 100350 diff --git a/Download_SDK_Desktop.bat b/Download_SDK_Desktop.bat index ec5a039..fd01711 100644 --- a/Download_SDK_Desktop.bat +++ b/Download_SDK_Desktop.bat @@ -6,7 +6,7 @@ setlocal bitsadmin /reset bitsadmin /create third_party_download_desktop -bitsadmin /addfile third_party_download_desktop https://downloads.popcornfx.com/Plugins/UE4/UnrealEngine_PopcornFXPlugin_2.15.13_Win64_Linux64_Mac64.7z "%~dp0\_PopcornFX_Runtime_SDK_Desktop.7z" +bitsadmin /addfile third_party_download_desktop https://downloads.popcornfx.com/Plugins/UE4/UnrealEngine_PopcornFXPlugin_2.15.14_Win64_Linux64_Mac64.7z "%~dp0\_PopcornFX_Runtime_SDK_Desktop.7z" bitsadmin /setpriority third_party_download_desktop "FOREGROUND" bitsadmin /resume third_party_download_desktop diff --git a/Download_SDK_Mobile.bat b/Download_SDK_Mobile.bat index cf4450f..b843981 100644 --- a/Download_SDK_Mobile.bat +++ b/Download_SDK_Mobile.bat @@ -6,7 +6,7 @@ setlocal bitsadmin /reset bitsadmin /create third_party_download_mobile -bitsadmin /addfile third_party_download_mobile https://downloads.popcornfx.com/Plugins/UE4/UnrealEngine_PopcornFXPlugin_2.15.13_iOS_Android.7z "%~dp0\_PopcornFX_Runtime_SDK_Mobile.7z" +bitsadmin /addfile third_party_download_mobile https://downloads.popcornfx.com/Plugins/UE4/UnrealEngine_PopcornFXPlugin_2.15.14_iOS_Android.7z "%~dp0\_PopcornFX_Runtime_SDK_Mobile.7z" bitsadmin /setpriority third_party_download_mobile "FOREGROUND" bitsadmin /resume third_party_download_mobile diff --git a/PopcornFX.uplugin b/PopcornFX.uplugin index 662b66d..3cf9ec4 100644 --- a/PopcornFX.uplugin +++ b/PopcornFX.uplugin @@ -1,7 +1,7 @@ { "FileVersion": 3, - "Version": 21513, - "VersionName": "2.15.13", + "Version": 21514, + "VersionName": "2.15.14", "FriendlyName": "PopcornFX", "Description": "PopcornFX Realtime Particle Solution integration into Unreal Engine", "Category": "PopcornFX", diff --git a/README.md b/README.md index bc1c494..d4331be 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # Unreal Engine PopcornFX Plugin Integrates the **PopcornFX Runtime SDK** into **Unreal Engine 4** and **Unreal Engine 5** as a Plugin. -* **Version:** `v2.15.13` -* **Unreal Engine:** `4.27`, `5.0`, `5.1` and `5.2` +* **Version:** `v2.15.14` +* **Unreal Engine:** `4.27`, `5.0`, `5.1`, `5.2` and `5.3` * **Supported platforms:** `Windows`, `MacOS`, `Linux`, `iOS`, `Android`, `PS4`, `PS5`, `XboxOne`, `Xbox Series`, `Switch` [Contact-us](http://www.popcornfx.com/contact-us/) to request access to the plugin for consoles. diff --git a/Source/PopcornFX/Private/Assets/PopcornFXAssetDep.cpp b/Source/PopcornFX/Private/Assets/PopcornFXAssetDep.cpp index dfb533e..2ea2d04 100644 --- a/Source/PopcornFX/Private/Assets/PopcornFXAssetDep.cpp +++ b/Source/PopcornFX/Private/Assets/PopcornFXAssetDep.cpp @@ -12,6 +12,7 @@ #include "Assets/PopcornFXFont.h" #include "Assets/PopcornFXAnimTrack.h" #include "Assets/PopcornFXSimulationCache.h" +#include "AssetRegistry/AssetData.h" #include "Internal/FileSystemController_UE.h" diff --git a/Source/PopcornFX/Private/Assets/PopcornFXRendererMaterial.cpp b/Source/PopcornFX/Private/Assets/PopcornFXRendererMaterial.cpp index fc2dfd1..2d64073 100644 --- a/Source/PopcornFX/Private/Assets/PopcornFXRendererMaterial.cpp +++ b/Source/PopcornFX/Private/Assets/PopcornFXRendererMaterial.cpp @@ -15,6 +15,10 @@ #include "Engine/Texture2D.h" #include "Engine/StaticMesh.h" #include "Engine/SkeletalMesh.h" +#if (ENGINE_MAJOR_VERSION == 5) && (ENGINE_MINOR_VERSION >= 1) +# include "Engine/SkinnedAssetCommon.h" +#endif +#include "MaterialShared.h" #include "PopcornFXSDK.h" #include diff --git a/Source/PopcornFX/Private/Attributes/PopcornFXAttributeSamplers.cpp b/Source/PopcornFX/Private/Attributes/PopcornFXAttributeSamplers.cpp index ffa64ee..1e20f65 100644 --- a/Source/PopcornFX/Private/Attributes/PopcornFXAttributeSamplers.cpp +++ b/Source/PopcornFX/Private/Attributes/PopcornFXAttributeSamplers.cpp @@ -33,6 +33,9 @@ #include "VectorField/VectorFieldStatic.h" #include "Serialization/BulkData.h" #include "Curves/RichCurve.h" +#include "Engine/Texture.h" +#include "Engine/Texture2D.h" +#include "UObject/Package.h" #if WITH_EDITOR # include "Editor.h" diff --git a/Source/PopcornFX/Private/GPUSim/PopcornFXGPUSim.cpp b/Source/PopcornFX/Private/GPUSim/PopcornFXGPUSim.cpp index d377cf8..4631c4f 100644 --- a/Source/PopcornFX/Private/GPUSim/PopcornFXGPUSim.cpp +++ b/Source/PopcornFX/Private/GPUSim/PopcornFXGPUSim.cpp @@ -13,6 +13,13 @@ PK_STATIC_ASSERT(false); #endif +#if (ENGINE_MAJOR_VERSION == 5) && (ENGINE_MINOR_VERSION >= 2) +# include "DataDrivenShaderPlatformInfo.h" +# if (ENGINE_MINOR_VERSION >= 3) +# include "RHIStaticShaderPlatformNames.h" +# endif +#endif + #include #include @@ -88,59 +95,4 @@ bool StreamBufferByteOffset(const PopcornFX::CParticleStreamToRender_GPU &stream return _streamOffset.Valid(); } -//---------------------------------------------------------------------------- - -template -FShaderResourceViewRHIRef StreamBufferSRVToRHI(const PopcornFX::CParticleStreamToRender &stream_GPU, PopcornFX::CGuid streamId, PopcornFX::CGuid &streamOffset) -{ - PK_ASSERT(streamId.Valid()); - -#if (PK_GPU_D3D11 == 1) - if (g_PopcornFXRHIAPI == SUERenderContext::D3D11) - { - const PopcornFX::CParticleStreamToRender_D3D11 &stream = static_cast(stream_GPU); - - streamOffset = stream.StreamOffset(streamId); - return StreamBufferSRVToRHI(&stream.StreamBuffer(), stream.StreamSizeEst() * _Stride, _Stride/*, DXGI_FORMAT_UNKNOWN*/); - } -#endif // (PK_GPU_D3D11 == 1) -#if (PK_GPU_D3D12 == 1) - if (g_PopcornFXRHIAPI == SUERenderContext::D3D12) - { - const PopcornFX::CParticleStreamToRender_D3D12 &stream = static_cast(stream_GPU); - - streamOffset = stream.StreamOffset(streamId); - return StreamBufferSRVToRHI(&stream.StreamBuffer(), stream.StreamSizeEst() * _Stride); - } -#endif // (PK_GPU_D3D12 == 1) - PK_ASSERT_NOT_REACHED(); - return null; -} - -#define DEFINE_StreamBufferSRVToRHI(__type, __stride) \ - template FShaderResourceViewRHIRef StreamBufferSRVToRHI<__type, __stride>(const PopcornFX::CParticleStreamToRender &stream_GPU, PopcornFX::CGuid streamId, PopcornFX::CGuid &streamOffset) - -DEFINE_StreamBufferSRVToRHI(CFloat4, 16); -DEFINE_StreamBufferSRVToRHI(CFloat3, 12); -DEFINE_StreamBufferSRVToRHI(CFloat2, 8); -DEFINE_StreamBufferSRVToRHI(float, 4); -#undef DEFINE_StreamBufferSRVToRHI - -//---------------------------------------------------------------------------- -// -// D3D -// -//---------------------------------------------------------------------------- - -#if (PK_GPU_D3D11 == 1 || PK_GPU_D3D12 == 1) - -uint32 _PopcornFXD3DGetRefCount(IUnknown &res) -{ - uint32 count = res.AddRef(); - res.Release(); - return count - 1; -} - -#endif // (PK_GPU_D3D11 == 1 || PK_GPU_D3D12 == 1) - #endif // (PK_HAS_GPU != 0) diff --git a/Source/PopcornFX/Private/GPUSim/PopcornFXGPUSim.h b/Source/PopcornFX/Private/GPUSim/PopcornFXGPUSim.h index f96d511..a1f2265 100644 --- a/Source/PopcornFX/Private/GPUSim/PopcornFXGPUSim.h +++ b/Source/PopcornFX/Private/GPUSim/PopcornFXGPUSim.h @@ -14,7 +14,7 @@ #include "Render/RenderTypesPolicies.h" - //---------------------------------------------------------------------------- +//---------------------------------------------------------------------------- #if (ENGINE_MAJOR_VERSION == 5) typedef FRHIBuffer* FVBRHIParamRef; @@ -23,35 +23,26 @@ typedef FRHIVertexBuffer* FVBRHIParamRef; typedef FRHIIndexBuffer* FIBRHIParamRef; #endif - typedef FRHIComputeShader* FCSRHIParamRef; - typedef FRHIShaderResourceView* FSRVRHIParamRef; - typedef FRHIUnorderedAccessView* FUAVRHIParamRef; +typedef FRHIComputeShader* FCSRHIParamRef; +typedef FRHIShaderResourceView* FSRVRHIParamRef; +typedef FRHIUnorderedAccessView* FUAVRHIParamRef; #if (PK_HAS_GPU != 0) - FWD_PK_API_BEGIN - class CParticleStreamToRender; - class CParticleStreamToRender_GPU; - FWD_PK_API_END - - extern SUERenderContext::ERHIAPI g_PopcornFXRHIAPI; - - void SetupPopcornFXRHIAPI(uint32 API); +FWD_PK_API_BEGIN +class CParticleStreamToRender; +class CParticleStreamToRender_GPU; +FWD_PK_API_END - template - FShaderResourceViewRHIRef StreamBufferSRVToRHI(const PopcornFX::CParticleStreamToRender &stream_GPU, PopcornFX::CGuid streamId, PopcornFX::CGuid &offset); +extern SUERenderContext::ERHIAPI g_PopcornFXRHIAPI; - bool StreamBufferByteOffset(const PopcornFX::CParticleStreamToRender_GPU &stream_GPU, PopcornFX::CGuid streamId, u32 &streamOffset); +void SetupPopcornFXRHIAPI(uint32 API); - //---------------------------------------------------------------------------- +bool StreamBufferByteOffset(const PopcornFX::CParticleStreamToRender_GPU &stream_GPU, PopcornFX::CGuid streamId, u32 &streamOffset); -# if (PK_GPU_D3D11 == 1) - uint32 _PopcornFXD3DGetRefCount(IUnknown &res); -# endif // ((PK_GPU_D3D11 == 1) || (PK_GPU_D3D12 == 1)) - - //---------------------------------------------------------------------------- +//---------------------------------------------------------------------------- - bool _IsGpuSupportedOnPlatform(const EShaderPlatform &platform); +bool _IsGpuSupportedOnPlatform(const EShaderPlatform &platform); # if (PK_GPU_D3D11 == 1) # include "GPUSim/PopcornFXGPUSim_D3D11.h" diff --git a/Source/PopcornFX/Private/GPUSim/PopcornFXGPUSim_D3D11.cpp b/Source/PopcornFX/Private/GPUSim/PopcornFXGPUSim_D3D11.cpp index d6d9240..040035b 100644 --- a/Source/PopcornFX/Private/GPUSim/PopcornFXGPUSim_D3D11.cpp +++ b/Source/PopcornFX/Private/GPUSim/PopcornFXGPUSim_D3D11.cpp @@ -63,23 +63,23 @@ void UpdateBufferStats(TRefCountPtr Buffer, bool bAllocating) { } // //---------------------------------------------------------------------------- -FShaderResourceViewRHIRef StreamBufferSRVToRHI(const PopcornFX::SParticleStreamBuffer_D3D11 *stream, u32 bytes, u32 stride, u8 pixelFormat) +FShaderResourceViewRHIRef StreamBufferSRVToRHI(const PopcornFX::SParticleStreamBuffer_D3D11 *stream, u32 stride, u8 pixelFormat) { #if (ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION >= 3) FRHICommandListBase &RHICmdList = FRHICommandListExecutor::GetImmediateCommandList(); #endif #if (ENGINE_MAJOR_VERSION == 5) - FD3D11Buffer *buffer = static_cast(StreamBufferResourceToRHI(stream, bytes, stride)); + FD3D11Buffer *buffer = static_cast(StreamBufferResourceToRHI(stream, stride)); #else - FD3D11VertexBuffer *buffer = static_cast(StreamBufferResourceToRHI(stream, bytes, stride)); + FD3D11VertexBuffer *buffer = static_cast(StreamBufferResourceToRHI(stream, stride)); #endif // (ENGINE_MAJOR_VERSION == 5) check(pixelFormat != PF_Unknown); #if (ENGINE_MAJOR_VERSION == 5) && (ENGINE_MINOR_VERSION >= 3) return RHICmdList.CreateShaderResourceView(buffer, FRHIViewDesc::CreateBufferSRV() .SetTypeFromBuffer(buffer) - .SetStride(stride)); + .SetFormat((EPixelFormat)pixelFormat)); #else // Create a new SRV from resource return RHICreateShaderResourceView(buffer, stride, pixelFormat); @@ -89,9 +89,9 @@ FShaderResourceViewRHIRef StreamBufferSRVToRHI(const PopcornFX::SParticleStreamB //---------------------------------------------------------------------------- #if (ENGINE_MAJOR_VERSION == 5) -FRHIBuffer *StreamBufferResourceToRHI(const PopcornFX::SParticleStreamBuffer_D3D11 *stream, u32 bytes, u32 stride) +FRHIBuffer *StreamBufferResourceToRHI(const PopcornFX::SParticleStreamBuffer_D3D11 *stream, u32 stride) #else -FRHIVertexBuffer *StreamBufferResourceToRHI(const PopcornFX::SParticleStreamBuffer_D3D11 *stream, u32 bytes, u32 stride) +FRHIVertexBuffer *StreamBufferResourceToRHI(const PopcornFX::SParticleStreamBuffer_D3D11 *stream, u32 stride) #endif // (ENGINE_MAJOR_VERSION == 5) { D3D11_BUFFER_DESC desc; @@ -103,15 +103,20 @@ FRHIVertexBuffer *StreamBufferResourceToRHI(const PopcornFX::SParticleStreamB PK_ASSERT((desc.Usage & D3D11_USAGE_DYNAMIC) == 0); // no BUF_AnyDynamic PK_ASSERT((desc.CPUAccessFlags) == 0); // no BUF_AnyDynamic - const EBufferUsageFlags bufferUsage = BUF_UnorderedAccess | BUF_ByteAddressBuffer | BUF_ShaderResource; + // TODO: Unify SParticleStreamBuffer_D3D11 with other APIs, just provide a m_ByteSize member.. + const u32 sizeInBytes = desc.ByteWidth; + + // Fixed #12899: removed BUF_UnorderedAccess | BUF_ByteAddressBuffer from the buffer usage, as it leads to crashes on some AMD GPU hardware. + // The driver does not properly set the buffer stride as it considers it raw (although the buffer isn't bound as a raw buffer). + // The BUF_UnorderedAccess could technically be left active, but none of the UE plugin shaders are binding any of the PK sim streams as UAV anyways. + const EBufferUsageFlags bufferUsage = BUF_ShaderResource; #if (ENGINE_MAJOR_VERSION == 5) && (ENGINE_MINOR_VERSION >= 3) - FD3D11Buffer *buffer = new FD3D11Buffer(stream->m_Buffer, FRHIBufferDesc(bytes, stride, bufferUsage)); + FD3D11Buffer *buffer = new FD3D11Buffer(stream->m_Buffer, FRHIBufferDesc(sizeInBytes, stride, bufferUsage)); #elif (ENGINE_MAJOR_VERSION == 5) - FD3D11Buffer *buffer = new FD3D11Buffer(stream->m_Buffer, bytes, bufferUsage, stride); + FD3D11Buffer *buffer = new FD3D11Buffer(stream->m_Buffer, sizeInBytes, bufferUsage, stride); #else - FD3D11VertexBuffer *buffer = new FD3D11VertexBuffer(stream->m_Buffer, bytes, bufferUsage); + FD3D11VertexBuffer *buffer = new FD3D11VertexBuffer(stream->m_Buffer, sizeInBytes, bufferUsage); #endif // (ENGINE_MAJOR_VERSION == 5) - PK_ASSERT(_PopcornFXD3DGetRefCount(*(buffer->Resource)) > 1); // Referenced here and by PopcornFX return buffer; } diff --git a/Source/PopcornFX/Private/GPUSim/PopcornFXGPUSim_D3D11.h b/Source/PopcornFX/Private/GPUSim/PopcornFXGPUSim_D3D11.h index bfbe6fb..c8ad681 100644 --- a/Source/PopcornFX/Private/GPUSim/PopcornFXGPUSim_D3D11.h +++ b/Source/PopcornFX/Private/GPUSim/PopcornFXGPUSim_D3D11.h @@ -17,11 +17,11 @@ struct SParticleStreamBuffer_D3D11; class CParticleStreamToRender_D3D11; FWD_PK_API_END -FShaderResourceViewRHIRef StreamBufferSRVToRHI(const PopcornFX::SParticleStreamBuffer_D3D11 *stream, u32 bytes, u32 stride, u8 pixelFormat = PF_R32_FLOAT); +FShaderResourceViewRHIRef StreamBufferSRVToRHI(const PopcornFX::SParticleStreamBuffer_D3D11 *stream, u32 stride, u8 pixelFormat = PF_R32_FLOAT); #if (ENGINE_MAJOR_VERSION == 5) -FRHIBuffer *StreamBufferResourceToRHI(const PopcornFX::SParticleStreamBuffer_D3D11 *stream, u32 bytes, u32 stride); +FRHIBuffer *StreamBufferResourceToRHI(const PopcornFX::SParticleStreamBuffer_D3D11 *stream, u32 stride); #else -FRHIVertexBuffer *StreamBufferResourceToRHI(const PopcornFX::SParticleStreamBuffer_D3D11 *stream, u32 bytes, u32 stride); +FRHIVertexBuffer *StreamBufferResourceToRHI(const PopcornFX::SParticleStreamBuffer_D3D11 *stream, u32 stride); #endif // (ENGINE_MAJOR_VERSION == 5) //---------------------------------------------------------------------------- diff --git a/Source/PopcornFX/Private/GPUSim/PopcornFXGPUSim_D3D12.cpp b/Source/PopcornFX/Private/GPUSim/PopcornFXGPUSim_D3D12.cpp index d40df6f..97f722f 100644 --- a/Source/PopcornFX/Private/GPUSim/PopcornFXGPUSim_D3D12.cpp +++ b/Source/PopcornFX/Private/GPUSim/PopcornFXGPUSim_D3D12.cpp @@ -150,6 +150,16 @@ void FD3D12ResourceLocation::SetResource(FD3D12Resource* Value) //---------------------------------------------------------------------------- +namespace D3D12RHI +{ + void VerifyD3D12Result(HRESULT Result, const ANSICHAR* Code, const ANSICHAR* Filename, uint32 Line, ID3D12Device* Device, FString Message) + { + check(FAILED(Result)); + } +} + +//---------------------------------------------------------------------------- + FD3D12Resource::FD3D12Resource(FD3D12Device* ParentDevice, FRHIGPUMask VisibleNodes, ID3D12Resource* InResource, @@ -206,24 +216,35 @@ FD3D12Resource::FD3D12Resource(FD3D12Device* ParentDevice, } InitalizeResourceState(InitialState, InResourceStateMode, InDefaultResourceState); -} +#if (ENGINE_MAJOR_VERSION == 5) && (ENGINE_MINOR_VERSION >= 3) + if (!IsPlacedResource()) + { + ResidencyHandle = MakeUnique(); + } -namespace D3D12RHI -{ - void VerifyD3D12Result(HRESULT Result, const ANSICHAR* Code, const ANSICHAR* Filename, uint32 Line, ID3D12Device* Device, FString Message) + if (Desc.bReservedResource) { - check(FAILED(Result)); + checkf(Heap == nullptr, TEXT("Reserved resources are not expected to have a heap")); + ReservedResourceData = MakeUnique(); } +#endif // (ENGINE_MAJOR_VERSION == 5) && (ENGINE_MINOR_VERSION >= 3) } //---------------------------------------------------------------------------- FD3D12Resource::~FD3D12Resource() { +#if (ENGINE_MAJOR_VERSION == 5) && (ENGINE_MINOR_VERSION >= 3) + if (!IsPlacedResource() && D3DX12Residency::IsInitialized(*ResidencyHandle)) + { + D3DX12Residency::EndTrackingObject(GetParentDevice()->GetResidencyManager(), *ResidencyHandle); + } +#else if (D3DX12Residency::IsInitialized(ResidencyHandle)) { D3DX12Residency::EndTrackingObject(GetParentDevice()->GetResidencyManager(), ResidencyHandle); } +#endif // (ENGINE_MAJOR_VERSION == 5) && (ENGINE_MINOR_VERSION >= 3) } //---------------------------------------------------------------------------- @@ -352,7 +373,10 @@ FRHIVertexBuffer *StreamBufferResourceToRHI(const PopcornFX::SParticleStreamBuff FD3D12DynamicRHI *dynamicRHI = static_cast(GDynamicRHI); FD3D12Device *device = dynamicRHI->GetAdapter().GetDevice(0); - const EBufferUsageFlags bufferUsage = BUF_UnorderedAccess | BUF_ByteAddressBuffer | BUF_ShaderResource; + // Fixed #12899: removed BUF_UnorderedAccess | BUF_ByteAddressBuffer from the buffer usage, as it leads to crashes on some AMD GPU hardware. + // The driver does not properly set the buffer stride as it considers it raw (although the buffer isn't bound as a raw buffer). + // The BUF_UnorderedAccess could technically be left active, but none of the UE plugin shaders are binding any of the PK sim streams as UAV anyways. + const EBufferUsageFlags bufferUsage = BUF_ShaderResource; const D3D12_RESOURCE_STATES resourceState = D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE | D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE; FD3D12Resource *resource = new FD3D12Resource(device, device->GetVisibilityMask(), stream->m_Resource, resourceState, ED3D12ResourceStateMode::Default, resourceState, desc, NULL, D3D12_HEAP_TYPE_DEFAULT); diff --git a/Source/PopcornFX/Private/GPUSim/PopcornFXSortComputeShader.cpp b/Source/PopcornFX/Private/GPUSim/PopcornFXSortComputeShader.cpp index ef45719..14d46be 100644 --- a/Source/PopcornFX/Private/GPUSim/PopcornFXSortComputeShader.cpp +++ b/Source/PopcornFX/Private/GPUSim/PopcornFXSortComputeShader.cpp @@ -8,6 +8,7 @@ #include "GPUSim/PopcornFXGPUSim.h" #include "Render/PopcornFXShaderUtils.h" +#include "PipelineStateCache.h" #include "ShaderParameterUtils.h" #include "SceneUtils.h" @@ -258,7 +259,7 @@ void FPopcornFXSortComputeShader_Sorter::DispatchGenIndiceBatch(FRHICommandList& PK_ASSERT(params.m_Count > 0); -#if (ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION >= 3) +#if (ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION >= 1) SetComputePipelineState(RHICmdList, shader); #else RHICmdList.SetComputeShader(shader); diff --git a/Source/PopcornFX/Private/HUD/PopcornFXHUDProfiler.cpp b/Source/PopcornFX/Private/HUD/PopcornFXHUDProfiler.cpp index 2f266b5..c386f0c 100644 --- a/Source/PopcornFX/Private/HUD/PopcornFXHUDProfiler.cpp +++ b/Source/PopcornFX/Private/HUD/PopcornFXHUDProfiler.cpp @@ -12,6 +12,7 @@ #include "Engine/Canvas.h" #include "Debug/DebugDrawService.h" #include "Engine/Engine.h" +#include "UObject/UObjectIterator.h" #include "PopcornFXSceneComponent.h" diff --git a/Source/PopcornFX/Private/Internal/FileSystemController_UE.cpp b/Source/PopcornFX/Private/Internal/FileSystemController_UE.cpp index f8c0c1c..aecf67b 100644 --- a/Source/PopcornFX/Private/Internal/FileSystemController_UE.cpp +++ b/Source/PopcornFX/Private/Internal/FileSystemController_UE.cpp @@ -228,6 +228,11 @@ CFileSystemController_UE::~CFileSystemController_UE() PopcornFX::PFileStream CFileSystemController_UE::OpenStream(const CString &path, IFileSystem::EAccessPolicy mode, bool pathNotVirtual) { + if (!IsInGameThread()) + { + CLog::Log(PK_INFO, "CFileSystemController_UE OpenStream: cannot load UE packages outside the main thread ('%s' pathNotVirtual:%d)", path.Data(), pathNotVirtual); + return null; + } CFileStreamFS_UE *fs = CFileStreamFS_UE::Open(this, path, pathNotVirtual, mode); if (fs != null) FS_DEBUG_LOG(PK_INFO, "CFileSystemController_UE OpenStream OK '%s' pathNotVirtual:%d", path.Data(), pathNotVirtual); @@ -240,6 +245,11 @@ PopcornFX::PFileStream CFileSystemController_UE::OpenStream(const CString &path bool CFileSystemController_UE::Exists(const CString &path, bool pathNotVirtual /*= false*/) { + if (!IsInGameThread()) + { + CLog::Log(PK_INFO, "CFileSystemController_UE Exists: cannot load UE packages outside the main thread ('%s' pathNotVirtual:%d)", path.Data(), pathNotVirtual); + return false; + } UObject *uobject = LoadUObject(path, pathNotVirtual); if (uobject != null) FS_DEBUG_LOG(PK_INFO, "CFileSystemController_UE Exists OK '%s' pathNotVirtual:%d", path.Data(), pathNotVirtual); diff --git a/Source/PopcornFX/Private/Internal/ParticleScene.cpp b/Source/PopcornFX/Private/Internal/ParticleScene.cpp index 6e454e6..1b61b0b 100644 --- a/Source/PopcornFX/Private/Internal/ParticleScene.cpp +++ b/Source/PopcornFX/Private/Internal/ParticleScene.cpp @@ -50,6 +50,9 @@ # include "PBDRigidsSolver.h" # include "Chaos/ChaosScene.h" # include "Chaos/PBDRigidsEvolutionGBF.h" + +# include "Physics/Experimental/PhysScene_Chaos.h" +# include "PhysicsInterfaceDeclaresCore.h" #endif #include "Collision.h" @@ -61,6 +64,7 @@ #include "RenderingThread.h" #include "Engine/LocalPlayer.h" #include "Engine/Engine.h" +#include "Engine/GameViewportClient.h" #include "Materials/MaterialInstanceConstant.h" #include "Materials/MaterialInstanceDynamic.h" #include "PhysicalMaterials/PhysicalMaterial.h" @@ -68,8 +72,11 @@ #if WITH_EDITOR # include "Editor.h" # include "LevelEditorViewport.h" +# include "Settings/LevelEditorViewportSettings.h" #endif // WITH_EDITOR +#include "UnrealClient.h" + #include "PopcornFXSDK.h" #include #include diff --git a/Source/PopcornFX/Private/Internal/ParticleScene.h b/Source/PopcornFX/Private/Internal/ParticleScene.h index dacfdf7..65eafd0 100644 --- a/Source/PopcornFX/Private/Internal/ParticleScene.h +++ b/Source/PopcornFX/Private/Internal/ParticleScene.h @@ -52,6 +52,8 @@ namespace physx struct PxRaycastHit; class PxScene; } +#else +# include "Chaos/ChaosScene.h" #endif // PK_WITH_PHYSX FWD_PK_API_BEGIN diff --git a/Source/PopcornFX/Private/Internal/Startup.cpp b/Source/PopcornFX/Private/Internal/Startup.cpp index 450a93a..9efb63c 100644 --- a/Source/PopcornFX/Private/Internal/Startup.cpp +++ b/Source/PopcornFX/Private/Internal/Startup.cpp @@ -12,6 +12,8 @@ #include "PopcornFXSettings.h" #include "PopcornFXStats.h" +#include "Templates/ScopedCallback.h" + #include "GenericPlatform/GenericPlatformMemory.h" #include "HAL/PlatformAffinity.h" #include "Misc/ConfigCacheIni.h" diff --git a/Source/PopcornFX/Private/Platforms/PopcornFXPlatform.h b/Source/PopcornFX/Private/Platforms/PopcornFXPlatform.h index 5ead76a..83621f2 100644 --- a/Source/PopcornFX/Private/Platforms/PopcornFXPlatform.h +++ b/Source/PopcornFX/Private/Platforms/PopcornFXPlatform.h @@ -18,6 +18,12 @@ # endif // (PK_HAS_GPU != 0) #endif // WITH_EDITOR +#if (ENGINE_MAJOR_VERSION == 5) && (ENGINE_MINOR_VERSION >= 2) +# if (PK_COMPILE_GPU != 0) +# include "RHIShaderPlatform.h" +# endif +#endif + FWD_PK_API_BEGIN class CImage; FWD_PK_API_END diff --git a/Source/PopcornFX/Private/Platforms/PopcornFXPlatformCommon.cpp b/Source/PopcornFX/Private/Platforms/PopcornFXPlatformCommon.cpp index 812bb40..64e8c2d 100644 --- a/Source/PopcornFX/Private/Platforms/PopcornFXPlatformCommon.cpp +++ b/Source/PopcornFX/Private/Platforms/PopcornFXPlatformCommon.cpp @@ -18,10 +18,18 @@ # include "ShaderCompilerCore.h" # include "Misc/FileHelper.h" +# if (ENGINE_MAJOR_VERSION == 5) && (ENGINE_MINOR_VERSION >= 3) +# include "ShaderPreprocessTypes.h" +# endif // (ENGINE_MAJOR_VERSION == 5) && (ENGINE_MINOR_VERSION >= 3) + # include # include #endif // (PK_COMPILE_GPU != 0) +#if (PKFX_COMMON_NewImageFromTexture != 0) +# include "TextureResource.h" +#endif + #include //---------------------------------------------------------------------------- @@ -35,7 +43,7 @@ PopcornFX::CImage *_CreateFallbackImage() const PopcornFX::CUint3 size(16, 16, 1); const PopcornFX::CImage::EFormat format = PopcornFX::CImage::Format_BGRA8; - const u32 bufferSize = PopcornFX::CImage::GetFormatPixelBufferSizeInBytes(format, size); + const u32 bufferSize = PopcornFX::CImage::GetFormatPixelBufferSizeInBytes(format, size); PopcornFX::PRefCountedMemoryBuffer dstBuffer = PopcornFX::CRefCountedMemoryBuffer::AllocAligned(bufferSize, 0x80); if (!PK_VERIFY(dstBuffer != null)) return null; @@ -314,9 +322,20 @@ bool CompileComputeShaderForAPI( const PopcornFX::CString &source, #endif // (ENGINE_MAJOR_VERSION == 5) } - FShaderCompilerOutput output; - const FString workingDirectory; + FShaderCompilerOutput output; + const FString workingDirectory; +#if (ENGINE_MAJOR_VERSION == 5) && (ENGINE_MINOR_VERSION >= 3) + FShaderPreprocessOutput preprocessorOutput; + FShaderCompilerEnvironment mergedEnvironment; + if (!shaderFormat->PreprocessShader(input, mergedEnvironment, preprocessorOutput)) + { + UE_LOG(LogPopcornFXPlatformCommon, Verbose, TEXT("Failed preprocessing shader for %s"), ANSI_TO_TCHAR(apiName.Data())); + return false; + } + shaderFormat->CompilePreprocessedShader(input, preprocessorOutput, output, workingDirectory); +#else shaderFormat->CompileShader(shaderFormatName, input, output, workingDirectory); +#endif // (ENGINE_MAJOR_VERSION == 5) && (ENGINE_MINOR_VERSION >= 3) if (output.bSucceeded) { diff --git a/Source/PopcornFX/Private/PopcornFXPlugin.cpp b/Source/PopcornFX/Private/PopcornFXPlugin.cpp index 7264dbd..84be13b 100644 --- a/Source/PopcornFX/Private/PopcornFXPlugin.cpp +++ b/Source/PopcornFX/Private/PopcornFXPlugin.cpp @@ -16,6 +16,8 @@ # include "Editor/PopcornFXEffectEditor.h" #endif +#include "ShaderCore.h" + #include "EngineModule.h" #include "Engine/Texture.h" #include "Engine/StaticMesh.h" diff --git a/Source/PopcornFX/Private/Render/BatchDrawer_Billboard_CPU.cpp b/Source/PopcornFX/Private/Render/BatchDrawer_Billboard_CPU.cpp index aa59c0a..567c615 100644 --- a/Source/PopcornFX/Private/Render/BatchDrawer_Billboard_CPU.cpp +++ b/Source/PopcornFX/Private/Render/BatchDrawer_Billboard_CPU.cpp @@ -7,6 +7,7 @@ #include "RenderBatchManager.h" #include "SceneManagement.h" #include "MaterialDesc.h" +#include "SceneInterface.h" #include "Engine/Engine.h" #include "World/PopcornFXSceneProxy.h" @@ -660,6 +661,7 @@ void CBatchDrawer_Billboard_CPUBB::_IssueDrawCall_Billboard(const SUERenderConte vsUniforms.DynamicParameterMask = matDesc.m_DynamicParameterMask; vsUniformsBillboard.RendererType = static_cast(PopcornFX::Renderer_Billboard); + vsUniformsBillboard.TotalParticleCount = desc.m_TotalParticleCount; vsUniformsBillboard.CapsulesOffset = m_CapsulesOffset; vsUniformsBillboard.InColorsOffset = m_AdditionalStreamOffsets[StreamOffset_Colors].OffsetForShaderConstant(); vsUniformsBillboard.InEmissiveColorsOffset = m_AdditionalStreamOffsets[StreamOffset_EmissiveColors].OffsetForShaderConstant(); diff --git a/Source/PopcornFX/Private/Render/BatchDrawer_Billboard_GPU.cpp b/Source/PopcornFX/Private/Render/BatchDrawer_Billboard_GPU.cpp index a2b8003..dcaf109 100644 --- a/Source/PopcornFX/Private/Render/BatchDrawer_Billboard_GPU.cpp +++ b/Source/PopcornFX/Private/Render/BatchDrawer_Billboard_GPU.cpp @@ -114,6 +114,7 @@ bool FPopcornFXAtlasRectsVertexBuffer::_LoadRects(const PopcornFX::TMemoryView= 3) +void FNullFloat4Buffer::InitRHI(FRHICommandListBase &RHICmdList) +#else +void FNullFloat4Buffer::InitRHI() +#endif // (ENGINE_MAJOR_VERSION == 5) && (ENGINE_MINOR_VERSION >= 3) +{ + // Note: buffer is not initialized, only meant to calm down UE not letting bind null descriptors. + // Draw calls binding this null buffer will access its data. + + const u32 totalByteCount = 4 * sizeof(float); // Whatever +#if (ENGINE_MAJOR_VERSION == 5) + FRHIResourceCreateInfo info(TEXT("PopcornFX Null Float4 buffer")); +#else + FRHIResourceCreateInfo info; +#endif // (ENGINE_MAJOR_VERSION == 5) + const EBufferUsageFlags usage = BUF_Dynamic | BUF_ShaderResource; + +#if (ENGINE_MAJOR_VERSION == 5) && (ENGINE_MINOR_VERSION >= 3) + VertexBufferRHI = RHICmdList.CreateBuffer(totalByteCount, usage, 0, ERHIAccess::VertexOrIndexBuffer | ERHIAccess::SRVMask, info); + SRV = RHICmdList.CreateShaderResourceView(VertexBufferRHI, sizeof(CFloat4), PF_A32B32G32R32F); +#else + VertexBufferRHI = RHICreateVertexBuffer(totalByteCount, usage, info); // TODO: Stride + SRV = RHICreateShaderResourceView(VertexBufferRHI, sizeof(CFloat4), PF_A32B32G32R32F); +#endif // (ENGINE_MAJOR_VERSION == 5) && (ENGINE_MINOR_VERSION >= 3) +} + +//---------------------------------------------------------------------------- + +void FNullFloat4Buffer::ReleaseRHI() +{ + SRV.SafeRelease(); + FVertexBuffer::ReleaseRHI(); +} + +//---------------------------------------------------------------------------- + +TGlobalResource GPopcornFXNullFloat4Buffer; + //---------------------------------------------------------------------------- // // FPopcornFXGPUBillboardCollector @@ -904,7 +949,7 @@ bool CBatchDrawer_Billboard_GPUBB::LaunchCustomTasks(PopcornFX::SRenderContext & if (renderContext.m_API == SUERenderContext::D3D11) { const PopcornFX::CParticleStreamToRender_D3D11 &stream_D3D11 = static_cast(dr.StreamToRender()); - copyParams.m_LiveParticleCount = StreamBufferSRVToRHI(&stream_D3D11.StreamSizeBuf(), sizeof(u32) * 4, sizeof(u32), PF_R32_UINT); + copyParams.m_LiveParticleCount = StreamBufferSRVToRHI(&stream_D3D11.StreamSizeBuf(), sizeof(u32), PF_R32_UINT /* debug layer errors if not specified correctly */); } #endif #if (PK_GPU_D3D12 == 1) @@ -1066,14 +1111,14 @@ bool CBatchDrawer_Billboard_GPUBB::_FillDrawCallUniforms_GPU(u32 drId, if (renderContext.m_API == SUERenderContext::D3D11) { const PopcornFX::CParticleStreamToRender_D3D11 &stream_D3D11 = static_cast(dr->StreamToRender()); - m_SimDataSRVRef = StreamBufferSRVToRHI(&stream_D3D11.StreamBuffer(), stream_D3D11.StreamSizeEst(), sizeof(float), PF_R32_UINT); + m_SimDataSRVRef = StreamBufferSRVToRHI(&stream_D3D11.StreamBuffer(), sizeof(float), PF_R32_UINT /* debug layer errors if not specified correctly */); } #endif #if (PK_GPU_D3D12 == 1) if (renderContext.m_API == SUERenderContext::D3D12) { const PopcornFX::CParticleStreamToRender_D3D12 &stream_D3D12 = static_cast(dr->StreamToRender()); - m_SimDataSRVRef = StreamBufferSRVToRHI(&stream_D3D12.StreamBuffer(), sizeof(u32)); + m_SimDataSRVRef = StreamBufferSRVToRHI(&stream_D3D12.StreamBuffer(), sizeof(float)); } #endif PK_ASSERT(m_SimDataSRVRef.IsValid()); @@ -1191,15 +1236,8 @@ void CBatchDrawer_Billboard_GPUBB::_IssueDrawCall_Billboard(const SUERenderConte vsUniformsGPUBillboard.InDynamicParameter3sOffset = m_AdditionalStreamOffsets[StreamOffset_DynParam3s].Valid() ? static_cast(m_AdditionalStreamOffsets[StreamOffset_DynParam3s] / sizeof(float)) : -1; vsUniformsGPUBillboard.AtlasRectCount = m_AtlasRects.m_AtlasRectsCount; - if (m_AtlasRects.m_AtlasBufferSRV != null) - vsUniformsGPUBillboard.AtlasBuffer = m_AtlasRects.m_AtlasBufferSRV; - else - vsUniformsGPUBillboard.AtlasBuffer = vsUniforms.InSimData; // Dummy SRV - - if (gpuStorage) - vsUniformsGPUBillboard.DrawRequests = vsUniforms.InSimData; - else - vsUniformsGPUBillboard.DrawRequests = m_DrawRequests.m_DrawRequestsBufferSRV; // Dummy SRV + vsUniformsGPUBillboard.AtlasBuffer = m_AtlasRects.m_AtlasBufferSRV == null ? GPopcornFXNullFloat4Buffer.SRV : m_AtlasRects.m_AtlasBufferSRV; + vsUniformsGPUBillboard.DrawRequests = gpuStorage ? GPopcornFXNullFloat4Buffer.SRV : m_DrawRequests.m_DrawRequestsBufferSRV; vertexFactory->m_VSUniformBuffer = FPopcornFXUniformsRef::CreateUniformBufferImmediate(vsUniforms, UniformBuffer_SingleFrame); vertexFactory->m_GPUBillboardVSUniformBuffer = FPopcornFXGPUBillboardVSUniformsRef::CreateUniformBufferImmediate(vsUniformsGPUBillboard, UniformBuffer_SingleFrame); diff --git a/Source/PopcornFX/Private/Render/BatchDrawer_Billboard_GPU.h b/Source/PopcornFX/Private/Render/BatchDrawer_Billboard_GPU.h index 03dfaab..75803d0 100644 --- a/Source/PopcornFX/Private/Render/BatchDrawer_Billboard_GPU.h +++ b/Source/PopcornFX/Private/Render/BatchDrawer_Billboard_GPU.h @@ -17,9 +17,12 @@ class FPopcornFXGPUVertexFactory; class FPopcornFXUniforms; class FPopcornFXGPUBillboardVSUniforms; +//---------------------------------------------------------------------------- +// +// Atlas buffer (holds CRectangleList rects) +// //---------------------------------------------------------------------------- -PK_FIXME("Should be build from PopcornFXFile") struct FPopcornFXAtlasRectsVertexBuffer { //FStructuredBufferRHIRef m_AtlasBuffer_Structured; @@ -47,6 +50,10 @@ struct FPopcornFXAtlasRectsVertexBuffer bool _LoadRects(const PopcornFX::TMemoryView &rects); }; +//---------------------------------------------------------------------------- +// +// Draw requests buffer (holds batching data, not currently supported by the GPU sim) +// //---------------------------------------------------------------------------- struct FPopcornFXDrawRequestsBuffer @@ -71,6 +78,31 @@ struct FPopcornFXDrawRequestsBuffer bool m_Mapped = false; }; +//---------------------------------------------------------------------------- +// +// Null Float4 buffer +// +//---------------------------------------------------------------------------- + +class FNullFloat4Buffer : public FVertexBuffer +{ +public: +#if (ENGINE_MAJOR_VERSION == 5) && (ENGINE_MINOR_VERSION >= 3) + virtual void InitRHI(FRHICommandListBase &RHICmdList) override; +#else + virtual void InitRHI() override; +#endif // (ENGINE_MAJOR_VERSION == 5) && (ENGINE_MINOR_VERSION >= 3) + virtual void ReleaseRHI() override; + + FShaderResourceViewRHIRef SRV; +}; + +extern TGlobalResource GPopcornFXNullFloat4Buffer; + +//---------------------------------------------------------------------------- +// +// Drawer +// //---------------------------------------------------------------------------- class CBatchDrawer_Billboard_GPUBB : public PopcornFX::CRendererBatchJobs_Billboard_GPUBB diff --git a/Source/PopcornFX/Private/Render/BatchDrawer_Ribbon_CPU.cpp b/Source/PopcornFX/Private/Render/BatchDrawer_Ribbon_CPU.cpp index cf58de3..fe2369d 100644 --- a/Source/PopcornFX/Private/Render/BatchDrawer_Ribbon_CPU.cpp +++ b/Source/PopcornFX/Private/Render/BatchDrawer_Ribbon_CPU.cpp @@ -7,6 +7,7 @@ #include "RenderBatchManager.h" #include "SceneManagement.h" #include "MaterialDesc.h" +#include "SceneInterface.h" #include "Engine/Engine.h" #include "World/PopcornFXSceneProxy.h" @@ -698,6 +699,7 @@ void CBatchDrawer_Ribbon_CPUBB::_IssueDrawCall_Ribbon(const SUERenderContext &re vsUniformsbillboard.RendererType = static_cast(PopcornFX::Renderer_Ribbon); vsUniformsbillboard.CapsulesOffset = 0; + vsUniformsbillboard.TotalParticleCount = desc.m_TotalParticleCount; vsUniformsbillboard.InColorsOffset = m_AdditionalStreamOffsets[StreamOffset_Colors].OffsetForShaderConstant(); vsUniformsbillboard.InEmissiveColorsOffset = m_AdditionalStreamOffsets[StreamOffset_EmissiveColors].OffsetForShaderConstant(); vsUniformsbillboard.InAlphaCursorsOffset = m_AdditionalStreamOffsets[StreamOffset_AlphaCursors].OffsetForShaderConstant(); diff --git a/Source/PopcornFX/Private/Render/BatchDrawer_SkeletalMesh_CPU.cpp b/Source/PopcornFX/Private/Render/BatchDrawer_SkeletalMesh_CPU.cpp index 1a76ed3..c7d7d84 100644 --- a/Source/PopcornFX/Private/Render/BatchDrawer_SkeletalMesh_CPU.cpp +++ b/Source/PopcornFX/Private/Render/BatchDrawer_SkeletalMesh_CPU.cpp @@ -10,6 +10,11 @@ #include "Rendering/SkeletalMeshRenderData.h" #include "Rendering/SkeletalMeshLODRenderData.h" #include "Engine/SkeletalMesh.h" +#include "Engine/Texture2D.h" +#if (ENGINE_MAJOR_VERSION == 5) && (ENGINE_MINOR_VERSION >= 1) +# include "Engine/SkinnedAssetCommon.h" +#endif +#include "RHIStaticStates.h" #include "Engine/Engine.h" #include "World/PopcornFXSceneProxy.h" diff --git a/Source/PopcornFX/Private/Render/BatchDrawer_Triangle_CPU.cpp b/Source/PopcornFX/Private/Render/BatchDrawer_Triangle_CPU.cpp index c8138da..fbbf0d9 100644 --- a/Source/PopcornFX/Private/Render/BatchDrawer_Triangle_CPU.cpp +++ b/Source/PopcornFX/Private/Render/BatchDrawer_Triangle_CPU.cpp @@ -7,6 +7,7 @@ #include "RenderBatchManager.h" #include "SceneManagement.h" #include "MaterialDesc.h" +#include "SceneInterface.h" #include "Engine/Engine.h" #include "World/PopcornFXSceneProxy.h" @@ -572,6 +573,7 @@ void CBatchDrawer_Triangle_CPUBB::_IssueDrawCall_Triangle(const SUERenderContext vsUniforms.DynamicParameterMask = matDesc.m_DynamicParameterMask; vsUniformsBillboard.RendererType = static_cast(PopcornFX::Renderer_Triangle); + vsUniformsBillboard.TotalParticleCount = desc.m_TotalParticleCount; vsUniformsBillboard.InColorsOffset = m_AdditionalStreamOffsets[StreamOffset_Colors].OffsetForShaderConstant(); vsUniformsBillboard.InEmissiveColorsOffset = m_AdditionalStreamOffsets[StreamOffset_EmissiveColors].OffsetForShaderConstant(); vsUniformsBillboard.InAlphaCursorsOffset = m_AdditionalStreamOffsets[StreamOffset_AlphaCursors].OffsetForShaderConstant(); diff --git a/Source/PopcornFX/Private/Render/MaterialDesc.cpp b/Source/PopcornFX/Private/Render/MaterialDesc.cpp index 740ec39..5689d89 100644 --- a/Source/PopcornFX/Private/Render/MaterialDesc.cpp +++ b/Source/PopcornFX/Private/Render/MaterialDesc.cpp @@ -20,6 +20,10 @@ #include "Materials/Material.h" #include "Materials/MaterialInterface.h" #include "Materials/MaterialInstanceConstant.h" +#if (ENGINE_MAJOR_VERSION == 5) && (ENGINE_MINOR_VERSION >= 2) +# include "Materials/MaterialRenderProxy.h" +# include "MaterialDomain.h" +#endif #include "MaterialShared.h" #include diff --git a/Source/PopcornFX/Private/Render/MaterialDesc.h b/Source/PopcornFX/Private/Render/MaterialDesc.h index f5c3fee..ab86cb4 100644 --- a/Source/PopcornFX/Private/Render/MaterialDesc.h +++ b/Source/PopcornFX/Private/Render/MaterialDesc.h @@ -16,6 +16,12 @@ #include "RenderTypesPolicies.h" +#if (ENGINE_MAJOR_VERSION == 5) && (ENGINE_MINOR_VERSION >= 2) +# if RHI_RAYTRACING +# include "RayTracingGeometry.h" +# endif +#endif + //---------------------------------------------------------------------------- class UPopcornFXRendererMaterial; diff --git a/Source/PopcornFX/Private/Render/PopcornFXGPUVertexFactory.cpp b/Source/PopcornFX/Private/Render/PopcornFXGPUVertexFactory.cpp index ac727ae..7116aa4 100644 --- a/Source/PopcornFX/Private/Render/PopcornFXGPUVertexFactory.cpp +++ b/Source/PopcornFX/Private/Render/PopcornFXGPUVertexFactory.cpp @@ -16,6 +16,11 @@ #include "MaterialShared.h" #include "Materials/Material.h" #include "Materials/MaterialInterface.h" +#include "MeshDrawShaderBindings.h" +#if (ENGINE_MAJOR_VERSION == 5) && (ENGINE_MINOR_VERSION >= 2) +# include "MaterialDomain.h" +# include "DataDrivenShaderPlatformInfo.h" +#endif IMPLEMENT_GLOBAL_SHADER_PARAMETER_STRUCT(FPopcornFXGPUBillboardVSUniforms, "PopcornFXGPUBillboardVSUniforms"); diff --git a/Source/PopcornFX/Private/Render/PopcornFXMeshVertexFactory.cpp b/Source/PopcornFX/Private/Render/PopcornFXMeshVertexFactory.cpp index e7a53c2..8886154 100644 --- a/Source/PopcornFX/Private/Render/PopcornFXMeshVertexFactory.cpp +++ b/Source/PopcornFX/Private/Render/PopcornFXMeshVertexFactory.cpp @@ -12,6 +12,10 @@ #include "MeshBatch.h" #include "Materials/MaterialInterface.h" #include "Materials/Material.h" +#if (ENGINE_MAJOR_VERSION == 5) && (ENGINE_MINOR_VERSION >= 2) +# include "MaterialDomain.h" +# include "GlobalRenderResources.h" +#endif #include "MeshMaterialShader.h" #include "MeshDrawShaderBindings.h" diff --git a/Source/PopcornFX/Private/Render/PopcornFXSkeletalMeshVertexFactory.cpp b/Source/PopcornFX/Private/Render/PopcornFXSkeletalMeshVertexFactory.cpp index 88793f2..6fb79e6 100644 --- a/Source/PopcornFX/Private/Render/PopcornFXSkeletalMeshVertexFactory.cpp +++ b/Source/PopcornFX/Private/Render/PopcornFXSkeletalMeshVertexFactory.cpp @@ -12,6 +12,10 @@ #include "MeshBatch.h" #include "Materials/MaterialInterface.h" #include "Materials/Material.h" +#if (ENGINE_MAJOR_VERSION == 5) && (ENGINE_MINOR_VERSION >= 2) +# include "MaterialDomain.h" +# include "GlobalRenderResources.h" +#endif #include "GPUSkinPublicDefs.h" diff --git a/Source/PopcornFX/Private/Render/PopcornFXVertexFactory.cpp b/Source/PopcornFX/Private/Render/PopcornFXVertexFactory.cpp index 02f05d6..6645ce2 100644 --- a/Source/PopcornFX/Private/Render/PopcornFXVertexFactory.cpp +++ b/Source/PopcornFX/Private/Render/PopcornFXVertexFactory.cpp @@ -12,6 +12,11 @@ #include "MaterialShared.h" #include "Materials/MaterialInterface.h" #include "Materials/Material.h" +#if (ENGINE_MAJOR_VERSION == 5) && (ENGINE_MINOR_VERSION >= 2) +# include "MaterialDomain.h" +# include "DataDrivenShaderPlatformInfo.h" +# include "GlobalRenderResources.h" +#endif #include "MeshMaterialShader.h" diff --git a/Source/PopcornFX/Private/Render/PopcornFXVertexFactoryShaderParameters.cpp b/Source/PopcornFX/Private/Render/PopcornFXVertexFactoryShaderParameters.cpp index 6ee53ed..e2bb77b 100644 --- a/Source/PopcornFX/Private/Render/PopcornFXVertexFactoryShaderParameters.cpp +++ b/Source/PopcornFX/Private/Render/PopcornFXVertexFactoryShaderParameters.cpp @@ -12,6 +12,7 @@ #include "ShaderParameterUtils.h" #include "MeshBatch.h" #include "MeshMaterialShader.h" +#include "MeshDrawShaderBindings.h" #include "PopcornFXSDK.h" diff --git a/Source/PopcornFX/Private/Render/RenderBatchManager.cpp b/Source/PopcornFX/Private/Render/RenderBatchManager.cpp index 9ebabbe..76fe00e 100644 --- a/Source/PopcornFX/Private/Render/RenderBatchManager.cpp +++ b/Source/PopcornFX/Private/Render/RenderBatchManager.cpp @@ -29,9 +29,14 @@ #include "Assets/PopcornFXRendererMaterial.h" #include "PopcornFXStats.h" +#include "Engine/World.h" + #include "Materials/Material.h" #include "Materials/MaterialInterface.h" #include "Materials/MaterialInstanceConstant.h" +#if (ENGINE_MAJOR_VERSION == 5) && (ENGINE_MINOR_VERSION >= 2) +# include "MaterialDomain.h" +#endif #if POPCORNFX_RENDER_DEBUG # include "PopcornFXSceneComponent.h" diff --git a/Source/PopcornFX/Private/World/PopcornFXSceneComponent.cpp b/Source/PopcornFX/Private/World/PopcornFXSceneComponent.cpp index 90bb489..021d789 100644 --- a/Source/PopcornFX/Private/World/PopcornFXSceneComponent.cpp +++ b/Source/PopcornFX/Private/World/PopcornFXSceneComponent.cpp @@ -14,6 +14,8 @@ #include "PopcornFXStats.h" #include "Assets/PopcornFXEffectPriv.h" +#include "Engine/World.h" + #include "Engine/CollisionProfile.h" #include "PopcornFXSDK.h" diff --git a/Source/PopcornFX/Public/PopcornFXVersionGenerated.h b/Source/PopcornFX/Public/PopcornFXVersionGenerated.h index 3886588..7cceb04 100644 --- a/Source/PopcornFX/Public/PopcornFXVersionGenerated.h +++ b/Source/PopcornFX/Public/PopcornFXVersionGenerated.h @@ -7,5 +7,5 @@ #define POPCORNFX_PLUGIN_VERSION_MAJOR 2 #define POPCORNFX_PLUGIN_VERSION_MINOR 15 -#define POPCORNFX_PLUGIN_VERSION_PATCH 13 +#define POPCORNFX_PLUGIN_VERSION_PATCH 14 #define POPCORNFX_PLUGIN_VERSION_TAG ""