MaterialX 1.39.1
Loading...
Searching...
No Matches
GlslResourceBindingContext.h
Go to the documentation of this file.
1//
2// Copyright Contributors to the MaterialX Project
3// SPDX-License-Identifier: Apache-2.0
4//
5
6#ifndef MATERIALX_GLSLRESOURCEBINDING_H
7#define MATERIALX_GLSLRESOURCEBINDING_H
8
11
13
15
16MATERIALX_NAMESPACE_BEGIN
17
19using GlslResourceBindingContextPtr = shared_ptr<class GlslResourceBindingContext>;
20
24{
25 public:
26 GlslResourceBindingContext(size_t uniformBindingLocation, size_t samplerBindingLocation);
27
29 size_t uniformBindingLocation = 0, size_t samplerBindingLocation = 0)
30 {
31 return std::make_shared<GlslResourceBindingContext>(
32 uniformBindingLocation, samplerBindingLocation);
33 }
34
35 // Initialize the context before generation starts.
36 void initialize() override;
37
38 // Emit directives for stage
39 void emitDirectives(GenContext& context, ShaderStage& stage) override;
40
41 // Emit uniforms with binding information
42 void emitResourceBindings(GenContext& context, const VariableBlock& uniforms, ShaderStage& stage) override;
43
44 // Emit structured uniforms with binding information and align members where possible
45 void emitStructuredResourceBindings(GenContext& context, const VariableBlock& uniforms,
46 ShaderStage& stage, const std::string& structInstanceName,
47 const std::string& arraySuffix) override;
48
49 // Emit separate binding locations for sampler and uniform table
50 void enableSeparateBindingLocations(bool separateBindingLocation) { _separateBindingLocation = separateBindingLocation; };
51
52 protected:
53 // List of required extensions
54 StringSet _requiredExtensions;
55
56 // Binding location for uniform blocks
57 size_t _hwUniformBindLocation = 0;
58
59 // Initial value of uniform binding location
60 size_t _hwInitUniformBindLocation = 0;
61
62 // Binding location for sampler blocks
63 size_t _hwSamplerBindLocation = 0;
64
65 // Initial value of sampler binding location
66 size_t _hwInitSamplerBindLocation = 0;
67
68 // Separate binding locations flag
69 // Indicates whether to use a shared binding counter for samplers and uniforms or separate ones.
70 // By default a shader counter is used.
71 bool _separateBindingLocation = false;
72};
73
74MATERIALX_NAMESPACE_END
75
76#endif
shared_ptr< class GlslResourceBindingContext > GlslResourceBindingContextPtr
Shared pointer to a GlslResourceBindingContext.
Definition: GlslResourceBindingContext.h:19
Hardware shader generator base class.
std::set< string > StringSet
A set of strings.
Definition: Library.h:59
Macros for declaring imported and exported symbols.
A context class for shader generation.
Definition: GenContext.h:31
Class representing a resource binding for Glsl shader resources.
Definition: GlslResourceBindingContext.h:24
Class representing a context for resource binding for hardware resources.
Definition: HwShaderGenerator.h:374
A shader stage, containing the state and resulting source code for the stage.
Definition: ShaderStage.h:139
A block of variables in a shader stage.
Definition: ShaderStage.h:61