mirror of https://gitlab.freedesktop.org/mesa/mesa
venus: drop vn_should_sanitize_descriptor_set_writes
The check won't reduce much of the overhead but also adds more when something is to be fixed (mostly the case for push descriptor). Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28563>
This commit is contained in:
parent
21dee4d463
commit
563a61878c
|
@ -2201,29 +2201,21 @@ vn_CmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer,
|
|||
uint32_t descriptorWriteCount,
|
||||
const VkWriteDescriptorSet *pDescriptorWrites)
|
||||
{
|
||||
if (vn_should_sanitize_descriptor_set_writes(descriptorWriteCount,
|
||||
pDescriptorWrites, layout)) {
|
||||
struct vn_command_buffer *cmd =
|
||||
vn_command_buffer_from_handle(commandBuffer);
|
||||
struct vn_update_descriptor_sets *update =
|
||||
vn_update_descriptor_sets_parse_writes(
|
||||
descriptorWriteCount, pDescriptorWrites, &cmd->pool->allocator,
|
||||
layout);
|
||||
if (!update) {
|
||||
cmd->state = VN_COMMAND_BUFFER_STATE_INVALID;
|
||||
return;
|
||||
}
|
||||
|
||||
VN_CMD_ENQUEUE(vkCmdPushDescriptorSetKHR, commandBuffer,
|
||||
pipelineBindPoint, layout, set, update->write_count,
|
||||
update->writes);
|
||||
|
||||
vk_free(&cmd->pool->allocator, update);
|
||||
} else {
|
||||
VN_CMD_ENQUEUE(vkCmdPushDescriptorSetKHR, commandBuffer,
|
||||
pipelineBindPoint, layout, set, descriptorWriteCount,
|
||||
pDescriptorWrites);
|
||||
struct vn_command_buffer *cmd =
|
||||
vn_command_buffer_from_handle(commandBuffer);
|
||||
struct vn_update_descriptor_sets *update =
|
||||
vn_update_descriptor_sets_parse_writes(descriptorWriteCount,
|
||||
pDescriptorWrites,
|
||||
&cmd->pool->allocator, layout);
|
||||
if (!update) {
|
||||
cmd->state = VN_COMMAND_BUFFER_STATE_INVALID;
|
||||
return;
|
||||
}
|
||||
|
||||
VN_CMD_ENQUEUE(vkCmdPushDescriptorSetKHR, commandBuffer, pipelineBindPoint,
|
||||
layout, set, update->write_count, update->writes);
|
||||
|
||||
vk_free(&cmd->pool->allocator, update);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -764,89 +764,6 @@ vn_update_descriptor_sets_alloc(uint32_t write_count,
|
|||
return update;
|
||||
}
|
||||
|
||||
bool
|
||||
vn_should_sanitize_descriptor_set_writes(
|
||||
uint32_t write_count,
|
||||
const VkWriteDescriptorSet *writes,
|
||||
VkPipelineLayout pipeline_layout_handle)
|
||||
{
|
||||
/* the encoder does not ignore
|
||||
* VkWriteDescriptorSet::{pImageInfo,pBufferInfo,pTexelBufferView} when it
|
||||
* should
|
||||
*
|
||||
* TODO make the encoder smarter
|
||||
*/
|
||||
const struct vn_pipeline_layout *pipeline_layout =
|
||||
vn_pipeline_layout_from_handle(pipeline_layout_handle);
|
||||
for (uint32_t i = 0; i < write_count; i++) {
|
||||
const struct vn_descriptor_set_layout *set_layout =
|
||||
pipeline_layout
|
||||
? pipeline_layout->push_descriptor_set_layout
|
||||
: vn_descriptor_set_from_handle(writes[i].dstSet)->layout;
|
||||
const struct vn_descriptor_set_layout_binding *binding =
|
||||
&set_layout->bindings[writes[i].dstBinding];
|
||||
const VkWriteDescriptorSet *write = &writes[i];
|
||||
const VkDescriptorImageInfo *imgs = write->pImageInfo;
|
||||
|
||||
switch (write->descriptorType) {
|
||||
case VK_DESCRIPTOR_TYPE_SAMPLER:
|
||||
case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER:
|
||||
case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE:
|
||||
case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE:
|
||||
case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT:
|
||||
if (write->pBufferInfo != NULL || write->pTexelBufferView != NULL)
|
||||
return true;
|
||||
|
||||
for (uint32_t j = 0; j < write->descriptorCount; j++) {
|
||||
switch (write->descriptorType) {
|
||||
case VK_DESCRIPTOR_TYPE_SAMPLER:
|
||||
if (imgs[j].imageView != VK_NULL_HANDLE)
|
||||
return true;
|
||||
FALLTHROUGH;
|
||||
case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER:
|
||||
if (binding->has_immutable_samplers &&
|
||||
imgs[j].sampler != VK_NULL_HANDLE)
|
||||
return true;
|
||||
break;
|
||||
case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE:
|
||||
case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE:
|
||||
case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT:
|
||||
if (imgs[j].sampler != VK_NULL_HANDLE)
|
||||
return true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER:
|
||||
case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER:
|
||||
if (write->pImageInfo != NULL || write->pBufferInfo != NULL)
|
||||
return true;
|
||||
|
||||
break;
|
||||
case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER:
|
||||
case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER:
|
||||
case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC:
|
||||
case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC:
|
||||
if (write->pImageInfo != NULL || write->pTexelBufferView != NULL)
|
||||
return true;
|
||||
|
||||
break;
|
||||
case VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK:
|
||||
case VK_DESCRIPTOR_TYPE_MUTABLE_EXT:
|
||||
default:
|
||||
if (write->pImageInfo != NULL || write->pBufferInfo != NULL ||
|
||||
write->pTexelBufferView != NULL)
|
||||
return true;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
struct vn_update_descriptor_sets *
|
||||
vn_update_descriptor_sets_parse_writes(uint32_t write_count,
|
||||
const VkWriteDescriptorSet *writes,
|
||||
|
|
|
@ -130,12 +130,6 @@ VK_DEFINE_NONDISP_HANDLE_CASTS(vn_descriptor_update_template,
|
|||
VkDescriptorUpdateTemplate,
|
||||
VK_OBJECT_TYPE_DESCRIPTOR_UPDATE_TEMPLATE)
|
||||
|
||||
bool
|
||||
vn_should_sanitize_descriptor_set_writes(
|
||||
uint32_t write_count,
|
||||
const VkWriteDescriptorSet *writes,
|
||||
VkPipelineLayout pipeline_layout_handle);
|
||||
|
||||
struct vn_update_descriptor_sets *
|
||||
vn_update_descriptor_sets_parse_writes(
|
||||
uint32_t write_count,
|
||||
|
|
Loading…
Reference in New Issue