Foray Library
rapid prototyping framework for crossplatform development of vulkan hardware ray tracing applications
|
Wraps shader code driver handle (VkShaderModule). See ShaderManager for compiling shaders dynamically. More...
#include <foray_shadermodule.hpp>
Public Member Functions | |
ShaderModule ()=default | |
~ShaderModule () | |
uint64_t | CompileFromSource (Context *context, const osi::Utf8Path &path, const ShaderCompilerConfig &config={}) |
Loads by compiling from source using the ShaderManager. | |
void | LoadFromFile (Context *context, const osi::Utf8Path &path) |
Loads from a spirv file. | |
void | LoadFromBinary (Context *context, const std::vector< uint8_t > &binaryBuffer) |
Loads from a binary buffer. | |
void | LoadFromBinary (Context *context, const std::vector< uint32_t > &binaryBuffer) |
Loads from a binary buffer. | |
template<size_t ARR_SIZE> | |
void | LoadFromBinary (Context *context, const uint8_t binaryBuffer[ARR_SIZE]) |
Loads from a binary buffer. | |
template<size_t ARR_SIZE> | |
void | LoadFromBinary (Context *context, const uint32_t binaryBuffer[ARR_SIZE]) |
Loads from a binary buffer. | |
void | LoadFromBinary (Context *context, const uint8_t *binaryBuffer, size_t sizeInBytes) |
Loads from a binary buffer. | |
void | LoadFromBinary (Context *context, const uint32_t *binaryBuffer, size_t sizeInBytes) |
Loads from a binary buffer. | |
virtual bool | Exists () const override |
Return true, if the managed resource is allocated. | |
virtual void | Destroy () override |
Destroy the resource. | |
VkPipelineShaderStageCreateInfo | GetShaderStageCi (VkShaderStageFlagBits stage, const char *entry="main") const |
Fill a shader stage create info. .sType, .stage, .module, .pName fields are set, remainder default initialized. | |
operator VkShaderModule () const | |
![]() | |
VulkanResource () | |
VulkanResource (std::string_view name) | |
virtual std::string_view | GetTypeName () const |
Returns <OBJECT_TYPE> stringified. | |
![]() | |
ManagedResource () | |
Default constructor registers the resource. | |
ManagedResource (std::string_view name) | |
Registers the resource and sets its name. | |
virtual | ~ManagedResource () |
Unregisters the resource. | |
std::string_view | GetName () const |
Return a custom name for the object. | |
virtual void | SetName (std::string_view name) |
Set a custom name for the object. | |
std::string | Print () const |
Print name and type in one string. | |
![]() | |
NoMoveDefaults ()=default | |
NoMoveDefaults (const NoMoveDefaults &other)=delete | |
NoMoveDefaults (NoMoveDefaults &&other)=default | |
NoMoveDefaults & | operator= (const NoMoveDefaults &other)=delete |
Protected Attributes | |
Context * | mContext = nullptr |
VkShaderModule | mShaderModule = nullptr |
![]() | |
std::string | mName |
This objects custom name. | |
Additional Inherited Members | |
![]() | |
static void | sPrintAllocatedResources (bool printAsWarning) |
Print a list of all registered existing resources. | |
static const std::unordered_set< ManagedResource * > * | GetTotalAllocatedResources () |
![]() | |
virtual void | SetObjectName (core::Context *context, const void *handle, std::string_view name, bool updateResourceName=true) |
Set the object name. Sets both ManagedResource::mName aswell as vulkan debug object name. | |
Wraps shader code driver handle (VkShaderModule). See ShaderManager for compiling shaders dynamically.
|
default |
|
inline |
uint64_t foray::core::ShaderModule::CompileFromSource | ( | Context * | context, |
const osi::Utf8Path & | path, | ||
const ShaderCompilerConfig & | config = {} |
||
) |
Loads by compiling from source using the ShaderManager.
context | Requires ShaderMan, DispatchTable |
path | Path of the source file (glsl or hlsl shader source) |
config | Optional struct for configuring the shader compiler |
|
overridevirtual |
Destroy the resource.
Implements foray::core::ManagedResource.
|
inlineoverridevirtual |
Return true, if the managed resource is allocated.
Example: Vulkan object stored could be nullptr or instantiated
Implements foray::core::ManagedResource.
VkPipelineShaderStageCreateInfo foray::core::ShaderModule::GetShaderStageCi | ( | VkShaderStageFlagBits | stage, |
const char * | entry = "main" |
||
) | const |
Fill a shader stage create info. .sType, .stage, .module, .pName fields are set, remainder default initialized.
|
inline |
Loads from a binary buffer.
context | Requires DispatchTable |
binaryBuffer | Binary data |
|
inline |
Loads from a binary buffer.
context | Requires DispatchTable |
binaryBuffer | Binary data |
void foray::core::ShaderModule::LoadFromBinary | ( | Context * | context, |
const uint32_t * | binaryBuffer, | ||
size_t | sizeInBytes | ||
) |
Loads from a binary buffer.
context | Requires DispatchTable |
binaryBuffer | Binary data |
sizeInBytes | Size in bytes |
|
inline |
Loads from a binary buffer.
context | Requires DispatchTable |
binaryBuffer | Binary data |
ARR_SIZE | Array size |
void foray::core::ShaderModule::LoadFromBinary | ( | Context * | context, |
const uint8_t * | binaryBuffer, | ||
size_t | sizeInBytes | ||
) |
Loads from a binary buffer.
context | Requires DispatchTable |
binaryBuffer | Binary data |
sizeInBytes | Size in bytes |
|
inline |
Loads from a binary buffer.
context | Requires DispatchTable |
binaryBuffer | Binary data |
ARR_SIZE | Array size |
void foray::core::ShaderModule::LoadFromFile | ( | Context * | context, |
const osi::Utf8Path & | path | ||
) |
Loads from a spirv file.
context | Requires DispatchTable |
path | Spirv file path (absolute or relative to current working directory) |
foray::core::ShaderModule::operator VkShaderModule | ( | ) | const |
|
protected |
|
protected |