Skip to content

Commit

Permalink
Merge pull request #42 from jbikker/dev
Browse files Browse the repository at this point in the history
Merging dev into main.
  • Loading branch information
jbikker authored Dec 7, 2024
2 parents c9b4504 + dfaf79a commit b70356a
Show file tree
Hide file tree
Showing 25 changed files with 1,602 additions and 761 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/tinybvh_sdk_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: tinybvh CI

on:
push:
branches: [ main ]
branches: [ main, dev ]
pull_request:
branches: [ main ]
branches: [ main, dev ]

jobs:
build:
Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# dev
This is the **development branch** for tinybvh. Potentially unstable code, consider yourself warned.

# tinybvh
Single-header BVH construction and traversal library written as "Sane C++" (or "C with classes"). The library has no dependencies.

Expand All @@ -9,6 +12,8 @@ Single-header OpenCL library, which helps you select and initialize a device. It
* Vendor and architecture detection and propagation to #defines in OpenCL code
* ..And many other things.

![Rendered with tinybvh](images/test.png)

To use tinyocl, just include ````tiny_ocl.h````; this will automatically cause linking with ````OpenCL.lib```` in the 'external' folder, which in turn passes on work to vendor-specific driver code. But all that is not your problem!

Note that the ````tiny_bvh.h```` library will work without ````tiny_ocl.h```` and remains dependency-free. The new ````tiny_ocl.h```` is only needed in projects that wish to trace rays _on the GPU_ using BVHs created by ````tiny_bvh.h````.
Expand All @@ -31,6 +36,7 @@ A constructed BVH can be used to quickly intersect a ray with the geometry, usin

The constructed BVH will have a layout suitable for construction ('````WALD_32BYTE````'). Several other layouts for the same data are available, which all serve one or more specific purposes. You can convert between layouts using ````BVH::Convert````. The available layouts are:
* ````BVH::WALD_32BYTE```` : A compact format that stores the AABB for a node, along with child pointers and leaf information in a cross-platform-friendly way. The 32-byte size allows for cache-line alignment.
* ````BVH::ALT_SOA```` : This format stores bounding box information in a SIMD-friendly format, making the BVH faster to traverse.
* ````BVH::WALD_DOUBLE```` : Double-precision version of ````BVH::WALD_32BYTE````.
* ````BVH::VERBOSE```` : A format designed for modifying BVHs, e.g. for post-build optimizations using ````BVH::Optimize()````.
* ````BVH::AILA_LAINE```` : This format uses 64 bytes per node and stores the AABBs of the two child nodes. This is the format presented in the [2009 Aila & Laine paper](https://research.nvidia.com/sites/default/files/pubs/2009-08_Understanding-the-Efficiency/aila2009hpg_paper.pdf) and recommended for basic GPU ray tracing.
Expand All @@ -57,6 +63,10 @@ The cross-platform fenster-based single-source **bitmap renderer** can be compil

```g++ -std=c++20 -mavx -O3 -framework Cocoa tiny_bvh_fenster.cpp -o tiny_bvh_fenster``` (on macOS)

The multi-threaded **ambient occlusion** demo can be compiled with

````g++ -std=c++20 -mavx -mwindows -fopenmp -O3 tiny_bvh_pt.cpp -o tiny_bvh_pt```` (on windows)

The **performance measurement tool** uses OpenMP and can be compiled with:

````g++ -std=c++20 -mavx -Ofast -fopenmp tiny_bvh_speedtest.cpp -o tiny_bvh_speedtest````
Expand Down
16 changes: 11 additions & 5 deletions external/fenster.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,8 @@ static LRESULT CALLBACK fenster_wndproc(HWND hwnd, UINT msg, WPARAM wParam,
PAINTSTRUCT ps;
HDC hdc = BeginPaint(hwnd, &ps);
HDC memdc = CreateCompatibleDC(hdc);
auto hbmp = CreateCompatibleBitmap(hdc, f->width, f->height);
auto oldbmp = SelectObject(memdc, hbmp);
HBITMAP hbmp = CreateCompatibleBitmap(hdc, f->width, f->height);
HBITMAP oldbmp = static_cast<HBITMAP>(SelectObject(memdc, hbmp));
BINFO bi = {{sizeof(bi), f->width, -f->height, 1, 32, BI_BITFIELDS}};
bi.bmiColors[0].rgbRed = 0xff;
bi.bmiColors[1].rgbGreen = 0xff;
Expand Down Expand Up @@ -249,10 +249,13 @@ FENSTER_API int fenster_open(struct fenster *f) {
wc.hInstance = hInstance;
wc.lpszClassName = f->title;
RegisterClassEx(&wc);
RECT desiredRect = {0, 0, f->width, f->height};
AdjustWindowRectEx(&desiredRect, WS_OVERLAPPEDWINDOW, FALSE, WS_EX_CLIENTEDGE);
int adjustedWidth = desiredRect.right - desiredRect.left;
int adjustedHeight = desiredRect.bottom - desiredRect.top;
f->hwnd = CreateWindowEx(WS_EX_CLIENTEDGE, f->title, f->title,
WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT,
f->width, f->height, NULL, NULL, hInstance, NULL);

adjustedWidth, adjustedHeight, NULL, NULL, hInstance, NULL);
if (f->hwnd == NULL)
return -1;
SetWindowLongPtr(f->hwnd, GWLP_USERDATA, (LONG_PTR)f);
Expand All @@ -261,7 +264,10 @@ FENSTER_API int fenster_open(struct fenster *f) {
return 0;
}

FENSTER_API void fenster_close(struct fenster *f) { (void)f; }
FENSTER_API void fenster_close(struct fenster *f) {
PostMessage(f->hwnd, WM_CLOSE, 0, 0);
(void)f;
}

FENSTER_API int fenster_loop(struct fenster *f) {
MSG msg;
Expand Down
Binary file added images/test.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added testdata/armadillo.bin
Binary file not shown.
Binary file added testdata/bunny.bin
Binary file not shown.
Binary file modified testdata/cryteksponza.bin
Binary file not shown.
Binary file added testdata/dragon.bin
Binary file not shown.
Binary file modified testdata/happybuddha.bin
Binary file not shown.
Binary file added testdata/head.bin
Binary file not shown.
Binary file added testdata/legocar.bin
Binary file not shown.
Binary file added testdata/lucy.bin
Binary file not shown.
Binary file added testdata/suzanne.bin
Binary file not shown.
Binary file added testdata/xyzrgb_dragon.bin
Binary file not shown.
Loading

0 comments on commit b70356a

Please sign in to comment.