Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 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 | |
Greg Daniel | 54bfb18 | 2018-11-20 17:12:36 -0500 | [diff] [blame] | 11 | #include "GrVkVulkan.h" |
| 12 | |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 13 | #include "GrColor.h" |
| 14 | #include "GrTypes.h" |
Greg Daniel | d3e65aa | 2018-08-01 09:19:45 -0400 | [diff] [blame] | 15 | #include "GrVkInterface.h" |
Hal Canary | 22be4c4 | 2018-06-12 12:37:31 -0400 | [diff] [blame] | 16 | #include "SkMacros.h" |
| 17 | #include "ir/SkSLProgram.h" |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 18 | |
egdaniel | 88987d8 | 2016-09-19 10:17:34 -0700 | [diff] [blame] | 19 | class GrVkGpu; |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 20 | |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 21 | // makes a Vk call on the interface |
Brian Salomon | 2335644 | 2018-11-30 15:33:19 -0500 | [diff] [blame] | 22 | #define GR_VK_CALL(IFACE, X) (IFACE)->fFunctions.f##X |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 23 | // same as GR_VK_CALL but checks for success |
| 24 | #ifdef SK_DEBUG |
Brian Salomon | 2335644 | 2018-11-30 15:33:19 -0500 | [diff] [blame] | 25 | #define GR_VK_CALL_ERRCHECK(IFACE, X) \ |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 26 | VkResult SK_MACRO_APPEND_LINE(ret) = GR_VK_CALL(IFACE, X); \ |
Brian Salomon | 2335644 | 2018-11-30 15:33:19 -0500 | [diff] [blame] | 27 | SkASSERT(VK_SUCCESS == SK_MACRO_APPEND_LINE(ret)) |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 28 | #else |
Brian Salomon | 2335644 | 2018-11-30 15:33:19 -0500 | [diff] [blame] | 29 | #define GR_VK_CALL_ERRCHECK(IFACE, X) (void) GR_VK_CALL(IFACE, X) |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 30 | #endif |
| 31 | |
| 32 | /** |
| 33 | * Returns the vulkan texture format for the given GrPixelConfig |
| 34 | */ |
| 35 | bool GrPixelConfigToVkFormat(GrPixelConfig config, VkFormat* format); |
| 36 | |
Greg Daniel | 81b8059 | 2017-12-13 10:20:04 -0500 | [diff] [blame] | 37 | bool GrVkFormatIsSupported(VkFormat); |
| 38 | |
Greg Daniel | 7e00022 | 2018-12-03 10:08:21 -0500 | [diff] [blame] | 39 | #ifdef SK_DEBUG |
Greg Daniel | 81b8059 | 2017-12-13 10:20:04 -0500 | [diff] [blame] | 40 | /** |
| 41 | * Returns true if the passed in VkFormat and GrPixelConfig are compatible with each other. |
| 42 | */ |
| 43 | bool GrVkFormatPixelConfigPairIsValid(VkFormat, GrPixelConfig); |
Greg Daniel | 7e00022 | 2018-12-03 10:08:21 -0500 | [diff] [blame] | 44 | #endif |
Greg Daniel | 81b8059 | 2017-12-13 10:20:04 -0500 | [diff] [blame] | 45 | |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 46 | bool GrSampleCountToVkSampleCount(uint32_t samples, VkSampleCountFlagBits* vkSamples); |
| 47 | |
egdaniel | 88987d8 | 2016-09-19 10:17:34 -0700 | [diff] [blame] | 48 | bool GrCompileVkShaderModule(const GrVkGpu* gpu, |
| 49 | const char* shaderString, |
| 50 | VkShaderStageFlagBits stage, |
| 51 | VkShaderModule* shaderModule, |
Ethan Nicholas | 941e7e2 | 2016-12-12 15:33:30 -0500 | [diff] [blame] | 52 | VkPipelineShaderStageCreateInfo* stageInfo, |
| 53 | const SkSL::Program::Settings& settings, |
Ethan Nicholas | 92e01cf | 2018-12-19 13:12:10 -0500 | [diff] [blame^] | 54 | SkSL::String* outSPIRV, |
Ethan Nicholas | 941e7e2 | 2016-12-12 15:33:30 -0500 | [diff] [blame] | 55 | SkSL::Program::Inputs* outInputs); |
egdaniel | 88987d8 | 2016-09-19 10:17:34 -0700 | [diff] [blame] | 56 | |
Ethan Nicholas | 92e01cf | 2018-12-19 13:12:10 -0500 | [diff] [blame^] | 57 | bool GrInstallVkShaderModule(const GrVkGpu* gpu, |
| 58 | const SkSL::String& spirv, |
| 59 | VkShaderStageFlagBits stage, |
| 60 | VkShaderModule* shaderModule, |
| 61 | VkPipelineShaderStageCreateInfo* stageInfo); |
| 62 | |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 63 | #endif |