Skip to content

Does it make sense to offer a property that wraps an external value? #104

@seanharmer

Description

@seanharmer

In some cases such as material classes in Vulkan or OpenGL based applications, we may want to have some packed data that can be copied to a Uniform Buffer Object (UBO). Using Property members does not allow this as the signals are also interleaved in the memory layout of the containing class.

Would it make sense and be feasible to offer a RefProperty (name open to improvement) that acts just like a Property (signals and can participate in binding expressions) but which reads and writes data to a provided reference.

Consider:

class Material
{
public:
  Property<vec3> baseColor;
  Property<float> metal;
  Property<float> roughness;
  Property<float> ambientOcclusion;
};

This is not good to transform into a UBO that would like to layout data like:

struct UboMaterialData {
  vec3 baseColor;
  vec3 metalRoughAoFactors;
};

Would this alternative make sense and be feasible?

class Material
{
public:
  RefProperty<vec3> baseColor{ &d.baseColor };
  RefProperty<float> metal{ &d.metalRoughAoFactors.x };
  RefProperty<float> roughness{ &d.metalRoughAoFactors.y };
  RefProperty<float> ambientOcclusion{ &d.metalRoughAoFactors.z };

private:
  UboMaterialData d;
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions