Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems with descriptorbuffer example on AMD GPU #1118

Closed
SRSaunders opened this issue Apr 23, 2024 · 3 comments
Closed

Problems with descriptorbuffer example on AMD GPU #1118

SRSaunders opened this issue Apr 23, 2024 · 3 comments

Comments

@SRSaunders
Copy link
Contributor

SRSaunders commented Apr 23, 2024

When running on Windows 10 with an AMD 6600XT GPU, I am having problems with the descriptorbuffer example. The VK_EXT_descriptor_buffer extension and buffer device address features are available on the GPU, but the example crashes on swap chain creation with an out-of-host memory error. However, I think this is a red herring - I suspect the issue is elsewhere.

As a test, I commented out the following line in buildCommandBuffers():

	// Image (set 2)
	uint32_t bufferIndexImage = 1;
	bufferOffset = j * combinedImageDescriptor.layoutSize;
-->	//vkCmdSetDescriptorBufferOffsetsEXT(drawCmdBuffers[i], VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineLayout, 2, 1, &bufferIndexImage, &bufferOffset);
	model.draw(drawCmdBuffers[i]);

This allows the example to run showing two rotating cubes, but there are visible "blue noise" artifacts overlaid on the texture-less cube face surfaces. It looks almost like old-time analog TV reception snow projected onto the rotating cube faces. I am not sure what is going on here, but I suspect there may be a memory sync or mapping coherence issue, or perhaps incorrect indexing into device or host memory.

Is this something you have seen in your testing? Have you verified if this works on other AMD devices?

UPDATE: I just realized this is very similar to #1091, but on Windows 10. I can also confirm that reverting e006185 fixes the issue. Interestingly, commenting out the same line above on the old code results in the same blue noise effect. So that observation is clearly irrelevant, and the real issue must have something to do with bad indexing and/or offsets into the combined image descriptors in that line of code.

@SRSaunders
Copy link
Contributor Author

SRSaunders commented Apr 25, 2024

I think I found the issue - a typo on line 236. The offset calculation should refer tocombinedImageDescriptor not uniformDescriptor:

	// Put image descriptors into the corresponding resource buffer
	char* imageDescriptorBufPtr = (char*)combinedImageDescriptor.buffer.mapped;
	descriptorInfo.type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
	for (uint32_t i = 0; i < static_cast<uint32_t>(cubes.size()); i++) {
		descriptorInfo.data.pCombinedImageSampler = &cubes[i].texture.descriptor;
-->		vkGetDescriptorEXT(device, &descriptorInfo, descriptorBufferProperties.combinedImageSamplerDescriptorSize, imageDescriptorBufPtr + i * uniformDescriptor.layoutSize + uniformDescriptor.layoutOffset);
	}
                                                                                                                                                       ^^^^^^^^^^^^^^^^^              ^^^^^^^^^^^^^^^^^

Making this change results in a working example for me. Hopefully should solve this and #1091.

@SaschaWillems
Copy link
Owner

Thank you very much for bringing this up. I'll fix this as soon as time permits.

@SRSaunders
Copy link
Contributor Author

I decided to add the fix to my open PR #1117. I hope you don't mind.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants