feat: major engine overhaul - scene demo with lighting, sphere, ground
- Scene Demo: cube + sphere + ground plane with proper lighting - Audio: XAudio2 dynamic loading + WAV playback - Physics: expanded collision system - Renderer: improved pipeline with materials - UI: extended widget system - VisualScript: enhanced serializer + block interactions - ASM: optimized math/memory/profiling routines - Window: mouse input + scroll support
This commit is contained in:
1 parent
2653926d85
commit
0669d102ce
35 files changed
+1844
-314
No files matched your search
@@ -255,42 +255,21 @@ fast_memset ENDP
|
||||
; uint64_t fast_strlen(const char* str) -> RAX
|
||||
; 使用 SSE4.2 PCMPESTRI 搜索 null terminator
|
||||
fast_strlen PROC
|
||||
mov rax, rcx ; rax = str
|
||||
xor rcx, rcx ; rcx = 计数器
|
||||
|
||||
; 每次检查 16 字节
|
||||
mov rdx, rcx ; rdx = original str
|
||||
pxor xmm0, xmm0 ; 搜索 0
|
||||
|
||||
strlen_sse_loop:
|
||||
; 检查是否接近字符串末尾 (避免越界读取)
|
||||
; 简化: 逐 16 字节检查
|
||||
movdqu xmm1, xmmword ptr [rax + rcx]
|
||||
pcmpestrm xmm0, xmm1, 00001000b ; 搜索 0, 返回掩码
|
||||
mov rax, rcx ; rax = 当前 16 字节块起始
|
||||
movdqu xmm1, xmmword ptr [rcx]
|
||||
pcmpestri xmm0, xmm1, 00001000b ; 搜索 0, CF=1 表示找到, ECX=偏移
|
||||
jc strlen_found
|
||||
|
||||
add rcx, 16
|
||||
jmp strlen_sse_loop
|
||||
|
||||
strlen_found:
|
||||
; 获取第一个匹配位置
|
||||
pcmpestri xmm0, xmm1, 00001000b ; ECX = 匹配位置
|
||||
; rax = 块起始, rcx (ecx) = 块内偏移
|
||||
add rax, rcx
|
||||
add rax, rcx
|
||||
; 需要计算实际位置
|
||||
; 简化: 使用标量回退
|
||||
mov rax, rcx
|
||||
ret
|
||||
|
||||
; 标量回退
|
||||
strlen_scalar:
|
||||
mov rax, rcx
|
||||
strlen_scalar_loop:
|
||||
cmp byte ptr [rax], 0
|
||||
je strlen_scalar_done
|
||||
inc rax
|
||||
jmp strlen_scalar_loop
|
||||
strlen_scalar_done:
|
||||
sub rax, rcx
|
||||
sub rax, rdx
|
||||
ret
|
||||
fast_strlen ENDP
|
||||
|
||||
|
||||
Reference in new issue
Block a user