Skip to content
This repository has been archived by the owner on Dec 13, 2019. It is now read-only.

Type Safe Root Signatures #6

Open
DaseinPhaos opened this issue Jun 6, 2017 · 0 comments
Open

Type Safe Root Signatures #6

DaseinPhaos opened this issue Jun 6, 2017 · 0 comments

Comments

@DaseinPhaos
Copy link
Owner

DaseinPhaos commented Jun 6, 2017

Currently most methods exposed by CommandList can be considered as unsafe, because no type or state checking has been perfomed.
We might save state-related issues for a better time to discuss, for now just focusing on root signature type safety.

The basic idea , inspired by similar constructs in vulkano, is that we can define a trait like RootSignature, which a safe command list can bound to. An implementation of this trait can be defined by user in compile time, exposing another limited interface for root parameter binding. At runtime, when a command list is bound to this signature, another type like RootSignatureCmdListRecording<T> would be returned, exposing type safe binding methods for it.

We should directly have macro driven, statically typed psos, since those are directly bounded to the command lists. Actually, coming to think of it, I think this might be the right way to go.

using example:

let static_sampler_desc = // describes a static sampler;
let pso_desc = pipeline_state_object!{
    root_signature {
        parameters {
            cbv {camera, 0, 0}, // shader register c0, register space 0
            constant {constants, 0, 0, 3}, // three constants
        },
       samplers {static_sampler_desc},
    },
    // defaults
};
let pso = pso_desc.build(&mut device).unwrap();

//...

// at recording time
let mut cmd_list_recording = cmd_list.start(&mut cmd_alloc, Some(&pso)).unwrap();
cmd_list_recording.camera(&camera_buffer);
cmd_list_recording.constants(&[1, 2, 3], 0);
// ...

The main unresolved problems include

  • should we use the type system to check against unbound root parameters, which would introduce dramatically more type level boilerplate
  • should/how do we introduce resource level type checking
  • type safe shaders?
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant