Skip to content

Commit

Permalink
PopcornFX Plugin v2.15.14
Browse files Browse the repository at this point in the history
  • Loading branch information
PopcornFX Bot committed Sep 28, 2023
1 parent 483557f commit 9efadda
Showing 39 changed files with 272 additions and 122 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/draft-release.yml
Original file line number Diff line number Diff line change
@@ -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 }}"
3 changes: 3 additions & 0 deletions Content/Materials/M_PK_Default_Mesh_AlphaBlend.uasset
Git LFS file not shown
2 changes: 1 addition & 1 deletion Download_SDK_Desktop.bat
Original file line number Diff line number Diff line change
@@ -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

2 changes: 1 addition & 1 deletion Download_SDK_Mobile.bat
Original file line number Diff line number Diff line change
@@ -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

4 changes: 2 additions & 2 deletions PopcornFX.uplugin
Original file line number Diff line number Diff line change
@@ -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",
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.
1 change: 1 addition & 0 deletions Source/PopcornFX/Private/Assets/PopcornFXAssetDep.cpp
Original file line number Diff line number Diff line change
@@ -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"

4 changes: 4 additions & 0 deletions Source/PopcornFX/Private/Assets/PopcornFXRendererMaterial.cpp
Original file line number Diff line number Diff line change
@@ -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 <pk_base_object/include/hbo_handler.h>
Original file line number Diff line number Diff line change
@@ -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"
62 changes: 7 additions & 55 deletions Source/PopcornFX/Private/GPUSim/PopcornFXGPUSim.cpp
Original file line number Diff line number Diff line change
@@ -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 <pk_kernel/include/kr_thread_pool.h>
#include <pk_particles/include/ps_stream_to_render.h>

@@ -88,59 +95,4 @@ bool StreamBufferByteOffset(const PopcornFX::CParticleStreamToRender_GPU &stream
return _streamOffset.Valid();
}

//----------------------------------------------------------------------------

template <typename _Type, u32 _Stride>
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<const PopcornFX::CParticleStreamToRender_D3D11&>(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<const PopcornFX::CParticleStreamToRender_D3D12&>(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)
35 changes: 13 additions & 22 deletions Source/PopcornFX/Private/GPUSim/PopcornFXGPUSim.h
Original file line number Diff line number Diff line change
@@ -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 <typename _Type, uint32 _Stride>
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"
27 changes: 16 additions & 11 deletions Source/PopcornFX/Private/GPUSim/PopcornFXGPUSim_D3D11.cpp
Original file line number Diff line number Diff line change
@@ -63,23 +63,23 @@ void UpdateBufferStats(TRefCountPtr<ID3D11Buffer> 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<FD3D11Buffer*>(StreamBufferResourceToRHI(stream, bytes, stride));
FD3D11Buffer *buffer = static_cast<FD3D11Buffer*>(StreamBufferResourceToRHI(stream, stride));
#else
FD3D11VertexBuffer *buffer = static_cast<FD3D11VertexBuffer*>(StreamBufferResourceToRHI(stream, bytes, stride));
FD3D11VertexBuffer *buffer = static_cast<FD3D11VertexBuffer*>(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;
}
6 changes: 3 additions & 3 deletions Source/PopcornFX/Private/GPUSim/PopcornFXGPUSim_D3D11.h
Original file line number Diff line number Diff line change
@@ -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)

//----------------------------------------------------------------------------
36 changes: 30 additions & 6 deletions Source/PopcornFX/Private/GPUSim/PopcornFXGPUSim_D3D12.cpp
Original file line number Diff line number Diff line change
@@ -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<FD3D12ResidencyHandle>();
}

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<FD3D12ReservedResourceData>();
}
#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<FD3D12DynamicRHI*>(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);
Original file line number Diff line number Diff line change
@@ -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);
1 change: 1 addition & 0 deletions Source/PopcornFX/Private/HUD/PopcornFXHUDProfiler.cpp
Original file line number Diff line number Diff line change
@@ -12,6 +12,7 @@
#include "Engine/Canvas.h"
#include "Debug/DebugDrawService.h"
#include "Engine/Engine.h"
#include "UObject/UObjectIterator.h"

#include "PopcornFXSceneComponent.h"

Loading

0 comments on commit 9efadda

Please sign in to comment.