Fix all Windows warnings
diff --git a/src/backend/BindGroup.cpp b/src/backend/BindGroup.cpp
index 04555f8..0946c14 100644
--- a/src/backend/BindGroup.cpp
+++ b/src/backend/BindGroup.cpp
@@ -110,7 +110,7 @@
const auto& layoutInfo = layout->GetBindingInfo();
for (size_t i = start, j = 0; i < start + count; ++i, ++j) {
- nxt::BufferUsageBit requiredBit;
+ nxt::BufferUsageBit requiredBit = nxt::BufferUsageBit::None;
switch (layoutInfo.types[i]) {
case nxt::BindingType::UniformBuffer:
requiredBit = nxt::BufferUsageBit::Uniform;
diff --git a/src/backend/CommandBuffer.cpp b/src/backend/CommandBuffer.cpp
index 95564eb..fae5ec8 100644
--- a/src/backend/CommandBuffer.cpp
+++ b/src/backend/CommandBuffer.cpp
@@ -71,7 +71,7 @@
bool ComputeTextureCopyBufferSize(CommandBufferBuilder*, const TextureCopyLocation& location, uint32_t* bufferSize) {
// TODO(cwallez@chromium.org): check for overflows
- uint32_t pixelSize = TextureFormatPixelSize(location.texture->GetFormat());
+ uint32_t pixelSize = static_cast<uint32_t>(TextureFormatPixelSize(location.texture->GetFormat()));
*bufferSize = location.width * location.height * location.depth * pixelSize;
return true;
diff --git a/src/backend/CommandBufferStateTracker.cpp b/src/backend/CommandBufferStateTracker.cpp
index d2de413..d5a54373 100644
--- a/src/backend/CommandBufferStateTracker.cpp
+++ b/src/backend/CommandBufferStateTracker.cpp
@@ -488,8 +488,7 @@
break;
default:
- ASSERT(false);
- return false;
+ UNREACHABLE();
}
auto buffer = group->GetBindingAsBufferView(i)->GetBuffer();
@@ -535,13 +534,13 @@
}
void CommandBufferStateTracker::UnsetPipeline() {
- constexpr ValidationAspects pipelineDependentAspectsInverse =
- ~(1 << VALIDATION_ASPECT_RENDER_PIPELINE |
- 1 << VALIDATION_ASPECT_COMPUTE_PIPELINE |
- 1 << VALIDATION_ASPECT_BIND_GROUPS |
- 1 << VALIDATION_ASPECT_VERTEX_BUFFERS |
- 1 << VALIDATION_ASPECT_INDEX_BUFFER);
- aspects &= pipelineDependentAspectsInverse;
+ constexpr ValidationAspects pipelineDependentAspects =
+ 1 << VALIDATION_ASPECT_RENDER_PIPELINE |
+ 1 << VALIDATION_ASPECT_COMPUTE_PIPELINE |
+ 1 << VALIDATION_ASPECT_BIND_GROUPS |
+ 1 << VALIDATION_ASPECT_VERTEX_BUFFERS |
+ 1 << VALIDATION_ASPECT_INDEX_BUFFER;
+ aspects &= ~pipelineDependentAspects;
bindgroups.fill(nullptr);
}
}
diff --git a/src/backend/RenderPass.cpp b/src/backend/RenderPass.cpp
index 5261746..9765a45 100644
--- a/src/backend/RenderPass.cpp
+++ b/src/backend/RenderPass.cpp
@@ -28,7 +28,7 @@
}
uint32_t RenderPassBase::GetAttachmentCount() const {
- return attachments.size();
+ return static_cast<uint32_t>(attachments.size());
}
const RenderPassBase::AttachmentInfo& RenderPassBase::GetAttachmentInfo(uint32_t attachment) const {
@@ -37,7 +37,7 @@
}
uint32_t RenderPassBase::GetSubpassCount() const {
- return subpasses.size();
+ return static_cast<uint32_t>(subpasses.size());
}
const RenderPassBase::SubpassInfo& RenderPassBase::GetSubpassInfo(uint32_t subpass) const {
diff --git a/src/backend/d3d12/CommandBufferD3D12.cpp b/src/backend/d3d12/CommandBufferD3D12.cpp
index 4a9a637..5de2b5b 100644
--- a/src/backend/d3d12/CommandBufferD3D12.cpp
+++ b/src/backend/d3d12/CommandBufferD3D12.cpp
@@ -273,7 +273,8 @@
D3D12_RECT scissorRect = { 0, 0, static_cast<long>(width), static_cast<long>(height) };
commandList->RSSetViewports(1, &viewport);
commandList->RSSetScissorRects(1, &scissorRect);
- commandList->OMSetRenderTargets(1, &device->GetCurrentRenderTargetDescriptor(), FALSE, nullptr);
+ D3D12_CPU_DESCRIPTOR_HANDLE rtv = device->GetCurrentRenderTargetDescriptor();
+ commandList->OMSetRenderTargets(1, &rtv, FALSE, nullptr);
}
break;
@@ -381,7 +382,7 @@
case Command::EndRenderPass:
{
- EndRenderPassCmd* cmd = commands.NextCommand<EndRenderPassCmd>();
+ commands.NextCommand<EndRenderPassCmd>();
}
break;
@@ -426,13 +427,13 @@
case Command::SetPushConstants:
{
- SetPushConstantsCmd* cmd = commands.NextCommand<SetPushConstantsCmd>();
+ commands.NextCommand<SetPushConstantsCmd>();
}
break;
case Command::SetStencilReference:
{
- SetStencilReferenceCmd* cmd = commands.NextCommand<SetStencilReferenceCmd>();
+ commands.NextCommand<SetStencilReferenceCmd>();
}
break;
diff --git a/src/backend/d3d12/D3D12Backend.cpp b/src/backend/d3d12/D3D12Backend.cpp
index c87ad59..b330bce 100644
--- a/src/backend/d3d12/D3D12Backend.cpp
+++ b/src/backend/d3d12/D3D12Backend.cpp
@@ -200,10 +200,10 @@
pendingCommands.open = false;
lists[0] = pendingCommands.commandList.Get();
std::copy(commandLists.begin(), commandLists.end(), lists.begin() + 1);
- commandQueue->ExecuteCommandLists(commandLists.size() + 1, lists.data());
+ commandQueue->ExecuteCommandLists(static_cast<UINT>(commandLists.size() + 1), lists.data());
} else {
std::vector<ID3D12CommandList*> lists(commandLists);
- commandQueue->ExecuteCommandLists(commandLists.size(), lists.data());
+ commandQueue->ExecuteCommandLists(static_cast<UINT>(commandLists.size()), lists.data());
}
}
diff --git a/src/backend/d3d12/InputStateD3D12.cpp b/src/backend/d3d12/InputStateD3D12.cpp
index 73b3acb..a02cd73 100644
--- a/src/backend/d3d12/InputStateD3D12.cpp
+++ b/src/backend/d3d12/InputStateD3D12.cpp
@@ -14,6 +14,8 @@
#include "backend/d3d12/InputStateD3D12.h"
+#include "common/BitSetIterator.h"
+
namespace backend {
namespace d3d12 {
@@ -48,8 +50,8 @@
const auto& attributesSetMask = GetAttributesSetMask();
- size_t count = 0;
- for (size_t i = 0; i < attributesSetMask.size(); ++i) {
+ unsigned int count = 0;
+ for (auto i : IterateBitSet(attributesSetMask)) {
if (!attributesSetMask[i]) {
continue;
}
@@ -60,7 +62,7 @@
// If the HLSL semantic is TEXCOORDN the SemanticName should be "TEXCOORD" and the SemanticIndex N
inputElementDescriptor.SemanticName = "TEXCOORD";
- inputElementDescriptor.SemanticIndex = i;
+ inputElementDescriptor.SemanticIndex = static_cast<uint32_t>(i);
inputElementDescriptor.Format = VertexFormatType(attribute.format);
inputElementDescriptor.InputSlot = attribute.bindingSlot;
diff --git a/src/backend/d3d12/TextureD3D12.cpp b/src/backend/d3d12/TextureD3D12.cpp
index 432b5b8..49a08b9 100644
--- a/src/backend/d3d12/TextureD3D12.cpp
+++ b/src/backend/d3d12/TextureD3D12.cpp
@@ -89,8 +89,8 @@
resourceDescriptor.Alignment = 0;
resourceDescriptor.Width = GetWidth();
resourceDescriptor.Height = GetHeight();
- resourceDescriptor.DepthOrArraySize = GetDepth();
- resourceDescriptor.MipLevels = GetNumMipLevels();
+ resourceDescriptor.DepthOrArraySize = static_cast<UINT16>(GetDepth());
+ resourceDescriptor.MipLevels = static_cast<UINT16>(GetNumMipLevels());
resourceDescriptor.Format = D3D12TextureFormat(GetFormat());
resourceDescriptor.SampleDesc.Count = 1;
resourceDescriptor.SampleDesc.Quality = 0;
diff --git a/src/backend/opengl/CommandBufferGL.cpp b/src/backend/opengl/CommandBufferGL.cpp
index 27a7568..2af08c1 100644
--- a/src/backend/opengl/CommandBufferGL.cpp
+++ b/src/backend/opengl/CommandBufferGL.cpp
@@ -243,10 +243,10 @@
case Command::SetBindGroup:
{
SetBindGroupCmd* cmd = commands.NextCommand<SetBindGroupCmd>();
- size_t index = cmd->index;
+ size_t groupIndex = cmd->index;
BindGroup* group = ToBackend(cmd->group.Get());
- const auto& indices = ToBackend(lastPipeline->GetLayout())->GetBindingIndexInfo()[index];
+ const auto& indices = ToBackend(lastPipeline->GetLayout())->GetBindingIndexInfo()[groupIndex];
const auto& layout = group->GetLayout()->GetBindingInfo();
// TODO(cwallez@chromium.org): iterate over the layout bitmask instead
@@ -260,18 +260,18 @@
{
BufferView* view = ToBackend(group->GetBindingAsBufferView(binding));
GLuint buffer = ToBackend(view->GetBuffer())->GetHandle();
- GLuint index = indices[binding];
+ GLuint uboIndex = indices[binding];
- glBindBufferRange(GL_UNIFORM_BUFFER, index, buffer, view->GetOffset(), view->GetSize());
+ glBindBufferRange(GL_UNIFORM_BUFFER, uboIndex, buffer, view->GetOffset(), view->GetSize());
}
break;
case nxt::BindingType::Sampler:
{
GLuint sampler = ToBackend(group->GetBindingAsSampler(binding))->GetHandle();
- GLuint index = indices[binding];
+ GLuint samplerIndex = indices[binding];
- for (auto unit : lastPipeline->GetTextureUnitsForSampler(index)) {
+ for (auto unit : lastPipeline->GetTextureUnitsForSampler(samplerIndex)) {
glBindSampler(unit, sampler);
}
}
@@ -283,9 +283,9 @@
Texture* texture = ToBackend(view->GetTexture());
GLuint handle = texture->GetHandle();
GLenum target = texture->GetGLTarget();
- GLuint index = indices[binding];
+ GLuint textureIndex = indices[binding];
- for (auto unit : lastPipeline->GetTextureUnitsForTexture(index)) {
+ for (auto unit : lastPipeline->GetTextureUnitsForTexture(textureIndex)) {
glActiveTexture(GL_TEXTURE0 + unit);
glBindTexture(target, handle);
}
@@ -296,9 +296,9 @@
{
BufferView* view = ToBackend(group->GetBindingAsBufferView(binding));
GLuint buffer = ToBackend(view->GetBuffer())->GetHandle();
- GLuint index = indices[binding];
+ GLuint ssboIndex = indices[binding];
- glBindBufferRange(GL_SHADER_STORAGE_BUFFER, index, buffer, view->GetOffset(), view->GetSize());
+ glBindBufferRange(GL_SHADER_STORAGE_BUFFER, ssboIndex, buffer, view->GetOffset(), view->GetSize());
}
break;
}
diff --git a/src/tests/end2end/InputStateTests.cpp b/src/tests/end2end/InputStateTests.cpp
index ea05ee8..dc1db5d 100644
--- a/src/tests/end2end/InputStateTests.cpp
+++ b/src/tests/end2end/InputStateTests.cpp
@@ -28,9 +28,9 @@
// The predetermined values are "K * gl_VertexID + componentIndex" for vertex-indexed buffers, and
// "K * gl_InstanceID + componentIndex" for instance-indexed buffers.
-constexpr static int kRTSize = 400;
-constexpr static int kRTCellOffset = 50;
-constexpr static int kRTCellSize = 100;
+constexpr static unsigned int kRTSize = 400;
+constexpr static unsigned int kRTCellOffset = 50;
+constexpr static unsigned int kRTCellSize = 100;
class InputStateTest : public NXTTest {
protected:
@@ -175,7 +175,7 @@
template<typename T>
nxt::Buffer MakeVertexBuffer(std::vector<T> data) {
- return utils::CreateFrozenBufferFromData(device, data.data(), data.size() * sizeof(T), nxt::BufferUsageBit::Vertex);
+ return utils::CreateFrozenBufferFromData(device, data.data(), static_cast<uint32_t>(data.size() * sizeof(T)), nxt::BufferUsageBit::Vertex);
}
struct DrawVertexBuffer {
@@ -183,8 +183,8 @@
nxt::Buffer* buffer;
};
void DoTestDraw(const nxt::Pipeline& pipeline, unsigned int triangles, unsigned int instances, std::vector<DrawVertexBuffer> vertexBuffers) {
- EXPECT_LE(triangles, 4);
- EXPECT_LE(instances, 4);
+ EXPECT_LE(triangles, 4u);
+ EXPECT_LE(instances, 4u);
nxt::CommandBufferBuilder builder = device.CreateCommandBufferBuilder();
@@ -207,10 +207,10 @@
// Check that the center of each triangle is pure green, so that if a single vertex shader
// instance fails, linear interpolation makes the pixel check fail.
- for (size_t triangle = 0; triangle < 4; triangle++) {
- for (size_t instance = 0; instance < 4; instance++) {
- int x = kRTCellOffset + kRTCellSize * triangle;
- int y = kRTCellOffset + kRTCellSize * instance;
+ for (unsigned int triangle = 0; triangle < 4; triangle++) {
+ for (unsigned int instance = 0; instance < 4; instance++) {
+ unsigned int x = kRTCellOffset + kRTCellSize * triangle;
+ unsigned int y = kRTCellOffset + kRTCellSize * instance;
if (triangle < triangles && instance < instances) {
EXPECT_PIXEL_RGBA8_EQ(RGBA8(0, 255, 0, 255), renderTarget, x, y);
} else {
diff --git a/src/tests/unittests/CommandAllocatorTests.cpp b/src/tests/unittests/CommandAllocatorTests.cpp
index faccdff..8c0bb27 100644
--- a/src/tests/unittests/CommandAllocatorTests.cpp
+++ b/src/tests/unittests/CommandAllocatorTests.cpp
@@ -160,9 +160,11 @@
uint32_t myFirst = 42;
uint32_t myCount = 16;
- CommandDraw* draw = allocator.Allocate<CommandDraw>(CommandType::Draw);
- draw->first = myFirst;
- draw->count = myCount;
+ {
+ CommandDraw* draw = allocator.Allocate<CommandDraw>(CommandType::Draw);
+ draw->first = myFirst;
+ draw->count = myCount;
+ }
{
CommandIterator iterator(std::move(allocator));
@@ -235,7 +237,7 @@
// Stay under max representable uint16_t
const int kCommandCount = 50000;
- int count = 0;
+ uint16_t count = 0;
for (int i = 0; i < kCommandCount; i++) {
CommandSmall* small = allocator.Allocate<CommandSmall>(CommandType::Small);
small->data = count ++;
diff --git a/src/tests/unittests/MathTests.cpp b/src/tests/unittests/MathTests.cpp
index 6fd7446..ae4c783 100644
--- a/src/tests/unittests/MathTests.cpp
+++ b/src/tests/unittests/MathTests.cpp
@@ -63,7 +63,7 @@
char* aligned = Align(unaligned, kTestAlignment);
ASSERT_GE(aligned - unaligned, 0);
- ASSERT_LT(aligned - unaligned, kTestAlignment);
+ ASSERT_LT(static_cast<size_t>(aligned - unaligned), kTestAlignment);
ASSERT_EQ(reinterpret_cast<intptr_t>(aligned) & (kTestAlignment -1), 0);
}
}
diff --git a/src/tests/unittests/validation/ValidationTest.cpp b/src/tests/unittests/validation/ValidationTest.cpp
index dadc600..8f80525 100644
--- a/src/tests/unittests/validation/ValidationTest.cpp
+++ b/src/tests/unittests/validation/ValidationTest.cpp
@@ -51,7 +51,7 @@
ASSERT_TRUE(expectation.gotStatus) << "Didn't get a status for " << name;
- ASSERT_NE(NXT_BUILDER_ERROR_STATUS_UNKNOWN, expectation.gotStatus) << "Got unknown status for " << name;
+ ASSERT_NE(NXT_BUILDER_ERROR_STATUS_UNKNOWN, expectation.status) << "Got unknown status for " << name;
bool wasSuccess = expectation.status == NXT_BUILDER_ERROR_STATUS_SUCCESS;
ASSERT_EQ(expectation.expectSuccess, wasSuccess)
diff --git a/src/utils/D3D12Binding.cpp b/src/utils/D3D12Binding.cpp
index f15fe97..4c4e5e3 100644
--- a/src/utils/D3D12Binding.cpp
+++ b/src/utils/D3D12Binding.cpp
@@ -142,7 +142,6 @@
resourceBarrier.Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE;
commandList->ResourceBarrier(1, &resourceBarrier);
ASSERT_SUCCESS(commandList->Close());
- ID3D12CommandList* commandLists[] = { commandList.Get() };
backend::d3d12::ExecuteCommandLists(backendDevice, { commandList.Get() });
backend::d3d12::NextSerial(backendDevice);
@@ -166,7 +165,6 @@
resourceBarrier.Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE;
commandList->ResourceBarrier(1, &resourceBarrier);
ASSERT_SUCCESS(commandList->Close());
- ID3D12CommandList* commandLists[] = { commandList.Get() };
backend::d3d12::ExecuteCommandLists(backendDevice, { commandList.Get() });
}
@@ -184,7 +182,6 @@
resourceBarrier.Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE;
commandList->ResourceBarrier(1, &resourceBarrier);
ASSERT_SUCCESS(commandList->Close());
- ID3D12CommandList* commandLists[] = { commandList.Get() };
backend::d3d12::ExecuteCommandLists(backendDevice, { commandList.Get() });
}
diff --git a/src/utils/NXTHelpers.cpp b/src/utils/NXTHelpers.cpp
index 595d073..d2f7eca 100644
--- a/src/utils/NXTHelpers.cpp
+++ b/src/utils/NXTHelpers.cpp
@@ -51,7 +51,7 @@
}
size_t size = (result.cend() - result.cbegin());
- builder.SetSource(size, result.cbegin());
+ builder.SetSource(static_cast<uint32_t>(size), result.cbegin());
#ifdef DUMP_SPIRV_ASSEMBLY
{