Ubershader Variant Generation Without Preprocessing Macros

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

The existing methods for developing and using ubershaders require preprocessing macros, leading to inefficiencies such as the generation of numerous shader variants and large asset files, which can be inconvenient for transport and installation on end-user devices.

Innovation Solution

The proposed solution involves using option indicators in the ubershader source code to flag selectable features, allowing for the compilation of a single intermediate code that can be converted into executable code at runtime, eliminating the need for preprocessing macros and reducing the number of asset files required.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Adaptability or versatility

If preprocessing macros are used to create ubershader variants, then multiple executable code versions can be generated with different feature sets, but the number of asset files increases and storage requirements increase

Engineering Contradiction:
Improveshader variant flexibilityVSAvoidnumber of asset files
Core Design Contradiction:
Adaptability or versatilityVSQuantity of substance

Solution Approach 1:

The patent merges multiple shader variants into a single ubershader asset file by using runtime macro definition. Instead of creating separate compiled shader files for each feature combination, all variants are consolidated into one file that can dynamically generate different executable code versions at runtime based on the desired feature set.

Inventive Principle:
Principle #5Merging (Combining)

Solution Approach 2:

The patent introduces dynamic macro definition at runtime to enable flexible shader variant generation. Macros are defined programmatically during execution based on the required feature combination, allowing the system to adaptively create appropriate shader variants without pre-compiling all possible versions.

Inventive Principle:
Principle #15Dynamics

2Adaptability or versatility

If preprocessing macros are used to create ubershader variants, then multiple executable code versions can be generated, but compilation time and processing overhead increase

Engineering Contradiction:
Improveshader variant flexibilityVSAvoidcompilation time
Core Design Contradiction:
Adaptability or versatilityVSLoss of time

Solution Approach 1:

The patent performs preliminary compilation of a single ubershader asset file that contains all possible variant definitions. The macro-based variant generation is set up in advance within the single file, but actual variant instantiation is deferred to runtime when specific feature combinations are needed, avoiding repeated full compilations.

Inventive Principle:
Principle #10Preliminary action

Solution Approach 2:

The patent introduces an intermediate representation layer where the ubershader source code with macro definitions is compiled once to an intermediate form, and then runtime macro definitions serve as a mediator to generate specific executable variants from this intermediate representation, reducing compilation overhead.

Inventive Principle:
Principle #24Intermediary (Mediator)

3Adaptability or versatility

If multiple shader variants are pre-compiled, then feature selection is flexible, but asset file size and installation burden increase

Engineering Contradiction:
Improvefeature selection capabilityVSAvoidasset file size
Core Design Contradiction:
Adaptability or versatilityVSWeight of moving object

Solution Approach 1:

The patent creates a universal ubershader asset file that can serve multiple feature combination requirements through runtime macro definition. A single asset file with comprehensive macro definitions can generate any desired shader variant configuration, making the system multi-functional without requiring separate specialized files for each variant.

Inventive Principle:
Principle #6Universality (Multi-functionality)

Data Source

PatentEP3356932B1System and method for using ubershader variants without preprocessing macros
Publication Date: 2022.04.13 APPLE INC
  • EP3356932B1 patent drawingFigure 1
  • EP3356932B1 patent drawingFigure 2
  • EP3356932B1 patent drawingFigure 3

AI summary

Ubershaders may be used in a graphics development environment as an efficiency tool because many options and properties may be captured in a single shader program. Each selectable option of property in the shader code may be tagged with an attribute to indicate the presence of the selection. The single shader program embodying the many selectable options and properties may be compiled to an intermediate version that also embodies the many options and properties, along with at least remnants of the tagging attributes. Upon a request for executable code including indications of the desired selectable options or properties, generation of the executable code may proceed such that it includes only the desire selectable options and properties and not other selectable options and properties embodied in the source code.