Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2019-07-14 17:49:44 +0300
committerClément Foucault <foucault.clem@gmail.com>2019-08-14 20:05:26 +0300
commit9c010c44f4201ab114b3facc69d0343525a1779f (patch)
tree744271becd24cead6c900e4f023d8c0bfa6138b6 /source/blender/gpu/intern/gpu_vertex_format.c
parent45a45f7d66211e82a3a3288782ad9523e8fdc516 (diff)
Mesh Batch Cache: Refactor + Multithread
For clarity sake, the batch cache now uses exclusively per Loop attributes. While this is a bit of a waste of VRAM (for the few case where per vert attribs are enough) it reduces the complexity and amount of overall VBO to update in general situations. This patch also makes the VertexBuffers filling multithreaded. This make the update of dense meshes a bit faster. The main bottleneck is the IndexBuffers update which cannot be multithreaded efficiently (have to increment a counter and/or do a final sorting pass). We introduce the concept of "extract" functions/step. All extract functions are executed in one thread each and if possible, using multiple thread for looping over all elements. Reviewed By: brecht Differential Revision: http://developer.blender.org/D5424
Diffstat (limited to 'source/blender/gpu/intern/gpu_vertex_format.c')
-rw-r--r--source/blender/gpu/intern/gpu_vertex_format.c78
1 files changed, 23 insertions, 55 deletions
diff --git a/source/blender/gpu/intern/gpu_vertex_format.c b/source/blender/gpu/intern/gpu_vertex_format.c
index 493c6d3ec59..f672d350afa 100644
--- a/source/blender/gpu/intern/gpu_vertex_format.c
+++ b/source/blender/gpu/intern/gpu_vertex_format.c
@@ -218,6 +218,29 @@ int GPU_vertformat_attr_id_get(const GPUVertFormat *format, const char *name)
return -1;
}
+/* Make attribute layout non-interleaved.
+ * Warning! This does not change data layout!
+ * Use direct buffer access to fill the data.
+ * This is for advanced usage.
+ *
+ * Deinterleaved data means all attrib data for each attrib
+ * is stored continuously like this :
+ * 000011112222
+ * instead of :
+ * 012012012012
+ *
+ * Note this is per attrib deinterleaving, NOT per component.
+ * */
+void GPU_vertformat_deinterleave(GPUVertFormat *format)
+{
+ /* Ideally we should change the stride and offset here. This would allow
+ * us to use GPU_vertbuf_attr_set / GPU_vertbuf_attr_fill. But since
+ * we use only 11 bits for attr->offset this limits the size of the
+ * buffer considerably. So instead we do the conversion when creating
+ * bindings in create_bindings(). */
+ format->deinterleaved = true;
+}
+
uint padding(uint offset, uint alignment)
{
const uint mod = offset % alignment;
@@ -391,58 +414,3 @@ void GPU_vertformat_from_interface(GPUVertFormat *format, const GPUShaderInterfa
}
}
}
-
-/* OpenGL ES packs in a different order as desktop GL but component conversion is the same.
- * Of the code here, only struct GPUPackedNormal needs to change. */
-
-#define SIGNED_INT_10_MAX 511
-#define SIGNED_INT_10_MIN -512
-
-static int clampi(int x, int min_allowed, int max_allowed)
-{
-#if TRUST_NO_ONE
- assert(min_allowed <= max_allowed);
-#endif
- if (x < min_allowed) {
- return min_allowed;
- }
- else if (x > max_allowed) {
- return max_allowed;
- }
- else {
- return x;
- }
-}
-
-static int quantize(float x)
-{
- int qx = x * 511.0f;
- return clampi(qx, SIGNED_INT_10_MIN, SIGNED_INT_10_MAX);
-}
-
-static int convert_i16(short x)
-{
- /* 16-bit signed --> 10-bit signed */
- /* TODO: round? */
- return x >> 6;
-}
-
-GPUPackedNormal GPU_normal_convert_i10_v3(const float data[3])
-{
- GPUPackedNormal n = {
- .x = quantize(data[0]),
- .y = quantize(data[1]),
- .z = quantize(data[2]),
- };
- return n;
-}
-
-GPUPackedNormal GPU_normal_convert_i10_s3(const short data[3])
-{
- GPUPackedNormal n = {
- .x = convert_i16(data[0]),
- .y = convert_i16(data[1]),
- .z = convert_i16(data[2]),
- };
- return n;
-}