From 98c90d4faa86cec8167f2bed73f91cd35e3facef Mon Sep 17 00:00:00 2001 From: Corentin Wallez Date: Fri, 7 Jul 2017 14:39:38 -0400 Subject: [PATCH] Fix clang/GCC warnings --- examples/glTFViewer/glTFViewer.cpp | 8 +++----- generator/templates/wire/WireClient.cpp | 4 ++-- src/backend/CommandBuffer.cpp | 4 ++-- src/backend/Pipeline.cpp | 4 ++++ src/backend/Pipeline.h | 1 + src/backend/Sampler.cpp | 2 +- src/backend/metal/BufferMTL.mm | 4 ++-- src/backend/metal/MetalBackend.mm | 2 +- src/backend/metal/TextureMTL.mm | 2 +- src/backend/null/NullBackend.cpp | 6 +++--- src/backend/opengl/CommandBufferGL.cpp | 2 +- src/backend/opengl/OpenGLBackend.cpp | 4 ++-- src/backend/opengl/TextureGL.cpp | 2 +- src/tests/NXTTest.cpp | 4 ++++ src/tests/end2end/InputStateTests.cpp | 2 +- src/tests/unittests/BitSetIteratorTests.cpp | 1 + src/tests/unittests/SerialQueueTests.cpp | 2 ++ src/tests/unittests/WireTests.cpp | 12 ++++++------ 18 files changed, 38 insertions(+), 28 deletions(-) diff --git a/examples/glTFViewer/glTFViewer.cpp b/examples/glTFViewer/glTFViewer.cpp index 56189b4dfe..1919c4fd2e 100644 --- a/examples/glTFViewer/glTFViewer.cpp +++ b/examples/glTFViewer/glTFViewer.cpp @@ -164,7 +164,6 @@ namespace { const auto& iMaterial = scene.materials.at(iMaterialID); const auto& iTechnique = scene.techniques.at(iMaterial.technique); - const auto& iProgram = scene.programs.at(iTechnique.program); auto oVSModule = utils::CreateShaderModule(device, nxt::ShaderStage::Vertex, R"( #version 450 @@ -504,7 +503,6 @@ namespace { uint32_t vertexCount = 0; for (const auto& s : slotSemantics) { uint32_t slot = s.first; - const auto& iSemantic = s.second; auto it = iPrim.attributes.find(s.second); if (it == iPrim.attributes.end()) { uint32_t zero = 0; @@ -589,11 +587,11 @@ namespace { namespace { bool buttons[GLFW_MOUSE_BUTTON_LAST + 1] = {0}; - void mouseButtonCallback(GLFWwindow *window, int button, int action, int mods) { + void mouseButtonCallback(GLFWwindow*, int button, int action, int) { buttons[button] = (action == GLFW_PRESS); } - void cursorPosCallback(GLFWwindow *window, double mouseX, double mouseY) { + void cursorPosCallback(GLFWwindow*, double mouseX, double mouseY) { static float oldX, oldY; float dX = mouseX - oldX; float dY = mouseY - oldY; @@ -609,7 +607,7 @@ namespace { } } - void scrollCallback(GLFWwindow *window, double xoffset, double yoffset) { + void scrollCallback(GLFWwindow*, double, double yoffset) { camera.zoom(yoffset * 0.04); } } diff --git a/generator/templates/wire/WireClient.cpp b/generator/templates/wire/WireClient.cpp index 0be1dfa86e..721f3d176f 100644 --- a/generator/templates/wire/WireClient.cpp +++ b/generator/templates/wire/WireClient.cpp @@ -373,10 +373,10 @@ namespace wire { ClientBufferUnmap(buffer); } - void ClientDeviceReference(Device* self) { + void ClientDeviceReference(Device*) { } - void ClientDeviceRelease(Device* self) { + void ClientDeviceRelease(Device*) { } void ClientDeviceSetErrorCallback(Device* self, nxtDeviceErrorCallback callback, nxtCallbackUserdata userdata) { diff --git a/src/backend/CommandBuffer.cpp b/src/backend/CommandBuffer.cpp index cf68b145dc..95564eb293 100644 --- a/src/backend/CommandBuffer.cpp +++ b/src/backend/CommandBuffer.cpp @@ -69,7 +69,7 @@ namespace backend { return true; } - bool ComputeTextureCopyBufferSize(CommandBufferBuilder* builder, const TextureCopyLocation& location, uint32_t* bufferSize) { + bool ComputeTextureCopyBufferSize(CommandBufferBuilder*, const TextureCopyLocation& location, uint32_t* bufferSize) { // TODO(cwallez@chromium.org): check for overflows uint32_t pixelSize = TextureFormatPixelSize(location.texture->GetFormat()); *bufferSize = location.width * location.height * location.depth * pixelSize; @@ -503,7 +503,7 @@ namespace backend { case Command::SetStencilReference: { - SetStencilReferenceCmd* cmd = iterator.NextCommand(); + iterator.NextCommand(); if (!state->HaveRenderPass()) { HandleError("Can't set stencil reference without an active render pass"); return false; diff --git a/src/backend/Pipeline.cpp b/src/backend/Pipeline.cpp index b5ece5a68c..eb4e9aee3e 100644 --- a/src/backend/Pipeline.cpp +++ b/src/backend/Pipeline.cpp @@ -97,6 +97,10 @@ namespace backend { return renderPass.Get(); } + uint32_t PipelineBase::GetSubPass() { + return subpass; + } + InputStateBase* PipelineBase::GetInputState() { return inputState.Get(); } diff --git a/src/backend/Pipeline.h b/src/backend/Pipeline.h index bf51e88c51..aacbffef1f 100644 --- a/src/backend/Pipeline.h +++ b/src/backend/Pipeline.h @@ -46,6 +46,7 @@ namespace backend { PipelineLayoutBase* GetLayout(); RenderPassBase* GetRenderPass(); + uint32_t GetSubPass(); InputStateBase* GetInputState(); DepthStencilStateBase* GetDepthStencilState(); diff --git a/src/backend/Sampler.cpp b/src/backend/Sampler.cpp index 554f0a5a9e..a31530e5ca 100644 --- a/src/backend/Sampler.cpp +++ b/src/backend/Sampler.cpp @@ -20,7 +20,7 @@ namespace backend { // SamplerBase - SamplerBase::SamplerBase(SamplerBuilder* builder) { + SamplerBase::SamplerBase(SamplerBuilder*) { } // SamplerBuilder diff --git a/src/backend/metal/BufferMTL.mm b/src/backend/metal/BufferMTL.mm index 4f8f99f0b8..3a8c0bc2e0 100644 --- a/src/backend/metal/BufferMTL.mm +++ b/src/backend/metal/BufferMTL.mm @@ -53,7 +53,7 @@ namespace metal { uploader->BufferSubData(mtlBuffer, start * sizeof(uint32_t), count * sizeof(uint32_t), data); } - void Buffer::MapReadAsyncImpl(uint32_t serial, uint32_t start, uint32_t count) { + void Buffer::MapReadAsyncImpl(uint32_t serial, uint32_t start, uint32_t) { MapReadRequestTracker* tracker = ToBackend(GetDevice())->GetMapReadTracker(); tracker->Track(this, serial, start); } @@ -62,7 +62,7 @@ namespace metal { // Nothing to do, Metal StorageModeShared buffers are always mapped. } - void Buffer::TransitionUsageImpl(nxt::BufferUsageBit currentUsage, nxt::BufferUsageBit targetUsage) { + void Buffer::TransitionUsageImpl(nxt::BufferUsageBit, nxt::BufferUsageBit) { } BufferView::BufferView(BufferViewBuilder* builder) diff --git a/src/backend/metal/MetalBackend.mm b/src/backend/metal/MetalBackend.mm index 5addf90057..f5b3ddbc7e 100644 --- a/src/backend/metal/MetalBackend.mm +++ b/src/backend/metal/MetalBackend.mm @@ -215,7 +215,7 @@ namespace metal { // so this-> works as expected. However it is unclear how members are captured, (are they // captured using this-> or by value?) so we make a copy of the pendingCommandSerial on the stack. Serial pendingSerial = pendingCommandSerial; - [pendingCommands addCompletedHandler:^(id commandBuffer) { + [pendingCommands addCompletedHandler:^(id) { this->finishedCommandSerial = pendingSerial; }]; diff --git a/src/backend/metal/TextureMTL.mm b/src/backend/metal/TextureMTL.mm index 842edc716c..03982089ac 100644 --- a/src/backend/metal/TextureMTL.mm +++ b/src/backend/metal/TextureMTL.mm @@ -78,7 +78,7 @@ namespace metal { return mtlTexture; } - void Texture::TransitionUsageImpl(nxt::TextureUsageBit currentUsage, nxt::TextureUsageBit targetUsage) { + void Texture::TransitionUsageImpl(nxt::TextureUsageBit, nxt::TextureUsageBit) { } TextureView::TextureView(TextureViewBuilder* builder) diff --git a/src/backend/null/NullBackend.cpp b/src/backend/null/NullBackend.cpp index c8e6210305..10f4312ecf 100644 --- a/src/backend/null/NullBackend.cpp +++ b/src/backend/null/NullBackend.cpp @@ -148,7 +148,7 @@ namespace null { void Buffer::UnmapImpl() { } - void Buffer::TransitionUsageImpl(nxt::BufferUsageBit currentUsage, nxt::BufferUsageBit targetUsage) { + void Buffer::TransitionUsageImpl(nxt::BufferUsageBit, nxt::BufferUsageBit) { } // CommandBuffer @@ -193,7 +193,7 @@ namespace null { Queue::~Queue() { } - void Queue::Submit(uint32_t numCommands, CommandBuffer* const * commands) { + void Queue::Submit(uint32_t numCommands, CommandBuffer* const* commands) { auto operations = ToBackend(GetDevice())->AcquirePendingOperations(); for (auto& operation : operations) { @@ -216,7 +216,7 @@ namespace null { Texture::~Texture() { } - void Texture::TransitionUsageImpl(nxt::TextureUsageBit currentUsage, nxt::TextureUsageBit targetUsage) { + void Texture::TransitionUsageImpl(nxt::TextureUsageBit, nxt::TextureUsageBit) { } } diff --git a/src/backend/opengl/CommandBufferGL.cpp b/src/backend/opengl/CommandBufferGL.cpp index 6a0d16e9d2..3e968c5bff 100644 --- a/src/backend/opengl/CommandBufferGL.cpp +++ b/src/backend/opengl/CommandBufferGL.cpp @@ -123,7 +123,7 @@ namespace opengl { case Command::CopyTextureToBuffer: { - CopyTextureToBufferCmd* copy = commands.NextCommand(); + commands.NextCommand(); // TODO(cwallez@chromium.org): implement using a temporary FBO and ReadPixels } break; diff --git a/src/backend/opengl/OpenGLBackend.cpp b/src/backend/opengl/OpenGLBackend.cpp index 2ba9e62807..c9a3715efb 100644 --- a/src/backend/opengl/OpenGLBackend.cpp +++ b/src/backend/opengl/OpenGLBackend.cpp @@ -130,7 +130,7 @@ namespace opengl { glBufferSubData(GL_ARRAY_BUFFER, start * sizeof(uint32_t), count * sizeof(uint32_t), data); } - void Buffer::MapReadAsyncImpl(uint32_t serial, uint32_t start, uint32_t count) { + void Buffer::MapReadAsyncImpl(uint32_t, uint32_t, uint32_t) { // TODO(cwallez@chromium.org): Implement Map Read for the GL backend } @@ -138,7 +138,7 @@ namespace opengl { // TODO(cwallez@chromium.org): Implement Map Read for the GL backend } - void Buffer::TransitionUsageImpl(nxt::BufferUsageBit currentUsage, nxt::BufferUsageBit targetUsage) { + void Buffer::TransitionUsageImpl(nxt::BufferUsageBit, nxt::BufferUsageBit) { } // BufferView diff --git a/src/backend/opengl/TextureGL.cpp b/src/backend/opengl/TextureGL.cpp index 9670b67814..6605d6a27f 100644 --- a/src/backend/opengl/TextureGL.cpp +++ b/src/backend/opengl/TextureGL.cpp @@ -76,7 +76,7 @@ namespace opengl { return GetGLFormatInfo(GetFormat()); } - void Texture::TransitionUsageImpl(nxt::TextureUsageBit currentUsage, nxt::TextureUsageBit targetUsage) { + void Texture::TransitionUsageImpl(nxt::TextureUsageBit, nxt::TextureUsageBit) { } // TextureView diff --git a/src/tests/NXTTest.cpp b/src/tests/NXTTest.cpp index 2f939395a1..b25dc42076 100644 --- a/src/tests/NXTTest.cpp +++ b/src/tests/NXTTest.cpp @@ -280,6 +280,10 @@ namespace detail { return type == MetalBackend; #elif defined(_WIN32) return type == D3D12Backend; + #elif __linux__ + // Temporarily silence a warning while Linux doesn't have a backend that can be tested. + (void) type; + return false; #else return false; #endif diff --git a/src/tests/end2end/InputStateTests.cpp b/src/tests/end2end/InputStateTests.cpp index e40b28e4d2..c0de37d390 100644 --- a/src/tests/end2end/InputStateTests.cpp +++ b/src/tests/end2end/InputStateTests.cpp @@ -179,7 +179,7 @@ class InputStateTest : public NXTTest { uint32_t location; nxt::Buffer* buffer; }; - void DoTestDraw(const nxt::Pipeline& pipeline, int triangles, int instances, std::vector vertexBuffers) { + void DoTestDraw(const nxt::Pipeline& pipeline, unsigned int triangles, unsigned int instances, std::vector vertexBuffers) { EXPECT_LE(triangles, 4); EXPECT_LE(instances, 4); diff --git a/src/tests/unittests/BitSetIteratorTests.cpp b/src/tests/unittests/BitSetIteratorTests.cpp index b1ac2e70dc..3c6e8ced10 100644 --- a/src/tests/unittests/BitSetIteratorTests.cpp +++ b/src/tests/unittests/BitSetIteratorTests.cpp @@ -53,6 +53,7 @@ TEST_F(BitSetIteratorTest, EmptySet) { // causing an unreachable code warning in MSVS bool sawBit = false; for (unsigned long bit : IterateBitSet(mStateBits)) { + (void) bit; sawBit = true; } EXPECT_FALSE(sawBit); diff --git a/src/tests/unittests/SerialQueueTests.cpp b/src/tests/unittests/SerialQueueTests.cpp index f4f22aa370..6eb4b94003 100644 --- a/src/tests/unittests/SerialQueueTests.cpp +++ b/src/tests/unittests/SerialQueueTests.cpp @@ -27,6 +27,7 @@ TEST(SerialQueue, BasicTest) { // Iterating on empty queue 1) works 2) doesn't produce any values for (int value : queue.IterateAll()) { + (void) value; ASSERT_TRUE(false); } @@ -49,6 +50,7 @@ TEST(SerialQueue, BasicTest) { ASSERT_TRUE(queue.Empty()); for (int value : queue.IterateAll()) { + (void) value; ASSERT_TRUE(false); } } diff --git a/src/tests/unittests/WireTests.cpp b/src/tests/unittests/WireTests.cpp index 06a3585a26..5392854388 100644 --- a/src/tests/unittests/WireTests.cpp +++ b/src/tests/unittests/WireTests.cpp @@ -128,7 +128,7 @@ class WireTests : public WireTestsBase { // One call gets forwarded correctly. TEST_F(WireTests, CallForwarded) { - nxtCommandBufferBuilder builder = nxtDeviceCreateCommandBufferBuilder(device); + nxtDeviceCreateCommandBufferBuilder(device); nxtCommandBufferBuilder apiCmdBufBuilder = api.GetNewCommandBufferBuilder(); EXPECT_CALL(api, DeviceCreateCommandBufferBuilder(apiDevice)) @@ -140,7 +140,7 @@ TEST_F(WireTests, CallForwarded) { // Test that calling methods on a new object works as expected. TEST_F(WireTests, CreateThenCall) { nxtCommandBufferBuilder builder = nxtDeviceCreateCommandBufferBuilder(device); - nxtCommandBuffer cmdBuf = nxtCommandBufferBuilderGetResult(builder); + nxtCommandBufferBuilderGetResult(builder); nxtCommandBufferBuilder apiCmdBufBuilder = api.GetNewCommandBufferBuilder(); EXPECT_CALL(api, DeviceCreateCommandBufferBuilder(apiDevice)) @@ -350,7 +350,7 @@ TEST_F(WireTests, CallsSkippedAfterBuilderError) { // These calls will be skipped because of the error nxtBufferTransitionUsage(buffer, NXT_BUFFER_USAGE_BIT_UNIFORM); nxtCommandBufferBuilderTransitionBufferUsage(cmdBufBuilder, buffer, NXT_BUFFER_USAGE_BIT_UNIFORM); - nxtCommandBuffer cmdBuf = nxtCommandBufferBuilderGetResult(cmdBufBuilder); + nxtCommandBufferBuilderGetResult(cmdBufBuilder); nxtCommandBufferBuilder apiCmdBufBuilder = api.GetNewCommandBufferBuilder(); EXPECT_CALL(api, DeviceCreateCommandBufferBuilder(apiDevice)) @@ -383,7 +383,7 @@ TEST_F(WireTests, CallsSkippedAfterBuilderError) { TEST_F(WireTests, SuccessCallbackOnBuilderSuccess) { nxtBufferBuilder bufferBuilder = nxtDeviceCreateBufferBuilder(device); nxtBufferBuilderSetErrorCallback(bufferBuilder, ToMockBuilderErrorCallback, 1, 2); - nxtBuffer buffer = nxtBufferBuilderGetResult(bufferBuilder); + nxtBufferBuilderGetResult(bufferBuilder); nxtBufferBuilder apiBufferBuilder = api.GetNewBufferBuilder(); EXPECT_CALL(api, DeviceCreateBufferBuilder(apiDevice)) @@ -420,7 +420,7 @@ TEST_F(WireTests, UnknownBuilderErrorStatusCallback) { { nxtBufferBuilder bufferBuilder = nxtDeviceCreateBufferBuilder(device); nxtBufferBuilderSetErrorCallback(bufferBuilder, ToMockBuilderErrorCallback, 3, 4); - nxtBuffer buffer = nxtBufferBuilderGetResult(bufferBuilder); + nxtBufferBuilderGetResult(bufferBuilder); EXPECT_CALL(*mockBuilderErrorCallback, Call(NXT_BUILDER_ERROR_STATUS_UNKNOWN, _ , 3, 4)).Times(0); @@ -485,7 +485,7 @@ TEST_F(WireSetCallbackTests, BuilderErrorCallback) { FlushClient(); // Create an object so that it is a valid case to call the error callback - nxtBuffer buffer = nxtBufferBuilderGetResult(bufferBuilder); + nxtBufferBuilderGetResult(bufferBuilder); nxtBuffer apiBuffer = api.GetNewBuffer(); EXPECT_CALL(api, BufferBuilderGetResult(apiBufferBuilder))