This has worked for my application:
//these will force use of dedicated GPU if available
extern "C"
{
__declspec(dllexport) unsigned long NvOptimusEnablement = 0x00000001;
}
extern "C"
{
__declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1;
}
First is for NVIDIA , second is AMD
________________________________
From: [email protected] <[email protected]> on behalf of
Christopher Jaquet <[email protected]>
Sent: Wednesday, August 3, 2022 1:27 AM
To: OpenSceneGraph Users <[email protected]>
Subject: Re: [osg-users] Re: New user on Windows, when running examples getting
errors
> but if I made a product with that you aren't going to ask a customer to do
> that, right?
You can try the flag on the `DisplaySettings` class that can enable the
dedicated GPU when you initialise OSG. In the osggpucull example below the line
osg::DisplaySettings::instance()->setNumMultiSamples( 4 );
you can add
osg::DisplaySettings::instance()->setNvOptimusEnablement( true );
and see if that works. This appears to be nvidia-only but you can probably
modify the OSG code to do the same for amd GPUs (see this stackoverflow article
which may help:
https://stackoverflow.com/questions/17458803/amd-equivalent-to-nvoptimusenablement
).
I generally compile OSG only in GL3 mode (i.e. the old fixed function pipeline
is disabled) and very few of the examples work as expected out of the box. Make
sure you have the `OSG_FILE_PATH` environment variable set to the folder
containing the data resources. (You can get a zip of the data resources from
https://www.openscenegraph.com/index.php/download-section/data )
> View an example on one screen
Most of the examples will accept the `--screen <num>` command line option which
you can use to choose a screen number to display on a single screen.
Alternatively you can use the `--window <x y w h>` (where x,y is the position
and w,h is the width/height) option to display in a window.
Hope this helps.
On Wednesday, 03 August 2022 at 02:21:07 UTC+2 [email protected] wrote:
Hello Mario,
> but if I made a product with that you aren't going to ask a customer to do
> that, right?
You're right. I'm not the one responsible for doing this at my workplace, so I
don't know all the ins and outs, but AFAIK, you need to go through the API
(https://docs.nvidia.com/gameworks/content/gameworkslibrary/coresdk/nvapi/group__drsapi.html)
to create a profile and add your app to it. We do this through our Installer
app and the installation process, but perhaps you could integrate it into your
own app and have it configure itself w.r.t. the NVIDIA drivers. (That would
likely require that you then run your app with administrator privileges, maybe?)
> Also, do you know why I'd be getting those errors?
I'm not sure. I tried to run the same example as you did "naturally" on my
laptop, and I got the following errors, with a garbage display:
VERTEX glCompileShader "static_cull_vertex" FAILED
VERTEX Shader "static_cull_vertex" infolog:
ERROR: 0:6: 'R32I' : syntax error syntax error
glLinkProgram 0000024FD95BA760"static_cull" FAILED
Program "static_cull" infolog:
Attached vertex shader is not compiled.
Warning: detected OpenGL error 'invalid operation' at after
pcp->apply(Unfiorm&) in GLObjectsVisitor::apply(osg::StateSet& stateset),
unifrom name: indirectCommand0
VERTEX glCompileShader "static_draw_0_vertex" FAILED
VERTEX Shader "static_draw_0_vertex" infolog:
ERROR: 0:34: 'RGBA32F' : syntax error syntax error
glLinkProgram 0000024FD95BAAE0"static_draw_0" FAILED
Program "static_draw_0" infolog:
Attached vertex shader is not compiled.
Warning: detected OpenGL error 'invalid operation' at after
pcp->apply(Unfiorm&) in GLObjectsVisitor::apply(osg::StateSet& stateset),
unifrom name: indirectTarget
VERTEX glCompileShader "static_draw_1_vertex" FAILED
VERTEX Shader "static_draw_1_vertex" infolog:
ERROR: 0:34: 'RGBA32F' : syntax error syntax error
glLinkProgram 0000024FD95BB100"static_draw_1" FAILED
Program "static_draw_1" infolog:
Attached vertex shader is not compiled.
Warning: detected OpenGL error 'invalid operation' at after
pcp->apply(Unfiorm&) in GLObjectsVisitor::apply(osg::StateSet& stateset),
unifrom name: indirectTarget
VERTEX glCompileShader "dynamic_cull_vertex" FAILED
VERTEX Shader "dynamic_cull_vertex" infolog:
ERROR: 0:9: 'R32I' : syntax error syntax error
glLinkProgram 0000024FD95BABC0"dynamic_cull" FAILED
Program "dynamic_cull" infolog:
Attached vertex shader is not compiled.
Warning: detected OpenGL error 'invalid operation' at after
pcp->apply(Unfiorm&) in GLObjectsVisitor::apply(osg::StateSet& stateset),
unifrom name: dynamicInstancesData
VERTEX glCompileShader "dynamic_draw_0_vertex" FAILED
VERTEX Shader "dynamic_draw_0_vertex" infolog:
ERROR: 0:37: 'RGBA32I' : syntax error syntax error
glLinkProgram 0000024FD95BB8E0"dynamic_draw_0" FAILED
Program "dynamic_draw_0" infolog:
Attached vertex shader is not compiled.
Warning: detected OpenGL error 'invalid operation' at after
pcp->apply(Unfiorm&) in GLObjectsVisitor::apply(osg::StateSet& stateset),
unifrom name: dynamicInstancesData
C:\dev\OpenSceneGraph-build-x64\bin\osggpucullrd.exe (process 20928) exited
with code 0.
Press any key to close this window . . .
Then I went through the process I explained earlier (actually, I added the
whole directory rather than the individual .exe) and then running the example
went fine. So apparently, the issue seems to be that the program is not running
with the proper chip, but you seem to mention you have made the proper
adjustments. That being said, I have a "NVIDIA GeForce RTX 3050 Ti Laptop GPU",
not a Nvidia Quadro T2000 like you have; according to this API doc
(https://docs.nvidia.com/gameworks/content/gameworkslibrary/coresdk/nvapi/modules.html),
there seems to be additional API functions to handle some Quadro features, but
I don't know if it's related to the issue you're having.
I don't think the issue is caused by issues with compilation, as you would not
be able to get to shader compilation (I think, I'm not the shader expert).
FWIW, this commit on github is essentially how I generate the solution with
CMake. This commit doesn't have the examples enabled, but you can enable them
by changing the flag BUILD_OSG_EXAMPLES to ON:
https://github.com/vaillancourt/OpenSceneGraph/commit/350924df765a4e43289e5cc77ea6271f9d5dd85d
I hope it helps.
--
Vaillancourt
On Tue, 2 Aug 2022 at 15:32, Mario Ricci <[email protected]> wrote:
Thanks Vaillancourt. I knew about that whole configuring the exe process, but
if I made a product with that you aren't going to ask a customer to do that,
right? I did some searching and there was some old switches and variables, but
I couldn't get any to work. Is there no other way to configure gpu
programmatically?
Also, do you know why I'd be getting those errors? Could it be a build issue?
On Tuesday, August 2, 2022 at 8:17:45 AM UTC-6 [email protected] wrote:
Hello Mario!
> how to get it to use my Nvidia GPU instead of integrated graphics
Usually I need to go through this process:
1. From the 'NVIDIA Control Panel', go to '3D Settings' > 'Manage 3D
Settings'.
2. Select the tab 'Program Settings'.
3. In the section 1., click on 'Add' and select your own .exe, then in
section 2. select the 'High-performance NVIDIA processor'.
4. Click 'Apply'. Restart your program; it should now use the NVIDIA
processor.
I had the possibility to further "tune" the parameters for my programs on a
previous laptop, but I can no longer change anything on this one (e.g.
enable/disable vsync).
> Find a page controls in examples
Unfortunately, there is no repository for this, nor a mechanisms that lists the
keys/buttons handled and what they do. You'll need to check the code of the
different classes that handle movement to see what they do and how they do it.
In osggpucull, the entry point is probably around this code:
osg::ref_ptr<osgGA::KeySwitchMatrixManipulator> keyswitchManipulator = new
osgGA::KeySwitchMatrixManipulator;
keyswitchManipulator->addMatrixManipulator( '1', "Trackball", new
osgGA::TrackballManipulator() );
keyswitchManipulator->addMatrixManipulator( '2', "Flight", new
osgGA::FlightManipulator() );
keyswitchManipulator->addMatrixManipulator( '3', "Drive", new
osgGA::DriveManipulator() );
keyswitchManipulator->addMatrixManipulator( '4', "Terrain", new
osgGA::TerrainManipulator() );
I hope this helps you get a bit further in your tests.
- Vaillancourt
On Monday, August 1, 2022 at 2:38:20 p.m. UTC-4 [email protected] wrote:
Hi all,
Very new to OSG. My main question is how to get some of the examples running
with large amounts of data on one screen, and how to get it to use my Nvidia
GPU instead of integrated graphics. I'd like to test performance and have at
least one example running properly.
I wasn't sure how to build and none of the walkthroughs worked for me, but
basically I used the GUI version of cmake on Windows 11 and pointed it to the
code and a build directory. After hitting the Configure and Generate buttons
as well as adding a BUILD_OSG_EXAMPLES flag, I had a solution which I opened in
VS 2022 and seemed to properly build.
I have multiple monitors and a Nvidia Quadro T2000 as well as the integrated
intel graphics. When running examples things seem a bit broken. I do get
graphics across both monitors and can zoom etc., but they don't look that great
(not sure if that's how they are supposed to look).
One example I tried was osggpuculld.exe, which displays this if I scroll in
very far (attachment osg cull example.png). I also see the following on the
CLI:
```
.\osggpuculld.exe
void StateSet::setGlobalDefaults() ShaderPipeline disabled.
void StateSet::setGlobalDefaults() ShaderPipeline disabled.
VERTEX glCompileShader "static_cull_vertex" FAILED
VERTEX Shader "static_cull_vertex" infolog:
ERROR: 0:6: 'R32I' : syntax error syntax error
VERTEX Shader "static_cull_vertex" infolog:
ERROR: 0:6: 'R32I' : syntax error syntax error
VERTEX Shader "static_cull_vertex" infolog:
ERROR: 0:6: 'R32I' : syntax error syntax error
glLinkProgram 0000028ACCB02AA0"static_cull" FAILED
glLinkProgram 0000028ACCB02AA0"static_cull" FAILED
Program "static_cull" infolog:
Attached vertex shader is not compiled.
```
I've tried other examples and used some built in data to view the dump truck
etc., but nothing has texture and everything uses my integrated graphics.
Does anyone know how to:
1. View an example on one screen
2. Use the proper GPU
3. Find a page controls in examples (e.g. what does mouse do? what do key
commands do?)
4. Get a big model combined into an example to check performance
Thanks in advance!
--
You received this message because you are subscribed to a topic in the Google
Groups "OpenSceneGraph Users" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/osg-users/nxZn2g45SsE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
[email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/osg-users/cf4311d0-f2f9-40a8-8fdb-9f002dc9a9f2n%40googlegroups.com<https://groups.google.com/d/msgid/osg-users/cf4311d0-f2f9-40a8-8fdb-9f002dc9a9f2n%40googlegroups.com?utm_medium=email&utm_source=footer>.
--
You received this message because you are subscribed to the Google Groups
"OpenSceneGraph Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to
[email protected]<mailto:[email protected]>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/osg-users/a0ed30f9-93d7-407c-be54-f8470f0eee55n%40googlegroups.com<https://groups.google.com/d/msgid/osg-users/a0ed30f9-93d7-407c-be54-f8470f0eee55n%40googlegroups.com?utm_medium=email&utm_source=footer>.
--
You received this message because you are subscribed to the Google Groups
"OpenSceneGraph Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/osg-users/MN2PR09MB540227EB5B6E1FF3C1BA6CAB9C9C9%40MN2PR09MB5402.namprd09.prod.outlook.com.