- hook up the software renderer
This commit is contained in:
parent
a3c21e0b01
commit
96547713d9
6 changed files with 95 additions and 16 deletions
|
|
@ -104,7 +104,7 @@ VulkanDescriptorSet *VkHardwareTexture::GetDescriptorSet(const FMaterialState &s
|
|||
mDescriptorSet = fb->GetRenderPassManager()->DescriptorPool->allocate(fb->GetRenderPassManager()->TextureSetLayout.get());
|
||||
|
||||
WriteDescriptors update;
|
||||
update.addCombinedImageSampler(mDescriptorSet.get(), 0, mImageView.get(), fb->GetSamplerManager()->Get(0), VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
|
||||
update.addCombinedImageSampler(mDescriptorSet.get(), 0, mImageView.get(), fb->GetSamplerManager()->Get(0), mImageLayout);
|
||||
update.updateSets(fb->device);
|
||||
}
|
||||
|
||||
|
|
@ -207,6 +207,44 @@ int VkHardwareTexture::GetMipLevels(int w, int h)
|
|||
return levels;
|
||||
}
|
||||
|
||||
void VkHardwareTexture::AllocateBuffer(int w, int h, int texelsize)
|
||||
{
|
||||
if (!mImage)
|
||||
{
|
||||
auto fb = GetVulkanFrameBuffer();
|
||||
|
||||
ImageBuilder imgbuilder;
|
||||
imgbuilder.setFormat(VK_FORMAT_B8G8R8A8_UNORM);
|
||||
imgbuilder.setSize(w, h);
|
||||
imgbuilder.setUsage(VK_IMAGE_USAGE_SAMPLED_BIT, VMA_MEMORY_USAGE_CPU_TO_GPU);
|
||||
imgbuilder.setLinearTiling();
|
||||
mImage = imgbuilder.create(fb->device);
|
||||
mImageLayout = VK_IMAGE_LAYOUT_GENERAL;
|
||||
mTexelsize = texelsize;
|
||||
|
||||
ImageViewBuilder viewbuilder;
|
||||
viewbuilder.setImage(mImage.get(), texelsize == 4 ? VK_FORMAT_B8G8R8A8_UNORM : VK_FORMAT_R8_UNORM);
|
||||
mImageView = viewbuilder.create(fb->device);
|
||||
|
||||
auto cmdbuffer = fb->GetUploadCommands();
|
||||
|
||||
PipelineBarrier imageTransition;
|
||||
imageTransition.addImage(mImage.get(), VK_IMAGE_LAYOUT_UNDEFINED, mImageLayout, 0, VK_ACCESS_SHADER_READ_BIT);
|
||||
imageTransition.execute(cmdbuffer, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT);
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t *VkHardwareTexture::MapBuffer()
|
||||
{
|
||||
return (uint8_t*)mImage->Map(0, mImage->width * mImage->height * mTexelsize);
|
||||
}
|
||||
|
||||
unsigned int VkHardwareTexture::CreateTexture(unsigned char * buffer, int w, int h, int texunit, bool mipmap, int translation, const char *name)
|
||||
{
|
||||
mImage->Unmap();
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
||||
//===========================================================================
|
||||
|
|
|
|||
|
|
@ -28,9 +28,9 @@ public:
|
|||
VulkanDescriptorSet *GetDescriptorSet(const FMaterialState &state);
|
||||
|
||||
// Software renderer stuff
|
||||
void AllocateBuffer(int w, int h, int texelsize) override { }
|
||||
uint8_t *MapBuffer() override { return nullptr; }
|
||||
unsigned int CreateTexture(unsigned char * buffer, int w, int h, int texunit, bool mipmap, int translation, const char *name) override { return 0; }
|
||||
void AllocateBuffer(int w, int h, int texelsize) override;
|
||||
uint8_t *MapBuffer() override;
|
||||
unsigned int CreateTexture(unsigned char * buffer, int w, int h, int texunit, bool mipmap, int translation, const char *name) override;
|
||||
|
||||
private:
|
||||
void CreateTexture(int w, int h, int pixelsize, VkFormat format, const void *pixels);
|
||||
|
|
@ -41,6 +41,8 @@ private:
|
|||
std::unique_ptr<VulkanImage> mImage;
|
||||
std::unique_ptr<VulkanImageView> mImageView;
|
||||
std::unique_ptr<VulkanBuffer> mStagingBuffer;
|
||||
VkImageLayout mImageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
|
||||
int mTexelsize = 4;
|
||||
};
|
||||
|
||||
#if 0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue