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

[SPIR-V] Device Buffer Address- feature #3772

Open
Eichenherz opened this issue May 16, 2021 · 1 comment
Open

[SPIR-V] Device Buffer Address- feature #3772

Eichenherz opened this issue May 16, 2021 · 1 comment
Labels
spirv

Comments

@Eichenherz
Copy link

@Eichenherz Eichenherz commented May 16, 2021

Hello !
In Vulkan it's possible to query the gpu address of a buffer and pass that as a uint64_t, pretty much like a pointer in C/C++.

inline u64 VkGetBufferDeviceAddress( VkDevice vkDevice, VkBuffer hndl )
{
	VkBufferDeviceAddressInfo deviceAddrInfo = {};
	deviceAddrInfo.sType = VK_STRUCTURE_TYPE_BUFFER_DEVICE_ADDRESS_INFO;
	deviceAddrInfo.buffer = hndl;

	return vkGetBufferDeviceAddress( vkDevice, &deviceAddrInfo );
layout( buffer_reference, scalar, buffer_reference_align = 4 ) readonly buffer mtl_ref{
	material_data materials[];
};
layout( buffer_reference, scalar, buffer_reference_align = 4 ) readonly buffer light_ref{
	light_data lights[];
};

.....................

void main()
{
	material_data mtl = mtl_ref( g.addr + g.materialsOffset ).materials[ mtlIdx ];

	vec4 baseCol = texture( sampler2D( sampledImages[ nonuniformEXT( mtl.baseColIdx ) ], samplers[ nonuniformEXT( 0 ) ] ), uv );
	...................
}

As far as I know, DX12 doesn't have this kind of capabilities, but Vulkan does, and since compiling HLSL to SPIR-V is possible, even used in the game industry, it would be very nice to have this. ( Maybe even in DX12, why not ? )
Thanks !

@jaebaek jaebaek added the spirv label Nov 8, 2021
@jaebaek jaebaek changed the title Device Buffer Address- feature [SPIR-V] Device Buffer Address- feature Nov 8, 2021
@StarsX
Copy link

@StarsX StarsX commented Mar 26, 2022

I think the key point is HLSL hasn’t supported 64-bit indexing for raw buffer yet.

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

No branches or pull requests

3 participants