venus: add and use VN_CS_ENCODER_INITIALIZER

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12568>
This commit is contained in:
Chia-I Wu 2021-08-30 09:37:08 -07:00 committed by Marge Bot
parent 0641a230a0
commit 862244ccc6
2 changed files with 15 additions and 8 deletions

View file

@ -8,17 +8,26 @@
#include "vn_common.h"
#define VN_CS_ENCODER_BUFFER_INITIALIZER(storage) \
(struct vn_cs_encoder_buffer) { .base = storage, }
/* note that buffers points to an unamed local variable */
#define VN_CS_ENCODER_INITIALIZER_LOCAL(storage, size) \
(struct vn_cs_encoder) \
{ \
.buffers = \
&(struct vn_cs_encoder_buffer){ \
.base = storage, \
}, \
.buffers = &VN_CS_ENCODER_BUFFER_INITIALIZER(storage), \
.buffer_count = 1, .buffer_max = 1, .current_buffer_size = size, \
.cur = storage, .end = (const void *)(storage) + (size), \
}
#define VN_CS_ENCODER_INITIALIZER(buf, size) \
(struct vn_cs_encoder) \
{ \
.buffers = (buf), .buffer_count = 1, .buffer_max = 1, \
.current_buffer_size = size, .cur = (buf)->base, \
.end = (buf)->base + (size), \
}
#define VN_CS_DECODER_INITIALIZER(storage, size) \
(struct vn_cs_decoder) \
{ \

View file

@ -128,10 +128,8 @@ vn_instance_submit_command_init(struct vn_instance *instance,
size_t cmd_size,
size_t reply_size)
{
submit->command = VN_CS_ENCODER_INITIALIZER_LOCAL(cmd_data, cmd_size);
/* fix submit->command.buffers to not point to a local variable */
submit->buffer = submit->command.buffers[0];
submit->command.buffers = &submit->buffer;
submit->buffer = VN_CS_ENCODER_BUFFER_INITIALIZER(cmd_data);
submit->command = VN_CS_ENCODER_INITIALIZER(&submit->buffer, cmd_size);
submit->reply_size = reply_size;
submit->reply_shmem = NULL;