Move su_load_gmdls into the responsibility of the intro to call, anticipating multicore rendering so it is called once before all the cores are spun up.

This commit is contained in:
Veikko Sariola
2020-05-27 17:08:35 +03:00
parent 200937aa50
commit c5b6e6e28c
7 changed files with 30 additions and 23 deletions

View File

@ -6,24 +6,26 @@ extern OpenFile ; requires windows
extern ReadFile ; requires windows
SECT_TEXT(sugmdls)
EXPORT MANGLE_FUNC(su_load_gmdls,0)
; Win64 ABI: RCX, RDX, R8, and R9
su_gmdls_load:
sub rsp, 40 ; Win64 ABI requires "shadow space" + space for one parameter.
mov rdi, PTRWORD MANGLE_DATA(su_sample_table)
mov rsi, PTRWORD su_gmdls_path1
mov rdx, PTRWORD MANGLE_DATA(su_sample_table)
mov rcx, PTRWORD su_gmdls_path1
su_gmdls_pathloop:
xor r8,r8 ; OF_READ
mov rdx, rdi ; &ofstruct, blatantly reuse the sample table
mov rcx, rsi ; path
push rdx ; &ofstruct, blatantly reuse the sample table
push rcx
call OpenFile ; eax = OpenFile(path,&ofstruct,OF_READ)
add rsi, su_gmdls_path2 - su_gmdls_path1 ; if we ever get to third, then crash
movsxd rcx,eax
cmp rcx, -1 ; ecx == INVALID?
pop rcx
add rcx, su_gmdls_path2 - su_gmdls_path1 ; if we ever get to third, then crash
pop rdx
cmp eax, -1 ; ecx == INVALID?
je su_gmdls_pathloop
movsxd rcx, eax
mov qword [rsp+32],0
mov r9, rdi
mov r9, rdx
mov r8d, SAMPLE_TABLE_SIZE ; number of bytes to read
mov rdx, rdi
call ReadFile ; Readfile(handle,&su_sample_table,SAMPLE_TABLE_SIZE,&bytes_read,NULL)
add rsp, 40 ; shadow space, as required by Win64 ABI
ret