Upload 201 files
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- .gitattributes +5 -0
- ginipick:SORA-3D/3d.mp4 +3 -0
- ginipick:SORA-3D/README.md +11 -0
- ginipick:SORA-3D/app.py +2 -0
- ginipick:SORA-3D/assets/.DS_Store +0 -0
- ginipick:SORA-3D/assets/example_image/.DS_Store +0 -0
- ginipick:SORA-3D/assets/example_image/assets_example_image_image - 2024-12-08T120910.945.webp +0 -0
- ginipick:SORA-3D/assets/example_image/assets_example_image_image - 2024-12-08T133209.680.webp +0 -0
- ginipick:SORA-3D/assets/example_image/assets_example_image_image - 2024-12-08T133232.481.webp +0 -0
- ginipick:SORA-3D/assets/example_image/assets_example_image_image - 2024-12-08T133327.828.webp +0 -0
- ginipick:SORA-3D/assets/example_image/assets_example_image_image - 2024-12-08T133551.674.webp +0 -0
- ginipick:SORA-3D/assets/example_image/assets_example_image_image - 2024-12-08T133554.085.webp +0 -0
- ginipick:SORA-3D/assets/example_image/assets_example_image_image - 2024-12-08T133942.986.webp +0 -0
- ginipick:SORA-3D/assets/example_image/assets_example_image_image - 2024-12-08T133945.143.webp +0 -0
- ginipick:SORA-3D/assets/example_image/assets_example_image_image - 2024-12-08T134251.217.webp +0 -0
- ginipick:SORA-3D/assets/example_image/assets_example_image_image - 2024-12-08T134253.975.webp +0 -0
- ginipick:SORA-3D/assets/example_image/assets_example_image_image - 2024-12-08T134602.793.webp +0 -0
- ginipick:SORA-3D/assets/example_image/assets_example_image_image - 2024-12-08T134606.919.webp +0 -0
- ginipick:SORA-3D/assets/example_image/assets_example_image_image - 2024-12-09T050638.566.webp +0 -0
- ginipick:SORA-3D/assets/example_image/assets_example_image_image - 2024-12-09T102148.803.webp +0 -0
- ginipick:SORA-3D/assets/example_image/assets_example_image_image - 2024-12-09T124050.873.webp +0 -0
- ginipick:SORA-3D/assets/example_image/assets_example_image_image - 2024-12-09T125348.492.webp +0 -0
- ginipick:SORA-3D/assets/example_image/assets_example_image_image - 2024-12-09T125709.810.webp +0 -0
- ginipick:SORA-3D/assets/example_image/assets_example_image_image - 2024-12-09T125745.419.webp +0 -0
- ginipick:SORA-3D/assets/example_image/assets_example_image_image - 2024-12-09T131128.626.webp +0 -0
- ginipick:SORA-3D/assets/example_image/assets_example_image_image - 2024-12-09T174905.915.webp +0 -0
- ginipick:SORA-3D/assets/example_image/assets_example_image_image - 2024-12-09T184202.582.webp +0 -0
- ginipick:SORA-3D/assets/example_image/assets_example_image_image - 2024-12-09T184251.254.webp +3 -0
- ginipick:SORA-3D/assets/example_image/assets_example_image_image - 2024-12-09T184336.200.webp +0 -0
- ginipick:SORA-3D/assets/example_image/assets_example_image_image - 2024-12-09T184407.431.webp +0 -0
- ginipick:SORA-3D/assets/example_image/assets_example_image_image - 2024-12-09T184511.907.webp +3 -0
- ginipick:SORA-3D/assets/example_image/assets_example_image_image - 2024-12-09T184535.205.webp +0 -0
- ginipick:SORA-3D/assets/example_image/assets_example_image_image - 2024-12-09T184804.224.webp +0 -0
- ginipick:SORA-3D/assets/example_image/assets_example_image_image - 2024-12-10T033838.708.webp +0 -0
- ginipick:SORA-3D/assets/example_image/assets_example_image_image - 2024-12-10T034054.527.webp +0 -0
- ginipick:SORA-3D/assets/example_image/assets_example_image_image - 2024-12-10T034505.337.webp +0 -0
- ginipick:SORA-3D/extensions/.DS_Store +0 -0
- ginipick:SORA-3D/extensions/extensions_nvdiffrast_LICENSE.txt +97 -0
- ginipick:SORA-3D/extensions/extensions_nvdiffrast_README.md +42 -0
- ginipick:SORA-3D/extensions/extensions_nvdiffrast_run_sample.sh +52 -0
- ginipick:SORA-3D/extensions/extensions_nvdiffrast_setup copy.py +51 -0
- ginipick:SORA-3D/extensions/extensions_nvdiffrast_setup.py +82 -0
- ginipick:SORA-3D/extensions/nvdiffrast/.DS_Store +0 -0
- ginipick:SORA-3D/extensions/nvdiffrast/common/.DS_Store +0 -0
- ginipick:SORA-3D/extensions/nvdiffrast/common/cudaraster/.DS_Store +0 -0
- ginipick:SORA-3D/extensions/nvdiffrast/common/cudaraster/extensions_nvdiffrast_nvdiffrast_common_cudaraster_CudaRaster.hpp +63 -0
- ginipick:SORA-3D/extensions/nvdiffrast/common/cudaraster/impl/.DS_Store +0 -0
- ginipick:SORA-3D/extensions/nvdiffrast/common/cudaraster/impl/extensions_nvdiffrast_nvdiffrast_common_cudaraster_impl_BinRaster.inl +423 -0
- ginipick:SORA-3D/extensions/nvdiffrast/common/cudaraster/impl/extensions_nvdiffrast_nvdiffrast_common_cudaraster_impl_Buffer.cpp +94 -0
- ginipick:SORA-3D/extensions/nvdiffrast/common/cudaraster/impl/extensions_nvdiffrast_nvdiffrast_common_cudaraster_impl_Buffer.hpp +55 -0
.gitattributes
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
ginipick:SORA-3D/3d.mp4 filter=lfs diff=lfs merge=lfs -text
|
2 |
+
ginipick:SORA-3D/assets/example_image/assets_example_image_image[[:space:]]-[[:space:]]2024-12-09T184251.254.webp filter=lfs diff=lfs merge=lfs -text
|
3 |
+
ginipick:SORA-3D/assets/example_image/assets_example_image_image[[:space:]]-[[:space:]]2024-12-09T184511.907.webp filter=lfs diff=lfs merge=lfs -text
|
4 |
+
ginipick:SORA-3D/wheels/nvdiffrast-0.3.3-cp310-cp310-linux_x86_64.whl filter=lfs diff=lfs merge=lfs -text
|
5 |
+
ginipick:SORA-3D/wheels/wheels_diff_gaussian_rasterization-0.0.0-cp310-cp310-linux_x86_64.whl filter=lfs diff=lfs merge=lfs -text
|
ginipick:SORA-3D/3d.mp4
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:6c3282465210bac76f44b605956139679ed774c8bad9be686707d1b770961371
|
3 |
+
size 21309978
|
ginipick:SORA-3D/README.md
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
title: SORA 3D
|
3 |
+
emoji: 🏢🏆
|
4 |
+
colorFrom: indigo
|
5 |
+
colorTo: blue
|
6 |
+
sdk: gradio
|
7 |
+
sdk_version: 4.44.1
|
8 |
+
app_file: app.py
|
9 |
+
pinned: false
|
10 |
+
short_description: Create top-quality 3D(.GLB) models from text or images
|
11 |
+
---
|
ginipick:SORA-3D/app.py
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
exec(os.environ.get('APP'))
|
ginipick:SORA-3D/assets/.DS_Store
ADDED
Binary file (6.15 kB). View file
|
|
ginipick:SORA-3D/assets/example_image/.DS_Store
ADDED
Binary file (12.3 kB). View file
|
|
ginipick:SORA-3D/assets/example_image/assets_example_image_image - 2024-12-08T120910.945.webp
ADDED
![]() |
ginipick:SORA-3D/assets/example_image/assets_example_image_image - 2024-12-08T133209.680.webp
ADDED
![]() |
ginipick:SORA-3D/assets/example_image/assets_example_image_image - 2024-12-08T133232.481.webp
ADDED
![]() |
ginipick:SORA-3D/assets/example_image/assets_example_image_image - 2024-12-08T133327.828.webp
ADDED
![]() |
ginipick:SORA-3D/assets/example_image/assets_example_image_image - 2024-12-08T133551.674.webp
ADDED
![]() |
ginipick:SORA-3D/assets/example_image/assets_example_image_image - 2024-12-08T133554.085.webp
ADDED
![]() |
ginipick:SORA-3D/assets/example_image/assets_example_image_image - 2024-12-08T133942.986.webp
ADDED
![]() |
ginipick:SORA-3D/assets/example_image/assets_example_image_image - 2024-12-08T133945.143.webp
ADDED
![]() |
ginipick:SORA-3D/assets/example_image/assets_example_image_image - 2024-12-08T134251.217.webp
ADDED
![]() |
ginipick:SORA-3D/assets/example_image/assets_example_image_image - 2024-12-08T134253.975.webp
ADDED
![]() |
ginipick:SORA-3D/assets/example_image/assets_example_image_image - 2024-12-08T134602.793.webp
ADDED
![]() |
ginipick:SORA-3D/assets/example_image/assets_example_image_image - 2024-12-08T134606.919.webp
ADDED
![]() |
ginipick:SORA-3D/assets/example_image/assets_example_image_image - 2024-12-09T050638.566.webp
ADDED
![]() |
ginipick:SORA-3D/assets/example_image/assets_example_image_image - 2024-12-09T102148.803.webp
ADDED
![]() |
ginipick:SORA-3D/assets/example_image/assets_example_image_image - 2024-12-09T124050.873.webp
ADDED
![]() |
ginipick:SORA-3D/assets/example_image/assets_example_image_image - 2024-12-09T125348.492.webp
ADDED
![]() |
ginipick:SORA-3D/assets/example_image/assets_example_image_image - 2024-12-09T125709.810.webp
ADDED
![]() |
ginipick:SORA-3D/assets/example_image/assets_example_image_image - 2024-12-09T125745.419.webp
ADDED
![]() |
ginipick:SORA-3D/assets/example_image/assets_example_image_image - 2024-12-09T131128.626.webp
ADDED
![]() |
ginipick:SORA-3D/assets/example_image/assets_example_image_image - 2024-12-09T174905.915.webp
ADDED
![]() |
ginipick:SORA-3D/assets/example_image/assets_example_image_image - 2024-12-09T184202.582.webp
ADDED
![]() |
ginipick:SORA-3D/assets/example_image/assets_example_image_image - 2024-12-09T184251.254.webp
ADDED
![]() |
Git LFS Details
|
ginipick:SORA-3D/assets/example_image/assets_example_image_image - 2024-12-09T184336.200.webp
ADDED
![]() |
ginipick:SORA-3D/assets/example_image/assets_example_image_image - 2024-12-09T184407.431.webp
ADDED
![]() |
ginipick:SORA-3D/assets/example_image/assets_example_image_image - 2024-12-09T184511.907.webp
ADDED
![]() |
Git LFS Details
|
ginipick:SORA-3D/assets/example_image/assets_example_image_image - 2024-12-09T184535.205.webp
ADDED
![]() |
ginipick:SORA-3D/assets/example_image/assets_example_image_image - 2024-12-09T184804.224.webp
ADDED
![]() |
ginipick:SORA-3D/assets/example_image/assets_example_image_image - 2024-12-10T033838.708.webp
ADDED
![]() |
ginipick:SORA-3D/assets/example_image/assets_example_image_image - 2024-12-10T034054.527.webp
ADDED
![]() |
ginipick:SORA-3D/assets/example_image/assets_example_image_image - 2024-12-10T034505.337.webp
ADDED
![]() |
ginipick:SORA-3D/extensions/.DS_Store
ADDED
Binary file (6.15 kB). View file
|
|
ginipick:SORA-3D/extensions/extensions_nvdiffrast_LICENSE.txt
ADDED
@@ -0,0 +1,97 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Copyright (c) 2020, NVIDIA Corporation. All rights reserved.
|
2 |
+
|
3 |
+
|
4 |
+
Nvidia Source Code License (1-Way Commercial)
|
5 |
+
|
6 |
+
=======================================================================
|
7 |
+
|
8 |
+
1. Definitions
|
9 |
+
|
10 |
+
"Licensor" means any person or entity that distributes its Work.
|
11 |
+
|
12 |
+
"Software" means the original work of authorship made available under
|
13 |
+
this License.
|
14 |
+
|
15 |
+
"Work" means the Software and any additions to or derivative works of
|
16 |
+
the Software that are made available under this License.
|
17 |
+
|
18 |
+
The terms "reproduce," "reproduction," "derivative works," and
|
19 |
+
"distribution" have the meaning as provided under U.S. copyright law;
|
20 |
+
provided, however, that for the purposes of this License, derivative
|
21 |
+
works shall not include works that remain separable from, or merely
|
22 |
+
link (or bind by name) to the interfaces of, the Work.
|
23 |
+
|
24 |
+
Works, including the Software, are "made available" under this License
|
25 |
+
by including in or with the Work either (a) a copyright notice
|
26 |
+
referencing the applicability of this License to the Work, or (b) a
|
27 |
+
copy of this License.
|
28 |
+
|
29 |
+
2. License Grants
|
30 |
+
|
31 |
+
2.1 Copyright Grant. Subject to the terms and conditions of this
|
32 |
+
License, each Licensor grants to you a perpetual, worldwide,
|
33 |
+
non-exclusive, royalty-free, copyright license to reproduce,
|
34 |
+
prepare derivative works of, publicly display, publicly perform,
|
35 |
+
sublicense and distribute its Work and any resulting derivative
|
36 |
+
works in any form.
|
37 |
+
|
38 |
+
3. Limitations
|
39 |
+
|
40 |
+
3.1 Redistribution. You may reproduce or distribute the Work only
|
41 |
+
if (a) you do so under this License, (b) you include a complete
|
42 |
+
copy of this License with your distribution, and (c) you retain
|
43 |
+
without modification any copyright, patent, trademark, or
|
44 |
+
attribution notices that are present in the Work.
|
45 |
+
|
46 |
+
3.2 Derivative Works. You may specify that additional or different
|
47 |
+
terms apply to the use, reproduction, and distribution of your
|
48 |
+
derivative works of the Work ("Your Terms") only if (a) Your Terms
|
49 |
+
provide that the use limitation in Section 3.3 applies to your
|
50 |
+
derivative works, and (b) you identify the specific derivative
|
51 |
+
works that are subject to Your Terms. Notwithstanding Your Terms,
|
52 |
+
this License (including the redistribution requirements in Section
|
53 |
+
3.1) will continue to apply to the Work itself.
|
54 |
+
|
55 |
+
3.3 Use Limitation. The Work and any derivative works thereof only
|
56 |
+
may be used or intended for use non-commercially. The Work or
|
57 |
+
derivative works thereof may be used or intended for use by Nvidia
|
58 |
+
or its affiliates commercially or non-commercially. As used herein,
|
59 |
+
"non-commercially" means for research or evaluation purposes only
|
60 |
+
and not for any direct or indirect monetary gain.
|
61 |
+
|
62 |
+
3.4 Patent Claims. If you bring or threaten to bring a patent claim
|
63 |
+
against any Licensor (including any claim, cross-claim or
|
64 |
+
counterclaim in a lawsuit) to enforce any patents that you allege
|
65 |
+
are infringed by any Work, then your rights under this License from
|
66 |
+
such Licensor (including the grant in Section 2.1) will terminate
|
67 |
+
immediately.
|
68 |
+
|
69 |
+
3.5 Trademarks. This License does not grant any rights to use any
|
70 |
+
Licensor's or its affiliates' names, logos, or trademarks, except
|
71 |
+
as necessary to reproduce the notices described in this License.
|
72 |
+
|
73 |
+
3.6 Termination. If you violate any term of this License, then your
|
74 |
+
rights under this License (including the grant in Section 2.1) will
|
75 |
+
terminate immediately.
|
76 |
+
|
77 |
+
4. Disclaimer of Warranty.
|
78 |
+
|
79 |
+
THE WORK IS PROVIDED "AS IS" WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
80 |
+
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WARRANTIES OR CONDITIONS OF
|
81 |
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE OR
|
82 |
+
NON-INFRINGEMENT. YOU BEAR THE RISK OF UNDERTAKING ANY ACTIVITIES UNDER
|
83 |
+
THIS LICENSE.
|
84 |
+
|
85 |
+
5. Limitation of Liability.
|
86 |
+
|
87 |
+
EXCEPT AS PROHIBITED BY APPLICABLE LAW, IN NO EVENT AND UNDER NO LEGAL
|
88 |
+
THEORY, WHETHER IN TORT (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE
|
89 |
+
SHALL ANY LICENSOR BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY DIRECT,
|
90 |
+
INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
|
91 |
+
OR RELATED TO THIS LICENSE, THE USE OR INABILITY TO USE THE WORK
|
92 |
+
(INCLUDING BUT NOT LIMITED TO LOSS OF GOODWILL, BUSINESS INTERRUPTION,
|
93 |
+
LOST PROFITS OR DATA, COMPUTER FAILURE OR MALFUNCTION, OR ANY OTHER
|
94 |
+
COMMERCIAL DAMAGES OR LOSSES), EVEN IF THE LICENSOR HAS BEEN ADVISED OF
|
95 |
+
THE POSSIBILITY OF SUCH DAMAGES.
|
96 |
+
|
97 |
+
=======================================================================
|
ginipick:SORA-3D/extensions/extensions_nvdiffrast_README.md
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
## Nvdiffrast – Modular Primitives for High-Performance Differentiable Rendering
|
2 |
+
|
3 |
+

|
4 |
+
|
5 |
+
**Modular Primitives for High-Performance Differentiable Rendering**<br>
|
6 |
+
Samuli Laine, Janne Hellsten, Tero Karras, Yeongho Seol, Jaakko Lehtinen, Timo Aila<br>
|
7 |
+
[http://arxiv.org/abs/2011.03277](http://arxiv.org/abs/2011.03277)
|
8 |
+
|
9 |
+
Nvdiffrast is a PyTorch/TensorFlow library that provides high-performance primitive operations for rasterization-based differentiable rendering.
|
10 |
+
Please refer to ☞☞ [nvdiffrast documentation](https://nvlabs.github.io/nvdiffrast) ☜☜ for more information.
|
11 |
+
|
12 |
+
## Licenses
|
13 |
+
|
14 |
+
Copyright © 2020–2024, NVIDIA Corporation. All rights reserved.
|
15 |
+
|
16 |
+
This work is made available under the [Nvidia Source Code License](https://github.com/NVlabs/nvdiffrast/blob/main/LICENSE.txt).
|
17 |
+
|
18 |
+
For business inquiries, please visit our website and submit the form: [NVIDIA Research Licensing](https://www.nvidia.com/en-us/research/inquiries/)
|
19 |
+
|
20 |
+
We do not currently accept outside code contributions in the form of pull requests.
|
21 |
+
|
22 |
+
Environment map stored as part of `samples/data/envphong.npz` is derived from a Wave Engine
|
23 |
+
[sample material](https://github.com/WaveEngine/Samples-2.5/tree/master/Materials/EnvironmentMap/Content/Assets/CubeMap.cubemap)
|
24 |
+
originally shared under
|
25 |
+
[MIT License](https://github.com/WaveEngine/Samples-2.5/blob/master/LICENSE.md).
|
26 |
+
Mesh and texture stored as part of `samples/data/earth.npz` are derived from
|
27 |
+
[3D Earth Photorealistic 2K](https://www.turbosquid.com/3d-models/3d-realistic-earth-photorealistic-2k-1279125)
|
28 |
+
model originally made available under
|
29 |
+
[TurboSquid 3D Model License](https://blog.turbosquid.com/turbosquid-3d-model-license/#3d-model-license).
|
30 |
+
|
31 |
+
## Citation
|
32 |
+
|
33 |
+
```
|
34 |
+
@article{Laine2020diffrast,
|
35 |
+
title = {Modular Primitives for High-Performance Differentiable Rendering},
|
36 |
+
author = {Samuli Laine and Janne Hellsten and Tero Karras and Yeongho Seol and Jaakko Lehtinen and Timo Aila},
|
37 |
+
journal = {ACM Transactions on Graphics},
|
38 |
+
year = {2020},
|
39 |
+
volume = {39},
|
40 |
+
number = {6}
|
41 |
+
}
|
42 |
+
```
|
ginipick:SORA-3D/extensions/extensions_nvdiffrast_run_sample.sh
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/bin/bash
|
2 |
+
|
3 |
+
# Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved.
|
4 |
+
#
|
5 |
+
# NVIDIA CORPORATION and its licensors retain all intellectual property
|
6 |
+
# and proprietary rights in and to this software, related documentation
|
7 |
+
# and any modifications thereto. Any use, reproduction, disclosure or
|
8 |
+
# distribution of this software and related documentation without an express
|
9 |
+
# license agreement from NVIDIA CORPORATION is strictly prohibited.
|
10 |
+
|
11 |
+
function print_help {
|
12 |
+
echo "Usage: `basename $0` [--build-container] <python_file>"
|
13 |
+
echo ""
|
14 |
+
echo "Option --build-container will build the Docker container based on"
|
15 |
+
echo "docker/Dockerfile and tag the image with gltorch:latest."
|
16 |
+
echo ""
|
17 |
+
echo "Example: `basename $0` samples/torch/envphong.py"
|
18 |
+
}
|
19 |
+
|
20 |
+
build_container=0
|
21 |
+
sample=""
|
22 |
+
while [[ "$#" -gt 0 ]]; do
|
23 |
+
case $1 in
|
24 |
+
--build-container) build_container=1;;
|
25 |
+
-h|--help) print_help; exit 0 ;;
|
26 |
+
--*) echo "Unknown parameter passed: $1"; exit 1 ;;
|
27 |
+
*) sample="$1"; shift; break;
|
28 |
+
esac
|
29 |
+
shift
|
30 |
+
done
|
31 |
+
|
32 |
+
rest=$@
|
33 |
+
|
34 |
+
# Build the docker container
|
35 |
+
if [ "$build_container" = "1" ]; then
|
36 |
+
docker build --tag gltorch:latest -f docker/Dockerfile .
|
37 |
+
fi
|
38 |
+
|
39 |
+
if [ ! -f "$sample" ]; then
|
40 |
+
echo
|
41 |
+
echo "No python sample given or file '$sample' not found. Exiting."
|
42 |
+
exit 1
|
43 |
+
fi
|
44 |
+
|
45 |
+
image="gltorch:latest"
|
46 |
+
|
47 |
+
echo "Using container image: $image"
|
48 |
+
echo "Running command: $sample $rest"
|
49 |
+
|
50 |
+
# Run a sample with docker
|
51 |
+
docker run --rm -it --gpus all --user $(id -u):$(id -g) \
|
52 |
+
-v `pwd`:/app --workdir /app -e TORCH_EXTENSIONS_DIR=/app/tmp $image python3 $sample $rest
|
ginipick:SORA-3D/extensions/extensions_nvdiffrast_setup copy.py
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved.
|
2 |
+
#
|
3 |
+
# NVIDIA CORPORATION and its licensors retain all intellectual property
|
4 |
+
# and proprietary rights in and to this software, related documentation
|
5 |
+
# and any modifications thereto. Any use, reproduction, disclosure or
|
6 |
+
# distribution of this software and related documentation without an express
|
7 |
+
# license agreement from NVIDIA CORPORATION is strictly prohibited.
|
8 |
+
|
9 |
+
import nvdiffrast
|
10 |
+
import setuptools
|
11 |
+
import os
|
12 |
+
|
13 |
+
with open("README.md", "r") as fh:
|
14 |
+
long_description = fh.read()
|
15 |
+
|
16 |
+
setuptools.setup(
|
17 |
+
name="nvdiffrast",
|
18 |
+
version=nvdiffrast.__version__,
|
19 |
+
author="Samuli Laine",
|
20 |
+
author_email="slaine@nvidia.com",
|
21 |
+
description="nvdiffrast - modular primitives for high-performance differentiable rendering",
|
22 |
+
long_description=long_description,
|
23 |
+
long_description_content_type="text/markdown",
|
24 |
+
url="https://github.com/NVlabs/nvdiffrast",
|
25 |
+
packages=setuptools.find_packages(),
|
26 |
+
package_data={
|
27 |
+
'nvdiffrast': [
|
28 |
+
'common/*.h',
|
29 |
+
'common/*.inl',
|
30 |
+
'common/*.cu',
|
31 |
+
'common/*.cpp',
|
32 |
+
'common/cudaraster/*.hpp',
|
33 |
+
'common/cudaraster/impl/*.cpp',
|
34 |
+
'common/cudaraster/impl/*.hpp',
|
35 |
+
'common/cudaraster/impl/*.inl',
|
36 |
+
'common/cudaraster/impl/*.cu',
|
37 |
+
'lib/*.h',
|
38 |
+
'torch/*.h',
|
39 |
+
'torch/*.inl',
|
40 |
+
'torch/*.cpp',
|
41 |
+
'tensorflow/*.cu',
|
42 |
+
] + (['lib/*.lib'] if os.name == 'nt' else [])
|
43 |
+
},
|
44 |
+
include_package_data=True,
|
45 |
+
install_requires=['numpy'], # note: can't require torch here as it will install torch even for a TensorFlow container
|
46 |
+
classifiers=[
|
47 |
+
"Programming Language :: Python :: 3",
|
48 |
+
"Operating System :: OS Independent",
|
49 |
+
],
|
50 |
+
python_requires='>=3.6',
|
51 |
+
)
|
ginipick:SORA-3D/extensions/extensions_nvdiffrast_setup.py
ADDED
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved.
|
2 |
+
#
|
3 |
+
# NVIDIA CORPORATION and its licensors retain all intellectual property
|
4 |
+
# and proprietary rights in and to this software, related documentation
|
5 |
+
# and any modifications thereto. Any use, reproduction, disclosure or
|
6 |
+
# distribution of this software and related documentation without an express
|
7 |
+
# license agreement from NVIDIA CORPORATION is strictly prohibited.
|
8 |
+
|
9 |
+
import nvdiffrast
|
10 |
+
import setuptools
|
11 |
+
import os
|
12 |
+
from torch.utils.cpp_extension import CUDAExtension, BuildExtension
|
13 |
+
|
14 |
+
|
15 |
+
with open("README.md", "r") as fh:
|
16 |
+
long_description = fh.read()
|
17 |
+
|
18 |
+
setuptools.setup(
|
19 |
+
name="nvdiffrast",
|
20 |
+
version=nvdiffrast.__version__,
|
21 |
+
author="Samuli Laine",
|
22 |
+
author_email="slaine@nvidia.com",
|
23 |
+
description="nvdiffrast - modular primitives for high-performance differentiable rendering",
|
24 |
+
long_description=long_description,
|
25 |
+
long_description_content_type="text/markdown",
|
26 |
+
url="https://github.com/NVlabs/nvdiffrast",
|
27 |
+
packages=setuptools.find_packages(),
|
28 |
+
# package_data={
|
29 |
+
# 'nvdiffrast': [
|
30 |
+
# 'common/*.h',
|
31 |
+
# 'common/*.inl',
|
32 |
+
# 'common/*.cu',
|
33 |
+
# 'common/*.cpp',
|
34 |
+
# 'common/cudaraster/*.hpp',
|
35 |
+
# 'common/cudaraster/impl/*.cpp',
|
36 |
+
# 'common/cudaraster/impl/*.hpp',
|
37 |
+
# 'common/cudaraster/impl/*.inl',
|
38 |
+
# 'common/cudaraster/impl/*.cu',
|
39 |
+
# 'lib/*.h',
|
40 |
+
# 'torch/*.h',
|
41 |
+
# 'torch/*.inl',
|
42 |
+
# 'torch/*.cpp',
|
43 |
+
# 'tensorflow/*.cu',
|
44 |
+
# ] + (['lib/*.lib'] if os.name == 'nt' else [])
|
45 |
+
# },
|
46 |
+
# include_package_data=True,
|
47 |
+
ext_modules=[
|
48 |
+
CUDAExtension(
|
49 |
+
name="nvdiffrast.torch._C",
|
50 |
+
sources=[
|
51 |
+
'nvdiffrast/common/cudaraster/impl/Buffer.cpp',
|
52 |
+
'nvdiffrast/common/cudaraster/impl/CudaRaster.cpp',
|
53 |
+
'nvdiffrast/common/cudaraster/impl/RasterImpl_.cu',
|
54 |
+
'nvdiffrast/common/cudaraster/impl/RasterImpl.cpp',
|
55 |
+
'nvdiffrast/common/common.cpp',
|
56 |
+
'nvdiffrast/common/rasterize.cu',
|
57 |
+
'nvdiffrast/common/interpolate.cu',
|
58 |
+
'nvdiffrast/common/texture_.cu',
|
59 |
+
'nvdiffrast/common/texture.cpp',
|
60 |
+
'nvdiffrast/common/antialias.cu',
|
61 |
+
'nvdiffrast/torch/torch_bindings.cpp',
|
62 |
+
'nvdiffrast/torch/torch_rasterize.cpp',
|
63 |
+
'nvdiffrast/torch/torch_interpolate.cpp',
|
64 |
+
'nvdiffrast/torch/torch_texture.cpp',
|
65 |
+
'nvdiffrast/torch/torch_antialias.cpp',
|
66 |
+
],
|
67 |
+
extra_compile_args={
|
68 |
+
'cxx': ['-DNVDR_TORCH'],
|
69 |
+
'nvcc': ['-DNVDR_TORCH', '-lineinfo'],
|
70 |
+
},
|
71 |
+
)
|
72 |
+
],
|
73 |
+
cmdclass={
|
74 |
+
'build_ext': BuildExtension
|
75 |
+
},
|
76 |
+
install_requires=['numpy'], # note: can't require torch here as it will install torch even for a TensorFlow container
|
77 |
+
classifiers=[
|
78 |
+
"Programming Language :: Python :: 3",
|
79 |
+
"Operating System :: OS Independent",
|
80 |
+
],
|
81 |
+
python_requires='>=3.6',
|
82 |
+
)
|
ginipick:SORA-3D/extensions/nvdiffrast/.DS_Store
ADDED
Binary file (8.2 kB). View file
|
|
ginipick:SORA-3D/extensions/nvdiffrast/common/.DS_Store
ADDED
Binary file (10.2 kB). View file
|
|
ginipick:SORA-3D/extensions/nvdiffrast/common/cudaraster/.DS_Store
ADDED
Binary file (6.15 kB). View file
|
|
ginipick:SORA-3D/extensions/nvdiffrast/common/cudaraster/extensions_nvdiffrast_nvdiffrast_common_cudaraster_CudaRaster.hpp
ADDED
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// Copyright (c) 2009-2022, NVIDIA CORPORATION. All rights reserved.
|
2 |
+
//
|
3 |
+
// NVIDIA CORPORATION and its licensors retain all intellectual property
|
4 |
+
// and proprietary rights in and to this software, related documentation
|
5 |
+
// and any modifications thereto. Any use, reproduction, disclosure or
|
6 |
+
// distribution of this software and related documentation without an express
|
7 |
+
// license agreement from NVIDIA CORPORATION is strictly prohibited.
|
8 |
+
|
9 |
+
#pragma once
|
10 |
+
|
11 |
+
//------------------------------------------------------------------------
|
12 |
+
// This is a slimmed-down and modernized version of the original
|
13 |
+
// CudaRaster codebase that accompanied the HPG 2011 paper
|
14 |
+
// "High-Performance Software Rasterization on GPUs" by Laine and Karras.
|
15 |
+
// Modifications have been made to accommodate post-Volta execution model
|
16 |
+
// with warp divergence. Support for shading, blending, quad rendering,
|
17 |
+
// and supersampling have been removed as unnecessary for nvdiffrast.
|
18 |
+
//------------------------------------------------------------------------
|
19 |
+
|
20 |
+
namespace CR
|
21 |
+
{
|
22 |
+
|
23 |
+
class RasterImpl;
|
24 |
+
|
25 |
+
//------------------------------------------------------------------------
|
26 |
+
// Interface class to isolate user from implementation details.
|
27 |
+
//------------------------------------------------------------------------
|
28 |
+
|
29 |
+
class CudaRaster
|
30 |
+
{
|
31 |
+
public:
|
32 |
+
enum
|
33 |
+
{
|
34 |
+
RenderModeFlag_EnableBackfaceCulling = 1 << 0, // Enable backface culling.
|
35 |
+
RenderModeFlag_EnableDepthPeeling = 1 << 1, // Enable depth peeling. Must have a peel buffer set.
|
36 |
+
};
|
37 |
+
|
38 |
+
public:
|
39 |
+
CudaRaster (void);
|
40 |
+
~CudaRaster (void);
|
41 |
+
|
42 |
+
void setBufferSize (int width, int height, int numImages); // Width and height are internally rounded up to multiples of tile size (8x8) for buffer sizes.
|
43 |
+
void setViewport (int width, int height, int offsetX, int offsetY); // Tiled rendering viewport setup.
|
44 |
+
void setRenderModeFlags (unsigned int renderModeFlags); // Affects all subsequent calls to drawTriangles(). Defaults to zero.
|
45 |
+
void deferredClear (unsigned int clearColor); // Clears color and depth buffers during next call to drawTriangles().
|
46 |
+
void setVertexBuffer (void* vertices, int numVertices); // GPU pointer managed by caller. Vertex positions in clip space as float4 (x, y, z, w).
|
47 |
+
void setIndexBuffer (void* indices, int numTriangles); // GPU pointer managed by caller. Triangle index+color quadruplets as uint4 (idx0, idx1, idx2, color).
|
48 |
+
bool drawTriangles (const int* ranges, bool peel, cudaStream_t stream); // Ranges (offsets and counts) as #triangles entries, not as bytes. If NULL, draw all triangles. Returns false in case of internal overflow.
|
49 |
+
void* getColorBuffer (void); // GPU pointer managed by CudaRaster.
|
50 |
+
void* getDepthBuffer (void); // GPU pointer managed by CudaRaster.
|
51 |
+
void swapDepthAndPeel (void); // Swap depth and peeling buffers.
|
52 |
+
|
53 |
+
private:
|
54 |
+
CudaRaster (const CudaRaster&); // forbidden
|
55 |
+
CudaRaster& operator= (const CudaRaster&); // forbidden
|
56 |
+
|
57 |
+
private:
|
58 |
+
RasterImpl* m_impl; // Opaque pointer to implementation.
|
59 |
+
};
|
60 |
+
|
61 |
+
//------------------------------------------------------------------------
|
62 |
+
} // namespace CR
|
63 |
+
|
ginipick:SORA-3D/extensions/nvdiffrast/common/cudaraster/impl/.DS_Store
ADDED
Binary file (10.2 kB). View file
|
|
ginipick:SORA-3D/extensions/nvdiffrast/common/cudaraster/impl/extensions_nvdiffrast_nvdiffrast_common_cudaraster_impl_BinRaster.inl
ADDED
@@ -0,0 +1,423 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// Copyright (c) 2009-2022, NVIDIA CORPORATION. All rights reserved.
|
2 |
+
//
|
3 |
+
// NVIDIA CORPORATION and its licensors retain all intellectual property
|
4 |
+
// and proprietary rights in and to this software, related documentation
|
5 |
+
// and any modifications thereto. Any use, reproduction, disclosure or
|
6 |
+
// distribution of this software and related documentation without an express
|
7 |
+
// license agreement from NVIDIA CORPORATION is strictly prohibited.
|
8 |
+
|
9 |
+
//------------------------------------------------------------------------
|
10 |
+
|
11 |
+
__device__ __inline__ void binRasterImpl(const CRParams p)
|
12 |
+
{
|
13 |
+
__shared__ volatile U32 s_broadcast [CR_BIN_WARPS + 16];
|
14 |
+
__shared__ volatile S32 s_outOfs [CR_MAXBINS_SQR];
|
15 |
+
__shared__ volatile S32 s_outTotal [CR_MAXBINS_SQR];
|
16 |
+
__shared__ volatile S32 s_overIndex [CR_MAXBINS_SQR];
|
17 |
+
__shared__ volatile S32 s_outMask [CR_BIN_WARPS][CR_MAXBINS_SQR + 1]; // +1 to avoid bank collisions
|
18 |
+
__shared__ volatile S32 s_outCount [CR_BIN_WARPS][CR_MAXBINS_SQR + 1]; // +1 to avoid bank collisions
|
19 |
+
__shared__ volatile S32 s_triBuf [CR_BIN_WARPS*32*4]; // triangle ring buffer
|
20 |
+
__shared__ volatile U32 s_batchPos;
|
21 |
+
__shared__ volatile U32 s_bufCount;
|
22 |
+
__shared__ volatile U32 s_overTotal;
|
23 |
+
__shared__ volatile U32 s_allocBase;
|
24 |
+
|
25 |
+
const CRImageParams& ip = getImageParams(p, blockIdx.z);
|
26 |
+
CRAtomics& atomics = p.atomics[blockIdx.z];
|
27 |
+
const U8* triSubtris = (const U8*)p.triSubtris + p.maxSubtris * blockIdx.z;
|
28 |
+
const CRTriangleHeader* triHeader = (const CRTriangleHeader*)p.triHeader + p.maxSubtris * blockIdx.z;
|
29 |
+
|
30 |
+
S32* binFirstSeg = (S32*)p.binFirstSeg + CR_MAXBINS_SQR * CR_BIN_STREAMS_SIZE * blockIdx.z;
|
31 |
+
S32* binTotal = (S32*)p.binTotal + CR_MAXBINS_SQR * CR_BIN_STREAMS_SIZE * blockIdx.z;
|
32 |
+
S32* binSegData = (S32*)p.binSegData + p.maxBinSegs * CR_BIN_SEG_SIZE * blockIdx.z;
|
33 |
+
S32* binSegNext = (S32*)p.binSegNext + p.maxBinSegs * blockIdx.z;
|
34 |
+
S32* binSegCount = (S32*)p.binSegCount + p.maxBinSegs * blockIdx.z;
|
35 |
+
|
36 |
+
if (atomics.numSubtris > p.maxSubtris)
|
37 |
+
return;
|
38 |
+
|
39 |
+
// per-thread state
|
40 |
+
int thrInBlock = threadIdx.x + threadIdx.y * 32;
|
41 |
+
int batchPos = 0;
|
42 |
+
|
43 |
+
// first 16 elements of s_broadcast are always zero
|
44 |
+
if (thrInBlock < 16)
|
45 |
+
s_broadcast[thrInBlock] = 0;
|
46 |
+
|
47 |
+
// initialize output linked lists and offsets
|
48 |
+
if (thrInBlock < p.numBins)
|
49 |
+
{
|
50 |
+
binFirstSeg[(thrInBlock << CR_BIN_STREAMS_LOG2) + blockIdx.x] = -1;
|
51 |
+
s_outOfs[thrInBlock] = -CR_BIN_SEG_SIZE;
|
52 |
+
s_outTotal[thrInBlock] = 0;
|
53 |
+
}
|
54 |
+
|
55 |
+
// repeat until done
|
56 |
+
for(;;)
|
57 |
+
{
|
58 |
+
// get batch
|
59 |
+
if (thrInBlock == 0)
|
60 |
+
s_batchPos = atomicAdd(&atomics.binCounter, ip.binBatchSize);
|
61 |
+
__syncthreads();
|
62 |
+
batchPos = s_batchPos;
|
63 |
+
|
64 |
+
// all batches done?
|
65 |
+
if (batchPos >= ip.triCount)
|
66 |
+
break;
|
67 |
+
|
68 |
+
// per-thread state
|
69 |
+
int bufIndex = 0;
|
70 |
+
int bufCount = 0;
|
71 |
+
int batchEnd = min(batchPos + ip.binBatchSize, ip.triCount);
|
72 |
+
|
73 |
+
// loop over batch as long as we have triangles in it
|
74 |
+
do
|
75 |
+
{
|
76 |
+
// read more triangles
|
77 |
+
while (bufCount < CR_BIN_WARPS*32 && batchPos < batchEnd)
|
78 |
+
{
|
79 |
+
// get subtriangle count
|
80 |
+
|
81 |
+
int triIdx = batchPos + thrInBlock;
|
82 |
+
int num = 0;
|
83 |
+
if (triIdx < batchEnd)
|
84 |
+
num = triSubtris[triIdx];
|
85 |
+
|
86 |
+
// cumulative sum of subtriangles within each warp
|
87 |
+
U32 myIdx = __popc(__ballot_sync(~0u, num & 1) & getLaneMaskLt());
|
88 |
+
if (__any_sync(~0u, num > 1))
|
89 |
+
{
|
90 |
+
myIdx += __popc(__ballot_sync(~0u, num & 2) & getLaneMaskLt()) * 2;
|
91 |
+
myIdx += __popc(__ballot_sync(~0u, num & 4) & getLaneMaskLt()) * 4;
|
92 |
+
}
|
93 |
+
if (threadIdx.x == 31) // Do not assume that last thread in warp wins the write.
|
94 |
+
s_broadcast[threadIdx.y + 16] = myIdx + num;
|
95 |
+
__syncthreads();
|
96 |
+
|
97 |
+
// cumulative sum of per-warp subtriangle counts
|
98 |
+
// Note: cannot have more than 32 warps or this needs to sync between each step.
|
99 |
+
bool act = (thrInBlock < CR_BIN_WARPS);
|
100 |
+
U32 actMask = __ballot_sync(~0u, act);
|
101 |
+
if (threadIdx.y == 0 && act)
|
102 |
+
{
|
103 |
+
volatile U32* ptr = &s_broadcast[thrInBlock + 16];
|
104 |
+
U32 val = *ptr;
|
105 |
+
#if (CR_BIN_WARPS > 1)
|
106 |
+
val += ptr[-1]; __syncwarp(actMask);
|
107 |
+
*ptr = val; __syncwarp(actMask);
|
108 |
+
#endif
|
109 |
+
#if (CR_BIN_WARPS > 2)
|
110 |
+
val += ptr[-2]; __syncwarp(actMask);
|
111 |
+
*ptr = val; __syncwarp(actMask);
|
112 |
+
#endif
|
113 |
+
#if (CR_BIN_WARPS > 4)
|
114 |
+
val += ptr[-4]; __syncwarp(actMask);
|
115 |
+
*ptr = val; __syncwarp(actMask);
|
116 |
+
#endif
|
117 |
+
#if (CR_BIN_WARPS > 8)
|
118 |
+
val += ptr[-8]; __syncwarp(actMask);
|
119 |
+
*ptr = val; __syncwarp(actMask);
|
120 |
+
#endif
|
121 |
+
#if (CR_BIN_WARPS > 16)
|
122 |
+
val += ptr[-16]; __syncwarp(actMask);
|
123 |
+
*ptr = val; __syncwarp(actMask);
|
124 |
+
#endif
|
125 |
+
|
126 |
+
// initially assume that we consume everything
|
127 |
+
// only last active thread does the writes
|
128 |
+
if (threadIdx.x == CR_BIN_WARPS - 1)
|
129 |
+
{
|
130 |
+
s_batchPos = batchPos + CR_BIN_WARPS * 32;
|
131 |
+
s_bufCount = bufCount + val;
|
132 |
+
}
|
133 |
+
}
|
134 |
+
__syncthreads();
|
135 |
+
|
136 |
+
// skip if no subtriangles
|
137 |
+
if (num)
|
138 |
+
{
|
139 |
+
// calculate write position for first subtriangle
|
140 |
+
U32 pos = bufCount + myIdx + s_broadcast[threadIdx.y + 16 - 1];
|
141 |
+
|
142 |
+
// only write if entire triangle fits
|
143 |
+
if (pos + num <= CR_ARRAY_SIZE(s_triBuf))
|
144 |
+
{
|
145 |
+
pos += bufIndex; // adjust for current start position
|
146 |
+
pos &= CR_ARRAY_SIZE(s_triBuf)-1;
|
147 |
+
if (num == 1)
|
148 |
+
s_triBuf[pos] = triIdx * 8 + 7; // single triangle
|
149 |
+
else
|
150 |
+
{
|
151 |
+
for (int i=0; i < num; i++)
|
152 |
+
{
|
153 |
+
s_triBuf[pos] = triIdx * 8 + i;
|
154 |
+
pos++;
|
155 |
+
pos &= CR_ARRAY_SIZE(s_triBuf)-1;
|
156 |
+
}
|
157 |
+
}
|
158 |
+
} else if (pos <= CR_ARRAY_SIZE(s_triBuf))
|
159 |
+
{
|
160 |
+
// this triangle is the first that failed, overwrite total count and triangle count
|
161 |
+
s_batchPos = batchPos + thrInBlock;
|
162 |
+
s_bufCount = pos;
|
163 |
+
}
|
164 |
+
}
|
165 |
+
|
166 |
+
// update triangle counts
|
167 |
+
__syncthreads();
|
168 |
+
batchPos = s_batchPos;
|
169 |
+
bufCount = s_bufCount;
|
170 |
+
}
|
171 |
+
|
172 |
+
// make every warp clear its output buffers
|
173 |
+
for (int i=threadIdx.x; i < p.numBins; i += 32)
|
174 |
+
s_outMask[threadIdx.y][i] = 0;
|
175 |
+
__syncwarp();
|
176 |
+
|
177 |
+
// choose our triangle
|
178 |
+
uint4 triData = make_uint4(0, 0, 0, 0);
|
179 |
+
if (thrInBlock < bufCount)
|
180 |
+
{
|
181 |
+
U32 triPos = bufIndex + thrInBlock;
|
182 |
+
triPos &= CR_ARRAY_SIZE(s_triBuf)-1;
|
183 |
+
|
184 |
+
// find triangle
|
185 |
+
int triIdx = s_triBuf[triPos];
|
186 |
+
int dataIdx = triIdx >> 3;
|
187 |
+
int subtriIdx = triIdx & 7;
|
188 |
+
if (subtriIdx != 7)
|
189 |
+
dataIdx = triHeader[dataIdx].misc + subtriIdx;
|
190 |
+
|
191 |
+
// read triangle
|
192 |
+
|
193 |
+
triData = *(((const uint4*)triHeader) + dataIdx);
|
194 |
+
}
|
195 |
+
|
196 |
+
// setup bounding box and edge functions, and rasterize
|
197 |
+
S32 lox, loy, hix, hiy;
|
198 |
+
bool hasTri = (thrInBlock < bufCount);
|
199 |
+
U32 hasTriMask = __ballot_sync(~0u, hasTri);
|
200 |
+
if (hasTri)
|
201 |
+
{
|
202 |
+
S32 v0x = add_s16lo_s16lo(triData.x, p.widthPixelsVp * (CR_SUBPIXEL_SIZE >> 1));
|
203 |
+
S32 v0y = add_s16hi_s16lo(triData.x, p.heightPixelsVp * (CR_SUBPIXEL_SIZE >> 1));
|
204 |
+
S32 d01x = sub_s16lo_s16lo(triData.y, triData.x);
|
205 |
+
S32 d01y = sub_s16hi_s16hi(triData.y, triData.x);
|
206 |
+
S32 d02x = sub_s16lo_s16lo(triData.z, triData.x);
|
207 |
+
S32 d02y = sub_s16hi_s16hi(triData.z, triData.x);
|
208 |
+
int binLog = CR_BIN_LOG2 + CR_TILE_LOG2 + CR_SUBPIXEL_LOG2;
|
209 |
+
lox = add_clamp_0_x((v0x + min_min(d01x, 0, d02x)) >> binLog, 0, p.widthBins - 1);
|
210 |
+
loy = add_clamp_0_x((v0y + min_min(d01y, 0, d02y)) >> binLog, 0, p.heightBins - 1);
|
211 |
+
hix = add_clamp_0_x((v0x + max_max(d01x, 0, d02x)) >> binLog, 0, p.widthBins - 1);
|
212 |
+
hiy = add_clamp_0_x((v0y + max_max(d01y, 0, d02y)) >> binLog, 0, p.heightBins - 1);
|
213 |
+
|
214 |
+
U32 bit = 1 << threadIdx.x;
|
215 |
+
#if __CUDA_ARCH__ >= 700
|
216 |
+
bool multi = (hix != lox || hiy != loy);
|
217 |
+
if (!__any_sync(hasTriMask, multi))
|
218 |
+
{
|
219 |
+
int binIdx = lox + p.widthBins * loy;
|
220 |
+
U32 mask = __match_any_sync(hasTriMask, binIdx);
|
221 |
+
s_outMask[threadIdx.y][binIdx] = mask;
|
222 |
+
__syncwarp(hasTriMask);
|
223 |
+
} else
|
224 |
+
#endif
|
225 |
+
{
|
226 |
+
bool complex = (hix > lox+1 || hiy > loy+1);
|
227 |
+
if (!__any_sync(hasTriMask, complex))
|
228 |
+
{
|
229 |
+
int binIdx = lox + p.widthBins * loy;
|
230 |
+
atomicOr((U32*)&s_outMask[threadIdx.y][binIdx], bit);
|
231 |
+
if (hix > lox) atomicOr((U32*)&s_outMask[threadIdx.y][binIdx + 1], bit);
|
232 |
+
if (hiy > loy) atomicOr((U32*)&s_outMask[threadIdx.y][binIdx + p.widthBins], bit);
|
233 |
+
if (hix > lox && hiy > loy) atomicOr((U32*)&s_outMask[threadIdx.y][binIdx + p.widthBins + 1], bit);
|
234 |
+
} else
|
235 |
+
{
|
236 |
+
S32 d12x = d02x - d01x, d12y = d02y - d01y;
|
237 |
+
v0x -= lox << binLog, v0y -= loy << binLog;
|
238 |
+
|
239 |
+
S32 t01 = v0x * d01y - v0y * d01x;
|
240 |
+
S32 t02 = v0y * d02x - v0x * d02y;
|
241 |
+
S32 t12 = d01x * d12y - d01y * d12x - t01 - t02;
|
242 |
+
S32 b01 = add_sub(t01 >> binLog, max(d01x, 0), min(d01y, 0));
|
243 |
+
S32 b02 = add_sub(t02 >> binLog, max(d02y, 0), min(d02x, 0));
|
244 |
+
S32 b12 = add_sub(t12 >> binLog, max(d12x, 0), min(d12y, 0));
|
245 |
+
|
246 |
+
int width = hix - lox + 1;
|
247 |
+
d01x += width * d01y;
|
248 |
+
d02x += width * d02y;
|
249 |
+
d12x += width * d12y;
|
250 |
+
|
251 |
+
U8* currPtr = (U8*)&s_outMask[threadIdx.y][lox + loy * p.widthBins];
|
252 |
+
U8* skipPtr = (U8*)&s_outMask[threadIdx.y][(hix + 1) + loy * p.widthBins];
|
253 |
+
U8* endPtr = (U8*)&s_outMask[threadIdx.y][lox + (hiy + 1) * p.widthBins];
|
254 |
+
int stride = p.widthBins * 4;
|
255 |
+
int ptrYInc = stride - width * 4;
|
256 |
+
|
257 |
+
do
|
258 |
+
{
|
259 |
+
if (b01 >= 0 && b02 >= 0 && b12 >= 0)
|
260 |
+
atomicOr((U32*)currPtr, bit);
|
261 |
+
currPtr += 4, b01 -= d01y, b02 += d02y, b12 -= d12y;
|
262 |
+
if (currPtr == skipPtr)
|
263 |
+
currPtr += ptrYInc, b01 += d01x, b02 -= d02x, b12 += d12x, skipPtr += stride;
|
264 |
+
}
|
265 |
+
while (currPtr != endPtr);
|
266 |
+
}
|
267 |
+
}
|
268 |
+
}
|
269 |
+
|
270 |
+
// count per-bin contributions
|
271 |
+
if (thrInBlock == 0)
|
272 |
+
s_overTotal = 0; // overflow counter
|
273 |
+
|
274 |
+
// ensure that out masks are done
|
275 |
+
__syncthreads();
|
276 |
+
|
277 |
+
int overIndex = -1;
|
278 |
+
bool act = (thrInBlock < p.numBins);
|
279 |
+
U32 actMask = __ballot_sync(~0u, act);
|
280 |
+
if (act)
|
281 |
+
{
|
282 |
+
U8* srcPtr = (U8*)&s_outMask[0][thrInBlock];
|
283 |
+
U8* dstPtr = (U8*)&s_outCount[0][thrInBlock];
|
284 |
+
int total = 0;
|
285 |
+
for (int i = 0; i < CR_BIN_WARPS; i++)
|
286 |
+
{
|
287 |
+
total += __popc(*(U32*)srcPtr);
|
288 |
+
*(U32*)dstPtr = total;
|
289 |
+
srcPtr += (CR_MAXBINS_SQR + 1) * 4;
|
290 |
+
dstPtr += (CR_MAXBINS_SQR + 1) * 4;
|
291 |
+
}
|
292 |
+
|
293 |
+
// overflow => request a new segment
|
294 |
+
int ofs = s_outOfs[thrInBlock];
|
295 |
+
bool ovr = (((ofs - 1) >> CR_BIN_SEG_LOG2) != (((ofs - 1) + total) >> CR_BIN_SEG_LOG2));
|
296 |
+
U32 ovrMask = __ballot_sync(actMask, ovr);
|
297 |
+
if (ovr)
|
298 |
+
{
|
299 |
+
overIndex = __popc(ovrMask & getLaneMaskLt());
|
300 |
+
if (overIndex == 0)
|
301 |
+
s_broadcast[threadIdx.y + 16] = atomicAdd((U32*)&s_overTotal, __popc(ovrMask));
|
302 |
+
__syncwarp(ovrMask);
|
303 |
+
overIndex += s_broadcast[threadIdx.y + 16];
|
304 |
+
s_overIndex[thrInBlock] = overIndex;
|
305 |
+
}
|
306 |
+
}
|
307 |
+
|
308 |
+
// sync after overTotal is ready
|
309 |
+
__syncthreads();
|
310 |
+
|
311 |
+
// at least one segment overflowed => allocate segments
|
312 |
+
U32 overTotal = s_overTotal;
|
313 |
+
U32 allocBase = 0;
|
314 |
+
if (overTotal > 0)
|
315 |
+
{
|
316 |
+
// allocate memory
|
317 |
+
if (thrInBlock == 0)
|
318 |
+
{
|
319 |
+
U32 allocBase = atomicAdd(&atomics.numBinSegs, overTotal);
|
320 |
+
s_allocBase = (allocBase + overTotal <= p.maxBinSegs) ? allocBase : 0;
|
321 |
+
}
|
322 |
+
__syncthreads();
|
323 |
+
allocBase = s_allocBase;
|
324 |
+
|
325 |
+
// did my bin overflow?
|
326 |
+
if (overIndex != -1)
|
327 |
+
{
|
328 |
+
// calculate new segment index
|
329 |
+
int segIdx = allocBase + overIndex;
|
330 |
+
|
331 |
+
// add to linked list
|
332 |
+
if (s_outOfs[thrInBlock] < 0)
|
333 |
+
binFirstSeg[(thrInBlock << CR_BIN_STREAMS_LOG2) + blockIdx.x] = segIdx;
|
334 |
+
else
|
335 |
+
binSegNext[(s_outOfs[thrInBlock] - 1) >> CR_BIN_SEG_LOG2] = segIdx;
|
336 |
+
|
337 |
+
// defaults
|
338 |
+
binSegNext [segIdx] = -1;
|
339 |
+
binSegCount[segIdx] = CR_BIN_SEG_SIZE;
|
340 |
+
}
|
341 |
+
}
|
342 |
+
|
343 |
+
// concurrent emission -- each warp handles its own triangle
|
344 |
+
if (thrInBlock < bufCount)
|
345 |
+
{
|
346 |
+
int triPos = (bufIndex + thrInBlock) & (CR_ARRAY_SIZE(s_triBuf) - 1);
|
347 |
+
int currBin = lox + loy * p.widthBins;
|
348 |
+
int skipBin = (hix + 1) + loy * p.widthBins;
|
349 |
+
int endBin = lox + (hiy + 1) * p.widthBins;
|
350 |
+
int binYInc = p.widthBins - (hix - lox + 1);
|
351 |
+
|
352 |
+
// loop over triangle's bins
|
353 |
+
do
|
354 |
+
{
|
355 |
+
U32 outMask = s_outMask[threadIdx.y][currBin];
|
356 |
+
if (outMask & (1<<threadIdx.x))
|
357 |
+
{
|
358 |
+
int idx = __popc(outMask & getLaneMaskLt());
|
359 |
+
if (threadIdx.y > 0)
|
360 |
+
idx += s_outCount[threadIdx.y-1][currBin];
|
361 |
+
|
362 |
+
int base = s_outOfs[currBin];
|
363 |
+
int free = (-base) & (CR_BIN_SEG_SIZE - 1);
|
364 |
+
if (idx >= free)
|
365 |
+
idx += ((allocBase + s_overIndex[currBin]) << CR_BIN_SEG_LOG2) - free;
|
366 |
+
else
|
367 |
+
idx += base;
|
368 |
+
|
369 |
+
binSegData[idx] = s_triBuf[triPos];
|
370 |
+
}
|
371 |
+
|
372 |
+
currBin++;
|
373 |
+
if (currBin == skipBin)
|
374 |
+
currBin += binYInc, skipBin += p.widthBins;
|
375 |
+
}
|
376 |
+
while (currBin != endBin);
|
377 |
+
}
|
378 |
+
|
379 |
+
// wait all triangles to finish, then replace overflown segment offsets
|
380 |
+
__syncthreads();
|
381 |
+
if (thrInBlock < p.numBins)
|
382 |
+
{
|
383 |
+
U32 total = s_outCount[CR_BIN_WARPS - 1][thrInBlock];
|
384 |
+
U32 oldOfs = s_outOfs[thrInBlock];
|
385 |
+
if (overIndex == -1)
|
386 |
+
s_outOfs[thrInBlock] = oldOfs + total;
|
387 |
+
else
|
388 |
+
{
|
389 |
+
int addr = oldOfs + total;
|
390 |
+
addr = ((addr - 1) & (CR_BIN_SEG_SIZE - 1)) + 1;
|
391 |
+
addr += (allocBase + overIndex) << CR_BIN_SEG_LOG2;
|
392 |
+
s_outOfs[thrInBlock] = addr;
|
393 |
+
}
|
394 |
+
s_outTotal[thrInBlock] += total;
|
395 |
+
}
|
396 |
+
|
397 |
+
// these triangles are now done
|
398 |
+
int count = ::min(bufCount, CR_BIN_WARPS * 32);
|
399 |
+
bufCount -= count;
|
400 |
+
bufIndex += count;
|
401 |
+
bufIndex &= CR_ARRAY_SIZE(s_triBuf)-1;
|
402 |
+
}
|
403 |
+
while (bufCount > 0 || batchPos < batchEnd);
|
404 |
+
|
405 |
+
// flush all bins
|
406 |
+
if (thrInBlock < p.numBins)
|
407 |
+
{
|
408 |
+
int ofs = s_outOfs[thrInBlock];
|
409 |
+
if (ofs & (CR_BIN_SEG_SIZE-1))
|
410 |
+
{
|
411 |
+
int seg = ofs >> CR_BIN_SEG_LOG2;
|
412 |
+
binSegCount[seg] = ofs & (CR_BIN_SEG_SIZE-1);
|
413 |
+
s_outOfs[thrInBlock] = (ofs + CR_BIN_SEG_SIZE - 1) & -CR_BIN_SEG_SIZE;
|
414 |
+
}
|
415 |
+
}
|
416 |
+
}
|
417 |
+
|
418 |
+
// output totals
|
419 |
+
if (thrInBlock < p.numBins)
|
420 |
+
binTotal[(thrInBlock << CR_BIN_STREAMS_LOG2) + blockIdx.x] = s_outTotal[thrInBlock];
|
421 |
+
}
|
422 |
+
|
423 |
+
//------------------------------------------------------------------------
|
ginipick:SORA-3D/extensions/nvdiffrast/common/cudaraster/impl/extensions_nvdiffrast_nvdiffrast_common_cudaraster_impl_Buffer.cpp
ADDED
@@ -0,0 +1,94 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// Copyright (c) 2009-2022, NVIDIA CORPORATION. All rights reserved.
|
2 |
+
//
|
3 |
+
// NVIDIA CORPORATION and its licensors retain all intellectual property
|
4 |
+
// and proprietary rights in and to this software, related documentation
|
5 |
+
// and any modifications thereto. Any use, reproduction, disclosure or
|
6 |
+
// distribution of this software and related documentation without an express
|
7 |
+
// license agreement from NVIDIA CORPORATION is strictly prohibited.
|
8 |
+
|
9 |
+
#include "../../framework.h"
|
10 |
+
#include "Buffer.hpp"
|
11 |
+
|
12 |
+
using namespace CR;
|
13 |
+
|
14 |
+
//------------------------------------------------------------------------
|
15 |
+
// GPU buffer.
|
16 |
+
//------------------------------------------------------------------------
|
17 |
+
|
18 |
+
Buffer::Buffer(void)
|
19 |
+
: m_gpuPtr(NULL),
|
20 |
+
m_bytes (0)
|
21 |
+
{
|
22 |
+
// empty
|
23 |
+
}
|
24 |
+
|
25 |
+
Buffer::~Buffer(void)
|
26 |
+
{
|
27 |
+
if (m_gpuPtr)
|
28 |
+
cudaFree(m_gpuPtr); // Don't throw an exception.
|
29 |
+
}
|
30 |
+
|
31 |
+
void Buffer::reset(size_t bytes)
|
32 |
+
{
|
33 |
+
if (bytes == m_bytes)
|
34 |
+
return;
|
35 |
+
|
36 |
+
if (m_gpuPtr)
|
37 |
+
{
|
38 |
+
NVDR_CHECK_CUDA_ERROR(cudaFree(m_gpuPtr));
|
39 |
+
m_gpuPtr = NULL;
|
40 |
+
}
|
41 |
+
|
42 |
+
if (bytes > 0)
|
43 |
+
NVDR_CHECK_CUDA_ERROR(cudaMalloc(&m_gpuPtr, bytes));
|
44 |
+
|
45 |
+
m_bytes = bytes;
|
46 |
+
}
|
47 |
+
|
48 |
+
void Buffer::grow(size_t bytes)
|
49 |
+
{
|
50 |
+
if (bytes > m_bytes)
|
51 |
+
reset(bytes);
|
52 |
+
}
|
53 |
+
|
54 |
+
//------------------------------------------------------------------------
|
55 |
+
// Host buffer with page-locked memory.
|
56 |
+
//------------------------------------------------------------------------
|
57 |
+
|
58 |
+
HostBuffer::HostBuffer(void)
|
59 |
+
: m_hostPtr(NULL),
|
60 |
+
m_bytes (0)
|
61 |
+
{
|
62 |
+
// empty
|
63 |
+
}
|
64 |
+
|
65 |
+
HostBuffer::~HostBuffer(void)
|
66 |
+
{
|
67 |
+
if (m_hostPtr)
|
68 |
+
cudaFreeHost(m_hostPtr); // Don't throw an exception.
|
69 |
+
}
|
70 |
+
|
71 |
+
void HostBuffer::reset(size_t bytes)
|
72 |
+
{
|
73 |
+
if (bytes == m_bytes)
|
74 |
+
return;
|
75 |
+
|
76 |
+
if (m_hostPtr)
|
77 |
+
{
|
78 |
+
NVDR_CHECK_CUDA_ERROR(cudaFreeHost(m_hostPtr));
|
79 |
+
m_hostPtr = NULL;
|
80 |
+
}
|
81 |
+
|
82 |
+
if (bytes > 0)
|
83 |
+
NVDR_CHECK_CUDA_ERROR(cudaMallocHost(&m_hostPtr, bytes));
|
84 |
+
|
85 |
+
m_bytes = bytes;
|
86 |
+
}
|
87 |
+
|
88 |
+
void HostBuffer::grow(size_t bytes)
|
89 |
+
{
|
90 |
+
if (bytes > m_bytes)
|
91 |
+
reset(bytes);
|
92 |
+
}
|
93 |
+
|
94 |
+
//------------------------------------------------------------------------
|
ginipick:SORA-3D/extensions/nvdiffrast/common/cudaraster/impl/extensions_nvdiffrast_nvdiffrast_common_cudaraster_impl_Buffer.hpp
ADDED
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// Copyright (c) 2009-2022, NVIDIA CORPORATION. All rights reserved.
|
2 |
+
//
|
3 |
+
// NVIDIA CORPORATION and its licensors retain all intellectual property
|
4 |
+
// and proprietary rights in and to this software, related documentation
|
5 |
+
// and any modifications thereto. Any use, reproduction, disclosure or
|
6 |
+
// distribution of this software and related documentation without an express
|
7 |
+
// license agreement from NVIDIA CORPORATION is strictly prohibited.
|
8 |
+
|
9 |
+
#pragma once
|
10 |
+
#include "Defs.hpp"
|
11 |
+
|
12 |
+
namespace CR
|
13 |
+
{
|
14 |
+
//------------------------------------------------------------------------
|
15 |
+
|
16 |
+
class Buffer
|
17 |
+
{
|
18 |
+
public:
|
19 |
+
Buffer (void);
|
20 |
+
~Buffer (void);
|
21 |
+
|
22 |
+
void reset (size_t bytes);
|
23 |
+
void grow (size_t bytes);
|
24 |
+
void* getPtr (size_t offset = 0) { return (void*)(((uintptr_t)m_gpuPtr) + offset); }
|
25 |
+
size_t getSize (void) const { return m_bytes; }
|
26 |
+
|
27 |
+
void setPtr (void* ptr) { m_gpuPtr = ptr; }
|
28 |
+
|
29 |
+
private:
|
30 |
+
void* m_gpuPtr;
|
31 |
+
size_t m_bytes;
|
32 |
+
};
|
33 |
+
|
34 |
+
//------------------------------------------------------------------------
|
35 |
+
|
36 |
+
class HostBuffer
|
37 |
+
{
|
38 |
+
public:
|
39 |
+
HostBuffer (void);
|
40 |
+
~HostBuffer (void);
|
41 |
+
|
42 |
+
void reset (size_t bytes);
|
43 |
+
void grow (size_t bytes);
|
44 |
+
void* getPtr (void) { return m_hostPtr; }
|
45 |
+
size_t getSize (void) const { return m_bytes; }
|
46 |
+
|
47 |
+
void setPtr (void* ptr) { m_hostPtr = ptr; }
|
48 |
+
|
49 |
+
private:
|
50 |
+
void* m_hostPtr;
|
51 |
+
size_t m_bytes;
|
52 |
+
};
|
53 |
+
|
54 |
+
//------------------------------------------------------------------------
|
55 |
+
}
|