gpu-trace-perf 1.6.0

Plays a collection of GPU traces under different environments to evaluate driver changes on performance
<!-- Common scripts for CI dashboard -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
<script type="module">
    import PhotoSwipeLightbox from 'https://cdn.jsdelivr.net/npm/photoswipe@5.3.8/dist/photoswipe-lightbox.esm.js'
    import PhotoSwipe from 'https://cdn.jsdelivr.net/npm/photoswipe@5.3.8/dist/photoswipe.esm.js'

    const lightbox = new PhotoSwipeLightbox({
        gallery: `body`,
        children: 'a[id^="gallery-img"]',
        pswpModule: PhotoSwipe
    });
    lightbox.init();

    // Magnifying glass functionality
    document.addEventListener('DOMContentLoaded', function () {
        const magnifierContainer = document.querySelector('.magnifier-container');
        const magOriginal = document.getElementById('mag-original');
        const magDiff = document.getElementById('mag-diff');
        const magSecond = document.getElementById('mag-second');
        let ZOOM_LEVEL = 3.5;
        const MIN_ZOOM = 3;
        const MAX_ZOOM = 25;
        const ZOOM_STEP = 0.5;
        let isImagesSwapped = false;
        let activePreviewImg = null;
        let activeOriginalUrl = null;
        let activeDiffUrl = null;
        let activeRunAComment = null;
        let activeRunBComment = null;

        function getSecondImageUrl(originalUrl) {
            return originalUrl.replace(/_0\./, '_1.');
        }

        function updateMagnifier(e, container, originalUrl, original2Url, diffUrl) {
            const rect = container.getBoundingClientRect();
            const x = e.clientX - rect.left;
            const y = e.clientY - rect.top;

            const xPercent = x / rect.width;
            const yPercent = y / rect.height;

            // Show magnifier
            magnifierContainer.style.display = 'block';

            // Update images and their positions
            [magOriginal, magDiff, magSecond].forEach((img, idx) => {
                let url;
                if (idx === 0) {
                    url = isImagesSwapped ? original2Url : originalUrl;
                } else if (idx === 1) {
                    url = diffUrl;
                } else {
                    url = isImagesSwapped ? originalUrl : original2Url;
                }
                img.src = url;
                img.style.width = (rect.width * ZOOM_LEVEL) + 'px';
                img.style.height = (rect.height * ZOOM_LEVEL) + 'px';
                const magnifierView = img.closest('.magnifier-view');
                const containerWidth = magnifierView.clientWidth;
                const containerHeight = magnifierView.clientHeight / 3;
                img.style.left = `-${xPercent * (rect.width * ZOOM_LEVEL - containerWidth)}px`;
                img.style.top = `-${yPercent * (rect.height * ZOOM_LEVEL - containerHeight)}px`;
            });

            // Update labels with run comments and zoom level
            document.querySelectorAll('.magnifier-label').forEach((label, idx) => {
                let baseText;
                if (idx === 0) {
                    baseText = isImagesSwapped ? `Run B${activeRunBComment ? ` - ${activeRunBComment}` : ''}` : `Run A${activeRunAComment ? ` - ${activeRunAComment}` : ''}`;
                } else if (idx === 1) {
                    baseText = 'Diff';
                } else {
                    baseText = isImagesSwapped ? `Run A${activeRunAComment ? ` - ${activeRunAComment}` : ''}` : `Run B${activeRunBComment ? ` - ${activeRunBComment}` : ''}`;
                }
                label.textContent = `${baseText} - ${ZOOM_LEVEL}x`;
            });
        }

        // Handle zoom with Ctrl+mousewheel
        function handleZoom(e) {
            if (e.ctrlKey) {
                e.preventDefault(); // Prevent page zoom
                const delta = Math.sign(e.deltaY) * -ZOOM_STEP;
                const newZoom = Math.max(MIN_ZOOM, Math.min(MAX_ZOOM, ZOOM_LEVEL + delta));

                if (newZoom !== ZOOM_LEVEL) {
                    ZOOM_LEVEL = newZoom;
                    // Trigger mousemove to update the display
                    const mousemoveEvent = new MouseEvent('mousemove', {
                        clientX: e.clientX,
                        clientY: e.clientY,
                        bubbles: true
                    });
                    e.target.dispatchEvent(mousemoveEvent);
                }
            }
        }

        // Add mouse events to image containers
        document.querySelectorAll('[id^="capture-"]').forEach(container => {
            const originalUrl = container.dataset.original;
            const original2Url = container.dataset.original2;
            const diffUrl = container.dataset.diff;
            const runAComment = container.dataset.runAComment;
            const runBComment = container.dataset.runBComment;

            if (originalUrl && diffUrl != "None") {
                const previewImg = container.querySelector('.preview-image');

                previewImg.addEventListener('mousemove', (e) => {
                    activePreviewImg = previewImg;
                    activeOriginalUrl = originalUrl;
                    activeDiffUrl = diffUrl;
                    activeRunAComment = runAComment;
                    activeRunBComment = runBComment;
                    updateMagnifier(e, previewImg, originalUrl, original2Url, diffUrl);
                });

                previewImg.addEventListener('wheel', handleZoom);

                previewImg.addEventListener('mouseleave', () => {
                    magnifierContainer.style.display = 'none';
                    activePreviewImg = null;
                    activeOriginalUrl = null;
                    activeDiffUrl = null;
                    activeRunAComment = null;
                    activeRunBComment = null;
                });
            }
        });

        // Global space key handler for image swapping
        document.addEventListener('keydown', (e) => {
            if (e.code === 'Space' && magnifierContainer.style.display === 'block' && activePreviewImg) {
                e.preventDefault(); // Prevent page scroll
                isImagesSwapped = !isImagesSwapped;
                // Trigger mousemove to update the display
                const mousemoveEvent = new MouseEvent('mousemove', {
                    clientX: e.clientX,
                    clientY: e.clientY,
                    bubbles: true
                });
                activePreviewImg.dispatchEvent(mousemoveEvent);
            }
        });
    });
</script>