summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTapani Pälli <tapani.palli@intel.com>2014-08-27 14:12:27 +0300
committerEmil Velikov <emil.l.velikov@gmail.com>2014-10-29 17:52:59 +0000
commit4ed4dec642bd192f0f1f8fd5bfe7b327c7f8f20b (patch)
tree2505523b75904e4280833dda47d4975aa7bfeda7 /src
parenta3d5e59563a9085d68cb192e4ab9f691b3beb5ec (diff)
glsl: fix uniform location count used for glsl types
Patch fixes the slot count used by vector types and adds 1 slot to be used by image and sampler types. Signed-off-by: Tapani Pälli <tapani.palli@intel.com> Reviewed-by: Francisco Jerez <currojerez@riseup.net> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=82921 (cherry picked from commit 1cb81d3a9b65781802f641fb3e4435edfed7f14a)
Diffstat (limited to 'src')
-rw-r--r--src/glsl/glsl_types.cpp18
-rw-r--r--src/glsl/glsl_types.h3
2 files changed, 12 insertions, 9 deletions
diff --git a/src/glsl/glsl_types.cpp b/src/glsl/glsl_types.cpp
index 56b96f5acf3..f785790a9f1 100644
--- a/src/glsl/glsl_types.cpp
+++ b/src/glsl/glsl_types.cpp
@@ -678,12 +678,17 @@ glsl_type::component_slots() const
unsigned
glsl_type::uniform_locations() const
{
- if (this->is_matrix())
- return 1;
-
unsigned size = 0;
switch (this->base_type) {
+ case GLSL_TYPE_UINT:
+ case GLSL_TYPE_INT:
+ case GLSL_TYPE_FLOAT:
+ case GLSL_TYPE_BOOL:
+ case GLSL_TYPE_SAMPLER:
+ case GLSL_TYPE_IMAGE:
+ return 1;
+
case GLSL_TYPE_STRUCT:
case GLSL_TYPE_INTERFACE:
for (unsigned i = 0; i < this->length; i++)
@@ -692,13 +697,8 @@ glsl_type::uniform_locations() const
case GLSL_TYPE_ARRAY:
return this->length * this->fields.array->uniform_locations();
default:
- break;
+ return 0;
}
-
- /* The location count for many types match with component_slots() result,
- * all expections should be handled above.
- */
- return component_slots();
}
bool
diff --git a/src/glsl/glsl_types.h b/src/glsl/glsl_types.h
index d545533dcd2..5a307bb7404 100644
--- a/src/glsl/glsl_types.h
+++ b/src/glsl/glsl_types.h
@@ -279,6 +279,9 @@ struct glsl_type {
/**
* Calculate the number of unique values from glGetUniformLocation for the
* elements of the type.
+ *
+ * This is used to allocate slots in the UniformRemapTable, the amount of
+ * locations may not match with actual used storage space by the driver.
*/
unsigned uniform_locations() const;