#include <materialinstance.h>
|
bool | initInternal (RenderService &renderService, BaseMaterial &material, BaseMaterialInstanceResource &instanceResource, utility::ErrorState &errorState) |
|
void | rebuildUBO (UniformBufferObject &ubo, UniformStructInstance *overrideStruct) |
|
void | onUniformCreated () |
|
void | onSamplerChanged (int imageStartIndex, SamplerInstance &samplerInstance) |
|
void | onBufferChanged (int storageBufferIndex, BufferBindingInstance &bindingInstance) |
|
void | updateBuffers (const DescriptorSet &descriptorSet) |
|
bool | initBuffers (BaseMaterialInstanceResource &resource, utility::ErrorState &errorState) |
|
void | updateSamplers (const DescriptorSet &descriptorSet) |
|
bool | initSamplers (BaseMaterialInstanceResource &resource, utility::ErrorState &errorState) |
|
void | addImageInfo (const Texture2D &texture2D, VkSampler sampler) |
|
BufferBindingInstance * | getOrCreateBufferInternal (const std::string &name) |
|
SamplerInstance * | getOrCreateSamplerInternal (const std::string &name) |
|
UniformStructInstance & | createUniformRootStruct (const ShaderVariableStructDeclaration &declaration, const UniformCreatedCallback &uniformCreatedCallback) |
|
BufferBindingInstance & | addBindingInstance (std::unique_ptr< BufferBindingInstance > instance) |
|
SamplerInstance & | addSamplerInstance (std::unique_ptr< SamplerInstance > instance) |
|
◆ addImageInfo()
void addImageInfo |
( |
const Texture2D & |
texture2D, |
|
|
VkSampler |
sampler |
|
) |
| |
|
protected |
◆ getMaterial() [1/2]
- Returns
- base material that this instance is overriding
◆ getMaterial() [2/2]
- Returns
- base material that this instance is overriding
◆ getOrCreateBuffer() [1/2]
T * getOrCreateBuffer |
( |
const std::string & |
name | ) |
|
Gets or creates a nap::BufferBindingInstance of type T for this material instance. This means that the buffer binding returned is only applicable to this instance. In order to change a buffer binding so that its value is shared among MaterialInstances, use getMaterial().getBinding(). This function will assert if the name of the binding does not match the type that you are trying to create.
- Parameters
-
name | the name of the buffer binding as declared in the shader. |
- Returns
- buffer binding that was found or created, nullptr if not available.
◆ getOrCreateBuffer() [2/2]
Gets or creates a buffer binding isntance for this material instance. This means that the buffer binding returned is only applicable to this instance. In order to change a buffer binding so that its value is shared among MaterialInstances, use getMaterial().getBinding().
- Parameters
-
name | the name of the buffer binding as declared in the shader. |
- Returns
- buffer binding that was found or created, nullptr if not available.
◆ getOrCreateBufferInternal()
◆ getOrCreateSampler() [1/2]
T * getOrCreateSampler |
( |
const std::string & |
name | ) |
|
Gets or creates a nap::SamplerInstance of type T for this material instance. This means that the sampler returned is only applicable to this instance. In order to change a sampler so that its value is shared among MaterialInstances, use getMaterial().findSampler(). This function will assert if the name of the sampler does not match the type that you are trying to create.
- Parameters
-
name | the name of the sampler declared in the shader. |
- Returns
- nap::SamplerInstance of type T, nullptr if not available.
◆ getOrCreateSampler() [2/2]
Gets or creates a nap::SamplerInstance for this material instance. This means that the sampler returned is only applicable to this instance. In order to change a sampler so that its value is shared among MaterialInstances, use getMaterial().findSampler(). This function will assert if the name of the uniform does not match the type that you are trying to create.
- Parameters
-
name | the name of the sampler declared in the shader. |
- Returns
- nap::SamplerInstance of type T, nullptr if not available.
◆ getOrCreateSamplerInternal()
◆ getOrCreateUniform()
Gets or creates a uniform struct (ubo) for this material instance. This means that the uniform returned is only applicable to this instance. In order to change a uniform so that its value is shared among MaterialInstances, use getMaterial().getUniform().
- Parameters
-
name | the name of the uniform struct (ubo) as declared in the shader. |
- Returns
- uniform that was found or created, nullptr if not available.
◆ initBuffers()
◆ initInternal()
◆ initSamplers()
◆ onBufferChanged()
◆ onSamplerChanged()
void onSamplerChanged |
( |
int |
imageStartIndex, |
|
|
SamplerInstance & |
samplerInstance |
|
) |
| |
|
protected |
◆ onUniformCreated()
void onUniformCreated |
( |
| ) |
|
|
protected |
◆ rebuildUBO()
◆ update()
This must be called before each draw. It will push the current uniform and sampler data into memory that is accessible for the GPU. A descriptor set will be returned that must be used in VkCmdBindDescriptorSets before the Vulkan draw call is issued.
VkDescriptorSet descriptor_set = mat_instance.update();
vkCmdBindDescriptorSets(cmd_buffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline.mLayout, 0, 1, &descriptor_set, 0, nullptr);
- Returns
- Descriptor to be used in vkCmdBindDescriptorSets.
◆ updateBuffers()
◆ updateSamplers()
◆ mDescriptorSetCache
◆ mDevice
VkDevice mDevice = nullptr |
|
protected |
◆ mMaterial
◆ mRenderService
◆ mResource
◆ mSamplerDescriptors
std::vector<VkDescriptorImageInfo> mSamplerDescriptors |
|
protected |
◆ mSamplerWriteDescriptorSets
std::vector<VkWriteDescriptorSet> mSamplerWriteDescriptorSets |
|
protected |
◆ mStorageDescriptors
std::vector<VkDescriptorBufferInfo> mStorageDescriptors |
|
protected |
◆ mStorageWriteDescriptorSets
std::vector<VkWriteDescriptorSet> mStorageWriteDescriptorSets |
|
protected |
◆ mUniformBufferObjects
◆ mUniformsCreated
bool mUniformsCreated = false |
|
protected |