Archived issue #0024699
Visualization - prototype interoperation of TKOpenGl viewer with Direct3D viewer
Description
OCCT viewer is based on OpenGL for portability reasons and common sense. However some applications might be restricted to Direct3D viewer (WPF) or require some Direct3D features (DXVA).
In 2010 NVIDIA introduced WGL_NV_DX_interop extension to their OpenGL implementation for such purposes. Nowadays this extension has been implemented by other vendors as well (AMD, Intel).
This issue suggest prototyping a sample application using this extension to incorporate TKOpenGl off-screen renderer into Direct3D viewer.
The main application work-flow would look like this:
- create off-screen WNT_Window and V3d_View in it.
- create visible Direct3D viewer.
- create D3D rendering target and dedicated depth/stencil buffers with sharing capabilities (required on Vista+).
- make dummy V3d_View redraw call to bind OpenGL context.
- create D3D->OpenGL handle using WGL_NV_DX_interop extension.
- create D3D->OpenGL handles for D3D surfaces and create OpenGL FBO based on them.
- inherit class from OpenGl_FrameBuffer to define custom FBO (fields must be re-defined as protected).
- assigns it to the V3d_View for rendering (which previously has been used only for snapshot dump functionality - see ToPixMap() method).
- perform consequential rendering of OpenGL / D3D viewers, locking shared resources when needed.
See discussion on development portal:
http://dev.opencascade.org/index.php?q=node/766
In 2010 NVIDIA introduced WGL_NV_DX_interop extension to their OpenGL implementation for such purposes. Nowadays this extension has been implemented by other vendors as well (AMD, Intel).
This issue suggest prototyping a sample application using this extension to incorporate TKOpenGl off-screen renderer into Direct3D viewer.
The main application work-flow would look like this:
- create off-screen WNT_Window and V3d_View in it.
- create visible Direct3D viewer.
- create D3D rendering target and dedicated depth/stencil buffers with sharing capabilities (required on Vista+).
- make dummy V3d_View redraw call to bind OpenGL context.
- create D3D->OpenGL handle using WGL_NV_DX_interop extension.
- create D3D->OpenGL handles for D3D surfaces and create OpenGL FBO based on them.
- inherit class from OpenGl_FrameBuffer to define custom FBO (fields must be re-defined as protected).
- assigns it to the V3d_View for rendering (which previously has been used only for snapshot dump functionality - see ToPixMap() method).
- perform consequential rendering of OpenGL / D3D viewers, locking shared resources when needed.
See discussion on development portal:
http://dev.opencascade.org/index.php?q=node/766
Public activity
40 archived notes
Participants are labeled by their role within this record.
Dear kgv,
Could you look at this demo (attached)?
Could you look at this demo (attached)?
To compile and run this demo:
1) Install Microsoft DirectX SDK 2010.
2) Configure CASROOT directory in msvc10.bat/msvc12.bat.
3) Build custom OCCT version: move OpenGL_Framebuffer.hxx private variables to protected section. Next release of OCCT will include this fix.
1) Install Microsoft DirectX SDK 2010.
2) Configure CASROOT directory in msvc10.bat/msvc12.bat.
3) Build custom OCCT version: move OpenGL_Framebuffer.hxx private variables to protected section. Next release of OCCT will include this fix.
Dear dbp,
the patch should be prepared in proper way - as sample example in OCCT git.
the patch should be prepared in proper way - as sample example in OCCT git.
Dear kgv,
The initial version of modified sample was implemented. Please review branch CR24699_1.
The initial version of modified sample was implemented. Please review branch CR24699_1.
Dear dbp,
the workaround for initialization on AMD cards has been pushed to branch CR24699 (including some extra minor changes).
Please investigate VBO creation failures on NVIDIA drivers - this may describe the crash on AMD drivers.
Please implement also software fallback mode (copying GL->D3D through system memory).
the workaround for initialization on AMD cards has been pushed to branch CR24699 (including some extra minor changes).
Please investigate VBO creation failures on NVIDIA drivers - this may describe the crash on AMD drivers.
Please implement also software fallback mode (copying GL->D3D through system memory).
Dear kgv,
please review the patch in branch CR24699_2.
please review the patch in branch CR24699_2.
Dear kgv,
the rebased squashed version is in branch CR24699_3.
the rebased squashed version is in branch CR24699_3.
Please test the patch (including updated sample).
Dear Commenter 1,
Branch CR24699_3 (and products from GIT master) was compiled on Linux, MacOS and Windows platforms and tested.
[revision removed]
Number of compiler warnings:
occt component :
Linux: 18 (18 on master)
Windows: 0 (0 on master)
MacOS: 413 (413 on master)
products component :
Linux: 12 (12 on master)
Windows: 2 (2 on master)
Regressions/Differences:
No regressions/differences
Testing cases:
Not needed
Testing on Linux:
Total MEMORY difference: 352987340 / 352653700
Total CPU difference: 74262.01999999965 / 67343.38000000024
Testing on Windows:
Total MEMORY difference: 381286492 / 380717640
Total CPU difference: 35453.984375 / 39760.234375
There are no differences in images found by testdiff.
Branch CR24699_3 (and products from GIT master) was compiled on Linux, MacOS and Windows platforms and tested.
[revision removed]
Number of compiler warnings:
occt component :
Linux: 18 (18 on master)
Windows: 0 (0 on master)
MacOS: 413 (413 on master)
products component :
Linux: 12 (12 on master)
Windows: 2 (2 on master)
Regressions/Differences:
No regressions/differences
Testing cases:
Not needed
Testing on Linux:
Total MEMORY difference: 352987340 / 352653700
Total CPU difference: 74262.01999999965 / 67343.38000000024
Testing on Windows:
Total MEMORY difference: 381286492 / 380717640
Total CPU difference: 35453.984375 / 39760.234375
There are no differences in images found by testdiff.
Dear Commenter 1,
re-based patch has been pushed to branch CR24699_5.
Please test CSharp samples within the patch (no need to test OCCT - patch affects only sample).
re-based patch has been pushed to branch CR24699_5.
Please test CSharp samples within the patch (no need to test OCCT - patch affects only sample).
It is suggested (by ABV) to make this functionality optional for developers who want to install DirectX SDK and has powerful video card.
The current version cannot be integrated as-is since it does not build in standard environment (without DirectX SDK) and it is not described how to build it with even if SDK is available. If it is possible to make DirectX dependency optional, we can keep it as part of WPF sample, just providing option to enable it and instructions on how to build. Otherwise, we can separate DirectX sample from "standard" WPF sample. In any case build instructions are required.
The proposed solution:
1. Since the redesigned WPF sample including DirectX support is very different from the "standard" WPF sample, it is necessary to restore the original one and add a specific DirectX demo as proposed by ABV.
2. Presence of DirectX SDK can be checked in the Visual Studio launcher batch file, corresponding preprocessor definition is to be added. If this definition is missing, compilation of the DirectX sample should fail with a user-friendly message, e.g. DirectX SDK is required in order to build the sample but it is not found in your system. Please install DirectX SDK and retry.
1. Since the redesigned WPF sample including DirectX support is very different from the "standard" WPF sample, it is necessary to restore the original one and add a specific DirectX demo as proposed by ABV.
2. Presence of DirectX SDK can be checked in the Visual Studio launcher batch file, corresponding preprocessor definition is to be added. If this definition is missing, compilation of the DirectX sample should fail with a user-friendly message, e.g. DirectX SDK is required in order to build the sample but it is not found in your system. Please install DirectX SDK and retry.
Branch [archived branch] has been created by Participant.
[revision removed]
Detailed log of new commits:
Author: dln
Date: Mon Sep 8 09:41:43 2014 +0400
0024699: Visualization - prototype interoperation of TKOpenGl viewer with Direct3D viewer
- edit of the C# samples documentation
Author: dln
Date: Fri Sep 5 15:50:55 2014 +0400
0024699: Visualization - prototype interoperation of TKOpenGl viewer with Direct3D viewer
- separate DirectX sample from "standard" WPF sample
- check of installed DirectX SDK on PC
[revision removed]
Detailed log of new commits:
Author: dln
Date: Mon Sep 8 09:41:43 2014 +0400
0024699: Visualization - prototype interoperation of TKOpenGl viewer with Direct3D viewer
- edit of the C# samples documentation
Author: dln
Date: Fri Sep 5 15:50:55 2014 +0400
0024699: Visualization - prototype interoperation of TKOpenGl viewer with Direct3D viewer
- separate DirectX sample from "standard" WPF sample
- check of installed DirectX SDK on PC
Branch [archived branch] has been updated forcibly by Participant.
[revision removed]
[revision removed]
Branch [archived branch] has been created by Participant.
[revision removed]
Detailed log of new commits:
Author: dbp
Date: Tue Jun 3 10:11:33 2014 +0400
0024699: Visualization - prototype interoperation of TKOpenGl viewer with Direct3D viewer
Add new C# sample which allow to render the OCCT scene to a Direct3D context in a WPF application.
DirectX SDK is required in order to build this sample.
[revision removed]
Detailed log of new commits:
Author: dbp
Date: Tue Jun 3 10:11:33 2014 +0400
0024699: Visualization - prototype interoperation of TKOpenGl viewer with Direct3D viewer
Add new C# sample which allow to render the OCCT scene to a Direct3D context in a WPF application.
DirectX SDK is required in order to build this sample.
Branch [archived branch] has been updated forcibly by Participant.
[revision removed]
[revision removed]
Would not it be possible to avoid moving existing samples (WinForms and WPF) to different location? Why not re-using the same code for OCCProxy, icons etc., and just adding new projects (and may be solution) for DirectX version?
Branch [archived branch] has been updated forcibly by Participant.
[revision removed]
[revision removed]
Done, Check it please. Branch CR24699_7
Please test changed samples.
Branch [archived branch] has been updated forcibly by Participant.
[revision removed]
[revision removed]
Do we really need to have OCCProxy-D3D and D3DProxy as separated libs, why not to combine them?
1. Microsoft DirectX SDK 2010 has been installed but unsuccessfully with error on installation redistributable. Despite this DXSDK_DIR variable is defined in system environment variables and I were able to continue.
2. wpf and wpf-D3D samples were compiled without problems.
3. wpf and wpf-D3D samples behavior is different
3.1 shape in wpf sample is displayed originally in wareframe mode but in wpf-D3D in shading one.
3.2 tone of shading in samples is different. See attached pictures
3.3 rectangle selection is not realized in wpf-D3D sample. In wpf sample it is realized very bad (no update).
3.4 context menu after clicking MB3 on selected shape is not realized in wpf-D3D sample.
2. wpf and wpf-D3D samples were compiled without problems.
3. wpf and wpf-D3D samples behavior is different
3.1 shape in wpf sample is displayed originally in wareframe mode but in wpf-D3D in shading one.
3.2 tone of shading in samples is different. See attached pictures
3.3 rectangle selection is not realized in wpf-D3D sample. In wpf sample it is realized very bad (no update).
3.4 context menu after clicking MB3 on selected shape is not realized in wpf-D3D sample.
Branch [archived branch] has been updated forcibly by Participant.
[revision removed]
[revision removed]
Done, Check it please. Branch CR24699_7
Please re-check samples.
Note that different tone of viewers is not covered by updated patch, please ignore it.
Note that different tone of viewers is not covered by updated patch, please ignore it.
Branch [archived branch] has been deleted by Participant.
[revision removed]
[revision removed]
Branch [archived branch] has been deleted by Participant.
[revision removed]
[revision removed]
Branch [archived branch] has been deleted by Participant.
[revision removed]
[revision removed]
Branch [archived branch] has been deleted by Participant.
[revision removed]
[revision removed]
Branch [archived branch] has been deleted by Participant.
[revision removed]
[revision removed]
Branch [archived branch] has been deleted by Participant.
[revision removed]
[revision removed]
Branch [archived branch] has been deleted by Participant.
[revision removed]
[revision removed]
Branch [archived branch] has been deleted by Participant.
[revision removed]
[revision removed]
Branch [archived branch] has been created by Author.
[revision removed]
Detailed log of new commits:
Author: Author
Date: Thu Jun 11 07:45:46 2015 +0300
TKD3DHost - D3D host for OpenGL window
[revision removed]
Detailed log of new commits:
Author: Author
Date: Thu Jun 11 07:45:46 2015 +0300
TKD3DHost - D3D host for OpenGL window
Branch [archived branch] has been updated forcibly by Author.
[revision removed]
[revision removed]
Branch [archived branch] has been updated by Author.
[revision removed]
Detailed log of new commits:
Author: Author
Date: Thu Jul 2 18:52:45 2015 +0300
V3d_View::IsInvalidated() - add method to check view cache validation state
Author: Author
Date: Thu Jul 2 18:51:18 2015 +0300
OpenGl_FrameBuffer::Init(), D3DHost_FrameBuffer::Init() - add protection against 0 dimensions
~D3DHost_Workspace() - release D3D/WGL FBO.
[revision removed]
Detailed log of new commits:
Author: Author
Date: Thu Jul 2 18:52:45 2015 +0300
V3d_View::IsInvalidated() - add method to check view cache validation state
Author: Author
Date: Thu Jul 2 18:51:18 2015 +0300
OpenGl_FrameBuffer::Init(), D3DHost_FrameBuffer::Init() - add protection against 0 dimensions
~D3DHost_Workspace() - release D3D/WGL FBO.
Branch [archived branch] has been updated by Author.
[revision removed]
Detailed log of new commits:
Author: Author
Date: Fri Jul 3 18:49:17 2015 +0300
cosmetics
[revision removed]
Detailed log of new commits:
Author: Author
Date: Fri Jul 3 18:49:17 2015 +0300
cosmetics
Branch [archived branch] has been deleted by Author.
[revision removed]
[revision removed]
Related records