Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>jmp [UPDATE] ;; skip obsolete text segment</strong></p> <p>Could it be that Cg is being destroyed after d3d so it doesn't release the reference on time? Or vice-versa? such as the function acquiring the texture but not releasing it before d3d closes, because when you set a texture to a shader, the texture is acquired until shader resources are released somehow. You are destroying the d3d context, here: SAFE_RELEASE( g.d3d ); SAFE_RELEASE( g.gpu ); Later on, you free the shader, as follows CleanupCg(): cgDestroyProgram( g.v_vncShader ); checkForCgError( "destroying vertex program" ); cgDestroyProgram( g.px_vncShader ); checkForCgError( "destroying fragment program" ); Try to change the order of the calls in a way you first release all resources from both cg and d3d, this: <code>cgD3D11SetDevice( g.cgContext, NULL );</code> should also be called before releasing the d3d context, just in case.</p> <p><strong>UPDATE:</strong></p> <p>This should be different inside <code>WinMain()</code>:</p> <pre><code>initD3D11() ; // &lt;&lt; FIRST you init D3D initCg() ; // &lt;&lt; SECOND you init CG with the D3D pointers initD2D1() ; // initVBs() ; // Main message loop while( WM_QUIT != msg.message ){ /* loop code */ } CleanupDevice(); //// &lt;&lt; FIRST you release all D3D, when Cg is still referencing it (why?). CleanupCg(); //// &lt;&lt; SECOND if something in the Cg runtime depend on d3dcontext which you just destroyed, it will crash or leak or do whatever it wants </code></pre> <p>so you should swap them to ensure Cg to free any d3d pointer:</p> <pre><code>CleanupCg(); //// &lt;&lt; FIRST release Cg to ensure it's not referencing D3D anymore. CleanupDevice(); //// &lt;&lt; SECOND D3D isn't either referencing or being referenced by Cg, so just release it all </code></pre> <p>You could also provide the debugger output and other info as I asked down there, because you're basically saying "Cg seems to be broken, this is the whole code, look the line ###, is it broken?" but there are more than a thousand lines (1012) of C, C++ and shader code in your file, you basically provide no info but readily point to a Cg bug (based on... what?) which of course, if you're so sure, why would anyone look at the code if the code is fine? Which isn't by the way, not that I don't like it but... it got these little things such as the call ordering which are silly mistakes but that can make debugging a real hell, it's a clear bug, and I may also think that if I just looked into Main and found a bug, well there is a long way up to the render call and the Cg implementation, isn't it? I can't run the app on WinXP, but these errors are in the most predictable places :)</p> <p>So... when your code is clean of any bug... ohh! look! what I've just found..</p> <pre><code>~VertexBuffer() { SAFE_RELEASE( vb ); SAFE_RELEASE( layout ) ; } </code></pre> <p>turns out in VertexBuffer constructor you call <code>iD3D-&gt;GetImmediateContext( &amp;gpu );</code> and store the pointer in a private member, so... shouldn't you add:</p> <pre><code>SAFE_RELEASE( gpu ); // ? there are 3 VertexBuffers instances, so that's another memory leak. </code></pre> <p>Ok so there are some things you should fix in your code that cause memory leaks, and I just took a look on it, so you didn't really try. On the other hand, it seems your code is clear and full of explanations and I need to learn some DX11, so actually I should thank you for it. The downvote was somewhat rude though :P specially because I'm probably right, and other people would avoid reading your code as soon as the page displays.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload