table.cpp 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. #include "source/table.h"
  15. #include <utility>
  16. spv_context spvContextCreate(spv_target_env env) {
  17. switch (env) {
  18. case SPV_ENV_UNIVERSAL_1_0:
  19. case SPV_ENV_VULKAN_1_0:
  20. case SPV_ENV_UNIVERSAL_1_1:
  21. case SPV_ENV_OPENCL_1_2:
  22. case SPV_ENV_OPENCL_EMBEDDED_1_2:
  23. case SPV_ENV_OPENCL_2_0:
  24. case SPV_ENV_OPENCL_EMBEDDED_2_0:
  25. case SPV_ENV_OPENCL_2_1:
  26. case SPV_ENV_OPENCL_EMBEDDED_2_1:
  27. case SPV_ENV_OPENCL_2_2:
  28. case SPV_ENV_OPENCL_EMBEDDED_2_2:
  29. case SPV_ENV_OPENGL_4_0:
  30. case SPV_ENV_OPENGL_4_1:
  31. case SPV_ENV_OPENGL_4_2:
  32. case SPV_ENV_OPENGL_4_3:
  33. case SPV_ENV_OPENGL_4_5:
  34. case SPV_ENV_UNIVERSAL_1_2:
  35. case SPV_ENV_UNIVERSAL_1_3:
  36. case SPV_ENV_VULKAN_1_1:
  37. case SPV_ENV_VULKAN_1_1_SPIRV_1_4:
  38. case SPV_ENV_UNIVERSAL_1_4:
  39. case SPV_ENV_UNIVERSAL_1_5:
  40. case SPV_ENV_VULKAN_1_2:
  41. case SPV_ENV_UNIVERSAL_1_6:
  42. case SPV_ENV_VULKAN_1_3:
  43. break;
  44. default:
  45. return nullptr;
  46. }
  47. spv_opcode_table opcode_table;
  48. spv_operand_table operand_table;
  49. spv_ext_inst_table ext_inst_table;
  50. spvOpcodeTableGet(&opcode_table, env);
  51. spvOperandTableGet(&operand_table, env);
  52. spvExtInstTableGet(&ext_inst_table, env);
  53. return new spv_context_t{env, opcode_table, operand_table, ext_inst_table,
  54. nullptr /* a null default consumer */};
  55. }
  56. void spvContextDestroy(spv_context context) { delete context; }
  57. void spvtools::SetContextMessageConsumer(spv_context context,
  58. spvtools::MessageConsumer consumer) {
  59. context->consumer = std::move(consumer);
  60. }