layers:Verify valid buffer for tex buff ds update
authorTobin Ehlis <tobine@google.com>
Wed, 11 Oct 2017 14:48:00 +0000 (08:48 -0600)
committerTobin Ehlis <tobine@google.com>
Thu, 12 Oct 2017 16:51:41 +0000 (10:51 -0600)
Fixes #2104

Make sure that buffer underlying the bufferView of texel buffer for a
uniform or storage texel buffer update has a valid buffer behind it.
Object tracker only checks to make sure that the view itself hasn't
been destroyed, so need this extra level of checking at this level to
avoid crash.

layers/descriptor_sets.cpp

index 6577fbb..5c8981e 100644 (file)
@@ -1510,7 +1510,16 @@ bool cvdescriptorset::DescriptorSet::VerifyWriteUpdateContents(const VkWriteDesc
                     return false;
                 }
                 auto buffer = bv_state->create_info.buffer;
-                if (!ValidateBufferUsage(GetBufferState(device_data_, buffer), update->descriptorType, error_code, error_msg)) {
+                auto buffer_state = GetBufferState(device_data_, buffer);
+                // Verify that buffer underlying the view hasn't been destroyed prematurely
+                if (!buffer_state) {
+                    *error_code = VALIDATION_ERROR_15c00286;
+                    std::stringstream error_str;
+                    error_str << "Attempted write update to texel buffer descriptor failed because underlying buffer (" << buffer
+                              << ") has been destroyed: " << error_msg->c_str();
+                    *error_msg = error_str.str();
+                    return false;
+                } else if (!ValidateBufferUsage(buffer_state, update->descriptorType, error_code, error_msg)) {
                     std::stringstream error_str;
                     error_str << "Attempted write update to texel buffer descriptor failed due to: " << error_msg->c_str();
                     *error_msg = error_str.str();