Passing uniform buffers to the vertex/pixel programs This cl contains the necessary changes to make uniform buffers usable in shaders. A few things to note: - Uniform buffers can be set, but nothing will attempt to access them in this cl. - While the 'index' of uniforms is expressed in terms of registers, uniform buffer 'index' is expressed in bytes in both PixelProgram and VertexProgram. This is necessary because of packing which can potentially put some variables in the middle of registers. Technically, std140 always packs variables in multiples of byte4, but other future layouts may not, so using bytes as the unit is more future proof. - The above mentioned 'index' will have to be computed in OutputASM and extra operations will need to be added (to fetch a row from a row major matrix, for example). Change-Id: I636cc4bdc6fe90d6f5697e735f4288f48d18a75b Reviewed-on: https://swiftshader-review.googlesource.com/4151 Tested-by: Alexis Hétu <sugoi@google.com> Reviewed-by: Nicolas Capens <capn@google.com>
diff --git a/src/Renderer/Renderer.cpp b/src/Renderer/Renderer.cpp index 52589d2..ca5e67a 100644 --- a/src/Renderer/Renderer.cpp +++ b/src/Renderer/Renderer.cpp
@@ -382,6 +382,8 @@ memcpy(&data->ps.b, PixelProcessor::b, sizeof(bool) * draw->psDirtyConstB); draw->psDirtyConstB = 0; } + + PixelProcessor::lockUniformBuffers(data->ps.u); } if(context->pixelShaderVersion() <= 0x0104) @@ -434,6 +436,8 @@ { data->instanceID = context->instanceID; } + + VertexProcessor::lockUniformBuffers(data->vs.u); } else { @@ -954,6 +958,9 @@ draw.indexBuffer->unlock(); } + PixelProcessor::unlockUniformBuffers(); + VertexProcessor::unlockUniformBuffers(); + draw.vertexRoutine->unbind(); draw.setupRoutine->unbind(); draw.pixelRoutine->unbind();