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

Add groupshared atomic array test. #6107

Merged
merged 3 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions tests/spirv/groupshared-array-atomic.slang
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//TEST:COMPARE_COMPUTE(filecheck-buffer=CHECK): -shaderobj -vk -emit-spirv-directly
groupshared Atomic<uint> values[10];

//TEST_INPUT: set outputAddr = out ubuffer(data=[0 0 0 0], stride=4)
uniform uint64_t outputAddr;

[numthreads(4,1,1)]
void computeMain(int i : SV_DispatchThreadID)
{
uint* output = (uint*)(outputAddr);
values[i] = 0;
values[i] += 1;
output[i] = values[i].load();

// CHECK: 1
// CHECK: 1
// CHECK: 1
// CHECK: 1
}
7 changes: 6 additions & 1 deletion tools/render-test/render-test-main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,13 +226,18 @@ struct AssignValsFromLayoutContext
device,
bufferResource));

if (dstCursor.getTypeLayout()->getType()->getKind() == slang::TypeReflection::Kind::Pointer)
if ((dstCursor.getTypeLayout()->getType()->getKind() ==
slang::TypeReflection::Kind::Scalar &&
dstCursor.getTypeLayout()->getType()->getScalarType() ==
slang::TypeReflection::ScalarType::UInt64) ||
dstCursor.getTypeLayout()->getType()->getKind() == slang::TypeReflection::Kind::Pointer)
{
// dstCursor is pointer to an ordinary uniform data field,
// we should write bufferResource as a pointer.
uint64_t addr = bufferResource->getDeviceAddress();
dstCursor.setData(&addr, sizeof(addr));
resourceContext.resources.add(ComPtr<IResource>(bufferResource.get()));
maybeAddOutput(dstCursor, srcVal, bufferResource);
return SLANG_OK;
}

Expand Down
Loading