[PATCH vkd3d 1/7] tests: Test casts to float.
Zebediah Figura (she/her)
zfigura at codeweavers.com
Thu Sep 9 19:36:23 CDT 2021
On 9/9/21 6:21 PM, Matteo Bruni wrote:
> On Thu, Sep 9, 2021 at 6:01 AM Zebediah Figura <zfigura at codeweavers.com> wrote:
>>
>> Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
>> ---
>> Makefile.am | 2 ++
>> tests/cast-to-float.shader_test | 29 +++++++++++++++++++++++++++++
>> tests/shader_runner_d3d12.c | 33 ++++++++++++++++++++++++++++++---
>> 3 files changed, 61 insertions(+), 3 deletions(-)
>> create mode 100644 tests/cast-to-float.shader_test
>
>> diff --git a/tests/shader_runner_d3d12.c b/tests/shader_runner_d3d12.c
>> index 2221c0f87..86151e424 100644
>> --- a/tests/shader_runner_d3d12.c
>> +++ b/tests/shader_runner_d3d12.c
>
>> @@ -242,11 +242,38 @@ static void parse_test_directive(struct shader_context *context, const char *lin
>> }
>> memcpy(context->uniforms + offset, &v, sizeof(v));
>> }
>> + else if (match_string(line, "float", &line))
>> + {
>> + float f;
>> +
>> + if (!(f = strtof(line, &line)) && !line)
>> + goto err;
>> + if (offset + 1 > context->uniform_count)
>> + {
>> + context->uniform_count = offset + 1;
>> + context->uniforms = realloc(context->uniforms, context->uniform_count * sizeof(*context->uniforms));
>> + }
>> + memcpy(context->uniforms + offset, &f, sizeof(f));
>> + }
>> + else if (match_string(line, "int", &line))
>> + {
>> + int i;
>> +
>> + if (!(i = strtol(line, &line, 0)))
>> + goto err;
>> + if (offset + 1 > context->uniform_count)
>> + {
>> + context->uniform_count = offset + 1;
>> + context->uniforms = realloc(context->uniforms, context->uniform_count * sizeof(*context->uniforms));
>> + }
>> + memcpy(context->uniforms + offset, &i, sizeof(i));
>> + }
>> else if (match_string(line, "uint", &line))
>> {
>> unsigned int u;
>>
>> - sscanf(line, "%u", &u);
>> + if (!(u = strtoul(line, &line, 0)))
>> + goto err;
>> if (offset + 1 > context->uniform_count)
>> {
>> context->uniform_count = offset + 1;
>
> Strictly speaking, it doesn't seem necessary to change and use the
> strto*() functions instead of sscanf() in all the non-float4 cases.
> Unless you have plans...
>
That was me wanting to use 0x, and being too lazy to fix this the right
way. Fortunately a two-second look at the man page for sscanf(3) tells
me the right way to fix this :-)
More information about the wine-devel
mailing list