1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2024-12-01 16:24:12 +01:00

[dxvk] Move vulkan helpers to vulkan module

This commit is contained in:
Philip Rebohle 2018-11-02 19:42:29 +01:00
parent d5481ac013
commit a97073adb9
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
3 changed files with 113 additions and 61 deletions

View File

@ -18,3 +18,4 @@
#include "../vulkan/vulkan_loader.h"
#include "../vulkan/vulkan_names.h"
#include "../vulkan/vulkan_util.h"

View File

@ -213,64 +213,3 @@ namespace dxvk::util {
uint32_t identity);
}
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);
}
inline bool operator == (
const VkImageSubresourceLayers& a,
const VkImageSubresourceLayers& b) {
return a.aspectMask == b.aspectMask
&& a.mipLevel == b.mipLevel
&& a.baseArrayLayer == b.baseArrayLayer
&& a.layerCount == b.layerCount;
}
inline bool operator != (
const VkImageSubresourceLayers& a,
const VkImageSubresourceLayers& b) {
return !operator == (a, b);
}
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;
}
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;
}

112
src/vulkan/vulkan_util.h Normal file
View File

@ -0,0 +1,112 @@
#pragma once
#include "vulkan_loader_fn.h"
namespace dxvk::vk {
inline VkImageSubresourceRange makeSubresourceRange(
const VkImageSubresourceLayers& layers) {
VkImageSubresourceRange range;
range.aspectMask = layers.aspectMask;
range.baseMipLevel = layers.mipLevel;
range.levelCount = 1;
range.baseArrayLayer = layers.baseArrayLayer;
range.layerCount = layers.layerCount;
return range;
}
inline VkImageSubresourceRange makeSubresourceRange(
const VkImageSubresource& subres) {
VkImageSubresourceRange range;
range.aspectMask = subres.aspectMask;
range.baseMipLevel = subres.mipLevel;
range.levelCount = 1;
range.baseArrayLayer = subres.arrayLayer;
range.layerCount = 1;
return range;
}
inline VkImageSubresourceLayers pickSubresourceLayers(
const VkImageSubresourceRange& range,
uint32_t level) {
VkImageSubresourceLayers layers;
layers.aspectMask = range.aspectMask;
layers.mipLevel = range.baseMipLevel + level;
layers.baseArrayLayer = range.baseArrayLayer;
layers.layerCount = range.layerCount;
return layers;
}
inline VkImageSubresource pickSubresource(
const VkImageSubresourceRange& range,
uint32_t level,
uint32_t layer) {
VkImageSubresource subres;
subres.aspectMask = range.aspectMask;
subres.mipLevel = range.baseMipLevel + level;
subres.arrayLayer = range.baseArrayLayer + layer;
return subres;
}
}
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);
}
inline bool operator == (
const VkImageSubresourceLayers& a,
const VkImageSubresourceLayers& b) {
return a.aspectMask == b.aspectMask
&& a.mipLevel == b.mipLevel
&& a.baseArrayLayer == b.baseArrayLayer
&& a.layerCount == b.layerCount;
}
inline bool operator != (
const VkImageSubresourceLayers& a,
const VkImageSubresourceLayers& b) {
return !operator == (a, b);
}
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;
}
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;
}