1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2024-12-13 07:08:50 +01:00

[dxvk] Add method to query shader stages that can access a buffer

This commit is contained in:
Philip Rebohle 2022-06-21 15:22:05 +02:00
parent 893183a7cc
commit db85de8c91
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
3 changed files with 25 additions and 1 deletions

View File

@ -14,7 +14,8 @@ namespace dxvk {
: m_device (device),
m_info (createInfo),
m_memAlloc (&memAlloc),
m_memFlags (memFlags) {
m_memFlags (memFlags),
m_shaderStages (util::shaderStages(createInfo.stages)) {
// Align slices so that we don't violate any alignment
// requirements imposed by the Vulkan device/driver
VkDeviceSize sliceAlignment = computeSliceAlignment();

View File

@ -143,6 +143,16 @@ namespace dxvk {
return reinterpret_cast<char*>(m_physSlice.mapPtr) + offset;
}
/**
* \brief Queries shader stages that can access this buffer
*
* Derived from the pipeline stage mask passed in during creation.
* \returns Shader stages that may access this buffer
*/
VkShaderStageFlags getShaderStages() const {
return m_shaderStages;
}
/**
* \brief Retrieves slice handle
* \returns Buffer slice handle
@ -286,6 +296,7 @@ namespace dxvk {
DxvkBufferCreateInfo m_info;
DxvkMemoryAllocator* m_memAlloc;
VkMemoryPropertyFlags m_memFlags;
VkShaderStageFlags m_shaderStages;
DxvkBufferHandle m_buffer;
DxvkBufferSliceHandle m_physSlice;

View File

@ -16,6 +16,18 @@ namespace dxvk::util {
| (shaderStages & VK_SHADER_STAGE_COMPUTE_BIT) << 6;
}
/**
* \brief Gets shader stage flags included in pipeline stages
*
* \param [in] pipelineStages Pipeline stage flags
* \returns Corresponding shader stage flags, if any
*/
inline VkShaderStageFlags shaderStages(
VkPipelineStageFlags pipelineStages) {
return ((pipelineStages >> 3) & VK_SHADER_STAGE_ALL_GRAPHICS)
| ((pipelineStages >> 6) & VK_SHADER_STAGE_COMPUTE_BIT);
}
/**
* \brief Computes number of mip levels for an image
*