Skip to content

Commit c5e6d03

Browse files
committed
(wip) Add support for existential uniforms.
This commit provides support for existential in `Uniform<T>`, so that it’s possible to ask for things like `&'a [T; N]`, where `'a` comes from call-site. The current implementation is not perfect as it would be normally implemented with GATs… but I don’t have GATs. Relates to #438.
1 parent de645dd commit c5e6d03

File tree

9 files changed

+360
-454
lines changed

9 files changed

+360
-454
lines changed

luminance-derive/src/uniform_interface.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -120,18 +120,18 @@ pub(crate) fn generate_uniform_interface_impl(
120120
let #field_ident = #build_call;
121121
});
122122
field_where_clause.push(quote! {
123-
S: luminance::backend::shader::Uniformable<#field_ty>
123+
B: for<'a> luminance::backend::shader::Uniformable<'a, #field_ty>
124124
});
125125
}
126126

127127
let output = quote! {
128-
impl<S> luminance::shader::UniformInterface<S> for #ident
128+
impl<B> luminance::shader::UniformInterface<B> for #ident
129129
where
130-
S: ?Sized + luminance::backend::shader::Shader,
130+
B: luminance::backend::shader::Shader,
131131
#(#field_where_clause),*,
132132
{
133133
fn uniform_interface<'a>(
134-
builder: &mut luminance::shader::UniformBuilder<'a, S>,
134+
builder: &mut luminance::shader::UniformBuilder<'a, B>,
135135
_: &mut ()
136136
) -> Result<Self, luminance::shader::UniformWarning> {
137137
#(#field_decls)*

luminance-gl/src/gl33/pipeline.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use luminance::{
2020
tess::{Deinterleaved, DeinterleavedData, Interleaved, TessIndex, TessVertexData},
2121
texture::Dimensionable,
2222
};
23-
use luminance_std140::{Arr, Std140};
23+
use luminance_std140::{ArrElem, Std140};
2424
use std::{cell::RefCell, marker::PhantomData, rc::Rc};
2525

2626
pub struct Pipeline {
@@ -187,7 +187,7 @@ where
187187

188188
unsafe impl<T> PipelineShaderData<T> for GL33
189189
where
190-
Self: ShaderData<T, ShaderDataRepr = Buffer<<Arr<T> as Std140>::Encoded>>,
190+
Self: ShaderData<T, ShaderDataRepr = Buffer<<ArrElem<T> as Std140>::Encoded>>,
191191
T: Std140,
192192
{
193193
type BoundShaderDataRepr = BoundShaderData<T>;

0 commit comments

Comments
 (0)