Jump to content

View more

Image of the Day

雑魚は多めにして、爽快感重視にしつつ・・・(´・ω・`)
早いとこ、ベースを作って、完成にもっていかないとね。
タイトルもまだ迷ってるだよなぁ。 
#indiedev  #indiegame #screenshotsaturday https://t.co/IwVbswGrhe
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

Passing macros to shader during compilation

4: Adsense

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
2 replies to this topic

#1 maxest   Members   

614
Like
0Likes
Like

Posted 15 May 2012 - 10:29 AM

I use D3DX11CompileFromFileA to compile my shader. Now I want to add some macros to it. But not macros like:
#define USE_FEATURE_A
but
#define LOOP_ITERATIONS 16
So, speaking shortly, I want to pass a macro *with* a value so that my shader can, for instance, nicely unroll a loop for which I know a number of iterations upfront. I don't want to declare such a define in the shader directly, because the shader does not have this numeric information - application, right before it compiles the shader, nows.

I tried something like:
D3D10_SHADER_MACRO macros[2];
macros[0].Definition = "LOOP_ITERATIONS";
macros[0].Name = "16";
macros[1].Definition = macros[1].Name = NULL;
or:
D3D10_SHADER_MACRO macros[2];
macros[0].Definition = "LOOP_ITERATIONS 16";
macros[0].Name = "";
macros[1].Definition = macros[1].Name = NULL;
but none of this works. Any idea?

On a side note: what's the purpose of macro's Name anyway?

#2 belfegor   Members   

2833
Like
2Likes
Like

Posted 15 May 2012 - 10:44 AM

Should it be oposite?
this:
macros[0].Definition = "16";
macros[0].Name = "LOOP_ITERATIONS";

instead:
macros[0].Definition = "LOOP_ITERATIONS";
macros[0].Name = "16";



#3 maxest   Members   

614
Like
0Likes
Like

Posted 15 May 2012 - 10:51 AM

Oh, boy... It's funny that in my other renderer I used "Name" field correctly, leaving Definition as an empty string, and here I thought that Definition is actually the name of the macro. What a confusion... Thank you very much :).




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.