18 #include <QtCore/QUuid>
23 namespace vks {
namespace util {
26 inline VkColorComponentFlags fullColorWriteMask() {
27 return VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT | VK_COLOR_COMPONENT_B_BIT |
28 VK_COLOR_COMPONENT_A_BIT;
31 inline VkViewport viewport(
float width,
float height,
float minDepth = 0,
float maxDepth = 1) {
33 viewport.width = width;
34 viewport.height = height;
35 viewport.minDepth = minDepth;
36 viewport.maxDepth = maxDepth;
40 inline VkViewport viewport(
const glm::uvec2& size,
float minDepth = 0,
float maxDepth = 1) {
41 return viewport((
float)size.x, (
float)size.y, minDepth, maxDepth);
44 inline VkViewport viewport(
const VkExtent2D& size,
float minDepth = 0,
float maxDepth = 1) {
45 return viewport((
float)size.width, (
float)size.height, minDepth, maxDepth);
48 inline VkRect2D rect2D(uint32_t width, uint32_t height, int32_t offsetX = 0, int32_t offsetY = 0) {
50 rect2D.extent.width = width;
51 rect2D.extent.height = height;
52 rect2D.offset.x = offsetX;
53 rect2D.offset.y = offsetY;
57 inline VkRect2D rect2D(
const glm::uvec2& size,
const glm::ivec2& offset = glm::ivec2(0)) {
58 return rect2D(size.x, size.y, offset.x, offset.y);
61 inline VkRect2D rect2D(
const VkExtent2D& size,
const VkOffset2D& offset = VkOffset2D()) {
62 return rect2D(size.width, size.height, offset.x, offset.y);
65 inline VkAccessFlags accessFlagsForLayout(VkImageLayout layout) {
67 case VK_IMAGE_LAYOUT_PREINITIALIZED:
68 return VK_ACCESS_HOST_WRITE_BIT;
69 case VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL:
70 return VK_ACCESS_TRANSFER_WRITE_BIT;
71 case VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL:
72 return VK_ACCESS_TRANSFER_READ_BIT;
73 case VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL:
74 return VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
75 case VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL:
76 return VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT;
77 case VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL:
78 return VK_ACCESS_SHADER_READ_BIT;
80 return VkAccessFlags();
84 bool loadPipelineCacheData(std::vector<uint8_t>& outCache);
85 void savePipelineCacheData(
const std::vector<uint8_t>& cache);
89 using UuidSet = std::set<QUuid>;
92 bool contextSupported(QOpenGLContext*);