Skip to content

Commit f8935cb

Browse files
committed
sync on 2026/06/27, rev 8a3630f36783b03aae39267a238c5aed3005fa05
1 parent 7f4b511 commit f8935cb

671 files changed

Lines changed: 16520 additions & 5766 deletions

File tree

Some content is hidden

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

DagorEngine.rev.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
b56bb083a422680afc47c84cabba44a7af5b9721
1+
8a3630f36783b03aae39267a238c5aed3005fa05

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ Restart the command line console to make the new environment variables available
4949

5050
## How to Build: Prebuilt Binaries
5151

52-
You will need to download and extract additional binary files (as of 2026/06/20) from the CDN into the X:\develop\DagorEngine folder:
53-
* [tools-base.7z](https://dagorenginedata.cdn.gaijin.net/head-2026.06.20/tools-base.7z) - contains initial data for tools
54-
* [samples-base.7z](https://dagorenginedata.cdn.gaijin.net/head-2026.04.30/samples-base.7z) - contains initial assets that will be compiled into binary files that will be loaded by the game (samples)
55-
* [outerSpace-devsrc.7z](https://dagorenginedata.cdn.gaijin.net/head-2026.06.13/outerSpace-devsrc.7z) - contains initial assets for OuterSpace sample project
56-
* [dngSceneViewer.7z](https://dagorenginedata.cdn.gaijin.net/head-2026.06.20/dngSceneViewer.7z) - contains binary data for east_district sample with dngSceneViewer (windows-x86_64 executables also included)
52+
You will need to download and extract additional binary files (as of 2026/06/27) from the CDN into the X:\develop\DagorEngine folder:
53+
* [tools-base.7z](https://dagorenginedata.cdn.gaijin.net/head-2026.06.27/tools-base.7z) - contains initial data for tools
54+
* [samples-base.7z](https://dagorenginedata.cdn.gaijin.net/head-2026.06.27/samples-base.7z) - contains initial assets that will be compiled into binary files that will be loaded by the game (samples)
55+
* [outerSpace-devsrc.7z](https://dagorenginedata.cdn.gaijin.net/head-2026.06.27/outerSpace-devsrc.7z) - contains initial assets for OuterSpace sample project
56+
* [dngSceneViewer.7z](https://dagorenginedata.cdn.gaijin.net/head-2026.06.27/dngSceneViewer.7z) - contains binary data for east_district sample with dngSceneViewer (windows-x86_64 executables also included)
5757

5858
More downloads in the repository [https://github.com/GaijinEntertainment/DagorEngine/releases](https://github.com/GaijinEntertainment/DagorEngine/releases) with prebuilt binaries (may be a bit outdate):
5959

@@ -80,11 +80,11 @@ X:\develop\DagorEngine\samples\testGI\game
8080

8181
## How to Build: Build from Source Code
8282

83-
First unpack [tools-base.7z](https://dagorenginedata.cdn.gaijin.net/head-2026.06.20/tools-base.7z) to DagorEngine root to get mandatory binary files in their place.
83+
First unpack [tools-base.7z](https://dagorenginedata.cdn.gaijin.net/head-2026.06.27/tools-base.7z) to DagorEngine root to get mandatory binary files in their place.
8484

85-
If you are going to run samples unpack [samples-base.7z](https://dagorenginedata.cdn.gaijin.net/head-2026.04.30/samples-base.7z) to DagorEngine root (if you plan to only build EXE and shaders these binary data are not mandatory).
85+
If you are going to run samples unpack [samples-base.7z](https://dagorenginedata.cdn.gaijin.net/head-2026.06.27/samples-base.7z) to DagorEngine root (if you plan to only build EXE and shaders these binary data are not mandatory).
8686

87-
To build and run OuterSpace sample project unpack also [outerSpace-devsrc.7z](https://dagorenginedata.cdn.gaijin.net/head-2026.06.13/outerSpace-devsrc.7z) to DagorEngine root.
87+
To build and run OuterSpace sample project unpack also [outerSpace-devsrc.7z](https://dagorenginedata.cdn.gaijin.net/head-2026.06.27/outerSpace-devsrc.7z) to DagorEngine root.
8888

8989
Then run `build_all.py` in DagorEngine root.
9090

@@ -125,7 +125,7 @@ Example: `build_all.py project:dngSceneViewer code shaders` will build only code
125125
[Demos of a new Gaijin’s game showcase Dagor Engine power](https://gaijinent.com/news/demos-of-a-new-gaijins-game-showcase-dagor-engine-power)<br>
126126
[East District review on YouTube](https://youtu.be/miABl6aekBA)
127127
* Multiplayer sample: **Outer Space**<br>
128-
[Code](https://github.com/GaijinEntertainment/DagorEngine/tree/main/outerSpace/prog) and source (develop) files [outerSpace-devsrc.7z](https://dagorenginedata.cdn.gaijin.net/head-2026.06.13/outerSpace-devsrc.7z) to be unpacked to DagorEngine root<br>
128+
[Code](https://github.com/GaijinEntertainment/DagorEngine/tree/main/outerSpace/prog) and source (develop) files [outerSpace-devsrc.7z](https://dagorenginedata.cdn.gaijin.net/head-2026.06.27/outerSpace-devsrc.7z) to be unpacked to DagorEngine root<br>
129129
Prebuilt game (executables, shaders, vromfs, gameres) is available as [outerSpace-prebuilt-fullsrc.tar.gz](https://dagorenginedata.cdn.gaijin.net/rel-fea0a2b3ae5acdb25e088e57a8fb1f77d5ba3e1d/outerSpace-prebuilt-fullsrc.tar.gz)
130130

131131
### Documentation

_docs/source/api-references/dagor-dshl/index/shaders.rst

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,128 @@ These indices are then used to retrieve the corresponding texture and sampler fr
375375

376376
This is what ``get_<texture_name>()`` essentialy does for you.
377377

378+
.. _explicit-bindless-resources:
379+
380+
---------------------------
381+
Explicit bindless resources
382+
---------------------------
383+
384+
The ``@static*`` material textures above are an *implicit* bindless path: the
385+
material system owns the resource and packs its ``uint2 {texture, sampler}`` slot
386+
into the per-material cbuffer for you.
387+
388+
``@bindless*`` postfixes are the *explicit* counterpart: you bind an arbitrary
389+
resource into a bindless heap yourself and pass the shader its slot index through
390+
an ``int`` shader variable. Texture and sampler are independent (one ``int`` slot
391+
each), and the resource is whatever C++/daFrameGraph registered in the bindless heap
392+
at that index, rather than a material texture slot.
393+
394+
.. list-table::
395+
:header-rows: 1
396+
397+
* - Postfix
398+
- HLSL element type
399+
* - @bindlessTex2D
400+
- Texture2D
401+
* - @bindlessTex3D
402+
- Texture3D
403+
* - @bindlessTexCube
404+
- TextureCube
405+
* - @bindlessTexArray
406+
- Texture2DArray
407+
* - @bindlessTexCubeArray
408+
- TextureCubeArray
409+
* - @bindlessSampler
410+
- SamplerState
411+
* - @bindlessByteBuffer
412+
- ByteAddressBuffer
413+
414+
The right-hand side of the declaration is an ``int`` shader variable holding the
415+
bindless slot index; ``-1`` means "no resource bound".
416+
417+
For each ``@bindless*`` declaration the compiler generates two functions: ``get_<name>()``
418+
fetches the resource from its bindless heap by the slot index (returning the postfix's
419+
HLSL element type, so ``get_albedo_smp()`` is a ``SamplerState`` and
420+
``get_albedo_buffer()`` a ``ByteAddressBuffer``), and ``has_<name>()`` returns whether
421+
a resource is bound (``slot >= 0``). Optional resources must be guarded with
422+
``has_<name>()`` before calling ``get_<name>()``:
423+
424+
.. code-block:: text
425+
426+
int albedo_bindless_index = -1;
427+
int bindless_sampler_index = -1;
428+
429+
shader example_bindless
430+
{
431+
(ps) {
432+
albedo_2d@bindlessTex2D = albedo_bindless_index;
433+
albedo_smp@bindlessSampler = bindless_sampler_index;
434+
}
435+
436+
hlsl(ps) {
437+
float4 main_ps() : SV_Target0
438+
{
439+
if (!has_albedo_2d())
440+
return float4(0, 0, 0, 1);
441+
442+
SamplerState smp = get_albedo_smp();
443+
return get_albedo_2d().SampleLevel(smp, float2(0, 0), 0);
444+
}
445+
}
446+
}
447+
448+
.. note::
449+
Unlike ``@static*`` material textures, ``@bindless*`` has no non-bindless fallback:
450+
it requires bindless support to be enabled for the target. Using it for a target
451+
without bindless enabled is a compile error.
452+
453+
There is no sugar for ``StructuredBuffer<T>``: it needs a per-element type, while the
454+
shared heap is untyped. Declare such a heap by hand and pass the slot through a plain
455+
``@i1`` int instead. Heap spaces ``1-6`` (the third argument to ``BINDLESS_*_ARRAY``)
456+
are reserved by the ``@bindless*`` heaps (textures ``1-5``, ``ByteAddressBuffer`` ``6``);
457+
use ``7+`` for your own arrays.
458+
459+
.. code-block:: text
460+
461+
int my_sbuffer_index = -1;
462+
463+
shader example_bindless_sbuffer
464+
{
465+
(ps) {
466+
my_sbuffer_id@i1 = (my_sbuffer_index);
467+
}
468+
469+
hlsl(ps) {
470+
BINDLESS_BUF_ARRAY(StructuredBuffer<float4>, sbufArr, 7);
471+
472+
float4 main_ps() : SV_Target0
473+
{
474+
if (my_sbuffer_id < 0)
475+
return float4(0, 0, 0, 1);
476+
return sbufArr[my_sbuffer_id][0];
477+
}
478+
}
479+
}
480+
481+
The ``int`` slot variable is filled on the CPU side. Manually, the slot index comes
482+
from the bindless API in ``<drv/3d/dag_bindless.h>`` (see
483+
:doc:`/api-references/dagor-render/index/d3dAPI/Bindless`):
484+
``d3d::allocate_bindless_resource_range()`` / ``d3d::update_bindless_resource()`` (or
485+
the ``d3d::add_bindless_resource()`` shortcut). Pass the returned index to the shader
486+
variable:
487+
488+
.. code-block:: cpp
489+
490+
#include <drv/3d/dag_bindless.h>
491+
492+
// allocate a slot and point it at the resource
493+
uint32_t idx = d3d::add_bindless_resource(D3DResourceType::TEX, tex);
494+
ShaderGlobal::set_int(get_shader_variable_id("albedo_bindless_index", true), idx);
495+
496+
Alternatively, inside a frame graph node, daFrameGraph's ``bindlessShaderVar()`` request
497+
does the allocation and sets this variable for you. See
498+
:cpp:class:`dafg::VirtualResourceRequest` in :doc:`/api-references/dagor-render/index/daFrameGraph/declaringNodes`.
499+
378500
-------
379501
Buffers
380502
-------

_docs/source/api-references/dagor-render/index/daFrameGraph/declaringNodes.rst

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,30 @@ These must be used inside the declaration callback for specifying the following
2727
* What global state the node requires (e.g. shader blocks)
2828
* Additional metadata (multiplexing mode, priority, explicit dependencies, etc)
2929

30+
.. _dafg-bindless-shader-var:
31+
32+
.. rubric:: Bindless bindings
33+
34+
Besides ``bindToShaderVar()``, a resource request can be bound *bindlessly*:
35+
the resource is registered in a bindless heap and its slot index is written into a
36+
named ``int`` shader variable (``-1`` when the resource is missing or the driver has
37+
no bindless support).
38+
39+
.. code-block:: cpp
40+
41+
registry.read("your_tex").texture()
42+
.atStage(dafg::Stage::PS_OR_CS)
43+
.bindlessShaderVar("your_bindless_index");
44+
45+
registry.create("your_sampler")
46+
.blob<d3d::SamplerHandle>(d3d::request_sampler(d3d::SamplerInfo{}))
47+
.bindlessShaderVar("your_sampler_index");
48+
49+
The shader consumes the index through the matching ``int`` variable, either via the
50+
``@bindless*`` DSHL sugar or a manual ``BINDLESS_*_ARRAY`` declaration. See
51+
:ref:`explicit-bindless-resources` in the DSHL reference. The full request API is
52+
documented in :cpp:class:`dafg::VirtualResourceRequest` below.
53+
3054
.. doxygenclass:: dafg::Registry
3155
:project: daFrameGraph
3256
:members:

outerSpace/prog/gameBase/gamedata/templates/outer_space.entities.blk

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -664,6 +664,9 @@ water{
664664
water__level:r=0
665665
water__fft_resolution:i=7
666666
water__max_tessellation:i=4
667+
water__fresnel_specular_intensity:r=0.02
668+
water__fresnel_ambient_reflection:r=0.2
669+
water__fresnel_reflection:r=0.5
667670
water__flowmap:b=yes
668671
water__has_slopes:b=no
669672
water__flowmap_tex:t=""
@@ -816,12 +819,8 @@ capsules_ao{
816819

817820
film_grain_lut{
818821
_singleton:b=yes
819-
film_grain_lut__wh:i=256
820-
film_grain_lut__d:i=64
821822
film_grain_lut__gen_params:p4=2.5,0.5,1.0,64
822823

823-
_tracked:t="film_grain_lut__wh"
824-
_tracked:t="film_grain_lut__d"
825824
_tracked:t="film_grain_lut__gen_params"
826825

827826
film_grain_lut{

prog/1stPartyLibs/daScript/daslib/flatten.das

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ let private STD_WHITELIST : table<string> <- {
5050
"min", "max", "abs", "clamp", "saturate", "sign", "floor", "ceil", "round", "trunc", "frac",
5151
"sqrt", "rsqrt", "pow", "exp", "exp2", "log", "log2",
5252
"sin", "cos", "tan", "asin", "acos", "atan", "atan2", "sincos",
53+
"radians", "degrees", // lowered to `x * K` by flatten_opt (no opcode needed)
5354
"dot", "cross", "length", "normalize", "distance", "reflect", "refract",
5455
"lerp", "mix", "step", "smooth_step", "rcp", "mad",
5556
"float2", "float3", "float4", "int2", "int3", "int4", "uint2", "uint3", "uint4"
@@ -719,6 +720,8 @@ def public flatten_function(var func : FunctionPtr; whitelist : table<string>; m
719720
dse_pass(out) // drop dead mask-kills (`__flat_live = false`) first…
720721
copy_prop_pass(out) // inline single-def temps AND const-fold the masks they expose
721722
// (`__flat_live=true` → `true ? a:b` → a; `__flat_ret=c; return __flat_ret` → `return c`)
723+
mask_const_prop_pass(out) // flow-sensitive const-prop of the multi-def loop/iter masks:
724+
// first unrolled iter unconditional (`true ? a:b → a`), `m = m && X → m = X`
722725
dse_pass(out) // remove anything left dead (collapsed mask decls, folded temps)
723726
ssa_rename_pass(out) // single-def-ify reassigned user locals → fold_body const-props the chain
724727
}
@@ -773,6 +776,14 @@ def public flatten_optimize(var func : FunctionPtr; barriers : table<string>; no
773776
return flatten_preshade_cse(func, barriers, no_fast_math, log_cse)
774777
}
775778

779+
[macro_function]
780+
def public flatten_pack(var func : FunctionPtr; no_fast_math : bool = false) : bool {
781+
//! Scalar-packing map-reduce re-roll (delegates to `pack_map_reduce`): recognize an unrolled
782+
//! min/max reduction's N isomorphic scalar lanes and pack them into width-W vector ops + one
783+
//! horizontal reduce. Run PRE-fold (before `flatten_fold`); re-infer after. no_fast_math skips it.
784+
return pack_map_reduce(func, no_fast_math)
785+
}
786+
776787
[macro_function]
777788
def public flatten_fuse(var func : FunctionPtr; no_fast_math : bool = false) : bool {
778789
//! PHASE_FUSED finishing pass (delegates to `fuse_body`): collapse same-vector lane sums into
@@ -894,6 +905,11 @@ def public flatten_fold_residuals(var func : FunctionPtr; no_fast_math : bool =
894905
unsafe {
895906
delete v
896907
}
908+
// Statement-level (not a node pattern): a same-condition select-accumulation chain that
909+
// fuse_select_chains should have collapsed to one select.
910+
if (func.body is ExprBlock && has_fusable_select_chain(func.body as ExprBlock)) {
911+
res |> push("an un-fused same-condition select chain (N selects should be 1)")
912+
}
897913
}
898914
return <- res
899915
}

0 commit comments

Comments
 (0)