Creator: Add CPU check on startup #118054

Merged
Ray molenkamp merged 12 commits from LazyDodo/blender:tmp_cpu_check into main 2024-02-19 18:12:06 +01:00
Member

This adds an sse42 cpu check on startup for both linux and windows,
mac has been excluded, since afaik there are no intel based macs that do
not support SSE42.

The way this works is, we count on the OS to initialize the shared
libraries in the order they are linked (which currently holds true)
before calling the initialization code in the main executable. This
allows us to check the CPU before running any of the code in the main
executable that might not be supported by the current isa.

Changing those build flags is for a future PR, but for now and for
future reference: blender_cpu_check must be build without optimized CPU
flags so it'll be able to run on older CPUs.

some code has been duplicated from blenlib, there's really no way around
that since we cannot link blenlib as it may be build with optimized cpu
flags.

Windows currently gives a popup to inform the user, while linux reports
to the console, there may be better ways to communicate with linux users
with perhaps some generic GUI popup, but I'm unaware of these and will
leave this for the linux platform maintainer to polish.

Part of #116592

This adds an sse42 cpu check on startup for both linux and windows, mac has been excluded, since afaik there are no intel based macs that do not support SSE42. The way this works is, we count on the OS to initialize the shared libraries in the order they are linked (which currently holds true) before calling the initialization code in the main executable. This allows us to check the CPU before running any of the code in the main executable that might not be supported by the current isa. Changing those build flags is for a future PR, but for now and for future reference: blender_cpu_check must be build without optimized CPU flags so it'll be able to run on older CPUs. some code has been duplicated from blenlib, there's really no way around that since we cannot link blenlib as it may be build with optimized cpu flags. Windows currently gives a popup to inform the user, while linux reports to the console, there may be better ways to communicate with linux users with perhaps some generic GUI popup, but I'm unaware of these and will leave this for the linux platform maintainer to polish. Part of #116592
Ray molenkamp added 1 commit 2024-02-09 18:46:15 +01:00
36481dff98 WIP: Add CPU check on startup
WIP description to be done, see #116592 for details.
Ray molenkamp added 1 commit 2024-02-09 19:11:20 +01:00
Thomas Dinges reviewed 2024-02-09 20:35:54 +01:00
@ -0,0 +22,4 @@
switch( fdwReason )
{
case DLL_PROCESS_ATTACH:
//if (!BLI_cpu_support_sse41())

Needs to be updated after eaeaf8322cae

Needs to be updated after [eaeaf8322cae](https://projects.blender.org/blender/blender/commit/eaeaf8322cae83ca89c3b87afe3f5940ef5f2b32)
Ray molenkamp added 1 commit 2024-02-10 00:48:39 +01:00
Ray molenkamp added 2 commits 2024-02-17 19:15:49 +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-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-coordinator Build done. Details
497d0ae962
Merge remote-tracking branch 'origin/main' into tmp_cpu_check
Author
Member

@blender-bot build

@blender-bot build
Ray molenkamp added 2 commits 2024-02-17 21:39:57 +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
a15fd2e8d3
fix linux install
Author
Member

@blender-bot build

@blender-bot build
Ray molenkamp added 1 commit 2024-02-17 21:54:52 +01:00
Ray molenkamp changed title from WIP: Add CPU check on startup to Add CPU check on startup 2024-02-17 22:10:29 +01:00
Ray molenkamp requested review from Campbell Barton 2024-02-17 22:11:42 +01:00
Ray molenkamp requested review from Thomas Dinges 2024-02-17 22:11:43 +01:00
Ray molenkamp requested review from Raul Fernandez Hernandez 2024-02-17 22:12:52 +01:00
Author
Member

added @Farsthary as a reviewer, just to validate my assumptions about sse42 support on mac.

added @Farsthary as a reviewer, just to validate my assumptions about sse42 support on mac.

just to validate my assumptions about sse42 support on mac

Blender minspec macOS version (Big Sur) supports Macs from year 2014-2015 and later. Apple used to have Intel CPUs without SSE4.2 support, but that was year 2009 and earlier. So this is pretty safe.

> just to validate my assumptions about sse42 support on mac Blender minspec macOS version (Big Sur) supports Macs from year 2014-2015 and later. Apple used to have Intel CPUs without SSE4.2 support, but that was year 2009 and earlier. So this is pretty safe.

added @Farsthary as a reviewer, just to validate my assumptions about sse42 support on mac.

Correct, all currently supported intel macs have SSE 4.2 instruction set

> added @Farsthary as a reviewer, just to validate my assumptions about sse42 support on mac. Correct, all currently supported intel macs have SSE 4.2 instruction set
Campbell Barton requested changes 2024-02-19 01:01:24 +01:00
@ -327,6 +327,30 @@ if(WITH_PYTHON_MODULE)
else()
add_executable(blender ${EXETYPE} ${SRC})
if(NOT APPLE)

This can be a CMake option, which has the advantage there is a single, obvious place to adjust the defaults, it also means we can limit this more easily exclude certain architectures, any further use can check WITH_CPU_CHECK directly.

e.g.

if((NOT WITH_PYTHON_MODULE) AND (
      (WIN32 AND (CMAKE_SYSTEM_PROCESSOR STREQUAL "AMD64")) OR
      ((UNIX AND NOT APPLE) AND (CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64"))))
  option(WITH_CPU_CHECK "\
Report when a CPU is not compatible on startup \
instead of failing to start with an inscrutable error."
    ON
  )
  mark_as_advanced(WITH_CPU_CHECK)
else()
  set(WITH_CPU_CHECK OFF)
endif()
This can be a CMake option, which has the advantage there is a single, obvious place to adjust the defaults, it also means we can limit this more easily exclude certain architectures, any further use can check `WITH_CPU_CHECK` directly. e.g. ``` if((NOT WITH_PYTHON_MODULE) AND ( (WIN32 AND (CMAKE_SYSTEM_PROCESSOR STREQUAL "AMD64")) OR ((UNIX AND NOT APPLE) AND (CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")))) option(WITH_CPU_CHECK "\ Report when a CPU is not compatible on startup \ instead of failing to start with an inscrutable error." ON ) mark_as_advanced(WITH_CPU_CHECK) else() set(WITH_CPU_CHECK OFF) endif() ```
Author
Member

That is much nicer, done!

That is much nicer, done!
LazyDodo marked this conversation as resolved
@ -10,3 +10,3 @@
#include <cstring>
#ifdef WIN32
#if defined(WIN32)

This change seems unnecessary?

This change seems unnecessary?
LazyDodo marked this conversation as resolved
@ -0,0 +64,4 @@
}
#ifdef _MSC_VER
extern "C" __declspec(dllexport) void cpu_check_win()

Name cpu_check_win32 to differentiate this from windowing, follows blender_launcher_win32.c & naming elsewhere.

Name `cpu_check_win32` to differentiate this from windowing, follows `blender_launcher_win32.c` & naming elsewhere.
LazyDodo marked this conversation as resolved
Ray molenkamp added 2 commits 2024-02-19 09:27:42 +01:00
5f3cc02ae2 update with feedback
- add CMake option WITH_CPU_CHECK
- rename cpu_check_win to cpu_check_win32
- restore unneeded change to `ifdef WIN32`
buildbot/vexp-code-patch-lint Build done. Details
buildbot/vexp-code-patch-linux-x86_64 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-coordinator Build done. Details
e6504571ed
Merge remote-tracking branch 'origin/main' into tmp_cpu_check
Author
Member

@blender-bot build

@blender-bot build
Thomas Dinges approved these changes 2024-02-19 11:29:20 +01:00
Thomas Dinges left a comment
Owner

Thanks for the patch, code looks good to me.

Thanks for the patch, code looks good to me.
Campbell Barton approved these changes 2024-02-19 11:29:54 +01:00
Raul Fernandez Hernandez approved these changes 2024-02-19 14:58:52 +01:00
Ray molenkamp added 2 commits 2024-02-19 18:05:50 +01:00
Ray molenkamp changed title from Add CPU check on startup to Creator: Add CPU check on startup 2024-02-19 18:10:38 +01:00
Ray molenkamp merged commit 0326b29899 into main 2024-02-19 18:12:06 +01:00
Ray molenkamp deleted branch tmp_cpu_check 2024-02-19 18:12:08 +01:00
Sign in to join this conversation.
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 project
No Assignees
5 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#118054
No description provided.