KhronosGroup / Vulkan-LoaderAndValidationLayers

**Deprecated repository** for Vulkan loader and validation layers
Apache License 2.0
414 stars 172 forks source link

Best Practices/Assistant/Performance Layer #1612

Open mark-lunarg opened 7 years ago

mark-lunarg commented 7 years ago

This issue is a place holder for a utility layer which provides application feedback for performance-related checks. For details and to add items, please see/add to the LunarG Github VulkanTools project Wiki or add an issue to this repo or VulkanTools and we'll add to the master list.

The following Github issues have been created and are now tracked by this issue -- completed checks are currently present in the assistant_layer, available in the Github VulkanTools repository, and soon to be in the Vulkan SDK.

Portability checks as suggested by Ecosystem Issue #11

karl-lunarg commented 7 years ago

1628 "VK_LAYER_LUNARG_core_validation queue submissions list grows forever and causes crash" might be another candidate condition to check for in this layer.

RippeR37 commented 7 years ago

Idea: Maybe this layer could also check if same state is set multiple times in a row which can lead to lower performance?

mark-lunarg commented 7 years ago

From @Tony-LunarG: Assuming that the 99% common workflow is [BeginCommandBuffer; write commands to command buffer; EndCommandBuffer], it would be nice to warn developer if the code is recording two command buffers simultaneously. Would also need to validate assumption about workflow. Note that it needs to be thread smart since we expect multiple threads to be recording multiple command buffers simultaneously

MarkY-LunarG commented 7 years ago

Idea: Detect case of LVL issue #1917 and warn.

karl-lunarg commented 7 years ago

Idea: #2061 - Add a layer that writes a unique ID to a CPU-visible buffer whenever a marker is encountered. After a GPU crash, the buffer can be examined to see the last ID written.

HansKristian-Work commented 6 years ago

Is this supposed to be a generic layer for best practices on Vulkan which collects best practices from a spec POV, or would there be room for IHV specifics as well (which are probably where the most useful/interesting checks will be)?

mark-lunarg commented 6 years ago

@HansKristian-ARM, the Assistant Layer effort is currently focused on the former. However, it is a simple matter to create related assistant-type layers specific to a particular IHV. The aim of the layer framework is to make the creation of these types of layers much more straightforward.

hrydgard commented 6 years ago

Regarding transitions from VK_IMAGE_LAYOUT_UNDEFINED to anything: When initializing textures with known data, I:

It seems to me that it would make sense to allow creating images directly in VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL and copy to them , I don't quite understand why that's not allowed.

krOoze commented 6 years ago

As this sequence will trigger a couple of the proposed checks in this issue, what's the recommended way to do this?

It will? You are making the contents defined in step 3, so the layers should not complain. Your sequence seems fine to me (except perhaps the wasteful VK_PIPELINE_STAGE_ALL_COMMANDS).

creating images directly in VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL and copy to them , I don't quite understand why that's not allowed.

I would assume the same reason why PREINITIALIZED is distinct from GENERAL. It ensures there will be at least one barrier before the first use of the Image by the device.

hrydgard commented 6 years ago

It will?

This one: "Transitions from VK_IMAGE_LAYOUT_UNDEFINED to anything".

wasteful VK_PIPELINE_STAGE_ALL_COMMANDS

What src pipeline stage would you suggest for transitioning from UNDEFINED? Simply BOTTOM_OF_PIPE?

EDIT: Well TOP_OF_PIPE of course, thanks. Keep confusing them.

krOoze commented 6 years ago

It will?

This one: "Transitions from VK_IMAGE_LAYOUT_UNDEFINED to anything".

You need to read the rest of that paragraph. It concerns itself with a situation where someone transitions from UNDEFINED and then reads the contents. The contents become undefined, so (depending on platform) it may contain original data or it may be trashed upon the read.

But you are writing the content, which makes it defined again. So it should not trigger any such checks. Check implemented in a way which interferes with your case would indeed be useless. It is a very common case, and it cannot be done any differently for TILING_OPTIMAL images.

What src pipeline stage would you suggest for transitioning from UNDEFINED? Simply BOTTOM_OF_PIPE?

New Image\Memory does not have any outstanding read\write operations on it to synchronize against. So, assuming you are not merging other barriers to this, srcStage = TOP_OF_PIPE (i.e. no execution dependency) will suffice.