Build: Fix some excessive Visual Studio compile times

While investigating Blender compilation time for windows-arm64, we
identified two compilation units that were taking a long time to compile
(~1h each). This affects windows-x64 builds as well.

Pull Request: https://projects.blender.org/blender/blender/pulls/117534
This commit is contained in:
Pierrick Bouvier
2024-01-28 12:12:52 +01:00
committed by Brecht Van Lommel
parent cbb0a96443
commit a3d915310b
2 changed files with 23 additions and 4 deletions

View File

@@ -238,10 +238,17 @@ integrate_direct_light_shadow_init_common(KernelGlobals kg,
/* Path tracing: sample point on light and evaluate light shader, then
* queue shadow ray to be traced. */
template<uint node_feature_mask>
ccl_device_forceinline void integrate_surface_direct_light(KernelGlobals kg,
IntegratorState state,
ccl_private ShaderData *sd,
ccl_private const RNGState *rng_state)
#if defined(__KERNEL_GPU__)
ccl_device_forceinline
#else
/* MSVC has very long compilation time (x20) if we force inline this function */
ccl_device
#endif
void
integrate_surface_direct_light(KernelGlobals kg,
IntegratorState state,
ccl_private ShaderData *sd,
ccl_private const RNGState *rng_state)
{
/* Test if there is a light or BSDF that needs direct light. */
if (!(kernel_data.integrator.use_direct_light && (sd->flag & SD_BSDF_HAS_EVAL))) {

View File

@@ -413,6 +413,15 @@ void ShaderCreateInfo::validate_vertex_attributes(const ShaderCreateInfo *other_
using namespace blender::gpu::shader;
#ifdef _MSC_VER
/* Disable optimization for this function with MSVC. It does not like the fact
* shaders info are declared in the same function (same basic block or not does
* not change anything).
* Since it is just a function called to register shaders (once),
* the fact it's optimized or not does not matter, it's not on any hot
* code path. */
# pragma optimize("", off)
#endif
void gpu_shader_create_info_init()
{
g_create_infos = new CreateInfoDictionnary();
@@ -553,6 +562,9 @@ void gpu_shader_create_info_init()
/* TEST */
// gpu_shader_create_info_compile(nullptr);
}
#ifdef _MSC_VER
# pragma optimize("", on)
#endif
void gpu_shader_create_info_exit()
{