[PATCH vkd3d v2 4/5] vkd3d-shader/hlsl: Handle texture types in hlsl_type_to_string().

Zebediah Figura (she/her) zfigura at codeweavers.com
Thu Oct 7 17:10:35 CDT 2021


On 10/7/21 13:46, Matteo Bruni wrote:
> On Wed, Oct 6, 2021 at 4:45 PM Zebediah Figura <zfigura at codeweavers.com> wrote:
>>
>> Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
>> ---
>>   libs/vkd3d-shader/hlsl.c | 29 +++++++++++++++++++++++++++++
>>   1 file changed, 29 insertions(+)
>>
>> diff --git a/libs/vkd3d-shader/hlsl.c b/libs/vkd3d-shader/hlsl.c
>> index 1f23a478c..87841e0e4 100644
>> --- a/libs/vkd3d-shader/hlsl.c
>> +++ b/libs/vkd3d-shader/hlsl.c
>> @@ -886,6 +886,35 @@ struct vkd3d_string_buffer *hlsl_type_to_string(struct hlsl_ctx *ctx, const stru
>>               vkd3d_string_buffer_printf(string, "<anonymous struct>");
>>               return string;
>>
>> +        case HLSL_CLASS_OBJECT:
>> +        {
>> +            static const char dimensions[5][HLSL_SAMPLER_DIM_MAX + 1] =
>> +            {
>> +                [HLSL_SAMPLER_DIM_1D] = "1D",
>> +                [HLSL_SAMPLER_DIM_2D] = "2D",
>> +                [HLSL_SAMPLER_DIM_3D] = "3D",
>> +                [HLSL_SAMPLER_DIM_CUBE] = "Cube"
>> +            };
>> +
>> +            switch (type->base_type)
>> +            {
>> +                case HLSL_TYPE_TEXTURE:
>> +                    if (type->sampler_dim == HLSL_SAMPLER_DIM_GENERIC)
>> +                    {
>> +                        vkd3d_string_buffer_printf(string, "texture");
>> +                        return string;
>> +                    }
> 
> This made me curious about the casing of the generic "texture" (only
> lowercase?) so I ran a few tests. It looks like "texture" actually
> accepts all the casing variations. It is also still handled as a
> keyword rather than an identifier, somehow.
> Maybe you were already aware of this. At any rate, I don't think we
> should care until we find some application that depends on it.

That's pretty easy to achieve with flex, actually, but I'll leave it 
alone regardless.

> 
>> +
>> +                    vkd3d_string_buffer_printf(string, "Texture%s<%s%u>", dimensions[type->sampler_dim],
>> +                            base_types[type->e.resource_format->base_type], type->e.resource_format->dimx);
>> +                    return string;
> 
> I guess this could use a couple of asserts for the array indices, if
> we're feeling paranoid.
> 

I wasn't feeling particularly paranoid, but I can add them anyway.



More information about the wine-devel mailing list