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:
parent
85cc603394
commit
b2d1d7b2ce
|
@ -120,7 +120,6 @@ config("dawn_internal") {
|
|||
"-Wno-language-extension-token",
|
||||
"-Wno-microsoft-enum-value",
|
||||
"-Wno-nested-anon-types",
|
||||
"-Wno-vla-extension",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -788,8 +788,8 @@ namespace dawn_native { namespace vulkan {
|
|||
// Draw a non-trivial picture
|
||||
uint32_t width = 640, height = 480, pixelSize = 4;
|
||||
uint32_t bytesPerRow = Align(width * pixelSize, kTextureBytesPerRowAlignment);
|
||||
uint32_t size = bytesPerRow * (height - 1) + width * pixelSize;
|
||||
unsigned char data[size];
|
||||
std::vector<unsigned char> data(bytesPerRow * (height - 1) + width * pixelSize);
|
||||
|
||||
for (uint32_t row = 0; row < height; row++) {
|
||||
for (uint32_t col = 0; col < width; col++) {
|
||||
float normRow = static_cast<float>(row) / height;
|
||||
|
@ -805,8 +805,8 @@ namespace dawn_native { namespace vulkan {
|
|||
|
||||
// Write the picture
|
||||
{
|
||||
wgpu::Buffer copySrcBuffer =
|
||||
utils::CreateBufferFromData(secondDevice, data, size, wgpu::BufferUsage::CopySrc);
|
||||
wgpu::Buffer copySrcBuffer = utils::CreateBufferFromData(
|
||||
secondDevice, data.data(), data.size(), wgpu::BufferUsage::CopySrc);
|
||||
wgpu::BufferCopyView copySrc =
|
||||
utils::CreateBufferCopyView(copySrcBuffer, 0, bytesPerRow, 0);
|
||||
wgpu::TextureCopyView copyDst =
|
||||
|
@ -829,7 +829,7 @@ namespace dawn_native { namespace vulkan {
|
|||
|
||||
// Copy the image into a buffer for comparison
|
||||
wgpu::BufferDescriptor copyDesc;
|
||||
copyDesc.size = size;
|
||||
copyDesc.size = data.size();
|
||||
copyDesc.usage = wgpu::BufferUsage::CopySrc | wgpu::BufferUsage::CopyDst;
|
||||
wgpu::Buffer copyDstBuffer = device.CreateBuffer(©Desc);
|
||||
{
|
||||
|
@ -847,7 +847,8 @@ namespace dawn_native { namespace vulkan {
|
|||
}
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
|
|
@ -962,8 +962,8 @@ namespace dawn_native { namespace vulkan {
|
|||
// Draw a non-trivial picture
|
||||
uint32_t width = 640, height = 480, pixelSize = 4;
|
||||
uint32_t bytesPerRow = Align(width * pixelSize, kTextureBytesPerRowAlignment);
|
||||
uint32_t size = bytesPerRow * (height - 1) + width * pixelSize;
|
||||
unsigned char data[size];
|
||||
std::vector<unsigned char> data(bytesPerRow * (height - 1) + width * pixelSize);
|
||||
|
||||
for (uint32_t row = 0; row < height; row++) {
|
||||
for (uint32_t col = 0; col < width; col++) {
|
||||
float normRow = static_cast<float>(row) / height;
|
||||
|
@ -979,8 +979,8 @@ namespace dawn_native { namespace vulkan {
|
|||
|
||||
// Write the picture
|
||||
{
|
||||
wgpu::Buffer copySrcBuffer =
|
||||
utils::CreateBufferFromData(secondDevice, data, size, wgpu::BufferUsage::CopySrc);
|
||||
wgpu::Buffer copySrcBuffer = utils::CreateBufferFromData(
|
||||
secondDevice, data.data(), data.size(), wgpu::BufferUsage::CopySrc);
|
||||
wgpu::BufferCopyView copySrc =
|
||||
utils::CreateBufferCopyView(copySrcBuffer, 0, bytesPerRow, 0);
|
||||
wgpu::TextureCopyView copyDst =
|
||||
|
@ -1003,7 +1003,7 @@ namespace dawn_native { namespace vulkan {
|
|||
|
||||
// Copy the image into a buffer for comparison
|
||||
wgpu::BufferDescriptor copyDesc;
|
||||
copyDesc.size = size;
|
||||
copyDesc.size = data.size();
|
||||
copyDesc.usage = wgpu::BufferUsage::CopySrc | wgpu::BufferUsage::CopyDst;
|
||||
wgpu::Buffer copyDstBuffer = device.CreateBuffer(©Desc);
|
||||
{
|
||||
|
@ -1021,7 +1021,8 @@ namespace dawn_native { namespace vulkan {
|
|||
}
|
||||
|
||||
// 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);
|
||||
secondDeviceVk->GetFencedDeleter()->DeleteWhenUnused(imageA);
|
||||
|
|
Loading…
Reference in New Issue