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