Jump to content

  • Log In with Google      Sign In   
  • Create Account

Easier way then 'GetParameterElement'?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

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

#1 cozzie   Members   -  Reputation: 1613

Like
0Likes
Like

Posted 19 February 2013 - 04:25 PM

Hi,

 

I'm trying to set float arrays to my HLSL parameter arrays.

Example:

 

The fx/effect file:

#define MaxPointLights 2

float3		PointLightPos[MaxPointLights];

In my code (C++) I achieve the expected resulted one of these 2 ways:

 

// one way

mEffect->SetFloatArray("PointLightPos[0]", myfloatarray, 3);

// another way

D3DXHANDLE param = mEffect->GetParameterElement("PointLightPos", 0);
mEffect->SetFloatArray(param, myfloatarray, 3);


Both ways work, where the 2nd is the most flexible (in the 1st one I need for hard code "PointLightPos[0]", [1] etc (or make a D3DXHANDLE adding strings etc.).

 

My question;

Is the 2nd option I do the best one, or is there a better/ easier way to set the element of a parameter in a d3dxeffect?

 



Sponsor:

#2 Jason Z   Crossbones+   -  Reputation: 5062

Like
0Likes
Like

Posted 19 February 2013 - 05:39 PM

The second one is better as long as you cache the handle to the parameter.  You are essentially looking up the text based name of the parameter, so if you only do that once at startup, and then set the value with the handle thereafter, then you should be doing very well from an efficiency standpoint.



#3 cozzie   Members   -  Reputation: 1613

Like
0Likes
Like

Posted 20 February 2013 - 12:23 PM

Thanks.
What i could do then is use one and the same handle for static lights, set to the effect once at initial setup. And for dynamic lights save all d3dxhandles in my light class. Wouldn't the needed memory for that take away the advantage?

For example, one point light would need 5 different d3dxhandles.
On the other hand the number of dynamc lights is relatively low and i could do it with a dynamic array, only created for objects of my light class, where dynamic==true.

#4 Jason Z   Crossbones+   -  Reputation: 5062

Like
0Likes
Like

Posted 20 February 2013 - 09:59 PM

IIRC, the handle is just a single integer value that maps easily to the handle.  You won't see any negative performance effects due to the usage of the handles - back in my D3D9 engine I did the exact same thing that we are discussing and it was perfectly fine.



#5 cozzie   Members   -  Reputation: 1613

Like
0Likes
Like

Posted 21 February 2013 - 05:16 AM

thanks, will implement it






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS