5#ifndef FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_FORMATS_VK_H_
6#define FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_FORMATS_VK_H_
16#include "vulkan/vulkan_enums.hpp"
23 case vk::Format::eR8G8B8A8Unorm:
25 case vk::Format::eB8G8R8A8Unorm:
35 return vk::SampleCountFlagBits::e1;
37 return vk::SampleCountFlagBits::e4;
45 return vk::BlendFactor::eZero;
47 return vk::BlendFactor::eOne;
49 return vk::BlendFactor::eSrcColor;
51 return vk::BlendFactor::eOneMinusSrcColor;
53 return vk::BlendFactor::eSrcAlpha;
55 return vk::BlendFactor::eOneMinusSrcAlpha;
57 return vk::BlendFactor::eDstColor;
59 return vk::BlendFactor::eOneMinusDstColor;
61 return vk::BlendFactor::eDstAlpha;
63 return vk::BlendFactor::eOneMinusDstAlpha;
65 return vk::BlendFactor::eSrcAlphaSaturate;
67 return vk::BlendFactor::eConstantColor;
69 return vk::BlendFactor::eOneMinusConstantColor;
71 return vk::BlendFactor::eConstantAlpha;
73 return vk::BlendFactor::eOneMinusConstantAlpha;
81 return vk::BlendOp::eAdd;
83 return vk::BlendOp::eSubtract;
85 return vk::BlendOp::eReverseSubtract;
91 vk::ColorComponentFlags mask;
94 mask |= vk::ColorComponentFlagBits::eR;
98 mask |= vk::ColorComponentFlagBits::eG;
102 mask |= vk::ColorComponentFlagBits::eB;
106 mask |= vk::ColorComponentFlagBits::eA;
112constexpr vk::PipelineColorBlendAttachmentState
114 vk::PipelineColorBlendAttachmentState res;
137 return vk::ShaderStageFlagBits::eVertex;
139 return vk::ShaderStageFlagBits::eFragment;
141 return vk::ShaderStageFlagBits::eCompute;
152 return vk::Format::eUndefined;
155 return vk::Format::eR8Unorm;
157 return vk::Format::eR8G8B8A8Unorm;
159 return vk::Format::eR8G8B8A8Srgb;
161 return vk::Format::eB8G8R8A8Unorm;
163 return vk::Format::eB8G8R8A8Srgb;
165 return vk::Format::eR32G32B32A32Sfloat;
167 return vk::Format::eR16G16B16A16Sfloat;
169 return vk::Format::eS8Uint;
171 return vk::Format::eD24UnormS8Uint;
173 return vk::Format::eD32SfloatS8Uint;
175 return vk::Format::eR8Unorm;
177 return vk::Format::eR8G8Unorm;
179 return vk::Format::eR32Sfloat;
181 return vk::Format::eBc1RgbaUnormBlock;
183 return vk::Format::eBc1RgbaSrgbBlock;
185 return vk::Format::eBc3UnormBlock;
187 return vk::Format::eBc3SrgbBlock;
189 return vk::Format::eBc5UnormBlock;
191 return vk::Format::eBc7UnormBlock;
193 return vk::Format::eBc7SrgbBlock;
195 return vk::Format::eEtc2R8G8B8UnormBlock;
197 return vk::Format::eEtc2R8G8B8SrgbBlock;
199 return vk::Format::eEtc2R8G8B8A8UnormBlock;
201 return vk::Format::eEtc2R8G8B8A8SrgbBlock;
203 return vk::Format::eAstc4x4UnormBlock;
205 return vk::Format::eAstc4x4SrgbBlock;
207 return vk::Format::eAstc8x8UnormBlock;
209 return vk::Format::eAstc8x8SrgbBlock;
211 return vk::Format::eAstc4x4SfloatBlock;
213 return vk::Format::eAstc8x8SfloatBlock;
221 case vk::Format::eUndefined:
223 case vk::Format::eR8G8B8A8Unorm:
225 case vk::Format::eR8G8B8A8Srgb:
227 case vk::Format::eB8G8R8A8Unorm:
229 case vk::Format::eB8G8R8A8Srgb:
231 case vk::Format::eR32G32B32A32Sfloat:
233 case vk::Format::eR16G16B16A16Sfloat:
235 case vk::Format::eS8Uint:
237 case vk::Format::eD24UnormS8Uint:
239 case vk::Format::eD32SfloatS8Uint:
241 case vk::Format::eR8Unorm:
243 case vk::Format::eR8G8Unorm:
251 switch (sample_count) {
253 return vk::SampleCountFlagBits::e1;
255 return vk::SampleCountFlagBits::e4;
264 return vk::Filter::eNearest;
266 return vk::Filter::eLinear;
276 return vk::SamplerMipmapMode::eNearest;
278 return vk::SamplerMipmapMode::eLinear;
288 return vk::SamplerAddressMode::eRepeat;
290 return vk::SamplerAddressMode::eMirroredRepeat;
292 return vk::SamplerAddressMode::eClampToEdge;
294 return vk::SamplerAddressMode::eClampToBorder;
303 return vk::ShaderStageFlagBits::eAll;
305 return vk::ShaderStageFlagBits::eFragment;
307 return vk::ShaderStageFlagBits::eCompute;
309 return vk::ShaderStageFlagBits::eVertex;
316 static_cast<int>(vk::DescriptorType::eCombinedImageSampler));
318 static_cast<int>(vk::DescriptorType::eUniformBuffer));
320 static_cast<int>(vk::DescriptorType::eStorageBuffer));
322 static_cast<int>(vk::DescriptorType::eSampledImage));
324 static_cast<int>(vk::DescriptorType::eSampler));
326 static_cast<int>(vk::DescriptorType::eInputAttachment));
329 return static_cast<vk::DescriptorType
>(
type);
334 vk::DescriptorSetLayoutBinding binding;
335 binding.binding = layout.
binding;
336 binding.descriptorCount = 1u;
343 switch (load_action) {
345 return vk::AttachmentLoadOp::eLoad;
347 return vk::AttachmentLoadOp::eClear;
349 return vk::AttachmentLoadOp::eDontCare;
356 bool is_resolve_texture) {
357 switch (store_action) {
361 return vk::AttachmentStoreOp::eStore;
365 return vk::AttachmentStoreOp::eDontCare;
369 return is_resolve_texture ? vk::AttachmentStoreOp::eStore
370 : vk::AttachmentStoreOp::eDontCare;
374 return vk::AttachmentStoreOp::eStore;
380 switch (store_action) {
392 switch (index_type) {
394 return vk::IndexType::eUint16;
396 return vk::IndexType::eUint32;
398 return vk::IndexType::eUint32;
409 return vk::PolygonMode::eFill;
411 return vk::PolygonMode::eLine;
434 return vk::PrimitiveTopology::eTriangleList;
436 return vk::PrimitiveTopology::eTriangleStrip;
438 return vk::PrimitiveTopology::eLineList;
440 return vk::PrimitiveTopology::eLineStrip;
442 return vk::PrimitiveTopology::ePointList;
444 return vk::PrimitiveTopology::eTriangleFan;
493 VK_ATTACHMENT_UNUSED, vk::ImageLayout::eUndefined};
498 return vk::CullModeFlagBits::eNone;
500 return vk::CullModeFlagBits::eFront;
502 return vk::CullModeFlagBits::eBack;
510 return vk::CompareOp::eNever;
512 return vk::CompareOp::eAlways;
514 return vk::CompareOp::eLess;
516 return vk::CompareOp::eEqual;
518 return vk::CompareOp::eLessOrEqual;
520 return vk::CompareOp::eGreater;
522 return vk::CompareOp::eNotEqual;
524 return vk::CompareOp::eGreaterOrEqual;
532 return vk::StencilOp::eKeep;
534 return vk::StencilOp::eZero;
536 return vk::StencilOp::eReplace;
538 return vk::StencilOp::eIncrementAndClamp;
540 return vk::StencilOp::eDecrementAndClamp;
542 return vk::StencilOp::eInvert;
544 return vk::StencilOp::eIncrementAndWrap;
546 return vk::StencilOp::eDecrementAndWrap;
554 vk::StencilOpState state;
563 state.reference = 1988;
600 return vk::ImageAspectFlagBits::eColor;
602 return vk::ImageAspectFlagBits::eStencil;
605 return vk::ImageAspectFlagBits::eDepth |
606 vk::ImageAspectFlagBits::eStencil;
620 <<
"kTextureExternalOES can not be used with the Vulkan backend.";
629 return vk::ImageViewType::e2D;
631 return vk::ImageViewType::eCube;
634 <<
"kTextureExternalOES can not be used with the Vulkan backend.";
645 return vk::ImageCreateFlagBits::eCubeCompatible;
648 <<
"kTextureExternalOES can not be used with the Vulkan backend.";
654 std::optional<DepthAttachmentDescriptor> depth,
655 std::optional<StencilAttachmentDescriptor> front,
656 std::optional<StencilAttachmentDescriptor> back);
692 return vk::ImageAspectFlagBits::eColor;
694 return vk::ImageAspectFlagBits::eStencil;
697 return vk::ImageAspectFlagBits::eDepth |
698 vk::ImageAspectFlagBits::eStencil;
uint32_t uint32_t * format
#define FML_UNREACHABLE()
constexpr std::optional< PixelFormat > VkFormatToImpellerFormat(vk::Format format)
static constexpr vk::AttachmentReference kUnusedAttachmentReference
@ kOneMinusDestinationAlpha
@ kOneMinusDestinationColor
PrimitiveType
Decides how backend draws pixels based on input vertices.
@ kPoint
Draws a point at each input vertex.
constexpr vk::SamplerAddressMode ToVKSamplerAddressMode(SamplerAddressMode mode)
@ kNone
Does not use the index buffer.
constexpr vk::PipelineColorBlendAttachmentState ToVKPipelineColorBlendAttachmentState(const ColorAttachmentDescriptor &desc)
constexpr PixelFormat ToPixelFormat(vk::Format format)
constexpr vk::CompareOp ToVKCompareOp(CompareFunction op)
constexpr vk::SamplerMipmapMode ToVKSamplerMipmapMode(MipFilter filter)
@ kDecal
decal sampling mode is only supported on devices that pass the Capabilities.SupportsDecalSamplerAddre...
constexpr bool StoreActionPerformsResolve(StoreAction store_action)
constexpr vk::IndexType ToVKIndexType(IndexType index_type)
constexpr vk::DescriptorSetLayoutBinding ToVKDescriptorSetLayoutBinding(const DescriptorSetLayout &layout)
constexpr uint32_t ToArrayLayerCount(TextureType type)
constexpr vk::Filter ToVKSamplerMinMagFilter(MinMagFilter filter)
constexpr vk::ImageAspectFlags ToImageAspectFlags(PixelFormat format)
constexpr vk::SampleCountFlagBits ToVKSampleCountFlagBits(SampleCount count)
constexpr vk::AttachmentLoadOp ToVKAttachmentLoadOp(LoadAction load_action)
constexpr vk::DescriptorType ToVKDescriptorType(DescriptorType type)
constexpr vk::PolygonMode ToVKPolygonMode(PolygonMode mode)
PixelFormat
The Pixel formats supported by Impeller. The naming convention denotes the usage of the component,...
@ kEqual
Comparison test passes if new_value == current_value.
@ kLessEqual
Comparison test passes if new_value <= current_value.
@ kGreaterEqual
Comparison test passes if new_value >= current_value.
@ kAlways
Comparison test passes always passes.
@ kLess
Comparison test passes if new_value < current_value.
@ kGreater
Comparison test passes if new_value > current_value.
@ kNotEqual
Comparison test passes if new_value != current_value.
@ kNever
Comparison test never passes.
constexpr vk::AttachmentStoreOp ToVKAttachmentStoreOp(StoreAction store_action, bool is_resolve_texture)
constexpr vk::CullModeFlags ToVKCullModeFlags(CullMode mode)
MipFilter
Options for selecting and filtering between mipmap levels.
@ kLinear
Sample from the two nearest mip levels and linearly interpolate.
@ kBase
The texture is sampled as if it only had a single mipmap level.
@ kNearest
The nearst mipmap level is selected.
constexpr vk::ColorComponentFlags ToVKColorComponentFlags(ColorWriteMask type)
@ kDecrementWrap
Decrement the current stencil value by 1. If at zero, set to maximum.
@ kSetToReferenceValue
Reset the stencil value to the reference value.
@ kDecrementClamp
Decrement the current stencil value by 1. Clamp it to zero.
@ kZero
Reset the stencil value to zero.
@ kIncrementClamp
Increment the current stencil value by 1. Clamp it to the maximum.
@ kIncrementWrap
Increment the current stencil value by 1. If at maximum, set to zero.
@ kInvert
Perform a logical bitwise invert on the current stencil value.
@ kKeep
Don't modify the current stencil value.
constexpr vk::BlendFactor ToVKBlendFactor(BlendFactor factor)
constexpr bool PixelFormatIsDepthStencil(PixelFormat format)
vk::PipelineDepthStencilStateCreateInfo ToVKPipelineDepthStencilStateCreateInfo(std::optional< DepthAttachmentDescriptor > depth, std::optional< StencilAttachmentDescriptor > front, std::optional< StencilAttachmentDescriptor > back)
constexpr bool PrimitiveTopologySupportsPrimitiveRestart(PrimitiveType primitive)
constexpr std::optional< vk::ShaderStageFlagBits > ToVKShaderStageFlagBits(ShaderStage stage)
constexpr vk::ImageViewType ToVKImageViewType(TextureType type)
@ kStoreAndMultisampleResolve
constexpr vk::SampleCountFlagBits ToVKSampleCount(SampleCount sample_count)
constexpr vk::Format ToVKImageFormat(PixelFormat format)
constexpr vk::StencilOpState ToVKStencilOpState(const StencilAttachmentDescriptor &desc)
constexpr vk::ShaderStageFlags ToVkShaderStage(ShaderStage stage)
constexpr vk::PrimitiveTopology ToVKPrimitiveTopology(PrimitiveType primitive)
constexpr vk::BlendOp ToVKBlendOp(BlendOperation op)
constexpr vk::StencilOp ToVKStencilOp(StencilOperation op)
MinMagFilter
Describes how the texture should be sampled when the texture is being shrunk (minified) or expanded (...
@ kNearest
Select nearest to the sample point. Most widely supported.
constexpr vk::ImageCreateFlags ToVKImageCreateFlags(TextureType type)
constexpr vk::ImageAspectFlags ToVKImageAspectFlags(PixelFormat format)
impeller::ShaderType type
Describe the color attachment that will be used with this pipeline.
BlendOperation color_blend_op
BlendFactor dst_color_blend_factor
ColorWriteMask write_mask
BlendFactor src_alpha_blend_factor
BlendOperation alpha_blend_op
BlendFactor src_color_blend_factor
BlendFactor dst_alpha_blend_factor
DescriptorType descriptor_type
StencilOperation stencil_failure
CompareFunction stencil_compare
StencilOperation depth_failure
StencilOperation depth_stencil_pass