| 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" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 fGeometryBufferMapThreshold = SK_MaxS32; //TODO: figure this out | 32 fGeometryBufferMapThreshold = SK_MaxS32; //TODO: figure this out |
| 33 | 33 |
| 34 fMaxRenderTargetSize = 4096; // minimum required by spec | 34 fMaxRenderTargetSize = 4096; // minimum required by spec |
| 35 fMaxTextureSize = 4096; // minimum required by spec | 35 fMaxTextureSize = 4096; // minimum required by spec |
| 36 fMaxColorSampleCount = 4; // minimum required by spec | 36 fMaxColorSampleCount = 4; // minimum required by spec |
| 37 fMaxStencilSampleCount = 4; // minimum required by spec | 37 fMaxStencilSampleCount = 4; // minimum required by spec |
| 38 | 38 |
| 39 | 39 |
| 40 fShaderCaps.reset(new GrGLSLCaps(contextOptions)); | 40 fShaderCaps.reset(new GrGLSLCaps(contextOptions)); |
| 41 | 41 |
| 42 /************************************************************************** | |
| 43 * GrVkCaps fields | |
| 44 **************************************************************************/ | |
| 45 fMaxSampledTextures = 16; // Spec requires a minimum of 16 sampled textures
per stage | |
| 46 | |
| 47 this->init(contextOptions, vkInterface, physDev); | 42 this->init(contextOptions, vkInterface, physDev); |
| 48 } | 43 } |
| 49 | 44 |
| 50 void GrVkCaps::init(const GrContextOptions& contextOptions, const GrVkInterface*
vkInterface, | 45 void GrVkCaps::init(const GrContextOptions& contextOptions, const GrVkInterface*
vkInterface, |
| 51 VkPhysicalDevice physDev) { | 46 VkPhysicalDevice physDev) { |
| 47 VkPhysicalDeviceProperties properties; |
| 48 GR_VK_CALL(vkInterface, GetPhysicalDeviceProperties(physDev, &properties)); |
| 52 | 49 |
| 53 this->initGLSLCaps(vkInterface, physDev); | 50 this->initGLSLCaps(vkInterface, physDev, properties); |
| 54 this->initConfigTexturableTable(vkInterface, physDev); | 51 this->initConfigTexturableTable(vkInterface, physDev); |
| 55 this->initConfigRenderableTable(vkInterface, physDev); | 52 this->initConfigRenderableTable(vkInterface, physDev); |
| 56 this->initStencilFormats(vkInterface, physDev); | 53 this->initStencilFormats(vkInterface, physDev); |
| 57 | 54 |
| 58 VkPhysicalDeviceProperties properties; | |
| 59 GR_VK_CALL(vkInterface, GetPhysicalDeviceProperties(physDev, &properties)); | |
| 60 | |
| 61 // We could actually querey and get a max size for each config, however maxI
mageDimension2D will | 55 // We could actually querey and get a max size for each config, however maxI
mageDimension2D will |
| 62 // give the minimum max size across all configs. So for simplicity we will u
se that for now. | 56 // give the minimum max size across all configs. So for simplicity we will u
se that for now. |
| 63 fMaxRenderTargetSize = properties.limits.maxImageDimension2D; | 57 fMaxRenderTargetSize = properties.limits.maxImageDimension2D; |
| 64 fMaxTextureSize = properties.limits.maxImageDimension2D; | 58 fMaxTextureSize = properties.limits.maxImageDimension2D; |
| 65 | 59 |
| 66 this->initSampleCount(properties); | 60 this->initSampleCount(properties); |
| 67 | 61 |
| 68 fMaxSampledTextures = SkTMin(properties.limits.maxPerStageDescriptorSampledI
mages, | |
| 69 properties.limits.maxPerStageDescriptorSamplers
); | |
| 70 | |
| 71 this->applyOptionsOverrides(contextOptions); | 62 this->applyOptionsOverrides(contextOptions); |
| 72 // need to friend GrVkCaps in GrGLSLCaps.h | 63 // need to friend GrVkCaps in GrGLSLCaps.h |
| 73 // GrGLSLCaps* glslCaps = static_cast<GrGLSLCaps*>(fShaderCaps.get()); | 64 // GrGLSLCaps* glslCaps = static_cast<GrGLSLCaps*>(fShaderCaps.get()); |
| 74 // glslCaps->applyOptionsOverrides(contextOptions); | 65 // glslCaps->applyOptionsOverrides(contextOptions); |
| 75 } | 66 } |
| 76 | 67 |
| 77 int get_max_sample_count(VkSampleCountFlags flags) { | 68 int get_max_sample_count(VkSampleCountFlags flags) { |
| 78 SkASSERT(flags & VK_SAMPLE_COUNT_1_BIT); | 69 SkASSERT(flags & VK_SAMPLE_COUNT_1_BIT); |
| 79 if (!(flags & VK_SAMPLE_COUNT_2_BIT)) { | 70 if (!(flags & VK_SAMPLE_COUNT_2_BIT)) { |
| 80 return 0; | 71 return 0; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 98 } | 89 } |
| 99 | 90 |
| 100 void GrVkCaps::initSampleCount(const VkPhysicalDeviceProperties& properties) { | 91 void GrVkCaps::initSampleCount(const VkPhysicalDeviceProperties& properties) { |
| 101 VkSampleCountFlags colorSamples = properties.limits.framebufferColorSampleCo
unts; | 92 VkSampleCountFlags colorSamples = properties.limits.framebufferColorSampleCo
unts; |
| 102 VkSampleCountFlags stencilSamples = properties.limits.framebufferStencilSamp
leCounts; | 93 VkSampleCountFlags stencilSamples = properties.limits.framebufferStencilSamp
leCounts; |
| 103 | 94 |
| 104 fMaxColorSampleCount = get_max_sample_count(colorSamples); | 95 fMaxColorSampleCount = get_max_sample_count(colorSamples); |
| 105 fMaxStencilSampleCount = get_max_sample_count(stencilSamples); | 96 fMaxStencilSampleCount = get_max_sample_count(stencilSamples); |
| 106 } | 97 } |
| 107 | 98 |
| 108 void GrVkCaps::initGLSLCaps(const GrVkInterface* interface, VkPhysicalDevice phy
sDev) { | 99 void GrVkCaps::initGLSLCaps(const GrVkInterface* interface, VkPhysicalDevice phy
sDev, |
| 100 const VkPhysicalDeviceProperties& properties) { |
| 109 GrGLSLCaps* glslCaps = static_cast<GrGLSLCaps*>(fShaderCaps.get()); | 101 GrGLSLCaps* glslCaps = static_cast<GrGLSLCaps*>(fShaderCaps.get()); |
| 110 // TODO: actually figure out a correct version here | 102 // TODO: actually figure out a correct version here |
| 111 glslCaps->fVersionDeclString = "#version 140\n"; | 103 glslCaps->fVersionDeclString = "#version 140\n"; |
| 112 | 104 |
| 113 // fConfigOutputSwizzle will default to RGBA so we only need to set it for a
lpha only config. | 105 // fConfigOutputSwizzle will default to RGBA so we only need to set it for a
lpha only config. |
| 114 for (int i = 0; i < kGrPixelConfigCnt; ++i) { | 106 for (int i = 0; i < kGrPixelConfigCnt; ++i) { |
| 115 GrPixelConfig config = static_cast<GrPixelConfig>(i); | 107 GrPixelConfig config = static_cast<GrPixelConfig>(i); |
| 116 if (GrPixelConfigIsAlphaOnly(config)) { | 108 if (GrPixelConfigIsAlphaOnly(config)) { |
| 117 glslCaps->fConfigTextureSwizzle[i] = GrSwizzle::RRRR(); | 109 glslCaps->fConfigTextureSwizzle[i] = GrSwizzle::RRRR(); |
| 118 glslCaps->fConfigOutputSwizzle[i] = GrSwizzle::AAAA(); | 110 glslCaps->fConfigOutputSwizzle[i] = GrSwizzle::AAAA(); |
| 119 } else { | 111 } else { |
| 120 glslCaps->fConfigTextureSwizzle[i] = GrSwizzle::RGBA(); | 112 glslCaps->fConfigTextureSwizzle[i] = GrSwizzle::RGBA(); |
| 121 } | 113 } |
| 122 } | 114 } |
| 123 | 115 |
| 124 glslCaps->fShaderDerivativeSupport = true; | 116 glslCaps->fShaderDerivativeSupport = true; |
| 117 |
| 118 glslCaps->fMaxVertexSamplers = |
| 119 glslCaps->fMaxGeometrySamplers = |
| 120 glslCaps->fMaxFragmentSamplers = SkTMin(properties.limits.maxPerStageDescrip
torSampledImages, |
| 121 properties.limits.maxPerStageDescrip
torSamplers); |
| 122 glslCaps->fMaxCombinedSamplers = SkTMin(properties.limits.maxDescriptorSetSa
mpledImages, |
| 123 properties.limits.maxDescriptorSetSa
mplers); |
| 124 |
| 125 } | 125 } |
| 126 | 126 |
| 127 static void format_supported_for_feature(const GrVkInterface* interface, | 127 static void format_supported_for_feature(const GrVkInterface* interface, |
| 128 VkPhysicalDevice physDev, | 128 VkPhysicalDevice physDev, |
| 129 VkFormat format, | 129 VkFormat format, |
| 130 VkFormatFeatureFlagBits featureBit, | 130 VkFormatFeatureFlagBits featureBit, |
| 131 bool* linearSupport, | 131 bool* linearSupport, |
| 132 bool* optimalSupport) { | 132 bool* optimalSupport) { |
| 133 VkFormatProperties props; | 133 VkFormatProperties props; |
| 134 memset(&props, 0, sizeof(VkFormatProperties)); | 134 memset(&props, 0, sizeof(VkFormatProperties)); |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 // internal Format stencil bits total bits
packed? | 237 // internal Format stencil bits total bits
packed? |
| 238 gS8 = { VK_FORMAT_S8_UINT, 8, 8,
false }, | 238 gS8 = { VK_FORMAT_S8_UINT, 8, 8,
false }, |
| 239 gD24S8 = { VK_FORMAT_D24_UNORM_S8_UINT, 8, 32,
true }; | 239 gD24S8 = { VK_FORMAT_D24_UNORM_S8_UINT, 8, 32,
true }; |
| 240 | 240 |
| 241 // I'm simply assuming that these two will be supported since they are used
in example code. | 241 // I'm simply assuming that these two will be supported since they are used
in example code. |
| 242 // TODO: Actaully figure this out | 242 // TODO: Actaully figure this out |
| 243 SET_CONFIG_CAN_STENCIL(gS8); | 243 SET_CONFIG_CAN_STENCIL(gS8); |
| 244 SET_CONFIG_CAN_STENCIL(gD24S8); | 244 SET_CONFIG_CAN_STENCIL(gD24S8); |
| 245 } | 245 } |
| 246 | 246 |
| OLD | NEW |