Fix unused warnings release (#3677)

* Release build fix for Windows
* Release build fix for Android
* Release build fix for Windows
* Release build fix for Android
* Release build fix for Linux
* Release build fix for Mac
* Release build fix for iOS

Signed-off-by: Steve Pham <spham@amazon.com>
This commit is contained in:
Steve Pham
2021-08-30 13:10:41 -07:00
committed by GitHub
parent da6bdd5b43
commit fa0f2a1007
94 changed files with 150 additions and 130 deletions
@@ -98,7 +98,7 @@ namespace ImageProcessingAtom
else
{
IImageObjectPtr dstImage = nullptr;
const PixelFormatInfo* compressedInfo = CPixelFormats::GetInstance().GetPixelFormatInfo(compressedFmt);
[[maybe_unused]] const PixelFormatInfo* compressedInfo = CPixelFormats::GetInstance().GetPixelFormatInfo(compressedFmt);
if (isSrcUncompressed)
{
AZ::u64 startTime = AZStd::GetTimeUTCMilliSecond();
@@ -350,7 +350,7 @@ namespace ImageProcessingAtom
// output conversion log
if (m_isSucceed && m_isFinished)
{
const uint32 sizeTotal = m_image->Get()->GetTextureMemory();
[[maybe_unused]] const uint32 sizeTotal = m_image->Get()->GetTextureMemory();
if (m_input->m_isPreview)
{
AZ_TracePrintf("Image Processing", "Image (%d bytes) converted in %f seconds\n", sizeTotal, m_processTime);
@@ -971,7 +971,7 @@ namespace ImageProcessingAtom
IImageObjectPtr previewImageAlpha = imageToProcess2.Get();
const uint32 imageMips = previewImage->GetMipCount();
const uint32 alphaMips = previewImageAlpha->GetMipCount();
[[maybe_unused]] const uint32 alphaMips = previewImageAlpha->GetMipCount();
// Get count of bytes per pixel for both rgb and alpha images
uint32 imagePixelBytes = CPixelFormats::GetInstance().GetPixelFormatInfo(ePixelFormat_R8G8B8A8)->bitsPerBlock / 8;
@@ -983,7 +983,7 @@ namespace ImageProcessingAtom
for (uint32 mipLevel = 0; mipLevel < imageMips; ++mipLevel)
{
const uint32 pixelCount = previewImage->GetPixelCount(mipLevel);
const uint32 alphaPixelCount = previewImageAlpha->GetPixelCount(mipLevel);
[[maybe_unused]] const uint32 alphaPixelCount = previewImageAlpha->GetPixelCount(mipLevel);
AZ_Assert(pixelCount == alphaPixelCount, "Pixel count for image and alpha image at mip level %d is not equal!", mipLevel);
@@ -830,7 +830,7 @@ namespace UnitTest
continue;
}
auto formatInfo = CPixelFormats::GetInstance().GetPixelFormatInfo(pixelFormat);
[[maybe_unused]] auto formatInfo = CPixelFormats::GetInstance().GetPixelFormatInfo(pixelFormat);
imageToProcess.Set(srcImage);
imageToProcess.ConvertFormat(pixelFormat);
@@ -908,9 +908,9 @@ namespace AZ
AZ_Assert(optionEntry.IsObject(), "Expected option entry to be an object!");
Name defaultValueId = optionEntry.HasMember("defaultValue") ? Name(optionEntry["defaultValue"].GetString()) : Name();
const AZStd::string optionName = optionEntry.HasMember("name") ? optionEntry["name"].GetString() : "";
const bool valuesAreRange = optionEntry.HasMember("range") ? optionEntry["range"].GetBool() : false;
const bool isPredefinedType = optionEntry.HasMember("kind") ? AzFramework::StringFunc::Equal(optionEntry["kind"].GetString(), "predefined") : false;
const AZStd::string optionName = optionEntry.HasMember("name") ? optionEntry["name"].GetString() : "";
[[maybe_unused]] const bool valuesAreRange = optionEntry.HasMember("range") ? optionEntry["range"].GetBool() : false;
const bool isPredefinedType = optionEntry.HasMember("kind") ? AzFramework::StringFunc::Equal(optionEntry["kind"].GetString(), "predefined") : false;
auto optionType = RPI::ShaderOptionType::Unknown;
if (isPredefinedType && optionEntry.HasMember("type"))
@@ -462,7 +462,7 @@ namespace AZ
{
finalShaderOptionGroupLayout = shaderOptionGroupLayout;
shaderAssetCreator.SetShaderOptionGroupLayout(finalShaderOptionGroupLayout);
const uint32_t usedShaderOptionBits = shaderOptionGroupLayout->GetBitSize();
[[maybe_unused]] const uint32_t usedShaderOptionBits = shaderOptionGroupLayout->GetBitSize();
AZ_TracePrintf(
ShaderAssetBuilderName, "Note: This shader uses %u of %u available shader variant key bits. \n",
usedShaderOptionBits, RPI::ShaderVariantKeyBitCount);
@@ -388,7 +388,7 @@ namespace AZ
for (const AZ::RPI::ShaderVariantListSourceData::VariantInfo& variantInfo : shaderVariantList.m_shaderVariants)
{
AZStd::string variantInfoAsJsonString;
const bool convertSuccess = AZ::RPI::JsonUtils::SaveObjectToJsonString(variantInfo, variantInfoAsJsonString);
[[maybe_unused]] const bool convertSuccess = AZ::RPI::JsonUtils::SaveObjectToJsonString(variantInfo, variantInfoAsJsonString);
AZ_Assert(convertSuccess, "Failed to convert VariantInfo to json string");
AssetBuilderSDK::JobDescriptor jobDescriptor;
@@ -755,7 +755,7 @@ namespace AZ
const AZStd::string& variantJsonString = jobParameters.at(ShaderVariantJobVariantParam);
RPI::ShaderVariantListSourceData::VariantInfo variantInfo;
const bool fromJsonStringSuccess = AZ::RPI::JsonUtils::LoadObjectFromJsonString(variantJsonString, variantInfo);
[[maybe_unused]] const bool fromJsonStringSuccess = AZ::RPI::JsonUtils::LoadObjectFromJsonString(variantJsonString, variantInfo);
AZ_Assert(fromJsonStringSuccess, "Failed to convert json string to VariantInfo");
RPI::ShaderSourceData shaderSourceDescriptor;
@@ -325,11 +325,11 @@ namespace AZ
DirectionalLightFeatureProcessorInterface::LightHandle DirectionalLightFeatureProcessor::AcquireLight()
{
const uint16_t index = m_lightData.GetFreeSlotIndex();
const uint16_t shadowPropIndex = m_shadowProperties.GetFreeSlotIndex();
[[maybe_unused]] const uint16_t shadowPropIndex = m_shadowProperties.GetFreeSlotIndex();
AZ_Assert(index == shadowPropIndex, "light index is illegal.");
for (const auto& viewIt : m_cameraViewNames)
{
const uint16_t shadowIndex = m_shadowData.at(viewIt.first).GetFreeSlotIndex();
[[maybe_unused]] const uint16_t shadowIndex = m_shadowData.at(viewIt.first).GetFreeSlotIndex();
AZ_Assert(index == shadowIndex, "light index is illegal.");
}
@@ -38,7 +38,7 @@ namespace AZ
{
namespace
{
static const char* PassName = "ImGuiPass";
[[maybe_unused]] static const char* PassName = "ImGuiPass";
static const char* ImguiShaderFilePath = "Shaders/imgui/imgui.azshader";
}
@@ -17,7 +17,7 @@ namespace AZ
{
namespace Render
{
static const char* ClassName = "GpuBufferHandler";
[[maybe_unused]] static const char* ClassName = "GpuBufferHandler";
static const uint32_t BufferMinSize = 1 << 16; // Min 64Kb.
GpuBufferHandler::GpuBufferHandler(const Descriptor& descriptor)
@@ -71,7 +71,7 @@ namespace AZ
{
EndContextInternal(m_contexts[contextIndex], contextIndex);
const int32_t activeCount = --m_contextCountActive;
[[maybe_unused]] const int32_t activeCount = --m_contextCountActive;
AZ_Assert(activeCount >= 0, "Asymmetric calls to FrameSchedulerExecuteContext:: Begin / End.");
++m_contextCountCompleted;
}
+2 -2
View File
@@ -98,8 +98,8 @@ namespace AZ
if (Validation::IsEnabled())
{
// The frame attachment has tight control over lifecycle here.
const bool isAttach = (!m_frameAttachment && frameAttachment);
const bool isDetach = (m_frameAttachment && !frameAttachment);
[[maybe_unused]] const bool isAttach = (!m_frameAttachment && frameAttachment);
[[maybe_unused]] const bool isDetach = (m_frameAttachment && !frameAttachment);
AZ_Assert(isAttach || isDetach, "The frame attachment for resource '%s' was not assigned properly.");
}
+1
View File
@@ -121,6 +121,7 @@ namespace UnitTest
bufferPool->ForEach<RHI::Buffer>([&bufferIndex, &buffers]([[maybe_unused]] RHI::Buffer& buffer)
{
AZ_UNUSED(buffers); // Prevent unused warning in release builds
AZ_Assert(buffers[bufferIndex] == &buffer, "buffers don't match");
bufferIndex++;
});
+1 -1
View File
@@ -58,7 +58,7 @@ namespace UnitTest
FrameGraphExecuteGroup* group = AddGroup<FrameGraphExecuteGroup>();
group->Init(scope->GetId());
const bool wasInserted = m_scopeIds.emplace(scope->GetId()).second;
[[maybe_unused]] const bool wasInserted = m_scopeIds.emplace(scope->GetId()).second;
AZ_Assert(wasInserted, "scope was inserted already");
}
}
+1
View File
@@ -108,6 +108,7 @@ namespace UnitTest
imagePool->ForEach<RHI::Image>([&imageIndex, &images]([[maybe_unused]] const RHI::Image& image)
{
AZ_UNUSED(images); // Prevent unused warning in release builds
AZ_Assert(images[imageIndex] == &image, "images don't match");
imageIndex++;
});
+1
View File
@@ -112,6 +112,7 @@ namespace UnitTest
queryPool->ForEach<RHI::Query>([&queryIndex, &queries]([[maybe_unused]] RHI::Query& query)
{
AZ_UNUSED(queries); // Prevent unused warning in release builds
AZ_Assert(queries[queryIndex] == &query, "Queries don't match");
queryIndex++;
});
@@ -191,7 +191,7 @@ namespace AZ
StageDescriptor& outputDescriptor,
const RHI::ShaderCompilerArguments& shaderCompilerArguments) const
{
for (auto srgLayout : m_srgLayouts)
for ([[maybe_unused]] auto srgLayout : m_srgLayouts)
{
AZ_Assert(srgLayout != nullptr, "Most likely BuildPipelineLayoutDescriptor() was not called!");
}
@@ -280,7 +280,7 @@ namespace AZ
// Enable half precision types when shader model >= 6.2
int shaderModelMajor = 0;
int shaderModelMinor = 0;
int numValuesRead = azsscanf(shaderModelVersion.c_str(), "%d_%d", &shaderModelMajor, &shaderModelMinor);
[[maybe_unused]] int numValuesRead = azsscanf(shaderModelVersion.c_str(), "%d_%d", &shaderModelMajor, &shaderModelMinor);
AZ_Assert(numValuesRead == 2, "Unknown shader model version format");
if (shaderModelMajor >= 6 && shaderModelMinor >= 2)
{
@@ -431,7 +431,7 @@ namespace AZ
}
else
{
bool isBoundToGraphics = RHI::CheckBitsAny(visMaskIt->second, RHI::ShaderStageMask::Vertex) || RHI::CheckBitsAny(visMaskIt->second, RHI::ShaderStageMask::Fragment);
[[maybe_unused]] bool isBoundToGraphics = RHI::CheckBitsAny(visMaskIt->second, RHI::ShaderStageMask::Vertex) || RHI::CheckBitsAny(visMaskIt->second, RHI::ShaderStageMask::Fragment);
AZ_Assert(isBoundToGraphics, "The visibility mask %i is not set for Vertex or fragment stage", visMaskIt->second);
CollectResourcesForGraphics(commandEncoder, visMaskIt->second, it.second, resourcesToMakeResidentGraphics);
}
@@ -54,7 +54,7 @@ namespace AZ
usage : textureUsage];
mtlTextureDesc.textureType = MTLTextureTypeTextureBuffer;
uint32_t bytesPerRow = viewDescriptor.m_elementCount * bytesPerPixel;
[[maybe_unused]] uint32_t bytesPerRow = viewDescriptor.m_elementCount * bytesPerPixel;
AZ_Assert(bytesPerRow == (viewDescriptor.m_elementCount * viewDescriptor.m_elementSize), "Mismatch for bytesPerRow");
id<MTLTexture> mtlTexture = [mtlBuffer newTextureWithDescriptor : mtlTextureDesc
offset : m_memoryView.GetOffset()
@@ -188,7 +188,7 @@ namespace AZ
}
else
{
const char * errorStr = [ error.localizedDescription UTF8String ];
[[maybe_unused]] const char * errorStr = [ error.localizedDescription UTF8String ];
AZ_Error("PipelineState", false, "Failed to compile compute pipeline state with error: %s.", errorStr);
return RHI::ResultCode::Fail;
}
@@ -221,7 +221,7 @@ namespace AZ
}
else
{
const char * errorStr = [ error.localizedDescription UTF8String ];
[[maybe_unused]] const char * errorStr = [ error.localizedDescription UTF8String ];
AZ_Error("PipelineState", false, "Failed to compile compute pipeline state with error: %s.", errorStr);
return RHI::ResultCode::Fail;
}
@@ -108,7 +108,7 @@ namespace AZ
VkAccelerationStructureKHR BufferView::GetNativeAccelerationStructure() const
{
bool hasOverrideFlags = GetDescriptor().m_overrideBindFlags != RHI::BufferBindFlags::None;
const RHI::BufferBindFlags bindFlags = hasOverrideFlags ? GetDescriptor().m_overrideBindFlags : GetBuffer().GetDescriptor().m_bindFlags;
[[maybe_unused]] const RHI::BufferBindFlags bindFlags = hasOverrideFlags ? GetDescriptor().m_overrideBindFlags : GetBuffer().GetDescriptor().m_bindFlags;
AZ_Assert(RHI::CheckBitsAll(bindFlags, RHI::BufferBindFlags::RayTracingAccelerationStructure),
"GetNativeAccelerationStructure() is only valid for buffers with the RayTracingAccelerationStructure bind flag");
@@ -117,10 +117,10 @@ namespace AZ
const auto& device = static_cast<const Device&>(GetDevice());
const auto& physicalDevice = static_cast<const PhysicalDevice&>(GetDevice().GetPhysicalDevice());
const uint16_t width = static_cast<uint16_t>(imgDesc.m_size.m_width);
const uint16_t height = static_cast<uint16_t>(imgDesc.m_size.m_height);
[[maybe_unused]] const uint16_t width = static_cast<uint16_t>(imgDesc.m_size.m_width);
[[maybe_unused]] const uint16_t height = static_cast<uint16_t>(imgDesc.m_size.m_height);
const uint16_t depth = AZStd::min(static_cast<uint16_t>(imgViewDesc.m_depthSliceMax - imgViewDesc.m_depthSliceMin), static_cast<uint16_t>(imgDesc.m_size.m_depth - 1)) + 1;
const uint16_t samples = imgDesc.m_multisampleState.m_samples;
[[maybe_unused]] const uint16_t samples = imgDesc.m_multisampleState.m_samples;
const uint16_t arrayLayers = AZStd::min(static_cast<uint16_t>(imgViewDesc.m_arraySliceMax - imgViewDesc.m_arraySliceMin), static_cast<uint16_t>(imgDesc.m_arraySize - 1)) + 1;
// We cannot only use the number of layers of the ImageView to determinate if is a texture array. You can have a texture array with only 1 layer and the shader expects
// an array type instead of a normal image type.
@@ -254,7 +254,7 @@ namespace AZ
poolAssetCreator.SetPoolDescriptor(AZStd::move(imagePoolDescriptor));
poolAssetCreator.SetControllerAsset(m_defaultStreamingImageControllerAsset);
poolAssetCreator.SetPoolName(systemStreamingPoolDescriptor.m_name);
const bool created = poolAssetCreator.End(poolAsset);
[[maybe_unused]] const bool created = poolAssetCreator.End(poolAsset);
AZ_Assert(created, "Failed to build streaming image pool");
m_systemStreamingPool = StreamingImagePool::FindOrCreate(poolAsset);
@@ -272,7 +272,7 @@ namespace AZ
poolAssetCreator.SetPoolDescriptor(AZStd::move(imagePoolDescriptor));
poolAssetCreator.SetControllerAsset(m_defaultStreamingImageControllerAsset);
poolAssetCreator.SetPoolName(assetStreamingPoolDescriptor.m_name);
const bool created = poolAssetCreator.End(poolAsset);
[[maybe_unused]] const bool created = poolAssetCreator.End(poolAsset);
AZ_Assert(created, "Failed to build streaming image pool for assets");
m_assetStreamingPool = StreamingImagePool::FindOrCreate(poolAsset);
@@ -292,7 +292,7 @@ namespace AZ
poolAssetCreator.Begin(systemAttachmentPoolDescriptor.m_assetId);
poolAssetCreator.SetPoolDescriptor(AZStd::move(imagePoolDescriptor));
poolAssetCreator.SetPoolName(systemAttachmentPoolDescriptor.m_name);
const bool created = poolAssetCreator.End(poolAsset);
[[maybe_unused]] const bool created = poolAssetCreator.End(poolAsset);
AZ_Assert(created, "Failed to build attachment image pool");
m_systemAttachmentPool = AttachmentImagePool::FindOrCreate(poolAsset);
@@ -88,7 +88,7 @@ namespace AZ
{
if (StreamingImage* image = context->TryGetImage())
{
const RHI::ResultCode resultCode = image->ExpandMipChain();
[[maybe_unused]] const RHI::ResultCode resultCode = image->ExpandMipChain();
AZ_Warning("StreamingImageController", resultCode == RHI::ResultCode::Success, "Failed to expand mip chain for streaming image.");
}
context->m_queuedForMipExpand = false;
@@ -494,6 +494,7 @@ namespace AZ
{
if (query->BeginQuery(context) == QueryResultCode::Fail)
{
AZ_UNUSED(this); // Prevent unused warning in release builds
AZ_WarningOnce("RenderPass", false, "BeginScopeQuery failed. Make sure AddScopeQueryToFrameGraph was called in SetupFrameGraphDependencies"
" for this pass: %s", this->RTTI_GetTypeName());
}
@@ -28,7 +28,7 @@ namespace AZ
static constexpr uint32_t SubProductTypeBitPosition = 0;
static constexpr uint32_t SubProductTypeNumBits = SupervariantIndexBitPosition - SubProductTypeBitPosition;
static constexpr uint32_t SubProductTypeMaxValue = (1 << SubProductTypeNumBits) - 1;
[[maybe_unused]] static constexpr uint32_t SubProductTypeMaxValue = (1 << SubProductTypeNumBits) - 1;
static_assert(RhiIndexMaxValue == RHI::Limits::APIType::PerPlatformApiUniqueIndexMax);
@@ -25,11 +25,11 @@ namespace AZ
{
static constexpr uint32_t SubProductTypeBitPosition = 17;
static constexpr uint32_t SubProductTypeNumBits = SupervariantIndexBitPosition - SubProductTypeBitPosition;
static constexpr uint32_t SubProductTypeMaxValue = (1 << SubProductTypeNumBits) - 1;
[[maybe_unused]] static constexpr uint32_t SubProductTypeMaxValue = (1 << SubProductTypeNumBits) - 1;
static constexpr uint32_t StableIdBitPosition = 0;
static constexpr uint32_t StableIdNumBits = SubProductTypeBitPosition - StableIdBitPosition;
static constexpr uint32_t StableIdMaxValue = (1 << StableIdNumBits) - 1;
[[maybe_unused]] static constexpr uint32_t StableIdMaxValue = (1 << StableIdNumBits) - 1;
static_assert(RhiIndexMaxValue == RHI::Limits::APIType::PerPlatformApiUniqueIndexMax);
@@ -238,6 +238,7 @@ namespace AtomToolsFramework
connectionSettings.m_connectionIdentifier = GetBuildTargetName();
connectionSettings.m_loggingCallback = [targetName]([[maybe_unused]] AZStd::string_view logData)
{
AZ_UNUSED(targetName); // Prevent unused warning in release builds
AZ_TracePrintf(targetName.c_str(), "%.*s", aznumeric_cast<int>(logData.size()), logData.data());
};
AzFramework::AssetSystemRequestBus::BroadcastResult(
@@ -112,7 +112,7 @@ namespace MaterialEditor
requestedViewportSize.width(), requestedViewportSize.height(), m_materialViewport->size().width(),
m_materialViewport->size().height());
QSize newDeviceSize = m_materialViewport->size();
[[maybe_unused]] QSize newDeviceSize = m_materialViewport->size();
AZ_Warning(
"Material Editor", static_cast<uint32_t>(newDeviceSize.width()) == width && static_cast<uint32_t>(newDeviceSize.height()) == height,
"Resizing the window did not give the expected frame size. Requested %d x %d but got %d x %d.", width, height,
@@ -390,7 +390,7 @@ namespace AZ
inline void ImGuiPipelineStatisticsView::CreateAttributeRow(const PassEntry* passEntry, const PassEntry* rootEntry)
{
const uint32_t columnCount = static_cast<uint32_t>(ImGui::GetColumnsCount());
[[maybe_unused]] const uint32_t columnCount = static_cast<uint32_t>(ImGui::GetColumnsCount());
AZ_Assert(columnCount == ImGuiPipelineStatisticsView::HeaderAttributeCount, "The column count needs to match HeaderAttributeCount.");
ImGui::Separator();
@@ -1348,7 +1348,7 @@ namespace AZ
PassEntry entry(pass, parent);
// Set the time stamp in the database.
const auto passEntry = passEntryDatabase.find(entry.m_path);
[[maybe_unused]] const auto passEntry = passEntryDatabase.find(entry.m_path);
AZ_Assert(passEntry == passEntryDatabase.end(), "There already is an entry with the name \"%s\".", entry.m_path.GetCStr());
// Set the entry in the map.