summaryrefslogtreecommitdiffstats
path: root/src/glsl/ir.h
diff options
context:
space:
mode:
authorSamuel Iglesias Gonsalvez <[email protected]>2015-04-13 16:17:07 +0200
committerSamuel Iglesias Gonsalvez <[email protected]>2015-09-25 08:39:21 +0200
commit273f61a0051a794d1a39d70fb1dbf46a3ca3c63f (patch)
tree85258cb644dccb440d29429d71dcbb7850f385d7 /src/glsl/ir.h
parent1440d2a6833902d9c966fe8ad7db46a7f787391c (diff)
glsl: Add parser/compiler support for unsized array's length()
The unsized array length is computed with the following formula: array.length() = max((buffer_object_size - offset_of_array) / stride_of_array, 0) Of these, only the buffer size needs to be provided by the backends, the frontend already knows the values of the two other variables. This patch identifies the cases where we need to get the length of an unsized array, injecting ir_unop_ssbo_unsized_array_length expressions that will be lowered (in a later patch) to inject the formula mentioned above. It also adds the ir_unop_get_buffer_size expression that drivers will implement to provide the buffer length. v2: - Do not define a triop that will force backends to implement the entire formula, they should only need to provide the buffer size since the other values are known by the frontend (Curro). v3: - Call state->has_shader_storage_buffer_objects() in ast_function.cpp instead of using state->ARB_shader_storage_buffer_object_enable (Tapani). Signed-off-by: Samuel Iglesias Gonsalvez <[email protected]> Reviewed-by: Kristian Høgsberg <[email protected]>
Diffstat (limited to 'src/glsl/ir.h')
-rw-r--r--src/glsl/ir.h19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/glsl/ir.h b/src/glsl/ir.h
index 48b6795cc09..43a2bf0ae1c 100644
--- a/src/glsl/ir.h
+++ b/src/glsl/ir.h
@@ -1425,9 +1425,26 @@ enum ir_expression_operation {
ir_unop_interpolate_at_centroid,
/**
+ * Ask the driver for the total size of a buffer block.
+ *
+ * operand0 is the ir_constant buffer block index in the linked shader.
+ */
+ ir_unop_get_buffer_size,
+
+ /**
+ * Calculate length of an unsized array inside a buffer block.
+ * This opcode is going to be replaced in a lowering pass inside
+ * the linker.
+ *
+ * operand0 is the unsized array's ir_value for the calculation
+ * of its length.
+ */
+ ir_unop_ssbo_unsized_array_length,
+
+ /**
* A sentinel marking the last of the unary operations.
*/
- ir_last_unop = ir_unop_interpolate_at_centroid,
+ ir_last_unop = ir_unop_ssbo_unsized_array_length,
ir_binop_add,
ir_binop_sub,