| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
- //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
- #pragma once
- #include "BsVulkanPrerequisites.h"
- #include "Image/BsPixelUtil.h"
- #include "RenderAPI/BsVertexDeclaration.h"
- namespace bs { namespace ct
- {
- /** @addtogroup Vulkan
- * @{
- */
- /** Contains various helper methods for dealing with Vulkan. */
- class VulkanUtility
- {
- public:
- /** Finds the closest pixel format that a specific Vulkan device supports. */
- static PixelFormat getClosestSupportedPixelFormat(VulkanDevice& device, PixelFormat format, TextureType texType,
- int usage, bool optimalTiling, bool hwGamma);
- /** Converts between Banshee and Vulkan pixel format. */
- static VkFormat getPixelFormat(PixelFormat format, bool sRGB = false);
- /** Converts between Banshee and Vulkan buffer element format. */
- static VkFormat getBufferFormat(GpuBufferFormat format);
- /** Converts between Banshee and Vulkan vertex element types. */
- static VkFormat getVertexType(VertexElementType type);
- /** Converts between Banshee and Vulkan texture addressing mode. */
- static VkSamplerAddressMode getAddressingMode(TextureAddressingMode mode);
- /** Converts between Banshee and Vulkan blend factor. */
- static VkBlendFactor getBlendFactor(BlendFactor factor);
- /** Converts between Banshee and Vulkan blend operation. */
- static VkBlendOp getBlendOp(BlendOperation op);
- /** Converts between Banshee and Vulkan comparison operation. */
- static VkCompareOp getCompareOp(CompareFunction op);
- /** Converts between Banshee and Vulkan cull mode. */
- static VkCullModeFlagBits getCullMode(CullingMode mode);
- /** Converts between Banshee and Vulkan polygon mode. */
- static VkPolygonMode getPolygonMode(PolygonMode mode);
- /** Converts between Banshee and Vulkan stencil op. */
- static VkStencilOp getStencilOp(StencilOperation op);
- /** Converts between Banshee and Vulkan index type. */
- static VkIndexType getIndexType(IndexType op);
- /** Converts between Banshee and Vulkan draw operation (i.e. primitive topology). */
- static VkPrimitiveTopology getDrawOp(DrawOperationType op);
- /** Converts between Banshee and Vulkan texture filtering modes. */
- static VkFilter getFilter(FilterOptions filter);
- /** Converts between Banshee and Vulkan texture filtering modes. */
- static VkSamplerMipmapMode getMipFilter(FilterOptions filter);
- /** Gets Vulkan flags representing the number of samples in an image. Sample count must be a power of 2. */
- static VkSampleCountFlagBits getSampleFlags(UINT32 numSamples);
- /** Gets Vulkan flags representing a certain shader stage. */
- static VkShaderStageFlagBits getShaderStage(GpuProgramType type);
- /**
- * Populates the provided array with Vulkan devices that correspond to provided flags. Sets null in unused slots.
- * Each device is placed at its own index in the output array.
- */
- static void getDevices(const VulkanRenderAPI& rapi, GpuDeviceFlags flags, VulkanDevice* (&devices)[BS_MAX_DEVICES]);
- /** Checks is a flag for a particular device enabled. */
- static bool isDeviceIdxSet(const VulkanRenderAPI& rapi, UINT32 idx, GpuDeviceFlags flags);
- /**
- * Subdivides an image subresource range by cutting it with another range. If the ranges don't overlap, or the
- * @p cutWith range completely overs the @p toCut range, the original @p toCut range is output.
- *
- * @param[in] toCut Range to cut.
- * @param[in] cutWith Range to cut with.
- * @param[out] output Pieces of the range that was cut.
- * @param[out] numAreas Number of pieces in the @p output array.
- */
- static void cutRange(const VkImageSubresourceRange& toCut, const VkImageSubresourceRange& cutWith,
- std::array<VkImageSubresourceRange, 5>& output, UINT32& numAreas);
- /** Checks if the two image subresource ranges have any overlapping subresources. */
- static bool rangeOverlaps(const VkImageSubresourceRange& a, const VkImageSubresourceRange& b);
- /**
- * Calculates the size and alignment of a single element within a shader interface block using the std140 layout.
- *
- * @param[in] type Type of the element. Structs are not supported.
- * @param[in] arraySize Number of array elements of the element (1 if it's not an array).
- * @param[in, out] offset Current location in some parent buffer at which the element should be placed at. If the
- * location doesn't match the element's alignment, the value will be modified to a valid
- * alignment. In multiples of 4 bytes.
- * @return Size of the element, in multiples of 4 bytes.
- */
- static UINT32 calcInterfaceBlockElementSizeAndOffset(GpuParamDataType type, UINT32 arraySize, UINT32& offset);
- };
- /** @} */
- }}
|