mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2025-01-31 04:20:34 +00:00
- implement VkPostprocess::GetOutput
This commit is contained in:
parent
40c14bcd67
commit
9d061cbef6
4 changed files with 54 additions and 23 deletions
|
@ -335,31 +335,59 @@ VulkanDescriptorSet *VkPostprocess::GetInput(VkPPRenderPassSetup *passSetup, con
|
|||
|
||||
VulkanFramebuffer *VkPostprocess::GetOutput(VkPPRenderPassSetup *passSetup, const PPOutput &output)
|
||||
{
|
||||
#if 0
|
||||
switch (output.Type)
|
||||
auto fb = GetVulkanFrameBuffer();
|
||||
|
||||
VulkanImage *image;
|
||||
VulkanImageView *view;
|
||||
VkImageLayout *layout;
|
||||
|
||||
if (output.Type == PPTextureType::CurrentPipelineTexture || output.Type == PPTextureType::NextPipelineTexture)
|
||||
{
|
||||
default:
|
||||
I_FatalError("Unsupported postprocess output type\n");
|
||||
break;
|
||||
int idx = mCurrentPipelineImage;
|
||||
if (output.Type == PPTextureType::NextPipelineTexture)
|
||||
idx = (idx + 1) % VkRenderBuffers::NumPipelineImages;
|
||||
|
||||
case PPTextureType::CurrentPipelineTexture:
|
||||
BindCurrentFB();
|
||||
break;
|
||||
|
||||
case PPTextureType::NextPipelineTexture:
|
||||
BindNextFB();
|
||||
break;
|
||||
|
||||
case PPTextureType::PPTexture:
|
||||
mTextures[step.Output.Texture]->View
|
||||
break;
|
||||
|
||||
case PPTextureType::SceneColor:
|
||||
BindSceneFB(false);
|
||||
break;
|
||||
image = fb->GetBuffers()->PipelineImage[idx].get();
|
||||
view = fb->GetBuffers()->PipelineView[idx].get();
|
||||
layout = &fb->GetBuffers()->PipelineLayout[idx];
|
||||
}
|
||||
#endif
|
||||
return nullptr;
|
||||
else if (output.Type == PPTextureType::PPTexture)
|
||||
{
|
||||
image = mTextures[output.Texture]->Image.get();
|
||||
view = mTextures[output.Texture]->View.get();
|
||||
layout = &mTextures[output.Texture]->Layout;
|
||||
}
|
||||
else if (output.Type == PPTextureType::SceneColor)
|
||||
{
|
||||
image = fb->GetBuffers()->SceneColor.get();
|
||||
view = fb->GetBuffers()->SceneColorView.get();
|
||||
layout = &fb->GetBuffers()->SceneColorLayout;
|
||||
}
|
||||
else
|
||||
{
|
||||
I_FatalError("Unsupported postprocess output type\n");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (*layout != VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)
|
||||
{
|
||||
PipelineBarrier barrier;
|
||||
barrier.addImage(image, *layout, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, VK_ACCESS_SHADER_READ_BIT, VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT);
|
||||
barrier.execute(fb->GetDrawCommands(), VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT);
|
||||
*layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
|
||||
}
|
||||
|
||||
auto &framebuffer = passSetup->Framebuffers[view];
|
||||
if (!framebuffer)
|
||||
{
|
||||
FramebufferBuilder builder;
|
||||
builder.setRenderPass(passSetup->RenderPass.get());
|
||||
builder.setSize(image->width, image->height);
|
||||
builder.addAttachment(view);
|
||||
framebuffer = builder.create(GetVulkanFrameBuffer()->device);
|
||||
}
|
||||
|
||||
return framebuffer.get();
|
||||
}
|
||||
|
||||
VulkanSampler *VkPostprocess::GetSampler(PPFilterMode filter, PPWrapMode wrap)
|
||||
|
|
|
@ -91,7 +91,7 @@ public:
|
|||
|
||||
//std::unique_ptr<VulkanDescriptorPool> DescriptorPool;
|
||||
|
||||
//std::unique_ptr<VulkanFramebuffer> Framebuffer;
|
||||
std::map<VulkanImageView *, std::unique_ptr<VulkanFramebuffer>> Framebuffers;
|
||||
//std::unique_ptr<VulkanDescriptorSet> DescriptorSet;
|
||||
|
||||
private:
|
||||
|
|
|
@ -111,4 +111,6 @@ void VkRenderBuffers::CreateScene(int width, int height, int samples)
|
|||
barrier.addImage(SceneColor.get(), VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, 0, VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT);
|
||||
barrier.addImage(SceneDepthStencil.get(), VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, 0, VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT, VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT);
|
||||
barrier.execute(fb->GetDrawCommands(), VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT | VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT);
|
||||
|
||||
SceneColorLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ public:
|
|||
std::unique_ptr<VulkanImageView> SceneDepthStencilView;
|
||||
std::unique_ptr<VulkanImageView> SceneDepthView;
|
||||
VkFormat SceneDepthStencilFormat = VK_FORMAT_D24_UNORM_S8_UINT;
|
||||
VkImageLayout SceneColorLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
|
||||
|
||||
static const int NumPipelineImages = 2;
|
||||
std::unique_ptr<VulkanImage> PipelineImage[NumPipelineImages];
|
||||
|
|
Loading…
Reference in a new issue