layers: MR82, Add lifetime validation for buffers to DrawState
Conflicts:
layers/draw_state.cpp
layers/draw_state.h
diff --git a/layers/draw_state.h b/layers/draw_state.h
index 78fb063..2221cac 100755
--- a/layers/draw_state.h
+++ b/layers/draw_state.h
@@ -27,6 +27,7 @@
*/
#include "vulkan/vk_layer.h"
#include "vulkan/vk_ext_debug_report.h"
+#include <atomic>
#include <vector>
#include <memory>
@@ -47,6 +48,7 @@
DRAWSTATE_INVALID_PIPELINE_CREATE_STATE, // Attempt to create a pipeline with invalid state
DRAWSTATE_INVALID_COMMAND_BUFFER, // Invalid CommandBuffer referenced
DRAWSTATE_INVALID_BARRIER, // Invalid Barrier
+ DRAWSTATE_INVALID_BUFFER, // Invalid Buffer
DRAWSTATE_VTX_INDEX_OUT_OF_BOUNDS, // binding in vkCmdBindVertexData() too large for PSO's pVertexBindingDescriptions array
DRAWSTATE_VTX_INDEX_ALIGNMENT_ERROR, // binding offset in vkCmdBindIndexBuffer() out of alignment based on indexType
//DRAWSTATE_MISSING_DOT_PROGRAM, // No "dot" program in order to generate png image
@@ -93,6 +95,8 @@
DRAWSTATE_BUFFERVIEW_DESCRIPTOR_ERROR, // A Descriptor of *_TEXEL_BUFFER type is being updated with an invalid or bad BufferView
DRAWSTATE_BUFFERINFO_DESCRIPTOR_ERROR, // A Descriptor of *_[UNIFORM|STORAGE]_BUFFER_[DYNAMIC] type is being updated with an invalid or bad BufferView
DRAWSTATE_DYNAMIC_OFFSET_OVERFLOW, // At draw time the dynamic offset combined with buffer offset and range oversteps size of buffer
+ DRAWSTATE_DOUBLE_DESTROY, // Destroying an object twice
+ DRAWSTATE_OBJECT_INUSE, // Destroying an object in use by a command buffer
} DRAW_STATE_ERROR;
typedef enum _SHADER_CHECKER_ERROR {
@@ -187,6 +191,11 @@
{};
} PIPELINE_NODE;
+class BASE_NODE {
+ public:
+ std::atomic_int in_use;
+};
+
typedef struct _SAMPLER_NODE {
VkSampler sampler;
VkSamplerCreateInfo createInfo;
@@ -203,6 +212,12 @@
VkImageLayout initialLayout;
} IMAGE_CMD_BUF_NODE;
+class BUFFER_NODE : public BASE_NODE {
+ public:
+ using BASE_NODE::in_use;
+ unique_ptr<VkBufferCreateInfo> create_info;
+};
+
struct RENDER_PASS_NODE {
VkRenderPassCreateInfo const* pCreateInfo;
std::vector<bool> hasSelfDependency;
@@ -231,6 +246,26 @@
}
};
+class FENCE_NODE : public BASE_NODE {
+ public:
+ using BASE_NODE::in_use;
+ vector<VkCommandBuffer> cmdBuffers;
+ bool needsSignaled;
+ VkFence priorFence;
+};
+
+class QUEUE_NODE {
+ public:
+ VkDevice device;
+ VkFence priorFence;
+ vector<VkCommandBuffer> untrackedCmdBuffers;
+};
+
+class DEVICE_NODE {
+ public:
+ vector<VkQueue> queues;
+};
+
// Descriptor Data structures
// Layout Node has the core layout data
typedef struct _LAYOUT_NODE {
@@ -404,6 +439,10 @@
uint32_t reference;
} CBStencilData;
+typedef struct _DRAW_DATA {
+ vector<VkBuffer> buffers;
+} DRAW_DATA;
+
// Cmd Buffer Wrapper Struct
typedef struct _GLOBAL_CB_NODE {
VkCommandBuffer commandBuffer;
@@ -441,6 +480,8 @@
VkFramebuffer framebuffer;
vector<VkDescriptorSet> boundDescriptorSets; // Index is set# that given set is bound to
unordered_map<VkImage, IMAGE_CMD_BUF_NODE> imageLayoutMap;
+ vector<DRAW_DATA> drawData;
+ DRAW_DATA currentDrawData;
} GLOBAL_CB_NODE;
typedef struct _SWAPCHAIN_NODE {