Skip to content

Commit

Permalink
make spv_target_env configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
rjodinchr committed Jan 10, 2024
1 parent 92788c0 commit 5a3bdcc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
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

0 comments on commit 5a3bdcc

Please sign in to comment.