Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upSplit of referrence batches into Core/non-Core #628
Conversation
kvark
added some commits
Mar 4, 2015
kvark
added
the
status: working
label
Mar 4, 2015
kvark
added some commits
Mar 4, 2015
This comment has been minimized.
This comment has been minimized.
|
Looks good. |
brendanzab
reviewed
Mar 4, 2015
| type Texture = (); | ||
| type Sampler = (); | ||
| } | ||
|
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
brendanzab
reviewed
Mar 4, 2015
| &mut self.context | ||
| } | ||
| } | ||
|
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
kvark
Mar 4, 2015
Author
Member
This allows make_batch, make_core, and bind to be called from Graphics, instead of wrapping them up into pass-through methods.
This comment has been minimized.
This comment has been minimized.
brendanzab
Mar 4, 2015
Member
Hmm, ok - just think it might be an abuse of Deref, which is a debate I would rather not have on this PR.
This comment has been minimized.
This comment has been minimized.
kvark
Mar 4, 2015
Author
Member
Feel free to open this debate anywhere please. I'm not too experienced with Deref practices and would be happy to know more.
brendanzab
reviewed
Mar 4, 2015
| @@ -236,66 +237,113 @@ impl<T: Clone + PartialEq> Array<T> { | |||
| } | |||
|
|
|||
|
|
|||
| /// Ref batch - copyable and smaller, but depends on the `Context`. | |||
| /// Referrenced core - a minimal sealed batch that depends on `Context`. | |||
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
brendanzab
reviewed
Mar 4, 2015
| /// It has references to the resources (mesh, program, state), that are held | ||
| /// by the context that created the batch, so these have to be used together. | ||
| pub struct RefBatch<T: ShaderParam> { | ||
| pub struct RefCore<T: ShaderParam> { |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
kvark
Mar 4, 2015
Author
Member
I haven't really thought about names, no. RefBatchData doesn't sound too good because it bears the "data" term, while in fact RefCore can be seen as a batch type. Yes it is incomplete (requires not only the context, but also a slice and a parameter data), but neither is RefBatch (needs the context).
I don't insist on RefCore name though. My understanding is that since we don't re-export everything in batch module, this type is accessed as gfx::batch::RefCore, which makes it less ambiguous. Perhaps, you'd prefer CoreBatch more?
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
One of the reasons behind the PR is also an attempt to standardize handle operations. I don't like the fact that some handles are copyable ( |
This comment has been minimized.
This comment has been minimized.
|
@stjahns this PR would improve this code in skeletal_animation: pub struct SkinnedRenderer {
animation_clip: AnimationClip,
skinning_transforms_buffer: BufferHandle<GlResources, [[f32; 4]; 4]>,
shader_params: SkinnedShaderParams<GlResources>,
batch: RefBatch<SkinnedShaderParams<GlResources>>,
}Also, I believe you really need this to be device-agnostic: pub struct SkinnedRenderer<R: Resources> {
animation_clip: AnimationClip,
skinning_transforms_buffer: BufferHandle<R, [[f32; 4]; 4]>,
batch: RefBatch<SkinnedShaderParams<R>>,
} |
stjahns
added a commit
to stjahns/gfx-debug-draw
that referenced
this pull request
Mar 4, 2015
This comment has been minimized.
This comment has been minimized.
|
Works for me / Am I doin' it rite? |
kvark
force-pushed the
kvark:core
branch
from
03e1364
to
67c4dff
Mar 5, 2015
This comment has been minimized.
This comment has been minimized.
|
Self-merging as everything is fixed and the concept has been approved. |
kvark commentedMar 4, 2015
(This is a breaking change, please review carefully)
I noticed a couple of things that weren't sound:
RefBatchcarried a publicly accessibleslice, while not carrying the parameters. The reason for the former was "convenience" (IIRC), the reason for the latter was "just because we can". Hence, this type was neither complete nor minimal.RefBatch. They are often seen together, and that wasn't convenient to do.As a solution, I made a
RefCorebatch that only carries minimal (for safety) sealed data, nothing is available to public. TheRefBatchnow is rather open - it carries the core as well as a slice (like it used to) and a parameter structure, all mutable by public.The idea is -
RefCoreto be used for maximum flexibility, like creating a batch when not yet having a parameter structure at hands, or using it with multiple parameters/slices. WhileRefBatchis just a convenient thing to have. The maintenance cost is minimal, since they are re-using lots of code.RefBatchis also nice for ergonomic reasons - you can create a batch with type inference.