Google

[solved] - 1.6.0 upgrade hardware skinning shaders problem

Problems building or running the engine, queries about how to use features etc.

Moderators: Moderators, OGRE Team

[solved] - 1.6.0 upgrade hardware skinning shaders problem

Postby oiram » Sun Dec 13, 2009 5:12 am

Upgrading from 1.60 to 1.6.4 raised some strange vertex shaders problem
the assertion is raised in GpuProgramParameters::_writeRawConstants here
assert(physicalIndex + count <= mFloatConstants.size());
it seems the physical index is 36 and the count is 16 so the add is bigger than 48. This error is given when the prgram packs inverse world matrix parameter into the float array (the vertex shader is nothing unusual and it worked ok with the former version
What could it happen?

i use jaiqua.mesh with shader.
Code: Select all
void vs(   float4 iPos                 : POSITION,
         float2 iTex0                : TEXCOORD0,
         float4 blendIdx             : BLENDINDICES,
         float4 blendWgt             : BLENDWEIGHT,

         out float4 oColor           : COLOR,
         out float4 oPos             : POSITION,
         out float2 oTex0            : TEXCOORD0,

         uniform float3x4    worldMatrix3x4Array[60],
         uniform float4x4    viewProjectionMatrix   )
{
   float4 blendPos = float4(0,0,0,0);
   int i;
   for (i = 0; i < 4; ++i)
   {
      blendPos += float4(mul(worldMatrix3x4Array[blendIdx[i]], iPos).xyz, 1.0) * blendWgt[i];
   }
   // view / projection
   oPos = mul(viewProjectionMatrix, blendPos);
   oTex0 = iTex0;

   oColor = float4(1,0,0,1);
}


Code: Select all
vertex_program Ogre/VS hlsl
{
    source vs.hlsl
    entry_point vs
    target vs_2_0
    includes_skeletal_animation true

    default_params
    {
       param_named_auto worldMatrix3x4Array world_matrix_array_3x4
       param_named_auto viewProjectionMatrix viewproj_matrix
    }
}


1.6.0is fine, 1.6.1 - 1.6.4 are bad.
any advices?
Last edited by oiram on Thu Dec 24, 2009 5:21 am, edited 2 times in total.
oiram
Newcomer
 
Posts: 18
Joined: Sun Dec 13, 2009 5:06 am

Re: 1.6.2 upgrade to above 1.6.3 shaders problem

Postby oiram » Mon Dec 14, 2009 8:54 am

and, i am using vs2005 with sp1 + ogre 1.6.4 + nv 9800 gtx+ + dxsdk august 2009.

i've run sample "skeletalAnimation", it's fine with cg and glsl. when i change to use hlsl, crash also.
here is the original version:
Code: Select all
// Basic hardware skinning using two indexed weights per vertex
vertex_program Ogre/HardwareSkinningTwoWeightsCg cg
{
   source Example_Basic.cg
   entry_point hardwareSkinningTwoWeights_vp
   profiles vs_1_1 arbvp1
   includes_skeletal_animation true
}


I modified to:
Code: Select all
// Basic hardware skinning using two indexed weights per vertex
vertex_program Ogre/HardwareSkinningTwoWeightsCg hlsl
{
   source Example_Basic.hlsl
   entry_point hardwareSkinningTwoWeights_vp
   target vs_1_1
   includes_skeletal_animation true
}


then when I run the sample "skeletalAnimation" in ogre solution or outside, this issue could be reproduced.
any updates in ogre or dxsdk of latest version to make it happen?
thanks for any reply.
oiram
Newcomer
 
Posts: 18
Joined: Sun Dec 13, 2009 5:06 am

Re: 1.6.0 upgrade hardware skinning shaders problem

Postby oiram » Mon Dec 14, 2009 10:42 am

sorry for my mistake, it's 1.6.0 upgrade issue, not prior 1.6.2 what i wrote. :cry:

i think it's a problem with direct3d render system here.
i found same thread here: viewtopic.php?f=2&t=53669

Code: Select all
uniform float3x4 worldMatrix3x4Array[60]

worldMatrix3x4Array cannot be parsed right with the latest direct3d render system code. d3dDesc.RegisterCount of worldMatrix3x4Array is 180 here. GpuConstantDefinition& def cannot be fill right.
D3D9HLSLProgram::populateDef @ OgreD3D9HLSLProgram.cpp
Code: Select all
      case D3DXPT_FLOAT:
         switch(d3dDesc.Class)
         {
         case D3DXPC_MATRIX_COLUMNS:
         case D3DXPC_MATRIX_ROWS:
            switch(d3dDesc.RegisterCount)
            {
            case 2:
               switch(d3dDesc.Columns)
               {
               case 2:
                  def.constType = GCT_MATRIX_2X2;
                  def.elementSize = 8; // HLSL always packs
                  break;
               case 3:
                  def.constType = GCT_MATRIX_2X3;
                  def.elementSize = 8; // HLSL always packs
                  break;
               case 4:
                  def.constType = GCT_MATRIX_2X4;
                  def.elementSize = 8;
                  break;
               } // columns
               break;
            case 3:
               switch(d3dDesc.Columns)
               {
               case 2:
                  def.constType = GCT_MATRIX_3X2;
                  def.elementSize = 12; // HLSL always packs
                  break;
               case 3:
                  def.constType = GCT_MATRIX_3X3;
                  def.elementSize = 12; // HLSL always packs
                  break;
               case 4:
                  def.constType = GCT_MATRIX_3X4;
                  def.elementSize = 12;
                  break;
               } // columns
               break;
            case 4:
               switch(d3dDesc.Columns)
               {
               case 2:
                  def.constType = GCT_MATRIX_4X2;
                  def.elementSize = 16; // HLSL always packs
                  break;
               case 3:
                  def.constType = GCT_MATRIX_4X3;
                  def.elementSize = 16; // HLSL always packs
                  break;
               case 4:
                  def.constType = GCT_MATRIX_4X4;
                  def.elementSize = 16;
                  break;
               } // columns
               break;

            } // rows
            break;
oiram
Newcomer
 
Posts: 18
Joined: Sun Dec 13, 2009 5:06 am

Re: 1.6.0 upgrade hardware skinning shaders problem

Postby oiram » Mon Dec 14, 2009 11:14 am

i cannot run ogre with dxsdk august 2009 because dxerr issue.
but i copy OgreD3D9HLSLProgram.cpp from 1.6.0 to 1.6.4, everything is fine now.

i need to know more about it, thanks for any reply.
oiram
Newcomer
 
Posts: 18
Joined: Sun Dec 13, 2009 5:06 am

Re: 1.6.0 upgrade hardware skinning shaders problem

Postby oiram » Tue Dec 15, 2009 9:03 am

i think i found what's going on with it.
D3D9HLSLProgram::populateDef @ ogred3d9hlslprogram.cpp
the most diff is when d3dDesc.Type such as D3DXPT_FLOAT, the older version 1.6.0 use switch(d3dDesc.Rows) but newer version 1.6.x use switch(d3dDesc.Class).

you can diff ogred3d9hlslprogram.cpp with 1.6.0 and 1.6.4 and observe this.
guys, do your hardware skinning works fine on 1.6.x? nobody took notice of it's a bug? or it's my mistake somewhere?
these codes attached.

1.6.0
Code: Select all
   void D3D9HLSLProgram::populateDef(D3DXCONSTANT_DESC& d3dDesc, GpuConstantDefinition& def) const
   {
      def.arraySize = d3dDesc.Elements;
      switch(d3dDesc.Type)
      {
      case D3DXPT_INT:
         switch(d3dDesc.Columns)
         {
         case 1:
            def.constType = GCT_INT1;
            def.elementSize = 4; // HLSL always packs
            break;
         case 2:
            def.constType = GCT_INT2;
            def.elementSize = 4; // HLSL always packs
            break;
         case 3:
            def.constType = GCT_INT3;
            def.elementSize = 4; // HLSL always packs
            break;
         case 4:
            def.constType = GCT_INT4;
            def.elementSize = 4;
            break;
         } // columns
         break;
      case D3DXPT_FLOAT:
         switch(d3dDesc.Rows)
         {
         case 1:
            switch(d3dDesc.Columns)
            {
            case 1:
               def.constType = GCT_FLOAT1;
               def.elementSize = 4; // HLSL always packs
               break;
            case 2:
               def.constType = GCT_FLOAT2;
               def.elementSize = 4; // HLSL always packs
               break;
            case 3:
               def.constType = GCT_FLOAT3;
               def.elementSize = 4; // HLSL always packs
               break;
            case 4:
               def.constType = GCT_FLOAT4;
               def.elementSize = 4;
               break;
            } // columns
            break;
         case 2:
            switch(d3dDesc.Columns)
            {
            case 2:
               def.constType = GCT_MATRIX_2X2;
               def.elementSize = 8; // HLSL always packs
               break;
            case 3:
               def.constType = GCT_MATRIX_2X3;
               def.elementSize = 8; // HLSL always packs
               break;
            case 4:
               def.constType = GCT_MATRIX_2X4;
               def.elementSize = 8;
               break;
            } // columns
            break;
         case 3:
            switch(d3dDesc.Columns)
            {
            case 2:
               def.constType = GCT_MATRIX_3X2;
               def.elementSize = 12; // HLSL always packs
               break;
            case 3:
               def.constType = GCT_MATRIX_3X3;
               def.elementSize = 12; // HLSL always packs
               break;
            case 4:
               def.constType = GCT_MATRIX_3X4;
               def.elementSize = 12;
               break;
            } // columns
            break;
         case 4:
            switch(d3dDesc.Columns)
            {
            case 2:
               def.constType = GCT_MATRIX_4X2;
               def.elementSize = 16; // HLSL always packs
               break;
            case 3:
               def.constType = GCT_MATRIX_4X3;
               def.elementSize = 16; // HLSL always packs
               break;
            case 4:
               def.constType = GCT_MATRIX_4X4;
               def.elementSize = 16;
               break;
            } // columns
            break;

         } // rows
         break;
         
      default:
         // not mapping samplers, don't need to take the space
         break;
      };

   }


1.6.4
Code: Select all
   void D3D9HLSLProgram::populateDef(D3DXCONSTANT_DESC& d3dDesc, GpuConstantDefinition& def) const
   {
      def.arraySize = d3dDesc.Elements;
      switch(d3dDesc.Type)
      {
      case D3DXPT_INT:
         switch(d3dDesc.Columns)
         {
         case 1:
            def.constType = GCT_INT1;
            def.elementSize = 4; // HLSL always packs
            break;
         case 2:
            def.constType = GCT_INT2;
            def.elementSize = 4; // HLSL always packs
            break;
         case 3:
            def.constType = GCT_INT3;
            def.elementSize = 4; // HLSL always packs
            break;
         case 4:
            def.constType = GCT_INT4;
            def.elementSize = 4;
            break;
         } // columns
         break;
      case D3DXPT_FLOAT:
         switch(d3dDesc.Class)
         {
         case D3DXPC_MATRIX_COLUMNS:
         case D3DXPC_MATRIX_ROWS:
            switch(d3dDesc.RegisterCount)
            {
            case 2:
               switch(d3dDesc.Columns)
               {
               case 2:
                  def.constType = GCT_MATRIX_2X2;
                  def.elementSize = 8; // HLSL always packs
                  break;
               case 3:
                  def.constType = GCT_MATRIX_2X3;
                  def.elementSize = 8; // HLSL always packs
                  break;
               case 4:
                  def.constType = GCT_MATRIX_2X4;
                  def.elementSize = 8;
                  break;
               } // columns
               break;
            case 3:
               switch(d3dDesc.Columns)
               {
               case 2:
                  def.constType = GCT_MATRIX_3X2;
                  def.elementSize = 12; // HLSL always packs
                  break;
               case 3:
                  def.constType = GCT_MATRIX_3X3;
                  def.elementSize = 12; // HLSL always packs
                  break;
               case 4:
                  def.constType = GCT_MATRIX_3X4;
                  def.elementSize = 12;
                  break;
               } // columns
               break;
            case 4:
               switch(d3dDesc.Columns)
               {
               case 2:
                  def.constType = GCT_MATRIX_4X2;
                  def.elementSize = 16; // HLSL always packs
                  break;
               case 3:
                  def.constType = GCT_MATRIX_4X3;
                  def.elementSize = 16; // HLSL always packs
                  break;
               case 4:
                  def.constType = GCT_MATRIX_4X4;
                  def.elementSize = 16;
                  break;
               } // columns
               break;

            } // rows
            break;
         case D3DXPC_SCALAR:
         case D3DXPC_VECTOR:
            switch(d3dDesc.Columns)
            {
            case 1:
               def.constType = GCT_FLOAT1;
               def.elementSize = 4; // HLSL always packs
               break;
            case 2:
               def.constType = GCT_FLOAT2;
               def.elementSize = 4; // HLSL always packs
               break;
            case 3:
               def.constType = GCT_FLOAT3;
               def.elementSize = 4; // HLSL always packs
               break;
            case 4:
               def.constType = GCT_FLOAT4;
               def.elementSize = 4;
               break;
            } // columns
            break;
         }
      default:
         // not mapping samplers, don't need to take the space
         break;
      };

   }
oiram
Newcomer
 
Posts: 18
Joined: Sun Dec 13, 2009 5:06 am

Re: 1.6.0 upgrade hardware skinning shaders problem

Postby oiram » Fri Dec 18, 2009 3:43 am

I'm quite sad I got no answer to my post :cry:
oiram
Newcomer
 
Posts: 18
Joined: Sun Dec 13, 2009 5:06 am

Re: 1.6.0 upgrade hardware skinning shaders problem

Postby jacmoe » Fri Dec 18, 2009 4:23 pm

You don't deserve answers when you double-post.
Don't do it. :evil:

I removed your double in Developers.
/* when invited to a free lunch, you should not complain about the quality of the caviar */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, Fueled by Passion.
Ogre AppWizards - project wizards for Visual Studio and Code::Blocks.
User avatar
jacmoe
OGRE Moderator
OGRE Moderator
 
Posts: 17493
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark

Re: 1.6.0 upgrade hardware skinning shaders problem

Postby jacmoe » Fri Dec 18, 2009 4:25 pm

/* when invited to a free lunch, you should not complain about the quality of the caviar */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, Fueled by Passion.
Ogre AppWizards - project wizards for Visual Studio and Code::Blocks.
User avatar
jacmoe
OGRE Moderator
OGRE Moderator
 
Posts: 17493
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark

Re: 1.6.0 upgrade hardware skinning shaders problem

Postby oiram » Fri Dec 18, 2009 4:46 pm

your reply so fast...
i remember that... sorry :cry:
oiram
Newcomer
 
Posts: 18
Joined: Sun Dec 13, 2009 5:06 am

Re: 1.6.0 upgrade hardware skinning shaders problem

Postby Archangel » Fri Dec 18, 2009 5:23 pm

I think the question deserves an answer, regardless of the double post.
This is an issue I'm having too (click), and I find it strange that either :
  • no one else is experiencing it (except the OP)
  • nobody can tell us why the code has changed, and how to adapt our code if necessary

Anyway, thanks for your time.
Arch. / Kalith
User avatar
Archangel
Regular
 
Posts: 120
Joined: Sun Dec 19, 2004 6:02 pm
Location: Nantes, France

Re: 1.6.0 upgrade hardware skinning shaders problem

Postby jacmoe » Fri Dec 18, 2009 5:29 pm

@Archangel: I think you should read the forum rules too, because it says that if you don't get an answer right away, provide some more details, or ask the question differently.
/* when invited to a free lunch, you should not complain about the quality of the caviar */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, Fueled by Passion.
Ogre AppWizards - project wizards for Visual Studio and Code::Blocks.
User avatar
jacmoe
OGRE Moderator
OGRE Moderator
 
Posts: 17493
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark

Re: 1.6.0 upgrade hardware skinning shaders problem

Postby Jabberwocky » Fri Dec 18, 2009 9:44 pm

For the record, I think both Oiram and Archangel have done an excellent job of researching and presenting this problem. Particularly Oiram, who posted a reproducable example, and identified the offending code. I think they deserve some cred for that. And I'd be a little surprised if I were in their shoes too, that there wasn't more of a response to this thread - either by others who encountered the same problem, or developer(s) familiar with the change that seems to be causing the problem.
Image
A space epic for PC.
website
twitter
User avatar
Jabberwocky
Veteran
 
Posts: 1048
Joined: Mon Mar 05, 2007 11:17 pm
Location: Canada

Re: 1.6.0 upgrade hardware skinning shaders problem

Postby Archangel » Fri Dec 18, 2009 10:46 pm

jacmoe wrote:@Archangel: I think you should read the forum rules too, because it says that if you don't get an answer right away, provide some more details, or ask the question differently.

I'd be glad to do so, but I'm afraid I can't :) I didn't write neither the original code, nor the patched one.
As to why we don't get our answer, I just think the people who knows it just aren't aware of this topic... I'm not sure there's more we can do.
Arch. / Kalith
User avatar
Archangel
Regular
 
Posts: 120
Joined: Sun Dec 19, 2004 6:02 pm
Location: Nantes, France

Re: 1.6.0 upgrade hardware skinning shaders problem

Postby sinbad » Wed Dec 23, 2009 11:20 am

I'm on this.
User avatar
sinbad
OGRE Founder, Ex-Lead
OGRE Founder, Ex-Lead
 
Posts: 25646
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands

Re: 1.6.0 upgrade hardware skinning shaders problem

Postby sinbad » Wed Dec 23, 2009 12:17 pm

Fixed: http://ogre.svn.sourceforge.net/viewvc/ ... ision=9459
Fix HLSL skinning with 3x4 matrices
This was broken by fixes to cope with matrices declared as 4x4 but which ended up being physically 3x3 or similar because of use in the shader (compiler optimised); that's why RegisterCount is used and not row/column definition directly. However the RegisterCount is multiplied by the array size which was throwing off the switch. Also made it deal with column/row major matrices.
User avatar
sinbad
OGRE Founder, Ex-Lead
OGRE Founder, Ex-Lead
 
Posts: 25646
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands

Re: 1.6.0 upgrade hardware skinning shaders problem

Postby sinbad » Wed Dec 23, 2009 12:23 pm

Oh, bear in mind your example was incorrect too, you were missing
Code: Select all
  column_major_matrices false

.. in the HLSL program definition (required to use 3x4 matrices in HLSL since it transposes matrices compared to every other system normally).
User avatar
sinbad
OGRE Founder, Ex-Lead
OGRE Founder, Ex-Lead
 
Posts: 25646
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands

Re: 1.6.0 upgrade hardware skinning shaders problem

Postby Archangel » Wed Dec 23, 2009 12:48 pm

Super sinbad to the rescue !
Thank you ;)

Edit : tested and approved.
Arch. / Kalith
User avatar
Archangel
Regular
 
Posts: 120
Joined: Sun Dec 19, 2004 6:02 pm
Location: Nantes, France

Re: 1.6.0 upgrade hardware skinning shaders problem

Postby sinbad » Wed Dec 23, 2009 1:56 pm

For future reference, don't assume I read every forum post, because I don't have time for that anymore. If something looks like a bug, and is confirmed by others, especially experienced members of the community, raise a bug in the tracker. I do prefer that people discuss things in the forum first to avoid raising any false-positives and to avoid splitting discussion (it's better that the forum is a master reference of discussions on what might be user error or bug), but if it's looking confirmed and you don't know how to fix it (so not a patch), please raise a bug.

In this case the issue was well stated and I could reproduce it quickly, which is precisely what we need from a bug report.
User avatar
sinbad
OGRE Founder, Ex-Lead
OGRE Founder, Ex-Lead
 
Posts: 25646
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands

Re: 1.6.0 upgrade hardware skinning shaders problem

Postby oiram » Thu Dec 24, 2009 5:19 am

Thanks sinbad. It works fine with your update.
I'll raise bug report if I found something wrong in the future.

Archangel, give me five. :wink:
oiram
Newcomer
 
Posts: 18
Joined: Sun Dec 13, 2009 5:06 am


Return to Help

Who is online

Users browsing this forum: Chris Jones, jacmoe, NQ, Yahoo [Bot] and 11 guests