Dejan Mircevski | b6fe02f | 2016-01-07 13:44:22 -0500 | [diff] [blame] | 1 | // Copyright (c) 2015-2016 The Khronos Group Inc. |
Lei Zhang | 972788b | 2015-11-12 13:48:30 -0500 | [diff] [blame] | 2 | // |
| 3 | // Permission is hereby granted, free of charge, to any person obtaining a |
| 4 | // copy of this software and/or associated documentation files (the |
| 5 | // "Materials"), to deal in the Materials without restriction, including |
| 6 | // without limitation the rights to use, copy, modify, merge, publish, |
| 7 | // distribute, sublicense, and/or sell copies of the Materials, and to |
| 8 | // permit persons to whom the Materials are furnished to do so, subject to |
| 9 | // the following conditions: |
| 10 | // |
| 11 | // The above copyright notice and this permission notice shall be included |
| 12 | // in all copies or substantial portions of the Materials. |
| 13 | // |
| 14 | // MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS |
| 15 | // KHRONOS STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS |
| 16 | // SPECIFICATIONS AND HEADER INFORMATION ARE LOCATED AT |
| 17 | // https://www.khronos.org/registry/ |
| 18 | // |
| 19 | // THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 20 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 21 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
| 22 | // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
| 23 | // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
| 24 | // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
| 25 | // MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. |
| 26 | |
| 27 | #include "table.h" |
| 28 | |
| 29 | #include <cstdlib> |
| 30 | |
Dejan Mircevski | 3d27da4 | 2016-03-31 12:16:51 -0400 | [diff] [blame] | 31 | spv_context spvContextCreate(spv_target_env env) { |
| 32 | switch (env) { |
Dejan Mircevski | 3d27da4 | 2016-03-31 12:16:51 -0400 | [diff] [blame] | 33 | case SPV_ENV_UNIVERSAL_1_0: |
Dejan Mircevski | 3d27da4 | 2016-03-31 12:16:51 -0400 | [diff] [blame] | 34 | case SPV_ENV_VULKAN_1_0: |
Dejan Mircevski | cb3c49e | 2016-04-07 14:41:34 -0400 | [diff] [blame] | 35 | case SPV_ENV_UNIVERSAL_1_1: |
Dejan Mircevski | 3d27da4 | 2016-03-31 12:16:51 -0400 | [diff] [blame] | 36 | break; |
| 37 | default: |
| 38 | return nullptr; |
| 39 | } |
| 40 | |
Lei Zhang | 972788b | 2015-11-12 13:48:30 -0500 | [diff] [blame] | 41 | spv_opcode_table opcode_table; |
| 42 | spv_operand_table operand_table; |
| 43 | spv_ext_inst_table ext_inst_table; |
| 44 | |
Dejan Mircevski | cb3c49e | 2016-04-07 14:41:34 -0400 | [diff] [blame] | 45 | spvOpcodeTableGet(&opcode_table, env); |
| 46 | spvOperandTableGet(&operand_table, env); |
| 47 | spvExtInstTableGet(&ext_inst_table, env); |
Lei Zhang | 972788b | 2015-11-12 13:48:30 -0500 | [diff] [blame] | 48 | |
Lei Zhang | 6fa3f8a | 2016-03-31 17:26:31 -0400 | [diff] [blame] | 49 | return new spv_context_t{env, opcode_table, operand_table, ext_inst_table}; |
Lei Zhang | 972788b | 2015-11-12 13:48:30 -0500 | [diff] [blame] | 50 | } |
| 51 | |
Lei Zhang | 4f293b7 | 2016-03-21 16:36:14 -0400 | [diff] [blame] | 52 | void spvContextDestroy(spv_context context) { delete context; } |