[SlimDX] HLSL annotations.

Started by
3 comments, last by user88 14 years, 1 month ago
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.
Advertisement
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.
It might be a bug. I've recorded this as issue 641 in our tracker and will take a look at it when I can.
I've just committed a fix that should sort it out, hopefully.
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.
Good work guys, Thanx

This topic is closed to new replies.

Advertisement