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>2020-09-05 18:29:51 +0300
committerClément Foucault <foucault.clem@gmail.com>2020-09-05 18:49:14 +0300
commitc766d9b9dc5661693a58e01a3637f15197c2fe59 (patch)
tree6905f0fc085af0eff5cfdf74d87c4ebed412e741 /source/blender/gpu/opengl/gl_state.hh
parentdb21c12abedd7606a3aaf50f70e506a24d9f0e7a (diff)
GPUTexture: GL Backend Isolation
This is a massive cleanup needed for vulkan support T68990. It provides: - More meaningful enums with conversion functions. - Less hacky supports of arrays and cubemaps (all considered layered). - More inline with the stateless design of vulkan and modern GL. - Methods Fallbacks are using framebuffer functions that are wrapped instead of implementing inside the texture module. What is not in there: - API change. - Samplers support (breaks a few effects). # Conflicts: # source/blender/gpu/GPU_texture.h
Diffstat (limited to 'source/blender/gpu/opengl/gl_state.hh')
-rw-r--r--source/blender/gpu/opengl/gl_state.hh22
1 files changed, 22 insertions, 0 deletions
diff --git a/source/blender/gpu/opengl/gl_state.hh b/source/blender/gpu/opengl/gl_state.hh
index c25e384fcd7..2befad690f0 100644
--- a/source/blender/gpu/opengl/gl_state.hh
+++ b/source/blender/gpu/opengl/gl_state.hh
@@ -20,6 +20,8 @@
* \ingroup gpu
*/
+#pragma once
+
#include "MEM_guardedalloc.h"
#include "BLI_utildefines.h"
@@ -32,6 +34,7 @@ namespace blender {
namespace gpu {
class GLFrameBuffer;
+class GLTexture;
/**
* State manager keeping track of the draw state and applying it before drawing.
@@ -49,11 +52,28 @@ class GLStateManager : public GPUStateManager {
/** Limits. */
float line_width_range_[2];
+ /** Texture state:
+ * We keep the full stack of textures and sampler bounds to use multi bind, and to be able to
+ * edit and restore texture binds on the fly without querying the context.
+ * Also this allows us to keep track of textures bounds to many texture units.
+ * Keep the targets to know what target to set to 0 for unbinding (legacy).
+ * Init first target to GL_TEXTURE_2D for texture_bind_temp to work.
+ */
+ GLuint targets_[64] = {GL_TEXTURE_2D};
+ GLuint textures_[64] = {0};
+ GLuint samplers_[64] = {0};
+ uint64_t dirty_texture_binds_ = 0;
+
public:
GLStateManager();
void apply_state(void) override;
+ void texture_bind(Texture *tex, eGPUSamplerState sampler, int unit) override;
+ void texture_bind_temp(GLTexture *tex);
+ void texture_unbind(Texture *tex) override;
+ void texture_unbind_all(void) override;
+
private:
static void set_write_mask(const eGPUWriteMask value);
static void set_depth_test(const eGPUDepthTest value);
@@ -70,6 +90,8 @@ class GLStateManager : public GPUStateManager {
void set_state(const GPUState &state);
void set_mutable_state(const GPUStateMutable &state);
+ void texture_bind_apply(void);
+
MEM_CXX_CLASS_ALLOC_FUNCS("GLStateManager")
};