diff options
author | 2017-09-08 04:27:53 +0200 | |
---|---|---|
committer | 2017-09-12 02:57:45 +0200 | |
commit | 0c2cb69597f52592bdb58312d9987978cb86a9d3 (patch) | |
tree | 59883f675f41c3302c5b8603f038754993037cd2 /video/out/opengl/ra.c | |
parent | 3faf1fb0a4482712b2177af2f72ef8877f8adc10 (diff) |
vo_opengl: generalize UBO packing/handling
This is simultaneously generalized into two directions:
1. Support more sc_uniform types (needed for SC_UNIFORM_TYPE_PUSHC)
2. Support more flexible packing (needed for both PUSHC and ra_d3d11)
Diffstat (limited to 'video/out/opengl/ra.c')
-rw-r--r-- | video/out/opengl/ra.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/video/out/opengl/ra.c b/video/out/opengl/ra.c index 7f0053955b..208507dfa0 100644 --- a/video/out/opengl/ra.c +++ b/video/out/opengl/ra.c @@ -36,7 +36,7 @@ void ra_free(struct ra **ra) *ra = NULL; } -static size_t vartype_size(enum ra_vartype type) +size_t ra_vartype_size(enum ra_vartype type) { switch (type) { case RA_VARTYPE_INT: return sizeof(int); @@ -46,12 +46,18 @@ static size_t vartype_size(enum ra_vartype type) } } -// Return the size of the data ra_renderpass_input_val.data is going to point -// to. This returns 0 for non-primitive types such as textures. -size_t ra_render_pass_input_data_size(struct ra_renderpass_input *input) +struct ra_layout ra_renderpass_input_layout(struct ra_renderpass_input *input) { - size_t el_size = vartype_size(input->type); - return el_size * input->dim_v * input->dim_m; + size_t el_size = ra_vartype_size(input->type); + if (!el_size) + return (struct ra_layout){0}; + + // host data is always tightly packed + return (struct ra_layout) { + .align = 1, + .stride = el_size * input->dim_v, + .size = el_size * input->dim_v * input->dim_m, + }; } static struct ra_renderpass_input *dup_inputs(void *ta_parent, |