image.hpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * Copyright 2015-2017 ARM Limited
  3. * SPDX-License-Identifier: Apache-2.0
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License");
  6. * you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. #ifndef SPIRV_CROSS_IMAGE_HPP
  18. #define SPIRV_CROSS_IMAGE_HPP
  19. #ifndef GLM_SWIZZLE
  20. #define GLM_SWIZZLE
  21. #endif
  22. #ifndef GLM_FORCE_RADIANS
  23. #define GLM_FORCE_RADIANS
  24. #endif
  25. #include <glm/glm.hpp>
  26. namespace spirv_cross
  27. {
  28. template <typename T>
  29. struct image2DBase
  30. {
  31. virtual ~image2DBase() = default;
  32. inline virtual T load(glm::ivec2 coord) const
  33. {
  34. return T(0, 0, 0, 1);
  35. }
  36. inline virtual void store(glm::ivec2 coord, const T &v)
  37. {
  38. }
  39. };
  40. typedef image2DBase<glm::vec4> image2D;
  41. typedef image2DBase<glm::ivec4> iimage2D;
  42. typedef image2DBase<glm::uvec4> uimage2D;
  43. template <typename T>
  44. inline T imageLoad(const image2DBase<T> &image, glm::ivec2 coord)
  45. {
  46. return image.load(coord);
  47. }
  48. template <typename T>
  49. void imageStore(image2DBase<T> &image, glm::ivec2 coord, const T &value)
  50. {
  51. image.store(coord, value);
  52. }
  53. }
  54. #endif