Currently shame always converts to float vecs when passing to the fragment stage
|
fn vec_fill_any<T: ScalarType, L: Len>(v: &vec<T, L>, method: FragmentSampleMethod, loc: Location) -> Any { |
|
match T::SCALAR_TYPE { |
|
ir::ScalarType::F16 | ir::ScalarType::F32 | ir::ScalarType::F64 => v.as_any(), |
|
ir::ScalarType::U32 | ir::ScalarType::I32 | ir::ScalarType::Bool => { |
|
// convert to vec<f32, L> then fill. |
|
Any::new_vec(L::LEN, ir::ScalarType::F32, &[v.as_any()]) |
|
} |
|
} |
|
.fill_fragments(loc, method) |
|
} |
I believe this should not be the case. For example, you should be able to use
fill_flat on a
u32x1 to pass a
u32x1 to the fragment stage. The conversion to floats would be removed (which I prefer anyway, because the user can easily convert to floats themselves using
to_f32, which is more explicit).
The type-safe way to implement this is to have a SupportsFill<Fill> trait and make Fill a trait instead of an enum. However, when/if this is implemented, please keep a non-type-safe version that takes an enum as input too (making it a runtime error if a non-float vec is used with a fill rate other than flat).
Currently shame always converts to float vecs when passing to the fragment stage
shame/shame/src/frontend/encoding/fill.rs
Lines 216 to 225 in 4beb307
I believe this should not be the case. For example, you should be able to use
fill_flaton au32x1to pass au32x1to the fragment stage. The conversion to floats would be removed (which I prefer anyway, because the user can easily convert to floats themselves usingto_f32, which is more explicit).The type-safe way to implement this is to have a
SupportsFill<Fill>trait and makeFilla trait instead of an enum. However, when/if this is implemented, please keep a non-type-safe version that takes an enum as input too (making it a runtime error if a non-float vec is used with a fill rate other than flat).