mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-06-25 16:03:38 +00:00
Fixup readability/casting lint issues
This CL fixes a few readability/casting issues and enables the lint check. Bug: dawn:1339 Change-Id: Ib0d127c3e01fad9b5ac074d8ca09f3a1956ad4fc Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/87020 Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
This commit is contained in:
parent
3e0547df6c
commit
4c9b72b4fa
@ -1,4 +1,3 @@
|
|||||||
filter=-build/namespaces
|
filter=-build/namespaces
|
||||||
filter=-readability/casting
|
|
||||||
filter=-readability/todo
|
filter=-readability/todo
|
||||||
filter=-runtime/indentation_namespace
|
filter=-runtime/indentation_namespace
|
||||||
|
@ -517,8 +517,8 @@ namespace dawn::native {
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
case BufferState::Mapped:
|
case BufferState::Mapped:
|
||||||
ASSERT(bool(mMapMode & wgpu::MapMode::Read) ^
|
ASSERT(bool{mMapMode & wgpu::MapMode::Read} ^
|
||||||
bool(mMapMode & wgpu::MapMode::Write));
|
bool{mMapMode & wgpu::MapMode::Write});
|
||||||
return !writable || (mMapMode & wgpu::MapMode::Write);
|
return !writable || (mMapMode & wgpu::MapMode::Write);
|
||||||
|
|
||||||
case BufferState::Unmapped:
|
case BufferState::Unmapped:
|
||||||
|
@ -32,7 +32,7 @@ wgpu::Buffer ubo;
|
|||||||
|
|
||||||
float RandomFloat(float min, float max) {
|
float RandomFloat(float min, float max) {
|
||||||
// NOLINTNEXTLINE(runtime/threadsafe_fn)
|
// NOLINTNEXTLINE(runtime/threadsafe_fn)
|
||||||
float zeroOne = rand() / float(RAND_MAX);
|
float zeroOne = rand() / static_cast<float>(RAND_MAX);
|
||||||
return zeroOne * (max - min) + min;
|
return zeroOne * (max - min) + min;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -625,11 +625,11 @@ TEST_P(TextureFormatTest, RGBA8UnormSrgb) {
|
|||||||
|
|
||||||
std::vector<float> uncompressedData;
|
std::vector<float> uncompressedData;
|
||||||
for (size_t i = 0; i < textureData.size(); i += 4) {
|
for (size_t i = 0; i < textureData.size(); i += 4) {
|
||||||
uncompressedData.push_back(SRGBToLinear(textureData[i + 0] / float(maxValue)));
|
uncompressedData.push_back(SRGBToLinear(textureData[i + 0] / static_cast<float>(maxValue)));
|
||||||
uncompressedData.push_back(SRGBToLinear(textureData[i + 1] / float(maxValue)));
|
uncompressedData.push_back(SRGBToLinear(textureData[i + 1] / static_cast<float>(maxValue)));
|
||||||
uncompressedData.push_back(SRGBToLinear(textureData[i + 2] / float(maxValue)));
|
uncompressedData.push_back(SRGBToLinear(textureData[i + 2] / static_cast<float>(maxValue)));
|
||||||
// Alpha is linear for sRGB formats
|
// Alpha is linear for sRGB formats
|
||||||
uncompressedData.push_back(textureData[i + 3] / float(maxValue));
|
uncompressedData.push_back(textureData[i + 3] / static_cast<float>(maxValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
DoFloatFormatSamplingTest(
|
DoFloatFormatSamplingTest(
|
||||||
@ -652,11 +652,11 @@ TEST_P(TextureFormatTest, BGRA8UnormSrgb) {
|
|||||||
std::vector<float> uncompressedData;
|
std::vector<float> uncompressedData;
|
||||||
for (size_t i = 0; i < textureData.size(); i += 4) {
|
for (size_t i = 0; i < textureData.size(); i += 4) {
|
||||||
// Note that R and B are swapped
|
// Note that R and B are swapped
|
||||||
uncompressedData.push_back(SRGBToLinear(textureData[i + 2] / float(maxValue)));
|
uncompressedData.push_back(SRGBToLinear(textureData[i + 2] / static_cast<float>(maxValue)));
|
||||||
uncompressedData.push_back(SRGBToLinear(textureData[i + 1] / float(maxValue)));
|
uncompressedData.push_back(SRGBToLinear(textureData[i + 1] / static_cast<float>(maxValue)));
|
||||||
uncompressedData.push_back(SRGBToLinear(textureData[i + 0] / float(maxValue)));
|
uncompressedData.push_back(SRGBToLinear(textureData[i + 0] / static_cast<float>(maxValue)));
|
||||||
// Alpha is linear for sRGB formats
|
// Alpha is linear for sRGB formats
|
||||||
uncompressedData.push_back(textureData[i + 3] / float(maxValue));
|
uncompressedData.push_back(textureData[i + 3] / static_cast<float>(maxValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
DoFloatFormatSamplingTest(
|
DoFloatFormatSamplingTest(
|
||||||
@ -755,7 +755,7 @@ TEST_P(TextureFormatTest, RGB9E5Ufloat) {
|
|||||||
// exponent (15).
|
// exponent (15).
|
||||||
|
|
||||||
float smallestExponent = std::pow(2.0f, -24.0f);
|
float smallestExponent = std::pow(2.0f, -24.0f);
|
||||||
float largestExponent = std::pow(2.0f, float(31 - 24));
|
float largestExponent = std::pow(2.0f, float{31 - 24});
|
||||||
|
|
||||||
auto MakeRGB9E5 = [](uint32_t r, uint32_t g, uint32_t b, uint32_t e) {
|
auto MakeRGB9E5 = [](uint32_t r, uint32_t g, uint32_t b, uint32_t e) {
|
||||||
ASSERT((r & 0x1FF) == r);
|
ASSERT((r & 0x1FF) == r);
|
||||||
|
@ -485,8 +485,8 @@ void ShaderRobustnessPerf::Step() {
|
|||||||
pass.SetPipeline(mPipeline);
|
pass.SetPipeline(mPipeline);
|
||||||
pass.SetBindGroup(0, mBindGroup);
|
pass.SetBindGroup(0, mBindGroup);
|
||||||
for (unsigned int i = 0; i < kNumIterations; ++i) {
|
for (unsigned int i = 0; i < kNumIterations; ++i) {
|
||||||
pass.Dispatch(ceil(float(mDimBOuter) / float(kTileSize)),
|
pass.Dispatch(ceil(static_cast<float>(mDimBOuter) / float{kTileSize}),
|
||||||
ceil(float(mDimAOuter) / float(kTileSize)), 1);
|
ceil(static_cast<float>(mDimAOuter) / float{kTileSize}), 1);
|
||||||
}
|
}
|
||||||
pass.End();
|
pass.End();
|
||||||
|
|
||||||
|
@ -144,8 +144,8 @@ namespace dawn::native {
|
|||||||
|
|
||||||
TEST(CacheKeySerializerTests, FloatingTypes) {
|
TEST(CacheKeySerializerTests, FloatingTypes) {
|
||||||
// Using 0s to avoid dealing with implementation specific float details.
|
// Using 0s to avoid dealing with implementation specific float details.
|
||||||
EXPECT_THAT(CacheKey().Record(float(0)), CacheKeyEq(CacheKey(sizeof(float), 0)));
|
EXPECT_THAT(CacheKey().Record(float{0}), CacheKeyEq(CacheKey(sizeof(float), 0)));
|
||||||
EXPECT_THAT(CacheKey().Record(double(0)), CacheKeyEq(CacheKey(sizeof(double), 0)));
|
EXPECT_THAT(CacheKey().Record(double{0}), CacheKeyEq(CacheKey(sizeof(double), 0)));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(CacheKeySerializerTests, LiteralStrings) {
|
TEST(CacheKeySerializerTests, LiteralStrings) {
|
||||||
|
@ -79,19 +79,19 @@ TEST_F(SetViewportTest, ViewportLargerThanFramebuffer) {
|
|||||||
|
|
||||||
// Width is larger than the rendertarget's width
|
// Width is larger than the rendertarget's width
|
||||||
TestViewportCall(false, 0.0, 0.0, kWidth + 1.0, kHeight, 0.0, 1.0);
|
TestViewportCall(false, 0.0, 0.0, kWidth + 1.0, kHeight, 0.0, 1.0);
|
||||||
TestViewportCall(false, 0.0, 0.0, nextafter(float(kWidth), 1000.0f), kHeight, 0.0, 1.0);
|
TestViewportCall(false, 0.0, 0.0, nextafter(float{kWidth}, 1000.0f), kHeight, 0.0, 1.0);
|
||||||
|
|
||||||
// Height is larger than the rendertarget's height
|
// Height is larger than the rendertarget's height
|
||||||
TestViewportCall(false, 0.0, 0.0, kWidth, kHeight + 1.0, 0.0, 1.0);
|
TestViewportCall(false, 0.0, 0.0, kWidth, kHeight + 1.0, 0.0, 1.0);
|
||||||
TestViewportCall(false, 0.0, 0.0, kWidth, nextafter(float(kHeight), 1000.0f), 0.0, 1.0);
|
TestViewportCall(false, 0.0, 0.0, kWidth, nextafter(float{kHeight}, 1000.0f), 0.0, 1.0);
|
||||||
|
|
||||||
// x + width is larger than the rendertarget's width
|
// x + width is larger than the rendertarget's width
|
||||||
TestViewportCall(false, 2.0, 0.0, kWidth - 1.0, kHeight, 0.0, 1.0);
|
TestViewportCall(false, 2.0, 0.0, kWidth - 1.0, kHeight, 0.0, 1.0);
|
||||||
TestViewportCall(false, 1.0, 0.0, nextafter(float(kWidth - 1.0), 1000.0f), kHeight, 0.0, 1.0);
|
TestViewportCall(false, 1.0, 0.0, nextafter(float{kWidth - 1.0}, 1000.0f), kHeight, 0.0, 1.0);
|
||||||
|
|
||||||
// Height is larger than the rendertarget's height
|
// Height is larger than the rendertarget's height
|
||||||
TestViewportCall(false, 0.0, 2.0, kWidth, kHeight - 1.0, 0.0, 1.0);
|
TestViewportCall(false, 0.0, 2.0, kWidth, kHeight - 1.0, 0.0, 1.0);
|
||||||
TestViewportCall(false, 0.0, 1.0, kWidth, nextafter(float(kHeight - 1.0), 1000.0f), 0.0, 1.0);
|
TestViewportCall(false, 0.0, 1.0, kWidth, nextafter(float{kHeight - 1.0}, 1000.0f), 0.0, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test to check that negative x in viewport is disallowed
|
// Test to check that negative x in viewport is disallowed
|
||||||
|
@ -62,8 +62,8 @@ namespace {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
float errorRate =
|
float errorRate = abs(static_cast<int64_t>(mExpected[i] - actual[i])) /
|
||||||
abs(static_cast<int64_t>(mExpected[i] - actual[i])) / float(mExpected[i]);
|
static_cast<float>(mExpected[i]);
|
||||||
if (errorRate > kErrorToleranceRatio) {
|
if (errorRate > kErrorToleranceRatio) {
|
||||||
return testing::AssertionFailure()
|
return testing::AssertionFailure()
|
||||||
<< "Expected data[" << i << "] to be " << mExpected[i] << ", actual "
|
<< "Expected data[" << i << "] to be " << mExpected[i] << ", actual "
|
||||||
|
Loading…
x
Reference in New Issue
Block a user