[PATCH] wined3d: Do not attempt to bind a null buffer_object in state_cb().

Henri Verbeet hverbeet at gmail.com
Tue Dec 14 06:19:18 CST 2021


On Tue, 14 Dec 2021 at 08:05, Conor McCarthy <cmccarthy at codeweavers.com> wrote:
>
> Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52020
> Signed-off-by: Conor McCarthy <cmccarthy at codeweavers.com>
> ---
>  dlls/wined3d/state.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c
> index 865c60d18..6d7e30732 100644
> --- a/dlls/wined3d/state.c
> +++ b/dlls/wined3d/state.c
> @@ -4584,13 +4584,12 @@ static void state_cb(struct wined3d_context *context, const struct wined3d_state
>      {
>          const struct wined3d_constant_buffer_state *buffer_state = &state->cb[shader_type][i];
>
> -        if (!buffer_state->buffer)
> +        if (!(buffer = buffer_state->buffer) || !buffer->buffer_object)
>          {
>              GL_EXTCALL(glBindBufferBase(GL_UNIFORM_BUFFER, base + i, 0));
>              continue;
>          }
>
> -        buffer = buffer_state->buffer;
>          bo_gl = wined3d_bo_gl(buffer->buffer_object);
>          GL_EXTCALL(glBindBufferRange(GL_UNIFORM_BUFFER, base + i,
>                  bo_gl->id, bo_gl->b.buffer_offset + buffer_state->offset, buffer_state->size));

This may be correct/fine, but as-is it's a little suspicious; why is
"buffer_object" NULL for the buffer resource in question?

In particular, state_cb() implies d3d10+, which implies running on a
GPU that supports buffer object. (And the log on the bug in question
shows buffer objects being created.) We don't create buffer objects
for buffer resources lacking WINED3D_RESOURCE_ACCESS_GPU either, but
in that case the resource shouldn't have WINED3D_BIND_CONSTANT_BUFFER
either.



More information about the wine-devel mailing list