Skip to content

Commit

Permalink
Working on arch, added jolt and entt
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikita Krupitskas committed Aug 13, 2024
1 parent fa4f7f1 commit 5f73ac7
Show file tree
Hide file tree
Showing 33 changed files with 379 additions and 23 deletions.
11 changes: 9 additions & 2 deletions Shaders/Tonemap.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ void main(uint3 threadId : SV_DispatchThreadID)
return;
}

// TODO: Fix pixel addressing, black line on right and bottom
LDRTexture[threadId.xy] = HDRTexture[threadId.xy];
const float gamma = 2.2;

const float3 hdr_color = HDRTexture[threadId.xy];

// Reinhard
const float3 ldr_color = 1.0f - exp(-hdr_color * exposure);
const float3 ldr_gamma_corrected_color = pow(ldr_color, 1.0f / gamma);

LDRTexture[threadId.xy] = float4(ldr_gamma_corrected_color, 0.0);
}
2 changes: 1 addition & 1 deletion Yasno/Graphics/Material.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#pragma once
#include "Material.hpp"

namespace ysn
{
Expand Down
4 changes: 3 additions & 1 deletion Yasno/Graphics/Material.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@

namespace ysn
{

class Material
{
};
}
4 changes: 4 additions & 0 deletions Yasno/Graphics/Mesh.cpp
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
#include "Mesh.hpp"

namespace ysn
{
}
7 changes: 5 additions & 2 deletions Yasno/Graphics/Mesh.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#pragma once

class Mesh
namespace ysn
{
};
class Mesh
{
};
}
10 changes: 7 additions & 3 deletions Yasno/Graphics/Primitives.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,19 @@

namespace ysn
{
struct Sphere
class Primitive
{
};

struct Box
class Sphere
{
};

struct Plane
class Box
{
};

class Plane
{
};
}
6 changes: 6 additions & 0 deletions Yasno/RHI/ColorBuffer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include "ColorBuffer.hpp"

namespace ysn
{

}
14 changes: 14 additions & 0 deletions Yasno/RHI/ColorBuffer.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#pragma once

#include <d3dx12.h>
#include <wil/com.h>

namespace ysn
{
class ColorBuffer
{
public:

private:
};
}
5 changes: 5 additions & 0 deletions Yasno/RHI/DepthBuffer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include "DepthBuffer.hpp"

namespace ysn
{
}
14 changes: 14 additions & 0 deletions Yasno/RHI/DepthBuffer.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#pragma once

#include <d3dx12.h>
#include <wil/com.h>

namespace ysn
{
class DepthBuffer
{
public:

private:
};
}
6 changes: 6 additions & 0 deletions Yasno/RHI/GpuBuffer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include "GpuBuffer.hpp"

namespace ysn
{

}
11 changes: 10 additions & 1 deletion Yasno/RHI/GpuBuffer.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
#pragma once

#include <d3dx12.h>
#include <wil/com.h>

namespace ysn
{

class GpuBuffer
{
public:

private:
wil::com_ptr<ID3D12Resource> m_resource;
};
}
5 changes: 5 additions & 0 deletions Yasno/RHI/GpuReadBackBuffer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include "GpuReadbackBuffer.hpp"

namespace ysn
{
}
14 changes: 14 additions & 0 deletions Yasno/RHI/GpuReadBackBuffer.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#pragma once

#include <d3dx12.h>
#include <wil/com.h>

namespace ysn
{
class GpuReadbackBuffer
{
public:

private:
};
}
15 changes: 15 additions & 0 deletions Yasno/RHI/GpuResource.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#pragma once

#include <d3dx12.h>
#include <wil/com.h>

namespace ysn
{
class GpuResource
{
public:

private:
wil::com_ptr<ID3D12Resource> m_resource;
};
}
5 changes: 5 additions & 0 deletions Yasno/RHI/GpuUploadBuffer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include "GpuUploadBuffer.hpp"

namespace ysn
{
}
14 changes: 14 additions & 0 deletions Yasno/RHI/GpuUploadBuffer.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#pragma once

#include <d3dx12.h>
#include <wil/com.h>

namespace ysn
{
class GpuUploadBuffer
{
public:

private:
};
}
21 changes: 19 additions & 2 deletions Yasno/RHI/PipelineStateObject.hpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,32 @@
#pragma once

#include <string>

#include <d3d12.h>
#include <wil/com.h>

namespace ysn
{
using PipelineStateObjectId = uint64_t;

struct PipelineStateObject
class PipelineStateObject
{
public:
PipelineStateObject(const std::wstring_view name) : m_name(name) {}

private:
const std::wstring m_name = L"Unnamed PSO";

ID3D12RootSignature* m_root_signature = nullptr;
ID3D12PipelineState* m_pso = nullptr;
};

class GraphicsPipelineStateObject : public PipelineStateObject
{
};

class ComputePipelineStateObject : public PipelineStateObject
{
wil::com_ptr<ID3D12PipelineState> pso;
};

class PipelineStateObjectManager
Expand Down
5 changes: 5 additions & 0 deletions Yasno/RHI/PixelBuffer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include "PixelBuffer.hpp"

namespace ysn
{
}
14 changes: 14 additions & 0 deletions Yasno/RHI/PixelBuffer.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#pragma once

#include <d3dx12.h>
#include <wil/com.h>

namespace ysn
{
class PixelBuffer
{
public:

private:
};
}
5 changes: 5 additions & 0 deletions Yasno/RHI/RootSignature.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include "RootSignature.hpp"

namespace ysn
{
}
13 changes: 13 additions & 0 deletions Yasno/RHI/RootSignature.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#pragma once

#include <d3dx12.h>

namespace ysn
{
class RootSignature
{
public:

private:
};
}
5 changes: 5 additions & 0 deletions Yasno/RHI/ShadowBuffer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include "ShadowBuffer.hpp"

namespace ysn
{
}
14 changes: 14 additions & 0 deletions Yasno/RHI/ShadowBuffer.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#pragma once

#include <d3dx12.h>
#include <wil/com.h>

namespace ysn
{
class ShadowBuffer
{
public:

private:
};
}
53 changes: 53 additions & 0 deletions Yasno/System/Hash.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#pragma once

#include <System/Math.hpp>

// This requires SSE4.2 which is present on Intel Nehalem (Nov. 2008)
// and AMD Bulldozer (Oct. 2011) processors. I could put a runtime
// check for this, but I'm just going to assume people playing with
// DirectX 12 on Windows 10 have fairly recent machines.
#ifdef _M_X64
#define ENABLE_SSE_CRC32 1
#else
#define ENABLE_SSE_CRC32 0
#endif

#if ENABLE_SSE_CRC32
#pragma intrinsic(_mm_crc32_u32)
#pragma intrinsic(_mm_crc32_u64)
#endif

namespace ysn
{
inline size_t HashRange(const uint32_t* const Begin, const uint32_t* const End, size_t Hash)
{
#if ENABLE_SSE_CRC32
const uint64_t* Iter64 = (const uint64_t*)AlignUp(Begin, 8);
const uint64_t* const End64 = (const uint64_t* const)AlignDown(End, 8);

// If not 64-bit aligned, start with a single u32
if ((uint32_t*)Iter64 > Begin)
Hash = _mm_crc32_u32((uint32_t)Hash, *Begin);

// Iterate over consecutive u64 values
while (Iter64 < End64)
Hash = _mm_crc32_u64((uint64_t)Hash, *Iter64++);

// If there is a 32-bit remainder, accumulate that
if ((uint32_t*)Iter64 < End)
Hash = _mm_crc32_u32((uint32_t)Hash, *(uint32_t*)Iter64);
#else
// An inexpensive hash for CPUs lacking SSE4.2
for (const uint32_t* Iter = Begin; Iter < End; ++Iter)
Hash = 16777619U * Hash ^ *Iter;
#endif

return Hash;
}

template <typename T> inline size_t HashState( const T* StateDesc, size_t Count = 1, size_t Hash = 2166136261U )
{
static_assert((sizeof(T) & 3) == 0 && alignof(T) >= 4, "State object is not word-aligned");
return HashRange((uint32_t*)StateDesc, (uint32_t*)(StateDesc + Count), Hash);
}
}
Loading

0 comments on commit 5f73ac7

Please sign in to comment.