Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compile *.comp with glslang optimizations enabled (-Os) #1117

Closed

Conversation

sharkautarch
Copy link

It seems that glslang doesn't actually do any optimizations by default.
I compared the cs_composite_*.h file sizes between gamescope built from ValveSoftware/gamescope/master, and gamescope built with a modification to src/meson.build where I added -Od to glslang's args
And the file sizes with or without -Od turned out to be the same...

Oddly enough, glslang only lets you specify -Os or -Od, not sure why...

I exclude one shader from optimization: cs_composite_rcas.comp
because I had noticed that if optimization was enabled for cs_composite_rcas.comp, it would take longer for gamescope to startup when running w/ fsr (also, it seems like that specific shader's .h output file would balloon in size w/ -Os)

@misyltoad
Copy link
Collaborator

FWIU, glslang optimizations are pretty worthless, the majority of the good stuff comes from the driver.

@sharkautarch
Copy link
Author

sharkautarch commented Jan 30, 2024

FWIU, glslang optimizations are pretty worthless, the majority of the good stuff comes from the driver.

From some testing with running gamescope on my integrate intel igpu (Intel Alder Lake-P GT2 [Iris Xe Graphics]), it seems like glslang seems to be able to make some optimizations that the driver might be lacking...
I ran a gpuvis-trace of a gamescope nested session w/

  • ValveSoftware/gamescope/master
  • glslang -Os optimizations

where I ran the same exact command for both: ./gamescope -W 1920 -H 1200 -w 992 -h 620 -F pixel -- vkcube
and found that the minimum paintall time for ValveSoftware/gamescope/master was around 3.25ms,
whereas the minimum paintall time for glslang -Os was around 3.1ms.
And overall, it seemed like paintall for glslang -Os was about 0.1 to 0.2 ms faster.

Maybe some drivers implement more shader optimizations than others?
Also maybe it might only be noticeable when using gamescope to do upscaling, maybe even where it is only noticeable with specific upscaling algorithms like the pixel one???

w/o -Os :
gamescope-no-glsl-opt

w/ -Os:
gamescope-glsl-opt

also more specs for my laptop I tested this on:

CPU: 14-core (6-mt/8-st) 12th Gen Intel Core i7-12700H (-MST AMCP-)
speed/min/max: 426/400/4600:4700:3500 MHz Kernel: 6.6.10-arch1-1 x86_64
vulkan-intel 1:23.3.3-1
mesa 1:23.3.3-1

@misyltoad
Copy link
Collaborator

misyltoad commented Feb 2, 2024

3.1ms seems extraordinarily slow for the composite shader, but what you are reporting seems kinda margin of error given it looks like n = 1 in your testing.

If you disable the 1D + 3D LUT stuff going on, does it make it faster on Intel?

(Just comment it out)

@sharkautarch
Copy link
Author

sharkautarch commented Feb 2, 2024

3.1ms seems extraordinarily slow for the composite shader, but what you are reporting seems kinda margin of error given it looks like n = 1 in your testing.

If you disable the 1D + 3D LUT stuff going on, does it make it faster on Intel?

(Just comment it out)

Ok:
I've retested gamescope w/ one trial run with latest upstream gamescope/master and one trial run with the 1D + 3D LUT stuff commented out

Here's the branch I'm running for testing running gamescope w/ 1D + 3D LUT commented out (in case I messed something up) : https://github.com/sharkautarch/gamescope/tree/test_w_no_lut
Same command for running gamescope as before, and for all of these runs, I've been running gamescope with cap_sys_nice=eip perms.

gamescope/master:
gpuvis_gamescope_vanilla

1D + 3D LUT commented out:
gpuvis_gamescope_no_lut

EDIT: I did another test where I removed a conditional from apply_layer_color_mgmt():
https://github.com/sharkautarch/gamescope/tree/color-mgmt-removed-condition
gpuvis:
gamescope-color-mgmt-removed-condition

@misyltoad
Copy link
Collaborator

Where's the GPU submit on your graph?

@sharkautarch
Copy link
Author

Where's the GPU submit on your graph?

If by GPU submit, you mean the i915_* and intel_* perf stats, they're not being recorded, because those stats are only available for recording if your kernel is built w/ CONFIG_EXPERT=y and CONFIG_DRM_I915_LOW_LEVEL_TRACEPOINTS=y

btw, here's another gpuvis trace I did w/ just perform_3dlut commented out + a slight modification to perform_1dlut():
(branch: https://github.com/sharkautarch/gamescope/tree/gamescope_no_lut3d_opt_lut1d)
gpuvis_gamescope_no_lut3d_opt_lut1d-2

@sharkautarch
Copy link
Author

closing this, since it seems that glslang -Os doesn't make any difference for me when color management stuff in the shader is commented out

@sharkautarch sharkautarch deleted the glslang_use_Os branch February 26, 2024 18:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants