Unity-Technologies / NativeRenderingPlugin

C++ Rendering Plugin example for Unity
https://docs.unity3d.com/Manual/NativePluginInterface.html
MIT License
815 stars 163 forks source link

Does AccessRenderBufferTexture of Vulkan Plugin API can transition image layout? #36

Open zhangbaochong opened 1 year ago

zhangbaochong commented 1 year ago
UnityVulkanImage image;
    if (!m_UnityVulkan->AccessRenderBufferTexture((UnityRenderBuffer)data->colorBuffer, UnityVulkanWholeImage, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
        VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, VK_ACCESS_SHADER_READ_BIT, kUnityVulkanResourceAccess_PipelineBarrier, &image))
    {
        UnityLog("failed to access rendertexture color buffer");
        return;
    }

after calling the API, I print the image.layout, it's VK_IMAGE_LAYOUT_UNDEFINED type instead of VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL. Because I want to sample the texture, so the image layout out must be VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL. Do I need to transition image layout manully?