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 ResolveWorldSurface3D PROTO :DWORD
include src_graphics\hall_layout.inc include src_graphics\hall_layout.inc
.data .data
ALIGN 4
tableInvDelta3D dd 241 dup(0)
tableStepRatio3D dd 241 dup(0)
hallSign3D AnimPack3D <> hallSign3D AnimPack3D <>
hallSignPath3D db "assets\animations\hall\sign.bin",0 hallSignPath3D db "assets\animations\hall\sign.bin",0
hallCityDetail3D AnimPack3D <> hallCityDetail3D AnimPack3D <>

View file

@ -27,9 +27,18 @@ hall_plane_floor:
mov ebx, floorTexture3D mov ebx, floorTexture3D
mov material, ebx mov material, ebx
hall_plane_distance: hall_plane_distance:
imul eax, SCREEN_H cmp ecx, 240
cdq jbe @F
idiv ecx 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 mov distance, eax
shr eax, 14 shr eax, 14
neg eax neg eax
@ -46,20 +55,18 @@ hall_plane_distance:
shr eax, 3 shr eax, 3
mov shade, eax mov shade, eax
@@: @@:
mov eax, playerPlaneX pop eax
shl eax, 1 mov edx, [tableStepRatio3D + ecx*4]
imul distance imul edx
shrd eax, edx, 16
mov ebx, eax
mov eax, playerPlaneX
imul ebx
shrd eax, edx, 16 shrd eax, edx, 16
cdq
mov ecx, SCREEN_W
idiv ecx
mov sx, eax mov sx, eax
mov eax, playerPlaneY mov eax, playerPlaneY
shl eax, 1 imul ebx
imul distance
shrd eax, edx, 16 shrd eax, edx, 16
cdq
idiv ecx
mov sy, eax mov sy, eax
mov eax, playerDirX mov eax, playerDirX
sub eax, playerPlaneX sub eax, playerPlaneX
@ -278,6 +285,22 @@ InitHall3D PROC uses esi edi
mov floorTexture3D, 100 mov floorTexture3D, 100
mov casinoSprites[14*SIZEOF SpriteObject].interactId, 0 mov casinoSprites[14*SIZEOF SpriteObject].interactId, 0
mov patronClock3D, 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 InitCasinoNpcMind
call InitNpcLife3D call InitNpcLife3D
ret ret