Skip to content
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
21 changes: 8 additions & 13 deletions layers/core_checks/cc_device_generated_commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -355,10 +355,6 @@ static bool IsShaderObjectIndirectBindable(const vvl::ShaderObject& shader_objec
return (shader_object.create_info_ext.flags & VK_SHADER_CREATE_INDIRECT_BINDABLE_BIT_EXT) != 0;
}

static const char* DescribeDescriptorMode([[maybe_unused]] const vvl::ShaderObject& shader_object, bool descriptor_heap) {
return descriptor_heap ? "with VK_SHADER_CREATE_DESCRIPTOR_HEAP_BIT_EXT" : "without VK_SHADER_CREATE_DESCRIPTOR_HEAP_BIT_EXT";
}

static std::string DescribeMissingIndirectBindable(const vvl::ShaderObject& shader_object) {
return "is missing VK_SHADER_CREATE_INDIRECT_BINDABLE_BIT_EXT, was created with flags " +
string_VkShaderCreateFlagsEXT(shader_object.create_info_ext.flags) + ".";
Expand Down Expand Up @@ -410,8 +406,8 @@ bool CoreChecks::ValidateIndirectExecutionSetShaderInfo(const VkIndirectExecutio
const LogObjectList objlist(shader_handle, first_mode_shader->Handle());
skip |= LogError(vuid, objlist, shader_info_loc.dot(Field::pInitialShaders, i),
"was created %s, but the first shader in pInitialShaders was created %s.",
DescribeDescriptorMode(*shader_object, shader_object->descriptor_heap_mode),
DescribeDescriptorMode(*first_mode_shader, first_mode_shader->descriptor_heap_mode));
shader_object->DescribeDescriptorMode(shader_object->descriptor_heap_mode),
first_mode_shader->DescribeDescriptorMode(first_mode_shader->descriptor_heap_mode));
descriptor_mode_same = false;
}

Expand Down Expand Up @@ -570,13 +566,13 @@ bool CoreChecks::ValidateGeneratedCommandsInfo(const vvl::CommandBuffer& cb_stat
info_loc.dot(Field::indirectCommandsLayout),
"contains an execution set token, but a VkPipelineLayout was not provided.\nHint: This is "
"only allowed if the shader object was created %s.",
DescribeDescriptorMode(initial_shader, true));
initial_shader.DescribeDescriptorMode(true));
} else if (has_layout && initial_shader.descriptor_heap_mode) {
skip |= LogError("VUID-VkGeneratedCommandsInfoEXT-indirectCommandsLayout-11331", cb_state.Handle(),
info_loc.dot(Field::indirectCommandsLayout),
"contains an execution set token and a VkPipelineLayout was provided, but shader object was "
"created %s.",
DescribeDescriptorMode(initial_shader, true));
initial_shader.DescribeDescriptorMode(true));
}
}
}
Expand Down Expand Up @@ -1362,11 +1358,10 @@ bool CoreChecks::PreCallValidateUpdateIndirectExecutionSetShaderEXT(VkDevice dev
? "VUID-vkUpdateIndirectExecutionSetShaderEXT-pInitialShaders-11327"
: "VUID-vkUpdateIndirectExecutionSetShaderEXT-pInitialShaders-11326";

skip |= LogError(vuid, objlist, set_write_loc.dot(Field::shader),
"was %screated with VK_SHADER_CREATE_DESCRIPTOR_HEAP_BIT_EXT, but pInitialShaders[0] "
"was %screated with VK_SHADER_CREATE_DESCRIPTOR_HEAP_BIT_EXT.",
update_shader_object->descriptor_heap_mode ? "" : "not ",
init_shader_object->descriptor_heap_mode ? "" : "not ");
skip |=
LogError(vuid, objlist, set_write_loc.dot(Field::shader), "was created %s, but pInitialShaders[0] was created %s.",
update_shader_object->DescribeDescriptorMode(update_shader_object->descriptor_heap_mode),
init_shader_object->DescribeDescriptorMode(init_shader_object->descriptor_heap_mode));
}
}

Expand Down
98 changes: 46 additions & 52 deletions layers/core_checks/cc_shader_object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "chassis/chassis_modification_state.h"
#include "core_validation.h"
#include "error_message/logging.h"
#include "error_message/error_strings.h"
#include "state_tracker/shader_object_state.h"
#include "state_tracker/shader_module.h"
#include "state_tracker/render_pass_state.h"
Expand Down Expand Up @@ -920,86 +921,79 @@ bool CoreChecks::ValidateDrawShaderObjectPushConstantAndLayout(const LastBound&
continue;
}

if (first->create_info_ext.pushConstantRangeCount != shader_state->create_info_ext.pushConstantRangeCount) {
const LogObjectList objlist(cb_state.Handle(), first->Handle(), shader_state->Handle());
skip |= LogError(CreateActionVuid(loc.function, vvl::ActionVUID::SHADERS_PUSH_CONSTANTS_08878), objlist, loc,
"The bound %s shader was created with a pushConstantRangeCount of %" PRIu32
" which doesn't match the bound %s shader created with a pushConstantRangeCount of %" PRIu32 "",
string_VkShaderStageFlagBits(first->GetStage()), first->create_info_ext.pushConstantRangeCount,
string_VkShaderStageFlagBits(shader_state->GetStage()),
shader_state->create_info_ext.pushConstantRangeCount);
} else {
for (uint32_t i = 0; i < shader_state->create_info_ext.pushConstantRangeCount; ++i) {
bool found = false; // find duplicate push constant ranges
for (uint32_t j = 0; j < first->create_info_ext.pushConstantRangeCount; ++j) {
if (shader_state->create_info_ext.pPushConstantRanges[i] == first->create_info_ext.pPushConstantRanges[j]) {
found = true;
break;
}
if (first->descriptor_heap_mode != shader_state->descriptor_heap_mode) {
const vvl::ShaderObject* heap_shader = first->descriptor_heap_mode ? first : shader_state;
const vvl::ShaderObject* non_heap_shader = first->descriptor_heap_mode ? shader_state : first;
const LogObjectList objlist(cb_state.Handle(), heap_shader->Handle(), non_heap_shader->Handle());
skip |=
LogError(CreateActionVuid(loc.function, vvl::ActionVUID::SHADERS_DESCRIPTOR_LAYOUTS_08879), objlist, loc,
"The bound %s shader uses descriptor heaps (created %s), but the bound %s shader uses a pipeline "
"layout (created %s).",
string_VkShaderStageFlagBits(heap_shader->GetStage()), heap_shader->DescribeDescriptorMode(true),
string_VkShaderStageFlagBits(non_heap_shader->GetStage()), non_heap_shader->DescribeDescriptorMode(false));
continue; // the push constant ranges and set layouts are not comparable
}

if (first->push_constant_ranges != shader_state->push_constant_ranges) {
std::ostringstream ss;
const vvl::ShaderObject* shaders[2] = {first, shader_state};
for (const vvl::ShaderObject* shader : shaders) {
ss << "\nThe " << string_VkShaderStageFlagBits(shader->GetStage()) << " shader (" << shader->LayoutStructName()
<< "::pPushConstantRanges):";
if (shader->push_constant_ranges->empty()) {
ss << "\n - (none)";
}
if (!found) {
const LogObjectList objlist(cb_state.Handle(), first->Handle(), shader_state->Handle());
skip |= LogError(CreateActionVuid(loc.function, vvl::ActionVUID::SHADERS_PUSH_CONSTANTS_08878), objlist, loc,
"The bound %s and %s shader have different push constant ranges.",
string_VkShaderStageFlagBits(first->GetStage()),
string_VkShaderStageFlagBits(shader_state->GetStage()));
break;
for (const VkPushConstantRange& range : *shader->push_constant_ranges) {
ss << "\n - " << string_VkPushConstantRange(range);
}
}
const LogObjectList objlist(cb_state.Handle(), first->Handle(), shader_state->Handle());
skip |= LogError(CreateActionVuid(loc.function, vvl::ActionVUID::SHADERS_PUSH_CONSTANTS_08878), objlist, loc,
"The bound %s and %s shader were created with different push constant ranges.%s\n",
string_VkShaderStageFlagBits(first->GetStage()),
string_VkShaderStageFlagBits(shader_state->GetStage()), ss.str().c_str());
}

// 13361 ensure both shader objects have INDEPENDENT_SETS
const bool has_independent_sets = first->is_independent_set;

if (first->create_info_ext.setLayoutCount != shader_state->create_info_ext.setLayoutCount && !has_independent_sets) {
const auto& first_set_layouts = first->set_layouts.list;
const auto& current_set_layouts = shader_state->set_layouts.list;
if (first_set_layouts.size() != current_set_layouts.size() && !has_independent_sets) {
const LogObjectList objlist(cb_state.Handle(), first->Handle(), shader_state->Handle());
skip |= LogError(CreateActionVuid(loc.function, vvl::ActionVUID::SHADERS_DESCRIPTOR_LAYOUTS_08879), objlist, loc,
"The bound %s shader was created with a setLayoutCount of %" PRIu32
" which doesn't match the bound %s shader created with a setLayoutCount of %" PRIu32,
string_VkShaderStageFlagBits(first->GetStage()), first->create_info_ext.setLayoutCount,
string_VkShaderStageFlagBits(shader_state->GetStage()), shader_state->create_info_ext.setLayoutCount);
"The bound %s shader was created with %s::setLayoutCount of %zu which doesn't match the bound %s "
"shader created with %s::setLayoutCount of %zu",
string_VkShaderStageFlagBits(first->GetStage()), first->LayoutStructName(), first_set_layouts.size(),
string_VkShaderStageFlagBits(shader_state->GetStage()), shader_state->LayoutStructName(),
current_set_layouts.size());
} else {
// with independent sets, could have different counts
// https://gitlab.khronos.org/vulkan/vulkan/-/issues/4812
const uint32_t set_layout_count =
std::min(first->create_info_ext.setLayoutCount, shader_state->create_info_ext.setLayoutCount);
const size_t set_layout_count = std::min(first_set_layouts.size(), current_set_layouts.size());

for (uint32_t i = 0; i < set_layout_count; ++i) {
const auto first_layout = Get<vvl::DescriptorSetLayout>(first->create_info_ext.pSetLayouts[i]);
const auto current_layout = Get<vvl::DescriptorSetLayout>(shader_state->create_info_ext.pSetLayouts[i]);
for (size_t i = 0; i < set_layout_count; ++i) {
const auto& first_layout = first_set_layouts[i];
const auto& current_layout = current_set_layouts[i];
if (!first_layout || !current_layout) {
// Can be NULL if using VK_SHADER_CREATE_INDEPENDENT_SETS_BIT_KHR
// Can be NULL if using independent sets
// Otherwise will be caught in 13359/13360
continue;
}
if (std::string err_msg; !VerifyDescriptorSetLayoutIsCompatibile(*first_layout, *current_layout, err_msg)) {
const LogObjectList objlist(cb_state.Handle(), first_layout->Handle(), current_layout->Handle());
const char* hint =
"\nHint: If using VK_SHADER_CREATE_INDEPENDENT_SETS_BIT_KHR make sure to use VK_NULL_HANDLE for the "
"VkShaderCreateInfoEXT::pSetLayouts not being used by the stage.";
"\nHint: With independent sets, use VK_NULL_HANDLE in pSetLayouts for the sets not used by the stage.";
skip |= LogError(
CreateActionVuid(loc.function, vvl::ActionVUID::SHADERS_DESCRIPTOR_LAYOUTS_08879), objlist, loc,
"The bound %s and %s shader are incompatible due to differently defined VkDescriptorSetLayouts.\n%s%s",
string_VkShaderStageFlagBits(first->GetStage()), string_VkShaderStageFlagBits(shader_state->GetStage()),
"The bound %s and %s shader are incompatible due to differently defined "
"VkDescriptorSetLayouts at set %zu.\n%s%s",
string_VkShaderStageFlagBits(first->GetStage()), string_VkShaderStageFlagBits(shader_state->GetStage()), i,
err_msg.c_str(), has_independent_sets ? hint : "");
break;
}
}
}

if ((first->create_info_ext.flags & VK_SHADER_CREATE_DESCRIPTOR_HEAP_BIT_EXT) !=
(shader_state->create_info_ext.flags & VK_SHADER_CREATE_DESCRIPTOR_HEAP_BIT_EXT)) {
const vvl::ShaderObject* heap_shader =
(first->create_info_ext.flags & VK_SHADER_CREATE_DESCRIPTOR_HEAP_BIT_EXT) ? first : shader_state;
const vvl::ShaderObject* non_heap_shader =
(first->create_info_ext.flags & VK_SHADER_CREATE_DESCRIPTOR_HEAP_BIT_EXT) ? shader_state : first;
const LogObjectList objlist(cb_state.Handle(), heap_shader->Handle(), non_heap_shader->Handle());
skip |= LogError(CreateActionVuid(loc.function, vvl::ActionVUID::SHADERS_DESCRIPTOR_LAYOUTS_08879), objlist, loc,
"The bound %s shader was created with VK_SHADER_CREATE_DESCRIPTOR_HEAP_BIT_EXT, but the bound %s "
"shader was created without VK_SHADER_CREATE_DESCRIPTOR_HEAP_BIT_EXT",
string_VkShaderStageFlagBits(heap_shader->GetStage()),
string_VkShaderStageFlagBits(non_heap_shader->GetStage()));
}
}

return skip;
Expand Down
4 changes: 4 additions & 0 deletions layers/state_tracker/shader_object_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,8 @@ void ShaderObject::Destroy() {
StateObject::Destroy();
}

const char* ShaderObject::DescribeDescriptorMode(bool descriptor_heap) const {
return descriptor_heap ? "with VK_SHADER_CREATE_DESCRIPTOR_HEAP_BIT_EXT" : "without VK_SHADER_CREATE_DESCRIPTOR_HEAP_BIT_EXT";
}

} // namespace vvl
3 changes: 3 additions & 0 deletions layers/state_tracker/shader_object_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ struct ShaderObject : public StateObject, public SubStateManager<ShaderObjectSub
VkShaderEXT VkHandle() const { return handle_.Cast<VkShaderEXT>(); }
bool IsGraphicsShaderState() const { return GetStage() != VK_SHADER_STAGE_COMPUTE_BIT; };
VkShaderStageFlagBits GetStage() const { return stage.GetStage(); }

const char* DescribeDescriptorMode(bool descriptor_heap) const;
const char* LayoutStructName() const { return "VkShaderCreateInfoEXT"; }
};

class ShaderObjectSubState {
Expand Down
32 changes: 20 additions & 12 deletions layers/stateless/sl_pipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,7 @@ bool Device::manual_PreCallValidateCreatePipelineLayout(VkDevice device, const V
bool skip = false;
const auto& error_obj = context.error_obj;
const Location create_info_loc = error_obj.location.dot(Field::pCreateInfo);
if (pCreateInfo->setLayoutCount > phys_dev_props.limits.maxBoundDescriptorSets) {
skip |= LogError("VUID-VkPipelineLayoutCreateInfo-setLayoutCount-00286", device, create_info_loc.dot(Field::setLayoutCount),
"(%" PRIu32 ") exceeds the maxBoundDescriptorSets limit (%" PRIu32 ").", pCreateInfo->setLayoutCount,
phys_dev_props.limits.maxBoundDescriptorSets);
}
skip |= ValidatePipelineLayoutCreateInfo(*pCreateInfo, create_info_loc);

if (!IsExtEnabled(extensions.vk_ext_graphics_pipeline_library)) {
for (uint32_t i = 0; i < pCreateInfo->setLayoutCount; ++i) {
Expand All @@ -71,14 +67,26 @@ bool Device::manual_PreCallValidateCreatePipelineLayout(VkDevice device, const V
}
}

if (pCreateInfo->flags & VK_PIPELINE_LAYOUT_CREATE_NO_TASK_SHADER_BIT_KHR &&
!(pCreateInfo->flags & VK_PIPELINE_LAYOUT_CREATE_INDEPENDENT_SETS_BIT_EXT)) {
return skip;
}

bool Device::ValidatePipelineLayoutCreateInfo(const VkPipelineLayoutCreateInfo& create_info,
const Location& create_info_loc) const {
bool skip = false;
if (create_info.setLayoutCount > phys_dev_props.limits.maxBoundDescriptorSets) {
skip |= LogError("VUID-VkPipelineLayoutCreateInfo-setLayoutCount-00286", device, create_info_loc.dot(Field::setLayoutCount),
"(%" PRIu32 ") exceeds the maxBoundDescriptorSets limit (%" PRIu32 ").", create_info.setLayoutCount,
phys_dev_props.limits.maxBoundDescriptorSets);
}

if (create_info.flags & VK_PIPELINE_LAYOUT_CREATE_NO_TASK_SHADER_BIT_KHR &&
!(create_info.flags & VK_PIPELINE_LAYOUT_CREATE_INDEPENDENT_SETS_BIT_EXT)) {
skip |= LogError("VUID-VkPipelineLayoutCreateInfo-flags-13352", device, create_info_loc.dot(Field::flags),
"is %s and does not include VK_PIPELINE_LAYOUT_CREATE_INDEPENDENT_SETS_BIT_EXT.",
string_VkPipelineLayoutCreateFlags(pCreateInfo->flags).c_str());
string_VkPipelineLayoutCreateFlags(create_info.flags).c_str());
}

skip |= ValidatePushConstantRange(pCreateInfo->pushConstantRangeCount, pCreateInfo->pPushConstantRanges, create_info_loc);
skip |= ValidatePushConstantRange(create_info.pushConstantRangeCount, create_info.pPushConstantRanges, create_info_loc);

return skip;
}
Expand Down Expand Up @@ -126,9 +134,9 @@ bool Device::ValidatePushConstantRange(uint32_t push_constant_range_count, const
for (uint32_t i = 0; i < push_constant_range_count; ++i) {
for (uint32_t j = i + 1; j < push_constant_range_count; ++j) {
if (0 != (push_constant_ranges[i].stageFlags & push_constant_ranges[j].stageFlags)) {
const char* vuid = loc.function == Func::vkCreatePipelineLayout
? "VUID-VkPipelineLayoutCreateInfo-pPushConstantRanges-00292"
: "VUID-VkShaderCreateInfoEXT-pPushConstantRanges-10063";
const char* vuid = loc.function == Func::vkCreateShadersEXT
? "VUID-VkShaderCreateInfoEXT-pPushConstantRanges-10063"
: "VUID-VkPipelineLayoutCreateInfo-pPushConstantRanges-00292";
skip |= LogError(
vuid, device, loc,
"pPushConstantRanges[%" PRIu32 "].stageFlags (%s) and pPushConstantRanges[%" PRIu32
Expand Down
1 change: 1 addition & 0 deletions layers/stateless/stateless_validation.h
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,7 @@ class Device : public vvl::BaseDevice {
bool manual_PreCallValidateCreatePipelineLayout(VkDevice device, const VkPipelineLayoutCreateInfo *pCreateInfo,
const VkAllocationCallbacks *pAllocator, VkPipelineLayout *pPipelineLayout,
const Context &context) const;
bool ValidatePipelineLayoutCreateInfo(const VkPipelineLayoutCreateInfo& create_info, const Location& create_info_loc) const;
bool ValidatePushConstantRange(uint32_t push_constant_range_count, const VkPushConstantRange *push_constant_ranges,
const Location &loc) const;

Expand Down
1 change: 1 addition & 0 deletions scripts/generators/spirv_validation_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def __init__(self, grammar):
for enum in kind['enumerants']:
if not IsNonVulkanSprivCapability(enum['enumerant']):
self.capabilityList.append(enum['enumerant'])
self.capabilityList.extend(enum.get('aliases', []))
if 'provisional' in enum:
self.provisionalList.append(enum['enumerant'])
break
Expand Down
Loading
Loading