-
Notifications
You must be signed in to change notification settings - Fork 562
Add HIP-RT support for rendering on AMD GPUs #473
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
base: master
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ | |
| .#* | ||
| #*# | ||
| src/build | ||
| src/ext/hiprtSdk/hiprt | ||
| .DS_Store | ||
| .ipynb_checkpoints/ | ||
| build/ | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
| @@ -0,0 +1,24 @@ | ||||
| From 56933471af36147e1032fbbc7912ca0088797b78 Mon Sep 17 00:00:00 2001 | ||||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this intended to be included?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm IIRC it was because libdeflate wasn't compiling due to some issue with BitScanReverse not being declared. Perhaps the CUDA SDK included the relevant intrin.h but not in the HIPCC path. It's applied here Line 1033 in 1b53728
A newer libdeflate commit seems to include the intrin.h though. Should we update the submodule to this commit |
||||
| From: Aaryaman Vasishta <[email protected]> | ||||
| Date: Sun, 10 Dec 2023 18:40:22 +0900 | ||||
| Subject: [PATCH] Fix BitScanreverse by including intrin.h for MSVC | ||||
|
|
||||
| --- | ||||
| common/compiler_msc.h | 1 + | ||||
| 1 file changed, 1 insertion(+) | ||||
|
|
||||
| diff --git a/common/compiler_msc.h b/common/compiler_msc.h | ||||
| index 18cfa12..2eafd55 100644 | ||||
| --- a/common/compiler_msc.h | ||||
| +++ b/common/compiler_msc.h | ||||
| @@ -4,6 +4,7 @@ | ||||
|
|
||||
| #include <stdint.h> | ||||
| #include <stdlib.h> /* for _byteswap_*() */ | ||||
| +#include <intrin.h> | ||||
|
|
||||
| #define LIBEXPORT __declspec(dllexport) | ||||
|
|
||||
| -- | ||||
| 2.33.0.windows.2 | ||||
|
|
||||
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,111 @@ | ||
| #ifndef PBRT_GPU_COMMON_H | ||
| #define PBRT_GPU_COMMON_H | ||
|
|
||
| #include <pbrt/pbrt.h> | ||
|
|
||
| #include <pbrt/base/light.h> | ||
| #include <pbrt/base/material.h> | ||
| #include <pbrt/base/medium.h> | ||
| #include <pbrt/base/shape.h> | ||
| #include <pbrt/base/texture.h> | ||
| #include <pbrt/util/pstd.h> | ||
| #include <pbrt/wavefront/workitems.h> | ||
| #include <pbrt/wavefront/workqueue.h> | ||
|
|
||
| #if defined(__HIPCC__) | ||
| #include <hiprt/hiprt.h> | ||
| #include <hiprt/hiprt_vec.h> | ||
| #else | ||
| #include <optix.h> | ||
| #endif | ||
|
|
||
| namespace pbrt { | ||
|
|
||
| class TriangleMesh; | ||
| class BilinearPatchMesh; | ||
|
|
||
| struct TriangleMeshRecord { | ||
| const TriangleMesh *mesh; | ||
| Material material; | ||
| FloatTexture alphaTexture; | ||
| pstd::span<Light> areaLights; | ||
| MediumInterface *mediumInterface; | ||
| }; | ||
|
|
||
| struct BilinearMeshRecord { | ||
| const BilinearPatchMesh *mesh; | ||
| Material material; | ||
| FloatTexture alphaTexture; | ||
| pstd::span<Light> areaLights; | ||
| MediumInterface *mediumInterface; | ||
| }; | ||
|
|
||
| struct QuadricRecord { | ||
| Shape shape; | ||
| Material material; | ||
| FloatTexture alphaTexture; | ||
| Light areaLight; | ||
| MediumInterface *mediumInterface; | ||
| }; | ||
|
|
||
| #if defined(__HIP_PLATFORM_AMD__) | ||
| static constexpr size_t HitgroupAlignment = 16u; | ||
|
|
||
| struct alignas(HitgroupAlignment) HitgroupRecord { | ||
| PBRT_CPU_GPU HitgroupRecord() {} | ||
| PBRT_CPU_GPU HitgroupRecord(const HitgroupRecord &r) { | ||
| memcpy(this, &r, sizeof(HitgroupRecord)); | ||
| } | ||
| PBRT_CPU_GPU HitgroupRecord &operator=(const HitgroupRecord &r) { | ||
| if (this != &r) | ||
| memcpy(this, &r, sizeof(HitgroupRecord)); | ||
| return *this; | ||
| } | ||
|
|
||
| union { | ||
| TriangleMeshRecord triRec; | ||
| BilinearMeshRecord blpRec; | ||
| QuadricRecord quadricRec; | ||
| }; | ||
| enum { TriangleMesh, BilinearMesh, Quadric } type; | ||
| }; | ||
| #endif | ||
|
|
||
| struct RayIntersectParameters { | ||
| #if defined(__HIPCC__) | ||
| hiprtScene traversable; | ||
| #else | ||
| OptixTraversableHandle traversable; | ||
| #endif | ||
|
|
||
| const RayQueue *rayQueue; | ||
|
|
||
| // Closest hit | ||
| RayQueue *nextRayQueue; | ||
| EscapedRayQueue *escapedRayQueue; | ||
| HitAreaLightQueue *hitAreaLightQueue; | ||
| MaterialEvalQueue *basicEvalMaterialQueue, *universalEvalMaterialQueue; | ||
| MediumSampleQueue *mediumSampleQueue; | ||
|
|
||
| // Shadow rays | ||
| ShadowRayQueue *shadowRayQueue; | ||
| SOA<PixelSampleState> pixelSampleState; | ||
|
|
||
| // Subsurface scattering... | ||
| SubsurfaceScatterQueue *subsurfaceScatterQueue; | ||
|
|
||
| #if defined(__HIPCC__) | ||
| // Stack buffers | ||
| hiprtGlobalStackBuffer globalStackBuffer; | ||
| hiprtGlobalStackBuffer globalInstanceStackBuffer; | ||
| // Custom function table | ||
| hiprtFuncTable funcTable; | ||
| // Hitgroup records | ||
| HitgroupRecord *hgRecords; | ||
| // Offsets for hitgroup records | ||
| uint32_t *offsets; | ||
| #endif | ||
| }; | ||
| } // namespace pbrt | ||
|
|
||
| #endif // PBRT_GPU_COMMON_H |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove? (Not sure if this is generally applicable.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this should not be included.