Texture implementation basics
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
#include "Vulkan/Image.hpp"
|
||||
#include "Vulkan/Context.hpp"
|
||||
#include "Vulkan/Resources/ResourceManager.hpp"
|
||||
#include "Vulkan/Scene/VulkanShader.hpp"
|
||||
#include "Scene/Texture.hpp"
|
||||
|
||||
namespace OpenVulkano::Vulkan
|
||||
@@ -18,22 +19,36 @@ namespace OpenVulkano::Vulkan
|
||||
{
|
||||
public:
|
||||
Scene::Texture* m_texture = nullptr;
|
||||
vk::DescriptorSet m_descriptorSet;
|
||||
uint32_t m_setId;
|
||||
|
||||
virtual void Init(ResourceManager* resManager, Scene::Texture* texture)
|
||||
virtual void Init(ResourceManager* resManager, Scene::Texture* texture, vk::DescriptorSetLayout* descriptorSetLayout, const DescriptorSetLayoutBinding& binding, uint32_t setId)
|
||||
{
|
||||
this->m_texture = texture;
|
||||
m_texture = texture;
|
||||
m_setId = setId;
|
||||
Image::Init(resManager->GetContext()->device.get(), { texture->resolution.x, texture->resolution.y, texture->resolution.z });
|
||||
resManager->CopyDataToImage(m_texture->size, m_texture->textureBuffer, this);
|
||||
texture->updated = false;
|
||||
|
||||
// Setup Descriptor set
|
||||
const vk::DescriptorSetAllocateInfo descSetAllocInfo = { ResourceManager::INSTANCE->descriptorPool, 1, descriptorSetLayout };
|
||||
m_descriptorSet = resManager->GetContext()->device->device.allocateDescriptorSets(descSetAllocInfo)[0];
|
||||
vk::DescriptorImageInfo imageInfo = { sampler, view, vk::ImageLayout::eShaderReadOnlyOptimal };
|
||||
vk::WriteDescriptorSet writeDescriptorSet = { m_descriptorSet, binding.bindingId, 0, 1 };
|
||||
writeDescriptorSet.descriptorType = static_cast<vk::DescriptorType>(binding.descriptorType);
|
||||
writeDescriptorSet.pImageInfo = &imageInfo;
|
||||
resManager->GetContext()->device->device.updateDescriptorSets(1, &writeDescriptorSet, 0, nullptr);
|
||||
|
||||
texture->renderTexture = this;
|
||||
}
|
||||
|
||||
void Record(VulkanDrawContext* context) override
|
||||
{
|
||||
//cmdBuffer.bindDescriptorSets(vk::PipelineBindPoint::eGraphics, )
|
||||
context->commandBuffer.bindDescriptorSets(vk::PipelineBindPoint::eGraphics, context->GetShader()->pipelineLayout, m_setId, 1, &m_descriptorSet, 0, nullptr);
|
||||
}
|
||||
};
|
||||
|
||||
class VulkanTextureDynamic : VulkanTexture
|
||||
/*class VulkanTextureDynamic : VulkanTexture
|
||||
{
|
||||
public:
|
||||
uint32_t lastUpdate = -1;
|
||||
@@ -48,13 +63,13 @@ namespace OpenVulkano::Vulkan
|
||||
|
||||
void Record(VulkanDrawContext* context) override
|
||||
{
|
||||
/*if(bufferId != lastUpdate && m_texture->updated)
|
||||
if(bufferId != lastUpdate && m_texture->updated)
|
||||
{
|
||||
lastUpdate = bufferId;
|
||||
resourceManager->CopyDataToImage(m_texture->size, m_texture->textureBuffer, this);
|
||||
m_texture->updated = false;
|
||||
}
|
||||
VulkanTexture::Record(cmdBuffer, bufferId);*/
|
||||
VulkanTexture::Record(cmdBuffer, bufferId);
|
||||
}
|
||||
};
|
||||
};*/
|
||||
}
|
||||
Reference in New Issue
Block a user