From 5dff410254a3f2d1de5fe6f43aed6ebadd1d6935 Mon Sep 17 00:00:00 2001 From: Henri Verbeet Date: Fri, 21 May 2010 09:35:24 +0200 Subject: [PATCH] wined3d: Explicitly pass GL info to buffer_get_sysmem(). --- dlls/wined3d/buffer.c | 12 ++++------ dlls/wined3d/device.c | 16 +++++++------ dlls/wined3d/drawprim.c | 44 ++++++++++++++++++---------------- dlls/wined3d/state.c | 2 +- dlls/wined3d/wined3d_private.h | 2 +- 5 files changed, 39 insertions(+), 37 deletions(-) diff --git a/dlls/wined3d/buffer.c b/dlls/wined3d/buffer.c index fbd39b995c4..73d532756c7 100644 --- a/dlls/wined3d/buffer.c +++ b/dlls/wined3d/buffer.c @@ -567,7 +567,7 @@ static void buffer_check_buffer_object_size(struct wined3d_buffer *This, const s /* Rescue the data before resizing the buffer object if we do not have our backup copy */ if(!(This->flags & WINED3D_BUFFER_DOUBLEBUFFER)) { - buffer_get_sysmem(This); + buffer_get_sysmem(This, gl_info); } ENTER_GL(); @@ -672,10 +672,8 @@ static ULONG STDMETHODCALLTYPE buffer_AddRef(IWineD3DBuffer *iface) } /* Context activation is done by the caller. */ -BYTE *buffer_get_sysmem(struct wined3d_buffer *This) +BYTE *buffer_get_sysmem(struct wined3d_buffer *This, const struct wined3d_gl_info *gl_info) { - const struct wined3d_gl_info *gl_info = &This->resource.device->adapter->gl_info; - /* AllocatedMemory exists if the buffer is double buffered or has no buffer object at all */ if(This->resource.allocatedMemory) return This->resource.allocatedMemory; @@ -706,7 +704,7 @@ static void STDMETHODCALLTYPE buffer_UnLoad(IWineD3DBuffer *iface) /* Download the buffer, but don't permanently enable double buffering */ if(!(This->flags & WINED3D_BUFFER_DOUBLEBUFFER)) { - buffer_get_sysmem(This); + buffer_get_sysmem(This, context->gl_info); This->flags &= ~WINED3D_BUFFER_DOUBLEBUFFER; } @@ -1065,7 +1063,7 @@ static void STDMETHODCALLTYPE buffer_PreLoad(IWineD3DBuffer *iface) if(!(This->flags & WINED3D_BUFFER_DOUBLEBUFFER)) { - buffer_get_sysmem(This); + buffer_get_sysmem(This, gl_info); } /* Now for each vertex in the buffer that needs conversion */ @@ -1300,7 +1298,7 @@ static HRESULT STDMETHODCALLTYPE buffer_Map(IWineD3DBuffer *iface, UINT offset, LEAVE_GL(); This->resource.allocatedMemory = NULL; - buffer_get_sysmem(This); + buffer_get_sysmem(This, gl_info); TRACE("New pointer is %p\n", This->resource.allocatedMemory); } context_release(context); diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index fd8cd601287..7a8b9da6ba8 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -225,7 +225,8 @@ void device_stream_info_from_declaration(IWineD3DDeviceImpl *This, { WARN("loadBaseVertexIndex is < 0 (%d), not using vbos\n", This->stateBlock->loadBaseVertexIndex); buffer_object = 0; - data = buffer_get_sysmem((struct wined3d_buffer *)This->stateBlock->streamSource[element->input_slot]); + data = buffer_get_sysmem((struct wined3d_buffer *)This->stateBlock->streamSource[element->input_slot], + &This->adapter->gl_info); if ((UINT_PTR)data < -This->stateBlock->loadBaseVertexIndex * stride) { FIXME("System memory vertex data load offset is negative!\n"); @@ -328,7 +329,7 @@ void device_stream_info_from_declaration(IWineD3DDeviceImpl *This, if (buffer->buffer_object != element->buffer_object) { element->buffer_object = 0; - element->data = buffer_get_sysmem(buffer) + (ptrdiff_t)element->data; + element->data = buffer_get_sysmem(buffer, &This->adapter->gl_info) + (ptrdiff_t)element->data; } query = ((struct wined3d_buffer *) buffer)->query; @@ -3576,9 +3577,8 @@ static HRESULT process_vertices_strided(IWineD3DDeviceImpl *This, DWORD dwDestIn /* We might access VBOs from this code, so hold the lock */ ENTER_GL(); - if (dest->resource.allocatedMemory == NULL) { - buffer_get_sysmem(dest); - } + if (!dest->resource.allocatedMemory) + buffer_get_sysmem(dest, gl_info); /* Get a pointer into the destination vbo(create one if none exists) and * write correct opengl data into it. It's cheap and allows us to run drawStridedFast @@ -3625,7 +3625,7 @@ static HRESULT process_vertices_strided(IWineD3DDeviceImpl *This, DWORD dwDestIn FIXME("Clipping is broken and disabled for now\n"); } } else doClip = FALSE; - dest_ptr = ((char *) buffer_get_sysmem(dest)) + dwDestIndex * get_flexible_vertex_size(DestFVF); + dest_ptr = ((char *)buffer_get_sysmem(dest, gl_info)) + dwDestIndex * get_flexible_vertex_size(DestFVF); IWineD3DDevice_GetTransform( (IWineD3DDevice *) This, WINED3DTS_VIEW, @@ -3901,6 +3901,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_ProcessVertices(IWineD3DDevice *iface, { IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; struct wined3d_stream_info stream_info; + const struct wined3d_gl_info *gl_info; struct wined3d_context *context; BOOL vbo = FALSE, streamWasUP = This->stateBlock->streamIsUP; HRESULT hr; @@ -3913,6 +3914,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_ProcessVertices(IWineD3DDevice *iface, /* Need any context to write to the vbo. */ context = context_acquire(This, NULL); + gl_info = context->gl_info; /* ProcessVertices reads from vertex buffers, which have to be assigned. DrawPrimitive and DrawPrimitiveUP * control the streamIsUP flag, thus restore it afterwards. @@ -3939,7 +3941,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_ProcessVertices(IWineD3DDevice *iface, { struct wined3d_buffer *vb = (struct wined3d_buffer *)This->stateBlock->streamSource[e->stream_idx]; e->buffer_object = 0; - e->data = (BYTE *)((unsigned long)e->data + (unsigned long)buffer_get_sysmem(vb)); + e->data = (BYTE *)((unsigned long)e->data + (unsigned long)buffer_get_sysmem(vb, gl_info)); ENTER_GL(); GL_EXTCALL(glDeleteBuffersARB(1, &vb->buffer_object)); vb->buffer_object = 0; diff --git a/dlls/wined3d/drawprim.c b/dlls/wined3d/drawprim.c index 3da4093ac39..882234d6026 100644 --- a/dlls/wined3d/drawprim.c +++ b/dlls/wined3d/drawprim.c @@ -85,14 +85,14 @@ static void drawStridedSlow(IWineD3DDevice *iface, const struct wined3d_context TRACE("Using slow vertex array code\n"); /* Variable Initialization */ - if (idxSize != 0) { - /* Immediate mode drawing can't make use of indices in a vbo - get the data from the index buffer. - * If the index buffer has no vbo(not supported or other reason), or with user pointer drawing - * idxData will be != NULL - */ - if(idxData == NULL) { - idxData = buffer_get_sysmem((struct wined3d_buffer *) This->stateBlock->pIndexData); - } + if (idxSize) + { + /* Immediate mode drawing can't make use of indices in a vbo - get the + * data from the index buffer. If the index buffer has no vbo (not + * supported or other reason), or with user pointer drawing idxData + * will be non-NULL. */ + if (!idxData) + idxData = buffer_get_sysmem((struct wined3d_buffer *)This->stateBlock->pIndexData, gl_info); if (idxSize == 2) pIdxBufS = idxData; else pIdxBufL = idxData; @@ -422,6 +422,7 @@ static void drawStridedSlowVs(IWineD3DDevice *iface, const struct wined3d_stream GLenum glPrimitiveType, const void *idxData, UINT idxSize, UINT startIdx) { IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface; + const struct wined3d_gl_info *gl_info = &This->adapter->gl_info; long SkipnStrides = startIdx + This->stateBlock->loadBaseVertexIndex; const WORD *pIdxBufS = NULL; const DWORD *pIdxBufL = NULL; @@ -430,14 +431,14 @@ static void drawStridedSlowVs(IWineD3DDevice *iface, const struct wined3d_stream IWineD3DStateBlockImpl *stateblock = This->stateBlock; const BYTE *ptr; - if (idxSize != 0) { - /* Immediate mode drawing can't make use of indices in a vbo - get the data from the index buffer. - * If the index buffer has no vbo(not supported or other reason), or with user pointer drawing - * idxData will be != NULL - */ - if(idxData == NULL) { - idxData = buffer_get_sysmem((struct wined3d_buffer *) This->stateBlock->pIndexData); - } + if (idxSize) + { + /* Immediate mode drawing can't make use of indices in a vbo - get the + * data from the index buffer. If the index buffer has no vbo (not + * supported or other reason), or with user pointer drawing idxData + * will be non-NULL. */ + if (!idxData) + idxData = buffer_get_sysmem((struct wined3d_buffer *)This->stateBlock->pIndexData, gl_info); if (idxSize == 2) pIdxBufS = idxData; else pIdxBufL = idxData; @@ -535,7 +536,7 @@ static inline void drawStridedInstanced(IWineD3DDevice *iface, const struct wine { struct wined3d_buffer *vb = (struct wined3d_buffer *)stateblock->streamSource[si->elements[instancedData[j]].stream_idx]; - ptr += (long) buffer_get_sysmem(vb); + ptr += (long)buffer_get_sysmem(vb, &This->adapter->gl_info); } send_attribute(This, si->elements[instancedData[j]].format_desc->format, instancedData[j], ptr); @@ -547,7 +548,8 @@ static inline void drawStridedInstanced(IWineD3DDevice *iface, const struct wine } } -static inline void remove_vbos(IWineD3DDeviceImpl *This, struct wined3d_stream_info *s) +static inline void remove_vbos(IWineD3DDeviceImpl *This, const struct wined3d_gl_info *gl_info, + struct wined3d_stream_info *s) { unsigned int i; @@ -562,7 +564,7 @@ static inline void remove_vbos(IWineD3DDeviceImpl *This, struct wined3d_stream_i { struct wined3d_buffer *vb = (struct wined3d_buffer *)This->stateBlock->streamSource[e->stream_idx]; e->buffer_object = 0; - e->data = (BYTE *)((unsigned long)e->data + (unsigned long)buffer_get_sysmem(vb)); + e->data = (BYTE *)((unsigned long)e->data + (unsigned long)buffer_get_sysmem(vb, gl_info)); } } } @@ -683,7 +685,7 @@ void drawPrimitive(IWineD3DDevice *iface, UINT index_count, UINT StartIdx, UINT if(emulation) { stream_info = &stridedlcl; memcpy(&stridedlcl, &This->strided_streams, sizeof(stridedlcl)); - remove_vbos(This, &stridedlcl); + remove_vbos(This, context->gl_info, &stridedlcl); } } @@ -830,7 +832,7 @@ HRESULT tesselate_rectpatch(IWineD3DDeviceImpl *This, { struct wined3d_buffer *vb; vb = (struct wined3d_buffer *)This->stateBlock->streamSource[e->stream_idx]; - e->data = (BYTE *)((unsigned long)e->data + (unsigned long)buffer_get_sysmem(vb)); + e->data = (BYTE *)((unsigned long)e->data + (unsigned long)buffer_get_sysmem(vb, context->gl_info)); } vtxStride = e->stride; data = e->data + diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c index 28de4eadb7e..5ade1a40a33 100644 --- a/dlls/wined3d/state.c +++ b/dlls/wined3d/state.c @@ -4100,7 +4100,7 @@ static inline void loadNumberedArrays(IWineD3DStateBlockImpl *stateblock, if (stream_info->elements[i].buffer_object) { vb = (struct wined3d_buffer *)stateblock->streamSource[stream_info->elements[i].stream_idx]; - ptr += (long) buffer_get_sysmem(vb); + ptr += (long)buffer_get_sysmem(vb, gl_info); } if (context->numbered_array_mask & (1 << i)) unload_numbered_array(stateblock, context, i); diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 947456a1d87..bc354091c18 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -2505,7 +2505,7 @@ struct wined3d_buffer const BYTE *buffer_get_memory(IWineD3DBuffer *iface, const struct wined3d_gl_info *gl_info, GLuint *buffer_object) DECLSPEC_HIDDEN; -BYTE *buffer_get_sysmem(struct wined3d_buffer *This) DECLSPEC_HIDDEN; +BYTE *buffer_get_sysmem(struct wined3d_buffer *This, const struct wined3d_gl_info *gl_info) DECLSPEC_HIDDEN; HRESULT buffer_init(struct wined3d_buffer *buffer, IWineD3DDeviceImpl *device, UINT size, DWORD usage, WINED3DFORMAT format, WINED3DPOOL pool, GLenum bind_hint, const char *data, IUnknown *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;