Fix all Windows warnings

This commit is contained in:
Corentin Wallez 2017-07-10 21:44:06 -04:00 committed by Corentin Wallez
parent 8fca4a21b7
commit 83e779d8f2
22 changed files with 99 additions and 96 deletions

View File

@ -113,12 +113,12 @@ void init() {
shaderData.resize(10000); shaderData.resize(10000);
for (auto& data : shaderData) { for (auto& data : shaderData) {
data.scale = RandomFloat(0.2, 0.4); data.scale = RandomFloat(0.2f, 0.4f);
data.time = 0.0; data.time = 0.0;
data.offsetX = RandomFloat(-0.9, 0.9); data.offsetX = RandomFloat(-0.9f, 0.9f);
data.offsetY = RandomFloat(-0.9, 0.9); data.offsetY = RandomFloat(-0.9f, 0.9f);
data.scalar = RandomFloat(0.5, 2.0); data.scalar = RandomFloat(0.5f, 2.0f);
data.scalarOffset = RandomFloat(0.0, 10.0); data.scalarOffset = RandomFloat(0.0f, 10.0f);
} }
} }

View File

@ -66,7 +66,7 @@ void initBuffers() {
}; };
modelBuffer = utils::CreateFrozenBufferFromData(device, model, sizeof(model), nxt::BufferUsageBit::Vertex); modelBuffer = utils::CreateFrozenBufferFromData(device, model, sizeof(model), nxt::BufferUsageBit::Vertex);
SimParams params = { 0.04, 0.1, 0.025, 0.025, 0.02, 0.05, 0.005, kNumParticles }; SimParams params = { 0.04f, 0.1f, 0.025f, 0.025f, 0.02f, 0.05f, 0.005f, kNumParticles };
updateParams = utils::CreateFrozenBufferFromData(device, &params, sizeof(params), nxt::BufferUsageBit::Uniform); updateParams = utils::CreateFrozenBufferFromData(device, &params, sizeof(params), nxt::BufferUsageBit::Uniform);
std::vector<Particle> initialParticles(kNumParticles); std::vector<Particle> initialParticles(kNumParticles);

View File

@ -257,7 +257,7 @@ void init() {
struct {uint32_t a; float b;} s; struct {uint32_t a; float b;} s;
void frame() { void frame() {
s.a = (s.a + 1) % 256; s.a = (s.a + 1) % 256;
s.b += 0.01; s.b += 0.01f;
if (s.b >= 1.0f) {s.b = 0.0f;} if (s.b >= 1.0f) {s.b = 0.0f;}
static const uint32_t vertexBufferOffsets[1] = {0}; static const uint32_t vertexBufferOffsets[1] = {0};

View File

@ -66,7 +66,7 @@ void initTextures() {
} }
nxt::Buffer stagingBuffer = utils::CreateFrozenBufferFromData(device, data.data(), data.size(), nxt::BufferUsageBit::TransferSrc); nxt::Buffer stagingBuffer = utils::CreateFrozenBufferFromData(device, data.data(), static_cast<uint32_t>(data.size()), nxt::BufferUsageBit::TransferSrc);
nxt::CommandBuffer copy = device.CreateCommandBufferBuilder() nxt::CommandBuffer copy = device.CreateCommandBufferBuilder()
.TransitionTextureUsage(texture, nxt::TextureUsageBit::TransferDst) .TransitionTextureUsage(texture, nxt::TextureUsageBit::TransferDst)
.CopyBufferToTexture(stagingBuffer, 0, texture, 0, 0, 0, 1024, 1024, 1, 0) .CopyBufferToTexture(stagingBuffer, 0, texture, 0, 0, 0, 1024, 1024, 1, 0)
@ -139,7 +139,7 @@ void init() {
struct {uint32_t a; float b;} s; struct {uint32_t a; float b;} s;
void frame() { void frame() {
s.a = (s.a + 1) % 256; s.a = (s.a + 1) % 256;
s.b += 0.02; s.b += 0.02f;
if (s.b >= 1.0f) {s.b = 0.0f;} if (s.b >= 1.0f) {s.b = 0.0f;}
static const uint32_t vertexBufferOffsets[1] = {0}; static const uint32_t vertexBufferOffsets[1] = {0};
nxt::CommandBuffer commands = device.CreateCommandBufferBuilder() nxt::CommandBuffer commands = device.CreateCommandBufferBuilder()

View File

@ -86,7 +86,7 @@ void init() {
void frame() { void frame() {
s.a = (s.a + 1) % 256; s.a = (s.a + 1) % 256;
s.b += 0.02; s.b += 0.02f;
if (s.b >= 1.0f) {s.b = 0.0f;} if (s.b >= 1.0f) {s.b = 0.0f;}
buffer.TransitionUsage(nxt::BufferUsageBit::TransferDst); buffer.TransitionUsage(nxt::BufferUsageBit::TransferDst);

View File

@ -15,6 +15,13 @@
#include "utils/BackendBinding.h" #include "utils/BackendBinding.h"
#include "../src/wire/TerribleCommandBuffer.h" #include "../src/wire/TerribleCommandBuffer.h"
// Include Windows.h before GLFW to avoid a redefinition of APIENTRY
#ifdef _WIN32
#include <Windows.h>
#else
#include <unistd.h>
#endif
#include <nxt/nxt.h> #include <nxt/nxt.h>
#include <nxt/nxtcpp.h> #include <nxt/nxtcpp.h>
#include "GLFW/glfw3.h" #include "GLFW/glfw3.h"
@ -22,12 +29,6 @@
#include <cstring> #include <cstring>
#include <iostream> #include <iostream>
#ifdef _WIN32
#include <Windows.h>
#else
#include <unistd.h>
#endif
void PrintDeviceError(const char* message, nxt::CallbackUserdata) { void PrintDeviceError(const char* message, nxt::CallbackUserdata) {
std::cout << "Device error: " << message << std::endl; std::cout << "Device error: " << message << std::endl;
} }
@ -171,7 +172,7 @@ void DoSwapBuffers() {
#ifdef _WIN32 #ifdef _WIN32
void USleep(uint64_t usecs) { void USleep(uint64_t usecs) {
Sleep(usecs / 1000); Sleep(static_cast<DWORD>(usecs / 1000));
} }
#else #else
void USleep(uint64_t usecs) { void USleep(uint64_t usecs) {

View File

@ -29,11 +29,12 @@
#include <glm/gtc/matrix_transform.hpp> #include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp> #include <glm/gtc/type_ptr.hpp>
#include "GLFW/glfw3.h"
#define TINYGLTF_LOADER_IMPLEMENTATION #define TINYGLTF_LOADER_IMPLEMENTATION
#define STB_IMAGE_IMPLEMENTATION #define STB_IMAGE_IMPLEMENTATION
#include <tinygltfloader/tiny_gltf_loader.h> #include <tinygltfloader/tiny_gltf_loader.h>
#include "GLFW/glfw3.h"
#include "Camera.inl" #include "Camera.inl"
namespace gl { namespace gl {
@ -146,20 +147,20 @@ namespace {
} }
const auto& iBuffer = scene.buffers.at(iBufferView.buffer); const auto& iBuffer = scene.buffers.at(iBufferView.buffer);
uint32_t iBufferViewSize = size_t iBufferViewSize =
iBufferView.byteLength ? iBufferView.byteLength : iBufferView.byteLength ? iBufferView.byteLength :
(iBuffer.data.size() - iBufferView.byteOffset); (iBuffer.data.size() - iBufferView.byteOffset);
auto oBuffer = utils::CreateFrozenBufferFromData(device, &iBuffer.data.at(iBufferView.byteOffset), iBufferViewSize, usage); auto oBuffer = utils::CreateFrozenBufferFromData(device, &iBuffer.data.at(iBufferView.byteOffset), static_cast<uint32_t>(iBufferViewSize), usage);
buffers[iBufferViewID] = std::move(oBuffer); buffers[iBufferViewID] = std::move(oBuffer);
} }
} }
const MaterialInfo& getMaterial(const std::string& iMaterialID, uint32_t stridePos, uint32_t strideNor, uint32_t strideTxc) { const MaterialInfo& getMaterial(const std::string& iMaterialID, size_t stridePos, size_t strideNor, size_t strideTxc) {
static std::map<std::tuple<std::string, uint32_t, uint32_t, uint32_t>, MaterialInfo> materials; static std::map<std::tuple<std::string, size_t, size_t, size_t>, MaterialInfo> materials;
auto key = make_tuple(iMaterialID, stridePos, strideNor, strideTxc); auto key = make_tuple(iMaterialID, stridePos, strideNor, strideTxc);
auto it = materials.find(key); auto materialIterator = materials.find(key);
if (it != materials.end()) { if (materialIterator != materials.end()) {
return it->second; return materialIterator->second;
} }
const auto& iMaterial = scene.materials.at(iMaterialID); const auto& iMaterial = scene.materials.at(iMaterialID);
@ -218,22 +219,22 @@ namespace {
} }
if (iParameter.semantic == "POSITION") { if (iParameter.semantic == "POSITION") {
builder.SetAttribute(0, 0, format, 0); builder.SetAttribute(0, 0, format, 0);
builder.SetInput(0, stridePos, nxt::InputStepMode::Vertex); builder.SetInput(0, static_cast<uint32_t>(stridePos), nxt::InputStepMode::Vertex);
slotsSet.set(0); slotsSet.set(0);
} else if (iParameter.semantic == "NORMAL") { } else if (iParameter.semantic == "NORMAL") {
builder.SetAttribute(1, 1, format, 0); builder.SetAttribute(1, 1, format, 0);
builder.SetInput(1, strideNor, nxt::InputStepMode::Vertex); builder.SetInput(1, static_cast<uint32_t>(strideNor), nxt::InputStepMode::Vertex);
slotsSet.set(1); slotsSet.set(1);
} else if (iParameter.semantic == "TEXCOORD_0") { } else if (iParameter.semantic == "TEXCOORD_0") {
builder.SetAttribute(2, 2, format, 0); builder.SetAttribute(2, 2, format, 0);
builder.SetInput(2, strideTxc, nxt::InputStepMode::Vertex); builder.SetInput(2, static_cast<uint32_t>(strideTxc), nxt::InputStepMode::Vertex);
slotsSet.set(2); slotsSet.set(2);
} else { } else {
fprintf(stderr, "unsupported technique attribute semantic %s\n", iParameter.semantic.c_str()); fprintf(stderr, "unsupported technique attribute semantic %s\n", iParameter.semantic.c_str());
} }
// TODO: use iAttributeParameter.node? // TODO: use iAttributeParameter.node?
} }
for (size_t i = 0; i < slotsSet.size(); i++) { for (uint32_t i = 0; i < slotsSet.size(); i++) {
if (slotsSet[i]) { if (slotsSet[i]) {
continue; continue;
} }
@ -478,7 +479,7 @@ namespace {
glm::inverseTranspose(model), glm::inverseTranspose(model),
}; };
uint32_t strides[3] = {0}; size_t strides[3] = {0};
for (const auto& s : slotSemantics) { for (const auto& s : slotSemantics) {
if (s.first < 3) { if (s.first < 3) {
auto it = iPrim.attributes.find(s.second); auto it = iPrim.attributes.find(s.second);
@ -516,11 +517,11 @@ namespace {
continue; continue;
} }
if (!vertexCount) { if (vertexCount == 0) {
vertexCount = iAccessor.count; vertexCount = static_cast<uint32_t>(iAccessor.count);
} }
const auto& oBuffer = buffers.at(iAccessor.bufferView); const auto& oBuffer = buffers.at(iAccessor.bufferView);
uint32_t iBufferOffset = iAccessor.byteOffset; uint32_t iBufferOffset = static_cast<uint32_t>(iAccessor.byteOffset);
cmd.SetVertexBuffers(slot, 1, &oBuffer, &iBufferOffset); cmd.SetVertexBuffers(slot, 1, &oBuffer, &iBufferOffset);
} }
@ -532,8 +533,8 @@ namespace {
continue; continue;
} }
const auto& oIndicesBuffer = buffers.at(iIndices.bufferView); const auto& oIndicesBuffer = buffers.at(iIndices.bufferView);
cmd.SetIndexBuffer(oIndicesBuffer, iIndices.byteOffset, nxt::IndexFormat::Uint16); cmd.SetIndexBuffer(oIndicesBuffer, static_cast<uint32_t>(iIndices.byteOffset), nxt::IndexFormat::Uint16);
cmd.DrawElements(iIndices.count, 1, 0, 0); cmd.DrawElements(static_cast<uint32_t>(iIndices.count), 1, 0, 0);
} else { } else {
// DrawArrays // DrawArrays
cmd.DrawArrays(vertexCount, 1, 0, 0); cmd.DrawArrays(vertexCount, 1, 0, 0);
@ -592,23 +593,23 @@ namespace {
} }
void cursorPosCallback(GLFWwindow*, double mouseX, double mouseY) { void cursorPosCallback(GLFWwindow*, double mouseX, double mouseY) {
static float oldX, oldY; static double oldX, oldY;
float dX = mouseX - oldX; float dX = static_cast<float>(mouseX - oldX);
float dY = mouseY - oldY; float dY = static_cast<float>(mouseY - oldY);
oldX = mouseX; oldX = mouseX;
oldY = mouseY; oldY = mouseY;
if (buttons[2] || (buttons[0] && buttons[1])) { if (buttons[2] || (buttons[0] && buttons[1])) {
camera.pan(-dX * 0.002, dY * 0.002); camera.pan(-dX * 0.002f, dY * 0.002f);
} else if (buttons[0]) { } else if (buttons[0]) {
camera.rotate(dX * -0.01, dY * 0.01); camera.rotate(dX * -0.01f, dY * 0.01f);
} else if (buttons[1]) { } else if (buttons[1]) {
camera.zoom(dY * -0.005); camera.zoom(dY * -0.005f);
} }
} }
void scrollCallback(GLFWwindow*, double, double yoffset) { void scrollCallback(GLFWwindow*, double, double yoffset) {
camera.zoom(yoffset * 0.04); camera.zoom(static_cast<float>(yoffset) * 0.04f);
} }
} }

View File

@ -110,7 +110,7 @@ namespace backend {
const auto& layoutInfo = layout->GetBindingInfo(); const auto& layoutInfo = layout->GetBindingInfo();
for (size_t i = start, j = 0; i < start + count; ++i, ++j) { 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]) { switch (layoutInfo.types[i]) {
case nxt::BindingType::UniformBuffer: case nxt::BindingType::UniformBuffer:
requiredBit = nxt::BufferUsageBit::Uniform; requiredBit = nxt::BufferUsageBit::Uniform;

View File

@ -71,7 +71,7 @@ namespace backend {
bool ComputeTextureCopyBufferSize(CommandBufferBuilder*, const TextureCopyLocation& location, uint32_t* bufferSize) { bool ComputeTextureCopyBufferSize(CommandBufferBuilder*, const TextureCopyLocation& location, uint32_t* bufferSize) {
// TODO(cwallez@chromium.org): check for overflows // 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; *bufferSize = location.width * location.height * location.depth * pixelSize;
return true; return true;

View File

@ -488,8 +488,7 @@ namespace backend {
break; break;
default: default:
ASSERT(false); UNREACHABLE();
return false;
} }
auto buffer = group->GetBindingAsBufferView(i)->GetBuffer(); auto buffer = group->GetBindingAsBufferView(i)->GetBuffer();
@ -535,13 +534,13 @@ namespace backend {
} }
void CommandBufferStateTracker::UnsetPipeline() { void CommandBufferStateTracker::UnsetPipeline() {
constexpr ValidationAspects pipelineDependentAspectsInverse = constexpr ValidationAspects pipelineDependentAspects =
~(1 << VALIDATION_ASPECT_RENDER_PIPELINE | 1 << VALIDATION_ASPECT_RENDER_PIPELINE |
1 << VALIDATION_ASPECT_COMPUTE_PIPELINE | 1 << VALIDATION_ASPECT_COMPUTE_PIPELINE |
1 << VALIDATION_ASPECT_BIND_GROUPS | 1 << VALIDATION_ASPECT_BIND_GROUPS |
1 << VALIDATION_ASPECT_VERTEX_BUFFERS | 1 << VALIDATION_ASPECT_VERTEX_BUFFERS |
1 << VALIDATION_ASPECT_INDEX_BUFFER); 1 << VALIDATION_ASPECT_INDEX_BUFFER;
aspects &= pipelineDependentAspectsInverse; aspects &= ~pipelineDependentAspects;
bindgroups.fill(nullptr); bindgroups.fill(nullptr);
} }
} }

View File

@ -28,7 +28,7 @@ namespace backend {
} }
uint32_t RenderPassBase::GetAttachmentCount() const { uint32_t RenderPassBase::GetAttachmentCount() const {
return attachments.size(); return static_cast<uint32_t>(attachments.size());
} }
const RenderPassBase::AttachmentInfo& RenderPassBase::GetAttachmentInfo(uint32_t attachment) const { const RenderPassBase::AttachmentInfo& RenderPassBase::GetAttachmentInfo(uint32_t attachment) const {
@ -37,7 +37,7 @@ namespace backend {
} }
uint32_t RenderPassBase::GetSubpassCount() const { uint32_t RenderPassBase::GetSubpassCount() const {
return subpasses.size(); return static_cast<uint32_t>(subpasses.size());
} }
const RenderPassBase::SubpassInfo& RenderPassBase::GetSubpassInfo(uint32_t subpass) const { const RenderPassBase::SubpassInfo& RenderPassBase::GetSubpassInfo(uint32_t subpass) const {

View File

@ -273,7 +273,8 @@ namespace d3d12 {
D3D12_RECT scissorRect = { 0, 0, static_cast<long>(width), static_cast<long>(height) }; D3D12_RECT scissorRect = { 0, 0, static_cast<long>(width), static_cast<long>(height) };
commandList->RSSetViewports(1, &viewport); commandList->RSSetViewports(1, &viewport);
commandList->RSSetScissorRects(1, &scissorRect); 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; break;
@ -381,7 +382,7 @@ namespace d3d12 {
case Command::EndRenderPass: case Command::EndRenderPass:
{ {
EndRenderPassCmd* cmd = commands.NextCommand<EndRenderPassCmd>(); commands.NextCommand<EndRenderPassCmd>();
} }
break; break;
@ -426,13 +427,13 @@ namespace d3d12 {
case Command::SetPushConstants: case Command::SetPushConstants:
{ {
SetPushConstantsCmd* cmd = commands.NextCommand<SetPushConstantsCmd>(); commands.NextCommand<SetPushConstantsCmd>();
} }
break; break;
case Command::SetStencilReference: case Command::SetStencilReference:
{ {
SetStencilReferenceCmd* cmd = commands.NextCommand<SetStencilReferenceCmd>(); commands.NextCommand<SetStencilReferenceCmd>();
} }
break; break;

View File

@ -200,10 +200,10 @@ namespace d3d12 {
pendingCommands.open = false; pendingCommands.open = false;
lists[0] = pendingCommands.commandList.Get(); lists[0] = pendingCommands.commandList.Get();
std::copy(commandLists.begin(), commandLists.end(), lists.begin() + 1); 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 { } else {
std::vector<ID3D12CommandList*> lists(commandLists); std::vector<ID3D12CommandList*> lists(commandLists);
commandQueue->ExecuteCommandLists(commandLists.size(), lists.data()); commandQueue->ExecuteCommandLists(static_cast<UINT>(commandLists.size()), lists.data());
} }
} }

View File

@ -14,6 +14,8 @@
#include "backend/d3d12/InputStateD3D12.h" #include "backend/d3d12/InputStateD3D12.h"
#include "common/BitSetIterator.h"
namespace backend { namespace backend {
namespace d3d12 { namespace d3d12 {
@ -48,8 +50,8 @@ namespace d3d12 {
const auto& attributesSetMask = GetAttributesSetMask(); const auto& attributesSetMask = GetAttributesSetMask();
size_t count = 0; unsigned int count = 0;
for (size_t i = 0; i < attributesSetMask.size(); ++i) { for (auto i : IterateBitSet(attributesSetMask)) {
if (!attributesSetMask[i]) { if (!attributesSetMask[i]) {
continue; continue;
} }
@ -60,7 +62,7 @@ namespace d3d12 {
// If the HLSL semantic is TEXCOORDN the SemanticName should be "TEXCOORD" and the SemanticIndex N // If the HLSL semantic is TEXCOORDN the SemanticName should be "TEXCOORD" and the SemanticIndex N
inputElementDescriptor.SemanticName = "TEXCOORD"; inputElementDescriptor.SemanticName = "TEXCOORD";
inputElementDescriptor.SemanticIndex = i; inputElementDescriptor.SemanticIndex = static_cast<uint32_t>(i);
inputElementDescriptor.Format = VertexFormatType(attribute.format); inputElementDescriptor.Format = VertexFormatType(attribute.format);
inputElementDescriptor.InputSlot = attribute.bindingSlot; inputElementDescriptor.InputSlot = attribute.bindingSlot;

View File

@ -89,8 +89,8 @@ namespace d3d12 {
resourceDescriptor.Alignment = 0; resourceDescriptor.Alignment = 0;
resourceDescriptor.Width = GetWidth(); resourceDescriptor.Width = GetWidth();
resourceDescriptor.Height = GetHeight(); resourceDescriptor.Height = GetHeight();
resourceDescriptor.DepthOrArraySize = GetDepth(); resourceDescriptor.DepthOrArraySize = static_cast<UINT16>(GetDepth());
resourceDescriptor.MipLevels = GetNumMipLevels(); resourceDescriptor.MipLevels = static_cast<UINT16>(GetNumMipLevels());
resourceDescriptor.Format = D3D12TextureFormat(GetFormat()); resourceDescriptor.Format = D3D12TextureFormat(GetFormat());
resourceDescriptor.SampleDesc.Count = 1; resourceDescriptor.SampleDesc.Count = 1;
resourceDescriptor.SampleDesc.Quality = 0; resourceDescriptor.SampleDesc.Quality = 0;

View File

@ -243,10 +243,10 @@ namespace opengl {
case Command::SetBindGroup: case Command::SetBindGroup:
{ {
SetBindGroupCmd* cmd = commands.NextCommand<SetBindGroupCmd>(); SetBindGroupCmd* cmd = commands.NextCommand<SetBindGroupCmd>();
size_t index = cmd->index; size_t groupIndex = cmd->index;
BindGroup* group = ToBackend(cmd->group.Get()); 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(); const auto& layout = group->GetLayout()->GetBindingInfo();
// TODO(cwallez@chromium.org): iterate over the layout bitmask instead // TODO(cwallez@chromium.org): iterate over the layout bitmask instead
@ -260,18 +260,18 @@ namespace opengl {
{ {
BufferView* view = ToBackend(group->GetBindingAsBufferView(binding)); BufferView* view = ToBackend(group->GetBindingAsBufferView(binding));
GLuint buffer = ToBackend(view->GetBuffer())->GetHandle(); 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; break;
case nxt::BindingType::Sampler: case nxt::BindingType::Sampler:
{ {
GLuint sampler = ToBackend(group->GetBindingAsSampler(binding))->GetHandle(); 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); glBindSampler(unit, sampler);
} }
} }
@ -283,9 +283,9 @@ namespace opengl {
Texture* texture = ToBackend(view->GetTexture()); Texture* texture = ToBackend(view->GetTexture());
GLuint handle = texture->GetHandle(); GLuint handle = texture->GetHandle();
GLenum target = texture->GetGLTarget(); 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); glActiveTexture(GL_TEXTURE0 + unit);
glBindTexture(target, handle); glBindTexture(target, handle);
} }
@ -296,9 +296,9 @@ namespace opengl {
{ {
BufferView* view = ToBackend(group->GetBindingAsBufferView(binding)); BufferView* view = ToBackend(group->GetBindingAsBufferView(binding));
GLuint buffer = ToBackend(view->GetBuffer())->GetHandle(); 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; break;
} }

View File

@ -28,9 +28,9 @@ using nxt::VertexFormat;
// The predetermined values are "K * gl_VertexID + componentIndex" for vertex-indexed buffers, and // The predetermined values are "K * gl_VertexID + componentIndex" for vertex-indexed buffers, and
// "K * gl_InstanceID + componentIndex" for instance-indexed buffers. // "K * gl_InstanceID + componentIndex" for instance-indexed buffers.
constexpr static int kRTSize = 400; constexpr static unsigned int kRTSize = 400;
constexpr static int kRTCellOffset = 50; constexpr static unsigned int kRTCellOffset = 50;
constexpr static int kRTCellSize = 100; constexpr static unsigned int kRTCellSize = 100;
class InputStateTest : public NXTTest { class InputStateTest : public NXTTest {
protected: protected:
@ -175,7 +175,7 @@ class InputStateTest : public NXTTest {
template<typename T> template<typename T>
nxt::Buffer MakeVertexBuffer(std::vector<T> data) { 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 { struct DrawVertexBuffer {
@ -183,8 +183,8 @@ class InputStateTest : public NXTTest {
nxt::Buffer* buffer; nxt::Buffer* buffer;
}; };
void DoTestDraw(const nxt::Pipeline& pipeline, unsigned int triangles, unsigned int instances, std::vector<DrawVertexBuffer> vertexBuffers) { void DoTestDraw(const nxt::Pipeline& pipeline, unsigned int triangles, unsigned int instances, std::vector<DrawVertexBuffer> vertexBuffers) {
EXPECT_LE(triangles, 4); EXPECT_LE(triangles, 4u);
EXPECT_LE(instances, 4); EXPECT_LE(instances, 4u);
nxt::CommandBufferBuilder builder = device.CreateCommandBufferBuilder(); nxt::CommandBufferBuilder builder = device.CreateCommandBufferBuilder();
@ -207,10 +207,10 @@ class InputStateTest : public NXTTest {
// Check that the center of each triangle is pure green, so that if a single vertex shader // 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. // instance fails, linear interpolation makes the pixel check fail.
for (size_t triangle = 0; triangle < 4; triangle++) { for (unsigned int triangle = 0; triangle < 4; triangle++) {
for (size_t instance = 0; instance < 4; instance++) { for (unsigned int instance = 0; instance < 4; instance++) {
int x = kRTCellOffset + kRTCellSize * triangle; unsigned int x = kRTCellOffset + kRTCellSize * triangle;
int y = kRTCellOffset + kRTCellSize * instance; unsigned int y = kRTCellOffset + kRTCellSize * instance;
if (triangle < triangles && instance < instances) { if (triangle < triangles && instance < instances) {
EXPECT_PIXEL_RGBA8_EQ(RGBA8(0, 255, 0, 255), renderTarget, x, y); EXPECT_PIXEL_RGBA8_EQ(RGBA8(0, 255, 0, 255), renderTarget, x, y);
} else { } else {

View File

@ -160,9 +160,11 @@ TEST(CommandAllocator, MultipleIterations) {
uint32_t myFirst = 42; uint32_t myFirst = 42;
uint32_t myCount = 16; uint32_t myCount = 16;
{
CommandDraw* draw = allocator.Allocate<CommandDraw>(CommandType::Draw); CommandDraw* draw = allocator.Allocate<CommandDraw>(CommandType::Draw);
draw->first = myFirst; draw->first = myFirst;
draw->count = myCount; draw->count = myCount;
}
{ {
CommandIterator iterator(std::move(allocator)); CommandIterator iterator(std::move(allocator));
@ -235,7 +237,7 @@ TEST(CommandAllocator, ManySmallCommands) {
// Stay under max representable uint16_t // Stay under max representable uint16_t
const int kCommandCount = 50000; const int kCommandCount = 50000;
int count = 0; uint16_t count = 0;
for (int i = 0; i < kCommandCount; i++) { for (int i = 0; i < kCommandCount; i++) {
CommandSmall* small = allocator.Allocate<CommandSmall>(CommandType::Small); CommandSmall* small = allocator.Allocate<CommandSmall>(CommandType::Small);
small->data = count ++; small->data = count ++;

View File

@ -63,7 +63,7 @@ TEST(Math, Align) {
char* aligned = Align(unaligned, kTestAlignment); char* aligned = Align(unaligned, kTestAlignment);
ASSERT_GE(aligned - unaligned, 0); 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); ASSERT_EQ(reinterpret_cast<intptr_t>(aligned) & (kTestAlignment -1), 0);
} }
} }

View File

@ -51,7 +51,7 @@ void ValidationTest::TearDown() {
ASSERT_TRUE(expectation.gotStatus) << "Didn't get a status for " << name; 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; bool wasSuccess = expectation.status == NXT_BUILDER_ERROR_STATUS_SUCCESS;
ASSERT_EQ(expectation.expectSuccess, wasSuccess) ASSERT_EQ(expectation.expectSuccess, wasSuccess)

View File

@ -142,7 +142,6 @@ namespace utils {
resourceBarrier.Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE; resourceBarrier.Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE;
commandList->ResourceBarrier(1, &resourceBarrier); commandList->ResourceBarrier(1, &resourceBarrier);
ASSERT_SUCCESS(commandList->Close()); ASSERT_SUCCESS(commandList->Close());
ID3D12CommandList* commandLists[] = { commandList.Get() };
backend::d3d12::ExecuteCommandLists(backendDevice, { commandList.Get() }); backend::d3d12::ExecuteCommandLists(backendDevice, { commandList.Get() });
backend::d3d12::NextSerial(backendDevice); backend::d3d12::NextSerial(backendDevice);
@ -166,7 +165,6 @@ namespace utils {
resourceBarrier.Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE; resourceBarrier.Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE;
commandList->ResourceBarrier(1, &resourceBarrier); commandList->ResourceBarrier(1, &resourceBarrier);
ASSERT_SUCCESS(commandList->Close()); ASSERT_SUCCESS(commandList->Close());
ID3D12CommandList* commandLists[] = { commandList.Get() };
backend::d3d12::ExecuteCommandLists(backendDevice, { commandList.Get() }); backend::d3d12::ExecuteCommandLists(backendDevice, { commandList.Get() });
} }
@ -184,7 +182,6 @@ namespace utils {
resourceBarrier.Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE; resourceBarrier.Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE;
commandList->ResourceBarrier(1, &resourceBarrier); commandList->ResourceBarrier(1, &resourceBarrier);
ASSERT_SUCCESS(commandList->Close()); ASSERT_SUCCESS(commandList->Close());
ID3D12CommandList* commandLists[] = { commandList.Get() };
backend::d3d12::ExecuteCommandLists(backendDevice, { commandList.Get() }); backend::d3d12::ExecuteCommandLists(backendDevice, { commandList.Get() });
} }

View File

@ -51,7 +51,7 @@ namespace utils {
} }
size_t size = (result.cend() - result.cbegin()); 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 #ifdef DUMP_SPIRV_ASSEMBLY
{ {