Skip to content

Commit

Permalink
Merge branch '#77' into #92
Browse files Browse the repository at this point in the history
  • Loading branch information
Jin02 committed Jul 22, 2018
2 parents 38ec6cb + e900560 commit 78c86b4
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 28 deletions.
1 change: 1 addition & 0 deletions SOCEngine/SOCEngine/Rendering/Buffer/BaseBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include <d3d11_1.h>
#include "DXResource.h"

namespace Device
{
class DirectX;
Expand Down
31 changes: 6 additions & 25 deletions SOCEngine/SOCEngine/Rendering/Mesh/MeshManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
#include <tuple>
#include <assert.h>
#include "OpaqueMeshRenderQueue.h"
#include "VectorIndexer.hpp"

#include "VBSortedMeshPool.h"
#include "UnsortedMeshPool.h"

namespace Core
{
Expand All @@ -15,7 +16,7 @@ namespace Rendering
{
namespace Geometry
{
using TransparentMeshPool = Core::VectorHashMap<Core::ObjectID::LiteralType, Mesh>;
using TransparentMeshPool = UnsortedMeshPool;
using OpaqueMeshPool = VBSortedMeshPool;
using AlphaTestMeshPool = OpaqueMeshPool;

Expand Down Expand Up @@ -56,7 +57,7 @@ namespace Rendering
Geometry::Mesh& Add(Geometry::Mesh& mesh, Geometry::TransparentMeshPool& meshPool)
{
assert(mesh.GetVBKey() != 0); //Error, mesh does not init yet.
return meshPool.Add(mesh.GetObjectID().Literal(), mesh);
return meshPool.Add(mesh.GetObjectID(), 0, mesh);
}

Geometry::Mesh& Add(Geometry::Mesh& mesh, Geometry::OpaqueMeshPool& meshPool) // or AlphaTestMeshPool
Expand Down Expand Up @@ -103,29 +104,9 @@ namespace Rendering

void ClearDirty() { _dirtyMeshes.clear(); _mustUpdateCBMeshes.clear(); _dirty = false; }

template <class FromMeshPool, class ToMeshPool>
void ChangeTrait(Core::ObjectID id,
Geometry::OpaqueMeshPool& fromPool, Geometry::OpaqueMeshPool& toPool) // Opaque <-> AlphaTest
{
uint literlID = id.Literal();
assert(fromPool.Has(literlID));
assert(toPool.Has(literlID) == false);

Geometry::Mesh* mesh = fromPool.Find(literlID);
toPool.Add(id, mesh->GetVBKey(), *mesh);
fromPool.Delete(literlID);
}
void ChangeTrait(Core::ObjectID id,
Geometry::OpaqueMeshPool& fromPool, Geometry::TransparentMeshPool& toPool) // Opaque or AlphaTest -> Transparent
{
uint literlID = id.Literal();
assert(fromPool.Has(literlID));
assert(toPool.Has(literlID) == false);

toPool.Add(literlID, *fromPool.Find(literlID));
fromPool.Delete(literlID);
}
void ChangeTrait(Core::ObjectID id,
Geometry::TransparentMeshPool& fromPool, Geometry::OpaqueMeshPool& toPool) // Transparent -> Opaque / AlphaTest
FromMeshPool& fromPool, ToMeshPool& toPool)
{
uint literlID = id.Literal();
assert(fromPool.Has(literlID));
Expand Down
13 changes: 13 additions & 0 deletions SOCEngine/SOCEngine/Rendering/Mesh/UnsortedMeshPool.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include "UnsortedMeshPool.h"

#include "Mesh.h"
#include "ObjectID.hpp"

using namespace Rendering;
using namespace Rendering::Geometry;
using namespace Core;

Mesh& UnsortedMeshPool::Add(Core::ObjectID id, int, Mesh& mesh)
{
return Parent::Add(id.Literal(), mesh);
}
24 changes: 24 additions & 0 deletions SOCEngine/SOCEngine/Rendering/Mesh/UnsortedMeshPool.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#pragma once

#include "VectorIndexer.hpp"
#include "ObjectID.hpp"

namespace Rendering
{
namespace Geometry
{
class Mesh;

class UnsortedMeshPool final
: public Core::VectorHashMap<Core::ObjectID::LiteralType, Mesh>
{
public:
using Parent = Core::VectorHashMap<Core::ObjectID::LiteralType, Mesh>;
using Parent::Parent;

public:
// int는 VBSortedPool과 interface 맞추는 용도에 불과함.
Mesh& Add(Core::ObjectID id, int, Mesh& mesh);
};
}
}
15 changes: 12 additions & 3 deletions SOCEngine/SOCEngine/Rendering/Postprocessing/Bloom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,17 @@ void Bloom::RenderBloom(DirectX& dx, RenderTexture& outRT, const RenderTexture&

void Bloom::SetElapsedTime(float time)
{
Half hTime(time);
Half hInvTime(1.0f / time);
uint packedTime = 0;

_paramData.packedDeltaTime = (hInvTime.GetValue() << 16) | hTime.GetValue();
if (fabsf(time) <= FLT_EPSILON)
packedTime = 0;
else
{
Half hTime(time);
Half hInvTime(1.0f / time);

packedTime = (hInvTime.GetValue() << 16) | hTime.GetValue();
}

_paramData.packedDeltaTime = packedTime;
}
2 changes: 2 additions & 0 deletions SOCEngine/SOCEngine/SOCEngine.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@
<ClInclude Include="Rendering\Mesh\MeshRawPtrs.h" />
<ClInclude Include="Rendering\Mesh\MeshRenderQueue.h" />
<ClInclude Include="Rendering\Mesh\OpaqueMeshRenderQueue.h" />
<ClInclude Include="Rendering\Mesh\UnsortedMeshPool.h" />
<ClInclude Include="Rendering\Mesh\VBSortedMeshPool.h" />
<ClInclude Include="Rendering\Mesh\MeshRawPool.h" />
<ClInclude Include="Rendering\Mesh\MeshUtility.h" />
Expand Down Expand Up @@ -393,6 +394,7 @@
<ClCompile Include="Rendering\Mesh\MeshManager.cpp" />
<ClCompile Include="Rendering\Mesh\MeshRawPtrs.cpp" />
<ClCompile Include="Rendering\Mesh\OpaqueMeshRenderQueue.cpp" />
<ClCompile Include="Rendering\Mesh\UnsortedMeshPool.cpp" />
<ClCompile Include="Rendering\Mesh\VBSortedMeshPool.cpp" />
<ClCompile Include="Rendering\Mesh\MeshRawPool.cpp" />
<ClCompile Include="Rendering\Mesh\MeshUtility.cpp" />
Expand Down
6 changes: 6 additions & 0 deletions SOCEngine/SOCEngine/SOCEngine.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -1030,6 +1030,9 @@
<ClInclude Include="Core\VectorIndexer.hpp">
<Filter>Core\Transform</Filter>
</ClInclude>
<ClInclude Include="Rendering\Mesh\UnsortedMeshPool.h">
<Filter>Rendering\Mesh\Pool</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="Device\DirectX.cpp">
Expand Down Expand Up @@ -1350,6 +1353,9 @@
<ClCompile Include="Rendering\PostProcessing\MotionBlur.cpp">
<Filter>Rendering\Postprocessing\MotionBlur</Filter>
</ClCompile>
<ClCompile Include="Rendering\Mesh\UnsortedMeshPool.cpp">
<Filter>Rendering\Mesh\Pool</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<FxCompile Include="ShaderCodes\BilateralFiltering.hlsl">
Expand Down

0 comments on commit 78c86b4

Please sign in to comment.