Nebula
Loading...
Searching...
No Matches
shader.h
Go to the documentation of this file.
1#pragma once
2//------------------------------------------------------------------------------
27//------------------------------------------------------------------------------
28#include "ids/id.h"
29#include "ids/idpool.h"
32#include "coregraphics/buffer.h"
33#include "util/variant.h"
34#include "util/dictionary.h"
35#include "api/loader.h"
36
37namespace CoreGraphics
38{
39
40struct TextureId;
41struct ShaderRWBufferId;
42struct ResourceTableId;
45struct ResourceTableSet;
46
48ID_24_8_24_8_NAMED_TYPE(ShaderProgramId, programId, programGeneration, shaderId, shaderGeneration, program, shader); // 32 bits shader, 24 bits program, 8 bits type
49
50ID_32_TYPE(DerivativeStateId); // 32 bits derivative state (already created from an ordinary state)
51
57
76
77
80
82const ShaderId CreateShader(const GPULangShaderCreateInfo& info);
84void DestroyShader(const ShaderId id);
85
86#if WITH_NEBULA_EDITOR
87bool ReloadShader(const ShaderId id, const GPULangShaderCreateInfo& info);
88#endif
89
91const ShaderId ShaderGet(const Resources::ResourceName& name);
94
96const ResourceTableId ShaderCreateResourceTable(const ShaderId id, const IndexT group, const uint overallocationSize = 1, const char* name = nullptr);
98ResourceTableSet ShaderCreateResourceTableSet(const ShaderId id, const IndexT group, const uint overallocationSize = 1, const char* name = nullptr);
100const bool ShaderHasResourceTable(const ShaderId id, const IndexT group);
102const BufferId ShaderCreateConstantBuffer(const ShaderId id, const Util::StringAtom& name, BufferAccessMode mode = BufferAccessMode::HostCached);
104const BufferId ShaderCreateConstantBuffer(const ShaderId id, const IndexT cbIndex, BufferAccessMode mode = BufferAccessMode::HostCached);
106const BufferId ShaderCreateConstantBuffer(const ShaderId id, const IndexT group, const IndexT cbIndex, BufferAccessMode mode = BufferAccessMode::HostCached);
108const uint ShaderCalculateConstantBufferIndex(const uint64_t bindingMask, const IndexT slot);
109
111const Resources::ResourceName ShaderGetName(const ShaderId id);
113const SizeT ShaderGetConstantCount(const ShaderId id);
115const ShaderConstantType ShaderGetConstantType(const ShaderId id, const IndexT i);
117const ShaderConstantType ShaderGetConstantType(const ShaderId id, const Util::StringAtom& name);
119const Util::StringAtom ShaderGetConstantName(const ShaderId id, const IndexT i);
121const Util::StringAtom ShaderGetConstantBlockName(const ShaderId id, const Util::StringAtom& name);
123const Util::StringAtom ShaderGetConstantBlockName(const ShaderId id, const IndexT cIndex);
125const IndexT ShaderGetConstantGroup(const ShaderId id, const Util::StringAtom& name);
127const IndexT ShaderGetConstantSlot(const ShaderId id, const Util::StringAtom& name);
128
133
135const SizeT ShaderGetConstantBufferCount(const ShaderId id);
137const SizeT ShaderGetConstantBufferSize(const ShaderId id, const IndexT i);
139const Util::StringAtom ShaderGetConstantBufferName(const ShaderId id, const IndexT i);
141const IndexT ShaderGetConstantBufferResourceSlot(const ShaderId id, const IndexT i);
143const IndexT ShaderGetConstantBufferResourceGroup(const ShaderId id, const IndexT i);
145const uint64_t ShaderGetConstantBufferBindingMask(const ShaderId id, const IndexT group);
147const uint64_t ShaderGetConstantBufferSize(const ShaderId id, const IndexT group, const IndexT i);
148
150const IndexT ShaderGetResourceSlot(const ShaderId id, const Util::StringAtom& name);
151
155const Util::String& ShaderProgramGetName(const ShaderProgramId id);
156
158const CoreGraphics::ShaderProgramId ShaderGetProgram(const ShaderId id, const CoreGraphics::ShaderFeature::Mask mask);
159
162{
163 struct
164 {
165 bool hasGen : 1;
166 bool hasCallable : 1;
167 bool hasAnyHit : 1;
169 bool hasIntersect : 1;
170 bool hasMiss : 1;
173};
174RayTracingBits ShaderProgramGetRaytracingBits(const ShaderProgramId id);
175
176} // namespace CoreGraphics
uint Mask
a shader feature bit mask
Definition shaderfeature.h:31
A collection of key/value pairs with quick value retrieval by key at roughly O(log n).
Definition dictionary.h:35
A StringAtom.
Definition stringatom.h:22
Nebula's universal string class.
Definition string.h:50
#define ID_32_TYPE(x)
Definition id.h:16
#define ID_24_8_24_8_NAMED_TYPE(x, id24_0_name, id8_0_name, id24_1_name, id8_1_name, combined0_name, combined1_name)
Definition id.h:73
Acceleration structures are used to enable ray tracing on the GPU by dividing the scene into a BVH.
Definition accelerationstructure.h:24
const IndexT ShaderGetConstantBufferResourceGroup(const ShaderId id, const IndexT i)
get group of constant buffer
Definition vkshader.cc:1254
const uint ShaderCalculateConstantBufferIndex(const uint64_t bindingMask, const IndexT slot)
Calculate buffer index using binding mask and slot.
Definition vkshader.cc:1084
const Resources::ResourceName ShaderGetName(const ShaderId id)
Get name of shader.
Definition vkshader.cc:1117
const ResourceTableId ShaderCreateResourceTable(const ShaderId id, const IndexT group, const uint overallocationSize=1, const char *name=nullptr)
create resource table from shader
Definition vkshader.cc:947
const uint64_t ShaderGetConstantBufferBindingMask(const ShaderId id, const IndexT group)
Get mask of constant buffers.
Definition vkshader.cc:1264
const Util::StringAtom ShaderGetConstantName(const ShaderId id, const IndexT i)
get name of variable by index
Definition vkshader.cc:1173
const IndexT ShaderGetConstantSlot(const ShaderId id, const Util::StringAtom &name)
get binding inside group of the constant buffer the constant lies in
Definition vkshader.cc:1199
RayTracingBits ShaderProgramGetRaytracingBits(const ShaderProgramId id)
Definition vkshaderprogram.cc:788
BufferAccessMode
Definition buffer.h:27
@ HostCached
Definition buffer.h:30
CoreGraphics::ResourcePipelineId ShaderGetResourcePipeline(const ShaderId id)
get pipeline layout for shader
Definition vkshader.cc:1108
const SizeT ShaderGetConstantBufferCount(const ShaderId id)
get the number of constant buffers from shader
Definition vkshader.cc:1215
const Util::StringAtom ShaderGetConstantBlockName(const ShaderId id, const Util::StringAtom &name)
get name of constant buffer wherein constant with name resides
Definition vkshader.cc:1153
const SizeT ShaderGetConstantCount(const ShaderId id)
get the number of constants from shader
Definition vkshader.cc:1126
const ShaderConstantType ShaderGetConstantType(const ShaderId id, const IndexT i)
get type of variable by index
Definition vkshader.cc:1135
const ShaderId ShaderGet(const Resources::ResourceName &name)
get shader by name
Definition shader.cc:14
const BufferId ShaderCreateConstantBuffer(const ShaderId id, const Util::StringAtom &name, BufferAccessMode mode=BufferAccessMode::HostCached)
create constant buffer from shader using name (don't use too frequently)
Definition vkshader.cc:1001
const bool ShaderHasResourceTable(const ShaderId id, const IndexT group)
Returns true if there is a resource table for the given group in the shader.
Definition vkshader.cc:991
const IndexT ShaderGetConstantGroup(const ShaderId id, const Util::StringAtom &name)
get group to which constant is bound (the constant buffer which it resides in)
Definition vkshader.cc:1183
const Util::StringAtom ShaderGetConstantBufferName(const ShaderId id, const IndexT i)
get name of constant buffer
Definition vkshader.cc:1234
const IndexT ShaderGetConstantBufferResourceSlot(const ShaderId id, const IndexT i)
get binding inside group of constant buffer
Definition vkshader.cc:1244
CoreGraphics::ShaderFeature::Mask ShaderFeatureMask(const Util::String &mask)
Get shader feature mask from string.
Definition shader.cc:23
const CoreGraphics::ShaderProgramId ShaderGetProgram(const ShaderId id, const CoreGraphics::ShaderFeature::Mask mask)
get shader program id from masks, this allows us to apply a shader program directly in the future
Definition vkshader.cc:1317
const Util::String ConstantTypeToString(const ShaderConstantType &type)
Get constant type as string.
Definition shader.cc:32
void DestroyShader(const ShaderId id)
Destroy shader.
Definition vkshader.cc:843
ResourceTableSet ShaderCreateResourceTableSet(const ShaderId id, const IndexT group, const uint overallocationSize=1, const char *name=nullptr)
create resource table set from shader
Definition vkshader.cc:968
ShaderConstantType
Definition shader.h:59
@ ConstantBufferVariableType
Definition shader.h:69
@ UnknownVariableType
Definition shader.h:60
@ ImageHandleType
Definition shader.h:73
@ SamplerHandleType
Definition shader.h:74
@ BufferReadWriteVariableType
Definition shader.h:71
@ Vector2VariableType
Definition shader.h:64
@ VectorVariableType
Definition shader.h:63
@ ImageReadWriteVariableType
Definition shader.h:70
@ IntVariableType
Definition shader.h:61
@ TextureVariableType
Definition shader.h:67
@ BoolVariableType
Definition shader.h:66
@ FloatVariableType
Definition shader.h:62
@ TextureHandleType
Definition shader.h:72
@ SamplerVariableType
Definition shader.h:68
@ MatrixVariableType
Definition shader.h:65
const Util::String & ShaderProgramGetName(const ShaderProgramId id)
get name of program
Definition vkshader.cc:1308
const ShaderId CreateShader(const GPULangShaderCreateInfo &info)
Create new shader.
Definition vkshader.cc:723
CoreGraphics::ResourceTableLayoutId ShaderGetResourceTableLayout(const ShaderId id, const IndexT group)
get resource table layout
Definition vkshader.cc:1097
const SizeT ShaderGetConstantBufferSize(const ShaderId id, const IndexT i)
get size of constant buffer
Definition vkshader.cc:1224
const IndexT ShaderGetResourceSlot(const ShaderId id, const Util::StringAtom &name)
get slot of any shader resource
Definition vkshader.cc:1287
const Util::Dictionary< ShaderFeature::Mask, ShaderProgramId > & ShaderGetPrograms(const ShaderId id)
get programs
Definition vkshader.cc:1299
Util::StringAtom ResourceName
Definition resourceid.h:33
#define RESOURCE_ID_TYPE(type)
Definition resourceid.h:41
Definition shader.h:50
GPULang::Loader * loader
Definition shader.h:55
Resources::ResourceName name
Definition shader.h:54
Definition resourcetable.h:399
Definition resourcetable.h:95
Definition resourcetable.h:25
Set of buffers which creates a resource table per each buffered frame.
Definition resourcetable.h:377
Definition shader.h:47
texture type
Definition texture.h:25
int SizeT
Definition types.h:42
unsigned int uint
Definition types.h:33
int IndexT
Definition types.h:41
Get shader program raytracing bits.
Definition shader.h:162
bool hasAnyHit
Definition shader.h:167
struct CoreGraphics::RayTracingBits::@237224006073315301152310140070207114272305324306 bitField
uint bits
Definition shader.h:172
bool hasMiss
Definition shader.h:170
bool hasIntersect
Definition shader.h:169
bool hasGen
Definition shader.h:165
bool hasCallable
Definition shader.h:166
bool hasClosestHit
Definition shader.h:168