Page MenuHomeWildfire Games

Do not send Screen height, width to shader if not needed [On Hold]
Needs ReviewPublic

Authored by Angen on Sun, Nov 10, 3:17 PM.
This revision needs review, but there are no reviewers specified.

Details

Reviewers
None
Summary

We do not need to send width and height to shader every time, so adding boolean variable which gets set to true when resized and will be set to false as soon new data are send to shader. It will be set to true if new shader is going to be created to send there initial values.

Test Plan

Compiler
Run game
Turn on/off wated effects, move camera, resize windows, change fullscreen/windowed check texture looks good and does not have fractions which will correct themselves after resizing window.

Event Timeline

Angen created this revision.Sun, Nov 10, 3:17 PM
Owners added a subscriber: Restricted Owners Package.Sun, Nov 10, 3:18 PM

Successful build - Chance fights ever on the side of the prudent.

Link to build: https://jenkins.wildfiregames.com/job/vs2015-differential/557/display/redirect

Successful build - Chance fights ever on the side of the prudent.

Linter detected issues:
Executing section Source...

source/renderer/TerrainRenderer.h
|  37| class·TerrainRenderer
|    | [MAJOR] CPPCheckBear (syntaxError):
|    | Code 'classTerrainRenderer{' is invalid C code. Use --std or --language to configure the language.
Executing section JS...
Executing section cli...

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/1071/display/redirect

Stan added a subscriber: Stan.Mon, Nov 11, 10:39 AM
Stan added inline comments.
source/renderer/TerrainRenderer.h
148

Remembers :) But the comment is not really useful.

Maybe something like "Send screen width and height in the next drawcall" ?

Actually looking at what the code does It's actually making the resize variable "dirty" So maybe it could be SetResize()/NeedsResize/ MakeDirty → ElevationHandlers.cpp ? https://github.com/0ad/0ad/search?q=DIRTY&unscoped_q=DIRTY

Angen added a comment.Mon, Nov 11, 6:45 PM

putting on hold, see discussion on irc: http://irclogs.wildfiregames.com/2019-11/2019-11-10-QuakeNet-%230ad-dev.log

14:25 < Vladislav_> Angen we need to send this data on each frame, and we don't have a cache there (afaik). So you can't skip Unfiorm steps.
14:26 < Vladislav_> Angen: and do you know why it works for you?
14:26 < Vladislav_> :)
14:26 < Angen> magic ?
14:27 < Vladislav_> Because we don't use screenSize afaik x)
14:27 < Angen> dont understand, shader is created once it should remember passed values
14:28 < Angen> we do use screensize :P
14:30 < Angen> and it is as my water would look really bad after resizing :)
14:30 < Vladislav_> It's compiled once but you pass uniform data on each frame.
14:31 < Angen> and thats bad
14:31 < Vladislav_> Yeah, you're right it's used but only in fancy water.
14:31 < Vladislav_> Why bad? That's expected.
14:31 < elexis> and where is pglProgramLocalParameter4fARB defined? OpenGL Easy Extension library? where is that located?
14:32 < Angen> nope, its expected to pass that only if values changes
14:32 < Vladislav_> elexis: it's a pointer calculated by any GL ext loader
14:33 < Vladislav_> Angen: why? You can have only one program binded at once. So GL need to change active unfiorms anyways.
14:33 < Angen> Vladislav_: https://stackoverflow.com/questions/10857602/do-uniform-values-remain-in-glsl-shader-if-unbound
14:37 < Angen> unbind does not mean removing values from variables
14:37 < Vladislav_> Angen: you need to reload it on each shader reload, also I'm not sure that all drivers support such behaviour.
Angen retitled this revision from Do not send Screen height, width to shader if not needed to Do not send Screen height, width to shader if not needed [On Hold].Mon, Nov 11, 6:45 PM