Nameless Engine
Loading...
Searching...
No Matches
ne::ShaderMacroConfigurations Struct Reference

#include <ShaderMacro.h>

Static Public Member Functions

static unsigned long long convertConfigurationToHash (const std::set< ShaderMacro > &configuration)
 
static std::string convertConfigurationToText (const std::set< ShaderMacro > &configuration)
 
static bool isMacroShouldBeConsideredInConfiguration (ShaderMacro macro, const std::set< ShaderMacro > &configuration)
 

Static Public Attributes

static const std::set< std::set< ShaderMacro > > validVertexShaderMacroConfigurations
 
static const std::set< std::set< ShaderMacro > > validPixelShaderMacroConfigurations
 
static const std::set< std::set< ShaderMacro > > validComputeShaderMacroConfigurations = {{}}
 

Static Private Member Functions

static std::set< std::set< ShaderMacro > > combineConfigurations (const std::set< std::set< ShaderMacro > > &constantSets, const std::set< std::set< ShaderMacro > > &macroSets, const std::set< ShaderMacro > &appendToEachSet, bool bIncludeEmptyConfiguration)
 
static std::set< std::set< ShaderMacro > > duplicateAndAppendConfiguration (const std::set< std::set< ShaderMacro > > &toDuplicateSets, const std::set< ShaderMacro > &toAppendToDuplicated)
 

Static Private Attributes

static const std::unordered_map< ShaderMacro, ShaderMacro > dependentMacros = {}
 

Detailed Description

Defines valid shader macro combinations (configurations), plus some helper functions.

Member Function Documentation

◆ combineConfigurations()

std::set< std::set< ShaderMacro > > ne::ShaderMacroConfigurations::combineConfigurations ( const std::set< std::set< ShaderMacro > > &  constantSets,
const std::set< std::set< ShaderMacro > > &  macroSets,
const std::set< ShaderMacro > &  appendToEachSet,
bool  bIncludeEmptyConfiguration 
)
staticprivate

Combines the specified macro sets with macros to append.

Example:

// The following code:
{
{NORMAL_TEXTURE}
},
{
{DIFFUSE_TEXTURE},
{FOO}
},
{
TEXTURE_FILTERING_POINT,
TEXTURE_FILTERING_LINEAR,
TEXTURE_FILTERING_ANISOTROPIC
},
true);
// Produces the following sets:
// 1. {} - empty set
// 2. {TEXTURE_FILTERING_POINT, DIFFUSE_TEXTURE}
// 3. {TEXTURE_FILTERING_POINT, FOO}
// 4. {TEXTURE_FILTERING_LINEAR, DIFFUSE_TEXTURE}
// 5. {TEXTURE_FILTERING_LINEAR, FOO}
// 5. {TEXTURE_FILTERING_ANISOTROPIC, DIFFUSE_TEXTURE}
// 6. {TEXTURE_FILTERING_ANISOTROPIC, FOO}
// 7. {NORMAL_TEXTURE}
static std::set< std::set< ShaderMacro > > combineConfigurations(const std::set< std::set< ShaderMacro > > &constantSets, const std::set< std::set< ShaderMacro > > &macroSets, const std::set< ShaderMacro > &appendToEachSet, bool bIncludeEmptyConfiguration)
Definition: ShaderMacro.cpp:41
Parameters
constantSetsSets that will be in the resulting set.
macroSetsSets to append macros to.
appendToEachSetEach macro from this set will be added to each set of the second argument.
bIncludeEmptyConfigurationWhether to add empty configuration to resulting sets or not.
Returns
Resulting sets (modified macroSets argument).

◆ convertConfigurationToHash()

unsigned long long ne::ShaderMacroConfigurations::convertConfigurationToHash ( const std::set< ShaderMacro > &  configuration)
static

Converts configuration to hash.

Parameters
configurationUsed shader configuration.
Returns
Configuration in hash form.

◆ convertConfigurationToText()

std::string ne::ShaderMacroConfigurations::convertConfigurationToText ( const std::set< ShaderMacro > &  configuration)
static

Converts configuration to text.

Parameters
configurationUsed shader configuration.
Returns
Configuration in text form. Usually looks like this: "1838281907459330133" (hash of the specified configuration).

◆ duplicateAndAppendConfiguration()

std::set< std::set< ShaderMacro > > ne::ShaderMacroConfigurations::duplicateAndAppendConfiguration ( const std::set< std::set< ShaderMacro > > &  toDuplicateSets,
const std::set< ShaderMacro > &  toAppendToDuplicated 
)
staticprivate

Takes an array of shader configurations, duplicates it and appends additional macros to the duplicated set.

Parameters
toDuplicateSetsOriginal sets to duplicate.
toAppendToDuplicatedMacros to add to each set of the duplicated sets.
Returns
Two sets: the original sets and the original sets with the specified macros appended to each set.

◆ isMacroShouldBeConsideredInConfiguration()

bool ne::ShaderMacroConfigurations::isMacroShouldBeConsideredInConfiguration ( ShaderMacro  macro,
const std::set< ShaderMacro > &  configuration 
)
static

Tells if the specified macro is valid (should be considered) in the specified configuration. Some macros depend on other which creates a situation where some macros should not be considered.

Parameters
macroMacro to test.
configurationConfiguration that the specified macro is going to be used.
Returns
true if the specified macro should be used in the specified configuration, false if some dependent macro does not exist in the specified configuration and thus makes the use of the specified macro useless.

Member Data Documentation

◆ dependentMacros

const std::unordered_map<ShaderMacro, ShaderMacro> ne::ShaderMacroConfigurations::dependentMacros = {}
inlinestaticprivate

Defines dependent macros that should be considered only when a specific macro is defined. Stores pairs of "dependent macro" - "macro it depends on".

Example:

{TEXTURE_FILTERING_POINT, USE_DIFFUSE_TEXTURE},
{TEXTURE_FILTERING_LINEAR, USE_DIFFUSE_TEXTURE}, // texture filtering depends on texture
{TEXTURE_FILTERING_ANISOTROPIC, USE_DIFFUSE_TEXTURE}
};
static const std::unordered_map< ShaderMacro, ShaderMacro > dependentMacros
Definition: ShaderMacro.h:135

◆ validComputeShaderMacroConfigurations

const std::set<std::set<ShaderMacro> > ne::ShaderMacroConfigurations::validComputeShaderMacroConfigurations = {{}}
inlinestatic

Valid combinations of compute shader macros.

◆ validPixelShaderMacroConfigurations

const std::set<std::set<ShaderMacro> > ne::ShaderMacroConfigurations::validPixelShaderMacroConfigurations
inlinestatic
Initial value:
=
{{ShaderMacro::FS_USE_DIFFUSE_TEXTURE},
{ShaderMacro::FS_USE_MATERIAL_TRANSPARENCY},
{ShaderMacro::FS_USE_DIFFUSE_TEXTURE, ShaderMacro::FS_USE_MATERIAL_TRANSPARENCY}},
{},
{},
true)

Valid combinations of pixel shader macros.

Remarks
Also consider dependentMacros.

◆ validVertexShaderMacroConfigurations

const std::set<std::set<ShaderMacro> > ne::ShaderMacroConfigurations::validVertexShaderMacroConfigurations
inlinestatic
Initial value:
= {
{}, {ShaderMacro::VS_SHADOW_MAPPING_PASS}}

Valid combinations of vertex shader macros.

Remarks
Also consider dependentMacros.

The documentation for this struct was generated from the following files: