wined3d: Don't create an END element for wined3d vertex declarations.
Wined3d doesn't need it since it already has the element count.
This commit is contained in:
parent
9f26fed28d
commit
6f206c75ec
|
@ -324,11 +324,6 @@ UINT convert_to_wined3d_declaration(const DWORD *d3d8_elements, DWORD *d3d8_elem
|
||||||
token += parse_token(token);
|
token += parse_token(token);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* END */
|
|
||||||
element = *wined3d_elements + element_count++;
|
|
||||||
element->Stream = 0xFF;
|
|
||||||
element->Type = WINED3DDECLTYPE_UNUSED;
|
|
||||||
|
|
||||||
*d3d8_elements_size = (++token - d3d8_elements) * sizeof(DWORD);
|
*d3d8_elements_size = (++token - d3d8_elements) * sizeof(DWORD);
|
||||||
|
|
||||||
return element_count;
|
return element_count;
|
||||||
|
|
|
@ -312,13 +312,16 @@ static UINT convert_to_wined3d_declaration(const D3DVERTEXELEMENT9* d3d9_element
|
||||||
while (element++->Stream != 0xff && element_count++ < 128);
|
while (element++->Stream != 0xff && element_count++ < 128);
|
||||||
|
|
||||||
if (element_count == 128) {
|
if (element_count == 128) {
|
||||||
return 0;
|
return ~0U;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Skip the END element */
|
||||||
|
--element_count;
|
||||||
|
|
||||||
*wined3d_elements = HeapAlloc(GetProcessHeap(), 0, element_count * sizeof(WINED3DVERTEXELEMENT));
|
*wined3d_elements = HeapAlloc(GetProcessHeap(), 0, element_count * sizeof(WINED3DVERTEXELEMENT));
|
||||||
if (!*wined3d_elements) {
|
if (!*wined3d_elements) {
|
||||||
FIXME("Memory allocation failed\n");
|
FIXME("Memory allocation failed\n");
|
||||||
return 0;
|
return ~0U;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < element_count; ++i) {
|
for (i = 0; i < element_count; ++i) {
|
||||||
|
@ -335,6 +338,7 @@ HRESULT WINAPI IDirect3DDevice9Impl_CreateVertexDeclaration(LPDIRECT3DDEVICE9E
|
||||||
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
||||||
IDirect3DVertexDeclaration9Impl *object = NULL;
|
IDirect3DVertexDeclaration9Impl *object = NULL;
|
||||||
WINED3DVERTEXELEMENT* wined3d_elements;
|
WINED3DVERTEXELEMENT* wined3d_elements;
|
||||||
|
UINT wined3d_element_count;
|
||||||
UINT element_count;
|
UINT element_count;
|
||||||
HRESULT hr = D3D_OK;
|
HRESULT hr = D3D_OK;
|
||||||
|
|
||||||
|
@ -344,8 +348,9 @@ HRESULT WINAPI IDirect3DDevice9Impl_CreateVertexDeclaration(LPDIRECT3DDEVICE9E
|
||||||
return D3DERR_INVALIDCALL;
|
return D3DERR_INVALIDCALL;
|
||||||
}
|
}
|
||||||
|
|
||||||
element_count = convert_to_wined3d_declaration(pVertexElements, &wined3d_elements);
|
wined3d_element_count = convert_to_wined3d_declaration(pVertexElements, &wined3d_elements);
|
||||||
if (!element_count) {
|
if (wined3d_element_count == ~0U)
|
||||||
|
{
|
||||||
FIXME("(%p) : Error parsing vertex declaration\n", This);
|
FIXME("(%p) : Error parsing vertex declaration\n", This);
|
||||||
return D3DERR_INVALIDCALL;
|
return D3DERR_INVALIDCALL;
|
||||||
}
|
}
|
||||||
|
@ -361,6 +366,7 @@ HRESULT WINAPI IDirect3DDevice9Impl_CreateVertexDeclaration(LPDIRECT3DDEVICE9E
|
||||||
object->lpVtbl = &Direct3DVertexDeclaration9_Vtbl;
|
object->lpVtbl = &Direct3DVertexDeclaration9_Vtbl;
|
||||||
object->ref = 0;
|
object->ref = 0;
|
||||||
|
|
||||||
|
element_count = wined3d_element_count + 1;
|
||||||
object->elements = HeapAlloc(GetProcessHeap(), 0, element_count * sizeof(D3DVERTEXELEMENT9));
|
object->elements = HeapAlloc(GetProcessHeap(), 0, element_count * sizeof(D3DVERTEXELEMENT9));
|
||||||
if (!object->elements) {
|
if (!object->elements) {
|
||||||
HeapFree(GetProcessHeap(), 0, wined3d_elements);
|
HeapFree(GetProcessHeap(), 0, wined3d_elements);
|
||||||
|
@ -372,7 +378,8 @@ HRESULT WINAPI IDirect3DDevice9Impl_CreateVertexDeclaration(LPDIRECT3DDEVICE9E
|
||||||
object->element_count = element_count;
|
object->element_count = element_count;
|
||||||
|
|
||||||
EnterCriticalSection(&d3d9_cs);
|
EnterCriticalSection(&d3d9_cs);
|
||||||
hr = IWineD3DDevice_CreateVertexDeclaration(This->WineD3DDevice, &object->wineD3DVertexDeclaration, (IUnknown *)object, wined3d_elements, element_count);
|
hr = IWineD3DDevice_CreateVertexDeclaration(This->WineD3DDevice, &object->wineD3DVertexDeclaration,
|
||||||
|
(IUnknown *)object, wined3d_elements, wined3d_element_count);
|
||||||
LeaveCriticalSection(&d3d9_cs);
|
LeaveCriticalSection(&d3d9_cs);
|
||||||
|
|
||||||
HeapFree(GetProcessHeap(), 0, wined3d_elements);
|
HeapFree(GetProcessHeap(), 0, wined3d_elements);
|
||||||
|
|
|
@ -2200,8 +2200,6 @@ static unsigned int ConvertFvfToDeclaration(IWineD3DDeviceImpl *This, /* For the
|
||||||
|
|
||||||
DWORD num_textures = (fvf & WINED3DFVF_TEXCOUNT_MASK) >> WINED3DFVF_TEXCOUNT_SHIFT;
|
DWORD num_textures = (fvf & WINED3DFVF_TEXCOUNT_MASK) >> WINED3DFVF_TEXCOUNT_SHIFT;
|
||||||
DWORD texcoords = (fvf & 0xFFFF0000) >> 16;
|
DWORD texcoords = (fvf & 0xFFFF0000) >> 16;
|
||||||
|
|
||||||
WINED3DVERTEXELEMENT end_element = WINED3DDECL_END();
|
|
||||||
WINED3DVERTEXELEMENT *elements = NULL;
|
WINED3DVERTEXELEMENT *elements = NULL;
|
||||||
|
|
||||||
unsigned int size;
|
unsigned int size;
|
||||||
|
@ -2210,14 +2208,12 @@ static unsigned int ConvertFvfToDeclaration(IWineD3DDeviceImpl *This, /* For the
|
||||||
|
|
||||||
/* Compute declaration size */
|
/* Compute declaration size */
|
||||||
size = has_pos + (has_blend && num_blends > 0) + has_blend_idx + has_normal +
|
size = has_pos + (has_blend && num_blends > 0) + has_blend_idx + has_normal +
|
||||||
has_psize + has_diffuse + has_specular + num_textures + 1;
|
has_psize + has_diffuse + has_specular + num_textures;
|
||||||
|
|
||||||
/* convert the declaration */
|
/* convert the declaration */
|
||||||
elements = HeapAlloc(GetProcessHeap(), 0, size * sizeof(WINED3DVERTEXELEMENT));
|
elements = HeapAlloc(GetProcessHeap(), 0, size * sizeof(WINED3DVERTEXELEMENT));
|
||||||
if (!elements)
|
if (!elements) return ~0U;
|
||||||
return 0;
|
|
||||||
|
|
||||||
elements[size-1] = end_element;
|
|
||||||
idx = 0;
|
idx = 0;
|
||||||
if (has_pos) {
|
if (has_pos) {
|
||||||
if (!has_blend && (fvf & WINED3DFVF_XYZRHW)) {
|
if (!has_blend && (fvf & WINED3DFVF_XYZRHW)) {
|
||||||
|
@ -2310,7 +2306,8 @@ static unsigned int ConvertFvfToDeclaration(IWineD3DDeviceImpl *This, /* For the
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Now compute offsets, and initialize the rest of the fields */
|
/* Now compute offsets, and initialize the rest of the fields */
|
||||||
for (idx = 0, offset = 0; idx < size-1; idx++) {
|
for (idx = 0, offset = 0; idx < size; ++idx)
|
||||||
|
{
|
||||||
elements[idx].Stream = 0;
|
elements[idx].Stream = 0;
|
||||||
elements[idx].Method = WINED3DDECLMETHOD_DEFAULT;
|
elements[idx].Method = WINED3DDECLMETHOD_DEFAULT;
|
||||||
elements[idx].Offset = offset;
|
elements[idx].Offset = offset;
|
||||||
|
@ -2328,7 +2325,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateVertexDeclarationFromFVF(IWineD3D
|
||||||
DWORD hr;
|
DWORD hr;
|
||||||
|
|
||||||
size = ConvertFvfToDeclaration(This, Fvf, &elements);
|
size = ConvertFvfToDeclaration(This, Fvf, &elements);
|
||||||
if (size == 0) return WINED3DERR_OUTOFVIDEOMEMORY;
|
if (size == ~0U) return WINED3DERR_OUTOFVIDEOMEMORY;
|
||||||
|
|
||||||
hr = IWineD3DDevice_CreateVertexDeclaration(iface, ppVertexDeclaration, Parent, elements, size);
|
hr = IWineD3DDevice_CreateVertexDeclaration(iface, ppVertexDeclaration, Parent, elements, size);
|
||||||
HeapFree(GetProcessHeap(), 0, elements);
|
HeapFree(GetProcessHeap(), 0, elements);
|
||||||
|
|
|
@ -206,9 +206,6 @@ HRESULT vertexdeclaration_init(IWineD3DVertexDeclarationImpl *This,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Skip the END element. */
|
|
||||||
--element_count;
|
|
||||||
|
|
||||||
This->element_count = element_count;
|
This->element_count = element_count;
|
||||||
This->elements = HeapAlloc(GetProcessHeap(), 0, sizeof(*This->elements) * element_count);
|
This->elements = HeapAlloc(GetProcessHeap(), 0, sizeof(*This->elements) * element_count);
|
||||||
if (!This->elements)
|
if (!This->elements)
|
||||||
|
|
|
@ -846,7 +846,6 @@ typedef enum _WINED3DDECLTYPE
|
||||||
WINED3DDECLTYPE_FLOAT16_4 = 16,
|
WINED3DDECLTYPE_FLOAT16_4 = 16,
|
||||||
WINED3DDECLTYPE_UNUSED = 17,
|
WINED3DDECLTYPE_UNUSED = 17,
|
||||||
} WINED3DDECLTYPE;
|
} WINED3DDECLTYPE;
|
||||||
cpp_quote("#define WINED3DDECL_END() {0xFF, 0, WINED3DDECLTYPE_UNUSED, 0, 0, 0, -1}")
|
|
||||||
|
|
||||||
typedef enum _WINED3DDECLUSAGE
|
typedef enum _WINED3DDECLUSAGE
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue