Add adaptive feed texture probe
This commit is contained in:
@@ -581,6 +581,10 @@ bool applyConfigFile(
|
||||
{
|
||||
config.v210UploadWorker = boolValue;
|
||||
}
|
||||
if (jsonBool(objectField(*root, "adaptiveFeedTexture"), boolValue))
|
||||
{
|
||||
config.adaptiveFeedTexture = boolValue;
|
||||
}
|
||||
|
||||
if (const std::string* present =
|
||||
jsonString(objectField(*root, "present")))
|
||||
@@ -814,6 +818,7 @@ void printUsage(const char* executableName)
|
||||
<< " --verbose Enable detailed startup and SDK logs\n"
|
||||
<< " --pace-uploads Pace v210 uploads by feed frame rate\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"
|
||||
<< " --grid <cols>x<rows> Set multiview grid (default 2x2, max 16 feeds)\n"
|
||||
<< " --fps-cap <fps> Limit render loop FPS (default 60)\n"
|
||||
@@ -966,6 +971,12 @@ ConfigParseResult parseAppConfig(
|
||||
continue;
|
||||
}
|
||||
|
||||
if (arg == "--adaptive-feed-texture")
|
||||
{
|
||||
result.config.adaptiveFeedTexture = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (arg == "--v210-staging-memory")
|
||||
{
|
||||
if (i + 1 >= argc)
|
||||
|
||||
@@ -51,6 +51,7 @@ struct AppConfig
|
||||
bool verbose = false;
|
||||
bool paceUploads = false;
|
||||
bool v210UploadWorker = false;
|
||||
bool adaptiveFeedTexture = false;
|
||||
uint32_t fpsCap = 60;
|
||||
uint32_t maxV210UploadsPerFrame = 0;
|
||||
uint32_t gridCols = DefaultGridCols;
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include <cstring>
|
||||
#include <deque>
|
||||
#include <csignal>
|
||||
#include <cmath>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <limits>
|
||||
@@ -45,6 +46,50 @@ constexpr float TILE_ASPECT = 16.0f / 9.0f;
|
||||
|
||||
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
|
||||
{
|
||||
uint64_t frames = 0;
|
||||
@@ -749,6 +794,19 @@ int main(int argc, char* argv[])
|
||||
int 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(
|
||||
ctx.device(),
|
||||
ctx.physicalDevice(),
|
||||
@@ -841,8 +899,8 @@ int main(int argc, char* argv[])
|
||||
feeds[i] = createFeed(
|
||||
config.feeds[i],
|
||||
i,
|
||||
TEXTURE_WIDTH,
|
||||
TEXTURE_HEIGHT,
|
||||
feedTextureWidth,
|
||||
feedTextureHeight,
|
||||
config.verbose
|
||||
);
|
||||
}
|
||||
@@ -852,7 +910,8 @@ int main(int argc, char* argv[])
|
||||
// ----------------------------------------
|
||||
|
||||
VkDeviceSize imageSize =
|
||||
TEXTURE_WIDTH * TEXTURE_HEIGHT * 4;
|
||||
static_cast<VkDeviceSize>(feedTextureWidth) *
|
||||
feedTextureHeight * 4;
|
||||
|
||||
std::vector<FeedTexture> feedTextures(feedCount);
|
||||
|
||||
@@ -960,8 +1019,8 @@ int main(int argc, char* argv[])
|
||||
v210Decoder.init(
|
||||
ctx.device(),
|
||||
feedCount,
|
||||
TEXTURE_WIDTH,
|
||||
TEXTURE_HEIGHT
|
||||
feedTextureWidth,
|
||||
feedTextureHeight
|
||||
);
|
||||
|
||||
std::vector<V210ComputeFeed> v210Feeds(feedCount);
|
||||
@@ -1806,8 +1865,8 @@ int main(int argc, char* argv[])
|
||||
feeds[i]->v210Width(),
|
||||
feeds[i]->v210Height(),
|
||||
feeds[i]->v210Stride(),
|
||||
TEXTURE_WIDTH,
|
||||
TEXTURE_HEIGHT,
|
||||
feedTextureWidth,
|
||||
feedTextureHeight,
|
||||
config.v210StagingMemoryMode,
|
||||
v210Feeds[i]
|
||||
);
|
||||
@@ -2084,8 +2143,8 @@ int main(int argc, char* argv[])
|
||||
feeds[i]->v210Width(),
|
||||
feeds[i]->v210Height(),
|
||||
feeds[i]->v210Stride(),
|
||||
TEXTURE_WIDTH,
|
||||
TEXTURE_HEIGHT
|
||||
feedTextureWidth,
|
||||
feedTextureHeight
|
||||
);
|
||||
|
||||
v210Decoder.recordOutputReadyForSampling(
|
||||
@@ -2098,8 +2157,8 @@ int main(int argc, char* argv[])
|
||||
recordFeedTextureUpload(
|
||||
uploadCmdBuf,
|
||||
feedTextures[i],
|
||||
TEXTURE_WIDTH,
|
||||
TEXTURE_HEIGHT
|
||||
feedTextureWidth,
|
||||
feedTextureHeight
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user