WHLSLPipelineDescriptor.h [plain text]
#pragma once
#if ENABLE(WEBGPU)
#include <wtf/OptionSet.h>
#include <wtf/Variant.h>
#include <wtf/Vector.h>
namespace WebCore {
namespace WHLSL {
enum class VertexFormat : uint8_t {
FloatR32G32B32A32,
FloatR32G32B32,
FloatR32G32,
FloatR32
};
struct VertexAttribute {
VertexFormat vertexFormat;
unsigned shaderLocation;
unsigned metalLocation;
};
using VertexAttributes = Vector<VertexAttribute>;
enum class TextureFormat {
R8Unorm,
R8UnormSrgb,
R8Snorm,
R16Unorm,
R16Snorm,
R16Float,
RG8Unorm,
RG8UnormSrgb,
RG8Snorm,
B5G6R5Unorm,
R32Uint,
R32Sint,
R32Float,
RG16Unorm,
RG16Snorm,
RG16Float,
RGBA8Unorm,
RGBA8UnormSrgb,
RGBA8Snorm,
BGRA8Unorm,
BGRA8UnormSrgb,
RGB10A2Unorm,
RG11B10Float,
RG32Uint,
RG32Sint,
RG32Float,
RGBA16Unorm,
RGBA16Snorm,
RGBA16Float,
RGBA32Uint,
RGBA32Sint,
RGBA32Float
};
struct AttachmentDescriptor {
TextureFormat textureFormat;
unsigned name;
};
struct AttachmentsStateDescriptor {
Vector<AttachmentDescriptor> attachmentDescriptors;
Optional<AttachmentDescriptor> depthStencilAttachmentDescriptor;
};
enum class ShaderStage : uint8_t {
None = 0,
Vertex = 1 << 0,
Fragment = 1 << 1,
Compute = 1 << 2
};
struct UniformBufferBinding {
unsigned lengthName;
};
struct SamplerBinding {
};
struct TextureBinding {
};
struct StorageBufferBinding {
unsigned lengthName;
};
struct Binding {
using BindingDetails = Variant<UniformBufferBinding, SamplerBinding, TextureBinding, StorageBufferBinding>;
OptionSet<ShaderStage> visibility;
BindingDetails binding;
unsigned internalName;
unsigned externalName;
};
struct BindGroup {
Vector<Binding> bindings;
unsigned name;
};
using Layout = Vector<BindGroup>;
struct RenderPipelineDescriptor {
VertexAttributes vertexAttributes;
AttachmentsStateDescriptor attachmentsStateDescriptor;
Layout layout;
String vertexEntryPointName;
String fragmentEntryPointName;
};
struct ComputePipelineDescriptor {
Layout layout;
String entryPointName;
};
using PipelineDescriptor = Variant<RenderPipelineDescriptor, ComputePipelineDescriptor>;
}
}
#endif // ENABLE(WEBGPU)