Commit 27b8e555 authored by Raphael Junqueira's avatar Raphael Junqueira Committed by Alexandre Julliard

- convert D3D8 VertexDecl to D3D9 format (D3DVERTEXELEMENT9 vector)

while parsing - display result on traces
parent b4ae3258
...@@ -251,6 +251,8 @@ DWORD IWineD3DVertexDeclarationImpl_ParseToken8(const DWORD* pToken) { ...@@ -251,6 +251,8 @@ DWORD IWineD3DVertexDeclarationImpl_ParseToken8(const DWORD* pToken) {
return tokenlen; return tokenlen;
} }
DWORD IWineD3DVertexDeclarationImpl_ParseToken9(const D3DVERTEXELEMENT9* pToken);
HRESULT IWineD3DVertexDeclarationImpl_ParseDeclaration8(IWineD3DDeviceImpl* This, const DWORD* pDecl, IWineD3DVertexDeclarationImpl* object) { HRESULT IWineD3DVertexDeclarationImpl_ParseDeclaration8(IWineD3DDeviceImpl* This, const DWORD* pDecl, IWineD3DVertexDeclarationImpl* object) {
const DWORD* pToken = pDecl; const DWORD* pToken = pDecl;
DWORD fvf = 0; DWORD fvf = 0;
...@@ -261,6 +263,8 @@ HRESULT IWineD3DVertexDeclarationImpl_ParseDeclaration8(IWineD3DDeviceImpl* This ...@@ -261,6 +263,8 @@ HRESULT IWineD3DVertexDeclarationImpl_ParseDeclaration8(IWineD3DDeviceImpl* This
DWORD token; DWORD token;
DWORD tokenlen; DWORD tokenlen;
DWORD tokentype; DWORD tokentype;
DWORD nTokens = 0;
D3DVERTEXELEMENT9 convTo9[128];
TRACE("(%p) : pDecl(%p)\n", This, pDecl); TRACE("(%p) : pDecl(%p)\n", This, pDecl);
...@@ -297,8 +301,15 @@ HRESULT IWineD3DVertexDeclarationImpl_ParseDeclaration8(IWineD3DDeviceImpl* This ...@@ -297,8 +301,15 @@ HRESULT IWineD3DVertexDeclarationImpl_ParseDeclaration8(IWineD3DDeviceImpl* This
DWORD type = ((token & D3DVSD_DATATYPEMASK) >> D3DVSD_DATATYPESHIFT); DWORD type = ((token & D3DVSD_DATATYPEMASK) >> D3DVSD_DATATYPESHIFT);
DWORD reg = ((token & D3DVSD_VERTEXREGMASK) >> D3DVSD_VERTEXREGSHIFT); DWORD reg = ((token & D3DVSD_VERTEXREGMASK) >> D3DVSD_VERTEXREGSHIFT);
convTo9[nTokens].Stream = stream;
convTo9[nTokens].Method = D3DDECLMETHOD_DEFAULT;
convTo9[nTokens].UsageIndex = 0;
convTo9[nTokens].Type = D3DDECLTYPE_UNUSED;
switch (reg) { switch (reg) {
case D3DVSDE_POSITION: case D3DVSDE_POSITION:
convTo9[nTokens].Usage = D3DDECLUSAGE_POSITION;
convTo9[nTokens].Type = type;
switch (type) { switch (type) {
case D3DVSDT_FLOAT3: fvf |= D3DFVF_XYZ; break; case D3DVSDT_FLOAT3: fvf |= D3DFVF_XYZ; break;
case D3DVSDT_FLOAT4: fvf |= D3DFVF_XYZRHW; break; case D3DVSDT_FLOAT4: fvf |= D3DFVF_XYZRHW; break;
...@@ -314,6 +325,8 @@ HRESULT IWineD3DVertexDeclarationImpl_ParseDeclaration8(IWineD3DDeviceImpl* This ...@@ -314,6 +325,8 @@ HRESULT IWineD3DVertexDeclarationImpl_ParseDeclaration8(IWineD3DDeviceImpl* This
break; break;
case D3DVSDE_BLENDWEIGHT: case D3DVSDE_BLENDWEIGHT:
convTo9[nTokens].Usage = D3DDECLUSAGE_BLENDWEIGHT;
convTo9[nTokens].Type = type;
switch (type) { switch (type) {
case D3DVSDT_FLOAT1: fvf |= D3DFVF_XYZB1; break; case D3DVSDT_FLOAT1: fvf |= D3DFVF_XYZB1; break;
case D3DVSDT_FLOAT2: fvf |= D3DFVF_XYZB2; break; case D3DVSDT_FLOAT2: fvf |= D3DFVF_XYZB2; break;
...@@ -327,6 +340,8 @@ HRESULT IWineD3DVertexDeclarationImpl_ParseDeclaration8(IWineD3DDeviceImpl* This ...@@ -327,6 +340,8 @@ HRESULT IWineD3DVertexDeclarationImpl_ParseDeclaration8(IWineD3DDeviceImpl* This
break; break;
case D3DVSDE_BLENDINDICES: /* seem to be B5 as said in MSDN Dx9SDK ?? */ case D3DVSDE_BLENDINDICES: /* seem to be B5 as said in MSDN Dx9SDK ?? */
convTo9[nTokens].Usage = D3DDECLUSAGE_BLENDINDICES;
convTo9[nTokens].Type = type;
switch (type) { switch (type) {
case D3DVSDT_UBYTE4: fvf |= D3DFVF_LASTBETA_UBYTE4; break; case D3DVSDT_UBYTE4: fvf |= D3DFVF_LASTBETA_UBYTE4; break;
default: default:
...@@ -337,6 +352,8 @@ HRESULT IWineD3DVertexDeclarationImpl_ParseDeclaration8(IWineD3DDeviceImpl* This ...@@ -337,6 +352,8 @@ HRESULT IWineD3DVertexDeclarationImpl_ParseDeclaration8(IWineD3DDeviceImpl* This
break; break;
case D3DVSDE_NORMAL: /* TODO: only FLOAT3 supported ... another choice possible ? */ case D3DVSDE_NORMAL: /* TODO: only FLOAT3 supported ... another choice possible ? */
convTo9[nTokens].Usage = D3DDECLUSAGE_NORMAL;
convTo9[nTokens].Type = type;
switch (type) { switch (type) {
case D3DVSDT_FLOAT3: fvf |= D3DFVF_NORMAL; break; case D3DVSDT_FLOAT3: fvf |= D3DFVF_NORMAL; break;
default: default:
...@@ -347,6 +364,8 @@ HRESULT IWineD3DVertexDeclarationImpl_ParseDeclaration8(IWineD3DDeviceImpl* This ...@@ -347,6 +364,8 @@ HRESULT IWineD3DVertexDeclarationImpl_ParseDeclaration8(IWineD3DDeviceImpl* This
break; break;
case D3DVSDE_PSIZE: /* TODO: only FLOAT1 supported ... another choice possible ? */ case D3DVSDE_PSIZE: /* TODO: only FLOAT1 supported ... another choice possible ? */
convTo9[nTokens].Usage = D3DDECLUSAGE_PSIZE;
convTo9[nTokens].Type = type;
switch (type) { switch (type) {
case D3DVSDT_FLOAT1: fvf |= D3DFVF_PSIZE; break; case D3DVSDT_FLOAT1: fvf |= D3DFVF_PSIZE; break;
default: default:
...@@ -357,6 +376,9 @@ HRESULT IWineD3DVertexDeclarationImpl_ParseDeclaration8(IWineD3DDeviceImpl* This ...@@ -357,6 +376,9 @@ HRESULT IWineD3DVertexDeclarationImpl_ParseDeclaration8(IWineD3DDeviceImpl* This
break; break;
case D3DVSDE_DIFFUSE: /* TODO: only D3DCOLOR supported */ case D3DVSDE_DIFFUSE: /* TODO: only D3DCOLOR supported */
convTo9[nTokens].Usage = D3DDECLUSAGE_COLOR;
convTo9[nTokens].UsageIndex = 0;
convTo9[nTokens].Type = type;
switch (type) { switch (type) {
case D3DVSDT_D3DCOLOR: fvf |= D3DFVF_DIFFUSE; break; case D3DVSDT_D3DCOLOR: fvf |= D3DFVF_DIFFUSE; break;
default: default:
...@@ -367,6 +389,9 @@ HRESULT IWineD3DVertexDeclarationImpl_ParseDeclaration8(IWineD3DDeviceImpl* This ...@@ -367,6 +389,9 @@ HRESULT IWineD3DVertexDeclarationImpl_ParseDeclaration8(IWineD3DDeviceImpl* This
break; break;
case D3DVSDE_SPECULAR: /* TODO: only D3DCOLOR supported */ case D3DVSDE_SPECULAR: /* TODO: only D3DCOLOR supported */
convTo9[nTokens].Usage = D3DDECLUSAGE_COLOR;
convTo9[nTokens].UsageIndex = 1;
convTo9[nTokens].Type = type;
switch (type) { switch (type) {
case D3DVSDT_D3DCOLOR: fvf |= D3DFVF_SPECULAR; break; case D3DVSDT_D3DCOLOR: fvf |= D3DFVF_SPECULAR; break;
default: default:
...@@ -387,6 +412,9 @@ HRESULT IWineD3DVertexDeclarationImpl_ParseDeclaration8(IWineD3DDeviceImpl* This ...@@ -387,6 +412,9 @@ HRESULT IWineD3DVertexDeclarationImpl_ParseDeclaration8(IWineD3DDeviceImpl* This
/* Fixme? - assume all tex coords in same stream */ /* Fixme? - assume all tex coords in same stream */
{ {
int texNo = 1 + (reg - D3DVSDE_TEXCOORD0); int texNo = 1 + (reg - D3DVSDE_TEXCOORD0);
convTo9[nTokens].Usage = D3DDECLUSAGE_TEXCOORD;
convTo9[nTokens].UsageIndex = texNo;
convTo9[nTokens].Type = type;
tex = max(tex, texNo); tex = max(tex, texNo);
switch (type) { switch (type) {
case D3DVSDT_FLOAT1: fvf |= D3DFVF_TEXCOORDSIZE1(texNo); break; case D3DVSDT_FLOAT1: fvf |= D3DFVF_TEXCOORDSIZE1(texNo); break;
...@@ -408,12 +436,16 @@ HRESULT IWineD3DVertexDeclarationImpl_ParseDeclaration8(IWineD3DDeviceImpl* This ...@@ -408,12 +436,16 @@ HRESULT IWineD3DVertexDeclarationImpl_ParseDeclaration8(IWineD3DDeviceImpl* This
} }
TRACE("VertexShader declaration define %lx as current FVF\n", fvf); TRACE("VertexShader declaration define %lx as current FVF\n", fvf);
} }
++nTokens;
len += tokenlen; len += tokenlen;
pToken += tokenlen; pToken += tokenlen;
} }
/* here D3DVSD_END() */ /* here D3DVSD_END() */
len += IWineD3DVertexDeclarationImpl_ParseToken8(pToken); len += IWineD3DVertexDeclarationImpl_ParseToken8(pToken);
convTo9[nTokens].Stream = 0xFF;
convTo9[nTokens].Type = D3DDECLTYPE_UNUSED;
/* copy fvf if valid */ /* copy fvf if valid */
if (FALSE == invalid_fvf) { if (FALSE == invalid_fvf) {
fvf |= tex << D3DFVF_TEXCOUNT_SHIFT; fvf |= tex << D3DFVF_TEXCOUNT_SHIFT;
...@@ -429,6 +461,23 @@ HRESULT IWineD3DVertexDeclarationImpl_ParseDeclaration8(IWineD3DDeviceImpl* This ...@@ -429,6 +461,23 @@ HRESULT IWineD3DVertexDeclarationImpl_ParseDeclaration8(IWineD3DDeviceImpl* This
/* copy the declaration */ /* copy the declaration */
object->pDeclaration8 = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, object->declaration8Length); object->pDeclaration8 = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, object->declaration8Length);
memcpy(object->pDeclaration8, pDecl, object->declaration8Length); memcpy(object->pDeclaration8, pDecl, object->declaration8Length);
/* compute convTo9 size */
object->declaration9NumElements = nTokens;
/* copy the convTo9 declaration */
object->pDeclaration9 = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, nTokens * sizeof(D3DVERTEXELEMENT9));
memcpy(object->pDeclaration9, convTo9, nTokens * sizeof(D3DVERTEXELEMENT9));
{
D3DVERTEXELEMENT9* pIt = object->pDeclaration9;
TRACE("dumping of D3D9 Convertion:\n");
while (0xFF != pIt->Stream) {
IWineD3DVertexDeclarationImpl_ParseToken9(pIt);
++pIt;
}
IWineD3DVertexDeclarationImpl_ParseToken9(pIt);
}
/* returns */ /* returns */
return D3D_OK; return D3D_OK;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment