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:
Diffstat (limited to 'intern/gawain/src')
-rw-r--r--intern/gawain/src/gwn_attr_binding.c (renamed from intern/gawain/src/attrib_binding.c)4
-rw-r--r--intern/gawain/src/gwn_batch.c (renamed from intern/gawain/src/batch.c)58
-rw-r--r--intern/gawain/src/gwn_buffer_id.cpp (renamed from intern/gawain/src/buffer_id.cpp)2
-rw-r--r--intern/gawain/src/gwn_element.c (renamed from intern/gawain/src/element.c)4
-rw-r--r--intern/gawain/src/gwn_imm_util.c (renamed from intern/gawain/src/imm_util.c)4
-rw-r--r--intern/gawain/src/gwn_immediate.c (renamed from intern/gawain/src/immediate.c)12
-rw-r--r--intern/gawain/src/gwn_primitive.c (renamed from intern/gawain/src/primitive.c)4
-rw-r--r--intern/gawain/src/gwn_shader_interface.c (renamed from intern/gawain/src/shader_interface.c)2
-rw-r--r--intern/gawain/src/gwn_vertex_buffer.c (renamed from intern/gawain/src/vertex_buffer.c)6
-rw-r--r--intern/gawain/src/gwn_vertex_format.c (renamed from intern/gawain/src/vertex_format.c)4
10 files changed, 57 insertions, 43 deletions
diff --git a/intern/gawain/src/attrib_binding.c b/intern/gawain/src/gwn_attr_binding.c
index 6cdb8a0e542..7647a927b1e 100644
--- a/intern/gawain/src/attrib_binding.c
+++ b/intern/gawain/src/gwn_attr_binding.c
@@ -9,8 +9,8 @@
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of
// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
-#include "attrib_binding.h"
-#include "attrib_binding_private.h"
+#include "gwn_attr_binding.h"
+#include "gwn_attr_binding_private.h"
#include <stddef.h>
#if GWN_VERT_ATTR_MAX_LEN != 16
diff --git a/intern/gawain/src/batch.c b/intern/gawain/src/gwn_batch.c
index 22a5aab48b4..359ca956495 100644
--- a/intern/gawain/src/batch.c
+++ b/intern/gawain/src/gwn_batch.c
@@ -9,25 +9,29 @@
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of
// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
-#include "batch.h"
-#include "buffer_id.h"
-#include "primitive_private.h"
+#include "gwn_batch.h"
+#include "gwn_buffer_id.h"
+#include "gwn_primitive_private.h"
#include <stdlib.h>
// necessary functions from matrix API
extern void gpuBindMatrices(const Gwn_ShaderInterface* shaderface);
extern bool gpuMatricesDirty(void); // how best to use this here?
-Gwn_Batch* GWN_batch_create(Gwn_PrimType prim_type, Gwn_VertBuf* verts, Gwn_IndexBuf* elem)
+Gwn_Batch* GWN_batch_create_ex(
+ Gwn_PrimType prim_type, Gwn_VertBuf* verts, Gwn_IndexBuf* elem,
+ unsigned owns_flag)
{
Gwn_Batch* batch = calloc(1, sizeof(Gwn_Batch));
- GWN_batch_init(batch, prim_type, verts, elem);
+ GWN_batch_init_ex(batch, prim_type, verts, elem, owns_flag);
return batch;
}
-void GWN_batch_init(Gwn_Batch* batch, Gwn_PrimType prim_type, Gwn_VertBuf* verts, Gwn_IndexBuf* elem)
+void GWN_batch_init_ex(
+ Gwn_Batch* batch, Gwn_PrimType prim_type, Gwn_VertBuf* verts, Gwn_IndexBuf* elem,
+ unsigned owns_flag)
{
#if TRUST_NO_ONE
assert(verts != NULL);
@@ -40,32 +44,34 @@ void GWN_batch_init(Gwn_Batch* batch, Gwn_PrimType prim_type, Gwn_VertBuf* verts
batch->prim_type = prim_type;
batch->gl_prim_type = convert_prim_type_to_gl(prim_type);
batch->phase = GWN_BATCH_READY_TO_DRAW;
+ batch->owns_flag = owns_flag;
}
void GWN_batch_discard(Gwn_Batch* batch)
{
- if (batch->vao_id)
- GWN_vao_free(batch->vao_id);
-
- free(batch);
- }
+ if (batch->owns_flag & GWN_BATCH_OWNS_INDEX)
+ GWN_indexbuf_discard(batch->elem);
-void GWN_batch_discard_all(Gwn_Batch* batch)
- {
- for (int v = 0; v < GWN_BATCH_VBO_MAX_LEN; ++v)
+ if ((batch->owns_flag & ~GWN_BATCH_OWNS_INDEX) != 0)
{
- if (batch->verts[v] == NULL)
- break;
- GWN_vertbuf_discard(batch->verts[v]);
+ for (int v = 0; v < GWN_BATCH_VBO_MAX_LEN; ++v)
+ {
+ if (batch->verts[v] == NULL)
+ break;
+ if (batch->owns_flag & (1 << v))
+ GWN_vertbuf_discard(batch->verts[v]);
+ }
}
- if (batch->elem)
- GWN_indexbuf_discard(batch->elem);
+ if (batch->vao_id)
+ GWN_vao_free(batch->vao_id);
- GWN_batch_discard(batch);
+ free(batch);
}
-int GWN_batch_vertbuf_add(Gwn_Batch* batch, Gwn_VertBuf* verts)
+int GWN_batch_vertbuf_add_ex(
+ Gwn_Batch* batch, Gwn_VertBuf* verts,
+ bool own_vbo)
{
for (unsigned v = 0; v < GWN_BATCH_VBO_MAX_LEN; ++v)
{
@@ -78,6 +84,8 @@ int GWN_batch_vertbuf_add(Gwn_Batch* batch, Gwn_VertBuf* verts)
#endif
batch->verts[v] = verts;
// TODO: mark dirty so we can keep attrib bindings up-to-date
+ if (own_vbo)
+ batch->owns_flag |= (1 << v);
return v;
}
}
@@ -219,6 +227,12 @@ void GWN_batch_uniform_1f(Gwn_Batch* batch, const char* name, float x)
glUniform1f(uniform->location, x);
}
+void GWN_batch_uniform_2fv(Gwn_Batch* batch, const char* name, const float data[2])
+ {
+ GET_UNIFORM
+ glUniform2fv(uniform->location, 1, data);
+ }
+
void GWN_batch_uniform_3fv(Gwn_Batch* batch, const char* name, const float data[3])
{
GET_UNIFORM
@@ -446,4 +460,4 @@ void GWN_batch_draw_stupid_instanced_with_batch(Gwn_Batch* batch_instanced, Gwn_
// GWN_batch_program_use_end(batch);
glBindVertexArray(0);
- } \ No newline at end of file
+ }
diff --git a/intern/gawain/src/buffer_id.cpp b/intern/gawain/src/gwn_buffer_id.cpp
index 59a6b9c89e7..a93c3950d29 100644
--- a/intern/gawain/src/buffer_id.cpp
+++ b/intern/gawain/src/gwn_buffer_id.cpp
@@ -9,7 +9,7 @@
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of
// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.#include "buffer_id.h"
-#include "buffer_id.h"
+#include "gwn_buffer_id.h"
#include <mutex>
#include <vector>
diff --git a/intern/gawain/src/element.c b/intern/gawain/src/gwn_element.c
index ecf555fbfe8..f31b64fa232 100644
--- a/intern/gawain/src/element.c
+++ b/intern/gawain/src/gwn_element.c
@@ -9,8 +9,8 @@
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of
// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
-#include "element.h"
-#include "buffer_id.h"
+#include "gwn_element.h"
+#include "gwn_buffer_id.h"
#include <stdlib.h>
#define KEEP_SINGLE_COPY 1
diff --git a/intern/gawain/src/imm_util.c b/intern/gawain/src/gwn_imm_util.c
index b06778c9045..45d8a7036e8 100644
--- a/intern/gawain/src/imm_util.c
+++ b/intern/gawain/src/gwn_imm_util.c
@@ -9,8 +9,8 @@
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of
// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
-#include "imm_util.h"
-#include "immediate.h"
+#include "gwn_imm_util.h"
+#include "gwn_immediate.h"
void immRectf(unsigned pos, float x1, float y1, float x2, float y2)
diff --git a/intern/gawain/src/immediate.c b/intern/gawain/src/gwn_immediate.c
index 5eb5ebb8336..1c0776d1bbf 100644
--- a/intern/gawain/src/immediate.c
+++ b/intern/gawain/src/gwn_immediate.c
@@ -9,12 +9,12 @@
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of
// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
-#include "immediate.h"
-#include "buffer_id.h"
-#include "attrib_binding.h"
-#include "attrib_binding_private.h"
-#include "vertex_format_private.h"
-#include "primitive_private.h"
+#include "gwn_immediate.h"
+#include "gwn_buffer_id.h"
+#include "gwn_attr_binding.h"
+#include "gwn_attr_binding_private.h"
+#include "gwn_vertex_format_private.h"
+#include "gwn_primitive_private.h"
#include <string.h>
// necessary functions from matrix API
diff --git a/intern/gawain/src/primitive.c b/intern/gawain/src/gwn_primitive.c
index b9d92a6bdf8..b206b3ae1b3 100644
--- a/intern/gawain/src/primitive.c
+++ b/intern/gawain/src/gwn_primitive.c
@@ -9,8 +9,8 @@
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of
// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
-#include "primitive.h"
-#include "primitive_private.h"
+#include "gwn_primitive.h"
+#include "gwn_primitive_private.h"
Gwn_PrimClass GWN_primtype_class(Gwn_PrimType prim_type)
{
diff --git a/intern/gawain/src/shader_interface.c b/intern/gawain/src/gwn_shader_interface.c
index dff2c06f531..e06fde6ad14 100644
--- a/intern/gawain/src/shader_interface.c
+++ b/intern/gawain/src/gwn_shader_interface.c
@@ -9,7 +9,7 @@
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of
// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
-#include "shader_interface.h"
+#include "gwn_shader_interface.h"
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
diff --git a/intern/gawain/src/vertex_buffer.c b/intern/gawain/src/gwn_vertex_buffer.c
index 364e16a1a68..2019d7d50bc 100644
--- a/intern/gawain/src/vertex_buffer.c
+++ b/intern/gawain/src/gwn_vertex_buffer.c
@@ -9,9 +9,9 @@
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of
// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
-#include "vertex_buffer.h"
-#include "buffer_id.h"
-#include "vertex_format_private.h"
+#include "gwn_vertex_buffer.h"
+#include "gwn_buffer_id.h"
+#include "gwn_vertex_format_private.h"
#include <stdlib.h>
#include <string.h>
diff --git a/intern/gawain/src/vertex_format.c b/intern/gawain/src/gwn_vertex_format.c
index 34704db3359..d6367935703 100644
--- a/intern/gawain/src/vertex_format.c
+++ b/intern/gawain/src/gwn_vertex_format.c
@@ -9,8 +9,8 @@
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of
// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
-#include "vertex_format.h"
-#include "vertex_format_private.h"
+#include "gwn_vertex_format.h"
+#include "gwn_vertex_format_private.h"
#include <stddef.h>
#include <string.h>