Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

D3d11 work #5

Merged
merged 4 commits into from
Feb 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DX11GraphicsAPI/DX11GraphicsAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1000,7 +1000,7 @@ namespace dooms
DOOMS_ENGINE_GRAPHICS_API unsigned int DeinitializeGraphicsAPI()
{
dx11::CleanupDevice();
return 0;
return 1;
}

DOOMS_ENGINE_GRAPHICS_API unsigned int GetDrawCall()
Expand Down
2 changes: 2 additions & 0 deletions Doom3/DoomsEngine_D3D11.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
start DoomsEngine.exe DIRECTX
exit
2 changes: 2 additions & 0 deletions Doom3/DoomsEngine_OPENGL.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
start DoomsEngine.exe OPENGL
exit
2 changes: 1 addition & 1 deletion Doom3/Source/Core/Game/AssetManager/AssetManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ void AssetManager::OnSetPendingKill()
DestroyAllAssets();
}

void dooms::assetImporter::AssetManager::Init()
void dooms::assetImporter::AssetManager::Init(const int argc, char* const* const argv)
{
AddToRootObjectList();

Expand Down
2 changes: 1 addition & 1 deletion Doom3/Source/Core/Game/AssetManager/AssetManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ namespace dooms
virtual void OnSetPendingKill() override;


virtual void Init() final;
virtual void Init(const int argc, char* const* const argv) final;
virtual void Update() final;
virtual void OnEndOfFrame() final;

Expand Down
53 changes: 40 additions & 13 deletions Doom3/Source/Core/Game/GameCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,47 @@ void dooms::GameCore::UpdateGameCore()

}

void dooms::GameCore::InitializeGraphicsAPI(const int argc, char* const* const argv)
{
graphics::GraphicsAPI::eGraphicsAPIType targetGraphicsAPI = graphics::GraphicsAPI::eGraphicsAPIType::GraphicsAPIType_NONE;

for(size_t i = 0 ; i < argc ; i++)
{
if(_stricmp(argv[i], "OPENGL") == 0)
{
targetGraphicsAPI = graphics::GraphicsAPI::eGraphicsAPIType::OpenGL;
}
else if
(
(_stricmp(argv[i], "DX11") == 0) ||
(_stricmp(argv[i], "DX11_10") == 0) ||
(_stricmp(argv[i], "DIRECTX") == 0) ||
(_stricmp(argv[i], "DIRECTX11") == 0) ||
(_stricmp(argv[i], "DIRECTX11_10") == 0)
)
{
targetGraphicsAPI = graphics::GraphicsAPI::eGraphicsAPIType::DX11_10;
}
}

D_START_PROFILING(LoadGraphisAPI, eProfileLayers::CPU);
mGraphics_Server.InitializeGraphicsAPI(targetGraphicsAPI);
D_END_PROFILING(LoadGraphisAPI);

}

dooms::GameCore::~GameCore()
{
mCurrentScene->SetIsPendingKill();
}

void dooms::GameCore::Init()
void dooms::GameCore::Init(const int argc, char* const* const argv)
{
D_START_PROFILING(InitGameSetting, eProfileLayers::CPU);
InitGameSetting();
D_END_PROFILING(InitGameSetting);

InitServers();
InitServers(argc, argv);
LateInit();

mCurrentScene = CreateNewScene();
Expand All @@ -74,42 +103,40 @@ void dooms::GameCore::Init()
dooms::gc::GarbageCollectorManager::ResetElapsedTime();
}

void dooms::GameCore::InitServers()
void dooms::GameCore::InitServers(const int argc, char* const* const argv)
{
mMemoryManager.Init();
mMemoryManager.Init(argc, argv);

D_START_PROFILING(Init_ReflectionManager, eProfileLayers::CPU);
mReflectionManager.Initialize();
D_END_PROFILING(Init_ReflectionManager);

D_START_PROFILING(LoadGraphisAPI, eProfileLayers::CPU);
mGraphics_Server.InitializeGraphicsAPI();
D_END_PROFILING(LoadGraphisAPI);
InitializeGraphicsAPI(argc, argv);

D_START_PROFILING(mJobSystem_Init, eProfileLayers::CPU);
mJobSystem.Init();
mJobSystem.Init(argc, argv);
D_END_PROFILING(mJobSystem_Init);

D_START_PROFILING(mTime_Server_Init, eProfileLayers::CPU);
mTime_Server.Init();
mTime_Server.Init(argc, argv);
D_END_PROFILING(mTime_Server_Init);

//
//Read This : https://docs.unity3d.com/Manual/class-TimeManager.html
D_START_PROFILING(Init_Physics_Server, eProfileLayers::CPU);
mPhysics_Server.Init();
mPhysics_Server.Init(argc, argv);
D_END_PROFILING(Init_Physics_Server);

D_START_PROFILING(Init_Graphics_Server, eProfileLayers::Rendering);
mGraphics_Server.Init();
mGraphics_Server.Init(argc, argv);
D_END_PROFILING(Init_Graphics_Server);

D_START_PROFILING(Init_UserInput_Server, eProfileLayers::CPU);
mUserImput_Server.Init();
mUserImput_Server.Init(argc, argv);
D_END_PROFILING(Init_UserInput_Server);

D_START_PROFILING(Init_AssetManager, eProfileLayers::CPU);
mAssetManager.Init();
mAssetManager.Init(argc, argv);
D_END_PROFILING(Init_AssetManager);


Expand Down
6 changes: 4 additions & 2 deletions Doom3/Source/Core/Game/GameCore.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ namespace dooms
void InitGameSetting();

void UpdateGameCore();

void InitializeGraphicsAPI(const int argc, char* const* const argv);

public:

Expand All @@ -101,8 +103,8 @@ namespace dooms
GameCore& operator=(GameCore&&) = delete;
~GameCore();

virtual void Init() final;
void InitServers();
virtual void Init(const int argc, char* const* const argv) final;
void InitServers(const int argc, char* const* const argv);
virtual void LateInit() final;

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion Doom3/Source/Core/Game/IGameFlow.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace dooms
/// Don't put virtual
/// </summary>
void Init_Internal() {}
virtual void Init() = 0;
virtual void Init(const int argc, char* const* const argv) = 0;
virtual void LateInit() {}

/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions Doom3/Source/Core/GameEngineEntryPoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

namespace dooms
{
int GameEngineEntryPoint()
int GameEngineEntryPoint(int argc, char* argv[])
{
{
{
Expand All @@ -24,7 +24,7 @@ namespace dooms
dooms::GameCore gameCore{};

D_START_PROFILING(Init_Game, dooms::profiler::eProfileLayers::CPU);
gameCore.Init();
gameCore.Init(argc, argv);
D_END_PROFILING(Init_Game);

while (gameCore.Tick())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ void dooms::graphics::GraphicsAPILoader::FetchExportedFunctionAddress()
//D_ASSERT(dooms::graphics::GraphicsAPI::AttachRenderBufferToFrameBuffer != nullptr);
dooms::graphics::GraphicsAPI::AttachShaderToMaterial = (GraphicsAPI::GRAPHICS_ATTACHSHADERTOMATERIAL)GetProcAddress(hModule, "AttachShaderToMaterial");
//D_ASSERT(dooms::graphics::GraphicsAPI::AttachShaderToMaterial != nullptr);
dooms::graphics::GraphicsAPI::DetachShaderFromMaterial = (GraphicsAPI::GRAPHICS_DETACHSHADERFROMMATERIAL)GetProcAddress(hModule, "DetachShaderToMaterial");
dooms::graphics::GraphicsAPI::DetachShaderFromMaterial = (GraphicsAPI::GRAPHICS_DETACHSHADERFROMMATERIAL)GetProcAddress(hModule, "DetachShaderFromMaterial");
//D_ASSERT(dooms::graphics::GraphicsAPI::DetachShaderToMaterial != nullptr);
dooms::graphics::GraphicsAPI::BindVertexDataBuffer = (GraphicsAPI::GRAPHICS_BINDVERTEXDATABUFFER)GetProcAddress(hModule, "BindVertexDataBuffer");
//D_ASSERT(dooms::graphics::GraphicsAPI::BindVertexDataBuffer != nullptr);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "../graphicsAPISetting.h"
#include "../Input/GraphicsAPIInput.h"
#include "Game/ConfigData.h"

#include <EngineGUI/PrintText.h>

dooms::graphics::GraphicsAPILoader dooms::graphics::GraphicsAPIManager::mGraphicsAPILoader{};
void dooms::graphics::GraphicsAPIManager::LoadGraphicsAPI(const GraphicsAPI::eGraphicsAPIType graphicsAPIType)
Expand Down Expand Up @@ -67,21 +67,41 @@ void dooms::graphics::GraphicsAPIManager::GraphisAPIDebugCallBack(const char* co

bool dooms::graphics::GraphicsAPIManager::Initialize(const GraphicsAPI::eGraphicsAPIType graphicsAPIType)
{
LoadGraphicsAPI(graphicsAPIType);
if(GraphicsAPI::SetDebugFunction != nullptr)
if(graphicsAPIType != GraphicsAPI::eGraphicsAPIType::GraphicsAPIType_NONE)
{
GraphicsAPI::SetDebugFunction(dooms::graphics::GraphicsAPIManager::GraphisAPIDebugCallBack);
LoadGraphicsAPI(graphicsAPIType);
if (GraphicsAPI::SetDebugFunction != nullptr)
{
GraphicsAPI::SetDebugFunction(dooms::graphics::GraphicsAPIManager::GraphisAPIDebugCallBack);
}

switch (graphicsAPIType)
{
case GraphicsAPI::eGraphicsAPIType::OpenGL:
dooms::ui::PrintText("Initilize OPENGL");
break;
case GraphicsAPI::eGraphicsAPIType::DX11_10:
dooms::ui::PrintText("Initilize DIRECTX 11");
break;
default:
D_ASSERT(false);
return false;
}

unsigned int result = 1;
result &= GraphicsAPI::InitializeGraphicsAPI(graphicsAPISetting::GetScreenWidth(), graphicsAPISetting::GetScreenHeight(), graphicsAPISetting::GetMultiSamplingNum());
D_ASSERT_LOG(result == 1, "Fail to GraphicsAPI::InitializeGraphisAPIInput ( Error Code : %u )", result);

SetDefaultSettingOfAPI();
result &= input::GraphicsAPIInput::InitializeGraphisAPIInput(dooms::graphics::GraphicsAPI::GetPlatformWindow());
D_ASSERT(result == 1);

return result == 1;
}
else
{
return false;
}

unsigned int result = 1;
result &= GraphicsAPI::InitializeGraphicsAPI(graphicsAPISetting::GetScreenWidth(), graphicsAPISetting::GetScreenHeight(), graphicsAPISetting::GetMultiSamplingNum());
D_ASSERT_LOG(result == 1, "Fail to GraphicsAPI::InitializeGraphisAPIInput ( Error Code : %u )", result);

SetDefaultSettingOfAPI();
result &= input::GraphicsAPIInput::InitializeGraphisAPIInput(dooms::graphics::GraphicsAPI::GetPlatformWindow());
D_ASSERT(result == 1);

return result == 1;
}

bool dooms::graphics::GraphicsAPIManager::DeInitialize()
Expand Down
41 changes: 32 additions & 9 deletions Doom3/Source/Core/Graphics/Graphics_Server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,31 +34,54 @@

#include "Acceleration/LinearData_ViewFrustumCulling/CullingModule/MaskedSWOcclusionCulling/MaskedSWOcclusionCulling.h"

bool dooms::graphics::Graphics_Server::InitializeGraphicsAPI()

bool dooms::graphics::Graphics_Server::InitializeGraphicsAPI(GraphicsAPI::eGraphicsAPIType graphicsAPIType)
{
dooms::graphics::graphicsSetting::LoadData();
dooms::graphics::graphicsAPISetting::LoadData();

bool isSuccess = false;

const std::string targetGraphicsAPI = ConfigData::GetSingleton()->GetConfigData().GetValue<std::string>("Graphics", "GRAPHICS_API");
if (targetGraphicsAPI == "OPENGL")
if(graphicsAPIType == GraphicsAPI::eGraphicsAPIType::GraphicsAPIType_NONE)
{
isSuccess = GraphicsAPIManager::Initialize(GraphicsAPI::eGraphicsAPIType::OpenGL);
dooms::ui::PrintText("Read Target Graphics API from Config.ini file");

const std::string targetGraphicsAPI = ConfigData::GetSingleton()->GetConfigData().GetValue<std::string>("Graphics", "GRAPHICS_API");
if (targetGraphicsAPI == "OPENGL")
{
graphicsAPIType = GraphicsAPI::eGraphicsAPIType::OpenGL;
}
else if (targetGraphicsAPI == "DX11_10" || targetGraphicsAPI == "DX11")
{
graphicsAPIType = GraphicsAPI::eGraphicsAPIType::DX11_10;
}
else
{
D_ASSERT(false);
}
}
else if (targetGraphicsAPI == "DX11_10" || targetGraphicsAPI == "DX11")


switch (graphicsAPIType)
{
case GraphicsAPI::eGraphicsAPIType::OpenGL:
isSuccess = GraphicsAPIManager::Initialize(GraphicsAPI::eGraphicsAPIType::OpenGL);
break;
case GraphicsAPI::eGraphicsAPIType::DX11_10:
isSuccess = GraphicsAPIManager::Initialize(GraphicsAPI::eGraphicsAPIType::DX11_10);
}
else
{
break;
default:
dooms::ui::PrintText("Graphics API isn't chosen. Default Graphics API OPENGL is chosen.");
isSuccess = GraphicsAPIManager::Initialize(GraphicsAPI::eGraphicsAPIType::OpenGL); // If any specific api type isn't passed, just use opengl....
D_ASSERT(false);
}

D_ASSERT(isSuccess == true);

return isSuccess;
}

void dooms::graphics::Graphics_Server::Init()
void dooms::graphics::Graphics_Server::Init(const int argc, char* const* const argv)
{


Expand Down
6 changes: 3 additions & 3 deletions Doom3/Source/Core/Graphics/Graphics_Server.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,10 @@ namespace dooms
BVHAABB3D mRendererColliderBVH{ RENDERER_BVH_MAX_NODE_COUNT };

std::unique_ptr<culling::EveryCulling> mCullingSystem;

bool InitializeGraphicsAPI(GraphicsAPI::eGraphicsAPIType graphicsAPIType);

bool InitializeGraphicsAPI();

virtual void Init() final;
virtual void Init(const int argc, char* const* const argv) final;
virtual void LateInit() final;
virtual void Update() final;
virtual void OnEndOfFrame() final;
Expand Down
7 changes: 6 additions & 1 deletion Doom3/Source/Core/Graphics/Material/Material.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,12 @@ void dooms::graphics::Material::DestroyShaderFromMaterial(const dooms::graphics:
{
if(mPipeLineShaderView[shaderType].IsValid())
{
GraphicsAPI::DetachShaderFromMaterial(mPipeLineShaderView[shaderType], mProgramIDForOpenGL, mShaderAsset[shaderType]->GetShaderObject(shaderType));
GraphicsAPI::DetachShaderFromMaterial
(
mPipeLineShaderView[shaderType],
mProgramIDForOpenGL,
(IsValid(mShaderAsset[shaderType]) == true) ? static_cast<UINT64>(mShaderAsset[shaderType]->GetShaderObject(shaderType)) : static_cast<UINT64>(0)
);
mPipeLineShaderView[shaderType].Reset();
}
}
Expand Down
1 change: 1 addition & 0 deletions Doom3/Source/Core/Graphics/Texture/TextureView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ void TextureView::DestroyTextureViewObject()
if(mTextureViewObject.IsValid())
{
GraphicsAPI::DestroyTextureViewObject(mTextureViewObject);
mTextureViewObject.Reset();
}
}

Expand Down
2 changes: 1 addition & 1 deletion Doom3/Source/Core/IO/UserInput_Server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ void dooms::userinput::UserInput_Server::UpdateCurrentCursorScreenPosition()
void UserInput_Server::Update()
{}

void UserInput_Server::Init()
void UserInput_Server::Init(const int argc, char* const* const argv)
{
UserInput_Server::SetIsCursorVisible(ConfigData::GetSingleton()->GetConfigData().GetValue<bool>("USERINPUT", "CURSOR_IS_VISIBLE"));
UserInput_Server::SetIsCursorLockedInScreen(ConfigData::GetSingleton()->GetConfigData().GetValue<bool>("USERINPUT", "CURSOR_LOCKED_IN_SCREEN"));
Expand Down
2 changes: 1 addition & 1 deletion Doom3/Source/Core/IO/UserInput_Server.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ namespace dooms

UserInput_Server();

virtual void Init() final;
virtual void Init(const int argc, char* const* const argv) final;
virtual void Update() final;
virtual void UpdateInput() final;
virtual void OnEndOfFrame() final;
Expand Down
2 changes: 1 addition & 1 deletion Doom3/Source/Core/Memory/MemoryManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ void dooms::memory::MemoryManager::CheckIsIntelTBBLoaded() const
}
}

void dooms::memory::MemoryManager::Init()
void dooms::memory::MemoryManager::Init(const int argc, char* const* const argv)
{
CheckIsIntelTBBLoaded();
}
Expand Down
2 changes: 1 addition & 1 deletion Doom3/Source/Core/Memory/MemoryManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace dooms

public:

void Init() override;
void Init(const int argc, char* const* const argv) override;
void Update() override;
void OnEndOfFrame() override;
};
Expand Down
Loading