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
36namespace AnyFX
37{
38class ShaderEffect;
39}
40
41namespace CoreGraphics
42{
43
44struct TextureId;
45struct ShaderRWBufferId;
46struct ResourceTableId;
47struct ResourceTableLayoutId;
48struct ResourcePipelineId;
49struct ResourceTableSet;
50
52ID_24_8_24_8_NAMED_TYPE(ShaderProgramId, programId, programGeneration, shaderId, shaderGeneration, program, shader); // 32 bits shader, 24 bits program, 8 bits type
53
54ID_32_TYPE(DerivativeStateId); // 32 bits derivative state (already created from an ordinary state)
55
57{
59 AnyFX::ShaderEffect* effect;
60};
61
80
81
84
86const ShaderId CreateShader(const ShaderCreateInfo& info);
88void DestroyShader(const ShaderId id);
90void ReloadShader(const ShaderId id, const AnyFX::ShaderEffect* effect);
91
93const ShaderId ShaderGet(const Resources::ResourceName& name);
96
98const ResourceTableId ShaderCreateResourceTable(const ShaderId id, const IndexT group, const uint overallocationSize = 1);
100ResourceTableSet ShaderCreateResourceTableSet(const ShaderId id, const IndexT group, const uint overallocationSize = 1);
102const bool ShaderHasResourceTable(const ShaderId id, const IndexT group);
104const BufferId ShaderCreateConstantBuffer(const ShaderId id, const Util::StringAtom& name, BufferAccessMode mode = BufferAccessMode::HostCached);
106const BufferId ShaderCreateConstantBuffer(const ShaderId id, const IndexT cbIndex, BufferAccessMode mode = BufferAccessMode::HostCached);
108const BufferId ShaderCreateConstantBuffer(const ShaderId id, const IndexT group, const IndexT cbIndex, BufferAccessMode mode = BufferAccessMode::HostCached);
110const uint ShaderCalculateConstantBufferIndex(const uint64 bindingMask, const IndexT slot);
111
113const Resources::ResourceName ShaderGetName(const ShaderId id);
115const SizeT ShaderGetConstantCount(const ShaderId id);
117const ShaderConstantType ShaderGetConstantType(const ShaderId id, const IndexT i);
119const ShaderConstantType ShaderGetConstantType(const ShaderId id, const Util::StringAtom& name);
121const Util::StringAtom ShaderGetConstantName(const ShaderId id, const IndexT i);
123const IndexT ShaderGetConstantBinding(const ShaderId id, const Util::StringAtom& name);
125const IndexT ShaderGetConstantBinding(const ShaderId id, const IndexT cIndex);
127const Util::StringAtom ShaderGetConstantBlockName(const ShaderId id, const Util::StringAtom& name);
129const Util::StringAtom ShaderGetConstantBlockName(const ShaderId id, const IndexT cIndex);
131const SizeT ShaderGetConstantBindingsCount(const ShaderId id);
133const IndexT ShaderGetConstantGroup(const ShaderId id, const Util::StringAtom& name);
135const IndexT ShaderGetConstantSlot(const ShaderId id, const Util::StringAtom& name);
136
141
143const SizeT ShaderGetConstantBufferCount(const ShaderId id);
145const SizeT ShaderGetConstantBufferSize(const ShaderId id, const IndexT i);
147const Util::StringAtom ShaderGetConstantBufferName(const ShaderId id, const IndexT i);
149const IndexT ShaderGetConstantBufferResourceSlot(const ShaderId id, const IndexT i);
151const IndexT ShaderGetConstantBufferResourceGroup(const ShaderId id, const IndexT i);
153const uint64 ShaderGetConstantBufferBindingMask(const ShaderId id, const IndexT group);
155const uint64 ShaderGetConstantBufferSize(const ShaderId id, const IndexT group, const IndexT i);
156
158const IndexT ShaderGetResourceSlot(const ShaderId id, const Util::StringAtom& name);
159
163const Util::StringAtom ShaderProgramGetName(const ShaderProgramId id);
164
166const CoreGraphics::ShaderProgramId ShaderGetProgram(const ShaderId id, const CoreGraphics::ShaderFeature::Mask mask);
167
170{
171 struct
172 {
173 bool hasGen : 1;
174 bool hasCallable : 1;
175 bool hasAnyHit : 1;
177 bool hasIntersect : 1;
178 bool hasMiss : 1;
181};
182RayTracingBits ShaderProgramGetRaytracingBits(const ShaderProgramId id);
183
184} // 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:37
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:1257
const uint ShaderCalculateConstantBufferIndex(const uint64 bindingMask, const IndexT slot)
Calculate buffer index using binding mask and slot.
Definition vkshader.cc:891
const Resources::ResourceName ShaderGetName(const ShaderId id)
Get name of shader.
Definition vkshader.cc:956
const Util::StringAtom ShaderGetConstantName(const ShaderId id, const IndexT i)
get name of variable by index
Definition vkshader.cc:1176
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:1202
void ReloadShader(const ShaderId id, const AnyFX::ShaderEffect *effect)
Reload shader.
Definition vkshader.cc:666
RayTracingBits ShaderProgramGetRaytracingBits(const ShaderProgramId id)
Definition vkshaderprogram.cc:509
BufferAccessMode
Definition buffer.h:27
@ HostCached
Definition buffer.h:30
CoreGraphics::ResourcePipelineId ShaderGetResourcePipeline(const ShaderId id)
get pipeline layout for shader
Definition vkshader.cc:947
const SizeT ShaderGetConstantBufferCount(const ShaderId id)
get the number of constant buffers from shader
Definition vkshader.cc:1218
const Util::StringAtom ShaderGetConstantBlockName(const ShaderId id, const Util::StringAtom &name)
get name of constant buffer wherein constant with name resides
Definition vkshader.cc:1156
const IndexT ShaderGetConstantBinding(const ShaderId id, const Util::StringAtom &name)
get constant buffer binding by name
Definition vkshader.cc:904
const SizeT ShaderGetConstantCount(const ShaderId id)
get the number of constants from shader
Definition vkshader.cc:965
const ShaderConstantType ShaderGetConstantType(const ShaderId id, const IndexT i)
get type of variable by index
Definition vkshader.cc:974
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:926
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:808
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:798
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:1186
const Util::StringAtom ShaderGetConstantBufferName(const ShaderId id, const IndexT i)
get name of constant buffer
Definition vkshader.cc:1237
ResourceTableSet ShaderCreateResourceTableSet(const ShaderId id, const IndexT group, const uint overallocationSize=1)
create resource table set from shader
Definition vkshader.cc:778
const IndexT ShaderGetConstantBufferResourceSlot(const ShaderId id, const IndexT i)
get binding inside group of constant buffer
Definition vkshader.cc:1247
const ResourceTableId ShaderCreateResourceTable(const ShaderId id, const IndexT group, const uint overallocationSize=1)
create resource table from shader
Definition vkshader.cc:758
const ShaderId CreateShader(const ShaderCreateInfo &info)
Create new shader.
Definition vkshader.cc:513
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:1320
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:656
const Util::StringAtom ShaderProgramGetName(const ShaderProgramId id)
get name of program
ShaderConstantType
Definition shader.h:63
@ ConstantBufferVariableType
Definition shader.h:73
@ UnknownVariableType
Definition shader.h:64
@ ImageHandleType
Definition shader.h:77
@ SamplerHandleType
Definition shader.h:78
@ BufferReadWriteVariableType
Definition shader.h:75
@ Vector2VariableType
Definition shader.h:68
@ VectorVariableType
Definition shader.h:67
@ ImageReadWriteVariableType
Definition shader.h:74
@ IntVariableType
Definition shader.h:65
@ TextureVariableType
Definition shader.h:71
@ BoolVariableType
Definition shader.h:70
@ FloatVariableType
Definition shader.h:66
@ TextureHandleType
Definition shader.h:76
@ SamplerVariableType
Definition shader.h:72
@ MatrixVariableType
Definition shader.h:69
CoreGraphics::ResourceTableLayoutId ShaderGetResourceTableLayout(const ShaderId id, const IndexT group)
get resource table layout
Definition vkshader.cc:936
const SizeT ShaderGetConstantBufferSize(const ShaderId id, const IndexT i)
get size of constant buffer
Definition vkshader.cc:1227
const IndexT ShaderGetResourceSlot(const ShaderId id, const Util::StringAtom &name)
get slot of any shader resource
Definition vkshader.cc:1290
const uint64 ShaderGetConstantBufferBindingMask(const ShaderId id, const IndexT group)
Get mask of constant buffers.
Definition vkshader.cc:1267
const Util::Dictionary< ShaderFeature::Mask, ShaderProgramId > & ShaderGetPrograms(const ShaderId id)
get programs
Definition vkshader.cc:1302
#define RESOURCE_ID_TYPE(type)
Definition resourceid.h:41
Definition shader.h:54
Definition resourcetable.h:402
Definition resourcetable.h:25
Definition shader.h:57
AnyFX::ShaderEffect * effect
Definition shader.h:59
Resources::ResourceName name
Definition shader.h:58
Definition shader.h:51
Nebula's universal string class.
Definition string.h:50
int SizeT
Definition types.h:49
unsigned int uint
Definition types.h:31
uint64_t uint64
Definition types.h:36
int IndexT
Definition types.h:48
Get shader program raytracing bits.
Definition shader.h:170
bool hasAnyHit
Definition shader.h:175
uint bits
Definition shader.h:180
struct CoreGraphics::RayTracingBits::@117 bitField
bool hasMiss
Definition shader.h:178
bool hasIntersect
Definition shader.h:177
bool hasGen
Definition shader.h:173
bool hasCallable
Definition shader.h:174
bool hasClosestHit
Definition shader.h:176