Commit 3cf874bb authored by Jason Edmeades's avatar Jason Edmeades Committed by Alexandre Julliard

Make the fixed function pipeline support multiple streams for created

vertex shaders with no function supplied. Also split down draw primitive along the lines of the d3dcore requirements and put in some diagnostic aids.
parent 3f5b518d
...@@ -16,6 +16,7 @@ C_SRCS = \ ...@@ -16,6 +16,7 @@ C_SRCS = \
d3d8_main.c \ d3d8_main.c \
device.c \ device.c \
directx.c \ directx.c \
drawprim.c \
indexbuffer.c \ indexbuffer.c \
resource.c \ resource.c \
shader.c \ shader.c \
......
...@@ -67,6 +67,15 @@ extern void (*wine_tsx11_unlock_ptr)(void); ...@@ -67,6 +67,15 @@ extern void (*wine_tsx11_unlock_ptr)(void);
#define HIGHEST_TRANSFORMSTATE 512 #define HIGHEST_TRANSFORMSTATE 512
#define D3DSBT_RECORDED 0xfffffffe #define D3DSBT_RECORDED 0xfffffffe
/* CreateVertexShader can return > 0xFFFF */
#define VS_HIGHESTFIXEDFXF 0xF0000000
#define VERTEX_SHADER(Handle) \
((Handle <= VS_HIGHESTFIXEDFXF) ? ((Handle >= sizeof(VertexShaders) / sizeof(IDirect3DVertexShaderImpl*)) ? NULL : VertexShaders[Handle]) : VertexShaders[Handle - VS_HIGHESTFIXEDFXF])
#define VERTEX_SHADER_DECL(Handle) \
((Handle <= VS_HIGHESTFIXEDFXF) ? ((Handle >= sizeof(VertexShaderDeclarations) / sizeof(IDirect3DVertexShaderDeclarationImpl*)) ? NULL : VertexShaderDeclarations[Handle]) : VertexShaderDeclarations[Handle - VS_HIGHESTFIXEDFXF])
#define PIXEL_SHADER(Handle) \
((Handle <= VS_HIGHESTFIXEDFXF) ? ((Handle >= sizeof(PixelShaders) / sizeof(IDirect3DPixelShaderImpl*)) ? NULL : PixelShaders[Handle]) : PixelShaders[Handle - VS_HIGHESTFIXEDFXF])
/* Direct3D8 Interfaces: */ /* Direct3D8 Interfaces: */
typedef struct IDirect3DBaseTexture8Impl IDirect3DBaseTexture8Impl; typedef struct IDirect3DBaseTexture8Impl IDirect3DBaseTexture8Impl;
typedef struct IDirect3DVolumeTexture8Impl IDirect3DVolumeTexture8Impl; typedef struct IDirect3DVolumeTexture8Impl IDirect3DVolumeTexture8Impl;
...@@ -112,14 +121,14 @@ typedef struct VSHADERDATA8 { ...@@ -112,14 +121,14 @@ typedef struct VSHADERDATA8 {
/** temporary here waiting for buffer code */ /** temporary here waiting for buffer code */
typedef struct VSHADERINPUTDATA8 { typedef struct VSHADERINPUTDATA8 {
D3DSHADERVECTOR V[16]; D3DSHADERVECTOR V[17];
} VSHADERINPUTDATA8; } VSHADERINPUTDATA8;
/** temporary here waiting for buffer code */ /** temporary here waiting for buffer code */
typedef struct VSHADEROUTPUTDATA8 { typedef struct VSHADEROUTPUTDATA8 {
D3DSHADERVECTOR oPos; D3DSHADERVECTOR oPos;
D3DSHADERVECTOR oD[2]; D3DSHADERVECTOR oD[2];
D3DSHADERVECTOR oT[4]; D3DSHADERVECTOR oT[8];
D3DSHADERVECTOR oFog; D3DSHADERVECTOR oFog;
D3DSHADERVECTOR oPts; D3DSHADERVECTOR oPts;
} VSHADEROUTPUTDATA8; } VSHADEROUTPUTDATA8;
...@@ -1064,7 +1073,8 @@ struct IDirect3DStateBlockImpl { ...@@ -1064,7 +1073,8 @@ struct IDirect3DStateBlockImpl {
/* Stream Source */ /* Stream Source */
UINT stream_stride[MAX_STREAMS]; UINT stream_stride[MAX_STREAMS];
IDirect3DVertexBuffer8 *stream_source[MAX_STREAMS]; IDirect3DVertexBuffer8 *stream_source[MAX_STREAMS];
BOOL streamIsUP;
/* Indices */ /* Indices */
IDirect3DIndexBuffer8* pIndexData; IDirect3DIndexBuffer8* pIndexData;
UINT baseVertexIndex; UINT baseVertexIndex;
...@@ -1141,7 +1151,9 @@ struct IDirect3DVertexShaderDeclarationImpl { ...@@ -1141,7 +1151,9 @@ struct IDirect3DVertexShaderDeclarationImpl {
IDirect3DDevice8Impl* device; IDirect3DDevice8Impl* device;
/** precomputed fvf if simple declaration */ /** precomputed fvf if simple declaration */
DWORD fvf; DWORD fvf[MAX_STREAMS];
DWORD allFVF;
/** dx8 compatible Declaration fields */ /** dx8 compatible Declaration fields */
DWORD* pDeclaration8; DWORD* pDeclaration8;
DWORD declaration8Length; DWORD declaration8Length;
...@@ -1197,7 +1209,7 @@ extern DWORD WINAPI IDirect3DVertexShaderImpl_GetVersion(IDirect3DVertexShaderIm ...@@ -1197,7 +1209,7 @@ extern DWORD WINAPI IDirect3DVertexShaderImpl_GetVersion(IDirect3DVertexShaderIm
extern HRESULT WINAPI IDirect3DVertexShaderImpl_ExecuteSW(IDirect3DVertexShaderImpl* This, VSHADERINPUTDATA8* input, VSHADEROUTPUTDATA8* output); extern HRESULT WINAPI IDirect3DVertexShaderImpl_ExecuteSW(IDirect3DVertexShaderImpl* This, VSHADERINPUTDATA8* input, VSHADEROUTPUTDATA8* output);
/* temporary internal Interfaces */ /* temporary internal Interfaces */
extern HRESULT WINAPI IDirect3DDeviceImpl_CreateVertexShader(IDirect3DDevice8Impl* This, CONST DWORD* pFunction, DWORD Usage, IDirect3DVertexShaderImpl** ppVertexShader); extern HRESULT WINAPI IDirect3DDeviceImpl_CreateVertexShader(IDirect3DDevice8Impl* This, CONST DWORD* pFunction, DWORD Usage, IDirect3DVertexShaderImpl** ppVertexShader);
extern HRESULT WINAPI IDirect3DDeviceImpl_FillVertexShaderInput(IDirect3DDevice8Impl* This, IDirect3DVertexShaderImpl* vshader, const void* vertexFirstStream, DWORD StartVertexIndex, DWORD idxDecal); extern HRESULT WINAPI IDirect3DDeviceImpl_FillVertexShaderInput(IDirect3DDevice8Impl* This, IDirect3DVertexShaderImpl* vshader, DWORD SkipnStrides);
/* ------------------------ */ /* ------------------------ */
/* IDirect3DPixelShaderImpl */ /* IDirect3DPixelShaderImpl */
...@@ -1272,4 +1284,37 @@ const char* debug_d3dressourcetype(D3DRESOURCETYPE res); ...@@ -1272,4 +1284,37 @@ const char* debug_d3dressourcetype(D3DRESOURCETYPE res);
const char* debug_d3dprimitivetype(D3DPRIMITIVETYPE PrimitiveType); const char* debug_d3dprimitivetype(D3DPRIMITIVETYPE PrimitiveType);
const char* debug_d3dpool(D3DPOOL Pool); const char* debug_d3dpool(D3DPOOL Pool);
/* Some #defines for additional diagnostics */
#if 0 /* NOTE: Must be 0 in cvs */
/* To avoid having to get gigabytes of trace, the following can be compiled in, and at the start
of each frame, a check is made for the existance of C:\D3DTRACE, and if if exists d3d trace
is enabled, and if it doesnt exists it is disabled. */
# define FRAME_DEBUGGING
/* Adding in the SINGLE_FRAME_DEBUGGING gives a trace of just what makes up a single frame, before
the file is deleted */
# if 1
# define SINGLE_FRAME_DEBUGGING
# endif
/* The following, when enabled, lets you see the makeup of the frame, by drawprimitive calls.
A check is made for the existence of C:\D3DSHOWFRAME, and if it exists will write the
contents of the back buffer into /tmp/backbuffer_* after each primitive array is drawn
for a single frame. At the end of the frame, the file is deleted. */
# if 1
# define SHOW_FRAME_MAKEUP 1
# endif
extern BOOL isOn;
extern BOOL isDumpingFrames;
extern LONG primCounter;
#endif
/* Per-vertex trace: */
#if 0 /* NOTE: Must be 0 in cvs */
# define VTRACE(A) TRACE A
#else
# define VTRACE(A)
#endif
#define TRACE_VECTOR(name) TRACE( #name "=(%f, %f, %f, %f)\n", name.x, name.y, name.z, name.w);
#define TRACE_STRIDED(sd,name) TRACE( #name "=(data:%p, stride:%ld, type:%ld)\n", sd->u.s.name.lpData, sd->u.s.name.dwStride, sd->u.s.name.dwType);
#endif /* __WINE_D3DX8_PRIVATE_H */ #endif /* __WINE_D3DX8_PRIVATE_H */
...@@ -268,4 +268,44 @@ typedef enum _GL_PSVersion { ...@@ -268,4 +268,44 @@ typedef enum _GL_PSVersion {
#define WINAPI __stdcall #define WINAPI __stdcall
#define APIENTRY WINAPI #define APIENTRY WINAPI
/* Routine common to the draw primitive and draw indexed primitive routines */
void drawPrimitive(LPDIRECT3DDEVICE8 iface,
int PrimitiveType,
long NumPrimitives,
/* for Indexed: */
long StartVertexIndex,
long StartIdx,
short idxBytes,
const void *idxData,
int minIndex);
/* Structures required to draw primitives */
typedef struct Direct3DStridedData {
BYTE *lpData; /* Pointer to start of data */
DWORD dwStride; /* Stride between occurances of this data */
DWORD dwType; /* Type (as in D3DVSDT_TYPE) */
} Direct3DStridedData;
typedef struct Direct3DVertexStridedData {
union {
struct {
Direct3DStridedData position;
Direct3DStridedData blendWeights;
Direct3DStridedData blendMatrixIndices;
Direct3DStridedData normal;
Direct3DStridedData pSize;
Direct3DStridedData diffuse;
Direct3DStridedData specular;
Direct3DStridedData texCoords[8];
} DUMMYSTRUCTNAME;
Direct3DStridedData input[16]; /* Indexed by constants in D3DVSDE_REGISTER */
} DUMMYUNIONNAME;
} Direct3DVertexStridedData;
#endif /* __WINE_D3DCORE_GL_H */ #endif /* __WINE_D3DCORE_GL_H */
...@@ -34,12 +34,12 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3d_shader); ...@@ -34,12 +34,12 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3d_shader);
/* Shader debugging - Change the following line to enable debugging of software /* Shader debugging - Change the following line to enable debugging of software
vertex shaders */ vertex shaders */
#if 0 #if 0 /* Must not be 1 in cvs version */
# define VSTRACE(A) TRACE A # define VSTRACE(A) TRACE A
# define TRACE_VECTOR(name) TRACE( #name "=(%f, %f, %f, %f)\n", name.x, name.y, name.z, name.w) # define TRACE_VSVECTOR(name) TRACE( #name "=(%f, %f, %f, %f)\n", name.x, name.y, name.z, name.w)
#else #else
# define VSTRACE(A) # define VSTRACE(A)
# define TRACE_VECTOR(name) # define TRACE_VSVECTOR(name)
#endif #endif
...@@ -584,30 +584,30 @@ HRESULT WINAPI IDirect3DVertexShaderImpl_ExecuteSW(IDirect3DVertexShaderImpl* vs ...@@ -584,30 +584,30 @@ HRESULT WINAPI IDirect3DVertexShaderImpl_ExecuteSW(IDirect3DVertexShaderImpl* vs
memset(R, 0, 12 * sizeof(D3DSHADERVECTOR)); memset(R, 0, 12 * sizeof(D3DSHADERVECTOR));
/* vshader_program_parse(vshader); */ /* vshader_program_parse(vshader); */
#if 0 #if 0 /* Must not be 1 in cvs */
TRACE("Input:\n"); TRACE("Input:\n");
TRACE_VECTOR(vshader->data->C[0]); TRACE_VSVECTOR(vshader->data->C[0]);
TRACE_VECTOR(vshader->data->C[1]); TRACE_VSVECTOR(vshader->data->C[1]);
TRACE_VECTOR(vshader->data->C[2]); TRACE_VSVECTOR(vshader->data->C[2]);
TRACE_VECTOR(vshader->data->C[3]); TRACE_VSVECTOR(vshader->data->C[3]);
TRACE_VECTOR(vshader->data->C[4]); TRACE_VSVECTOR(vshader->data->C[4]);
TRACE_VECTOR(vshader->data->C[5]); TRACE_VSVECTOR(vshader->data->C[5]);
TRACE_VECTOR(vshader->data->C[6]); TRACE_VSVECTOR(vshader->data->C[6]);
TRACE_VECTOR(vshader->data->C[7]); TRACE_VSVECTOR(vshader->data->C[7]);
TRACE_VECTOR(vshader->data->C[8]); TRACE_VSVECTOR(vshader->data->C[8]);
TRACE_VECTOR(vshader->data->C[64]); TRACE_VSVECTOR(vshader->data->C[64]);
TRACE_VECTOR(input->V[D3DVSDE_POSITION]); TRACE_VSVECTOR(input->V[D3DVSDE_POSITION]);
TRACE_VECTOR(input->V[D3DVSDE_BLENDWEIGHT]); TRACE_VSVECTOR(input->V[D3DVSDE_BLENDWEIGHT]);
TRACE_VECTOR(input->V[D3DVSDE_BLENDINDICES]); TRACE_VSVECTOR(input->V[D3DVSDE_BLENDINDICES]);
TRACE_VECTOR(input->V[D3DVSDE_NORMAL]); TRACE_VSVECTOR(input->V[D3DVSDE_NORMAL]);
TRACE_VECTOR(input->V[D3DVSDE_PSIZE]); TRACE_VSVECTOR(input->V[D3DVSDE_PSIZE]);
TRACE_VECTOR(input->V[D3DVSDE_DIFFUSE]); TRACE_VSVECTOR(input->V[D3DVSDE_DIFFUSE]);
TRACE_VECTOR(input->V[D3DVSDE_SPECULAR]); TRACE_VSVECTOR(input->V[D3DVSDE_SPECULAR]);
TRACE_VECTOR(input->V[D3DVSDE_TEXCOORD0]); TRACE_VSVECTOR(input->V[D3DVSDE_TEXCOORD0]);
TRACE_VECTOR(input->V[D3DVSDE_TEXCOORD1]); TRACE_VSVECTOR(input->V[D3DVSDE_TEXCOORD1]);
#endif #endif
TRACE_VECTOR(vshader->data->C[64]); TRACE_VSVECTOR(vshader->data->C[64]);
/* the first dword is the version tag */ /* the first dword is the version tag */
/* TODO: parse it */ /* TODO: parse it */
...@@ -756,17 +756,17 @@ HRESULT WINAPI IDirect3DVertexShaderImpl_ExecuteSW(IDirect3DVertexShaderImpl* vs ...@@ -756,17 +756,17 @@ HRESULT WINAPI IDirect3DVertexShaderImpl_ExecuteSW(IDirect3DVertexShaderImpl* vs
} }
#if 0 #if 0
TRACE_VECTOR(output->oPos); TRACE_VSVECTOR(output->oPos);
TRACE_VECTOR(output->oD[0]); TRACE_VSVECTOR(output->oD[0]);
TRACE_VECTOR(output->oD[1]); TRACE_VSVECTOR(output->oD[1]);
TRACE_VECTOR(output->oT[0]); TRACE_VSVECTOR(output->oT[0]);
TRACE_VECTOR(output->oT[1]); TRACE_VSVECTOR(output->oT[1]);
TRACE_VECTOR(R[0]); TRACE_VSVECTOR(R[0]);
TRACE_VECTOR(R[1]); TRACE_VSVECTOR(R[1]);
TRACE_VECTOR(R[2]); TRACE_VSVECTOR(R[2]);
TRACE_VECTOR(R[3]); TRACE_VSVECTOR(R[3]);
TRACE_VECTOR(R[4]); TRACE_VSVECTOR(R[4]);
TRACE_VECTOR(R[5]); TRACE_VSVECTOR(R[5]);
#endif #endif
/* to next opcode token */ /* to next opcode token */
...@@ -774,26 +774,26 @@ HRESULT WINAPI IDirect3DVertexShaderImpl_ExecuteSW(IDirect3DVertexShaderImpl* vs ...@@ -774,26 +774,26 @@ HRESULT WINAPI IDirect3DVertexShaderImpl_ExecuteSW(IDirect3DVertexShaderImpl* vs
} }
#if 0 #if 0
TRACE("End of current instruction:\n"); TRACE("End of current instruction:\n");
TRACE_VECTOR(output->oPos); TRACE_VSVECTOR(output->oPos);
TRACE_VECTOR(output->oD[0]); TRACE_VSVECTOR(output->oD[0]);
TRACE_VECTOR(output->oD[1]); TRACE_VSVECTOR(output->oD[1]);
TRACE_VECTOR(output->oT[0]); TRACE_VSVECTOR(output->oT[0]);
TRACE_VECTOR(output->oT[1]); TRACE_VSVECTOR(output->oT[1]);
TRACE_VECTOR(R[0]); TRACE_VSVECTOR(R[0]);
TRACE_VECTOR(R[1]); TRACE_VSVECTOR(R[1]);
TRACE_VECTOR(R[2]); TRACE_VSVECTOR(R[2]);
TRACE_VECTOR(R[3]); TRACE_VSVECTOR(R[3]);
TRACE_VECTOR(R[4]); TRACE_VSVECTOR(R[4]);
TRACE_VECTOR(R[5]); TRACE_VSVECTOR(R[5]);
#endif #endif
} }
#if 0 #if 0 /* Must not be 1 in cvs */
TRACE("Output:\n"); TRACE("Output:\n");
TRACE_VECTOR(output->oPos); TRACE_VSVECTOR(output->oPos);
TRACE_VECTOR(output->oD[0]); TRACE_VSVECTOR(output->oD[0]);
TRACE_VECTOR(output->oD[1]); TRACE_VSVECTOR(output->oD[1]);
TRACE_VECTOR(output->oT[0]); TRACE_VSVECTOR(output->oT[0]);
TRACE_VECTOR(output->oT[1]); TRACE_VSVECTOR(output->oT[1]);
#endif #endif
return D3D_OK; return D3D_OK;
} }
......
...@@ -31,14 +31,6 @@ ...@@ -31,14 +31,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3d_surface); WINE_DEFAULT_DEBUG_CHANNEL(d3d_surface);
/* trace: */
#if 0
# define VTRACE(A) TRACE A
#else
# define VTRACE(A)
#endif
/* IDirect3DVolume IUnknown parts follow: */ /* IDirect3DVolume IUnknown parts follow: */
HRESULT WINAPI IDirect3DSurface8Impl_QueryInterface(LPDIRECT3DSURFACE8 iface,REFIID riid,LPVOID *ppobj) HRESULT WINAPI IDirect3DSurface8Impl_QueryInterface(LPDIRECT3DSURFACE8 iface,REFIID riid,LPVOID *ppobj)
{ {
......
...@@ -35,13 +35,6 @@ ...@@ -35,13 +35,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3d); WINE_DEFAULT_DEBUG_CHANNEL(d3d);
#if 0
# define VTRACE(A) TRACE A
#else
# define VTRACE(A)
#endif
const char* debug_d3ddevicetype(D3DDEVTYPE devtype) { const char* debug_d3ddevicetype(D3DDEVTYPE devtype) {
switch (devtype) { switch (devtype) {
#define DEVTYPE_TO_STR(dev) case dev: return #dev #define DEVTYPE_TO_STR(dev) case dev: return #dev
......
...@@ -203,6 +203,7 @@ HRESULT WINAPI IDirect3DDeviceImpl_CreateVertexShaderDeclaration8(IDirect3DDevic ...@@ -203,6 +203,7 @@ HRESULT WINAPI IDirect3DDeviceImpl_CreateVertexShaderDeclaration8(IDirect3DDevic
/*object->lpVtbl = &Direct3DVextexShaderDeclaration8_Vtbl;*/ /*object->lpVtbl = &Direct3DVextexShaderDeclaration8_Vtbl;*/
object->device = This; /* FIXME: AddRef(This) */ object->device = This; /* FIXME: AddRef(This) */
object->ref = 1; object->ref = 1;
object->allFVF = 0;
while (D3DVSD_END() != *pToken) { while (D3DVSD_END() != *pToken) {
token = *pToken; token = *pToken;
...@@ -215,16 +216,27 @@ HRESULT WINAPI IDirect3DDeviceImpl_CreateVertexShaderDeclaration8(IDirect3DDevic ...@@ -215,16 +216,27 @@ HRESULT WINAPI IDirect3DDeviceImpl_CreateVertexShaderDeclaration8(IDirect3DDevic
* how really works streams, * how really works streams,
* in DolphinVS dx8 dsk sample they seems to decal reg numbers !!! * in DolphinVS dx8 dsk sample they seems to decal reg numbers !!!
*/ */
DWORD oldStream = stream;
stream = ((token & D3DVSD_STREAMNUMBERMASK) >> D3DVSD_STREAMNUMBERSHIFT); stream = ((token & D3DVSD_STREAMNUMBERMASK) >> D3DVSD_STREAMNUMBERSHIFT);
if (stream > 0) { /* copy fvf if valid */
/** fvf cannot map mutliple streams, so invalid fvf computing */ if (FALSE == invalid_fvf) {
invalid_fvf = TRUE; fvf |= tex << D3DFVF_TEXCOUNT_SHIFT;
tex = 0;
object->fvf[oldStream] = fvf;
object->allFVF |= fvf;
} else {
object->fvf[oldStream] = 0;
tex = 0;
} }
/* reset valid/invalid fvf */
fvf = 0;
invalid_fvf = FALSE;
} else if (D3DVSD_TOKEN_STREAMDATA == tokentype && 0 == (0x10000000 & tokentype)) { } else if (D3DVSD_TOKEN_STREAMDATA == tokentype && 0 == (0x10000000 & tokentype)) {
DWORD type = ((token & D3DVSD_DATATYPEMASK) >> D3DVSD_DATATYPESHIFT); DWORD type = ((token & D3DVSD_DATATYPEMASK) >> D3DVSD_DATATYPESHIFT);
DWORD reg = ((token & D3DVSD_VERTEXREGMASK) >> D3DVSD_VERTEXREGSHIFT) - stream; DWORD reg = ((token & D3DVSD_VERTEXREGMASK) >> D3DVSD_VERTEXREGSHIFT);
switch (reg) { switch (reg) {
case D3DVSDE_POSITION: case D3DVSDE_POSITION:
...@@ -241,7 +253,7 @@ HRESULT WINAPI IDirect3DDeviceImpl_CreateVertexShaderDeclaration8(IDirect3DDevic ...@@ -241,7 +253,7 @@ HRESULT WINAPI IDirect3DDeviceImpl_CreateVertexShaderDeclaration8(IDirect3DDevic
} }
} }
break; break;
case D3DVSDE_BLENDWEIGHT: case D3DVSDE_BLENDWEIGHT:
switch (type) { switch (type) {
case D3DVSDT_FLOAT1: fvf |= D3DFVF_XYZB1; break; case D3DVSDT_FLOAT1: fvf |= D3DFVF_XYZB1; break;
...@@ -305,40 +317,54 @@ HRESULT WINAPI IDirect3DDeviceImpl_CreateVertexShaderDeclaration8(IDirect3DDevic ...@@ -305,40 +317,54 @@ HRESULT WINAPI IDirect3DDeviceImpl_CreateVertexShaderDeclaration8(IDirect3DDevic
} }
break; break;
/** case D3DVSDE_TEXCOORD0:
* TODO: for TEX* only FLOAT2 supported case D3DVSDE_TEXCOORD1:
* by default using texture type info case D3DVSDE_TEXCOORD2:
*/ case D3DVSDE_TEXCOORD3:
case D3DVSDE_TEXCOORD0: tex = max(tex, D3DFVF_TEX1); break; case D3DVSDE_TEXCOORD4:
case D3DVSDE_TEXCOORD1: tex = max(tex, D3DFVF_TEX2); break; case D3DVSDE_TEXCOORD5:
case D3DVSDE_TEXCOORD2: tex = max(tex, D3DFVF_TEX3); break; case D3DVSDE_TEXCOORD6:
case D3DVSDE_TEXCOORD3: tex = max(tex, D3DFVF_TEX4); break; case D3DVSDE_TEXCOORD7:
case D3DVSDE_TEXCOORD4: tex = max(tex, D3DFVF_TEX5); break; /* Fixme? - assume all tex coords in same stream */
case D3DVSDE_TEXCOORD5: tex = max(tex, D3DFVF_TEX6); break; {
case D3DVSDE_TEXCOORD6: tex = max(tex, D3DFVF_TEX7); break; int texNo = 1 + (reg - D3DVSDE_TEXCOORD0);
case D3DVSDE_TEXCOORD7: tex = max(tex, D3DFVF_TEX8); break; tex = max(tex, texNo);
switch (type) {
case D3DVSDT_FLOAT1: fvf |= D3DFVF_TEXCOORDSIZE1(texNo); break;
case D3DVSDT_FLOAT2: fvf |= D3DFVF_TEXCOORDSIZE2(texNo); break;
case D3DVSDT_FLOAT3: fvf |= D3DFVF_TEXCOORDSIZE3(texNo); break;
case D3DVSDT_FLOAT4: fvf |= D3DFVF_TEXCOORDSIZE4(texNo); break;
default:
/** errooooorr mismatched use of a register, invalid fvf computing */
invalid_fvf = TRUE;
TRACE("Mismatched use in VertexShader declaration of D3DVSDE_TEXCOORD? register: unsupported type %s\n", VertexShaderDeclDataTypes[type]);
}
}
break;
case D3DVSDE_POSITION2: /* maybe D3DFVF_XYZRHW instead D3DFVF_XYZ (of D3DVDE_POSITION) ... to see */ case D3DVSDE_POSITION2: /* maybe D3DFVF_XYZRHW instead D3DFVF_XYZ (of D3DVDE_POSITION) ... to see */
case D3DVSDE_NORMAL2: /* FIXME i don't know what to do here ;( */ case D3DVSDE_NORMAL2: /* FIXME i don't know what to do here ;( */
FIXME("[%lu] registers in VertexShader declaration not supported yet (token:0x%08lx)\n", reg, token); TRACE("[%lu] registers in VertexShader declaration not supported yet (token:0x%08lx)\n", reg, token);
break; break;
} }
/*TRACE("VertexShader declaration define %x as current FVF\n", fvf);*/ TRACE("VertexShader declaration define %lx as current FVF\n", fvf);
} }
len += tokenlen; len += tokenlen;
pToken += tokenlen; pToken += tokenlen;
} }
if (tex > 0) {
/*TRACE("VertexShader declaration define %x as texture level\n", tex);*/
fvf |= tex;
}
/* here D3DVSD_END() */ /* here D3DVSD_END() */
len += Direct3DVextexShaderDeclarationImpl_ParseToken(pToken); len += Direct3DVextexShaderDeclarationImpl_ParseToken(pToken);
/* copy fvf if valid */ /* copy fvf if valid */
if (FALSE == invalid_fvf) if (FALSE == invalid_fvf) {
object->fvf = fvf; fvf |= tex << D3DFVF_TEXCOUNT_SHIFT;
else object->fvf[stream] = fvf;
object->fvf = 0; object->allFVF |= fvf;
} else {
object->fvf[stream] = 0;
}
TRACE("Completed, allFVF = %lx\n", object->allFVF);
/* compute size */ /* compute size */
object->declaration8Length = len * sizeof(DWORD); object->declaration8Length = len * sizeof(DWORD);
/* copy the declaration */ /* copy the declaration */
...@@ -352,9 +378,7 @@ HRESULT WINAPI IDirect3DDeviceImpl_CreateVertexShaderDeclaration8(IDirect3DDevic ...@@ -352,9 +378,7 @@ HRESULT WINAPI IDirect3DDeviceImpl_CreateVertexShaderDeclaration8(IDirect3DDevic
HRESULT WINAPI IDirect3DDeviceImpl_FillVertexShaderInput(IDirect3DDevice8Impl* This, HRESULT WINAPI IDirect3DDeviceImpl_FillVertexShaderInput(IDirect3DDevice8Impl* This,
IDirect3DVertexShaderImpl* vshader, IDirect3DVertexShaderImpl* vshader,
const void* vertexFirstStream, DWORD SkipnStrides) {
DWORD StartVertexIndex,
DWORD idxDecal) {
/** parser data */ /** parser data */
const DWORD* pToken = This->UpdateStateBlock->vertexShaderDecl->pDeclaration8; const DWORD* pToken = This->UpdateStateBlock->vertexShaderDecl->pDeclaration8;
DWORD stream = 0; DWORD stream = 0;
...@@ -367,7 +391,7 @@ HRESULT WINAPI IDirect3DDeviceImpl_FillVertexShaderInput(IDirect3DDevice8Impl* T ...@@ -367,7 +391,7 @@ HRESULT WINAPI IDirect3DDeviceImpl_FillVertexShaderInput(IDirect3DDevice8Impl* T
SHORT u, v, r, t; SHORT u, v, r, t;
DWORD dw; DWORD dw;
TRACE("(%p) - This:%p - stream:%p, startIdx=%lu, idxDecal=%lu\n", vshader, This, vertexFirstStream, StartVertexIndex, idxDecal); TRACE("(%p) - This:%p, skipstrides=%lu\n", vshader, This, SkipnStrides);
while (D3DVSD_END() != *pToken) { while (D3DVSD_END() != *pToken) {
token = *pToken; token = *pToken;
...@@ -376,7 +400,6 @@ HRESULT WINAPI IDirect3DDeviceImpl_FillVertexShaderInput(IDirect3DDevice8Impl* T ...@@ -376,7 +400,6 @@ HRESULT WINAPI IDirect3DDeviceImpl_FillVertexShaderInput(IDirect3DDevice8Impl* T
/** FVF generation block */ /** FVF generation block */
if (D3DVSD_TOKEN_STREAM == tokentype && 0 == (D3DVSD_STREAMTESSMASK & token)) { if (D3DVSD_TOKEN_STREAM == tokentype && 0 == (D3DVSD_STREAMTESSMASK & token)) {
IDirect3DVertexBuffer8* pVB; IDirect3DVertexBuffer8* pVB;
const char* startVtx = NULL;
int skip = 0; int skip = 0;
++pToken; ++pToken;
...@@ -385,25 +408,21 @@ HRESULT WINAPI IDirect3DDeviceImpl_FillVertexShaderInput(IDirect3DDevice8Impl* T ...@@ -385,25 +408,21 @@ HRESULT WINAPI IDirect3DDeviceImpl_FillVertexShaderInput(IDirect3DDevice8Impl* T
* in DolphinVS dx8 dsk sample use it !!! * in DolphinVS dx8 dsk sample use it !!!
*/ */
stream = ((token & D3DVSD_STREAMNUMBERMASK) >> D3DVSD_STREAMNUMBERSHIFT); stream = ((token & D3DVSD_STREAMNUMBERMASK) >> D3DVSD_STREAMNUMBERSHIFT);
skip = This->StateBlock->stream_stride[stream];
if (0 == stream) { pVB = This->StateBlock->stream_source[stream];
skip = This->StateBlock->stream_stride[0];
startVtx = (const char*) vertexFirstStream + (StartVertexIndex * skip); if (NULL == pVB) {
curPos = startVtx + idxDecal;
/*TRACE(" using stream[%lu] with %lu decal => curPos %p\n", stream, idxDecal, curPos);*/
} else {
skip = This->StateBlock->stream_stride[stream];
pVB = This->StateBlock->stream_source[stream];
if (NULL == pVB) {
ERR("using unitialised stream[%lu]\n", stream); ERR("using unitialised stream[%lu]\n", stream);
return D3DERR_INVALIDCALL; return D3DERR_INVALIDCALL;
} else { } else {
startVtx = ((IDirect3DVertexBuffer8Impl*) pVB)->allocatedMemory + (StartVertexIndex * skip); if (This->StateBlock->streamIsUP == TRUE) {
/** do we need to decal if we use idxBuffer */ curPos = ((char *) pVB) + (SkipnStrides * skip); /* Not really a VB */
curPos = startVtx + idxDecal; } else {
/*TRACE(" using stream[%lu] with %lu decal\n", stream, idxDecal);*/ curPos = ((IDirect3DVertexBuffer8Impl*) pVB)->allocatedMemory + (SkipnStrides * skip);
} }
TRACE(" using stream[%lu] with %p (%p + (Stride %d * skip %ld))\n", stream, curPos,
((IDirect3DVertexBuffer8Impl*) pVB)->allocatedMemory, skip, SkipnStrides);
} }
} else if (D3DVSD_TOKEN_CONSTMEM == tokentype) { } else if (D3DVSD_TOKEN_CONSTMEM == tokentype) {
/** Const decl */ /** Const decl */
......
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