Mesa (main): d3d12: Fix set constant buffers
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Tue Feb 8 21:13:47 UTC 2022
Module: Mesa
Branch: main
Commit: 2659098d6d7c18a96ed4d5cf1d07699ef96dac35
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=2659098d6d7c18a96ed4d5cf1d07699ef96dac35
Author: Jesse Natalie <jenatali at microsoft.com>
Date: Mon Feb 7 15:52:52 2022 -0800
d3d12: Fix set constant buffers
Reviewed-by: Sil Vilerino <sivileri at microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14933>
---
src/gallium/drivers/d3d12/d3d12_context.cpp | 23 ++++++++++++-----------
1 file changed, 12 insertions(+), 11 deletions(-)
diff --git a/src/gallium/drivers/d3d12/d3d12_context.cpp b/src/gallium/drivers/d3d12/d3d12_context.cpp
index 3a2d6ee3731..f0fadc89abb 100644
--- a/src/gallium/drivers/d3d12/d3d12_context.cpp
+++ b/src/gallium/drivers/d3d12/d3d12_context.cpp
@@ -1356,30 +1356,31 @@ d3d12_set_constant_buffer(struct pipe_context *pctx,
const struct pipe_constant_buffer *buf)
{
struct d3d12_context *ctx = d3d12_context(pctx);
+ struct d3d12_resource *old_buf = d3d12_resource(ctx->cbufs[shader][index].buffer);
+ if (old_buf)
+ d3d12_decrement_constant_buffer_bind_count(ctx, shader, old_buf);
if (buf) {
- struct pipe_resource *buffer = buf->buffer;
unsigned offset = buf->buffer_offset;
if (buf->user_buffer) {
u_upload_data(pctx->const_uploader, 0, buf->buffer_size,
- D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT,
+ D3D12_CONSTANT_BUFFER_DATA_PLACEMENT_ALIGNMENT,
buf->user_buffer, &offset, &ctx->cbufs[shader][index].buffer);
-
+ d3d12_increment_constant_buffer_bind_count(ctx, shader,
+ d3d12_resource(ctx->cbufs[shader][index].buffer));
} else {
+ struct pipe_resource *buffer = buf->buffer;
+ if (buffer)
+ d3d12_increment_constant_buffer_bind_count(ctx, shader, d3d12_resource(buffer));
+
if (take_ownership) {
- struct d3d12_resource *old_buf = d3d12_resource(ctx->cbufs[shader][index].buffer);
- if (old_buf)
- d3d12_decrement_constant_buffer_bind_count(ctx, shader, old_buf);
+ pipe_resource_reference(&ctx->cbufs[shader][index].buffer, buffer);
+ } else {
pipe_resource_reference(&ctx->cbufs[shader][index].buffer, NULL);
ctx->cbufs[shader][index].buffer = buffer;
- if (buffer)
- d3d12_increment_constant_buffer_bind_count(ctx, shader, d3d12_resource(buffer));
- } else {
- pipe_resource_reference(&ctx->cbufs[shader][index].buffer, buffer);
}
}
-
ctx->cbufs[shader][index].buffer_offset = offset;
ctx->cbufs[shader][index].buffer_size = buf->buffer_size;
ctx->cbufs[shader][index].user_buffer = NULL;
More information about the mesa-commit
mailing list