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

Associated resource type preparations #564

Merged
merged 11 commits into from
Feb 18, 2015

Conversation

brendanzab
Copy link
Contributor

This should get us closer to implementing #416.

Currently referring to the Resources type via Device is quite ugly, eg. <<D as Device>::Resources as Resources>::Buffer, but apparently D::Resources::Buffer is going to be implemented in the future, which should make things nicer.

@brendanzab brendanzab changed the title Associated type preparations Associated resource type preparations Feb 14, 2015
@brendanzab brendanzab force-pushed the associated-type-prep branch 6 times, most recently from 46e9ba8 to 0c83286 Compare February 15, 2015 03:57
@brendanzab
Copy link
Contributor Author

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.

@kvark
Copy link
Member

kvark commented Feb 17, 2015

@bjz cgmath is published. I'll have a good look at the PR tomorrow.

@brendanzab
Copy link
Contributor Author

Ok, it builds fine - needs a rebase though.

@kvark
Copy link
Member

kvark commented Feb 17, 2015

Did I just break your auto-merge?..

@brendanzab
Copy link
Contributor Author

Yeah - that's ok. I can do it when I get home in several hours, or you are welcome to rebase for me.

@kvark
Copy link
Member

kvark commented Feb 17, 2015

Yay for Resources! I'm reviewing the whole thing now.

@@ -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>,
Copy link
Member

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, ()>;
Copy link
Member

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?

Copy link
Contributor Author

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.

@kvark
Copy link
Member

kvark commented Feb 17, 2015

@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.

@brendanzab
Copy link
Contributor Author

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.

@kvark
Copy link
Member

kvark commented Feb 17, 2015

Sure thing. I'd be happy to finish the conversion, as well as move the device out of gfx_device_gl.

Let me know when you are ready for the merge. Also - are you confident enough to proceed without @csherratt review?

@ghost
Copy link

ghost commented Feb 18, 2015

Look ok to me.

@kvark
Copy link
Member

kvark commented Feb 18, 2015

@csherratt Thanks for having a look! Nice catch about Send though. If it doesn't work, that would prevent my apps (Asteroids, at least) from running. @bjz ?

@brendanzab
Copy link
Contributor Author

Maybe we should add that as a constraint for the resources?

@brendanzab
Copy link
Contributor Author

It wasn't me that picked it up - it was the type checker ^_^

@kvark
Copy link
Member

kvark commented Feb 18, 2015

@bjz please add the constraint to the resources, if you can.
Also, perhaps bring back the static reset command buffer.

@brendanzab
Copy link
Contributor Author

Yeah, sure thing - will do it when I get home.

@kvark
Copy link
Member

kvark commented Feb 18, 2015

@bjz when is this gonna happen, roughly?

@brendanzab
Copy link
Contributor Author

Done!

@brendanzab
Copy link
Contributor Author

This is ready to merge by the way, whenever you are free. I'm now working on decoupling the renderer.

@kvark
Copy link
Member

kvark commented Feb 18, 2015

@bjz Awesome, thanks!

kvark added a commit that referenced this pull request Feb 18, 2015
Associated resource type preparations
@kvark kvark merged commit dc200c6 into gfx-rs:master Feb 18, 2015
@brendanzab brendanzab deleted the associated-type-prep branch February 18, 2015 20:03
@ghost
Copy link

ghost commented Feb 19, 2015

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

glDrawArrays(GL_TRIANGLES, 0, 3) --> glDrawArrays(GL_POINTS, 0, 0)

So something really screwy is going on here. I'm using rustc 1.0.0-nightly (b63cee4a1 2015-02-14 17:01:11 +0000)

@brendanzab
Copy link
Contributor Author

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.

@brendanzab
Copy link
Contributor Author

The triangle works for one frame, then disappears. :/

@bvssvni
Copy link
Contributor

bvssvni commented Feb 19, 2015

Macros seem to be broken with rustc 1.0.0-nightly (6c065fc8c 2015-02-17) (built 2015-02-18).

@kvark
Copy link
Member

kvark commented Feb 19, 2015

@bvssvni didn't I fix them in #576 ?

Apparently the new changes hit the same rustc bug that was plaguing hematite.

@kvark
Copy link
Member

kvark commented Feb 19, 2015

@bjz I wish you could show up a bit more often... Is gitter not allowed at your workplace?
Are you still working on decoupling the device?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants