blob: 01688c848661a8571b347810977fd7554511ad31 [file] [log] [blame]
Greg Daniel164a9f02016-02-22 09:56:40 -05001/*
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"
egdaniel88987d82016-09-19 10:17:34 -070013#include "vk/GrVkDefines.h"
Greg Daniel164a9f02016-02-22 09:56:40 -050014#include "vk/GrVkInterface.h"
Ethan Nicholas941e7e22016-12-12 15:33:30 -050015#include "ir/SkSLProgram.h"
Greg Daniel164a9f02016-02-22 09:56:40 -050016
egdaniel88987d82016-09-19 10:17:34 -070017class GrVkGpu;
Greg Daniel164a9f02016-02-22 09:56:40 -050018
Greg Daniel164a9f02016-02-22 09:56:40 -050019// 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 */
33bool GrPixelConfigToVkFormat(GrPixelConfig config, VkFormat* format);
34
Greg Daniel8a3f55c2018-03-14 17:32:12 +000035/**
36* Returns the GrPixelConfig for the given vulkan texture format
37*/
38GrPixelConfig GrVkFormatToPixelConfig(VkFormat format);
39
Greg Daniel81b80592017-12-13 10:20:04 -050040bool GrVkFormatIsSupported(VkFormat);
41
42/**
43 * Returns true if the passed in VkFormat and GrPixelConfig are compatible with each other.
44 */
45bool GrVkFormatPixelConfigPairIsValid(VkFormat, GrPixelConfig);
46
brianosmanf05ab1b2016-05-12 11:01:10 -070047/**
48 * Returns true if the given vulkan texture format is sRGB encoded.
49 * Also provides the non-sRGB version, if there is one.
50 */
51bool GrVkFormatIsSRGB(VkFormat format, VkFormat* linearFormat);
52
Greg Daniel164a9f02016-02-22 09:56:40 -050053bool GrSampleCountToVkSampleCount(uint32_t samples, VkSampleCountFlagBits* vkSamples);
54
egdaniel88987d82016-09-19 10:17:34 -070055bool GrCompileVkShaderModule(const GrVkGpu* gpu,
56 const char* shaderString,
57 VkShaderStageFlagBits stage,
58 VkShaderModule* shaderModule,
Ethan Nicholas941e7e22016-12-12 15:33:30 -050059 VkPipelineShaderStageCreateInfo* stageInfo,
60 const SkSL::Program::Settings& settings,
61 SkSL::Program::Inputs* outInputs);
egdaniel88987d82016-09-19 10:17:34 -070062
Greg Daniel164a9f02016-02-22 09:56:40 -050063#endif