2017-10-15 17:56:06 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "dxvk_include.h"
|
|
|
|
|
|
|
|
namespace dxvk::util {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Gets pipeline stage flags for shader stages
|
|
|
|
*
|
|
|
|
* \param [in] shaderStages Shader stage flags
|
|
|
|
* \returns Corresponding pipeline stage flags
|
|
|
|
*/
|
|
|
|
VkPipelineStageFlags pipelineStages(
|
|
|
|
VkShaderStageFlags shaderStages);
|
|
|
|
|
2017-12-10 19:10:17 +01:00
|
|
|
/**
|
|
|
|
* \brief Computes number of mip levels for an image
|
|
|
|
*
|
|
|
|
* \param [in] imageSize Size of the image
|
|
|
|
* \returns Number of mipmap layers
|
|
|
|
*/
|
|
|
|
uint32_t computeMipLevelCount(VkExtent3D imageSize);
|
2017-12-10 15:57:51 +01:00
|
|
|
|
2018-01-20 21:42:11 +01:00
|
|
|
/**
|
|
|
|
* \brief Writes tightly packed image data to a buffer
|
|
|
|
*
|
|
|
|
* \param [in] dstData Destination buffer pointer
|
|
|
|
* \param [in] srcData Pointer to source data
|
|
|
|
* \param [in] blockCount Number of blocks to copy
|
|
|
|
* \param [in] blockSize Number of bytes per block
|
|
|
|
* \param [in] pitchPerRow Number of bytes between rows
|
|
|
|
* \param [in] pitchPerLayer Number of bytes between layers
|
|
|
|
*/
|
|
|
|
void packImageData(
|
|
|
|
char* dstData,
|
|
|
|
const char* srcData,
|
|
|
|
VkExtent3D blockCount,
|
|
|
|
VkDeviceSize blockSize,
|
|
|
|
VkDeviceSize pitchPerRow,
|
|
|
|
VkDeviceSize pitchPerLayer);
|
|
|
|
|
2018-01-20 20:31:47 +01:00
|
|
|
/**
|
|
|
|
* \brief Computes block count for compressed images
|
|
|
|
*
|
|
|
|
* Convenience function to compute the size, in
|
|
|
|
* blocks, of compressed images subresources.
|
|
|
|
* \param [in] imageSize The image size
|
|
|
|
* \param [in] blockSize Size per pixel block
|
|
|
|
* \returns Number of blocks in the image
|
|
|
|
*/
|
|
|
|
inline VkExtent3D computeBlockCount(VkExtent3D imageSize, VkExtent3D blockSize) {
|
|
|
|
return VkExtent3D {
|
|
|
|
(imageSize.width + blockSize.width - 1) / blockSize.width,
|
|
|
|
(imageSize.height + blockSize.height - 1) / blockSize.height,
|
|
|
|
(imageSize.depth + blockSize.depth - 1) / blockSize.depth };
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Computes number of pixels or blocks of an image
|
|
|
|
*
|
|
|
|
* Basically returns the product of width, height and depth.
|
|
|
|
* \param [in] extent Image extent, in pixels or blocks
|
|
|
|
* \returns Flattened number of pixels or blocks
|
|
|
|
*/
|
|
|
|
inline uint32_t flattenImageExtent(VkExtent3D extent) {
|
|
|
|
return extent.width * extent.height * extent.depth;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-02-06 17:31:23 +01:00
|
|
|
inline bool operator == (
|
|
|
|
const VkImageSubresourceRange& a,
|
|
|
|
const VkImageSubresourceRange& b) {
|
|
|
|
return a.aspectMask == b.aspectMask
|
|
|
|
&& a.baseMipLevel == b.baseMipLevel
|
|
|
|
&& a.levelCount == b.levelCount
|
|
|
|
&& a.baseArrayLayer == b.baseArrayLayer
|
|
|
|
&& a.layerCount == b.layerCount;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline bool operator != (
|
|
|
|
const VkImageSubresourceRange& a,
|
|
|
|
const VkImageSubresourceRange& b) {
|
|
|
|
return !operator == (a, b);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-01-20 20:31:47 +01:00
|
|
|
inline bool operator == (VkExtent3D a, VkExtent3D b) {
|
|
|
|
return a.width == b.width
|
|
|
|
&& a.height == b.height
|
|
|
|
&& a.depth == b.depth;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline bool operator != (VkExtent3D a, VkExtent3D b) {
|
|
|
|
return a.width != b.width
|
|
|
|
|| a.height != b.height
|
|
|
|
|| a.depth != b.depth;
|
2017-12-10 15:57:51 +01:00
|
|
|
}
|
|
|
|
|
2018-01-13 03:53:33 +01:00
|
|
|
|
2018-01-20 20:31:47 +01:00
|
|
|
inline bool operator == (VkExtent2D a, VkExtent2D b) {
|
|
|
|
return a.width == b.width
|
|
|
|
&& a.height == b.height;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline bool operator != (VkExtent2D a, VkExtent2D b) {
|
|
|
|
return a.width != b.width
|
|
|
|
|| a.height != b.height;
|
|
|
|
}
|