venus: prepare and feed renderer protocol info into cs
Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15495>
This commit is contained in:
parent
440705d78f
commit
a263da69ec
|
@ -24,6 +24,7 @@
|
|||
|
||||
#include "c11/threads.h"
|
||||
#include "util/bitscan.h"
|
||||
#include "util/bitset.h"
|
||||
#include "util/compiler.h"
|
||||
#include "util/list.h"
|
||||
#include "util/macros.h"
|
||||
|
|
|
@ -8,6 +8,46 @@
|
|||
#include "vn_instance.h"
|
||||
#include "vn_renderer.h"
|
||||
|
||||
struct vn_cs_renderer_protocol_info _vn_cs_renderer_protocol_info = {
|
||||
.mutex = _SIMPLE_MTX_INITIALIZER_NP,
|
||||
};
|
||||
|
||||
static void
|
||||
vn_cs_renderer_protocol_info_init_once(struct vn_instance *instance)
|
||||
{
|
||||
const struct vn_renderer_info *renderer_info = &instance->renderer->info;
|
||||
/* assume renderer protocol supports all extensions if bit 0 is not set */
|
||||
const bool support_all_exts =
|
||||
!vn_info_extension_mask_test(renderer_info->vk_extension_mask, 0);
|
||||
|
||||
_vn_cs_renderer_protocol_info.api_version = renderer_info->vk_xml_version;
|
||||
|
||||
STATIC_ASSERT(sizeof(renderer_info->vk_extension_mask) >=
|
||||
sizeof(_vn_cs_renderer_protocol_info.extension_bitset));
|
||||
|
||||
for (uint32_t i = 1; i <= VN_INFO_EXTENSION_MAX_NUMBER; i++) {
|
||||
/* use protocl helper to ensure mask decoding matches encoding */
|
||||
if (support_all_exts ||
|
||||
vn_info_extension_mask_test(renderer_info->vk_extension_mask, i))
|
||||
BITSET_SET(_vn_cs_renderer_protocol_info.extension_bitset, i);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
vn_cs_renderer_protocol_info_init(struct vn_instance *instance)
|
||||
{
|
||||
simple_mtx_lock(&_vn_cs_renderer_protocol_info.mutex);
|
||||
if (_vn_cs_renderer_protocol_info.init_once) {
|
||||
simple_mtx_unlock(&_vn_cs_renderer_protocol_info.mutex);
|
||||
return;
|
||||
}
|
||||
|
||||
vn_cs_renderer_protocol_info_init_once(instance);
|
||||
|
||||
_vn_cs_renderer_protocol_info.init_once = true;
|
||||
simple_mtx_unlock(&_vn_cs_renderer_protocol_info.mutex);
|
||||
}
|
||||
|
||||
static void
|
||||
vn_cs_encoder_sanity_check(struct vn_cs_encoder *enc)
|
||||
{
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
|
||||
#include "vn_common.h"
|
||||
|
||||
#include "venus-protocol/vn_protocol_driver_info.h"
|
||||
|
||||
#define VN_CS_ENCODER_BUFFER_INITIALIZER(storage) \
|
||||
(struct vn_cs_encoder_buffer) { .base = storage, }
|
||||
|
||||
|
@ -81,18 +83,31 @@ struct vn_cs_decoder {
|
|||
const void *end;
|
||||
};
|
||||
|
||||
struct vn_cs_renderer_protocol_info {
|
||||
simple_mtx_t mutex;
|
||||
bool init_once;
|
||||
uint32_t api_version;
|
||||
BITSET_DECLARE(extension_bitset, VN_INFO_EXTENSION_MAX_NUMBER + 1);
|
||||
};
|
||||
|
||||
extern struct vn_cs_renderer_protocol_info _vn_cs_renderer_protocol_info;
|
||||
|
||||
static inline bool
|
||||
vn_cs_renderer_protocol_has_api_version(UNUSED uint32_t api_version)
|
||||
vn_cs_renderer_protocol_has_api_version(uint32_t api_version)
|
||||
{
|
||||
return true;
|
||||
return _vn_cs_renderer_protocol_info.api_version >= api_version;
|
||||
}
|
||||
|
||||
static inline bool
|
||||
vn_cs_renderer_protocol_has_extension(UNUSED uint32_t ext_number)
|
||||
vn_cs_renderer_protocol_has_extension(uint32_t ext_number)
|
||||
{
|
||||
return true;
|
||||
return BITSET_TEST(_vn_cs_renderer_protocol_info.extension_bitset,
|
||||
ext_number);
|
||||
}
|
||||
|
||||
void
|
||||
vn_cs_renderer_protocol_info_init(struct vn_instance *instance);
|
||||
|
||||
void
|
||||
vn_cs_encoder_init(struct vn_cs_encoder *enc,
|
||||
struct vn_instance *instance,
|
||||
|
|
|
@ -731,6 +731,8 @@ vn_CreateInstance(const VkInstanceCreateInfo *pCreateInfo,
|
|||
if (result != VK_SUCCESS)
|
||||
goto fail;
|
||||
|
||||
vn_cs_renderer_protocol_info_init(instance);
|
||||
|
||||
vn_renderer_shmem_pool_init(instance->renderer,
|
||||
&instance->reply_shmem_pool, 1u << 20);
|
||||
|
||||
|
|
Loading…
Reference in New Issue