ra: assert when using params with dimensions

This came up in #9828. According to the header comments, creating a 1D
ra_tex requires height and depth to be set to 1. For a 2D texture, it
requires depth be set to 1. There were a couple of spots in mpv's code
where this wasn't being followed. Although there was no known bug from
this, the rest of the code works like this so it was a good idea to go
ahead and sync it up. As a followup, let's just add some simple asserts
to ra.c to enforce this so it doesn't go unnoticed in the future.
This commit is contained in:
Dudemanguy 2023-02-28 22:54:14 -06:00
parent 779d4f99a7
commit cd02b5ccf6
1 changed files with 10 additions and 0 deletions

View File

@ -26,6 +26,16 @@ void *ra_get_native_resource(struct ra *ra, const char *name)
struct ra_tex *ra_tex_create(struct ra *ra, const struct ra_tex_params *params)
{
switch (params->dimensions) {
case 1:
assert(params->h == 1 && params->d == 1);
break;
case 2:
assert(params->d == 1);
break;
default:
assert(params->dimensions >= 1 && params->dimensions <= 3);
}
return ra->fns->tex_create(ra, params);
}