Fix and enable -Wvla-extension

Bug: dawn:394
Change-Id: If5ced5f910da7fd598521113aba89e6a9051f4a9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/20582
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
This commit is contained in:
Corentin Wallez 2020-04-29 16:00:41 +00:00 committed by Commit Bot service account
parent 85cc603394
commit b2d1d7b2ce
3 changed files with 14 additions and 13 deletions

View File

@ -120,7 +120,6 @@ config("dawn_internal") {
"-Wno-language-extension-token", "-Wno-language-extension-token",
"-Wno-microsoft-enum-value", "-Wno-microsoft-enum-value",
"-Wno-nested-anon-types", "-Wno-nested-anon-types",
"-Wno-vla-extension",
] ]
} }
} }

View File

@ -788,8 +788,8 @@ namespace dawn_native { namespace vulkan {
// Draw a non-trivial picture // Draw a non-trivial picture
uint32_t width = 640, height = 480, pixelSize = 4; uint32_t width = 640, height = 480, pixelSize = 4;
uint32_t bytesPerRow = Align(width * pixelSize, kTextureBytesPerRowAlignment); uint32_t bytesPerRow = Align(width * pixelSize, kTextureBytesPerRowAlignment);
uint32_t size = bytesPerRow * (height - 1) + width * pixelSize; std::vector<unsigned char> data(bytesPerRow * (height - 1) + width * pixelSize);
unsigned char data[size];
for (uint32_t row = 0; row < height; row++) { for (uint32_t row = 0; row < height; row++) {
for (uint32_t col = 0; col < width; col++) { for (uint32_t col = 0; col < width; col++) {
float normRow = static_cast<float>(row) / height; float normRow = static_cast<float>(row) / height;
@ -805,8 +805,8 @@ namespace dawn_native { namespace vulkan {
// Write the picture // Write the picture
{ {
wgpu::Buffer copySrcBuffer = wgpu::Buffer copySrcBuffer = utils::CreateBufferFromData(
utils::CreateBufferFromData(secondDevice, data, size, wgpu::BufferUsage::CopySrc); secondDevice, data.data(), data.size(), wgpu::BufferUsage::CopySrc);
wgpu::BufferCopyView copySrc = wgpu::BufferCopyView copySrc =
utils::CreateBufferCopyView(copySrcBuffer, 0, bytesPerRow, 0); utils::CreateBufferCopyView(copySrcBuffer, 0, bytesPerRow, 0);
wgpu::TextureCopyView copyDst = wgpu::TextureCopyView copyDst =
@ -829,7 +829,7 @@ namespace dawn_native { namespace vulkan {
// Copy the image into a buffer for comparison // Copy the image into a buffer for comparison
wgpu::BufferDescriptor copyDesc; wgpu::BufferDescriptor copyDesc;
copyDesc.size = size; copyDesc.size = data.size();
copyDesc.usage = wgpu::BufferUsage::CopySrc | wgpu::BufferUsage::CopyDst; copyDesc.usage = wgpu::BufferUsage::CopySrc | wgpu::BufferUsage::CopyDst;
wgpu::Buffer copyDstBuffer = device.CreateBuffer(&copyDesc); wgpu::Buffer copyDstBuffer = device.CreateBuffer(&copyDesc);
{ {
@ -847,7 +847,8 @@ namespace dawn_native { namespace vulkan {
} }
// Check the image is not corrupted on |device| // Check the image is not corrupted on |device|
EXPECT_BUFFER_U32_RANGE_EQ(reinterpret_cast<uint32_t*>(data), copyDstBuffer, 0, size / 4); EXPECT_BUFFER_U32_RANGE_EQ(reinterpret_cast<uint32_t*>(data.data()), copyDstBuffer, 0,
data.size() / 4);
IgnoreSignalSemaphore(device, nextWrappedTexture); IgnoreSignalSemaphore(device, nextWrappedTexture);
} }

View File

@ -962,8 +962,8 @@ namespace dawn_native { namespace vulkan {
// Draw a non-trivial picture // Draw a non-trivial picture
uint32_t width = 640, height = 480, pixelSize = 4; uint32_t width = 640, height = 480, pixelSize = 4;
uint32_t bytesPerRow = Align(width * pixelSize, kTextureBytesPerRowAlignment); uint32_t bytesPerRow = Align(width * pixelSize, kTextureBytesPerRowAlignment);
uint32_t size = bytesPerRow * (height - 1) + width * pixelSize; std::vector<unsigned char> data(bytesPerRow * (height - 1) + width * pixelSize);
unsigned char data[size];
for (uint32_t row = 0; row < height; row++) { for (uint32_t row = 0; row < height; row++) {
for (uint32_t col = 0; col < width; col++) { for (uint32_t col = 0; col < width; col++) {
float normRow = static_cast<float>(row) / height; float normRow = static_cast<float>(row) / height;
@ -979,8 +979,8 @@ namespace dawn_native { namespace vulkan {
// Write the picture // Write the picture
{ {
wgpu::Buffer copySrcBuffer = wgpu::Buffer copySrcBuffer = utils::CreateBufferFromData(
utils::CreateBufferFromData(secondDevice, data, size, wgpu::BufferUsage::CopySrc); secondDevice, data.data(), data.size(), wgpu::BufferUsage::CopySrc);
wgpu::BufferCopyView copySrc = wgpu::BufferCopyView copySrc =
utils::CreateBufferCopyView(copySrcBuffer, 0, bytesPerRow, 0); utils::CreateBufferCopyView(copySrcBuffer, 0, bytesPerRow, 0);
wgpu::TextureCopyView copyDst = wgpu::TextureCopyView copyDst =
@ -1003,7 +1003,7 @@ namespace dawn_native { namespace vulkan {
// Copy the image into a buffer for comparison // Copy the image into a buffer for comparison
wgpu::BufferDescriptor copyDesc; wgpu::BufferDescriptor copyDesc;
copyDesc.size = size; copyDesc.size = data.size();
copyDesc.usage = wgpu::BufferUsage::CopySrc | wgpu::BufferUsage::CopyDst; copyDesc.usage = wgpu::BufferUsage::CopySrc | wgpu::BufferUsage::CopyDst;
wgpu::Buffer copyDstBuffer = device.CreateBuffer(&copyDesc); wgpu::Buffer copyDstBuffer = device.CreateBuffer(&copyDesc);
{ {
@ -1021,7 +1021,8 @@ namespace dawn_native { namespace vulkan {
} }
// Check the image is not corrupted on |device| // Check the image is not corrupted on |device|
EXPECT_BUFFER_U32_RANGE_EQ(reinterpret_cast<uint32_t*>(data), copyDstBuffer, 0, size / 4); EXPECT_BUFFER_U32_RANGE_EQ(reinterpret_cast<uint32_t*>(data.data()), copyDstBuffer, 0,
data.size() / 4);
IgnoreSignalSemaphore(device, nextWrappedTexture); IgnoreSignalSemaphore(device, nextWrappedTexture);
secondDeviceVk->GetFencedDeleter()->DeleteWhenUnused(imageA); secondDeviceVk->GetFencedDeleter()->DeleteWhenUnused(imageA);