Skip to content

Commit

Permalink
Fix warnings found by compiling with MS VC++ 2019
Browse files Browse the repository at this point in the history
This change resolves all found warnings including 'nodiscard'
warnings mentioned in the issue description.

Components: Vulkan, OpenGL, EGL

VK-GL-CTS public issue: 188

Affects:
*

Change-Id: I962f02a1a7e55dcc5141e1cbdf2497482972e02a
  • Loading branch information
piby authored and alegal-arm committed May 21, 2020
1 parent edacd4a commit eaa9608
Show file tree
Hide file tree
Showing 16 changed files with 25 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1067,7 +1067,7 @@ tcu::TestNode::IterateResult RenderbufferCase::iterate(void)
GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram");

float mvpMatrix[16];
constructOrthoProjMatrix(mvpMatrix, 0.0, m_renderWidth, 0.0f, m_renderHeight, 1.0f, -1.0f);
constructOrthoProjMatrix(mvpMatrix, 0.0, w, 0.0f, h, 1.0f, -1.0f);
GLint mvpUniformLocation = gl.getUniformLocation(programs[loop]->getProgram(), "mvpMatrix");
gl.uniformMatrix4fv(mvpUniformLocation, 1, 0, mvpMatrix);

Expand Down
2 changes: 1 addition & 1 deletion external/openglcts/modules/common/glcPackedPixelsTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -948,7 +948,7 @@ void RectangleTest::applyInitialStorageModes()

void RectangleTest::swapBytes(int typeSize, std::vector<GLbyte>& dataBuffer)
{
int bufferSize = dataBuffer.size();
int bufferSize = static_cast<int>(dataBuffer.size());
switch (typeSize)
{
case 1:
Expand Down
1 change: 0 additions & 1 deletion external/openglcts/modules/common/glcShaderLibraryCase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ class ShaderCase : public tcu::TestCase
ValueBlock(void)
{
arrayLength = 0;
values.empty();
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -524,8 +524,8 @@ tcu::TestNode::IterateResult TextureFilterAnisotropicDrawingTestCase::iterate()
if (!result)
{
// Stop loops
iTarget = m_supportedTargets.size();
iFormat = m_supportedInternalFormats.size();
iTarget = static_cast<deUint32>(m_supportedTargets.size());
iFormat = static_cast<deUint32>(m_supportedInternalFormats.size());
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion external/openglcts/modules/gl/gl3cTextureSizePromotion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ tcu::TestNode::IterateResult FunctionalTest::iterate()
{
prepareSourceTexture(s_formats[i], s_source_texture_targets[j]);
}
catch (tcu::NotSupportedError& e)
catch (tcu::NotSupportedError&)
{
continue;
}
Expand Down
8 changes: 4 additions & 4 deletions external/openglcts/modules/gl/gl4cGlSpirvTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ ShaderBinary readSpirV(tcu::Resource* resource)
}

binary.binary.resize((resource->getSize() - resource->getPosition()) / sizeof(deUint32));
resource->read((deUint8*)binary.binary.data(), binary.binary.size() * sizeof(deUint32));
resource->read((deUint8*)binary.binary.data(), static_cast<deUint32>(binary.binary.size()) * sizeof(deUint32));

return binary;
}
Expand Down Expand Up @@ -793,7 +793,7 @@ tcu::TestNode::IterateResult SpirvModulesStateQueriesTest::iterate()

// 4) Check if ShaderSource command usage on Spir-V binary shader will change SPIR_V_BINARY_ARB state to FALSE
const char* source = m_vertex.c_str();
const int length = m_vertex.length();
const int length = static_cast<int>(m_vertex.length());
gl.shaderSource(shader->getShader(), 1, &source, &length);
GLU_EXPECT_NO_ERROR(gl.getError(), "shaderSource");

Expand Down Expand Up @@ -881,7 +881,7 @@ tcu::TestNode::IterateResult SpirvModulesErrorVerificationTest::iterate()
const Functions& gl = m_context.getRenderContext().getFunctions();

const char* shaderSrc = m_vertex.c_str();
const int shaderLen = m_vertex.length();
const int shaderLen = static_cast<int>(m_vertex.length());

ShaderBinary vertexBinary;

Expand All @@ -891,7 +891,7 @@ tcu::TestNode::IterateResult SpirvModulesErrorVerificationTest::iterate()
GLU_EXPECT_NO_ERROR(gl.getError(), "shaderSource");

gl.shaderBinary(1, &m_spirvShaderId, GL_SHADER_BINARY_FORMAT_SPIR_V_ARB, (GLvoid*)vertexBinary.binary.data(),
vertexBinary.binary.size() * sizeof(deUint32));
static_cast<deUint32>(vertexBinary.binary.size()) * sizeof(deUint32));
GLU_EXPECT_NO_ERROR(gl.getError(), "shaderBinary");

gl.attachShader(m_programId, m_spirvShaderId);
Expand Down
2 changes: 1 addition & 1 deletion external/openglcts/modules/gl/gl4cShaderBallotTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ const char* const* ShaderBallotBaseTestCase::ShaderPipeline::getShaderParts(glu:

unsigned int ShaderBallotBaseTestCase::ShaderPipeline::getShaderPartsCount(glu::ShaderType shaderType) const
{
return m_shaders[shaderType].size();
return static_cast<unsigned int>(m_shaders[shaderType].size());
}

void ShaderBallotBaseTestCase::ShaderPipeline::renderQuad(deqp::Context& context)
Expand Down
6 changes: 0 additions & 6 deletions external/openglcts/modules/gles31/es31cArrayOfArraysTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7176,9 +7176,6 @@ void InteractionUniformBuffers3<API>::test_shader_compilation(
shader_source += " " + var_iterator->second.type +
invalid_size_declarations[invalid_size_declarations_index] +
" my_variable = " + array_initializers[var_type_index];

var_iterator->second.type + invalid_size_declarations[invalid_size_declarations_index] +
" my_variable = " + array_initializers[var_type_index];
shader_source += "};\n\n";
shader_source += shader_start;

Expand Down Expand Up @@ -7630,9 +7627,6 @@ void InteractionStorageBuffers3<API>::test_shader_compilation(
shader_source += " " + var_iterator->second.type +
invalid_size_declarations[invalid_size_declarations_index] +
" my_variable = " + array_initializers[var_type_index];

var_iterator->second.type + invalid_size_declarations[invalid_size_declarations_index] +
" my_variable = " + array_initializers[var_type_index];
shader_source += "};\n\n";
shader_source += shader_start;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4027,9 +4027,10 @@ tcu::TestStatus testAndroidHardwareBufferImageFormat (Context& context, vk::VkF
vk::VK_IMAGE_TILING_LINEAR,
};
deUint64 mustSupportAhbUsageFlags = ahbApi->mustSupportAhbUsageFlags();
const size_t one = 1u;
const size_t numOfUsageFlags = DE_LENGTH_OF_ARRAY(usageFlags);
const size_t numOfCreateFlags = DE_LENGTH_OF_ARRAY(createFlags);
const size_t numOfFlagCombos = 1u << (numOfUsageFlags + numOfCreateFlags);
const size_t numOfFlagCombos = one << (numOfUsageFlags + numOfCreateFlags);
const size_t numOfTilings = DE_LENGTH_OF_ARRAY(tilings);

for (size_t combo = 0; combo < numOfFlagCombos; combo++)
Expand All @@ -4040,15 +4041,15 @@ tcu::TestStatus testAndroidHardwareBufferImageFormat (Context& context, vk::VkF
bool enableMaxLayerTest = true;
for (size_t usageNdx = 0; usageNdx < numOfUsageFlags; usageNdx++)
{
if ((combo & (1u << usageNdx)) == 0)
if ((combo & (one << usageNdx)) == 0)
continue;
usage |= usageFlags[usageNdx];
requiredAhbUsage |= ahbApi->vkUsageToAhbUsage(usageFlags[usageNdx]);
}
for (size_t createFlagNdx = 0; createFlagNdx < numOfCreateFlags; createFlagNdx++)
{
const size_t bit = numOfUsageFlags + createFlagNdx;
if ((combo & (1u << bit)) == 0)
if ((combo & (one << bit)) == 0)
continue;
if (((createFlags[createFlagNdx] & vk::VK_IMAGE_CREATE_PROTECTED_BIT) == vk::VK_IMAGE_CREATE_PROTECTED_BIT ) &&
(protectedFeatures.protectedMemory == VK_FALSE))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1309,7 +1309,7 @@ tcu::TestStatus DepthBoundsRangeUnrestrictedTestInstance::verifyTestResult (bool
if (isFloatingPointDepthFormat(m_param.depthFormat) == VK_FALSE)
depth = de::min(de::max(depth, 0.0f), 1.0f);

long i = vertex - m_vertices.begin();
auto i = vertex - m_vertices.begin();

// Depending if the first draw call succeed, we need to know if the second draw call will render the points because the depth buffer content
// will determine if it passes the depth test and the depth bounds test.
Expand Down Expand Up @@ -1379,7 +1379,7 @@ tcu::TestStatus DepthBoundsRangeUnrestrictedTestInstance::verifyTestResult (bool
float scaling = (vertex->position.z() / vertex->position.w()) * (m_param.viewportMaxDepth - m_param.viewportMinDepth) + m_param.viewportMinDepth;
float expectedDepth = de::min(de::max(scaling, m_param.viewportMinDepth), m_param.viewportMaxDepth);

long i = vertex - m_vertices.begin();
auto i = vertex - m_vertices.begin();

// Depending if the first draw call succeed, we need to know if the second draw call will render the points because the depth buffer content
// will determine if it passes the depth test and the depth bounds test.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ void uploadYCbCrImage (ProtectedContext& ctx,

for (deUint32 planeNdx = 0; planeNdx < imageData.getDescription().numPlanes; ++planeNdx)
{
const vk::VkImageAspectFlagBits aspect = formatDesc.numPlanes > 1
const vk::VkImageAspectFlags aspect = formatDesc.numPlanes > 1
? vk::getPlaneAspect(planeNdx)
: vk::VK_IMAGE_ASPECT_COLOR_BIT;

Expand Down Expand Up @@ -419,7 +419,7 @@ void uploadYCbCrImage (ProtectedContext& ctx,

for (deUint32 planeNdx = 0; planeNdx < imageData.getDescription().numPlanes; ++planeNdx)
{
const vk::VkImageAspectFlagBits aspect = formatDesc.numPlanes > 1
const vk::VkImageAspectFlags aspect = formatDesc.numPlanes > 1
? vk::getPlaneAspect(planeNdx)
: vk::VK_IMAGE_ASPECT_COLOR_BIT;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1355,7 +1355,7 @@ tcu::TestStatus multiSwapchainRenderTest (Context& context, MultiSwapchainParams
{
native.reset(new NativeObjects(context, instHelper.supportedExtensions, params.wsiType, params.swapchainCount, tcu::just(desiredSize)));
}
catch(tcu::ResourceError& err)
catch(tcu::ResourceError&)
{
std::ostringstream msg;
msg << "Unable to create " << params.swapchainCount << " windows";
Expand Down
6 changes: 3 additions & 3 deletions framework/egl/egluUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ EGLDisplay getDisplay (NativeDisplay& nativeDisplay)
de::contains(platformExts.begin(), platformExts.end(), string(nativeDisplay.getPlatformExtensionName()));

}
catch (const tcu::NotSupportedError& error)
catch (const tcu::NotSupportedError&)
{
// If we can't get the client extension string we must not have EGL 1.5 support or the appropriate extensions.
maySupportPlatformGetDisplay = false;
Expand Down Expand Up @@ -332,7 +332,7 @@ EGLSurface createWindowSurface (NativeDisplay& nativeDisplay, NativeWindow& wind
de::contains(platformExts.begin(), platformExts.end(), string(nativeDisplay.getPlatformExtensionName()));

}
catch (const tcu::NotSupportedError& error)
catch (const tcu::NotSupportedError&)
{
maySupportPlatformCreate = false;
maySupportPlatformCreateExtension = false;
Expand Down Expand Up @@ -390,7 +390,7 @@ EGLSurface createPixmapSurface (NativeDisplay& nativeDisplay, NativePixmap& pixm
de::contains(platformExts.begin(), platformExts.end(), string(nativeDisplay.getPlatformExtensionName()));

}
catch (const tcu::NotSupportedError& error)
catch (const tcu::NotSupportedError&)
{
maySupportPlatformCreate = false;
maySupportPlatformCreateExtension = false;
Expand Down
2 changes: 1 addition & 1 deletion modules/egl/teglGetProcAddressTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ void GetProcAddressCase::init (void)
{
m_supported = eglu::getClientExtensions(m_eglTestCtx.getLibrary());
}
catch (const tcu::NotSupportedError& error)
catch (const tcu::NotSupportedError&)
{
// Ignore case where EGL client extensions are not supported
// that's okay for these tests.
Expand Down
2 changes: 1 addition & 1 deletion modules/gles2/functional/es2fUniformApiTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ class UniformCollection
for (int j = 0; j < (int)structTypes.size(); j++)
delete structTypes[j];
structTypes.clear();
uniform.type = (("u_var" + de::toString(i)).c_str(), generateRandomType(3, structIdx, structTypes, rnd));
uniform.type = generateRandomType(3, structIdx, structTypes, rnd);
} while (res->getNumSamplers() + getNumSamplersInType(uniform.type) > MAX_NUM_SAMPLER_UNIFORMS);

res->addUniform(uniform);
Expand Down
2 changes: 1 addition & 1 deletion modules/gles3/functional/es3fUniformApiTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ class UniformCollection
for (int j = 0; j < (int)structTypes.size(); j++)
delete structTypes[j];
structTypes.clear();
uniform.type = (("u_var" + de::toString(i)).c_str(), generateRandomType(3, structIdx, structTypes, rnd));
uniform.type = generateRandomType(3, structIdx, structTypes, rnd);
} while (res->getNumSamplers() + getNumSamplersInType(uniform.type) > MAX_NUM_SAMPLER_UNIFORMS);

res->addUniform(uniform);
Expand Down

0 comments on commit eaa9608

Please sign in to comment.