[PATCH 4/4] wined3d: Remove support for unfenced double-buffered buffer loads
Stefan Dösinger
stefan at codeweavers.com
Tue Feb 28 05:19:28 CST 2012
This is dead code now that we do not have double-buffered dynamic
buffers.
---
dlls/wined3d/buffer.c | 145 ++++++++++++++--------------------------
dlls/wined3d/wined3d_private.h | 4 +-
2 files changed, 52 insertions(+), 97 deletions(-)
diff --git a/dlls/wined3d/buffer.c b/dlls/wined3d/buffer.c
index 691e0b9..26d6173 100644
--- a/dlls/wined3d/buffer.c
+++ b/dlls/wined3d/buffer.c
@@ -664,7 +664,7 @@ drop_query:
}
/* The caller provides a GL context */
-static void buffer_direct_upload(struct wined3d_buffer *This, const struct wined3d_gl_info *gl_info, DWORD flags)
+static void buffer_direct_upload(struct wined3d_buffer *This, const struct wined3d_gl_info *gl_info)
{
BYTE *map;
UINT start = 0, len = 0;
@@ -677,25 +677,16 @@ static void buffer_direct_upload(struct wined3d_buffer *This, const struct wined
checkGLcall("glBindBufferARB");
if (gl_info->supported[ARB_MAP_BUFFER_RANGE])
{
- GLbitfield mapflags;
- mapflags = GL_MAP_WRITE_BIT | GL_MAP_FLUSH_EXPLICIT_BIT;
- if (flags & WINED3D_BUFFER_DISCARD)
- mapflags |= GL_MAP_INVALIDATE_BUFFER_BIT;
- if (flags & WINED3D_BUFFER_NOSYNC)
- mapflags |= GL_MAP_UNSYNCHRONIZED_BIT;
map = GL_EXTCALL(glMapBufferRange(This->buffer_type_hint, 0,
- This->resource.size, mapflags));
+ This->resource.size, GL_MAP_WRITE_BIT | GL_MAP_FLUSH_EXPLICIT_BIT));
checkGLcall("glMapBufferRange");
}
else
{
if (This->flags & WINED3D_BUFFER_APPLESYNC)
{
- DWORD syncflags = 0;
- if (flags & WINED3D_BUFFER_DISCARD) syncflags |= WINED3DLOCK_DISCARD;
- if (flags & WINED3D_BUFFER_NOSYNC) syncflags |= WINED3DLOCK_NOOVERWRITE;
LEAVE_GL();
- buffer_sync_apple(This, syncflags, gl_info);
+ buffer_sync_apple(This, 0, gl_info);
ENTER_GL();
}
map = GL_EXTCALL(glMapBufferARB(This->buffer_type_hint, GL_WRITE_ONLY_ARB));
@@ -753,7 +744,6 @@ static void wined3d_buffer_drop_bo(struct wined3d_buffer *buffer)
/* Do not call while under the GL lock. */
void CDECL wined3d_buffer_preload(struct wined3d_buffer *buffer)
{
- DWORD flags = buffer->flags & (WINED3D_BUFFER_NOSYNC | WINED3D_BUFFER_DISCARD);
struct wined3d_device *device = buffer->resource.device;
UINT start = 0, end = 0, len = 0, vertices;
const struct wined3d_gl_info *gl_info;
@@ -764,8 +754,6 @@ void CDECL wined3d_buffer_preload(struct wined3d_buffer *buffer)
TRACE("buffer %p.\n", buffer);
- buffer->flags &= ~(WINED3D_BUFFER_NOSYNC | WINED3D_BUFFER_DISCARD);
-
if (!buffer->buffer_object)
{
/* TODO: Make converting independent from VBOs */
@@ -830,10 +818,6 @@ void CDECL wined3d_buffer_preload(struct wined3d_buffer *buffer)
ERR("buffer_add_dirty_area failed, this is not expected\n");
return;
}
- /* Avoid unfenced updates, we might overwrite more areas of the buffer than the application
- * cleared for unsynchronized updates
- */
- flags = 0;
}
else
{
@@ -880,7 +864,7 @@ void CDECL wined3d_buffer_preload(struct wined3d_buffer *buffer)
}
context = context_acquire(device, NULL);
- buffer_direct_upload(buffer, context->gl_info, flags);
+ buffer_direct_upload(buffer, context->gl_info);
context_release(context);
return;
@@ -1001,7 +985,6 @@ struct wined3d_resource * CDECL wined3d_buffer_get_resource(struct wined3d_buffe
HRESULT CDECL wined3d_buffer_map(struct wined3d_buffer *buffer, UINT offset, UINT size, BYTE **data, DWORD flags)
{
- BOOL dirty = buffer_is_dirty(buffer);
LONG count;
TRACE("buffer %p, offset %u, size %u, data %p, flags %#x\n", buffer, offset, size, data, flags);
@@ -1014,94 +997,68 @@ HRESULT CDECL wined3d_buffer_map(struct wined3d_buffer *buffer, UINT offset, UIN
count = InterlockedIncrement(&buffer->lock_count);
- if (buffer->buffer_object)
+ if (buffer->buffer_object && !(buffer->flags & WINED3D_BUFFER_DOUBLEBUFFER) && count == 1)
{
- if (!(buffer->flags & WINED3D_BUFFER_DOUBLEBUFFER))
- {
- if (count == 1)
- {
- struct wined3d_device *device = buffer->resource.device;
- struct wined3d_context *context;
- const struct wined3d_gl_info *gl_info;
-
- context = context_acquire(device, NULL);
- gl_info = context->gl_info;
+ struct wined3d_device *device = buffer->resource.device;
+ struct wined3d_context *context;
+ const struct wined3d_gl_info *gl_info;
- ENTER_GL();
+ context = context_acquire(device, NULL);
+ gl_info = context->gl_info;
- if (buffer->buffer_type_hint == GL_ELEMENT_ARRAY_BUFFER_ARB)
- context_invalidate_state(context, STATE_INDEXBUFFER);
- GL_EXTCALL(glBindBufferARB(buffer->buffer_type_hint, buffer->buffer_object));
+ ENTER_GL();
- if (gl_info->supported[ARB_MAP_BUFFER_RANGE])
- {
- GLbitfield mapflags = buffer_gl_map_flags(flags);
- buffer->resource.allocatedMemory = GL_EXTCALL(glMapBufferRange(buffer->buffer_type_hint,
- 0, buffer->resource.size, mapflags));
- checkGLcall("glMapBufferRange");
- }
- else
- {
- if (buffer->flags & WINED3D_BUFFER_APPLESYNC)
- {
- LEAVE_GL();
- buffer_sync_apple(buffer, flags, gl_info);
- ENTER_GL();
- }
- buffer->resource.allocatedMemory = GL_EXTCALL(glMapBufferARB(buffer->buffer_type_hint,
- GL_READ_WRITE_ARB));
- checkGLcall("glMapBufferARB");
- }
- LEAVE_GL();
+ if (buffer->buffer_type_hint == GL_ELEMENT_ARRAY_BUFFER_ARB)
+ context_invalidate_state(context, STATE_INDEXBUFFER);
+ GL_EXTCALL(glBindBufferARB(buffer->buffer_type_hint, buffer->buffer_object));
- if (((DWORD_PTR)buffer->resource.allocatedMemory) & (RESOURCE_ALIGNMENT - 1))
- {
- WARN("Pointer %p is not %u byte aligned.\n", buffer->resource.allocatedMemory, RESOURCE_ALIGNMENT);
-
- ENTER_GL();
- GL_EXTCALL(glUnmapBufferARB(buffer->buffer_type_hint));
- checkGLcall("glUnmapBufferARB");
- LEAVE_GL();
- buffer->resource.allocatedMemory = NULL;
-
- if (buffer->resource.usage & WINED3DUSAGE_DYNAMIC)
- {
- /* The extra copy is more expensive than not using VBOs at
- * all on the Nvidia Linux driver, which is the only driver
- * that returns unaligned pointers
- */
- TRACE("Dynamic buffer, dropping VBO\n");
- wined3d_buffer_drop_bo(buffer);
- }
- else
- {
- TRACE("Falling back to doublebuffered operation\n");
- buffer_get_sysmem(buffer, gl_info);
- }
- TRACE("New pointer is %p.\n", buffer->resource.allocatedMemory);
- }
- context_release(context);
- }
+ if (gl_info->supported[ARB_MAP_BUFFER_RANGE])
+ {
+ GLbitfield mapflags = buffer_gl_map_flags(flags);
+ buffer->resource.allocatedMemory = GL_EXTCALL(glMapBufferRange(buffer->buffer_type_hint,
+ 0, buffer->resource.size, mapflags));
+ checkGLcall("glMapBufferRange");
}
else
{
- if (dirty)
+ if (buffer->flags & WINED3D_BUFFER_APPLESYNC)
{
- if (buffer->flags & WINED3D_BUFFER_NOSYNC && !(flags & WINED3DLOCK_NOOVERWRITE))
- {
- buffer->flags &= ~WINED3D_BUFFER_NOSYNC;
- }
+ LEAVE_GL();
+ buffer_sync_apple(buffer, flags, gl_info);
+ ENTER_GL();
}
- else if(flags & WINED3DLOCK_NOOVERWRITE)
+ buffer->resource.allocatedMemory = GL_EXTCALL(glMapBufferARB(buffer->buffer_type_hint,
+ GL_READ_WRITE_ARB));
+ checkGLcall("glMapBufferARB");
+ }
+ LEAVE_GL();
+
+ if (((DWORD_PTR)buffer->resource.allocatedMemory) & (RESOURCE_ALIGNMENT - 1))
+ {
+ WARN("Pointer %p is not %u byte aligned.\n", buffer->resource.allocatedMemory, RESOURCE_ALIGNMENT);
+
+ ENTER_GL();
+ GL_EXTCALL(glUnmapBufferARB(buffer->buffer_type_hint));
+ checkGLcall("glUnmapBufferARB");
+ LEAVE_GL();
+ buffer->resource.allocatedMemory = NULL;
+
+ if (buffer->resource.usage & WINED3DUSAGE_DYNAMIC)
{
- buffer->flags |= WINED3D_BUFFER_NOSYNC;
+ /* The extra copy is more expensive than not using VBOs at
+ * all on the Nvidia Linux driver, which is the only driver
+ * that returns unaligned pointers */
+ TRACE("Dynamic buffer, dropping VBO\n");
+ wined3d_buffer_drop_bo(buffer);
}
-
- if (flags & WINED3DLOCK_DISCARD)
+ else
{
- buffer->flags |= WINED3D_BUFFER_DISCARD;
+ TRACE("Falling back to doublebuffered operation\n");
+ buffer_get_sysmem(buffer, gl_info);
}
+ TRACE("New pointer is %p.\n", buffer->resource.allocatedMemory);
}
+ context_release(context);
}
*data = buffer->resource.allocatedMemory + offset;
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index df817af..1dca5b8 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -2393,9 +2393,7 @@ struct wined3d_map_range
#define WINED3D_BUFFER_CREATEBO 0x04 /* Attempt to create a buffer object next PreLoad */
#define WINED3D_BUFFER_DOUBLEBUFFER 0x08 /* Use a vbo and local allocated memory */
#define WINED3D_BUFFER_FLUSH 0x10 /* Manual unmap flushing */
-#define WINED3D_BUFFER_DISCARD 0x20 /* A DISCARD lock has occurred since the last PreLoad */
-#define WINED3D_BUFFER_NOSYNC 0x40 /* All locks since the last PreLoad had NOOVERWRITE set */
-#define WINED3D_BUFFER_APPLESYNC 0x80 /* Using sync as in GL_APPLE_flush_buffer_range */
+#define WINED3D_BUFFER_APPLESYNC 0x20 /* Using sync as in GL_APPLE_flush_buffer_range */
struct wined3d_buffer
{
--
1.7.3.4
More information about the wine-patches
mailing list