[Mesa-dev] [PATCH 6/6] nir/spirv: handle functions with scalar and vector params
Karol Herbst
kherbst at redhat.com
Sun Jul 15 05:40:35 UTC 2018
On Sun, Jul 15, 2018 at 4:58 AM, Jason Ekstrand <jason at jlekstrand.net> wrote:
> I'm not really sure what this doing. Mind giving some more explanation? Is
> this something that's an issue with Vulkan SPIR-V as well?
>
I am not entirely sure. I know this came up when I called functions
having vectors and scalars as arguments. I am not quite sure how that
works for Vulkan spir-v, because in glsl you usually pass everything
in by reference, but there are also "in" parameters. I will check with
glslang what happens here and if I see there the same problem as with
OpenCL.
> On Thu, Jul 12, 2018 at 4:30 AM Karol Herbst <kherbst at redhat.com> wrote:
>>
>> Signed-off-by: Karol Herbst <kherbst at redhat.com>
>> ---
>> src/compiler/spirv/vtn_cfg.c | 25 ++++++++++++++++++-------
>> 1 file changed, 18 insertions(+), 7 deletions(-)
>>
>> diff --git a/src/compiler/spirv/vtn_cfg.c b/src/compiler/spirv/vtn_cfg.c
>> index ed1ab5d1c2c..2b01ede6f81 100644
>> --- a/src/compiler/spirv/vtn_cfg.c
>> +++ b/src/compiler/spirv/vtn_cfg.c
>> @@ -90,7 +90,10 @@ vtn_cfg_handle_prepass_instruction(struct vtn_builder
>> *b, SpvOp opcode,
>> }
>>
>> for (unsigned i = 0; i < func_type->length; i++) {
>> - if (func_type->params[i]->base_type ==
>> vtn_base_type_sampled_image) {
>> + enum vtn_base_type base_type = func_type->params[i]->base_type;
>> + const struct glsl_type *type = func_type->params[i]->type;
>> +
>> + if (base_type == vtn_base_type_sampled_image) {
>> /* Sampled images are two pointer parameters */
>> func->params[idx++] = (nir_parameter) {
>> .num_components = 1, .bit_size = 32,
>> @@ -98,14 +101,22 @@ vtn_cfg_handle_prepass_instruction(struct vtn_builder
>> *b, SpvOp opcode,
>> func->params[idx++] = (nir_parameter) {
>> .num_components = 1, .bit_size = 32,
>> };
>> - } else if (func_type->params[i]->base_type ==
>> vtn_base_type_pointer &&
>> - func_type->params[i]->type != NULL) {
>> + } else if (base_type == vtn_base_type_pointer && type != NULL) {
>> /* Pointers with as storage class get passed by-value */
>> -
>> assert(glsl_type_is_vector_or_scalar(func_type->params[i]->type));
>> + assert(glsl_type_is_vector_or_scalar(type));
>> + func->params[idx++] = (nir_parameter) {
>> + .num_components = glsl_get_vector_elements(type),
>> + .bit_size = glsl_get_bit_size(type),
>> + };
>> + } else if (base_type == vtn_base_type_scalar) {
>> + func->params[idx++] = (nir_parameter) {
>> + .num_components = 1,
>> + .bit_size = glsl_get_bit_size(type),
>> + };
>> + } else if (base_type == vtn_base_type_vector) {
>> func->params[idx++] = (nir_parameter) {
>> - .num_components =
>> - glsl_get_vector_elements(func_type->params[i]->type),
>> - .bit_size = glsl_get_bit_size(func_type->params[i]->type),
>> + .num_components = glsl_get_components(type),
>> + .bit_size = glsl_get_bit_size(type),
>> };
>> } else {
>> /* Everything else is a regular pointer */
>> --
>> 2.17.1
>>
>> _______________________________________________
>> mesa-dev mailing list
>> mesa-dev at lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
More information about the mesa-dev
mailing list