Add check for an invalid D3D12/Vk object in SetDebugLabel
Fixes a crash found while fuzzing by returning early when SetDebugName is called with an empty D3D12/Vulkan object or when the device is lost. Adds tests. Bug: chromium:1245720 Change-Id: Ie443f690cf5635d017295a13e21c33dd2e97dc46 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/63363 Reviewed-by: Austin Eng <enga@chromium.org> Commit-Queue: Brandon Jones (Intel) <brandon1.jones@intel.com>
This commit is contained in:
parent
c1bcbbf357
commit
8a0b49b6d6
|
@ -373,6 +373,10 @@ namespace dawn_native { namespace d3d12 {
|
|||
}
|
||||
|
||||
void SetDebugName(Device* device, ID3D12Object* object, const char* prefix, std::string label) {
|
||||
if (!object) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (label.empty() || !device->IsToggleEnabled(Toggle::UseUserDefinedLabelsInBackend)) {
|
||||
object->SetPrivateData(WKPDID_D3DDebugObjectName, strlen(prefix), prefix);
|
||||
return;
|
||||
|
|
|
@ -170,6 +170,10 @@ namespace dawn_native { namespace vulkan {
|
|||
uint64_t objectHandle,
|
||||
const char* prefix,
|
||||
std::string label) {
|
||||
if (!objectHandle) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (device->GetGlobalInfo().HasExt(InstanceExt::DebugUtils)) {
|
||||
VkDebugUtilsObjectNameInfoEXT objectNameInfo;
|
||||
objectNameInfo.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT;
|
||||
|
|
|
@ -152,6 +152,18 @@ TEST_P(DestroyTest, TextureSubmitDestroySubmit) {
|
|||
ASSERT_DEVICE_ERROR(queue.Submit(1, &commands));
|
||||
}
|
||||
|
||||
// Attempting to set an object label after it has been destroyed should not cause an error.
|
||||
TEST_P(DestroyTest, DestroyThenSetLabel) {
|
||||
DAWN_TEST_UNSUPPORTED_IF(UsesWire());
|
||||
std::string label = "test";
|
||||
wgpu::BufferDescriptor descriptor;
|
||||
descriptor.size = 4;
|
||||
descriptor.usage = wgpu::BufferUsage::Uniform;
|
||||
wgpu::Buffer buffer = device.CreateBuffer(&descriptor);
|
||||
buffer.Destroy();
|
||||
buffer.SetLabel(label.c_str());
|
||||
}
|
||||
|
||||
DAWN_INSTANTIATE_TEST(DestroyTest,
|
||||
D3D12Backend(),
|
||||
MetalBackend(),
|
||||
|
|
|
@ -506,6 +506,18 @@ TEST_P(DeviceLostTest, FreeBindGroupAfterDeviceLossWithPendingCommands) {
|
|||
bg = nullptr;
|
||||
}
|
||||
|
||||
// Attempting to set an object label after device loss should not cause an error.
|
||||
TEST_P(DeviceLostTest, SetLabelAfterDeviceLoss) {
|
||||
DAWN_TEST_UNSUPPORTED_IF(UsesWire());
|
||||
std::string label = "test";
|
||||
wgpu::BufferDescriptor descriptor;
|
||||
descriptor.size = 4;
|
||||
descriptor.usage = wgpu::BufferUsage::Uniform;
|
||||
wgpu::Buffer buffer = device.CreateBuffer(&descriptor);
|
||||
LoseForTesting();
|
||||
buffer.SetLabel(label.c_str());
|
||||
}
|
||||
|
||||
DAWN_INSTANTIATE_TEST(DeviceLostTest,
|
||||
D3D12Backend(),
|
||||
MetalBackend(),
|
||||
|
|
Loading…
Reference in New Issue