Commit a173c8e3 authored by Stefan Dösinger's avatar Stefan Dösinger Committed by Alexandre Julliard

wined3d: Add IWineD3DDevice::DrawPrimitiveStrided.

parent 1cfbc903
......@@ -5272,7 +5272,7 @@ HRESULT WINAPI IWineD3DDeviceImpl_DrawPrimitive(IWineD3DDevice *iface, D3DPRIMIT
debug_d3dprimitivetype(PrimitiveType),
StartVertex, PrimitiveCount);
drawPrimitive(iface, PrimitiveType, PrimitiveCount, StartVertex, 0/* NumVertices */, -1 /* indxStart */,
0 /* indxSize */, NULL /* indxData */, 0 /* minIndex */);
0 /* indxSize */, NULL /* indxData */, 0 /* minIndex */, NULL);
return WINED3D_OK;
......@@ -5304,7 +5304,7 @@ HRESULT WINAPI IWineD3DDeviceImpl_DrawIndexedPrimitive(IWineD3DDevice *iface,
}
drawPrimitive(iface, PrimitiveType, primCount, baseVIndex, NumVertices, startIndex,
idxStride, ((IWineD3DIndexBufferImpl *) pIB)->resource.allocatedMemory, minIndex);
idxStride, ((IWineD3DIndexBufferImpl *) pIB)->resource.allocatedMemory, minIndex, NULL);
return WINED3D_OK;
}
......@@ -5329,7 +5329,7 @@ HRESULT WINAPI IWineD3DDeviceImpl_DrawPrimitiveUP(IWineD3DDevice *iface, D3DPRIM
This->stateBlock->streamIsUP = TRUE;
drawPrimitive(iface, PrimitiveType, PrimitiveCount, 0 /* start vertex */, 0 /* NumVertices */,
0 /* indxStart*/, 0 /* indxSize*/, NULL /* indxData */, 0 /* indxMin */);
0 /* indxStart*/, 0 /* indxSize*/, NULL /* indxData */, 0 /* indxMin */, NULL);
/* stream zero settings set to null at end, as per the msdn
http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/directx9_c/directx/graphics/reference/d3d/interfaces/idirect3ddevice9/DrawPrimitiveUP.asp
*/
......@@ -5372,7 +5372,7 @@ HRESULT WINAPI IWineD3DDeviceImpl_DrawIndexedPrimitiveUP(IWineD3DDevice *iface,
This->stateBlock->streamIsUP = TRUE;
This->stateBlock->streamStride[0] = VertexStreamZeroStride;
drawPrimitive(iface, PrimitiveType, PrimitiveCount, 0 /* vertexStart */, NumVertices, 0 /* indxStart */, idxStride, pIndexData, MinVertexIndex);
drawPrimitive(iface, PrimitiveType, PrimitiveCount, 0 /* vertexStart */, NumVertices, 0 /* indxStart */, idxStride, pIndexData, MinVertexIndex, NULL);
/* stream zero settings set to null at end as per the msdn
http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/directx9_c/directx/graphics/reference/d3d/interfaces/idirect3ddevice9/DrawPrimitiveUP.asp
*/
......@@ -5384,6 +5384,11 @@ HRESULT WINAPI IWineD3DDeviceImpl_DrawIndexedPrimitiveUP(IWineD3DDevice *iface,
return WINED3D_OK;
}
HRESULT WINAPI IWineD3DDeviceImpl_DrawPrimitiveStrided (IWineD3DDevice *iface, D3DPRIMITIVETYPE PrimitiveType, UINT PrimitiveCount, WineDirect3DVertexStridedData *DrawPrimStrideData) {
drawPrimitive(iface, PrimitiveType, PrimitiveCount, 0, 0, 0, 0, NULL, 0, DrawPrimStrideData);
return WINED3D_OK;
}
/* Yet another way to update a texture, some apps use this to load default textures instead of using surface/texture lock/unlock */
HRESULT WINAPI IWineD3DDeviceImpl_UpdateTexture (IWineD3DDevice *iface, IWineD3DBaseTexture *pSourceTexture, IWineD3DBaseTexture *pDestinationTexture){
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
......@@ -7176,6 +7181,7 @@ const IWineD3DDeviceVtbl IWineD3DDevice_Vtbl =
IWineD3DDeviceImpl_DrawIndexedPrimitive,
IWineD3DDeviceImpl_DrawPrimitiveUP,
IWineD3DDeviceImpl_DrawIndexedPrimitiveUP,
IWineD3DDeviceImpl_DrawPrimitiveStrided,
IWineD3DDeviceImpl_DrawRectPatch,
IWineD3DDeviceImpl_DrawTriPatch,
IWineD3DDeviceImpl_DeletePatch,
......
......@@ -315,7 +315,7 @@ static BOOL primitiveInitState(IWineD3DDevice *iface, BOOL vtx_transformed, BOOL
return isLightingOn;
}
void primitiveDeclarationConvertToStridedData(IWineD3DDevice *iface, BOOL useVertexShaderFunction, Direct3DVertexStridedData *strided, LONG BaseVertexIndex, DWORD *fvf, BOOL storeOrder, INT arrayUsageMap[WINED3DSHADERDECLUSAGE_MAX_USAGE]) {
void primitiveDeclarationConvertToStridedData(IWineD3DDevice *iface, BOOL useVertexShaderFunction, WineDirect3DVertexStridedData *strided, LONG BaseVertexIndex, DWORD *fvf, BOOL storeOrder, INT arrayUsageMap[WINED3DSHADERDECLUSAGE_MAX_USAGE]) {
/* We need to deal with frequency data!*/
int textureNo =0;
......@@ -557,7 +557,7 @@ void primitiveDeclarationConvertToStridedData(IWineD3DDevice *iface, BOOL useVer
}
static void primitiveConvertToStridedData(IWineD3DDevice *iface, Direct3DVertexStridedData *strided, LONG BaseVertexIndex) {
static void primitiveConvertToStridedData(IWineD3DDevice *iface, WineDirect3DVertexStridedData *strided, LONG BaseVertexIndex) {
short LoopThroughTo = 0;
short nStream;
......@@ -845,7 +845,7 @@ static void draw_vertex(IWineD3DDevice *iface, /* interf
}
#endif /* TODO: Software shaders */
void loadNumberedArrays(IWineD3DDevice *iface, Direct3DVertexStridedData *sd, INT arrayUsageMap[WINED3DSHADERDECLUSAGE_MAX_USAGE]) {
void loadNumberedArrays(IWineD3DDevice *iface, WineDirect3DVertexStridedData *sd, INT arrayUsageMap[WINED3DSHADERDECLUSAGE_MAX_USAGE]) {
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
#define LOAD_NUMBERED_ARRAY(_arrayName, _lookupName) \
......@@ -928,7 +928,7 @@ void loadNumberedArrays(IWineD3DDevice *iface, Direct3DVertexStridedData *sd, IN
#undef LOAD_NUMBERED_ARRAY
}
static void loadVertexData(IWineD3DDevice *iface, Direct3DVertexStridedData *sd) {
static void loadVertexData(IWineD3DDevice *iface, WineDirect3DVertexStridedData *sd) {
unsigned int textureNo = 0;
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
......@@ -1259,7 +1259,7 @@ static void drawStridedFast(IWineD3DDevice *iface,UINT numberOfVertices, GLenum
* Slower GL version which extracts info about each vertex in turn
*/
static void drawStridedSlow(IWineD3DDevice *iface, Direct3DVertexStridedData *sd,
static void drawStridedSlow(IWineD3DDevice *iface, WineDirect3DVertexStridedData *sd,
UINT NumVertexes, GLenum glPrimType,
const void *idxData, short idxSize, ULONG minIndex, ULONG startIdx) {
......@@ -1555,7 +1555,7 @@ static void drawStridedSlow(IWineD3DDevice *iface, Direct3DVertexStridedData *sd
* Note: strided data is uninitialized, as we need to pass the vertex
* shader directly as ordering irs yet
*/
void drawStridedSoftwareVS(IWineD3DDevice *iface, Direct3DVertexStridedData *sd,
void drawStridedSoftwareVS(IWineD3DDevice *iface, WineDirect3DVertexStridedData *sd,
int PrimitiveType, ULONG NumPrimitives,
const void *idxData, short idxSize, ULONG minIndex, ULONG startIdx) {
......@@ -1692,7 +1692,7 @@ void drawStridedSoftwareVS(IWineD3DDevice *iface, Direct3DVertexStridedData *sd,
#endif
void inline drawPrimitiveDrawStrided(IWineD3DDevice *iface, BOOL useVertexShaderFunction, BOOL usePixelShaderFunction, int useHW, Direct3DVertexStridedData *dataLocations,
void inline drawPrimitiveDrawStrided(IWineD3DDevice *iface, BOOL useVertexShaderFunction, BOOL usePixelShaderFunction, int useHW, WineDirect3DVertexStridedData *dataLocations,
UINT numberOfvertices, UINT numberOfIndicies, GLenum glPrimType, const void *idxData, short idxSize, int minIndex, long StartIdx) {
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
......@@ -1909,7 +1909,7 @@ UINT numberOfvertices, UINT numberOfIndicies, GLenum glPrimType, const void *idx
}
}
void inline drawPrimitiveTraceDataLocations(Direct3DVertexStridedData *dataLocations,DWORD fvf) {
void inline drawPrimitiveTraceDataLocations(WineDirect3DVertexStridedData *dataLocations,DWORD fvf) {
/* Dump out what parts we have supplied */
TRACE("Strided Data (from FVF/VS): %lx\n", fvf);
......@@ -2042,15 +2042,16 @@ void inline drawPrimitiveUploadTextures(IWineD3DDeviceImpl* This) {
/* Routine common to the draw primitive and draw indexed primitive routines */
void drawPrimitive(IWineD3DDevice *iface,
int PrimitiveType,
long NumPrimitives,
/* for Indexed: */
long StartVertexIndex,
UINT numberOfVertices,
long StartIdx,
short idxSize,
const void *idxData,
int minIndex) {
int PrimitiveType,
long NumPrimitives,
/* for Indexed: */
long StartVertexIndex,
UINT numberOfVertices,
long StartIdx,
short idxSize,
const void *idxData,
int minIndex,
WineDirect3DVertexStridedData *DrawPrimStrideData) {
BOOL rc = FALSE;
DWORD fvf = 0;
......@@ -2058,7 +2059,7 @@ void drawPrimitive(IWineD3DDevice *iface,
BOOL useVertexShaderFunction = FALSE;
BOOL usePixelShaderFunction = FALSE;
BOOL isLightingOn = FALSE;
Direct3DVertexStridedData dataLocations;
WineDirect3DVertexStridedData *dataLocations;
int useHW = FALSE;
if (This->stateBlock->vertexShader != NULL && wined3d_settings.vs_mode != VS_NONE
......@@ -2086,23 +2087,35 @@ void drawPrimitive(IWineD3DDevice *iface,
/* Ok, we will be updating the screen from here onwards so grab the lock */
ENTER_GL();
/* Initialize all values to null */
memset(&dataLocations, 0x00, sizeof(dataLocations));
/* convert the FVF or vertexDeclaration into a strided stream (this should be done when the fvf or declaration is created) */
if (This->stateBlock->vertexDecl != NULL || (useVertexShaderFunction && NULL != ((IWineD3DVertexShaderImpl *)This->stateBlock->vertexShader)->vertexDeclaration)) {
if(DrawPrimStrideData) {
TRACE("================ Strided Input ===================\n");
dataLocations = DrawPrimStrideData;
}
else if (This->stateBlock->vertexDecl != NULL || (useVertexShaderFunction && NULL != ((IWineD3DVertexShaderImpl *)This->stateBlock->vertexShader)->vertexDeclaration)) {
BOOL storeArrays = useVertexShaderFunction && ((IWineD3DVertexShaderImpl *)This->stateBlock->vertexShader)->declaredArrays == FALSE && ((IWineD3DVertexShaderImpl *)This->stateBlock->vertexShader)->namedArrays == FALSE;
TRACE("================ Vertex Declaration ===================\n");
primitiveDeclarationConvertToStridedData(iface, useVertexShaderFunction, &dataLocations, StartVertexIndex, &fvf, storeArrays,
dataLocations = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*dataLocations));
if(!dataLocations) {
ERR("Out of memory!\n");
return;
}
primitiveDeclarationConvertToStridedData(iface, useVertexShaderFunction, dataLocations, StartVertexIndex, &fvf, storeArrays,
((IWineD3DVertexShaderImpl *)This->stateBlock->vertexShader)->arrayUsageMap);
} else {
TRACE("================ FVF ===================\n");
primitiveConvertToStridedData(iface, &dataLocations, StartVertexIndex);
dataLocations = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*dataLocations));
if(!dataLocations) {
ERR("Out of memory!\n");
return;
}
primitiveConvertToStridedData(iface, dataLocations, StartVertexIndex);
}
/* write out some debug information*/
drawPrimitiveTraceDataLocations(&dataLocations, fvf);
drawPrimitiveTraceDataLocations(dataLocations, fvf);
/* Setup transform matrices and sort out */
if (useHW) {
......@@ -2120,7 +2133,7 @@ void drawPrimitive(IWineD3DDevice *iface,
}
/* Now initialize the materials state */
init_materials(iface, (dataLocations.u.s.diffuse.lpData != NULL));
init_materials(iface, (dataLocations->u.s.diffuse.lpData != NULL));
drawPrimitiveUploadTextures(This);
......@@ -2137,9 +2150,11 @@ void drawPrimitive(IWineD3DDevice *iface,
#endif
if (numberOfVertices == 0 )
numberOfVertices = calculatedNumberOfindices;
drawPrimitiveDrawStrided(iface, useVertexShaderFunction, usePixelShaderFunction, useHW, &dataLocations, numberOfVertices, calculatedNumberOfindices, glPrimType, idxData, idxSize, minIndex, StartIdx);
drawPrimitiveDrawStrided(iface, useVertexShaderFunction, usePixelShaderFunction, useHW, dataLocations, numberOfVertices, calculatedNumberOfindices, glPrimType, idxData, idxSize, minIndex, StartIdx);
}
if(!DrawPrimStrideData) HeapFree(GetProcessHeap(), 0, dataLocations);
/* If vertex shaders or no normals, restore previous lighting state */
if (useVertexShaderFunction || !(fvf & D3DFVF_NORMAL)) {
if (isLightingOn) glEnable(GL_LIGHTING);
......
......@@ -375,47 +375,14 @@ void drawPrimitive(IWineD3DDevice *iface,
long StartIdx,
short idxBytes,
const void *idxData,
int minIndex);
int minIndex,
WineDirect3DVertexStridedData *DrawPrimStrideData);
/* Routine to fill gl caps for swapchains and IWineD3D */
BOOL IWineD3DImpl_FillGLCaps(WineD3D_GL_Info *gl_info,
Display* display);
/*****************************************************************************
* 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[MAX_TEXTURES];
Direct3DStridedData position2; /* tween data */
Direct3DStridedData normal2; /* tween data */
Direct3DStridedData tangent;
Direct3DStridedData binormal;
Direct3DStridedData tessFactor;
Direct3DStridedData fog;
Direct3DStridedData depth;
Direct3DStridedData sample;
} s;
Direct3DStridedData input[16]; /* Indexed by constants in D3DVSDE_REGISTER */
} u;
} Direct3DVertexStridedData;
/*****************************************************************************
* Internal representation of a light
*/
typedef struct PLIGHTINFOEL PLIGHTINFOEL;
......
......@@ -491,6 +491,7 @@ DECLARE_INTERFACE_(IWineD3DDevice,IWineD3DBase)
STDMETHOD(DrawIndexedPrimitive)(THIS_ D3DPRIMITIVETYPE PrimitiveType,INT baseVIdx, UINT minIndex,UINT NumVertices,UINT startIndex,UINT primCount) PURE;
STDMETHOD(DrawPrimitiveUP)(THIS_ D3DPRIMITIVETYPE PrimitiveType,UINT PrimitiveCount,CONST void * pVertexStreamZeroData,UINT VertexStreamZeroStride) PURE;
STDMETHOD(DrawIndexedPrimitiveUP)(THIS_ D3DPRIMITIVETYPE PrimitiveType,UINT MinVertexIndex,UINT NumVertexIndices,UINT PrimitiveCount,CONST void * pIndexData,WINED3DFORMAT IndexDataFormat,CONST void * pVertexStreamZeroData,UINT VertexStreamZeroStride) PURE;
STDMETHOD(DrawPrimitiveStrided)(THIS_ D3DPRIMITIVETYPE PrimitiveType, UINT PrimitiveCount, WineDirect3DVertexStridedData *DrawPrimStrideData) PURE;
STDMETHOD(DrawRectPatch)(THIS_ UINT Handle, CONST float* pNumSegs, CONST WINED3DRECTPATCH_INFO* pRectPatchInfo) PURE;
STDMETHOD(DrawTriPatch)(THIS_ UINT Handle, CONST float* pNumSegs, CONST WINED3DTRIPATCH_INFO* pTriPatchInfo) PURE;
STDMETHOD(DeletePatch)(THIS_ UINT Handle) PURE;
......@@ -639,6 +640,7 @@ DECLARE_INTERFACE_(IWineD3DDevice,IWineD3DBase)
#define IWineD3DDevice_DrawIndexedPrimitive(p,a,b,c,d,e,f) (p)->lpVtbl->DrawIndexedPrimitive(p,a,b,c,d,e,f)
#define IWineD3DDevice_DrawPrimitiveUP(p,a,b,c,d) (p)->lpVtbl->DrawPrimitiveUP(p,a,b,c,d)
#define IWineD3DDevice_DrawIndexedPrimitiveUP(p,a,b,c,d,e,f,g,h) (p)->lpVtbl->DrawIndexedPrimitiveUP(p,a,b,c,d,e,f,g,h)
#define IWineD3DDevice_DrawPrimitiveStrided(p,a,b,c) (p)->lpVtbl->DrawPrimitiveStrided(p,a,b,c)
#define IWineD3DDevice_DrawRectPatch(p,a,b,c) (p)->lpVtbl->DrawRectPatch(p,a,b,c)
#define IWineD3DDevice_DrawTriPatch(p,a,b,c) (p)->lpVtbl->DrawTriPatch(p,a,b,c)
#define IWineD3DDevice_DeletePatch(p,a) (p)->lpVtbl->DeletePatch(p,a)
......
......@@ -870,6 +870,59 @@ typedef struct glDescriptor {
int/*GLenum*/ glFormatInternal;
int/*GLenum*/ glType;
} glDescriptor;
typedef enum _WINED3DDECLTYPE {
WINED3DDECLTYPE_FLOAT1 = 0,
WINED3DDECLTYPE_FLOAT2 = 1,
WINED3DDECLTYPE_FLOAT3 = 2,
WINED3DDECLTYPE_FLOAT4 = 3,
WINED3DDECLTYPE_D3DCOLOR = 4,
WINED3DDECLTYPE_UBYTE4 = 5,
WINED3DDECLTYPE_SHORT2 = 6,
WINED3DDECLTYPE_SHORT4 = 7,
/* VS 2.0 */
WINED3DDECLTYPE_UBYTE4N = 8,
WINED3DDECLTYPE_SHORT2N = 9,
WINED3DDECLTYPE_SHORT4N = 10,
WINED3DDECLTYPE_USHORT2N = 11,
WINED3DDECLTYPE_USHORT4N = 12,
WINED3DDECLTYPE_UDEC3 = 13,
WINED3DDECLTYPE_DEC3N = 14,
WINED3DDECLTYPE_FLOAT16_2 = 15,
WINED3DDECLTYPE_FLOAT16_4 = 16,
WINED3DDECLTYPE_UNUSED = 17,
} WINED3DDECLTYPE;
typedef struct WineDirect3DStridedData {
BYTE *lpData; /* Pointer to start of data */
DWORD dwStride; /* Stride between occurances of this data */
DWORD dwType; /* Type (as in D3DVSDT_TYPE) */
} WineDirect3DStridedData;
typedef struct WineDirect3DVertexStridedData {
union {
struct {
WineDirect3DStridedData position;
WineDirect3DStridedData blendWeights;
WineDirect3DStridedData blendMatrixIndices;
WineDirect3DStridedData normal;
WineDirect3DStridedData pSize;
WineDirect3DStridedData diffuse;
WineDirect3DStridedData specular;
WineDirect3DStridedData texCoords[D3DDP_MAXTEXCOORD];
WineDirect3DStridedData position2; /* tween data */
WineDirect3DStridedData normal2; /* tween data */
WineDirect3DStridedData tangent;
WineDirect3DStridedData binormal;
WineDirect3DStridedData tessFactor;
WineDirect3DStridedData fog;
WineDirect3DStridedData depth;
WineDirect3DStridedData sample;
} s;
WineDirect3DStridedData input[16]; /* Indexed by constants in D3DVSDE_REGISTER */
} u;
} WineDirect3DVertexStridedData;
/****************************
* * Vertex Shaders Declaration
* */
......
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