allow device change at any time

This commit is contained in:
myT 2023-08-05 02:17:00 +02:00
parent fd035c0f70
commit d1912ba929
4 changed files with 18 additions and 4 deletions

View file

@ -193,7 +193,7 @@ void RenderPassStats::EndFrame(uint32_t cpu, uint32_t gpu)
void GRP::Init()
{
RHI::Init();
firstInit = RHI::Init();
if(firstInit)
{

View file

@ -133,6 +133,11 @@ static void UpdateEntityData(bool& depthHack, int entityNum, double originalTime
void World::Init()
{
if(grp.firstInit)
{
fogDescriptorTable = RHI_MAKE_NULL_HANDLE();
}
{
TextureDesc desc("depth buffer", glConfig.vidWidth, glConfig.vidHeight);
desc.committedResource = true;

View file

@ -2329,7 +2329,7 @@ namespace RHI
}
}
void Init()
bool Init()
{
Sys_V_Init();
@ -2417,7 +2417,7 @@ namespace RHI
rhi.vsync = vsync;
return;
return false;
}
// @NOTE: we can't use memset because of the StaticPool members
@ -2761,12 +2761,21 @@ namespace RHI
glInfo.depthFadeSupport = qfalse;
rhi.initialized = true;
return true;
}
void ShutDown(bool destroyWindow)
{
#define DESTROY_POOL(Name, Func) DestroyPool(rhi.Name, &Func, !!destroyWindow);
if(!destroyWindow &&
r_gpuPreference->latchedString != NULL &&
Q_stricmp(r_gpuPreference->latchedString, r_gpuPreference->string) != 0)
{
destroyWindow = true;
}
if(rhi.frameBegun)
{
backEnd.renderFrame = qfalse;

View file

@ -676,7 +676,7 @@ namespace RHI
const ShaderMacro* macros = NULL;
};
void Init();
bool Init(); // true when a full init happened (the device was created)
void ShutDown(bool destroyWindow);
void BeginFrame();