perf(engine): eliminate idiv in floor and ceiling render using tableInvDelta3D and tableStepRatio3D LUTs

This commit is contained in:
Игорь Федосеев 2026-10-13 20:36:25 +03:00
parent 3403696642
commit 9d504622ca
6 changed files with 1332 additions and 1306 deletions

Binary file not shown.

BIN
poker.exe

Binary file not shown.

BIN
poker.obj

Binary file not shown.

Binary file not shown.

View file

@ -25,6 +25,9 @@ RenderPatrons3D PROTO
ResolveWorldSurface3D PROTO :DWORD
include src_graphics\hall_layout.inc
.data
ALIGN 4
tableInvDelta3D dd 241 dup(0)
tableStepRatio3D dd 241 dup(0)
hallSign3D AnimPack3D <>
hallSignPath3D db "assets\animations\hall\sign.bin",0
hallCityDetail3D AnimPack3D <>

View file

@ -27,9 +27,18 @@ hall_plane_floor:
mov ebx, floorTexture3D
mov material, ebx
hall_plane_distance:
imul eax, SCREEN_H
cdq
idiv ecx
cmp ecx, 240
jbe @F
mov ecx, 240
@@:
cmp ecx, 1
jae @F
mov ecx, 1
@@:
push eax
mov edx, [tableInvDelta3D + ecx*4]
imul edx
shrd eax, edx, 16
mov distance, eax
shr eax, 14
neg eax
@ -46,20 +55,18 @@ hall_plane_distance:
shr eax, 3
mov shade, eax
@@:
mov eax, playerPlaneX
shl eax, 1
imul distance
pop eax
mov edx, [tableStepRatio3D + ecx*4]
imul edx
shrd eax, edx, 16
mov ebx, eax
mov eax, playerPlaneX
imul ebx
shrd eax, edx, 16
cdq
mov ecx, SCREEN_W
idiv ecx
mov sx, eax
mov eax, playerPlaneY
shl eax, 1
imul distance
imul ebx
shrd eax, edx, 16
cdq
idiv ecx
mov sy, eax
mov eax, playerDirX
sub eax, playerPlaneX
@ -278,6 +285,22 @@ InitHall3D PROC uses esi edi
mov floorTexture3D, 100
mov casinoSprites[14*SIZEOF SpriteObject].interactId, 0
mov patronClock3D, 0
; Precalculate floor & ceiling distance / step LUTs (no division at runtime)
mov ecx, 1
init_plane_lut:
cmp ecx, 241
jge init_plane_done
mov eax, SCREEN_H * FP_1
xor edx, edx
div ecx
mov [tableInvDelta3D + ecx*4], eax
mov eax, 98304
xor edx, edx
div ecx
mov [tableStepRatio3D + ecx*4], eax
inc ecx
jmp init_plane_lut
init_plane_done:
call InitCasinoNpcMind
call InitNpcLife3D
ret