Closed quixoticaxis closed 4 years ago
Hi !
Yeah the correct one is the one you have now. I think the version of the validation layers I used did not pick this up since I fixed that in another project.
The error is emitted because the spec of cmd_copy_buffer says :
The size member of each element of pRegions must be less than or equal to the size of srcBuffer minus srcOffset
and
The size member of each element of pRegions must be less than or equal to the size of dstBuffer minus dstOffset
Yes, the buffer size is 60 but requires 256 bytes of allocated memory. From what I understand about it, the additional memory is related to the layout of these 60 bytes in memory.
"but it works because bytes from 60 to 255 do not matter anyway"
I think that the fact that this works is mostly due to a bit of luck given the fact that we use the api incorrectly. Maybe the driver just clamp it to 60. But most of the time not respecting the specs rules lead to unspecified behavior, so it might or might not work.
I'm not exactly an expert on Vulkan and I'm still learning about it, so I might be wrong but this is my understanding of the issue :)
I fixed it on the master branch :)
Cool, thanks, I'll be closing this issue then.
I suppose it's not about allignment in this case: my guess is that the minimum required memory for our GPU is 256 bytes long. As for alligment changes (at least as far I understood the Vulkan docs) we should use the value that is returned in "requirements" structure (in case of ash, pass it to the helper "Align" struct). And GPU "knows" its own aligment requirements and adhers to them with respect to the format we specify for the attachement.
Does it make any sense?
I suppose it's not about allignment in this case: my guess is that the minimum required memory for our GPU is 256 bytes long.
That could be just that yes. I could not find any information about the mimimum memory size for my gpu though so could not confirm.
As for alligment changes (at least as far I understood the Vulkan docs) we should use the value that is returned in "requirements" structure (in case of ash, pass it to the helper "Align" struct). And GPU "knows" its own aligment requirements and adhers to them with respect to the format we specify for the attachement.
Yes that is how I understand it too.
Hello. Sorry to bother you again, but in the chapter that describes the staging buffer implementation (this commit), there's an error emitted to the log (everything works though):
It looks like
mem_requirements.size
is 256, while the size is 3 * 20 = 60. Although everything works, I cannot wrap my mind around this error and why it is emitted.I've tried changing the code like this:
and the error is gone.
Could you please provide some guidance on this one? As far as I understand, the source buffer is 60 bytes but requires 256, so it looks like
[information in 0- 59 | 60 - 255 filled with any values]
, and the destination buffer is also 60 bytes long with 256 bytes needed and has the very same structure. So the validation layer is upset when we copy more than 60 bytes, but it works because bytes from 60 to 255 do not matter anyway. Do I understand this correctly?