Skip to content

Commit

Permalink
Cleanup atomic intrinsics. (#5324)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
csyonghe authored Oct 18, 2024
1 parent 11e1eca commit a618b8c
Show file tree
Hide file tree
Showing 33 changed files with 4,074 additions and 5,598 deletions.
18 changes: 16 additions & 2 deletions prelude/slang-cuda-prelude.h
Original file line number Diff line number Diff line change
Expand Up @@ -1261,7 +1261,14 @@ struct ByteAddressBuffer
memcpy(&data, ((const char*)this->data) + index, sizeof(T));
return data;
}

template<typename T>
SLANG_CUDA_CALL StructuredBuffer<T> asStructuredBuffer() const
{
StructuredBuffer<T> rs;
rs.data = (T*)data;
rs.count = sizeInBytes / sizeof(T);
return rs;
}
const uint32_t* data;
size_t sizeInBytes; //< Must be multiple of 4
};
Expand Down Expand Up @@ -1348,7 +1355,14 @@ struct RWByteAddressBuffer
SLANG_BOUND_CHECK_BYTE_ADDRESS(index, sizeof(T), sizeInBytes);
return (T*)(((char*)data) + index);
}

template<typename T>
SLANG_CUDA_CALL RWStructuredBuffer<T> asStructuredBuffer() const
{
RWStructuredBuffer<T> rs;
rs.data = (T*)data;
rs.count = sizeInBytes / sizeof(T);
return rs;
}
uint32_t* data;
size_t sizeInBytes; //< Must be multiple of 4
};
Expand Down
20 changes: 20 additions & 0 deletions source/slang/core.meta.slang
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,18 @@ interface __BuiltinSignedArithmeticType : __BuiltinArithmeticType {}
interface __BuiltinIntegerType : __BuiltinArithmeticType, IInteger
{}

/// Represent a `int` or `uint` type.
[sealed]
[builtin]
interface __BuiltinInt32Type : __BuiltinIntegerType
{}

/// Represent a `int64_t` or `uint64_t` type.
[sealed]
[builtin]
interface __BuiltinInt64Type : __BuiltinIntegerType
{}

/// Represent builtin types that can represent a real number.
[sealed]
[builtin]
Expand Down Expand Up @@ -602,6 +614,14 @@ ${{{{
}}}}
, __BuiltinArithmeticType
, __BuiltinIntegerType
${{{{
if (kBaseTypes[tt].tag == BaseType::Int || kBaseTypes[tt].tag == BaseType::UInt)
}}}}
, __BuiltinInt32Type
${{{{
if (kBaseTypes[tt].tag == BaseType::Int64 || kBaseTypes[tt].tag == BaseType::UInt64)
}}}}
, __BuiltinInt64Type
${{{{
; // fall through
case BaseType::Bool:
Expand Down
Loading

0 comments on commit a618b8c

Please sign in to comment.