Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix build issues and migrate to ue4.23 #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified ImsvGraphVis.uproject
Binary file not shown.
4 changes: 2 additions & 2 deletions Plugins/SplineRenderer/Source/Private/SplineComputeShader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
#include "ShaderParameters.h"
#include "UniformBuffer.h"

IMPLEMENT_UNIFORM_BUFFER_STRUCT(FSplineComputeShaderUniformParameters,
TEXT("SplineComputeShaderUniformParameters"))
IMPLEMENT_GLOBAL_SHADER_PARAMETER_STRUCT(FSplineComputeShaderUniformParameters,
"SplineComputeShaderUniformParameters");

FBaseSplineComputeShader::FBaseSplineComputeShader(
ShaderMetaType::CompiledShaderInitializerType const& Initializer)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,16 @@ IMPLEMENT_MODULE(FSplineRendererModule, SplineRenderer)

void FSplineRendererModule::StartupModule()
{
#if ENGINE_MAJOR_VERSION >= 4 && ENGINE_MINOR_VERSION >= 21
FString ShaderDirectory = FPaths::Combine(
FPaths::ProjectDir(), TEXT("Plugins"), TEXT("SplineRenderer"), TEXT("Shaders"));
AddShaderSourceDirectoryMapping("/Plugin/SplineRenderer", ShaderDirectory);
#endif
}

void FSplineRendererModule::ShutdownModule()
{
#if ENGINE_MAJOR_VERSION >= 4 && ENGINE_MINOR_VERSION >= 21
ResetAllShaderSourceDirectoryMappings();
#endif
}
18 changes: 11 additions & 7 deletions Plugins/SplineRenderer/Source/Public/SplineComputeShader.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
#include "UniformBuffer.h"

// DECLARE_UNIFORM_BUFFER_STRUCT_MEMBER(uint32, Degree)
BEGIN_UNIFORM_BUFFER_STRUCT(FSplineComputeShaderUniformParameters, )
DECLARE_UNIFORM_BUFFER_STRUCT_MEMBER(float, WorldSize)
DECLARE_UNIFORM_BUFFER_STRUCT_MEMBER(float, Width)
DECLARE_UNIFORM_BUFFER_STRUCT_MEMBER(uint32, NumSides)
END_UNIFORM_BUFFER_STRUCT(FSplineComputeShaderUniformParameters)
BEGIN_GLOBAL_SHADER_PARAMETER_STRUCT(FSplineComputeShaderUniformParameters, )
SHADER_PARAMETER(float, WorldSize)
SHADER_PARAMETER(float, Width)
SHADER_PARAMETER(uint32, NumSides)
END_GLOBAL_SHADER_PARAMETER_STRUCT()

typedef TUniformBufferRef<FSplineComputeShaderUniformParameters>
FSplineComputeShaderUniformParametersRef;
Expand All @@ -31,10 +31,10 @@ class SPLINERENDERER_API FBaseSplineComputeShader : public FGlobalShader
return RHISupportsComputeShaders(Platform);
}

static void ModifyCompilationEnvironment(EShaderPlatform Platform,
static void ModifyCompilationEnvironment(const FGlobalShaderPermutationParameters& Parameters,
FShaderCompilerEnvironment& OutEnvironment)
{
FGlobalShader::ModifyCompilationEnvironment(Platform, OutEnvironment);
FGlobalShader::ModifyCompilationEnvironment(Parameters, OutEnvironment);
OutEnvironment.SetDefine(TEXT("SPLINE_COMPUTE_SHADER_MAX_SAMPLES_PER_SEGMENT"), 64);
}

Expand Down Expand Up @@ -78,4 +78,8 @@ class SPLINERENDERER_API FSplineComputeShader_Sphere : public FBaseSplineCompute

explicit FSplineComputeShader_Sphere(
ShaderMetaType::CompiledShaderInitializerType const& Initializer);

static bool ShouldCompilePermutation(const FGlobalShaderPermutationParameters& PermutationParams) {
return true;
}
};
9 changes: 5 additions & 4 deletions Plugins/SplineRenderer/Source/SplineRenderer.Build.cs
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
using System.IO;

namespace UnrealBuildTool.Rules
{
public class SplineRenderer : ModuleRules
{
public SplineRenderer(ReadOnlyTargetRules Target) : base(Target)
{
PrivateIncludePaths.AddRange(new string[] {
"SplineRenderer/Private",
});
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;

PublicDependencyModuleNames.AddRange(new string[] {
"Core",
"CoreUObject",
"Engine",
"RenderCore",
"ShaderCore",
"RHI"
});

PublicIncludePaths.Add(Path.Combine(ModuleDirectory, "Public"));
}
}
}
2 changes: 1 addition & 1 deletion Source/ImsvGraphVis/IGVEdgeMeshComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ UIGVEdgeMeshComponent::UIGVEdgeMeshComponent()
SplineControlPointData(),
SplineSegmentData(),
SplineData(),
NumMeshVertices(0),
NumMeshIndices(0),
NumMeshVertices(0),
MeshIndices(),
MaterialInstance(nullptr)
{
Expand Down
44 changes: 32 additions & 12 deletions Source/ImsvGraphVis/IGVEdgeMeshSceneProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,13 @@ void FIGVEdgeMeshVertexFactory::Init(FVertexBuffer* VertexBuffer)
}
else
{
ENQUEUE_UNIQUE_RENDER_COMMAND_TWOPARAMETER(
InitMeshVertexFactory, FIGVEdgeMeshVertexFactory*, VertexFactory, this,
const FVertexBuffer*, VertexBuffer, VertexBuffer,
{ VertexFactory->Init_RenderThread(VertexBuffer); });
FIGVEdgeMeshVertexFactory* VertexFactory = this;
ENQUEUE_RENDER_COMMAND(InitMeshVertexFactory)(
[VertexBuffer, VertexFactory](FRHICommandListImmediate& RHICmdList)
{
(void)RHICmdList;
VertexFactory->Init_RenderThread(VertexBuffer);
});
}
}

Expand Down Expand Up @@ -87,11 +90,12 @@ FIGVEdgeMeshSceneProxy::FIGVEdgeMeshSceneProxy(UIGVEdgeMeshComponent* const Comp

VertexBuffer(Component->NumMeshVertices),
IndexBuffer(Component->MeshIndices),
VertexFactory(ERHIFeatureLevel::SM5),

Material(Component->GetMaterial(0)),
MaterialRelevance(Component->GetMaterialRelevance(GetScene().GetFeatureLevel())),
WireframeMaterial(GEngine->WireframeMaterial
? GEngine->WireframeMaterial->GetRenderProxy(IsSelected())
? GEngine->WireframeMaterial->GetRenderProxy()
: nullptr,
FLinearColor::White)
{
Expand All @@ -114,8 +118,10 @@ FIGVEdgeMeshSceneProxy::FIGVEdgeMeshSceneProxy(UIGVEdgeMeshComponent* const Comp

void FIGVEdgeMeshSceneProxy::OnTransformChanged()
{
FBoxSphereBounds PreSkinnedLocalBounds;
GetPreSkinnedLocalBounds(PreSkinnedLocalBounds);
PrimitiveUniformBuffer = CreatePrimitiveUniformBufferImmediate(
GetLocalToWorld(), GetBounds(), GetLocalBounds(), true, UseEditorDepthTest());
GetLocalToWorld(), GetBounds(), GetLocalBounds(), PreSkinnedLocalBounds, ReceivesDecals(), DrawsVelocity(), LpvBiasMultiplier);
}

bool FIGVEdgeMeshSceneProxy::CanBeOccluded() const
Expand All @@ -142,9 +148,13 @@ void FIGVEdgeMeshSceneProxy::SendRenderDynamicData()
// TODO: is this required code?
IndexBuffer.Indices = IGVEdgeMeshComponent->MeshIndices;

ENQUEUE_UNIQUE_RENDER_COMMAND_ONEPARAMETER(FSendIGVEdgeMeshSceneProxyDynamicData,
FIGVEdgeMeshSceneProxy&, Self, *this,
{ Self.SendRenderDynamicData_RenderThread(); });
FIGVEdgeMeshSceneProxy* Self = this;
ENQUEUE_RENDER_COMMAND(InitMeshVertexFactory)(
[Self](FRHICommandListImmediate& RHICmdList)
{
(void)RHICmdList;
Self->SendRenderDynamicData_RenderThread();
});

ComputeMesh();
}
Expand Down Expand Up @@ -228,7 +238,7 @@ void FIGVEdgeMeshSceneProxy::SetMesh(FMeshBatch& Mesh, bool const bWireframe) co
Mesh.bWireframe = bWireframe;
Mesh.VertexFactory = &VertexFactory;
Mesh.MaterialRenderProxy =
!bWireframe ? Material->GetRenderProxy(IsSelected()) : &WireframeMaterial;
!bWireframe ? Material->GetRenderProxy() : &WireframeMaterial;
}

int32 FIGVEdgeMeshSceneProxy::SetMeshBatchElements(FMeshBatch& Mesh, bool const bWireframe) const
Expand Down Expand Up @@ -295,6 +305,11 @@ void FIGVEdgeMeshSceneProxy::SetMeshBatchElement(FMeshBatchElement& BatchElement
MeshData->VertexBufferOffset[RenderGroup] + MeshData->VertexBufferSize[RenderGroup] - 1;
}

SIZE_T FIGVEdgeMeshSceneProxy::GetTypeHash() const {
static size_t UniquePointer;
return reinterpret_cast<size_t>(&UniquePointer);
}

void FIGVEdgeMeshSceneProxy::ReleaseBuffers()
{
if (InSplineControlPointBuffer != nullptr)
Expand Down Expand Up @@ -385,8 +400,13 @@ void FIGVEdgeMeshSceneProxy::ComputeMesh()
SplineComputeShaderUniformParameters.Width = GraphActor->EdgeWidth * 0.5;
SplineComputeShaderUniformParameters.NumSides = GraphActor->EdgeNumSides;

ENQUEUE_UNIQUE_RENDER_COMMAND_ONEPARAMETER(FSendIGVEdgeMeshDynamicData, FIGVEdgeMeshSceneProxy&,
Self, *this, { Self.ComputeMesh_RenderThread(); });
FIGVEdgeMeshSceneProxy* Self = this;
ENQUEUE_RENDER_COMMAND(FSendIGVEdgeMeshDynamicData)(
[Self](FRHICommandListImmediate& RHICmdList)
{
(void)RHICmdList;
Self->ComputeMesh_RenderThread();
});
}

void FIGVEdgeMeshSceneProxy::ComputeMesh_RenderThread()
Expand Down
7 changes: 7 additions & 0 deletions Source/ImsvGraphVis/IGVEdgeMeshSceneProxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ class IMSVGRAPHVIS_API FIGVEdgeMeshVertexBuffer : public FVertexBuffer
class IMSVGRAPHVIS_API FIGVEdgeMeshVertexFactory : public FLocalVertexFactory
{
public:
FIGVEdgeMeshVertexFactory(ERHIFeatureLevel::Type InFeatureLevel)
: FLocalVertexFactory(InFeatureLevel, "FIGVEdgeMeshVertexFactory")
{
}

void Init(FVertexBuffer* VertexBuffer);
void Init_RenderThread(const FVertexBuffer* VertexBuffer);
};
Expand Down Expand Up @@ -84,6 +89,8 @@ class IMSVGRAPHVIS_API FIGVEdgeMeshSceneProxy : public FPrimitiveSceneProxy
void SetMeshBatchElement(FMeshBatchElement& BatchElement,
FIGVEdgeMeshData* const MeshData) const;

virtual SIZE_T GetTypeHash() const override;

private:
void ReleaseBuffers();
void CreateBuffers();
Expand Down
1 change: 0 additions & 1 deletion Source/ImsvGraphVis/ImsvGraphVis.Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ public ImsvGraphVis(ReadOnlyTargetRules Target) : base(Target)
"RenderCore",
"Renderer",
"RHI",
"ShaderCore",
"SplineRenderer",
"Slate",
"SlateCore"
Expand Down
19 changes: 13 additions & 6 deletions Source/ImsvGraphVis/KWMeshElement.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@ class FResourceArrayIndexBuffer : public FIndexBuffer
class FMeshVertexFactory : public FLocalVertexFactory
{
public:
FMeshVertexFactory()
FMeshVertexFactory(ERHIFeatureLevel::Type InFeatureLevel)
: FLocalVertexFactory(InFeatureLevel, "FMeshVertexFactory")
{
}

Expand Down Expand Up @@ -205,10 +206,13 @@ class FMeshVertexFactory : public FLocalVertexFactory
}
else
{
ENQUEUE_UNIQUE_RENDER_COMMAND_TWOPARAMETER(
InitMeshVertexFactory, FMeshVertexFactory*, VertexFactory, this,
const FVertexBuffer*, VertexBuffer, VertexBuffer,
{ VertexFactory->Init_RenderThread(VertexBuffer); });
FMeshVertexFactory* VertexFactory = this;
ENQUEUE_RENDER_COMMAND(InitMeshVertexFactory)(
[VertexBuffer, VertexFactory](FRHICommandListImmediate& RHICmdList)
{
(void)RHICmdList;
VertexFactory->Init_RenderThread(VertexBuffer);
});
}
}
};
Expand Down Expand Up @@ -240,6 +244,7 @@ class FMeshSceneProxy : public FPrimitiveSceneProxy
BufferUsage(InBufferUsage),
VertexBuffer(Vertices, BufferUsage),
IndexBuffer(Indices, BufferUsage),
VertexFactory(ERHIFeatureLevel::ES3_1),
Material(Component->GetMaterial(0)),
MaterialRelevance(Component->GetMaterialRelevance(GetScene().GetFeatureLevel()))
{
Expand All @@ -262,8 +267,10 @@ class FMeshSceneProxy : public FPrimitiveSceneProxy

virtual void OnTransformChanged() override
{
FBoxSphereBounds PreSkinnedLocalBounds;
GetPreSkinnedLocalBounds(PreSkinnedLocalBounds);
PrimitiveUniformBuffer = CreatePrimitiveUniformBufferImmediate(
GetLocalToWorld(), GetBounds(), GetLocalBounds(), true, UseEditorDepthTest());
GetLocalToWorld(), GetBounds(), GetLocalBounds(), PreSkinnedLocalBounds, ReceivesDecals(), DrawsVelocity(), LpvBiasMultiplier);
}

virtual bool CanBeOccluded() const override
Expand Down