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

Param block support for Metal #208

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open

Param block support for Metal #208

wants to merge 10 commits into from

Conversation

kaizhangNV
Copy link
Contributor

Add parameter block support for Metal backend, the only thing we need to change to support that is to change the type layout of the parameter block to use argument buffer tier2 rule. In such rule, everything inside parameter block will be uniform, and resource will be represented by device pointer or resource id, which means that they will be bindless resource.

Add a test.

@@ -22,6 +22,8 @@ elseif(UNIX)
set(SGL_ORIGIN "$ORIGIN")
endif()

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this

Copy link
Contributor Author

@kaizhangNV kaizhangNV Mar 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we just keep this for developers using clangd as their language server?

@@ -37,7 +37,7 @@
CMAKE_PRESET = {
"windows": "windows-msvc",
"linux": "linux-gcc",
"macos": "macos-clang",
"macos": "macos-arm64-clang",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why did you change this? does the macos-clang preset build for x64 only?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is no macos-clang preset, only macos-arm64-clang and macos-x64-clang, and I think we don't care macos-x64-clang.

return ShaderCursor(m_shader_object->get_object(m_offset));
{
ShaderCursor d = ShaderCursor(m_shader_object->get_object(m_offset));
#if SGL_MACOS
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is wrong. you should check the device type instead.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because, vulkan is a valid device type on macos too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, I don't know vulkan is actually supported on macos.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is through moltenVK

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but switching the layout does depend on the active device type, not the OS, so checking SGL_MACOS is the wrong approach anyway

@@ -155,10 +164,6 @@ ShaderCursor ShaderCursor::find_field(std::string_view name) const
//
case TypeReflection::Kind::constant_buffer:
case TypeReflection::Kind::parameter_block: {
// We basically need to "dereference" the current cursor
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this comment removed?

{
NestedStruct a;
uint b;
ParameterBlock<NestedStruct> nestParamBlock;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ideally you would avoid using camelCase when adding code to sgl. we try to stick to snake_case convention throughout c++ python and slang code

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I see.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated.

@skallweitNV
Copy link
Collaborator

do we not have existing tests for parameter blocks?

@kaizhangNV
Copy link
Contributor Author

kaizhangNV commented Mar 11, 2025

do we not have existing tests for parameter blocks?

not I'm aware of.

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

Successfully merging this pull request may close these issues.

None yet

2 participants