aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorSteven Perron <stevenperron@google.com>2017-10-24 15:13:13 -0400
committerDavid Neto <dneto@google.com>2017-10-28 18:48:21 -0400
commit716138ee14c88ba0f0aa65a9a995f67e5ad252ec (patch)
tree2ac6d02b4449691aac7736c6b6af6d0da67fe29f /include
parent6724c272515686398105813de0801407566ae914 (diff)
downloadspirv-tools-716138ee14c88ba0f0aa65a9a995f67e5ad252ec.tar.gz
Add option to relax validation of store types.
There are a number of users of spriv-opt that are hitting errors because of stores with different types. In general, this is wrong, but, in these cases, the types are the exact same except for decorations. The options is "--relax-store-struct", and it can be used with the validator or the optimizer. We assume that if layout information is missing it is consistent. For example if one struct has a offset of one of its members, and the other one does not, we will still consider them as being layout compatible. The problem will be if both struct has and offset decoration for corresponding members, and the offset are different.
Diffstat (limited to 'include')
-rw-r--r--include/spirv-tools/libspirv.h21
-rw-r--r--include/spirv-tools/libspirv.hpp4
2 files changed, 22 insertions, 3 deletions
diff --git a/include/spirv-tools/libspirv.h b/include/spirv-tools/libspirv.h
index b7bcc0f5..9119ca33 100644
--- a/include/spirv-tools/libspirv.h
+++ b/include/spirv-tools/libspirv.h
@@ -420,6 +420,19 @@ void spvValidatorOptionsSetUniversalLimit(spv_validator_options options,
spv_validator_limit limit_type,
uint32_t limit);
+// Record whether or not the validator should relax the rules on types for
+// stores to structs. When relaxed, it will allow a type mismatch as long as
+// the types are structs with the same layout. Two structs have the same layout
+// if
+//
+// 1) the members of the structs are either the same type or are structs with
+// same layout, and
+//
+// 2) the decorations that affect the memory layout are identical for both
+// types. Other decorations are not relevant.
+void spvValidatorOptionsSetRelaxStoreStruct(spv_validator_options options,
+ bool val);
+
// Encodes the given SPIR-V assembly text to its binary representation. The
// length parameter specifies the number of bytes for text. Encoded binary will
// be stored into *binary. Any error will be written into *diagnostic if
@@ -432,9 +445,11 @@ spv_result_t spvTextToBinary(const spv_const_context context, const char* text,
// Encodes the given SPIR-V assembly text to its binary representation. Same as
// spvTextToBinary but with options. The options parameter is a bit field of
// spv_text_to_binary_options_t.
-spv_result_t spvTextToBinaryWithOptions(
- const spv_const_context context, const char* text, const size_t length,
- const uint32_t options, spv_binary* binary, spv_diagnostic* diagnostic);
+spv_result_t spvTextToBinaryWithOptions(const spv_const_context context,
+ const char* text, const size_t length,
+ const uint32_t options,
+ spv_binary* binary,
+ spv_diagnostic* diagnostic);
// Frees an allocated text stream. This is a no-op if the text parameter
// is a null pointer.
diff --git a/include/spirv-tools/libspirv.hpp b/include/spirv-tools/libspirv.hpp
index f82c1348..9dbcf16e 100644
--- a/include/spirv-tools/libspirv.hpp
+++ b/include/spirv-tools/libspirv.hpp
@@ -44,6 +44,10 @@ class ValidatorOptions {
spvValidatorOptionsSetUniversalLimit(options_, limit_type, limit);
}
+ void SetRelaxStructStore(bool val) {
+ spvValidatorOptionsSetRelaxStoreStruct(options_, val);
+ }
+
private:
spv_validator_options options_;
};