vkr: split out vkr_descriptor_set.c

No functional change.

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Ryan Neph <ryanneph@google.com>
macos/master
Chia-I Wu 3 years ago
parent 0dd30e9704
commit f74caa30fc
  1. 1
      src/meson.build
  2. 205
      src/venus/vkr_descriptor_set.c
  3. 12
      src/venus/vkr_descriptor_set.h
  4. 170
      src/venus/vkr_renderer.c

@ -85,6 +85,7 @@ venus_sources = [
'venus/vkr_context.h', 'venus/vkr_context.h',
'venus/vkr_cs.c', 'venus/vkr_cs.c',
'venus/vkr_cs.h', 'venus/vkr_cs.h',
'venus/vkr_descriptor_set.c',
'venus/vkr_descriptor_set.h', 'venus/vkr_descriptor_set.h',
'venus/vkr_device.h', 'venus/vkr_device.h',
'venus/vkr_device_memory.h', 'venus/vkr_device_memory.h',

@ -0,0 +1,205 @@
/*
* Copyright 2020 Google LLC
* SPDX-License-Identifier: MIT
*/
#include "vkr_descriptor_set.h"
#include "venus-protocol/vn_protocol_renderer_descriptor_pool.h"
#include "venus-protocol/vn_protocol_renderer_descriptor_set.h"
#include "venus-protocol/vn_protocol_renderer_descriptor_set_layout.h"
#include "venus-protocol/vn_protocol_renderer_descriptor_update_template.h"
#include "vkr_context.h"
#include "vkr_device.h"
static void
vkr_dispatch_vkGetDescriptorSetLayoutSupport(
UNUSED struct vn_dispatch_context *dispatch,
struct vn_command_vkGetDescriptorSetLayoutSupport *args)
{
vn_replace_vkGetDescriptorSetLayoutSupport_args_handle(args);
vkGetDescriptorSetLayoutSupport(args->device, args->pCreateInfo, args->pSupport);
}
static void
vkr_dispatch_vkCreateDescriptorSetLayout(
struct vn_dispatch_context *dispatch,
struct vn_command_vkCreateDescriptorSetLayout *args)
{
struct vkr_context *ctx = dispatch->data;
CREATE_OBJECT(layout, descriptor_set_layout, DESCRIPTOR_SET_LAYOUT,
vkCreateDescriptorSetLayout, pSetLayout);
util_hash_table_set_u64(ctx->object_table, layout->base.id, layout);
}
static void
vkr_dispatch_vkDestroyDescriptorSetLayout(
struct vn_dispatch_context *dispatch,
struct vn_command_vkDestroyDescriptorSetLayout *args)
{
struct vkr_context *ctx = dispatch->data;
DESTROY_OBJECT(layout, descriptor_set_layout, DESCRIPTOR_SET_LAYOUT,
vkDestroyDescriptorSetLayout, descriptorSetLayout);
util_hash_table_remove_u64(ctx->object_table, layout->base.id);
}
static void
vkr_dispatch_vkCreateDescriptorPool(struct vn_dispatch_context *dispatch,
struct vn_command_vkCreateDescriptorPool *args)
{
struct vkr_context *ctx = dispatch->data;
CREATE_OBJECT(pool, descriptor_pool, DESCRIPTOR_POOL, vkCreateDescriptorPool,
pDescriptorPool);
list_inithead(&pool->descriptor_sets);
util_hash_table_set_u64(ctx->object_table, pool->base.id, pool);
}
static void
vkr_dispatch_vkDestroyDescriptorPool(struct vn_dispatch_context *dispatch,
struct vn_command_vkDestroyDescriptorPool *args)
{
struct vkr_context *ctx = dispatch->data;
DESTROY_OBJECT(pool, descriptor_pool, DESCRIPTOR_POOL, vkDestroyDescriptorPool,
descriptorPool);
struct vkr_descriptor_set *set, *tmp;
LIST_FOR_EACH_ENTRY_SAFE (set, tmp, &pool->descriptor_sets, head)
util_hash_table_remove_u64(ctx->object_table, set->base.id);
util_hash_table_remove_u64(ctx->object_table, pool->base.id);
}
static void
vkr_dispatch_vkResetDescriptorPool(struct vn_dispatch_context *dispatch,
struct vn_command_vkResetDescriptorPool *args)
{
struct vkr_context *ctx = dispatch->data;
struct vkr_descriptor_pool *pool =
(struct vkr_descriptor_pool *)(uintptr_t)args->descriptorPool;
if (!pool || pool->base.type != VK_OBJECT_TYPE_DESCRIPTOR_POOL) {
vkr_cs_decoder_set_fatal(&ctx->decoder);
return;
}
vn_replace_vkResetDescriptorPool_args_handle(args);
args->ret = vkResetDescriptorPool(args->device, args->descriptorPool, args->flags);
struct vkr_descriptor_set *set, *tmp;
LIST_FOR_EACH_ENTRY_SAFE (set, tmp, &pool->descriptor_sets, head)
util_hash_table_remove_u64(ctx->object_table, set->base.id);
list_inithead(&pool->descriptor_sets);
}
static void
vkr_dispatch_vkAllocateDescriptorSets(struct vn_dispatch_context *dispatch,
struct vn_command_vkAllocateDescriptorSets *args)
{
struct vkr_context *ctx = dispatch->data;
ALLOCATE_OBJECT_ARRAY(set, descriptor_set, DESCRIPTOR_SET, DescriptorSet,
vkAllocateDescriptorSets, descriptorSetCount, descriptorPool,
descriptor_pool, DESCRIPTOR_POOL);
}
static void
vkr_dispatch_vkFreeDescriptorSets(struct vn_dispatch_context *dispatch,
struct vn_command_vkFreeDescriptorSets *args)
{
struct vkr_context *ctx = dispatch->data;
FREE_OBJECT_ARRAY(set, descriptor_set, DESCRIPTOR_SET, vkFreeDescriptorSets,
pDescriptorSets, descriptorSetCount, descriptorPool);
args->ret = VK_SUCCESS;
}
static void
vkr_dispatch_vkUpdateDescriptorSets(UNUSED struct vn_dispatch_context *dispatch,
struct vn_command_vkUpdateDescriptorSets *args)
{
vn_replace_vkUpdateDescriptorSets_args_handle(args);
vkUpdateDescriptorSets(args->device, args->descriptorWriteCount,
args->pDescriptorWrites, args->descriptorCopyCount,
args->pDescriptorCopies);
}
static void
vkr_dispatch_vkCreateDescriptorUpdateTemplate(
struct vn_dispatch_context *dispatch,
struct vn_command_vkCreateDescriptorUpdateTemplate *args)
{
struct vkr_context *ctx = dispatch->data;
CREATE_OBJECT(templ, descriptor_update_template, DESCRIPTOR_UPDATE_TEMPLATE,
vkCreateDescriptorUpdateTemplate, pDescriptorUpdateTemplate);
util_hash_table_set_u64(ctx->object_table, templ->base.id, templ);
}
static void
vkr_dispatch_vkDestroyDescriptorUpdateTemplate(
struct vn_dispatch_context *dispatch,
struct vn_command_vkDestroyDescriptorUpdateTemplate *args)
{
struct vkr_context *ctx = dispatch->data;
DESTROY_OBJECT(templ, descriptor_update_template, DESCRIPTOR_UPDATE_TEMPLATE,
vkDestroyDescriptorUpdateTemplate, descriptorUpdateTemplate);
util_hash_table_remove_u64(ctx->object_table, templ->base.id);
}
void
vkr_context_init_descriptor_set_layout_dispatch(struct vkr_context *ctx)
{
struct vn_dispatch_context *dispatch = &ctx->dispatch;
dispatch->dispatch_vkGetDescriptorSetLayoutSupport =
vkr_dispatch_vkGetDescriptorSetLayoutSupport;
dispatch->dispatch_vkCreateDescriptorSetLayout =
vkr_dispatch_vkCreateDescriptorSetLayout;
dispatch->dispatch_vkDestroyDescriptorSetLayout =
vkr_dispatch_vkDestroyDescriptorSetLayout;
}
void
vkr_context_init_descriptor_pool_dispatch(struct vkr_context *ctx)
{
struct vn_dispatch_context *dispatch = &ctx->dispatch;
dispatch->dispatch_vkCreateDescriptorPool = vkr_dispatch_vkCreateDescriptorPool;
dispatch->dispatch_vkDestroyDescriptorPool = vkr_dispatch_vkDestroyDescriptorPool;
dispatch->dispatch_vkResetDescriptorPool = vkr_dispatch_vkResetDescriptorPool;
}
void
vkr_context_init_descriptor_set_dispatch(struct vkr_context *ctx)
{
struct vn_dispatch_context *dispatch = &ctx->dispatch;
dispatch->dispatch_vkAllocateDescriptorSets = vkr_dispatch_vkAllocateDescriptorSets;
dispatch->dispatch_vkFreeDescriptorSets = vkr_dispatch_vkFreeDescriptorSets;
dispatch->dispatch_vkUpdateDescriptorSets = vkr_dispatch_vkUpdateDescriptorSets;
}
void
vkr_context_init_descriptor_update_template_dispatch(struct vkr_context *ctx)
{
struct vn_dispatch_context *dispatch = &ctx->dispatch;
dispatch->dispatch_vkCreateDescriptorUpdateTemplate =
vkr_dispatch_vkCreateDescriptorUpdateTemplate;
dispatch->dispatch_vkDestroyDescriptorUpdateTemplate =
vkr_dispatch_vkDestroyDescriptorUpdateTemplate;
dispatch->dispatch_vkUpdateDescriptorSetWithTemplate = NULL;
}

@ -30,4 +30,16 @@ struct vkr_descriptor_update_template {
struct vkr_object base; struct vkr_object base;
}; };
void
vkr_context_init_descriptor_set_layout_dispatch(struct vkr_context *ctx);
void
vkr_context_init_descriptor_pool_dispatch(struct vkr_context *ctx);
void
vkr_context_init_descriptor_set_dispatch(struct vkr_context *ctx);
void
vkr_context_init_descriptor_update_template_dispatch(struct vkr_context *ctx);
#endif /* VKR_DESCRIPTOR_SET_H */ #endif /* VKR_DESCRIPTOR_SET_H */

@ -2451,152 +2451,6 @@ vkr_dispatch_vkDestroySamplerYcbcrConversion(
util_hash_table_remove_u64(ctx->object_table, conv->base.id); util_hash_table_remove_u64(ctx->object_table, conv->base.id);
} }
static void
vkr_dispatch_vkGetDescriptorSetLayoutSupport(
UNUSED struct vn_dispatch_context *dispatch,
struct vn_command_vkGetDescriptorSetLayoutSupport *args)
{
vn_replace_vkGetDescriptorSetLayoutSupport_args_handle(args);
vkGetDescriptorSetLayoutSupport(args->device, args->pCreateInfo, args->pSupport);
}
static void
vkr_dispatch_vkCreateDescriptorSetLayout(
struct vn_dispatch_context *dispatch,
struct vn_command_vkCreateDescriptorSetLayout *args)
{
struct vkr_context *ctx = dispatch->data;
CREATE_OBJECT(layout, descriptor_set_layout, DESCRIPTOR_SET_LAYOUT,
vkCreateDescriptorSetLayout, pSetLayout);
util_hash_table_set_u64(ctx->object_table, layout->base.id, layout);
}
static void
vkr_dispatch_vkDestroyDescriptorSetLayout(
struct vn_dispatch_context *dispatch,
struct vn_command_vkDestroyDescriptorSetLayout *args)
{
struct vkr_context *ctx = dispatch->data;
DESTROY_OBJECT(layout, descriptor_set_layout, DESCRIPTOR_SET_LAYOUT,
vkDestroyDescriptorSetLayout, descriptorSetLayout);
util_hash_table_remove_u64(ctx->object_table, layout->base.id);
}
static void
vkr_dispatch_vkCreateDescriptorPool(struct vn_dispatch_context *dispatch,
struct vn_command_vkCreateDescriptorPool *args)
{
struct vkr_context *ctx = dispatch->data;
CREATE_OBJECT(pool, descriptor_pool, DESCRIPTOR_POOL, vkCreateDescriptorPool,
pDescriptorPool);
list_inithead(&pool->descriptor_sets);
util_hash_table_set_u64(ctx->object_table, pool->base.id, pool);
}
static void
vkr_dispatch_vkDestroyDescriptorPool(struct vn_dispatch_context *dispatch,
struct vn_command_vkDestroyDescriptorPool *args)
{
struct vkr_context *ctx = dispatch->data;
DESTROY_OBJECT(pool, descriptor_pool, DESCRIPTOR_POOL, vkDestroyDescriptorPool,
descriptorPool);
struct vkr_descriptor_set *set, *tmp;
LIST_FOR_EACH_ENTRY_SAFE (set, tmp, &pool->descriptor_sets, head)
util_hash_table_remove_u64(ctx->object_table, set->base.id);
util_hash_table_remove_u64(ctx->object_table, pool->base.id);
}
static void
vkr_dispatch_vkResetDescriptorPool(struct vn_dispatch_context *dispatch,
struct vn_command_vkResetDescriptorPool *args)
{
struct vkr_context *ctx = dispatch->data;
struct vkr_descriptor_pool *pool =
(struct vkr_descriptor_pool *)(uintptr_t)args->descriptorPool;
if (!pool || pool->base.type != VK_OBJECT_TYPE_DESCRIPTOR_POOL) {
vkr_cs_decoder_set_fatal(&ctx->decoder);
return;
}
vn_replace_vkResetDescriptorPool_args_handle(args);
args->ret = vkResetDescriptorPool(args->device, args->descriptorPool, args->flags);
struct vkr_descriptor_set *set, *tmp;
LIST_FOR_EACH_ENTRY_SAFE (set, tmp, &pool->descriptor_sets, head)
util_hash_table_remove_u64(ctx->object_table, set->base.id);
list_inithead(&pool->descriptor_sets);
}
static void
vkr_dispatch_vkAllocateDescriptorSets(struct vn_dispatch_context *dispatch,
struct vn_command_vkAllocateDescriptorSets *args)
{
struct vkr_context *ctx = dispatch->data;
ALLOCATE_OBJECT_ARRAY(set, descriptor_set, DESCRIPTOR_SET, DescriptorSet,
vkAllocateDescriptorSets, descriptorSetCount, descriptorPool,
descriptor_pool, DESCRIPTOR_POOL);
}
static void
vkr_dispatch_vkFreeDescriptorSets(struct vn_dispatch_context *dispatch,
struct vn_command_vkFreeDescriptorSets *args)
{
struct vkr_context *ctx = dispatch->data;
FREE_OBJECT_ARRAY(set, descriptor_set, DESCRIPTOR_SET, vkFreeDescriptorSets,
pDescriptorSets, descriptorSetCount, descriptorPool);
args->ret = VK_SUCCESS;
}
static void
vkr_dispatch_vkUpdateDescriptorSets(UNUSED struct vn_dispatch_context *dispatch,
struct vn_command_vkUpdateDescriptorSets *args)
{
vn_replace_vkUpdateDescriptorSets_args_handle(args);
vkUpdateDescriptorSets(args->device, args->descriptorWriteCount,
args->pDescriptorWrites, args->descriptorCopyCount,
args->pDescriptorCopies);
}
static void
vkr_dispatch_vkCreateDescriptorUpdateTemplate(
struct vn_dispatch_context *dispatch,
struct vn_command_vkCreateDescriptorUpdateTemplate *args)
{
struct vkr_context *ctx = dispatch->data;
CREATE_OBJECT(templ, descriptor_update_template, DESCRIPTOR_UPDATE_TEMPLATE,
vkCreateDescriptorUpdateTemplate, pDescriptorUpdateTemplate);
util_hash_table_set_u64(ctx->object_table, templ->base.id, templ);
}
static void
vkr_dispatch_vkDestroyDescriptorUpdateTemplate(
struct vn_dispatch_context *dispatch,
struct vn_command_vkDestroyDescriptorUpdateTemplate *args)
{
struct vkr_context *ctx = dispatch->data;
DESTROY_OBJECT(templ, descriptor_update_template, DESCRIPTOR_UPDATE_TEMPLATE,
vkDestroyDescriptorUpdateTemplate, descriptorUpdateTemplate);
util_hash_table_remove_u64(ctx->object_table, templ->base.id);
}
static void static void
vkr_dispatch_vkCreateEvent(struct vn_dispatch_context *dispatch, vkr_dispatch_vkCreateEvent(struct vn_dispatch_context *dispatch,
struct vn_command_vkCreateEvent *args) struct vn_command_vkCreateEvent *args)
@ -2901,26 +2755,10 @@ vkr_context_init_dispatch(struct vkr_context *ctx)
dispatch->dispatch_vkDestroySamplerYcbcrConversion = dispatch->dispatch_vkDestroySamplerYcbcrConversion =
vkr_dispatch_vkDestroySamplerYcbcrConversion; vkr_dispatch_vkDestroySamplerYcbcrConversion;
dispatch->dispatch_vkGetDescriptorSetLayoutSupport = vkr_context_init_descriptor_set_layout_dispatch(ctx);
vkr_dispatch_vkGetDescriptorSetLayoutSupport; vkr_context_init_descriptor_pool_dispatch(ctx);
dispatch->dispatch_vkCreateDescriptorSetLayout = vkr_context_init_descriptor_set_dispatch(ctx);
vkr_dispatch_vkCreateDescriptorSetLayout; vkr_context_init_descriptor_update_template_dispatch(ctx);
dispatch->dispatch_vkDestroyDescriptorSetLayout =
vkr_dispatch_vkDestroyDescriptorSetLayout;
dispatch->dispatch_vkCreateDescriptorPool = vkr_dispatch_vkCreateDescriptorPool;
dispatch->dispatch_vkDestroyDescriptorPool = vkr_dispatch_vkDestroyDescriptorPool;
dispatch->dispatch_vkResetDescriptorPool = vkr_dispatch_vkResetDescriptorPool;
dispatch->dispatch_vkAllocateDescriptorSets = vkr_dispatch_vkAllocateDescriptorSets;
dispatch->dispatch_vkFreeDescriptorSets = vkr_dispatch_vkFreeDescriptorSets;
dispatch->dispatch_vkUpdateDescriptorSets = vkr_dispatch_vkUpdateDescriptorSets;
dispatch->dispatch_vkCreateDescriptorUpdateTemplate =
vkr_dispatch_vkCreateDescriptorUpdateTemplate;
dispatch->dispatch_vkDestroyDescriptorUpdateTemplate =
vkr_dispatch_vkDestroyDescriptorUpdateTemplate;
dispatch->dispatch_vkUpdateDescriptorSetWithTemplate = NULL;
vkr_context_init_render_pass_dispatch(ctx); vkr_context_init_render_pass_dispatch(ctx);
vkr_context_init_framebuffer_dispatch(ctx); vkr_context_init_framebuffer_dispatch(ctx);

Loading…
Cancel
Save