1 /* Copyright (c) 2015-2019 The Khronos Group Inc.
2 * Copyright (c) 2015-2019 Valve Corporation
3 * Copyright (c) 2015-2019 LunarG, Inc.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 * Author: Camden Stocker <camden@lunarg.com>
18 */
19
20 #include "best_practices.h"
21 #include "layer_chassis_dispatch.h"
22
23 #include <string>
24 #include <iomanip>
25
26 // get the API name is proper format
GetAPIVersionName(uint32_t version)27 std::string BestPractices::GetAPIVersionName(uint32_t version) {
28 std::stringstream version_name;
29 uint32_t major = VK_VERSION_MAJOR(version);
30 uint32_t minor = VK_VERSION_MINOR(version);
31 uint32_t patch = VK_VERSION_PATCH(version);
32
33 version_name << major << "." << minor << "." << patch << " (0x" << std::setfill('0') << std::setw(8) << std::hex << version
34 << ")";
35
36 return version_name.str();
37 }
38
PreCallValidateCreateInstance(const VkInstanceCreateInfo * pCreateInfo,const VkAllocationCallbacks * pAllocator,VkInstance * pInstance)39 bool BestPractices::PreCallValidateCreateInstance(const VkInstanceCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator,
40 VkInstance* pInstance) {
41 bool skip = false;
42
43 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
44 if (white_list(pCreateInfo->ppEnabledExtensionNames[i], kDeviceExtensionNames)) {
45 skip |=
46 log_msg(report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
47 layer_name.c_str(), "vkCreateInstance(): Attempting to enable Device Extension %s at CreateInstance time.",
48 pCreateInfo->ppEnabledExtensionNames[i]);
49 }
50 }
51
52 return skip;
53 }
54
PreCallRecordCreateInstance(const VkInstanceCreateInfo * pCreateInfo,const VkAllocationCallbacks * pAllocator,VkInstance * pInstance)55 void BestPractices::PreCallRecordCreateInstance(const VkInstanceCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator,
56 VkInstance* pInstance) {
57 instance_api_version = pCreateInfo->pApplicationInfo->apiVersion;
58 }
59
PreCallValidateCreateDevice(VkPhysicalDevice physicalDevice,const VkDeviceCreateInfo * pCreateInfo,const VkAllocationCallbacks * pAllocator,VkDevice * pDevice)60 bool BestPractices::PreCallValidateCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo* pCreateInfo,
61 const VkAllocationCallbacks* pAllocator, VkDevice* pDevice) {
62 bool skip = false;
63
64 // get API version of physical device passed when creating device.
65 VkPhysicalDeviceProperties physical_device_properties{};
66 DispatchGetPhysicalDeviceProperties(physicalDevice, &physical_device_properties);
67 device_api_version = physical_device_properties.apiVersion;
68
69 // check api versions and warn if instance api Version is higher than version on device.
70 if (instance_api_version > device_api_version) {
71 std::string inst_api_name = GetAPIVersionName(instance_api_version);
72 std::string dev_api_name = GetAPIVersionName(device_api_version);
73
74 skip |=
75 log_msg(report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, layer_name.c_str(),
76 "vkCreateDevice(): API Version of current instance, %s is higher than API Version on device, %s",
77 inst_api_name.c_str(), dev_api_name.c_str());
78 }
79
80 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
81 if (white_list(pCreateInfo->ppEnabledExtensionNames[i], kInstanceExtensionNames)) {
82 skip |=
83 log_msg(report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
84 layer_name.c_str(), "vkCreateDevice(): Attempting to enable Instance Extension %s at CreateDevice time.",
85 pCreateInfo->ppEnabledExtensionNames[i]);
86 }
87 }
88
89 return skip;
90 }
91
PreCallValidateCreateBuffer(VkDevice device,const VkBufferCreateInfo * pCreateInfo,const VkAllocationCallbacks * pAllocator,VkBuffer * pBuffer)92 bool BestPractices::PreCallValidateCreateBuffer(VkDevice device, const VkBufferCreateInfo* pCreateInfo,
93 const VkAllocationCallbacks* pAllocator, VkBuffer* pBuffer) {
94 bool skip = false;
95
96 if ((pCreateInfo->queueFamilyIndexCount > 1) && (pCreateInfo->sharingMode == VK_SHARING_MODE_EXCLUSIVE)) {
97 std::stringstream bufferHex;
98 bufferHex << "0x" << std::hex << HandleToUint64(pBuffer);
99
100 skip |=
101 log_msg(report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, layer_name.c_str(),
102 "Warning: Buffer (%s) specifies a sharing mode of VK_SHARING_MODE_EXCLUSIVE while specifying multiple queues "
103 "(queueFamilyIndexCount of %" PRIu32 ").",
104 bufferHex.str().c_str(), pCreateInfo->queueFamilyIndexCount);
105 }
106
107 return skip;
108 }
109
PreCallValidateCreateImage(VkDevice device,const VkImageCreateInfo * pCreateInfo,const VkAllocationCallbacks * pAllocator,VkImage * pImage)110 bool BestPractices::PreCallValidateCreateImage(VkDevice device, const VkImageCreateInfo* pCreateInfo,
111 const VkAllocationCallbacks* pAllocator, VkImage* pImage) {
112 bool skip = false;
113
114 if ((pCreateInfo->queueFamilyIndexCount > 1) && (pCreateInfo->sharingMode == VK_SHARING_MODE_EXCLUSIVE)) {
115 std::stringstream imageHex;
116 imageHex << "0x" << std::hex << HandleToUint64(pImage);
117
118 skip |=
119 log_msg(report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, layer_name.c_str(),
120 "Warning: Image (%s) specifies a sharing mode of VK_SHARING_MODE_EXCLUSIVE while specifying multiple queues "
121 "(queueFamilyIndexCount of %" PRIu32 ").",
122 imageHex.str().c_str(), pCreateInfo->queueFamilyIndexCount);
123 }
124
125 return skip;
126 }
127
PreCallValidateCreateSwapchainKHR(VkDevice device,const VkSwapchainCreateInfoKHR * pCreateInfo,const VkAllocationCallbacks * pAllocator,VkSwapchainKHR * pSwapchain)128 bool BestPractices::PreCallValidateCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR* pCreateInfo,
129 const VkAllocationCallbacks* pAllocator, VkSwapchainKHR* pSwapchain) {
130 bool skip = false;
131
132 if ((pCreateInfo->queueFamilyIndexCount > 1) && (pCreateInfo->imageSharingMode == VK_SHARING_MODE_EXCLUSIVE)) {
133 skip |=
134 log_msg(report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, layer_name.c_str(),
135 "Warning: A Swapchain is being created which specifies a sharing mode of VK_SHARING_MODE_EXCULSIVE while "
136 "specifying multiple queues (queueFamilyIndexCount of %" PRIu32 ").",
137 pCreateInfo->queueFamilyIndexCount);
138 }
139
140 return skip;
141 }
142
PreCallValidateCreateSharedSwapchainsKHR(VkDevice device,uint32_t swapchainCount,const VkSwapchainCreateInfoKHR * pCreateInfos,const VkAllocationCallbacks * pAllocator,VkSwapchainKHR * pSwapchains)143 bool BestPractices::PreCallValidateCreateSharedSwapchainsKHR(VkDevice device, uint32_t swapchainCount,
144 const VkSwapchainCreateInfoKHR* pCreateInfos,
145 const VkAllocationCallbacks* pAllocator, VkSwapchainKHR* pSwapchains) {
146 bool skip = false;
147
148 for (uint32_t i = 0; i < swapchainCount; i++) {
149 if ((pCreateInfos[i].queueFamilyIndexCount > 1) && (pCreateInfos[i].imageSharingMode == VK_SHARING_MODE_EXCLUSIVE)) {
150 skip |= log_msg(
151 report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, layer_name.c_str(),
152 "Warning: A shared swapchain (index %" PRIu32
153 ") is being created which specifies a sharing mode of VK_SHARING_MODE_EXCLUSIVE while specifying multiple "
154 "queues (queueFamilyIndexCount of %" PRIu32 ").",
155 i, pCreateInfos[i].queueFamilyIndexCount);
156 }
157 }
158
159 return skip;
160 }
161
PreCallValidateCreateRenderPass(VkDevice device,const VkRenderPassCreateInfo * pCreateInfo,const VkAllocationCallbacks * pAllocator,VkRenderPass * pRenderPass)162 bool BestPractices::PreCallValidateCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo* pCreateInfo,
163 const VkAllocationCallbacks* pAllocator, VkRenderPass* pRenderPass) {
164 bool skip = false;
165
166 for (uint32_t i = 0; i < pCreateInfo->attachmentCount; ++i) {
167 VkFormat format = pCreateInfo->pAttachments[i].format;
168 if (pCreateInfo->pAttachments[i].initialLayout == VK_IMAGE_LAYOUT_UNDEFINED) {
169 if ((FormatIsColor(format) || FormatHasDepth(format)) &&
170 pCreateInfo->pAttachments[i].loadOp == VK_ATTACHMENT_LOAD_OP_LOAD) {
171 skip |= log_msg(report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
172 layer_name.c_str(),
173 "Render pass has an attachment with loadOp == VK_ATTACHMENT_LOAD_OP_LOAD and "
174 "initialLayout == VK_IMAGE_LAYOUT_UNDEFINED. This is probably not what you "
175 "intended. Consider using VK_ATTACHMENT_LOAD_OP_DONT_CARE instead if the "
176 "image truely is undefined at the start of the render pass.");
177 }
178 if (FormatHasStencil(format) && pCreateInfo->pAttachments[i].stencilLoadOp == VK_ATTACHMENT_LOAD_OP_LOAD) {
179 skip |= log_msg(report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
180 layer_name.c_str(),
181 "Render pass has an attachment with stencilLoadOp == VK_ATTACHMENT_LOAD_OP_LOAD "
182 "and initialLayout == VK_IMAGE_LAYOUT_UNDEFINED. This is probably not what you "
183 "intended. Consider using VK_ATTACHMENT_LOAD_OP_DONT_CARE instead if the "
184 "image truely is undefined at the start of the render pass.");
185 }
186 }
187 }
188
189 for (uint32_t dependency = 0; dependency < pCreateInfo->dependencyCount; dependency++) {
190 skip |= CheckPipelineStageFlags("vkCreateRenderPass", pCreateInfo->pDependencies[dependency].srcStageMask);
191 skip |= CheckPipelineStageFlags("vkCreateRenderPass", pCreateInfo->pDependencies[dependency].dstStageMask);
192 }
193
194 return skip;
195 }
196
PreCallValidateAllocateMemory(VkDevice device,const VkMemoryAllocateInfo * pAllocateInfo,const VkAllocationCallbacks * pAllocator,VkDeviceMemory * pMemory)197 bool BestPractices::PreCallValidateAllocateMemory(VkDevice device, const VkMemoryAllocateInfo* pAllocateInfo,
198 const VkAllocationCallbacks* pAllocator, VkDeviceMemory* pMemory) {
199 bool skip = false;
200
201 num_mem_objects++;
202
203 if (num_mem_objects > kMemoryObjectWarningLimit) {
204 skip |= log_msg(report_data, VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
205 layer_name.c_str(), "Performance Warning: This app has > %" PRIu32 " memory objects.",
206 kMemoryObjectWarningLimit);
207 }
208
209 return skip;
210 }
211
PreCallRecordFreeMemory(VkDevice device,VkDeviceMemory memory,const VkAllocationCallbacks * pAllocator)212 void BestPractices::PreCallRecordFreeMemory(VkDevice device, VkDeviceMemory memory, const VkAllocationCallbacks* pAllocator) {
213 if (memory != VK_NULL_HANDLE) {
214 num_mem_objects--;
215 }
216 }
217
PreCallValidateCreateGraphicsPipelines(VkDevice device,VkPipelineCache pipelineCache,uint32_t createInfoCount,const VkGraphicsPipelineCreateInfo * pCreateInfos,const VkAllocationCallbacks * pAllocator,VkPipeline * pPipelines)218 bool BestPractices::PreCallValidateCreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache, uint32_t createInfoCount,
219 const VkGraphicsPipelineCreateInfo* pCreateInfos,
220 const VkAllocationCallbacks* pAllocator, VkPipeline* pPipelines) {
221 bool skip = false;
222
223 if ((createInfoCount > 1) && (!pipelineCache)) {
224 skip |=
225 log_msg(report_data, VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
226 layer_name.c_str(),
227 "Performance Warning: This vkCreateGraphicsPipelines call is creating multiple pipelines but is not using a "
228 "pipeline cache, which may help with performance");
229 }
230
231 return skip;
232 }
233
PreCallValidateCreateComputePipelines(VkDevice device,VkPipelineCache pipelineCache,uint32_t createInfoCount,const VkComputePipelineCreateInfo * pCreateInfos,const VkAllocationCallbacks * pAllocator,VkPipeline * pPipelines)234 bool BestPractices::PreCallValidateCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache, uint32_t createInfoCount,
235 const VkComputePipelineCreateInfo* pCreateInfos,
236 const VkAllocationCallbacks* pAllocator, VkPipeline* pPipelines) {
237 bool skip = false;
238
239 if ((createInfoCount > 1) && (!pipelineCache)) {
240 skip |= log_msg(report_data, VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
241 layer_name.c_str(),
242 "Performance Warning: This vkCreateComputePipelines call is creating multiple pipelines but is not using a "
243 "pipeline cache, which may help with performance");
244 }
245
246 return skip;
247 }
248
CheckPipelineStageFlags(std::string api_name,const VkPipelineStageFlags flags)249 bool BestPractices::CheckPipelineStageFlags(std::string api_name, const VkPipelineStageFlags flags) {
250 bool skip = false;
251
252 if (flags & VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT) {
253 skip |=
254 log_msg(report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, layer_name.c_str(),
255 "You are using VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT when %s is called\n", api_name.c_str());
256 } else if (flags & VK_PIPELINE_STAGE_ALL_COMMANDS_BIT) {
257 skip |=
258 log_msg(report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, layer_name.c_str(),
259 "You are using VK_PIPELINE_STAGE_ALL_COMMANDS_BIT when %s is called\n", api_name.c_str());
260 }
261
262 return skip;
263 }
264
PreCallValidateQueueSubmit(VkQueue queue,uint32_t submitCount,const VkSubmitInfo * pSubmits,VkFence fence)265 bool BestPractices::PreCallValidateQueueSubmit(VkQueue queue, uint32_t submitCount, const VkSubmitInfo* pSubmits, VkFence fence) {
266 bool skip = false;
267
268 for (uint32_t submit = 0; submit < submitCount; submit++) {
269 for (uint32_t semaphore = 0; semaphore < pSubmits[submit].waitSemaphoreCount; semaphore++) {
270 skip |= CheckPipelineStageFlags("vkQueueSubmit", pSubmits[submit].pWaitDstStageMask[semaphore]);
271 }
272 }
273
274 return skip;
275 }
276
PreCallValidateCmdSetEvent(VkCommandBuffer commandBuffer,VkEvent event,VkPipelineStageFlags stageMask)277 bool BestPractices::PreCallValidateCmdSetEvent(VkCommandBuffer commandBuffer, VkEvent event, VkPipelineStageFlags stageMask) {
278 bool skip = false;
279
280 skip |= CheckPipelineStageFlags("vkCmdSetEvent", stageMask);
281
282 return skip;
283 }
284
PreCallValidateCmdResetEvent(VkCommandBuffer commandBuffer,VkEvent event,VkPipelineStageFlags stageMask)285 bool BestPractices::PreCallValidateCmdResetEvent(VkCommandBuffer commandBuffer, VkEvent event, VkPipelineStageFlags stageMask) {
286 bool skip = false;
287
288 skip |= CheckPipelineStageFlags("vkCmdResetEvent", stageMask);
289
290 return skip;
291 }
292
PreCallValidateCmdWaitEvents(VkCommandBuffer commandBuffer,uint32_t eventCount,const VkEvent * pEvents,VkPipelineStageFlags srcStageMask,VkPipelineStageFlags dstStageMask,uint32_t memoryBarrierCount,const VkMemoryBarrier * pMemoryBarriers,uint32_t bufferMemoryBarrierCount,const VkBufferMemoryBarrier * pBufferMemoryBarriers,uint32_t imageMemoryBarrierCount,const VkImageMemoryBarrier * pImageMemoryBarriers)293 bool BestPractices::PreCallValidateCmdWaitEvents(VkCommandBuffer commandBuffer, uint32_t eventCount, const VkEvent* pEvents,
294 VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask,
295 uint32_t memoryBarrierCount, const VkMemoryBarrier* pMemoryBarriers,
296 uint32_t bufferMemoryBarrierCount,
297 const VkBufferMemoryBarrier* pBufferMemoryBarriers,
298 uint32_t imageMemoryBarrierCount,
299 const VkImageMemoryBarrier* pImageMemoryBarriers) {
300 bool skip = false;
301
302 skip |= CheckPipelineStageFlags("vkCmdWaitEvents", srcStageMask);
303 skip |= CheckPipelineStageFlags("vkCmdWaitEvents", dstStageMask);
304
305 return skip;
306 }
307
PreCallValidateCmdPipelineBarrier(VkCommandBuffer commandBuffer,VkPipelineStageFlags srcStageMask,VkPipelineStageFlags dstStageMask,VkDependencyFlags dependencyFlags,uint32_t memoryBarrierCount,const VkMemoryBarrier * pMemoryBarriers,uint32_t bufferMemoryBarrierCount,const VkBufferMemoryBarrier * pBufferMemoryBarriers,uint32_t imageMemoryBarrierCount,const VkImageMemoryBarrier * pImageMemoryBarriers)308 bool BestPractices::PreCallValidateCmdPipelineBarrier(VkCommandBuffer commandBuffer, VkPipelineStageFlags srcStageMask,
309 VkPipelineStageFlags dstStageMask, VkDependencyFlags dependencyFlags,
310 uint32_t memoryBarrierCount, const VkMemoryBarrier* pMemoryBarriers,
311 uint32_t bufferMemoryBarrierCount,
312 const VkBufferMemoryBarrier* pBufferMemoryBarriers,
313 uint32_t imageMemoryBarrierCount,
314 const VkImageMemoryBarrier* pImageMemoryBarriers) {
315 bool skip = false;
316
317 skip |= CheckPipelineStageFlags("vkCmdPipelineBarrier", srcStageMask);
318 skip |= CheckPipelineStageFlags("vkCmdPipelineBarrier", dstStageMask);
319
320 return skip;
321 }
322
PreCallValidateCmdWriteTimestamp(VkCommandBuffer commandBuffer,VkPipelineStageFlagBits pipelineStage,VkQueryPool queryPool,uint32_t query)323 bool BestPractices::PreCallValidateCmdWriteTimestamp(VkCommandBuffer commandBuffer, VkPipelineStageFlagBits pipelineStage,
324 VkQueryPool queryPool, uint32_t query) {
325 bool skip = false;
326
327 skip |= CheckPipelineStageFlags("vkCmdWriteTimestamp", pipelineStage);
328
329 return skip;
330 }
331
PreCallValidateCmdDraw(VkCommandBuffer commandBuffer,uint32_t vertexCount,uint32_t instanceCount,uint32_t firstVertex,uint32_t firstInstance)332 bool BestPractices::PreCallValidateCmdDraw(VkCommandBuffer commandBuffer, uint32_t vertexCount, uint32_t instanceCount,
333 uint32_t firstVertex, uint32_t firstInstance) {
334 bool skip = false;
335
336 if (instanceCount == 0) {
337 skip |= log_msg(report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
338 layer_name.c_str(), "Warning: You are calling vkCmdDraw() with an instanceCount of Zero.");
339 }
340
341 return skip;
342 }
343
PreCallValidateCmdDrawIndexed(VkCommandBuffer commandBuffer,uint32_t indexCount,uint32_t instanceCount,uint32_t firstIndex,int32_t vertexOffset,uint32_t firstInstance)344 bool BestPractices::PreCallValidateCmdDrawIndexed(VkCommandBuffer commandBuffer, uint32_t indexCount, uint32_t instanceCount,
345 uint32_t firstIndex, int32_t vertexOffset, uint32_t firstInstance) {
346 bool skip = false;
347
348 if (instanceCount == 0) {
349 skip |= log_msg(report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
350 layer_name.c_str(), "Warning: You are calling vkCmdDrawIndexed() with an instanceCount of Zero.");
351 }
352
353 return skip;
354 }
355
PreCallValidateCmdDrawIndirect(VkCommandBuffer commandBuffer,VkBuffer buffer,VkDeviceSize offset,uint32_t drawCount,uint32_t stride)356 bool BestPractices::PreCallValidateCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
357 uint32_t drawCount, uint32_t stride) {
358 bool skip = false;
359
360 if (drawCount == 0) {
361 skip |= log_msg(report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
362 layer_name.c_str(), "Warning: You are calling vkCmdDrawIndirect() with a drawCount of Zero.");
363 }
364
365 return skip;
366 }
367
PreCallValidateCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer,VkBuffer buffer,VkDeviceSize offset,uint32_t drawCount,uint32_t stride)368 bool BestPractices::PreCallValidateCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
369 uint32_t drawCount, uint32_t stride) {
370 bool skip = false;
371
372 if (drawCount == 0) {
373 skip |= log_msg(report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
374 layer_name.c_str(), "Warning: You are calling vkCmdDrawIndexedIndirect() with a drawCount of Zero.");
375 }
376
377 return skip;
378 }
379
PreCallValidateCmdDispatch(VkCommandBuffer commandBuffer,uint32_t groupCountX,uint32_t groupCountY,uint32_t groupCountZ)380 bool BestPractices::PreCallValidateCmdDispatch(VkCommandBuffer commandBuffer, uint32_t groupCountX, uint32_t groupCountY,
381 uint32_t groupCountZ) {
382 bool skip = false;
383
384 if ((groupCountX == 0) || (groupCountY == 0) || (groupCountZ == 0)) {
385 skip |=
386 log_msg(report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, layer_name.c_str(),
387 "Warning: You are calling vkCmdDispatch() while one or more groupCounts are zero (groupCountX = %" PRIu32
388 ", groupCountY = %" PRIu32 ", groupCountZ = %" PRIu32 ").",
389 groupCountX, groupCountY, groupCountZ);
390 }
391
392 return skip;
393 }
394