Add VulkanTextureDynamic
This commit is contained in:
@@ -25,6 +25,5 @@ namespace OpenVulkano::Scene
|
||||
resolution = {width, height, 1};
|
||||
size = sizeof(Math::Vector4uc) * width * height;
|
||||
format = DataFormat::B8G8R8A8_UNORM;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -145,7 +145,6 @@ namespace OpenVulkano::Vulkan
|
||||
|
||||
void ResourceManager::PrepareMaterial(Scene::Material* material)
|
||||
{
|
||||
const std::unique_lock lock(mutex);
|
||||
if (material->texture && !material->texture->renderTexture)
|
||||
{
|
||||
PrepareTexture(material->texture);
|
||||
@@ -378,7 +377,13 @@ namespace OpenVulkano::Vulkan
|
||||
|
||||
VulkanTexture* ResourceManager::PrepareTexture(Scene::Texture* texture)
|
||||
{
|
||||
VulkanTexture* vkTexture = new VulkanTexture();
|
||||
const std::unique_lock lock(mutex);
|
||||
if (texture->renderTexture) return static_cast<VulkanTexture*>(texture->renderTexture);
|
||||
VulkanTexture* vkTexture;
|
||||
if (texture->updateFrequency == Scene::UpdateFrequency::Never)
|
||||
vkTexture = new VulkanTexture();
|
||||
else
|
||||
vkTexture = new VulkanTextureDynamic();
|
||||
|
||||
vkTexture->Init(this, texture, GetDescriptorLayoutSet(Scene::Texture::DESCRIPTOR_SET_LAYOUT_BINDING), Scene::Texture::DESCRIPTOR_SET_LAYOUT_BINDING);
|
||||
|
||||
|
||||
@@ -71,34 +71,38 @@ namespace OpenVulkano::Vulkan
|
||||
}
|
||||
}
|
||||
|
||||
void Record(VulkanDrawContext* context, int setId)
|
||||
virtual void Record(VulkanDrawContext* context, int setId)
|
||||
{
|
||||
context->commandBuffer.bindDescriptorSets(vk::PipelineBindPoint::eGraphics, context->GetShader()->pipelineLayout, setId, 1, &m_descriptorSet, 0, nullptr);
|
||||
}
|
||||
};
|
||||
|
||||
/*class VulkanTextureDynamic : VulkanTexture
|
||||
class VulkanTextureDynamic : public VulkanTexture
|
||||
{
|
||||
public:
|
||||
uint32_t lastUpdate = -1;
|
||||
ResourceManager* resourceManager;
|
||||
|
||||
void Init(ResourceManager* resManager, Scene::Texture* texture) override
|
||||
void Init(ResourceManager* resManager, Scene::Texture* texture, vk::DescriptorSetLayout* descriptorSetLayout, const DescriptorSetLayoutBinding& binding) override
|
||||
{
|
||||
resourceManager = resManager;
|
||||
VulkanTexture::Init(resourceManager, texture);
|
||||
lastUpdate = -1;
|
||||
VulkanTexture::Init(resManager, texture, descriptorSetLayout, binding);
|
||||
}
|
||||
|
||||
void Record(VulkanDrawContext* context) override
|
||||
{
|
||||
if(bufferId != lastUpdate && m_texture->updated)
|
||||
if(m_texture->updated)
|
||||
{
|
||||
lastUpdate = bufferId;
|
||||
resourceManager->CopyDataToImage(m_texture->size, m_texture->textureBuffer, this);
|
||||
context->renderer->GetResourceManager().CopyDataToImage(m_texture->size, m_texture->textureBuffer, this);
|
||||
m_texture->updated = false;
|
||||
}
|
||||
VulkanTexture::Record(cmdBuffer, bufferId);
|
||||
VulkanTexture::Record(context);
|
||||
}
|
||||
};*/
|
||||
|
||||
void Record(VulkanDrawContext* context, int setId) override
|
||||
{
|
||||
if(m_texture->updated)
|
||||
{
|
||||
context->renderer->GetResourceManager().CopyDataToImage(m_texture->size, m_texture->textureBuffer, this);
|
||||
m_texture->updated = false;
|
||||
}
|
||||
VulkanTexture::Record(context, setId);
|
||||
}
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user