Jump to content
  • Advertisement
Sign in to follow this  
Julian Spillane

[CgFX] Problem Updating Parameters...

This topic is 4298 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey all, We're currently using Cg 1.5 final in our engine. We've implemented a whole system based around CgFX but have run into some issues. I was just wondering if it was possible to disable parameter shadowing with effects. With parameter shadowing enabled we have to wait until the next update in order for parameters to be updated. I wish for the parameter value to be updated as it is set (as can be done by disabling parameter shadowing in normal Cg). Hopefully this sample code will give you some insight into my dilemma. Just for clarification we're using this with Direct3D:
CGpass curPass = cgGetFirstPass(m_pDevice->m_vEffects[m_pDevice->m_nActiveEffectID].m_technique);

 while (curPass)
 {     
  cgSetPassState(curPass);

  for (int i = 0; i < MAX_CACHES; i++)
  {
   if (m_pCaches.m_nCurrentVertices > 0)
   {
    m_pDevice->setEffectParameterMatrixFloat(m_pDevice->m_nActiveEffectID, "fn_worldView", true, m_pCaches.m_matWV.getColumnMajor());
    m_pDevice->setEffectParameterMatrixFloat(m_pDevice->m_nActiveEffectID, "fn_worldViewProjection", true, m_pCaches.m_matWVP.getColumnMajor());
    m_pDevice->setEffectParameterMatrixFloat(m_pDevice->m_nActiveEffectID, "fn_worldViewInverseTranspose", true, m_pCaches.m_matWVIT.getColumnMajor());

    m_pDevice->m_pD3DDevice->SetStreamSource(0, m_pCaches.m_pVB, 0, m_pCaches.m_nStride);

    if (m_pCaches.m_nCurrentIndices > 0)
    {
     m_pDevice->m_pD3DDevice->SetIndices(m_pCaches.m_pIB);

     m_pDevice->m_pD3DDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0, m_pCaches.m_nCurrentVertices, 0, m_pCaches.m_nCurrentIndices / 3);
    }
    else
    {
     m_pDevice->m_pD3DDevice->DrawPrimitive(D3DPT_TRIANGLELIST, 0, m_pCaches.m_nCurrentVertices / 3);
    }
   }
  }
  cgResetPassState(curPass);

  curPass = cgGetNextPass(curPass);
 }

This code is part of our dynamic rendering system. Geometry that is rendered dynamically is grouped into caches according to material. This geometry is further sorted into sub caches with the same transformation matrix. During my rendering loop I wish to bind the vertex and pixel shader once and then draw all of the sub caches with their appropriate transformation matrix. This is quite efficient as only one bind has to take place for all of the geometry that is rendered subsequently. Any help would be greatly appreciated.

Share this post


Link to post
Share on other sites
Advertisement
Hmm...I still haven't been able to solve it.
I've posted on the NVidia forums as well but have received no response.

Does anyone have any suggestions on how I can circumvent this if there is no way to prevent this behaviour in CgFX?

Share this post


Link to post
Share on other sites
In CgFX there is no way to control the shadowing when using D3D.

We are working on this issue for all of Cg so stay tuned. :)

You could also look into rolling your own state callbacks. Look into cgSetStateCallbacks.

This way you can control the loading of programs in your own callback code and handle shadowing yourself. NVSG uses this user callback mechanism since they want to control everything on their own.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!