Home | History | Annotate | Download | only in vk
      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"
     13 #include "vk/GrVkDefines.h"
     14 #include "vk/GrVkInterface.h"
     15 #include "ir/SkSLProgram.h"
     16 
     17 class GrVkGpu;
     18 
     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 
     35 /**
     36 * Returns the GrPixelConfig for the given vulkan texture format
     37 */
     38 bool GrVkFormatToPixelConfig(VkFormat format, GrPixelConfig* config);
     39 
     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 
     46 bool GrSampleCountToVkSampleCount(uint32_t samples, VkSampleCountFlagBits* vkSamples);
     47 
     48 bool GrCompileVkShaderModule(const GrVkGpu* gpu,
     49                              const char* shaderString,
     50                              VkShaderStageFlagBits stage,
     51                              VkShaderModule* shaderModule,
     52                              VkPipelineShaderStageCreateInfo* stageInfo,
     53                              const SkSL::Program::Settings& settings,
     54                              SkSL::Program::Inputs* outInputs);
     55 
     56 #endif
     57