[Bf-blender-cvs] [28ea459a61f] master: GPUState: Encapsulate glPixelStorei inside the GLStateManager

Clément Foucault noreply at git.blender.org
Tue Sep 8 04:15:56 CEST 2020


Commit: 28ea459a61f65de03724db8709271d41f6bf135b
Author: Clément Foucault
Date:   Tue Sep 8 00:30:38 2020 +0200
Branches: master
https://developer.blender.org/rB28ea459a61f65de03724db8709271d41f6bf135b

GPUState: Encapsulate glPixelStorei inside the GLStateManager

Part of the Vulkan task T68990

Isolate the last remaining gl functions.

===================================================================

M	source/blender/gpu/GPU_state.h
M	source/blender/gpu/GPU_texture.h
M	source/blender/gpu/intern/gpu_state.cc
M	source/blender/gpu/intern/gpu_state_private.hh
M	source/blender/gpu/intern/gpu_texture.cc
M	source/blender/gpu/opengl/gl_state.cc
M	source/blender/gpu/opengl/gl_state.hh

===================================================================

diff --git a/source/blender/gpu/GPU_state.h b/source/blender/gpu/GPU_state.h
index 869e8c32861..5e872001267 100644
--- a/source/blender/gpu/GPU_state.h
+++ b/source/blender/gpu/GPU_state.h
@@ -128,7 +128,6 @@ void GPU_write_mask(eGPUWriteMask mask);
 void GPU_color_mask(bool r, bool g, bool b, bool a);
 void GPU_depth_mask(bool depth);
 bool GPU_depth_mask_get(void);
-void GPU_unpack_row_length_set(uint len);
 void GPU_shadow_offset(bool enable);
 void GPU_clip_distances(int distances_enabled);
 bool GPU_mipmap_enabled(void);
diff --git a/source/blender/gpu/GPU_texture.h b/source/blender/gpu/GPU_texture.h
index bae5bfbaae8..b31cb42d38d 100644
--- a/source/blender/gpu/GPU_texture.h
+++ b/source/blender/gpu/GPU_texture.h
@@ -228,6 +228,7 @@ void GPU_texture_update_sub(GPUTexture *tex,
                             int width,
                             int height,
                             int depth);
+void GPU_unpack_row_length_set(uint len);
 
 void *GPU_texture_read(GPUTexture *tex, eGPUDataFormat data_format, int miplvl);
 void GPU_texture_clear(GPUTexture *tex, eGPUDataFormat data_format, const void *data);
diff --git a/source/blender/gpu/intern/gpu_state.cc b/source/blender/gpu/intern/gpu_state.cc
index a88dc1beb00..68f0c290bc6 100644
--- a/source/blender/gpu/intern/gpu_state.cc
+++ b/source/blender/gpu/intern/gpu_state.cc
@@ -303,11 +303,6 @@ void GPU_finish(void)
   GPU_context_active_get()->finish();
 }
 
-void GPU_unpack_row_length_set(uint len)
-{
-  glPixelStorei(GL_UNPACK_ROW_LENGTH, len);
-}
-
 /** \} */
 
 /* -------------------------------------------------------------------- */
diff --git a/source/blender/gpu/intern/gpu_state_private.hh b/source/blender/gpu/intern/gpu_state_private.hh
index 6ce240df108..9fee45e7bd4 100644
--- a/source/blender/gpu/intern/gpu_state_private.hh
+++ b/source/blender/gpu/intern/gpu_state_private.hh
@@ -166,6 +166,8 @@ class GPUStateManager {
   virtual void texture_bind(Texture *tex, eGPUSamplerState sampler, int unit) = 0;
   virtual void texture_unbind(Texture *tex) = 0;
   virtual void texture_unbind_all(void) = 0;
+
+  virtual void texture_unpack_row_length_set(uint len) = 0;
 };
 
 }  // namespace gpu
diff --git a/source/blender/gpu/intern/gpu_texture.cc b/source/blender/gpu/intern/gpu_texture.cc
index 0aa1a6553f9..95f922173b5 100644
--- a/source/blender/gpu/intern/gpu_texture.cc
+++ b/source/blender/gpu/intern/gpu_texture.cc
@@ -380,6 +380,13 @@ void GPU_texture_update(GPUTexture *tex, eGPUDataFormat data_format, const void
   reinterpret_cast<Texture *>(tex)->update(data_format, data);
 }
 
+/* Makes data interpretation aware of the source layout.
+ * Skipping pixels correctly when changing rows when doing partial update.*/
+void GPU_unpack_row_length_set(uint len)
+{
+  GPU_context_active_get()->state_manager->texture_unpack_row_length_set(len);
+}
+
 void GPU_invalid_tex_init(void)
 {
   /* TODO remove */
diff --git a/source/blender/gpu/opengl/gl_state.cc b/source/blender/gpu/opengl/gl_state.cc
index b43b01aed4f..6dcb56288e8 100644
--- a/source/blender/gpu/opengl/gl_state.cc
+++ b/source/blender/gpu/opengl/gl_state.cc
@@ -520,6 +520,11 @@ void GLStateManager::texture_bind_apply(void)
   }
 }
 
+void GLStateManager::texture_unpack_row_length_set(uint len)
+{
+  glPixelStorei(GL_UNPACK_ROW_LENGTH, len);
+}
+
 uint64_t GLStateManager::bound_texture_slots(void)
 {
   uint64_t bound_slots = 0;
diff --git a/source/blender/gpu/opengl/gl_state.hh b/source/blender/gpu/opengl/gl_state.hh
index d5622b4ab89..db9b9721ad5 100644
--- a/source/blender/gpu/opengl/gl_state.hh
+++ b/source/blender/gpu/opengl/gl_state.hh
@@ -74,6 +74,8 @@ class GLStateManager : public GPUStateManager {
   void texture_unbind(Texture *tex) override;
   void texture_unbind_all(void) override;
 
+  void texture_unpack_row_length_set(uint len) override;
+
   uint64_t bound_texture_slots(void);
 
  private:



More information about the Bf-blender-cvs mailing list