// Copyright (c) 2012-2023 Wojciech Figat. All rights reserved.
#pragma once
#include "Engine/Graphics/GPUResourceState.h"
#include "IncludeVulkanHeaders.h"
#if GRAPHICS_API_VULKAN
class GPUResource;
class GPUContextVulkan;
///
/// Vulkan resource state used to indicate invalid state (useful for debugging resource tracking issues).
///
#define VK_IMAGE_LAYOUT_CORRUPT VK_IMAGE_LAYOUT_MAX_ENUM
///
/// Tracking of per-resource or per-subresource state for Vulkan resources that require to issue resource access barriers during rendering.
///
class ResourceStateVulkan : public GPUResourceState
{
};
///
/// Base class for objects in Vulkan backend that can own a resource.
///
class ResourceOwnerVulkan
{
friend GPUContextVulkan;
public:
virtual ~ResourceOwnerVulkan()
{
}
public:
///
/// The resource state tracking helper. Used for resource barriers.
///
ResourceStateVulkan State;
///
/// The array size (for textures).
///
int32 ArraySlices;
public:
///
/// Gets resource owner object as a GPUResource type or returns null if cannot perform cast.
///
/// GPU Resource or null if cannot cast.
virtual GPUResource* AsGPUResource() const = 0;
protected:
void initResource(VkImageLayout initialState, int32 mipLevels = 1, int32 arraySize = 1, bool usePerSubresourceTracking = false)
{
State.Initialize(mipLevels * arraySize, initialState, usePerSubresourceTracking);
ArraySlices = arraySize;
}
};
#endif