Replies: 20 comments 2 replies
-
|
Have you tried running this with validation layers enabled and, if that doesn't reveal any problems, with RenderDoc? They should usually be the first things you try if a Vulkan-based app isn't doing what you expect. |
Beta Was this translation helpful? Give feedback.
-
|
When I add validation layers "VK_LAYER_KHRONOS_validation", I get this message VUID-vkCmdDraw-None-09600(ERROR / SPEC): msgNum: 1180184443 - Validation Error: [ VUID-vkCmdDraw-None-09600 ] Object 0: handle = 0x2ae88a7c080, type = VK_OBJECT_TYPE_COMMAND_BUFFER; Object 1: handle = 0xee647e0000000009, type = VK_OBJECT_TYPE_IMAGE; | MessageID = 0x46582f7b | vkQueueSubmit(): pSubmits[0].pCommandBuffers[0] command buffer VkCommandBuffer 0x2ae88a7c080[] expects VkImage 0xee647e0000000009[] (subresource: aspectMask = VK_IMAGE_ASPECT_COLOR_BIT, mipLevel = 0, arrayLayer = 0) to be in layout VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL--instead, current layout is VK_IMAGE_LAYOUT_UNDEFINED. |
Beta Was this translation helpful? Give feedback.
-
|
I tried replace to still received the same validation error message. |
Beta Was this translation helpful? Give feedback.
-
|
I took a look at the code. In Is my understanding correct? If so, how should I set up the image and sampler correctly so that I can sample from the image within the compute shader? |
Beta Was this translation helpful? Give feedback.
-
|
I applied a PipelineBarrier to change the image layout, and there are no more validation layer warnings, but I still cannot sample from the image in compute shader. I tried using RenderDoc to capture the compute pipeline, but I haven't yet figured out how to use this tool effectively for compute pipelines. |
Beta Was this translation helpful? Give feedback.
-
|
I have been away so coming to this discussion a bit late. The PipelineBarrier setting shouldn't affect the final state of the associate image but the timing of that assignment state, so I guess it's happening after the compute being run. The compile traversal is usually treated as entirely dedicated step that is completed fully before the next operations happen. We may need to look at the implementation of vsg::transferImageData() so that it can take the stage that the transfer needs to be complete by and default it to the top of the pipe. Top of the pipe would reduce the parallelism but if you are reading the image earlier than VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT then this really should be respected. I am catching up with a range of different tasks so I'll not be able to just focus on this item right away. It would be worth creating an Issue for it, ideally with an example program that illustrates how to recreate the problem. I see such an example embedded in the example above but this will require me to create source files, cmake files, build and hope that I've done it as intended so I'm reproducing the problem. If this was the only task I had to look into doing all of this would be fine, but I have dozens of items to look at so assistance would be appreciated. |
Beta Was this translation helpful? Give feedback.
-
|
Yes, you are absolutely right. It can now be almost confirmed that the I created an example that combines VSG and Vulkan methods. When the layout transition is done with However, I'm not very familiar with CMake and haven't managed to write the I have an idea: add a |
Beta Was this translation helpful? Give feedback.
-
|
To add to that, for images, we don't only use them in fragment shaders and compute shaders; they could also be used in vertex shaders or elsewhere. |
Beta Was this translation helpful? Give feedback.
-
|
@x1244 I have started looking into this topic, first step for me has been to recreate the test program, so I've created a CMakeLists.txt based on the one MyFirstVsgApplication/CMakeLists.txt and got your main.cpp compiling, added union.comp. I had to add a vsg before the read_cast<> to get it to compile. Did you compile the code before posting it? If so what compiler are you using? When I run I get a crash in the submitCommandsToQueue(..) : Which version of the VSG are you compiling against? You code also reads a "layer.jpg" file but you didn't supply this file. I can find a image to substitute, but would be helpful to use the same file so I can reproduce your results exactly rather than having to guess at what might be going on, on your system. |
Beta Was this translation helpful? Give feedback.
-
|
As an initial set in resolving this issue I have added a dstStageMask variable into the vsg::transferImageData(...) function with it's default still set to VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT for now: f0d1853 The stage that the image is used would typically be governed by the DescriptorSetLayoutBinding::stageFlags but this isn't passed in via the ImageInfo/ImageView. Perhaps we could cache all the stageFlags associated with an vkImage so when data is transferred to it it can handle all the possible variations. A simpler approach might be just to set the default dstStageMask value to VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT as this should ensure that the copies are complete before any possible usage, however, this could reduce the level of parallelism that can be achieved. |
Beta Was this translation helpful? Give feedback.
-
|
The compiler I'm using is VS2022, and it compiles and runs successfully on my end. Below are some compilation parameters: and Additionally, below is the test image I used. Also, in the main.cpp file, My current VSG commit is 35acf0e, which should correspond to version v1.1.9. I'm currently trying out the commit f0d1853. |
Beta Was this translation helpful? Give feedback.
-
|
sorry the vsg version maybe v1.1.11. |
Beta Was this translation helpful? Give feedback.
-
|
Unfortunately, when I tried commit 6bee434, which is the next commit after f0d1853, I also encountered a crash. However, the vsgviewer from this commit runs normally. |
Beta Was this translation helpful? Give feedback.
-
|
Well I guess it's good we both see the same behavior... The VSG usage in your testbed is unusual, as is the vsgcompute example for that matter, so likely which others have tripped up on a crash in this situation. Looking at the stack trace it looks like changes in VSG to help improve handling of inheritance of descriptor sets between pipeline layouts relied up a valid vsg::State being assigned but the usage case you have isn't providing this. Both the crash and pipeline barrier stage mask used during transfer data will need fixing. |
Beta Was this translation helpful? Give feedback.
-
|
I've discovered that when comparing these two versions, not only was The scope of changes is so extensive that I'm currently unsure where to begin investigating. Additionally, due to the changes in the definition and interface of the Thank you for your work. |
Beta Was this translation helpful? Give feedback.
-
|
I have had a bash at resolve the issues with this test example, integrating support for -d and -a options for enabling Vulkan Validation Layer and the API Layers and but haven't got to the bottom of why the texture read isn't working yet. $ bin/computetest -d
UNASSIGNED-CoreValidation-DrawState-InvalidImageLayout(ERROR / SPEC): msgNum: 1303270965 - Validation Error: [ UNASSIGNED-CoreValidation-DrawState-InvalidImageLayout ] Object 0: handle = 0x623aa7d55620, type = VK_OBJECT_TYPE_COMMAND_BUFFER; Object 1: handle = 0xee647e0000000009, type = VK_OBJECT_TYPE_IMAGE; | MessageID = 0x4dae5635 | vkQueueSubmit(): pSubmits[0].pCommandBuffers[0] command buffer VkCommandBuffer 0x623aa7d55620[] expects VkImage 0xee647e0000000009[] (subresource: aspectMask 0x1 array layer 0, mip level 0) to be in layout VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL--instead, current layout is VK_IMAGE_LAYOUT_UNDEFINED.
Objects: 2
[0] 0x623aa7d55620, type: 6, name: NULL
[1] 0xee647e0000000009, type: 10, name: NULL
wirte to output.jpgThe odd thing is the image handle that it has an issue with doesn't related to one that has been created earlier - you see the full output when using -a. My changes to get things compiling and running on Linux are: I need to get on with other tasks so I'll live it to others to investigate further. |
Beta Was this translation helpful? Give feedback.
-
|
YES. Updated to 34c36bd, and now the program runs normally without crashing. Using the Additionally, I have implemented image flipping - not using |
Beta Was this translation helpful? Give feedback.
-
|
Now, I get the picture with the new union.compu shader, where change |
Beta Was this translation helpful? Give feedback.
-
|
I am away from my dev system so can't check progress, but good to see you are now able to read and modify the image. W.r.t osg2vsg updates, thanks for spotting this, I have merged the mipmap_refinements branch with master. |
Beta Was this translation helpful? Give feedback.
-
|
The reason why using Even if a The corresponding output is as follows: |
Beta Was this translation helpful? Give feedback.



Uh oh!
There was an error while loading. Please reload this page.
-
I want to implement image sampling and processing in a compute shader. Regardless of which image I read, sampling in the compute shader always returns a black image. Can you help me analyze where the problem might be?
Important notes:
The image being read is correct and without issues. I have verified its raw data in vsg::Data.
If I don't use a sampler and use storage instead, I can correctly access and read the image information.
Below is the application code:
main.cppBelow is the compute shader code:
union.compI got the image

Beta Was this translation helpful? Give feedback.
All reactions