Skip to content

Commit 7d2f55a

Browse files
authored
Merge pull request #19 from GPUOpen-LibrariesAndSDKs/feature/HRT-0-02001
hiprt 2.1
2 parents 853935b + e7b0073 commit 7d2f55a

66 files changed

Lines changed: 2240 additions & 1523 deletions

Some content is hidden

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

contrib/Orochi

Submodule Orochi updated 85 files

tutorials/00_context_creation/main.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
int main( int argc, char** argv )
2626
{
2727
const int deviceIndex = 0;
28-
29-
CHECK_ORO( (oroError)oroInitialize( ( oroApi )( ORO_API_HIP | ORO_API_CUDA ), 0 ) );
28+
29+
CHECK_ORO( (oroError)oroInitialize( (oroApi)( ORO_API_HIP | ORO_API_CUDA ), 0 ) );
3030

3131
CHECK_ORO( oroInit( 0 ) );
3232

@@ -45,11 +45,11 @@ int main( int argc, char** argv )
4545
ctxtInput.deviceType = hiprtDeviceNVIDIA;
4646
else
4747
ctxtInput.deviceType = hiprtDeviceAMD;
48-
ctxtInput.ctxt = oroGetRawCtx( oroCtx );
48+
ctxtInput.ctxt = oroGetRawCtx( oroCtx );
4949
ctxtInput.device = oroGetRawDevice( oroDevice );
5050

5151
hiprtContext ctxt;
52-
CHECK_HIPRT( hiprtCreateContext( HIPRT_API_VERSION, ctxtInput, &ctxt ) );
52+
CHECK_HIPRT( hiprtCreateContext( HIPRT_API_VERSION, ctxtInput, ctxt ) );
5353
CHECK_HIPRT( hiprtDestroyContext( ctxt ) );
5454

5555
return 0;

tutorials/01_geom_intersection/main.cpp

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,60 +25,64 @@
2525
class Tutorial : public TutorialBase
2626
{
2727
public:
28-
void run()
28+
void run()
2929
{
3030
hiprtContext ctxt;
31-
CHECK_HIPRT( hiprtCreateContext( HIPRT_API_VERSION, m_ctxtInput, &ctxt ) );
31+
CHECK_HIPRT( hiprtCreateContext( HIPRT_API_VERSION, m_ctxtInput, ctxt ) );
3232

3333
hiprtTriangleMeshPrimitive mesh;
3434
mesh.triangleCount = 2;
3535
mesh.triangleStride = sizeof( hiprtInt3 );
3636
int triangleIndices[] = { 0, 1, 2, 3, 4, 5 };
37-
CHECK_ORO( oroMalloc( (oroDeviceptr*)&mesh.triangleIndices, mesh.triangleCount * sizeof( hiprtInt3 ) ) );
3837
CHECK_ORO(
39-
oroMemcpyHtoD( (oroDeviceptr)mesh.triangleIndices, triangleIndices, mesh.triangleCount * sizeof( hiprtInt3 ) ) );
38+
oroMalloc( reinterpret_cast<oroDeviceptr*>( &mesh.triangleIndices ), mesh.triangleCount * sizeof( hiprtInt3 ) ) );
39+
CHECK_ORO( oroMemcpyHtoD(
40+
reinterpret_cast<oroDeviceptr>( mesh.triangleIndices ),
41+
triangleIndices,
42+
mesh.triangleCount * sizeof( hiprtInt3 ) ) );
4043

41-
mesh.vertexCount = 6;
42-
mesh.vertexStride = sizeof( hiprtFloat3 );
44+
mesh.vertexCount = 6;
45+
mesh.vertexStride = sizeof( hiprtFloat3 );
4346
hiprtFloat3 vertices[] = {
4447
{ 0.0f, 0.0f, 0.0f },
4548
{ 1.0f, 0.0f, 0.0f },
4649
{ 0.5f, 1.0f, 0.0f },
4750
{ 0.0f, 0.0f, 1.0f },
4851
{ 1.0f, 0.0f, 1.0f },
4952
{ 0.5f, 1.0f, 1.0f } };
50-
CHECK_ORO( oroMalloc( (oroDeviceptr*)&mesh.vertices, mesh.vertexCount * sizeof( hiprtFloat3 ) ) );
51-
CHECK_ORO( oroMemcpyHtoD( (oroDeviceptr)mesh.vertices, vertices, mesh.vertexCount * sizeof( hiprtFloat3 ) ) );
53+
CHECK_ORO( oroMalloc( reinterpret_cast<oroDeviceptr*>( &mesh.vertices ), mesh.vertexCount * sizeof( hiprtFloat3 ) ) );
54+
CHECK_ORO( oroMemcpyHtoD(
55+
reinterpret_cast<oroDeviceptr>( mesh.vertices ), vertices, mesh.vertexCount * sizeof( hiprtFloat3 ) ) );
5256

5357
hiprtGeometryBuildInput geomInput;
5458
geomInput.type = hiprtPrimitiveTypeTriangleMesh;
55-
geomInput.triangleMesh.primitive = &mesh;
59+
geomInput.triangleMesh.primitive = mesh;
5660

5761
size_t geomTempSize;
5862
hiprtDevicePtr geomTemp;
5963
hiprtBuildOptions options;
6064
options.buildFlags = hiprtBuildFlagBitPreferFastBuild;
61-
CHECK_HIPRT( hiprtGetGeometryBuildTemporaryBufferSize( ctxt, &geomInput, &options, &geomTempSize ) );
62-
CHECK_ORO( oroMalloc( (oroDeviceptr*)&geomTemp, geomTempSize ) );
65+
CHECK_HIPRT( hiprtGetGeometryBuildTemporaryBufferSize( ctxt, geomInput, options, geomTempSize ) );
66+
CHECK_ORO( oroMalloc( reinterpret_cast<oroDeviceptr*>( &geomTemp ), geomTempSize ) );
6367

6468
hiprtGeometry geom;
65-
CHECK_HIPRT( hiprtCreateGeometry( ctxt, &geomInput, &options, &geom ) );
66-
CHECK_HIPRT( hiprtBuildGeometry( ctxt, hiprtBuildOperationBuild, &geomInput, &options, geomTemp, 0, geom ) );
69+
CHECK_HIPRT( hiprtCreateGeometry( ctxt, geomInput, options, geom ) );
70+
CHECK_HIPRT( hiprtBuildGeometry( ctxt, hiprtBuildOperationBuild, geomInput, options, geomTemp, 0, geom ) );
6771

6872
oroFunction func;
6973
buildTraceKernelFromBitcode( ctxt, "../common/TutorialKernels.h", "GeomIntersectionKernel", func );
7074

7175
u8* pixels;
72-
CHECK_ORO( oroMalloc( (oroDeviceptr*)&pixels, m_res.x * m_res.y * 4 ) );
76+
CHECK_ORO( oroMalloc( reinterpret_cast<oroDeviceptr*>( &pixels ), m_res.x * m_res.y * 4 ) );
7377

7478
void* args[] = { &geom, &pixels, &m_res };
7579
launchKernel( func, m_res.x, m_res.y, args );
7680
writeImage( "01_geom_intersection.png", m_res.x, m_res.y, pixels );
7781

78-
CHECK_ORO( oroFree( (oroDeviceptr)mesh.triangleIndices ) );
79-
CHECK_ORO( oroFree( (oroDeviceptr)mesh.vertices ) );
80-
CHECK_ORO( oroFree( (oroDeviceptr)geomTemp ) );
81-
CHECK_ORO( oroFree( (oroDeviceptr)pixels ) );
82+
CHECK_ORO( oroFree( reinterpret_cast<oroDeviceptr>( mesh.triangleIndices ) ) );
83+
CHECK_ORO( oroFree( reinterpret_cast<oroDeviceptr>( mesh.vertices ) ) );
84+
CHECK_ORO( oroFree( reinterpret_cast<oroDeviceptr>( geomTemp ) ) );
85+
CHECK_ORO( oroFree( reinterpret_cast<oroDeviceptr>( pixels ) ) );
8286

8387
CHECK_HIPRT( hiprtDestroyGeometry( ctxt, geom ) );
8488
CHECK_HIPRT( hiprtDestroyContext( ctxt ) );

tutorials/02_scene_intersection/TestKernel.h

Lines changed: 0 additions & 43 deletions
This file was deleted.

tutorials/02_scene_intersection/main.cpp

Lines changed: 34 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,21 @@
2525
class Tutorial : public TutorialBase
2626
{
2727
public:
28-
void run()
28+
void run()
2929
{
3030
hiprtContext ctxt;
31-
CHECK_HIPRT( hiprtCreateContext( HIPRT_API_VERSION, m_ctxtInput, &ctxt ) );
31+
CHECK_HIPRT( hiprtCreateContext( HIPRT_API_VERSION, m_ctxtInput, ctxt ) );
3232

3333
hiprtTriangleMeshPrimitive mesh;
34-
mesh.triangleCount = 2;
35-
mesh.triangleStride = sizeof( hiprtInt3 );
34+
mesh.triangleCount = 2;
35+
mesh.triangleStride = sizeof( hiprtInt3 );
3636
int triangleIndices[] = { 0, 1, 2, 3, 4, 5 };
37-
CHECK_ORO( oroMalloc( (oroDeviceptr*)&mesh.triangleIndices, mesh.triangleCount * sizeof( hiprtInt3 ) ) );
3837
CHECK_ORO(
39-
oroMemcpyHtoD( (oroDeviceptr)mesh.triangleIndices, triangleIndices, mesh.triangleCount * sizeof( hiprtInt3 ) ) );
38+
oroMalloc( reinterpret_cast<oroDeviceptr*>( &mesh.triangleIndices ), mesh.triangleCount * sizeof( hiprtInt3 ) ) );
39+
CHECK_ORO( oroMemcpyHtoD(
40+
reinterpret_cast<oroDeviceptr>( mesh.triangleIndices ),
41+
triangleIndices,
42+
mesh.triangleCount * sizeof( hiprtInt3 ) ) );
4043

4144
mesh.vertexCount = 6;
4245
mesh.vertexStride = sizeof( hiprtFloat3 );
@@ -49,65 +52,68 @@ class Tutorial : public TutorialBase
4952
{ -s, s, 0.0f },
5053
{ -s + t * s, -s * s, 0.0f },
5154
{ -s - t * s, -s * s, 0.0f } };
52-
CHECK_ORO( oroMalloc( (oroDeviceptr*)&mesh.vertices, mesh.vertexCount * sizeof( hiprtFloat3 ) ) );
53-
CHECK_ORO( oroMemcpyHtoD( (oroDeviceptr)mesh.vertices, vertices, mesh.vertexCount * sizeof( hiprtFloat3 ) ) );
55+
CHECK_ORO( oroMalloc( reinterpret_cast<oroDeviceptr*>( &mesh.vertices ), mesh.vertexCount * sizeof( hiprtFloat3 ) ) );
56+
CHECK_ORO( oroMemcpyHtoD(
57+
reinterpret_cast<oroDeviceptr>( mesh.vertices ), vertices, mesh.vertexCount * sizeof( hiprtFloat3 ) ) );
5458

5559
hiprtGeometryBuildInput geomInput;
5660
geomInput.type = hiprtPrimitiveTypeTriangleMesh;
57-
geomInput.triangleMesh.primitive = &mesh;
61+
geomInput.triangleMesh.primitive = mesh;
5862

5963
size_t geomTempSize;
6064
hiprtDevicePtr geomTemp;
6165
hiprtBuildOptions options;
6266
options.buildFlags = hiprtBuildFlagBitPreferFastBuild;
63-
CHECK_HIPRT( hiprtGetGeometryBuildTemporaryBufferSize( ctxt, &geomInput, &options, &geomTempSize ) );
64-
CHECK_ORO( oroMalloc( (oroDeviceptr*)&geomTemp, geomTempSize ) );
67+
CHECK_HIPRT( hiprtGetGeometryBuildTemporaryBufferSize( ctxt, geomInput, options, geomTempSize ) );
68+
CHECK_ORO( oroMalloc( reinterpret_cast<oroDeviceptr*>( &geomTemp ), geomTempSize ) );
6569

6670
hiprtGeometry geom;
67-
CHECK_HIPRT( hiprtCreateGeometry( ctxt, &geomInput, &options, &geom ) );
68-
CHECK_HIPRT( hiprtBuildGeometry( ctxt, hiprtBuildOperationBuild, &geomInput, &options, geomTemp, 0, geom ) );
71+
CHECK_HIPRT( hiprtCreateGeometry( ctxt, geomInput, options, geom ) );
72+
CHECK_HIPRT( hiprtBuildGeometry( ctxt, hiprtBuildOperationBuild, geomInput, options, geomTemp, 0, geom ) );
6973

7074
hiprtSceneBuildInput sceneInput;
7175
sceneInput.instanceCount = 1;
7276
sceneInput.instanceMasks = nullptr;
7377
sceneInput.instanceTransformHeaders = nullptr;
7478
hiprtDevicePtr geoms[] = { geom };
75-
CHECK_ORO( oroMalloc( (oroDeviceptr*)&sceneInput.instanceGeometries, sizeof( hiprtDevicePtr ) ) );
76-
CHECK_ORO( oroMemcpyHtoD( (oroDeviceptr)sceneInput.instanceGeometries, geoms, sizeof( hiprtDevicePtr ) ) );
79+
CHECK_ORO( oroMalloc( reinterpret_cast<oroDeviceptr*>( &sceneInput.instanceGeometries ), sizeof( hiprtDevicePtr ) ) );
80+
CHECK_ORO(
81+
oroMemcpyHtoD( reinterpret_cast<oroDeviceptr>( sceneInput.instanceGeometries ), geoms, sizeof( hiprtDevicePtr ) ) );
7782

7883
hiprtFrameSRT frame;
7984
frame.translation = make_hiprtFloat3( 0.0f, 0.0f, 0.0f );
8085
frame.scale = make_hiprtFloat3( 0.5f, 0.5f, 0.5f );
8186
frame.rotation = make_hiprtFloat4( 0.0f, 0.0f, 1.0f, 0.0f );
8287
sceneInput.frameCount = 1;
83-
CHECK_ORO( oroMalloc( (oroDeviceptr*)&sceneInput.instanceFrames, sizeof( hiprtFrameSRT ) ) );
84-
CHECK_ORO( oroMemcpyHtoD( (oroDeviceptr)sceneInput.instanceFrames, &frame, sizeof( hiprtFrameSRT ) ) );
88+
CHECK_ORO( oroMalloc( reinterpret_cast<oroDeviceptr*>( &sceneInput.instanceFrames ), sizeof( hiprtFrameSRT ) ) );
89+
CHECK_ORO(
90+
oroMemcpyHtoD( reinterpret_cast<oroDeviceptr>( sceneInput.instanceFrames ), &frame, sizeof( hiprtFrameSRT ) ) );
8591

8692
size_t sceneTempSize;
8793
hiprtDevicePtr sceneTemp;
88-
CHECK_HIPRT( hiprtGetSceneBuildTemporaryBufferSize( ctxt, &sceneInput, &options, &sceneTempSize ) );
89-
CHECK_ORO( oroMalloc( (oroDeviceptr*)&sceneTemp, sceneTempSize ) );
94+
CHECK_HIPRT( hiprtGetSceneBuildTemporaryBufferSize( ctxt, sceneInput, options, sceneTempSize ) );
95+
CHECK_ORO( oroMalloc( reinterpret_cast<oroDeviceptr*>( &sceneTemp ), sceneTempSize ) );
9096

9197
hiprtScene scene;
92-
CHECK_HIPRT( hiprtCreateScene( ctxt, &sceneInput, &options, &scene ) );
93-
CHECK_HIPRT( hiprtBuildScene( ctxt, hiprtBuildOperationBuild, &sceneInput, &options, sceneTemp, 0, scene ) );
98+
CHECK_HIPRT( hiprtCreateScene( ctxt, sceneInput, options, scene ) );
99+
CHECK_HIPRT( hiprtBuildScene( ctxt, hiprtBuildOperationBuild, sceneInput, options, sceneTemp, 0, scene ) );
94100

95101
oroFunction func;
96102
buildTraceKernelFromBitcode( ctxt, "../common/TutorialKernels.h", "SceneIntersectionKernel", func );
97103

98104
u8* pixels;
99-
CHECK_ORO( oroMalloc( (oroDeviceptr*)&pixels, m_res.x * m_res.y * 4 ) );
105+
CHECK_ORO( oroMalloc( reinterpret_cast<oroDeviceptr*>( &pixels ), m_res.x * m_res.y * 4 ) );
100106

101107
void* args[] = { &scene, &pixels, &m_res };
102108
launchKernel( func, m_res.x, m_res.y, args );
103109
writeImage( "02_scene_intersection.png", m_res.x, m_res.y, pixels );
104110

105-
CHECK_ORO( oroFree( (oroDeviceptr)sceneInput.instanceGeometries ) );
106-
CHECK_ORO( oroFree( (oroDeviceptr)sceneInput.instanceFrames ) );
107-
CHECK_ORO( oroFree( (oroDeviceptr)mesh.triangleIndices ) );
108-
CHECK_ORO( oroFree( (oroDeviceptr)mesh.vertices ) );
109-
CHECK_ORO( oroFree( (oroDeviceptr)geomTemp ) );
110-
CHECK_ORO( oroFree( (oroDeviceptr)pixels ) );
111+
CHECK_ORO( oroFree( reinterpret_cast<oroDeviceptr>( sceneInput.instanceGeometries ) ) );
112+
CHECK_ORO( oroFree( reinterpret_cast<oroDeviceptr>( sceneInput.instanceFrames ) ) );
113+
CHECK_ORO( oroFree( reinterpret_cast<oroDeviceptr>( mesh.triangleIndices ) ) );
114+
CHECK_ORO( oroFree( reinterpret_cast<oroDeviceptr>( mesh.vertices ) ) );
115+
CHECK_ORO( oroFree( reinterpret_cast<oroDeviceptr>( geomTemp ) ) );
116+
CHECK_ORO( oroFree( reinterpret_cast<oroDeviceptr>( pixels ) ) );
111117

112118
CHECK_HIPRT( hiprtDestroyGeometry( ctxt, geom ) );
113119
CHECK_HIPRT( hiprtDestroyScene( ctxt, scene ) );
@@ -123,5 +129,3 @@ int main( int argc, char** argv )
123129

124130
return 0;
125131
}
126-
127-

tutorials/03_custom_intersection/TestKernel.h

Lines changed: 0 additions & 82 deletions
This file was deleted.

0 commit comments

Comments
 (0)