#ifdef-Code generated by Static Switch

Node-based Shader Editor

#ifdef-Code generated by Static Switch

Postby Catalystc-NG » Mon Mar 26, 2018 5:20 pm

Hi!

Is there any hope for an implementation of the Static Switch, that would handle the #ifdef / #else -scopes generated like in the image that has been attached to this post? (Please see the image)

Currently the Static Switch is generating code that will only enable the selection of two different data-paths, while they both still get calculated, which can certainly be useful, but not sufficiently so, if you would like to enable/disable certain features of your shader per material, and so avoid extra calculations where they might be useless.

I know that the example in the image is completely imaginary for usefulness, but I tested it in a real world case as well, with proper features being enabled/disabled - and it does the same thing. The generated code calculates *everything* to be ready for either data-path, but only #ifdef:s the final decision between which data to use, which does not optimize the code at all. :cry:
Attachments
ASESwitchExample.png
ASESwitchExample.png (121.32 KiB) Viewed 1464 times
Catalystc-NG
 
Posts: 2
Joined: Mon Mar 26, 2018 5:08 pm

Re: #ifdef-Code generated by Static Switch

Postby Amplify_Borba » Mon Mar 26, 2018 5:34 pm

Hello, thank you for getting in touch and for your support!

In this situation, the compiler is smart enough to actually not run the code that is outside of the if scope, you may test this if you compile both versions and compare the results.

Please let me know if you have any further questions, thanks!
Customer Relations at Amplify Creations
Learn more about our offering: Amplify Creations Products
Amplify Shader Editor won the Asset Store Best Tool Award - Thank you for your support!
User avatar
Amplify_Borba
 
Posts: 1239
Joined: Mon Jul 24, 2017 9:50 am

Re: #ifdef-Code generated by Static Switch

Postby Catalystc-NG » Mon Mar 26, 2018 6:59 pm

Hey!
Thanks for a super quick reply - you guys are pretty much on top of the game when it comes to customer service too!

Very nice to hear that this is a non-problem because of the compiler taking the whole shader in to the #ifdef -consideration!

Thanks again!
Catalystc-NG
 
Posts: 2
Joined: Mon Mar 26, 2018 5:08 pm

Re: #ifdef-Code generated by Static Switch

Postby Amplify_Borba » Tue Mar 27, 2018 10:56 am

No problem, glad to be of assistance, and thank you for the kind words!

Please don't hesitate to get back in touch if you have any further questions.
Customer Relations at Amplify Creations
Learn more about our offering: Amplify Creations Products
Amplify Shader Editor won the Asset Store Best Tool Award - Thank you for your support!
User avatar
Amplify_Borba
 
Posts: 1239
Joined: Mon Jul 24, 2017 9:50 am

Re: #ifdef-Code generated by Static Switch

Postby Ziboo » Thu Apr 05, 2018 7:55 pm

Would it does the same thing for Shader Feature Keyword ?
The compiler would move all instructions in the ifdef block, or just the end path ?

Thanks
Ziboo
 
Posts: 1
Joined: Thu Apr 05, 2018 6:44 pm

Re: #ifdef-Code generated by Static Switch

Postby Amplify_Borba » Fri Apr 06, 2018 10:19 am

Hello! It's not a matter of moving the code, the compiler is simply aware of which code it's going to be used, be it within a shader feature or not.

In other words, it knows which code is going to be executed and only compiles that.
Customer Relations at Amplify Creations
Learn more about our offering: Amplify Creations Products
Amplify Shader Editor won the Asset Store Best Tool Award - Thank you for your support!
User avatar
Amplify_Borba
 
Posts: 1239
Joined: Mon Jul 24, 2017 9:50 am


Return to Amplify Shader Editor

Who is online

Users browsing this forum: No registered users and 0 guests