Mesa (master): d3d12: Handle null constant buffers
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Mon Mar 1 20:51:29 UTC 2021
Module: Mesa
Branch: master
Commit: eb27db8681643cbde80a9e04e25e7fb42d07fdf3
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=eb27db8681643cbde80a9e04e25e7fb42d07fdf3
Author: Jesse Natalie <jenatali at microsoft.com>
Date: Mon Mar 1 09:37:57 2021 -0800
d3d12: Handle null constant buffers
RuneScape ends up hitting this path, and it's easy enough to get
some well-defined behavior instead of a crash.
Reviewed-by: Eric Anholt <eric at anholt.net>
Reviewed-By: Bill Kristiansen <billkris at microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9342>
---
src/gallium/drivers/d3d12/d3d12_draw.cpp | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/src/gallium/drivers/d3d12/d3d12_draw.cpp b/src/gallium/drivers/d3d12/d3d12_draw.cpp
index 557ea589324..0513dc52bb8 100644
--- a/src/gallium/drivers/d3d12/d3d12_draw.cpp
+++ b/src/gallium/drivers/d3d12/d3d12_draw.cpp
@@ -59,16 +59,18 @@ fill_cbv_descriptors(struct d3d12_context *ctx,
unsigned binding = shader->cb_bindings[i].binding;
struct pipe_constant_buffer *buffer = &ctx->cbufs[stage][binding];
- assert(buffer->buffer_size > 0);
- assert(buffer->buffer);
-
- struct d3d12_resource *res = d3d12_resource(buffer->buffer);
- d3d12_transition_resource_state(ctx, res, D3D12_RESOURCE_STATE_VERTEX_AND_CONSTANT_BUFFER);
D3D12_CONSTANT_BUFFER_VIEW_DESC cbv_desc = {};
- cbv_desc.BufferLocation = d3d12_resource_gpu_virtual_address(res) + buffer->buffer_offset;
- cbv_desc.SizeInBytes = MIN2(D3D12_REQ_CONSTANT_BUFFER_ELEMENT_COUNT * 16,
- align(buffer->buffer_size, 256));
- d3d12_batch_reference_resource(batch, res);
+ if (buffer) {
+ assert(buffer->buffer_size > 0);
+ assert(buffer->buffer);
+
+ struct d3d12_resource *res = d3d12_resource(buffer->buffer);
+ d3d12_transition_resource_state(ctx, res, D3D12_RESOURCE_STATE_VERTEX_AND_CONSTANT_BUFFER);
+ cbv_desc.BufferLocation = d3d12_resource_gpu_virtual_address(res) + buffer->buffer_offset;
+ cbv_desc.SizeInBytes = MIN2(D3D12_REQ_CONSTANT_BUFFER_ELEMENT_COUNT * 16,
+ align(buffer->buffer_size, 256));
+ d3d12_batch_reference_resource(batch, res);
+ }
struct d3d12_descriptor_handle handle;
d3d12_descriptor_heap_alloc_handle(batch->view_heap, &handle);
More information about the mesa-commit
mailing list