diff options
| author | Chris Forbes <chrisf@ijw.co.nz> | 2015-05-04 14:04:06 +1200 |
|---|---|---|
| committer | Chris Forbes <chrisf@ijw.co.nz> | 2015-05-12 04:53:40 +1200 |
| commit | f5959dbbeaa036de11313c44545469eeada09b5c (patch) | |
| tree | d56e796eea1d5cd263e15cac42f6f5aeec0e301e /layers/shader_checker.cpp | |
| parent | 06135b6641f8e9fee8d896d4eca76ca14fdecb31 (diff) | |
| download | usermoji-f5959dbbeaa036de11313c44545469eeada09b5c.tar.xz | |
shader_checker: add helper to walk a type tree and return the basic type
Diffstat (limited to 'layers/shader_checker.cpp')
| -rw-r--r-- | layers/shader_checker.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/layers/shader_checker.cpp b/layers/shader_checker.cpp index cb545d55..bb3b9225 100644 --- a/layers/shader_checker.cpp +++ b/layers/shader_checker.cpp @@ -584,6 +584,38 @@ get_format_type(VkFormat fmt) { } +/* characterizes a SPIR-V type appearing in an interface to a FF stage, + * for comparison to a VkFormat's characterization above. */ +static unsigned +get_fundamental_type(shader_source const *src, unsigned type) +{ + auto type_def_it = src->type_def_index.find(type); + + if (type_def_it == src->type_def_index.end()) { + return FORMAT_TYPE_UNDEFINED; + } + + unsigned int const *code = (unsigned int const *)&src->words[type_def_it->second]; + unsigned opcode = code[0] & 0x0ffffu; + switch (opcode) { + case spv::OpTypeInt: + return code[3] ? FORMAT_TYPE_SINT : FORMAT_TYPE_UINT; + case spv::OpTypeFloat: + return FORMAT_TYPE_FLOAT; + case spv::OpTypeVector: + return get_fundamental_type(src, code[2]); + case spv::OpTypeMatrix: + return get_fundamental_type(src, code[2]); + case spv::OpTypeArray: + return get_fundamental_type(src, code[2]); + case spv::OpTypePointer: + return get_fundamental_type(src, code[3]); + default: + return FORMAT_TYPE_UNDEFINED; + } +} + + static void validate_vi_against_vs_inputs(VkPipelineVertexInputCreateInfo const *vi, shader_source const *vs) { |
