Skip to content

Commit bdc08be

Browse files
committed
Merge branch 'master' into erfan_device_features
2 parents 1a827b1 + 9b5b2a4 commit bdc08be

Some content is hidden

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

53 files changed

+3058
-351
lines changed

README.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,59 @@ If you want to use git (without a submodule) then you can use `ExternalProject_A
414414

415415
I recommend you use `ExternalProject_Add` instead of `add_subdirectory` for **Nabla** as we haven't tested its use by *3rdparty* applications that use *CMake* to build themselves yet.
416416

417+
# Caveats and Particular Behaviour
418+
419+
## Hardcoded Caps
420+
421+
### Max Descriptor Sets is always 4
422+
423+
## Debugging with RenderDoc
424+
425+
### Non-programmatic OpenGL catpures will be delimited inconsistently
426+
427+
Due to our no-pollution opengl state isolation policy, we have 1 queue or swapchain = 1 thread = 1 gl context + 1 master context and thread for device calls.
428+
429+
Renderdoc therefore serializes all calls, and presents them inside the capture in interleaved order (records them on a single timeline "as they happened").
430+
431+
Furthermore it has no idea what constitutes a frame, because swap-buffers call happens on a separate thread than all the other API calls. **So use the `IGPUQueue` start/end capture methods!**
432+
433+
### RenderDoc flips images for display in the ImageViewer tab on OpenGL captures
434+
435+
Ctrl+F `localRenderer in https://github.com/baldurk/renderdoc/blob/4103f6a5455b9734e9bf74e254577f5c03188136/renderdoc/core/image_viewer.cpp
436+
437+
### OpenGL/Vulkan Inconsistencies
438+
439+
In certain cases same calls to Vulkan and OpenGL might result in y-flipped image relevant to the other API.
440+
441+
Both APIs write (-1,-1) in NDC space to (0,0) in image space (two wrongs make right), and memory-wise (0,0) always represents the lowest byte in memory.
442+
443+
This inconsistency comes from swapchain presentation. When presenting the swapchain, the image location (0,0) corresponds to **bottom-left** in OpenGL and **top-left** in Vulkan.
444+
445+
#### Solution by Surface Transforms
446+
447+
We solve this inconsistency by using [surface transforms](https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkSurfaceTransformFlagBitsKHR.html); This transforms are relative to `presentation engine’s natural orientation`. and we report `HORIZONTAL_MIRROR_180` support in our OpenGL backend and defer handling these rotations (relative to natural orientaion) to the user.
448+
449+
We provide helper functions in both GLSL and C++ Nabla codebase to consider surface transforms, See [surface_transform.glsl](https://github.com/Devsh-Graphics-Programming/Nabla/tree/master/include/nbl/builtin/glsl/utils/surface_transform.glsl)
450+
451+
Note that it is common to apply surface transformation to projection matrices to account for this fact. See [getSurfaceTransformationMatrix](https://github.com/Devsh-Graphics-Programming/Nabla/tree/master/include/nbl/video/surface/ISurface.h) and [Android Developers Guide to Pre-rotation](https://developer.android.com/games/optimize/vulkan-prerotation)
452+
453+
Use [`ISwapchain getSurfaceTransform()`](https://github.com/Devsh-Graphics-Programming/Nabla/tree/master/include/nbl/video/ISwapchain.h) to get the transformation from swapchain.
454+
455+
- When generating projection matricies, take into account the aspect ratio (which is changed when rotating 90 or 270 degrees). For this, we have helper functions in both GLSL and the ISurface class:
456+
- [`float getTransformedAspectRatio(const E_SURFACE_TRANSFORM_FLAGS transform, uint32_t w, uint32_t h)`](https://github.com/Devsh-Graphics-Programming/Nabla/tree/master/include/nbl/video/surface/ISurface.h)
457+
- [`nbl_glsl_surface_transform_transformedExtents`](https://github.com/Devsh-Graphics-Programming/Nabla/tree/master/include/nbl/builtin/glsl/utils/surface_transform.glsl)
458+
459+
- On the swapchain rendering pass, perform **one** of the following transforms:
460+
- If rendering **directly to the swapchain**, you can apply the (post) transform matrix to your projection or combined view-projection matrix **for rendering** (don't pre-multiply with projection matrix for use outside rendering):
461+
- [`matrix4SIMD ISurface::getSurfaceTransformationMatrix(const E_SURFACE_TRANSFORM_FLAGS transform)`](https://github.com/Devsh-Graphics-Programming/Nabla/tree/master/include/nbl/video/surface/ISurface.h)
462+
- [`nbl_glsl_surface_transform_applyToNDC`](https://github.com/Devsh-Graphics-Programming/Nabla/tree/master/include/nbl/builtin/glsl/utils/surface_transform.glsl) (This takes in an NDC coordinate and multiplies it with the transform matrix in one function)
463+
464+
- If using `imageStore` to write **directly to the swapchain**, you can either:
465+
- Apply a transform to the screen-space coordinates being written to the swapchain:
466+
- [`nbl_glsl_surface_transform_applyToScreenSpaceCoordinate`](https://github.com/Devsh-Graphics-Programming/Nabla/tree/master/include/nbl/builtin/glsl/utils/surface_transform.glsl)
467+
- Apply an **inverse** transform to the screen-space coordinates (taken from `gl_GlobalInvocationID.xy`) before turning them into UV/world-space coordinates for rendering:
468+
- [`nbl_glsl_surface_transform_applyInverseToScreenSpaceCoordinate`](https://github.com/Devsh-Graphics-Programming/Nabla/tree/master/include/nbl/builtin/glsl/utils/surface_transform.glsl)
469+
417470
## Automated Builds (TODO)
418471

419472
## License

include/nbl/asset/IDescriptorSet.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ class NBL_API IDescriptorSet : public virtual core::IReferenceCounted
5151
};
5252
struct SImageInfo
5353
{
54+
// This will be ignored if the DS layout already has an immutable sampler specified for the binding.
5455
core::smart_refctd_ptr<typename layout_t::sampler_type> sampler;
5556
//! Irrelevant in OpenGL backend
5657
E_IMAGE_LAYOUT imageLayout;

include/nbl/asset/IDescriptorSetLayout.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ class NBL_API IDescriptorSetLayout : public virtual core::IReferenceCounted
8787
E_DESCRIPTOR_TYPE type;
8888
uint32_t count;
8989
IShader::E_SHADER_STAGE stageFlags;
90+
// Use this if you want an immutable sampler that is baked into the DS layout itself.
91+
// If its `nullptr` then the sampler used is mutable and can be specified while writing the image descriptor to a binding while updating the DS.
9092
const core::smart_refctd_ptr<sampler_type>* samplers;
9193

9294
bool operator<(const SBinding& rhs) const

include/nbl/asset/IImage.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,10 @@ class NBL_API IImage : public IDescriptor
104104
};
105105
enum E_TYPE : uint32_t
106106
{
107-
ET_1D,
107+
ET_1D = 0,
108108
ET_2D,
109-
ET_3D
109+
ET_3D,
110+
ET_COUNT
110111
};
111112
enum E_SAMPLE_COUNT_FLAGS : uint32_t
112113
{

0 commit comments

Comments
 (0)