Sign in to follow this  
user88

[SlimDX] HLSL annotations.

Recommended Posts

Hi. I have a code that working with error after migration my projects from MDX to SlimDX. I have some hlsl technique:
technique t1
{
    pass p0
    <
	bool ClearRT = true;
    >
    {
        VertexShader = compile ps_3_0 VS();
        PixelShader = compile ps_3_0 PS();
    }
}


there is some mechanism: if property of some class has [PassParameter] attribute then that property is manages from HLSL come automatically. the application code:
...
// obtain all properties that manages from effect
void ObtainAllManagedProperties()
{
   TechniqueDescription desc = Effect.GetTechniqueDescription(Technique);
   PropertyInfo[] properties = GetType().GetProperties();
   m_mapPassToPassParameters.Clear();
   var passParameters = new List<PassParameter>();
   for (int p = 0; p < desc.Passes; p++)
   {
      passParameters.Clear();
      EffectHandle passHandle = Effect.GetPass(Technique, p);

      foreach (PropertyInfo property in properties)
      {
         object[] attributes = property.GetCustomAttributes(typeof(PassParameterAttribute), false);
         if (attributes.Length <= 0) continue;

         EffectHandle annotation = Effect.GetAnnotation(passHandle, property.Name);
         if (annotation == null) continue;

         PassParameter parameter = new PassParameter(this, p, annotation, property);
         passParameters.Add(parameter);
      }
      m_mapPassToPassParameters.Add(p, passParameters.ToArray());
   }
}

...

public bool Read()
{
   try
   {
      switch (Type.Name)
      {
         case "Boolean" : Value = PostProcess.Effect.GetValue<bool>(Annotation); break; // error happens here!!!!! note, Annotation is not null.
         case "Single": Value = PostProcess.Effect.GetValue<float>(Annotation); break;
         case "String": Value = PostProcess.Effect.GetString(Annotation); break;
         case "Vector4": Value = PostProcess.Effect.GetValue<Vector3>(Annotation); break;
       }

       Property.SetValue(PostProcess, Value, null);
    }
    catch 
    {
       Debug.Assert(false);
       return false;
    }

    return true;
}


as you see there is annotation to pass p0 which indicate to clear render target before begin that pass. So, i get an error when try to read "ClearRT" annotation. There is no any information in debug log. Error: D3DERR_INVALIDCALL: Invalid call (-2005530516) Note that this worked good with MDX.

Share this post


Link to post
Share on other sites
I have found out that problem is in bool type. Annotation was successfully read after changed its type.

*** Example with error:

Application code

...
Value = Effect.GetValue<bool>(Annotation);
...



Effect code:

...
technique T1
{
pass p0
<
bool ClearRT = true;
>
{
VertexShader = compile vs_3_0 VS();
PixelShader = compile ps_3_0 PS();
}
}




*** Example without error:

Application code

...
Value = Effect.GetString(Annotation);
...



Effect code:

...
technique T1
{
pass p0
<
string ClearRT = "true";
>
{
VertexShader = compile vs_3_0 VS();
PixelShader = compile ps_3_0 PS();
}
}




Why i get error in first example? Thanks in advice.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this