EEVEE-Next: Viewport pixel size with up-scaling #118903

Merged
Jeroen Bakker merged 27 commits from Jeroen-Bakker/blender:eevee-next/preview-pixel-size into main 2024-03-13 12:00:38 +01:00
Member

EEVEE-Next performes less on integrated GPUs then discrete GPUs.
Most shaders have been analyzed, but there will always be bottlenecks
related to architectural differences.

In order to make EEVEE-Next run smooth on integrated GPUs this change
will implement viewport pixel size option similar to Cycles. The main difference
is that the samples will still be weighted and up-sampled to the final film
resolution. This makes the pixels not look squared in the viewport but will
resolve to something close to the results without up-scaling.

This improves the performance especially on integrated GPUs. The improvement
for discrete GPUs are less noticeable. See here the stats when playing
rain_restaurant.blend back on a RAPHAEL_MENDOCINO iGPU.

Pixel size Frames per second
1x 0.25 FPS
2x 4.14 FPS
4x 6.90 FPS
8x 9.95 FPS

Related to: #114597

The next images show that the pixel size will eventually resolve to the same result.
The number of samples have been adjusted.

Pixel size 1 - 16 samples
image
Pixel size 2 - 64 samples
image
Pixel size 4 - 256 samples
image
Pixel size 8 - 1024 samples
image

EEVEE-Next performes less on integrated GPUs then discrete GPUs. Most shaders have been analyzed, but there will always be bottlenecks related to architectural differences. In order to make EEVEE-Next run smooth on integrated GPUs this change will implement viewport pixel size option similar to Cycles. The main difference is that the samples will still be weighted and up-sampled to the final film resolution. This makes the pixels not look squared in the viewport but will resolve to something close to the results without up-scaling. This improves the performance especially on integrated GPUs. The improvement for discrete GPUs are less noticeable. See here the stats when playing `rain_restaurant.blend` back on a RAPHAEL_MENDOCINO iGPU. | Pixel size | Frames per second | |------------|-------------------| | 1x | 0.25 FPS | | 2x | 4.14 FPS | | 4x | 6.90 FPS | | 8x | 9.95 FPS | Related to: #114597 The next images show that the pixel size will eventually resolve to the same result. The number of samples have been adjusted. **Pixel size 1 - 16 samples** ![image](/attachments/3255e7af-053b-4cbd-8d22-93bd63e3c0f5) **Pixel size 2 - 64 samples** ![image](/attachments/89fee9e8-a7ce-4847-adbd-5dff63d522a6) **Pixel size 4 - 256 samples** ![image](/attachments/7762aada-12f0-4a27-a220-6b175b5d806c) **Pixel size 8 - 1024 samples** ![image](/attachments/dd122446-5b1f-4915-a892-e12f96660707)
Jeroen Bakker added this to the 4.2 LTS milestone 2024-02-29 13:46:21 +01:00
Jeroen Bakker added the
Module
EEVEE & Viewport
label 2024-02-29 13:46:21 +01:00
Jeroen Bakker self-assigned this 2024-02-29 13:46:21 +01:00
Jeroen Bakker added 1 commit 2024-02-29 13:46:29 +01:00
a5f3cdda12 EEVEE-Next: Preview pixel size
EEVEE-Next is less performance on integrated GPUs then on descrete GPUs.
Most shaders have been analyzed, but there will always be bottlenecks
related to diverse architectural changes.

In order to make EEVEE-Next run smooth on integrated GPUs this change
will implement viewport resolution scaling similar to Cycles.
Jeroen Bakker added this to the EEVEE & Viewport project 2024-02-29 13:46:34 +01:00
Jeroen Bakker added 1 commit 2024-02-29 13:54:37 +01:00
Jeroen Bakker added 1 commit 2024-02-29 14:27:46 +01:00
Jeroen Bakker added 1 commit 2024-02-29 14:29:15 +01:00
Jeroen Bakker requested review from Clément Foucault 2024-02-29 14:37:31 +01:00
Clément Foucault requested changes 2024-03-07 13:48:49 +01:00
@ -48,6 +48,7 @@ static void eevee_engine_init(void *vedata)
DefaultTextureList *dtxl = DRW_viewport_texture_list_get();
int2 size = int2(GPU_texture_width(dtxl->color), GPU_texture_height(dtxl->color));
const int scaling_factor = v3d ? BKE_render_preview_pixel_size(&scene->r) : 1;

Why getting it so early? That's only used by film and you can access scene by inst_.scene. Better keep the interfaces cleaner.

Why getting it so early? That's only used by film and you can access scene by `inst_.scene`. Better keep the interfaces cleaner.
Author
Member

My assumption was that we would like to reduce the calls to code outside functions to a minimum. Also was a left over as I expected I needed to adjust the rect and visible_rect here which wasn't needed after all.

Will move the code to inside film.

My assumption was that we would like to reduce the calls to code outside functions to a minimum. Also was a left over as I expected I needed to adjust the `rect` and `visible_rect` here which wasn't needed after all. Will move the code to inside film.
Jeroen-Bakker marked this conversation as resolved
@ -8,2 +8,3 @@
{
ivec2 texel_film = ivec2(gl_FragCoord.xy) - uniform_buf.film.offset;
ivec2 texel_film = ivec2(
((gl_FragCoord.xy - vec2(uniform_buf.film.offset)) / uniform_buf.film.scaling_factor));

This isn't where the scaling factor should be applied. This basically negate the benefit of having a 1:1 film buffer and just duplicate the processing for the pixels under the scaling factor for no benefit.
See SCALED_RENDERING (which should be added or use a new specialization constant instead).

This isn't where the scaling factor should be applied. This basically negate the benefit of having a 1:1 film buffer and just duplicate the processing for the pixels under the scaling factor for no benefit. See `SCALED_RENDERING` (which should be added or use a new specialization constant instead).
Author
Member

I chose to use a specialization constant, although it might only have benefit when panoramic camera support is added as the filter size is constant and doesn't lead to that much registry pressure as the samples_len is already a specialization constant..

I chose to use a specialization constant, although it might only have benefit when panoramic camera support is added as the filter size is constant and doesn't lead to that much registry pressure as the samples_len is already a specialization constant..
Jeroen-Bakker marked this conversation as resolved
@ -602,3 +602,3 @@
#endif
/* Small offset to avoid depth test lessEqual failing because of all the conversions loss. */
depth += 2.4e-7 * 4.0;
if (scaling_factor == 1) {

You are not biasing for the same reason. You increased the bias because fwidth(depth) is effectively 0 with the nearest neighbor up-sampling. If you fix it like I mention above, you should not need to touch the bias.

You are not biasing for the same reason. You increased the bias because `fwidth(depth)` is effectively `0` with the nearest neighbor up-sampling. If you fix it like I mention above, you should not need to touch the bias.
Jeroen-Bakker marked this conversation as resolved
Jeroen Bakker added 3 commits 2024-03-08 03:55:25 +01:00
Jeroen Bakker added 1 commit 2024-03-08 03:56:59 +01:00
Jeroen Bakker added 1 commit 2024-03-08 04:35:18 +01:00
Jeroen Bakker added 1 commit 2024-03-08 04:42:02 +01:00
Jeroen Bakker requested review from Clément Foucault 2024-03-08 04:43:04 +01:00
Jeroen Bakker changed title from EEVEE-Next: Preview pixel size to EEVEE-Next: Viewport pixel size with up-scaling 2024-03-08 04:47:14 +01:00
Jeroen Bakker added 1 commit 2024-03-08 05:03:41 +01:00
Jeroen Bakker added 1 commit 2024-03-08 05:05:19 +01:00
Clément Foucault requested changes 2024-03-08 12:00:25 +01:00
@ -328,3 +326,3 @@
/** Sum of the weights of all samples in the sample table. */
float samples_weight_total;
int _pad1;
int _pad1[2];

no scalar array allowed in shader shared. Theses gets padded in UBOs.

no scalar array allowed in shader shared. Theses gets padded in UBOs.
Jeroen-Bakker marked this conversation as resolved
Jeroen Bakker added 1 commit 2024-03-08 12:25:34 +01:00
buildbot/vexp-code-patch-lint Build done. Details
buildbot/vexp-code-patch-linux-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-arm64 Build done. Details
buildbot/vexp-code-patch-darwin-x86_64 Build done. Details
buildbot/vexp-code-patch-windows-amd64 Build done. Details
buildbot/vexp-code-patch-coordinator Build done. Details
30c16c1181
Remove array from _pad in shader shared.
Jeroen Bakker requested review from Clément Foucault 2024-03-08 12:25:42 +01:00
Author
Member

@blender-bot build

@blender-bot build
First-time contributor

I see we have flat scaling,
will FSR / DLSS be in the cards at some point?

I see we have flat scaling, will FSR / DLSS be in the cards at some point?
Author
Member

This is a sample based approach, not an image based approach. So flat scaling isn't what is actually being done. Note that pixel size of 2 means that your rescaling from 1920x1080 to 3840x2160. A pixel size of 4 means a rescale from 960x540 -> 3840x2160 and a pixel size of 8 from 480x270 to 3840x2160.

Regular image based up scalers are often limited to scales of 1.25/1.5 for good results. When going further they may also look blurry :-)

Back to your question we are not against it, and talked about it a few weeks ago, but it ain't very high on our priority list. Patches are welcome.

This is a sample based approach, not an image based approach. So flat scaling isn't what is actually being done. Note that pixel size of 2 means that your rescaling from 1920x1080 to 3840x2160. A pixel size of 4 means a rescale from 960x540 -> 3840x2160 and a pixel size of 8 from 480x270 to 3840x2160. Regular image based up scalers are often limited to scales of 1.25/1.5 for good results. When going further they may also look blurry :-) Back to your question we are not against it, and talked about it a few weeks ago, but it ain't very high on our priority list. Patches are welcome.
Clément Foucault added 2 commits 2024-03-08 17:19:26 +01:00
1ffca50108 Make scaled rendering use full extent weight buffer
This allow correct per pixel weighting, which is needed to correctly
converge.
Clément Foucault requested changes 2024-03-08 17:21:50 +01:00
@ -244,0 +246,4 @@
scaling_factor_ = 1;
if (inst_.is_viewport()) {
scaling_factor_ = BKE_render_preview_pixel_size(&inst_.scene->r);
if (DRW_state_is_navigating()) {

This is making all viewport reduce size even if preview pixel size is 1. This is very unconfortable and messes with a bunch of TAA algorithm that are reset because render size changes on navigation.

So remove that all-together.

This is making all viewport reduce size even if preview pixel size is 1. This is very unconfortable and messes with a bunch of TAA algorithm that are reset because render size changes on navigation. So remove that all-together.
Jeroen-Bakker marked this conversation as resolved

After my fix it works as expected: It converges to the sharp image.
Note this is what to expect because of the missing LOD Bias:

Pixel size 1 Pixel size 2 Pixel size 4 Pixel size 8
Capture d’écran du 2024-03-08 17-23-35.png Capture d’écran du 2024-03-08 17-23-43.png Capture d’écran du 2024-03-08 17-23-51.png Capture d’écran du 2024-03-08 17-24-21.png

Also note that the render is streched a bit. This is because the pixel count of the film is not a divisor of the internal render resolution. To fix this we need to change the projection matrix as explained in this TODO:

  /* TODO(fclem): Mixed-resolution rendering: We need to make sure we render with exactly the same
   * distances between pixels to line up render samples and target pixels.
   * So if the target resolution is not a multiple of the resolution divisor, we need to make the
   * projection window bigger in the +X and +Y directions. */
After my fix it works as expected: It converges to the sharp image. Note this is what to expect because of the missing LOD Bias: | Pixel size 1 | Pixel size 2 | Pixel size 4 | Pixel size 8 | | -------- | -------- | -------- | -------- | | ![Capture d’écran du 2024-03-08 17-23-35.png](/attachments/b230681d-07bd-4524-99cc-f056565dc693) | ![Capture d’écran du 2024-03-08 17-23-43.png](/attachments/d5c3e100-b812-4bb3-8b0f-6b0a1d4ce553) | ![Capture d’écran du 2024-03-08 17-23-51.png](/attachments/d81d8f94-22d6-49ed-9c97-41df5899ffdb) | ![Capture d’écran du 2024-03-08 17-24-21.png](/attachments/f491f443-711c-4369-88cc-90111a54b973)| Also note that the render is streched a bit. This is because the pixel count of the film is not a divisor of the internal render resolution. To fix this we need to change the projection matrix as explained in this TODO: ``` /* TODO(fclem): Mixed-resolution rendering: We need to make sure we render with exactly the same * distances between pixels to line up render samples and target pixels. * So if the target resolution is not a multiple of the resolution divisor, we need to make the * projection window bigger in the +X and +Y directions. */
Jeroen Bakker added 1 commit 2024-03-08 20:25:31 +01:00
Jeroen Bakker added 1 commit 2024-03-11 08:21:15 +01:00
Jeroen Bakker added 1 commit 2024-03-11 12:21:31 +01:00
Jeroen Bakker added 1 commit 2024-03-11 12:29:19 +01:00
Jeroen Bakker added 1 commit 2024-03-11 13:49:12 +01:00
Jeroen Bakker added 1 commit 2024-03-12 12:21:43 +01:00
Jeroen Bakker requested review from Clément Foucault 2024-03-12 12:56:24 +01:00
Jeroen Bakker added 1 commit 2024-03-12 14:01:15 +01:00
Jeroen Bakker added 1 commit 2024-03-12 14:09:09 +01:00
Jeroen Bakker added 1 commit 2024-03-12 14:12:41 +01:00
buildbot/vexp-code-patch-lint Build done. Details
buildbot/vexp-code-patch-darwin-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-arm64 Build done. Details
buildbot/vexp-code-patch-windows-amd64 Build done. Details
buildbot/vexp-code-patch-linux-x86_64 Build done. Details
buildbot/vexp-code-patch-coordinator Build done. Details
5490b1a248
Merge branch 'main' into eevee-next/preview-pixel-size
Author
Member

@blender-bot build +gpu

@blender-bot build +gpu
Clément Foucault approved these changes 2024-03-12 14:16:23 +01:00
@ -231,6 +231,7 @@ BLI_STATIC_ASSERT_ALIGN(SSSProfileBlock, 16)
# define alphaHashScale common_block._alphaHashScale
# define cameraUvScaleBias common_block._cameraUvScaleBias
# define planarClipPlane common_block._planarClipPlane
# define filmScalingFactor 1.0

Move that to eevee_nodetree_lib.glsl for EEVEE-Next and to the respective file for eevee legacy.

Move that to `eevee_nodetree_lib.glsl` for EEVEE-Next and to the respective file for eevee legacy.
Jeroen-Bakker marked this conversation as resolved
Jeroen Bakker added 1 commit 2024-03-12 14:34:09 +01:00
buildbot/vexp-code-patch-coordinator Build done. Details
90034b60ed
Move filmScalingFactor to nodetree_lib
Author
Member

@blender-bot build +gpu

@blender-bot build +gpu
Clément Foucault approved these changes 2024-03-12 15:04:09 +01:00
@ -8,6 +8,8 @@
#pragma BLENDER_REQUIRE(gpu_shader_codegen_lib.glsl)
#pragma BLENDER_REQUIRE(eevee_renderpass_lib.glsl)
#define filmScalingFactor float(uniform_buf.film.scaling_factor)

Nitpick1: Don't use camecase, so film_scaling_factor. This is old codestyle and will eventually fade away.

Nitpicl2: Use functions instead of macros.

Nitpick1: Don't use camecase, so `film_scaling_factor`. This is old codestyle and will eventually fade away. Nitpicl2: Use functions instead of macros.
Jeroen-Bakker marked this conversation as resolved

There is still some issue with some blocky artifacts which are likely to be the result of badly weighting the first samples (see film_sample.weight = max(film_sample.weight, 1e-6);) but I don't consider this as a blocker.

There is still some issue with some blocky artifacts which are likely to be the result of badly weighting the first samples (see `film_sample.weight = max(film_sample.weight, 1e-6);`) but I don't consider this as a blocker.
Jeroen Bakker added 2 commits 2024-03-13 09:32:14 +01:00
buildbot/vexp-code-patch-lint Build done. Details
buildbot/vexp-code-patch-darwin-arm64 Build done. Details
buildbot/vexp-code-patch-darwin-x86_64 Build done. Details
buildbot/vexp-code-patch-linux-x86_64 Build done. Details
buildbot/vexp-code-patch-windows-amd64 Build done. Details
buildbot/vexp-code-patch-coordinator Build done. Details
2e811101da
Cleanup: Use function to read film scaling factor
Author
Member

@blender-bot build +gpu

@blender-bot build +gpu
Author
Member

@blender-bot package

@blender-bot package
Member

Package build started. Download here when ready.

Package build started. [Download here](https://builder.blender.org/download/patch/PR118903) when ready.
Jeroen Bakker merged commit f0f911590e into main 2024-03-13 12:00:38 +01:00
Sign in to join this conversation.
No reviewers
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No Assignees
4 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#118903
No description provided.