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
87const ShaderId ShaderGet(const Resources::ResourceName& name);
90
92const ResourceTableId ShaderCreateResourceTable(const ShaderId id, const IndexT group, const uint overallocationSize = 1, const char* name = nullptr);
94ResourceTableSet ShaderCreateResourceTableSet(const ShaderId id, const IndexT group, const uint overallocationSize = 1, const char* name = nullptr);
96const bool ShaderHasResourceTable(const ShaderId id, const IndexT group);
98const BufferId ShaderCreateConstantBuffer(const ShaderId id, const Util::StringAtom& name, BufferAccessMode mode = BufferAccessMode::HostCached);
100const BufferId ShaderCreateConstantBuffer(const ShaderId id, const IndexT cbIndex, BufferAccessMode mode = BufferAccessMode::HostCached);
102const BufferId ShaderCreateConstantBuffer(const ShaderId id, const IndexT group, const IndexT cbIndex, BufferAccessMode mode = BufferAccessMode::HostCached);
104const uint ShaderCalculateConstantBufferIndex(const uint64_t bindingMask, const IndexT slot);
105
107const Resources::ResourceName ShaderGetName(const ShaderId id);
109const SizeT ShaderGetConstantCount(const ShaderId id);
111const ShaderConstantType ShaderGetConstantType(const ShaderId id, const IndexT i);
113const ShaderConstantType ShaderGetConstantType(const ShaderId id, const Util::StringAtom& name);
115const Util::StringAtom ShaderGetConstantName(const ShaderId id, const IndexT i);
117const Util::StringAtom ShaderGetConstantBlockName(const ShaderId id, const Util::StringAtom& name);
119const Util::StringAtom ShaderGetConstantBlockName(const ShaderId id, const IndexT cIndex);
121const IndexT ShaderGetConstantGroup(const ShaderId id, const Util::StringAtom& name);
123const IndexT ShaderGetConstantSlot(const ShaderId id, const Util::StringAtom& name);
124
129
131const SizeT ShaderGetConstantBufferCount(const ShaderId id);
133const SizeT ShaderGetConstantBufferSize(const ShaderId id, const IndexT i);
135const Util::StringAtom ShaderGetConstantBufferName(const ShaderId id, const IndexT i);
137const IndexT ShaderGetConstantBufferResourceSlot(const ShaderId id, const IndexT i);
139const IndexT ShaderGetConstantBufferResourceGroup(const ShaderId id, const IndexT i);
141const uint64_t ShaderGetConstantBufferBindingMask(const ShaderId id, const IndexT group);
143const uint64_t ShaderGetConstantBufferSize(const ShaderId id, const IndexT group, const IndexT i);
144
146const IndexT ShaderGetResourceSlot(const ShaderId id, const Util::StringAtom& name);
147
151const Util::String& ShaderProgramGetName(const ShaderProgramId id);
152
154const CoreGraphics::ShaderProgramId ShaderGetProgram(const ShaderId id, const CoreGraphics::ShaderFeature::Mask mask);
155
158{
159 struct
160 {
161 bool hasGen : 1;
162 bool hasCallable : 1;
163 bool hasAnyHit : 1;
165 bool hasIntersect : 1;
166 bool hasMiss : 1;
169};
170RayTracingBits ShaderProgramGetRaytracingBits(const ShaderProgramId id);
171
172} // 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:34
A StringAtom.
Definition stringatom.h:22
#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:1116
const uint ShaderCalculateConstantBufferIndex(const uint64_t bindingMask, const IndexT slot)
Calculate buffer index using binding mask and slot.
Definition vkshader.cc:946
const Resources::ResourceName ShaderGetName(const ShaderId id)
Get name of shader.
Definition vkshader.cc:979
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:809
const uint64_t ShaderGetConstantBufferBindingMask(const ShaderId id, const IndexT group)
Get mask of constant buffers.
Definition vkshader.cc:1126
const Util::StringAtom ShaderGetConstantName(const ShaderId id, const IndexT i)
get name of variable by index
Definition vkshader.cc:1035
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:1061
RayTracingBits ShaderProgramGetRaytracingBits(const ShaderProgramId id)
Definition vkshaderprogram.cc:772
BufferAccessMode
Definition buffer.h:27
@ HostCached
Definition buffer.h:30
CoreGraphics::ResourcePipelineId ShaderGetResourcePipeline(const ShaderId id)
get pipeline layout for shader
Definition vkshader.cc:970
const SizeT ShaderGetConstantBufferCount(const ShaderId id)
get the number of constant buffers from shader
Definition vkshader.cc:1077
const Util::StringAtom ShaderGetConstantBlockName(const ShaderId id, const Util::StringAtom &name)
get name of constant buffer wherein constant with name resides
Definition vkshader.cc:1015
const SizeT ShaderGetConstantCount(const ShaderId id)
get the number of constants from shader
Definition vkshader.cc:988
const ShaderConstantType ShaderGetConstantType(const ShaderId id, const IndexT i)
get type of variable by index
Definition vkshader.cc:997
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:863
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:853
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:1045
const Util::StringAtom ShaderGetConstantBufferName(const ShaderId id, const IndexT i)
get name of constant buffer
Definition vkshader.cc:1096
const IndexT ShaderGetConstantBufferResourceSlot(const ShaderId id, const IndexT i)
get binding inside group of constant buffer
Definition vkshader.cc:1106
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:1179
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:787
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:830
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:1170
const ShaderId CreateShader(const GPULangShaderCreateInfo &info)
Create new shader.
Definition vkshader.cc:673
CoreGraphics::ResourceTableLayoutId ShaderGetResourceTableLayout(const ShaderId id, const IndexT group)
get resource table layout
Definition vkshader.cc:959
const SizeT ShaderGetConstantBufferSize(const ShaderId id, const IndexT i)
get size of constant buffer
Definition vkshader.cc:1086
const IndexT ShaderGetResourceSlot(const ShaderId id, const Util::StringAtom &name)
get slot of any shader resource
Definition vkshader.cc:1149
const Util::Dictionary< ShaderFeature::Mask, ShaderProgramId > & ShaderGetPrograms(const ShaderId id)
get programs
Definition vkshader.cc:1161
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
Nebula's universal string class.
Definition String.cs:8
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:158
bool hasAnyHit
Definition shader.h:163
struct CoreGraphics::RayTracingBits::@237224006073315301152310140070207114272305324306 bitField
uint bits
Definition shader.h:168
bool hasMiss
Definition shader.h:166
bool hasIntersect
Definition shader.h:165
bool hasGen
Definition shader.h:161
bool hasCallable
Definition shader.h:162
bool hasClosestHit
Definition shader.h:164