Переглянути джерело

glsl_type: Add method to get number of slots used by a type

tags/mesa-7.9-rc1
Ian Romanick 15 роки тому
джерело
коміт
57bb893a46
2 змінених файлів з 37 додано та 0 видалено
  1. 28
    0
      glsl_types.cpp
  2. 9
    0
      glsl_types.h

+ 28
- 0
glsl_types.cpp Переглянути файл

@@ -732,3 +732,31 @@ glsl_type::field_index(const char *name) const

return -1;
}


unsigned
glsl_type::component_slots() const
{
switch (this->base_type) {
case GLSL_TYPE_UINT:
case GLSL_TYPE_INT:
case GLSL_TYPE_FLOAT:
case GLSL_TYPE_BOOL:
return this->components();

case GLSL_TYPE_STRUCT: {
unsigned size = 0;

for (unsigned i = 0; i < this->length; i++)
size += this->fields.structure[i].type->component_slots();

return size;
}

case GLSL_TYPE_ARRAY:
return this->length * this->fields.array->component_slots();

default:
return 0;
}
}

+ 9
- 0
glsl_types.h Переглянути файл

@@ -214,6 +214,15 @@ struct glsl_type {
return vector_elements * matrix_columns;
}

/**
* Calculate the number of components slots required to hold this type
*
* This is used to determine how many uniform or varying locations a type
* might occupy.
*/
unsigned component_slots() const;


/**
* Query whether or not a type is a scalar (non-vector and non-matrix).
*/

Завантаження…
Відмінити
Зберегти