From a5686e41aaaadeab33d87a81ba0947b19b6ccbc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20D=C3=B6singer?= Date: Mon, 28 Dec 2009 00:31:12 +0100 Subject: [PATCH 02/18] WineD3D: Set WINED3D_BUFFER_CREATEBO in buffer_init() --- dlls/wined3d/buffer.c | 25 +++++++++++++++++++++++++ dlls/wined3d/device.c | 26 ++------------------------ 2 files changed, 27 insertions(+), 24 deletions(-) diff --git a/dlls/wined3d/buffer.c b/dlls/wined3d/buffer.c index c5b8b44..ceeede0 100644 --- a/dlls/wined3d/buffer.c +++ b/dlls/wined3d/buffer.c @@ -1098,6 +1098,7 @@ HRESULT buffer_init(struct wined3d_buffer *buffer, IWineD3DDeviceImpl *device, { const struct GlPixelFormatDesc *format_desc = getFormatDescEntry(format, &device->adapter->gl_info); HRESULT hr; + const struct wined3d_gl_info *gl_info = &device->adapter->gl_info; if (!size) { @@ -1119,6 +1120,30 @@ HRESULT buffer_init(struct wined3d_buffer *buffer, IWineD3DDeviceImpl *device, TRACE("size %#x, usage %#x, format %s, memory @ %p, iface @ %p.\n", buffer->resource.size, buffer->resource.usage, debug_d3dformat(buffer->resource.format_desc->format), buffer->resource.allocatedMemory, buffer); + /* Observations show that drawStridedSlow is faster on dynamic VBs than converting + + * drawStridedFast (half-life 2 and others). + * + * Basically converting the vertices in the buffer is quite expensive, and observations + * show that drawStridedSlow is faster than converting + uploading + drawStridedFast. + * Therefore do not create a VBO for WINED3DUSAGE_DYNAMIC buffers. + */ + if (!gl_info->supported[ARB_VERTEX_BUFFER_OBJECT]) + { + TRACE("Not creating a vbo because GL_ARB_vertex_buffer is not supported\n"); + } + else if(buffer->resource.pool == WINED3DPOOL_SYSTEMMEM) + { + TRACE("Not creating a vbo because the vertex buffer is in system memory\n"); + } + else if(buffer->resource.usage & WINED3DUSAGE_DYNAMIC) + { + TRACE("Not creating a vbo because the buffer has dynamic usage\n"); + } + else + { + buffer->flags |= WINED3D_BUFFER_CREATEBO; + } + if (data) { BYTE *ptr; diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index d0660b4..c0e01d4 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -520,23 +520,6 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateVertexBuffer(IWineD3DDevice *ifac TRACE("Created buffer %p.\n", object); *ppVertexBuffer = (IWineD3DBuffer *)object; - /* Observations show that drawStridedSlow is faster on dynamic VBs than converting + - * drawStridedFast (half-life 2). - * - * Basically converting the vertices in the buffer is quite expensive, and observations - * show that drawStridedSlow is faster than converting + uploading + drawStridedFast. - * Therefore do not create a VBO for WINED3DUSAGE_DYNAMIC buffers. - */ - if (!This->adapter->gl_info.supported[ARB_VERTEX_BUFFER_OBJECT]) - { - TRACE("Not creating a vbo because GL_ARB_vertex_buffer is not supported\n"); - } else if(Pool == WINED3DPOOL_SYSTEMMEM) { - TRACE("Not creating a vbo because the vertex buffer is in system memory\n"); - } else if(Usage & WINED3DUSAGE_DYNAMIC) { - TRACE("Not creating a vbo because the buffer has dynamic usage\n"); - } else { - object->flags |= WINED3D_BUFFER_CREATEBO; - } return WINED3D_OK; } @@ -560,7 +543,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateIndexBuffer(IWineD3DDevice *iface } hr = buffer_init(object, This, Length, Usage | WINED3DUSAGE_STATICDECL, - WINED3DFMT_UNKNOWN, Pool, GL_ELEMENT_ARRAY_BUFFER_ARB, NULL, parent, parent_ops); + WINED3DFMT_UNKNOWN, Pool, GL_ELEMENT_ARRAY_BUFFER_ARB, NULL, + parent, parent_ops); if (FAILED(hr)) { WARN("Failed to initialize buffer, hr %#x\n", hr); @@ -570,12 +554,6 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateIndexBuffer(IWineD3DDevice *iface TRACE("Created buffer %p.\n", object); - if (Pool != WINED3DPOOL_SYSTEMMEM && !(Usage & WINED3DUSAGE_DYNAMIC) - && This->adapter->gl_info.supported[ARB_VERTEX_BUFFER_OBJECT]) - { - object->flags |= WINED3D_BUFFER_CREATEBO; - } - *ppIndexBuffer = (IWineD3DBuffer *) object; return WINED3D_OK; -- 1.6.4.4