2017-02-15 18:29:33 +00:00
|
|
|
// Copyright (c) 2017 Google Inc.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
2019-05-08 22:01:10 +00:00
|
|
|
#include "source/spirv_validator_options.h"
|
|
|
|
|
2017-02-15 18:29:33 +00:00
|
|
|
#include <cassert>
|
|
|
|
#include <cstring>
|
|
|
|
|
|
|
|
bool spvParseUniversalLimitsOptions(const char* s, spv_validator_limit* type) {
|
|
|
|
auto match = [s](const char* b) {
|
|
|
|
return s && (0 == strncmp(s, b, strlen(b)));
|
|
|
|
};
|
|
|
|
if (match("--max-struct-members")) {
|
|
|
|
*type = spv_validator_limit_max_struct_members;
|
|
|
|
} else if (match("--max-struct_depth")) {
|
|
|
|
*type = spv_validator_limit_max_struct_depth;
|
|
|
|
} else if (match("--max-local-variables")) {
|
|
|
|
*type = spv_validator_limit_max_local_variables;
|
|
|
|
} else if (match("--max-global-variables")) {
|
|
|
|
*type = spv_validator_limit_max_global_variables;
|
|
|
|
} else if (match("--max-switch-branches")) {
|
|
|
|
*type = spv_validator_limit_max_global_variables;
|
|
|
|
} else if (match("--max-function-args")) {
|
|
|
|
*type = spv_validator_limit_max_function_args;
|
|
|
|
} else if (match("--max-control-flow-nesting-depth")) {
|
|
|
|
*type = spv_validator_limit_max_control_flow_nesting_depth;
|
|
|
|
} else if (match("--max-access-chain-indexes")) {
|
|
|
|
*type = spv_validator_limit_max_access_chain_indexes;
|
2018-11-06 16:30:19 +00:00
|
|
|
} else if (match("--max-id-bound")) {
|
|
|
|
*type = spv_validator_limit_max_id_bound;
|
2017-02-15 18:29:33 +00:00
|
|
|
} else {
|
|
|
|
// The command line option for this validator limit has not been added.
|
|
|
|
// Therefore we return false.
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-03-23 20:17:52 +00:00
|
|
|
spv_validator_options spvValidatorOptionsCreate(void) {
|
2017-02-15 18:29:33 +00:00
|
|
|
return new spv_validator_options_t;
|
|
|
|
}
|
|
|
|
|
|
|
|
void spvValidatorOptionsDestroy(spv_validator_options options) {
|
|
|
|
delete options;
|
|
|
|
}
|
|
|
|
|
|
|
|
void spvValidatorOptionsSetUniversalLimit(spv_validator_options options,
|
|
|
|
spv_validator_limit limit_type,
|
|
|
|
uint32_t limit) {
|
|
|
|
assert(options && "Validator options object may not be Null");
|
2017-10-24 19:13:13 +00:00
|
|
|
switch (limit_type) {
|
2017-02-15 18:29:33 +00:00
|
|
|
#define LIMIT(TYPE, FIELD) \
|
2017-10-24 19:13:13 +00:00
|
|
|
case TYPE: \
|
|
|
|
options->universal_limits_.FIELD = limit; \
|
|
|
|
break;
|
|
|
|
LIMIT(spv_validator_limit_max_struct_members, max_struct_members)
|
|
|
|
LIMIT(spv_validator_limit_max_struct_depth, max_struct_depth)
|
|
|
|
LIMIT(spv_validator_limit_max_local_variables, max_local_variables)
|
|
|
|
LIMIT(spv_validator_limit_max_global_variables, max_global_variables)
|
|
|
|
LIMIT(spv_validator_limit_max_switch_branches, max_switch_branches)
|
|
|
|
LIMIT(spv_validator_limit_max_function_args, max_function_args)
|
|
|
|
LIMIT(spv_validator_limit_max_control_flow_nesting_depth,
|
|
|
|
max_control_flow_nesting_depth)
|
|
|
|
LIMIT(spv_validator_limit_max_access_chain_indexes,
|
|
|
|
max_access_chain_indexes)
|
2018-11-06 16:30:19 +00:00
|
|
|
LIMIT(spv_validator_limit_max_id_bound, max_id_bound)
|
2017-02-15 18:29:33 +00:00
|
|
|
#undef LIMIT
|
|
|
|
}
|
|
|
|
}
|
2017-10-24 19:13:13 +00:00
|
|
|
|
|
|
|
void spvValidatorOptionsSetRelaxStoreStruct(spv_validator_options options,
|
|
|
|
bool val) {
|
|
|
|
options->relax_struct_store = val;
|
|
|
|
}
|
2018-01-07 15:50:01 +00:00
|
|
|
|
|
|
|
void spvValidatorOptionsSetRelaxLogicalPointer(spv_validator_options options,
|
|
|
|
bool val) {
|
2018-05-17 07:49:19 +00:00
|
|
|
options->relax_logical_pointer = val;
|
|
|
|
}
|
|
|
|
|
2019-05-13 17:48:17 +00:00
|
|
|
void spvValidatorOptionsSetBeforeHlslLegalization(spv_validator_options options,
|
|
|
|
bool val) {
|
|
|
|
options->before_hlsl_legalization = val;
|
|
|
|
options->relax_logical_pointer = val;
|
|
|
|
}
|
|
|
|
|
2018-05-17 07:49:19 +00:00
|
|
|
void spvValidatorOptionsSetRelaxBlockLayout(spv_validator_options options,
|
|
|
|
bool val) {
|
|
|
|
options->relax_block_layout = val;
|
2018-01-07 15:50:01 +00:00
|
|
|
}
|
2018-07-11 20:53:19 +00:00
|
|
|
|
2019-05-08 22:01:10 +00:00
|
|
|
void spvValidatorOptionsSetUniformBufferStandardLayout(
|
|
|
|
spv_validator_options options, bool val) {
|
|
|
|
options->uniform_buffer_standard_layout = val;
|
|
|
|
}
|
|
|
|
|
2018-10-10 00:43:09 +00:00
|
|
|
void spvValidatorOptionsSetScalarBlockLayout(spv_validator_options options,
|
|
|
|
bool val) {
|
|
|
|
options->scalar_block_layout = val;
|
|
|
|
}
|
|
|
|
|
2018-07-11 20:53:19 +00:00
|
|
|
void spvValidatorOptionsSetSkipBlockLayout(spv_validator_options options,
|
|
|
|
bool val) {
|
|
|
|
options->skip_block_layout = val;
|
|
|
|
}
|