[PATCH 1/5] wined3d: Don't mess with the device in buffer_create_buffer_object
Stefan Dösinger
stefan at codeweavers.com
Mon Sep 9 05:56:16 CDT 2013
The stream info will be moved from the device into the context soon,
which will remove the unelegant passing of device and context to
device_stream_info_from_declaration.
---
dlls/wined3d/buffer.c | 11 ++++++-----
dlls/wined3d/context.c | 2 +-
dlls/wined3d/device.c | 16 +++++++++-------
dlls/wined3d/wined3d_private.h | 4 ++--
4 files changed, 18 insertions(+), 15 deletions(-)
diff --git a/dlls/wined3d/buffer.c b/dlls/wined3d/buffer.c
index 00e4dae..6314ded 100644
--- a/dlls/wined3d/buffer.c
+++ b/dlls/wined3d/buffer.c
@@ -118,10 +118,11 @@ static void delete_gl_buffer(struct wined3d_buffer *This, const struct wined3d_g
}
/* Context activation is done by the caller. */
-static void buffer_create_buffer_object(struct wined3d_buffer *This, const struct wined3d_gl_info *gl_info)
+static void buffer_create_buffer_object(struct wined3d_buffer *This, struct wined3d_context *context)
{
GLenum gl_usage = GL_STATIC_DRAW_ARB;
GLenum error;
+ const struct wined3d_gl_info *gl_info = context->gl_info;
TRACE("Creating an OpenGL vertex buffer object for wined3d_buffer %p with usage %s.\n",
This, debug_d3dusage(This->resource.usage));
@@ -148,7 +149,7 @@ static void buffer_create_buffer_object(struct wined3d_buffer *This, const struc
}
if (This->buffer_type_hint == GL_ELEMENT_ARRAY_BUFFER_ARB)
- device_invalidate_state(This->resource.device, STATE_INDEXBUFFER);
+ context_invalidate_state(context, STATE_INDEXBUFFER);
GL_EXTCALL(glBindBufferARB(This->buffer_type_hint, This->buffer_object));
error = gl_info->gl_ops.gl.p_glGetError();
if (error != GL_NO_ERROR)
@@ -460,7 +461,7 @@ static inline void fixup_transformed_pos(float *p)
}
/* Context activation is done by the caller. */
-void buffer_get_memory(struct wined3d_buffer *buffer, const struct wined3d_gl_info *gl_info,
+void buffer_get_memory(struct wined3d_buffer *buffer, struct wined3d_context *context,
struct wined3d_bo_address *data)
{
data->buffer_object = buffer->buffer_object;
@@ -468,7 +469,7 @@ void buffer_get_memory(struct wined3d_buffer *buffer, const struct wined3d_gl_in
{
if ((buffer->flags & WINED3D_BUFFER_CREATEBO) && !buffer->resource.map_count)
{
- buffer_create_buffer_object(buffer, gl_info);
+ buffer_create_buffer_object(buffer, context);
buffer->flags &= ~WINED3D_BUFFER_CREATEBO;
if (buffer->buffer_object)
{
@@ -754,7 +755,7 @@ void CDECL wined3d_buffer_preload(struct wined3d_buffer *buffer)
if (buffer->flags & WINED3D_BUFFER_CREATEBO)
{
context = context_acquire(device, NULL);
- buffer_create_buffer_object(buffer, context->gl_info);
+ buffer_create_buffer_object(buffer, context);
context_release(context);
buffer->flags &= ~WINED3D_BUFFER_CREATEBO;
}
diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c
index bb3b06b..f05fdcc 100644
--- a/dlls/wined3d/context.c
+++ b/dlls/wined3d/context.c
@@ -2368,7 +2368,7 @@ BOOL context_apply_draw_state(struct wined3d_context *context, struct wined3d_de
device_update_tex_unit_map(device);
device_preload_textures(device);
if (isStateDirty(context, STATE_VDECL) || isStateDirty(context, STATE_STREAMSRC))
- device_update_stream_info(device, context->gl_info);
+ device_update_stream_info(device, context);
if (state->index_buffer)
{
if (device->stream_info.all_vbo)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 65209e3..1ef2763 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -164,7 +164,8 @@ static BOOL fixed_get_input(BYTE usage, BYTE usage_idx, unsigned int *regnum)
}
/* Context activation is done by the caller. */
-static void device_stream_info_from_declaration(struct wined3d_device *device, struct wined3d_stream_info *stream_info)
+static void device_stream_info_from_declaration(struct wined3d_device *device, struct wined3d_stream_info *stream_info,
+ struct wined3d_context *context)
{
const struct wined3d_state *state = &device->state;
/* We need to deal with frequency data! */
@@ -200,7 +201,7 @@ static void device_stream_info_from_declaration(struct wined3d_device *device, s
stride = stream->stride;
TRACE("Stream %u, buffer %p.\n", element->input_slot, buffer);
- buffer_get_memory(buffer, &device->adapter->gl_info, &data);
+ buffer_get_memory(buffer, context, &data);
/* We can't use VBOs if the base vertex index is negative. OpenGL
* doesn't accept negative offsets (or rather offsets bigger than the
@@ -213,7 +214,7 @@ static void device_stream_info_from_declaration(struct wined3d_device *device, s
{
WARN_(d3d_perf)("load_base_vertex_index is < 0 (%d), not using VBOs.\n", state->load_base_vertex_index);
data.buffer_object = 0;
- data.addr = buffer_get_sysmem(buffer, &device->adapter->gl_info);
+ data.addr = buffer_get_sysmem(buffer, context->gl_info);
if ((UINT_PTR)data.addr < -state->load_base_vertex_index * stride)
FIXME("System memory vertex data load offset is negative!\n");
}
@@ -266,7 +267,7 @@ static void device_stream_info_from_declaration(struct wined3d_device *device, s
stream_info->elements[idx].stride = stride;
stream_info->elements[idx].stream_idx = element->input_slot;
- if (!device->adapter->gl_info.supported[ARB_VERTEX_ARRAY_BGRA]
+ if (!context->gl_info->supported[ARB_VERTEX_ARRAY_BGRA]
&& element->format->id == WINED3DFMT_B8G8R8A8_UNORM)
{
stream_info->swizzle_map |= 1 << idx;
@@ -305,14 +306,15 @@ static void device_stream_info_from_declaration(struct wined3d_device *device, s
}
/* Context activation is done by the caller. */
-void device_update_stream_info(struct wined3d_device *device, const struct wined3d_gl_info *gl_info)
+void device_update_stream_info(struct wined3d_device *device, struct wined3d_context *context)
{
+ const struct wined3d_gl_info *gl_info = context->gl_info;
struct wined3d_stream_info *stream_info = &device->stream_info;
const struct wined3d_state *state = &device->state;
DWORD prev_all_vbo = stream_info->all_vbo;
TRACE("============================= Vertex Declaration =============================\n");
- device_stream_info_from_declaration(device, stream_info);
+ device_stream_info_from_declaration(device, stream_info, context);
if (state->vertex_shader && !stream_info->position_transformed)
{
@@ -3535,7 +3537,7 @@ HRESULT CDECL wined3d_device_process_vertices(struct wined3d_device *device,
vs = state->vertex_shader;
state->vertex_shader = NULL;
- device_stream_info_from_declaration(device, &stream_info);
+ device_stream_info_from_declaration(device, &stream_info, context);
state->vertex_shader = vs;
/* We can't convert FROM a VBO, and vertex buffers used to source into
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 5a8ced0..0ad81d1 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -1957,7 +1957,7 @@ void device_resource_add(struct wined3d_device *device, struct wined3d_resource
void device_resource_released(struct wined3d_device *device, struct wined3d_resource *resource) DECLSPEC_HIDDEN;
void device_switch_onscreen_ds(struct wined3d_device *device, struct wined3d_context *context,
struct wined3d_surface *depth_stencil) DECLSPEC_HIDDEN;
-void device_update_stream_info(struct wined3d_device *device, const struct wined3d_gl_info *gl_info) DECLSPEC_HIDDEN;
+void device_update_stream_info(struct wined3d_device *device, struct wined3d_context *context) DECLSPEC_HIDDEN;
void device_update_tex_unit_map(struct wined3d_device *device) DECLSPEC_HIDDEN;
void device_invalidate_state(const struct wined3d_device *device, DWORD state) DECLSPEC_HIDDEN;
@@ -2519,7 +2519,7 @@ static inline struct wined3d_buffer *buffer_from_resource(struct wined3d_resourc
return CONTAINING_RECORD(resource, struct wined3d_buffer, resource);
}
-void buffer_get_memory(struct wined3d_buffer *buffer, const struct wined3d_gl_info *gl_info,
+void buffer_get_memory(struct wined3d_buffer *buffer, struct wined3d_context *context,
struct wined3d_bo_address *data) DECLSPEC_HIDDEN;
BYTE *buffer_get_sysmem(struct wined3d_buffer *This, const struct wined3d_gl_info *gl_info) DECLSPEC_HIDDEN;
--
1.8.1.5
More information about the wine-patches
mailing list