Villacaleb / slimdx

Automatically exported from code.google.com/p/slimdx
MIT License
0 stars 0 forks source link

D3D9 Macro problem #724

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hi.

Firstly sorry for my bad english : )

I'm using SlimDX June 2010. I'm working on my own big project and stucked with 
one problem. When i use EffectCompiler to call "CompileShader(...)", shaders 
compiles incorrect! I've spend about week to figuring out what caused  shader 
corruption - my HLSL code seems to be correct.

I googled my problem and found  code like that (for C++)

  // собираем макросы
  std::vector<D3DXMACRO> MacroVect;
  ShaderMacroContainer::DefinesMap::const_iterator macro_it = Desc.Macro.Defines.begin();
  while (macro_it != Desc.Macro.Defines.end())
  {
    D3DXMACRO NewDefine;
    NewDefine.Name = macro_it->first.c_str();
    NewDefine.Definition = macro_it->second.c_str();
    MacroVect.push_back(NewDefine);
    macro_it++;
  }
  D3DXMACRO EndDefine;
  EndDefine.Name = NULL;
  EndDefine.Definition = NULL;
  MacroVect.push_back(EndDefine)

so at the end of MACRO list we should add"null" element 
(  
  EndDefine.Name = NULL;
  EndDefine.Definition = NULL;
)

But if I'm trying to do that in C#:

macro[macro.Length - 1].Definition = null;
macro[macro.Length - 1].Name = null;

I'm catching this exception:

"Ссылка на строку не ссылается на экземпляр 
String.
Имя параметра: s"

 - something like:

"The reference to the string does not refer to an instance of String.
Parameter name: s "

Original issue reported on code.google.com by i.prog...@gmail.com on 9 Oct 2010 at 9:48

GoogleCodeExporter commented 9 years ago
You don't need to manually add the null macro at the end in SlimDX, as we do 
this for you. You should only need to pass the actual macros you want to use to 
Effect.FromMemory or whatever you are calling.

Original comment by josh.petrie on 4 Dec 2010 at 10:00