LLGL 0.05 Beta
Loading...
Searching...
No Matches

Context class for descriptor parsing. More...

#include <Parse.h>

Public Types

using StringType = SmallVector<char, 0>
using TokenArrayType = SmallVector<StringView, 0>

Public Member Functions

 ParseContext ()=default
 ParseContext (const ParseContext &)=default
ParseContext & operator= (const ParseContext &)=default
 ParseContext (ParseContext &&)=default
ParseContext & operator= (ParseContext &&)=default
 ParseContext (const StringView &source)
 Constructs the context with a string view.
 ParseContext (UTF8String &&source)
 Constructs the context with a UTF-8 string.
PipelineLayoutDescriptor AsPipelineLayoutDesc () const
 Generates a pipeline layout descriptor from this parse context.
SamplerDescriptor AsSamplerDesc () const
 Generates a sampler descriptor from this parse context.
DepthDescriptor AsDepthDesc () const
 Generates a depth descriptor from this parse context.
StencilFaceDescriptor AsStencilFaceDesc () const
 Generates a stencil-face descriptor from this parse context.
StencilDescriptor AsStencilDesc () const
 Generates a stencil descriptor from this parse context.
TextureSwizzleRGBA AsTextureSwizzleRGBA () const
 Generates a texture swizzle descriptor from this parse context.
VertexAttribute AsVertexAttribute () const
 Generates a basic vertex attribute descriptor from this parse context. This only includes format and identifier.
DynamicVector< VertexAttribute > AsVertexAttributeVector () const
 Generates a vector of basic vertex attributes from this parse context.
 operator PipelineLayoutDescriptor () const
 Implicit conversion to PipelineLayoutDescriptor.
 operator SamplerDescriptor () const
 Implicit conversion to SamplerDescriptor.
 operator DepthDescriptor () const
 Implicit conversion to DepthDescriptor.
 operator StencilFaceDescriptor () const
 Implicit conversion to StencilFaceDescriptor.
 operator StencilDescriptor () const
 Implicit conversion to StencilDescriptor.
 operator TextureSwizzleRGBA () const
 Implicit conversion to TextureSwizzleRGBA.
 operator VertexAttribute () const
 Implicit conversion to VertexAttribute.
 operator DynamicVector< VertexAttribute > () const
 Implicit conversion to DynamicVector<VertexAttribute>.

Detailed Description

Context class for descriptor parsing.

Remarks
Numeric values are parsed as follows:
DIGIT := '0'-'9'
HEX_DIGIT := '0'-'9' | 'a'-'f' | 'A'-'F'
BOOL_TRUE := 'true' | 'yes' | 'on' | '1'
BOOL_FALSE := 'false' | 'no' | 'off' | '0'
BOOL := BOOL_TRUE | BOOL_FALSE
INT := DIGIT+ | '0x' HEX_DIGIT+
FLOAT := INT | INT '.' INT
See also
Parse

Member Typedef Documentation

◆ StringType

◆ TokenArrayType

Constructor & Destructor Documentation

◆ ParseContext() [1/5]

LLGL::ParseContext::ParseContext ( )
default

◆ ParseContext() [2/5]

LLGL::ParseContext::ParseContext ( const ParseContext & )
default

◆ ParseContext() [3/5]

LLGL::ParseContext::ParseContext ( ParseContext && )
default

◆ ParseContext() [4/5]

LLGL::ParseContext::ParseContext ( const StringView & source)
explicit

Constructs the context with a string view.

Remarks
This will only keep a weak reference to the source string and that string must be kept alive for the lifetime of this context.

◆ ParseContext() [5/5]

LLGL::ParseContext::ParseContext ( UTF8String && source)
explicit

Constructs the context with a UTF-8 string.

Remarks
This will take the ownership of the source string.

Member Function Documentation

◆ AsDepthDesc()

DepthDescriptor LLGL::ParseContext::AsDepthDesc ( ) const

Generates a depth descriptor from this parse context.

Remarks
The syntax for this conversion is as follows:
Here is a usage example:
LLGL::DepthDescriptor myDepthDesc = LLGL::Parse("compare=ls,test=on,write=on");
LLGL_EXPORT ParseContext Parse(const char *format,...)
Returns a parse context for the input source code.
Depth state descriptor structure.
Definition PipelineStateFlags.h:434

◆ AsPipelineLayoutDesc()

PipelineLayoutDescriptor LLGL::ParseContext::AsPipelineLayoutDesc ( ) const

Generates a pipeline layout descriptor from this parse context.

Remarks
The syntax for this conversion is as follows:
Here is a usage example:
// Standard way of declaring a pipeline layout:
myLayoutDescStd.heapBindings = {
};
myLayoutDescStd.bindings = {
LLGL::BindingDescriptor{ "smpl" LLGL::ResourceType::Sampler, 0, LLGL::StageFlags::FragmentStage, 3u },
};
myLayoutDescStd.uniforms = {
LLGL::UniformDescriptor{ "WorldMatrix", LLGL::UniformType::Float4x4 }
};
myLayoutDescStd.combinedTextureSamplers = {
LLGL::CombinedTextureSamplerDescriptor{ "TexArray_smpl", "TexArray", "smpl" }
};
auto myLayout = myRenderer->CreatePipelineLayout(myLayoutDescStd);
@ Float4x4
4x4 matrix of 32-bit floating-points. Use "float4x4" for parsing.
Definition PipelineLayoutFlags.h:108
@ Sampler
Sampler state resource.
Definition ResourceFlags.h:49
@ Buffer
Buffer resource.
Definition ResourceFlags.h:34
@ Texture
Texture resource.
Definition ResourceFlags.h:42
@ Sampled
The resource can be used to bind a buffer or texture for read access.
Definition ResourceFlags.h:111
@ ConstantBuffer
The resource can be used to bind a set of constants.
Definition ResourceFlags.h:88
Layout structure for a single binding point of the pipeline layout descriptor.
Definition PipelineLayoutFlags.h:175
Pipeline layout descriptor structure.
Definition PipelineLayoutFlags.h:477
std::vector< BindingDescriptor > bindings
List of individual layout resource bindings.
Definition PipelineLayoutFlags.h:502
std::vector< CombinedTextureSamplerDescriptor > combinedTextureSamplers
List of combined texture-samplers.
Definition PipelineLayoutFlags.h:535
std::vector< BindingDescriptor > heapBindings
List of layout resource heap bindings.
Definition PipelineLayoutFlags.h:494
std::vector< UniformDescriptor > uniforms
List of shader uniforms that can be written dynamically.
Definition PipelineLayoutFlags.h:525
@ VertexStage
Specifies the vertex shader stage.
Definition ShaderFlags.h:218
@ FragmentStage
Specifies the fragment shader stage (also referred to as "Pixel Shader").
Definition ShaderFlags.h:230
The same pipeline layout can be created with the following usage of this utility function:
// Abbreviated way of declaring a pipeline layout using the utility function:
"heap{ cbuffer(Scene@0):frag:vert }," // Constant buffer "Scene"
"heap{ texture(1, TexArray@2[4]):frag }," // Texture "TexArray"
"sampler(smpl@3):frag," // Sampler "smpl"
"float4x4(WorldMatrix)," // Uniform "WorldMatrix"
"sampler<TexArray,smpl>(TexArray_smpl)," // Combined texture-sampler "TexArray_smpl"
);
auto myLayout = myRenderer->CreatePipelineLayout(myLayoutDescUtil);

◆ AsSamplerDesc()

SamplerDescriptor LLGL::ParseContext::AsSamplerDesc ( ) const

Generates a sampler descriptor from this parse context.

Remarks
The syntax for this conversion is as follows:
Here is a usage example:
// Standard way of declaring a sampler descriptor:
LLGL::SamplerDescriptor mySamplerDescStd;
mySamplerDescStd.addressModeU = LLGL::SamplerDescriptor::Clamp;
mySamplerDescStd.addressModeV = LLGL::SamplerDescriptor::Clamp;
mySamplerDescStd.mipMapLODBias = 2.5f;
auto mySampler = myRenderer->CreateSampler(mySamplerDescStd);
@ Nearest
Take the nearest texture sample.
Definition SamplerFlags.h:84
Texture sampler descriptor structure.
Definition SamplerFlags.h:102
SamplerFilter minFilter
Minification filter. By default SamplerFilter::Linear.
Definition SamplerFlags.h:120
SamplerAddressMode addressModeV
Sampler address mode in V direction (also Y axis). By default SamplerAddressMode::Repeat.
Definition SamplerFlags.h:114
SamplerAddressMode addressModeU
Sampler address mode in U direction (also X axis). By default SamplerAddressMode::Repeat.
Definition SamplerFlags.h:111
float mipMapLODBias
MIP-mapping level-of-detail (LOD) bias (or rather offset). By default 0.
Definition SamplerFlags.h:141
SamplerFilter magFilter
Magnification filter. By default SamplerFilter::Linear.
Definition SamplerFlags.h:123
The same sampler can be created with the following usage of this utility function:
"address.uv=clamp,filter.min=nearest,filter.mag=nearest,lod.bias=2.5"
);
auto mySampler = myRenderer->CreateSampler(mySamplerDescUtil);

◆ AsStencilDesc()

StencilDescriptor LLGL::ParseContext::AsStencilDesc ( ) const

Generates a stencil descriptor from this parse context.

◆ AsStencilFaceDesc()

StencilFaceDescriptor LLGL::ParseContext::AsStencilFaceDesc ( ) const

Generates a stencil-face descriptor from this parse context.

Remarks
The syntax for this conversion is as follows:

◆ AsTextureSwizzleRGBA()

TextureSwizzleRGBA LLGL::ParseContext::AsTextureSwizzleRGBA ( ) const

Generates a texture swizzle descriptor from this parse context.

Remarks
This conversion always requires 4 characters from the parse string and the characters are interpreted as follows:

◆ AsVertexAttribute()

VertexAttribute LLGL::ParseContext::AsVertexAttribute ( ) const

Generates a basic vertex attribute descriptor from this parse context. This only includes format and identifier.

Remarks
The syntax for this conversion is as follows:
  • Attribute type translates to Format, e.g. 'rgb32float' translates to RGB32Float.
  • Followed by the name in parenthesis, e.g. '(position)'.
Format identifiers can be abbreviated as follows:
  • 'float' can be abbreviated with 'f', e.g. 'rgb32float' as 'rgb32f'.
  • 'sint' can be abbreviated with 'i', e.g. 'rgba16sint' as 'rgba16i'.
  • 'uint' can be abbreviated with 'u', e.g. 'rgba16uint' as 'rgba16u'.
A full vertex attribute might look like this "rgb32f(position)".

◆ AsVertexAttributeVector()

DynamicVector< VertexAttribute > LLGL::ParseContext::AsVertexAttributeVector ( ) const

Generates a vector of basic vertex attributes from this parse context.

Remarks
This parses a comma separated list of vertex attributes, the last comma being optional.
A full vertex attribute list might look like this "rgb32f(position),rgba8unorm(color),".
See also
AsVertexAttribute

◆ operator DepthDescriptor()

LLGL::ParseContext::operator DepthDescriptor ( ) const
inline

Implicit conversion to DepthDescriptor.

See also
AsDepthDesc

◆ operator DynamicVector< VertexAttribute >()

LLGL::ParseContext::operator DynamicVector< VertexAttribute > ( ) const
inline

◆ operator PipelineLayoutDescriptor()

LLGL::ParseContext::operator PipelineLayoutDescriptor ( ) const
inline

Implicit conversion to PipelineLayoutDescriptor.

See also
AsPipelineLayoutDesc

◆ operator SamplerDescriptor()

LLGL::ParseContext::operator SamplerDescriptor ( ) const
inline

Implicit conversion to SamplerDescriptor.

See also
AsSamplerDesc

◆ operator StencilDescriptor()

LLGL::ParseContext::operator StencilDescriptor ( ) const
inline

Implicit conversion to StencilDescriptor.

See also
AsStencilDesc

◆ operator StencilFaceDescriptor()

LLGL::ParseContext::operator StencilFaceDescriptor ( ) const
inline

Implicit conversion to StencilFaceDescriptor.

See also
AsStencilFaceDesc

◆ operator TextureSwizzleRGBA()

LLGL::ParseContext::operator TextureSwizzleRGBA ( ) const
inline

Implicit conversion to TextureSwizzleRGBA.

See also
AsTextureSwizzleRGBA

◆ operator VertexAttribute()

LLGL::ParseContext::operator VertexAttribute ( ) const
inline

Implicit conversion to VertexAttribute.

See also
AsVertexAttribute

◆ operator=() [1/2]

ParseContext & LLGL::ParseContext::operator= ( const ParseContext & )
default

◆ operator=() [2/2]

ParseContext & LLGL::ParseContext::operator= ( ParseContext && )
default

The documentation for this class was generated from the following file: