From 2d3368f5bf08c6eb905f839a97f3fdfffb7cc8f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Mon, 8 Apr 2024 20:06:39 +0200 Subject: [PATCH] EEVEE-Next: Fix performance regression The SAFE_UNION_ACCESS is always defined. The correct check is to test for its value. Fix DATA_MEMBER declaration too. --- .../draw/engines/eevee_next/eevee_shader_shared.hh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/source/blender/draw/engines/eevee_next/eevee_shader_shared.hh b/source/blender/draw/engines/eevee_next/eevee_shader_shared.hh index df6b07abf26..ffe293566f0 100644 --- a/source/blender/draw/engines/eevee_next/eevee_shader_shared.hh +++ b/source/blender/draw/engines/eevee_next/eevee_shader_shared.hh @@ -925,10 +925,8 @@ BLI_STATIC_ASSERT_ALIGN(LightData, 16) * the GPU so that only lights of a certain type can read for the appropriate union member. * Return cross platform garbage data as some platform can return cleared memory if we early exit. */ -#ifdef SAFE_UNION_ACCESS +#if SAFE_UNION_ACCESS # ifdef GPU_SHADER -# define DATA_MEMBER do_not_access_directly - /* Should result in a beautiful zebra pattern on invalid load. */ # if defined(GPU_FRAGMENT_SHADER) # define GARBAGE_VALUE sin(gl_FragCoord.x + gl_FragCoord.y) @@ -944,7 +942,6 @@ BLI_STATIC_ASSERT_ALIGN(LightData, 16) # else /* C++ */ # define GARBAGE_VALUE 0.0f -# define DATA_MEMBER local # endif # define SAFE_BEGIN(data_type, check) \ @@ -960,6 +957,12 @@ BLI_STATIC_ASSERT_ALIGN(LightData, 16) # define SAFE_ASSIGN_LIGHT_TYPE_CHECK(_type, _value) _value #endif +#if USE_LIGHT_UNION +# define DATA_MEMBER local +#else +# define DATA_MEMBER do_not_access_directly +#endif + #define ERROR_OFS(a, b) "Offset of " STRINGIFY(a) " mismatch offset of " STRINGIFY(b) /* This is a dangerous process, make sure to static assert every assignment. */