added main menus, improved shading
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
#include "tier1/commandline.h"
|
||||
|
||||
CUtlVector<CUtlString> engine_CompiledFiles = {
|
||||
"engine/interface.cpp",
|
||||
"engine/console.cpp",
|
||||
"engine/filesystem.cpp",
|
||||
"engine/server.cpp",
|
||||
|
||||
@@ -47,7 +47,12 @@ void CBrushEntity::Think( float fDelta )
|
||||
|
||||
};
|
||||
|
||||
void CBrushEntity::Sync( void *pData, uint32_t nDataSize )
|
||||
void CBrushEntity::SendToServer()
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
void CBrushEntity::RecieveFromServer( void *pData, uint32_t nDataSize )
|
||||
{
|
||||
|
||||
};
|
||||
@@ -149,6 +154,9 @@ void CBrushRendering::Init()
|
||||
|
||||
void CBrushRendering::Frame( float fDelta )
|
||||
{
|
||||
g_BrushPipeline->BindData(0, IRenderer::GetCameraMatrix(), 0);
|
||||
g_BrushPipeline->PushBindings();
|
||||
|
||||
IRenderer::ResetState();
|
||||
IRenderer::SetDepthMode(DEPTH_MODE_LESS);
|
||||
IRenderer::BindPipeline(g_BrushPipeline);
|
||||
@@ -160,8 +168,6 @@ void CBrushRendering::Frame( float fDelta )
|
||||
} constants;
|
||||
glm_mat4_identity(constants.i);
|
||||
IRenderer::SetConstants(sizeof(constants), &constants);
|
||||
IRenderer::BindData(0, IRenderer::GetCameraMatrix(), 0);
|
||||
IRenderer::PushBindings();
|
||||
for (auto &v: g_BrushVertices)
|
||||
{
|
||||
IRenderer::Draw(v, 0);
|
||||
|
||||
@@ -1,11 +1,65 @@
|
||||
#include "console.h"
|
||||
#include "fgui/rect.h"
|
||||
#include "fgui/widget.h"
|
||||
#include "fgui/label.h"
|
||||
#include "filesystem.h"
|
||||
#include "rendering.h"
|
||||
#include "tier1/utlstring.h"
|
||||
#include "tier1/utlvector.h"
|
||||
#include "stdarg.h"
|
||||
|
||||
CUtlVector<ConVar*> g_convars;
|
||||
CUtlVector<ConCommand*> g_commands;
|
||||
|
||||
enum EConsoleMessageType
|
||||
{
|
||||
CONSOLE_MESSAGE_TYPE_MESSAGE,
|
||||
CONSOLE_MESSAGE_TYPE_WARNING,
|
||||
CONSOLE_MESSAGE_TYPE_ERROR,
|
||||
};
|
||||
|
||||
struct ConsoleMessage_t
|
||||
{
|
||||
EConsoleMessageType type;
|
||||
CUtlString szMessage;
|
||||
};
|
||||
|
||||
uint32_t g_nNumConsoleMessages = 0;
|
||||
ConsoleMessage_t g_consoleLog[1024];
|
||||
|
||||
void Msg( const char* message )
|
||||
{
|
||||
printf(message);
|
||||
g_consoleLog[g_nNumConsoleMessages] = {CONSOLE_MESSAGE_TYPE_MESSAGE, message};
|
||||
g_nNumConsoleMessages = (g_nNumConsoleMessages+1)%1024;
|
||||
|
||||
}
|
||||
|
||||
void Warning( const char* message )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Error( const char* message )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void IConsole::Init()
|
||||
{
|
||||
}
|
||||
|
||||
void IConsole::Frame()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void IConsole::Deinit()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void IConsole::RegisterVar( ConVar *cvar )
|
||||
{
|
||||
g_convars.AppendTail(cvar);
|
||||
@@ -267,3 +321,63 @@ void IConsole_Exec( int argc, char **argv)
|
||||
}
|
||||
|
||||
ConCommand IConsole_ExecCmd("exec", IConsole_Exec);
|
||||
|
||||
class CConsoleGUI: public CFGUI_Widget
|
||||
{
|
||||
public:
|
||||
CConsoleGUI();
|
||||
virtual void Event( FGUI_Event_t event ) override;
|
||||
virtual void Draw() override;
|
||||
virtual void Frame() override;
|
||||
private:
|
||||
CFGUI_Rect *m_pBackground = 0;
|
||||
CFGUI_Label *m_pLog = 0;
|
||||
};
|
||||
|
||||
bool console_bDrawUI = false;
|
||||
|
||||
CConsoleGUI::CConsoleGUI()
|
||||
{
|
||||
m_pBackground = new CFGUI_Rect();
|
||||
m_pBackground->SetBoxColor(0.13, 0.13, 0.13, 1);
|
||||
m_pBackground->SetSize(200, 200);
|
||||
m_pBackground->SetParent(this);
|
||||
|
||||
m_pLog = new CFGUI_Label();
|
||||
m_pLog->SetFont("fonts/IBMPlexMono-Regular");
|
||||
m_pLog->SetLabel("CONSOLE");
|
||||
m_pLog->SetGlyphSize(24);
|
||||
m_pLog->SetParent(this);
|
||||
};
|
||||
|
||||
void CConsoleGUI::Event( FGUI_Event_t event )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CConsoleGUI::Draw()
|
||||
{
|
||||
SetPosition(20, 20);
|
||||
m_pBackground->SetSize(g_nWindowWidth-40, g_nWindowHeight-40);
|
||||
m_pBackground->SetSize(g_nWindowWidth-40, g_nWindowHeight-40);
|
||||
}
|
||||
|
||||
void CConsoleGUI::Frame()
|
||||
{
|
||||
SetVisibility(console_bDrawUI);
|
||||
}
|
||||
|
||||
void IConsoleUI::Init()
|
||||
{
|
||||
new CConsoleGUI;
|
||||
};
|
||||
|
||||
void IConsoleUI::SetVisibility( bool bIsVisisble )
|
||||
{
|
||||
console_bDrawUI = bIsVisisble;
|
||||
}
|
||||
|
||||
bool IConsoleUI::IsVisibile()
|
||||
{
|
||||
return console_bDrawUI;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
|
||||
#include "fgui/fgui.h"
|
||||
#include "input.h"
|
||||
#include "mainmenu.h"
|
||||
#include "networking.h"
|
||||
#include "tier0/network.h"
|
||||
#include "tier0/platform.h"
|
||||
@@ -99,7 +100,7 @@ void IEngine::Init()
|
||||
}
|
||||
if (!SteamAPI_Init())
|
||||
{
|
||||
V_printf("failed to init steam\n");
|
||||
Plat_FatalErrorFunc("failed to init steam\n");
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -116,12 +117,13 @@ void IEngine::Init()
|
||||
// Init IO
|
||||
IVideo::Init();
|
||||
IInput::Init();
|
||||
IInput::SetMouseMode(MOUSE_MODE_GAME);
|
||||
IInput::SetInputMode(INPUT_MODE_MENU);
|
||||
IFGUI::Init();
|
||||
};
|
||||
|
||||
INetworking::Init();
|
||||
|
||||
|
||||
// load game
|
||||
IServer::LoadGame("funnygame");
|
||||
|
||||
@@ -132,6 +134,10 @@ void IEngine::Init()
|
||||
// execute default config
|
||||
IConsole::AddCommand("exec default.cfg;");
|
||||
IConsole::Execute();
|
||||
|
||||
MainMenu()->Init();
|
||||
|
||||
IConsoleUI::Init();
|
||||
|
||||
};
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -146,6 +152,7 @@ void IEngine::Frame(float fDelta)
|
||||
INetworking::Frame();
|
||||
if (!ICommandLine::CheckParam("-dedicated"))
|
||||
{
|
||||
MainMenu()->Frame();
|
||||
IFGUI::Frame();
|
||||
IVideo::Frame(fDelta);
|
||||
}
|
||||
@@ -156,6 +163,7 @@ void IEngine::Frame(float fDelta)
|
||||
//-----------------------------------------------------------------------------
|
||||
void IEngine::Shutdown()
|
||||
{
|
||||
MainMenu()->Deinit();
|
||||
INetworking::Deinit();
|
||||
};
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "gamemode.h"
|
||||
#include "engine.h"
|
||||
#include "interface.h"
|
||||
#include "playerstart.h"
|
||||
#include "networking.h"
|
||||
|
||||
@@ -53,10 +54,29 @@ void CGameMode::RoundEnd( void )
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class CGameModeManager: public IGameModeManager
|
||||
{
|
||||
public:
|
||||
virtual void Init( void ) override;
|
||||
virtual void Frame( void ) override;
|
||||
virtual void Deinit( void ) override;
|
||||
|
||||
virtual void StartGameMode( const char *szName ) override;
|
||||
virtual const char *GetCurrentGameMode( void ) override;
|
||||
virtual CGameMode *GetCurrentGameModeClass( void ) override;
|
||||
virtual void RestartCurrentGameMode( void ) override;
|
||||
};
|
||||
|
||||
DECLARE_INTERFACE(GameModeManager, CGameModeManager);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void IGameModeManager::Init( void )
|
||||
void CGameModeManager::Init( void )
|
||||
{
|
||||
|
||||
}
|
||||
@@ -64,14 +84,22 @@ void IGameModeManager::Init( void )
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void IGameModeManager::Frame( void )
|
||||
void CGameModeManager::Frame( void )
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void CGameModeManager::Deinit( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Sets gamemode
|
||||
//-----------------------------------------------------------------------------
|
||||
void IGameModeManager::StartGameMode( const char *szName )
|
||||
void CGameModeManager::StartGameMode( const char *szName )
|
||||
{
|
||||
if (pCurrentMode)
|
||||
{
|
||||
@@ -93,7 +121,15 @@ void IGameModeManager::StartGameMode( const char *szName )
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
CGameMode *IGameModeManager::GetCurrentGameModeClass( void )
|
||||
const char *CGameModeManager::GetCurrentGameMode( void )
|
||||
{
|
||||
return szCurrentModeName;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
CGameMode *CGameModeManager::GetCurrentGameModeClass( void )
|
||||
{
|
||||
return pCurrentMode;
|
||||
}
|
||||
@@ -101,7 +137,7 @@ CGameMode *IGameModeManager::GetCurrentGameModeClass( void )
|
||||
//-----------------------------------------------------------------------------
|
||||
// Restarts the gamemode
|
||||
//-----------------------------------------------------------------------------
|
||||
void IGameModeManager::RestartCurrentGameMode( void )
|
||||
void CGameModeManager::RestartCurrentGameMode( void )
|
||||
{
|
||||
if (!pCurrentMode)
|
||||
return;
|
||||
|
||||
121
engine/input.cpp
121
engine/input.cpp
@@ -1,5 +1,6 @@
|
||||
#include "input.h"
|
||||
#include "console.h"
|
||||
#include "mainmenu.h"
|
||||
#include "tier0/lib.h"
|
||||
#include "tier1/commandline.h"
|
||||
#include "math3d.h"
|
||||
@@ -109,53 +110,124 @@ EInputKey IInput_StringToKey( char *psz )
|
||||
//-----------------------------------------------------------------------------
|
||||
void IInput::Init( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
CUtlVector<EInputMode> g_inputModeStack = {INPUT_MODE_GAME, INPUT_MODE_MENU};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Key event may have different different effects based on current input mode.
|
||||
//
|
||||
// GAME:
|
||||
// Generates command call when pressed the key. eg +forward; -left;
|
||||
// Just to be sure we put ; in the end of the command.
|
||||
// When user releases the key command event is not generated. But if the first
|
||||
// command contains + as first character ( in case of example +forward ), then
|
||||
// it fires -forward
|
||||
//
|
||||
// MENU:
|
||||
// Sends all event to FGUI. KEY_ESCAPE key makes leave the menu and get back to
|
||||
// the game.
|
||||
//
|
||||
// CONSOLE:
|
||||
// Works as permanent input field.
|
||||
//
|
||||
// INPUT FIELD:
|
||||
// Doesn't recieve any events except for KEY_ESCAPE and KEY_ENTER
|
||||
//-----------------------------------------------------------------------------
|
||||
void IInput::KeyEvent( EInputKey key, EKeyEventType event )
|
||||
{
|
||||
if (event == KEY_EVENT_TYPE_DOWN) {
|
||||
IConsole::AddCommand(g_bindings[key]);
|
||||
IConsole::AddCommand(";");
|
||||
}
|
||||
if (event == KEY_EVENT_TYPE_UP)
|
||||
if (event == KEY_EVENT_TYPE_DOWN && key == KEY_ESCAPE)
|
||||
{
|
||||
auto binding = IConsole::ParseCommandLine(g_bindings[key]);
|
||||
if (binding.GetSize()==0)
|
||||
return;
|
||||
if (binding[0].GetSize() == 0)
|
||||
return;
|
||||
if (binding[0][0].GetString()[0] == '+')
|
||||
if (g_inputModeStack.GetSize() == 1)
|
||||
{
|
||||
CUtlString command = binding[0][0];
|
||||
command.GetString()[0] = '-';
|
||||
IConsole::AddCommand(command);
|
||||
g_inputModeStack.AppendTail(INPUT_MODE_MENU);
|
||||
IInput::SetInputMode(INPUT_MODE_MENU);
|
||||
MainMenu()->SetVisibility(true);
|
||||
return;
|
||||
}
|
||||
if (IConsoleUI::IsVisibile())
|
||||
IConsoleUI::SetVisibility(false);
|
||||
IInput::SetInputMode(g_inputModeStack[g_inputModeStack.GetSize()-2]);
|
||||
g_inputModeStack.RemoveTail();
|
||||
|
||||
if (g_inputModeStack[g_inputModeStack.GetSize()-1] != INPUT_MODE_MENU)
|
||||
{
|
||||
V_printf("no menu\n");
|
||||
MainMenu()->SetVisibility(false);
|
||||
}
|
||||
return;
|
||||
};
|
||||
|
||||
if (event == KEY_EVENT_TYPE_DOWN && key == KEY_TILDE)
|
||||
{
|
||||
if (IConsoleUI::IsVisibile())
|
||||
{
|
||||
IInput::SetInputMode(g_inputModeStack[g_inputModeStack.GetSize()-2]);
|
||||
g_inputModeStack.RemoveTail();
|
||||
IConsoleUI::SetVisibility(false);
|
||||
} else
|
||||
{
|
||||
g_inputModeStack.AppendTail(INPUT_MODE_CONSOLE);
|
||||
IInput::SetInputMode(INPUT_MODE_CONSOLE);
|
||||
IConsoleUI::SetVisibility(true);
|
||||
}
|
||||
|
||||
return;
|
||||
};
|
||||
|
||||
if (event == KEY_EVENT_TYPE_DOWN && key == KEY_F11)
|
||||
{
|
||||
IConsole::AddCommand("exit;");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (g_inputModeStack[g_inputModeStack.GetSize()-1] == INPUT_MODE_GAME)
|
||||
{
|
||||
if (event == KEY_EVENT_TYPE_DOWN) {
|
||||
IConsole::AddCommand(g_bindings[key]);
|
||||
IConsole::AddCommand(";");
|
||||
}
|
||||
if (event == KEY_EVENT_TYPE_UP)
|
||||
{
|
||||
auto binding = IConsole::ParseCommandLine(g_bindings[key]);
|
||||
if (binding.GetSize()==0)
|
||||
return;
|
||||
if (binding[0].GetSize() == 0)
|
||||
return;
|
||||
if (binding[0][0].GetString()[0] == '+')
|
||||
{
|
||||
CUtlString command = binding[0][0];
|
||||
command.GetString()[0] = '-';
|
||||
IConsole::AddCommand(command);
|
||||
IConsole::AddCommand(";");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (g_inputModeStack[g_inputModeStack.GetSize()-1] == INPUT_MODE_MENU)
|
||||
{
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Axis events for the input devices such as mouse and controller.
|
||||
// Game needs to explicitly support all of the devices.
|
||||
//-----------------------------------------------------------------------------
|
||||
void IInput::AxisEvent( EInputAxis axis, float fValue )
|
||||
{
|
||||
if (axis == AXIS_MOUSE_X || axis == AXIS_MOUSE_Y)
|
||||
if (g_inputModeStack[g_inputModeStack.GetSize()-1] == INPUT_MODE_GAME)
|
||||
{
|
||||
g_bController = false;
|
||||
g_fAxisValues[axis] += fValue*3.09;
|
||||
}
|
||||
if (axis == AXIS_CONTROLLER_PITCH || axis == AXIS_CONTROLLER_YAW)
|
||||
{
|
||||
g_bController = true;
|
||||
g_fAxisModifiers[axis] = fValue*3.09;
|
||||
if (axis == AXIS_MOUSE_X || axis == AXIS_MOUSE_Y)
|
||||
{
|
||||
g_bController = false;
|
||||
g_fAxisValues[axis] += fValue*3.09;
|
||||
}
|
||||
if (axis == AXIS_CONTROLLER_PITCH || axis == AXIS_CONTROLLER_YAW)
|
||||
{
|
||||
g_bController = true;
|
||||
g_fAxisModifiers[axis] = fValue*3.09;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -173,7 +245,6 @@ void IInput::Frame( void )
|
||||
//-----------------------------------------------------------------------------
|
||||
void IInput::Deinit( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
7
engine/interface.cpp
Normal file
7
engine/interface.cpp
Normal file
@@ -0,0 +1,7 @@
|
||||
#include "interface.h"
|
||||
#include "tier0/lib.h"
|
||||
|
||||
|
||||
CInterfaceRegistry::CInterfaceRegistry( const char *szName, InterfaceRegistryFn pfn )
|
||||
{
|
||||
};
|
||||
@@ -115,11 +115,12 @@ void CMeshRendering::Init()
|
||||
|
||||
void CMeshRendering::Frame( float fDelta )
|
||||
{
|
||||
g_MeshPipeline->BindData(0, IRenderer::GetCameraMatrix(), 0);
|
||||
g_MeshPipeline->PushBindings();
|
||||
|
||||
IRenderer::ResetState();
|
||||
IRenderer::SetDepthMode(DEPTH_MODE_LESS);
|
||||
IRenderer::BindPipeline(g_MeshPipeline);
|
||||
IRenderer::BindData(0, IRenderer::GetCameraMatrix(), 0);
|
||||
IRenderer::PushBindings();
|
||||
for (auto &v: g_meshes)
|
||||
{
|
||||
CMeshInstance *pMesh = (CMeshInstance*)v;
|
||||
|
||||
@@ -51,14 +51,16 @@ MTL::PixelFormat g_swapchainFormat;
|
||||
// Other platforms
|
||||
#endif
|
||||
|
||||
void IInput::SetMouseMode( EMouseMode mode )
|
||||
void IInput::SetInputMode( EInputMode mode )
|
||||
{
|
||||
switch (mode)
|
||||
{
|
||||
case MOUSE_MODE_GAME:
|
||||
case INPUT_MODE_GAME:
|
||||
g_currentInputMode = INPUT_MODE_GAME;
|
||||
SDL_SetWindowRelativeMouseMode(g_window, true);
|
||||
return;
|
||||
default:
|
||||
g_currentInputMode = INPUT_MODE_MENU;
|
||||
SDL_SetWindowRelativeMouseMode(g_window, false);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -243,7 +243,7 @@ void INetworking::ProcessPacket( void *pData, uint32_t nSize, IIClient *pClient
|
||||
if (IsServer())
|
||||
{
|
||||
if (pClient->pBasePlayer)
|
||||
pClient->pBasePlayer->Sync(pData, nSize);
|
||||
pClient->pBasePlayer->RecieveFromServer(pData, nSize);
|
||||
}
|
||||
for (auto &client: g_clients)
|
||||
{
|
||||
@@ -251,7 +251,7 @@ void INetworking::ProcessPacket( void *pData, uint32_t nSize, IIClient *pClient
|
||||
{
|
||||
if (!client->pBasePlayer)
|
||||
return;
|
||||
client->pBasePlayer->Sync(pData, nSize);
|
||||
client->pBasePlayer->RecieveFromServer(pData, nSize);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -288,7 +288,7 @@ void INetworking::ProcessPacket( void *pData, uint32_t nSize, IIClient *pClient
|
||||
V_printf("PacketGameMode\n");
|
||||
if (nSize != sizeof(PacketGameMode_t))
|
||||
return;
|
||||
IGameModeManager::StartGameMode(pGameModePacket->szName);
|
||||
GameModeManager()->StartGameMode(pGameModePacket->szName);
|
||||
return;
|
||||
default:
|
||||
return;
|
||||
@@ -383,7 +383,7 @@ void INetworking::ClientConnectedCallback( SteamNetConnectionStatusChangedCallba
|
||||
};
|
||||
|
||||
|
||||
IGameModeManager::RestartCurrentGameMode();
|
||||
GameModeManager()->RestartCurrentGameMode();
|
||||
break;
|
||||
case k_ESteamNetworkingConnectionState_ClosedByPeer:
|
||||
case k_ESteamNetworkingConnectionState_ProblemDetectedLocally:
|
||||
|
||||
@@ -60,7 +60,7 @@ void IServer::Think( float fDelta )
|
||||
for (auto &entity: g_entities)
|
||||
{
|
||||
entity->Think(fTickrate);
|
||||
entity->Sync(0, 0);
|
||||
entity->SendToServer();
|
||||
}
|
||||
px_frame(px, fTickrate);
|
||||
INetworking::Frame();
|
||||
|
||||
@@ -9,7 +9,8 @@ public:
|
||||
virtual void ReadParameter( const char *szName, const char *szValue ) override;
|
||||
virtual void Destroy( void ) override;
|
||||
virtual void Think( float fDelta ) override;
|
||||
virtual void Sync( void *pData, uint32_t nDataSize ) override;
|
||||
virtual void SendToServer() override;
|
||||
virtual void RecieveFromServer( void *pData, uint32_t nDataSize ) override;
|
||||
};
|
||||
|
||||
void CLight::Precache()
|
||||
@@ -36,7 +37,12 @@ void CLight::Think( float fDelta )
|
||||
{
|
||||
};
|
||||
|
||||
void CLight::Sync( void *pData, uint32_t nDataSize )
|
||||
void CLight::SendToServer()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CLight::RecieveFromServer( void *pData, uint32_t nDataSize )
|
||||
{
|
||||
};
|
||||
|
||||
|
||||
@@ -61,7 +61,12 @@ void CPlayerStart::RoundStart(IIClient *pClient)
|
||||
pClient->pBasePlayer = pOwningPlayer;
|
||||
};
|
||||
|
||||
void CPlayerStart::Sync( void *pData, uint32_t nDataSize )
|
||||
void CPlayerStart::SendToServer()
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
void CPlayerStart::RecieveFromServer( void *pData, uint32_t nDataSize )
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
@@ -9,7 +9,8 @@ public:
|
||||
virtual void ReadParameter( const char *szName, const char *szValue ) override;
|
||||
virtual void Destroy( void ) override;
|
||||
virtual void Think( float fDelta ) override;
|
||||
virtual void Sync( void *pData, uint32_t nDataSize ) override;
|
||||
virtual void SendToServer() override;
|
||||
virtual void RecieveFromServer( void *pData, uint32_t nDataSize ) override;
|
||||
};
|
||||
|
||||
void CWorldSpawn::Precache()
|
||||
@@ -37,7 +38,12 @@ void CWorldSpawn::Think( float fDelta )
|
||||
CBrushEntity::Think(fDelta);
|
||||
}
|
||||
|
||||
void CWorldSpawn::Sync( void *pData, uint32_t nDataSize )
|
||||
void CWorldSpawn::SendToServer()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CWorldSpawn::RecieveFromServer( void *pData, uint32_t nDataSize )
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
@@ -28,6 +28,7 @@ class CVkImage: public IImage
|
||||
public:
|
||||
vk_image2d_t m_image = {};
|
||||
uint32_t m_usage;
|
||||
VkImageLayout m_currentLayout;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -42,6 +42,7 @@ IImage *g_meshDepth;
|
||||
IImage *g_meshDepthMSAA;
|
||||
IImage *g_meshColor;
|
||||
IImage *g_meshColorMSAA;
|
||||
|
||||
class CVkGraphicsPipeline: public IGraphicsPipeline
|
||||
{
|
||||
public:
|
||||
@@ -55,8 +56,76 @@ public:
|
||||
|
||||
CUtlVector<ShaderInput_t> m_inputs;
|
||||
|
||||
virtual void PushBindings() override;
|
||||
virtual void BindData( uint32_t binding, IBuffer *pBuffer, IImage* pImage) override;
|
||||
};
|
||||
|
||||
void CVkGraphicsPipeline::BindData( uint32_t binding, IBuffer *pBuffer, IImage* pImage)
|
||||
{
|
||||
CVkBuffer* pVkBuffer = (CVkBuffer*)pBuffer;
|
||||
VkDescriptorBufferInfo dbi;
|
||||
for (auto &input: m_inputs)
|
||||
{
|
||||
if (input.binding != binding)
|
||||
continue;
|
||||
|
||||
switch (input.type)
|
||||
{
|
||||
case SHADER_INPUT_TYPE_STORAGE_BUFFER:
|
||||
case SHADER_INPUT_TYPE_UNIFORM_BUFFER:
|
||||
if (!pBuffer)
|
||||
Plat_FatalErrorFunc("pBuffer is NULL\n");
|
||||
if (m_writes[binding].pBufferInfo)
|
||||
V_free((void*)m_writes[binding].pBufferInfo);
|
||||
dbi = {
|
||||
.buffer = pVkBuffer->m_buffer.m_buffer,
|
||||
.offset = 0,
|
||||
.range = pVkBuffer->m_buffer.m_nSize,
|
||||
};
|
||||
m_writes[binding].pBufferInfo = (VkDescriptorBufferInfo*)V_malloc(sizeof(VkDescriptorBufferInfo));
|
||||
V_memcpy((void*)m_writes[binding].pBufferInfo, &dbi, sizeof(VkDescriptorBufferInfo));
|
||||
break;
|
||||
case SHADER_INPUT_TYPE_IMAGE:
|
||||
break;
|
||||
case SHADER_INPUT_TYPE_TLAS:
|
||||
break;
|
||||
case SHADER_INPUT_TYPE_TEXTURES:
|
||||
break;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CVkGraphicsPipeline::PushBindings()
|
||||
{
|
||||
CUtlVector<VkDescriptorImageInfo> textures;
|
||||
textures.Reserve(g_textures.GetSize());
|
||||
for (ITexture *t: g_textures)
|
||||
{
|
||||
CVkTexture *texture = (CVkTexture*)t;
|
||||
VkDescriptorImageInfo image = {};
|
||||
image.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
|
||||
image.imageView = texture->image.m_imageView;
|
||||
image.sampler = g_invalidTextureSampler;
|
||||
textures.AppendTail(image);
|
||||
};
|
||||
|
||||
for ( int i = 0; i < m_inputs.GetSize(); i++ )
|
||||
{
|
||||
if (m_inputs[i].type == SHADER_INPUT_TYPE_TEXTURES)
|
||||
{
|
||||
m_writes[i].descriptorCount = textures.GetSize();
|
||||
m_writes[i].pImageInfo = textures.GetData();
|
||||
}
|
||||
}
|
||||
textures[0].sampler = g_invalidTextureSampler;
|
||||
|
||||
vkUpdateDescriptorSets(g_vkDevice, m_writes.GetSize(), m_writes.GetData(), 0, NULL);
|
||||
}
|
||||
|
||||
|
||||
|
||||
class CVkComputePipeline: public IComputePipeline
|
||||
{
|
||||
public:
|
||||
@@ -146,8 +215,8 @@ void IVulkan::Init()
|
||||
vkGetPhysicalDeviceProperties(g_vkPhysicalDevice, &properties);
|
||||
VkSamplerCreateInfo samplerInfo{};
|
||||
samplerInfo.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO;
|
||||
samplerInfo.magFilter = VK_FILTER_NEAREST;
|
||||
samplerInfo.minFilter = VK_FILTER_NEAREST;
|
||||
samplerInfo.magFilter = VK_FILTER_LINEAR;
|
||||
samplerInfo.minFilter = VK_FILTER_LINEAR;
|
||||
samplerInfo.addressModeU = VK_SAMPLER_ADDRESS_MODE_REPEAT;
|
||||
samplerInfo.addressModeV = VK_SAMPLER_ADDRESS_MODE_REPEAT;
|
||||
samplerInfo.addressModeW = VK_SAMPLER_ADDRESS_MODE_REPEAT;
|
||||
@@ -216,7 +285,7 @@ void IVulkan::Frame()
|
||||
|
||||
for (auto &step: g_StepPrepass)
|
||||
step.pPipeline->Frame(0);
|
||||
IRenderer::Barrier(BARRIER_STAGE_TOP, BARRIER_STAGE_COLOR_OUTPUT, {}, {
|
||||
IRenderer::Barrier(BARRIER_STAGE_TOP, BARRIER_STAGE_COLOR_OUTPUT | BARRIER_STAGE_DEPTH_OUTPUT, {}, {
|
||||
{
|
||||
.in = BARRIER_MEMORY_PERMISSIONS_NONE,
|
||||
.out = BARRIER_MEMORY_PERMISSIONS_COLOR_WRITE,
|
||||
@@ -250,17 +319,22 @@ void IVulkan::Frame()
|
||||
step.pPipeline->Frame(0);
|
||||
}
|
||||
IRenderer::End();
|
||||
IRenderer::Barrier(BARRIER_STAGE_COLOR_OUTPUT, BARRIER_STAGE_BOTTOM, {}, {
|
||||
{
|
||||
.in = BARRIER_MEMORY_PERMISSIONS_COLOR_WRITE,
|
||||
.out = BARRIER_MEMORY_PERMISSIONS_COPY_READ,
|
||||
.pImage = g_meshColor,
|
||||
},
|
||||
IRenderer::Barrier(BARRIER_STAGE_DEPTH_OUTPUT, BARRIER_STAGE_BOTTOM, {}, {
|
||||
{
|
||||
.in = BARRIER_MEMORY_PERMISSIONS_DEPTH_WRITE,
|
||||
.out = BARRIER_MEMORY_PERMISSIONS_NONE,
|
||||
.pImage = g_meshDepth,
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
IRenderer::Barrier(BARRIER_STAGE_COLOR_OUTPUT, BARRIER_STAGE_BLIT, {}, {
|
||||
{
|
||||
|
||||
.in = BARRIER_MEMORY_PERMISSIONS_COLOR_WRITE,
|
||||
.out = BARRIER_MEMORY_PERMISSIONS_COPY_READ,
|
||||
.pImage = g_meshColor,
|
||||
},
|
||||
{
|
||||
.in = BARRIER_MEMORY_PERMISSIONS_NONE,
|
||||
.out = BARRIER_MEMORY_PERMISSIONS_COPY_WRITE,
|
||||
@@ -290,12 +364,32 @@ void IVulkan::Frame()
|
||||
1, &imageCopyRegion,
|
||||
VK_FILTER_NEAREST
|
||||
);
|
||||
IRenderer::Barrier(BARRIER_STAGE_BLIT, BARRIER_STAGE_COLOR_OUTPUT, {},
|
||||
{
|
||||
{
|
||||
|
||||
.in = BARRIER_MEMORY_PERMISSIONS_COPY_WRITE,
|
||||
.out = BARRIER_MEMORY_PERMISSIONS_COLOR_WRITE | BARRIER_MEMORY_PERMISSIONS_COLOR_READ,
|
||||
.pImage = IRenderer::GetOutputImage(),
|
||||
}
|
||||
}
|
||||
);
|
||||
for (auto &step: g_StepShading)
|
||||
step.pPipeline->Frame(0);
|
||||
for (auto &step: g_StepPostProcessing)
|
||||
step.pPipeline->Frame(0);
|
||||
for (auto &step: g_StepUI)
|
||||
step.pPipeline->Frame(0);
|
||||
step.pPipeline->Frame(0);
|
||||
IRenderer::Barrier(BARRIER_STAGE_COLOR_OUTPUT, BARRIER_STAGE_IMAGE_OUPUT, {},
|
||||
{
|
||||
{
|
||||
|
||||
.in = BARRIER_MEMORY_PERMISSIONS_COLOR_WRITE,
|
||||
.out = 0,
|
||||
.pImage = IRenderer::GetOutputImage(),
|
||||
}
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
void vk_shader_t::Create( const char *szPath, VkShaderStageFlagBits shaderStage )
|
||||
@@ -428,7 +522,14 @@ void vk_tripipeline_t::Create(
|
||||
.primitiveRestartEnable = VK_TRUE,
|
||||
};
|
||||
VkPipelineColorBlendAttachmentState pcbas = {
|
||||
.blendEnable = VK_FALSE,
|
||||
.blendEnable = VK_TRUE,
|
||||
.srcColorBlendFactor = VK_BLEND_FACTOR_SRC_ALPHA,
|
||||
.dstColorBlendFactor = VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA,
|
||||
.colorBlendOp = VK_BLEND_OP_ADD,
|
||||
|
||||
.srcAlphaBlendFactor = VK_BLEND_FACTOR_ONE,
|
||||
.dstAlphaBlendFactor = VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA,
|
||||
.alphaBlendOp = VK_BLEND_OP_ADD,
|
||||
.colorWriteMask = VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT | VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT,
|
||||
};
|
||||
|
||||
@@ -873,16 +974,21 @@ void IRenderer::Barrier( uint32_t stageIn, uint32_t stageOut, CUtlVector<BufferB
|
||||
if (stageIn & BARRIER_STAGE_GEOMETRY_SHADER) psfSrc |= VK_PIPELINE_STAGE_GEOMETRY_SHADER_BIT;
|
||||
if (stageIn & BARRIER_STAGE_FRAGMENT_SHADER) psfSrc |= VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT;
|
||||
if (stageIn & BARRIER_STAGE_COLOR_OUTPUT) psfSrc |= VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
|
||||
if (stageIn & BARRIER_STAGE_DEPTH_OUTPUT) psfSrc |= VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT;
|
||||
if (stageIn & BARRIER_STAGE_RAY_TRACING_SHADER) psfSrc |= VK_PIPELINE_STAGE_RAY_TRACING_SHADER_BIT_KHR;
|
||||
if (stageIn & BARRIER_STAGE_BOTTOM) psfSrc |= VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT;
|
||||
if (stageIn & BARRIER_STAGE_BLIT) psfSrc |= VK_PIPELINE_STAGE_TRANSFER_BIT;
|
||||
if (stageIn & BARRIER_STAGE_COPY) psfSrc |= VK_PIPELINE_STAGE_TRANSFER_BIT;
|
||||
if (stageOut & BARRIER_STAGE_TOP) psfDst |= VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT;
|
||||
if (stageOut & BARRIER_STAGE_VERTEX_INPUT) psfDst |= VK_PIPELINE_STAGE_VERTEX_INPUT_BIT;
|
||||
if (stageOut & BARRIER_STAGE_VERTEX_SHADER) psfDst |= VK_PIPELINE_STAGE_VERTEX_SHADER_BIT;
|
||||
if (stageOut & BARRIER_STAGE_GEOMETRY_SHADER) psfDst |= VK_PIPELINE_STAGE_GEOMETRY_SHADER_BIT;
|
||||
if (stageOut & BARRIER_STAGE_FRAGMENT_SHADER) psfDst |= VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT;
|
||||
if (stageOut & BARRIER_STAGE_COLOR_OUTPUT) psfDst |= VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
|
||||
if (stageOut & BARRIER_STAGE_DEPTH_OUTPUT) psfDst |= VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT;
|
||||
if (stageOut & BARRIER_STAGE_RAY_TRACING_SHADER) psfDst |= VK_PIPELINE_STAGE_RAY_TRACING_SHADER_BIT_KHR;
|
||||
if (stageOut & BARRIER_STAGE_BOTTOM) psfDst |= VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT;
|
||||
if (stageOut & BARRIER_STAGE_BLIT) psfDst |= VK_PIPELINE_STAGE_TRANSFER_BIT;
|
||||
if (stageOut & BARRIER_STAGE_IMAGE_OUPUT) psfDst |= VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT;
|
||||
|
||||
CUtlVector<VkImageMemoryBarrier> imb = {};
|
||||
CUtlVector<VkBufferMemoryBarrier> bmb = {};
|
||||
@@ -923,86 +1029,45 @@ void IRenderer::Barrier( uint32_t stageIn, uint32_t stageOut, CUtlVector<BufferB
|
||||
.layerCount = 1,
|
||||
};
|
||||
b.subresourceRange = isr;
|
||||
b.oldLayout = pVkImage->m_currentLayout;
|
||||
if (pVkImage->m_usage == IMAGE_USAGE_COLOR_ATTACHMENT)
|
||||
{
|
||||
b.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
|
||||
b.newLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
|
||||
}
|
||||
if (pVkImage->m_usage == IMAGE_USAGE_DEPTH_ATTACHMENT)
|
||||
{
|
||||
b.oldLayout = VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL;
|
||||
b.newLayout = VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL;
|
||||
}
|
||||
b.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
|
||||
b.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
|
||||
switch (image.in)
|
||||
{
|
||||
case BARRIER_MEMORY_PERMISSIONS_COLOR_READ: b.srcAccessMask = VK_ACCESS_COLOR_ATTACHMENT_READ_BIT; break;
|
||||
case BARRIER_MEMORY_PERMISSIONS_COLOR_WRITE: b.srcAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT; break;
|
||||
case BARRIER_MEMORY_PERMISSIONS_DEPTH_READ: b.srcAccessMask = VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT; break;
|
||||
case BARRIER_MEMORY_PERMISSIONS_DEPTH_WRITE: b.srcAccessMask = VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT; break;
|
||||
default:
|
||||
break;
|
||||
};
|
||||
switch (image.out)
|
||||
{
|
||||
case BARRIER_MEMORY_PERMISSIONS_COLOR_READ: b.dstAccessMask = VK_ACCESS_COLOR_ATTACHMENT_READ_BIT; break;
|
||||
case BARRIER_MEMORY_PERMISSIONS_COLOR_WRITE: b.dstAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT; break;
|
||||
case BARRIER_MEMORY_PERMISSIONS_DEPTH_READ: b.dstAccessMask = VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT; break;
|
||||
case BARRIER_MEMORY_PERMISSIONS_DEPTH_WRITE: b.dstAccessMask = VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT; break;
|
||||
default:
|
||||
break;
|
||||
};
|
||||
|
||||
if (image.in & BARRIER_MEMORY_PERMISSIONS_COLOR_READ) b.srcAccessMask |= VK_ACCESS_COLOR_ATTACHMENT_READ_BIT;
|
||||
if (image.in & BARRIER_MEMORY_PERMISSIONS_COLOR_WRITE) b.srcAccessMask |= VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
|
||||
if (image.in & BARRIER_MEMORY_PERMISSIONS_DEPTH_READ) b.srcAccessMask |= VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT;
|
||||
if (image.in & BARRIER_MEMORY_PERMISSIONS_DEPTH_WRITE) b.srcAccessMask |= VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT;
|
||||
if (image.in & BARRIER_MEMORY_PERMISSIONS_COPY_READ) b.srcAccessMask |= VK_ACCESS_TRANSFER_READ_BIT;
|
||||
if (image.in & BARRIER_MEMORY_PERMISSIONS_COPY_WRITE) b.srcAccessMask |= VK_ACCESS_TRANSFER_WRITE_BIT;
|
||||
if (image.in & BARRIER_MEMORY_PERMISSIONS_BLIT_READ) b.srcAccessMask |= VK_ACCESS_TRANSFER_READ_BIT;
|
||||
if (image.in & BARRIER_MEMORY_PERMISSIONS_BLIT_WRITE) b.srcAccessMask |= VK_ACCESS_TRANSFER_WRITE_BIT;
|
||||
|
||||
|
||||
if (image.out & BARRIER_MEMORY_PERMISSIONS_COLOR_READ) b.dstAccessMask |= VK_ACCESS_COLOR_ATTACHMENT_READ_BIT;
|
||||
if (image.out & BARRIER_MEMORY_PERMISSIONS_COLOR_WRITE) b.dstAccessMask |= VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
|
||||
if (image.out & BARRIER_MEMORY_PERMISSIONS_DEPTH_READ) b.dstAccessMask |= VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT;
|
||||
if (image.out & BARRIER_MEMORY_PERMISSIONS_DEPTH_WRITE) b.dstAccessMask |= VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT;
|
||||
if (image.out & BARRIER_MEMORY_PERMISSIONS_COPY_READ) { b.dstAccessMask |= VK_ACCESS_TRANSFER_READ_BIT; b.newLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; }
|
||||
if (image.out & BARRIER_MEMORY_PERMISSIONS_COPY_WRITE) { b.dstAccessMask |= VK_ACCESS_TRANSFER_WRITE_BIT; b.newLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL; }
|
||||
if (image.out & BARRIER_MEMORY_PERMISSIONS_BLIT_READ) { b.dstAccessMask |= VK_ACCESS_TRANSFER_READ_BIT; b.newLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; }
|
||||
if (image.out & BARRIER_MEMORY_PERMISSIONS_BLIT_WRITE) { b.dstAccessMask |= VK_ACCESS_TRANSFER_WRITE_BIT; b.newLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL; }
|
||||
|
||||
if (stageOut & BARRIER_STAGE_IMAGE_OUPUT) b.newLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR;
|
||||
pVkImage->m_currentLayout = b.newLayout;
|
||||
imb.AppendTail(b);
|
||||
}
|
||||
|
||||
vkCmdPipelineBarrier(g_vkCommandBuffer, psfSrc, psfDst, 0, 0, 0, bmb.GetSize(), bmb.GetData(), imb.GetSize(), imb.GetData());
|
||||
}
|
||||
|
||||
void IRenderer::BindData( uint32_t binding, IBuffer *pBuffer, IImage* pImage)
|
||||
{
|
||||
if (!g_pCurrentPipeline)
|
||||
return;
|
||||
if (g_pCurrentPipeline->type == PIPELINE_TYPE_RASTERIZATION)
|
||||
{
|
||||
CVkGraphicsPipeline *pVkPipeline = (CVkGraphicsPipeline*)g_pCurrentPipeline;
|
||||
CVkBuffer* pVkBuffer = (CVkBuffer*)pBuffer;
|
||||
VkDescriptorBufferInfo dbi;
|
||||
for (auto &input: pVkPipeline->m_inputs)
|
||||
{
|
||||
if (input.binding != binding)
|
||||
continue;
|
||||
|
||||
switch (input.type)
|
||||
{
|
||||
case SHADER_INPUT_TYPE_STORAGE_BUFFER:
|
||||
case SHADER_INPUT_TYPE_UNIFORM_BUFFER:
|
||||
if (!pBuffer)
|
||||
Plat_FatalErrorFunc("pBuffer is NULL\n");
|
||||
if (pVkPipeline->m_writes[binding].pBufferInfo)
|
||||
V_free((void*)pVkPipeline->m_writes[binding].pBufferInfo);
|
||||
dbi = {
|
||||
.buffer = pVkBuffer->m_buffer.m_buffer,
|
||||
.offset = 0,
|
||||
.range = pVkBuffer->m_buffer.m_nSize,
|
||||
};
|
||||
pVkPipeline->m_writes[binding].pBufferInfo = (VkDescriptorBufferInfo*)V_malloc(sizeof(VkDescriptorBufferInfo));
|
||||
V_memcpy((void*)pVkPipeline->m_writes[binding].pBufferInfo, &dbi, sizeof(VkDescriptorBufferInfo));
|
||||
break;
|
||||
case SHADER_INPUT_TYPE_IMAGE:
|
||||
break;
|
||||
case SHADER_INPUT_TYPE_TLAS:
|
||||
break;
|
||||
case SHADER_INPUT_TYPE_TEXTURES:
|
||||
break;
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void IRenderer::BindPipeline( IPipeline *pPipeline )
|
||||
{
|
||||
if (!pPipeline)
|
||||
@@ -1012,44 +1077,10 @@ void IRenderer::BindPipeline( IPipeline *pPipeline )
|
||||
CVkGraphicsPipeline *pVkPipeline = (CVkGraphicsPipeline*)pPipeline;
|
||||
|
||||
vkCmdBindPipeline(g_vkCommandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pVkPipeline->m_pipeline.m_pipeline);
|
||||
vkCmdBindDescriptorSets(g_vkCommandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pVkPipeline->m_pipeline.m_layout, 0, 1, &pVkPipeline->m_descriptorSet, 0, NULL);
|
||||
}
|
||||
g_pCurrentPipeline = pPipeline;
|
||||
}
|
||||
void IRenderer::PushBindings()
|
||||
{
|
||||
|
||||
if (!g_pCurrentPipeline)
|
||||
return;
|
||||
if (g_pCurrentPipeline->type == PIPELINE_TYPE_RASTERIZATION)
|
||||
{
|
||||
CVkGraphicsPipeline *pVkPipeline = (CVkGraphicsPipeline*)g_pCurrentPipeline;
|
||||
|
||||
CUtlVector<VkDescriptorImageInfo> textures;
|
||||
textures.Reserve(g_textures.GetSize());
|
||||
for (ITexture *t: g_textures)
|
||||
{
|
||||
CVkTexture *texture = (CVkTexture*)t;
|
||||
VkDescriptorImageInfo image = {};
|
||||
image.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
|
||||
image.imageView = texture->image.m_imageView;
|
||||
image.sampler = g_invalidTextureSampler;
|
||||
textures.AppendTail(image);
|
||||
};
|
||||
|
||||
for ( int i = 0; i < pVkPipeline->m_inputs.GetSize(); i++ )
|
||||
{
|
||||
if (pVkPipeline->m_inputs[i].type == SHADER_INPUT_TYPE_TEXTURES)
|
||||
{
|
||||
pVkPipeline->m_writes[i].descriptorCount = textures.GetSize();
|
||||
pVkPipeline->m_writes[i].pImageInfo = textures.GetData();
|
||||
}
|
||||
}
|
||||
textures[0].sampler = g_invalidTextureSampler;
|
||||
|
||||
vkUpdateDescriptorSets(g_vkDevice, pVkPipeline->m_writes.GetSize(), pVkPipeline->m_writes.GetData(), 0, NULL);
|
||||
vkCmdBindDescriptorSets(g_vkCommandBuffer,VK_PIPELINE_BIND_POINT_GRAPHICS, pVkPipeline->m_pipeline.m_layout, 0, 1, &pVkPipeline->m_descriptorSet, 0, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void IRenderer::Begin( uint32_t nWidth, uint32_t nHeight, CUtlVector<RenderingColorAttachment_t> attachments, RenderingDepthAttachment_t depth )
|
||||
@@ -1257,6 +1288,7 @@ IGraphicsPipeline *IRenderer::CreateGraphicsPipeline(
|
||||
allocInfo.descriptorSetCount = 1;
|
||||
allocInfo.pSetLayouts = &pipeline->m_pipeline.m_descriptorSetLayout;
|
||||
vkAllocateDescriptorSets(g_vkDevice, &allocInfo, &pipeline->m_descriptorSet);
|
||||
V_printf("Created %p\n",pipeline->m_descriptorSet);
|
||||
|
||||
pipeline->m_writes = {};
|
||||
for (auto &input: inputs)
|
||||
|
||||
@@ -204,6 +204,8 @@ EInputKey ISDL_KeyName(SDL_Keycode key)
|
||||
case SDLK_RALT: return KEY_ALT;
|
||||
case SDLK_LALT: return KEY_ALT;
|
||||
case SDLK_SPACE: return KEY_SPACE;
|
||||
|
||||
case SDLK_GRAVE: return KEY_TILDE;
|
||||
|
||||
case SDLK_F1: return KEY_F1;
|
||||
case SDLK_F2: return KEY_F2;
|
||||
@@ -414,15 +416,20 @@ void IVideo::Init()
|
||||
IVulkan::Init();
|
||||
}
|
||||
|
||||
void IInput::SetMouseMode( EMouseMode mode )
|
||||
void IInput::SetInputMode( EInputMode mode )
|
||||
{
|
||||
switch (mode)
|
||||
{
|
||||
case MOUSE_MODE_GAME:
|
||||
case INPUT_MODE_GAME:
|
||||
SDL_SetWindowRelativeMouseMode(g_window, true);
|
||||
return;
|
||||
case INPUT_MODE_MENU:
|
||||
SDL_SetWindowRelativeMouseMode(g_window, false);
|
||||
return;
|
||||
case INPUT_MODE_CONSOLE:
|
||||
SDL_SetWindowRelativeMouseMode(g_window, true);
|
||||
return;
|
||||
default:
|
||||
SDL_SetWindowRelativeMouseMode(g_window, false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user