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 8 #ifndef GrVkUtil_DEFINED 9 #define GrVkUtil_DEFINED 10 11 #include "GrColor.h" 12 #include "GrTypes.h" 13 #include "GrVkInterface.h" 14 #include "SkMacros.h" 15 #include "ir/SkSLProgram.h" 16 #include "vk/GrVkTypes.h" 17 18 class GrVkGpu; 19 20 // makes a Vk call on the interface 21 #define GR_VK_CALL(IFACE, X) (IFACE)->fFunctions.f##X 22 // same as GR_VK_CALL but checks for success 23 #ifdef SK_DEBUG 24 #define GR_VK_CALL_ERRCHECK(IFACE, X) \ 25 VkResult SK_MACRO_APPEND_LINE(ret) = GR_VK_CALL(IFACE, X); \ 26 SkASSERT(VK_SUCCESS == SK_MACRO_APPEND_LINE(ret)) 27 #else 28 #define GR_VK_CALL_ERRCHECK(IFACE, X) (void) GR_VK_CALL(IFACE, X) 29 #endif 30 31 /** 32 * Returns the vulkan texture format for the given GrPixelConfig 33 */ 34 bool GrPixelConfigToVkFormat(GrPixelConfig config, VkFormat* format); 35 36 bool GrVkFormatIsSupported(VkFormat); 37 38 #ifdef SK_DEBUG 39 /** 40 * Returns true if the passed in VkFormat and GrPixelConfig are compatible with each other. 41 */ 42 bool GrVkFormatPixelConfigPairIsValid(VkFormat, GrPixelConfig); 43 #endif 44 45 bool GrSampleCountToVkSampleCount(uint32_t samples, VkSampleCountFlagBits* vkSamples); 46 47 bool GrCompileVkShaderModule(const GrVkGpu* gpu, 48 const char* shaderString, 49 VkShaderStageFlagBits stage, 50 VkShaderModule* shaderModule, 51 VkPipelineShaderStageCreateInfo* stageInfo, 52 const SkSL::Program::Settings& settings, 53 SkSL::String* outSPIRV, 54 SkSL::Program::Inputs* outInputs); 55 56 bool GrInstallVkShaderModule(const GrVkGpu* gpu, 57 const SkSL::String& spirv, 58 VkShaderStageFlagBits stage, 59 VkShaderModule* shaderModule, 60 VkPipelineShaderStageCreateInfo* stageInfo); 61 62 #endif 63