MCPcopy Create free account
hub / github.com/DiligentGraphics/DiligentFX / DefineMacros

Method DefineMacros

PBR/src/PBR_Renderer.cpp:1095–1329  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1093}
1094
1095ShaderMacroHelper PBR_Renderer::DefineMacros(const PSOKey& Key) const
1096{
1097 const PSO_FLAGS PSOFlags = Key.GetFlags();
1098
1099 ShaderMacroHelper Macros;
1100 Macros.Add("MAX_JOINT_COUNT", static_cast<int>(m_Settings.MaxJointCount));
1101 Macros.Add("TONE_MAPPING_MODE", "TONE_MAPPING_MODE_UNCHARTED2");
1102
1103 Macros.Add("PRIMITIVE_ARRAY_SIZE", static_cast<int>(m_Settings.PrimitiveArraySize));
1104 if (m_Settings.PrimitiveArraySize > 0)
1105 {
1106 const char* PrimitiveID = nullptr;
1107 if (m_Device.GetDeviceInfo().Features.NativeMultiDraw)
1108 {
1109 if (m_Device.GetDeviceInfo().IsGLDevice())
1110 {
1111#if PLATFORM_EMSCRIPTEN
1112 PrimitiveID = "gl_DrawID";
1113#else
1114 PrimitiveID = "gl_DrawIDARB";
1115#endif
1116 }
1117 else if (m_Device.GetDeviceInfo().IsVulkanDevice())
1118 {
1119#ifdef HLSL2GLSL_CONVERTER_SUPPORTED
1120 PrimitiveID = "gl_DrawID";
1121#else
1122 UNSUPPORTED("Primitive ID on Vulkan requires HLSL2GLSL converter");
1123 PrimitiveID = "0";
1124#endif
1125 }
1126 else
1127 {
1128 UNEXPECTED("Native multi-draw is only expected in GL and Vulkan");
1129 PrimitiveID = "0";
1130 }
1131 }
1132 else
1133 {
1134 // Use instance ID as primitive ID
1135 PrimitiveID = "int(VSIn.InstanceID)";
1136 }
1137 Macros.Add("PRIMITIVE_ID", PrimitiveID);
1138 }
1139
1140 Macros.Add("PBR_WORKFLOW_METALLIC_ROUGHNESS", static_cast<int>(PBR_WORKFLOW_METALL_ROUGH));
1141 Macros.Add("PBR_WORKFLOW_SPECULAR_GLOSINESS", static_cast<int>(PBR_WORKFLOW_SPEC_GLOSS));
1142 Macros.Add("PBR_WORKFLOW_UNLIT", static_cast<int>(PBR_WORKFLOW_UNLIT));
1143
1144 Macros.Add("PBR_ALPHA_MODE_OPAQUE", static_cast<int>(ALPHA_MODE_OPAQUE));
1145 Macros.Add("PBR_ALPHA_MODE_MASK", static_cast<int>(ALPHA_MODE_MASK));
1146 Macros.Add("PBR_ALPHA_MODE_BLEND", static_cast<int>(ALPHA_MODE_BLEND));
1147 Macros.Add("PBR_ALPHA_MODE", static_cast<int>(Key.GetAlphaMode()));
1148
1149 Macros.Add("PBR_MAX_LIGHTS", (PSOFlags & PSO_FLAG_USE_LIGHTS) != 0 ? static_cast<int>(m_Settings.MaxLightCount) : 0);
1150 Macros.Add("PBR_LIGHT_TYPE_DIRECTIONAL", static_cast<int>(LIGHT_TYPE_DIRECTIONAL));
1151 Macros.Add("PBR_LIGHT_TYPE_POINT", static_cast<int>(LIGHT_TYPE_POINT));
1152 Macros.Add("PBR_LIGHT_TYPE_SPOT", static_cast<int>(LIGHT_TYPE_SPOT));

Callers

nothing calls this directly

Calls 7

GetTextureAttribIdStringFunction · 0.85
GetTextureAttribStringFunction · 0.85
GetTextureIdStringFunction · 0.85
GetFlagsMethod · 0.80
GetAlphaModeMethod · 0.80
GetLoadingAnimationMethod · 0.80
GetDebugViewMethod · 0.45

Tested by

no test coverage detected