diff --git a/MobileGL/Config.h b/MobileGL/Config.h index bd35da61..1c253a98 100644 --- a/MobileGL/Config.h +++ b/MobileGL/Config.h @@ -45,17 +45,9 @@ namespace MobileGL::MG_Config { Bool VulkanR11G11B10FFallback = false; // MOBILEGL_MAGMA_FRAMESINFLIGHT: requested Magma frames in flight, defaulting to 3. Uint32 MagmaFramesInFlight = 3; - // MOBILEGL_GLES_PRESENT_STATS: log present pixel statistics (DirectGLES backend). - Bool GlesPresentStats = false; // MOBILEGL_ANGLE_LLVMPIPE_AVOID_SAMPLER_MIPMAP_MIN_FILTER: avoid mipmap min // filters in samplers on ANGLE/llvmpipe renderers. Bool AvoidAngleLlvmpipeSamplerMipmapMinFilter = false; - // MOBILEGL_DESCRIPTOR_STATS: log descriptor binding statistics (DirectVulkan). - Bool DescriptorStats = false; - // MOBILEGL_TEXTURE_UPLOAD_STATS: log texture upload statistics (DirectVulkan). - Bool TextureUploadStats = false; - // MOBILEGL_VERTEX_INPUT_STATS: log vertex input statistics (DirectVulkan). - Bool VertexInputStats = false; // MOBILEGL_PRESENT_DUMP_PATH: directory for present frame dumps (DirectVulkan). String PresentDumpPath; // MOBILEGL_PRESENT_STATS: log present pixel statistics (DirectVulkan backend). diff --git a/MobileGL/ConfigLoader.cpp b/MobileGL/ConfigLoader.cpp index 84a5dfe5..0b8a0fe1 100644 --- a/MobileGL/ConfigLoader.cpp +++ b/MobileGL/ConfigLoader.cpp @@ -115,12 +115,8 @@ namespace MobileGL::MG_ConfigLoader { features.DisableSubgroup = QueryEnvFlag("MOBILEGL_DISABLE_SUBGROUP"); features.VulkanR11G11B10FFallback = QueryEnvFlag("MOBILEGL_MAGMA_R11G11B10F_FALLBACK"); features.MagmaFramesInFlight = QueryEnvUint32("MOBILEGL_MAGMA_FRAMESINFLIGHT", 3, 1, 64); - features.GlesPresentStats = QueryEnvFlag("MOBILEGL_GLES_PRESENT_STATS"); features.AvoidAngleLlvmpipeSamplerMipmapMinFilter = QueryEnvFlag("MOBILEGL_ANGLE_LLVMPIPE_AVOID_SAMPLER_MIPMAP_MIN_FILTER"); - features.DescriptorStats = QueryEnvFlag("MOBILEGL_DESCRIPTOR_STATS"); - features.TextureUploadStats = QueryEnvFlag("MOBILEGL_TEXTURE_UPLOAD_STATS"); - features.VertexInputStats = QueryEnvFlag("MOBILEGL_VERTEX_INPUT_STATS"); QueryEnvVariable("MOBILEGL_PRESENT_DUMP_PATH", features.PresentDumpPath, ""); features.PresentStats = QueryEnvFlag("MOBILEGL_PRESENT_STATS"); features.TraceSkipAutodestroy = QueryEnvFlag("MOBILEGL_TRACE_SKIP_AUTODESTROY"); diff --git a/MobileGL/MG_Backend/DirectGLES/DirectGLES.cpp b/MobileGL/MG_Backend/DirectGLES/DirectGLES.cpp index 5a2c0259..c9783edd 100644 --- a/MobileGL/MG_Backend/DirectGLES/DirectGLES.cpp +++ b/MobileGL/MG_Backend/DirectGLES/DirectGLES.cpp @@ -3519,50 +3519,6 @@ namespace MobileGL::MG_Backend::DirectGLES { return true; } - static Bool PresentStatsEnabled() { - // MOBILEGL_GLES_PRESENT_STATS, parsed once in MG_ConfigLoader::Init. - return MG_Config::Features.GlesPresentStats; - } - - static void DumpDefaultFramebufferStats() { - if (!PresentStatsEnabled() || !g_GLESFuncs.glReadPixels || !g_EGLFuncs.eglQuerySurface || - g_Display == EGL_NO_DISPLAY || g_Surface == EGL_NO_SURFACE) { - return; - } - - Int width = 0; - Int height = 0; - if (!QueryCurrentSurfaceSize(width, height)) { - return; - } - - GLint viewport[4] = {0, 0, 0, 0}; - g_GLESFuncs.glGetIntegerv(GL_VIEWPORT, viewport); - GLint previousReadFramebuffer = 0; - g_GLESFuncs.glGetIntegerv(GL_READ_FRAMEBUFFER_BINDING, &previousReadFramebuffer); - g_GLESFuncs.glBindFramebuffer(GL_READ_FRAMEBUFFER, 0); - - Vector pixels(static_cast(width) * static_cast(height) * 4); - g_GLESFuncs.glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, pixels.data()); - - SizeT nonBlack = 0; - SizeT nonZeroAlpha = 0; - for (SizeT offset = 0; offset + 3 < pixels.size(); offset += 4) { - if (pixels[offset] != 0 || pixels[offset + 1] != 0 || pixels[offset + 2] != 0) { - ++nonBlack; - } - if (pixels[offset + 3] != 0) { - ++nonZeroAlpha; - } - } - - g_GLESFuncs.glBindFramebuffer(GL_READ_FRAMEBUFFER, static_cast(previousReadFramebuffer)); - std::fprintf(stderr, - "MOBILEGL_GLES_PRESENT_STATS nonBlack=%zu/%zu alpha=%zu/%zu size=%dx%d viewport=%d,%d,%d,%d\n", - nonBlack, pixels.size() / 4, nonZeroAlpha, pixels.size() / 4, width, height, - viewport[0], viewport[1], viewport[2], viewport[3]); - } - #if defined(__linux__) && !defined(__ANDROID__) static void* OpenX11Lib() { void* x11Lib = dlopen("libX11.so.6", RTLD_LOCAL | RTLD_NOW); diff --git a/MobileGL/MG_Backend/DirectVulkan/Renderer/UniformManager.cpp b/MobileGL/MG_Backend/DirectVulkan/Renderer/UniformManager.cpp index 3f564770..eb41fcd3 100644 --- a/MobileGL/MG_Backend/DirectVulkan/Renderer/UniformManager.cpp +++ b/MobileGL/MG_Backend/DirectVulkan/Renderer/UniformManager.cpp @@ -78,10 +78,6 @@ namespace MobileGL::MG_Backend::DirectVulkan { return uniformUnit >= 0 ? uniformUnit : 0; } - static Bool ShouldDumpDescriptorStats() { - return MG_Config::Features.DescriptorStats; - } - Bool UniformManager::Initialize(VkDevice device, VkBufferManager* bufferManager, ProgramFactory* programFactory, VkDeviceSize minUniformBufferOffsetAlignment, Uint32 frameCount, @@ -314,21 +310,6 @@ namespace MobileGL::MG_Backend::DirectVulkan { .imageView = resource->sampledView != VK_NULL_HANDLE ? resource->sampledView : resource->fullView, .imageLayout = resource->layout, }; - if (ShouldDumpDescriptorStats()) { - std::fprintf(stderr, - "MOBILEGL_DESCRIPTOR_STATS program=%u binding=%u name=%s location=%d unit=%d " - "texture=%u target=%d sampler=%p imageView=%p layout=%d\n", - program.GetExternalIndex(), - binding, - programObj.samplerNameByBinding[binding].c_str(), - location, - unit, - texture->GetExternalIndex(), - static_cast(texture->GetTarget()), - reinterpret_cast(outImageInfo.sampler), - reinterpret_cast(outImageInfo.imageView), - static_cast(outImageInfo.imageLayout)); - } return outImageInfo.sampler != VK_NULL_HANDLE; } diff --git a/MobileGL/MG_Backend/DirectVulkan/Renderer/VkTextureManager.cpp b/MobileGL/MG_Backend/DirectVulkan/Renderer/VkTextureManager.cpp index 764a14cc..f4c9403b 100644 --- a/MobileGL/MG_Backend/DirectVulkan/Renderer/VkTextureManager.cpp +++ b/MobileGL/MG_Backend/DirectVulkan/Renderer/VkTextureManager.cpp @@ -383,102 +383,6 @@ namespace MobileGL::MG_Backend::DirectVulkan { return true; } - static Bool ShouldDumpTextureUploadStats() { - return MG_Config::Features.TextureUploadStats; - } - - static void DumpTextureSyncStats(Int textureId, TextureInternalFormat format, TextureUploadTarget uploadTarget, - Uint32 mipLevelCount, const IntVec3& texelSize, SizeT byteSize, - Bool hasDirtyMipLevel) { - if (!ShouldDumpTextureUploadStats()) { - return; - } - - std::fprintf(stderr, - "MOBILEGL_TEXTURE_SYNC_STATS texture=%d format=%s target=%s mips=%u size=%dx%dx%d " - "bytes=%zu dirty=%d\n", - textureId, - MG_Util::ConvertTextureInternalFormatToString(format).c_str(), - MG_Util::ConvertTextureUploadTargetToString(uploadTarget).c_str(), - mipLevelCount, - texelSize.x(), - texelSize.y(), - texelSize.z(), - byteSize, - hasDirtyMipLevel ? 1 : 0); - } - - static void DumpTextureUploadStats(Int textureId, TextureUploadTarget target, Uint32 level, - const IntVec3& texelSize, const void* data, SizeT byteSize, Uint32 channels) { - if (channels == 0 && texelSize.x() > 0 && texelSize.y() > 0) { - const SizeT depth = static_cast(std::max(texelSize.z(), 1)); - const SizeT pixelCount = static_cast(texelSize.x()) * static_cast(texelSize.y()) * depth; - if (pixelCount > 0 && byteSize % pixelCount == 0) { - channels = static_cast(std::min(byteSize / pixelCount, 4)); - } - } - if (!ShouldDumpTextureUploadStats() || data == nullptr || byteSize == 0 || channels == 0) { - return; - } - - const auto* bytes = static_cast(data); - Uint8 minValue = 255; - Uint8 maxValue = 0; - SizeT nonZero = 0; - Uint64 sum = 0; - Uint64 neighborDiff = 0; - SizeT neighborCount = 0; - - for (SizeT i = 0; i < byteSize; ++i) { - minValue = std::min(minValue, bytes[i]); - maxValue = std::max(maxValue, bytes[i]); - nonZero += bytes[i] != 0 ? 1 : 0; - sum += bytes[i]; - } - - const SizeT width = static_cast(std::max(texelSize.x(), 0)); - const SizeT height = static_cast(std::max(texelSize.y(), 0)); - const SizeT pixelStride = channels; - if (width > 1 && height > 0 && byteSize >= width * height * pixelStride) { - for (SizeT y = 0; y < height; ++y) { - const SizeT row = y * width * pixelStride; - for (SizeT x = 1; x < width; ++x) { - const SizeT prev = row + (x - 1) * pixelStride; - const SizeT cur = row + x * pixelStride; - for (SizeT c = 0; c < std::min(channels, 3); ++c) { - neighborDiff += static_cast( - std::abs(static_cast(bytes[cur + c]) - static_cast(bytes[prev + c]))); - ++neighborCount; - } - } - } - } - - const double avg = byteSize > 0 ? static_cast(sum) / static_cast(byteSize) : 0.0; - const double avgNeighborDiff = - neighborCount > 0 ? static_cast(neighborDiff) / static_cast(neighborCount) : 0.0; - std::fprintf(stderr, - "MOBILEGL_TEXTURE_UPLOAD_STATS texture=%d target=%s level=%u size=%dx%dx%d bytes=%zu " - "channels=%u min=%u max=%u avg=%.2f nonzero=%zu neighborDiff=%.2f first=%u,%u,%u,%u\n", - textureId, - MG_Util::ConvertTextureUploadTargetToString(target).c_str(), - level, - texelSize.x(), - texelSize.y(), - texelSize.z(), - byteSize, - channels, - static_cast(minValue), - static_cast(maxValue), - avg, - nonZero, - avgNeighborDiff, - byteSize > 0 ? static_cast(bytes[0]) : 0u, - byteSize > 1 ? static_cast(bytes[1]) : 0u, - byteSize > 2 ? static_cast(bytes[2]) : 0u, - byteSize > 3 ? static_cast(bytes[3]) : 0u); - } - static VkComponentSwizzle ToVkComponentSwizzle(TextureSwizzleParam swizzle) { switch (swizzle) { case TextureSwizzleParam::Red: @@ -1123,8 +1027,6 @@ namespace MobileGL::MG_Backend::DirectVulkan { break; } } - DumpTextureSyncStats(texture.GetExternalIndex(), texture.GetFormat(), uploadTarget, mipLevelCount, - texelSize, byteSize, hasDirtyMipLevel); if (!hasDirtyMipLevel) { outResource.syncedContentVersion = syncingContentVersion; outResource.syncedMipLevelCount = syncingMipLevelCount; @@ -1514,10 +1416,6 @@ namespace MobileGL::MG_Backend::DirectVulkan { if (!uploadItems.back().expandedData.empty()) { uploadItems.back().source = uploadItems.back().expandedData.data(); } - DumpTextureUploadStats(mipmapTexture.GetExternalIndex(), uploadItems.back().target, - uploadItems.back().level, uploadItems.back().texelSize, - uploadItems.back().source, uploadItems.back().uploadByteSize, - formatInfo.expandRgbToRgba ? 4u : 0u); stagingSize += static_cast(uploadItems.back().uploadByteSize); } } diff --git a/MobileGL/MG_Backend/DirectVulkan/Renderer/VulkanRenderer.cpp b/MobileGL/MG_Backend/DirectVulkan/Renderer/VulkanRenderer.cpp index 761956f0..9afb16ba 100644 --- a/MobileGL/MG_Backend/DirectVulkan/Renderer/VulkanRenderer.cpp +++ b/MobileGL/MG_Backend/DirectVulkan/Renderer/VulkanRenderer.cpp @@ -639,10 +639,6 @@ namespace MobileGL::MG_Backend::DirectVulkan { return attributeMask; } - static Bool ShouldDumpVertexInputStats() { - return MG_Config::Features.VertexInputStats; - } - static const char* PresentDumpPath() { const String& path = MG_Config::Features.PresentDumpPath; return path.empty() ? nullptr : path.c_str(); @@ -661,80 +657,6 @@ namespace MobileGL::MG_Backend::DirectVulkan { return current != nullptr && std::strcmp(target, current) == 0; } - static void DumpVertexInputStats(Uint32 location, const MG_State::GLState::VertexAttribute& attr, - Uint32 firstVertex, Uint32 vertexCount) { - if (!ShouldDumpVertexInputStats() || attr.Type != DataType::Float32 || attr.Size <= 0 || attr.Size > 4) { - return; - } - - const SizeT componentSize = sizeof(float); - const SizeT elementSize = componentSize * static_cast(attr.Size); - const SizeT stride = attr.Stride > 0 ? static_cast(attr.Stride) : elementSize; - const Uint8* base = nullptr; - SizeT available = 0; - if (attr.Buffer) { - if (attr.Offset >= attr.Buffer->GetSize()) { - return; - } - base = attr.Buffer->MappedData() + attr.Offset; - available = attr.Buffer->GetSize() - attr.Offset; - } else { - base = reinterpret_cast(attr.Offset); - available = static_cast(firstVertex + vertexCount) * stride; - } - if (base == nullptr || vertexCount == 0 || available < elementSize) { - return; - } - - float minValues[4] = {0.0f, 0.0f, 0.0f, 0.0f}; - float maxValues[4] = {0.0f, 0.0f, 0.0f, 0.0f}; - Bool initialized = false; - SizeT sampled = 0; - const Uint32 maxSamples = std::min(vertexCount, 256); - for (Uint32 sample = 0; sample < maxSamples; ++sample) { - const SizeT offset = static_cast(firstVertex + sample) * stride; - if (offset + elementSize > available) { - break; - } - - const auto* values = reinterpret_cast(base + offset); - for (Int component = 0; component < attr.Size; ++component) { - if (!initialized) { - minValues[component] = values[component]; - maxValues[component] = values[component]; - } else { - minValues[component] = std::min(minValues[component], values[component]); - maxValues[component] = std::max(maxValues[component], values[component]); - } - } - initialized = true; - ++sampled; - } - - if (!initialized) { - return; - } - - std::fprintf(stderr, - "MOBILEGL_VERTEX_INPUT_STATS loc=%u buffer=%u size=%d stride=%zu first=%u count=%u sampled=%zu " - "min=(%.3f,%.3f,%.3f,%.3f) max=(%.3f,%.3f,%.3f,%.3f)\n", - location, - attr.Buffer ? attr.Buffer->GetExternalIndex() : 0u, - attr.Size, - stride, - firstVertex, - vertexCount, - sampled, - minValues[0], - minValues[1], - minValues[2], - minValues[3], - maxValues[0], - maxValues[1], - maxValues[2], - maxValues[3]); - } - static Bool TryGetCurrentVertexAttributeFormat(GLenum glType, VkFormat& outFormat) { switch (glType) { case GL_FLOAT: @@ -2189,10 +2111,6 @@ void main() { const Uint32 bindingLocation = binding < vertexInputState.bindingAttributeLocations.size() ? vertexInputState.bindingAttributeLocations[binding] : static_cast(MG_State::GLState::VertexArrayObject::MAX_VERTEX_ATTRIBS); - if (bindingLocation < MG_State::GLState::VertexArrayObject::MAX_VERTEX_ATTRIBS) { - DumpVertexInputStats(bindingLocation, vao.GetAttribute(bindingLocation), - drawParams.firstVertex, drawParams.vertexCount); - } const Bool usesClientMemory = binding < vertexInputState.bindingUsesClientMemory.size() && vertexInputState.bindingUsesClientMemory[binding]; if (usesClientMemory) { diff --git a/android-plugin/app/src/trace/cpp/trace_replay_core.cpp b/android-plugin/app/src/trace/cpp/trace_replay_core.cpp index bb6df573..cfd649ca 100644 --- a/android-plugin/app/src/trace/cpp/trace_replay_core.cpp +++ b/android-plugin/app/src/trace/cpp/trace_replay_core.cpp @@ -933,8 +933,6 @@ Result RunTraceReplay(const Request& request) { unsetenv("MOBILEGL_PRESENT_STATS"); unsetenv("MOBILEGL_PRESENT_DUMP_PATH"); unsetenv("MOBILEGL_PRESENT_DUMP_CALL"); - unsetenv("MOBILEGL_TEXTURE_UPLOAD_STATS"); - unsetenv("MOBILEGL_DESCRIPTOR_STATS"); } setenv("MOBILEGL_LOG_FILE_PATH", mobileGlLogPath.c_str(), 1);