[Bf-blender-cvs] [a35da181f00] temp-gpu-compute-shaders: Size of indexbuffer needs to be given by the caller.
Jeroen Bakker
noreply at git.blender.org
Wed May 12 07:46:50 CEST 2021
Commit: a35da181f00ec93c883f67a922ced1f899ebf205
Author: Jeroen Bakker
Date: Wed May 12 07:46:13 2021 +0200
Branches: temp-gpu-compute-shaders
https://developer.blender.org/rBa35da181f00ec93c883f67a922ced1f899ebf205
Size of indexbuffer needs to be given by the caller.
===================================================================
M source/blender/gpu/GPU_index_buffer.h
M source/blender/gpu/intern/gpu_index_buffer.cc
M source/blender/gpu/intern/gpu_index_buffer_private.hh
M source/blender/gpu/opengl/gl_index_buffer.cc
M source/blender/gpu/tests/gpu_shader_test.cc
===================================================================
diff --git a/source/blender/gpu/GPU_index_buffer.h b/source/blender/gpu/GPU_index_buffer.h
index 5ab0299c35d..03e39a5d846 100644
--- a/source/blender/gpu/GPU_index_buffer.h
+++ b/source/blender/gpu/GPU_index_buffer.h
@@ -49,7 +49,7 @@ void GPU_indexbuf_init_ex(GPUIndexBufBuilder *, GPUPrimType, uint index_len, uin
/* supports only GPU_PRIM_POINTS, GPU_PRIM_LINES and GPU_PRIM_TRIS. */
void GPU_indexbuf_init(GPUIndexBufBuilder *, GPUPrimType, uint prim_len, uint vertex_len);
-GPUIndexBuf *GPU_indexbuf_build_on_device(GPUPrimType, uint prim_len);
+GPUIndexBuf *GPU_indexbuf_build_on_device(uint index_len);
void GPU_indexbuf_add_generic_vert(GPUIndexBufBuilder *, uint v);
void GPU_indexbuf_add_primitive_restart(GPUIndexBufBuilder *);
diff --git a/source/blender/gpu/intern/gpu_index_buffer.cc b/source/blender/gpu/intern/gpu_index_buffer.cc
index b9d1514c7c4..3586c512fda 100644
--- a/source/blender/gpu/intern/gpu_index_buffer.cc
+++ b/source/blender/gpu/intern/gpu_index_buffer.cc
@@ -66,11 +66,11 @@ void GPU_indexbuf_init(GPUIndexBufBuilder *builder,
GPU_indexbuf_init_ex(builder, prim_type, prim_len * (uint)verts_per_prim, vertex_len);
}
-GPUIndexBuf *GPU_indexbuf_build_on_device(GPUPrimType prim_type, uint prim_len)
+GPUIndexBuf *GPU_indexbuf_build_on_device(uint index_len)
{
GPUIndexBuf *elem_ = GPU_indexbuf_calloc();
IndexBuf *elem = unwrap(elem_);
- elem->init_build_on_device(prim_type, prim_len);
+ elem->init_build_on_device(index_len);
return elem_;
}
@@ -249,11 +249,11 @@ void IndexBuf::init(uint indices_len, uint32_t *indices)
#endif
}
-void IndexBuf::init_build_on_device(GPUPrimType prim_type, uint prim_len)
+void IndexBuf::init_build_on_device(uint index_len)
{
is_init_ = true;
index_start_ = 0;
- index_len_ = prim_len * indices_per_primitive(prim_type);
+ index_len_ = index_len;
index_type_ = GPU_INDEX_U32;
data_ = nullptr;
}
diff --git a/source/blender/gpu/intern/gpu_index_buffer_private.hh b/source/blender/gpu/intern/gpu_index_buffer_private.hh
index 113b054953f..9d81c338417 100644
--- a/source/blender/gpu/intern/gpu_index_buffer_private.hh
+++ b/source/blender/gpu/intern/gpu_index_buffer_private.hh
@@ -75,7 +75,7 @@ class IndexBuf {
void init(uint indices_len, uint32_t *indices);
void init_subrange(IndexBuf *elem_src, uint start, uint length);
- void init_build_on_device(GPUPrimType prim_type, uint prim_len);
+ void init_build_on_device(uint index_len);
uint32_t index_len_get(void) const
{
diff --git a/source/blender/gpu/opengl/gl_index_buffer.cc b/source/blender/gpu/opengl/gl_index_buffer.cc
index 11822176bce..e74ea45fd21 100644
--- a/source/blender/gpu/opengl/gl_index_buffer.cc
+++ b/source/blender/gpu/opengl/gl_index_buffer.cc
@@ -68,7 +68,7 @@ uint32_t *GLIndexBuf::read() const
BLI_assert(is_active());
size_t size = size_get();
uint32_t *result = static_cast<uint32_t *>(MEM_mallocN(size, __func__));
- void *data = glMapBuffer(GL_ARRAY_BUFFER, GL_READ_ONLY);
+ void *data = glMapBuffer(GL_ELEMENT_ARRAY_BUFFER, GL_READ_ONLY);
memcpy(result, data, size);
return result;
}
diff --git a/source/blender/gpu/tests/gpu_shader_test.cc b/source/blender/gpu/tests/gpu_shader_test.cc
index daa9c112060..75787e1e83f 100644
--- a/source/blender/gpu/tests/gpu_shader_test.cc
+++ b/source/blender/gpu/tests/gpu_shader_test.cc
@@ -237,7 +237,7 @@ void main() {
GPU_shader_bind(shader);
/* Construct IBO. */
- GPUIndexBuf *ibo = GPU_indexbuf_build_on_device(GPU_PRIM_POINTS, SIZE);
+ GPUIndexBuf *ibo = GPU_indexbuf_build_on_device(SIZE);
GPU_indexbuf_bind_as_ssbo(ibo, GPU_shader_get_ssbo(shader, "outputIboData"));
/* Dispatch compute task. */
More information about the Bf-blender-cvs
mailing list