| OLD | NEW | 
|    1 /* |    1 /* | 
|    2  * Copyright 2015 Google Inc. |    2  * Copyright 2015 Google Inc. | 
|    3  * |    3  * | 
|    4  * Use of this source code is governed by a BSD-style license that can be |    4  * Use of this source code is governed by a BSD-style license that can be | 
|    5  * found in the LICENSE file. |    5  * found in the LICENSE file. | 
|    6  */ |    6  */ | 
|    7  |    7  | 
|    8 #include "GrVkCaps.h" |    8 #include "GrVkCaps.h" | 
|    9  |    9  | 
|   10 #include "GrVkUtil.h" |   10 #include "GrVkUtil.h" | 
|   11 #include "glsl/GrGLSLCaps.h" |   11 #include "glsl/GrGLSLCaps.h" | 
|   12 #include "vk/GrVkInterface.h" |   12 #include "vk/GrVkInterface.h" | 
 |   13 #include "vk/GrVkBackendContext.h" | 
|   13  |   14  | 
|   14 GrVkCaps::GrVkCaps(const GrContextOptions& contextOptions, const GrVkInterface* 
     vkInterface, |   15 GrVkCaps::GrVkCaps(const GrContextOptions& contextOptions, const GrVkInterface* 
     vkInterface, | 
|   15                    VkPhysicalDevice physDev) : INHERITED(contextOptions) { |   16                    VkPhysicalDevice physDev, uint32_t featureFlags) : INHERITED(
     contextOptions) { | 
|   16     /************************************************************************** |   17     /************************************************************************** | 
|   17     * GrDrawTargetCaps fields |   18     * GrDrawTargetCaps fields | 
|   18     **************************************************************************/ |   19     **************************************************************************/ | 
|   19     fMipMapSupport = false; //TODO: figure this out |   20     fMipMapSupport = false; //TODO: figure this out | 
|   20     fNPOTTextureTileSupport = false; //TODO: figure this out |   21     fNPOTTextureTileSupport = false; //TODO: figure this out | 
|   21     fTwoSidedStencilSupport = false; //TODO: figure this out |   22     fTwoSidedStencilSupport = false; //TODO: figure this out | 
|   22     fStencilWrapOpsSupport = false; //TODO: figure this out |   23     fStencilWrapOpsSupport = false; //TODO: figure this out | 
|   23     fDiscardRenderTargetSupport = false; //TODO: figure this out |   24     fDiscardRenderTargetSupport = false; //TODO: figure this out | 
|   24     fReuseScratchTextures = true; //TODO: figure this out |   25     fReuseScratchTextures = true; //TODO: figure this out | 
|   25     fGpuTracingSupport = false; //TODO: figure this out |   26     fGpuTracingSupport = false; //TODO: figure this out | 
|   26     fCompressedTexSubImageSupport = false; //TODO: figure this out |   27     fCompressedTexSubImageSupport = false; //TODO: figure this out | 
|   27     fOversizedStencilSupport = false; //TODO: figure this out |   28     fOversizedStencilSupport = false; //TODO: figure this out | 
|   28  |   29  | 
|   29     fUseDrawInsteadOfClear = false; //TODO: figure this out |   30     fUseDrawInsteadOfClear = false; //TODO: figure this out | 
|   30  |   31  | 
|   31     fMapBufferFlags = kNone_MapFlags; //TODO: figure this out |   32     fMapBufferFlags = kNone_MapFlags; //TODO: figure this out | 
|   32     fGeometryBufferMapThreshold = SK_MaxS32;  //TODO: figure this out |   33     fGeometryBufferMapThreshold = SK_MaxS32;  //TODO: figure this out | 
|   33  |   34  | 
|   34     fMaxRenderTargetSize = 4096; // minimum required by spec |   35     fMaxRenderTargetSize = 4096; // minimum required by spec | 
|   35     fMaxTextureSize = 4096; // minimum required by spec |   36     fMaxTextureSize = 4096; // minimum required by spec | 
|   36     fMaxColorSampleCount = 4; // minimum required by spec |   37     fMaxColorSampleCount = 4; // minimum required by spec | 
|   37     fMaxStencilSampleCount = 4; // minimum required by spec |   38     fMaxStencilSampleCount = 4; // minimum required by spec | 
|   38  |   39  | 
|   39  |   40  | 
|   40     fShaderCaps.reset(new GrGLSLCaps(contextOptions)); |   41     fShaderCaps.reset(new GrGLSLCaps(contextOptions)); | 
|   41  |   42  | 
|   42     this->init(contextOptions, vkInterface, physDev); |   43     this->init(contextOptions, vkInterface, physDev, featureFlags); | 
|   43 } |   44 } | 
|   44  |   45  | 
|   45 void GrVkCaps::init(const GrContextOptions& contextOptions, const GrVkInterface*
      vkInterface, |   46 void GrVkCaps::init(const GrContextOptions& contextOptions, const GrVkInterface*
      vkInterface, | 
|   46                     VkPhysicalDevice physDev) { |   47                     VkPhysicalDevice physDev, uint32_t featureFlags) { | 
|   47  |   48  | 
|   48     VkPhysicalDeviceProperties properties; |   49     VkPhysicalDeviceProperties properties; | 
|   49     GR_VK_CALL(vkInterface, GetPhysicalDeviceProperties(physDev, &properties)); |   50     GR_VK_CALL(vkInterface, GetPhysicalDeviceProperties(physDev, &properties)); | 
|   50  |   51  | 
|   51     VkPhysicalDeviceFeatures features; |  | 
|   52     GR_VK_CALL(vkInterface, GetPhysicalDeviceFeatures(physDev, &features)); |  | 
|   53  |  | 
|   54     VkPhysicalDeviceMemoryProperties memoryProperties; |   52     VkPhysicalDeviceMemoryProperties memoryProperties; | 
|   55     GR_VK_CALL(vkInterface, GetPhysicalDeviceMemoryProperties(physDev, &memoryPr
     operties)); |   53     GR_VK_CALL(vkInterface, GetPhysicalDeviceMemoryProperties(physDev, &memoryPr
     operties)); | 
|   56  |   54  | 
|   57     this->initGrCaps(properties, features, memoryProperties); |   55     this->initGrCaps(properties, memoryProperties, featureFlags); | 
|   58     this->initGLSLCaps(features, properties); |   56     this->initGLSLCaps(properties, featureFlags); | 
|   59     this->initConfigTexturableTable(vkInterface, physDev); |   57     this->initConfigTexturableTable(vkInterface, physDev); | 
|   60     this->initConfigRenderableTable(vkInterface, physDev); |   58     this->initConfigRenderableTable(vkInterface, physDev); | 
|   61     this->initStencilFormats(vkInterface, physDev); |   59     this->initStencilFormats(vkInterface, physDev); | 
|   62  |   60  | 
|   63  |   61  | 
|   64  |   62  | 
|   65     this->applyOptionsOverrides(contextOptions); |   63     this->applyOptionsOverrides(contextOptions); | 
|   66     // need to friend GrVkCaps in GrGLSLCaps.h |   64     // need to friend GrVkCaps in GrGLSLCaps.h | 
|   67     // GrGLSLCaps* glslCaps = static_cast<GrGLSLCaps*>(fShaderCaps.get()); |   65     // GrGLSLCaps* glslCaps = static_cast<GrGLSLCaps*>(fShaderCaps.get()); | 
|   68     // glslCaps->applyOptionsOverrides(contextOptions); |   66     // glslCaps->applyOptionsOverrides(contextOptions); | 
| (...skipping 24 matching lines...) Expand all  Loading... | 
|   93  |   91  | 
|   94 void GrVkCaps::initSampleCount(const VkPhysicalDeviceProperties& properties) { |   92 void GrVkCaps::initSampleCount(const VkPhysicalDeviceProperties& properties) { | 
|   95     VkSampleCountFlags colorSamples = properties.limits.framebufferColorSampleCo
     unts; |   93     VkSampleCountFlags colorSamples = properties.limits.framebufferColorSampleCo
     unts; | 
|   96     VkSampleCountFlags stencilSamples = properties.limits.framebufferStencilSamp
     leCounts; |   94     VkSampleCountFlags stencilSamples = properties.limits.framebufferStencilSamp
     leCounts; | 
|   97  |   95  | 
|   98     fMaxColorSampleCount = get_max_sample_count(colorSamples); |   96     fMaxColorSampleCount = get_max_sample_count(colorSamples); | 
|   99     fMaxStencilSampleCount = get_max_sample_count(stencilSamples); |   97     fMaxStencilSampleCount = get_max_sample_count(stencilSamples); | 
|  100 } |   98 } | 
|  101  |   99  | 
|  102 void GrVkCaps::initGrCaps(const VkPhysicalDeviceProperties& properties, |  100 void GrVkCaps::initGrCaps(const VkPhysicalDeviceProperties& properties, | 
|  103                           const VkPhysicalDeviceFeatures& features, |  101                           const VkPhysicalDeviceMemoryProperties& memoryProperti
     es, | 
|  104                           const VkPhysicalDeviceMemoryProperties& memoryProperit
     es) { |  102                           uint32_t featureFlags) { | 
|  105     fMaxVertexAttributes = properties.limits.maxVertexInputAttributes; |  103     fMaxVertexAttributes = properties.limits.maxVertexInputAttributes; | 
|  106     // We could actually query and get a max size for each config, however maxIm
     ageDimension2D will |  104     // We could actually query and get a max size for each config, however maxIm
     ageDimension2D will | 
|  107     // give the minimum max size across all configs. So for simplicity we will u
     se that for now. |  105     // give the minimum max size across all configs. So for simplicity we will u
     se that for now. | 
|  108     fMaxRenderTargetSize = properties.limits.maxImageDimension2D; |  106     fMaxRenderTargetSize = properties.limits.maxImageDimension2D; | 
|  109     fMaxTextureSize = properties.limits.maxImageDimension2D; |  107     fMaxTextureSize = properties.limits.maxImageDimension2D; | 
|  110  |  108  | 
|  111     this->initSampleCount(properties); |  109     this->initSampleCount(properties); | 
|  112  |  110  | 
|  113     // Assuming since we will always map in the end to upload the data we might 
     as well just map |  111     // Assuming since we will always map in the end to upload the data we might 
     as well just map | 
|  114     // from the get go. There is no hard data to suggest this is faster or slowe
     r. |  112     // from the get go. There is no hard data to suggest this is faster or slowe
     r. | 
|  115     fGeometryBufferMapThreshold = 0; |  113     fGeometryBufferMapThreshold = 0; | 
|  116  |  114  | 
|  117     fMapBufferFlags = kCanMap_MapFlag | kSubset_MapFlag; |  115     fMapBufferFlags = kCanMap_MapFlag | kSubset_MapFlag; | 
|  118  |  116  | 
|  119     fStencilWrapOpsSupport = true; |  117     fStencilWrapOpsSupport = true; | 
|  120     fOversizedStencilSupport = true; |  118     fOversizedStencilSupport = true; | 
|  121 } |  119 } | 
|  122  |  120  | 
|  123 void GrVkCaps::initGLSLCaps(const VkPhysicalDeviceFeatures& features, |  121 void GrVkCaps::initGLSLCaps(const VkPhysicalDeviceProperties& properties, | 
|  124                             const VkPhysicalDeviceProperties& properties) { |  122                             uint32_t featureFlags) { | 
|  125     GrGLSLCaps* glslCaps = static_cast<GrGLSLCaps*>(fShaderCaps.get()); |  123     GrGLSLCaps* glslCaps = static_cast<GrGLSLCaps*>(fShaderCaps.get()); | 
|  126     glslCaps->fVersionDeclString = "#version 310 es\n"; |  124     glslCaps->fVersionDeclString = "#version 310 es\n"; | 
|  127  |  125  | 
|  128     // fConfigOutputSwizzle will default to RGBA so we only need to set it for a
     lpha only config. |  126     // fConfigOutputSwizzle will default to RGBA so we only need to set it for a
     lpha only config. | 
|  129     for (int i = 0; i < kGrPixelConfigCnt; ++i) { |  127     for (int i = 0; i < kGrPixelConfigCnt; ++i) { | 
|  130         GrPixelConfig config = static_cast<GrPixelConfig>(i); |  128         GrPixelConfig config = static_cast<GrPixelConfig>(i); | 
|  131         if (GrPixelConfigIsAlphaOnly(config)) { |  129         if (GrPixelConfigIsAlphaOnly(config)) { | 
|  132             glslCaps->fConfigTextureSwizzle[i] = GrSwizzle::RRRR(); |  130             glslCaps->fConfigTextureSwizzle[i] = GrSwizzle::RRRR(); | 
|  133             glslCaps->fConfigOutputSwizzle[i] = GrSwizzle::AAAA(); |  131             glslCaps->fConfigOutputSwizzle[i] = GrSwizzle::AAAA(); | 
|  134         } else { |  132         } else { | 
|  135             glslCaps->fConfigTextureSwizzle[i] = GrSwizzle::RGBA(); |  133             glslCaps->fConfigTextureSwizzle[i] = GrSwizzle::RGBA(); | 
|  136         } |  134         } | 
|  137     } |  135     } | 
|  138  |  136  | 
|  139     // Vulkan is based off ES 3.0 so the following should all be supported |  137     // Vulkan is based off ES 3.0 so the following should all be supported | 
|  140     glslCaps->fUsesPrecisionModifiers = true; |  138     glslCaps->fUsesPrecisionModifiers = true; | 
|  141     glslCaps->fFlatInterpolationSupport = true; |  139     glslCaps->fFlatInterpolationSupport = true; | 
|  142  |  140  | 
|  143     // GrShaderCaps |  141     // GrShaderCaps | 
|  144  |  142  | 
|  145     glslCaps->fShaderDerivativeSupport = true; |  143     glslCaps->fShaderDerivativeSupport = true; | 
|  146     glslCaps->fGeometryShaderSupport = features.geometryShader == VK_TRUE; |  144     glslCaps->fGeometryShaderSupport = SkToBool(featureFlags & kGeometryShader_G
     rVkFeatureFlag); | 
|  147 #if 0 |  145 #if 0 | 
|  148     // For now disabling dual source blending till we get it hooked up in the re
     st of system |  146     // For now disabling dual source blending till we get it hooked up in the re
     st of system | 
|  149     glslCaps->fDualSourceBlendingSupport = features.dualSrcBlend; |  147     glslCaps->fDualSourceBlendingSupport = SkToBool(featureFlags & kDualSrcBlend
     _GrVkFeatureFlag); | 
|  150 #endif |  148 #endif | 
|  151     glslCaps->fIntegerSupport = true; |  149     glslCaps->fIntegerSupport = true; | 
|  152  |  150  | 
|  153     glslCaps->fMaxVertexSamplers = |  151     glslCaps->fMaxVertexSamplers = | 
|  154     glslCaps->fMaxGeometrySamplers = |  152     glslCaps->fMaxGeometrySamplers = | 
|  155     glslCaps->fMaxFragmentSamplers = SkTMin(properties.limits.maxPerStageDescrip
     torSampledImages, |  153     glslCaps->fMaxFragmentSamplers = SkTMin(properties.limits.maxPerStageDescrip
     torSampledImages, | 
|  156                                             properties.limits.maxPerStageDescrip
     torSamplers); |  154                                             properties.limits.maxPerStageDescrip
     torSamplers); | 
|  157     glslCaps->fMaxCombinedSamplers = SkTMin(properties.limits.maxDescriptorSetSa
     mpledImages, |  155     glslCaps->fMaxCombinedSamplers = SkTMin(properties.limits.maxDescriptorSetSa
     mpledImages, | 
|  158                                             properties.limits.maxDescriptorSetSa
     mplers); |  156                                             properties.limits.maxDescriptorSetSa
     mplers); | 
|  159 } |  157 } | 
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  271                   // internal Format             stencil bits      total bits   
          packed? |  269                   // internal Format             stencil bits      total bits   
          packed? | 
|  272         gS8    = { VK_FORMAT_S8_UINT,            8,                 8,          
          false }, |  270         gS8    = { VK_FORMAT_S8_UINT,            8,                 8,          
          false }, | 
|  273         gD24S8 = { VK_FORMAT_D24_UNORM_S8_UINT,  8,                32,          
          true }; |  271         gD24S8 = { VK_FORMAT_D24_UNORM_S8_UINT,  8,                32,          
          true }; | 
|  274  |  272  | 
|  275     // I'm simply assuming that these two will be supported since they are used 
     in example code. |  273     // I'm simply assuming that these two will be supported since they are used 
     in example code. | 
|  276     // TODO: Actaully figure this out |  274     // TODO: Actaully figure this out | 
|  277     SET_CONFIG_CAN_STENCIL(gS8); |  275     SET_CONFIG_CAN_STENCIL(gS8); | 
|  278     SET_CONFIG_CAN_STENCIL(gD24S8); |  276     SET_CONFIG_CAN_STENCIL(gD24S8); | 
|  279 } |  277 } | 
|  280  |  278  | 
| OLD | NEW |