Skip to content

Commit

Permalink
Renderer::CreateGraphicsResources
Browse files Browse the repository at this point in the history
  • Loading branch information
roeas committed Sep 12, 2023
1 parent fccf8ab commit 3404891
Show file tree
Hide file tree
Showing 34 changed files with 167 additions and 129 deletions.
25 changes: 19 additions & 6 deletions Engine/Source/Editor/EditorApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ void EditorApp::Init(engine::EngineInitArgs initArgs)
AddWindow(cd::MoveTemp(pSplashWindow));

InitEditorRenderers();
CreateEditorRendererGraphicsResources();
InitEditorImGuiContext(m_initArgs.language);

InitECWorld();
Expand Down Expand Up @@ -446,6 +447,22 @@ void EditorApp::InitEngineRenderers()
AddEngineRenderer(std::make_unique<engine::ImGuiRenderer>(m_pRenderContext->CreateView(), pSceneRenderTarget));
}

void EditorApp::CreateEditorRendererGraphicsResources()
{
for (std::unique_ptr<engine::Renderer>& pRenderer : m_pEditorRenderers)
{
pRenderer->CreateGraphicsResources();
}
}

void EditorApp::CreateEngineRendererGraphicsResources()
{
for (std::unique_ptr<engine::Renderer>& pRenderer : m_pEngineRenderers)
{
pRenderer->CreateGraphicsResources();
}
}

bool EditorApp::IsAtmosphericScatteringEnable() const
{
engine::GraphicsBackend backend = engine::Path::GetGraphicsBackend();
Expand Down Expand Up @@ -502,18 +519,14 @@ bool EditorApp::Update(float deltaTime)
{
m_bInitEditor = true;

// Load compiled shaders.
for (std::unique_ptr<engine::Renderer>& pRenderer : m_pEngineRenderers)
{
pRenderer->LoadShaders();
}

engine::ShaderLoader::UploadUberShader(m_pSceneWorld->GetPBRMaterialType());
engine::ShaderLoader::UploadUberShader(m_pSceneWorld->GetAnimationMaterialType());
#ifdef ENABLE_DDGI
engine::ShaderLoader::UploadUberShader(m_pSceneWorld->GetDDGIMaterialType());
#endif

CreateEngineRendererGraphicsResources();

// Phase 2 - Project Manager
// * TODO : Show project selector
//GetMainWindow()->SetTitle("Project Manager");
Expand Down
4 changes: 4 additions & 0 deletions Engine/Source/Editor/EditorApp.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ class EditorApp final : public engine::IApplication
void InitRenderContext(engine::GraphicsBackend backend, void* hwnd = nullptr);
void InitEditorRenderers();
void InitEngineRenderers();

void CreateEditorRendererGraphicsResources();
void CreateEngineRendererGraphicsResources();

void InitShaderPrograms() const;
void AddEditorRenderer(std::unique_ptr<engine::Renderer> pRenderer);
void AddEngineRenderer(std::unique_ptr<engine::Renderer> pRenderer);
Expand Down
6 changes: 3 additions & 3 deletions Engine/Source/Editor/ImGui/EditorImGuiViewport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ EditorImGuiViewport::EditorImGuiViewport(engine::RenderContext* pRenderContext)

void EditorImGuiViewport::Update()
{
//struct Rect { int left, top, width, height; };
//struct Rect { int left, top, m_width, m_height; };
//struct Monitor {
// Rect work_rect;
// Rect monitor_rect;
Expand All @@ -101,9 +101,9 @@ void EditorImGuiViewport::Update()
// const os::Monitor& m = monitors[i];
// ImGuiPlatformMonitor im;
// im.MainPos = ImVec2((float)m.monitor_rect.left, (float)m.monitor_rect.top);
// im.MainSize = ImVec2((float)m.monitor_rect.width, (float)m.monitor_rect.height);
// im.MainSize = ImVec2((float)m.monitor_rect.m_width, (float)m.monitor_rect.m_height);
// im.WorkPos = ImVec2((float)m.work_rect.left, (float)m.work_rect.top);
// im.WorkSize = ImVec2((float)m.work_rect.width, (float)m.work_rect.height);
// im.WorkSize = ImVec2((float)m.work_rect.m_width, (float)m.work_rect.m_height);
//
// if (m.primary) {
// pio.Monitors.push_front(im);
Expand Down
2 changes: 1 addition & 1 deletion Engine/Source/Editor/UILayers/AssetBrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1130,7 +1130,7 @@ void AssetBrowser::Update()
// Column border size is fixed in ImGui
// https://stackoverflow.com/questions/72068188/how-do-i-change-the-border-size-for-a-table-in-dear-imgui

// Colomn width doesn't have a flag to set only in the first frame.
// Colomn m_width doesn't have a flag to set only in the first frame.
ImGui::SetColumnWidth(0, ImGui::GetWindowContentRegionMax().x * 0.3f);
bFirstUpdate = false;
}
Expand Down
2 changes: 1 addition & 1 deletion Engine/Source/Editor/UILayers/OutputLog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ void OutputLog::Draw() {
// If you have tens of thousands of items and their processing cost is non-negligible, coarse clipping them
// on your side is recommended. Using ImGuiListClipper requires
// - A) random access into your data
// - B) items all being the same height,
// - B) items all being the same m_height,
// both of which we can handle since we have an array pointing to the beginning of each line of text.
// When using the filter (in the block of code above) we don't have random access into the data to display
// anymore, which is why we don't use the clipper. Storing or skimming through the search result would make
Expand Down
8 changes: 4 additions & 4 deletions Engine/Source/Runtime/ECWorld/TerrainComponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ class TerrainComponent final

private:
//mesh
uint16_t m_meshWidth = 129U;//uint32_t is too big for width
uint16_t m_meshWidth = 129U;//uint32_t is too big for m_width
uint16_t m_meshDepth = 129U;

//height map input
uint16_t m_texWidth = 129U;//uint32_t is too big for width
//m_height map input
uint16_t m_texWidth = 129U;//uint32_t is too big for m_width
uint16_t m_texDepth = 129U;//
float m_roughness = 1.55f;
float m_minHeight = 0.0f;
Expand All @@ -71,7 +71,7 @@ class TerrainComponent final
//for patch wise generating
//uint32_t m_PatchSize;

//height map output
//m_height map output
std::vector<std::byte> m_elevationRawData;
};

Expand Down
2 changes: 1 addition & 1 deletion Engine/Source/Runtime/ImGui/ImGuiContextInstance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ void ImGuiContextInstance::BeginDockSpace()
ImGuiWindowFlags_NoBackground;

// Place dock space window under static imgui layers.
// It is a hack now as only main menu bar is a static layer so we only need to adjust the height.
// It is a hack now as only main menu bar is a static layer so we only need to adjust the m_height.
// If we have more static layers, we need to calculate their accurate areas.
ImGuiViewport* pMainViewport = ImGui::GetMainViewport();
assert(pMainViewport && "The main viewport cannot be null");
Expand Down
2 changes: 1 addition & 1 deletion Engine/Source/Runtime/Rendering/AABBRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ void AABBRenderer::Init()
bgfx::setViewName(GetViewID(), "AABBRenderer");
}

void AABBRenderer::LoadShaders()
void AABBRenderer::CreateGraphicsResources()
{
GetRenderContext()->CreateProgram("AABBProgram", "vs_AABB.bin", "fs_AABB.bin");
}
Expand Down
2 changes: 1 addition & 1 deletion Engine/Source/Runtime/Rendering/AABBRenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class AABBRenderer final : public Renderer
using Renderer::Renderer;

virtual void Init() override;
virtual void LoadShaders() override;
virtual void CreateGraphicsResources() override;
virtual void UpdateView(const float* pViewMatrix, const float* pProjectionMatrix) override;
virtual void Render(float deltaTime) override;

Expand Down
2 changes: 1 addition & 1 deletion Engine/Source/Runtime/Rendering/AnimationRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ void AnimationRenderer::Init()
bgfx::setViewName(GetViewID(), "AnimationRenderer");
}

void AnimationRenderer::LoadShaders()
void AnimationRenderer::CreateGraphicsResources()
{
#ifdef VISUALIZE_BONE_WEIGHTS
m_pRenderContext->CreateUniform("u_debugBoneIndex", bgfx::UniformType::Vec4, 1);
Expand Down
2 changes: 1 addition & 1 deletion Engine/Source/Runtime/Rendering/AnimationRenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class AnimationRenderer final : public Renderer
using Renderer::Renderer;

virtual void Init() override;
virtual void LoadShaders() override;
virtual void CreateGraphicsResources() override;
virtual void UpdateView(const float* pViewMatrix, const float* pProjectionMatrix) override;
virtual void Render(float deltaTime) override;

Expand Down
2 changes: 1 addition & 1 deletion Engine/Source/Runtime/Rendering/BlitRenderTargetPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ BlitRenderTargetPass::~BlitRenderTargetPass()
{
}

void BlitRenderTargetPass::LoadShaders()
void BlitRenderTargetPass::CreateGraphicsResources()
{
}

Expand Down
2 changes: 1 addition & 1 deletion Engine/Source/Runtime/Rendering/BlitRenderTargetPass.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class BlitRenderTargetPass final : public Renderer
virtual ~BlitRenderTargetPass();

virtual void Init() override;
virtual void LoadShaders() override;
virtual void CreateGraphicsResources() override;
virtual void UpdateView(const float* pViewMatrix, const float* pProjectionMatrix) override;
virtual void Render(float deltaTime) override;

Expand Down
Loading

0 comments on commit 3404891

Please sign in to comment.