diff options
| author | Jeremy Hayes <jeremy@lunarg.com> | 2016-12-12 11:01:28 -0700 |
|---|---|---|
| committer | Jeremy Hayes <jeremy-lunarg@users.noreply.github.com> | 2017-01-09 16:36:44 -0700 |
| commit | 00d2c2dd004bff400641e40ce72df3deb08af78b (patch) | |
| tree | c55d81a79d92affede6a0bcdd3e94405bf770594 /layers/core_validation.cpp | |
| parent | 62d1cf764989653de49f779901404b4752e26188 (diff) | |
| download | usermoji-00d2c2dd004bff400641e40ce72df3deb08af78b.tar.xz | |
layers: Update valid usage for Jira VL-59.
Change-Id: I9aba0480aad5b565eb59f642def7a11e46822566
Diffstat (limited to 'layers/core_validation.cpp')
| -rw-r--r-- | layers/core_validation.cpp | 83 |
1 files changed, 46 insertions, 37 deletions
diff --git a/layers/core_validation.cpp b/layers/core_validation.cpp index 77dd6a45..c92171b9 100644 --- a/layers/core_validation.cpp +++ b/layers/core_validation.cpp @@ -1,7 +1,7 @@ -/* Copyright (c) 2015-2016 The Khronos Group Inc. - * Copyright (c) 2015-2016 Valve Corporation - * Copyright (c) 2015-2016 LunarG, Inc. - * Copyright (C) 2015-2016 Google Inc. +/* Copyright (c) 2015-2017 The Khronos Group Inc. + * Copyright (c) 2015-2017 Valve Corporation + * Copyright (c) 2015-2017 LunarG, Inc. + * Copyright (C) 2015-2017 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -763,6 +763,7 @@ bool ValidateMemoryIsBoundToBuffer(const layer_data *dev_data, const BUFFER_STAT // IF a previous binding existed, output validation error // Otherwise, add reference from objectInfo to memoryInfo // Add reference off of objInfo +// TODO: We may need to refactor or pass in multiple valid usage statements to handle multiple valid usage conditions. static bool SetMemBinding(layer_data *dev_data, VkDeviceMemory mem, uint64_t handle, VkDebugReportObjectTypeEXT type, const char *apiName) { bool skip_call = false; @@ -781,6 +782,7 @@ static bool SetMemBinding(layer_data *dev_data, VkDeviceMemory mem, uint64_t han if (mem_info) { DEVICE_MEM_INFO *prev_binding = getMemObjInfo(dev_data, mem_binding->binding.mem); if (prev_binding) { + // TODO: VALIDATION_ERROR_00791 and VALIDATION_ERROR_00803 skip_call |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_MEMORY_EXT, reinterpret_cast<uint64_t &>(mem), __LINE__, MEMTRACK_REBIND_OBJECT, "MEM", @@ -1735,6 +1737,7 @@ static bool validate_vi_consistency(debug_report_data *report_data, VkPipelineVe auto desc = &vi->pVertexBindingDescriptions[i]; auto &binding = bindings[desc->binding]; if (binding) { + // TODO: VALIDATION_ERROR_02105 perhaps? if (log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VkDebugReportObjectTypeEXT(0), 0, __LINE__, SHADER_CHECKER_INCONSISTENT_VI, "SC", "Duplicate vertex input binding descriptions for binding %d", desc->binding)) { @@ -2098,11 +2101,12 @@ static bool hasDrawCmd(GLOBAL_CB_NODE *pCB) { // Check object status for selected flag state static bool validate_status(layer_data *my_data, GLOBAL_CB_NODE *pNode, CBStatusFlags status_mask, VkFlags msg_flags, - DRAW_STATE_ERROR error_code, const char *fail_msg) { + const char *fail_msg, UNIQUE_VALIDATION_ERROR_CODE const msg_code) { if (!(pNode->status & status_mask)) { + char const *const message = validation_error_map[msg_code]; return log_msg(my_data->report_data, msg_flags, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, - reinterpret_cast<const uint64_t &>(pNode->commandBuffer), __LINE__, error_code, "DS", - "command buffer object 0x%p: %s", pNode->commandBuffer, fail_msg); + reinterpret_cast<const uint64_t &>(pNode->commandBuffer), __LINE__, msg_code, "DS", + "command buffer object 0x%p: %s. %s.", pNode->commandBuffer, fail_msg, message); } return false; } @@ -2160,42 +2164,43 @@ static bool isDynamic(const PIPELINE_STATE *pPipeline, const VkDynamicState stat } // Validate state stored as flags at time of draw call -static bool validate_draw_state_flags(layer_data *dev_data, GLOBAL_CB_NODE *pCB, const PIPELINE_STATE *pPipe, bool indexed) { +static bool validate_draw_state_flags(layer_data *dev_data, GLOBAL_CB_NODE *pCB, const PIPELINE_STATE *pPipe, bool indexed, + UNIQUE_VALIDATION_ERROR_CODE const msg_code) { bool result = false; if (pPipe->graphicsPipelineCI.pInputAssemblyState && ((pPipe->graphicsPipelineCI.pInputAssemblyState->topology == VK_PRIMITIVE_TOPOLOGY_LINE_LIST) || (pPipe->graphicsPipelineCI.pInputAssemblyState->topology == VK_PRIMITIVE_TOPOLOGY_LINE_STRIP))) { result |= validate_status(dev_data, pCB, CBSTATUS_LINE_WIDTH_SET, VK_DEBUG_REPORT_ERROR_BIT_EXT, - DRAWSTATE_LINE_WIDTH_NOT_BOUND, "Dynamic line width state not set for this command buffer"); + "Dynamic line width state not set for this command buffer", msg_code); } if (pPipe->graphicsPipelineCI.pRasterizationState && (pPipe->graphicsPipelineCI.pRasterizationState->depthBiasEnable == VK_TRUE)) { result |= validate_status(dev_data, pCB, CBSTATUS_DEPTH_BIAS_SET, VK_DEBUG_REPORT_ERROR_BIT_EXT, - DRAWSTATE_DEPTH_BIAS_NOT_BOUND, "Dynamic depth bias state not set for this command buffer"); + "Dynamic depth bias state not set for this command buffer", msg_code); } if (pPipe->blendConstantsEnabled) { result |= validate_status(dev_data, pCB, CBSTATUS_BLEND_CONSTANTS_SET, VK_DEBUG_REPORT_ERROR_BIT_EXT, - DRAWSTATE_BLEND_NOT_BOUND, "Dynamic blend constants state not set for this command buffer"); + "Dynamic blend constants state not set for this command buffer", msg_code); } if (pPipe->graphicsPipelineCI.pDepthStencilState && (pPipe->graphicsPipelineCI.pDepthStencilState->depthBoundsTestEnable == VK_TRUE)) { result |= validate_status(dev_data, pCB, CBSTATUS_DEPTH_BOUNDS_SET, VK_DEBUG_REPORT_ERROR_BIT_EXT, - DRAWSTATE_DEPTH_BOUNDS_NOT_BOUND, "Dynamic depth bounds state not set for this command buffer"); + "Dynamic depth bounds state not set for this command buffer", msg_code); } if (pPipe->graphicsPipelineCI.pDepthStencilState && (pPipe->graphicsPipelineCI.pDepthStencilState->stencilTestEnable == VK_TRUE)) { result |= validate_status(dev_data, pCB, CBSTATUS_STENCIL_READ_MASK_SET, VK_DEBUG_REPORT_ERROR_BIT_EXT, - DRAWSTATE_STENCIL_NOT_BOUND, "Dynamic stencil read mask state not set for this command buffer"); + "Dynamic stencil read mask state not set for this command buffer", msg_code); result |= validate_status(dev_data, pCB, CBSTATUS_STENCIL_WRITE_MASK_SET, VK_DEBUG_REPORT_ERROR_BIT_EXT, - DRAWSTATE_STENCIL_NOT_BOUND, "Dynamic stencil write mask state not set for this command buffer"); + "Dynamic stencil write mask state not set for this command buffer", msg_code); result |= validate_status(dev_data, pCB, CBSTATUS_STENCIL_REFERENCE_SET, VK_DEBUG_REPORT_ERROR_BIT_EXT, - DRAWSTATE_STENCIL_NOT_BOUND, "Dynamic stencil reference state not set for this command buffer"); + "Dynamic stencil reference state not set for this command buffer", msg_code); } if (indexed) { result |= validate_status(dev_data, pCB, CBSTATUS_INDEX_BUFFER_BOUND, VK_DEBUG_REPORT_ERROR_BIT_EXT, - DRAWSTATE_INDEX_BUFFER_NOT_BOUND, - "Index buffer object not bound to this command buffer when Indexed Draw attempted"); + "Index buffer object not bound to this command buffer when Indexed Draw attempted", msg_code); } + return result; } @@ -2327,14 +2332,16 @@ static bool validate_specialization_offsets(debug_report_data *report_data, VkPi if (spec) { for (auto i = 0u; i < spec->mapEntryCount; i++) { + // TODO: This is a good place for VALIDATION_ERROR_00589. if (spec->pMapEntries[i].offset + spec->pMapEntries[i].size > spec->dataSize) { - if (log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, - 0, __LINE__, SHADER_CHECKER_BAD_SPECIALIZATION, "SC", + if (log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, 0, __LINE__, + VALIDATION_ERROR_00590, "SC", "Specialization entry %u (for constant id %u) references memory outside provided " "specialization data (bytes %u.." PRINTF_SIZE_T_SPECIFIER "; " PRINTF_SIZE_T_SPECIFIER - " bytes provided)", + " bytes provided). %s.", i, spec->pMapEntries[i].constantID, spec->pMapEntries[i].offset, - spec->pMapEntries[i].offset + spec->pMapEntries[i].size - 1, spec->dataSize)) { + spec->pMapEntries[i].offset + spec->pMapEntries[i].size - 1, spec->dataSize, + validation_error_map[VALIDATION_ERROR_00590])) { pass = false; } @@ -2628,10 +2635,9 @@ validate_pipeline_shader_stage(debug_report_data *report_data, VkPipelineShaderS // Find the entrypoint auto entrypoint = *out_entrypoint = find_entrypoint(module, pStage->pName, pStage->stage); if (entrypoint == module->end()) { - if (log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VkDebugReportObjectTypeEXT(0), 0, - __LINE__, SHADER_CHECKER_MISSING_ENTRYPOINT, "SC", - "No entrypoint found named `%s` for stage %s", pStage->pName, - string_VkShaderStageFlagBits(pStage->stage))) { + if (log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VkDebugReportObjectTypeEXT(0), 0, __LINE__, VALIDATION_ERROR_00510, + "SC", "No entrypoint found named `%s` for stage %s. %s.", pStage->pName, + string_VkShaderStageFlagBits(pStage->stage), validation_error_map[VALIDATION_ERROR_00510])) { return false; // no point continuing beyond here, any analysis is just going to be garbage. } } @@ -2993,7 +2999,8 @@ static bool ValidatePipelineDrawtimeState(layer_data const *my_data, LAST_BOUND_ // Validate overall state at the time of a draw call static bool ValidateDrawState(layer_data *my_data, GLOBAL_CB_NODE *cb_node, const bool indexed, - const VkPipelineBindPoint bind_point, const char *function) { + const VkPipelineBindPoint bind_point, const char *function, + UNIQUE_VALIDATION_ERROR_CODE const msg_code) { bool result = false; auto const &state = cb_node->lastBound[bind_point]; PIPELINE_STATE *pPipe = state.pipeline_state; @@ -3008,7 +3015,7 @@ static bool ValidateDrawState(layer_data *my_data, GLOBAL_CB_NODE *cb_node, cons } // First check flag states if (VK_PIPELINE_BIND_POINT_GRAPHICS == bind_point) - result = validate_draw_state_flags(my_data, cb_node, pPipe, indexed); + result = validate_draw_state_flags(my_data, cb_node, pPipe, indexed, msg_code); // Now complete other state checks if (VK_NULL_HANDLE != state.pipeline_layout.layout) { @@ -7956,12 +7963,12 @@ static void MarkStoreImagesAndBuffersAsWritten(layer_data *dev_data, GLOBAL_CB_N // Generic function to handle validation for all CmdDraw* type functions static bool ValidateCmdDrawType(layer_data *dev_data, VkCommandBuffer cmd_buffer, bool indexed, VkPipelineBindPoint bind_point, CMD_TYPE cmd_type, GLOBAL_CB_NODE **cb_state, const char *caller, - UNIQUE_VALIDATION_ERROR_CODE msg_code) { + UNIQUE_VALIDATION_ERROR_CODE msg_code, UNIQUE_VALIDATION_ERROR_CODE const dynamic_state_msg_code) { bool skip = false; *cb_state = getCBNode(dev_data, cmd_buffer); if (*cb_state) { skip |= ValidateCmd(dev_data, *cb_state, cmd_type, caller); - skip |= ValidateDrawState(dev_data, *cb_state, indexed, bind_point, caller); + skip |= ValidateDrawState(dev_data, *cb_state, indexed, bind_point, caller, dynamic_state_msg_code); skip |= (VK_PIPELINE_BIND_POINT_GRAPHICS == bind_point) ? outsideRenderPass(dev_data, *cb_state, caller, msg_code) : insideRenderPass(dev_data, *cb_state, caller, msg_code); } @@ -7986,7 +7993,8 @@ static void UpdateStateCmdDrawType(layer_data *dev_data, GLOBAL_CB_NODE *cb_stat static bool PreCallValidateCmdDraw(layer_data *dev_data, VkCommandBuffer cmd_buffer, bool indexed, VkPipelineBindPoint bind_point, GLOBAL_CB_NODE **cb_state, const char *caller) { - return ValidateCmdDrawType(dev_data, cmd_buffer, indexed, bind_point, CMD_DRAW, cb_state, caller, VALIDATION_ERROR_01365); + return ValidateCmdDrawType(dev_data, cmd_buffer, indexed, bind_point, CMD_DRAW, cb_state, caller, VALIDATION_ERROR_01365, + VALIDATION_ERROR_02203); } static void PostCallRecordCmdDraw(layer_data *dev_data, GLOBAL_CB_NODE *cb_state, VkPipelineBindPoint bind_point) { @@ -8010,8 +8018,8 @@ VKAPI_ATTR void VKAPI_CALL CmdDraw(VkCommandBuffer commandBuffer, uint32_t verte static bool PreCallValidateCmdDrawIndexed(layer_data *dev_data, VkCommandBuffer cmd_buffer, bool indexed, VkPipelineBindPoint bind_point, GLOBAL_CB_NODE **cb_state, const char *caller) { - return ValidateCmdDrawType(dev_data, cmd_buffer, indexed, bind_point, CMD_DRAWINDEXED, cb_state, caller, - VALIDATION_ERROR_01372); + return ValidateCmdDrawType(dev_data, cmd_buffer, indexed, bind_point, CMD_DRAWINDEXED, cb_state, caller, VALIDATION_ERROR_01372, + VALIDATION_ERROR_02216); } static void PostCallRecordCmdDrawIndexed(layer_data *dev_data, GLOBAL_CB_NODE *cb_state, VkPipelineBindPoint bind_point) { @@ -8038,8 +8046,8 @@ VKAPI_ATTR void VKAPI_CALL CmdDrawIndexed(VkCommandBuffer commandBuffer, uint32_ static bool PreCallValidateCmdDrawIndirect(layer_data *dev_data, VkCommandBuffer cmd_buffer, VkBuffer buffer, bool indexed, VkPipelineBindPoint bind_point, GLOBAL_CB_NODE **cb_state, BUFFER_STATE **buffer_state, const char *caller) { - bool skip = - ValidateCmdDrawType(dev_data, cmd_buffer, indexed, bind_point, CMD_DRAWINDIRECT, cb_state, caller, VALIDATION_ERROR_01381); + bool skip = ValidateCmdDrawType(dev_data, cmd_buffer, indexed, bind_point, CMD_DRAWINDIRECT, cb_state, caller, + VALIDATION_ERROR_01381, VALIDATION_ERROR_02234); *buffer_state = getBufferState(dev_data, buffer); skip |= ValidateMemoryIsBoundToBuffer(dev_data, *buffer_state, caller, VALIDATION_ERROR_02544); return skip; @@ -8072,7 +8080,7 @@ static bool PreCallValidateCmdDrawIndexedIndirect(layer_data *dev_data, VkComman VkPipelineBindPoint bind_point, GLOBAL_CB_NODE **cb_state, BUFFER_STATE **buffer_state, const char *caller) { bool skip = ValidateCmdDrawType(dev_data, cmd_buffer, indexed, bind_point, CMD_DRAWINDEXEDINDIRECT, cb_state, caller, - VALIDATION_ERROR_01393); + VALIDATION_ERROR_01393, VALIDATION_ERROR_02272); *buffer_state = getBufferState(dev_data, buffer); skip |= ValidateMemoryIsBoundToBuffer(dev_data, *buffer_state, caller, VALIDATION_ERROR_02545); return skip; @@ -8103,7 +8111,8 @@ CmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceS static bool PreCallValidateCmdDispatch(layer_data *dev_data, VkCommandBuffer cmd_buffer, bool indexed, VkPipelineBindPoint bind_point, GLOBAL_CB_NODE **cb_state, const char *caller) { - return ValidateCmdDrawType(dev_data, cmd_buffer, indexed, bind_point, CMD_DISPATCH, cb_state, caller, VALIDATION_ERROR_01562); + return ValidateCmdDrawType(dev_data, cmd_buffer, indexed, bind_point, CMD_DISPATCH, cb_state, caller, VALIDATION_ERROR_01562, + VALIDATION_ERROR_UNDEFINED); } static void PostCallRecordCmdDispatch(layer_data *dev_data, GLOBAL_CB_NODE *cb_state, VkPipelineBindPoint bind_point) { @@ -8129,7 +8138,7 @@ static bool PreCallValidateCmdDispatchIndirect(layer_data *dev_data, VkCommandBu VkPipelineBindPoint bind_point, GLOBAL_CB_NODE **cb_state, BUFFER_STATE **buffer_state, const char *caller) { bool skip = ValidateCmdDrawType(dev_data, cmd_buffer, indexed, bind_point, CMD_DISPATCHINDIRECT, cb_state, caller, - VALIDATION_ERROR_01569); + VALIDATION_ERROR_01569, VALIDATION_ERROR_UNDEFINED); *buffer_state = getBufferState(dev_data, buffer); skip |= ValidateMemoryIsBoundToBuffer(dev_data, *buffer_state, caller, VALIDATION_ERROR_02547); return skip; |
