Skip to content

Commit

Permalink
freat: remove pre post z pass (#119)
Browse files Browse the repository at this point in the history
* feat: migrate in changes for the forge

Signed-off-by: Michael Pollind <[email protected]>

* feat: update vcpkg

Signed-off-by: Michael Pollind <[email protected]>

* feat: remove pre and post z pass

Signed-off-by: Michael Pollind <[email protected]>

* feat: tweak build action

Signed-off-by: Michael Pollind <[email protected]>

* feat: address sub proejct

Signed-off-by: Michael Pollind <[email protected]>

* feat: fix

Signed-off-by: Michael Pollind <[email protected]>

* tweak

Signed-off-by: Michael Pollind <[email protected]>

* feat: remove caching logic for the moment

Signed-off-by: Michael Pollind <[email protected]>

* feat: compile gpu data

Signed-off-by: Michael Pollind <[email protected]>

* feat: move over to GraphicsAllocator

Signed-off-by: Michael Pollind <[email protected]>

* feat: tweak viewport logic

Signed-off-by: Michael Pollind <[email protected]>

* feat: fix compiling error on windows

Signed-off-by: Michael Pollind <[email protected]>

* feat: add D311 sources

Signed-off-by: Michael Pollind <[email protected]>

* fix platform something or other

Signed-off-by: Michael Pollind <[email protected]>

---------

Signed-off-by: Michael Pollind <[email protected]>
  • Loading branch information
pollend authored Jun 12, 2024
1 parent c0c861c commit a1621ae
Show file tree
Hide file tree
Showing 105 changed files with 6,164 additions and 7,429 deletions.
18 changes: 17 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ jobs:
run: |
cd ${{ github.workspace }}/build
ninja
- name: Package Amnesia
working-directory: ./build
run: tar -czvf ../amnesia-linux-x86-64-release.tar.gz *
- name: Upload Amnesia artifact
uses: actions/upload-artifact@v3
with:
name: amnesia-linux-x86-64-release
path: amnesia-linux-x86-64-release.tar.gz
windows:
runs-on: windows-latest
steps:
Expand All @@ -50,4 +58,12 @@ jobs:
- name: Build
run: |
cd ${{ github.workspace }}\build
msbuild ALL_BUILD.vcxproj /property:Configuration=Release
msbuild ALL_BUILD.vcxproj /property:Configuration=Release
- name: Package Amnesia
working-directory: .\build
run: 7z a ..\amnesia-win-x86-64-release.zip *
- name: Upload Amnesia artifact
uses: actions/upload-artifact@v3
with:
name: amnesia-win-x86-64-release
path: amnesia-win-x86-64-release.zip
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
- name: Zipping (Windows)
run: |
cd ${{ github.workspace }}/build
7z a Amnesia_windows_x68_64_${{ github.event.inputs.tag }}.zip amnesia/Release
7z a Amnesia_windows_x68_64_${{ github.event.inputs.tag }}.zip *
- uses: actions/upload-artifact@master
with:
name: windows-build-artifacts
Expand Down
19 changes: 12 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
mono_crash.*

# Build results
build/
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
Expand All @@ -30,10 +31,6 @@ bld/
[Oo]bj/
[Ll]og/
[Ll]ogs/
.[Bb]uild/
[Bb]uild/
vcpkg_installed/
/out/

# Visual Studio 2015/2017 cache/options directory
.vs/
Expand Down Expand Up @@ -353,8 +350,16 @@ MigrationBackup/
# Ionide (cross platform F# VS Code tools) working folder
.ionide/

lib/

# HPL2 Specific
BuildID_*.cpp
BuildID_*.h
cmake-build-debug/
CMakeCache.txt
vcpkg_installed/
CMakeFiles/

Makefile
cmake_install.cmake
*.a

/HPL2/Shaders
/HPL2/CompiledShaders
8 changes: 2 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ cmake_minimum_required(VERSION 3.21)
set(CMAKE_CXX_STANDARD 20)
set(INSTALL_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/bin)
set(CMAKE_INSTALL_PREFIX ${INSTALL_OUTPUT_PATH} CACHE PATH "Install path prefix, prepended onto install directories." FORCE)
set(CMAKE_MODULE_PATH ${CMAKE_HOME_DIRECTORY}/cmake)
include(HPLUtils)

enable_language(ASM)

Expand All @@ -14,12 +16,6 @@ if(UNIX)
endif()
include("${CMAKE_CURRENT_SOURCE_DIR}/vcpkg/scripts/buildsystems/vcpkg.cmake")

add_definitions(
-DUSE_THE_FORGE_LEGACY
# -DUSE_FORWARD_PLUS_BACKEND # prototype forward renderer
)


# hack to get to build on windwos
# HACK to correctly set Linux property for newer cmake
if(NOT APPLE AND UNIX)
Expand Down
2 changes: 1 addition & 1 deletion HPL2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ source_group("Platform" REGULAR_EXPRESSION "\\/impl\\/Platform.+")

# setup libs

set(OpenGL_GL_PREFERENCE LEGACY)
# set(OpenGL_GL_PREFERENCE LEGACY)
find_package(DevIL REQUIRED)
find_package(OpenGL REQUIRED)
find_package(ZLIB REQUIRED)
Expand Down
6 changes: 2 additions & 4 deletions HPL2/include/graphics/DebugDraw.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ class DebugDraw final {
Count
};

static constexpr uint32_t ImmediateVertexBufferSize = 1 << 25;
static constexpr uint32_t ImmediateIndexBufferSize = 1 << 23;
static constexpr uint32_t ImmediateVertexBufferSize = 1 << 10;
static constexpr uint32_t ImmediateIndexBufferSize = 1 << 10;
static constexpr uint32_t NumberOfPerFrameUniforms = 32;
static constexpr uint32_t NumberOfTextureUnits = 512;

Expand Down Expand Up @@ -131,8 +131,6 @@ class DebugDraw final {
mat4 m_viewProj2DMat;
};

GPURingBuffer* m_vertexBuffer = nullptr;
GPURingBuffer* m_indexBuffer = nullptr;
std::array<SharedBuffer, NumberOfPerFrameUniforms> m_viewBufferUniform;
uint32_t m_frameIndex = 0;
uint32_t m_activeFrame = 0;
Expand Down
5 changes: 2 additions & 3 deletions HPL2/include/graphics/DrawPacket.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ namespace hpl {
uint32_t m_numStreams;
struct {
SharedBuffer* m_buffer;
eVertexBufferElement m_element;
uint64_t m_offset;
uint32_t m_stride;
} m_vertexStream[MaxVertexBindings];
Expand All @@ -33,8 +34,6 @@ namespace hpl {
};

struct GeometrySetBinding {
uint32_t m_numStreams;
eVertexBufferElement m_elements[MaxVertexBindings];
GraphicsAllocator::AllocationSet m_set;
GeometrySet::GeometrySetSubAllocation* m_subAllocation;
uint32_t m_numIndices;
Expand All @@ -51,7 +50,7 @@ namespace hpl {
return 0;
}

static void cmdBindBuffers(Cmd* cmd, ForgeRenderer::CommandResourcePool* resourcePool, DrawPacket* packet);
static void cmdBindBuffers(Cmd* cmd, ForgeRenderer::CommandResourcePool* resourcePool, DrawPacket* packet, std::span<eVertexBufferElement> elements);

DrawPacket()
: m_type(DrawPacketType::Unknown) {
Expand Down
79 changes: 49 additions & 30 deletions HPL2/include/graphics/ForgeRenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#include <engine/RTTI.h>

#include "Common_3/Utilities/RingBuffer.h"
#include "graphics/ForgeHandles.h"
#include "windowing/NativeWindow.h"
#include "engine/QueuedEventLoopHandler.h"
Expand Down Expand Up @@ -54,13 +55,12 @@ namespace hpl {
CopyPipelineCount = 2
};


static constexpr uint32_t MaxCopyFrames = 32;
static constexpr uint32_t SwapChainLength = 2; // double buffered
static constexpr uint32_t ResourcePoolSize = 4; // double buffered

void InitializeRenderer(window::NativeWindowWrapper* window);
void InitializeResource();
RendererApi GetApi();

struct SamplerPoolKey {
union {
Expand Down Expand Up @@ -103,36 +103,58 @@ namespace hpl {
/**
* tracks the resources used by a single command buffer
*/
//TODO: transiation this to Frame.h
struct Frame {
public:
uint32_t m_currentFrame = 0;
uint32_t m_frameIndex = 0;
uint32_t m_swapChainIndex = 0;
GpuCmdRingElement m_cmdRingElement;
bool m_isFinished = true;

Frame() = default;
Frame(Frame& frame) = delete;
void operator=(Frame&) = delete;

ForgeRenderer* m_renderer = nullptr;
SwapChain* m_swapChain = nullptr;
Cmd* m_cmd = nullptr;
CmdPool* m_cmdPool = nullptr;
Fence* m_renderCompleteFence = nullptr;
Semaphore* m_renderCompleteSemaphore = nullptr;
CommandResourcePool* m_resourcePool = nullptr;
RenderTarget* m_finalRenderTarget = nullptr;
};
std::vector<Semaphore*> m_waitSemaphores = {};

template<typename T>
inline void pushResource(const T& ele) {
m_resourcePool->Push(ele);
}

inline uint32_t FrameCount() {
return m_currentFrame;
}

inline uint32_t index() {
return m_frameIndex;
}

inline Cmd*& cmd() {
return m_cmdRingElement.pCmds[0];
}

inline RenderTarget* finalTarget() {
return m_finalRenderTarget;
}

inline GpuCmdRingElement& RingElement() {
return m_cmdRingElement;
}

friend class ForgeRenderer;
};

const inline Frame GetFrame() {
Frame frame;
frame.m_currentFrame = FrameCount();
frame.m_frameIndex = CurrentFrameIndex();
frame.m_swapChainIndex = SwapChainIndex();
frame.m_renderer = this;
frame.m_swapChain = m_swapChain.m_handle;

frame.m_cmd = m_cmds[CurrentFrameIndex()];
frame.m_cmdPool = m_cmdPools[CurrentFrameIndex()];
frame.m_renderCompleteFence = m_renderCompleteFences[CurrentFrameIndex()];
frame.m_renderCompleteSemaphore = m_renderCompleteSemaphores[CurrentFrameIndex()];
frame.m_resourcePool = &m_resourcePool[CurrentFrameIndex()];
frame.m_finalRenderTarget = m_finalRenderTarget[CurrentFrameIndex()].m_handle;
return frame;
inline Frame& GetFrame() {
return m_frame;
}
// void BeginFrame() {}

Expand All @@ -145,10 +167,6 @@ namespace hpl {
}
RootSignature* PipelineSignature() { return m_pipelineSignature; }

size_t SwapChainIndex() { return m_swapChainIndex; }
size_t CurrentFrameIndex() { return m_currentFrameCount % SwapChainLength; }
size_t FrameCount() { return m_currentFrameCount; }
inline SwapChain* GetSwapChain() { return m_swapChain.m_handle; }
inline Queue* GetGraphicsQueue() { return m_graphicsQueue; }

void cmdCopyTexture(Cmd* cmd, Texture* srcTexture, RenderTarget* dstTexture);
Expand All @@ -158,17 +176,15 @@ namespace hpl {
private:
std::array<Sampler*, SamplerPoolKey::NumOfVariants> m_samplerPool;
std::array<CommandResourcePool, SwapChainLength> m_resourcePool;
std::array<Fence*, SwapChainLength> m_renderCompleteFences;
std::array<Semaphore*, SwapChainLength> m_renderCompleteSemaphores;
std::array<CmdPool*, SwapChainLength> m_cmdPools;
std::array<Cmd*, SwapChainLength> m_cmds;
std::array<SharedRenderTarget, SwapChainLength> m_finalRenderTarget;

float m_gamma = 1.0f;

window::WindowEvent::QueuedEventHandler m_windowEventHandler;
window::NativeWindowWrapper* m_window = nullptr;

GpuCmdRing m_graphicsCmdRing;

Renderer* m_renderer = nullptr;
RootSignature* m_pipelineSignature = nullptr;
SharedSwapChain m_swapChain;
Expand All @@ -187,11 +203,14 @@ namespace hpl {
SharedSampler m_pointSampler ;

RootSignature* m_copyPostProcessingRootSignature = nullptr;
DescriptorSet* m_copyPostProcessingDescriptorSet = nullptr;
std::array<DescriptorSet*, SwapChainLength> m_copyPostProcessingDescriptorSet ;
uint32_t m_copyRegionDescriptorIndex = 0;
float m_gamma = 1.0f;
uint32_t m_swapChainCount;


Frame m_frame;

uint32_t m_currentFrameCount = 0;
uint32_t m_swapChainIndex = 0;
};

} // namespace hpl
49 changes: 0 additions & 49 deletions HPL2/include/graphics/ForwardResources.h

This file was deleted.

4 changes: 2 additions & 2 deletions HPL2/include/graphics/GeometrySet.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ namespace hpl {
inline SharedBuffer& indexBuffer() { return m_geometrySet->m_indexBuffer; }
inline std::span<GeometryStream> vertexStreams() { return m_geometrySet->m_vertexStreams; }
inline std::span<GeometryStream>::iterator getStreamBySemantic(ShaderSemantic semantic) {return m_geometrySet->getStreamBySemantic(semantic);}
inline uint32_t vertextOffset() { return m_vertexAllocation.offset; }
inline uint32_t vertexOffset() { return m_vertexAllocation.offset; }
inline uint32_t indexOffset() { return m_indexAllocation.offset; }

private:
Expand All @@ -77,7 +77,7 @@ namespace hpl {
inline SharedBuffer& indexBuffer() { return m_indexBuffer; }
void operator=(GeometrySet&& set);
void operator=(const GeometrySet& set) = delete;
std::shared_ptr<GeometrySetSubAllocation> allocate(uint32_t numElements, uint32_t numIndecies);
std::shared_ptr<GeometrySet::GeometrySetSubAllocation> allocate(uint32_t numElements, uint32_t numIndecies);
private:
OffsetAllocator::Allocator m_vertexStreamAllocator;
OffsetAllocator::Allocator m_indexStreamAllocator;
Expand Down
Loading

0 comments on commit a1621ae

Please sign in to comment.