Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Primitive submission to renderer #13

Open
ori-sky opened this issue Aug 17, 2016 · 4 comments
Open

Primitive submission to renderer #13

ori-sky opened this issue Aug 17, 2016 · 4 comments
Assignees

Comments

@ori-sky
Copy link
Member

ori-sky commented Aug 17, 2016

We need to devise a method of submitting primitives (triangles, etc) to the low-level renderer such as OpenGL_3_2 in a renderer-agnostic, efficient manner.

The immediate conclusion for this would be to use the existing storage implementation; however, this may not be suited to such a task where an infinite stream of data is incoming and must be handled in sequence.

One possibility would be to store a concurrent channel for each data type, expanding the current storage data structure to include a channel in its now-named VectorStorage. However, this may also present issues when multiple channels of the same type are required in various places across the engine.

A solution to this may be to store the channels themselves in storage, allowing them to benefit from key lookup in constant time, as well as the other benefits of the storage structure like the ability to lookup the entire set of channels as a list.

@ori-sky
Copy link
Member Author

ori-sky commented Aug 18, 2016

The renderer must be able to return a value back to whatever submits the data, in some way, as it needs to return a unique ID to allow primitive deletion. If we're going to be using channels for this, there really is no guarantee on when the data will be read, so the best way I can think of doing this would be to generate a unique ID in the primitive submission function and write this to the channel along with the primitives, in addition to returning it to the callee.

If there's a better way to do this, I'm open to suggestions, but I'll begin working on this pretty soon.

@ori-sky
Copy link
Member Author

ori-sky commented Aug 19, 2016

To recap, the current plan to resolve this issue is as follows.

  • Primitive submission function
    • Generate unique ID (from engine core?)
    • Retrieve channel from Storage
    • Write primitive submission message to channel, with ID and primitives
    • Return ID
  • Renderer primitive submission handler
    • Retrieve channel from Storage
    • Read one (or until empty?)
    • Do backend-specific stuff
    • Map ID to backend handle (e.g. OpenGL object ID)
  • Primitive deletion function
    • Retrieve channel from Storage
    • Write primitive deletion message to channel, with ID

@ori-sky
Copy link
Member Author

ori-sky commented Aug 19, 2016

Additionally, the unique ID referring to a primitive batch should be a newtype or similar and its constructor should not be exported. Exporting would allow the type to be constructed anywhere, but we want to ensure that values of this type only exist within these bounds to eliminate the possibility of corruption of renderer storage by other engine systems.

@ori-sky
Copy link
Member Author

ori-sky commented Aug 21, 2016

Regarding my previous comment, I've discovered that this safety restriction can actually more easily be achieved simply through a new data type such as the following:

data UniqueKey = UniqueKey

This would be used as the lookup key and still doesn't need to be exported from the module.

ori-sky added a commit that referenced this issue Aug 21, 2016
This patch first adds a new module `Polar.Unique` that can generate
unique IDs for any type with an instance of `Enum`. This is based around
engine storage and the initial ID is set as `toEnum 0` of the type in
question. `succ` is used to increment the ID.

Additionally, this patch implements a basic message queue for the
renderer, built on top of engine storage with a `TChan` channel as the
actual queue.

This issue partially addresses #13.
ori-sky added a commit that referenced this issue Aug 21, 2016
This patch first adds a new module `Polar.Unique` that can generate
unique IDs for any type with an instance of `Enum`. This is based around
engine storage and the initial ID is set as `toEnum 0` of the type in
question. `succ` is used to increment the ID.

Additionally, this patch implements a basic message queue for the
renderer, built on top of engine storage with a `TChan` channel as the
actual queue.

This issue partially addresses #13.
ori-sky added a commit that referenced this issue Aug 21, 2016
This patch  removes the hardcoded triangle primitive from the OpenGL
renderer and instead submits it via the updated message queue from
example-basic.

Addresses #13 partially.
ori-sky added a commit that referenced this issue Aug 21, 2016
This patch  removes the hardcoded triangle primitive from the OpenGL
renderer and instead submits it via the updated message queue from
example-basic.

Addresses #13 partially.
@ori-sky ori-sky self-assigned this Aug 21, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant