mirror of
https://github.com/jmarshall23/DoomRTX.git
synced 2026-08-16 00:01:53 +02:00
Raytracing backend now supports multiple worlds.
This commit is contained in:
@@ -51,10 +51,18 @@ idRenderEntityLocal::idRenderEntityLocal() {
|
||||
entityRefs = NULL;
|
||||
firstInteraction = NULL;
|
||||
lastInteraction = NULL;
|
||||
dxrBottomAccelStruct = 0;
|
||||
needsPortalSky = false;
|
||||
}
|
||||
|
||||
void idRenderEntityLocal::FreeRenderEntity() {
|
||||
void idRenderEntityLocal::FreeRenderEntity(glRaytracingSceneHandle_t sceneHandle) {
|
||||
if (dxrBottomAccelStruct != 0)
|
||||
{
|
||||
glRaytracingDeleteMesh(dxrBottomAccelStruct);
|
||||
glRaytracingDeleteInstanceInScene(sceneHandle, dxrTopAccelStruct);
|
||||
}
|
||||
|
||||
dxrBottomAccelStruct = 0;
|
||||
}
|
||||
|
||||
void idRenderEntityLocal::UpdateRenderEntity( const renderEntity_t *re, bool forceUpdate ) {
|
||||
|
||||
@@ -989,9 +989,9 @@ void idRenderSystemLocal::CaptureRenderToFile( const char *fileName, bool fixAlp
|
||||
AllocRenderWorld
|
||||
==============
|
||||
*/
|
||||
idRenderWorld *idRenderSystemLocal::AllocRenderWorld() {
|
||||
idRenderWorldLocal *rw;
|
||||
rw = new idRenderWorldLocal;
|
||||
idRenderWorld *idRenderSystemLocal::AllocRenderWorld(dxrWorldId_t worldId) {
|
||||
idRenderWorldLocal *rw = new idRenderWorldLocal(worldId);
|
||||
glRaytracingClearScene(rw->dxrWorldId);
|
||||
worlds.Append( rw );
|
||||
return rw;
|
||||
}
|
||||
|
||||
@@ -98,6 +98,17 @@ typedef struct glconfig_s {
|
||||
bool isInitialized;
|
||||
} glconfig_t;
|
||||
|
||||
//
|
||||
// dxrWorldId_t
|
||||
//
|
||||
enum dxrWorldId_t {
|
||||
DXR_WORLD_MAINMENU = 0,
|
||||
DXR_WORLD_GAME,
|
||||
DXR_WORLD_EDITOR,
|
||||
DXR_MATERIAL_PREVIEW,
|
||||
DXR_WIDGET_0,
|
||||
DXR_WORLD_NUM
|
||||
};
|
||||
|
||||
// font support
|
||||
const int GLYPH_START = 0;
|
||||
@@ -179,7 +190,7 @@ public:
|
||||
virtual int GetScreenHeight( void ) const = 0;
|
||||
|
||||
// allocate a renderWorld to be used for drawing
|
||||
virtual idRenderWorld * AllocRenderWorld( void ) = 0;
|
||||
virtual idRenderWorld * AllocRenderWorld( dxrWorldId_t worldId ) = 0;
|
||||
virtual void FreeRenderWorld( idRenderWorld * rw ) = 0;
|
||||
|
||||
// All data that will be used in a level should be
|
||||
|
||||
@@ -515,6 +515,12 @@ void R_InitOpenGL( void ) {
|
||||
// Reset our gamma
|
||||
R_SetColorMappings();
|
||||
|
||||
// Create the DXR worlds.
|
||||
for (int i = 0; i < DXR_WORLD_NUM; i++)
|
||||
{
|
||||
tr.dxrWorldHandles[i] = glRaytracingCreateScene();
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
static bool glCheck = false;
|
||||
if ( !glCheck && win32.osversion.dwMajorVersion == 6 ) {
|
||||
|
||||
@@ -125,10 +125,12 @@ void R_ListRenderEntityDefs_f( const idCmdArgs &args ) {
|
||||
idRenderWorldLocal::idRenderWorldLocal
|
||||
===================
|
||||
*/
|
||||
idRenderWorldLocal::idRenderWorldLocal() {
|
||||
idRenderWorldLocal::idRenderWorldLocal(dxrWorldId_t dxrWorldId) {
|
||||
mapName.Clear();
|
||||
mapTimeStamp = FILE_NOT_FOUND_TIMESTAMP;
|
||||
|
||||
this->dxrWorldId = tr.dxrWorldHandles[dxrWorldId];
|
||||
|
||||
generateAllInteractionsCalled = false;
|
||||
|
||||
areaNodes = NULL;
|
||||
@@ -285,7 +287,7 @@ void idRenderWorldLocal::UpdateEntityDef( qhandle_t entityHandle, const renderEn
|
||||
float dxrTransformMatrix[16];
|
||||
|
||||
RB_CopyModelMatrixToDXRTransform(def->modelMatrix, dxrTransformMatrix);
|
||||
glUpdateTopLevelAceelStructure(def->dxrBottomAccelStruct, dxrTransformMatrix, def->dxrTopAccelStruct);
|
||||
glUpdateTopLevelAceelStructure(dxrWorldId, def->dxrBottomAccelStruct, dxrTransformMatrix, def->dxrTopAccelStruct);
|
||||
}
|
||||
|
||||
def->lastModifiedFrameNum = tr.frameCount;
|
||||
@@ -340,6 +342,8 @@ void idRenderWorldLocal::FreeEntityDef( qhandle_t entityHandle ) {
|
||||
def->parms.gui[ 1 ] = NULL;
|
||||
def->parms.gui[ 2 ] = NULL;
|
||||
|
||||
def->FreeRenderEntity(dxrWorldId);
|
||||
|
||||
delete def;
|
||||
entityDefs[ entityHandle ] = NULL;
|
||||
}
|
||||
|
||||
@@ -43,6 +43,13 @@ void idRenderWorldLocal::FreeWorld() {
|
||||
// this will free all the lightDefs and entityDefs
|
||||
FreeDefs();
|
||||
|
||||
// clear the dxr models.
|
||||
glRaytracingClearScene(dxrWorldId);
|
||||
for (i = 0; i < worldDXRmodels.Num(); i++) {
|
||||
glRaytracingDeleteMesh(worldDXRmodels[i].dxrBottomAcel);
|
||||
}
|
||||
worldDXRmodels.Clear();
|
||||
|
||||
// free all the portals and check light/model references
|
||||
for ( i = 0 ; i < numPortalAreas ; i++ ) {
|
||||
portalArea_t *area;
|
||||
@@ -180,7 +187,7 @@ idRenderModel *idRenderWorldLocal::ParseModel( idLexer *src ) {
|
||||
idRenderModelStatic* modelStatic = (idRenderModelStatic*)model;
|
||||
dxrWorldModel_t dxrModel;
|
||||
modelStatic->UpdateDXR(dxrModel.dxrBottomAcel, model->NumSurfaces() - 1);
|
||||
glUpdateTopLevelAceelStructure(dxrModel.dxrBottomAcel, NULL, dxrModel.topAccelStruct);
|
||||
glUpdateTopLevelAceelStructure(dxrWorldId, dxrModel.dxrBottomAcel, NULL, dxrModel.topAccelStruct);
|
||||
worldDXRmodels.Append(dxrModel);
|
||||
}
|
||||
}
|
||||
@@ -499,7 +506,6 @@ bool idRenderWorldLocal::InitFromMap( const char *name ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// load it
|
||||
filename = name;
|
||||
filename.SetFileExtension( PROC_FILE_EXT );
|
||||
|
||||
@@ -81,7 +81,7 @@ struct dxrWorldModel_t {
|
||||
|
||||
class idRenderWorldLocal : public idRenderWorld {
|
||||
public:
|
||||
idRenderWorldLocal();
|
||||
idRenderWorldLocal(dxrWorldId_t dxrWorldId);
|
||||
virtual ~idRenderWorldLocal();
|
||||
|
||||
virtual qhandle_t AddEntityDef( const renderEntity_t *re );
|
||||
@@ -262,6 +262,7 @@ public:
|
||||
// tr_light.c
|
||||
void CreateLightDefInteractions( idRenderLightLocal *ldef );
|
||||
|
||||
glRaytracingSceneHandle_t dxrWorldId;
|
||||
idList<dxrWorldModel_t> worldDXRmodels;
|
||||
};
|
||||
|
||||
|
||||
@@ -50,6 +50,6 @@ void RB_DXDrawInteractions(void) {
|
||||
|
||||
|
||||
glFinish();
|
||||
glLightScene();
|
||||
glLightScene(backEnd.viewDef->renderWorld->dxrWorldId);
|
||||
glRaytracingLightingClearLights(false);
|
||||
}
|
||||
|
||||
@@ -1143,7 +1143,7 @@ idRenderModel *R_EntityDefDynamicModel( idRenderEntityLocal *def ) {
|
||||
float dxrTransformMatrix[16];
|
||||
staticMesh->UpdateDXR(def->dxrBottomAccelStruct);
|
||||
RB_CopyModelMatrixToDXRTransform(def->modelMatrix, dxrTransformMatrix);
|
||||
glUpdateTopLevelAceelStructure(def->dxrBottomAccelStruct, dxrTransformMatrix, def->dxrTopAccelStruct);
|
||||
glUpdateTopLevelAceelStructure(tr.primaryWorld->dxrWorldId, def->dxrBottomAccelStruct, dxrTransformMatrix, def->dxrTopAccelStruct);
|
||||
}
|
||||
|
||||
if ( def->cachedDynamicModel ) {
|
||||
|
||||
@@ -166,7 +166,7 @@ class idRenderEntity {
|
||||
public:
|
||||
virtual ~idRenderEntity() {}
|
||||
|
||||
virtual void FreeRenderEntity() = 0;
|
||||
virtual void FreeRenderEntity(glRaytracingSceneHandle_t sceneHandle) = 0;
|
||||
virtual void UpdateRenderEntity( const renderEntity_t *re, bool forceUpdate = false ) = 0;
|
||||
virtual void GetRenderEntity( renderEntity_t *re ) = 0;
|
||||
virtual void ForceUpdate() = 0;
|
||||
@@ -238,7 +238,7 @@ class idRenderEntityLocal : public idRenderEntity {
|
||||
public:
|
||||
idRenderEntityLocal();
|
||||
|
||||
virtual void FreeRenderEntity();
|
||||
virtual void FreeRenderEntity(glRaytracingSceneHandle_t sceneHandle);
|
||||
virtual void UpdateRenderEntity( const renderEntity_t *re, bool forceUpdate = false );
|
||||
virtual void GetRenderEntity( renderEntity_t *re );
|
||||
virtual void ForceUpdate();
|
||||
@@ -703,7 +703,7 @@ public:
|
||||
virtual bool IsFullScreen( void ) const;
|
||||
virtual int GetScreenWidth( void ) const;
|
||||
virtual int GetScreenHeight( void ) const;
|
||||
virtual idRenderWorld * AllocRenderWorld( void );
|
||||
virtual idRenderWorld * AllocRenderWorld(dxrWorldId_t worldId);
|
||||
virtual void FreeRenderWorld( idRenderWorld *rw );
|
||||
virtual void BeginLevelLoad( void );
|
||||
virtual void EndLevelLoad( void );
|
||||
@@ -734,7 +734,6 @@ public:
|
||||
virtual void UnCrop();
|
||||
virtual void GetCardCaps( bool &oldCard, bool &nv10or20 );
|
||||
virtual bool UploadImage( const char *imageName, const byte *data, int width, int height );
|
||||
|
||||
public:
|
||||
// internal functions
|
||||
idRenderSystemLocal( void );
|
||||
@@ -806,6 +805,8 @@ public:
|
||||
class idGuiModel * demoGuiModel;
|
||||
|
||||
unsigned short gammaTable[256]; // brightness / gamma modify this
|
||||
|
||||
glRaytracingSceneHandle_t dxrWorldHandles[dxrWorldId_t::DXR_WORLD_NUM];
|
||||
};
|
||||
|
||||
extern backEndState_t backEnd;
|
||||
|
||||
Reference in New Issue
Block a user