Skip to content

Commit 8602b8c

Browse files
RichardGemeistdan
andauthored
Merge pull request #52 from GPUOpen-LibrariesAndSDKs/next-release-12
Update to 3.1.0.cb09c56 Co-authored-by: Daniel Meister <daniel.meister@amd.com>
2 parents d612ede + 5f7c1d2 commit 8602b8c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+1109
-1071
lines changed

.github/workflows/format.yaml

Lines changed: 0 additions & 30 deletions
This file was deleted.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Format and Update Hash
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- master
7+
8+
jobs:
9+
format-and-update:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout PR branch
14+
uses: actions/checkout@v4
15+
with:
16+
ref: ${{ github.event.pull_request.head.ref }}
17+
18+
# Step 1: Run clang-format linter (in place)
19+
- name: Run clang-format
20+
uses: DoozyX/clang-format-lint-action@v0.20
21+
with:
22+
source: './hiprt ./test'
23+
exclude: './contrib ./tools ./scripts'
24+
extensions: 'h,cpp,c'
25+
clangFormatVersion: 15
26+
inplace: 'True'
27+
28+
# Step 2: Update commit hash in version.txt (line 4)
29+
- name: Update version.txt with latest commit hash
30+
run: |
31+
FILE="version.txt"
32+
HASH=$(git rev-parse --short HEAD)
33+
if [ -f "$FILE" ]; then
34+
echo "Updating $FILE with hash $HASH"
35+
sed -i "4s~.*~$HASH~" "$FILE"
36+
else
37+
echo "File $FILE not found!"
38+
exit 1
39+
fi
40+
41+
# Step 3: Commit and push all changes (format + hash)
42+
- name: Commit and push changes
43+
uses: EndBug/add-and-commit@v9.1.1
44+
with:
45+
author_name: rprbuild
46+
author_email: a1rpr@amd.com
47+
message: 'Automatic: clang-format + hash update'

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ add_library(${HIPRT_NAME} SHARED)
361361
target_compile_definitions(${HIPRT_NAME} PRIVATE HIPRT_EXPORTS)
362362

363363

364-
if( ${CMAKE_BUILD_TYPE} STREQUAL "Debug" )
364+
if( CMAKE_BUILD_TYPE STREQUAL "Debug" )
365365
set_target_properties(${HIPRT_NAME} PROPERTIES OUTPUT_NAME "${HIPRT_NAME}64D")
366366
else()
367367
set_target_properties(${HIPRT_NAME} PROPERTIES OUTPUT_NAME "${HIPRT_NAME}64")
@@ -650,7 +650,7 @@ if(NOT NO_UNITTEST)
650650
target_link_libraries(unittest PRIVATE version)
651651
endif()
652652

653-
if( ${CMAKE_BUILD_TYPE} STREQUAL "Debug" )
653+
if( CMAKE_BUILD_TYPE STREQUAL "Debug" )
654654
set_target_properties(unittest PROPERTIES OUTPUT_NAME "unittest64D")
655655
else()
656656
set_target_properties(unittest PROPERTIES OUTPUT_NAME "unittest64")

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ Example: `..\dist\bin\Release\unittest64.exe --width=512 --height=512 --referenc
8080
- Use references instead of pointers if possible.
8181
- Use bit-fields instead of explicit bit masking if possible.
8282
- Use `nullptr` instead of `NULL` or zero.
83+
- Use `using` instead of `typedef`.
8384
- Use C++-style casts (e.g., `static_cast`) instead of C-style cast.
8485
- Add `const` for references and pointers if they are not being changed.
8586
- Add `constexpr` for variables and functions if they can be constant in compile time (do not use `#define` if possible).

_codeql_detected_source_root

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.

hiprt/hiprt_device.h

Lines changed: 8 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -506,46 +506,14 @@ class hiprtSceneTraversalAnyHitCustomStack
506506
m_impl;
507507
};
508508

509-
/** \brief Returns the object to world transformation for a given instance and time in the form of the SRT frame.
510-
*
511-
* \param scene A scene.
512-
* \param instanceID Instance ID.
513-
* \param time The time.
514-
*/
515-
HIPRT_DEVICE hiprtFrameSRT hiprtGetObjectToWorldFrameSRT( hiprtScene scene, uint32_t instanceID, float time = 0.0f );
516-
517-
/** \brief Returns the world to object transformation for a given instance and time in the form of the SRT frame.
518-
*
519-
* \param scene A scene.
520-
* \param instanceID Instance ID.
521-
* \param time The time.
522-
*/
523-
HIPRT_DEVICE hiprtFrameSRT hiprtGetWorldToObjectFrameSRT( hiprtScene scene, uint32_t instanceID, float time = 0.0f );
524-
525-
/** \brief Returns the object to world transformation for a given instance and time in the form of the matrix.
526-
*
527-
* \param scene A scene.
528-
* \param instanceID Instance ID.
529-
* \param time The time.
530-
*/
531-
HIPRT_DEVICE hiprtFrameMatrix hiprtGetObjectToWorldFrameMatrix( hiprtScene scene, uint32_t instanceID, float time = 0.0f );
532-
533-
/** \brief Returns the world to object transformation for a given instance and time in the form of the matrix.
534-
*
535-
* \param scene A scene.
536-
* \param instanceID Instance ID.
537-
* \param time The time.
538-
*/
539-
HIPRT_DEVICE hiprtFrameMatrix hiprtGetWorldToObjectFrameMatrix( hiprtScene scene, uint32_t instanceID, float time = 0.0f );
540-
541509
/** \brief Transforms a point from the object space to the world space.
542510
*
543511
* \param point A point in the object space.
544512
* \param scene A scene.
545513
* \param instanceID Instance ID.
546514
* \param time The time.
547515
*/
548-
HIPRT_DEVICE float3 hiprtPointObjectToWorld( float3 point, hiprtScene scene, uint32_t instanceID, float time = 0.0f );
516+
HIPRT_DEVICE float3 hiprtPointObjectToWorld( const float3& point, hiprtScene scene, uint32_t instanceID, float time = 0.0f );
549517

550518
/** \brief Transforms a point from the world space to the object space.
551519
*
@@ -554,7 +522,7 @@ HIPRT_DEVICE float3 hiprtPointObjectToWorld( float3 point, hiprtScene scene, uin
554522
* \param instanceID Instance ID.
555523
* \param time The time.
556524
*/
557-
HIPRT_DEVICE float3 hiprtPointWorldToObject( float3 point, hiprtScene scene, uint32_t instanceID, float time = 0.0f );
525+
HIPRT_DEVICE float3 hiprtPointWorldToObject( const float3& point, hiprtScene scene, uint32_t instanceID, float time = 0.0f );
558526

559527
/** \brief Transforms a vector from the object space to the world space.
560528
*
@@ -563,7 +531,7 @@ HIPRT_DEVICE float3 hiprtPointWorldToObject( float3 point, hiprtScene scene, uin
563531
* \param instanceID Instance ID.
564532
* \param time The time.
565533
*/
566-
HIPRT_DEVICE float3 hiprtVectorObjectToWorld( float3 vector, hiprtScene scene, uint32_t instanceID, float time = 0.0f );
534+
HIPRT_DEVICE float3 hiprtVectorObjectToWorld( const float3& vector, hiprtScene scene, uint32_t instanceID, float time = 0.0f );
567535

568536
/** \brief Transforms a vector from the world space to the object space.
569537
*
@@ -572,43 +540,7 @@ HIPRT_DEVICE float3 hiprtVectorObjectToWorld( float3 vector, hiprtScene scene, u
572540
* \param instanceID Instance ID.
573541
* \param time The time.
574542
*/
575-
HIPRT_DEVICE float3 hiprtVectorWorldToObject( float3 vector, hiprtScene scene, uint32_t instanceID, float time = 0.0f );
576-
577-
/** \brief Returns the object to world transformation for a given instance and time in the form of the SRT frame.
578-
*
579-
* \param scene A scene.
580-
* \param instanceIDs Instance IDs (multi-level instancing).
581-
* \param time The time.
582-
*/
583-
HIPRT_DEVICE hiprtFrameSRT
584-
hiprtGetObjectToWorldFrameSRT( hiprtScene scene, const uint32_t ( &instanceIDs )[hiprtMaxInstanceLevels], float time = 0.0f );
585-
586-
/** \brief Returns the world to object transformation for a given instance and time in the form of the SRT frame.
587-
*
588-
* \param scene A scene.
589-
* \param instanceIDs Instance IDs (multi-level instancing).
590-
* \param time The time.
591-
*/
592-
HIPRT_DEVICE hiprtFrameSRT
593-
hiprtGetWorldToObjectFrameSRT( hiprtScene scene, const uint32_t ( &instanceIDs )[hiprtMaxInstanceLevels], float time = 0.0f );
594-
595-
/** \brief Returns the object to world transformation for a given instance and time in the form of the matrix.
596-
*
597-
* \param scene A scene.
598-
* \param instanceIDs Instance IDs (multi-level instancing).
599-
* \param time The time.
600-
*/
601-
HIPRT_DEVICE hiprtFrameMatrix hiprtGetObjectToWorldFrameMatrix(
602-
hiprtScene scene, const uint32_t ( &instanceIDs )[hiprtMaxInstanceLevels], float time = 0.0f );
603-
604-
/** \brief Returns the world to object transformation for a given instance and time in the form of the matrix.
605-
*
606-
* \param scene A scene.
607-
* \param instanceIDs Instance IDs (multi-level instancing).
608-
* \param time The time.
609-
*/
610-
HIPRT_DEVICE hiprtFrameMatrix hiprtGetWorldToObjectFrameMatrix(
611-
hiprtScene scene, const uint32_t ( &instanceIDs )[hiprtMaxInstanceLevels], float time = 0.0f );
543+
HIPRT_DEVICE float3 hiprtVectorWorldToObject( const float3& vector, hiprtScene scene, uint32_t instanceID, float time = 0.0f );
612544

613545
/** \brief Transforms a point from the object space to the world space.
614546
*
@@ -618,7 +550,7 @@ HIPRT_DEVICE hiprtFrameMatrix hiprtGetWorldToObjectFrameMatrix(
618550
* \param time The time.
619551
*/
620552
HIPRT_DEVICE float3 hiprtPointObjectToWorld(
621-
float3 point, hiprtScene scene, const uint32_t ( &instanceIDs )[hiprtMaxInstanceLevels], float time = 0.0f );
553+
const float3& point, hiprtScene scene, const uint32_t ( &instanceIDs )[hiprtMaxInstanceLevels], float time = 0.0f );
622554

623555
/** \brief Transforms a point from the world space to the object space.
624556
*
@@ -628,7 +560,7 @@ HIPRT_DEVICE float3 hiprtPointObjectToWorld(
628560
* \param time The time.
629561
*/
630562
HIPRT_DEVICE float3 hiprtPointWorldToObject(
631-
float3 point, hiprtScene scene, const uint32_t ( &instanceIDs )[hiprtMaxInstanceLevels], float time = 0.0f );
563+
const float3& point, hiprtScene scene, const uint32_t ( &instanceIDs )[hiprtMaxInstanceLevels], float time = 0.0f );
632564

633565
/** \brief Transforms a vector from the object space to the world space.
634566
*
@@ -638,7 +570,7 @@ HIPRT_DEVICE float3 hiprtPointWorldToObject(
638570
* \param time The time.
639571
*/
640572
HIPRT_DEVICE float3 hiprtVectorObjectToWorld(
641-
float3 vector, hiprtScene scene, const uint32_t ( &instanceIDs )[hiprtMaxInstanceLevels], float time = 0.0f );
573+
const float3& vector, hiprtScene scene, const uint32_t ( &instanceIDs )[hiprtMaxInstanceLevels], float time = 0.0f );
642574

643575
/** \brief Transforms a vector from the world space to the object space.
644576
*
@@ -648,4 +580,4 @@ HIPRT_DEVICE float3 hiprtVectorObjectToWorld(
648580
* \param time The time.
649581
*/
650582
HIPRT_DEVICE float3 hiprtVectorWorldToObject(
651-
float3 vector, hiprtScene scene, const uint32_t ( &instanceIDs )[hiprtMaxInstanceLevels], float time = 0.0f );
583+
const float3& vector, hiprtScene scene, const uint32_t ( &instanceIDs )[hiprtMaxInstanceLevels], float time = 0.0f );

hiprt/hiprt_libpath.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ const char* g_hip_paths[] = {
3535
"amdhip64_7.dll",
3636
"amdhip64_6.dll",
3737
"amdhip64.dll", // <- hip '5.x' DLL.
38-
NULL };
38+
nullptr };
3939

4040
const char* g_hiprtc_paths[] = { "hiprtc0707.dll", "hiprtc0706.dll", "hiprtc0705.dll", "hiprtc0704.dll", "hiprtc0703.dll",
4141
"hiprtc0702.dll", "hiprtc0701.dll", "hiprtc0700.dll", "hiprtc0605.dll", "hiprtc0604.dll",
4242
"hiprtc0603.dll", "hiprtc0602.dll", "hiprtc0601.dll", "hiprtc0600.dll", "hiprtc0507.dll",
43-
"hiprtc0506.dll", "hiprtc0505.dll", "hiprtc0504.dll", "hiprtc0503.dll", NULL };
43+
"hiprtc0506.dll", "hiprtc0505.dll", "hiprtc0504.dll", "hiprtc0503.dll", nullptr };
4444
#elif defined( __APPLE__ )
4545

4646
const char** g_hip_paths = nullptr;
@@ -67,7 +67,7 @@ const char* g_hip_paths[] = {
6767
"/opt/rocm/lib/libamdhip64.so.5",
6868
"/opt/rocm/hip/lib/libamdhip64.so.5",
6969

70-
NULL };
70+
nullptr };
7171

7272
const char* g_hiprtc_paths[] = {
7373

@@ -89,5 +89,5 @@ const char* g_hiprtc_paths[] = {
8989
"/opt/rocm/lib/libhiprtc.so.5",
9090
"libhiprtc.so.5",
9191

92-
NULL };
92+
nullptr };
9393
#endif

hiprt/hiprt_math.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1580,6 +1580,15 @@ HIPRT_HOST_DEVICE HIPRT_INLINE float differenceOfProducts( const float a, const
15801580
return fmaf( a, b, -cd ) - fmaf( c, d, -cd );
15811581
}
15821582

1583+
HIPRT_HOST_DEVICE HIPRT_INLINE float hypot( const float3& a )
1584+
{
1585+
float x = fabsf( a.x );
1586+
float y = fabsf( a.y );
1587+
float z = fabsf( a.z );
1588+
float d = x < y ? y < z ? z : y : x < z ? z : x;
1589+
return d != 0.0f ? ( d * sqrtf( ( x / d ) * ( x / d ) + ( y / d ) * ( y / d ) + ( z / d ) * ( z / d ) ) ) : 0.0f;
1590+
}
1591+
15831592
HIPRT_HOST_DEVICE HIPRT_INLINE float3 cross( const float3& a, const float3& b )
15841593
{
15851594
return {
@@ -1593,7 +1602,7 @@ HIPRT_HOST_DEVICE HIPRT_INLINE float dot( const float3& a, const float3& b )
15931602
return fmaf( a.x, b.x, sumOfProducts( a.y, b.y, a.z, b.z ) );
15941603
}
15951604

1596-
HIPRT_HOST_DEVICE HIPRT_INLINE float3 normalize( const float3& a ) { return a / sqrtf( dot( a, a ) ); }
1605+
HIPRT_HOST_DEVICE HIPRT_INLINE float3 normalize( const float3& a ) { return a / hypot( a ); }
15971606

15981607
template <typename V>
15991608
HIPRT_HOST_DEVICE HIPRT_INLINE auto* ptr( V& a )

hiprt/hiprt_types.h

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,20 @@ struct _hiprtScene;
3131
struct _hiprtContext;
3232
struct _hiprtFuncTable;
3333

34-
typedef void* hiprtDevicePtr;
35-
typedef _hiprtGeometry* hiprtGeometry;
36-
typedef _hiprtScene* hiprtScene;
37-
typedef _hiprtContext* hiprtContext;
38-
typedef _hiprtFuncTable* hiprtFuncTable;
39-
typedef uint32_t hiprtLogLevel;
40-
typedef uint32_t hiprtBuildFlags;
41-
typedef uint32_t hiprtRayMask;
42-
43-
typedef int hiprtApiDevice; // hipDevice, cuDevice
44-
typedef void* hiprtApiCtx; // hipCtx, cuCtx
45-
typedef void* hiprtApiStream; // hipStream, cuStream
46-
typedef void* hiprtApiFunction; // hipFunction, cuFunction
47-
typedef void* hiprtApiModule; // hipModule, cuModule
34+
using hiprtDevicePtr = void*;
35+
using hiprtGeometry = _hiprtGeometry*;
36+
using hiprtScene = _hiprtScene*;
37+
using hiprtContext = _hiprtContext*;
38+
using hiprtFuncTable = _hiprtFuncTable*;
39+
using hiprtLogLevel = uint32_t;
40+
using hiprtBuildFlags = uint32_t;
41+
using hiprtRayMask = uint32_t;
42+
43+
using hiprtApiDevice = int; // hipDevice, cuDevice
44+
using hiprtApiCtx = void*; // hipCtx, cuCtx
45+
using hiprtApiStream = void*; // hipStream, cuStream
46+
using hiprtApiFunction = void*; // hipFunction, cuFunction
47+
using hiprtApiModule = void*; // hipModule, cuModule
4848

4949
/** \brief Ray traversal type.
5050
*
@@ -490,19 +490,19 @@ HIPRT_STATIC_ASSERT( sizeof( hiprtInstance ) == 16 );
490490
* are evaluated with the primitive of corresponding instance if the result is
491491
* 0. The transformation header defines the offset and the number of consecutive
492492
* transformation frames in the frame array for each instance. More than one frame
493-
* is interpreted as motion blur. If the transformation headers is NULL, it
493+
* is interpreted as motion blur. If the transformation headers is nullptr, it
494494
* assumes one frame per instance. Optionally, it is possible to import a custom
495495
* BVH by setting nodes and the corresponding build flag.
496496
*/
497497
struct alignas( 16 ) hiprtSceneBuildInput
498498
{
499499
/*!< Array of instanceCount pointers to instances */
500500
hiprtDevicePtr instances;
501-
/*!< Array of instanceCount transform headers (optional: per object frame assumed if NULL) */
501+
/*!< Array of instanceCount transform headers (optional: per object frame assumed if nullptr) */
502502
hiprtDevicePtr instanceTransformHeaders;
503503
/*!< Array of frameCount frames (supposed to be ordered according to time) */
504504
hiprtDevicePtr instanceFrames;
505-
/*!< Per object bit masks for instance masking (optional: if NULL masks treated as hiprtFullRayMask) */
505+
/*!< Per object bit masks for instance masking (optional: if nullptr masks treated as hiprtFullRayMask) */
506506
hiprtDevicePtr instanceMasks;
507507
/*!< Custom Bvh nodes (optional) */
508508
hiprtBvhNodeList nodeList;

0 commit comments

Comments
 (0)