QGraphicsHelpers: Add uniform block introspection

Change-Id: I6aebc07f5f7c2eac615204be5780e1d599b8c113
Note: Only supported since OpenGL 3.1
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
RenderShader: initialize uniform blocks method added

UniformBlocks are stored and indexed by their index.
That way they will easily be accessible as uniforms contain the corresponding
uniform blockindex.

Change-Id: I7c7da1ddbd808e380fd18c74d0942507b8b237b3
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
QGraphicsContext: initialize uniform blocks if helper supports it.

Change-Id: I8770580f5ac9e0449963359a6d90b7e2a5b9ef9a
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
QGraphicHelpers: bindUniformBlock method added,

Will allow to bind a UBO to a shader uniform block.

Change-Id: Iab8ede38236bc7ac92ea6147e072e01b7acf8bfd
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
QGraphicsHelperGL3/ShaderUniform: store array stride

If we have the array stride and the offset, we will be able to provide UBO
compatible with the shaders uniform blocks whether or not they have the
std140/std430 layout.

Change-Id: I964b267e07d654e6c0bc69c7478c93072088eeaf
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
RenderShader: added getters for uniform and attributes

Change-Id: Ica54fce8377fb9eff175576d702ab21d9599d029
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
RenderShaderData

-Property getter
-Do not store default QNode properties (data, childNodes)

Change-Id: I54c687592274ebbf56d296a9404c73f038d5dc91
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
RenderView: add QShaderData

- Preprocessing: shader data stored with the world transform
- setShaderAndUniform corrected to detect when a QParameter has a

Change-Id: Iaa8a0cc8a77c56a40a131e854e954da8ec6b2834
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
RenderLight: qDebug removed

Change-Id: Ida7ac0f77c31e0b36e9957ccfa0d024333fb9c83
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
QGraphicsHelper: bindBufferBase method added

Change-Id: I060326d6bfcc413c6c1692f7539696acf7e1a460
Note: Available since OpenGL 3.0 / ES 3.0 only
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
QGraphicsHelperGL3: store matrix stride and initialize index of uniform blocks

Change-Id: I88bbf841c8fb8342a8a20b3a62f1364eab8d0ca0
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
QGraphicsUtils: added methods to help filling UBO buffers

- for scalar and scalar arrays, fillDataArray will fill the byte buffer
  applying the array stride defined in the ShaderUniform description.

- for matrices, fillDataMatrixArray will fill the byte buffer applying a the
  matrix and array stride defined in the ShaderUniform description.

This will allow us to handle any type of packing for uniform blocks.

Change-Id: Idf6d16ecedecfc56b3e979a8a6760f1696805944
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Unit tests for QGraphicsUtils

Helps make sure that the methods are working as expected before being used by
the renderer.

Change-Id: If335bf4c7f9cb95d5e7b1f9bd862d438e71a3fe1
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
QGraphicsHelper: buildUniformBuffer method

Fills a uniform buffer with the correct OpenGL packing based on the shader
uniform description (offset, array stride, matrix stride).
The method should be called for every variable in the uniform block,
The buffer should be preallocated (can easily be done using the size stored in
the uniform block description)

Change-Id: Ib57e40a9e2c43d355bb0da73cc199cb98776fc50
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
QGraphicsContext: uniform block methods

They are basically forwarding the call to the QGraphicsHelper.

Change-Id: I498e77c9fe357644f28f1dc4bd0a0cafee991a40
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
QUniformPack: contains an array of uniform blocks/buffer

Based on the uniform block index and the uniform buffer (RenderShaderData),
the QUniformPack should have all what's needed to bind the proper UBO to be
used by a shader.

Change-Id: Ic1f7ae9b954a597ddb445de53d623672c3fbf425
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
UniformBuffer: wraps around the GL calls needed to have a UBO

Will be used by the RenderShaderData internally to map the CPU side buffer to
the GPU side Uniform Buffer Object.

Change-Id: I6b8ffdbff49d806bb8668df81ec59872feafe611
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
RenderShaderData completed to build UBO

Contains a UniformBuffer internally.
Once initialized created UBO on the GPU.
When properties of the QShaderData are updated, updated data is uploaded to
the UBO.
Some room for improvement, we'll improve that once the whole UBO/QShaderData
architecture is in place.

Change-Id: I26e55b78ad9633f75b988d8976ba496a7c7738fc
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
RenderView: handles Uniform Block values

UniformBlock values now trigger the initialization of the associated
RenderShaderData the first time they are used. Then the pair Uniform Block
index and RenderShaderData QNodeId is added to the QUniformPack.

Change-Id: I6f20ff830f46a9faeeceebfc30162b9438ce8a09
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
QGraphicsContext: UBO support implemented

Retrieve the Uniform Block index / RenderShaderData QNodeId pair in the
QUniformPack.
Assing the Uniform Block identified by its index to a binding point.
Use that to binding point to bind the UBO contained in the RenderShaderData.
Also added small comments in shadervariables and qgraphicshelpergl3 for
clarity.

Change-Id: I5eb9570f75f41953ad74529876ab842a48dc2a83
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>