Skip to content

Commit

Permalink
cover all cases of the unit tests
Browse files Browse the repository at this point in the history
Signed-off-by: uedaki <[email protected]>
  • Loading branch information
Uedaki committed Feb 14, 2024
1 parent 41828f3 commit baaa9ba
Showing 1 changed file with 55 additions and 7 deletions.
62 changes: 55 additions & 7 deletions src/testshade/simplerend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -695,8 +695,21 @@ SimpleRenderer::build_interpolated_getter(const ShaderGroup& group,

static const OIIO::ustring rs_get_attribute_constant_int(
"rs_get_attribute_constant_int");
static const OIIO::ustring rs_get_attribute_constant_int2(
"rs_get_attribute_constant_int2");
static const OIIO::ustring rs_get_attribute_constant_int3(
"rs_get_attribute_constant_int3");
static const OIIO::ustring rs_get_attribute_constant_int4(
"rs_get_attribute_constant_int4");

static const OIIO::ustring rs_get_attribute_constant_float(
"rs_get_attribute_constant_float");
static const OIIO::ustring rs_get_attribute_constant_float2(
"rs_get_attribute_constant_float2");
static const OIIO::ustring rs_get_attribute_constant_float3(
"rs_get_attribute_constant_float3");
static const OIIO::ustring rs_get_attribute_constant_float4(
"rs_get_attribute_constant_float4");

if (param_name == RS::Hashes::s && type == OIIO::TypeDesc::TypeFloat) {
spec.set(rs_get_interpolated_s,
Expand Down Expand Up @@ -727,14 +740,49 @@ SimpleRenderer::build_interpolated_getter(const ShaderGroup& group,
spec.set(rs_get_interpolated_test);
} else if (const OIIO::ParamValue* p = userdata.find_pv(param_name, type)) {
if (p->type().basetype == OIIO::TypeDesc::INT) {
spec.set(rs_get_attribute_constant_int,
((int*)p->data())[0]);
return;
if (p->type().aggregate == 1) {
spec.set(rs_get_attribute_constant_int,
((int*)p->data())[0]);
return;
} else if (p->type().aggregate == 2) {
spec.set(rs_get_attribute_constant_int2,
((int*)p->data())[0], ((int*)p->data())[1]);
return;
} else if (p->type().aggregate == 3) {
spec.set(rs_get_attribute_constant_int3,
((int*)p->data())[0], ((int*)p->data())[1],
((int*)p->data())[2]);
return;
} else if (p->type().aggregate == 4) {
spec.set(rs_get_attribute_constant_int4,
((int*)p->data())[0], ((int*)p->data())[1],
((int*)p->data())[2], ((int*)p->data())[3]);
return;
}
} else if (p->type().basetype == OIIO::TypeDesc::FLOAT) {
spec.set(rs_get_attribute_constant_float,
((float*)p->data())[0],
InterpolatedSpecBuiltinArg::Derivatives);
return;
if (p->type().aggregate == 1) {
spec.set(rs_get_attribute_constant_float,
((float*)p->data())[0],
InterpolatedSpecBuiltinArg::Derivatives);
return;
} else if (p->type().aggregate == 2) {
spec.set(rs_get_attribute_constant_float2,
((float*)p->data())[0], ((float*)p->data())[1],
InterpolatedSpecBuiltinArg::Derivatives);
return;
} else if (p->type().aggregate == 3) {
spec.set(rs_get_attribute_constant_float3,
((float*)p->data())[0], ((float*)p->data())[1],
((float*)p->data())[2],
InterpolatedSpecBuiltinArg::Derivatives);
return;
} else if (p->type().aggregate == 4) {
spec.set(rs_get_attribute_constant_float4,
((float*)p->data())[0], ((float*)p->data())[1],
((float*)p->data())[2], ((float*)p->data())[3],
InterpolatedSpecBuiltinArg::Derivatives);
return;
}
}
}
}
Expand Down

0 comments on commit baaa9ba

Please sign in to comment.