Page MenuHome

Cycles: Replace use_qbvh boolean flag with an enum-based property
ClosedPublic

Authored by Sergey Sharybin (sergey) on Jan 19 2018, 11:04 AM.

Details

Summary

This was we can introduce other types of BVH, for example, wider ones, without
causing too much mess around boolean flags.

Thoughs:

  • Ideally device info should probably return bitflag of what BVH types it supports.

    It is possible to implement based on simple logic in device/ and mesh.cpp, rest of the changes will stay the same.
  • Not happy with workarounds in util_debug and duplicated enum in kernel. Maybe enbum should be stores in kernel, but then it's kind of weird to include kernel types from utils. Soudns some cyclkic dependency.

Diff Detail

Repository
rB Blender
Branch
cycles_bvh_enum
Build Status
Buildable 1104
Build 1104: arc lint + arc unit

Event Timeline

Maybe call it BVH layout instead of BVH size? Makes a bit more sense if we ever add more variations.

About duplicated enums and dependencies, I think DebugFlags belongs in the render/ folder really. util/ was meant to be for generic types and functions,

intern/cycles/bvh/bvh_params.h
58–64

I would move this out of the BVHParams namespace. If needs to be in the namespace BVHSize should just be Size.

Maybe call it BVH layout instead of BVH size? Makes a bit more sense if we ever add more variations.

That sounds like a better name indeed.

About duplicated enums and dependencies, I think DebugFlags belongs in the render/ folder really. util/ was meant to be for generic types and functions,

DebugFlags() are used by device code, and it seemed to be a bad level include to include render/ from device. If you think it's not that bad level, i don't mind moving debug stuff from util to render at all.

intern/cycles/bvh/bvh_params.h
58–64

For the host code it's kind of optimal to have it a class enum inside of ccl itself. But we aren't forcing C++11 for now, and not sure having BVHSize class with enum inside is a good idea,

  • Renamed bvh_size to bvh_layout
  • Removed duplicated enums in bvh.h and kernel_types.h
  • Removed workaround in util_debug.h
  • Made it a bit mask returned by device info, so we should be more future proof now.
  • Made it BVH_LAYOUT_DEFAULT rather than "widest". This way we can add wider BVH implementations but not use them for production files yet.

Looks good, though could be simplified a little imo.

intern/cycles/kernel/kernel_types.h
1347

BVHSize -> BVHLayoutMaskBits.

I would just define BVH_LAYOUT_BVH2 and BVH_LAYOUT_BVH4 directly as (1 << 0) and (1 << 1) though, no need for the duplication.

This revision is now accepted and ready to land.Jan 19 2018, 8:06 PM

Remove duplicated enum values

Forgot this in previous update

Ready to commit I think, except that some stuff can be removed still before you do.

intern/cycles/bvh/bvh.cpp
37–44

This can be removed now.

58–66

This can be removed now.

This revision was automatically updated to reflect the committed changes.