• Login
  • Register
  • Dolphin Forums
  • Home
  • FAQ
  • Download
  • Wiki
  • Code


Dolphin, the GameCube and Wii emulator - Forums › Dolphin Emulator Discussion and Support › Development Discussion v
« Previous 1 ... 17 18 19 20 21 ... 117 Next »

How to bind framebuffer as texture in vulkan?
View New Posts | View Today's Posts

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Thread Modes
How to bind framebuffer as texture in vulkan?
08-30-2018, 07:52 PM
#1
weihuoya Offline
Member
***
Posts: 73
Threads: 2
Joined: Aug 2018
Could it realized framebuffer fetch in vulkan?
My android phone isn't support dual source blend, so I want to bind current framebuffer as texture, and fetch color in shader.
But it don't work what I expected.
so anyone could help me to do this? Tongue
Code:
void Renderer::BindFramebufferAsTexture(u32 index)
{
 Texture2D* retex = FramebufferManager::GetInstance()->GetResolvedEFBColorTexture();
 if (!retex)
 {
   Texture2D* tex = FramebufferManager::GetInstance()->GetEFBColorTexture();
   VkRect2D region = { { 0, 0 },{ tex->GetWidth(), tex->GetHeight() } };
   retex = FramebufferManager::GetInstance()->ResolveEFBColorTexture(region);
 }

 if (retex)
 {
   VkImageView view = retex->GetView();
   if (view)
   {
     StateTracker::GetInstance()->SetTexture(index, view);
     StateTracker::GetInstance()->SetSampler(index, g_object_cache->GetPointSampler());
   }
 }
}
Code:
void VertexManager::vFlush()
{
   // bind shader blend texture
   bool useDstAlpha = bpmem.dstalpha.enable && bpmem.blendmode.alphaupdate && bpmem.zcontrol.pixel_format == PEControl::RGBA6_Z24;
   if (useDstAlpha && !g_vulkan_context->SupportsDualSourceBlend())
   {
     Renderer::GetInstance()->BindFramebufferAsTexture(1);
   }
}
Code:
ShaderCode GeneratePixelShaderCode(APIType ApiType, const ShaderHostConfig& host_config,
                                  const pixel_shader_uid_data* uid_data)
{
   if (use_shader_blend)
   {
     if (host_config.backend_shader_framebuffer_fetch)
     {
       // Store off a copy of the initial fb value for blending
       out.Write("\tfloat4 initial_ocol0 = FB_FETCH_VALUE;\n");
     }
     else
     {
       out.Write("\tfloat4 initial_ocol0 = texelFetch(samp[1], ivec3(rawpos.xy, 0), 0);\n");
     }
     out.Write("\tfloat4 ocol0;\n");
     out.Write("\tfloat4 ocol1;\n");
   }
}
Find
Reply
« Next Oldest | Next Newest »


Messages In This Thread
How to bind framebuffer as texture in vulkan? - weihuoya - 08-30-2018, 07:52 PM
RE: How to bind framebuffer as texture in vulkan? - DJBarry004 - 08-31-2018, 02:06 AM
RE: How to bind framebuffer as texture in vulkan? - Helios - 08-31-2018, 02:21 AM
RE: How to bind framebuffer as texture in vulkan? - JonnyH - 08-31-2018, 05:37 AM

  • View a Printable Version
  • Subscribe to this thread
Forum Jump:


Users browsing this thread: 1 Guest(s)



Powered By MyBB | Theme by Fragma

Linear Mode
Threaded Mode