diff --git a/src/dxvk/dxvk_buffer.cpp b/src/dxvk/dxvk_buffer.cpp index 931a6269..3de5b4d7 100644 --- a/src/dxvk/dxvk_buffer.cpp +++ b/src/dxvk/dxvk_buffer.cpp @@ -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(); diff --git a/src/dxvk/dxvk_buffer.h b/src/dxvk/dxvk_buffer.h index 4d94cec7..13909810 100644 --- a/src/dxvk/dxvk_buffer.h +++ b/src/dxvk/dxvk_buffer.h @@ -142,6 +142,16 @@ namespace dxvk { void* mapPtr(VkDeviceSize offset) const { return reinterpret_cast(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 @@ -286,6 +296,7 @@ namespace dxvk { DxvkBufferCreateInfo m_info; DxvkMemoryAllocator* m_memAlloc; VkMemoryPropertyFlags m_memFlags; + VkShaderStageFlags m_shaderStages; DxvkBufferHandle m_buffer; DxvkBufferSliceHandle m_physSlice; diff --git a/src/dxvk/dxvk_util.h b/src/dxvk/dxvk_util.h index 94fd06dd..181e448d 100644 --- a/src/dxvk/dxvk_util.h +++ b/src/dxvk/dxvk_util.h @@ -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 *