This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How Vertex Buffer And VTF affect VertexShader LS?

Hell Arm,

Recently I use Malioc to analyze UE4 Niaggara Particle System Related Shader on ES31,  and I have some confuse aboout how vertex attritubes affect VertexShader LS.

The Vertex Shader which used for Niaggara Particle Sprite have too many texelFetch on VS which cause T Bounded and stack spiling on Mali-G71, The VS code is here,     

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#version 310 es
#ifdef GL_EXT_texture_buffer
#extension GL_EXT_texture_buffer : enable
#endif
#define HLSLCC_DX11ClipSpace 1
// end extensions
void compiler_internal_AdjustInputSemantic(inout vec4 TempVariable)
{
#if HLSLCC_DX11ClipSpace
TempVariable.y = -TempVariable.y;
TempVariable.z = ( TempVariable.z + TempVariable.w ) / 2.0;
#endif
}
void compiler_internal_AdjustOutputSemantic(inout vec4 Src)
{
#if HLSLCC_DX11ClipSpace
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Malioc Reports,

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Mali Offline Compiler v7.5.0 (Build 30e352)
Copyright 2007-2022 Arm Limited, all rights reserved
Configuration
=============
Hardware: Mali-G71 r0p1
Architecture: Bifrost
Driver: r36p0-00rel0
Shader type: OpenGL ES Vertex
Main shader
===========
Position variant
----------------
Work registers: 64
Uniform registers: 128
Stack spilling: 16 bytes
16-bit arithmetic: 0%
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

So, I make a litte test which I use generic Read Particle Data from Vertex Buffer replacing of VTF.  Modied code is here,

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#version 310 es
#ifdef GL_EXT_texture_buffer
#extension GL_EXT_texture_buffer : enable
#endif
#define HLSLCC_DX11ClipSpace 1
// end extensions
void compiler_internal_AdjustInputSemantic(inout vec4 TempVariable)
{
#if HLSLCC_DX11ClipSpace
TempVariable.y = -TempVariable.y;
TempVariable.z = ( TempVariable.z + TempVariable.w ) / 2.0;
#endif
}
void compiler_internal_AdjustOutputSemantic(inout vec4 Src)
{
#if HLSLCC_DX11ClipSpace
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

 Malioc Reports It's better than VTF version,

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Mali Offline Compiler v7.5.0 (Build 30e352)
Copyright 2007-2022 Arm Limited, all rights reserved
Configuration
=============
Hardware: Mali-G71 r0p1
Architecture: Bifrost
Driver: r36p0-00rel0
Shader type: OpenGL ES Vertex
Main shader
===========
Position variant
----------------
Work registers: 50
Uniform registers: 128
Stack spilling: false
16-bit arithmetic: 0%
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

But VS just has 7 layout in_Attributes and LS seems larger than expected. So I did more test , then I found when I delete the 

CalculateHeightFog part code, the LS became better. Position Variant LS also became 7 from 14 which I confuse that CalculateHeightFog is not affect Position Variant.
whiout CalculateHeightFog  VS Code and Malioc Reposrts,
Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#version 310 es
#ifdef GL_EXT_texture_buffer
#extension GL_EXT_texture_buffer : enable
#endif
#define HLSLCC_DX11ClipSpace 1
// end extensions
void compiler_internal_AdjustInputSemantic(inout vec4 TempVariable)
{
#if HLSLCC_DX11ClipSpace
TempVariable.y = -TempVariable.y;
TempVariable.z = ( TempVariable.z + TempVariable.w ) / 2.0;
#endif
}
void compiler_internal_AdjustOutputSemantic(inout vec4 Src)
{
#if HLSLCC_DX11ClipSpace
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Hardware: Mali-G71 r0p1
Architecture: Bifrost
Driver: r36p0-00rel0
Shader type: OpenGL ES Vertex
Main shader
===========
Position variant
----------------
Work registers: 47
Uniform registers: 128
Stack spilling: false
16-bit arithmetic: 0%
A LS T Bound
Total instruction cycles: 21.33 7.00 0.00 A
Shortest path cycles: 8.50 7.00 0.00 A
Longest path cycles: 15.93 7.00 0.00 A
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

So, I just want to ask

1. why calculate heigh fog affect LS even if the Position Variant?

2. "if.. else.." Branching seems like do not affect vertex buffer Loading but can braching TexelFetch(), Is it possible that I can slot some optional data like "custom facing", "custom aligning" using TexBuffer to optimize the shortest path?

0