Wasabi
|
#include <WMaterial.hpp>
Public Member Functions | |
virtual std::string | GetTypeName () const override |
virtual void | SetID (uint32_t newID) override |
virtual void | SetName (std::string newName) override |
virtual WError | Bind (class WRenderTarget *rt, bool bindDescSet=true, bool bindPushConsts=true) |
VkDescriptorSet | GetDescriptorSet () const |
class WEffect * | GetEffect () const |
template<typename T > | |
WError | SetVariable (const char *varName, T value) |
template<typename T > | |
WError | SetVariableArray (const char *varName, T *arr, int numElements) |
WError | SetVariableData (const char *varName, void *data, size_t len) |
WError | SetTexture (uint32_t bindingIndex, class WImage *img, uint32_t arrayIndex=0) |
WError | SetTexture (std::string name, class WImage *img, uint32_t arrayIndex=0) |
virtual bool | Valid () const override |
virtual WError | SaveToStream (WFile *file, std::ostream &outputStream) override |
virtual WError | LoadFromStream (WFile *file, std::istream &inputStream, std::vector< void * > &args, std::string nameSuffix) override |
![]() | |
WFileAsset (class Wasabi *const app, uint32_t ID=0) | |
virtual WError | LoadFromStream (class WFile *file, std::istream &inputStream, vector< void * > &args, std::string nameSuffix)=0 |
![]() | |
WBase (class Wasabi *const app, uint32_t ID=0) | |
uint32_t | GetID () const |
std::string | GetName () const |
class Wasabi * | GetAppPtr () const |
void | AddReference () |
void | RemoveReference () |
Static Public Member Functions | |
static std::string | _GetTypeName () |
static std::vector< void * > | LoadArgs () |
Protected Member Functions | |
WMaterial (class Wasabi *const app, uint32_t ID=0) | |
WError | CreateForEffect (class WEffect *const effect, uint32_t bindingSet=0) |
Friends | |
class | WEffect |
class | WFile |
Additional Inherited Members | |
![]() | |
class Wasabi * | m_app |
uint32_t | m_ID |
std::string | m_name |
A WMaterial contains the information needed to pass shader parameters to WEffects and their shaders. Parameters include all types of variables and textures. WMaterials provide a convenient interface for setting values without having to deal with memory mapping between the host and the client (The RAM and the GPU memory). In Vulkan terms, a WMaterial is a descriptor set that is a subset of all descriptors of a WEffect. Each material may have a descriptor set containing all bound resources of a WEffect, or only a subset of them.
|
static |
Returns "Material" string.
|
virtual |
Binds the resources to the pipeline. In Vulkan terms, this binds the descriptor set associated with this material as well as the push constants.
rt | Render target to bind to its command buffer |
bindDescSet | Whether or not to bind the descriptor set |
bindPushConsts | Whether or not to bind push constants |
|
protected |
Builds the material's resources to be used for a certain effect. The material may be created for only a subset of the bound resources of the WEffect using the boundResources parameter.
effect | Effect to use |
bindingSet | Set index to use from effect |
VkDescriptorSet WMaterial::GetDescriptorSet | ( | ) | const |
Retrieves the Vulkan descriptor set created by this material.
class WEffect* WMaterial::GetEffect | ( | ) | const |
|
overridevirtual |
This function must be implemented by a child class. This is used for debugging, in which a class should return its name.
Implements WBase.
|
overridevirtual |
|
overridevirtual |
Sets a texture in the bound effect.
name | Name of the texture to bind to |
img | The image to set the texture to, can be nullptr |
arrayIndex | Index into the texture array (if its an array) |
Sets a texture in the bound effect.
bindingIndex | The binding index of the texture |
img | The image to set the texture to, can be nullptr |
arrayIndex | Index into the texture array (if its an array) |
|
inline |
Sets a variable in one of the bound effect's shaders whose name is varName and whose type is T. If multiple variables have the same name, they will all be set.
varName | Name of the variable to set |
value | Value to set |
|
inline |
Sets a variable in one of the bound effect's shaders whose name is varName and whose type is an array of T. If multiple variables have the same name, they will all be set.
varName | Name of the variable to set |
arr | Address of the array to set |
numElements | Number of elements in arr |
WError WMaterial::SetVariableData | ( | const char * | varName, |
void * | data, | ||
size_t | len | ||
) |
Sets a variable in one of the bound effect's shaders whose name is varName and whose type can be anything. The set variable's size must match the len parameter for successful setting. If multiple variables have the same name, they will all be set. If the target variable is a structure, make sure to properly pad the members as specified by the Vulkan specs. If the target variable is an array of structures, you should also make sure that the structure is padded at the end of it. Refer to: https://www.khronos.org/registry/vulkan/specs/1.0-wsi_extensions/html/vkspec.html#interfaces-resources-layout Wasabi will automatically do the padding for all the data, except when the user is explicitly setting structures data using this function.
varName | Name of the variable to set |
data | Address of the memory to set the variable's data to |
len | Length of data, in bytes |
|
overridevirtual |
Checks the validity of the material. A material is valid if it has a valid effect assigned to it.
Implements WBase.