-
Notifications
You must be signed in to change notification settings - Fork 545
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
Associated resource type preparations #564
Conversation
46e9ba8
to
0c83286
Compare
I think this is ready for review. Could you bump the cgmath version @kvark? I can't do it right now - I'm at work. |
@bjz cgmath is published. I'll have a good look at the PR tomorrow. |
Ok, it builds fine - needs a rebase though. |
Did I just break your auto-merge?.. |
Yeah - that's ok. I can do it when I get home in several hours, or you are welcome to rebase for me. |
This is a little ugly, but it allows us to have access to the resource types without CommandBuffer needing to have access to Device, which would result in a rustc stack overflow.
For now we just use `GlDevice` when we refer to them
1ee52a8
to
af64f3e
Compare
Yay for |
@@ -307,7 +307,9 @@ fn calculate_color(height: f32) -> [f32; 3] { | |||
} | |||
} | |||
|
|||
fn create_g_buffer(width: u16, height: u16, device: &mut gfx::GlDevice) -> (gfx::Frame, TextureHandle, TextureHandle, TextureHandle, TextureHandle) { | |||
fn create_g_buffer(width: u16, height: u16, device: &mut gfx::GlDevice) | |||
-> (gfx::Frame, TextureHandle<gfx::GlResources>, TextureHandle<gfx::GlResources>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the user has to access gfx_device_gl
crate anyway in order to create he device, perhaps we could provide a typedef for TextureHandle
in there?
@@ -368,56 +364,56 @@ pub trait Device { | |||
fn submit(&mut self, buffer: (&Self::CommandBuffer, &draw::DataBuffer)); | |||
|
|||
// resource creation | |||
fn create_buffer_raw(&mut self, size: usize, usage: BufferUsage) -> BufferHandle<()>; | |||
fn create_buffer<T>(&mut self, num: usize, usage: BufferUsage) -> BufferHandle<T> { | |||
fn create_buffer_raw(&mut self, size: usize, usage: BufferUsage) -> BufferHandle<back::GlResources, ()>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait, this looks wrong. Shouldn't this be BufferHandle<Self::Resources, ()>
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am just hard-coding it to GlDevice
for now. That way we don't have to tackle everything at once.
@bjz Ok, I finished the first pass, waiting for you to comment. I assume you still had some technical issues preventing us to go fully generic on the device. Please describe them in detail. Also, it would be great if @csherratt had a look here as well. The PR is big and important. |
The reasons for not going fully generic on the device yet was mainly just to keep the PR under control. It is going to be a big effort to convert the Render crate as well. |
Sure thing. I'd be happy to finish the conversion, as well as move the Let me know when you are ready for the merge. Also - are you confident enough to proceed without @csherratt review? |
Look ok to me. |
@csherratt Thanks for having a look! Nice catch about |
Maybe we should add that as a constraint for the resources? |
It wasn't me that picked it up - it was the type checker ^_^ |
@bjz please add the constraint to the resources, if you can. |
Yeah, sure thing - will do it when I get home. |
@bjz when is this gonna happen, roughly? |
Done! |
This is ready to merge by the way, whenever you are free. I'm now working on decoupling the renderer. |
@bjz Awesome, thanks! |
Associated resource type preparations
Sorry to ask this, but did anyone get this change working? I walked back to try and figure out what the root cause of a regression was and found that everything works as expected up until. brendanzab@c25ef1d None of the examples are working after this change, Even the trivial triangle one. Using api trace
So something really screwy is going on here. I'm using |
Ack. Sorry! This is quite strange - can't see any transcription error in the diff. If you need to roll back on master feel free - I don't have much time to work on it tonight. |
The triangle works for one frame, then disappears. :/ |
Macros seem to be broken with |
@bjz I wish you could show up a bit more often... Is gitter not allowed at your workplace? |
This should get us closer to implementing #416.
Currently referring to the
Resources
type viaDevice
is quite ugly, eg.<<D as Device>::Resources as Resources>::Buffer
, but apparentlyD::Resources::Buffer
is going to be implemented in the future, which should make things nicer.