Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I have in fact tested everything with GLES 2.0, 3.1, and desktop GL 2.1 and 3.3 and they should all work. If it's as efficient as it could be is another question. I find OpenGL rather messy as an API compared to d3d9.


I don’t have GTA3 but I do have VC on Steam. Compiled 32-bit Windows build of VC with GL2. Here’s a renderdoc capture from my PC: http://const.me/tmp/vc-win10-gl.zip

1. On the main rendering pass, your code renders stuff mostly back to front. Consider sorting opaque objects by Z and render then front to back. If you do that, early Z rejection gonna save tons of pixel shaders and fill rate. The sorting doesn’t need to be perfect, an approximate will do as well, but with these ~5k draw calls I’m pretty sure even C qsort gonna be adequate on Pi4.

Translucent objects need to be rendered back to front like you’re currently doing.

2. In your pixel shader you often have this code:

    if( a < u_alphaRef.x || a >= u_alphaRef.y ) discard;
Where u_alphaRef is [ -1000; +1000 ] i.e. very large interval.

Don’t do that. Write another pixel shader for cases when you don’t need alpha tests. GPUs disable some optimizations (early Z rejection is one of them) when you calling discard in GLSL/HLSL.

3. Up to EID 5328, the game rendered the next frame. Starting from EID 5377, the game was finishing rendering of the previous one. That’s a good idea by itself, the problem with that, the temporary texture has size 4096*4096 pixels. Only top-center 3840*2160 portion was actually used. My desktop PC is fast enough to deliver 60 FPS, but on RPi you should not use textures much larger than necessary. All modern GPUs support non-power-of-2 textures, Pi4 included.

4. You are using 2x MSAA for the main pass. At least for my test cases on Pi4 (see e.g. this project https://github.com/Const-me/Vrmac ), even 2x MSAA ruined performance, if you use the same setting on Pi4, I think that contributed the most to the performance issue.

Try to disable MSAA and see what gonna happen. If you’ll find out it helps with the performance but the quality is too bad now, try to implement a cheaper substitute somehow, search the web for FXAA and SMAA keywords.


Thank you for your input!

For shaders I'm never sure if I should do something dynamically or switch to a different shader, but it makes sense of course to kill the alpha test code if it's not used.

As for MSAA, our support for that is pretty rather young and it gives artifacts. I'm actually surprised it's on at all by default...


> it makes sense of course to kill the alpha test code if it's not used.

It’s used, but only for some meshes like vegetation, u_alphaRef was like [ 0.50196, 1000.00 ] for them.

> I'm actually surprised it's on at all by default

I don’t think I have adjusted anything, just built and run your code on Win10 with GL. This doesn’t mean it gonna use the same defaults on Pi, but it might.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: