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" |
egdaniel | 88987d8 | 2016-09-19 10:17:34 -0700 | [diff] [blame] | 13 | #include "vk/GrVkDefines.h" |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 14 | #include "vk/GrVkInterface.h" |
Ethan Nicholas | 941e7e2 | 2016-12-12 15:33:30 -0500 | [diff] [blame] | 15 | #include "ir/SkSLProgram.h" |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 16 | |
egdaniel | 88987d8 | 2016-09-19 10:17:34 -0700 | [diff] [blame] | 17 | class GrVkGpu; |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 18 | |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 19 | // makes a Vk call on the interface |
| 20 | #define GR_VK_CALL(IFACE, X) (IFACE)->fFunctions.f##X; |
| 21 | // same as GR_VK_CALL but checks for success |
| 22 | #ifdef SK_DEBUG |
| 23 | #define GR_VK_CALL_ERRCHECK(IFACE, X) \ |
| 24 | VkResult SK_MACRO_APPEND_LINE(ret) = GR_VK_CALL(IFACE, X); \ |
| 25 | SkASSERT(VK_SUCCESS == SK_MACRO_APPEND_LINE(ret)); |
| 26 | #else |
| 27 | #define GR_VK_CALL_ERRCHECK(IFACE, X) (void) GR_VK_CALL(IFACE, X); |
| 28 | #endif |
| 29 | |
| 30 | /** |
| 31 | * Returns the vulkan texture format for the given GrPixelConfig |
| 32 | */ |
| 33 | bool GrPixelConfigToVkFormat(GrPixelConfig config, VkFormat* format); |
| 34 | |
jvanverth | 9f37246 | 2016-04-06 06:08:59 -0700 | [diff] [blame] | 35 | /** |
| 36 | * Returns the GrPixelConfig for the given vulkan texture format |
| 37 | */ |
Greg Daniel | 9440345 | 2017-04-18 15:52:36 -0400 | [diff] [blame] | 38 | GrPixelConfig GrVkFormatToPixelConfig(VkFormat format); |
jvanverth | 9f37246 | 2016-04-06 06:08:59 -0700 | [diff] [blame] | 39 | |
brianosman | f05ab1b | 2016-05-12 11:01:10 -0700 | [diff] [blame] | 40 | /** |
| 41 | * Returns true if the given vulkan texture format is sRGB encoded. |
| 42 | * Also provides the non-sRGB version, if there is one. |
| 43 | */ |
| 44 | bool GrVkFormatIsSRGB(VkFormat format, VkFormat* linearFormat); |
| 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, |
| 54 | SkSL::Program::Inputs* outInputs); |
egdaniel | 88987d8 | 2016-09-19 10:17:34 -0700 | [diff] [blame] | 55 | |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 56 | #endif |