Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 seobyeongky · Jun 08, 2016 at 10:29 AM · shaderprofilergpu

What is this shader?

I profiled my game using Mali Graphics Debugger 3.5. And found out, One shader is costing a lot of unexpected cycles. I don't know what is this shader, and why so much heavy. It is 86 shader in the picture.

alt text

It is called at the end of frame. (last draw call)

Here is the function call.

 glDrawElements
 (
     mode = GL_TRIANGLES, 
     count = 3, 
     type = GL_UNSIGNED_SHORT, 
     indices = NULL
 )

Uniforms

 Index / Location / Name           /       Type     /  Value
 0     /   0      /   tex            / GL_SAMPLER_2D / [0] 
 1     /   1      / uvOffsetAndScale / GL_FLOAT_VEC4 / [0.0, 0.0, 1.0, 1.0]

Vertices

 0      -1.0, 3.0, 0.0, 2.0
 1      -1.0, -1.0, 0.0, 0.0
 2      3.0, -1.0, 2.0, 0.0

Indices

 [0, 1, 2]

So, It is a single triangle, That covers whole perspective coordniates.

alt text

And the fragment count is equal to screen.width * screen.height.

I deleted every my rendered objects but this shader is steel running(even disabled the camera).

Vertex shader code

 #version 300 es
 #define ATTRIBUTE_IN in
 #define VARYING_IN in
 #define VARYING_OUT out
 #define DECLARE_FRAG_COLOR out vec4 fragColor
 #define FRAG_COLOR fragColor
 #define SAMPLE_TEXTURE_2D texture

 precision highp float;
 ATTRIBUTE_IN vec4 vertex;
 uniform vec4 uvOffsetAndScale;
 VARYING_OUT vec2 texCoord;
 void main()
 {
     gl_Position = vec4(vertex.xy, 0.0, 1.0);
     texCoord = vertex.zw * uvOffsetAndScale.zw + uvOffsetAndScale.xy;
 }

Fragment shader code

 #version 300 es
 #define ATTRIBUTE_IN in
 #define VARYING_IN in
 #define VARYING_OUT out
 #define DECLARE_FRAG_COLOR out vec4 fragColor
 #define FRAG_COLOR fragColor
 #define SAMPLE_TEXTURE_2D texture

 precision mediump float;
 VARYING_IN vec2 texCoord;
 #ifdef DECLARE_FRAG_COLOR
     DECLARE_FRAG_COLOR;
 #endif
 uniform sampler2D tex;
 void main()
 {
     vec4 c = SAMPLE_TEXTURE_2D(tex, texCoord);
     FRAG_COLOR = vec4(c.rgb, 1.0);
 }




Thank you.

---------------- Additonal Info -----------------

So I created a new Unity project.(Unity 5.3.4f) Here is what i have done.

  • Add single empty scene to "Scenes in build" list.

  • Set zero "Always Included Shaders" and "Preloaded Shaders" in the GraphicsSettings.

  • Set android bundle ID in the PlayerSettings.

  • Add libMGD.so and custom Activity to load the libMGD.so file. (to connect with Mali Graphic Debugger. This step may make side effects. But this unrecognized shading is occured at Galaxy S4 device with Adreno GPU Profiler)

  • Build android apk and install it to my Galaxy S6 device.

And the result is same. The shader steel running. In this time it, There is only Unity Logo in the screen, And not disappear, becuase there is no camera.

Here is draw calls of whole frames.

Frame 0 ~ Frame 2 (9 vertices, 5 draws, )

First Render Pass

  • glClear

  • glClear GL_DEPTH_BUFFER_BIT

  • glDrawElements 6 vertices, no indices

Secnd Render Pass

  • glClear

  • glDrawElements 3 vertices, 3 indices -> It is the shader of this question.

    Frame 3 (30243 vertices, 15 draws)

First Render Pass

  • glClear

  • glClear GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT

  • glDrawArrays 5040 vertices

  • glClear GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT

  • glDrawArrays 5040 vertices

  • glClear GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT

  • glDrawArrays 5040 vertices

  • glClear GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT

  • glDrawArrays 5040 vertices

  • glClear GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT

  • glDrawArrays 5040 vertices

  • glClear GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT

  • glDrawArrays 5040 vertices

Second Render Pass

  • glClear

  • glDrawElements 3 vertices

    Frame 4 ~ end of frame

First Render Pass

  • glClear

  • glDrawElements 3 vertices

So the shader is running every frames.

Additonally, at the frame 3, the app draws sphere that has dense vertices near the equator with 5040 vertices 6 times. I don't know what it is, But it would be necessary for Unity engine system I guess??

aaa.png (68.9 kB)
bbb.png (11.0 kB)
Comment
Add comment · Show 6
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 tanoshimi · Jun 08, 2016 at 06:47 PM 0
Share

Curious. You get this even with no camera or rendered objects in your scene. No UI? No Graphics.Draw$$anonymous$$esh? No image effects or RenderTextures? Can't think why you've got a full screen shader otherwise, but interested to know if you find out. +1 for well-researched question too :)

avatar image Dave-Carlile · Jun 08, 2016 at 06:56 PM 0
Share

Complete stab in the dark, but something to do with deferred rendering maybe?

avatar image seobyeongky · Jun 09, 2016 at 02:21 AM 0
Share

I disabled all deferred supports at GraphicsSettings and tested with "Forward" and "Legacy Vertex-lit" rendering mode at PlayerSettings but the result is same.

avatar image SumFortyOne · Jun 09, 2016 at 03:00 AM 0
Share

Sorry, not an expert on shaders here, but my first thought is the procedural skybox shader maybe? "sphere that has dense vertices near the equator" sounds kind of like that to me. 6x for the cubemap effect?

Do you have the default skybox in the lighting settings?

avatar image seobyeongky SumFortyOne · Jun 09, 2016 at 08:28 AM 0
Share

You were right. The sphere was Skybox. I changed Ambient Source to Skybox to Color And the sphere render call is gone. Unfortunately the issue steel exists.

avatar image seobyeongky · Jun 09, 2016 at 03:20 AM 0
Share

I re-captured with adreno profiler, and found something. This shader draws entire screen. Unity camera draws to render buffer and finally this shader draws complete rendered scene "again" to another back buffer.

1 Reply

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

Answer by seobyeongky · May 23, 2017 at 05:28 AM

I found it.

https://forum.unity3d.com/threads/big-performance-issue-with-unity5-on-android.338847/

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

RenderTexture.GrabPixels slowdown - How to fix? 0 Answers

Is it possible to profile compute shaders? 2 Answers

How to know if my game is CPU or GPU bounded without GPU Profiler module. 1 Answer

Using the GPU instead of multiple threads 1 Answer

(Bilboard Shader) Max Screen Size 0 Answers


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