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

make spv_target_env configurable #4

Merged
merged 1 commit into from
Jan 10, 2024
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ Required options:

Optional options:

* `-e`: allow to choose the `spv_target_env` to use when using a non-binary input to convert it to binary (default: `vulkan1.3`)
* `-n`: allow to run the program multiple times
* `-m`: allow to run the program multiple times before starting to benchmark it
* `-v`: enable the verbose mode which is mainly use for debug purpose.
Expand Down
18 changes: 15 additions & 3 deletions runner/runner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ static std::string gInput = "";
static uint32_t gColdRun = 0, gHotRun = 1;
static VkBuffer gCounterBuffer;
static VkDeviceMemory gCounterMemory;
static spv_target_env gSpvTargetEnv = SPV_ENV_VULKAN_1_3;

static const uint32_t gNbGpuTimestamps = 3;

Expand Down Expand Up @@ -191,7 +192,7 @@ static bool extract_from_input(std::vector<uint32_t> &shader, std::vector<spvtoo
fclose(input);

const uint32_t spirv_magic = 0x07230203;
spv_context context = spvContextCreate(SPV_ENV_UNIVERSAL_1_0);
spv_context context = spvContextCreate(gSpvTargetEnv);
uint32_t *binary = (uint32_t *)input_buffer.data();
size_t size = input_size / sizeof(uint32_t);
spv_binary tmp_binary;
Expand Down Expand Up @@ -765,8 +766,18 @@ static bool parse_args(int argc, char **argv)
{
bool bHelp = false;
int c;
while ((c = getopt(argc, argv, "hvi:n:m:")) != -1) {
while ((c = getopt(argc, argv, "hvi:n:m:e:")) != -1) {
switch (c) {
case 'e': {
spv_target_env env;
if (spvParseTargetEnv(optarg, &env)) {
gSpvTargetEnv = env;
} else {
ERROR("Could not parse spv target env, using default: '%s'", spvTargetEnvDescription(gSpvTargetEnv));
}

}
break;
case 'n':
gHotRun = atoi(optarg);
break;
Expand Down Expand Up @@ -801,7 +812,8 @@ int main(int argc, char **argv)
if (!parse_args(argc, argv)) {
return -1;
}
PRINT("Arguments parsed: input '%s' verbose '%u'", gInput.c_str(), gVerbose);
PRINT("Arguments parsed: input '%s' verbose '%u' spv_target_env '%s' hot_runs '%u' cold_runs '%u'", gInput.c_str(),
gVerbose, spvTargetEnvDescription(gSpvTargetEnv), gHotRun, gColdRun);

std::vector<uint32_t> shader;
std::vector<spvtools::vksp_descriptor_set> dsVector;
Expand Down