On Fri, Oct 28, 2016 at 3:55 PM, Henri Verbeet hverbeet@gmail.com wrote:
On 28 October 2016 at 12:20, Józef Kucia jkucia@codeweavers.com wrote:
- if (buffer->resource.bind_count)
- {
if (buffer->buffer_type_hint == GL_ELEMENT_ARRAY_BUFFER)
device_invalidate_state(buffer->resource.device, STATE_INDEXBUFFER);
- }
You can merge those if-conditions.
What happens exactly that makes this required?
The bound index buffer is unloaded and the game crashes on the next draw call because we use indexed drawing with zeroish offset and GL_ELEMENT_ARRAY_BUFFER_BINDING is 0. I've sent another patch which targets this issue.
The other thing is that, in theory, when a buffer is modified in the current context we should should invalidate buffer bindings for this buffer in other contexts in order to make the contents changes visible in other contexts. That's the reason why I was trying to restore device_invalidate_state() call in wined3d_buffer_load(). This would fix the regression as well. The quote from GL spec: "If the contents of an object T are changed in a context other than the cur- rent context, T must be attached or re-attached to at least one binding point in the current context, or at least one attachment point of a currently bound container object C, in order to guarantee that the new contents of T are visible in the current context."