Translate cpu detection from assembly to C++ - #74
Merged
ZivDero merged 3 commits intoAug 30, 2026
Conversation
No documentation update: tests/cpudetect checks the ported detection against values derived directly from CPUID, so the documented CPU-detection behavior is unchanged.
ZivDero
requested changes
Aug 29, 2026
|
Development builds of 96ae888: The links work without a GitHub account. Artifacts expire after 90 days, and this comment follows the latest successful build. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Translates
detproc.asm, the last hand-written x86 assembly CPU-detectionroutine, to C++, folding it directly into
getcpu.cppalongside the rest ofGet_CPU_Type. While doing so, this simplifies MMX and CMOV detection toassume both are always present rather than probing CPUID feature bits, since
the project's supported minimum hardware (SSE2, so a Pentium 4 or Athlon 64
onward) always carries them.
Detect_CMOV_AvailabilityandProcessorareremoved outright, as neither had a remaining caller once that assumption held.
Get_CPU_Clock(previously#if 0'd out inmpu.cpp) is enabled using the__rdtsc()intrinsic in place of the inline_emitopcode bytes it usedbefore.
A new
tests/cpudetectCTest target builds the ported detection standaloneand checks its reported family, vendor, and feature flags against CPUID read
directly. No gameplay-visible change on any machine
meeting the documented minimum hardware.
Behavior and compatibility
(
Get_CPU_Type'scpu_type/vendor output, theCPUType/VendorIDglobals) — the family is still read from CPUID leaf 1 exactly as the
assembly did.
UseMMX,UseCMOV, andHasCMOVare now fixed-true constants instead of being written by CPUIDfeature-bit checks, and
Detect_CMOV_Availability/Processorare removed.These globals still gate the MMX/CMOV instruction paths in
winasm.asm'spalette-fade routines, so a machine below the documented minimum hardware
(SSE2, so a Pentium 4 or Athlon 64 onward) would now execute an instruction
it lacks instead of falling back to the plain path — such hardware was
never in the supported build matrix, so this formalizes an existing
requirement rather than narrowing one.
formats, INI/data formats, or COM/ABI surfaces — this is process-internal
engine plumbing.
0.2.0(current developmentrelease). Migration steps are recorded in
manual/changes/cpu-feature-detection.md: drop any code callingDetect_CMOV_AvailabilityorProcessor, and treatUseMMX/UseCMOV/HasCMOVas fixed-true constants rather than runtime-detected flags.Validation
Documentation
manual/changes/cpu-feature-detection.md(breaking: true, release0.2.0) documenting the MMX/CMOV assumption, the removed functions, and themigration steps.
getcpu.h,getcpu.cpp,mpu.h,mpu.cpp,init.cpp, andmisc.hto state the modern-hardware assumption and removestale references to the now-removed
Detect_CMOV_Availability,Processor,and the deleted
DETPROC.ASM.Checklist