058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync/*
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync * vertex declaration implementation
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync *
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync * Copyright 2002-2005 Raphael Junqueira
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync * Copyright 2004 Jason Edmeades
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync * Copyright 2004 Christian Costa
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync * Copyright 2005 Oliver Stieber
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync * Copyright 2009 Henri Verbeet for CodeWeavers
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync *
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync * This library is free software; you can redistribute it and/or
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync * modify it under the terms of the GNU Lesser General Public
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync * License as published by the Free Software Foundation; either
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync * version 2.1 of the License, or (at your option) any later version.
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync *
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync * This library is distributed in the hope that it will be useful,
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync * but WITHOUT ANY WARRANTY; without even the implied warranty of
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync * Lesser General Public License for more details.
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync *
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync * You should have received a copy of the GNU Lesser General Public
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync * License along with this library; if not, write to the Free Software
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync */
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
4237d5a79f48789aacc67dc43378d2d7813a39f4vboxsync/*
4237d5a79f48789aacc67dc43378d2d7813a39f4vboxsync * Oracle LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
4237d5a79f48789aacc67dc43378d2d7813a39f4vboxsync * other than GPL or LGPL is available it will apply instead, Oracle elects to use only
4237d5a79f48789aacc67dc43378d2d7813a39f4vboxsync * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
4237d5a79f48789aacc67dc43378d2d7813a39f4vboxsync * a choice of LGPL license versions is made available with the language indicating
4237d5a79f48789aacc67dc43378d2d7813a39f4vboxsync * that LGPLv2 or any later version may be used, or where a choice of which version
4237d5a79f48789aacc67dc43378d2d7813a39f4vboxsync * of the LGPL is applied is otherwise unspecified.
4237d5a79f48789aacc67dc43378d2d7813a39f4vboxsync */
4237d5a79f48789aacc67dc43378d2d7813a39f4vboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync#include "config.h"
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync#include "wine/port.h"
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync#include "wined3d_private.h"
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsyncWINE_DEFAULT_DEBUG_CHANNEL(d3d_decl);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsyncstatic void dump_wined3d_vertex_element(const struct wined3d_vertex_element *element)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync{
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync TRACE(" format: %s (%#x)\n", debug_d3dformat(element->format), element->format);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync TRACE(" input_slot: %u\n", element->input_slot);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync TRACE(" offset: %u\n", element->offset);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync TRACE("output_slot: %u\n", element->output_slot);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync TRACE(" method: %s (%#x)\n", debug_d3ddeclmethod(element->method), element->method);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync TRACE(" usage: %s (%#x)\n", debug_d3ddeclusage(element->usage), element->usage);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync TRACE(" usage_idx: %u\n", element->usage_idx);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync}
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsyncULONG CDECL wined3d_vertex_declaration_incref(struct wined3d_vertex_declaration *declaration)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync{
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync ULONG refcount = InterlockedIncrement(&declaration->ref);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync TRACE("%p increasing refcount to %u.\n", declaration, refcount);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync return refcount;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync}
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsyncULONG CDECL wined3d_vertex_declaration_decref(struct wined3d_vertex_declaration *declaration)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync{
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync ULONG refcount = InterlockedDecrement(&declaration->ref);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync TRACE("%p decreasing refcount to %u.\n", declaration, refcount);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if (!refcount)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync {
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync HeapFree(GetProcessHeap(), 0, declaration->elements);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync declaration->parent_ops->wined3d_object_destroyed(declaration->parent);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync HeapFree(GetProcessHeap(), 0, declaration);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync }
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync return refcount;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync}
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsyncvoid * CDECL wined3d_vertex_declaration_get_parent(const struct wined3d_vertex_declaration *declaration)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync{
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync TRACE("declaration %p.\n", declaration);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync return declaration->parent;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync}
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsyncstatic BOOL declaration_element_valid_ffp(const struct wined3d_vertex_element *element)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync{
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync switch(element->usage)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync {
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync case WINED3D_DECL_USAGE_POSITION:
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync case WINED3D_DECL_USAGE_POSITIONT:
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync switch(element->format)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync {
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync case WINED3DFMT_R32G32_FLOAT:
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync case WINED3DFMT_R32G32B32_FLOAT:
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync case WINED3DFMT_R32G32B32A32_FLOAT:
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync case WINED3DFMT_R16G16_SINT:
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync case WINED3DFMT_R16G16B16A16_SINT:
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync case WINED3DFMT_R16G16_FLOAT:
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync case WINED3DFMT_R16G16B16A16_FLOAT:
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync return TRUE;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync default:
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync return FALSE;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync }
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync case WINED3D_DECL_USAGE_BLEND_WEIGHT:
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync switch(element->format)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync {
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync case WINED3DFMT_R32_FLOAT:
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync case WINED3DFMT_R32G32_FLOAT:
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync case WINED3DFMT_R32G32B32_FLOAT:
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync case WINED3DFMT_R32G32B32A32_FLOAT:
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync case WINED3DFMT_B8G8R8A8_UNORM:
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync case WINED3DFMT_R8G8B8A8_UINT:
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync case WINED3DFMT_R16G16_SINT:
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync case WINED3DFMT_R16G16B16A16_SINT:
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync case WINED3DFMT_R16G16_FLOAT:
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync case WINED3DFMT_R16G16B16A16_FLOAT:
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync return TRUE;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync default:
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync return FALSE;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync }
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync case WINED3D_DECL_USAGE_NORMAL:
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync switch(element->format)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync {
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync case WINED3DFMT_R32G32B32_FLOAT:
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync case WINED3DFMT_R32G32B32A32_FLOAT:
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync case WINED3DFMT_R16G16B16A16_SINT:
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync case WINED3DFMT_R16G16B16A16_FLOAT:
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync return TRUE;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync default:
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync return FALSE;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync }
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync case WINED3D_DECL_USAGE_TEXCOORD:
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync switch(element->format)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync {
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync case WINED3DFMT_R32_FLOAT:
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync case WINED3DFMT_R32G32_FLOAT:
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync case WINED3DFMT_R32G32B32_FLOAT:
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync case WINED3DFMT_R32G32B32A32_FLOAT:
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync case WINED3DFMT_R16G16_SINT:
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync case WINED3DFMT_R16G16B16A16_SINT:
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync case WINED3DFMT_R16G16_FLOAT:
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync case WINED3DFMT_R16G16B16A16_FLOAT:
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync return TRUE;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync default:
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync return FALSE;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync }
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync case WINED3D_DECL_USAGE_COLOR:
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync switch(element->format)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync {
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync case WINED3DFMT_R32G32B32_FLOAT:
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync case WINED3DFMT_R32G32B32A32_FLOAT:
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync case WINED3DFMT_B8G8R8A8_UNORM:
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync case WINED3DFMT_R8G8B8A8_UINT:
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync case WINED3DFMT_R16G16B16A16_SINT:
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync case WINED3DFMT_R8G8B8A8_UNORM:
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync case WINED3DFMT_R16G16B16A16_SNORM:
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync case WINED3DFMT_R16G16B16A16_UNORM:
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync case WINED3DFMT_R16G16B16A16_FLOAT:
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync return TRUE;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync default:
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync return FALSE;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync }
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync default:
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync return FALSE;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync }
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync}
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsyncstatic HRESULT vertexdeclaration_init(struct wined3d_vertex_declaration *declaration,
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync struct wined3d_device *device, const struct wined3d_vertex_element *elements, UINT element_count,
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync void *parent, const struct wined3d_parent_ops *parent_ops)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync{
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync unsigned int i;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if (TRACE_ON(d3d_decl))
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync {
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync for (i = 0; i < element_count; ++i)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync {
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync dump_wined3d_vertex_element(elements + i);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync }
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync }
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync declaration->ref = 1;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync declaration->parent = parent;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync declaration->parent_ops = parent_ops;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync declaration->device = device;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync declaration->elements = HeapAlloc(GetProcessHeap(), 0, sizeof(*declaration->elements) * element_count);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if (!declaration->elements)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync {
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync ERR("Failed to allocate elements memory.\n");
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync return E_OUTOFMEMORY;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync }
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync declaration->element_count = element_count;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync /* Do some static analysis on the elements to make reading the
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync * declaration more comfortable for the drawing code. */
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync for (i = 0; i < element_count; ++i)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync {
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync struct wined3d_vertex_declaration_element *e = &declaration->elements[i];
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync e->format = wined3d_get_format(gl_info, elements[i].format);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync e->ffp_valid = declaration_element_valid_ffp(&elements[i]);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync e->input_slot = elements[i].input_slot;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync e->offset = elements[i].offset;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync e->output_slot = elements[i].output_slot;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync e->method = elements[i].method;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync e->usage = elements[i].usage;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync e->usage_idx = elements[i].usage_idx;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if (e->usage == WINED3D_DECL_USAGE_POSITIONT)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync declaration->position_transformed = TRUE;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync /* Find the streams used in the declaration. The vertex buffers have
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync * to be loaded when drawing, but filter tesselation pseudo streams. */
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if (e->input_slot >= MAX_STREAMS) continue;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if (!e->format->gl_vtx_format)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync {
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync FIXME("The application tries to use an unsupported format (%s), returning E_FAIL.\n",
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync debug_d3dformat(elements[i].format));
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync HeapFree(GetProcessHeap(), 0, declaration->elements);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync return E_FAIL;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync }
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if (e->offset & 0x3)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync {
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync WARN("Declaration element %u is not 4 byte aligned(%u), returning E_FAIL.\n", i, e->offset);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync HeapFree(GetProcessHeap(), 0, declaration->elements);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync return E_FAIL;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync }
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if (elements[i].format == WINED3DFMT_R16G16_FLOAT || elements[i].format == WINED3DFMT_R16G16B16A16_FLOAT)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync {
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if (!gl_info->supported[ARB_HALF_FLOAT_VERTEX]) declaration->half_float_conv_needed = TRUE;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync }
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync }
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync return WINED3D_OK;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync}
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsyncHRESULT CDECL wined3d_vertex_declaration_create(struct wined3d_device *device,
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync const struct wined3d_vertex_element *elements, UINT element_count, void *parent,
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync const struct wined3d_parent_ops *parent_ops, struct wined3d_vertex_declaration **declaration)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync{
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync struct wined3d_vertex_declaration *object;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync HRESULT hr;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync TRACE("device %p, elements %p, element_count %u, parent %p, parent_ops %p, declaration %p.\n",
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync device, elements, element_count, parent, parent_ops, declaration);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if(!object)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync return E_OUTOFMEMORY;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync hr = vertexdeclaration_init(object, device, elements, element_count, parent, parent_ops);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if (FAILED(hr))
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync {
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync WARN("Failed to initialize vertex declaration, hr %#x.\n", hr);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync HeapFree(GetProcessHeap(), 0, object);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync return hr;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync }
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync TRACE("Created vertex declaration %p.\n", object);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync *declaration = object;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync return WINED3D_OK;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync}
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsyncstruct wined3d_fvf_convert_state
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync{
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync const struct wined3d_gl_info *gl_info;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync struct wined3d_vertex_element *elements;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync UINT offset;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync UINT idx;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync};
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsyncstatic void append_decl_element(struct wined3d_fvf_convert_state *state,
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync enum wined3d_format_id format_id, enum wined3d_decl_usage usage, UINT usage_idx)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync{
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync struct wined3d_vertex_element *elements = state->elements;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync const struct wined3d_format *format;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync UINT offset = state->offset;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync UINT idx = state->idx;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync elements[idx].format = format_id;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync elements[idx].input_slot = 0;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync elements[idx].offset = offset;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync elements[idx].output_slot = 0;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync elements[idx].method = WINED3D_DECL_METHOD_DEFAULT;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync elements[idx].usage = usage;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync elements[idx].usage_idx = usage_idx;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync format = wined3d_get_format(state->gl_info, format_id);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync state->offset += format->component_count * format->component_size;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync ++state->idx;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync}
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsyncstatic unsigned int convert_fvf_to_declaration(const struct wined3d_gl_info *gl_info,
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync DWORD fvf, struct wined3d_vertex_element **elements)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync{
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync BOOL has_pos = !!(fvf & WINED3DFVF_POSITION_MASK);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync BOOL has_blend = (fvf & WINED3DFVF_XYZB5) > WINED3DFVF_XYZRHW;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync BOOL has_blend_idx = has_blend &&
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync (((fvf & WINED3DFVF_XYZB5) == WINED3DFVF_XYZB5) ||
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync (fvf & WINED3DFVF_LASTBETA_D3DCOLOR) ||
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync (fvf & WINED3DFVF_LASTBETA_UBYTE4));
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync BOOL has_normal = !!(fvf & WINED3DFVF_NORMAL);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync BOOL has_psize = !!(fvf & WINED3DFVF_PSIZE);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync BOOL has_diffuse = !!(fvf & WINED3DFVF_DIFFUSE);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync BOOL has_specular = !!(fvf & WINED3DFVF_SPECULAR);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync DWORD num_textures = (fvf & WINED3DFVF_TEXCOUNT_MASK) >> WINED3DFVF_TEXCOUNT_SHIFT;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync DWORD texcoords = (fvf & 0xffff0000) >> 16;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync struct wined3d_fvf_convert_state state;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync unsigned int size;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync unsigned int idx;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync DWORD num_blends = 1 + (((fvf & WINED3DFVF_XYZB5) - WINED3DFVF_XYZB1) >> 1);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if (has_blend_idx) num_blends--;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync /* Compute declaration size */
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync size = has_pos + (has_blend && num_blends > 0) + has_blend_idx + has_normal +
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync has_psize + has_diffuse + has_specular + num_textures;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync state.gl_info = gl_info;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync state.elements = HeapAlloc(GetProcessHeap(), 0, size * sizeof(*state.elements));
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if (!state.elements) return ~0U;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync state.offset = 0;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync state.idx = 0;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if (has_pos)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync {
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if (!has_blend && (fvf & WINED3DFVF_XYZRHW))
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync append_decl_element(&state, WINED3DFMT_R32G32B32A32_FLOAT, WINED3D_DECL_USAGE_POSITIONT, 0);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync else if ((fvf & WINED3DFVF_XYZW) == WINED3DFVF_XYZW)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync append_decl_element(&state, WINED3DFMT_R32G32B32A32_FLOAT, WINED3D_DECL_USAGE_POSITION, 0);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync else
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync append_decl_element(&state, WINED3DFMT_R32G32B32_FLOAT, WINED3D_DECL_USAGE_POSITION, 0);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync }
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if (has_blend && (num_blends > 0))
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync {
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if ((fvf & WINED3DFVF_XYZB5) == WINED3DFVF_XYZB2 && (fvf & WINED3DFVF_LASTBETA_D3DCOLOR))
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync append_decl_element(&state, WINED3DFMT_B8G8R8A8_UNORM, WINED3D_DECL_USAGE_BLEND_WEIGHT, 0);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync else
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync {
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync switch (num_blends)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync {
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync case 1:
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync append_decl_element(&state, WINED3DFMT_R32_FLOAT, WINED3D_DECL_USAGE_BLEND_WEIGHT, 0);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync break;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync case 2:
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync append_decl_element(&state, WINED3DFMT_R32G32_FLOAT, WINED3D_DECL_USAGE_BLEND_WEIGHT, 0);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync break;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync case 3:
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync append_decl_element(&state, WINED3DFMT_R32G32B32_FLOAT, WINED3D_DECL_USAGE_BLEND_WEIGHT, 0);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync break;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync case 4:
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync append_decl_element(&state, WINED3DFMT_R32G32B32A32_FLOAT, WINED3D_DECL_USAGE_BLEND_WEIGHT, 0);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync break;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync default:
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync ERR("Unexpected amount of blend values: %u\n", num_blends);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync }
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync }
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync }
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if (has_blend_idx)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync {
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if ((fvf & WINED3DFVF_LASTBETA_UBYTE4)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync || ((fvf & WINED3DFVF_XYZB5) == WINED3DFVF_XYZB2 && (fvf & WINED3DFVF_LASTBETA_D3DCOLOR)))
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync append_decl_element(&state, WINED3DFMT_R8G8B8A8_UINT, WINED3D_DECL_USAGE_BLEND_INDICES, 0);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync else if (fvf & WINED3DFVF_LASTBETA_D3DCOLOR)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync append_decl_element(&state, WINED3DFMT_B8G8R8A8_UNORM, WINED3D_DECL_USAGE_BLEND_INDICES, 0);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync else
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync append_decl_element(&state, WINED3DFMT_R32_FLOAT, WINED3D_DECL_USAGE_BLEND_INDICES, 0);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync }
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if (has_normal)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync append_decl_element(&state, WINED3DFMT_R32G32B32_FLOAT, WINED3D_DECL_USAGE_NORMAL, 0);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if (has_psize)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync append_decl_element(&state, WINED3DFMT_R32_FLOAT, WINED3D_DECL_USAGE_PSIZE, 0);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if (has_diffuse)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync append_decl_element(&state, WINED3DFMT_B8G8R8A8_UNORM, WINED3D_DECL_USAGE_COLOR, 0);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if (has_specular)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync append_decl_element(&state, WINED3DFMT_B8G8R8A8_UNORM, WINED3D_DECL_USAGE_COLOR, 1);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync for (idx = 0; idx < num_textures; ++idx)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync {
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync switch ((texcoords >> (idx * 2)) & 0x03)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync {
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync case WINED3DFVF_TEXTUREFORMAT1:
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync append_decl_element(&state, WINED3DFMT_R32_FLOAT, WINED3D_DECL_USAGE_TEXCOORD, idx);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync break;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync case WINED3DFVF_TEXTUREFORMAT2:
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync append_decl_element(&state, WINED3DFMT_R32G32_FLOAT, WINED3D_DECL_USAGE_TEXCOORD, idx);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync break;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync case WINED3DFVF_TEXTUREFORMAT3:
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync append_decl_element(&state, WINED3DFMT_R32G32B32_FLOAT, WINED3D_DECL_USAGE_TEXCOORD, idx);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync break;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync case WINED3DFVF_TEXTUREFORMAT4:
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync append_decl_element(&state, WINED3DFMT_R32G32B32A32_FLOAT, WINED3D_DECL_USAGE_TEXCOORD, idx);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync break;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync }
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync }
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync *elements = state.elements;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync return size;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync}
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsyncHRESULT CDECL wined3d_vertex_declaration_create_from_fvf(struct wined3d_device *device,
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync DWORD fvf, void *parent, const struct wined3d_parent_ops *parent_ops,
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync struct wined3d_vertex_declaration **declaration)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync{
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync struct wined3d_vertex_element *elements;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync unsigned int size;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync DWORD hr;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync TRACE("device %p, fvf %#x, parent %p, parent_ops %p, declaration %p.\n",
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync device, fvf, parent, parent_ops, declaration);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync size = convert_fvf_to_declaration(&device->adapter->gl_info, fvf, &elements);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if (size == ~0U) return E_OUTOFMEMORY;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync hr = wined3d_vertex_declaration_create(device, elements, size, parent, parent_ops, declaration);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync HeapFree(GetProcessHeap(), 0, elements);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync return hr;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync}