NAP
shaderconstant.h
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2  * License, v. 2.0. If a copy of the MPL was not distributed with this
3  * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 
5 #pragma once
6 
7 // Local includes
8 #include "shaderconstantdeclaration.h"
9 
10 // External Includes
11 #include <nap/resource.h>
12 #include <nap/numeric.h>
13 #include <utility/dllexport.h>
14 
15 
16 namespace nap
17 {
18  // Shader constant instance
20  {
21  std::vector<VkSpecializationMapEntry> mEntries;
22  std::vector<uint> mData;
23  };
24 
56  class NAPAPI ShaderConstant : public Resource
57  {
58  RTTI_ENABLE(Resource)
59  public:
60  std::string mName;
61  uint mValue = 0;
62  };
63 
64 
97  {
98  public:
99  // Constructor
100  ShaderConstantInstance(const ShaderConstantDeclaration& declaration, const ShaderConstant* constant) :
101  mDeclaration(declaration), mConstant(constant), mValue((constant != nullptr) ? constant->mValue : declaration.mValue) {}
102 
106  const ShaderConstantDeclaration& getDeclaration() const { return mDeclaration; }
107 
111  const uint getValue() const { return mValue; }
112 
114  const ShaderConstant* mConstant = nullptr;
115  uint mValue = 0;
116  };
117 }
nap::uint
unsigned int uint
Definition: numeric.h:23
nap::ShaderConstantInstance::getValue
const uint getValue() const
Definition: shaderconstant.h:111
nap::ShaderSpecializationConstantInfo::mEntries
std::vector< VkSpecializationMapEntry > mEntries
Definition: shaderconstant.h:21
nap::ShaderConstantInstance::mDeclaration
const ShaderConstantDeclaration & mDeclaration
Definition: shaderconstant.h:113
nap::ShaderConstantDeclaration
Definition: shaderconstantdeclaration.h:30
nap::ShaderSpecializationConstantInfo::mData
std::vector< uint > mData
Definition: shaderconstant.h:22
nap::ShaderConstantInstance::ShaderConstantInstance
ShaderConstantInstance(const ShaderConstantDeclaration &declaration, const ShaderConstant *constant)
Definition: shaderconstant.h:100
nap::ShaderConstant::mName
std::string mName
Property: 'Name' The name of the specialization constant variable in the shader interface.
Definition: shaderconstant.h:60
nap::ShaderSpecializationConstantInfo
Definition: shaderconstant.h:19
nap::ShaderConstantInstance
Definition: shaderconstant.h:96
nap::ShaderConstant
Definition: shaderconstant.h:56
nap
Definition: templateapp.h:17
nap::Resource
Definition: resource.h:19
nap::ShaderConstantInstance::getDeclaration
const ShaderConstantDeclaration & getDeclaration() const
Definition: shaderconstant.h:106