Skip to content

Commit a618b8c

Browse files
authored
Cleanup atomic intrinsics. (shader-slang#5324)
* Cleanup atomic intrinsics. * Fix. * Fix glsl. * Remove hacky intrinsic expansion logic for glsl image atomics. * Fix all tests. * Fix. * Add `InterlockedAddF16Emulated`. * Fix glsl intrinsic. * Fix.
1 parent 11e1eca commit a618b8c

33 files changed

+4074
-5598
lines changed

prelude/slang-cuda-prelude.h

+16-2
Original file line numberDiff line numberDiff line change
@@ -1261,7 +1261,14 @@ struct ByteAddressBuffer
12611261
memcpy(&data, ((const char*)this->data) + index, sizeof(T));
12621262
return data;
12631263
}
1264-
1264+
template<typename T>
1265+
SLANG_CUDA_CALL StructuredBuffer<T> asStructuredBuffer() const
1266+
{
1267+
StructuredBuffer<T> rs;
1268+
rs.data = (T*)data;
1269+
rs.count = sizeInBytes / sizeof(T);
1270+
return rs;
1271+
}
12651272
const uint32_t* data;
12661273
size_t sizeInBytes; //< Must be multiple of 4
12671274
};
@@ -1348,7 +1355,14 @@ struct RWByteAddressBuffer
13481355
SLANG_BOUND_CHECK_BYTE_ADDRESS(index, sizeof(T), sizeInBytes);
13491356
return (T*)(((char*)data) + index);
13501357
}
1351-
1358+
template<typename T>
1359+
SLANG_CUDA_CALL RWStructuredBuffer<T> asStructuredBuffer() const
1360+
{
1361+
RWStructuredBuffer<T> rs;
1362+
rs.data = (T*)data;
1363+
rs.count = sizeInBytes / sizeof(T);
1364+
return rs;
1365+
}
13521366
uint32_t* data;
13531367
size_t sizeInBytes; //< Must be multiple of 4
13541368
};

source/slang/core.meta.slang

+20
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,18 @@ interface __BuiltinSignedArithmeticType : __BuiltinArithmeticType {}
299299
interface __BuiltinIntegerType : __BuiltinArithmeticType, IInteger
300300
{}
301301

302+
/// Represent a `int` or `uint` type.
303+
[sealed]
304+
[builtin]
305+
interface __BuiltinInt32Type : __BuiltinIntegerType
306+
{}
307+
308+
/// Represent a `int64_t` or `uint64_t` type.
309+
[sealed]
310+
[builtin]
311+
interface __BuiltinInt64Type : __BuiltinIntegerType
312+
{}
313+
302314
/// Represent builtin types that can represent a real number.
303315
[sealed]
304316
[builtin]
@@ -602,6 +614,14 @@ ${{{{
602614
}}}}
603615
, __BuiltinArithmeticType
604616
, __BuiltinIntegerType
617+
${{{{
618+
if (kBaseTypes[tt].tag == BaseType::Int || kBaseTypes[tt].tag == BaseType::UInt)
619+
}}}}
620+
, __BuiltinInt32Type
621+
${{{{
622+
if (kBaseTypes[tt].tag == BaseType::Int64 || kBaseTypes[tt].tag == BaseType::UInt64)
623+
}}}}
624+
, __BuiltinInt64Type
605625
${{{{
606626
; // fall through
607627
case BaseType::Bool:

0 commit comments

Comments
 (0)