aboutsummaryrefslogtreecommitdiff
path: root/layers
diff options
context:
space:
mode:
authorTobin Ehlis <tobine@google.com>2016-01-20 10:25:29 -0700
committerMark Lobodzinski <mark@lunarg.com>2016-01-20 11:40:02 -0700
commitbf6bcad21e911637db8f3769bdfd7dd7ceb61701 (patch)
treeac51cb227fbb264840d6d0e4995174c834fc6611 /layers
parent2f415056c53219c90c2f695e50f7547b9d4f5dc3 (diff)
downloadusermoji-bf6bcad21e911637db8f3769bdfd7dd7ceb61701.tar.xz
layers: MR149, Cleanup CMD_NODE use in draw_state
Move pCmds vector<CMD_NODE*> to be cmds vector<CMD_NODE> instead. This simplifies cleanup of the data structure as we don't have to manage the ptr new/delete lifecycle.
Diffstat (limited to 'layers')
-rw-r--r--layers/draw_state.cpp39
-rwxr-xr-xlayers/draw_state.h2
2 files changed, 11 insertions, 30 deletions
diff --git a/layers/draw_state.cpp b/layers/draw_state.cpp
index fd975ee3..8954a89f 100644
--- a/layers/draw_state.cpp
+++ b/layers/draw_state.cpp
@@ -2497,12 +2497,6 @@ static void deleteCommandBuffers(layer_data* my_data)
return;
}
for (auto ii=my_data->commandBufferMap.begin(); ii!=my_data->commandBufferMap.end(); ++ii) {
- vector<CMD_NODE*> cmd_node_list = (*ii).second->pCmds;
- while (!cmd_node_list.empty()) {
- CMD_NODE* cmd_node = cmd_node_list.back();
- delete cmd_node;
- cmd_node_list.pop_back();
- }
delete (*ii).second;
}
my_data->commandBufferMap.clear();
@@ -2536,18 +2530,11 @@ static VkBool32 addCmd(const layer_data* my_data, GLOBAL_CB_NODE* pCB, const CMD
if (pCB->state != CB_RECORDING) {
skipCall |= report_error_no_cb_begin(my_data, pCB->commandBuffer, caller_name);
skipCall |= validateCmdsInCmdBuffer(my_data, pCB, cmd);
- CMD_NODE* pCmd = new CMD_NODE;
- if (pCmd) {
- // init cmd node and append to end of cmd LL
- memset(pCmd, 0, sizeof(CMD_NODE));
- pCmd->cmdNumber = ++pCB->numCmds;
- pCmd->type = cmd;
- pCB->pCmds.push_back(pCmd);
- } else {
- // TODO : How to pass cb as srcObj here?
- skipCall |= log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, 0, __LINE__, DRAWSTATE_OUT_OF_MEMORY, "DS",
- "Out of memory while attempting to allocate new CMD_NODE for commandBuffer %#" PRIxLEAST64, reinterpret_cast<uint64_t>(pCB->commandBuffer));
- }
+ CMD_NODE cmdNode = {};
+ // init cmd node and append to end of cmd LL
+ cmdNode.cmdNumber = ++pCB->numCmds;
+ cmdNode.type = cmd;
+ pCB->cmds.push_back(cmdNode);
}
return skipCall;
}
@@ -2557,12 +2544,7 @@ static void resetCB(layer_data* my_data, const VkCommandBuffer cb)
{
GLOBAL_CB_NODE* pCB = getCBNode(my_data, cb);
if (pCB) {
- vector<CMD_NODE*> cmd_list = pCB->pCmds;
- while (!cmd_list.empty()) {
- delete cmd_list.back();
- cmd_list.pop_back();
- }
- pCB->pCmds.clear();
+ pCB->cmds.clear();
// Reset CB state (note that createInfo is not cleared)
pCB->commandBuffer = cb;
memset(&pCB->beginInfo, 0, sizeof(VkCommandBufferBeginInfo));
@@ -2573,7 +2555,6 @@ static void resetCB(layer_data* my_data, const VkCommandBuffer cb)
pCB->state = CB_NEW;
pCB->submitCount = 0;
pCB->status = 0;
- pCB->pCmds.clear();
pCB->lastBoundPipeline = 0;
pCB->viewports.clear();
pCB->scissors.clear();
@@ -2731,14 +2712,14 @@ static VkBool32 printDSConfig(layer_data* my_data, const VkCommandBuffer cb)
static void printCB(layer_data* my_data, const VkCommandBuffer cb)
{
GLOBAL_CB_NODE* pCB = getCBNode(my_data, cb);
- if (pCB && pCB->pCmds.size() > 0) {
+ if (pCB && pCB->cmds.size() > 0) {
log_msg(my_data->report_data, VK_DEBUG_REPORT_INFO_BIT_EXT, (VkDebugReportObjectTypeEXT) 0, 0, __LINE__, DRAWSTATE_NONE, "DS",
"Cmds in CB %p", (void*)cb);
- vector<CMD_NODE*> pCmds = pCB->pCmds;
- for (auto ii=pCmds.begin(); ii!=pCmds.end(); ++ii) {
+ vector<CMD_NODE> cmds = pCB->cmds;
+ for (auto ii=cmds.begin(); ii!=cmds.end(); ++ii) {
// TODO : Need to pass cb as srcObj here
log_msg(my_data->report_data, VK_DEBUG_REPORT_INFO_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, 0, __LINE__, DRAWSTATE_NONE, "DS",
- " CMD#%" PRIu64 ": %s", (*ii)->cmdNumber, cmdTypeToString((*ii)->type).c_str());
+ " CMD#%" PRIu64 ": %s", (*ii).cmdNumber, cmdTypeToString((*ii).type).c_str());
}
} else {
// Nothing to print
diff --git a/layers/draw_state.h b/layers/draw_state.h
index e2e8aebd..cbd9a080 100755
--- a/layers/draw_state.h
+++ b/layers/draw_state.h
@@ -485,7 +485,7 @@ typedef struct _GLOBAL_CB_NODE {
CB_STATE state; // Track cmd buffer update state
uint64_t submitCount; // Number of times CB has been submitted
CBStatusFlags status; // Track status of various bindings on cmd buffer
- vector<CMD_NODE*> pCmds;
+ vector<CMD_NODE> cmds; // vector of commands bound to this command buffer
// Currently storing "lastBound" objects on per-CB basis
// long-term may want to create caches of "lastBound" states and could have
// each individual CMD_NODE referencing its own "lastBound" state