Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
2
Question by Jessy · Jan 02, 2010 at 09:30 PM · shaderiphonecustom-shader

Why do Zwrite, Ztest, and Colormask simplifications not optimize shader performance?

I figured that it would make my shaders run faster if I tried optimizing the rendering when possible. Some of these supposed optimizations have been...

Zwrite Off
Ztest Always
Colormask RGB

But none of them seem to have any positive impact. On my MacBook Pro, there isn't any negative impact, either.

However, I found that using Colormask RGB is 20-40% SLOWER than using standard RGBA on my iPod touch.

If you're trying to use the Geometry Queue, using Zwrite Off/Ztest Always is slower than not using them, which makes sense, given the Tile-Based Deferred Rendering. (I don't even know if your shader still uses the Geometry queue if you use these commands.) However, if you don't have overlapping objects, I would think these two commands should have a benefit, but they don't seem to.

So why are these commands not helpful? It would make sense to me that the shader could run faster if the GPU has to do less work.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

3 Replies

· Add your reply
  • Sort: 
avatar image
3
Best Answer

Answer by Aras · Jan 07, 2010 at 08:02 PM

Turning writes/tests on or off can affect performance in a positive or negative way. Turning color writes off (completely), for example, can speed up rendering a lot - but only if the rendering was the bottleneck!

In other words, maybe the bottleneck is somewhere entirely else? E.g. you're limited by the CPU?

As a side note, turning off Alpha writes but leaving RGB writes on is never an optimization. The GPU still writes more or less "complete pixels", just leaves alpha untouched. iPhone has quite quirky architecture where it can even be slower (another iPhone specific quirk: alpha blending is faster than alpha testing - on most other platforms it's the other way around).

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Jessy · Jan 08, 2010 at 12:18 AM 0
Share

Do you recommend, then, using Zwrite Off, and Ztest Always, when you know there will never need to be a Ztest? Or do you recommend leaving them out, considering it makes no noticeable difference, cleans up the shader code ever so slightly, and requires less thought and typing?

avatar image Aras ♦♦ · Jan 08, 2010 at 07:46 AM 0
Share

On a PC, if you know you don't need it, then turning ZWrite Off should be a win. If the object or part of it can be occluded by already rendered opaque stuff, then leaving ZTest untouched should be better (the GPU will skip computing pixel shader for pixels that are surely occluded).

I'm not sure about the iPhone. It's a non-standard rendering architecture and I don't know whether turning ZWrite Off is actually an advantage or not.

avatar image
2

Answer by duck · Jan 07, 2010 at 11:05 AM

I think your problem is that these features aren't actually supposed to be used as optimisations. They are there as features, to allow you more flexibility when designing your shaders, and to allow you to achieve effects that you wouldn't be able to if they didn't exist.

So, while your hunch may be that certain settings might offer improved performance, that is not the main purpose of these features, and the inner workings of the GPU and the shader compiler is a complicated beast - there is already so much optimisation going on under the hood that it's difficult to guess whether certain features actually cause less or more work for the GPU!

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
1

Answer by DerWoDaSo · Jan 07, 2010 at 10:29 AM

I did a quick test and came to the same result. Colorwrite setting has not impact and turning off ZWrite and/or setting ZTest to Always slows down the framerate (because more polygones are drawn). For non-overlapping objects the performance stays always the same...

So why are these commands not helpful? It would make sense to me that the shader could run faster if the GPU has to do less work.

I am not sure about this, but perhaps the writing and checking of the ZBuffer is a dedicated pipeline stage and lies idle if there is nothing to do?

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

No one has followed this question yet.

Related Questions

Toon Shader for the iPhone 1 Answer

What, exactly, in a shader, stops batching from happening? 2 Answers

What shader blending modes don't work on iOS? 1 Answer

VertexLit Hilight Shader - Flicker on iOS Problem 1 Answer

What is the capability of ShaderLab's LightmapMode tag? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges