• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2015-2016 The Khronos Group Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //     http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #include "table.h"
16 
17 #include <utility>
18 
spvContextCreate(spv_target_env env)19 spv_context spvContextCreate(spv_target_env env) {
20   switch (env) {
21     case SPV_ENV_UNIVERSAL_1_0:
22     case SPV_ENV_VULKAN_1_0:
23     case SPV_ENV_UNIVERSAL_1_1:
24     case SPV_ENV_OPENCL_2_1:
25     case SPV_ENV_OPENCL_2_2:
26     case SPV_ENV_OPENGL_4_0:
27     case SPV_ENV_OPENGL_4_1:
28     case SPV_ENV_OPENGL_4_2:
29     case SPV_ENV_OPENGL_4_3:
30     case SPV_ENV_OPENGL_4_5:
31     case SPV_ENV_UNIVERSAL_1_2:
32       break;
33     default:
34       return nullptr;
35   }
36 
37   spv_opcode_table opcode_table;
38   spv_operand_table operand_table;
39   spv_ext_inst_table ext_inst_table;
40 
41   spvOpcodeTableGet(&opcode_table, env);
42   spvOperandTableGet(&operand_table, env);
43   spvExtInstTableGet(&ext_inst_table, env);
44 
45   return new spv_context_t{env, opcode_table, operand_table, ext_inst_table,
46                            nullptr /* a null default consumer */};
47 }
48 
spvContextDestroy(spv_context context)49 void spvContextDestroy(spv_context context) { delete context; }
50 
SetContextMessageConsumer(spv_context context,spvtools::MessageConsumer consumer)51 void SetContextMessageConsumer(spv_context context,
52                                spvtools::MessageConsumer consumer) {
53   context->consumer = std::move(consumer);
54 }
55