Fix compilation errors and warnings

This commit is contained in:
Jérôme Leclercq 2021-07-07 22:16:22 +02:00
parent 1f6937ab1b
commit 309fd547e1
14 changed files with 38 additions and 30 deletions

View File

@ -130,7 +130,7 @@ int main()
std::vector<GLint> uniformIndices = program.GetActiveUniformBlockUniformIndices(blockIndex);
std::vector<GLint> offsets = program.GetActiveUniforms(uniformIndices.size(), reinterpret_cast<GLuint*>(uniformIndices.data()), GL_UNIFORM_OFFSET);
std::vector<GLint> offsets = program.GetActiveUniforms(GLsizei(uniformIndices.size()), reinterpret_cast<GLuint*>(uniformIndices.data()), GL_UNIFORM_OFFSET);
auto p = SortIndexes(offsets, std::less<std::size_t>());

View File

@ -4,6 +4,7 @@
#include <Nazara/OpenGLRenderer/Wrapper/DeviceObject.hpp>
#include <Nazara/Core/Error.hpp>
#include <Nazara/OpenGLRenderer/OpenGLDevice.hpp>
#include <Nazara/OpenGLRenderer/Utils.hpp>
#include <Nazara/OpenGLRenderer/Debug.hpp>

View File

@ -910,7 +910,7 @@ namespace Nz
bufferBits = bufferPos = 0; // reset buffer
}
buffer[bufferPos] = b << (8 - bufferRem);
buffer[bufferPos] = static_cast<UInt8>(b << (8 - bufferRem));
bufferBits += bufferRem;
// proceed to remaining data
@ -945,7 +945,7 @@ namespace Nz
bufferBits = bufferPos = 0; // reset buffer
}
buffer[bufferPos] = b << (8 - bufferRem);
buffer[bufferPos] = UInt8(b << (8 - bufferRem));
bufferBits += len;
}

View File

@ -330,7 +330,7 @@ namespace Nz
if (value > 65535) // must be 16 bit quantity
return false;
*(resultPtr++) = value >> 8;
*(resultPtr++) = static_cast<UInt8>(value >> 8);
*(resultPtr++) = value & 0xFF;
if (*addressPtr == ':') // typical case inside; carry on

View File

@ -831,7 +831,7 @@ namespace Nz
command.header.channelID = acknowledgement.command.header.channelID;
command.header.reliableSequenceNumber = reliableSequenceNumber;
command.acknowledge.receivedReliableSequenceNumber = reliableSequenceNumber;
command.acknowledge.receivedSentTime = HostToNet<UInt16>(acknowledgement.sentTime);
command.acknowledge.receivedSentTime = HostToNet(UInt16(acknowledgement.sentTime));
if ((acknowledgement.command.header.command & ENetProtocolCommand_Mask) == ENetProtocolCommand_Disconnect)
peer->DispatchState(ENetPeerState::Zombie);
@ -1219,7 +1219,7 @@ namespace Nz
void ENetHost::ThrottleBandwidth()
{
UInt32 currentTime = GetElapsedMilliseconds();
UInt32 currentTime = UInt32(GetElapsedMilliseconds());
UInt32 elapsedTime = currentTime - m_bandwidthThrottleEpoch;
if (elapsedTime < ENetConstants::ENetHost_BandwidthThrottleInterval)
@ -1230,8 +1230,8 @@ namespace Nz
if (m_connectedPeers == 0)
return;
UInt32 dataTotal = ~0;
UInt32 bandwidth = ~0;
UInt32 dataTotal = ~UInt32(0);
UInt32 bandwidth = ~UInt32(0);
if (m_outgoingBandwidth != 0)
{
@ -1248,8 +1248,8 @@ namespace Nz
}
UInt32 peersRemaining = m_connectedPeers;
UInt32 bandwidthLimit = ~0;
UInt32 throttle = ~0;
UInt32 bandwidthLimit = ~UInt32(0);
UInt32 throttle = ~UInt32(0);
bool needsAdjustment = m_bandwidthLimitedPeers > 0;
while (peersRemaining > 0 && needsAdjustment)

View File

@ -267,7 +267,7 @@ namespace Nz
command.sendUnreliable.dataLength = HostToNet(UInt16(packetRef->data.GetDataSize()));
}
QueueOutgoingCommand(command, packetRef, 0, packetSize);
QueueOutgoingCommand(command, packetRef, 0, UInt16(packetSize));
return true;
}
@ -355,7 +355,7 @@ namespace Nz
channel.incomingReliableSequenceNumber = incomingCommand.reliableSequenceNumber;
if (incomingCommand.fragments.GetSize() > 0)
channel.incomingReliableSequenceNumber += incomingCommand.fragments.GetSize() - 1;
channel.incomingReliableSequenceNumber += static_cast<UInt16>(incomingCommand.fragments.GetSize() - 1);
}
if (currentCommand == channel.incomingReliableCommands.begin())
@ -608,7 +608,7 @@ namespace Nz
ENetPeer::Channel& channel = m_channels[command->header.channelID];
UInt32 startSequenceNumber = NetToHost(command->sendFragment.startSequenceNumber);
UInt16 startWindow = startSequenceNumber / ENetConstants::ENetPeer_ReliableWindowSize;
UInt16 startWindow = UInt16(startSequenceNumber / ENetConstants::ENetPeer_ReliableWindowSize);
UInt16 currentWindow = channel.incomingReliableSequenceNumber / ENetConstants::ENetPeer_ReliableWindowSize;
if (startSequenceNumber < channel.incomingReliableSequenceNumber)
@ -656,7 +656,7 @@ namespace Nz
if (!startCommand)
{
ENetProtocol hostCommand = *command;
hostCommand.header.reliableSequenceNumber = startSequenceNumber;
hostCommand.header.reliableSequenceNumber = static_cast<UInt16>(startSequenceNumber);
startCommand = QueueIncomingCommand(hostCommand, nullptr, totalLength, ENetPacketFlag_Reliable, fragmentCount);
if (!startCommand)
@ -727,7 +727,7 @@ namespace Nz
UInt32 reliableSequenceNumber = command->header.reliableSequenceNumber;
UInt32 startSequenceNumber = NetToHost(command->sendFragment.startSequenceNumber);
UInt16 reliableWindow = reliableSequenceNumber / ENetConstants::ENetPeer_ReliableWindowSize;
UInt16 reliableWindow = UInt16(reliableSequenceNumber / ENetConstants::ENetPeer_ReliableWindowSize);
UInt16 currentWindow = channel.incomingReliableSequenceNumber / ENetConstants::ENetPeer_ReliableWindowSize;
if (startSequenceNumber < channel.incomingReliableSequenceNumber)
@ -829,7 +829,7 @@ namespace Nz
if (unsequencedGroup - index != m_incomingUnsequencedGroup)
{
m_incomingUnsequencedGroup = unsequencedGroup - index;
m_incomingUnsequencedGroup = static_cast<UInt16>(unsequencedGroup - index);
m_unsequencedWindow.fill(0);
}
@ -1120,7 +1120,7 @@ namespace Nz
if ((command.header.command & ENetProtocolCommand_Mask) != ENetProtocolCommand_SendUnsequenced)
{
reliableSequenceNumber = command.header.reliableSequenceNumber;
reliableWindow = reliableSequenceNumber / ENetConstants::ENetPeer_ReliableWindowSize;
reliableWindow = static_cast<UInt16>(reliableSequenceNumber / ENetConstants::ENetPeer_ReliableWindowSize);
currentWindow = channel.incomingReliableSequenceNumber / ENetConstants::ENetPeer_ReliableWindowSize;
if (reliableSequenceNumber < channel.incomingReliableSequenceNumber)
@ -1225,7 +1225,7 @@ namespace Nz
if (m_totalWaitingData >= m_host->m_maximumWaitingData)
return nullptr;
ENetPacketRef packet = m_host->AllocatePacket(flags);
ENetPacketRef packet = m_host->AllocatePacket(ENetPacketFlags(flags));
packet->data.Reset(0, data, dataLength);
IncomingCommmand incomingCommand;

View File

@ -264,8 +264,8 @@ namespace Nz
for (unsigned int i = 0; i < 8; ++i)
{
u_short addressPart = htons(address[i]);
socketAddress->sin6_addr.s6_addr[i * 2 + 0] = addressPart >> 0;
socketAddress->sin6_addr.s6_addr[i * 2 + 1] = addressPart >> 8;
socketAddress->sin6_addr.s6_addr[i * 2 + 0] = static_cast<UCHAR>(addressPart >> 0);
socketAddress->sin6_addr.s6_addr[i * 2 + 1] = static_cast<UCHAR>(addressPart >> 8);
}
return sizeof(sockaddr_in6);

View File

@ -452,7 +452,7 @@ namespace Nz
#endif
}
SocketState SocketImpl::PollConnection(SocketHandle handle, const IpAddress& address, UInt64 msTimeout, SocketError* error)
SocketState SocketImpl::PollConnection(SocketHandle handle, const IpAddress& /*address*/, UInt64 msTimeout, SocketError* error)
{
// Wait until socket is available for writing or an error occurs (ie when connection succeeds or fails)
WSAPOLLFD descriptor;

View File

@ -126,6 +126,9 @@ namespace Nz
const auto& attachmentInfo = command.renderpass->GetAttachment(i);
switch (PixelFormatInfo::GetContent(attachmentInfo.format))
{
case PixelFormatContent::Undefined:
break;
case PixelFormatContent::ColorRGBA:
colorIndexes[colorIndex++] = i;
break;
@ -139,6 +142,12 @@ namespace Nz
if (!depthStencilIndex)
depthStencilIndex = i;
break;
case PixelFormatContent::Stencil:
//FIXME: I'm not sure stencil is properly handled here
if (!depthStencilIndex)
depthStencilIndex = i;
break;
}
}
@ -164,7 +173,7 @@ namespace Nz
context->glClearBufferfv(GL_COLOR, GLint(i), clearColor.data());
}
else if (attachmentInfo.loadOp == AttachmentLoadOp::Discard)
invalidateAttachments.push_back(GL_COLOR_ATTACHMENT0 + i);
invalidateAttachments.push_back(static_cast<GLenum>(GL_COLOR_ATTACHMENT0 + i));
}
if (depthStencilIndex)
@ -210,7 +219,6 @@ namespace Nz
if (colorIndex > 0)
{
std::size_t colorBufferCount = command.framebuffer->GetColorBufferCount();
assert(colorBufferCount <= 1);
std::size_t colorAttachmentIndex = colorIndexes.front();

View File

@ -35,14 +35,14 @@ namespace Nz
return RenderFrame(m_renderImage[m_currentFrame].get(), invalidateFramebuffer, m_size, 0);
}
bool OpenGLRenderWindow::Create(RendererImpl* renderer, RenderSurface* surface, const RenderWindowParameters& parameters)
bool OpenGLRenderWindow::Create(RendererImpl* /*renderer*/, RenderSurface* surface, const RenderWindowParameters& parameters)
{
DummySurface* dummySurface = static_cast<DummySurface*>(surface);
OpenGLRenderer* glRenderer = static_cast<OpenGLRenderer*>(renderer);
OpenGLDevice& device = static_cast<OpenGLDevice&>(*m_owner.GetRenderDevice());
GL::ContextParams contextParams;
//TODO: Pass render window parameters to context
m_context = device.CreateContext(contextParams, dummySurface->GetWindowHandle());
if (!m_context)

View File

@ -53,7 +53,7 @@ namespace Nz
return m_device;
}
bool OpenGLRenderer::Prepare(const ParameterList& parameters)
bool OpenGLRenderer::Prepare(const ParameterList& /*parameters*/)
{
std::unique_ptr<GL::Loader> loader = SelectLoader();
if (!loader)

View File

@ -4,7 +4,6 @@
#include <Nazara/Shader/Ast/AstRecursiveVisitor.hpp>
#include <Nazara/Shader/Debug.hpp>
#include "..\..\..\..\include\Nazara\Shader\Ast\AstRecursiveVisitor.hpp"
namespace Nz::ShaderAst
{

View File

@ -551,7 +551,6 @@ namespace Nz::ShaderAst
#define NAZARA_SHADERAST_STATEMENT(Node) case NodeType:: Node : node = std::make_unique<Node>(); break;
#include <Nazara/Shader/Ast/AstNodeList.hpp>
#include "..\..\..\..\include\Nazara\Shader\Ast\AstSerializer.hpp"
default: throw std::runtime_error("unexpected node type");
}

View File

@ -19,7 +19,8 @@ namespace Nz
m_device(device),
m_params(params)
{
VkImageCreateInfo createInfo = { VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO };
VkImageCreateInfo createInfo = {};
createInfo.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO;
createInfo.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
createInfo.mipLevels = params.mipmapLevel;
createInfo.samples = VK_SAMPLE_COUNT_1_BIT;
@ -207,7 +208,7 @@ namespace Nz
VK_IMAGE_ASPECT_COLOR_BIT,
0, //< mipLevel
0, //< baseArrayLayer
(m_params.type == ImageType::Cubemap) ? 6 : 1 //< layerCount
UInt32((m_params.type == ImageType::Cubemap) ? 6 : 1) //< layerCount
};
VkImageSubresourceRange subresourceRange = { //< FIXME