Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show adapter info in slang-test #6388

Merged
merged 5 commits into from
Feb 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions tools/render-test/options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,10 @@ static rhi::DeviceType _toRenderType(Slang::RenderApiType apiType)
{
outOptions.dx12Experimental = true;
}
else if (argValue == "-show-adapter-info")
{
outOptions.showAdapterInfo = true;
}
else
{
// Lookup
Expand Down
2 changes: 2 additions & 0 deletions tools/render-test/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ struct Options

bool dx12Experimental = false;

bool showAdapterInfo = false;

Options() { downstreamArgs.addName("slang"); }

static SlangResult parse(
Expand Down
8 changes: 8 additions & 0 deletions tools/render-test/render-test-main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1450,6 +1450,14 @@ static SlangResult _innerMain(
}
}

// Print adapter info after device creation but before any other operations
if (options.showAdapterInfo)
{
auto info = device->getDeviceInfo();
auto out = stdWriters->getOut();
out.print("Using graphics adapter: %s\n", info.adapterName);
}

// If the only test is we can startup, then we are done
if (options.onlyStartup)
{
Expand Down
4 changes: 4 additions & 0 deletions tools/slang-test/options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,10 @@ static bool _isSubCommand(const char* arg)
}
optionsOut->testDir = *argCursor++;
}
else if (strcmp(arg, "-show-adapter-info") == 0)
{
optionsOut->showAdapterInfo = true;
}
else
{
stdError.print("unknown option '%s'\n", arg);
Expand Down
3 changes: 3 additions & 0 deletions tools/slang-test/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ struct Options
// The adapter to use. If empty will match first found adapter.
Slang::String adapter;

// If true, print detailed adapter information
bool showAdapterInfo = false;

// Maximum number of test servers to run.
int serverCount = 1;

Expand Down
41 changes: 41 additions & 0 deletions tools/slang-test/slang-test-main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1391,6 +1391,47 @@ static RenderApiFlags _getAvailableRenderApiFlags(TestContext* context)
}
}

// After determining available APIs, print adapter info for each one
if (context->options.showAdapterInfo && availableRenderApiFlags)
{
StdWriters::getOut().print("\nAdapter Information for Available APIs:\n");
for (int i = 0; i < int(RenderApiType::CountOf); ++i)
{
const RenderApiType apiType = RenderApiType(i);
const RenderApiFlags apiFlag = RenderApiFlags(1) << int(apiType);

if (availableRenderApiFlags & apiFlag)
{
// Create command line to query adapter info
CommandLine cmdLine;
cmdLine.setExecutableLocation(
ExecutableLocation(context->options.binDir, "render-test"));

// Add the API type
StringBuilder builder;
builder << "-" << RenderApiUtil::getApiName(apiType);
cmdLine.addArg(builder);

// Add flags to show adapter info and only startup
cmdLine.addArg("-show-adapter-info");
cmdLine.addArg("-only-startup");

// Run render-test to get adapter info
ExecuteResult exeRes;
if (SLANG_SUCCEEDED(
spawnAndWaitSharedLibrary(context, "adapter-info", cmdLine, exeRes)))
{
// Output the adapter info
StdWriters::getOut().print(
"\n%s:\n%s",
RenderApiUtil::getApiName(apiType).begin(),
exeRes.standardOutput.getBuffer());
}
}
}
StdWriters::getOut().print("\n");
}

context->availableRenderApiFlags = availableRenderApiFlags;
context->isAvailableRenderApiFlagsValid = true;
}
Expand Down
Loading