GrVkUtil.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * Copyright 2015 Google Inc.
  3. *
  4. * Use of this source code is governed by a BSD-style license that can be
  5. * found in the LICENSE file.
  6. */
  7. #ifndef GrVkUtil_DEFINED
  8. #define GrVkUtil_DEFINED
  9. #include "include/gpu/GrTypes.h"
  10. #include "include/gpu/vk/GrVkTypes.h"
  11. #include "include/private/SkMacros.h"
  12. #include "src/gpu/GrColor.h"
  13. #include "src/gpu/GrDataUtils.h"
  14. #include "src/gpu/vk/GrVkInterface.h"
  15. #include "src/sksl/ir/SkSLProgram.h"
  16. class GrVkGpu;
  17. // makes a Vk call on the interface
  18. #define GR_VK_CALL(IFACE, X) (IFACE)->fFunctions.f##X
  19. // same as GR_VK_CALL but checks for success
  20. #ifdef SK_DEBUG
  21. #define GR_VK_CALL_ERRCHECK(IFACE, X) \
  22. VkResult SK_MACRO_APPEND_LINE(ret) = GR_VK_CALL(IFACE, X); \
  23. SkASSERT(VK_SUCCESS == SK_MACRO_APPEND_LINE(ret))
  24. #else
  25. #define GR_VK_CALL_ERRCHECK(IFACE, X) (void) GR_VK_CALL(IFACE, X)
  26. #endif
  27. /**
  28. * Returns the vulkan texture format for the given GrPixelConfig
  29. */
  30. bool GrPixelConfigToVkFormat(GrPixelConfig config, VkFormat* format);
  31. bool GrVkFormatIsSupported(VkFormat);
  32. #ifdef SK_DEBUG
  33. /**
  34. * Returns true if the passed in VkFormat and GrColorType are compatible with each other.
  35. */
  36. bool GrVkFormatColorTypePairIsValid(VkFormat, GrColorType);
  37. #endif
  38. bool GrSampleCountToVkSampleCount(uint32_t samples, VkSampleCountFlagBits* vkSamples);
  39. bool GrCompileVkShaderModule(const GrVkGpu* gpu,
  40. const SkSL::String& shaderString,
  41. VkShaderStageFlagBits stage,
  42. VkShaderModule* shaderModule,
  43. VkPipelineShaderStageCreateInfo* stageInfo,
  44. const SkSL::Program::Settings& settings,
  45. SkSL::String* outSPIRV,
  46. SkSL::Program::Inputs* outInputs);
  47. bool GrInstallVkShaderModule(const GrVkGpu* gpu,
  48. const SkSL::String& spirv,
  49. VkShaderStageFlagBits stage,
  50. VkShaderModule* shaderModule,
  51. VkPipelineShaderStageCreateInfo* stageInfo);
  52. size_t GrVkBytesPerFormat(VkFormat);
  53. /**
  54. * Returns true if the format is compressed.
  55. */
  56. bool GrVkFormatIsCompressed(VkFormat);
  57. /**
  58. * Maps a vk format into the CompressionType enum if applicable.
  59. */
  60. bool GrVkFormatToCompressionType(VkFormat vkFormat, SkImage::CompressionType* compressionType);
  61. #endif