Software Startup
As you may know, HOOPS Luminate is a hybrid rendering engine: it can run and display data using the system’s graphic adapter (GPU) or it can run without using it and display data using a pure software (CPU) rendering mode. To quickly dive into the topic, HOOPS Luminate can be started in one or the other mode using the code sample below:
Hardware or Software Startup
HOOPS Luminate has three different rendering modes:
0: Hardware only mode. This rendering mode only uses the GPU for the display. It’s suitable for any real-time only application.
1: Hybrid mode: The engine can use hardware rendering or software rendering at will. It’s mostly used for applications that do both data setup and high quality renderings.
2: Software mode: The engine only renders in software. It’s used mostly for rendering applications.
// Create our resource manager:
RED::Object* resmgr = RED::Factory::CreateInstance( CID_REDResourceManager );
// Access its main interface:
RED::IResourceManager* iresmgr = resmgr->As< RED::IResourceManager >();
// Access its option interface:
RED::IOptions* iresopt = resmgr->As< RED::IOptions >();
// 0: hardware; 1: hybrid; 2: full software. Here, for instance, let's start in hybrid mode:
RC_TEST( iresopt->SetOptionValue( RED::OPTIONS_RAY_ENABLE_SOFT_TRACER, 1, iresmgr->GetState() ) );
The hardware mode will use the video memory (and the RAM used by the video card driver) to store application graphic data. The hybrid mode will use both the video memory and the RAM to store application graphic data. Textures are stored in the CPU RAM and in the video memory. The software mode will use the RAM to store application graphic data.
Then, if a problem arise during the first startup procedure (for instance, if the graphics hardware is not supported), then the following procedure can be set to restart HOOPS Luminate in software mode instead of the hardware mode:
Software Restart After Failure
If HOOPS Luminate is initialized in hardware mode or in hybrid mode, then the first window that is created will initialize the OpenGL rendering layer of the system. If the creation of this window fails, then we can use the code below to overcome the failure and force HOOPS Luminate startup whenever possible:
// Create the resource manager unique instance:
RED::Object* resmgr = RED::Factory::CreateInstance( CID_REDResourceManager );
if( !resmgr )
exit( 1 );
RED::IResourceManager *iresmgr = resmgr->As< RED::IResourceManager >();
RED::IOptions* iresopt = resmgr->As< RED::IOptions >();
// Let's start in hardware mode for instance (it could be hybrid too):
RC_TEST( iresopt->SetOptionValue( RED::OPTIONS_RAY_ENABLE_SOFT_TRACER, 0, iresmgr->GetState() ) );
// Create a width x height window ('hwnd' is our windows handler here):
RED_RC rc;
RED::Object* window = RED::Factory::CreateREDWindow( *resmgr, hwnd, width, height, NULL, rc );
if( window == NULL )
{
// Critical failure. We can't continue here. The window object has not been allocated indicating a severe error.
exit( 1 );
}
// Try to restart in full CPU mode if we have failed to initialize the window:
if( rc != RED_OK )
{
if( rc == RED_DRV_UNSUPPORTED_GPU )
{
// Cleanup our previously created window. As it was not properly initialized, do a direct destruction:
if( window )
rdelete window;
// Setup the resource manager in software mode:
RC_TEST( iresopt->SetOptionValue( RED::OPTIONS_RAY_ENABLE_SOFT_TRACER, 2, iresmgr->GetState() ) );
window = RED::Factory::CreateREDWindow( *resmgr, hwnd, width, height, NULL, rc );
if( window == NULL )
exit( 1 );
if( rc != RED_OK )
{
// Restart attempt has failed. Exit now.
exit( 1 );
}
}
else
{
// Other failures for which we can't restart. Exit now.
exit( 1 );
}
}
Please that we may not be able to restart if a severe error has occurred; This never happens, or the system is badly damaged, as on the second attempt, the startup procedure is purely software, and does not rely on any other piece of software.
There are differences to understand between the rendering technologies that co-exist in HOOPS Luminate:
Hardware Rendering |
Software Rendering |
---|---|
Setup RED ::OPTIONS_RAY_ENABLE_SOFT_TRACER equal to 0 (hardware) or 1 (hybrid) on the cluster’s resource manager. |
Setup RED ::OPTIONS_RAY_ENABLE_SOFT_TRACER equal to 2 (software) on the cluster’s resource manager. |
Rendering uses a scanline algorithm, implemented by the OpenGL operating system layer. |
Rendering uses native ray-tracing, implemented by Tech Soft 3D. |
Rendering uses one CPU core and requires a GPU for the display. |
Rendering uses CPU cores for the calculation and the OS rendering API for the display. |
The rendering call is RED::IWindow::FrameDrawing. |
The rendering call is RED::IWindow::FrameTracing (and/or derived calls). |
One rendering call displays an entire frame. |
After a rendering call, the frame may be incomplete. The application may need to loop to get a complete result, due to the display using progressive refinement. |
Real-time (limited) rendering quality. |
Photo-realistic rendering quality. |
As illustrated above, from an application design standpoint, using hardware rendering or software rendering makes a difference in the way to manage events. Using the hardware, once the rendering call has returned, the image is complete and it’s displayed by the hardware. In software, the image has just started to be calculated. It may be more or less complete, depending of course on rendering options and on the data to be visualized, but most of the times, several rendering calls will be needed to get the image complete. Consequently, the calling application must be manage that fact if it has to use software rendering.
A comparison of typical application rendering loops can be found here: Hardware Event Loop vs. Software Event Loop.
Then, please refer to this page: Hardware, Hybrid or Software Start for details on all the startup modes of HOOPS Luminate.