[Bf-blender-cvs] [c6abbb4] blender2.8: Gawain: closer integration of immediate mode & matrix APIs
Mike Erwin
noreply at git.blender.org
Thu Oct 20 20:50:55 CEST 2016
Commit: c6abbb40ad8e62a74c992ca02b8bc85171b6af8e
Author: Mike Erwin
Date: Thu Oct 20 14:29:59 2016 -0400
Branches: blender2.8
https://developer.blender.org/rBc6abbb40ad8e62a74c992ca02b8bc85171b6af8e
Gawain: closer integration of immediate mode & matrix APIs
- any shader program can use matrix state (not only built-in shaders)
- you can mix matrix & begin/end calls, and the bound shader will use the latest matrix state
Part of T49450 & T49043
===================================================================
M source/blender/gpu/gawain/immediate.c
M source/blender/gpu/intern/gpu_immediate.c
===================================================================
diff --git a/source/blender/gpu/gawain/immediate.c b/source/blender/gpu/gawain/immediate.c
index 30c82fd..7c3edc2 100644
--- a/source/blender/gpu/gawain/immediate.c
+++ b/source/blender/gpu/gawain/immediate.c
@@ -13,6 +13,10 @@
#include "attrib_binding.h"
#include <string.h>
+// necessary functions from matrix API
+extern void gpuBindMatrices(GLuint program);
+extern bool gpuMatricesDirty(void);
+
typedef struct {
// TODO: organize this struct by frequency of change (run-time)
@@ -116,6 +120,7 @@ void immBindProgram(GLuint program)
{
#if TRUST_NO_ONE
assert(imm.bound_program == 0);
+ assert(glIsProgram(program));
#endif
if (!imm.vertex_format.packed)
@@ -124,6 +129,8 @@ void immBindProgram(GLuint program)
glUseProgram(program);
get_attrib_locations(&imm.vertex_format, &imm.attrib_binding, program);
imm.bound_program = program;
+
+ gpuBindMatrices(program);
}
void immUnbindProgram()
@@ -326,6 +333,9 @@ static void immDrawSetup(void)
glVertexAttribIPointer(loc, a->comp_ct, a->comp_type, stride, pointer);
}
}
+
+ if (gpuMatricesDirty())
+ gpuBindMatrices(imm.bound_program);
}
void immEnd()
diff --git a/source/blender/gpu/intern/gpu_immediate.c b/source/blender/gpu/intern/gpu_immediate.c
index 711afda..0706c74 100644
--- a/source/blender/gpu/intern/gpu_immediate.c
+++ b/source/blender/gpu/intern/gpu_immediate.c
@@ -35,7 +35,6 @@ void immBindBuiltinProgram(GPUBuiltinShader shader_id)
{
GPUShader *shader = GPU_shader_get_builtin_shader(shader_id);
immBindProgram(shader->program);
- gpuBindMatrices(shader->program);
}
void immUniformThemeColor(int color_id)
More information about the Bf-blender-cvs
mailing list