Mesa (master): zink: replace unset buffer with a dummy-buffer
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Mon Feb 10 10:59:42 UTC 2020
Module: Mesa
Branch: master
Commit: 8736ffae2eda9de1ac49200ef399170b428b9f8c
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=8736ffae2eda9de1ac49200ef399170b428b9f8c
Author: Erik Faye-Lund <erik.faye-lund at collabora.com>
Date: Sat Feb 1 17:38:30 2020 +0100
zink: replace unset buffer with a dummy-buffer
This fixes a crash in spec@!opengl 1.1 at ppgtt_memory_alignment
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3673>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3673>
---
src/gallium/drivers/zink/zink_context.c | 6 ++++++
src/gallium/drivers/zink/zink_context.h | 2 ++
src/gallium/drivers/zink/zink_draw.c | 15 ++++++++++-----
3 files changed, 18 insertions(+), 5 deletions(-)
diff --git a/src/gallium/drivers/zink/zink_context.c b/src/gallium/drivers/zink/zink_context.c
index f2b9044bc2b..d6d3f33b115 100644
--- a/src/gallium/drivers/zink/zink_context.c
+++ b/src/gallium/drivers/zink/zink_context.c
@@ -1172,6 +1172,12 @@ zink_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags)
!ctx->framebuffer_cache)
goto fail;
+ const uint8_t data[] = { 0 };
+ ctx->dummy_buffer = pipe_buffer_create_with_data(&ctx->base,
+ PIPE_BIND_VERTEX_BUFFER, PIPE_USAGE_IMMUTABLE, sizeof(data), data);
+ if (!ctx->dummy_buffer)
+ goto fail;
+
ctx->dirty_program = true;
/* start the first batch */
diff --git a/src/gallium/drivers/zink/zink_context.h b/src/gallium/drivers/zink/zink_context.h
index e46cb8017da..3aeef31e3d3 100644
--- a/src/gallium/drivers/zink/zink_context.h
+++ b/src/gallium/drivers/zink/zink_context.h
@@ -110,6 +110,8 @@ struct zink_context {
struct list_head active_queries;
bool queries_disabled;
+
+ struct pipe_resource *dummy_buffer;
};
static inline struct zink_context *
diff --git a/src/gallium/drivers/zink/zink_draw.c b/src/gallium/drivers/zink/zink_draw.c
index 76dcd30783d..553579acf64 100644
--- a/src/gallium/drivers/zink/zink_draw.c
+++ b/src/gallium/drivers/zink/zink_draw.c
@@ -44,11 +44,16 @@ zink_bind_vertex_buffers(struct zink_batch *batch, struct zink_context *ctx)
const struct zink_vertex_elements_state *elems = ctx->element_state;
for (unsigned i = 0; i < elems->hw_state.num_bindings; i++) {
struct pipe_vertex_buffer *vb = ctx->buffers + ctx->element_state->binding_map[i];
- assert(vb && vb->buffer.resource);
- struct zink_resource *res = zink_resource(vb->buffer.resource);
- buffers[i] = res->buffer;
- buffer_offsets[i] = vb->buffer_offset;
- zink_batch_reference_resoure(batch, res);
+ assert(vb);
+ if (vb->buffer.resource) {
+ struct zink_resource *res = zink_resource(vb->buffer.resource);
+ buffers[i] = res->buffer;
+ buffer_offsets[i] = vb->buffer_offset;
+ zink_batch_reference_resoure(batch, res);
+ } else {
+ buffers[i] = zink_resource(ctx->dummy_buffer)->buffer;
+ buffer_offsets[i] = 0;
+ }
}
if (elems->hw_state.num_bindings > 0)
More information about the mesa-commit
mailing list