2

I have this a piece of code, disassembled DX:

.text:004386D3                 push    ecx
.text:004386D4                 fld1
.text:004386D6                 fstp    [esp+26Ch+var_26C] ;load 1.0 value texture coords
.text:004386D9                 push    ecx
.text:004386DA                 fld1
.text:004386DC                 fstp    [esp+270h+var_270] ;load 1.0 value texture coords
.text:004386DF                 push    ecx
.text:004386E0                 fld     ds:__real@c1700000
.text:004386E6                 fstp    [esp+274h+var_274] ;load -15.0 value x vertex
.text:004386E9                 push    ecx
.text:004386EA                 fld     ds:__real@c1700000
.text:004386F0                 fstp    [esp+278h+var_278] ;load -15.0 value y vertex
.text:004386F3                 push    ecx
.text:004386F4                 fld     ds:__real@c1700000
.text:004386FA                 fstp    [esp+27Ch+var_27C] ;load -15.0 value z vertex
.text:004386FD                 lea     ecx, [ebp+var_22C] ;this pointer
.text:00438703                 call    j_D3DVERTEX__D3DVERTEX ;fills structure with values
.text:00438708                 mov     ecx, [ebp+var_8] ;var_8 pointer returned by Lock() buffer func
.text:0043870B                 mov     edx, [eax]
.text:0043870D                 mov     [ecx], edx
.text:0043870F                 mov     edx, [eax+4]
.text:00438712                 mov     [ecx+4], edx
.text:00438715                 mov     edx, [eax+8]
.text:00438718                 mov     [ecx+8], edx
.text:0043871B                 mov     edx, [eax+0Ch]
.text:0043871E                 mov     [ecx+0Ch], edx
.text:00438721                 mov     eax, [eax+10h]
.text:00438724                 mov     [ecx+10h], eax

This code fills one vertex structure with values:

-15.000000,-15.000000,-15.000000, 1.0,1.0

It seems values is stored into two copies. First copy of this values stored relatively ebp+var_22C and into ecx passed this pointer:

.text:004386FD                 lea     ecx, [ebp+var_22C] ; ecx has pointer this to store values
.text:00438703                 call    j_D3DVERTEX__D3DVERTEX ;fills structure with values

And second copy this values stored relatively ebp+var_8 after calling j_D3DVERTEX__D3DVERTEX:

.text:00438708                 mov     ecx, [ebp+var_8] ;var_8 pointer returned by Lock() buffer func

I.e. completely it's looks like:

.text:004386FD                 lea     ecx, [ebp+var_22C] ; ecx has pointer this to store values
.text:00438703                 call    j_D3DVERTEX__D3DVERTEX ;store values into structure
.text:00438708                 mov     ecx, [ebp+var_8] ;var_8 pointer returned by Lock() buffer func

If I right understood- why need two copy of this vertex values? Maybe it is important the vertex buffer created with D3DPOOL_MANAGED and D3DUSAGE_WRITEONLY parameters.

-1

Inside D3DVERTEX__D3DVERTEX [ebp+var_334] i.e. ecx passed to variable [ebp+var_4] and in end of function [ebp+var_4] passed to eax as return:

.text:00439440 D3DVERTEX__D3DVERTEX proc near          ; CODE XREF: j_D3DVERTEX__D3DVERTEXj
.text:00439440
.text:00439440 var_5C          = dword ptr -5Ch
.text:00439440 var_58          = dword ptr -58h
.text:00439440 var_54          = dword ptr -54h
.text:00439440 var_4           = dword ptr -4
.text:00439440 arg_0           = dword ptr  8
.text:00439440 arg_4           = dword ptr  0Ch
.text:00439440 arg_8           = dword ptr  10h
.text:00439440 arg_C           = dword ptr  14h
.text:00439440 arg_10          = dword ptr  18h
.text:00439440
.text:00439440                 push    ebp
.text:00439441                 mov     ebp, esp
.text:00439443                 sub     esp, 44h
.text:00439446                 push    ebx
.text:00439447                 push    esi
.text:00439448                 push    edi
.text:00439449                 mov     [ebp+var_4], ecx

...........
.text:0043947B                 mov     eax, [ebp+var_4]
.text:0043947E                 pop     edi
.text:0043947F                 pop     esi
.text:00439480                 pop     ebx
.text:00439481                 mov     esp, ebp
.text:00439483                 pop     ebp
.text:00439484                 retn    14h
.text:00439484 D3DVERTEX__D3DVERTEX endp

and after D3DVERTEX__D3DVERTEX this eax used as base bointer to fill memory of vertex buffer with values:

.text:00438703                 call    j_D3DVERTEX__D3DVERTEX
.text:00438708                 mov     ecx, [ebp+var_8] ;pointer to vertex buffer
.text:0043870B                 mov     edx, [eax] ;eax returned by j_D3DVERTEX__D3DVERTEX

Maybe j_D3DVERTEX__D3DVERTEX used to arrange and prepare vertex values to fill vertex memory after calling j_D3DVERTEX__D3DVERTEX?

| improve this answer | |
  • 2
    This does not seem to be an answer; may be best to add this info to the question. – Igor Skochinsky Jun 4 at 10:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.