wined3d: Only invalidate STATE_INDEXBUFFER for the current context in buffer_create_buffer_object().

This commit is contained in:
Stefan Dösinger 2013-09-09 15:15:35 +02:00 committed by Alexandre Julliard
parent c5be905bf7
commit 1cf192172e
4 changed files with 18 additions and 15 deletions

View File

@ -118,10 +118,11 @@ static void delete_gl_buffer(struct wined3d_buffer *This, const struct wined3d_g
} }
/* Context activation is done by the caller. */ /* 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 gl_usage = GL_STATIC_DRAW_ARB;
GLenum error; 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", TRACE("Creating an OpenGL vertex buffer object for wined3d_buffer %p with usage %s.\n",
This, debug_d3dusage(This->resource.usage)); 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) 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)); GL_EXTCALL(glBindBufferARB(This->buffer_type_hint, This->buffer_object));
error = gl_info->gl_ops.gl.p_glGetError(); error = gl_info->gl_ops.gl.p_glGetError();
if (error != GL_NO_ERROR) if (error != GL_NO_ERROR)
@ -460,7 +461,7 @@ static inline void fixup_transformed_pos(float *p)
} }
/* Context activation is done by the caller. */ /* 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) struct wined3d_bo_address *data)
{ {
data->buffer_object = buffer->buffer_object; 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) 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; buffer->flags &= ~WINED3D_BUFFER_CREATEBO;
if (buffer->buffer_object) if (buffer->buffer_object)
{ {
@ -754,7 +755,7 @@ void CDECL wined3d_buffer_preload(struct wined3d_buffer *buffer)
if (buffer->flags & WINED3D_BUFFER_CREATEBO) if (buffer->flags & WINED3D_BUFFER_CREATEBO)
{ {
context = context_acquire(device, NULL); context = context_acquire(device, NULL);
buffer_create_buffer_object(buffer, context->gl_info); buffer_create_buffer_object(buffer, context);
context_release(context); context_release(context);
buffer->flags &= ~WINED3D_BUFFER_CREATEBO; buffer->flags &= ~WINED3D_BUFFER_CREATEBO;
} }

View File

@ -2368,7 +2368,7 @@ BOOL context_apply_draw_state(struct wined3d_context *context, struct wined3d_de
device_update_tex_unit_map(device); device_update_tex_unit_map(device);
device_preload_textures(device); device_preload_textures(device);
if (isStateDirty(context, STATE_VDECL) || isStateDirty(context, STATE_STREAMSRC)) 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 (state->index_buffer)
{ {
if (device->stream_info.all_vbo) if (device->stream_info.all_vbo)

View File

@ -164,7 +164,8 @@ static BOOL fixed_get_input(BYTE usage, BYTE usage_idx, unsigned int *regnum)
} }
/* Context activation is done by the caller. */ /* 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; const struct wined3d_state *state = &device->state;
/* We need to deal with frequency data! */ /* 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; stride = stream->stride;
TRACE("Stream %u, buffer %p.\n", element->input_slot, buffer); 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 /* We can't use VBOs if the base vertex index is negative. OpenGL
* doesn't accept negative offsets (or rather offsets bigger than the * 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); WARN_(d3d_perf)("load_base_vertex_index is < 0 (%d), not using VBOs.\n", state->load_base_vertex_index);
data.buffer_object = 0; 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) if ((UINT_PTR)data.addr < -state->load_base_vertex_index * stride)
FIXME("System memory vertex data load offset is negative!\n"); 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].stride = stride;
stream_info->elements[idx].stream_idx = element->input_slot; 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) && element->format->id == WINED3DFMT_B8G8R8A8_UNORM)
{ {
stream_info->swizzle_map |= 1 << idx; 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. */ /* 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; struct wined3d_stream_info *stream_info = &device->stream_info;
const struct wined3d_state *state = &device->state; const struct wined3d_state *state = &device->state;
DWORD prev_all_vbo = stream_info->all_vbo; DWORD prev_all_vbo = stream_info->all_vbo;
TRACE("============================= Vertex Declaration =============================\n"); 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) 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; vs = state->vertex_shader;
state->vertex_shader = NULL; 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; state->vertex_shader = vs;
/* We can't convert FROM a VBO, and vertex buffers used to source into /* We can't convert FROM a VBO, and vertex buffers used to source into

View File

@ -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_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, void device_switch_onscreen_ds(struct wined3d_device *device, struct wined3d_context *context,
struct wined3d_surface *depth_stencil) DECLSPEC_HIDDEN; 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_update_tex_unit_map(struct wined3d_device *device) DECLSPEC_HIDDEN;
void device_invalidate_state(const struct wined3d_device *device, DWORD state) DECLSPEC_HIDDEN; void device_invalidate_state(const struct wined3d_device *device, DWORD state) DECLSPEC_HIDDEN;
@ -2520,7 +2520,7 @@ static inline struct wined3d_buffer *buffer_from_resource(struct wined3d_resourc
return CONTAINING_RECORD(resource, struct wined3d_buffer, resource); 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; struct wined3d_bo_address *data) DECLSPEC_HIDDEN;
BYTE *buffer_get_sysmem(struct wined3d_buffer *This, const struct wined3d_gl_info *gl_info) DECLSPEC_HIDDEN; BYTE *buffer_get_sysmem(struct wined3d_buffer *This, const struct wined3d_gl_info *gl_info) DECLSPEC_HIDDEN;