Scrub 'OLD code' comment framing and a getenv warning from tooling
The vk_capture_perf_test comments described its synchronous reference arm as "the OLD code"; it is a deliberately-constructed slow baseline the test compares against, not removed history -- reworded to say so. Replace the last std::getenv (tone_source.hpp) with GetEnvironmentVariableA, dropping the C4996 deprecation warning from every audio-tone build, and drop the now-unused cstdint/cstdlib includes. Generalize a game-name aside in the header comment.
This commit is contained in:
@@ -8,13 +8,13 @@
|
|||||||
//
|
//
|
||||||
// This test builds a known gradient image (in PRESENT_SRC layout) on a real device and measures the
|
// This test builds a known gradient image (in PRESENT_SRC layout) on a real device and measures the
|
||||||
// time the *present thread* spends per capture for two implementations:
|
// time the *present thread* spends per capture for two implementations:
|
||||||
// * a synchronous reference that mirrors the OLD code (copy + WaitForFences + read the
|
// * a synchronous reference (copy + WaitForFences + read the HOST_COHERENT mapping + swizzle, all
|
||||||
// HOST_COHERENT mapping + swizzle, all inline) -> reproduces the stall, and
|
// inline) -> reproduces the stall, and
|
||||||
// * coop::hook::VkCapture (the fix: present thread only records+submits; a reaper thread does the
|
// * coop::hook::VkCapture (present thread only records+submits; a reaper thread does the
|
||||||
// HOST_CACHED read-back + swizzle + upload off the critical path).
|
// HOST_CACHED read-back + swizzle + upload off the critical path).
|
||||||
// It asserts the fixed present-thread cost is a small fraction of the synchronous cost, and that the
|
// It asserts VkCapture's present-thread cost is a small fraction of the synchronous cost, and that
|
||||||
// captured image is byte-correct (BGRA->RGBA swizzle). `--sync` routes the measured path through the
|
// the captured image is byte-correct (BGRA->RGBA swizzle). `--sync` routes the measured path through
|
||||||
// synchronous reference so the same assertion FAILS, demonstrating the test catches the regression.
|
// the synchronous reference so the same assertion FAILS, demonstrating the test catches the regression.
|
||||||
//
|
//
|
||||||
// Needs a working Vulkan ICD (the dev box has one). With no vulkan-1.dll / no device it SKIPs.
|
// Needs a working Vulkan ICD (the dev box has one). With no vulkan-1.dll / no device it SKIPs.
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
@@ -391,7 +391,7 @@ int main(int argc, char** argv)
|
|||||||
submit_wait(cb);
|
submit_wait(cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- Synchronous reference (mirrors the OLD code: HOST_COHERENT staging, inline read-back) ------
|
// --- Synchronous reference (HOST_COHERENT staging, inline read-back on the present thread) ------
|
||||||
VkBuffer ref_buf = VK_NULL_HANDLE;
|
VkBuffer ref_buf = VK_NULL_HANDLE;
|
||||||
VkDeviceMemory ref_mem = VK_NULL_HANDLE;
|
VkDeviceMemory ref_mem = VK_NULL_HANDLE;
|
||||||
void* ref_mapped = nullptr;
|
void* ref_mapped = nullptr;
|
||||||
@@ -443,8 +443,8 @@ int main(int argc, char** argv)
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Time the synchronous reference (a few iterations; this is the per-present cost the OLD code put
|
// Time the synchronous reference (a few iterations; this is the per-present cost an inline
|
||||||
// on the game's present thread).
|
// read-back puts on the game's present thread).
|
||||||
sync_capture(); // warm
|
sync_capture(); // warm
|
||||||
double sync_ms = 0;
|
double sync_ms = 0;
|
||||||
const int iters = 8;
|
const int iters = 8;
|
||||||
@@ -527,7 +527,7 @@ int main(int argc, char** argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// The core assertion: the measured present-thread cost must be a small fraction of the synchronous
|
// The core assertion: the measured present-thread cost must be a small fraction of the synchronous
|
||||||
// read-back cost (the fix moves the read-back off the present thread). In --sync repro mode the
|
// read-back cost (VkCapture moves the read-back off the present thread). In --sync repro mode the
|
||||||
// measured path IS the synchronous one, so this fails -- demonstrating the test catches the bug.
|
// measured path IS the synchronous one, so this fails -- demonstrating the test catches the bug.
|
||||||
std::printf("present-thread cost: measured %.3f ms vs synchronous %.2f ms (ratio %.3f)\n", sut_ms, sync_ms,
|
std::printf("present-thread cost: measured %.3f ms vs synchronous %.2f ms (ratio %.3f)\n", sut_ms, sync_ms,
|
||||||
sut_ms / sync_ms);
|
sut_ms / sync_ms);
|
||||||
|
|||||||
@@ -1,13 +1,11 @@
|
|||||||
// Configurable WASAPI sine-tone render source, shared by coop_tone.exe and the audio
|
// Configurable WASAPI sine-tone render source, shared by coop_tone.exe and the audio
|
||||||
// render-hook self-test. Opens a shared-mode render client at a requested format
|
// render-hook self-test. Opens a shared-mode render client at a requested format
|
||||||
// (sample rate / channels / bits / float vs PCM) using AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM,
|
// (sample rate / channels / bits / float vs PCM) using AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM,
|
||||||
// so it can render formats that differ from the device mix format -- exactly how games
|
// so it can render formats that differ from the device mix format -- exactly the case a
|
||||||
// like Godot render 44100 Hz on a 48000 Hz endpoint, the case the hook must detect.
|
// game rendering 44100 Hz on a 48000 Hz endpoint creates, which the hook must detect.
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <cstdint>
|
|
||||||
#include <cstdlib>
|
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
@@ -91,7 +89,8 @@ public:
|
|||||||
// Optional: give each channel genuinely different content (a per-channel frequency scale),
|
// Optional: give each channel genuinely different content (a per-channel frequency scale),
|
||||||
// so a downstream test can *recover* the channel count by correlation (identical channels
|
// so a downstream test can *recover* the channel count by correlation (identical channels
|
||||||
// are ambiguous: 2ch@R looks like 1ch@2R). Off by default -> the usual single-tone source.
|
// are ambiguous: 2ch@R looks like 1ch@2R). Off by default -> the usual single-tone source.
|
||||||
if (const char* d = std::getenv("COOP_TONE_DISTINCT_CH"); d != nullptr && d[0] == '1')
|
char d[2] = {};
|
||||||
|
if (GetEnvironmentVariableA("COOP_TONE_DISTINCT_CH", d, sizeof(d)) > 0 && d[0] == '1')
|
||||||
{
|
{
|
||||||
distinct_ = true;
|
distinct_ = true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user