Resource slot in das+ecs

We can handle in ecs NodeHandleWithSlotsAccess as we handle NodeHandle

Let’s say we have das code for node:

require daBfg.bfg_ecs

[bfg_ecs_node(on_appear)]
def register_some_node(var some_node_handle : NodeHandle&)

  some_node_handle <- root() |> registerNode("some_node") <| @(slots_state; var registry : Registry)

    registry |> create("some_node_output_tex", History No) |> texture(...)
    registry |> requestRenderPass |> color([[auto[] "some_node_output_tex"]])

    registry |> read("some_node_input_tex") |> texture |> atStage(Stage POST_RASTER) |> bindToShaderVar("some_shader_var")

    return <- @ <|
      query() <| $ [es] (some_renderer : PostFxRenderer)
        some_renderer |> render

We can convert it to read texture from and write back to resource slot slot_name:

require daBfg.resource_slot_ecs

[resource_slot_ecs(on_appear)]
def register_some_node(var some_node_handle : NodeHandleWithSlotsAccess&)

  some_node_handle <- root() |> registerAccess("some_node", [[SlotActions update <- [{Update slot="slot_name", resource="some_node_output_tex", priority=100}] ]]) <| @(slots_state; var registry : Registry)

    registry |> create(slots_state |> resourceToCreateFor("slot_name"), History No) |> texture(...)
    registry |> requestRenderPass |> color([[auto[] slots_state |> resourceToCreateFor("postfx_input_slot")]])

    registry |> read(slots_state |> resourceToReadFrom("slot_name")) |> texture |> atStage(Stage POST_RASTER) |> bindToShaderVar("some_shader_var")

    return <- @ <|
      query() <| $ [es] (some_renderer : PostFxRenderer)
        some_renderer |> render

Difference with bfg_ecs

bfg_ecs

resource_slot_ecs

require daBfg.bfg_ecs

require daBfg.resource_slot_ecs

[bfg_ecs_node(on_appear)]

[resource_slot_ecs(on_appear)]

NodeHandle

NodeHandleWithSlotsAccess

registerNode(“node_name”)

registerAccess(“node_name”, [[SlotActions … ]])

@(var registry : Registry)

@(slots_state; var registry : Registry)

“some_node_input_tex”

slots_state |> resourceToReadFrom(“slot_name”)

“some_node_output_tex”

slots_state |> resourceToCreateFor(“slot_name”)

SlotActions have 3 possible properties:

See also: registerAccess

Function annotations

resource_slot_ecs

|function_annotation-resource_slot_ecs-resource_slot_ecs|

Classes

ResourceSlotEcsAnnotation : AstFunctionAnnotation

|class-resource_slot_ecs-ResourceSlotEcsAnnotation|

ResourceSlotEcsAnnotation.apply(self: AstFunctionAnnotation; func: FunctionPtr; group: ModuleGroup; args: AnnotationArgumentList const; errors: das_string)

apply returns bool

argument

argument type

self

ast::AstFunctionAnnotation

func

FunctionPtr

group

rtti::ModuleGroup

args

rtti::AnnotationArgumentList const

errors

builtin::das_string

|method-resource_slot_ecs-ResourceSlotEcsAnnotation.apply|

ResourceSlotEcsAnnotation.parseArgs(self: ResourceSlotEcsAnnotation; func: FunctionPtr; args: AnnotationArgumentList const; errors: das_string)

parseArgs returns resource_slot_ecs::ResSlotEcsAnnotationArgs

argument

argument type

self

resource_slot_ecs::ResourceSlotEcsAnnotation

func

FunctionPtr

args

rtti::AnnotationArgumentList const

errors

builtin::das_string

|method-resource_slot_ecs-ResourceSlotEcsAnnotation.parseArgs|

ResourceSlotEcsAnnotation.declareReloadCallback(self: ResourceSlotEcsAnnotation; func: FunctionPtr; parsed: ResSlotEcsAnnotationArgs const; args: AnnotationArgumentList const)

argument

argument type

self

resource_slot_ecs::ResourceSlotEcsAnnotation

func

FunctionPtr

parsed

resource_slot_ecs::ResSlotEcsAnnotationArgs const

args

rtti::AnnotationArgumentList const

|method-resource_slot_ecs-ResourceSlotEcsAnnotation.declareReloadCallback|

ResourceSlotEcsAnnotation.declareES(self: ResourceSlotEcsAnnotation; func: FunctionPtr; parsed: ResSlotEcsAnnotationArgs const; args: AnnotationArgumentList const)

argument

argument type

self

resource_slot_ecs::ResourceSlotEcsAnnotation

func

FunctionPtr

parsed

resource_slot_ecs::ResSlotEcsAnnotationArgs const

args

rtti::AnnotationArgumentList const

|method-resource_slot_ecs-ResourceSlotEcsAnnotation.declareES|