Add adaptive feed texture probe

This commit is contained in:
Johanness
2026-05-21 11:35:46 +03:00
parent bccf6cfb10
commit 8ef858e3c8
3 changed files with 82 additions and 11 deletions
+11
View File
@@ -581,6 +581,10 @@ bool applyConfigFile(
{ {
config.v210UploadWorker = boolValue; config.v210UploadWorker = boolValue;
} }
if (jsonBool(objectField(*root, "adaptiveFeedTexture"), boolValue))
{
config.adaptiveFeedTexture = boolValue;
}
if (const std::string* present = if (const std::string* present =
jsonString(objectField(*root, "present"))) jsonString(objectField(*root, "present")))
@@ -814,6 +818,7 @@ void printUsage(const char* executableName)
<< " --verbose Enable detailed startup and SDK logs\n" << " --verbose Enable detailed startup and SDK logs\n"
<< " --pace-uploads Pace v210 uploads by feed frame rate\n" << " --pace-uploads Pace v210 uploads by feed frame rate\n"
<< " --v210-upload-worker Copy direct v210 payloads on a worker thread\n" << " --v210-upload-worker Copy direct v210 payloads on a worker thread\n"
<< " --adaptive-feed-texture Size feed textures to grid tile size\n"
<< " --config <path> Load JSON feed configuration\n" << " --config <path> Load JSON feed configuration\n"
<< " --grid <cols>x<rows> Set multiview grid (default 2x2, max 16 feeds)\n" << " --grid <cols>x<rows> Set multiview grid (default 2x2, max 16 feeds)\n"
<< " --fps-cap <fps> Limit render loop FPS (default 60)\n" << " --fps-cap <fps> Limit render loop FPS (default 60)\n"
@@ -966,6 +971,12 @@ ConfigParseResult parseAppConfig(
continue; continue;
} }
if (arg == "--adaptive-feed-texture")
{
result.config.adaptiveFeedTexture = true;
continue;
}
if (arg == "--v210-staging-memory") if (arg == "--v210-staging-memory")
{ {
if (i + 1 >= argc) if (i + 1 >= argc)
+1
View File
@@ -51,6 +51,7 @@ struct AppConfig
bool verbose = false; bool verbose = false;
bool paceUploads = false; bool paceUploads = false;
bool v210UploadWorker = false; bool v210UploadWorker = false;
bool adaptiveFeedTexture = false;
uint32_t fpsCap = 60; uint32_t fpsCap = 60;
uint32_t maxV210UploadsPerFrame = 0; uint32_t maxV210UploadsPerFrame = 0;
uint32_t gridCols = DefaultGridCols; uint32_t gridCols = DefaultGridCols;
+70 -11
View File
@@ -22,6 +22,7 @@
#include <cstring> #include <cstring>
#include <deque> #include <deque>
#include <csignal> #include <csignal>
#include <cmath>
#include <filesystem> #include <filesystem>
#include <fstream> #include <fstream>
#include <limits> #include <limits>
@@ -45,6 +46,50 @@ constexpr float TILE_ASPECT = 16.0f / 9.0f;
static std::atomic<bool> g_running{true}; static std::atomic<bool> g_running{true};
struct FeedTextureSize
{
uint32_t width = TEXTURE_WIDTH;
uint32_t height = TEXTURE_HEIGHT;
};
FeedTextureSize chooseFeedTextureSize(
const AppConfig& config,
int windowWidth,
int windowHeight)
{
if (!config.adaptiveFeedTexture)
{
return {};
}
const std::vector<TileRect> rects =
makeGridTileRects(
config.gridCols,
config.gridRows,
static_cast<float>(windowWidth),
static_cast<float>(windowHeight),
TILE_GAP_PIXELS,
TILE_ASPECT);
if (rects.empty())
{
return {};
}
const TileRect& rect = rects.front();
const uint32_t tileWidth =
static_cast<uint32_t>(
std::max(1.0f, std::ceil(rect.x1 - rect.x0)));
const uint32_t tileHeight =
static_cast<uint32_t>(
std::max(1.0f, std::ceil(rect.y1 - rect.y0)));
return {
std::min(TEXTURE_WIDTH, tileWidth),
std::min(TEXTURE_HEIGHT, tileHeight)
};
}
struct PerfStats struct PerfStats
{ {
uint64_t frames = 0; uint64_t frames = 0;
@@ -749,6 +794,19 @@ int main(int argc, char* argv[])
int winWidth, winHeight; int winWidth, winHeight;
SDL_GetWindowSize(window, &winWidth, &winHeight); SDL_GetWindowSize(window, &winWidth, &winHeight);
const FeedTextureSize feedTextureSize =
chooseFeedTextureSize(config, winWidth, winHeight);
const uint32_t feedTextureWidth = feedTextureSize.width;
const uint32_t feedTextureHeight = feedTextureSize.height;
std::cout
<< "Feed texture size: "
<< feedTextureWidth
<< "x"
<< feedTextureHeight
<< (config.adaptiveFeedTexture ? " adaptive" : " fixed")
<< std::endl;
Swapchain swapchain( Swapchain swapchain(
ctx.device(), ctx.device(),
ctx.physicalDevice(), ctx.physicalDevice(),
@@ -841,8 +899,8 @@ int main(int argc, char* argv[])
feeds[i] = createFeed( feeds[i] = createFeed(
config.feeds[i], config.feeds[i],
i, i,
TEXTURE_WIDTH, feedTextureWidth,
TEXTURE_HEIGHT, feedTextureHeight,
config.verbose config.verbose
); );
} }
@@ -852,7 +910,8 @@ int main(int argc, char* argv[])
// ---------------------------------------- // ----------------------------------------
VkDeviceSize imageSize = VkDeviceSize imageSize =
TEXTURE_WIDTH * TEXTURE_HEIGHT * 4; static_cast<VkDeviceSize>(feedTextureWidth) *
feedTextureHeight * 4;
std::vector<FeedTexture> feedTextures(feedCount); std::vector<FeedTexture> feedTextures(feedCount);
@@ -960,8 +1019,8 @@ int main(int argc, char* argv[])
v210Decoder.init( v210Decoder.init(
ctx.device(), ctx.device(),
feedCount, feedCount,
TEXTURE_WIDTH, feedTextureWidth,
TEXTURE_HEIGHT feedTextureHeight
); );
std::vector<V210ComputeFeed> v210Feeds(feedCount); std::vector<V210ComputeFeed> v210Feeds(feedCount);
@@ -1806,8 +1865,8 @@ int main(int argc, char* argv[])
feeds[i]->v210Width(), feeds[i]->v210Width(),
feeds[i]->v210Height(), feeds[i]->v210Height(),
feeds[i]->v210Stride(), feeds[i]->v210Stride(),
TEXTURE_WIDTH, feedTextureWidth,
TEXTURE_HEIGHT, feedTextureHeight,
config.v210StagingMemoryMode, config.v210StagingMemoryMode,
v210Feeds[i] v210Feeds[i]
); );
@@ -2084,8 +2143,8 @@ int main(int argc, char* argv[])
feeds[i]->v210Width(), feeds[i]->v210Width(),
feeds[i]->v210Height(), feeds[i]->v210Height(),
feeds[i]->v210Stride(), feeds[i]->v210Stride(),
TEXTURE_WIDTH, feedTextureWidth,
TEXTURE_HEIGHT feedTextureHeight
); );
v210Decoder.recordOutputReadyForSampling( v210Decoder.recordOutputReadyForSampling(
@@ -2098,8 +2157,8 @@ int main(int argc, char* argv[])
recordFeedTextureUpload( recordFeedTextureUpload(
uploadCmdBuf, uploadCmdBuf,
feedTextures[i], feedTextures[i],
TEXTURE_WIDTH, feedTextureWidth,
TEXTURE_HEIGHT feedTextureHeight
); );
} }
} }