mirror of
https://github.com/KhronosGroup/SPIRV-Tools
synced 2024-11-22 11:40:05 +00:00
Turn --vulkan into --target-env.
This commit is contained in:
parent
dc4c2ba7dc
commit
7648187c34
@ -351,6 +351,10 @@ typedef enum {
|
||||
// Returns a string describing the given SPIR-V target environment.
|
||||
const char* spvTargetEnvDescription(spv_target_env env);
|
||||
|
||||
// Parses s into *env and returns true if successful. If unparsable, returns
|
||||
// false and sets *env to SPV_ENV_UNIVERSAL_1_0.
|
||||
bool spvParseTargetEnv(const char* s, spv_target_env* env);
|
||||
|
||||
// Creates a context object. Returns null if env is invalid.
|
||||
spv_context spvContextCreate(spv_target_env env);
|
||||
|
||||
|
@ -24,7 +24,8 @@
|
||||
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
// MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
|
||||
|
||||
#include <assert.h>
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
|
||||
#include "spirv-tools/libspirv.h"
|
||||
#include "spirv_constant.h"
|
||||
@ -57,3 +58,19 @@ uint32_t spvVersionForTargetEnv(spv_target_env env) {
|
||||
assert(0 && "Unhandled SPIR-V target environment");
|
||||
return SPV_SPIRV_VERSION_WORD(0, 0);
|
||||
}
|
||||
|
||||
bool spvParseTargetEnv(const char* s, spv_target_env* env) {
|
||||
if (!strncmp(s, "vulkan1.0", strlen("vulkan1.0"))) {
|
||||
if (env) *env = SPV_ENV_VULKAN_1_0;
|
||||
return true;
|
||||
} else if (!strncmp(s, "spv1.0", strlen("spv1.0"))) {
|
||||
if (env) *env = SPV_ENV_UNIVERSAL_1_0;
|
||||
return true;
|
||||
} else if (!strncmp(s, "spv1.1", strlen("spv1.1"))) {
|
||||
if (env) *env = SPV_ENV_UNIVERSAL_1_1;
|
||||
return true;
|
||||
} else {
|
||||
if (env) *env = SPV_ENV_UNIVERSAL_1_0;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -24,10 +24,9 @@
|
||||
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
// MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <cassert>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <vector>
|
||||
|
||||
#include "spirv-tools/libspirv.h"
|
||||
@ -46,6 +45,8 @@ NOTE: The validator is a work in progress.
|
||||
Options:
|
||||
-h, --help Print this help.
|
||||
--version Display validator version information.
|
||||
--target-env {vulkan1.0|spv1.0|spv1.1}
|
||||
Use Vulkan/SPIR-V1.0/SPIR-V1.1 validation rules.
|
||||
)",
|
||||
argv0, argv0);
|
||||
}
|
||||
@ -66,8 +67,17 @@ int main(int argc, char** argv) {
|
||||
} else if (0 == strcmp(cur_arg, "--help") || 0 == strcmp(cur_arg, "-h")) {
|
||||
print_usage(argv[0]);
|
||||
return 0;
|
||||
} else if (0 == strcmp(cur_arg, "--vulkan")) {
|
||||
target_env = SPV_ENV_VULKAN_1_0;
|
||||
} else if (0 == strcmp(cur_arg, "--target-env")) {
|
||||
if (argi + 1 < argc) {
|
||||
const auto env_str = argv[++argi];
|
||||
if (!spvParseTargetEnv(env_str, &target_env)) {
|
||||
fprintf(stderr, "error: Unrecognized target env: %s\n", env_str);
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
fprintf(stderr, "error: Missing argument to --target-env\n");
|
||||
return 1;
|
||||
}
|
||||
} else if (0 == cur_arg[1]) {
|
||||
// Setting a filename of "-" to indicate stdin.
|
||||
if (!inFile) {
|
||||
|
Loading…
Reference in New Issue
Block a user