Refactor enum flags with __underlying_type and new EnumHasAnyFlags/EnumHasAllFlags
Fixes #832 Closes #886
This commit is contained in:
@@ -562,7 +562,7 @@ bool GameCookerImpl::Build()
|
||||
{
|
||||
if (GameCooker::IsCancelRequested())
|
||||
break;
|
||||
if (data.Options & BuildOptions::NoCook)
|
||||
if (EnumHasAnyFlags(data.Options, BuildOptions::NoCook))
|
||||
continue;
|
||||
auto step = Steps[stepIndex];
|
||||
data.NextStep();
|
||||
@@ -587,12 +587,12 @@ bool GameCookerImpl::Build()
|
||||
{
|
||||
LOG(Info, "Game building done!");
|
||||
|
||||
if (data.Options & BuildOptions::ShowOutput)
|
||||
if (EnumHasAnyFlags(data.Options, BuildOptions::ShowOutput))
|
||||
{
|
||||
FileSystem::ShowFileExplorer(data.OriginalOutputPath);
|
||||
}
|
||||
|
||||
if (data.Options & BuildOptions::AutoRun)
|
||||
if (EnumHasAnyFlags(data.Options, BuildOptions::AutoRun))
|
||||
{
|
||||
String executableFile, commandLineFormat, workingDir;
|
||||
data.Tools->OnRun(data, executableFile, commandLineFormat, workingDir);
|
||||
|
||||
@@ -63,7 +63,7 @@ ViewportIconsRendererService ViewportIconsRendererServiceInstance;
|
||||
void ViewportIconsRenderer::DrawIcons(RenderContext& renderContext, Actor* actor)
|
||||
{
|
||||
auto& view = renderContext.View;
|
||||
if (!actor || (view.Flags & ViewFlags::EditorSprites) == 0 || QuadModel == nullptr || !QuadModel->IsLoaded())
|
||||
if (!actor || (view.Flags & ViewFlags::EditorSprites) == ViewFlags::None || QuadModel == nullptr || !QuadModel->IsLoaded())
|
||||
return;
|
||||
|
||||
Mesh::DrawInfo draw;
|
||||
|
||||
@@ -17,7 +17,7 @@ void AnimEvent::Serialize(SerializeStream& stream, const void* otherObj)
|
||||
|
||||
#if !COMPILE_WITHOUT_CSHARP
|
||||
// Handle C# objects data serialization
|
||||
if (Flags & ObjectFlags::IsManagedType)
|
||||
if (EnumHasAnyFlags(Flags, ObjectFlags::IsManagedType))
|
||||
{
|
||||
stream.JKEY("V");
|
||||
if (other)
|
||||
@@ -32,7 +32,7 @@ void AnimEvent::Serialize(SerializeStream& stream, const void* otherObj)
|
||||
#endif
|
||||
|
||||
// Handle custom scripting objects data serialization
|
||||
if (Flags & ObjectFlags::IsCustomScriptingType)
|
||||
if (EnumHasAnyFlags(Flags, ObjectFlags::IsCustomScriptingType))
|
||||
{
|
||||
stream.JKEY("D");
|
||||
_type.Module->SerializeObject(stream, this, other);
|
||||
@@ -43,7 +43,7 @@ void AnimEvent::Deserialize(DeserializeStream& stream, ISerializeModifier* modif
|
||||
{
|
||||
#if !COMPILE_WITHOUT_CSHARP
|
||||
// Handle C# objects data serialization
|
||||
if (Flags & ObjectFlags::IsManagedType)
|
||||
if (EnumHasAnyFlags(Flags, ObjectFlags::IsManagedType))
|
||||
{
|
||||
auto* const v = SERIALIZE_FIND_MEMBER(stream, "V");
|
||||
if (v != stream.MemberEnd() && v->value.IsObject() && v->value.MemberCount() != 0)
|
||||
@@ -54,7 +54,7 @@ void AnimEvent::Deserialize(DeserializeStream& stream, ISerializeModifier* modif
|
||||
#endif
|
||||
|
||||
// Handle custom scripting objects data serialization
|
||||
if (Flags & ObjectFlags::IsCustomScriptingType)
|
||||
if (EnumHasAnyFlags(Flags, ObjectFlags::IsCustomScriptingType))
|
||||
{
|
||||
auto* const v = SERIALIZE_FIND_MEMBER(stream, "D");
|
||||
if (v != stream.MemberEnd() && v->value.IsObject() && v->value.MemberCount() != 0)
|
||||
|
||||
@@ -1517,7 +1517,7 @@ void AnimGraphExecutor::ProcessGroupAnimation(Box* boxBase, Node* nodeBase, Valu
|
||||
const uint16 idx = stateData.Transitions[transitionIndex];
|
||||
ASSERT(idx < data.Graph->StateTransitions.Count());
|
||||
auto& transition = data.Graph->StateTransitions[idx];
|
||||
const bool useDefaultRule = (transition.Flags & AnimGraphStateTransition::FlagTypes::UseDefaultRule) != 0;
|
||||
const bool useDefaultRule = EnumHasAnyFlags(transition.Flags, AnimGraphStateTransition::FlagTypes::UseDefaultRule);
|
||||
if (transition.RuleGraph && !useDefaultRule)
|
||||
{
|
||||
// Execute transition rule
|
||||
@@ -1569,7 +1569,7 @@ void AnimGraphExecutor::ProcessGroupAnimation(Box* boxBase, Node* nodeBase, Valu
|
||||
|
||||
// Skip after Solo transition
|
||||
// TODO: don't load transitions after first enabled Solo transition and remove this check here
|
||||
if ((transition.Flags & AnimGraphStateTransition::FlagTypes::Solo) != 0)
|
||||
if (EnumHasAnyFlags(transition.Flags, AnimGraphStateTransition::FlagTypes::Solo))
|
||||
break;
|
||||
|
||||
transitionIndex++;
|
||||
|
||||
@@ -424,8 +424,8 @@ void Material::InitCompilationOptions(ShaderCompilationOptions& options)
|
||||
const bool useDistortion =
|
||||
(info.Domain == MaterialDomain::Surface || info.Domain == MaterialDomain::Deformable || info.Domain == MaterialDomain::Particle) &&
|
||||
info.BlendMode != MaterialBlendMode::Opaque &&
|
||||
(info.UsageFlags & MaterialUsageFlags::UseRefraction) != 0 &&
|
||||
(info.FeaturesFlags & MaterialFeaturesFlags::DisableDistortion) == 0;
|
||||
EnumHasAnyFlags(info.UsageFlags, MaterialUsageFlags::UseRefraction) &&
|
||||
(info.FeaturesFlags & MaterialFeaturesFlags::DisableDistortion) == MaterialFeaturesFlags::None;
|
||||
|
||||
// @formatter:off
|
||||
static const char* Numbers[] =
|
||||
@@ -438,22 +438,22 @@ void Material::InitCompilationOptions(ShaderCompilationOptions& options)
|
||||
options.Macros.Add({ "MATERIAL_DOMAIN", Numbers[(int32)info.Domain] });
|
||||
options.Macros.Add({ "MATERIAL_BLEND", Numbers[(int32)info.BlendMode] });
|
||||
options.Macros.Add({ "MATERIAL_SHADING_MODEL", Numbers[(int32)info.ShadingModel] });
|
||||
options.Macros.Add({ "MATERIAL_MASKED", Numbers[info.UsageFlags & MaterialUsageFlags::UseMask ? 1 : 0] });
|
||||
options.Macros.Add({ "MATERIAL_MASKED", Numbers[EnumHasAnyFlags(info.UsageFlags, MaterialUsageFlags::UseMask) ? 1 : 0] });
|
||||
options.Macros.Add({ "DECAL_BLEND_MODE", Numbers[(int32)info.DecalBlendingMode] });
|
||||
options.Macros.Add({ "USE_EMISSIVE", Numbers[info.UsageFlags & MaterialUsageFlags::UseEmissive ? 1 : 0] });
|
||||
options.Macros.Add({ "USE_NORMAL", Numbers[info.UsageFlags & MaterialUsageFlags::UseNormal ? 1 : 0] });
|
||||
options.Macros.Add({ "USE_POSITION_OFFSET", Numbers[info.UsageFlags & MaterialUsageFlags::UsePositionOffset ? 1 : 0] });
|
||||
options.Macros.Add({ "USE_VERTEX_COLOR", Numbers[info.UsageFlags & MaterialUsageFlags::UseVertexColor ? 1 : 0] });
|
||||
options.Macros.Add({ "USE_DISPLACEMENT", Numbers[info.UsageFlags & MaterialUsageFlags::UseDisplacement ? 1 : 0] });
|
||||
options.Macros.Add({ "USE_DITHERED_LOD_TRANSITION", Numbers[info.FeaturesFlags & MaterialFeaturesFlags::DitheredLODTransition ? 1 : 0] });
|
||||
options.Macros.Add({ "USE_EMISSIVE", Numbers[EnumHasAnyFlags(info.UsageFlags, MaterialUsageFlags::UseEmissive) ? 1 : 0] });
|
||||
options.Macros.Add({ "USE_NORMAL", Numbers[EnumHasAnyFlags(info.UsageFlags, MaterialUsageFlags::UseNormal) ? 1 : 0] });
|
||||
options.Macros.Add({ "USE_POSITION_OFFSET", Numbers[EnumHasAnyFlags(info.UsageFlags, MaterialUsageFlags::UsePositionOffset) ? 1 : 0] });
|
||||
options.Macros.Add({ "USE_VERTEX_COLOR", Numbers[EnumHasAnyFlags(info.UsageFlags, MaterialUsageFlags::UseVertexColor) ? 1 : 0] });
|
||||
options.Macros.Add({ "USE_DISPLACEMENT", Numbers[EnumHasAnyFlags(info.UsageFlags, MaterialUsageFlags::UseDisplacement) ? 1 : 0] });
|
||||
options.Macros.Add({ "USE_DITHERED_LOD_TRANSITION", Numbers[EnumHasAnyFlags(info.FeaturesFlags, MaterialFeaturesFlags::DitheredLODTransition) ? 1 : 0] });
|
||||
options.Macros.Add({ "USE_GBUFFER_CUSTOM_DATA", Numbers[useCustomData ? 1 : 0] });
|
||||
options.Macros.Add({ "USE_REFLECTIONS", Numbers[info.FeaturesFlags & MaterialFeaturesFlags::DisableReflections ? 0 : 1] });
|
||||
if (!(info.FeaturesFlags & MaterialFeaturesFlags::DisableReflections) && info.FeaturesFlags & MaterialFeaturesFlags::ScreenSpaceReflections)
|
||||
options.Macros.Add({ "USE_REFLECTIONS", Numbers[EnumHasAnyFlags(info.FeaturesFlags, MaterialFeaturesFlags::DisableReflections) ? 0 : 1] });
|
||||
if (!(info.FeaturesFlags & MaterialFeaturesFlags::DisableReflections) && EnumHasAnyFlags(info.FeaturesFlags, MaterialFeaturesFlags::ScreenSpaceReflections))
|
||||
options.Macros.Add({ "MATERIAL_REFLECTIONS", Numbers[1] });
|
||||
options.Macros.Add({ "USE_FOG", Numbers[info.FeaturesFlags & MaterialFeaturesFlags::DisableFog ? 0 : 1] });
|
||||
options.Macros.Add({ "USE_FOG", Numbers[EnumHasAnyFlags(info.FeaturesFlags, MaterialFeaturesFlags::DisableFog) ? 0 : 1] });
|
||||
if (useForward)
|
||||
{
|
||||
options.Macros.Add({ "USE_PIXEL_NORMAL_OFFSET_REFRACTION", Numbers[info.FeaturesFlags & MaterialFeaturesFlags::PixelNormalOffsetRefraction ? 1 : 0] });
|
||||
options.Macros.Add({ "USE_PIXEL_NORMAL_OFFSET_REFRACTION", Numbers[EnumHasAnyFlags(info.FeaturesFlags, MaterialFeaturesFlags::PixelNormalOffsetRefraction) ? 1 : 0] });
|
||||
switch (info.TransparentLightingMode)
|
||||
{
|
||||
case MaterialTransparentLightingMode::Surface:
|
||||
|
||||
@@ -97,7 +97,7 @@ void AssetsCache::Init()
|
||||
stream->Read(tmp1);
|
||||
#endif
|
||||
|
||||
if (flags & AssetsCacheFlags::RelativePaths && e.Info.Path.HasChars())
|
||||
if (EnumHasAnyFlags(flags, AssetsCacheFlags::RelativePaths) && e.Info.Path.HasChars())
|
||||
{
|
||||
// Convert to absolute path
|
||||
e.Info.Path = Globals::StartupFolder / e.Info.Path;
|
||||
@@ -125,7 +125,7 @@ void AssetsCache::Init()
|
||||
String mappedPath;
|
||||
stream->ReadString(&mappedPath, i + 73);
|
||||
|
||||
if (flags & AssetsCacheFlags::RelativePaths && mappedPath.HasChars())
|
||||
if (EnumHasAnyFlags(flags, AssetsCacheFlags::RelativePaths) && mappedPath.HasChars())
|
||||
{
|
||||
// Convert to absolute path
|
||||
mappedPath = Globals::StartupFolder / mappedPath;
|
||||
|
||||
@@ -651,7 +651,7 @@ bool FlaxStorage::LoadAssetChunk(FlaxChunk* chunk)
|
||||
|
||||
// Load data
|
||||
auto size = chunk->LocationInFile.Size;
|
||||
if (chunk->Flags & FlaxChunkFlags::CompressedLZ4)
|
||||
if (EnumHasAnyFlags(chunk->Flags, FlaxChunkFlags::CompressedLZ4))
|
||||
{
|
||||
// Compressed
|
||||
size -= sizeof(int32); // Don't count original size int
|
||||
@@ -861,7 +861,7 @@ bool FlaxStorage::Create(WriteStream* stream, const AssetInitData* data, int32 d
|
||||
for (int32 i = 0; i < chunksCount; i++)
|
||||
{
|
||||
const FlaxChunk* chunk = chunks[i];
|
||||
if (chunk->Flags & FlaxChunkFlags::CompressedLZ4)
|
||||
if (EnumHasAnyFlags(chunk->Flags, FlaxChunkFlags::CompressedLZ4))
|
||||
{
|
||||
PROFILE_CPU_NAMED("CompressLZ4");
|
||||
const int32 srcSize = chunk->Data.Length();
|
||||
|
||||
@@ -42,7 +42,6 @@ public:
|
||||
/// <summary>
|
||||
/// Gets the string representation of this object.
|
||||
/// </summary>
|
||||
/// <returns>The string.</returns>
|
||||
virtual String ToString() const = 0;
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -113,7 +113,7 @@ void ObjectsRemovalService::Flush(float dt, float gameDelta)
|
||||
for (auto i = Pool.Begin(); i.IsNotEnd(); ++i)
|
||||
{
|
||||
auto obj = i->Key;
|
||||
const float ttl = i->Value - (obj->Flags & ObjectFlags::UseGameTimeForDelete ? gameDelta : dt);
|
||||
const float ttl = i->Value - ((obj->Flags & ObjectFlags::UseGameTimeForDelete) != ObjectFlags::None ? gameDelta : dt);
|
||||
if (ttl <= ZeroTolerance)
|
||||
{
|
||||
Pool.Remove(i);
|
||||
|
||||
@@ -141,13 +141,28 @@ struct Color32;
|
||||
|
||||
// Declares full set of operators for the enum type (using binary operation on integer values)
|
||||
#define DECLARE_ENUM_OPERATORS(T) \
|
||||
inline constexpr T operator~ (T a) { return (T)~(int)a; } \
|
||||
inline constexpr T operator| (T a, T b) { return (T)((int)a | (int)b); } \
|
||||
inline constexpr int operator& (T a, T b) { return ((int)a & (int)b); } \
|
||||
inline constexpr T operator^ (T a, T b) { return (T)((int)a ^ (int)b); } \
|
||||
inline T& operator|= (T& a, T b) { return (T&)((int&)a |= (int)b); } \
|
||||
inline T& operator&= (T& a, T b) { return (T&)((int&)a &= (int)b); } \
|
||||
inline T& operator^= (T& a, T b) { return (T&)((int&)a ^= (int)b); }
|
||||
inline constexpr bool operator!(T a) { return !(__underlying_type(T))a; } \
|
||||
inline constexpr T operator~(T a) { return (T)~(__underlying_type(T))a; } \
|
||||
inline constexpr T operator|(T a, T b) { return (T)((__underlying_type(T))a | (__underlying_type(T))b); } \
|
||||
inline constexpr T operator&(T a, T b) { return (T)((__underlying_type(T))a & (__underlying_type(T))b); } \
|
||||
inline constexpr T operator^(T a, T b) { return (T)((__underlying_type(T))a ^ (__underlying_type(T))b); } \
|
||||
inline T& operator|=(T& a, T b) { return a = (T)((__underlying_type(T))a | (__underlying_type(T))b); } \
|
||||
inline T& operator&=(T& a, T b) { return a = (T)((__underlying_type(T))a & (__underlying_type(T))b); } \
|
||||
inline T& operator^=(T& a, T b) { return a = (T)((__underlying_type(T))a ^ (__underlying_type(T))b); }
|
||||
|
||||
// Returns true if given enum value has one or more enum flags set
|
||||
template<typename T>
|
||||
constexpr bool EnumHasAnyFlags(T value, T flags)
|
||||
{
|
||||
return ((__underlying_type(T))value & (__underlying_type(T))flags) != 0;
|
||||
}
|
||||
|
||||
// Returns true if given enum value has all of the enum flags set
|
||||
template<typename T>
|
||||
constexpr bool EnumHasAllFlags(T value, T flags)
|
||||
{
|
||||
return ((__underlying_type(T))value & (__underlying_type(T))flags) == (__underlying_type(T))flags;
|
||||
}
|
||||
|
||||
// Returns byte offset from the object pointer in vtable to the begin of the given inherited type implementation
|
||||
#define VTABLE_OFFSET(type, baseType) (((intptr)static_cast<baseType*>((type*)1))-1)
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#include "Engine/Serialization/Serialization.h"
|
||||
#include "Engine/Utilities/Encryption.h"
|
||||
|
||||
#define FOLIAGE_GET_DRAW_MODES(renderContext, type) static_cast<DrawPass>(type.DrawModes & renderContext.View.Pass & (int32)renderContext.View.GetShadowsDrawPassMask(type.ShadowsMode))
|
||||
#define FOLIAGE_GET_DRAW_MODES(renderContext, type) (type.DrawModes & renderContext.View.Pass & renderContext.View.GetShadowsDrawPassMask(type.ShadowsMode))
|
||||
#define FOLIAGE_CAN_DRAW(renderContext, type) (type.IsReady() && FOLIAGE_GET_DRAW_MODES(renderContext, type) != DrawPass::None && type.Model->CanBeRendered())
|
||||
|
||||
Foliage::Foliage(const SpawnParams& params)
|
||||
@@ -115,7 +115,7 @@ void Foliage::DrawInstance(RenderContext& renderContext, FoliageInstance& instan
|
||||
e = &result[key];
|
||||
ASSERT_LOW_LAYER(key.Mat);
|
||||
e->DrawCall.Material = key.Mat;
|
||||
e->DrawCall.Surface.Lightmap = _staticFlags & StaticFlags::Lightmap ? _scene->LightmapsData.GetReadyLightmap(key.Lightmap) : nullptr;
|
||||
e->DrawCall.Surface.Lightmap = EnumHasAnyFlags(_staticFlags, StaticFlags::Lightmap) ? _scene->LightmapsData.GetReadyLightmap(key.Lightmap) : nullptr;
|
||||
}
|
||||
|
||||
// Add instance to the draw batch
|
||||
@@ -450,9 +450,9 @@ void Foliage::DrawType(RenderContext& renderContext, const FoliageType& type, Dr
|
||||
continue;
|
||||
|
||||
// Select draw modes
|
||||
const auto shadowsMode = static_cast<ShadowsCastingMode>(entry.ShadowsMode & slot.ShadowsMode);
|
||||
const auto drawModes = static_cast<DrawPass>(typeDrawModes & renderContext.View.GetShadowsDrawPassMask(shadowsMode)) & material->GetDrawModes();
|
||||
if (drawModes == 0)
|
||||
const auto shadowsMode = entry.ShadowsMode & slot.ShadowsMode;
|
||||
const auto drawModes = typeDrawModes & renderContext.View.GetShadowsDrawPassMask(shadowsMode) & material->GetDrawModes();
|
||||
if (drawModes == DrawPass::None)
|
||||
continue;
|
||||
|
||||
drawCall.DrawCall.Material = material;
|
||||
@@ -472,8 +472,8 @@ void Foliage::DrawType(RenderContext& renderContext, const FoliageType& type, Dr
|
||||
const auto& mesh = *e.Key.Geo;
|
||||
const auto& entry = type.Entries[mesh.GetMaterialSlotIndex()];
|
||||
const MaterialSlot& slot = type.Model->MaterialSlots[mesh.GetMaterialSlotIndex()];
|
||||
const auto shadowsMode = static_cast<ShadowsCastingMode>(entry.ShadowsMode & slot.ShadowsMode);
|
||||
const auto drawModes = (DrawPass)(static_cast<DrawPass>(typeDrawModes & renderContext.View.GetShadowsDrawPassMask(shadowsMode)) & batch.DrawCall.Material->GetDrawModes());
|
||||
const auto shadowsMode = entry.ShadowsMode & slot.ShadowsMode;
|
||||
const auto drawModes = typeDrawModes & renderContext.View.GetShadowsDrawPassMask(shadowsMode) & batch.DrawCall.Material->GetDrawModes();
|
||||
|
||||
// Setup draw call
|
||||
mesh.GetDrawCallGeometry(batch.DrawCall);
|
||||
@@ -493,7 +493,7 @@ void Foliage::DrawType(RenderContext& renderContext, const FoliageType& type, Dr
|
||||
batch.DrawCall.Surface.Skinning = nullptr;
|
||||
batch.DrawCall.WorldDeterminantSign = 1;
|
||||
|
||||
if (drawModes & DrawPass::Forward)
|
||||
if (EnumHasAnyFlags(drawModes, DrawPass::Forward))
|
||||
{
|
||||
// Transparency requires sorting by depth so convert back the batched draw call into normal draw calls (RenderList impl will handle this)
|
||||
DrawCall drawCall = batch.DrawCall;
|
||||
@@ -518,22 +518,22 @@ void Foliage::DrawType(RenderContext& renderContext, const FoliageType& type, Dr
|
||||
const int32 batchIndex = renderContext.List->BatchedDrawCalls.Add(MoveTemp(batch));
|
||||
|
||||
// Add draw call to proper draw lists
|
||||
if (drawModes & DrawPass::Depth)
|
||||
if (EnumHasAnyFlags(drawModes, DrawPass::Depth))
|
||||
{
|
||||
renderContext.List->DrawCallsLists[(int32)DrawCallsListType::Depth].PreBatchedDrawCalls.Add(batchIndex);
|
||||
}
|
||||
if (drawModes & DrawPass::GBuffer)
|
||||
if (EnumHasAnyFlags(drawModes, DrawPass::GBuffer))
|
||||
{
|
||||
if (entry.ReceiveDecals)
|
||||
renderContext.List->DrawCallsLists[(int32)DrawCallsListType::GBuffer].PreBatchedDrawCalls.Add(batchIndex);
|
||||
else
|
||||
renderContext.List->DrawCallsLists[(int32)DrawCallsListType::GBufferNoDecals].PreBatchedDrawCalls.Add(batchIndex);
|
||||
}
|
||||
if (drawModes & DrawPass::Distortion)
|
||||
if (EnumHasAnyFlags(drawModes, DrawPass::Distortion))
|
||||
{
|
||||
renderContext.List->DrawCallsLists[(int32)DrawCallsListType::Distortion].PreBatchedDrawCalls.Add(batchIndex);
|
||||
}
|
||||
if (drawModes & DrawPass::MotionVectors && (_staticFlags & StaticFlags::Transform) == 0)
|
||||
if (EnumHasAnyFlags(drawModes, DrawPass::MotionVectors) && (_staticFlags & StaticFlags::Transform) == StaticFlags::None)
|
||||
{
|
||||
renderContext.List->DrawCallsLists[(int32)DrawCallsListType::MotionVectors].PreBatchedDrawCalls.Add(batchIndex);
|
||||
}
|
||||
@@ -1053,7 +1053,7 @@ bool Foliage::Intersects(const Ray& ray, Real& distance, Vector3& normal, int32&
|
||||
Real tmpDistance;
|
||||
Vector3 tmpNormal;
|
||||
FoliageInstance* tmpInstance;
|
||||
for (auto& type : FoliageTypes)
|
||||
for (const auto& type : FoliageTypes)
|
||||
{
|
||||
if (type.Root && type.Root->Intersects(this, ray, tmpDistance, tmpNormal, tmpInstance) && tmpDistance < distance)
|
||||
{
|
||||
@@ -1155,7 +1155,7 @@ void Foliage::Draw(RenderContext& renderContext)
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
if (renderContext.View.Pass & DrawPass::GlobalSurfaceAtlas)
|
||||
if (EnumHasAnyFlags(renderContext.View.Pass, DrawPass::GlobalSurfaceAtlas))
|
||||
{
|
||||
// Draw single foliage instance projection into Global Surface Atlas
|
||||
auto& instance = *(FoliageInstance*)GlobalSurfaceAtlasPass::Instance()->GetCurrentActorObject();
|
||||
@@ -1181,7 +1181,7 @@ void Foliage::Draw(RenderContext& renderContext)
|
||||
draw.DrawState = &instance.DrawState;
|
||||
draw.Bounds = instance.Bounds;
|
||||
draw.PerInstanceRandom = instance.Random;
|
||||
draw.DrawModes = static_cast<DrawPass>(type.DrawModes & view.Pass & (int32)view.GetShadowsDrawPassMask(type.ShadowsMode));
|
||||
draw.DrawModes = type.DrawModes & view.Pass & view.GetShadowsDrawPassMask(type.ShadowsMode);
|
||||
type.Model->Draw(renderContext, draw);
|
||||
return;
|
||||
}
|
||||
@@ -1216,7 +1216,7 @@ void Foliage::Draw(RenderContextBatch& renderContextBatch)
|
||||
#if !FOLIAGE_USE_SINGLE_QUAD_TREE
|
||||
// Run async job for each foliage type
|
||||
const RenderView& view = renderContextBatch.GetMainContext().View;
|
||||
if ((view.Pass & DrawPass::GBuffer) && !(view.Pass & (DrawPass::GlobalSDF | DrawPass::GlobalSurfaceAtlas)) && renderContextBatch.EnableAsync)
|
||||
if (EnumHasAnyFlags(view.Pass, DrawPass::GBuffer) && !(view.Pass & (DrawPass::GlobalSDF | DrawPass::GlobalSurfaceAtlas)) && renderContextBatch.EnableAsync)
|
||||
{
|
||||
// Cache data per foliage instance type
|
||||
for (FoliageType& type : FoliageTypes)
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include "GPUBuffer.h"
|
||||
#include "GPUDevice.h"
|
||||
#include "GPUResourceProperty.h"
|
||||
#include "GPUBufferDescription.h"
|
||||
#include "PixelFormatExtensions.h"
|
||||
#include "Async/Tasks/GPUCopyResourceTask.h"
|
||||
@@ -10,9 +11,8 @@
|
||||
#include "Engine/Core/Types/DataContainer.h"
|
||||
#include "Engine/Debug/Exceptions/InvalidOperationException.h"
|
||||
#include "Engine/Debug/Exceptions/ArgumentNullException.h"
|
||||
#include "Engine/Threading/ThreadPoolTask.h"
|
||||
#include "Engine/Graphics/GPUResourceProperty.h"
|
||||
#include "Engine/Debug/Exceptions/ArgumentOutOfRangeException.h"
|
||||
#include "Engine/Threading/ThreadPoolTask.h"
|
||||
#include "Engine/Threading/Threading.h"
|
||||
|
||||
GPUBufferDescription GPUBufferDescription::Buffer(uint32 size, GPUBufferFlags flags, PixelFormat format, const void* initData, uint32 stride, GPUResourceUsage usage)
|
||||
@@ -91,7 +91,7 @@ String GPUBufferDescription::ToString() const
|
||||
{
|
||||
// TODO: create tool to auto convert flag enums to string
|
||||
|
||||
#define CONVERT_FLAGS_FLAGS_2_STR(value) if(Flags & GPUBufferFlags::value) { if (flags.HasChars()) flags += TEXT('|'); flags += TEXT(#value); }
|
||||
#define CONVERT_FLAGS_FLAGS_2_STR(value) if (EnumHasAnyFlags(Flags, GPUBufferFlags::value)) { if (flags.HasChars()) flags += TEXT('|'); flags += TEXT(#value); }
|
||||
CONVERT_FLAGS_FLAGS_2_STR(ShaderResource);
|
||||
CONVERT_FLAGS_FLAGS_2_STR(VertexBuffer);
|
||||
CONVERT_FLAGS_FLAGS_2_STR(IndexBuffer);
|
||||
@@ -149,7 +149,7 @@ bool GPUBuffer::Init(const GPUBufferDescription& desc)
|
||||
&& Math::IsInRange<uint32>(desc.Stride, 0, 1024));
|
||||
|
||||
// Validate description
|
||||
if (desc.Flags & GPUBufferFlags::Structured)
|
||||
if (EnumHasAnyFlags(desc.Flags, GPUBufferFlags::Structured))
|
||||
{
|
||||
if (desc.Stride <= 0)
|
||||
{
|
||||
@@ -157,7 +157,7 @@ bool GPUBuffer::Init(const GPUBufferDescription& desc)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (desc.Flags & GPUBufferFlags::RawBuffer)
|
||||
if (EnumHasAnyFlags(desc.Flags, GPUBufferFlags::RawBuffer))
|
||||
{
|
||||
if (desc.Format != PixelFormat::R32_Typeless)
|
||||
{
|
||||
|
||||
@@ -124,7 +124,7 @@ public:
|
||||
/// </summary>
|
||||
FORCE_INLINE bool IsShaderResource() const
|
||||
{
|
||||
return (Flags & GPUBufferFlags::ShaderResource) != 0;
|
||||
return (Flags & GPUBufferFlags::ShaderResource) != GPUBufferFlags::None;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -132,7 +132,7 @@ public:
|
||||
/// </summary>
|
||||
FORCE_INLINE bool IsUnorderedAccess() const
|
||||
{
|
||||
return (Flags & GPUBufferFlags::UnorderedAccess) != 0;
|
||||
return (Flags & GPUBufferFlags::UnorderedAccess) != GPUBufferFlags::None;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
@@ -173,12 +173,6 @@ API_ENUM(Attributes="Flags") enum class FormatSupport : int32
|
||||
|
||||
DECLARE_ENUM_OPERATORS(FormatSupport);
|
||||
|
||||
// Helper macro to check if given format does not support a given set of feature flags
|
||||
#define FORMAT_FEATURES_ARE_NOT_SUPPORTED(formatSupport, formatSupportFlags) ((formatSupport & (formatSupportFlags)) != static_cast<int>(formatSupportFlags))
|
||||
|
||||
// Helper macro to check if given format does support a given set of feature flags
|
||||
#define FORMAT_FEATURES_ARE_SUPPORTED(formatSupport, formatSupportFlags) ((formatSupport & (formatSupportFlags)) == static_cast<int>(formatSupportFlags))
|
||||
|
||||
/// <summary>
|
||||
/// The features exposed for a particular format.
|
||||
/// </summary>
|
||||
|
||||
@@ -101,7 +101,7 @@ void DeferredMaterialShader::Bind(BindParameters& params)
|
||||
}
|
||||
|
||||
// Select pipeline state based on current pass and render mode
|
||||
const bool wireframe = (_info.FeaturesFlags & MaterialFeaturesFlags::Wireframe) != 0 || view.Mode == ViewMode::Wireframe;
|
||||
const bool wireframe = (_info.FeaturesFlags & MaterialFeaturesFlags::Wireframe) != MaterialFeaturesFlags::None || view.Mode == ViewMode::Wireframe;
|
||||
CullMode cullMode = view.Pass == DrawPass::Depth ? CullMode::TwoSided : _info.CullMode;
|
||||
#if USE_EDITOR
|
||||
if (IsRunningRadiancePass)
|
||||
@@ -137,8 +137,8 @@ void DeferredMaterialShader::Unload()
|
||||
bool DeferredMaterialShader::Load()
|
||||
{
|
||||
auto psDesc = GPUPipelineState::Description::Default;
|
||||
psDesc.DepthTestEnable = (_info.FeaturesFlags & MaterialFeaturesFlags::DisableDepthTest) == 0;
|
||||
psDesc.DepthWriteEnable = (_info.FeaturesFlags & MaterialFeaturesFlags::DisableDepthWrite) == 0;
|
||||
psDesc.DepthTestEnable = (_info.FeaturesFlags & MaterialFeaturesFlags::DisableDepthTest) == MaterialFeaturesFlags::None;
|
||||
psDesc.DepthWriteEnable = (_info.FeaturesFlags & MaterialFeaturesFlags::DisableDepthWrite) == MaterialFeaturesFlags::None;
|
||||
|
||||
// Check if use tessellation (both material and runtime supports it)
|
||||
const bool useTess = _info.TessellationMode != TessellationMethod::None && GPUDevice::Instance->Limits.HasTessellation;
|
||||
@@ -206,7 +206,7 @@ bool DeferredMaterialShader::Load()
|
||||
psDesc.HS = nullptr;
|
||||
psDesc.DS = nullptr;
|
||||
GPUShaderProgramVS* instancedDepthPassVS;
|
||||
if ((_info.UsageFlags & (MaterialUsageFlags::UseMask | MaterialUsageFlags::UsePositionOffset)) != 0)
|
||||
if (EnumHasAnyFlags(_info.UsageFlags, MaterialUsageFlags::UseMask | MaterialUsageFlags::UsePositionOffset))
|
||||
{
|
||||
// Materials with masking need full vertex buffer to get texcoord used to sample textures for per pixel masking.
|
||||
// Materials with world pos offset need full VB to apply offset using texcoord etc.
|
||||
|
||||
@@ -82,7 +82,7 @@ void DeformableMaterialShader::Bind(BindParameters& params)
|
||||
}
|
||||
|
||||
// Select pipeline state based on current pass and render mode
|
||||
const bool wireframe = (_info.FeaturesFlags & MaterialFeaturesFlags::Wireframe) != 0 || view.Mode == ViewMode::Wireframe;
|
||||
const bool wireframe = (_info.FeaturesFlags & MaterialFeaturesFlags::Wireframe) != MaterialFeaturesFlags::None || view.Mode == ViewMode::Wireframe;
|
||||
CullMode cullMode = view.Pass == DrawPass::Depth ? CullMode::TwoSided : _info.CullMode;
|
||||
if (cullMode != CullMode::TwoSided && drawCall.WorldDeterminantSign < 0)
|
||||
{
|
||||
@@ -112,8 +112,8 @@ bool DeformableMaterialShader::Load()
|
||||
{
|
||||
_drawModes = DrawPass::Depth | DrawPass::QuadOverdraw;
|
||||
auto psDesc = GPUPipelineState::Description::Default;
|
||||
psDesc.DepthTestEnable = (_info.FeaturesFlags & MaterialFeaturesFlags::DisableDepthTest) == 0;
|
||||
psDesc.DepthWriteEnable = (_info.FeaturesFlags & MaterialFeaturesFlags::DisableDepthWrite) == 0;
|
||||
psDesc.DepthTestEnable = (_info.FeaturesFlags & MaterialFeaturesFlags::DisableDepthTest) == MaterialFeaturesFlags::None;
|
||||
psDesc.DepthWriteEnable = (_info.FeaturesFlags & MaterialFeaturesFlags::DisableDepthWrite) == MaterialFeaturesFlags::None;
|
||||
|
||||
// Check if use tessellation (both material and runtime supports it)
|
||||
const bool useTess = _info.TessellationMode != TessellationMethod::None && GPUDevice::Instance->Limits.HasTessellation;
|
||||
|
||||
@@ -51,7 +51,7 @@ void ForwardMaterialShader::Bind(BindParameters& params)
|
||||
int32 srv = 2;
|
||||
|
||||
// Setup features
|
||||
if (_info.FeaturesFlags & MaterialFeaturesFlags::GlobalIllumination)
|
||||
if ((_info.FeaturesFlags & MaterialFeaturesFlags::GlobalIllumination) != MaterialFeaturesFlags::None)
|
||||
GlobalIlluminationFeature::Bind(params, cb, srv);
|
||||
ForwardShadingFeature::Bind(params, cb, srv);
|
||||
|
||||
@@ -92,7 +92,7 @@ void ForwardMaterialShader::Bind(BindParameters& params)
|
||||
}
|
||||
|
||||
// Select pipeline state based on current pass and render mode
|
||||
const bool wireframe = (_info.FeaturesFlags & MaterialFeaturesFlags::Wireframe) != 0 || view.Mode == ViewMode::Wireframe;
|
||||
const bool wireframe = (_info.FeaturesFlags & MaterialFeaturesFlags::Wireframe) != MaterialFeaturesFlags::None || view.Mode == ViewMode::Wireframe;
|
||||
CullMode cullMode = view.Pass == DrawPass::Depth ? CullMode::TwoSided : _info.CullMode;
|
||||
#if USE_EDITOR
|
||||
if (IsRunningRadiancePass)
|
||||
@@ -130,8 +130,8 @@ bool ForwardMaterialShader::Load()
|
||||
_drawModes = DrawPass::Depth | DrawPass::Forward | DrawPass::QuadOverdraw;
|
||||
|
||||
auto psDesc = GPUPipelineState::Description::Default;
|
||||
psDesc.DepthTestEnable = (_info.FeaturesFlags & MaterialFeaturesFlags::DisableDepthTest) == 0;
|
||||
psDesc.DepthWriteEnable = (_info.FeaturesFlags & MaterialFeaturesFlags::DisableDepthWrite) == 0;
|
||||
psDesc.DepthTestEnable = (_info.FeaturesFlags & MaterialFeaturesFlags::DisableDepthTest) == MaterialFeaturesFlags::None;
|
||||
psDesc.DepthWriteEnable = (_info.FeaturesFlags & MaterialFeaturesFlags::DisableDepthWrite) == MaterialFeaturesFlags::None;
|
||||
|
||||
// Check if use tessellation (both material and runtime supports it)
|
||||
const bool useTess = _info.TessellationMode != TessellationMethod::None && GPUDevice::Instance->Limits.HasTessellation;
|
||||
|
||||
@@ -84,7 +84,7 @@ void GUIMaterialShader::Unload()
|
||||
bool GUIMaterialShader::Load()
|
||||
{
|
||||
GPUPipelineState::Description psDesc0 = GPUPipelineState::Description::DefaultFullscreenTriangle;
|
||||
psDesc0.Wireframe = (_info.FeaturesFlags & MaterialFeaturesFlags::Wireframe) != 0;
|
||||
psDesc0.Wireframe = EnumHasAnyFlags(_info.FeaturesFlags, MaterialFeaturesFlags::Wireframe);
|
||||
psDesc0.VS = _shader->GetVS("VS_GUI");
|
||||
psDesc0.PS = _shader->GetPS("PS_GUI");
|
||||
psDesc0.BlendMode = BlendingMode::AlphaBlend;
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
#include "Engine/Serialization/MemoryWriteStream.h"
|
||||
#include "Engine/Graphics/RenderBuffers.h"
|
||||
#include "Engine/Graphics/GPUDevice.h"
|
||||
#include "Engine/Graphics/GPULimits.h"
|
||||
#include "Engine/Graphics/RenderTask.h"
|
||||
#include "Engine/Renderer/GlobalSignDistanceFieldPass.h"
|
||||
#include "Engine/Streaming/Streaming.h"
|
||||
@@ -36,42 +35,42 @@ MaterialInfo9::MaterialInfo9(const MaterialInfo8& other)
|
||||
BlendMode = other.BlendMode;
|
||||
ShadingModel = other.ShadingModel;
|
||||
UsageFlags = MaterialUsageFlags::None;
|
||||
if (other.Flags & MaterialFlags_Deprecated::UseMask)
|
||||
if (EnumHasAnyFlags(other.Flags, MaterialFlags_Deprecated::UseMask))
|
||||
UsageFlags |= MaterialUsageFlags::UseMask;
|
||||
if (other.Flags & MaterialFlags_Deprecated::UseEmissive)
|
||||
if (EnumHasAnyFlags(other.Flags, MaterialFlags_Deprecated::UseEmissive))
|
||||
UsageFlags |= MaterialUsageFlags::UseEmissive;
|
||||
if (other.Flags & MaterialFlags_Deprecated::UsePositionOffset)
|
||||
if (EnumHasAnyFlags(other.Flags, MaterialFlags_Deprecated::UsePositionOffset))
|
||||
UsageFlags |= MaterialUsageFlags::UsePositionOffset;
|
||||
if (other.Flags & MaterialFlags_Deprecated::UseVertexColor)
|
||||
if (EnumHasAnyFlags(other.Flags, MaterialFlags_Deprecated::UseVertexColor))
|
||||
UsageFlags |= MaterialUsageFlags::UseVertexColor;
|
||||
if (other.Flags & MaterialFlags_Deprecated::UseNormal)
|
||||
if (EnumHasAnyFlags(other.Flags, MaterialFlags_Deprecated::UseNormal))
|
||||
UsageFlags |= MaterialUsageFlags::UseNormal;
|
||||
if (other.Flags & MaterialFlags_Deprecated::UseDisplacement)
|
||||
if (EnumHasAnyFlags(other.Flags, MaterialFlags_Deprecated::UseDisplacement))
|
||||
UsageFlags |= MaterialUsageFlags::UseDisplacement;
|
||||
if (other.Flags & MaterialFlags_Deprecated::UseRefraction)
|
||||
if (EnumHasAnyFlags(other.Flags, MaterialFlags_Deprecated::UseRefraction))
|
||||
UsageFlags |= MaterialUsageFlags::UseRefraction;
|
||||
FeaturesFlags = MaterialFeaturesFlags::None;
|
||||
if (other.Flags & MaterialFlags_Deprecated::Wireframe)
|
||||
if (EnumHasAnyFlags(other.Flags, MaterialFlags_Deprecated::Wireframe))
|
||||
FeaturesFlags |= MaterialFeaturesFlags::Wireframe;
|
||||
if (other.Flags & MaterialFlags_Deprecated::TransparentDisableDepthTest && BlendMode != MaterialBlendMode::Opaque)
|
||||
if (EnumHasAnyFlags(other.Flags, MaterialFlags_Deprecated::TransparentDisableDepthTest) && BlendMode != MaterialBlendMode::Opaque)
|
||||
FeaturesFlags |= MaterialFeaturesFlags::DisableDepthTest;
|
||||
if (other.Flags & MaterialFlags_Deprecated::TransparentDisableFog && BlendMode != MaterialBlendMode::Opaque)
|
||||
if (EnumHasAnyFlags(other.Flags, MaterialFlags_Deprecated::TransparentDisableFog) && BlendMode != MaterialBlendMode::Opaque)
|
||||
FeaturesFlags |= MaterialFeaturesFlags::DisableFog;
|
||||
if (other.Flags & MaterialFlags_Deprecated::TransparentDisableReflections && BlendMode != MaterialBlendMode::Opaque)
|
||||
if (EnumHasAnyFlags(other.Flags, MaterialFlags_Deprecated::TransparentDisableReflections) && BlendMode != MaterialBlendMode::Opaque)
|
||||
FeaturesFlags |= MaterialFeaturesFlags::DisableReflections;
|
||||
if (other.Flags & MaterialFlags_Deprecated::DisableDepthWrite)
|
||||
if (EnumHasAnyFlags(other.Flags, MaterialFlags_Deprecated::DisableDepthWrite))
|
||||
FeaturesFlags |= MaterialFeaturesFlags::DisableDepthWrite;
|
||||
if (other.Flags & MaterialFlags_Deprecated::TransparentDisableDistortion && BlendMode != MaterialBlendMode::Opaque)
|
||||
if (EnumHasAnyFlags(other.Flags, MaterialFlags_Deprecated::TransparentDisableDistortion) && BlendMode != MaterialBlendMode::Opaque)
|
||||
FeaturesFlags |= MaterialFeaturesFlags::DisableDistortion;
|
||||
if (other.Flags & MaterialFlags_Deprecated::InputWorldSpaceNormal)
|
||||
if (EnumHasAnyFlags(other.Flags, MaterialFlags_Deprecated::InputWorldSpaceNormal))
|
||||
FeaturesFlags |= MaterialFeaturesFlags::InputWorldSpaceNormal;
|
||||
if (other.Flags & MaterialFlags_Deprecated::UseDitheredLODTransition)
|
||||
if (EnumHasAnyFlags(other.Flags, MaterialFlags_Deprecated::UseDitheredLODTransition))
|
||||
FeaturesFlags |= MaterialFeaturesFlags::DitheredLODTransition;
|
||||
if (other.BlendMode != MaterialBlendMode::Opaque && other.TransparentLighting == MaterialTransparentLighting_Deprecated::None)
|
||||
ShadingModel = MaterialShadingModel::Unlit;
|
||||
DecalBlendingMode = other.DecalBlendingMode;
|
||||
PostFxLocation = other.PostFxLocation;
|
||||
CullMode = other.Flags & MaterialFlags_Deprecated::TwoSided ? ::CullMode::TwoSided : ::CullMode::Normal;
|
||||
CullMode = EnumHasAnyFlags(other.Flags, MaterialFlags_Deprecated::TwoSided) ? ::CullMode::TwoSided : ::CullMode::Normal;
|
||||
MaskThreshold = other.MaskThreshold;
|
||||
OpacityThreshold = other.OpacityThreshold;
|
||||
TessellationMode = other.TessellationMode;
|
||||
@@ -441,7 +440,7 @@ void MaterialParameter::Bind(BindMeta& meta) const
|
||||
case MaterialSceneTextures::SceneDepth:
|
||||
case MaterialSceneTextures::WorldPosition:
|
||||
view = meta.CanSampleDepth
|
||||
? meta.Buffers->DepthBuffer->GetDescription().Flags & GPUTextureFlags::ReadOnlyDepthView
|
||||
? EnumHasAnyFlags(meta.Buffers->DepthBuffer->Flags(), GPUTextureFlags::ReadOnlyDepthView)
|
||||
? meta.Buffers->DepthBuffer->ViewReadOnlyDepth()
|
||||
: meta.Buffers->DepthBuffer->View()
|
||||
: GPUDevice::Instance->GetDefaultWhiteTexture()->View();
|
||||
|
||||
@@ -127,7 +127,7 @@ bool LightmapFeature::Bind(MaterialShader::BindParameters& params, Span<byte>& c
|
||||
auto& drawCall = *params.FirstDrawCall;
|
||||
ASSERT_LOW_LAYER(cb.Length() >= sizeof(Data));
|
||||
|
||||
const bool useLightmap = params.RenderContext.View.Flags & ViewFlags::GI
|
||||
const bool useLightmap = EnumHasAnyFlags(params.RenderContext.View.Flags, ViewFlags::GI)
|
||||
#if USE_EDITOR
|
||||
&& EnableLightmapsUsage
|
||||
#endif
|
||||
@@ -157,7 +157,7 @@ bool GlobalIlluminationFeature::Bind(MaterialShader::BindParameters& params, Spa
|
||||
ASSERT_LOW_LAYER(cb.Length() >= sizeof(Data));
|
||||
|
||||
bool useGI = false;
|
||||
if (params.RenderContext.View.Flags & ViewFlags::GI)
|
||||
if (EnumHasAnyFlags(params.RenderContext.View.Flags, ViewFlags::GI))
|
||||
{
|
||||
switch (params.RenderContext.List->Settings.GlobalIllumination.Mode)
|
||||
{
|
||||
|
||||
@@ -56,7 +56,7 @@ void ParticleMaterialShader::Bind(BindParameters& params)
|
||||
int32 srv = 2;
|
||||
|
||||
// Setup features
|
||||
if (_info.FeaturesFlags & MaterialFeaturesFlags::GlobalIllumination)
|
||||
if (EnumHasAnyFlags(_info.FeaturesFlags, MaterialFeaturesFlags::GlobalIllumination))
|
||||
GlobalIlluminationFeature::Bind(params, cb, srv);
|
||||
ForwardShadingFeature::Bind(params, cb, srv);
|
||||
|
||||
@@ -117,7 +117,7 @@ void ParticleMaterialShader::Bind(BindParameters& params)
|
||||
}
|
||||
|
||||
// Select pipeline state based on current pass and render mode
|
||||
bool wireframe = (_info.FeaturesFlags & MaterialFeaturesFlags::Wireframe) != 0 || view.Mode == ViewMode::Wireframe;
|
||||
bool wireframe = EnumHasAnyFlags(_info.FeaturesFlags, MaterialFeaturesFlags::Wireframe) || view.Mode == ViewMode::Wireframe;
|
||||
CullMode cullMode = view.Pass == DrawPass::Depth ? CullMode::TwoSided : _info.CullMode;
|
||||
PipelineStateCache* psCache = nullptr;
|
||||
switch (drawCall.Particle.Module->TypeID)
|
||||
@@ -189,8 +189,8 @@ bool ParticleMaterialShader::Load()
|
||||
{
|
||||
_drawModes = DrawPass::Depth | DrawPass::Forward | DrawPass::QuadOverdraw;
|
||||
GPUPipelineState::Description psDesc = GPUPipelineState::Description::Default;
|
||||
psDesc.DepthTestEnable = (_info.FeaturesFlags & MaterialFeaturesFlags::DisableDepthTest) == 0;
|
||||
psDesc.DepthWriteEnable = (_info.FeaturesFlags & MaterialFeaturesFlags::DisableDepthWrite) == 0;
|
||||
psDesc.DepthTestEnable = (_info.FeaturesFlags & MaterialFeaturesFlags::DisableDepthTest) == MaterialFeaturesFlags::None;
|
||||
psDesc.DepthWriteEnable = (_info.FeaturesFlags & MaterialFeaturesFlags::DisableDepthWrite) == MaterialFeaturesFlags::None;
|
||||
|
||||
auto vsSprite = _shader->GetVS("VS_Sprite");
|
||||
auto vsMesh = _shader->GetVS("VS_Model");
|
||||
|
||||
@@ -100,7 +100,7 @@ void TerrainMaterialShader::Bind(BindParameters& params)
|
||||
}
|
||||
|
||||
// Select pipeline state based on current pass and render mode
|
||||
const bool wireframe = (_info.FeaturesFlags & MaterialFeaturesFlags::Wireframe) != 0 || view.Mode == ViewMode::Wireframe;
|
||||
const bool wireframe = EnumHasAnyFlags(_info.FeaturesFlags, MaterialFeaturesFlags::Wireframe) || view.Mode == ViewMode::Wireframe;
|
||||
CullMode cullMode = view.Pass == DrawPass::Depth ? CullMode::TwoSided : _info.CullMode;
|
||||
#if USE_EDITOR
|
||||
if (IsRunningRadiancePass)
|
||||
@@ -133,8 +133,8 @@ void TerrainMaterialShader::Unload()
|
||||
bool TerrainMaterialShader::Load()
|
||||
{
|
||||
GPUPipelineState::Description psDesc = GPUPipelineState::Description::Default;
|
||||
psDesc.DepthTestEnable = (_info.FeaturesFlags & MaterialFeaturesFlags::DisableDepthTest) == 0;
|
||||
psDesc.DepthWriteEnable = (_info.FeaturesFlags & MaterialFeaturesFlags::DisableDepthWrite) == 0;
|
||||
psDesc.DepthTestEnable = (_info.FeaturesFlags & MaterialFeaturesFlags::DisableDepthTest) == MaterialFeaturesFlags::None;
|
||||
psDesc.DepthWriteEnable = (_info.FeaturesFlags & MaterialFeaturesFlags::DisableDepthWrite) == MaterialFeaturesFlags::None;
|
||||
|
||||
// Check if use tessellation (both material and runtime supports it)
|
||||
const bool useTess = _info.TessellationMode != TessellationMethod::None && GPUDevice::Instance->Limits.HasTessellation;
|
||||
|
||||
@@ -468,8 +468,8 @@ void Mesh::Draw(const RenderContext& renderContext, const DrawInfo& info, float
|
||||
return;
|
||||
|
||||
// Check if skip rendering
|
||||
const auto shadowsMode = (ShadowsCastingMode)(entry.ShadowsMode & slot.ShadowsMode);
|
||||
const auto drawModes = (DrawPass)((uint32)info.DrawModes & (uint32)renderContext.View.Pass & (uint32)renderContext.View.GetShadowsDrawPassMask(shadowsMode) & (uint32)material->GetDrawModes());
|
||||
const auto shadowsMode = entry.ShadowsMode & slot.ShadowsMode;
|
||||
const auto drawModes = info.DrawModes & renderContext.View.Pass & renderContext.View.GetShadowsDrawPassMask(shadowsMode) & material->GetDrawModes();
|
||||
if (drawModes == DrawPass::None)
|
||||
return;
|
||||
|
||||
@@ -499,7 +499,7 @@ void Mesh::Draw(const RenderContext& renderContext, const DrawInfo& info, float
|
||||
drawCall.ObjectPosition = drawCall.World.GetTranslation();
|
||||
drawCall.Surface.GeometrySize = _box.GetSize();
|
||||
drawCall.Surface.PrevWorld = info.DrawState->PrevWorld;
|
||||
drawCall.Surface.Lightmap = info.Flags & StaticFlags::Lightmap ? info.Lightmap : nullptr;
|
||||
drawCall.Surface.Lightmap = (info.Flags & StaticFlags::Lightmap) != StaticFlags::None ? info.Lightmap : nullptr;
|
||||
drawCall.Surface.LightmapUVsArea = info.LightmapUVs ? *info.LightmapUVs : Rectangle::Empty;
|
||||
drawCall.Surface.Skinning = nullptr;
|
||||
drawCall.Surface.LODDitherFactor = lodDitherFactor;
|
||||
@@ -559,7 +559,7 @@ void Mesh::Draw(const RenderContextBatch& renderContextBatch, const DrawInfo& in
|
||||
drawCall.ObjectPosition = drawCall.World.GetTranslation();
|
||||
drawCall.Surface.GeometrySize = _box.GetSize();
|
||||
drawCall.Surface.PrevWorld = info.DrawState->PrevWorld;
|
||||
drawCall.Surface.Lightmap = info.Flags & StaticFlags::Lightmap ? info.Lightmap : nullptr;
|
||||
drawCall.Surface.Lightmap = (info.Flags & StaticFlags::Lightmap) != StaticFlags::None ? info.Lightmap : nullptr;
|
||||
drawCall.Surface.LightmapUVsArea = info.LightmapUVs ? *info.LightmapUVs : Rectangle::Empty;
|
||||
drawCall.Surface.Skinning = nullptr;
|
||||
drawCall.Surface.LODDitherFactor = lodDitherFactor;
|
||||
@@ -572,8 +572,8 @@ void Mesh::Draw(const RenderContextBatch& renderContextBatch, const DrawInfo& in
|
||||
#endif
|
||||
|
||||
// Push draw call to the render lists
|
||||
const auto shadowsMode = (ShadowsCastingMode)(entry.ShadowsMode & slot.ShadowsMode);
|
||||
const DrawPass drawModes = (DrawPass)(info.DrawModes & material->GetDrawModes());
|
||||
const auto shadowsMode = entry.ShadowsMode & slot.ShadowsMode;
|
||||
const auto drawModes = info.DrawModes & material->GetDrawModes();
|
||||
if (drawModes != DrawPass::None)
|
||||
renderContextBatch.GetMainContext().List->AddDrawCall(renderContextBatch, drawModes, info.Flags, shadowsMode, info.Bounds, drawCall, entry.ReceiveDecals);
|
||||
}
|
||||
|
||||
@@ -172,8 +172,8 @@ void SkinnedMesh::Draw(const RenderContext& renderContext, const DrawInfo& info,
|
||||
return;
|
||||
|
||||
// Check if skip rendering
|
||||
const auto shadowsMode = (ShadowsCastingMode)(entry.ShadowsMode & slot.ShadowsMode);
|
||||
const auto drawModes = (DrawPass)((uint32)info.DrawModes & (uint32)renderContext.View.Pass & (uint32)renderContext.View.GetShadowsDrawPassMask(shadowsMode) & (uint32)material->GetDrawModes());
|
||||
const auto shadowsMode = entry.ShadowsMode & slot.ShadowsMode;
|
||||
const auto drawModes = info.DrawModes & renderContext.View.Pass & renderContext.View.GetShadowsDrawPassMask(shadowsMode) & material->GetDrawModes();
|
||||
if (drawModes == DrawPass::None)
|
||||
return;
|
||||
|
||||
@@ -276,8 +276,8 @@ void SkinnedMesh::Draw(const RenderContextBatch& renderContextBatch, const DrawI
|
||||
drawCall.PerInstanceRandom = info.PerInstanceRandom;
|
||||
|
||||
// Push draw call to the render lists
|
||||
const auto shadowsMode = (ShadowsCastingMode)(entry.ShadowsMode & slot.ShadowsMode);
|
||||
const DrawPass drawModes = (DrawPass)(info.DrawModes & material->GetDrawModes());
|
||||
const auto shadowsMode = entry.ShadowsMode & slot.ShadowsMode;
|
||||
const auto drawModes = info.DrawModes & material->GetDrawModes();
|
||||
if (drawModes != DrawPass::None)
|
||||
renderContextBatch.GetMainContext().List->AddDrawCall(renderContextBatch, drawModes, StaticFlags::None, shadowsMode, info.Bounds, drawCall, entry.ReceiveDecals);
|
||||
}
|
||||
|
||||
@@ -192,11 +192,11 @@ void SceneRenderTask::CollectPostFxVolumes(RenderContext& renderContext)
|
||||
// Cache WorldPosition used for PostFx volumes blending (RenderView caches it later on)
|
||||
renderContext.View.WorldPosition = renderContext.View.Origin + renderContext.View.Position;
|
||||
|
||||
if ((ActorsSource & ActorsSources::Scenes) != 0)
|
||||
if (EnumHasAllFlags(ActorsSource, ActorsSources::Scenes))
|
||||
{
|
||||
Level::CollectPostFxVolumes(renderContext);
|
||||
}
|
||||
if ((ActorsSource & ActorsSources::CustomActors) != 0)
|
||||
if (EnumHasAllFlags(ActorsSource , ActorsSources::CustomActors))
|
||||
{
|
||||
for (Actor* a : CustomActors)
|
||||
{
|
||||
@@ -262,7 +262,7 @@ void SceneRenderTask::OnCollectDrawCalls(RenderContextBatch& renderContextBatch,
|
||||
}
|
||||
|
||||
// Draw actors (collect draw calls)
|
||||
if ((ActorsSource & ActorsSources::CustomActors) != 0)
|
||||
if (EnumHasAllFlags(ActorsSource, ActorsSources::CustomActors))
|
||||
{
|
||||
if (category == SceneRendering::DrawCategory::PreRender)
|
||||
{
|
||||
@@ -276,7 +276,7 @@ void SceneRenderTask::OnCollectDrawCalls(RenderContextBatch& renderContextBatch,
|
||||
ASSERT_LOW_LAYER(_customActorsScene);
|
||||
_customActorsScene->Draw(renderContextBatch, (SceneRendering::DrawCategory)category);
|
||||
}
|
||||
if ((ActorsSource & ActorsSources::Scenes) != 0)
|
||||
if (EnumHasAllFlags(ActorsSource, ActorsSources::Scenes))
|
||||
{
|
||||
Level::DrawActors(renderContextBatch, category);
|
||||
}
|
||||
|
||||
@@ -168,7 +168,7 @@ String GPUTextureDescription::ToString() const
|
||||
{
|
||||
// TODO: create tool to auto convert flag enums to string
|
||||
|
||||
#define CONVERT_FLAGS_FLAGS_2_STR(value) if(Flags & GPUTextureFlags::value) { if (flags.HasChars()) flags += TEXT('|'); flags += TEXT(#value); }
|
||||
#define CONVERT_FLAGS_FLAGS_2_STR(value) if (EnumHasAnyFlags(Flags, GPUTextureFlags::value)) { if (flags.HasChars()) flags += TEXT('|'); flags += TEXT(#value); }
|
||||
CONVERT_FLAGS_FLAGS_2_STR(ShaderResource);
|
||||
CONVERT_FLAGS_FLAGS_2_STR(RenderTarget);
|
||||
CONVERT_FLAGS_FLAGS_2_STR(UnorderedAccess);
|
||||
@@ -385,7 +385,7 @@ bool GPUTexture::Init(const GPUTextureDescription& desc)
|
||||
LOG(Warning, "Cannot create texture. Depth Stencil texture cannot be used as a Render Target. Description: {0}", desc.ToString());
|
||||
return true;
|
||||
}
|
||||
if (desc.Flags & GPUTextureFlags::ReadOnlyDepthView && !device->Limits.HasReadOnlyDepth)
|
||||
if (EnumHasAnyFlags(desc.Flags, GPUTextureFlags::ReadOnlyDepthView) && !device->Limits.HasReadOnlyDepth)
|
||||
{
|
||||
LOG(Warning, "Cannot create texture. The current graphics platform does not support read-only Depth Stencil texture. Description: {0}", desc.ToString());
|
||||
return true;
|
||||
@@ -393,7 +393,7 @@ bool GPUTexture::Init(const GPUTextureDescription& desc)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (desc.Flags & GPUTextureFlags::ReadOnlyDepthView)
|
||||
if (EnumHasAnyFlags(desc.Flags, GPUTextureFlags::ReadOnlyDepthView))
|
||||
{
|
||||
LOG(Warning, "Cannot create texture. Cannot create read-only Depth Stencil texture that is not a Depth Stencil texture. Add DepthStencil flag. Description: {0}", desc.ToString());
|
||||
return true;
|
||||
|
||||
@@ -148,7 +148,7 @@ public:
|
||||
/// </summary>
|
||||
FORCE_INLINE bool IsRenderTarget() const
|
||||
{
|
||||
return (Flags & GPUTextureFlags::RenderTarget) != 0;
|
||||
return (Flags & GPUTextureFlags::RenderTarget) != GPUTextureFlags::None;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -156,7 +156,7 @@ public:
|
||||
/// </summary>
|
||||
FORCE_INLINE bool IsDepthStencil() const
|
||||
{
|
||||
return (Flags & GPUTextureFlags::DepthStencil) != 0;
|
||||
return (Flags & GPUTextureFlags::DepthStencil) != GPUTextureFlags::None;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -164,7 +164,7 @@ public:
|
||||
/// </summary>
|
||||
FORCE_INLINE bool IsShaderResource() const
|
||||
{
|
||||
return (Flags & GPUTextureFlags::ShaderResource) != 0;
|
||||
return (Flags & GPUTextureFlags::ShaderResource) != GPUTextureFlags::None;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -172,7 +172,7 @@ public:
|
||||
/// </summary>
|
||||
FORCE_INLINE bool IsUnorderedAccess() const
|
||||
{
|
||||
return (Flags & GPUTextureFlags::UnorderedAccess) != 0;
|
||||
return (Flags & GPUTextureFlags::UnorderedAccess) != GPUTextureFlags::None;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -180,7 +180,7 @@ public:
|
||||
/// </summary>
|
||||
FORCE_INLINE bool HasPerMipViews() const
|
||||
{
|
||||
return (Flags & GPUTextureFlags::PerMipViews) != 0;
|
||||
return (Flags & GPUTextureFlags::PerMipViews) != GPUTextureFlags::None;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -188,7 +188,7 @@ public:
|
||||
/// </summary>
|
||||
FORCE_INLINE bool HasPerSliceViews() const
|
||||
{
|
||||
return (Flags & GPUTextureFlags::PerSliceViews) != 0;
|
||||
return (Flags & GPUTextureFlags::PerSliceViews) != GPUTextureFlags::None;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -76,21 +76,20 @@ bool GPUBufferDX11::OnInit()
|
||||
bufferDesc.CPUAccessFlags = RenderToolsDX::GetDX11CpuAccessFlagsFromUsage(_desc.Usage);
|
||||
bufferDesc.MiscFlags = 0;
|
||||
bufferDesc.StructureByteStride = 0;
|
||||
//
|
||||
if (_desc.Flags & GPUBufferFlags::VertexBuffer)
|
||||
if (EnumHasAnyFlags(_desc.Flags, GPUBufferFlags::VertexBuffer))
|
||||
bufferDesc.BindFlags |= D3D11_BIND_VERTEX_BUFFER;
|
||||
if (_desc.Flags & GPUBufferFlags::IndexBuffer)
|
||||
if (EnumHasAnyFlags(_desc.Flags, GPUBufferFlags::IndexBuffer))
|
||||
bufferDesc.BindFlags |= D3D11_BIND_INDEX_BUFFER;
|
||||
if (useSRV)
|
||||
bufferDesc.BindFlags |= D3D11_BIND_SHADER_RESOURCE;
|
||||
if (useUAV)
|
||||
bufferDesc.BindFlags |= D3D11_BIND_UNORDERED_ACCESS;
|
||||
//
|
||||
if (_desc.Flags & GPUBufferFlags::Argument)
|
||||
|
||||
if (EnumHasAnyFlags(_desc.Flags, GPUBufferFlags::Argument))
|
||||
bufferDesc.MiscFlags |= D3D11_RESOURCE_MISC_DRAWINDIRECT_ARGS;
|
||||
if (_desc.Flags & GPUBufferFlags::RawBuffer)
|
||||
if (EnumHasAnyFlags(_desc.Flags, GPUBufferFlags::RawBuffer))
|
||||
bufferDesc.MiscFlags |= D3D11_RESOURCE_MISC_BUFFER_ALLOW_RAW_VIEWS;
|
||||
if (_desc.Flags & GPUBufferFlags::Structured)
|
||||
if (EnumHasAnyFlags(_desc.Flags, GPUBufferFlags::Structured))
|
||||
{
|
||||
bufferDesc.MiscFlags |= D3D11_RESOURCE_MISC_BUFFER_STRUCTURED;
|
||||
bufferDesc.StructureByteStride = _desc.Stride;
|
||||
@@ -115,7 +114,7 @@ bool GPUBufferDX11::OnInit()
|
||||
if (useSRV)
|
||||
{
|
||||
D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc;
|
||||
if (_desc.Flags & GPUBufferFlags::RawBuffer)
|
||||
if (EnumHasAnyFlags(_desc.Flags, GPUBufferFlags::RawBuffer))
|
||||
{
|
||||
srvDesc.Format = DXGI_FORMAT_R32_TYPELESS;
|
||||
srvDesc.ViewDimension = D3D11_SRV_DIMENSION_BUFFEREX;
|
||||
@@ -125,7 +124,7 @@ bool GPUBufferDX11::OnInit()
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_desc.Flags & GPUBufferFlags::Structured)
|
||||
if (EnumHasAnyFlags(_desc.Flags, GPUBufferFlags::Structured))
|
||||
srvDesc.Format = DXGI_FORMAT_UNKNOWN;
|
||||
else
|
||||
srvDesc.Format = RenderToolsDX::ToDxgiFormat(PixelFormatExtensions::FindShaderResourceFormat(_desc.Format, false));
|
||||
@@ -144,13 +143,13 @@ bool GPUBufferDX11::OnInit()
|
||||
uavDesc.Buffer.FirstElement = 0;
|
||||
uavDesc.Buffer.NumElements = numElements;
|
||||
uavDesc.Buffer.Flags = 0;
|
||||
if (_desc.Flags & GPUBufferFlags::RawBuffer)
|
||||
if (EnumHasAnyFlags(_desc.Flags, GPUBufferFlags::RawBuffer))
|
||||
uavDesc.Buffer.Flags |= D3D11_BUFFER_UAV_FLAG_RAW;
|
||||
if (_desc.Flags & GPUBufferFlags::Append)
|
||||
if (EnumHasAnyFlags(_desc.Flags, GPUBufferFlags::Append))
|
||||
uavDesc.Buffer.Flags |= D3D11_BUFFER_UAV_FLAG_APPEND;
|
||||
if (_desc.Flags & GPUBufferFlags::Counter)
|
||||
if (EnumHasAnyFlags(_desc.Flags, GPUBufferFlags::Counter))
|
||||
uavDesc.Buffer.Flags |= D3D11_BUFFER_UAV_FLAG_COUNTER;
|
||||
if (_desc.Flags & GPUBufferFlags::Structured)
|
||||
if (EnumHasAnyFlags(_desc.Flags, GPUBufferFlags::Structured))
|
||||
uavDesc.Format = DXGI_FORMAT_UNKNOWN;
|
||||
else
|
||||
uavDesc.Format = RenderToolsDX::ToDxgiFormat(PixelFormatExtensions::FindUnorderedAccessFormat(_desc.Format));
|
||||
|
||||
@@ -472,7 +472,7 @@ void GPUContextDX11::DrawIndexedInstanced(uint32 indicesCount, uint32 instanceCo
|
||||
|
||||
void GPUContextDX11::DrawInstancedIndirect(GPUBuffer* bufferForArgs, uint32 offsetForArgs)
|
||||
{
|
||||
ASSERT(bufferForArgs && bufferForArgs->GetFlags() & GPUBufferFlags::Argument);
|
||||
ASSERT(bufferForArgs && EnumHasAnyFlags(bufferForArgs->GetFlags(), GPUBufferFlags::Argument));
|
||||
|
||||
const auto bufferForArgsDX11 = static_cast<GPUBufferDX11*>(bufferForArgs);
|
||||
|
||||
@@ -483,7 +483,7 @@ void GPUContextDX11::DrawInstancedIndirect(GPUBuffer* bufferForArgs, uint32 offs
|
||||
|
||||
void GPUContextDX11::DrawIndexedInstancedIndirect(GPUBuffer* bufferForArgs, uint32 offsetForArgs)
|
||||
{
|
||||
ASSERT(bufferForArgs && bufferForArgs->GetFlags() & GPUBufferFlags::Argument);
|
||||
ASSERT(bufferForArgs && EnumHasAnyFlags(bufferForArgs->GetFlags(), GPUBufferFlags::Argument));
|
||||
|
||||
const auto bufferForArgsDX11 = static_cast<GPUBufferDX11*>(bufferForArgs);
|
||||
|
||||
|
||||
@@ -494,7 +494,7 @@ void GPUTextureDX11::initHandles()
|
||||
}
|
||||
|
||||
// Read-only depth-stencil
|
||||
if (_desc.Flags & GPUTextureFlags::ReadOnlyDepthView)
|
||||
if (EnumHasAnyFlags(_desc.Flags, GPUTextureFlags::ReadOnlyDepthView))
|
||||
{
|
||||
CLEAR_VIEWS();
|
||||
|
||||
|
||||
@@ -172,7 +172,7 @@ bool GPUBufferDX12::OnInit()
|
||||
}
|
||||
|
||||
// Check if need to use a counter
|
||||
if (_desc.Flags & GPUBufferFlags::Counter || _desc.Flags & GPUBufferFlags::Append)
|
||||
if (EnumHasAnyFlags(_desc.Flags, GPUBufferFlags::Counter) || EnumHasAnyFlags(_desc.Flags, GPUBufferFlags::Append))
|
||||
{
|
||||
#if GPU_ENABLE_RESOURCE_NAMING
|
||||
String name = String(GetName()) + TEXT(".Counter");
|
||||
@@ -192,7 +192,7 @@ bool GPUBufferDX12::OnInit()
|
||||
if (useSRV)
|
||||
{
|
||||
D3D12_SHADER_RESOURCE_VIEW_DESC srvDesc;
|
||||
if (_desc.Flags & GPUBufferFlags::RawBuffer)
|
||||
if (EnumHasAnyFlags(_desc.Flags, GPUBufferFlags::RawBuffer))
|
||||
srvDesc.Format = RenderToolsDX::ToDxgiFormat(_desc.Format);
|
||||
else
|
||||
srvDesc.Format = RenderToolsDX::ToDxgiFormat(PixelFormatExtensions::FindShaderResourceFormat(_desc.Format, false));
|
||||
@@ -201,7 +201,7 @@ bool GPUBufferDX12::OnInit()
|
||||
srvDesc.Buffer.FirstElement = 0;
|
||||
srvDesc.Buffer.NumElements = numElements;
|
||||
srvDesc.Buffer.Flags = D3D12_BUFFER_SRV_FLAG_NONE;
|
||||
if (_desc.Flags & GPUBufferFlags::Structured)
|
||||
if (EnumHasAnyFlags(_desc.Flags, GPUBufferFlags::Structured))
|
||||
{
|
||||
srvDesc.Buffer.StructureByteStride = _desc.Stride;
|
||||
srvDesc.Format = DXGI_FORMAT_UNKNOWN;
|
||||
@@ -210,7 +210,7 @@ bool GPUBufferDX12::OnInit()
|
||||
{
|
||||
srvDesc.Buffer.StructureByteStride = 0;
|
||||
}
|
||||
if (_desc.Flags & GPUBufferFlags::RawBuffer)
|
||||
if (EnumHasAnyFlags(_desc.Flags, GPUBufferFlags::RawBuffer))
|
||||
srvDesc.Buffer.Flags |= D3D12_BUFFER_SRV_FLAG_RAW;
|
||||
_view.SetSRV(srvDesc);
|
||||
}
|
||||
@@ -223,11 +223,11 @@ bool GPUBufferDX12::OnInit()
|
||||
uavDesc.Buffer.CounterOffsetInBytes = 0;
|
||||
uavDesc.Buffer.Flags = D3D12_BUFFER_UAV_FLAG_NONE;
|
||||
uavDesc.Buffer.NumElements = numElements;
|
||||
if (_desc.Flags & GPUBufferFlags::Structured)
|
||||
if (EnumHasAnyFlags(_desc.Flags, GPUBufferFlags::Structured))
|
||||
uavDesc.Buffer.StructureByteStride = _desc.Stride;
|
||||
if (_desc.Flags & GPUBufferFlags::RawBuffer)
|
||||
if (EnumHasAnyFlags(_desc.Flags, GPUBufferFlags::RawBuffer))
|
||||
uavDesc.Buffer.Flags |= D3D12_BUFFER_UAV_FLAG_RAW;
|
||||
if (_desc.Flags & GPUBufferFlags::Structured)
|
||||
if (EnumHasAnyFlags(_desc.Flags, GPUBufferFlags::Structured))
|
||||
uavDesc.Format = DXGI_FORMAT_UNKNOWN;
|
||||
else
|
||||
uavDesc.Format = RenderToolsDX::ToDxgiFormat(PixelFormatExtensions::FindUnorderedAccessFormat(_desc.Format));
|
||||
|
||||
@@ -1100,7 +1100,7 @@ void GPUContextDX12::DrawIndexedInstanced(uint32 indicesCount, uint32 instanceCo
|
||||
|
||||
void GPUContextDX12::DrawInstancedIndirect(GPUBuffer* bufferForArgs, uint32 offsetForArgs)
|
||||
{
|
||||
ASSERT(bufferForArgs && bufferForArgs->GetFlags() & GPUBufferFlags::Argument);
|
||||
ASSERT(bufferForArgs && EnumHasAnyFlags(bufferForArgs->GetFlags(), GPUBufferFlags::Argument));
|
||||
|
||||
auto bufferForArgsDX12 = (GPUBufferDX12*)bufferForArgs;
|
||||
auto signature = _device->DrawIndirectCommandSignature->GetSignature();
|
||||
@@ -1113,7 +1113,7 @@ void GPUContextDX12::DrawInstancedIndirect(GPUBuffer* bufferForArgs, uint32 offs
|
||||
|
||||
void GPUContextDX12::DrawIndexedInstancedIndirect(GPUBuffer* bufferForArgs, uint32 offsetForArgs)
|
||||
{
|
||||
ASSERT(bufferForArgs && bufferForArgs->GetFlags() & GPUBufferFlags::Argument);
|
||||
ASSERT(bufferForArgs && EnumHasAnyFlags(bufferForArgs->GetFlags(), GPUBufferFlags::Argument));
|
||||
|
||||
auto bufferForArgsDX12 = (GPUBufferDX12*)bufferForArgs;
|
||||
auto signature = _device->DrawIndexedIndirectCommandSignature->GetSignature();
|
||||
|
||||
@@ -691,7 +691,7 @@ void GPUTextureDX12::initHandles()
|
||||
}
|
||||
|
||||
// Read-only depth-stencil
|
||||
if (_desc.Flags & GPUTextureFlags::ReadOnlyDepthView)
|
||||
if (EnumHasAnyFlags(_desc.Flags, GPUTextureFlags::ReadOnlyDepthView))
|
||||
{
|
||||
_handleReadOnlyDepth.Init(this, _device, this, format, msaa);
|
||||
_handleReadOnlyDepth.ReadOnlyDepthView = true;
|
||||
|
||||
@@ -197,7 +197,7 @@ public:
|
||||
// [IShaderResourceDX12]
|
||||
bool IsDepthStencilResource() const override
|
||||
{
|
||||
return (_desc.Flags & GPUTextureFlags::DepthStencil) != 0;
|
||||
return (_desc.Flags & GPUTextureFlags::DepthStencil) != GPUTextureFlags::None;
|
||||
}
|
||||
D3D12_CPU_DESCRIPTOR_HANDLE SRV() const override
|
||||
{
|
||||
|
||||
@@ -100,19 +100,19 @@ bool GPUBufferVulkan::OnInit()
|
||||
bufferInfo.usage = VK_BUFFER_USAGE_TRANSFER_DST_BIT;
|
||||
if (useSRV && !(_desc.Flags & GPUBufferFlags::Structured))
|
||||
bufferInfo.usage |= VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT;
|
||||
if (useUAV || _desc.Flags & GPUBufferFlags::RawBuffer || _desc.Flags & GPUBufferFlags::Structured)
|
||||
if (useUAV || EnumHasAnyFlags(_desc.Flags, GPUBufferFlags::RawBuffer | GPUBufferFlags::Structured))
|
||||
bufferInfo.usage |= VK_BUFFER_USAGE_STORAGE_BUFFER_BIT;
|
||||
if (useUAV && useSRV)
|
||||
bufferInfo.usage |= VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT;
|
||||
if (_desc.Flags & GPUBufferFlags::Argument)
|
||||
if (EnumHasAnyFlags(_desc.Flags, GPUBufferFlags::Argument))
|
||||
bufferInfo.usage |= VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT;
|
||||
if (_desc.Flags & GPUBufferFlags::Argument && useUAV)
|
||||
if (EnumHasAnyFlags(_desc.Flags, GPUBufferFlags::Argument) && useUAV)
|
||||
bufferInfo.usage |= VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT; // For some reason, glslang marks indirect uav buffers (UpdateProbesInitArgs, IndirectArgsBuffer) as Storage Texel Buffers
|
||||
if (_desc.Flags & GPUBufferFlags::VertexBuffer)
|
||||
if (EnumHasAnyFlags(_desc.Flags, GPUBufferFlags::VertexBuffer))
|
||||
bufferInfo.usage |= VK_BUFFER_USAGE_VERTEX_BUFFER_BIT;
|
||||
if (_desc.Flags & GPUBufferFlags::IndexBuffer)
|
||||
if (EnumHasAnyFlags(_desc.Flags, GPUBufferFlags::IndexBuffer))
|
||||
bufferInfo.usage |= VK_BUFFER_USAGE_INDEX_BUFFER_BIT;
|
||||
if (IsStaging() || _desc.Flags & GPUBufferFlags::UnorderedAccess)
|
||||
if (IsStaging() || EnumHasAnyFlags(_desc.Flags, GPUBufferFlags::UnorderedAccess))
|
||||
bufferInfo.usage |= VK_BUFFER_USAGE_TRANSFER_SRC_BIT;
|
||||
|
||||
// Create buffer
|
||||
@@ -162,7 +162,7 @@ bool GPUBufferVulkan::OnInit()
|
||||
}
|
||||
|
||||
// Check if need to use a counter
|
||||
if (_desc.Flags & GPUBufferFlags::Counter || _desc.Flags & GPUBufferFlags::Append)
|
||||
if (EnumHasAnyFlags(_desc.Flags, GPUBufferFlags::Counter | GPUBufferFlags::Append))
|
||||
{
|
||||
#if GPU_ENABLE_RESOURCE_NAMING
|
||||
String name = String(GetName()) + TEXT(".Counter");
|
||||
|
||||
@@ -1215,7 +1215,7 @@ void GPUContextVulkan::DrawIndexedInstanced(uint32 indicesCount, uint32 instance
|
||||
|
||||
void GPUContextVulkan::DrawInstancedIndirect(GPUBuffer* bufferForArgs, uint32 offsetForArgs)
|
||||
{
|
||||
ASSERT(bufferForArgs && bufferForArgs->GetFlags() & GPUBufferFlags::Argument);
|
||||
ASSERT(bufferForArgs && EnumHasAnyFlags(bufferForArgs->GetFlags(), GPUBufferFlags::Argument));
|
||||
|
||||
auto bufferForArgsVK = (GPUBufferVulkan*)bufferForArgs;
|
||||
const auto cmdBuffer = _cmdBufferManager->GetCmdBuffer();
|
||||
@@ -1226,7 +1226,7 @@ void GPUContextVulkan::DrawInstancedIndirect(GPUBuffer* bufferForArgs, uint32 of
|
||||
|
||||
void GPUContextVulkan::DrawIndexedInstancedIndirect(GPUBuffer* bufferForArgs, uint32 offsetForArgs)
|
||||
{
|
||||
ASSERT(bufferForArgs && bufferForArgs->GetFlags() & GPUBufferFlags::Argument);
|
||||
ASSERT(bufferForArgs && EnumHasAnyFlags(bufferForArgs->GetFlags(), GPUBufferFlags::Argument));
|
||||
|
||||
auto bufferForArgsVK = (GPUBufferVulkan*)bufferForArgs;
|
||||
const auto cmdBuffer = _cmdBufferManager->GetCmdBuffer();
|
||||
|
||||
@@ -1322,19 +1322,19 @@ PixelFormat GPUDeviceVulkan::GetClosestSupportedPixelFormat(PixelFormat format,
|
||||
{
|
||||
// Collect features to use
|
||||
VkFormatFeatureFlags wantedFeatureFlags = 0;
|
||||
if (flags & GPUTextureFlags::ShaderResource)
|
||||
if (EnumHasAnyFlags(flags, GPUTextureFlags::ShaderResource))
|
||||
wantedFeatureFlags |= VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT;
|
||||
if (flags & GPUTextureFlags::RenderTarget)
|
||||
if (EnumHasAnyFlags(flags, GPUTextureFlags::RenderTarget))
|
||||
wantedFeatureFlags |= VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT;
|
||||
if (flags & GPUTextureFlags::DepthStencil)
|
||||
if (EnumHasAnyFlags(flags, GPUTextureFlags::DepthStencil))
|
||||
wantedFeatureFlags |= VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT;
|
||||
if (flags & GPUTextureFlags::UnorderedAccess)
|
||||
if (EnumHasAnyFlags(flags, GPUTextureFlags::UnorderedAccess))
|
||||
wantedFeatureFlags |= VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT;
|
||||
|
||||
if (!IsVkFormatSupported(RenderToolsVulkan::ToVulkanFormat(format), wantedFeatureFlags, optimalTiling))
|
||||
{
|
||||
// Special case for depth-stencil formats
|
||||
if (flags & GPUTextureFlags::DepthStencil)
|
||||
if (EnumHasAnyFlags(flags, GPUTextureFlags::DepthStencil))
|
||||
{
|
||||
const bool hasStencil = PixelFormatExtensions::HasStencil(format);
|
||||
|
||||
@@ -1749,7 +1749,7 @@ bool GPUDeviceVulkan::Init()
|
||||
//VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_MINMAX_BIT_EXT
|
||||
|
||||
// Multi-sampling support
|
||||
if (support & FormatSupport::Texture2D)
|
||||
if (EnumHasAnyFlags(support, FormatSupport::Texture2D))
|
||||
msaa = maxMsaa;
|
||||
}
|
||||
|
||||
|
||||
@@ -216,7 +216,7 @@ bool GPUSwapChainVulkan::CreateSwapChain(int32 width, int32 height)
|
||||
if (resultFormat != PixelFormat::Unknown)
|
||||
{
|
||||
bool found = false;
|
||||
if (FORMAT_FEATURES_ARE_SUPPORTED(_device->FeaturesPerFormat[(int32)resultFormat].Support, FormatSupport::RenderTarget))
|
||||
if (EnumHasAllFlags(_device->FeaturesPerFormat[(int32)resultFormat].Support, FormatSupport::RenderTarget))
|
||||
{
|
||||
const VkFormat requested = RenderToolsVulkan::ToVulkanFormat(resultFormat);
|
||||
for (int32 i = 0; i < surfaceFormats.Count(); i++)
|
||||
|
||||
@@ -420,7 +420,7 @@ void GPUTextureVulkan::initHandles()
|
||||
}
|
||||
|
||||
// Read-only depth-stencil
|
||||
if (_desc.Flags & GPUTextureFlags::ReadOnlyDepthView)
|
||||
if (EnumHasAnyFlags(_desc.Flags, GPUTextureFlags::ReadOnlyDepthView))
|
||||
{
|
||||
_handleReadOnlyDepth.Init(_device, this, _image, mipLevels, format, msaa, extent, VK_IMAGE_VIEW_TYPE_2D, mipLevels, 0, 1, 0, true);
|
||||
}
|
||||
|
||||
@@ -350,7 +350,7 @@ public:
|
||||
/// </summary>
|
||||
FORCE_INLINE bool IsTransformStatic() const
|
||||
{
|
||||
return (_staticFlags & StaticFlags::Transform) != 0;
|
||||
return (_staticFlags & StaticFlags::Transform) != StaticFlags::None;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -373,7 +373,7 @@ public:
|
||||
/// </summary>
|
||||
FORCE_INLINE bool HasStaticFlag(StaticFlags flag) const
|
||||
{
|
||||
return (_staticFlags & flag) == (int)flag;
|
||||
return EnumHasAllFlags(_staticFlags, flag);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -391,7 +391,7 @@ public:
|
||||
/// <param name="flags">The flags to remove.</param>
|
||||
FORCE_INLINE void RemoveStaticFlags(StaticFlags flags)
|
||||
{
|
||||
SetStaticFlags(static_cast<StaticFlags>(_staticFlags & ~flags));
|
||||
SetStaticFlags(_staticFlags & ~flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -401,7 +401,7 @@ public:
|
||||
/// <param name="value">The target value of the flag.</param>
|
||||
FORCE_INLINE void SetStaticFlag(StaticFlags flag, bool value)
|
||||
{
|
||||
SetStaticFlags(static_cast<StaticFlags>(_staticFlags & ~flag) | (value ? flag : StaticFlags::None));
|
||||
SetStaticFlags((_staticFlags & ~flag) | (value ? flag : StaticFlags::None));
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
@@ -730,7 +730,7 @@ void AnimatedModel::Draw(RenderContext& renderContext)
|
||||
draw.World = &world;
|
||||
draw.DrawState = &_drawState;
|
||||
PRAGMA_DISABLE_DEPRECATION_WARNINGS
|
||||
draw.DrawModes = (DrawPass)(DrawModes & renderContext.View.GetShadowsDrawPassMask(ShadowsMode));
|
||||
draw.DrawModes = DrawModes & renderContext.View.GetShadowsDrawPassMask(ShadowsMode);
|
||||
PRAGMA_ENABLE_DEPRECATION_WARNINGS
|
||||
draw.Bounds = _sphere;
|
||||
draw.Bounds.Center -= renderContext.View.Origin;
|
||||
@@ -785,7 +785,7 @@ void AnimatedModel::Draw(RenderContextBatch& renderContextBatch)
|
||||
// TODO: maybe deserialize ShadowsMode into ModelInstanceBuffer entries options?
|
||||
for (auto& e : renderContextBatch.Contexts)
|
||||
{
|
||||
draw.DrawModes = (DrawPass)(DrawModes & e.View.GetShadowsDrawPassMask(ShadowsMode));
|
||||
draw.DrawModes = DrawModes & e.View.GetShadowsDrawPassMask(ShadowsMode);
|
||||
SkinnedModel->Draw(e, draw);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -275,7 +275,7 @@ bool Camera::HasContentLoaded() const
|
||||
|
||||
void Camera::Draw(RenderContext& renderContext)
|
||||
{
|
||||
if (renderContext.View.Flags & ViewFlags::EditorSprites
|
||||
if (EnumHasAnyFlags(renderContext.View.Flags, ViewFlags::EditorSprites)
|
||||
&& _previewModel
|
||||
&& _previewModel->IsLoaded())
|
||||
{
|
||||
@@ -291,7 +291,7 @@ void Camera::Draw(RenderContext& renderContext)
|
||||
draw.Lightmap = nullptr;
|
||||
draw.LightmapUVs = nullptr;
|
||||
draw.Flags = StaticFlags::Transform;
|
||||
draw.DrawModes = (DrawPass)((DrawPass::Depth | DrawPass::GBuffer | DrawPass::Forward) & renderContext.View.Pass);
|
||||
draw.DrawModes = (DrawPass::Depth | DrawPass::GBuffer | DrawPass::Forward) & renderContext.View.Pass;
|
||||
BoundingSphere::FromBox(_previewModelBox, draw.Bounds);
|
||||
draw.Bounds.Center -= renderContext.View.Origin;
|
||||
draw.PerInstanceRandom = GetPerInstanceRandom();
|
||||
|
||||
@@ -69,8 +69,8 @@ void Decal::OnLayerChanged()
|
||||
|
||||
void Decal::Draw(RenderContext& renderContext)
|
||||
{
|
||||
if ((renderContext.View.Flags & ViewFlags::Decals) != 0 &&
|
||||
renderContext.View.Pass & DrawPass::GBuffer &&
|
||||
if (EnumHasAnyFlags(renderContext.View.Flags, ViewFlags::Decals) &&
|
||||
EnumHasAnyFlags(renderContext.View.Pass, DrawPass::GBuffer) &&
|
||||
Material &&
|
||||
Material->IsLoaded() &&
|
||||
Material->IsDecal())
|
||||
|
||||
@@ -20,8 +20,8 @@ void DirectionalLight::Draw(RenderContext& renderContext)
|
||||
AdjustBrightness(renderContext.View, brightness);
|
||||
const Float3 position = GetPosition() - renderContext.View.Origin;
|
||||
if (Brightness > ZeroTolerance
|
||||
&& (renderContext.View.Flags & ViewFlags::DirectionalLights) != 0
|
||||
&& renderContext.View.Pass & DrawPass::GBuffer
|
||||
&& EnumHasAnyFlags(renderContext.View.Flags, ViewFlags::DirectionalLights)
|
||||
&& EnumHasAnyFlags(renderContext.View.Pass, DrawPass::GBuffer)
|
||||
&& (ViewDistance < ZeroTolerance || Float3::DistanceSquared(renderContext.View.Position, position) < ViewDistance * ViewDistance))
|
||||
{
|
||||
RendererDirectionalLightData data;
|
||||
|
||||
@@ -178,8 +178,8 @@ void EnvironmentProbe::UpdateBounds()
|
||||
void EnvironmentProbe::Draw(RenderContext& renderContext)
|
||||
{
|
||||
if (Brightness > ZeroTolerance &&
|
||||
(renderContext.View.Flags & ViewFlags::Reflections) != 0 &&
|
||||
renderContext.View.Pass & DrawPass::GBuffer)
|
||||
EnumHasAnyFlags(renderContext.View.Flags, ViewFlags::Reflections) &&
|
||||
EnumHasAnyFlags(renderContext.View.Pass, DrawPass::GBuffer))
|
||||
{
|
||||
if (UpdateMode == ProbeUpdateMode::Realtime)
|
||||
ProbesRenderer::Bake(this, 0.0f);
|
||||
|
||||
@@ -35,8 +35,8 @@ void ExponentialHeightFog::Draw(RenderContext& renderContext)
|
||||
{
|
||||
// Render only when shader is valid and fog can be rendered
|
||||
// Do not render exponential fog in orthographic views
|
||||
if ((renderContext.View.Flags & ViewFlags::Fog) != 0
|
||||
&& renderContext.View.Pass & DrawPass::GBuffer
|
||||
if (EnumHasAnyFlags(renderContext.View.Flags, ViewFlags::Fog)
|
||||
&& EnumHasAnyFlags(renderContext.View.Pass, DrawPass::GBuffer)
|
||||
&& _shader
|
||||
&& _shader->IsLoaded()
|
||||
&& renderContext.View.IsPerspectiveProjection())
|
||||
|
||||
@@ -83,9 +83,9 @@ void PointLight::Draw(RenderContext& renderContext)
|
||||
AdjustBrightness(renderContext.View, brightness);
|
||||
const Float3 position = GetPosition() - renderContext.View.Origin;
|
||||
const float radius = GetScaledRadius();
|
||||
if ((renderContext.View.Flags & ViewFlags::PointLights) != 0
|
||||
if (EnumHasAnyFlags(renderContext.View.Flags, ViewFlags::PointLights)
|
||||
&& EnumHasAnyFlags(renderContext.View.Pass, DrawPass::GBuffer)
|
||||
&& brightness > ZeroTolerance
|
||||
&& renderContext.View.Pass & DrawPass::GBuffer
|
||||
&& radius > ZeroTolerance
|
||||
&& (ViewDistance < ZeroTolerance || Vector3::DistanceSquared(renderContext.View.Position, position) < ViewDistance * ViewDistance))
|
||||
{
|
||||
|
||||
@@ -184,7 +184,7 @@ void Sky::DrawFog(GPUContext* context, RenderContext& renderContext, GPUTextureV
|
||||
data.ViewOffset = renderContext.View.Origin + GetPosition();
|
||||
InitConfig(data.Fog);
|
||||
data.Fog.AtmosphericFogSunPower *= SunLight ? SunLight->Brightness : 1.0f;
|
||||
bool useSpecularLight = (renderContext.View.Flags & ViewFlags::SpecularLight) != 0;
|
||||
bool useSpecularLight = EnumHasAnyFlags(renderContext.View.Flags, ViewFlags::SpecularLight);
|
||||
if (!useSpecularLight)
|
||||
{
|
||||
data.Fog.AtmosphericFogSunDiscScale = 0;
|
||||
@@ -223,7 +223,7 @@ void Sky::ApplySky(GPUContext* context, RenderContext& renderContext, const Matr
|
||||
data.ViewOffset = renderContext.View.Origin + GetPosition();
|
||||
InitConfig(data.Fog);
|
||||
//data.Fog.AtmosphericFogSunPower *= SunLight ? SunLight->Brightness : 1.0f;
|
||||
bool useSpecularLight = (renderContext.View.Flags & ViewFlags::SpecularLight) != 0;
|
||||
bool useSpecularLight = EnumHasAnyFlags(renderContext.View.Flags, ViewFlags::SpecularLight);
|
||||
if (!useSpecularLight)
|
||||
{
|
||||
// Hide sun disc if specular light is disabled
|
||||
|
||||
@@ -106,8 +106,8 @@ void SkyLight::Draw(RenderContext& renderContext)
|
||||
float brightness = Brightness;
|
||||
AdjustBrightness(renderContext.View, brightness);
|
||||
const Float3 position = GetPosition() - renderContext.View.Origin;
|
||||
if ((renderContext.View.Flags & ViewFlags::SkyLights) != 0
|
||||
&& renderContext.View.Pass & DrawPass::GBuffer
|
||||
if (EnumHasAnyFlags(renderContext.View.Flags, ViewFlags::SkyLights)
|
||||
&& EnumHasAnyFlags(renderContext.View.Pass, DrawPass::GBuffer)
|
||||
&& brightness > ZeroTolerance
|
||||
&& (ViewDistance < ZeroTolerance || Vector3::DistanceSquared(renderContext.View.Position, position) < ViewDistance * ViewDistance))
|
||||
{
|
||||
|
||||
@@ -33,7 +33,7 @@ void Skybox::Draw(RenderContext& renderContext)
|
||||
bool isReady;
|
||||
if (CustomMaterial)
|
||||
{
|
||||
isReady = CustomMaterial->IsLoaded() && CustomMaterial->IsSurface() && CustomMaterial->GetDrawModes() & DrawPass::GBuffer;
|
||||
isReady = CustomMaterial->IsLoaded() && CustomMaterial->IsSurface() && EnumHasAnyFlags(CustomMaterial->GetDrawModes(), DrawPass::GBuffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -348,7 +348,7 @@ bool SplineModel::HasContentLoaded() const
|
||||
|
||||
void SplineModel::Draw(RenderContext& renderContext)
|
||||
{
|
||||
const DrawPass actorDrawModes = (DrawPass)(DrawModes & renderContext.View.Pass);
|
||||
const DrawPass actorDrawModes = DrawModes & renderContext.View.Pass;
|
||||
if (!_spline || !Model || !Model->IsLoaded() || !Model->CanBeRendered() || actorDrawModes == DrawPass::None)
|
||||
return;
|
||||
auto model = Model.Get();
|
||||
@@ -428,8 +428,8 @@ void SplineModel::Draw(RenderContext& renderContext)
|
||||
continue;
|
||||
|
||||
// Check if skip rendering
|
||||
const auto shadowsMode = static_cast<ShadowsCastingMode>(entry.ShadowsMode & slot.ShadowsMode);
|
||||
const auto drawModes = static_cast<DrawPass>(actorDrawModes & renderContext.View.GetShadowsDrawPassMask(shadowsMode) & (uint32)material->GetDrawModes());
|
||||
const auto shadowsMode = entry.ShadowsMode & slot.ShadowsMode;
|
||||
const auto drawModes = actorDrawModes & renderContext.View.GetShadowsDrawPassMask(shadowsMode) & material->GetDrawModes();
|
||||
if (drawModes == DrawPass::None)
|
||||
continue;
|
||||
|
||||
|
||||
@@ -132,8 +132,8 @@ void SpotLight::Draw(RenderContext& renderContext)
|
||||
const Float3 position = GetPosition() - renderContext.View.Origin;
|
||||
const float radius = GetScaledRadius();
|
||||
const float outerConeAngle = GetOuterConeAngle();
|
||||
if ((renderContext.View.Flags & ViewFlags::SpotLights) != 0
|
||||
&& renderContext.View.Pass & DrawPass::GBuffer
|
||||
if (EnumHasAnyFlags(renderContext.View.Flags, ViewFlags::SpotLights)
|
||||
&& EnumHasAnyFlags(renderContext.View.Pass, DrawPass::GBuffer)
|
||||
&& brightness > ZeroTolerance
|
||||
&& radius > ZeroTolerance
|
||||
&& outerConeAngle > ZeroTolerance
|
||||
|
||||
@@ -262,13 +262,13 @@ void StaticModel::Draw(RenderContext& renderContext)
|
||||
return;
|
||||
if (renderContext.View.Pass == DrawPass::GlobalSDF)
|
||||
{
|
||||
if (DrawModes & DrawPass::GlobalSDF)
|
||||
if (EnumHasAnyFlags(DrawModes, DrawPass::GlobalSDF))
|
||||
GlobalSignDistanceFieldPass::Instance()->RasterizeModelSDF(this, Model->SDF, _transform, _box);
|
||||
return;
|
||||
}
|
||||
if (renderContext.View.Pass == DrawPass::GlobalSurfaceAtlas)
|
||||
{
|
||||
if (DrawModes & DrawPass::GlobalSurfaceAtlas)
|
||||
if (EnumHasAnyFlags(DrawModes, DrawPass::GlobalSurfaceAtlas))
|
||||
GlobalSurfaceAtlasPass::Instance()->RasterizeActor(this, this, _sphere, _transform, Model->LODs.Last().GetBox());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -184,7 +184,7 @@ void PrefabInstanceData::CollectPrefabInstances(Array<PrefabInstanceData>& prefa
|
||||
for (int32 instanceIndex = 0; instanceIndex < instances.Count(); instanceIndex++)
|
||||
{
|
||||
const auto instance = instances[instanceIndex];
|
||||
if ((instance->Flags & ObjectFlags::WasMarkedToDelete) != 0)
|
||||
if (EnumHasAnyFlags(instance->Flags, ObjectFlags::WasMarkedToDelete))
|
||||
continue;
|
||||
if (instance != defaultInstance && targetActor != instance && !targetActor->HasActorInHierarchy(instance))
|
||||
usedCount++;
|
||||
@@ -195,7 +195,7 @@ void PrefabInstanceData::CollectPrefabInstances(Array<PrefabInstanceData>& prefa
|
||||
{
|
||||
// Skip default instance because it will be recreated, skip input actor because it needs just to be linked
|
||||
Actor* instance = instances[instanceIndex];
|
||||
if ((instance->Flags & ObjectFlags::WasMarkedToDelete) != 0)
|
||||
if (EnumHasAnyFlags(instance->Flags, ObjectFlags::WasMarkedToDelete))
|
||||
continue;
|
||||
if (instance != defaultInstance && targetActor != instance && !targetActor->HasActorInHierarchy(instance))
|
||||
{
|
||||
@@ -268,7 +268,7 @@ bool PrefabInstanceData::SynchronizePrefabInstances(Array<PrefabInstanceData>& p
|
||||
|
||||
// If prefab object root was changed during changes apply then update the TargetActor to point a valid object
|
||||
Actor* oldTargetActor = instance.TargetActor;
|
||||
if (!oldTargetActor || (oldTargetActor->Flags & ObjectFlags::WasMarkedToDelete) != 0)
|
||||
if (!oldTargetActor || EnumHasAnyFlags(oldTargetActor->Flags, ObjectFlags::WasMarkedToDelete))
|
||||
continue;
|
||||
Actor* newTargetActor = FindActorWithPrefabObjectId(instance.TargetActor, defaultInstance->GetID());
|
||||
if (!newTargetActor)
|
||||
@@ -670,7 +670,7 @@ bool Prefab::ApplyAll(Actor* targetActor)
|
||||
for (int32 i = 0; i < nestedPrefabIds.Count(); i++)
|
||||
{
|
||||
const auto nestedPrefab = Content::LoadAsync<Prefab>(nestedPrefabIds[i]);
|
||||
if (nestedPrefab && nestedPrefab != this && (nestedPrefab->Flags & ObjectFlags::WasMarkedToDelete) == 0)
|
||||
if (nestedPrefab && nestedPrefab != this && (nestedPrefab->Flags & ObjectFlags::WasMarkedToDelete) == ObjectFlags::None)
|
||||
{
|
||||
allPrefabs.Add(nestedPrefab);
|
||||
}
|
||||
|
||||
@@ -298,7 +298,7 @@ bool PrefabManager::CreatePrefab(Actor* targetActor, const StringView& outputPat
|
||||
LOG(Error, "Cannot create prefab from scene actor.");
|
||||
return true;
|
||||
}
|
||||
if ((targetActor->HideFlags & HideFlags::DontSave) != 0)
|
||||
if (EnumHasAnyFlags(targetActor->HideFlags, HideFlags::DontSave))
|
||||
{
|
||||
LOG(Error, "Cannot create prefab from actor marked with HideFlags.DontSave.");
|
||||
return true;
|
||||
|
||||
@@ -85,10 +85,10 @@ void SceneRendering::Draw(RenderContextBatch& renderContextBatch, DrawCategory c
|
||||
}
|
||||
|
||||
#if USE_EDITOR
|
||||
if (view.Pass & DrawPass::GBuffer && category == SceneDraw)
|
||||
if (EnumHasAnyFlags(view.Pass, DrawPass::GBuffer) && category == SceneDraw)
|
||||
{
|
||||
// Draw physics shapes
|
||||
if (view.Flags & ViewFlags::PhysicsDebug || view.Mode == ViewMode::PhysicsColliders)
|
||||
if (EnumHasAnyFlags(view.Flags, ViewFlags::PhysicsDebug) || view.Mode == ViewMode::PhysicsColliders)
|
||||
{
|
||||
const PhysicsDebugCallback* physicsDebugData = PhysicsDebug.Get();
|
||||
for (int32 i = 0; i < PhysicsDebug.Count(); i++)
|
||||
@@ -203,7 +203,7 @@ void SceneRendering::DrawActorsJob(int32)
|
||||
// Offline pass with additional static flags culling
|
||||
FOR_EACH_BATCH_ACTOR
|
||||
e.Bounds.Center -= view.Origin;
|
||||
if (CHECK_ACTOR && e.Actor->GetStaticFlags() & view.StaticFlagsMask)
|
||||
if (CHECK_ACTOR && (e.Actor->GetStaticFlags() & view.StaticFlagsMask) != StaticFlags::None)
|
||||
{
|
||||
DRAW_ACTOR(*_drawBatch);
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ void SceneObject::Serialize(SerializeStream& stream, const void* otherObj)
|
||||
|
||||
#if !COMPILE_WITHOUT_CSHARP
|
||||
// Handle C# objects data serialization
|
||||
if (Flags & ObjectFlags::IsManagedType)
|
||||
if (EnumHasAnyFlags(Flags, ObjectFlags::IsManagedType))
|
||||
{
|
||||
stream.JKEY("V");
|
||||
if (other)
|
||||
@@ -134,7 +134,7 @@ void SceneObject::Serialize(SerializeStream& stream, const void* otherObj)
|
||||
#endif
|
||||
|
||||
// Handle custom scripting objects data serialization
|
||||
if (Flags & ObjectFlags::IsCustomScriptingType)
|
||||
if (EnumHasAnyFlags(Flags, ObjectFlags::IsCustomScriptingType))
|
||||
{
|
||||
stream.JKEY("D");
|
||||
_type.Module->SerializeObject(stream, this, other);
|
||||
@@ -150,7 +150,7 @@ void SceneObject::Deserialize(DeserializeStream& stream, ISerializeModifier* mod
|
||||
|
||||
#if !COMPILE_WITHOUT_CSHARP
|
||||
// Handle C# objects data serialization
|
||||
if (Flags & ObjectFlags::IsManagedType)
|
||||
if (EnumHasAnyFlags(Flags, ObjectFlags::IsManagedType))
|
||||
{
|
||||
auto* const v = SERIALIZE_FIND_MEMBER(stream, "V");
|
||||
if (v != stream.MemberEnd() && v->value.IsObject() && v->value.MemberCount() != 0)
|
||||
@@ -161,7 +161,7 @@ void SceneObject::Deserialize(DeserializeStream& stream, ISerializeModifier* mod
|
||||
#endif
|
||||
|
||||
// Handle custom scripting objects data serialization
|
||||
if (Flags & ObjectFlags::IsCustomScriptingType)
|
||||
if (EnumHasAnyFlags(Flags, ObjectFlags::IsCustomScriptingType))
|
||||
{
|
||||
auto* const v = SERIALIZE_FIND_MEMBER(stream, "D");
|
||||
if (v != stream.MemberEnd() && v->value.IsObject() && v->value.MemberCount() != 0)
|
||||
|
||||
@@ -99,7 +99,7 @@ public:
|
||||
/// </summary>
|
||||
API_PROPERTY() FORCE_INLINE bool IsDuringPlay() const
|
||||
{
|
||||
return (Flags & ObjectFlags::IsDuringPlay) != 0;
|
||||
return (Flags & ObjectFlags::IsDuringPlay) == ObjectFlags::IsDuringPlay;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -54,7 +54,7 @@ void SceneQuery::GetAllSceneObjects(Actor* root, Array<SceneObject*>& objects)
|
||||
|
||||
bool GetAllSerializableSceneObjectsQuery(Actor* actor, Array<SceneObject*>& objects)
|
||||
{
|
||||
if ((actor->HideFlags & HideFlags::DontSave) != 0)
|
||||
if (EnumHasAnyFlags(actor->HideFlags, HideFlags::DontSave))
|
||||
return false;
|
||||
|
||||
objects.Add(actor);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2012-2023 Wojciech Figat. All rights reserved.
|
||||
// Copyright (c) 2012-2023 Wojciech Figat. All rights reserved.
|
||||
|
||||
// Interpolation and prediction logic based on https://www.gabrielgambetta.com/client-server-game-architecture.html
|
||||
|
||||
@@ -162,51 +162,51 @@ void NetworkTransform::Serialize(NetworkStream* stream)
|
||||
data.HasSequenceIndex = Mode == ReplicationModes::Prediction;
|
||||
data.Components = Components;
|
||||
stream->Write(data);
|
||||
if ((data.Components & ReplicationComponents::All) == (int)ReplicationComponents::All)
|
||||
if (EnumHasAllFlags(data.Components, ReplicationComponents::All))
|
||||
{
|
||||
stream->Write(transform);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((data.Components & ReplicationComponents::Position) == (int)ReplicationComponents::Position)
|
||||
if (EnumHasAllFlags(data.Components, ReplicationComponents::Position))
|
||||
{
|
||||
stream->Write(transform.Translation);
|
||||
}
|
||||
else if (data.Components & ReplicationComponents::Position)
|
||||
else if (EnumHasAnyFlags(data.Components, ReplicationComponents::Position))
|
||||
{
|
||||
if (data.Components & ReplicationComponents::PositionX)
|
||||
if (EnumHasAnyFlags(data.Components, ReplicationComponents::PositionX))
|
||||
stream->Write(transform.Translation.X);
|
||||
if (data.Components & ReplicationComponents::PositionY)
|
||||
if (EnumHasAnyFlags(data.Components, ReplicationComponents::PositionY))
|
||||
stream->Write(transform.Translation.X);
|
||||
if (data.Components & ReplicationComponents::PositionZ)
|
||||
if (EnumHasAnyFlags(data.Components, ReplicationComponents::PositionZ))
|
||||
stream->Write(transform.Translation.X);
|
||||
}
|
||||
if ((data.Components & ReplicationComponents::Scale) == (int)ReplicationComponents::Scale)
|
||||
if (EnumHasAllFlags(data.Components, ReplicationComponents::Scale))
|
||||
{
|
||||
stream->Write(transform.Scale);
|
||||
}
|
||||
else if (data.Components & ReplicationComponents::Scale)
|
||||
else if (EnumHasAnyFlags(data.Components, ReplicationComponents::Scale))
|
||||
{
|
||||
if (data.Components & ReplicationComponents::ScaleX)
|
||||
if (EnumHasAnyFlags(data.Components, ReplicationComponents::ScaleX))
|
||||
stream->Write(transform.Scale.X);
|
||||
if (data.Components & ReplicationComponents::ScaleY)
|
||||
if (EnumHasAnyFlags(data.Components, ReplicationComponents::ScaleY))
|
||||
stream->Write(transform.Scale.X);
|
||||
if (data.Components & ReplicationComponents::ScaleZ)
|
||||
if (EnumHasAnyFlags(data.Components, ReplicationComponents::ScaleZ))
|
||||
stream->Write(transform.Scale.X);
|
||||
}
|
||||
if ((data.Components & ReplicationComponents::Rotation) == (int)ReplicationComponents::Rotation)
|
||||
if (EnumHasAllFlags(data.Components, ReplicationComponents::Rotation))
|
||||
{
|
||||
const Float3 rotation = transform.Orientation.GetEuler();
|
||||
stream->Write(rotation);
|
||||
}
|
||||
else if (data.Components & ReplicationComponents::Rotation)
|
||||
else if (EnumHasAnyFlags(data.Components, ReplicationComponents::Rotation))
|
||||
{
|
||||
const Float3 rotation = transform.Orientation.GetEuler();
|
||||
if (data.Components & ReplicationComponents::RotationX)
|
||||
if (EnumHasAnyFlags(data.Components, ReplicationComponents::RotationX))
|
||||
stream->Write(rotation.X);
|
||||
if (data.Components & ReplicationComponents::RotationY)
|
||||
if (EnumHasAnyFlags(data.Components, ReplicationComponents::RotationY))
|
||||
stream->Write(rotation.Y);
|
||||
if (data.Components & ReplicationComponents::RotationZ)
|
||||
if (EnumHasAnyFlags(data.Components, ReplicationComponents::RotationZ))
|
||||
stream->Write(rotation.Z);
|
||||
}
|
||||
}
|
||||
@@ -227,52 +227,52 @@ void NetworkTransform::Deserialize(NetworkStream* stream)
|
||||
// Decode data
|
||||
Data data;
|
||||
stream->Read(data);
|
||||
if ((data.Components & ReplicationComponents::All) == (int)ReplicationComponents::All)
|
||||
if (EnumHasAllFlags(data.Components, ReplicationComponents::All))
|
||||
{
|
||||
stream->Read(transform);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((data.Components & ReplicationComponents::Position) == (int)ReplicationComponents::Position)
|
||||
if (EnumHasAllFlags(data.Components, ReplicationComponents::Position))
|
||||
{
|
||||
stream->Read(transform.Translation);
|
||||
}
|
||||
else if (data.Components & ReplicationComponents::Position)
|
||||
else if (EnumHasAnyFlags(data.Components, ReplicationComponents::Position))
|
||||
{
|
||||
if (data.Components & ReplicationComponents::PositionX)
|
||||
if (EnumHasAnyFlags(data.Components, ReplicationComponents::PositionX))
|
||||
stream->Read(transform.Translation.X);
|
||||
if (data.Components & ReplicationComponents::PositionY)
|
||||
if (EnumHasAnyFlags(data.Components, ReplicationComponents::PositionY))
|
||||
stream->Read(transform.Translation.X);
|
||||
if (data.Components & ReplicationComponents::PositionZ)
|
||||
if (EnumHasAnyFlags(data.Components, ReplicationComponents::PositionZ))
|
||||
stream->Read(transform.Translation.X);
|
||||
}
|
||||
if ((data.Components & ReplicationComponents::Scale) == (int)ReplicationComponents::Scale)
|
||||
if (EnumHasAllFlags(data.Components, ReplicationComponents::Scale))
|
||||
{
|
||||
stream->Read(transform.Scale);
|
||||
}
|
||||
else if (data.Components & ReplicationComponents::Scale)
|
||||
else if (EnumHasAnyFlags(data.Components, ReplicationComponents::Scale))
|
||||
{
|
||||
if (data.Components & ReplicationComponents::ScaleX)
|
||||
if (EnumHasAnyFlags(data.Components, ReplicationComponents::ScaleX))
|
||||
stream->Read(transform.Scale.X);
|
||||
if (data.Components & ReplicationComponents::ScaleY)
|
||||
if (EnumHasAnyFlags(data.Components, ReplicationComponents::ScaleY))
|
||||
stream->Read(transform.Scale.X);
|
||||
if (data.Components & ReplicationComponents::ScaleZ)
|
||||
if (EnumHasAnyFlags(data.Components, ReplicationComponents::ScaleZ))
|
||||
stream->Read(transform.Scale.X);
|
||||
}
|
||||
if ((data.Components & ReplicationComponents::Rotation) == (int)ReplicationComponents::Rotation)
|
||||
if (EnumHasAllFlags(data.Components, ReplicationComponents::Rotation))
|
||||
{
|
||||
Float3 rotation;
|
||||
stream->Read(rotation);
|
||||
transform.Orientation = Quaternion::Euler(rotation);
|
||||
}
|
||||
else if (data.Components & ReplicationComponents::Rotation)
|
||||
else if (EnumHasAnyFlags(data.Components, ReplicationComponents::Rotation))
|
||||
{
|
||||
Float3 rotation = transform.Orientation.GetEuler();
|
||||
if (data.Components & ReplicationComponents::RotationX)
|
||||
if (EnumHasAnyFlags(data.Components, ReplicationComponents::RotationX))
|
||||
stream->Read(rotation.X);
|
||||
if (data.Components & ReplicationComponents::RotationY)
|
||||
if (EnumHasAnyFlags(data.Components, ReplicationComponents::RotationY))
|
||||
stream->Read(rotation.Y);
|
||||
if (data.Components & ReplicationComponents::RotationZ)
|
||||
if (EnumHasAnyFlags(data.Components, ReplicationComponents::RotationZ))
|
||||
stream->Read(rotation.Z);
|
||||
transform.Orientation = Quaternion::Euler(rotation);
|
||||
}
|
||||
|
||||
@@ -409,7 +409,7 @@ void DrawEmitterCPU(RenderContext& renderContext, ParticleBuffer* buffer, DrawCa
|
||||
{
|
||||
const auto material = (MaterialBase*)module->Assets[0].Get();
|
||||
const auto moduleDrawModes = module->Values.Count() > 3 ? (DrawPass)module->Values[3].AsInt : DrawPass::Default;
|
||||
auto dp = (DrawPass)(drawModes & moduleDrawModes & (uint32)material->GetDrawModes());
|
||||
auto dp = drawModes & moduleDrawModes & material->GetDrawModes();
|
||||
if (dp == DrawPass::None)
|
||||
break;
|
||||
drawCall.Material = material;
|
||||
@@ -427,7 +427,7 @@ void DrawEmitterCPU(RenderContext& renderContext, ParticleBuffer* buffer, DrawCa
|
||||
const auto model = (Model*)module->Assets[0].Get();
|
||||
const auto material = (MaterialBase*)module->Assets[1].Get();
|
||||
const auto moduleDrawModes = module->Values.Count() > 4 ? (DrawPass)module->Values[4].AsInt : DrawPass::Default;
|
||||
auto dp = (DrawPass)(drawModes & moduleDrawModes & (uint32)material->GetDrawModes());
|
||||
auto dp = drawModes & moduleDrawModes & material->GetDrawModes();
|
||||
if (dp == DrawPass::None)
|
||||
break;
|
||||
drawCall.Material = material;
|
||||
@@ -457,7 +457,7 @@ void DrawEmitterCPU(RenderContext& renderContext, ParticleBuffer* buffer, DrawCa
|
||||
break;
|
||||
const auto material = (MaterialBase*)module->Assets[0].Get();
|
||||
const auto moduleDrawModes = module->Values.Count() > 6 ? (DrawPass)module->Values[6].AsInt : DrawPass::Default;
|
||||
auto dp = (DrawPass)(drawModes & moduleDrawModes & (uint32)material->GetDrawModes());
|
||||
auto dp = drawModes & moduleDrawModes & material->GetDrawModes();
|
||||
if (dp == DrawPass::None)
|
||||
break;
|
||||
drawCall.Material = material;
|
||||
@@ -820,7 +820,7 @@ void DrawEmitterGPU(RenderContext& renderContext, ParticleBuffer* buffer, DrawCa
|
||||
{
|
||||
const auto material = (MaterialBase*)module->Assets[0].Get();
|
||||
const auto moduleDrawModes = module->Values.Count() > 3 ? (DrawPass)module->Values[3].AsInt : DrawPass::Default;
|
||||
auto dp = (DrawPass)(drawModes & moduleDrawModes & (uint32)material->GetDrawModes());
|
||||
auto dp = drawModes & moduleDrawModes & material->GetDrawModes();
|
||||
drawCall.Material = material;
|
||||
|
||||
// Submit draw call
|
||||
@@ -840,7 +840,7 @@ void DrawEmitterGPU(RenderContext& renderContext, ParticleBuffer* buffer, DrawCa
|
||||
const auto model = (Model*)module->Assets[0].Get();
|
||||
const auto material = (MaterialBase*)module->Assets[1].Get();
|
||||
const auto moduleDrawModes = module->Values.Count() > 4 ? (DrawPass)module->Values[4].AsInt : DrawPass::Default;
|
||||
auto dp = (DrawPass)(drawModes & moduleDrawModes & (uint32)material->GetDrawModes());
|
||||
auto dp = drawModes & moduleDrawModes & material->GetDrawModes();
|
||||
drawCall.Material = material;
|
||||
|
||||
// TODO: model LOD picking for particles?
|
||||
@@ -887,7 +887,7 @@ void Particles::DrawParticles(RenderContext& renderContext, ParticleEffect* effe
|
||||
{
|
||||
// Setup
|
||||
auto& view = renderContext.View;
|
||||
const auto drawModes = static_cast<DrawPass>(view.Pass & effect->DrawModes);
|
||||
const auto drawModes = view.Pass & effect->DrawModes;
|
||||
if (drawModes == DrawPass::None || SpriteRenderer.Init())
|
||||
return;
|
||||
Matrix worlds[2];
|
||||
@@ -937,11 +937,11 @@ void Particles::DrawParticles(RenderContext& renderContext, ParticleEffect* effe
|
||||
case 400:
|
||||
{
|
||||
const auto material = (MaterialBase*)module->Assets[0].Get();
|
||||
const auto moduleDrawModes = module->Values.Count() > 3 ? module->Values[3].AsInt : (int32)DrawPass::Default;
|
||||
const auto moduleDrawModes = module->Values.Count() > 3 ? (DrawPass)module->Values[3].AsInt : DrawPass::Default;
|
||||
if (!material ||
|
||||
!material->IsReady() ||
|
||||
!material->IsParticle() ||
|
||||
(view.Pass & material->GetDrawModes() & moduleDrawModes) == 0
|
||||
(view.Pass & material->GetDrawModes() & moduleDrawModes) == DrawPass::None
|
||||
)
|
||||
break;
|
||||
renderModulesIndices.Add(moduleIndex);
|
||||
@@ -951,7 +951,7 @@ void Particles::DrawParticles(RenderContext& renderContext, ParticleEffect* effe
|
||||
case 403:
|
||||
{
|
||||
const auto model = (Model*)module->Assets[0].Get();
|
||||
const auto moduleDrawModes = module->Values.Count() > 4 ? module->Values[4].AsInt : (int32)DrawPass::Default;
|
||||
const auto moduleDrawModes = module->Values.Count() > 4 ? (DrawPass)module->Values[4].AsInt : DrawPass::Default;
|
||||
if (!model ||
|
||||
!model->IsLoaded() ||
|
||||
!model->CanBeRendered())
|
||||
@@ -960,7 +960,7 @@ void Particles::DrawParticles(RenderContext& renderContext, ParticleEffect* effe
|
||||
if (!material ||
|
||||
!material->IsReady() ||
|
||||
!material->IsParticle() ||
|
||||
(view.Pass & material->GetDrawModes() & moduleDrawModes) == 0
|
||||
(view.Pass & material->GetDrawModes() & moduleDrawModes) == DrawPass::None
|
||||
)
|
||||
break;
|
||||
renderModulesIndices.Add(moduleIndex);
|
||||
@@ -970,11 +970,11 @@ void Particles::DrawParticles(RenderContext& renderContext, ParticleEffect* effe
|
||||
case 404:
|
||||
{
|
||||
const auto material = (MaterialBase*)module->Assets[0].Get();
|
||||
const auto moduleDrawModes = module->Values.Count() > 6 ? module->Values[6].AsInt : (int32)DrawPass::Default;
|
||||
const auto moduleDrawModes = module->Values.Count() > 6 ? (DrawPass)module->Values[6].AsInt : DrawPass::Default;
|
||||
if (!material ||
|
||||
!material->IsReady() ||
|
||||
!material->IsParticle() ||
|
||||
(view.Pass & material->GetDrawModes() & moduleDrawModes) == 0
|
||||
(view.Pass & material->GetDrawModes() & moduleDrawModes) == DrawPass::None
|
||||
)
|
||||
break;
|
||||
renderModulesIndices.Add(moduleIndex);
|
||||
@@ -987,7 +987,7 @@ void Particles::DrawParticles(RenderContext& renderContext, ParticleEffect* effe
|
||||
if (!material ||
|
||||
!material->IsReady() ||
|
||||
material->GetInfo().Domain != MaterialDomain::VolumeParticle ||
|
||||
(view.Flags & ViewFlags::Fog) == 0
|
||||
(view.Flags & ViewFlags::Fog) == ViewFlags::None
|
||||
)
|
||||
break;
|
||||
renderModulesIndices.Add(moduleIndex);
|
||||
|
||||
@@ -79,13 +79,13 @@ void DistanceJoint::OnDebugDrawSelected()
|
||||
dir *= 1.0f / len;
|
||||
Vector3 start = source, end = target;
|
||||
float max = 0, min = 0;
|
||||
if (_flags & DistanceJointFlag::MinDistance)
|
||||
if (EnumHasAnyFlags(_flags, DistanceJointFlag::MinDistance))
|
||||
{
|
||||
min = Math::Min(_minDistance, len);
|
||||
start += dir * min;
|
||||
DEBUG_DRAW_LINE(source, start, Color::Red * 0.6f, 0, false);
|
||||
}
|
||||
if (_flags & DistanceJointFlag::MaxDistance)
|
||||
if (EnumHasAnyFlags(_flags, DistanceJointFlag::MaxDistance))
|
||||
{
|
||||
max = Math::Min(_maxDistance, len - min);
|
||||
end -= dir * max;
|
||||
|
||||
@@ -65,7 +65,7 @@ void HingeJoint::OnDebugDrawSelected()
|
||||
const Color color = Color::Green.AlphaMultiplied(0.6f);
|
||||
DEBUG_DRAW_WIRE_ARROW(source, sourceRotation, size / 100.0f * 0.5f, Color::Red, 0, false);
|
||||
DEBUG_DRAW_WIRE_ARROW(target, targetRotation, size / 100.0f * 0.5f, Color::Blue, 0, false);
|
||||
if (_flags & HingeJointFlag::Limit)
|
||||
if (EnumHasAnyFlags(_flags, HingeJointFlag::Limit))
|
||||
{
|
||||
const float upper = Math::Max(_limit.Upper, _limit.Lower);
|
||||
const float range = Math::Abs(upper - _limit.Lower);
|
||||
|
||||
@@ -49,7 +49,7 @@ void SliderJoint::OnDebugDrawSelected()
|
||||
const Vector3 source = GetPosition();
|
||||
const Vector3 normal = GetOrientation() * Vector3::Right;
|
||||
float min = -100.0f, max = 100.0f;
|
||||
if (_flags & SliderJointFlag::Limit)
|
||||
if (EnumHasAnyFlags(_flags, SliderJointFlag::Limit))
|
||||
{
|
||||
min = _limit.Lower;
|
||||
max = _limit.Upper;
|
||||
|
||||
@@ -40,7 +40,7 @@ void SphericalJoint::OnDebugDrawSelected()
|
||||
const float size = 15.0f;
|
||||
const Color color = Color::Green.AlphaMultiplied(0.6f);
|
||||
DEBUG_DRAW_WIRE_ARROW(source, GetOrientation(), size / 100.0f * 0.5f, Color::Red, 0, false);
|
||||
if (_flags & SphericalJointFlag::Limit)
|
||||
if (EnumHasAnyFlags(_flags, SphericalJointFlag::Limit))
|
||||
{
|
||||
DEBUG_DRAW_CONE(source, GetOrientation(), size, _limit.YLimitAngle * DegreesToRadians, _limit.ZLimitAngle * DegreesToRadians, color, 0, false);
|
||||
}
|
||||
|
||||
@@ -569,16 +569,16 @@ bool CollisionCooking::CookConvexMesh(CookingInput& input, BytesContainer& outpu
|
||||
desc.vertexLimit = CONVEX_VERTEX_MAX;
|
||||
else
|
||||
desc.vertexLimit = (PxU16)Math::Clamp(input.ConvexVertexLimit, CONVEX_VERTEX_MIN, CONVEX_VERTEX_MAX);
|
||||
if (input.ConvexFlags & ConvexMeshGenerationFlags::SkipValidation)
|
||||
if (EnumHasAnyFlags(input.ConvexFlags, ConvexMeshGenerationFlags::SkipValidation))
|
||||
desc.flags |= PxConvexFlag::Enum::eDISABLE_MESH_VALIDATION;
|
||||
if (input.ConvexFlags & ConvexMeshGenerationFlags::UsePlaneShifting)
|
||||
if (EnumHasAnyFlags(input.ConvexFlags, ConvexMeshGenerationFlags::UsePlaneShifting))
|
||||
desc.flags |= PxConvexFlag::Enum::ePLANE_SHIFTING;
|
||||
if (input.ConvexFlags & ConvexMeshGenerationFlags::UseFastInteriaComputation)
|
||||
if (EnumHasAnyFlags(input.ConvexFlags, ConvexMeshGenerationFlags::UseFastInteriaComputation))
|
||||
desc.flags |= PxConvexFlag::Enum::eFAST_INERTIA_COMPUTATION;
|
||||
if (input.ConvexFlags & ConvexMeshGenerationFlags::ShiftVertices)
|
||||
if (EnumHasAnyFlags(input.ConvexFlags, ConvexMeshGenerationFlags::ShiftVertices))
|
||||
desc.flags |= PxConvexFlag::Enum::eSHIFT_VERTICES;
|
||||
PxCookingParams cookingParams = cooking->getParams();
|
||||
cookingParams.suppressTriangleMeshRemapTable = input.ConvexFlags & ConvexMeshGenerationFlags::SuppressFaceRemapTable;
|
||||
cookingParams.suppressTriangleMeshRemapTable = EnumHasAnyFlags(input.ConvexFlags, ConvexMeshGenerationFlags::SuppressFaceRemapTable);
|
||||
cooking->setParams(cookingParams);
|
||||
|
||||
// Perform cooking
|
||||
@@ -612,7 +612,7 @@ bool CollisionCooking::CookTriangleMesh(CookingInput& input, BytesContainer& out
|
||||
desc.triangles.data = input.IndexData;
|
||||
desc.flags = input.Is16bitIndexData ? PxMeshFlag::e16_BIT_INDICES : (PxMeshFlag::Enum)0;
|
||||
PxCookingParams cookingParams = cooking->getParams();
|
||||
cookingParams.suppressTriangleMeshRemapTable = input.ConvexFlags & ConvexMeshGenerationFlags::SuppressFaceRemapTable;
|
||||
cookingParams.suppressTriangleMeshRemapTable = EnumHasAnyFlags(input.ConvexFlags, ConvexMeshGenerationFlags::SuppressFaceRemapTable);
|
||||
cooking->setParams(cookingParams);
|
||||
|
||||
// Perform cooking
|
||||
@@ -1628,9 +1628,9 @@ void PhysicsBackend::SetActorFlags(void* actor, ActorFlags value)
|
||||
#if WITH_PVD
|
||||
flags |= PxActorFlag::eVISUALIZATION;
|
||||
#endif
|
||||
if (value & ActorFlags::NoGravity)
|
||||
if (EnumHasAnyFlags(value, ActorFlags::NoGravity))
|
||||
flags |= PxActorFlag::eDISABLE_GRAVITY;
|
||||
if (value & ActorFlags::NoSimulation)
|
||||
if (EnumHasAnyFlags(value, ActorFlags::NoSimulation))
|
||||
flags |= PxActorFlag::eDISABLE_SIMULATION;
|
||||
actorPhysX->setActorFlags(flags);
|
||||
}
|
||||
@@ -1697,9 +1697,9 @@ void PhysicsBackend::SetRigidDynamicActorFlags(void* actor, RigidDynamicFlags va
|
||||
{
|
||||
auto actorPhysX = (PxRigidDynamic*)actor;
|
||||
auto flags = (PxRigidBodyFlags)0;
|
||||
if (value & RigidDynamicFlags::Kinematic)
|
||||
if (EnumHasAnyFlags(value, RigidDynamicFlags::Kinematic))
|
||||
flags |= PxRigidBodyFlag::eKINEMATIC;
|
||||
if (value & RigidDynamicFlags::CCD)
|
||||
if (EnumHasAnyFlags(value, RigidDynamicFlags::CCD))
|
||||
flags |= PxRigidBodyFlag::eENABLE_CCD;
|
||||
actorPhysX->setRigidBodyFlags(flags);
|
||||
}
|
||||
@@ -2089,7 +2089,7 @@ bool PhysicsBackend::RayCastShape(void* shape, const Vector3& position, const Qu
|
||||
void PhysicsBackend::SetJointFlags(void* joint, JointFlags value)
|
||||
{
|
||||
auto jointPhysX = (PxJoint*)joint;
|
||||
jointPhysX->setConstraintFlag(PxConstraintFlag::eCOLLISION_ENABLED, value & JointFlags::Collision);
|
||||
jointPhysX->setConstraintFlag(PxConstraintFlag::eCOLLISION_ENABLED, EnumHasAnyFlags(value, JointFlags::Collision));
|
||||
}
|
||||
|
||||
void PhysicsBackend::SetJointActors(void* joint, void* actors0, void* actor1)
|
||||
@@ -2235,9 +2235,9 @@ void PhysicsBackend::SetHingeJointFlags(void* joint, HingeJointFlag value, bool
|
||||
{
|
||||
auto jointPhysX = (PxRevoluteJoint*)joint;
|
||||
PxRevoluteJointFlags flags = (PxRevoluteJointFlags)0;
|
||||
if (value & HingeJointFlag::Limit)
|
||||
if (EnumHasAnyFlags(value, HingeJointFlag::Limit))
|
||||
flags |= PxRevoluteJointFlag::eLIMIT_ENABLED;
|
||||
if (value & HingeJointFlag::Drive)
|
||||
if (EnumHasAnyFlags(value, HingeJointFlag::Drive))
|
||||
flags |= PxRevoluteJointFlag::eDRIVE_ENABLED;
|
||||
if (driveFreeSpin)
|
||||
flags |= PxRevoluteJointFlag::eDRIVE_FREESPIN;
|
||||
@@ -2279,7 +2279,7 @@ float PhysicsBackend::GetHingeJointVelocity(void* joint)
|
||||
void PhysicsBackend::SetSliderJointFlags(void* joint, SliderJointFlag value)
|
||||
{
|
||||
auto jointPhysX = (PxPrismaticJoint*)joint;
|
||||
jointPhysX->setPrismaticJointFlag(PxPrismaticJointFlag::eLIMIT_ENABLED, (value & SliderJointFlag::Limit) != 0);
|
||||
jointPhysX->setPrismaticJointFlag(PxPrismaticJointFlag::eLIMIT_ENABLED, EnumHasAnyFlags(value, SliderJointFlag::Limit));
|
||||
}
|
||||
|
||||
void PhysicsBackend::SetSliderJointLimit(void* joint, const LimitLinearRange& value)
|
||||
@@ -2308,7 +2308,7 @@ float PhysicsBackend::GetSliderJointVelocity(void* joint)
|
||||
void PhysicsBackend::SetSphericalJointFlags(void* joint, SphericalJointFlag value)
|
||||
{
|
||||
auto jointPhysX = (PxSphericalJoint*)joint;
|
||||
jointPhysX->setSphericalJointFlag(PxSphericalJointFlag::eLIMIT_ENABLED, (value & SphericalJointFlag::Limit) != 0);
|
||||
jointPhysX->setSphericalJointFlag(PxSphericalJointFlag::eLIMIT_ENABLED, EnumHasAnyFlags(value, SphericalJointFlag::Limit));
|
||||
}
|
||||
|
||||
void PhysicsBackend::SetSphericalJointLimit(void* joint, const LimitConeRange& value)
|
||||
|
||||
@@ -116,7 +116,7 @@ Font* FontAsset::CreateFont(int32 size)
|
||||
FontAsset* FontAsset::GetBold()
|
||||
{
|
||||
ScopeLock lock(Locker);
|
||||
if (_options.Flags & FontFlags::Bold)
|
||||
if (EnumHasAnyFlags(_options.Flags, FontFlags::Bold))
|
||||
return this;
|
||||
if (!_virtualBold)
|
||||
{
|
||||
@@ -132,7 +132,7 @@ FontAsset* FontAsset::GetBold()
|
||||
FontAsset* FontAsset::GetItalic()
|
||||
{
|
||||
ScopeLock lock(Locker);
|
||||
if (_options.Flags & FontFlags::Italic)
|
||||
if (EnumHasAnyFlags(_options.Flags, FontFlags::Italic))
|
||||
return this;
|
||||
if (!_virtualItalic)
|
||||
{
|
||||
|
||||
@@ -125,7 +125,8 @@ bool FontManager::AddNewEntry(Font* font, Char c, FontCharacterEntry& entry)
|
||||
|
||||
// Set load flags
|
||||
uint32 glyphFlags = FT_LOAD_NO_BITMAP;
|
||||
if (options.Flags & FontFlags::AntiAliasing)
|
||||
const bool useAA = EnumHasAnyFlags(options.Flags, FontFlags::AntiAliasing);
|
||||
if (useAA)
|
||||
{
|
||||
switch (options.Hinting)
|
||||
{
|
||||
@@ -164,18 +165,18 @@ bool FontManager::AddNewEntry(Font* font, Char c, FontCharacterEntry& entry)
|
||||
}
|
||||
|
||||
// Handle special effects
|
||||
if (options.Flags & FontFlags::Bold)
|
||||
if (EnumHasAnyFlags(options.Flags, FontFlags::Bold))
|
||||
{
|
||||
FT_GlyphSlot_Embolden(face->glyph);
|
||||
}
|
||||
if (options.Flags & FontFlags::Italic)
|
||||
if (EnumHasAnyFlags(options.Flags, FontFlags::Italic))
|
||||
{
|
||||
FT_GlyphSlot_Oblique(face->glyph);
|
||||
}
|
||||
|
||||
// Render glyph to the bitmap
|
||||
FT_GlyphSlot glyph = face->glyph;
|
||||
FT_Render_Glyph(glyph, options.Flags & FontFlags::AntiAliasing ? FT_RENDER_MODE_NORMAL : FT_RENDER_MODE_MONO);
|
||||
FT_Render_Glyph(glyph, useAA ? FT_RENDER_MODE_NORMAL : FT_RENDER_MODE_MONO);
|
||||
|
||||
FT_Bitmap* bitmap = &glyph->bitmap;
|
||||
FT_Bitmap tmpBitmap;
|
||||
|
||||
@@ -206,7 +206,7 @@ void AmbientOcclusionPass::Render(RenderContext& renderContext)
|
||||
if (renderContext.List == nullptr)
|
||||
return;
|
||||
auto& aoSettings = renderContext.List->Settings.AmbientOcclusion;
|
||||
if (aoSettings.Enabled == false || (renderContext.View.Flags & ViewFlags::AO) == 0)
|
||||
if (aoSettings.Enabled == false || (renderContext.View.Flags & ViewFlags::AO) == ViewFlags::None)
|
||||
return;
|
||||
|
||||
// TODO: add support for SSAO in ortho projection
|
||||
|
||||
@@ -62,7 +62,7 @@ bool ColorGradingPass::Init()
|
||||
formatSupportFlags |= FormatSupport::Texture3D;
|
||||
else
|
||||
formatSupportFlags |= FormatSupport::Texture2D;
|
||||
if (FORMAT_FEATURES_ARE_NOT_SUPPORTED(formatSupport, formatSupportFlags))
|
||||
if (!EnumHasAllFlags(formatSupport, formatSupportFlags))
|
||||
{
|
||||
// Fallback to format that is supported on every washing machine
|
||||
_lutFormat = PixelFormat::R8G8B8A8_UNorm;
|
||||
|
||||
@@ -209,7 +209,7 @@ void DepthOfFieldPass::Render(RenderContext& renderContext, GPUTexture*& frame,
|
||||
const auto depthBuffer = renderContext.Buffers->DepthBuffer;
|
||||
const auto shader = _shader->GetShader();
|
||||
DepthOfFieldSettings& dofSettings = renderContext.List->Settings.DepthOfField;
|
||||
const bool useDoF = _platformSupportsDoF && (renderContext.View.Flags & ViewFlags::DepthOfField) != 0 && dofSettings.Enabled;
|
||||
const bool useDoF = _platformSupportsDoF && EnumHasAnyFlags(renderContext.View.Flags, ViewFlags::DepthOfField) && dofSettings.Enabled;
|
||||
if (!useDoF)
|
||||
return;
|
||||
PROFILE_GPU_CPU("Depth Of Field");
|
||||
|
||||
@@ -150,7 +150,7 @@ void MaterialComplexityMaterialShader::Draw(RenderContext& renderContext, GPUCon
|
||||
// Draw transparency into Light buffer to include it into complexity drawing
|
||||
GPUTexture* depthBuffer = renderContext.Buffers->DepthBuffer;
|
||||
GPUTextureView* readOnlyDepthBuffer = depthBuffer->View();
|
||||
if (depthBuffer->GetDescription().Flags & GPUTextureFlags::ReadOnlyDepthView)
|
||||
if (EnumHasAnyFlags(depthBuffer->Flags(), GPUTextureFlags::ReadOnlyDepthView))
|
||||
readOnlyDepthBuffer = depthBuffer->ViewReadOnlyDepth();
|
||||
context->SetRenderTarget(readOnlyDepthBuffer, lightBuffer);
|
||||
auto& distortionList = renderContext.List->DrawCallsLists[(int32)DrawCallsListType::Distortion];
|
||||
@@ -196,7 +196,7 @@ void MaterialComplexityMaterialShader::DebugOverrideDrawCallsMaterial(DrawCall&
|
||||
switch (domain)
|
||||
{
|
||||
case MaterialDomain::Surface:
|
||||
wrapperIndex = drawCall.Material->GetDrawModes() & DrawPass::Forward ? 1 : 0;
|
||||
wrapperIndex = EnumHasAnyFlags(drawCall.Material->GetDrawModes(), DrawPass::Forward) ? 1 : 0;
|
||||
break;
|
||||
case MaterialDomain::Terrain:
|
||||
wrapperIndex = 2;
|
||||
|
||||
@@ -93,7 +93,7 @@ void QuadOverdrawPass::Render(RenderContext& renderContext, GPUContext* context,
|
||||
}
|
||||
GPUTexture* depthBuffer = renderContext.Buffers->DepthBuffer;
|
||||
GPUTextureView* readOnlyDepthBuffer = depthBuffer->View();
|
||||
if (depthBuffer->GetDescription().Flags & GPUTextureFlags::ReadOnlyDepthView)
|
||||
if (EnumHasAnyFlags(depthBuffer->Flags(), GPUTextureFlags::ReadOnlyDepthView))
|
||||
readOnlyDepthBuffer = depthBuffer->ViewReadOnlyDepth();
|
||||
context->ResetSR();
|
||||
context->ResetRenderTarget();
|
||||
|
||||
@@ -47,7 +47,7 @@ void EyeAdaptationPass::Render(RenderContext& renderContext, GPUTexture* colorBu
|
||||
renderContext.Buffers->LastEyeAdaptationTime = 0.0f;
|
||||
|
||||
// Optionally skip the rendering
|
||||
if (checkIfSkipPass() || (view.Flags & ViewFlags::EyeAdaptation) == 0 || settings.Mode == EyeAdaptationMode::None)
|
||||
if (checkIfSkipPass() || (view.Flags & ViewFlags::EyeAdaptation) == ViewFlags::None || settings.Mode == EyeAdaptationMode::None)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ void ForwardPass::Render(RenderContext& renderContext, GPUTexture* input, GPUTex
|
||||
// Try to use read-only depth if supported
|
||||
GPUTexture* depthBuffer = renderContext.Buffers->DepthBuffer;
|
||||
GPUTextureView* depthBufferHandle = depthBuffer->View();
|
||||
if (depthBuffer->GetDescription().Flags & GPUTextureFlags::ReadOnlyDepthView)
|
||||
if (EnumHasAnyFlags(depthBuffer->Flags(), GPUTextureFlags::ReadOnlyDepthView))
|
||||
depthBufferHandle = depthBuffer->ViewReadOnlyDepth();
|
||||
|
||||
// Check if there is no objects to render or no resources ready
|
||||
|
||||
@@ -116,7 +116,7 @@ void DebugOverrideDrawCallsMaterial(const RenderContext& renderContext, IMateria
|
||||
IMaterial::InstancingHandler handler;
|
||||
const bool canUseInstancing = material->CanUseInstancing(handler);
|
||||
const auto drawModes = material->GetDrawModes();
|
||||
if (drawModes & DrawPass::GBuffer)
|
||||
if (EnumHasAnyFlags(drawModes, DrawPass::GBuffer))
|
||||
{
|
||||
auto& drawCallsList = renderContext.List->DrawCallsLists[(int32)DrawCallsListType::GBuffer];
|
||||
for (int32 i : drawCallsList.Indices)
|
||||
@@ -129,7 +129,7 @@ void DebugOverrideDrawCallsMaterial(const RenderContext& renderContext, IMateria
|
||||
}
|
||||
drawCallsList.CanUseInstancing &= canUseInstancing;
|
||||
}
|
||||
if (drawModes & DrawPass::GBuffer)
|
||||
if (EnumHasAnyFlags(drawModes, DrawPass::GBuffer))
|
||||
{
|
||||
auto& drawCallsList = renderContext.List->DrawCallsLists[(int32)DrawCallsListType::GBufferNoDecals];
|
||||
for (int32 i : drawCallsList.Indices)
|
||||
@@ -473,18 +473,18 @@ void GBufferPass::DrawDecals(RenderContext& renderContext, GPUTextureView* light
|
||||
int32 count = 2;
|
||||
targetBuffers[0] = buffers->GBuffer0->View();
|
||||
targetBuffers[1] = buffers->GBuffer2->View();
|
||||
if (info.UsageFlags & MaterialUsageFlags::UseEmissive)
|
||||
if (EnumHasAnyFlags(info.UsageFlags, MaterialUsageFlags::UseEmissive))
|
||||
{
|
||||
count++;
|
||||
targetBuffers[2] = lightBuffer;
|
||||
|
||||
if (info.UsageFlags & MaterialUsageFlags::UseNormal)
|
||||
if (EnumHasAnyFlags(info.UsageFlags, MaterialUsageFlags::UseNormal))
|
||||
{
|
||||
count++;
|
||||
targetBuffers[3] = buffers->GBuffer1->View();
|
||||
}
|
||||
}
|
||||
else if (info.UsageFlags & MaterialUsageFlags::UseNormal)
|
||||
else if (EnumHasAnyFlags(info.UsageFlags, MaterialUsageFlags::UseNormal))
|
||||
{
|
||||
count++;
|
||||
targetBuffers[2] = buffers->GBuffer1->View();
|
||||
|
||||
@@ -820,7 +820,7 @@ bool GlobalSurfaceAtlasPass::Render(RenderContext& renderContext, GPUContext* co
|
||||
{
|
||||
GlobalSurfaceAtlasLight& lightData = surfaceAtlasData.Lights[light.ID];
|
||||
lightData.LastFrameUsed = currentFrame;
|
||||
uint32 redrawFramesCount = (light.StaticFlags & StaticFlags::Lightmap) ? 120 : 4;
|
||||
uint32 redrawFramesCount = EnumHasAnyFlags(light.StaticFlags, StaticFlags::Lightmap) ? 120 : 4;
|
||||
if (surfaceAtlasData.CurrentFrame - lightData.LastFrameUpdated < (redrawFramesCount + (light.ID.D & redrawFramesCount)))
|
||||
continue;
|
||||
lightData.LastFrameUpdated = currentFrame;
|
||||
@@ -828,7 +828,7 @@ bool GlobalSurfaceAtlasPass::Render(RenderContext& renderContext, GPUContext* co
|
||||
// Mark all objects to shade
|
||||
allLightingDirty = true;
|
||||
}
|
||||
if (renderContext.View.Flags & ViewFlags::GI && (renderContext.List->DirectionalLights.Count() != 1 || renderContext.List->DirectionalLights[0].StaticFlags & StaticFlags::Lightmap))
|
||||
if (EnumHasAnyFlags(renderContext.View.Flags, ViewFlags::GI) && (renderContext.List->DirectionalLights.Count() != 1 || EnumHasAnyFlags(renderContext.List->DirectionalLights[0].StaticFlags, StaticFlags::Lightmap)))
|
||||
{
|
||||
switch (renderContext.List->Settings.GlobalIllumination.Mode)
|
||||
{
|
||||
@@ -855,7 +855,7 @@ bool GlobalSurfaceAtlasPass::Render(RenderContext& renderContext, GPUContext* co
|
||||
{
|
||||
GlobalSurfaceAtlasLight& lightData = surfaceAtlasData.Lights[light.ID];
|
||||
lightData.LastFrameUsed = currentFrame;
|
||||
uint32 redrawFramesCount = (light.StaticFlags & StaticFlags::Lightmap) ? 120 : 4;
|
||||
uint32 redrawFramesCount = EnumHasAnyFlags(light.StaticFlags, StaticFlags::Lightmap) ? 120 : 4;
|
||||
if (surfaceAtlasData.CurrentFrame - lightData.LastFrameUpdated < (redrawFramesCount + (light.ID.D & redrawFramesCount)))
|
||||
continue;
|
||||
lightData.LastFrameUpdated = currentFrame;
|
||||
@@ -877,7 +877,7 @@ bool GlobalSurfaceAtlasPass::Render(RenderContext& renderContext, GPUContext* co
|
||||
{
|
||||
GlobalSurfaceAtlasLight& lightData = surfaceAtlasData.Lights[light.ID];
|
||||
lightData.LastFrameUsed = currentFrame;
|
||||
uint32 redrawFramesCount = (light.StaticFlags & StaticFlags::Lightmap) ? 120 : 4;
|
||||
uint32 redrawFramesCount = EnumHasAnyFlags(light.StaticFlags, StaticFlags::Lightmap) ? 120 : 4;
|
||||
if (surfaceAtlasData.CurrentFrame - lightData.LastFrameUpdated < (redrawFramesCount + (light.ID.D & redrawFramesCount)))
|
||||
continue;
|
||||
lightData.LastFrameUpdated = currentFrame;
|
||||
@@ -1028,7 +1028,7 @@ bool GlobalSurfaceAtlasPass::Render(RenderContext& renderContext, GPUContext* co
|
||||
}
|
||||
|
||||
// Draw draw indirect light from Global Illumination
|
||||
if (renderContext.View.Flags & ViewFlags::GI)
|
||||
if (EnumHasAnyFlags(renderContext.View.Flags, ViewFlags::GI))
|
||||
{
|
||||
switch (giSettings.Mode)
|
||||
{
|
||||
@@ -1081,7 +1081,7 @@ bool GlobalSurfaceAtlasPass::Render(RenderContext& renderContext, GPUContext* co
|
||||
void GlobalSurfaceAtlasPass::RenderDebug(RenderContext& renderContext, GPUContext* context, GPUTexture* output)
|
||||
{
|
||||
// Render all dependant effects before
|
||||
if (renderContext.View.Flags & ViewFlags::GI)
|
||||
if (EnumHasAnyFlags(renderContext.View.Flags, ViewFlags::GI))
|
||||
{
|
||||
switch (renderContext.List->Settings.GlobalIllumination.Mode)
|
||||
{
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
#define GLOBAL_SDF_MIP_FLOODS 5 // Amount of flood fill passes for mip.
|
||||
#define GLOBAL_SDF_DEBUG_CHUNKS 0
|
||||
#define GLOBAL_SDF_DEBUG_FORCE_REDRAW 0 // Forces to redraw all SDF cascades every frame
|
||||
#define GLOBAL_SDF_ACTOR_IS_STATIC(actor) ((actor->GetStaticFlags() & (StaticFlags::Lightmap | StaticFlags::Transform)) == (int32)(StaticFlags::Lightmap | StaticFlags::Transform))
|
||||
#define GLOBAL_SDF_ACTOR_IS_STATIC(actor) EnumHasAllFlags(actor->GetStaticFlags(), StaticFlags::Lightmap | StaticFlags::Transform)
|
||||
|
||||
static_assert(GLOBAL_SDF_RASTERIZE_MODEL_MAX_COUNT % 4 == 0, "Must be multiple of 4 due to data packing for GPU constant buffer.");
|
||||
#if GLOBAL_SDF_DEBUG_CHUNKS
|
||||
@@ -272,7 +272,7 @@ bool GlobalSignDistanceFieldPass::Init()
|
||||
// Check platform support
|
||||
const auto device = GPUDevice::Instance;
|
||||
_supported = device->GetFeatureLevel() >= FeatureLevel::SM5 && device->Limits.HasCompute && device->Limits.HasTypedUAVLoad
|
||||
&& FORMAT_FEATURES_ARE_SUPPORTED(device->GetFormatFeatures(GLOBAL_SDF_FORMAT).Support, FormatSupport::ShaderSample | FormatSupport::Texture3D);
|
||||
&& EnumHasAllFlags(device->GetFormatFeatures(GLOBAL_SDF_FORMAT).Support, FormatSupport::ShaderSample | FormatSupport::Texture3D);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ bool LightPass::Init()
|
||||
#endif
|
||||
|
||||
auto format = PixelFormat::R8G8_UNorm;
|
||||
if (FORMAT_FEATURES_ARE_NOT_SUPPORTED(GPUDevice::Instance->GetFormatFeatures(format).Support, (FormatSupport::RenderTarget | FormatSupport::ShaderSample | FormatSupport::Texture2D)))
|
||||
if (!EnumHasAllFlags(GPUDevice::Instance->GetFormatFeatures(format).Support, (FormatSupport::RenderTarget | FormatSupport::ShaderSample | FormatSupport::Texture2D)))
|
||||
{
|
||||
format = PixelFormat::B8G8R8A8_UNorm;
|
||||
}
|
||||
@@ -171,8 +171,8 @@ void LightPass::RenderLight(RenderContextBatch& renderContextBatch, GPUTextureVi
|
||||
auto& view = renderContext.View;
|
||||
auto mainCache = renderContext.List;
|
||||
const auto lightShader = _shader->GetShader();
|
||||
const bool useShadows = ShadowsPass::Instance()->IsReady() && ((view.Flags & ViewFlags::Shadows) != 0);
|
||||
const bool disableSpecular = (view.Flags & ViewFlags::SpecularLight) == 0;
|
||||
const bool useShadows = ShadowsPass::Instance()->IsReady() && EnumHasAnyFlags(view.Flags, ViewFlags::Shadows);
|
||||
const bool disableSpecular = (view.Flags & ViewFlags::SpecularLight) == ViewFlags::None;
|
||||
|
||||
// Check if debug lights
|
||||
if (renderContext.View.Mode == ViewMode::LightBuffer)
|
||||
@@ -210,7 +210,7 @@ void LightPass::RenderLight(RenderContextBatch& renderContextBatch, GPUTextureVi
|
||||
|
||||
// Bind output
|
||||
GPUTexture* depthBuffer = renderContext.Buffers->DepthBuffer;
|
||||
const bool depthBufferReadOnly = (depthBuffer->GetDescription().Flags & GPUTextureFlags::ReadOnlyDepthView) != 0;
|
||||
const bool depthBufferReadOnly = EnumHasAnyFlags(depthBuffer->Flags(), GPUTextureFlags::ReadOnlyDepthView);
|
||||
GPUTextureView* depthBufferRTV = depthBufferReadOnly ? depthBuffer->ViewReadOnlyDepth() : nullptr;
|
||||
GPUTextureView* depthBufferSRV = depthBufferReadOnly ? depthBuffer->ViewReadOnlyDepth() : depthBuffer->View();
|
||||
context->SetRenderTarget(depthBufferRTV, lightBuffer);
|
||||
|
||||
@@ -62,11 +62,11 @@ bool MotionBlurPass::Init()
|
||||
|
||||
// Prepare formats for the buffers
|
||||
auto format = PixelFormat::R16G16_Float;
|
||||
if (FORMAT_FEATURES_ARE_NOT_SUPPORTED(GPUDevice::Instance->GetFormatFeatures(format).Support, FormatSupport::RenderTarget | FormatSupport::ShaderSample | FormatSupport::Texture2D))
|
||||
if (!EnumHasAllFlags(GPUDevice::Instance->GetFormatFeatures(format).Support, FormatSupport::RenderTarget | FormatSupport::ShaderSample | FormatSupport::Texture2D))
|
||||
{
|
||||
if (FORMAT_FEATURES_ARE_NOT_SUPPORTED(GPUDevice::Instance->GetFormatFeatures(PixelFormat::R32G32_Float).Support, FormatSupport::RenderTarget | FormatSupport::ShaderSample | FormatSupport::Texture2D))
|
||||
if (!EnumHasAllFlags(GPUDevice::Instance->GetFormatFeatures(PixelFormat::R32G32_Float).Support, FormatSupport::RenderTarget | FormatSupport::ShaderSample | FormatSupport::Texture2D))
|
||||
format = PixelFormat::R32G32_Float;
|
||||
else if (FORMAT_FEATURES_ARE_NOT_SUPPORTED(GPUDevice::Instance->GetFormatFeatures(PixelFormat::R16G16B16A16_Float).Support, FormatSupport::RenderTarget | FormatSupport::ShaderSample | FormatSupport::Texture2D))
|
||||
else if (!EnumHasAllFlags(GPUDevice::Instance->GetFormatFeatures(PixelFormat::R16G16B16A16_Float).Support, FormatSupport::RenderTarget | FormatSupport::ShaderSample | FormatSupport::Texture2D))
|
||||
format = PixelFormat::R16G16B16A16_Float;
|
||||
else
|
||||
format = PixelFormat::R32G32B32A32_Float;
|
||||
@@ -269,7 +269,7 @@ void MotionBlurPass::Render(RenderContext& renderContext, GPUTexture*& frame, GP
|
||||
const int32 screenHeight = frame->Height();
|
||||
const int32 motionVectorsWidth = screenWidth / static_cast<int32>(settings.MotionVectorsResolution);
|
||||
const int32 motionVectorsHeight = screenHeight / static_cast<int32>(settings.MotionVectorsResolution);
|
||||
if ((renderContext.View.Flags & ViewFlags::MotionBlur) == 0 ||
|
||||
if ((renderContext.View.Flags & ViewFlags::MotionBlur) == ViewFlags::None ||
|
||||
!_hasValidResources ||
|
||||
isCameraCut ||
|
||||
screenWidth < 16 ||
|
||||
|
||||
@@ -200,10 +200,10 @@ void PostProcessingPass::Render(RenderContext& renderContext, GPUTexture* input,
|
||||
|
||||
// Cache data
|
||||
PostProcessSettings& settings = renderContext.List->Settings;
|
||||
bool useBloom = (view.Flags & ViewFlags::Bloom) != 0 && settings.Bloom.Enabled && settings.Bloom.Intensity > 0.0f;
|
||||
bool useToneMapping = (view.Flags & ViewFlags::ToneMapping) != 0;
|
||||
bool useCameraArtifacts = (view.Flags & ViewFlags::CameraArtifacts) != 0;
|
||||
bool useLensFlares = (view.Flags & ViewFlags::LensFlares) != 0 && settings.LensFlares.Intensity > 0.0f && useBloom;
|
||||
bool useBloom = EnumHasAnyFlags(view.Flags, ViewFlags::Bloom) && settings.Bloom.Enabled && settings.Bloom.Intensity > 0.0f;
|
||||
bool useToneMapping = EnumHasAnyFlags(view.Flags, ViewFlags::ToneMapping);
|
||||
bool useCameraArtifacts = EnumHasAnyFlags(view.Flags, ViewFlags::CameraArtifacts);
|
||||
bool useLensFlares = EnumHasAnyFlags(view.Flags, ViewFlags::LensFlares) && settings.LensFlares.Intensity > 0.0f && useBloom;
|
||||
|
||||
// Ensure to have valid data and if at least one effect should be applied
|
||||
if (!(useBloom || useToneMapping || useCameraArtifacts))
|
||||
|
||||
@@ -370,9 +370,9 @@ void ReflectionsPass::Render(RenderContext& renderContext, GPUTextureView* light
|
||||
|
||||
// Cache data
|
||||
auto& view = renderContext.View;
|
||||
bool useReflections = ((view.Flags & ViewFlags::Reflections) != 0);
|
||||
bool useSSR = ((view.Flags & ViewFlags::SSR) != 0) && (renderContext.List->Settings.ScreenSpaceReflections.Intensity > ZeroTolerance);
|
||||
int32 probesCount = (int32)renderContext.List->EnvironmentProbes.Count();
|
||||
bool useReflections = EnumHasAnyFlags(view.Flags, ViewFlags::Reflections);
|
||||
bool useSSR = EnumHasAnyFlags(view.Flags, ViewFlags::SSR) && renderContext.List->Settings.ScreenSpaceReflections.Intensity > ZeroTolerance;
|
||||
int32 probesCount = renderContext.List->EnvironmentProbes.Count();
|
||||
bool renderProbes = probesCount > 0;
|
||||
auto shader = _shader->GetShader();
|
||||
auto cb = shader->GetCB(0);
|
||||
@@ -404,7 +404,7 @@ void ReflectionsPass::Render(RenderContext& renderContext, GPUTextureView* light
|
||||
context->SetRenderTarget(*reflectionsBuffer);
|
||||
|
||||
// Sort probes by the radius
|
||||
Sorting::QuickSort(renderContext.List->EnvironmentProbes.Get(), (int32)renderContext.List->EnvironmentProbes.Count(), &sortProbes);
|
||||
Sorting::QuickSort(renderContext.List->EnvironmentProbes.Get(), renderContext.List->EnvironmentProbes.Count(), &sortProbes);
|
||||
|
||||
// TODO: don't render too far probes, check area of the screen and apply culling!
|
||||
|
||||
|
||||
@@ -218,7 +218,7 @@ void RenderList::RunPostFxPass(GPUContext* context, RenderContext& renderContext
|
||||
needTempTarget = true;
|
||||
}
|
||||
}
|
||||
if (renderContext.View.Flags & ViewFlags::CustomPostProcess)
|
||||
if (EnumHasAnyFlags(renderContext.View.Flags, ViewFlags::CustomPostProcess))
|
||||
{
|
||||
for (const PostProcessEffect* fx : renderContext.List->PostFx)
|
||||
{
|
||||
@@ -259,7 +259,7 @@ void RenderList::RunPostFxPass(GPUContext* context, RenderContext& renderContext
|
||||
Swap(output, input);
|
||||
}
|
||||
}
|
||||
if (renderContext.View.Flags & ViewFlags::CustomPostProcess)
|
||||
if (EnumHasAnyFlags(renderContext.View.Flags, ViewFlags::CustomPostProcess))
|
||||
{
|
||||
for (PostProcessEffect* fx : renderContext.List->PostFx)
|
||||
{
|
||||
@@ -328,7 +328,7 @@ void RenderList::RunCustomPostFxPass(GPUContext* context, RenderContext& renderC
|
||||
|
||||
bool RenderList::HasAnyPostFx(const RenderContext& renderContext, PostProcessEffectLocation postProcess) const
|
||||
{
|
||||
if (renderContext.View.Flags & ViewFlags::CustomPostProcess)
|
||||
if (EnumHasAnyFlags(renderContext.View.Flags, ViewFlags::CustomPostProcess))
|
||||
{
|
||||
for (const PostProcessEffect* fx : renderContext.List->PostFx)
|
||||
{
|
||||
@@ -443,26 +443,26 @@ void RenderList::AddDrawCall(const RenderContext& renderContext, DrawPass drawMo
|
||||
const int32 index = DrawCalls.Add(drawCall);
|
||||
|
||||
// Add draw call to proper draw lists
|
||||
if (drawModes & DrawPass::Depth)
|
||||
if ((drawModes & DrawPass::Depth) != DrawPass::None)
|
||||
{
|
||||
DrawCallsLists[(int32)DrawCallsListType::Depth].Indices.Add(index);
|
||||
}
|
||||
if (drawModes & (DrawPass::GBuffer | DrawPass::GlobalSurfaceAtlas))
|
||||
if ((drawModes & (DrawPass::GBuffer | DrawPass::GlobalSurfaceAtlas)) != DrawPass::None)
|
||||
{
|
||||
if (receivesDecals)
|
||||
DrawCallsLists[(int32)DrawCallsListType::GBuffer].Indices.Add(index);
|
||||
else
|
||||
DrawCallsLists[(int32)DrawCallsListType::GBufferNoDecals].Indices.Add(index);
|
||||
}
|
||||
if (drawModes & DrawPass::Forward)
|
||||
if ((drawModes & DrawPass::Forward) != DrawPass::None)
|
||||
{
|
||||
DrawCallsLists[(int32)DrawCallsListType::Forward].Indices.Add(index);
|
||||
}
|
||||
if (drawModes & DrawPass::Distortion)
|
||||
if ((drawModes & DrawPass::Distortion) != DrawPass::None)
|
||||
{
|
||||
DrawCallsLists[(int32)DrawCallsListType::Distortion].Indices.Add(index);
|
||||
}
|
||||
if (drawModes & DrawPass::MotionVectors && (staticFlags & StaticFlags::Transform) == 0)
|
||||
if ((drawModes & DrawPass::MotionVectors) != DrawPass::None && (staticFlags & StaticFlags::Transform) == StaticFlags::None)
|
||||
{
|
||||
DrawCallsLists[(int32)DrawCallsListType::MotionVectors].Indices.Add(index);
|
||||
}
|
||||
@@ -482,30 +482,30 @@ void RenderList::AddDrawCall(const RenderContextBatch& renderContextBatch, DrawP
|
||||
const int32 index = DrawCalls.Add(drawCall);
|
||||
|
||||
// Add draw call to proper draw lists
|
||||
DrawPass modes = (DrawPass)(drawModes & mainRenderContext.View.GetShadowsDrawPassMask(shadowsMode));
|
||||
drawModes = (DrawPass)(modes & mainRenderContext.View.Pass);
|
||||
DrawPass modes = drawModes & mainRenderContext.View.GetShadowsDrawPassMask(shadowsMode);
|
||||
drawModes = modes & mainRenderContext.View.Pass;
|
||||
if (drawModes != DrawPass::None && mainRenderContext.View.CullingFrustum.Intersects(bounds))
|
||||
{
|
||||
if (drawModes & DrawPass::Depth)
|
||||
if ((drawModes & DrawPass::Depth) != DrawPass::None)
|
||||
{
|
||||
DrawCallsLists[(int32)DrawCallsListType::Depth].Indices.Add(index);
|
||||
}
|
||||
if (drawModes & (DrawPass::GBuffer | DrawPass::GlobalSurfaceAtlas))
|
||||
if ((drawModes & (DrawPass::GBuffer | DrawPass::GlobalSurfaceAtlas)) != DrawPass::None)
|
||||
{
|
||||
if (receivesDecals)
|
||||
DrawCallsLists[(int32)DrawCallsListType::GBuffer].Indices.Add(index);
|
||||
else
|
||||
DrawCallsLists[(int32)DrawCallsListType::GBufferNoDecals].Indices.Add(index);
|
||||
}
|
||||
if (drawModes & DrawPass::Forward)
|
||||
if ((drawModes & DrawPass::Forward) != DrawPass::None)
|
||||
{
|
||||
DrawCallsLists[(int32)DrawCallsListType::Forward].Indices.Add(index);
|
||||
}
|
||||
if (drawModes & DrawPass::Distortion)
|
||||
if ((drawModes & DrawPass::Distortion) != DrawPass::None)
|
||||
{
|
||||
DrawCallsLists[(int32)DrawCallsListType::Distortion].Indices.Add(index);
|
||||
}
|
||||
if (drawModes & DrawPass::MotionVectors && (staticFlags & StaticFlags::Transform) == 0)
|
||||
if ((drawModes & DrawPass::MotionVectors) != DrawPass::None && (staticFlags & StaticFlags::Transform) == StaticFlags::None)
|
||||
{
|
||||
DrawCallsLists[(int32)DrawCallsListType::MotionVectors].Indices.Add(index);
|
||||
}
|
||||
|
||||
@@ -297,7 +297,7 @@ void RenderInner(SceneRenderTask* task, RenderContext& renderContext, RenderCont
|
||||
// Perform postFx volumes blending and query before rendering
|
||||
task->CollectPostFxVolumes(renderContext);
|
||||
renderContext.List->BlendSettings();
|
||||
auto aaMode = (renderContext.View.Flags & ViewFlags::AntiAliasing) != 0 ? renderContext.List->Settings.AntiAliasing.Mode : AntialiasingMode::None;
|
||||
auto aaMode = EnumHasAnyFlags(renderContext.View.Flags, ViewFlags::AntiAliasing) ? renderContext.List->Settings.AntiAliasing.Mode : AntialiasingMode::None;
|
||||
if (aaMode == AntialiasingMode::TemporalAntialiasing && view.IsOrthographicProjection())
|
||||
aaMode = AntialiasingMode::None; // TODO: support TAA in ortho projection (see RenderView::Prepare to jitter projection matrix better)
|
||||
renderContext.List->Settings.AntiAliasing.Mode = aaMode;
|
||||
@@ -317,10 +317,11 @@ void RenderInner(SceneRenderTask* task, RenderContext& renderContext, RenderCont
|
||||
{
|
||||
const MotionBlurSettings& motionBlurSettings = renderContext.List->Settings.MotionBlur;
|
||||
const ScreenSpaceReflectionsSettings ssrSettings = renderContext.List->Settings.ScreenSpaceReflections;
|
||||
setup.UseMotionVectors = ((renderContext.View.Flags & ViewFlags::MotionBlur) != 0 && motionBlurSettings.Enabled && motionBlurSettings.Scale > ZeroTolerance) ||
|
||||
renderContext.View.Mode == ViewMode::MotionVectors ||
|
||||
(ssrSettings.TemporalEffect && renderContext.View.Flags & ViewFlags::SSR) ||
|
||||
renderContext.List->Settings.AntiAliasing.Mode == AntialiasingMode::TemporalAntialiasing;
|
||||
setup.UseMotionVectors =
|
||||
(EnumHasAnyFlags(renderContext.View.Flags, ViewFlags::MotionBlur) && motionBlurSettings.Enabled && motionBlurSettings.Scale > ZeroTolerance) ||
|
||||
renderContext.View.Mode == ViewMode::MotionVectors ||
|
||||
(ssrSettings.TemporalEffect && EnumHasAnyFlags(renderContext.View.Flags, ViewFlags::SSR)) ||
|
||||
renderContext.List->Settings.AntiAliasing.Mode == AntialiasingMode::TemporalAntialiasing;
|
||||
}
|
||||
setup.UseTemporalAAJitter = aaMode == AntialiasingMode::TemporalAntialiasing;
|
||||
|
||||
@@ -344,7 +345,7 @@ void RenderInner(SceneRenderTask* task, RenderContext& renderContext, RenderCont
|
||||
view.Pass |= DrawPass::MotionVectors;
|
||||
renderContextBatch.GetMainContext() = renderContext; // Sync render context in batch with the current value
|
||||
|
||||
bool drawShadows = !isGBufferDebug && ((view.Flags & ViewFlags::Shadows) != 0) && ShadowsPass::Instance()->IsReady();
|
||||
bool drawShadows = !isGBufferDebug && EnumHasAnyFlags(view.Flags, ViewFlags::Shadows) && ShadowsPass::Instance()->IsReady();
|
||||
switch (renderContext.View.Mode)
|
||||
{
|
||||
case ViewMode::QuadOverdraw:
|
||||
@@ -415,7 +416,7 @@ void RenderInner(SceneRenderTask* task, RenderContext& renderContext, RenderCont
|
||||
#endif
|
||||
|
||||
// Global SDF rendering (can be used by materials later on)
|
||||
if (graphicsSettings->EnableGlobalSDF && view.Flags & ViewFlags::GlobalSDF)
|
||||
if (graphicsSettings->EnableGlobalSDF && EnumHasAnyFlags(view.Flags, ViewFlags::GlobalSDF))
|
||||
{
|
||||
GlobalSignDistanceFieldPass::BindingData bindingData;
|
||||
GlobalSignDistanceFieldPass::Instance()->Render(renderContext, context, bindingData);
|
||||
@@ -470,7 +471,7 @@ void RenderInner(SceneRenderTask* task, RenderContext& renderContext, RenderCont
|
||||
// Render lighting
|
||||
renderContextBatch.GetMainContext() = renderContext; // Sync render context in batch with the current value
|
||||
LightPass::Instance()->RenderLight(renderContextBatch, *lightBuffer);
|
||||
if (renderContext.View.Flags & ViewFlags::GI)
|
||||
if (EnumHasAnyFlags(renderContext.View.Flags, ViewFlags::GI))
|
||||
{
|
||||
switch (renderContext.List->Settings.GlobalIllumination.Mode)
|
||||
{
|
||||
|
||||
@@ -275,7 +275,7 @@ void ScreenSpaceReflectionsPass::Render(RenderContext& renderContext, GPUTexture
|
||||
GlobalSignDistanceFieldPass::BindingData bindingDataSDF;
|
||||
GlobalSurfaceAtlasPass::BindingData bindingDataSurfaceAtlas;
|
||||
if (settings.TraceMode == ReflectionsTraceMode::SoftwareTracing &&
|
||||
view.Flags & ViewFlags::GI &&
|
||||
EnumHasAnyFlags(view.Flags, ViewFlags::GI) &&
|
||||
renderContext.List->Settings.GlobalIllumination.Mode == GlobalIlluminationMode::DDGI)
|
||||
{
|
||||
if (!GlobalSignDistanceFieldPass::Instance()->Render(renderContext, context, bindingDataSDF) &&
|
||||
|
||||
@@ -84,8 +84,8 @@ bool ShadowsPass::Init()
|
||||
const auto formatTexture = PixelFormatExtensions::FindShaderResourceFormat(SHADOW_MAPS_FORMAT, false);
|
||||
const auto formatFeaturesDepth = GPUDevice::Instance->GetFormatFeatures(SHADOW_MAPS_FORMAT);
|
||||
const auto formatFeaturesTexture = GPUDevice::Instance->GetFormatFeatures(formatTexture);
|
||||
_supportsShadows = FORMAT_FEATURES_ARE_SUPPORTED(formatFeaturesDepth.Support, FormatSupport::DepthStencil | FormatSupport::Texture2D)
|
||||
&& FORMAT_FEATURES_ARE_SUPPORTED(formatFeaturesTexture.Support, FormatSupport::ShaderSample | FormatSupport::ShaderSampleComparison);
|
||||
_supportsShadows = EnumHasAllFlags(formatFeaturesDepth.Support, FormatSupport::DepthStencil | FormatSupport::Texture2D)
|
||||
&& EnumHasAllFlags(formatFeaturesTexture.Support, FormatSupport::ShaderSample | FormatSupport::ShaderSampleComparison);
|
||||
if (!_supportsShadows)
|
||||
{
|
||||
LOG(Warning, "GPU doesn't support shadows rendering");
|
||||
@@ -640,7 +640,7 @@ void ShadowsPass::RenderShadow(RenderContextBatch& renderContextBatch, RendererP
|
||||
context->ResetRenderTarget();
|
||||
const Viewport viewport = renderContext.Task->GetViewport();
|
||||
GPUTexture* depthBuffer = renderContext.Buffers->DepthBuffer;
|
||||
GPUTextureView* depthBufferSRV = depthBuffer->GetDescription().Flags & GPUTextureFlags::ReadOnlyDepthView ? depthBuffer->ViewReadOnlyDepth() : depthBuffer->View();
|
||||
GPUTextureView* depthBufferSRV = EnumHasAnyFlags(depthBuffer->Flags(), GPUTextureFlags::ReadOnlyDepthView) ? depthBuffer->ViewReadOnlyDepth() : depthBuffer->View();
|
||||
context->SetViewportAndScissors(viewport);
|
||||
context->BindSR(0, renderContext.Buffers->GBuffer0);
|
||||
context->BindSR(1, renderContext.Buffers->GBuffer1);
|
||||
@@ -655,7 +655,7 @@ void ShadowsPass::RenderShadow(RenderContextBatch& renderContextBatch, RendererP
|
||||
sperLight.LightShadow = shadowData.Constants;
|
||||
Matrix::Transpose(view.ViewProjection(), sperLight.ViewProjectionMatrix);
|
||||
sperLight.ContactShadowsDistance = light.ShadowsDistance;
|
||||
sperLight.ContactShadowsLength = view.Flags & ViewFlags::ContactShadows ? light.ContactShadowsLength : 0.0f;
|
||||
sperLight.ContactShadowsLength = EnumHasAnyFlags(view.Flags, ViewFlags::ContactShadows) ? light.ContactShadowsLength : 0.0f;
|
||||
|
||||
// Calculate world view projection matrix for the light sphere
|
||||
Matrix world, wvp, matrix;
|
||||
@@ -718,7 +718,7 @@ void ShadowsPass::RenderShadow(RenderContextBatch& renderContextBatch, RendererS
|
||||
context->ResetRenderTarget();
|
||||
const Viewport viewport = renderContext.Task->GetViewport();
|
||||
GPUTexture* depthBuffer = renderContext.Buffers->DepthBuffer;
|
||||
GPUTextureView* depthBufferSRV = depthBuffer->GetDescription().Flags & GPUTextureFlags::ReadOnlyDepthView ? depthBuffer->ViewReadOnlyDepth() : depthBuffer->View();
|
||||
GPUTextureView* depthBufferSRV = EnumHasAllFlags(depthBuffer->Flags(), GPUTextureFlags::ReadOnlyDepthView) ? depthBuffer->ViewReadOnlyDepth() : depthBuffer->View();
|
||||
context->SetViewportAndScissors(viewport);
|
||||
context->BindSR(0, renderContext.Buffers->GBuffer0);
|
||||
context->BindSR(1, renderContext.Buffers->GBuffer1);
|
||||
@@ -733,7 +733,7 @@ void ShadowsPass::RenderShadow(RenderContextBatch& renderContextBatch, RendererS
|
||||
sperLight.LightShadow = shadowData.Constants;
|
||||
Matrix::Transpose(view.ViewProjection(), sperLight.ViewProjectionMatrix);
|
||||
sperLight.ContactShadowsDistance = light.ShadowsDistance;
|
||||
sperLight.ContactShadowsLength = view.Flags & ViewFlags::ContactShadows ? light.ContactShadowsLength : 0.0f;
|
||||
sperLight.ContactShadowsLength = EnumHasAnyFlags(view.Flags, ViewFlags::ContactShadows) ? light.ContactShadowsLength : 0.0f;
|
||||
|
||||
// Calculate world view projection matrix for the light sphere
|
||||
Matrix world, wvp, matrix;
|
||||
@@ -787,7 +787,7 @@ void ShadowsPass::RenderShadow(RenderContextBatch& renderContextBatch, RendererD
|
||||
context->ResetSR();
|
||||
context->ResetRenderTarget();
|
||||
GPUTexture* depthBuffer = renderContext.Buffers->DepthBuffer;
|
||||
GPUTextureView* depthBufferSRV = depthBuffer->GetDescription().Flags & GPUTextureFlags::ReadOnlyDepthView ? depthBuffer->ViewReadOnlyDepth() : depthBuffer->View();
|
||||
GPUTextureView* depthBufferSRV = EnumHasAnyFlags(depthBuffer->Flags(), GPUTextureFlags::ReadOnlyDepthView) ? depthBuffer->ViewReadOnlyDepth() : depthBuffer->View();
|
||||
context->SetViewportAndScissors(renderContext.Task->GetViewport());
|
||||
context->BindSR(0, renderContext.Buffers->GBuffer0);
|
||||
context->BindSR(1, renderContext.Buffers->GBuffer1);
|
||||
@@ -803,7 +803,7 @@ void ShadowsPass::RenderShadow(RenderContextBatch& renderContextBatch, RendererD
|
||||
sperLight.LightShadow = shadowData.Constants;
|
||||
Matrix::Transpose(view.ViewProjection(), sperLight.ViewProjectionMatrix);
|
||||
sperLight.ContactShadowsDistance = light.ShadowsDistance;
|
||||
sperLight.ContactShadowsLength = view.Flags & ViewFlags::ContactShadows ? light.ContactShadowsLength : 0.0f;
|
||||
sperLight.ContactShadowsLength = EnumHasAnyFlags(view.Flags, ViewFlags::ContactShadows) ? light.ContactShadowsLength : 0.0f;
|
||||
|
||||
// Render shadow in screen space
|
||||
auto shader = _shader->GetShader();
|
||||
|
||||
@@ -120,7 +120,7 @@ bool VolumetricFogPass::Init(RenderContext& renderContext, GPUContext* context,
|
||||
}
|
||||
|
||||
// Check if skip rendering
|
||||
if (fog == nullptr || (view.Flags & ViewFlags::Fog) == 0 || !_isSupported || checkIfSkipPass())
|
||||
if (fog == nullptr || (view.Flags & ViewFlags::Fog) == ViewFlags::None || !_isSupported || checkIfSkipPass())
|
||||
{
|
||||
RenderTargetPool::Release(renderContext.Buffers->VolumetricFog);
|
||||
renderContext.Buffers->VolumetricFog = nullptr;
|
||||
@@ -459,7 +459,7 @@ void VolumetricFogPass::Render(RenderContext& renderContext)
|
||||
// Init GI data
|
||||
bool useDDGI = false;
|
||||
DynamicDiffuseGlobalIlluminationPass::BindingData bindingDataDDGI;
|
||||
if (renderContext.View.Flags & ViewFlags::GI)
|
||||
if (EnumHasAnyFlags(renderContext.View.Flags, ViewFlags::GI))
|
||||
{
|
||||
switch (renderContext.List->Settings.GlobalIllumination.Mode)
|
||||
{
|
||||
|
||||
@@ -265,7 +265,7 @@ void Script::Initialize()
|
||||
{
|
||||
ASSERT(!IsDuringPlay());
|
||||
|
||||
if (Flags & ObjectFlags::IsManagedType || Flags & ObjectFlags::IsCustomScriptingType)
|
||||
if (EnumHasAnyFlags(Flags, ObjectFlags::IsManagedType | ObjectFlags::IsCustomScriptingType))
|
||||
SetupType();
|
||||
|
||||
// Use lazy creation for the managed instance, just register the object
|
||||
|
||||
@@ -45,7 +45,7 @@ ScriptingObject::~ScriptingObject()
|
||||
ASSERT(_gcHandle == 0);
|
||||
|
||||
// Handle custom scripting objects removing
|
||||
if (Flags & ObjectFlags::IsCustomScriptingType)
|
||||
if (EnumHasAnyFlags(Flags, ObjectFlags::IsCustomScriptingType))
|
||||
{
|
||||
_type.Module->OnObjectDeleted(this);
|
||||
}
|
||||
|
||||
@@ -206,7 +206,7 @@ public:
|
||||
/// </summary>
|
||||
FORCE_INLINE bool IsRegistered() const
|
||||
{
|
||||
return (Flags & ObjectFlags::IsRegistered) != 0;
|
||||
return (Flags & ObjectFlags::IsRegistered) != ObjectFlags::None;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -433,7 +433,7 @@ namespace ShaderProcessing
|
||||
}
|
||||
|
||||
// Check if use this shader program
|
||||
if ((current.Flags & ShaderFlags::Hidden) == false && current.MinFeatureLevel <= parser->GetFeatureLevel())
|
||||
if ((current.Flags & ShaderFlags::Hidden) == (ShaderFlags)0 && current.MinFeatureLevel <= parser->GetFeatureLevel())
|
||||
{
|
||||
// Cache read function
|
||||
ShaderMetaReaderType::_cache.Add(current);
|
||||
|
||||
@@ -259,7 +259,7 @@ bool ShaderCompiler::CompileShaders()
|
||||
for (int32 i = 0; i < meta->VS.Count(); i++)
|
||||
{
|
||||
auto& shader = meta->VS[i];
|
||||
ASSERT(shader.GetStage() == ShaderStage::Vertex && (shader.Flags & ShaderFlags::Hidden) == 0);
|
||||
ASSERT(shader.GetStage() == ShaderStage::Vertex && (shader.Flags & ShaderFlags::Hidden) == (ShaderFlags)0);
|
||||
PROFILE_COMPILE_SHADER(shader);
|
||||
if (CompileShader(shader, &WriteCustomDataVS))
|
||||
{
|
||||
@@ -272,7 +272,7 @@ bool ShaderCompiler::CompileShaders()
|
||||
for (int32 i = 0; i < meta->HS.Count(); i++)
|
||||
{
|
||||
auto& shader = meta->HS[i];
|
||||
ASSERT(shader.GetStage() == ShaderStage::Hull && (shader.Flags & ShaderFlags::Hidden) == 0);
|
||||
ASSERT(shader.GetStage() == ShaderStage::Hull && (shader.Flags & ShaderFlags::Hidden) == (ShaderFlags)0);
|
||||
PROFILE_COMPILE_SHADER(shader);
|
||||
if (CompileShader(shader, &WriteCustomDataHS))
|
||||
{
|
||||
@@ -285,7 +285,7 @@ bool ShaderCompiler::CompileShaders()
|
||||
for (int32 i = 0; i < meta->DS.Count(); i++)
|
||||
{
|
||||
auto& shader = meta->DS[i];
|
||||
ASSERT(shader.GetStage() == ShaderStage::Domain && (shader.Flags & ShaderFlags::Hidden) == 0);
|
||||
ASSERT(shader.GetStage() == ShaderStage::Domain && (shader.Flags & ShaderFlags::Hidden) == (ShaderFlags)0);
|
||||
PROFILE_COMPILE_SHADER(shader);
|
||||
if (CompileShader(shader))
|
||||
{
|
||||
@@ -298,7 +298,7 @@ bool ShaderCompiler::CompileShaders()
|
||||
for (int32 i = 0; i < meta->GS.Count(); i++)
|
||||
{
|
||||
auto& shader = meta->GS[i];
|
||||
ASSERT(shader.GetStage() == ShaderStage::Geometry && (shader.Flags & ShaderFlags::Hidden) == 0);
|
||||
ASSERT(shader.GetStage() == ShaderStage::Geometry && (shader.Flags & ShaderFlags::Hidden) == (ShaderFlags)0);
|
||||
PROFILE_COMPILE_SHADER(shader);
|
||||
if (CompileShader(shader))
|
||||
{
|
||||
@@ -311,7 +311,7 @@ bool ShaderCompiler::CompileShaders()
|
||||
for (int32 i = 0; i < meta->PS.Count(); i++)
|
||||
{
|
||||
auto& shader = meta->PS[i];
|
||||
ASSERT(shader.GetStage() == ShaderStage::Pixel && (shader.Flags & ShaderFlags::Hidden) == 0);
|
||||
ASSERT(shader.GetStage() == ShaderStage::Pixel && (shader.Flags & ShaderFlags::Hidden) == (ShaderFlags)0);
|
||||
PROFILE_COMPILE_SHADER(shader);
|
||||
if (CompileShader(shader))
|
||||
{
|
||||
@@ -324,7 +324,7 @@ bool ShaderCompiler::CompileShaders()
|
||||
for (int32 i = 0; i < meta->CS.Count(); i++)
|
||||
{
|
||||
auto& shader = meta->CS[i];
|
||||
ASSERT(shader.GetStage() == ShaderStage::Compute && (shader.Flags & ShaderFlags::Hidden) == 0);
|
||||
ASSERT(shader.GetStage() == ShaderStage::Compute && (shader.Flags & ShaderFlags::Hidden) == (ShaderFlags)0);
|
||||
PROFILE_COMPILE_SHADER(shader);
|
||||
if (CompileShader(shader))
|
||||
{
|
||||
|
||||
@@ -24,7 +24,7 @@ bool canUseMaterialWithLightmap(MaterialBase* material, ShadowsOfMordor::Builder
|
||||
bool cacheStaticGeometryTree(Actor* actor, ShadowsOfMordor::Builder::SceneBuildCache* scene)
|
||||
{
|
||||
ShadowsOfMordor::Builder::GeometryEntry entry;
|
||||
const bool useLightmap = actor->GetIsActive() && (actor->GetStaticFlags() & StaticFlags::Lightmap);
|
||||
const bool useLightmap = actor->GetIsActive() && actor->HasStaticFlag(StaticFlags::Lightmap);
|
||||
auto& results = scene->Entries;
|
||||
|
||||
// Switch actor type
|
||||
|
||||
@@ -505,13 +505,13 @@ void Terrain::RemovePatch(const Int2& patchCoord)
|
||||
|
||||
void Terrain::Draw(RenderContext& renderContext)
|
||||
{
|
||||
DrawPass drawModes = (DrawPass)(DrawModes & renderContext.View.Pass);
|
||||
const DrawPass drawModes = DrawModes & renderContext.View.Pass;
|
||||
if (drawModes == DrawPass::None)
|
||||
return;
|
||||
PROFILE_CPU();
|
||||
if (renderContext.View.Pass == DrawPass::GlobalSDF)
|
||||
{
|
||||
if ((DrawModes & DrawPass::GlobalSDF) == 0)
|
||||
if ((DrawModes & DrawPass::GlobalSDF) == DrawPass::None)
|
||||
return;
|
||||
const float chunkSize = TERRAIN_UNITS_PER_VERTEX * (float)_chunkSize;
|
||||
const float posToUV = 0.25f / chunkSize;
|
||||
@@ -531,7 +531,7 @@ void Terrain::Draw(RenderContext& renderContext)
|
||||
}
|
||||
if (renderContext.View.Pass == DrawPass::GlobalSurfaceAtlas)
|
||||
{
|
||||
if ((DrawModes & DrawPass::GlobalSurfaceAtlas) == 0)
|
||||
if ((DrawModes & DrawPass::GlobalSurfaceAtlas) == DrawPass::None)
|
||||
return;
|
||||
for (TerrainPatch* patch : _patches)
|
||||
{
|
||||
|
||||
@@ -101,7 +101,7 @@ void TerrainChunk::Draw(const RenderContext& renderContext) const
|
||||
drawCall.Terrain.NeighborLOD.W = (float)Math::Clamp<int32>(_neighbors[3]->_cachedDrawLOD, lod, minLod);
|
||||
const auto scene = _patch->_terrain->GetScene();
|
||||
const auto flags = _patch->_terrain->_staticFlags;
|
||||
if (flags & StaticFlags::Lightmap && scene)
|
||||
if ((flags & StaticFlags::Lightmap) != StaticFlags::None && scene)
|
||||
{
|
||||
drawCall.Terrain.Lightmap = scene->LightmapsData.GetReadyLightmap(Lightmap.TextureIndex);
|
||||
drawCall.Terrain.LightmapUVsArea = Lightmap.UVsArea;
|
||||
@@ -121,7 +121,7 @@ void TerrainChunk::Draw(const RenderContext& renderContext) const
|
||||
//drawCall.TerrainData.HeightmapUVScaleBias.W += halfTexelOffset;
|
||||
|
||||
// Submit draw call
|
||||
auto drawModes = (DrawPass)(_patch->_terrain->DrawModes & renderContext.View.Pass & (uint32)drawCall.Material->GetDrawModes());
|
||||
const DrawPass drawModes = _patch->_terrain->DrawModes & renderContext.View.Pass & drawCall.Material->GetDrawModes();
|
||||
if (drawModes != DrawPass::None)
|
||||
renderContext.List->AddDrawCall(renderContext, drawModes, flags, drawCall, true);
|
||||
}
|
||||
@@ -157,7 +157,7 @@ void TerrainChunk::Draw(const RenderContext& renderContext, MaterialBase* materi
|
||||
drawCall.Terrain.NeighborLOD.W = (float)lod;
|
||||
const auto scene = _patch->_terrain->GetScene();
|
||||
const auto flags = _patch->_terrain->_staticFlags;
|
||||
if (flags & StaticFlags::Lightmap && scene)
|
||||
if ((flags & StaticFlags::Lightmap) != StaticFlags::None && scene)
|
||||
{
|
||||
drawCall.Terrain.Lightmap = scene->LightmapsData.GetReadyLightmap(Lightmap.TextureIndex);
|
||||
drawCall.Terrain.LightmapUVsArea = Lightmap.UVsArea;
|
||||
@@ -177,7 +177,7 @@ void TerrainChunk::Draw(const RenderContext& renderContext, MaterialBase* materi
|
||||
//drawCall.TerrainData.HeightmapUVScaleBias.W += halfTexelOffset;
|
||||
|
||||
// Submit draw call
|
||||
auto drawModes = (DrawPass)(_patch->_terrain->DrawModes & renderContext.View.Pass & (uint32)drawCall.Material->GetDrawModes());
|
||||
const DrawPass drawModes = _patch->_terrain->DrawModes & renderContext.View.Pass & drawCall.Material->GetDrawModes();
|
||||
if (drawModes != DrawPass::None)
|
||||
renderContext.List->AddDrawCall(renderContext, drawModes, flags, drawCall, true);
|
||||
}
|
||||
|
||||
@@ -195,9 +195,9 @@ bool MaterialGenerator::Generate(WriteStream& source, MaterialInfo& materialInfo
|
||||
ADD_FEATURE(LightmapFeature);
|
||||
if (materialInfo.BlendMode == MaterialBlendMode::Opaque)
|
||||
ADD_FEATURE(DeferredShadingFeature);
|
||||
if (materialInfo.BlendMode != MaterialBlendMode::Opaque && (materialInfo.FeaturesFlags & MaterialFeaturesFlags::DisableDistortion) == 0)
|
||||
if (materialInfo.BlendMode != MaterialBlendMode::Opaque && (materialInfo.FeaturesFlags & MaterialFeaturesFlags::DisableDistortion) == MaterialFeaturesFlags::None)
|
||||
ADD_FEATURE(DistortionFeature);
|
||||
if (materialInfo.BlendMode != MaterialBlendMode::Opaque && (materialInfo.FeaturesFlags & MaterialFeaturesFlags::GlobalIllumination) != 0)
|
||||
if (materialInfo.BlendMode != MaterialBlendMode::Opaque && EnumHasAnyFlags(materialInfo.FeaturesFlags, MaterialFeaturesFlags::GlobalIllumination))
|
||||
ADD_FEATURE(GlobalIlluminationFeature);
|
||||
if (materialInfo.BlendMode != MaterialBlendMode::Opaque)
|
||||
ADD_FEATURE(ForwardShadingFeature);
|
||||
@@ -209,9 +209,9 @@ bool MaterialGenerator::Generate(WriteStream& source, MaterialInfo& materialInfo
|
||||
ADD_FEATURE(DeferredShadingFeature);
|
||||
break;
|
||||
case MaterialDomain::Particle:
|
||||
if (materialInfo.BlendMode != MaterialBlendMode::Opaque && (materialInfo.FeaturesFlags & MaterialFeaturesFlags::DisableDistortion) == 0)
|
||||
if (materialInfo.BlendMode != MaterialBlendMode::Opaque && (materialInfo.FeaturesFlags & MaterialFeaturesFlags::DisableDistortion) == MaterialFeaturesFlags::None)
|
||||
ADD_FEATURE(DistortionFeature);
|
||||
if (materialInfo.BlendMode != MaterialBlendMode::Opaque && (materialInfo.FeaturesFlags & MaterialFeaturesFlags::GlobalIllumination) != 0)
|
||||
if (materialInfo.BlendMode != MaterialBlendMode::Opaque && EnumHasAnyFlags(materialInfo.FeaturesFlags, MaterialFeaturesFlags::GlobalIllumination))
|
||||
ADD_FEATURE(GlobalIlluminationFeature);
|
||||
ADD_FEATURE(ForwardShadingFeature);
|
||||
break;
|
||||
@@ -330,15 +330,15 @@ bool MaterialGenerator::Generate(WriteStream& source, MaterialInfo& materialInfo
|
||||
|
||||
// Normalize and transform to world space if need to
|
||||
_writer.Write(TEXT("\t{0}.TangentNormal = normalize({0}.TangentNormal);\n"), materialVarPS.Value);
|
||||
if ((baseLayer->FeaturesFlags & MaterialFeaturesFlags::InputWorldSpaceNormal) == 0)
|
||||
{
|
||||
_writer.Write(TEXT("\t{0}.WorldNormal = normalize(TransformTangentVectorToWorld(input, {0}.TangentNormal));\n"), materialVarPS.Value);
|
||||
}
|
||||
else
|
||||
if (EnumHasAllFlags(baseLayer->FeaturesFlags, MaterialFeaturesFlags::InputWorldSpaceNormal))
|
||||
{
|
||||
_writer.Write(TEXT("\t{0}.WorldNormal = {0}.TangentNormal;\n"), materialVarPS.Value);
|
||||
_writer.Write(TEXT("\t{0}.TangentNormal = normalize(TransformWorldVectorToTangent(input, {0}.WorldNormal));\n"), materialVarPS.Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
_writer.Write(TEXT("\t{0}.WorldNormal = normalize(TransformTangentVectorToWorld(input, {0}.TangentNormal));\n"), materialVarPS.Value);
|
||||
}
|
||||
|
||||
// Clamp values
|
||||
_writer.Write(TEXT("\t{0}.Metalness = saturate({0}.Metalness);\n"), materialVarPS.Value);
|
||||
@@ -421,7 +421,7 @@ bool MaterialGenerator::Generate(WriteStream& source, MaterialInfo& materialInfo
|
||||
_writer.Write(TEXT("#define MATERIAL_MASK_THRESHOLD ({0})\n"), baseLayer->MaskThreshold);
|
||||
_writer.Write(TEXT("#define CUSTOM_VERTEX_INTERPOLATORS_COUNT ({0})\n"), _vsToPsInterpolants.Count());
|
||||
_writer.Write(TEXT("#define MATERIAL_OPACITY_THRESHOLD ({0})\n"), baseLayer->OpacityThreshold);
|
||||
if (materialInfo.BlendMode != MaterialBlendMode::Opaque && !(materialInfo.FeaturesFlags & MaterialFeaturesFlags::DisableReflections) && materialInfo.FeaturesFlags & MaterialFeaturesFlags::ScreenSpaceReflections)
|
||||
if (materialInfo.BlendMode != MaterialBlendMode::Opaque && !(materialInfo.FeaturesFlags & MaterialFeaturesFlags::DisableReflections) && EnumHasAnyFlags(materialInfo.FeaturesFlags, MaterialFeaturesFlags::ScreenSpaceReflections))
|
||||
{
|
||||
// Inject depth and color buffers for Screen Space Reflections used by transparent material
|
||||
auto sceneDepthTexture = findOrAddSceneTexture(MaterialSceneTextures::SceneDepth);
|
||||
|
||||
@@ -352,7 +352,7 @@ bool ProcessMesh(ImportedModelData& result, AssimpImporterData& data, const aiMe
|
||||
}
|
||||
|
||||
// Blend Indices and Blend Weights
|
||||
if (aMesh->mNumBones > 0 && aMesh->mBones && result.Types & ImportDataTypes::Skeleton)
|
||||
if (aMesh->mNumBones > 0 && aMesh->mBones && EnumHasAnyFlags(result.Types, ImportDataTypes::Skeleton))
|
||||
{
|
||||
const int32 vertexCount = mesh.Positions.Count();
|
||||
mesh.BlendIndices.Resize(vertexCount);
|
||||
@@ -433,7 +433,7 @@ bool ProcessMesh(ImportedModelData& result, AssimpImporterData& data, const aiMe
|
||||
}
|
||||
|
||||
// Blend Shapes
|
||||
if (aMesh->mNumAnimMeshes > 0 && result.Types & ImportDataTypes::Skeleton && data.Options.ImportBlendShapes)
|
||||
if (aMesh->mNumAnimMeshes > 0 && EnumHasAnyFlags(result.Types, ImportDataTypes::Skeleton) && data.Options.ImportBlendShapes)
|
||||
{
|
||||
mesh.BlendShapes.EnsureCapacity(aMesh->mNumAnimMeshes);
|
||||
for (unsigned int animMeshIndex = 0; animMeshIndex < aMesh->mNumAnimMeshes; animMeshIndex++)
|
||||
@@ -524,7 +524,7 @@ bool ImportMaterials(ImportedModelData& result, AssimpImporterData& data, String
|
||||
materialSlot.Name = String(aName.C_Str()).TrimTrailing();
|
||||
materialSlot.AssetID = Guid::Empty;
|
||||
|
||||
if (result.Types & ImportDataTypes::Materials)
|
||||
if (EnumHasAnyFlags(result.Types, ImportDataTypes::Materials))
|
||||
{
|
||||
aiColor3D aColor;
|
||||
if (aMaterial->Get(AI_MATKEY_COLOR_DIFFUSE, aColor) == AI_SUCCESS)
|
||||
@@ -536,7 +536,7 @@ bool ImportMaterials(ImportedModelData& result, AssimpImporterData& data, String
|
||||
if (aMaterial->Get(AI_MATKEY_OPACITY, aFloat) == AI_SUCCESS)
|
||||
materialSlot.Opacity.Value = aFloat;
|
||||
|
||||
if (result.Types & ImportDataTypes::Textures)
|
||||
if (EnumHasAnyFlags(result.Types, ImportDataTypes::Textures))
|
||||
{
|
||||
ImportMaterialTexture(result, data, aMaterial, aiTextureType_DIFFUSE, materialSlot.Diffuse.TextureIndex, TextureEntry::TypeHint::ColorRGB);
|
||||
ImportMaterialTexture(result, data, aMaterial, aiTextureType_EMISSIVE, materialSlot.Emissive.TextureIndex, TextureEntry::TypeHint::ColorRGB);
|
||||
@@ -641,8 +641,8 @@ bool ModelTool::ImportDataAssimp(const char* path, ImportedModelData& data, Opti
|
||||
AssimpInited = true;
|
||||
LOG(Info, "Assimp {0}.{1}.{2}", aiGetVersionMajor(), aiGetVersionMinor(), aiGetVersionRevision());
|
||||
}
|
||||
bool importMeshes = (data.Types & ImportDataTypes::Geometry) != 0;
|
||||
bool importAnimations = (data.Types & ImportDataTypes::Animations) != 0;
|
||||
bool importMeshes = EnumHasAnyFlags(data.Types, ImportDataTypes::Geometry);
|
||||
bool importAnimations = EnumHasAnyFlags(data.Types, ImportDataTypes::Animations);
|
||||
context = New<AssimpImporterData>(path, options);
|
||||
|
||||
// Setup import flags
|
||||
@@ -704,7 +704,7 @@ bool ModelTool::ImportDataAssimp(const char* path, ImportedModelData& data, Opti
|
||||
}
|
||||
|
||||
// Import geometry
|
||||
if (data.Types & ImportDataTypes::Geometry && context->Scene->HasMeshes())
|
||||
if (EnumHasAnyFlags(data.Types, ImportDataTypes::Geometry) && context->Scene->HasMeshes())
|
||||
{
|
||||
const int meshCount = context->Scene->mNumMeshes;
|
||||
if (options.SplitObjects && options.ObjectIndex == -1)
|
||||
@@ -747,7 +747,7 @@ bool ModelTool::ImportDataAssimp(const char* path, ImportedModelData& data, Opti
|
||||
}
|
||||
|
||||
// Import skeleton
|
||||
if (data.Types & ImportDataTypes::Skeleton)
|
||||
if (EnumHasAnyFlags(data.Types, ImportDataTypes::Skeleton))
|
||||
{
|
||||
data.Skeleton.Nodes.Resize(context->Nodes.Count(), false);
|
||||
for (int32 i = 0; i < context->Nodes.Count(); i++)
|
||||
@@ -777,7 +777,7 @@ bool ModelTool::ImportDataAssimp(const char* path, ImportedModelData& data, Opti
|
||||
}
|
||||
|
||||
// Import animations
|
||||
if (data.Types & ImportDataTypes::Animations && context->Scene->HasAnimations())
|
||||
if (EnumHasAnyFlags(data.Types, ImportDataTypes::Animations) && context->Scene->HasAnimations())
|
||||
{
|
||||
const int32 animCount = (int32)context->Scene->mNumAnimations;
|
||||
if (options.SplitObjects && options.ObjectIndex == -1)
|
||||
@@ -825,7 +825,7 @@ bool ModelTool::ImportDataAssimp(const char* path, ImportedModelData& data, Opti
|
||||
}
|
||||
|
||||
// Import nodes
|
||||
if (data.Types & ImportDataTypes::Nodes)
|
||||
if (EnumHasAnyFlags(data.Types, ImportDataTypes::Nodes))
|
||||
{
|
||||
data.Nodes.Resize(context->Nodes.Count());
|
||||
for (int32 i = 0; i < context->Nodes.Count(); i++)
|
||||
|
||||
@@ -219,11 +219,11 @@ struct OpenFbxImporterData
|
||||
if (mat)
|
||||
material.Name = String(mat->name).TrimTrailing();
|
||||
|
||||
if (mat && result.Types & ImportDataTypes::Materials)
|
||||
if (mat && EnumHasAnyFlags(result.Types, ImportDataTypes::Materials))
|
||||
{
|
||||
material.Diffuse.Color = ToColor(mat->getDiffuseColor());
|
||||
|
||||
if (result.Types & ImportDataTypes::Textures)
|
||||
if (EnumHasAnyFlags(result.Types, ImportDataTypes::Textures))
|
||||
{
|
||||
ImportMaterialTexture(result, mat, ofbx::Texture::DIFFUSE, material.Diffuse.TextureIndex, TextureEntry::TypeHint::ColorRGB);
|
||||
ImportMaterialTexture(result, mat, ofbx::Texture::EMISSIVE, material.Emissive.TextureIndex, TextureEntry::TypeHint::ColorRGB);
|
||||
@@ -698,7 +698,7 @@ bool ProcessMesh(ImportedModelData& result, OpenFbxImporterData& data, const ofb
|
||||
}
|
||||
|
||||
// Blend Indices and Blend Weights
|
||||
if (skin && skin->getClusterCount() > 0 && result.Types & ImportDataTypes::Skeleton)
|
||||
if (skin && skin->getClusterCount() > 0 && EnumHasAnyFlags(result.Types, ImportDataTypes::Skeleton))
|
||||
{
|
||||
mesh.BlendIndices.Resize(vertexCount);
|
||||
mesh.BlendWeights.Resize(vertexCount);
|
||||
@@ -764,7 +764,7 @@ bool ProcessMesh(ImportedModelData& result, OpenFbxImporterData& data, const ofb
|
||||
}
|
||||
|
||||
// Blend Shapes
|
||||
if (blendShape && blendShape->getBlendShapeChannelCount() > 0 && result.Types & ImportDataTypes::Skeleton && data.Options.ImportBlendShapes)
|
||||
if (blendShape && blendShape->getBlendShapeChannelCount() > 0 && EnumHasAnyFlags(result.Types, ImportDataTypes::Skeleton) && data.Options.ImportBlendShapes)
|
||||
{
|
||||
mesh.BlendShapes.EnsureCapacity(blendShape->getBlendShapeChannelCount());
|
||||
for (int32 channelIndex = 0; channelIndex < blendShape->getBlendShapeChannelCount(); channelIndex++)
|
||||
@@ -1130,7 +1130,7 @@ bool ModelTool::ImportDataOpenFBX(const char* path, ImportedModelData& data, Opt
|
||||
return true;
|
||||
}
|
||||
ofbx::u64 loadFlags = 0;
|
||||
if (data.Types & ImportDataTypes::Geometry)
|
||||
if (EnumHasAnyFlags(data.Types, ImportDataTypes::Geometry))
|
||||
loadFlags |= (ofbx::u64)ofbx::LoadFlags::TRIANGULATE;
|
||||
else
|
||||
loadFlags |= (ofbx::u64)ofbx::LoadFlags::IGNORE_GEOMETRY;
|
||||
@@ -1160,7 +1160,7 @@ bool ModelTool::ImportDataOpenFBX(const char* path, ImportedModelData& data, Opt
|
||||
LOG(Info, "Imported scene: Up={0}, Front={1}, Right={2}", context->Up, context->Front, context->Right);
|
||||
|
||||
// Extract embedded textures
|
||||
if (data.Types & ImportDataTypes::Textures)
|
||||
if (EnumHasAnyFlags(data.Types, ImportDataTypes::Textures))
|
||||
{
|
||||
String outputPath;
|
||||
for (int i = 0, c = scene->getEmbeddedDataCount(); i < c; i++)
|
||||
@@ -1229,7 +1229,7 @@ bool ModelTool::ImportDataOpenFBX(const char* path, ImportedModelData& data, Opt
|
||||
DeleteMe<OpenFbxImporterData> contextCleanup(options.SplitContext ? nullptr : context);
|
||||
|
||||
// Build final skeleton bones hierarchy before importing meshes
|
||||
if (data.Types & ImportDataTypes::Skeleton)
|
||||
if (EnumHasAnyFlags(data.Types, ImportDataTypes::Skeleton))
|
||||
{
|
||||
if (ImportBones(*context, errorMsg))
|
||||
{
|
||||
@@ -1241,7 +1241,7 @@ bool ModelTool::ImportDataOpenFBX(const char* path, ImportedModelData& data, Opt
|
||||
}
|
||||
|
||||
// Import geometry (meshes and materials)
|
||||
if (data.Types & ImportDataTypes::Geometry && context->Scene->getMeshCount() > 0)
|
||||
if (EnumHasAnyFlags(data.Types, ImportDataTypes::Geometry) && context->Scene->getMeshCount() > 0)
|
||||
{
|
||||
const int meshCount = context->Scene->getMeshCount();
|
||||
if (options.SplitObjects && options.ObjectIndex == -1)
|
||||
@@ -1284,7 +1284,7 @@ bool ModelTool::ImportDataOpenFBX(const char* path, ImportedModelData& data, Opt
|
||||
}
|
||||
|
||||
// Import skeleton
|
||||
if (data.Types & ImportDataTypes::Skeleton)
|
||||
if (EnumHasAnyFlags(data.Types, ImportDataTypes::Skeleton))
|
||||
{
|
||||
data.Skeleton.Nodes.Resize(context->Nodes.Count(), false);
|
||||
for (int32 i = 0; i < context->Nodes.Count(); i++)
|
||||
@@ -1324,7 +1324,7 @@ bool ModelTool::ImportDataOpenFBX(const char* path, ImportedModelData& data, Opt
|
||||
}
|
||||
|
||||
// Import animations
|
||||
if (data.Types & ImportDataTypes::Animations)
|
||||
if (EnumHasAnyFlags(data.Types, ImportDataTypes::Animations))
|
||||
{
|
||||
const int animCount = context->Scene->getAnimationStackCount();
|
||||
if (options.SplitObjects && options.ObjectIndex == -1)
|
||||
@@ -1367,7 +1367,7 @@ bool ModelTool::ImportDataOpenFBX(const char* path, ImportedModelData& data, Opt
|
||||
}
|
||||
|
||||
// Import nodes
|
||||
if (data.Types & ImportDataTypes::Nodes)
|
||||
if (EnumHasAnyFlags(data.Types, ImportDataTypes::Nodes))
|
||||
{
|
||||
data.Nodes.Resize(context->Nodes.Count());
|
||||
for (int32 i = 0; i < context->Nodes.Count(); i++)
|
||||
|
||||
@@ -482,7 +482,7 @@ bool ModelTool::ImportData(const String& path, ImportedModelData& data, Options&
|
||||
}
|
||||
|
||||
// Flip normals of the imported geometry
|
||||
if (options.FlipNormals && data.Types & ImportDataTypes::Geometry)
|
||||
if (options.FlipNormals && EnumHasAnyFlags(data.Types, ImportDataTypes::Geometry))
|
||||
{
|
||||
for (auto& lod : data.LODs)
|
||||
{
|
||||
@@ -795,7 +795,7 @@ bool ModelTool::ImportModel(const String& path, ModelData& meshData, Options& op
|
||||
auto& texture = data.Textures[i];
|
||||
|
||||
// Auto-import textures
|
||||
if (autoImportOutput.IsEmpty() || (data.Types & ImportDataTypes::Textures) == 0 || texture.FilePath.IsEmpty())
|
||||
if (autoImportOutput.IsEmpty() || (data.Types & ImportDataTypes::Textures) == ImportDataTypes::None || texture.FilePath.IsEmpty())
|
||||
continue;
|
||||
String filename = StringUtils::GetFileNameWithoutExtension(texture.FilePath);
|
||||
for (int32 j = filename.Length() - 1; j >= 0; j--)
|
||||
@@ -842,7 +842,7 @@ bool ModelTool::ImportModel(const String& path, ModelData& meshData, Options& op
|
||||
material.Name = TEXT("Material ") + StringUtils::ToString(i);
|
||||
|
||||
// Auto-import materials
|
||||
if (autoImportOutput.IsEmpty() || (data.Types & ImportDataTypes::Materials) == 0 || !material.UsesProperties())
|
||||
if (autoImportOutput.IsEmpty() || (data.Types & ImportDataTypes::Materials) == ImportDataTypes::None || !material.UsesProperties())
|
||||
continue;
|
||||
auto filename = material.Name;
|
||||
for (int32 j = filename.Length() - 1; j >= 0; j--)
|
||||
|
||||
@@ -19,6 +19,8 @@ class JsonWriter;
|
||||
/// </summary>
|
||||
enum class ImportDataTypes : int32
|
||||
{
|
||||
None = 0,
|
||||
|
||||
/// <summary>
|
||||
/// Imports materials and meshes.
|
||||
/// </summary>
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user