Jump to content

  • Log In with Google      Sign In   
  • Create Account


Two vertexShader cannot function simultaneously

  • You cannot reply to this topic
5 replies to this topic

#1 xxl534   Members   -  Reputation: 101

Like
0Likes
Like

Posted Yesterday, 08:15 PM

     I have stayed up for this problem,but it is unsolved.

     I load a D3DXFrame from an X file,Scan the D3DXFrame hierarchy and render the mesh if there is one.I have two vertexShader:p_vs_Skinning for the mesh-with-SkinInfo and p_vs_simple for the mesh-without-SkinInfo.There's no compile error or running-time error,two vertexShader perform perfect when running seperately.However, when they are simultaneously running,the p_vs_simple has no effect.Actually they were not literally simultaneous.they are in different parts of if-else branch.When I render mesh-without-SkinInfo through fixed pipeline ,it works well.When I bypass if branch,the vertexShader works.

     Here's part of code,boneMesh is a derived class of D3DXMeshContainer,I've omitted large part of irrelevant content.Virtually I don't think the trouble is in the code.

              if((boneMesh->pSkinInfo!=NULL))
		{

			for (int i = 0; i < boneMesh->numAttributeGroups; i++)
			{
				int mtrl=boneMesh->attributeTable[i].AttribId;
				p_Device->SetMaterial(&(boneMesh->materials[mtrl]));
				p_Device->SetTexture(texIndex,boneMesh->textures[mtrl]);
				
				p_Device->SetVertexShader(p_vs_Skinning);
				p_Device->SetPixelShader(p_ps_Simple);
				boneMesh->MeshData.pMesh->DrawSubset(mtrl);				
			}
		}
		else 
		{
			
			for (int i = 0; i < boneMesh->NumMaterials; i++)
			{
				p_Device->SetMaterial(&(boneMesh->materials[i]));
				p_Device->SetTexture(texIndex,boneMesh->textures[i]);

				p_Device->SetVertexShader(p_vs_Simple);
			        p_Device->SetPixelShader(p_ps_Simple);

				boneMesh->MeshData.pMesh->DrawSubset(i);
			}
		}


Sponsor:

#2 Buckeye   Crossbones+   -  Reputation: 2624

Like
0Likes
Like

Posted Yesterday, 08:56 PM

It's not entirely clear what your situation is from your description.

 

However, do these remarks in the docs apply?

 

To set a fixed-function vertex shader (after having set a programmable vertex shader), call IDirect3DDevice9::SetVertexShader(NULL) to release the programmable shader, and then call IDirect3DDevice9::SetFVF with the fixed-function vertex format.

 

 

I've not used SetVertexShader so I can't speak from experience (I use effects). However, it may be that you also have to release one vertex shader before setting and using another.


Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.


#3 mhagain   Crossbones+   -  Reputation: 6345

Like
0Likes
Like

Posted Today, 02:46 AM

I don't use the Mesh interfaces, but otherwise the code you've posted should work (I'd move the Set*Shader calls outside of the for loops, though).  There's nothing in raw D3D to prevent it.

 

The possibility is that one or both of your shaders has failed to compile; have you run this in the debugger and checked that the shaders are non-NULL?

 

Your SetMaterial calls are useless, by the way: these relate to the fixed-pipeline lighting engine, which is switched off when using vertex shaders.


It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.


#4 Hodgman   Moderators   -  Reputation: 24033

Like
0Likes
Like

Posted Today, 04:00 AM

Does it matter that one loop uses DrawSubset(mtrl) while the other uses DrawSubset(i)?

#5 ankhd   Members   -  Reputation: 932

Like
0Likes
Like

Posted Today, 07:02 AM

do you update the meshes frame hierarchy



#6 xxl534   Members   -  Reputation: 101

Like
0Likes
Like

Posted Today, 11:46 AM

Thanks , I've tried to do so,but didn't make any difference.

It's not entirely clear what your situation is from your description.

 

However, do these remarks in the docs apply?

 

To set a fixed-function vertex shader (after having set a programmable vertex shader), call IDirect3DDevice9::SetVertexShader(NULL) to release the programmable shader, and then call IDirect3DDevice9::SetFVF with the fixed-function vertex format.

 

 

I've not used SetVertexShader so I can't speak from experience (I use effects). However, it may be that you also have to release one vertex shader before setting and using another.







PARTNERS