Giter Site home page Giter Site logo

Comments (13)

Overv avatar Overv commented on May 12, 2024

With regards to your global barrier, it may be preferable to keep the old code to be explicit about the intend, but note that it is not actually necessary. Do you agree?

from vulkantutorial.

qnope avatar qnope commented on May 12, 2024

I disagree for this transition :
transitionImageLayout(textureImage, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);

You want to transition the image from TRANSFER_DST to SHADER_READ.
As I wrote above, you must wait the transfer stage to be finished. And you want to use it at the Fragment Shader stage.
That's said, you must flush the caches used for transfers with VK_ACCESS_TRANSFER_WRITE and invalidate caches red by the FRAGMENT_SHADER using VK_ACCESS_SHADER_READ.

So, if you do not want use a "all blocking barrier", you should, IMHO, at least use :

srcStage = TRANSFER;
dstStage = FRAGMENT_SHADER
srcAccess = TRANSFER_WRITE;
dstAccess = SHADER_READ;

from vulkantutorial.

qnope avatar qnope commented on May 12, 2024

Actually, for the dstStage/Access, a TOP_OF_PIPE / 0 should be correct.

from vulkantutorial.

Overv avatar Overv commented on May 12, 2024

For your first proposal, am I understanding correctly that you want to change

if (oldLayout == VK_IMAGE_LAYOUT_PREINITIALIZED && newLayout == VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL) {
    barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT;
    barrier.dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT;
} else if (oldLayout == VK_IMAGE_LAYOUT_PREINITIALIZED && newLayout == VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL) {
    barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT;
    barrier.dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
}

To:

if (oldLayout == VK_IMAGE_LAYOUT_PREINITIALIZED && newLayout == VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL) {
    barrier.srcAccessMask = 0;
    barrier.dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT;
} else if (oldLayout == VK_IMAGE_LAYOUT_PREINITIALIZED && newLayout == VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL) {
    barrier.srcAccessMask = 0;
    barrier.dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
}

Because if I do this, I still get a warning from the validation layers despite your pull request.

from vulkantutorial.

qnope avatar qnope commented on May 12, 2024

It is correct, try to upgrade your validation layer, I pushed a fix that correct this bug :
KhronosGroup/Vulkan-LoaderAndValidationLayers#1142

from vulkantutorial.

Overv avatar Overv commented on May 12, 2024

I am aware, but I'm already using the latest version.

from vulkantutorial.

qnope avatar qnope commented on May 12, 2024

I do not have any problem
I am using archlinux and use vulkan-extra-layers 1.0.37

from vulkantutorial.

qnope avatar qnope commented on May 12, 2024

Here is the code I am using :

vk::ImageMemoryBarrier Transferer::transitionImage(Image image,
                                                   vk::ImageLayout oldLayout,
                                                   vk::ImageLayout newLayout,
                                                   vk::ImageSubresourceRange imageSubResourceRange) {
    vk::AccessFlags src, dst;

    if(oldLayout == vk::ImageLayout::eUndefined || oldLayout == vk::ImageLayout::ePreinitialized)
        src = vk::AccessFlags();

    // If it was in transferDst, we wait for transferWrite
    else if(oldLayout == vk::ImageLayout::eTransferDstOptimal)
        src = vk::AccessFlagBits::eTransferWrite;

    // If it was in transferSrc, we wait for transferRead
    else if(oldLayout == vk::ImageLayout::eTransferSrcOptimal)
        src = vk::AccessFlagBits::eTransferRead; // Useless since make available a read is meaningless

    else
        assert(!"This oldLayout is not managed");

    // If it will be transferSrcOptimal, it should be ready at transferRead
    if(newLayout == vk::ImageLayout::eTransferSrcOptimal)
        dst = vk::AccessFlagBits::eTransferRead;

    // If it will be transferDstOptimal
    else if(newLayout == vk::ImageLayout::eTransferDstOptimal)
        dst = vk::AccessFlagBits::eTransferWrite; // Myst be useless since invalidate for a write

    // If it will be shaderReadOnlyOptimal, it should be ready at shaderRead
    else if(newLayout == vk::ImageLayout::eShaderReadOnlyOptimal)
        dst = vk::AccessFlagBits::eShaderRead;

    else
        assert(!"This newLayout is not managed");

    return vk::ImageMemoryBarrier(src, dst, oldLayout, newLayout, VK_QUEUE_FAMILY_IGNORED, VK_QUEUE_FAMILY_IGNORED,
                                  image, imageSubResourceRange);
}

from vulkantutorial.

Overv avatar Overv commented on May 12, 2024

I'm also using version 1.0.37 of the validation layers, although I don't know what "vulkan-extra-layers" is.

from vulkantutorial.

qnope avatar qnope commented on May 12, 2024

I guess it is for other validation layers, but 1.0.37 should be good.
What is the message that is gave by the validation layers?

from vulkantutorial.

Overv avatar Overv commented on May 12, 2024

Source AccessMask 0 [None] must have required access bit 16384 [VK_ACCESS_HOST_WRITE_BIT] when layout is VK_IMAGE_LAYOUT_PREINITIALIZED, unless the app has previously added a barrier for this transition.

from vulkantutorial.

qnope avatar qnope commented on May 12, 2024

It is weird ^^, I do not have any problem... Try to compile by yourself the validation layers? Else, try to compile my VulkanExample Scene and launch it to see if in your case you have the same error or not.

from vulkantutorial.

Overv avatar Overv commented on May 12, 2024

Ah, I had a configuration error that caused it to use DLLs from an older SDK. It runs without errors now, I'll update the tutorial.

from vulkantutorial.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.