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

layers: Remove callback for image layout #8917

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
8 changes: 0 additions & 8 deletions layers/core_checks/cc_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,14 +343,6 @@ void CoreChecks::PostCreateDevice(const VkDeviceCreateInfo *pCreateInfo, const L
// The state tracker sets up the device state (also if extension and/or features are enabled)
StateTracker::PostCreateDevice(pCreateInfo, loc);

// Add the callback hooks for the functions that are either broadly or deeply used and that the ValidationStateTracker refactor
// would be messier without.
// TODO: Find a good way to do this hooklessly.
SetSetImageViewInitialLayoutCallback(
[](vvl::CommandBuffer *cb_state, const vvl::ImageView &iv_state, VkImageLayout layout) -> void {
cb_state->SetImageViewInitialLayout(iv_state, layout);
});

AdjustValidatorOptions(device_extensions, enabled_features, spirv_val_options, &spirv_val_option_hash);

// Allocate shader validation cache
Expand Down
4 changes: 2 additions & 2 deletions layers/drawdispatch/descriptor_validator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,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(&dev_state, cb_state);
}
skip |= ValidateDescriptorsDynamic(binding_info, imgs_binding, indices);
break;
Expand All @@ -169,7 +169,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(&dev_state, cb_state);
}
skip |= ValidateDescriptorsDynamic(binding_info, img_binding, indices);
break;
Expand Down
8 changes: 0 additions & 8 deletions layers/gpu/core/gpuav_setup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -384,14 +384,6 @@ void Validator::PostCreateDevice(const VkDeviceCreateInfo *pCreateInfo, const Lo
return;
}

// Add the callback hooks for the functions that are either broadly or deeply used and that the ValidationStateTracker refactor
// would be messier without.
// TODO: Find a good way to do this hooklessly.
SetSetImageViewInitialLayoutCallback(
[](vvl::CommandBuffer *cb_state, const vvl::ImageView &iv_state, VkImageLayout layout) -> void {
cb_state->SetImageViewInitialLayout(iv_state, layout);
});

// Set up a stub implementation of the descriptor heap in case we abort.
desc_heap_.emplace(*this, 0, loc);

Expand Down
2 changes: 1 addition & 1 deletion layers/state_tracker/cmd_buffer_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1242,7 +1242,7 @@ void CommandBuffer::UpdatePipelineState(Func command, const VkPipelineBindPoint
}

// Bind this set and its active descriptor resources to the command buffer
descriptor_set->UpdateDrawState(&dev_data, this, command, pipe, set_binding_pair.second);
descriptor_set->UpdateDrawStates(&dev_data, *this, set_binding_pair.second);

set_info.validated_set = descriptor_set.get();
set_info.validated_set_change_count = descriptor_set->GetChangeCount();
Expand Down
12 changes: 6 additions & 6 deletions layers/state_tracker/descriptor_sets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -687,8 +687,8 @@ void vvl::DescriptorSet::PerformCopyUpdate(const VkCopyDescriptorSet &update, co
// TODO: Modify the UpdateDrawState virtural functions to *only* set initial layout and not change layouts
// Prereq: This should be called for a set that has been confirmed to be active for the given cb_state, meaning it's going
// to be used in a draw by the given cb_state
void vvl::DescriptorSet::UpdateDrawState(ValidationStateTracker *device_data, vvl::CommandBuffer *cb_state, vvl::Func command,
const vvl::Pipeline *pipe, const BindingVariableMap &binding_req_map) {
void vvl::DescriptorSet::UpdateDrawStates(ValidationStateTracker *device_data, vvl::CommandBuffer &cb_state,
const BindingVariableMap &binding_req_map) {
// Descriptor UpdateDrawState only call image layout validation callbacks. If it is disabled, skip the entire loop.
if (device_data->disabled[image_layout_validation]) {
return;
Expand Down Expand Up @@ -873,11 +873,11 @@ 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(ValidationStateTracker *dev_data, vvl::CommandBuffer &cb_state) {
// Add binding for image
auto iv_state = GetImageViewState();
if (iv_state) {
dev_data->CallSetImageViewInitialLayoutCallback(cb_state, *iv_state, image_layout_);
cb_state.SetImageViewInitialLayout(*iv_state, image_layout_);
}
}

Expand Down Expand Up @@ -1301,11 +1301,11 @@ VkDeviceSize vvl::MutableDescriptor::GetEffectiveRange() const {
}
}

void vvl::MutableDescriptor::UpdateDrawState(ValidationStateTracker *dev_data, vvl::CommandBuffer *cb_state) {
void vvl::MutableDescriptor::UpdateDrawState(ValidationStateTracker *dev_data, vvl::CommandBuffer &cb_state) {
auto active_class = DescriptorTypeToClass(active_descriptor_type_);
if (active_class == DescriptorClass::Image || active_class == DescriptorClass::ImageSampler) {
if (image_view_state_) {
dev_data->CallSetImageViewInitialLayoutCallback(cb_state, *image_view_state_, image_layout_);
cb_state.SetImageViewInitialLayout(*image_view_state_, image_layout_);
}
}
}
Expand Down
7 changes: 3 additions & 4 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(ValidationStateTracker *, 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 @@ -614,7 +614,7 @@ class MutableDescriptor : public Descriptor {
return acc_khr != VK_NULL_HANDLE;
}

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

bool AddParent(StateObject *state_object) override;
void RemoveParent(StateObject *state_object) override;
Expand Down Expand Up @@ -828,8 +828,7 @@ class DescriptorSet : public StateObject {
VkDescriptorSet VkHandle() const { return handle_.Cast<VkDescriptorSet>(); };
// Bind given cmd_buffer to this descriptor set and
// update CB image layout map with image/imagesampler descriptor image layouts
void UpdateDrawState(ValidationStateTracker *, vvl::CommandBuffer *cb_state, vvl::Func command, const vvl::Pipeline *,
const BindingVariableMap &);
void UpdateDrawStates(ValidationStateTracker *, vvl::CommandBuffer &cb_state, const BindingVariableMap &);

// For a particular binding, get the global index
const IndexRange GetGlobalIndexRangeFromBinding(const uint32_t binding, bool actual_length = false) const {
Expand Down
14 changes: 0 additions & 14 deletions layers/state_tracker/state_tracker.h
Original file line number Diff line number Diff line change
Expand Up @@ -437,18 +437,6 @@ class ValidationStateTracker : public ValidationObject {
return {written_count, buffer_address_map_.size()};
}

using SetImageViewInitialLayoutCallback = std::function<void(vvl::CommandBuffer*, const vvl::ImageView&, VkImageLayout)>;
template <typename Fn>
void SetSetImageViewInitialLayoutCallback(Fn&& fn) {
set_image_view_initial_layout_callback.reset(new SetImageViewInitialLayoutCallback(std::forward<Fn>(fn)));
}

void CallSetImageViewInitialLayoutCallback(vvl::CommandBuffer* cb_state, const vvl::ImageView& iv_state, VkImageLayout layout) {
if (set_image_view_initial_layout_callback) {
(*set_image_view_initial_layout_callback)(cb_state, iv_state, layout);
}
}

VkDeviceSize AllocFakeMemory(VkDeviceSize size) { return fake_memory.Alloc(size); }
void FreeFakeMemory(VkDeviceSize address) { fake_memory.Free(address); }

Expand Down Expand Up @@ -1788,8 +1776,6 @@ class ValidationStateTracker : public ValidationObject {
// Link for derived device objects back to their parent instance object
ValidationStateTracker* instance_state;

std::unique_ptr<SetImageViewInitialLayoutCallback> set_image_view_initial_layout_callback;

DeviceFeatures enabled_features = {};
// Device specific data
VkPhysicalDeviceMemoryProperties phys_dev_mem_props = {};
Expand Down