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 AnyFX
38{
39class ShaderEffect;
40}
41
42namespace CoreGraphics
43{
44
45struct TextureId;
46struct ShaderRWBufferId;
47struct ResourceTableId;
48struct ResourceTableLayoutId;
49struct ResourcePipelineId;
50struct ResourceTableSet;
51
53ID_24_8_24_8_NAMED_TYPE(ShaderProgramId, programId, programGeneration, shaderId, shaderGeneration, program, shader); // 32 bits shader, 24 bits program, 8 bits type
54
55ID_32_TYPE(DerivativeStateId); // 32 bits derivative state (already created from an ordinary state)
56
58{
60 AnyFX::ShaderEffect* effect;
61};
62
68
87
88
91
93const ShaderId CreateShader(const ShaderCreateInfo& info);
95const ShaderId CreateShader(const GPULangShaderCreateInfo& info);
97void DestroyShader(const ShaderId id);
99void ReloadShader(const ShaderId id, const AnyFX::ShaderEffect* effect);
100
102const ShaderId ShaderGet(const Resources::ResourceName& name);
105
107const ResourceTableId ShaderCreateResourceTable(const ShaderId id, const IndexT group, const uint overallocationSize = 1, const char* name = nullptr);
109ResourceTableSet ShaderCreateResourceTableSet(const ShaderId id, const IndexT group, const uint overallocationSize = 1, const char* name = nullptr);
111const bool ShaderHasResourceTable(const ShaderId id, const IndexT group);
113const BufferId ShaderCreateConstantBuffer(const ShaderId id, const Util::StringAtom& name, BufferAccessMode mode = BufferAccessMode::HostCached);
115const BufferId ShaderCreateConstantBuffer(const ShaderId id, const IndexT cbIndex, BufferAccessMode mode = BufferAccessMode::HostCached);
117const BufferId ShaderCreateConstantBuffer(const ShaderId id, const IndexT group, const IndexT cbIndex, BufferAccessMode mode = BufferAccessMode::HostCached);
119const uint ShaderCalculateConstantBufferIndex(const uint64_t bindingMask, const IndexT slot);
120
122const Resources::ResourceName ShaderGetName(const ShaderId id);
124const SizeT ShaderGetConstantCount(const ShaderId id);
126const ShaderConstantType ShaderGetConstantType(const ShaderId id, const IndexT i);
128const ShaderConstantType ShaderGetConstantType(const ShaderId id, const Util::StringAtom& name);
130const Util::StringAtom ShaderGetConstantName(const ShaderId id, const IndexT i);
132const IndexT ShaderGetConstantBinding(const ShaderId id, const Util::StringAtom& name);
134const IndexT ShaderGetConstantBinding(const ShaderId id, const IndexT cIndex);
136const Util::StringAtom ShaderGetConstantBlockName(const ShaderId id, const Util::StringAtom& name);
138const Util::StringAtom ShaderGetConstantBlockName(const ShaderId id, const IndexT cIndex);
140const SizeT ShaderGetConstantBindingsCount(const ShaderId id);
142const IndexT ShaderGetConstantGroup(const ShaderId id, const Util::StringAtom& name);
144const IndexT ShaderGetConstantSlot(const ShaderId id, const Util::StringAtom& name);
145
150
152const SizeT ShaderGetConstantBufferCount(const ShaderId id);
154const SizeT ShaderGetConstantBufferSize(const ShaderId id, const IndexT i);
156const Util::StringAtom ShaderGetConstantBufferName(const ShaderId id, const IndexT i);
158const IndexT ShaderGetConstantBufferResourceSlot(const ShaderId id, const IndexT i);
160const IndexT ShaderGetConstantBufferResourceGroup(const ShaderId id, const IndexT i);
162const uint64_t ShaderGetConstantBufferBindingMask(const ShaderId id, const IndexT group);
164const uint64_t ShaderGetConstantBufferSize(const ShaderId id, const IndexT group, const IndexT i);
165
167const IndexT ShaderGetResourceSlot(const ShaderId id, const Util::StringAtom& name);
168
172const Util::StringAtom ShaderProgramGetName(const ShaderProgramId id);
173
175const CoreGraphics::ShaderProgramId ShaderGetProgram(const ShaderId id, const CoreGraphics::ShaderFeature::Mask mask);
176
179{
180 struct
181 {
182 bool hasGen : 1;
183 bool hasCallable : 1;
184 bool hasAnyHit : 1;
186 bool hasIntersect : 1;
187 bool hasMiss : 1;
190};
191RayTracingBits ShaderProgramGetRaytracingBits(const ShaderProgramId id);
192
193} // 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
Implements a shader effect (using AnyFX) in Vulkan.
Definition shader.h:38
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:1944
const uint ShaderCalculateConstantBufferIndex(const uint64_t bindingMask, const IndexT slot)
Calculate buffer index using binding mask and slot.
Definition vkshader.cc:1578
const Resources::ResourceName ShaderGetName(const ShaderId id)
Get name of shader.
Definition vkshader.cc:1643
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:1441
const uint64_t ShaderGetConstantBufferBindingMask(const ShaderId id, const IndexT group)
Get mask of constant buffers.
Definition vkshader.cc:1954
const Util::StringAtom ShaderGetConstantName(const ShaderId id, const IndexT i)
get name of variable by index
Definition vkshader.cc:1863
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:1889
void ReloadShader(const ShaderId id, const AnyFX::ShaderEffect *effect)
Reload shader.
Definition vkshader.cc:1349
RayTracingBits ShaderProgramGetRaytracingBits(const ShaderProgramId id)
Definition vkshaderprogram.cc:1139
BufferAccessMode
Definition buffer.h:27
@ HostCached
Definition buffer.h:30
CoreGraphics::ResourcePipelineId ShaderGetResourcePipeline(const ShaderId id)
get pipeline layout for shader
Definition vkshader.cc:1634
const SizeT ShaderGetConstantBufferCount(const ShaderId id)
get the number of constant buffers from shader
Definition vkshader.cc:1905
const Util::StringAtom ShaderGetConstantBlockName(const ShaderId id, const Util::StringAtom &name)
get name of constant buffer wherein constant with name resides
Definition vkshader.cc:1843
const IndexT ShaderGetConstantBinding(const ShaderId id, const Util::StringAtom &name)
get constant buffer binding by name
Definition vkshader.cc:1591
const SizeT ShaderGetConstantCount(const ShaderId id)
get the number of constants from shader
Definition vkshader.cc:1652
const ShaderConstantType ShaderGetConstantType(const ShaderId id, const IndexT i)
get type of variable by index
Definition vkshader.cc:1661
const ShaderId ShaderGet(const Resources::ResourceName &name)
get shader by name
Definition shader.cc:14
const SizeT ShaderGetConstantBindingsCount(const ShaderId id)
get count of constant buffer bindings (for iteration)
Definition vkshader.cc:1613
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:1495
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:1485
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:1873
const Util::StringAtom ShaderGetConstantBufferName(const ShaderId id, const IndexT i)
get name of constant buffer
Definition vkshader.cc:1924
const IndexT ShaderGetConstantBufferResourceSlot(const ShaderId id, const IndexT i)
get binding inside group of constant buffer
Definition vkshader.cc:1934
const ShaderId CreateShader(const ShaderCreateInfo &info)
Create new shader.
Definition vkshader.cc:1040
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:2007
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:1339
const Util::StringAtom ShaderProgramGetName(const ShaderProgramId id)
get name of program
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:1462
ShaderConstantType
Definition shader.h:70
@ ConstantBufferVariableType
Definition shader.h:80
@ UnknownVariableType
Definition shader.h:71
@ ImageHandleType
Definition shader.h:84
@ SamplerHandleType
Definition shader.h:85
@ BufferReadWriteVariableType
Definition shader.h:82
@ Vector2VariableType
Definition shader.h:75
@ VectorVariableType
Definition shader.h:74
@ ImageReadWriteVariableType
Definition shader.h:81
@ IntVariableType
Definition shader.h:72
@ TextureVariableType
Definition shader.h:78
@ BoolVariableType
Definition shader.h:77
@ FloatVariableType
Definition shader.h:73
@ TextureHandleType
Definition shader.h:83
@ SamplerVariableType
Definition shader.h:79
@ MatrixVariableType
Definition shader.h:76
CoreGraphics::ResourceTableLayoutId ShaderGetResourceTableLayout(const ShaderId id, const IndexT group)
get resource table layout
Definition vkshader.cc:1623
const SizeT ShaderGetConstantBufferSize(const ShaderId id, const IndexT i)
get size of constant buffer
Definition vkshader.cc:1914
const IndexT ShaderGetResourceSlot(const ShaderId id, const Util::StringAtom &name)
get slot of any shader resource
Definition vkshader.cc:1977
const Util::Dictionary< ShaderFeature::Mask, ShaderProgramId > & ShaderGetPrograms(const ShaderId id)
get programs
Definition vkshader.cc:1989
Util::StringAtom ResourceName
Definition resourceid.h:33
#define RESOURCE_ID_TYPE(type)
Definition resourceid.h:41
Definition shader.h:55
GPULang::Loader * loader
Definition shader.h:66
Resources::ResourceName name
Definition shader.h:65
Definition resourcetable.h:399
Definition resourcetable.h:25
Definition shader.h:58
AnyFX::ShaderEffect * effect
Definition shader.h:60
Resources::ResourceName name
Definition shader.h:59
Definition shader.h:52
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:179
bool hasAnyHit
Definition shader.h:184
struct CoreGraphics::RayTracingBits::@237224006073315301152310140070207114272305324306 bitField
uint bits
Definition shader.h:189
bool hasMiss
Definition shader.h:187
bool hasIntersect
Definition shader.h:186
bool hasGen
Definition shader.h:182
bool hasCallable
Definition shader.h:183
bool hasClosestHit
Definition shader.h:185