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