Commit 829470a9 authored by Niklas Haas's avatar Niklas Haas

tests: add test case for pl_gpu dummy

parent 5d0c1f8d
......@@ -117,6 +117,7 @@ tests = [
'context.c',
'colorspace.c',
'dither.c',
'dummy.c',
'filters.c',
'utils.c',
]
......@@ -247,6 +248,7 @@ if get_option('tests')
foreach t : tests
e = executable('test.' + t, 'tests/' + t,
objects: lib.extract_all_objects(recursive: false),
c_args: [ '-Wno-unused-function' ],
dependencies: tdep,
)
......
#include "gpu_tests.h"
int main()
{
struct pl_context *ctx = pl_test_context();
const struct pl_gpu *gpu = pl_gpu_dummy_create(ctx, NULL);
pl_texture_tests(gpu);
// Attempt creating a shader and accessing the resulting LUT
const struct pl_tex *dummy = pl_tex_dummy_create(gpu, &(struct pl_tex_params) {
.w = 100,
.h = 100,
.format = pl_find_named_fmt(gpu, "rgba8"),
.sample_mode = PL_TEX_SAMPLE_LINEAR,
.address_mode = PL_TEX_ADDRESS_CLAMP,
});
struct pl_sample_src src = {
.tex = dummy,
.new_w = 1000,
.new_h = 1000,
};
struct pl_shader_obj *lut = NULL;
struct pl_sample_filter_params filter_params = {
.filter = pl_filter_ewa_lanczos,
.lut = &lut,
};
struct pl_shader *sh = pl_shader_alloc(ctx, gpu, 0);
REQUIRE(pl_shader_sample_polar(sh, &src, &filter_params));
const struct pl_shader_res *res = pl_shader_finalize(sh);
REQUIRE(res);
for (int n = 0; n < res->num_descriptors; n++) {
const struct pl_shader_desc *sd = &res->descriptors[n];
if (sd->desc.type != PL_DESC_SAMPLED_TEX)
continue;
const struct pl_tex *tex = sd->object;
const float *data = (float *) pl_tex_dummy_data(tex);
if (!data)
continue; // means this was the `dummy` texture
for (int i = 0; i < tex->params.w; i++)
printf("lut[%d] = %f\n", i, data[i]);
}
pl_shader_free(&sh);
pl_shader_obj_destroy(&lut);
pl_tex_destroy(gpu, &dummy);
pl_gpu_dummy_destroy(&gpu);
pl_context_destroy(&ctx);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment