blob: 72ed483d814e8e6e82f50190a7f65993fdfaba9d [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
jvanverth9f372462016-04-06 06:08:59 -070035/**
36* Returns the GrPixelConfig for the given vulkan texture format
37*/
Greg Daniel94403452017-04-18 15:52:36 -040038GrPixelConfig GrVkFormatToPixelConfig(VkFormat format);
jvanverth9f372462016-04-06 06:08:59 -070039
brianosmanf05ab1b2016-05-12 11:01:10 -070040/**
41 * Returns true if the given vulkan texture format is sRGB encoded.
42 * Also provides the non-sRGB version, if there is one.
43 */
44bool GrVkFormatIsSRGB(VkFormat format, VkFormat* linearFormat);
45
Greg Daniel164a9f02016-02-22 09:56:40 -050046bool GrSampleCountToVkSampleCount(uint32_t samples, VkSampleCountFlagBits* vkSamples);
47
egdaniel88987d82016-09-19 10:17:34 -070048bool GrCompileVkShaderModule(const GrVkGpu* gpu,
49 const char* shaderString,
50 VkShaderStageFlagBits stage,
51 VkShaderModule* shaderModule,
Ethan Nicholas941e7e22016-12-12 15:33:30 -050052 VkPipelineShaderStageCreateInfo* stageInfo,
53 const SkSL::Program::Settings& settings,
54 SkSL::Program::Inputs* outInputs);
egdaniel88987d82016-09-19 10:17:34 -070055
Greg Daniel164a9f02016-02-22 09:56:40 -050056#endif