Jump to content
  • Advertisement
Sign in to follow this  
user88

[SlimDX] HLSL annotations.

This topic is 3011 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!