Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gpu: Reduce post processing already done on CPU #8923

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions layers/drawdispatch/descriptor_validator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,15 @@ bool DescriptorValidator::ValidateBindingDynamic(const DescriptorBindingInfo &bi
auto binding_ptr = descriptor_set.GetBinding(binding_info.first);
ASSERT_AND_RETURN_SKIP(binding_ptr);
auto &binding = *binding_ptr;

// If we already validated/updated the descriptor on the CPU, no reason to redo on the Post Processing of GPU-AV.
// There is no descriptor aliasing on the CPU, so we automatically know it needs Post Processing
if (binding_info.second.size() == 1) {
if (!descriptor_set.ValidateBindingOnGPU(binding, binding_info.second[0].variable->is_dynamic_accessed)) {
return skip;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the main change, it will now not re-run the checks/updates on the GPU-AV post process if it was done on the CPU

}
}

switch (binding.descriptor_class) {
case DescriptorClass::GeneralBuffer:
skip |= ValidateDescriptorsDynamic(binding_info, static_cast<const BufferBinding &>(binding), indices);
Expand All @@ -160,7 +169,7 @@ bool DescriptorValidator::ValidateBindingDynamic(const DescriptorBindingInfo &bi
auto &imgs_binding = static_cast<ImageSamplerBinding &>(binding);
for (auto index : indices) {
auto &descriptor = imgs_binding.descriptors[index];
descriptor.UpdateDrawState(&dev_state, cb_state);
descriptor.UpdateDrawState(cb_state);
}
skip |= ValidateDescriptorsDynamic(binding_info, imgs_binding, indices);
break;
Expand All @@ -169,7 +178,7 @@ bool DescriptorValidator::ValidateBindingDynamic(const DescriptorBindingInfo &bi
auto &img_binding = static_cast<ImageBinding &>(binding);
for (auto index : indices) {
auto &descriptor = img_binding.descriptors[index];
descriptor.UpdateDrawState(&dev_state, cb_state);
descriptor.UpdateDrawState(cb_state);
}
skip |= ValidateDescriptorsDynamic(binding_info, img_binding, indices);
break;
Expand Down Expand Up @@ -307,6 +316,10 @@ bool DescriptorValidator::ValidateDescriptor(const DescriptorBindingInfo &bindin

if (image_descriptor.GetClass() == DescriptorClass::ImageSampler) {
sampler_states.emplace_back(static_cast<const ImageSamplerDescriptor &>(image_descriptor).GetSamplerState());
} else if (is_gpu_av) {
// TODO - This will skip for GPU-AV because we don't currently capture array of samplers with array of sampled images
// https://github.com/KhronosGroup/Vulkan-ValidationLayers/issues/8922
// To not give false positve, we will skip all Sampler related checks since sampler_states will be empty
} else {
for (const auto &req : binding_info.second) {
if (!req.variable || req.variable->samplers_used_by_image.size() <= index) {
Expand Down
10 changes: 5 additions & 5 deletions layers/state_tracker/descriptor_sets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -708,21 +708,21 @@ void vvl::DescriptorSet::UpdateDrawStates(ValidationStateTracker *device_data, v
case DescriptorClass::Image: {
auto *image_binding = static_cast<ImageBinding *>(binding);
for (uint32_t i = 0; i < image_binding->count; ++i) {
image_binding->descriptors[i].UpdateDrawState(device_data, cb_state);
image_binding->descriptors[i].UpdateDrawState(cb_state);
}
break;
}
case DescriptorClass::ImageSampler: {
auto *image_binding = static_cast<ImageSamplerBinding *>(binding);
for (uint32_t i = 0; i < image_binding->count; ++i) {
image_binding->descriptors[i].UpdateDrawState(device_data, cb_state);
image_binding->descriptors[i].UpdateDrawState(cb_state);
}
break;
}
case DescriptorClass::Mutable: {
auto *mutable_binding = static_cast<MutableBinding *>(binding);
for (uint32_t i = 0; i < mutable_binding->count; ++i) {
mutable_binding->descriptors[i].UpdateDrawState(device_data, cb_state);
mutable_binding->descriptors[i].UpdateDrawState(cb_state);
}
break;
}
Expand Down Expand Up @@ -873,7 +873,7 @@ void vvl::ImageDescriptor::CopyUpdate(DescriptorSet &set_state, const Validation
UpdateKnownValidView(is_bindless);
}

void vvl::ImageDescriptor::UpdateDrawState(ValidationStateTracker *dev_data, vvl::CommandBuffer &cb_state) {
void vvl::ImageDescriptor::UpdateDrawState(vvl::CommandBuffer &cb_state) {
// Add binding for image
auto iv_state = GetImageViewState();
if (iv_state) {
Expand Down Expand Up @@ -1276,7 +1276,7 @@ VkDeviceSize vvl::MutableDescriptor::GetEffectiveRange() const {
}
}

void vvl::MutableDescriptor::UpdateDrawState(ValidationStateTracker *dev_data, vvl::CommandBuffer &cb_state) {
void vvl::MutableDescriptor::UpdateDrawState(vvl::CommandBuffer &cb_state) {
const vvl::DescriptorClass active_class = ActiveClass();
if (active_class == DescriptorClass::Image || active_class == DescriptorClass::ImageSampler) {
if (image_view_state_) {
Expand Down
4 changes: 2 additions & 2 deletions layers/state_tracker/descriptor_sets.h
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ class ImageDescriptor : public Descriptor {
bool is_bindless) override;
void CopyUpdate(DescriptorSet &set_state, const ValidationStateTracker &dev_data, const Descriptor &, bool is_bindless,
VkDescriptorType type) override;
void UpdateDrawState(ValidationStateTracker *, vvl::CommandBuffer &cb_state);
void UpdateDrawState(vvl::CommandBuffer &cb_state);
VkImageView GetImageView() const;
const vvl::ImageView *GetImageViewState() const { return image_view_state_.get(); }
vvl::ImageView *GetImageViewState() { return image_view_state_.get(); }
Expand Down Expand Up @@ -613,7 +613,7 @@ class MutableDescriptor : public Descriptor {
return acc_khr != VK_NULL_HANDLE;
}

void UpdateDrawState(ValidationStateTracker *, vvl::CommandBuffer &cb_state);
void UpdateDrawState(vvl::CommandBuffer &cb_state);

bool AddParent(StateObject *state_object) override;
void RemoveParent(StateObject *state_object) override;
Expand Down
Loading