-
Notifications
You must be signed in to change notification settings - Fork 436
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
Add support for RG11B10 and RGB9E5 vertex formats #1940
Conversation
f2bf44c
to
2726a74
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks for taking care of this.
Are you expecting to add more, or do you want to move this from Draft status so I can pull it in?
No the draft status is because I don't think it worked on my machine, I tried looking at VulkanCapsViewer and it didn't look like the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't see anything major you missed. Just a few minor problems.
Are you sure you built with Xcode 15? Are you sure MVK_XCODE_15
is true
in that case? (This is the only other thing I can think of.)
Also, are you running |
I'm definitely building with Xcode 15 and |
Yeah...I usually wait until later in the beta cycle. The challenges of such early beta is why we usually don't jump directly into trying to implement new capabilities at this point. However, your change is fairly straightforward. I think if you implement the
changes, and leave the |
What's the current status of this PR? Although it would be good to get it all resolved, I'd like to get at least the generic Xcode SDK 15 changes in these files pulled in:
and we can add the |
This commit adds some extra code that was needed to define to MSL 3.1 enum that was not included in the first commit. Based on PR: KhronosGroup#1940
Sorry for getting back this late. Seems like #1966 already addressed all of these concerns? So I'll just rebase this to add the two formats in a single commit. The changes are fairly simple now. |
68899a0
to
baaa4ad
Compare
@billhollings Is this mergeable now? I don't have macOS 14 to test myself, but theoretically this should be fine, right? |
@spnda I'm running MacOS 14, would you like me to try and build it? |
Building isn't the issue, but yeah if you want you can try and check if the formats are properly marked as available. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Just waiting for @cdavis5e to clear his previous review..
@spnda So I compiled your PR on my machine, and I temporally replaced
Note: I also tried this for I know that I'm using your PR build because I recieve all of the config messages, and before changing vertex format, my graphics were displaying perfectly the same as the Vulkan SDK build. |
Just checking...definitely using Xcode 15? |
@billhollings Definitely |
Are you using Apple Silicon? The new formats only appear to be enabled for Apple Silicon GPUs. |
Yes, I'm using an M1 MacBook Air, I'll try and see if I did anything wrong for linking or building tomorrow. |
Clearly, we've all missed something. What does |
@cdavis5e I ran the function that you provided and got:
This is the code I'm running if you want to know: VkFormatProperties props1 = {};
vkGetPhysicalDeviceFormatProperties(physicalDevice, VK_FORMAT_B10G11R11_UFLOAT_PACK32, &props1);
if(props1.bufferFeatures & VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT)
{
std::cout << "VK_FORMAT_B10G11R11_UFLOAT_PACK32 has been found!" << std::endl;
}else
{
std::cout << "VK_FORMAT_B10G11R11_UFLOAT_PACK32 has not been found!" << std::endl;
}
VkFormatProperties props2 = {};
vkGetPhysicalDeviceFormatProperties(physicalDevice, VK_FORMAT_E5B9G9R9_UFLOAT_PACK32, &props2);
if(props2.bufferFeatures & VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT)
{
std::cout << "VK_FORMAT_E5B9G9R9_UFLOAT_PACK32 has been found!" << std::endl;
}else
{
std::cout << "VK_FORMAT_E5B9G9R9_UFLOAT_PACK32 has not been found!" << std::endl;
} Tell me if I'm doing anything wrong. Thanks |
That result would mean that it does work. Your hobby project must be doing something differently/wrong for it to think it's not supported. Or am I misremembering that a vertex buffer just needs to have a format with VERTEX_BUFFER_BIT set to be used validly? |
@spnda Here's my vertex code: class Vertex
{
public:
glm::vec2 position;
glm::vec3 color;
static VkVertexInputBindingDescription GetBindingDescription()
{
VkVertexInputBindingDescription bindingDescription{};
bindingDescription.binding = 0;
bindingDescription.stride = sizeof(Vertex);
bindingDescription.inputRate = VK_VERTEX_INPUT_RATE_VERTEX;
return bindingDescription;
}
static std::array<VkVertexInputAttributeDescription, 2> GetAttributeDescriptions()
{
std::array<VkVertexInputAttributeDescription, 2> attributeDescriptions{};
attributeDescriptions[0].binding = 0;
attributeDescriptions[0].location = 0;
attributeDescriptions[0].format = VK_FORMAT_R32G32_SFLOAT;
attributeDescriptions[0].offset = offsetof(Vertex, position);
attributeDescriptions[1].binding = 0;
attributeDescriptions[1].location = 1;
// attributeDescriptions[1].format = VK_FORMAT_R32G32B32_SFLOAT;
attributeDescriptions[1].format = VK_FORMAT_E5B9G9R9_UFLOAT_PACK32;
attributeDescriptions[1].offset = offsetof(Vertex, color);
return attributeDescriptions;
}
}; This is all based on Vulkan Tutorial. Whenever I switch to the new vulkan formats, it gives me this error.
Perhaps you forgot to add something somewhere in the code, cause it says it's supported when asked, but when using the new formats, just breaks. I'm not formatting my vertices for these new formats, but they should cause validation errors, not MoltenVK errors. |
That error message comes from |
Or is getting set back to
|
So
Since we know the format itself is not |
baaa4ad
to
9281233
Compare
I see that the Xcode 11 CI was removed, and now everything builds correctly. @AntarticCoder could you perhaps re-test to see if it wasn't anything else causing the issue on your end? Otherwise, @billhollings, care to review & merge? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is still causing problems. The CTS vertex format tests for these formats fail.
It turns out the problem all along has been that _mtlVertexFormatCount
is set too low. Please update the following line at the top of MVKPixelFormats.h
as follows:
static const uint32_t _mtlVertexFormatCount = MTLVertexFormatFloatRGB9E5 + 1;
This is not your mistake. There is an assertion that should be triggered when this count is too low, but the assertion test itself is broken.
It also looks like the vertex format lookups in MVKPixelFormats
could be simplified. Rather than deal with all that here, once you've made this change (plus the change I requested inline), and this PR is pulled in, I'll submit a PR to correct the vertex format lookup logic.
9281233
to
d77f614
Compare
Shoot! It's now (understandably) failing Xcode before 15. We'll have to do what we did with
|
d77f614
to
86c080d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM now. Thanks!
Metal 3.1 and iOS 17/macOS 14 add support for these two new vertex/attribute formats.
I also put in all of the necessary fixes (afaik) for Xcode 15 into this PR.